From 0588e8953c66be237a9871e1aabb3c113ddd199f Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Fri, 6 May 2016 13:00:21 -0700 Subject: [PATCH 001/400] 8156088: Reintegrate 8153892: Handle unsafe access error directly in signal handler instead of going through a stub Reviewed-by: stuefe, dholmes --- hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp | 13 ---- .../src/cpu/sparc/vm/stubGenerator_sparc.cpp | 75 +------------------ .../src/cpu/x86/vm/stubGenerator_x86_32.cpp | 41 +--------- .../src/cpu/x86/vm/stubGenerator_x86_64.cpp | 46 +----------- .../src/cpu/zero/vm/stubGenerator_zero.cpp | 6 +- hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp | 16 ++-- hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp | 6 +- .../linux_aarch64/vm/os_linux_aarch64.cpp | 23 +----- .../src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp | 14 ++-- .../os_cpu/linux_sparc/vm/os_linux_sparc.cpp | 8 +- .../src/os_cpu/linux_x86/vm/os_linux_x86.cpp | 6 +- .../solaris_sparc/vm/os_solaris_sparc.cpp | 4 +- .../os_cpu/solaris_x86/vm/os_solaris_x86.cpp | 6 +- .../src/share/vm/runtime/sharedRuntime.cpp | 15 ++++ .../src/share/vm/runtime/sharedRuntime.hpp | 2 + hotspot/src/share/vm/runtime/stubRoutines.cpp | 1 - hotspot/src/share/vm/runtime/stubRoutines.hpp | 5 -- 17 files changed, 54 insertions(+), 233 deletions(-) diff --git a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp index 2eba3edacef..58222baa2fa 100644 --- a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp @@ -825,17 +825,6 @@ class StubGenerator: public StubCodeGenerator { return start; } - // The following routine generates a subroutine to throw an asynchronous - // UnknownError when an unsafe access gets a fault that could not be - // reasonably prevented by the programmer. (Example: SIGBUS/OBJERR.) - // - address generate_handler_for_unsafe_access() { - StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); - address start = __ function_entry(); - __ unimplemented("StubRoutines::handler_for_unsafe_access", 93); - return start; - } - #if !defined(PRODUCT) // Wrapper which calls oopDesc::is_oop_or_null() // Only called by MacroAssembler::verify_oop @@ -3111,8 +3100,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError), false); 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); - StubRoutines::_handler_for_unsafe_access_entry = generate_handler_for_unsafe_access(); - // support for verify_oop (must happen after universe_init) StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop(); diff --git a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp index db2c5eefac8..efac738816a 100644 --- a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,20 +64,6 @@ static const Register& Lstub_temp = L2; // ------------------------------------------------------------------------------------------------------------------------- // Stub Code definitions -static address handle_unsafe_access() { - JavaThread* thread = JavaThread::current(); - address pc = thread->saved_exception_pc(); - address npc = thread->saved_exception_npc(); - // pc is the instruction which we must emulate - // doing a no-op is fine: return garbage from the load - - // request an async exception - thread->set_pending_unsafe_access_error(); - - // return address of next instruction to execute - return npc; -} - class StubGenerator: public StubCodeGenerator { private: @@ -746,62 +732,6 @@ class StubGenerator: public StubCodeGenerator { Label _atomic_add_stub; // called from other stubs - //------------------------------------------------------------------------------------------------------------------------ - // The following routine generates a subroutine to throw an asynchronous - // UnknownError when an unsafe access gets a fault that could not be - // reasonably prevented by the programmer. (Example: SIGBUS/OBJERR.) - // - // Arguments : - // - // trapping PC: O7 - // - // Results: - // posts an asynchronous exception, skips the trapping instruction - // - - address generate_handler_for_unsafe_access() { - StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); - address start = __ pc(); - - const int preserve_register_words = (64 * 2); - Address preserve_addr(FP, (-preserve_register_words * wordSize) + STACK_BIAS); - - Register Lthread = L7_thread_cache; - int i; - - __ save_frame(0); - __ mov(G1, L1); - __ mov(G2, L2); - __ mov(G3, L3); - __ mov(G4, L4); - __ mov(G5, L5); - for (i = 0; i < 64; i += 2) { - __ stf(FloatRegisterImpl::D, as_FloatRegister(i), preserve_addr, i * wordSize); - } - - address entry_point = CAST_FROM_FN_PTR(address, handle_unsafe_access); - BLOCK_COMMENT("call handle_unsafe_access"); - __ call(entry_point, relocInfo::runtime_call_type); - __ delayed()->nop(); - - __ mov(L1, G1); - __ mov(L2, G2); - __ mov(L3, G3); - __ mov(L4, G4); - __ mov(L5, G5); - for (i = 0; i < 64; i += 2) { - __ ldf(FloatRegisterImpl::D, preserve_addr, as_FloatRegister(i), i * wordSize); - } - - __ verify_thread(); - - __ jmp(O0, 0); - __ delayed()->restore(); - - return start; - } - - // Support for uint StubRoutine::Sparc::partial_subtype_check( Klass sub, Klass super ); // Arguments : // @@ -5380,9 +5310,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError)); StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call)); - StubRoutines::_handler_for_unsafe_access_entry = - generate_handler_for_unsafe_access(); - // support for verify_oop (must happen after universe_init) StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop_subroutine(); diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp index 66a819a07f7..adcfe63b39f 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,21 +63,6 @@ const int FPU_CNTRL_WRD_MASK = 0xFFFF; // ------------------------------------------------------------------------------------------------------------------------- // Stub Code definitions -static address handle_unsafe_access() { - JavaThread* thread = JavaThread::current(); - address pc = thread->saved_exception_pc(); - // pc is the instruction which we must emulate - // doing a no-op is fine: return garbage from the load - // therefore, compute npc - address npc = Assembler::locate_next_instruction(pc); - - // request an async exception - thread->set_pending_unsafe_access_error(); - - // return address of next instruction to execute - return npc; -} - class StubGenerator: public StubCodeGenerator { private: @@ -623,27 +608,6 @@ class StubGenerator: public StubCodeGenerator { } - //--------------------------------------------------------------------------- - // The following routine generates a subroutine to throw an asynchronous - // UnknownError when an unsafe access gets a fault that could not be - // reasonably prevented by the programmer. (Example: SIGBUS/OBJERR.) - address generate_handler_for_unsafe_access() { - StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); - address start = __ pc(); - - __ push(0); // hole for return address-to-be - __ pusha(); // push registers - Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord); - BLOCK_COMMENT("call handle_unsafe_access"); - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access))); - __ movptr(next_pc, rax); // stuff next address - __ popa(); - __ ret(0); // jump to next address - - return start; - } - - //---------------------------------------------------------------------------------------------------- // Non-destructive plausibility checks for oops @@ -3865,9 +3829,6 @@ class StubGenerator: public StubCodeGenerator { // These are currently used by Solaris/Intel StubRoutines::_atomic_xchg_entry = generate_atomic_xchg(); - StubRoutines::_handler_for_unsafe_access_entry = - generate_handler_for_unsafe_access(); - // platform dependent create_control_words(); diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp index 3d8acc78947..9d3bb2d03df 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,21 +61,6 @@ const int MXCSR_MASK = 0xFFC0; // Mask out any pending exceptions // Stub Code definitions -static address handle_unsafe_access() { - JavaThread* thread = JavaThread::current(); - address pc = thread->saved_exception_pc(); - // pc is the instruction which we must emulate - // doing a no-op is fine: return garbage from the load - // therefore, compute npc - address npc = Assembler::locate_next_instruction(pc); - - // request an async exception - thread->set_pending_unsafe_access_error(); - - // return address of next instruction to execute - return npc; -} - class StubGenerator: public StubCodeGenerator { private: @@ -989,32 +974,6 @@ class StubGenerator: public StubCodeGenerator { return start; } - // The following routine generates a subroutine to throw an - // asynchronous UnknownError when an unsafe access gets a fault that - // could not be reasonably prevented by the programmer. (Example: - // SIGBUS/OBJERR.) - address generate_handler_for_unsafe_access() { - StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); - address start = __ pc(); - - __ push(0); // hole for return address-to-be - __ pusha(); // push registers - Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord); - - // FIXME: this probably needs alignment logic - - __ subptr(rsp, frame::arg_reg_save_area_bytes); - BLOCK_COMMENT("call handle_unsafe_access"); - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access))); - __ addptr(rsp, frame::arg_reg_save_area_bytes); - - __ movptr(next_pc, rax); // stuff next address - __ popa(); - __ ret(0); // jump to next address - - return start; - } - // Non-destructive plausibility checks for oops // // Arguments: @@ -5136,9 +5095,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_atomic_add_ptr_entry = generate_atomic_add_ptr(); StubRoutines::_fence_entry = generate_orderaccess_fence(); - StubRoutines::_handler_for_unsafe_access_entry = - generate_handler_for_unsafe_access(); - // platform dependent StubRoutines::x86::_get_previous_fp_entry = generate_get_previous_fp(); StubRoutines::x86::_get_previous_sp_entry = generate_get_previous_sp(); diff --git a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp index bdaec67cd73..9d64fb99e94 100644 --- a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp +++ b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2010, 2015 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -261,10 +261,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_atomic_add_entry = ShouldNotCallThisStub(); StubRoutines::_atomic_add_ptr_entry = ShouldNotCallThisStub(); StubRoutines::_fence_entry = ShouldNotCallThisStub(); - - // amd64 does this here, sparc does it in generate_all() - StubRoutines::_handler_for_unsafe_access_entry = - ShouldNotCallThisStub(); } void generate_all() { diff --git a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp index 824d4d7a820..211a2dc3323 100644 --- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp +++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp @@ -392,11 +392,9 @@ JVM_handle_aix_signal(int sig, siginfo_t* info, void* ucVoid, int abort_if_unrec CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { - // We don't really need a stub here! Just set the pending exeption and - // continue at the next instruction after the faulting read. Returning - // garbage from this read is ok. - thread->set_pending_unsafe_access_error(); - os::Aix::ucontext_set_pc(uc, pc + 4); + address next_pc = pc + 4; + next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); + os::Aix::ucontext_set_pc(uc, next_pc); return 1; } } @@ -415,11 +413,9 @@ JVM_handle_aix_signal(int sig, siginfo_t* info, void* ucVoid, int abort_if_unrec } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && thread->doing_unsafe_access()) { - // We don't really need a stub here! Just set the pending exeption and - // continue at the next instruction after the faulting read. Returning - // garbage from this read is ok. - thread->set_pending_unsafe_access_error(); - os::Aix::ucontext_set_pc(uc, pc + 4); + address next_pc = pc + 4; + next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); + os::Aix::ucontext_set_pc(uc, next_pc); return 1; } } diff --git a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp index 911dfe50fed..9fe34fc1770 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp +++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp @@ -584,7 +584,8 @@ JVM_handle_bsd_signal(int sig, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + address next_pc = Assembler::locate_next_instruction(pc); + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } } else @@ -655,7 +656,8 @@ JVM_handle_bsd_signal(int sig, } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && /* info->si_code == BUS_OBJERR && */ thread->doing_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + address next_pc = Assembler::locate_next_instruction(pc); + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } // jni_fast_GetField can trap at certain pc's if a GC kicks in diff --git a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp index e6070b63dd6..04179925e67 100644 --- a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp +++ b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp @@ -226,23 +226,6 @@ extern "C" void FetchNPFI () ; extern "C" void FetchNResume () ; #endif -// An operation in Unsafe has faulted. We're going to return to the -// instruction after the faulting load or store. We also set -// pending_unsafe_access_error so that at some point in the future our -// user will get a helpful message. -static address handle_unsafe_access(JavaThread* thread, address pc) { - // pc is the instruction which we must emulate - // doing a no-op is fine: return garbage from the load - // therefore, compute npc - address npc = pc + NativeCall::instruction_size; - - // request an async exception - thread->set_pending_unsafe_access_error(); - - // return address of next instruction to execute - return npc; -} - extern "C" JNIEXPORT int JVM_handle_linux_signal(int sig, siginfo_t* info, @@ -387,7 +370,8 @@ JVM_handle_linux_signal(int sig, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { - stub = handle_unsafe_access(thread, pc); + address next_pc = pc + NativeCall::instruction_size; + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } } else @@ -408,7 +392,8 @@ JVM_handle_linux_signal(int sig, } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && /* info->si_code == BUS_OBJERR && */ thread->doing_unsafe_access()) { - stub = handle_unsafe_access(thread, pc); + address next_pc = pc + NativeCall::instruction_size; + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } // jni_fast_GetField can trap at certain pc's if a GC kicks in diff --git a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp index 7ecf0ad8263..8cd04dce290 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp @@ -366,11 +366,9 @@ JVM_handle_linux_signal(int sig, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { - // We don't really need a stub here! Just set the pending exeption and - // continue at the next instruction after the faulting read. Returning - // garbage from this read is ok. - thread->set_pending_unsafe_access_error(); - os::Linux::ucontext_set_pc(uc, pc + 4); + address next_pc = pc + 4; + next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); + os::Linux::ucontext_set_pc(uc, next_pc); return true; } } @@ -385,10 +383,8 @@ JVM_handle_linux_signal(int sig, } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && thread->doing_unsafe_access()) { - // We don't really need a stub here! Just set the pending exeption and - // continue at the next instruction after the faulting read. Returning - // garbage from this read is ok. - thread->set_pending_unsafe_access_error(); + address next_pc = pc + 4; + next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); os::Linux::ucontext_set_pc(uc, pc + 4); return true; } diff --git a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp index 4f83c606600..4a0da12c498 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp @@ -433,14 +433,14 @@ inline static bool checkPollingPage(address pc, address fault, address* stub) { return false; } -inline static bool checkByteBuffer(address pc, address* stub) { +inline static bool checkByteBuffer(address pc, address npc, address* stub) { // BugId 4454115: A read from a MappedByteBuffer can fault // here if the underlying file has been truncated. // Do not crash the VM in such a case. CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { - *stub = StubRoutines::handler_for_unsafe_access(); + *stub = SharedRuntime::handle_unsafe_access(thread, npc); return true; } return false; @@ -613,7 +613,7 @@ JVM_handle_linux_signal(int sig, if (sig == SIGBUS && thread->thread_state() == _thread_in_vm && thread->doing_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + stub = SharedRuntime::handle_unsafe_access(thread, npc); } if (thread->thread_state() == _thread_in_Java) { @@ -625,7 +625,7 @@ JVM_handle_linux_signal(int sig, break; } - if ((sig == SIGBUS) && checkByteBuffer(pc, &stub)) { + if ((sig == SIGBUS) && checkByteBuffer(pc, npc, &stub)) { break; } diff --git a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp index 7d7aad54046..b73658ed036 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp +++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp @@ -420,7 +420,8 @@ JVM_handle_linux_signal(int sig, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + address next_pc = Assembler::locate_next_instruction(pc); + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } } else @@ -469,7 +470,8 @@ JVM_handle_linux_signal(int sig, } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && /* info->si_code == BUS_OBJERR && */ thread->doing_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + address next_pc = Assembler::locate_next_instruction(pc); + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } // jni_fast_GetField can trap at certain pc's if a GC kicks in diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp index 0fd9adf3c03..39663ed0e74 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp @@ -441,7 +441,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, if (thread->thread_state() == _thread_in_vm) { if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + stub = SharedRuntime::handle_unsafe_access(thread, npc); } } @@ -480,7 +480,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + stub = SharedRuntime::handle_unsafe_access(thread, npc); } } diff --git a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp index d1bc192646d..695fc127835 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp @@ -503,7 +503,8 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, if (thread->thread_state() == _thread_in_vm) { if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + address next_pc = Assembler::locate_next_instruction(pc); + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } } @@ -520,7 +521,8 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, if (cb != NULL) { CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + address next_pc = Assembler::locate_next_instruction(pc); + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } } } diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index 0824a8a56df..4e0aec4a423 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -1762,6 +1762,21 @@ methodHandle SharedRuntime::reresolve_call_site(JavaThread *thread, TRAPS) { return callee_method; } +address SharedRuntime::handle_unsafe_access(JavaThread* thread, address next_pc) { + // The faulting unsafe accesses should be changed to throw the error + // synchronously instead. Meanwhile the faulting instruction will be + // skipped over (effectively turning it into a no-op) and an + // asynchronous exception will be raised which the thread will + // handle at a later point. If the instruction is a load it will + // return garbage. + + // Request an async exception. + thread->set_pending_unsafe_access_error(); + + // Return address of next instruction to execute. + return next_pc; +} + #ifdef ASSERT void SharedRuntime::check_member_name_argument_is_last_argument(const methodHandle& method, const BasicType* sig_bt, diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.hpp b/hotspot/src/share/vm/runtime/sharedRuntime.hpp index 52bca29cf72..eb9797f26f5 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp @@ -522,6 +522,8 @@ class SharedRuntime: AllStatic { static address handle_wrong_method_abstract(JavaThread* thread); static address handle_wrong_method_ic_miss(JavaThread* thread); + static address handle_unsafe_access(JavaThread* thread, address next_pc); + #ifndef PRODUCT // Collect and print inline cache miss statistics diff --git a/hotspot/src/share/vm/runtime/stubRoutines.cpp b/hotspot/src/share/vm/runtime/stubRoutines.cpp index 8a8f0fd4762..12e0e3a5b82 100644 --- a/hotspot/src/share/vm/runtime/stubRoutines.cpp +++ b/hotspot/src/share/vm/runtime/stubRoutines.cpp @@ -55,7 +55,6 @@ address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL; address StubRoutines::_throw_NullPointerException_at_call_entry = NULL; address StubRoutines::_throw_StackOverflowError_entry = NULL; address StubRoutines::_throw_delayed_StackOverflowError_entry = NULL; -address StubRoutines::_handler_for_unsafe_access_entry = NULL; jint StubRoutines::_verify_oop_count = 0; address StubRoutines::_verify_oop_subroutine_entry = NULL; address StubRoutines::_atomic_xchg_entry = NULL; diff --git a/hotspot/src/share/vm/runtime/stubRoutines.hpp b/hotspot/src/share/vm/runtime/stubRoutines.hpp index 49f3550c273..729886f04fd 100644 --- a/hotspot/src/share/vm/runtime/stubRoutines.hpp +++ b/hotspot/src/share/vm/runtime/stubRoutines.hpp @@ -111,7 +111,6 @@ class StubRoutines: AllStatic { static address _throw_NullPointerException_at_call_entry; static address _throw_StackOverflowError_entry; static address _throw_delayed_StackOverflowError_entry; - static address _handler_for_unsafe_access_entry; static address _atomic_xchg_entry; static address _atomic_xchg_ptr_entry; @@ -288,10 +287,6 @@ class StubRoutines: AllStatic { static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; } static address throw_delayed_StackOverflowError_entry() { return _throw_delayed_StackOverflowError_entry; } - // Exceptions during unsafe access - should throw Java exception rather - // than crash. - static address handler_for_unsafe_access() { return _handler_for_unsafe_access_entry; } - static address atomic_xchg_entry() { return _atomic_xchg_entry; } static address atomic_xchg_ptr_entry() { return _atomic_xchg_ptr_entry; } static address atomic_store_entry() { return _atomic_store_entry; } -- GitLab From e9b0eedbc77a2a5ab998723edbc9fcea7372dac7 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Fri, 6 May 2016 15:41:08 -0700 Subject: [PATCH 002/400] 8156480: Quarantine compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java Reviewed-by: dcubed --- .../compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java index 154c3b28bd2..14e53044357 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java @@ -24,6 +24,7 @@ /* * @test * @bug 8136421 + * @ignore 8155216 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches -- GitLab From fd9f92e18de45f899f0b14b6f0a175e796cd8479 Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Fri, 6 May 2016 15:59:26 -0700 Subject: [PATCH 003/400] 8150921: Update Unsafe getters/setters to use double-register variants Reviewed-by: dholmes, shade, psandoz, jrose --- hotspot/src/share/vm/c1/c1_Compiler.cpp | 14 - hotspot/src/share/vm/c1/c1_GraphBuilder.cpp | 14 - hotspot/src/share/vm/classfile/vmSymbols.cpp | 16 - hotspot/src/share/vm/classfile/vmSymbols.hpp | 37 --- hotspot/src/share/vm/opto/c2compiler.cpp | 16 - hotspot/src/share/vm/opto/library_call.cpp | 271 +++++++--------- hotspot/src/share/vm/prims/unsafe.cpp | 309 +++++++++---------- 7 files changed, 260 insertions(+), 417 deletions(-) diff --git a/hotspot/src/share/vm/c1/c1_Compiler.cpp b/hotspot/src/share/vm/c1/c1_Compiler.cpp index 4903ab682f3..c3a55b4f1f7 100644 --- a/hotspot/src/share/vm/c1/c1_Compiler.cpp +++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp @@ -198,20 +198,6 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) { case vmIntrinsics::_putLongVolatile: case vmIntrinsics::_putFloatVolatile: case vmIntrinsics::_putDoubleVolatile: - case vmIntrinsics::_getByte_raw: - case vmIntrinsics::_getShort_raw: - case vmIntrinsics::_getChar_raw: - case vmIntrinsics::_getInt_raw: - case vmIntrinsics::_getLong_raw: - case vmIntrinsics::_getFloat_raw: - case vmIntrinsics::_getDouble_raw: - case vmIntrinsics::_putByte_raw: - case vmIntrinsics::_putShort_raw: - case vmIntrinsics::_putChar_raw: - case vmIntrinsics::_putInt_raw: - case vmIntrinsics::_putLong_raw: - case vmIntrinsics::_putFloat_raw: - case vmIntrinsics::_putDouble_raw: case vmIntrinsics::_getShortUnaligned: case vmIntrinsics::_getCharUnaligned: case vmIntrinsics::_getIntUnaligned: diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index 2b4d36300a1..69d475ac939 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -3465,20 +3465,6 @@ void GraphBuilder::build_graph_for_intrinsic(ciMethod* callee) { case vmIntrinsics::_putLongVolatile : append_unsafe_put_obj(callee, T_LONG, true); return; case vmIntrinsics::_putFloatVolatile : append_unsafe_put_obj(callee, T_FLOAT, true); return; case vmIntrinsics::_putDoubleVolatile : append_unsafe_put_obj(callee, T_DOUBLE, true); return; - case vmIntrinsics::_getByte_raw : append_unsafe_get_raw(callee, T_BYTE ); return; - case vmIntrinsics::_getShort_raw : append_unsafe_get_raw(callee, T_SHORT ); return; - case vmIntrinsics::_getChar_raw : append_unsafe_get_raw(callee, T_CHAR ); return; - case vmIntrinsics::_getInt_raw : append_unsafe_get_raw(callee, T_INT ); return; - case vmIntrinsics::_getLong_raw : append_unsafe_get_raw(callee, T_LONG ); return; - case vmIntrinsics::_getFloat_raw : append_unsafe_get_raw(callee, T_FLOAT ); return; - case vmIntrinsics::_getDouble_raw : append_unsafe_get_raw(callee, T_DOUBLE); return; - case vmIntrinsics::_putByte_raw : append_unsafe_put_raw(callee, T_BYTE ); return; - case vmIntrinsics::_putShort_raw : append_unsafe_put_raw(callee, T_SHORT ); return; - case vmIntrinsics::_putChar_raw : append_unsafe_put_raw(callee, T_CHAR ); return; - case vmIntrinsics::_putInt_raw : append_unsafe_put_raw(callee, T_INT ); return; - case vmIntrinsics::_putLong_raw : append_unsafe_put_raw(callee, T_LONG ); return; - case vmIntrinsics::_putFloat_raw : append_unsafe_put_raw(callee, T_FLOAT ); return; - case vmIntrinsics::_putDouble_raw : append_unsafe_put_raw(callee, T_DOUBLE); return; case vmIntrinsics::_compareAndSwapLong: case vmIntrinsics::_compareAndSwapInt: case vmIntrinsics::_compareAndSwapObject: append_unsafe_CAS(callee); return; diff --git a/hotspot/src/share/vm/classfile/vmSymbols.cpp b/hotspot/src/share/vm/classfile/vmSymbols.cpp index 42555054305..4c46cb98780 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.cpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp @@ -578,20 +578,6 @@ bool vmIntrinsics::is_disabled_by_flags(const methodHandle& method) { case vmIntrinsics::_putLongOpaque: case vmIntrinsics::_putFloatOpaque: case vmIntrinsics::_putDoubleOpaque: - case vmIntrinsics::_getByte_raw: - case vmIntrinsics::_getShort_raw: - case vmIntrinsics::_getChar_raw: - case vmIntrinsics::_getInt_raw: - case vmIntrinsics::_getLong_raw: - case vmIntrinsics::_getFloat_raw: - case vmIntrinsics::_getDouble_raw: - case vmIntrinsics::_putByte_raw: - case vmIntrinsics::_putShort_raw: - case vmIntrinsics::_putChar_raw: - case vmIntrinsics::_putInt_raw: - case vmIntrinsics::_putLong_raw: - case vmIntrinsics::_putFloat_raw: - case vmIntrinsics::_putDouble_raw: case vmIntrinsics::_getAndAddInt: case vmIntrinsics::_getAndAddLong: case vmIntrinsics::_getAndSetInt: @@ -632,8 +618,6 @@ bool vmIntrinsics::is_disabled_by_flags(const methodHandle& method) { case vmIntrinsics::_putIntUnaligned: case vmIntrinsics::_putLongUnaligned: case vmIntrinsics::_allocateInstance: - case vmIntrinsics::_getAddress_raw: - case vmIntrinsics::_putAddress_raw: if (!InlineUnsafeOps || !UseUnalignedAccesses) return true; break; case vmIntrinsics::_hashCode: diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index 6f4d4c65ee6..50db4d6a87b 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -1231,43 +1231,6 @@ do_intrinsic(_putIntUnaligned, jdk_internal_misc_Unsafe, putIntUnaligned_name, putInt_signature, F_R) \ do_intrinsic(_putLongUnaligned, jdk_internal_misc_Unsafe, putLongUnaligned_name, putLong_signature, F_R) \ \ - /* %%% these are redundant except perhaps for getAddress, but Unsafe has native methods for them */ \ - do_signature(getByte_raw_signature, "(J)B") \ - do_signature(putByte_raw_signature, "(JB)V") \ - do_signature(getShort_raw_signature, "(J)S") \ - do_signature(putShort_raw_signature, "(JS)V") \ - do_signature(getChar_raw_signature, "(J)C") \ - do_signature(putChar_raw_signature, "(JC)V") \ - do_signature(putInt_raw_signature, "(JI)V") \ - do_alias(getLong_raw_signature, /*(J)J*/ long_long_signature) \ - do_alias(putLong_raw_signature, /*(JJ)V*/ long_long_void_signature) \ - do_signature(getFloat_raw_signature, "(J)F") \ - do_signature(putFloat_raw_signature, "(JF)V") \ - do_alias(getDouble_raw_signature, /*(J)D*/ long_double_signature) \ - do_signature(putDouble_raw_signature, "(JD)V") \ - do_alias(getAddress_raw_signature, /*(J)J*/ long_long_signature) \ - do_alias(putAddress_raw_signature, /*(JJ)V*/ long_long_void_signature) \ - \ - do_name( getAddress_name, "getAddress") \ - do_name( putAddress_name, "putAddress") \ - \ - do_intrinsic(_getByte_raw, jdk_internal_misc_Unsafe, getByte_name, getByte_raw_signature, F_R) \ - do_intrinsic(_getShort_raw, jdk_internal_misc_Unsafe, getShort_name, getShort_raw_signature, F_R) \ - do_intrinsic(_getChar_raw, jdk_internal_misc_Unsafe, getChar_name, getChar_raw_signature, F_R) \ - do_intrinsic(_getInt_raw, jdk_internal_misc_Unsafe, getInt_name, long_int_signature, F_R) \ - do_intrinsic(_getLong_raw, jdk_internal_misc_Unsafe, getLong_name, getLong_raw_signature, F_R) \ - do_intrinsic(_getFloat_raw, jdk_internal_misc_Unsafe, getFloat_name, getFloat_raw_signature, F_R) \ - do_intrinsic(_getDouble_raw, jdk_internal_misc_Unsafe, getDouble_name, getDouble_raw_signature, F_R) \ - do_intrinsic(_getAddress_raw, jdk_internal_misc_Unsafe, getAddress_name, getAddress_raw_signature, F_R) \ - do_intrinsic(_putByte_raw, jdk_internal_misc_Unsafe, putByte_name, putByte_raw_signature, F_R) \ - do_intrinsic(_putShort_raw, jdk_internal_misc_Unsafe, putShort_name, putShort_raw_signature, F_R) \ - do_intrinsic(_putChar_raw, jdk_internal_misc_Unsafe, putChar_name, putChar_raw_signature, F_R) \ - do_intrinsic(_putInt_raw, jdk_internal_misc_Unsafe, putInt_name, putInt_raw_signature, F_R) \ - do_intrinsic(_putLong_raw, jdk_internal_misc_Unsafe, putLong_name, putLong_raw_signature, F_R) \ - do_intrinsic(_putFloat_raw, jdk_internal_misc_Unsafe, putFloat_name, putFloat_raw_signature, F_R) \ - do_intrinsic(_putDouble_raw, jdk_internal_misc_Unsafe, putDouble_name, putDouble_raw_signature, F_R) \ - do_intrinsic(_putAddress_raw, jdk_internal_misc_Unsafe, putAddress_name, putAddress_raw_signature, F_R) \ - \ do_signature(compareAndSwapObject_signature, "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z") \ do_signature(compareAndExchangeObject_signature, "(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;") \ do_signature(compareAndSwapLong_signature, "(Ljava/lang/Object;JJJ)Z") \ diff --git a/hotspot/src/share/vm/opto/c2compiler.cpp b/hotspot/src/share/vm/opto/c2compiler.cpp index b46b3c8d30f..1480ebf8fec 100644 --- a/hotspot/src/share/vm/opto/c2compiler.cpp +++ b/hotspot/src/share/vm/opto/c2compiler.cpp @@ -409,22 +409,6 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt case vmIntrinsics::_putLong: case vmIntrinsics::_putFloat: case vmIntrinsics::_putDouble: - case vmIntrinsics::_getByte_raw: - case vmIntrinsics::_getShort_raw: - case vmIntrinsics::_getChar_raw: - case vmIntrinsics::_getInt_raw: - case vmIntrinsics::_getLong_raw: - case vmIntrinsics::_getFloat_raw: - case vmIntrinsics::_getDouble_raw: - case vmIntrinsics::_getAddress_raw: - case vmIntrinsics::_putByte_raw: - case vmIntrinsics::_putShort_raw: - case vmIntrinsics::_putChar_raw: - case vmIntrinsics::_putInt_raw: - case vmIntrinsics::_putLong_raw: - case vmIntrinsics::_putFloat_raw: - case vmIntrinsics::_putDouble_raw: - case vmIntrinsics::_putAddress_raw: case vmIntrinsics::_getObjectVolatile: case vmIntrinsics::_getBooleanVolatile: case vmIntrinsics::_getByteVolatile: diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index aca79cbc6e2..3645c7e5f84 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -93,7 +93,7 @@ class LibraryCallKit : public GraphKit { Node* _result; // the result node, if any int _reexecute_sp; // the stack pointer when bytecode needs to be reexecuted - const TypeOopPtr* sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type, bool is_native_ptr = false); + const TypeOopPtr* sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type); public: LibraryCallKit(JVMState* jvms, LibraryIntrinsic* intrinsic) @@ -247,7 +247,7 @@ class LibraryCallKit : public GraphKit { void insert_pre_barrier(Node* base_oop, Node* offset, Node* pre_val, bool need_mem_bar); typedef enum { Relaxed, Opaque, Volatile, Acquire, Release } AccessKind; - bool inline_unsafe_access(bool is_native_ptr, bool is_store, BasicType type, AccessKind kind, bool is_unaligned); + bool inline_unsafe_access(bool is_store, BasicType type, AccessKind kind, bool is_unaligned); static bool klass_needs_init_guard(Node* kls); bool inline_unsafe_allocate(); bool inline_unsafe_newArray(bool uninitialized); @@ -475,7 +475,6 @@ bool LibraryCallKit::try_to_inline(int predicate) { // Handle symbolic names for otherwise undistinguished boolean switches: const bool is_store = true; const bool is_compress = true; - const bool is_native_ptr = true; const bool is_static = true; const bool is_volatile = true; @@ -555,113 +554,95 @@ bool LibraryCallKit::try_to_inline(int predicate) { case vmIntrinsics::_inflateStringC: case vmIntrinsics::_inflateStringB: return inline_string_copy(!is_compress); - case vmIntrinsics::_getObject: return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT, Relaxed, false); - case vmIntrinsics::_getBoolean: return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN, Relaxed, false); - case vmIntrinsics::_getByte: return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE, Relaxed, false); - case vmIntrinsics::_getShort: return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT, Relaxed, false); - case vmIntrinsics::_getChar: return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR, Relaxed, false); - case vmIntrinsics::_getInt: return inline_unsafe_access(!is_native_ptr, !is_store, T_INT, Relaxed, false); - case vmIntrinsics::_getLong: return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG, Relaxed, false); - case vmIntrinsics::_getFloat: return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT, Relaxed, false); - case vmIntrinsics::_getDouble: return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE, Relaxed, false); - - case vmIntrinsics::_putObject: return inline_unsafe_access(!is_native_ptr, is_store, T_OBJECT, Relaxed, false); - case vmIntrinsics::_putBoolean: return inline_unsafe_access(!is_native_ptr, is_store, T_BOOLEAN, Relaxed, false); - case vmIntrinsics::_putByte: return inline_unsafe_access(!is_native_ptr, is_store, T_BYTE, Relaxed, false); - case vmIntrinsics::_putShort: return inline_unsafe_access(!is_native_ptr, is_store, T_SHORT, Relaxed, false); - case vmIntrinsics::_putChar: return inline_unsafe_access(!is_native_ptr, is_store, T_CHAR, Relaxed, false); - case vmIntrinsics::_putInt: return inline_unsafe_access(!is_native_ptr, is_store, T_INT, Relaxed, false); - case vmIntrinsics::_putLong: return inline_unsafe_access(!is_native_ptr, is_store, T_LONG, Relaxed, false); - case vmIntrinsics::_putFloat: return inline_unsafe_access(!is_native_ptr, is_store, T_FLOAT, Relaxed, false); - case vmIntrinsics::_putDouble: return inline_unsafe_access(!is_native_ptr, is_store, T_DOUBLE, Relaxed, false); - - case vmIntrinsics::_getByte_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_BYTE, Relaxed, false); - case vmIntrinsics::_getShort_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_SHORT, Relaxed, false); - case vmIntrinsics::_getChar_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_CHAR, Relaxed, false); - case vmIntrinsics::_getInt_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_INT, Relaxed, false); - case vmIntrinsics::_getLong_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_LONG, Relaxed, false); - case vmIntrinsics::_getFloat_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_FLOAT, Relaxed, false); - case vmIntrinsics::_getDouble_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_DOUBLE, Relaxed, false); - case vmIntrinsics::_getAddress_raw: return inline_unsafe_access( is_native_ptr, !is_store, T_ADDRESS, Relaxed, false); - - case vmIntrinsics::_putByte_raw: return inline_unsafe_access( is_native_ptr, is_store, T_BYTE, Relaxed, false); - case vmIntrinsics::_putShort_raw: return inline_unsafe_access( is_native_ptr, is_store, T_SHORT, Relaxed, false); - case vmIntrinsics::_putChar_raw: return inline_unsafe_access( is_native_ptr, is_store, T_CHAR, Relaxed, false); - case vmIntrinsics::_putInt_raw: return inline_unsafe_access( is_native_ptr, is_store, T_INT, Relaxed, false); - case vmIntrinsics::_putLong_raw: return inline_unsafe_access( is_native_ptr, is_store, T_LONG, Relaxed, false); - case vmIntrinsics::_putFloat_raw: return inline_unsafe_access( is_native_ptr, is_store, T_FLOAT, Relaxed, false); - case vmIntrinsics::_putDouble_raw: return inline_unsafe_access( is_native_ptr, is_store, T_DOUBLE, Relaxed, false); - case vmIntrinsics::_putAddress_raw: return inline_unsafe_access( is_native_ptr, is_store, T_ADDRESS, Relaxed, false); - - case vmIntrinsics::_getObjectVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT, Volatile, false); - case vmIntrinsics::_getBooleanVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN, Volatile, false); - case vmIntrinsics::_getByteVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE, Volatile, false); - case vmIntrinsics::_getShortVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT, Volatile, false); - case vmIntrinsics::_getCharVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR, Volatile, false); - case vmIntrinsics::_getIntVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_INT, Volatile, false); - case vmIntrinsics::_getLongVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG, Volatile, false); - case vmIntrinsics::_getFloatVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT, Volatile, false); - case vmIntrinsics::_getDoubleVolatile: return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE, Volatile, false); - - case vmIntrinsics::_putObjectVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_OBJECT, Volatile, false); - case vmIntrinsics::_putBooleanVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_BOOLEAN, Volatile, false); - case vmIntrinsics::_putByteVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_BYTE, Volatile, false); - case vmIntrinsics::_putShortVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_SHORT, Volatile, false); - case vmIntrinsics::_putCharVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_CHAR, Volatile, false); - case vmIntrinsics::_putIntVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_INT, Volatile, false); - case vmIntrinsics::_putLongVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_LONG, Volatile, false); - case vmIntrinsics::_putFloatVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_FLOAT, Volatile, false); - case vmIntrinsics::_putDoubleVolatile: return inline_unsafe_access(!is_native_ptr, is_store, T_DOUBLE, Volatile, false); - - case vmIntrinsics::_getShortUnaligned: return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT, Relaxed, true); - case vmIntrinsics::_getCharUnaligned: return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR, Relaxed, true); - case vmIntrinsics::_getIntUnaligned: return inline_unsafe_access(!is_native_ptr, !is_store, T_INT, Relaxed, true); - case vmIntrinsics::_getLongUnaligned: return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG, Relaxed, true); - - case vmIntrinsics::_putShortUnaligned: return inline_unsafe_access(!is_native_ptr, is_store, T_SHORT, Relaxed, true); - case vmIntrinsics::_putCharUnaligned: return inline_unsafe_access(!is_native_ptr, is_store, T_CHAR, Relaxed, true); - case vmIntrinsics::_putIntUnaligned: return inline_unsafe_access(!is_native_ptr, is_store, T_INT, Relaxed, true); - case vmIntrinsics::_putLongUnaligned: return inline_unsafe_access(!is_native_ptr, is_store, T_LONG, Relaxed, true); - - case vmIntrinsics::_getObjectAcquire: return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT, Acquire, false); - case vmIntrinsics::_getBooleanAcquire: return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN, Acquire, false); - case vmIntrinsics::_getByteAcquire: return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE, Acquire, false); - case vmIntrinsics::_getShortAcquire: return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT, Acquire, false); - case vmIntrinsics::_getCharAcquire: return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR, Acquire, false); - case vmIntrinsics::_getIntAcquire: return inline_unsafe_access(!is_native_ptr, !is_store, T_INT, Acquire, false); - case vmIntrinsics::_getLongAcquire: return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG, Acquire, false); - case vmIntrinsics::_getFloatAcquire: return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT, Acquire, false); - case vmIntrinsics::_getDoubleAcquire: return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE, Acquire, false); - - case vmIntrinsics::_putObjectRelease: return inline_unsafe_access(!is_native_ptr, is_store, T_OBJECT, Release, false); - case vmIntrinsics::_putBooleanRelease: return inline_unsafe_access(!is_native_ptr, is_store, T_BOOLEAN, Release, false); - case vmIntrinsics::_putByteRelease: return inline_unsafe_access(!is_native_ptr, is_store, T_BYTE, Release, false); - case vmIntrinsics::_putShortRelease: return inline_unsafe_access(!is_native_ptr, is_store, T_SHORT, Release, false); - case vmIntrinsics::_putCharRelease: return inline_unsafe_access(!is_native_ptr, is_store, T_CHAR, Release, false); - case vmIntrinsics::_putIntRelease: return inline_unsafe_access(!is_native_ptr, is_store, T_INT, Release, false); - case vmIntrinsics::_putLongRelease: return inline_unsafe_access(!is_native_ptr, is_store, T_LONG, Release, false); - case vmIntrinsics::_putFloatRelease: return inline_unsafe_access(!is_native_ptr, is_store, T_FLOAT, Release, false); - case vmIntrinsics::_putDoubleRelease: return inline_unsafe_access(!is_native_ptr, is_store, T_DOUBLE, Release, false); - - case vmIntrinsics::_getObjectOpaque: return inline_unsafe_access(!is_native_ptr, !is_store, T_OBJECT, Opaque, false); - case vmIntrinsics::_getBooleanOpaque: return inline_unsafe_access(!is_native_ptr, !is_store, T_BOOLEAN, Opaque, false); - case vmIntrinsics::_getByteOpaque: return inline_unsafe_access(!is_native_ptr, !is_store, T_BYTE, Opaque, false); - case vmIntrinsics::_getShortOpaque: return inline_unsafe_access(!is_native_ptr, !is_store, T_SHORT, Opaque, false); - case vmIntrinsics::_getCharOpaque: return inline_unsafe_access(!is_native_ptr, !is_store, T_CHAR, Opaque, false); - case vmIntrinsics::_getIntOpaque: return inline_unsafe_access(!is_native_ptr, !is_store, T_INT, Opaque, false); - case vmIntrinsics::_getLongOpaque: return inline_unsafe_access(!is_native_ptr, !is_store, T_LONG, Opaque, false); - case vmIntrinsics::_getFloatOpaque: return inline_unsafe_access(!is_native_ptr, !is_store, T_FLOAT, Opaque, false); - case vmIntrinsics::_getDoubleOpaque: return inline_unsafe_access(!is_native_ptr, !is_store, T_DOUBLE, Opaque, false); - - case vmIntrinsics::_putObjectOpaque: return inline_unsafe_access(!is_native_ptr, is_store, T_OBJECT, Opaque, false); - case vmIntrinsics::_putBooleanOpaque: return inline_unsafe_access(!is_native_ptr, is_store, T_BOOLEAN, Opaque, false); - case vmIntrinsics::_putByteOpaque: return inline_unsafe_access(!is_native_ptr, is_store, T_BYTE, Opaque, false); - case vmIntrinsics::_putShortOpaque: return inline_unsafe_access(!is_native_ptr, is_store, T_SHORT, Opaque, false); - case vmIntrinsics::_putCharOpaque: return inline_unsafe_access(!is_native_ptr, is_store, T_CHAR, Opaque, false); - case vmIntrinsics::_putIntOpaque: return inline_unsafe_access(!is_native_ptr, is_store, T_INT, Opaque, false); - case vmIntrinsics::_putLongOpaque: return inline_unsafe_access(!is_native_ptr, is_store, T_LONG, Opaque, false); - case vmIntrinsics::_putFloatOpaque: return inline_unsafe_access(!is_native_ptr, is_store, T_FLOAT, Opaque, false); - case vmIntrinsics::_putDoubleOpaque: return inline_unsafe_access(!is_native_ptr, is_store, T_DOUBLE, Opaque, false); + case vmIntrinsics::_getObject: return inline_unsafe_access(!is_store, T_OBJECT, Relaxed, false); + case vmIntrinsics::_getBoolean: return inline_unsafe_access(!is_store, T_BOOLEAN, Relaxed, false); + case vmIntrinsics::_getByte: return inline_unsafe_access(!is_store, T_BYTE, Relaxed, false); + case vmIntrinsics::_getShort: return inline_unsafe_access(!is_store, T_SHORT, Relaxed, false); + case vmIntrinsics::_getChar: return inline_unsafe_access(!is_store, T_CHAR, Relaxed, false); + case vmIntrinsics::_getInt: return inline_unsafe_access(!is_store, T_INT, Relaxed, false); + case vmIntrinsics::_getLong: return inline_unsafe_access(!is_store, T_LONG, Relaxed, false); + case vmIntrinsics::_getFloat: return inline_unsafe_access(!is_store, T_FLOAT, Relaxed, false); + case vmIntrinsics::_getDouble: return inline_unsafe_access(!is_store, T_DOUBLE, Relaxed, false); + + case vmIntrinsics::_putObject: return inline_unsafe_access( is_store, T_OBJECT, Relaxed, false); + case vmIntrinsics::_putBoolean: return inline_unsafe_access( is_store, T_BOOLEAN, Relaxed, false); + case vmIntrinsics::_putByte: return inline_unsafe_access( is_store, T_BYTE, Relaxed, false); + case vmIntrinsics::_putShort: return inline_unsafe_access( is_store, T_SHORT, Relaxed, false); + case vmIntrinsics::_putChar: return inline_unsafe_access( is_store, T_CHAR, Relaxed, false); + case vmIntrinsics::_putInt: return inline_unsafe_access( is_store, T_INT, Relaxed, false); + case vmIntrinsics::_putLong: return inline_unsafe_access( is_store, T_LONG, Relaxed, false); + case vmIntrinsics::_putFloat: return inline_unsafe_access( is_store, T_FLOAT, Relaxed, false); + case vmIntrinsics::_putDouble: return inline_unsafe_access( is_store, T_DOUBLE, Relaxed, false); + + case vmIntrinsics::_getObjectVolatile: return inline_unsafe_access(!is_store, T_OBJECT, Volatile, false); + case vmIntrinsics::_getBooleanVolatile: return inline_unsafe_access(!is_store, T_BOOLEAN, Volatile, false); + case vmIntrinsics::_getByteVolatile: return inline_unsafe_access(!is_store, T_BYTE, Volatile, false); + case vmIntrinsics::_getShortVolatile: return inline_unsafe_access(!is_store, T_SHORT, Volatile, false); + case vmIntrinsics::_getCharVolatile: return inline_unsafe_access(!is_store, T_CHAR, Volatile, false); + case vmIntrinsics::_getIntVolatile: return inline_unsafe_access(!is_store, T_INT, Volatile, false); + case vmIntrinsics::_getLongVolatile: return inline_unsafe_access(!is_store, T_LONG, Volatile, false); + case vmIntrinsics::_getFloatVolatile: return inline_unsafe_access(!is_store, T_FLOAT, Volatile, false); + case vmIntrinsics::_getDoubleVolatile: return inline_unsafe_access(!is_store, T_DOUBLE, Volatile, false); + + case vmIntrinsics::_putObjectVolatile: return inline_unsafe_access( is_store, T_OBJECT, Volatile, false); + case vmIntrinsics::_putBooleanVolatile: return inline_unsafe_access( is_store, T_BOOLEAN, Volatile, false); + case vmIntrinsics::_putByteVolatile: return inline_unsafe_access( is_store, T_BYTE, Volatile, false); + case vmIntrinsics::_putShortVolatile: return inline_unsafe_access( is_store, T_SHORT, Volatile, false); + case vmIntrinsics::_putCharVolatile: return inline_unsafe_access( is_store, T_CHAR, Volatile, false); + case vmIntrinsics::_putIntVolatile: return inline_unsafe_access( is_store, T_INT, Volatile, false); + case vmIntrinsics::_putLongVolatile: return inline_unsafe_access( is_store, T_LONG, Volatile, false); + case vmIntrinsics::_putFloatVolatile: return inline_unsafe_access( is_store, T_FLOAT, Volatile, false); + case vmIntrinsics::_putDoubleVolatile: return inline_unsafe_access( is_store, T_DOUBLE, Volatile, false); + + case vmIntrinsics::_getShortUnaligned: return inline_unsafe_access(!is_store, T_SHORT, Relaxed, true); + case vmIntrinsics::_getCharUnaligned: return inline_unsafe_access(!is_store, T_CHAR, Relaxed, true); + case vmIntrinsics::_getIntUnaligned: return inline_unsafe_access(!is_store, T_INT, Relaxed, true); + case vmIntrinsics::_getLongUnaligned: return inline_unsafe_access(!is_store, T_LONG, Relaxed, true); + + case vmIntrinsics::_putShortUnaligned: return inline_unsafe_access( is_store, T_SHORT, Relaxed, true); + case vmIntrinsics::_putCharUnaligned: return inline_unsafe_access( is_store, T_CHAR, Relaxed, true); + case vmIntrinsics::_putIntUnaligned: return inline_unsafe_access( is_store, T_INT, Relaxed, true); + case vmIntrinsics::_putLongUnaligned: return inline_unsafe_access( is_store, T_LONG, Relaxed, true); + + case vmIntrinsics::_getObjectAcquire: return inline_unsafe_access(!is_store, T_OBJECT, Acquire, false); + case vmIntrinsics::_getBooleanAcquire: return inline_unsafe_access(!is_store, T_BOOLEAN, Acquire, false); + case vmIntrinsics::_getByteAcquire: return inline_unsafe_access(!is_store, T_BYTE, Acquire, false); + case vmIntrinsics::_getShortAcquire: return inline_unsafe_access(!is_store, T_SHORT, Acquire, false); + case vmIntrinsics::_getCharAcquire: return inline_unsafe_access(!is_store, T_CHAR, Acquire, false); + case vmIntrinsics::_getIntAcquire: return inline_unsafe_access(!is_store, T_INT, Acquire, false); + case vmIntrinsics::_getLongAcquire: return inline_unsafe_access(!is_store, T_LONG, Acquire, false); + case vmIntrinsics::_getFloatAcquire: return inline_unsafe_access(!is_store, T_FLOAT, Acquire, false); + case vmIntrinsics::_getDoubleAcquire: return inline_unsafe_access(!is_store, T_DOUBLE, Acquire, false); + + case vmIntrinsics::_putObjectRelease: return inline_unsafe_access( is_store, T_OBJECT, Release, false); + case vmIntrinsics::_putBooleanRelease: return inline_unsafe_access( is_store, T_BOOLEAN, Release, false); + case vmIntrinsics::_putByteRelease: return inline_unsafe_access( is_store, T_BYTE, Release, false); + case vmIntrinsics::_putShortRelease: return inline_unsafe_access( is_store, T_SHORT, Release, false); + case vmIntrinsics::_putCharRelease: return inline_unsafe_access( is_store, T_CHAR, Release, false); + case vmIntrinsics::_putIntRelease: return inline_unsafe_access( is_store, T_INT, Release, false); + case vmIntrinsics::_putLongRelease: return inline_unsafe_access( is_store, T_LONG, Release, false); + case vmIntrinsics::_putFloatRelease: return inline_unsafe_access( is_store, T_FLOAT, Release, false); + case vmIntrinsics::_putDoubleRelease: return inline_unsafe_access( is_store, T_DOUBLE, Release, false); + + case vmIntrinsics::_getObjectOpaque: return inline_unsafe_access(!is_store, T_OBJECT, Opaque, false); + case vmIntrinsics::_getBooleanOpaque: return inline_unsafe_access(!is_store, T_BOOLEAN, Opaque, false); + case vmIntrinsics::_getByteOpaque: return inline_unsafe_access(!is_store, T_BYTE, Opaque, false); + case vmIntrinsics::_getShortOpaque: return inline_unsafe_access(!is_store, T_SHORT, Opaque, false); + case vmIntrinsics::_getCharOpaque: return inline_unsafe_access(!is_store, T_CHAR, Opaque, false); + case vmIntrinsics::_getIntOpaque: return inline_unsafe_access(!is_store, T_INT, Opaque, false); + case vmIntrinsics::_getLongOpaque: return inline_unsafe_access(!is_store, T_LONG, Opaque, false); + case vmIntrinsics::_getFloatOpaque: return inline_unsafe_access(!is_store, T_FLOAT, Opaque, false); + case vmIntrinsics::_getDoubleOpaque: return inline_unsafe_access(!is_store, T_DOUBLE, Opaque, false); + + case vmIntrinsics::_putObjectOpaque: return inline_unsafe_access( is_store, T_OBJECT, Opaque, false); + case vmIntrinsics::_putBooleanOpaque: return inline_unsafe_access( is_store, T_BOOLEAN, Opaque, false); + case vmIntrinsics::_putByteOpaque: return inline_unsafe_access( is_store, T_BYTE, Opaque, false); + case vmIntrinsics::_putShortOpaque: return inline_unsafe_access( is_store, T_SHORT, Opaque, false); + case vmIntrinsics::_putCharOpaque: return inline_unsafe_access( is_store, T_CHAR, Opaque, false); + case vmIntrinsics::_putIntOpaque: return inline_unsafe_access( is_store, T_INT, Opaque, false); + case vmIntrinsics::_putLongOpaque: return inline_unsafe_access( is_store, T_LONG, Opaque, false); + case vmIntrinsics::_putFloatOpaque: return inline_unsafe_access( is_store, T_FLOAT, Opaque, false); + case vmIntrinsics::_putDoubleOpaque: return inline_unsafe_access( is_store, T_DOUBLE, Opaque, false); case vmIntrinsics::_compareAndSwapObject: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap, Volatile); case vmIntrinsics::_compareAndSwapInt: return inline_unsafe_load_store(T_INT, LS_cmp_swap, Volatile); @@ -2196,8 +2177,6 @@ bool LibraryCallKit::inline_number_methods(vmIntrinsics::ID id) { //----------------------------inline_unsafe_access---------------------------- -const static BasicType T_ADDRESS_HOLDER = T_LONG; - // Helper that guards and inserts a pre-barrier. void LibraryCallKit::insert_pre_barrier(Node* base_oop, Node* offset, Node* pre_val, bool need_mem_bar) { @@ -2298,13 +2277,12 @@ void LibraryCallKit::insert_pre_barrier(Node* base_oop, Node* offset, } -const TypeOopPtr* LibraryCallKit::sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type, bool is_native_ptr) { +const TypeOopPtr* LibraryCallKit::sharpen_unsafe_type(Compile::AliasType* alias_type, const TypePtr *adr_type) { // Attempt to infer a sharper value type from the offset and base type. ciKlass* sharpened_klass = NULL; // See if it is an instance field, with an object type. if (alias_type->field() != NULL) { - assert(!is_native_ptr, "native pointer op cannot use a java address"); if (alias_type->field()->type()->is_klass()) { sharpened_klass = alias_type->field()->type()->as_klass(); } @@ -2337,7 +2315,7 @@ const TypeOopPtr* LibraryCallKit::sharpen_unsafe_type(Compile::AliasType* alias_ return NULL; } -bool LibraryCallKit::inline_unsafe_access(const bool is_native_ptr, bool is_store, const BasicType type, const AccessKind kind, const bool unaligned) { +bool LibraryCallKit::inline_unsafe_access(bool is_store, const BasicType type, const AccessKind kind, const bool unaligned) { if (callee()->is_static()) return false; // caller must have the capability! guarantee(!is_store || kind != Acquire, "Acquire accesses can be produced only for loads"); guarantee( is_store || kind != Release, "Release accesses can be produced only for stores"); @@ -2352,31 +2330,17 @@ bool LibraryCallKit::inline_unsafe_access(const bool is_native_ptr, bool is_stor if (!is_store) { // Object getObject(Object base, int/long offset), etc. BasicType rtype = sig->return_type()->basic_type(); - if (rtype == T_ADDRESS_HOLDER && callee()->name() == ciSymbol::getAddress_name()) - rtype = T_ADDRESS; // it is really a C void* assert(rtype == type, "getter must return the expected value"); - if (!is_native_ptr) { - assert(sig->count() == 2, "oop getter has 2 arguments"); - assert(sig->type_at(0)->basic_type() == T_OBJECT, "getter base is object"); - assert(sig->type_at(1)->basic_type() == T_LONG, "getter offset is correct"); - } else { - assert(sig->count() == 1, "native getter has 1 argument"); - assert(sig->type_at(0)->basic_type() == T_LONG, "getter base is long"); - } + assert(sig->count() == 2, "oop getter has 2 arguments"); + assert(sig->type_at(0)->basic_type() == T_OBJECT, "getter base is object"); + assert(sig->type_at(1)->basic_type() == T_LONG, "getter offset is correct"); } else { // void putObject(Object base, int/long offset, Object x), etc. assert(sig->return_type()->basic_type() == T_VOID, "putter must not return a value"); - if (!is_native_ptr) { - assert(sig->count() == 3, "oop putter has 3 arguments"); - assert(sig->type_at(0)->basic_type() == T_OBJECT, "putter base is object"); - assert(sig->type_at(1)->basic_type() == T_LONG, "putter offset is correct"); - } else { - assert(sig->count() == 2, "native putter has 2 arguments"); - assert(sig->type_at(0)->basic_type() == T_LONG, "putter base is long"); - } + assert(sig->count() == 3, "oop putter has 3 arguments"); + assert(sig->type_at(0)->basic_type() == T_OBJECT, "putter base is object"); + assert(sig->type_at(1)->basic_type() == T_LONG, "putter offset is correct"); BasicType vtype = sig->type_at(sig->count()-1)->basic_type(); - if (vtype == T_ADDRESS_HOLDER && callee()->name() == ciSymbol::putAddress_name()) - vtype = T_ADDRESS; // it is really a C void* assert(vtype == type, "putter must accept the expected value"); } #endif // ASSERT @@ -2393,27 +2357,22 @@ bool LibraryCallKit::inline_unsafe_access(const bool is_native_ptr, bool is_stor Node* offset = top(); Node* val; - if (!is_native_ptr) { - // The base is either a Java object or a value produced by Unsafe.staticFieldBase - Node* base = argument(1); // type: oop - // The offset is a value produced by Unsafe.staticFieldOffset or Unsafe.objectFieldOffset - offset = argument(2); // type: long - // We currently rely on the cookies produced by Unsafe.xxxFieldOffset - // to be plain byte offsets, which are also the same as those accepted - // by oopDesc::field_base. - assert(Unsafe_field_offset_to_byte_offset(11) == 11, - "fieldOffset must be byte-scaled"); - // 32-bit machines ignore the high half! - offset = ConvL2X(offset); - adr = make_unsafe_address(base, offset); + // The base is either a Java object or a value produced by Unsafe.staticFieldBase + Node* base = argument(1); // type: oop + // The offset is a value produced by Unsafe.staticFieldOffset or Unsafe.objectFieldOffset + offset = argument(2); // type: long + // We currently rely on the cookies produced by Unsafe.xxxFieldOffset + // to be plain byte offsets, which are also the same as those accepted + // by oopDesc::field_base. + assert(Unsafe_field_offset_to_byte_offset(11) == 11, + "fieldOffset must be byte-scaled"); + // 32-bit machines ignore the high half! + offset = ConvL2X(offset); + adr = make_unsafe_address(base, offset); + if (_gvn.type(base)->isa_ptr() != TypePtr::NULL_PTR) { heap_base_oop = base; - val = is_store ? argument(4) : NULL; - } else { - Node* ptr = argument(1); // type: long - ptr = ConvL2X(ptr); // adjust Java long to machine word - adr = make_unsafe_address(NULL, ptr); - val = is_store ? argument(3) : NULL; } + val = is_store ? argument(4) : NULL; const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); @@ -2494,11 +2453,11 @@ bool LibraryCallKit::inline_unsafe_access(const bool is_native_ptr, bool is_stor // SATB log buffer using the pre-barrier mechanism. // Also we need to add memory barrier to prevent commoning reads // from this field across safepoint since GC can change its value. - bool need_read_barrier = !is_native_ptr && !is_store && + bool need_read_barrier = !is_store && offset != top() && heap_base_oop != top(); if (!is_store && type == T_OBJECT) { - const TypeOopPtr* tjp = sharpen_unsafe_type(alias_type, adr_type, is_native_ptr); + const TypeOopPtr* tjp = sharpen_unsafe_type(alias_type, adr_type); if (tjp != NULL) { value_type = tjp; } diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 3b9c48558cc..71116760c07 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -131,38 +131,137 @@ jlong Unsafe_field_offset_from_byte_offset(jlong byte_offset) { } -///// Data in the Java heap. +///// Data read/writes on the Java heap and in native (off-heap) memory -#define truncate_jboolean(x) ((x) & 1) -#define truncate_jbyte(x) (x) -#define truncate_jshort(x) (x) -#define truncate_jchar(x) (x) -#define truncate_jint(x) (x) -#define truncate_jlong(x) (x) -#define truncate_jfloat(x) (x) -#define truncate_jdouble(x) (x) +/** + * Helper class for accessing memory. + * + * Normalizes values and wraps accesses in + * JavaThread::doing_unsafe_access() if needed. + */ +class MemoryAccess : StackObj { + JavaThread* _thread; + jobject _obj; + jlong _offset; + + // Resolves and returns the address of the memory access + void* addr() { + return index_oop_from_field_offset_long(JNIHandles::resolve(_obj), _offset); + } + + template + T normalize(T x) { + return x; + } + + jboolean normalize(jboolean x) { + return x & 1; + } + + /** + * Helper class to wrap memory accesses in JavaThread::doing_unsafe_access() + */ + class GuardUnsafeAccess { + JavaThread* _thread; + bool _active; + + public: + GuardUnsafeAccess(JavaThread* thread, jobject _obj) : _thread(thread) { + if (JNIHandles::resolve(_obj) == NULL) { + // native/off-heap access which may raise SIGBUS if accessing + // memory mapped file data in a region of the file which has + // been truncated and is now invalid + _thread->set_doing_unsafe_access(true); + _active = true; + } else { + _active = false; + } + } + + ~GuardUnsafeAccess() { + if (_active) { + _thread->set_doing_unsafe_access(false); + } + } + }; + +public: + MemoryAccess(JavaThread* thread, jobject obj, jlong offset) + : _thread(thread), _obj(obj), _offset(offset) { + } + + template + T get() { + GuardUnsafeAccess guard(_thread, _obj); + + T* p = (T*)addr(); + + T x = *p; + + return x; + } + + template + void put(T x) { + GuardUnsafeAccess guard(_thread, _obj); + + T* p = (T*)addr(); + + *p = normalize(x); + } + + + template + T get_volatile() { + GuardUnsafeAccess guard(_thread, _obj); + + T* p = (T*)addr(); + + if (support_IRIW_for_not_multiple_copy_atomic_cpu) { + OrderAccess::fence(); + } + + T x = OrderAccess::load_acquire((volatile T*)p); + + return x; + } + + template + void put_volatile(T x) { + GuardUnsafeAccess guard(_thread, _obj); + + T* p = (T*)addr(); + + OrderAccess::release_store_fence((volatile T*)p, normalize(x)); + } + + +#ifndef SUPPORTS_NATIVE_CX8 + jlong get_jlong_locked() { + GuardUnsafeAccess guard(_thread, _obj); + + MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag); + + jlong* p = (jlong*)addr(); + + jlong x = Atomic::load(p); -#define GET_FIELD(obj, offset, type_name, v) \ - oop p = JNIHandles::resolve(obj); \ - type_name v = *(type_name*)index_oop_from_field_offset_long(p, offset) + return x; + } -#define SET_FIELD(obj, offset, type_name, x) \ - oop p = JNIHandles::resolve(obj); \ - *(type_name*)index_oop_from_field_offset_long(p, offset) = truncate_##type_name(x) + void put_jlong_locked(jlong x) { + GuardUnsafeAccess guard(_thread, _obj); -#define GET_FIELD_VOLATILE(obj, offset, type_name, v) \ - oop p = JNIHandles::resolve(obj); \ - if (support_IRIW_for_not_multiple_copy_atomic_cpu) { \ - OrderAccess::fence(); \ - } \ - volatile type_name v = OrderAccess::load_acquire((volatile type_name*)index_oop_from_field_offset_long(p, offset)); + MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag); -#define SET_FIELD_VOLATILE(obj, offset, type_name, x) \ - oop p = JNIHandles::resolve(obj); \ - OrderAccess::release_store_fence((volatile type_name*)index_oop_from_field_offset_long(p, offset), truncate_##type_name(x)); + jlong* p = (jlong*)addr(); + Atomic::store(normalize(x), p); + } +#endif +}; -// Get/SetObject must be special-cased, since it works with handles. +// Get/PutObject must be special-cased, since it works with handles. // These functions allow a null base pointer with an arbitrary address. // But if the base pointer is non-null, the offset should make some sense. @@ -208,7 +307,7 @@ UNSAFE_ENTRY(jobject, Unsafe_GetObject(JNIEnv *env, jobject unsafe, jobject obj, return ret; } UNSAFE_END -UNSAFE_ENTRY(void, Unsafe_SetObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) { +UNSAFE_ENTRY(void, Unsafe_PutObject(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) { oop x = JNIHandles::resolve(x_h); oop p = JNIHandles::resolve(obj); @@ -236,7 +335,7 @@ UNSAFE_ENTRY(jobject, Unsafe_GetObjectVolatile(JNIEnv *env, jobject unsafe, jobj return JNIHandles::make_local(env, v); } UNSAFE_END -UNSAFE_ENTRY(void, Unsafe_SetObjectVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) { +UNSAFE_ENTRY(void, Unsafe_PutObjectVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jobject x_h)) { oop x = JNIHandles::resolve(x_h); oop p = JNIHandles::resolve(obj); void* addr = index_oop_from_field_offset_long(p, offset); @@ -301,25 +400,17 @@ UNSAFE_ENTRY(jlong, Unsafe_GetKlassPointer(JNIEnv *env, jobject unsafe, jobject UNSAFE_ENTRY(jlong, Unsafe_GetLongVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) { if (VM_Version::supports_cx8()) { - GET_FIELD_VOLATILE(obj, offset, jlong, v); - return v; + return MemoryAccess(thread, obj, offset).get_volatile(); } else { - Handle p (THREAD, JNIHandles::resolve(obj)); - jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset)); - MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag); - jlong value = Atomic::load(addr); - return value; + return MemoryAccess(thread, obj, offset).get_jlong_locked(); } } UNSAFE_END -UNSAFE_ENTRY(void, Unsafe_SetLongVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong x)) { +UNSAFE_ENTRY(void, Unsafe_PutLongVolatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong x)) { if (VM_Version::supports_cx8()) { - SET_FIELD_VOLATILE(obj, offset, jlong, x); + MemoryAccess(thread, obj, offset).put_volatile(x); } else { - Handle p (THREAD, JNIHandles::resolve(obj)); - jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset)); - MutexLockerEx mu(UnsafeJlong_lock, Mutex::_no_safepoint_check_flag); - Atomic::store(x, addr); + MemoryAccess(thread, obj, offset).put_jlong_locked(x); } } UNSAFE_END @@ -337,15 +428,14 @@ UNSAFE_LEAF(jint, Unsafe_unalignedAccess0(JNIEnv *env, jobject unsafe)) { return UseUnalignedAccesses; } UNSAFE_END -#define DEFINE_GETSETOOP(java_type, Type) \ +#define DEFINE_GETSETOOP(java_type, Type) \ \ UNSAFE_ENTRY(java_type, Unsafe_Get##Type(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) { \ - GET_FIELD(obj, offset, java_type, v); \ - return v; \ + return MemoryAccess(thread, obj, offset).get(); \ } UNSAFE_END \ \ -UNSAFE_ENTRY(void, Unsafe_Set##Type(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, java_type x)) { \ - SET_FIELD(obj, offset, java_type, x); \ +UNSAFE_ENTRY(void, Unsafe_Put##Type(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, java_type x)) { \ + MemoryAccess(thread, obj, offset).put(x); \ } UNSAFE_END \ \ // END DEFINE_GETSETOOP. @@ -364,12 +454,11 @@ DEFINE_GETSETOOP(jdouble, Double); #define DEFINE_GETSETOOP_VOLATILE(java_type, Type) \ \ UNSAFE_ENTRY(java_type, Unsafe_Get##Type##Volatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset)) { \ - GET_FIELD_VOLATILE(obj, offset, java_type, v); \ - return v; \ + return MemoryAccess(thread, obj, offset).get_volatile(); \ } UNSAFE_END \ \ -UNSAFE_ENTRY(void, Unsafe_Set##Type##Volatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, java_type x)) { \ - SET_FIELD_VOLATILE(obj, offset, java_type, x); \ +UNSAFE_ENTRY(void, Unsafe_Put##Type##Volatile(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, java_type x)) { \ + MemoryAccess(thread, obj, offset).put_volatile(x); \ } UNSAFE_END \ \ // END DEFINE_GETSETOOP_VOLATILE. @@ -400,98 +489,6 @@ UNSAFE_LEAF(void, Unsafe_FullFence(JNIEnv *env, jobject unsafe)) { OrderAccess::fence(); } UNSAFE_END -////// Data in the C heap. - -// Note: These do not throw NullPointerException for bad pointers. -// They just crash. Only a oop base pointer can generate a NullPointerException. -// -#define DEFINE_GETSETNATIVE(java_type, Type, native_type) \ - \ -UNSAFE_ENTRY(java_type, Unsafe_GetNative##Type(JNIEnv *env, jobject unsafe, jlong addr)) { \ - void* p = addr_from_java(addr); \ - JavaThread* t = JavaThread::current(); \ - t->set_doing_unsafe_access(true); \ - java_type x = *(volatile native_type*)p; \ - t->set_doing_unsafe_access(false); \ - return x; \ -} UNSAFE_END \ - \ -UNSAFE_ENTRY(void, Unsafe_SetNative##Type(JNIEnv *env, jobject unsafe, jlong addr, java_type x)) { \ - JavaThread* t = JavaThread::current(); \ - t->set_doing_unsafe_access(true); \ - void* p = addr_from_java(addr); \ - *(volatile native_type*)p = x; \ - t->set_doing_unsafe_access(false); \ -} UNSAFE_END \ - \ -// END DEFINE_GETSETNATIVE. - -DEFINE_GETSETNATIVE(jbyte, Byte, signed char) -DEFINE_GETSETNATIVE(jshort, Short, signed short); -DEFINE_GETSETNATIVE(jchar, Char, unsigned short); -DEFINE_GETSETNATIVE(jint, Int, jint); -// no long -- handled specially -DEFINE_GETSETNATIVE(jfloat, Float, float); -DEFINE_GETSETNATIVE(jdouble, Double, double); - -#undef DEFINE_GETSETNATIVE - -UNSAFE_ENTRY(jlong, Unsafe_GetNativeLong(JNIEnv *env, jobject unsafe, jlong addr)) { - JavaThread* t = JavaThread::current(); - // We do it this way to avoid problems with access to heap using 64 - // bit loads, as jlong in heap could be not 64-bit aligned, and on - // some CPUs (SPARC) it leads to SIGBUS. - t->set_doing_unsafe_access(true); - void* p = addr_from_java(addr); - jlong x; - - if (is_ptr_aligned(p, sizeof(jlong)) == 0) { - // jlong is aligned, do a volatile access - x = *(volatile jlong*)p; - } else { - jlong_accessor acc; - acc.words[0] = ((volatile jint*)p)[0]; - acc.words[1] = ((volatile jint*)p)[1]; - x = acc.long_value; - } - - t->set_doing_unsafe_access(false); - - return x; -} UNSAFE_END - -UNSAFE_ENTRY(void, Unsafe_SetNativeLong(JNIEnv *env, jobject unsafe, jlong addr, jlong x)) { - JavaThread* t = JavaThread::current(); - // see comment for Unsafe_GetNativeLong - t->set_doing_unsafe_access(true); - void* p = addr_from_java(addr); - - if (is_ptr_aligned(p, sizeof(jlong))) { - // jlong is aligned, do a volatile access - *(volatile jlong*)p = x; - } else { - jlong_accessor acc; - acc.long_value = x; - ((volatile jint*)p)[0] = acc.words[0]; - ((volatile jint*)p)[1] = acc.words[1]; - } - - t->set_doing_unsafe_access(false); -} UNSAFE_END - - -UNSAFE_LEAF(jlong, Unsafe_GetNativeAddress(JNIEnv *env, jobject unsafe, jlong addr)) { - void* p = addr_from_java(addr); - - return addr_to_java(*(void**)p); -} UNSAFE_END - -UNSAFE_LEAF(void, Unsafe_SetNativeAddress(JNIEnv *env, jobject unsafe, jlong addr, jlong x)) { - void* p = addr_from_java(addr); - *(void**)p = addr_from_java(x); -} UNSAFE_END - - ////// Allocation requests UNSAFE_ENTRY(jobject, Unsafe_AllocateInstance(JNIEnv *env, jobject unsafe, jclass cls)) { @@ -980,8 +977,8 @@ UNSAFE_ENTRY(jint, Unsafe_CompareAndExchangeInt(JNIEnv *env, jobject unsafe, job } UNSAFE_END UNSAFE_ENTRY(jlong, Unsafe_CompareAndExchangeLong(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jlong e, jlong x)) { - Handle p (THREAD, JNIHandles::resolve(obj)); - jlong* addr = (jlong*)(index_oop_from_field_offset_long(p(), offset)); + Handle p(THREAD, JNIHandles::resolve(obj)); + jlong* addr = (jlong*)index_oop_from_field_offset_long(p(), offset); #ifdef SUPPORTS_NATIVE_CX8 return (jlong)(Atomic::cmpxchg(x, addr, e)); @@ -1017,7 +1014,7 @@ UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapObject(JNIEnv *env, jobject unsafe, UNSAFE_ENTRY(jboolean, Unsafe_CompareAndSwapInt(JNIEnv *env, jobject unsafe, jobject obj, jlong offset, jint e, jint x)) { oop p = JNIHandles::resolve(obj); - jint* addr = (jint *) index_oop_from_field_offset_long(p, offset); + jint* addr = (jint *)index_oop_from_field_offset_long(p, offset); return (jint)(Atomic::cmpxchg(x, addr, e)) == e; } UNSAFE_END @@ -1143,20 +1140,16 @@ UNSAFE_ENTRY(jint, Unsafe_GetLoadAverage0(JNIEnv *env, jobject unsafe, jdoubleAr #define DECLARE_GETPUTOOP(Type, Desc) \ {CC "get" #Type, CC "(" OBJ "J)" #Desc, FN_PTR(Unsafe_Get##Type)}, \ - {CC "put" #Type, CC "(" OBJ "J" #Desc ")V", FN_PTR(Unsafe_Set##Type)}, \ + {CC "put" #Type, CC "(" OBJ "J" #Desc ")V", FN_PTR(Unsafe_Put##Type)}, \ {CC "get" #Type "Volatile", CC "(" OBJ "J)" #Desc, FN_PTR(Unsafe_Get##Type##Volatile)}, \ - {CC "put" #Type "Volatile", CC "(" OBJ "J" #Desc ")V", FN_PTR(Unsafe_Set##Type##Volatile)} - + {CC "put" #Type "Volatile", CC "(" OBJ "J" #Desc ")V", FN_PTR(Unsafe_Put##Type##Volatile)} -#define DECLARE_GETPUTNATIVE(Byte, B) \ - {CC "get" #Byte, CC "(" ADR ")" #B, FN_PTR(Unsafe_GetNative##Byte)}, \ - {CC "put" #Byte, CC "(" ADR#B ")V", FN_PTR(Unsafe_SetNative##Byte)} static JNINativeMethod jdk_internal_misc_Unsafe_methods[] = { {CC "getObject", CC "(" OBJ "J)" OBJ "", FN_PTR(Unsafe_GetObject)}, - {CC "putObject", CC "(" OBJ "J" OBJ ")V", FN_PTR(Unsafe_SetObject)}, + {CC "putObject", CC "(" OBJ "J" OBJ ")V", FN_PTR(Unsafe_PutObject)}, {CC "getObjectVolatile",CC "(" OBJ "J)" OBJ "", FN_PTR(Unsafe_GetObjectVolatile)}, - {CC "putObjectVolatile",CC "(" OBJ "J" OBJ ")V", FN_PTR(Unsafe_SetObjectVolatile)}, + {CC "putObjectVolatile",CC "(" OBJ "J" OBJ ")V", FN_PTR(Unsafe_PutObjectVolatile)}, {CC "getUncompressedObject", CC "(" ADR ")" OBJ, FN_PTR(Unsafe_GetUncompressedObject)}, {CC "getJavaMirror", CC "(" ADR ")" CLS, FN_PTR(Unsafe_GetJavaMirror)}, @@ -1171,17 +1164,6 @@ static JNINativeMethod jdk_internal_misc_Unsafe_methods[] = { DECLARE_GETPUTOOP(Float, F), DECLARE_GETPUTOOP(Double, D), - DECLARE_GETPUTNATIVE(Byte, B), - DECLARE_GETPUTNATIVE(Short, S), - DECLARE_GETPUTNATIVE(Char, C), - DECLARE_GETPUTNATIVE(Int, I), - DECLARE_GETPUTNATIVE(Long, J), - DECLARE_GETPUTNATIVE(Float, F), - DECLARE_GETPUTNATIVE(Double, D), - - {CC "getAddress", CC "(" ADR ")" ADR, FN_PTR(Unsafe_GetNativeAddress)}, - {CC "putAddress", CC "(" ADR "" ADR ")V", FN_PTR(Unsafe_SetNativeAddress)}, - {CC "allocateMemory0", CC "(J)" ADR, FN_PTR(Unsafe_AllocateMemory0)}, {CC "reallocateMemory0", CC "(" ADR "J)" ADR, FN_PTR(Unsafe_ReallocateMemory0)}, {CC "freeMemory0", CC "(" ADR ")V", FN_PTR(Unsafe_FreeMemory0)}, @@ -1239,7 +1221,6 @@ static JNINativeMethod jdk_internal_misc_Unsafe_methods[] = { #undef DAC_Args #undef DECLARE_GETPUTOOP -#undef DECLARE_GETPUTNATIVE // This function is exported, used by NativeLookup. -- GitLab From d4a0000fdb18a9e776af7f80522fd4f891cc2606 Mon Sep 17 00:00:00 2001 From: Brent Christian Date: Fri, 6 May 2016 22:45:32 -0700 Subject: [PATCH 004/400] 8147039: Incorrect locals and operands in compiled frames Implement stack walking using javaVFrame instead of vframeStream Reviewed-by: mchung, vlivanov --- hotspot/src/share/vm/prims/stackwalk.cpp | 103 +++++++++++------------ hotspot/src/share/vm/prims/stackwalk.hpp | 28 ++++-- hotspot/src/share/vm/runtime/vframe.hpp | 8 -- 3 files changed, 69 insertions(+), 70 deletions(-) diff --git a/hotspot/src/share/vm/prims/stackwalk.cpp b/hotspot/src/share/vm/prims/stackwalk.cpp index d772620dcf5..70f46f747d2 100644 --- a/hotspot/src/share/vm/prims/stackwalk.cpp +++ b/hotspot/src/share/vm/prims/stackwalk.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,44 +37,44 @@ #include "utilities/globalDefinitions.hpp" // setup and cleanup actions -void StackWalkAnchor::setup_magic_on_entry(objArrayHandle frames_array) { +void JavaFrameStream::setup_magic_on_entry(objArrayHandle frames_array) { frames_array->obj_at_put(magic_pos, _thread->threadObj()); _anchor = address_value(); assert(check_magic(frames_array), "invalid magic"); } -bool StackWalkAnchor::check_magic(objArrayHandle frames_array) { +bool JavaFrameStream::check_magic(objArrayHandle frames_array) { oop m1 = frames_array->obj_at(magic_pos); jlong m2 = _anchor; if (m1 == _thread->threadObj() && m2 == address_value()) return true; return false; } -bool StackWalkAnchor::cleanup_magic_on_exit(objArrayHandle frames_array) { +bool JavaFrameStream::cleanup_magic_on_exit(objArrayHandle frames_array) { bool ok = check_magic(frames_array); frames_array->obj_at_put(magic_pos, NULL); _anchor = 0L; return ok; } -// Returns StackWalkAnchor for the current stack being traversed. +// Returns JavaFrameStream for the current stack being traversed. // // Parameters: // thread Current Java thread. // magic Magic value used for each stack walking // frames_array User-supplied buffers. The 0th element is reserved -// to this StackWalkAnchor to use +// to this JavaFrameStream to use // -StackWalkAnchor* StackWalkAnchor::from_current(JavaThread* thread, jlong magic, +JavaFrameStream* JavaFrameStream::from_current(JavaThread* thread, jlong magic, objArrayHandle frames_array) { assert(thread != NULL && thread->is_Java_thread(), ""); oop m1 = frames_array->obj_at(magic_pos); if (m1 != thread->threadObj()) return NULL; if (magic == 0L) return NULL; - StackWalkAnchor* anchor = (StackWalkAnchor*) (intptr_t) magic; - if (!anchor->is_valid_in(thread, frames_array)) return NULL; - return anchor; + JavaFrameStream* stream = (JavaFrameStream*) (intptr_t) magic; + if (!stream->is_valid_in(thread, frames_array)) return NULL; + return stream; } // Unpacks one or more frames into user-supplied buffers. @@ -84,19 +84,19 @@ StackWalkAnchor* StackWalkAnchor::from_current(JavaThread* thread, jlong magic, // In other words, do not leave any stale data in the vfst. // // Parameters: -// mode Restrict which frames to be decoded. -// vfst vFrameStream. -// max_nframes Maximum number of frames to be filled. -// start_index Start index to the user-supplied buffers. -// frames_array Buffer to store Class or StackFrame in, starting at start_index. -// frames array is a Class[] array when only getting caller -// reference, and a StackFrameInfo[] array (or derivative) -// otherwise. It should never be null. -// end_index End index to the user-supplied buffers with unpacked frames. +// mode Restrict which frames to be decoded. +// JavaFrameStream stream of javaVFrames +// max_nframes Maximum number of frames to be filled. +// start_index Start index to the user-supplied buffers. +// frames_array Buffer to store Class or StackFrame in, starting at start_index. +// frames array is a Class[] array when only getting caller +// reference, and a StackFrameInfo[] array (or derivative) +// otherwise. It should never be null. +// end_index End index to the user-supplied buffers with unpacked frames. // // Returns the number of frames whose information was transferred into the buffers. // -int StackWalk::fill_in_frames(jlong mode, vframeStream& vfst, +int StackWalk::fill_in_frames(jlong mode, JavaFrameStream& stream, int max_nframes, int start_index, objArrayHandle frames_array, int& end_index, TRAPS) { @@ -108,9 +108,9 @@ int StackWalk::fill_in_frames(jlong mode, vframeStream& vfst, assert(start_index + max_nframes <= frames_array->length(), "oob"); int frames_decoded = 0; - for (; !vfst.at_end(); vfst.next()) { - Method* method = vfst.method(); - int bci = vfst.bci(); + for (; !stream.at_end(); stream.next()) { + Method* method = stream.method(); + int bci = stream.bci(); if (method == NULL) continue; if (!ShowHiddenFrames && StackWalk::skip_hidden_frames(mode)) { @@ -133,7 +133,7 @@ int StackWalk::fill_in_frames(jlong mode, vframeStream& vfst, if (live_frame_info(mode)) { assert (use_frames_array(mode), "Bad mode for get live frame"); Handle stackFrame(frames_array->obj_at(index)); - fill_live_stackframe(stackFrame, method, bci, vfst.java_frame(), CHECK_0); + fill_live_stackframe(stackFrame, method, bci, stream.java_frame(), CHECK_0); } else if (need_method_info(mode)) { assert (use_frames_array(mode), "Bad mode for get stack frame"); Handle stackFrame(frames_array->obj_at(index)); @@ -294,6 +294,7 @@ oop StackWalk::walk(Handle stackStream, jlong mode, int skip_frames, int frame_count, int start_index, objArrayHandle frames_array, TRAPS) { + ResourceMark rm(THREAD); JavaThread* jt = (JavaThread*)THREAD; if (TraceStackWalk) { tty->print_cr("Start walking: mode " JLONG_FORMAT " skip %d frames batch size %d", @@ -309,41 +310,39 @@ oop StackWalk::walk(Handle stackStream, jlong mode, methodHandle m_doStackWalk(THREAD, Universe::do_stack_walk_method()); - // Open up a traversable stream onto my stack. - // This stream will be made available by *reference* to the inner Java call. - StackWalkAnchor anchor(jt); - vframeStream& vfst = anchor.vframe_stream(); - + // Setup traversal onto my stack. + RegisterMap regMap(jt, true); + JavaFrameStream stream(jt, ®Map); { - while (!vfst.at_end()) { - InstanceKlass* ik = vfst.method()->method_holder(); + while (!stream.at_end()) { + InstanceKlass* ik = stream.method()->method_holder(); if (ik != stackWalker_klass && ik != abstractStackWalker_klass && ik->super() != abstractStackWalker_klass) { break; } if (TraceStackWalk) { - tty->print(" skip "); vfst.method()->print_short_name(); tty->print("\n"); + tty->print(" skip "); stream.method()->print_short_name(); tty->print("\n"); } - vfst.next(); + stream.next(); } // stack frame has been traversed individually and resume stack walk // from the stack frame at depth == skip_frames. - for (int n=0; n < skip_frames && !vfst.at_end(); vfst.next(), n++) { + for (int n=0; n < skip_frames && !stream.at_end(); stream.next(), n++) { if (TraceStackWalk) { - tty->print(" skip "); vfst.method()->print_short_name(); + tty->print(" skip "); stream.method()->print_short_name(); tty->print_cr(" frame id: " PTR_FORMAT " pc: " PTR_FORMAT, - p2i(vfst.frame_id()), p2i(vfst.frame_pc())); + p2i(stream.java_frame()->fr().id()), + p2i(stream.java_frame()->fr().pc())); } } } - // The Method* pointer in the vfst has a very short shelf life. Grab it now. int end_index = start_index; int numFrames = 0; - if (!vfst.at_end()) { - numFrames = fill_in_frames(mode, vfst, frame_count, start_index, + if (!stream.at_end()) { + numFrames = fill_in_frames(mode, stream, frame_count, start_index, frames_array, end_index, CHECK_NULL); if (numFrames < 1) { THROW_MSG_(vmSymbols::java_lang_InternalError(), "stack walk: decode failed", NULL); @@ -356,19 +355,19 @@ oop StackWalk::walk(Handle stackStream, jlong mode, // When JVM_CallStackWalk returns, it invalidates the stack stream. JavaValue result(T_OBJECT); JavaCallArguments args(stackStream); - args.push_long(anchor.address_value()); + args.push_long(stream.address_value()); args.push_int(skip_frames); args.push_int(frame_count); args.push_int(start_index); args.push_int(end_index); // Link the thread and vframe stream into the callee-visible object - anchor.setup_magic_on_entry(frames_array); + stream.setup_magic_on_entry(frames_array); JavaCalls::call(&result, m_doStackWalk, &args, THREAD); // Do this before anything else happens, to disable any lingering stream objects - bool ok = anchor.cleanup_magic_on_exit(frames_array); + bool ok = stream.cleanup_magic_on_exit(frames_array); // Throw pending exception if we must (void) (CHECK_NULL); @@ -379,7 +378,6 @@ oop StackWalk::walk(Handle stackStream, jlong mode, // Return normally return (oop)result.get_jobject(); - } // Walk the next batch of stack frames @@ -400,8 +398,8 @@ jint StackWalk::moreFrames(Handle stackStream, jlong mode, jlong magic, TRAPS) { JavaThread* jt = (JavaThread*)THREAD; - StackWalkAnchor* existing_anchor = StackWalkAnchor::from_current(jt, magic, frames_array); - if (existing_anchor == NULL) { + JavaFrameStream* existing_stream = JavaFrameStream::from_current(jt, magic, frames_array); + if (existing_stream == NULL) { THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: corrupted buffers", 0L); } @@ -410,8 +408,8 @@ jint StackWalk::moreFrames(Handle stackStream, jlong mode, jlong magic, } if (TraceStackWalk) { - tty->print_cr("StackWalk::moreFrames frame_count %d existing_anchor " PTR_FORMAT " start %d frames %d", - frame_count, p2i(existing_anchor), start_index, frames_array->length()); + tty->print_cr("StackWalk::moreFrames frame_count %d existing_stream " PTR_FORMAT " start %d frames %d", + frame_count, p2i(existing_stream), start_index, frames_array->length()); } int end_index = start_index; if (frame_count <= 0) { @@ -421,12 +419,11 @@ jint StackWalk::moreFrames(Handle stackStream, jlong mode, jlong magic, int count = frame_count + start_index; assert (frames_array->length() >= count, "not enough space in buffers"); - StackWalkAnchor& anchor = (*existing_anchor); - vframeStream& vfst = anchor.vframe_stream(); - if (!vfst.at_end()) { - vfst.next(); // this was the last frame decoded in the previous batch - if (!vfst.at_end()) { - int n = fill_in_frames(mode, vfst, frame_count, start_index, + JavaFrameStream& stream = (*existing_stream); + if (!stream.at_end()) { + stream.next(); // advance past the last frame decoded in previous batch + if (!stream.at_end()) { + int n = fill_in_frames(mode, stream, frame_count, start_index, frames_array, end_index, CHECK_0); if (n < 1) { THROW_MSG_(vmSymbols::java_lang_InternalError(), "doStackWalk: later decode failed", 0L); diff --git a/hotspot/src/share/vm/prims/stackwalk.hpp b/hotspot/src/share/vm/prims/stackwalk.hpp index 2eb41aeb711..e222e623f6d 100644 --- a/hotspot/src/share/vm/prims/stackwalk.hpp +++ b/hotspot/src/share/vm/prims/stackwalk.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,21 +29,31 @@ #include "oops/oop.hpp" #include "runtime/vframe.hpp" -class StackWalkAnchor : public StackObj { +// +// JavaFrameStream is used by StackWalker to iterate through Java stack frames +// on the given JavaThread. +// +class JavaFrameStream : public StackObj { private: enum { magic_pos = 0 }; JavaThread* _thread; - vframeStream _vfst; + javaVFrame* _jvf; jlong _anchor; public: - StackWalkAnchor(JavaThread* thread) - : _thread(thread), _vfst(thread), _anchor(0L) {} + JavaFrameStream(JavaThread* thread, RegisterMap* rm) + : _thread(thread), _anchor(0L) { + _jvf = _thread->last_java_vframe(rm); + } + + javaVFrame* java_frame() { return _jvf; } + void next() { _jvf = _jvf->java_sender(); } + bool at_end() { return _jvf == NULL; } - vframeStream& vframe_stream() { return _vfst; } - JavaThread* thread() { return _thread; } + Method* method() { return _jvf->method(); } + int bci() { return _jvf->bci(); } void setup_magic_on_entry(objArrayHandle frames_array); bool check_magic(objArrayHandle frames_array); @@ -57,12 +67,12 @@ public: return (jlong) castable_address(this); } - static StackWalkAnchor* from_current(JavaThread* thread, jlong anchor, objArrayHandle frames_array); + static JavaFrameStream* from_current(JavaThread* thread, jlong magic, objArrayHandle frames_array); }; class StackWalk : public AllStatic { private: - static int fill_in_frames(jlong mode, vframeStream& vfst, + static int fill_in_frames(jlong mode, JavaFrameStream& stream, int max_nframes, int start_index, objArrayHandle frames_array, int& end_index, TRAPS); diff --git a/hotspot/src/share/vm/runtime/vframe.hpp b/hotspot/src/share/vm/runtime/vframe.hpp index 148244aee6f..de7d510fc2d 100644 --- a/hotspot/src/share/vm/runtime/vframe.hpp +++ b/hotspot/src/share/vm/runtime/vframe.hpp @@ -317,14 +317,6 @@ class vframeStreamCommon : StackObj { intptr_t* frame_id() const { return _frame.id(); } address frame_pc() const { return _frame.pc(); } - javaVFrame* java_frame() { - vframe* vf = vframe::new_vframe(&_frame, &_reg_map, _thread); - if (vf->is_java_frame()) { - return (javaVFrame*)vf; - } - return NULL; - } - CodeBlob* cb() const { return _frame.cb(); } CompiledMethod* nm() const { assert( cb() != NULL && cb()->is_compiled(), "usage"); -- GitLab From af168abecc857b700f02256b11401b10b49f2ec0 Mon Sep 17 00:00:00 2001 From: Thomas Stuefe Date: Thu, 28 Apr 2016 15:40:45 +0200 Subject: [PATCH 005/400] 8155639: Remove STEP numbers from error reporting Reviewed-by: coleenp, twisti --- hotspot/src/share/vm/utilities/vmError.cpp | 156 ++++++++++----------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/hotspot/src/share/vm/utilities/vmError.cpp b/hotspot/src/share/vm/utilities/vmError.cpp index 1eac0b14d0e..095cc8bbb26 100644 --- a/hotspot/src/share/vm/utilities/vmError.cpp +++ b/hotspot/src/share/vm/utilities/vmError.cpp @@ -290,8 +290,8 @@ const char* VMError::_current_step_info; void VMError::report(outputStream* st, bool _verbose) { -# define BEGIN if (_current_step == 0) { _current_step = 1; -# define STEP(n, s) } if (_current_step < n) { _current_step = n; _current_step_info = s; +# define BEGIN if (_current_step == 0) { _current_step = __LINE__; +# define STEP(s) } if (_current_step < __LINE__) { _current_step = __LINE__; _current_step_info = s; # define END } // don't allocate large buffer on stack @@ -299,7 +299,7 @@ void VMError::report(outputStream* st, bool _verbose) { BEGIN - STEP(10, "(printing fatal error message)") + STEP("printing fatal error message") st->print_cr("#"); if (should_report_bug(_id)) { @@ -314,21 +314,21 @@ void VMError::report(outputStream* st, bool _verbose) { // test secondary error handling. Test it twice, to test that resetting // error handler after a secondary crash works. - STEP(20, "(test secondary crash 1)") + STEP("test secondary crash 1") if (_verbose && TestCrashInErrorHandler != 0) { st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...", TestCrashInErrorHandler); controlled_crash(TestCrashInErrorHandler); } - STEP(30, "(test secondary crash 2)") + STEP("test secondary crash 2") if (_verbose && TestCrashInErrorHandler != 0) { st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...", TestCrashInErrorHandler); controlled_crash(TestCrashInErrorHandler); } - STEP(40, "(test safefetch in error handler)") + STEP("test safefetch in error handler") // test whether it is safe to use SafeFetch32 in Crash Handler. Test twice // to test that resetting the signal handler works correctly. if (_verbose && TestSafeFetchInErrorHandler) { @@ -349,7 +349,7 @@ void VMError::report(outputStream* st, bool _verbose) { } #endif // PRODUCT - STEP(50, "(printing type of error)") + STEP("printing type of error") switch(_id) { case OOM_MALLOC_ERROR: @@ -384,7 +384,7 @@ void VMError::report(outputStream* st, bool _verbose) { break; } - STEP(60, "(printing exception/signal name)") + STEP("printing exception/signal name") st->print_cr("#"); st->print("# "); @@ -414,14 +414,14 @@ void VMError::report(outputStream* st, bool _verbose) { } } - STEP(70, "(printing current thread and pid)") + STEP("printing current thread and pid") // process id, thread id st->print(", pid=%d", os::current_process_id()); st->print(", tid=" UINTX_FORMAT, os::current_thread_id()); st->cr(); - STEP(80, "(printing error message)") + STEP("printing error message") if (should_report_bug(_id)) { // already printed the message. // error message @@ -432,11 +432,11 @@ void VMError::report(outputStream* st, bool _verbose) { } } - STEP(90, "(printing Java version string)") + STEP("printing Java version string") report_vm_version(st, buf, sizeof(buf)); - STEP(100, "(printing problematic frame)") + STEP("printing problematic frame") // Print current frame if we have a context (i.e. it's a crash) if (_context) { @@ -448,7 +448,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->print_cr("#"); } - STEP(110, "(printing core file information)") + STEP("printing core file information") st->print("# "); if (CreateCoredumpOnCrash) { if (coredump_status) { @@ -462,13 +462,13 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); st->print_cr("#"); - STEP(120, "(printing bug submit message)") + STEP("printing bug submit message") if (should_report_bug(_id) && _verbose) { print_bug_submit_message(st, _thread); } - STEP(130, "(printing summary)" ) + STEP("printing summary") if (_verbose) { st->cr(); @@ -476,7 +476,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(140, "(printing VM option summary)" ) + STEP("printing VM option summary") if (_verbose) { // VM options @@ -484,20 +484,20 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(150, "(printing summary machine and OS info)") + STEP("printing summary machine and OS info") if (_verbose) { os::print_summary_info(st, buf, sizeof(buf)); } - STEP(160, "(printing date and time)" ) + STEP("printing date and time") if (_verbose) { os::print_date_and_time(st, buf, sizeof(buf)); } - STEP(170, "(printing thread)" ) + STEP("printing thread") if (_verbose) { st->cr(); @@ -505,7 +505,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(180, "(printing current thread)" ) + STEP("printing current thread") // current thread if (_verbose) { @@ -519,7 +519,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(190, "(printing current compile task)" ) + STEP("printing current compile task") if (_verbose && _thread && _thread->is_Compiler_thread()) { CompilerThread* t = (CompilerThread*)_thread; @@ -532,7 +532,7 @@ void VMError::report(outputStream* st, bool _verbose) { } - STEP(200, "(printing stack bounds)" ) + STEP("printing stack bounds") if (_verbose) { st->print("Stack: "); @@ -563,7 +563,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(210, "(printing native stack)" ) + STEP("printing native stack") if (_verbose) { if (os::platform_print_native_stack(st, _context, buf, sizeof(buf))) { @@ -577,13 +577,13 @@ void VMError::report(outputStream* st, bool _verbose) { } } - STEP(220, "(printing Java stack)" ) + STEP("printing Java stack") if (_verbose && _thread && _thread->is_Java_thread()) { print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf)); } - STEP(230, "(printing target Java thread stack)" ) + STEP("printing target Java thread stack") // printing Java thread stack trace if it is involved in GC crash if (_verbose && _thread && (_thread->is_Named_thread())) { @@ -594,7 +594,7 @@ void VMError::report(outputStream* st, bool _verbose) { } } - STEP(240, "(printing siginfo)" ) + STEP("printing siginfo") // signal no, signal code, address that caused the fault if (_verbose && _siginfo) { @@ -603,7 +603,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(245, "(CDS archive access warning)" ) + STEP("CDS archive access warning") // Print an explicit hint if we crashed on access to the CDS archive. if (_verbose && _siginfo) { @@ -611,7 +611,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(250, "(printing register info)") + STEP("printing register info") // decode register contents if possible if (_verbose && _context && Universe::is_fully_initialized()) { @@ -619,7 +619,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(260, "(printing registers, top of stack, instructions near pc)") + STEP("printing registers, top of stack, instructions near pc") // registers, top of stack, instructions near pc if (_verbose && _context) { @@ -627,7 +627,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(265, "(printing code blob if possible)") + STEP("printing code blob if possible") if (_verbose && _context) { CodeBlob* cb = CodeCache::find_blob(_pc); @@ -652,7 +652,7 @@ void VMError::report(outputStream* st, bool _verbose) { } } - STEP(270, "(printing VM operation)" ) + STEP("printing VM operation") if (_verbose && _thread && _thread->is_VM_thread()) { VMThread* t = (VMThread*)_thread; @@ -664,7 +664,7 @@ void VMError::report(outputStream* st, bool _verbose) { } } - STEP(280, "(printing process)" ) + STEP("printing process") if (_verbose) { st->cr(); @@ -672,7 +672,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(290, "(printing all threads)" ) + STEP("printing all threads") // all threads if (_verbose && _thread) { @@ -680,7 +680,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(300, "(printing VM state)" ) + STEP("printing VM state") if (_verbose) { // Safepoint state @@ -702,7 +702,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(310, "(printing owned locks on error)" ) + STEP("printing owned locks on error") // mutexes/monitors that currently have an owner if (_verbose) { @@ -710,7 +710,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(320, "(printing number of OutOfMemoryError and StackOverflow exceptions)") + STEP("printing number of OutOfMemoryError and StackOverflow exceptions") if (_verbose && Exceptions::has_exception_counts()) { st->print_cr("OutOfMemory and StackOverflow Exception counts:"); @@ -718,7 +718,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(330, "(printing compressed oops mode") + STEP("printing compressed oops mode") if (_verbose && UseCompressedOops) { Universe::print_compressed_oops_mode(st); @@ -728,7 +728,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(340, "(printing heap information)" ) + STEP("printing heap information") if (_verbose && Universe::is_fully_initialized()) { Universe::heap()->print_on_error(st); @@ -737,7 +737,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(350, "(printing code cache information)" ) + STEP("printing code cache information") if (_verbose && Universe::is_fully_initialized()) { // print code cache information before vm abort @@ -745,14 +745,14 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(360, "(printing ring buffers)" ) + STEP("printing ring buffers") if (_verbose) { Events::print_all(st); st->cr(); } - STEP(370, "(printing dynamic libraries)" ) + STEP("printing dynamic libraries") if (_verbose) { // dynamic libraries, or memory map @@ -760,7 +760,7 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(380, "(printing VM options)" ) + STEP("printing VM options") if (_verbose) { // VM options @@ -768,40 +768,40 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(390, "(printing warning if internal testing API used)" ) + STEP("printing warning if internal testing API used") if (WhiteBox::used()) { st->print_cr("Unsupported internal testing APIs have been used."); st->cr(); } - STEP(395, "(printing log configuration)") + STEP("printing log configuration") if (_verbose){ st->print_cr("Logging:"); LogConfiguration::describe_current_configuration(st); st->cr(); } - STEP(400, "(printing all environment variables)" ) + STEP("printing all environment variables") if (_verbose) { os::print_environment_variables(st, env_list); st->cr(); } - STEP(410, "(printing signal handlers)" ) + STEP("printing signal handlers") if (_verbose) { os::print_signal_handlers(st, buf, sizeof(buf)); st->cr(); } - STEP(420, "(Native Memory Tracking)" ) + STEP("Native Memory Tracking") if (_verbose) { MemTracker::error_report(st); } - STEP(430, "(printing system)" ) + STEP("printing system") if (_verbose) { st->cr(); @@ -809,27 +809,27 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } - STEP(440, "(printing OS information)" ) + STEP("printing OS information") if (_verbose) { os::print_os_info(st); st->cr(); } - STEP(450, "(printing CPU info)" ) + STEP("printing CPU info") if (_verbose) { os::print_cpu_info(st, buf, sizeof(buf)); st->cr(); } - STEP(460, "(printing memory info)" ) + STEP("printing memory info") if (_verbose) { os::print_memory_info(st); st->cr(); } - STEP(470, "(printing internal vm info)" ) + STEP("printing internal vm info") if (_verbose) { st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string()); @@ -837,7 +837,7 @@ void VMError::report(outputStream* st, bool _verbose) { } // print a defined marker to show that error handling finished correctly. - STEP(480, "(printing end marker)" ) + STEP("printing end marker") if (_verbose) { st->print_cr("END."); @@ -858,35 +858,35 @@ void VMError::print_vm_info(outputStream* st) { char buf[O_BUFLEN]; report_vm_version(st, buf, sizeof(buf)); - // STEP("(printing summary)") + // STEP("printing summary") st->cr(); st->print_cr("--------------- S U M M A R Y ------------"); st->cr(); - // STEP("(printing VM option summary)") + // STEP("printing VM option summary") // VM options Arguments::print_summary_on(st); st->cr(); - // STEP("(printing summary machine and OS info)") + // STEP("printing summary machine and OS info") os::print_summary_info(st, buf, sizeof(buf)); - // STEP("(printing date and time)") + // STEP("printing date and time") os::print_date_and_time(st, buf, sizeof(buf)); - // Skip: STEP("(printing thread)") + // Skip: STEP("printing thread") - // STEP("(printing process)") + // STEP("printing process") st->cr(); st->print_cr("--------------- P R O C E S S ---------------"); st->cr(); - // STEP("(printing number of OutOfMemoryError and StackOverflow exceptions)") + // STEP("printing number of OutOfMemoryError and StackOverflow exceptions") if (Exceptions::has_exception_counts()) { st->print_cr("OutOfMemory and StackOverflow Exception counts:"); @@ -894,7 +894,7 @@ void VMError::print_vm_info(outputStream* st) { st->cr(); } - // STEP("(printing compressed oops mode") + // STEP("printing compressed oops mode") if (UseCompressedOops) { Universe::print_compressed_oops_mode(st); @@ -904,7 +904,7 @@ void VMError::print_vm_info(outputStream* st) { st->cr(); } - // STEP("(printing heap information)") + // STEP("printing heap information") if (Universe::is_fully_initialized()) { Universe::heap()->print_on_error(st); @@ -913,7 +913,7 @@ void VMError::print_vm_info(outputStream* st) { st->cr(); } - // STEP("(printing code cache information)") + // STEP("printing code cache information") if (Universe::is_fully_initialized()) { // print code cache information before vm abort @@ -921,77 +921,77 @@ void VMError::print_vm_info(outputStream* st) { st->cr(); } - // STEP("(printing ring buffers)") + // STEP("printing ring buffers") Events::print_all(st); st->cr(); - // STEP("(printing dynamic libraries)") + // STEP("printing dynamic libraries") // dynamic libraries, or memory map os::print_dll_info(st); st->cr(); - // STEP("(printing VM options)") + // STEP("printing VM options") // VM options Arguments::print_on(st); st->cr(); - // STEP("(printing warning if internal testing API used)") + // STEP("printing warning if internal testing API used") if (WhiteBox::used()) { st->print_cr("Unsupported internal testing APIs have been used."); st->cr(); } - // STEP("(printing log configuration)") + // STEP("printing log configuration") st->print_cr("Logging:"); LogConfiguration::describe(st); st->cr(); - // STEP("(printing all environment variables)") + // STEP("printing all environment variables") os::print_environment_variables(st, env_list); st->cr(); - // STEP("(printing signal handlers)") + // STEP("printing signal handlers") os::print_signal_handlers(st, buf, sizeof(buf)); st->cr(); - // STEP("(Native Memory Tracking)") + // STEP("Native Memory Tracking") MemTracker::error_report(st); - // STEP("(printing system)") + // STEP("printing system") st->cr(); st->print_cr("--------------- S Y S T E M ---------------"); st->cr(); - // STEP("(printing OS information)") + // STEP("printing OS information") os::print_os_info(st); st->cr(); - // STEP("(printing CPU info)") + // STEP("printing CPU info") os::print_cpu_info(st, buf, sizeof(buf)); st->cr(); - // STEP("(printing memory info)") + // STEP("printing memory info") os::print_memory_info(st); st->cr(); - // STEP("(printing internal vm info)") + // STEP("printing internal vm info") st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string()); st->cr(); // print a defined marker to show that error handling finished correctly. - // STEP("(printing end marker)") + // STEP("printing end marker") st->print_cr("END."); } @@ -1190,7 +1190,7 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt } jio_snprintf(buffer, sizeof(buffer), - "[error occurred during error reporting %s, id 0x%x]", + "[error occurred during error reporting (%s), id 0x%x]", _current_step_info, _id); if (log.is_open()) { log.cr(); -- GitLab From c16b4b76731d971dcca9deeec20d5e8dae03190b Mon Sep 17 00:00:00 2001 From: Jon Masamitsu Date: Thu, 6 Aug 2015 22:07:30 -0700 Subject: [PATCH 006/400] 6858051: Create GC worker threads dynamically Reviewed-by: tschatzl, drwhite --- .../share/vm/gc/parallel/gcTaskManager.cpp | 73 ++++++++++++------ .../share/vm/gc/parallel/gcTaskManager.hpp | 12 ++- .../src/share/vm/gc/parallel/gcTaskThread.cpp | 7 -- .../src/share/vm/gc/parallel/gcTaskThread.hpp | 6 +- .../share/vm/gc/shared/adaptiveSizePolicy.cpp | 9 +-- .../share/vm/gc/shared/adaptiveSizePolicy.hpp | 2 +- .../src/share/vm/gc/shared/workerManager.hpp | 77 +++++++++++++++++++ hotspot/src/share/vm/gc/shared/workgroup.cpp | 53 +++++++------ hotspot/src/share/vm/gc/shared/workgroup.hpp | 22 +++++- 9 files changed, 196 insertions(+), 65 deletions(-) create mode 100644 hotspot/src/share/vm/gc/shared/workerManager.hpp diff --git a/hotspot/src/share/vm/gc/parallel/gcTaskManager.cpp b/hotspot/src/share/vm/gc/parallel/gcTaskManager.cpp index 57e91b6d16c..2ec5d190293 100644 --- a/hotspot/src/share/vm/gc/parallel/gcTaskManager.cpp +++ b/hotspot/src/share/vm/gc/parallel/gcTaskManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,8 @@ #include "precompiled.hpp" #include "gc/parallel/gcTaskManager.hpp" #include "gc/parallel/gcTaskThread.hpp" -#include "gc/shared/adaptiveSizePolicy.hpp" #include "gc/shared/gcId.hpp" +#include "gc/shared/workerManager.hpp" #include "logging/log.hpp" #include "memory/allocation.hpp" #include "memory/allocation.inline.hpp" @@ -34,6 +34,7 @@ #include "runtime/mutex.hpp" #include "runtime/mutexLocker.hpp" #include "runtime/orderAccess.inline.hpp" +#include "runtime/os.hpp" // // GCTask @@ -372,10 +373,28 @@ SynchronizedGCTaskQueue::~SynchronizedGCTaskQueue() { GCTaskManager::GCTaskManager(uint workers) : _workers(workers), _active_workers(0), - _idle_workers(0) { + _idle_workers(0), + _created_workers(0) { initialize(); } +GCTaskThread* GCTaskManager::install_worker(uint t) { + GCTaskThread* new_worker = GCTaskThread::create(this, t, _processor_assignment[t]); + set_thread(t, new_worker); + return new_worker; +} + +void GCTaskManager::add_workers(bool initializing) { + os::ThreadType worker_type = os::pgc_thread; + _created_workers = WorkerManager::add_workers(this, + _active_workers, + (uint) _workers, + _created_workers, + worker_type, + initializing); + _active_workers = MIN2(_created_workers, _active_workers); +} + void GCTaskManager::initialize() { if (TraceGCTaskManager) { tty->print_cr("GCTaskManager::initialize: workers: %u", workers()); @@ -394,28 +413,30 @@ void GCTaskManager::initialize() { // Set up worker threads. // Distribute the workers among the available processors, // unless we were told not to, or if the os doesn't want to. - uint* processor_assignment = NEW_C_HEAP_ARRAY(uint, workers(), mtGC); + _processor_assignment = NEW_C_HEAP_ARRAY(uint, workers(), mtGC); if (!BindGCTaskThreadsToCPUs || - !os::distribute_processes(workers(), processor_assignment)) { + !os::distribute_processes(workers(), _processor_assignment)) { for (uint a = 0; a < workers(); a += 1) { - processor_assignment[a] = sentinel_worker(); + _processor_assignment[a] = sentinel_worker(); } } + _thread = NEW_C_HEAP_ARRAY(GCTaskThread*, workers(), mtGC); - for (uint t = 0; t < workers(); t += 1) { - set_thread(t, GCTaskThread::create(this, t, processor_assignment[t])); + _active_workers = ParallelGCThreads; + if (UseDynamicNumberOfGCThreads && !FLAG_IS_CMDLINE(ParallelGCThreads)) { + _active_workers = 1U; } + Log(gc, task, thread) log; if (log.is_trace()) { ResourceMark rm; outputStream* out = log.trace_stream(); out->print("GCTaskManager::initialize: distribution:"); for (uint t = 0; t < workers(); t += 1) { - out->print(" %u", processor_assignment[t]); + out->print(" %u", _processor_assignment[t]); } out->cr(); } - FREE_C_HEAP_ARRAY(uint, processor_assignment); } reset_busy_workers(); set_unblocked(); @@ -426,9 +447,8 @@ void GCTaskManager::initialize() { reset_completed_tasks(); reset_barriers(); reset_emptied_queue(); - for (uint s = 0; s < workers(); s += 1) { - thread(s)->start(); - } + + add_workers(true); } GCTaskManager::~GCTaskManager() { @@ -437,13 +457,17 @@ GCTaskManager::~GCTaskManager() { NoopGCTask::destroy(_noop_task); _noop_task = NULL; if (_thread != NULL) { - for (uint i = 0; i < workers(); i += 1) { + for (uint i = 0; i < created_workers(); i += 1) { GCTaskThread::destroy(thread(i)); set_thread(i, NULL); } FREE_C_HEAP_ARRAY(GCTaskThread*, _thread); _thread = NULL; } + if (_processor_assignment != NULL) { + FREE_C_HEAP_ARRAY(uint, _processor_assignment); + _processor_assignment = NULL; + } if (_resource_flag != NULL) { FREE_C_HEAP_ARRAY(bool, _resource_flag); _resource_flag = NULL; @@ -470,6 +494,9 @@ void GCTaskManager::set_active_gang() { "all_workers_active() is incorrect: " "active %d ParallelGCThreads %u", active_workers(), ParallelGCThreads); + _active_workers = MIN2(_active_workers, _workers); + // "add_workers" does not guarantee any additional workers + add_workers(false); log_trace(gc, task)("GCTaskManager::set_active_gang(): " "all_workers_active() %d workers %d " "active %d ParallelGCThreads %u", @@ -499,7 +526,7 @@ void GCTaskManager::task_idle_workers() { // is starting). Try later to release enough idle_workers // to allow the desired number of active_workers. more_inactive_workers = - workers() - active_workers() - idle_workers(); + created_workers() - active_workers() - idle_workers(); if (more_inactive_workers < 0) { int reduced_active_workers = active_workers() + more_inactive_workers; set_active_workers(reduced_active_workers); @@ -507,7 +534,7 @@ void GCTaskManager::task_idle_workers() { } log_trace(gc, task)("JT: %d workers %d active %d idle %d more %d", Threads::number_of_non_daemon_threads(), - workers(), + created_workers(), active_workers(), idle_workers(), more_inactive_workers); @@ -517,7 +544,7 @@ void GCTaskManager::task_idle_workers() { q->enqueue(IdleGCTask::create_on_c_heap()); increment_idle_workers(); } - assert(workers() == active_workers() + idle_workers(), + assert(created_workers() == active_workers() + idle_workers(), "total workers should equal active + inactive"); add_list(q); // GCTaskQueue* q was created in a ResourceArea so a @@ -539,14 +566,15 @@ void GCTaskManager::print_task_time_stamps() { if (!log_is_enabled(Debug, gc, task, time)) { return; } - for(uint i=0; iprint_task_time_stamps(); } } void GCTaskManager::print_threads_on(outputStream* st) { - uint num_thr = workers(); + uint num_thr = created_workers(); for (uint i = 0; i < num_thr; i++) { thread(i)->print_on(st); st->cr(); @@ -555,19 +583,20 @@ void GCTaskManager::print_threads_on(outputStream* st) { void GCTaskManager::threads_do(ThreadClosure* tc) { assert(tc != NULL, "Null ThreadClosure"); - uint num_thr = workers(); + uint num_thr = created_workers(); for (uint i = 0; i < num_thr; i++) { tc->do_thread(thread(i)); } } GCTaskThread* GCTaskManager::thread(uint which) { - assert(which < workers(), "index out of bounds"); + assert(which < created_workers(), "index out of bounds"); assert(_thread[which] != NULL, "shouldn't have null thread"); return _thread[which]; } void GCTaskManager::set_thread(uint which, GCTaskThread* value) { + // "_created_workers" may not have been updated yet so use workers() assert(which < workers(), "index out of bounds"); assert(value != NULL, "shouldn't have null thread"); _thread[which] = value; @@ -728,7 +757,7 @@ uint GCTaskManager::decrement_busy_workers() { void GCTaskManager::release_all_resources() { // If you want this to be done atomically, do it in a WaitForBarrierGCTask. - for (uint i = 0; i < workers(); i += 1) { + for (uint i = 0; i < created_workers(); i += 1) { set_resource_flag(i, true); } } diff --git a/hotspot/src/share/vm/gc/parallel/gcTaskManager.hpp b/hotspot/src/share/vm/gc/parallel/gcTaskManager.hpp index 9d462039ad7..70ac6b2d226 100644 --- a/hotspot/src/share/vm/gc/parallel/gcTaskManager.hpp +++ b/hotspot/src/share/vm/gc/parallel/gcTaskManager.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -370,6 +370,7 @@ private: Monitor* _monitor; // Notification of changes. SynchronizedGCTaskQueue* _queue; // Queue of tasks. GCTaskThread** _thread; // Array of worker threads. + uint _created_workers; // Number of workers created. uint _active_workers; // Number of active workers. uint _busy_workers; // Number of busy workers. uint _blocking_worker; // The worker that's blocking. @@ -381,6 +382,8 @@ private: NoopGCTask* _noop_task; // The NoopGCTask instance. WaitHelper _wait_helper; // Used by inactive worker volatile uint _idle_workers; // Number of idled workers + uint* _processor_assignment; // Worker to cpu mappings. May + // be used lazily public: // Factory create and destroy methods. static GCTaskManager* create(uint workers) { @@ -546,6 +549,13 @@ protected: uint active_workers() const { return _active_workers; } + uint created_workers() const { + return _created_workers; + } + // Create a GC worker and install into GCTaskManager + GCTaskThread* install_worker(uint worker_id); + // Add GC workers as needed. + void add_workers(bool initializing); }; // diff --git a/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp b/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp index d81db6900e1..f6fd1a38a6f 100644 --- a/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp +++ b/hotspot/src/share/vm/gc/parallel/gcTaskThread.cpp @@ -44,9 +44,6 @@ GCTaskThread::GCTaskThread(GCTaskManager* manager, _time_stamps(NULL), _time_stamp_index(0) { - if (!os::create_thread(this, os::pgc_thread)) - vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GC thread. Out of system resources."); - set_id(which); set_name("ParGC Thread#%d", which); } @@ -57,10 +54,6 @@ GCTaskThread::~GCTaskThread() { } } -void GCTaskThread::start() { - os::start_thread(this); -} - GCTaskTimeStamp* GCTaskThread::time_stamp_at(uint index) { guarantee(index < GCTaskTimeStampEntries, "increase GCTaskTimeStampEntries"); if (_time_stamps == NULL) { diff --git a/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp b/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp index 49f9bd07fbf..aa10a69531a 100644 --- a/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp +++ b/hotspot/src/share/vm/gc/parallel/gcTaskThread.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,13 +48,13 @@ private: bool _is_working; // True if participating in GC tasks - public: // Factory create and destroy methods. static GCTaskThread* create(GCTaskManager* manager, uint which, uint processor_id) { return new GCTaskThread(manager, which, processor_id); } + public: static void destroy(GCTaskThread* manager) { if (manager != NULL) { delete manager; @@ -65,8 +65,6 @@ private: return true; } virtual void run(); - // Methods. - void start(); void print_task_time_stamps(); diff --git a/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.cpp b/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.cpp index 8365c62766f..9aa3f79c08d 100644 --- a/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.cpp +++ b/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -130,10 +130,7 @@ uint AdaptiveSizePolicy::calc_default_active_workers(uintx total_workers, uintx max_active_workers = MAX2(active_workers_by_JT, active_workers_by_heap_size); - // Limit the number of workers to the the number created, - // (workers()). - new_active_workers = MIN2(max_active_workers, - (uintx) total_workers); + new_active_workers = MIN2(max_active_workers, (uintx) total_workers); // Increase GC workers instantly but decrease them more // slowly. @@ -167,7 +164,7 @@ uint AdaptiveSizePolicy::calc_default_active_workers(uintx total_workers, "Jiggled active workers too much"); } - log_trace(gc, task)("GCTaskManager::calc_default_active_workers() : " + log_trace(gc, task)("GCTaskManager::calc_default_active_workers() : " "active_workers(): " UINTX_FORMAT " new_active_workers: " UINTX_FORMAT " " "prev_active_workers: " UINTX_FORMAT "\n" " active_workers_by_JT: " UINTX_FORMAT " active_workers_by_heap_size: " UINTX_FORMAT, diff --git a/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.hpp b/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.hpp index eb483623d20..27bc4f307a0 100644 --- a/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.hpp +++ b/hotspot/src/share/vm/gc/shared/adaptiveSizePolicy.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/hotspot/src/share/vm/gc/shared/workerManager.hpp b/hotspot/src/share/vm/gc/shared/workerManager.hpp new file mode 100644 index 00000000000..9dfa7d745bc --- /dev/null +++ b/hotspot/src/share/vm/gc/shared/workerManager.hpp @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_GC_SHARED_WORKERMANAGER_HPP +#define SHARE_VM_GC_SHARED_WORKERMANAGER_HPP + +#include "gc/shared/adaptiveSizePolicy.hpp" + +class WorkerManager : public AllStatic { + public: + // Create additional workers as needed. + // active_workers - number of workers being requested for an upcoming + // parallel task. + // total_workers - total number of workers. This is the maximum + // number possible. + // created_workers - number of workers already created. This maybe + // less than, equal to, or greater than active workers. If greater than + // or equal to active_workers, nothing is done. + // worker_type - type of thread. + // initializing - true if this is called to get the initial number of + // GC workers. + // If initializing is true, do a vm exit if the workers cannot be created. + // The initializing = true case is for JVM start up and failing to + // create all the worker at start should considered a problem so exit. + // If initializing = false, there are already some number of worker + // threads and a failure would not be optimal but should not be fatal. + template + static uint add_workers (WorkerType* holder, + uint active_workers, + uint total_workers, + uint created_workers, + os::ThreadType worker_type, + bool initializing) { + uint start = created_workers; + uint end = MIN2(active_workers, total_workers); + for (uint worker_id = start; worker_id < end; worker_id += 1) { + WorkerThread* new_worker = holder->install_worker(worker_id); + assert(new_worker != NULL, "Failed to allocate GangWorker"); + if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) { + if(initializing) { + vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, + "Cannot create worker GC thread. Out of system resources."); + } + } + created_workers++; + os::start_thread(new_worker); + } + + log_trace(gc, task)("AdaptiveSizePolicy::add_workers() : " + "active_workers: %u created_workers: %u", + active_workers, created_workers); + + return created_workers; + } +}; +#endif // SHARE_VM_GC_SHARED_WORKERMANAGER_HPP diff --git a/hotspot/src/share/vm/gc/shared/workgroup.cpp b/hotspot/src/share/vm/gc/shared/workgroup.cpp index 715b6a1e3b6..0dfffcd82e8 100644 --- a/hotspot/src/share/vm/gc/shared/workgroup.cpp +++ b/hotspot/src/share/vm/gc/shared/workgroup.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "gc/shared/gcId.hpp" #include "gc/shared/workgroup.hpp" +#include "gc/shared/workerManager.hpp" #include "memory/allocation.hpp" #include "memory/allocation.inline.hpp" #include "runtime/atomic.inline.hpp" @@ -35,37 +36,45 @@ // Definitions of WorkGang methods. // The current implementation will exit if the allocation -// of any worker fails. Still, return a boolean so that -// a future implementation can possibly do a partial -// initialization of the workers and report such to the -// caller. -bool AbstractWorkGang::initialize_workers() { +// of any worker fails. +void AbstractWorkGang::initialize_workers() { log_develop_trace(gc, workgang)("Constructing work gang %s with %u threads", name(), total_workers()); _workers = NEW_C_HEAP_ARRAY(AbstractGangWorker*, total_workers(), mtInternal); if (_workers == NULL) { vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, "Cannot create GangWorker array."); - return false; } + + _active_workers = ParallelGCThreads; + if (UseDynamicNumberOfGCThreads && !FLAG_IS_CMDLINE(ParallelGCThreads)) { + _active_workers = 1U; + } + + add_workers(true); +} + + +AbstractGangWorker* AbstractWorkGang::install_worker(uint worker_id) { + AbstractGangWorker* new_worker = allocate_worker(worker_id); + set_thread(worker_id, new_worker); + return new_worker; +} + +void AbstractWorkGang::add_workers(bool initializing) { + os::ThreadType worker_type; if (are_ConcurrentGC_threads()) { worker_type = os::cgc_thread; } else { worker_type = os::pgc_thread; } - for (uint worker = 0; worker < total_workers(); worker += 1) { - AbstractGangWorker* new_worker = allocate_worker(worker); - assert(new_worker != NULL, "Failed to allocate GangWorker"); - _workers[worker] = new_worker; - if (new_worker == NULL || !os::create_thread(new_worker, worker_type)) { - vm_exit_out_of_memory(0, OOM_MALLOC_ERROR, - "Cannot create worker GC thread. Out of system resources."); - return false; - } - if (!DisableStartThread) { - os::start_thread(new_worker); - } - } - return true; + + _created_workers = WorkerManager::add_workers(this, + _active_workers, + _total_workers, + _created_workers, + worker_type, + initializing); + _active_workers = MIN2(_created_workers, _active_workers); } AbstractGangWorker* AbstractWorkGang::worker(uint i) const { @@ -79,7 +88,7 @@ AbstractGangWorker* AbstractWorkGang::worker(uint i) const { } void AbstractWorkGang::print_worker_threads_on(outputStream* st) const { - uint workers = total_workers(); + uint workers = created_workers(); for (uint i = 0; i < workers; i++) { worker(i)->print_on(st); st->cr(); @@ -88,7 +97,7 @@ void AbstractWorkGang::print_worker_threads_on(outputStream* st) const { void AbstractWorkGang::threads_do(ThreadClosure* tc) const { assert(tc != NULL, "Null ThreadClosure"); - uint workers = total_workers(); + uint workers = created_workers(); for (uint i = 0; i < workers; i++) { tc->do_thread(worker(i)); } diff --git a/hotspot/src/share/vm/gc/shared/workgroup.hpp b/hotspot/src/share/vm/gc/shared/workgroup.hpp index 657b00c9a21..388909168be 100644 --- a/hotspot/src/share/vm/gc/shared/workgroup.hpp +++ b/hotspot/src/share/vm/gc/shared/workgroup.hpp @@ -112,6 +112,8 @@ class AbstractWorkGang : public CHeapObj { uint _total_workers; // The currently active workers in this gang. uint _active_workers; + // The count of created workers in the gang. + uint _created_workers; // Printing support. const char* _name; @@ -120,23 +122,32 @@ class AbstractWorkGang : public CHeapObj { const bool _are_GC_task_threads; const bool _are_ConcurrentGC_threads; + void set_thread(uint worker_id, AbstractGangWorker* worker) { + _workers[worker_id] = worker; + } + public: AbstractWorkGang(const char* name, uint workers, bool are_GC_task_threads, bool are_ConcurrentGC_threads) : _name(name), _total_workers(workers), _active_workers(UseDynamicNumberOfGCThreads ? 1U : workers), + _created_workers(0), _are_GC_task_threads(are_GC_task_threads), _are_ConcurrentGC_threads(are_ConcurrentGC_threads) { } // Initialize workers in the gang. Return true if initialization succeeded. - bool initialize_workers(); + void initialize_workers(); bool are_GC_task_threads() const { return _are_GC_task_threads; } bool are_ConcurrentGC_threads() const { return _are_ConcurrentGC_threads; } uint total_workers() const { return _total_workers; } + uint created_workers() const { + return _created_workers; + } + virtual uint active_workers() const { assert(_active_workers <= _total_workers, "_active_workers: %u > _total_workers: %u", _active_workers, _total_workers); @@ -144,22 +155,29 @@ class AbstractWorkGang : public CHeapObj { "Unless dynamic should use total workers"); return _active_workers; } + void set_active_workers(uint v) { assert(v <= _total_workers, "Trying to set more workers active than there are"); _active_workers = MIN2(v, _total_workers); + add_workers(false /* exit_on_failure */); assert(v != 0, "Trying to set active workers to 0"); - _active_workers = MAX2(1U, _active_workers); assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers, "Unless dynamic should use total workers"); log_info(gc, task)("GC Workers: using %d out of %d", _active_workers, _total_workers); } + // Add GC workers as needed. + void add_workers(bool initializing); + // Return the Ith worker. AbstractGangWorker* worker(uint i) const; void threads_do(ThreadClosure* tc) const; + // Create a GC worker and install it into the work gang. + virtual AbstractGangWorker* install_worker(uint which); + // Debugging. const char* name() const { return _name; } -- GitLab From 72f951e112562a5dcc0c06fd745e93e9d48a80b6 Mon Sep 17 00:00:00 2001 From: Alex Henrie Date: Tue, 17 Nov 2015 23:10:30 -0700 Subject: [PATCH 007/400] 8145278: Fix memory leak in splitPathList Reviewed-by: sspitsyn, dsamersoff, dcubed --- .../share/native/libinstrument/InvocationAdapter.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c index 0c57f8b289d..a74b2b725ba 100644 --- a/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c +++ b/jdk/src/java.instrument/share/native/libinstrument/InvocationAdapter.c @@ -518,18 +518,22 @@ static void splitPathList(const char* str, int* pathCount, char*** paths) { int count = 0; char** segments = NULL; + char** new_segments; char* c = (char*) str; while (*c != '\0') { while (*c == ' ') c++; /* skip leading spaces */ if (*c == '\0') { break; } - if (segments == NULL) { - segments = (char**)malloc( sizeof(char**) ); - } else { - segments = (char**)realloc( segments, (count+1)*sizeof(char**) ); + new_segments = (char**)realloc(segments, (count+1)*sizeof(char*)); + if (new_segments == NULL) { + jplis_assert(0); + free(segments); + count = 0; + segments = NULL; + break; } - jplis_assert(segments != (char**)NULL); + segments = new_segments; segments[count++] = c; c = strchr(c, ' '); if (c == NULL) { -- GitLab From 34abb0688722c725998916cf5b61d7660c24e0c4 Mon Sep 17 00:00:00 2001 From: Gil Tene Date: Wed, 30 Mar 2016 17:04:09 +0200 Subject: [PATCH 008/400] 8147844: new method j.l.Thread.onSpinWait() and the corresponding x86 hotspot instrinsic See JEP-285 for details Co-authored-by: Ivan Krylov Reviewed-by: psandoz, alanb, dholmes --- .../share/classes/java/lang/Thread.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/jdk/src/java.base/share/classes/java/lang/Thread.java b/jdk/src/java.base/share/classes/java/lang/Thread.java index eb47a05427d..972815e16c7 100644 --- a/jdk/src/java.base/share/classes/java/lang/Thread.java +++ b/jdk/src/java.base/share/classes/java/lang/Thread.java @@ -340,6 +340,45 @@ class Thread implements Runnable { sleep(millis); } + /** + * Indicates that the caller is momentarily unable to progress, until the + * occurrence of one or more actions on the part of other activities. By + * invoking this method within each iteration of a spin-wait loop construct, + * the calling thread indicates to the runtime that it is busy-waiting. + * The runtime may take action to improve the performance of invoking + * spin-wait loop constructions. + *

+ * @apiNote + * As an example consider a method in a class that spins in a loop until + * some flag is set outside of that method. A call to the {@code onSpinWait} + * method should be placed inside the spin loop. + *

{@code
+     *     class EventHandler {
+     *         volatile boolean eventNotificationNotReceived;
+     *         void waitForEventAndHandleIt() {
+     *             while ( eventNotificationNotReceived ) {
+     *                 java.lang.Thread.onSpinWait();
+     *             }
+     *             readAndProcessEvent();
+     *         }
+     *
+     *         void readAndProcessEvent() {
+     *             // Read event from some source and process it
+     *              . . .
+     *         }
+     *     }
+     * }
+ *

+ * The code above would remain correct even if the {@code onSpinWait} + * method was not called at all. However on some architectures the Java + * Virtual Machine may issue the processor instructions to address such + * code patterns in a more beneficial way. + *

+ * @since 9 + */ + @HotSpotIntrinsicCandidate + public static void onSpinWait() {} + /** * Initializes a Thread with the current AccessControlContext. * @see #init(ThreadGroup,Runnable,String,long,AccessControlContext,boolean) -- GitLab From fd6507d3538a451cdeb8b31ea2ea8633d66c466e Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Wed, 20 Apr 2016 09:57:01 +0200 Subject: [PATCH 009/400] 8072921: -Xincgc should be removed from output Reviewed-by: alanb --- .../share/classes/sun/launcher/resources/launcher.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties index 52d621b414d..f678ba37057 100644 --- a/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties +++ b/jdk/src/java.base/share/classes/sun/launcher/resources/launcher.properties @@ -99,7 +99,6 @@ java.launcher.X.usage=\ \ -Xdiag show additional diagnostic messages\n\ \ -Xdiag:resolver show resolver diagnostic messages\n\ \ -Xnoclassgc disable class garbage collection\n\ -\ -Xincgc enable incremental garbage collection\n\ \ -Xloggc: log GC status to a file with time stamps\n\ \ -Xbatch disable background compilation\n\ \ -Xms set initial Java heap size\n\ -- GitLab From 3f6fc8998db487dbf80789d6ae78b07d3aed2933 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Wed, 20 Apr 2016 18:01:02 +0300 Subject: [PATCH 010/400] 8152847: JDI use of sun.boot.class.path needs to be updated for Jigsaw Remove references to bootclasspath Reviewed-by: alanb, sspitsyn --- .../share/classes/com/sun/tools/example/debug/tty/Commands.java | 1 - .../classes/com/sun/tools/example/debug/tty/TTYResources.java | 1 - .../com/sun/tools/example/debug/tty/TTYResources_ja.java | 1 - .../com/sun/tools/example/debug/tty/TTYResources_zh_CN.java | 1 - .../share/classes/com/sun/tools/jdi/VirtualMachineImpl.java | 2 +- 5 files changed, 1 insertion(+), 5 deletions(-) diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java index 61823822d0e..11a376e0f22 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/Commands.java @@ -1534,7 +1534,6 @@ class Commands { PathSearchingVirtualMachine vm = (PathSearchingVirtualMachine)Env.vm(); MessageOutput.println("base directory:", vm.baseDirectory()); MessageOutput.println("classpath:", vm.classPath().toString()); - MessageOutput.println("bootclasspath:", vm.bootClassPath().toString()); } else { MessageOutput.println("The VM does not use paths"); } diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java index c412743c4b6..39e703d88b8 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources.java @@ -74,7 +74,6 @@ public class TTYResources extends java.util.ListResourceBundle { {"Array element is not a method", "Array element is not a method"}, {"Array index must be a integer type", "Array index must be a integer type"}, {"base directory:", "base directory: {0}"}, - {"bootclasspath:", "bootclasspath: {0}"}, {"Breakpoint hit:", "Breakpoint hit: "}, {"breakpoint", "breakpoint {0}"}, {"Breakpoints set:", "Breakpoints set:"}, diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java index 1cb6d231d50..b3562226398 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_ja.java @@ -74,7 +74,6 @@ public class TTYResources_ja extends java.util.ListResourceBundle { {"Array element is not a method", "\u914D\u5217\u8981\u7D20\u306F\u30E1\u30BD\u30C3\u30C9\u3067\u306F\u3042\u308A\u307E\u305B\u3093"}, {"Array index must be a integer type", "\u914D\u5217\u306E\u6DFB\u3048\u5B57\u306F\u6574\u6570\u578B\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059"}, {"base directory:", "\u30D9\u30FC\u30B9\u30FB\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA: {0}"}, - {"bootclasspath:", "\u30D6\u30FC\u30C8\u30FB\u30AF\u30E9\u30B9\u30D1\u30B9: {0}"}, {"Breakpoint hit:", "\u30D2\u30C3\u30C8\u3057\u305F\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8: "}, {"breakpoint", "\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8{0}"}, {"Breakpoints set:", "\u8A2D\u5B9A\u3055\u308C\u3066\u3044\u308B\u30D6\u30EC\u30FC\u30AF\u30DD\u30A4\u30F3\u30C8:"}, diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java index 50790cb9d72..79dc9268da0 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTYResources_zh_CN.java @@ -74,7 +74,6 @@ public class TTYResources_zh_CN extends java.util.ListResourceBundle { {"Array element is not a method", "\u6570\u7EC4\u5143\u7D20\u4E0D\u662F\u65B9\u6CD5"}, {"Array index must be a integer type", "\u6570\u7EC4\u7D22\u5F15\u5FC5\u987B\u4E3A\u6574\u6570\u7C7B\u578B"}, {"base directory:", "\u57FA\u76EE\u5F55: {0}"}, - {"bootclasspath:", "\u5F15\u5BFC\u7C7B\u8DEF\u5F84: {0}"}, {"Breakpoint hit:", "\u65AD\u70B9\u547D\u4E2D: "}, {"breakpoint", "\u65AD\u70B9{0}"}, {"Breakpoints set:", "\u65AD\u70B9\u96C6:"}, diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java index 47e743483e3..28c3dfbfa3c 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/jdi/VirtualMachineImpl.java @@ -1439,7 +1439,7 @@ class VirtualMachineImpl extends MirrorImpl } public List bootClassPath() { - return Arrays.asList(getClasspath().bootclasspaths); + return Collections.emptyList(); } public String baseDirectory() { -- GitLab From ebbecb1b63493e47e7ad3a4d49698564ae1ac99a Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Thu, 21 Apr 2016 13:18:46 +0300 Subject: [PATCH 011/400] 8143921: nsk/jdi/ObjectReference/waitingThreads/waitingthreads003 fails with JVMTI_ERROR_INVALID_CLASS Skip invalid classes Reviewed-by: sspitsyn --- .../share/native/libjdwp/VirtualMachineImpl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c index 2718ad1e3a4..8e1639c5e2e 100644 --- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c +++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/VirtualMachineImpl.c @@ -126,7 +126,7 @@ classesForSignature(PacketInputStream *in, PacketOutputStream *out) int writtenCount = 0; int i; - for (i=0; i Date: Mon, 25 Apr 2016 15:32:35 +0200 Subject: [PATCH 012/400] 8154529: some places in the invoke.c that use InvokeRequest* not protected with invokerLock Reviewed-by: sspitsyn --- .../share/native/libjdwp/invoker.c | 21 +++++++------------ .../share/native/libjdwp/invoker.h | 1 - 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c index cd1cd2f7dc0..3baf486c233 100644 --- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c +++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.c @@ -277,12 +277,14 @@ invoker_enableInvokeRequests(jthread thread) JDI_ASSERT(thread); + debugMonitorEnter(invokerLock); request = threadControl_getInvokeRequest(thread); if (request == NULL) { EXIT_ERROR(AGENT_ERROR_INVALID_THREAD, "getting thread invoke request"); } request->available = JNI_TRUE; + debugMonitorExit(invokerLock); } jvmtiError @@ -738,30 +740,21 @@ invoker_completeInvokeRequest(jthread thread) } } -jboolean -invoker_isPending(jthread thread) -{ - InvokeRequest *request; - - JDI_ASSERT(thread); - request = threadControl_getInvokeRequest(thread); - if (request == NULL) { - EXIT_ERROR(AGENT_ERROR_INVALID_THREAD, "getting thread invoke request"); - } - return request->pending; -} - jboolean invoker_isEnabled(jthread thread) { InvokeRequest *request; + jboolean isEnabled; JDI_ASSERT(thread); + debugMonitorEnter(invokerLock); request = threadControl_getInvokeRequest(thread); if (request == NULL) { EXIT_ERROR(AGENT_ERROR_INVALID_THREAD, "getting thread invoke request"); } - return request->available; + isEnabled = request->available; + debugMonitorExit(invokerLock); + return isEnabled; } void diff --git a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.h b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.h index 29ecdb5d59c..e004ce6ef8e 100644 --- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.h +++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/invoker.h @@ -67,7 +67,6 @@ jvmtiError invoker_requestInvoke(jbyte invokeType, jbyte options, jint id, jboolean invoker_doInvoke(jthread thread); void invoker_completeInvokeRequest(jthread thread); -jboolean invoker_isPending(jthread thread); jboolean invoker_isEnabled(jthread thread); void invoker_detach(InvokeRequest *request); -- GitLab From af802cb54114616dc74217ac91a65ecdb15d144f Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Mon, 25 Apr 2016 19:14:30 +0300 Subject: [PATCH 013/400] 7124381: DragSourceListener.dragDropEnd() never been called on completion of dnd operation Reviewed-by: yan, ssadetsky --- .../dnd/Button2DragTest/Button2DragTest.html | 45 ----------- .../dnd/Button2DragTest/Button2DragTest.java | 80 +++++++++---------- 2 files changed, 40 insertions(+), 85 deletions(-) delete mode 100644 jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html diff --git a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html b/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html deleted file mode 100644 index 91dcf4f413d..00000000000 --- a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - -

Button2DragTest
Bug ID: 4955110

- -

This is an AUTOMATIC test, simply wait for completion

- - - - diff --git a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java b/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java index 33bb5058706..c5045ed7fa7 100644 --- a/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java +++ b/jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,45 +21,52 @@ * questions. */ -/* - test - @bug 4955110 - @summary tests that a drag ends on button2 release - @author Alexander.Gerasimov area=dnd - @library ../../regtesthelpers - @build Util - @run applet/othervm Button2DragTest.html -*/ +import java.awt.Frame; +import java.awt.Point; +import java.awt.Robot; +import java.awt.datatransfer.StringSelection; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DragGestureEvent; +import java.awt.dnd.DragGestureListener; +import java.awt.dnd.DragSource; +import java.awt.dnd.DragSourceAdapter; +import java.awt.dnd.DragSourceDropEvent; +import java.awt.dnd.DragSourceListener; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetAdapter; +import java.awt.dnd.DropTargetDropEvent; +import java.awt.event.InputEvent; +import test.java.awt.regtesthelpers.Util; /** - * Button2DragTest.java - * - * summary: tests that DragSourceDragEvent.getDropAction() accords to its new spec - * (does not depend on the user drop action) - * + * @test + * @bug 4955110 + * @summary tests that DragSourceDragEvent.getDropAction() accords to its new + * spec (does not depend on the user drop action) + * @library ../../regtesthelpers + * @build Util + * @run main/othervm Button2DragTest + * @author Alexander.Gerasimov area=dnd */ - -import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; -import java.awt.datatransfer.*; -import java.awt.dnd.*; -import test.java.awt.regtesthelpers.Util; - - -public class Button2DragTest extends Applet { +public final class Button2DragTest { private volatile boolean dropSuccess; - private Frame frame; + private static Frame frame; + public static void main(final String[] args) { + Button2DragTest test = new Button2DragTest(); + try { + test.run(); + } finally { + if (frame != null) { + frame.dispose(); + } + } + } - public void init() { - // Set up the environment -- set the layout manager, add - // buttons, etc. - setLayout(new BorderLayout()); - + public void run() { frame = new Frame(); final DragSourceListener dragSourceListener = new DragSourceAdapter() { @@ -84,20 +91,13 @@ public class Button2DragTest extends Applet { } }; new DropTarget(frame, dropTargetListener); - } - - - public void start() { - //Get things going. Request focus, set size, et cetera - setSize(200,200); - setVisible(true); - validate(); //What would normally go into main() will probably go here. //Use System.out.println for diagnostic messages that you want //to read after the test is done. - + frame.setUndecorated(true); frame.setBounds(100, 100, 200, 200); + frame.setLocationRelativeTo(null); frame.setVisible(true); Robot robot = Util.createRobot(); -- GitLab From 5874c487963e3aaf423b2c43cd18b8f1a290347e Mon Sep 17 00:00:00 2001 From: Avik Niyogi Date: Wed, 27 Apr 2016 12:08:37 +0400 Subject: [PATCH 014/400] 8152492: [macosx swing] double key event actions when using Mac menubar Reviewed-by: serb, mhalder, alexsch --- .../native/libawt_lwawt/awt/CMenuItem.m | 113 ++++++------------ .../ActionListenerCalledTwiceTest.java | 33 +++-- 2 files changed, 59 insertions(+), 87 deletions(-) diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m index 28e4f386d78..e6b7e21bccb 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/CMenuItem.m @@ -25,7 +25,6 @@ #import #include - #import "CMenuItem.h" #import "CMenu.h" #import "AWTEvent.h" @@ -64,42 +63,6 @@ - (BOOL) worksWhenModal { return YES; } -// This is a method written using Carbon framework methods to remove -// All modifiers including "Shift" modifier. -// Example 1: Shortcut set is "Command Shift m" returns "m" -// Example 2: Shortcut set is "Command m" returns "m" -// Example 3: Shortcut set is "Alt Shift ," returns "," - -CFStringRef createStringForKey(CGKeyCode keyCode) -{ - TISInputSourceRef currentKeyboard = TISCopyCurrentKeyboardInputSource(); -// currentKeyboard now contains the current input source - CFDataRef layoutData = - TISGetInputSourceProperty(currentKeyboard, - kTISPropertyUnicodeKeyLayoutData); -// the UNICODE keyLayout is fetched from currentKeyboard in layoutData - const UCKeyboardLayout *keyboardLayout = - (const UCKeyboardLayout *)CFDataGetBytePtr(layoutData); -// A read-only data pointer is fetched from layoutData - UInt32 keysDown = 0; - UniChar chars[4]; - UniCharCount realLength; - - UCKeyTranslate(keyboardLayout, - keyCode, - kUCKeyActionDisplay, - 0, - LMGetKbdType(), - kUCKeyTranslateNoDeadKeysBit, - &keysDown, - sizeof(chars) / sizeof(chars[0]), - &realLength, - chars); - CFRelease(currentKeyboard); -// Converts keyCode, modifier and dead-key state into UNICODE characters - return CFStringCreateWithCharacters(kCFAllocatorDefault, chars, 1); -} - // Events - (void)handleAction:(NSMenuItem *)sender { AWT_ASSERT_APPKIT_THREAD; @@ -116,35 +79,6 @@ CFStringRef createStringForKey(CGKeyCode keyCode) // from this "frameless" menu, because there are no active windows. This // means we have to handle it here. NSEvent *currEvent = [[NSApplication sharedApplication] currentEvent]; - if ([currEvent type] == NSKeyDown) { - NSString *menuKey = [sender keyEquivalent]; -// If shortcut is "Command Shift ," the menuKey gets the value "," -// But [currEvent charactersIgnoringModifiers]; returns "<" and not "," -// because the charactersIgnoreingModifiers does not ignore "Shift" -// So a shortcut like "Command Shift m" will return "M" where as the -// MenuKey will have the value "m". To remove this issue the below -// createStringForKey is used. - NSString *eventKey = createStringForKey([currEvent keyCode]); - -// Apple uses characters from private Unicode range for some of the -// keys, so we need to do the same translation here that we do -// for the regular key down events - if ([eventKey length] == 1) { - unichar origChar = [eventKey characterAtIndex:0]; - unichar newChar = NsCharToJavaChar(origChar, 0); - if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) { - newChar = origChar; - } - - eventKey = [NSString stringWithCharacters: &newChar length: 1]; - } - - NSWindow *keyWindow = [NSApp keyWindow]; - if ([menuKey isEqualToString:eventKey] && keyWindow != nil) { - return; - } - } - if (fIsCheckbox) { static JNF_CLASS_CACHE(jc_CCheckboxMenuItem, "sun/lwawt/macosx/CCheckboxMenuItem"); static JNF_MEMBER_CACHE(jm_ckHandleAction, jc_CCheckboxMenuItem, "handleAction", "(Z)V"); @@ -154,16 +88,47 @@ CFStringRef createStringForKey(CGKeyCode keyCode) NSInteger state = [sender state]; jboolean newState = (state == NSOnState ? JNI_FALSE : JNI_TRUE); JNFCallVoidMethod(env, fPeer, jm_ckHandleAction, newState); - } else { - static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem"); - static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event) - - NSUInteger modifiers = [currEvent modifierFlags]; - jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO); - - JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event) + } + else { + if ([currEvent type] == NSKeyDown) { + + // Event available through sender variable hence NSApplication + // not needed for checking the keyboard input sans the modifier keys + // Also, the method used to fetch eventKey earlier would be locale dependent + // With earlier implementation, if MenuKey: e EventKey: ा ; if input method + // is not U.S. (Devanagari in this case) + // With current implementation, EventKey = MenuKey = e irrespective of + // input method + + NSString *eventKey = [sender keyEquivalent]; + // Apple uses characters from private Unicode range for some of the + // keys, so we need to do the same translation here that we do + // for the regular key down events + if ([eventKey length] == 1) { + unichar origChar = [eventKey characterAtIndex:0]; + unichar newChar = NsCharToJavaChar(origChar, 0); + if (newChar == java_awt_event_KeyEvent_CHAR_UNDEFINED) { + newChar = origChar; + } + eventKey = [NSString stringWithCharacters: &newChar length: 1]; + } + NSWindow *keyWindow = [NSApp keyWindow]; + if (keyWindow != nil) { + return; + } + else { + static JNF_CLASS_CACHE(jc_CMenuItem, "sun/lwawt/macosx/CMenuItem"); + static JNF_MEMBER_CACHE(jm_handleAction, jc_CMenuItem, "handleAction", "(JI)V"); // AWT_THREADING Safe (event) + + NSUInteger modifiers = [currEvent modifierFlags]; + jint javaModifiers = NsKeyModifiersToJavaModifiers(modifiers, NO); + + JNFCallVoidMethod(env, fPeer, jm_handleAction, UTC(currEvent), javaModifiers); // AWT_THREADING Safe (event) + } + } } JNF_COCOA_EXIT(env); + } - (void) setJavaLabel:(NSString *)theLabel shortcut:(NSString *)theKeyEquivalent modifierMask:(jint)modifiers { diff --git a/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java b/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java index 1a9f42120e2..589bb9b5744 100644 --- a/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java +++ b/jdk/test/javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.java @@ -21,23 +21,23 @@ * questions. */ -/* + /* * @test - * @bug 7160951 + * @bug 7160951 8152492 * @summary [macosx] ActionListener called twice for JMenuItem using ScreenMenuBar * @author vera.akulova@oracle.com * @library ../../../../lib/testlibrary * @build jdk.testlibrary.OSInfo * @run main ActionListenerCalledTwiceTest */ - import jdk.testlibrary.OSInfo; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class ActionListenerCalledTwiceTest { - static String menuItems[] = { "Item1", "Item2", "Item3", "Item4", "Item5", "Item6" }; + + static String menuItems[] = {"Item1", "Item2", "Item3", "Item4", "Item5", "Item6"}; static KeyStroke keyStrokes[] = { KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.META_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), @@ -46,8 +46,10 @@ public class ActionListenerCalledTwiceTest { KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK), KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.META_MASK) }; - + static JMenu menu; + static JFrame frame; static volatile int listenerCallCounter = 0; + public static void main(String[] args) throws Exception { if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { System.out.println("This test is for MacOS only. Automatically passed on other platforms."); @@ -82,33 +84,38 @@ public class ActionListenerCalledTwiceTest { robot.waitForIdle(); if (listenerCallCounter != 1) { - throw new Exception("Test failed: ActionListener for " + menuItems[i] + - " called " + listenerCallCounter + " times instead of 1!"); + throw new Exception("Test failed: ActionListener for " + menuItems[i] + + " called " + listenerCallCounter + " times instead of 1!"); } listenerCallCounter = 0; } + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame.dispose(); + } + }); } private static void createAndShowGUI() { - JMenu menu = new JMenu("Menu"); + menu = new JMenu("Menu"); for (int i = 0; i < menuItems.length; ++i) { JMenuItem newItem = new JMenuItem(menuItems[i]); newItem.setAccelerator(keyStrokes[i]); newItem.addActionListener( - new ActionListener(){ - public void actionPerformed(ActionEvent e) { - listenerCallCounter++; - } + new ActionListener() { + public void actionPerformed(ActionEvent e) { + listenerCallCounter++; } + } ); menu.add(newItem); } JMenuBar bar = new JMenuBar(); bar.add(menu); - JFrame frame = new JFrame("Test"); + frame = new JFrame("Test"); frame.setJMenuBar(bar); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); -- GitLab From eb3750d326afb8d965fe737ac92c7562010b8aef Mon Sep 17 00:00:00 2001 From: Manajit Halder Date: Wed, 27 Apr 2016 13:09:58 +0300 Subject: [PATCH 015/400] 8151136: [macosx] According to the description, the case is failed Reviewed-by: ssadetsky, aniyogi --- .../macosx/native/libawt_lwawt/awt/AWTEvent.m | 28 +++++++++++++++---- .../AltGraphModifierTest.java | 13 +++++---- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m index 9b8e370a938..e57074ee74c 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTEvent.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -282,11 +282,19 @@ const nsKeyToJavaModifierTable[] = //kCGSFlagsMaskAppleLeftAlternateKey, //kCGSFlagsMaskAppleRightAlternateKey, 58, - 61, + 0, java_awt_event_InputEvent_ALT_DOWN_MASK, java_awt_event_InputEvent_ALT_MASK, java_awt_event_KeyEvent_VK_ALT }, + { + NSAlternateKeyMask, + 0, + 61, + java_awt_event_InputEvent_ALT_DOWN_MASK | java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK, + java_awt_event_InputEvent_ALT_MASK | java_awt_event_InputEvent_ALT_GRAPH_MASK, + java_awt_event_KeyEvent_VK_ALT + }, { NSCommandKeyMask, //kCGSFlagsMaskAppleLeftCommandKey, @@ -310,6 +318,8 @@ const nsKeyToJavaModifierTable[] = {0, 0, 0, 0, 0, 0} }; +static BOOL leftAltKeyPressed; + /* * Almost all unicode characters just go from NS to Java with no translation. * For the few exceptions, we handle it here with this small table. @@ -523,13 +533,17 @@ NsKeyModifiersToJavaKeyInfo(NSUInteger nsFlags, unsigned short eventKeyCode, // *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_RIGHT; //} if (eventKeyCode == cur->leftKeyCode) { + leftAltKeyPressed = YES; *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_LEFT; } else if (eventKeyCode == cur->rightKeyCode) { *javaKeyLocation = java_awt_event_KeyEvent_KEY_LOCATION_RIGHT; + } else if (cur->nsMask == NSAlternateKeyMask) { + leftAltKeyPressed = NO; + continue; } *javaKeyType = (cur->nsMask & nsFlags) ? - java_awt_event_KeyEvent_KEY_PRESSED : - java_awt_event_KeyEvent_KEY_RELEASED; + java_awt_event_KeyEvent_KEY_PRESSED : + java_awt_event_KeyEvent_KEY_RELEASED; break; } } @@ -545,7 +559,11 @@ jint NsKeyModifiersToJavaModifiers(NSUInteger nsFlags, BOOL isExtMods) for (cur = nsKeyToJavaModifierTable; cur->nsMask != 0; ++cur) { if ((cur->nsMask & nsFlags) != 0) { - javaModifiers |= isExtMods? cur->javaExtMask : cur->javaMask; + javaModifiers |= isExtMods ? cur->javaExtMask : cur->javaMask; + if (cur->nsMask == NSAlternateKeyMask && leftAltKeyPressed == NO) { + continue; + } + break; } } diff --git a/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java b/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java index 92dcc214376..00c471ad7f4 100644 --- a/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java +++ b/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ public class AltGraphModifierTest { "3. If Alt-Gr key is not present, press Ctrl+Alt keys &", " perform mouse click on the TestWindow.", "4. Test will exit by itself with appropriate result.", - "", + " ", "Linux :-", "1. Please check if Alt-Gr key is present on keyboard.", "2. If present, press the Alt-Gr key and perform", @@ -63,10 +63,11 @@ public class AltGraphModifierTest { "6. Press Right Alt Key & perform mouse click on the", " TestWindow", "7. Test will exit by itself with appropriate result.", - "", + " ", "Mac :-", - " Mac fix is under progress, & will be fixed soon.", - " Please click Fail" + "1. Press Right Option key on the keyboard and mouse click", + " on the TestWindow", + "3. Test will exit by itself with appropriate result.", }; Sysout.createDialog(); @@ -77,7 +78,7 @@ public class AltGraphModifierTest { public static void initTestWindow() { mainFrame = new Frame(); mainFrame.setTitle("TestWindow"); - mainFrame.setSize(300, 200); + mainFrame.setBounds(700, 10, 300, 300); mainFrame.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { -- GitLab From 8f5fb772b45cce20bdb89917d931c22dc078c034 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Thu, 28 Apr 2016 00:38:21 -0700 Subject: [PATCH 016/400] 8153749: New capability can_generate_early_class_hook_events Add new capability Reviewed-by: alanb, dsamersoff --- jdk/src/java.base/share/native/include/jvmti.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/native/include/jvmti.h b/jdk/src/java.base/share/native/include/jvmti.h index 684fd2d7046..5f8835c0baa 100644 --- a/jdk/src/java.base/share/native/include/jvmti.h +++ b/jdk/src/java.base/share/native/include/jvmti.h @@ -704,7 +704,8 @@ typedef struct { unsigned int can_generate_resource_exhaustion_heap_events : 1; unsigned int can_generate_resource_exhaustion_threads_events : 1; unsigned int can_generate_early_vmstart : 1; - unsigned int : 6; + unsigned int can_generate_early_class_hook_events : 1; + unsigned int : 5; unsigned int : 16; unsigned int : 16; unsigned int : 16; -- GitLab From 0a29c9196258f080fa24e7bac2febfbce479e072 Mon Sep 17 00:00:00 2001 From: Alexander Stepanov Date: Thu, 28 Apr 2016 19:35:09 +0300 Subject: [PATCH 017/400] 8155021: [TEST] create one more inheritance test for @BeanProperty Reviewed-by: serb --- .../AnonymousClassBeanPropertyTest.java | 218 ++- .../beans/Introspector/BeanPropertyTest.java | 85 +- .../InheritanceBeanPropertyTest.java | 1281 +++++++++++++++++ 3 files changed, 1552 insertions(+), 32 deletions(-) create mode 100644 jdk/test/java/beans/Introspector/InheritanceBeanPropertyTest.java diff --git a/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java b/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java index a8ec7d49188..b5fc3667b94 100644 --- a/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java +++ b/jdk/test/java/beans/Introspector/AnonymousClassBeanPropertyTest.java @@ -33,7 +33,7 @@ import java.util.Arrays; /** * @test - * @bug 8132973 8132732 8155013 + * @bug 8132973 8132732 8155013 8154958 * @summary Some check for BeanProperty annotation * @author a.stepanov * @run main AnonymousClassBeanPropertyTest @@ -62,6 +62,10 @@ public class AnonymousClassBeanPropertyTest { // ---------- test cases (interfaces) ---------- + public interface IPublic { + double getX(); + } + private interface IGet { double getX(); } @@ -113,6 +117,10 @@ public class AnonymousClassBeanPropertyTest { void setX(double a[]); } + private interface IIs { + boolean isX(); + } + // ---------- checks ---------- @@ -124,7 +132,7 @@ public class AnonymousClassBeanPropertyTest { return ok; } - private static boolean checkInfo(Class c, String what) { + private static boolean checkInfo(Class c, String what, boolean checkVals) { BeanInfo i; try { i = Introspector.getBeanInfo(c, Object.class); } @@ -154,6 +162,8 @@ public class AnonymousClassBeanPropertyTest { ok &= check("visualUpdate", (boolean) d.getValue("visualUpdate"), UPDATE); + if (!checkVals) { return ok; } + Object vals[] = (Object[]) d.getValue("enumerationValues"); if (vals == null) { System.out.println("null enumerationValues"); @@ -210,8 +220,10 @@ public class AnonymousClassBeanPropertyTest { (boolean) d.getValue("visualUpdate"), !UPDATE); Object vals[] = (Object[]) d.getValue("enumerationValues"); - if (vals != null || vals.length > 0) { - System.out.println("non-empty enumerationValues"); + if (vals != null && vals.length > 0) { + System.out.println("non-empty enumerationValues:"); + for (Object v: vals) { System.out.print(v.toString()); } + System.out.println(); return false; } @@ -228,6 +240,31 @@ public class AnonymousClassBeanPropertyTest { //---------------------------------------------------------------------- + // TODO: please uncomment/update after 8154958 fix + /* + IPublic testPublic = new IPublic() { + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + @Override + public double getX() { return X; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + }; + ok = checkInfo(testPublic.getClass(), "IPublic", true); + System.out.println("OK = " + ok); + passed = passed && ok; + */ + + //---------------------------------------------------------------------- + IGet testGet = new IGet() { @BeanProperty( description = DESCRIPTION, @@ -244,7 +281,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGet.getClass(), "IGet"); + ok = checkInfo(testGet.getClass(), "IGet", true); System.out.println("OK = " + ok); passed = passed && ok; @@ -269,7 +306,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testSet.getClass(), "ISet"); + ok = checkInfo(testSet.getClass(), "ISet", true); System.out.println("OK = " + ok); passed = passed && ok; @@ -294,7 +331,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetByIndex.getClass(), "IGetByIndex"); + ok = checkInfo(testGetByIndex.getClass(), "IGetByIndex", true); System.out.println("OK = " + ok); passed = passed && ok; @@ -319,7 +356,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testSetByIndex.getClass(), "ISetByIndex"); + ok = checkInfo(testSetByIndex.getClass(), "ISetByIndex", true); System.out.println("OK = " + ok); passed = passed && ok; @@ -346,7 +383,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetArray.getClass(), "IGetArray"); + ok = checkInfo(testGetArray.getClass(), "IGetArray", true); System.out.println("OK = " + ok); passed = passed && ok; */ @@ -374,7 +411,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testSetArray.getClass(), "ISetArray"); + ok = checkInfo(testSetArray.getClass(), "ISetArray", true); System.out.println("OK = " + ok); passed = passed && ok; */ @@ -402,7 +439,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetBoth_1.getClass(), "IGetBoth-1"); + ok = checkInfo(testGetBoth_1.getClass(), "IGetBoth-1", true); System.out.println("OK = " + ok); passed = passed && ok; @@ -429,7 +466,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetBoth_2.getClass(), "IGetBoth-2"); + ok = checkInfo(testGetBoth_2.getClass(), "IGetBoth-2", true); System.out.println("OK = " + ok); passed = passed && ok; */ @@ -465,11 +502,11 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetBoth_3.getClass(), "IGetBoth-3"); + ok = checkInfo(testGetBoth_3.getClass(), "IGetBoth-3", true); System.out.println("OK = " + ok); ok2 = checkAlternativeInfo(testGetBoth_3.getClass(), "IGetBoth-3"); System.out.println("OK = " + ok2); - passed = passed && ok && ok2; + passed = passed && (ok || ok2); */ //---------------------------------------------------------------------- @@ -495,7 +532,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testSetBoth_1.getClass(), "ISetBoth-1"); + ok = checkInfo(testSetBoth_1.getClass(), "ISetBoth-1", true); System.out.println("OK = " + ok); passed = passed && ok; @@ -522,7 +559,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testSetBoth_2.getClass(), "ISetBoth-2"); + ok = checkInfo(testSetBoth_2.getClass(), "ISetBoth-2", true); System.out.println("OK = " + ok); passed = passed && ok; */ @@ -558,11 +595,11 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testSetBoth_3.getClass(), "ISetBoth-3"); + ok = checkInfo(testSetBoth_3.getClass(), "ISetBoth-3", true); System.out.println("OK = " + ok); ok2 = checkAlternativeInfo(testSetBoth_3.getClass(), "ISetBoth-3"); System.out.println("OK = " + ok2); - passed = passed && ok && ok2; + passed = passed && (ok || ok2); */ //---------------------------------------------------------------------- @@ -588,7 +625,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetSet_1.getClass(), "IGetSet-1"); + ok = checkInfo(testGetSet_1.getClass(), "IGetSet-1", true); System.out.println("OK = " + ok); passed = passed && ok; @@ -614,7 +651,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetSet_2.getClass(), "IGetSet-2"); + ok = checkInfo(testGetSet_2.getClass(), "IGetSet-2", true); System.out.println("OK = " + ok); passed = passed && ok; @@ -649,11 +686,11 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetSet_3.getClass(), "IGetSet-3"); + ok = checkInfo(testGetSet_3.getClass(), "IGetSet-3", true); System.out.println("OK = " + ok); ok2 = checkAlternativeInfo(testGetSet_3.getClass(), "IGetSet-3"); System.out.println("OK = " + ok2); - passed = passed && ok && ok2; + passed = passed && (ok || ok2); */ //---------------------------------------------------------------------- @@ -679,7 +716,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetSetByIndex_1.getClass(), "IGetSetByIndex-1"); + ok = checkInfo(testGetSetByIndex_1.getClass(), "IGetSetByIndex-1", true); System.out.println("OK = " + ok); passed = passed && ok; @@ -705,7 +742,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetSetByIndex_2.getClass(), "IGetSetByIndex-2"); + ok = checkInfo(testGetSetByIndex_2.getClass(), "IGetSetByIndex-2", true); System.out.println("OK = " + ok); passed = passed && ok; @@ -744,12 +781,12 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetSetByIndex_3.getClass(), "IGetSetByIndex-3"); + ok = checkInfo(testGetSetByIndex_3.getClass(), "IGetSetByIndex-3", true); System.out.println("OK = " + ok); ok2 = checkAlternativeInfo( testGetSetByIndex_3.getClass(), "IGetSetByIndex-3"); System.out.println("OK = " + ok2); - passed = passed && ok && ok2; + passed = passed && (ok || ok2); */ //---------------------------------------------------------------------- @@ -781,7 +818,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetSetBoth_1.getClass(), "IGetSetBoth-1"); + ok = checkInfo(testGetSetBoth_1.getClass(), "IGetSetBoth-1", true); System.out.println("OK = " + ok); passed = passed && ok; */ @@ -813,7 +850,7 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetSetBoth_2.getClass(), "IGetSetBoth-2"); + ok = checkInfo(testGetSetBoth_2.getClass(), "IGetSetBoth-2", true); System.out.println("OK = " + ok); passed = passed && ok; */ @@ -853,14 +890,135 @@ public class AnonymousClassBeanPropertyTest { public void addPropertyChangeListener(PropertyChangeListener l) {} public void removePropertyChangeListener(PropertyChangeListener l) {} }; - ok = checkInfo(testGetSetBoth_3.getClass(), "IGetSetBoth-3"); + ok = checkInfo(testGetSetBoth_3.getClass(), "IGetSetBoth-3", true); System.out.println("OK = " + ok); ok2 = checkAlternativeInfo( testGetSetBoth_3.getClass(), "IGetSetBoth-3"); System.out.println("OK = " + ok2); - passed = passed && ok && ok2; + passed = passed && (ok || ok2); + */ + + //---------------------------------------------------------------------- + + IIs testIs_1 = new IIs() { + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + @Override + public boolean isX() { return false; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + }; + ok = checkInfo(testIs_1.getClass(), "IIs-1", false); + System.out.println("OK = " + ok); + passed = passed && ok; + + + IIs testIs_2 = new IIs() { + + private boolean b; + + @Override + public boolean isX() { return b; } + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + public void setX(boolean v) { b = v; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + }; + ok = checkInfo(testIs_2.getClass(), "IIs-2", false); + System.out.println("OK = " + ok); + passed = passed && ok; + + + IIs testIs_3 = new IIs() { + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + @Override + public boolean isX() { return false; } + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public boolean getX() { return false; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + }; + ok = checkInfo(testIs_3.getClass(), "IIs-3", false); + System.out.println("OK = " + ok); + ok2 = checkAlternativeInfo(testIs_3.getClass(), "IIs-3"); + System.out.println("OK = " + ok2); + passed = passed && (ok || ok2); + + // TODO: please uncomment/update after 8132973 fix + /* + IIs testIs_4 = new IIs() { + + private boolean b; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + @Override + public boolean isX() { return b; } + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public void setX(boolean v) { b = v; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + }; + ok = checkInfo(testIs_4.getClass(), "IIs-4", false); + System.out.println("OK = " + ok); + ok2 = checkAlternativeInfo(testIs_4.getClass(), "IIs-4"); + System.out.println("OK = " + ok2); + passed = passed && (ok || ok2); */ + + //---------------------------------------------------------------------- + + if (!passed) { throw new RuntimeException("test failed"); } System.out.println("\ntest passed"); } diff --git a/jdk/test/java/beans/Introspector/BeanPropertyTest.java b/jdk/test/java/beans/Introspector/BeanPropertyTest.java index 6f957074c6e..5e84aaaed4e 100644 --- a/jdk/test/java/beans/Introspector/BeanPropertyTest.java +++ b/jdk/test/java/beans/Introspector/BeanPropertyTest.java @@ -33,7 +33,7 @@ import java.util.Arrays; /** * @test - * @bug 8132703 8132163 8132732 8132973 8154756 8132888 + * @bug 8132703 8132163 8132732 8132973 8154756 8132888 8155103 * @summary Some check for BeanProperty annotation * @author a.stepanov * @run main BeanPropertyTest @@ -853,6 +853,64 @@ public class BeanPropertyTest { public void removePropertyChangeListener(PropertyChangeListener l) {} } + // JDK-8155103 + public static enum E { + + ONE, + TWO { + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public void setX(int v) {} + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + }; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public void setX(int v) {} + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + + } + + private static enum EB { + + TRUE(true), FALSE(false); + + private boolean b; + private EB(boolean v) { b = v; } + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + public boolean isTrue() { return true; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + + } + // ---------- checks ---------- @@ -953,7 +1011,7 @@ public class BeanPropertyTest { } private static boolean ignoreVals(Class c) { - return (c.equals(Self.class) || c.equals(SelfArr.class)); + return (c.equals(Self.class) || c.equals(SelfArr.class)) || c.equals(EB.class); } @@ -1003,6 +1061,29 @@ public class BeanPropertyTest { passed = passed && ok; } + // enums + + Class enumCases[] = { + + // TODO: uncomment/update after 8155103 fix + //E.class, E.TWO.getClass(), EB.class + }; + + int ne = 1; + for (Class c: enumCases) { + + System.out.println("\nEnum-" + ne + ":"); + ne++; + + BeanInfo i; + try { i = Introspector.getBeanInfo(c, Object.class); } + catch (IntrospectionException e) { throw new RuntimeException(e); } + boolean ok = checkInfo(i, !ignoreVals(c)); + System.out.println(ok ? "OK" : "NOK"); + passed = passed && ok; + } + + if (!passed) { throw new RuntimeException("test failed"); } System.out.println("\ntest passed"); } diff --git a/jdk/test/java/beans/Introspector/InheritanceBeanPropertyTest.java b/jdk/test/java/beans/Introspector/InheritanceBeanPropertyTest.java new file mode 100644 index 00000000000..e42fa6228f3 --- /dev/null +++ b/jdk/test/java/beans/Introspector/InheritanceBeanPropertyTest.java @@ -0,0 +1,1281 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.beans.BeanInfo; +import java.beans.BeanProperty; +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyChangeListener; +import java.beans.PropertyDescriptor; + +import java.util.Arrays; + + +/** + * @test + * @bug 8132565 8155013 + * @summary Some inheritance check for BeanProperty annotation + * @author a.stepanov + * @run main InheritanceBeanPropertyTest + */ + + +public class InheritanceBeanPropertyTest { + + private final static String DESCRIPTION = "TEST"; + private final static boolean BOUND = true; + private final static boolean EXPERT = false; + private final static boolean HIDDEN = true; + private final static boolean PREFERRED = false; + private final static boolean REQUIRED = true; + private final static boolean UPDATE = false; + + private final static double X = java.lang.Math.PI; + + private final static String + V_NAME = "java.lang.Math.PI", + V_SHORT = "PI", + V = Double.toString(X); + + private final static String DESCRIPTION_2 = "XYZ"; + + + // ---------- test cases ---------- + + public static class BaseGet { + + private final static String TESTCASE = "base getter"; + + public double getX() { return X; } + } + + public static class OverloadGet extends BaseGet { + + private final static String TESTCASE = "overload getter"; + + private final double x[] = {X, X, X}; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public double getX(int i) { return x[i]; } // indexed + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static class BaseSet { + + private final static String TESTCASE = "base setter"; + + double u; + public void setX(double v) { u = v; } + } + + public static class OverloadSet extends BaseSet { + + private final static String TESTCASE = "overload setter"; + + private final double x[] = {X, X, X}; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public void setX(int i, double v) { x[i] = v; } // indexed + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static class BaseIGet { + + protected final double x[] = {X, X, X}; + public double[] getX() { return x; } + } + + public static class OverloadIGet extends BaseIGet { + + private final static String TESTCASE = "overload indexed getter"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public double getX(int i) { return x[i]; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static class BaseISet { + + protected double x[] = {X, X, X}; + public void setX(double a[]) { x = Arrays.copyOf(a, a.length); } + } + + public static class OverloadISet extends BaseISet { + + private final static String TESTCASE = "overload indexed setter"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public void setX(int i, double v) { x[i] = v; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static class BoolGet { + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public boolean getX() { return false; } + } + + public static class BoolGetIs extends BoolGet { + + private final static String TESTCASE = "base boolean getter + is"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + public boolean isX() { return false; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + // ---------- + + public static class BoolIs { + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public boolean isX() { return false; } + } + + public static class BoolIsGet extends BoolIs { + + private final static String TESTCASE = "base is + boolean getter"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + public boolean getX() { return false; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static class AnnotatedGet { + + private final static String TESTCASE = "annotated super getter"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public double getX() { return 0.; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + public static class OverrideAnnotatedGet extends AnnotatedGet { + + private final static String TESTCASE = "override annotated getter"; + + @Override + public double getX() { return X; } + } + + // ---------- + + public static class AnnotatedIs { + + private final static String TESTCASE = "annotated super is"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public boolean isX() { return false; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + public static class OverrideAnnotatedIs extends AnnotatedIs { + + private final static String TESTCASE = "override annotated is"; + + @Override + public boolean isX() { return false; } + } + + // ---------- + + public static class AnnotatedSet { + + private final static String TESTCASE = "annotated super set"; + + protected double x; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public void setX(double v) { x = -v; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + public static class OverrideAnnotatedSet extends AnnotatedSet { + + private final static String TESTCASE = "override annotated setter"; + + @Override + public void setX(double v) { x = v; } + } + + // ---------- + + public static class AnnotatedGet2 { + + protected double x; + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public double getX() { return 0.; } + } + + public static class OverrideAnnotatedGet2 extends AnnotatedGet2 { + + private final static String TESTCASE = "override annotated getter - 2"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + @Override + public double getX() { return X; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + public static class AnnotatedGet2Ext extends AnnotatedGet2 { + + private final static String TESTCASE = "extend annotated getter - 2"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public void setX(double v) { x = v; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static class AnnotatedIs2 { + + protected boolean b = false; + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public boolean isX() { return false; } + } + + public static class OverrideAnnotatedIs2 extends AnnotatedIs2 { + + private final static String TESTCASE = "override annotated is - 2"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + @Override + public boolean isX() { return b; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + public static class AnnotatedIs2Ext extends AnnotatedIs2 { + + private final static String TESTCASE = "extend annotated is - 2"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + public void setX(boolean v) { b = v; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static class AnnotatedSet2 { + + protected double x; + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public void setX(double v) { x = -v; } + } + + public static class OverrideAnnotatedSet2 extends AnnotatedSet2 { + + private final static String TESTCASE = "override annotated setter - 2"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + @Override + public void setX(double v) { x = v; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + public static class AnnotatedSet2Ext extends AnnotatedSet2 { + + private final static String TESTCASE = "extend annotated setter - 2"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public double getX() { return x; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public abstract static class AbstractGet { + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public abstract double getX(); + } + + public static class OverrideAbstractGet extends AbstractGet { + + private final static String TESTCASE = + "override abstract annotated getter"; + + @Override + public double getX() { return X; } + } + + public static class OverrideAbstractGet2 extends AbstractGet { + + private final static String TESTCASE = + "override abstract annotated getter - 2"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + @Override + public double getX() { return X; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + public abstract static class AbstractGetExt extends AbstractGet { + + private final static String TESTCASE = + "extend abstract annotated getter"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public abstract void setX(double v); + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public abstract static class AbstractIs { + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public abstract boolean isX(); + } + + public static class OverrideAbstractIs extends AbstractIs { + + private final static String TESTCASE = + "override abstract annotated is"; + + @Override + public boolean isX() { return true; } + } + + public static class OverrideAbstractIs2 extends AbstractIs { + + private final static String TESTCASE = + "override abstract annotated is - 2"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + @Override + public boolean isX() { return true; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + + public abstract static class AbstractIsExt extends AbstractIs { + + private final static String TESTCASE = + "extend abstract annotated is"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + public abstract boolean getX(); + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public abstract static class AbstractSet { + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public abstract void setX(double v); + } + + public static class OverrideAbstractSet extends AbstractSet { + + private final static String TESTCASE = + "override abstract annotated setter"; + + private double x; + + @Override + public void setX(double v) { x = v; } + } + + public static class OverrideAbstractSet2 extends AbstractSet { + + private final static String TESTCASE = + "override abstract annotated setter - 2"; + + private double x; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + @Override + public void setX(double v) { x = v; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + public abstract static class AbstractSetExt extends AbstractSet { + + private final static String TESTCASE = + "extend abstract annotated setter"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public abstract void setX(double v[]); + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static abstract class AbstractGet2 { + + private final static String TESTCASE = "abstract super getter"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public abstract double getX(); + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + public static abstract class AbstractGet2Ext extends AbstractGet2 { + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public abstract void setX(double a[]); + } + + // ---------- + + public static interface IGet { + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + double getX(); + } + + public static class IGetImpl implements IGet { + + private final static String TESTCASE = "implement getter interface"; + + @Override + public double getX() { return X; } + } + + public static class IGetImpl2 implements IGet { + + private final static String TESTCASE = "implement getter interface - 2"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + @Override + public double getX() { return X; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + public abstract static class IGetImpl3 implements IGet { + + private final static String TESTCASE = "implement getter interface - 3"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public abstract void setX(double v); + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static interface IIs { + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public boolean isX(); + } + + public static class IIsImpl implements IIs { + + private final static String TESTCASE = "implement is interface"; + + @Override + public boolean isX() { return true; } + } + + public static class IIsImpl2 implements IIs { + + private final static String TESTCASE = "implement is interface - 2"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + @Override + public boolean isX() { return true; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + public abstract static class IIsImpl3 implements IIs { + + private final static String TESTCASE = "implement is interface - 3"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE) + public abstract void setX(boolean v); + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static interface ISet { + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public void setX(double v); + } + + public static class ISetImpl implements ISet { + + private final static String TESTCASE = "implement getter interface"; + + private double x; + + @Override + public void setX(double v) { x = v; } + } + + public static class ISetImpl2 implements ISet { + + private final static String TESTCASE = "implement getter interface - 2"; + + private double x; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + @Override + public void setX(double v) { x = v; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + public abstract static class ISetImpl3 implements ISet { + + private final static String TESTCASE = "implement getter interface - 3"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public abstract double getX(); + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static interface ISet2 { + + final static String TESTCASE = "super interface - setter"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public void setX(double v); + + public void addPropertyChangeListener(PropertyChangeListener l); + public void removePropertyChangeListener(PropertyChangeListener l); + } + + public static class ISet2Impl implements ISet2 { + + private double x; + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + @Override + public void setX(double v) { x = v; } + + @Override + public void addPropertyChangeListener(PropertyChangeListener l) {} + @Override + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static interface IGet2 { + + final static String TESTCASE = "super interface - indexed getter"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + public double[] getX(); + + public void addPropertyChangeListener(PropertyChangeListener l); + public void removePropertyChangeListener(PropertyChangeListener l); + } + + public static class IGet2Impl implements IGet2 { + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + @Override + public double[] getX() { return new double[]{X, X}; } + + @Override + public void addPropertyChangeListener(PropertyChangeListener l) {} + @Override + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + public static class ProtectedGet { + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + protected double getX() { return 0.; } + } + + public static class OverrideProtectedGet extends ProtectedGet { + + final static String TESTCASE = "override protected getter"; + + @BeanProperty( + description = DESCRIPTION, + bound = BOUND, + expert = EXPERT, + hidden = HIDDEN, + preferred = PREFERRED, + required = REQUIRED, + visualUpdate = UPDATE, + enumerationValues = {V_NAME}) + @Override + public double getX() { return X; } + + public void addPropertyChangeListener(PropertyChangeListener l) {} + public void removePropertyChangeListener(PropertyChangeListener l) {} + } + + // ---------- + + // static getter - see also JDK-8154938 + public static class StaticGet { + + @BeanProperty( + description = DESCRIPTION_2, + bound = !BOUND, + expert = !EXPERT, + hidden = !HIDDEN, + preferred = !PREFERRED, + required = !REQUIRED, + visualUpdate = !UPDATE) + public static double getProp() { return 0.; } + } + + public static class HideStaticGet extends StaticGet { + + final static String TESTCASE = "hide static getter"; + + public double getX() { return X; } // add to get the "default" info + public static double getProp() { return X; } + } + + // TODO: if 8154938 is considered to be a real issue, + // create one more test case "HideStaticGet2 extends StaticGet" with an + // annotated getter and check the correctness of the corresponding bean info + + // ---------- checks ---------- + + private static boolean check(String what, boolean v, boolean ref) { + + boolean ok = (v == ref); + if (!ok) { System.out.println( + "invalid " + what + ": " + v + ", expected: " + ref); } + return ok; + } + + private static boolean checkInfo(BeanInfo i, boolean ignoreValsCheck) { + + System.out.println("checking info..."); + + PropertyDescriptor descriptors[] = i.getPropertyDescriptors(); + int nd = descriptors.length; + if (nd != 1) { + System.out.println("invalid number of descriptors: " + nd); + return false; + } + + PropertyDescriptor d = descriptors[0]; + + String descr = d.getShortDescription(); + boolean ok = descr.equals(DESCRIPTION); + if (!ok) { System.out.println("invalid description: " + descr + + ", expected: " + DESCRIPTION); } + + ok &= check("isBound", d.isBound(), BOUND); + ok &= check("isExpert", d.isExpert(), EXPERT); + ok &= check("isHidden", d.isHidden(), HIDDEN); + ok &= check("isPreferred", d.isPreferred(), PREFERRED); + ok &= check("required", (boolean) d.getValue("required"), REQUIRED); + ok &= check("visualUpdate", + (boolean) d.getValue("visualUpdate"), UPDATE); + + if (ignoreValsCheck) { return ok; } + + Object vals[] = (Object[]) d.getValue("enumerationValues"); + if (vals == null) { + System.out.println("null enumerationValues"); + return false; + } + + boolean okVals = ( + (vals.length == 3) && + vals[0].toString().equals(V_SHORT) && + vals[1].toString().equals(V) && + vals[2].toString().equals(V_NAME)); + + if (!okVals) { System.out.println("invalid enumerationValues"); } + + return (ok && okVals); + } + + private static boolean checkDefault(BeanInfo i) { + + System.out.println("checking default info..."); + + PropertyDescriptor descriptors[] = i.getPropertyDescriptors(); + int nd = descriptors.length; + if (nd != 1) { + System.out.println("invalid number of descriptors: " + nd); + return false; + } + + PropertyDescriptor d = descriptors[0]; + + String descr = d.getShortDescription(); + boolean ok = descr.equals("x"); + if (!ok) { System.out.println("invalid description: " + descr + + ", expected: x"); } + + ok &= check("isBound", d.isBound(), false); + ok &= check("isExpert", d.isExpert(), false); + ok &= check("isHidden", d.isHidden(), false); + ok &= check("isPreferred", d.isPreferred(), false); + ok &= check("required", (boolean) d.getValue("required"), false); + ok &= check("visualUpdate", + (boolean) d.getValue("visualUpdate"), false); + + Object vals[] = (Object[]) d.getValue("enumerationValues"); + if (vals != null && vals.length > 0) { + System.out.println("non-empty enumerationValues"); + ok = false; + } + + return ok; + } + + // do not check enumerationValues for these classes + private static boolean ignoreVals(Class c) { + return ( + c.equals(BoolGetIs.class) || + c.equals(BoolIsGet.class) || + c.equals(AnnotatedIs.class) || + c.equals(OverrideAnnotatedIs2.class) || + c.equals(AnnotatedIs2Ext.class) || + c.equals(OverrideAbstractIs.class) || + c.equals(OverrideAbstractIs2.class) || + c.equals(AbstractIsExt.class) || + c.equals(OverrideAbstractIs.class) || + c.equals(IIsImpl.class) || + c.equals(IIsImpl2.class) || + c.equals(IIsImpl3.class) + ); + } + + // default property descriptor data are expected for these classes + private static boolean isDefault(Class c) { + return ( + c.equals(OverrideAnnotatedGet.class) || + c.equals(OverrideAnnotatedIs.class ) || + c.equals(OverrideAnnotatedSet.class) || + c.equals(OverrideAbstractGet.class) || + c.equals(OverrideAbstractIs.class) || + c.equals(OverrideAbstractSet.class) || + c.equals(IGetImpl.class) || + c.equals(IIsImpl.class) || + c.equals(ISetImpl.class) || + c.equals(BaseGet.class) || + c.equals(BaseSet.class) || + c.equals(HideStaticGet.class) + ); + } + + + // ---------- run test ---------- + + public static void main(String[] args) throws Exception { + + Class + ic1 = ISet2Impl.class.getInterfaces()[0], + ic2 = IGet2Impl.class.getInterfaces()[0]; + + Class cases[] = { + + OverloadGet.class, + OverloadGet.class.getSuperclass(), + OverloadSet.class, + OverloadSet.class.getSuperclass(), + OverloadIGet.class, + OverloadISet.class, + + // TODO: uncomment/update after 8132565 fix + //BoolGetIs.class, + //BoolIsGet.class, + //OverrideAnnotatedGet.class, + //OverrideAnnotatedIs.class, + //OverrideAnnotatedSet.class, + //OverrideAnnotatedGet2.class, + //AnnotatedGet2Ext.class, + //OverrideAnnotatedIs2.class + //AnnotatedIs2Ext.class, + //OverrideAnnotatedSet2.class, + //AnnotatedSet2Ext.class, + + OverrideAnnotatedGet.class.getSuperclass(), + OverrideAnnotatedIs.class.getSuperclass(), + OverrideAnnotatedSet.class.getSuperclass(), + + // TODO: uncomment/update after 8132565 fix + //OverrideAbstractGet.class, + //OverrideAbstractGet2.class, + //AbstractGetExt.class, + //OverrideAbstractIs.class, + //OverrideAbstractIs2.class, + //AbstractIsExt.class + //OverrideAbstractSet.class, + //OverrideAbstractSet2.class, + //AbstractSetExt.class, + + AbstractGet2Ext.class.getSuperclass(), + IGetImpl.class, + IGetImpl2.class, + IGetImpl3.class, + IIsImpl.class, + IIsImpl2.class, + IIsImpl3.class, + ISetImpl.class, + ISetImpl2.class, + ISetImpl3.class, + ic1, + // ic2, // TODO: uncomment/update after 8155013 fix + OverrideProtectedGet.class, + HideStaticGet.class + }; + + boolean passed = true; + + for (Class c: cases) { + + java.lang.reflect.Field f = c.getDeclaredField("TESTCASE"); + f.setAccessible(true); + String descr = f.get(c).toString(); + + System.out.println("\n" + c.getSimpleName() + " (" + descr + "):"); + BeanInfo i; + try { + i = Introspector.getBeanInfo(c, + (c.equals(ic1) || c.equals(ic2)) ? null : Object.class); + } + catch (IntrospectionException e) { throw new RuntimeException(e); } + + boolean ok; + + if (isDefault(c)) { + ok = checkDefault(i); + } else { + ok = checkInfo(i, ignoreVals(c)); + } + System.out.println(ok ? "OK" : "NOK"); + passed = passed && ok; + } + + if (!passed) { throw new RuntimeException("test failed"); } + System.out.println("\ntest passed"); + } +} -- GitLab From 8499a7a0b3f0c80504025ce37b58d1026b7a9b4d Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Thu, 28 Apr 2016 23:48:37 +0400 Subject: [PATCH 018/400] 8152677: [macosx] All files filter can't be selected in JFileChooser Reviewed-by: serb --- .../com/apple/laf/AquaFileChooserUI.java | 13 ++- .../8152677/SelectAllFilesFilterTest.java | 108 ++++++++++++++++++ 2 files changed, 118 insertions(+), 3 deletions(-) create mode 100644 jdk/test/javax/swing/JFileChooser/8152677/SelectAllFilesFilterTest.java diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java index 91e1e4e8c39..eaade120e04 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaFileChooserUI.java @@ -112,7 +112,7 @@ public class AquaFileChooserUI extends FileChooserUI { private AncestorListener ancestorListener = null; private DropTarget dragAndDropTarget = null; - private final AcceptAllFileFilter acceptAllFileFilter = new AcceptAllFileFilter(); + private static final AcceptAllFileFilter acceptAllFileFilter = new AcceptAllFileFilter(); private AquaFileSystemModel model; @@ -997,7 +997,7 @@ public class AquaFileChooserUI extends FileChooserUI { // ***************************************** // ***** default AcceptAll file filter ***** // ***************************************** - protected class AcceptAllFileFilter extends FileFilter { + private static class AcceptAllFileFilter extends FileFilter { public AcceptAllFileFilter() { } @@ -1305,6 +1305,8 @@ public class AquaFileChooserUI extends FileChooserUI { protected class FilterComboBoxModel extends AbstractListModel implements ComboBoxModel, PropertyChangeListener { protected FileFilter[] filters; + Object oldFileFilter = getFileChooser().getFileFilter(); + protected FilterComboBoxModel() { super(); filters = getFileChooser().getChoosableFileFilters(); @@ -1321,12 +1323,17 @@ public class AquaFileChooserUI extends FileChooserUI { } public void setSelectedItem(Object filter) { - if (filter != null && !containsFileFilter(filter)) { + if (filter != null && !isSelectedFileFilterInModel(filter)) { + oldFileFilter = filter; getFileChooser().setFileFilter((FileFilter) filter); fireContentsChanged(this, -1, -1); } } + private boolean isSelectedFileFilterInModel(Object filter) { + return Objects.equals(filter, oldFileFilter); + } + public Object getSelectedItem() { // Ensure that the current filter is in the list. // NOTE: we shouldnt' have to do this, since JFileChooser adds diff --git a/jdk/test/javax/swing/JFileChooser/8152677/SelectAllFilesFilterTest.java b/jdk/test/javax/swing/JFileChooser/8152677/SelectAllFilesFilterTest.java new file mode 100644 index 00000000000..bc17b04a306 --- /dev/null +++ b/jdk/test/javax/swing/JFileChooser/8152677/SelectAllFilesFilterTest.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Component; +import java.awt.Container; +import java.awt.Robot; +import javax.swing.JComboBox; +import javax.swing.JFileChooser; +import javax.swing.JLabel; +import javax.swing.SwingUtilities; +import javax.swing.filechooser.FileFilter; +import javax.swing.filechooser.FileNameExtensionFilter; + +/* + * @test + * @bug 8152677 + * @requires (os.family == "mac") + * @summary [macosx] All files filter can't be selected in JFileChooser + * @run main SelectAllFilesFilterTest + */ + +public class SelectAllFilesFilterTest { + + private static final String LABEL_TEXT = "File Format:"; + private static volatile JFileChooser fileChooser; + private static JComboBox comboBox; + + public static void main(String[] args) throws Exception { + + SwingUtilities.invokeLater(SelectAllFilesFilterTest::createAndShowGUI); + + while (fileChooser == null) { + Thread.sleep(100); + } + + Robot robot = new Robot(); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> { + comboBox = findComboBox(fileChooser); + comboBox.setSelectedIndex(0); + }); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> { + int selectedIndex = comboBox.getSelectedIndex(); + fileChooser.setVisible(false); + + if (selectedIndex != 0) { + throw new RuntimeException("Select All file filter is not selected!"); + } + }); + } + + private static void createAndShowGUI() { + fileChooser = new JFileChooser(); + fileChooser.setAcceptAllFileFilterUsed(true); + fileChooser.setDialogType(JFileChooser.OPEN_DIALOG); + + FileFilter txtFilter = new FileNameExtensionFilter("Text files", "txt"); + fileChooser.addChoosableFileFilter(txtFilter); + fileChooser.setFileFilter(txtFilter); + fileChooser.showOpenDialog(null); + } + + private static JComboBox findComboBox(Component comp) { + + if (comp instanceof JLabel) { + JLabel label = (JLabel) comp; + if (LABEL_TEXT.equals(label.getText())) { + return (JComboBox) label.getLabelFor(); + } + } + + if (comp instanceof Container) { + Container cont = (Container) comp; + for (int i = 0; i < cont.getComponentCount(); i++) { + + JComboBox result = findComboBox(cont.getComponent(i)); + if (result != null) { + return result; + } + } + } + + return null; + } +} -- GitLab From c7f8bb25dda6a009f279ea160a6d255fb4140fcb Mon Sep 17 00:00:00 2001 From: Nils Eliasson Date: Fri, 29 Apr 2016 09:40:08 +0200 Subject: [PATCH 019/400] 8142464: PlatformLoggerTest.java throws java.lang.RuntimeException: Logger test.logger.bar does not exist Test doesn't keep strong references to loggers Reviewed-by: kvn --- jdk/test/sun/util/logging/PlatformLoggerTest.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/jdk/test/sun/util/logging/PlatformLoggerTest.java b/jdk/test/sun/util/logging/PlatformLoggerTest.java index 0bf94d64a5a..913390161e4 100644 --- a/jdk/test/sun/util/logging/PlatformLoggerTest.java +++ b/jdk/test/sun/util/logging/PlatformLoggerTest.java @@ -31,7 +31,6 @@ * * @modules java.base/sun.util.logging * java.logging/sun.util.logging.internal - * @compile -XDignore.symbol.file PlatformLoggerTest.java * @run main/othervm PlatformLoggerTest */ @@ -42,25 +41,31 @@ import sun.util.logging.PlatformLogger; import static sun.util.logging.PlatformLogger.Level.*; public class PlatformLoggerTest { + + static Logger logger; + static PlatformLogger bar; + static PlatformLogger goo; + static PlatformLogger foo; + public static void main(String[] args) throws Exception { final String FOO_PLATFORM_LOGGER = "test.platformlogger.foo"; final String BAR_PLATFORM_LOGGER = "test.platformlogger.bar"; final String GOO_PLATFORM_LOGGER = "test.platformlogger.goo"; final String BAR_LOGGER = "test.logger.bar"; - PlatformLogger goo = PlatformLogger.getLogger(GOO_PLATFORM_LOGGER); + goo = PlatformLogger.getLogger(GOO_PLATFORM_LOGGER); // test the PlatformLogger methods testLogMethods(goo); // Create a platform logger using the default - PlatformLogger foo = PlatformLogger.getLogger(FOO_PLATFORM_LOGGER); + foo = PlatformLogger.getLogger(FOO_PLATFORM_LOGGER); checkPlatformLogger(foo, FOO_PLATFORM_LOGGER); // create a java.util.logging.Logger // now java.util.logging.Logger should be created for each platform logger - Logger logger = Logger.getLogger(BAR_LOGGER); + logger = Logger.getLogger(BAR_LOGGER); logger.setLevel(Level.WARNING); - PlatformLogger bar = PlatformLogger.getLogger(BAR_PLATFORM_LOGGER); + bar = PlatformLogger.getLogger(BAR_PLATFORM_LOGGER); checkPlatformLogger(bar, BAR_PLATFORM_LOGGER); // test the PlatformLogger methods -- GitLab From a94f4aafd20dafa1ac27e3e0e7a5a1f18e2c750b Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Fri, 29 Apr 2016 15:44:04 +0300 Subject: [PATCH 020/400] 8143346: Broken link in java.beans.XMLEncoder Reviewed-by: prr --- jdk/src/demo/share/jvmti/index.html | 2 +- .../libawt_lwawt/awt/JavaComponentAccessibility.m | 4 ++-- .../share/classes/java/awt/Toolkit.java | 2 +- .../share/classes/java/beans/XMLDecoder.java | 7 ++++--- .../share/classes/java/beans/XMLEncoder.java | 7 ++++--- .../share/classes/javax/swing/JRootPane.java | 2 +- .../classes/javax/swing/colorchooser/package.html | 8 ++++---- .../share/classes/javax/swing/event/package.html | 8 ++++---- .../classes/javax/swing/filechooser/package.html | 8 ++++---- .../share/classes/javax/swing/package.html | 14 +++++++------- .../classes/javax/swing/plaf/basic/package.html | 6 +++--- .../classes/javax/swing/plaf/metal/package.html | 6 +++--- .../swing/plaf/multi/doc-files/multi_tsc.html | 6 +++--- .../classes/javax/swing/plaf/multi/package.html | 6 +++--- .../classes/javax/swing/plaf/nimbus/package.html | 4 ++-- .../share/classes/javax/swing/plaf/package.html | 6 +++--- .../plaf/synth/doc-files/synthFileFormat.html | 2 +- .../share/classes/javax/swing/table/package.html | 8 ++++---- .../share/classes/javax/swing/text/Document.java | 2 +- .../classes/javax/swing/text/html/package.html | 6 +++--- .../javax/swing/text/html/parser/package.html | 6 +++--- .../share/classes/javax/swing/text/package.html | 8 ++++---- .../classes/javax/swing/text/rtf/package.html | 6 +++--- .../share/classes/javax/swing/tree/package.html | 8 ++++---- .../share/classes/javax/swing/undo/package.html | 8 ++++---- 25 files changed, 76 insertions(+), 74 deletions(-) diff --git a/jdk/src/demo/share/jvmti/index.html b/jdk/src/demo/share/jvmti/index.html index 25440a104d9..5791b8b046f 100644 --- a/jdk/src/demo/share/jvmti/index.html +++ b/jdk/src/demo/share/jvmti/index.html @@ -415,7 +415,7 @@ Additional information can also be found by doing a search on "jvmti" at Various technical articles are also available through this website. And don't forget the Java Tutorials at -http://java.sun.com/docs/books/tutorial +http://docs.oracle.com/javase/tutorial for getting a quick start on all the various interfaces.

Comments and Feedback

diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m index 1b3ec43a9fe..e7b229f00e1 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m @@ -25,7 +25,7 @@ // External Java Accessibility links: // -// +// // // (Sun's mailing list for Java accessibility) @@ -973,7 +973,7 @@ static NSObject *sAttributeNamesLOCK = nil; // Element's value (id) // note that the appKit meaning of "accessibilityValue" is different from the java // meaning of "accessibleValue", which is specific to numerical values -// (http://java.sun.com/j2se/1.3/docs/api/javax/accessibility/AccessibleValue.html#setCurrentAccessibleValue(java.lang.Number)) +// (https://docs.oracle.com/javase/8/docs/api/javax/accessibility/AccessibleValue.html#setCurrentAccessibleValue-java.lang.Number-) - (id)accessibilityValueAttribute { static JNF_STATIC_MEMBER_CACHE(jm_getCurrentAccessibleValue, sjc_CAccessibility, "getCurrentAccessibleValue", "(Ljavax/accessibility/AccessibleValue;Ljava/awt/Component;)Ljava/lang/Number;"); diff --git a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java index 9e7646fd320..bed5149c08a 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java @@ -89,7 +89,7 @@ import javax.accessibility.AccessibilityProvider; *
For more information, see * Timing * Focus Transfers, a section in - * The Swing + * The Swing * Tutorial. * *
  • Making a top-level container visible. diff --git a/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java b/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java index d86ecfaf6bd..daae045316b 100644 --- a/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java +++ b/jdk/src/java.desktop/share/classes/java/beans/XMLDecoder.java @@ -53,8 +53,8 @@ import org.xml.sax.helpers.DefaultHandler; * *

    * For more information you might also want to check out - * Long Term Persistence of JavaBeans Components: XML Schema, + * + * Long Term Persistence of JavaBeans Components: XML Schema, * an article in The Swing Connection. * @see XMLEncoder * @see java.io.ObjectInputStream @@ -284,7 +284,8 @@ public class XMLDecoder implements AutoCloseable { * The {@code null} value may cause illegal parsing in such case. * The same problem may occur, if the {@code owner} class * does not contain expected method to call. See details here. + * href="http://www.oracle.com/technetwork/java/persistence3-139471.html"> + * here. * * @param owner the owner of the default handler * that can be used as a value of <java> element diff --git a/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java b/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java index ac4ab411ce4..7deaea30622 100644 --- a/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java +++ b/jdk/src/java.desktop/share/classes/java/beans/XMLEncoder.java @@ -193,8 +193,8 @@ import java.nio.charset.UnsupportedCharsetException; * *

    * For more information you might also want to check out - * Using XMLEncoder, + * + * Using XMLEncoder, * an article in The Swing Connection. * @see XMLDecoder * @see java.io.ObjectOutputStream @@ -438,7 +438,8 @@ public class XMLEncoder extends Encoder implements AutoCloseable { *

    * For more information about using resource bundles with the * XMLEncoder, see - * http://java.sun.com/products/jfc/tsc/articles/persistence4/#i18n + * + * Creating Internationalized Applications, * * @param oldExp The expression that will be written * to the stream. diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java b/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java index 4061f2e2471..80dfb2954b4 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JRootPane.java @@ -194,7 +194,7 @@ import sun.security.action.GetBooleanAction; * @see JComponent * @see BoxLayout * - * @see + * @see * Mixing Heavy and Light Components * * @author David Kloba diff --git a/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html b/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html index cb8030258c3..43ff5ee8739 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/colorchooser/package.html @@ -37,10 +37,10 @@ component. Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial. @@ -49,7 +49,7 @@ target="_top">The Java Tutorial. This document forms the complete API specification. For overviews, tutorials, examples, guides, and tool documentation, please see:

      -
    • How to Use Color Choosers, +
    • How to Use Color Choosers, a section in The Java Tutorial
    • not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial.

      Related Documentation

      For overviews, tutorials, examples, guides, and tool documentation, please see: diff --git a/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html b/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html index d850fc5b19e..fa06236262c 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/filechooser/package.html @@ -37,10 +37,10 @@ Contains classes and interfaces used by the JFileChooser component. Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial. @@ -49,7 +49,7 @@ target="_top">The Java Tutorial. This document forms the complete API specification. For overviews, tutorials, examples, guides, and tool documentation, please see:
        -
      • How to Use File Choosers, +
      • How to Use File Choosers, a section in The Java Tutorial
      • Internationalization Documentation diff --git a/jdk/src/java.desktop/share/classes/javax/swing/package.html b/jdk/src/java.desktop/share/classes/javax/swing/package.html index 8050000ae91..934bb9025da 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/package.html @@ -38,7 +38,7 @@ questions. (all-Java language) components that, to the maximum degree possible, work the same on all platforms. For a programmer's guide to using these components, see -Creating a GUI with JFC/Swing, a trail in The Java Tutorial. For other resources, see @@ -123,9 +123,9 @@ input. Refer to {@link javax.swing.SwingWorker} for the preferred way to do such processing when working with Swing.

        More information on this topic can be found in the -Swing tutorial, +Swing tutorial, in particular the section on -Concurrency in Swing. +Concurrency in Swing.

        @@ -134,13 +134,13 @@ in particular the section on

        For overviews, tutorials, examples, guides, and other documentation, please see:

        diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html index d02593c7455..347fc7cf9c8 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/package.html @@ -55,10 +55,10 @@ encouraged. Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial. @since 1.2 diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html index 1c41e7f9577..db16ddda090 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/metal/package.html @@ -51,10 +51,10 @@ encouraged. Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial. @since 1.2 diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html index 512b1a581ea..343db5479e2 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/doc-files/multi_tsc.html @@ -18,7 +18,7 @@ Using the Multiplexing Look and Feel This document is based on an article originally published in -The Swing +The Swing Connection.

        @@ -65,12 +65,12 @@ This document has the following sections: Before reading further, you should be familiar with the concept of pluggable look and feels. For basic information, see -How to Set the Look and Feel, +How to Set the Look and Feel, a section in The Java Tutorial. For architectural details, you can read Pluggable look-and-feel architecture, a section within +href="http://www.oracle.com/technetwork/java/architecture-142923.html#pluggable">Pluggable look-and-feel architecture, a section within a Swing Connection article.

        diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html index 65d1aeafcfc..32b0d6b21af 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/multi/package.html @@ -53,10 +53,10 @@ the Multiplexing Look and Feel. Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial. @since 1.2 diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html index 14cac304214..f91d73781fd 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/nimbus/package.html @@ -88,10 +88,10 @@ encouraged.

        Note: Most of the Swing API is not thread safe. For details, see -Concurrency in Swing, a section in -The Java Tutorial. @since 1.7 diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html index c207c89b103..0fc8c538143 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/package.html @@ -44,10 +44,10 @@ by the javax.swing.plaf.basic and Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial. @since 1.2 diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html index 202283049b5..0936b2951d3 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/doc-files/synthFileFormat.html @@ -950,7 +950,7 @@ div.example { Beans persistance can be used to embed any Object. This is typically used for embedding your own Painters, but can be used for other arbritrary objects as well. Refer to http://java.sun.com/products/jfc/tsc/articles/persistence3/ for details on beans persistance. + href="http://www.oracle.com/technetwork/java/persistence3-139471.html">http://www.oracle.com/technetwork/java/persistence3-139471.html for details on beans persistance.

        Backing Style

        diff --git a/jdk/src/java.desktop/share/classes/javax/swing/table/package.html b/jdk/src/java.desktop/share/classes/javax/swing/table/package.html index f3fd20c8bb1..cf944823e91 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/table/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/table/package.html @@ -43,10 +43,10 @@ with the tables are viewed and managed. Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial. @@ -54,7 +54,7 @@ target="_top">The Java Tutorial
        . For overviews, tutorials, examples, guides, and tool documentation, please see: diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java b/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java index 12c9a09bc5c..4cab9c4fe2d 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/Document.java @@ -166,7 +166,7 @@ import javax.swing.event.*; *

      * *

      For more information on the Document class, see - * The Swing Connection + * The Swing Connection * and most particularly the article, * * The Element Interface. diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html b/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html index e0ab0354d53..c9c41b8cc22 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/package.html @@ -37,10 +37,10 @@ for creating HTML text editors. Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial.

      Package Specification

      diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html b/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html index d503bc741e7..05c53989142 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/parser/package.html @@ -40,10 +40,10 @@ the HTMLEditorKit.ParserCallback interface. Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial. @see javax.swing.text.html.HTMLEditorKit.ParserCallback diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/package.html b/jdk/src/java.desktop/share/classes/javax/swing/text/package.html index 4aa7804f544..1c38c251066 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/package.html @@ -41,17 +41,17 @@ and key mapping. Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial.

      Related Documentation

      For overviews, tutorials, examples, guides, and tool documentation, please see: diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html b/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html index aa83e9fa502..9b62f229a93 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/rtf/package.html @@ -38,10 +38,10 @@ text editors. Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial. @since 1.2 diff --git a/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html b/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html index b6b58bbdabe..e820b3cb364 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/tree/package.html @@ -39,10 +39,10 @@ as how data associated with the tree nodes are viewed and managed. Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial. @@ -50,7 +50,7 @@ target="_top">The Java Tutorial. For overviews, tutorials, examples, guides, and tool documentation, please see: diff --git a/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html b/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html index f4ae62d7b16..bf6d809fafb 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html +++ b/jdk/src/java.desktop/share/classes/javax/swing/undo/package.html @@ -37,17 +37,17 @@ in applications such as text editors. Most of the Swing API is not thread safe. For details, see Threads and Swing, +href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/index.html" +target="_top">Concurrency in Swing, a section in -The Java Tutorial.

      Related Documentation

      For overviews, tutorials, examples, guides, and tool documentation, please see: -- GitLab From 4b793fa7ffa88cbba91575494aa0a573504e2f4a Mon Sep 17 00:00:00 2001 From: Phil Race Date: Fri, 29 Apr 2016 09:16:06 -0700 Subject: [PATCH 021/400] 8039444: Swing applications not being displayed properly Reviewed-by: serb, vadim --- .../native/libawt/java2d/d3d/D3DBadHardware.h | 129 +----------------- 1 file changed, 3 insertions(+), 126 deletions(-) diff --git a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h index 91ee7b358a4..115626c857c 100644 --- a/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h +++ b/jdk/src/java.desktop/windows/native/libawt/java2d/d3d/D3DBadHardware.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,131 +51,8 @@ typedef struct ADAPTER_INFO { static const ADAPTER_INFO badHardware[] = { - // Intel HD - // Clarkdale (Desktop) GMA HD Lines - { 0x8086, 0x0042, NO_VERSION, OS_ALL }, - // Arrandale (Mobile) GMA HD Lines - { 0x8086, 0x0046, NO_VERSION, OS_ALL }, - - // Sandy Bridge HD Graphics 3000/2000 - { 0x8086, 0x0102, NO_VERSION, OS_ALL }, - { 0x8086, 0x0106, NO_VERSION, OS_ALL }, - { 0x8086, 0x0112, NO_VERSION, OS_ALL }, - { 0x8086, 0x0116, NO_VERSION, OS_ALL }, - { 0x8086, 0x0122, NO_VERSION, OS_ALL }, - { 0x8086, 0x0126, NO_VERSION, OS_ALL }, - { 0x8086, 0x010A, NO_VERSION, OS_ALL }, - - // Ivy Bridge - { 0x8086, 0x0162, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0162, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0166, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0166, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x016A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x016A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0152, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0152, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0156, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0156, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x015A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x015A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - - // Haswell - { 0x8086, 0x0402, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0402, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0406, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0406, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0412, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0412, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0416, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0416, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x041E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x041E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x040A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x040A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x041A, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x041A, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0A06, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0A06, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0A16, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0A16, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0A26, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0A26, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0A2E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0A2E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0A1E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0A1E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0A0E, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0A0E, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0D26, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0D26, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - { 0x8086, 0x0D22, D_VERSION(6,14,10,5437), OS_WINXP | OS_WINXP_64 }, - { 0x8086, 0x0D22, D_VERSION(9,18,10,3257), OS_VISTA | OS_WINDOWS7 }, - - // Reason: workaround for 6620073, 6612195 - // Intel 740 - { 0x8086, 0x7800, NO_VERSION, OS_ALL }, - { 0x8086, 0x1240, NO_VERSION, OS_ALL }, - { 0x8086, 0x7121, NO_VERSION, OS_ALL }, - { 0x8086, 0x7123, NO_VERSION, OS_ALL }, - { 0x8086, 0x7125, NO_VERSION, OS_ALL }, - { 0x8086, 0x1132, NO_VERSION, OS_ALL }, - // IEG - { 0x8086, 0x2562, NO_VERSION, OS_ALL }, - { 0x8086, 0x3577, NO_VERSION, OS_ALL }, - { 0x8086, 0x2572, NO_VERSION, OS_ALL }, - { 0x8086, 0x3582, NO_VERSION, OS_ALL }, - { 0x8086, 0x358E, NO_VERSION, OS_ALL }, - // GMA - { 0x8086, 0x2582, NO_VERSION, OS_ALL }, - { 0x8086, 0x2782, NO_VERSION, OS_ALL }, - { 0x8086, 0x2592, NO_VERSION, OS_ALL }, - { 0x8086, 0x2792, NO_VERSION, OS_ALL }, - { 0x8086, 0x2772, NO_VERSION, OS_ALL }, - { 0x8086, 0x2776, NO_VERSION, OS_ALL }, - { 0x8086, 0x27A2, NO_VERSION, OS_ALL }, - { 0x8086, 0x27A6, NO_VERSION, OS_ALL }, - { 0x8086, 0x27AE, NO_VERSION, OS_ALL }, - { 0x8086, 0x29D2, NO_VERSION, OS_ALL }, - { 0x8086, 0x29D3, NO_VERSION, OS_ALL }, - { 0x8086, 0x29B2, NO_VERSION, OS_ALL }, - { 0x8086, 0x29B3, NO_VERSION, OS_ALL }, - { 0x8086, 0x29C2, NO_VERSION, OS_ALL }, - { 0x8086, 0x29C3, NO_VERSION, OS_ALL }, - { 0x8086, 0xA001, NO_VERSION, OS_ALL }, - { 0x8086, 0xA002, NO_VERSION, OS_ALL }, - { 0x8086, 0xA011, NO_VERSION, OS_ALL }, - { 0x8086, 0xA012, NO_VERSION, OS_ALL }, - // GMA - { 0x8086, 0x2972, NO_VERSION, OS_ALL }, - { 0x8086, 0x2973, NO_VERSION, OS_ALL }, - { 0x8086, 0x2992, NO_VERSION, OS_ALL }, - { 0x8086, 0x2993, NO_VERSION, OS_ALL }, - { 0x8086, 0x29A2, NO_VERSION, OS_ALL }, - { 0x8086, 0x29A3, NO_VERSION, OS_ALL }, - { 0x8086, 0x2982, NO_VERSION, OS_ALL }, - { 0x8086, 0x2983, NO_VERSION, OS_ALL }, - { 0x8086, 0x2A02, NO_VERSION, OS_ALL }, - { 0x8086, 0x2A03, NO_VERSION, OS_ALL }, - { 0x8086, 0x2A12, NO_VERSION, OS_ALL }, - { 0x8086, 0x2A13, NO_VERSION, OS_ALL }, - - // Eaglelake (Desktop) GMA 4500 Lines - { 0x8086, 0x2E42, NO_VERSION, OS_ALL }, - { 0x8086, 0x2E43, NO_VERSION, OS_ALL }, - { 0x8086, 0x2E92, NO_VERSION, OS_ALL }, - { 0x8086, 0x2E93, NO_VERSION, OS_ALL }, - { 0x8086, 0x2E12, NO_VERSION, OS_ALL }, - { 0x8086, 0x2E13, NO_VERSION, OS_ALL }, - // Eaglelake (Desktop) GMA X4500 Lines - { 0x8086, 0x2E32, NO_VERSION, OS_ALL }, - { 0x8086, 0x2E33, NO_VERSION, OS_ALL }, - { 0x8086, 0x2E22, NO_VERSION, OS_ALL }, - // Eaglelake (Desktop) GMA X4500HD Lines - { 0x8086, 0x2E23, NO_VERSION, OS_ALL }, - // Cantiga (Mobile) GMA 4500MHD Lines - { 0x8086, 0x2A42, NO_VERSION, OS_ALL }, - { 0x8086, 0x2A43, NO_VERSION, OS_ALL }, + // All Intel Chips. + { 0x8086, ALL_DEVICEIDS, NO_VERSION, OS_ALL }, // ATI Mobility Radeon X1600, X1400, X1450, X1300, X1350 // Reason: workaround for 6613066, 6687166 -- GitLab From bf6b990945a035ad0f5bc76987be75f2bbc6819b Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Fri, 29 Apr 2016 21:59:47 +0400 Subject: [PATCH 022/400] 8017112: JTabbedPane components have inconsistent accessibility tree Reviewed-by: ptbrunet, serb --- .../share/classes/java/awt/Component.java | 27 +++++--- .../8017112/AccessibleIndexInParentTest.java | 68 +++++++++++++++++++ 2 files changed, 84 insertions(+), 11 deletions(-) create mode 100644 jdk/test/javax/accessibility/8017112/AccessibleIndexInParentTest.java diff --git a/jdk/src/java.desktop/share/classes/java/awt/Component.java b/jdk/src/java.desktop/share/classes/java/awt/Component.java index b2b51e08559..c2a021fd595 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Component.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java @@ -9739,19 +9739,24 @@ public abstract class Component implements ImageObserver, MenuContainer, */ int getAccessibleIndexInParent() { synchronized (getTreeLock()) { - int index = -1; - Container parent = this.getParent(); - if (parent != null && parent instanceof Accessible) { - Component ca[] = parent.getComponents(); - for (int i = 0; i < ca.length; i++) { - if (ca[i] instanceof Accessible) { - index++; - } - if (this.equals(ca[i])) { - return index; - } + + AccessibleContext accContext = getAccessibleContext(); + if (accContext == null) { + return -1; + } + + Accessible parent = accContext.getAccessibleParent(); + if (parent == null) { + return -1; + } + + accContext = parent.getAccessibleContext(); + for (int i = 0; i < accContext.getAccessibleChildrenCount(); i++) { + if (this.equals(accContext.getAccessibleChild(i))) { + return i; } } + return -1; } } diff --git a/jdk/test/javax/accessibility/8017112/AccessibleIndexInParentTest.java b/jdk/test/javax/accessibility/8017112/AccessibleIndexInParentTest.java new file mode 100644 index 00000000000..87f35b40da9 --- /dev/null +++ b/jdk/test/javax/accessibility/8017112/AccessibleIndexInParentTest.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.awt.Component; +import javax.swing.JLabel; +import javax.swing.JTabbedPane; +import javax.swing.SwingUtilities; +import javax.accessibility.Accessible; +import javax.accessibility.AccessibleContext; +/* + * @test + * @bug 8017112 + * @summary JTabbedPane components have inconsistent accessibility tree + * @run main AccessibleIndexInParentTest + */ + +public class AccessibleIndexInParentTest { + + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(AccessibleIndexInParentTest::test); + } + + private static void test() { + + int N = 5; + JTabbedPane tabbedPane = new JTabbedPane(); + + for (int i = 0; i < N; i++) { + tabbedPane.addTab("Title: " + i, new JLabel("Component: " + i)); + } + + for (int i = 0; i < tabbedPane.getTabCount(); i++) { + Component child = tabbedPane.getComponentAt(i); + + AccessibleContext ac = child.getAccessibleContext(); + if (ac == null) { + throw new RuntimeException("Accessible Context is null!"); + } + + int index = ac.getAccessibleIndexInParent(); + Accessible parent = ac.getAccessibleParent(); + + if (parent.getAccessibleContext().getAccessibleChild(index) != child) { + throw new RuntimeException("Wrong getAccessibleIndexInParent!"); + } + } + } +} \ No newline at end of file -- GitLab From 6a55291a23f5116c16c27c7a7f152bcf8e45adb3 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Fri, 29 Apr 2016 11:14:56 -0700 Subject: [PATCH 023/400] 8151323: GeoTIFFTagSet#"ModelTiePointTag" name case does not match GeoTIFF specification Change occurrences of "ModelTiePoint" to "ModelTiepoint." Reviewed-by: prr --- .../classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java index 28ee56abd3c..58adc761f29 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/GeoTIFFTagSet.java @@ -87,9 +87,9 @@ public class GeoTIFFTagSet extends TIFFTagSet { } } - static class ModelTiePoint extends TIFFTag { - public ModelTiePoint() { - super("ModelTiePointTag", + static class ModelTiepoint extends TIFFTag { + public ModelTiepoint() { + super("ModelTiepointTag", TAG_MODEL_TIE_POINT, 1 << TIFFTag.TIFF_DOUBLE); } @@ -126,7 +126,7 @@ public class GeoTIFFTagSet extends TIFFTagSet { tags.add(new GeoTIFFTagSet.ModelPixelScale()); tags.add(new GeoTIFFTagSet.ModelTransformation()); - tags.add(new GeoTIFFTagSet.ModelTiePoint()); + tags.add(new GeoTIFFTagSet.ModelTiepoint()); tags.add(new GeoTIFFTagSet.GeoKeyDirectory()); tags.add(new GeoTIFFTagSet.GeoDoubleParams()); tags.add(new GeoTIFFTagSet.GeoAsciiParams()); -- GitLab From 528b2cc81a583705fd00075aa465256cd306be09 Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Fri, 29 Apr 2016 15:17:46 -0400 Subject: [PATCH 024/400] 8155727: java/util/concurrent/locks/Lock/TimedAcquireLeak.java timeouts Fix regex pattern to handle possible (module@version) text Reviewed-by: ctornqvi, martin --- .../java/util/concurrent/locks/Lock/TimedAcquireLeak.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java b/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java index 7d6da0b255e..630f3796b8c 100644 --- a/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java +++ b/jdk/test/java/util/concurrent/locks/Lock/TimedAcquireLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -167,7 +167,7 @@ public class TimedAcquireLeak { final String childPid, final String className) { final String regex = - "(?m)^ *[0-9]+: +([0-9]+) +[0-9]+ +\\Q"+className+"\\E$"; + "(?m)^ *[0-9]+: +([0-9]+) +[0-9]+ +\\Q"+className+"\\E(?:$| )"; final Callable objectsInUse = new Callable() { public Integer call() { Integer i = Integer.parseInt( -- GitLab From fed3d6ceac50ab9e33fcdf74ab4a8d6e26348200 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Fri, 29 Apr 2016 14:50:50 -0700 Subject: [PATCH 025/400] 8149810: TIFFField#getAsLong throws ClassCastException when data is type TIFFTag.TIFF_DOUBLE or TIFFTag.FLOAT Expand the getAsLong() specification and handle the TIFF_DOUBLE and TIFF_FLOAT cases. Reviewed-by: prr --- .../javax/imageio/plugins/tiff/TIFFField.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java index 336f81550b7..168e6b17328 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java @@ -1089,6 +1089,15 @@ public class TIFFField implements Cloneable { * {@code TIFF_SBYTE} data will be returned in the range * [-128, 127]. * + *

      Data in {@code TIFF_FLOAT} and {@code TIFF_DOUBLE} are + * simply cast to {@code long} and may suffer from truncation. + * + *

      Data in {@code TIFF_SRATIONAL} or + * {@code TIFF_RATIONAL} format are evaluated by dividing the + * numerator into the denominator using double-precision + * arithmetic and then casting to {@code long}. Loss of + * precision and truncation may occur. + * *

      Data in {@code TIFF_ASCII} format will be parsed as by * the {@code Double.parseDouble} method, with the result * cast to {@code long}. @@ -1112,6 +1121,10 @@ public class TIFFField implements Cloneable { case TIFFTag.TIFF_LONG: case TIFFTag.TIFF_IFD_POINTER: return ((long[])data)[index]; + case TIFFTag.TIFF_FLOAT: + return (long)((float[])data)[index]; + case TIFFTag.TIFF_DOUBLE: + return (long)((double[])data)[index]; case TIFFTag.TIFF_SRATIONAL: int[] ivalue = getAsSRational(index); return (long)((double)ivalue[0]/ivalue[1]); -- GitLab From 5dda2fc113cd2a7c2c252f2726d200213f18bd8d Mon Sep 17 00:00:00 2001 From: Phil Race Date: Fri, 29 Apr 2016 16:37:02 -0700 Subject: [PATCH 026/400] 8155772: gtk3_interface.c compilation error on Ubuntu 12.10 Reviewed-by: serb, kcr --- .../java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c index 6a188fb3598..060b082e53b 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk3_interface.c @@ -2547,14 +2547,14 @@ static jobject get_string_property(JNIEnv *env, GtkSettings* settings, static jobject get_integer_property(JNIEnv *env, GtkSettings* settings, const gchar* key) { - gint intval = NULL; + gint intval = 0; (*fp_g_object_get)(settings, key, &intval, NULL); return create_Integer(env, intval); } static jobject get_boolean_property(JNIEnv *env, GtkSettings* settings, const gchar* key) { - gint intval = NULL; + gint intval = 0; (*fp_g_object_get)(settings, key, &intval, NULL); return create_Boolean(env, intval); } -- GitLab From 3dfed24a479db9972f0ba9324ca27a9586fe2a45 Mon Sep 17 00:00:00 2001 From: Max Ockner Date: Fri, 29 Apr 2016 22:39:44 -0400 Subject: [PATCH 027/400] 8154110: Update class* and safepoint* logging subsystems Refactored logging tags in class and safepoint subsystems. Reviewed-by: coleenp, rehn, hseigel --- jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh | 2 +- jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh | 2 +- .../instrument/appendToClassLoaderSearch/ClassUnloadTest.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh b/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh index 3872f813ffd..a00c14077d6 100644 --- a/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh +++ b/jdk/test/java/lang/ClassLoader/deadlock/TestCrossDelegate.sh @@ -106,7 +106,7 @@ done # run test ${TESTJAVA}${FS}bin${FS}java \ ${TESTVMOPTS} \ - -verbose:class -Xlog:classload -cp . \ + -verbose:class -Xlog:class+load -cp . \ -Dtest.classes=${TESTCLASSES} \ Starter cross # -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass \ diff --git a/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh b/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh index 198cd70827a..1289b4c861e 100644 --- a/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh +++ b/jdk/test/java/lang/ClassLoader/deadlock/TestOneWayDelegate.sh @@ -102,7 +102,7 @@ done # run test ${TESTJAVA}${FS}bin${FS}java \ ${TESTVMOPTS} \ - -verbose:class -Xlog:classload -cp . \ + -verbose:class -Xlog:class+load -cp . \ -Dtest.classes=${TESTCLASSES} \ Starter one-way # -XX:+UnlockDiagnosticVMOptions -XX:+UnsyncloadClass \ diff --git a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh index f5bb3b83179..b428a59bb28 100644 --- a/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh +++ b/jdk/test/java/lang/instrument/appendToClassLoaderSearch/ClassUnloadTest.sh @@ -80,5 +80,5 @@ $JAR ${TESTTOOLVMOPTS} -cfm "${TESTCLASSES}"/ClassUnloadTest.jar "${MANIFEST}" \ # Finally we run the test (cd "${TESTCLASSES}"; \ - $JAVA ${TESTVMOPTS} -Xverify:none -Xlog:classunload \ + $JAVA ${TESTVMOPTS} -Xverify:none -Xlog:class+unload \ -javaagent:ClassUnloadTest.jar ClassUnloadTest "${OTHERDIR}" Bar.jar) -- GitLab From 1f092412dccc3eeb353c0ef4ab360a5999f2e050 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Mon, 2 May 2016 12:01:39 +0300 Subject: [PATCH 028/400] 8154493: AppletViewer should emit its deprecation warning to standard error Reviewed-by: smarks --- jdk/src/java.desktop/share/classes/sun/applet/Main.java | 3 ++- .../DeprecatedAppletViewer/DeprecatedAppletViewer.java | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/sun/applet/Main.java b/jdk/src/java.desktop/share/classes/sun/applet/Main.java index 086b1113614..6c28c8f9d11 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/Main.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/Main.java @@ -104,7 +104,8 @@ public class Main { private int run(String [] args) { // DECODE ARGS try { - System.out.println(lookup("deprecated")); + System.err.println(lookup("deprecated")); + System.err.flush(); if (args.length == 0) { usage(); return 0; diff --git a/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java b/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java index f3b43f83eee..3c491011794 100644 --- a/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java +++ b/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java @@ -35,14 +35,14 @@ public final class DeprecatedAppletViewer { private static final String TEXT = "AppletViewer is deprecated."; public static void main(final String[] args) { - final PrintStream old = System.out; + final PrintStream old = System.err; final ByteArrayOutputStream baos = new ByteArrayOutputStream(1000); final PrintStream ps = new PrintStream(baos); try { - System.setOut(ps); + System.setErr(ps); sun.applet.Main.main(new String[]{}); } finally { - System.setOut(old); + System.setErr(old); } final String text = new String(baos.toByteArray()); -- GitLab From 36865021a112e983a33d495d4a1ab0d4490ae2b0 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Mon, 2 May 2016 12:08:59 +0300 Subject: [PATCH 029/400] 8027324: The spec for Toolkit.setDynamicLayout() and Toolkit.isDynamicLayoutActive() needs to be clarified Reviewed-by: alexsch, prr --- .../share/classes/java/awt/Toolkit.java | 52 ++++++++++--------- .../awt/Toolkit/DynamicLayout/bug7172833.java | 22 +++++++- 2 files changed, 48 insertions(+), 26 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java index bed5149c08a..b45dd39a717 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Toolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -207,30 +207,34 @@ public abstract class Toolkit { } /** - * Returns whether dynamic layout of Containers on resize is - * currently active (both set in program - *( {@code isDynamicLayoutSet()} ) - *, and supported - * by the underlying operating system and/or window manager). - * If dynamic layout is currently inactive then Containers - * re-layout their components when resizing is completed. As a result - * the {@code Component.validate()} method will be invoked only - * once per resize. - * If dynamic layout is currently active then Containers - * re-layout their components on every native resize event and - * the {@code validate()} method will be invoked each time. - * The OS/WM support can be queried using - * the getDesktopProperty("awt.dynamicLayoutSupported") method. + * Returns whether dynamic layout of Containers on resize is currently + * enabled on the underlying operating system and/or window manager). If the + * platform supports it, {@code setDynamicLayout(boolean)} may be used to + * programmatically enable or disable platform dynamic layout. Regardless of + * whether that toggling is supported, or whether {@code true} or {@code + * false} is specified as an argument, or has never been called at all, this + * method will return the active current platform behavior and which will be + * followed by the JDK in determining layout policy during resizing. + *

      + * If dynamic layout is currently inactive then Containers re-layout their + * components when resizing is completed. As a result the + * {@code Component.validate()} method will be invoked only once per resize. + * If dynamic layout is currently active then Containers re-layout their + * components on every native resize event and the {@code validate()} method + * will be invoked each time. The OS/WM support can be queried using the + * getDesktopProperty("awt.dynamicLayoutSupported") method. This property + * will reflect the platform capability but is not sufficient to tell if it + * is presently enabled. * - * @return true if dynamic layout of Containers on resize is - * currently active, false otherwise. - * @exception HeadlessException if the GraphicsEnvironment.isHeadless() - * method returns true - * @see #setDynamicLayout(boolean dynamic) - * @see #isDynamicLayoutSet() - * @see #getDesktopProperty(String propertyName) - * @see java.awt.GraphicsEnvironment#isHeadless - * @since 1.4 + * @return true if dynamic layout of Containers on resize is currently + * active, false otherwise. + * @throws HeadlessException if the GraphicsEnvironment.isHeadless() method + * returns true + * @see #setDynamicLayout(boolean dynamic) + * @see #isDynamicLayoutSet() + * @see #getDesktopProperty(String propertyName) + * @see java.awt.GraphicsEnvironment#isHeadless + * @since 1.4 */ public boolean isDynamicLayoutActive() throws HeadlessException { diff --git a/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java b/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java index 7c61804892b..2c4f04147b8 100644 --- a/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java +++ b/jdk/test/java/awt/Toolkit/DynamicLayout/bug7172833.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,16 +45,34 @@ public final class bug7172833 { public static void main(final String[] args) throws Exception { final StubbedToolkit t = new StubbedToolkit(); - + final Boolean dynamicLayoutSupported + = (Boolean) t.getDesktopProperty("awt.dynamicLayoutSupported"); t.setDynamicLayout(true); if(!t.isDynamicLayoutSet()){ throw new RuntimeException("'true' expected but 'false' returned"); } + if (dynamicLayoutSupported) { + if (!t.isDynamicLayoutActive()) { + throw new RuntimeException("is inactive but set+supported"); + } + } else { + if (t.isDynamicLayoutActive()) { + throw new RuntimeException("is active but unsupported"); + } + } t.setDynamicLayout(false); if(t.isDynamicLayoutSet()){ throw new RuntimeException("'false' expected but 'true' returned"); } + if (dynamicLayoutSupported) { + // Layout is supported and was set to false, cannot verifym because + // the native system is free to ignore our request. + } else { + if (t.isDynamicLayoutActive()) { + throw new RuntimeException("is active but unset+unsupported"); + } + } } static final class StubbedToolkit extends Toolkit { -- GitLab From 4f53885343025864dedb15af3c22156242809e17 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 4 May 2016 17:17:28 +0300 Subject: [PATCH 030/400] 8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures Reviewed-by: psandoz, vlivanov, simonis --- .../invoke/VarHandles/VarHandleBaseTest.java | 3 +- .../VarHandleTestAccessBoolean.java | 1 - .../VarHandles/VarHandleTestAccessByte.java | 1 - .../VarHandles/VarHandleTestAccessChar.java | 1 - .../VarHandles/VarHandleTestAccessDouble.java | 1 - .../VarHandles/VarHandleTestAccessFloat.java | 1 - .../VarHandles/VarHandleTestAccessInt.java | 64 +++++++++++++------ .../VarHandles/VarHandleTestAccessLong.java | 64 +++++++++++++------ .../VarHandles/VarHandleTestAccessShort.java | 1 - .../VarHandles/VarHandleTestAccessString.java | 64 +++++++++++++------ .../VarHandleTestByteArrayAsChar.java | 1 - .../VarHandleTestByteArrayAsDouble.java | 43 +++++++++---- .../VarHandleTestByteArrayAsFloat.java | 43 +++++++++---- .../VarHandleTestByteArrayAsInt.java | 43 +++++++++---- .../VarHandleTestByteArrayAsLong.java | 43 +++++++++---- .../VarHandleTestByteArrayAsShort.java | 1 - .../VarHandleTestMethodHandleAccessInt.java | 63 ++++++++++++------ .../VarHandleTestMethodHandleAccessLong.java | 63 ++++++++++++------ ...VarHandleTestMethodHandleAccessString.java | 63 ++++++++++++------ .../X-VarHandleTestAccess.java.template | 63 ++++++++++++------ ...X-VarHandleTestByteArrayView.java.template | 42 ++++++++---- ...HandleTestMethodHandleAccess.java.template | 63 ++++++++++++------ 22 files changed, 512 insertions(+), 220 deletions(-) diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java index 241d821c00a..ee6205d1ed7 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; abstract class VarHandleBaseTest { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); interface ThrowingRunnable { void run() throws Throwable; @@ -474,4 +475,4 @@ abstract class VarHandleBaseTest { assertEquals(mt.parameterType(mt.parameterCount() - 1), vh.varType()); } } -} \ No newline at end of file +} diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java index 5590984e493..b22fc3e182a 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java @@ -106,7 +106,6 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java index f9c9d4fc31e..088a519e920 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java @@ -106,7 +106,6 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java index bd1174efc5a..18ff6542615 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java @@ -106,7 +106,6 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java index d8732d239b4..36c84e2f753 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java @@ -106,7 +106,6 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java index 9976102d027..2ea2d9617be 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java @@ -106,7 +106,6 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java index c78e5cb7199..25683af1097 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java @@ -106,7 +106,6 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -402,22 +401,31 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { } { - boolean r = vh.weakCompareAndSet(recv, 1, 2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(recv, 1, 2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(recv); assertEquals(x, 2, "weakCompareAndSet int value"); } { - boolean r = vh.weakCompareAndSetAcquire(recv, 2, 1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(recv, 2, 1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) vh.get(recv); assertEquals(x, 1, "weakCompareAndSetAcquire int"); } { - boolean r = vh.weakCompareAndSetRelease(recv, 1, 2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(recv, 1, 2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) vh.get(recv); assertEquals(x, 2, "weakCompareAndSetRelease int"); } @@ -536,22 +544,31 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { } { - boolean r = (boolean) vh.weakCompareAndSet(1, 2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(1, 2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(); assertEquals(x, 2, "weakCompareAndSet int value"); } { - boolean r = (boolean) vh.weakCompareAndSetAcquire(2, 1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(2, 1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) vh.get(); assertEquals(x, 1, "weakCompareAndSetAcquire int"); } { - boolean r = (boolean) vh.weakCompareAndSetRelease( 1, 2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(1, 2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) vh.get(); assertEquals(x, 2, "weakCompareAndSetRelease int"); } @@ -673,22 +690,31 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { } { - boolean r = vh.weakCompareAndSet(array, i, 1, 2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, 1, 2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(array, i); assertEquals(x, 2, "weakCompareAndSet int value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, 2, 1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, 2, 1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) vh.get(array, i); assertEquals(x, 1, "weakCompareAndSetAcquire int"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, 1, 2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, 1, 2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) vh.get(array, i); assertEquals(x, 2, "weakCompareAndSetRelease int"); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java index f82ee67960e..2b44b4793f7 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java @@ -106,7 +106,6 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -402,22 +401,31 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { } { - boolean r = vh.weakCompareAndSet(recv, 1L, 2L); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(recv, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(recv); assertEquals(x, 2L, "weakCompareAndSet long value"); } { - boolean r = vh.weakCompareAndSetAcquire(recv, 2L, 1L); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(recv, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) vh.get(recv); assertEquals(x, 1L, "weakCompareAndSetAcquire long"); } { - boolean r = vh.weakCompareAndSetRelease(recv, 1L, 2L); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(recv, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) vh.get(recv); assertEquals(x, 2L, "weakCompareAndSetRelease long"); } @@ -536,22 +544,31 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { } { - boolean r = (boolean) vh.weakCompareAndSet(1L, 2L); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(1L, 2L); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(); assertEquals(x, 2L, "weakCompareAndSet long value"); } { - boolean r = (boolean) vh.weakCompareAndSetAcquire(2L, 1L); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) vh.get(); assertEquals(x, 1L, "weakCompareAndSetAcquire long"); } { - boolean r = (boolean) vh.weakCompareAndSetRelease( 1L, 2L); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(1L, 2L); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) vh.get(); assertEquals(x, 2L, "weakCompareAndSetRelease long"); } @@ -673,22 +690,31 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { } { - boolean r = vh.weakCompareAndSet(array, i, 1L, 2L); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(array, i); assertEquals(x, 2L, "weakCompareAndSet long value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, 2L, 1L); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) vh.get(array, i); assertEquals(x, 1L, "weakCompareAndSetAcquire long"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, 1L, 2L); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) vh.get(array, i); assertEquals(x, 2L, "weakCompareAndSetRelease long"); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java index d235e03a7bf..4ff25cc4a5f 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java @@ -106,7 +106,6 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java index 61e3690447c..1e876059a69 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java @@ -106,7 +106,6 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -416,22 +415,31 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { } { - boolean r = vh.weakCompareAndSet(recv, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSet String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(recv, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) vh.get(recv); assertEquals(x, "bar", "weakCompareAndSet String value"); } { - boolean r = vh.weakCompareAndSetAcquire(recv, "bar", "foo"); - assertEquals(r, true, "weakCompareAndSetAcquire String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(recv, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetAcquire String"); String x = (String) vh.get(recv); assertEquals(x, "foo", "weakCompareAndSetAcquire String"); } { - boolean r = vh.weakCompareAndSetRelease(recv, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSetRelease String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(recv, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSetRelease String"); String x = (String) vh.get(recv); assertEquals(x, "bar", "weakCompareAndSetRelease String"); } @@ -548,22 +556,31 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { } { - boolean r = (boolean) vh.weakCompareAndSet("foo", "bar"); - assertEquals(r, true, "weakCompareAndSet String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet("foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) vh.get(); assertEquals(x, "bar", "weakCompareAndSet String value"); } { - boolean r = (boolean) vh.weakCompareAndSetAcquire("bar", "foo"); - assertEquals(r, true, "weakCompareAndSetAcquire String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire("bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetAcquire String"); String x = (String) vh.get(); assertEquals(x, "foo", "weakCompareAndSetAcquire String"); } { - boolean r = (boolean) vh.weakCompareAndSetRelease( "foo", "bar"); - assertEquals(r, true, "weakCompareAndSetRelease String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease("foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSetRelease String"); String x = (String) vh.get(); assertEquals(x, "bar", "weakCompareAndSetRelease String"); } @@ -683,22 +700,31 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { } { - boolean r = vh.weakCompareAndSet(array, i, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSet String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) vh.get(array, i); assertEquals(x, "bar", "weakCompareAndSet String value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, "bar", "foo"); - assertEquals(r, true, "weakCompareAndSetAcquire String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetAcquire String"); String x = (String) vh.get(array, i); assertEquals(x, "foo", "weakCompareAndSetAcquire String"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSetRelease String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSetRelease String"); String x = (String) vh.get(array, i); assertEquals(x, "bar", "weakCompareAndSetRelease String"); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java index e6941f5fa3c..842a9f55327 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java @@ -93,7 +93,6 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java index ec4b843b2aa..57635e95474 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java @@ -93,7 +93,6 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -678,22 +677,31 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet double value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire double"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease double"); } @@ -811,22 +819,31 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet double value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire double"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease double"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease double"); double x = (double) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease double"); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java index 57d37cbe523..23d5072e274 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java @@ -93,7 +93,6 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -678,22 +677,31 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet float value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire float"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease float"); } @@ -811,22 +819,31 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet float value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire float"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease float"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease float"); float x = (float) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease float"); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java index ae66477d3b6..91eee4f4775 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java @@ -93,7 +93,6 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -692,22 +691,31 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet int value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire int"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease int"); } @@ -834,22 +842,31 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet int value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire int"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease int"); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java index ac08db2af5c..8adaf2b3428 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java @@ -93,7 +93,6 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); @@ -692,22 +691,31 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet long value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire long"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease long"); } @@ -834,22 +842,31 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet long value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire long"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease long"); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java index 9742fbd2522..f554fb35058 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java @@ -93,7 +93,6 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); - assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_ADD)); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java index 4e8de0c3bc8..4985136f2fd 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java @@ -208,22 +208,31 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1, 2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1, 2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, 2, "weakCompareAndSet int value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2, 1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2, 1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, 1, "weakCompareAndSetAcquire int"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1, 2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1, 2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, 2, "weakCompareAndSetRelease int"); } @@ -342,22 +351,31 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1, 2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1, 2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 2, "weakCompareAndSet int value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2, 1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2, 1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 1, "weakCompareAndSetAcquire int"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( 1, 2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1, 2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 2, "weakCompareAndSetRelease int"); } @@ -479,22 +497,31 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1, 2); - assertEquals(r, true, "weakCompareAndSet int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1, 2); + } + assertEquals(success, true, "weakCompareAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 2, "weakCompareAndSet int value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2, 1); - assertEquals(r, true, "weakCompareAndSetAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2, 1); + } + assertEquals(success, true, "weakCompareAndSetAcquire int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 1, "weakCompareAndSetAcquire int"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1, 2); - assertEquals(r, true, "weakCompareAndSetRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1, 2); + } + assertEquals(success, true, "weakCompareAndSetRelease int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 2, "weakCompareAndSetRelease int"); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java index 05efd70079b..59a3941c4db 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java @@ -208,22 +208,31 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1L, 2L); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, 2L, "weakCompareAndSet long value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2L, 1L); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, 1L, "weakCompareAndSetAcquire long"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1L, 2L); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, 2L, "weakCompareAndSetRelease long"); } @@ -342,22 +351,31 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1L, 2L); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(1L, 2L); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 2L, "weakCompareAndSet long value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2L, 1L); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 1L, "weakCompareAndSetAcquire long"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( 1L, 2L); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(1L, 2L); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, 2L, "weakCompareAndSetRelease long"); } @@ -479,22 +497,31 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1L, 2L); - assertEquals(r, true, "weakCompareAndSet long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 2L, "weakCompareAndSet long value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2L, 1L); - assertEquals(r, true, "weakCompareAndSetAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetAcquire long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 1L, "weakCompareAndSetAcquire long"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1L, 2L); - assertEquals(r, true, "weakCompareAndSetRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSetRelease long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, 2L, "weakCompareAndSetRelease long"); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java index 62ef4ae7f37..eb2ed9d3c08 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java @@ -208,22 +208,31 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSet String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, "bar", "weakCompareAndSet String value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, "bar", "foo"); - assertEquals(r, true, "weakCompareAndSetAcquire String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetAcquire String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, "foo", "weakCompareAndSetAcquire String"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSetRelease String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSetRelease String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, "bar", "weakCompareAndSetRelease String"); } @@ -338,22 +347,31 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("foo", "bar"); - assertEquals(r, true, "weakCompareAndSet String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact("foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, "bar", "weakCompareAndSet String value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact("bar", "foo"); - assertEquals(r, true, "weakCompareAndSetAcquire String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact("bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetAcquire String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, "foo", "weakCompareAndSetAcquire String"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( "foo", "bar"); - assertEquals(r, true, "weakCompareAndSetRelease String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact("foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSetRelease String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, "bar", "weakCompareAndSetRelease String"); } @@ -471,22 +489,31 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSet String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, "bar", "weakCompareAndSet String value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, "bar", "foo"); - assertEquals(r, true, "weakCompareAndSetAcquire String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetAcquire String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, "foo", "weakCompareAndSetAcquire String"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSetRelease String"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSetRelease String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, "bar", "weakCompareAndSetRelease String"); } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template index fb44c8bbb2b..dbee4cbb347 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template @@ -494,22 +494,31 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { } { - boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(recv, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(recv); assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); } { - boolean r = vh.weakCompareAndSetAcquire(recv, $value2$, $value1$); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(recv, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) vh.get(recv); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { - boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(recv, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) vh.get(recv); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } @@ -670,22 +679,31 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { } { - boolean r = (boolean) vh.weakCompareAndSet($value1$, $value2$); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet($value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(); assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); } { - boolean r = (boolean) vh.weakCompareAndSetAcquire($value2$, $value1$); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire($value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) vh.get(); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { - boolean r = (boolean) vh.weakCompareAndSetRelease( $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease($value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) vh.get(); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } @@ -849,22 +867,31 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { } { - boolean r = vh.weakCompareAndSet(array, i, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, $value2$, $value1$); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template index 1c323e2f195..12a0fcef8ad 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template @@ -848,22 +848,31 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire $type$"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease $type$"); } @@ -994,22 +1003,31 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { } { - boolean r = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSet(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSet $type$ value"); } { - boolean r = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetAcquire(array, i, VALUE_2, VALUE_1); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_1, "weakCompareAndSetAcquire $type$"); } { - boolean r = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(array, i, VALUE_1, VALUE_2); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) vh.get(array, i); assertEquals(x, VALUE_2, "weakCompareAndSetRelease $type$"); } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template index 8e40761a4f3..a3b3aa5c43f 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template @@ -209,22 +209,31 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(recv, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(recv, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(recv, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } @@ -373,22 +382,31 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact($value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact($value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact( $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact($value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } @@ -540,22 +558,31 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSet $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET).invokeExact(array, i, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, $value2$, "weakCompareAndSet $type$ value"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$); - assertEquals(r, true, "weakCompareAndSetAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_ACQUIRE).invokeExact(array, i, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetAcquire $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, $value1$, "weakCompareAndSetAcquire $type$"); } { - boolean r = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSetRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_RELEASE).invokeExact(array, i, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSetRelease $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } -- GitLab From 182152c38568d5f73b469d37e7b663677620d50d Mon Sep 17 00:00:00 2001 From: Harsha Wardhana B Date: Thu, 5 May 2016 01:52:03 -0700 Subject: [PATCH 031/400] 8154166: java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java fails with RuntimeException Fix the RuntimeException issue Reviewed-by: jbachorik --- .../management/MemoryMXBean/ResetPeakMemoryUsage.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java b/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java index b1f6e781044..dc85eb6bb03 100644 --- a/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java +++ b/jdk/test/java/lang/management/MemoryMXBean/ResetPeakMemoryUsage.java @@ -36,9 +36,13 @@ * @modules java.management * @build jdk.testlibrary.* ResetPeakMemoryUsage MemoryUtil RunUtil * @run main ResetPeakMemoryUsage + * @requires vm.opt.ExplicitGCInvokesConcurrent != "true" + * @requires vm.opt.ExplicitGCInvokesConcurrentAndUnloadsClasses != "true" + * @requires vm.opt.DisableExplicitGC != "true" */ import java.lang.management.*; +import java.lang.ref.WeakReference; import java.util.*; public class ResetPeakMemoryUsage { @@ -100,6 +104,7 @@ public class ResetPeakMemoryUsage { printMemoryUsage(usage0, peak0); obj = new Object[largeArraySize]; + WeakReference weakRef = new WeakReference<>(obj); MemoryUsage usage1 = mpool.getUsage(); MemoryUsage peak1 = mpool.getPeakUsage(); @@ -124,7 +129,11 @@ public class ResetPeakMemoryUsage { // The object is now garbage and do a GC // memory usage should drop obj = null; - mbean.gc(); + + //This will cause sure shot GC unlike Runtime.gc() invoked by mbean.gc() + while(weakRef.get() != null) { + mbean.gc(); + } MemoryUsage usage2 = mpool.getUsage(); MemoryUsage peak2 = mpool.getPeakUsage(); -- GitLab From b52c5bbd676a3d78caf1cee59abfa4846f540c9c Mon Sep 17 00:00:00 2001 From: Brent Christian Date: Thu, 5 May 2016 11:44:01 -0700 Subject: [PATCH 032/400] 8147039: Incorrect locals and operands in compiled frames Implement stack walking using javaVFrame instead of vframeStream Reviewed-by: mchung, vlivanov --- .../lang/StackWalker/CountLocalSlots.java | 61 +++ .../lang/StackWalker/LocalsAndOperands.java | 374 ++++++++++++++---- .../java/lang/StackWalker/LocalsCrash.java | 74 ++++ 3 files changed, 437 insertions(+), 72 deletions(-) create mode 100644 jdk/test/java/lang/StackWalker/CountLocalSlots.java create mode 100644 jdk/test/java/lang/StackWalker/LocalsCrash.java diff --git a/jdk/test/java/lang/StackWalker/CountLocalSlots.java b/jdk/test/java/lang/StackWalker/CountLocalSlots.java new file mode 100644 index 00000000000..c78a4cb7bf4 --- /dev/null +++ b/jdk/test/java/lang/StackWalker/CountLocalSlots.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8147039 + * @summary Confirm locals[] always has expected length, even for "dead" locals + * @compile LocalsAndOperands.java + * @run testng/othervm -Xcomp CountLocalSlots + */ + +import org.testng.annotations.Test; +import java.lang.StackWalker.StackFrame; + +public class CountLocalSlots { + final static boolean debug = true; + + @Test(dataProvider = "provider", dataProviderClass = LocalsAndOperands.class) + public void countLocalSlots(StackFrame... frames) { + for (StackFrame frame : frames) { + if (debug) { + System.out.println("Running countLocalSlots"); + LocalsAndOperands.dumpStackWithLocals(frames); + } + // Confirm expected number of locals + String methodName = frame.getMethodName(); + Integer expectedObj = (Integer) LocalsAndOperands.Tester.NUM_LOCALS.get(methodName); + if (expectedObj == null) { + if (!debug) { LocalsAndOperands.dumpStackWithLocals(frames); } + throw new RuntimeException("No NUM_LOCALS entry for " + + methodName + "(). Update test?"); + } + Object[] locals = (Object[]) LocalsAndOperands.invokeGetLocals(frame); + if (locals.length != expectedObj) { + if (!debug) { LocalsAndOperands.dumpStackWithLocals(frames); } + throw new RuntimeException(methodName + "(): number of locals (" + + locals.length + ") did not match expected (" + expectedObj + ")"); + } + } + } +} diff --git a/jdk/test/java/lang/StackWalker/LocalsAndOperands.java b/jdk/test/java/lang/StackWalker/LocalsAndOperands.java index 63a6731a164..b253ab27e81 100644 --- a/jdk/test/java/lang/StackWalker/LocalsAndOperands.java +++ b/jdk/test/java/lang/StackWalker/LocalsAndOperands.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,17 +23,20 @@ /* * @test - * @bug 8020968 - * @summary Sanity test for locals and operands - * @run main LocalsAndOperands + * @bug 8020968 8147039 + * @summary Tests for locals and operands + * @run testng LocalsAndOperands */ +import org.testng.annotations.*; import java.lang.StackWalker.StackFrame; import java.lang.reflect.*; -import java.util.List; -import java.util.stream.Collectors; +import java.util.*; +import java.util.stream.*; public class LocalsAndOperands { + static final boolean debug = true; + static Class liveStackFrameClass; static Class primitiveValueClass; static StackWalker extendedWalker; @@ -41,92 +44,319 @@ public class LocalsAndOperands { static Method getOperands; static Method getMonitors; static Method primitiveType; - public static void main(String... args) throws Exception { - liveStackFrameClass = Class.forName("java.lang.LiveStackFrame"); - primitiveValueClass = Class.forName("java.lang.LiveStackFrame$PrimitiveValue"); - getLocals = liveStackFrameClass.getDeclaredMethod("getLocals"); - getLocals.setAccessible(true); + static { + try { + liveStackFrameClass = Class.forName("java.lang.LiveStackFrame"); + primitiveValueClass = Class.forName("java.lang.LiveStackFrame$PrimitiveValue"); + + getLocals = liveStackFrameClass.getDeclaredMethod("getLocals"); + getLocals.setAccessible(true); + + getOperands = liveStackFrameClass.getDeclaredMethod("getStack"); + getOperands.setAccessible(true); + + getMonitors = liveStackFrameClass.getDeclaredMethod("getMonitors"); + getMonitors.setAccessible(true); + + primitiveType = primitiveValueClass.getDeclaredMethod("type"); + primitiveType.setAccessible(true); + + Method method = liveStackFrameClass.getMethod("getStackWalker"); + method.setAccessible(true); + extendedWalker = (StackWalker) method.invoke(null); + } catch (Throwable t) { throw new RuntimeException(t); } + } - getOperands = liveStackFrameClass.getDeclaredMethod("getStack"); - getOperands.setAccessible(true); + /** Helper method to return a StackFrame's locals */ + static Object[] invokeGetLocals(StackFrame arg) { + try { + return (Object[]) getLocals.invoke(arg); + } catch (Exception e) { throw new RuntimeException(e); } + } - getMonitors = liveStackFrameClass.getDeclaredMethod("getMonitors"); - getMonitors.setAccessible(true); + /***************** + * DataProviders * + *****************/ - primitiveType = primitiveValueClass.getDeclaredMethod("type"); - primitiveType.setAccessible(true); + /** Calls testLocals() and provides LiveStackFrames for testLocals* methods */ + @DataProvider + public static StackFrame[][] provider() { + return new StackFrame[][] { + new Tester().testLocals() + }; + } - Method method = liveStackFrameClass.getMethod("getStackWalker"); - method.setAccessible(true); - extendedWalker = (StackWalker) method.invoke(null); - new LocalsAndOperands(extendedWalker, true).test(); + /** + * Calls testLocalsKeepAlive() and provides LiveStackFrames for testLocals* methods. + * Local variables in testLocalsKeepAlive() are ensured to not become dead. + */ + @DataProvider + public static StackFrame[][] keepAliveProvider() { + return new StackFrame[][] { + new Tester().testLocalsKeepAlive() + }; + } - // no access to local and operands. - new LocalsAndOperands(StackWalker.getInstance(), false).test(); + /** + * Provides StackFrames from a StackWalker without the LOCALS_AND_OPERANDS + * option. + */ + @DataProvider + public static StackFrame[][] noLocalsProvider() { + // Use default StackWalker + return new StackFrame[][] { + new Tester(StackWalker.getInstance(), true).testLocals() + }; } - private final StackWalker walker; - private final boolean extended; - LocalsAndOperands(StackWalker walker, boolean extended) { - this.walker = walker; - this.extended = extended; + /** + * Calls testLocals() and provides LiveStackFrames for *all* called methods, + * including test infrastructure (jtreg, testng, etc) + * + */ + @DataProvider + public static StackFrame[][] unfilteredProvider() { + return new StackFrame[][] { + new Tester(extendedWalker, false).testLocals() + }; } - synchronized void test() throws Exception { - int x = 10; - char c = 'z'; - String hi = "himom"; - long l = 1000000L; - double d = 3.1415926; - - List frames = walker.walk(s -> s.collect(Collectors.toList())); - if (extended) { - for (StackWalker.StackFrame f : frames) { - System.out.println("frame: " + f); - Object[] locals = (Object[]) getLocals.invoke(f); + /**************** + * Test methods * + ****************/ + + /** + * Check for expected local values and types in the LiveStackFrame + */ + @Test(dataProvider = "keepAliveProvider") + public static void checkLocalValues(StackFrame... frames) { + if (debug) { + System.out.println("Running checkLocalValues"); + dumpStackWithLocals(frames); + } + Arrays.stream(frames).filter(f -> f.getMethodName() + .equals("testLocalsKeepAlive")) + .forEach( + f -> { + Object[] locals = invokeGetLocals(f); for (int i = 0; i < locals.length; i++) { - System.out.format(" local %d: %s type %s\n", i, locals[i], type(locals[i])); - - // check for non-null locals in LocalsAndOperands.test() - if (f.getClassName().equals("LocalsAndOperands") && - f.getMethodName().equals("test")) { - if (locals[i] == null) { - throw new RuntimeException("kept-alive locals should not be null"); - } + // Value + String expected = Tester.LOCAL_VALUES[i]; + Object observed = locals[i]; + if (expected != null /* skip nulls in golden values */ && + !expected.equals(observed.toString())) { + System.err.println("Local value mismatch:"); + if (!debug) { dumpStackWithLocals(frames); } + throw new RuntimeException("local " + i + " value is " + + observed + ", expected " + expected); } - } - Object[] operands = (Object[]) getOperands.invoke(f); - for (int i = 0; i < operands.length; i++) { - System.out.format(" operand %d: %s type %s%n", i, operands[i], - type(operands[i])); + // Type + expected = Tester.LOCAL_TYPES[i]; + observed = type(locals[i]); + if (expected != null /* skip nulls in golden values */ && + !expected.equals(observed)) { + System.err.println("Local type mismatch:"); + if (!debug) { dumpStackWithLocals(frames); } + throw new RuntimeException("local " + i + " type is " + + observed + ", expected " + expected); + } } + } + ); + } - Object[] monitors = (Object[]) getMonitors.invoke(f); - for (int i = 0; i < monitors.length; i++) { - System.out.format(" monitor %d: %s%n", i, monitors[i]); - } + /** + * Basic sanity check for locals and operands + */ + @Test(dataProvider = "provider") + public static void sanityCheck(StackFrame... frames) { + if (debug) { + System.out.println("Running sanityCheck"); + } + try { + Stream stream = Arrays.stream(frames); + if (debug) { + stream.forEach(LocalsAndOperands::printLocals); + } else { + System.out.println(stream.count() + " frames"); } - } else { - for (StackFrame f : frames) { - if (liveStackFrameClass.isInstance(f)) { - throw new RuntimeException("should not be LiveStackFrame"); - } + } catch (Throwable t) { + dumpStackWithLocals(frames); + throw t; + } + } + + /** + * Sanity check for locals and operands, including testng/jtreg frames + */ + @Test(dataProvider = "unfilteredProvider") + public static void unfilteredSanityCheck(StackFrame... frames) { + if (debug) { + System.out.println("Running unfilteredSanityCheck"); + } + try { + Stream stream = Arrays.stream(frames); + if (debug) { + stream.forEach(f -> { System.out.println(f + ": " + + invokeGetLocals(f).length + " locals"); } ); + } else { + System.out.println(stream.count() + " frames"); + } + } catch (Throwable t) { + dumpStackWithLocals(frames); + throw t; + } + } + + /** + * Test that LiveStackFrames are not provided with the default StackWalker + * options. + */ + @Test(dataProvider = "noLocalsProvider") + public static void withoutLocalsAndOperands(StackFrame... frames) { + for (StackFrame frame : frames) { + if (liveStackFrameClass.isInstance(frame)) { + throw new RuntimeException("should not be LiveStackFrame"); } } - // Use local variables so they stay alive - System.out.println("Stayin' alive: "+x+" "+c+" "+hi+" "+l+" "+d); } - String type(Object o) throws Exception { - if (o == null) { - return "null"; - } else if (primitiveValueClass.isInstance(o)) { - char c = (char)primitiveType.invoke(o); - return String.valueOf(c); - } else { - return o.getClass().getName(); + static class Tester { + private StackWalker walker; + private boolean filter = true; // Filter out testng/jtreg/etc frames? + + Tester() { + this.walker = extendedWalker; + } + + Tester(StackWalker walker, boolean filter) { + this.walker = walker; + this.filter = filter; + } + + /** + * Perform stackwalk without keeping local variables alive and return an + * array of the collected StackFrames + */ + private synchronized StackFrame[] testLocals() { + // Unused local variables will become dead + int x = 10; + char c = 'z'; + String hi = "himom"; + long l = 1000000L; + double d = 3.1415926; + + if (filter) { + return walker.walk(s -> s.filter(f -> TEST_METHODS.contains(f + .getMethodName())).collect(Collectors.toList())) + .toArray(new StackFrame[0]); + } else { + return walker.walk(s -> s.collect(Collectors.toList())) + .toArray(new StackFrame[0]); + } } + + /** + * Perform stackwalk, keeping local variables alive, and return a list of + * the collected StackFrames + */ + private synchronized StackFrame[] testLocalsKeepAlive() { + int x = 10; + char c = 'z'; + String hi = "himom"; + long l = 1000000L; + double d = 3.1415926; + + List frames; + if (filter) { + frames = walker.walk(s -> s.filter(f -> TEST_METHODS.contains(f + .getMethodName())).collect(Collectors.toList())); + } else { + frames = walker.walk(s -> s.collect(Collectors.toList())); + } + + // Use local variables so they stay alive + System.out.println("Stayin' alive: "+x+" "+c+" "+hi+" "+l+" "+d); + return frames.toArray(new StackFrame[0]); // FIXME: convert to Array here + } + + // Expected values for locals in testLocals() & testLocalsKeepAlive() + // TODO: use real values instead of Strings, rebuild doubles & floats, etc + private final static String[] LOCAL_VALUES = new String[] { + null, // skip, LocalsAndOperands$Tester@XXX identity is different each run + "10", + "122", + "himom", + "0", + null, // skip, fix in 8156073 + null, // skip, fix in 8156073 + null, // skip, fix in 8156073 + "0" + }; + + // Expected types for locals in testLocals() & testLocalsKeepAlive() + // TODO: use real types + private final static String[] LOCAL_TYPES = new String[] { + null, // skip + "I", + "I", + "java.lang.String", + "I", + "I", + "I", + "I", + "I" + }; + + final static Map NUM_LOCALS = Map.of("testLocals", 8, + "testLocalsKeepAlive", + LOCAL_VALUES.length); + private final static Collection TEST_METHODS = NUM_LOCALS.keySet(); + } + + /** + * Print stack trace with locals + */ + public static void dumpStackWithLocals(StackFrame...frames) { + Arrays.stream(frames).forEach(LocalsAndOperands::printLocals); + } + + /** + * Print the StackFrame and an indexed list of its locals + */ + public static void printLocals(StackWalker.StackFrame frame) { + try { + System.out.println(frame); + Object[] locals = (Object[]) getLocals.invoke(frame); + for (int i = 0; i < locals.length; i++) { + System.out.format(" local %d: %s type %s\n", i, locals[i], type(locals[i])); + } + + Object[] operands = (Object[]) getOperands.invoke(frame); + for (int i = 0; i < operands.length; i++) { + System.out.format(" operand %d: %s type %s%n", i, operands[i], + type(operands[i])); + } + + Object[] monitors = (Object[]) getMonitors.invoke(frame); + for (int i = 0; i < monitors.length; i++) { + System.out.format(" monitor %d: %s%n", i, monitors[i]); + } + } catch (Exception e) { throw new RuntimeException(e); } + } + + private static String type(Object o) { + try { + if (o == null) { + return "null"; + } else if (primitiveValueClass.isInstance(o)) { + char c = (char)primitiveType.invoke(o); + return String.valueOf(c); + } else { + return o.getClass().getName(); + } + } catch(Exception e) { throw new RuntimeException(e); } } } diff --git a/jdk/test/java/lang/StackWalker/LocalsCrash.java b/jdk/test/java/lang/StackWalker/LocalsCrash.java new file mode 100644 index 00000000000..b50dd263f00 --- /dev/null +++ b/jdk/test/java/lang/StackWalker/LocalsCrash.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8147039 + * @summary Test for -Xcomp crash that happened before 8147039 fix + * @run testng/othervm -Xcomp LocalsCrash + */ + +import org.testng.annotations.*; +import java.lang.reflect.*; +import java.util.List; +import java.util.stream.Collectors; + +public class LocalsCrash { + static Class liveStackFrameClass; + static Method getStackWalker; + + static { + try { + liveStackFrameClass = Class.forName("java.lang.LiveStackFrame"); + getStackWalker = liveStackFrameClass.getMethod("getStackWalker"); + getStackWalker.setAccessible(true); + } catch (Throwable t) { throw new RuntimeException(t); } + } + + private StackWalker walker; + + LocalsCrash() { + try { + walker = (StackWalker) getStackWalker.invoke(null); + } catch (Exception e) { throw new RuntimeException(e); } + } + + @Test + public void test00() { doStackWalk(); } + + @Test + public void test01() { doStackWalk(); } + + private synchronized List doStackWalk() { + try { + // Unused local variables will become dead + int x = 10; + char c = 'z'; + String hi = "himom"; + long l = 1000000L; + double d = 3.1415926; + + return walker.walk(s -> s.collect(Collectors.toList())); + } catch (Exception e) { throw new RuntimeException(e); } + } +} -- GitLab From 3d8d9fe7fa31fe7302e0d06274bf6980a53dd434 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 5 May 2016 18:14:47 -0700 Subject: [PATCH 033/400] 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package Reviewed-by: chegar, shade, forax, vlivanov --- .../classes/java/lang/invoke/VarHandle.java | 4 +- .../lang/invoke/X-VarHandle.java.template | 36 +- .../X-VarHandleByteArrayView.java.template | 7 +- .../share/classes/java/util/Objects.java | 343 +---------------- .../jdk/internal/util/Preconditions.java | 346 ++++++++++++++++++ jdk/test/java/util/Objects/CheckIndex.java | 70 ++-- 6 files changed, 414 insertions(+), 392 deletions(-) create mode 100644 jdk/src/java.base/share/classes/jdk/internal/util/Preconditions.java diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java index cf869b3ebe7..8b555bcf7e2 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java @@ -26,6 +26,7 @@ package java.lang.invoke; import jdk.internal.HotSpotIntrinsicCandidate; +import jdk.internal.util.Preconditions; import jdk.internal.vm.annotation.ForceInline; import java.lang.reflect.Method; @@ -34,7 +35,6 @@ import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Objects; import java.util.function.BiFunction; import java.util.function.Function; @@ -1380,7 +1380,7 @@ public abstract class VarHandle { } static final BiFunction, ArrayIndexOutOfBoundsException> - AIOOBE_SUPPLIER = Objects.outOfBoundsExceptionFormatter( + AIOOBE_SUPPLIER = Preconditions.outOfBoundsExceptionFormatter( new Function() { @Override public ArrayIndexOutOfBoundsException apply(String s) { diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template index bcec64bd390..20514c79bf0 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template @@ -24,9 +24,11 @@ */ package java.lang.invoke; -import java.util.Objects; +import jdk.internal.util.Preconditions; import jdk.internal.vm.annotation.ForceInline; +import java.util.Objects; + import static java.lang.invoke.MethodHandleStatics.UNSAFE; #warn @@ -407,7 +409,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.get$Type$Volatile(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); } @ForceInline @@ -418,7 +420,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] UNSAFE.put$Type$Volatile(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(value):value}); } @@ -430,7 +432,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.get$Type$Opaque(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); } @ForceInline @@ -441,7 +443,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] UNSAFE.put$Type$Opaque(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(value):value}); } @@ -453,7 +455,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.get$Type$Acquire(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase); } @ForceInline @@ -464,7 +466,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] UNSAFE.put$Type$Release(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(value):value}); } #if[CAS] @@ -477,7 +479,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.compareAndSwap$Type$(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); } @@ -490,7 +492,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.compareAndExchange$Type$Volatile(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); } @@ -503,7 +505,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.compareAndExchange$Type$Acquire(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); } @@ -516,7 +518,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.compareAndExchange$Type$Release(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); } @@ -529,7 +531,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.weakCompareAndSwap$Type$(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); } @@ -542,7 +544,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.weakCompareAndSwap$Type$Acquire(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); } @@ -555,7 +557,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.weakCompareAndSwap$Type$Release(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); } @@ -568,7 +570,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.getAndSet$Type$(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(value):value}); } #end[CAS] @@ -582,7 +584,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.getAndAdd$Type$(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value); } @@ -594,7 +596,7 @@ final class VarHandle$Type$s { $type$[] array = ($type$[]) oarray; #end[Object] return UNSAFE.getAndAdd$Type$(array, - (((long) Objects.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, + (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, value) + value; } #end[AtomicAdd] diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template index bdc77a820d2..f0721b60778 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template @@ -25,6 +25,7 @@ package java.lang.invoke; import jdk.internal.misc.Unsafe; +import jdk.internal.util.Preconditions; import jdk.internal.vm.annotation.ForceInline; import java.nio.ByteBuffer; @@ -78,7 +79,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static int index(byte[] ba, int index) { - return Objects.checkIndex(index, ba.length - ALIGN, null); + return Preconditions.checkIndex(index, ba.length - ALIGN, null); } @ForceInline @@ -287,14 +288,14 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static int index(ByteBuffer bb, int index) { - return Objects.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null); + return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null); } @ForceInline static int indexRO(ByteBuffer bb, int index) { if (UNSAFE.getBoolean(bb, BYTE_BUFFER_IS_READ_ONLY)) throw new ReadOnlyBufferException(); - return Objects.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null); + return Preconditions.checkIndex(index, UNSAFE.getInt(bb, BUFFER_LIMIT) - ALIGN, null); } @ForceInline diff --git a/jdk/src/java.base/share/classes/java/util/Objects.java b/jdk/src/java.base/share/classes/java/util/Objects.java index 28b39d08969..dad583b9206 100644 --- a/jdk/src/java.base/share/classes/java/util/Objects.java +++ b/jdk/src/java.base/share/classes/java/util/Objects.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,10 +25,9 @@ package java.util; -import jdk.internal.HotSpotIntrinsicCandidate; +import jdk.internal.util.Preconditions; +import jdk.internal.vm.annotation.ForceInline; -import java.util.function.BiFunction; -import java.util.function.Function; import java.util.function.Supplier; /** @@ -348,172 +347,6 @@ public final class Objects { return obj; } - /** - * Maps out-of-bounds values to a runtime exception. - * - * @param checkKind the kind of bounds check, whose name may correspond - * to the name of one of the range check methods, checkIndex, - * checkFromToIndex, checkFromIndexSize - * @param args the out-of-bounds arguments that failed the range check. - * If the checkKind corresponds a the name of a range check method - * then the bounds arguments are those that can be passed in order - * to the method. - * @param oobef the exception formatter that when applied with a checkKind - * and a list out-of-bounds arguments returns a runtime exception. - * If {@code null} then, it is as if an exception formatter was - * supplied that returns {@link IndexOutOfBoundsException} for any - * given arguments. - * @return the runtime exception - */ - private static RuntimeException outOfBounds( - BiFunction, ? extends RuntimeException> oobef, - String checkKind, - Integer... args) { - List largs = List.of(args); - RuntimeException e = oobef == null - ? null : oobef.apply(checkKind, largs); - return e == null - ? new IndexOutOfBoundsException(outOfBoundsMessage(checkKind, largs)) : e; - } - - // Specific out-of-bounds exception producing methods that avoid - // the varargs-based code in the critical methods there by reducing their - // the byte code size, and therefore less likely to peturb inlining - - private static RuntimeException outOfBoundsCheckIndex( - BiFunction, ? extends RuntimeException> oobe, - int index, int length) { - return outOfBounds(oobe, "checkIndex", index, length); - } - - private static RuntimeException outOfBoundsCheckFromToIndex( - BiFunction, ? extends RuntimeException> oobe, - int fromIndex, int toIndex, int length) { - return outOfBounds(oobe, "checkFromToIndex", fromIndex, toIndex, length); - } - - private static RuntimeException outOfBoundsCheckFromIndexSize( - BiFunction, ? extends RuntimeException> oobe, - int fromIndex, int size, int length) { - return outOfBounds(oobe, "checkFromIndexSize", fromIndex, size, length); - } - - /** - * Returns an out-of-bounds exception formatter from an given exception - * factory. The exception formatter is a function that formats an - * out-of-bounds message from its arguments and applies that message to the - * given exception factory to produce and relay an exception. - * - *

      The exception formatter accepts two arguments: a {@code String} - * describing the out-of-bounds range check that failed, referred to as the - * check kind; and a {@code List} containing the - * out-of-bound integer values that failed the check. The list of - * out-of-bound values is not modified. - * - *

      Three check kinds are supported {@code checkIndex}, - * {@code checkFromToIndex} and {@code checkFromIndexSize} corresponding - * respectively to the specified application of an exception formatter as an - * argument to the out-of-bounds range check methods - * {@link #checkIndex(int, int, BiFunction) checkIndex}, - * {@link #checkFromToIndex(int, int, int, BiFunction) checkFromToIndex}, and - * {@link #checkFromIndexSize(int, int, int, BiFunction) checkFromIndexSize}. - * Thus a supported check kind corresponds to a method name and the - * out-of-bound integer values correspond to method argument values, in - * order, preceding the exception formatter argument (similar in many - * respects to the form of arguments required for a reflective invocation of - * such a range check method). - * - *

      Formatter arguments conforming to such supported check kinds will - * produce specific exception messages describing failed out-of-bounds - * checks. Otherwise, more generic exception messages will be produced in - * any of the following cases: the check kind is supported but fewer - * or more out-of-bounds values are supplied, the check kind is not - * supported, the check kind is {@code null}, or the list of out-of-bound - * values is {@code null}. - * - * @apiNote - * This method produces an out-of-bounds exception formatter that can be - * passed as an argument to any of the supported out-of-bounds range check - * methods declared by {@code Objects}. For example, a formatter producing - * an {@code ArrayIndexOutOfBoundsException} may be produced and stored on a - * {@code static final} field as follows: - *

      {@code
      -     * static final
      -     * BiFunction, ArrayIndexOutOfBoundsException> AIOOBEF =
      -     *     outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new);
      -     * }
      - * The formatter instance {@code AIOOBEF} may be passed as an argument to an - * out-of-bounds range check method, such as checking if an {@code index} - * is within the bounds of a {@code limit}: - *
      {@code
      -     * checkIndex(index, limit, AIOOBEF);
      -     * }
      - * If the bounds check fails then the range check method will throw an - * {@code ArrayIndexOutOfBoundsException} with an appropriate exception - * message that is a produced from {@code AIOOBEF} as follows: - *
      {@code
      -     * AIOOBEF.apply("checkIndex", List.of(index, limit));
      -     * }
      - * - * @param f the exception factory, that produces an exception from a message - * where the message is produced and formatted by the returned - * exception formatter. If this factory is stateless and side-effect - * free then so is the returned formatter. - * Exceptions thrown by the factory are relayed to the caller - * of the returned formatter. - * @param the type of runtime exception to be returned by the given - * exception factory and relayed by the exception formatter - * @return the out-of-bounds exception formatter - */ - public static - BiFunction, X> outOfBoundsExceptionFormatter(Function f) { - // Use anonymous class to avoid bootstrap issues if this method is - // used early in startup - return new BiFunction, X>() { - @Override - public X apply(String checkKind, List args) { - return f.apply(outOfBoundsMessage(checkKind, args)); - } - }; - } - - private static String outOfBoundsMessage(String checkKind, List args) { - if (checkKind == null && args == null) { - return String.format("Range check failed"); - } else if (checkKind == null) { - return String.format("Range check failed: %s", args); - } else if (args == null) { - return String.format("Range check failed: %s", checkKind); - } - - int argSize = 0; - switch (checkKind) { - case "checkIndex": - argSize = 2; - break; - case "checkFromToIndex": - case "checkFromIndexSize": - argSize = 3; - break; - default: - } - - // Switch to default if fewer or more arguments than required are supplied - switch ((args.size() != argSize) ? "" : checkKind) { - case "checkIndex": - return String.format("Index %d out-of-bounds for length %d", - args.get(0), args.get(1)); - case "checkFromToIndex": - return String.format("Range [%d, %d) out-of-bounds for length %d", - args.get(0), args.get(1), args.get(2)); - case "checkFromIndexSize": - return String.format("Range [%d, %{@code length < 0}, which is implied from the former inequalities * * - *

      This method behaves as if {@link #checkIndex(int, int, BiFunction)} - * was called with same out-of-bounds arguments and an exception formatter - * argument produced from an invocation of - * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} (though it may - * be more efficient). - * * @param index the index * @param length the upper-bound (exclusive) of the range * @return {@code index} if it is within bounds of the range * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds * @since 9 */ + @ForceInline public static int checkIndex(int index, int length) { - return checkIndex(index, length, null); - } - - /** - * Checks if the {@code index} is within the bounds of the range from - * {@code 0} (inclusive) to {@code length} (exclusive). - * - *

      The {@code index} is defined to be out-of-bounds if any of the - * following inequalities is true: - *

        - *
      • {@code index < 0}
      • - *
      • {@code index >= length}
      • - *
      • {@code length < 0}, which is implied from the former inequalities
      • - *
      - * - *

      If the {@code index} is out-of-bounds, then a runtime exception is - * thrown that is the result of applying the following arguments to the - * exception formatter: the name of this method, {@code checkIndex}; - * and an unmodifiable list integers whose values are, in order, the - * out-of-bounds arguments {@code index} and {@code length}. - * - * @param the type of runtime exception to throw if the arguments are - * out-of-bounds - * @param index the index - * @param length the upper-bound (exclusive) of the range - * @param oobef the exception formatter that when applied with this - * method name and out-of-bounds arguments returns a runtime - * exception. If {@code null} or returns {@code null} then, it is as - * if an exception formatter produced from an invocation of - * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used - * instead (though it may be more efficient). - * Exceptions thrown by the formatter are relayed to the caller. - * @return {@code index} if it is within bounds of the range - * @throws X if the {@code index} is out-of-bounds and the exception - * formatter is non-{@code null} - * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds - * and the exception formatter is {@code null} - * @since 9 - * - * @implNote - * This method is made intrinsic in optimizing compilers to guide them to - * perform unsigned comparisons of the index and length when it is known the - * length is a non-negative value (such as that of an array length or from - * the upper bound of a loop) - */ - @HotSpotIntrinsicCandidate - public static - int checkIndex(int index, int length, - BiFunction, X> oobef) { - if (index < 0 || index >= length) - throw outOfBoundsCheckIndex(oobef, index, length); - return index; + return Preconditions.checkIndex(index, length, null); } /** @@ -608,12 +385,6 @@ public final class Objects { *

    • {@code length < 0}, which is implied from the former inequalities
    • * * - *

      This method behaves as if {@link #checkFromToIndex(int, int, int, BiFunction)} - * was called with same out-of-bounds arguments and an exception formatter - * argument produced from an invocation of - * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} (though it may - * be more efficient). - * * @param fromIndex the lower-bound (inclusive) of the sub-range * @param toIndex the upper-bound (exclusive) of the sub-range * @param length the upper-bound (exclusive) the range @@ -623,54 +394,7 @@ public final class Objects { */ public static int checkFromToIndex(int fromIndex, int toIndex, int length) { - return checkFromToIndex(fromIndex, toIndex, length, null); - } - - /** - * Checks if the sub-range from {@code fromIndex} (inclusive) to - * {@code toIndex} (exclusive) is within the bounds of range from {@code 0} - * (inclusive) to {@code length} (exclusive). - * - *

      The sub-range is defined to be out-of-bounds if any of the following - * inequalities is true: - *

        - *
      • {@code fromIndex < 0}
      • - *
      • {@code fromIndex > toIndex}
      • - *
      • {@code toIndex > length}
      • - *
      • {@code length < 0}, which is implied from the former inequalities
      • - *
      - * - *

      If the sub-range is out-of-bounds, then a runtime exception is - * thrown that is the result of applying the following arguments to the - * exception formatter: the name of this method, {@code checkFromToIndex}; - * and an unmodifiable list integers whose values are, in order, the - * out-of-bounds arguments {@code fromIndex}, {@code toIndex}, and {@code length}. - * - * @param the type of runtime exception to throw if the arguments are - * out-of-bounds - * @param fromIndex the lower-bound (inclusive) of the sub-range - * @param toIndex the upper-bound (exclusive) of the sub-range - * @param length the upper-bound (exclusive) the range - * @param oobef the exception formatter that when applied with this - * method name and out-of-bounds arguments returns a runtime - * exception. If {@code null} or returns {@code null} then, it is as - * if an exception formatter produced from an invocation of - * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used - * instead (though it may be more efficient). - * Exceptions thrown by the formatter are relayed to the caller. - * @return {@code fromIndex} if the sub-range within bounds of the range - * @throws X if the sub-range is out-of-bounds and the exception factory - * function is non-{@code null} - * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and - * the exception factory function is {@code null} - * @since 9 - */ - public static - int checkFromToIndex(int fromIndex, int toIndex, int length, - BiFunction, X> oobef) { - if (fromIndex < 0 || fromIndex > toIndex || toIndex > length) - throw outOfBoundsCheckFromToIndex(oobef, fromIndex, toIndex, length); - return fromIndex; + return Preconditions.checkFromToIndex(fromIndex, toIndex, length, null); } /** @@ -687,12 +411,6 @@ public final class Objects { *

    • {@code length < 0}, which is implied from the former inequalities
    • * * - *

      This method behaves as if {@link #checkFromIndexSize(int, int, int, BiFunction)} - * was called with same out-of-bounds arguments and an exception formatter - * argument produced from an invocation of - * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} (though it may - * be more efficient). - * * @param fromIndex the lower-bound (inclusive) of the sub-interval * @param size the size of the sub-range * @param length the upper-bound (exclusive) of the range @@ -702,54 +420,7 @@ public final class Objects { */ public static int checkFromIndexSize(int fromIndex, int size, int length) { - return checkFromIndexSize(fromIndex, size, length, null); + return Preconditions.checkFromIndexSize(fromIndex, size, length, null); } - /** - * Checks if the sub-range from {@code fromIndex} (inclusive) to - * {@code fromIndex + size} (exclusive) is within the bounds of range from - * {@code 0} (inclusive) to {@code length} (exclusive). - * - *

      The sub-range is defined to be out-of-bounds if any of the following - * inequalities is true: - *

        - *
      • {@code fromIndex < 0}
      • - *
      • {@code size < 0}
      • - *
      • {@code fromIndex + size > length}, taking into account integer overflow
      • - *
      • {@code length < 0}, which is implied from the former inequalities
      • - *
      - * - *

      If the sub-range is out-of-bounds, then a runtime exception is - * thrown that is the result of applying the following arguments to the - * exception formatter: the name of this method, {@code checkFromIndexSize}; - * and an unmodifiable list integers whose values are, in order, the - * out-of-bounds arguments {@code fromIndex}, {@code size}, and - * {@code length}. - * - * @param the type of runtime exception to throw if the arguments are - * out-of-bounds - * @param fromIndex the lower-bound (inclusive) of the sub-interval - * @param size the size of the sub-range - * @param length the upper-bound (exclusive) of the range - * @param oobef the exception formatter that when applied with this - * method name and out-of-bounds arguments returns a runtime - * exception. If {@code null} or returns {@code null} then, it is as - * if an exception formatter produced from an invocation of - * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used - * instead (though it may be more efficient). - * Exceptions thrown by the formatter are relayed to the caller. - * @return {@code fromIndex} if the sub-range within bounds of the range - * @throws X if the sub-range is out-of-bounds and the exception factory - * function is non-{@code null} - * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and - * the exception factory function is {@code null} - * @since 9 - */ - public static - int checkFromIndexSize(int fromIndex, int size, int length, - BiFunction, X> oobef) { - if ((length | fromIndex | size) < 0 || size > length - fromIndex) - throw outOfBoundsCheckFromIndexSize(oobef, fromIndex, size, length); - return fromIndex; - } } diff --git a/jdk/src/java.base/share/classes/jdk/internal/util/Preconditions.java b/jdk/src/java.base/share/classes/jdk/internal/util/Preconditions.java new file mode 100644 index 00000000000..cb1b748f620 --- /dev/null +++ b/jdk/src/java.base/share/classes/jdk/internal/util/Preconditions.java @@ -0,0 +1,346 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.internal.util; + +import jdk.internal.HotSpotIntrinsicCandidate; + +import java.util.List; +import java.util.function.BiFunction; +import java.util.function.Function; + +/** + * Utility methods to check if state or arguments are correct. + * + */ +public class Preconditions { + + /** + * Maps out-of-bounds values to a runtime exception. + * + * @param checkKind the kind of bounds check, whose name may correspond + * to the name of one of the range check methods, checkIndex, + * checkFromToIndex, checkFromIndexSize + * @param args the out-of-bounds arguments that failed the range check. + * If the checkKind corresponds a the name of a range check method + * then the bounds arguments are those that can be passed in order + * to the method. + * @param oobef the exception formatter that when applied with a checkKind + * and a list out-of-bounds arguments returns a runtime exception. + * If {@code null} then, it is as if an exception formatter was + * supplied that returns {@link IndexOutOfBoundsException} for any + * given arguments. + * @return the runtime exception + */ + private static RuntimeException outOfBounds( + BiFunction, ? extends RuntimeException> oobef, + String checkKind, + Integer... args) { + List largs = List.of(args); + RuntimeException e = oobef == null + ? null : oobef.apply(checkKind, largs); + return e == null + ? new IndexOutOfBoundsException(outOfBoundsMessage(checkKind, largs)) : e; + } + + private static RuntimeException outOfBoundsCheckIndex( + BiFunction, ? extends RuntimeException> oobe, + int index, int length) { + return outOfBounds(oobe, "checkIndex", index, length); + } + + private static RuntimeException outOfBoundsCheckFromToIndex( + BiFunction, ? extends RuntimeException> oobe, + int fromIndex, int toIndex, int length) { + return outOfBounds(oobe, "checkFromToIndex", fromIndex, toIndex, length); + } + + private static RuntimeException outOfBoundsCheckFromIndexSize( + BiFunction, ? extends RuntimeException> oobe, + int fromIndex, int size, int length) { + return outOfBounds(oobe, "checkFromIndexSize", fromIndex, size, length); + } + + /** + * Returns an out-of-bounds exception formatter from an given exception + * factory. The exception formatter is a function that formats an + * out-of-bounds message from its arguments and applies that message to the + * given exception factory to produce and relay an exception. + * + *

      The exception formatter accepts two arguments: a {@code String} + * describing the out-of-bounds range check that failed, referred to as the + * check kind; and a {@code List} containing the + * out-of-bound integer values that failed the check. The list of + * out-of-bound values is not modified. + * + *

      Three check kinds are supported {@code checkIndex}, + * {@code checkFromToIndex} and {@code checkFromIndexSize} corresponding + * respectively to the specified application of an exception formatter as an + * argument to the out-of-bounds range check methods + * {@link #checkIndex(int, int, BiFunction) checkIndex}, + * {@link #checkFromToIndex(int, int, int, BiFunction) checkFromToIndex}, and + * {@link #checkFromIndexSize(int, int, int, BiFunction) checkFromIndexSize}. + * Thus a supported check kind corresponds to a method name and the + * out-of-bound integer values correspond to method argument values, in + * order, preceding the exception formatter argument (similar in many + * respects to the form of arguments required for a reflective invocation of + * such a range check method). + * + *

      Formatter arguments conforming to such supported check kinds will + * produce specific exception messages describing failed out-of-bounds + * checks. Otherwise, more generic exception messages will be produced in + * any of the following cases: the check kind is supported but fewer + * or more out-of-bounds values are supplied, the check kind is not + * supported, the check kind is {@code null}, or the list of out-of-bound + * values is {@code null}. + * + * @apiNote + * This method produces an out-of-bounds exception formatter that can be + * passed as an argument to any of the supported out-of-bounds range check + * methods declared by {@code Objects}. For example, a formatter producing + * an {@code ArrayIndexOutOfBoundsException} may be produced and stored on a + * {@code static final} field as follows: + *

      {@code
      +     * static final
      +     * BiFunction, ArrayIndexOutOfBoundsException> AIOOBEF =
      +     *     outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new);
      +     * }
      + * The formatter instance {@code AIOOBEF} may be passed as an argument to an + * out-of-bounds range check method, such as checking if an {@code index} + * is within the bounds of a {@code limit}: + *
      {@code
      +     * checkIndex(index, limit, AIOOBEF);
      +     * }
      + * If the bounds check fails then the range check method will throw an + * {@code ArrayIndexOutOfBoundsException} with an appropriate exception + * message that is a produced from {@code AIOOBEF} as follows: + *
      {@code
      +     * AIOOBEF.apply("checkIndex", List.of(index, limit));
      +     * }
      + * + * @param f the exception factory, that produces an exception from a message + * where the message is produced and formatted by the returned + * exception formatter. If this factory is stateless and side-effect + * free then so is the returned formatter. + * Exceptions thrown by the factory are relayed to the caller + * of the returned formatter. + * @param the type of runtime exception to be returned by the given + * exception factory and relayed by the exception formatter + * @return the out-of-bounds exception formatter + */ + public static + BiFunction, X> outOfBoundsExceptionFormatter(Function f) { + // Use anonymous class to avoid bootstrap issues if this method is + // used early in startup + return new BiFunction, X>() { + @Override + public X apply(String checkKind, List args) { + return f.apply(outOfBoundsMessage(checkKind, args)); + } + }; + } + + private static String outOfBoundsMessage(String checkKind, List args) { + if (checkKind == null && args == null) { + return String.format("Range check failed"); + } else if (checkKind == null) { + return String.format("Range check failed: %s", args); + } else if (args == null) { + return String.format("Range check failed: %s", checkKind); + } + + int argSize = 0; + switch (checkKind) { + case "checkIndex": + argSize = 2; + break; + case "checkFromToIndex": + case "checkFromIndexSize": + argSize = 3; + break; + default: + } + + // Switch to default if fewer or more arguments than required are supplied + switch ((args.size() != argSize) ? "" : checkKind) { + case "checkIndex": + return String.format("Index %d out-of-bounds for length %d", + args.get(0), args.get(1)); + case "checkFromToIndex": + return String.format("Range [%d, %d) out-of-bounds for length %d", + args.get(0), args.get(1), args.get(2)); + case "checkFromIndexSize": + return String.format("Range [%d, %The {@code index} is defined to be out-of-bounds if any of the + * following inequalities is true: + *
        + *
      • {@code index < 0}
      • + *
      • {@code index >= length}
      • + *
      • {@code length < 0}, which is implied from the former inequalities
      • + *
      + * + *

      If the {@code index} is out-of-bounds, then a runtime exception is + * thrown that is the result of applying the following arguments to the + * exception formatter: the name of this method, {@code checkIndex}; + * and an unmodifiable list integers whose values are, in order, the + * out-of-bounds arguments {@code index} and {@code length}. + * + * @param the type of runtime exception to throw if the arguments are + * out-of-bounds + * @param index the index + * @param length the upper-bound (exclusive) of the range + * @param oobef the exception formatter that when applied with this + * method name and out-of-bounds arguments returns a runtime + * exception. If {@code null} or returns {@code null} then, it is as + * if an exception formatter produced from an invocation of + * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used + * instead (though it may be more efficient). + * Exceptions thrown by the formatter are relayed to the caller. + * @return {@code index} if it is within bounds of the range + * @throws X if the {@code index} is out-of-bounds and the exception + * formatter is non-{@code null} + * @throws IndexOutOfBoundsException if the {@code index} is out-of-bounds + * and the exception formatter is {@code null} + * @since 9 + * + * @implNote + * This method is made intrinsic in optimizing compilers to guide them to + * perform unsigned comparisons of the index and length when it is known the + * length is a non-negative value (such as that of an array length or from + * the upper bound of a loop) + */ + @HotSpotIntrinsicCandidate + public static + int checkIndex(int index, int length, + BiFunction, X> oobef) { + if (index < 0 || index >= length) + throw outOfBoundsCheckIndex(oobef, index, length); + return index; + } + + /** + * Checks if the sub-range from {@code fromIndex} (inclusive) to + * {@code toIndex} (exclusive) is within the bounds of range from {@code 0} + * (inclusive) to {@code length} (exclusive). + * + *

      The sub-range is defined to be out-of-bounds if any of the following + * inequalities is true: + *

        + *
      • {@code fromIndex < 0}
      • + *
      • {@code fromIndex > toIndex}
      • + *
      • {@code toIndex > length}
      • + *
      • {@code length < 0}, which is implied from the former inequalities
      • + *
      + * + *

      If the sub-range is out-of-bounds, then a runtime exception is + * thrown that is the result of applying the following arguments to the + * exception formatter: the name of this method, {@code checkFromToIndex}; + * and an unmodifiable list integers whose values are, in order, the + * out-of-bounds arguments {@code fromIndex}, {@code toIndex}, and {@code length}. + * + * @param the type of runtime exception to throw if the arguments are + * out-of-bounds + * @param fromIndex the lower-bound (inclusive) of the sub-range + * @param toIndex the upper-bound (exclusive) of the sub-range + * @param length the upper-bound (exclusive) the range + * @param oobef the exception formatter that when applied with this + * method name and out-of-bounds arguments returns a runtime + * exception. If {@code null} or returns {@code null} then, it is as + * if an exception formatter produced from an invocation of + * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used + * instead (though it may be more efficient). + * Exceptions thrown by the formatter are relayed to the caller. + * @return {@code fromIndex} if the sub-range within bounds of the range + * @throws X if the sub-range is out-of-bounds and the exception factory + * function is non-{@code null} + * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and + * the exception factory function is {@code null} + * @since 9 + */ + public static + int checkFromToIndex(int fromIndex, int toIndex, int length, + BiFunction, X> oobef) { + if (fromIndex < 0 || fromIndex > toIndex || toIndex > length) + throw outOfBoundsCheckFromToIndex(oobef, fromIndex, toIndex, length); + return fromIndex; + } + + /** + * Checks if the sub-range from {@code fromIndex} (inclusive) to + * {@code fromIndex + size} (exclusive) is within the bounds of range from + * {@code 0} (inclusive) to {@code length} (exclusive). + * + *

      The sub-range is defined to be out-of-bounds if any of the following + * inequalities is true: + *

        + *
      • {@code fromIndex < 0}
      • + *
      • {@code size < 0}
      • + *
      • {@code fromIndex + size > length}, taking into account integer overflow
      • + *
      • {@code length < 0}, which is implied from the former inequalities
      • + *
      + * + *

      If the sub-range is out-of-bounds, then a runtime exception is + * thrown that is the result of applying the following arguments to the + * exception formatter: the name of this method, {@code checkFromIndexSize}; + * and an unmodifiable list integers whose values are, in order, the + * out-of-bounds arguments {@code fromIndex}, {@code size}, and + * {@code length}. + * + * @param the type of runtime exception to throw if the arguments are + * out-of-bounds + * @param fromIndex the lower-bound (inclusive) of the sub-interval + * @param size the size of the sub-range + * @param length the upper-bound (exclusive) of the range + * @param oobef the exception formatter that when applied with this + * method name and out-of-bounds arguments returns a runtime + * exception. If {@code null} or returns {@code null} then, it is as + * if an exception formatter produced from an invocation of + * {@code outOfBoundsExceptionFormatter(IndexOutOfBounds::new)} is used + * instead (though it may be more efficient). + * Exceptions thrown by the formatter are relayed to the caller. + * @return {@code fromIndex} if the sub-range within bounds of the range + * @throws X if the sub-range is out-of-bounds and the exception factory + * function is non-{@code null} + * @throws IndexOutOfBoundsException if the sub-range is out-of-bounds and + * the exception factory function is {@code null} + * @since 9 + */ + public static + int checkFromIndexSize(int fromIndex, int size, int length, + BiFunction, X> oobef) { + if ((length | fromIndex | size) < 0 || size > length - fromIndex) + throw outOfBoundsCheckFromIndexSize(oobef, fromIndex, size, length); + return fromIndex; + } +} diff --git a/jdk/test/java/util/Objects/CheckIndex.java b/jdk/test/java/util/Objects/CheckIndex.java index c4efdb1c253..bcfa1d5b23d 100644 --- a/jdk/test/java/util/Objects/CheckIndex.java +++ b/jdk/test/java/util/Objects/CheckIndex.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,11 +23,13 @@ /** * @test - * @summary IndexOutOfBoundsException check index tests + * @summary Objects.checkIndex/jdk.internal.util.Preconditions.checkIndex tests * @run testng CheckIndex - * @bug 8135248 8142493 + * @bug 8135248 8142493 8155794 + * @modules java.base/jdk.internal.util */ +import jdk.internal.util.Preconditions; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -95,7 +97,7 @@ public class CheckIndex { public void testCheckIndex(int index, int length, boolean withinBounds) { String expectedMessage = withinBounds ? null - : Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new). + : Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new). apply("checkIndex", List.of(index, length)).getMessage(); BiConsumer, IntSupplier> checker = (ec, s) -> { @@ -117,21 +119,21 @@ public class CheckIndex { }; checker.accept(AssertingOutOfBoundsException.class, - () -> Objects.checkIndex(index, length, - assertingOutOfBounds(expectedMessage, "checkIndex", index, length))); + () -> Preconditions.checkIndex(index, length, + assertingOutOfBounds(expectedMessage, "checkIndex", index, length))); checker.accept(IndexOutOfBoundsException.class, - () -> Objects.checkIndex(index, length, - assertingOutOfBoundsReturnNull("checkIndex", index, length))); + () -> Preconditions.checkIndex(index, length, + assertingOutOfBoundsReturnNull("checkIndex", index, length))); checker.accept(IndexOutOfBoundsException.class, - () -> Objects.checkIndex(index, length, null)); + () -> Preconditions.checkIndex(index, length, null)); checker.accept(IndexOutOfBoundsException.class, () -> Objects.checkIndex(index, length)); checker.accept(ArrayIndexOutOfBoundsException.class, - () -> Objects.checkIndex(index, length, - Objects.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new))); + () -> Preconditions.checkIndex(index, length, + Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new))); checker.accept(StringIndexOutOfBoundsException.class, - () -> Objects.checkIndex(index, length, - Objects.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new))); + () -> Preconditions.checkIndex(index, length, + Preconditions.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new))); } @@ -157,7 +159,7 @@ public class CheckIndex { public void testCheckFromToIndex(int fromIndex, int toIndex, int length, boolean withinBounds) { String expectedMessage = withinBounds ? null - : Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new). + : Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new). apply("checkFromToIndex", List.of(fromIndex, toIndex, length)).getMessage(); BiConsumer, IntSupplier> check = (ec, s) -> { @@ -179,21 +181,21 @@ public class CheckIndex { }; check.accept(AssertingOutOfBoundsException.class, - () -> Objects.checkFromToIndex(fromIndex, toIndex, length, - assertingOutOfBounds(expectedMessage, "checkFromToIndex", fromIndex, toIndex, length))); + () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length, + assertingOutOfBounds(expectedMessage, "checkFromToIndex", fromIndex, toIndex, length))); check.accept(IndexOutOfBoundsException.class, - () -> Objects.checkFromToIndex(fromIndex, toIndex, length, - assertingOutOfBoundsReturnNull("checkFromToIndex", fromIndex, toIndex, length))); + () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length, + assertingOutOfBoundsReturnNull("checkFromToIndex", fromIndex, toIndex, length))); check.accept(IndexOutOfBoundsException.class, - () -> Objects.checkFromToIndex(fromIndex, toIndex, length, null)); + () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length, null)); check.accept(IndexOutOfBoundsException.class, () -> Objects.checkFromToIndex(fromIndex, toIndex, length)); check.accept(ArrayIndexOutOfBoundsException.class, - () -> Objects.checkFromToIndex(fromIndex, toIndex, length, - Objects.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new))); + () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length, + Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new))); check.accept(StringIndexOutOfBoundsException.class, - () -> Objects.checkFromToIndex(fromIndex, toIndex, length, - Objects.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new))); + () -> Preconditions.checkFromToIndex(fromIndex, toIndex, length, + Preconditions.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new))); } @@ -226,7 +228,7 @@ public class CheckIndex { public void testCheckFromIndexSize(int fromIndex, int size, int length, boolean withinBounds) { String expectedMessage = withinBounds ? null - : Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new). + : Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new). apply("checkFromIndexSize", List.of(fromIndex, size, length)).getMessage(); BiConsumer, IntSupplier> check = (ec, s) -> { @@ -248,27 +250,27 @@ public class CheckIndex { }; check.accept(AssertingOutOfBoundsException.class, - () -> Objects.checkFromIndexSize(fromIndex, size, length, - assertingOutOfBounds(expectedMessage, "checkFromIndexSize", fromIndex, size, length))); + () -> Preconditions.checkFromIndexSize(fromIndex, size, length, + assertingOutOfBounds(expectedMessage, "checkFromIndexSize", fromIndex, size, length))); check.accept(IndexOutOfBoundsException.class, - () -> Objects.checkFromIndexSize(fromIndex, size, length, - assertingOutOfBoundsReturnNull("checkFromIndexSize", fromIndex, size, length))); + () -> Preconditions.checkFromIndexSize(fromIndex, size, length, + assertingOutOfBoundsReturnNull("checkFromIndexSize", fromIndex, size, length))); check.accept(IndexOutOfBoundsException.class, - () -> Objects.checkFromIndexSize(fromIndex, size, length, null)); + () -> Preconditions.checkFromIndexSize(fromIndex, size, length, null)); check.accept(IndexOutOfBoundsException.class, () -> Objects.checkFromIndexSize(fromIndex, size, length)); check.accept(ArrayIndexOutOfBoundsException.class, - () -> Objects.checkFromIndexSize(fromIndex, size, length, - Objects.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new))); + () -> Preconditions.checkFromIndexSize(fromIndex, size, length, + Preconditions.outOfBoundsExceptionFormatter(ArrayIndexOutOfBoundsException::new))); check.accept(StringIndexOutOfBoundsException.class, - () -> Objects.checkFromIndexSize(fromIndex, size, length, - Objects.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new))); + () -> Preconditions.checkFromIndexSize(fromIndex, size, length, + Preconditions.outOfBoundsExceptionFormatter(StringIndexOutOfBoundsException::new))); } @Test public void uniqueMessagesForCheckKinds() { BiFunction, IndexOutOfBoundsException> f = - Objects.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new); + Preconditions.outOfBoundsExceptionFormatter(IndexOutOfBoundsException::new); List messages = new ArrayList<>(); // Exact arguments -- GitLab From 096e59e6c9d39e1704fb182a61c5debe748cc3e5 Mon Sep 17 00:00:00 2001 From: Sharath Ballal Date: Fri, 6 May 2016 11:47:45 +0300 Subject: [PATCH 034/400] 8154144: Tests in com/sun/jdi fails intermittently with "jdb input stream closed prematurely" Don't print stream closed message during shutdown Reviewed-by: dcubed, sla, dsamersoff --- .../tools/example/debug/tty/EventHandler.java | 6 +++++- .../com/sun/tools/example/debug/tty/TTY.java | 20 +++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/EventHandler.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/EventHandler.java index fe6dd070f0d..cd416ccf24e 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/EventHandler.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/EventHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -133,6 +133,10 @@ public class EventHandler implements Runnable { if (!vmDied) { vmDisconnectEvent(event); } + /* + * Inform jdb command line processor that jdb is being shutdown. JDK-8154144. + */ + ((TTY)notifier).setShuttingDown(true); Env.shutdown(shutdownMessageKey); return false; } else { diff --git a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java index 0bd403af2b9..ee716a55dcb 100644 --- a/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java +++ b/jdk/src/jdk.jdi/share/classes/com/sun/tools/example/debug/tty/TTY.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,6 +56,16 @@ public class TTY implements EventNotifier { */ private static final String progname = "jdb"; + private volatile boolean shuttingDown = false; + + public void setShuttingDown(boolean s) { + shuttingDown = s; + } + + public boolean isShuttingDown() { + return shuttingDown; + } + @Override public void vmStartEvent(VMStartEvent se) { Thread.yield(); // fetch output @@ -750,7 +760,13 @@ public class TTY implements EventNotifier { while (true) { String ln = in.readLine(); if (ln == null) { - MessageOutput.println("Input stream closed."); + /* + * Jdb is being shutdown because debuggee exited, ignore any 'null' + * returned by readLine() during shutdown. JDK-8154144. + */ + if (!isShuttingDown()) { + MessageOutput.println("Input stream closed."); + } ln = "quit"; } -- GitLab From 85f537701c959dd32065f8e33a31999022dfbe5c Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 6 May 2016 17:59:49 +0300 Subject: [PATCH 035/400] 8155965: Unsafe.weakCompareAndSetVolatile entry points and intrinsics Reviewed-by: psandoz, vlivanov --- .../classes/jdk/internal/misc/Unsafe.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java index beb64fd5155..fbd994da432 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java @@ -1271,6 +1271,13 @@ public final class Unsafe { return compareAndSwapObject(o, offset, expected, x); } + @HotSpotIntrinsicCandidate + public final boolean weakCompareAndSwapObjectVolatile(Object o, long offset, + Object expected, + Object x) { + return compareAndSwapObject(o, offset, expected, x); + } + /** * Atomically updates Java variable to {@code x} if it is currently * holding {@code expected}. @@ -1325,6 +1332,13 @@ public final class Unsafe { return compareAndSwapInt(o, offset, expected, x); } + @HotSpotIntrinsicCandidate + public final boolean weakCompareAndSwapIntVolatile(Object o, long offset, + int expected, + int x) { + return compareAndSwapInt(o, offset, expected, x); + } + /** * Atomically updates Java variable to {@code x} if it is currently * holding {@code expected}. @@ -1379,6 +1393,13 @@ public final class Unsafe { return compareAndSwapLong(o, offset, expected, x); } + @HotSpotIntrinsicCandidate + public final boolean weakCompareAndSwapLongVolatile(Object o, long offset, + long expected, + long x) { + return compareAndSwapLong(o, offset, expected, x); + } + /** * Fetches a reference value from a given Java variable, with volatile * load semantics. Otherwise identical to {@link #getObject(Object, long)} -- GitLab From 2b1fdef17a5fffe8ce0076a5e2d1b0e70aafd3ae Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Fri, 6 May 2016 15:59:27 -0700 Subject: [PATCH 036/400] 8150921: Update Unsafe getters/setters to use double-register variants Reviewed-by: dholmes, shade, psandoz, jrose --- .../classes/jdk/internal/misc/Unsafe.java | 191 +++++++++++++----- 1 file changed, 135 insertions(+), 56 deletions(-) diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java index 735d1b86143..c7ee6a2f44f 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/Unsafe.java @@ -33,6 +33,7 @@ import jdk.internal.reflect.Reflection; import jdk.internal.misc.VM; import jdk.internal.HotSpotIntrinsicCandidate; +import jdk.internal.vm.annotation.ForceInline; /** @@ -209,46 +210,103 @@ public final class Unsafe { /** @see #getInt(Object, long) */ @HotSpotIntrinsicCandidate public native boolean getBoolean(Object o, long offset); + /** @see #putInt(Object, long, int) */ @HotSpotIntrinsicCandidate public native void putBoolean(Object o, long offset, boolean x); + /** @see #getInt(Object, long) */ @HotSpotIntrinsicCandidate public native byte getByte(Object o, long offset); + /** @see #putInt(Object, long, int) */ @HotSpotIntrinsicCandidate public native void putByte(Object o, long offset, byte x); + /** @see #getInt(Object, long) */ @HotSpotIntrinsicCandidate public native short getShort(Object o, long offset); + /** @see #putInt(Object, long, int) */ @HotSpotIntrinsicCandidate public native void putShort(Object o, long offset, short x); + /** @see #getInt(Object, long) */ @HotSpotIntrinsicCandidate public native char getChar(Object o, long offset); + /** @see #putInt(Object, long, int) */ @HotSpotIntrinsicCandidate public native void putChar(Object o, long offset, char x); + /** @see #getInt(Object, long) */ @HotSpotIntrinsicCandidate public native long getLong(Object o, long offset); + /** @see #putInt(Object, long, int) */ @HotSpotIntrinsicCandidate public native void putLong(Object o, long offset, long x); + /** @see #getInt(Object, long) */ @HotSpotIntrinsicCandidate public native float getFloat(Object o, long offset); + /** @see #putInt(Object, long, int) */ @HotSpotIntrinsicCandidate public native void putFloat(Object o, long offset, float x); + /** @see #getInt(Object, long) */ @HotSpotIntrinsicCandidate public native double getDouble(Object o, long offset); + /** @see #putInt(Object, long, int) */ @HotSpotIntrinsicCandidate public native void putDouble(Object o, long offset, double x); + /** + * Fetches a native pointer from a given memory address. If the address is + * zero, or does not point into a block obtained from {@link + * #allocateMemory}, the results are undefined. + * + *

      If the native pointer is less than 64 bits wide, it is extended as + * an unsigned number to a Java long. The pointer may be indexed by any + * given byte offset, simply by adding that offset (as a simple integer) to + * the long representing the pointer. The number of bytes actually read + * from the target address may be determined by consulting {@link + * #addressSize}. + * + * @see #allocateMemory + * @see #getInt(Object, long) + */ + @ForceInline + public long getAddress(Object o, long offset) { + if (ADDRESS_SIZE == 4) { + return Integer.toUnsignedLong(getInt(o, offset)); + } else { + return getLong(o, offset); + } + } + + /** + * Stores a native pointer into a given memory address. If the address is + * zero, or does not point into a block obtained from {@link + * #allocateMemory}, the results are undefined. + * + *

      The number of bytes actually written at the target address may be + * determined by consulting {@link #addressSize}. + * + * @see #allocateMemory + * @see #putInt(Object, long, int) + */ + @ForceInline + public void putAddress(Object o, long offset, long x) { + if (ADDRESS_SIZE == 4) { + putInt(o, offset, (int)x); + } else { + putLong(o, offset, x); + } + } + // These read VM internal data. /** @@ -287,8 +345,10 @@ public final class Unsafe { * * @see #allocateMemory */ - @HotSpotIntrinsicCandidate - public native byte getByte(long address); + @ForceInline + public byte getByte(long address) { + return getByte(null, address); + } /** * Stores a value into a given memory address. If the address is zero, or @@ -297,75 +357,94 @@ public final class Unsafe { * * @see #getByte(long) */ - @HotSpotIntrinsicCandidate - public native void putByte(long address, byte x); + @ForceInline + public void putByte(long address, byte x) { + putByte(null, address, x); + } /** @see #getByte(long) */ - @HotSpotIntrinsicCandidate - public native short getShort(long address); + @ForceInline + public short getShort(long address) { + return getShort(null, address); + } + /** @see #putByte(long, byte) */ - @HotSpotIntrinsicCandidate - public native void putShort(long address, short x); + @ForceInline + public void putShort(long address, short x) { + putShort(null, address, x); + } + /** @see #getByte(long) */ - @HotSpotIntrinsicCandidate - public native char getChar(long address); + @ForceInline + public char getChar(long address) { + return getChar(null, address); + } + /** @see #putByte(long, byte) */ - @HotSpotIntrinsicCandidate - public native void putChar(long address, char x); + @ForceInline + public void putChar(long address, char x) { + putChar(null, address, x); + } + /** @see #getByte(long) */ - @HotSpotIntrinsicCandidate - public native int getInt(long address); + @ForceInline + public int getInt(long address) { + return getInt(null, address); + } + /** @see #putByte(long, byte) */ - @HotSpotIntrinsicCandidate - public native void putInt(long address, int x); + @ForceInline + public void putInt(long address, int x) { + putInt(null, address, x); + } + /** @see #getByte(long) */ - @HotSpotIntrinsicCandidate - public native long getLong(long address); + @ForceInline + public long getLong(long address) { + return getLong(null, address); + } + /** @see #putByte(long, byte) */ - @HotSpotIntrinsicCandidate - public native void putLong(long address, long x); + @ForceInline + public void putLong(long address, long x) { + putLong(null, address, x); + } + /** @see #getByte(long) */ - @HotSpotIntrinsicCandidate - public native float getFloat(long address); + @ForceInline + public float getFloat(long address) { + return getFloat(null, address); + } + /** @see #putByte(long, byte) */ - @HotSpotIntrinsicCandidate - public native void putFloat(long address, float x); + @ForceInline + public void putFloat(long address, float x) { + putFloat(null, address, x); + } + /** @see #getByte(long) */ - @HotSpotIntrinsicCandidate - public native double getDouble(long address); + @ForceInline + public double getDouble(long address) { + return getDouble(null, address); + } + /** @see #putByte(long, byte) */ - @HotSpotIntrinsicCandidate - public native void putDouble(long address, double x); + @ForceInline + public void putDouble(long address, double x) { + putDouble(null, address, x); + } - /** - * Fetches a native pointer from a given memory address. If the address is - * zero, or does not point into a block obtained from {@link - * #allocateMemory}, the results are undefined. - * - *

      If the native pointer is less than 64 bits wide, it is extended as - * an unsigned number to a Java long. The pointer may be indexed by any - * given byte offset, simply by adding that offset (as a simple integer) to - * the long representing the pointer. The number of bytes actually read - * from the target address may be determined by consulting {@link - * #addressSize}. - * - * @see #allocateMemory - */ - @HotSpotIntrinsicCandidate - public native long getAddress(long address); + /** @see #getAddress(Object, long) */ + @ForceInline + public long getAddress(long address) { + return getAddress(null, address); + } - /** - * Stores a native pointer into a given memory address. If the address is - * zero, or does not point into a block obtained from {@link - * #allocateMemory}, the results are undefined. - * - *

      The number of bytes actually written at the target address may be - * determined by consulting {@link #addressSize}. - * - * @see #getAddress(long) - */ - @HotSpotIntrinsicCandidate - public native void putAddress(long address, long x); + /** @see #putAddress(Object, long, long) */ + @ForceInline + public void putAddress(long address, long x) { + putAddress(null, address, x); + } -- GitLab From 529e4623639ff721a272e19b01191fb606abfac9 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Sat, 7 May 2016 10:32:56 +0900 Subject: [PATCH 037/400] 8156033: jhsdb jmap cannot set heapdump name Reviewed-by: dsamersoff --- .../sun/tools/jhsdb/BasicLauncherTest.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java index afba30c6055..b0f3b8d4f73 100644 --- a/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java +++ b/jdk/test/sun/tools/jhsdb/BasicLauncherTest.java @@ -31,9 +31,12 @@ * @run main BasicLauncherTest */ +import static jdk.testlibrary.Asserts.assertTrue; + import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Arrays; @@ -99,7 +102,7 @@ public class BasicLauncherTest { System.out.println("Starting LingeredApp"); try { - theApp = LingeredApp.startApp(); + theApp = LingeredApp.startApp(Arrays.asList("-Xmx256m")); System.out.println("Starting " + toolName + " " + toolArgs.get(0) + " against " + theApp.getPid()); JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK(toolName); @@ -129,6 +132,21 @@ public class BasicLauncherTest { launch(expectedMessage, Arrays.asList(toolArgs)); } + public static void testHeapDump() throws IOException { + File dump = new File("jhsdb.jmap.dump." + + System.currentTimeMillis() + ".hprof"); + if (dump.exists()) { + dump.delete(); + } + dump.deleteOnExit(); + + launch("heap written to", "jmap", + "--binaryheap", "--dumpfile=" + dump.getAbsolutePath()); + + assertTrue(dump.exists() && dump.isFile(), + "Could not create dump file " + dump.getAbsolutePath()); + } + public static void main(String[] args) throws IOException { @@ -145,6 +163,8 @@ public class BasicLauncherTest { launch("Java System Properties", "jinfo"); launch("java.threads", "jsnap"); + testHeapDump(); + // The test throws RuntimeException on error. // IOException is thrown if LingeredApp can't start because of some bad // environment condition -- GitLab From ae4d032d4143fd7b7bef4af7a8b7a75976f37707 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Mon, 9 May 2016 23:41:59 +0300 Subject: [PATCH 038/400] 8155091: Remove SA related functions from tmtools Remove options that enables support for non-cooperative mode Reviewed-by: alanb, mchung, sla --- .../tools/attach/HotSpotVirtualMachine.java | 2 +- .../internal/vm/agent/spi/ToolProvider.java | 42 -- .../vm/agent/spi/ToolProviderFinder.java | 46 --- .../jdk.jcmd/share/classes/module-info.java | 5 - .../share/classes/sun/tools/jinfo/JInfo.java | 258 +++++------- .../share/classes/sun/tools/jmap/JMap.java | 371 ++++++------------ .../classes/sun/tools/jstack/JStack.java | 144 +++---- .../heapconfig/JMapHeapConfigTest.java | 4 +- .../heapconfig/TmtoolTestScenario.java | 4 +- .../{JInfoHelper.java => BasicJInfoTest.java} | 67 ++-- .../sun/tools/jinfo/JInfoLauncherTest.java | 343 ---------------- .../jinfo/JInfoRunningProcessFlagTest.java | 129 ------ .../tools/jinfo/JInfoRunningProcessTest.java | 65 --- jdk/test/sun/tools/jinfo/JInfoSanityTest.java | 77 ---- jdk/test/sun/tools/jmap/BasicJMapTest.java | 17 +- .../sun/tools/jstack/BasicJStackTest.java | 2 - .../tools/jstack/DeadlockDetectionTest.java | 1 - 17 files changed, 317 insertions(+), 1260 deletions(-) delete mode 100644 jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProvider.java delete mode 100644 jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProviderFinder.java rename jdk/test/sun/tools/{jmap => jhsdb}/heapconfig/JMapHeapConfigTest.java (98%) rename jdk/test/sun/tools/{jmap => jhsdb}/heapconfig/TmtoolTestScenario.java (97%) rename jdk/test/sun/tools/jinfo/{JInfoHelper.java => BasicJInfoTest.java} (51%) delete mode 100644 jdk/test/sun/tools/jinfo/JInfoLauncherTest.java delete mode 100644 jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java delete mode 100644 jdk/test/sun/tools/jinfo/JInfoRunningProcessTest.java delete mode 100644 jdk/test/sun/tools/jinfo/JInfoSanityTest.java diff --git a/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java b/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java index 4a9562b069f..a5e965e5ec3 100644 --- a/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java +++ b/jdk/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java @@ -258,7 +258,7 @@ public abstract class HotSpotVirtualMachine extends VirtualMachine { /* * Convenience method for simple commands */ - private InputStream executeCommand(String cmd, Object ... args) throws IOException { + public InputStream executeCommand(String cmd, Object ... args) throws IOException { try { return execute(cmd, args); } catch (AgentLoadException x) { diff --git a/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProvider.java b/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProvider.java deleted file mode 100644 index 55be308348a..00000000000 --- a/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProvider.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.internal.vm.agent.spi; - -/** - * Service interface for jdk.hotspot.agent to provide the tools that - * jstack, jmap, jinfo will invoke, if present. - */ -public interface ToolProvider { - /** - * Returns the name of the tool provider - */ - String getName(); - - /** - * Invoke the tool provider with the given arguments - */ - void run(String... arguments); -} diff --git a/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProviderFinder.java b/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProviderFinder.java deleted file mode 100644 index b96e6ae6239..00000000000 --- a/jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProviderFinder.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.internal.vm.agent.spi; - -import java.lang.reflect.Layer; -import java.util.HashMap; -import java.util.Map; -import java.util.ServiceLoader; - -public final class ToolProviderFinder { - private static final Map providers = init(); - - public static ToolProvider find(String name) { - return providers.get(name); - } - - private static Map init() { - Map providers = new HashMap<>(); - ServiceLoader.load(Layer.boot(), ToolProvider.class) - .forEach(p -> providers.putIfAbsent(p.getName(), p)); - return providers; - } -} diff --git a/jdk/src/jdk.jcmd/share/classes/module-info.java b/jdk/src/jdk.jcmd/share/classes/module-info.java index 4b8dbce1304..c78803b774c 100644 --- a/jdk/src/jdk.jcmd/share/classes/module-info.java +++ b/jdk/src/jdk.jcmd/share/classes/module-info.java @@ -26,9 +26,4 @@ module jdk.jcmd { requires jdk.attach; requires jdk.jvmstat; - - exports jdk.internal.vm.agent.spi to jdk.hotspot.agent; - - uses jdk.internal.vm.agent.spi.ToolProvider; } - diff --git a/jdk/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java b/jdk/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java index f19b6d159f0..dbfbaf2e25b 100644 --- a/jdk/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java +++ b/jdk/src/jdk.jcmd/share/classes/sun/tools/jinfo/JInfo.java @@ -32,8 +32,6 @@ import java.io.InputStream; import com.sun.tools.attach.VirtualMachine; import sun.tools.attach.HotSpotVirtualMachine; -import jdk.internal.vm.agent.spi.ToolProvider; -import jdk.internal.vm.agent.spi.ToolProviderFinder; /* * This class is the main class for the JInfo utility. It parses its arguments @@ -41,155 +39,73 @@ import jdk.internal.vm.agent.spi.ToolProviderFinder; * or an SA tool. */ final public class JInfo { - private static final String SA_JINFO_TOOL_NAME = "jinfo"; - private boolean useSA = false; - private String[] args = null; - private JInfo(String[] args) throws IllegalArgumentException { + public static void main(String[] args) throws Exception { if (args.length == 0) { - throw new IllegalArgumentException(); + usage(1); // no arguments } - - int argCopyIndex = 0; - // First determine if we should launch SA or not - if (args[0].equals("-F")) { - // delete the -F - argCopyIndex = 1; - useSA = true; - } else if (args[0].equals("-flags") - || args[0].equals("-sysprops")) - { - if (args.length == 2) { - if (!isPid(args[1])) { - // If args[1] doesn't parse to a number then - // it must be the SA debug server - // (otherwise it is the pid) - useSA = true; - } - } else if (args.length == 3) { - // arguments include an executable and a core file - useSA = true; - } else { - throw new IllegalArgumentException(); - } - } else if (!args[0].startsWith("-")) { - if (args.length == 2) { - // the only arguments are an executable and a core file - useSA = true; - } else if (args.length == 1) { - if (!isPid(args[0])) { - // The only argument is not a PID; it must be SA debug - // server - useSA = true; - } - } else { - throw new IllegalArgumentException(); - } - } else if (args[0].equals("-h") || args[0].equals("-help")) { - if (args.length > 1) { - throw new IllegalArgumentException(); - } - } else if (args[0].equals("-flag")) { - if (args.length == 3) { - if (!isPid(args[2])) { - throw new IllegalArgumentException(); - } - } else { - throw new IllegalArgumentException(); + checkForUnsupportedOptions(args); + + boolean doFlag = false; + boolean doFlags = false; + boolean doSysprops = false; + + // Parse the options (arguments starting with "-" ) + int optionCount = 0; + while (optionCount < args.length) { + String arg = args[optionCount]; + if (!arg.startsWith("-")) { + break; } - } else { - throw new IllegalArgumentException(); - } - - this.args = Arrays.copyOfRange(args, argCopyIndex, args.length); - } - @SuppressWarnings("fallthrough") - private void execute() throws Exception { - if (args[0].equals("-h") - || args[0].equals("-help")) { - usage(0); - } + optionCount++; - if (useSA) { - // SA only supports -flags or -sysprops - if (args[0].startsWith("-")) { - if (!(args[0].equals("-flags") || args[0].equals("-sysprops"))) { - usage(1); - } + if (arg.equals("-help") || arg.equals("-h")) { + usage(0); } - // invoke SA which does it's own argument parsing - runTool(); + if (arg.equals("-flag")) { + doFlag = true; + continue; + } - } else { - // Now we can parse arguments for the non-SA case - String pid = null; + if (arg.equals("-flags")) { + doFlags = true; + continue; + } - switch(args[0]) { - case "-flag": - if (args.length != 3) { - usage(1); - } - String option = args[1]; - pid = args[2]; - flag(pid, option); - break; - case "-flags": - if (args.length != 2) { - usage(1); - } - pid = args[1]; - flags(pid); - break; - case "-sysprops": - if (args.length != 2) { - usage(1); - } - pid = args[1]; - sysprops(pid); - break; - case "-help": - case "-h": - usage(0); - // Fall through - default: - if (args.length == 1) { - // no flags specified, we do -sysprops and -flags - pid = args[0]; - sysprops(pid); - System.out.println(); - flags(pid); - System.out.println(); - commandLine(pid); - } else { - usage(1); - } + if (arg.equals("-sysprops")) { + doSysprops = true; + continue; } } - } - public static void main(String[] args) throws Exception { - JInfo jinfo = null; - try { - jinfo = new JInfo(args); - jinfo.execute(); - } catch (IllegalArgumentException e) { + // Next we check the parameter count. -flag allows extra parameters + int paramCount = args.length - optionCount; + if ((doFlag && paramCount != 2) || (paramCount != 1)) { usage(1); } - } - private static boolean isPid(String arg) { - return arg.matches("[0-9]+"); - } + if (!doFlag && !doFlags && !doSysprops) { + // Print flags and sysporps if no options given + sysprops(args[optionCount]); + System.out.println(); + flags(args[optionCount]); + System.out.println(); + commandLine(args[optionCount]); + } - // Invoke SA tool with the given arguments - private void runTool() throws Exception { - ToolProvider tool = ToolProviderFinder.find(SA_JINFO_TOOL_NAME); - if (tool == null) { - usage(1); + if (doFlag) { + flag(args[optionCount+1], args[optionCount]); + } + else { + if (doFlags) { + flags(args[optionCount]); + } + else if (doSysprops) { + sysprops(args[optionCount]); + } } - tool.run(args); } private static void flag(String pid, String option) throws IOException { @@ -274,46 +190,50 @@ final public class JInfo { vm.detach(); } + private static void checkForUnsupportedOptions(String[] args) { + // Check arguments for -F, and non-numeric value + // and warn the user that SA is not supported anymore - // print usage message - private static void usage(int exit) { - boolean usageSA = ToolProviderFinder.find(SA_JINFO_TOOL_NAME) != null; + int paramCount = 0; - System.err.println("Usage:"); - if (usageSA) { - System.err.println(" jinfo [option] "); - System.err.println(" (to connect to a running process)"); - System.err.println(" jinfo -F [option] "); - System.err.println(" (to connect to a hung process)"); - System.err.println(" jinfo [option] "); - System.err.println(" (to connect to a core file)"); - System.err.println(" jinfo [option] [server_id@]"); - System.err.println(" (to connect to remote debug server)"); - System.err.println(""); - System.err.println("where

        + *
      • For jimage content: /{module name}/{package1}/.../{packageN}/{file + * name}
      • + *
      • For other files (shared lib, launchers, config, ...):/{module name}/ + * {@literal bin|conf|native}/{dir1}>/.../{dirN}/{file name}
      • + *
      + */ +public class ModuleEntryImpl implements ModuleEntry { + + private final Type type; + private final String path; + private final String module; + private final long length; + private final InputStream stream; + private byte[] buffer; + + /** + * Create a new LinkModuleEntry. + * + * @param module The module name. + * @param path The data path identifier. + * @param type The data type. + * @param stream The data content stream. + * @param length The stream length. + */ + public ModuleEntryImpl(String module, String path, Type type, InputStream stream, long length) { + Objects.requireNonNull(module); + Objects.requireNonNull(path); + Objects.requireNonNull(type); + Objects.requireNonNull(stream); + this.path = path; + this.type = type; + this.module = module; + this.stream = stream; + this.length = length; + } + + /** + * The LinkModuleEntry module name. + * + * @return The module name. + */ + @Override + public final String getModule() { + return module; + } + + /** + * The LinkModuleEntry path. + * + * @return The module path. + */ + @Override + public final String getPath() { + return path; + } + + /** + * The LinkModuleEntry's type. + * + * @return The data type. + */ + @Override + public final Type getType() { + return type; + } + + /** + * The LinkModuleEntry content as an array of byte. + * + * @return An Array of bytes. + */ + @Override + public byte[] getBytes() { + if (buffer == null) { + try (InputStream is = stream) { + buffer = is.readAllBytes(); + } catch (IOException ex) { + throw new UncheckedIOException(ex); + } + } + return buffer; + } + + /** + * The LinkModuleEntry content length. + * + * @return The length. + */ + @Override + public long getLength() { + return length; + } + + /** + * The LinkModuleEntry stream. + * + * @return The module data stream. + */ + @Override + public InputStream stream() { + return stream; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 89 * hash + Objects.hashCode(this.path); + return hash; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof ModuleEntryImpl)) { + return false; + } + ModuleEntryImpl f = (ModuleEntryImpl) other; + return f.path.equals(path); + } + + @Override + public String toString() { + return getPath(); + } +} \ No newline at end of file diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java new file mode 100644 index 00000000000..a572fa48637 --- /dev/null +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ModulePoolImpl.java @@ -0,0 +1,421 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.tools.jlink.internal; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.lang.module.ModuleDescriptor; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; +import java.util.function.Function; +import java.util.stream.Stream; +import jdk.internal.jimage.decompressor.CompressedResourceHeader; +import jdk.tools.jlink.plugin.ModulePool; +import jdk.tools.jlink.plugin.LinkModule; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.PluginException; +import jdk.tools.jlink.internal.plugins.FileCopierPlugin; + +/** + * Pool of module data. + */ +public class ModulePoolImpl implements ModulePool { + + private class ModuleImpl implements LinkModule { + + final Map moduleContent = new LinkedHashMap<>(); + private ModuleDescriptor descriptor; + final String name; + + private ModuleImpl(String name) { + this.name = name; + } + + @Override + public String getName() { + return name; + } + + @Override + public Optional findEntry(String path) { + if (!path.startsWith("/")) { + path = "/" + path; + } + if (!path.startsWith("/" + name)) { + path = "/" + name + path; + } + return Optional.ofNullable(moduleContent.get(path)); + } + + @Override + public ModuleDescriptor getDescriptor() { + if (descriptor == null) { + String p = "/" + name + "/module-info.class"; + Optional content = findEntry(p); + if (!content.isPresent()) { + throw new PluginException("No module-info for " + name + + " module"); + } + ByteBuffer bb = ByteBuffer.wrap(content.get().getBytes()); + descriptor = ModuleDescriptor.read(bb); + } + return descriptor; + } + + @Override + public void add(ModuleEntry data) { + if (isReadOnly()) { + throw new PluginException("LinkConfiguration is readonly"); + } + Objects.requireNonNull(data); + if (!data.getModule().equals(name)) { + throw new PluginException("Can't add resource " + data.getPath() + + " to module " + name); + } + ModulePoolImpl.this.add(data); + } + + @Override + public Set getAllPackages() { + Set pkgs = new HashSet<>(); + moduleContent.values().stream().filter(m -> m.getType(). + equals(ModuleEntry.Type.CLASS_OR_RESOURCE)).forEach(res -> { + // Module metadata only contains packages with .class files + if (ImageFileCreator.isClassPackage(res.getPath())) { + String[] split = ImageFileCreator.splitPath(res.getPath()); + String pkg = split[1]; + if (pkg != null && !pkg.isEmpty()) { + pkgs.add(pkg); + } + } + }); + return pkgs; + } + + @Override + public String toString() { + return getName(); + } + + @Override + public Stream entries() { + return moduleContent.values().stream(); + } + + @Override + public int getEntryCount() { + return moduleContent.values().size(); + } + } + + private final Map resources = new LinkedHashMap<>(); + private final Map modules = new LinkedHashMap<>(); + private final ModuleImpl fileCopierModule = new ModuleImpl(FileCopierPlugin.FAKE_MODULE); + private Map releaseProps = new HashMap<>(); + + private final ByteOrder order; + + private boolean isReadOnly; + private final StringTable table; + + public ModulePoolImpl() { + this(ByteOrder.nativeOrder()); + } + + public ModulePoolImpl(ByteOrder order) { + this(order, new StringTable() { + + @Override + public int addString(String str) { + return -1; + } + + @Override + public String getString(int id) { + return null; + } + }); + } + + public ModulePoolImpl(ByteOrder order, StringTable table) { + this.order = order; + this.table = table; + } + + /** + * Add a ModuleEntry. + * + * @param data The ModuleEntry to add. + */ + @Override + public void add(ModuleEntry data) { + if (isReadOnly()) { + throw new PluginException("LinkConfiguration is readonly"); + } + Objects.requireNonNull(data); + if (resources.get(data.getPath()) != null) { + throw new PluginException("Resource " + data.getPath() + + " already present"); + } + String modulename = data.getModule(); + ModuleImpl m = modules.get(modulename); + // ## TODO: FileCopierPlugin should not add content to a module + // FAKE_MODULE is not really a module to be added in the image + if (FileCopierPlugin.FAKE_MODULE.equals(modulename)) { + m = fileCopierModule; + } + if (m == null) { + m = new ModuleImpl(modulename); + modules.put(modulename, m); + } + resources.put(data.getPath(), data); + m.moduleContent.put(data.getPath(), data); + } + + /** + * Retrieves the module for the provided name. + * + * @param name The module name + * @return the module of matching name, if found + */ + @Override + public Optional findModule(String name) { + Objects.requireNonNull(name); + return Optional.ofNullable(modules.get(name)); + } + + /** + * The stream of modules contained in this LinkConfiguration. + * + * @return The stream of modules. + */ + @Override + public Stream modules() { + return modules.values().stream(); + } + + /** + * Return the number of LinkModule count in this LinkConfiguration. + * + * @return the module count. + */ + @Override + public int getModuleCount() { + return modules.size(); + } + + /** + * Get all ModuleEntry contained in this LinkConfiguration instance. + * + * @return The stream of LinkModuleEntries. + */ + @Override + public Stream entries() { + return resources.values().stream(); + } + + /** + * Return the number of ModuleEntry count in this LinkConfiguration. + * + * @return the entry count. + */ + @Override + public int getEntryCount() { + return resources.values().size(); + } + + /** + * Get the ModuleEntry for the passed path. + * + * @param path A data path + * @return A ModuleEntry instance or null if the data is not found + */ + @Override + public Optional findEntry(String path) { + Objects.requireNonNull(path); + return Optional.ofNullable(resources.get(path)); + } + + /** + * Check if the LinkConfiguration contains the given ModuleEntry. + * + * @param data The module data to check existence for. + * @return The module data or null if not found. + */ + @Override + public boolean contains(ModuleEntry data) { + Objects.requireNonNull(data); + return findEntry(data.getPath()).isPresent(); + } + + /** + * Check if the LinkConfiguration contains some content at all. + * + * @return True, no content, false otherwise. + */ + @Override + public boolean isEmpty() { + return resources.isEmpty(); + } + + /** + * Visit each ModuleEntry in this LinkConfiguration to transform it and + * copy the transformed ModuleEntry to the output LinkConfiguration. + * + * @param transform The function called for each ModuleEntry found in + * the LinkConfiguration. The transform function should return a + * ModuleEntry instance which will be added to the output or it should + * return null if the passed ModuleEntry is to be ignored for the + * output. + * + * @param output The LinkConfiguration to be filled with Visitor returned + * ModuleEntry. + */ + @Override + public void transformAndCopy(Function transform, + ModulePool output) { + entries().forEach(resource -> { + ModuleEntry res = transform.apply(resource); + if (res != null) { + output.add(res); + } + }); + } + + /** + * The ByteOrder currently in use when generating the jimage file. + * + * @return The ByteOrder. + */ + @Override + public ByteOrder getByteOrder() { + return order; + } + + @Override + public Map getReleaseProperties() { + return isReadOnly()? Collections.unmodifiableMap(releaseProps) : releaseProps; + } + + public StringTable getStringTable() { + return table; + } + + /** + * Make this Resources instance read-only. No resource can be added. + */ + public void setReadOnly() { + isReadOnly = true; + } + + /** + * Read only state. + * + * @return true if readonly false otherwise. + */ + @Override + public boolean isReadOnly() { + return isReadOnly; + } + + /** + * A resource that has been compressed. + */ + public static final class CompressedModuleData extends ModuleEntryImpl { + + final long uncompressed_size; + + private CompressedModuleData(String module, String path, + InputStream stream, long size, + long uncompressed_size) { + super(module, path, ModuleEntry.Type.CLASS_OR_RESOURCE, stream, size); + this.uncompressed_size = uncompressed_size; + } + + public long getUncompressedSize() { + return uncompressed_size; + } + + @Override + public boolean equals(Object other) { + if (!(other instanceof CompressedModuleData)) { + return false; + } + CompressedModuleData f = (CompressedModuleData) other; + return f.getPath().equals(getPath()); + } + + @Override + public int hashCode() { + return super.hashCode(); + } + } + + public static CompressedModuleData newCompressedResource(ModuleEntry original, + ByteBuffer compressed, + String plugin, String pluginConfig, StringTable strings, + ByteOrder order) { + Objects.requireNonNull(original); + Objects.requireNonNull(compressed); + Objects.requireNonNull(plugin); + + boolean isTerminal = !(original instanceof CompressedModuleData); + long uncompressed_size = original.getLength(); + if (original instanceof CompressedModuleData) { + CompressedModuleData comp = (CompressedModuleData) original; + uncompressed_size = comp.getUncompressedSize(); + } + int nameOffset = strings.addString(plugin); + int configOffset = -1; + if (pluginConfig != null) { + configOffset = strings.addString(plugin); + } + CompressedResourceHeader rh + = new CompressedResourceHeader(compressed.limit(), original.getLength(), + nameOffset, configOffset, isTerminal); + // Merge header with content; + byte[] h = rh.getBytes(order); + ByteBuffer bb = ByteBuffer.allocate(compressed.limit() + h.length); + bb.order(order); + bb.put(h); + bb.put(compressed); + byte[] contentWithHeader = bb.array(); + + CompressedModuleData compressedResource + = new CompressedModuleData(original.getModule(), original.getPath(), + new ByteArrayInputStream(contentWithHeader), + contentWithHeader.length, uncompressed_size); + return compressedResource; + } + +} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java deleted file mode 100644 index 7fe7dcea36e..00000000000 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.tools.jlink.internal; - -import java.util.Properties; - -import jdk.tools.jlink.plugin.PluginContext; - -public final class PluginContextImpl implements PluginContext { - private final Properties releaseProps = new Properties(); - - public Properties getReleaseProperties() { - return releaseProps; - } -} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java deleted file mode 100644 index 2b1dd827bae..00000000000 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.tools.jlink.internal; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Objects; -import jdk.internal.jimage.decompressor.CompressedResourceHeader; -import jdk.tools.jlink.plugin.Pool; - -/** - * Pool of module data. - */ -public class PoolImpl extends Pool { - - /** - * A resource that has been compressed. - */ - public static final class CompressedModuleData extends ModuleData { - - private final long uncompressed_size; - - private CompressedModuleData(String module, String path, - InputStream stream, long size, - long uncompressed_size) { - super(module, path, ModuleDataType.CLASS_OR_RESOURCE, stream, size); - this.uncompressed_size = uncompressed_size; - } - - public long getUncompressedSize() { - return uncompressed_size; - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof CompressedModuleData)) { - return false; - } - CompressedModuleData f = (CompressedModuleData) other; - return f.getPath().equals(getPath()); - } - - @Override - public int hashCode() { - return super.hashCode(); - } - } - - private boolean isReadOnly; - private final StringTable table; - - public PoolImpl() { - this(ByteOrder.nativeOrder(), new StringTable() { - - @Override - public int addString(String str) { - return -1; - } - @Override - public String getString(int id) { - return null; - } - }); - } - - public PoolImpl(ByteOrder order) { - this(order, new StringTable() { - - @Override - public int addString(String str) { - return -1; - } - @Override - public String getString(int id) { - return null; - } - }); - } - - public PoolImpl(ByteOrder order, StringTable table) { - super(order); - this.table = table; - } - - public StringTable getStringTable() { - return table; - } - - /** - * Make this Resources instance read-only. No resource can be added. - */ - public void setReadOnly() { - isReadOnly = true; - } - - /** - * Read only state. - * - * @return true if readonly false otherwise. - */ - @Override - public boolean isReadOnly() { - return isReadOnly; - } - - public static CompressedModuleData newCompressedResource(ModuleData original, - ByteBuffer compressed, - String plugin, String pluginConfig, StringTable strings, - ByteOrder order) { - Objects.requireNonNull(original); - Objects.requireNonNull(compressed); - Objects.requireNonNull(plugin); - - boolean isTerminal = !(original instanceof CompressedModuleData); - long uncompressed_size = original.getLength(); - if (original instanceof CompressedModuleData) { - CompressedModuleData comp = (CompressedModuleData) original; - uncompressed_size = comp.getUncompressedSize(); - } - int nameOffset = strings.addString(plugin); - int configOffset = -1; - if (pluginConfig != null) { - configOffset = strings.addString(plugin); - } - CompressedResourceHeader rh - = new CompressedResourceHeader(compressed.limit(), original.getLength(), - nameOffset, configOffset, isTerminal); - // Merge header with content; - byte[] h = rh.getBytes(order); - ByteBuffer bb = ByteBuffer.allocate(compressed.limit() + h.length); - bb.order(order); - bb.put(h); - bb.put(compressed); - byte[] contentWithHeader = bb.array(); - - CompressedModuleData compressedResource - = new CompressedModuleData(original.getModule(), original.getPath(), - new ByteArrayInputStream(contentWithHeader), - contentWithHeader.length, uncompressed_size); - return compressedResource; - } - -} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java index d9c5bab9a61..c8b8bc79ed6 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ResourcePrevisitor.java @@ -24,7 +24,7 @@ */ package jdk.tools.jlink.internal; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModulePool; /** * Plugin wishing to pre-visit the resources must implement this interface. @@ -44,5 +44,5 @@ public interface ResourcePrevisitor { * usage. * @throws PluginException */ - public void previsit(Pool resources, StringTable strings); + public void previsit(ModulePool resources, StringTable strings); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java index 31064ab79d6..b255312bbf4 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/TaskHelper.java @@ -52,7 +52,7 @@ import jdk.internal.module.ConfigurableModuleFinder.Phase; import jdk.tools.jlink.Jlink; import jdk.tools.jlink.Jlink.PluginsConfiguration; import jdk.tools.jlink.plugin.Plugin; -import jdk.tools.jlink.plugin.Plugin.CATEGORY; +import jdk.tools.jlink.plugin.Plugin.Category; import jdk.tools.jlink.builder.DefaultImageBuilder; import jdk.tools.jlink.builder.ImageBuilder; import jdk.tools.jlink.plugin.PluginException; @@ -346,7 +346,6 @@ public final class TaskHelper { } } - PluginContextImpl pluginContext = new PluginContextImpl(); List pluginsList = new ArrayList<>(); for (Entry>> entry : pluginToMaps.entrySet()) { Plugin plugin = entry.getKey(); @@ -356,7 +355,7 @@ public final class TaskHelper { // we call configure once for each occurrence. It is upto the plugin // to 'merge' and/or 'override' arguments. for (Map map : argsMaps) { - plugin.configure(Collections.unmodifiableMap(map), pluginContext); + plugin.configure(Collections.unmodifiableMap(map)); } if (!Utils.isDisabled(plugin)) { @@ -371,7 +370,7 @@ public final class TaskHelper { } return new Jlink.PluginsConfiguration(pluginsList, - builder, lastSorter, pluginContext); + builder, lastSorter); } } @@ -594,7 +593,7 @@ public final class TaskHelper { + ": " + plugin.getClass().getName()); log.println(bundleHelper.getMessage("main.plugin.module") + ": " + plugin.getClass().getModule().getName()); - CATEGORY category = Utils.getCategory(plugin); + Category category = Utils.getCategory(plugin); log.println(bundleHelper.getMessage("main.plugin.category") + ": " + category.getName()); log.println(bundleHelper.getMessage("main.plugin.state") diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java index a8a9a45a5f4..0e29969a034 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/Utils.java @@ -30,7 +30,6 @@ import java.util.Comparator; import java.util.List; import java.util.function.Function; import jdk.tools.jlink.plugin.Plugin; -import jdk.tools.jlink.plugin.Plugin.PluginType; public class Utils { @@ -50,25 +49,26 @@ public class Utils { return arguments; }; - public static boolean isPostProcessor(Plugin.CATEGORY category) { - return category.equals(Plugin.CATEGORY.VERIFIER) - || category.equals(Plugin.CATEGORY.PROCESSOR) - || category.equals(Plugin.CATEGORY.PACKAGER); + public static boolean isPostProcessor(Plugin.Category category) { + return category.equals(Plugin.Category.VERIFIER) + || category.equals(Plugin.Category.PROCESSOR) + || category.equals(Plugin.Category.PACKAGER); } - public static boolean isPreProcessor(Plugin.CATEGORY category) { - return category.equals(Plugin.CATEGORY.COMPRESSOR) - || category.equals(Plugin.CATEGORY.FILTER) - || category.equals(Plugin.CATEGORY.MODULEINFO_TRANSFORMER) - || category.equals(Plugin.CATEGORY.SORTER) - || category.equals(Plugin.CATEGORY.TRANSFORMER); + public static boolean isPreProcessor(Plugin.Category category) { + return category.equals(Plugin.Category.COMPRESSOR) + || category.equals(Plugin.Category.FILTER) + || category.equals(Plugin.Category.MODULEINFO_TRANSFORMER) + || category.equals(Plugin.Category.SORTER) + || category.equals(Plugin.Category.TRANSFORMER) + || category.equals(Plugin.Category.METAINFO_ADDER); } public static boolean isPostProcessor(Plugin prov) { if (prov.getType() != null) { - for (PluginType pt : prov.getType()) { - if (pt instanceof Plugin.CATEGORY) { - return isPostProcessor((Plugin.CATEGORY) pt); + for (Plugin.Category pt : prov.getType()) { + if (pt instanceof Plugin.Category) { + return isPostProcessor(pt); } } } @@ -77,20 +77,20 @@ public class Utils { public static boolean isPreProcessor(Plugin prov) { if (prov.getType() != null) { - for (PluginType pt : prov.getType()) { - if (pt instanceof Plugin.CATEGORY) { - return isPreProcessor((Plugin.CATEGORY) pt); + for (Plugin.Category pt : prov.getType()) { + if (pt instanceof Plugin.Category) { + return isPreProcessor(pt); } } } return false; } - public static Plugin.CATEGORY getCategory(Plugin provider) { + public static Plugin.Category getCategory(Plugin provider) { if (provider.getType() != null) { - for (Plugin.PluginType t : provider.getType()) { - if (t instanceof Plugin.CATEGORY) { - return (Plugin.CATEGORY) t; + for (Plugin.Category t : provider.getType()) { + if (t instanceof Plugin.Category) { + return t; } } } @@ -140,15 +140,15 @@ public class Utils { } public static boolean isFunctional(Plugin prov) { - return prov.getState().contains(Plugin.STATE.FUNCTIONAL); + return prov.getState().contains(Plugin.State.FUNCTIONAL); } public static boolean isAutoEnabled(Plugin prov) { - return prov.getState().contains(Plugin.STATE.AUTO_ENABLED); + return prov.getState().contains(Plugin.State.AUTO_ENABLED); } public static boolean isDisabled(Plugin prov) { - return prov.getState().contains(Plugin.STATE.DISABLED); + return prov.getState().contains(Plugin.State.DISABLED); } // is this a builtin (jdk.jlink) plugin? diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java index e448acd0b1d..874b338c93f 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/packager/AppRuntimeImageBuilder.java @@ -30,7 +30,7 @@ import jdk.tools.jlink.Jlink; import jdk.tools.jlink.builder.ImageBuilder; import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.builder.*; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModulePool; import java.io.ByteArrayOutputStream; import java.io.File; diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java index aa068f1136e..43eb6f27dec 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/DefaultCompressPlugin.java @@ -26,16 +26,13 @@ package jdk.tools.jlink.internal.plugins; import java.io.IOException; import java.io.UncheckedIOException; -import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; -import java.util.List; import java.util.Map; import java.util.Set; -import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.internal.PoolImpl; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.internal.ModulePoolImpl; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; import jdk.tools.jlink.internal.ImagePluginStack; import jdk.tools.jlink.internal.ResourcePrevisitor; @@ -62,10 +59,10 @@ public final class DefaultCompressPlugin implements TransformerPlugin, ResourceP } @Override - public void visit(Pool in, Pool out) { + public void visit(ModulePool in, ModulePool out) { if (ss != null && zip != null) { - Pool output = new ImagePluginStack.OrderedResourcePool(in.getByteOrder(), - ((PoolImpl) in).getStringTable()); + ModulePool output = new ImagePluginStack.OrderedResourcePool(in.getByteOrder(), + ((ModulePoolImpl) in).getStringTable()); ss.visit(in, output); zip.visit(output, out); } else if (ss != null) { @@ -76,16 +73,16 @@ public final class DefaultCompressPlugin implements TransformerPlugin, ResourceP } @Override - public void previsit(Pool resources, StringTable strings) { + public void previsit(ModulePool resources, StringTable strings) { if (ss != null) { ss.previsit(resources, strings); } } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.COMPRESSOR); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.COMPRESSOR); return Collections.unmodifiableSet(set); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java index 0271670e4c1..628d8f6346e 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeFilesPlugin.java @@ -32,8 +32,8 @@ import java.util.Map; import java.util.Set; import java.util.function.Predicate; import jdk.tools.jlink.plugin.TransformerPlugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleDataType; +import jdk.tools.jlink.plugin.ModulePool; +import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.internal.Utils; /** @@ -51,9 +51,9 @@ public final class ExcludeFilesPlugin implements TransformerPlugin { } @Override - public void visit(Pool in, Pool out) { - in.visit((file) -> { - if (!file.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) { + public void visit(ModulePool in, ModulePool out) { + in.transformAndCopy((file) -> { + if (!file.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) { file = predicate.test(file.getPath()) ? file : null; } return file; @@ -61,9 +61,9 @@ public final class ExcludeFilesPlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.FILTER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.FILTER); return Collections.unmodifiableSet(set); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java index 6d4737a4661..626087b76be 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludePlugin.java @@ -32,7 +32,8 @@ import java.util.Set; import java.util.function.Predicate; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.TransformerPlugin; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.internal.Utils; /** @@ -50,9 +51,9 @@ public final class ExcludePlugin implements TransformerPlugin { } @Override - public void visit(Pool in, Pool out) { - in.visit((resource) -> { - if (resource.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)) { + public void visit(ModulePool in, ModulePool out) { + in.transformAndCopy((resource) -> { + if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) { resource = predicate.test(resource.getPath()) ? resource : null; } return resource; @@ -75,9 +76,9 @@ public final class ExcludePlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.FILTER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.FILTER); return Collections.unmodifiableSet(set); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java index 4d502904c37..753d63e5cfc 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ExcludeVMPlugin.java @@ -40,9 +40,10 @@ import java.util.TreeSet; import java.util.function.Predicate; import java.util.stream.Collectors; import jdk.tools.jlink.plugin.TransformerPlugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleDataType; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.internal.Utils; +import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.PluginException; /** @@ -102,24 +103,24 @@ public final class ExcludeVMPlugin implements TransformerPlugin { * e.g.: /java.base/native/amd64/server/libjvm.so * /java.base/native/server/libjvm.dylib */ - private List getVMs(Pool in) { + private List getVMs(ModulePool in) { String jvmlib = jvmlib(); - List ret = in.getModule("java.base").getContent().stream().filter((t) -> { + List ret = in.findModule("java.base").get().entries().filter((t) -> { return t.getPath().endsWith("/" + jvmlib); }).collect(Collectors.toList()); return ret; } @Override - public void visit(Pool in, Pool out) { + public void visit(ModulePool in, ModulePool out) { String jvmlib = jvmlib(); TreeSet existing = new TreeSet<>(new JvmComparator()); TreeSet removed = new TreeSet<>(new JvmComparator()); if (!keepAll) { // First retrieve all available VM names and removed VM - List jvms = getVMs(in); + List jvms = getVMs(in); for (Jvm jvm : Jvm.values()) { - for (Pool.ModuleData md : jvms) { + for (ModuleEntry md : jvms) { if (md.getPath().endsWith("/" + jvm.getName() + "/" + jvmlib)) { existing.add(jvm); if (isRemoved(md)) { @@ -137,9 +138,9 @@ public final class ExcludeVMPlugin implements TransformerPlugin { } // Rewrite the jvm.cfg file. - in.visit((file) -> { + in.transformAndCopy((file) -> { if (!keepAll) { - if (file.getType().equals(ModuleDataType.NATIVE_LIB)) { + if (file.getType().equals(ModuleEntry.Type.NATIVE_LIB)) { if (file.getPath().endsWith(JVM_CFG)) { try { file = handleJvmCfgFile(file, existing, removed); @@ -155,14 +156,14 @@ public final class ExcludeVMPlugin implements TransformerPlugin { } - private boolean isRemoved(Pool.ModuleData file) { + private boolean isRemoved(ModuleEntry file) { return !predicate.test(file.getPath()); } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.FILTER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.FILTER); return Collections.unmodifiableSet(set); } @@ -217,7 +218,7 @@ public final class ExcludeVMPlugin implements TransformerPlugin { } } - private Pool.ModuleData handleJvmCfgFile(Pool.ModuleData orig, + private ModuleEntry handleJvmCfgFile(ModuleEntry orig, TreeSet existing, TreeSet removed) throws IOException { if (keepAll) { @@ -253,7 +254,7 @@ public final class ExcludeVMPlugin implements TransformerPlugin { byte[] content = builder.toString().getBytes(StandardCharsets.UTF_8); - return Pool.newImageFile(orig.getModule(), + return ModuleEntry.create(orig.getModule(), orig.getPath(), orig.getType(), new ByteArrayInputStream(content), content.length); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java index 7a51d6cbcdf..497d97e50a6 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/FileCopierPlugin.java @@ -41,10 +41,10 @@ import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Set; +import jdk.tools.jlink.internal.ModuleEntryImpl; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; -import jdk.tools.jlink.plugin.Pool.ModuleDataType; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; import jdk.tools.jlink.internal.Utils; @@ -68,12 +68,12 @@ public class FileCopierPlugin implements TransformerPlugin { /** * Symbolic link to another path. */ - public static abstract class SymImageFile extends Pool.ModuleData { + public static abstract class SymImageFile extends ModuleEntryImpl { private final String targetPath; public SymImageFile(String targetPath, String module, String path, - Pool.ModuleDataType type, InputStream stream, long size) { + ModuleEntry.Type type, InputStream stream, long size) { super(module, path, type, stream, size); this.targetPath = targetPath; } @@ -86,7 +86,7 @@ public class FileCopierPlugin implements TransformerPlugin { private static final class SymImageFileImpl extends SymImageFile { public SymImageFileImpl(String targetPath, Path file, String module, - String path, ModuleDataType type) { + String path, ModuleEntry.Type type) { super(targetPath, module, path, type, newStream(file), length(file)); } } @@ -110,11 +110,11 @@ public class FileCopierPlugin implements TransformerPlugin { private static final class DirectoryCopy implements FileVisitor { private final Path source; - private final Pool pool; + private final ModulePool pool; private final String targetDir; private final List symlinks = new ArrayList<>(); - DirectoryCopy(Path source, Pool pool, String targetDir) { + DirectoryCopy(Path source, ModulePool pool, String targetDir) { this.source = source; this.pool = pool; this.targetDir = targetDir; @@ -148,7 +148,7 @@ public class FileCopierPlugin implements TransformerPlugin { } SymImageFileImpl impl = new SymImageFileImpl(symTarget.toString(), file, path, Objects.requireNonNull(file.getFileName()).toString(), - Pool.ModuleDataType.OTHER); + ModuleEntry.Type.OTHER); symlinks.add(impl); } else { addFile(pool, file, path); @@ -172,14 +172,14 @@ public class FileCopierPlugin implements TransformerPlugin { } } - private static void addFile(Pool pool, Path file, String path) + private static void addFile(ModulePool pool, Path file, String path) throws IOException { Objects.requireNonNull(pool); Objects.requireNonNull(file); Objects.requireNonNull(path); - ModuleData impl = Pool.newImageFile(FAKE_MODULE, + ModuleEntry impl = ModuleEntry.create(FAKE_MODULE, "/" + FAKE_MODULE + "/other/" + path, - Pool.ModuleDataType.OTHER, newStream(file), length(file)); + ModuleEntry.Type.OTHER, newStream(file), length(file)); try { pool.add(impl); } catch (Exception ex) { @@ -188,9 +188,9 @@ public class FileCopierPlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.TRANSFORMER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.TRANSFORMER); return Collections.unmodifiableSet(set); } @@ -239,8 +239,8 @@ public class FileCopierPlugin implements TransformerPlugin { } @Override - public void visit(Pool in, Pool out) { - in.visit((file) -> { + public void visit(ModulePool in, ModulePool out) { + in.transformAndCopy((file) -> { return file; }, out); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java index d2b2995bdda..9e0805ec361 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java @@ -33,8 +33,9 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; /** @@ -60,8 +61,8 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin { } @Override - public Set getType() { - return Collections.singleton(CATEGORY.TRANSFORMER); + public Set getType() { + return Collections.singleton(Category.TRANSFORMER); } @Override @@ -75,8 +76,8 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin { } @Override - public Set getState() { - return EnumSet.of(STATE.AUTO_ENABLED, STATE.FUNCTIONAL); + public Set getState() { + return EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL); } @Override @@ -151,8 +152,8 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin { } @Override - public void visit(Pool in, Pool out) { - for (Pool.ModuleData data : in.getContent()) { + public void visit(ModulePool in, ModulePool out) { + in.entries().forEach(data -> { if (("/java.base/" + BMH + ".class").equals(data.getPath())) { // Add BoundMethodHandle unchanged out.add(data); @@ -162,11 +163,11 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin { out.add(data); } } - } + }); } @SuppressWarnings("unchecked") - private void generateConcreteClass(String types, Pool.ModuleData data, Pool out) { + private void generateConcreteClass(String types, ModuleEntry data, ModulePool out) { try { // Generate class Map.Entry result = (Map.Entry) @@ -175,9 +176,9 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin { byte[] bytes = result.getValue(); // Add class to pool - Pool.ModuleData ndata = new Pool.ModuleData(data.getModule(), + ModuleEntry ndata = ModuleEntry.create(data.getModule(), "/java.base/" + className + ".class", - Pool.ModuleDataType.CLASS_OR_RESOURCE, + ModuleEntry.Type.CLASS_OR_RESOURCE, new ByteArrayInputStream(bytes), bytes.length); if (!out.contains(ndata)) { out.add(ndata); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java index b8b7aa46cc1..3083c19d2ba 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/IncludeLocalesPlugin.java @@ -34,6 +34,7 @@ import java.util.IllformedLocaleException; import java.util.Locale; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.function.Predicate; import java.util.regex.Pattern; @@ -44,9 +45,10 @@ import jdk.internal.org.objectweb.asm.ClassReader; import jdk.tools.jlink.internal.ResourcePrevisitor; import jdk.tools.jlink.internal.StringTable; import jdk.tools.jlink.internal.Utils; +import jdk.tools.jlink.plugin.LinkModule; +import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleDataType; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; /** @@ -112,19 +114,19 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr } @Override - public void visit(Pool in, Pool out) { - in.visit((resource) -> { + public void visit(ModulePool in, ModulePool out) { + in.transformAndCopy((resource) -> { if (resource.getModule().equals(MODULENAME)) { String path = resource.getPath(); resource = predicate.test(path) ? resource: null; if (resource != null && - resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) { + resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) { byte[] bytes = resource.getBytes(); ClassReader cr = new ClassReader(bytes); if (Arrays.stream(cr.getInterfaces()) .anyMatch(i -> i.contains(METAINFONAME)) && stripUnsupportedLocales(bytes, cr)) { - resource = new Pool.ModuleData(MODULENAME, path, + resource = ModuleEntry.create(MODULENAME, path, resource.getType(), new ByteArrayInputStream(bytes), bytes.length); } @@ -135,9 +137,9 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.FILTER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.FILTER); return Collections.unmodifiableSet(set); } @@ -172,12 +174,13 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr } @Override - public void previsit(Pool resources, StringTable strings) { + public void previsit(ModulePool resources, StringTable strings) { final Pattern p = Pattern.compile(".*((Data_)|(Names_))(?.*)\\.class"); - Pool.Module module = resources.getModule(MODULENAME); + Optional optMod = resources.findModule(MODULENAME); // jdk.localedata module validation - if (module != null) { + if (optMod.isPresent()) { + LinkModule module = optMod.get(); Set packages = module.getAllPackages(); if (!packages.containsAll(LOCALEDATA_PACKAGES)) { throw new PluginException(PluginsResourceBundle.getMessage(NAME + ".missingpackages") + @@ -186,7 +189,7 @@ public final class IncludeLocalesPlugin implements TransformerPlugin, ResourcePr .collect(Collectors.joining(",\n\t"))); } - available = Stream.concat(module.getContent().stream() + available = Stream.concat(module.entries() .map(md -> p.matcher(md.getPath())) .filter(m -> m.matches()) .map(m -> m.group("tag").replaceAll("_", "-")), diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java index 4f8e5eade53..9632cdf9b95 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OptimizationPlugin.java @@ -24,7 +24,6 @@ */ package jdk.tools.jlink.internal.plugins; -import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; @@ -287,9 +286,9 @@ public final class OptimizationPlugin extends AsmPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.TRANSFORMER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.TRANSFORMER); return Collections.unmodifiableSet(set); } } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java index 8fb124dd775..5060bf5c519 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/OrderResourcesPlugin.java @@ -36,9 +36,8 @@ import java.util.Map; import java.util.Set; import java.util.function.ToIntFunction; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; -import jdk.tools.jlink.plugin.Pool.ModuleDataType; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; import jdk.tools.jlink.internal.Utils; @@ -62,15 +61,15 @@ public final class OrderResourcesPlugin implements TransformerPlugin { } static class SortWrapper { - private final ModuleData resource; + private final ModuleEntry resource; private final int ordinal; - SortWrapper(ModuleData resource, int ordinal) { + SortWrapper(ModuleEntry resource, int ordinal) { this.resource = resource; this.ordinal = ordinal; } - ModuleData getResource() { + ModuleEntry getResource() { return resource; } @@ -95,7 +94,7 @@ public final class OrderResourcesPlugin implements TransformerPlugin { return path; } - private int getOrdinal(ModuleData resource) { + private int getOrdinal(ModuleEntry resource) { String path = resource.getPath(); Integer value = orderedPaths.get(stripModule(path)); @@ -126,23 +125,23 @@ public final class OrderResourcesPlugin implements TransformerPlugin { } @Override - public void visit(Pool in, Pool out) { - in.getContent().stream() + public void visit(ModulePool in, ModulePool out) { + in.entries() .filter(resource -> resource.getType() - .equals(ModuleDataType.CLASS_OR_RESOURCE)) + .equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) .map((resource) -> new SortWrapper(resource, getOrdinal(resource))) .sorted(OrderResourcesPlugin::compare) .forEach((wrapper) -> out.add(wrapper.getResource())); - in.getContent().stream() + in.entries() .filter(other -> !other.getType() - .equals(ModuleDataType.CLASS_OR_RESOURCE)) + .equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) .forEach((other) -> out.add(other)); } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.SORTER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.SORTER); return Collections.unmodifiableSet(set); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java index bbc7428a41e..579aace7e0a 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ReleaseInfoPlugin.java @@ -24,34 +24,33 @@ */ package jdk.tools.jlink.internal.plugins; -import java.lang.module.ModuleDescriptor; import java.io.FileInputStream; import java.io.IOException; import java.util.Collections; import java.util.EnumSet; -import java.util.List; +import java.util.HashMap; import java.util.Map; -import java.util.Set; import java.util.Properties; - +import java.util.Set; +import java.util.function.Function; import jdk.tools.jlink.internal.Utils; -import jdk.tools.jlink.plugin.ExecutableImage; -import jdk.tools.jlink.plugin.PluginContext; -import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.PostProcessorPlugin; +import jdk.tools.jlink.plugin.ModulePool; +import jdk.tools.jlink.plugin.Plugin.Category; +import jdk.tools.jlink.plugin.Plugin.State; +import jdk.tools.jlink.plugin.TransformerPlugin; /** * This plugin adds/deletes information for 'release' file. */ -public final class ReleaseInfoPlugin implements PostProcessorPlugin { +public final class ReleaseInfoPlugin implements TransformerPlugin { // option name public static final String NAME = "release-info"; public static final String KEYS = "keys"; + private final Map release = new HashMap<>(); @Override - public Set getType() { - return Collections.singleton(CATEGORY.PROCESSOR); + public Set getType() { + return Collections.singleton(Category.METAINFO_ADDER); } @Override @@ -65,8 +64,8 @@ public final class ReleaseInfoPlugin implements PostProcessorPlugin { } @Override - public Set getState() { - return EnumSet.of(STATE.FUNCTIONAL); + public Set getState() { + return EnumSet.of(State.FUNCTIONAL); } @Override @@ -80,49 +79,49 @@ public final class ReleaseInfoPlugin implements PostProcessorPlugin { } @Override - public void configure(Map config, PluginContext ctx) { - Properties release = ctx != null? ctx.getReleaseProperties() : null; - if (release != null) { - String operation = config.get(NAME); - switch (operation) { - case "add": { - // leave it to open-ended! source, java_version, java_full_version - // can be passed via this option like: - // - // --release-info add:build_type=fastdebug,source=openjdk,java_version=9 - // and put whatever value that was passed in command line. + public void configure(Map config) { + String operation = config.get(NAME); + switch (operation) { + case "add": { + // leave it to open-ended! source, java_version, java_full_version + // can be passed via this option like: + // + // --release-info add:build_type=fastdebug,source=openjdk,java_version=9 + // and put whatever value that was passed in command line. - config.keySet().stream(). - filter(s -> !NAME.equals(s)). - forEach(s -> release.put(s, config.get(s))); - } - break; + config.keySet().stream(). + filter(s -> !NAME.equals(s)). + forEach(s -> release.put(s, config.get(s))); + } + break; - case "del": { - // --release-info del:keys=openjdk,java_version - String[] keys = Utils.listParser.apply(config.get(KEYS)); - for (String k : keys) { - release.remove(k); - } + case "del": { + // --release-info del:keys=openjdk,java_version + String[] keys = Utils.listParser.apply(config.get(KEYS)); + for (String k : keys) { + release.remove(k); } - break; + } + break; - default: { - // --release-info - try (FileInputStream fis = new FileInputStream(operation)) { - release.load(fis); - } catch (IOException exp) { - throw new RuntimeException(exp); - } + default: { + // --release-info + Properties props = new Properties(); + try (FileInputStream fis = new FileInputStream(operation)) { + props.load(fis); + } catch (IOException exp) { + throw new RuntimeException(exp); } - break; + props.forEach((k, v) -> release.put(k.toString(), v.toString())); } + break; } } @Override - public List process(ExecutableImage image) { - // Nothing to do! Release info copied already during configure! - return Collections.emptyList(); + public void visit(ModulePool in, ModulePool out) { + in.transformAndCopy(Function.identity(), out); + out.getReleaseProperties().putAll(in.getReleaseProperties()); + out.getReleaseProperties().putAll(release); } } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java index a4aa8f9d5ca..b3a1e7cf3cf 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StringSharingPlugin.java @@ -56,11 +56,11 @@ import java.util.stream.Collectors; import jdk.internal.jimage.decompressor.CompressIndexes; import jdk.internal.jimage.decompressor.SignatureParser; import jdk.internal.jimage.decompressor.StringSharingDecompressor; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.plugin.TransformerPlugin; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.internal.ResourcePrevisitor; import jdk.tools.jlink.internal.StringTable; import jdk.tools.jlink.internal.Utils; @@ -228,7 +228,7 @@ public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisito } } - public byte[] transform(ModuleData resource, Pool out, + public byte[] transform(ModuleEntry resource, ModulePool out, StringTable strings) throws IOException, Exception { byte[] content = resource.getBytes(); ClassFile cf; @@ -243,7 +243,7 @@ public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisito } @SuppressWarnings("fallthrough") - private byte[] optimize(ModuleData resource, Pool resources, + private byte[] optimize(ModuleEntry resource, ModulePool resources, StringTable strings, Set descriptorIndexes, byte[] content) throws Exception { DataInputStream stream = new DataInputStream(new ByteArrayInputStream(content)); @@ -348,27 +348,27 @@ public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisito } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.COMPRESSOR); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.COMPRESSOR); return Collections.unmodifiableSet(set); } @Override - public void visit(Pool in, Pool result) { + public void visit(ModulePool in, ModulePool result) { CompactCPHelper visit = new CompactCPHelper(); - in.visit((resource) -> { - ModuleData res = resource; + in.transformAndCopy((resource) -> { + ModuleEntry res = resource; if (predicate.test(resource.getPath()) && resource.getPath().endsWith(".class")) { byte[] compressed = null; try { - compressed = visit.transform(resource, result, ((PoolImpl) in).getStringTable()); + compressed = visit.transform(resource, result, ((ModulePoolImpl) in).getStringTable()); } catch (Exception ex) { throw new PluginException(ex); } - res = PoolImpl.newCompressedResource(resource, + res = ModulePoolImpl.newCompressedResource(resource, ByteBuffer.wrap(compressed), getName(), null, - ((PoolImpl) in).getStringTable(), in.getByteOrder()); + ((ModulePoolImpl) in).getStringTable(), in.getByteOrder()); } return res; }, result); @@ -405,10 +405,10 @@ public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisito } @Override - public void previsit(Pool resources, StringTable strings) { + public void previsit(ModulePool resources, StringTable strings) { CompactCPHelper preVisit = new CompactCPHelper(); - for (ModuleData resource : resources.getContent()) { - if (resource.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE) + resources.entries().forEach(resource -> { + if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE) && resource.getPath().endsWith(".class") && predicate.test(resource.getPath())) { try { preVisit.transform(resource, null, strings); @@ -416,6 +416,6 @@ public class StringSharingPlugin implements TransformerPlugin, ResourcePrevisito throw new PluginException(ex); } } - } + }); } } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java index ae927952226..4e7a036d838 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripDebugPlugin.java @@ -29,14 +29,12 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.util.Collections; import java.util.HashSet; -import java.util.Map; import java.util.Set; import java.util.function.Predicate; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.ClassWriter; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; -import jdk.tools.jlink.plugin.Pool.ModuleDataType; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; /** @@ -61,9 +59,9 @@ public final class StripDebugPlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.TRANSFORMER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.TRANSFORMER); return Collections.unmodifiableSet(set); } @@ -73,11 +71,11 @@ public final class StripDebugPlugin implements TransformerPlugin { } @Override - public void visit(Pool in, Pool out) { + public void visit(ModulePool in, ModulePool out) { //remove *.diz files as well as debug attributes. - in.visit((resource) -> { - ModuleData res = resource; - if (resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE)) { + in.transformAndCopy((resource) -> { + ModuleEntry res = resource; + if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) { String path = resource.getPath(); if (path.endsWith(".class")) { if (path.endsWith("module-info.class")) { @@ -87,7 +85,7 @@ public final class StripDebugPlugin implements TransformerPlugin { ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS); reader.accept(writer, ClassReader.SKIP_DEBUG); byte[] content = writer.toByteArray(); - res = Pool.newResource(path, new ByteArrayInputStream(content), content.length); + res = ModuleEntry.create(path, new ByteArrayInputStream(content), content.length); } } } else if (predicate.test(res.getPath())) { diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java index dc64582be21..496a4e538d7 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/StripNativeCommandsPlugin.java @@ -26,9 +26,9 @@ package jdk.tools.jlink.internal.plugins; import java.util.Collections; import java.util.HashSet; -import java.util.Map; import java.util.Set; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; /** @@ -45,16 +45,16 @@ public final class StripNativeCommandsPlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.FILTER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.FILTER); return Collections.unmodifiableSet(set); } @Override - public void visit(Pool in, Pool out) { - in.visit((file) -> { - return file.getType() == Pool.ModuleDataType.NATIVE_CMD ? null : file; + public void visit(ModulePool in, ModulePool out) { + in.transformAndCopy((file) -> { + return file.getType() == ModuleEntry.Type.NATIVE_CMD ? null : file; }, out); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java index f4cba7607ea..b60fecb5d16 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModuleDescriptorPlugin.java @@ -36,6 +36,7 @@ import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -50,9 +51,10 @@ import jdk.internal.org.objectweb.asm.Opcodes; import static jdk.internal.org.objectweb.asm.Opcodes.*; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; import jdk.tools.jlink.internal.plugins.SystemModuleDescriptorPlugin.Builder.*; +import jdk.tools.jlink.plugin.ModuleEntry; /** * Jlink plugin to reconstitute module descriptors for installed modules. @@ -81,8 +83,8 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin { } @Override - public Set getType() { - return Collections.singleton(CATEGORY.TRANSFORMER); + public Set getType() { + return Collections.singleton(Category.TRANSFORMER); } @Override @@ -96,9 +98,9 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin { } @Override - public Set getState() { - return enabled ? EnumSet.of(STATE.AUTO_ENABLED, STATE.FUNCTIONAL) - : EnumSet.of(STATE.DISABLED); + public Set getState() { + return enabled ? EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL) + : EnumSet.of(State.DISABLED); } @Override @@ -110,7 +112,7 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin { @Override - public void visit(Pool in, Pool out) { + public void visit(ModulePool in, ModulePool out) { if (!enabled) { throw new PluginException(NAME + " was set"); } @@ -119,13 +121,14 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin { // generate the byte code to create ModuleDescriptors // skip parsing module-info.class and skip name check - for (Pool.Module module : in.getModules()) { - Pool.ModuleData data = module.get("module-info.class"); - if (data == null) { + in.modules().forEach(module -> { + Optional optData = module.findEntry("module-info.class"); + if (! optData.isPresent()) { // automatic module not supported yet throw new PluginException("module-info.class not found for " + module.getName() + " module"); } + ModuleEntry data = optData.get(); assert module.getName().equals(data.getModule()); try { ByteArrayInputStream bain = new ByteArrayInputStream(data.getBytes()); @@ -141,7 +144,7 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin { ModuleInfoRewriter minfoWriter = new ModuleInfoRewriter(bain, mbuilder.conceals()); // replace with the overridden version - data = new Pool.ModuleData(data.getModule(), + data = ModuleEntry.create(data.getModule(), data.getPath(), data.getType(), minfoWriter.stream(), @@ -151,19 +154,17 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin { } catch (IOException e) { throw new PluginException(e); } - - } + }); // Generate the new class ClassWriter cwriter = builder.build(); - for (Pool.ModuleData data : in.getContent()) { + in.entries().forEach(data -> { if (data.getPath().endsWith("module-info.class")) - continue; - + return; if (builder.isOverriddenClass(data.getPath())) { byte[] bytes = cwriter.toByteArray(); - Pool.ModuleData ndata = - new Pool.ModuleData(data.getModule(), + ModuleEntry ndata = + ModuleEntry.create(data.getModule(), data.getPath(), data.getType(), new ByteArrayInputStream(bytes), @@ -172,7 +173,7 @@ public final class SystemModuleDescriptorPlugin implements TransformerPlugin { } else { out.add(data); } - } + }); } /* diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java index df66e300f5c..d3dd7bff210 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/ZipPlugin.java @@ -34,10 +34,9 @@ import java.util.Set; import java.util.function.Predicate; import java.util.zip.Deflater; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.internal.PoolImpl; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; -import jdk.tools.jlink.plugin.Pool.ModuleDataType; +import jdk.tools.jlink.internal.ModulePoolImpl; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; import jdk.tools.jlink.internal.Utils; @@ -68,9 +67,9 @@ public final class ZipPlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.COMPRESSOR); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.COMPRESSOR); return Collections.unmodifiableSet(set); } @@ -124,16 +123,16 @@ public final class ZipPlugin implements TransformerPlugin { } @Override - public void visit(Pool in, Pool out) { - in.visit((resource) -> { - ModuleData res = resource; - if (resource.getType().equals(ModuleDataType.CLASS_OR_RESOURCE) + public void visit(ModulePool in, ModulePool out) { + in.transformAndCopy((resource) -> { + ModuleEntry res = resource; + if (resource.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE) && predicate.test(resource.getPath())) { byte[] compressed; compressed = compress(resource.getBytes()); - res = PoolImpl.newCompressedResource(resource, + res = ModulePoolImpl.newCompressedResource(resource, ByteBuffer.wrap(compressed), getName(), null, - ((PoolImpl) in).getStringTable(), in.getByteOrder()); + ((ModulePoolImpl) in).getStringTable(), in.getByteOrder()); } return res; }, out); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java index 9902959d059..52712172d5e 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPlugin.java @@ -26,9 +26,9 @@ package jdk.tools.jlink.internal.plugins.asm; import java.util.Objects; import jdk.tools.jlink.plugin.TransformerPlugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; +import jdk.tools.jlink.internal.ModulePoolImpl; /** * Extend this class to develop your own plugin in order to transform jimage @@ -41,17 +41,17 @@ public abstract class AsmPlugin implements TransformerPlugin { } @Override - public void visit(Pool allContent, Pool outResources) { + public void visit(ModulePool allContent, ModulePool outResources) { Objects.requireNonNull(allContent); Objects.requireNonNull(outResources); - PoolImpl resources = new PoolImpl(allContent.getByteOrder()); - for(ModuleData md : allContent.getContent()) { - if(md.getType().equals(Pool.ModuleDataType.CLASS_OR_RESOURCE)) { + ModulePoolImpl resources = new ModulePoolImpl(allContent.getByteOrder()); + allContent.entries().forEach(md -> { + if(md.getType().equals(ModuleEntry.Type.CLASS_OR_RESOURCE)) { resources.add(md); } else { outResources.add(md); } - } + }); AsmPools pools = new AsmPools(resources); visit(pools); pools.fillOutputResources(outResources); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java index 9184bb86257..aa5c1cb5ef5 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPool.java @@ -24,13 +24,12 @@ */ package jdk.tools.jlink.internal.plugins.asm; -import java.io.InputStream; -import java.nio.ByteBuffer; import java.util.Collection; import java.util.List; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.ClassWriter; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; /** * A pool of ClassReader and other resource files. @@ -138,14 +137,14 @@ public interface AsmPool { * @return The ClassReader or null if the class is not found. * @throws jdk.tools.jlink.plugin.PluginException */ - public ClassReader getClassReader(Pool.ModuleData res); + public ClassReader getClassReader(ModuleEntry res); /** * Returns all the classes contained in the writable pool. * * @return The collection of classes. */ - public Collection getClasses(); + public Collection getClasses(); } /** @@ -185,14 +184,14 @@ public interface AsmPool { * @param res The java resource * @return The Resource or null if the resource is not found. */ - public ResourceFile getResourceFile(Pool.ModuleData res); + public ResourceFile getResourceFile(ModuleEntry res); /** * Returns all the resources contained in the writable pool. * * @return The array of resources. */ - public Collection getResourceFiles(); + public Collection getResourceFiles(); } /** @@ -206,7 +205,7 @@ public interface AsmPool { * @return The resource paths ordered in the way to use for storage in the jimage. * @throws jdk.tools.jlink.plugin.PluginException */ - public List sort(Pool resources); + public List sort(ModulePool resources); } /** @@ -237,7 +236,7 @@ public interface AsmPool { * * @return The classes. */ - public Collection getClasses(); + public Collection getClasses(); /** * Returns the resources contained in the pool. Resources are all the file @@ -245,7 +244,7 @@ public interface AsmPool { * * @return The array of resource files. */ - public Collection getResourceFiles(); + public Collection getResourceFiles(); /** * Retrieves a resource based on the binary name. This name doesn't contain @@ -266,7 +265,7 @@ public interface AsmPool { * @param res The resource * @return The resource file or null if it doesn't exist. */ - public ResourceFile getResourceFile(Pool.ModuleData res); + public ResourceFile getResourceFile(ModuleEntry res); /** * Retrieve a ClassReader from the pool. @@ -284,7 +283,7 @@ public interface AsmPool { * @return A reader or null if the class is unknown * @throws jdk.tools.jlink.plugin.PluginException */ - public ClassReader getClassReader(Pool.ModuleData res); + public ClassReader getClassReader(ModuleEntry res); /** * To visit the set of ClassReaders. @@ -310,6 +309,6 @@ public interface AsmPool { * @param output The pool used to fill the jimage. * @throws jdk.tools.jlink.plugin.PluginException */ - public void fillOutputResources(Pool output); + public void fillOutputResources(ModulePool output); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java index cb838d11efa..20c17c85b7b 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPoolImpl.java @@ -41,15 +41,14 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Objects; -import java.util.Optional; import java.util.Set; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.tools.jlink.internal.ImageFileCreator; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; +import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModulePool; /** * A pool of ClassReader and other resource files. This class allows to @@ -94,7 +93,7 @@ final class AsmPoolImpl implements AsmModulePool { } byte[] content = writer.toByteArray(); - ModuleData res = Pool.newResource(path, + ModuleEntry res = ModuleEntry.create(path, new ByteArrayInputStream(content), content.length); transformedClasses.put(className, res); } @@ -108,7 +107,7 @@ final class AsmPoolImpl implements AsmModulePool { public void forgetClass(String className) { Objects.requireNonNull(className); // do we have a resource? - ModuleData res = transformedClasses.get(className); + ModuleEntry res = transformedClasses.get(className); if (res == null) { res = inputClasses.get(className); if (res == null) { @@ -130,7 +129,7 @@ final class AsmPoolImpl implements AsmModulePool { @Override public ClassReader getClassReader(String binaryName) { Objects.requireNonNull(binaryName); - ModuleData res = transformedClasses.get(binaryName); + ModuleEntry res = transformedClasses.get(binaryName); ClassReader reader = null; if (res != null) { reader = getClassReader(res); @@ -144,16 +143,16 @@ final class AsmPoolImpl implements AsmModulePool { * @return The array of transformed classes. */ @Override - public Collection getClasses() { - List classes = new ArrayList<>(); - for (Entry entry : transformedClasses.entrySet()) { + public Collection getClasses() { + List classes = new ArrayList<>(); + for (Entry entry : transformedClasses.entrySet()) { classes.add(entry.getValue()); } return classes; } @Override - public ClassReader getClassReader(ModuleData res) { + public ClassReader getClassReader(ModuleEntry res) { return newClassReader(res.getBytes()); } } @@ -176,7 +175,7 @@ final class AsmPoolImpl implements AsmModulePool { public void addResourceFile(ResourceFile resFile) { Objects.requireNonNull(resFile); String path = toResourceNamePath(resFile.getPath()); - ModuleData res = Pool.newResource(path, resFile.getContent()); + ModuleEntry res = ModuleEntry.create(path, resFile.getContent()); transformedResources.put(resFile.getPath(), res); } @@ -191,7 +190,7 @@ final class AsmPoolImpl implements AsmModulePool { Objects.requireNonNull(resourceName); String path = toResourceNamePath(resourceName); // do we have a resource? - ModuleData res = transformedResources.get(resourceName); + ModuleEntry res = transformedResources.get(resourceName); if (res == null) { res = inputResources.get(resourceName); if (res == null) { @@ -212,7 +211,7 @@ final class AsmPoolImpl implements AsmModulePool { @Override public ResourceFile getResourceFile(String name) { Objects.requireNonNull(name); - ModuleData res = transformedResources.get(name); + ModuleEntry res = transformedResources.get(name); ResourceFile resFile = null; if (res != null) { resFile = getResourceFile(res); @@ -226,24 +225,24 @@ final class AsmPoolImpl implements AsmModulePool { * @return The array of transformed classes. */ @Override - public Collection getResourceFiles() { - List resources = new ArrayList<>(); - for (Entry entry : transformedResources.entrySet()) { + public Collection getResourceFiles() { + List resources = new ArrayList<>(); + for (Entry entry : transformedResources.entrySet()) { resources.add(entry.getValue()); } return resources; } @Override - public ResourceFile getResourceFile(ModuleData res) { + public ResourceFile getResourceFile(ModuleEntry res) { return new ResourceFile(toJavaBinaryResourceName(res.getPath()), res.getBytes()); } } - private final Pool jimageResources; - private final Map inputClasses; - private final Map inputResources; + private final ModulePool jimageResources; + private final Map inputClasses; + private final Map inputResources; private final Map inputClassPackageMapping; private final Map inputOtherPackageMapping; @@ -254,9 +253,9 @@ final class AsmPoolImpl implements AsmModulePool { private Sorter sorter; - private final Map transformedClasses + private final Map transformedClasses = new LinkedHashMap<>(); - private final Map transformedResources + private final Map transformedResources = new LinkedHashMap<>(); private final List forgetResources = new ArrayList<>(); private final Map newPackageMapping = new HashMap<>(); @@ -274,7 +273,7 @@ final class AsmPoolImpl implements AsmModulePool { * @param pools The resource pools. * @param descriptor The module descriptor. */ - AsmPoolImpl(Pool inputResources, String moduleName, + AsmPoolImpl(ModulePool inputResources, String moduleName, AsmPools pools, ModuleDescriptor descriptor) { Objects.requireNonNull(inputResources); @@ -285,11 +284,11 @@ final class AsmPoolImpl implements AsmModulePool { this.moduleName = moduleName; this.pools = pools; this.descriptor = descriptor; - Map classes = new LinkedHashMap<>(); - Map resources = new LinkedHashMap<>(); + Map classes = new LinkedHashMap<>(); + Map resources = new LinkedHashMap<>(); Map packageClassToModule = new HashMap<>(); Map packageOtherToModule = new HashMap<>(); - for (ModuleData res : inputResources.getContent()) { + inputResources.entries().forEach(res -> { if (res.getPath().endsWith(".class")) { classes.put(toJavaBinaryClassName(res.getPath()), res); } else { @@ -305,7 +304,7 @@ final class AsmPoolImpl implements AsmModulePool { packageOtherToModule.put(split[1], res.getModule()); } } - } + }); this.inputClasses = Collections.unmodifiableMap(classes); this.inputResources = Collections.unmodifiableMap(resources); @@ -356,7 +355,7 @@ final class AsmPoolImpl implements AsmModulePool { * @return The array of classes. */ @Override - public Collection getClasses() { + public Collection getClasses() { return inputClasses.values(); } @@ -367,7 +366,7 @@ final class AsmPoolImpl implements AsmModulePool { * @return The array of classes. */ @Override - public Collection getResourceFiles() { + public Collection getResourceFiles() { return inputResources.values(); } @@ -385,7 +384,7 @@ final class AsmPoolImpl implements AsmModulePool { @Override public ResourceFile getResourceFile(String binaryName) { Objects.requireNonNull(binaryName); - ModuleData res = inputResources.get(binaryName); + ModuleEntry res = inputResources.get(binaryName); ResourceFile resFile = null; if (res != null) { resFile = getResourceFile(res); @@ -402,7 +401,7 @@ final class AsmPoolImpl implements AsmModulePool { @Override public ClassReader getClassReader(String binaryName) { Objects.requireNonNull(binaryName); - ModuleData res = inputClasses.get(binaryName); + ModuleEntry res = inputClasses.get(binaryName); ClassReader reader = null; if (res != null) { reader = getClassReader(res); @@ -411,13 +410,13 @@ final class AsmPoolImpl implements AsmModulePool { } @Override - public ResourceFile getResourceFile(ModuleData res) { + public ResourceFile getResourceFile(ModuleEntry res) { return new ResourceFile(toJavaBinaryResourceName(res.getPath()), res.getBytes()); } @Override - public ClassReader getClassReader(ModuleData res) { + public ClassReader getClassReader(ModuleEntry res) { return newClassReader(res.getBytes()); } @@ -505,7 +504,7 @@ final class AsmPoolImpl implements AsmModulePool { @Override public void visitClassReaders(ClassReaderVisitor visitor) { Objects.requireNonNull(visitor); - for (ModuleData res : getClasses()) { + for (ModuleEntry res : getClasses()) { ClassReader reader = newClassReader(res.getBytes()); ClassWriter writer = visitor.visit(reader); if (writer != null) { @@ -523,7 +522,7 @@ final class AsmPoolImpl implements AsmModulePool { @Override public void visitResourceFiles(ResourceFileVisitor visitor) { Objects.requireNonNull(visitor); - for (ModuleData resource : getResourceFiles()) { + for (ModuleEntry resource : getResourceFiles()) { ResourceFile resFile = new ResourceFile(toJavaBinaryResourceName(resource.getPath()), resource.getBytes()); @@ -540,18 +539,18 @@ final class AsmPoolImpl implements AsmModulePool { * been set, it is used to sort the returned resources. * */ @Override - public void fillOutputResources(Pool outputResources) { + public void fillOutputResources(ModulePool outputResources) { List added = new ArrayList<>(); // If the sorter is null, use the input order. // New resources are added at the end // First input classes that have not been removed - Pool output = new PoolImpl(outputResources.getByteOrder(), - ((PoolImpl)outputResources).getStringTable()); - for (ModuleData inResource : jimageResources.getContent()) { + ModulePool output = new ModulePoolImpl(outputResources.getByteOrder(), + ((ModulePoolImpl)outputResources).getStringTable()); + jimageResources.entries().forEach(inResource -> { if (!forgetResources.contains(inResource.getPath())) { - ModuleData resource = inResource; + ModuleEntry resource = inResource; // Do we have a transformed class with the same name? - ModuleData res = transformedResources. + ModuleEntry res = transformedResources. get(toJavaBinaryResourceName(inResource.getPath())); if (res != null) { resource = res; @@ -565,10 +564,10 @@ final class AsmPoolImpl implements AsmModulePool { output.add(resource); added.add(resource.getPath()); } - } + }); // Then new resources - for (Map.Entry entry : transformedResources.entrySet()) { - ModuleData resource = entry.getValue(); + for (Map.Entry entry : transformedResources.entrySet()) { + ModuleEntry resource = entry.getValue(); if (!forgetResources.contains(resource.getPath())) { if (!added.contains(resource.getPath())) { output.add(resource); @@ -576,8 +575,8 @@ final class AsmPoolImpl implements AsmModulePool { } } // And new classes - for (Map.Entry entry : transformedClasses.entrySet()) { - ModuleData resource = entry.getValue(); + for (Map.Entry entry : transformedClasses.entrySet()) { + ModuleEntry resource = entry.getValue(); if (!forgetResources.contains(resource.getPath())) { if (!added.contains(resource.getPath())) { output.add(resource); diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java index bbb2d5403f8..53742ee5ad7 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/asm/AsmPools.java @@ -41,11 +41,11 @@ import java.util.Objects; import java.util.Set; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.ClassWriter; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.internal.plugins.asm.AsmPool.Sorter; +import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModulePool; /** * A container for pools of ClassReader and other resource files. A pool of all @@ -97,10 +97,10 @@ public final class AsmPools { } @Override - public Collection getClasses() { - List all = new ArrayList<>(); + public Collection getClasses() { + List all = new ArrayList<>(); visitAllPools((AsmModulePool pool) -> { - for (Pool.ModuleData rf : pool.getTransformedClasses().getClasses()) { + for (ModuleEntry rf : pool.getTransformedClasses().getClasses()) { all.add(rf); } }); @@ -108,7 +108,7 @@ public final class AsmPools { } @Override - public ClassReader getClassReader(Pool.ModuleData res) { + public ClassReader getClassReader(ModuleEntry res) { return visitPools((AsmModulePool pool) -> { return pool.getTransformedClasses().getClassReader(res); }); @@ -140,10 +140,10 @@ public final class AsmPools { } @Override - public Collection getResourceFiles() { - List all = new ArrayList<>(); + public Collection getResourceFiles() { + List all = new ArrayList<>(); visitAllPools((AsmModulePool pool) -> { - for (Pool.ModuleData rf : pool.getTransformedResourceFiles().getResourceFiles()) { + for (ModuleEntry rf : pool.getTransformedResourceFiles().getResourceFiles()) { all.add(rf); } }); @@ -151,7 +151,7 @@ public final class AsmPools { } @Override - public ResourceFile getResourceFile(Pool.ModuleData res) { + public ResourceFile getResourceFile(ModuleEntry res) { return visitPools((AsmModulePool pool) -> { return pool.getTransformedResourceFiles().getResourceFile(res); }); @@ -175,10 +175,10 @@ public final class AsmPools { } @Override - public Collection getClasses() { - List all = new ArrayList<>(); + public Collection getClasses() { + List all = new ArrayList<>(); visitAllPools((AsmModulePool pool) -> { - for (Pool.ModuleData rf : pool.getClasses()) { + for (ModuleEntry rf : pool.getClasses()) { all.add(rf); } }); @@ -186,10 +186,10 @@ public final class AsmPools { } @Override - public Collection getResourceFiles() { - List all = new ArrayList<>(); + public Collection getResourceFiles() { + List all = new ArrayList<>(); visitAllPools((AsmModulePool pool) -> { - for (Pool.ModuleData rf : pool.getResourceFiles()) { + for (ModuleEntry rf : pool.getResourceFiles()) { all.add(rf); } }); @@ -211,14 +211,14 @@ public final class AsmPools { } @Override - public ResourceFile getResourceFile(Pool.ModuleData res) { + public ResourceFile getResourceFile(ModuleEntry res) { return visitPools((AsmModulePool pool) -> { return pool.getResourceFile(res); }); } @Override - public ClassReader getClassReader(Pool.ModuleData res) { + public ClassReader getClassReader(ModuleEntry res) { return visitPoolsEx((AsmModulePool pool) -> { return pool.getClassReader(res); }); @@ -239,7 +239,7 @@ public final class AsmPools { } @Override - public void fillOutputResources(Pool outputResources) { + public void fillOutputResources(ModulePool outputResources) { AsmPools.this.fillOutputResources(outputResources); } @@ -324,15 +324,15 @@ public final class AsmPools { * * @param inputResources The raw resources to build the pool from. */ - public AsmPools(Pool inputResources) { + public AsmPools(ModulePool inputResources) { Objects.requireNonNull(inputResources); - Map resPools = new LinkedHashMap<>(); + Map resPools = new LinkedHashMap<>(); Map descriptors = new HashMap<>(); - for (Pool.ModuleData res : inputResources.getContent()) { - Pool p = resPools.get(res.getModule()); + inputResources.entries().forEach(res -> { + ModulePool p = resPools.get(res.getModule()); if (p == null) { - p = new PoolImpl(inputResources.getByteOrder(), - ((PoolImpl)inputResources).getStringTable()); + p = new ModulePoolImpl(inputResources.getByteOrder(), + ((ModulePoolImpl)inputResources).getStringTable()); resPools.put(res.getModule(), p); } if (res.getPath().endsWith("module-info.class")) { @@ -341,11 +341,11 @@ public final class AsmPools { descriptors.put(res.getModule(), descriptor); } p.add(res); - } + }); poolsArray = new AsmModulePool[resPools.size()]; int i = 0; - for (Entry entry : resPools.entrySet()) { + for (Entry entry : resPools.entrySet()) { ModuleDescriptor descriptor = descriptors.get(entry.getKey()); if (descriptor == null) { throw new PluginException("module-info.class not found for " + entry.getKey() + " module"); @@ -405,7 +405,7 @@ public final class AsmPools { * * @param outputResources The pool used to fill the jimage. */ - public void fillOutputResources(Pool outputResources) { + public void fillOutputResources(ModulePool outputResources) { // First sort modules List modules = new ArrayList<>(); for (String k : pools.keySet()) { @@ -414,8 +414,8 @@ public final class AsmPools { if (moduleSorter != null) { modules = moduleSorter.sort(modules); } - Pool output = new PoolImpl(outputResources.getByteOrder(), - ((PoolImpl)outputResources).getStringTable()); + ModulePool output = new ModulePoolImpl(outputResources.getByteOrder(), + ((ModulePoolImpl)outputResources).getStringTable()); for (String mn : modules) { AsmPool pool = pools.get(mn); pool.fillOutputResources(output); @@ -423,17 +423,17 @@ public final class AsmPools { sort(outputResources, output, global.sorter); } - static void sort(Pool outputResources, - Pool transientOutput, Sorter sorter) { + static void sort(ModulePool outputResources, + ModulePool transientOutput, Sorter sorter) { if (sorter != null) { List order = sorter.sort(transientOutput); for (String s : order) { - outputResources.add(transientOutput.get(s)); + outputResources.add(transientOutput.findEntry(s).get()); } } else { - for (ModuleData res : transientOutput.getContent()) { + transientOutput.entries().forEach(res-> { outputResources.add(res); - } + }); } } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ExecutableImage.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ExecutableImage.java index d5e767cd553..499d23dd450 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ExecutableImage.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ExecutableImage.java @@ -24,66 +24,41 @@ */ package jdk.tools.jlink.plugin; -import java.nio.file.Files; import java.nio.file.Path; -import java.util.Collections; import java.util.List; -import java.util.Objects; import java.util.Set; /** - * An executable runtime image. Instance of this class contains the information - * needed to create image processes. + * An executable runtime image. Contains the information about the executable + * image created. */ -public abstract class ExecutableImage { - - private final Path home; - private final List args; - private final Set modules; - - protected ExecutableImage(Path home, Set modules, - List args) { - Objects.requireNonNull(home); - Objects.requireNonNull(args); - if (!Files.exists(home)) { - throw new IllegalArgumentException("Invalid image home"); - } - this.home = home; - this.modules = Collections.unmodifiableSet(modules); - this.args = Collections.unmodifiableList(args); - } +public interface ExecutableImage { /** * Image home directory, * * @return The home directory. */ - public Path getHome() { - return home; - } + public Path getHome(); /** * The names of the modules located in the image. * * @return The set of modules. */ - public Set getModules() { - return modules; - } + public Set getModules(); /** * The list of arguments required to execute the image. * * @return The list of arguments. */ - public List getExecutionArgs() { - return args; - } + public List getExecutionArgs(); /** * Store new arguments required to execute the image. * * @param args Additional arguments */ - public abstract void storeLaunchArgs(List args); + public void storeLaunchArgs(List args); } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/LinkModule.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/LinkModule.java new file mode 100644 index 00000000000..f516d8d0494 --- /dev/null +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/LinkModule.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.tools.jlink.plugin; + +import java.lang.module.ModuleDescriptor; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Stream; + +/** + * Link-time representation of a Java module. + */ +public interface LinkModule { + + /** + * The module name. + * + * @return The name. + */ + public String getName(); + + /** + * Retrieves a LinkModuleEntry from the given path (e.g: + * /mymodule/com.foo.bar/MyClass.class) + * + * @param path The piece of data path. + * @return A LinkModuleEntry of the given path, if found. + */ + public Optional findEntry(String path); + + /** + * The module descriptor of this module. + * + * @return The module descriptor. + */ + public ModuleDescriptor getDescriptor(); + + /** + * Add a LinkModuleEntry to this module. + * + * @param data The LinkModuleEntry to add. + */ + public void add(ModuleEntry data); + + /** + * Retrieves all the packages located in this module. + * + * @return The set of packages. + */ + public Set getAllPackages(); + + /** + * Retrieves the stream of LinkModuleEntry. + * + * @return The LinkModuleEntry stream. + */ + public Stream entries(); + + /** + * Return the number of LinkModuleEntry count in this LinkModule. + * + * @return the entry count. + */ + public int getEntryCount(); +} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java new file mode 100644 index 00000000000..61f828fc914 --- /dev/null +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModuleEntry.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.tools.jlink.plugin; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.Objects; +import jdk.tools.jlink.internal.ImageFileCreator; +import jdk.tools.jlink.internal.ModuleEntryImpl; + +/** + * A LinkModuleEntry is the elementary unit of data inside an image. It is + * generally a file. e.g.: a java class file, a resource file, a shared library, + * ... + *
      + * A LinkModuleEntry is identified by a path of the form: + *
        + *
      • For jimage content: /{module name}/{package1}/.../{packageN}/{file + * name}
      • + *
      • For other files (shared lib, launchers, config, ...):/{module name}/ + * {@literal bin|conf|native}/{dir1}>/.../{dirN}/{file name}
      • + *
      + */ +public interface ModuleEntry { + + /** + * Type of module data. + *
    • + *
        CLASS_OR_RESOURCE: A java class or resource file.
      + *
        CONFIG: A configuration file.
      + *
        NATIVE_CMD: A native process launcher.
      + *
        NATIVE_LIB: A native library.
      + *
        OTHER: Other kind of file.
      + *
    • + */ + public enum Type { + CLASS_OR_RESOURCE, + CONFIG, + NATIVE_CMD, + NATIVE_LIB, + OTHER + } + /** + * The LinkModuleEntry module name. + * + * @return The module name. + */ + public String getModule(); + + /** + * The LinkModuleEntry path. + * + * @return The module path. + */ + public String getPath(); + + /** + * The LinkModuleEntry's type. + * + * @return The data type. + */ + public Type getType(); + + /** + * The LinkModuleEntry content as an array of byte. + * + * @return An Array of bytes. + */ + public byte[] getBytes(); + + /** + * The LinkModuleEntry content length. + * + * @return The length. + */ + public long getLength(); + + /** + * The LinkModuleEntry stream. + * + * @return The module data stream. + */ + public InputStream stream(); + + + /** + * Create a LinkModuleEntry located inside a jimage file. Such + * LinkModuleEntry has a Type being equals to CLASS_OR_RESOURCE. + * + * @param path The complete resource path (contains the module radical). + * @param content The resource content. + * @param size The content size. + * @return A new LinkModuleEntry. + */ + public static ModuleEntry create(String path, InputStream content, long size) { + Objects.requireNonNull(path); + Objects.requireNonNull(content); + String[] split = ImageFileCreator.splitPath(path); + String module = split[0]; + return new ModuleEntryImpl(module, path, Type.CLASS_OR_RESOURCE, content, size); + } + + /** + * Create a LinkModuleEntry for a file that will be located inside a jimage + * file. + * + * @param path The resource path. + * @param content The resource content. + * @return A new LinkModuleEntry. + */ + public static ModuleEntry create(String path, byte[] content) { + return create(path, new ByteArrayInputStream(content), + content.length); + } + + /** + * Create a LinkModuleEntry for a file that will be located outside a jimage + * file. + * + * @param module The module in which this files is located. + * @param path The file path locator (doesn't contain the module name). + * @param type The LinkModuleEntry type. + * @param content The file content. + * @param size The content size. + * @return A new LinkModuleEntry. + */ + public static ModuleEntry create(String module, String path, ModuleEntry.Type type, + InputStream content, long size) { + Objects.requireNonNull(path); + Objects.requireNonNull(content); + return new ModuleEntryImpl(module, path, type, content, size); + } +} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModulePool.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModulePool.java new file mode 100644 index 00000000000..4d0f230e1c6 --- /dev/null +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/ModulePool.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.tools.jlink.plugin; + +import java.nio.ByteOrder; +import java.util.Map; +import java.util.Optional; +import java.util.function.Function; +import java.util.stream.Stream; + +/** + * Pool of module data. + */ +public interface ModulePool { +/** + * Is this a read-only ModulePool? + * + * @return true if this is a read-only configuration. + */ + public boolean isReadOnly(); + + /** + * Add a ModuleEntry. + * + * @param data The ModuleEntry to add. + */ + public void add(ModuleEntry data); + /** + * Retrieves the module for the provided name. + * + * @param name The module name + * @return the module of matching name, if found + */ + public Optional findModule(String name); + + /** + * The stream of modules contained in this ModulePool. + * + * @return The stream of modules. + */ + public Stream modules(); + + /** + * Return the number of LinkModule count in this ModulePool. + * + * @return the module count. + */ + public int getModuleCount(); + + /** + * Get all ModuleEntry contained in this ModulePool instance. + * + * @return The stream of LinkModuleEntries. + */ + public Stream entries(); + + /** + * Return the number of ModuleEntry count in this ModulePool. + * + * @return the entry count. + */ + public int getEntryCount(); + + /** + * Get the ModuleEntry for the passed path. + * + * @param path A data path + * @return A ModuleEntry instance or null if the data is not found + */ + public Optional findEntry(String path); + + /** + * Check if the ModulePool contains the given ModuleEntry. + * + * @param data The module data to check existence for. + * @return The module data or null if not found. + */ + public boolean contains(ModuleEntry data); + + /** + * Check if the ModulePool contains some content at all. + * + * @return True, no content, false otherwise. + */ + public boolean isEmpty(); + + /** + * Visit each ModuleEntry in this ModulePool to transform it and copy + * the transformed ModuleEntry to the output ModulePool. + * + * @param transform The function called for each ModuleEntry found in the + * ModulePool. The transform function should return a ModuleEntry + * instance which will be added to the output or it should return null if + * the passed ModuleEntry is to be ignored for the output. + * + * @param output The ModulePool to be filled with Visitor returned + * ModuleEntry. + */ + public void transformAndCopy(Function transform, ModulePool output); + + /** + * The ByteOrder currently in use when generating the jimage file. + * + * @return The ByteOrder. + */ + public ByteOrder getByteOrder(); + + /** + * Release properties such as OS, CPU name, version etc. + * + * @return the release properties + */ + public Map getReleaseProperties(); +} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java index 56e51bc9bc5..30633b546d3 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Plugin.java @@ -26,7 +26,6 @@ package jdk.tools.jlink.plugin; import java.util.Collections; import java.util.EnumSet; -import java.util.List; import java.util.Map; import java.util.Set; import jdk.tools.jlink.internal.plugins.PluginsResourceBundle; @@ -36,14 +35,6 @@ import jdk.tools.jlink.internal.plugins.PluginsResourceBundle; */ public interface Plugin { - /** - * Type of plugin. - */ - public interface PluginType { - - public String getName(); - } - /** * Order of categories: *
        @@ -53,28 +44,29 @@ public interface Plugin { *
      1. MODULEINFO_TRANSFORMER: Transform only module-info.class
      2. *
      3. SORTER: Sort resources within the resource container.
      4. *
      5. COMPRESSOR: Compress resource within the resouce containers.
      6. + *
      7. METAINFO_ADDER: Added meta info (like release, copyright etc.)
      8. *
      9. VERIFIER: Does some image verification.
      10. *
      11. PROCESSOR: Does some post processing on image.
      12. *
      13. PACKAGER: Final processing
      14. *
      */ - public enum CATEGORY implements PluginType { + public enum Category { FILTER("FILTER"), TRANSFORMER("TRANSFORMER"), MODULEINFO_TRANSFORMER("MODULEINFO_TRANSFORMER"), SORTER("SORTER"), COMPRESSOR("COMPRESSOR"), + METAINFO_ADDER("METAINFO_ADDER"), VERIFIER("VERIFIER"), PROCESSOR("PROCESSOR"), PACKAGER("PACKAGER"); private final String name; - CATEGORY(String name) { + Category(String name) { this.name = name; } - @Override public String getName() { return name; } @@ -91,7 +83,7 @@ public interface Plugin { * {@link #getStateDescription() getStateDescription} method * */ - public enum STATE { + public enum State { DISABLED, AUTO_ENABLED, FUNCTIONAL @@ -101,7 +93,7 @@ public interface Plugin { * The Plugin set of types. * @return The set of types. */ - public default Set getType() { + public default Set getType() { return Collections.emptySet(); } @@ -109,8 +101,8 @@ public interface Plugin { * The Plugin set of states. * @return The set of states. */ - public default Set getState() { - return EnumSet.of(STATE.FUNCTIONAL); + public default Set getState() { + return EnumSet.of(State.FUNCTIONAL); } /** @@ -191,7 +183,7 @@ public interface Plugin { * @return A status description. */ public default String getStateDescription() { - return getState().contains(STATE.FUNCTIONAL) + return getState().contains(State.FUNCTIONAL) ? PluginsResourceBundle.getMessage("main.status.ok") : PluginsResourceBundle.getMessage("main.status.not.ok"); } @@ -206,18 +198,4 @@ public interface Plugin { */ public default void configure(Map config) { } - - /** - * Configure the plugin based on the passed configuration. - * This method is called prior to invoke the plugin. - * - * @param config The plugin configuration. - * @param ctx The plugin context - * @throws IllegalArgumentException if a mandatory argument is missing or - * if an argument has invalid value. - * - */ - public default void configure(Map config, PluginContext ctx) { - configure(config); - } } diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java deleted file mode 100644 index 9e5a4a7df61..00000000000 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.tools.jlink.plugin; - -import java.util.Properties; - -/** - * Interface to plugin (container) context. - */ -public interface PluginContext { - /** - * Returns 'release' properties - */ - public Properties getReleaseProperties(); -} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java deleted file mode 100644 index 380ca41ac1a..00000000000 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java +++ /dev/null @@ -1,528 +0,0 @@ -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package jdk.tools.jlink.plugin; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.UncheckedIOException; -import java.lang.module.ModuleDescriptor; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import jdk.tools.jlink.internal.ImageFileCreator; -import jdk.tools.jlink.internal.plugins.FileCopierPlugin; - -/** - * Pool of module data. - * - */ -public abstract class Pool { - - /** - * Interface to visit the content of a Pool. - */ - public interface Visitor { - - /** - * Called for each visited ModuleData. - * - * @param content A ModuleData - * @return A ModuleData instance or null if the passed ModuleData is to - * be removed from the image. - * @throws PluginException - */ - public ModuleData visit(ModuleData content); - } - - /** - * Type of module data. - *
    • - *
        CLASS_OR_RESOURCE: A java class or resource file.
      - *
        CONFIG: A configuration file.
      - *
        NATIVE_CMD: A native process launcher.
      - *
        NATIVE_LIB: A native library.
      - *
        OTHER: Other kind of file.
      - *
    • - */ - public static enum ModuleDataType { - - CLASS_OR_RESOURCE, - CONFIG, - NATIVE_CMD, - NATIVE_LIB, - OTHER; - } - - /** - * A module in the pool. - */ - public interface Module { - - /** - * The module name. - * - * @return The name. - */ - public String getName(); - - /** - * Retrieves a ModuleData from a path (e.g: - * /mymodule/com.foo.bar/MyClass.class) - * - * @param path The piece of data path. - * @return A ModuleData or null if the path doesn't identify a - * ModuleData. - */ - public ModuleData get(String path); - - /** - * The module descriptor of this module. - * - * @return The module descriptor. - */ - public ModuleDescriptor getDescriptor(); - - /** - * Add a ModuleData to this module. - * - * @param data The ModuleData to add. - */ - public void add(ModuleData data); - - /** - * Retrieves all the packages located in this module. - * - * @return The set of packages. - */ - public Set getAllPackages(); - - /** - * Retrieves the collection of ModuleData. - * - * @return The ModuleData collection. - */ - public Collection getContent(); - - } - - private class ModuleImpl implements Module { - - private final Map moduleContent = new LinkedHashMap<>(); - private ModuleDescriptor descriptor; - private final String name; - - private ModuleImpl(String name) { - this.name = name; - } - - @Override - public String getName() { - return name; - } - - @Override - public ModuleData get(String path) { - if (!path.startsWith("/")) { - path = "/" + path; - } - if (!path.startsWith("/" + name)) { - path = "/" + name + path; - } - return moduleContent.get(path); - } - - @Override - public ModuleDescriptor getDescriptor() { - if (descriptor == null) { - String p = "/" + name + "/module-info.class"; - ModuleData content = moduleContent.get(p); - if (content == null) { - throw new PluginException("No module-info for " + name - + " module"); - } - ByteBuffer bb = ByteBuffer.wrap(content.getBytes()); - descriptor = ModuleDescriptor.read(bb); - } - return descriptor; - } - - @Override - public void add(ModuleData data) { - if (isReadOnly()) { - throw new PluginException("pool is readonly"); - } - Objects.requireNonNull(data); - if (!data.getModule().equals(name)) { - throw new PluginException("Can't add resource " + data.getPath() - + " to module " + name); - } - Pool.this.add(data); - } - - @Override - public Set getAllPackages() { - Set pkgs = new HashSet<>(); - moduleContent.values().stream().filter(m -> m.getType(). - equals(ModuleDataType.CLASS_OR_RESOURCE)).forEach((res) -> { - // Module metadata only contains packages with .class files - if (ImageFileCreator.isClassPackage(res.getPath())) { - String[] split = ImageFileCreator.splitPath(res.getPath()); - String pkg = split[1]; - if (pkg != null && !pkg.isEmpty()) { - pkgs.add(pkg); - } - } - }); - return pkgs; - } - - @Override - public String toString() { - return getName(); - } - - @Override - public Collection getContent() { - return Collections.unmodifiableCollection(moduleContent.values()); - } - } - - /** - * A ModuleData is the elementary unit of data inside an image. It is - * generally a file. e.g.: a java class file, a resource file, a shared - * library, ... - *
      - * A ModuleData is identified by a path of the form: - *
        - *
      • For jimage content: /{module name}/{package1}/.../{packageN}/{file - * name}
      • - *
      • For other files (shared lib, launchers, config, ...):/{module name}/ - * {@literal bin|conf|native}/{dir1}/.../{dirN}/{file name}
      • - *
      - */ - public static class ModuleData { - - private final ModuleDataType type; - private final String path; - private final String module; - private final long length; - private final InputStream stream; - private byte[] buffer; - - /** - * Create a new ModuleData. - * - * @param module The module name. - * @param path The data path identifier. - * @param type The data type. - * @param stream The data content stream. - * @param length The stream length. - */ - public ModuleData(String module, String path, ModuleDataType type, - InputStream stream, long length) { - Objects.requireNonNull(module); - Objects.requireNonNull(path); - Objects.requireNonNull(type); - Objects.requireNonNull(stream); - this.path = path; - this.type = type; - this.module = module; - this.stream = stream; - this.length = length; - } - - /** - * The ModuleData module name. - * - * @return The module name. - */ - public final String getModule() { - return module; - } - - /** - * The ModuleData path. - * - * @return The module path. - */ - public final String getPath() { - return path; - } - - /** - * The ModuleData type. - * - * @return The data type. - */ - public final ModuleDataType getType() { - return type; - } - - /** - * The ModuleData content as an array of byte. - * - * @return An Array of bytes. - */ - public byte[] getBytes() { - if (buffer == null) { - try { - buffer = stream.readAllBytes(); - } catch (IOException ex) { - throw new UncheckedIOException(ex); - } - } - return buffer; - } - - /** - * The ModuleData content length. - * - * @return The length. - */ - public long getLength() { - return length; - } - - /** - * The ModuleData stream. - * - * @return The module data stream. - */ - public InputStream stream() { - return stream; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 89 * hash + Objects.hashCode(this.path); - return hash; - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof ModuleData)) { - return false; - } - ModuleData f = (ModuleData) other; - return f.path.equals(path); - } - - @Override - public String toString() { - return getPath(); - } - } - - private final Map resources = new LinkedHashMap<>(); - private final Map modules = new LinkedHashMap<>(); - private final ModuleImpl fileCopierModule = new ModuleImpl(FileCopierPlugin.FAKE_MODULE); - - private final ByteOrder order; - - protected Pool() { - this(ByteOrder.nativeOrder()); - } - - protected Pool(ByteOrder order) { - Objects.requireNonNull(order); - this.order = order; - } - - /** - * Read only state. No data can be added to a ReadOnly Pool. - * - * @return true if readonly false otherwise. - */ - public abstract boolean isReadOnly(); - - /** - * Add a ModuleData. - * - * @param data The ModuleData to add. - */ - public void add(ModuleData data) { - if (isReadOnly()) { - throw new PluginException("pool is readonly"); - } - Objects.requireNonNull(data); - if (resources.get(data.getPath()) != null) { - throw new PluginException("Resource " + data.getPath() - + " already present"); - } - String modulename = data.getModule(); - ModuleImpl m = modules.get(modulename); - // ## TODO: FileCopierPlugin should not add content to a module - // FAKE_MODULE is not really a module to be added in the image - if (FileCopierPlugin.FAKE_MODULE.equals(modulename)) { - m = fileCopierModule; - } - if (m == null) { - m = new ModuleImpl(modulename); - modules.put(modulename, m); - } - resources.put(data.getPath(), data); - m.moduleContent.put(data.getPath(), data); - } - - /** - * Retrieves the module for the provided name. - * - * @param name The module name - * @return the module or null if the module doesn't exist. - */ - public Module getModule(String name) { - Objects.requireNonNull(name); - return modules.get(name); - } - - /** - * The collection of modules contained in this pool. - * - * @return The collection of modules. - */ - public Collection getModules() { - return Collections.unmodifiableCollection(modules.values()); - } - - /** - * Get all ModuleData contained in this pool instance. - * - * @return The collection of resources; - */ - public Collection getContent() { - return Collections.unmodifiableCollection(resources.values()); - } - - /** - * Get the ModuleData for the passed path. - * - * @param path A data path - * @return A ModuleData instance or null if the data is not found - */ - public ModuleData get(String path) { - Objects.requireNonNull(path); - return resources.get(path); - } - - /** - * Check if the pool contains this data. - * - * @param data The module data to check existence for. - * @return The module data or null if not found. - */ - public boolean contains(ModuleData data) { - Objects.requireNonNull(data); - return get(data.getPath()) != null; - } - - /** - * Check if the Pool contains some content. - * - * @return True, no content, false otherwise. - */ - public boolean isEmpty() { - return resources.isEmpty(); - } - - /** - * Visit the pool. - * - * @param visitor The Visitor called for each ModuleData found in the pool. - * @param output The pool to be filled with Visitor returned ModuleData. - */ - public void visit(Visitor visitor, Pool output) { - for (ModuleData resource : getContent()) { - ModuleData res = visitor.visit(resource); - if (res != null) { - output.add(res); - } - } - } - - /** - * The ByteOrder currently in use when generating the jimage file. - * - * @return The ByteOrder. - */ - public ByteOrder getByteOrder() { - return order; - } - - /** - * Create a ModuleData located inside a jimage file. Such ModuleData has a - * ModuleDataType being equals to CLASS_OR_RESOURCE. - * - * @param path The complete resource path (contains the module radical). - * @param content The resource content. - * @param size The content size. - * @return A new ModuleData. - */ - public static ModuleData newResource(String path, InputStream content, long size) { - Objects.requireNonNull(path); - Objects.requireNonNull(content); - String[] split = ImageFileCreator.splitPath(path); - String module = split[0]; - return new ModuleData(module, path, ModuleDataType.CLASS_OR_RESOURCE, content, size); - } - - /** - * Create a ModuleData for a file that will be located inside a jimage file. - * - * @param path The resource path. - * @param content The resource content. - * @return A new ModuleData. - */ - public static ModuleData newResource(String path, byte[] content) { - return newResource(path, new ByteArrayInputStream(content), - content.length); - } - - /** - * Create a ModuleData for a file that will be located outside a jimage - * file. - * - * @param module The module in which this files is located. - * @param path The file path locator (doesn't contain the module name). - * @param type The ModuleData type. - * @param content The file content. - * @param size The content size. - * @return A new ModuleData. - */ - public static ModuleData newImageFile(String module, String path, ModuleDataType type, - InputStream content, long size) { - Objects.requireNonNull(path); - Objects.requireNonNull(content); - return new ModuleData(module, path, type, content, size); - } - -} diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/TransformerPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/TransformerPlugin.java index 4af4897e636..15133221c43 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/TransformerPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/TransformerPlugin.java @@ -40,5 +40,5 @@ public interface TransformerPlugin extends Plugin { * * @throws PluginException */ - public void visit(Pool in, Pool out); + public void visit(ModulePool in, ModulePool out); } diff --git a/jdk/src/jdk.jlink/share/classes/module-info.java b/jdk/src/jdk.jlink/share/classes/module-info.java index 49e426fed12..c23116404ac 100644 --- a/jdk/src/jdk.jlink/share/classes/module-info.java +++ b/jdk/src/jdk.jlink/share/classes/module-info.java @@ -24,9 +24,7 @@ */ module jdk.jlink { - exports jdk.tools.jlink; exports jdk.tools.jlink.plugin; - exports jdk.tools.jlink.builder; requires jdk.internal.opt; requires jdk.jdeps; @@ -46,5 +44,5 @@ module jdk.jlink { provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ExcludeVMPlugin; provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.IncludeLocalesPlugin; provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.GenerateJLIClassesPlugin; - provides jdk.tools.jlink.plugin.PostProcessorPlugin with jdk.tools.jlink.internal.plugins.ReleaseInfoPlugin; + provides jdk.tools.jlink.plugin.TransformerPlugin with jdk.tools.jlink.internal.plugins.ReleaseInfoPlugin; } diff --git a/jdk/test/tools/jlink/DefaultProviderTest.java b/jdk/test/tools/jlink/DefaultProviderTest.java index 22c68287d5c..c10e9d37060 100644 --- a/jdk/test/tools/jlink/DefaultProviderTest.java +++ b/jdk/test/tools/jlink/DefaultProviderTest.java @@ -33,7 +33,7 @@ import java.util.Set; import jdk.tools.jlink.internal.PluginRepository; import jdk.tools.jlink.plugin.Plugin; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; import tests.Helper; @@ -65,26 +65,26 @@ public class DefaultProviderTest { private boolean enabled = true; @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.TRANSFORMER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.TRANSFORMER); return Collections.unmodifiableSet(set); } @Override - public Set getState() { - return enabled ? EnumSet.of(STATE.AUTO_ENABLED, STATE.FUNCTIONAL) - : EnumSet.of(STATE.DISABLED); + public Set getState() { + return enabled ? EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL) + : EnumSet.of(State.DISABLED); } @Override - public void visit(Pool in, Pool out) { + public void visit(ModulePool in, ModulePool out) { if (!enabled) { throw new PluginException(NAME + " was set"); } DefaultProviderTest.isNewPluginsCalled = true; - in.visit((Pool.ModuleData content) -> { + in.transformAndCopy(content -> { return content; }, out); } diff --git a/jdk/test/tools/jlink/ImageFileCreatorTest.java b/jdk/test/tools/jlink/ImageFileCreatorTest.java index 449d950d04d..8e093c69459 100644 --- a/jdk/test/tools/jlink/ImageFileCreatorTest.java +++ b/jdk/test/tools/jlink/ImageFileCreatorTest.java @@ -39,7 +39,7 @@ import jdk.tools.jlink.internal.ImageFileCreator; import jdk.tools.jlink.internal.ImagePluginStack; import jdk.tools.jlink.plugin.ExecutableImage; import jdk.tools.jlink.builder.ImageBuilder; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModulePool; /* @@ -47,6 +47,7 @@ import jdk.tools.jlink.plugin.Pool; * @summary ImageFileCreator class test * @author Jean-Francois Denise * @modules jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.builder * java.base/jdk.internal.jimage * @run main/othervm -verbose:gc -Xmx1g ImageFileCreatorTest */ @@ -214,7 +215,7 @@ public class ImageFileCreatorTest { } @Override - public void storeFiles(Pool content) { + public void storeFiles(ModulePool content) { } }; diff --git a/jdk/test/tools/jlink/ImageFilePoolTest.java b/jdk/test/tools/jlink/ImageFilePoolTest.java index 7d35f9da8d6..1ea0fada3d7 100644 --- a/jdk/test/tools/jlink/ImageFilePoolTest.java +++ b/jdk/test/tools/jlink/ImageFilePoolTest.java @@ -31,11 +31,12 @@ */ import java.io.ByteArrayInputStream; -import jdk.tools.jlink.internal.PoolImpl; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; -import jdk.tools.jlink.plugin.Pool.ModuleDataType; -import jdk.tools.jlink.plugin.Pool.Visitor; +import java.util.Optional; +import java.util.function.Function; +import jdk.tools.jlink.internal.ModuleEntryImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; public class ImageFilePoolTest { public static void main(String[] args) throws Exception { @@ -50,45 +51,45 @@ public class ImageFilePoolTest { private static final String SUFFIX = "END"; private void checkVisitor() throws Exception { - Pool input = new PoolImpl(); + ModulePool input = new ModulePoolImpl(); for (int i = 0; i < 1000; ++i) { String module = "module" + (i / 100); input.add(new InMemoryImageFile(module, "/" + module + "/java/class" + i, - ModuleDataType.CONFIG, "class" + i)); + ModuleEntry.Type.CONFIG, "class" + i)); } - if (input.getContent().size() != 1000) { + if (input.getEntryCount() != 1000) { throw new AssertionError(); } - Pool output = new PoolImpl(); + ModulePool output = new ModulePoolImpl(); ResourceVisitor visitor = new ResourceVisitor(); - input.visit(visitor, output); + input.transformAndCopy(visitor, output); if (visitor.getAmountBefore() == 0) { throw new AssertionError("Resources not found"); } - if (visitor.getAmountBefore() != input.getContent().size()) { + if (visitor.getAmountBefore() != input.getEntryCount()) { throw new AssertionError("Number of visited resources. Expected: " + - visitor.getAmountBefore() + ", got: " + input.getContent().size()); + visitor.getAmountBefore() + ", got: " + input.getEntryCount()); } - if (visitor.getAmountAfter() != output.getContent().size()) { + if (visitor.getAmountAfter() != output.getEntryCount()) { throw new AssertionError("Number of added resources. Expected: " + - visitor.getAmountAfter() + ", got: " + output.getContent().size()); + visitor.getAmountAfter() + ", got: " + output.getEntryCount()); } - for (ModuleData outFile : output.getContent()) { + output.entries().forEach(outFile -> { String path = outFile.getPath().replaceAll(SUFFIX + "$", ""); - ModuleData inFile = input.get(path); - if (inFile == null) { + Optional inFile = input.findEntry(path); + if (!inFile.isPresent()) { throw new AssertionError("Unknown resource: " + path); } - } + }); } - private static class ResourceVisitor implements Visitor { + private static class ResourceVisitor implements Function { private int amountBefore; private int amountAfter; @Override - public ModuleData visit(ModuleData file) { + public ModuleEntry apply(ModuleEntry file) { int index = ++amountBefore % 3; switch (index) { case 0: @@ -113,7 +114,7 @@ public class ImageFilePoolTest { } private void checkNegative() throws Exception { - PoolImpl input = new PoolImpl(); + ModulePoolImpl input = new ModulePoolImpl(); try { input.add(null); throw new AssertionError("NullPointerException is not thrown"); @@ -126,30 +127,30 @@ public class ImageFilePoolTest { } catch (NullPointerException e) { // expected } - if (input.get("unknown") != null) { - throw new AssertionError("ImageFilePool does not return null for unknown file"); + if (input.findEntry("unknown").isPresent()) { + throw new AssertionError("ImageFileModulePool does not return null for unknown file"); } - if (input.contains(new InMemoryImageFile("", "unknown", ModuleDataType.CONFIG, "unknown"))) { + if (input.contains(new InMemoryImageFile("", "unknown", ModuleEntry.Type.CONFIG, "unknown"))) { throw new AssertionError("'contain' returns true for unknown file"); } - input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleDataType.CONFIG, "")); + input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleEntry.Type.CONFIG, "")); try { - input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleDataType.CONFIG, "")); + input.add(new InMemoryImageFile("", "/aaa/bbb", ModuleEntry.Type.CONFIG, "")); throw new AssertionError("Exception expected"); } catch (Exception e) { // expected } input.setReadOnly(); try { - input.add(new InMemoryImageFile("", "/aaa/ccc", ModuleDataType.CONFIG, "")); + input.add(new InMemoryImageFile("", "/aaa/ccc", ModuleEntry.Type.CONFIG, "")); throw new AssertionError("Exception expected"); } catch (Exception e) { // expected } } - private static class InMemoryImageFile extends ModuleData { - public InMemoryImageFile(String module, String path, ModuleDataType type, String content) { + private static class InMemoryImageFile extends ModuleEntryImpl { + public InMemoryImageFile(String module, String path, ModuleEntry.Type type, String content) { super(module, path, type, new ByteArrayInputStream(content.getBytes()), content.getBytes().length); } } diff --git a/jdk/test/tools/jlink/IntegrationTest.java b/jdk/test/tools/jlink/IntegrationTest.java index 951c16cff74..e5637b421a8 100644 --- a/jdk/test/tools/jlink/IntegrationTest.java +++ b/jdk/test/tools/jlink/IntegrationTest.java @@ -39,7 +39,7 @@ import jdk.tools.jlink.Jlink.JlinkConfiguration; import jdk.tools.jlink.Jlink.PluginsConfiguration; import jdk.tools.jlink.builder.DefaultImageBuilder; import jdk.tools.jlink.plugin.ExecutableImage; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.PostProcessorPlugin; import jdk.tools.jlink.plugin.TransformerPlugin; import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin; @@ -56,6 +56,8 @@ import tests.JImageGenerator; * @library ../lib * @modules java.base/jdk.internal.jimage * jdk.jdeps/com.sun.tools.classfile + * jdk.jlink/jdk.tools.jlink + * jdk.jlink/jdk.tools.jlink.builder * jdk.jlink/jdk.tools.jlink.internal * jdk.jlink/jdk.tools.jlink.internal.plugins * jdk.jlink/jdk.tools.jmod @@ -88,9 +90,9 @@ public class IntegrationTest { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.PROCESSOR); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.PROCESSOR); return Collections.unmodifiableSet(set); } @@ -128,18 +130,18 @@ public class IntegrationTest { } @Override - public void visit(Pool in, Pool out) { + public void visit(ModulePool in, ModulePool out) { System.err.println(NAME + index); ordered.add(index); - in.visit((file) -> { + in.transformAndCopy((file) -> { return file; }, out); } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.TRANSFORMER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.TRANSFORMER); return Collections.unmodifiableSet(set); } diff --git a/jdk/test/tools/jlink/JLinkOptimTest.java b/jdk/test/tools/jlink/JLinkOptimTest.java index 82c5431f034..acc089c89c0 100644 --- a/jdk/test/tools/jlink/JLinkOptimTest.java +++ b/jdk/test/tools/jlink/JLinkOptimTest.java @@ -23,15 +23,15 @@ import jdk.internal.org.objectweb.asm.tree.MethodInsnNode; import jdk.internal.org.objectweb.asm.tree.MethodNode; import jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode; import jdk.tools.jlink.internal.PluginRepository; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.internal.plugins.OptimizationPlugin; import jdk.tools.jlink.internal.plugins.asm.AsmModulePool; import jdk.tools.jlink.internal.plugins.asm.AsmPlugin; import jdk.tools.jlink.internal.plugins.asm.AsmPools; import jdk.tools.jlink.internal.plugins.optim.ControlFlow; import jdk.tools.jlink.internal.plugins.optim.ControlFlow.Block; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import tests.Helper; import tests.JImageGenerator; @@ -134,9 +134,9 @@ public class JLinkOptimTest { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.TRANSFORMER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.TRANSFORMER); return Collections.unmodifiableSet(set); } } @@ -150,13 +150,13 @@ public class JLinkOptimTest { FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/")); Path root = fs.getPath("/modules/java.base"); // Access module-info.class to be reused as fake module-info.class - List javabaseResources = new ArrayList<>(); + List javabaseResources = new ArrayList<>(); try (Stream stream = Files.walk(root)) { for (Iterator iterator = stream.iterator(); iterator.hasNext();) { Path p = iterator.next(); if (Files.isRegularFile(p)) { try { - javabaseResources.add(Pool.newResource(p.toString(). + javabaseResources.add(ModuleEntry.create(p.toString(). substring("/modules".length()), Files.readAllBytes(p))); } catch (Exception ex) { throw new RuntimeException(ex); @@ -166,18 +166,18 @@ public class JLinkOptimTest { } //forName folding - PoolImpl pool = new PoolImpl(); + ModulePoolImpl pool = new ModulePoolImpl(); byte[] content = Files.readAllBytes(classes. resolve("optim").resolve("ForNameTestCase.class")); byte[] content2 = Files.readAllBytes(classes. resolve("optim").resolve("AType.class")); byte[] mcontent = Files.readAllBytes(classes.resolve("module-info.class")); - pool.add(Pool.newResource("/optimplugin/optim/ForNameTestCase.class", content)); - pool.add(Pool.newResource("/optimplugin/optim/AType.class", content2)); - pool.add(Pool.newResource("/optimplugin/module-info.class", mcontent)); + pool.add(ModuleEntry.create("/optimplugin/optim/ForNameTestCase.class", content)); + pool.add(ModuleEntry.create("/optimplugin/optim/AType.class", content2)); + pool.add(ModuleEntry.create("/optimplugin/module-info.class", mcontent)); - for (ModuleData r : javabaseResources) { + for (ModuleEntry r : javabaseResources) { pool.add(r); } @@ -186,10 +186,10 @@ public class JLinkOptimTest { optional.put(OptimizationPlugin.NAME, OptimizationPlugin.FORNAME_REMOVAL); optional.put(OptimizationPlugin.LOG, "forName.log"); plugin.configure(optional); - Pool out = new PoolImpl(); + ModulePool out = new ModulePoolImpl(); plugin.visit(pool, out); - ModuleData result = out.getContent().iterator().next(); + ModuleEntry result = out.entries().iterator().next(); ClassReader optimReader = new ClassReader(result.getBytes()); ClassNode optimClass = new ClassNode(); diff --git a/jdk/test/tools/jlink/JLinkOptionsTest.java b/jdk/test/tools/jlink/JLinkOptionsTest.java index 8c8d241f5b7..565c58bffa9 100644 --- a/jdk/test/tools/jlink/JLinkOptionsTest.java +++ b/jdk/test/tools/jlink/JLinkOptionsTest.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.internal.PluginRepository; import jdk.tools.jlink.plugin.TransformerPlugin; @@ -62,7 +62,7 @@ public class JLinkOptionsTest { } @Override - public void visit(Pool in, Pool out) { + public void visit(ModulePool in, ModulePool out) { } diff --git a/jdk/test/tools/jlink/JLinkPostProcessingTest.java b/jdk/test/tools/jlink/JLinkPostProcessingTest.java index b32bf207ff2..abc2b58142e 100644 --- a/jdk/test/tools/jlink/JLinkPostProcessingTest.java +++ b/jdk/test/tools/jlink/JLinkPostProcessingTest.java @@ -75,9 +75,9 @@ public class JLinkPostProcessingTest { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.PROCESSOR); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.PROCESSOR); return Collections.unmodifiableSet(set); } diff --git a/jdk/test/tools/jlink/ResourcePoolTest.java b/jdk/test/tools/jlink/ResourcePoolTest.java index 77a82e5c1b2..523503c996a 100644 --- a/jdk/test/tools/jlink/ResourcePoolTest.java +++ b/jdk/test/tools/jlink/ResourcePoolTest.java @@ -37,14 +37,14 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Optional; import java.util.Set; - -import jdk.tools.jlink.internal.PoolImpl; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.Module; -import jdk.tools.jlink.plugin.Pool.ModuleData; -import jdk.tools.jlink.plugin.Pool.ModuleDataType; -import jdk.tools.jlink.plugin.Pool.Visitor; +import java.util.function.Function; +import jdk.tools.jlink.internal.ModulePoolImpl; +import jdk.tools.jlink.plugin.ModulePool; +import jdk.tools.jlink.plugin.LinkModule; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; public class ResourcePoolTest { @@ -61,54 +61,53 @@ public class ResourcePoolTest { private static final String SUFFIX = "END"; private void checkResourceVisitor() throws Exception { - Pool input = new PoolImpl(); + ModulePool input = new ModulePoolImpl(); for (int i = 0; i < 1000; ++i) { String module = "/module" + (i / 10); String resourcePath = module + "/java/package" + i; byte[] bytes = resourcePath.getBytes(); - input.add(new ModuleData(module, resourcePath, - ModuleDataType.CLASS_OR_RESOURCE, + input.add(ModuleEntry.create(module, resourcePath, + ModuleEntry.Type.CLASS_OR_RESOURCE, new ByteArrayInputStream(bytes), bytes.length)); } - Pool output = new PoolImpl(); + ModulePool output = new ModulePoolImpl(); ResourceVisitor visitor = new ResourceVisitor(); - input.visit(visitor, output); + input.transformAndCopy(visitor, output); if (visitor.getAmountBefore() == 0) { throw new AssertionError("Resources not found"); } - if (visitor.getAmountBefore() != input.getContent().size()) { + if (visitor.getAmountBefore() != input.getEntryCount()) { throw new AssertionError("Number of visited resources. Expected: " + - visitor.getAmountBefore() + ", got: " + input.getContent().size()); + visitor.getAmountBefore() + ", got: " + input.getEntryCount()); } - if (visitor.getAmountAfter() != output.getContent().size()) { + if (visitor.getAmountAfter() != output.getEntryCount()) { throw new AssertionError("Number of added resources. Expected: " + - visitor.getAmountAfter() + ", got: " + output.getContent().size()); + visitor.getAmountAfter() + ", got: " + output.getEntryCount()); } - for (ModuleData outResource : output.getContent()) { + output.entries().forEach(outResource -> { String path = outResource.getPath().replaceAll(SUFFIX + "$", ""); - ModuleData inResource = input.get(path); - if (inResource == null) { + if (!input.findEntry(path).isPresent()) { throw new AssertionError("Unknown resource: " + path); } - } + }); } - private static class ResourceVisitor implements Visitor { + private static class ResourceVisitor implements Function { private int amountBefore; private int amountAfter; @Override - public ModuleData visit(ModuleData resource) { + public ModuleEntry apply(ModuleEntry resource) { int index = ++amountBefore % 3; switch (index) { case 0: ++amountAfter; - return new ModuleData(resource.getModule(), resource.getPath() + SUFFIX, + return ModuleEntry.create(resource.getModule(), resource.getPath() + SUFFIX, resource.getType(), resource.stream(), resource.getLength()); case 1: ++amountAfter; - return new ModuleData(resource.getModule(), resource.getPath(), + return ModuleEntry.create(resource.getModule(), resource.getPath(), resource.getType(), resource.stream(), resource.getLength()); } return null; @@ -133,8 +132,8 @@ public class ResourcePoolTest { samples.add("javax/management/ObjectName"); test(samples, (resources, module, path) -> { try { - resources.add(new ModuleData(module, path, - ModuleDataType.CLASS_OR_RESOURCE, + resources.add(ModuleEntry.create(module, path, + ModuleEntry.Type.CLASS_OR_RESOURCE, new ByteArrayInputStream(new byte[0]), 0)); } catch (Exception ex) { throw new RuntimeException(ex); @@ -142,12 +141,12 @@ public class ResourcePoolTest { }); test(samples, (resources, module, path) -> { try { - resources.add(PoolImpl. - newCompressedResource(new ModuleData(module, path, - ModuleDataType.CLASS_OR_RESOURCE, + resources.add(ModulePoolImpl. + newCompressedResource(ModuleEntry.create(module, path, + ModuleEntry.Type.CLASS_OR_RESOURCE, new ByteArrayInputStream(new byte[0]), 0), ByteBuffer.allocate(99), "bitcruncher", null, - ((PoolImpl)resources).getStringTable(), ByteOrder.nativeOrder())); + ((ModulePoolImpl)resources).getStringTable(), ByteOrder.nativeOrder())); } catch (Exception ex) { throw new RuntimeException(ex); } @@ -158,7 +157,7 @@ public class ResourcePoolTest { if (samples.isEmpty()) { throw new AssertionError("No sample to test"); } - Pool resources = new PoolImpl(); + ModulePool resources = new ModulePoolImpl(); Set modules = new HashSet<>(); for (int i = 0; i < samples.size(); i++) { String module = samples.get(i); @@ -173,70 +172,69 @@ public class ResourcePoolTest { i++; String clazz = samples.get(i); String path = "/" + module + "/" + clazz + ".class"; - ModuleData res = resources.get(path); - checkModule(resources, res); - if (res == null) { + Optional res = resources.findEntry(path); + if (!res.isPresent()) { throw new AssertionError("Resource not found " + path); } - ModuleData res2 = resources.get(clazz); - if (res2 != null) { + checkModule(resources, res.get()); + if (resources.findEntry(clazz).isPresent()) { throw new AssertionError("Resource found " + clazz); } } - if (resources.getContent().size() != samples.size() / 2) { + if (resources.getEntryCount() != samples.size() / 2) { throw new AssertionError("Invalid number of resources"); } } - private void checkModule(Pool resources, ModuleData res) { - Module m = resources.getModule(res.getModule()); - if (m == null) { + private void checkModule(ModulePool resources, ModuleEntry res) { + Optional optMod = resources.findModule(res.getModule()); + if (!optMod.isPresent()) { throw new AssertionError("No module " + res.getModule()); } + LinkModule m = optMod.get(); if (!m.getName().equals(res.getModule())) { throw new AssertionError("Not right module name " + res.getModule()); } - if (m.get(res.getPath()) == null) { + if (!m.findEntry(res.getPath()).isPresent()) { throw new AssertionError("resource " + res.getPath() + " not in module " + m.getName()); } } private void checkResourcesAfterCompression() throws Exception { - PoolImpl resources1 = new PoolImpl(); - ModuleData res1 = new ModuleData("module1", "/module1/toto1", - ModuleDataType.CLASS_OR_RESOURCE, + ModulePoolImpl resources1 = new ModulePoolImpl(); + ModuleEntry res1 = ModuleEntry.create("module1", "/module1/toto1", + ModuleEntry.Type.CLASS_OR_RESOURCE, new ByteArrayInputStream(new byte[0]), 0); - ModuleData res2 = new ModuleData("module2", "/module2/toto1", - ModuleDataType.CLASS_OR_RESOURCE, + ModuleEntry res2 = ModuleEntry.create("module2", "/module2/toto1", + ModuleEntry.Type.CLASS_OR_RESOURCE, new ByteArrayInputStream(new byte[0]), 0); resources1.add(res1); resources1.add(res2); checkResources(resources1, res1, res2); - Pool resources2 = new PoolImpl(); - ModuleData res3 = new ModuleData("module2", "/module2/toto1", - ModuleDataType.CLASS_OR_RESOURCE, + ModulePool resources2 = new ModulePoolImpl(); + ModuleEntry res3 = ModuleEntry.create("module2", "/module2/toto1", + ModuleEntry.Type.CLASS_OR_RESOURCE, new ByteArrayInputStream(new byte[7]), 7); resources2.add(res3); - resources2.add(PoolImpl.newCompressedResource(res1, + resources2.add(ModulePoolImpl.newCompressedResource(res1, ByteBuffer.allocate(7), "zip", null, resources1.getStringTable(), ByteOrder.nativeOrder())); checkResources(resources2, res1, res2); } - private void checkResources(Pool resources, ModuleData... expected) { - Collection ms = resources.getModules(); + private void checkResources(ModulePool resources, ModuleEntry... expected) { List modules = new ArrayList(); - for(Module m : ms) { + resources.modules().forEach(m -> { modules.add(m.getName()); - } - for (ModuleData res : expected) { + }); + for (ModuleEntry res : expected) { if (!resources.contains(res)) { throw new AssertionError("Resource not found: " + res); } - if (resources.get(res.getPath()) == null) { + if (!resources.findEntry(res.getPath()).isPresent()) { throw new AssertionError("Resource not found: " + res); } @@ -244,7 +242,7 @@ public class ResourcePoolTest { throw new AssertionError("Module not found: " + res.getModule()); } - if (!resources.getContent().contains(res)) { + if (!resources.contains(res)) { throw new AssertionError("Resources not found: " + res); } @@ -260,17 +258,17 @@ public class ResourcePoolTest { throw new AssertionError("ReadOnly resources"); } - ((PoolImpl) resources).setReadOnly(); + ((ModulePoolImpl) resources).setReadOnly(); try { - resources.add(new ModuleData("module2", "/module2/toto1", - ModuleDataType.CLASS_OR_RESOURCE, new ByteArrayInputStream(new byte[0]), 0)); - throw new AssertionError("Pool is read-only, but an exception is not thrown"); + resources.add(ModuleEntry.create("module2", "/module2/toto1", + ModuleEntry.Type.CLASS_OR_RESOURCE, new ByteArrayInputStream(new byte[0]), 0)); + throw new AssertionError("ModulePool is read-only, but an exception is not thrown"); } catch (Exception ex) { // Expected } } interface ResourceAdder { - void add(Pool resources, String module, String path); + void add(ModulePool resources, String module, String path); } } diff --git a/jdk/test/tools/jlink/SecurityTest.java b/jdk/test/tools/jlink/SecurityTest.java index 9497d6f3f34..dbf593bccc0 100644 --- a/jdk/test/tools/jlink/SecurityTest.java +++ b/jdk/test/tools/jlink/SecurityTest.java @@ -25,6 +25,7 @@ * @test * @summary Test JlinkPermission * @author Jean-Francois Denise + * @modules jdk.jlink/jdk.tools.jlink * @run main/othervm SecurityTest */ diff --git a/jdk/test/tools/jlink/asmplugin/AddForgetResourcesTest.java b/jdk/test/tools/jlink/asmplugin/AddForgetResourcesTest.java index 6a414b57d63..4385534e07f 100644 --- a/jdk/test/tools/jlink/asmplugin/AddForgetResourcesTest.java +++ b/jdk/test/tools/jlink/asmplugin/AddForgetResourcesTest.java @@ -55,8 +55,8 @@ import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFile; import jdk.tools.jlink.internal.plugins.asm.AsmPool.WritableClassPool; import jdk.tools.jlink.internal.plugins.asm.AsmPool.WritableResourcePool; import jdk.tools.jlink.internal.plugins.asm.AsmPools; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; public class AddForgetResourcesTest extends AsmPluginTestBase { @@ -82,7 +82,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { new ComboPlugin() }; for (TestPlugin p : plugins) { - Pool out = p.visit(getPool()); + ModulePool out = p.visit(getPool()); p.test(getPool(), out); } } @@ -124,7 +124,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { AsmGlobalPool globalPool = pools.getGlobalPool(); WritableClassPool transformedClasses = globalPool.getTransformedClasses(); expected = globalPool.getClasses().size(); - for (ModuleData res : globalPool.getClasses()) { + for (ModuleEntry res : globalPool.getClasses()) { ClassReader reader = globalPool.getClassReader(res); String className = reader.getClassName(); if (!className.endsWith("module-info")) { @@ -137,14 +137,14 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { } @Override - public void test(Pool inResources, Pool outResources) { - Collection inClasses = extractClasses(inResources); - Collection outClasses = extractClasses(outResources); + public void test(ModulePool inResources, ModulePool outResources) { + Collection inClasses = extractClasses(inResources); + Collection outClasses = extractClasses(outResources); if (expected != outClasses.size()) { throw new AssertionError("Classes were not added. Expected: " + expected + ", got: " + outClasses.size()); } - for (ModuleData in : inClasses) { + for (ModuleEntry in : inClasses) { String path = in.getPath(); if (!outClasses.contains(in)) { throw new AssertionError("Class not found: " + path); @@ -153,7 +153,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { continue; } String modifiedPath = path.replace(".class", SUFFIX + ".class"); - if (!outClasses.contains(Pool.newResource(modifiedPath, new byte[0]))) { + if (!outClasses.contains(ModuleEntry.create(modifiedPath, new byte[0]))) { throw new AssertionError("Class not found: " + modifiedPath); } } @@ -166,7 +166,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { public void visit() { AsmPools pools = getPools(); AsmGlobalPool globalPool = pools.getGlobalPool(); - for (ModuleData res : globalPool.getResourceFiles()) { + for (ModuleEntry res : globalPool.getResourceFiles()) { String path = res.getPath(); String moduleName = getModule(path); AsmModulePool modulePool = pools.getModulePool(moduleName); @@ -177,20 +177,20 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { } @Override - public void test(Pool in, Pool out) throws Exception { - Collection inResources = extractResources(in); - Collection outResources = extractResources(out); + public void test(ModulePool in, ModulePool out) throws Exception { + Collection inResources = extractResources(in); + Collection outResources = extractResources(out); if (2 * inResources.size() != outResources.size()) { throw new AssertionError("Classes were not added. Expected: " + (2 * inResources.size()) + ", got: " + outResources.size()); } - for (ModuleData r : inResources) { + for (ModuleEntry r : inResources) { String path = r.getPath(); if (!outResources.contains(r)) { throw new AssertionError("Class not found: " + path); } String modifiedPath = path + SUFFIX; - if (!outResources.contains(Pool.newResource(modifiedPath, new byte[0]))) { + if (!outResources.contains(ModuleEntry.create(modifiedPath, new byte[0]))) { throw new AssertionError("Class not found: " + modifiedPath); } } @@ -204,7 +204,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { AsmPools pools = getPools(); AsmGlobalPool globalPool = pools.getGlobalPool(); WritableClassPool transformedClasses = globalPool.getTransformedClasses(); - for (ModuleData res : globalPool.getClasses()) { + for (ModuleEntry res : globalPool.getClasses()) { ClassReader reader = globalPool.getClassReader(res); ClassWriter writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES); reader.accept(new AddMethodClassVisitor(writer), ClassReader.EXPAND_FRAMES); @@ -213,14 +213,14 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { } @Override - public void test(Pool inResources, Pool outResources) throws Exception { - Collection inClasses = extractClasses(inResources); - Collection outClasses = extractClasses(outResources); + public void test(ModulePool inResources, ModulePool outResources) throws Exception { + Collection inClasses = extractClasses(inResources); + Collection outClasses = extractClasses(outResources); if (inClasses.size() != outClasses.size()) { throw new AssertionError("Number of classes. Expected: " + (inClasses.size()) + ", got: " + outClasses.size()); } - for (ModuleData out : outClasses) { + for (ModuleEntry out : outClasses) { String path = out.getPath(); if (!inClasses.contains(out)) { throw new AssertionError("Class not found: " + path); @@ -248,7 +248,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { public void visit() { AsmPools pools = getPools(); AsmGlobalPool globalPool = pools.getGlobalPool(); - for (ModuleData res : globalPool.getResourceFiles()) { + for (ModuleEntry res : globalPool.getResourceFiles()) { String path = res.getPath(); AsmModulePool modulePool = pools.getModulePool(getModule(path)); modulePool.getTransformedResourceFiles().addResourceFile(new ResourceFile(removeModule(path), @@ -257,14 +257,14 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { } @Override - public void test(Pool in, Pool out) throws Exception { - Collection inResources = extractResources(in); - Collection outResources = extractResources(out); + public void test(ModulePool in, ModulePool out) throws Exception { + Collection inResources = extractResources(in); + Collection outResources = extractResources(out); if (inResources.size() != outResources.size()) { throw new AssertionError("Number of resources. Expected: " + inResources.size() + ", got: " + outResources.size()); } - for (ModuleData r : outResources) { + for (ModuleEntry r : outResources) { String path = r.getPath(); if (!inResources.contains(r)) { throw new AssertionError("Resource not found: " + path); @@ -287,7 +287,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { AsmGlobalPool globalPool = pools.getGlobalPool(); WritableClassPool transformedClasses = globalPool.getTransformedClasses(); int i = 0; - for (ModuleData res : globalPool.getClasses()) { + for (ModuleEntry res : globalPool.getClasses()) { String path = removeModule(res.getPath()); String className = path.replace(".class", ""); if ((i & 1) == 0 && !className.endsWith("module-info")) { @@ -300,8 +300,8 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { } @Override - public void test(Pool inResources, Pool outResources) throws Exception { - Collection outClasses = extractClasses(outResources); + public void test(ModulePool inResources, ModulePool outResources) throws Exception { + Collection outClasses = extractClasses(outResources); if (expected != outClasses.size()) { throw new AssertionError("Number of classes. Expected: " + expected + ", got: " + outClasses.size()); @@ -318,7 +318,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { AsmPools pools = getPools(); AsmGlobalPool globalPool = pools.getGlobalPool(); int i = 0; - for (ModuleData res : globalPool.getResourceFiles()) { + for (ModuleEntry res : globalPool.getResourceFiles()) { String path = res.getPath(); if (!path.contains("META-INF/services")) { if ((i & 1) == 0) { @@ -335,8 +335,8 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { } @Override - public void test(Pool in, Pool out) throws Exception { - Collection outResources = extractResources(out); + public void test(ModulePool in, ModulePool out) throws Exception { + Collection outResources = extractResources(out); if (expectedAmount != outResources.size()) { throw new AssertionError("Number of classes. Expected: " + expectedAmount + ", got: " + outResources.size()); @@ -354,7 +354,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { AsmGlobalPool globalPool = pools.getGlobalPool(); WritableClassPool transformedClasses = globalPool.getTransformedClasses(); int i = 0; - for (ModuleData res : globalPool.getClasses()) { + for (ModuleEntry res : globalPool.getClasses()) { ClassReader reader = globalPool.getClassReader(res); String className = reader.getClassName(); ClassWriter writer = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES); @@ -374,8 +374,8 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { } @Override - public void test(Pool inResources, Pool outResources) throws Exception { - Collection outClasses = extractClasses(outResources); + public void test(ModulePool inResources, ModulePool outResources) throws Exception { + Collection outClasses = extractClasses(outResources); if (expected != outClasses.size()) { throw new AssertionError("Number of classes. Expected: " + expected + ", got: " + outClasses.size()); @@ -392,7 +392,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { AsmPools pools = getPools(); AsmGlobalPool globalPool = pools.getGlobalPool(); int i = 0; - for (ModuleData res : globalPool.getResourceFiles()) { + for (ModuleEntry res : globalPool.getResourceFiles()) { String path = res.getPath(); String moduleName = getModule(path); if (!path.contains("META-INF")) { @@ -412,8 +412,8 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { } @Override - public void test(Pool inResources, Pool out) throws Exception { - Collection outResources = extractResources(out); + public void test(ModulePool inResources, ModulePool out) throws Exception { + Collection outResources = extractResources(out); if (expectedAmount != outResources.size()) { throw new AssertionError("Number of classes. Expected: " + expectedAmount + ", got: " + outResources.size()); @@ -446,7 +446,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { } @Override - public void test(Pool inResources, Pool outResources) throws Exception { + public void test(ModulePool inResources, ModulePool outResources) throws Exception { if (!isVisitCalled()) { throw new AssertionError("Resources not visited"); } @@ -455,7 +455,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { throw new AssertionError("Number of transformed classes not equal to expected"); } // Check that only renamed classes and resource files are in the result. - for (ModuleData r : outResources.getContent()) { + outResources.entries().forEach(r -> { String resourceName = r.getPath(); if (resourceName.endsWith(".class") && !resourceName.endsWith("module-info.class")) { if (!resourceName.endsWith(SUFFIX + ".class")) { @@ -467,7 +467,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { throw new AssertionError("Resource file not renamed " + resourceName); } } - } + }); } private void renameResources() throws IOException { @@ -476,7 +476,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { for (Map.Entry> mod : MODULES.entrySet()) { String moduleName = mod.getKey(); AsmModulePool modulePool = pools.getModulePool(moduleName); - for (ModuleData res : modulePool.getResourceFiles()) { + for (ModuleEntry res : modulePool.getResourceFiles()) { ResourceFile resFile = modulePool.getResourceFile(res); if (resFile.getPath().startsWith("META-INF/services/")) { String newContent = new String(resFile.getContent()) + SUFFIX; @@ -492,7 +492,7 @@ public class AddForgetResourcesTest extends AsmPluginTestBase { AsmPools pools = getPools(); AsmGlobalPool globalPool = pools.getGlobalPool(); WritableClassPool transformedClasses = globalPool.getTransformedClasses(); - for (ModuleData res : globalPool.getClasses()) { + for (ModuleEntry res : globalPool.getClasses()) { if (res.getPath().endsWith("module-info.class")) { continue; } diff --git a/jdk/test/tools/jlink/asmplugin/AsmPluginTestBase.java b/jdk/test/tools/jlink/asmplugin/AsmPluginTestBase.java index d5c035562fa..c51419e682c 100644 --- a/jdk/test/tools/jlink/asmplugin/AsmPluginTestBase.java +++ b/jdk/test/tools/jlink/asmplugin/AsmPluginTestBase.java @@ -38,23 +38,23 @@ import java.util.Set; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.internal.StringTable; import jdk.tools.jlink.internal.plugins.asm.AsmPlugin; import jdk.tools.jlink.internal.plugins.asm.AsmPools; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; public abstract class AsmPluginTestBase { protected static final String TEST_MODULE = "jlink.test"; protected static final Map> MODULES; - private static final Predicate isClass = r -> r.getPath().endsWith(".class"); + private static final Predicate isClass = r -> r.getPath().endsWith(".class"); private final List classes; private final List resources; - private final Pool pool; + private final ModulePool pool; static { Map> map = new HashMap<>(); @@ -75,7 +75,7 @@ public abstract class AsmPluginTestBase { List classes = new ArrayList<>(); List resources = new ArrayList<>(); - pool = new PoolImpl(); + pool = new ModulePoolImpl(); FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/")); Path root = fs.getPath("/modules"); @@ -100,7 +100,7 @@ public abstract class AsmPluginTestBase { MODULES.get(module).add(toResourceFile(p)); } resources.add(toPath(p.toString())); - ModuleData res = Pool.newResource(toPath(p.toString()), content); + ModuleEntry res = ModuleEntry.create(toPath(p.toString()), content); pool.add(res); } catch (Exception ex) { throw new RuntimeException(ex); @@ -110,17 +110,17 @@ public abstract class AsmPluginTestBase { } } // There is more than 10 classes in java.base... - if (classes.size() < 10 || pool.getContent().size() < 10) { + if (classes.size() < 10 || pool.getEntryCount() < 10) { throw new AssertionError("Not expected resource or class number"); } //Add a fake resource file String content = "java.lang.Object"; String path = "META-INF/services/com.foo.BarProvider"; - ModuleData resFile = Pool.newResource("/" + TEST_MODULE + "/" + + ModuleEntry resFile = ModuleEntry.create("/" + TEST_MODULE + "/" + path, content.getBytes()); pool.add(resFile); - ModuleData fakeInfoFile = Pool.newResource("/" + TEST_MODULE + ModuleEntry fakeInfoFile = ModuleEntry.create("/" + TEST_MODULE + "/module-info.class", moduleInfos.get(0)); pool.add(fakeInfoFile); MODULES.get(TEST_MODULE).add(path); @@ -144,20 +144,20 @@ public abstract class AsmPluginTestBase { return resources; } - public Pool getPool() { + public ModulePool getPool() { return pool; } public abstract void test() throws Exception; - public Collection extractClasses(Pool pool) { - return pool.getContent().stream() + public Collection extractClasses(ModulePool pool) { + return pool.entries() .filter(isClass) .collect(Collectors.toSet()); } - public Collection extractResources(Pool pool) { - return pool.getContent().stream() + public Collection extractResources(ModulePool pool) { + return pool.entries() .filter(isClass.negate()) .collect(Collectors.toSet()); } @@ -209,9 +209,9 @@ public abstract class AsmPluginTestBase { return pools != null; } - public Pool visit(Pool inResources) throws IOException { + public ModulePool visit(ModulePool inResources) throws IOException { try { - Pool outResources = new PoolImpl(inResources.getByteOrder(), new StringTable() { + ModulePool outResources = new ModulePoolImpl(inResources.getByteOrder(), new StringTable() { @Override public int addString(String str) { return -1; @@ -239,7 +239,7 @@ public abstract class AsmPluginTestBase { } public abstract void visit(); - public abstract void test(Pool inResources, Pool outResources) throws Exception; + public abstract void test(ModulePool inResources, ModulePool outResources) throws Exception; @Override public String getName() { diff --git a/jdk/test/tools/jlink/asmplugin/BasicTest.java b/jdk/test/tools/jlink/asmplugin/BasicTest.java index 0c42d4cfb99..afc5fd5f634 100644 --- a/jdk/test/tools/jlink/asmplugin/BasicTest.java +++ b/jdk/test/tools/jlink/asmplugin/BasicTest.java @@ -45,8 +45,8 @@ import java.util.logging.Logger; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.tools.jlink.internal.plugins.asm.AsmModulePool; import jdk.tools.jlink.internal.plugins.asm.AsmPool; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; public class BasicTest extends AsmPluginTestBase { @@ -61,7 +61,7 @@ public class BasicTest extends AsmPluginTestBase { @Override public void test() throws Exception { BasicPlugin basicPlugin = new BasicPlugin(getClasses()); - Pool res = basicPlugin.visit(getPool()); + ModulePool res = basicPlugin.visit(getPool()); basicPlugin.test(getPool(), res); } @@ -107,13 +107,13 @@ public class BasicTest extends AsmPluginTestBase { } @Override - public void test(Pool inResources, Pool outResources) throws Exception { + public void test(ModulePool inResources, ModulePool outResources) throws Exception { if (!isVisitCalled()) { throw new AssertionError("Resources not visited"); } - if (inResources.getContent().size() != outResources.getContent().size()) { - throw new AssertionError("Input size " + inResources.getContent().size() + - " != to " + outResources.getContent().size()); + if (inResources.getEntryCount() != outResources.getEntryCount()) { + throw new AssertionError("Input size " + inResources.getEntryCount() + + " != to " + outResources.getEntryCount()); } } @@ -142,7 +142,7 @@ public class BasicTest extends AsmPluginTestBase { private void testPools() throws IOException { Set remain = new HashSet<>(classes); - for (ModuleData res : getPools().getGlobalPool().getClasses()) { + for (ModuleEntry res : getPools().getGlobalPool().getClasses()) { ClassReader reader = getPools().getGlobalPool().getClassReader(res); String className = reader.getClassName(); // Wrong naming of module-info.class in ASM diff --git a/jdk/test/tools/jlink/asmplugin/IdentityPluginTest.java b/jdk/test/tools/jlink/asmplugin/IdentityPluginTest.java index ceb2e50f9b9..416d3581552 100644 --- a/jdk/test/tools/jlink/asmplugin/IdentityPluginTest.java +++ b/jdk/test/tools/jlink/asmplugin/IdentityPluginTest.java @@ -35,14 +35,15 @@ import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.UncheckedIOException; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.ClassVisitor; import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.Opcodes; import jdk.tools.jlink.internal.plugins.asm.AsmPool.WritableClassPool; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; public class IdentityPluginTest extends AsmPluginTestBase { @@ -56,7 +57,7 @@ public class IdentityPluginTest extends AsmPluginTestBase { public void test() throws Exception { IdentityPlugin asm = new IdentityPlugin(); - Pool resourcePool = asm.visit(getPool()); + ModulePool resourcePool = asm.visit(getPool()); asm.test(getPool(), resourcePool); } @@ -64,7 +65,7 @@ public class IdentityPluginTest extends AsmPluginTestBase { @Override public void visit() { - for (ModuleData res : getPools().getGlobalPool().getClasses()) { + for (ModuleEntry res : getPools().getGlobalPool().getClasses()) { if (res.getPath().endsWith("module-info.class")) { continue; } @@ -77,7 +78,7 @@ public class IdentityPluginTest extends AsmPluginTestBase { } @Override - public void test(Pool inResources, Pool outResources) throws IOException { + public void test(ModulePool inResources, ModulePool outResources) throws IOException { if (outResources.isEmpty()) { throw new AssertionError("Empty result"); } @@ -93,13 +94,17 @@ public class IdentityPluginTest extends AsmPluginTestBase { throw new AssertionError("Class not transformed " + className); } } - for (ModuleData r : outResources.getContent()) { + outResources.entries().forEach(r -> { if (r.getPath().endsWith(".class") && !r.getPath().endsWith("module-info.class")) { - ClassReader reader = new ClassReader(new ByteArrayInputStream(r.getBytes())); - ClassWriter w = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES); - reader.accept(w, ClassReader.EXPAND_FRAMES); + try { + ClassReader reader = new ClassReader(new ByteArrayInputStream(r.getBytes())); + ClassWriter w = new ClassWriter(reader, ClassWriter.COMPUTE_FRAMES); + reader.accept(w, ClassReader.EXPAND_FRAMES); + } catch (IOException exp) { + throw new UncheckedIOException(exp); + } } - } + }); } @Override diff --git a/jdk/test/tools/jlink/asmplugin/NegativeTest.java b/jdk/test/tools/jlink/asmplugin/NegativeTest.java index f95b7c62399..6263fcaaa4a 100644 --- a/jdk/test/tools/jlink/asmplugin/NegativeTest.java +++ b/jdk/test/tools/jlink/asmplugin/NegativeTest.java @@ -43,7 +43,7 @@ import jdk.internal.org.objectweb.asm.ClassVisitor; import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.Opcodes; import jdk.tools.jlink.plugin.Plugin; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.internal.StringTable; import jdk.tools.jlink.internal.plugins.asm.AsmGlobalPool; import jdk.tools.jlink.internal.plugins.asm.AsmModulePool; @@ -51,7 +51,7 @@ import jdk.tools.jlink.internal.plugins.asm.AsmPlugin; import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFile; import jdk.tools.jlink.internal.plugins.asm.AsmPools; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModulePool; public class NegativeTest extends AsmPluginTestBase { public static void main(String[] args) throws Exception { @@ -102,7 +102,7 @@ public class NegativeTest extends AsmPluginTestBase { } } }; - Pool resources = new PoolImpl(ByteOrder.BIG_ENDIAN, new StringTable() { + ModulePool resources = new ModulePoolImpl(ByteOrder.BIG_ENDIAN, new StringTable() { @Override public int addString(String str) { return -1; @@ -136,7 +136,7 @@ public class NegativeTest extends AsmPluginTestBase { action(() -> pools.fillOutputResources(null), "Output resource is null", NullPointerException.class); } }; - Pool resources = new PoolImpl(ByteOrder.BIG_ENDIAN, new StringTable() { + ModulePool resources = new ModulePoolImpl(ByteOrder.BIG_ENDIAN, new StringTable() { @Override public int addString(String str) { return -1; diff --git a/jdk/test/tools/jlink/asmplugin/PackageMappingTest.java b/jdk/test/tools/jlink/asmplugin/PackageMappingTest.java index 9453ac5f917..bd0a8fdbf4d 100644 --- a/jdk/test/tools/jlink/asmplugin/PackageMappingTest.java +++ b/jdk/test/tools/jlink/asmplugin/PackageMappingTest.java @@ -48,8 +48,8 @@ import jdk.tools.jlink.internal.plugins.asm.AsmModulePool; import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFile; import jdk.tools.jlink.internal.plugins.asm.AsmPool.WritableResourcePool; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; public class PackageMappingTest extends AsmPluginTestBase { @@ -72,7 +72,7 @@ public class PackageMappingTest extends AsmPluginTestBase { new PackageMappingPlugin(newFiles, true) }; for (TestPlugin p : plugins) { - Pool pool = p.visit(getPool()); + ModulePool pool = p.visit(getPool()); p.test(getPool(), pool); } } @@ -105,12 +105,12 @@ public class PackageMappingTest extends AsmPluginTestBase { } @Override - public void test(Pool inResources, Pool outResources) { + public void test(ModulePool inResources, ModulePool outResources) { Set in = getPools().getGlobalPool().getResourceFiles().stream() - .map(ModuleData::getPath) + .map(ModuleEntry::getPath) .collect(Collectors.toSet()); Set out = extractResources(outResources).stream() - .map(ModuleData::getPath) + .map(ModuleEntry::getPath) .collect(Collectors.toSet()); in.addAll(PackageMappingTest.this.newFiles); if (!Objects.equals(in, out)) { diff --git a/jdk/test/tools/jlink/asmplugin/SortingTest.java b/jdk/test/tools/jlink/asmplugin/SortingTest.java index 0fc4c7a6854..26974b3b065 100644 --- a/jdk/test/tools/jlink/asmplugin/SortingTest.java +++ b/jdk/test/tools/jlink/asmplugin/SortingTest.java @@ -35,12 +35,13 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import jdk.tools.jlink.internal.plugins.asm.AsmModulePool; import jdk.tools.jlink.plugin.PluginException; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; public class SortingTest extends AsmPluginTestBase { @@ -66,7 +67,7 @@ public class SortingTest extends AsmPluginTestBase { List sorted = new ArrayList<>(getResources()); sorted.sort(null); ClassSorterPlugin sorterPlugin = new ClassSorterPlugin(sorted); - Pool resourcePool = sorterPlugin.visit(getPool()); + ModulePool resourcePool = sorterPlugin.visit(getPool()); sorterPlugin.test(getPool(), resourcePool); } @@ -78,7 +79,7 @@ public class SortingTest extends AsmPluginTestBase { List sorted = new ArrayList<>(getResources()); sorted.sort((s1, s2) -> -getModuleName(s1).compareTo(getModuleName(s2))); ModuleSorterPlugin sorterPlugin = new ModuleSorterPlugin(); - Pool resourcePool = sorterPlugin.visit(getPool()); + ModulePool resourcePool = sorterPlugin.visit(getPool()); sorterPlugin.test(getPool(), resourcePool); } @@ -88,8 +89,8 @@ public class SortingTest extends AsmPluginTestBase { public void visit() { for (AsmModulePool modulePool : getPools().getModulePools()) { modulePool.setSorter(resources -> { - List sort = resources.getContent().stream() - .map(ModuleData::getPath) + List sort = resources.entries() + .map(ModuleEntry::getPath) .collect(Collectors.toList()); sort.sort(null); return sort; @@ -102,21 +103,21 @@ public class SortingTest extends AsmPluginTestBase { } @Override - public void test(Pool inResources, Pool outResources) throws Exception { + public void test(ModulePool inResources, ModulePool outResources) throws Exception { if (!isVisitCalled()) { throw new AssertionError("Resources not visited"); } - List sortedResourcePaths = outResources.getContent().stream() - .map(ModuleData::getPath) + List sortedResourcePaths = outResources.entries() + .map(ModuleEntry::getPath) .collect(Collectors.toList()); List defaultResourceOrder = new ArrayList<>(); - for (ModuleData r : inResources.getContent()) { - if (!inResources.getContent().contains(r)) { + inResources.entries().forEach(r -> { + if (!inResources.contains(r)) { throw new AssertionError("Resource " + r.getPath() + " not in result pool"); } defaultResourceOrder.add(r.getPath()); - } + }); // Check that default sorting is not equal to sorted one if (defaultResourceOrder.equals(sortedResourcePaths)) { throw new AssertionError("Sorting not applied, default ordering"); @@ -147,27 +148,28 @@ public class SortingTest extends AsmPluginTestBase { public void visit() { getPools().getGlobalPool().setSorter( (resources) -> expectedClassesOrder.stream() - .map(resources::get) - .map(ModuleData::getPath) + .map(resources::findEntry) + .map(Optional::get) + .map(ModuleEntry::getPath) .collect(Collectors.toList())); } @Override - public void test(Pool inResources, Pool outResources) throws Exception { + public void test(ModulePool inResources, ModulePool outResources) throws Exception { if (!isVisitCalled()) { throw new AssertionError("Resources not visited"); } - List sortedResourcePaths = outResources.getContent().stream() - .map(ModuleData::getPath) + List sortedResourcePaths = outResources.entries() + .map(ModuleEntry::getPath) .collect(Collectors.toList()); List defaultResourceOrder = new ArrayList<>(); - for (ModuleData r : getPool().getContent()) { - if (!getPool().getContent().contains(r)) { + getPool().entries().forEach(r -> { + if (!getPool().contains(r)) { throw new AssertionError("Resource " + r.getPath() + " not in result pool"); } defaultResourceOrder.add(r.getPath()); - } + }); // Check that default sorting is not equal to sorted one if (defaultResourceOrder.equals(sortedResourcePaths)) { throw new AssertionError("Sorting not applied, default ordering"); diff --git a/jdk/test/tools/jlink/asmplugin/VisitorTest.java b/jdk/test/tools/jlink/asmplugin/VisitorTest.java index 1b278a8bd48..500d415bc50 100644 --- a/jdk/test/tools/jlink/asmplugin/VisitorTest.java +++ b/jdk/test/tools/jlink/asmplugin/VisitorTest.java @@ -46,8 +46,8 @@ import jdk.tools.jlink.internal.plugins.asm.AsmPool.ClassReaderVisitor; import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFile; import jdk.tools.jlink.internal.plugins.asm.AsmPool.ResourceFileVisitor; import jdk.tools.jlink.internal.plugins.asm.AsmPools; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; public class VisitorTest extends AsmPluginTestBase { @@ -69,7 +69,7 @@ public class VisitorTest extends AsmPluginTestBase { }; for (TestPlugin p : plugins) { System.err.println("Testing: " + p.getName()); - Pool out = p.visit(getPool()); + ModulePool out = p.visit(getPool()); p.test(getPool(), out); } } @@ -149,15 +149,15 @@ public class VisitorTest extends AsmPluginTestBase { } @Override - public void test(Pool in, Pool out) throws Exception { - Collection inClasses = getPool.apply(getPools()).getClasses(); + public void test(ModulePool in, ModulePool out) throws Exception { + Collection inClasses = getPool.apply(getPools()).getClasses(); if (inClasses.size() != classReaderVisitor.getAmount()) { throw new AssertionError("Testing " + name + ". Number of visited classes. Expected: " + inClasses.size() + ", got: " + classReaderVisitor.getAmount()); } - Collection outClasses = extractClasses(out); + Collection outClasses = extractClasses(out); int changedClasses = 0; - for (ModuleData r : outClasses) { + for (ModuleEntry r : outClasses) { if (r.getPath().endsWith("Changed.class")) { ++changedClasses; } @@ -192,15 +192,15 @@ public class VisitorTest extends AsmPluginTestBase { } @Override - public void test(Pool in, Pool out) throws Exception { - Collection inResources = getPool.apply(getPools()).getResourceFiles(); + public void test(ModulePool in, ModulePool out) throws Exception { + Collection inResources = getPool.apply(getPools()).getResourceFiles(); if (inResources.size() != resourceFileVisitor.getAmount()) { throw new AssertionError("Testing " + name + ". Number of visited resources. Expected: " + inResources.size() + ", got: " + resourceFileVisitor.getAmount()); } - Collection outResources = extractResources(out); + Collection outResources = extractResources(out); int changedClasses = 0; - for (ModuleData r : outResources) { + for (ModuleEntry r : outResources) { if (r.getPath().endsWith("Changed")) { ++changedClasses; } diff --git a/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java b/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java index 38054ec2015..781039a517a 100644 --- a/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java +++ b/jdk/test/tools/jlink/customplugin/plugin/CustomPlugin.java @@ -26,7 +26,9 @@ import java.util.Collections; import java.util.HashSet; import java.util.Map; import java.util.Set; -import jdk.tools.jlink.plugin.Pool; +import java.util.function.Function; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; public class CustomPlugin implements TransformerPlugin { @@ -37,13 +39,8 @@ public class CustomPlugin implements TransformerPlugin { } @Override - public void visit(Pool in, Pool out) { - in.visit(new Pool.Visitor() { - @Override - public Pool.ModuleData visit(Pool.ModuleData content) { - return content; - } - }, out); + public void visit(ModulePool in, ModulePool out) { + in.transformAndCopy(Function.identity(), out); } @Override @@ -61,9 +58,9 @@ public class CustomPlugin implements TransformerPlugin { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.PROCESSOR); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.PROCESSOR); return Collections.unmodifiableSet(set); } } diff --git a/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java b/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java index d06f99050b1..aa150350d7f 100644 --- a/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java +++ b/jdk/test/tools/jlink/customplugin/plugin/HelloPlugin.java @@ -29,8 +29,8 @@ import java.util.Collections; import java.util.HashSet; import java.util.Map; import java.util.Set; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; /** @@ -49,23 +49,23 @@ public final class HelloPlugin implements TransformerPlugin { } @Override - public void visit(Pool inResources, Pool outResources) { + public void visit(ModulePool inResources, ModulePool outResources) { try { System.out.println("Hello!!!!!!!!!!"); File f = new File(OUTPUT_FILE); f.createNewFile(); - for (ModuleData res : inResources.getContent()) { + inResources.entries().forEach(res -> { outResources.add(res); - } + }); } catch (IOException ex) { throw new UncheckedIOException(ex); } } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.TRANSFORMER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.TRANSFORMER); return Collections.unmodifiableSet(set); } diff --git a/jdk/test/tools/jlink/plugins/CompressorPluginTest.java b/jdk/test/tools/jlink/plugins/CompressorPluginTest.java index cd01b93836b..d37bf1b73d2 100644 --- a/jdk/test/tools/jlink/plugins/CompressorPluginTest.java +++ b/jdk/test/tools/jlink/plugins/CompressorPluginTest.java @@ -53,14 +53,14 @@ import jdk.internal.jimage.decompressor.ResourceDecompressor; import jdk.internal.jimage.decompressor.ResourceDecompressorFactory; import jdk.internal.jimage.decompressor.StringSharingDecompressorFactory; import jdk.internal.jimage.decompressor.ZipDecompressorFactory; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.internal.StringTable; import jdk.tools.jlink.internal.plugins.DefaultCompressPlugin; import jdk.tools.jlink.internal.plugins.StringSharingPlugin; import jdk.tools.jlink.internal.plugins.ZipPlugin; import jdk.tools.jlink.plugin.Plugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; public class CompressorPluginTest { @@ -86,7 +86,7 @@ public class CompressorPluginTest { new ZipDecompressorFactory() }); - Pool classes = gatherClasses(javabase); + ModulePool classes = gatherClasses(javabase); // compress = String sharing checkCompress(classes, new StringSharingPlugin(), null, new ResourceDecompressorFactory[]{ @@ -173,8 +173,8 @@ public class CompressorPluginTest { Collections.singletonList(".*IOException.class")); } - private Pool gatherResources(Path module) throws Exception { - Pool pool = new PoolImpl(ByteOrder.nativeOrder(), new StringTable() { + private ModulePool gatherResources(Path module) throws Exception { + ModulePool pool = new ModulePoolImpl(ByteOrder.nativeOrder(), new StringTable() { @Override public int addString(String str) { @@ -191,15 +191,15 @@ public class CompressorPluginTest { Path p = iterator.next(); if (Files.isRegularFile(p)) { byte[] content = Files.readAllBytes(p); - pool.add(Pool.newResource(p.toString(), content)); + pool.add(ModuleEntry.create(p.toString(), content)); } } } return pool; } - private Pool gatherClasses(Path module) throws Exception { - Pool pool = new PoolImpl(ByteOrder.nativeOrder(), new StringTable() { + private ModulePool gatherClasses(Path module) throws Exception { + ModulePool pool = new ModulePoolImpl(ByteOrder.nativeOrder(), new StringTable() { @Override public int addString(String str) { @@ -216,27 +216,27 @@ public class CompressorPluginTest { Path p = iterator.next(); if (Files.isRegularFile(p) && p.toString().endsWith(".class")) { byte[] content = Files.readAllBytes(p); - pool.add(Pool.newResource(p.toString(), content)); + pool.add(ModuleEntry.create(p.toString(), content)); } } } return pool; } - private void checkCompress(Pool resources, Plugin prov, + private void checkCompress(ModulePool resources, Plugin prov, Properties config, ResourceDecompressorFactory[] factories) throws Exception { checkCompress(resources, prov, config, factories, Collections.emptyList(), Collections.emptyList()); } - private void checkCompress(Pool resources, Plugin prov, + private void checkCompress(ModulePool resources, Plugin prov, Properties config, ResourceDecompressorFactory[] factories, List includes, List excludes) throws Exception { - long original = 0; - long compressed = 0; - for (ModuleData resource : resources.getContent()) { + long[] original = new long[1]; + long[] compressed = new long[1]; + resources.entries().forEach(resource -> { List includesPatterns = includes.stream() .map(Pattern::compile) .collect(Collectors.toList()); @@ -252,7 +252,7 @@ public class CompressorPluginTest { } prov.configure(props); final Map strings = new HashMap<>(); - PoolImpl inputResources = new PoolImpl(ByteOrder.nativeOrder(), new StringTable() { + ModulePoolImpl inputResources = new ModulePoolImpl(ByteOrder.nativeOrder(), new StringTable() { @Override public int addString(String str) { int id = strID; @@ -267,32 +267,32 @@ public class CompressorPluginTest { } }); inputResources.add(resource); - Pool compressedResources = applyCompressor(prov, inputResources, resource, includesPatterns, excludesPatterns); - original += resource.getLength(); - compressed += compressedResources.get(resource.getPath()).getLength(); + ModulePool compressedResources = applyCompressor(prov, inputResources, resource, includesPatterns, excludesPatterns); + original[0] += resource.getLength(); + compressed[0] += compressedResources.findEntry(resource.getPath()).get().getLength(); applyDecompressors(factories, inputResources, compressedResources, strings, includesPatterns, excludesPatterns); - } + }); String compressors = Stream.of(factories) .map(Object::getClass) .map(Class::getSimpleName) .collect(Collectors.joining(", ")); - String size = "Compressed size: " + compressed + ", original size: " + original; + String size = "Compressed size: " + compressed[0] + ", original size: " + original[0]; System.out.println("Used " + compressors + ". " + size); - if (original <= compressed) { + if (original[0] <= compressed[0]) { throw new AssertionError("java.base not compressed."); } } - private Pool applyCompressor(Plugin plugin, - PoolImpl inputResources, - ModuleData res, + private ModulePool applyCompressor(Plugin plugin, + ModulePoolImpl inputResources, + ModuleEntry res, List includesPatterns, - List excludesPatterns) throws Exception { + List excludesPatterns) { TransformerPlugin compressor = (TransformerPlugin) plugin; - Pool compressedPool = new PoolImpl(ByteOrder.nativeOrder(), inputResources.getStringTable()); - compressor.visit(inputResources, compressedPool); + ModulePool compressedModulePool = new ModulePoolImpl(ByteOrder.nativeOrder(), inputResources.getStringTable()); + compressor.visit(inputResources, compressedModulePool); String path = res.getPath(); - ModuleData compressed = compressedPool.get(path); + ModuleEntry compressed = compressedModulePool.findEntry(path).get(); CompressedResourceHeader header = CompressedResourceHeader.readFromResource(ByteOrder.nativeOrder(), compressed.getBytes()); if (isIncluded(includesPatterns, excludesPatterns, path)) { @@ -310,29 +310,33 @@ public class CompressorPluginTest { } else if (header != null) { throw new AssertionError("Path should not be compressed: " + path); } - return compressedPool; + return compressedModulePool; } private void applyDecompressors(ResourceDecompressorFactory[] decompressors, - Pool inputResources, - Pool compressedResources, + ModulePool inputResources, + ModulePool compressedResources, Map strings, List includesPatterns, - List excludesPatterns) throws Exception { - for (ModuleData compressed : compressedResources.getContent()) { + List excludesPatterns) { + compressedResources.entries().forEach(compressed -> { CompressedResourceHeader header = CompressedResourceHeader.readFromResource( ByteOrder.nativeOrder(), compressed.getBytes()); String path = compressed.getPath(); - ModuleData orig = inputResources.get(path); + ModuleEntry orig = inputResources.findEntry(path).get(); if (!isIncluded(includesPatterns, excludesPatterns, path)) { - continue; + return; } byte[] decompressed = compressed.getBytes(); for (ResourceDecompressorFactory factory : decompressors) { - ResourceDecompressor decompressor = factory.newDecompressor(new Properties()); - decompressed = decompressor.decompress( + try { + ResourceDecompressor decompressor = factory.newDecompressor(new Properties()); + decompressed = decompressor.decompress( strings::get, decompressed, CompressedResourceHeader.getSize(), header.getUncompressedSize()); + } catch (Exception exp) { + throw new RuntimeException(exp); + } } if (decompressed.length != orig.getLength()) { @@ -345,7 +349,7 @@ public class CompressorPluginTest { throw new AssertionError("Decompressed and original differ at index " + i); } } - } + }); } private boolean isIncluded(List includesPatterns, List excludesPatterns, String path) { diff --git a/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java b/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java index cde83aa2761..744d7a2ba25 100644 --- a/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java +++ b/jdk/test/tools/jlink/plugins/ExcludeFilesPluginTest.java @@ -35,12 +35,11 @@ import java.io.File; import java.nio.file.Files; import java.util.HashMap; import java.util.Map; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.internal.plugins.ExcludeFilesPlugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; -import jdk.tools.jlink.plugin.Pool.ModuleDataType; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; public class ExcludeFilesPluginTest { @@ -73,20 +72,20 @@ public class ExcludeFilesPluginTest { prop.put(ExcludeFilesPlugin.NAME, s); ExcludeFilesPlugin fplug = new ExcludeFilesPlugin(); fplug.configure(prop); - PoolImpl files = new PoolImpl(); - PoolImpl fresult = new PoolImpl(); - ModuleData f = Pool.newImageFile(module, "/" + module + "/" + sample, - ModuleDataType.CONFIG, new ByteArrayInputStream(new byte[0]), 0); + ModulePoolImpl files = new ModulePoolImpl(); + ModulePoolImpl fresult = new ModulePoolImpl(); + ModuleEntry f = ModuleEntry.create(module, "/" + module + "/" + sample, + ModuleEntry.Type.CONFIG, new ByteArrayInputStream(new byte[0]), 0); files.add(f); fplug.visit(files, fresult); if (exclude) { - if (fresult.getContent().contains(f)) { + if (fresult.contains(f)) { throw new Exception(sample + " should be excluded by " + s); } } else { - if (!fresult.getContent().contains(f)) { + if (!fresult.contains(f)) { throw new Exception(sample + " shouldn't be excluded by " + s); } } diff --git a/jdk/test/tools/jlink/plugins/ExcludePluginTest.java b/jdk/test/tools/jlink/plugins/ExcludePluginTest.java index 0f508073288..c39e738e079 100644 --- a/jdk/test/tools/jlink/plugins/ExcludePluginTest.java +++ b/jdk/test/tools/jlink/plugins/ExcludePluginTest.java @@ -34,11 +34,11 @@ import java.io.File; import java.nio.file.Files; import java.util.HashMap; import java.util.Map; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.internal.plugins.ExcludePlugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; public class ExcludePluginTest { @@ -75,17 +75,17 @@ public class ExcludePluginTest { prop.put(ExcludePlugin.NAME, s); ExcludePlugin excludePlugin = new ExcludePlugin(); excludePlugin.configure(prop); - Pool resources = new PoolImpl(); - ModuleData resource = Pool.newResource(sample, new byte[0]); + ModulePool resources = new ModulePoolImpl(); + ModuleEntry resource = ModuleEntry.create(sample, new byte[0]); resources.add(resource); - Pool result = new PoolImpl(); + ModulePool result = new ModulePoolImpl(); excludePlugin.visit(resources, result); if (exclude) { - if (result.getContent().contains(resource)) { + if (result.contains(resource)) { throw new AssertionError(sample + " should be excluded by " + s); } } else { - if (!result.getContent().contains(resource)) { + if (!result.contains(resource)) { throw new AssertionError(sample + " shouldn't be excluded by " + s); } } diff --git a/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java b/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java index 701368c3dd0..edc10702eb3 100644 --- a/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java +++ b/jdk/test/tools/jlink/plugins/ExcludeVMPluginTest.java @@ -32,13 +32,12 @@ import java.io.ByteArrayInputStream; import java.util.HashMap; import java.util.Map; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.internal.plugins.ExcludeVMPlugin; import jdk.tools.jlink.plugin.Plugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; -import jdk.tools.jlink.plugin.Pool.ModuleDataType; +import jdk.tools.jlink.plugin.ModulePool; +import jdk.tools.jlink.plugin.ModuleEntry; import jdk.tools.jlink.plugin.TransformerPlugin; public class ExcludeVMPluginTest { @@ -165,14 +164,14 @@ public class ExcludeVMPluginTest { private void doCheckVM(String vm, String[] input, String jvmcfg, String[] expectedOutput, String expectdJvmCfg) throws Exception { // Create a pool with jvm.cfg and the input paths. byte[] jvmcfgContent = jvmcfg.getBytes(); - Pool pool = new PoolImpl(); - pool.add(Pool.newImageFile("java.base", "/java.base/native/jvm.cfg", - ModuleDataType.NATIVE_LIB, new ByteArrayInputStream(jvmcfgContent), jvmcfgContent.length)); + ModulePool pool = new ModulePoolImpl(); + pool.add(ModuleEntry.create("java.base", "/java.base/native/jvm.cfg", + ModuleEntry.Type.NATIVE_LIB, new ByteArrayInputStream(jvmcfgContent), jvmcfgContent.length)); for (String in : input) { - pool.add(Pool.newImageFile("java.base", in, - ModuleDataType.NATIVE_LIB, new ByteArrayInputStream(new byte[0]), 0)); + pool.add(ModuleEntry.create("java.base", in, + ModuleEntry.Type.NATIVE_LIB, new ByteArrayInputStream(new byte[0]), 0)); } - Pool out = new PoolImpl(); + ModulePool out = new ModulePoolImpl(); TransformerPlugin p = new ExcludeVMPlugin(); Map config = new HashMap<>(); @@ -182,22 +181,22 @@ public class ExcludeVMPluginTest { p.configure(config); p.visit(pool, out); - String newContent = new String(out.get("/java.base/native/jvm.cfg").stream().readAllBytes()); + String newContent = new String(out.findEntry("/java.base/native/jvm.cfg").get().stream().readAllBytes()); if (!expectdJvmCfg.equals(newContent)) { throw new Exception("Got content " + newContent + " expected " + expectdJvmCfg); } - if (out.getContent().size() != (expectedOutput.length + 1)) { - for (ModuleData m : out.getContent()) { + if (out.getEntryCount() != (expectedOutput.length + 1)) { + out.entries().forEach(m -> { System.err.println(m.getPath()); - } - throw new Exception("Invalid output size " + out.getContent().size() + " expected " + (expectedOutput.length + 1)); + }); + throw new Exception("Invalid output size " + out.getEntryCount() + " expected " + (expectedOutput.length + 1)); } - for (ModuleData md : out.getContent()) { + out.entries().forEach(md -> { if (md.getPath().equals("/java.base/native/jvm.cfg")) { - continue; + return; } boolean contained = false; for (String o : expectedOutput) { @@ -207,9 +206,9 @@ public class ExcludeVMPluginTest { } } if (!contained) { - throw new Exception(md.getPath() + " not expected"); + throw new RuntimeException(md.getPath() + " not expected"); } - } + }); } diff --git a/jdk/test/tools/jlink/plugins/FileCopierPluginTest.java b/jdk/test/tools/jlink/plugins/FileCopierPluginTest.java index 5fecfec388b..a6fb749ba7f 100644 --- a/jdk/test/tools/jlink/plugins/FileCopierPluginTest.java +++ b/jdk/test/tools/jlink/plugins/FileCopierPluginTest.java @@ -26,6 +26,7 @@ * @summary Test files copy plugin * @author Jean-Francois Denise * @modules jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink.builder * jdk.jlink/jdk.tools.jlink.internal.plugins * @run main FileCopierPluginTest */ @@ -36,13 +37,12 @@ import java.nio.file.Path; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.builder.DefaultImageBuilder; import jdk.tools.jlink.internal.plugins.FileCopierPlugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; -import jdk.tools.jlink.plugin.Pool.ModuleDataType; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; public class FileCopierPluginTest { @@ -85,21 +85,20 @@ public class FileCopierPluginTest { Map conf = new HashMap<>(); conf.put(FileCopierPlugin.NAME, builder.toString()); plug.configure(conf); - Pool pool = new PoolImpl(); - plug.visit(new PoolImpl(), pool); - if (pool.getContent().size() != expected) { + ModulePool pool = new ModulePoolImpl(); + plug.visit(new ModulePoolImpl(), pool); + if (pool.getEntryCount() != expected) { throw new AssertionError("Wrong number of added files"); } - for (ModuleData f : pool.getContent()) { - if (!f.getType().equals(ModuleDataType.OTHER)) { + pool.entries().forEach(f -> { + if (!f.getType().equals(ModuleEntry.Type.OTHER)) { throw new AssertionError("Invalid type " + f.getType() + " for file " + f.getPath()); } if (f.stream() == null) { throw new AssertionError("Null stream for file " + f.getPath()); } - - } + }); Path root = new File(".").toPath(); DefaultImageBuilder imgbuilder = new DefaultImageBuilder(root); imgbuilder.storeFiles(pool); diff --git a/jdk/test/tools/jlink/plugins/LastSorterTest.java b/jdk/test/tools/jlink/plugins/LastSorterTest.java index 100ca1e4674..0dc27b44ec8 100644 --- a/jdk/test/tools/jlink/plugins/LastSorterTest.java +++ b/jdk/test/tools/jlink/plugins/LastSorterTest.java @@ -26,6 +26,7 @@ * @summary Test last sorter property * @author Jean-Francois Denise * @modules jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink * @run main/othervm LastSorterTest */ @@ -40,12 +41,12 @@ import java.util.Set; import jdk.tools.jlink.internal.ImagePluginConfiguration; import jdk.tools.jlink.internal.PluginRepository; import jdk.tools.jlink.internal.ImagePluginStack; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.Jlink; import jdk.tools.jlink.Jlink.PluginsConfiguration; import jdk.tools.jlink.plugin.Plugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; public class LastSorterTest { @@ -80,7 +81,7 @@ public class LastSorterTest { ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(config); // check order - PoolImpl res = fillOutResourcePool(); + ModulePoolImpl res = fillOutResourceModulePool(); try { stack.visitResources(res); @@ -91,18 +92,18 @@ public class LastSorterTest { } } - private PoolImpl fillOutResourcePool() throws Exception { - PoolImpl res = new PoolImpl(); - res.add(Pool.newResource("/eee/bbb/res1.class", new byte[90])); - res.add(Pool.newResource("/aaaa/bbb/res2.class", new byte[90])); - res.add(Pool.newResource("/bbb/aa/res1.class", new byte[90])); - res.add(Pool.newResource("/aaaa/bbb/res3.class", new byte[90])); - res.add(Pool.newResource("/bbb/aa/res2.class", new byte[90])); - res.add(Pool.newResource("/fff/bbb/res1.class", new byte[90])); - res.add(Pool.newResource("/aaaa/bbb/res1.class", new byte[90])); - res.add(Pool.newResource("/bbb/aa/res3.class", new byte[90])); - res.add(Pool.newResource("/ccc/bbb/res1.class", new byte[90])); - res.add(Pool.newResource("/ddd/bbb/res1.class", new byte[90])); + private ModulePoolImpl fillOutResourceModulePool() throws Exception { + ModulePoolImpl res = new ModulePoolImpl(); + res.add(ModuleEntry.create("/eee/bbb/res1.class", new byte[90])); + res.add(ModuleEntry.create("/aaaa/bbb/res2.class", new byte[90])); + res.add(ModuleEntry.create("/bbb/aa/res1.class", new byte[90])); + res.add(ModuleEntry.create("/aaaa/bbb/res3.class", new byte[90])); + res.add(ModuleEntry.create("/bbb/aa/res2.class", new byte[90])); + res.add(ModuleEntry.create("/fff/bbb/res1.class", new byte[90])); + res.add(ModuleEntry.create("/aaaa/bbb/res1.class", new byte[90])); + res.add(ModuleEntry.create("/bbb/aa/res3.class", new byte[90])); + res.add(ModuleEntry.create("/ccc/bbb/res1.class", new byte[90])); + res.add(ModuleEntry.create("/ddd/bbb/res1.class", new byte[90])); return res; } @@ -124,7 +125,7 @@ public class LastSorterTest { ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(config); // check order - PoolImpl res = fillOutResourcePool(); + ModulePoolImpl res = fillOutResourceModulePool(); stack.visitResources(res); } @@ -159,7 +160,7 @@ public class LastSorterTest { ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(config); // check order - PoolImpl res = fillOutResourcePool(); + ModulePoolImpl res = fillOutResourceModulePool(); try { stack.visitResources(res); throw new AssertionError("Order was changed after the last sorter, but no exception occurred"); @@ -178,17 +179,17 @@ public class LastSorterTest { } @Override - public void visit(Pool resources, Pool output) { - List paths = new ArrayList<>(); - for (ModuleData res : resources.getContent()) { + public void visit(ModulePool resources, ModulePool output) { + List paths = new ArrayList<>(); + resources.entries().forEach(res -> { if (res.getPath().startsWith(starts)) { paths.add(0, res); } else { paths.add(res); } - } + }); - for (ModuleData r : paths) { + for (ModuleEntry r : paths) { output.add(r); } } @@ -199,9 +200,9 @@ public class LastSorterTest { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.TRANSFORMER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.TRANSFORMER); return Collections.unmodifiableSet(set); } diff --git a/jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java b/jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java index cbf418669c0..701736139c6 100644 --- a/jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java +++ b/jdk/test/tools/jlink/plugins/OrderResourcesPluginTest.java @@ -36,11 +36,12 @@ import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.Map; -import jdk.tools.jlink.internal.PoolImpl; +import java.util.stream.Collectors; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.internal.plugins.OrderResourcesPlugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; public class OrderResourcesPluginTest { @@ -50,52 +51,52 @@ public class OrderResourcesPluginTest { } public void test() throws Exception { - ModuleData[] array = { - Pool.newResource("/module1/toto1.class", new byte[0]), - Pool.newResource("/module2/toto2.class", new byte[0]), - Pool.newResource("/module3/toto3.class", new byte[0]), - Pool.newResource("/module3/toto3/module-info.class", new byte[0]), - Pool.newResource("/zazou/toto.class", new byte[0]), - Pool.newResource("/module4/zazou.class", new byte[0]), - Pool.newResource("/module5/toto5.class", new byte[0]), - Pool.newResource("/module6/toto6/module-info.class", new byte[0]) + ModuleEntry[] array = { + ModuleEntry.create("/module1/toto1.class", new byte[0]), + ModuleEntry.create("/module2/toto2.class", new byte[0]), + ModuleEntry.create("/module3/toto3.class", new byte[0]), + ModuleEntry.create("/module3/toto3/module-info.class", new byte[0]), + ModuleEntry.create("/zazou/toto.class", new byte[0]), + ModuleEntry.create("/module4/zazou.class", new byte[0]), + ModuleEntry.create("/module5/toto5.class", new byte[0]), + ModuleEntry.create("/module6/toto6/module-info.class", new byte[0]) }; - ModuleData[] sorted = { - Pool.newResource("/zazou/toto.class", new byte[0]), - Pool.newResource("/module3/toto3/module-info.class", new byte[0]), - Pool.newResource("/module6/toto6/module-info.class", new byte[0]), - Pool.newResource("/module1/toto1.class", new byte[0]), - Pool.newResource("/module2/toto2.class", new byte[0]), - Pool.newResource("/module3/toto3.class", new byte[0]), - Pool.newResource("/module4/zazou.class", new byte[0]), - Pool.newResource("/module5/toto5.class", new byte[0]) + ModuleEntry[] sorted = { + ModuleEntry.create("/zazou/toto.class", new byte[0]), + ModuleEntry.create("/module3/toto3/module-info.class", new byte[0]), + ModuleEntry.create("/module6/toto6/module-info.class", new byte[0]), + ModuleEntry.create("/module1/toto1.class", new byte[0]), + ModuleEntry.create("/module2/toto2.class", new byte[0]), + ModuleEntry.create("/module3/toto3.class", new byte[0]), + ModuleEntry.create("/module4/zazou.class", new byte[0]), + ModuleEntry.create("/module5/toto5.class", new byte[0]) }; - ModuleData[] sorted2 = { - Pool.newResource("/module5/toto5.class", new byte[0]), - Pool.newResource("/module6/toto6/module-info.class", new byte[0]), - Pool.newResource("/module4/zazou.class", new byte[0]), - Pool.newResource("/module3/toto3.class", new byte[0]), - Pool.newResource("/module3/toto3/module-info.class", new byte[0]), - Pool.newResource("/module1/toto1.class", new byte[0]), - Pool.newResource("/module2/toto2.class", new byte[0]), - Pool.newResource("/zazou/toto.class", new byte[0]) + ModuleEntry[] sorted2 = { + ModuleEntry.create("/module5/toto5.class", new byte[0]), + ModuleEntry.create("/module6/toto6/module-info.class", new byte[0]), + ModuleEntry.create("/module4/zazou.class", new byte[0]), + ModuleEntry.create("/module3/toto3.class", new byte[0]), + ModuleEntry.create("/module3/toto3/module-info.class", new byte[0]), + ModuleEntry.create("/module1/toto1.class", new byte[0]), + ModuleEntry.create("/module2/toto2.class", new byte[0]), + ModuleEntry.create("/zazou/toto.class", new byte[0]) }; - Pool resources = new PoolImpl(); - for (ModuleData r : array) { + ModulePool resources = new ModulePoolImpl(); + for (ModuleEntry r : array) { resources.add(r); } { - Pool out = new PoolImpl(); + ModulePool out = new ModulePoolImpl(); Map config = new HashMap<>(); config.put(OrderResourcesPlugin.NAME, "/zazou/*,*/module-info.class"); TransformerPlugin p = new OrderResourcesPlugin(); p.configure(config); p.visit(resources, out); - check(out.getContent(), sorted); + check(out.entries().collect(Collectors.toList()), sorted); } { @@ -112,26 +113,26 @@ public class OrderResourcesPluginTest { } Files.write(order.toPath(), builder.toString().getBytes()); - Pool out = new PoolImpl(); + ModulePool out = new ModulePoolImpl(); Map config = new HashMap<>(); config.put(OrderResourcesPlugin.NAME, "@" + order.getAbsolutePath()); TransformerPlugin p = new OrderResourcesPlugin(); p.configure(config); p.visit(resources, out); - check(out.getContent(), sorted2); + check(out.entries().collect(Collectors.toList()), sorted2); } } - private void check(Collection outResources, - ModuleData[] sorted) { + private void check(Collection outResources, + ModuleEntry[] sorted) { if (outResources.size() != sorted.length) { throw new AssertionError("Wrong number of resources:\n" + "expected: " + Arrays.toString(sorted) + ",\n" + " got: " + outResources); } int i = 0; - for (ModuleData r : outResources) { + for (ModuleEntry r : outResources) { System.err.println("Resource: " + r); if (!sorted[i].getPath().equals(r.getPath())) { throw new AssertionError("Resource not properly sorted, difference at: " + i + "\n" diff --git a/jdk/test/tools/jlink/plugins/PluginOrderTest.java b/jdk/test/tools/jlink/plugins/PluginOrderTest.java index 42655d408fe..4c9f2c2241d 100644 --- a/jdk/test/tools/jlink/plugins/PluginOrderTest.java +++ b/jdk/test/tools/jlink/plugins/PluginOrderTest.java @@ -44,8 +44,8 @@ import java.util.Set; import jdk.tools.jlink.internal.PluginOrderingGraph; import jdk.tools.jlink.plugin.Plugin; -import jdk.tools.jlink.plugin.Plugin.CATEGORY; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.Plugin.Category; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; public class PluginOrderTest { @@ -96,8 +96,8 @@ public class PluginOrderTest { set.add("plug2"); List plugins = new ArrayList<>(); plugins.add(new Plug("plug2", Collections.emptySet(), Collections.emptySet(), - CATEGORY.TRANSFORMER)); - plugins.add(new Plug("plug1", set, Collections.emptySet(), CATEGORY.TRANSFORMER)); + Category.TRANSFORMER)); + plugins.add(new Plug("plug1", set, Collections.emptySet(), Category.TRANSFORMER)); List ordered = PluginOrderingGraph.sort(plugins); if (ordered.get(0) != plugins.get(1) || ordered.get(1) != plugins.get(0)) { throw new Exception("Invalid sorting"); @@ -108,32 +108,32 @@ public class PluginOrderTest { Set lst1 = new HashSet<>(); lst1.add("plug2"); lst1.add("plug3"); - Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), Category.TRANSFORMER); - Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER); Set lst3 = new HashSet<>(); lst3.add("plug4"); lst3.add("plug6"); - Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), Category.TRANSFORMER); - Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER); Set lst5 = new HashSet<>(); lst5.add("plug3"); lst5.add("plug1"); lst5.add("plug2"); lst5.add("plug6"); - Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), Category.TRANSFORMER); Set lst6 = new HashSet<>(); lst6.add("plug4"); lst6.add("plug2"); - Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), Category.TRANSFORMER); - Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER); - Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER); List plugins = new ArrayList<>(); plugins.add(p1); @@ -153,11 +153,11 @@ public class PluginOrderTest { set2.add("plug1"); List plugins = new ArrayList<>(); plugins.add(new Plug("plug2", set2, Collections.emptySet(), - CATEGORY.TRANSFORMER)); + Category.TRANSFORMER)); Set set1 = new HashSet<>(); set1.add("plug2"); - plugins.add(new Plug("plug1", set1, Collections.emptySet(), CATEGORY.TRANSFORMER)); + plugins.add(new Plug("plug1", set1, Collections.emptySet(), Category.TRANSFORMER)); PluginOrderingGraph.sort(plugins); } @@ -166,31 +166,31 @@ public class PluginOrderTest { Set lst1 = new HashSet<>(); lst1.add("plug2"); lst1.add("plug3"); - Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p1 = new Plug("plug1", lst1, Collections.emptySet(), Category.TRANSFORMER); - Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER); Set lst3 = new HashSet<>(); lst3.add("plug4"); lst3.add("plug6"); - Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p3 = new Plug("plug3", lst3, Collections.emptySet(), Category.TRANSFORMER); - Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p4 = new Plug("plug4", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER); Set lst5 = new HashSet<>(); lst5.add("plug3"); lst5.add("plug1"); lst5.add("plug2"); - Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p5 = new Plug("plug5", lst5, Collections.emptySet(), Category.TRANSFORMER); Set lst6 = new HashSet<>(); lst6.add("plug4"); lst6.add("plug1"); - Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p6 = new Plug("plug6", lst6, Collections.emptySet(), Category.TRANSFORMER); - Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p7 = new Plug("plug7", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER); - Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p8 = new Plug("plug8", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER); List plugins = new ArrayList<>(); plugins.add(p1); @@ -208,8 +208,8 @@ public class PluginOrderTest { Set lst1 = new HashSet<>(); lst1.add("plug2"); lst1.add("plug3"); - Plugin p = new Plug("plug1", lst1, Collections.emptySet(), CATEGORY.TRANSFORMER); - Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), CATEGORY.TRANSFORMER); + Plugin p = new Plug("plug1", lst1, Collections.emptySet(), Category.TRANSFORMER); + Plugin p2 = new Plug("plug2", Collections.emptySet(), Collections.emptySet(), Category.TRANSFORMER); Set lst3 = new HashSet<>(); lst3.add("plug2"); @@ -217,7 +217,7 @@ public class PluginOrderTest { Set lst4 = new HashSet<>(); lst4.add("plug1"); - Plugin p3 = new Plug("plug3", lst4, lst3, CATEGORY.TRANSFORMER); + Plugin p3 = new Plug("plug3", lst4, lst3, Category.TRANSFORMER); List plugins = new ArrayList<>(); plugins.add(p); plugins.add(p2); @@ -229,10 +229,10 @@ public class PluginOrderTest { private final Set isBefore; private final Set isAfter; - private final CATEGORY category; + private final Category category; private final String name; - private Plug(String name, Set isBefore, Set isAfter, CATEGORY category) { + private Plug(String name, Set isBefore, Set isAfter, Category category) { this.name = name; this.isBefore = isBefore; this.isAfter = isAfter; @@ -255,12 +255,12 @@ public class PluginOrderTest { } @Override - public void visit(Pool in, Pool out) { + public void visit(ModulePool in, ModulePool out) { } @Override - public Set getType() { + public Set getType() { return Collections.singleton(category); } diff --git a/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java b/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java index 525fb0b5ce2..5b8ed2d6c83 100644 --- a/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java +++ b/jdk/test/tools/jlink/plugins/PluginsNegativeTest.java @@ -26,6 +26,7 @@ * @summary Negative test for ImagePluginStack. * @author Andrei Eremeev * @modules jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink * @run main/othervm PluginsNegativeTest */ import java.lang.reflect.Layer; @@ -39,11 +40,12 @@ import java.util.Set; import jdk.tools.jlink.internal.ImagePluginConfiguration; import jdk.tools.jlink.internal.PluginRepository; import jdk.tools.jlink.internal.ImagePluginStack; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.Jlink; import jdk.tools.jlink.Jlink.PluginsConfiguration; import jdk.tools.jlink.plugin.Plugin; -import jdk.tools.jlink.plugin.Pool; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; public class PluginsNegativeTest { @@ -96,8 +98,8 @@ public class PluginsNegativeTest { plugins.add(createPlugin("plugin")); ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(new PluginsConfiguration(plugins, null, null)); - PoolImpl inResources = new PoolImpl(); - inResources.add(Pool.newResource("/aaa/bbb/A", new byte[10])); + ModulePoolImpl inResources = new ModulePoolImpl(); + inResources.add(ModuleEntry.create("/aaa/bbb/A", new byte[10])); try { stack.visitResources(inResources); throw new AssertionError("Exception expected when output resource is empty"); @@ -110,8 +112,8 @@ public class PluginsNegativeTest { plugins.add(createPlugin("plugin")); ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(new PluginsConfiguration(plugins, null, null)); - PoolImpl inResources = new PoolImpl(); - PoolImpl outResources = (PoolImpl) stack.visitResources(inResources); + ModulePoolImpl inResources = new ModulePoolImpl(); + ModulePoolImpl outResources = (ModulePoolImpl) stack.visitResources(inResources); if (!outResources.isEmpty()) { throw new AssertionError("Output resource is not empty"); } @@ -126,7 +128,7 @@ public class PluginsNegativeTest { } @Override - public void visit(Pool inResources, Pool outResources) { + public void visit(ModulePool inResources, ModulePool outResources) { // do nothing } @@ -136,9 +138,9 @@ public class PluginsNegativeTest { } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.TRANSFORMER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.TRANSFORMER); return Collections.unmodifiableSet(set); } diff --git a/jdk/test/tools/jlink/plugins/PrevisitorTest.java b/jdk/test/tools/jlink/plugins/PrevisitorTest.java index 16d79f0c068..1f721d66d5f 100644 --- a/jdk/test/tools/jlink/plugins/PrevisitorTest.java +++ b/jdk/test/tools/jlink/plugins/PrevisitorTest.java @@ -26,6 +26,7 @@ * @summary Test previsitor * @author Andrei Eremeev * @modules jdk.jlink/jdk.tools.jlink.internal + * jdk.jlink/jdk.tools.jlink * @run main/othervm PrevisitorTest */ import java.nio.ByteOrder; @@ -36,19 +37,20 @@ import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; import jdk.tools.jlink.internal.ImagePluginConfiguration; import jdk.tools.jlink.internal.PluginRepository; import jdk.tools.jlink.internal.ImagePluginStack; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.internal.ResourcePrevisitor; import jdk.tools.jlink.internal.StringTable; import jdk.tools.jlink.Jlink; import jdk.tools.jlink.plugin.Plugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; public class PrevisitorTest { @@ -68,17 +70,17 @@ public class PrevisitorTest { plugins.add(createPlugin(CustomPlugin.NAME)); ImagePluginStack stack = ImagePluginConfiguration.parseConfiguration(new Jlink.PluginsConfiguration(plugins, null, null)); - PoolImpl inResources = new PoolImpl(ByteOrder.nativeOrder(), new CustomStringTable()); - inResources.add(Pool.newResource("/aaa/bbb/res1.class", new byte[90])); - inResources.add(Pool.newResource("/aaa/bbb/res2.class", new byte[90])); - inResources.add(Pool.newResource("/aaa/bbb/res3.class", new byte[90])); - inResources.add(Pool.newResource("/aaa/ddd/res1.class", new byte[90])); - inResources.add(Pool.newResource("/aaa/res1.class", new byte[90])); - Pool outResources = stack.visitResources(inResources); - Collection input = inResources.getContent().stream() + ModulePoolImpl inResources = new ModulePoolImpl(ByteOrder.nativeOrder(), new CustomStringTable()); + inResources.add(ModuleEntry.create("/aaa/bbb/res1.class", new byte[90])); + inResources.add(ModuleEntry.create("/aaa/bbb/res2.class", new byte[90])); + inResources.add(ModuleEntry.create("/aaa/bbb/res3.class", new byte[90])); + inResources.add(ModuleEntry.create("/aaa/ddd/res1.class", new byte[90])); + inResources.add(ModuleEntry.create("/aaa/res1.class", new byte[90])); + ModulePool outResources = stack.visitResources(inResources); + Collection input = inResources.entries() .map(Object::toString) .collect(Collectors.toList()); - Collection output = outResources.getContent().stream() + Collection output = outResources.entries() .map(Object::toString) .collect(Collectors.toList()); if (!input.equals(output)) { @@ -114,19 +116,20 @@ public class PrevisitorTest { private boolean isPrevisitCalled = false; @Override - public void visit(Pool inResources, Pool outResources) { + public void visit(ModulePool inResources, ModulePool outResources) { if (!isPrevisitCalled) { throw new AssertionError("Previsit was not called"); } CustomStringTable table = (CustomStringTable) - ((PoolImpl) inResources).getStringTable(); + ((ModulePoolImpl) inResources).getStringTable(); if (table.size() == 0) { throw new AssertionError("Table is empty"); } Map count = new HashMap<>(); for (int i = 0; i < table.size(); ++i) { String s = table.getString(i); - if (inResources.get(s) != null) { + Optional e = inResources.findEntry(s); + if (e.isPresent()) { throw new AssertionError(); } count.compute(s, (k, c) -> 1 + (c == null ? 0 : c)); @@ -136,9 +139,9 @@ public class PrevisitorTest { throw new AssertionError("Expected one entry in the table, got: " + v + " for " + k); } }); - for (ModuleData r : inResources.getContent()) { + inResources.entries().forEach(r -> { outResources.add(r); - } + }); } @Override @@ -147,21 +150,21 @@ public class PrevisitorTest { } @Override - public void previsit(Pool resources, StringTable strings) { + public void previsit(ModulePool resources, StringTable strings) { isPrevisitCalled = true; - for (ModuleData r : resources.getContent()) { + resources.entries().forEach(r -> { String s = r.getPath(); int lastIndexOf = s.lastIndexOf('/'); if (lastIndexOf >= 0) { strings.addString(s.substring(0, lastIndexOf)); } - } + }); } @Override - public Set getType() { - Set set = new HashSet<>(); - set.add(CATEGORY.TRANSFORMER); + public Set getType() { + Set set = new HashSet<>(); + set.add(Category.TRANSFORMER); return Collections.unmodifiableSet(set); } } diff --git a/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java b/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java index 786da460990..c02a8e6db0c 100644 --- a/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java +++ b/jdk/test/tools/jlink/plugins/StringSharingPluginTest.java @@ -38,6 +38,8 @@ * @run main StringSharingPluginTest */ +import java.io.IOException; +import java.io.UncheckedIOException; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.file.Files; @@ -50,11 +52,11 @@ import java.util.function.Consumer; import jdk.internal.jimage.decompressor.CompressedResourceHeader; import jdk.internal.jimage.decompressor.StringSharingDecompressor; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.internal.StringTable; import jdk.tools.jlink.internal.plugins.StringSharingPlugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; import tests.Helper; import tests.JImageValidator; @@ -78,7 +80,7 @@ public class StringSharingPluginTest { Map map = new HashMap<>(); Map reversedMap = new HashMap<>(); - PoolImpl resources = new PoolImpl(ByteOrder.nativeOrder(), new StringTable() { + ModulePoolImpl resources = new ModulePoolImpl(ByteOrder.nativeOrder(), new StringTable() { @Override public int addString(String str) { Integer id = map.get(str); @@ -104,7 +106,7 @@ public class StringSharingPluginTest { byte[] content = Files.readAllBytes(p); String path = p.toString().replace('\\', '/'); path = path.substring("/modules".length()); - ModuleData res = Pool.newResource(path, content); + ModuleEntry res = ModuleEntry.create(path, content); resources.add(res); } catch (Exception ex) { throw new RuntimeException(ex); @@ -115,19 +117,23 @@ public class StringSharingPluginTest { stream.forEach(c); } TransformerPlugin plugin = new StringSharingPlugin(); - PoolImpl result = new PoolImpl(resources.getByteOrder(), resources.getStringTable()); + ModulePoolImpl result = new ModulePoolImpl(resources.getByteOrder(), resources.getStringTable()); plugin.visit(resources, result); if (result.isEmpty()) { throw new AssertionError("No result"); } - for (ModuleData res : result.getContent()) { + result.entries().forEach(res -> { if (res.getPath().endsWith(".class")) { - byte[] uncompacted = StringSharingDecompressor.normalize(reversedMap::get, res.getBytes(), + try { + byte[] uncompacted = StringSharingDecompressor.normalize(reversedMap::get, res.getBytes(), CompressedResourceHeader.getSize()); - JImageValidator.readClass(uncompacted); + JImageValidator.readClass(uncompacted); + } catch (IOException exp) { + throw new UncheckedIOException(exp); + } } - } + }); } } diff --git a/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java b/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java index fd8acae896c..d3617db6f8a 100644 --- a/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java +++ b/jdk/test/tools/jlink/plugins/StripDebugPluginTest.java @@ -54,10 +54,10 @@ import com.sun.tools.classfile.ConstantPoolException; import com.sun.tools.classfile.Method; import java.util.HashMap; import java.util.Map; -import jdk.tools.jlink.internal.PoolImpl; +import jdk.tools.jlink.internal.ModulePoolImpl; import jdk.tools.jlink.internal.plugins.StripDebugPlugin; -import jdk.tools.jlink.plugin.Pool; -import jdk.tools.jlink.plugin.Pool.ModuleData; +import jdk.tools.jlink.plugin.ModuleEntry; +import jdk.tools.jlink.plugin.ModulePool; import jdk.tools.jlink.plugin.TransformerPlugin; import tests.Helper; @@ -106,7 +106,7 @@ public class StripDebugPluginTest { path = path.replace('\\', '/'); StripDebugPlugin debug = new StripDebugPlugin(); debug.configure(new HashMap<>()); - ModuleData result1 = stripDebug(debug, Pool.newResource(path,content), path, infoPath, moduleInfo); + ModuleEntry result1 = stripDebug(debug, ModuleEntry.create(path,content), path, infoPath, moduleInfo); if (!path.endsWith("module-info.class")) { if (result1.getLength() >= content.length) { @@ -116,7 +116,7 @@ public class StripDebugPluginTest { checkDebugAttributes(result1.getBytes()); } - ModuleData result2 = stripDebug(debug, result1, path, infoPath, moduleInfo); + ModuleEntry result2 = stripDebug(debug, result1, path, infoPath, moduleInfo); if (result1.getLength() != result2.getLength()) { throw new AssertionError("removing debug info twice reduces class size of " + path); @@ -124,18 +124,18 @@ public class StripDebugPluginTest { checkDebugAttributes(result1.getBytes()); } - private ModuleData stripDebug(TransformerPlugin debug, ModuleData classResource, + private ModuleEntry stripDebug(TransformerPlugin debug, ModuleEntry classResource, String path, String infoPath, byte[] moduleInfo) throws Exception { - Pool resources = new PoolImpl(); + ModulePool resources = new ModulePoolImpl(); resources.add(classResource); if (!path.endsWith("module-info.class")) { - ModuleData res2 = Pool.newResource(infoPath, moduleInfo); + ModuleEntry res2 = ModuleEntry.create(infoPath, moduleInfo); resources.add(res2); } - Pool results = new PoolImpl(); + ModulePool results = new ModulePoolImpl(); debug.visit(resources, results); System.out.println(classResource.getPath()); - return results.get(classResource.getPath()); + return results.findEntry(classResource.getPath()).get(); } private void checkDebugAttributes(byte[] strippedClassFile) throws IOException, ConstantPoolException { -- GitLab From baf59c0bd8876069bc565c39ec0564ade6fed6a8 Mon Sep 17 00:00:00 2001 From: Pavel Rappo Date: Mon, 16 May 2016 15:10:04 +0100 Subject: [PATCH 041/400] 8150785: (bf) Hoist slice and duplicate methods up to java.nio.Buffer Reviewed-by: alanb, rriggs, chegar --- .../share/classes/java/nio/Buffer.java | 48 ++++++++++++++++++- .../classes/java/nio/X-Buffer.java.template | 5 +- .../java/nio/Buffer/Order-X.java.template | 3 -- jdk/test/java/nio/Buffer/Order.java | 24 ++++++---- jdk/test/java/nio/Buffer/OrderChar.java | 3 -- jdk/test/java/nio/Buffer/OrderDouble.java | 3 -- jdk/test/java/nio/Buffer/OrderFloat.java | 3 -- jdk/test/java/nio/Buffer/OrderInt.java | 3 -- jdk/test/java/nio/Buffer/OrderLong.java | 3 -- jdk/test/java/nio/Buffer/OrderShort.java | 3 -- 10 files changed, 65 insertions(+), 33 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/nio/Buffer.java b/jdk/src/java.base/share/classes/java/nio/Buffer.java index d534fb3ae73..1f6bef17960 100644 --- a/jdk/src/java.base/share/classes/java/nio/Buffer.java +++ b/jdk/src/java.base/share/classes/java/nio/Buffer.java @@ -111,7 +111,7 @@ import java.util.Spliterator; * to zero. * * - *

      Clearing, flipping, and rewinding

      + *

      Additional operations

      * *

      In addition to methods for accessing the position, limit, and capacity * values and for marking and resetting, this class also defines the following @@ -131,6 +131,12 @@ import java.util.Spliterator; * it already contains: It leaves the limit unchanged and sets the position * to zero.

      * + *
    • {@link #slice} creates a subsequence of a buffer: It leaves the + * limit and the position unchanged.

    • + * + *
    • {@link #duplicate} creates a shallow copy of a buffer: It leaves + * the limit and the position unchanged.

    • + * * * * @@ -567,6 +573,46 @@ public abstract class Buffer { */ public abstract boolean isDirect(); + /** + * Creates a new buffer whose content is a shared subsequence of + * this buffer's content. + * + *

      The content of the new buffer will start at this buffer's current + * position. Changes to this buffer's content will be visible in the new + * buffer, and vice versa; the two buffers' position, limit, and mark + * values will be independent. + * + *

      The new buffer's position will be zero, its capacity and its limit + * will be the number of elements remaining in this buffer, its mark will be + * undefined. The new buffer will be direct if, and only if, this buffer is + * direct, and it will be read-only if, and only if, this buffer is + * read-only.

      + * + * @return The new buffer + * + * @since 9 + */ + public abstract Buffer slice(); + + /** + * Creates a new buffer that shares this buffer's content. + * + *

      The content of the new buffer will be that of this buffer. Changes + * to this buffer's content will be visible in the new buffer, and vice + * versa; the two buffers' position, limit, and mark values will be + * independent. + * + *

      The new buffer's capacity, limit, position and mark values will be + * identical to those of this buffer. The new buffer will be direct if, and + * only if, this buffer is direct, and it will be read-only if, and only if, + * this buffer is read-only.

      + * + * @return The new buffer + * + * @since 9 + */ + public abstract Buffer duplicate(); + // -- Package-private methods for bounds checking, etc. -- diff --git a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template index 104f504b551..1292ca458c6 100644 --- a/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template +++ b/jdk/src/java.base/share/classes/java/nio/X-Buffer.java.template @@ -70,8 +70,7 @@ import java.util.stream.$Streamtype$Stream; * #end[byte] * - *
    • Methods for {@link #compact compacting}, {@link - * #duplicate duplicating}, and {@link #slice slicing} + *

    • A method for {@link #compact compacting} * $a$ $type$ buffer.

    • * * @@ -535,6 +534,7 @@ public abstract class $Type$Buffer * @see #alignedSlice(int) #end[byte] */ + @Override public abstract $Type$Buffer slice(); /** @@ -557,6 +557,7 @@ public abstract class $Type$Buffer * * @return The new $type$ buffer */ + @Override public abstract $Type$Buffer duplicate(); /** diff --git a/jdk/test/java/nio/Buffer/Order-X.java.template b/jdk/test/java/nio/Buffer/Order-X.java.template index a8753a5f8a9..97313a841f6 100644 --- a/jdk/test/java/nio/Buffer/Order-X.java.template +++ b/jdk/test/java/nio/Buffer/Order-X.java.template @@ -52,8 +52,5 @@ public class Order$Type$ extends Order { buf = $Type$Buffer.allocate(LENGTH); ck(buf.order(), nord); ck$Type$Buffer(buf, nord); - - ck$Type$Buffer(ByteBuffer.allocate(LENGTH).as$Type$Buffer(), be); - ck$Type$Buffer(ByteBuffer.allocateDirect(LENGTH).as$Type$Buffer(), be); } } diff --git a/jdk/test/java/nio/Buffer/Order.java b/jdk/test/java/nio/Buffer/Order.java index 0232992525b..33ae418bb56 100644 --- a/jdk/test/java/nio/Buffer/Order.java +++ b/jdk/test/java/nio/Buffer/Order.java @@ -51,25 +51,31 @@ public class Order { ck(bb.asDoubleBuffer().order(), bb.order()); } + private static void ckCopyViews(ByteBuffer bb) { + ck(bb.asReadOnlyBuffer().order(), be); + ck(bb.duplicate().order(), be); + ck(bb.slice().order(), be); + } + private static void ckByteBuffer(ByteBuffer bb) { ckViews(bb); + ckCopyViews(bb); bb.order(be); ckViews(bb); + ckCopyViews(bb); bb.order(le); ckViews(bb); - - if (bb.hasArray()) { - byte[] array = bb.array(); - ck(ByteBuffer.wrap(array, LENGTH/2, LENGTH/2).order(), be); - ck(ByteBuffer.wrap(array).order(), be); - ck(bb.asReadOnlyBuffer().order(), be); - ck(bb.duplicate().order(), be); - ck(bb.slice().order(), be); - } + ckCopyViews(bb); } public static void main(String args[]) throws Exception { + ck(ByteBuffer.wrap(new byte[LENGTH], LENGTH/2, LENGTH/2).order(), be); + ck(ByteBuffer.wrap(new byte[LENGTH]).order(), be); + ck(ByteBuffer.wrap(new byte[LENGTH], LENGTH/2, LENGTH/2).order(be).order(), be); + ck(ByteBuffer.wrap(new byte[LENGTH]).order(be).order(), be); + ck(ByteBuffer.wrap(new byte[LENGTH], LENGTH/2, LENGTH/2).order(le).order(), le); + ck(ByteBuffer.wrap(new byte[LENGTH]).order(le).order(), le); ck(ByteBuffer.allocate(LENGTH).order(), be); ck(ByteBuffer.allocateDirect(LENGTH).order(), be); ck(ByteBuffer.allocate(LENGTH).order(be).order(), be); diff --git a/jdk/test/java/nio/Buffer/OrderChar.java b/jdk/test/java/nio/Buffer/OrderChar.java index ebf9faad79c..f72828bd0de 100644 --- a/jdk/test/java/nio/Buffer/OrderChar.java +++ b/jdk/test/java/nio/Buffer/OrderChar.java @@ -52,8 +52,5 @@ public class OrderChar extends Order { buf = CharBuffer.allocate(LENGTH); ck(buf.order(), nord); ckCharBuffer(buf, nord); - - ckCharBuffer(ByteBuffer.allocate(LENGTH).asCharBuffer(), be); - ckCharBuffer(ByteBuffer.allocateDirect(LENGTH).asCharBuffer(), be); } } diff --git a/jdk/test/java/nio/Buffer/OrderDouble.java b/jdk/test/java/nio/Buffer/OrderDouble.java index deaa6a3eb27..4100695cab5 100644 --- a/jdk/test/java/nio/Buffer/OrderDouble.java +++ b/jdk/test/java/nio/Buffer/OrderDouble.java @@ -52,8 +52,5 @@ public class OrderDouble extends Order { buf = DoubleBuffer.allocate(LENGTH); ck(buf.order(), nord); ckDoubleBuffer(buf, nord); - - ckDoubleBuffer(ByteBuffer.allocate(LENGTH).asDoubleBuffer(), be); - ckDoubleBuffer(ByteBuffer.allocateDirect(LENGTH).asDoubleBuffer(), be); } } diff --git a/jdk/test/java/nio/Buffer/OrderFloat.java b/jdk/test/java/nio/Buffer/OrderFloat.java index 6a65eaa8e4f..905d531d434 100644 --- a/jdk/test/java/nio/Buffer/OrderFloat.java +++ b/jdk/test/java/nio/Buffer/OrderFloat.java @@ -52,8 +52,5 @@ public class OrderFloat extends Order { buf = FloatBuffer.allocate(LENGTH); ck(buf.order(), nord); ckFloatBuffer(buf, nord); - - ckFloatBuffer(ByteBuffer.allocate(LENGTH).asFloatBuffer(), be); - ckFloatBuffer(ByteBuffer.allocateDirect(LENGTH).asFloatBuffer(), be); } } diff --git a/jdk/test/java/nio/Buffer/OrderInt.java b/jdk/test/java/nio/Buffer/OrderInt.java index 5d3843ffec7..700fc07110a 100644 --- a/jdk/test/java/nio/Buffer/OrderInt.java +++ b/jdk/test/java/nio/Buffer/OrderInt.java @@ -52,8 +52,5 @@ public class OrderInt extends Order { buf = IntBuffer.allocate(LENGTH); ck(buf.order(), nord); ckIntBuffer(buf, nord); - - ckIntBuffer(ByteBuffer.allocate(LENGTH).asIntBuffer(), be); - ckIntBuffer(ByteBuffer.allocateDirect(LENGTH).asIntBuffer(), be); } } diff --git a/jdk/test/java/nio/Buffer/OrderLong.java b/jdk/test/java/nio/Buffer/OrderLong.java index abda8b22932..9e507ffc18e 100644 --- a/jdk/test/java/nio/Buffer/OrderLong.java +++ b/jdk/test/java/nio/Buffer/OrderLong.java @@ -52,8 +52,5 @@ public class OrderLong extends Order { buf = LongBuffer.allocate(LENGTH); ck(buf.order(), nord); ckLongBuffer(buf, nord); - - ckLongBuffer(ByteBuffer.allocate(LENGTH).asLongBuffer(), be); - ckLongBuffer(ByteBuffer.allocateDirect(LENGTH).asLongBuffer(), be); } } diff --git a/jdk/test/java/nio/Buffer/OrderShort.java b/jdk/test/java/nio/Buffer/OrderShort.java index d19b43a1b60..f385b62d6dd 100644 --- a/jdk/test/java/nio/Buffer/OrderShort.java +++ b/jdk/test/java/nio/Buffer/OrderShort.java @@ -52,8 +52,5 @@ public class OrderShort extends Order { buf = ShortBuffer.allocate(LENGTH); ck(buf.order(), nord); ckShortBuffer(buf, nord); - - ckShortBuffer(ByteBuffer.allocate(LENGTH).asShortBuffer(), be); - ckShortBuffer(ByteBuffer.allocateDirect(LENGTH).asShortBuffer(), be); } } -- GitLab From fc86d03190d3bf585459ec9057978272e6ab5900 Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Mon, 16 May 2016 16:04:14 +0100 Subject: [PATCH 042/400] 8156825: java/net/httpclient/BasicWebSocketAPITest.java failed with java.lang.AssertionError Reviewed-by: rriggs --- .../classes/java/net/http/HttpClientImpl.java | 17 +++++++++++ .../classes/java/net/http/HttpHeaders1.java | 29 ------------------- .../java/net/http/HttpResponseImpl.java | 2 +- .../classes/java/net/http/RawChannel.java | 15 +++++++++- .../java/net/http/WSOpeningHandshake.java | 11 ++++++- 5 files changed, 42 insertions(+), 32 deletions(-) delete mode 100644 jdk/src/java.httpclient/share/classes/java/net/http/HttpHeaders1.java diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/HttpClientImpl.java b/jdk/src/java.httpclient/share/classes/java/net/http/HttpClientImpl.java index 446987d6b5d..226cee95c55 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/HttpClientImpl.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/HttpClientImpl.java @@ -35,6 +35,7 @@ import java.nio.channels.ClosedChannelException; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.Iterator; @@ -155,6 +156,15 @@ class HttpClientImpl extends HttpClient implements BufferHandler { selmgr.register(exchange); } + /** + * Only used from RawChannel to disconnect the channel from + * the selector + */ + void cancelRegistration(SocketChannel s) { + selmgr.cancel(s); + } + + Http2ClientImpl client2() { return client2; } @@ -220,6 +230,13 @@ class HttpClientImpl extends HttpClient implements BufferHandler { selector.wakeup(); } + synchronized void cancel(SocketChannel e) { + SelectionKey key = e.keyFor(selector); + if (key != null) + key.cancel(); + selector.wakeup(); + } + void wakeupSelector() { selector.wakeup(); } diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/HttpHeaders1.java b/jdk/src/java.httpclient/share/classes/java/net/http/HttpHeaders1.java deleted file mode 100644 index c9ff689a931..00000000000 --- a/jdk/src/java.httpclient/share/classes/java/net/http/HttpHeaders1.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - */ - -package java.net.http; - -public interface HttpHeaders1 extends HttpHeaders { - public void makeUnmodifiable(); -} diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/HttpResponseImpl.java b/jdk/src/java.httpclient/share/classes/java/net/http/HttpResponseImpl.java index 10758d6db99..dcbfbdb8f1a 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/HttpResponseImpl.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/HttpResponseImpl.java @@ -176,7 +176,7 @@ class HttpResponseImpl extends HttpResponse { * * @return */ - RawChannel rawChannel() { + RawChannel rawChannel() throws IOException { if (rawchan == null) { rawchan = new RawChannel(request.client(), connection); } diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java b/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java index e4dc3b00b8d..5f6fb4df6c0 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/RawChannel.java @@ -29,6 +29,7 @@ import java.nio.channels.ByteChannel; import java.nio.channels.GatheringByteChannel; import java.nio.channels.SelectableChannel; import java.nio.channels.SelectionKey; +import java.nio.channels.SocketChannel; // // Used to implement WebSocket. Each RawChannel corresponds to a TCP connection @@ -56,9 +57,21 @@ final class RawChannel implements ByteChannel, GatheringByteChannel { interface NonBlockingEvent extends RawEvent { } - RawChannel(HttpClientImpl client, HttpConnection connection) { + RawChannel(HttpClientImpl client, HttpConnection connection) + throws IOException { this.client = client; this.connection = connection; + SocketChannel chan = connection.channel(); + client.cancelRegistration(chan); + chan.configureBlocking(false); + } + + SocketChannel socketChannel() { + return connection.channel(); + } + + ByteBuffer getRemaining() { + return connection.getRemaining(); } private class RawAsyncEvent extends AsyncEvent { diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java b/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java index 6a7ddaa882c..d3cc7da3520 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/WSOpeningHandshake.java @@ -24,6 +24,8 @@ */ package java.net.http; +import java.io.UncheckedIOException; +import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; @@ -126,6 +128,8 @@ final class WSOpeningHandshake { return CompletableFuture.completedFuture(result); } catch (WebSocketHandshakeException e) { return CompletableFuture.failedFuture(e); + } catch (UncheckedIOException ee) { + return CompletableFuture.failedFuture(ee.getCause()); } }); } @@ -149,7 +153,12 @@ final class WSOpeningHandshake { checkAccept(response, h); checkExtensions(response, h); String subprotocol = checkAndReturnSubprotocol(response, h); - RawChannel channel = ((HttpResponseImpl) response).rawChannel(); + RawChannel channel = null; + try { + channel = ((HttpResponseImpl) response).rawChannel(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } return new Result(subprotocol, channel); } -- GitLab From 5cd35e69e24863a9b52c78c787f7df6a0485170c Mon Sep 17 00:00:00 2001 From: Rajan Halade Date: Mon, 16 May 2016 10:36:51 -0700 Subject: [PATCH 043/400] 8155049: New tests from 8144566 fail with "No expected Server Name Indication" Reviewed-by: xuelei --- .../javax/net/ssl/ServerName/BestEffortOnLazyConnected.java | 4 +--- .../www/protocol/https/HttpsURLConnection/ImpactOnSNI.java | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java b/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java index ba3e5f10e50..bda0710f61e 100644 --- a/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java +++ b/jdk/test/javax/net/ssl/ServerName/BestEffortOnLazyConnected.java @@ -34,9 +34,6 @@ */ import java.io.*; -import java.nio.*; -import java.nio.channels.*; -import java.util.*; import java.net.*; import javax.net.ssl.*; @@ -197,6 +194,7 @@ public class BestEffortOnLazyConnected { hostname); // Ignore the test if the hostname does not sound like a domain name. if ((hostname == null) || hostname.isEmpty() || + !hostname.contains(".") || hostname.endsWith(".") || hostname.startsWith("localhost") || Character.isDigit(hostname.charAt(hostname.length() - 1))) { diff --git a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java index 4e0f0bdac59..d90d9478e2a 100644 --- a/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java +++ b/jdk/test/sun/net/www/protocol/https/HttpsURLConnection/ImpactOnSNI.java @@ -235,6 +235,7 @@ public class ImpactOnSNI { hostname); // Ignore the test if the hostname does not sound like a domain name. if ((hostname == null) || hostname.isEmpty() || + !hostname.contains(".") || hostname.endsWith(".") || hostname.startsWith("localhost") || Character.isDigit(hostname.charAt(hostname.length() - 1))) { -- GitLab From 5c27ac09c7127a449ad8d9535a0fe420d94829f2 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Mon, 16 May 2016 13:53:46 -0400 Subject: [PATCH 044/400] 8150468: ClassCircularityError on error in security policy file Reviewed-by: mchung, xuelei --- .../sun/security/provider/PolicyFile.java | 36 ++++++++++--- .../sun/security/provider/PolicyParser.java | 38 +++++++++----- .../provider/PolicyFile/BadPolicyFile.java | 51 +++++++++++++++++++ .../provider/PolicyFile/BadPolicyFile.policy | 4 ++ 4 files changed, 110 insertions(+), 19 deletions(-) create mode 100644 jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.java create mode 100644 jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.policy diff --git a/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java b/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java index 5861b6c7a85..861fa692471 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/PolicyFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -259,14 +259,10 @@ public class PolicyFile extends java.security.Policy { private static final Debug debug = Debug.getInstance("policy"); - private static final String NONE = "NONE"; - private static final String P11KEYSTORE = "PKCS11"; - private static final String SELF = "${{self}}"; private static final String X500PRINCIPAL = "javax.security.auth.x500.X500Principal"; private static final String POLICY = "java.security.policy"; - private static final String SECURITY_MANAGER = "java.security.manager"; private static final String POLICY_URL = "policy.url."; private static final String AUTH_POLICY = "java.security.auth.policy"; private static final String AUTH_POLICY_URL = "auth.policy.url."; @@ -287,6 +283,17 @@ public class PolicyFile extends java.security.Policy { private static final Class[] PARAMS1 = { String.class }; private static final Class[] PARAMS2 = { String.class, String.class }; + /** + * When a policy file has a syntax error, the exception code may generate + * another permission check and this can cause the policy file to be parsed + * repeatedly, leading to a StackOverflowError or ClassCircularityError. + * To avoid this, this set is populated with policy files that have been + * previously parsed and have syntax errors, so that they can be + * subsequently ignored. + */ + private static AtomicReference> badPolicyURLs = + new AtomicReference<>(new HashSet<>()); + /** * Initializes the Policy object and reads the default policy * configuration file(s) into the Policy object. @@ -580,6 +587,16 @@ public class PolicyFile extends java.security.Policy { * @param policyFile the policy Reader object. */ private boolean init(URL policy, PolicyInfo newInfo) { + + // skip parsing policy file if it has been previously parsed and + // has syntax errors + if (badPolicyURLs.get().contains(policy)) { + if (debug != null) { + debug.println("skipping bad policy file: " + policy); + } + return false; + } + boolean success = false; PolicyParser pp = new PolicyParser(expandProperties); InputStreamReader isr = null; @@ -622,13 +639,18 @@ public class PolicyFile extends java.security.Policy { addGrantEntry(ge, keyStore, newInfo); } } catch (PolicyParser.ParsingException pe) { + // record bad policy file to avoid later reparsing it + badPolicyURLs.updateAndGet(k -> { + k.add(policy); + return k; + }); MessageFormat form = new MessageFormat(ResourcesMgr.getString (POLICY + ".error.parsing.policy.message")); Object[] source = {policy, pe.getLocalizedMessage()}; System.err.println(form.format(source)); - if (debug != null) + if (debug != null) { pe.printStackTrace(); - + } } catch (Exception e) { if (debug != null) { debug.println("error parsing "+policy); diff --git a/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java b/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java index ba8ed750254..f8aa620fc77 100644 --- a/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java +++ b/jdk/src/java.base/share/classes/sun/security/provider/PolicyParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -213,7 +213,9 @@ public class PolicyParser { new MessageFormat(ResourcesMgr.getString( "duplicate.keystore.domain.name")); Object[] source = {domainName}; - throw new ParsingException(form.format(source)); + String msg = "duplicate keystore domain name: " + + domainName; + throw new ParsingException(msg, form, source); } } } else { @@ -743,7 +745,8 @@ public class PolicyParser { ResourcesMgr.getString ("expected.expect.read.end.of.file.")); Object[] source = {expect}; - throw new ParsingException(form.format(source)); + String msg = "expected [" + expect + "], read [end of file]"; + throw new ParsingException(msg, form, source); case StreamTokenizer.TT_WORD: if (expect.equalsIgnoreCase(st.sval)) { lookahead = st.nextToken(); @@ -1244,7 +1247,8 @@ public class PolicyParser { MessageFormat form = new MessageFormat(ResourcesMgr.getString( "duplicate.keystore.name")); Object[] source = {keystoreName}; - throw new ParsingException(form.format(source)); + String msg = "duplicate keystore name: " + keystoreName; + throw new ParsingException(msg, form, source); } } @@ -1316,6 +1320,8 @@ public class PolicyParser { private static final long serialVersionUID = -4330692689482574072L; private String i18nMessage; + private MessageFormat form; + private Object[] source; /** * Constructs a ParsingException with the specified @@ -1330,26 +1336,34 @@ public class PolicyParser { i18nMessage = msg; } + public ParsingException(String msg, MessageFormat form, + Object[] source) { + super(msg); + this.form = form; + this.source = source; + } + public ParsingException(int line, String msg) { super("line " + line + ": " + msg); - MessageFormat form = new MessageFormat - (ResourcesMgr.getString("line.number.msg")); - Object[] source = {line, msg}; - i18nMessage = form.format(source); + // don't call form.format unless getLocalizedMessage is called + // to avoid unnecessary permission checks + form = new MessageFormat(ResourcesMgr.getString("line.number.msg")); + source = new Object[] {line, msg}; } public ParsingException(int line, String expect, String actual) { super("line " + line + ": expected [" + expect + "], found [" + actual + "]"); - MessageFormat form = new MessageFormat(ResourcesMgr.getString + // don't call form.format unless getLocalizedMessage is called + // to avoid unnecessary permission checks + form = new MessageFormat(ResourcesMgr.getString ("line.number.expected.expect.found.actual.")); - Object[] source = {line, expect, actual}; - i18nMessage = form.format(source); + source = new Object[] {line, expect, actual}; } @Override public String getLocalizedMessage() { - return i18nMessage; + return i18nMessage != null ? i18nMessage : form.format(source); } } diff --git a/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.java b/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.java new file mode 100644 index 00000000000..17a4c5d8d71 --- /dev/null +++ b/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8150468 + * @summary check that a badly formatted policy file is handled correctly + * @run main/othervm BadPolicyFile + */ + +import java.io.File; +import java.net.URI; +import java.security.AccessControlException; +import java.security.Policy; +import java.security.URIParameter; + +public class BadPolicyFile { + + public static void main(String[] args) throws Exception { + URI uri = new File(System.getProperty("test.src", "."), + "BadPolicyFile.policy").toURI(); + Policy.setPolicy(Policy.getInstance("JavaPolicy", new URIParameter(uri))); + System.setSecurityManager(new SecurityManager()); + try { + String javahome = System.getProperty("java.home"); + throw new Exception("Expected AccessControlException"); + } catch (AccessControlException ace) { + System.out.println("Test PASSED"); + } + } +} diff --git a/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.policy b/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.policy new file mode 100644 index 00000000000..b5abfaf8f42 --- /dev/null +++ b/jdk/test/sun/security/provider/PolicyFile/BadPolicyFile.policy @@ -0,0 +1,4 @@ +grant { + // permission statement is missing trailing semi-colon + permission "java.util.PropertyPermission" "java.home", "read" +}; -- GitLab From 6e8eab119e9bad68a1310a47bae29f2f79c33254 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 16 May 2016 22:07:07 +0100 Subject: [PATCH 045/400] 8156989: Trailing empty element in classpath ignored Reviewed-by: mchung --- .../jdk/internal/loader/ClassLoaders.java | 47 +++++++++++-------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java index 7a946099fdf..bc2396f10c3 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java +++ b/jdk/src/java.base/share/classes/jdk/internal/loader/ClassLoaders.java @@ -68,13 +68,14 @@ public class ClassLoaders { if (s != null && s.length() > 0) bcp = toURLClassPath(s); - // we have a class path if -cp is specified or -m is not specified + // we have a class path if -cp is specified or -m is not specified. + // If neither is specified then default to -cp . URLClassPath ucp = null; String mainMid = System.getProperty("jdk.module.main"); String cp = System.getProperty("java.class.path"); - if (mainMid == null && (cp == null || cp.length() == 0)) - cp = "."; - if (cp != null && cp.length() > 0) + if (mainMid == null && cp == null) + cp = ""; + if (cp != null) ucp = toURLClassPath(cp); @@ -197,7 +198,7 @@ public class ClassLoaders { * @see java.lang.instrument.Instrumentation#appendToSystemClassLoaderSearch */ void appendToClassPathForInstrumentation(String path) { - appendToUCP(path, ucp); + addClassPathToUCP(path, ucp); } /** @@ -224,7 +225,7 @@ public class ClassLoaders { */ private static URLClassPath toURLClassPath(String cp) { URLClassPath ucp = new URLClassPath(new URL[0]); - appendToUCP(cp, ucp); + addClassPathToUCP(cp, ucp); return ucp; } @@ -232,20 +233,28 @@ public class ClassLoaders { * Converts the elements in the given class path to file URLs and adds * them to the given URLClassPath. */ - private static void appendToUCP(String cp, URLClassPath ucp) { - String[] elements = cp.split(File.pathSeparator); - if (elements.length == 0) { - // contains path separator(s) only, default to current directory - // to be compatible with long standing behavior - elements = new String[] { "" }; + private static void addClassPathToUCP(String cp, URLClassPath ucp) { + int off = 0; + int next; + while ((next = cp.indexOf(File.pathSeparator, off)) != -1) { + addURLToUCP(cp.substring(off, next), ucp); + off = next + 1; } - for (String s: elements) { - try { - URL url = Paths.get(s).toRealPath().toUri().toURL(); - ucp.addURL(url); - } catch (InvalidPathException | IOException ignore) { - // malformed path string or class path element does not exist - } + + // remaining + addURLToUCP(cp.substring(off), ucp); + } + + /** + * Attempts to convert to the given string to a file URL and adds it + * to the given URLClassPath. + */ + private static void addURLToUCP(String s, URLClassPath ucp) { + try { + URL url = Paths.get(s).toRealPath().toUri().toURL(); + ucp.addURL(url); + } catch (InvalidPathException | IOException ignore) { + // malformed path string or class path element does not exist } } -- GitLab From c594c87387f8a7151f4beaee8f623b6cad004191 Mon Sep 17 00:00:00 2001 From: Felix Yang Date: Tue, 17 May 2016 02:34:56 -0700 Subject: [PATCH 046/400] 8155088: Fix module dependencies in java/sql/* and javax/* tests Reviewed-by: alanb --- jdk/test/java/sql/TEST.properties | 2 ++ jdk/test/javax/net/ssl/HttpsURLConnection/Equals.java | 3 ++- jdk/test/javax/rmi/TEST.properties | 1 + jdk/test/javax/script/TEST.properties | 1 + jdk/test/javax/xml/jaxp/TEST.properties | 1 + 5 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/sql/TEST.properties create mode 100644 jdk/test/javax/rmi/TEST.properties create mode 100644 jdk/test/javax/script/TEST.properties create mode 100644 jdk/test/javax/xml/jaxp/TEST.properties diff --git a/jdk/test/java/sql/TEST.properties b/jdk/test/java/sql/TEST.properties new file mode 100644 index 00000000000..878b05fc591 --- /dev/null +++ b/jdk/test/java/sql/TEST.properties @@ -0,0 +1,2 @@ +modules = java.sql + diff --git a/jdk/test/javax/net/ssl/HttpsURLConnection/Equals.java b/jdk/test/javax/net/ssl/HttpsURLConnection/Equals.java index 0a482f31b90..0e40e52ce9b 100644 --- a/jdk/test/javax/net/ssl/HttpsURLConnection/Equals.java +++ b/jdk/test/javax/net/ssl/HttpsURLConnection/Equals.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /** * @test * @library /lib/testlibrary + * @modules jdk.httpserver * @build jdk.testlibrary.SimpleSSLContext * @run main Equals * @bug 8055299 diff --git a/jdk/test/javax/rmi/TEST.properties b/jdk/test/javax/rmi/TEST.properties new file mode 100644 index 00000000000..d4bbfc905b9 --- /dev/null +++ b/jdk/test/javax/rmi/TEST.properties @@ -0,0 +1 @@ +modules = java.rmi diff --git a/jdk/test/javax/script/TEST.properties b/jdk/test/javax/script/TEST.properties new file mode 100644 index 00000000000..3bb100c3fad --- /dev/null +++ b/jdk/test/javax/script/TEST.properties @@ -0,0 +1 @@ +modules = java.scripting diff --git a/jdk/test/javax/xml/jaxp/TEST.properties b/jdk/test/javax/xml/jaxp/TEST.properties new file mode 100644 index 00000000000..fbf9f77ec10 --- /dev/null +++ b/jdk/test/javax/xml/jaxp/TEST.properties @@ -0,0 +1 @@ +modules = java.xml -- GitLab From 44afe20e99f0b43123fe465a02052b12024c07c5 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Tue, 17 May 2016 12:06:41 +0200 Subject: [PATCH 047/400] 8156485: MethodHandles.varHandleExactInvoker should perform exact checks Reviewed-by: vlivanov --- .../classes/java/lang/invoke/Invokers.java | 110 +----- .../classes/java/lang/invoke/VarHandle.java | 4 +- .../invoke/VarHandles/VarHandleBaseTest.java | 63 ++- .../VarHandleTestAccessBoolean.java | 21 + .../VarHandles/VarHandleTestAccessByte.java | 21 + .../VarHandles/VarHandleTestAccessChar.java | 21 + .../VarHandles/VarHandleTestAccessDouble.java | 21 + .../VarHandles/VarHandleTestAccessFloat.java | 21 + .../VarHandles/VarHandleTestAccessInt.java | 1 + .../VarHandles/VarHandleTestAccessLong.java | 1 + .../VarHandles/VarHandleTestAccessShort.java | 21 + .../VarHandles/VarHandleTestAccessString.java | 1 + .../VarHandleTestByteArrayAsChar.java | 5 + .../VarHandleTestByteArrayAsDouble.java | 5 +- .../VarHandleTestByteArrayAsFloat.java | 5 +- .../VarHandleTestByteArrayAsInt.java | 5 +- .../VarHandleTestByteArrayAsLong.java | 5 +- .../VarHandleTestByteArrayAsShort.java | 5 + ...arHandleTestMethodHandleAccessBoolean.java | 1 + .../VarHandleTestMethodHandleAccessByte.java | 1 + .../VarHandleTestMethodHandleAccessChar.java | 1 + ...VarHandleTestMethodHandleAccessDouble.java | 1 + .../VarHandleTestMethodHandleAccessFloat.java | 1 + .../VarHandleTestMethodHandleAccessInt.java | 1 + .../VarHandleTestMethodHandleAccessLong.java | 1 + .../VarHandleTestMethodHandleAccessShort.java | 1 + ...VarHandleTestMethodHandleAccessString.java | 1 + .../VarHandleTestMethodTypeBoolean.java | 100 ++--- .../VarHandleTestMethodTypeByte.java | 100 ++--- .../VarHandleTestMethodTypeChar.java | 100 ++--- .../VarHandleTestMethodTypeDouble.java | 100 ++--- .../VarHandleTestMethodTypeFloat.java | 100 ++--- .../VarHandleTestMethodTypeInt.java | 308 +++++++-------- .../VarHandleTestMethodTypeLong.java | 308 +++++++-------- .../VarHandleTestMethodTypeShort.java | 100 ++--- .../VarHandleTestMethodTypeString.java | 310 +++++++-------- .../X-VarHandleTestAccess.java.template | 21 + ...X-VarHandleTestByteArrayView.java.template | 5 +- ...HandleTestMethodHandleAccess.java.template | 1 + .../X-VarHandleTestMethodType.java.template | 370 +++++++++--------- 40 files changed, 1189 insertions(+), 1079 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java index 29cc430f877..1aca86298fe 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java @@ -95,12 +95,12 @@ class Invokers { /*non-public*/ MethodHandle varHandleMethodInvoker(VarHandle.AccessMode ak) { // TODO cache invoker - return makeVarHandleMethodInvoker(ak); + return makeVarHandleMethodInvoker(ak, false); } /*non-public*/ MethodHandle varHandleMethodExactInvoker(VarHandle.AccessMode ak) { // TODO cache invoker - return makeVarHandleMethodExactInvoker(ak); + return makeVarHandleMethodInvoker(ak, true); } private MethodHandle cachedInvoker(int idx) { @@ -127,26 +127,11 @@ class Invokers { return invoker; } - private MethodHandle makeVarHandleMethodInvoker(VarHandle.AccessMode ak) { + private MethodHandle makeVarHandleMethodInvoker(VarHandle.AccessMode ak, boolean isExact) { MethodType mtype = targetType; MethodType invokerType = mtype.insertParameterTypes(0, VarHandle.class); - LambdaForm lform = varHandleMethodGenericInvokerHandleForm(ak.methodName(), mtype); - VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal()); - MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, ad); - - invoker = invoker.withInternalMemberName(MemberName.makeVarHandleMethodInvoke(ak.methodName(), mtype), false); - assert(checkVarHandleInvoker(invoker)); - - maybeCompileToBytecode(invoker); - return invoker; - } - - private MethodHandle makeVarHandleMethodExactInvoker(VarHandle.AccessMode ak) { - MethodType mtype = targetType; - MethodType invokerType = mtype.insertParameterTypes(0, VarHandle.class); - - LambdaForm lform = varHandleMethodExactInvokerHandleForm(ak.methodName(), mtype); + LambdaForm lform = varHandleMethodInvokerHandleForm(ak.methodName(), mtype, isExact); VarHandle.AccessDescriptor ad = new VarHandle.AccessDescriptor(mtype, ak.at.ordinal(), ak.ordinal()); MethodHandle invoker = BoundMethodHandle.bindSingle(invokerType, lform, ad); @@ -400,7 +385,7 @@ class Invokers { return lform; } - private static LambdaForm varHandleMethodExactInvokerHandleForm(String name, MethodType mtype) { + private static LambdaForm varHandleMethodInvokerHandleForm(String name, MethodType mtype, boolean isExact) { // TODO Cache form? final int THIS_MH = 0; @@ -410,20 +395,8 @@ class Invokers { int nameCursor = ARG_LIMIT; final int VAD_ARG = nameCursor++; final int CHECK_TYPE = nameCursor++; - final int GET_MEMBER = nameCursor++; final int LINKER_CALL = nameCursor++; - MethodType invokerFormType = mtype.insertParameterTypes(0, VarHandle.class) - .basicType() - .appendParameterTypes(MemberName.class); - - MemberName linker = new MemberName(MethodHandle.class, "linkToStatic", invokerFormType, REF_invokeStatic); - try { - linker = MemberName.getFactory().resolveOrFail(REF_invokeStatic, linker, null, NoSuchMethodException.class); - } catch (ReflectiveOperationException ex) { - throw newInternalError(ex); - } - Name[] names = new Name[LINKER_CALL + 1]; names[THIS_MH] = argument(THIS_MH, BasicType.basicType(Object.class)); names[CALL_VH] = argument(CALL_VH, BasicType.basicType(Object.class)); @@ -437,48 +410,11 @@ class Invokers { NamedFunction getter = speciesData.getterFunction(0); names[VAD_ARG] = new Name(getter, names[THIS_MH]); - Object[] outArgs = Arrays.copyOfRange(names, CALL_VH, ARG_LIMIT + 1, Object[].class); - - names[CHECK_TYPE] = new Name(NF_checkVarHandleExactType, names[CALL_VH], names[VAD_ARG]); - - names[GET_MEMBER] = new Name(NF_getVarHandleMemberName, names[CALL_VH], names[VAD_ARG]); - outArgs[outArgs.length - 1] = names[GET_MEMBER]; - - names[LINKER_CALL] = new Name(linker, outArgs); - LambdaForm lform = new LambdaForm(name + ":VarHandle_exactInvoker" + shortenSignature(basicTypeSignature(mtype)), - ARG_LIMIT, names); - - lform.compileToBytecode(); - return lform; - } - - private static LambdaForm varHandleMethodGenericInvokerHandleForm(String name, MethodType mtype) { - // TODO Cache form? - - final int THIS_MH = 0; - final int CALL_VH = THIS_MH + 1; - final int ARG_BASE = CALL_VH + 1; - final int ARG_LIMIT = ARG_BASE + mtype.parameterCount(); - int nameCursor = ARG_LIMIT; - final int VAD_ARG = nameCursor++; - final int CHECK_TYPE = nameCursor++; - final int LINKER_CALL = nameCursor++; - - Name[] names = new Name[LINKER_CALL + 1]; - names[THIS_MH] = argument(THIS_MH, BasicType.basicType(Object.class)); - names[CALL_VH] = argument(CALL_VH, BasicType.basicType(Object.class)); - for (int i = 0; i < mtype.parameterCount(); i++) { - names[ARG_BASE + i] = argument(ARG_BASE + i, BasicType.basicType(mtype.parameterType(i))); + if (isExact) { + names[CHECK_TYPE] = new Name(NF_checkVarHandleExactType, names[CALL_VH], names[VAD_ARG]); + } else { + names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[CALL_VH], names[VAD_ARG]); } - - BoundMethodHandle.SpeciesData speciesData = BoundMethodHandle.speciesData_L(); - names[THIS_MH] = names[THIS_MH].withConstraint(speciesData); - - NamedFunction getter = speciesData.getterFunction(0); - names[VAD_ARG] = new Name(getter, names[THIS_MH]); - - names[CHECK_TYPE] = new Name(NF_checkVarHandleGenericType, names[CALL_VH], names[VAD_ARG]); - Object[] outArgs = new Object[ARG_LIMIT]; outArgs[0] = names[CHECK_TYPE]; for (int i = 1; i < ARG_LIMIT; i++) { @@ -488,7 +424,8 @@ class Invokers { MethodType outCallType = mtype.insertParameterTypes(0, VarHandle.class) .basicType(); names[LINKER_CALL] = new Name(outCallType, outArgs); - LambdaForm lform = new LambdaForm(name + ":VarHandle_invoker" + shortenSignature(basicTypeSignature(mtype)), + String debugName = isExact ? ":VarHandle_exactInvoker" : ":VarHandle_invoker"; + LambdaForm lform = new LambdaForm(name + debugName + shortenSignature(basicTypeSignature(mtype)), ARG_LIMIT, names); lform.prepare(); @@ -511,21 +448,13 @@ class Invokers { /*non-public*/ static @ForceInline - void checkVarHandleExactType(VarHandle handle, VarHandle.AccessDescriptor ad) { - MethodType erasedTarget = handle.vform.methodType_table[ad.type]; - MethodType erasedSymbolic = ad.symbolicMethodTypeErased; - if (erasedTarget != erasedSymbolic) - throw newWrongMethodTypeException(erasedTarget, erasedSymbolic); - } - - /*non-public*/ static - @ForceInline - MemberName getVarHandleMemberName(VarHandle handle, VarHandle.AccessDescriptor ad) { - MemberName mn = handle.vform.memberName_table[ad.mode]; - if (mn == null) { - throw handle.unsupported(); + MethodHandle checkVarHandleExactType(VarHandle handle, VarHandle.AccessDescriptor ad) { + MethodHandle mh = handle.getMethodHandle(ad.mode); + MethodType mt = mh.type(); + if (mt != ad.symbolicMethodTypeInvoker) { + throw newWrongMethodTypeException(mt, ad.symbolicMethodTypeInvoker); } - return mn; + return mh; } /*non-public*/ static @@ -649,8 +578,7 @@ class Invokers { NF_getCallSiteTarget, NF_checkCustomized, NF_checkVarHandleGenericType, - NF_checkVarHandleExactType, - NF_getVarHandleMemberName; + NF_checkVarHandleExactType; static { try { NamedFunction nfs[] = { @@ -666,8 +594,6 @@ class Invokers { .getDeclaredMethod("checkVarHandleGenericType", VarHandle.class, VarHandle.AccessDescriptor.class)), NF_checkVarHandleExactType = new NamedFunction(Invokers.class .getDeclaredMethod("checkVarHandleExactType", VarHandle.class, VarHandle.AccessDescriptor.class)), - NF_getVarHandleMemberName = new NamedFunction(Invokers.class - .getDeclaredMethod("getVarHandleMemberName", VarHandle.class, VarHandle.AccessDescriptor.class)) }; // Each nf must be statically invocable or we get tied up in our bootstraps. assert(InvokerBytecodeGenerator.isStaticallyInvocable(nfs)); diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java index 78a75bf05cc..ccbaf4b3b69 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/VarHandle.java @@ -1475,11 +1475,11 @@ public abstract class VarHandle { TypesAndInvokers tis = getTypesAndInvokers(); MethodHandle mh = tis.methodHandle_table[mode]; if (mh == null) { - mh = tis.methodHandle_table[mode] = getMethodHandleUncached(tis, mode); + mh = tis.methodHandle_table[mode] = getMethodHandleUncached(mode); } return mh; } - private final MethodHandle getMethodHandleUncached(TypesAndInvokers tis, int mode) { + private final MethodHandle getMethodHandleUncached(int mode) { MethodType mt = accessModeType(AccessMode.values()[mode]). insertParameterTypes(0, VarHandle.class); MemberName mn = vform.getMemberName(mode); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java index 59737dbeb7b..a40675b4073 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleBaseTest.java @@ -211,7 +211,6 @@ abstract class VarHandleBaseTest { } static MethodHandle findVirtual(VarHandle vh, TestAccessMode tam, MethodType mt) { - mt = vh.accessModeType(tam.toAccessMode()); MethodHandle mh; try { mh = MethodHandles.publicLookup(). @@ -221,36 +220,26 @@ abstract class VarHandleBaseTest { } catch (Exception e) { throw new RuntimeException(e); } - return bind(vh, tam, mh, mt); + return bind(vh, mh, mt); } - static MethodHandle varHandleInvokerWithAccessModeType(VarHandle vh, TestAccessMode tam, MethodType mt) { - mt = vh.accessModeType(tam.toAccessMode()); + static MethodHandle varHandleInvoker(VarHandle vh, TestAccessMode tam, MethodType mt) { MethodHandle mh = MethodHandles.varHandleInvoker( tam.toAccessMode(), mt); - return bind(vh, tam, mh, mt); + return bind(vh, mh, mt); } - static MethodHandle varHandleInvokerWithSymbolicTypeDescriptor(VarHandle vh, TestAccessMode tam, MethodType mt) { - MethodHandle mh = MethodHandles.varHandleInvoker( - tam.toAccessMode(), - mt); - - return bind(vh, tam, mh, mt); - } - - static MethodHandle varHandleExactInvokerWithAccessModeType(VarHandle vh, TestAccessMode tam, MethodType mt) { - mt = vh.accessModeType(tam.toAccessMode()); + static MethodHandle varHandleExactInvoker(VarHandle vh, TestAccessMode tam, MethodType mt) { MethodHandle mh = MethodHandles.varHandleExactInvoker( tam.toAccessMode(), mt); - return bind(vh, tam, mh, mt); + return bind(vh, mh, mt); } - private static MethodHandle bind(VarHandle vh, TestAccessMode testAccessMode, MethodHandle mh, MethodType emt) { + private static MethodHandle bind(VarHandle vh, MethodHandle mh, MethodType emt) { assertEquals(mh.type(), emt.insertParameterTypes(0, VarHandle.class), "MethodHandle type differs from access mode type"); @@ -268,33 +257,30 @@ abstract class VarHandleBaseTest { enum VarHandleToMethodHandle { VAR_HANDLE_TO_METHOD_HANDLE( "VarHandle.toMethodHandle", + true, VarHandleBaseTest::toMethodHandle), METHOD_HANDLES_LOOKUP_FIND_VIRTUAL( "Lookup.findVirtual", + false, VarHandleBaseTest::findVirtual), - METHOD_HANDLES_VAR_HANDLE_INVOKER_WITH_ACCESS_MODE_TYPE( - "MethodHandles.varHandleInvoker(accessModeType)", - VarHandleBaseTest::varHandleInvokerWithAccessModeType), - METHOD_HANDLES_VAR_HANDLE_INVOKER_WITH_SYMBOLIC_TYPE_DESCRIPTOR( - "MethodHandles.varHandleInvoker(symbolicTypeDescriptor)", - VarHandleBaseTest::varHandleInvokerWithSymbolicTypeDescriptor), - METHOD_HANDLES_VAR_HANDLE_EXACT_INVOKER_WITH_ACCESS_MODE_TYPE( - "MethodHandles.varHandleExactInvoker(accessModeType)", - VarHandleBaseTest::varHandleExactInvokerWithAccessModeType); + METHOD_HANDLES_VAR_HANDLE_INVOKER( + "MethodHandles.varHandleInvoker", + false, + VarHandleBaseTest::varHandleInvoker), + METHOD_HANDLES_VAR_HANDLE_EXACT_INVOKER( + "MethodHandles.varHandleExactInvoker", + true, + VarHandleBaseTest::varHandleExactInvoker); final String desc; + final boolean isExact; final TriFunction f; - final boolean exact; - VarHandleToMethodHandle(String desc, TriFunction f) { - this(desc, f, false); - } - - VarHandleToMethodHandle(String desc, TriFunction f, - boolean exact) { + VarHandleToMethodHandle(String desc, boolean isExact, + TriFunction f) { this.desc = desc; this.f = f; - this.exact = exact; + this.isExact = isExact; } MethodHandle apply(VarHandle vh, TestAccessMode am, MethodType mt) { @@ -363,6 +349,15 @@ abstract class VarHandleBaseTest { return amToHandle.computeIfAbsent( amt, k -> f.apply(vh, am, mt)); } + + Class getWMTEOOrOther(Class c) { + return f.isExact ? WrongMethodTypeException.class : c; + } + + void checkWMTEOrCCE(ThrowingRunnable r) { + checkWithThrowable(getWMTEOOrOther(ClassCastException.class), null, r); + } + } interface AccessTestAction { diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java index 021091484e6..06d2a65b1dd 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessBoolean * @run testng/othervm -Diters=20000 VarHandleTestAccessBoolean * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessBoolean + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessBoolean */ import org.testng.annotations.BeforeClass; @@ -292,6 +293,10 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(recv, true, false); }); + checkUOE(() -> { + boolean r = (boolean) vh.getAndSet(recv, true); + }); + checkUOE(() -> { boolean o = (boolean) vh.getAndAdd(recv, true); }); @@ -378,6 +383,10 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(true, false); }); + checkUOE(() -> { + boolean r = (boolean) vh.getAndSet(true); + }); + checkUOE(() -> { boolean o = (boolean) vh.getAndAdd(true); }); @@ -454,6 +463,10 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(recv, true, false); }); + checkUOE(() -> { + boolean r = (boolean) vh.getAndSet(recv, true); + }); + checkUOE(() -> { boolean o = (boolean) vh.getAndAdd(recv, true); }); @@ -530,6 +543,10 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(true, false); }); + checkUOE(() -> { + boolean r = (boolean) vh.getAndSet(true); + }); + checkUOE(() -> { boolean o = (boolean) vh.getAndAdd(true); }); @@ -613,6 +630,10 @@ public class VarHandleTestAccessBoolean extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(array, i, true, false); }); + checkUOE(() -> { + boolean r = (boolean) vh.getAndSet(array, i, true); + }); + checkUOE(() -> { boolean o = (boolean) vh.getAndAdd(array, i, true); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java index e550815156c..2ba0afbef2d 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessByte * @run testng/othervm -Diters=20000 VarHandleTestAccessByte * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessByte + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessByte */ import org.testng.annotations.BeforeClass; @@ -292,6 +293,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(recv, (byte)1, (byte)2); }); + checkUOE(() -> { + byte r = (byte) vh.getAndSet(recv, (byte)1); + }); + checkUOE(() -> { byte o = (byte) vh.getAndAdd(recv, (byte)1); }); @@ -378,6 +383,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease((byte)1, (byte)2); }); + checkUOE(() -> { + byte r = (byte) vh.getAndSet((byte)1); + }); + checkUOE(() -> { byte o = (byte) vh.getAndAdd((byte)1); }); @@ -454,6 +463,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(recv, (byte)1, (byte)2); }); + checkUOE(() -> { + byte r = (byte) vh.getAndSet(recv, (byte)1); + }); + checkUOE(() -> { byte o = (byte) vh.getAndAdd(recv, (byte)1); }); @@ -530,6 +543,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease((byte)1, (byte)2); }); + checkUOE(() -> { + byte r = (byte) vh.getAndSet((byte)1); + }); + checkUOE(() -> { byte o = (byte) vh.getAndAdd((byte)1); }); @@ -613,6 +630,10 @@ public class VarHandleTestAccessByte extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(array, i, (byte)1, (byte)2); }); + checkUOE(() -> { + byte r = (byte) vh.getAndSet(array, i, (byte)1); + }); + checkUOE(() -> { byte o = (byte) vh.getAndAdd(array, i, (byte)1); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java index 5c13c6d6677..bcc42a3c335 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessChar * @run testng/othervm -Diters=20000 VarHandleTestAccessChar * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessChar + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessChar */ import org.testng.annotations.BeforeClass; @@ -292,6 +293,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(recv, 'a', 'b'); }); + checkUOE(() -> { + char r = (char) vh.getAndSet(recv, 'a'); + }); + checkUOE(() -> { char o = (char) vh.getAndAdd(recv, 'a'); }); @@ -378,6 +383,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease('a', 'b'); }); + checkUOE(() -> { + char r = (char) vh.getAndSet('a'); + }); + checkUOE(() -> { char o = (char) vh.getAndAdd('a'); }); @@ -454,6 +463,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(recv, 'a', 'b'); }); + checkUOE(() -> { + char r = (char) vh.getAndSet(recv, 'a'); + }); + checkUOE(() -> { char o = (char) vh.getAndAdd(recv, 'a'); }); @@ -530,6 +543,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease('a', 'b'); }); + checkUOE(() -> { + char r = (char) vh.getAndSet('a'); + }); + checkUOE(() -> { char o = (char) vh.getAndAdd('a'); }); @@ -613,6 +630,10 @@ public class VarHandleTestAccessChar extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(array, i, 'a', 'b'); }); + checkUOE(() -> { + char r = (char) vh.getAndSet(array, i, 'a'); + }); + checkUOE(() -> { char o = (char) vh.getAndAdd(array, i, 'a'); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java index 65125e3f62e..74f0765f709 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessDouble * @run testng/othervm -Diters=20000 VarHandleTestAccessDouble * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessDouble + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessDouble */ import org.testng.annotations.BeforeClass; @@ -292,6 +293,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(recv, 1.0d, 2.0d); }); + checkUOE(() -> { + double r = (double) vh.getAndSet(recv, 1.0d); + }); + checkUOE(() -> { double o = (double) vh.getAndAdd(recv, 1.0d); }); @@ -378,6 +383,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(1.0d, 2.0d); }); + checkUOE(() -> { + double r = (double) vh.getAndSet(1.0d); + }); + checkUOE(() -> { double o = (double) vh.getAndAdd(1.0d); }); @@ -454,6 +463,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(recv, 1.0d, 2.0d); }); + checkUOE(() -> { + double r = (double) vh.getAndSet(recv, 1.0d); + }); + checkUOE(() -> { double o = (double) vh.getAndAdd(recv, 1.0d); }); @@ -530,6 +543,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(1.0d, 2.0d); }); + checkUOE(() -> { + double r = (double) vh.getAndSet(1.0d); + }); + checkUOE(() -> { double o = (double) vh.getAndAdd(1.0d); }); @@ -613,6 +630,10 @@ public class VarHandleTestAccessDouble extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(array, i, 1.0d, 2.0d); }); + checkUOE(() -> { + double r = (double) vh.getAndSet(array, i, 1.0d); + }); + checkUOE(() -> { double o = (double) vh.getAndAdd(array, i, 1.0d); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java index 8e7491ad45a..241e0897414 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessFloat * @run testng/othervm -Diters=20000 VarHandleTestAccessFloat * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessFloat + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessFloat */ import org.testng.annotations.BeforeClass; @@ -292,6 +293,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(recv, 1.0f, 2.0f); }); + checkUOE(() -> { + float r = (float) vh.getAndSet(recv, 1.0f); + }); + checkUOE(() -> { float o = (float) vh.getAndAdd(recv, 1.0f); }); @@ -378,6 +383,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(1.0f, 2.0f); }); + checkUOE(() -> { + float r = (float) vh.getAndSet(1.0f); + }); + checkUOE(() -> { float o = (float) vh.getAndAdd(1.0f); }); @@ -454,6 +463,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(recv, 1.0f, 2.0f); }); + checkUOE(() -> { + float r = (float) vh.getAndSet(recv, 1.0f); + }); + checkUOE(() -> { float o = (float) vh.getAndAdd(recv, 1.0f); }); @@ -530,6 +543,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(1.0f, 2.0f); }); + checkUOE(() -> { + float r = (float) vh.getAndSet(1.0f); + }); + checkUOE(() -> { float o = (float) vh.getAndAdd(1.0f); }); @@ -613,6 +630,10 @@ public class VarHandleTestAccessFloat extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(array, i, 1.0f, 2.0f); }); + checkUOE(() -> { + float r = (float) vh.getAndSet(array, i, 1.0f); + }); + checkUOE(() -> { float o = (float) vh.getAndAdd(array, i, 1.0f); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java index bfcb5feec4c..9ce9ef7baca 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessInt * @run testng/othervm -Diters=20000 VarHandleTestAccessInt * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessInt + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessInt */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java index 1f02bed9045..ff831d23fd1 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessLong * @run testng/othervm -Diters=20000 VarHandleTestAccessLong * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessLong + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessLong */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java index 822252f7a7d..a64ed990cb9 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessShort * @run testng/othervm -Diters=20000 VarHandleTestAccessShort * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessShort + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessShort */ import org.testng.annotations.BeforeClass; @@ -292,6 +293,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(recv, (short)1, (short)2); }); + checkUOE(() -> { + short r = (short) vh.getAndSet(recv, (short)1); + }); + checkUOE(() -> { short o = (short) vh.getAndAdd(recv, (short)1); }); @@ -378,6 +383,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease((short)1, (short)2); }); + checkUOE(() -> { + short r = (short) vh.getAndSet((short)1); + }); + checkUOE(() -> { short o = (short) vh.getAndAdd((short)1); }); @@ -454,6 +463,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(recv, (short)1, (short)2); }); + checkUOE(() -> { + short r = (short) vh.getAndSet(recv, (short)1); + }); + checkUOE(() -> { short o = (short) vh.getAndAdd(recv, (short)1); }); @@ -530,6 +543,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease((short)1, (short)2); }); + checkUOE(() -> { + short r = (short) vh.getAndSet((short)1); + }); + checkUOE(() -> { short o = (short) vh.getAndAdd((short)1); }); @@ -613,6 +630,10 @@ public class VarHandleTestAccessShort extends VarHandleBaseTest { boolean r = vh.weakCompareAndSetRelease(array, i, (short)1, (short)2); }); + checkUOE(() -> { + short r = (short) vh.getAndSet(array, i, (short)1); + }); + checkUOE(() -> { short o = (short) vh.getAndAdd(array, i, (short)1); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java index 9e4ec77768b..8b78b248e0f 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessString * @run testng/othervm -Diters=20000 VarHandleTestAccessString * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessString + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessString */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java index 8159e16ff62..806dd1ce4f8 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsChar * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsChar * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsChar + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsChar */ import org.testng.annotations.DataProvider; @@ -253,6 +254,10 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { checkROBE(() -> { vh.setOpaque(array, ci, VALUE_1); }); + checkUOE(() -> { + boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2); + }); + checkUOE(() -> { char r = (char) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java index a327b00fb77..95af9c2dd67 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsDouble * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsDouble * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsDouble + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsDouble */ import org.testng.annotations.DataProvider; @@ -254,9 +255,7 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { checkROBE(() -> { double o = (double) vh.getAndSet(array, ci, VALUE_1); }); - checkUOE(() -> { - boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2); - }); + checkUOE(() -> { double o = (double) vh.getAndAdd(array, ci, VALUE_1); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java index 196c8101723..48f7977bfdd 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsFloat * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsFloat * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsFloat + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsFloat */ import org.testng.annotations.DataProvider; @@ -254,9 +255,7 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { checkROBE(() -> { float o = (float) vh.getAndSet(array, ci, VALUE_1); }); - checkUOE(() -> { - boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2); - }); + checkUOE(() -> { float o = (float) vh.getAndAdd(array, ci, VALUE_1); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java index 400c20605c5..99690423f24 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsInt * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsInt * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsInt + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsInt */ import org.testng.annotations.DataProvider; @@ -247,9 +248,7 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { checkROBE(() -> { int o = (int) vh.getAndSet(array, ci, VALUE_1); }); - checkUOE(() -> { - boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2); - }); + checkROBE(() -> { int o = (int) vh.getAndAdd(array, ci, VALUE_1); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java index a0cabc8653a..de21efeee54 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsLong * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsLong * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsLong + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsLong */ import org.testng.annotations.DataProvider; @@ -247,9 +248,7 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { checkROBE(() -> { long o = (long) vh.getAndSet(array, ci, VALUE_1); }); - checkUOE(() -> { - boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2); - }); + checkROBE(() -> { long o = (long) vh.getAndAdd(array, ci, VALUE_1); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java index 2632b00bd23..b13bce1e1da 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsShort * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsShort * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsShort + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsShort */ import org.testng.annotations.DataProvider; @@ -253,6 +254,10 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { checkROBE(() -> { vh.setOpaque(array, ci, VALUE_1); }); + checkUOE(() -> { + boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2); + }); + checkUOE(() -> { short r = (short) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java index 32761fe0e3f..f43fcc1b82c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java @@ -24,6 +24,7 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessBoolean + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessBoolean */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java index 8c36eb861c5..3d5c27e8bfd 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java @@ -24,6 +24,7 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessByte + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessByte */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java index fb1f3877342..bde76a69c05 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java @@ -24,6 +24,7 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessChar + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessChar */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java index cd2c15d04d3..de683ce6997 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java @@ -24,6 +24,7 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessDouble + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessDouble */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java index 58d9e295298..99309e5081f 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java @@ -24,6 +24,7 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessFloat + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessFloat */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java index 8ccf7983056..6b35f03ab7f 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java @@ -24,6 +24,7 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessInt + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessInt */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java index 65493ec2b49..840ccf272ae 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java @@ -24,6 +24,7 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessLong + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessLong */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java index 6edc9b19b68..51b51e73747 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java @@ -24,6 +24,7 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessShort + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessShort */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java index 5ae7c877854..096880f3557 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java @@ -24,6 +24,7 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessString + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessString */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java index 75ba7ae3dc2..df680146374 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8156486 * @run testng/othervm VarHandleTestMethodTypeBoolean * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeBoolean */ @@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { public Object[][] accessTestCaseProvider() throws Exception { List> cases = new ArrayList<>(); - cases.add(new VarHandleAccessTestCase("Instance field wrong method type", + cases.add(new VarHandleAccessTestCase("Instance field", vhField, vh -> testInstanceFieldWrongMethodType(this, vh), false)); - cases.add(new VarHandleAccessTestCase("Static field wrong method type", + cases.add(new VarHandleAccessTestCase("Static field", vhStaticField, VarHandleTestMethodTypeBoolean::testStaticFieldWrongMethodType, false)); - cases.add(new VarHandleAccessTestCase("Array wrong method type", + cases.add(new VarHandleAccessTestCase("Array", vhArray, VarHandleTestMethodTypeBoolean::testArrayWrongMethodType, false)); + for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { - cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", + cases.add(new MethodHandleAccessTestCase("Instance field", vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), false)); - cases.add(new MethodHandleAccessTestCase("Static field wrong method type", + cases.add(new MethodHandleAccessTestCase("Static field", vhStaticField, f, VarHandleTestMethodTypeBoolean::testStaticFieldWrongMethodType, false)); - cases.add(new MethodHandleAccessTestCase("Array wrong method type", + cases.add(new MethodHandleAccessTestCase("Array", vhArray, f, VarHandleTestMethodTypeBoolean::testArrayWrongMethodType, false)); } @@ -329,63 +331,63 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null receiver - boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class)). - invoke(null); + boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class)). + invokeExact((VarHandleTestMethodTypeBoolean) null); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); checkWMTE(() -> { // receiver primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)). - invoke(0); + invokeExact(0); }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class)). - invoke(recv); + Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeBoolean.class)). + invokeExact(recv); }); checkWMTE(() -> { // primitive class int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeBoolean.class)). - invoke(recv); + invokeExact(recv); }); // Incorrect arity checkWMTE(() -> { // 0 boolean x = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeBoolean.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - hs.get(am, methodType(void.class, Void.class, boolean.class)). - invoke(null, true); + hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, boolean.class)). + invokeExact((VarHandleTestMethodTypeBoolean) null, true); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class hs.get(am, methodType(void.class, Class.class, boolean.class)). - invoke(Void.class, true); + invokeExact(Void.class, true); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, boolean.class)). - invoke(0, true); + invokeExact(0, true); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, VarHandleTestMethodTypeBoolean.class, boolean.class, Class.class)). - invoke(recv, true, Void.class); + invokeExact(recv, true, Void.class); }); } @@ -513,32 +515,32 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // primitive class int x = (int) hs.get(am, methodType(int.class)). - invoke(); + invokeExact(); }); // Incorrect arity checkWMTE(() -> { // > boolean x = (boolean) hs.get(am, methodType(Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, boolean.class, Class.class)). - invoke(true, Void.class); + invokeExact(true, Void.class); }); } @@ -783,71 +785,71 @@ public class VarHandleTestMethodTypeBoolean extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null array - boolean x = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class)). - invoke(null, 0); + boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class)). + invokeExact((boolean[]) null, 0); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class boolean x = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)). - invoke(Void.class, 0); + invokeExact(Void.class, 0); }); checkWMTE(() -> { // array primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)). - invoke(0, 0); + invokeExact(0, 0); }); checkWMTE(() -> { // index reference class boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, Class.class)). - invoke(array, Void.class); + invokeExact(array, Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class, boolean[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); checkWMTE(() -> { // primitive class int x = (int) hs.get(am, methodType(int.class, boolean[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); // Incorrect arity checkWMTE(() -> { // 0 boolean x = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean x = (boolean) hs.get(am, methodType(boolean.class, boolean[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null array - hs.get(am, methodType(void.class, Void.class, int.class, boolean.class)). - invoke(null, 0, true); + hs.get(am, methodType(void.class, boolean[].class, int.class, boolean.class)). + invokeExact((boolean[]) null, 0, true); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class hs.get(am, methodType(void.class, Class.class, int.class, boolean.class)). - invoke(Void.class, 0, true); + invokeExact(Void.class, 0, true); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, int.class, boolean.class)). - invoke(0, 0, true); + invokeExact(0, 0, true); }); checkWMTE(() -> { // index reference class hs.get(am, methodType(void.class, boolean[].class, Class.class, boolean.class)). - invoke(array, Void.class, true); + invokeExact(array, Void.class, true); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, boolean[].class, int.class, Class.class)). - invoke(array, 0, true, Void.class); + invokeExact(array, 0, true, Void.class); }); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java index b212bfc9d7d..0bfddc7ad27 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8156486 * @run testng/othervm VarHandleTestMethodTypeByte * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeByte */ @@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { public Object[][] accessTestCaseProvider() throws Exception { List> cases = new ArrayList<>(); - cases.add(new VarHandleAccessTestCase("Instance field wrong method type", + cases.add(new VarHandleAccessTestCase("Instance field", vhField, vh -> testInstanceFieldWrongMethodType(this, vh), false)); - cases.add(new VarHandleAccessTestCase("Static field wrong method type", + cases.add(new VarHandleAccessTestCase("Static field", vhStaticField, VarHandleTestMethodTypeByte::testStaticFieldWrongMethodType, false)); - cases.add(new VarHandleAccessTestCase("Array wrong method type", + cases.add(new VarHandleAccessTestCase("Array", vhArray, VarHandleTestMethodTypeByte::testArrayWrongMethodType, false)); + for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { - cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", + cases.add(new MethodHandleAccessTestCase("Instance field", vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), false)); - cases.add(new MethodHandleAccessTestCase("Static field wrong method type", + cases.add(new MethodHandleAccessTestCase("Static field", vhStaticField, f, VarHandleTestMethodTypeByte::testStaticFieldWrongMethodType, false)); - cases.add(new MethodHandleAccessTestCase("Array wrong method type", + cases.add(new MethodHandleAccessTestCase("Array", vhArray, f, VarHandleTestMethodTypeByte::testArrayWrongMethodType, false)); } @@ -329,63 +331,63 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null receiver - byte x = (byte) hs.get(am, methodType(byte.class, Void.class)). - invoke(null); + byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class)). + invokeExact((VarHandleTestMethodTypeByte) null); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class byte x = (byte) hs.get(am, methodType(byte.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); checkWMTE(() -> { // receiver primitive class byte x = (byte) hs.get(am, methodType(byte.class, int.class)). - invoke(0); + invokeExact(0); }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class)). - invoke(recv); + Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeByte.class)). + invokeExact(recv); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeByte.class)). - invoke(recv); + invokeExact(recv); }); // Incorrect arity checkWMTE(() -> { // 0 byte x = (byte) hs.get(am, methodType(byte.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > byte x = (byte) hs.get(am, methodType(byte.class, VarHandleTestMethodTypeByte.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - hs.get(am, methodType(void.class, Void.class, byte.class)). - invoke(null, (byte)1); + hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class)). + invokeExact((VarHandleTestMethodTypeByte) null, (byte)1); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class hs.get(am, methodType(void.class, Class.class, byte.class)). - invoke(Void.class, (byte)1); + invokeExact(Void.class, (byte)1); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, byte.class)). - invoke(0, (byte)1); + invokeExact(0, (byte)1); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, VarHandleTestMethodTypeByte.class, byte.class, Class.class)). - invoke(recv, (byte)1, Void.class); + invokeExact(recv, (byte)1, Void.class); }); } @@ -513,32 +515,32 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); // Incorrect arity checkWMTE(() -> { // > byte x = (byte) hs.get(am, methodType(Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, byte.class, Class.class)). - invoke((byte)1, Void.class); + invokeExact((byte)1, Void.class); }); } @@ -783,71 +785,71 @@ public class VarHandleTestMethodTypeByte extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null array - byte x = (byte) hs.get(am, methodType(byte.class, Void.class, int.class)). - invoke(null, 0); + byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class)). + invokeExact((byte[]) null, 0); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class byte x = (byte) hs.get(am, methodType(byte.class, Class.class, int.class)). - invoke(Void.class, 0); + invokeExact(Void.class, 0); }); checkWMTE(() -> { // array primitive class byte x = (byte) hs.get(am, methodType(byte.class, int.class, int.class)). - invoke(0, 0); + invokeExact(0, 0); }); checkWMTE(() -> { // index reference class byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, Class.class)). - invoke(array, Void.class); + invokeExact(array, Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class, byte[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, byte[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); // Incorrect arity checkWMTE(() -> { // 0 byte x = (byte) hs.get(am, methodType(byte.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > byte x = (byte) hs.get(am, methodType(byte.class, byte[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null array - hs.get(am, methodType(void.class, Void.class, int.class, byte.class)). - invoke(null, 0, (byte)1); + hs.get(am, methodType(void.class, byte[].class, int.class, byte.class)). + invokeExact((byte[]) null, 0, (byte)1); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class hs.get(am, methodType(void.class, Class.class, int.class, byte.class)). - invoke(Void.class, 0, (byte)1); + invokeExact(Void.class, 0, (byte)1); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, int.class, byte.class)). - invoke(0, 0, (byte)1); + invokeExact(0, 0, (byte)1); }); checkWMTE(() -> { // index reference class hs.get(am, methodType(void.class, byte[].class, Class.class, byte.class)). - invoke(array, Void.class, (byte)1); + invokeExact(array, Void.class, (byte)1); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, byte[].class, int.class, Class.class)). - invoke(array, 0, (byte)1, Void.class); + invokeExact(array, 0, (byte)1, Void.class); }); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java index 6ac8a0fed70..8d5166d8644 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8156486 * @run testng/othervm VarHandleTestMethodTypeChar * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeChar */ @@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { public Object[][] accessTestCaseProvider() throws Exception { List> cases = new ArrayList<>(); - cases.add(new VarHandleAccessTestCase("Instance field wrong method type", + cases.add(new VarHandleAccessTestCase("Instance field", vhField, vh -> testInstanceFieldWrongMethodType(this, vh), false)); - cases.add(new VarHandleAccessTestCase("Static field wrong method type", + cases.add(new VarHandleAccessTestCase("Static field", vhStaticField, VarHandleTestMethodTypeChar::testStaticFieldWrongMethodType, false)); - cases.add(new VarHandleAccessTestCase("Array wrong method type", + cases.add(new VarHandleAccessTestCase("Array", vhArray, VarHandleTestMethodTypeChar::testArrayWrongMethodType, false)); + for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { - cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", + cases.add(new MethodHandleAccessTestCase("Instance field", vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), false)); - cases.add(new MethodHandleAccessTestCase("Static field wrong method type", + cases.add(new MethodHandleAccessTestCase("Static field", vhStaticField, f, VarHandleTestMethodTypeChar::testStaticFieldWrongMethodType, false)); - cases.add(new MethodHandleAccessTestCase("Array wrong method type", + cases.add(new MethodHandleAccessTestCase("Array", vhArray, f, VarHandleTestMethodTypeChar::testArrayWrongMethodType, false)); } @@ -329,63 +331,63 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null receiver - char x = (char) hs.get(am, methodType(char.class, Void.class)). - invoke(null); + char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class)). + invokeExact((VarHandleTestMethodTypeChar) null); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class char x = (char) hs.get(am, methodType(char.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); checkWMTE(() -> { // receiver primitive class char x = (char) hs.get(am, methodType(char.class, int.class)). - invoke(0); + invokeExact(0); }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class)). - invoke(recv); + Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeChar.class)). + invokeExact(recv); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeChar.class)). - invoke(recv); + invokeExact(recv); }); // Incorrect arity checkWMTE(() -> { // 0 char x = (char) hs.get(am, methodType(char.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > char x = (char) hs.get(am, methodType(char.class, VarHandleTestMethodTypeChar.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - hs.get(am, methodType(void.class, Void.class, char.class)). - invoke(null, 'a'); + hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, char.class)). + invokeExact((VarHandleTestMethodTypeChar) null, 'a'); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class hs.get(am, methodType(void.class, Class.class, char.class)). - invoke(Void.class, 'a'); + invokeExact(Void.class, 'a'); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, char.class)). - invoke(0, 'a'); + invokeExact(0, 'a'); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, VarHandleTestMethodTypeChar.class, char.class, Class.class)). - invoke(recv, 'a', Void.class); + invokeExact(recv, 'a', Void.class); }); } @@ -513,32 +515,32 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); // Incorrect arity checkWMTE(() -> { // > char x = (char) hs.get(am, methodType(Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, char.class, Class.class)). - invoke('a', Void.class); + invokeExact('a', Void.class); }); } @@ -783,71 +785,71 @@ public class VarHandleTestMethodTypeChar extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null array - char x = (char) hs.get(am, methodType(char.class, Void.class, int.class)). - invoke(null, 0); + char x = (char) hs.get(am, methodType(char.class, char[].class, int.class)). + invokeExact((char[]) null, 0); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class char x = (char) hs.get(am, methodType(char.class, Class.class, int.class)). - invoke(Void.class, 0); + invokeExact(Void.class, 0); }); checkWMTE(() -> { // array primitive class char x = (char) hs.get(am, methodType(char.class, int.class, int.class)). - invoke(0, 0); + invokeExact(0, 0); }); checkWMTE(() -> { // index reference class char x = (char) hs.get(am, methodType(char.class, char[].class, Class.class)). - invoke(array, Void.class); + invokeExact(array, Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class, char[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, char[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); // Incorrect arity checkWMTE(() -> { // 0 char x = (char) hs.get(am, methodType(char.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > char x = (char) hs.get(am, methodType(char.class, char[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null array - hs.get(am, methodType(void.class, Void.class, int.class, char.class)). - invoke(null, 0, 'a'); + hs.get(am, methodType(void.class, char[].class, int.class, char.class)). + invokeExact((char[]) null, 0, 'a'); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class hs.get(am, methodType(void.class, Class.class, int.class, char.class)). - invoke(Void.class, 0, 'a'); + invokeExact(Void.class, 0, 'a'); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, char[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, int.class, char.class)). - invoke(0, 0, 'a'); + invokeExact(0, 0, 'a'); }); checkWMTE(() -> { // index reference class hs.get(am, methodType(void.class, char[].class, Class.class, char.class)). - invoke(array, Void.class, 'a'); + invokeExact(array, Void.class, 'a'); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, char[].class, int.class, Class.class)). - invoke(array, 0, 'a', Void.class); + invokeExact(array, 0, 'a', Void.class); }); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java index e5fc073d191..f3531016262 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8156486 * @run testng/othervm VarHandleTestMethodTypeDouble * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeDouble */ @@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { public Object[][] accessTestCaseProvider() throws Exception { List> cases = new ArrayList<>(); - cases.add(new VarHandleAccessTestCase("Instance field wrong method type", + cases.add(new VarHandleAccessTestCase("Instance field", vhField, vh -> testInstanceFieldWrongMethodType(this, vh), false)); - cases.add(new VarHandleAccessTestCase("Static field wrong method type", + cases.add(new VarHandleAccessTestCase("Static field", vhStaticField, VarHandleTestMethodTypeDouble::testStaticFieldWrongMethodType, false)); - cases.add(new VarHandleAccessTestCase("Array wrong method type", + cases.add(new VarHandleAccessTestCase("Array", vhArray, VarHandleTestMethodTypeDouble::testArrayWrongMethodType, false)); + for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { - cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", + cases.add(new MethodHandleAccessTestCase("Instance field", vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), false)); - cases.add(new MethodHandleAccessTestCase("Static field wrong method type", + cases.add(new MethodHandleAccessTestCase("Static field", vhStaticField, f, VarHandleTestMethodTypeDouble::testStaticFieldWrongMethodType, false)); - cases.add(new MethodHandleAccessTestCase("Array wrong method type", + cases.add(new MethodHandleAccessTestCase("Array", vhArray, f, VarHandleTestMethodTypeDouble::testArrayWrongMethodType, false)); } @@ -329,63 +331,63 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null receiver - double x = (double) hs.get(am, methodType(double.class, Void.class)). - invoke(null); + double x = (double) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class)). + invokeExact((VarHandleTestMethodTypeDouble) null); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class double x = (double) hs.get(am, methodType(double.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); checkWMTE(() -> { // receiver primitive class double x = (double) hs.get(am, methodType(double.class, int.class)). - invoke(0); + invokeExact(0); }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class)). - invoke(recv); + Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeDouble.class)). + invokeExact(recv); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeDouble.class)). - invoke(recv); + invokeExact(recv); }); // Incorrect arity checkWMTE(() -> { // 0 double x = (double) hs.get(am, methodType(double.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > double x = (double) hs.get(am, methodType(double.class, VarHandleTestMethodTypeDouble.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - hs.get(am, methodType(void.class, Void.class, double.class)). - invoke(null, 1.0d); + hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, double.class)). + invokeExact((VarHandleTestMethodTypeDouble) null, 1.0d); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class hs.get(am, methodType(void.class, Class.class, double.class)). - invoke(Void.class, 1.0d); + invokeExact(Void.class, 1.0d); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, double.class)). - invoke(0, 1.0d); + invokeExact(0, 1.0d); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, VarHandleTestMethodTypeDouble.class, double.class, Class.class)). - invoke(recv, 1.0d, Void.class); + invokeExact(recv, 1.0d, Void.class); }); } @@ -513,32 +515,32 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); // Incorrect arity checkWMTE(() -> { // > double x = (double) hs.get(am, methodType(Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, double.class, Class.class)). - invoke(1.0d, Void.class); + invokeExact(1.0d, Void.class); }); } @@ -783,71 +785,71 @@ public class VarHandleTestMethodTypeDouble extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null array - double x = (double) hs.get(am, methodType(double.class, Void.class, int.class)). - invoke(null, 0); + double x = (double) hs.get(am, methodType(double.class, double[].class, int.class)). + invokeExact((double[]) null, 0); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class double x = (double) hs.get(am, methodType(double.class, Class.class, int.class)). - invoke(Void.class, 0); + invokeExact(Void.class, 0); }); checkWMTE(() -> { // array primitive class double x = (double) hs.get(am, methodType(double.class, int.class, int.class)). - invoke(0, 0); + invokeExact(0, 0); }); checkWMTE(() -> { // index reference class double x = (double) hs.get(am, methodType(double.class, double[].class, Class.class)). - invoke(array, Void.class); + invokeExact(array, Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class, double[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, double[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); // Incorrect arity checkWMTE(() -> { // 0 double x = (double) hs.get(am, methodType(double.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > double x = (double) hs.get(am, methodType(double.class, double[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null array - hs.get(am, methodType(void.class, Void.class, int.class, double.class)). - invoke(null, 0, 1.0d); + hs.get(am, methodType(void.class, double[].class, int.class, double.class)). + invokeExact((double[]) null, 0, 1.0d); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class hs.get(am, methodType(void.class, Class.class, int.class, double.class)). - invoke(Void.class, 0, 1.0d); + invokeExact(Void.class, 0, 1.0d); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, double[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, int.class, double.class)). - invoke(0, 0, 1.0d); + invokeExact(0, 0, 1.0d); }); checkWMTE(() -> { // index reference class hs.get(am, methodType(void.class, double[].class, Class.class, double.class)). - invoke(array, Void.class, 1.0d); + invokeExact(array, Void.class, 1.0d); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, double[].class, int.class, Class.class)). - invoke(array, 0, 1.0d, Void.class); + invokeExact(array, 0, 1.0d, Void.class); }); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java index c1bee039b73..b07049d64b0 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8156486 * @run testng/othervm VarHandleTestMethodTypeFloat * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeFloat */ @@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { public Object[][] accessTestCaseProvider() throws Exception { List> cases = new ArrayList<>(); - cases.add(new VarHandleAccessTestCase("Instance field wrong method type", + cases.add(new VarHandleAccessTestCase("Instance field", vhField, vh -> testInstanceFieldWrongMethodType(this, vh), false)); - cases.add(new VarHandleAccessTestCase("Static field wrong method type", + cases.add(new VarHandleAccessTestCase("Static field", vhStaticField, VarHandleTestMethodTypeFloat::testStaticFieldWrongMethodType, false)); - cases.add(new VarHandleAccessTestCase("Array wrong method type", + cases.add(new VarHandleAccessTestCase("Array", vhArray, VarHandleTestMethodTypeFloat::testArrayWrongMethodType, false)); + for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { - cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", + cases.add(new MethodHandleAccessTestCase("Instance field", vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), false)); - cases.add(new MethodHandleAccessTestCase("Static field wrong method type", + cases.add(new MethodHandleAccessTestCase("Static field", vhStaticField, f, VarHandleTestMethodTypeFloat::testStaticFieldWrongMethodType, false)); - cases.add(new MethodHandleAccessTestCase("Array wrong method type", + cases.add(new MethodHandleAccessTestCase("Array", vhArray, f, VarHandleTestMethodTypeFloat::testArrayWrongMethodType, false)); } @@ -329,63 +331,63 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null receiver - float x = (float) hs.get(am, methodType(float.class, Void.class)). - invoke(null); + float x = (float) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class)). + invokeExact((VarHandleTestMethodTypeFloat) null); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class float x = (float) hs.get(am, methodType(float.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); checkWMTE(() -> { // receiver primitive class float x = (float) hs.get(am, methodType(float.class, int.class)). - invoke(0); + invokeExact(0); }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class)). - invoke(recv); + Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeFloat.class)). + invokeExact(recv); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeFloat.class)). - invoke(recv); + invokeExact(recv); }); // Incorrect arity checkWMTE(() -> { // 0 float x = (float) hs.get(am, methodType(float.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > float x = (float) hs.get(am, methodType(float.class, VarHandleTestMethodTypeFloat.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - hs.get(am, methodType(void.class, Void.class, float.class)). - invoke(null, 1.0f); + hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, float.class)). + invokeExact((VarHandleTestMethodTypeFloat) null, 1.0f); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class hs.get(am, methodType(void.class, Class.class, float.class)). - invoke(Void.class, 1.0f); + invokeExact(Void.class, 1.0f); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, float.class)). - invoke(0, 1.0f); + invokeExact(0, 1.0f); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, VarHandleTestMethodTypeFloat.class, float.class, Class.class)). - invoke(recv, 1.0f, Void.class); + invokeExact(recv, 1.0f, Void.class); }); } @@ -513,32 +515,32 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); // Incorrect arity checkWMTE(() -> { // > float x = (float) hs.get(am, methodType(Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, float.class, Class.class)). - invoke(1.0f, Void.class); + invokeExact(1.0f, Void.class); }); } @@ -783,71 +785,71 @@ public class VarHandleTestMethodTypeFloat extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null array - float x = (float) hs.get(am, methodType(float.class, Void.class, int.class)). - invoke(null, 0); + float x = (float) hs.get(am, methodType(float.class, float[].class, int.class)). + invokeExact((float[]) null, 0); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class float x = (float) hs.get(am, methodType(float.class, Class.class, int.class)). - invoke(Void.class, 0); + invokeExact(Void.class, 0); }); checkWMTE(() -> { // array primitive class float x = (float) hs.get(am, methodType(float.class, int.class, int.class)). - invoke(0, 0); + invokeExact(0, 0); }); checkWMTE(() -> { // index reference class float x = (float) hs.get(am, methodType(float.class, float[].class, Class.class)). - invoke(array, Void.class); + invokeExact(array, Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class, float[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, float[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); // Incorrect arity checkWMTE(() -> { // 0 float x = (float) hs.get(am, methodType(float.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > float x = (float) hs.get(am, methodType(float.class, float[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null array - hs.get(am, methodType(void.class, Void.class, int.class, float.class)). - invoke(null, 0, 1.0f); + hs.get(am, methodType(void.class, float[].class, int.class, float.class)). + invokeExact((float[]) null, 0, 1.0f); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class hs.get(am, methodType(void.class, Class.class, int.class, float.class)). - invoke(Void.class, 0, 1.0f); + invokeExact(Void.class, 0, 1.0f); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, float[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, int.class, float.class)). - invoke(0, 0, 1.0f); + invokeExact(0, 0, 1.0f); }); checkWMTE(() -> { // index reference class hs.get(am, methodType(void.class, float[].class, Class.class, float.class)). - invoke(array, Void.class, 1.0f); + invokeExact(array, Void.class, 1.0f); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, float[].class, int.class, Class.class)). - invoke(array, 0, 1.0f, Void.class); + invokeExact(array, 0, 1.0f, Void.class); }); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java index 13b6b0607b0..67fca94c49a 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8156486 * @run testng/othervm VarHandleTestMethodTypeInt * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeInt */ @@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { public Object[][] accessTestCaseProvider() throws Exception { List> cases = new ArrayList<>(); - cases.add(new VarHandleAccessTestCase("Instance field wrong method type", + cases.add(new VarHandleAccessTestCase("Instance field", vhField, vh -> testInstanceFieldWrongMethodType(this, vh), false)); - cases.add(new VarHandleAccessTestCase("Static field wrong method type", + cases.add(new VarHandleAccessTestCase("Static field", vhStaticField, VarHandleTestMethodTypeInt::testStaticFieldWrongMethodType, false)); - cases.add(new VarHandleAccessTestCase("Array wrong method type", + cases.add(new VarHandleAccessTestCase("Array", vhArray, VarHandleTestMethodTypeInt::testArrayWrongMethodType, false)); + for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { - cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", + cases.add(new MethodHandleAccessTestCase("Instance field", vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), false)); - cases.add(new MethodHandleAccessTestCase("Static field wrong method type", + cases.add(new MethodHandleAccessTestCase("Static field", vhStaticField, f, VarHandleTestMethodTypeInt::testStaticFieldWrongMethodType, false)); - cases.add(new MethodHandleAccessTestCase("Array wrong method type", + cases.add(new MethodHandleAccessTestCase("Array", vhArray, f, VarHandleTestMethodTypeInt::testArrayWrongMethodType, false)); } @@ -644,211 +646,211 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null receiver - int x = (int) hs.get(am, methodType(int.class, Void.class)). - invoke(null); + int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class)). + invokeExact((VarHandleTestMethodTypeInt) null); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class int x = (int) hs.get(am, methodType(int.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); checkWMTE(() -> { // receiver primitive class int x = (int) hs.get(am, methodType(int.class, int.class)). - invoke(0); + invokeExact(0); }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class)). - invoke(recv); + Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class)). + invokeExact(recv); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class)). - invoke(recv); + invokeExact(recv); }); // Incorrect arity checkWMTE(() -> { // 0 int x = (int) hs.get(am, methodType(int.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - hs.get(am, methodType(void.class, Void.class, int.class)). - invoke(null, 1); + hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class)). + invokeExact((VarHandleTestMethodTypeInt) null, 1); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class hs.get(am, methodType(void.class, Class.class, int.class)). - invoke(Void.class, 1); + invokeExact(Void.class, 1); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, int.class)). - invoke(0, 1); + invokeExact(0, 1); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)). - invoke(recv, 1, Void.class); + invokeExact(recv, 1, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, int.class)). - invoke(null, 1, 1); + boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class)). + invokeExact((VarHandleTestMethodTypeInt) null, 1, 1); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class)). - invoke(Void.class, 1, 1); + invokeExact(Void.class, 1, 1); }); checkWMTE(() -> { // expected reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)). - invoke(recv, Void.class, 1); + invokeExact(recv, Void.class, 1); }); checkWMTE(() -> { // actual reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)). - invoke(recv, 1, Void.class); + invokeExact(recv, 1, Void.class); }); checkWMTE(() -> { // receiver primitive class boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , int.class, int.class)). - invoke(0, 1, 1); + invokeExact(0, 1, 1); }); // Incorrect arity checkWMTE(() -> { // 0 boolean r = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)). - invoke(recv, 1, 1, Void.class); + invokeExact(recv, 1, 1, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { checkNPE(() -> { // null receiver - int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)). - invoke(null, 1, 1); + int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class)). + invokeExact((VarHandleTestMethodTypeInt) null, 1, 1); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)). - invoke(Void.class, 1, 1); + invokeExact(Void.class, 1, 1); }); checkWMTE(() -> { // expected reference class int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class, int.class)). - invoke(recv, Void.class, 1); + invokeExact(recv, Void.class, 1); }); checkWMTE(() -> { // actual reference class int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, Class.class)). - invoke(recv, 1, Void.class); + invokeExact(recv, 1, Void.class); }); checkWMTE(() -> { // reciever primitive class int x = (int) hs.get(am, methodType(int.class, int.class , int.class, int.class)). - invoke(0, 1, 1); + invokeExact(0, 1, 1); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class , int.class, int.class)). - invoke(recv, 1, 1); + invokeExact(recv, 1, 1); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class , int.class, int.class)). - invoke(recv, 1, 1); + invokeExact(recv, 1, 1); }); // Incorrect arity checkWMTE(() -> { // 0 int x = (int) hs.get(am, methodType(int.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class, int.class, Class.class)). - invoke(recv, 1, 1, Void.class); + invokeExact(recv, 1, 1, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { checkNPE(() -> { // null receiver - int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)). - invoke(null, 1); + int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)). + invokeExact((VarHandleTestMethodTypeInt) null, 1); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)). - invoke(Void.class, 1); + invokeExact(Void.class, 1); }); checkWMTE(() -> { // value reference class int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class int x = (int) hs.get(am, methodType(int.class, int.class, int.class)). - invoke(0, 1); + invokeExact(0, 1); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)). - invoke(recv, 1); + invokeExact(recv, 1); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)). - invoke(recv, 1); + invokeExact(recv, 1); }); // Incorrect arity checkWMTE(() -> { // 0 int x = (int) hs.get(am, methodType(int.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)). - invoke(recv, 1, Void.class); + invokeExact(recv, 1, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { checkNPE(() -> { // null receiver - int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)). - invoke(null, 1); + int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)). + invokeExact((VarHandleTestMethodTypeInt) null, 1); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)). - invoke(Void.class, 1); + invokeExact(Void.class, 1); }); checkWMTE(() -> { // value reference class int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class int x = (int) hs.get(am, methodType(int.class, int.class, int.class)). - invoke(0, 1); + invokeExact(0, 1); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeInt.class, int.class)). - invoke(recv, 1); + invokeExact(recv, 1); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeInt.class, int.class)). - invoke(recv, 1); + invokeExact(recv, 1); }); // Incorrect arity checkWMTE(() -> { // 0 int x = (int) hs.get(am, methodType(int.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > int x = (int) hs.get(am, methodType(int.class, VarHandleTestMethodTypeInt.class, int.class)). - invoke(recv, 1, Void.class); + invokeExact(recv, 1, Void.class); }); } } @@ -1190,52 +1192,52 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); // Incorrect arity checkWMTE(() -> { // > int x = (int) hs.get(am, methodType(Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, int.class, Class.class)). - invoke(1, Void.class); + invokeExact(1, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class)). - invoke(Void.class, 1); + invokeExact(Void.class, 1); }); checkWMTE(() -> { // actual reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, Class.class)). - invoke(1, Void.class); + invokeExact(1, Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 boolean r = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, Class.class)). - invoke(1, 1, Void.class); + invokeExact(1, 1, Void.class); }); } @@ -1243,29 +1245,29 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { // Incorrect argument types checkWMTE(() -> { // expected reference class int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)). - invoke(Void.class, 1); + invokeExact(Void.class, 1); }); checkWMTE(() -> { // actual reference class int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)). - invoke(1, Void.class); + invokeExact(1, Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, int.class, int.class)). - invoke(1, 1); + invokeExact(1, 1); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class)). - invoke(1, 1); + invokeExact(1, 1); }); // Incorrect arity checkWMTE(() -> { // 0 int x = (int) hs.get(am, methodType(int.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > int x = (int) hs.get(am, methodType(int.class, int.class, int.class, Class.class)). - invoke(1, 1, Void.class); + invokeExact(1, 1, Void.class); }); } @@ -1273,25 +1275,25 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { // Incorrect argument types checkWMTE(() -> { // value reference class int x = (int) hs.get(am, methodType(int.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, int.class)). - invoke(1); + invokeExact(1); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)). - invoke(1); + invokeExact(1); }); // Incorrect arity checkWMTE(() -> { // 0 int x = (int) hs.get(am, methodType(int.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)). - invoke(1, Void.class); + invokeExact(1, Void.class); }); } @@ -1299,25 +1301,25 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { // Incorrect argument types checkWMTE(() -> { // value reference class int x = (int) hs.get(am, methodType(int.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, int.class)). - invoke(1); + invokeExact(1); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, int.class)). - invoke(1); + invokeExact(1); }); // Incorrect arity checkWMTE(() -> { // 0 int x = (int) hs.get(am, methodType(int.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > int x = (int) hs.get(am, methodType(int.class, int.class, Class.class)). - invoke(1, Void.class); + invokeExact(1, Void.class); }); } } @@ -1909,237 +1911,237 @@ public class VarHandleTestMethodTypeInt extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null array - int x = (int) hs.get(am, methodType(int.class, Void.class, int.class)). - invoke(null, 0); + int x = (int) hs.get(am, methodType(int.class, int[].class, int.class)). + invokeExact((int[]) null, 0); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class int x = (int) hs.get(am, methodType(int.class, Class.class, int.class)). - invoke(Void.class, 0); + invokeExact(Void.class, 0); }); checkWMTE(() -> { // array primitive class int x = (int) hs.get(am, methodType(int.class, int.class, int.class)). - invoke(0, 0); + invokeExact(0, 0); }); checkWMTE(() -> { // index reference class int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class)). - invoke(array, Void.class); + invokeExact(array, Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class, int[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); // Incorrect arity checkWMTE(() -> { // 0 int x = (int) hs.get(am, methodType(int.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null array - hs.get(am, methodType(void.class, Void.class, int.class, int.class)). - invoke(null, 0, 1); + hs.get(am, methodType(void.class, int[].class, int.class, int.class)). + invokeExact((int[]) null, 0, 1); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class hs.get(am, methodType(void.class, Class.class, int.class, int.class)). - invoke(Void.class, 0, 1); + invokeExact(Void.class, 0, 1); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, int[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, int.class, int.class)). - invoke(0, 0, 1); + invokeExact(0, 0, 1); }); checkWMTE(() -> { // index reference class hs.get(am, methodType(void.class, int[].class, Class.class, int.class)). - invoke(array, Void.class, 1); + invokeExact(array, Void.class, 1); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, int[].class, int.class, Class.class)). - invoke(array, 0, 1, Void.class); + invokeExact(array, 0, 1, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, int.class, int.class)). - invoke(null, 0, 1, 1); + boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class)). + invokeExact((int[]) null, 0, 1, 1); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, int.class, int.class)). - invoke(Void.class, 0, 1, 1); + invokeExact(Void.class, 0, 1, 1); }); checkWMTE(() -> { // expected reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, Class.class, int.class)). - invoke(array, 0, Void.class, 1); + invokeExact(array, 0, Void.class, 1); }); checkWMTE(() -> { // actual reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, Class.class)). - invoke(array, 0, 1, Void.class); + invokeExact(array, 0, 1, Void.class); }); checkWMTE(() -> { // receiver primitive class boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, int.class, int.class)). - invoke(0, 0, 1, 1); + invokeExact(0, 0, 1, 1); }); checkWMTE(() -> { // index reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, Class.class, int.class, int.class)). - invoke(array, Void.class, 1, 1); + invokeExact(array, Void.class, 1, 1); }); // Incorrect arity checkWMTE(() -> { // 0 boolean r = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean r = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class, Class.class)). - invoke(array, 0, 1, 1, Void.class); + invokeExact(array, 0, 1, 1, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { // Incorrect argument types checkNPE(() -> { // null receiver - int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class, int.class)). - invoke(null, 0, 1, 1); + int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class)). + invokeExact((int[]) null, 0, 1, 1); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class, int.class)). - invoke(Void.class, 0, 1, 1); + invokeExact(Void.class, 0, 1, 1); }); checkWMTE(() -> { // expected reference class int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class, int.class)). - invoke(array, 0, Void.class, 1); + invokeExact(array, 0, Void.class, 1); }); checkWMTE(() -> { // actual reference class int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)). - invoke(array, 0, 1, Void.class); + invokeExact(array, 0, 1, Void.class); }); checkWMTE(() -> { // array primitive class int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class, int.class)). - invoke(0, 0, 1, 1); + invokeExact(0, 0, 1, 1); }); checkWMTE(() -> { // index reference class int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class, int.class)). - invoke(array, Void.class, 1, 1); + invokeExact(array, Void.class, 1, 1); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class, int.class)). - invoke(array, 0, 1, 1); + invokeExact(array, 0, 1, 1); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class, int.class)). - invoke(array, 0, 1, 1); + invokeExact(array, 0, 1, 1); }); // Incorrect arity checkWMTE(() -> { // 0 int x = (int) hs.get(am, methodType(int.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, int.class, Class.class)). - invoke(array, 0, 1, 1, Void.class); + invokeExact(array, 0, 1, 1, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null array - int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)). - invoke(null, 0, 1); + int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)). + invokeExact((int[]) null, 0, 1); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)). - invoke(Void.class, 0, 1); + invokeExact(Void.class, 0, 1); }); checkWMTE(() -> { // value reference class int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)). - invoke(0, 0, 1); + invokeExact(0, 0, 1); }); checkWMTE(() -> { // index reference class int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)). - invoke(array, Void.class, 1); + invokeExact(array, Void.class, 1); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)). - invoke(array, 0, 1); + invokeExact(array, 0, 1); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)). - invoke(array, 0, 1); + invokeExact(array, 0, 1); }); // Incorrect arity checkWMTE(() -> { // 0 int x = (int) hs.get(am, methodType(int.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)). - invoke(array, 0, 1, Void.class); + invokeExact(array, 0, 1, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { // Incorrect argument types checkNPE(() -> { // null array - int x = (int) hs.get(am, methodType(int.class, Void.class, int.class, int.class)). - invoke(null, 0, 1); + int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class)). + invokeExact((int[]) null, 0, 1); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class int x = (int) hs.get(am, methodType(int.class, Class.class, int.class, int.class)). - invoke(Void.class, 0, 1); + invokeExact(Void.class, 0, 1); }); checkWMTE(() -> { // value reference class int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class int x = (int) hs.get(am, methodType(int.class, int.class, int.class, int.class)). - invoke(0, 0, 1); + invokeExact(0, 0, 1); }); checkWMTE(() -> { // index reference class int x = (int) hs.get(am, methodType(int.class, int[].class, Class.class, int.class)). - invoke(array, Void.class, 1); + invokeExact(array, Void.class, 1); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, int[].class, int.class, int.class)). - invoke(array, 0, 1); + invokeExact(array, 0, 1); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, int[].class, int.class, int.class)). - invoke(array, 0, 1); + invokeExact(array, 0, 1); }); // Incorrect arity checkWMTE(() -> { // 0 int x = (int) hs.get(am, methodType(int.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > int x = (int) hs.get(am, methodType(int.class, int[].class, int.class, int.class, Class.class)). - invoke(array, 0, 1, Void.class); + invokeExact(array, 0, 1, Void.class); }); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java index 44151683133..0972e663cc7 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8156486 * @run testng/othervm VarHandleTestMethodTypeLong * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeLong */ @@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { public Object[][] accessTestCaseProvider() throws Exception { List> cases = new ArrayList<>(); - cases.add(new VarHandleAccessTestCase("Instance field wrong method type", + cases.add(new VarHandleAccessTestCase("Instance field", vhField, vh -> testInstanceFieldWrongMethodType(this, vh), false)); - cases.add(new VarHandleAccessTestCase("Static field wrong method type", + cases.add(new VarHandleAccessTestCase("Static field", vhStaticField, VarHandleTestMethodTypeLong::testStaticFieldWrongMethodType, false)); - cases.add(new VarHandleAccessTestCase("Array wrong method type", + cases.add(new VarHandleAccessTestCase("Array", vhArray, VarHandleTestMethodTypeLong::testArrayWrongMethodType, false)); + for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { - cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", + cases.add(new MethodHandleAccessTestCase("Instance field", vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), false)); - cases.add(new MethodHandleAccessTestCase("Static field wrong method type", + cases.add(new MethodHandleAccessTestCase("Static field", vhStaticField, f, VarHandleTestMethodTypeLong::testStaticFieldWrongMethodType, false)); - cases.add(new MethodHandleAccessTestCase("Array wrong method type", + cases.add(new MethodHandleAccessTestCase("Array", vhArray, f, VarHandleTestMethodTypeLong::testArrayWrongMethodType, false)); } @@ -644,211 +646,211 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null receiver - long x = (long) hs.get(am, methodType(long.class, Void.class)). - invoke(null); + long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class)). + invokeExact((VarHandleTestMethodTypeLong) null); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class long x = (long) hs.get(am, methodType(long.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); checkWMTE(() -> { // receiver primitive class long x = (long) hs.get(am, methodType(long.class, int.class)). - invoke(0); + invokeExact(0); }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class)). - invoke(recv); + Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class)). + invokeExact(recv); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class)). - invoke(recv); + invokeExact(recv); }); // Incorrect arity checkWMTE(() -> { // 0 long x = (long) hs.get(am, methodType(long.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - hs.get(am, methodType(void.class, Void.class, long.class)). - invoke(null, 1L); + hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, long.class)). + invokeExact((VarHandleTestMethodTypeLong) null, 1L); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class hs.get(am, methodType(void.class, Class.class, long.class)). - invoke(Void.class, 1L); + invokeExact(Void.class, 1L); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, long.class)). - invoke(0, 1L); + invokeExact(0, 1L); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)). - invoke(recv, 1L, Void.class); + invokeExact(recv, 1L, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, long.class, long.class)). - invoke(null, 1L, 1L); + boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, long.class)). + invokeExact((VarHandleTestMethodTypeLong) null, 1L, 1L); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class, long.class)). - invoke(Void.class, 1L, 1L); + invokeExact(Void.class, 1L, 1L); }); checkWMTE(() -> { // expected reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, Class.class, long.class)). - invoke(recv, Void.class, 1L); + invokeExact(recv, Void.class, 1L); }); checkWMTE(() -> { // actual reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)). - invoke(recv, 1L, Void.class); + invokeExact(recv, 1L, Void.class); }); checkWMTE(() -> { // receiver primitive class boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , long.class, long.class)). - invoke(0, 1L, 1L); + invokeExact(0, 1L, 1L); }); // Incorrect arity checkWMTE(() -> { // 0 boolean r = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class, long.class, Class.class)). - invoke(recv, 1L, 1L, Void.class); + invokeExact(recv, 1L, 1L, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { checkNPE(() -> { // null receiver - long x = (long) hs.get(am, methodType(long.class, Void.class, long.class, long.class)). - invoke(null, 1L, 1L); + long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, long.class)). + invokeExact((VarHandleTestMethodTypeLong) null, 1L, 1L); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class long x = (long) hs.get(am, methodType(long.class, Class.class, long.class, long.class)). - invoke(Void.class, 1L, 1L); + invokeExact(Void.class, 1L, 1L); }); checkWMTE(() -> { // expected reference class long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class, long.class)). - invoke(recv, Void.class, 1L); + invokeExact(recv, Void.class, 1L); }); checkWMTE(() -> { // actual reference class long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, Class.class)). - invoke(recv, 1L, Void.class); + invokeExact(recv, 1L, Void.class); }); checkWMTE(() -> { // reciever primitive class long x = (long) hs.get(am, methodType(long.class, int.class , long.class, long.class)). - invoke(0, 1L, 1L); + invokeExact(0, 1L, 1L); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class , long.class, long.class)). - invoke(recv, 1L, 1L); + invokeExact(recv, 1L, 1L); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class , long.class, long.class)). - invoke(recv, 1L, 1L); + invokeExact(recv, 1L, 1L); }); // Incorrect arity checkWMTE(() -> { // 0 long x = (long) hs.get(am, methodType(long.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class, long.class, Class.class)). - invoke(recv, 1L, 1L, Void.class); + invokeExact(recv, 1L, 1L, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { checkNPE(() -> { // null receiver - long x = (long) hs.get(am, methodType(long.class, Void.class, long.class)). - invoke(null, 1L); + long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)). + invokeExact((VarHandleTestMethodTypeLong) null, 1L); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)). - invoke(Void.class, 1L); + invokeExact(Void.class, 1L); }); checkWMTE(() -> { // value reference class long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class long x = (long) hs.get(am, methodType(long.class, int.class, long.class)). - invoke(0, 1L); + invokeExact(0, 1L); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)). - invoke(recv, 1L); + invokeExact(recv, 1L); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)). - invoke(recv, 1L); + invokeExact(recv, 1L); }); // Incorrect arity checkWMTE(() -> { // 0 long x = (long) hs.get(am, methodType(long.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)). - invoke(recv, 1L, Void.class); + invokeExact(recv, 1L, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { checkNPE(() -> { // null receiver - long x = (long) hs.get(am, methodType(long.class, Void.class, long.class)). - invoke(null, 1L); + long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)). + invokeExact((VarHandleTestMethodTypeLong) null, 1L); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)). - invoke(Void.class, 1L); + invokeExact(Void.class, 1L); }); checkWMTE(() -> { // value reference class long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class long x = (long) hs.get(am, methodType(long.class, int.class, long.class)). - invoke(0, 1L); + invokeExact(0, 1L); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeLong.class, long.class)). - invoke(recv, 1L); + invokeExact(recv, 1L); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeLong.class, long.class)). - invoke(recv, 1L); + invokeExact(recv, 1L); }); // Incorrect arity checkWMTE(() -> { // 0 long x = (long) hs.get(am, methodType(long.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > long x = (long) hs.get(am, methodType(long.class, VarHandleTestMethodTypeLong.class, long.class)). - invoke(recv, 1L, Void.class); + invokeExact(recv, 1L, Void.class); }); } } @@ -1190,52 +1192,52 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); // Incorrect arity checkWMTE(() -> { // > long x = (long) hs.get(am, methodType(Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, long.class, Class.class)). - invoke(1L, Void.class); + invokeExact(1L, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types checkWMTE(() -> { // expected reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, long.class)). - invoke(Void.class, 1L); + invokeExact(Void.class, 1L); }); checkWMTE(() -> { // actual reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, long.class, Class.class)). - invoke(1L, Void.class); + invokeExact(1L, Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 boolean r = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean r = (boolean) hs.get(am, methodType(boolean.class, long.class, long.class, Class.class)). - invoke(1L, 1L, Void.class); + invokeExact(1L, 1L, Void.class); }); } @@ -1243,29 +1245,29 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { // Incorrect argument types checkWMTE(() -> { // expected reference class long x = (long) hs.get(am, methodType(long.class, Class.class, long.class)). - invoke(Void.class, 1L); + invokeExact(Void.class, 1L); }); checkWMTE(() -> { // actual reference class long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)). - invoke(1L, Void.class); + invokeExact(1L, Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, long.class, long.class)). - invoke(1L, 1L); + invokeExact(1L, 1L); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class, long.class)). - invoke(1L, 1L); + invokeExact(1L, 1L); }); // Incorrect arity checkWMTE(() -> { // 0 long x = (long) hs.get(am, methodType(long.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > long x = (long) hs.get(am, methodType(long.class, long.class, long.class, Class.class)). - invoke(1L, 1L, Void.class); + invokeExact(1L, 1L, Void.class); }); } @@ -1273,25 +1275,25 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { // Incorrect argument types checkWMTE(() -> { // value reference class long x = (long) hs.get(am, methodType(long.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, long.class)). - invoke(1L); + invokeExact(1L); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)). - invoke(1L); + invokeExact(1L); }); // Incorrect arity checkWMTE(() -> { // 0 long x = (long) hs.get(am, methodType(long.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)). - invoke(1L, Void.class); + invokeExact(1L, Void.class); }); } @@ -1299,25 +1301,25 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { // Incorrect argument types checkWMTE(() -> { // value reference class long x = (long) hs.get(am, methodType(long.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, long.class)). - invoke(1L); + invokeExact(1L); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, long.class)). - invoke(1L); + invokeExact(1L); }); // Incorrect arity checkWMTE(() -> { // 0 long x = (long) hs.get(am, methodType(long.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > long x = (long) hs.get(am, methodType(long.class, long.class, Class.class)). - invoke(1L, Void.class); + invokeExact(1L, Void.class); }); } } @@ -1909,237 +1911,237 @@ public class VarHandleTestMethodTypeLong extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null array - long x = (long) hs.get(am, methodType(long.class, Void.class, int.class)). - invoke(null, 0); + long x = (long) hs.get(am, methodType(long.class, long[].class, int.class)). + invokeExact((long[]) null, 0); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class long x = (long) hs.get(am, methodType(long.class, Class.class, int.class)). - invoke(Void.class, 0); + invokeExact(Void.class, 0); }); checkWMTE(() -> { // array primitive class long x = (long) hs.get(am, methodType(long.class, int.class, int.class)). - invoke(0, 0); + invokeExact(0, 0); }); checkWMTE(() -> { // index reference class long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class)). - invoke(array, Void.class); + invokeExact(array, Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class, long[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); // Incorrect arity checkWMTE(() -> { // 0 long x = (long) hs.get(am, methodType(long.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null array - hs.get(am, methodType(void.class, Void.class, int.class, long.class)). - invoke(null, 0, 1L); + hs.get(am, methodType(void.class, long[].class, int.class, long.class)). + invokeExact((long[]) null, 0, 1L); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class hs.get(am, methodType(void.class, Class.class, int.class, long.class)). - invoke(Void.class, 0, 1L); + invokeExact(Void.class, 0, 1L); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, long[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, int.class, long.class)). - invoke(0, 0, 1L); + invokeExact(0, 0, 1L); }); checkWMTE(() -> { // index reference class hs.get(am, methodType(void.class, long[].class, Class.class, long.class)). - invoke(array, Void.class, 1L); + invokeExact(array, Void.class, 1L); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, long[].class, int.class, Class.class)). - invoke(array, 0, 1L, Void.class); + invokeExact(array, 0, 1L, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, long.class, long.class)). - invoke(null, 0, 1L, 1L); + boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class)). + invokeExact((long[]) null, 0, 1L, 1L); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, long.class, long.class)). - invoke(Void.class, 0, 1L, 1L); + invokeExact(Void.class, 0, 1L, 1L); }); checkWMTE(() -> { // expected reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, Class.class, long.class)). - invoke(array, 0, Void.class, 1L); + invokeExact(array, 0, Void.class, 1L); }); checkWMTE(() -> { // actual reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, Class.class)). - invoke(array, 0, 1L, Void.class); + invokeExact(array, 0, 1L, Void.class); }); checkWMTE(() -> { // receiver primitive class boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, long.class, long.class)). - invoke(0, 0, 1L, 1L); + invokeExact(0, 0, 1L, 1L); }); checkWMTE(() -> { // index reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, Class.class, long.class, long.class)). - invoke(array, Void.class, 1L, 1L); + invokeExact(array, Void.class, 1L, 1L); }); // Incorrect arity checkWMTE(() -> { // 0 boolean r = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean r = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class, Class.class)). - invoke(array, 0, 1L, 1L, Void.class); + invokeExact(array, 0, 1L, 1L, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { // Incorrect argument types checkNPE(() -> { // null receiver - long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class, long.class)). - invoke(null, 0, 1L, 1L); + long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, long.class)). + invokeExact((long[]) null, 0, 1L, 1L); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class, long.class)). - invoke(Void.class, 0, 1L, 1L); + invokeExact(Void.class, 0, 1L, 1L); }); checkWMTE(() -> { // expected reference class long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class, long.class)). - invoke(array, 0, Void.class, 1L); + invokeExact(array, 0, Void.class, 1L); }); checkWMTE(() -> { // actual reference class long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)). - invoke(array, 0, 1L, Void.class); + invokeExact(array, 0, 1L, Void.class); }); checkWMTE(() -> { // array primitive class long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class, long.class)). - invoke(0, 0, 1L, 1L); + invokeExact(0, 0, 1L, 1L); }); checkWMTE(() -> { // index reference class long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class, long.class)). - invoke(array, Void.class, 1L, 1L); + invokeExact(array, Void.class, 1L, 1L); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class, long.class)). - invoke(array, 0, 1L, 1L); + invokeExact(array, 0, 1L, 1L); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class, long.class)). - invoke(array, 0, 1L, 1L); + invokeExact(array, 0, 1L, 1L); }); // Incorrect arity checkWMTE(() -> { // 0 long x = (long) hs.get(am, methodType(long.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, long.class, Class.class)). - invoke(array, 0, 1L, 1L, Void.class); + invokeExact(array, 0, 1L, 1L, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null array - long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class)). - invoke(null, 0, 1L); + long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class)). + invokeExact((long[]) null, 0, 1L); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)). - invoke(Void.class, 0, 1L); + invokeExact(Void.class, 0, 1L); }); checkWMTE(() -> { // value reference class long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)). - invoke(0, 0, 1L); + invokeExact(0, 0, 1L); }); checkWMTE(() -> { // index reference class long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)). - invoke(array, Void.class, 1L); + invokeExact(array, Void.class, 1L); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)). - invoke(array, 0, 1L); + invokeExact(array, 0, 1L); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)). - invoke(array, 0, 1L); + invokeExact(array, 0, 1L); }); // Incorrect arity checkWMTE(() -> { // 0 long x = (long) hs.get(am, methodType(long.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)). - invoke(array, 0, 1L, Void.class); + invokeExact(array, 0, 1L, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { // Incorrect argument types checkNPE(() -> { // null array - long x = (long) hs.get(am, methodType(long.class, Void.class, int.class, long.class)). - invoke(null, 0, 1L); + long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class)). + invokeExact((long[]) null, 0, 1L); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class long x = (long) hs.get(am, methodType(long.class, Class.class, int.class, long.class)). - invoke(Void.class, 0, 1L); + invokeExact(Void.class, 0, 1L); }); checkWMTE(() -> { // value reference class long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class long x = (long) hs.get(am, methodType(long.class, int.class, int.class, long.class)). - invoke(0, 0, 1L); + invokeExact(0, 0, 1L); }); checkWMTE(() -> { // index reference class long x = (long) hs.get(am, methodType(long.class, long[].class, Class.class, long.class)). - invoke(array, Void.class, 1L); + invokeExact(array, Void.class, 1L); }); // Incorrect return type checkWMTE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, long[].class, int.class, long.class)). - invoke(array, 0, 1L); + invokeExact(array, 0, 1L); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, long[].class, int.class, long.class)). - invoke(array, 0, 1L); + invokeExact(array, 0, 1L); }); // Incorrect arity checkWMTE(() -> { // 0 long x = (long) hs.get(am, methodType(long.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > long x = (long) hs.get(am, methodType(long.class, long[].class, int.class, long.class, Class.class)). - invoke(array, 0, 1L, Void.class); + invokeExact(array, 0, 1L, Void.class); }); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java index 634646e78c1..16efabe0917 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8156486 * @run testng/othervm VarHandleTestMethodTypeShort * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeShort */ @@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { public Object[][] accessTestCaseProvider() throws Exception { List> cases = new ArrayList<>(); - cases.add(new VarHandleAccessTestCase("Instance field wrong method type", + cases.add(new VarHandleAccessTestCase("Instance field", vhField, vh -> testInstanceFieldWrongMethodType(this, vh), false)); - cases.add(new VarHandleAccessTestCase("Static field wrong method type", + cases.add(new VarHandleAccessTestCase("Static field", vhStaticField, VarHandleTestMethodTypeShort::testStaticFieldWrongMethodType, false)); - cases.add(new VarHandleAccessTestCase("Array wrong method type", + cases.add(new VarHandleAccessTestCase("Array", vhArray, VarHandleTestMethodTypeShort::testArrayWrongMethodType, false)); + for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { - cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", + cases.add(new MethodHandleAccessTestCase("Instance field", vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), false)); - cases.add(new MethodHandleAccessTestCase("Static field wrong method type", + cases.add(new MethodHandleAccessTestCase("Static field", vhStaticField, f, VarHandleTestMethodTypeShort::testStaticFieldWrongMethodType, false)); - cases.add(new MethodHandleAccessTestCase("Array wrong method type", + cases.add(new MethodHandleAccessTestCase("Array", vhArray, f, VarHandleTestMethodTypeShort::testArrayWrongMethodType, false)); } @@ -329,63 +331,63 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null receiver - short x = (short) hs.get(am, methodType(short.class, Void.class)). - invoke(null); + short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class)). + invokeExact((VarHandleTestMethodTypeShort) null); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class short x = (short) hs.get(am, methodType(short.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); checkWMTE(() -> { // receiver primitive class short x = (short) hs.get(am, methodType(short.class, int.class)). - invoke(0); + invokeExact(0); }); // Incorrect return type checkWMTE(() -> { // reference class - Void x = (Void) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class)). - invoke(recv); + Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeShort.class)). + invokeExact(recv); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeShort.class)). - invoke(recv); + invokeExact(recv); }); // Incorrect arity checkWMTE(() -> { // 0 short x = (short) hs.get(am, methodType(short.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > short x = (short) hs.get(am, methodType(short.class, VarHandleTestMethodTypeShort.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - hs.get(am, methodType(void.class, Void.class, short.class)). - invoke(null, (short)1); + hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, short.class)). + invokeExact((VarHandleTestMethodTypeShort) null, (short)1); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class hs.get(am, methodType(void.class, Class.class, short.class)). - invoke(Void.class, (short)1); + invokeExact(Void.class, (short)1); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, short.class)). - invoke(0, (short)1); + invokeExact(0, (short)1); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, VarHandleTestMethodTypeShort.class, short.class, Class.class)). - invoke(recv, (short)1, Void.class); + invokeExact(recv, (short)1, Void.class); }); } @@ -513,32 +515,32 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); // Incorrect arity checkWMTE(() -> { // > short x = (short) hs.get(am, methodType(Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, short.class, Class.class)). - invoke((short)1, Void.class); + invokeExact((short)1, Void.class); }); } @@ -783,71 +785,71 @@ public class VarHandleTestMethodTypeShort extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null array - short x = (short) hs.get(am, methodType(short.class, Void.class, int.class)). - invoke(null, 0); + short x = (short) hs.get(am, methodType(short.class, short[].class, int.class)). + invokeExact((short[]) null, 0); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class short x = (short) hs.get(am, methodType(short.class, Class.class, int.class)). - invoke(Void.class, 0); + invokeExact(Void.class, 0); }); checkWMTE(() -> { // array primitive class short x = (short) hs.get(am, methodType(short.class, int.class, int.class)). - invoke(0, 0); + invokeExact(0, 0); }); checkWMTE(() -> { // index reference class short x = (short) hs.get(am, methodType(short.class, short[].class, Class.class)). - invoke(array, Void.class); + invokeExact(array, Void.class); }); // Incorrect return type checkWMTE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class, short[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, short[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); // Incorrect arity checkWMTE(() -> { // 0 short x = (short) hs.get(am, methodType(short.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > short x = (short) hs.get(am, methodType(short.class, short[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null array - hs.get(am, methodType(void.class, Void.class, int.class, short.class)). - invoke(null, 0, (short)1); + hs.get(am, methodType(void.class, short[].class, int.class, short.class)). + invokeExact((short[]) null, 0, (short)1); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class hs.get(am, methodType(void.class, Class.class, int.class, short.class)). - invoke(Void.class, 0, (short)1); + invokeExact(Void.class, 0, (short)1); }); checkWMTE(() -> { // value reference class hs.get(am, methodType(void.class, short[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, int.class, short.class)). - invoke(0, 0, (short)1); + invokeExact(0, 0, (short)1); }); checkWMTE(() -> { // index reference class hs.get(am, methodType(void.class, short[].class, Class.class, short.class)). - invoke(array, Void.class, (short)1); + invokeExact(array, Void.class, (short)1); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, short[].class, int.class, Class.class)). - invoke(array, 0, (short)1, Void.class); + invokeExact(array, 0, (short)1, Void.class); }); } diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java index f3b58c9e2f9..2cc853349ce 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8156486 * @run testng/othervm VarHandleTestMethodTypeString * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodTypeString */ @@ -81,27 +82,28 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { public Object[][] accessTestCaseProvider() throws Exception { List> cases = new ArrayList<>(); - cases.add(new VarHandleAccessTestCase("Instance field wrong method type", + cases.add(new VarHandleAccessTestCase("Instance field", vhField, vh -> testInstanceFieldWrongMethodType(this, vh), false)); - cases.add(new VarHandleAccessTestCase("Static field wrong method type", + cases.add(new VarHandleAccessTestCase("Static field", vhStaticField, VarHandleTestMethodTypeString::testStaticFieldWrongMethodType, false)); - cases.add(new VarHandleAccessTestCase("Array wrong method type", + cases.add(new VarHandleAccessTestCase("Array", vhArray, VarHandleTestMethodTypeString::testArrayWrongMethodType, false)); + for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { - cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", + cases.add(new MethodHandleAccessTestCase("Instance field", vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), false)); - cases.add(new MethodHandleAccessTestCase("Static field wrong method type", + cases.add(new MethodHandleAccessTestCase("Static field", vhStaticField, f, VarHandleTestMethodTypeString::testStaticFieldWrongMethodType, false)); - cases.add(new MethodHandleAccessTestCase("Array wrong method type", + cases.add(new MethodHandleAccessTestCase("Array", vhArray, f, VarHandleTestMethodTypeString::testArrayWrongMethodType, false)); } @@ -586,174 +588,174 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null receiver - String x = (String) hs.get(am, methodType(String.class, Void.class)). - invoke(null); + String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class)). + invokeExact((VarHandleTestMethodTypeString) null); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class String x = (String) hs.get(am, methodType(String.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); checkWMTE(() -> { // receiver primitive class String x = (String) hs.get(am, methodType(String.class, int.class)). - invoke(0); + invokeExact(0); }); // Incorrect return type - checkCCE(() -> { // reference class - Void x = (Void) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class)). - invoke(recv); + hs.checkWMTEOrCCE(() -> { // reference class + Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class)). + invokeExact(recv); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class)). - invoke(recv); + invokeExact(recv); }); // Incorrect arity checkWMTE(() -> { // 0 String x = (String) hs.get(am, methodType(String.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - hs.get(am, methodType(void.class, Void.class, String.class)). - invoke(null, "foo"); + hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, String.class)). + invokeExact((VarHandleTestMethodTypeString) null, "foo"); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class hs.get(am, methodType(void.class, Class.class, String.class)). - invoke(Void.class, "foo"); + invokeExact(Void.class, "foo"); }); - checkCCE(() -> { // value reference class + hs.checkWMTEOrCCE(() -> { // value reference class hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, String.class)). - invoke(0, "foo"); + invokeExact(0, "foo"); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, VarHandleTestMethodTypeString.class, String.class, Class.class)). - invoke(recv, "foo", Void.class); + invokeExact(recv, "foo", Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, String.class, String.class)). - invoke(null, "foo", "foo"); + boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, String.class)). + invokeExact((VarHandleTestMethodTypeString) null, "foo", "foo"); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, String.class, String.class)). - invoke(Void.class, "foo", "foo"); + invokeExact(Void.class, "foo", "foo"); }); - checkCCE(() -> { // expected reference class + hs.checkWMTEOrCCE(() -> { // expected reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, Class.class, String.class)). - invoke(recv, Void.class, "foo"); + invokeExact(recv, Void.class, "foo"); }); - checkCCE(() -> { // actual reference class + hs.checkWMTEOrCCE(() -> { // actual reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, Class.class)). - invoke(recv, "foo", Void.class); + invokeExact(recv, "foo", Void.class); }); checkWMTE(() -> { // receiver primitive class boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , String.class, String.class)). - invoke(0, "foo", "foo"); + invokeExact(0, "foo", "foo"); }); // Incorrect arity checkWMTE(() -> { // 0 boolean r = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class, String.class, Class.class)). - invoke(recv, "foo", "foo", Void.class); + invokeExact(recv, "foo", "foo", Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { checkNPE(() -> { // null receiver - String x = (String) hs.get(am, methodType(String.class, Void.class, String.class, String.class)). - invoke(null, "foo", "foo"); + String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, String.class)). + invokeExact((VarHandleTestMethodTypeString) null, "foo", "foo"); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class String x = (String) hs.get(am, methodType(String.class, Class.class, String.class, String.class)). - invoke(Void.class, "foo", "foo"); + invokeExact(Void.class, "foo", "foo"); }); - checkCCE(() -> { // expected reference class + hs.checkWMTEOrCCE(() -> { // expected reference class String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class, String.class)). - invoke(recv, Void.class, "foo"); + invokeExact(recv, Void.class, "foo"); }); - checkCCE(() -> { // actual reference class + hs.checkWMTEOrCCE(() -> { // actual reference class String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, Class.class)). - invoke(recv, "foo", Void.class); + invokeExact(recv, "foo", Void.class); }); checkWMTE(() -> { // reciever primitive class String x = (String) hs.get(am, methodType(String.class, int.class , String.class, String.class)). - invoke(0, "foo", "foo"); + invokeExact(0, "foo", "foo"); }); // Incorrect return type - checkCCE(() -> { // reference class + hs.checkWMTEOrCCE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class , String.class, String.class)). - invoke(recv, "foo", "foo"); + invokeExact(recv, "foo", "foo"); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class , String.class, String.class)). - invoke(recv, "foo", "foo"); + invokeExact(recv, "foo", "foo"); }); // Incorrect arity checkWMTE(() -> { // 0 String x = (String) hs.get(am, methodType(String.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class, String.class, Class.class)). - invoke(recv, "foo", "foo", Void.class); + invokeExact(recv, "foo", "foo", Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { checkNPE(() -> { // null receiver - String x = (String) hs.get(am, methodType(String.class, Void.class, String.class)). - invoke(null, "foo"); + String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class)). + invokeExact((VarHandleTestMethodTypeString) null, "foo"); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class String x = (String) hs.get(am, methodType(String.class, Class.class, String.class)). - invoke(Void.class, "foo"); + invokeExact(Void.class, "foo"); }); - checkCCE(() -> { // value reference class + hs.checkWMTEOrCCE(() -> { // value reference class String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class String x = (String) hs.get(am, methodType(String.class, int.class, String.class)). - invoke(0, "foo"); + invokeExact(0, "foo"); }); // Incorrect return type - checkCCE(() -> { // reference class + hs.checkWMTEOrCCE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodTypeString.class, String.class)). - invoke(recv, "foo"); + invokeExact(recv, "foo"); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodTypeString.class, String.class)). - invoke(recv, "foo"); + invokeExact(recv, "foo"); }); // Incorrect arity checkWMTE(() -> { // 0 String x = (String) hs.get(am, methodType(String.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > String x = (String) hs.get(am, methodType(String.class, VarHandleTestMethodTypeString.class, String.class)). - invoke(recv, "foo", Void.class); + invokeExact(recv, "foo", Void.class); }); } @@ -1054,110 +1056,110 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect return type - checkCCE(() -> { // reference class + hs.checkWMTEOrCCE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); // Incorrect arity checkWMTE(() -> { // > String x = (String) hs.get(am, methodType(Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { - checkCCE(() -> { // value reference class + hs.checkWMTEOrCCE(() -> { // value reference class hs.get(am, methodType(void.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, String.class, Class.class)). - invoke("foo", Void.class); + invokeExact("foo", Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types - checkCCE(() -> { // expected reference class + hs.checkWMTEOrCCE(() -> { // expected reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, String.class)). - invoke(Void.class, "foo"); + invokeExact(Void.class, "foo"); }); - checkCCE(() -> { // actual reference class + hs.checkWMTEOrCCE(() -> { // actual reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, String.class, Class.class)). - invoke("foo", Void.class); + invokeExact("foo", Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 boolean r = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean r = (boolean) hs.get(am, methodType(boolean.class, String.class, String.class, Class.class)). - invoke("foo", "foo", Void.class); + invokeExact("foo", "foo", Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { // Incorrect argument types - checkCCE(() -> { // expected reference class + hs.checkWMTEOrCCE(() -> { // expected reference class String x = (String) hs.get(am, methodType(String.class, Class.class, String.class)). - invoke(Void.class, "foo"); + invokeExact(Void.class, "foo"); }); - checkCCE(() -> { // actual reference class + hs.checkWMTEOrCCE(() -> { // actual reference class String x = (String) hs.get(am, methodType(String.class, String.class, Class.class)). - invoke("foo", Void.class); + invokeExact("foo", Void.class); }); // Incorrect return type - checkCCE(() -> { // reference class + hs.checkWMTEOrCCE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, String.class, String.class)). - invoke("foo", "foo"); + invokeExact("foo", "foo"); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, String.class, String.class)). - invoke("foo", "foo"); + invokeExact("foo", "foo"); }); // Incorrect arity checkWMTE(() -> { // 0 String x = (String) hs.get(am, methodType(String.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > String x = (String) hs.get(am, methodType(String.class, String.class, String.class, Class.class)). - invoke("foo", "foo", Void.class); + invokeExact("foo", "foo", Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { // Incorrect argument types - checkCCE(() -> { // value reference class + hs.checkWMTEOrCCE(() -> { // value reference class String x = (String) hs.get(am, methodType(String.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect return type - checkCCE(() -> { // reference class + hs.checkWMTEOrCCE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, String.class)). - invoke("foo"); + invokeExact("foo"); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, String.class)). - invoke("foo"); + invokeExact("foo"); }); // Incorrect arity checkWMTE(() -> { // 0 String x = (String) hs.get(am, methodType(String.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > String x = (String) hs.get(am, methodType(String.class, String.class, Class.class)). - invoke("foo", Void.class); + invokeExact("foo", Void.class); }); } @@ -1686,195 +1688,195 @@ public class VarHandleTestMethodTypeString extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null array - String x = (String) hs.get(am, methodType(String.class, Void.class, int.class)). - invoke(null, 0); + String x = (String) hs.get(am, methodType(String.class, String[].class, int.class)). + invokeExact((String[]) null, 0); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class String x = (String) hs.get(am, methodType(String.class, Class.class, int.class)). - invoke(Void.class, 0); + invokeExact(Void.class, 0); }); checkWMTE(() -> { // array primitive class String x = (String) hs.get(am, methodType(String.class, int.class, int.class)). - invoke(0, 0); + invokeExact(0, 0); }); checkWMTE(() -> { // index reference class String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class)). - invoke(array, Void.class); + invokeExact(array, Void.class); }); // Incorrect return type - checkCCE(() -> { // reference class + hs.checkWMTEOrCCE(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class, String[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); // Incorrect arity checkWMTE(() -> { // 0 String x = (String) hs.get(am, methodType(String.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null array - hs.get(am, methodType(void.class, Void.class, int.class, String.class)). - invoke(null, 0, "foo"); + hs.get(am, methodType(void.class, String[].class, int.class, String.class)). + invokeExact((String[]) null, 0, "foo"); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class hs.get(am, methodType(void.class, Class.class, int.class, String.class)). - invoke(Void.class, 0, "foo"); + invokeExact(Void.class, 0, "foo"); }); - checkCCE(() -> { // value reference class + hs.checkWMTEOrCCE(() -> { // value reference class hs.get(am, methodType(void.class, String[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, int.class, String.class)). - invoke(0, 0, "foo"); + invokeExact(0, 0, "foo"); }); checkWMTE(() -> { // index reference class hs.get(am, methodType(void.class, String[].class, Class.class, String.class)). - invoke(array, Void.class, "foo"); + invokeExact(array, Void.class, "foo"); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, String[].class, int.class, Class.class)). - invoke(array, 0, "foo", Void.class); + invokeExact(array, 0, "foo", Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, String.class, String.class)). - invoke(null, 0, "foo", "foo"); + boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class)). + invokeExact((String[]) null, 0, "foo", "foo"); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, String.class, String.class)). - invoke(Void.class, 0, "foo", "foo"); + invokeExact(Void.class, 0, "foo", "foo"); }); - checkCCE(() -> { // expected reference class + hs.checkWMTEOrCCE(() -> { // expected reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, Class.class, String.class)). - invoke(array, 0, Void.class, "foo"); + invokeExact(array, 0, Void.class, "foo"); }); - checkCCE(() -> { // actual reference class + hs.checkWMTEOrCCE(() -> { // actual reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, Class.class)). - invoke(array, 0, "foo", Void.class); + invokeExact(array, 0, "foo", Void.class); }); checkWMTE(() -> { // receiver primitive class boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, String.class, String.class)). - invoke(0, 0, "foo", "foo"); + invokeExact(0, 0, "foo", "foo"); }); checkWMTE(() -> { // index reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, Class.class, String.class, String.class)). - invoke(array, Void.class, "foo", "foo"); + invokeExact(array, Void.class, "foo", "foo"); }); // Incorrect arity checkWMTE(() -> { // 0 boolean r = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean r = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class, Class.class)). - invoke(array, 0, "foo", "foo", Void.class); + invokeExact(array, 0, "foo", "foo", Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { // Incorrect argument types checkNPE(() -> { // null receiver - String x = (String) hs.get(am, methodType(String.class, Void.class, int.class, String.class, String.class)). - invoke(null, 0, "foo", "foo"); + String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, String.class)). + invokeExact((String[]) null, 0, "foo", "foo"); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class String x = (String) hs.get(am, methodType(String.class, Class.class, int.class, String.class, String.class)). - invoke(Void.class, 0, "foo", "foo"); + invokeExact(Void.class, 0, "foo", "foo"); }); - checkCCE(() -> { // expected reference class + hs.checkWMTEOrCCE(() -> { // expected reference class String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class, String.class)). - invoke(array, 0, Void.class, "foo"); + invokeExact(array, 0, Void.class, "foo"); }); - checkCCE(() -> { // actual reference class + hs.checkWMTEOrCCE(() -> { // actual reference class String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, Class.class)). - invoke(array, 0, "foo", Void.class); + invokeExact(array, 0, "foo", Void.class); }); checkWMTE(() -> { // array primitive class String x = (String) hs.get(am, methodType(String.class, int.class, int.class, String.class, String.class)). - invoke(0, 0, "foo", "foo"); + invokeExact(0, 0, "foo", "foo"); }); checkWMTE(() -> { // index reference class String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class, String.class, String.class)). - invoke(array, Void.class, "foo", "foo"); + invokeExact(array, Void.class, "foo", "foo"); }); // Incorrect return type - checkCCE(() -> { // reference class + hs.checkWMTEOrCCE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, String[].class, int.class, String.class, String.class)). - invoke(array, 0, "foo", "foo"); + invokeExact(array, 0, "foo", "foo"); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class, String.class)). - invoke(array, 0, "foo", "foo"); + invokeExact(array, 0, "foo", "foo"); }); // Incorrect arity checkWMTE(() -> { // 0 String x = (String) hs.get(am, methodType(String.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, String.class, Class.class)). - invoke(array, 0, "foo", "foo", Void.class); + invokeExact(array, 0, "foo", "foo", Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null array - String x = (String) hs.get(am, methodType(String.class, Void.class, int.class, String.class)). - invoke(null, 0, "foo"); + String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class)). + invokeExact((String[]) null, 0, "foo"); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class String x = (String) hs.get(am, methodType(String.class, Class.class, int.class, String.class)). - invoke(Void.class, 0, "foo"); + invokeExact(Void.class, 0, "foo"); }); - checkCCE(() -> { // value reference class + hs.checkWMTEOrCCE(() -> { // value reference class String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class String x = (String) hs.get(am, methodType(String.class, int.class, int.class, String.class)). - invoke(0, 0, "foo"); + invokeExact(0, 0, "foo"); }); checkWMTE(() -> { // index reference class String x = (String) hs.get(am, methodType(String.class, String[].class, Class.class, String.class)). - invoke(array, Void.class, "foo"); + invokeExact(array, Void.class, "foo"); }); // Incorrect return type - checkCCE(() -> { // reference class + hs.checkWMTEOrCCE(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, String[].class, int.class, String.class)). - invoke(array, 0, "foo"); + invokeExact(array, 0, "foo"); }); checkWMTE(() -> { // primitive class boolean x = (boolean) hs.get(am, methodType(boolean.class, String[].class, int.class, String.class)). - invoke(array, 0, "foo"); + invokeExact(array, 0, "foo"); }); // Incorrect arity checkWMTE(() -> { // 0 String x = (String) hs.get(am, methodType(String.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > String x = (String) hs.get(am, methodType(String.class, String[].class, int.class, String.class, Class.class)). - invoke(array, 0, "foo", Void.class); + invokeExact(array, 0, "foo", Void.class); }); } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template index 391dc1a5197..dc4aed56fd4 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccess$Type$ * @run testng/othervm -Diters=20000 VarHandleTestAccess$Type$ * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccess$Type$ + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccess$Type$ */ import org.testng.annotations.BeforeClass; @@ -309,6 +310,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSet(recv, $value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -399,6 +404,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { boolean r = vh.weakCompareAndSetRelease($value1$, $value2$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSet($value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -586,6 +595,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { boolean r = vh.weakCompareAndSetRelease(recv, $value1$, $value2$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSet(recv, $value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -773,6 +786,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { boolean r = vh.weakCompareAndSetRelease($value1$, $value2$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSet($value1$); + }); #end[CAS] #if[!AtomicAdd] @@ -967,6 +984,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { checkUOE(() -> { boolean r = vh.weakCompareAndSetRelease(array, i, $value1$, $value2$); }); + + checkUOE(() -> { + $type$ r = ($type$) vh.getAndSet(array, i, $value1$); + }); #end[CAS] #if[!AtomicAdd] diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template index e433789f8cd..bb0cbb11f76 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template @@ -27,6 +27,7 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAs$Type$ * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAs$Type$ * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAs$Type$ + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAs$Type$ */ import org.testng.annotations.DataProvider; @@ -311,10 +312,12 @@ public class VarHandleTestByteArrayAs$Type$ extends VarHandleBaseByteArrayTest { checkROBE(() -> { $type$ o = ($type$) vh.getAndSet(array, ci, VALUE_1); }); + +#else[CAS] checkUOE(() -> { boolean r = vh.compareAndSet(array, ci, VALUE_1, VALUE_2); }); -#else[CAS] + checkUOE(() -> { $type$ r = ($type$) vh.compareAndExchangeVolatile(array, ci, VALUE_2, VALUE_1); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template index f56d9a641a7..9d48ba47431 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template @@ -24,6 +24,7 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccess$Type$ + * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccess$Type$ */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template index fe504902f10..5bec8b46a10 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodType.java.template @@ -23,6 +23,7 @@ /* * @test + * @bug 8156486 * @run testng/othervm VarHandleTestMethodType$Type$ * @run testng/othervm -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodType$Type$ */ @@ -81,27 +82,28 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { public Object[][] accessTestCaseProvider() throws Exception { List> cases = new ArrayList<>(); - cases.add(new VarHandleAccessTestCase("Instance field wrong method type", + cases.add(new VarHandleAccessTestCase("Instance field", vhField, vh -> testInstanceFieldWrongMethodType(this, vh), false)); - cases.add(new VarHandleAccessTestCase("Static field wrong method type", + cases.add(new VarHandleAccessTestCase("Static field", vhStaticField, VarHandleTestMethodType$Type$::testStaticFieldWrongMethodType, false)); - cases.add(new VarHandleAccessTestCase("Array wrong method type", + cases.add(new VarHandleAccessTestCase("Array", vhArray, VarHandleTestMethodType$Type$::testArrayWrongMethodType, false)); + for (VarHandleToMethodHandle f : VarHandleToMethodHandle.values()) { - cases.add(new MethodHandleAccessTestCase("Instance field wrong method type", + cases.add(new MethodHandleAccessTestCase("Instance field", vhField, f, hs -> testInstanceFieldWrongMethodType(this, hs), false)); - cases.add(new MethodHandleAccessTestCase("Static field wrong method type", + cases.add(new MethodHandleAccessTestCase("Static field", vhStaticField, f, VarHandleTestMethodType$Type$::testStaticFieldWrongMethodType, false)); - cases.add(new MethodHandleAccessTestCase("Array wrong method type", + cases.add(new MethodHandleAccessTestCase("Array", vhArray, f, VarHandleTestMethodType$Type$::testArrayWrongMethodType, false)); } @@ -648,63 +650,63 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null receiver - $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class)). - invoke(null); + $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class)). + invokeExact((VarHandleTestMethodType$Type$) null); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); checkWMTE(() -> { // receiver primitive class $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class)). - invoke(0); + invokeExact(0); }); // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class - Void x = (Void) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class)). - invoke(recv); + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class + Void x = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class)). + invokeExact(recv); }); checkWMTE(() -> { // primitive class $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class)). - invoke(recv); + invokeExact(recv); }); // Incorrect arity checkWMTE(() -> { // 0 $type$ x = ($type$) hs.get(am, methodType($type$.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - hs.get(am, methodType(void.class, Void.class, $type$.class)). - invoke(null, $value1$); + hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, $type$.class)). + invokeExact((VarHandleTestMethodType$Type$) null, $value1$); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class hs.get(am, methodType(void.class, Class.class, $type$.class)). - invoke(Void.class, $value1$); + invokeExact(Void.class, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // value reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, $type$.class)). - invoke(0, $value1$); + invokeExact(0, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)). - invoke(recv, $value1$, Void.class); + invokeExact(recv, $value1$, Void.class); }); } @@ -712,111 +714,111 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, $type$.class, $type$.class)). - invoke(null, $value1$, $value1$); + boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class)). + invokeExact((VarHandleTestMethodType$Type$) null, $value1$, $value1$); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class, $type$.class)). - invoke(Void.class, $value1$, $value1$); + invokeExact(Void.class, $value1$, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // expected reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, Class.class, $type$.class)). - invoke(recv, Void.class, $value1$); + invokeExact(recv, Void.class, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // actual reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)). - invoke(recv, $value1$, Void.class); + invokeExact(recv, $value1$, Void.class); }); checkWMTE(() -> { // receiver primitive class boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class , $type$.class, $type$.class)). - invoke(0, $value1$, $value1$); + invokeExact(0, $value1$, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 boolean r = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean r = (boolean) hs.get(am, methodType(boolean.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class, Class.class)). - invoke(recv, $value1$, $value1$, Void.class); + invokeExact(recv, $value1$, $value1$, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { checkNPE(() -> { // null receiver - $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class, $type$.class)). - invoke(null, $value1$, $value1$); + $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class)). + invokeExact((VarHandleTestMethodType$Type$) null, $value1$, $value1$); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class, $type$.class)). - invoke(Void.class, $value1$, $value1$); + invokeExact(Void.class, $value1$, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // expected reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class, $type$.class)). - invoke(recv, Void.class, $value1$); + invokeExact(recv, Void.class, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // actual reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, Class.class)). - invoke(recv, $value1$, Void.class); + invokeExact(recv, $value1$, Void.class); }); checkWMTE(() -> { // reciever primitive class $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class , $type$.class, $type$.class)). - invoke(0, $value1$, $value1$); + invokeExact(0, $value1$, $value1$); }); // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class , $type$.class, $type$.class)). - invoke(recv, $value1$, $value1$); + invokeExact(recv, $value1$, $value1$); }); checkWMTE(() -> { // primitive class $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class , $type$.class, $type$.class)). - invoke(recv, $value1$, $value1$); + invokeExact(recv, $value1$, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 $type$ x = ($type$) hs.get(am, methodType($type$.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class, $type$.class, Class.class)). - invoke(recv, $value1$, $value1$, Void.class); + invokeExact(recv, $value1$, $value1$, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { checkNPE(() -> { // null receiver - $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class)). - invoke(null, $value1$); + $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). + invokeExact((VarHandleTestMethodType$Type$) null, $value1$); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)). - invoke(Void.class, $value1$); + invokeExact(Void.class, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // value reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)). - invoke(0, $value1$); + invokeExact(0, $value1$); }); // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)). - invoke(recv, $value1$); + invokeExact(recv, $value1$); }); checkWMTE(() -> { // primitive class $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). - invoke(recv, $value1$); + invokeExact(recv, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 $type$ x = ($type$) hs.get(am, methodType($type$.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). - invoke(recv, $value1$, Void.class); + invokeExact(recv, $value1$, Void.class); }); } #end[CAS] @@ -824,38 +826,38 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { #if[AtomicAdd] for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { checkNPE(() -> { // null receiver - $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, $type$.class)). - invoke(null, $value1$); + $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). + invokeExact((VarHandleTestMethodType$Type$) null, $value1$); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)). - invoke(Void.class, $value1$); + invokeExact(Void.class, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // value reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, Class.class)). - invoke(recv, Void.class); + invokeExact(recv, Void.class); }); checkWMTE(() -> { // reciever primitive class $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, $type$.class)). - invoke(0, $value1$); + invokeExact(0, $value1$); }); // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, VarHandleTestMethodType$Type$.class, $type$.class)). - invoke(recv, $value1$); + invokeExact(recv, $value1$); }); checkWMTE(() -> { // primitive class $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). - invoke(recv, $value1$); + invokeExact(recv, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 $type$ x = ($type$) hs.get(am, methodType($type$.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > $type$ x = ($type$) hs.get(am, methodType($type$.class, VarHandleTestMethodType$Type$.class, $type$.class)). - invoke(recv, $value1$, Void.class); + invokeExact(recv, $value1$, Void.class); }); } #end[AtomicAdd] @@ -1200,111 +1202,111 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // primitive class $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class)). - invoke(); + invokeExact(); }); // Incorrect arity checkWMTE(() -> { // > $type$ x = ($type$) hs.get(am, methodType(Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { - check{#if[String]?CCE:WMTE}(() -> { // value reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class hs.get(am, methodType(void.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, $type$.class, Class.class)). - invoke($value1$, Void.class); + invokeExact($value1$, Void.class); }); } #if[CAS] for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types - check{#if[String]?CCE:WMTE}(() -> { // expected reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, $type$.class)). - invoke(Void.class, $value1$); + invokeExact(Void.class, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // actual reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$.class, Class.class)). - invoke($value1$, Void.class); + invokeExact($value1$, Void.class); }); // Incorrect arity checkWMTE(() -> { // 0 boolean r = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$.class, $type$.class, Class.class)). - invoke($value1$, $value1$, Void.class); + invokeExact($value1$, $value1$, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { // Incorrect argument types - check{#if[String]?CCE:WMTE}(() -> { // expected reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, $type$.class)). - invoke(Void.class, $value1$); + invokeExact(Void.class, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // actual reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)). - invoke($value1$, Void.class); + invokeExact($value1$, Void.class); }); // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, $type$.class, $type$.class)). - invoke($value1$, $value1$); + invokeExact($value1$, $value1$); }); checkWMTE(() -> { // primitive class $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class, $type$.class)). - invoke($value1$, $value1$); + invokeExact($value1$, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 $type$ x = ($type$) hs.get(am, methodType($type$.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, $type$.class, Class.class)). - invoke($value1$, $value1$, Void.class); + invokeExact($value1$, $value1$, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { // Incorrect argument types - check{#if[String]?CCE:WMTE}(() -> { // value reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)). - invoke($value1$); + invokeExact($value1$); }); checkWMTE(() -> { // primitive class $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)). - invoke($value1$); + invokeExact($value1$); }); // Incorrect arity checkWMTE(() -> { // 0 $type$ x = ($type$) hs.get(am, methodType($type$.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)). - invoke($value1$, Void.class); + invokeExact($value1$, Void.class); }); } #end[CAS] @@ -1314,25 +1316,25 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { // Incorrect argument types check{#if[String]?CCE:WMTE}(() -> { // value reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class)). - invoke(Void.class); + invokeExact(Void.class); }); // Incorrect return type check{#if[String]?CCE:WMTE}(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, $type$.class)). - invoke($value1$); + invokeExact($value1$); }); checkWMTE(() -> { // primitive class $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$.class)). - invoke($value1$); + invokeExact($value1$); }); // Incorrect arity checkWMTE(() -> { // 0 $type$ x = ($type$) hs.get(am, methodType($type$.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$.class, Class.class)). - invoke($value1$, Void.class); + invokeExact($value1$, Void.class); }); } #end[AtomicAdd] @@ -1929,196 +1931,196 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET)) { // Incorrect argument types checkNPE(() -> { // null array - $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class)). - invoke(null, 0); + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class)). + invokeExact(($type$[]) null, 0); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class)). - invoke(Void.class, 0); + invokeExact(Void.class, 0); }); checkWMTE(() -> { // array primitive class $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class)). - invoke(0, 0); + invokeExact(0, 0); }); checkWMTE(() -> { // index reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class)). - invoke(array, Void.class); + invokeExact(array, Void.class); }); // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class Void x = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); checkWMTE(() -> { // primitive class $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class)). - invoke(array, 0); + invokeExact(array, 0); }); // Incorrect arity checkWMTE(() -> { // 0 $type$ x = ($type$) hs.get(am, methodType($type$.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.SET)) { // Incorrect argument types checkNPE(() -> { // null array - hs.get(am, methodType(void.class, Void.class, int.class, $type$.class)). - invoke(null, 0, $value1$); + hs.get(am, methodType(void.class, $type$[].class, int.class, $type$.class)). + invokeExact(($type$[]) null, 0, $value1$); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class hs.get(am, methodType(void.class, Class.class, int.class, $type$.class)). - invoke(Void.class, 0, $value1$); + invokeExact(Void.class, 0, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // value reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class hs.get(am, methodType(void.class, $type$[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // receiver primitive class hs.get(am, methodType(void.class, int.class, int.class, $type$.class)). - invoke(0, 0, $value1$); + invokeExact(0, 0, $value1$); }); checkWMTE(() -> { // index reference class hs.get(am, methodType(void.class, $type$[].class, Class.class, $type$.class)). - invoke(array, Void.class, $value1$); + invokeExact(array, Void.class, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 hs.get(am, methodType(void.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > hs.get(am, methodType(void.class, $type$[].class, int.class, Class.class)). - invoke(array, 0, $value1$, Void.class); + invokeExact(array, 0, $value1$, Void.class); }); } #if[CAS] for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null receiver - boolean r = (boolean) hs.get(am, methodType(boolean.class, Void.class, int.class, $type$.class, $type$.class)). - invoke(null, 0, $value1$, $value1$); + boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, $type$.class)). + invokeExact(($type$[]) null, 0, $value1$, $value1$); }); - checkCCE(() -> { // receiver reference class + hs.checkWMTEOrCCE(() -> { // receiver reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, Class.class, int.class, $type$.class, $type$.class)). - invoke(Void.class, 0, $value1$, $value1$); + invokeExact(Void.class, 0, $value1$, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // expected reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, Class.class, $type$.class)). - invoke(array, 0, Void.class, $value1$); + invokeExact(array, 0, Void.class, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // actual reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, Class.class)). - invoke(array, 0, $value1$, Void.class); + invokeExact(array, 0, $value1$, Void.class); }); checkWMTE(() -> { // receiver primitive class boolean r = (boolean) hs.get(am, methodType(boolean.class, int.class, int.class, $type$.class, $type$.class)). - invoke(0, 0, $value1$, $value1$); + invokeExact(0, 0, $value1$, $value1$); }); checkWMTE(() -> { // index reference class boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, Class.class, $type$.class, $type$.class)). - invoke(array, Void.class, $value1$, $value1$); + invokeExact(array, Void.class, $value1$, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 boolean r = (boolean) hs.get(am, methodType(boolean.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > boolean r = (boolean) hs.get(am, methodType(boolean.class, $type$[].class, int.class, $type$.class, $type$.class, Class.class)). - invoke(array, 0, $value1$, $value1$, Void.class); + invokeExact(array, 0, $value1$, $value1$, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.COMPARE_AND_EXCHANGE)) { // Incorrect argument types checkNPE(() -> { // null receiver - $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class, $type$.class)). - invoke(null, 0, $value1$, $value1$); + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, $type$.class)). + invokeExact(($type$[]) null, 0, $value1$, $value1$); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class, $type$.class)). - invoke(Void.class, 0, $value1$, $value1$); + invokeExact(Void.class, 0, $value1$, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // expected reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // expected reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class, $type$.class)). - invoke(array, 0, Void.class, $value1$); + invokeExact(array, 0, Void.class, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // actual reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // actual reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)). - invoke(array, 0, $value1$, Void.class); + invokeExact(array, 0, $value1$, Void.class); }); checkWMTE(() -> { // array primitive class $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class, $type$.class)). - invoke(0, 0, $value1$, $value1$); + invokeExact(0, 0, $value1$, $value1$); }); checkWMTE(() -> { // index reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class, $type$.class)). - invoke(array, Void.class, $value1$, $value1$); + invokeExact(array, Void.class, $value1$, $value1$); }); // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class, $type$.class)). - invoke(array, 0, $value1$, $value1$); + invokeExact(array, 0, $value1$, $value1$); }); checkWMTE(() -> { // primitive class $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class, $type$.class)). - invoke(array, 0, $value1$, $value1$); + invokeExact(array, 0, $value1$, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 $type$ x = ($type$) hs.get(am, methodType($type$.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, $type$.class, Class.class)). - invoke(array, 0, $value1$, $value1$, Void.class); + invokeExact(array, 0, $value1$, $value1$, Void.class); }); } for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_SET)) { // Incorrect argument types checkNPE(() -> { // null array - $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class)). - invoke(null, 0, $value1$); + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class)). + invokeExact(($type$[]) null, 0, $value1$); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)). - invoke(Void.class, 0, $value1$); + invokeExact(Void.class, 0, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // value reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)). - invoke(0, 0, $value1$); + invokeExact(0, 0, $value1$); }); checkWMTE(() -> { // index reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)). - invoke(array, Void.class, $value1$); + invokeExact(array, Void.class, $value1$); }); // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)). - invoke(array, 0, $value1$); + invokeExact(array, 0, $value1$); }); checkWMTE(() -> { // primitive class $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)). - invoke(array, 0, $value1$); + invokeExact(array, 0, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 $type$ x = ($type$) hs.get(am, methodType($type$.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)). - invoke(array, 0, $value1$, Void.class); + invokeExact(array, 0, $value1$, Void.class); }); } #end[CAS] @@ -2127,42 +2129,42 @@ public class VarHandleTestMethodType$Type$ extends VarHandleBaseTest { for (TestAccessMode am : testAccessModesOfType(TestAccessType.GET_AND_ADD)) { // Incorrect argument types checkNPE(() -> { // null array - $type$ x = ($type$) hs.get(am, methodType($type$.class, Void.class, int.class, $type$.class)). - invoke(null, 0, $value1$); + $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class)). + invokeExact(($type$[]) null, 0, $value1$); }); - checkCCE(() -> { // array reference class + hs.checkWMTEOrCCE(() -> { // array reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, Class.class, int.class, $type$.class)). - invoke(Void.class, 0, $value1$); + invokeExact(Void.class, 0, $value1$); }); - check{#if[String]?CCE:WMTE}(() -> { // value reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // value reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, Class.class)). - invoke(array, 0, Void.class); + invokeExact(array, 0, Void.class); }); checkWMTE(() -> { // array primitive class $type$ x = ($type$) hs.get(am, methodType($type$.class, int.class, int.class, $type$.class)). - invoke(0, 0, $value1$); + invokeExact(0, 0, $value1$); }); checkWMTE(() -> { // index reference class $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, Class.class, $type$.class)). - invoke(array, Void.class, $value1$); + invokeExact(array, Void.class, $value1$); }); // Incorrect return type - check{#if[String]?CCE:WMTE}(() -> { // reference class + {#if[String]?hs.checkWMTEOrCCE:checkWMTE}(() -> { // reference class Void r = (Void) hs.get(am, methodType(Void.class, $type$[].class, int.class, $type$.class)). - invoke(array, 0, $value1$); + invokeExact(array, 0, $value1$); }); checkWMTE(() -> { // primitive class $wrong_primitive_type$ x = ($wrong_primitive_type$) hs.get(am, methodType($wrong_primitive_type$.class, $type$[].class, int.class, $type$.class)). - invoke(array, 0, $value1$); + invokeExact(array, 0, $value1$); }); // Incorrect arity checkWMTE(() -> { // 0 $type$ x = ($type$) hs.get(am, methodType($type$.class)). - invoke(); + invokeExact(); }); checkWMTE(() -> { // > $type$ x = ($type$) hs.get(am, methodType($type$.class, $type$[].class, int.class, $type$.class, Class.class)). - invoke(array, 0, $value1$, Void.class); + invokeExact(array, 0, $value1$, Void.class); }); } #end[AtomicAdd] -- GitLab From 38f007ac7fe9f3a94e78f6bbfbaf377323ee50fa Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Tue, 17 May 2016 19:53:43 +0530 Subject: [PATCH 048/400] 8157146: Add debug printlns to tests FieldSetAccessibleTest and VerifyJimage.java Reviewed-by: alanb, shade --- .../Class/getDeclaredField/FieldSetAccessibleTest.java | 8 +++++++- jdk/test/tools/jimage/VerifyJimage.java | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java index a162debb3f8..9052737aad5 100644 --- a/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java +++ b/jdk/test/java/lang/Class/getDeclaredField/FieldSetAccessibleTest.java @@ -228,12 +228,18 @@ public class FieldSetAccessibleTest { } static boolean test(String s, boolean addExports) { + String clsName = s.replace('/', '.').substring(0, s.length() - 6); try { + System.out.println("Loading " + clsName); final Class c = Class.forName( - s.replace('/', '.').substring(0, s.length() - 6), + clsName, false, systemClassLoader); return test(c, addExports); + } catch (VerifyError ve) { + System.err.println("VerifyError for " + clsName); + ve.printStackTrace(System.err); + failed.add(s); } catch (Exception t) { t.printStackTrace(System.err); failed.add(s); diff --git a/jdk/test/tools/jimage/VerifyJimage.java b/jdk/test/tools/jimage/VerifyJimage.java index 9c33cc3fa74..5056e6322a5 100644 --- a/jdk/test/tools/jimage/VerifyJimage.java +++ b/jdk/test/tools/jimage/VerifyJimage.java @@ -188,7 +188,11 @@ public class VerifyJimage { String cn = removeModule(n).replaceAll("\\.class$", "").replace('/', '.'); count.incrementAndGet(); try { + System.out.println("Loading " + cn); Class.forName(cn, false, loader); + } catch (VerifyError ve) { + System.err.println("VerifyError for " + cn); + failed.add(reader.imageName() + ": " + cn + " not verified: " + ve.getMessage()); } catch (ClassNotFoundException e) { failed.add(reader.imageName() + ": " + cn + " not found"); } -- GitLab From a96b7f7d25bbe58412429be59b224af27eec140c Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Tue, 17 May 2016 19:24:46 +0200 Subject: [PATCH 049/400] 8139982: Re-examine java.management dependency on java.util.logging.LoggingMXBean The logging MXBean implementation no longer implements java.util.logging.LoggingMXBean. java.lang.management.PlatformLoggingMXBean is used instead. java.util.logging.LoggingMXBean and java.util.logging.LogManager::getLoggingMXBean are now deprecated. Types and accessors defined in java.lang.management should be used instead. Reviewed-by: mchung --- .../classes/java/util/logging/LogManager.java | 22 +- .../classes/java/util/logging/Logging.java | 16 +- .../java/util/logging/LoggingMXBean.java | 38 ++-- .../lang/management/ManagementFactory.java | 30 ++- .../management/PlatformLoggingMXBean.java | 4 - .../management/ManagementFactoryHelper.java | 191 ++++++++++++------ .../PlatformLoggingMXBeanTest.java | 3 +- 7 files changed, 201 insertions(+), 103 deletions(-) diff --git a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java index bc06286e8da..f429452419e 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/LogManager.java @@ -2506,15 +2506,12 @@ public class LogManager { } } - // Management Support - private static LoggingMXBean loggingMXBean = null; /** * String representation of the * {@link javax.management.ObjectName} for the management interface * for the logging facility. * * @see java.lang.management.PlatformLoggingMXBean - * @see java.util.logging.LoggingMXBean * * @since 1.5 */ @@ -2523,24 +2520,21 @@ public class LogManager { /** * Returns {@code LoggingMXBean} for managing loggers. - * An alternative way to manage loggers is through the - * {@link java.lang.management.PlatformLoggingMXBean} interface - * that can be obtained by calling: - *
      -     *     PlatformLoggingMXBean logging = {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class)
      -     *         ManagementFactory.getPlatformMXBean}(PlatformLoggingMXBean.class);
      -     * 
      * * @return a {@link LoggingMXBean} object. * + * @deprecated {@code java.util.logging.LoggingMXBean} is deprecated and + * replaced with {@code java.lang.management.PlatformLoggingMXBean}. Use + * {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class) + * ManagementFactory.getPlatformMXBean}(PlatformLoggingMXBean.class) + * instead. + * * @see java.lang.management.PlatformLoggingMXBean * @since 1.5 */ + @Deprecated(since="9") public static synchronized LoggingMXBean getLoggingMXBean() { - if (loggingMXBean == null) { - loggingMXBean = new Logging(); - } - return loggingMXBean; + return Logging.getInstance(); } /** diff --git a/jdk/src/java.logging/share/classes/java/util/logging/Logging.java b/jdk/src/java.logging/share/classes/java/util/logging/Logging.java index 70c59503e4e..716e8bc150d 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/Logging.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/Logging.java @@ -44,16 +44,18 @@ import java.util.ArrayList; * @see Logger * @see LogManager */ -class Logging implements LoggingMXBean { +@SuppressWarnings("deprecation") // implements LoggingMXBean +final class Logging implements LoggingMXBean { private static LogManager logManager = LogManager.getLogManager(); /** Constructor of Logging which is the implementation class * of LoggingMXBean. */ - Logging() { + private Logging() { } + @Override public List getLoggerNames() { Enumeration loggers = logManager.getLoggerNames(); ArrayList array = new ArrayList<>(); @@ -65,6 +67,7 @@ class Logging implements LoggingMXBean { } private static String EMPTY_STRING = ""; + @Override public String getLoggerLevel(String loggerName) { Logger l = logManager.getLogger(loggerName); if (l == null) { @@ -79,6 +82,7 @@ class Logging implements LoggingMXBean { } } + @Override public void setLoggerLevel(String loggerName, String levelName) { if (loggerName == null) { throw new NullPointerException("loggerName is null"); @@ -102,6 +106,7 @@ class Logging implements LoggingMXBean { logger.setLevel(level); } + @Override public String getParentLoggerName( String loggerName ) { Logger l = logManager.getLogger( loggerName ); if (l == null) { @@ -116,4 +121,11 @@ class Logging implements LoggingMXBean { return p.getName(); } } + + static Logging getInstance() { + return INSTANCE; + } + + private static final Logging INSTANCE = new Logging(); + } diff --git a/jdk/src/java.logging/share/classes/java/util/logging/LoggingMXBean.java b/jdk/src/java.logging/share/classes/java/util/logging/LoggingMXBean.java index 9d545d8d28d..812eb36622d 100644 --- a/jdk/src/java.logging/share/classes/java/util/logging/LoggingMXBean.java +++ b/jdk/src/java.logging/share/classes/java/util/logging/LoggingMXBean.java @@ -27,30 +27,23 @@ package java.util.logging; /** - * The management interface for the logging facility. It is recommended - * to use the {@link java.lang.management.PlatformLoggingMXBean} management - * interface that implements all attributes defined in this - * {@code LoggingMXBean}. The - * {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class) - * ManagementFactory.getPlatformMXBean} method can be used to obtain - * the {@code PlatformLoggingMXBean} object representing the management - * interface for logging. + * The management interface for the logging facility. * - *

      There is a single global instance of the {@code LoggingMXBean}. - * This instance is an {@link javax.management.MXBean MXBean} that - * can be obtained by calling the {@link LogManager#getLoggingMXBean} - * method or from the - * {@linkplain java.lang.management.ManagementFactory#getPlatformMBeanServer + * {@link java.lang.management.PlatformLoggingMXBean + * java.lang.management.PlatformLoggingMXBean} is the management interface + * for logging facility registered in the {@link + * java.lang.management.ManagementFactory#getPlatformMBeanServer() * platform MBeanServer}. - *

      - * The {@link javax.management.ObjectName ObjectName} that uniquely identifies - * the management interface for logging within the {@code MBeanServer} is: - *

      - *    {@link LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging}
      - * 
      - *

      - * The instance registered in the platform {@code MBeanServer} - * is also a {@link java.lang.management.PlatformLoggingMXBean}. + * It is recommended to use the {@code PlatformLoggingMXBean} obtained via + * the {@link java.lang.management.ManagementFactory#getPlatformMXBean(Class) + * ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class)} method. + * + * @deprecated {@code LoggingMXBean} is no longer a {@link + * java.lang.management.PlatformManagedObject platform MXBean} and is replaced + * with {@link java.lang.management.PlatformLoggingMXBean}. + * It will not register in the platform {@code MBeanServer}. + * Use {@code ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class)} + * instead. * * @author Ron Mann * @author Mandy Chung @@ -58,6 +51,7 @@ package java.util.logging; * * @see java.lang.management.PlatformLoggingMXBean */ +@Deprecated(since="9") public interface LoggingMXBean { /** diff --git a/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java b/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java index 8d0083ff807..9a6252add85 100644 --- a/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java +++ b/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java @@ -598,9 +598,8 @@ public class ManagementFactory { try { final ObjectName objName = new ObjectName(mxbeanName); - // skip the isInstanceOf check for LoggingMXBean String intfName = mxbeanInterface.getName(); - if (!connection.isInstanceOf(objName, intfName)) { + if (!isInstanceOf(connection, objName, intfName)) { throw new IllegalArgumentException(mxbeanName + " is not an instance of " + mxbeanInterface); } @@ -616,6 +615,33 @@ public class ManagementFactory { } } + // This makes it possible to obtain an instance of LoggingMXBean + // using newPlatformMXBeanProxy(mbs, on, LoggingMXBean.class) + // even though the underlying MXBean no longer implements + // java.util.logging.LoggingMXBean. + // Altough java.util.logging.LoggingMXBean is deprecated, an application + // that uses newPlatformMXBeanProxy(mbs, on, LoggingMXBean.class) will + // continue to work. + // + private static boolean isInstanceOf(MBeanServerConnection connection, + ObjectName objName, String intfName) + throws InstanceNotFoundException, IOException + { + // special case for java.util.logging.LoggingMXBean. + // java.util.logging.LoggingMXBean is deprecated and + // replaced with java.lang.management.PlatformLoggingMXBean, + // so we will consider that any MBean implementing + // java.lang.management.PlatformLoggingMXBean also implements + // java.util.logging.LoggingMXBean. + if ("java.util.logging.LoggingMXBean".equals(intfName)) { + if (connection.isInstanceOf(objName, + PlatformLoggingMXBean.class.getName())) { + return true; + } + } + return connection.isInstanceOf(objName, intfName); + } + /** * Returns the platform MXBean implementing * the given {@code mxbeanInterface} which is specified diff --git a/jdk/src/java.management/share/classes/java/lang/management/PlatformLoggingMXBean.java b/jdk/src/java.management/share/classes/java/lang/management/PlatformLoggingMXBean.java index d18d0b30c40..80595dd75d6 100644 --- a/jdk/src/java.management/share/classes/java/lang/management/PlatformLoggingMXBean.java +++ b/jdk/src/java.management/share/classes/java/lang/management/PlatformLoggingMXBean.java @@ -44,10 +44,6 @@ package java.lang.management; * {@link java.util.logging.LogManager#LOGGING_MXBEAN_NAME java.util.logging:type=Logging} * * - *

      The instance registered in the platform {@code MBeanServer} with - * this {@code ObjectName} implements all attributes defined by - * {@link java.util.logging.LoggingMXBean}. - * * @since 1.7 */ public interface PlatformLoggingMXBean extends PlatformManagedObject { diff --git a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java index 44682b29971..4eb5742b2ba 100644 --- a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java +++ b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java @@ -26,6 +26,8 @@ package sun.management; import java.lang.management.*; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import javax.management.InstanceAlreadyExistsException; import javax.management.InstanceNotFoundException; import javax.management.MBeanServer; @@ -43,9 +45,13 @@ import jdk.internal.misc.SharedSecrets; import java.util.ArrayList; import java.util.List; -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Module; +import java.lang.reflect.UndeclaredThrowableException; import java.security.PrivilegedAction; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; /** * ManagementFactoryHelper provides static factory methods to create @@ -66,6 +72,7 @@ public class ManagementFactoryHelper { return jvm; } + static final String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging"; private static ClassLoadingImpl classMBean = null; private static MemoryImpl memoryMBean = null; private static ThreadImpl threadMBean = null; @@ -145,74 +152,138 @@ public class ManagementFactoryHelper { } public static PlatformLoggingMXBean getPlatformLoggingMXBean() { - if (LoggingMXBeanSupport.isAvailable()) { - return PlatformLoggingImpl.instance; + if (LoggingMXBeanAccess.isAvailable()) { + return PlatformLoggingImpl.MBEAN; } else { return null; } } public static boolean isPlatformLoggingMXBeanAvailable() { - return LoggingMXBeanSupport.isAvailable(); + return LoggingMXBeanAccess.isAvailable(); } - /** - * The logging MXBean object is an instance of - * PlatformLoggingMXBean and java.util.logging.LoggingMXBean - * but it can't directly implement two MXBean interfaces - * as a compliant MXBean implements exactly one MXBean interface, - * or if it implements one interface that is a subinterface of - * all the others; otherwise, it is a non-compliant MXBean - * and MBeanServer will throw NotCompliantMBeanException. - * See the Definition of an MXBean section in javax.management.MXBean spec. - * - * To create a compliant logging MXBean, define a LoggingMXBean interface - * that extend PlatformLoggingMXBean and j.u.l.LoggingMXBean - */ - public interface LoggingMXBean - extends PlatformLoggingMXBean, java.util.logging.LoggingMXBean { - } - - // This is a trick: if java.util.logging is not present then - // attempting to access something that implements - // java.util.logging.LoggingMXBean will trigger a CNFE. - // So we cannot directly call any static method or access any static field - // on PlatformLoggingImpl, as we would risk raising a CNFE. - // Instead we use this intermediate LoggingMXBeanSupport class to determine + // The LoggingMXBeanAccess class uses reflection to determine // whether java.util.logging is present, and load the actual LoggingMXBean // implementation. // - static final class LoggingMXBeanSupport { - final static Object loggingImpl = - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Object run() { - try { - // create a LoggingProxyImpl instance when - // java.util.logging classes exist - Class c = Class.forName("java.util.logging.Logging", true, null); - Constructor cons = c.getDeclaredConstructor(); - cons.setAccessible(true); - return cons.newInstance(); - } catch (ClassNotFoundException cnf) { + static final class LoggingMXBeanAccess { + + final static String LOG_MANAGER_CLASS_NAME = "java.util.logging.LogManager"; + final static String LOGGING_MXBEAN_CLASS_NAME = "java.util.logging.LoggingMXBean"; + final static Class LOG_MANAGER_CLASS = loadLoggingClass(LOG_MANAGER_CLASS_NAME); + + static boolean isAvailable() { + return LOG_MANAGER_CLASS != null; + } + + private static Class loadLoggingClass(String className) { + return AccessController.doPrivileged(new PrivilegedAction<>() { + @Override + public Class run() { + Optional logging = java.lang.reflect.Layer.boot() + .findModule("java.logging"); + if (logging.isPresent()) { + return Class.forName(logging.get(), className); + } return null; - } catch (NoSuchMethodException | InstantiationException - | IllegalAccessException | InvocationTargetException e) { - throw new AssertionError(e); } - }}); + }); + } - static boolean isAvailable() { - return loggingImpl != null; + private Map initMethodMap(Object impl) { + if (impl == null) { + return Collections.emptyMap(); + } + Class intfClass = loadLoggingClass(LOGGING_MXBEAN_CLASS_NAME); + final Map methodsMap = new HashMap<>(); + for (Method m : intfClass.getMethods()) { + try { + // Sanity checking: all public methods present in + // java.util.logging.LoggingMXBean should + // also be in PlatformLoggingMXBean + Method specMethod = PlatformLoggingMXBean.class + .getMethod(m.getName(), m.getParameterTypes()); + if (specMethod.getReturnType().isAssignableFrom(m.getReturnType())) { + if (methodsMap.putIfAbsent(m.getName(), m) != null) { + throw new RuntimeException("unexpected polymorphic method: " + + m.getName()); + } + } + } catch (NoSuchMethodException x) { + // All methods in java.util.logging.LoggingMXBean should + // also be in PlatformLoggingMXBean + throw new InternalError(x); + } + } + return Collections.unmodifiableMap(methodsMap); } + + private static Object getMXBeanImplementation() { + if (!isAvailable()) { + // should not happen + throw new NoClassDefFoundError(LOG_MANAGER_CLASS_NAME); + } + try { + final Method m = LOG_MANAGER_CLASS.getMethod("getLoggingMXBean"); + return m.invoke(null); + } catch (NoSuchMethodException + | IllegalAccessException + | InvocationTargetException x) { + throw new ExceptionInInitializerError(x); + } + } + + // The implementation object, which will be invoked through + // reflection. The implementation does not need to implement + // PlatformLoggingMXBean, but must declare the same methods + // with same signatures, and they must be public, with one + // exception: + // getObjectName will not be called on the implementation object, + // so the implementation object does not need to declare such + // a method. + final Object impl = getMXBeanImplementation(); + final Map methods = initMethodMap(impl); + + LoggingMXBeanAccess() { + } + + T invoke(String methodName, Object... args) { + Method m = methods.get(methodName); + if (m == null) { + throw new UnsupportedOperationException(methodName); + } + try { + @SuppressWarnings("unchecked") + T result = (T) m.invoke(impl, args); + return result; + } catch (IllegalAccessException ex) { + throw new UnsupportedOperationException(ex); + } catch (InvocationTargetException ex) { + throw unwrap(ex); + } + } + + private static RuntimeException unwrap(InvocationTargetException x) { + Throwable t = x.getCause(); + if (t instanceof RuntimeException) { + return (RuntimeException)t; + } + if (t instanceof Error) { + throw (Error)t; + } + return new UndeclaredThrowableException(t == null ? x : t); + } + + } - static class PlatformLoggingImpl implements LoggingMXBean - { - final static java.util.logging.LoggingMXBean impl = - (java.util.logging.LoggingMXBean) LoggingMXBeanSupport.loggingImpl; - final static PlatformLoggingMXBean instance = new PlatformLoggingImpl(); - final static String LOGGING_MXBEAN_NAME = "java.util.logging:type=Logging"; + static final class PlatformLoggingImpl implements PlatformLoggingMXBean { + + private final LoggingMXBeanAccess loggingAccess; + private PlatformLoggingImpl(LoggingMXBeanAccess loggingAccess) { + this.loggingAccess = loggingAccess; + } private volatile ObjectName objname; // created lazily @Override @@ -232,23 +303,29 @@ public class ManagementFactoryHelper { @Override public java.util.List getLoggerNames() { - return impl.getLoggerNames(); + return loggingAccess.invoke("getLoggerNames"); } @Override public String getLoggerLevel(String loggerName) { - return impl.getLoggerLevel(loggerName); + return loggingAccess.invoke("getLoggerLevel", loggerName); } @Override public void setLoggerLevel(String loggerName, String levelName) { - impl.setLoggerLevel(loggerName, levelName); + loggingAccess.invoke("setLoggerLevel", loggerName, levelName); } @Override public String getParentLoggerName(String loggerName) { - return impl.getParentLoggerName(loggerName); + return loggingAccess.invoke("getParentLoggerName", loggerName); } + + private static PlatformLoggingImpl getInstance() { + return new PlatformLoggingImpl(new LoggingMXBeanAccess()); + } + + static final PlatformLoggingMXBean MBEAN = getInstance(); } private static List bufferPools = null; diff --git a/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java b/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java index ac0bc89f98c..63f5c5fbc31 100644 --- a/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java +++ b/jdk/test/java/lang/management/PlatformLoggingMXBean/PlatformLoggingMXBeanTest.java @@ -270,8 +270,7 @@ public class PlatformLoggingMXBeanTest // Calling getMBeanInfo will throw exception if not found. platformMBS.getMBeanInfo(objName); - if (!platformMBS.isInstanceOf(objName, "java.lang.management.PlatformLoggingMXBean") || - !platformMBS.isInstanceOf(objName, "java.util.logging.LoggingMXBean")) { + if (!platformMBS.isInstanceOf(objName, "java.lang.management.PlatformLoggingMXBean")) { throw new RuntimeException(objName + " is of unexpected type"); } -- GitLab From f8157334a83a3462f2a51c923a1238d3f9c70b05 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 3 May 2016 15:35:39 +0200 Subject: [PATCH 050/400] 8136777: Introduce bundle targets Reviewed-by: tbell, ihse --- jdk/make/Import.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/make/Import.gmk b/jdk/make/Import.gmk index d479b095514..29e4ce0f19e 100644 --- a/jdk/make/Import.gmk +++ b/jdk/make/Import.gmk @@ -112,7 +112,7 @@ $(BASE_INSTALL_LIBRARIES_HERE)/server/%$(SHARED_LIBRARY_SUFFIX): $(BASE_INSTALL_ $(LN) -s ../$(@F) $@ ifeq ($(OPENJDK_TARGET_OS), macosx) - $(BASE_INSTALL_LIBRARIES_HERE)/server/%.dSYM : $(BASE_INSTALL_LIBRARIES_HERE)/%.dSYM + $(BASE_INSTALL_LIBRARIES_HERE)/server/%.dSYM: $(MKDIR) -p $(@D) $(RM) $@ $(LN) -s ../$(@F) $@ -- GitLab From 5302ecdbff769171e41aabbef529d19bb5346b0c Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Tue, 3 May 2016 09:48:02 -0700 Subject: [PATCH 051/400] 8149560: TIFFField#createFromMetadataNode throws a NullPointerException when the node is set with "tagNumber" attribute In the specification of createFromMetadataNode() change "tagNumber" to "number" and add two throws clauses which match the behavior. Reviewed-by: prr --- .../share/classes/javax/imageio/plugins/tiff/TIFFField.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java index 168e6b17328..3ac06d98414 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java @@ -412,7 +412,7 @@ public class TIFFField implements Cloneable { /** * Creates a {@code TIFFField} from a TIFF native image - * metadata node. If the value of the "tagNumber" attribute + * metadata node. If the value of the "number" attribute * of the node is not found in {@code tagSet} then a new * {@code TIFFTag} with name {@code TIFFTag.UNKNOWN_TAG_NAME} * will be created and assigned to the field. @@ -424,6 +424,10 @@ public class TIFFField implements Cloneable { * {@code null}. * @throws IllegalArgumentException if the name of the node is not * {@code "TIFFField"}. + * @throws NullPointerException if the node does not contain any data. + * @throws IllegalArgumentException if the combination of node attributes + * and data is not legal per the {@link #TIFFField(TIFFTag,int,int,Object)} + * constructor specification. * @return A new {@code TIFFField}. */ public static TIFFField createFromMetadataNode(TIFFTagSet tagSet, -- GitLab From 214029ed2b8f243b75a0033f8b26617e7a71025e Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 4 May 2016 01:03:46 +0300 Subject: [PATCH 052/400] 6729836: JavaSound treats large file sizes as negative and cannot read or skip Reviewed-by: prr --- .../com/sun/media/sound/AiffFileFormat.java | 14 +- .../com/sun/media/sound/AiffFileReader.java | 13 +- .../com/sun/media/sound/AuFileFormat.java | 15 +- .../com/sun/media/sound/AuFileReader.java | 23 +- .../media/sound/SoftMidiAudioFileReader.java | 9 +- .../sun/media/sound/StandardFileFormat.java | 114 ++++++++ .../com/sun/media/sound/SunFileReader.java | 12 +- .../media/sound/WaveExtensibleFileReader.java | 17 +- .../com/sun/media/sound/WaveFileFormat.java | 8 +- .../com/sun/media/sound/WaveFileReader.java | 21 +- .../sun/media/sound/WaveFloatFileReader.java | 18 +- .../RecognizeHugeAiffFiles.java | 247 ++++++++++++++++++ .../AudioFileReader/RecognizeHugeAuFiles.java | 232 ++++++++++++++++ .../RecognizeHugeWaveExtFiles.java | 7 +- ...Files.java => RecognizeHugeWaveFiles.java} | 23 +- 15 files changed, 680 insertions(+), 93 deletions(-) create mode 100644 jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardFileFormat.java create mode 100644 jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAiffFiles.java create mode 100644 jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAuFiles.java rename jdk/test/javax/sound/sampled/spi/AudioFileReader/{RecognizeHugeWaveFloatFiles.java => RecognizeHugeWaveFiles.java} (91%) diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileFormat.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileFormat.java index 8d5e7f07468..010bd3d4b56 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileFormat.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,17 +25,14 @@ package com.sun.media.sound; -import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; - /** * AIFF file format. * * @author Jan Borgersen */ - -final class AiffFileFormat extends AudioFileFormat { +final class AiffFileFormat extends StandardFileFormat { static final int AIFF_MAGIC = 1179603533; @@ -70,11 +67,8 @@ final class AiffFileFormat extends AudioFileFormat { /** FVER chunk size in bytes, inclusive magic and length field */ private final int fverChunkSize=0; - AiffFileFormat( AudioFileFormat aff ) { - this( aff.getType(), aff.getByteLength(), aff.getFormat(), aff.getFrameLength() ); - } - - AiffFileFormat(Type type, int byteLength, AudioFormat format, int frameLength) { + AiffFileFormat(final Type type, final long byteLength, + final AudioFormat format, final long frameLength) { super(type, byteLength, format, frameLength); } diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileReader.java index c0ac8bf6d40..20dc68409ff 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AiffFileReader.java @@ -45,7 +45,7 @@ import javax.sound.sampled.UnsupportedAudioFileException; public final class AiffFileReader extends SunFileReader { @Override - AudioFileFormat getAudioFileFormatImpl(final InputStream stream) + StandardFileFormat getAudioFileFormatImpl(final InputStream stream) throws UnsupportedAudioFileException, IOException { DataInputStream dis = new DataInputStream(stream); @@ -60,11 +60,11 @@ public final class AiffFileReader extends SunFileReader { throw new UnsupportedAudioFileException("not an AIFF file"); } - int frameLength = 0; + long /* unsigned 32bit */ frameLength = 0; int length = dis.readInt(); int iffType = dis.readInt(); - int totallength; + final long totallength; if(length <= 0 ) { length = AudioSystem.NOT_SPECIFIED; totallength = AudioSystem.NOT_SPECIFIED; @@ -106,12 +106,7 @@ public final class AiffFileReader extends SunFileReader { if (channels <= 0) { throw new UnsupportedAudioFileException("Invalid number of channels"); } - frameLength = dis.readInt(); // numSampleFrames - if (frameLength < 0) { - // AiffFileFormat uses int, unlike AIS which uses long - //TODO this (negative) value should be passed as long to AIS - frameLength = AudioSystem.NOT_SPECIFIED; - } + frameLength = dis.readInt() & 0xffffffffL; // numSampleFrames int sampleSizeInBits = dis.readUnsignedShort(); if (sampleSizeInBits < 1 || sampleSizeInBits > 32) { diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileFormat.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileFormat.java index 7a91bfc0a75..dc425e40a65 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileFormat.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileFormat.java @@ -33,7 +33,7 @@ import javax.sound.sampled.AudioFormat; * * @author Jan Borgersen */ -final class AuFileFormat extends AudioFileFormat { +final class AuFileFormat extends StandardFileFormat { // magic numbers static final int AU_SUN_MAGIC = 0x2e736e64; // ".snd" @@ -55,11 +55,18 @@ final class AuFileFormat extends AudioFileFormat { static final int AU_HEADERSIZE = 24; - private int auType; + /** + * According the specification of AU file format this is the value for + * length field if length is not known. This is a maximum possible value for + * the unsigned int. + */ + static final long /*unsigned int */ UNKNOWN_SIZE = 0xffffffffL; - AuFileFormat(AudioFileFormat.Type type, int lengthInBytes, AudioFormat format, int lengthInFrames) { + private int auType; - super(type,lengthInBytes,format,lengthInFrames); + AuFileFormat(final AudioFileFormat.Type type, final long byteLength, + final AudioFormat format, final long frameLength) { + super(type, byteLength, format, frameLength); AudioFormat.Encoding encoding = format.getEncoding(); diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java index 876c3b78e80..097b64b4746 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/AuFileReader.java @@ -29,7 +29,6 @@ import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; -import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFileFormat.Type; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; @@ -45,7 +44,7 @@ import javax.sound.sampled.UnsupportedAudioFileException; public final class AuFileReader extends SunFileReader { @Override - public AudioFileFormat getAudioFileFormatImpl(final InputStream stream) + public StandardFileFormat getAudioFileFormatImpl(final InputStream stream) throws UnsupportedAudioFileException, IOException { final DataInputStream dis = new DataInputStream(stream); final int magic = dis.readInt(); @@ -56,7 +55,7 @@ public final class AuFileReader extends SunFileReader { } final int headerSize = dis.readInt(); - final int dataSize = dis.readInt(); + final long /* unsigned int */ dataSize = dis.readInt() & 0xffffffffL; final int auType = dis.readInt(); final int sampleRate = dis.readInt(); final int channels = dis.readInt(); @@ -120,21 +119,21 @@ public final class AuFileReader extends SunFileReader { // unsupported filetype, throw exception throw new UnsupportedAudioFileException("not a valid AU file"); } + // now seek past the header + dis.skipBytes(headerSize - AuFileFormat.AU_HEADERSIZE); final int frameSize = calculatePCMFrameSize(sampleSizeInBits, channels); //$$fb 2002-11-02: fix for 4629669: AU file reader: problems with empty files - final int length; - if (dataSize < 0) { - length = AudioSystem.NOT_SPECIFIED; - } else { - //$$fb 2003-10-20: fix for 4940459: AudioInputStream.getFrameLength() returns 0 instead of NOT_SPECIFIED - length = dataSize / frameSize; + //$$fb 2003-10-20: fix for 4940459: AudioInputStream.getFrameLength() returns 0 instead of NOT_SPECIFIED + long frameLength = AudioSystem.NOT_SPECIFIED; + long byteLength = AudioSystem.NOT_SPECIFIED; + if (dataSize != AuFileFormat.UNKNOWN_SIZE) { + frameLength = dataSize / frameSize; + byteLength = dataSize + headerSize; } - // now seek past the header - dis.skipBytes(headerSize - AuFileFormat.AU_HEADERSIZE); final AudioFormat format = new AudioFormat(encoding, sampleRate, sampleSizeInBits, channels, frameSize, sampleRate, true); - return new AuFileFormat(Type.AU, dataSize + headerSize, format, length); + return new AuFileFormat(Type.AU, byteLength, format, frameLength); } } diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java index 715cfcf9e76..b573b16d935 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,6 @@ import javax.sound.midi.MidiUnavailableException; import javax.sound.midi.Receiver; import javax.sound.midi.Sequence; import javax.sound.midi.Track; -import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFileFormat.Type; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; @@ -56,10 +55,10 @@ public final class SoftMidiAudioFileReader extends SunFileReader { private static final AudioFormat format = new AudioFormat(44100, 16, 2, true, false); - private static AudioFileFormat getAudioFileFormat(final Sequence seq) { + private static StandardFileFormat getAudioFileFormat(final Sequence seq) { long totallen = seq.getMicrosecondLength() / 1000000; long len = (long) (format.getFrameRate() * (totallen + 4)); - return new AudioFileFormat(MIDI, format, (int) len); + return new StandardFileFormat(MIDI, format, len); } private AudioInputStream getAudioInputStream(final Sequence seq) @@ -140,7 +139,7 @@ public final class SoftMidiAudioFileReader extends SunFileReader { } @Override - AudioFileFormat getAudioFileFormatImpl(final InputStream stream) + StandardFileFormat getAudioFileFormatImpl(final InputStream stream) throws UnsupportedAudioFileException, IOException { try { return getAudioFileFormat(MidiSystem.getSequence(stream)); diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardFileFormat.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardFileFormat.java new file mode 100644 index 00000000000..5be7149929c --- /dev/null +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/StandardFileFormat.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.media.sound; + +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioSystem; + +/** + * An instance of the {@code StandardFileFormat} describes the file's length in + * bytes and the length in sample frames as longs. This will provide an + * additional precision unlike the {@code AudioFileFormat}. + */ +class StandardFileFormat extends AudioFileFormat { + + /** + * File length in bytes stored as long. + */ + private final long byteLength; + + /** + * Audio data length in sample frames stored as long. + */ + private final long frameLength; + + /** + * Constructs {@code StandardFileFormat} object. + * + * @param type the type of the audio file + * @param format the format of the audio data contained in the file + * @param frameLength the audio data length in sample frames, or + * {@code AudioSystem.NOT_SPECIFIED} + */ + StandardFileFormat(final Type type, final AudioFormat format, + final long frameLength) { + this(type, AudioSystem.NOT_SPECIFIED, format, frameLength); + } + + /** + * Constructs {@code StandardFileFormat} object. + * + * @param type the type of the audio file + * @param byteLength the length of the file in bytes, or + * {@code AudioSystem.NOT_SPECIFIED} + * @param format the format of the audio data contained in the file + * @param frameLength the audio data length in sample frames, or + * {@code AudioSystem.NOT_SPECIFIED} + */ + StandardFileFormat(final Type type, final long byteLength, + final AudioFormat format, final long frameLength) { + super(type, clip(byteLength), format, clip(frameLength)); + this.byteLength = byteLength; + this.frameLength = frameLength; + } + + /** + * Replaces the passed value to {@code AudioSystem.NOT_SPECIFIED} if the + * value is greater than {@code Integer.MAX_VALUE}. + * + * @param value which should be clipped + * @return the clipped value + */ + private static int clip(final long value) { + if (value > Integer.MAX_VALUE) { + return AudioSystem.NOT_SPECIFIED; + } + return (int) value; + } + + /** + * Obtains the length of the audio data contained in the file, expressed in + * sample frames. The long precision is used. + * + * @return the number of sample frames of audio data in the file + * @see AudioSystem#NOT_SPECIFIED + */ + public final long getLongFrameLength() { + return frameLength; + } + + /** + * Obtains the size in bytes of the entire audio file (not just its audio + * data). The long precision is used. + * + * @return the audio file length in bytes + * @see AudioSystem#NOT_SPECIFIED + */ + public final long getLongByteLength() { + return byteLength; + } +} diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java index a9e40ff33c5..01307d59514 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/SunFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ import javax.sound.sampled.spi.AudioFileReader; abstract class SunFileReader extends AudioFileReader { @Override - public final AudioFileFormat getAudioFileFormat(final InputStream stream) + public final StandardFileFormat getAudioFileFormat(final InputStream stream) throws UnsupportedAudioFileException, IOException { stream.mark(200); // The biggest value which was historically used try { @@ -87,11 +87,11 @@ abstract class SunFileReader extends AudioFileReader { throws UnsupportedAudioFileException, IOException { stream.mark(200); // The biggest value which was historically used try { - final AudioFileFormat fileFormat = getAudioFileFormatImpl(stream); + final StandardFileFormat format = getAudioFileFormatImpl(stream); // we've got everything, the stream is supported and it is at the // beginning of the audio data, so return an AudioInputStream - return new AudioInputStream(stream, fileFormat.getFormat(), - fileFormat.getFrameLength()); + return new AudioInputStream(stream, format.getFormat(), + format.getLongFrameLength()); } catch (UnsupportedAudioFileException | EOFException ignored) { // stream is unsupported or the header is less than was expected stream.reset(); @@ -140,7 +140,7 @@ abstract class SunFileReader extends AudioFileReader { * UnsupportedAudioFileException if the header is less than was * expected */ - abstract AudioFileFormat getAudioFileFormatImpl(InputStream stream) + abstract StandardFileFormat getAudioFileFormatImpl(InputStream stream) throws UnsupportedAudioFileException, IOException; // HELPER METHODS diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java index 7d6ec18239b..5066ba29ea5 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java @@ -34,7 +34,6 @@ import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioFormat.Encoding; import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; import javax.sound.sampled.UnsupportedAudioFileException; /** @@ -167,7 +166,7 @@ public final class WaveExtensibleFileReader extends SunFileReader { } @Override - AudioFileFormat getAudioFileFormatImpl(final InputStream stream) + StandardFileFormat getAudioFileFormatImpl(final InputStream stream) throws UnsupportedAudioFileException, IOException { RIFFReader riffiterator = new RIFFReader(stream); @@ -249,19 +248,17 @@ public final class WaveExtensibleFileReader extends SunFileReader { } else { throw new UnsupportedAudioFileException(); } - long frameLength = dataSize / audioformat.getFrameSize(); - if (frameLength > Integer.MAX_VALUE) { - frameLength = AudioSystem.NOT_SPECIFIED; - } - return new AudioFileFormat(AudioFileFormat.Type.WAVE, audioformat, - (int) frameLength); + return new StandardFileFormat(AudioFileFormat.Type.WAVE, audioformat, + dataSize / audioformat.getFrameSize()); } @Override public AudioInputStream getAudioInputStream(final InputStream stream) throws UnsupportedAudioFileException, IOException { - final AudioFileFormat format = getAudioFileFormat(stream); + final StandardFileFormat format = getAudioFileFormat(stream); + final AudioFormat af = format.getFormat(); + final long length = format.getLongFrameLength(); // we've got everything, the stream is supported and it is at the // beginning of the header, so find the data chunk again and return an // AudioInputStream @@ -269,8 +266,6 @@ public final class WaveExtensibleFileReader extends SunFileReader { while (riffiterator.hasNextChunk()) { RIFFReader chunk = riffiterator.nextChunk(); if (chunk.getFormat().equals("data")) { - final AudioFormat af = format.getFormat(); - final long length = chunk.getSize() / af.getFrameSize(); return new AudioInputStream(chunk, af, length); } } diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileFormat.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileFormat.java index 9bf8c9200ad..bf3abbf684a 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileFormat.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileFormat.java @@ -33,7 +33,7 @@ import javax.sound.sampled.AudioFormat; * * @author Jan Borgersen */ -final class WaveFileFormat extends AudioFileFormat { +final class WaveFileFormat extends StandardFileFormat { /** * Wave format type. @@ -73,9 +73,9 @@ final class WaveFileFormat extends AudioFileFormat { static final int WAVE_FORMAT_SX7383 = 0x1C07; static final int WAVE_FORMAT_EXTENSIBLE= 0xFFFE; - WaveFileFormat(AudioFileFormat.Type type, int lengthInBytes, AudioFormat format, int lengthInFrames) { - - super(type,lengthInBytes,format,lengthInFrames); + WaveFileFormat(final AudioFileFormat.Type type, final long byteLength, + final AudioFormat format, final long frameLength) { + super(type, byteLength, format, frameLength); AudioFormat.Encoding encoding = format.getEncoding(); diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileReader.java index 96a4bd7cd1f..7295b180ed1 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ import javax.sound.sampled.UnsupportedAudioFileException; public final class WaveFileReader extends SunFileReader { @Override - AudioFileFormat getAudioFileFormatImpl(final InputStream stream) + StandardFileFormat getAudioFileFormatImpl(final InputStream stream) throws UnsupportedAudioFileException, IOException { // assumes sream is rewound @@ -64,9 +64,9 @@ public final class WaveFileReader extends SunFileReader { DataInputStream dis = new DataInputStream( stream ); int magic = dis.readInt(); - int fileLength = rllong(dis); + long /* unsigned int */ fileLength = rllong(dis) & 0xffffffffL; int waveMagic = dis.readInt(); - int totallength; + long totallength; if (fileLength <= 0) { fileLength = AudioSystem.NOT_SPECIFIED; totallength = AudioSystem.NOT_SPECIFIED; @@ -186,19 +186,18 @@ public final class WaveFileReader extends SunFileReader { } } // this is the length of the data chunk - int dataLength = rllong(dis); nread += 4; + long /* unsigned int */ dataLength = rllong(dis) & 0xffffffffL; nread += 4; // now build the new AudioFileFormat and return - + final int frameSize = calculatePCMFrameSize(sampleSizeInBits, channels); AudioFormat format = new AudioFormat(encoding, (float)sampleRate, sampleSizeInBits, channels, - calculatePCMFrameSize(sampleSizeInBits, channels), + frameSize, (float)sampleRate, false); - return new WaveFileFormat(AudioFileFormat.Type.WAVE, - totallength, - format, - dataLength / format.getFrameSize()); + long frameLength = dataLength / format.getFrameSize(); + return new WaveFileFormat(AudioFileFormat.Type.WAVE, totallength, + format, frameLength); } } diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFloatFileReader.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFloatFileReader.java index 284877d1599..2c3be1507fc 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFloatFileReader.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/WaveFloatFileReader.java @@ -32,7 +32,6 @@ import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioFormat.Encoding; import javax.sound.sampled.AudioInputStream; -import javax.sound.sampled.AudioSystem; import javax.sound.sampled.UnsupportedAudioFileException; /** @@ -43,7 +42,7 @@ import javax.sound.sampled.UnsupportedAudioFileException; public final class WaveFloatFileReader extends SunFileReader { @Override - AudioFileFormat getAudioFileFormatImpl(final InputStream stream) + StandardFileFormat getAudioFileFormatImpl(final InputStream stream) throws UnsupportedAudioFileException, IOException { RIFFReader riffiterator = new RIFFReader(stream); @@ -88,20 +87,17 @@ public final class WaveFloatFileReader extends SunFileReader { AudioFormat audioformat = new AudioFormat( Encoding.PCM_FLOAT, samplerate, bits, channels, framesize, samplerate, false); - long frameLength = dataSize / audioformat.getFrameSize(); - if (frameLength > Integer.MAX_VALUE) { - frameLength = AudioSystem.NOT_SPECIFIED; - } - - return new AudioFileFormat(AudioFileFormat.Type.WAVE, audioformat, - (int) frameLength); + return new StandardFileFormat(AudioFileFormat.Type.WAVE, audioformat, + dataSize / audioformat.getFrameSize()); } @Override public AudioInputStream getAudioInputStream(final InputStream stream) throws UnsupportedAudioFileException, IOException { - final AudioFileFormat format = getAudioFileFormat(stream); + final StandardFileFormat format = getAudioFileFormat(stream); + final AudioFormat af = format.getFormat(); + final long length = format.getLongFrameLength(); // we've got everything, the stream is supported and it is at the // beginning of the header, so find the data chunk again and return an // AudioInputStream @@ -109,8 +105,6 @@ public final class WaveFloatFileReader extends SunFileReader { while (riffiterator.hasNextChunk()) { RIFFReader chunk = riffiterator.nextChunk(); if (chunk.getFormat().equals("data")) { - final AudioFormat af = format.getFormat(); - final long length = chunk.getSize() / af.getFrameSize(); return new AudioInputStream(chunk, af, length); } } diff --git a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAiffFiles.java b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAiffFiles.java new file mode 100644 index 00000000000..c0899484328 --- /dev/null +++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAiffFiles.java @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.ByteArrayInputStream; + +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; + +/** + * @test + * @bug 6729836 + */ +public final class RecognizeHugeAiffFiles { + + /** + * The maximum number of sample frames per AIFF specification. + */ + private static final /* unsigned int */ long MAX_UNSIGNED_INT = 0xffffffffL; + + /** + * The supported aiff sample size in bits. + */ + private static final byte[] aiffBits = { + 1, 2, 4, 8, 11, 16, 20, 24, 27, 32 + }; + + /** + * The list of supported sample rates. + */ + private static final int[] sampleRates = { + 8000, 11025, 16000, 22050, 32000, 37800, 44056, 44100, 47250, 48000, + 50000, 50400, 88200, 96000, 176400, 192000, 352800, 2822400, + 5644800, Integer.MAX_VALUE + }; + + /** + * The list of supported channels. + */ + private static final int[] channels = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 + }; + + /** + * The list of supported number of frames. + *

      + * The {@code MAX_UNSIGNED_INT} is a maximum. + */ + private static final long[] numberOfFrames = { + 0, 1, 2, 3, Integer.MAX_VALUE - 1, Integer.MAX_VALUE, + (long) Integer.MAX_VALUE + 1, MAX_UNSIGNED_INT - 1, MAX_UNSIGNED_INT + }; + + public static void main(final String[] args) throws Exception { + for (final byte bits : aiffBits) { + for (final int sampleRate : sampleRates) { + for (final int channel : channels) { + for (final long dataSize : numberOfFrames) { + testAFF(bits, sampleRate, channel, dataSize); + testAIS(bits, sampleRate, channel, dataSize); + } + } + } + } + } + + /** + * Tests the {@code AudioFileFormat} fetched from the fake header. + *

      + * Note that the frameLength and byteLength are stored as int which means + * that {@code AudioFileFormat} will store the data above {@code MAX_INT} as + * NOT_SPECIFIED. + */ + private static void testAFF(final byte bits, final int rate, + final int channel, final long frameLength) + throws Exception { + final byte[] header = createHeader(bits, rate, channel, frameLength); + final ByteArrayInputStream fake = new ByteArrayInputStream(header); + final AudioFileFormat aff = AudioSystem.getAudioFileFormat(fake); + + if (aff.getType() != AudioFileFormat.Type.AIFF) { + throw new RuntimeException("Error"); + } + + if (frameLength <= Integer.MAX_VALUE) { + if (aff.getFrameLength() != frameLength) { + System.err.println("Expected: " + frameLength); + System.err.println("Actual: " + aff.getFrameLength()); + throw new RuntimeException(); + } + } else { + if (aff.getFrameLength() != AudioSystem.NOT_SPECIFIED) { + System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED); + System.err.println("Actual: " + aff.getFrameLength()); + throw new RuntimeException(); + } + } + validateFormat(bits, rate, channel, aff.getFormat()); + } + + /** + * Tests the {@code AudioInputStream} fetched from the fake header. + *

      + * Note that the frameLength is stored as long which means that {@code + * AudioInputStream} must store all possible data from aiff file. + */ + private static void testAIS(final byte bits, final int rate, + final int channel, final long frameLength) + throws Exception { + final byte[] header = createHeader(bits, rate, channel, frameLength); + final ByteArrayInputStream fake = new ByteArrayInputStream(header); + final AudioInputStream ais = AudioSystem.getAudioInputStream(fake); + final AudioFormat format = ais.getFormat(); + + if (frameLength != ais.getFrameLength()) { + System.err.println("Expected: " + frameLength); + System.err.println("Actual: " + ais.getFrameLength()); + throw new RuntimeException(); + } + if (ais.available() < 0) { + System.err.println("available should be >=0: " + ais.available()); + throw new RuntimeException(); + } + + validateFormat(bits, rate, channel, format); + } + + /** + * Tests that format contains the same data as were provided to the fake + * stream. + */ + private static void validateFormat(final byte bits, final int rate, + final int channel, + final AudioFormat format) { + + if (Float.compare(format.getSampleRate(), rate) != 0) { + System.err.println("Expected: " + rate); + System.err.println("Actual: " + format.getSampleRate()); + throw new RuntimeException(); + } + if (format.getChannels() != channel) { + System.err.println("Expected: " + channel); + System.err.println("Actual: " + format.getChannels()); + throw new RuntimeException(); + } + int frameSize = ((bits + 7) / 8) * channel; + if (format.getFrameSize() != frameSize) { + System.out.println("Expected: " + frameSize); + System.err.println("Actual: " + format.getFrameSize()); + throw new RuntimeException(); + } + } + + private static final int DOUBLE_MANTISSA_LENGTH = 52; + private static final int DOUBLE_EXPONENT_LENGTH = 11; + private static final long DOUBLE_SIGN_MASK = 0x8000000000000000L; + private static final long DOUBLE_EXPONENT_MASK = 0x7FF0000000000000L; + private static final long DOUBLE_MANTISSA_MASK = 0x000FFFFFFFFFFFFFL; + private static final int DOUBLE_EXPONENT_OFFSET = 1023; + + private static final int EXTENDED_EXPONENT_OFFSET = 16383; + private static final int EXTENDED_MANTISSA_LENGTH = 63; + private static final int EXTENDED_EXPONENT_LENGTH = 15; + private static final long EXTENDED_INTEGER_MASK = 0x8000000000000000L; + + /** + * Creates the custom header of the AIFF file. It is expected that all + * passed data are supported. + */ + private static byte[] createHeader(final byte bits, final int rate, + final int channel, final long frameLength) { + long doubleBits = Double.doubleToLongBits(rate); + + long sign = (doubleBits & DOUBLE_SIGN_MASK) + >> (DOUBLE_EXPONENT_LENGTH + DOUBLE_MANTISSA_LENGTH); + long doubleExponent = (doubleBits & DOUBLE_EXPONENT_MASK) + >> DOUBLE_MANTISSA_LENGTH; + long doubleMantissa = doubleBits & DOUBLE_MANTISSA_MASK; + + long extendedExponent = doubleExponent - DOUBLE_EXPONENT_OFFSET + + EXTENDED_EXPONENT_OFFSET; + long extendedMantissa = doubleMantissa + << (EXTENDED_MANTISSA_LENGTH - DOUBLE_MANTISSA_LENGTH); + long extendedSign = sign << EXTENDED_EXPONENT_LENGTH; + short extendedBits79To64 = (short) (extendedSign | extendedExponent); + long extendedBits63To0 = EXTENDED_INTEGER_MASK | extendedMantissa; + + return new byte[]{ + // AIFF_MAGIC + 0x46, 0x4f, 0x52, 0x4d, + // fileLength (will use the number of frames for testing) + (byte) (frameLength >> 24), (byte) (frameLength >> 16), + (byte) (frameLength >> 8), (byte) frameLength, + // form aiff + 0x41, 0x49, 0x46, 0x46, + // COMM_MAGIC + 0x43, 0x4f, 0x4d, 0x4d, + // comm chunk size + 0, 0, 0, 18, + // channels + (byte) (channel >> 8),(byte) channel, + // numSampleFrames + (byte) (frameLength >> 24), (byte) (frameLength >> 16), + (byte) (frameLength >> 8), (byte) (frameLength), + // samplesize + (byte) (bits >> 8),(byte) (bits), + // samplerate + (byte) (extendedBits79To64 >> 8), + (byte) extendedBits79To64, + (byte) (extendedBits63To0 >> 56), + (byte) (extendedBits63To0 >> 48), + (byte) (extendedBits63To0 >> 40), + (byte) (extendedBits63To0 >> 32), (byte) (extendedBits63To0 >> 24), + (byte) (extendedBits63To0 >> 16), (byte) (extendedBits63To0 >> 8), + (byte) extendedBits63To0, + // SND_MAGIC + 0x53, 0x53, 0x4e, 0x44, + // data chunk size + 0, 0, 0, 0, + // dataOffset + 0, 0, 0, 0, + // blocksize + 0, 0, 0, 0, + }; + } +} diff --git a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAuFiles.java b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAuFiles.java new file mode 100644 index 00000000000..ba908667299 --- /dev/null +++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeAuFiles.java @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.ByteArrayInputStream; + +import javax.sound.sampled.AudioFileFormat; +import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; + +/** + * @test + * @bug 6729836 + */ +public final class RecognizeHugeAuFiles { + + /** + * The size of the header's data. + */ + private static final byte AU_HEADER = 44; + + /** + * This value should be used if the size in bytes is unknown. + */ + private static final /* unsigned int */ long MAX_UNSIGNED_INT = 0xffffffffL; + + /** + * The list of supported au formats and sample size in bits per format. + */ + private static final byte[][] auTypeBits = { + {1, 8}, {2, 8}, {3, 16}, {4, 24}, {5, 32}, {6, 32}, {27, 8} + }; + + /** + * The list of supported sample rates(stored as unsigned int). + */ + private static final int[] sampleRates = { + 8000, 11025, 16000, 22050, 32000, 37800, 44056, 44100, 47250, 48000, + 50000, 50400, 88200, 96000, 176400, 192000, 352800, 2822400, + 5644800, Integer.MAX_VALUE + }; + + /** + * The list of supported channels (stored as unsigned int). + */ + private static final int[] channels = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 + }; + + /** + * The list of supported size of data (stored as unsigned int). + *

      + * The {@code MAX_UNSIGNED_INT} used if the size in bytes is unknown. + */ + private static final long[] dataSizes = { + 0, 1, 2, 3, Integer.MAX_VALUE - AU_HEADER, Integer.MAX_VALUE - 1, + Integer.MAX_VALUE, (long) Integer.MAX_VALUE + 1, + (long) Integer.MAX_VALUE + AU_HEADER, MAX_UNSIGNED_INT - AU_HEADER, + MAX_UNSIGNED_INT - 1, MAX_UNSIGNED_INT + }; + + public static void main(final String[] args) throws Exception { + for (final byte[] type : auTypeBits) { + for (final int sampleRate : sampleRates) { + for (final int channel : channels) { + for (final long dataSize : dataSizes) { + testAFF(type, sampleRate, channel, dataSize); + testAIS(type, sampleRate, channel, dataSize); + } + } + } + } + } + + /** + * Tests the {@code AudioFileFormat} fetched from the fake header. + *

      + * Note that the frameLength and byteLength are stored as int which means + * that {@code AudioFileFormat} will store the data above {@code MAX_INT} + * as NOT_SPECIFIED. + */ + private static void testAFF(final byte[] type, final int rate, + final int channel, final long size) + throws Exception { + final byte[] header = createHeader(type, rate, channel, size); + final ByteArrayInputStream fake = new ByteArrayInputStream(header); + final AudioFileFormat aff = AudioSystem.getAudioFileFormat(fake); + final AudioFormat format = aff.getFormat(); + + if (aff.getType() != AudioFileFormat.Type.AU) { + throw new RuntimeException("Error"); + } + + final long frameLength = size / format.getFrameSize(); + if (size != MAX_UNSIGNED_INT && frameLength <= Integer.MAX_VALUE) { + if (aff.getFrameLength() != frameLength) { + System.err.println("Expected: " + frameLength); + System.err.println("Actual: " + aff.getFrameLength()); + throw new RuntimeException(); + } + } else { + if (aff.getFrameLength() != AudioSystem.NOT_SPECIFIED) { + System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED); + System.err.println("Actual: " + aff.getFrameLength()); + throw new RuntimeException(); + } + } + + final long byteLength = size + AU_HEADER; + if (byteLength <= Integer.MAX_VALUE) { + if (aff.getByteLength() != byteLength) { + System.err.println("Expected: " + byteLength); + System.err.println("Actual: " + aff.getByteLength()); + throw new RuntimeException(); + } + } else { + if (aff.getByteLength() != AudioSystem.NOT_SPECIFIED) { + System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED); + System.err.println("Actual: " + aff.getByteLength()); + throw new RuntimeException(); + } + } + validateFormat(type[1], rate, channel, aff.getFormat()); + } + + /** + * Tests the {@code AudioInputStream} fetched from the fake header. + *

      + * Note that the frameLength is stored as long which means + * that {@code AudioInputStream} must store all possible data from au file. + */ + private static void testAIS(final byte[] type, final int rate, + final int channel, final long size) + throws Exception { + final byte[] header = createHeader(type, rate, channel, size); + final ByteArrayInputStream fake = new ByteArrayInputStream(header); + final AudioInputStream ais = AudioSystem.getAudioInputStream(fake); + final AudioFormat format = ais.getFormat(); + final long frameLength = size / format.getFrameSize(); + if (size != MAX_UNSIGNED_INT) { + if (frameLength != ais.getFrameLength()) { + System.err.println("Expected: " + frameLength); + System.err.println("Actual: " + ais.getFrameLength()); + throw new RuntimeException(); + } + } else { + if (ais.getFrameLength() != AudioSystem.NOT_SPECIFIED) { + System.err.println("Expected: " + AudioSystem.NOT_SPECIFIED); + System.err.println("Actual: " + ais.getFrameLength()); + throw new RuntimeException(); + } + } + if (ais.available() < 0) { + System.err.println("available should be >=0: " + ais.available()); + throw new RuntimeException(); + } + validateFormat(type[1], rate, channel, format); + } + + /** + * Tests that format contains the same data as were provided to the fake + * stream. + */ + private static void validateFormat(final byte bits, final int rate, + final int channel, + final AudioFormat format) { + + if (Float.compare(format.getSampleRate(), rate) != 0) { + System.out.println("Expected: " + rate); + System.out.println("Actual: " + format.getSampleRate()); + throw new RuntimeException(); + } + if (format.getChannels() != channel) { + System.out.println("Expected: " + channel); + System.out.println("Actual: " + format.getChannels()); + throw new RuntimeException(); + } + int frameSize = ((bits + 7) / 8) * channel; + if (format.getFrameSize() != frameSize) { + System.out.println("Expected: " + frameSize); + System.out.println("Actual: " + format.getFrameSize()); + throw new RuntimeException(); + } + } + + /** + * Creates the custom header of the AU file. It is expected that all passed + * data are supported. + */ + private static byte[] createHeader(final byte[] type, final int rate, + final int channel, final long size) { + return new byte[]{ + // AU_SUN_MAGIC + 0x2e, 0x73, 0x6e, 0x64, + // headerSize + 0, 0, 0, AU_HEADER, + // dataSize + (byte) (size >> 24), (byte) (size >> 16), (byte) (size >> 8), + (byte) size, + // encoding + 0, 0, 0, type[0], + // sampleRate + (byte) (rate >> 24), (byte) (rate >> 16), (byte) (rate >> 8), + (byte) (rate), + // channels + (byte) (channel >> 24), (byte) (channel >> 16), + (byte) (channel >> 8), (byte) (channel), + // data + 0, 0, 0, 0, 0, 0 + }; + } +} diff --git a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveExtFiles.java b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveExtFiles.java index 88b231d62d7..ca8d17e3e78 100644 --- a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveExtFiles.java +++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveExtFiles.java @@ -125,7 +125,7 @@ public final class RecognizeHugeWaveExtFiles { * Tests the {@code AudioInputStream} fetched from the fake header. *

      * Note that the frameLength is stored as long which means that {@code - * AudioInputStream} must store all possible data from au file. + * AudioInputStream} must store all possible data from wave file. */ private static void testAIS(final int[] type, final int rate, final int channel, final long size) @@ -166,8 +166,9 @@ public final class RecognizeHugeWaveExtFiles { System.err.println("Actual: " + format.getChannels()); throw new RuntimeException(); } - if (format.getFrameSize() != ((bits + 7) / 8) * channel) { - System.err.println("Expected: " + (bits * channel + 1) / 8); + int frameSize = ((bits + 7) / 8) * channel; + if (format.getFrameSize() != frameSize) { + System.err.println("Expected: " + frameSize); System.err.println("Actual: " + format.getFrameSize()); throw new RuntimeException(); } diff --git a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFloatFiles.java b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFiles.java similarity index 91% rename from jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFloatFiles.java rename to jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFiles.java index e36a7e2b180..191290a128e 100644 --- a/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFloatFiles.java +++ b/jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFiles.java @@ -30,9 +30,9 @@ import javax.sound.sampled.AudioSystem; /** * @test - * @bug 8132782 + * @bug 8132782 6729836 */ -public final class RecognizeHugeWaveFloatFiles { +public final class RecognizeHugeWaveFiles { /** * The maximum size in bytes per WAVE specification. @@ -43,7 +43,17 @@ public final class RecognizeHugeWaveFloatFiles { * The supported wave pcm_float format and sample size in bits. */ private static final byte[][] waveTypeBits = { - {0x0003/*WAVE_FORMAT_IEEE_FLOAT*/, 32} + {0x0001/*WAVE_FORMAT_PCM*/,1}, + {0x0001/*WAVE_FORMAT_PCM*/,2}, + {0x0001/*WAVE_FORMAT_PCM*/,4}, + {0x0001/*WAVE_FORMAT_PCM*/,8}, + {0x0001/*WAVE_FORMAT_PCM*/,16}, + {0x0001/*WAVE_FORMAT_PCM*/,20}, + {0x0001/*WAVE_FORMAT_PCM*/,24}, + {0x0001/*WAVE_FORMAT_PCM*/,32}, + {0x0003/*WAVE_FORMAT_IEEE_FLOAT*/, 32}, + {0x0006/*WAVE_FORMAT_ALAW*/, 8}, + {0x0007/*WAVE_FORMAT_MULAW*/, 8} }; /** @@ -125,7 +135,7 @@ public final class RecognizeHugeWaveFloatFiles { * Tests the {@code AudioInputStream} fetched from the fake header. *

      * Note that the frameLength is stored as long which means that {@code - * AudioInputStream} must store all possible data from au file. + * AudioInputStream} must store all possible data from wave file. */ private static void testAIS(final byte[] type, final int rate, final int channel, final long size) @@ -166,8 +176,9 @@ public final class RecognizeHugeWaveFloatFiles { System.err.println("Actual: " + format.getChannels()); throw new RuntimeException(); } - if (format.getFrameSize() != ((bits + 7) / 8) * channel) { - System.err.println("Expected: " + (bits * channel + 1) / 8); + int frameSize = ((bits + 7) / 8) * channel; + if (format.getFrameSize() != frameSize) { + System.err.println("Expected: " + frameSize); System.err.println("Actual: " + format.getFrameSize()); throw new RuntimeException(); } -- GitLab From fa5b3ae32f3aa6e30135cbb0e1ef4e69a318f741 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Wed, 4 May 2016 10:01:00 -0700 Subject: [PATCH 053/400] 8149816: TIFFField#getValueAsString result is unexpected for RATIONAL and SRATIONAL types (when modulo is 0) Add more precision to the specification verbiage of getValueAsString(). Reviewed-by: prr --- .../share/classes/javax/imageio/plugins/tiff/TIFFField.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java index 3ac06d98414..a6ba3859d2b 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java @@ -1303,7 +1303,11 @@ public class TIFFField implements Cloneable { * version of the data item. Data of type * {@code TIFFTag.TIFF_RATIONAL} or {@code TIFF_SRATIONAL} are * represented as a pair of integers separated by a - * {@code '/'} character. + * {@code '/'} character. If the numerator of a + * {@code TIFFTag.TIFF_RATIONAL} or {@code TIFF_SRATIONAL} is an integral + * multiple of the denominator, then the value is represented as + * {@code "q/1"} where {@code q} is the quotient of the numerator and + * denominator. * * @param index The index of the data. * @return The data at the given index as a {@code String}. -- GitLab From 09a7921d55215d9c97bf387287efbd238f3efc8f Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Thu, 5 May 2016 01:30:23 +0300 Subject: [PATCH 054/400] 8151786: [TESTBUG] java/beans/XMLEncoder/Test4625418.java timed out intermittently Reviewed-by: alexsch, yan --- .../java/beans/XMLEncoder/Test4625418.java | 658 +++++++++--------- 1 file changed, 329 insertions(+), 329 deletions(-) diff --git a/jdk/test/java/beans/XMLEncoder/Test4625418.java b/jdk/test/java/beans/XMLEncoder/Test4625418.java index 0f9203e864d..a8a23aced37 100644 --- a/jdk/test/java/beans/XMLEncoder/Test4625418.java +++ b/jdk/test/java/beans/XMLEncoder/Test4625418.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,332 +26,338 @@ * @bug 4625418 * @summary Tests XML encoding * @author Sergey Malenkov - * - * @run main Test4625418 ASCII - * @run main Test4625418 Big5 - * ?run main Test4625418 Big5-HKSCS - * ?run main Test4625418 Big5_HKSCS - * @run main Test4625418 Big5_Solaris - * ?run main Test4625418 Cp037 - * @run main Test4625418 Cp1006 - * ?run main Test4625418 Cp1025 - * -run main Test4625418 Cp1026 - * @run main Test4625418 Cp1046 - * @run main Test4625418 Cp1047 - * @run main Test4625418 Cp1097 - * @run main Test4625418 Cp1098 - * ?run main Test4625418 Cp1112 - * ?run main Test4625418 Cp1122 - * ?run main Test4625418 Cp1123 - * @run main Test4625418 Cp1124 - * ?run main Test4625418 Cp1140 - * ?run main Test4625418 Cp1141 - * ?run main Test4625418 Cp1142 - * ?run main Test4625418 Cp1143 - * ?run main Test4625418 Cp1144 - * ?run main Test4625418 Cp1145 - * ?run main Test4625418 Cp1146 - * ?run main Test4625418 Cp1147 - * ?run main Test4625418 Cp1148 - * ?run main Test4625418 Cp1149 - * @run main Test4625418 Cp1250 - * @run main Test4625418 Cp1251 - * @run main Test4625418 Cp1252 - * @run main Test4625418 Cp1253 - * @run main Test4625418 Cp1254 - * @run main Test4625418 Cp1255 - * @run main Test4625418 Cp1256 - * @run main Test4625418 Cp1257 - * @run main Test4625418 Cp1258 - * ?run main Test4625418 Cp1381 - * ?run main Test4625418 Cp1383 - * ?run main Test4625418 Cp273 - * ?run main Test4625418 Cp277 - * ?run main Test4625418 Cp278 - * ?run main Test4625418 Cp280 - * ?run main Test4625418 Cp284 - * ?run main Test4625418 Cp285 - * ?run main Test4625418 Cp297 - * ?run main Test4625418 Cp33722 - * ?run main Test4625418 Cp420 - * ?run main Test4625418 Cp424 - * @run main Test4625418 Cp437 - * ?run main Test4625418 Cp500 - * ?run main Test4625418 Cp50220 - * ?run main Test4625418 Cp50221 - * @run main Test4625418 Cp737 - * @run main Test4625418 Cp775 - * -run main Test4625418 Cp834 - * ?run main Test4625418 Cp838 - * @run main Test4625418 Cp850 - * @run main Test4625418 Cp852 - * @run main Test4625418 Cp855 - * @run main Test4625418 Cp856 - * @run main Test4625418 Cp857 - * @run main Test4625418 Cp858 - * @run main Test4625418 Cp860 - * @run main Test4625418 Cp861 - * @run main Test4625418 Cp862 - * @run main Test4625418 Cp863 - * @run main Test4625418 Cp864 - * @run main Test4625418 Cp865 - * @run main Test4625418 Cp866 - * @run main Test4625418 Cp868 - * @run main Test4625418 Cp869 - * ?run main Test4625418 Cp870 - * ?run main Test4625418 Cp871 - * @run main Test4625418 Cp874 - * ?run main Test4625418 Cp875 - * ?run main Test4625418 Cp918 - * @run main Test4625418 Cp921 - * @run main Test4625418 Cp922 - * -run main Test4625418 Cp930 - * @run main Test4625418 Cp933 - * ?run main Test4625418 Cp935 - * ?run main Test4625418 Cp937 - * ?run main Test4625418 Cp939 - * ?run main Test4625418 Cp942 - * ?run main Test4625418 Cp942C - * @run main Test4625418 Cp943 - * ?run main Test4625418 Cp943C - * @run main Test4625418 Cp948 - * @run main Test4625418 Cp949 - * ?run main Test4625418 Cp949C - * @run main Test4625418 Cp950 - * @run main Test4625418 Cp964 - * ?run main Test4625418 Cp970 - * ?run main Test4625418 EUC-JP - * @run main Test4625418 EUC-KR - * @run main Test4625418 EUC_CN - * ?run main Test4625418 EUC_JP - * ?run main Test4625418 EUC_JP_LINUX - * ?run main Test4625418 EUC_JP_Solaris - * @run main Test4625418 EUC_KR - * ?run main Test4625418 EUC_TW - * @run main Test4625418 GB18030 - * @run main Test4625418 GB2312 - * @run main Test4625418 GBK - * ?run main Test4625418 IBM-Thai - * @run main Test4625418 IBM00858 - * ?run main Test4625418 IBM01140 - * ?run main Test4625418 IBM01141 - * ?run main Test4625418 IBM01142 - * ?run main Test4625418 IBM01143 - * ?run main Test4625418 IBM01144 - * ?run main Test4625418 IBM01145 - * ?run main Test4625418 IBM01146 - * ?run main Test4625418 IBM01147 - * ?run main Test4625418 IBM01148 - * ?run main Test4625418 IBM01149 - * ?run main Test4625418 IBM037 - * -run main Test4625418 IBM1026 - * @run main Test4625418 IBM1047 - * ?run main Test4625418 IBM273 - * ?run main Test4625418 IBM277 - * ?run main Test4625418 IBM278 - * ?run main Test4625418 IBM280 - * ?run main Test4625418 IBM284 - * ?run main Test4625418 IBM285 - * ?run main Test4625418 IBM297 - * ?run main Test4625418 IBM420 - * ?run main Test4625418 IBM424 - * @run main Test4625418 IBM437 - * ?run main Test4625418 IBM500 - * @run main Test4625418 IBM775 - * @run main Test4625418 IBM850 - * @run main Test4625418 IBM852 - * @run main Test4625418 IBM855 - * @run main Test4625418 IBM857 - * @run main Test4625418 IBM860 - * @run main Test4625418 IBM861 - * @run main Test4625418 IBM862 - * @run main Test4625418 IBM863 - * @run main Test4625418 IBM864 - * @run main Test4625418 IBM865 - * @run main Test4625418 IBM866 - * @run main Test4625418 IBM868 - * @run main Test4625418 IBM869 - * ?run main Test4625418 IBM870 - * ?run main Test4625418 IBM871 - * ?run main Test4625418 IBM918 - * ?run main Test4625418 ISCII91 - * -run main Test4625418 ISO-2022-CN - * @run main Test4625418 ISO-2022-JP - * @run main Test4625418 ISO-2022-KR - * @run main Test4625418 ISO-8859-1 - * @run main Test4625418 ISO-8859-13 - * @run main Test4625418 ISO-8859-15 - * @run main Test4625418 ISO-8859-2 - * @run main Test4625418 ISO-8859-3 - * @run main Test4625418 ISO-8859-4 - * @run main Test4625418 ISO-8859-5 - * @run main Test4625418 ISO-8859-6 - * @run main Test4625418 ISO-8859-7 - * @run main Test4625418 ISO-8859-8 - * @run main Test4625418 ISO-8859-9 - * -run main Test4625418 ISO2022CN - * @run main Test4625418 ISO2022JP - * @run main Test4625418 ISO2022KR - * -run main Test4625418 ISO2022_CN_CNS - * -run main Test4625418 ISO2022_CN_GB - * @run main Test4625418 ISO8859_1 - * @run main Test4625418 ISO8859_13 - * @run main Test4625418 ISO8859_15 - * @run main Test4625418 ISO8859_2 - * @run main Test4625418 ISO8859_3 - * @run main Test4625418 ISO8859_4 - * @run main Test4625418 ISO8859_5 - * @run main Test4625418 ISO8859_6 - * @run main Test4625418 ISO8859_7 - * @run main Test4625418 ISO8859_8 - * @run main Test4625418 ISO8859_9 - * -run main Test4625418 JISAutoDetect - * ?run main Test4625418 JIS_X0201 - * -run main Test4625418 JIS_X0212-1990 - * @run main Test4625418 KOI8-R - * @run main Test4625418 KOI8-U - * @run main Test4625418 KOI8_R - * @run main Test4625418 KOI8_U - * @run main Test4625418 MS874 - * ?run main Test4625418 MS932 - * ?run main Test4625418 MS936 - * @run main Test4625418 MS949 - * @run main Test4625418 MS950 - * ?run main Test4625418 MS950_HKSCS - * @run main Test4625418 MacArabic - * @run main Test4625418 MacCentralEurope - * @run main Test4625418 MacCroatian - * @run main Test4625418 MacCyrillic - * -run main Test4625418 MacDingbat - * @run main Test4625418 MacGreek - * @run main Test4625418 MacHebrew - * @run main Test4625418 MacIceland - * @run main Test4625418 MacRoman - * @run main Test4625418 MacRomania - * -run main Test4625418 MacSymbol - * @run main Test4625418 MacThai - * @run main Test4625418 MacTurkish - * @run main Test4625418 MacUkraine - * ?run main Test4625418 PCK - * ?run main Test4625418 SJIS - * ?run main Test4625418 Shift_JIS - * @run main Test4625418 TIS-620 - * @run main Test4625418 TIS620 - * @run main Test4625418 US-ASCII - * @run main Test4625418 UTF-16 - * @run main Test4625418 UTF-16BE - * @run main Test4625418 UTF-16LE - * @run main Test4625418 UTF-32 - * @run main Test4625418 UTF-32BE - * @run main Test4625418 UTF-32LE - * @run main Test4625418 UTF-8 - * @run main Test4625418 UTF8 - * @run main Test4625418 UTF_32 - * @run main Test4625418 UTF_32BE - * -run main Test4625418 UTF_32BE_BOM - * @run main Test4625418 UTF_32LE - * -run main Test4625418 UTF_32LE_BOM - * @run main Test4625418 UnicodeBig - * @run main Test4625418 UnicodeBigUnmarked - * @run main Test4625418 UnicodeLittle - * @run main Test4625418 UnicodeLittleUnmarked - * @run main Test4625418 windows-1250 - * @run main Test4625418 windows-1251 - * @run main Test4625418 windows-1252 - * @run main Test4625418 windows-1253 - * @run main Test4625418 windows-1254 - * @run main Test4625418 windows-1255 - * @run main Test4625418 windows-1256 - * @run main Test4625418 windows-1257 - * @run main Test4625418 windows-1258 - * ?run main Test4625418 windows-31j - * -run main Test4625418 x-Big5_Solaris - * ?run main Test4625418 x-EUC-TW - * @run main Test4625418 x-IBM1006 - * ?run main Test4625418 x-IBM1025 - * @run main Test4625418 x-IBM1046 - * @run main Test4625418 x-IBM1097 - * @run main Test4625418 x-IBM1098 - * ?run main Test4625418 x-IBM1112 - * ?run main Test4625418 x-IBM1122 - * ?run main Test4625418 x-IBM1123 - * @run main Test4625418 x-IBM1124 - * ?run main Test4625418 x-IBM1381 - * ?run main Test4625418 x-IBM1383 - * ?run main Test4625418 x-IBM33722 - * @run main Test4625418 x-IBM737 - * -run main Test4625418 x-IBM834 - * @run main Test4625418 x-IBM856 - * @run main Test4625418 x-IBM874 - * ?run main Test4625418 x-IBM875 - * @run main Test4625418 x-IBM921 - * @run main Test4625418 x-IBM922 - * -run main Test4625418 x-IBM930 - * @run main Test4625418 x-IBM933 - * ?run main Test4625418 x-IBM935 - * ?run main Test4625418 x-IBM937 - * ?run main Test4625418 x-IBM939 - * ?run main Test4625418 x-IBM942 - * ?run main Test4625418 x-IBM942C - * @run main Test4625418 x-IBM943 - * ?run main Test4625418 x-IBM943C - * @run main Test4625418 x-IBM948 - * @run main Test4625418 x-IBM949 - * ?run main Test4625418 x-IBM949C - * @run main Test4625418 x-IBM950 - * @run main Test4625418 x-IBM964 - * ?run main Test4625418 x-IBM970 - * ?run main Test4625418 x-ISCII91 - * -run main Test4625418 x-ISO2022-CN-CNS - * -run main Test4625418 x-ISO2022-CN-GB - * -run main Test4625418 x-JIS0208 - * -run main Test4625418 x-JISAutoDetect - * @run main Test4625418 x-Johab - * ?run main Test4625418 x-MS950-HKSCS - * @run main Test4625418 x-MacArabic - * @run main Test4625418 x-MacCentralEurope - * @run main Test4625418 x-MacCroatian - * @run main Test4625418 x-MacCyrillic - * -run main Test4625418 x-MacDingbat - * @run main Test4625418 x-MacGreek - * @run main Test4625418 x-MacHebrew - * @run main Test4625418 x-MacIceland - * @run main Test4625418 x-MacRoman - * @run main Test4625418 x-MacRomania - * -run main Test4625418 x-MacSymbol - * @run main Test4625418 x-MacThai - * @run main Test4625418 x-MacTurkish - * @run main Test4625418 x-MacUkraine - * ?run main Test4625418 x-PCK - * @run main Test4625418 x-UTF-16LE-BOM - * -run main Test4625418 x-UTF-32BE-BOM - * -run main Test4625418 x-UTF-32LE-BOM - * ?run main Test4625418 x-euc-jp-linux - * ?run main Test4625418 x-eucJP-Open - * @run main Test4625418 x-iso-8859-11 - * @run main Test4625418 x-mswin-936 - * ?run main Test4625418 x-windows-50220 - * ?run main Test4625418 x-windows-50221 - * @run main Test4625418 x-windows-874 - * @run main Test4625418 x-windows-949 - * @run main Test4625418 x-windows-950 - * ?run main Test4625418 x-windows-iso2022jp + * @run main/timeout=360 Test4625418 */ import java.beans.ExceptionListener; import java.beans.XMLDecoder; import java.beans.XMLEncoder; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; import java.nio.charset.IllegalCharsetNameException; import java.nio.charset.UnsupportedCharsetException; public final class Test4625418 implements ExceptionListener { - public static void main(String[] args) { - new Test4625418(args[0]).test(createString(0x10000)); - System.out.println("Test passed: " + args[0]); + + private static final String[] encodings = { + "ASCII", + "Big5", + //"Big5-HKSCS", + //"Big5_HKSCS", + "Big5_Solaris", + //"Cp037", + "Cp1006", + //"Cp1025", + //"Cp1026", + "Cp1046", + "Cp1047", + "Cp1097", + "Cp1098", + //"Cp1112", + //"Cp1122", + //"Cp1123", + "Cp1124", + //"Cp1140", + //"Cp1141", + //"Cp1142", + //"Cp1143", + //"Cp1144", + //"Cp1145", + //"Cp1146", + //"Cp1147", + //"Cp1148", + //"Cp1149", + "Cp1250", + "Cp1251", + "Cp1252", + "Cp1253", + "Cp1254", + "Cp1255", + "Cp1256", + "Cp1257", + "Cp1258", + //"Cp1381", + //"Cp1383", + //"Cp273", + //"Cp277", + //"Cp278", + //"Cp280", + //"Cp284", + //"Cp285", + //"Cp297", + //"Cp33722", + //"Cp420", + //"Cp424", + "Cp437", + //"Cp500", + //"Cp50220", + //"Cp50221", + "Cp737", + "Cp775", + //"Cp834", + //"Cp838", + "Cp850", + "Cp852", + "Cp855", + "Cp856", + "Cp857", + "Cp858", + "Cp860", + "Cp861", + "Cp862", + "Cp863", + "Cp864", + "Cp865", + "Cp866", + "Cp868", + "Cp869", + //"Cp870", + //"Cp871", + "Cp874", + //"Cp875", + //"Cp918", + "Cp921", + "Cp922", + //"Cp930", + "Cp933", + //"Cp935", + //"Cp937", + //"Cp939", + //"Cp942", + //"Cp942C", + "Cp943", + //"Cp943C", + "Cp948", + "Cp949", + //"Cp949C", + "Cp950", + "Cp964", + //"Cp970", + //"EUC-JP", + "EUC-KR", + "EUC_CN", + //"EUC_JP", + //"EUC_JP_LINUX", + //"EUC_JP_Solaris", + "EUC_KR", + //"EUC_TW", + "GB18030", + "GB2312", + "GBK", + //"IBM-Thai", + "IBM00858", + //"IBM01140", + //"IBM01141", + //"IBM01142", + //"IBM01143", + //"IBM01144", + //"IBM01145", + //"IBM01146", + //"IBM01147", + //"IBM01148", + //"IBM01149", + //"IBM037", + //"IBM1026", + "IBM1047", + //"IBM273", + //"IBM277", + //"IBM278", + //"IBM280", + //"IBM284", + //"IBM285", + //"IBM297", + //"IBM420", + //"IBM424", + "IBM437", + //"IBM500", + "IBM775", + "IBM850", + "IBM852", + "IBM855", + "IBM857", + "IBM860", + "IBM861", + "IBM862", + "IBM863", + "IBM864", + "IBM865", + "IBM866", + "IBM868", + "IBM869", + //"IBM870", + //"IBM871", + //"IBM918", + //"ISCII91", + //"ISO-2022-CN", + "ISO-2022-JP", + "ISO-2022-KR", + "ISO-8859-1", + "ISO-8859-13", + "ISO-8859-15", + "ISO-8859-2", + "ISO-8859-3", + "ISO-8859-4", + "ISO-8859-5", + "ISO-8859-6", + "ISO-8859-7", + "ISO-8859-8", + "ISO-8859-9", + //"ISO2022CN", + "ISO2022JP", + "ISO2022KR", + //"ISO2022_CN_CNS", + //"ISO2022_CN_GB", + "ISO8859_1", + "ISO8859_13", + "ISO8859_15", + "ISO8859_2", + "ISO8859_3", + "ISO8859_4", + "ISO8859_5", + "ISO8859_6", + "ISO8859_7", + "ISO8859_8", + "ISO8859_9", + //"JISAutoDetect", + //"JIS_X0201", + //"JIS_X0212-1990", + "KOI8-R", + "KOI8-U", + "KOI8_R", + "KOI8_U", + "MS874", + //"MS932", + //"MS936", + "MS949", + "MS950", + //"MS950_HKSCS", + "MacArabic", + "MacCentralEurope", + "MacCroatian", + "MacCyrillic", + //"MacDingbat", + "MacGreek", + "MacHebrew", + "MacIceland", + "MacRoman", + "MacRomania", + //"MacSymbol", + "MacThai", + "MacTurkish", + "MacUkraine", + //"PCK", + //"SJIS", + //"Shift_JIS", + "TIS-620", + "TIS620", + "US-ASCII", + "UTF-16", + "UTF-16BE", + "UTF-16LE", + "UTF-32", + "UTF-32BE", + "UTF-32LE", + "UTF-8", + "UTF8", + "UTF_32", + "UTF_32BE", + //"UTF_32BE_BOM", + "UTF_32LE", + //"UTF_32LE_BOM", + "UnicodeBig", + "UnicodeBigUnmarked", + "UnicodeLittle", + "UnicodeLittleUnmarked", + "windows-1250", + "windows-1251", + "windows-1252", + "windows-1253", + "windows-1254", + "windows-1255", + "windows-1256", + "windows-1257", + "windows-1258", + //"windows-31j", + //"x-Big5_Solaris", + //"x-EUC-TW", + "x-IBM1006", + //"x-IBM1025", + "x-IBM1046", + "x-IBM1097", + "x-IBM1098", + //"x-IBM1112", + //"x-IBM1122", + //"x-IBM1123", + "x-IBM1124", + //"x-IBM1381", + //"x-IBM1383", + //"x-IBM33722", + "x-IBM737", + //"x-IBM834", + "x-IBM856", + "x-IBM874", + //"x-IBM875", + "x-IBM921", + "x-IBM922", + //"x-IBM930", + "x-IBM933", + //"x-IBM935", + //"x-IBM937", + //"x-IBM939", + //"x-IBM942", + //"x-IBM942C", + "x-IBM943", + //"x-IBM943C", + "x-IBM948", + "x-IBM949", + //"x-IBM949C", + "x-IBM950", + "x-IBM964", + //"x-IBM970", + //"x-ISCII91", + //"x-ISO2022-CN-CNS", + //"x-ISO2022-CN-GB", + //"x-JIS0208", + //"x-JISAutoDetect", + "x-Johab", + //"x-MS950-HKSCS", + "x-MacArabic", + "x-MacCentralEurope", + "x-MacCroatian", + "x-MacCyrillic", + //"x-MacDingbat", + "x-MacGreek", + "x-MacHebrew", + "x-MacIceland", + "x-MacRoman", + "x-MacRomania", + //"x-MacSymbol", + "x-MacThai", + "x-MacTurkish", + "x-MacUkraine", + //"x-PCK", + "x-UTF-16LE-BOM", + //"x-UTF-32BE-BOM", + //"x-UTF-32LE-BOM", + //"x-euc-jp-linux", + //"x-eucJP-Open", + "x-iso-8859-11", + "x-mswin-936", + //"x-windows-50220", + //"x-windows-50221", + "x-windows-874", + "x-windows-949", + "x-windows-950", + //"x-windows-iso2022jp", + }; + + public static void main(final String[] args) { + final String string = createString(0x10000); + for (String encoding : encodings) { + System.out.println("Test encoding: " + encoding); + new Test4625418(encoding).test(string); + } } private static String createString(int length) { @@ -364,33 +370,27 @@ public final class Test4625418 implements ExceptionListener { private final String encoding; - private Test4625418(String encoding) { + private Test4625418(final String encoding) { this.encoding = encoding; } private void test(String string) { try { - File file = new File("4625418." + this.encoding + ".xml"); - - FileOutputStream output = new FileOutputStream(file); + ByteArrayOutputStream output = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder(output, this.encoding, true, 0); encoder.setExceptionListener(this); encoder.writeObject(string); encoder.close(); - FileInputStream input = new FileInputStream(file); + InputStream input = new ByteArrayInputStream(output.toByteArray()); XMLDecoder decoder = new XMLDecoder(input); decoder.setExceptionListener(this); Object object = decoder.readObject(); decoder.close(); - if (!string.equals(object)) + if (!string.equals(object)) { throw new Error(this.encoding + " - can't read properly"); - - file.delete(); - } - catch (FileNotFoundException exception) { - throw new Error(this.encoding + " - file not found", exception); + } } catch (IllegalCharsetNameException exception) { throw new Error(this.encoding + " - illegal charset name", exception); -- GitLab From 6fd98f9b985399fe5ab818066fe8a080b30b5949 Mon Sep 17 00:00:00 2001 From: Ambarish Rapte Date: Thu, 5 May 2016 14:44:25 +0300 Subject: [PATCH 055/400] 6384991: TrayIcon ActionListener called at wrong time Reviewed-by: rchamyal, serb --- .../classes/sun/awt/X11/XTrayIconPeer.java | 2 +- .../TrayIconMouseTest/TrayIconMouseTest.java | 135 ++++++++++-------- 2 files changed, 76 insertions(+), 61 deletions(-) diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java index 20b7a9d7899..fa1ba5dcf03 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XTrayIconPeer.java @@ -464,7 +464,7 @@ public class XTrayIconPeer implements TrayIconPeer, XToolkit.postEvent(XToolkit.targetToAppContext(e.getSource()), e); } public void mouseClicked(MouseEvent e) { - if ((e.getClickCount() > 1 || xtiPeer.balloon.isVisible()) && + if ((e.getClickCount() == 1 || xtiPeer.balloon.isVisible()) && e.getButton() == MouseEvent.BUTTON1) { ActionEvent aev = new ActionEvent(xtiPeer.target, ActionEvent.ACTION_PERFORMED, diff --git a/jdk/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java b/jdk/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java index 551878efb04..f7549a385eb 100644 --- a/jdk/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java +++ b/jdk/test/java/awt/TrayIcon/TrayIconMouseTest/TrayIconMouseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,16 +21,19 @@ * questions. */ -import java.awt.*; -import java.awt.event.*; +import java.awt.EventQueue; +import java.awt.Point; +import java.awt.SystemTray; +import java.awt.TrayIcon; +import java.awt.event.InputEvent; import java.awt.image.BufferedImage; /* - * @test - * @summary Check if ActionEvent is triggered by a TrayIcon only when - * it is double clicked using mouse button 1 (or single clicked - * with button 3 (on Mac OS X)) - * @author Dmitriy Ermashov (dmitriy.ermashov@oracle.com) + * @test 6384991 + * @summary Check if ActionEvent is triggered by a TrayIcon when + * it is double clicked with mouse button 1 on windows + * or single clicked with button 3 on Mac OS X + * or single clicked with button 1 on rest. * @library /java/awt/patchlib * @library ../../../../lib/testlibrary ../ * @build java.desktop/java.awt.Helper @@ -42,19 +45,17 @@ public class TrayIconMouseTest { TrayIcon icon; ExtendedRobot robot; - boolean actionPerformed = false; Object actionLock = new Object(); static boolean isMacOS = false; - + static boolean isWinOS = false; + static boolean isOelOS = false; String caption = "Sample Icon"; - int[] buttonTypes = { InputEvent.BUTTON1_MASK, InputEvent.BUTTON2_MASK, InputEvent.BUTTON3_MASK }; - String[] buttonNames = { "BUTTON1", "BUTTON2", @@ -62,30 +63,31 @@ public class TrayIconMouseTest { }; public static void main(String[] args) throws Exception { - if (! SystemTray.isSupported()) { - System.out.println("SystemTray not supported on the platform under test. " + - "Marking the test passed"); + if (!SystemTray.isSupported()) { + System.out.println("SystemTray not supported on the platform " + + "under test. Marking the test passed"); } else { - if (System.getProperty("os.name").toLowerCase().startsWith("mac")) { + String osName = System.getProperty("os.name").toLowerCase(); + if (osName.startsWith("mac")) { isMacOS = true; - } else if (SystemTrayIconHelper.isOel7()) { - System.out.println("OEL 7 doesn't support double click in " + - "systray. Skipped"); - return; + } else if (osName.startsWith("win")) { + isWinOS = true; + } else { + isOelOS = SystemTrayIconHelper.isOel7(); } new TrayIconMouseTest().doTest(); } } - TrayIconMouseTest() throws Exception{ + TrayIconMouseTest() throws Exception { robot = new ExtendedRobot(); EventQueue.invokeAndWait(this::initializeGUI); } void initializeGUI() { - SystemTray tray = SystemTray.getSystemTray(); - icon = new TrayIcon(new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), caption); + icon = new TrayIcon( + new BufferedImage(20, 20, BufferedImage.TYPE_INT_RGB), caption); icon.addActionListener(event -> { actionPerformed = true; synchronized (actionLock) { @@ -103,31 +105,32 @@ public class TrayIconMouseTest { } private void doTest() throws Exception { - Point iconPosition = SystemTrayIconHelper.getTrayIconLocation(icon); - if (iconPosition == null) + if (iconPosition == null) { throw new RuntimeException("Unable to find the icon location!"); - + } robot.mouseMove(iconPosition.x, iconPosition.y); robot.waitForIdle(); for (int i = 0; i < buttonTypes.length; i++) { actionPerformed = false; robot.click(buttonTypes[i]); - robot.waitForIdle(6000); - - if (isMacOS && actionPerformed && i == 2) { - - }else if (isMacOS && i == 2) { - throw new RuntimeException("FAIL: ActionEvent NOT triggered when " + - buttonNames[i] + " is single clicked on Mac OS"); - }else if (actionPerformed) { - throw new RuntimeException("FAIL: ActionEvent triggered when " + - buttonNames[i] + " is single clicked"); + robot.waitForIdle(); + delayIfRequired(); + + if (isMacOS && i == 2 && !actionPerformed) { + throw new RuntimeException("FAIL: ActionEvent NOT triggered " + + "when " + buttonNames[i] + " is single clicked on Mac"); + } else if (isWinOS && actionPerformed) { + throw new RuntimeException("FAIL: ActionEvent triggered " + + "when " + buttonNames[i] + " is single clicked"); + } else if (!isMacOS && !isWinOS && i == 0 && !actionPerformed) { + throw new RuntimeException("FAIL: ActionEvent NOT triggered " + + "when " + buttonNames[i] + " is single clicked"); } } - if(!isMacOS) { + if (!isMacOS && !isOelOS) { for (int i = 0; i < buttonTypes.length; i++) { for (int j = 0; j < buttonTypes.length; j++) { if (j != i) { @@ -136,13 +139,22 @@ public class TrayIconMouseTest { robot.mousePress(buttonTypes[j]); robot.mouseRelease(buttonTypes[j]); robot.mouseRelease(buttonTypes[i]); - robot.waitForIdle(); + delayIfRequired(); + + if (isWinOS) { + if (actionPerformed) { + throw new RuntimeException( + "FAIL: ActionEvent triggered when " + + buttonNames[i] + " & " + buttonNames[j] + + " is clicked and released"); + } - if (actionPerformed) - throw new RuntimeException("FAIL: ActionEvent triggered when " + - buttonNames[i] + " and " + buttonNames[j] + - " is clicked and released"); + } else if ((i == 0 || j == 0) && !actionPerformed) { + throw new RuntimeException("FAIL: ActionEvent is " + + "NOT triggered when " + buttonNames[i] + " & " + + buttonNames[j] + " is pressed & released"); + } } } } @@ -150,31 +162,34 @@ public class TrayIconMouseTest { for (int i = 0; i < buttonTypes.length; i++) { actionPerformed = false; robot.mousePress(buttonTypes[i]); - robot.delay(50); robot.mouseRelease(buttonTypes[i]); robot.delay(50); robot.mousePress(buttonTypes[i]); - robot.delay(50); robot.mouseRelease(buttonTypes[i]); + robot.waitForIdle(); + delayIfRequired(); if (i == 0) { - if (! actionPerformed) { - synchronized (actionLock) { - try { - actionLock.wait(6000); - } catch (Exception e) { - } - } + if (!actionPerformed) { + throw new RuntimeException("FAIL: ActionEvent not " + + "triggered when " + buttonNames[i] + + " is double clicked"); } - if (! actionPerformed) - throw new RuntimeException("FAIL: ActionEvent not triggered when " + - buttonNames[i] + " is double clicked"); - } else { - robot.waitForIdle(); - - if (actionPerformed) - throw new RuntimeException("FAIL: ActionEvent triggered when " + - buttonNames[i] + " is double clicked"); + } else if (actionPerformed) { + throw new RuntimeException("FAIL: ActionEvent " + + "triggered when " + buttonNames[i] + + " is double clicked"); + } + } + } + } + + public void delayIfRequired() { + if (!actionPerformed) { + synchronized (actionLock) { + try { + actionLock.wait(500); + } catch (Exception e) { } } } -- GitLab From 08482543b496efa11dc8084a14a831799de60a93 Mon Sep 17 00:00:00 2001 From: Ambarish Rapte Date: Thu, 5 May 2016 14:56:42 +0300 Subject: [PATCH 056/400] 8155742: [Windows] robot.keyPress(KeyEvent.VK_ALT_GRAPH) throws java.lang.IllegalArgumentException in windows Reviewed-by: rchamyal, serb --- .../native/libawt/windows/awt_Component.cpp | 1 + .../native/libawt/windows/awt_Robot.cpp | 3 +++ .../ModifierRobotKeyTest.java | 26 ++++++++++++------- .../AltGraphModifierTest.java | 8 ++---- 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp index 746b1114488..781d4c5201e 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Component.cpp @@ -2720,6 +2720,7 @@ KeyMapEntry keyMapTable[] = { {java_awt_event_KeyEvent_VK_SHIFT, VK_SHIFT}, {java_awt_event_KeyEvent_VK_CONTROL, VK_CONTROL}, {java_awt_event_KeyEvent_VK_ALT, VK_MENU}, + {java_awt_event_KeyEvent_VK_ALT_GRAPH, VK_RMENU}, {java_awt_event_KeyEvent_VK_NUM_LOCK, VK_NUMLOCK}, // Miscellaneous Windows keys diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp index 0528148e23e..3baf7f7448c 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_Robot.cpp @@ -335,6 +335,9 @@ void AwtRobot::DoKeyEvent( jint jkey, DWORD dwFlags ) } else { // get the scancode from the virtual key scancode = ::MapVirtualKey(vkey, 0); + if (vkey == VK_RMENU) { + dwFlags |= KEYEVENTF_EXTENDEDKEY; + } keybd_event(vkey, scancode, dwFlags, 0); } } diff --git a/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java b/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java index 5cdc8085255..1e941473061 100644 --- a/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java +++ b/jdk/test/java/awt/Robot/ModifierRobotKey/ModifierRobotKeyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,17 +21,23 @@ * questions. */ - -import java.awt.*; -import java.awt.event.*; +import java.awt.BorderLayout; +import java.awt.Canvas; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseEvent; import static jdk.testlibrary.Asserts.assertTrue; /* - * @test + * @test 8155742 * @summary Make sure that modifier key mask is set when robot press - * some key with one or more modifiers. - * + * some key with one or more modifiers. * @library ../../../../lib/testlibrary/ * @build ExtendedRobot * @run main ModifierRobotKeyTest @@ -60,15 +66,17 @@ public class ModifierRobotKeyTest extends KeyAdapter { } public ModifierRobotKeyTest() throws Exception { - modifierKeys = new int[3]; + modifierKeys = new int[4]; modifierKeys[0] = KeyEvent.VK_SHIFT; modifierKeys[1] = KeyEvent.VK_CONTROL; modifierKeys[2] = KeyEvent.VK_ALT; + modifierKeys[3] = KeyEvent.VK_ALT_GRAPH; - inputMasks = new int[3]; + inputMasks = new int[4]; inputMasks[0] = InputEvent.SHIFT_MASK; inputMasks[1] = InputEvent.CTRL_MASK; inputMasks[2] = InputEvent.ALT_MASK; + inputMasks[3] = InputEvent.ALT_GRAPH_MASK; modifierStatus = new boolean[modifierKeys.length]; diff --git a/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java b/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java index 00c471ad7f4..11cd886d598 100644 --- a/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java +++ b/jdk/test/java/awt/event/MouseEvent/AltGraphModifierTest/AltGraphModifierTest.java @@ -44,12 +44,8 @@ public class AltGraphModifierTest { = { "This test is for verifying Alt-Gr modifier of an event.", "Windows :-", - "1. Please check if Alt-Gr key is present on keyboard.", - "2. If present, press the Alt-Gr key and perform", - " mouse click on the TestWindow.", - "3. If Alt-Gr key is not present, press Ctrl+Alt keys &", - " perform mouse click on the TestWindow.", - "4. Test will exit by itself with appropriate result.", + "1. Click Pass.", + "2. Alt-Gr modifier is tested under Robot tests.", " ", "Linux :-", "1. Please check if Alt-Gr key is present on keyboard.", -- GitLab From b1cc284a24642d5d53e8eddb670d98367131c67b Mon Sep 17 00:00:00 2001 From: Manajit Halder Date: Thu, 5 May 2016 16:08:34 +0300 Subject: [PATCH 057/400] 8137137: [macosx] The native dialog doesn't have 'close'(X) button on Mac Reviewed-by: psadhukhan, prr --- .../RestoreActiveWindowTest.html | 43 -- .../RestoreActiveWindowTest.java | 378 +++++++++--------- 2 files changed, 181 insertions(+), 240 deletions(-) delete mode 100644 jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.html diff --git a/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.html b/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.html deleted file mode 100644 index 9973c033612..00000000000 --- a/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - -RestoreActiveWindowTest - - - -

      RestoreActiveWindowTest
      Bug ID: 6365992

      - -

      See the dialog box (usually in upper left corner) for instructions

      - - - - diff --git a/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.java b/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.java index 66e4148931c..8d29dbb5849 100644 --- a/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.java +++ b/jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,210 +22,194 @@ */ /* - test - @bug 6365992 6379599 - @summary REG: Showing and disposing a native print dialog makes the main frame inactive, Win32 - @author Dmitry.Cherepanov@SUN.COM area=awt.printdialog - @run applet/manual=yesno RestoreActiveWindowTest.html -*/ - -import java.applet.Applet; -import java.awt.*; -import java.awt.event.*; -import java.awt.print.*; -import javax.print.attribute.*; - -public class RestoreActiveWindowTest extends Applet -{ - Button showBtn1 = new Button("show a native print dialog"); - Button showBtn2 = new Button("show a native page dialog"); - - public void init() - { - showBtn1.addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent ae) { - PrinterJob.getPrinterJob().printDialog(); - } - }); - showBtn2.addActionListener(new ActionListener(){ - public void actionPerformed(ActionEvent ae){ - PrinterJob.getPrinterJob().pageDialog(new PageFormat()); - } - }); - - add(showBtn1); - add(showBtn2); - - String[] instructions = { - "1.1) Click on 'show a native print dialog'. A native print dialog will come up.", - "1.2) Click on the 'close'(X) button. The dialog will be closed.", - "1.3) After the dialog closing another window should become the active window.", - "1.4) If there no any active window then the test failed.", - "2.1) Click on 'show a native page dialog'. A native page dialog will come up.", - "2.2) Click on the 'close'(X) button. The dialog will be closed.", - "2.3) After the dialog closing another window should become the active window.", - "2.4) If there no any active window then the test failed.", - "3) Test Passed." - }; - - Sysout.createDialogWithInstructions( instructions ); - - }//End init() - - public void start () - { - //Get things going. Request focus, set size, et cetera - setSize (200,200); - show(); - - }// start() - - //The rest of this class is the actions which perform the test... - - //Use Sysout.println to communicate with the user NOT System.out!! - //Sysout.println ("Something Happened!"); - -}// class ManualYesNoTest - -/* Place other classes related to the test after this line */ - - - - - -/**************************************************** - Standard Test Machinery - DO NOT modify anything below -- it's a standard - chunk of code whose purpose is to make user - interaction uniform, and thereby make it simpler - to read and understand someone else's test. - ****************************************************/ - -/** - This is part of the standard test machinery. - It creates a dialog (with the instructions), and is the interface - for sending text messages to the user. - To print the instructions, send an array of strings to Sysout.createDialog - WithInstructions method. Put one line of instructions per array entry. - To display a message for the tester to see, simply call Sysout.println - with the string to be displayed. - This mimics System.out.println but works within the test harness as well - as standalone. + * @test + * @bug 6365992 6379599 8137137 + * @summary REG: Showing and disposing a native print dialog makes the main + * frame inactive, Win32 + * @run main/manual RestoreActiveWindowTest */ - -class Sysout -{ - private static TestDialog dialog; - - public static void createDialogWithInstructions( String[] instructions ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - dialog.printInstructions( instructions ); - dialog.setVisible(true); - println( "Any messages for the tester will display here." ); +import java.awt.Frame; +import java.awt.Button; +import java.awt.GridBagLayout; +import java.awt.Panel; +import java.awt.TextArea; +import java.awt.GridLayout; +import java.awt.GridBagConstraints; +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PrinterJob; +import java.awt.print.PageFormat; + +public class RestoreActiveWindowTest implements ActionListener { + + private static Frame mainFrame; + private static Button printDialogButton; + private static Button pageDialogButton; + private static Frame instructionFrame; + private static GridBagLayout layout; + private static Panel mainControlPanel; + private static Panel resultButtonPanel; + private static TextArea instructionTextArea; + private static Button passButton; + private static Button failButton; + private static Thread mainThread = null; + private static boolean testPassed = false; + private static boolean isInterrupted = false; + private static final int testTimeOut = 300000; + private static String testFailMessage; + + public void createAndShowGUI() { + mainFrame = new Frame("Test"); + mainFrame.setSize(200, 200); + mainFrame.setLocationRelativeTo(null); + mainFrame.setLayout(new GridLayout(2, 1)); + + printDialogButton = new Button("show a native print dialog"); + pageDialogButton = new Button("show a native page dialog"); + printDialogButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ae) { + PrinterJob.getPrinterJob().printDialog(); + setButtonEnable(true); + testFailMessage = "Print dialog test failed."; + } + }); + pageDialogButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent ae) { + PrinterJob.getPrinterJob().pageDialog(new PageFormat()); + setButtonEnable(true); + testFailMessage = "Page dialog test failed."; + } + }); + + mainFrame.add(printDialogButton); + mainFrame.add(pageDialogButton); + mainFrame.setVisible(true); + + mainFrame.addWindowListener(new WindowAdapter() { + public void windowClosing(WindowEvent we) { + cleanUp(); + throw new RuntimeException("User has closed the test window " + + "without clicking Pass or Fail."); + } + }); } - public static void createDialog( ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - String[] defInstr = { "Instructions will appear here. ", "" } ; - dialog.printInstructions( defInstr ); - dialog.setVisible(true); - println( "Any messages for the tester will display here." ); + private void createInstructionUI() { + instructionFrame = new Frame("Native Print Dialog and Page Dialog"); + layout = new GridBagLayout(); + mainControlPanel = new Panel(layout); + resultButtonPanel = new Panel(layout); + + GridBagConstraints gbc = new GridBagConstraints(); + String instructions + = "\nINSTRUCTIONS:\n" + + "\n 1. Click on the 'show a native print dialog' button. A " + + "native print dialog will come up." + + "\n 2. Click on the 'Cancel' button on Mac OS X or " + + "'close'(X) on other paltforms. Dialog will be closed." + + "\n 3. After the dialog is closed another window should " + + "become the active window." + + "\n 4. If there no any active window then the test has " + + "failed. Click on 'Fail' Button." + + "\n 5. Click on the 'show a native page dialog' button. A " + + "native page dialog will come up." + + "\n 6. Click on the 'Cancel' button on Mac OS X or " + + "'close'(X) on other paltforms. Dialog will be closed." + + "\n 7. After the dialog is closed another window should " + + "become the active window." + + "\n 8. If there no any active window then the test has " + + "failed. Click on 'Fail' Button." + + "\n 9. Test Passed. Click on 'Pass' Button."; + + instructionTextArea = new TextArea(13, 80); + instructionTextArea.setText(instructions); + instructionTextArea.setEnabled(false); + instructionTextArea.setBackground(Color.white); + + gbc.gridx = 0; + gbc.gridy = 0; + gbc.weightx = 0.5; + gbc.fill = GridBagConstraints.HORIZONTAL; + mainControlPanel.add(instructionTextArea, gbc); + + passButton = new Button("Pass"); + passButton.setName("Pass"); + passButton.addActionListener((ActionListener) this); + + failButton = new Button("Fail"); + failButton.setName("Fail"); + failButton.addActionListener((ActionListener) this); + + setButtonEnable(false); + + gbc.gridx = 0; + gbc.gridy = 0; + resultButtonPanel.add(passButton, gbc); + gbc.gridx = 1; + gbc.gridy = 0; + resultButtonPanel.add(failButton, gbc); + gbc.gridx = 0; + gbc.gridy = 1; + mainControlPanel.add(resultButtonPanel, gbc); + + instructionFrame.add(mainControlPanel); + instructionFrame.pack(); + instructionFrame.setVisible(true); } - - public static void printInstructions( String[] instructions ) - { - dialog.printInstructions( instructions ); + @Override + public void actionPerformed(ActionEvent ae) { + if (ae.getSource() instanceof Button) { + Button btn = (Button) ae.getSource(); + switch (btn.getName()) { + case "Pass": + testPassed = true; + isInterrupted = true; + mainThread.interrupt(); + break; + case "Fail": + testPassed = false; + isInterrupted = true; + mainThread.interrupt(); + break; + } + } } - - public static void println( String messageIn ) - { - dialog.displayMessage( messageIn ); + private static void setButtonEnable(boolean status) { + passButton.setEnabled(status); + failButton.setEnabled(status); } -}// Sysout class - -/** - This is part of the standard test machinery. It provides a place for the - test instructions to be displayed, and a place for interactive messages - to the user to be displayed. - To have the test instructions displayed, see Sysout. - To have a message to the user be displayed, see Sysout. - Do not call anything in this dialog directly. - */ -class TestDialog extends Dialog -{ - - TextArea instructionsText; - TextArea messageText; - int maxStringLength = 80; - - //DO NOT call this directly, go through Sysout - public TestDialog( Frame frame, String name ) - { - super( frame, name ); - int scrollBoth = TextArea.SCROLLBARS_BOTH; - instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); - add( "North", instructionsText ); - - messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); - add("Center", messageText); - - pack(); - - setVisible(true); - }// TestDialog() - - //DO NOT call this directly, go through Sysout - public void printInstructions( String[] instructions ) - { - //Clear out any current instructions - instructionsText.setText( "" ); - - //Go down array of instruction strings - - String printStr, remainingStr; - for( int i=0; i < instructions.length; i++ ) - { - //chop up each into pieces maxSringLength long - remainingStr = instructions[ i ]; - while( remainingStr.length() > 0 ) - { - //if longer than max then chop off first max chars to print - if( remainingStr.length() >= maxStringLength ) - { - //Try to chop on a word boundary - int posOfSpace = remainingStr. - lastIndexOf( ' ', maxStringLength - 1 ); - - if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; - - printStr = remainingStr.substring( 0, posOfSpace + 1 ); - remainingStr = remainingStr.substring( posOfSpace + 1 ); - } - //else just print - else - { - printStr = remainingStr; - remainingStr = ""; - } - - instructionsText.append( printStr + "\n" ); - - }// while - - }// for - - }//printInstructions() - - //DO NOT call this directly, go through Sysout - public void displayMessage( String messageIn ) - { - messageText.append( messageIn + "\n" ); - System.out.println(messageIn); + private static void cleanUp() { + mainFrame.dispose(); + instructionFrame.dispose(); } -}// TestDialog class + public static void main(String args[]) { + RestoreActiveWindowTest printDialogs = new RestoreActiveWindowTest(); + printDialogs.createInstructionUI(); + printDialogs.createAndShowGUI(); + + mainThread = Thread.currentThread(); + try { + mainThread.sleep(testTimeOut); + } catch (InterruptedException ex) { + if (!testPassed) { + throw new RuntimeException(testFailMessage); + } + } finally { + cleanUp(); + } + + if (!isInterrupted) { + throw new RuntimeException("Test Timed out after " + + testTimeOut / 1000 + " seconds"); + } + } +} -- GitLab From b1cc5f555f68a14f4c2c18c6d8518c9d4d3f5356 Mon Sep 17 00:00:00 2001 From: Ambarish Rapte Date: Fri, 6 May 2016 17:43:36 +0300 Subject: [PATCH 058/400] 8154328: [TEST_BUG] java/awt/TrayIcon/ActionEventTest/ActionEventTest.java Reviewed-by: serb, rchamyal --- .../ActionEventTest/ActionEventTest.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java b/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java index 7a5f87a38f3..95879ce4f80 100644 --- a/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java +++ b/jdk/test/java/awt/TrayIcon/ActionEventTest/ActionEventTest.java @@ -23,10 +23,13 @@ /* * @test - * @bug 6191390 + * @bug 6191390 8154328 * @summary Verify that ActionEvent is received with correct modifiers set. * @library ../../../../lib/testlibrary ../ + * @library /java/awt/patchlib + * @build java.desktop/java.awt.Helper * @build ExtendedRobot SystemTrayIconHelper + * @run main ActionEventTest */ import java.awt.Image; @@ -46,6 +49,7 @@ public class ActionEventTest { Image image; TrayIcon icon; Robot robot; + boolean actionPerformed; public static void main(String[] args) throws Exception { if (!SystemTray.isSupported()) { @@ -82,6 +86,7 @@ public class ActionEventTest { icon.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { + actionPerformed = true; int md = ae.getModifiers(); int expectedMask = ActionEvent.ALT_MASK | ActionEvent.CTRL_MASK | ActionEvent.SHIFT_MASK; @@ -102,6 +107,9 @@ public class ActionEventTest { } public void clear() { + robot.keyRelease(KeyEvent.VK_ALT); + robot.keyRelease(KeyEvent.VK_SHIFT); + robot.keyRelease(KeyEvent.VK_CONTROL); SystemTray.getSystemTray().remove(icon); } @@ -123,10 +131,9 @@ public class ActionEventTest { robot.delay(100); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - robot.delay(100); robot.waitForIdle(); - robot.keyRelease(KeyEvent.VK_ALT); - robot.keyRelease(KeyEvent.VK_SHIFT); - robot.keyRelease(KeyEvent.VK_CONTROL); + if (!actionPerformed) { + robot.delay(500); + } } } -- GitLab From 144b4fb478e0da86303c6d63d162664c63ae48e9 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Fri, 6 May 2016 12:57:37 -0700 Subject: [PATCH 059/400] 8156459: SimpleCMYKColorSpace serialVersionUID is inappropriate Generate an appropriate value using the 'serialver' command. Reviewed-by: prr --- .../com/sun/imageio/plugins/common/SimpleCMYKColorSpace.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SimpleCMYKColorSpace.java b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SimpleCMYKColorSpace.java index a1097b3853e..db96e67bb1d 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SimpleCMYKColorSpace.java +++ b/jdk/src/java.desktop/share/classes/com/sun/imageio/plugins/common/SimpleCMYKColorSpace.java @@ -31,7 +31,7 @@ import java.awt.color.ColorSpace; * color space. */ public final class SimpleCMYKColorSpace extends ColorSpace { - private static final long serialVersionUID = 666L; // XXX Revise UID value + private static final long serialVersionUID = 5387117338644522424L; private static ColorSpace theInstance = null; private ColorSpace csRGB; -- GitLab From 6b75dd66682413d460c7ccb46906d9bc0ec4865a Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Mon, 9 May 2016 12:55:03 +0300 Subject: [PATCH 060/400] 8155071: AppletViewer should print the deprecation warning that the Applet API is deprecated Reviewed-by: prr, smarks --- .../share/classes/sun/applet/resources/MsgAppletViewer.java | 2 +- .../applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/sun/applet/resources/MsgAppletViewer.java b/jdk/src/java.desktop/share/classes/sun/applet/resources/MsgAppletViewer.java index 2b2bf2de74f..d9ba0253213 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/resources/MsgAppletViewer.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/resources/MsgAppletViewer.java @@ -73,7 +73,7 @@ public class MsgAppletViewer extends ListResourceBundle { {"appletviewer.parse.warning.embed.requiresheight", "Warning: tag requires height attribute."}, {"appletviewer.parse.warning.embed.requireswidth", "Warning: tag requires width attribute."}, {"appletviewer.parse.warning.appnotLongersupported", "Warning: tag no longer supported, use instead:"}, - {"appletviewer.deprecated", "AppletViewer is deprecated."}, + {"appletviewer.deprecated", "Warning: Applet API and AppletViewer are deprecated."}, {"appletviewer.usage", "Usage: appletviewer url(s)\n\nwhere include:\n -encoding Specify character encoding used by HTML files\n -J Pass argument to the java interpreter\n\nThe -J option is non-standard and subject to change without notice."}, {"appletviewer.main.err.unsupportedopt", "Unsupported option: {0}"}, {"appletviewer.main.err.unrecognizedarg", "Unrecognized argument: {0}"}, diff --git a/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java b/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java index 3c491011794..27cf0330389 100644 --- a/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java +++ b/jdk/test/sun/applet/DeprecatedAppletViewer/DeprecatedAppletViewer.java @@ -32,7 +32,8 @@ import java.io.PrintStream; */ public final class DeprecatedAppletViewer { - private static final String TEXT = "AppletViewer is deprecated."; + private static final String TEXT + = "Warning: Applet API and AppletViewer are deprecated."; public static void main(final String[] args) { final PrintStream old = System.err; -- GitLab From 35d36c1c1016298c9c12ea88fd20cd5e94fb532a Mon Sep 17 00:00:00 2001 From: Phil Race Date: Mon, 9 May 2016 09:53:55 -0700 Subject: [PATCH 061/400] 8155682: Get rid of legacy Windows Flags for DX Reviewed-by: serb, jgodinez --- .../sun/java2d/windows/WindowsFlags.java | 43 +------------------ .../libawt/java2d/windows/WindowsFlags.cpp | 15 ------- .../libawt/java2d/windows/WindowsFlags.h | 3 -- 3 files changed, 1 insertion(+), 60 deletions(-) diff --git a/jdk/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java b/jdk/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java index 4973ac389bd..8fc1a827e38 100644 --- a/jdk/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java +++ b/jdk/src/java.desktop/windows/classes/sun/java2d/windows/WindowsFlags.java @@ -55,8 +55,6 @@ public class WindowsFlags { * This flag can force us to use d3d * anyway in these situations. Or, this flag can force us to * not use d3d in a situation where we would use it otherwise. - * translAccelEnabled: usage: "-Dsun.java2d.translaccel=true" - * equivalent to sun.java2d.d3d=true * offscreenSharingEnabled: usage: "-Dsun.java2d.offscreenSharing=true" * Turns on the ability to share a hardware-accelerated * offscreen surface through the JAWT interface. See @@ -67,23 +65,6 @@ public class WindowsFlags { * without being very sure that we will be willing to support * that API in the future regardless of other native * rendering pipeline changes. - * accelReset: usage: "-Dsun.java2d.accelReset" - * This flag tells us to reset any persistent information - * the display device acceleration characteristics so that - * we are forced to retest these characteristics. This flag - * is primarily used for debugging purposes (to allow testing - * of the persistent storage mechanisms) but may also be - * needed by some users if, for example, a driver upgrade - * may change the runtime characteristics and they want the - * tests to be re-run. - * checkRegistry: usage: "-Dsun.java2d.checkRegistry" - * This flag tells us to output the current registry settings - * (after our initialization) to the console. - * disableRegistry: usage: "-Dsun.java2d.disableRegistry" - * This flag tells us to disable all registry-related - * activities. It is mainly here for debugging purposes, - * to allow us to see whether any runtime bugs are caused - * by or related to registry problems. * magPresent: usage: "-Djavax.accessibility.screen_magnifier_present" * This flag is set either on the command line or in the * properties file. It tells Swing whether the user is @@ -121,9 +102,6 @@ public class WindowsFlags { private static boolean oglEnabled; private static boolean oglVerbose; private static boolean offscreenSharingEnabled; - private static boolean accelReset; - private static boolean checkRegistry; - private static boolean disableRegistry; private static boolean magPresent; private static boolean setHighDPIAware; // TODO: other flags, including nopixfmt @@ -234,11 +212,6 @@ public class WindowsFlags { } offscreenSharingEnabled = getBooleanProp("sun.java2d.offscreenSharing", false); - accelReset = getBooleanProp("sun.java2d.accelReset", false); - checkRegistry = - getBooleanProp("sun.java2d.checkRegistry", false); - disableRegistry = - getBooleanProp("sun.java2d.disableRegistry", false); String dpiOverride = System.getProperty("sun.java2d.dpiaware"); if (dpiOverride != null) { setHighDPIAware = dpiOverride.equalsIgnoreCase("true"); @@ -265,22 +238,12 @@ public class WindowsFlags { System.out.println("WindowsFlags (Java):"); System.out.println(" ddEnabled: " + ddEnabled + "\n" + " ddOffscreenEnabled: " + ddOffscreenEnabled + "\n" + - " ddVramForced: " + ddVramForced + "\n" + - " ddLockEnabled: " + ddLockEnabled + "\n" + - " ddLockSet: " + ddLockSet + "\n" + - " ddBlitEnabled: " + ddBlitEnabled + "\n" + - " ddScaleEnabled: " + ddScaleEnabled + "\n" + " d3dEnabled: " + d3dEnabled + "\n" + " d3dSet: " + d3dSet + "\n" + " oglEnabled: " + oglEnabled + "\n" + " oglVerbose: " + oglVerbose + "\n" + " gdiBlitEnabled: " + gdiBlitEnabled + "\n" + - " translAccelEnabled: " + translAccelEnabled + "\n" + - " offscreenSharingEnabled: " + offscreenSharingEnabled + "\n" + - " accelReset: " + accelReset + "\n" + - " checkRegistry: " + checkRegistry + "\n" + - " disableRegistry: " + disableRegistry + "\n" + - " d3dTexBPP: " + d3dTexBpp); + " offscreenSharingEnabled: " + offscreenSharingEnabled); */ } @@ -304,10 +267,6 @@ public class WindowsFlags { return gdiBlitEnabled; } - public static boolean isTranslucentAccelerationEnabled() { - return d3dEnabled; - } - public static boolean isOffscreenSharingEnabled() { return offscreenSharingEnabled; } diff --git a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp index 1de213f838e..528e95e326a 100644 --- a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.cpp @@ -27,13 +27,10 @@ #include "Trace.h" #include "WindowsFlags.h" -BOOL accelReset; // reset registry 2d acceleration settings BOOL useD3D = TRUE; // d3d enabled flag // initially is TRUE to allow D3D preloading BOOL forceD3DUsage; // force d3d on or off jboolean g_offscreenSharing; // JAWT accelerated surface sharing -BOOL checkRegistry; // Diagnostic tool: outputs 2d registry settings -BOOL disableRegistry; // Diagnostic tool: disables registry interaction BOOL setHighDPIAware; // Whether to set the high-DPI awareness flag extern WCHAR *j2dAccelKey; // Name of java2d root key @@ -95,12 +92,6 @@ void GetFlagValues(JNIEnv *env, jclass wFlagsClass) g_offscreenSharing = GetStaticBoolean(env, wFlagsClass, "offscreenSharingEnabled"); JNU_CHECK_EXCEPTION(env); - accelReset = GetStaticBoolean(env, wFlagsClass, "accelReset"); - JNU_CHECK_EXCEPTION(env); - checkRegistry = GetStaticBoolean(env, wFlagsClass, "checkRegistry"); - JNU_CHECK_EXCEPTION(env); - disableRegistry = GetStaticBoolean(env, wFlagsClass, "disableRegistry"); - JNU_CHECK_EXCEPTION(env); setHighDPIAware = (IS_WINVISTA && GetStaticBoolean(env, wFlagsClass, "setHighDPIAware")); @@ -113,12 +104,6 @@ void GetFlagValues(JNIEnv *env, jclass wFlagsClass) (forceD3DUsage ? "true" : "false")); J2dTraceLn1(J2D_TRACE_INFO, " offscreenSharing = %s", (g_offscreenSharing ? "true" : "false")); - J2dTraceLn1(J2D_TRACE_INFO, " accelReset = %s", - (accelReset ? "true" : "false")); - J2dTraceLn1(J2D_TRACE_INFO, " checkRegistry = %s", - (checkRegistry ? "true" : "false")); - J2dTraceLn1(J2D_TRACE_INFO, " disableRegistry = %s", - (disableRegistry ? "true" : "false")); J2dTraceLn1(J2D_TRACE_INFO, " setHighDPIAware = %s", (setHighDPIAware ? "true" : "false")); } diff --git a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h index 68a51e4e940..1a3f0418a6f 100644 --- a/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h +++ b/jdk/src/java.desktop/windows/native/libawt/java2d/windows/WindowsFlags.h @@ -27,12 +27,9 @@ #ifndef WINDOWSFLAGS_H #define WINDOWSFLAGS_H -extern BOOL accelReset; // reset registry 2d acceleration settings extern BOOL useD3D; // d3d enabled flag extern BOOL forceD3DUsage; // force d3d on or off extern jboolean g_offscreenSharing; // JAWT accelerated surface sharing -extern BOOL checkRegistry; // Diag tool: outputs 2d registry settings -extern BOOL disableRegistry; // Diag tool: disables registry interaction extern BOOL setHighDPIAware; // whether to set High DPI Aware flag on Vista void SetD3DEnabledFlag(JNIEnv *env, BOOL d3dEnabled, BOOL d3dSet); -- GitLab From d338c44a68f210d2a02261112a2f591ff864945e Mon Sep 17 00:00:00 2001 From: Yuri Nesterenko Date: Tue, 10 May 2016 12:15:07 +0300 Subject: [PATCH 062/400] 8156128: Tests for [AWT/Swing] Conditional support for GTK 3 on Linux Reviewed-by: prr --- .../swing/LookAndFeel/8145547/DemandGTK.java | 71 +++++++++++++++ .../swing/LookAndFeel/8145547/DemandGTK2.sh | 89 +++++++++++++++++++ .../swing/LookAndFeel/8145547/DemandGTK2.txt | 36 ++++++++ .../swing/LookAndFeel/8145547/DemandGTK3.sh | 81 +++++++++++++++++ .../swing/LookAndFeel/8145547/ProvokeGTK.java | 57 ++++++++++++ 5 files changed, 334 insertions(+) create mode 100644 jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK.java create mode 100644 jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.sh create mode 100644 jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.txt create mode 100644 jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK3.sh create mode 100644 jdk/test/javax/swing/LookAndFeel/8145547/ProvokeGTK.java diff --git a/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK.java b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK.java new file mode 100644 index 00000000000..c1b7214e406 --- /dev/null +++ b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + @test + @summary Tests that GTK LaF is supported on solaris + regardless of jdk.gtk.version flag values. + @bug 8156121 + @requires (os.name == "linux" | os.name == "solaris") + @run main/othervm -Djdk.gtk.version=2 DemandGTK + @run main/othervm -Djdk.gtk.version=3 DemandGTK +*/ + +import javax.swing.JFrame; +import javax.swing.UIManager; +import javax.swing.SwingUtilities; +import java.awt.Robot; + +public class DemandGTK { + + static JFrame frame; + public static void createAndShow() { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); + } catch(Exception cnf) { + cnf.printStackTrace(); + throw new RuntimeException("GTK LaF must be supported"); + } + frame = new JFrame("JFrame"); + frame.setSize(200, 200); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(DemandGTK::createAndShow); + Robot robot = new Robot(); + robot.waitForIdle(); + robot.delay(1000); + SwingUtilities.invokeAndWait( () -> { + frame.setVisible(false); + frame.dispose(); + }); + + } +} + diff --git a/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.sh b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.sh new file mode 100644 index 00000000000..93de97904fd --- /dev/null +++ b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.sh @@ -0,0 +1,89 @@ +#!/bin/ksh -p + +# +# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# @test +# @summary Try to force GTK2. We must bail out to GTK3 (if any) if no 2 available. +# +# @compile ProvokeGTK.java +# @requires os.family == "linux" +# @run shell/timeout=400 DemandGTK2.sh + +# +# Note that we depend on +# strace in the PATH +# /sbin/ldconfig (which may be not in PATH) +# It is true for OEL 7 and Ubuntu 14, 16 +# but may fail in future. Save tomorrow for tomorrow. +# +# Read DemandGTK2.txt how to prepare GTK2-less machine. +# + +which strace +if [ $? -ne 0 ] +then + echo "Please provide strace: \"which strace\" failed." + exit 1 +fi + +HAVE_2=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-x11-2 | wc -l` +HAVE_3=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-3.so | wc -l` + + +if [ "${HAVE_2}" = "0" ] +then + + if [ "${HAVE_3}" = "0" ] + then + echo "Neither GTK2 nor GTK3 found: system misconfiguration. Exit." + exit 1 + fi + echo "No GTK 2 library found: we should bail out to 3" + strace -o strace.log -fe open ${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -Djdk.gtk.version=2 ProvokeGTK + EXECRES=$? + grep 'libgtk-3.*=\ *[0-9]*$' strace.log > logg +else + echo "There is GTK 2 library: we should use it" + strace -o strace.log -fe open ${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -Djdk.gtk.version=2 ProvokeGTK + EXECRES=$? + grep 'libgtk-x11.*=\ *[0-9]*$' strace.log > logg +fi + +if [ ${EXECRES} -ne 0 ] +then + echo "java execution failed for unknown reason, see logs" + exit 2 +fi + +cat logg +if [ -s logg ] +then + echo "Success." + exit 0 +else + echo "Failed. Examine logs." + exit 3 +fi + + diff --git a/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.txt b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.txt new file mode 100644 index 00000000000..7313e3ee4a7 --- /dev/null +++ b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK2.txt @@ -0,0 +1,36 @@ +How to prepare an Ubuntu machine for GTK-2-less test run. + +The test DemandGTK2.sh should work well without GTK-2 switching to version 3 +if there's no GTK-2 library available. +At the moment, it's not easy to find a system with GTK-3 and without GTK-2: +many programs still depend on version 2. +We can, however, rename GTK-2 library for a single test run and then restore +it back. + +(1) Find GTK2 library: run + /sbin/ldconfig -v 2>/dev/null | grep libgtk-x11-2 + +It will output one or two lines like +libgtk-x11-2.0.so.0 -> libgtk-x11-2.0.so.0.2400.23 +Search for the target of that symlink for instance with locate: +locate libgtk-x11-2.0.so.0.2400.23 +Finally, you'll find the libraries. On my current machine they are +/usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0.2400.23 +/usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23 + +I'm running 64-bit JDK and need to tamper with x86_64 copy only. + +(2) Find running programs depending on this library. They probably would crash +if you rename it. Stop them for this test run. +That said, I'm afraid it would be impossible to do on a system older than Ubuntu 16.04. +On my Ubuntu 16.04 I have only hud-service using this library, and that's OK, it will restart +after a crash, if any. +To find these programs, run +lsof /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23 + +(3) Now, +sudo mv /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23 /usr/lib/x86_64-linux-gnu/bak.libgtk-x11-2.0.so.0.2400.23 +jtreg DemandGTK2.sh +sudo mv /usr/lib/x86_64-linux-gnu/bak.libgtk-x11-2.0.so.0.2400.23 /usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0.2400.23 + +Needless to say, you should substitute your own library path and however you run jtreg. diff --git a/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK3.sh b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK3.sh new file mode 100644 index 00000000000..1a9038a4bef --- /dev/null +++ b/jdk/test/javax/swing/LookAndFeel/8145547/DemandGTK3.sh @@ -0,0 +1,81 @@ +#!/bin/ksh -p + +# +# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + + +# @test +# @summary Try to force GTK3. We must bail out to GTK2 if no 3 available. +# +# @compile ProvokeGTK.java +# @requires os.family == "linux" +# @run shell/timeout=400 DemandGTK3.sh + +# +# Note that we depend on +# strace in the PATH +# /sbin/ldconfig (which may be is not in PATH) +# It is true for OEL 7 and Ubuntu 14, 16 +# but may fail in future. Save tomorrow for tomorrow. +# + +which strace +if [ $? -ne 0 ] +then + echo "Please provide strace: \"which strace\" failed." + exit 1 +fi + +HAVE_3=`/sbin/ldconfig -v 2>/dev/null | grep libgtk-3.so | wc -l` + + +if [ "${HAVE_3}" = "0" ] +then + + echo "No GTK 3 library found: we should bail out to 2" + strace -o strace.log -fe open ${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -Djdk.gtk.version=3 ProvokeGTK + EXECRES=$? + grep 'libgtk-x11.*=\ *[0-9]*$' strace.log > logg +else + echo "There is GTK 3 library: we should use it" + strace -o strace.log -fe open ${TESTJAVA}/bin/java -cp ${TESTCLASSPATH} -Djdk.gtk.version=3 ProvokeGTK + EXECRES=$? + grep 'libgtk-3.*=\ *[0-9]*$' strace.log > logg +fi + +if [ ${EXECRES} -ne 0 ] +then + echo "java execution failed for unknown reason, see logs" + exit 2 +fi + +cat logg +if [ -s logg ] +then + echo "Success." + exit 0 +else + echo "Failed. Examine logs." + exit 3 +fi + diff --git a/jdk/test/javax/swing/LookAndFeel/8145547/ProvokeGTK.java b/jdk/test/javax/swing/LookAndFeel/8145547/ProvokeGTK.java new file mode 100644 index 00000000000..485ea05beaa --- /dev/null +++ b/jdk/test/javax/swing/LookAndFeel/8145547/ProvokeGTK.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import javax.swing.JFrame; +import javax.swing.UIManager; +import javax.swing.SwingUtilities; + +public class ProvokeGTK { + + static JFrame frame; + public static void createAndShow() { + try { + UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel"); + } catch(Exception cnf) { + cnf.printStackTrace(); + } + frame = new JFrame("JFrame"); + frame.setSize(200, 200); + + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + } + + /** + * @param args the command line arguments + */ + public static void main(String[] args) throws Exception { + SwingUtilities.invokeAndWait(ProvokeGTK::createAndShow); + Thread.sleep(1000); + SwingUtilities.invokeAndWait( () -> { + frame.setVisible(false); + frame.dispose(); + }); + + } +} + -- GitLab From 12675924fcc621594a24564c6dc3f0da2ae9d84c Mon Sep 17 00:00:00 2001 From: Prem Balakrishnan Date: Tue, 10 May 2016 16:08:21 +0530 Subject: [PATCH 063/400] 6421058: When calls JSpinner.setEditor() the font in a JSpinner become is a bold Reviewed-by: serb, alexsch --- .../swing/plaf/basic/BasicSpinnerUI.java | 10 ++ .../swing/JSpinner/6421058/bug6421058.java | 94 +++++++++++++++++++ 2 files changed, 104 insertions(+) create mode 100644 jdk/test/javax/swing/JSpinner/6421058/bug6421058.java diff --git a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java index f6d211f5f9f..5ee8bedcf8e 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java @@ -210,6 +210,16 @@ public class BasicSpinnerUI extends SpinnerUI LookAndFeel.installBorder(spinner, "Spinner.border"); LookAndFeel.installColorsAndFont(spinner, "Spinner.background", "Spinner.foreground", "Spinner.font"); LookAndFeel.installProperty(spinner, "opaque", Boolean.TRUE); + + JComponent editor = spinner.getEditor(); + if (editor instanceof JSpinner.DefaultEditor) { + JTextField tf = ((JSpinner.DefaultEditor) editor).getTextField(); + if (tf != null) { + if (tf.getFont() instanceof UIResource) { + tf.setFont(new FontUIResource(spinner.getFont())); + } + } + } } diff --git a/jdk/test/javax/swing/JSpinner/6421058/bug6421058.java b/jdk/test/javax/swing/JSpinner/6421058/bug6421058.java new file mode 100644 index 00000000000..d67762b21d7 --- /dev/null +++ b/jdk/test/javax/swing/JSpinner/6421058/bug6421058.java @@ -0,0 +1,94 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + /* + * @test + * @bug 6421058 + * @summary Verify font of the text field is changed to the font of + * JSpinner if the font of text field was NOT set by the user + * @run main bug6421058 + */ + +import java.awt.Font; +import javax.swing.JFrame; +import javax.swing.JSpinner; +import javax.swing.JSpinner.DefaultEditor; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; +import javax.swing.plaf.UIResource; +import static javax.swing.UIManager.getInstalledLookAndFeels; + +public class bug6421058 implements Runnable { + + public static void main(final String[] args) throws Exception { + for (final UIManager.LookAndFeelInfo laf : getInstalledLookAndFeels()) { + SwingUtilities.invokeAndWait(() -> setLookAndFeel(laf)); + SwingUtilities.invokeAndWait(new bug6421058()); + } + } + + @Override + public void run() { + final JFrame mainFrame = new JFrame(); + try { + testDefaultFont(mainFrame); + } finally { + mainFrame.dispose(); + } + } + + private static void testDefaultFont(final JFrame frame) { + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JSpinner spinner = new JSpinner(); + frame.add(spinner); + frame.setSize(300, 100); + frame.setVisible(true); + + final DefaultEditor editor = (DefaultEditor) spinner.getEditor(); + final Font editorFont = editor.getTextField().getFont(); + + /* + * Validate that the font of the text field is changed to the + * font of JSpinner if the font of text field was not set by the + * user. + */ + + if (!(editorFont instanceof UIResource)) { + throw new RuntimeException("Font must be UIResource"); + } + if (!editorFont.equals(spinner.getFont())) { + throw new RuntimeException("Wrong FONT"); + } + } + + private static void setLookAndFeel(final UIManager.LookAndFeelInfo laf) { + try { + UIManager.setLookAndFeel(laf.getClassName()); + } catch (ClassNotFoundException | InstantiationException | + UnsupportedLookAndFeelException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } +} -- GitLab From 72bf5160ac43696b0986e1e6f6730cf06f936e32 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Thu, 12 May 2016 09:16:17 -0700 Subject: [PATCH 064/400] 8154546: Retire sun.misc.GThreadHelper Reviewed-by: serb, chegar, kcr --- .../native/libawt_xawt/awt/gtk2_interface.c | 44 ++-------- .../unix/classes/sun/misc/GThreadHelper.java | 87 ------------------- 2 files changed, 7 insertions(+), 124 deletions(-) delete mode 100644 jdk/src/jdk.unsupported/unix/classes/sun/misc/GThreadHelper.java diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c index ef8caa94382..7ce7fae60d5 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/gtk2_interface.c @@ -817,52 +817,22 @@ GtkApi* gtk2_load(JNIEnv *env, const char* lib_name) io_handler = XSetIOErrorHandler(NULL); if (fp_gtk_check_version(2, 2, 0) == NULL) { - jclass clazz = (*env)->FindClass(env, "sun/misc/GThreadHelper"); - jmethodID mid_getAndSetInitializationNeededFlag = - (*env)->GetStaticMethodID(env, clazz, "getAndSetInitializationNeededFlag", "()Z"); - jmethodID mid_lock = (*env)->GetStaticMethodID(env, clazz, "lock", "()V"); - jmethodID mid_unlock = (*env)->GetStaticMethodID(env, clazz, "unlock", "()V"); - - // Init the thread system to use GLib in a thread-safe mode - (*env)->CallStaticVoidMethod(env, clazz, mid_lock); - if ((*env)->ExceptionCheck(env)) { - AWT_UNLOCK(); - return FALSE; - } // Calling g_thread_init() multiple times leads to crash on GLib < 2.24 // We can use g_thread_get_initialized () but it is available only for - // GLib >= 2.20. We rely on GThreadHelper for GLib < 2.20. + // GLib >= 2.20. gboolean is_g_thread_get_initialized = FALSE; if (GLIB_CHECK_VERSION(2, 20, 0)) { is_g_thread_get_initialized = fp_g_thread_get_initialized(); } - if (!(*env)->CallStaticBooleanMethod(env, clazz, mid_getAndSetInitializationNeededFlag)) { - if (!is_g_thread_get_initialized) { - fp_g_thread_init(NULL); - } - - //According the GTK documentation, gdk_threads_init() should be - //called before gtk_init() or gtk_init_check() - fp_gdk_threads_init(); - } - jthrowable pendExcpn = NULL; - // Exception raised during mid_getAndSetInitializationNeededFlag - // call is saved and error handling is done - // after unlock method is called - if ((pendExcpn = (*env)->ExceptionOccurred(env)) != NULL) { - (*env)->ExceptionClear(env); - } - (*env)->CallStaticVoidMethod(env, clazz, mid_unlock); - if (pendExcpn != NULL) { - (*env)->Throw(env, pendExcpn); - } - // check if any exception occured during mid_unlock call - if ((*env)->ExceptionCheck(env)) { - AWT_UNLOCK(); - return FALSE; + if (!is_g_thread_get_initialized) { + fp_g_thread_init(NULL); } + + //According the GTK documentation, gdk_threads_init() should be + //called before gtk_init() or gtk_init_check() + fp_gdk_threads_init(); } result = (*fp_gtk_init_check)(NULL, NULL); diff --git a/jdk/src/jdk.unsupported/unix/classes/sun/misc/GThreadHelper.java b/jdk/src/jdk.unsupported/unix/classes/sun/misc/GThreadHelper.java deleted file mode 100644 index 180a5d5c1af..00000000000 --- a/jdk/src/jdk.unsupported/unix/classes/sun/misc/GThreadHelper.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.misc; - -import java.util.concurrent.locks.ReentrantLock; - -/** - * This class is used to prevent multiple calling of g_thread_init () - * and gdk_thread_init (). - * - * Since version 2.24 of GLib, calling g_thread_init () multiple times is - * allowed, but it will crash for older versions. There are two ways to - * find out if g_thread_init () has been called: - * g_thread_get_initialized (), but it was introduced in 2.20 - * g_thread_supported (), but it is a macro and cannot be loaded with dlsym. - * - * usage: - *
      - * lock();
      - * try {
      - *    if (!getAndSetInitializationNeededFlag()) {
      - *        //call to g_thread_init();
      - *        //call to gdk_thread_init();
      - *    }
      - * } finally {
      - *    unlock();
      - * }
      - * 
      - */ -public final class GThreadHelper { - - private static final ReentrantLock LOCK = new ReentrantLock(); - private static boolean isGThreadInitialized = false; - - /** - * Acquires the lock. - */ - public static void lock() { - LOCK.lock(); - } - - /** - * Releases the lock. - */ - public static void unlock() { - LOCK.unlock(); - } - - /** - * Gets current value of initialization flag and sets it to {@code true}. - * MUST be called under the lock. - * - * A return value of {@code false} indicates that the calling code - * should call the g_thread_init() and gdk_thread_init() functions - * before releasing the lock. - * - * @return {@code true} if initialization has been completed. - */ - public static boolean getAndSetInitializationNeededFlag() { - boolean ret = isGThreadInitialized; - isGThreadInitialized = true; - return ret; - } -} -- GitLab From 39fe334e1216b35c99353be42393e50df1e30499 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Thu, 12 May 2016 20:43:37 +0400 Subject: [PATCH 065/400] 8154539: Examine the desktop module's use of sun.misc.SoftCache Reviewed-by: prr, chegar, mchung --- jdk/src/java.desktop/share/classes/module-info.java | 2 -- .../misc => java.desktop/share/classes/sun/awt}/SoftCache.java | 2 +- jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java | 1 - .../classes/sun/awt/image/MultiResolutionToolkitImage.java | 2 +- jdk/test/com/sun/jdi/ReferrersTest.java | 2 +- 5 files changed, 3 insertions(+), 6 deletions(-) rename jdk/src/{jdk.unsupported/share/classes/sun/misc => java.desktop/share/classes/sun/awt}/SoftCache.java (99%) diff --git a/jdk/src/java.desktop/share/classes/module-info.java b/jdk/src/java.desktop/share/classes/module-info.java index 5cf785de71f..77150e17b73 100644 --- a/jdk/src/java.desktop/share/classes/module-info.java +++ b/jdk/src/java.desktop/share/classes/module-info.java @@ -27,8 +27,6 @@ module java.desktop { requires public java.datatransfer; requires public java.xml; requires java.prefs; - // 8147544 - requires jdk.unsupported; exports java.applet; exports java.awt; diff --git a/jdk/src/jdk.unsupported/share/classes/sun/misc/SoftCache.java b/jdk/src/java.desktop/share/classes/sun/awt/SoftCache.java similarity index 99% rename from jdk/src/jdk.unsupported/share/classes/sun/misc/SoftCache.java rename to jdk/src/java.desktop/share/classes/sun/awt/SoftCache.java index 30bc2ec6068..7b7ea26be86 100644 --- a/jdk/src/jdk.unsupported/share/classes/sun/misc/SoftCache.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/SoftCache.java @@ -23,7 +23,7 @@ * questions. */ -package sun.misc; +package sun.awt; import java.lang.ref.SoftReference; import java.lang.ref.ReferenceQueue; diff --git a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java index fdaeb1ea7ad..8461974375f 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java @@ -65,7 +65,6 @@ import sun.awt.image.MultiResolutionToolkitImage; import sun.awt.image.ToolkitImage; import sun.awt.image.URLImageSource; import sun.font.FontDesignMetrics; -import sun.misc.SoftCache; import sun.net.util.URLUtil; import sun.security.action.GetBooleanAction; import sun.security.action.GetPropertyAction; diff --git a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java index a8e67f767ca..26a86916824 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java @@ -29,7 +29,7 @@ import java.awt.image.ImageObserver; import java.awt.image.MultiResolutionImage; import java.util.Arrays; import java.util.List; -import sun.misc.SoftCache; +import sun.awt.SoftCache; public class MultiResolutionToolkitImage extends ToolkitImage implements MultiResolutionImage { diff --git a/jdk/test/com/sun/jdi/ReferrersTest.java b/jdk/test/com/sun/jdi/ReferrersTest.java index b78a5618019..3293b089f31 100644 --- a/jdk/test/com/sun/jdi/ReferrersTest.java +++ b/jdk/test/com/sun/jdi/ReferrersTest.java @@ -446,7 +446,7 @@ public class ReferrersTest extends TestScaffold { if (rt instanceof ClassType) { ClassType ct = (ClassType)rt; String name = ct.name(); - if (name.equals("sun.misc.SoftCache$ValueCell")) { + if (name.equals("sun.awt.SoftCache$ValueCell")) { return; } if (name.equals("java.lang.ref.Finalizer")) { -- GitLab From e931bc512f9f14d87587e2aaad0ce961d831ddb2 Mon Sep 17 00:00:00 2001 From: Vadim Pakhnushev Date: Fri, 13 May 2016 11:31:05 +0300 Subject: [PATCH 066/400] 8047931: Remove unused medialib code Reviewed-by: bae --- jdk/make/lib/Awt2dLibraries.gmk | 11 - .../native/libmlib_image/mlib_ImageAffine.c | 52 +- .../native/libmlib_image/mlib_ImageAffine.h | 82 +- .../libmlib_image/mlib_ImageAffineEdge.c | 299 +- .../native/libmlib_image/mlib_ImageCheck.h | 6 - .../libmlib_image/mlib_ImageColorTrue2Index.c | 4256 ----------------- .../native/libmlib_image/mlib_ImageColormap.h | 221 - .../native/libmlib_image/mlib_ImageConv.h | 460 -- .../libmlib_image/mlib_ImageConv2x2_f.c | 1118 ----- .../libmlib_image/mlib_ImageConv_16ext.c | 1380 ------ .../libmlib_image/mlib_ImageConv_16nw.c | 1192 ----- .../libmlib_image/mlib_ImageConv_32nw.c | 833 ---- .../libmlib_image/mlib_ImageConv_8ext.c | 1395 ------ .../native/libmlib_image/mlib_ImageConv_8nw.c | 1192 ----- .../libmlib_image/mlib_ImageConv_D64nw.c | 489 -- .../libmlib_image/mlib_ImageConv_F32nw.c | 489 -- .../libmlib_image/mlib_ImageConv_u16ext.c | 1370 ------ .../libmlib_image/mlib_ImageConv_u16nw.c | 1192 ----- .../mlib_c_ImageAffineIndex_BC.c | 413 -- .../mlib_c_ImageAffineIndex_BL.c | 280 -- .../libmlib_image/mlib_c_ImageBlendTable.c | 263 - .../libmlib_image/mlib_c_ImageBlendTable.h | 41 - .../native/libmlib_image/mlib_c_ImageConv.h | 208 - .../native/libmlib_image/mlib_c_ImageConv_f.c | 144 - .../libmlib_image/mlib_c_ImageThresh1.h | 103 - .../libmlib_image/mlib_c_ImageThresh1_U8.c | 848 ---- .../share/native/libmlib_image/mlib_image.h | 1 - .../libmlib_image/mlib_image_blend_proto.h | 1448 ------ .../native/libmlib_image/mlib_image_proto.h | 229 - .../libawt/awt/medialib/mlib_v_ImageCopy.c | 193 - .../awt/medialib/mlib_v_ImageCopy_blk.s | 262 - .../unix/native/libawt/awt/medialib/vis_asi.h | 210 - .../mlib_v_ImageAffineIndex_BC.c | 1443 ------ .../libmlib_image/mlib_v_ImageAffine_BL.c | 132 - .../libmlib_image/mlib_v_ImageAffine_BL_S16.c | 126 - .../libmlib_image/mlib_v_ImageAffine_BL_U16.c | 1 - .../mlib_v_ImageChannelExtract.c | 825 ---- .../mlib_v_ImageChannelExtract.h | 319 -- .../mlib_v_ImageChannelExtract_1.c | 1980 -------- .../mlib_v_ImageChannelExtract_43.c | 919 ---- .../mlib_v_ImageChannelExtract_f.c | 784 --- .../libmlib_image/mlib_v_ImageChannelInsert.c | 715 --- .../libmlib_image/mlib_v_ImageChannelInsert.h | 269 -- .../mlib_v_ImageChannelInsert_1.c | 1070 ----- .../mlib_v_ImageChannelInsert_34.c | 1225 ----- .../native/libmlib_image/mlib_v_ImageConv.h | 22 - .../mlib_v_ImageConvIndex3_8_16nw.c | 1673 ------- .../mlib_v_ImageConvIndex3_8_8nw.c | 1673 ------- .../libmlib_image/mlib_v_ImageConv_8nw.c | 1015 +--- 49 files changed, 16 insertions(+), 34855 deletions(-) delete mode 100644 jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColorTrue2Index.c delete mode 100644 jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColormap.h delete mode 100644 jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv2x2_f.c delete mode 100644 jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BC.c delete mode 100644 jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BL.c delete mode 100644 jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.c delete mode 100644 jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.h delete mode 100644 jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1.h delete mode 100644 jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1_U8.c delete mode 100644 jdk/src/java.desktop/share/native/libmlib_image/mlib_image_blend_proto.h delete mode 100644 jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy.c delete mode 100644 jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy_blk.s delete mode 100644 jdk/src/java.desktop/unix/native/libawt/awt/medialib/vis_asi.h delete mode 100644 jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffineIndex_BC.c delete mode 100644 jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.c delete mode 100644 jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_f.c delete mode 100644 jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.c delete mode 100644 jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_34.c delete mode 100644 jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_16nw.c delete mode 100644 jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_8nw.c diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index 7215f351700..57067da008d 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -96,10 +96,7 @@ ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) mlib_c_ImageAffine_BL.c \ mlib_c_ImageAffine_BL_S16.c \ mlib_c_ImageAffine_BL_U16.c \ - mlib_c_ImageAffineIndex_BC.c \ - mlib_c_ImageAffineIndex_BL.c \ mlib_c_ImageAffine_NN.c \ - mlib_c_ImageBlendTable.c \ mlib_c_ImageConvClearEdge.c \ mlib_c_ImageConvCopyEdge.c \ mlib_c_ImageConv_f.c \ @@ -107,14 +104,6 @@ ifeq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU_ARCH), solaris-sparc) mlib_c_ImageCopy.c \ mlib_c_ImageLookUp.c \ mlib_c_ImageLookUp_f.c \ - mlib_v_ImageChannelExtract.c \ - mlib_v_ImageChannelExtract_f.c \ - mlib_v_ImageChannelInsert_34.c \ - mlib_v_ImageChannelInsert.c \ - mlib_v_ImageConvIndex3_8_16nw.c \ - mlib_v_ImageConvIndex3_8_8nw.c \ - mlib_v_ImageCopy.c \ - mlib_v_ImageCopy_blk.s \ # LIBMLIB_IMAGE_V_CFLAGS += $(filter-out -DMLIB_NO_LIBSUNMATH, $(BUILD_LIBMLIB_CFLAGS)) diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.c index 42d42ed041b..84d8a147aa3 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.c @@ -73,7 +73,6 @@ */ #include "mlib_ImageCheck.h" -#include "mlib_ImageColormap.h" #include "mlib_ImageAffine.h" @@ -124,18 +123,6 @@ const type_affine_fun mlib_AffineFunArr_bc[] = { mlib_ImageAffine_d64_3ch_bc, mlib_ImageAffine_d64_4ch_bc }; -/***************************************************************/ -const type_affine_i_fun mlib_AffineFunArr_bc_i[] = { - mlib_ImageAffineIndex_U8_U8_3CH_BC, - mlib_ImageAffineIndex_U8_U8_4CH_BC, - mlib_ImageAffineIndex_S16_U8_3CH_BC, - mlib_ImageAffineIndex_S16_U8_4CH_BC, - mlib_ImageAffineIndex_U8_S16_3CH_BC, - mlib_ImageAffineIndex_U8_S16_4CH_BC, - mlib_ImageAffineIndex_S16_S16_3CH_BC, - mlib_ImageAffineIndex_S16_S16_4CH_BC -}; - /***************************************************************/ #ifdef i386 /* do not perform the coping by mlib_d64 data type for x86 */ #define MAX_T_IND 2 @@ -148,8 +135,7 @@ mlib_status mlib_ImageAffine_alltypes(mlib_image *dst, const mlib_image *src, const mlib_d64 *mtx, mlib_filter filter, - mlib_edge edge, - const void *colormap) + mlib_edge edge) { mlib_affine_param param[1]; mlib_status res; @@ -213,18 +199,6 @@ mlib_status mlib_ImageAffine_alltypes(mlib_image *dst, else return MLIB_FAILURE; /* unknown image type */ - if (colormap != NULL && filter != MLIB_NEAREST) { - if (t_ind != 0 && t_ind != 1) - return MLIB_FAILURE; - - if (mlib_ImageGetLutType(colormap) == MLIB_SHORT) - t_ind += 2; - t_ind = 2 * t_ind; - - if (mlib_ImageGetLutChannels(colormap) == 4) - t_ind++; - } - if (type == MLIB_BIT) { mlib_s32 s_bitoff = mlib_ImageGetBitOffset(src); mlib_s32 d_bitoff = mlib_ImageGetBitOffset(dst); @@ -253,25 +227,13 @@ mlib_status mlib_ImageAffine_alltypes(mlib_image *dst, case MLIB_BILINEAR: - if (colormap != NULL) { - res = mlib_AffineFunArr_bl_i[t_ind] (param, colormap); - } - else { - res = mlib_AffineFunArr_bl[4 * t_ind + (nchan - 1)] (param); - } - + res = mlib_AffineFunArr_bl[4 * t_ind + (nchan - 1)] (param); break; case MLIB_BICUBIC: case MLIB_BICUBIC2: - if (colormap != NULL) { - res = mlib_AffineFunArr_bc_i[t_ind] (param, colormap); - } - else { - res = mlib_AffineFunArr_bc[4 * t_ind + (nchan - 1)] (param); - } - + res = mlib_AffineFunArr_bc[4 * t_ind + (nchan - 1)] (param); break; } @@ -303,7 +265,7 @@ mlib_status mlib_ImageAffine_alltypes(mlib_image *dst, switch (edge) { case MLIB_EDGE_DST_FILL_ZERO: - mlib_ImageAffineEdgeZero(param, param_e, colormap); + mlib_ImageAffineEdgeZero(param, param_e); break; case MLIB_EDGE_OP_NEAREST: @@ -313,10 +275,10 @@ mlib_status mlib_ImageAffine_alltypes(mlib_image *dst, case MLIB_EDGE_SRC_EXTEND: if (filter == MLIB_BILINEAR) { - res = mlib_ImageAffineEdgeExtend_BL(param, param_e, colormap); + res = mlib_ImageAffineEdgeExtend_BL(param, param_e); } else { - res = mlib_ImageAffineEdgeExtend_BC(param, param_e, colormap); + res = mlib_ImageAffineEdgeExtend_BC(param, param_e); } break; @@ -355,7 +317,7 @@ mlib_status mlib_ImageAffine(mlib_image *dst, return MLIB_FAILURE; } - return mlib_ImageAffine_alltypes(dst, src, mtx, filter, edge, NULL); + return mlib_ImageAffine_alltypes(dst, src, mtx, filter, edge); } /***************************************************************/ diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.h index b9f8fe801b5..be21823729c 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.h +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffine.h @@ -162,99 +162,25 @@ mlib_status mlib_ImageAffine_d64_4ch_bc(mlib_affine_param *param); /***************************************************************/ void mlib_ImageAffineEdgeZero(mlib_affine_param *param, - mlib_affine_param *param_e, - const void *colormap); + mlib_affine_param *param_e); void mlib_ImageAffineEdgeNearest(mlib_affine_param *param, mlib_affine_param *param_e); mlib_status mlib_ImageAffineEdgeExtend_BL(mlib_affine_param *param, - mlib_affine_param *param_e, - const void *colormap); + mlib_affine_param *param_e); mlib_status mlib_ImageAffineEdgeExtend_BC(mlib_affine_param *param, - mlib_affine_param *param_e, - const void *colormap); - -mlib_status mlib_ImageAffineEdgeExtend_BC2(mlib_affine_param *param, - mlib_affine_param *param_e, - const void *colormap); - -/***************************************************************/ -typedef mlib_status (*type_affine_i_fun)(mlib_affine_param *param, const void *colormap); - -mlib_status mlib_ImageAffine_u8_u8_i_bl(mlib_affine_param *param, - const void *colormap); -mlib_status mlib_ImageAffine_u8_s16_i_bl(mlib_affine_param *param, - const void *colormap); -mlib_status mlib_ImageAffine_s16_u8_i_bl(mlib_affine_param *param, - const void *colormap); -mlib_status mlib_ImageAffine_s16_s16_i_bl(mlib_affine_param *param, - const void *colormap); - -mlib_status mlib_ImageAffine_u8_u8_i_bc(mlib_affine_param *param, - const void *colormap); -mlib_status mlib_ImageAffine_u8_s16_i_bc(mlib_affine_param *param, - const void *colormap); -mlib_status mlib_ImageAffine_s16_u8_i_bc(mlib_affine_param *param, - const void *colormap); -mlib_status mlib_ImageAffine_s16_s16_i_bc(mlib_affine_param *param, - const void *colormap); - -void mlib_ImageAffineEdgeZeroIndex(mlib_affine_param *param, - mlib_affine_param *param_e, - const void *colormap); - -void mlib_ImageAffineEdgeExtendIndex_BL(mlib_affine_param *param, - mlib_affine_param *param_e, - const void *colormap); - -void mlib_ImageAffineEdgeExtendIndex_BC(mlib_affine_param *param, - mlib_affine_param *param_e, - const void *colormap); - -void mlib_ImageAffineEdgeExtendIndex_BC2(mlib_affine_param *param, - mlib_affine_param *param_e, - const void *colormap); - -/***************************************************************/ -#define PROT_AFFINEINDEX_BC(ITYPE, LTYPE, NCHAN) \ - mlib_status mlib_ImageAffineIndex_##ITYPE##_##LTYPE##_##NCHAN##CH_BC(mlib_affine_param *param, \ - const void *colormap) - -PROT_AFFINEINDEX_BC(U8, U8, 3); -PROT_AFFINEINDEX_BC(U8, S16, 3); -PROT_AFFINEINDEX_BC(U8, U8, 4); -PROT_AFFINEINDEX_BC(U8, S16, 4); -PROT_AFFINEINDEX_BC(S16, U8, 3); -PROT_AFFINEINDEX_BC(S16, S16, 3); -PROT_AFFINEINDEX_BC(S16, U8, 4); -PROT_AFFINEINDEX_BC(S16, S16, 4); - -/***************************************************************/ -#define PROT_AFFINEINDEX_BL(ITYPE, LTYPE, NCHAN) \ - mlib_status mlib_ImageAffineIndex_##ITYPE##_##LTYPE##_##NCHAN##CH_BL(mlib_affine_param *param, \ - const void *colormap) - -PROT_AFFINEINDEX_BL(U8, U8, 3); -PROT_AFFINEINDEX_BL(U8, S16, 3); -PROT_AFFINEINDEX_BL(U8, U8, 4); -PROT_AFFINEINDEX_BL(U8, S16, 4); -PROT_AFFINEINDEX_BL(S16, U8, 3); -PROT_AFFINEINDEX_BL(S16, S16, 3); -PROT_AFFINEINDEX_BL(S16, U8, 4); -PROT_AFFINEINDEX_BL(S16, S16, 4); + mlib_affine_param *param_e); /***************************************************************/ mlib_status mlib_ImageAffine_alltypes(mlib_image *dst, const mlib_image *src, const mlib_d64 *mtx, mlib_filter filter, - mlib_edge edge, - const void *colormap); + mlib_edge edge); /***************************************************************/ -extern const type_affine_i_fun mlib_AffineFunArr_bl_i[]; extern const type_affine_fun mlib_AffineFunArr_nn[]; extern const type_affine_fun mlib_AffineFunArr_bl[]; extern const type_affine_fun mlib_AffineFunArr_bc[]; diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffineEdge.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffineEdge.c index e095a0e9c01..2cb39d0b55a 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffineEdge.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageAffineEdge.c @@ -73,7 +73,6 @@ */ #include "mlib_image.h" -#include "mlib_ImageColormap.h" #include "mlib_ImageAffine.h" /***************************************************************/ @@ -217,97 +216,6 @@ dp += channels; \ } -/***************************************************************/ -#define LUT(k, ind) plut[channels*sp[ind] + k] - -/***************************************************************/ -#define MLIB_EDGE_INDEX(ITYPE, DTYPE, size) \ - for (j = 0; j < size; j++) { \ - ySrc = ((Y - 32768) >> MLIB_SHIFT); \ - xSrc = ((X - 32768) >> MLIB_SHIFT); \ - \ - t = ((X - 32768) & MLIB_MASK) * scale; \ - u = ((Y - 32768) & MLIB_MASK) * scale; \ - \ - xDelta = (((xSrc + 1 - srcWidth )) >> MLIB_SIGN_SHIFT) & 1; \ - yDelta = (((ySrc + 1 - srcHeight)) >> MLIB_SIGN_SHIFT) & srcStride; \ - \ - xFlag = (xSrc >> (MLIB_SIGN_SHIFT - MLIB_SHIFT)); \ - xSrc = xSrc + (1 & xFlag); \ - xDelta = xDelta &~ xFlag; \ - \ - yFlag = (ySrc >> (MLIB_SIGN_SHIFT - MLIB_SHIFT)); \ - ySrc = ySrc + (1 & yFlag); \ - yDelta = yDelta &~ yFlag; \ - \ - sp = (ITYPE*)lineAddr[ySrc] + xSrc; \ - \ - for (k = 0; k < channels; k++) { \ - a00 = LUT(k, 0); \ - a01 = LUT(k, xDelta); \ - a10 = LUT(k, yDelta); \ - a11 = LUT(k, yDelta + xDelta); \ - pix0 = (a00 * (1 - t) + a01 * t) * (1 - u) + \ - (a10 * (1 - t) + a11 * t) * u; \ - \ - pbuff[k] = (mlib_s32)pix0; \ - } \ - pbuff += channels; \ - \ - X += dX; \ - Y += dY; \ - } - -/***************************************************************/ -#define MLIB_EDGE_INDEX_u8i(ITYPE, Left, Right) { \ - mlib_u8 *pbuff = buff; \ - \ - size = Right - Left; \ - \ - MLIB_EDGE_INDEX(ITYPE, mlib_u8, size); \ - \ - dp = (ITYPE*)data + Left; \ - \ - if (channels == 3) { \ - if (sizeof(ITYPE) == 1) { \ - mlib_ImageColorTrue2IndexLine_U8_U8_3 (buff, (void*)dp, size, colormap); \ - } else { \ - mlib_ImageColorTrue2IndexLine_U8_S16_3(buff, (void*)dp, size, colormap); \ - } \ - } else { \ - if (sizeof(ITYPE) == 1) { \ - mlib_ImageColorTrue2IndexLine_U8_U8_4 (buff, (void*)dp, size, colormap); \ - } else { \ - mlib_ImageColorTrue2IndexLine_U8_S16_4(buff, (void*)dp, size, colormap); \ - } \ - } \ -} - -/***************************************************************/ -#define MLIB_EDGE_INDEX_s16i(ITYPE, Left, Right) { \ - mlib_s16 *pbuff = buff; \ - \ - size = Right - Left; \ - \ - MLIB_EDGE_INDEX(ITYPE, mlib_s16, size); \ - \ - dp = (ITYPE*)data + Left; \ - \ - if (channels == 3) { \ - if (sizeof(ITYPE) == 1) { \ - mlib_ImageColorTrue2IndexLine_S16_U8_3 (buff, (void*)dp, size, colormap); \ - } else { \ - mlib_ImageColorTrue2IndexLine_S16_S16_3(buff, (void*)dp, size, colormap); \ - } \ - } else { \ - if (sizeof(ITYPE) == 1) { \ - mlib_ImageColorTrue2IndexLine_S16_U8_4 (buff, (void*)dp, size, colormap); \ - } else { \ - mlib_ImageColorTrue2IndexLine_S16_S16_4(buff, (void*)dp, size, colormap); \ - } \ - } \ -} - /***************************************************************/ #define GET_FLT_TBL(X, xf0, xf1, xf2, xf3) \ filterpos = ((X - 32768) >> flt_shift) & flt_mask; \ @@ -423,47 +331,6 @@ #define MLIB_EDGE_BC2(TYPE, Left, Right) \ MLIB_EDGE_BC_LINE(TYPE, Left, Right, GET_FLT_BC2) -/***************************************************************/ -#define MLIB_EDGE_INDEX_BC(ITYPE, DTYPE, size) \ - for (j = 0; j < size; j++) { \ - GET_FLT_TBL(X, xf0, xf1, xf2, xf3); \ - GET_FLT_TBL(Y, yf0, yf1, yf2, yf3); \ - \ - CALC_SRC_POS(X, Y, 1, srcStride); \ - \ - sp = (ITYPE*)lineAddr[ySrc] + xSrc; \ - \ - for (k = 0; k < channels; k++) { \ - c0 = LUT(k, yDelta0 + xDelta0) * xf0 + \ - LUT(k, yDelta0 ) * xf1 + \ - LUT(k, yDelta0 + xDelta1) * xf2 + \ - LUT(k, yDelta0 + xDelta2) * xf3; \ - \ - c1 = LUT(k, xDelta0) * xf0 + \ - LUT(k, 0 ) * xf1 + \ - LUT(k, xDelta1) * xf2 + \ - LUT(k, xDelta2) * xf3; \ - \ - c2 = LUT(k, yDelta1 + xDelta0) * xf0 + \ - LUT(k, yDelta1 ) * xf1 + \ - LUT(k, yDelta1 + xDelta1) * xf2 + \ - LUT(k, yDelta1 + xDelta2) * xf3; \ - \ - c3 = LUT(k, yDelta2 + xDelta0) * xf0 + \ - LUT(k, yDelta2 ) * xf1 + \ - LUT(k, yDelta2 + xDelta1) * xf2 + \ - LUT(k, yDelta2 + xDelta2) * xf3; \ - \ - val0 = c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3; \ - \ - SAT##DTYPE(pbuff[k], val0); \ - } \ - pbuff += channels; \ - \ - X += dX; \ - Y += dY; \ - } - /***************************************************************/ #define MLIB_PROCESS_EDGES_ZERO(TYPE) { \ TYPE *dp, *dstLineEnd; \ @@ -586,16 +453,11 @@ /***************************************************************/ void mlib_ImageAffineEdgeZero(mlib_affine_param *param, - mlib_affine_param *param_e, - const void *colormap) + mlib_affine_param *param_e) { GET_EDGE_PARAMS_ZERO(); mlib_s32 zero = 0; - if (colormap != NULL) { - zero = mlib_ImageGetLutOffset(colormap); - } - switch (type) { case MLIB_BYTE: MLIB_PROCESS_EDGES_ZERO(mlib_u8); @@ -654,8 +516,7 @@ void mlib_ImageAffineEdgeNearest(mlib_affine_param *param, /***************************************************************/ mlib_status mlib_ImageAffineEdgeExtend_BL(mlib_affine_param *param, - mlib_affine_param *param_e, - const void *colormap) + mlib_affine_param *param_e) { GET_EDGE_PARAMS(); mlib_d64 scale = 1.0 / (mlib_d64) MLIB_PREC; @@ -663,79 +524,6 @@ mlib_status mlib_ImageAffineEdgeExtend_BL(mlib_affine_param *param, mlib_d64 t, u, pix0; mlib_d64 a00, a01, a10, a11; - if (colormap != NULL) { - mlib_s32 max_xsize = param_e->max_xsize; - mlib_type ltype = mlib_ImageGetLutType(colormap); - mlib_d64 *plut = (mlib_d64 *) mlib_ImageGetLutDoubleData(colormap); - void *buff; - - channels = mlib_ImageGetLutChannels(colormap); - plut -= channels * mlib_ImageGetLutOffset(colormap); - - if (max_xsize == 0) { - return MLIB_SUCCESS; - } - - if (ltype == MLIB_BYTE) { - buff = mlib_malloc(channels * max_xsize); - } - else if (ltype == MLIB_SHORT) { - buff = mlib_malloc(channels * max_xsize * sizeof(mlib_s16)); - } else { - /* Unsupported type of lookup table. Report a failure */ - return MLIB_FAILURE; - } - - if (buff == NULL) - return MLIB_FAILURE; - - switch (ltype) { - case MLIB_BYTE: - switch (type) { - case MLIB_BYTE: - MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_u8i, mlib_u8); - break; - - case MLIB_SHORT: - srcStride >>= 1; - MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_u8i, mlib_s16); - break; - default: - /* Incompatible image type. Ignore it for now. */ - break; - } - - break; - - case MLIB_SHORT: - switch (type) { - case MLIB_BYTE: - MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_s16i, mlib_u8); - break; - - case MLIB_SHORT: - srcStride >>= 1; - MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_s16i, mlib_s16); - break; - default: - /* Incompatible image type. Ignore it for now. */ - break; - } - - break; - default: - /* Unsupported type of lookup table. - * Can not be here due to check on line 685, - * so just ignore it. - */ - break; - } - - mlib_free(buff); - - return MLIB_SUCCESS; - } - switch (type) { case MLIB_BYTE: MLIB_PROCESS_EDGES(MLIB_EDGE_BL, mlib_u8); @@ -775,12 +563,8 @@ mlib_status mlib_ImageAffineEdgeExtend_BL(mlib_affine_param *param, } /***************************************************************/ -#undef MLIB_EDGE_INDEX -#define MLIB_EDGE_INDEX MLIB_EDGE_INDEX_BC - mlib_status mlib_ImageAffineEdgeExtend_BC(mlib_affine_param *param, - mlib_affine_param *param_e, - const void *colormap) + mlib_affine_param *param_e) { GET_EDGE_PARAMS(); mlib_d64 scale = 1.0 / (mlib_d64) MLIB_PREC; @@ -789,7 +573,6 @@ mlib_status mlib_ImageAffineEdgeExtend_BC(mlib_affine_param *param, mlib_d64 xf0, xf1, xf2, xf3; mlib_d64 yf0, yf1, yf2, yf3; mlib_d64 c0, c1, c2, c3, val0; - mlib_type ltype; mlib_filter filter = param->filter; mlib_f32 *fptr; mlib_f32 const *flt_tbl; @@ -798,9 +581,7 @@ mlib_status mlib_ImageAffineEdgeExtend_BC(mlib_affine_param *param, mlib_s32 yDelta0, yDelta1, yDelta2; mlib_d64 sat; - ltype = (colormap != NULL) ? mlib_ImageGetLutType(colormap) : type; - - if (ltype == MLIB_BYTE) { + if (type == MLIB_BYTE) { flt_shift = FLT_SHIFT_U8; flt_mask = FLT_MASK_U8; flt_tbl = (filter == MLIB_BICUBIC) ? mlib_filters_u8f_bc : mlib_filters_u8f_bc2; @@ -813,78 +594,6 @@ mlib_status mlib_ImageAffineEdgeExtend_BC(mlib_affine_param *param, sat = (mlib_d64) 0x7FFF8000; /* saturation for U16 */ } - if (colormap != NULL) { - mlib_s32 max_xsize = param_e->max_xsize; - mlib_d64 *plut = (mlib_d64 *) mlib_ImageGetLutDoubleData(colormap); - void *buff; - - channels = mlib_ImageGetLutChannels(colormap); - plut -= channels * mlib_ImageGetLutOffset(colormap); - - if (max_xsize == 0) { - return MLIB_SUCCESS; - } - - if (ltype == MLIB_BYTE) { - buff = mlib_malloc(channels * max_xsize); - } - else if (ltype == MLIB_SHORT) { - buff = mlib_malloc(channels * max_xsize * sizeof(mlib_s16)); - } else { - /* Unsupported type of lookup table. */ - return MLIB_FAILURE; - } - - if (buff == NULL) - return MLIB_FAILURE; - - switch (ltype) { - case MLIB_BYTE: - switch (type) { - case MLIB_BYTE: - MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_u8i, mlib_u8); - break; - - case MLIB_SHORT: - srcStride >>= 1; - MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_u8i, mlib_s16); - break; - default: - /* Ignore incomatible image type. */ - break; - } - - break; - - case MLIB_SHORT: - switch (type) { - case MLIB_BYTE: - MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_s16i, mlib_u8); - break; - - case MLIB_SHORT: - srcStride >>= 1; - MLIB_PROCESS_EDGES(MLIB_EDGE_INDEX_s16i, mlib_s16); - break; - default: - /* Ignore incomatible image type. */ - break; - } - - break; - - default: - /* Unsupported type of lookup table. - * Can not be here due to check on line 836, - * so just ignore it. - */ - break; - } - - mlib_free(buff); - - return MLIB_SUCCESS; - } switch (type) { case MLIB_BYTE: diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageCheck.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageCheck.h index 3cfaea8c815..8c6a5b19ede 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageCheck.h +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageCheck.h @@ -82,12 +82,6 @@ extern "C" { return MLIB_FAILURE; \ } -#define MLIB_IMAGE_AND_COLORMAP_ARE_COMPAT(image,colormap) \ - if ((mlib_ImageGetChannels(image) != mlib_ImageGetLutChannels(colormap)) \ - || (mlib_ImageGetLutType(colormap) != mlib_ImageGetType(image))) { \ - return MLIB_FAILURE; \ - } - #define MLIB_IMAGE_GET_ALL_PARAMS(image, type, nchan, width, height, stride, pdata) \ type = mlib_ImageGetType(image); \ nchan = mlib_ImageGetChannels(image); \ diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColorTrue2Index.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColorTrue2Index.c deleted file mode 100644 index 0028fd296c4..00000000000 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColorTrue2Index.c +++ /dev/null @@ -1,4256 +0,0 @@ -/* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * FUNCTION - * mlib_ImageColorTrue2Index - convert a true color image to an indexed - * color image - * - * SYNOPSIS - * mlib_status mlib_ImageColorTrue2Index(mlib_image *dst, - * const mlib_image *src, - * const void *colormap) - * - * ARGUMENTS - * colormap Internal data structure for inverse color mapping. - * dst Pointer to destination image. - * src Pointer to source image. - * - * DESCRIPTION - * Convert a true color image to a pseudo color image with the method - * of finding the nearest matched lut entry for each pixel. - * - * The src can be an MLIB_BYTE or MLIB_SHORT image with 3 or 4 channels. - * The dst must be a 1-channel MLIB_BYTE or MLIB_SHORT image. - * - * The lut might have either 3 or 4 channels. The type of the lut can be - * one of the following: - * MLIB_BYTE in, MLIB_BYTE out (i.e., BYTE-to-BYTE) - * MLIB_BYTE in, MLIB_SHORT out (i.e., BYTE-to-SHORT) - * MLIB_SHORT in, MLIB_SHORT out (i.e., SHORT-to-SHORT) - * MLIB_SHORT in, MLIB_BYTE out (i.e., SHORT-to-BYTE) - * - * The src image and the lut must have same number of channels. - */ - -#include "mlib_image.h" -#include "mlib_ImageColormap.h" -#include "mlib_ImageCheck.h" - -/***************************************************************/ - -/*#define USE_VIS_CODE*/ - -#ifdef USE_VIS_CODE -#include "vis_proto.h" -#define VIS_ALIGNADDR(X, Y) vis_alignaddr((void *)(X), (Y)) -#endif - -/***************************************************************/ - -#define LUT_BYTE_COLORS_3CHANNELS 1000 -#define LUT_BYTE_COLORS_4CHANNELS 3000 -#define LUT_SHORT_COLORS_3CHANNELS 1000 -#define LUT_SHORT_COLORS_4CHANNELS 1000 - -/***************************************************************/ - -#define MAIN_COLORTRUE2INDEX_LOOP( FROM_TYPE, TO_TYPE, NCHANNELS ) \ - for( y = 0; y < height; y++ ) \ - { \ - mlib_ImageColorTrue2IndexLine_##FROM_TYPE##_##TO_TYPE##_##NCHANNELS( \ - sdata, ddata, width, colormap ); \ - \ - sdata += sstride; \ - ddata += dstride; \ - } - -/***************************************************************/ - -#define COLOR_CUBE_U8_3_SEARCH( TABLE_POINTER_TYPE, SHIFT, STEP ) \ -{ \ - const mlib_u8 *c0, *c1, *c2; \ - TABLE_POINTER_TYPE *table = s->table; \ - mlib_s32 bits = s->bits; \ - mlib_s32 nbits = 8 - bits; \ - mlib_s32 mask = ~( ( 1 << nbits ) - 1 ); \ - mlib_s32 j; \ - \ - c0 = src + SHIFT; \ - c1 = src + 1 + SHIFT; \ - c2 = src + 2 + SHIFT; \ - \ - switch( bits ) \ - { \ - case 1: \ - case 2: \ - { \ - mlib_s32 bits0 = 8 - bits; \ - mlib_s32 bits1 = bits0 - bits; \ - mlib_s32 bits2 = bits1 - bits; \ - \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( *c0 & mask ) >> bits2 ) | \ - ( ( *c1 & mask ) >> bits1 ) | \ - ( ( *c2 & mask ) >> bits0 ) ]; \ - \ - c0 += STEP; \ - c1 += STEP; \ - c2 += STEP; \ - } \ - break; \ - } \ - case 3: \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( *c0 & mask ) << 1 ) | \ - ( ( *c1 & mask ) >> 2 ) | \ - ( ( *c2 & mask ) >> 5 ) ]; \ - \ - c0 += STEP; \ - c1 += STEP; \ - c2 += STEP; \ - } \ - break; \ - } \ - case 4: \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( *c0 & mask ) << 4 ) | \ - ( *c1 & mask ) | \ - ( ( *c2 & mask ) >> 4 ) ]; \ - \ - c0 += STEP; \ - c1 += STEP; \ - c2 += STEP; \ - } \ - break; \ - } \ - case 5: \ - case 6: \ - case 7: \ - { \ - mlib_s32 bits0 = 8 - bits; \ - mlib_s32 bits1 = bits * 2 - 8; \ - mlib_s32 bits2 = bits1 + bits; \ - \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( *c0 & mask ) << bits2 ) | \ - ( ( *c1 & mask ) << bits1 ) | \ - ( ( *c2 & mask ) >> bits0 ) ]; \ - \ - c0 += STEP; \ - c1 += STEP; \ - c2 += STEP; \ - } \ - break; \ - } \ - case 8: \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( *c0 & mask ) << 16 ) | \ - ( ( *c1 & mask ) << 8 ) | \ - ( *c2 & mask ) ]; \ - \ - c0 += STEP; \ - c1 += STEP; \ - c2 += STEP; \ - } \ - break; \ - } \ - } \ -} - -/***************************************************************/ -#define COLOR_CUBE_U8_4_SEARCH( TABLE_TYPE ) \ -{ \ - const mlib_u8 *c0, *c1, *c2, *c3; \ - TABLE_TYPE *table = s->table; \ - mlib_s32 bits = s->bits; \ - mlib_s32 nbits = 8 - bits; \ - mlib_s32 mask = ~( ( 1 << nbits ) - 1 ); \ - mlib_s32 j; \ - \ - c0 = src; \ - c1 = src + 1; \ - c2 = src + 2; \ - c3 = src + 3; \ - \ - switch( bits ) \ - { \ - case 1: \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( *c0 & mask ) >> 4 ) | \ - ( ( *c1 & mask ) >> 5 ) | \ - ( ( *c2 & mask ) >> 6 ) | \ - ( ( *c3 & mask ) >> 7 ) ]; \ - \ - c0 += 4; \ - c1 += 4; \ - c2 += 4; \ - c3 += 4; \ - } \ - break; \ - } \ - case 2: \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( *c0 & mask ) | \ - ( ( *c1 & mask ) >> 2 ) | \ - ( ( *c2 & mask ) >> 4 ) | \ - ( ( *c3 & mask ) >> 6 ) ]; \ - \ - c0 += 4; \ - c1 += 4; \ - c2 += 4; \ - c3 += 4; \ - } \ - break; \ - } \ - case 3: \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( *c0 & mask ) << 4 ) | \ - ( ( *c1 & mask ) << 1 ) | \ - ( ( *c2 & mask ) >> 2 ) | \ - ( ( *c3 & mask ) >> 5 ) ]; \ - \ - c0 += 4; \ - c1 += 4; \ - c2 += 4; \ - c3 += 4; \ - } \ - break; \ - } \ - case 4: \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( *c0 & mask ) << 8 ) | \ - ( ( *c1 & mask ) << 4 ) | \ - ( *c2 & mask ) | \ - ( ( *c3 & mask ) >> 4 ) ]; \ - \ - c0 += 4; \ - c1 += 4; \ - c2 += 4; \ - c3 += 4; \ - } \ - break; \ - } \ - case 5: \ - case 6: \ - { \ - mlib_s32 bits3 = bits * 4 - 8; \ - mlib_s32 bits2 = bits3 - bits; \ - mlib_s32 bits1 = bits2 - bits; \ - mlib_s32 bits0 = 8 - bits; \ - \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( *c0 & mask ) << bits3 ) | \ - ( ( *c1 & mask ) << bits2 ) | \ - ( ( *c2 & mask ) << bits1 ) | \ - ( ( *c3 & mask ) >> bits0 ) ]; \ - \ - c0 += 4; \ - c1 += 4; \ - c2 += 4; \ - c3 += 4; \ - } \ - break; \ - } \ - case 7: \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( *c0 & mask ) << 20 ) | \ - ( ( *c1 & mask ) << 13 ) | \ - ( ( *c2 & mask ) << 6 ) | \ - ( ( *c3 & mask ) >> 1 ) ]; \ - \ - c0 += 4; \ - c1 += 4; \ - c2 += 4; \ - c3 += 4; \ - } \ - break; \ - } \ - case 8: /* will never be called */ \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( *c0 & mask ) << 24 ) | \ - ( ( *c1 & mask ) << 16 ) | \ - ( ( *c2 & mask ) << 8 ) | \ - ( *c3 & mask ) ]; \ - \ - c0 += 4; \ - c1 += 4; \ - c2 += 4; \ - c3 += 4; \ - } \ - break; \ - } \ - } \ -} - -/***************************************************************/ -#define COLOR_CUBE_S16_3_SEARCH( TABLE_TYPE, SHIFT, STEP ) \ -{ \ - const mlib_s16 *c0, *c1, *c2; \ - mlib_s32 bits = s->bits; \ - mlib_s32 nbits = 16 - bits; \ - mlib_s32 mask = ~( ( 1 << nbits ) - 1 ); \ - TABLE_TYPE *table = s->table; \ - mlib_s32 j; \ - \ - c0 = src + SHIFT; \ - c1 = src + 1 + SHIFT; \ - c2 = src + 2 + SHIFT; \ - \ - switch( bits ) \ - { \ - case 1: \ - case 2: \ - case 3: \ - case 4: \ - case 5: \ - { \ - mlib_s32 bits0 = 16 - bits; \ - mlib_s32 bits1 = bits0 - bits; \ - mlib_s32 bits2 = bits1 - bits; \ - \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) >> bits2 ) | \ - ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> bits1 ) | \ - ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits0 ) ]; \ - \ - c0 += STEP; \ - c1 += STEP; \ - c2 += STEP; \ - } \ - break; \ - } \ - case 6: \ - case 7: \ - { \ - mlib_s32 bits0 = 16 - bits; \ - mlib_s32 bits1 = bits0 - bits; \ - mlib_s32 bits2 = bits * 3 - 16; \ - \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << bits2 ) | \ - ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> bits1 ) | \ - ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits0 ) ]; \ - \ - c0 += STEP; \ - c1 += STEP; \ - c2 += STEP; \ - } \ - break; \ - } \ - case 8: \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << 8 ) | \ - ( ( *c1 - MLIB_S16_MIN ) & mask ) | \ - ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> 8 ) ]; \ - \ - c0 += STEP; \ - c1 += STEP; \ - c2 += STEP; \ - } \ - break; \ - } \ - case 9: \ - case 10: \ - { \ - mlib_s32 bits0 = 16 - bits; \ - mlib_s32 bits1 = 2 * bits - 16; \ - mlib_s32 bits2 = bits1 + bits; \ - \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << bits2 ) | \ - ( ( ( *c1 - MLIB_S16_MIN ) & mask ) << bits1 ) | \ - ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits0 ) ]; \ - \ - c0 += STEP; \ - c1 += STEP; \ - c2 += STEP; \ - } \ - break; \ - } \ - /* Other cases may not be considered as the table size will be more \ - than 2^32 */ \ - } \ -} - -/***************************************************************/ -#define COLOR_CUBE_S16_4_SEARCH( TABLE_TYPE ) \ -{ \ - const mlib_s16 *c0, *c1, *c2, *c3; \ - TABLE_TYPE *table = s->table; \ - mlib_s32 bits = s->bits; \ - mlib_s32 nbits = 16 - bits; \ - mlib_s32 mask = ~( ( 1 << nbits ) - 1 ); \ - mlib_s32 j; \ - \ - c0 = src; \ - c1 = src + 1; \ - c2 = src + 2; \ - c3 = src + 3; \ - \ - switch( bits ) \ - { \ - case 1: \ - case 2: \ - case 3: \ - { \ - mlib_s32 bits0 = 16 - bits; \ - mlib_s32 bits1 = bits0 - bits; \ - mlib_s32 bits2 = bits1 - bits; \ - mlib_s32 bits3 = bits2 - bits; \ - \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) >> bits3 ) | \ - ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> bits2 ) | \ - ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits1 ) | \ - ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> bits0 ) ]; \ - \ - c0 += 4; \ - c1 += 4; \ - c2 += 4; \ - c3 += 4; \ - } \ - break; \ - } \ - case 4: \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( *c0 - MLIB_S16_MIN ) & mask ) | \ - ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> 4 ) | \ - ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> 8 ) | \ - ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> 12 ) ]; \ - \ - c0 += 4; \ - c1 += 4; \ - c2 += 4; \ - c3 += 4; \ - } \ - break; \ - } \ - case 5: \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << 4 ) | \ - ( ( ( *c1 - MLIB_S16_MIN ) & mask ) >> 1 ) | \ - ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> 6 ) | \ - ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> 11 ) ]; \ - \ - c0 += 4; \ - c1 += 4; \ - c2 += 4; \ - c3 += 4; \ - } \ - break; \ - } \ - case 6: \ - case 7: \ - { \ - mlib_s32 bits0 = 16 - bits; \ - mlib_s32 bits1 = bits0 - bits; \ - mlib_s32 bits3 = bits * 4 - 16; \ - mlib_s32 bits2 = bits3 - bits; \ - \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << bits3 ) | \ - ( ( ( *c1 - MLIB_S16_MIN ) & mask ) << bits2 ) | \ - ( ( ( *c2 - MLIB_S16_MIN ) & mask ) >> bits1 ) | \ - ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> bits0 ) ]; \ - \ - c0 += 4; \ - c1 += 4; \ - c2 += 4; \ - c3 += 4; \ - } \ - break; \ - } \ - case 8: \ - { \ - for( j = 0; j < length; j++ ) \ - { \ - dst[ j ] = table[ ( ( ( *c0 - MLIB_S16_MIN ) & mask ) << 16 ) | \ - ( ( ( *c1 - MLIB_S16_MIN ) & mask ) << 8 ) | \ - ( ( *c2 - MLIB_S16_MIN ) & mask ) | \ - ( ( ( *c3 - MLIB_S16_MIN ) & mask ) >> 8 ) ]; \ - \ - c0 += 4; \ - c1 += 4; \ - c2 += 4; \ - c3 += 4; \ - } \ - break; \ - } \ - /* Other cases may not be considered as the table size will be more \ - than 2^32 */ \ - } \ -} - -/***************************************************************/ -#define BINARY_TREE_SEARCH_RIGHT( POSITION, COLOR_MAX, SHIFT ) \ -{ \ - if( ( distance >= ( ( ( position[ POSITION ] + current_size - \ - c[ POSITION ] ) * ( position[ POSITION ] + current_size - \ - c[ POSITION ] ) ) >> SHIFT ) ) && \ - ( position[ POSITION ] + current_size != COLOR_MAX ) ) \ - continue_up = 1; \ -} - -/***************************************************************/ -#define BINARY_TREE_EXPLORE_RIGHT_3( POSITION, COLOR_MAX, IMAGE_TYPE, \ - FIRST_NEIBOUR, SECOND_NEIBOUR, SUBSTRACTION, SHIFT ) \ -{ \ - if( distance >= ( ( ( position[ POSITION ] + current_size - \ - c[ POSITION ] ) * ( position[ POSITION ] + \ - current_size - c[ POSITION ] ) ) >> SHIFT ) ) \ - { \ - if( distance < ( ( ( COLOR_MAX - c[ POSITION ] ) * \ - ( COLOR_MAX - c[ POSITION ] ) ) >> SHIFT ) ) \ - { \ - if( distance < ( ( ( position[ POSITION ] + \ - current_size * 2 - c[ POSITION ] ) * \ - ( position[ POSITION ] + current_size * 2 - \ - c[ POSITION ] ) ) >> SHIFT ) ) \ - { \ - /* Check only a part of quadrant */ \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 1; \ - check_neibours[ SECOND_NEIBOUR ] += 1; \ - check_corner += 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Only a part of quadrant needs checking */ \ - distance = \ - mlib_search_quadrant_part_to_left_##IMAGE_TYPE##_3( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c, p, \ - position[ POSITION ] + current_size, pass - 1, POSITION ); \ - } \ - else /* Check whole quadrant */ \ - { \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 2; \ - check_neibours[ SECOND_NEIBOUR ] += 2; \ - check_corner += 2; \ - continue_up = 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Here is a full node. Just explore it */ \ - distance = mlib_search_quadrant_##IMAGE_TYPE##_3( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], p ); \ - } \ - } \ - else /* Cell is on the edge of the space */ \ - { \ - if( position[ POSITION ] + current_size * 2 == \ - COLOR_MAX ) \ - { \ - /* Check only a part of quadrant */ \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 1; \ - check_neibours[ SECOND_NEIBOUR ] += 1; \ - check_corner += 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Only a part of quadrant needs checking */ \ - distance = \ - mlib_search_quadrant_part_to_left_##IMAGE_TYPE##_3( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c, p, \ - position[ POSITION ] + current_size, \ - pass - 1, POSITION ); \ - } \ - else /* Check whole quadrant */ \ - { \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 2; \ - check_neibours[ SECOND_NEIBOUR ] += 2; \ - check_corner += 2; \ - continue_up = 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Here is a full node. Just explore it */ \ - distance = mlib_search_quadrant_##IMAGE_TYPE##_3( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], p ); \ - } \ - } \ - } \ -} - -/***************************************************************/ -#define BINARY_TREE_EXPLORE_RIGHT_4( POSITION, COLOR_MAX, IMAGE_TYPE, \ - FIRST_NEIBOUR, SECOND_NEIBOUR, THIRD_NEIBOUR, SUBSTRACTION, SHIFT ) \ -{ \ - if( distance >= ( ( ( position[ POSITION ] + current_size - \ - c[ POSITION ] ) * ( position[ POSITION ] + \ - current_size - c[ POSITION ] ) ) >> SHIFT ) ) \ - { \ - if( distance < ( ( ( COLOR_MAX - c[ POSITION ] ) * \ - ( COLOR_MAX - c[ POSITION ] ) ) >> SHIFT ) ) \ - { \ - if( distance < ( ( ( position[ POSITION ] + \ - current_size * 2 - c[ POSITION ] ) * \ - ( position[ POSITION ] + current_size * 2 - \ - c[ POSITION ] ) ) >> SHIFT ) ) \ - { \ - /* Check only a part of quadrant */ \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 1; \ - check_neibours[ SECOND_NEIBOUR ] += 1; \ - check_neibours[ THIRD_NEIBOUR ] += 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ], \ - p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Only a part of quadrant needs checking */ \ - distance = \ - mlib_search_quadrant_part_to_left_##IMAGE_TYPE##_4( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c, p, \ - position[ POSITION ] + current_size, pass - 1, POSITION ); \ - } \ - else /* Check whole quadrant */ \ - { \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 2; \ - check_neibours[ SECOND_NEIBOUR ] += 2; \ - check_neibours[ THIRD_NEIBOUR ] += 2; \ - continue_up = 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ], \ - p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Here is a full node. Just explore it */ \ - distance = mlib_search_quadrant_##IMAGE_TYPE##_4( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \ - } \ - } \ - else /* Cell is on the edge of the space */ \ - { \ - if( position[ POSITION ] + current_size * 2 == \ - COLOR_MAX ) \ - { \ - /* Check only a part of quadrant */ \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 1; \ - check_neibours[ SECOND_NEIBOUR ] += 1; \ - check_neibours[ THIRD_NEIBOUR ] += 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ], \ - p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Only a part of quadrant needs checking */ \ - distance = \ - mlib_search_quadrant_part_to_left_##IMAGE_TYPE##_4( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c, p, \ - position[ POSITION ] + current_size, \ - pass - 1, POSITION ); \ - } \ - else /* Check whole quadrant */ \ - { \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 2; \ - check_neibours[ SECOND_NEIBOUR ] += 2; \ - check_neibours[ THIRD_NEIBOUR ] += 2; \ - continue_up = 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ], \ - p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Here is a full node. Just explore it */ \ - distance = mlib_search_quadrant_##IMAGE_TYPE##_4( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \ - } \ - } \ - } \ -} - -/***************************************************************/ -#define BINARY_TREE_SEARCH_LEFT( POSITION, SHIFT ) \ -{ \ - if( ( distance > ( ( ( position[ POSITION ] - c[ POSITION ] ) * \ - ( position[ POSITION ] - c[ POSITION ] ) ) >> SHIFT ) ) && \ - position[ POSITION ] ) \ - continue_up = 1; \ -} - -/***************************************************************/ -#define BINARY_TREE_EXPLORE_LEFT_3( POSITION, IMAGE_TYPE, \ - FIRST_NEIBOUR, SECOND_NEIBOUR, SUBSTRACTION, SHIFT ) \ -{ \ - if( distance > \ - ( ( ( c[ POSITION ] - position[ POSITION ] ) * \ - ( c[ POSITION ] - position[ POSITION ] ) ) >> SHIFT ) ) \ - { \ - if( distance <= ( ( c[ POSITION ] * c[ POSITION ] ) >> SHIFT ) ) \ - { \ - if( distance <= ( ( ( c[ POSITION ] + current_size - \ - position[ POSITION ] ) * \ - ( c[ POSITION ] + current_size - \ - position[ POSITION ] ) ) >> SHIFT ) ) \ - { \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 1; \ - check_neibours[ SECOND_NEIBOUR ] += 1; \ - check_corner += 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Only a part of quadrant needs checking */ \ - distance = \ - mlib_search_quadrant_part_to_right_##IMAGE_TYPE##_3( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c, p, \ - position[ POSITION ] - current_size, pass - 1, POSITION ); \ - } \ - else /* Check whole quadrant */ \ - { \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 2; \ - check_neibours[ SECOND_NEIBOUR ] += 2; \ - check_corner += 2; \ - continue_up = 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Here is a full node. Just explore it */ \ - distance = mlib_search_quadrant_##IMAGE_TYPE##_3( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], p ); \ - } \ - } \ - else \ - { \ - if( !( position[ POSITION ] - current_size ) ) \ - { \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 1; \ - check_neibours[ SECOND_NEIBOUR ] += 1; \ - check_corner += 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Only a part of quadrant needs checking */ \ - distance = \ - mlib_search_quadrant_part_to_right_##IMAGE_TYPE##_3( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c, p, \ - position[ POSITION ] - current_size, pass - 1, POSITION ); \ - } \ - else \ - { \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 2; \ - check_neibours[ SECOND_NEIBOUR ] += 2; \ - check_corner += 2; \ - continue_up = 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Here is a full node. Just explore it */ \ - distance = mlib_search_quadrant_##IMAGE_TYPE##_3( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], p ); \ - } \ - } \ - } \ -} - -/***************************************************************/ -#define BINARY_TREE_EXPLORE_LEFT_4( POSITION, IMAGE_TYPE, \ - FIRST_NEIBOUR, SECOND_NEIBOUR, THIRD_NEIBOUR, SUBSTRACTION, SHIFT ) \ -{ \ - if( distance > \ - ( ( ( c[ POSITION ] - position[ POSITION ] ) * \ - ( c[ POSITION ] - position[ POSITION ] ) ) >> SHIFT ) ) \ - { \ - if( distance <= ( ( c[ POSITION ] * c[ POSITION ] ) >> SHIFT ) ) \ - { \ - if( distance <= ( ( ( c[ POSITION ] + current_size - \ - position[ POSITION ] ) * \ - ( c[ POSITION ] + current_size - \ - position[ POSITION ] ) ) >> SHIFT ) ) \ - { \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 1; \ - check_neibours[ SECOND_NEIBOUR ] += 1; \ - check_neibours[ THIRD_NEIBOUR ] += 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ], \ - p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Only a part of quadrant needs checking */ \ - distance = \ - mlib_search_quadrant_part_to_right_##IMAGE_TYPE##_4( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c, p, \ - position[ POSITION ] - current_size, pass - 1, POSITION ); \ - } \ - else /* Check whole quadrant */ \ - { \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 2; \ - check_neibours[ SECOND_NEIBOUR ] += 2; \ - check_neibours[ THIRD_NEIBOUR ] += 2; \ - continue_up = 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ], \ - p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Here is a full node. Just explore it */ \ - distance = mlib_search_quadrant_##IMAGE_TYPE##_4( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \ - } \ - } \ - else \ - { \ - if( !( position[ POSITION ] - current_size ) ) \ - { \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 1; \ - check_neibours[ SECOND_NEIBOUR ] += 1; \ - check_neibours[ THIRD_NEIBOUR ] += 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ], \ - p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Only a part of quadrant needs checking */ \ - distance = \ - mlib_search_quadrant_part_to_right_##IMAGE_TYPE##_4( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c, p, \ - position[ POSITION ] - current_size, pass - 1, POSITION ); \ - } \ - else \ - { \ - mlib_s32 qq = q ^ ( 1 << POSITION ); \ - \ - check_neibours[ FIRST_NEIBOUR ] += 2; \ - check_neibours[ SECOND_NEIBOUR ] += 2; \ - check_neibours[ THIRD_NEIBOUR ] += 2; \ - continue_up = 1; \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. \ - Check the distance */ \ - mlib_s32 new_found_color = \ - node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ], \ - p[ 0 ][ new_found_color ] - SUBSTRACTION, c[ 1 ], \ - p[ 1 ][ new_found_color ] - SUBSTRACTION, c[ 2 ], \ - p[ 2 ][ new_found_color ] - SUBSTRACTION, c[ 3 ], \ - p[ 3 ][ new_found_color ] - SUBSTRACTION, SHIFT ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Here is a full node. Just explore it */ \ - distance = mlib_search_quadrant_##IMAGE_TYPE##_4( \ - node->contents.quadrants[ qq ], \ - distance, &found_color, c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \ - } \ - } \ - } \ -} - -/***************************************************************/ -#define CHECK_QUADRANT_U8_3( qq ) \ -{ \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. Check the distance */ \ - mlib_s32 new_found_color = node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_3( c[ 0 ], \ - p[ 0 ][ new_found_color ], c[ 1 ], \ - p[ 1 ][ new_found_color ], c[ 2 ], \ - p[ 2 ][ new_found_color ], 0 ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Here is a full node. Just explore it all */ \ - distance = mlib_search_quadrant_U8_3( \ - node->contents.quadrants[ qq ], distance, &found_color, \ - c[ 0 ], c[ 1 ], c[ 2 ], p ); \ -/* Else there is just an empty cell */ \ -} - -/***************************************************************/ -#define CHECK_QUADRANT_S16_3( qq ) \ -{ \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. Check the distance */ \ - mlib_s32 new_found_color = node->contents.index[ qq ]; \ - mlib_u32 palc0, palc1, palc2, newdistance; \ - \ - palc0 = p[ 0 ][ new_found_color ] - MLIB_S16_MIN; \ - palc1 = p[ 1 ][ new_found_color ] - MLIB_S16_MIN; \ - palc2 = p[ 2 ][ new_found_color ] - MLIB_S16_MIN; \ - \ - newdistance = FIND_DISTANCE_3( c[ 0 ], palc0, \ - c[ 1 ], palc1, \ - c[ 2 ], palc2, 2 ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Here is a full node. Just explore it all */ \ - distance = mlib_search_quadrant_S16_3( \ - node->contents.quadrants[ qq ], distance, &found_color, \ - c[ 0 ], c[ 1 ], c[ 2 ], p ); \ -/* Else there is just an empty cell */ \ -} - -/***************************************************************/ -#define BINARY_TREE_SEARCH_3( SOURCE_IMAGE, POINTER_TYPE, BITS, \ - COLOR_MAX, SUBTRACTION, POINTER_SHIFT, STEP, SHIFT ) \ -{ \ - const POINTER_TYPE *channels[ 3 ], *p[ 3 ]; \ - mlib_u32 c[ 3 ]; \ - mlib_s32 j; \ - \ - p[ 0 ] = s->lut[ 0 ]; \ - p[ 1 ] = s->lut[ 1 ]; \ - p[ 2 ] = s->lut[ 2 ]; \ - channels[ 0 ] = src + POINTER_SHIFT; \ - channels[ 1 ] = src + 1 + POINTER_SHIFT; \ - channels[ 2 ] = src + 2 + POINTER_SHIFT; \ - \ - for( j = 0; j < length; j++ ) \ - { \ - mlib_s32 pass = BITS - 1; \ - mlib_u32 position[ 3 ] = { 0, 0, 0 }; \ - mlib_s32 we_found_it = 0; \ - struct lut_node_3 *node = s->table; \ - /* Stack pointer pointers to the first free element of stack. */ \ - /* The node we are in is in the `node' */ \ - struct \ - { \ - struct lut_node_3 *node; \ - mlib_s32 q; \ - } stack[ BITS ]; \ - mlib_s32 stack_pointer = 0; \ - \ - c[ 0 ] = *channels[ 0 ] - SUBTRACTION; \ - c[ 1 ] = *channels[ 1 ] - SUBTRACTION; \ - c[ 2 ] = *channels[ 2 ] - SUBTRACTION; \ - \ - do \ - { \ - mlib_s32 q; \ - mlib_u32 current_size = 1 << pass; \ - \ - q = ( ( c[ 0 ] >> pass ) & 1 ) | \ - ( ( ( c[ 1 ] << 1 ) >> pass ) & 2 ) | \ - ( ( ( c[ 2 ] << 2 ) >> pass ) & 4 ); \ - \ - position[ 0 ] |= c[ 0 ] & current_size; \ - position[ 1 ] |= c[ 1 ] & current_size; \ - position[ 2 ] |= c[ 2 ] & current_size; \ - \ - if( node->tag & ( 1 << q ) ) \ - { \ - /* \ - Here is a cell with one color. We need to be sure it's \ - the one that is the closest to our color \ - */ \ - mlib_s32 palindex = node->contents.index[ q ]; \ - mlib_u32 palc[ 3 ]; \ - mlib_s32 identical; \ - \ - palc[ 0 ] = p[ 0 ][ palindex ] - SUBTRACTION; \ - palc[ 1 ] = p[ 1 ][ palindex ] - SUBTRACTION; \ - palc[ 2 ] = p[ 2 ][ palindex ] - SUBTRACTION; \ - \ - identical = ( palc[ 0 ] - c[ 0 ] ) | ( palc[ 1 ] - c[ 1 ] ) | \ - ( palc[ 2 ] - c[ 2 ] ); \ - \ - if( !identical || BITS - pass == bits ) \ - { \ - /* Oh, here it is :) */ \ - dst[ j ] = palindex + s->offset; \ - we_found_it = 1; \ - } \ - else \ - { \ - mlib_u32 distance; \ - /* First index is the channel, second is the number of the \ - side */ \ - mlib_s32 found_color; \ - mlib_s32 continue_up; \ - \ - distance = FIND_DISTANCE_3( c[ 0 ], palc[ 0 ], \ - c[ 1 ], palc[ 1 ], c[ 2 ], palc[ 2 ], SHIFT ); \ - found_color = palindex; \ - \ - do \ - { \ - mlib_s32 check_corner; \ - \ - /* \ - Neibours are enumerated in a cicle: \ - 0 - between quadrants 0 and 1, \ - 1 - between quadrants 1 and 2 and \ - 2 - between quadrants 2 and 0 \ - */ \ - mlib_s32 check_neibours[ 3 ]; \ - \ - /* \ - Others are three two neibour quadrants \ - \ - Side number is [ ][ ], e.g. 2 is 0..010b, so the sides it has \ - near are: \ - [ 0 (coordinate number) ][ 0 (bit 0 in the number) ] \ - [ 1 (coordinate number) ][ 1 (bit 1 in the number) ] \ - \ - Now we can look in the three nearest quadrants. Do \ - we really need it ? Check it. \ - */ \ - \ - check_corner = check_neibours[ 0 ] = check_neibours[ 1 ] = \ - check_neibours[ 2 ] = 0; \ - continue_up = 0; \ - \ - if( q & 1 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_3( 0, SOURCE_IMAGE, 2, 0, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_3( 0, COLOR_MAX, SOURCE_IMAGE, 2, 0, \ - SUBTRACTION, SHIFT ); \ - } \ - \ - if( q & 2 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_3( 1, SOURCE_IMAGE, 0, 1, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_3( 1, COLOR_MAX, SOURCE_IMAGE, 0, 1, \ - SUBTRACTION, SHIFT ); \ - } \ - \ - if( q & 4 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_3( 2, SOURCE_IMAGE, 1, 2, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_3( 2, COLOR_MAX, SOURCE_IMAGE, 1, 2, \ - SUBTRACTION, SHIFT ); \ - } \ - \ - if( check_neibours[ 0 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 3; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq ); \ - } \ - \ - if( check_neibours[ 1 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 6; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq ); \ - } \ - \ - if( check_neibours[ 2 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 5; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq ); \ - } \ - \ - if( check_corner >= 3 ) \ - { \ - mlib_s32 qq = q ^ 7; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq ); \ - } \ - \ - if( q & 1 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 0, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 0, SHIFT ); \ - } \ - \ - if( q & 2 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 1, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 1, SHIFT ); \ - } \ - \ - if( q & 4 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 2, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 2, SHIFT ); \ - } \ - \ - position[ 0 ] &= ~( c[ 0 ] & current_size ); \ - position[ 1 ] &= ~( c[ 1 ] & current_size ); \ - position[ 2 ] &= ~( c[ 2 ] & current_size ); \ - \ - current_size <<= 1; \ - \ - pass++; \ - \ - stack_pointer--; \ - q = stack[ stack_pointer ].q; \ - node = stack[ stack_pointer ].node; \ - } while( continue_up ); \ - \ - dst[ j ] = found_color + s->offset; \ - \ - we_found_it = 1; \ - } \ - } \ - else if( node->contents.quadrants[ q ] ) \ - { \ - /* Descend one level */ \ - stack[ stack_pointer ].node = node; \ - stack[ stack_pointer++ ].q = q; \ - node = node->contents.quadrants[ q ]; \ - } \ - else \ - { \ - /* Found the empty quadrant. Look around */ \ - mlib_u32 distance = MLIB_U32_MAX; \ - mlib_s32 found_color; \ - mlib_s32 continue_up; \ - \ - /* \ - As we had come to this level, it is warranted that there \ - are other points on this level near the empty quadrant \ - */ \ - do \ - { \ - mlib_s32 check_corner; \ - mlib_s32 check_neibours[ 3 ]; \ - \ - check_corner = check_neibours[ 0 ] = check_neibours[ 1 ] = \ - check_neibours[ 2 ] = 0; \ - continue_up = 0; \ - \ - if( q & 1 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_3( 0, SOURCE_IMAGE, 2, 0, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_3( 0, COLOR_MAX, SOURCE_IMAGE, 2, 0, \ - SUBTRACTION, SHIFT ); \ - } \ - \ - if( q & 2 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_3( 1, SOURCE_IMAGE, 0, 1, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_3( 1, COLOR_MAX, SOURCE_IMAGE, 0, 1, \ - SUBTRACTION, SHIFT ); \ - } \ - \ - if( q & 4 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_3( 2, SOURCE_IMAGE, 1, 2, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_3( 2, COLOR_MAX, SOURCE_IMAGE, 1, 2, \ - SUBTRACTION, SHIFT ); \ - } \ - \ - if( check_neibours[ 0 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 3; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq ); \ - } \ - \ - if( check_neibours[ 1 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 6; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq ); \ - } \ - \ - if( check_neibours[ 2 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 5; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq ); \ - } \ - \ - if( check_corner >= 3 ) \ - { \ - mlib_s32 qq = q ^ 7; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_3( qq ); \ - } \ - \ - if( q & 1 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 0, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 0, SHIFT ); \ - } \ - \ - if( q & 2 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 1, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 1, SHIFT ); \ - } \ - \ - if( q & 4 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 2, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 2, SHIFT ); \ - } \ - \ - position[ 0 ] &= ~( c[ 0 ] & current_size ); \ - position[ 1 ] &= ~( c[ 1 ] & current_size ); \ - position[ 2 ] &= ~( c[ 2 ] & current_size ); \ - \ - current_size <<= 1; \ - \ - pass++; \ - \ - stack_pointer--; \ - q = stack[ stack_pointer ].q; \ - node = stack[ stack_pointer ].node; \ - } while( continue_up ); \ - \ - dst[ j ] = found_color + s->offset; \ - we_found_it = 1; \ - } \ - \ - pass--; \ - \ - } while( !we_found_it ); \ - \ - channels[ 0 ] += STEP; \ - channels[ 1 ] += STEP; \ - channels[ 2 ] += STEP; \ - } \ -} - -/***************************************************************/ -#define CHECK_QUADRANT_U8_4( qq ) \ -{ \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. Check the distance */ \ - mlib_s32 new_found_color = node->contents.index[ qq ]; \ - mlib_u32 newdistance = FIND_DISTANCE_4( c[ 0 ], \ - p[ 0 ][ new_found_color ], c[ 1 ], \ - p[ 1 ][ new_found_color ], c[ 2 ], \ - p[ 2 ][ new_found_color ], c[ 3 ], \ - p[ 3 ][ new_found_color ], 0 ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Here is a full node. Just explore it all */ \ - distance = mlib_search_quadrant_U8_4( \ - node->contents.quadrants[ qq ], distance, &found_color, \ - c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \ -/* Else there is just an empty cell */ \ -} - -/***************************************************************/ -#define CHECK_QUADRANT_S16_4( qq ) \ -{ \ - if( node->tag & ( 1 << qq ) ) \ - { \ - /* Here is another color cell. Check the distance */ \ - mlib_s32 new_found_color = node->contents.index[ qq ]; \ - mlib_u32 palc0, palc1, palc2, palc3, newdistance; \ - \ - palc0 = p[ 0 ][ new_found_color ] - MLIB_S16_MIN; \ - palc1 = p[ 1 ][ new_found_color ] - MLIB_S16_MIN; \ - palc2 = p[ 2 ][ new_found_color ] - MLIB_S16_MIN; \ - palc3 = p[ 3 ][ new_found_color ] - MLIB_S16_MIN; \ - \ - newdistance = FIND_DISTANCE_4( c[ 0 ], palc0, \ - c[ 1 ], palc1, \ - c[ 2 ], palc2, \ - c[ 3 ], palc3, 2 ); \ - \ - if( newdistance < distance ) \ - { \ - found_color = new_found_color; \ - distance = newdistance; \ - } \ - } \ - else if( node->contents.quadrants[ qq ] ) \ - /* Here is a full node. Just explore it all */ \ - distance = mlib_search_quadrant_S16_4( \ - node->contents.quadrants[ qq ], distance, &found_color, \ - c[ 0 ], c[ 1 ], c[ 2 ], c[ 3 ], p ); \ -/* Else there is just an empty cell */ \ -} - -/***************************************************************/ -#define BINARY_TREE_SEARCH_4( SOURCE_IMAGE, POINTER_TYPE, BITS, \ - COLOR_MAX, SUBTRACTION, SHIFT ) \ -{ \ - const POINTER_TYPE *channels[ 4 ], *p[ 4 ]; \ - mlib_u32 c[ 4 ]; \ - mlib_s32 j; \ - \ - p[ 0 ] = s->lut[ 0 ]; \ - p[ 1 ] = s->lut[ 1 ]; \ - p[ 2 ] = s->lut[ 2 ]; \ - p[ 3 ] = s->lut[ 3 ]; \ - channels[ 0 ] = src; \ - channels[ 1 ] = src + 1; \ - channels[ 2 ] = src + 2; \ - channels[ 3 ] = src + 3; \ - \ - for( j = 0; j < length; j++ ) \ - { \ - mlib_s32 pass = BITS - 1; \ - mlib_u32 position[ 4 ] = { 0, 0, 0, 0 }; \ - mlib_s32 we_found_it = 0; \ - struct lut_node_4 *node = s->table; \ - /* Stack pointer pointers to the first free element of stack. */ \ - /* The node we are in is in the `node' */ \ - struct \ - { \ - struct lut_node_4 *node; \ - mlib_s32 q; \ - } stack[ BITS ]; \ - mlib_s32 stack_pointer = 0; \ - \ - c[ 0 ] = *channels[ 0 ] - SUBTRACTION; \ - c[ 1 ] = *channels[ 1 ] - SUBTRACTION; \ - c[ 2 ] = *channels[ 2 ] - SUBTRACTION; \ - c[ 3 ] = *channels[ 3 ] - SUBTRACTION; \ - \ - do \ - { \ - mlib_s32 q; \ - mlib_u32 current_size = 1 << pass; \ - \ - q = ( ( c[ 0 ] >> pass ) & 1 ) | \ - ( ( ( c[ 1 ] << 1 ) >> pass ) & 2 ) | \ - ( ( ( c[ 2 ] << 2 ) >> pass ) & 4 ) | \ - ( ( ( c[ 3 ] << 3 ) >> pass ) & 8 ); \ - \ - position[ 0 ] |= c[ 0 ] & current_size; \ - position[ 1 ] |= c[ 1 ] & current_size; \ - position[ 2 ] |= c[ 2 ] & current_size; \ - position[ 3 ] |= c[ 3 ] & current_size; \ - \ - if( node->tag & ( 1 << q ) ) \ - { \ - /* \ - Here is a cell with one color. We need to be sure it's \ - the one that is the closest to our color \ - */ \ - mlib_s32 palindex = node->contents.index[ q ]; \ - mlib_u32 palc[ 4 ]; \ - mlib_s32 identical; \ - \ - palc[ 0 ] = p[ 0 ][ palindex ] - SUBTRACTION; \ - palc[ 1 ] = p[ 1 ][ palindex ] - SUBTRACTION; \ - palc[ 2 ] = p[ 2 ][ palindex ] - SUBTRACTION; \ - palc[ 3 ] = p[ 3 ][ palindex ] - SUBTRACTION; \ - \ - identical = ( palc[ 0 ] - c[ 0 ] ) | ( palc[ 1 ] - c[ 1 ] ) | \ - ( palc[ 2 ] - c[ 2 ] ) | ( palc[ 3 ] - c[ 3 ] ); \ - \ - if( !identical || BITS - pass == bits ) \ - { \ - /* Oh, here it is :) */ \ - dst[ j ] = palindex + s->offset; \ - we_found_it = 1; \ - } \ - else \ - { \ - mlib_u32 distance; \ - /* First index is the channel, second is the number of the \ - side */ \ - mlib_s32 found_color; \ - mlib_s32 continue_up; \ - \ - distance = FIND_DISTANCE_4( c[ 0 ], palc[ 0 ], \ - c[ 1 ], palc[ 1 ], c[ 2 ], palc[ 2 ], c[ 3 ], palc[ 3 ], SHIFT ); \ - found_color = palindex; \ - \ - do \ - { \ - mlib_s32 check_corner; \ - mlib_s32 check_neibours[ 6 ]; \ - mlib_s32 check_far_neibours[ 4 ]; \ - \ - /* \ - Check neibours: quadrants that are different by 2 bits \ - from the quadrant, that we are in: \ - 3 - 0 \ - 5 - 1 \ - 6 - 2 \ - 9 - 3 \ - 10 - 4 \ - 12 - 5 \ - Far quadrants: different by 3 bits: \ - 7 - 0 \ - 11 - 1 \ - 13 - 2 \ - 14 - 3 \ - */ \ - \ - check_neibours[ 0 ] = check_neibours[ 1 ] = \ - check_neibours[ 2 ] = check_neibours[ 3 ] = \ - check_neibours[ 4 ] = check_neibours[ 5 ] = 0; \ - continue_up = 0; \ - \ - if( q & 1 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_4( 0, SOURCE_IMAGE, 0, 1, 3, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_4( 0, COLOR_MAX, SOURCE_IMAGE, \ - 0, 1, 3, SUBTRACTION, SHIFT ); \ - } \ - \ - if( q & 2 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_4( 1, SOURCE_IMAGE, 0, 2, 4, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_4( 1, COLOR_MAX, SOURCE_IMAGE, \ - 0, 2, 4, SUBTRACTION, SHIFT ); \ - } \ - \ - if( q & 4 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_4( 2, SOURCE_IMAGE, 1, 2, 5, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_4( 2, COLOR_MAX, SOURCE_IMAGE, \ - 1, 2, 5, SUBTRACTION, SHIFT ); \ - } \ - \ - if( q & 8 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_4( 3, SOURCE_IMAGE, 3, 4, 5, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_4( 3, COLOR_MAX, SOURCE_IMAGE, \ - 3, 4, 5, SUBTRACTION, SHIFT ); \ - } \ - \ - check_far_neibours[ 0 ] = check_neibours[ 0 ] + \ - check_neibours[ 1 ] + check_neibours[ 2 ]; \ - check_far_neibours[ 1 ] = check_neibours[ 0 ] + \ - check_neibours[ 3 ] + check_neibours[ 4 ]; \ - check_far_neibours[ 2 ] = check_neibours[ 1 ] + \ - check_neibours[ 3 ] + check_neibours[ 5 ]; \ - check_far_neibours[ 3 ] = check_neibours[ 2 ] + \ - check_neibours[ 4 ] + check_neibours[ 5 ]; \ - \ - check_corner = check_far_neibours[ 0 ] + \ - check_far_neibours[ 1 ] + \ - check_far_neibours[ 2 ] + \ - check_far_neibours[ 3 ]; \ - \ - if( check_neibours[ 0 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 3; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_neibours[ 1 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 5; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_neibours[ 2 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 6; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_neibours[ 3 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 9; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_neibours[ 4 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 10; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_neibours[ 5 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 12; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_far_neibours[ 0 ] >= 3 ) \ - { \ - mlib_s32 qq = q ^ 7; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_far_neibours[ 1 ] >= 3 ) \ - { \ - mlib_s32 qq = q ^ 11; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_far_neibours[ 2 ] >= 3 ) \ - { \ - mlib_s32 qq = q ^ 13; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_far_neibours[ 3 ] >= 3 ) \ - { \ - mlib_s32 qq = q ^ 14; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_corner >= 4 ) \ - { \ - mlib_s32 qq = q ^ 15; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( q & 1 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 0, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 0, SHIFT ); \ - } \ - \ - if( q & 2 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 1, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 1, SHIFT ); \ - } \ - \ - if( q & 4 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 2, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 2, SHIFT ); \ - } \ - \ - if( q & 8 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 3, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 3, SHIFT ); \ - } \ - \ - position[ 0 ] &= ~( c[ 0 ] & current_size ); \ - position[ 1 ] &= ~( c[ 1 ] & current_size ); \ - position[ 2 ] &= ~( c[ 2 ] & current_size ); \ - position[ 3 ] &= ~( c[ 3 ] & current_size ); \ - \ - current_size <<= 1; \ - \ - pass++; \ - \ - stack_pointer--; \ - q = stack[ stack_pointer ].q; \ - node = stack[ stack_pointer ].node; \ - } while( continue_up ); \ - \ - dst[ j ] = found_color + s->offset; \ - we_found_it = 1; \ - } \ - } \ - else if( node->contents.quadrants[ q ] ) \ - { \ - /* Descend one level */ \ - stack[ stack_pointer ].node = node; \ - stack[ stack_pointer++ ].q = q; \ - node = node->contents.quadrants[ q ]; \ - } \ - else \ - { \ - /* Found the empty quadrant. Look around */ \ - mlib_u32 distance = MLIB_U32_MAX; \ - mlib_s32 found_color; \ - mlib_s32 continue_up; \ - \ - /* \ - As we had come to this level, it is warranted that there \ - are other points on this level near the empty quadrant \ - */ \ - do \ - { \ - mlib_s32 check_corner; \ - mlib_s32 check_neibours[ 6 ]; \ - mlib_s32 check_far_neibours[ 4 ]; \ - \ - /* \ - Check neibours: quadrants that are different by 2 bits \ - from the quadrant, that we are in: \ - 3 - 0 \ - 5 - 1 \ - 6 - 2 \ - 9 - 3 \ - 10 - 4 \ - 12 - 5 \ - Far quadrants: different by 3 bits: \ - 7 - 0 \ - 11 - 1 \ - 13 - 2 \ - 14 - 3 \ - */ \ - \ - check_neibours[ 0 ] = check_neibours[ 1 ] = \ - check_neibours[ 2 ] = check_neibours[ 3 ] = \ - check_neibours[ 4 ] = check_neibours[ 5 ] = 0; \ - continue_up = 0; \ - \ - if( q & 1 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_4( 0, SOURCE_IMAGE, 0, 1, 3, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_4( 0, COLOR_MAX, SOURCE_IMAGE, \ - 0, 1, 3, SUBTRACTION, SHIFT ); \ - } \ - \ - if( q & 2 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_4( 1, SOURCE_IMAGE, 0, 2, 4, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_4( 1, COLOR_MAX, SOURCE_IMAGE, \ - 0, 2, 4, SUBTRACTION, SHIFT ); \ - } \ - \ - if( q & 4 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_4( 2, SOURCE_IMAGE, 1, 2, 5, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_4( 2, COLOR_MAX, SOURCE_IMAGE, \ - 1, 2, 5, SUBTRACTION, SHIFT ); \ - } \ - \ - if( q & 8 ) \ - { \ - BINARY_TREE_EXPLORE_LEFT_4( 3, SOURCE_IMAGE, 3, 4, 5, \ - SUBTRACTION, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_EXPLORE_RIGHT_4( 3, COLOR_MAX, SOURCE_IMAGE, \ - 3, 4, 5, SUBTRACTION, SHIFT ); \ - } \ - \ - check_far_neibours[ 0 ] = check_neibours[ 0 ] + \ - check_neibours[ 1 ] + check_neibours[ 2 ]; \ - check_far_neibours[ 1 ] = check_neibours[ 0 ] + \ - check_neibours[ 3 ] + check_neibours[ 4 ]; \ - check_far_neibours[ 2 ] = check_neibours[ 1 ] + \ - check_neibours[ 3 ] + check_neibours[ 5 ]; \ - check_far_neibours[ 3 ] = check_neibours[ 2 ] + \ - check_neibours[ 4 ] + check_neibours[ 5 ]; \ - \ - check_corner = check_far_neibours[ 0 ] + \ - check_far_neibours[ 1 ] + \ - check_far_neibours[ 2 ] + \ - check_far_neibours[ 3 ]; \ - \ - if( check_neibours[ 0 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 3; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_neibours[ 1 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 5; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_neibours[ 2 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 6; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_neibours[ 3 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 9; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_neibours[ 4 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 10; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_neibours[ 5 ] >= 2 ) \ - { \ - mlib_s32 qq = q ^ 12; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_far_neibours[ 0 ] >= 3 ) \ - { \ - mlib_s32 qq = q ^ 7; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_far_neibours[ 1 ] >= 3 ) \ - { \ - mlib_s32 qq = q ^ 11; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_far_neibours[ 2 ] >= 3 ) \ - { \ - mlib_s32 qq = q ^ 13; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_far_neibours[ 3 ] >= 3 ) \ - { \ - mlib_s32 qq = q ^ 14; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( check_corner >= 4 ) \ - { \ - mlib_s32 qq = q ^ 15; \ - CHECK_QUADRANT_##SOURCE_IMAGE##_4( qq ); \ - } \ - \ - if( q & 1 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 0, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 0, SHIFT ); \ - } \ - \ - if( q & 2 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 1, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 1, SHIFT ); \ - } \ - \ - if( q & 4 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 2, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 2, SHIFT ); \ - } \ - \ - if( q & 8 ) \ - { \ - BINARY_TREE_SEARCH_RIGHT( 3, COLOR_MAX, SHIFT ); \ - } \ - else \ - { \ - BINARY_TREE_SEARCH_LEFT( 3, SHIFT ); \ - } \ - \ - position[ 0 ] &= ~( c[ 0 ] & current_size ); \ - position[ 1 ] &= ~( c[ 1 ] & current_size ); \ - position[ 2 ] &= ~( c[ 2 ] & current_size ); \ - position[ 3 ] &= ~( c[ 3 ] & current_size ); \ - \ - current_size <<= 1; \ - \ - pass++; \ - \ - stack_pointer--; \ - q = stack[ stack_pointer ].q; \ - node = stack[ stack_pointer ].node; \ - } while( continue_up ); \ - \ - dst[ j ] = found_color + s->offset; \ - we_found_it = 1; \ - } \ - \ - pass--; \ - \ - } while( !we_found_it ); \ - \ - channels[ 0 ] += 4; \ - channels[ 1 ] += 4; \ - channels[ 2 ] += 4; \ - channels[ 3 ] += 4; \ - } \ -} - -/***************************************************************/ -#define FIND_NEAREST_U8_3_C( SHIFT, STEP ) \ - mlib_s32 i, k, k_min, min_dist, diff, mask; \ - mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1; \ - mlib_s32 entries = s -> lutlength; \ - mlib_d64 *double_lut = mlib_ImageGetLutDoubleData( s ); \ - mlib_d64 col0, col1, col2; \ - mlib_d64 dist, len0, len1, len2; \ - \ - for ( i = 0; i < length; i++ ) { \ - col0 = src[ STEP * i + SHIFT ]; \ - col1 = src[ STEP * i + 1 + SHIFT ]; \ - col2 = src[ STEP * i + 2 + SHIFT ]; \ - min_dist = MLIB_S32_MAX; \ - k_min = 1; \ - len0 = double_lut[ 0 ] - col0; \ - len1 = double_lut[ 1 ] - col1; \ - len2 = double_lut[ 2 ] - col2; \ - \ - for ( k = 1; k <= entries; k++ ) { \ - dist = len0 * len0; \ - len0 = double_lut[ 3 * k ] - col0; \ - dist += len1 * len1; \ - len1 = double_lut[ 3 * k + 1 ] - col1; \ - dist += len2 * len2; \ - len2 = double_lut[ 3 * k + 2 ] - col2; \ - diff = ( mlib_s32 )dist - min_dist; \ - mask = diff >> 31; \ - min_dist += diff & mask; \ - k_min += ( k - k_min ) & mask; \ - } \ - \ - dst[ i ] = k_min + offset; \ - } - -/***************************************************************/ -#define FIND_NEAREST_U8_4_C \ - mlib_s32 i, k, k_min, min_dist, diff, mask; \ - mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1; \ - mlib_s32 entries = s -> lutlength; \ - mlib_d64 *double_lut = mlib_ImageGetLutDoubleData( s ); \ - mlib_d64 col0, col1, col2, col3; \ - mlib_d64 dist, len0, len1, len2, len3; \ - \ - for ( i = 0; i < length; i++ ) { \ - col0 = src[ 4 * i ]; \ - col1 = src[ 4 * i + 1 ]; \ - col2 = src[ 4 * i + 2 ]; \ - col3 = src[ 4 * i + 3 ]; \ - min_dist = MLIB_S32_MAX; \ - k_min = 1; \ - len0 = double_lut[ 0 ] - col0; \ - len1 = double_lut[ 1 ] - col1; \ - len2 = double_lut[ 2 ] - col2; \ - len3 = double_lut[ 3 ] - col3; \ - \ - for ( k = 1; k <= entries; k++ ) { \ - dist = len0 * len0; \ - len0 = double_lut[ 4 * k ] - col0; \ - dist += len1 * len1; \ - len1 = double_lut[ 4 * k + 1 ] - col1; \ - dist += len2 * len2; \ - len2 = double_lut[ 4 * k + 2 ] - col2; \ - dist += len3 * len3; \ - len3 = double_lut[ 4 * k + 3 ] - col3; \ - diff = ( mlib_s32 )dist - min_dist; \ - mask = diff >> 31; \ - min_dist += diff & mask; \ - k_min += ( k - k_min ) & mask; \ - } \ - \ - dst[ i ] = k_min + offset; \ - } - -/***************************************************************/ -#define FSQR_S16_HI(dsrc) \ - vis_fpadd32( vis_fmuld8ulx16( vis_read_hi( dsrc ), vis_read_hi( dsrc ) ), \ - vis_fmuld8sux16( vis_read_hi( dsrc ), vis_read_hi( dsrc ) ) ) - -/***************************************************************/ -#define FSQR_S16_LO(dsrc) \ - vis_fpadd32( vis_fmuld8ulx16( vis_read_lo( dsrc ), vis_read_lo( dsrc) ), \ - vis_fmuld8sux16( vis_read_lo( dsrc ), vis_read_lo( dsrc ) ) ) - -/***************************************************************/ -#define FIND_NEAREST_U8_3 \ -{ \ - mlib_d64 *dpsrc, dsrc, dsrc1, ddist, ddist1, ddist2, ddist3; \ - mlib_d64 dcolor, dind, dres, dres1, dpind[1], dpmin[1]; \ - mlib_d64 done = vis_to_double_dup( 1 ), \ - dmax = vis_to_double_dup( MLIB_S32_MAX ); \ - mlib_f32 *lut = ( mlib_f32 * )mlib_ImageGetLutNormalTable( s ); \ - mlib_f32 fone = vis_to_float( 0x100 ); \ - mlib_s32 i, k, mask; \ - mlib_s32 gsr[1]; \ - mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1; \ - mlib_s32 entries = s->lutlength; \ - \ - gsr[0] = vis_read_gsr(); \ - for( i = 0; i <= ( length-2 ); i += 2 ) \ - { \ - dpsrc = VIS_ALIGNADDR( src, -1 ); \ - src += 6; \ - dsrc = dpsrc[ 0 ]; \ - dsrc1 = dpsrc[ 1 ]; \ - dsrc1 = vis_faligndata( dsrc, dsrc1 ); \ - dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone ); \ - VIS_ALIGNADDR( dpsrc, 3 ); \ - dsrc1 = vis_faligndata( dsrc1, dsrc1 ); \ - dsrc1 = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone ); \ - dpind[ 0 ] = dind = done; \ - dpmin[ 0 ] = dmax; \ - dcolor = vis_fmul8x16al( lut[ 0 ], fone ); \ - for( k = 1; k <= entries; k++ ) \ - { \ - ddist1 = vis_fpsub16( dcolor, dsrc ); \ - ddist = FSQR_S16_HI( ddist1 ); \ - ddist1 = FSQR_S16_LO( ddist1 ); \ - dres = vis_fpadd32( ddist, ddist1 ); \ - ddist3 = vis_fpsub16( dcolor, dsrc1 ); \ - ddist2 = FSQR_S16_HI( ddist3 ); \ - ddist3 = FSQR_S16_LO( ddist3 ); \ - dres1 = vis_fpadd32( ddist2, ddist3 ); \ - dcolor = vis_fmul8x16al( lut[ k ], fone ); \ - dres = vis_freg_pair( \ - vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ), \ - vis_fpadd32s( vis_read_hi( dres1 ), vis_read_lo( dres1 ) ) ); \ - mask = vis_fcmplt32( dres, dpmin[ 0 ] ); \ - vis_pst_32( dind, ( void * )dpind, mask ); \ - dind = vis_fpadd32( dind, done ); \ - vis_pst_32( dres, ( void * )dpmin, mask ); \ - } \ - dst[ i ] = ( ( mlib_s32 * )dpind )[ 0 ] + offset; \ - dst[ i + 1 ] = ( ( mlib_s32 * )dpind)[ 1 ] + offset; \ - } \ - if( i < length ) \ - { \ - dpsrc = VIS_ALIGNADDR( src, -1 ); \ - dsrc = dpsrc[ 0 ]; \ - dsrc1 = dpsrc[ 1 ]; \ - dsrc1 = vis_faligndata( dsrc, dsrc1 ); \ - dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone ); \ - dpind[ 0 ] = dind = done; \ - dpmin[ 0 ] = dmax; \ - for( k = 0; k < entries; k++ ) \ - { \ - dcolor = vis_fmul8x16al( lut[ k ], fone ); \ - ddist1 = vis_fpsub16( dcolor, dsrc ); \ - ddist = FSQR_S16_HI( ddist1 ); \ - ddist1 = FSQR_S16_LO( ddist1 ); \ - dres = vis_fpadd32( ddist, ddist1 ); \ - dres = vis_write_lo( dres, \ - vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ) ); \ - mask = vis_fcmplt32( dres, dpmin[ 0 ] ); \ - vis_pst_32( dind, ( void * )dpind, mask ); \ - dind = vis_fpadd32( dind, done ); \ - vis_pst_32( dres, ( void * )dpmin, mask ); \ - } \ - dst[ i ] = ( ( mlib_s32 * )dpind)[ 1 ] + offset; \ - } \ - vis_write_gsr(gsr[0]); \ -} - -/***************************************************************/ -#define FIND_NEAREST_U8_3_IN4 \ -{ \ - mlib_d64 *dpsrc, dsrc, dsrc1, ddist, ddist1, ddist2, ddist3; \ - mlib_d64 dcolor, dind, dres, dres1, dpind[1], dpmin[1]; \ - mlib_d64 done = vis_to_double_dup( 1 ), \ - dmax = vis_to_double_dup( MLIB_S32_MAX ); \ - mlib_f32 *lut = ( mlib_f32 * )mlib_ImageGetLutNormalTable( s ); \ - mlib_f32 fone = vis_to_float( 0x100 ); \ - mlib_s32 i, k, mask, gsr[1]; \ - mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1; \ - mlib_s32 entries = s->lutlength; \ - \ - gsr[0] = vis_read_gsr(); \ - dpsrc = VIS_ALIGNADDR( src, 0 ); \ - for( i = 0; i <= ( length-2 ); i += 2 ) \ - { \ - dsrc = dpsrc[ 0 ]; \ - dsrc1 = dpsrc[ 1 ]; \ - dsrc1 = vis_faligndata( dsrc, dsrc1 ); \ - dpsrc++; \ - dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone ); \ - dsrc1 = vis_fmul8x16al( vis_read_lo( dsrc1 ), fone ); \ - dpind[ 0 ] = dind = done; \ - dpmin[ 0 ] = dmax; \ - dcolor = vis_fmul8x16al( lut[ 0 ], fone ); \ - for( k = 1; k <= entries; k++ ) \ - { \ - ddist1 = vis_fpsub16( dcolor, dsrc ); \ - ddist = FSQR_S16_HI( ddist1 ); \ - ddist1 = FSQR_S16_LO( ddist1 ); \ - dres = vis_fpadd32( ddist, ddist1 ); \ - ddist3 = vis_fpsub16( dcolor, dsrc1 ); \ - ddist2 = FSQR_S16_HI( ddist3 ); \ - ddist3 = FSQR_S16_LO( ddist3 ); \ - dres1 = vis_fpadd32( ddist2, ddist3 ); \ - dcolor = vis_fmul8x16al( lut[ k ], fone ); \ - dres = vis_freg_pair( \ - vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ), \ - vis_fpadd32s( vis_read_hi( dres1 ), vis_read_lo( dres1 ) ) ); \ - mask = vis_fcmplt32( dres, dpmin[ 0 ] ); \ - vis_pst_32( dind, ( void * )dpind, mask ); \ - dind = vis_fpadd32( dind, done ); \ - vis_pst_32( dres, ( void * )dpmin, mask ); \ - } \ - dst[ i ] = ( ( mlib_s32 * )dpind )[ 0 ] + offset; \ - dst[ i + 1 ] = ( ( mlib_s32 * )dpind)[ 1 ] + offset; \ - } \ - if( i < length ) \ - { \ - dsrc = dpsrc[ 0 ]; \ - dsrc1 = dpsrc[ 1 ]; \ - dsrc1 = vis_faligndata( dsrc, dsrc1 ); \ - dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone ); \ - dpind[ 0 ] = dind = done; \ - dpmin[ 0 ] = dmax; \ - for( k = 0; k < entries; k++ ) \ - { \ - dcolor = vis_fmul8x16al( lut[ k ], fone ); \ - ddist1 = vis_fpsub16( dcolor, dsrc ); \ - ddist = FSQR_S16_HI( ddist1 ); \ - ddist1 = FSQR_S16_LO( ddist1 ); \ - dres = vis_fpadd32( ddist, ddist1 ); \ - dres = vis_write_lo( dres, \ - vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ) ); \ - mask = vis_fcmplt32( dres, dpmin[ 0 ] ); \ - vis_pst_32( dind, ( void * )dpind, mask ); \ - dind = vis_fpadd32( dind, done ); \ - vis_pst_32( dres, ( void * )dpmin, mask ); \ - } \ - dst[ i ] = ( ( mlib_s32 * )dpind)[ 1 ] + offset; \ - } \ - vis_write_gsr(gsr[0]); \ -} - -/***************************************************************/ -#define FIND_NEAREST_U8_4 \ -{ \ - mlib_d64 *dpsrc, dsrc, dsrc1, ddist, ddist1, ddist2, ddist3; \ - mlib_d64 dcolor, dind, dres, dres1, dpind[ 1 ], dpmin[ 1 ]; \ - mlib_d64 done = vis_to_double_dup( 1 ), \ - dmax = vis_to_double_dup( MLIB_S32_MAX ); \ - mlib_f32 *lut = ( mlib_f32 * )mlib_ImageGetLutNormalTable( s ); \ - mlib_f32 fone = vis_to_float( 0x100 ); \ - mlib_s32 i, k, mask, gsr[1]; \ - mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1; \ - mlib_s32 entries = s->lutlength; \ - \ - gsr[0] = vis_read_gsr(); \ - dpsrc = VIS_ALIGNADDR( src, 0 ); \ - for( i = 0; i <= ( length-2 ); i += 2 ) \ - { \ - dsrc = dpsrc[ 0 ]; \ - dsrc1 = dpsrc[ 1 ]; \ - dsrc1 = vis_faligndata( dsrc, dsrc1 ); \ - dpsrc++; \ - dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone ); \ - dsrc1 = vis_fmul8x16al( vis_read_lo( dsrc1 ), fone ); \ - dpind[ 0 ] = dind = done; \ - dpmin[ 0 ] = dmax; \ - dcolor = vis_fmul8x16al(lut[0], fone); \ - for( k = 1; k <= entries; k++ ) \ - { \ - ddist1 = vis_fpsub16( dcolor, dsrc ); \ - ddist = FSQR_S16_HI( ddist1 ); \ - ddist1 = FSQR_S16_LO( ddist1 ); \ - dres = vis_fpadd32( ddist, ddist1 ); \ - ddist3 = vis_fpsub16( dcolor, dsrc1 ); \ - ddist2 = FSQR_S16_HI( ddist3 ); \ - ddist3 = FSQR_S16_LO( ddist3 ); \ - dres1 = vis_fpadd32( ddist2, ddist3 ); \ - dcolor = vis_fmul8x16al( lut[ k ], fone ); \ - dres = vis_freg_pair( \ - vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ), \ - vis_fpadd32s( vis_read_hi( dres1 ), vis_read_lo( dres1 ) ) ); \ - mask = vis_fcmplt32( dres, dpmin[ 0 ] ); \ - vis_pst_32( dind, ( void * )dpind, mask ); \ - dind = vis_fpadd32( dind, done ); \ - vis_pst_32( dres, ( void * )dpmin, mask ); \ - } \ - dst[ i ] = ( ( mlib_s32 * )dpind )[ 0 ] + offset; \ - dst[ i + 1 ] = ( ( mlib_s32 * )dpind )[ 1 ] + offset; \ - } \ - if( i < length ) \ - { \ - dsrc = dpsrc[ 0 ]; \ - dsrc1 = dpsrc[ 1 ]; \ - dsrc1 = vis_faligndata( dsrc, dsrc1 ); \ - dsrc = vis_fmul8x16al( vis_read_hi( dsrc1 ), fone ); \ - dpind[ 0 ] = dind = done; \ - dpmin[ 0 ] = dmax; \ - for( k = 0; k < entries; k++ ) \ - { \ - dcolor = vis_fmul8x16al( lut[ k ], fone ); \ - ddist1 = vis_fpsub16( dcolor, dsrc ); \ - ddist = FSQR_S16_HI( ddist1 ); \ - ddist1 = FSQR_S16_LO( ddist1 ); \ - dres = vis_fpadd32( ddist, ddist1 ); \ - dres = vis_write_lo( dres, \ - vis_fpadd32s( vis_read_hi( dres ), vis_read_lo( dres ) ) ); \ - mask = vis_fcmplt32( dres, dpmin[ 0 ] ); \ - vis_pst_32( dind, ( void * )dpind, mask ); \ - dind = vis_fpadd32( dind, done ); \ - vis_pst_32( dres, ( void * )dpmin, mask ); \ - } \ - dst[ i ] = ( ( mlib_s32 * )dpind )[ 1 ] + offset; \ - } \ - vis_write_gsr(gsr[0]); \ -} - -/***************************************************************/ -#define FIND_NEAREST_S16_3( SHIFT, STEP ) \ - mlib_s32 i, k, k_min, min_dist, diff, mask; \ - mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1; \ - mlib_s32 entries = s->lutlength; \ - mlib_d64 *double_lut = mlib_ImageGetLutDoubleData( s ); \ - mlib_d64 col0, col1, col2; \ - mlib_d64 dist, len0, len1, len2; \ - \ - for( i = 0; i < length; i++ ) \ - { \ - col0 = src[ STEP * i + SHIFT ]; \ - col1 = src[ STEP * i + 1 + SHIFT ]; \ - col2 = src[ STEP * i + 2 + SHIFT ]; \ - min_dist = MLIB_S32_MAX; \ - k_min = 1; \ - len0 = double_lut[ 0 ] - col0; \ - len1 = double_lut[ 1 ] - col1; \ - len2 = double_lut[ 2 ] - col2; \ - for( k = 1; k <= entries; k++ ) \ - { \ - dist = len0 * len0; \ - len0 = double_lut[ 3 * k ] - col0; \ - dist += len1 * len1; \ - len1 = double_lut[ 3 * k + 1 ] - col1; \ - dist += len2 * len2; \ - len2 = double_lut[ 3 * k + 2 ] - col2; \ - diff = ( mlib_s32 )( dist * 0.125 ) - min_dist; \ - mask = diff >> 31; \ - min_dist += diff & mask; \ - k_min += ( k - k_min ) & mask; \ - } \ - dst[ i ] = k_min + offset; \ - } - -/***************************************************************/ -#define FIND_NEAREST_S16_4 \ - mlib_s32 i, k, k_min, min_dist, diff, mask; \ - mlib_s32 offset = mlib_ImageGetLutOffset( s ) - 1; \ - mlib_s32 entries = s->lutlength; \ - mlib_d64 *double_lut = mlib_ImageGetLutDoubleData( s ); \ - mlib_d64 col0, col1, col2, col3; \ - mlib_d64 dist, len0, len1, len2, len3; \ - \ - for( i = 0; i < length; i++ ) \ - { \ - col0 = src[ 4 * i ]; \ - col1 = src[ 4 * i + 1 ]; \ - col2 = src[ 4 * i + 2 ]; \ - col3 = src[ 4 * i + 3 ]; \ - min_dist = MLIB_S32_MAX; \ - k_min = 1; \ - len0 = double_lut[ 0 ] - col0; \ - len1 = double_lut[ 1 ] - col1; \ - len2 = double_lut[ 2 ] - col2; \ - len3 = double_lut[ 3 ] - col3; \ - for( k = 1; k <= entries; k++ ) \ - { \ - dist = len0 * len0; \ - len0 = double_lut[ 4 * k ] - col0; \ - dist += len1 * len1; \ - len1 = double_lut[ 4 * k + 1 ] - col1; \ - dist += len2 * len2; \ - len2 = double_lut[ 4 * k + 2 ] - col2; \ - dist += len3 * len3; \ - len3 = double_lut[ 4 * k + 3 ] - col3; \ - diff = ( mlib_s32 )( dist * 0.125 ) - min_dist; \ - mask = diff >> 31; \ - min_dist += diff & mask; \ - k_min += ( k - k_min ) & mask; \ - } \ - dst[ i ] = k_min + offset; \ - } - -/***************************************************************/ -mlib_status mlib_ImageColorTrue2Index(mlib_image *dst, - const mlib_image *src, - const void *colormap) -{ - mlib_s32 y, width, height, sstride, dstride, schann; - mlib_colormap *s = (mlib_colormap *)colormap; - mlib_s32 channels; - mlib_type stype, dtype; - - MLIB_IMAGE_CHECK(src); - MLIB_IMAGE_CHECK(dst); - MLIB_IMAGE_SIZE_EQUAL(src, dst); - MLIB_IMAGE_HAVE_CHAN(dst, 1); - - if (!colormap) - return MLIB_NULLPOINTER; - - channels = s->channels; - stype = mlib_ImageGetType(src); - dtype = mlib_ImageGetType(dst); - width = mlib_ImageGetWidth(src); - height = mlib_ImageGetHeight(src); - sstride = mlib_ImageGetStride(src); - dstride = mlib_ImageGetStride(dst); - schann = mlib_ImageGetChannels(src); - - if (stype != s->intype || dtype != s->outtype) - return MLIB_FAILURE; - - if (channels != schann) - return MLIB_FAILURE; - - switch (stype) { - case MLIB_BYTE: - { - mlib_u8 *sdata = mlib_ImageGetData(src); - - switch (dtype) { - case MLIB_BYTE: - { - mlib_u8 *ddata = mlib_ImageGetData(dst); - - switch (channels) { - case 3: - { - MAIN_COLORTRUE2INDEX_LOOP(U8, U8, 3); - return MLIB_SUCCESS; - } - - case 4: - { - MAIN_COLORTRUE2INDEX_LOOP(U8, U8, 4); - return MLIB_SUCCESS; - } - - default: - return MLIB_FAILURE; - } - } - - case MLIB_SHORT: - { - mlib_s16 *ddata = mlib_ImageGetData(dst); - - dstride /= 2; - switch (channels) { - case 3: - { - MAIN_COLORTRUE2INDEX_LOOP(U8, S16, 3); - return MLIB_SUCCESS; - } - - case 4: - { - MAIN_COLORTRUE2INDEX_LOOP(U8, S16, 4); - return MLIB_SUCCESS; - } - - default: - return MLIB_FAILURE; - } - } - default: - /* Unsupported type of destination image */ - return MLIB_FAILURE; - } - } - - case MLIB_SHORT: - { - mlib_s16 *sdata = mlib_ImageGetData(src); - - sstride /= 2; - switch (dtype) { - case MLIB_BYTE: - { - mlib_u8 *ddata = mlib_ImageGetData(dst); - - switch (channels) { - case 3: - { - MAIN_COLORTRUE2INDEX_LOOP(S16, U8, 3); - return MLIB_SUCCESS; - } - - case 4: - { - MAIN_COLORTRUE2INDEX_LOOP(S16, U8, 4); - return MLIB_SUCCESS; - } - - default: - return MLIB_FAILURE; - } - } - - case MLIB_SHORT: - { - mlib_s16 *ddata = mlib_ImageGetData(dst); - - dstride /= 2; - switch (channels) { - case 3: - { - MAIN_COLORTRUE2INDEX_LOOP(S16, S16, 3); - return MLIB_SUCCESS; - } - - case 4: - { - MAIN_COLORTRUE2INDEX_LOOP(S16, S16, 4); - return MLIB_SUCCESS; - } - - default: - return MLIB_FAILURE; - } - } - default: - /* Unsupported type of destination image */ - return MLIB_FAILURE; - } - } - - default: - return MLIB_FAILURE; - } -} - -/***************************************************************/ -mlib_u32 mlib_search_quadrant_U8_3(struct lut_node_3 *node, - mlib_u32 distance, - mlib_s32 *found_color, - mlib_u32 c0, - mlib_u32 c1, - mlib_u32 c2, - const mlib_u8 **base) -{ - mlib_s32 i; - - for (i = 0; i < 8; i++) { - - if (node->tag & (1 << i)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[i]; - mlib_u32 newpalc0, newpalc1, newpalc2; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex]; - newpalc1 = base[1][newindex]; - newpalc2 = base[2][newindex]; - newdistance = FIND_DISTANCE_3(c0, newpalc0, c1, newpalc1, c2, newpalc2, 0); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[i]) - distance = - mlib_search_quadrant_U8_3(node->contents.quadrants[i], distance, - found_color, c0, c1, c2, base); - } - - return distance; -} - -/***************************************************************/ -mlib_u32 mlib_search_quadrant_part_to_left_U8_3(struct lut_node_3 *node, - mlib_u32 distance, - mlib_s32 *found_color, - const mlib_u32 *c, - const mlib_u8 **base, - mlib_u32 position, - mlib_s32 pass, - mlib_s32 dir_bit) -{ - mlib_u32 current_size = 1 << pass; - mlib_s32 i; - static mlib_s32 opposite_quadrants[3][4] = { - {0, 2, 4, 6}, - {0, 1, 4, 5}, - {0, 1, 2, 3} - }; - -/* Search only quadrant's half untill it is necessary to check the - whole quadrant */ - - if (distance < (position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) { /* Search half of quadrant */ - for (i = 0; i < 4; i++) { - mlib_s32 qq = opposite_quadrants[dir_bit][i]; - - if (node->tag & (1 << qq)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[qq]; - mlib_u32 newpalc0, newpalc1, newpalc2; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex]; - newpalc1 = base[1][newindex]; - newpalc2 = base[2][newindex]; - newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 0); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[qq]) - distance = - mlib_search_quadrant_part_to_left_U8_3(node->contents.quadrants[qq], - distance, found_color, c, base, - position, pass - 1, dir_bit); - } - } - else { /* Search whole quadrant */ - - mlib_s32 mask = 1 << dir_bit; - - for (i = 0; i < 8; i++) { - - if (node->tag & (1 << i)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[i]; - mlib_u32 newpalc0, newpalc1, newpalc2; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex]; - newpalc1 = base[1][newindex]; - newpalc2 = base[2][newindex]; - newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 0); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[i]) { - - if (i & mask) - /* This quadrant may require partial checking */ - distance = - mlib_search_quadrant_part_to_left_U8_3(node->contents.quadrants[i], - distance, found_color, c, - base, - position + current_size, - pass - 1, dir_bit); - else - /* Here we should check all */ - distance = - mlib_search_quadrant_U8_3(node->contents.quadrants[i], distance, - found_color, c[0], c[1], c[2], base); - } - } - } - - return distance; -} - -/***************************************************************/ -mlib_u32 mlib_search_quadrant_part_to_right_U8_3(struct lut_node_3 *node, - mlib_u32 distance, - mlib_s32 *found_color, - const mlib_u32 *c, - const mlib_u8 **base, - mlib_u32 position, - mlib_s32 pass, - mlib_s32 dir_bit) -{ - mlib_u32 current_size = 1 << pass; - mlib_s32 i; - static mlib_s32 opposite_quadrants[3][4] = { - {1, 3, 5, 7}, - {2, 3, 6, 7}, - {4, 5, 6, 7} - }; - -/* Search only quadrant's half untill it is necessary to check the - whole quadrant */ - - if (distance <= (c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) { /* Search half of quadrant */ - for (i = 0; i < 4; i++) { - mlib_s32 qq = opposite_quadrants[dir_bit][i]; - - if (node->tag & (1 << qq)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[qq]; - mlib_u32 newpalc0, newpalc1, newpalc2; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex]; - newpalc1 = base[1][newindex]; - newpalc2 = base[2][newindex]; - newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 0); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[qq]) - distance = - mlib_search_quadrant_part_to_right_U8_3(node->contents.quadrants[qq], - distance, found_color, c, - base, position + current_size, - pass - 1, dir_bit); - } - } - else { /* Search whole quadrant */ - - mlib_s32 mask = 1 << dir_bit; - - for (i = 0; i < 8; i++) { - - if (node->tag & (1 << i)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[i]; - mlib_u32 newpalc0, newpalc1, newpalc2; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex]; - newpalc1 = base[1][newindex]; - newpalc2 = base[2][newindex]; - newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 0); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[i]) { - - if (i & mask) - /* Here we should check all */ - distance = - mlib_search_quadrant_U8_3(node->contents.quadrants[i], distance, - found_color, c[0], c[1], c[2], base); - else - /* This quadrant may require partial checking */ - distance = - mlib_search_quadrant_part_to_right_U8_3(node->contents.quadrants[i], - distance, found_color, c, - base, position, pass - 1, dir_bit); - } - } - } - - return distance; -} - -/***************************************************************/ -mlib_u32 mlib_search_quadrant_S16_3(struct lut_node_3 *node, - mlib_u32 distance, - mlib_s32 *found_color, - mlib_u32 c0, - mlib_u32 c1, - mlib_u32 c2, - const mlib_s16 **base) -{ - mlib_s32 i; - - for (i = 0; i < 8; i++) { - - if (node->tag & (1 << i)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[i]; - mlib_u32 newpalc0, newpalc1, newpalc2; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex] - MLIB_S16_MIN; - newpalc1 = base[1][newindex] - MLIB_S16_MIN; - newpalc2 = base[2][newindex] - MLIB_S16_MIN; - newdistance = FIND_DISTANCE_3(c0, newpalc0, c1, newpalc1, c2, newpalc2, 2); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[i]) - distance = - mlib_search_quadrant_S16_3(node->contents.quadrants[i], distance, - found_color, c0, c1, c2, base); - } - - return distance; -} - -/***************************************************************/ -mlib_u32 mlib_search_quadrant_part_to_left_S16_3(struct lut_node_3 *node, - mlib_u32 distance, - mlib_s32 *found_color, - const mlib_u32 *c, - const mlib_s16 **base, - mlib_u32 position, - mlib_s32 pass, - mlib_s32 dir_bit) -{ - mlib_u32 current_size = 1 << pass; - mlib_s32 i; - static mlib_s32 opposite_quadrants[3][4] = { - {0, 2, 4, 6}, - {0, 1, 4, 5}, - {0, 1, 2, 3} - }; - -/* Search only quadrant's half untill it is necessary to check the - whole quadrant */ - - if (distance < (((position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) >> 2)) { /* Search half of quadrant */ - for (i = 0; i < 4; i++) { - mlib_s32 qq = opposite_quadrants[dir_bit][i]; - - if (node->tag & (1 << qq)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[qq]; - mlib_u32 newpalc0, newpalc1, newpalc2; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex] - MLIB_S16_MIN; - newpalc1 = base[1][newindex] - MLIB_S16_MIN; - newpalc2 = base[2][newindex] - MLIB_S16_MIN; - newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 2); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[qq]) - distance = - mlib_search_quadrant_part_to_left_S16_3(node->contents.quadrants[qq], - distance, found_color, c, - base, position, pass - 1, dir_bit); - } - } - else { /* Search whole quadrant */ - - mlib_s32 mask = 1 << dir_bit; - - for (i = 0; i < 8; i++) { - - if (node->tag & (1 << i)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[i]; - mlib_u32 newpalc0, newpalc1, newpalc2; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex] - MLIB_S16_MIN; - newpalc1 = base[1][newindex] - MLIB_S16_MIN; - newpalc2 = base[2][newindex] - MLIB_S16_MIN; - newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 2); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[i]) { - - if (i & mask) - /* This quadrant may require partial checking */ - distance = - mlib_search_quadrant_part_to_left_S16_3(node->contents.quadrants[i], - distance, found_color, c, - base, - position + current_size, - pass - 1, dir_bit); - else - /* Here we should check all */ - distance = - mlib_search_quadrant_S16_3(node->contents.quadrants[i], distance, - found_color, c[0], c[1], c[2], base); - } - } - } - - return distance; -} - -/***************************************************************/ -mlib_u32 mlib_search_quadrant_part_to_right_S16_3(struct lut_node_3 *node, - mlib_u32 distance, - mlib_s32 *found_color, - const mlib_u32 *c, - const mlib_s16 **base, - mlib_u32 position, - mlib_s32 pass, - mlib_s32 dir_bit) -{ - mlib_u32 current_size = 1 << pass; - mlib_s32 i; - static mlib_s32 opposite_quadrants[3][4] = { - {1, 3, 5, 7}, - {2, 3, 6, 7}, - {4, 5, 6, 7} - }; - -/* Search only quadrant's half untill it is necessary to check the - whole quadrant */ - - if (distance <= (((c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) >> 2)) { /* Search half of quadrant */ - for (i = 0; i < 4; i++) { - mlib_s32 qq = opposite_quadrants[dir_bit][i]; - - if (node->tag & (1 << qq)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[qq]; - mlib_u32 newpalc0, newpalc1, newpalc2; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex] - MLIB_S16_MIN; - newpalc1 = base[1][newindex] - MLIB_S16_MIN; - newpalc2 = base[2][newindex] - MLIB_S16_MIN; - newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 2); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[qq]) - distance = - mlib_search_quadrant_part_to_right_S16_3(node->contents.quadrants[qq], - distance, found_color, c, - base, - position + current_size, - pass - 1, dir_bit); - } - } - else { /* Search whole quadrant */ - - mlib_s32 mask = 1 << dir_bit; - - for (i = 0; i < 8; i++) { - - if (node->tag & (1 << i)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[i]; - mlib_u32 newpalc0, newpalc1, newpalc2; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex] - MLIB_S16_MIN; - newpalc1 = base[1][newindex] - MLIB_S16_MIN; - newpalc2 = base[2][newindex] - MLIB_S16_MIN; - newdistance = FIND_DISTANCE_3(c[0], newpalc0, c[1], newpalc1, c[2], newpalc2, 2); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[i]) { - - if (i & mask) - /* Here we should check all */ - distance = - mlib_search_quadrant_S16_3(node->contents.quadrants[i], distance, - found_color, c[0], c[1], c[2], base); - else - /* This quadrant may require partial checking */ - distance = - mlib_search_quadrant_part_to_right_S16_3(node->contents. - quadrants[i], distance, - found_color, c, base, - position, pass - 1, dir_bit); - } - } - } - - return distance; -} - -/***************************************************************/ -mlib_u32 mlib_search_quadrant_U8_4(struct lut_node_4 *node, - mlib_u32 distance, - mlib_s32 *found_color, - mlib_u32 c0, - mlib_u32 c1, - mlib_u32 c2, - mlib_u32 c3, - const mlib_u8 **base) -{ - mlib_s32 i; - - for (i = 0; i < 16; i++) { - - if (node->tag & (1 << i)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[i]; - mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex]; - newpalc1 = base[1][newindex]; - newpalc2 = base[2][newindex]; - newpalc3 = base[3][newindex]; - newdistance = FIND_DISTANCE_4(c0, newpalc0, - c1, newpalc1, c2, newpalc2, c3, newpalc3, 0); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[i]) - distance = - mlib_search_quadrant_U8_4(node->contents.quadrants[i], distance, - found_color, c0, c1, c2, c3, base); - } - - return distance; -} - -/***************************************************************/ -mlib_u32 mlib_search_quadrant_part_to_left_U8_4(struct lut_node_4 *node, - mlib_u32 distance, - mlib_s32 *found_color, - const mlib_u32 *c, - const mlib_u8 **base, - mlib_u32 position, - mlib_s32 pass, - mlib_s32 dir_bit) -{ - mlib_u32 current_size = 1 << pass; - mlib_s32 i; - static mlib_s32 opposite_quadrants[4][8] = { - {0, 2, 4, 6, 8, 10, 12, 14}, - {0, 1, 4, 5, 8, 9, 12, 13}, - {0, 1, 2, 3, 8, 9, 10, 11}, - {0, 1, 2, 3, 4, 5, 6, 7} - }; - -/* Search only quadrant's half untill it is necessary to check the - whole quadrant */ - - if (distance < (position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) { /* Search half of quadrant */ - for (i = 0; i < 8; i++) { - mlib_s32 qq = opposite_quadrants[dir_bit][i]; - - if (node->tag & (1 << qq)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[qq]; - mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex]; - newpalc1 = base[1][newindex]; - newpalc2 = base[2][newindex]; - newpalc3 = base[3][newindex]; - newdistance = FIND_DISTANCE_4(c[0], newpalc0, - c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 0); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[qq]) - distance = - mlib_search_quadrant_part_to_left_U8_4(node->contents.quadrants[qq], - distance, found_color, c, base, - position, pass - 1, dir_bit); - } - } - else { /* Search whole quadrant */ - - mlib_s32 mask = 1 << dir_bit; - - for (i = 0; i < 16; i++) { - - if (node->tag & (1 << i)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[i]; - mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex]; - newpalc1 = base[1][newindex]; - newpalc2 = base[2][newindex]; - newpalc3 = base[3][newindex]; - newdistance = FIND_DISTANCE_4(c[0], newpalc0, - c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 0); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[i]) { - - if (i & mask) - /* This quadrant may require partial checking */ - distance = - mlib_search_quadrant_part_to_left_U8_4(node->contents.quadrants[i], - distance, found_color, c, - base, - position + current_size, - pass - 1, dir_bit); - else - /* Here we should check all */ - distance = - mlib_search_quadrant_U8_4(node->contents.quadrants[i], distance, - found_color, c[0], c[1], c[2], c[3], base); - } - } - } - - return distance; -} - -/***************************************************************/ -mlib_u32 mlib_search_quadrant_part_to_right_U8_4(struct lut_node_4 *node, - mlib_u32 distance, - mlib_s32 *found_color, - const mlib_u32 *c, - const mlib_u8 **base, - mlib_u32 position, - mlib_s32 pass, - mlib_s32 dir_bit) -{ - mlib_u32 current_size = 1 << pass; - mlib_s32 i; - static mlib_s32 opposite_quadrants[4][8] = { - {1, 3, 5, 7, 9, 11, 13, 15}, - {2, 3, 6, 7, 10, 11, 14, 15}, - {4, 5, 6, 7, 12, 13, 14, 15}, - {8, 9, 10, 11, 12, 13, 14, 15} - }; - -/* Search only quadrant's half untill it is necessary to check the - whole quadrant */ - - if (distance <= (c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) { /* Search half of quadrant */ - for (i = 0; i < 8; i++) { - mlib_s32 qq = opposite_quadrants[dir_bit][i]; - - if (node->tag & (1 << qq)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[qq]; - mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex]; - newpalc1 = base[1][newindex]; - newpalc2 = base[2][newindex]; - newpalc3 = base[3][newindex]; - newdistance = FIND_DISTANCE_4(c[0], newpalc0, - c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 0); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[qq]) - distance = - mlib_search_quadrant_part_to_right_U8_4(node->contents.quadrants[qq], - distance, found_color, c, - base, position + current_size, - pass - 1, dir_bit); - } - } - else { /* Search whole quadrant */ - - mlib_s32 mask = 1 << dir_bit; - - for (i = 0; i < 16; i++) { - - if (node->tag & (1 << i)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[i]; - mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex]; - newpalc1 = base[1][newindex]; - newpalc2 = base[2][newindex]; - newpalc3 = base[3][newindex]; - newdistance = FIND_DISTANCE_4(c[0], newpalc0, - c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 0); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[i]) { - - if (i & mask) - /* Here we should check all */ - distance = - mlib_search_quadrant_U8_4(node->contents.quadrants[i], distance, - found_color, c[0], c[1], c[2], c[3], base); - else - /* This quadrant may require partial checking */ - distance = - mlib_search_quadrant_part_to_right_U8_4(node->contents.quadrants[i], - distance, found_color, c, - base, position, pass - 1, dir_bit); - } - } - } - - return distance; -} - -/***************************************************************/ -mlib_u32 mlib_search_quadrant_S16_4(struct lut_node_4 *node, - mlib_u32 distance, - mlib_s32 *found_color, - mlib_u32 c0, - mlib_u32 c1, - mlib_u32 c2, - mlib_u32 c3, - const mlib_s16 **base) -{ - mlib_s32 i; - - for (i = 0; i < 16; i++) { - - if (node->tag & (1 << i)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[i]; - mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex] - MLIB_S16_MIN; - newpalc1 = base[1][newindex] - MLIB_S16_MIN; - newpalc2 = base[2][newindex] - MLIB_S16_MIN; - newpalc3 = base[3][newindex] - MLIB_S16_MIN; - newdistance = FIND_DISTANCE_4(c0, newpalc0, - c1, newpalc1, c2, newpalc2, c3, newpalc3, 2); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[i]) - distance = - mlib_search_quadrant_S16_4(node->contents.quadrants[i], distance, - found_color, c0, c1, c2, c3, base); - } - - return distance; -} - -/***************************************************************/ -mlib_u32 mlib_search_quadrant_part_to_left_S16_4(struct lut_node_4 *node, - mlib_u32 distance, - mlib_s32 *found_color, - const mlib_u32 *c, - const mlib_s16 **base, - mlib_u32 position, - mlib_s32 pass, - mlib_s32 dir_bit) -{ - mlib_u32 current_size = 1 << pass; - mlib_s32 i; - static mlib_s32 opposite_quadrants[4][8] = { - {0, 2, 4, 6, 8, 10, 12, 14}, - {0, 1, 4, 5, 8, 9, 12, 13}, - {0, 1, 2, 3, 8, 9, 10, 11}, - {0, 1, 2, 3, 4, 5, 6, 7} - }; - -/* Search only quadrant's half untill it is necessary to check the - whole quadrant */ - - if (distance < (((position + current_size - c[dir_bit]) * (position + current_size - c[dir_bit])) >> 2)) { /* Search half of quadrant */ - for (i = 0; i < 8; i++) { - mlib_s32 qq = opposite_quadrants[dir_bit][i]; - - if (node->tag & (1 << qq)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[qq]; - mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex] - MLIB_S16_MIN; - newpalc1 = base[1][newindex] - MLIB_S16_MIN; - newpalc2 = base[2][newindex] - MLIB_S16_MIN; - newpalc3 = base[3][newindex] - MLIB_S16_MIN; - newdistance = FIND_DISTANCE_4(c[0], newpalc0, - c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 2); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[qq]) - distance = - mlib_search_quadrant_part_to_left_S16_4(node->contents.quadrants[qq], - distance, found_color, c, - base, position, pass - 1, dir_bit); - } - } - else { /* Search whole quadrant */ - - mlib_s32 mask = 1 << dir_bit; - - for (i = 0; i < 16; i++) { - - if (node->tag & (1 << i)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[i]; - mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex] - MLIB_S16_MIN; - newpalc1 = base[1][newindex] - MLIB_S16_MIN; - newpalc2 = base[2][newindex] - MLIB_S16_MIN; - newpalc3 = base[3][newindex] - MLIB_S16_MIN; - newdistance = FIND_DISTANCE_4(c[0], newpalc0, - c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 2); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[i]) { - - if (i & mask) - /* This quadrant may require partial checking */ - distance = - mlib_search_quadrant_part_to_left_S16_4(node->contents.quadrants[i], - distance, found_color, c, - base, - position + current_size, - pass - 1, dir_bit); - else - /* Here we should check all */ - distance = - mlib_search_quadrant_S16_4(node->contents.quadrants[i], distance, - found_color, c[0], c[1], c[2], c[3], base); - } - } - } - - return distance; -} - -/***************************************************************/ -mlib_u32 mlib_search_quadrant_part_to_right_S16_4(struct lut_node_4 *node, - mlib_u32 distance, - mlib_s32 *found_color, - const mlib_u32 *c, - const mlib_s16 **base, - mlib_u32 position, - mlib_s32 pass, - mlib_s32 dir_bit) -{ - mlib_u32 current_size = 1 << pass; - mlib_s32 i; - static mlib_s32 opposite_quadrants[4][8] = { - {1, 3, 5, 7, 9, 11, 13, 15}, - {2, 3, 6, 7, 10, 11, 14, 15}, - {4, 5, 6, 7, 12, 13, 14, 15}, - {8, 9, 10, 11, 12, 13, 14, 15} - }; - -/* Search only quadrant's half untill it is necessary to check the - whole quadrant */ - - if (distance <= (((c[dir_bit] - position - current_size) * (c[dir_bit] - position - current_size)) >> 2)) { /* Search half of quadrant */ - for (i = 0; i < 8; i++) { - mlib_s32 qq = opposite_quadrants[dir_bit][i]; - - if (node->tag & (1 << qq)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[qq]; - mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex] - MLIB_S16_MIN; - newpalc1 = base[1][newindex] - MLIB_S16_MIN; - newpalc2 = base[2][newindex] - MLIB_S16_MIN; - newpalc3 = base[3][newindex] - MLIB_S16_MIN; - newdistance = FIND_DISTANCE_4(c[0], newpalc0, - c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 2); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[qq]) - distance = - mlib_search_quadrant_part_to_right_S16_4(node->contents.quadrants[qq], - distance, found_color, c, - base, - position + current_size, - pass - 1, dir_bit); - } - } - else { /* Search whole quadrant */ - - mlib_s32 mask = 1 << dir_bit; - - for (i = 0; i < 16; i++) { - - if (node->tag & (1 << i)) { - /* Here is alone color cell. Check the distance */ - mlib_s32 newindex = node->contents.index[i]; - mlib_u32 newpalc0, newpalc1, newpalc2, newpalc3; - mlib_u32 newdistance; - - newpalc0 = base[0][newindex] - MLIB_S16_MIN; - newpalc1 = base[1][newindex] - MLIB_S16_MIN; - newpalc2 = base[2][newindex] - MLIB_S16_MIN; - newpalc3 = base[3][newindex] - MLIB_S16_MIN; - newdistance = FIND_DISTANCE_4(c[0], newpalc0, - c[1], newpalc1, c[2], newpalc2, c[3], newpalc3, 2); - - if (distance > newdistance) { - *found_color = newindex; - distance = newdistance; - } - } - else if (node->contents.quadrants[i]) { - - if (i & mask) - /* Here we should check all */ - distance = - mlib_search_quadrant_S16_4(node->contents.quadrants[i], distance, - found_color, c[0], c[1], c[2], c[3], base); - else - /* This quadrant may require partial checking */ - distance = - mlib_search_quadrant_part_to_right_S16_4(node->contents. - quadrants[i], distance, - found_color, c, base, - position, pass - 1, dir_bit); - } - } - } - - return distance; -} - -/***************************************************************/ - -#define TAB_SIZE_mlib_u8 256 -#define TAB_SIZE_mlib_s16 1024 - -#define SRC_mlib_u8(i) src[i] -#define SRC_mlib_s16(i) (((mlib_u16*)src)[i] >> 6) - -/***************************************************************/ - -#define DIMENSIONS_SEARCH_3(STYPE, DTYPE, STEP) \ -{ \ - DTYPE *tab0 = ((mlib_colormap *)state)->table; \ - DTYPE *tab1 = tab0 + TAB_SIZE_##STYPE; \ - DTYPE *tab2 = tab1 + TAB_SIZE_##STYPE; \ - mlib_s32 i; \ - \ - for (i = 0; i < length; i++) { \ - dst[i] = tab0[SRC_##STYPE(0)] + tab1[SRC_##STYPE(1)] + \ - tab2[SRC_##STYPE(2)]; \ - src += STEP; \ - } \ -} - -/***************************************************************/ - -#define DIMENSIONS_SEARCH_4(STYPE, DTYPE) \ -{ \ - DTYPE *tab0 = ((mlib_colormap *)state)->table; \ - DTYPE *tab1 = tab0 + TAB_SIZE_##STYPE; \ - DTYPE *tab2 = tab1 + TAB_SIZE_##STYPE; \ - DTYPE *tab3 = tab2 + TAB_SIZE_##STYPE; \ - mlib_s32 i; \ - \ - for (i = 0; i < length; i++) { \ - dst[i] = tab0[SRC_##STYPE(0)] + tab1[SRC_##STYPE(1)] + \ - tab2[SRC_##STYPE(2)] + tab3[SRC_##STYPE(3)]; \ - src += 4; \ - } \ -} - -/***************************************************************/ -void mlib_ImageColorTrue2IndexLine_U8_U8_3(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 length, - const void *state) -{ - mlib_colormap *s = (mlib_colormap *)state; - - switch (s->method) { -#if LUT_BYTE_COLORS_3CHANNELS <= 256 - case LUT_BINARY_TREE_SEARCH: - { - mlib_s32 bits = s->bits; - BINARY_TREE_SEARCH_3(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 0, 3, 0); - } - break; - -#endif /* LUT_BYTE_COLORS_3CHANNELS <= 256 */ - case LUT_COLOR_CUBE_SEARCH: - { - COLOR_CUBE_U8_3_SEARCH(mlib_u8, 0, 3); - } - break; - - case LUT_STUPID_SEARCH: - { -#ifdef USE_VIS_CODE - FIND_NEAREST_U8_3; -#else - FIND_NEAREST_U8_3_C(0, 3); -#endif - } - break; - - case LUT_COLOR_DIMENSIONS: - DIMENSIONS_SEARCH_3(mlib_u8, mlib_u8, 3) - break; - } -} - -/***************************************************************/ -void mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 length, - const void *state) -{ - mlib_colormap *s = (mlib_colormap *)state; - - switch (s->method) { -#if LUT_BYTE_COLORS_3CHANNELS <= 256 - case LUT_BINARY_TREE_SEARCH: - { - mlib_s32 bits = s->bits; - BINARY_TREE_SEARCH_3(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 1, 4, 0); - break; - } - -#endif /* LUT_BYTE_COLORS_3CHANNELS <= 256 */ - case LUT_COLOR_CUBE_SEARCH: - { - COLOR_CUBE_U8_3_SEARCH(mlib_u8, 1, 4); - break; - } - - case LUT_STUPID_SEARCH: - { -#ifdef USE_VIS_CODE - FIND_NEAREST_U8_3_IN4; -#else - FIND_NEAREST_U8_3_C(1, 4); -#endif - break; - } - - case LUT_COLOR_DIMENSIONS: - src++; - DIMENSIONS_SEARCH_3(mlib_u8, mlib_u8, 4) - break; - } -} - -/***************************************************************/ -void mlib_ImageColorTrue2IndexLine_U8_U8_4(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 length, - const void *state) -{ - mlib_colormap *s = (mlib_colormap *)state; - - switch (s->method) { -#if LUT_BYTE_COLORS_4CHANNELS <= 256 - case LUT_BINARY_TREE_SEARCH: - { - mlib_s32 bits = s->bits; - BINARY_TREE_SEARCH_4(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 0); - break; - } - -#endif /* LUT_BYTE_COLORS_4CHANNELS <= 256 */ - case LUT_COLOR_CUBE_SEARCH: - { - COLOR_CUBE_U8_4_SEARCH(mlib_u8); - break; - } - - case LUT_STUPID_SEARCH: - { -#ifdef USE_VIS_CODE - FIND_NEAREST_U8_4; -#else - FIND_NEAREST_U8_4_C; -#endif - break; - } - - case LUT_COLOR_DIMENSIONS: - DIMENSIONS_SEARCH_4(mlib_u8, mlib_u8) - break; - } -} - -/***************************************************************/ -void mlib_ImageColorTrue2IndexLine_U8_S16_3(const mlib_u8 *src, - mlib_s16 *dst, - mlib_s32 length, - const void *state) -{ - mlib_colormap *s = (mlib_colormap *)state; - mlib_s32 bits = s->bits; - - switch (s->method) { - case LUT_BINARY_TREE_SEARCH: - { - BINARY_TREE_SEARCH_3(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 0, 3, 0); - break; - } - - case LUT_COLOR_CUBE_SEARCH: - { - switch (s->indexsize) { - case 1: - { - COLOR_CUBE_U8_3_SEARCH(mlib_u8, 0, 3); - break; - } - - case 2: - { - COLOR_CUBE_U8_3_SEARCH(mlib_s16, 0, 3); - break; - } - } - - break; - } - - case LUT_STUPID_SEARCH: - { -#ifdef USE_VIS_CODE - FIND_NEAREST_U8_3; -#else - FIND_NEAREST_U8_3_C(0, 3); -#endif - break; - } - - case LUT_COLOR_DIMENSIONS: - DIMENSIONS_SEARCH_3(mlib_u8, mlib_s16, 3) - break; - } -} - -/***************************************************************/ -void mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4(const mlib_u8 *src, - mlib_s16 *dst, - mlib_s32 length, - const void *state) -{ - mlib_colormap *s = (mlib_colormap *)state; - mlib_s32 bits = s->bits; - - switch (s->method) { - case LUT_BINARY_TREE_SEARCH: - { - BINARY_TREE_SEARCH_3(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 1, 4, 0); - break; - } - - case LUT_COLOR_CUBE_SEARCH: - { - switch (s->indexsize) { - case 1: - { - COLOR_CUBE_U8_3_SEARCH(mlib_u8, 1, 4); - break; - } - - case 2: - { - COLOR_CUBE_U8_3_SEARCH(mlib_s16, 1, 4); - break; - } - } - - break; - } - - case LUT_STUPID_SEARCH: - { -#ifdef USE_VIS_CODE - FIND_NEAREST_U8_3_IN4; -#else - FIND_NEAREST_U8_3_C(1, 4); -#endif - break; - } - - case LUT_COLOR_DIMENSIONS: - src++; - DIMENSIONS_SEARCH_3(mlib_u8, mlib_s16, 4) - break; - } -} - -/***************************************************************/ -void mlib_ImageColorTrue2IndexLine_U8_S16_4(const mlib_u8 *src, - mlib_s16 *dst, - mlib_s32 length, - const void *state) -{ - mlib_colormap *s = (mlib_colormap *)state; - mlib_s32 bits = s->bits; - - switch (s->method) { - case LUT_BINARY_TREE_SEARCH: - { - BINARY_TREE_SEARCH_4(U8, mlib_u8, 8, (MLIB_U8_MAX + 1), 0, 0); - break; - } - - case LUT_COLOR_CUBE_SEARCH: - { - switch (s->indexsize) { - case 1: - { - COLOR_CUBE_U8_4_SEARCH(mlib_u8); - break; - } - - case 2: - { - COLOR_CUBE_U8_4_SEARCH(mlib_s16); - break; - } - } - - break; - } - - case LUT_STUPID_SEARCH: - { -#ifdef USE_VIS_CODE - FIND_NEAREST_U8_4; -#else - FIND_NEAREST_U8_4_C; -#endif - break; - } - - case LUT_COLOR_DIMENSIONS: - DIMENSIONS_SEARCH_4(mlib_u8, mlib_s16) - break; - } -} - -/***************************************************************/ -void mlib_ImageColorTrue2IndexLine_S16_S16_3(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 length, - const void *state) -{ - mlib_colormap *s = (mlib_colormap *)state; - mlib_s32 bits = s->bits; - - switch (s->method) { - case LUT_BINARY_TREE_SEARCH: - { - BINARY_TREE_SEARCH_3(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2), - MLIB_S16_MIN, 0, 3, 2); - break; - } - - case LUT_COLOR_CUBE_SEARCH: - { - switch (s->indexsize) { - case 1: - { - COLOR_CUBE_S16_3_SEARCH(mlib_u8, 0, 3); - break; - } - - case 2: - { - COLOR_CUBE_S16_3_SEARCH(mlib_s16, 0, 3); - break; - } - } - - break; - } - - case LUT_STUPID_SEARCH: - { - FIND_NEAREST_S16_3(0, 3); - break; - } - - case LUT_COLOR_DIMENSIONS: - DIMENSIONS_SEARCH_3(mlib_s16, mlib_s16, 3) - break; - } -} - -/***************************************************************/ -void mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 length, - const void *state) -{ - mlib_colormap *s = (mlib_colormap *)state; - mlib_s32 bits = s->bits; - - switch (s->method) { - case LUT_BINARY_TREE_SEARCH: - { - BINARY_TREE_SEARCH_3(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2), - MLIB_S16_MIN, 1, 4, 2); - break; - } - - case LUT_COLOR_CUBE_SEARCH: - { - switch (s->indexsize) { - case 1: - { - COLOR_CUBE_S16_3_SEARCH(mlib_u8, 1, 4); - break; - } - - case 2: - { - COLOR_CUBE_S16_3_SEARCH(mlib_s16, 1, 4); - break; - } - } - - break; - } - - case LUT_STUPID_SEARCH: - { - FIND_NEAREST_S16_3(1, 4); - break; - } - - case LUT_COLOR_DIMENSIONS: - src++; - DIMENSIONS_SEARCH_3(mlib_s16, mlib_s16, 4) - break; - } -} - -/***************************************************************/ -void mlib_ImageColorTrue2IndexLine_S16_S16_4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 length, - const void *state) -{ - mlib_colormap *s = (mlib_colormap *)state; - mlib_s32 bits = s->bits; - - switch (s->method) { - case LUT_BINARY_TREE_SEARCH: - { - BINARY_TREE_SEARCH_4(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2), - MLIB_S16_MIN, 2); - break; - } - - case LUT_COLOR_CUBE_SEARCH: - { - switch (s->indexsize) { - case 1: - { - COLOR_CUBE_S16_4_SEARCH(mlib_u8); - break; - } - - case 2: - { - COLOR_CUBE_S16_4_SEARCH(mlib_s16); - break; - } - } - - break; - } - - case LUT_STUPID_SEARCH: - { - FIND_NEAREST_S16_4; - break; - } - - case LUT_COLOR_DIMENSIONS: - DIMENSIONS_SEARCH_4(mlib_s16, mlib_s16) - break; - } -} - -/***************************************************************/ -void mlib_ImageColorTrue2IndexLine_S16_U8_3(const mlib_s16 *src, - mlib_u8 *dst, - mlib_s32 length, - const void *state) -{ - mlib_colormap *s = (mlib_colormap *)state; - - switch (s->method) { -#if LUT_SHORT_COLORS_3CHANNELS <= 256 - case LUT_BINARY_TREE_SEARCH: - { - mlib_s32 bits = s->bits; - BINARY_TREE_SEARCH_3(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2), - MLIB_S16_MIN, 0, 3, 2); - break; - } - -#endif /* LUT_SHORT_COLORS_3CHANNELS <= 256 */ - case LUT_COLOR_CUBE_SEARCH: - { - COLOR_CUBE_S16_3_SEARCH(mlib_u8, 0, 3); - break; - } - - case LUT_STUPID_SEARCH: - { - FIND_NEAREST_S16_3(0, 3); - break; - } - - case LUT_COLOR_DIMENSIONS: - DIMENSIONS_SEARCH_3(mlib_s16, mlib_u8, 3) - break; - } -} - -/***************************************************************/ -void mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4(const mlib_s16 *src, - mlib_u8 *dst, - mlib_s32 length, - const void *state) -{ - mlib_colormap *s = (mlib_colormap *)state; - - switch (s->method) { -#if LUT_SHORT_COLORS_3CHANNELS <= 256 - case LUT_BINARY_TREE_SEARCH: - { - mlib_s32 bits = s->bits; - BINARY_TREE_SEARCH_3(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2), - MLIB_S16_MIN, 1, 4, 2); - break; - } - -#endif /* LUT_SHORT_COLORS_3CHANNELS <= 256 */ - case LUT_COLOR_CUBE_SEARCH: - { - COLOR_CUBE_S16_3_SEARCH(mlib_u8, 1, 4); - break; - } - - case LUT_STUPID_SEARCH: - { - FIND_NEAREST_S16_3(1, 4); - break; - } - - case LUT_COLOR_DIMENSIONS: - src++; - DIMENSIONS_SEARCH_3(mlib_s16, mlib_u8, 4) - break; - } -} - -/***************************************************************/ -void mlib_ImageColorTrue2IndexLine_S16_U8_4(const mlib_s16 *src, - mlib_u8 *dst, - mlib_s32 length, - const void *state) -{ - mlib_colormap *s = (mlib_colormap *)state; - - switch (s->method) { -#if LUT_SHORT_COLORS_4CHANNELS <= 256 - case LUT_BINARY_TREE_SEARCH: - { - mlib_s32 bits = s->bits; - BINARY_TREE_SEARCH_4(S16, mlib_s16, 16, ((MLIB_S16_MAX + 1) * 2), - MLIB_S16_MIN, 2); - break; - } - -#endif /* LUT_SHORT_COLORS_4CHANNELS <= 256 */ - case LUT_COLOR_CUBE_SEARCH: - { - COLOR_CUBE_S16_4_SEARCH(mlib_u8); - break; - } - - case LUT_STUPID_SEARCH: - { - FIND_NEAREST_S16_4; - break; - } - - case LUT_COLOR_DIMENSIONS: - DIMENSIONS_SEARCH_4(mlib_s16, mlib_u8) - break; - } -} - -/***************************************************************/ - -#ifndef VIS - -void mlib_c_ImageThresh1_U81_1B(void *psrc, - void *pdst, - mlib_s32 src_stride, - mlib_s32 dst_stride, - mlib_s32 width, - mlib_s32 height, - void *thresh, - void *ghigh, - void *glow, - mlib_s32 dbit_off); - -/***************************************************************/ - -void mlib_ImageColorTrue2IndexLine_U8_BIT_1(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 bit_offset, - mlib_s32 length, - const void *state) -{ - mlib_u8 *lut = ((mlib_colormap *)state)->table; - mlib_s32 thresh[1]; - mlib_s32 ghigh[1]; - mlib_s32 glow[1]; - - thresh[0] = lut[2]; - - glow[0] = lut[0] - lut[1]; - ghigh[0] = lut[1] - lut[0]; - - mlib_c_ImageThresh1_U81_1B((void*)src, dst, 0, 0, length, 1, - thresh, ghigh, glow, bit_offset); -} - -#else - -/***************************************************************/ - -void mlib_v_ImageThresh1B_U8_1(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 dbit_off, - const mlib_s32 *th, - mlib_s32 hc, - mlib_s32 lc); - -/***************************************************************/ - -void mlib_ImageColorTrue2IndexLine_U8_BIT_1(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 bit_offset, - mlib_s32 length, - const void *state) -{ - mlib_u8 *lut = ((mlib_colormap *)state)->table; - mlib_s32 thresh[4]; - mlib_s32 ghigh[1]; - mlib_s32 glow[1]; - - thresh[0] = thresh[1] = thresh[2] = thresh[3] = lut[2]; - - glow[0] = (lut[1] < lut[0]) ? 0xFF : 0; - ghigh[0] = (lut[1] < lut[0]) ? 0 : 0xFF; - - mlib_v_ImageThresh1B_U8_1((void*)src, 0, dst, 0, length, 1, - bit_offset, thresh, ghigh[0], glow[0]); -} - -/***************************************************************/ - -#endif diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColormap.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColormap.h deleted file mode 100644 index 331851bfc7a..00000000000 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColormap.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -#ifndef __MLIB_IMAGECOLORMAP_H -#define __MLIB_IMAGECOLORMAP_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -typedef struct { - void **lut; - mlib_s32 channels; - mlib_type intype; - mlib_s32 offset; - void *table; - mlib_s32 bits; - mlib_s32 method; - mlib_s32 lutlength; - mlib_s32 indexsize; - mlib_type outtype; - void *normal_table; - mlib_d64 *double_lut; -} mlib_colormap; - -/***************************************************************/ -#define LUT_COLOR_CUBE_SEARCH 0 -#define LUT_BINARY_TREE_SEARCH 1 -#define LUT_STUPID_SEARCH 2 -#define LUT_COLOR_DIMENSIONS 3 - -/***************************************************************/ - -/* Bit set in the tag denotes that the corresponding quadrant is a - palette index, not node. If the bit is clear, this means that that - is a pointer to the down level node. If the bit is clear and the - corresponding quadrant is NULL, then there is no way down there and - this quadrant is clear. */ - -struct lut_node_3 { - mlib_u8 tag; - union { - struct lut_node_3 *quadrants[8]; - long index[8]; - } contents; -}; - -struct lut_node_4 { - mlib_u16 tag; - union { - struct lut_node_4 *quadrants[16]; - long index[16]; - } contents; -}; - -/***************************************************************/ - -#define mlib_ImageGetLutData(colormap) \ - ((void **)((( mlib_colormap *)( colormap))->lut)) - -/***************************************************************/ -#define mlib_ImageGetLutNormalTable(colormap) \ - ((void *)((( mlib_colormap *)( colormap))->normal_table)) - -/***************************************************************/ -#define mlib_ImageGetLutInversTable(colormap) \ - ((void *)((( mlib_colormap *)( colormap))->table)) - -/***************************************************************/ -#define mlib_ImageGetLutChannels(colormap) \ - ((mlib_s32)((( mlib_colormap *)( colormap))->channels)) - -/***************************************************************/ -#define mlib_ImageGetLutType(colormap) \ - ((mlib_type)((( mlib_colormap *)( colormap))->intype)) - -/***************************************************************/ -#define mlib_ImageGetIndexSize(colormap) \ - ((mlib_s32)((( mlib_colormap *)( colormap))->indexsize)) - -/***************************************************************/ -#define mlib_ImageGetOutType(colormap) \ - ((mlib_type)((( mlib_colormap *)( colormap))->outtype)) - -/***************************************************************/ -#define mlib_ImageGetLutOffset(colormap) \ - ((mlib_s32)((( mlib_colormap *)( colormap))->offset)) - -/***************************************************************/ -#define mlib_ImageGetBits(colormap) \ - ((mlib_s32)((( mlib_colormap *)( colormap))->bits)) - -/***************************************************************/ -#define mlib_ImageGetMethod(colormap) \ - ((mlib_s32)((( mlib_colormap *)( colormap))->method)) - -/***************************************************************/ -#define mlib_ImageGetLutDoubleData(colormap) \ - ((mlib_d64 *)((( mlib_colormap *)( colormap))->double_lut)) - -/***************************************************************/ -#define FIND_DISTANCE_3( x1, x2, y1, y2, z1, z2, SHIFT ) \ - (( ( ( ( x1 ) - ( x2 ) ) * ( ( x1 ) - ( x2 ) ) ) >> SHIFT ) + \ - ( ( ( ( y1 ) - ( y2 ) ) * ( ( y1 ) - ( y2 ) ) ) >> SHIFT ) + \ - ( ( ( ( z1 ) - ( z2 ) ) * ( ( z1 ) - ( z2 ) ) ) >> SHIFT ) ) - -/***************************************************************/ -#define FIND_DISTANCE_4( x1, x2, y1, y2, z1, z2, w1, w2, SHIFT ) \ - (( ( ( ( x1 ) - ( x2 ) ) * ( ( x1 ) - ( x2 ) ) ) >> SHIFT ) + \ - ( ( ( ( y1 ) - ( y2 ) ) * ( ( y1 ) - ( y2 ) ) ) >> SHIFT ) + \ - ( ( ( ( z1 ) - ( z2 ) ) * ( ( z1 ) - ( z2 ) ) ) >> SHIFT ) + \ - ( ( ( ( w1 ) - ( w2 ) ) * ( ( w1 ) - ( w2 ) ) ) >> SHIFT ) ) - -/***************************************************************/ - -void mlib_ImageColorTrue2IndexLine_U8_BIT_1(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 bit_offset, - mlib_s32 length, - const void *state); - - -void mlib_ImageColorTrue2IndexLine_U8_U8_3(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 length, - const void *colormap); - - -void mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 length, - const void *colormap); - - -void mlib_ImageColorTrue2IndexLine_U8_U8_4(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 length, - const void *colormap); - - -void mlib_ImageColorTrue2IndexLine_U8_S16_3(const mlib_u8 *src, - mlib_s16 *dst, - mlib_s32 length, - const void *colormap); - - -void mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4(const mlib_u8 *src, - mlib_s16 *dst, - mlib_s32 length, - const void *colormap); - - -void mlib_ImageColorTrue2IndexLine_U8_S16_4(const mlib_u8 *src, - mlib_s16 *dst, - mlib_s32 length, - const void *colormap); - - -void mlib_ImageColorTrue2IndexLine_S16_S16_3(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 length, - const void *colormap); - - -void mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 length, - const void *colormap); - - -void mlib_ImageColorTrue2IndexLine_S16_S16_4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 length, - const void *colormap); - - -void mlib_ImageColorTrue2IndexLine_S16_U8_3(const mlib_s16 *src, - mlib_u8 *dst, - mlib_s32 length, - const void *colormap); - - -void mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4(const mlib_s16 *src, - mlib_u8 *dst, - mlib_s32 length, - const void *colormap); - - -void mlib_ImageColorTrue2IndexLine_S16_U8_4(const mlib_s16 *src, - mlib_u8 *dst, - mlib_s32 length, - const void *colormap); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __MLIB_IMAGECOLORMAP_H */ diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv.h index a4f37d90386..dc4b6bd4cd7 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv.h +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv.h @@ -41,466 +41,6 @@ return status; \ } #endif /* FREE_AND_RETURN_STATUS */ -void mlib_ImageXor80_aa(mlib_u8 *dl, - mlib_s32 wid, - mlib_s32 hgt, - mlib_s32 str); - -void mlib_ImageXor80(mlib_u8 *dl, - mlib_s32 wid, - mlib_s32 hgt, - mlib_s32 str, - mlib_s32 nchan, - mlib_s32 cmask); - -mlib_status mlib_conv2x2ext_d64(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv2x2ext_f32(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv2x2ext_s16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv2x2ext_s32(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv2x2ext_u16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv2x2ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv2x2nw_d64(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv2x2nw_f32(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv2x2nw_s16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv2x2nw_s32(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv2x2nw_u16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv2x2nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv3x3ext_bit(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv3x3ext_d64(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv3x3ext_f32(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv3x3ext_s16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv3x3ext_s32(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv3x3ext_u16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv3x3ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv3x3nw_bit(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv3x3nw_d64(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv3x3nw_f32(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv3x3nw_s16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv3x3nw_s32(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv3x3nw_u16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv3x3nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv4x4ext_d64(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv4x4ext_f32(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv4x4ext_s16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv4x4ext_s32(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv4x4ext_u16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv4x4ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv4x4nw_d64(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv4x4nw_f32(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv4x4nw_s16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv4x4nw_s32(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv4x4nw_u16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv4x4nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv5x5ext_d64(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv5x5ext_f32(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv5x5ext_s16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv5x5ext_s32(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv5x5ext_u16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv5x5ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv5x5nw_d64(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv5x5nw_f32(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *kern, - mlib_s32 cmask); - -mlib_status mlib_conv5x5nw_s16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv5x5nw_s32(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv5x5nw_u16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv5x5nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv7x7ext_s16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv7x7ext_s32(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv7x7ext_u16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv7x7ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv7x7nw_s16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv7x7nw_s32(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv7x7nw_u16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv7x7nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - mlib_status mlib_convMxNext_s32(mlib_image *dst, const mlib_image *src, const mlib_s32 *kernel, diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv2x2_f.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv2x2_f.c deleted file mode 100644 index f10cbe61eb2..00000000000 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv2x2_f.c +++ /dev/null @@ -1,1118 +0,0 @@ -/* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * FUNCTION - * Internal functions for mlib_ImageConv2x2 on U8/S16/U16 types - * and MLIB_EDGE_DST_NO_WRITE mask. - */ - -#include "mlib_image.h" -#include "mlib_ImageConv.h" -#include "mlib_c_ImageConv.h" - -/***************************************************************/ -#ifdef i386 /* do not copy by mlib_d64 data type for x86 */ - -typedef struct { - mlib_s32 int0, int1; -} two_int; - -#define TYPE_64BIT two_int - -#else /* i386 */ - -#define TYPE_64BIT mlib_d64 - -#endif /* i386 ( do not copy by mlib_d64 data type for x86 ) */ - -/***************************************************************/ -#define LOAD_KERNEL_INTO_DOUBLE() \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - /* keep kernel in regs */ \ - k0 = scalef * kern[0]; k1 = scalef * kern[1]; k2 = scalef * kern[2]; \ - k3 = scalef * kern[3] - -/***************************************************************/ -#define GET_SRC_DST_PARAMETERS(type) \ - hgt = mlib_ImageGetHeight(src); \ - wid = mlib_ImageGetWidth(src); \ - nchannel = mlib_ImageGetChannels(src); \ - sll = mlib_ImageGetStride(src) / sizeof(type); \ - dll = mlib_ImageGetStride(dst) / sizeof(type); \ - adr_src = (type *)mlib_ImageGetData(src); \ - adr_dst = (type *)mlib_ImageGetData(dst) - -/***************************************************************/ -#ifndef MLIB_USE_FTOI_CLAMPING - -#define CLAMP_S32(x) \ - (((x) <= MLIB_S32_MIN) ? MLIB_S32_MIN : \ - (((x) >= MLIB_S32_MAX) ? MLIB_S32_MAX : (mlib_s32)(x))) - -#else - -#define CLAMP_S32(x) ((mlib_s32)(x)) - -#endif /* MLIB_USE_FTOI_CLAMPING */ - -/***************************************************************/ -#if defined(_LITTLE_ENDIAN) && !defined(_NO_LONGLONG) - -/* NB: Explicit cast to DTYPE is necessary to avoid warning from Microsoft VC compiler. - And we need to explicitly define cast behavior if source exceeds destination range. - (it is undefined according to C99 spec). We use mask here because this macro is typically - used to extract bit regions. */ - -#define STORE2(res0, res1) \ - dp[0 ] = (DTYPE) ((res1) & DTYPE_MASK); \ - dp[chan1] = (DTYPE) ((res0) & DTYPE_MASK) - -#else - -#define STORE2(res0, res1) \ - dp[0 ] = (DTYPE) ((res0) & DTYPE_MASK); \ - dp[chan1] = (DTYPE) ((res1) & DTYPE_MASK) - -#endif /* defined(_LITTLE_ENDIAN) && !defined(_NO_LONGLONG) */ - -/***************************************************************/ -#ifdef _NO_LONGLONG - -#define LOAD_BUFF(buff) \ - buff[i ] = sp[0]; \ - buff[i + 1] = sp[chan1] - -#else /* _NO_LONGLONG */ - -#ifdef _LITTLE_ENDIAN - -#define LOAD_BUFF(buff) \ - *(mlib_s64*)(buff + i) = (((mlib_s64)sp[chan1]) << 32) | ((mlib_s64)sp[0] & 0xffffffff) - -#else /* _LITTLE_ENDIAN */ - -#define LOAD_BUFF(buff) \ - *(mlib_s64*)(buff + i) = (((mlib_s64)sp[0]) << 32) | ((mlib_s64)sp[chan1] & 0xffffffff) - -#endif /* _LITTLE_ENDIAN */ - -#endif /* _NO_LONGLONG */ - -/***************************************************************/ -typedef union { - TYPE_64BIT d64; - struct { - mlib_s32 i0, i1; - } i32s; -} d64_2x32; - -/***************************************************************/ -#define D_KER 1 - -#define BUFF_LINE 256 - -/***************************************************************/ -#define XOR_80(x) x ^= 0x80 - -void mlib_ImageXor80_aa(mlib_u8 *dl, - mlib_s32 wid, - mlib_s32 hgt, - mlib_s32 str) -{ - mlib_u8 *dp, *dend; -#ifdef _NO_LONGLONG - mlib_u32 cadd = 0x80808080; -#else /* _NO_LONGLONG */ - mlib_u64 cadd = MLIB_U64_CONST(0x8080808080808080); -#endif /* _NO_LONGLONG */ - mlib_s32 j; - - if (wid == str) { - wid *= hgt; - hgt = 1; - } - - for (j = 0; j < hgt; j++) { - dend = dl + wid; - - for (dp = dl; ((mlib_addr)dp & 7) && (dp < dend); dp++) XOR_80(dp[0]); - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (; dp <= (dend - 8); dp += 8) { -#ifdef _NO_LONGLONG - *((mlib_s32*)dp) ^= cadd; - *((mlib_s32*)dp+1) ^= cadd; -#else /* _NO_LONGLONG */ - *((mlib_u64*)dp) ^= cadd; -#endif /* _NO_LONGLONG */ - } - - for (; (dp < dend); dp++) XOR_80(dp[0]); - - dl += str; - } -} - -/***************************************************************/ -void mlib_ImageXor80(mlib_u8 *dl, - mlib_s32 wid, - mlib_s32 hgt, - mlib_s32 str, - mlib_s32 nchan, - mlib_s32 cmask) -{ - mlib_s32 i, j, c; - - for (j = 0; j < hgt; j++) { - for (c = 0; c < nchan; c++) { - if (cmask & (1 << (nchan - 1 - c))) { - mlib_u8 *dp = dl + c; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid; i++) XOR_80(dp[i*nchan]); - } - } - - dl += str; - } -} - -/***************************************************************/ -#define DTYPE mlib_s16 -#define DTYPE_MASK 0xffff - -mlib_status mlib_c_conv2x2nw_s16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_d64 buff_arr[2*BUFF_LINE]; - mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT; - DTYPE *adr_src, *sl, *sp, *sl1; - DTYPE *adr_dst, *dl, *dp; - mlib_d64 k0, k1, k2, k3, scalef = 65536.0; - mlib_d64 p00, p01, p02, - p10, p11, p12; - mlib_s32 wid, hgt, sll, dll, wid1; - mlib_s32 nchannel, chan1, chan2; - mlib_s32 i, j, c; - LOAD_KERNEL_INTO_DOUBLE(); - GET_SRC_DST_PARAMETERS(DTYPE); - - wid1 = (wid + 1) &~ 1; - - if (wid1 > BUFF_LINE) { - pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buffo = pbuff; - buff0 = buffo + wid1; - buff1 = buff0 + wid1; - buff2 = buff1 + wid1; - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= D_KER; - hgt -= D_KER; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + D_KER; i++) { - buff0[i - 1] = (mlib_s32)sl[i*chan1]; - buff1[i - 1] = (mlib_s32)sl1[i*chan1]; - } - - sl += (D_KER + 1)*sll; - - for (j = 0; j < hgt; j++) { - sp = sl; - dp = dl; - - buff2[-1] = (mlib_s32)sp[0]; - sp += chan1; - - p02 = buff0[-1]; - p12 = buff1[-1]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { -#ifdef _NO_LONGLONG - mlib_s32 o64_1, o64_2; -#else /* _NO_LONGLONG */ - mlib_s64 o64; -#endif /* _NO_LONGLONG */ - d64_2x32 sd0, sd1, dd; - - p00 = p02; p10 = p12; - - sd0.d64 = *(TYPE_64BIT*)(buff0 + i); - sd1.d64 = *(TYPE_64BIT*)(buff1 + i); - p01 = (mlib_d64)sd0.i32s.i0; - p02 = (mlib_d64)sd0.i32s.i1; - p11 = (mlib_d64)sd1.i32s.i0; - p12 = (mlib_d64)sd1.i32s.i1; - - LOAD_BUFF(buff2); - - dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3); - dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3); - *(TYPE_64BIT*)(buffo + i) = dd.d64; - -#ifdef _NO_LONGLONG - - o64_1 = buffo[i]; - o64_2 = buffo[i+1]; - STORE2(o64_1 >> 16, o64_2 >> 16); - -#else /* _NO_LONGLONG */ - - o64 = *(mlib_s64*)(buffo + i); - STORE2(o64 >> 48, o64 >> 16); - -#endif /* _NO_LONGLONG */ - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i - 1]; p10 = buff1[i - 1]; - p01 = buff0[i]; p11 = buff1[i]; - - buff2[i] = (mlib_s32)sp[0]; - - buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3); - dp[0] = buffo[i] >> 16; - - sp += chan1; - dp += chan1; - } - - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buffT; - } - } - - if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -mlib_status mlib_c_conv2x2ext_s16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_d64 buff_arr[2*BUFF_LINE]; - mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT; - DTYPE *adr_src, *sl, *sp, *sl1; - DTYPE *adr_dst, *dl, *dp; - mlib_d64 k0, k1, k2, k3, scalef = 65536.0; - mlib_d64 p00, p01, p02, - p10, p11, p12; - mlib_s32 wid, hgt, sll, dll, wid1; - mlib_s32 nchannel, chan1, chan2; - mlib_s32 i, j, c, swid; - LOAD_KERNEL_INTO_DOUBLE(); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + D_KER; - - wid1 = (swid + 1) &~ 1; - - if (wid1 > BUFF_LINE) { - pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buffo = pbuff; - buff0 = buffo + wid1; - buff1 = buff0 + wid1; - buff2 = buff1 + wid1; - - swid -= dx_r; - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((hgt - dy_b) > 0) sl1 = sl + sll; - else sl1 = sl; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buff0[i - 1] = (mlib_s32)sl[i*chan1]; - buff1[i - 1] = (mlib_s32)sl1[i*chan1]; - } - - if (dx_r != 0) { - buff0[swid - 1] = buff0[swid - 2]; - buff1[swid - 1] = buff1[swid - 2]; - } - - if ((hgt - dy_b) > 1) sl = sl1 + sll; - else sl = sl1; - - for (j = 0; j < hgt; j++) { - sp = sl; - dp = dl; - - buff2[-1] = (mlib_s32)sp[0]; - sp += chan1; - - p02 = buff0[-1]; - p12 = buff1[-1]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { -#ifdef _NO_LONGLONG - mlib_s32 o64_1, o64_2; -#else /* _NO_LONGLONG */ - mlib_s64 o64; -#endif /* _NO_LONGLONG */ - d64_2x32 sd0, sd1, dd; - - p00 = p02; p10 = p12; - - sd0.d64 = *(TYPE_64BIT*)(buff0 + i); - sd1.d64 = *(TYPE_64BIT*)(buff1 + i); - p01 = (mlib_d64)sd0.i32s.i0; - p02 = (mlib_d64)sd0.i32s.i1; - p11 = (mlib_d64)sd1.i32s.i0; - p12 = (mlib_d64)sd1.i32s.i1; - - LOAD_BUFF(buff2); - - dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3); - dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3); - *(TYPE_64BIT*)(buffo + i) = dd.d64; - -#ifdef _NO_LONGLONG - - o64_1 = buffo[i]; - o64_2 = buffo[i+1]; - STORE2(o64_1 >> 16, o64_2 >> 16); - -#else /* _NO_LONGLONG */ - - o64 = *(mlib_s64*)(buffo + i); - STORE2(o64 >> 48, o64 >> 16); - -#endif /* _NO_LONGLONG */ - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i - 1]; p10 = buff1[i - 1]; - p01 = buff0[i]; p11 = buff1[i]; - - buff2[i] = (mlib_s32)sp[0]; - - buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3); - dp[0] = buffo[i] >> 16; - - sp += chan1; - dp += chan1; - } - - if (dx_r != 0) buff2[swid - 1] = buff2[swid - 2]; - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buffT; - } - } - - if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef DTYPE -#define DTYPE mlib_u16 - -mlib_status mlib_c_conv2x2nw_u16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_d64 buff_arr[2*BUFF_LINE]; - mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT; - DTYPE *adr_src, *sl, *sp, *sl1; - DTYPE *adr_dst, *dl, *dp; - mlib_d64 k0, k1, k2, k3, scalef = 65536.0; - mlib_d64 p00, p01, p02, - p10, p11, p12; - mlib_s32 wid, hgt, sll, dll, wid1; - mlib_s32 nchannel, chan1, chan2; - mlib_s32 i, j, c; - mlib_d64 doff = 0x7FFF8000; - LOAD_KERNEL_INTO_DOUBLE(); - GET_SRC_DST_PARAMETERS(DTYPE); - - wid1 = (wid + 1) &~ 1; - - if (wid1 > BUFF_LINE) { - pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buffo = pbuff; - buff0 = buffo + wid1; - buff1 = buff0 + wid1; - buff2 = buff1 + wid1; - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= D_KER; - hgt -= D_KER; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + D_KER; i++) { - buff0[i - 1] = (mlib_s32)sl[i*chan1]; - buff1[i - 1] = (mlib_s32)sl1[i*chan1]; - } - - sl += (D_KER + 1)*sll; - - for (j = 0; j < hgt; j++) { - sp = sl; - dp = dl; - - buff2[-1] = (mlib_s32)sp[0]; - sp += chan1; - - p02 = buff0[-1]; - p12 = buff1[-1]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { -#ifdef _NO_LONGLONG - mlib_s32 o64_1, o64_2; -#else /* _NO_LONGLONG */ - mlib_s64 o64; -#endif /* _NO_LONGLONG */ - d64_2x32 sd0, sd1, dd; - - p00 = p02; p10 = p12; - - sd0.d64 = *(TYPE_64BIT*)(buff0 + i); - sd1.d64 = *(TYPE_64BIT*)(buff1 + i); - p01 = (mlib_d64)sd0.i32s.i0; - p02 = (mlib_d64)sd0.i32s.i1; - p11 = (mlib_d64)sd1.i32s.i0; - p12 = (mlib_d64)sd1.i32s.i1; - - LOAD_BUFF(buff2); - - dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - doff); - dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3 - doff); - *(TYPE_64BIT*)(buffo + i) = dd.d64; - -#ifdef _NO_LONGLONG - - o64_1 = buffo[i]; - o64_2 = buffo[i+1]; - o64_1 = o64_1 ^ 0x80000000U; - o64_2 = o64_2 ^ 0x80000000U; - STORE2(o64_1 >> 16, o64_2 >> 16); - -#else /* _NO_LONGLONG */ - - o64 = *(mlib_s64*)(buffo + i); - o64 = o64 ^ MLIB_U64_CONST(0x8000000080000000); - STORE2(o64 >> 48, o64 >> 16); - -#endif /* _NO_LONGLONG */ - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i - 1]; p10 = buff1[i - 1]; - p01 = buff0[i]; p11 = buff1[i]; - - buff2[i] = (mlib_s32)sp[0]; - - buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - doff); - dp[0] = (buffo[i] >> 16) ^ 0x8000; - - sp += chan1; - dp += chan1; - } - - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buffT; - } - } - - if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -mlib_status mlib_c_conv2x2ext_u16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_d64 buff_arr[2*BUFF_LINE]; - mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT; - DTYPE *adr_src, *sl, *sp, *sl1; - DTYPE *adr_dst, *dl, *dp; - mlib_d64 k0, k1, k2, k3, scalef = 65536.0; - mlib_d64 p00, p01, p02, - p10, p11, p12; - mlib_s32 wid, hgt, sll, dll, wid1; - mlib_s32 nchannel, chan1, chan2; - mlib_s32 i, j, c, swid; - mlib_d64 doff = 0x7FFF8000; - LOAD_KERNEL_INTO_DOUBLE(); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + D_KER; - - wid1 = (swid + 1) &~ 1; - - if (wid1 > BUFF_LINE) { - pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buffo = pbuff; - buff0 = buffo + wid1; - buff1 = buff0 + wid1; - buff2 = buff1 + wid1; - - swid -= dx_r; - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((hgt - dy_b) > 0) sl1 = sl + sll; - else sl1 = sl; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buff0[i - 1] = (mlib_s32)sl[i*chan1]; - buff1[i - 1] = (mlib_s32)sl1[i*chan1]; - } - - if (dx_r != 0) { - buff0[swid - 1] = buff0[swid - 2]; - buff1[swid - 1] = buff1[swid - 2]; - } - - if ((hgt - dy_b) > 1) sl = sl1 + sll; - else sl = sl1; - - for (j = 0; j < hgt; j++) { - sp = sl; - dp = dl; - - buff2[-1] = (mlib_s32)sp[0]; - sp += chan1; - - p02 = buff0[-1]; - p12 = buff1[-1]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { -#ifdef _NO_LONGLONG - mlib_s32 o64_1, o64_2; -#else /* _NO_LONGLONG */ - mlib_s64 o64; -#endif /* _NO_LONGLONG */ - d64_2x32 sd0, sd1, dd; - - p00 = p02; p10 = p12; - - sd0.d64 = *(TYPE_64BIT*)(buff0 + i); - sd1.d64 = *(TYPE_64BIT*)(buff1 + i); - p01 = (mlib_d64)sd0.i32s.i0; - p02 = (mlib_d64)sd0.i32s.i1; - p11 = (mlib_d64)sd1.i32s.i0; - p12 = (mlib_d64)sd1.i32s.i1; - - LOAD_BUFF(buff2); - - dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - doff); - dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3 - doff); - *(TYPE_64BIT*)(buffo + i) = dd.d64; - -#ifdef _NO_LONGLONG - - o64_1 = buffo[i]; - o64_2 = buffo[i+1]; - o64_1 = o64_1 ^ 0x80000000U; - o64_2 = o64_2 ^ 0x80000000U; - STORE2(o64_1 >> 16, o64_2 >> 16); - -#else /* _NO_LONGLONG */ - - o64 = *(mlib_s64*)(buffo + i); - o64 = o64 ^ MLIB_U64_CONST(0x8000000080000000); - STORE2(o64 >> 48, o64 >> 16); - -#endif /* _NO_LONGLONG */ - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i - 1]; p10 = buff1[i - 1]; - p01 = buff0[i]; p11 = buff1[i]; - - buff2[i] = (mlib_s32)sp[0]; - - buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - doff); - dp[0] = (buffo[i] >> 16) ^ 0x8000; - - sp += chan1; - dp += chan1; - } - - if (dx_r != 0) buff2[swid - 1] = buff2[swid - 2]; - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buffT; - } - } - - if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef DTYPE -#define DTYPE mlib_u8 - -mlib_status mlib_c_conv2x2nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_d64 buff_arr[2*BUFF_LINE]; - mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT; - DTYPE *adr_src, *sl, *sp, *sl1; - DTYPE *adr_dst, *dl, *dp; - mlib_d64 k0, k1, k2, k3, scalef = (1 << 24); - mlib_d64 p00, p01, p02, - p10, p11, p12; - mlib_s32 wid, hgt, sll, dll, wid1; - mlib_s32 nchannel, chan1, chan2; - mlib_s32 i, j, c; - LOAD_KERNEL_INTO_DOUBLE(); - GET_SRC_DST_PARAMETERS(DTYPE); - - wid1 = (wid + 1) &~ 1; - - if (wid1 > BUFF_LINE) { - pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buffo = pbuff; - buff0 = buffo + wid1; - buff1 = buff0 + wid1; - buff2 = buff1 + wid1; - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= D_KER; - hgt -= D_KER; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + D_KER; i++) { - buff0[i - 1] = (mlib_s32)sl[i*chan1]; - buff1[i - 1] = (mlib_s32)sl1[i*chan1]; - } - - sl += (D_KER + 1)*sll; - - for (j = 0; j < hgt; j++) { - sp = sl; - dp = dl; - - buff2[-1] = (mlib_s32)sp[0]; - sp += chan1; - - p02 = buff0[-1]; - p12 = buff1[-1]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { -#ifdef _NO_LONGLONG - mlib_s32 o64_1, o64_2; -#else /* _NO_LONGLONG */ - mlib_s64 o64; -#endif /* _NO_LONGLONG */ - d64_2x32 sd0, sd1, dd; - - p00 = p02; p10 = p12; - - sd0.d64 = *(TYPE_64BIT*)(buff0 + i); - sd1.d64 = *(TYPE_64BIT*)(buff1 + i); - p01 = (mlib_d64)sd0.i32s.i0; - p02 = (mlib_d64)sd0.i32s.i1; - p11 = (mlib_d64)sd1.i32s.i0; - p12 = (mlib_d64)sd1.i32s.i1; - - LOAD_BUFF(buff2); - - dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - (1u << 31)); - dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3 - (1u << 31)); - *(TYPE_64BIT*)(buffo + i) = dd.d64; - -#ifdef _NO_LONGLONG - - o64_1 = buffo[i]; - o64_2 = buffo[i+1]; - STORE2(o64_1 >> 24, o64_2 >> 24); - -#else /* _NO_LONGLONG */ - - o64 = *(mlib_s64*)(buffo + i); - STORE2(o64 >> 56, o64 >> 24); - -#endif /* _NO_LONGLONG */ - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i - 1]; p10 = buff1[i - 1]; - p01 = buff0[i]; p11 = buff1[i]; - - buff2[i] = (mlib_s32)sp[0]; - - buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - (1u << 31)); - dp[0] = (buffo[i] >> 24); - - sp += chan1; - dp += chan1; - } - - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buffT; - } - } - - { - mlib_s32 amask = (1 << nchannel) - 1; - - if ((cmask & amask) != amask) { - mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask); - } else { - mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll); - } - } - - if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -mlib_status mlib_c_conv2x2ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_d64 buff_arr[4*BUFF_LINE]; - mlib_s32 *pbuff = (mlib_s32*)buff_arr, *buffo, *buff0, *buff1, *buff2, *buffT; - DTYPE *adr_src, *sl, *sp, *sl1; - DTYPE *adr_dst, *dl, *dp; - mlib_d64 k0, k1, k2, k3, scalef = (1 << 24); - mlib_d64 p00, p01, p02, - p10, p11, p12; - mlib_s32 wid, hgt, sll, dll, wid1; - mlib_s32 nchannel, chan1, chan2; - mlib_s32 i, j, c, swid; - LOAD_KERNEL_INTO_DOUBLE(); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + D_KER; - - wid1 = (swid + 1) &~ 1; - - if (wid1 > BUFF_LINE) { - pbuff = mlib_malloc(4*sizeof(mlib_s32)*wid1); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buffo = pbuff; - buff0 = buffo + wid1; - buff1 = buff0 + wid1; - buff2 = buff1 + wid1; - - chan1 = nchannel; - chan2 = chan1 + chan1; - - swid -= dx_r; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((hgt - dy_b) > 0) sl1 = sl + sll; - else sl1 = sl; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buff0[i - 1] = (mlib_s32)sl[i*chan1]; - buff1[i - 1] = (mlib_s32)sl1[i*chan1]; - } - - if (dx_r != 0) { - buff0[swid - 1] = buff0[swid - 2]; - buff1[swid - 1] = buff1[swid - 2]; - } - - if ((hgt - dy_b) > 1) sl = sl1 + sll; - else sl = sl1; - - for (j = 0; j < hgt; j++) { - sp = sl; - dp = dl; - - buff2[-1] = (mlib_s32)sp[0]; - sp += chan1; - - p02 = buff0[-1]; - p12 = buff1[-1]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { -#ifdef _NO_LONGLONG - mlib_s32 o64_1, o64_2; -#else /* _NO_LONGLONG */ - mlib_s64 o64; -#endif /* _NO_LONGLONG */ - d64_2x32 sd0, sd1, dd; - - p00 = p02; p10 = p12; - - sd0.d64 = *(TYPE_64BIT*)(buff0 + i); - sd1.d64 = *(TYPE_64BIT*)(buff1 + i); - p01 = (mlib_d64)sd0.i32s.i0; - p02 = (mlib_d64)sd0.i32s.i1; - p11 = (mlib_d64)sd1.i32s.i0; - p12 = (mlib_d64)sd1.i32s.i1; - - LOAD_BUFF(buff2); - - dd.i32s.i0 = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - (1u << 31)); - dd.i32s.i1 = CLAMP_S32(p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3 - (1u << 31)); - *(TYPE_64BIT*)(buffo + i) = dd.d64; - -#ifdef _NO_LONGLONG - - o64_1 = buffo[i]; - o64_2 = buffo[i+1]; - STORE2(o64_1 >> 24, o64_2 >> 24); - -#else /* _NO_LONGLONG */ - - o64 = *(mlib_s64*)(buffo + i); - STORE2(o64 >> 56, o64 >> 24); - -#endif /* _NO_LONGLONG */ - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i - 1]; p10 = buff1[i - 1]; - p01 = buff0[i]; p11 = buff1[i]; - - buff2[i] = (mlib_s32)sp[0]; - - buffo[i] = CLAMP_S32(p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3 - (1u << 31)); - dp[0] = (buffo[i] >> 24); - - sp += chan1; - dp += chan1; - } - - if (dx_r != 0) buff2[swid - 1] = buff2[swid - 2]; - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buffT; - } - } - - { - mlib_s32 amask = (1 << nchannel) - 1; - - if ((cmask & amask) != amask) { - mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask); - } else { - mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll); - } - } - - if (pbuff != (mlib_s32*)buff_arr) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c index 11a68ad31f2..7226fd789ec 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16ext.c @@ -79,9 +79,6 @@ #endif /* IMG_TYPE == 1 */ -/***************************************************************/ -#define KSIZE1 (KSIZE - 1) - /***************************************************************/ #define PARAM \ mlib_image *dst, \ @@ -162,9 +159,6 @@ #endif /* _LITTLE_ENDIAN */ #endif /* _NO_LONGLONG */ -/***************************************************************/ -#define MLIB_D2_24 16777216.0f - /***************************************************************/ typedef union { mlib_d64 d64; @@ -174,52 +168,6 @@ typedef union { } i32s; } d64_2x32; -/***************************************************************/ -#define BUFF_LINE 256 - -/***************************************************************/ -#define DEF_VARS(type) \ - type *adr_src, *sl, *sp, *sl1; \ - type *adr_dst, *dl, *dp; \ - FTYPE *pbuff = buff; \ - mlib_s32 *buffi, *buffo; \ - mlib_s32 wid, hgt, sll, dll; \ - mlib_s32 nchannel, chan1, chan2; \ - mlib_s32 i, j, c, swid - -/***************************************************************/ -#define LOAD_KERNEL3() \ - FTYPE scalef = DSCALE; \ - FTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8; \ - FTYPE p00, p01, p02, p03, \ - p10, p11, p12, p13, \ - p20, p21, p22, p23; \ - \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - /* keep kernel in regs */ \ - k0 = scalef * kern[0]; k1 = scalef * kern[1]; k2 = scalef * kern[2]; \ - k3 = scalef * kern[3]; k4 = scalef * kern[4]; k5 = scalef * kern[5]; \ - k6 = scalef * kern[6]; k7 = scalef * kern[7]; k8 = scalef * kern[8] - -/***************************************************************/ -#define LOAD_KERNEL(SIZE) \ - FTYPE scalef = DSCALE; \ - \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j] - /***************************************************************/ #define GET_SRC_DST_PARAMETERS(type) \ hgt = mlib_ImageGetHeight(src); \ @@ -277,1334 +225,6 @@ typedef union { #endif /* IMG_TYPE == 1 */ #endif /* __sparc */ -/***************************************************************/ -#define KSIZE 3 - -mlib_status CONV_FUNC(3x3) -{ - FTYPE buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT; - DEF_VARS(DTYPE); - DTYPE *sl2; -#ifndef __sparc - mlib_s32 d0, d1; -#endif /* __sparc */ - LOAD_KERNEL3(); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + KSIZE1; - - if (swid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE )*swid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + swid; - buff2 = buff1 + swid; - buff3 = buff2 + swid; - buffo = (mlib_s32*)(buff3 + swid); - buffi = buffo + (swid &~ 1); - - swid -= (dx_l + dx_r); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll; - else sl1 = sl; - - if ((hgt - dy_b) > 0) sl2 = sl1 + sll; - else sl2 = sl1; - - for (i = 0; i < dx_l; i++) { - buff0[i] = (FTYPE)sl[0]; - buff1[i] = (FTYPE)sl1[0]; - buff2[i] = (FTYPE)sl2[0]; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buff0[i + dx_l] = (FTYPE)sl[i*chan1]; - buff1[i + dx_l] = (FTYPE)sl1[i*chan1]; - buff2[i + dx_l] = (FTYPE)sl2[i*chan1]; - } - - for (i = 0; i < dx_r; i++) { - buff0[swid + dx_l + i] = buff0[swid + dx_l - 1]; - buff1[swid + dx_l + i] = buff1[swid + dx_l - 1]; - buff2[swid + dx_l + i] = buff2[swid + dx_l - 1]; - } - - if ((hgt - dy_b) > 1) sl = sl2 + sll; - else sl = sl2; - - for (j = 0; j < hgt; j++) { - FTYPE s0, s1; - - p02 = buff0[0]; - p12 = buff1[0]; - p22 = buff2[0]; - - p03 = buff0[1]; - p13 = buff1[1]; - p23 = buff2[1]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp = sl; - dp = dl; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { -#ifdef __sparc -#ifdef _NO_LONGLONG - mlib_s32 o64_1, o64_2; -#else /* _NO_LONGLONG */ - mlib_s64 o64; -#endif /* _NO_LONGLONG */ -#endif /* __sparc */ - d64_2x32 dd; - - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buff3[i + dx_l ] = (FTYPE)dd.i32s.i0; - buff3[i + dx_l + 1] = (FTYPE)dd.i32s.i1; - -#ifndef __sparc - - d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8); - d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8); - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - -#else /* __sparc */ - - dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8); - dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8); - *(FTYPE *)(buffo + i) = dd.d64; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - -#ifdef _NO_LONGLONG - - o64_1 = buffo[i]; - o64_2 = buffo[i+1]; -#if IMG_TYPE != 1 - STORE2(FROM_S32(o64_1), FROM_S32(o64_2)); -#else - STORE2(o64_1 >> 24, o64_2 >> 24); -#endif /* IMG_TYPE != 1 */ - -#else /* _NO_LONGLONG */ - - o64 = *(mlib_s64*)(buffo + i); -#if IMG_TYPE != 1 - STORE2(FROM_S32(o64 >> 32), FROM_S32(o64)); -#else - STORE2(o64 >> 56, o64 >> 24); -#endif /* IMG_TYPE != 1 */ -#endif /* _NO_LONGLONG */ -#endif /* __sparc */ - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - - buffi[i] = (mlib_s32)sp[0]; - buff3[i + dx_l] = (FTYPE)buffi[i]; - -#ifndef __sparc - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); - - dp[0] = FROM_S32(d0); - -#else /* __sparc */ - - buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); -#if IMG_TYPE != 1 - dp[0] = FROM_S32(buffo[i]); -#else - dp[0] = buffo[i] >> 24; -#endif /* IMG_TYPE != 1 */ -#endif /* __sparc */ - - sp += chan1; - dp += chan1; - } - - for (; i < swid; i++) { - buffi[i] = (mlib_s32)sp[0]; - buff3[i + dx_l] = (FTYPE)buffi[i]; - sp += chan1; - } - - for (i = 0; i < dx_l; i++) buff3[i] = buff3[dx_l]; - for (i = 0; i < dx_r; i++) buff3[swid + dx_l + i] = buff3[swid + dx_l - 1]; - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buffT; - } - } - -#ifdef __sparc -#if IMG_TYPE == 1 - { - mlib_s32 amask = (1 << nchannel) - 1; - - if ((cmask & amask) != amask) { - mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask); - } else { - mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll); - } - } - -#endif /* IMG_TYPE == 1 */ -#endif /* __sparc */ - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#ifndef __sparc /* for x86, using integer multiplies is faster */ - -mlib_status CONV_FUNC_I(3x3) -{ - DTYPE *adr_src, *sl, *sp0, *sp1, *sp2, *sp_1, *sp_2; - DTYPE *adr_dst, *dl, *dp; - mlib_s32 wid, hgt, sll, dll; - mlib_s32 nchannel, chan1, chan2, delta_chan; - mlib_s32 i, j, c; - mlib_s32 shift1, shift2; - mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8; - mlib_s32 p02, p03, - p12, p13, - p22, p23; - -#if IMG_TYPE != 1 - shift1 = 16; -#else - shift1 = 8; -#endif /* IMG_TYPE != 1 */ - - shift2 = scalef_expon - shift1; - - /* keep kernel in regs */ - k0 = kern[0] >> shift1; k1 = kern[1] >> shift1; k2 = kern[2] >> shift1; - k3 = kern[3] >> shift1; k4 = kern[4] >> shift1; k5 = kern[5] >> shift1; - k6 = kern[6] >> shift1; k7 = kern[7] >> shift1; k8 = kern[8] >> shift1; - - GET_SRC_DST_PARAMETERS(DTYPE); - - chan1 = nchannel; - chan2 = chan1 + chan1; - delta_chan = 0; - - if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan = chan1; - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sp_1 = sl; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll; - sp_2 = sl; - - if ((hgt - dy_b) > 0) sl += sll; - - for (j = 0; j < hgt; j++) { - mlib_s32 s0, s1; - mlib_s32 pix0, pix1; - - dp = dl; - sp0 = sp_1; - sp_1 = sp_2; - sp_2 = sl; - - sp1 = sp_1; - sp2 = sp_2; - - p02 = sp0[0]; - p12 = sp1[0]; - p22 = sp2[0]; - - p03 = sp0[delta_chan]; - p13 = sp1[delta_chan]; - p23 = sp2[delta_chan]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += (chan1 + delta_chan); - sp1 += (chan1 + delta_chan); - sp2 += (chan1 + delta_chan); - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - dx_r - 2); i += 2) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1]; - - pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2; - pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 + - p13 * k5 + p22 * k7 + p23 * k8) >> shift2; - - CLAMP_STORE(dp[0], pix0); - CLAMP_STORE(dp[chan1], pix1); - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - dp += chan2; - } - - p02 = p03; p12 = p13; p22 = p23; - - for (; i < wid - dx_r; i++) { - p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0]; - pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2; - CLAMP_STORE(dp[0], pix0); - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - p02 = p03; p12 = p13; p22 = p23; - sp0 += chan1; - sp1 += chan1; - sp2 += chan1; - dp += chan1; - } - - sp0 -= chan1; - sp1 -= chan1; - sp2 -= chan1; - - for (; i < wid; i++) { - p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0]; - pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2; - CLAMP_STORE(dp[0], pix0); - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - p02 = p03; p12 = p13; p22 = p23; - dp += chan1; - } - - if (j < hgt - dy_b - 1) sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - -#endif /* __sparc ( for x86, using integer multiplies is faster ) */ - -/***************************************************************/ -#undef KSIZE -#define KSIZE 4 - -mlib_status CONV_FUNC(4x4) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE]; - FTYPE *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6, k7; - FTYPE p00, p01, p02, p03, p04, - p10, p11, p12, p13, p14, - p20, p21, p22, p23, - p30, p31, p32, p33; - DEF_VARS(DTYPE); - DTYPE *sl2, *sl3; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + KSIZE1; - - if (swid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE )*swid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + swid; - buff2 = buff1 + swid; - buff3 = buff2 + swid; - buff4 = buff3 + swid; - buffd = buff4 + swid; - buffo = (mlib_s32*)(buffd + swid); - buffi = buffo + (swid &~ 1); - - swid -= (dx_l + dx_r); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll; - else sl1 = sl; - - if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll; - else sl2 = sl1; - - if ((hgt - dy_b) > 0) sl3 = sl2 + sll; - else sl3 = sl2; - - for (i = 0; i < dx_l; i++) { - buff0[i] = (FTYPE)sl[0]; - buff1[i] = (FTYPE)sl1[0]; - buff2[i] = (FTYPE)sl2[0]; - buff3[i] = (FTYPE)sl3[0]; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buff0[i + dx_l] = (FTYPE)sl[i*chan1]; - buff1[i + dx_l] = (FTYPE)sl1[i*chan1]; - buff2[i + dx_l] = (FTYPE)sl2[i*chan1]; - buff3[i + dx_l] = (FTYPE)sl3[i*chan1]; - } - - for (i = 0; i < dx_r; i++) { - buff0[swid + dx_l + i] = buff0[swid + dx_l - 1]; - buff1[swid + dx_l + i] = buff1[swid + dx_l - 1]; - buff2[swid + dx_l + i] = buff2[swid + dx_l - 1]; - buff3[swid + dx_l + i] = buff3[swid + dx_l - 1]; - } - - if ((hgt - dy_b) > 1) sl = sl3 + sll; - else sl = sl3; - - for (j = 0; j < hgt; j++) { - d64_2x32 dd; - - /* - * First loop on two first lines of kernel - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; - k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff1[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buff4[i + dx_l ] = (FTYPE)dd.i32s.i0; - buff4[i + dx_l + 1] = (FTYPE)dd.i32s.i1; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7); - - sp += chan2; - } - - /* - * Second loop on two last lines of kernel - */ - k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11]; - k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15]; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - p04 = buff2[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]); - d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - - buff4[i + dx_l] = (FTYPE)sp[0]; - - buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + - p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] + - p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] + - p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]); - - dp[0] = FROM_S32(buffo[i]); - - sp += chan1; - dp += chan1; - } - - for (; i < swid; i++) { - buff4[i + dx_l] = (FTYPE)sp[0]; - sp += chan1; - } - - for (i = 0; i < dx_l; i++) buff4[i] = buff4[dx_l]; - for (i = 0; i < dx_r; i++) buff4[swid + dx_l + i] = buff4[swid + dx_l - 1]; - - /* next line */ - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 5 - -mlib_status CONV_FUNC(5x5) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE]; - FTYPE *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - FTYPE p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15, - p20, p21, p22, p23, p24, - p30, p31, p32, p33, p34, - p40, p41, p42, p43, p44; - DEF_VARS(DTYPE); - DTYPE *sl2, *sl3, *sl4; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + KSIZE1; - - if (swid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE )*swid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + swid; - buff2 = buff1 + swid; - buff3 = buff2 + swid; - buff4 = buff3 + swid; - buff5 = buff4 + swid; - buffd = buff5 + swid; - buffo = (mlib_s32*)(buffd + swid); - buffi = buffo + (swid &~ 1); - - swid -= (dx_l + dx_r); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll; - else sl1 = sl; - - if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll; - else sl2 = sl1; - - if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll; - else sl3 = sl2; - - if ((hgt - dy_b) > 0) sl4 = sl3 + sll; - else sl4 = sl3; - - for (i = 0; i < dx_l; i++) { - buff0[i] = (FTYPE)sl[0]; - buff1[i] = (FTYPE)sl1[0]; - buff2[i] = (FTYPE)sl2[0]; - buff3[i] = (FTYPE)sl3[0]; - buff4[i] = (FTYPE)sl4[0]; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buff0[i + dx_l] = (FTYPE)sl[i*chan1]; - buff1[i + dx_l] = (FTYPE)sl1[i*chan1]; - buff2[i + dx_l] = (FTYPE)sl2[i*chan1]; - buff3[i + dx_l] = (FTYPE)sl3[i*chan1]; - buff4[i + dx_l] = (FTYPE)sl4[i*chan1]; - } - - for (i = 0; i < dx_r; i++) { - buff0[swid + dx_l + i] = buff0[swid + dx_l - 1]; - buff1[swid + dx_l + i] = buff1[swid + dx_l - 1]; - buff2[swid + dx_l + i] = buff2[swid + dx_l - 1]; - buff3[swid + dx_l + i] = buff3[swid + dx_l - 1]; - buff4[swid + dx_l + i] = buff4[swid + dx_l - 1]; - } - - if ((hgt - dy_b) > 1) sl = sl4 + sll; - else sl = sl4; - - for (j = 0; j < hgt; j++) { - d64_2x32 dd; - - /* - * First loop - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - p14 = buff1[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - - LOAD_BUFF(buffi); - - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - p05 = buff0[i + 5]; p15 = buff1[i + 5]; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp += chan2; - } - - /* - * Second loop - */ - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - - p02 = buff2[i + 2]; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - p05 = buff2[i + 5]; p15 = buff3[i + 5]; - - dd.d64 = *(FTYPE *)(buffi + i); - buff5[i + dx_l ] = (FTYPE)dd.i32s.i0; - buff5[i + dx_l + 1] = (FTYPE)dd.i32s.i1; - - buffd[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - } - - /* - * 3 loop - */ - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - p02 = buff4[0]; - p03 = buff4[1]; - p04 = buff4[2]; - p05 = buff4[3]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = buff4[i + 4]; p05 = buff4[i + 5]; - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]); - d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4]; - - p40 = buff4[i]; p41 = buff4[i + 1]; p42 = buff4[i + 2]; - p43 = buff4[i + 3]; p44 = buff4[i + 4]; - - buff5[i + dx_l] = (FTYPE)sp[0]; - - buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] + - p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] + - p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] + - p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] + - p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]); - - dp[0] = FROM_S32(buffo[i]); - - sp += chan1; - dp += chan1; - } - - for (; i < swid; i++) { - buff5[i + dx_l] = (FTYPE)sp[0]; - sp += chan1; - } - - for (i = 0; i < dx_l; i++) buff5[i] = buff5[dx_l]; - for (i = 0; i < dx_r; i++) buff5[swid + dx_l + i] = buff5[swid + dx_l - 1]; - - /* next line */ - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buff5; - buff5 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#ifndef __sparc /* for x86, using integer multiplies is faster */ - -mlib_status CONV_FUNC_I(5x5) -{ - mlib_s32 buff[BUFF_LINE]; - mlib_s32 *buffd; - mlib_s32 k[KSIZE*KSIZE]; - mlib_s32 shift1, shift2; - mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - mlib_s32 p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15; - DTYPE *adr_src, *sl, *sp0, *sp1, *sp2, *sp3, *sp4; - DTYPE *sp_1, *sp_2, *sp_3, *sp_4; - DTYPE *adr_dst, *dl, *dp; - mlib_s32 *pbuff = buff; - mlib_s32 wid, hgt, sll, dll; - mlib_s32 nchannel, chan1, chan2, chan4; - mlib_s32 delta_chan1, delta_chan2, delta_chan3; - mlib_s32 i, j, c; - -#if IMG_TYPE != 1 - shift1 = 16; -#else - shift1 = 8; -#endif /* IMG_TYPE != 1 */ - - shift2 = scalef_expon - shift1; - - for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1; - - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc(sizeof(mlib_s32)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buffd = pbuff; - - chan1 = nchannel; - chan2 = chan1 + chan1; - - if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan1 = chan1; - else delta_chan1 = 0; - - if ((2 > dx_l) && (2 < wid + KSIZE1 - dx_r)) delta_chan2 = delta_chan1 + chan1; - else delta_chan2 = delta_chan1; - - if ((3 > dx_l) && (3 < wid + KSIZE1 - dx_r)) delta_chan3 = delta_chan2 + chan1; - else delta_chan3 = delta_chan2; - - chan4 = chan1 + delta_chan3; - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sp_1 = sl; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll; - sp_2 = sl; - - if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl += sll; - sp_3 = sl; - - if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl += sll; - sp_4 = sl; - - if ((hgt - dy_b) > 0) sl += sll; - - for (j = 0; j < hgt; j++) { - mlib_s32 pix0, pix1; - - dp = dl; - sp0 = sp_1; - sp_1 = sp_2; - sp_2 = sp_3; - sp_3 = sp_4; - sp_4 = sl; - - sp1 = sp_1; - sp2 = sp_2; - sp3 = sp_3; - sp4 = sp_4; - - /* - * First loop - */ - - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[delta_chan1]; p13 = sp1[delta_chan1]; - p04 = sp0[delta_chan2]; p14 = sp1[delta_chan2]; - p05 = sp0[delta_chan3]; p15 = sp1[delta_chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - dx_r - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - } - - p01 = p02; p02 = p03; p03 = p04; p04 = p05; - p11 = p12; p12 = p13; p13 = p14; p14 = p15; - - for (; i < wid - dx_r; i++) { - p00 = p01; p10 = p11; - p01 = p02; p11 = p12; - p02 = p03; p12 = p13; - p03 = p04; p13 = p14; - - p04 = sp0[0]; p14 = sp1[0]; - - buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - - sp0 += chan1; - sp1 += chan1; - } - - sp0 -= chan1; - sp1 -= chan1; - - for (; i < wid; i++) { - p00 = p01; p10 = p11; - p01 = p02; p11 = p12; - p02 = p03; p12 = p13; - p03 = p04; p13 = p14; - - p04 = sp0[0]; p14 = sp1[0]; - - buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * Second loop - */ - - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - p02 = sp2[0]; p12 = sp3[0]; - p03 = sp2[delta_chan1]; p13 = sp3[delta_chan1]; - p04 = sp2[delta_chan2]; p14 = sp3[delta_chan2]; - p05 = sp2[delta_chan3]; p15 = sp3[delta_chan3]; - - sp2 += chan4; - sp3 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - dx_r - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp2[0]; p14 = sp3[0]; - p05 = sp2[chan1]; p15 = sp3[chan1]; - - buffd[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp2 += chan2; - sp3 += chan2; - } - - p01 = p02; p02 = p03; p03 = p04; p04 = p05; - p11 = p12; p12 = p13; p13 = p14; p14 = p15; - - for (; i < wid - dx_r; i++) { - p00 = p01; p10 = p11; - p01 = p02; p11 = p12; - p02 = p03; p12 = p13; - p03 = p04; p13 = p14; - - p04 = sp2[0]; p14 = sp3[0]; - - buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - - sp2 += chan1; - sp3 += chan1; - } - - sp2 -= chan1; - sp3 -= chan1; - - for (; i < wid; i++) { - p00 = p01; p10 = p11; - p01 = p02; p11 = p12; - p02 = p03; p12 = p13; - p03 = p04; p13 = p14; - - p04 = sp2[0]; p14 = sp3[0]; - - buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * 3 loop - */ - - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - p02 = sp4[0]; - p03 = sp4[delta_chan1]; - p04 = sp4[delta_chan2]; - p05 = sp4[delta_chan3]; - - sp4 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - dx_r - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp4[0]; p05 = sp4[chan1]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 + - p04 * k3 + p05 * k4) >> shift2; - - CLAMP_STORE(dp[0], pix0); - CLAMP_STORE(dp[chan1], pix1); - - dp += chan2; - sp4 += chan2; - } - - p01 = p02; p02 = p03; p03 = p04; p04 = p05; - - for (; i < wid - dx_r; i++) { - p00 = p01; p01 = p02; p02 = p03; p03 = p04; - - p04 = sp4[0]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - CLAMP_STORE(dp[0], pix0); - - dp += chan1; - sp4 += chan1; - } - - sp4 -= chan1; - - for (; i < wid; i++) { - p00 = p01; p01 = p02; p02 = p03; p03 = p04; - - p04 = sp4[0]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - CLAMP_STORE(dp[0], pix0); - - dp += chan1; - } - - /* next line */ - - if (j < hgt - dy_b - 1) sl += sll; - dl += dll; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -#endif /* __sparc ( for x86, using integer multiplies is faster ) */ - -/***************************************************************/ -#if IMG_TYPE == 1 - -#undef KSIZE -#define KSIZE 7 - -mlib_status CONV_FUNC(7x7) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 l, m, buff_ind; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6; - FTYPE p0, p1, p2, p3, p4, p5, p6, p7; - DTYPE *sl2, *sl3, *sl4, *sl5, *sl6; - DEF_VARS(DTYPE); - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + KSIZE1; - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE )*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*swid; - for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l]; - buffd = buffs[KSIZE] + swid; - buffo = (mlib_s32*)(buffd + swid); - buffi = buffo + (swid &~ 1); - - swid -= (dx_l + dx_r); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll; - else sl1 = sl; - - if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll; - else sl2 = sl1; - - if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll; - else sl3 = sl2; - - if ((4 > dy_t) && (4 < hgt + KSIZE1 - dy_b)) sl4 = sl3 + sll; - else sl4 = sl3; - - if ((5 > dy_t) && (5 < hgt + KSIZE1 - dy_b)) sl5 = sl4 + sll; - else sl5 = sl4; - - if ((hgt - dy_b) > 0) sl6 = sl5 + sll; - else sl6 = sl5; - - for (i = 0; i < dx_l; i++) { - buffs[0][i] = (FTYPE)sl[0]; - buffs[1][i] = (FTYPE)sl1[0]; - buffs[2][i] = (FTYPE)sl2[0]; - buffs[3][i] = (FTYPE)sl3[0]; - buffs[4][i] = (FTYPE)sl4[0]; - buffs[5][i] = (FTYPE)sl5[0]; - buffs[6][i] = (FTYPE)sl6[0]; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buffs[0][i + dx_l] = (FTYPE)sl[i*chan1]; - buffs[1][i + dx_l] = (FTYPE)sl1[i*chan1]; - buffs[2][i + dx_l] = (FTYPE)sl2[i*chan1]; - buffs[3][i + dx_l] = (FTYPE)sl3[i*chan1]; - buffs[4][i + dx_l] = (FTYPE)sl4[i*chan1]; - buffs[5][i + dx_l] = (FTYPE)sl5[i*chan1]; - buffs[6][i + dx_l] = (FTYPE)sl6[i*chan1]; - } - - for (i = 0; i < dx_r; i++) { - buffs[0][swid + dx_l + i] = buffs[0][swid + dx_l - 1]; - buffs[1][swid + dx_l + i] = buffs[1][swid + dx_l - 1]; - buffs[2][swid + dx_l + i] = buffs[2][swid + dx_l - 1]; - buffs[3][swid + dx_l + i] = buffs[3][swid + dx_l - 1]; - buffs[4][swid + dx_l + i] = buffs[4][swid + dx_l - 1]; - buffs[5][swid + dx_l + i] = buffs[5][swid + dx_l - 1]; - buffs[6][swid + dx_l + i] = buffs[6][swid + dx_l - 1]; - } - - buff_ind = 0; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid; i++) buffd[i] = 0.0; - - if ((hgt - dy_b) > 1) sl = sl6 + sll; - else sl = sl6; - - for (j = 0; j < hgt; j++) { - FTYPE **buffc = buffs + buff_ind; - FTYPE *buffn = buffc[KSIZE]; - FTYPE *pk = k; - - for (l = 0; l < KSIZE; l++) { - FTYPE *buff = buffc[l]; - d64_2x32 dd; - - sp = sl; - dp = dl; - - p2 = buff[0]; p3 = buff[1]; p4 = buff[2]; - p5 = buff[3]; p6 = buff[4]; p7 = buff[5]; - - k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++; - k4 = *pk++; k5 = *pk++; k6 = *pk++; - - if (l < (KSIZE - 1)) { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - buffd[i ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6; - buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6; - } - - } else { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buffn[i + dx_l ] = (FTYPE)dd.i32s.i0; - buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1; - - d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i ]); - d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - buffd[i ] = 0.0; - buffd[i + 1] = 0.0; - - sp += chan2; - dp += chan2; - } - } - } - - /* last pixels */ - for (; i < wid; i++) { - FTYPE *pk = k, s = 0; - mlib_s32 d0; - - for (l = 0; l < KSIZE; l++) { - FTYPE *buff = buffc[l] + i; - - for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++); - } - - d0 = D2I(s); - dp[0] = FROM_S32(d0); - - buffn[i + dx_l] = (FTYPE)sp[0]; - - sp += chan1; - dp += chan1; - } - - for (; i < swid; i++) { - buffn[i + dx_l] = (FTYPE)sp[0]; - sp += chan1; - } - - for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l]; - for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1]; - - /* next line */ - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buff_ind++; - - if (buff_ind >= KSIZE + 1) buff_ind = 0; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -#endif /* IMG_TYPE == 1 */ - /***************************************************************/ #define MAX_KER 7 #define MAX_N 15 diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c index 0be65cda597..4d0ba0ce493 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_16nw.c @@ -143,9 +143,6 @@ typedef union { } f32s; } d64_2x32; -/***************************************************************/ -#define BUFF_LINE 256 - /***************************************************************/ #define DEF_VARS(type) \ type *adr_src, *sl, *sp = NULL; \ @@ -155,39 +152,6 @@ typedef union { mlib_s32 nchannel, chan1; \ mlib_s32 i, j, c -/***************************************************************/ -#define LOAD_KERNEL3() \ - FTYPE scalef = DSCALE; \ - FTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8; \ - FTYPE p00, p01, p02, p03, \ - p10, p11, p12, p13, \ - p20, p21, p22, p23; \ - \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - /* keep kernel in regs */ \ - k0 = scalef * kern[0]; k1 = scalef * kern[1]; k2 = scalef * kern[2]; \ - k3 = scalef * kern[3]; k4 = scalef * kern[4]; k5 = scalef * kern[5]; \ - k6 = scalef * kern[6]; k7 = scalef * kern[7]; k8 = scalef * kern[8] - -/***************************************************************/ -#define LOAD_KERNEL(SIZE) \ - FTYPE scalef = DSCALE; \ - \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j] - /***************************************************************/ #define GET_SRC_DST_PARAMETERS(type) \ hgt = mlib_ImageGetHeight(src); \ @@ -245,1162 +209,6 @@ typedef union { #endif /* IMG_TYPE == 1 */ #endif /* __sparc */ -/***************************************************************/ -#define KSIZE 3 - -mlib_status CONV_FUNC(3x3)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - FTYPE buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT; - DEF_VARS(DTYPE); - DTYPE *sl1; - mlib_s32 chan2; - mlib_s32 *buffo, *buffi; - DTYPE *sl2; -#ifndef __sparc - mlib_s32 d0, d1; -#endif /* __sparc */ - LOAD_KERNEL3(); - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - buff3 = buff2 + wid; - buffo = (mlib_s32*)(buff3 + wid); - buffi = buffo + (wid &~ 1); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (FTYPE)sl[i*chan1]; - buff1[i] = (FTYPE)sl1[i*chan1]; - buff2[i] = (FTYPE)sl2[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - FTYPE s0, s1; - - p02 = buff0[0]; - p12 = buff1[0]; - p22 = buff2[0]; - - p03 = buff0[1]; - p13 = buff1[1]; - p23 = buff2[1]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp = sl; - dp = dl; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { -#ifdef __sparc -#ifdef _NO_LONGLONG - mlib_s32 o64_1, o64_2; -#else /* _NO_LONGLONG */ - mlib_s64 o64; -#endif /* _NO_LONGLONG */ -#endif /* __sparc */ - d64_2x32 dd; - - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buff3[i ] = (FTYPE)dd.i32s.i0; - buff3[i + 1] = (FTYPE)dd.i32s.i1; - -#ifndef __sparc - d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8); - d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8); - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - -#else /* __sparc */ - - dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8); - dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8); - *(FTYPE *)(buffo + i) = dd.d64; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - -#ifdef _NO_LONGLONG - - o64_1 = buffo[i]; - o64_2 = buffo[i+1]; -#if IMG_TYPE != 1 - STORE2(FROM_S32(o64_1), FROM_S32(o64_2)); -#else - STORE2(o64_1 >> 24, o64_2 >> 24); -#endif /* IMG_TYPE != 1 */ - -#else /* _NO_LONGLONG */ - - o64 = *(mlib_s64*)(buffo + i); -#if IMG_TYPE != 1 - STORE2(FROM_S32(o64 >> 32), FROM_S32(o64)); -#else - STORE2(o64 >> 56, o64 >> 24); -#endif /* IMG_TYPE != 1 */ -#endif /* _NO_LONGLONG */ -#endif /* __sparc */ - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - - buffi[i] = (mlib_s32)sp[0]; - buff3[i] = (FTYPE)buffi[i]; - -#ifndef __sparc - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); - - dp[0] = FROM_S32(d0); - -#else /* __sparc */ - - buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); -#if IMG_TYPE != 1 - dp[0] = FROM_S32(buffo[i]); -#else - dp[0] = buffo[i] >> 24; -#endif /* IMG_TYPE != 1 */ -#endif /* __sparc */ - - sp += chan1; - dp += chan1; - } - - buffi[wid] = (mlib_s32)sp[0]; - buff3[wid] = (FTYPE)buffi[wid]; - buffi[wid + 1] = (mlib_s32)sp[chan1]; - buff3[wid + 1] = (FTYPE)buffi[wid + 1]; - - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buffT; - } - } - -#ifdef __sparc -#if IMG_TYPE == 1 - { - mlib_s32 amask = (1 << nchannel) - 1; - - if ((cmask & amask) != amask) { - mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask); - } else { - mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll); - } - } - -#endif /* IMG_TYPE == 1 */ -#endif /* __sparc */ - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#ifndef __sparc /* for x86, using integer multiplies is faster */ - -mlib_status CONV_FUNC_I(3x3)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - DTYPE *adr_src, *sl, *sp0, *sp1, *sp2; - DTYPE *adr_dst, *dl, *dp; - mlib_s32 wid, hgt, sll, dll; - mlib_s32 nchannel, chan1, chan2; - mlib_s32 i, j, c; - mlib_s32 shift1, shift2; - mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8; - mlib_s32 p02, p03, - p12, p13, - p22, p23; - -#if IMG_TYPE != 1 - shift1 = 16; -#else - shift1 = 8; -#endif /* IMG_TYPE != 1 */ - - shift2 = scalef_expon - shift1; - - /* keep kernel in regs */ - k0 = kern[0] >> shift1; k1 = kern[1] >> shift1; k2 = kern[2] >> shift1; - k3 = kern[3] >> shift1; k4 = kern[4] >> shift1; k5 = kern[5] >> shift1; - k6 = kern[6] >> shift1; k7 = kern[7] >> shift1; k8 = kern[8] >> shift1; - - GET_SRC_DST_PARAMETERS(DTYPE); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - for (j = 0; j < hgt; j++) { - mlib_s32 s0, s1; - mlib_s32 pix0, pix1; - - dp = dl; - sp0 = sl; - sp1 = sp0 + sll; - sp2 = sp1 + sll; - - p02 = sp0[0]; - p12 = sp1[0]; - p22 = sp2[0]; - - p03 = sp0[chan1]; - p13 = sp1[chan1]; - p23 = sp2[chan1]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1]; - - pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2; - pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 + - p13 * k5 + p22 * k7 + p23 * k8) >> shift2; - - CLAMP_STORE(dp[0], pix0); - CLAMP_STORE(dp[chan1], pix1); - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - dp += chan2; - } - - if (wid & 1) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2; - CLAMP_STORE(dp[0], pix0); - } - - sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - -#endif /* __sparc ( for x86, using integer multiplies is faster ) */ - -/***************************************************************/ -#undef KSIZE -#define KSIZE 4 - -mlib_status CONV_FUNC(4x4)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE]; - FTYPE *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6, k7; - FTYPE p00, p01, p02, p03, p04, - p10, p11, p12, p13, p14, - p20, p21, p22, p23, - p30, p31, p32, p33; - DEF_VARS(DTYPE); - DTYPE *sl1; - mlib_s32 chan2; - mlib_s32 *buffo, *buffi; - DTYPE *sl2, *sl3; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - buff3 = buff2 + wid; - buff4 = buff3 + wid; - buffd = buff4 + wid; - buffo = (mlib_s32*)(buffd + wid); - buffi = buffo + (wid &~ 1); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; - sl3 = sl2 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (FTYPE)sl[i*chan1]; - buff1[i] = (FTYPE)sl1[i*chan1]; - buff2[i] = (FTYPE)sl2[i*chan1]; - buff3[i] = (FTYPE)sl3[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - d64_2x32 dd; - - /* - * First loop on two first lines of kernel - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; - k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff1[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buff4[i ] = (FTYPE)dd.i32s.i0; - buff4[i + 1] = (FTYPE)dd.i32s.i1; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7); - - sp += chan2; - dp += chan2; - } - - /* - * Second loop on two last lines of kernel - */ - k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11]; - k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15]; - - sp = sl; - dp = dl; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - p04 = buff2[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]); - d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - sp += chan2; - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - - buff4[i] = (FTYPE)sp[0]; - - buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + - p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] + - p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] + - p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]); - - dp[0] = FROM_S32(buffo[i]); - - sp += chan1; - dp += chan1; - } - - buff4[wid ] = (FTYPE)sp[0]; - buff4[wid + 1] = (FTYPE)sp[chan1]; - buff4[wid + 2] = (FTYPE)sp[chan2]; - - /* next line */ - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 5 - -mlib_status CONV_FUNC(5x5)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE]; - FTYPE *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - FTYPE p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15, - p20, p21, p22, p23, p24, - p30, p31, p32, p33, p34, - p40, p41, p42, p43, p44; - DEF_VARS(DTYPE); - DTYPE *sl1; - mlib_s32 chan2; - mlib_s32 *buffo, *buffi; - DTYPE *sl2, *sl3, *sl4; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - buff3 = buff2 + wid; - buff4 = buff3 + wid; - buff5 = buff4 + wid; - buffd = buff5 + wid; - buffo = (mlib_s32*)(buffd + wid); - buffi = buffo + (wid &~ 1); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; - sl3 = sl2 + sll; - sl4 = sl3 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (FTYPE)sl[i*chan1]; - buff1[i] = (FTYPE)sl1[i*chan1]; - buff2[i] = (FTYPE)sl2[i*chan1]; - buff3[i] = (FTYPE)sl3[i*chan1]; - buff4[i] = (FTYPE)sl4[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - d64_2x32 dd; - - /* - * First loop - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - p14 = buff1[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - - LOAD_BUFF(buffi); - - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - p05 = buff0[i + 5]; p15 = buff1[i + 5]; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp += chan2; - dp += chan2; - } - - /* - * Second loop - */ - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - sp = sl; - dp = dl; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - p04 = buff2[2]; - p14 = buff3[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - - p02 = buff2[i + 2]; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - p05 = buff2[i + 5]; p15 = buff3[i + 5]; - - dd.d64 = *(FTYPE *)(buffi + i); - buff5[i ] = (FTYPE)dd.i32s.i0; - buff5[i + 1] = (FTYPE)dd.i32s.i1; - - buffd[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp += chan2; - dp += chan2; - } - - /* - * 3 loop - */ - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - sp = sl; - dp = dl; - - p02 = buff4[0]; - p03 = buff4[1]; - p04 = buff4[2]; - p05 = buff4[3]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = buff4[i + 4]; p05 = buff4[i + 5]; - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]); - d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - sp += chan2; - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4]; - - p40 = buff4[i]; p41 = buff4[i + 1]; p42 = buff4[i + 2]; - p43 = buff4[i + 3]; p44 = buff4[i + 4]; - - buff5[i] = (FTYPE)sp[0]; - - buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] + - p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] + - p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] + - p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] + - p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]); - - dp[0] = FROM_S32(buffo[i]); - - sp += chan1; - dp += chan1; - } - - buff5[wid ] = (FTYPE)sp[0]; - buff5[wid + 1] = (FTYPE)sp[chan1]; - buff5[wid + 2] = (FTYPE)sp[chan2]; - buff5[wid + 3] = (FTYPE)sp[chan2 + chan1]; - - /* next line */ - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buff5; - buff5 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#ifndef __sparc /* for x86, using integer multiplies is faster */ - -mlib_status CONV_FUNC_I(5x5)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_s32 buff[BUFF_LINE]; - mlib_s32 *buffd; - mlib_s32 k[KSIZE*KSIZE]; - mlib_s32 shift1, shift2; - mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - mlib_s32 p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15; - DTYPE *adr_src, *sl, *sp0, *sp1; - DTYPE *adr_dst, *dl, *dp; - mlib_s32 *pbuff = buff; - mlib_s32 wid, hgt, sll, dll; - mlib_s32 nchannel, chan1, chan2, chan3, chan4; - mlib_s32 i, j, c; - -#if IMG_TYPE != 1 - shift1 = 16; -#else - shift1 = 8; -#endif /* IMG_TYPE != 1 */ - - shift2 = scalef_expon - shift1; - - for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1; - - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc(sizeof(mlib_s32)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buffd = pbuff; - - chan1 = nchannel; - chan2 = chan1 + chan1; - chan3 = chan2 + chan1; - chan4 = chan3 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - for (j = 0; j < hgt; j++) { - mlib_s32 pix0, pix1; - /* - * First loop - */ - sp0 = sl; - sp1 = sp0 + sll; - dp = dl; - - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - p05 = sp0[chan3]; p15 = sp1[chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - - buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * Second loop - */ - sp0 = sl + 2*sll; - sp1 = sp0 + sll; - dp = dl; - - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - p05 = sp0[chan3]; p15 = sp1[chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - buffd[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - - buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * 3 loop - */ - dp = dl; - sp0 = sl + 4*sll; - - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - p02 = sp0[0]; - p03 = sp0[chan1]; - p04 = sp0[chan2]; - p05 = sp0[chan3]; - - sp0 += chan2 + chan2; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp0[0]; p05 = sp0[chan1]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 + - p04 * k3 + p05 * k4) >> shift2; - - CLAMP_STORE(dp[0], pix0); - CLAMP_STORE(dp[chan1], pix1); - - dp += chan2; - sp0 += chan2; - } - - if (wid & 1) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp0[0]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - CLAMP_STORE(dp[0], pix0); - } - - /* next line */ - sl += sll; - dl += dll; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -#endif /* __sparc ( for x86, using integer multiplies is faster ) */ - -/***************************************************************/ -#if IMG_TYPE == 1 - -#undef KSIZE -#define KSIZE 7 - -mlib_status CONV_FUNC(7x7)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 l, m, buff_ind; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6; - FTYPE p0, p1, p2, p3, p4, p5, p6, p7; - DTYPE *sl2, *sl3, *sl4, *sl5, *sl6; - DEF_VARS(DTYPE); - DTYPE *sl1; - mlib_s32 chan2; - mlib_s32 *buffo, *buffi; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*wid; - for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l]; - buffd = buffs[KSIZE] + wid; - buffo = (mlib_s32*)(buffd + wid); - buffi = buffo + (wid &~ 1); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; - sl3 = sl2 + sll; - sl4 = sl3 + sll; - sl5 = sl4 + sll; - sl6 = sl5 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buffs[0][i] = (FTYPE)sl[i*chan1]; - buffs[1][i] = (FTYPE)sl1[i*chan1]; - buffs[2][i] = (FTYPE)sl2[i*chan1]; - buffs[3][i] = (FTYPE)sl3[i*chan1]; - buffs[4][i] = (FTYPE)sl4[i*chan1]; - buffs[5][i] = (FTYPE)sl5[i*chan1]; - buffs[6][i] = (FTYPE)sl6[i*chan1]; - } - - buff_ind = 0; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid; i++) buffd[i] = 0.0; - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - FTYPE **buffc = buffs + buff_ind; - FTYPE *buffn = buffc[KSIZE]; - FTYPE *pk = k; - - for (l = 0; l < KSIZE; l++) { - FTYPE *buff = buffc[l]; - d64_2x32 dd; - - sp = sl; - dp = dl; - - p2 = buff[0]; p3 = buff[1]; p4 = buff[2]; - p5 = buff[3]; p6 = buff[4]; p7 = buff[5]; - - k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++; - k4 = *pk++; k5 = *pk++; k6 = *pk++; - - if (l < (KSIZE - 1)) { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - buffd[i ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6; - buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6; - } - - } else { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buffn[i ] = (FTYPE)dd.i32s.i0; - buffn[i + 1] = (FTYPE)dd.i32s.i1; - - d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i ]); - d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - buffd[i ] = 0.0; - buffd[i + 1] = 0.0; - - sp += chan2; - dp += chan2; - } - } - } - - /* last pixels */ - for (; i < wid; i++) { - FTYPE *pk = k, s = 0; - mlib_s32 d0; - - for (l = 0; l < KSIZE; l++) { - FTYPE *buff = buffc[l] + i; - - for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++); - } - - d0 = D2I(s); - dp[0] = FROM_S32(d0); - - buffn[i] = (FTYPE)sp[0]; - - sp += chan1; - dp += chan1; - } - - for (l = 0; l < (KSIZE - 1); l++) buffn[wid + l] = sp[l*chan1]; - - /* next line */ - sl += sll; - dl += dll; - - buff_ind++; - - if (buff_ind >= KSIZE + 1) buff_ind = 0; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -#endif /* IMG_TYPE == 1 */ - /***************************************************************/ #define MAX_KER 7 #define MAX_N 15 diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c index b0697c831dc..1b5b120f963 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_32nw.c @@ -35,8 +35,6 @@ #include "mlib_ImageConv.h" /***************************************************************/ -#define BUFF_LINE 256 - #define CACHE_SIZE (64*1024) /***************************************************************/ @@ -82,837 +80,6 @@ mlib_d64 *pbuff = buff; \ mlib_s32 i, j, c -/***************************************************************/ -#define CALC_SCALE() \ - scalef = 1.0; \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon) - -/***************************************************************/ -#undef KSIZE -#define KSIZE 2 - -mlib_status CONV_FUNC(2x2)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_d64 buff[(KSIZE + 1)*BUFF_LINE]; - mlib_d64 k0, k1, k2, k3; - mlib_d64 p00, p01, p02, p03, - p10, p11, p12, p13; - mlib_d64 d2; - DEF_VARS(mlib_s32); - mlib_s32 chan2 = chan1 + chan1; - mlib_s32 chan3 = chan1 + chan2; - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 1)*sizeof(mlib_d64)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - /* keep kernel in regs */ - CALC_SCALE(); - k0 = scalef * kern[0]; k1 = scalef * kern[1]; - k2 = scalef * kern[2]; k3 = scalef * kern[3]; - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (mlib_d64)sl[i*chan1]; - buff1[i] = (mlib_d64)sl1[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - p03 = buff0[0]; - p13 = buff1[0]; - - sp = sl; - dp = dl; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 3); i += 3) { - - p00 = p03; p10 = p13; - - p01 = buff0[i + 1]; p11 = buff1[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - - buff2[i ] = (mlib_d64)sp[0]; - buff2[i + 1] = (mlib_d64)sp[chan1]; - buff2[i + 2] = (mlib_d64)sp[chan2]; - - d0 = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3; - d1 = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3; - d2 = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3; - - CLAMP_S32(dp[0 ], d0); - CLAMP_S32(dp[chan1], d1); - CLAMP_S32(dp[chan2], d2); - - sp += chan3; - dp += chan3; - } - - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; - - buff2[i] = (mlib_d64)sp[0]; - - d0 = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3; - CLAMP_S32(dp[0], d0); - - sp += chan1; - dp += chan1; - } - - buff2[wid] = (mlib_d64)sp[0]; - - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 3 - -mlib_status CONV_FUNC(3x3)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_d64 buff[(KSIZE + 1)*BUFF_LINE], *buff3; - mlib_d64 k0, k1, k2, k3, k4, k5, k6, k7, k8; - mlib_d64 p00, p01, p02, p03, - p10, p11, p12, p13, - p20, p21, p22, p23; - mlib_s32 *sl2; - DEF_VARS(mlib_s32); - mlib_s32 chan2 = chan1 + chan1; - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 1)*sizeof(mlib_d64)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - buff3 = buff2 + wid; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - CALC_SCALE(); - k0 = scalef * kern[0]; k1 = scalef * kern[1]; k2 = scalef * kern[2]; - k3 = scalef * kern[3]; k4 = scalef * kern[4]; k5 = scalef * kern[5]; - k6 = scalef * kern[6]; k7 = scalef * kern[7]; k8 = scalef * kern[8]; - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (mlib_d64)sl[i*chan1]; - buff1[i] = (mlib_d64)sl1[i*chan1]; - buff2[i] = (mlib_d64)sl2[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - mlib_d64 s0, s1; - - p02 = buff0[0]; - p12 = buff1[0]; - p22 = buff2[0]; - - p03 = buff0[1]; - p13 = buff1[1]; - p23 = buff2[1]; - - sp = sl; - dp = dl; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; - - buff3[i ] = (mlib_d64)sp[0]; - buff3[i + 1] = (mlib_d64)sp[chan1]; - - d0 = s0 + p02 * k2 + p12 * k5 + p22 * k8; - d1 = s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8; - - CLAMP_S32(dp[0 ], d0); - CLAMP_S32(dp[chan1], d1); - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - - buff3[i] = (mlib_d64)sp[0]; - - d0 = (p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); - - CLAMP_S32(dp[0], d0); - - sp += chan1; - dp += chan1; - } - - buff3[wid ] = (mlib_d64)sp[0]; - buff3[wid + 1] = (mlib_d64)sp[chan1]; - - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 4 - -mlib_status CONV_FUNC(4x4)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_d64 buff[(KSIZE + 2)*BUFF_LINE], *buff3, *buff4, *buff5; - mlib_d64 k[KSIZE*KSIZE]; - mlib_d64 k0, k1, k2, k3, k4, k5, k6, k7; - mlib_d64 p00, p01, p02, p03, p04, - p10, p11, p12, p13, p14, - p20, p21, p22, p23, - p30, p31, p32, p33; - mlib_s32 *sl2, *sl3; - DEF_VARS(mlib_s32); - mlib_s32 chan2 = chan1 + chan1; - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 2)*sizeof(mlib_d64)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - buff3 = buff2 + wid; - buff4 = buff3 + wid; - buff5 = buff4 + wid; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - CALC_SCALE(); - for (j = 0; j < 16; j++) k[j] = scalef * kern[j]; - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; - sl3 = sl2 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (mlib_d64)sl[i*chan1]; - buff1[i] = (mlib_d64)sl1[i*chan1]; - buff2[i] = (mlib_d64)sl2[i*chan1]; - buff3[i] = (mlib_d64)sl3[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - /* - * First loop on two first lines of kernel - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; - k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff1[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - - buff4[i] = (mlib_d64)sp[0]; - buff4[i + 1] = (mlib_d64)sp[chan1]; - - buff5[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - buff5[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7); - - sp += chan2; - dp += chan2; - } - - /* - * Second loop on two last lines of kernel - */ - k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11]; - k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15]; - - sp = sl; - dp = dl; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - p04 = buff2[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - - d0 = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buff5[i]); - d1 = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buff5[i + 1]); - - CLAMP_S32(dp[0 ], d0); - CLAMP_S32(dp[chan1], d1); - - sp += chan2; - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - - buff4[i] = (mlib_d64)sp[0]; - - d0 = (p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + - p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] + - p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] + - p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]); - - CLAMP_S32(dp[0], d0); - - sp += chan1; - dp += chan1; - } - - buff4[wid ] = (mlib_d64)sp[0]; - buff4[wid + 1] = (mlib_d64)sp[chan1]; - buff4[wid + 2] = (mlib_d64)sp[chan2]; - - /* next line */ - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 5 - -mlib_status CONV_FUNC(5x5)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_d64 buff[(KSIZE + 2)*BUFF_LINE], *buff3, *buff4, *buff5, *buff6; - mlib_d64 k[KSIZE*KSIZE]; - mlib_d64 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - mlib_d64 p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15, - p20, p21, p22, p23, p24, - p30, p31, p32, p33, p34, - p40, p41, p42, p43, p44; - mlib_s32 *sl2, *sl3, *sl4; - DEF_VARS(mlib_s32); - mlib_s32 chan2 = chan1 + chan1; - mlib_s32 chan3 = chan1 + chan2; - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 2)*sizeof(mlib_d64)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - buff3 = buff2 + wid; - buff4 = buff3 + wid; - buff5 = buff4 + wid; - buff6 = buff5 + wid; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - CALC_SCALE(); - for (j = 0; j < 25; j++) k[j] = scalef * kern[j]; - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; - sl3 = sl2 + sll; - sl4 = sl3 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (mlib_d64)sl[i*chan1]; - buff1[i] = (mlib_d64)sl1[i*chan1]; - buff2[i] = (mlib_d64)sl2[i*chan1]; - buff3[i] = (mlib_d64)sl3[i*chan1]; - buff4[i] = (mlib_d64)sl4[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - /* - * First loop - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - p14 = buff1[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - p05 = buff0[i + 5]; p15 = buff1[i + 5]; - - buff6[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buff6[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp += chan2; - dp += chan2; - } - - /* - * Second loop - */ - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - sp = sl; - dp = dl; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - - p02 = buff2[i + 2]; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - p05 = buff2[i + 5]; p15 = buff3[i + 5]; - - buff6[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buff6[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp += chan2; - dp += chan2; - } - - /* - * 3 loop - */ - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - sp = sl; - dp = dl; - - p02 = buff4[0]; - p03 = buff4[1]; - p04 = buff4[2]; - p05 = buff4[3]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = buff4[i + 4]; p05 = buff4[i + 5]; - - buff5[i ] = (mlib_d64)sp[0]; - buff5[i + 1] = (mlib_d64)sp[chan1]; - - d0 = p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buff6[i]; - d1 = p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buff6[i + 1]; - - CLAMP_S32(dp[0 ], d0); - CLAMP_S32(dp[chan1], d1); - - sp += chan2; - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4]; - - p40 = buff4[i]; p41 = buff4[i + 1]; p42 = buff4[i + 2]; - p43 = buff4[i + 3]; p44 = buff4[i + 4]; - - buff5[i] = (mlib_d64)sp[0]; - - d0 = (p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] + - p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] + - p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] + - p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] + - p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]); - - CLAMP_S32(dp[0], d0); - - sp += chan1; - dp += chan1; - } - - buff5[wid ] = (mlib_d64)sp[0]; - buff5[wid + 1] = (mlib_d64)sp[chan1]; - buff5[wid + 2] = (mlib_d64)sp[chan2]; - buff5[wid + 3] = (mlib_d64)sp[chan3]; - - /* next line */ - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buff5; - buff5 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 7 - -mlib_status CONV_FUNC(7x7)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_d64 buff[(KSIZE + 2)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd; - mlib_d64 k[KSIZE*KSIZE]; - mlib_d64 k0, k1, k2, k3, k4, k5, k6; - mlib_d64 p0, p1, p2, p3, p4, p5, p6, p7; - mlib_d64 d0, d1; - mlib_s32 l, m, buff_ind, *sl2, *sl3, *sl4, *sl5, *sl6; - mlib_d64 scalef; - DEF_VARS_MxN(mlib_s32); - mlib_s32 chan2 = chan1 + chan1; - mlib_s32 *sl1; - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 2)*sizeof(mlib_d64)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*wid; - for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l]; - buffd = buffs[KSIZE] + wid; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - CALC_SCALE(); - for (j = 0; j < 49; j++) k[j] = scalef * kern[j]; - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; - sl3 = sl2 + sll; - sl4 = sl3 + sll; - sl5 = sl4 + sll; - sl6 = sl5 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buffs[0][i] = (mlib_d64)sl[i*chan1]; - buffs[1][i] = (mlib_d64)sl1[i*chan1]; - buffs[2][i] = (mlib_d64)sl2[i*chan1]; - buffs[3][i] = (mlib_d64)sl3[i*chan1]; - buffs[4][i] = (mlib_d64)sl4[i*chan1]; - buffs[5][i] = (mlib_d64)sl5[i*chan1]; - buffs[6][i] = (mlib_d64)sl6[i*chan1]; - } - - buff_ind = 0; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid; i++) buffd[i] = 0.0; - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - mlib_d64 **buffc = buffs + buff_ind; - mlib_d64 *buffn = buffc[KSIZE]; - mlib_d64 *pk = k; - - for (l = 0; l < KSIZE; l++) { - mlib_d64 *buff = buffc[l]; - - sp = sl; - dp = dl; - - p2 = buff[0]; p3 = buff[1]; p4 = buff[2]; - p5 = buff[3]; p6 = buff[4]; p7 = buff[5]; - - k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++; - k4 = *pk++; k5 = *pk++; k6 = *pk++; - - if (l < (KSIZE - 1)) { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - buffd[i ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6; - buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6; - } - - } else { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - buffn[i ] = (mlib_d64)sp[0]; - buffn[i + 1] = (mlib_d64)sp[chan1]; - - d0 = p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i ]; - d1 = p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]; - - CLAMP_S32(dp[0 ], d0); - CLAMP_S32(dp[chan1], d1); - - buffd[i ] = 0.0; - buffd[i + 1] = 0.0; - - sp += chan2; - dp += chan2; - } - } - } - - /* last pixels */ - for (; i < wid; i++) { - mlib_d64 *pk = k, s = 0; - - for (l = 0; l < KSIZE; l++) { - mlib_d64 *buff = buffc[l] + i; - - for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++); - } - - CLAMP_S32(dp[0], s); - - buffn[i] = (mlib_d64)sp[0]; - - sp += chan1; - dp += chan1; - } - - for (l = 0; l < (KSIZE - 1); l++) buffn[wid + l] = sp[l*chan1]; - - /* next line */ - sl += sll; - dl += dll; - - buff_ind++; - - if (buff_ind >= KSIZE + 1) buff_ind = 0; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - /***************************************************************/ #define FTYPE mlib_d64 #define DTYPE mlib_s32 diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c index c7420a9136b..15799a46d32 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8ext.c @@ -79,9 +79,6 @@ #endif /* IMG_TYPE == 1 */ -/***************************************************************/ -#define KSIZE1 (KSIZE - 1) - /***************************************************************/ #define PARAM \ mlib_image *dst, \ @@ -125,21 +122,6 @@ /***************************************************************/ #define D2I(x) CLAMP_S32((x) SAT_OFF) -/***************************************************************/ -#ifdef _LITTLE_ENDIAN - -#define STORE2(res0, res1) \ - dp[0 ] = res1; \ - dp[chan1] = res0 - -#else - -#define STORE2(res0, res1) \ - dp[0 ] = res0; \ - dp[chan1] = res1 - -#endif /* _LITTLE_ENDIAN */ - /***************************************************************/ #ifdef _NO_LONGLONG @@ -162,9 +144,6 @@ #endif /* _LITTLE_ENDIAN */ #endif /* _NO_LONGLONG */ -/***************************************************************/ -#define MLIB_D2_24 16777216.0f - /***************************************************************/ typedef union { mlib_d64 d64; @@ -174,52 +153,6 @@ typedef union { } i32s; } d64_2x32; -/***************************************************************/ -#define BUFF_LINE 256 - -/***************************************************************/ -#define DEF_VARS(type) \ - type *adr_src, *sl, *sp, *sl1; \ - type *adr_dst, *dl, *dp; \ - FTYPE *pbuff = buff; \ - mlib_s32 *buffi, *buffo; \ - mlib_s32 wid, hgt, sll, dll; \ - mlib_s32 nchannel, chan1, chan2; \ - mlib_s32 i, j, c, swid - -/***************************************************************/ -#define LOAD_KERNEL3() \ - FTYPE scalef = DSCALE; \ - FTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8; \ - FTYPE p00, p01, p02, p03, \ - p10, p11, p12, p13, \ - p20, p21, p22, p23; \ - \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - /* keep kernel in regs */ \ - k0 = scalef * kern[0]; k1 = scalef * kern[1]; k2 = scalef * kern[2]; \ - k3 = scalef * kern[3]; k4 = scalef * kern[4]; k5 = scalef * kern[5]; \ - k6 = scalef * kern[6]; k7 = scalef * kern[7]; k8 = scalef * kern[8] - -/***************************************************************/ -#define LOAD_KERNEL(SIZE) \ - FTYPE scalef = DSCALE; \ - \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j] - /***************************************************************/ #define GET_SRC_DST_PARAMETERS(type) \ hgt = mlib_ImageGetHeight(src); \ @@ -277,1334 +210,6 @@ typedef union { #endif /* IMG_TYPE == 1 */ #endif /* __sparc */ -/***************************************************************/ -#define KSIZE 3 - -mlib_status CONV_FUNC(3x3) -{ - FTYPE buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT; - DEF_VARS(DTYPE); - DTYPE *sl2; -#ifndef __sparc - mlib_s32 d0, d1; -#endif /* __sparc */ - LOAD_KERNEL3(); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + KSIZE1; - - if (swid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE )*swid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + swid; - buff2 = buff1 + swid; - buff3 = buff2 + swid; - buffo = (mlib_s32*)(buff3 + swid); - buffi = buffo + (swid &~ 1); - - swid -= (dx_l + dx_r); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll; - else sl1 = sl; - - if ((hgt - dy_b) > 0) sl2 = sl1 + sll; - else sl2 = sl1; - - for (i = 0; i < dx_l; i++) { - buff0[i] = (FTYPE)sl[0]; - buff1[i] = (FTYPE)sl1[0]; - buff2[i] = (FTYPE)sl2[0]; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buff0[i + dx_l] = (FTYPE)sl[i*chan1]; - buff1[i + dx_l] = (FTYPE)sl1[i*chan1]; - buff2[i + dx_l] = (FTYPE)sl2[i*chan1]; - } - - for (i = 0; i < dx_r; i++) { - buff0[swid + dx_l + i] = buff0[swid + dx_l - 1]; - buff1[swid + dx_l + i] = buff1[swid + dx_l - 1]; - buff2[swid + dx_l + i] = buff2[swid + dx_l - 1]; - } - - if ((hgt - dy_b) > 1) sl = sl2 + sll; - else sl = sl2; - - for (j = 0; j < hgt; j++) { - FTYPE s0, s1; - - p02 = buff0[0]; - p12 = buff1[0]; - p22 = buff2[0]; - - p03 = buff0[1]; - p13 = buff1[1]; - p23 = buff2[1]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp = sl; - dp = dl; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { -#ifdef __sparc -#ifdef _NO_LONGLONG - mlib_s32 o64_1, o64_2; -#else /* _NO_LONGLONG */ - mlib_s64 o64; -#endif /* _NO_LONGLONG */ -#endif /* __sparc */ - d64_2x32 dd; - - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buff3[i + dx_l ] = (FTYPE)dd.i32s.i0; - buff3[i + dx_l + 1] = (FTYPE)dd.i32s.i1; - -#ifndef __sparc - - d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8); - d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8); - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - -#else /* __sparc */ - - dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8); - dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8); - *(FTYPE *)(buffo + i) = dd.d64; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - -#ifdef _NO_LONGLONG - - o64_1 = buffo[i]; - o64_2 = buffo[i+1]; -#if IMG_TYPE != 1 - STORE2(FROM_S32(o64_1), FROM_S32(o64_2)); -#else - STORE2(o64_1 >> 24, o64_2 >> 24); -#endif /* IMG_TYPE != 1 */ - -#else /* _NO_LONGLONG */ - - o64 = *(mlib_s64*)(buffo + i); -#if IMG_TYPE != 1 - STORE2(FROM_S32(o64 >> 32), FROM_S32(o64)); -#else - STORE2(o64 >> 56, o64 >> 24); -#endif /* IMG_TYPE != 1 */ -#endif /* _NO_LONGLONG */ -#endif /* __sparc */ - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - - buffi[i] = (mlib_s32)sp[0]; - buff3[i + dx_l] = (FTYPE)buffi[i]; - -#ifndef __sparc - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); - - dp[0] = FROM_S32(d0); - -#else /* __sparc */ - - buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); -#if IMG_TYPE != 1 - dp[0] = FROM_S32(buffo[i]); -#else - dp[0] = buffo[i] >> 24; -#endif /* IMG_TYPE != 1 */ -#endif /* __sparc */ - - sp += chan1; - dp += chan1; - } - - for (; i < swid; i++) { - buffi[i] = (mlib_s32)sp[0]; - buff3[i + dx_l] = (FTYPE)buffi[i]; - sp += chan1; - } - - for (i = 0; i < dx_l; i++) buff3[i] = buff3[dx_l]; - for (i = 0; i < dx_r; i++) buff3[swid + dx_l + i] = buff3[swid + dx_l - 1]; - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buffT; - } - } - -#ifdef __sparc -#if IMG_TYPE == 1 - { - mlib_s32 amask = (1 << nchannel) - 1; - - if ((cmask & amask) != amask) { - mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask); - } else { - mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll); - } - } - -#endif /* IMG_TYPE == 1 */ -#endif /* __sparc */ - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#ifndef __sparc /* for x86, using integer multiplies is faster */ - -mlib_status CONV_FUNC_I(3x3) -{ - DTYPE *adr_src, *sl, *sp0, *sp1, *sp2, *sp_1, *sp_2; - DTYPE *adr_dst, *dl, *dp; - mlib_s32 wid, hgt, sll, dll; - mlib_s32 nchannel, chan1, chan2, delta_chan; - mlib_s32 i, j, c; - mlib_s32 shift1, shift2; - mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8; - mlib_s32 p02, p03, - p12, p13, - p22, p23; - -#if IMG_TYPE != 1 - shift1 = 16; -#else - shift1 = 8; -#endif /* IMG_TYPE != 1 */ - - shift2 = scalef_expon - shift1; - - /* keep kernel in regs */ - k0 = kern[0] >> shift1; k1 = kern[1] >> shift1; k2 = kern[2] >> shift1; - k3 = kern[3] >> shift1; k4 = kern[4] >> shift1; k5 = kern[5] >> shift1; - k6 = kern[6] >> shift1; k7 = kern[7] >> shift1; k8 = kern[8] >> shift1; - - GET_SRC_DST_PARAMETERS(DTYPE); - - chan1 = nchannel; - chan2 = chan1 + chan1; - delta_chan = 0; - - if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan = chan1; - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sp_1 = sl; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll; - sp_2 = sl; - - if ((hgt - dy_b) > 0) sl += sll; - - for (j = 0; j < hgt; j++) { - mlib_s32 s0, s1; - mlib_s32 pix0, pix1; - - dp = dl; - sp0 = sp_1; - sp_1 = sp_2; - sp_2 = sl; - - sp1 = sp_1; - sp2 = sp_2; - - p02 = sp0[0]; - p12 = sp1[0]; - p22 = sp2[0]; - - p03 = sp0[delta_chan]; - p13 = sp1[delta_chan]; - p23 = sp2[delta_chan]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += (chan1 + delta_chan); - sp1 += (chan1 + delta_chan); - sp2 += (chan1 + delta_chan); - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - dx_r - 2); i += 2) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1]; - - pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2; - pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 + - p13 * k5 + p22 * k7 + p23 * k8) >> shift2; - - CLAMP_STORE(dp[0], pix0) - CLAMP_STORE(dp[chan1], pix1) - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - dp += chan2; - } - - p02 = p03; p12 = p13; p22 = p23; - - for (; i < wid - dx_r; i++) { - p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0]; - pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2; - CLAMP_STORE(dp[0], pix0) - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - p02 = p03; p12 = p13; p22 = p23; - sp0 += chan1; - sp1 += chan1; - sp2 += chan1; - dp += chan1; - } - - sp0 -= chan1; - sp1 -= chan1; - sp2 -= chan1; - - for (; i < wid; i++) { - p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0]; - pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2; - CLAMP_STORE(dp[0], pix0) - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - p02 = p03; p12 = p13; p22 = p23; - dp += chan1; - } - - if (j < hgt - dy_b - 1) sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - -#endif /* __sparc ( for x86, using integer multiplies is faster ) */ - -/***************************************************************/ -#undef KSIZE -#define KSIZE 4 - -mlib_status CONV_FUNC(4x4) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE]; - FTYPE *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6, k7; - FTYPE p00, p01, p02, p03, p04, - p10, p11, p12, p13, p14, - p20, p21, p22, p23, - p30, p31, p32, p33; - DEF_VARS(DTYPE); - DTYPE *sl2, *sl3; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + KSIZE1; - - if (swid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE )*swid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + swid; - buff2 = buff1 + swid; - buff3 = buff2 + swid; - buff4 = buff3 + swid; - buffd = buff4 + swid; - buffo = (mlib_s32*)(buffd + swid); - buffi = buffo + (swid &~ 1); - - swid -= (dx_l + dx_r); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll; - else sl1 = sl; - - if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll; - else sl2 = sl1; - - if ((hgt - dy_b) > 0) sl3 = sl2 + sll; - else sl3 = sl2; - - for (i = 0; i < dx_l; i++) { - buff0[i] = (FTYPE)sl[0]; - buff1[i] = (FTYPE)sl1[0]; - buff2[i] = (FTYPE)sl2[0]; - buff3[i] = (FTYPE)sl3[0]; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buff0[i + dx_l] = (FTYPE)sl[i*chan1]; - buff1[i + dx_l] = (FTYPE)sl1[i*chan1]; - buff2[i + dx_l] = (FTYPE)sl2[i*chan1]; - buff3[i + dx_l] = (FTYPE)sl3[i*chan1]; - } - - for (i = 0; i < dx_r; i++) { - buff0[swid + dx_l + i] = buff0[swid + dx_l - 1]; - buff1[swid + dx_l + i] = buff1[swid + dx_l - 1]; - buff2[swid + dx_l + i] = buff2[swid + dx_l - 1]; - buff3[swid + dx_l + i] = buff3[swid + dx_l - 1]; - } - - if ((hgt - dy_b) > 1) sl = sl3 + sll; - else sl = sl3; - - for (j = 0; j < hgt; j++) { - d64_2x32 dd; - - /* - * First loop on two first lines of kernel - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; - k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff1[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buff4[i + dx_l ] = (FTYPE)dd.i32s.i0; - buff4[i + dx_l + 1] = (FTYPE)dd.i32s.i1; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7); - - sp += chan2; - } - - /* - * Second loop on two last lines of kernel - */ - k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11]; - k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15]; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - p04 = buff2[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]); - d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - - buff4[i + dx_l] = (FTYPE)sp[0]; - - buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + - p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] + - p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] + - p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]); - - dp[0] = FROM_S32(buffo[i]); - - sp += chan1; - dp += chan1; - } - - for (; i < swid; i++) { - buff4[i + dx_l] = (FTYPE)sp[0]; - sp += chan1; - } - - for (i = 0; i < dx_l; i++) buff4[i] = buff4[dx_l]; - for (i = 0; i < dx_r; i++) buff4[swid + dx_l + i] = buff4[swid + dx_l - 1]; - - /* next line */ - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 5 - -mlib_status CONV_FUNC(5x5) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE]; - FTYPE *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - FTYPE p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15, - p20, p21, p22, p23, p24, - p30, p31, p32, p33, p34, - p40, p41, p42, p43, p44; - DEF_VARS(DTYPE); - DTYPE *sl2, *sl3, *sl4; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + KSIZE1; - - if (swid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE )*swid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + swid; - buff2 = buff1 + swid; - buff3 = buff2 + swid; - buff4 = buff3 + swid; - buff5 = buff4 + swid; - buffd = buff5 + swid; - buffo = (mlib_s32*)(buffd + swid); - buffi = buffo + (swid &~ 1); - - swid -= (dx_l + dx_r); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll; - else sl1 = sl; - - if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll; - else sl2 = sl1; - - if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll; - else sl3 = sl2; - - if ((hgt - dy_b) > 0) sl4 = sl3 + sll; - else sl4 = sl3; - - for (i = 0; i < dx_l; i++) { - buff0[i] = (FTYPE)sl[0]; - buff1[i] = (FTYPE)sl1[0]; - buff2[i] = (FTYPE)sl2[0]; - buff3[i] = (FTYPE)sl3[0]; - buff4[i] = (FTYPE)sl4[0]; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buff0[i + dx_l] = (FTYPE)sl[i*chan1]; - buff1[i + dx_l] = (FTYPE)sl1[i*chan1]; - buff2[i + dx_l] = (FTYPE)sl2[i*chan1]; - buff3[i + dx_l] = (FTYPE)sl3[i*chan1]; - buff4[i + dx_l] = (FTYPE)sl4[i*chan1]; - } - - for (i = 0; i < dx_r; i++) { - buff0[swid + dx_l + i] = buff0[swid + dx_l - 1]; - buff1[swid + dx_l + i] = buff1[swid + dx_l - 1]; - buff2[swid + dx_l + i] = buff2[swid + dx_l - 1]; - buff3[swid + dx_l + i] = buff3[swid + dx_l - 1]; - buff4[swid + dx_l + i] = buff4[swid + dx_l - 1]; - } - - if ((hgt - dy_b) > 1) sl = sl4 + sll; - else sl = sl4; - - for (j = 0; j < hgt; j++) { - d64_2x32 dd; - - /* - * First loop - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - p14 = buff1[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - - LOAD_BUFF(buffi); - - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - p05 = buff0[i + 5]; p15 = buff1[i + 5]; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp += chan2; - } - - /* - * Second loop - */ - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - - p02 = buff2[i + 2]; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - p05 = buff2[i + 5]; p15 = buff3[i + 5]; - - dd.d64 = *(FTYPE *)(buffi + i); - buff5[i + dx_l ] = (FTYPE)dd.i32s.i0; - buff5[i + dx_l + 1] = (FTYPE)dd.i32s.i1; - - buffd[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - } - - /* - * 3 loop - */ - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - p02 = buff4[0]; - p03 = buff4[1]; - p04 = buff4[2]; - p05 = buff4[3]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = buff4[i + 4]; p05 = buff4[i + 5]; - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]); - d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4]; - - p40 = buff4[i]; p41 = buff4[i + 1]; p42 = buff4[i + 2]; - p43 = buff4[i + 3]; p44 = buff4[i + 4]; - - buff5[i + dx_l] = (FTYPE)sp[0]; - - buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] + - p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] + - p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] + - p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] + - p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]); - - dp[0] = FROM_S32(buffo[i]); - - sp += chan1; - dp += chan1; - } - - for (; i < swid; i++) { - buff5[i + dx_l] = (FTYPE)sp[0]; - sp += chan1; - } - - for (i = 0; i < dx_l; i++) buff5[i] = buff5[dx_l]; - for (i = 0; i < dx_r; i++) buff5[swid + dx_l + i] = buff5[swid + dx_l - 1]; - - /* next line */ - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buff5; - buff5 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#ifndef __sparc /* for x86, using integer multiplies is faster */ - -mlib_status CONV_FUNC_I(5x5) -{ - mlib_s32 buff[BUFF_LINE]; - mlib_s32 *buffd; - mlib_s32 k[KSIZE*KSIZE]; - mlib_s32 shift1, shift2; - mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - mlib_s32 p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15; - DTYPE *adr_src, *sl, *sp0, *sp1, *sp2, *sp3, *sp4; - DTYPE *sp_1, *sp_2, *sp_3, *sp_4; - DTYPE *adr_dst, *dl, *dp; - mlib_s32 *pbuff = buff; - mlib_s32 wid, hgt, sll, dll; - mlib_s32 nchannel, chan1, chan2, chan4; - mlib_s32 delta_chan1, delta_chan2, delta_chan3; - mlib_s32 i, j, c; - -#if IMG_TYPE != 1 - shift1 = 16; -#else - shift1 = 8; -#endif /* IMG_TYPE != 1 */ - - shift2 = scalef_expon - shift1; - - for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1; - - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc(sizeof(mlib_s32)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buffd = pbuff; - - chan1 = nchannel; - chan2 = chan1 + chan1; - - if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan1 = chan1; - else delta_chan1 = 0; - - if ((2 > dx_l) && (2 < wid + KSIZE1 - dx_r)) delta_chan2 = delta_chan1 + chan1; - else delta_chan2 = delta_chan1; - - if ((3 > dx_l) && (3 < wid + KSIZE1 - dx_r)) delta_chan3 = delta_chan2 + chan1; - else delta_chan3 = delta_chan2; - - chan4 = chan1 + delta_chan3; - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sp_1 = sl; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll; - sp_2 = sl; - - if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl += sll; - sp_3 = sl; - - if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl += sll; - sp_4 = sl; - - if ((hgt - dy_b) > 0) sl += sll; - - for (j = 0; j < hgt; j++) { - mlib_s32 pix0, pix1; - - dp = dl; - sp0 = sp_1; - sp_1 = sp_2; - sp_2 = sp_3; - sp_3 = sp_4; - sp_4 = sl; - - sp1 = sp_1; - sp2 = sp_2; - sp3 = sp_3; - sp4 = sp_4; - - /* - * First loop - */ - - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[delta_chan1]; p13 = sp1[delta_chan1]; - p04 = sp0[delta_chan2]; p14 = sp1[delta_chan2]; - p05 = sp0[delta_chan3]; p15 = sp1[delta_chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - dx_r - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - } - - p01 = p02; p02 = p03; p03 = p04; p04 = p05; - p11 = p12; p12 = p13; p13 = p14; p14 = p15; - - for (; i < wid - dx_r; i++) { - p00 = p01; p10 = p11; - p01 = p02; p11 = p12; - p02 = p03; p12 = p13; - p03 = p04; p13 = p14; - - p04 = sp0[0]; p14 = sp1[0]; - - buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - - sp0 += chan1; - sp1 += chan1; - } - - sp0 -= chan1; - sp1 -= chan1; - - for (; i < wid; i++) { - p00 = p01; p10 = p11; - p01 = p02; p11 = p12; - p02 = p03; p12 = p13; - p03 = p04; p13 = p14; - - p04 = sp0[0]; p14 = sp1[0]; - - buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * Second loop - */ - - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - p02 = sp2[0]; p12 = sp3[0]; - p03 = sp2[delta_chan1]; p13 = sp3[delta_chan1]; - p04 = sp2[delta_chan2]; p14 = sp3[delta_chan2]; - p05 = sp2[delta_chan3]; p15 = sp3[delta_chan3]; - - sp2 += chan4; - sp3 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - dx_r - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp2[0]; p14 = sp3[0]; - p05 = sp2[chan1]; p15 = sp3[chan1]; - - buffd[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp2 += chan2; - sp3 += chan2; - } - - p01 = p02; p02 = p03; p03 = p04; p04 = p05; - p11 = p12; p12 = p13; p13 = p14; p14 = p15; - - for (; i < wid - dx_r; i++) { - p00 = p01; p10 = p11; - p01 = p02; p11 = p12; - p02 = p03; p12 = p13; - p03 = p04; p13 = p14; - - p04 = sp2[0]; p14 = sp3[0]; - - buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - - sp2 += chan1; - sp3 += chan1; - } - - sp2 -= chan1; - sp3 -= chan1; - - for (; i < wid; i++) { - p00 = p01; p10 = p11; - p01 = p02; p11 = p12; - p02 = p03; p12 = p13; - p03 = p04; p13 = p14; - - p04 = sp2[0]; p14 = sp3[0]; - - buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * 3 loop - */ - - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - p02 = sp4[0]; - p03 = sp4[delta_chan1]; - p04 = sp4[delta_chan2]; - p05 = sp4[delta_chan3]; - - sp4 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - dx_r - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp4[0]; p05 = sp4[chan1]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 + - p04 * k3 + p05 * k4) >> shift2; - - CLAMP_STORE(dp[0], pix0) - CLAMP_STORE(dp[chan1], pix1) - - dp += chan2; - sp4 += chan2; - } - - p01 = p02; p02 = p03; p03 = p04; p04 = p05; - - for (; i < wid - dx_r; i++) { - p00 = p01; p01 = p02; p02 = p03; p03 = p04; - - p04 = sp4[0]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - CLAMP_STORE(dp[0], pix0) - - dp += chan1; - sp4 += chan1; - } - - sp4 -= chan1; - - for (; i < wid; i++) { - p00 = p01; p01 = p02; p02 = p03; p03 = p04; - - p04 = sp4[0]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - CLAMP_STORE(dp[0], pix0) - - dp += chan1; - } - - /* next line */ - - if (j < hgt - dy_b - 1) sl += sll; - dl += dll; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -#endif /* __sparc ( for x86, using integer multiplies is faster ) */ - -/***************************************************************/ -#if IMG_TYPE == 1 - -#undef KSIZE -#define KSIZE 7 - -mlib_status CONV_FUNC(7x7) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 l, m, buff_ind; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6; - FTYPE p0, p1, p2, p3, p4, p5, p6, p7; - DTYPE *sl2, *sl3, *sl4, *sl5, *sl6; - DEF_VARS(DTYPE); - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + KSIZE1; - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE )*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*swid; - for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l]; - buffd = buffs[KSIZE] + swid; - buffo = (mlib_s32*)(buffd + swid); - buffi = buffo + (swid &~ 1); - - swid -= (dx_l + dx_r); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll; - else sl1 = sl; - - if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll; - else sl2 = sl1; - - if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll; - else sl3 = sl2; - - if ((4 > dy_t) && (4 < hgt + KSIZE1 - dy_b)) sl4 = sl3 + sll; - else sl4 = sl3; - - if ((5 > dy_t) && (5 < hgt + KSIZE1 - dy_b)) sl5 = sl4 + sll; - else sl5 = sl4; - - if ((hgt - dy_b) > 0) sl6 = sl5 + sll; - else sl6 = sl5; - - for (i = 0; i < dx_l; i++) { - buffs[0][i] = (FTYPE)sl[0]; - buffs[1][i] = (FTYPE)sl1[0]; - buffs[2][i] = (FTYPE)sl2[0]; - buffs[3][i] = (FTYPE)sl3[0]; - buffs[4][i] = (FTYPE)sl4[0]; - buffs[5][i] = (FTYPE)sl5[0]; - buffs[6][i] = (FTYPE)sl6[0]; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buffs[0][i + dx_l] = (FTYPE)sl[i*chan1]; - buffs[1][i + dx_l] = (FTYPE)sl1[i*chan1]; - buffs[2][i + dx_l] = (FTYPE)sl2[i*chan1]; - buffs[3][i + dx_l] = (FTYPE)sl3[i*chan1]; - buffs[4][i + dx_l] = (FTYPE)sl4[i*chan1]; - buffs[5][i + dx_l] = (FTYPE)sl5[i*chan1]; - buffs[6][i + dx_l] = (FTYPE)sl6[i*chan1]; - } - - for (i = 0; i < dx_r; i++) { - buffs[0][swid + dx_l + i] = buffs[0][swid + dx_l - 1]; - buffs[1][swid + dx_l + i] = buffs[1][swid + dx_l - 1]; - buffs[2][swid + dx_l + i] = buffs[2][swid + dx_l - 1]; - buffs[3][swid + dx_l + i] = buffs[3][swid + dx_l - 1]; - buffs[4][swid + dx_l + i] = buffs[4][swid + dx_l - 1]; - buffs[5][swid + dx_l + i] = buffs[5][swid + dx_l - 1]; - buffs[6][swid + dx_l + i] = buffs[6][swid + dx_l - 1]; - } - - buff_ind = 0; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid; i++) buffd[i] = 0.0; - - if ((hgt - dy_b) > 1) sl = sl6 + sll; - else sl = sl6; - - for (j = 0; j < hgt; j++) { - FTYPE **buffc = buffs + buff_ind; - FTYPE *buffn = buffc[KSIZE]; - FTYPE *pk = k; - - for (l = 0; l < KSIZE; l++) { - FTYPE *buff = buffc[l]; - d64_2x32 dd; - - sp = sl; - dp = dl; - - p2 = buff[0]; p3 = buff[1]; p4 = buff[2]; - p5 = buff[3]; p6 = buff[4]; p7 = buff[5]; - - k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++; - k4 = *pk++; k5 = *pk++; k6 = *pk++; - - if (l < (KSIZE - 1)) { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - buffd[i ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6; - buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6; - } - - } else { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buffn[i + dx_l ] = (FTYPE)dd.i32s.i0; - buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1; - - d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i ]); - d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - buffd[i ] = 0.0; - buffd[i + 1] = 0.0; - - sp += chan2; - dp += chan2; - } - } - } - - /* last pixels */ - for (; i < wid; i++) { - FTYPE *pk = k, s = 0; - mlib_s32 d0; - - for (l = 0; l < KSIZE; l++) { - FTYPE *buff = buffc[l] + i; - - for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++); - } - - d0 = D2I(s); - dp[0] = FROM_S32(d0); - - buffn[i + dx_l] = (FTYPE)sp[0]; - - sp += chan1; - dp += chan1; - } - - for (; i < swid; i++) { - buffn[i + dx_l] = (FTYPE)sp[0]; - sp += chan1; - } - - for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l]; - for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1]; - - /* next line */ - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buff_ind++; - - if (buff_ind >= KSIZE + 1) buff_ind = 0; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -#endif /* IMG_TYPE == 1 */ - /***************************************************************/ #define MAX_KER 7 #define MAX_N 15 diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c index c81dbd08a35..4cdba6d1fa5 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_8nw.c @@ -144,9 +144,6 @@ typedef union { } f32s; } d64_2x32; -/***************************************************************/ -#define BUFF_LINE 256 - /***************************************************************/ #define DEF_VARS(type) \ type *adr_src, *sl, *sp = NULL; \ @@ -156,39 +153,6 @@ typedef union { mlib_s32 nchannel, chan1; \ mlib_s32 i, j, c -/***************************************************************/ -#define LOAD_KERNEL3() \ - FTYPE scalef = DSCALE; \ - FTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8; \ - FTYPE p00, p01, p02, p03, \ - p10, p11, p12, p13, \ - p20, p21, p22, p23; \ - \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - /* keep kernel in regs */ \ - k0 = scalef * kern[0]; k1 = scalef * kern[1]; k2 = scalef * kern[2]; \ - k3 = scalef * kern[3]; k4 = scalef * kern[4]; k5 = scalef * kern[5]; \ - k6 = scalef * kern[6]; k7 = scalef * kern[7]; k8 = scalef * kern[8] - -/***************************************************************/ -#define LOAD_KERNEL(SIZE) \ - FTYPE scalef = DSCALE; \ - \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j] - /***************************************************************/ #define GET_SRC_DST_PARAMETERS(type) \ hgt = mlib_ImageGetHeight(src); \ @@ -246,1162 +210,6 @@ typedef union { #endif /* IMG_TYPE == 1 */ #endif /* __sparc */ -/***************************************************************/ -#define KSIZE 3 - -mlib_status CONV_FUNC(3x3)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - FTYPE buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT; - DEF_VARS(DTYPE); - DTYPE *sl1; - mlib_s32 chan2; - mlib_s32 *buffo, *buffi; - DTYPE *sl2; -#ifndef __sparc - mlib_s32 d0, d1; -#endif /* __sparc */ - LOAD_KERNEL3(); - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - buff3 = buff2 + wid; - buffo = (mlib_s32*)(buff3 + wid); - buffi = buffo + (wid &~ 1); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (FTYPE)sl[i*chan1]; - buff1[i] = (FTYPE)sl1[i*chan1]; - buff2[i] = (FTYPE)sl2[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - FTYPE s0, s1; - - p02 = buff0[0]; - p12 = buff1[0]; - p22 = buff2[0]; - - p03 = buff0[1]; - p13 = buff1[1]; - p23 = buff2[1]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp = sl; - dp = dl; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { -#ifdef __sparc -#ifdef _NO_LONGLONG - mlib_s32 o64_1, o64_2; -#else /* _NO_LONGLONG */ - mlib_s64 o64; -#endif /* _NO_LONGLONG */ -#endif /* __sparc */ - d64_2x32 dd; - - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buff3[i ] = (FTYPE)dd.i32s.i0; - buff3[i + 1] = (FTYPE)dd.i32s.i1; - -#ifndef __sparc - d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8); - d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8); - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - -#else /* __sparc */ - - dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8); - dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8); - *(FTYPE *)(buffo + i) = dd.d64; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - -#ifdef _NO_LONGLONG - - o64_1 = buffo[i]; - o64_2 = buffo[i+1]; -#if IMG_TYPE != 1 - STORE2(FROM_S32(o64_1), FROM_S32(o64_2)); -#else - STORE2(o64_1 >> 24, o64_2 >> 24); -#endif /* IMG_TYPE != 1 */ - -#else /* _NO_LONGLONG */ - - o64 = *(mlib_s64*)(buffo + i); -#if IMG_TYPE != 1 - STORE2(FROM_S32(o64 >> 32), FROM_S32(o64)); -#else - STORE2(o64 >> 56, o64 >> 24); -#endif /* IMG_TYPE != 1 */ -#endif /* _NO_LONGLONG */ -#endif /* __sparc */ - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - - buffi[i] = (mlib_s32)sp[0]; - buff3[i] = (FTYPE)buffi[i]; - -#ifndef __sparc - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); - - dp[0] = FROM_S32(d0); - -#else /* __sparc */ - - buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); -#if IMG_TYPE != 1 - dp[0] = FROM_S32(buffo[i]); -#else - dp[0] = buffo[i] >> 24; -#endif /* IMG_TYPE != 1 */ -#endif /* __sparc */ - - sp += chan1; - dp += chan1; - } - - buffi[wid] = (mlib_s32)sp[0]; - buff3[wid] = (FTYPE)buffi[wid]; - buffi[wid + 1] = (mlib_s32)sp[chan1]; - buff3[wid + 1] = (FTYPE)buffi[wid + 1]; - - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buffT; - } - } - -#ifdef __sparc -#if IMG_TYPE == 1 - { - mlib_s32 amask = (1 << nchannel) - 1; - - if ((cmask & amask) != amask) { - mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask); - } else { - mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll); - } - } - -#endif /* IMG_TYPE == 1 */ -#endif /* __sparc */ - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#ifndef __sparc /* for x86, using integer multiplies is faster */ - -mlib_status CONV_FUNC_I(3x3)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - DTYPE *adr_src, *sl, *sp0, *sp1, *sp2; - DTYPE *adr_dst, *dl, *dp; - mlib_s32 wid, hgt, sll, dll; - mlib_s32 nchannel, chan1, chan2; - mlib_s32 i, j, c; - mlib_s32 shift1, shift2; - mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8; - mlib_s32 p02, p03, - p12, p13, - p22, p23; - -#if IMG_TYPE != 1 - shift1 = 16; -#else - shift1 = 8; -#endif /* IMG_TYPE != 1 */ - - shift2 = scalef_expon - shift1; - - /* keep kernel in regs */ - k0 = kern[0] >> shift1; k1 = kern[1] >> shift1; k2 = kern[2] >> shift1; - k3 = kern[3] >> shift1; k4 = kern[4] >> shift1; k5 = kern[5] >> shift1; - k6 = kern[6] >> shift1; k7 = kern[7] >> shift1; k8 = kern[8] >> shift1; - - GET_SRC_DST_PARAMETERS(DTYPE); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - for (j = 0; j < hgt; j++) { - mlib_s32 s0, s1; - mlib_s32 pix0, pix1; - - dp = dl; - sp0 = sl; - sp1 = sp0 + sll; - sp2 = sp1 + sll; - - p02 = sp0[0]; - p12 = sp1[0]; - p22 = sp2[0]; - - p03 = sp0[chan1]; - p13 = sp1[chan1]; - p23 = sp2[chan1]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1]; - - pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2; - pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 + - p13 * k5 + p22 * k7 + p23 * k8) >> shift2; - - CLAMP_STORE(dp[0], pix0) - CLAMP_STORE(dp[chan1], pix1) - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - dp += chan2; - } - - if (wid & 1) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2; - CLAMP_STORE(dp[0], pix0) - } - - sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - -#endif /* __sparc ( for x86, using integer multiplies is faster ) */ - -/***************************************************************/ -#undef KSIZE -#define KSIZE 4 - -mlib_status CONV_FUNC(4x4)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE]; - FTYPE *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6, k7; - FTYPE p00, p01, p02, p03, p04, - p10, p11, p12, p13, p14, - p20, p21, p22, p23, - p30, p31, p32, p33; - DEF_VARS(DTYPE); - DTYPE *sl1; - mlib_s32 chan2; - mlib_s32 *buffo, *buffi; - DTYPE *sl2, *sl3; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - buff3 = buff2 + wid; - buff4 = buff3 + wid; - buffd = buff4 + wid; - buffo = (mlib_s32*)(buffd + wid); - buffi = buffo + (wid &~ 1); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; - sl3 = sl2 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (FTYPE)sl[i*chan1]; - buff1[i] = (FTYPE)sl1[i*chan1]; - buff2[i] = (FTYPE)sl2[i*chan1]; - buff3[i] = (FTYPE)sl3[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - d64_2x32 dd; - - /* - * First loop on two first lines of kernel - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; - k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff1[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buff4[i ] = (FTYPE)dd.i32s.i0; - buff4[i + 1] = (FTYPE)dd.i32s.i1; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7); - - sp += chan2; - dp += chan2; - } - - /* - * Second loop on two last lines of kernel - */ - k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11]; - k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15]; - - sp = sl; - dp = dl; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - p04 = buff2[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]); - d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - sp += chan2; - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - - buff4[i] = (FTYPE)sp[0]; - - buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + - p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] + - p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] + - p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]); - - dp[0] = FROM_S32(buffo[i]); - - sp += chan1; - dp += chan1; - } - - buff4[wid ] = (FTYPE)sp[0]; - buff4[wid + 1] = (FTYPE)sp[chan1]; - buff4[wid + 2] = (FTYPE)sp[chan2]; - - /* next line */ - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 5 - -mlib_status CONV_FUNC(5x5)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE]; - FTYPE *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - FTYPE p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15, - p20, p21, p22, p23, p24, - p30, p31, p32, p33, p34, - p40, p41, p42, p43, p44; - DEF_VARS(DTYPE); - DTYPE *sl1; - mlib_s32 chan2; - mlib_s32 *buffo, *buffi; - DTYPE *sl2, *sl3, *sl4; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - buff3 = buff2 + wid; - buff4 = buff3 + wid; - buff5 = buff4 + wid; - buffd = buff5 + wid; - buffo = (mlib_s32*)(buffd + wid); - buffi = buffo + (wid &~ 1); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; - sl3 = sl2 + sll; - sl4 = sl3 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (FTYPE)sl[i*chan1]; - buff1[i] = (FTYPE)sl1[i*chan1]; - buff2[i] = (FTYPE)sl2[i*chan1]; - buff3[i] = (FTYPE)sl3[i*chan1]; - buff4[i] = (FTYPE)sl4[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - d64_2x32 dd; - - /* - * First loop - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - p14 = buff1[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - - LOAD_BUFF(buffi); - - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - p05 = buff0[i + 5]; p15 = buff1[i + 5]; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp += chan2; - dp += chan2; - } - - /* - * Second loop - */ - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - sp = sl; - dp = dl; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - p04 = buff2[2]; - p14 = buff3[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - - p02 = buff2[i + 2]; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - p05 = buff2[i + 5]; p15 = buff3[i + 5]; - - dd.d64 = *(FTYPE *)(buffi + i); - buff5[i ] = (FTYPE)dd.i32s.i0; - buff5[i + 1] = (FTYPE)dd.i32s.i1; - - buffd[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp += chan2; - dp += chan2; - } - - /* - * 3 loop - */ - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - sp = sl; - dp = dl; - - p02 = buff4[0]; - p03 = buff4[1]; - p04 = buff4[2]; - p05 = buff4[3]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = buff4[i + 4]; p05 = buff4[i + 5]; - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]); - d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - sp += chan2; - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4]; - - p40 = buff4[i]; p41 = buff4[i + 1]; p42 = buff4[i + 2]; - p43 = buff4[i + 3]; p44 = buff4[i + 4]; - - buff5[i] = (FTYPE)sp[0]; - - buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] + - p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] + - p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] + - p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] + - p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]); - - dp[0] = FROM_S32(buffo[i]); - - sp += chan1; - dp += chan1; - } - - buff5[wid ] = (FTYPE)sp[0]; - buff5[wid + 1] = (FTYPE)sp[chan1]; - buff5[wid + 2] = (FTYPE)sp[chan2]; - buff5[wid + 3] = (FTYPE)sp[chan2 + chan1]; - - /* next line */ - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buff5; - buff5 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#ifndef __sparc /* for x86, using integer multiplies is faster */ - -mlib_status CONV_FUNC_I(5x5)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_s32 buff[BUFF_LINE]; - mlib_s32 *buffd; - mlib_s32 k[KSIZE*KSIZE]; - mlib_s32 shift1, shift2; - mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - mlib_s32 p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15; - DTYPE *adr_src, *sl, *sp0, *sp1; - DTYPE *adr_dst, *dl, *dp; - mlib_s32 *pbuff = buff; - mlib_s32 wid, hgt, sll, dll; - mlib_s32 nchannel, chan1, chan2, chan3, chan4; - mlib_s32 i, j, c; - -#if IMG_TYPE != 1 - shift1 = 16; -#else - shift1 = 8; -#endif /* IMG_TYPE != 1 */ - - shift2 = scalef_expon - shift1; - - for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1; - - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc(sizeof(mlib_s32)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buffd = pbuff; - - chan1 = nchannel; - chan2 = chan1 + chan1; - chan3 = chan2 + chan1; - chan4 = chan3 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - for (j = 0; j < hgt; j++) { - mlib_s32 pix0, pix1; - /* - * First loop - */ - sp0 = sl; - sp1 = sp0 + sll; - dp = dl; - - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - p05 = sp0[chan3]; p15 = sp1[chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - - buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * Second loop - */ - sp0 = sl + 2*sll; - sp1 = sp0 + sll; - dp = dl; - - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - p05 = sp0[chan3]; p15 = sp1[chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - buffd[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - - buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * 3 loop - */ - dp = dl; - sp0 = sl + 4*sll; - - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - p02 = sp0[0]; - p03 = sp0[chan1]; - p04 = sp0[chan2]; - p05 = sp0[chan3]; - - sp0 += chan2 + chan2; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp0[0]; p05 = sp0[chan1]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 + - p04 * k3 + p05 * k4) >> shift2; - - CLAMP_STORE(dp[0], pix0) - CLAMP_STORE(dp[chan1], pix1) - - dp += chan2; - sp0 += chan2; - } - - if (wid & 1) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp0[0]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - CLAMP_STORE(dp[0], pix0) - } - - /* next line */ - sl += sll; - dl += dll; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -#endif /* __sparc ( for x86, using integer multiplies is faster ) */ - -/***************************************************************/ -#if IMG_TYPE == 1 - -#undef KSIZE -#define KSIZE 7 - -mlib_status CONV_FUNC(7x7)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 l, m, buff_ind; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6; - FTYPE p0, p1, p2, p3, p4, p5, p6, p7; - DTYPE *sl2, *sl3, *sl4, *sl5, *sl6; - DEF_VARS(DTYPE); - DTYPE *sl1; - mlib_s32 chan2; - mlib_s32 *buffo, *buffi; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*wid; - for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l]; - buffd = buffs[KSIZE] + wid; - buffo = (mlib_s32*)(buffd + wid); - buffi = buffo + (wid &~ 1); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; - sl3 = sl2 + sll; - sl4 = sl3 + sll; - sl5 = sl4 + sll; - sl6 = sl5 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buffs[0][i] = (FTYPE)sl[i*chan1]; - buffs[1][i] = (FTYPE)sl1[i*chan1]; - buffs[2][i] = (FTYPE)sl2[i*chan1]; - buffs[3][i] = (FTYPE)sl3[i*chan1]; - buffs[4][i] = (FTYPE)sl4[i*chan1]; - buffs[5][i] = (FTYPE)sl5[i*chan1]; - buffs[6][i] = (FTYPE)sl6[i*chan1]; - } - - buff_ind = 0; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid; i++) buffd[i] = 0.0; - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - FTYPE **buffc = buffs + buff_ind; - FTYPE *buffn = buffc[KSIZE]; - FTYPE *pk = k; - - for (l = 0; l < KSIZE; l++) { - FTYPE *buff = buffc[l]; - d64_2x32 dd; - - sp = sl; - dp = dl; - - p2 = buff[0]; p3 = buff[1]; p4 = buff[2]; - p5 = buff[3]; p6 = buff[4]; p7 = buff[5]; - - k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++; - k4 = *pk++; k5 = *pk++; k6 = *pk++; - - if (l < (KSIZE - 1)) { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - buffd[i ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6; - buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6; - } - - } else { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buffn[i ] = (FTYPE)dd.i32s.i0; - buffn[i + 1] = (FTYPE)dd.i32s.i1; - - d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i ]); - d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - buffd[i ] = 0.0; - buffd[i + 1] = 0.0; - - sp += chan2; - dp += chan2; - } - } - } - - /* last pixels */ - for (; i < wid; i++) { - FTYPE *pk = k, s = 0; - mlib_s32 d0; - - for (l = 0; l < KSIZE; l++) { - FTYPE *buff = buffc[l] + i; - - for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++); - } - - d0 = D2I(s); - dp[0] = FROM_S32(d0); - - buffn[i] = (FTYPE)sp[0]; - - sp += chan1; - dp += chan1; - } - - for (l = 0; l < (KSIZE - 1); l++) buffn[wid + l] = sp[l*chan1]; - - /* next line */ - sl += sll; - dl += dll; - - buff_ind++; - - if (buff_ind >= KSIZE + 1) buff_ind = 0; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -#endif /* IMG_TYPE == 1 */ - /***************************************************************/ #define MAX_KER 7 #define MAX_N 15 diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c index 551ea197876..ef111ba1f44 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_D64nw.c @@ -74,495 +74,6 @@ type *dl, *dp = NULL; \ mlib_s32 i = 0, j, c -/***************************************************************/ -#undef KSIZE -#define KSIZE 2 - -mlib_status CONV_FUNC(2x2)(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *kern, - mlib_s32 cmask) -{ - DEF_VARS(DTYPE); - DTYPE *sp0, *sp1; - mlib_s32 chan2 = chan1 + chan1; - mlib_s32 chan3 = chan1 + chan2; - mlib_s32 chan4 = chan3 + chan1; - DTYPE k0, k1, k2, k3; - DTYPE p00, p01, p02, p03, p04, - p10, p11, p12, p13, p14; - - /* keep kernel in regs */ - k0 = (DTYPE)kern[0]; k1 = (DTYPE)kern[1]; - k2 = (DTYPE)kern[2]; k3 = (DTYPE)kern[3]; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - dl = adr_dst + c; - sl = adr_src + c; - - for (j = 0; j < hgt; j++) { - dp = dl; - sp0 = sl; - sp1 = sp0 + sll; - - p04 = sp0[0]; - p14 = sp1[0]; - - sp0 += chan1; - sp1 += chan1; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 4); i += 4) { - p00 = p04; p10 = p14; - - p01 = sp0[0]; p11 = sp1[0]; - p02 = sp0[chan1]; p12 = sp1[chan1]; - p03 = sp0[chan2]; p13 = sp1[chan2]; - p04 = sp0[chan3]; p14 = sp1[chan3]; - - dp[0 ] = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3; - dp[chan1] = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3; - dp[chan2] = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3; - dp[chan3] = p03 * k0 + p04 * k1 + p13 * k2 + p14 * k3; - - dp += chan4; - sp0 += chan4; - sp1 += chan4; - } - - if (i < wid) { - p00 = p04; p10 = p14; - p01 = sp0[0]; p11 = sp1[0]; - dp[0] = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3; - - if ((i + 1) < wid) { - p02 = sp0[chan1]; p12 = sp1[chan1]; - dp[chan1] = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3; - - if ((i + 2) < wid) { - p03 = sp0[chan2]; p13 = sp1[chan2]; - dp[chan2] = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3; - } - } - } - - sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 3 - -mlib_status CONV_FUNC(3x3)(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *kern, - mlib_s32 cmask) -{ - DEF_VARS(DTYPE); - mlib_s32 chan2 = chan1 + chan1; - DTYPE *sp0, *sp1; - DTYPE *sp2; - DTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8; - DTYPE p02, p03, p12, p13, p22, p23; - - /* keep kernel in regs */ - k0 = (DTYPE)kern[0]; k1 = (DTYPE)kern[1]; k2 = (DTYPE)kern[2]; - k3 = (DTYPE)kern[3]; k4 = (DTYPE)kern[4]; k5 = (DTYPE)kern[5]; - k6 = (DTYPE)kern[6]; k7 = (DTYPE)kern[7]; k8 = (DTYPE)kern[8]; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - for (j = 0; j < hgt; j++) { - DTYPE s0, s1; - - dp = dl; - sp0 = sl; - sp1 = sp0 + sll; - sp2 = sp1 + sll; - - p02 = sp0[0]; - p12 = sp1[0]; - p22 = sp2[0]; - - p03 = sp0[chan1]; - p13 = sp1[chan1]; - p23 = sp2[chan1]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1]; - - dp[0 ] = s0 + p02 * k2 + p12 * k5 + p22 * k8; - dp[chan1] = s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - dp += chan2; - } - - if (wid & 1) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - dp[0] = s0 + p02 * k2 + p12 * k5 + p22 * k8; - } - - sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 4 - -mlib_status CONV_FUNC(4x4)(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *k, - mlib_s32 cmask) -{ - DTYPE k0, k1, k2, k3, k4, k5, k6, k7; - DTYPE p00, p01, p02, p03, p04, - p10, p11, p12, p13, p14; - DEF_VARS(DTYPE); - DTYPE *sp0, *sp1; - mlib_s32 chan2 = chan1 + chan1; - mlib_s32 chan3 = chan1 + chan2; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - for (j = 0; j < hgt; j++) { - /* - * First loop on two first lines of kernel - */ - sp0 = sl; - sp1 = sp0 + sll; - dp = dl; - - k0 = (DTYPE)k[0]; k1 = (DTYPE)k[1]; k2 = (DTYPE)k[2]; k3 = (DTYPE)k[3]; - k4 = (DTYPE)k[4]; k5 = (DTYPE)k[5]; k6 = (DTYPE)k[6]; k7 = (DTYPE)k[7]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - - sp0 += chan3; - sp1 += chan3; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - - p03 = sp0[0]; p13 = sp1[0]; - p04 = sp0[chan1]; p14 = sp1[chan1]; - - dp[0 ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - dp[chan1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = sp0[0]; p13 = sp1[0]; - - dp[0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - } - - /* - * Second loop on two last lines of kernel - */ - sp0 = sl + 2*sll; - sp1 = sp0 + sll; - dp = dl; - - k0 = (DTYPE)k[ 8]; k1 = (DTYPE)k[ 9]; k2 = (DTYPE)k[10]; k3 = (DTYPE)k[11]; - k4 = (DTYPE)k[12]; k5 = (DTYPE)k[13]; k6 = (DTYPE)k[14]; k7 = (DTYPE)k[15]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - - sp0 += chan3; - sp1 += chan3; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - - p03 = sp0[0]; p13 = sp1[0]; - p04 = sp0[chan1]; p14 = sp1[chan1]; - - dp[0 ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - dp[chan1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = sp0[0]; p13 = sp1[0]; - - dp[0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - } - - /* next line */ - sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 5 - -mlib_status CONV_FUNC(5x5)(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *k, - mlib_s32 cmask) -{ - DTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - DTYPE p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15; - DEF_VARS(DTYPE); - DTYPE *sp0, *sp1; - mlib_s32 chan2 = chan1 + chan1; - mlib_s32 chan3 = chan1 + chan2; - mlib_s32 chan4 = chan3 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - for (j = 0; j < hgt; j++) { - /* - * First loop - */ - sp0 = sl; - sp1 = sp0 + sll; - dp = dl; - - k0 = (DTYPE)k[0]; k1 = (DTYPE)k[1]; k2 = (DTYPE)k[2]; k3 = (DTYPE)k[3]; k4 = (DTYPE)k[4]; - k5 = (DTYPE)k[5]; k6 = (DTYPE)k[6]; k7 = (DTYPE)k[7]; k8 = (DTYPE)k[8]; k9 = (DTYPE)k[9]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - p05 = sp0[chan3]; p15 = sp1[chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - dp[ 0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - dp[chan1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - - dp[0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * Second loop - */ - sp0 = sl + 2*sll; - sp1 = sp0 + sll; - dp = dl; - - k0 = (DTYPE)k[10]; k1 = (DTYPE)k[11]; k2 = (DTYPE)k[12]; k3 = (DTYPE)k[13]; k4 = (DTYPE)k[14]; - k5 = (DTYPE)k[15]; k6 = (DTYPE)k[16]; k7 = (DTYPE)k[17]; k8 = (DTYPE)k[18]; k9 = (DTYPE)k[19]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - p05 = sp0[chan3]; p15 = sp1[chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - dp[ 0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - dp[chan1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - - dp[0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * 3 loop - */ - dp = dl; - sp0 = sl + 4*sll; - - k0 = (DTYPE)k[20]; k1 = (DTYPE)k[21]; k2 = (DTYPE)k[22]; k3 = (DTYPE)k[23]; k4 = (DTYPE)k[24]; - - p02 = sp0[0]; - p03 = sp0[chan1]; - p04 = sp0[chan2]; - p05 = sp0[chan3]; - - sp0 += chan2 + chan2; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp0[0]; p05 = sp0[chan1]; - - dp[0 ] += p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4; - dp[chan1] += p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4; - - dp += chan2; - sp0 += chan2; - } - - if (wid & 1) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp0[0]; - - dp[0] += p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4; - } - - /* next line */ - sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - /***************************************************************/ #define BUFF_SIZE 1600 diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c index 7e279d7a61e..c825c97c437 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_F32nw.c @@ -74,495 +74,6 @@ type *dl, *dp = NULL; \ mlib_s32 i, j, c -/***************************************************************/ -#undef KSIZE -#define KSIZE 2 - -mlib_status CONV_FUNC(2x2)(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *kern, - mlib_s32 cmask) -{ - DEF_VARS(DTYPE); - DTYPE *sp0, *sp1; - mlib_s32 chan2 = chan1 + chan1; - mlib_s32 chan3 = chan1 + chan2; - mlib_s32 chan4 = chan3 + chan1; - DTYPE k0, k1, k2, k3; - DTYPE p00, p01, p02, p03, p04, - p10, p11, p12, p13, p14; - - /* keep kernel in regs */ - k0 = (DTYPE)kern[0]; k1 = (DTYPE)kern[1]; - k2 = (DTYPE)kern[2]; k3 = (DTYPE)kern[3]; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - dl = adr_dst + c; - sl = adr_src + c; - - for (j = 0; j < hgt; j++) { - dp = dl; - sp0 = sl; - sp1 = sp0 + sll; - - p04 = sp0[0]; - p14 = sp1[0]; - - sp0 += chan1; - sp1 += chan1; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 4); i += 4) { - p00 = p04; p10 = p14; - - p01 = sp0[0]; p11 = sp1[0]; - p02 = sp0[chan1]; p12 = sp1[chan1]; - p03 = sp0[chan2]; p13 = sp1[chan2]; - p04 = sp0[chan3]; p14 = sp1[chan3]; - - dp[0 ] = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3; - dp[chan1] = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3; - dp[chan2] = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3; - dp[chan3] = p03 * k0 + p04 * k1 + p13 * k2 + p14 * k3; - - dp += chan4; - sp0 += chan4; - sp1 += chan4; - } - - if (i < wid) { - p00 = p04; p10 = p14; - p01 = sp0[0]; p11 = sp1[0]; - dp[0] = p00 * k0 + p01 * k1 + p10 * k2 + p11 * k3; - - if ((i + 1) < wid) { - p02 = sp0[chan1]; p12 = sp1[chan1]; - dp[chan1] = p01 * k0 + p02 * k1 + p11 * k2 + p12 * k3; - - if ((i + 2) < wid) { - p03 = sp0[chan2]; p13 = sp1[chan2]; - dp[chan2] = p02 * k0 + p03 * k1 + p12 * k2 + p13 * k3; - } - } - } - - sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 3 - -mlib_status CONV_FUNC(3x3)(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *kern, - mlib_s32 cmask) -{ - DEF_VARS(DTYPE); - mlib_s32 chan2 = chan1 + chan1; - DTYPE *sp0, *sp1; - DTYPE *sp2; - DTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8; - DTYPE p02, p03, p12, p13, p22, p23; - - /* keep kernel in regs */ - k0 = (DTYPE)kern[0]; k1 = (DTYPE)kern[1]; k2 = (DTYPE)kern[2]; - k3 = (DTYPE)kern[3]; k4 = (DTYPE)kern[4]; k5 = (DTYPE)kern[5]; - k6 = (DTYPE)kern[6]; k7 = (DTYPE)kern[7]; k8 = (DTYPE)kern[8]; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - for (j = 0; j < hgt; j++) { - DTYPE s0, s1; - - dp = dl; - sp0 = sl; - sp1 = sp0 + sll; - sp2 = sp1 + sll; - - p02 = sp0[0]; - p12 = sp1[0]; - p22 = sp2[0]; - - p03 = sp0[chan1]; - p13 = sp1[chan1]; - p23 = sp2[chan1]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1]; - - dp[0 ] = s0 + p02 * k2 + p12 * k5 + p22 * k8; - dp[chan1] = s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - dp += chan2; - } - - if (wid & 1) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - dp[0] = s0 + p02 * k2 + p12 * k5 + p22 * k8; - } - - sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 4 - -mlib_status CONV_FUNC(4x4)(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *k, - mlib_s32 cmask) -{ - DTYPE k0, k1, k2, k3, k4, k5, k6, k7; - DTYPE p00, p01, p02, p03, p04, - p10, p11, p12, p13, p14; - DEF_VARS(DTYPE); - DTYPE *sp0, *sp1; - mlib_s32 chan2 = chan1 + chan1; - mlib_s32 chan3 = chan1 + chan2; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - for (j = 0; j < hgt; j++) { - /* - * First loop on two first lines of kernel - */ - sp0 = sl; - sp1 = sp0 + sll; - dp = dl; - - k0 = (DTYPE)k[0]; k1 = (DTYPE)k[1]; k2 = (DTYPE)k[2]; k3 = (DTYPE)k[3]; - k4 = (DTYPE)k[4]; k5 = (DTYPE)k[5]; k6 = (DTYPE)k[6]; k7 = (DTYPE)k[7]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - - sp0 += chan3; - sp1 += chan3; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - - p03 = sp0[0]; p13 = sp1[0]; - p04 = sp0[chan1]; p14 = sp1[chan1]; - - dp[0 ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - dp[chan1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = sp0[0]; p13 = sp1[0]; - - dp[0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - } - - /* - * Second loop on two last lines of kernel - */ - sp0 = sl + 2*sll; - sp1 = sp0 + sll; - dp = dl; - - k0 = (DTYPE)k[ 8]; k1 = (DTYPE)k[ 9]; k2 = (DTYPE)k[10]; k3 = (DTYPE)k[11]; - k4 = (DTYPE)k[12]; k5 = (DTYPE)k[13]; k6 = (DTYPE)k[14]; k7 = (DTYPE)k[15]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - - sp0 += chan3; - sp1 += chan3; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - - p03 = sp0[0]; p13 = sp1[0]; - p04 = sp0[chan1]; p14 = sp1[chan1]; - - dp[0 ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - dp[chan1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = sp0[0]; p13 = sp1[0]; - - dp[0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - } - - /* next line */ - sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 5 - -mlib_status CONV_FUNC(5x5)(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *k, - mlib_s32 cmask) -{ - DTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - DTYPE p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15; - DEF_VARS(DTYPE); - DTYPE *sp0, *sp1; - mlib_s32 chan2 = chan1 + chan1; - mlib_s32 chan3 = chan1 + chan2; - mlib_s32 chan4 = chan3 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - for (j = 0; j < hgt; j++) { - /* - * First loop - */ - sp0 = sl; - sp1 = sp0 + sll; - dp = dl; - - k0 = (DTYPE)k[0]; k1 = (DTYPE)k[1]; k2 = (DTYPE)k[2]; k3 = (DTYPE)k[3]; k4 = (DTYPE)k[4]; - k5 = (DTYPE)k[5]; k6 = (DTYPE)k[6]; k7 = (DTYPE)k[7]; k8 = (DTYPE)k[8]; k9 = (DTYPE)k[9]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - p05 = sp0[chan3]; p15 = sp1[chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - dp[ 0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - dp[chan1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - - dp[0] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * Second loop - */ - sp0 = sl + 2*sll; - sp1 = sp0 + sll; - dp = dl; - - k0 = (DTYPE)k[10]; k1 = (DTYPE)k[11]; k2 = (DTYPE)k[12]; k3 = (DTYPE)k[13]; k4 = (DTYPE)k[14]; - k5 = (DTYPE)k[15]; k6 = (DTYPE)k[16]; k7 = (DTYPE)k[17]; k8 = (DTYPE)k[18]; k9 = (DTYPE)k[19]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - p05 = sp0[chan3]; p15 = sp1[chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - dp[ 0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - dp[chan1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - - dp[0] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * 3 loop - */ - dp = dl; - sp0 = sl + 4*sll; - - k0 = (DTYPE)k[20]; k1 = (DTYPE)k[21]; k2 = (DTYPE)k[22]; k3 = (DTYPE)k[23]; k4 = (DTYPE)k[24]; - - p02 = sp0[0]; - p03 = sp0[chan1]; - p04 = sp0[chan2]; - p05 = sp0[chan3]; - - sp0 += chan2 + chan2; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp0[0]; p05 = sp0[chan1]; - - dp[0 ] += p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4; - dp[chan1] += p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4; - - dp += chan2; - sp0 += chan2; - } - - if (wid & 1) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp0[0]; - - dp[0] += p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4; - } - - /* next line */ - sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - /***************************************************************/ #define BUFF_SIZE 1600 diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c index 926459d1170..b6a641039fa 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16ext.c @@ -79,9 +79,6 @@ #endif /* IMG_TYPE == 1 */ -/***************************************************************/ -#define KSIZE1 (KSIZE - 1) - /***************************************************************/ #define PARAM \ mlib_image *dst, \ @@ -162,9 +159,6 @@ #endif /* _LITTLE_ENDIAN */ #endif /* _NO_LONGLONG */ -/***************************************************************/ -#define MLIB_D2_24 16777216.0f - /***************************************************************/ typedef union { mlib_d64 d64; @@ -174,9 +168,6 @@ typedef union { } i32s; } d64_2x32; -/***************************************************************/ -#define BUFF_LINE 256 - /***************************************************************/ #define DEF_VARS(type) \ type *adr_src, *sl, *sp, *sl1; \ @@ -187,39 +178,6 @@ typedef union { mlib_s32 nchannel, chan1, chan2; \ mlib_s32 i, j, c, swid -/***************************************************************/ -#define LOAD_KERNEL3() \ - FTYPE scalef = DSCALE; \ - FTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8; \ - FTYPE p00, p01, p02, p03, \ - p10, p11, p12, p13, \ - p20, p21, p22, p23; \ - \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - /* keep kernel in regs */ \ - k0 = scalef * kern[0]; k1 = scalef * kern[1]; k2 = scalef * kern[2]; \ - k3 = scalef * kern[3]; k4 = scalef * kern[4]; k5 = scalef * kern[5]; \ - k6 = scalef * kern[6]; k7 = scalef * kern[7]; k8 = scalef * kern[8] - -/***************************************************************/ -#define LOAD_KERNEL(SIZE) \ - FTYPE scalef = DSCALE; \ - \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j] - /***************************************************************/ #define GET_SRC_DST_PARAMETERS(type) \ hgt = mlib_ImageGetHeight(src); \ @@ -277,1334 +235,6 @@ typedef union { #endif /* IMG_TYPE == 1 */ #endif /* __sparc */ -/***************************************************************/ -#define KSIZE 3 - -mlib_status CONV_FUNC(3x3) -{ - FTYPE buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT; - DEF_VARS(DTYPE); - DTYPE *sl2; -#ifndef __sparc - mlib_s32 d0, d1; -#endif /* __sparc */ - LOAD_KERNEL3(); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + KSIZE1; - - if (swid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE )*swid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + swid; - buff2 = buff1 + swid; - buff3 = buff2 + swid; - buffo = (mlib_s32*)(buff3 + swid); - buffi = buffo + (swid &~ 1); - - swid -= (dx_l + dx_r); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll; - else sl1 = sl; - - if ((hgt - dy_b) > 0) sl2 = sl1 + sll; - else sl2 = sl1; - - for (i = 0; i < dx_l; i++) { - buff0[i] = (FTYPE)sl[0]; - buff1[i] = (FTYPE)sl1[0]; - buff2[i] = (FTYPE)sl2[0]; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buff0[i + dx_l] = (FTYPE)sl[i*chan1]; - buff1[i + dx_l] = (FTYPE)sl1[i*chan1]; - buff2[i + dx_l] = (FTYPE)sl2[i*chan1]; - } - - for (i = 0; i < dx_r; i++) { - buff0[swid + dx_l + i] = buff0[swid + dx_l - 1]; - buff1[swid + dx_l + i] = buff1[swid + dx_l - 1]; - buff2[swid + dx_l + i] = buff2[swid + dx_l - 1]; - } - - if ((hgt - dy_b) > 1) sl = sl2 + sll; - else sl = sl2; - - for (j = 0; j < hgt; j++) { - FTYPE s0, s1; - - p02 = buff0[0]; - p12 = buff1[0]; - p22 = buff2[0]; - - p03 = buff0[1]; - p13 = buff1[1]; - p23 = buff2[1]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp = sl; - dp = dl; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { -#ifdef __sparc -#ifdef _NO_LONGLONG - mlib_s32 o64_1, o64_2; -#else /* _NO_LONGLONG */ - mlib_s64 o64; -#endif /* _NO_LONGLONG */ -#endif /* __sparc */ - d64_2x32 dd; - - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buff3[i + dx_l ] = (FTYPE)dd.i32s.i0; - buff3[i + dx_l + 1] = (FTYPE)dd.i32s.i1; - -#ifndef __sparc - - d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8); - d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8); - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - -#else /* __sparc */ - - dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8); - dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8); - *(FTYPE *)(buffo + i) = dd.d64; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - -#ifdef _NO_LONGLONG - - o64_1 = buffo[i]; - o64_2 = buffo[i+1]; -#if IMG_TYPE != 1 - STORE2(FROM_S32(o64_1), FROM_S32(o64_2)); -#else - STORE2(o64_1 >> 24, o64_2 >> 24); -#endif /* IMG_TYPE != 1 */ - -#else /* _NO_LONGLONG */ - - o64 = *(mlib_s64*)(buffo + i); -#if IMG_TYPE != 1 - STORE2(FROM_S32(o64 >> 32), FROM_S32(o64)); -#else - STORE2(o64 >> 56, o64 >> 24); -#endif /* IMG_TYPE != 1 */ -#endif /* _NO_LONGLONG */ -#endif /* __sparc */ - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - - buffi[i] = (mlib_s32)sp[0]; - buff3[i + dx_l] = (FTYPE)buffi[i]; - -#ifndef __sparc - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); - - dp[0] = FROM_S32(d0); - -#else /* __sparc */ - - buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); -#if IMG_TYPE != 1 - dp[0] = FROM_S32(buffo[i]); -#else - dp[0] = buffo[i] >> 24; -#endif /* IMG_TYPE != 1 */ -#endif /* __sparc */ - - sp += chan1; - dp += chan1; - } - - for (; i < swid; i++) { - buffi[i] = (mlib_s32)sp[0]; - buff3[i + dx_l] = (FTYPE)buffi[i]; - sp += chan1; - } - - for (i = 0; i < dx_l; i++) buff3[i] = buff3[dx_l]; - for (i = 0; i < dx_r; i++) buff3[swid + dx_l + i] = buff3[swid + dx_l - 1]; - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buffT; - } - } - -#ifdef __sparc -#if IMG_TYPE == 1 - { - mlib_s32 amask = (1 << nchannel) - 1; - - if ((cmask & amask) != amask) { - mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask); - } else { - mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll); - } - } - -#endif /* IMG_TYPE == 1 */ -#endif /* __sparc */ - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#ifndef __sparc /* for x86, using integer multiplies is faster */ - -mlib_status CONV_FUNC_I(3x3) -{ - DTYPE *adr_src, *sl, *sp0, *sp1, *sp2, *sp_1, *sp_2; - DTYPE *adr_dst, *dl, *dp; - mlib_s32 wid, hgt, sll, dll; - mlib_s32 nchannel, chan1, chan2, delta_chan; - mlib_s32 i, j, c; - mlib_s32 shift1, shift2; - mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8; - mlib_s32 p02, p03, - p12, p13, - p22, p23; - -#if IMG_TYPE != 1 - shift1 = 16; -#else - shift1 = 8; -#endif /* IMG_TYPE != 1 */ - - shift2 = scalef_expon - shift1; - - /* keep kernel in regs */ - k0 = kern[0] >> shift1; k1 = kern[1] >> shift1; k2 = kern[2] >> shift1; - k3 = kern[3] >> shift1; k4 = kern[4] >> shift1; k5 = kern[5] >> shift1; - k6 = kern[6] >> shift1; k7 = kern[7] >> shift1; k8 = kern[8] >> shift1; - - GET_SRC_DST_PARAMETERS(DTYPE); - - chan1 = nchannel; - chan2 = chan1 + chan1; - delta_chan = 0; - - if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan = chan1; - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sp_1 = sl; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll; - sp_2 = sl; - - if ((hgt - dy_b) > 0) sl += sll; - - for (j = 0; j < hgt; j++) { - mlib_s32 s0, s1; - mlib_s32 pix0, pix1; - - dp = dl; - sp0 = sp_1; - sp_1 = sp_2; - sp_2 = sl; - - sp1 = sp_1; - sp2 = sp_2; - - p02 = sp0[0]; - p12 = sp1[0]; - p22 = sp2[0]; - - p03 = sp0[delta_chan]; - p13 = sp1[delta_chan]; - p23 = sp2[delta_chan]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += (chan1 + delta_chan); - sp1 += (chan1 + delta_chan); - sp2 += (chan1 + delta_chan); - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - dx_r - 2); i += 2) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1]; - - pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2; - pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 + - p13 * k5 + p22 * k7 + p23 * k8) >> shift2; - - CLAMP_STORE(dp[0], pix0); - CLAMP_STORE(dp[chan1], pix1); - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - dp += chan2; - } - - p02 = p03; p12 = p13; p22 = p23; - - for (; i < wid - dx_r; i++) { - p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0]; - pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2; - CLAMP_STORE(dp[0], pix0); - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - p02 = p03; p12 = p13; p22 = p23; - sp0 += chan1; - sp1 += chan1; - sp2 += chan1; - dp += chan1; - } - - sp0 -= chan1; - sp1 -= chan1; - sp2 -= chan1; - - for (; i < wid; i++) { - p03 = sp0[0]; p13 = sp1[0]; p23 = sp2[0]; - pix0 = (s0 + p03 * k2 + p13 * k5 + p23 * k8) >> shift2; - CLAMP_STORE(dp[0], pix0); - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - p02 = p03; p12 = p13; p22 = p23; - dp += chan1; - } - - if (j < hgt - dy_b - 1) sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - -#endif /* __sparc ( for x86, using integer multiplies is faster ) */ - -/***************************************************************/ -#undef KSIZE -#define KSIZE 4 - -mlib_status CONV_FUNC(4x4) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE]; - FTYPE *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6, k7; - FTYPE p00, p01, p02, p03, p04, - p10, p11, p12, p13, p14, - p20, p21, p22, p23, - p30, p31, p32, p33; - DEF_VARS(DTYPE); - DTYPE *sl2, *sl3; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + KSIZE1; - - if (swid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE )*swid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + swid; - buff2 = buff1 + swid; - buff3 = buff2 + swid; - buff4 = buff3 + swid; - buffd = buff4 + swid; - buffo = (mlib_s32*)(buffd + swid); - buffi = buffo + (swid &~ 1); - - swid -= (dx_l + dx_r); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll; - else sl1 = sl; - - if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll; - else sl2 = sl1; - - if ((hgt - dy_b) > 0) sl3 = sl2 + sll; - else sl3 = sl2; - - for (i = 0; i < dx_l; i++) { - buff0[i] = (FTYPE)sl[0]; - buff1[i] = (FTYPE)sl1[0]; - buff2[i] = (FTYPE)sl2[0]; - buff3[i] = (FTYPE)sl3[0]; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buff0[i + dx_l] = (FTYPE)sl[i*chan1]; - buff1[i + dx_l] = (FTYPE)sl1[i*chan1]; - buff2[i + dx_l] = (FTYPE)sl2[i*chan1]; - buff3[i + dx_l] = (FTYPE)sl3[i*chan1]; - } - - for (i = 0; i < dx_r; i++) { - buff0[swid + dx_l + i] = buff0[swid + dx_l - 1]; - buff1[swid + dx_l + i] = buff1[swid + dx_l - 1]; - buff2[swid + dx_l + i] = buff2[swid + dx_l - 1]; - buff3[swid + dx_l + i] = buff3[swid + dx_l - 1]; - } - - if ((hgt - dy_b) > 1) sl = sl3 + sll; - else sl = sl3; - - for (j = 0; j < hgt; j++) { - d64_2x32 dd; - - /* - * First loop on two first lines of kernel - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; - k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff1[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buff4[i + dx_l ] = (FTYPE)dd.i32s.i0; - buff4[i + dx_l + 1] = (FTYPE)dd.i32s.i1; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7); - - sp += chan2; - } - - /* - * Second loop on two last lines of kernel - */ - k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11]; - k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15]; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - p04 = buff2[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]); - d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - - buff4[i + dx_l] = (FTYPE)sp[0]; - - buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + - p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] + - p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] + - p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]); - - dp[0] = FROM_S32(buffo[i]); - - sp += chan1; - dp += chan1; - } - - for (; i < swid; i++) { - buff4[i + dx_l] = (FTYPE)sp[0]; - sp += chan1; - } - - for (i = 0; i < dx_l; i++) buff4[i] = buff4[dx_l]; - for (i = 0; i < dx_r; i++) buff4[swid + dx_l + i] = buff4[swid + dx_l - 1]; - - /* next line */ - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 5 - -mlib_status CONV_FUNC(5x5) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE]; - FTYPE *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - FTYPE p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15, - p20, p21, p22, p23, p24, - p30, p31, p32, p33, p34, - p40, p41, p42, p43, p44; - DEF_VARS(DTYPE); - DTYPE *sl2, *sl3, *sl4; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + KSIZE1; - - if (swid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE )*swid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + swid; - buff2 = buff1 + swid; - buff3 = buff2 + swid; - buff4 = buff3 + swid; - buff5 = buff4 + swid; - buffd = buff5 + swid; - buffo = (mlib_s32*)(buffd + swid); - buffi = buffo + (swid &~ 1); - - swid -= (dx_l + dx_r); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll; - else sl1 = sl; - - if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll; - else sl2 = sl1; - - if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll; - else sl3 = sl2; - - if ((hgt - dy_b) > 0) sl4 = sl3 + sll; - else sl4 = sl3; - - for (i = 0; i < dx_l; i++) { - buff0[i] = (FTYPE)sl[0]; - buff1[i] = (FTYPE)sl1[0]; - buff2[i] = (FTYPE)sl2[0]; - buff3[i] = (FTYPE)sl3[0]; - buff4[i] = (FTYPE)sl4[0]; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buff0[i + dx_l] = (FTYPE)sl[i*chan1]; - buff1[i + dx_l] = (FTYPE)sl1[i*chan1]; - buff2[i + dx_l] = (FTYPE)sl2[i*chan1]; - buff3[i + dx_l] = (FTYPE)sl3[i*chan1]; - buff4[i + dx_l] = (FTYPE)sl4[i*chan1]; - } - - for (i = 0; i < dx_r; i++) { - buff0[swid + dx_l + i] = buff0[swid + dx_l - 1]; - buff1[swid + dx_l + i] = buff1[swid + dx_l - 1]; - buff2[swid + dx_l + i] = buff2[swid + dx_l - 1]; - buff3[swid + dx_l + i] = buff3[swid + dx_l - 1]; - buff4[swid + dx_l + i] = buff4[swid + dx_l - 1]; - } - - if ((hgt - dy_b) > 1) sl = sl4 + sll; - else sl = sl4; - - for (j = 0; j < hgt; j++) { - d64_2x32 dd; - - /* - * First loop - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - p14 = buff1[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - - LOAD_BUFF(buffi); - - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - p05 = buff0[i + 5]; p15 = buff1[i + 5]; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp += chan2; - } - - /* - * Second loop - */ - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - - p02 = buff2[i + 2]; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - p05 = buff2[i + 5]; p15 = buff3[i + 5]; - - dd.d64 = *(FTYPE *)(buffi + i); - buff5[i + dx_l ] = (FTYPE)dd.i32s.i0; - buff5[i + dx_l + 1] = (FTYPE)dd.i32s.i1; - - buffd[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - } - - /* - * 3 loop - */ - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - p02 = buff4[0]; - p03 = buff4[1]; - p04 = buff4[2]; - p05 = buff4[3]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = buff4[i + 4]; p05 = buff4[i + 5]; - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]); - d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4]; - - p40 = buff4[i]; p41 = buff4[i + 1]; p42 = buff4[i + 2]; - p43 = buff4[i + 3]; p44 = buff4[i + 4]; - - buff5[i + dx_l] = (FTYPE)sp[0]; - - buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] + - p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] + - p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] + - p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] + - p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]); - - dp[0] = FROM_S32(buffo[i]); - - sp += chan1; - dp += chan1; - } - - for (; i < swid; i++) { - buff5[i + dx_l] = (FTYPE)sp[0]; - sp += chan1; - } - - for (i = 0; i < dx_l; i++) buff5[i] = buff5[dx_l]; - for (i = 0; i < dx_r; i++) buff5[swid + dx_l + i] = buff5[swid + dx_l - 1]; - - /* next line */ - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buff5; - buff5 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#ifndef __sparc /* for x86, using integer multiplies is faster */ - -mlib_status CONV_FUNC_I(5x5) -{ - mlib_s32 buff[BUFF_LINE]; - mlib_s32 *buffd; - mlib_s32 k[KSIZE*KSIZE]; - mlib_s32 shift1, shift2; - mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - mlib_s32 p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15; - DTYPE *adr_src, *sl, *sp0, *sp1, *sp2, *sp3, *sp4; - DTYPE *sp_1, *sp_2, *sp_3, *sp_4; - DTYPE *adr_dst, *dl, *dp; - mlib_s32 *pbuff = buff; - mlib_s32 wid, hgt, sll, dll; - mlib_s32 nchannel, chan1, chan2, chan4; - mlib_s32 delta_chan1, delta_chan2, delta_chan3; - mlib_s32 i, j, c; - -#if IMG_TYPE != 1 - shift1 = 16; -#else - shift1 = 8; -#endif /* IMG_TYPE != 1 */ - - shift2 = scalef_expon - shift1; - - for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1; - - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc(sizeof(mlib_s32)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buffd = pbuff; - - chan1 = nchannel; - chan2 = chan1 + chan1; - - if ((1 > dx_l) && (1 < wid + KSIZE1 - dx_r)) delta_chan1 = chan1; - else delta_chan1 = 0; - - if ((2 > dx_l) && (2 < wid + KSIZE1 - dx_r)) delta_chan2 = delta_chan1 + chan1; - else delta_chan2 = delta_chan1; - - if ((3 > dx_l) && (3 < wid + KSIZE1 - dx_r)) delta_chan3 = delta_chan2 + chan1; - else delta_chan3 = delta_chan2; - - chan4 = chan1 + delta_chan3; - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sp_1 = sl; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl += sll; - sp_2 = sl; - - if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl += sll; - sp_3 = sl; - - if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl += sll; - sp_4 = sl; - - if ((hgt - dy_b) > 0) sl += sll; - - for (j = 0; j < hgt; j++) { - mlib_s32 pix0, pix1; - - dp = dl; - sp0 = sp_1; - sp_1 = sp_2; - sp_2 = sp_3; - sp_3 = sp_4; - sp_4 = sl; - - sp1 = sp_1; - sp2 = sp_2; - sp3 = sp_3; - sp4 = sp_4; - - /* - * First loop - */ - - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[delta_chan1]; p13 = sp1[delta_chan1]; - p04 = sp0[delta_chan2]; p14 = sp1[delta_chan2]; - p05 = sp0[delta_chan3]; p15 = sp1[delta_chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - dx_r - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - } - - p01 = p02; p02 = p03; p03 = p04; p04 = p05; - p11 = p12; p12 = p13; p13 = p14; p14 = p15; - - for (; i < wid - dx_r; i++) { - p00 = p01; p10 = p11; - p01 = p02; p11 = p12; - p02 = p03; p12 = p13; - p03 = p04; p13 = p14; - - p04 = sp0[0]; p14 = sp1[0]; - - buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - - sp0 += chan1; - sp1 += chan1; - } - - sp0 -= chan1; - sp1 -= chan1; - - for (; i < wid; i++) { - p00 = p01; p10 = p11; - p01 = p02; p11 = p12; - p02 = p03; p12 = p13; - p03 = p04; p13 = p14; - - p04 = sp0[0]; p14 = sp1[0]; - - buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * Second loop - */ - - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - p02 = sp2[0]; p12 = sp3[0]; - p03 = sp2[delta_chan1]; p13 = sp3[delta_chan1]; - p04 = sp2[delta_chan2]; p14 = sp3[delta_chan2]; - p05 = sp2[delta_chan3]; p15 = sp3[delta_chan3]; - - sp2 += chan4; - sp3 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - dx_r - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp2[0]; p14 = sp3[0]; - p05 = sp2[chan1]; p15 = sp3[chan1]; - - buffd[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp2 += chan2; - sp3 += chan2; - } - - p01 = p02; p02 = p03; p03 = p04; p04 = p05; - p11 = p12; p12 = p13; p13 = p14; p14 = p15; - - for (; i < wid - dx_r; i++) { - p00 = p01; p10 = p11; - p01 = p02; p11 = p12; - p02 = p03; p12 = p13; - p03 = p04; p13 = p14; - - p04 = sp2[0]; p14 = sp3[0]; - - buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - - sp2 += chan1; - sp3 += chan1; - } - - sp2 -= chan1; - sp3 -= chan1; - - for (; i < wid; i++) { - p00 = p01; p10 = p11; - p01 = p02; p11 = p12; - p02 = p03; p12 = p13; - p03 = p04; p13 = p14; - - p04 = sp2[0]; p14 = sp3[0]; - - buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * 3 loop - */ - - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - p02 = sp4[0]; - p03 = sp4[delta_chan1]; - p04 = sp4[delta_chan2]; - p05 = sp4[delta_chan3]; - - sp4 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - dx_r - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp4[0]; p05 = sp4[chan1]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 + - p04 * k3 + p05 * k4) >> shift2; - - CLAMP_STORE(dp[0], pix0); - CLAMP_STORE(dp[chan1], pix1); - - dp += chan2; - sp4 += chan2; - } - - p01 = p02; p02 = p03; p03 = p04; p04 = p05; - - for (; i < wid - dx_r; i++) { - p00 = p01; p01 = p02; p02 = p03; p03 = p04; - - p04 = sp4[0]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - CLAMP_STORE(dp[0], pix0); - - dp += chan1; - sp4 += chan1; - } - - sp4 -= chan1; - - for (; i < wid; i++) { - p00 = p01; p01 = p02; p02 = p03; p03 = p04; - - p04 = sp4[0]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - CLAMP_STORE(dp[0], pix0); - - dp += chan1; - } - - /* next line */ - - if (j < hgt - dy_b - 1) sl += sll; - dl += dll; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -#endif /* __sparc ( for x86, using integer multiplies is faster ) */ - -/***************************************************************/ -#if IMG_TYPE == 1 - -#undef KSIZE -#define KSIZE 7 - -mlib_status CONV_FUNC(7x7) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 l, m, buff_ind; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6; - FTYPE p0, p1, p2, p3, p4, p5, p6, p7; - DTYPE *sl2, *sl3, *sl4, *sl5, *sl6; - DEF_VARS(DTYPE); - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - swid = wid + KSIZE1; - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE )*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*swid; - for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l]; - buffd = buffs[KSIZE] + swid; - buffo = (mlib_s32*)(buffd + swid); - buffi = buffo + (swid &~ 1); - - swid -= (dx_l + dx_r); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - if ((1 > dy_t) && (1 < hgt + KSIZE1 - dy_b)) sl1 = sl + sll; - else sl1 = sl; - - if ((2 > dy_t) && (2 < hgt + KSIZE1 - dy_b)) sl2 = sl1 + sll; - else sl2 = sl1; - - if ((3 > dy_t) && (3 < hgt + KSIZE1 - dy_b)) sl3 = sl2 + sll; - else sl3 = sl2; - - if ((4 > dy_t) && (4 < hgt + KSIZE1 - dy_b)) sl4 = sl3 + sll; - else sl4 = sl3; - - if ((5 > dy_t) && (5 < hgt + KSIZE1 - dy_b)) sl5 = sl4 + sll; - else sl5 = sl4; - - if ((hgt - dy_b) > 0) sl6 = sl5 + sll; - else sl6 = sl5; - - for (i = 0; i < dx_l; i++) { - buffs[0][i] = (FTYPE)sl[0]; - buffs[1][i] = (FTYPE)sl1[0]; - buffs[2][i] = (FTYPE)sl2[0]; - buffs[3][i] = (FTYPE)sl3[0]; - buffs[4][i] = (FTYPE)sl4[0]; - buffs[5][i] = (FTYPE)sl5[0]; - buffs[6][i] = (FTYPE)sl6[0]; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < swid; i++) { - buffs[0][i + dx_l] = (FTYPE)sl[i*chan1]; - buffs[1][i + dx_l] = (FTYPE)sl1[i*chan1]; - buffs[2][i + dx_l] = (FTYPE)sl2[i*chan1]; - buffs[3][i + dx_l] = (FTYPE)sl3[i*chan1]; - buffs[4][i + dx_l] = (FTYPE)sl4[i*chan1]; - buffs[5][i + dx_l] = (FTYPE)sl5[i*chan1]; - buffs[6][i + dx_l] = (FTYPE)sl6[i*chan1]; - } - - for (i = 0; i < dx_r; i++) { - buffs[0][swid + dx_l + i] = buffs[0][swid + dx_l - 1]; - buffs[1][swid + dx_l + i] = buffs[1][swid + dx_l - 1]; - buffs[2][swid + dx_l + i] = buffs[2][swid + dx_l - 1]; - buffs[3][swid + dx_l + i] = buffs[3][swid + dx_l - 1]; - buffs[4][swid + dx_l + i] = buffs[4][swid + dx_l - 1]; - buffs[5][swid + dx_l + i] = buffs[5][swid + dx_l - 1]; - buffs[6][swid + dx_l + i] = buffs[6][swid + dx_l - 1]; - } - - buff_ind = 0; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid; i++) buffd[i] = 0.0; - - if ((hgt - dy_b) > 1) sl = sl6 + sll; - else sl = sl6; - - for (j = 0; j < hgt; j++) { - FTYPE **buffc = buffs + buff_ind; - FTYPE *buffn = buffc[KSIZE]; - FTYPE *pk = k; - - for (l = 0; l < KSIZE; l++) { - FTYPE *buff = buffc[l]; - d64_2x32 dd; - - sp = sl; - dp = dl; - - p2 = buff[0]; p3 = buff[1]; p4 = buff[2]; - p5 = buff[3]; p6 = buff[4]; p7 = buff[5]; - - k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++; - k4 = *pk++; k5 = *pk++; k6 = *pk++; - - if (l < (KSIZE - 1)) { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - buffd[i ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6; - buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6; - } - - } else { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buffn[i + dx_l ] = (FTYPE)dd.i32s.i0; - buffn[i + dx_l + 1] = (FTYPE)dd.i32s.i1; - - d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i ]); - d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - buffd[i ] = 0.0; - buffd[i + 1] = 0.0; - - sp += chan2; - dp += chan2; - } - } - } - - /* last pixels */ - for (; i < wid; i++) { - FTYPE *pk = k, s = 0; - mlib_s32 d0; - - for (l = 0; l < KSIZE; l++) { - FTYPE *buff = buffc[l] + i; - - for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++); - } - - d0 = D2I(s); - dp[0] = FROM_S32(d0); - - buffn[i + dx_l] = (FTYPE)sp[0]; - - sp += chan1; - dp += chan1; - } - - for (; i < swid; i++) { - buffn[i + dx_l] = (FTYPE)sp[0]; - sp += chan1; - } - - for (i = 0; i < dx_l; i++) buffn[i] = buffn[dx_l]; - for (i = 0; i < dx_r; i++) buffn[swid + dx_l + i] = buffn[swid + dx_l - 1]; - - /* next line */ - - if (j < hgt - dy_b - 2) sl += sll; - dl += dll; - - buff_ind++; - - if (buff_ind >= KSIZE + 1) buff_ind = 0; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -#endif /* IMG_TYPE == 1 */ - /***************************************************************/ #define MAX_KER 7 #define MAX_N 15 diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c index 2aebcb86bae..9bfbe939abb 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv_u16nw.c @@ -143,9 +143,6 @@ typedef union { } f32s; } d64_2x32; -/***************************************************************/ -#define BUFF_LINE 256 - /***************************************************************/ #define DEF_VARS(type) \ type *adr_src, *sl, *sp = NULL; \ @@ -155,39 +152,6 @@ typedef union { mlib_s32 nchannel, chan1; \ mlib_s32 i, j, c -/***************************************************************/ -#define LOAD_KERNEL3() \ - FTYPE scalef = DSCALE; \ - FTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8; \ - FTYPE p00, p01, p02, p03, \ - p10, p11, p12, p13, \ - p20, p21, p22, p23; \ - \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - /* keep kernel in regs */ \ - k0 = scalef * kern[0]; k1 = scalef * kern[1]; k2 = scalef * kern[2]; \ - k3 = scalef * kern[3]; k4 = scalef * kern[4]; k5 = scalef * kern[5]; \ - k6 = scalef * kern[6]; k7 = scalef * kern[7]; k8 = scalef * kern[8] - -/***************************************************************/ -#define LOAD_KERNEL(SIZE) \ - FTYPE scalef = DSCALE; \ - \ - while (scalef_expon > 30) { \ - scalef /= (1 << 30); \ - scalef_expon -= 30; \ - } \ - \ - scalef /= (1 << scalef_expon); \ - \ - for (j = 0; j < SIZE; j++) k[j] = scalef * kern[j] - /***************************************************************/ #define GET_SRC_DST_PARAMETERS(type) \ hgt = mlib_ImageGetHeight(src); \ @@ -245,1162 +209,6 @@ typedef union { #endif /* IMG_TYPE == 1 */ #endif /* __sparc */ -/***************************************************************/ -#define KSIZE 3 - -mlib_status CONV_FUNC(3x3)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - FTYPE buff[(KSIZE + 2)*BUFF_LINE], *buff0, *buff1, *buff2, *buff3, *buffT; - DEF_VARS(DTYPE); - DTYPE *sl1; - mlib_s32 chan2; - mlib_s32 *buffo, *buffi; - DTYPE *sl2; -#ifndef __sparc - mlib_s32 d0, d1; -#endif /* __sparc */ - LOAD_KERNEL3(); - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 2)*sizeof(FTYPE)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - buff3 = buff2 + wid; - buffo = (mlib_s32*)(buff3 + wid); - buffi = buffo + (wid &~ 1); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (FTYPE)sl[i*chan1]; - buff1[i] = (FTYPE)sl1[i*chan1]; - buff2[i] = (FTYPE)sl2[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - FTYPE s0, s1; - - p02 = buff0[0]; - p12 = buff1[0]; - p22 = buff2[0]; - - p03 = buff0[1]; - p13 = buff1[1]; - p23 = buff2[1]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp = sl; - dp = dl; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { -#ifdef __sparc -#ifdef _NO_LONGLONG - mlib_s32 o64_1, o64_2; -#else /* _NO_LONGLONG */ - mlib_s64 o64; -#endif /* _NO_LONGLONG */ -#endif /* __sparc */ - d64_2x32 dd; - - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buff3[i ] = (FTYPE)dd.i32s.i0; - buff3[i + 1] = (FTYPE)dd.i32s.i1; - -#ifndef __sparc - d0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8); - d1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8); - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - -#else /* __sparc */ - - dd.i32s.i0 = D2I(s0 + p02 * k2 + p12 * k5 + p22 * k8); - dd.i32s.i1 = D2I(s1 + p02 * k1 + p03 * k2 + p12 * k4 + p13 * k5 + p22 * k7 + p23 * k8); - *(FTYPE *)(buffo + i) = dd.d64; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - -#ifdef _NO_LONGLONG - - o64_1 = buffo[i]; - o64_2 = buffo[i+1]; -#if IMG_TYPE != 1 - STORE2(FROM_S32(o64_1), FROM_S32(o64_2)); -#else - STORE2(o64_1 >> 24, o64_2 >> 24); -#endif /* IMG_TYPE != 1 */ - -#else /* _NO_LONGLONG */ - - o64 = *(mlib_s64*)(buffo + i); -#if IMG_TYPE != 1 - STORE2(FROM_S32(o64 >> 32), FROM_S32(o64)); -#else - STORE2(o64 >> 56, o64 >> 24); -#endif /* IMG_TYPE != 1 */ -#endif /* _NO_LONGLONG */ -#endif /* __sparc */ - - sp += chan2; - dp += chan2; - } - - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; - - buffi[i] = (mlib_s32)sp[0]; - buff3[i] = (FTYPE)buffi[i]; - -#ifndef __sparc - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); - - dp[0] = FROM_S32(d0); - -#else /* __sparc */ - - buffo[i] = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p10 * k3 + p11 * k4 + - p12 * k5 + p20 * k6 + p21 * k7 + p22 * k8); -#if IMG_TYPE != 1 - dp[0] = FROM_S32(buffo[i]); -#else - dp[0] = buffo[i] >> 24; -#endif /* IMG_TYPE != 1 */ -#endif /* __sparc */ - - sp += chan1; - dp += chan1; - } - - buffi[wid] = (mlib_s32)sp[0]; - buff3[wid] = (FTYPE)buffi[wid]; - buffi[wid + 1] = (mlib_s32)sp[chan1]; - buff3[wid + 1] = (FTYPE)buffi[wid + 1]; - - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buffT; - } - } - -#ifdef __sparc -#if IMG_TYPE == 1 - { - mlib_s32 amask = (1 << nchannel) - 1; - - if ((cmask & amask) != amask) { - mlib_ImageXor80(adr_dst, wid, hgt, dll, nchannel, cmask); - } else { - mlib_ImageXor80_aa(adr_dst, wid*nchannel, hgt, dll); - } - } - -#endif /* IMG_TYPE == 1 */ -#endif /* __sparc */ - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#ifndef __sparc /* for x86, using integer multiplies is faster */ - -mlib_status CONV_FUNC_I(3x3)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - DTYPE *adr_src, *sl, *sp0, *sp1, *sp2; - DTYPE *adr_dst, *dl, *dp; - mlib_s32 wid, hgt, sll, dll; - mlib_s32 nchannel, chan1, chan2; - mlib_s32 i, j, c; - mlib_s32 shift1, shift2; - mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8; - mlib_s32 p02, p03, - p12, p13, - p22, p23; - -#if IMG_TYPE != 1 - shift1 = 16; -#else - shift1 = 8; -#endif /* IMG_TYPE != 1 */ - - shift2 = scalef_expon - shift1; - - /* keep kernel in regs */ - k0 = kern[0] >> shift1; k1 = kern[1] >> shift1; k2 = kern[2] >> shift1; - k3 = kern[3] >> shift1; k4 = kern[4] >> shift1; k5 = kern[5] >> shift1; - k6 = kern[6] >> shift1; k7 = kern[7] >> shift1; k8 = kern[8] >> shift1; - - GET_SRC_DST_PARAMETERS(DTYPE); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - for (j = 0; j < hgt; j++) { - mlib_s32 s0, s1; - mlib_s32 pix0, pix1; - - dp = dl; - sp0 = sl; - sp1 = sp0 + sll; - sp2 = sp1 + sll; - - p02 = sp0[0]; - p12 = sp1[0]; - p22 = sp2[0]; - - p03 = sp0[chan1]; - p13 = sp1[chan1]; - p23 = sp2[chan1]; - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; p23 = sp2[chan1]; - - pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2; - pix1 = (s1 + p02 * k1 + p03 * k2 + p12 * k4 + - p13 * k5 + p22 * k7 + p23 * k8) >> shift2; - - CLAMP_STORE(dp[0], pix0); - CLAMP_STORE(dp[chan1], pix1); - - s0 = p02 * k0 + p03 * k1 + p12 * k3 + p13 * k4 + p22 * k6 + p23 * k7; - s1 = p03 * k0 + p13 * k3 + p23 * k6; - - sp0 += chan2; - sp1 += chan2; - sp2 += chan2; - dp += chan2; - } - - if (wid & 1) { - p02 = sp0[0]; p12 = sp1[0]; p22 = sp2[0]; - pix0 = (s0 + p02 * k2 + p12 * k5 + p22 * k8) >> shift2; - CLAMP_STORE(dp[0], pix0); - } - - sl += sll; - dl += dll; - } - } - - return MLIB_SUCCESS; -} - -#endif /* __sparc ( for x86, using integer multiplies is faster ) */ - -/***************************************************************/ -#undef KSIZE -#define KSIZE 4 - -mlib_status CONV_FUNC(4x4)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE]; - FTYPE *buff0, *buff1, *buff2, *buff3, *buff4, *buffd, *buffT; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6, k7; - FTYPE p00, p01, p02, p03, p04, - p10, p11, p12, p13, p14, - p20, p21, p22, p23, - p30, p31, p32, p33; - DEF_VARS(DTYPE); - DTYPE *sl1; - mlib_s32 chan2; - mlib_s32 *buffo, *buffi; - DTYPE *sl2, *sl3; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - buff3 = buff2 + wid; - buff4 = buff3 + wid; - buffd = buff4 + wid; - buffo = (mlib_s32*)(buffd + wid); - buffi = buffo + (wid &~ 1); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; - sl3 = sl2 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (FTYPE)sl[i*chan1]; - buff1[i] = (FTYPE)sl1[i*chan1]; - buff2[i] = (FTYPE)sl2[i*chan1]; - buff3[i] = (FTYPE)sl3[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - d64_2x32 dd; - - /* - * First loop on two first lines of kernel - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; - k4 = k[4]; k5 = k[5]; k6 = k[6]; k7 = k[7]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff1[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buff4[i ] = (FTYPE)dd.i32s.i0; - buff4[i + 1] = (FTYPE)dd.i32s.i1; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7); - - sp += chan2; - dp += chan2; - } - - /* - * Second loop on two last lines of kernel - */ - k0 = k[ 8]; k1 = k[ 9]; k2 = k[10]; k3 = k[11]; - k4 = k[12]; k5 = k[13]; k6 = k[14]; k7 = k[15]; - - sp = sl; - dp = dl; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - p04 = buff2[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + - p10 * k4 + p11 * k5 + p12 * k6 + p13 * k7 + buffd[i]); - d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + - p11 * k4 + p12 * k5 + p13 * k6 + p14 * k7 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - sp += chan2; - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - - buff4[i] = (FTYPE)sp[0]; - - buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + - p10 * k[4] + p11 * k[5] + p12 * k[6] + p13 * k[7] + - p20 * k[ 8] + p21 * k[ 9] + p22 * k[10] + p23 * k[11] + - p30 * k[12] + p31 * k[13] + p32 * k[14] + p33 * k[15]); - - dp[0] = FROM_S32(buffo[i]); - - sp += chan1; - dp += chan1; - } - - buff4[wid ] = (FTYPE)sp[0]; - buff4[wid + 1] = (FTYPE)sp[chan1]; - buff4[wid + 2] = (FTYPE)sp[chan2]; - - /* next line */ - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 5 - -mlib_status CONV_FUNC(5x5)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE]; - FTYPE *buff0, *buff1, *buff2, *buff3, *buff4, *buff5, *buffd, *buffT; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - FTYPE p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15, - p20, p21, p22, p23, p24, - p30, p31, p32, p33, p34, - p40, p41, p42, p43, p44; - DEF_VARS(DTYPE); - DTYPE *sl1; - mlib_s32 chan2; - mlib_s32 *buffo, *buffi; - DTYPE *sl2, *sl3, *sl4; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buff0 = pbuff; - buff1 = buff0 + wid; - buff2 = buff1 + wid; - buff3 = buff2 + wid; - buff4 = buff3 + wid; - buff5 = buff4 + wid; - buffd = buff5 + wid; - buffo = (mlib_s32*)(buffd + wid); - buffi = buffo + (wid &~ 1); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; - sl3 = sl2 + sll; - sl4 = sl3 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buff0[i] = (FTYPE)sl[i*chan1]; - buff1[i] = (FTYPE)sl1[i*chan1]; - buff2[i] = (FTYPE)sl2[i*chan1]; - buff3[i] = (FTYPE)sl3[i*chan1]; - buff4[i] = (FTYPE)sl4[i*chan1]; - } - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - d64_2x32 dd; - - /* - * First loop - */ - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - sp = sl; - dp = dl; - - p02 = buff0[0]; - p12 = buff1[0]; - p03 = buff0[1]; - p13 = buff1[1]; - p04 = buff0[2]; - p14 = buff1[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - - LOAD_BUFF(buffi); - - p03 = buff0[i + 3]; p13 = buff1[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; - p05 = buff0[i + 5]; p15 = buff1[i + 5]; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp += chan2; - dp += chan2; - } - - /* - * Second loop - */ - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - sp = sl; - dp = dl; - - p02 = buff2[0]; - p12 = buff3[0]; - p03 = buff2[1]; - p13 = buff3[1]; - p04 = buff2[2]; - p14 = buff3[2]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - - p02 = buff2[i + 2]; p12 = buff3[i + 2]; - p03 = buff2[i + 3]; p13 = buff3[i + 3]; - p04 = buff2[i + 4]; p14 = buff3[i + 4]; - p05 = buff2[i + 5]; p15 = buff3[i + 5]; - - dd.d64 = *(FTYPE *)(buffi + i); - buff5[i ] = (FTYPE)dd.i32s.i0; - buff5[i + 1] = (FTYPE)dd.i32s.i1; - - buffd[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp += chan2; - dp += chan2; - } - - /* - * 3 loop - */ - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - sp = sl; - dp = dl; - - p02 = buff4[0]; - p03 = buff4[1]; - p04 = buff4[2]; - p05 = buff4[3]; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = buff4[i + 4]; p05 = buff4[i + 5]; - - d0 = D2I(p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + buffd[i]); - d1 = D2I(p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - sp += chan2; - dp += chan2; - } - - /* last pixels */ - for (; i < wid; i++) { - p00 = buff0[i]; p10 = buff1[i]; p20 = buff2[i]; p30 = buff3[i]; - p01 = buff0[i + 1]; p11 = buff1[i + 1]; p21 = buff2[i + 1]; p31 = buff3[i + 1]; - p02 = buff0[i + 2]; p12 = buff1[i + 2]; p22 = buff2[i + 2]; p32 = buff3[i + 2]; - p03 = buff0[i + 3]; p13 = buff1[i + 3]; p23 = buff2[i + 3]; p33 = buff3[i + 3]; - p04 = buff0[i + 4]; p14 = buff1[i + 4]; p24 = buff2[i + 4]; p34 = buff3[i + 4]; - - p40 = buff4[i]; p41 = buff4[i + 1]; p42 = buff4[i + 2]; - p43 = buff4[i + 3]; p44 = buff4[i + 4]; - - buff5[i] = (FTYPE)sp[0]; - - buffo[i] = D2I(p00 * k[0] + p01 * k[1] + p02 * k[2] + p03 * k[3] + p04 * k[4] + - p10 * k[5] + p11 * k[6] + p12 * k[7] + p13 * k[8] + p14 * k[9] + - p20 * k[10] + p21 * k[11] + p22 * k[12] + p23 * k[13] + p24 * k[14] + - p30 * k[15] + p31 * k[16] + p32 * k[17] + p33 * k[18] + p34 * k[19] + - p40 * k[20] + p41 * k[21] + p42 * k[22] + p43 * k[23] + p44 * k[24]); - - dp[0] = FROM_S32(buffo[i]); - - sp += chan1; - dp += chan1; - } - - buff5[wid ] = (FTYPE)sp[0]; - buff5[wid + 1] = (FTYPE)sp[chan1]; - buff5[wid + 2] = (FTYPE)sp[chan2]; - buff5[wid + 3] = (FTYPE)sp[chan2 + chan1]; - - /* next line */ - sl += sll; - dl += dll; - - buffT = buff0; - buff0 = buff1; - buff1 = buff2; - buff2 = buff3; - buff3 = buff4; - buff4 = buff5; - buff5 = buffT; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#ifndef __sparc /* for x86, using integer multiplies is faster */ - -mlib_status CONV_FUNC_I(5x5)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - mlib_s32 buff[BUFF_LINE]; - mlib_s32 *buffd; - mlib_s32 k[KSIZE*KSIZE]; - mlib_s32 shift1, shift2; - mlib_s32 k0, k1, k2, k3, k4, k5, k6, k7, k8, k9; - mlib_s32 p00, p01, p02, p03, p04, p05, - p10, p11, p12, p13, p14, p15; - DTYPE *adr_src, *sl, *sp0, *sp1; - DTYPE *adr_dst, *dl, *dp; - mlib_s32 *pbuff = buff; - mlib_s32 wid, hgt, sll, dll; - mlib_s32 nchannel, chan1, chan2, chan3, chan4; - mlib_s32 i, j, c; - -#if IMG_TYPE != 1 - shift1 = 16; -#else - shift1 = 8; -#endif /* IMG_TYPE != 1 */ - - shift2 = scalef_expon - shift1; - - for (j = 0; j < KSIZE*KSIZE; j++) k[j] = kern[j] >> shift1; - - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc(sizeof(mlib_s32)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - buffd = pbuff; - - chan1 = nchannel; - chan2 = chan1 + chan1; - chan3 = chan2 + chan1; - chan4 = chan3 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < chan1; c++) { - if (!(cmask & (1 << (chan1 - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - for (j = 0; j < hgt; j++) { - mlib_s32 pix0, pix1; - /* - * First loop - */ - sp0 = sl; - sp1 = sp0 + sll; - dp = dl; - - k0 = k[0]; k1 = k[1]; k2 = k[2]; k3 = k[3]; k4 = k[4]; - k5 = k[5]; k6 = k[6]; k7 = k[7]; k8 = k[8]; k9 = k[9]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - p05 = sp0[chan3]; p15 = sp1[chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - buffd[i ] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] = (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - - buffd[i] = (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * Second loop - */ - sp0 = sl + 2*sll; - sp1 = sp0 + sll; - dp = dl; - - k0 = k[10]; k1 = k[11]; k2 = k[12]; k3 = k[13]; k4 = k[14]; - k5 = k[15]; k6 = k[16]; k7 = k[17]; k8 = k[18]; k9 = k[19]; - - p02 = sp0[0]; p12 = sp1[0]; - p03 = sp0[chan1]; p13 = sp1[chan1]; - p04 = sp0[chan2]; p14 = sp1[chan2]; - p05 = sp0[chan3]; p15 = sp1[chan3]; - - sp0 += chan4; - sp1 += chan4; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - p05 = sp0[chan1]; p15 = sp1[chan1]; - - buffd[i ] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - buffd[i + 1] += (p01 * k0 + p02 * k1 + p03 * k2 + p04 * k3 + p05 * k4 + - p11 * k5 + p12 * k6 + p13 * k7 + p14 * k8 + p15 * k9); - - sp0 += chan2; - sp1 += chan2; - dp += chan2; - } - - if (wid & 1) { - p00 = p02; p10 = p12; - p01 = p03; p11 = p13; - p02 = p04; p12 = p14; - p03 = p05; p13 = p15; - - p04 = sp0[0]; p14 = sp1[0]; - - buffd[i] += (p00 * k0 + p01 * k1 + p02 * k2 + p03 * k3 + p04 * k4 + - p10 * k5 + p11 * k6 + p12 * k7 + p13 * k8 + p14 * k9); - } - - /* - * 3 loop - */ - dp = dl; - sp0 = sl + 4*sll; - - k0 = k[20]; k1 = k[21]; k2 = k[22]; k3 = k[23]; k4 = k[24]; - - p02 = sp0[0]; - p03 = sp0[chan1]; - p04 = sp0[chan2]; - p05 = sp0[chan3]; - - sp0 += chan2 + chan2; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp0[0]; p05 = sp0[chan1]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - pix1 = (buffd[i + 1] + p01 * k0 + p02 * k1 + p03 * k2 + - p04 * k3 + p05 * k4) >> shift2; - - CLAMP_STORE(dp[0], pix0); - CLAMP_STORE(dp[chan1], pix1); - - dp += chan2; - sp0 += chan2; - } - - if (wid & 1) { - p00 = p02; p01 = p03; p02 = p04; p03 = p05; - - p04 = sp0[0]; - - pix0 = (buffd[i ] + p00 * k0 + p01 * k1 + p02 * k2 + - p03 * k3 + p04 * k4) >> shift2; - CLAMP_STORE(dp[0], pix0); - } - - /* next line */ - sl += sll; - dl += dll; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -#endif /* __sparc ( for x86, using integer multiplies is faster ) */ - -/***************************************************************/ -#if IMG_TYPE == 1 - -#undef KSIZE -#define KSIZE 7 - -mlib_status CONV_FUNC(7x7)(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scalef_expon, - mlib_s32 cmask) -{ - FTYPE buff[(KSIZE + 3)*BUFF_LINE], *buffs[2*(KSIZE + 1)], *buffd; - FTYPE k[KSIZE*KSIZE]; - mlib_s32 l, m, buff_ind; - mlib_s32 d0, d1; - FTYPE k0, k1, k2, k3, k4, k5, k6; - FTYPE p0, p1, p2, p3, p4, p5, p6, p7; - DTYPE *sl2, *sl3, *sl4, *sl5, *sl6; - DEF_VARS(DTYPE); - DTYPE *sl1; - mlib_s32 chan2; - mlib_s32 *buffo, *buffi; - LOAD_KERNEL(KSIZE*KSIZE); - GET_SRC_DST_PARAMETERS(DTYPE); - - if (wid > BUFF_LINE) { - pbuff = mlib_malloc((KSIZE + 3)*sizeof(FTYPE)*wid); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - for (l = 0; l < KSIZE + 1; l++) buffs[l] = pbuff + l*wid; - for (l = 0; l < KSIZE + 1; l++) buffs[l + (KSIZE + 1)] = buffs[l]; - buffd = buffs[KSIZE] + wid; - buffo = (mlib_s32*)(buffd + wid); - buffi = buffo + (wid &~ 1); - - chan1 = nchannel; - chan2 = chan1 + chan1; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - - adr_dst += ((KSIZE - 1)/2)*(dll + chan1); - - for (c = 0; c < nchannel; c++) { - if (!(cmask & (1 << (nchannel - 1 - c)))) continue; - - sl = adr_src + c; - dl = adr_dst + c; - - sl1 = sl + sll; - sl2 = sl1 + sll; - sl3 = sl2 + sll; - sl4 = sl3 + sll; - sl5 = sl4 + sll; - sl6 = sl5 + sll; -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid + (KSIZE - 1); i++) { - buffs[0][i] = (FTYPE)sl[i*chan1]; - buffs[1][i] = (FTYPE)sl1[i*chan1]; - buffs[2][i] = (FTYPE)sl2[i*chan1]; - buffs[3][i] = (FTYPE)sl3[i*chan1]; - buffs[4][i] = (FTYPE)sl4[i*chan1]; - buffs[5][i] = (FTYPE)sl5[i*chan1]; - buffs[6][i] = (FTYPE)sl6[i*chan1]; - } - - buff_ind = 0; - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i < wid; i++) buffd[i] = 0.0; - - sl += KSIZE*sll; - - for (j = 0; j < hgt; j++) { - FTYPE **buffc = buffs + buff_ind; - FTYPE *buffn = buffc[KSIZE]; - FTYPE *pk = k; - - for (l = 0; l < KSIZE; l++) { - FTYPE *buff = buffc[l]; - d64_2x32 dd; - - sp = sl; - dp = dl; - - p2 = buff[0]; p3 = buff[1]; p4 = buff[2]; - p5 = buff[3]; p6 = buff[4]; p7 = buff[5]; - - k0 = *pk++; k1 = *pk++; k2 = *pk++; k3 = *pk++; - k4 = *pk++; k5 = *pk++; k6 = *pk++; - - if (l < (KSIZE - 1)) { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - buffd[i ] += p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6; - buffd[i + 1] += p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6; - } - - } else { -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (i = 0; i <= (wid - 2); i += 2) { - p0 = p2; p1 = p3; p2 = p4; p3 = p5; p4 = p6; p5 = p7; - - p6 = buff[i + 6]; p7 = buff[i + 7]; - - LOAD_BUFF(buffi); - - dd.d64 = *(FTYPE *)(buffi + i); - buffn[i ] = (FTYPE)dd.i32s.i0; - buffn[i + 1] = (FTYPE)dd.i32s.i1; - - d0 = D2I(p0*k0 + p1*k1 + p2*k2 + p3*k3 + p4*k4 + p5*k5 + p6*k6 + buffd[i ]); - d1 = D2I(p1*k0 + p2*k1 + p3*k2 + p4*k3 + p5*k4 + p6*k5 + p7*k6 + buffd[i + 1]); - - dp[0 ] = FROM_S32(d0); - dp[chan1] = FROM_S32(d1); - - buffd[i ] = 0.0; - buffd[i + 1] = 0.0; - - sp += chan2; - dp += chan2; - } - } - } - - /* last pixels */ - for (; i < wid; i++) { - FTYPE *pk = k, s = 0; - mlib_s32 d0; - - for (l = 0; l < KSIZE; l++) { - FTYPE *buff = buffc[l] + i; - - for (m = 0; m < KSIZE; m++) s += buff[m] * (*pk++); - } - - d0 = D2I(s); - dp[0] = FROM_S32(d0); - - buffn[i] = (FTYPE)sp[0]; - - sp += chan1; - dp += chan1; - } - - for (l = 0; l < (KSIZE - 1); l++) buffn[wid + l] = sp[l*chan1]; - - /* next line */ - sl += sll; - dl += dll; - - buff_ind++; - - if (buff_ind >= KSIZE + 1) buff_ind = 0; - } - } - - if (pbuff != buff) mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -#endif /* IMG_TYPE == 1 */ - /***************************************************************/ #define MAX_KER 7 #define MAX_N 15 diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BC.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BC.c deleted file mode 100644 index cd763f534a4..00000000000 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BC.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -#include "mlib_image.h" -#include "mlib_ImageAffine.h" -#include "mlib_ImageColormap.h" - -/***************************************************************/ -#define MLIB_LIMIT 512 -#define MLIB_SHIFT 16 -#define MLIB_PREC (1 << MLIB_SHIFT) -#define MLIB_MASK (MLIB_PREC - 1) - -/***************************************************************/ -#define DTYPE MLIB_TYPE - -/***************************************************************/ -#define DECLAREVAR_IND() \ - DECLAREVAR0(); \ - mlib_s32 *warp_tbl = param -> warp_tbl; \ - mlib_s32 xSrc, ySrc; \ - mlib_s32 srcYStride = param -> srcYStride; \ - mlib_s32 max_xsize = param -> max_xsize; \ - mlib_filter filter = param -> filter; \ - MLIB_TYPE *sp, *dl; \ - mlib_d64 xf0, xf1, xf2, xf3; \ - mlib_d64 yf0, yf1, yf2, yf3; \ - mlib_d64 c0, c1, c2, c3, val0; \ - mlib_s32 filterpos; \ - mlib_f32 *fptr; \ - mlib_d64 s0, s1, s2, s3; \ - mlib_s32 i, size - -/***************************************************************/ -#define GET_FILTERS_KOEF() \ - filterpos = (X >> FILTER_SHIFT) & FILTER_MASK; \ - fptr = (mlib_f32 *) ((mlib_u8 *)mlib_filters_table + filterpos); \ - \ - xf0 = fptr[0]; \ - xf1 = fptr[1]; \ - xf2 = fptr[2]; \ - xf3 = fptr[3]; \ - \ - filterpos = (Y >> FILTER_SHIFT) & FILTER_MASK; \ - fptr = (mlib_f32 *) ((mlib_u8 *)mlib_filters_table + filterpos); \ - \ - yf0 = fptr[0]; \ - yf1 = fptr[1]; \ - yf2 = fptr[2]; \ - yf3 = fptr[3] - -/***************************************************************/ -#define GET_POINTER() \ - xSrc = (X >> MLIB_SHIFT)-1; \ - ySrc = (Y >> MLIB_SHIFT)-1; \ - sp = ((MLIB_TYPE **)lineAddr)[ySrc] + xSrc - -/***************************************************************/ -#define LOAD_FIRST_ROW(nchan, chan) \ - s0 = *(lut + sp[0]*nchan + chan); \ - s1 = *(lut + sp[1]*nchan + chan); \ - s2 = *(lut + sp[2]*nchan + chan); \ - s3 = *(lut + sp[3]*nchan + chan) - -/***************************************************************/ -#define COUNT_NEXT_ROW(dst, nchan, chan) \ - sp = (MLIB_TYPE*)((mlib_addr)sp + srcYStride); \ - dst = ((*(lut + sp[0]*nchan + chan))*xf0 + \ - (*(lut + sp[1]*nchan + chan))*xf1 + \ - (*(lut + sp[2]*nchan + chan))*xf2 + \ - (*(lut + sp[3]*nchan + chan))*xf3) - -/***************************************************************/ -#ifdef MLIB_USE_FTOI_CLAMPING - -/***********/ -#define STORE_SAT_VALUE_U8(ind) \ - dp[ind] = ((mlib_s32)(val0 - (mlib_d64)0x7F800000) >> 24) ^ 0x80 - -/***********/ -#define STORE_SAT_VALUE_S16(ind) \ - dp[ind] = ((mlib_s32)(val0)) >> 16 - -#else - -/***********/ -#define STORE_SAT_VALUE_U8(ind) \ - val0 -= (mlib_d64)0x7F800000; \ - if (val0 >= MLIB_S32_MAX) \ - dp[ind] = MLIB_U8_MAX; \ - else if (val0 <= MLIB_S32_MIN) \ - dp[ind] = MLIB_U8_MIN; \ - else \ - dp[ind] = ((mlib_s32)val0 >> 24) ^ 0x80 - -/***********/ -#define STORE_SAT_VALUE_S16(ind) \ - if (val0 >= MLIB_S32_MAX) \ - dp[ind] = MLIB_S16_MAX; \ - else if (val0 <= MLIB_S32_MIN) \ - dp[ind] = MLIB_S16_MIN; \ - else \ - dp[ind] = (mlib_s32)val0 >> 16 - -#endif /* MLIB_USE_FTOI_CLAMPING */ - -/***************************************************************/ -#define MAKE_BC_3CH(lut_format) \ - X += dX; \ - Y += dY; \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 3, 0); \ - COUNT_NEXT_ROW(c2, 3, 0); \ - COUNT_NEXT_ROW(c3, 3, 0); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride); \ - LOAD_FIRST_ROW(3, 1); \ - STORE_SAT_VALUE_##lut_format(0); \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 3, 1); \ - COUNT_NEXT_ROW(c2, 3, 1); \ - COUNT_NEXT_ROW(c3, 3, 1); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride); \ - LOAD_FIRST_ROW(3, 2); \ - STORE_SAT_VALUE_##lut_format(1); \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 3, 2); \ - COUNT_NEXT_ROW(c2, 3, 2); \ - COUNT_NEXT_ROW(c3, 3, 2); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - GET_FILTERS_KOEF(); \ - GET_POINTER(); \ - LOAD_FIRST_ROW(3, 0); \ - STORE_SAT_VALUE_##lut_format(2); - -/***************************************************************/ -#define MAKE_LAST_PIXEL_BC_3CH(lut_format) \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 3, 0); \ - COUNT_NEXT_ROW(c2, 3, 0); \ - COUNT_NEXT_ROW(c3, 3, 0); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride); \ - LOAD_FIRST_ROW(3, 1); \ - STORE_SAT_VALUE_##lut_format(0); \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 3, 1); \ - COUNT_NEXT_ROW(c2, 3, 1); \ - COUNT_NEXT_ROW(c3, 3, 1); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride); \ - LOAD_FIRST_ROW(3, 2); \ - STORE_SAT_VALUE_##lut_format(1); \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 3, 2); \ - COUNT_NEXT_ROW(c2, 3, 2); \ - COUNT_NEXT_ROW(c3, 3, 2); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - STORE_SAT_VALUE_##lut_format(2); - -/***************************************************************/ -#define MAKE_BC_4CH(lut_format) \ - X += dX; \ - Y += dY; \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 4, 0); \ - COUNT_NEXT_ROW(c2, 4, 0); \ - COUNT_NEXT_ROW(c3, 4, 0); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride); \ - LOAD_FIRST_ROW(4, 1); \ - STORE_SAT_VALUE_##lut_format(0); \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 4, 1); \ - COUNT_NEXT_ROW(c2, 4, 1); \ - COUNT_NEXT_ROW(c3, 4, 1); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride); \ - LOAD_FIRST_ROW(4, 2); \ - STORE_SAT_VALUE_##lut_format(1); \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 4, 2); \ - COUNT_NEXT_ROW(c2, 4, 2); \ - COUNT_NEXT_ROW(c3, 4, 2); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride); \ - LOAD_FIRST_ROW(4, 3); \ - STORE_SAT_VALUE_##lut_format(2); \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 4, 3); \ - COUNT_NEXT_ROW(c2, 4, 3); \ - COUNT_NEXT_ROW(c3, 4, 3); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - GET_FILTERS_KOEF(); \ - GET_POINTER(); \ - LOAD_FIRST_ROW(4, 0); \ - STORE_SAT_VALUE_##lut_format(3); - -/***************************************************************/ -#define MAKE_LAST_PIXEL_BC_4CH(lut_format) \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 4, 0); \ - COUNT_NEXT_ROW(c2, 4, 0); \ - COUNT_NEXT_ROW(c3, 4, 0); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride); \ - LOAD_FIRST_ROW(4, 1); \ - STORE_SAT_VALUE_##lut_format(0); \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 4, 1); \ - COUNT_NEXT_ROW(c2, 4, 1); \ - COUNT_NEXT_ROW(c3, 4, 1); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride); \ - LOAD_FIRST_ROW(4, 2); \ - STORE_SAT_VALUE_##lut_format(1); \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 4, 2); \ - COUNT_NEXT_ROW(c2, 4, 2); \ - COUNT_NEXT_ROW(c3, 4, 2); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - sp = (MLIB_TYPE*)((mlib_addr)sp - 3*srcYStride); \ - LOAD_FIRST_ROW(4, 3); \ - STORE_SAT_VALUE_##lut_format(2); \ - c0 = (s0*xf0 + s1*xf1 + s2*xf2 + s3*xf3); \ - COUNT_NEXT_ROW(c1, 4, 3); \ - COUNT_NEXT_ROW(c2, 4, 3); \ - COUNT_NEXT_ROW(c3, 4, 3); \ - val0 = (c0*yf0 + c1*yf1 + c2*yf2 + c3*yf3); \ - STORE_SAT_VALUE_##lut_format(3); - -/***************************************************************/ -#define FILTER_U8 ((filter == MLIB_BICUBIC) ? mlib_filters_u8f_bc : mlib_filters_u8f_bc2) -#define FILTER_S16 ((filter == MLIB_BICUBIC) ? mlib_filters_s16f_bc : mlib_filters_s16f_bc2) - -/***************************************************************/ -#define mlib_U8 mlib_u8 -#define mlib_S16 mlib_s16 - -/***************************************************************/ -#define FUNC_AFFINEINDEX_BC_0(ITYPE, LTYPE, NCHAN) \ - mlib_status mlib_ImageAffineIndex_##ITYPE##_##LTYPE##_##NCHAN##CH_BC(mlib_affine_param *param, \ - const void *colormap) \ - { \ - DECLAREVAR_IND(); \ - mlib_##LTYPE buff_lcl[NCHAN * MLIB_LIMIT], *pbuff = buff_lcl, *dp; \ - mlib_d64 *lut = ((mlib_d64*)mlib_ImageGetLutDoubleData(colormap) - \ - NCHAN * mlib_ImageGetLutOffset(colormap)); \ - const mlib_f32 *mlib_filters_table = FILTER_##LTYPE; \ - \ - if (max_xsize > MLIB_LIMIT) { \ - pbuff = mlib_malloc(NCHAN * sizeof(mlib_##LTYPE) * max_xsize); \ - if (pbuff == NULL) return MLIB_FAILURE; \ - } \ - \ - for (j = yStart; j <= yFinish; j++) { \ - \ - NEW_LINE(1); \ - dp = pbuff; \ - \ - GET_FILTERS_KOEF(); \ - GET_POINTER(); \ - LOAD_FIRST_ROW(NCHAN, 0); - - /* pragma pipeloop(0) must be here */ - -/***************************************************************/ -#define FUNC_AFFINEINDEX_BC_1(ITYPE, LTYPE, NCHAN) \ - \ - for (i = 0; i < (xRight - xLeft); i++, dp += NCHAN) { \ - MAKE_BC_##NCHAN##CH(LTYPE); \ - } \ - \ - MAKE_LAST_PIXEL_BC_##NCHAN##CH(LTYPE); \ - \ - mlib_ImageColorTrue2IndexLine_##LTYPE##_##ITYPE##_##NCHAN \ - (pbuff, dl, xRight - xLeft + 1, colormap); \ - } \ - \ - if (pbuff != buff_lcl) mlib_free(pbuff); \ - \ - return MLIB_SUCCESS; \ - } - -/***************************************************************/ -#undef MLIB_TYPE -#define MLIB_TYPE mlib_u8 - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 4 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 8) - 1) << 4) - -FUNC_AFFINEINDEX_BC_0(U8, U8, 3) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BC_1(U8, U8, 3) - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 3 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 9) - 1) << 4) - -FUNC_AFFINEINDEX_BC_0(U8, S16, 3) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BC_1(U8, S16, 3) - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 4 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 8) - 1) << 4) - -FUNC_AFFINEINDEX_BC_0(U8, U8, 4) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BC_1(U8, U8, 4) - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 3 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 9) - 1) << 4) - -FUNC_AFFINEINDEX_BC_0(U8, S16, 4) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BC_1(U8, S16, 4) - -/***************************************************************/ -#undef MLIB_TYPE -#define MLIB_TYPE mlib_s16 - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 4 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 8) - 1) << 4) - -FUNC_AFFINEINDEX_BC_0(S16, U8, 3) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BC_1(S16, U8, 3) - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 3 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 9) - 1) << 4) - -FUNC_AFFINEINDEX_BC_0(S16, S16, 3) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BC_1(S16, S16, 3) - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 4 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 8) - 1) << 4) - -FUNC_AFFINEINDEX_BC_0(S16, U8, 4) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BC_1(S16, U8, 4) - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 3 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 9) - 1) << 4) - -FUNC_AFFINEINDEX_BC_0(S16, S16, 4) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BC_1(S16, S16, 4) - -/***************************************************************/ diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BL.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BL.c deleted file mode 100644 index 83ef3e5b1f5..00000000000 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BL.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -#include "mlib_image.h" -#include "mlib_ImageAffine.h" -#include "mlib_ImageColormap.h" - -/***************************************************************/ -#define MLIB_LIMIT 512 - -/***************************************************************/ -#define DTYPE MLIB_TYPE - -/***************************************************************/ -#define DECLAREVAR_IND() \ - DECLAREVAR0(); \ - mlib_s32 *warp_tbl = param -> warp_tbl; \ - mlib_s32 xSrc, ySrc; \ - mlib_s32 srcYStride = param -> srcYStride; \ - mlib_s32 max_xsize = param -> max_xsize; \ - MLIB_TYPE *sp0, *sp1; \ - MLIB_TYPE *dl; \ - mlib_d64 scale = 1.0 / 65536.0; \ - mlib_s32 i, size - -/***************************************************************/ -#define DECLARE_INTERNAL_VAR_3CH() \ - mlib_d64 fdx, fdy; \ - mlib_d64 a00_0, a01_0, a10_0, a11_0; \ - mlib_d64 a00_1, a01_1, a10_1, a11_1; \ - mlib_d64 a00_2, a01_2, a10_2, a11_2; \ - mlib_d64 pix0_0, pix1_0, res0; \ - mlib_d64 pix0_1, pix1_1, res1; \ - mlib_d64 pix0_2, pix1_2, res2 - -/***************************************************************/ -#define DECLARE_INTERNAL_VAR_4CH() \ - mlib_d64 fdx, fdy; \ - mlib_d64 a00_0, a01_0, a10_0, a11_0; \ - mlib_d64 a00_1, a01_1, a10_1, a11_1; \ - mlib_d64 a00_2, a01_2, a10_2, a11_2; \ - mlib_d64 a00_3, a01_3, a10_3, a11_3; \ - mlib_d64 pix0_0, pix1_0, res0; \ - mlib_d64 pix0_1, pix1_1, res1; \ - mlib_d64 pix0_2, pix1_2, res2; \ - mlib_d64 pix0_3, pix1_3, res3 - -/***************************************************************/ -#define GET_PIXELS_POINTERS() \ - fdx = (X & MLIB_MASK) * scale; \ - fdy = (Y & MLIB_MASK) * scale; \ - ySrc = MLIB_POINTER_SHIFT(Y); Y += dY; \ - xSrc = X >> MLIB_SHIFT; X += dX; \ - sp0 = MLIB_POINTER_GET(lineAddr, ySrc) + xSrc; \ - sp1 = (MLIB_TYPE *)((mlib_u8 *)sp0 + srcYStride) - -/***************************************************************/ -#define GET_COLOR_POINTERS(ind) \ - pcolor00 = (lut + sp0[0]*ind); \ - pcolor10 = (lut + sp1[0]*ind); \ - pcolor01 = (lut + sp0[1]*ind); \ - pcolor11 = (lut + sp1[1]*ind) - -/***************************************************************/ -#define COUNT_BL_U8(ind) \ - pix0_##ind = a00_##ind + fdy * (a10_##ind - a00_##ind); \ - pix1_##ind = a01_##ind + fdy * (a11_##ind - a01_##ind); \ - res##ind = pix0_##ind + fdx * (pix1_##ind - pix0_##ind) + 0.5 - -/***************************************************************/ -#define COUNT_BL_U8_3CH() \ - COUNT_BL_U8(0); \ - COUNT_BL_U8(1); \ - COUNT_BL_U8(2); - -/***************************************************************/ -#define COUNT_BL_U8_4CH() \ - COUNT_BL_U8_3CH(); \ - COUNT_BL_U8(3); - -/***************************************************************/ -#define COUNT_BL_S16(ind) \ - pix0_##ind = a00_##ind + fdy * (a10_##ind - a00_##ind); \ - pix1_##ind = a01_##ind + fdy * (a11_##ind - a01_##ind); \ - res##ind = pix0_##ind + fdx * (pix1_##ind - pix0_##ind) - -/***************************************************************/ -#define COUNT_BL_S16_3CH() \ - COUNT_BL_S16(0); \ - COUNT_BL_S16(1); \ - COUNT_BL_S16(2); - -/***************************************************************/ -#define COUNT_BL_S16_4CH() \ - COUNT_BL_S16_3CH(); \ - COUNT_BL_S16(3); - -/***************************************************************/ -#define LOAD(ind) \ - a00_##ind = pcolor00[ind]; \ - a01_##ind = pcolor01[ind]; \ - a10_##ind = pcolor10[ind]; \ - a11_##ind = pcolor11[ind] - -/***************************************************************/ -#define LOAD_3CH() \ - LOAD(0); \ - LOAD(1); \ - LOAD(2); - -/***************************************************************/ -#define LOAD_4CH() \ - LOAD_3CH(); \ - LOAD(3); - -/***************************************************************/ -#define STORE_INTO_INTERM_BUF_3CH(LTYPE) \ - dp[0] = (mlib_##LTYPE)res0; \ - dp[1] = (mlib_##LTYPE)res1; \ - dp[2] = (mlib_##LTYPE)res2 - -/***************************************************************/ -#define STORE_INTO_INTERM_BUF_4CH(LTYPE) \ - dp[0] = (mlib_##LTYPE)res0; \ - dp[1] = (mlib_##LTYPE)res1; \ - dp[2] = (mlib_##LTYPE)res2; \ - dp[3] = (mlib_##LTYPE)res3 - -/***************************************************************/ -#undef MLIB_TYPE -#define MLIB_TYPE mlib_u8 - -/***************************************************************/ -#define mlib_U8 mlib_u8 -#define mlib_S16 mlib_s16 - -/***************************************************************/ -#define FUNC_AFFINEINDEX_BL_0(ITYPE, LTYPE, NCHAN) \ - mlib_status mlib_ImageAffineIndex_##ITYPE##_##LTYPE##_##NCHAN##CH_BL(mlib_affine_param *param, \ - const void *colormap) \ - { \ - DECLAREVAR_IND(); \ - mlib_##LTYPE *dp, buff_lcl[NCHAN*MLIB_LIMIT], *pbuff = buff_lcl; \ - mlib_d64 *pcolor00, *pcolor10, *pcolor01, *pcolor11; \ - mlib_d64 *lut = mlib_ImageGetLutDoubleData(colormap); \ - \ - lut -= NCHAN*mlib_ImageGetLutOffset(colormap); \ - \ - if (max_xsize > MLIB_LIMIT) { \ - pbuff = mlib_malloc(NCHAN * sizeof(mlib_##LTYPE) * max_xsize); \ - if (pbuff == NULL) return MLIB_FAILURE; \ - } \ - \ - for (j = yStart; j <= yFinish; j++) { \ - DECLARE_INTERNAL_VAR_##NCHAN##CH(); \ - \ - NEW_LINE(1); \ - dp = pbuff; \ - \ - GET_PIXELS_POINTERS(); \ - GET_COLOR_POINTERS(NCHAN); \ - LOAD_##NCHAN##CH(); - - /* pragma pipeloop(0) must be here */ - -/***************************************************************/ -#define FUNC_AFFINEINDEX_BL_1(ITYPE, LTYPE, NCHAN) \ - for (i = 0; i < (xRight - xLeft); i++, dp += NCHAN) { \ - COUNT_BL_##LTYPE##_##NCHAN##CH(); \ - \ - GET_PIXELS_POINTERS(); \ - GET_COLOR_POINTERS(NCHAN); \ - LOAD_##NCHAN##CH(); \ - \ - STORE_INTO_INTERM_BUF_##NCHAN##CH(LTYPE); \ - } \ - \ - COUNT_BL_##LTYPE##_##NCHAN##CH(); \ - STORE_INTO_INTERM_BUF_##NCHAN##CH(LTYPE); \ - \ - mlib_ImageColorTrue2IndexLine_##LTYPE##_##ITYPE##_##NCHAN \ - (pbuff, dl, xRight - xLeft + 1, colormap); \ - } \ - \ - if (pbuff != buff_lcl) mlib_free(pbuff); \ - \ - return MLIB_SUCCESS; \ - } - -/***************************************************************/ -#undef MLIB_TYPE -#define MLIB_TYPE mlib_u8 - -FUNC_AFFINEINDEX_BL_0(U8, U8, 3) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BL_1(U8, U8, 3) - -FUNC_AFFINEINDEX_BL_0(U8, S16, 3) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BL_1(U8, S16, 3) - -FUNC_AFFINEINDEX_BL_0(U8, U8, 4) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BL_1(U8, U8, 4) - -FUNC_AFFINEINDEX_BL_0(U8, S16, 4) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BL_1(U8, S16, 4) - -/***************************************************************/ -#undef MLIB_TYPE -#define MLIB_TYPE mlib_s16 - -FUNC_AFFINEINDEX_BL_0(S16, U8, 3) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BL_1(S16, U8, 3) - -FUNC_AFFINEINDEX_BL_0(S16, S16, 3) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BL_1(S16, S16, 3) - -FUNC_AFFINEINDEX_BL_0(S16, U8, 4) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BL_1(S16, U8, 4) - -FUNC_AFFINEINDEX_BL_0(S16, S16, 4) -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ -FUNC_AFFINEINDEX_BL_1(S16, S16, 4) - -/***************************************************************/ -const type_affine_i_fun mlib_AffineFunArr_bl_i[] = { - mlib_ImageAffineIndex_U8_U8_3CH_BL, - mlib_ImageAffineIndex_U8_U8_4CH_BL, - mlib_ImageAffineIndex_S16_U8_3CH_BL, - mlib_ImageAffineIndex_S16_U8_4CH_BL, - mlib_ImageAffineIndex_U8_S16_3CH_BL, - mlib_ImageAffineIndex_U8_S16_4CH_BL, - mlib_ImageAffineIndex_S16_S16_3CH_BL, - mlib_ImageAffineIndex_S16_S16_4CH_BL -}; -/***************************************************************/ diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.c deleted file mode 100644 index 2447f769e69..00000000000 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include -#include "mlib_c_ImageBlendTable.h" - -const mlib_f32 mlib_c_blend_u8[] = { - 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, - 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, - 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, - 24.0f, 25.0f, 26.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, - 32.0f, 33.0f, 34.0f, 35.0f, 36.0f, 37.0f, 38.0f, 39.0f, - 40.0f, 41.0f, 42.0f, 43.0f, 44.0f, 45.0f, 46.0f, 47.0f, - 48.0f, 49.0f, 50.0f, 51.0f, 52.0f, 53.0f, 54.0f, 55.0f, - 56.0f, 57.0f, 58.0f, 59.0f, 60.0f, 61.0f, 62.0f, 63.0f, - 64.0f, 65.0f, 66.0f, 67.0f, 68.0f, 69.0f, 70.0f, 71.0f, - 72.0f, 73.0f, 74.0f, 75.0f, 76.0f, 77.0f, 78.0f, 79.0f, - 80.0f, 81.0f, 82.0f, 83.0f, 84.0f, 85.0f, 86.0f, 87.0f, - 88.0f, 89.0f, 90.0f, 91.0f, 92.0f, 93.0f, 94.0f, 95.0f, - 96.0f, 97.0f, 98.0f, 99.0f, 100.0f, 101.0f, 102.0f, 103.0f, - 104.0f, 105.0f, 106.0f, 107.0f, 108.0f, 109.0f, 110.0f, 111.0f, - 112.0f, 113.0f, 114.0f, 115.0f, 116.0f, 117.0f, 118.0f, 119.0f, - 120.0f, 121.0f, 122.0f, 123.0f, 124.0f, 125.0f, 126.0f, 127.0f, - 128.0f, 129.0f, 130.0f, 131.0f, 132.0f, 133.0f, 134.0f, 135.0f, - 136.0f, 137.0f, 138.0f, 139.0f, 140.0f, 141.0f, 142.0f, 143.0f, - 144.0f, 145.0f, 146.0f, 147.0f, 148.0f, 149.0f, 150.0f, 151.0f, - 152.0f, 153.0f, 154.0f, 155.0f, 156.0f, 157.0f, 158.0f, 159.0f, - 160.0f, 161.0f, 162.0f, 163.0f, 164.0f, 165.0f, 166.0f, 167.0f, - 168.0f, 169.0f, 170.0f, 171.0f, 172.0f, 173.0f, 174.0f, 175.0f, - 176.0f, 177.0f, 178.0f, 179.0f, 180.0f, 181.0f, 182.0f, 183.0f, - 184.0f, 185.0f, 186.0f, 187.0f, 188.0f, 189.0f, 190.0f, 191.0f, - 192.0f, 193.0f, 194.0f, 195.0f, 196.0f, 197.0f, 198.0f, 199.0f, - 200.0f, 201.0f, 202.0f, 203.0f, 204.0f, 205.0f, 206.0f, 207.0f, - 208.0f, 209.0f, 210.0f, 211.0f, 212.0f, 213.0f, 214.0f, 215.0f, - 216.0f, 217.0f, 218.0f, 219.0f, 220.0f, 221.0f, 222.0f, 223.0f, - 224.0f, 225.0f, 226.0f, 227.0f, 228.0f, 229.0f, 230.0f, 231.0f, - 232.0f, 233.0f, 234.0f, 235.0f, 236.0f, 237.0f, 238.0f, 239.0f, - 240.0f, 241.0f, 242.0f, 243.0f, 244.0f, 245.0f, 246.0f, 247.0f, - 248.0f, 249.0f, 250.0f, 251.0f, 252.0f, 253.0f, 254.0f, 255.0f, - 256.0f -}; - -const mlib_f32 mlib_c_blend_Q8[] = { - 0.00000000f, 0.00390625f, 0.00781250f, 0.01171875f, - 0.01562500f, 0.01953125f, 0.02343750f, 0.02734375f, - 0.03125000f, 0.03515625f, 0.03906250f, 0.04296875f, - 0.04687500f, 0.05078125f, 0.05468750f, 0.05859375f, - 0.06250000f, 0.06640625f, 0.07031250f, 0.07421875f, - 0.07812500f, 0.08203125f, 0.08593750f, 0.08984375f, - 0.09375000f, 0.09765625f, 0.10156250f, 0.10546875f, - 0.10937500f, 0.11328125f, 0.11718750f, 0.12109375f, - 0.12500000f, 0.12890625f, 0.13281250f, 0.13671875f, - 0.14062500f, 0.14453125f, 0.14843750f, 0.15234375f, - 0.15625000f, 0.16015625f, 0.16406250f, 0.16796875f, - 0.17187500f, 0.17578125f, 0.17968750f, 0.18359375f, - 0.18750000f, 0.19140625f, 0.19531250f, 0.19921875f, - 0.20312500f, 0.20703125f, 0.21093750f, 0.21484375f, - 0.21875000f, 0.22265625f, 0.22656250f, 0.23046875f, - 0.23437500f, 0.23828125f, 0.24218750f, 0.24609375f, - 0.25000000f, 0.25390625f, 0.25781250f, 0.26171875f, - 0.26562500f, 0.26953125f, 0.27343750f, 0.27734375f, - 0.28125000f, 0.28515625f, 0.28906250f, 0.29296875f, - 0.29687500f, 0.30078125f, 0.30468750f, 0.30859375f, - 0.31250000f, 0.31640625f, 0.32031250f, 0.32421875f, - 0.32812500f, 0.33203125f, 0.33593750f, 0.33984375f, - 0.34375000f, 0.34765625f, 0.35156250f, 0.35546875f, - 0.35937500f, 0.36328125f, 0.36718750f, 0.37109375f, - 0.37500000f, 0.37890625f, 0.38281250f, 0.38671875f, - 0.39062500f, 0.39453125f, 0.39843750f, 0.40234375f, - 0.40625000f, 0.41015625f, 0.41406250f, 0.41796875f, - 0.42187500f, 0.42578125f, 0.42968750f, 0.43359375f, - 0.43750000f, 0.44140625f, 0.44531250f, 0.44921875f, - 0.45312500f, 0.45703125f, 0.46093750f, 0.46484375f, - 0.46875000f, 0.47265625f, 0.47656250f, 0.48046875f, - 0.48437500f, 0.48828125f, 0.49218750f, 0.49609375f, - 0.50000000f, 0.50390625f, 0.50781250f, 0.51171875f, - 0.51562500f, 0.51953125f, 0.52343750f, 0.52734375f, - 0.53125000f, 0.53515625f, 0.53906250f, 0.54296875f, - 0.54687500f, 0.55078125f, 0.55468750f, 0.55859375f, - 0.56250000f, 0.56640625f, 0.57031250f, 0.57421875f, - 0.57812500f, 0.58203125f, 0.58593750f, 0.58984375f, - 0.59375000f, 0.59765625f, 0.60156250f, 0.60546875f, - 0.60937500f, 0.61328125f, 0.61718750f, 0.62109375f, - 0.62500000f, 0.62890625f, 0.63281250f, 0.63671875f, - 0.64062500f, 0.64453125f, 0.64843750f, 0.65234375f, - 0.65625000f, 0.66015625f, 0.66406250f, 0.66796875f, - 0.67187500f, 0.67578125f, 0.67968750f, 0.68359375f, - 0.68750000f, 0.69140625f, 0.69531250f, 0.69921875f, - 0.70312500f, 0.70703125f, 0.71093750f, 0.71484375f, - 0.71875000f, 0.72265625f, 0.72656250f, 0.73046875f, - 0.73437500f, 0.73828125f, 0.74218750f, 0.74609375f, - 0.75000000f, 0.75390625f, 0.75781250f, 0.76171875f, - 0.76562500f, 0.76953125f, 0.77343750f, 0.77734375f, - 0.78125000f, 0.78515625f, 0.78906250f, 0.79296875f, - 0.79687500f, 0.80078125f, 0.80468750f, 0.80859375f, - 0.81250000f, 0.81640625f, 0.82031250f, 0.82421875f, - 0.82812500f, 0.83203125f, 0.83593750f, 0.83984375f, - 0.84375000f, 0.84765625f, 0.85156250f, 0.85546875f, - 0.85937500f, 0.86328125f, 0.86718750f, 0.87109375f, - 0.87500000f, 0.87890625f, 0.88281250f, 0.88671875f, - 0.89062500f, 0.89453125f, 0.89843750f, 0.90234375f, - 0.90625000f, 0.91015625f, 0.91406250f, 0.91796875f, - 0.92187500f, 0.92578125f, 0.92968750f, 0.93359375f, - 0.93750000f, 0.94140625f, 0.94531250f, 0.94921875f, - 0.95312500f, 0.95703125f, 0.96093750f, 0.96484375f, - 0.96875000f, 0.97265625f, 0.97656250f, 0.98046875f, - 0.98437500f, 0.98828125f, 0.99218750f, 0.99609375f, - 1.00000000f, 1.00390625f, 1.00781250f, 1.01171875f, - 1.01562500f, 1.01953125f, 1.02343750f, 1.02734375f, - 1.03125000f, 1.03515625f, 1.03906250f, 1.04296875f, - 1.04687500f, 1.05078125f, 1.05468750f, 1.05859375f, - 1.06250000f, 1.06640625f, 1.07031250f, 1.07421875f, - 1.07812500f, 1.08203125f, 1.08593750f, 1.08984375f, - 1.09375000f, 1.09765625f, 1.10156250f, 1.10546875f, - 1.10937500f, 1.11328125f, 1.11718750f, 1.12109375f, - 1.12500000f, 1.12890625f, 1.13281250f, 1.13671875f, - 1.14062500f, 1.14453125f, 1.14843750f, 1.15234375f, - 1.15625000f, 1.16015625f, 1.16406250f, 1.16796875f, - 1.17187500f, 1.17578125f, 1.17968750f, 1.18359375f, - 1.18750000f, 1.19140625f, 1.19531250f, 1.19921875f, - 1.20312500f, 1.20703125f, 1.21093750f, 1.21484375f, - 1.21875000f, 1.22265625f, 1.22656250f, 1.23046875f, - 1.23437500f, 1.23828125f, 1.24218750f, 1.24609375f, - 1.25000000f, 1.25390625f, 1.25781250f, 1.26171875f, - 1.26562500f, 1.26953125f, 1.27343750f, 1.27734375f, - 1.28125000f, 1.28515625f, 1.28906250f, 1.29296875f, - 1.29687500f, 1.30078125f, 1.30468750f, 1.30859375f, - 1.31250000f, 1.31640625f, 1.32031250f, 1.32421875f, - 1.32812500f, 1.33203125f, 1.33593750f, 1.33984375f, - 1.34375000f, 1.34765625f, 1.35156250f, 1.35546875f, - 1.35937500f, 1.36328125f, 1.36718750f, 1.37109375f, - 1.37500000f, 1.37890625f, 1.38281250f, 1.38671875f, - 1.39062500f, 1.39453125f, 1.39843750f, 1.40234375f, - 1.40625000f, 1.41015625f, 1.41406250f, 1.41796875f, - 1.42187500f, 1.42578125f, 1.42968750f, 1.43359375f, - 1.43750000f, 1.44140625f, 1.44531250f, 1.44921875f, - 1.45312500f, 1.45703125f, 1.46093750f, 1.46484375f, - 1.46875000f, 1.47265625f, 1.47656250f, 1.48046875f, - 1.48437500f, 1.48828125f, 1.49218750f, 1.49609375f, - 1.50000000f, 1.50390625f, 1.50781250f, 1.51171875f, - 1.51562500f, 1.51953125f, 1.52343750f, 1.52734375f, - 1.53125000f, 1.53515625f, 1.53906250f, 1.54296875f, - 1.54687500f, 1.55078125f, 1.55468750f, 1.55859375f, - 1.56250000f, 1.56640625f, 1.57031250f, 1.57421875f, - 1.57812500f, 1.58203125f, 1.58593750f, 1.58984375f, - 1.59375000f, 1.59765625f, 1.60156250f, 1.60546875f, - 1.60937500f, 1.61328125f, 1.61718750f, 1.62109375f, - 1.62500000f, 1.62890625f, 1.63281250f, 1.63671875f, - 1.64062500f, 1.64453125f, 1.64843750f, 1.65234375f, - 1.65625000f, 1.66015625f, 1.66406250f, 1.66796875f, - 1.67187500f, 1.67578125f, 1.67968750f, 1.68359375f, - 1.68750000f, 1.69140625f, 1.69531250f, 1.69921875f, - 1.70312500f, 1.70703125f, 1.71093750f, 1.71484375f, - 1.71875000f, 1.72265625f, 1.72656250f, 1.73046875f, - 1.73437500f, 1.73828125f, 1.74218750f, 1.74609375f, - 1.75000000f, 1.75390625f, 1.75781250f, 1.76171875f, - 1.76562500f, 1.76953125f, 1.77343750f, 1.77734375f, - 1.78125000f, 1.78515625f, 1.78906250f, 1.79296875f, - 1.79687500f, 1.80078125f, 1.80468750f, 1.80859375f, - 1.81250000f, 1.81640625f, 1.82031250f, 1.82421875f, - 1.82812500f, 1.83203125f, 1.83593750f, 1.83984375f, - 1.84375000f, 1.84765625f, 1.85156250f, 1.85546875f, - 1.85937500f, 1.86328125f, 1.86718750f, 1.87109375f, - 1.87500000f, 1.87890625f, 1.88281250f, 1.88671875f, - 1.89062500f, 1.89453125f, 1.89843750f, 1.90234375f, - 1.90625000f, 1.91015625f, 1.91406250f, 1.91796875f, - 1.92187500f, 1.92578125f, 1.92968750f, 1.93359375f, - 1.93750000f, 1.94140625f, 1.94531250f, 1.94921875f, - 1.95312500f, 1.95703125f, 1.96093750f, 1.96484375f, - 1.96875000f, 1.97265625f, 1.97656250f, 1.98046875f, - 1.98437500f, 1.98828125f, 1.99218750f, 1.99609375f, - 2.00000000f -}; - -const mlib_f32 mlib_c_blend_u8_sat[] = { - 0.0f, 8388608.0f, 16777216.0f, 25165824.0f, - 33554432.0f, 41943040.0f, 50331648.0f, 58720256.0f, - 67108864.0f, 75497472.0f, 83886080.0f, 92274688.0f, - 100663296.0f, 109051904.0f, 117440512.0f, 125829120.0f, - 134217728.0f, 142606336.0f, 150994944.0f, 159383552.0f, - 167772160.0f, 176160768.0f, 184549376.0f, 192937984.0f, - 201326592.0f, 209715200.0f, 218103808.0f, 226492416.0f, - 234881024.0f, 243269632.0f, 251658240.0f, 260046848.0f, - 268435456.0f, 276824064.0f, 285212672.0f, 293601280.0f, - 301989888.0f, 310378496.0f, 318767104.0f, 327155712.0f, - 335544320.0f, 343932928.0f, 352321536.0f, 360710144.0f, - 369098752.0f, 377487360.0f, 385875968.0f, 394264576.0f, - 402653184.0f, 411041792.0f, 419430400.0f, 427819008.0f, - 436207616.0f, 444596224.0f, 452984832.0f, 461373440.0f, - 469762048.0f, 478150656.0f, 486539264.0f, 494927872.0f, - 503316480.0f, 511705088.0f, 520093696.0f, 528482304.0f, - 536870912.0f, 545259520.0f, 553648128.0f, 562036736.0f, - 570425344.0f, 578813952.0f, 587202560.0f, 595591168.0f, - 603979776.0f, 612368384.0f, 620756992.0f, 629145600.0f, - 637534208.0f, 645922816.0f, 654311424.0f, 662700032.0f, - 671088640.0f, 679477248.0f, 687865856.0f, 696254464.0f, - 704643072.0f, 713031680.0f, 721420288.0f, 729808896.0f, - 738197504.0f, 746586112.0f, 754974720.0f, 763363328.0f, - 771751936.0f, 780140544.0f, 788529152.0f, 796917760.0f, - 805306368.0f, 813694976.0f, 822083584.0f, 830472192.0f, - 838860800.0f, 847249408.0f, 855638016.0f, 864026624.0f, - 872415232.0f, 880803840.0f, 889192448.0f, 897581056.0f, - 905969664.0f, 914358272.0f, 922746880.0f, 931135488.0f, - 939524096.0f, 947912704.0f, 956301312.0f, 964689920.0f, - 973078528.0f, 981467136.0f, 989855744.0f, 998244352.0f, - 1006632960.0f, 1015021568.0f, 1023410176.0f, 1031798784.0f, - 1040187392.0f, 1048576000.0f, 1056964608.0f, 1065353216.0f, - 1073741824.0f, 1082130432.0f, 1090519040.0f, 1098907648.0f, - 1107296256.0f, 1115684864.0f, 1124073472.0f, 1132462080.0f, - 1140850688.0f, 1149239296.0f, 1157627904.0f, 1166016512.0f, - 1174405120.0f, 1182793728.0f, 1191182336.0f, 1199570944.0f, - 1207959552.0f, 1216348160.0f, 1224736768.0f, 1233125376.0f, - 1241513984.0f, 1249902592.0f, 1258291200.0f, 1266679808.0f, - 1275068416.0f, 1283457024.0f, 1291845632.0f, 1300234240.0f, - 1308622848.0f, 1317011456.0f, 1325400064.0f, 1333788672.0f, - 1342177280.0f, 1350565888.0f, 1358954496.0f, 1367343104.0f, - 1375731712.0f, 1384120320.0f, 1392508928.0f, 1400897536.0f, - 1409286144.0f, 1417674752.0f, 1426063360.0f, 1434451968.0f, - 1442840576.0f, 1451229184.0f, 1459617792.0f, 1468006400.0f, - 1476395008.0f, 1484783616.0f, 1493172224.0f, 1501560832.0f, - 1509949440.0f, 1518338048.0f, 1526726656.0f, 1535115264.0f, - 1543503872.0f, 1551892480.0f, 1560281088.0f, 1568669696.0f, - 1577058304.0f, 1585446912.0f, 1593835520.0f, 1602224128.0f, - 1610612736.0f, 1619001344.0f, 1627389952.0f, 1635778560.0f, - 1644167168.0f, 1652555776.0f, 1660944384.0f, 1669332992.0f, - 1677721600.0f, 1686110208.0f, 1694498816.0f, 1702887424.0f, - 1711276032.0f, 1719664640.0f, 1728053248.0f, 1736441856.0f, - 1744830464.0f, 1753219072.0f, 1761607680.0f, 1769996288.0f, - 1778384896.0f, 1786773504.0f, 1795162112.0f, 1803550720.0f, - 1811939328.0f, 1820327936.0f, 1828716544.0f, 1837105152.0f, - 1845493760.0f, 1853882368.0f, 1862270976.0f, 1870659584.0f, - 1879048192.0f, 1887436800.0f, 1895825408.0f, 1904214016.0f, - 1912602624.0f, 1920991232.0f, 1929379840.0f, 1937768448.0f, - 1946157056.0f, 1954545664.0f, 1962934272.0f, 1971322880.0f, - 1979711488.0f, 1988100096.0f, 1996488704.0f, 2004877312.0f, - 2013265920.0f, 2021654528.0f, 2030043136.0f, 2038431744.0f, - 2046820352.0f, 2055208960.0f, 2063597568.0f, 2071986176.0f, - 2080374784.0f, 2088763392.0f, 2097152000.0f, 2105540608.0f, - 2113929216.0f, 2122317824.0f, 2130706432.0f, 2139095040.0f, - 2147483648.0f -}; diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.h deleted file mode 100644 index 2e95d502478..00000000000 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * These tables are used by C versions of the - * mlib_ImageBlend_... functions. - */ - -#ifndef MLIB_C_IMAGE_BLEND_TABLE_H -#define MLIB_C_IMAGE_BLEND_TABLE_H - -#include "mlib_image.h" - -extern const mlib_f32 mlib_c_blend_u8[]; -extern const mlib_f32 mlib_U82F32[]; -extern const mlib_f32 mlib_c_blend_Q8[]; -extern const mlib_f32 mlib_c_blend_u8_sat[]; - -#endif /* MLIB_C_IMAGEF_BLEND_TABLE_H */ diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv.h index 41fb98072b9..8097c7d11ed 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv.h +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv.h @@ -41,118 +41,6 @@ return status; \ } #endif /* FREE_AND_RETURN_STATUS */ -mlib_status mlib_c_conv2x2ext_s16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv2x2ext_u16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv2x2ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv2x2nw_s16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv2x2nw_u16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv2x2nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv3x3ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv3x3nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv4x4ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv4x4nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv5x5ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv5x5nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv7x7ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_c_conv7x7nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - mlib_status mlib_c_convMxNnw_u8(mlib_image *dst, const mlib_image *src, const mlib_s32 *kernel, @@ -177,102 +65,6 @@ mlib_status mlib_c_convMxNext_u8(mlib_image *dst, #if ! defined ( __sparc ) /* for x86, using integer multiplies is faster */ -mlib_status mlib_i_conv3x3ext_s16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_i_conv3x3ext_u16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_i_conv3x3ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_i_conv3x3nw_s16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_i_conv3x3nw_u16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_i_conv3x3nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_i_conv5x5ext_s16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_i_conv5x5ext_u16(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_i_conv5x5ext_u8(mlib_image *dst, - const mlib_image *src, - mlib_s32 dx_l, - mlib_s32 dx_r, - mlib_s32 dy_t, - mlib_s32 dy_b, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_i_conv5x5nw_s16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_i_conv5x5nw_u16(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_i_conv5x5nw_u8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - mlib_status mlib_i_convMxNnw_s16(mlib_image *dst, const mlib_image *src, const mlib_s32 *kernel, diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv_f.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv_f.c index de4276b9bc3..825f973779e 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv_f.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageConv_f.c @@ -28,34 +28,6 @@ #include "mlib_ImageConv.h" #include "mlib_c_ImageConv.h" -/***************************************************************/ -#define MLIB_PARAMS_CONV_NW \ - mlib_image *dst, \ - const mlib_image *src, \ - const mlib_s32 *kern, \ - mlib_s32 scale, \ - mlib_s32 cmask - -/***************************************************************/ -#define MLIB_CALL_PARAMS_CONV_NW \ - dst, src, kern, scale, cmask - -/***************************************************************/ -#define MLIB_PARAMS_CONV_EXT \ - mlib_image *dst, \ - const mlib_image *src, \ - mlib_s32 dx_l, \ - mlib_s32 dx_r, \ - mlib_s32 dy_t, \ - mlib_s32 dy_b, \ - const mlib_s32 *kern, \ - mlib_s32 scale, \ - mlib_s32 cmask - -/***************************************************************/ -#define MLIB_CALL_PARAMS_CONV_EXT \ - dst, src, dx_l, dx_r, dy_t, dy_b, kern, scale, cmask - /***************************************************************/ #define MLIB_PARAMS_CONV_MN_NW \ mlib_image *dst, \ @@ -91,52 +63,6 @@ dst, src, kern, m, n, dx_l, dx_r, dy_t, dy_b, scale, cmask -/***************************************************************/ -mlib_status mlib_conv2x2nw_u8(MLIB_PARAMS_CONV_NW) -{ - return mlib_c_conv2x2nw_u8(MLIB_CALL_PARAMS_CONV_NW); -} - -/***************************************************************/ -mlib_status mlib_conv3x3nw_u8(MLIB_PARAMS_CONV_NW) -{ -#ifdef __sparc - return mlib_c_conv3x3nw_u8(MLIB_CALL_PARAMS_CONV_NW); -#else - - if (mlib_ImageConvVersion(3, 3, scale, MLIB_BYTE) == 0) - return mlib_c_conv3x3nw_u8(MLIB_CALL_PARAMS_CONV_NW); - else - return mlib_i_conv3x3nw_u8(MLIB_CALL_PARAMS_CONV_NW); -#endif /* __sparc */ -} - -/***************************************************************/ -mlib_status mlib_conv4x4nw_u8(MLIB_PARAMS_CONV_NW) -{ - return mlib_c_conv4x4nw_u8(MLIB_CALL_PARAMS_CONV_NW); -} - -/***************************************************************/ -mlib_status mlib_conv5x5nw_u8(MLIB_PARAMS_CONV_NW) -{ -#ifdef __sparc - return mlib_c_conv5x5nw_u8(MLIB_CALL_PARAMS_CONV_NW); -#else - - if (mlib_ImageConvVersion(5, 5, scale, MLIB_BYTE) == 0) - return mlib_c_conv5x5nw_u8(MLIB_CALL_PARAMS_CONV_NW); - else - return mlib_i_conv5x5nw_u8(MLIB_CALL_PARAMS_CONV_NW); -#endif /* __sparc */ -} - -/***************************************************************/ -mlib_status mlib_conv7x7nw_u8(MLIB_PARAMS_CONV_NW) -{ - return mlib_c_conv7x7nw_u8(MLIB_CALL_PARAMS_CONV_NW); -} - /***************************************************************/ mlib_status mlib_convMxNnw_u8(MLIB_PARAMS_CONV_MN_NW) { @@ -151,52 +77,6 @@ mlib_status mlib_convMxNnw_u8(MLIB_PARAMS_CONV_MN_NW) #endif /* __sparc */ } -/***************************************************************/ -mlib_status mlib_conv2x2ext_u8(MLIB_PARAMS_CONV_EXT) -{ - return mlib_c_conv2x2ext_u8(MLIB_CALL_PARAMS_CONV_EXT); -} - -/***************************************************************/ -mlib_status mlib_conv3x3ext_u8(MLIB_PARAMS_CONV_EXT) -{ -#ifdef __sparc - return mlib_c_conv3x3ext_u8(MLIB_CALL_PARAMS_CONV_EXT); -#else - - if (mlib_ImageConvVersion(3, 3, scale, MLIB_BYTE) == 0) - return mlib_c_conv3x3ext_u8(MLIB_CALL_PARAMS_CONV_EXT); - else - return mlib_i_conv3x3ext_u8(MLIB_CALL_PARAMS_CONV_EXT); -#endif /* __sparc */ -} - -/***************************************************************/ -mlib_status mlib_conv4x4ext_u8(MLIB_PARAMS_CONV_EXT) -{ - return mlib_c_conv4x4ext_u8(MLIB_CALL_PARAMS_CONV_EXT); -} - -/***************************************************************/ -mlib_status mlib_conv5x5ext_u8(MLIB_PARAMS_CONV_EXT) -{ -#ifdef __sparc - return mlib_c_conv5x5ext_u8(MLIB_CALL_PARAMS_CONV_EXT); -#else - - if (mlib_ImageConvVersion(5, 5, scale, MLIB_BYTE) == 0) - return mlib_c_conv5x5ext_u8(MLIB_CALL_PARAMS_CONV_EXT); - else - return mlib_i_conv5x5ext_u8(MLIB_CALL_PARAMS_CONV_EXT); -#endif /* __sparc */ -} - -/***************************************************************/ -mlib_status mlib_conv7x7ext_u8(MLIB_PARAMS_CONV_EXT) -{ - return mlib_c_conv7x7ext_u8(MLIB_CALL_PARAMS_CONV_EXT); -} - /***************************************************************/ mlib_status mlib_convMxNext_u8(MLIB_PARAMS_CONV_MN_EXT) { @@ -212,27 +92,3 @@ mlib_status mlib_convMxNext_u8(MLIB_PARAMS_CONV_MN_EXT) } /***************************************************************/ -mlib_status mlib_conv2x2nw_s16(MLIB_PARAMS_CONV_NW) -{ - return mlib_c_conv2x2nw_s16(MLIB_CALL_PARAMS_CONV_NW); -} - -/***************************************************************/ -mlib_status mlib_conv2x2nw_u16(MLIB_PARAMS_CONV_NW) -{ - return mlib_c_conv2x2nw_u16(MLIB_CALL_PARAMS_CONV_NW); -} - -/***************************************************************/ -mlib_status mlib_conv2x2ext_s16(MLIB_PARAMS_CONV_EXT) -{ - return mlib_c_conv2x2ext_s16(MLIB_CALL_PARAMS_CONV_EXT); -} - -/***************************************************************/ -mlib_status mlib_conv2x2ext_u16(MLIB_PARAMS_CONV_EXT) -{ - return mlib_c_conv2x2ext_u16(MLIB_CALL_PARAMS_CONV_EXT); -} - -/***************************************************************/ diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1.h deleted file mode 100644 index 54449b45da2..00000000000 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -#ifndef __MLIB_C_IMAGETHRESH1_H -#define __MLIB_C_IMAGETHRESH1_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/***************************************************************/ -#define PARAMS \ - void *psrc, \ - void *pdst, \ - mlib_s32 src_stride, \ - mlib_s32 dst_stride, \ - mlib_s32 width, \ - mlib_s32 height, \ - void *__thresh, \ - void *__ghigh, \ - void *__glow - -void mlib_c_ImageThresh1_D641(PARAMS); -void mlib_c_ImageThresh1_D642(PARAMS); -void mlib_c_ImageThresh1_D643(PARAMS); -void mlib_c_ImageThresh1_D644(PARAMS); -void mlib_c_ImageThresh1_D641_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_D642_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_D643_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_D644_1B(PARAMS, mlib_s32 dbit_off); - -void mlib_c_ImageThresh1_F321(PARAMS); -void mlib_c_ImageThresh1_F322(PARAMS); -void mlib_c_ImageThresh1_F323(PARAMS); -void mlib_c_ImageThresh1_F324(PARAMS); -void mlib_c_ImageThresh1_F321_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_F322_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_F323_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_F324_1B(PARAMS, mlib_s32 dbit_off); - -void mlib_c_ImageThresh1_S321(PARAMS); -void mlib_c_ImageThresh1_S322(PARAMS); -void mlib_c_ImageThresh1_S323(PARAMS); -void mlib_c_ImageThresh1_S324(PARAMS); -void mlib_c_ImageThresh1_S321_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_S322_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_S323_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_S324_1B(PARAMS, mlib_s32 dbit_off); - -void mlib_c_ImageThresh1_S161(PARAMS); -void mlib_c_ImageThresh1_S162(PARAMS); -void mlib_c_ImageThresh1_S163(PARAMS); -void mlib_c_ImageThresh1_S164(PARAMS); -void mlib_c_ImageThresh1_S161_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_S162_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_S163_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_S164_1B(PARAMS, mlib_s32 dbit_off); - -void mlib_c_ImageThresh1_U161(PARAMS); -void mlib_c_ImageThresh1_U162(PARAMS); -void mlib_c_ImageThresh1_U163(PARAMS); -void mlib_c_ImageThresh1_U164(PARAMS); -void mlib_c_ImageThresh1_U161_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_U162_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_U163_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_U164_1B(PARAMS, mlib_s32 dbit_off); - -void mlib_c_ImageThresh1_U81(PARAMS); -void mlib_c_ImageThresh1_U82(PARAMS); -void mlib_c_ImageThresh1_U83(PARAMS); -void mlib_c_ImageThresh1_U84(PARAMS); -void mlib_c_ImageThresh1_U81_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_U82_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_U83_1B(PARAMS, mlib_s32 dbit_off); -void mlib_c_ImageThresh1_U84_1B(PARAMS, mlib_s32 dbit_off); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __MLIB_C_IMAGETHRESH1_H */ diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1_U8.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1_U8.c deleted file mode 100644 index d16b069109c..00000000000 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1_U8.c +++ /dev/null @@ -1,848 +0,0 @@ -/* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * FUNCTION - * mlib_ImageThresh1 - thresholding - * - * SYNOPSIS - * mlib_status mlib_ImageThresh1(mlib_image *dst, - * const mlib_image *src, - * const mlib_s32 *thresh, - * const mlib_s32 *ghigh, - * const mlib_s32 *glow); - * - * ARGUMENT - * dst pointer to output image - * src pointer to input image - * thresh array of thresholds - * ghigh array of values above thresholds - * glow array of values below thresholds - * - * RESTRICTION - * The images must have the same size, and the same number - * of channels. - * The images can have 1, 2, 3, or 4 channels. - * The images can be in MLIB_BYTE, MLIB_SHORT or MLIB_INT data type. - * The type of the output image can be MLIB_BIT, or the same as the - * type of the input image. - * - * DESCRIPTION - * If the pixel band value is above the threshold for that channel, - * set the destination to the ghigh value for that channel. - * Otherwise, set the destination to the glow value for that channel. - * - * +- glow[c] src[x][y][c] <= thresh[c] - * dst[x][y][c] = | - * +- ghigh[c] src[x][y][c] > thresh[c] - */ - -#include "mlib_image.h" -#include "mlib_ImageCheck.h" -#include "mlib_c_ImageThresh1.h" - -/***************************************************************/ -#define STYPE mlib_u8 -#define TTYPE mlib_s32 -#define T_SHIFT 31 - -/***************************************************************/ -#define DO_THRESH(s0, th, gl, gh) \ - (((gh) & (((th) - (TTYPE)(s0)) >> T_SHIFT)) | \ - ((gl) &~ (((th) - (TTYPE)(s0)) >> T_SHIFT))) - -/***************************************************************/ -#define THRESH1_CMP_SHIFT(s0, th, sh) \ - ((((th) - (s0)) >> T_SHIFT) & (1 << (sh))) - -/***************************************************************/ -#define STRIP(pd, ps, w, h, ch, th, gh, gl) { \ - STYPE s0; \ - for ( i = 0; i < h; i++ ) { \ - for (j = 0; j < w; j ++) { \ - for (k = 0; k < ch; k++) { \ - s0 = ((STYPE*)ps)[i*src_stride + j*ch + k]; \ - ((STYPE*)pd)[i*dst_stride + j*ch + k] = \ - (s0 <= th[k]) ? gl[k]: gh[k]; \ - } \ - } \ - } \ - } - -/***************************************************************/ -#define INIT_THRESH0(n) \ - thresh0 = thresh[n]; \ - ghigh0 = ghigh[n]; \ - glow0 = glow[n] - -/***************************************************************/ -#define INIT_THRESH1(n) \ - thresh1 = thresh[n]; \ - ghigh1 = ghigh[n]; \ - glow1 = glow[n] - -/***************************************************************/ -#define INIT_THRESH2(n) \ - thresh2 = thresh[n]; \ - ghigh2 = ghigh[n]; \ - glow2 = glow[n] - -/***************************************************************/ -#define INIT_THRESH3(n) \ - thresh3 = thresh[n]; \ - ghigh3 = ghigh[n]; \ - glow3 = glow[n] - -/***************************************************************/ -#define THRESH0(s0) DO_THRESH(s0, thresh0, glow0, ghigh0) -#define THRESH1(s0) DO_THRESH(s0, thresh1, glow1, ghigh1) -#define THRESH2(s0) DO_THRESH(s0, thresh2, glow2, ghigh2) -#define THRESH3(s0) DO_THRESH(s0, thresh3, glow3, ghigh3) - -/***************************************************************/ -void mlib_c_ImageThresh1_U81(PARAMS) -{ - mlib_s32 *thresh = (void *)__thresh; - mlib_s32 *ghigh = (void *)__ghigh; - mlib_s32 *glow = (void *)__glow; - STYPE *psrc_row = psrc; - STYPE *pdst_row = pdst; - TTYPE thresh0; - TTYPE ghigh0; - TTYPE glow0; - mlib_s32 i, j, k; - - if (width < 16) { - STRIP(pdst, psrc, width, height, 1, thresh, ghigh, glow); - return; - } - - INIT_THRESH0(0); - - for (i = 0; i < height; i++) { - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (j = 0; j <= (width - 8); j += 8) { - pdst_row[j] = THRESH0(psrc_row[j]); - pdst_row[j + 1] = THRESH0(psrc_row[j + 1]); - pdst_row[j + 2] = THRESH0(psrc_row[j + 2]); - pdst_row[j + 3] = THRESH0(psrc_row[j + 3]); - pdst_row[j + 4] = THRESH0(psrc_row[j + 4]); - pdst_row[j + 5] = THRESH0(psrc_row[j + 5]); - pdst_row[j + 6] = THRESH0(psrc_row[j + 6]); - pdst_row[j + 7] = THRESH0(psrc_row[j + 7]); - } - - for (; j < width; j++) { - pdst_row[j] = THRESH0(psrc_row[j]); - } - - psrc_row += src_stride; - pdst_row += dst_stride; - } -} - -/***************************************************************/ -void mlib_c_ImageThresh1_U82(PARAMS) -{ - mlib_s32 *thresh = (void *)__thresh; - mlib_s32 *ghigh = (void *)__ghigh; - mlib_s32 *glow = (void *)__glow; - STYPE *psrc_row = psrc; - STYPE *pdst_row = pdst; - TTYPE thresh0, thresh1; - TTYPE ghigh0, ghigh1; - TTYPE glow0, glow1; - mlib_s32 i, j, k; - - if (width < 16) { - STRIP(pdst, psrc, width, height, 2, thresh, ghigh, glow); - return; - } - - INIT_THRESH0(0); - INIT_THRESH1(1); - width <<= 1; - - for (i = 0; i < height; i++) { - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (j = 0; j <= (width - 8); j += 8) { - pdst_row[j] = THRESH0(psrc_row[j]); - pdst_row[j + 1] = THRESH1(psrc_row[j + 1]); - pdst_row[j + 2] = THRESH0(psrc_row[j + 2]); - pdst_row[j + 3] = THRESH1(psrc_row[j + 3]); - pdst_row[j + 4] = THRESH0(psrc_row[j + 4]); - pdst_row[j + 5] = THRESH1(psrc_row[j + 5]); - pdst_row[j + 6] = THRESH0(psrc_row[j + 6]); - pdst_row[j + 7] = THRESH1(psrc_row[j + 7]); - } - - for (; j < width; j += 2) { - pdst_row[j] = THRESH0(psrc_row[j]); - pdst_row[j + 1] = THRESH1(psrc_row[j + 1]); - } - - psrc_row += src_stride; - pdst_row += dst_stride; - } -} - -/***************************************************************/ -void mlib_c_ImageThresh1_U83(PARAMS) -{ - mlib_s32 *thresh = (void *)__thresh; - mlib_s32 *ghigh = (void *)__ghigh; - mlib_s32 *glow = (void *)__glow; - STYPE *psrc_row = psrc; - STYPE *pdst_row = pdst; - TTYPE thresh0, thresh1, thresh2; - TTYPE ghigh0, ghigh1, ghigh2; - TTYPE glow0, glow1, glow2; - mlib_s32 i, j, k; - - if (width < 16) { - STRIP(pdst, psrc, width, height, 3, thresh, ghigh, glow); - return; - } - - width = 3 * width; - INIT_THRESH0(0); - INIT_THRESH1(1); - INIT_THRESH2(2); - - for (i = 0; i < height; i++) { - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (j = 0; j <= (width - 12); j += 12) { - pdst_row[j] = THRESH0(psrc_row[j]); - pdst_row[j + 1] = THRESH1(psrc_row[j + 1]); - pdst_row[j + 2] = THRESH2(psrc_row[j + 2]); - pdst_row[j + 3] = THRESH0(psrc_row[j + 3]); - pdst_row[j + 4] = THRESH1(psrc_row[j + 4]); - pdst_row[j + 5] = THRESH2(psrc_row[j + 5]); - pdst_row[j + 6] = THRESH0(psrc_row[j + 6]); - pdst_row[j + 7] = THRESH1(psrc_row[j + 7]); - pdst_row[j + 8] = THRESH2(psrc_row[j + 8]); - pdst_row[j + 9] = THRESH0(psrc_row[j + 9]); - pdst_row[j + 10] = THRESH1(psrc_row[j + 10]); - pdst_row[j + 11] = THRESH2(psrc_row[j + 11]); - } - - for (; j < width; j += 3) { - pdst_row[j] = THRESH0(psrc_row[j]); - pdst_row[j + 1] = THRESH1(psrc_row[j + 1]); - pdst_row[j + 2] = THRESH2(psrc_row[j + 2]); - } - - psrc_row += src_stride; - pdst_row += dst_stride; - } -} - -/***************************************************************/ -void mlib_c_ImageThresh1_U84(PARAMS) -{ - mlib_s32 *thresh = (void *)__thresh; - mlib_s32 *ghigh = (void *)__ghigh; - mlib_s32 *glow = (void *)__glow; - STYPE *psrc_row = psrc; - STYPE *pdst_row = pdst; - TTYPE thresh0, thresh1, thresh2, thresh3; - TTYPE ghigh0, ghigh1, ghigh2, ghigh3; - TTYPE glow0, glow1, glow2, glow3; - mlib_s32 i, j, k; - - if (width < 16) { - STRIP(pdst, psrc, width, height, 4, thresh, ghigh, glow); - return; - } - - INIT_THRESH0(0); - INIT_THRESH1(1); - INIT_THRESH2(2); - INIT_THRESH3(3); - - width *= 4; - - for (i = 0; i < height; i++) { - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (j = 0; j <= (width - 8); j += 8) { - pdst_row[j] = THRESH0(psrc_row[j]); - pdst_row[j + 1] = THRESH1(psrc_row[j + 1]); - pdst_row[j + 2] = THRESH2(psrc_row[j + 2]); - pdst_row[j + 3] = THRESH3(psrc_row[j + 3]); - pdst_row[j + 4] = THRESH0(psrc_row[j + 4]); - pdst_row[j + 5] = THRESH1(psrc_row[j + 5]); - pdst_row[j + 6] = THRESH2(psrc_row[j + 6]); - pdst_row[j + 7] = THRESH3(psrc_row[j + 7]); - } - - if (j < width) { - pdst_row[j] = THRESH0(psrc_row[j]); - pdst_row[j + 1] = THRESH1(psrc_row[j + 1]); - pdst_row[j + 2] = THRESH2(psrc_row[j + 2]); - pdst_row[j + 3] = THRESH3(psrc_row[j + 3]); - } - - psrc_row += src_stride; - pdst_row += dst_stride; - } -} - -/***************************************************************/ -void mlib_c_ImageThresh1_U81_1B(PARAMS, - mlib_s32 dbit_off) -{ - mlib_s32 *thresh = (void *)__thresh; - mlib_s32 *ghigh = (void *)__ghigh; - mlib_s32 *glow = (void *)__glow; - STYPE *psrc_row = psrc; - mlib_u8 *pdst_row = pdst; - TTYPE thresh0 = thresh[0]; - mlib_s32 mhigh, mlow, emask, dst0; - mlib_s32 i, j, jbit, l; - - mhigh = (ghigh[0] > 0) ? 0xff : 0; - mlow = (glow[0] > 0) ? 0xff : 0; - - for (i = 0; i < height; i++) { - j = 0; - jbit = 0; - - if (dbit_off) { - mlib_s32 nume = 8 - dbit_off; - - if (nume > width) - nume = width; - dst0 = 0; - emask = 0; - - for (; j < nume; j++) { - emask |= (1 << (7 - (dbit_off + j))); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j)); - } - - dst0 = (mhigh & dst0) | (mlow & ~dst0); - pdst_row[0] = (dst0 & emask) | (pdst_row[0] & ~emask); - jbit++; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (; j <= (width - 16); j += 16) { - dst0 = THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh0, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh0, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh0, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh0, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh0, 0); - dst0 = (mhigh & dst0) | (mlow & ~dst0); - *(pdst_row + jbit) = (mlib_u8) dst0; - jbit++; - dst0 = THRESH1_CMP_SHIFT(psrc_row[j + 8], thresh0, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 9], thresh0, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 10], thresh0, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 11], thresh0, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 12], thresh0, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 13], thresh0, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 14], thresh0, 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 15], thresh0, 0); - dst0 = (mhigh & dst0) | (mlow & ~dst0); - *(pdst_row + jbit) = (mlib_u8) dst0; - jbit++; - } - - if (width - j >= 8) { - dst0 = THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh0, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh0, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh0, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh0, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh0, 0); - dst0 = (mhigh & dst0) | (mlow & ~dst0); - *(pdst_row + jbit) = (mlib_u8) dst0; - jbit++; - j += 8; - } - - if (j < width) { - dst0 = 0; - l = 7; - for (; j < width; j++) { - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, l); - l--; - } - - emask = (0xFF << (l + 1)); - dst0 = (mhigh & dst0) | (mlow & ~dst0); - pdst_row[jbit] = (dst0 & emask) | (pdst_row[jbit] & ~emask); - } - - psrc_row += src_stride; - pdst_row += dst_stride; - } -} - -/***************************************************************/ -void mlib_c_ImageThresh1_U82_1B(PARAMS, - mlib_s32 dbit_off) -{ - mlib_s32 *thresh = (void *)__thresh; - mlib_s32 *ghigh = (void *)__ghigh; - mlib_s32 *glow = (void *)__glow; - STYPE *psrc_row = psrc; - mlib_u8 *pdst_row = pdst; - TTYPE thresh0 = thresh[0], thresh1 = thresh[1]; - mlib_s32 mhigh0, mlow0, mhigh, mlow, emask, dst0; - mlib_s32 i, j, jbit, l; - - mhigh0 = (ghigh[0] > 0) ? 0xaaa : 0; - mhigh0 |= (ghigh[1] > 0) ? 0x555 : 0; - mlow0 = (glow[0] > 0) ? 0xaaa : 0; - mlow0 |= (glow[1] > 0) ? 0x555 : 0; - - width *= 2; - - for (i = 0; i < height; i++) { - thresh0 = thresh[0]; - thresh1 = thresh[1]; - - j = 0; - jbit = 0; - mhigh = mhigh0 >> (dbit_off & 1); - mlow = mlow0 >> (dbit_off & 1); - - if (dbit_off) { - mlib_s32 nume = 8 - dbit_off; - - if (nume > width) - nume = width; - dst0 = 0; - emask = 0; - - for (; j <= (nume - 2); j += 2) { - emask |= (3 << (6 - (dbit_off + j))); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j)); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6 - (dbit_off + j)); - } - - if (j < nume) { - emask |= (1 << (7 - (dbit_off + j))); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j)); - /* swap threshes */ - thresh0 = thresh[1]; - thresh1 = thresh[0]; - j++; - } - - dst0 = (mhigh & dst0) | (mlow & ~dst0); - pdst_row[0] = (dst0 & emask) | (pdst_row[0] & ~emask); - jbit++; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (; j <= (width - 16); j += 16) { - dst0 = THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh0, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh1, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh1, 0); - dst0 = (mhigh & dst0) | (mlow & ~dst0); - *(pdst_row + jbit) = (mlib_u8) dst0; - jbit++; - dst0 = THRESH1_CMP_SHIFT(psrc_row[j + 8], thresh0, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 9], thresh1, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 10], thresh0, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 11], thresh1, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 12], thresh0, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 13], thresh1, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 14], thresh0, 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 15], thresh1, 0); - dst0 = (mhigh & dst0) | (mlow & ~dst0); - *(pdst_row + jbit) = (mlib_u8) dst0; - jbit++; - } - - if (width - j >= 8) { - dst0 = THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh0, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh1, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh1, 0); - dst0 = (mhigh & dst0) | (mlow & ~dst0); - *(pdst_row + jbit) = (mlib_u8) dst0; - jbit++; - j += 8; - } - - if (j < width) { - dst0 = 0; - l = 7; - for (; j <= (width - 2); j += 2) { - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, l); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, l - 1); - l -= 2; - } - - if (j < width) { - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, l); - l--; - } - - emask = (0xFF << (l + 1)); - dst0 = (mhigh & dst0) | (mlow & ~dst0); - pdst_row[jbit] = (dst0 & emask) | (pdst_row[jbit] & ~emask); - } - - psrc_row += src_stride; - pdst_row += dst_stride; - } -} - -/***************************************************************/ -void mlib_c_ImageThresh1_U83_1B(PARAMS, - mlib_s32 dbit_off) -{ - mlib_s32 *thresh = (void *)__thresh; - mlib_s32 *ghigh = (void *)__ghigh; - mlib_s32 *glow = (void *)__glow; - STYPE *psrc_row = psrc; - mlib_u8 *pdst_row = pdst; - TTYPE thresh0, thresh1, thresh2, threshT; - mlib_s32 mhigh = 0, mlow = 0; - mlib_s32 mhigh0, mlow0, mhigh1, mlow1, mhigh2, mlow2, emask, dst0, dst1; - mlib_s32 i, j, jbit, k, l; - - if (ghigh[0] > 0) - mhigh = 0x492492; - - if (ghigh[1] > 0) - mhigh |= 0x249249; - - if (ghigh[2] > 0) - mhigh |= 0x924924; - - if (glow[0] > 0) - mlow = 0x492492; - - if (glow[1] > 0) - mlow |= 0x249249; - - if (glow[2] > 0) - mlow |= 0x924924; - - width = 3 * width; - - for (i = 0; i < height; i++) { - thresh0 = thresh[0]; - thresh1 = thresh[1]; - thresh2 = thresh[2]; - - j = 0; - jbit = 0; - mhigh0 = mhigh >> (dbit_off & 7); - mlow0 = mlow >> (dbit_off & 7); - mhigh1 = mhigh0 >> 1; - mlow1 = mlow0 >> 1; - mhigh2 = mhigh0 >> 2; - mlow2 = mlow0 >> 2; - - if (dbit_off) { - mlib_s32 nume = 8 - dbit_off; - - if (nume > width) - nume = width; - dst0 = 0; - emask = 0; - - for (; j <= (nume - 3); j += 3) { - emask |= (7 << (5 - (dbit_off + j))); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j)); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6 - (dbit_off + j)); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5 - (dbit_off + j)); - } - - for (; j < nume; j++) { - emask |= (1 << (7 - (dbit_off + j))); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j)); - /* swap threshes */ - threshT = thresh0; - thresh0 = thresh1; - thresh1 = thresh2; - thresh2 = threshT; - } - - dst0 = (mhigh0 & dst0) | (mlow0 & ~dst0); - pdst_row[0] = (dst0 & emask) | (pdst_row[0] & ~emask); - jbit++; - - mhigh0 = mhigh >> (9 - nume); - mlow0 = mlow >> (9 - nume); - mhigh1 = mhigh0 >> 1; - mlow1 = mlow0 >> 1; - mhigh2 = mhigh0 >> 2; - mlow2 = mlow0 >> 2; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (; j <= (width - 24); j += 24) { - dst0 = (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh0, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh1, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh2, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh0, 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh1, 0)); - dst0 = (mhigh0 & dst0) | (mlow0 & ~dst0); - *(pdst_row + jbit) = dst0; - jbit++; - dst0 = (THRESH1_CMP_SHIFT(psrc_row[j + 8], thresh2, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 9], thresh0, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 10], thresh1, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 11], thresh2, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 12], thresh0, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 13], thresh1, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 14], thresh2, 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 15], thresh0, 0)); - dst0 = (mhigh1 & dst0) | (mlow1 & ~dst0); - *(pdst_row + jbit) = dst0; - jbit++; - dst0 = (THRESH1_CMP_SHIFT(psrc_row[j + 16], thresh1, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 17], thresh2, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 18], thresh0, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 19], thresh1, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 20], thresh2, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 21], thresh0, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 22], thresh1, 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 23], thresh2, 0)); - dst0 = (mhigh2 & dst0) | (mlow2 & ~dst0); - *(pdst_row + jbit) = dst0; - jbit++; - } - - if (j < width) { - k = width - j; - dst0 = 0; - l = 31; - for (; j < width; j += 3) { - dst0 |= (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, l) | - THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, l - 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, l - 2)); - l -= 3; - } - - l = (k + 7) >> 3; - k = (l << 3) - k; - emask = (0xFF << k); - - if (l == 3) { - dst1 = dst0 >> 24; - dst1 = (mhigh0 & dst1) | (mlow0 & ~dst1); - pdst_row[jbit] = dst1; - dst1 = (dst0 >> 16); - dst1 = (mhigh1 & dst1) | (mlow1 & ~dst1); - pdst_row[jbit + 1] = dst1; - dst1 = (dst0 >> 8); - dst1 = (mhigh2 & dst1) | (mlow2 & ~dst1); - pdst_row[jbit + 2] = (dst1 & emask) | (pdst_row[jbit + 2] & ~emask); - } - else if (l == 2) { - dst1 = dst0 >> 24; - dst1 = (mhigh0 & dst1) | (mlow0 & ~dst1); - pdst_row[jbit] = dst1; - dst1 = (dst0 >> 16); - dst1 = (mhigh1 & dst1) | (mlow1 & ~dst1); - pdst_row[jbit + 1] = (dst1 & emask) | (pdst_row[jbit + 1] & ~emask); - } - else { - dst1 = dst0 >> 24; - dst1 = (mhigh0 & dst1) | (mlow0 & ~dst1); - pdst_row[jbit] = (dst1 & emask) | (pdst_row[jbit] & ~emask); - } - } - - psrc_row += src_stride; - pdst_row += dst_stride; - } -} - -/***************************************************************/ -void mlib_c_ImageThresh1_U84_1B(PARAMS, - mlib_s32 dbit_off) -{ - mlib_s32 *thresh = (void *)__thresh; - mlib_s32 *ghigh = (void *)__ghigh; - mlib_s32 *glow = (void *)__glow; - STYPE *psrc_row = psrc; - mlib_u8 *pdst_row = pdst; - TTYPE thresh0, thresh1, thresh2, thresh3, threshT; - mlib_s32 mhigh0, mlow0, mhigh, mlow, emask, dst0; - mlib_s32 i, j, jbit; - - mhigh0 = (ghigh[0] > 0) ? 0x8888 : 0; - mhigh0 |= (ghigh[1] > 0) ? 0x4444 : 0; - mhigh0 |= (ghigh[2] > 0) ? 0x2222 : 0; - mhigh0 |= (ghigh[3] > 0) ? 0x1111 : 0; - - mlow0 = (glow[0] > 0) ? 0x8888 : 0; - mlow0 |= (glow[1] > 0) ? 0x4444 : 0; - mlow0 |= (glow[2] > 0) ? 0x2222 : 0; - mlow0 |= (glow[3] > 0) ? 0x1111 : 0; - - width *= 4; - - for (i = 0; i < height; i++) { - thresh0 = thresh[0]; - thresh1 = thresh[1]; - thresh2 = thresh[2]; - thresh3 = thresh[3]; - - j = 0; - jbit = 0; - mhigh = mhigh0 >> dbit_off; - mlow = mlow0 >> dbit_off; - - if (dbit_off) { - mlib_s32 nume = 8 - dbit_off; - - if (nume > width) - nume = width; - dst0 = 0; - emask = 0; - - for (; j <= (nume - 4); j += 4) { - emask |= (0xf << (4 - (dbit_off + j))); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j)); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6 - (dbit_off + j)); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5 - (dbit_off + j)); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh3, 4 - (dbit_off + j)); - } - - for (; j < nume; j++) { - emask |= (1 << (7 - (dbit_off + j))); - dst0 |= THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7 - (dbit_off + j)); - /* swap threshes */ - threshT = thresh0; - thresh0 = thresh1; - thresh1 = thresh2; - thresh2 = thresh3; - thresh3 = threshT; - } - - dst0 = (mhigh & dst0) | (mlow & ~dst0); - pdst_row[0] = (dst0 & emask) | (pdst_row[0] & ~emask); - jbit++; - } - -#ifdef __SUNPRO_C -#pragma pipeloop(0) -#endif /* __SUNPRO_C */ - for (; j <= (width - 16); j += 16) { - dst0 = (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh3, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh2, 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh3, 0)); - dst0 = (mhigh & dst0) | (mlow & ~dst0); - pdst_row[jbit] = dst0; - jbit++; - dst0 = (THRESH1_CMP_SHIFT(psrc_row[j + 8], thresh0, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 9], thresh1, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 10], thresh2, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 11], thresh3, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 12], thresh0, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 13], thresh1, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 14], thresh2, 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 15], thresh3, 0)); - dst0 = (mhigh & dst0) | (mlow & ~dst0); - pdst_row[jbit] = dst0; - jbit++; - } - - if (j <= width - 8) { - dst0 = (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh3, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh2, 1) | - THRESH1_CMP_SHIFT(psrc_row[j + 7], thresh3, 0)); - dst0 = (mhigh & dst0) | (mlow & ~dst0); - pdst_row[jbit] = dst0; - jbit++; - j += 8; - } - - if (j < width) { - dst0 = (THRESH1_CMP_SHIFT(psrc_row[j], thresh0, 7) | - THRESH1_CMP_SHIFT(psrc_row[j + 1], thresh1, 6) | - THRESH1_CMP_SHIFT(psrc_row[j + 2], thresh2, 5) | - THRESH1_CMP_SHIFT(psrc_row[j + 3], thresh3, 4) | - THRESH1_CMP_SHIFT(psrc_row[j + 4], thresh0, 3) | - THRESH1_CMP_SHIFT(psrc_row[j + 5], thresh1, 2) | - THRESH1_CMP_SHIFT(psrc_row[j + 6], thresh2, 1)); - - emask = (0xFF << (8 - (width - j))); - dst0 = (mhigh & dst0) | (mlow & ~dst0); - pdst_row[jbit] = (dst0 & emask) | (pdst_row[jbit] & ~emask); - } - - psrc_row += src_stride; - pdst_row += dst_stride; - } -} - -/***************************************************************/ diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_image.h index 60d776a8558..ae1d2247fd2 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image.h +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_image.h @@ -35,7 +35,6 @@ #include #include #include -#include #include #endif /* MLIB_IMAGE_H */ diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_blend_proto.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_blend_proto.h deleted file mode 100644 index 5a7b0017d5f..00000000000 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_blend_proto.h +++ /dev/null @@ -1,1448 +0,0 @@ -/* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -#ifndef __ORIG_MLIB_IMAGE_BLEND_PROTO_H -#define __ORIG_MLIB_IMAGE_BLEND_PROTO_H - -#include -#include -#include -#if defined ( __MEDIALIB_OLD_NAMES_ADDED ) -#include <../include/mlib_image_blend_proto.h> -#endif /* defined ( __MEDIALIB_OLD_NAMES_ADDED ) */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#if defined ( _MSC_VER ) -#if ! defined ( __MEDIALIB_OLD_NAMES ) -#define __MEDIALIB_OLD_NAMES -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -#endif /* defined ( _MSC_VER ) */ - -/*********************************************************************** - - NOTE: f = min(ALPHAsrc2, 1 - ALPHAsrc1) - f = min(ALPHAscr2, 1 - ALPHAsrc1dst) for In-place function - ALPHA = (ALPHA, ALPHA, ALPHA, ALPHA) - -************************************************************************/ - -/* dst = 0 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_ZERO mlib_ImageBlend_ZERO_ZERO -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_ZERO(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = 0 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_ZERO_Inp mlib_ImageBlend_ZERO_ZERO_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_ZERO_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_ONE mlib_ImageBlend_ZERO_ONE -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_ONE(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_ONE_Inp mlib_ImageBlend_ZERO_ONE_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_ONE_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 * src1 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_DC mlib_ImageBlend_ZERO_DC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_DC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 * src1dst */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_DC_Inp mlib_ImageBlend_ZERO_DC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_DC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 * (1 - src1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_OMDC mlib_ImageBlend_ZERO_OMDC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_OMDC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 * (1 - src1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_OMDC_Inp mlib_ImageBlend_ZERO_OMDC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_OMDC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_SA mlib_ImageBlend_ZERO_SA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_SA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_SA_Inp mlib_ImageBlend_ZERO_SA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_SA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 * (1 - ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_OMSA mlib_ImageBlend_ZERO_OMSA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_OMSA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 * (1 - ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_OMSA_Inp mlib_ImageBlend_ZERO_OMSA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_OMSA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 * ALPHAsrc1 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_DA mlib_ImageBlend_ZERO_DA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_DA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 * ALPHAsrc1dst */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_DA_Inp mlib_ImageBlend_ZERO_DA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_DA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 * (1 - ALPHAsrc1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_OMDA mlib_ImageBlend_ZERO_OMDA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_OMDA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 * (1 - ALPHAsrc1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_OMDA_Inp mlib_ImageBlend_ZERO_OMDA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_OMDA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 * (f, f, f, 1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_SAS mlib_ImageBlend_ZERO_SAS -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_SAS(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 * (f, f, f, 1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ZERO_SAS_Inp mlib_ImageBlend_ZERO_SAS_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ZERO_SAS_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_ZERO mlib_ImageBlend_ONE_ZERO -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_ZERO(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_ZERO_Inp mlib_ImageBlend_ONE_ZERO_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_ZERO_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_ONE mlib_ImageBlend_ONE_ONE -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_ONE(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_ONE_Inp mlib_ImageBlend_ONE_ONE_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_ONE_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 + src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_DC mlib_ImageBlend_ONE_DC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_DC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 + src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_DC_Inp mlib_ImageBlend_ONE_DC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_DC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 + src1 * (1 - src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_OMDC mlib_ImageBlend_ONE_OMDC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_OMDC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 + src1dst * (1 - src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_OMDC_Inp mlib_ImageBlend_ONE_OMDC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_OMDC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_SA mlib_ImageBlend_ONE_SA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_SA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_SA_Inp mlib_ImageBlend_ONE_SA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_SA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 * (1 - ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_OMSA mlib_ImageBlend_ONE_OMSA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_OMSA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 * (1 - ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_OMSA_Inp mlib_ImageBlend_ONE_OMSA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_OMSA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 * ALPHAsrc1 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_DA mlib_ImageBlend_ONE_DA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_DA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 * ALPHAsrc1dst */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_DA_Inp mlib_ImageBlend_ONE_DA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_DA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 * (1 - ALPHAsrc1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_OMDA mlib_ImageBlend_ONE_OMDA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_OMDA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 * (1 - ALPHAsrc1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_OMDA_Inp mlib_ImageBlend_ONE_OMDA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_OMDA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 * (f, f, f, 1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_SAS mlib_ImageBlend_ONE_SAS -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_SAS(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 * (f, f, f, 1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_ONE_SAS_Inp mlib_ImageBlend_ONE_SAS_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_ONE_SAS_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_ZERO mlib_ImageBlend_SC_ZERO -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_ZERO(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_ZERO_Inp mlib_ImageBlend_SC_ZERO_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_ZERO_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = (src1 + 1) * src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_ONE mlib_ImageBlend_SC_ONE -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_ONE(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = (src1dst + 1) * src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_ONE_Inp mlib_ImageBlend_SC_ONE_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_ONE_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = 2 * src1 * src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_DC mlib_ImageBlend_SC_DC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_DC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = 2 * src1dst * src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_DC_Inp mlib_ImageBlend_SC_DC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_DC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_OMDC mlib_ImageBlend_SC_OMDC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_OMDC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_OMDC_Inp mlib_ImageBlend_SC_OMDC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_OMDC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 * (src1 + ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_SA mlib_ImageBlend_SC_SA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_SA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 * (src1dst + ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_SA_Inp mlib_ImageBlend_SC_SA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_SA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 * (1 - ALPHAsrc2 + src1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_OMSA mlib_ImageBlend_SC_OMSA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_OMSA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 * (1 - ALPHAsrc2 + src1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_OMSA_Inp mlib_ImageBlend_SC_OMSA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_OMSA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 * (src1 + ALPHAsrc1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_DA mlib_ImageBlend_SC_DA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_DA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 * (src1dst + ALPHAsrc1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_DA_Inp mlib_ImageBlend_SC_DA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_DA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 * (1 - ALPHAsrc1 + src1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_OMDA mlib_ImageBlend_SC_OMDA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_OMDA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 * (1 - ALPHAsrc1dst + src1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_OMDA_Inp mlib_ImageBlend_SC_OMDA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_OMDA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src2 * ((f, f, f, 1) + src1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_SAS mlib_ImageBlend_SC_SAS -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_SAS(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src2 * ((f, f, f, 1) + src1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SC_SAS_Inp mlib_ImageBlend_SC_SAS_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SC_SAS_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_ZERO mlib_ImageBlend_OMSC_ZERO -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_ZERO(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_ZERO_Inp mlib_ImageBlend_OMSC_ZERO_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_ZERO_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 * (1 - src1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_ONE mlib_ImageBlend_OMSC_ONE -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_ONE(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 * (1 - src1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_ONE_Inp mlib_ImageBlend_OMSC_ONE_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_ONE_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_DC mlib_ImageBlend_OMSC_DC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_DC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_DC_Inp mlib_ImageBlend_OMSC_DC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_DC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 - 2 * src1 * src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_OMDC mlib_ImageBlend_OMSC_OMDC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_OMDC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 - 2 * src1dst * src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_OMDC_Inp mlib_ImageBlend_OMSC_OMDC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_OMDC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 * (ALPHAsrc2 - src1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_SA mlib_ImageBlend_OMSC_SA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_SA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 * (ALPHAsrc2 - src1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_SA_Inp mlib_ImageBlend_OMSC_SA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_SA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 - src2 * (src1 + ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_OMSA mlib_ImageBlend_OMSC_OMSA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_OMSA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 - src2 * (src1dst + ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_OMSA_Inp mlib_ImageBlend_OMSC_OMSA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_OMSA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 * (ALPHAsrc1 - src1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_DA mlib_ImageBlend_OMSC_DA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_DA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 * (ALPHAsrc1dst - src1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_DA_Inp mlib_ImageBlend_OMSC_DA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_DA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 - src2 * (src1 + ALPHAsrc1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_OMDA mlib_ImageBlend_OMSC_OMDA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_OMDA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 - src2 * (src1dst + ALPHAsrc1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_OMDA_Inp mlib_ImageBlend_OMSC_OMDA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_OMDA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + src2 * ((f, f, f, 1) - src1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_SAS mlib_ImageBlend_OMSC_SAS -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_SAS(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + src2 * ((f, f, f, 1) - src1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSC_SAS_Inp mlib_ImageBlend_OMSC_SAS_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSC_SAS_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_ZERO mlib_ImageBlend_SA_ZERO -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_ZERO(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_ZERO_Inp mlib_ImageBlend_SA_ZERO_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_ZERO_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * ALPHAsrc2 + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_ONE mlib_ImageBlend_SA_ONE -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_ONE(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * ALPHAsrc2 + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_ONE_Inp mlib_ImageBlend_SA_ONE_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_ONE_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (ALPHAsrc2 + src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_DC mlib_ImageBlend_SA_DC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_DC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (ALPHAsrc2 + src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_DC_Inp mlib_ImageBlend_SA_DC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_DC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (ALPHAsrc2 - src2) + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_OMDC mlib_ImageBlend_SA_OMDC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_OMDC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (ALPHAsrc2 - src2) + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_OMDC_Inp mlib_ImageBlend_SA_OMDC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_OMDC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = (src1 + src2) * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_SA mlib_ImageBlend_SA_SA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_SA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = (src1dst + src2) * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_SA_Inp mlib_ImageBlend_SA_SA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_SA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = (src1 - src2) * ALPHAsrc2 + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_OMSA mlib_ImageBlend_SA_OMSA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_OMSA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = (src1dst - src2) * ALPHAsrc2 + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_OMSA_Inp mlib_ImageBlend_SA_OMSA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_OMSA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * ALPHAsrc2 + src2 * ALPHAsrc1 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_DA mlib_ImageBlend_SA_DA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_DA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * ALPHAsrc2 + src2 * ALPHAsrc1dst */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_DA_Inp mlib_ImageBlend_SA_DA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_DA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * ALPHAsrc2 + src2 * (1 - ALPHAsrc1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_OMDA mlib_ImageBlend_SA_OMDA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_OMDA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * ALPHAsrc2 + src2 * (1 - ALPHAsrc1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_OMDA_Inp mlib_ImageBlend_SA_OMDA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_OMDA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * ALPHAsrc2 + src2 * (f, f, f, 1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_SAS mlib_ImageBlend_SA_SAS -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_SAS(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * ALPHAsrc2 + src2 * (f, f, f, 1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_SA_SAS_Inp mlib_ImageBlend_SA_SAS_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_SA_SAS_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_ZERO mlib_ImageBlend_OMSA_ZERO -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_ZERO(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_ZERO_Inp mlib_ImageBlend_OMSA_ZERO_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_ZERO_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc2) + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_ONE mlib_ImageBlend_OMSA_ONE -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_ONE(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc2) + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_ONE_Inp mlib_ImageBlend_OMSA_ONE_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_ONE_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc2 + src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_DC mlib_ImageBlend_OMSA_DC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_DC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc2 + src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_DC_Inp mlib_ImageBlend_OMSA_DC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_DC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc2 - src2) + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_OMDC mlib_ImageBlend_OMSA_OMDC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_OMDC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc2 - src2) + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_OMDC_Inp mlib_ImageBlend_OMSA_OMDC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_OMDC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + (src2 - src1) * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_SA mlib_ImageBlend_OMSA_SA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_SA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + (src2 - src1dst) * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_SA_Inp mlib_ImageBlend_OMSA_SA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_SA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = (src1 + src2) * (1 - ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_OMSA mlib_ImageBlend_OMSA_OMSA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_OMSA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = (src1dst + src2) * (1 - ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_OMSA_Inp mlib_ImageBlend_OMSA_OMSA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_OMSA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc2) + src2 * ALPHAsrc1 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_DA mlib_ImageBlend_OMSA_DA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_DA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc2) + src2 * ALPHAsrc1dst */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_DA_Inp mlib_ImageBlend_OMSA_DA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_DA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc2) + src2 * (1 - ALPHAsrc1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_OMDA mlib_ImageBlend_OMSA_OMDA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_OMDA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc2) + src2 * (1 - ALPHAsrc1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_OMDA_Inp mlib_ImageBlend_OMSA_OMDA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_OMDA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc2) + src2 * (f, f, f, 1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_SAS mlib_ImageBlend_OMSA_SAS -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_SAS(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc2) + src2 * (f, f, f, 1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMSA_SAS_Inp mlib_ImageBlend_OMSA_SAS_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMSA_SAS_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * ALPHAsrc1 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_ZERO mlib_ImageBlend_DA_ZERO -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_ZERO(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * ALPHAsrc1dst */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_ZERO_Inp mlib_ImageBlend_DA_ZERO_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_ZERO_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * ALPHAsrc1 + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_ONE mlib_ImageBlend_DA_ONE -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_ONE(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * ALPHAsrc1dst + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_ONE_Inp mlib_ImageBlend_DA_ONE_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_ONE_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (ALPHAsrc1 + src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_DC mlib_ImageBlend_DA_DC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_DC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (ALPHAsrc1dst + src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_DC_Inp mlib_ImageBlend_DA_DC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_DC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (ALPHAsrc1 - src2) + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_OMDC mlib_ImageBlend_DA_OMDC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_OMDC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (ALPHAsrc1dst - src2) + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_OMDC_Inp mlib_ImageBlend_DA_OMDC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_OMDC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * ALPHAsrc1 + src2 * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_SA mlib_ImageBlend_DA_SA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_SA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * ALPHAsrc1dst + src2 * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_SA_Inp mlib_ImageBlend_DA_SA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_SA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * ALPHAsrc1 + src2 * (1 - ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_OMSA mlib_ImageBlend_DA_OMSA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_OMSA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * ALPHAsrc1dst + src2 * (1 - ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_OMSA_Inp mlib_ImageBlend_DA_OMSA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_OMSA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = (src1 + src2) * ALPHAsrc1 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_DA mlib_ImageBlend_DA_DA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_DA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = (src1dst + src2) * ALPHAsrc1dst */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_DA_Inp mlib_ImageBlend_DA_DA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_DA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = (src1 - src2) * ALPHAsrc1 + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_OMDA mlib_ImageBlend_DA_OMDA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_OMDA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = (src1dst - src2) * ALPHAsrc1dst + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_OMDA_Inp mlib_ImageBlend_DA_OMDA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_OMDA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * ALPHAsrc1 + src2 * (f, f, f, 1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_SAS mlib_ImageBlend_DA_SAS -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_SAS(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * ALPHAsrc1dst + src2 * (f, f, f, 1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_DA_SAS_Inp mlib_ImageBlend_DA_SAS_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_DA_SAS_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_ZERO mlib_ImageBlend_OMDA_ZERO -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_ZERO(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_ZERO_Inp mlib_ImageBlend_OMDA_ZERO_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_ZERO_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc1) + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_ONE mlib_ImageBlend_OMDA_ONE -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_ONE(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc1dst) + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_ONE_Inp mlib_ImageBlend_OMDA_ONE_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_ONE_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc1 + src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_DC mlib_ImageBlend_OMDA_DC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_DC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc1dst + src2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_DC_Inp mlib_ImageBlend_OMDA_DC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_DC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc1 - src2) + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_OMDC mlib_ImageBlend_OMDA_OMDC -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_OMDC(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc1dst - src2) + src2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_OMDC_Inp mlib_ImageBlend_OMDA_OMDC_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_OMDC_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc1) + src2 * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_SA mlib_ImageBlend_OMDA_SA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_SA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc1dst) + src2 * ALPHAsrc2 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_SA_Inp mlib_ImageBlend_OMDA_SA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_SA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc1) + src2 * (1 - ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_OMSA mlib_ImageBlend_OMDA_OMSA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_OMSA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc1dst) + src2 * (1 - ALPHAsrc2) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_OMSA_Inp mlib_ImageBlend_OMDA_OMSA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_OMSA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 + (src2 - src1) * ALPHAsrc1 */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_DA mlib_ImageBlend_OMDA_DA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_DA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst + (src2 - src1dst) * ALPHAsrc1dst */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_DA_Inp mlib_ImageBlend_OMDA_DA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_DA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = (src1 + src2) * (1 - ALPHAsrc1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_OMDA mlib_ImageBlend_OMDA_OMDA -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_OMDA(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = (src1dst + src2) * (1 - ALPHAsrc1dst) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_OMDA_Inp mlib_ImageBlend_OMDA_OMDA_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_OMDA_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - -/* dst = src1 * (1 - ALPHAsrc1) + src2 * (f, f, f, 1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_SAS mlib_ImageBlend_OMDA_SAS -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_SAS(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_s32 cmask); - -/* src1dst = src1dst * (1 - ALPHAsrc1dst) + src2 * (f, f, f, 1) */ - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageBlend_OMDA_SAS_Inp mlib_ImageBlend_OMDA_SAS_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageBlend_OMDA_SAS_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_s32 cmask); - - - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageComposite mlib_ImageComposite -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageComposite(mlib_image *dst, - const mlib_image *src1, - const mlib_image *src2, - mlib_blend bsrc1, - mlib_blend bsrc2, - mlib_s32 cmask); - - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageComposite_Inp mlib_ImageComposite_Inp -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageComposite_Inp(mlib_image *src1dst, - const mlib_image *src2, - mlib_blend bsrc1, - mlib_blend bsrc2, - mlib_s32 cmask); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ -#endif /* __ORIG_MLIB_IMAGE_BLEND_PROTO_H */ diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_proto.h b/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_proto.h index 3a03e16a207..eabe26828a1 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_proto.h +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_image_proto.h @@ -1429,17 +1429,6 @@ mlib_status __mlib_ImageAffine(mlib_image *dst, mlib_edge edge); -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageAffineIndex mlib_ImageAffineIndex -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageAffineIndex(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *mtx, - mlib_filter filter, - mlib_edge edge, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageAffineTable mlib_ImageAffineTable #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ @@ -1470,17 +1459,6 @@ mlib_status __mlib_ImageAffineTransform(mlib_image *dst, mlib_edge edge); -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageAffineTransformIndex mlib_ImageAffineTransformIndex -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageAffineTransformIndex(mlib_image *dst, - const mlib_image *src, - const mlib_d64 *mtx, - mlib_filter filter, - mlib_edge edge, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageAffineTransform_Fp mlib_ImageAffineTransform_Fp #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ @@ -1824,19 +1802,6 @@ mlib_status __mlib_ImageRotate90_Fp(mlib_image *dst, const mlib_image *src); -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageRotateIndex mlib_ImageRotateIndex -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageRotateIndex(mlib_image *dst, - const mlib_image *src, - mlib_d64 angle, - mlib_d64 xcenter, - mlib_d64 ycenter, - mlib_filter filter, - mlib_edge edge, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageRotate_Fp mlib_ImageRotate_Fp #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ @@ -1886,16 +1851,6 @@ mlib_status __mlib_ImageZoomIn2X(mlib_image *dst, mlib_edge edge); -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageZoomIn2XIndex mlib_ImageZoomIn2XIndex -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageZoomIn2XIndex(mlib_image *dst, - const mlib_image *src, - mlib_filter filter, - mlib_edge edge, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageZoomIn2X_Fp mlib_ImageZoomIn2X_Fp #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ @@ -1914,16 +1869,6 @@ mlib_status __mlib_ImageZoomOut2X(mlib_image *dst, mlib_edge edge); -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageZoomOut2XIndex mlib_ImageZoomOut2XIndex -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageZoomOut2XIndex(mlib_image *dst, - const mlib_image *src, - mlib_filter filter, - mlib_edge edge, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageZoomOut2X_Fp mlib_ImageZoomOut2X_Fp #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ @@ -2011,18 +1956,6 @@ mlib_status __mlib_ImageZoom(mlib_image *dst, mlib_edge edge); -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageZoomIndex mlib_ImageZoomIndex -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageZoomIndex(mlib_image *dst, - const mlib_image *src, - mlib_d64 zoomx, - mlib_d64 zoomy, - mlib_filter filter, - mlib_edge edge, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageZoom_Fp mlib_ImageZoom_Fp #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ @@ -2311,98 +2244,6 @@ mlib_status __mlib_ImageXor_Inp(mlib_image *src1dst, /* Radiometric Operations ( radio ) */ -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageColorTrue2IndexInit mlib_ImageColorTrue2IndexInit -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageColorTrue2IndexInit(void **colormap, - mlib_s32 bits, - mlib_type intype, - mlib_type outtype, - mlib_s32 channels, - mlib_s32 entries, - mlib_s32 offset, - const void **table); - - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageColorTrue2Index mlib_ImageColorTrue2Index -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageColorTrue2Index(mlib_image *dst, - const mlib_image *src, - const void *colormap); - - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageColorTrue2IndexFree mlib_ImageColorTrue2IndexFree -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -void __mlib_ImageColorTrue2IndexFree(void *colormap); - - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageColorDitherInit mlib_ImageColorDitherInit -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageColorDitherInit(void **colormap, - const mlib_s32 *dimensions, - mlib_type intype, - mlib_type outtype, - mlib_s32 channels, - mlib_s32 entries, - mlib_s32 offset, - void **lut); - - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageColorDitherFree mlib_ImageColorDitherFree -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -void __mlib_ImageColorDitherFree(void *colormap); - - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageColorErrorDiffusion3x3 mlib_ImageColorErrorDiffusion3x3 -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageColorErrorDiffusion3x3(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kernel, - mlib_s32 scale, - const void *colormap); - - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageColorErrorDiffusionMxN mlib_ImageColorErrorDiffusionMxN -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageColorErrorDiffusionMxN(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kernel, - mlib_s32 m, - mlib_s32 n, - mlib_s32 dm, - mlib_s32 dn, - mlib_s32 scale, - const void *colormap); - - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageColorOrderedDither8x8 mlib_ImageColorOrderedDither8x8 -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageColorOrderedDither8x8(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *dmask, - mlib_s32 scale, - const void *colormap); - - -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageColorOrderedDitherMxN mlib_ImageColorOrderedDitherMxN -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageColorOrderedDitherMxN(mlib_image *dst, - const mlib_image *src, - const mlib_s32 **dmask, - mlib_s32 m, - mlib_s32 n, - mlib_s32 scale, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageColorReplace mlib_ImageColorReplace #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ @@ -2693,17 +2534,6 @@ mlib_status __mlib_ImageConv2x2(mlib_image *dst, mlib_edge edge); -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageConv2x2Index mlib_ImageConv2x2Index -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageConv2x2Index(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kernel, - mlib_s32 scale, - mlib_edge edge, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageConv2x2_Fp mlib_ImageConv2x2_Fp #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ @@ -2725,17 +2555,6 @@ mlib_status __mlib_ImageConv3x3(mlib_image *dst, mlib_edge edge); -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageConv3x3Index mlib_ImageConv3x3Index -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageConv3x3Index(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kernel, - mlib_s32 scale, - mlib_edge edge, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageConv3x3_Fp mlib_ImageConv3x3_Fp #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ @@ -2757,17 +2576,6 @@ mlib_status __mlib_ImageConv4x4(mlib_image *dst, mlib_edge edge); -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageConv4x4Index mlib_ImageConv4x4Index -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageConv4x4Index(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kernel, - mlib_s32 scale, - mlib_edge edge, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageConv4x4_Fp mlib_ImageConv4x4_Fp #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ @@ -2789,17 +2597,6 @@ mlib_status __mlib_ImageConv5x5(mlib_image *dst, mlib_edge edge); -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageConv5x5Index mlib_ImageConv5x5Index -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageConv5x5Index(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kernel, - mlib_s32 scale, - mlib_edge edge, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageConv5x5_Fp mlib_ImageConv5x5_Fp #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ @@ -2821,17 +2618,6 @@ mlib_status __mlib_ImageConv7x7(mlib_image *dst, mlib_edge edge); -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageConv7x7Index mlib_ImageConv7x7Index -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageConv7x7Index(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kernel, - mlib_s32 scale, - mlib_edge edge, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageConv7x7_Fp mlib_ImageConv7x7_Fp #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ @@ -2870,21 +2656,6 @@ mlib_status __mlib_ImageConvMxN(mlib_image *dst, mlib_edge edge); -#if defined ( __MEDIALIB_OLD_NAMES ) -#define __mlib_ImageConvMxNIndex mlib_ImageConvMxNIndex -#endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ -mlib_status __mlib_ImageConvMxNIndex(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kernel, - mlib_s32 m, - mlib_s32 n, - mlib_s32 dm, - mlib_s32 dn, - mlib_s32 scale, - mlib_edge edge, - const void *colormap); - - #if defined ( __MEDIALIB_OLD_NAMES ) #define __mlib_ImageConvMxN_Fp mlib_ImageConvMxN_Fp #endif /* ! defined ( __MEDIALIB_OLD_NAMES ) */ diff --git a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy.c b/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy.c deleted file mode 100644 index ad2bdf4657c..00000000000 --- a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - - -/* - * FUNCTION - * mlib_ImageCopy - Direct copy from one image to another. - * - * SYNOPSIS - * mlib_status mlib_ImageCopy(mlib_image *dst, - * mlib_image *src); - * - * ARGUMENT - * dst pointer to output or destination image - * src pointer to input or source image - * - * RESTRICTION - * src and dst must have the same size, type and number of channels. - * They can have 1, 2, 3 or 4 channels of MLIB_BIT, MLIB_BYTE, - * MLIB_SHORT, MLIB_INT, MLIB_FLOAT or MLIB_DOUBLE data type. - * - * DESCRIPTION - * Direct copy from one image to another. - */ - -#include -#include "mlib_image.h" -#include "mlib_ImageCheck.h" - -/***************************************************************/ - -extern void mlib_v_ImageCopy_blk(mlib_u8 *sa, mlib_u8 *da, mlib_s32 size); -extern void mlib_v_ImageCopy_a1(mlib_d64 *sp, mlib_d64 *dp, mlib_s32 size); -extern void mlib_ImageCopy_na(mlib_u8 *sa, mlib_u8 *da, mlib_s32 size); -extern void mlib_ImageCopy_bit_al(mlib_u8 *sa, mlib_u8 *da, - mlib_s32 size, mlib_s32 offset); -extern void mlib_ImageCopy_bit_na(mlib_u8 *sa, mlib_u8 *da, mlib_s32 size, - mlib_s32 s_offset, mlib_s32 d_offset); - -/***************************************************************/ - -#ifdef MLIB_TEST - -mlib_status mlib_v_ImageCopy(mlib_image *dst, mlib_image *src) - -#else - -mlib_status mlib_ImageCopy(mlib_image *dst, const mlib_image *src) - -#endif -{ - mlib_u8 *sa; /* start point in source */ - mlib_u8 *da; /* start points in destination */ - mlib_s32 width; /* width in bytes of src and dst */ - mlib_s32 height; /* height in lines of src and dst */ - mlib_s32 s_offset; /* bit offset of src */ - mlib_s32 d_offset; /* bit offset of dst */ - mlib_s32 stride; /* stride in bytes in src*/ - mlib_s32 dstride; /* stride in bytes in dst */ - mlib_s32 j; /* indices for x, y */ - mlib_s32 size; - - MLIB_IMAGE_CHECK(src); - MLIB_IMAGE_CHECK(dst); - MLIB_IMAGE_TYPE_EQUAL(src, dst); - MLIB_IMAGE_CHAN_EQUAL(src, dst); - MLIB_IMAGE_SIZE_EQUAL(src, dst); - - width = mlib_ImageGetWidth(dst) * mlib_ImageGetChannels(dst); - height = mlib_ImageGetHeight(dst); - sa = (mlib_u8 *)mlib_ImageGetData(src); - da = (mlib_u8 *)mlib_ImageGetData(dst); - - switch (mlib_ImageGetType(dst)) { - case MLIB_BIT: - - if (!mlib_ImageIsNotOneDvector(src) && - !mlib_ImageIsNotOneDvector(dst)) { - size = height * (width >> 3); - if ((size & 0x3f) == 0 && - !mlib_ImageIsNotAligned64(src) && - !mlib_ImageIsNotAligned64(dst)) { - - mlib_v_ImageCopy_blk(sa, da, size); - return MLIB_SUCCESS; - } - if (((size & 7) == 0) && !mlib_ImageIsNotAligned8(src) && - !mlib_ImageIsNotAligned8(dst)) { - - size >>= 3; /* in octlet */ - mlib_v_ImageCopy_a1((mlib_d64 *)sa, (mlib_d64 *)da, size); - } - else { - - mlib_ImageCopy_na(sa, da, size); - } - } - else { - stride = mlib_ImageGetStride(src); /* in byte */ - dstride = mlib_ImageGetStride(dst); /* in byte */ - s_offset = mlib_ImageGetBitOffset(src); /* in bits */ - d_offset = mlib_ImageGetBitOffset(dst); /* in bits */ - - if (s_offset == d_offset) { - for (j = 0; j < height; j++) { - mlib_ImageCopy_bit_al(sa, da, width, s_offset); - sa += stride; - da += dstride; - } - } else { - for (j = 0; j < height; j++) { - mlib_ImageCopy_bit_na(sa, da, width, s_offset, d_offset); - sa += stride; - da += dstride; - } - } - } - return MLIB_SUCCESS; - case MLIB_BYTE: - break; - case MLIB_SHORT: - width *= 2; - break; - case MLIB_INT: - case MLIB_FLOAT: - width *= 4; - break; - case MLIB_DOUBLE: - width *= 8; - break; - default: - return MLIB_FAILURE; - } - - if (!mlib_ImageIsNotOneDvector(src) && - !mlib_ImageIsNotOneDvector(dst)) { - size = height * width; - if ((size & 0x3f) == 0 && - !mlib_ImageIsNotAligned64(src) && - !mlib_ImageIsNotAligned64(dst)) { - - mlib_v_ImageCopy_blk(sa, da, size); - return MLIB_SUCCESS; - } - if (((size & 7) == 0) && !mlib_ImageIsNotAligned8(src) && - !mlib_ImageIsNotAligned8(dst)) { - - size >>= 3; /* in octlet */ - mlib_v_ImageCopy_a1((mlib_d64 *)sa, (mlib_d64 *)da, size); - } - else { - - mlib_ImageCopy_na(sa, da, size); - } - } - else { - stride = mlib_ImageGetStride(src); /* in byte */ - dstride = mlib_ImageGetStride(dst); /* in byte */ - - /* row loop */ - for (j = 0; j < height; j++) { - mlib_ImageCopy_na(sa, da, width); - sa += stride; - da += dstride; - } - } - return MLIB_SUCCESS; -} - -/***************************************************************/ diff --git a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy_blk.s b/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy_blk.s deleted file mode 100644 index 8261781c3eb..00000000000 --- a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy_blk.s +++ /dev/null @@ -1,262 +0,0 @@ -! -! -! -! Copyright 2000 Sun Microsystems, Inc. All Rights Reserved. -! DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -! -! This code is free software; you can redistribute it and/or modify it -! under the terms of the GNU General Public License version 2 only, as -! published by the Free Software Foundation. Oracle designates this -! particular file as subject to the "Classpath" exception as provided -! by Oracle in the LICENSE file that accompanied this code. -! -! This code is distributed in the hope that it will be useful, but WITHOUT -! ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -! FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -! version 2 for more details (a copy is included in the LICENSE file that -! accompanied this code). -! -! You should have received a copy of the GNU General Public License version -! 2 along with this work; if not, write to the Free Software Foundation, -! Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -! -! Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -! or visit www.oracle.com if you need additional information or have any -! questions. -! - - -! FUNCTION -! mlib_v_ImageCopy_blk - Copy an image into another -! (with Block Load/Store) -! -! SYNOPSIS -! void mlib_v_ImageCopy_blk(void *src, -! void *dst, -! int size); -! -! ARGUMENT -! src source image data -! dst destination image data -! size image size in bytes -! -! NOTES -! src and dst must point to 64-byte aligned addresses -! size must be multiple of 64 -! -! DESCRIPTION -! dst = src -! - -#include "vis_asi.h" - -! Minimum size of stack frame according to SPARC ABI -#define MINFRAME 96 - -! ENTRY provides the standard procedure entry code -#define ENTRY(x) \ - .align 4; \ - .global x; \ -x: - -! SET_SIZE trails a function and sets the size for the ELF symbol table -#define SET_SIZE(x) \ - .size x, (.-x) - -! SPARC have four integer register groups. i-registers %i0 to %i7 -! hold input data. o-registers %o0 to %o7 hold output data. l-registers -! %l0 to %l7 hold local data. g-registers %g0 to %g7 hold global data. -! Note that %g0 is alway zero, write to it has no program-visible effect. - -! When calling an assembly function, the first 6 arguments are stored -! in i-registers from %i0 to %i5. The rest arguments are stored in stack. -! Note that %i6 is reserved for stack pointer and %i7 for return address. - -! Only the first 32 f-registers can be used as 32-bit registers. -! The last 32 f-registers can only be used as 16 64-bit registers. - -#define src %i0 -#define dst %i1 -#define sz %i2 - -!frame pointer %i6 -!return addr %i7 - -!stack pointer %o6 -!call link %o7 - -#define sa %l0 -#define da %l1 -#define se %l2 -#define ns %l3 - -#define O0 %f16 -#define O1 %f18 -#define O2 %f20 -#define O3 %f22 -#define O4 %f24 -#define O5 %f26 -#define O6 %f28 -#define O7 %f30 - -#define A0 %f32 -#define A1 %f34 -#define A2 %f36 -#define A3 %f38 -#define A4 %f40 -#define A5 %f42 -#define A6 %f44 -#define A7 %f46 - -#define B0 %f48 -#define B1 %f50 -#define B2 %f52 -#define B3 %f54 -#define B4 %f56 -#define B5 %f58 -#define B6 %f60 -#define B7 %f62 - -#define USE_BLD -#define USE_BST - -#define MEMBAR_BEFORE_BLD membar #StoreLoad -#define MEMBAR_AFTER_BLD membar #StoreLoad - -#ifdef USE_BLD -#define BLD_A0 \ - ldda [sa]ASI_BLK_P,A0; \ - cmp sa,se; \ - blu,pt %icc,1f; \ - inc 64,sa; \ - dec 64,sa; \ -1: -#else -#define BLD_A0 \ - ldd [sa + 0],A0; \ - ldd [sa + 8],A1; \ - ldd [sa + 16],A2; \ - ldd [sa + 24],A3; \ - ldd [sa + 32],A4; \ - ldd [sa + 40],A5; \ - ldd [sa + 48],A6; \ - ldd [sa + 56],A7; \ - cmp sa,se; \ - blu,pt %icc,1f; \ - inc 64,sa; \ - dec 64,sa; \ -1: -#endif - -#ifdef USE_BLD -#define BLD_B0 \ - ldda [sa]ASI_BLK_P,B0; \ - cmp sa,se; \ - blu,pt %icc,1f; \ - inc 64,sa; \ - dec 64,sa; \ -1: -#else -#define BLD_B0 \ - ldd [sa + 0],B0; \ - ldd [sa + 8],B1; \ - ldd [sa + 16],B2; \ - ldd [sa + 24],B3; \ - ldd [sa + 32],B4; \ - ldd [sa + 40],B5; \ - ldd [sa + 48],B6; \ - ldd [sa + 56],B7; \ - cmp sa,se; \ - blu,pt %icc,1f; \ - inc 64,sa; \ - dec 64,sa; \ -1: -#endif - -#ifdef USE_BST -#define BST \ - stda O0,[da]ASI_BLK_P; \ - inc 64,da; \ - deccc ns; \ - ble,pn %icc,mlib_v_ImageCopy_end; \ - nop -#else -#define BST \ - std O0,[da + 0]; \ - std O1,[da + 8]; \ - std O2,[da + 16]; \ - std O3,[da + 24]; \ - std O4,[da + 32]; \ - std O5,[da + 40]; \ - std O6,[da + 48]; \ - std O7,[da + 56]; \ - inc 64,da; \ - deccc ns; \ - ble,pn %icc,mlib_v_ImageCopy_end; \ - nop -#endif - -#define COPY_A0 \ - fmovd A0, O0; \ - fmovd A1, O1; \ - fmovd A2, O2; \ - fmovd A3, O3; \ - fmovd A4, O4; \ - fmovd A5, O5; \ - fmovd A6, O6; \ - fmovd A7, O7; - -#define COPY_B0 \ - fmovd B0, O0; \ - fmovd B1, O1; \ - fmovd B2, O2; \ - fmovd B3, O3; \ - fmovd B4, O4; \ - fmovd B5, O5; \ - fmovd B6, O6; \ - fmovd B7, O7; - - .section ".text",#alloc,#execinstr - - ENTRY(mlib_v_ImageCopy_blk) ! function name - - save %sp,-MINFRAME,%sp ! reserve space for stack - ! and adjust register window -! do some error checking - tst sz ! size > 0 - ble,pn %icc,mlib_v_ImageCopy_ret - -! calculate loop count - sra sz,6,ns ! 64 bytes per loop - - add src,sz,se ! end address of source - mov src,sa - mov dst,da - ! issue memory barrier instruction - MEMBAR_BEFORE_BLD ! to ensure all previous memory load - ! and store has completed - - BLD_A0 - BLD_B0 ! issue the 2nd block load instruction - ! to synchronize with returning data -mlib_v_ImageCopy_bgn: - - COPY_A0 ! process data returned by BLD_A0 - BLD_A0 ! block load and sync data from BLD_B0 - BST ! block store data from BLD_A0 - - COPY_B0 ! process data returned by BLD_B0 - BLD_B0 ! block load and sync data from BLD_A0 - BST ! block store data from BLD_B0 - - bg,pt %icc,mlib_v_ImageCopy_bgn - -mlib_v_ImageCopy_end: - ! issue memory barrier instruction - MEMBAR_AFTER_BLD ! to ensure all previous memory load - ! and store has completed. -mlib_v_ImageCopy_ret: - ret ! return - restore ! restore register window - - SET_SIZE(mlib_v_ImageCopy_blk) diff --git a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/vis_asi.h b/jdk/src/java.desktop/unix/native/libawt/awt/medialib/vis_asi.h deleted file mode 100644 index d0a75d3b6a2..00000000000 --- a/jdk/src/java.desktop/unix/native/libawt/awt/medialib/vis_asi.h +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -#ifndef VIS_ASI_H -#define VIS_ASI_H - -/* evolved from asm_asi.h in VSDK 1.0 */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* ASI definitions for VIS */ - -#define ASI_N 0x04 -#define ASI_NL 0x0C -#define ASI_AIUP 0x10 -#define ASI_AIUS 0x11 -#define ASI_AIUPL 0x18 -#define ASI_AIUSL 0x19 -#define ASI_PHYS_USE_EC_L 0x1C -#define ASI_PHYS_BYPASS_EC_WITH_EBIT_L 0x1D -#define ASI_DC_DATA 0x46 -#define ASI_DC_TAG 0x47 -#define ASI_UPA_CONTROL 0x4A -#define ASI_MONDO_SEND_CTRL 0x48 -#define ASI_MONDO_RECEIVE_CTRL 0x49 -#define ASI_AFSR 0x4C -#define ASI_AFAR 0x4D -#define ASI_EC_TAG_DATA 0x4E -#define ASI_ICACHE_DATA 0x66 -#define ASI_IC_INSTR 0x66 -#define ASI_IC_TAG 0x67 -#define ASI_IC_PRE_DECODE 0x6E -#define ASI_IC_NEXT_FIELD 0x6F -#define ASI_BLK_AIUP 0x70 -#define ASI_BLK_AIUS 0x71 -#define ASI_EC 0x76 -#define ASI_BLK_AIUPL 0x78 -#define ASI_BLK_AIUSL 0x79 -#define ASI_P 0x80 -#define ASI_S 0x81 -#define ASI_PNF 0x82 -#define ASI_SNF 0x83 -#define ASI_PL 0x88 -#define ASI_SL 0x89 -#define ASI_PNFL 0x8A -#define ASI_SNFL 0x8B -#define ASI_PST8_P 0xC0 -#define ASI_PST8_S 0xC1 -#define ASI_PST16_P 0xC2 -#define ASI_PST16_S 0xC3 -#define ASI_PST32_P 0xC4 -#define ASI_PST32_S 0xC5 -#define ASI_PST8_PL 0xC8 -#define ASI_PST8_SL 0xC9 -#define ASI_PST16_PL 0xCA -#define ASI_PST16_SL 0xCB -#define ASI_PST32_PL 0xCC -#define ASI_PST32_SL 0xCD -#define ASI_FL8_P 0xD0 -#define ASI_FL8_S 0xD1 -#define ASI_FL16_P 0xD2 -#define ASI_FL16_S 0xD3 -#define ASI_FL8_PL 0xD8 -#define ASI_FL8_SL 0xD9 -#define ASI_FL16_PL 0xDA -#define ASI_FL16_SL 0xDB -#define ASI_COMMIT_P 0xE0 -#define ASI_COMMIT_S 0xE1 -#define ASI_BLK_P 0xF0 -#define ASI_BLK_S 0xF1 -#define ASI_BLK_PL 0xF8 -#define ASI_BLK_SL 0xF9 - -#define ASI_NUCLEUS 0x04 -#define ASI_NUCLEUS_LITTLE 0x0C -#define ASI_AS_IF_USER_PRIMARY 0x10 -#define ASI_AS_IF_USER_SECONDARY 0x11 -#define ASI_PHYS_USE_EC 0x14 -#define ASI_PHYS_BYPASS_EC_WITH_EBIT 0x15 -#define ASI_AS_IF_USER_PRIMARY_LITTLE 0x18 -#define ASI_AS_IF_USER_SECONDARY_LITTLE 0x19 -#define ASI_PHYS_USE_EC_LITTLE 0x1C -#define ASI_PHYS_BYPASS_EC_WITH_EBIT_LITTLE 0x1D -#define ASI_LSU_CONTROL_REG 0x45 -#define ASI_DCACHE_DATA 0x46 -#define ASI_DCACHE_TAG 0x47 -#define ASI_INTR_DISPATCH_STATUS 0x48 -#define ASI_INTR_RECEIVE 0x49 -#define ASI_UPA_CONFIG_REG 0x4A -#define ASI_ESTATE_ERROR_EN_REG 0x4B -#define ASI_ASYNC_FAULT_STATUS 0x4C -#define ASI_ASYNC_FAULT_ADDR 0x4D -#define ASI_ECACHE_TAG_DATA 0x4E -#define ASI_OBSERVABILITY_REG 0x4F -#define ASI_IMMU 0x50 -#define ASI_IMU_TSB_BASE 0x50 -#define ASI_IMU_TAG_ACCESS 0x50 -#define ASI_IMU_SFSR 0x50 -#define ASI_IMU_TAG_TARGET 0x50 -#define ASI_IMU_TSB_POINTER_8K 0x51 -#define ASI_IMU_TSB_POINTER_64K 0x52 -#define ASI_IMU_DATAIN 0x54 -#define ASI_IMMU_DATA_IN 0x54 -#define ASI_IMU_DATA_ACCESS 0x55 -#define ASI_IMU_TAG_READ 0x56 -#define ASI_IMU_DEMAP 0x57 -#define ASI_DMMU 0x58 -#define ASI_PRIMARY_CONTEXT 0x58 -#define ASI_SECONDARY_CONTEXT 0x58 -#define ASI_DMU_TSB_BASE 0x58 -#define ASI_DMU_TAG_ACCESS 0x58 -#define ASI_DMU_TAG_TARGET 0x58 -#define ASI_DMU_SFSR 0x58 -#define ASI_DMU_SFAR 0x58 -#define ASI_DMU_VA_WATCHPOINT 0x58 -#define ASI_DMU_PA_WATCHPOINT 0x58 -#define ASI_DMU_TSB_POINTER_8K 0x59 -#define ASI_DMU_TSB_POINTER_64K 0x5A -#define ASI_DMU_TSB_POINTER_DIRECT 0x5B -#define ASI_DMU_DATAIN 0x5C -#define ASI_DMMU_DATA_IN 0x5C -#define ASI_DMU_DATA_ACCESS 0x5D -#define ASI_DMU_TAG_READ 0x5E -#define ASI_DMU_DEMAP 0x5F -#define ASI_ICACHE_INSTR 0x66 -#define ASI_ICACHE_TAG 0x67 -#define ASI_ICACHE_PRE_DECODE 0x6E -#define ASI_ICACHE_NEXT_FIELD 0x6F -#define ASI_BLOCK_AS_IF_USER_PRIMARY 0x70 -#define ASI_BLOCK_AS_IF_USER_SECONDARY 0x71 -#define ASI_EXT 0x76 -#define ASI_ECACHE 0x76 -#define ASI_ECACHE_DATA 0x76 -#define ASI_ECACHE_TAG 0x76 -#define ASI_SDB_INTR 0x77 -#define ASI_SDBH_ERR_REG 0x77 -#define ASI_SDBL_ERR_REG 0x77 -#define ASI_SDBH_CONTROL_REG 0x77 -#define ASI_SDBL_CONTROL_REG 0x77 -#define ASI_INTR_DISPATCH 0x77 -#define ASI_INTR_DATA0 0x77 -#define ASI_INTR_DATA1 0x77 -#define ASI_INTR_DATA2 0x77 -#define ASI_BLOCK_AS_IF_USER_PRIMARY_LITTLE 0x78 -#define ASI_BLOCK_AS_IF_USER_SECONDARY_LITTLE 0x79 -#define ASI_PRIMARY 0x80 -#define ASI_SECONDARY 0x81 -#define ASI_PRIMARY_NO_FAULT 0x82 -#define ASI_SECONDARY_NO_FAULT 0x83 -#define ASI_PRIMARY_LITTLE 0x88 -#define ASI_SECONDARY_LITTLE 0x89 -#define ASI_PRIMARY_NO_FAULT_LITTLE 0x8A -#define ASI_SECONDARY_NO_FAULT_LITTLE 0x8B -#define ASI_PST8_PRIMARY 0xC0 -#define ASI_PST8_SECONDARY 0xC1 -#define ASI_PST16_PRIMARY 0xC2 -#define ASI_PST16_SECONDARY 0xC3 -#define ASI_PST32_PRIMARY 0xC4 -#define ASI_PST32_SECONDARY 0xC5 -#define ASI_PST8_PRIMARY_LITTLE 0xC8 -#define ASI_PST8_SECONDARY_LITTLE 0xC9 -#define ASI_PST16_PRIMARY_LITTLE 0xCA -#define ASI_PST16_SECONDARY_LITTLE 0xCB -#define ASI_PST32_PRIMARY_LITTLE 0xCC -#define ASI_PST32_SECONDARY_LITTLE 0xCD -#define ASI_FL8_PRIMARY 0xD0 -#define ASI_FL8_SECONDARY 0xD1 -#define ASI_FL16_PRIMARY 0xD2 -#define ASI_FL16_SECONDARY 0xD3 -#define ASI_FL8_PRIMARY_LITTLE 0xD8 -#define ASI_FL8_SECONDARY_LITTLE 0xD9 -#define ASI_FL16_PRIMARY_LITTLE 0xDA -#define ASI_FL16_SECONDARY_LITTLE 0xDB -#define ASI_COMMIT_PRIMARY 0xE0 -#define ASI_COMMIT_SECONDARY 0xE1 -#define ASI_BLOCK_PRIMARY 0xF0 -#define ASI_BLOCK_SECONDARY 0xF1 -#define ASI_BLOCK_PRIMARY_LITTLE 0xF8 -#define ASI_BLOCK_SECONDARY_LITTLE 0xF9 - -#ifdef __cplusplus -} -#endif - -#endif /* VIS_ASI_H */ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffineIndex_BC.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffineIndex_BC.c deleted file mode 100644 index d87fa01926d..00000000000 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffineIndex_BC.c +++ /dev/null @@ -1,1443 +0,0 @@ -/* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - - -#include "vis_proto.h" -#include "mlib_image.h" -#include "mlib_ImageColormap.h" -#include "mlib_ImageAffine.h" -#include "mlib_v_ImageFilters.h" - -/***************************************************************/ -#define MLIB_LIMIT 512 -#define MLIB_SHIFT 16 - -/***************************************************************/ -#undef DECLAREVAR -#define DECLAREVAR() \ - DECLAREVAR0(); \ - mlib_s32 *warp_tbl = param -> warp_tbl; \ - mlib_s32 xSrc, ySrc; \ - mlib_s32 srcYStride = param -> srcYStride; \ - mlib_s32 filter = param -> filter; \ - mlib_s32 max_xsize = param -> max_xsize; \ - MLIB_TYPE *srcIndexPtr; \ - MLIB_TYPE *dstIndexPtr; \ - mlib_d64 *dstPixelPtr; \ - mlib_s32 i - -/***************************************************************/ -#define DECLAREVAR_U8() \ - mlib_s32 filterposx, filterposy; \ - mlib_d64 sum0, sum1, sum2, sum3; \ - mlib_f32 hi_row00, hi_row10, hi_row20, hi_row30; \ - mlib_f32 hi_row01, hi_row11, hi_row21, hi_row31; \ - mlib_f32 lo_row00, lo_row10, lo_row20, lo_row30; \ - mlib_f32 lo_row01, lo_row11, lo_row21, lo_row31; \ - mlib_d64 xFilter0, xFilter1, xFilter2, xFilter3, yFilter; \ - mlib_d64 v00, v10, v20, v30; \ - mlib_d64 v01, v11, v21, v31; \ - mlib_d64 v02, v12, v22, v32; \ - mlib_d64 v03, v13, v23, v33; \ - mlib_d64 d0, d1, d2, d3; \ - mlib_d64 d00, d10, d20, d30; \ - mlib_d64 d01, d11, d21, d31; \ - mlib_s32 cols; \ - mlib_d64 res, *xPtr - -/***************************************************************/ -#define DECLAREVAR_S16() \ - mlib_s32 filterposx, filterposy; \ - mlib_d64 sum0, sum1, sum2, sum3; \ - mlib_d64 row00, row10, row20, row30; \ - mlib_d64 row01, row11, row21, row31; \ - mlib_d64 row02, row12, row22, row32; \ - mlib_d64 row03, row13, row23, row33; \ - mlib_d64 xFilter0, xFilter1, xFilter2, xFilter3; \ - mlib_d64 yFilter0, yFilter1, yFilter2, yFilter3; \ - mlib_d64 v00, v01, v02, v03, v10, v11, v12, v13; \ - mlib_d64 v20, v21, v22, v23, v30, v31, v32, v33; \ - mlib_d64 u00, u01, u10, u11, u20, u21, u30, u31; \ - mlib_d64 d0, d1, d2, d3; \ - mlib_d64 *yPtr, *xPtr; \ - mlib_s32 cols; \ - mlib_d64 res; \ - mlib_f32 f_x01000100 = vis_to_float(0x01000100) - -/***************************************************************/ -#undef CLIP -#define CLIP() \ - dstData += dstYStride; \ - xLeft = leftEdges[j]; \ - xRight = rightEdges[j]; \ - X = xStarts[j]; \ - Y = yStarts[j]; \ - PREPARE_DELTAS \ - if (xLeft > xRight) \ - continue; \ - dstIndexPtr = (MLIB_TYPE *)dstData + xLeft; \ - dstPixelPtr = dstRowPtr - -/***************************************************************/ -#define FADD_4BC_U8() \ - d0 = vis_fpadd16(d00, d10); \ - d1 = vis_fpadd16(d20, d30); \ - d0 = vis_fpadd16(d0, d1); \ - d2 = vis_fpadd16(d01, d11); \ - d3 = vis_fpadd16(d21, d31); \ - d2 = vis_fpadd16(d2, d3); \ - res = vis_fpack16_pair(d0, d2) - -/***************************************************************/ -#define LOAD_BC_U8_4CH_1PIXEL(mlib_filters_u8, mlib_filters_u8_4) \ - filterposy = (Y >> FILTER_SHIFT) & FILTER_MASK; \ - yFilter = *((mlib_d64 *) ((mlib_u8 *)mlib_filters_u8 + filterposy)); \ - filterposx = (X >> FILTER_SHIFT) & FILTER_MASK; \ - xPtr = ((mlib_d64 *)((mlib_u8 *)mlib_filters_u8_4+4*filterposx)); \ - xFilter0 = xPtr[0]; \ - xFilter1 = xPtr[1]; \ - xFilter2 = xPtr[2]; \ - xFilter3 = xPtr[3]; \ - X += dX; \ - Y += dY; \ - hi_row00 = flut[srcIndexPtr[0]]; \ - lo_row00 = flut[srcIndexPtr[1]]; \ - hi_row01 = flut[srcIndexPtr[2]]; \ - lo_row01 = flut[srcIndexPtr[3]]; \ - srcIndexPtr += srcYStride; \ - hi_row10 = flut[srcIndexPtr[0]]; \ - lo_row10 = flut[srcIndexPtr[1]]; \ - hi_row11 = flut[srcIndexPtr[2]]; \ - lo_row11 = flut[srcIndexPtr[3]]; \ - srcIndexPtr += srcYStride; \ - hi_row20 = flut[srcIndexPtr[0]]; \ - lo_row20 = flut[srcIndexPtr[1]]; \ - hi_row21 = flut[srcIndexPtr[2]]; \ - lo_row21 = flut[srcIndexPtr[3]]; \ - srcIndexPtr += srcYStride; \ - hi_row30 = flut[srcIndexPtr[0]]; \ - lo_row30 = flut[srcIndexPtr[1]]; \ - hi_row31 = flut[srcIndexPtr[2]]; \ - lo_row31 = flut[srcIndexPtr[3]] - -/***************************************************************/ -#define NEXT_PIXEL_4BC() \ - xSrc = (X >> MLIB_SHIFT)-1; \ - ySrc = (Y >> MLIB_SHIFT)-1; \ - srcIndexPtr = (MLIB_TYPE *)lineAddr[ySrc] + xSrc - -/***************************************************************/ -#define RESULT_4BC_U8_1PIXEL(ind) \ - v00 = vis_fmul8x16au(hi_row00, vis_read_hi(yFilter)); \ - v01 = vis_fmul8x16au(lo_row00, vis_read_hi(yFilter)); \ - v02 = vis_fmul8x16au(hi_row01, vis_read_hi(yFilter)); \ - v03 = vis_fmul8x16au(lo_row01, vis_read_hi(yFilter)); \ - v10 = vis_fmul8x16al(hi_row10, vis_read_hi(yFilter)); \ - v11 = vis_fmul8x16al(lo_row10, vis_read_hi(yFilter)); \ - sum0 = vis_fpadd16(v00, v10); \ - v12 = vis_fmul8x16al(hi_row11, vis_read_hi(yFilter)); \ - sum1 = vis_fpadd16(v01, v11); \ - v13 = vis_fmul8x16al(lo_row11, vis_read_hi(yFilter)); \ - sum2 = vis_fpadd16(v02, v12); \ - v20 = vis_fmul8x16au(hi_row20, vis_read_lo(yFilter)); \ - sum3 = vis_fpadd16(v03, v13); \ - v21 = vis_fmul8x16au(lo_row20, vis_read_lo(yFilter)); \ - sum0 = vis_fpadd16(sum0, v20); \ - v22 = vis_fmul8x16au(hi_row21, vis_read_lo(yFilter)); \ - sum1 = vis_fpadd16(sum1, v21); \ - v23 = vis_fmul8x16au(lo_row21, vis_read_lo(yFilter)); \ - sum2 = vis_fpadd16(sum2, v22); \ - v30 = vis_fmul8x16al(hi_row30, vis_read_lo(yFilter)); \ - sum3 = vis_fpadd16(sum3, v23); \ - v31 = vis_fmul8x16al(lo_row30, vis_read_lo(yFilter)); \ - sum0 = vis_fpadd16(sum0, v30); \ - v32 = vis_fmul8x16al(hi_row31, vis_read_lo(yFilter)); \ - sum1 = vis_fpadd16(sum1, v31); \ - v33 = vis_fmul8x16al(lo_row31, vis_read_lo(yFilter)); \ - sum2 = vis_fpadd16(sum2, v32); \ - v00 = vis_fmul8sux16(sum0, xFilter0); \ - sum3 = vis_fpadd16(sum3, v33); \ - v01 = vis_fmul8ulx16(sum0, xFilter0); \ - v10 = vis_fmul8sux16(sum1, xFilter1); \ - d0##ind = vis_fpadd16(v00, v01); \ - v11 = vis_fmul8ulx16(sum1, xFilter1); \ - v20 = vis_fmul8sux16(sum2, xFilter2); \ - d1##ind = vis_fpadd16(v10, v11); \ - v21 = vis_fmul8ulx16(sum2, xFilter2); \ - v30 = vis_fmul8sux16(sum3, xFilter3); \ - d2##ind = vis_fpadd16(v20, v21); \ - v31 = vis_fmul8ulx16(sum3, xFilter3); \ - d3##ind = vis_fpadd16(v30, v31) - -/***************************************************************/ -#define BC_U8_4CH(ind, mlib_filters_u8, mlib_filters_u8_4) \ - v00 = vis_fmul8x16au(hi_row00, vis_read_hi(yFilter)); \ - v01 = vis_fmul8x16au(lo_row00, vis_read_hi(yFilter)); \ - v02 = vis_fmul8x16au(hi_row01, vis_read_hi(yFilter)); \ - v03 = vis_fmul8x16au(lo_row01, vis_read_hi(yFilter)); \ - hi_row00 = flut[srcIndexPtr[0]]; \ - filterposy = (Y >> FILTER_SHIFT); \ - v10 = vis_fmul8x16al(hi_row10, vis_read_hi(yFilter)); \ - lo_row00 = flut[srcIndexPtr[1]]; \ - v11 = vis_fmul8x16al(lo_row10, vis_read_hi(yFilter)); \ - sum0 = vis_fpadd16(v00, v10); \ - hi_row01 = flut[srcIndexPtr[2]]; \ - v12 = vis_fmul8x16al(hi_row11, vis_read_hi(yFilter)); \ - lo_row01 = flut[srcIndexPtr[3]]; \ - filterposx = (X >> FILTER_SHIFT); \ - v13 = vis_fmul8x16al(lo_row11, vis_read_hi(yFilter)); \ - srcIndexPtr += srcYStride; \ - hi_row10 = flut[srcIndexPtr[0]]; \ - v20 = vis_fmul8x16au(hi_row20, vis_read_lo(yFilter)); \ - sum1 = vis_fpadd16(v01, v11); \ - lo_row10 = flut[srcIndexPtr[1]]; \ - X += dX; \ - hi_row11 = flut[srcIndexPtr[2]]; \ - v21 = vis_fmul8x16au(lo_row20, vis_read_lo(yFilter)); \ - sum2 = vis_fpadd16(v02, v12); \ - lo_row11 = flut[srcIndexPtr[3]]; \ - v22 = vis_fmul8x16au(hi_row21, vis_read_lo(yFilter)); \ - srcIndexPtr += srcYStride; \ - hi_row20 = flut[srcIndexPtr[0]]; \ - v23 = vis_fmul8x16au(lo_row21, vis_read_lo(yFilter)); \ - sum3 = vis_fpadd16(v03, v13); \ - Y += dY; \ - xSrc = (X >> MLIB_SHIFT)-1; \ - v30 = vis_fmul8x16al(hi_row30, vis_read_lo(yFilter)); \ - sum0 = vis_fpadd16(sum0, v20); \ - lo_row20 = flut[srcIndexPtr[1]]; \ - ySrc = (Y >> MLIB_SHIFT)-1; \ - hi_row21 = flut[srcIndexPtr[2]]; \ - v31 = vis_fmul8x16al(lo_row30, vis_read_lo(yFilter)); \ - sum1 = vis_fpadd16(sum1, v21); \ - filterposy &= FILTER_MASK; \ - lo_row21 = flut[srcIndexPtr[3]]; \ - v32 = vis_fmul8x16al(hi_row31, vis_read_lo(yFilter)); \ - srcIndexPtr += srcYStride; \ - filterposx &= FILTER_MASK; \ - v33 = vis_fmul8x16al(lo_row31, vis_read_lo(yFilter)); \ - sum2 = vis_fpadd16(sum2, v22); \ - hi_row30 = flut[srcIndexPtr[0]]; \ - sum3 = vis_fpadd16(sum3, v23); \ - sum0 = vis_fpadd16(sum0, v30); \ - lo_row30 = flut[srcIndexPtr[1]]; \ - sum1 = vis_fpadd16(sum1, v31); \ - v00 = vis_fmul8sux16(sum0, xFilter0); \ - hi_row31 = flut[srcIndexPtr[2]]; \ - sum2 = vis_fpadd16(sum2, v32); \ - v01 = vis_fmul8ulx16(sum0, xFilter0); \ - sum3 = vis_fpadd16(sum3, v33); \ - lo_row31 = flut[srcIndexPtr[3]]; \ - v10 = vis_fmul8sux16(sum1, xFilter1); \ - d0##ind = vis_fpadd16(v00, v01); \ - yFilter = *((mlib_d64 *)((mlib_u8 *)mlib_filters_u8 + filterposy)); \ - v11 = vis_fmul8ulx16(sum1, xFilter1); \ - xPtr = ((mlib_d64 *)((mlib_u8 *)mlib_filters_u8_4+4*filterposx)); \ - xFilter0 = xPtr[0]; \ - v20 = vis_fmul8sux16(sum2, xFilter2); \ - d1##ind = vis_fpadd16(v10, v11); \ - xFilter1 = xPtr[1]; \ - v21 = vis_fmul8ulx16(sum2, xFilter2); \ - xFilter2 = xPtr[2]; \ - v30 = vis_fmul8sux16(sum3, xFilter3); \ - d2##ind = vis_fpadd16(v20, v21); \ - xFilter3 = xPtr[3]; \ - v31 = vis_fmul8ulx16(sum3, xFilter3); \ - srcIndexPtr = (MLIB_TYPE *)lineAddr[ySrc] + xSrc; \ - d3##ind = vis_fpadd16(v30, v31) - -/***************************************************************/ -#define LOAD_BC_S16_4CH_1PIXEL(mlib_filters_s16_4) \ - row00 = flut[srcIndexPtr[0]]; \ - row01 = flut[srcIndexPtr[1]]; \ - row02 = flut[srcIndexPtr[2]]; \ - row03 = flut[srcIndexPtr[3]]; \ - srcIndexPtr += srcYStride; \ - row10 = flut[srcIndexPtr[0]]; \ - row11 = flut[srcIndexPtr[1]]; \ - row12 = flut[srcIndexPtr[2]]; \ - row13 = flut[srcIndexPtr[3]]; \ - srcIndexPtr += srcYStride; \ - row20 = flut[srcIndexPtr[0]]; \ - row21 = flut[srcIndexPtr[1]]; \ - row22 = flut[srcIndexPtr[2]]; \ - row23 = flut[srcIndexPtr[3]]; \ - srcIndexPtr += srcYStride; \ - row30 = flut[srcIndexPtr[0]]; \ - row31 = flut[srcIndexPtr[1]]; \ - row32 = flut[srcIndexPtr[2]]; \ - row33 = flut[srcIndexPtr[3]]; \ - filterposy = (Y >> FILTER_SHIFT) & FILTER_MASK; \ - yPtr = ((mlib_d64 *) ((mlib_u8 *)mlib_filters_s16_4 + filterposy*4)); \ - yFilter0 = yPtr[0]; \ - yFilter1 = yPtr[1]; \ - yFilter2 = yPtr[2]; \ - yFilter3 = yPtr[3]; \ - filterposx = (X >> FILTER_SHIFT) & FILTER_MASK; \ - xPtr = ((mlib_d64 *)((mlib_u8 *)mlib_filters_s16_4 + filterposx*4)); \ - xFilter0 = xPtr[0]; \ - xFilter1 = xPtr[1]; \ - xFilter2 = xPtr[2]; \ - xFilter3 = xPtr[3]; \ - X += dX; \ - Y += dY - -/***************************************************************/ -#define RESULT_4BC_S16_1PIXEL() \ - u00 = vis_fmul8sux16(row00, yFilter0); \ - u01 = vis_fmul8ulx16(row00, yFilter0); \ - u10 = vis_fmul8sux16(row01, yFilter0); \ - u11 = vis_fmul8ulx16(row01, yFilter0); \ - v00 = vis_fpadd16(u00, u01); \ - u20 = vis_fmul8sux16(row02, yFilter0); \ - v01 = vis_fpadd16(u10, u11); \ - u21 = vis_fmul8ulx16(row02, yFilter0); \ - u30 = vis_fmul8sux16(row03, yFilter0); \ - u31 = vis_fmul8ulx16(row03, yFilter0); \ - v02 = vis_fpadd16(u20, u21); \ - u00 = vis_fmul8sux16(row10, yFilter1); \ - u01 = vis_fmul8ulx16(row10, yFilter1); \ - v03 = vis_fpadd16(u30, u31); \ - u10 = vis_fmul8sux16(row11, yFilter1); \ - u11 = vis_fmul8ulx16(row11, yFilter1); \ - v10 = vis_fpadd16(u00, u01); \ - u20 = vis_fmul8sux16(row12, yFilter1); \ - v11 = vis_fpadd16(u10, u11); \ - u21 = vis_fmul8ulx16(row12, yFilter1); \ - u30 = vis_fmul8sux16(row13, yFilter1); \ - u31 = vis_fmul8ulx16(row13, yFilter1); \ - u00 = vis_fmul8sux16(row20, yFilter2); \ - v12 = vis_fpadd16(u20, u21); \ - u01 = vis_fmul8ulx16(row20, yFilter2); \ - v13 = vis_fpadd16(u30, u31); \ - u10 = vis_fmul8sux16(row21, yFilter2); \ - u11 = vis_fmul8ulx16(row21, yFilter2); \ - v20 = vis_fpadd16(u00, u01); \ - u20 = vis_fmul8sux16(row22, yFilter2); \ - sum0 = vis_fpadd16(v00, v10); \ - u21 = vis_fmul8ulx16(row22, yFilter2); \ - u30 = vis_fmul8sux16(row23, yFilter2); \ - u31 = vis_fmul8ulx16(row23, yFilter2); \ - u00 = vis_fmul8sux16(row30, yFilter3); \ - u01 = vis_fmul8ulx16(row30, yFilter3); \ - v21 = vis_fpadd16(u10, u11); \ - sum1 = vis_fpadd16(v01, v11); \ - u10 = vis_fmul8sux16(row31, yFilter3); \ - sum2 = vis_fpadd16(v02, v12); \ - sum3 = vis_fpadd16(v03, v13); \ - v22 = vis_fpadd16(u20, u21); \ - u11 = vis_fmul8ulx16(row31, yFilter3); \ - sum0 = vis_fpadd16(sum0, v20); \ - u20 = vis_fmul8sux16(row32, yFilter3); \ - u21 = vis_fmul8ulx16(row32, yFilter3); \ - v23 = vis_fpadd16(u30, u31); \ - v30 = vis_fpadd16(u00, u01); \ - sum1 = vis_fpadd16(sum1, v21); \ - u30 = vis_fmul8sux16(row33, yFilter3); \ - u31 = vis_fmul8ulx16(row33, yFilter3); \ - v31 = vis_fpadd16(u10, u11); \ - sum2 = vis_fpadd16(sum2, v22); \ - sum3 = vis_fpadd16(sum3, v23); \ - v32 = vis_fpadd16(u20, u21); \ - sum0 = vis_fpadd16(sum0, v30); \ - v33 = vis_fpadd16(u30, u31); \ - v00 = vis_fmul8sux16(sum0, xFilter0); \ - sum1 = vis_fpadd16(sum1, v31); \ - sum2 = vis_fpadd16(sum2, v32); \ - v01 = vis_fmul8ulx16(sum0, xFilter0); \ - v10 = vis_fmul8sux16(sum1, xFilter1); \ - sum3 = vis_fpadd16(sum3, v33); \ - v11 = vis_fmul8ulx16(sum1, xFilter1); \ - d0 = vis_fpadd16(v00, v01); \ - v20 = vis_fmul8sux16(sum2, xFilter2); \ - v21 = vis_fmul8ulx16(sum2, xFilter2); \ - d1 = vis_fpadd16(v10, v11); \ - v30 = vis_fmul8sux16(sum3, xFilter3); \ - v31 = vis_fmul8ulx16(sum3, xFilter3); \ - d2 = vis_fpadd16(v20, v21); \ - d3 = vis_fpadd16(v30, v31); \ - d0 = vis_fpadd16(d0, d1); \ - d2 = vis_fpadd16(d2, d3); \ - d0 = vis_fpadd16(d0, d2); \ - d2 = vis_fmuld8sux16(f_x01000100, vis_read_hi(d0)); \ - d3 = vis_fmuld8sux16(f_x01000100, vis_read_lo(d0)); \ - res = vis_fpackfix_pair(d2, d3) - -/***************************************************************/ -#define BC_S16_4CH(mlib_filters_s16_4) \ - u00 = vis_fmul8sux16(row00, yFilter0); \ - u01 = vis_fmul8ulx16(row00, yFilter0); \ - u10 = vis_fmul8sux16(row01, yFilter0); \ - u11 = vis_fmul8ulx16(row01, yFilter0); \ - v00 = vis_fpadd16(u00, u01); \ - u20 = vis_fmul8sux16(row02, yFilter0); \ - v01 = vis_fpadd16(u10, u11); \ - u21 = vis_fmul8ulx16(row02, yFilter0); \ - u30 = vis_fmul8sux16(row03, yFilter0); \ - u31 = vis_fmul8ulx16(row03, yFilter0); \ - v02 = vis_fpadd16(u20, u21); \ - row00 = flut[srcIndexPtr[0]]; \ - u00 = vis_fmul8sux16(row10, yFilter1); \ - u01 = vis_fmul8ulx16(row10, yFilter1); \ - filterposy = (Y >> FILTER_SHIFT); \ - v03 = vis_fpadd16(u30, u31); \ - row01 = flut[srcIndexPtr[1]]; \ - u10 = vis_fmul8sux16(row11, yFilter1); \ - u11 = vis_fmul8ulx16(row11, yFilter1); \ - v10 = vis_fpadd16(u00, u01); \ - row02 = flut[srcIndexPtr[2]]; \ - u20 = vis_fmul8sux16(row12, yFilter1); \ - v11 = vis_fpadd16(u10, u11); \ - u21 = vis_fmul8ulx16(row12, yFilter1); \ - u30 = vis_fmul8sux16(row13, yFilter1); \ - row03 = flut[srcIndexPtr[3]]; \ - u31 = vis_fmul8ulx16(row13, yFilter1); \ - u00 = vis_fmul8sux16(row20, yFilter2); \ - filterposx = (X >> FILTER_SHIFT); \ - srcIndexPtr += srcYStride; \ - v12 = vis_fpadd16(u20, u21); \ - u01 = vis_fmul8ulx16(row20, yFilter2); \ - v13 = vis_fpadd16(u30, u31); \ - row10 = flut[srcIndexPtr[0]]; \ - u10 = vis_fmul8sux16(row21, yFilter2); \ - X += dX; \ - u11 = vis_fmul8ulx16(row21, yFilter2); \ - v20 = vis_fpadd16(u00, u01); \ - row11 = flut[srcIndexPtr[1]]; \ - u20 = vis_fmul8sux16(row22, yFilter2); \ - sum0 = vis_fpadd16(v00, v10); \ - u21 = vis_fmul8ulx16(row22, yFilter2); \ - row12 = flut[srcIndexPtr[2]]; \ - u30 = vis_fmul8sux16(row23, yFilter2); \ - u31 = vis_fmul8ulx16(row23, yFilter2); \ - row13 = flut[srcIndexPtr[3]]; \ - u00 = vis_fmul8sux16(row30, yFilter3); \ - srcIndexPtr += srcYStride; \ - u01 = vis_fmul8ulx16(row30, yFilter3); \ - v21 = vis_fpadd16(u10, u11); \ - Y += dY; \ - xSrc = (X >> MLIB_SHIFT)-1; \ - sum1 = vis_fpadd16(v01, v11); \ - row20 = flut[srcIndexPtr[0]]; \ - u10 = vis_fmul8sux16(row31, yFilter3); \ - sum2 = vis_fpadd16(v02, v12); \ - sum3 = vis_fpadd16(v03, v13); \ - ySrc = (Y >> MLIB_SHIFT)-1; \ - row21 = flut[srcIndexPtr[1]]; \ - v22 = vis_fpadd16(u20, u21); \ - u11 = vis_fmul8ulx16(row31, yFilter3); \ - sum0 = vis_fpadd16(sum0, v20); \ - u20 = vis_fmul8sux16(row32, yFilter3); \ - row22 = flut[srcIndexPtr[2]]; \ - u21 = vis_fmul8ulx16(row32, yFilter3); \ - v23 = vis_fpadd16(u30, u31); \ - v30 = vis_fpadd16(u00, u01); \ - filterposy &= FILTER_MASK; \ - sum1 = vis_fpadd16(sum1, v21); \ - u30 = vis_fmul8sux16(row33, yFilter3); \ - row23 = flut[srcIndexPtr[3]]; \ - u31 = vis_fmul8ulx16(row33, yFilter3); \ - srcIndexPtr += srcYStride; \ - filterposx &= FILTER_MASK; \ - v31 = vis_fpadd16(u10, u11); \ - row30 = flut[srcIndexPtr[0]]; \ - sum2 = vis_fpadd16(sum2, v22); \ - sum3 = vis_fpadd16(sum3, v23); \ - row31 = flut[srcIndexPtr[1]]; \ - v32 = vis_fpadd16(u20, u21); \ - sum0 = vis_fpadd16(sum0, v30); \ - row32 = flut[srcIndexPtr[2]]; \ - v33 = vis_fpadd16(u30, u31); \ - row33 = flut[srcIndexPtr[3]]; \ - v00 = vis_fmul8sux16(sum0, xFilter0); \ - yPtr = ((mlib_d64 *) ((mlib_u8 *)mlib_filters_s16_4 + filterposy*4)); \ - sum1 = vis_fpadd16(sum1, v31); \ - yFilter0 = yPtr[0]; \ - sum2 = vis_fpadd16(sum2, v32); \ - v01 = vis_fmul8ulx16(sum0, xFilter0); \ - yFilter1 = yPtr[1]; \ - v10 = vis_fmul8sux16(sum1, xFilter1); \ - sum3 = vis_fpadd16(sum3, v33); \ - yFilter2 = yPtr[2]; \ - v11 = vis_fmul8ulx16(sum1, xFilter1); \ - d0 = vis_fpadd16(v00, v01); \ - yFilter3 = yPtr[3]; \ - xPtr = ((mlib_d64 *)((mlib_u8 *)mlib_filters_s16_4 + filterposx*4)); \ - v20 = vis_fmul8sux16(sum2, xFilter2); \ - xFilter0 = xPtr[0]; \ - v21 = vis_fmul8ulx16(sum2, xFilter2); \ - d1 = vis_fpadd16(v10, v11); \ - xFilter1 = xPtr[1]; \ - v30 = vis_fmul8sux16(sum3, xFilter3); \ - v31 = vis_fmul8ulx16(sum3, xFilter3); \ - d2 = vis_fpadd16(v20, v21); \ - xFilter2 = xPtr[2]; \ - d3 = vis_fpadd16(v30, v31); \ - xFilter3 = xPtr[3]; \ - srcIndexPtr = (MLIB_TYPE *)lineAddr[ySrc] + xSrc - -/***************************************************************/ -#define FADD_4BC_S16() \ - d0 = vis_fpadd16(d0, d1); \ - d2 = vis_fpadd16(d2, d3); \ - d0 = vis_fpadd16(d0, d2); \ - d2 = vis_fmuld8sux16(f_x01000100, vis_read_hi(d0)); \ - d3 = vis_fmuld8sux16(f_x01000100, vis_read_lo(d0)); \ - res = vis_fpackfix_pair(d2, d3) - -/***************************************************************/ -#undef MLIB_TYPE -#define MLIB_TYPE mlib_u8 - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 5 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 8) - 1) << 3) - -/***************************************************************/ -mlib_status mlib_ImageAffineIndex_U8_U8_3CH_BC(mlib_affine_param *param, - const void *colormap) -{ - DECLAREVAR(); - DECLAREVAR_U8(); - mlib_f32 *flut = (mlib_f32 *)mlib_ImageGetLutNormalTable(colormap) - - mlib_ImageGetLutOffset(colormap); - mlib_d64 dstRowData[MLIB_LIMIT/2]; - mlib_d64 *dstRowPtr = dstRowData; - const mlib_s16 *mlib_filters_table_u8, *mlib_filters_table_u8_4; - - if (filter == MLIB_BICUBIC) { - mlib_filters_table_u8 = mlib_filters_u8_bc; - mlib_filters_table_u8_4 = mlib_filters_u8_bc_4; - } else { - mlib_filters_table_u8 = mlib_filters_u8_bc2; - mlib_filters_table_u8_4 = mlib_filters_u8_bc2_4; - } - - if (max_xsize > MLIB_LIMIT) { - dstRowPtr = mlib_malloc(sizeof(mlib_d64) * ((max_xsize + 1) >> 1)); - - if (dstRowPtr == NULL) return MLIB_FAILURE; - } - - vis_write_gsr(3 << 3); - - for (j = yStart; j <= yFinish; j++) { - - CLIP(); - - cols = xRight - xLeft + 1; - - i = 0; - - if (i <= cols - 6) { - - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - - NEXT_PIXEL_4BC(); - - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - FADD_4BC_U8(); - - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - -#pragma pipeloop(0) - for (; i <= cols-8; i += 2) { - *dstPixelPtr++ = res; - - FADD_4BC_U8(); - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - } - - *dstPixelPtr++ = res; - - FADD_4BC_U8(); - *dstPixelPtr++ = res; - - RESULT_4BC_U8_1PIXEL(0); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(1); - FADD_4BC_U8(); - - *dstPixelPtr++ = res; - i += 6; - } - - if (i <= cols-4) { - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - - NEXT_PIXEL_4BC(); - - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - FADD_4BC_U8(); - *dstPixelPtr++ = res; - - RESULT_4BC_U8_1PIXEL(0); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(1); - FADD_4BC_U8(); - - *dstPixelPtr++ = res; - i += 4; - } - - if (i <= cols-2) { - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(0); - - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(1); - FADD_4BC_U8(); - - *dstPixelPtr++ = res; - i += 2; - } - - if (i < cols) { - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(0); - - d0 = vis_fpadd16(d00, d10); - d1 = vis_fpadd16(d20, d30); - d0 = vis_fpadd16(d0, d1); - res = vis_fpack16_pair(d0, d0); - *dstPixelPtr++ = res; - } - - mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4((mlib_u8 *)dstRowPtr, - dstIndexPtr, - xRight - xLeft + 1, - colormap); - } - - if (dstRowPtr != dstRowData) mlib_free(dstRowPtr); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 4 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 9) - 1) << 3) - -/***************************************************************/ -mlib_status mlib_ImageAffineIndex_U8_S16_3CH_BC(mlib_affine_param *param, - const void *colormap) -{ - DECLAREVAR(); - DECLAREVAR_S16(); - mlib_d64 *flut = (mlib_d64 *)mlib_ImageGetLutNormalTable(colormap) - - mlib_ImageGetLutOffset(colormap); - mlib_d64 dstRowData[MLIB_LIMIT]; - mlib_d64 *dstRowPtr = dstRowData; - const mlib_s16 *mlib_filters_table_s16_4; - - if (filter == MLIB_BICUBIC) { - mlib_filters_table_s16_4 = mlib_filters_s16_bc_4; - } else { - mlib_filters_table_s16_4 = mlib_filters_s16_bc2_4; - } - - if (max_xsize > MLIB_LIMIT) { - dstRowPtr = mlib_malloc(sizeof(mlib_d64) * max_xsize); - - if (dstRowPtr == NULL) return MLIB_FAILURE; - } - - for (j = yStart; j <= yFinish; j++) { - - CLIP(); - - vis_write_gsr(10 << 3); - - cols = xRight - xLeft + 1; - i = 0; - - if (i <= cols - 4) { - - NEXT_PIXEL_4BC(); - LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4); - - NEXT_PIXEL_4BC(); - - BC_S16_4CH(mlib_filters_table_s16_4); - FADD_4BC_S16(); - - BC_S16_4CH(mlib_filters_table_s16_4); - -#pragma pipeloop(0) - - for (; i < cols-4; i++) { - *dstPixelPtr++ = res; - - FADD_4BC_S16(); - BC_S16_4CH(mlib_filters_table_s16_4); - } - - *dstPixelPtr++ = res; - - FADD_4BC_S16(); - *dstPixelPtr++ = res; - - RESULT_4BC_S16_1PIXEL(); - *dstPixelPtr++ = res; - - LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4); - RESULT_4BC_S16_1PIXEL(); - *dstPixelPtr++ = res; - i += 4; - } - -#pragma pipeloop(0) - for (; i < cols; i++) { - NEXT_PIXEL_4BC(); - LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4); - RESULT_4BC_S16_1PIXEL(); - *dstPixelPtr++ = res; - } - - mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4((mlib_s16 *)dstRowPtr, - dstIndexPtr, - xRight - xLeft + 1, - colormap); - } - - if (dstRowPtr != dstRowData) mlib_free(dstRowPtr); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 5 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 8) - 1) << 3) - -/***************************************************************/ -mlib_status mlib_ImageAffineIndex_U8_U8_4CH_BC(mlib_affine_param *param, - const void *colormap) -{ - DECLAREVAR(); - DECLAREVAR_U8(); - mlib_f32 *flut = (mlib_f32 *)mlib_ImageGetLutNormalTable(colormap) - - mlib_ImageGetLutOffset(colormap); - mlib_d64 dstRowData[MLIB_LIMIT/2]; - mlib_d64 *dstRowPtr = dstRowData; - const mlib_s16 *mlib_filters_table_u8, *mlib_filters_table_u8_4; - - if (filter == MLIB_BICUBIC) { - mlib_filters_table_u8 = mlib_filters_u8_bc; - mlib_filters_table_u8_4 = mlib_filters_u8_bc_4; - } else { - mlib_filters_table_u8 = mlib_filters_u8_bc2; - mlib_filters_table_u8_4 = mlib_filters_u8_bc2_4; - } - - if (max_xsize > MLIB_LIMIT) { - dstRowPtr = mlib_malloc(sizeof(mlib_d64) * ((max_xsize + 1) >> 1)); - - if (dstRowPtr == NULL) return MLIB_FAILURE; - } - - vis_write_gsr(3 << 3); - - for (j = yStart; j <= yFinish; j++) { - - CLIP(); - - cols = xRight - xLeft + 1; - - i = 0; - - if (i <= cols - 6) { - - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - - NEXT_PIXEL_4BC(); - - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - FADD_4BC_U8(); - - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - -#pragma pipeloop(0) - for (; i <= cols-8; i += 2) { - *dstPixelPtr++ = res; - - FADD_4BC_U8(); - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - } - - *dstPixelPtr++ = res; - - FADD_4BC_U8(); - *dstPixelPtr++ = res; - - RESULT_4BC_U8_1PIXEL(0); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(1); - FADD_4BC_U8(); - - *dstPixelPtr++ = res; - i += 6; - } - - if (i <= cols-4) { - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - - NEXT_PIXEL_4BC(); - - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - FADD_4BC_U8(); - *dstPixelPtr++ = res; - - RESULT_4BC_U8_1PIXEL(0); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(1); - FADD_4BC_U8(); - - *dstPixelPtr++ = res; - i += 4; - } - - if (i <= cols-2) { - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(0); - - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(1); - FADD_4BC_U8(); - - *dstPixelPtr++ = res; - i += 2; - } - - if (i < cols) { - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(0); - - d0 = vis_fpadd16(d00, d10); - d1 = vis_fpadd16(d20, d30); - d0 = vis_fpadd16(d0, d1); - res = vis_fpack16_pair(d0, d0); - *dstPixelPtr++ = res; - } - - mlib_ImageColorTrue2IndexLine_U8_U8_4((mlib_u8 *)dstRowPtr, - dstIndexPtr, - xRight - xLeft + 1, - colormap); - } - - if (dstRowPtr != dstRowData) mlib_free(dstRowPtr); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 4 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 9) - 1) << 3) - -/***************************************************************/ -mlib_status mlib_ImageAffineIndex_U8_S16_4CH_BC(mlib_affine_param *param, - const void *colormap) -{ - DECLAREVAR(); - DECLAREVAR_S16(); - mlib_d64 *flut = (mlib_d64 *)mlib_ImageGetLutNormalTable(colormap) - - mlib_ImageGetLutOffset(colormap); - mlib_d64 dstRowData[MLIB_LIMIT]; - mlib_d64 *dstRowPtr = dstRowData; - const mlib_s16 *mlib_filters_table_s16_4; - - if (filter == MLIB_BICUBIC) { - mlib_filters_table_s16_4 = mlib_filters_s16_bc_4; - } else { - mlib_filters_table_s16_4 = mlib_filters_s16_bc2_4; - } - - if (max_xsize > MLIB_LIMIT) { - dstRowPtr = mlib_malloc(sizeof(mlib_d64) * max_xsize); - - if (dstRowPtr == NULL) return MLIB_FAILURE; - } - - for (j = yStart; j <= yFinish; j++) { - - CLIP(); - - vis_write_gsr(10 << 3); - - cols = xRight - xLeft + 1; - i = 0; - - if (i <= cols - 4) { - - NEXT_PIXEL_4BC(); - LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4); - - NEXT_PIXEL_4BC(); - - BC_S16_4CH(mlib_filters_table_s16_4); - FADD_4BC_S16(); - - BC_S16_4CH(mlib_filters_table_s16_4); - -#pragma pipeloop(0) - - for (; i < cols-4; i++) { - *dstPixelPtr++ = res; - - FADD_4BC_S16(); - BC_S16_4CH(mlib_filters_table_s16_4); - } - - *dstPixelPtr++ = res; - - FADD_4BC_S16(); - *dstPixelPtr++ = res; - - RESULT_4BC_S16_1PIXEL(); - *dstPixelPtr++ = res; - - LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4); - RESULT_4BC_S16_1PIXEL(); - *dstPixelPtr++ = res; - i += 4; - } - -#pragma pipeloop(0) - for (; i < cols; i++) { - NEXT_PIXEL_4BC(); - LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4); - RESULT_4BC_S16_1PIXEL(); - *dstPixelPtr++ = res; - } - - mlib_ImageColorTrue2IndexLine_S16_U8_4((mlib_s16 *)dstRowPtr, - dstIndexPtr, - xRight - xLeft + 1, - colormap); - } - - if (dstRowPtr != dstRowData) mlib_free(dstRowPtr); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef MLIB_TYPE -#define MLIB_TYPE mlib_s16 - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 5 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 8) - 1) << 3) - -/***************************************************************/ -mlib_status mlib_ImageAffineIndex_S16_U8_3CH_BC(mlib_affine_param *param, - const void *colormap) -{ - DECLAREVAR(); - DECLAREVAR_U8(); - mlib_f32 *flut = (mlib_f32 *)mlib_ImageGetLutNormalTable(colormap) - - mlib_ImageGetLutOffset(colormap); - mlib_d64 dstRowData[MLIB_LIMIT/2]; - mlib_d64 *dstRowPtr = dstRowData; - const mlib_s16 *mlib_filters_table_u8, *mlib_filters_table_u8_4; - - if (filter == MLIB_BICUBIC) { - mlib_filters_table_u8 = mlib_filters_u8_bc; - mlib_filters_table_u8_4 = mlib_filters_u8_bc_4; - } else { - mlib_filters_table_u8 = mlib_filters_u8_bc2; - mlib_filters_table_u8_4 = mlib_filters_u8_bc2_4; - } - - srcYStride >>= 1; - - if (max_xsize > MLIB_LIMIT) { - dstRowPtr = mlib_malloc(sizeof(mlib_d64) * ((max_xsize + 1) >> 1)); - - if (dstRowPtr == NULL) return MLIB_FAILURE; - } - - vis_write_gsr(3 << 3); - - for (j = yStart; j <= yFinish; j++) { - - CLIP(); - - cols = xRight - xLeft + 1; - - i = 0; - - if (i <= cols - 6) { - - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - - NEXT_PIXEL_4BC(); - - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - FADD_4BC_U8(); - - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - -#pragma pipeloop(0) - for (; i <= cols-8; i += 2) { - *dstPixelPtr++ = res; - - FADD_4BC_U8(); - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - } - - *dstPixelPtr++ = res; - - FADD_4BC_U8(); - *dstPixelPtr++ = res; - - RESULT_4BC_U8_1PIXEL(0); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(1); - FADD_4BC_U8(); - - *dstPixelPtr++ = res; - i += 6; - } - - if (i <= cols-4) { - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - - NEXT_PIXEL_4BC(); - - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - FADD_4BC_U8(); - *dstPixelPtr++ = res; - - RESULT_4BC_U8_1PIXEL(0); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(1); - FADD_4BC_U8(); - - *dstPixelPtr++ = res; - i += 4; - } - - if (i <= cols-2) { - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(0); - - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(1); - FADD_4BC_U8(); - - *dstPixelPtr++ = res; - i += 2; - } - - if (i < cols) { - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(0); - - d0 = vis_fpadd16(d00, d10); - d1 = vis_fpadd16(d20, d30); - d0 = vis_fpadd16(d0, d1); - res = vis_fpack16_pair(d0, d0); - *dstPixelPtr++ = res; - } - - mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4((mlib_u8 *)dstRowPtr, - dstIndexPtr, - xRight - xLeft + 1, - colormap); - } - - if (dstRowPtr != dstRowData) mlib_free(dstRowPtr); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 4 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 9) - 1) << 3) - -/***************************************************************/ -mlib_status mlib_ImageAffineIndex_S16_S16_3CH_BC(mlib_affine_param *param, - const void *colormap) -{ - DECLAREVAR(); - DECLAREVAR_S16(); - mlib_d64 *flut = (mlib_d64 *)mlib_ImageGetLutNormalTable(colormap) - - mlib_ImageGetLutOffset(colormap); - mlib_d64 dstRowData[MLIB_LIMIT]; - mlib_d64 *dstRowPtr = dstRowData; - const mlib_s16 *mlib_filters_table_s16_4; - - if (filter == MLIB_BICUBIC) { - mlib_filters_table_s16_4 = mlib_filters_s16_bc_4; - } else { - mlib_filters_table_s16_4 = mlib_filters_s16_bc2_4; - } - - srcYStride >>= 1; - - if (max_xsize > MLIB_LIMIT) { - dstRowPtr = mlib_malloc(sizeof(mlib_d64) * max_xsize); - - if (dstRowPtr == NULL) return MLIB_FAILURE; - } - - for (j = yStart; j <= yFinish; j++) { - - CLIP(); - - vis_write_gsr(10 << 3); - - cols = xRight - xLeft + 1; - i = 0; - - if (i <= cols - 4) { - - NEXT_PIXEL_4BC(); - LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4); - - NEXT_PIXEL_4BC(); - - BC_S16_4CH(mlib_filters_table_s16_4); - FADD_4BC_S16(); - - BC_S16_4CH(mlib_filters_table_s16_4); - -#pragma pipeloop(0) - - for (; i < cols-4; i++) { - *dstPixelPtr++ = res; - - FADD_4BC_S16(); - BC_S16_4CH(mlib_filters_table_s16_4); - } - - *dstPixelPtr++ = res; - - FADD_4BC_S16(); - *dstPixelPtr++ = res; - - RESULT_4BC_S16_1PIXEL(); - *dstPixelPtr++ = res; - - LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4); - RESULT_4BC_S16_1PIXEL(); - *dstPixelPtr++ = res; - i += 4; - } - -#pragma pipeloop(0) - for (; i < cols; i++) { - NEXT_PIXEL_4BC(); - LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4); - RESULT_4BC_S16_1PIXEL(); - *dstPixelPtr++ = res; - } - - mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4((mlib_s16 *)dstRowPtr, - dstIndexPtr, - xRight - xLeft + 1, - colormap); - } - - if (dstRowPtr != dstRowData) mlib_free(dstRowPtr); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 5 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 8) - 1) << 3) - -/***************************************************************/ -mlib_status mlib_ImageAffineIndex_S16_U8_4CH_BC(mlib_affine_param *param, - const void *colormap) -{ - DECLAREVAR(); - DECLAREVAR_U8(); - mlib_f32 *flut = (mlib_f32 *)mlib_ImageGetLutNormalTable(colormap) - - mlib_ImageGetLutOffset(colormap); - mlib_d64 dstRowData[MLIB_LIMIT/2]; - mlib_d64 *dstRowPtr = dstRowData; - const mlib_s16 *mlib_filters_table_u8, *mlib_filters_table_u8_4; - - if (filter == MLIB_BICUBIC) { - mlib_filters_table_u8 = mlib_filters_u8_bc; - mlib_filters_table_u8_4 = mlib_filters_u8_bc_4; - } else { - mlib_filters_table_u8 = mlib_filters_u8_bc2; - mlib_filters_table_u8_4 = mlib_filters_u8_bc2_4; - } - - srcYStride >>= 1; - - if (max_xsize > MLIB_LIMIT) { - dstRowPtr = mlib_malloc(sizeof(mlib_d64) * ((max_xsize + 1) >> 1)); - - if (dstRowPtr == NULL) return MLIB_FAILURE; - } - - vis_write_gsr(3 << 3); - - for (j = yStart; j <= yFinish; j++) { - - CLIP(); - - cols = xRight - xLeft + 1; - - i = 0; - - if (i <= cols - 6) { - - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - - NEXT_PIXEL_4BC(); - - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - FADD_4BC_U8(); - - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - -#pragma pipeloop(0) - for (; i <= cols-8; i += 2) { - *dstPixelPtr++ = res; - - FADD_4BC_U8(); - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - } - - *dstPixelPtr++ = res; - - FADD_4BC_U8(); - *dstPixelPtr++ = res; - - RESULT_4BC_U8_1PIXEL(0); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(1); - FADD_4BC_U8(); - - *dstPixelPtr++ = res; - i += 6; - } - - if (i <= cols-4) { - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - - NEXT_PIXEL_4BC(); - - BC_U8_4CH(0, mlib_filters_table_u8, mlib_filters_table_u8_4); - BC_U8_4CH(1, mlib_filters_table_u8, mlib_filters_table_u8_4); - FADD_4BC_U8(); - *dstPixelPtr++ = res; - - RESULT_4BC_U8_1PIXEL(0); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(1); - FADD_4BC_U8(); - - *dstPixelPtr++ = res; - i += 4; - } - - if (i <= cols-2) { - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(0); - - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(1); - FADD_4BC_U8(); - - *dstPixelPtr++ = res; - i += 2; - } - - if (i < cols) { - NEXT_PIXEL_4BC(); - LOAD_BC_U8_4CH_1PIXEL(mlib_filters_table_u8, mlib_filters_table_u8_4); - RESULT_4BC_U8_1PIXEL(0); - - d0 = vis_fpadd16(d00, d10); - d1 = vis_fpadd16(d20, d30); - d0 = vis_fpadd16(d0, d1); - res = vis_fpack16_pair(d0, d0); - *dstPixelPtr++ = res; - } - - mlib_ImageColorTrue2IndexLine_U8_S16_4((mlib_u8 *)dstRowPtr, - dstIndexPtr, - xRight - xLeft + 1, - colormap); - } - - if (dstRowPtr != dstRowData) mlib_free(dstRowPtr); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef FILTER_SHIFT -#define FILTER_SHIFT 4 -#undef FILTER_MASK -#define FILTER_MASK (((1 << 9) - 1) << 3) - -/***************************************************************/ -mlib_status mlib_ImageAffineIndex_S16_S16_4CH_BC(mlib_affine_param *param, - const void *colormap) -{ - DECLAREVAR(); - DECLAREVAR_S16(); - mlib_d64 *flut = (mlib_d64 *)mlib_ImageGetLutNormalTable(colormap) - - mlib_ImageGetLutOffset(colormap); - mlib_d64 dstRowData[MLIB_LIMIT]; - mlib_d64 *dstRowPtr = dstRowData; - const mlib_s16 *mlib_filters_table_s16_4; - - if (filter == MLIB_BICUBIC) { - mlib_filters_table_s16_4 = mlib_filters_s16_bc_4; - } else { - mlib_filters_table_s16_4 = mlib_filters_s16_bc2_4; - } - - srcYStride >>= 1; - - if (max_xsize > MLIB_LIMIT) { - dstRowPtr = mlib_malloc(sizeof(mlib_d64) * max_xsize); - - if (dstRowPtr == NULL) return MLIB_FAILURE; - } - - for (j = yStart; j <= yFinish; j++) { - - CLIP(); - - vis_write_gsr(10 << 3); - - cols = xRight - xLeft + 1; - i = 0; - - if (i <= cols - 4) { - - NEXT_PIXEL_4BC(); - LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4); - - NEXT_PIXEL_4BC(); - - BC_S16_4CH(mlib_filters_table_s16_4); - FADD_4BC_S16(); - - BC_S16_4CH(mlib_filters_table_s16_4); - -#pragma pipeloop(0) - - for (; i < cols-4; i++) { - *dstPixelPtr++ = res; - - FADD_4BC_S16(); - BC_S16_4CH(mlib_filters_table_s16_4); - } - - *dstPixelPtr++ = res; - - FADD_4BC_S16(); - *dstPixelPtr++ = res; - - RESULT_4BC_S16_1PIXEL(); - *dstPixelPtr++ = res; - - LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4); - RESULT_4BC_S16_1PIXEL(); - *dstPixelPtr++ = res; - i += 4; - } - -#pragma pipeloop(0) - for (; i < cols; i++) { - NEXT_PIXEL_4BC(); - LOAD_BC_S16_4CH_1PIXEL(mlib_filters_table_s16_4); - RESULT_4BC_S16_1PIXEL(); - *dstPixelPtr++ = res; - } - - mlib_ImageColorTrue2IndexLine_S16_S16_4((mlib_s16 *)dstRowPtr, - dstIndexPtr, - xRight - xLeft + 1, - colormap); - } - - if (dstRowPtr != dstRowData) mlib_free(dstRowPtr); - - return MLIB_SUCCESS; -} - -/***************************************************************/ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL.c index 6d73ae05c36..f0abee6fa6c 100644 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL.c +++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL.c @@ -33,7 +33,6 @@ #include "vis_proto.h" #include "mlib_image.h" -#include "mlib_ImageColormap.h" #include "mlib_ImageCopy.h" #include "mlib_ImageAffine.h" #include "mlib_v_ImageFilters.h" @@ -719,134 +718,3 @@ mlib_status FUN_NAME(4ch_na)(mlib_affine_param *param) } /***************************************************************/ -#define LUT(x) plut[x] - -mlib_status FUN_NAME(u8_i)(mlib_affine_param *param, - const void *colormap) -{ - DECLAREVAR(); - mlib_s32 nchan = mlib_ImageGetLutChannels(colormap); - mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap); - mlib_f32 *plut = (mlib_f32*)mlib_ImageGetLutNormalTable(colormap) - lut_off; - mlib_s32 max_xsize = param -> max_xsize; - mlib_f32 buff[BUF_SIZE], *pbuff = buff; - - if (max_xsize > BUF_SIZE) { - pbuff = mlib_malloc(max_xsize*sizeof(mlib_f32)); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - vis_write_gsr(3 << 3); - - for (j = yStart; j <= yFinish; j++) { - mlib_f32 s0, s1, s2, s3; - DTYPE *sp; - - NEW_LINE(1); - -#pragma pipeloop(0) - for (i = 0; i < size; i++) { - GET_FILTER_XY(); - - sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT); - s0 = LUT(sp[0]); - s1 = LUT(sp[1]); - s2 = LUT(sp[srcYStride]); - s3 = LUT(sp[srcYStride + 1]); - - PROCESS_4CH(s0, s1, s2, s3); - - pbuff[i] = vis_fpack16(dd); - X += dX; - Y += dY; - } - - if (nchan == 3) { - mlib_ImageColorTrue2IndexLine_U8_U8_3_in_4((void*)pbuff, (void*)dl, size, colormap); - } else { - mlib_ImageColorTrue2IndexLine_U8_U8_4((void*)pbuff, (void*)dl, size, colormap); - } - } - - if (pbuff != buff) { - mlib_free(pbuff); - } - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef DTYPE -#define DTYPE mlib_s16 - -mlib_status FUN_NAME(s16_i)(mlib_affine_param *param, - const void *colormap) -{ - DECLAREVAR(); - mlib_s32 nchan = mlib_ImageGetLutChannels(colormap); - mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap); - mlib_f32 *plut = (mlib_f32*)mlib_ImageGetLutNormalTable(colormap) - lut_off; - mlib_s32 max_xsize = param -> max_xsize; - mlib_f32 buff[BUF_SIZE], *pbuff = buff; - - srcYStride /= sizeof(DTYPE); - - if (max_xsize > BUF_SIZE) { - pbuff = mlib_malloc(max_xsize*sizeof(mlib_f32)); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - vis_write_gsr(3 << 3); - - for (j = yStart; j <= yFinish; j++) { - mlib_f32 s0, s1, s2, s3; - DTYPE *sp; - - NEW_LINE(1); - -#pragma pipeloop(0) - for (i = 0; i < size; i++) { - GET_FILTER_XY(); - - sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT); - s0 = LUT(sp[0]); - s1 = LUT(sp[1]); - s2 = LUT(sp[srcYStride]); - s3 = LUT(sp[srcYStride + 1]); - - PROCESS_4CH(s0, s1, s2, s3); - - pbuff[i] = vis_fpack16(dd); - X += dX; - Y += dY; - } - - if (nchan == 3) { - mlib_ImageColorTrue2IndexLine_U8_S16_3_in_4((void*)pbuff, (void*)dl, size, colormap); - } else { - mlib_ImageColorTrue2IndexLine_U8_S16_4((void*)pbuff, (void*)dl, size, colormap); - } - } - - if (pbuff != buff) { - mlib_free(pbuff); - } - - return MLIB_SUCCESS; -} - -/***************************************************************/ -const type_affine_i_fun mlib_AffineFunArr_bl_i[] = { - mlib_ImageAffine_u8_u8_i_bl, - mlib_ImageAffine_u8_u8_i_bl, - mlib_ImageAffine_u8_s16_i_bl, - mlib_ImageAffine_u8_s16_i_bl, - mlib_ImageAffine_s16_u8_i_bl, - mlib_ImageAffine_s16_u8_i_bl, - mlib_ImageAffine_s16_s16_i_bl, - mlib_ImageAffine_s16_s16_i_bl -}; - -/***************************************************************/ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_S16.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_S16.c index 05e9c6f36a5..c51c3519c43 100644 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_S16.c +++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_S16.c @@ -33,7 +33,6 @@ #include "vis_proto.h" #include "mlib_image.h" -#include "mlib_ImageColormap.h" #include "mlib_ImageCopy.h" #include "mlib_ImageAffine.h" #include "mlib_v_ImageFilters.h" @@ -716,128 +715,3 @@ mlib_status FUN_NAME(4ch_na)(mlib_affine_param *param) } /***************************************************************/ -#define LUT(x) plut[x] - -mlib_status FUN_NAME(s16_i)(mlib_affine_param *param, - const void *colormap) -{ - DECLAREVAR(); - mlib_s32 nchan = mlib_ImageGetLutChannels(colormap); - mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap); - mlib_d64 *plut = (mlib_d64*)mlib_ImageGetLutNormalTable(colormap) - lut_off; - mlib_s32 max_xsize = param -> max_xsize; - mlib_d64 buff[BUF_SIZE], *pbuff = buff; - - srcYStride /= sizeof(DTYPE); - - if (max_xsize > BUF_SIZE) { - pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64)); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */ - dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */ - dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF)); - dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF)); - - for (j = yStart; j <= yFinish; j++) { - DTYPE *sp; - - NEW_LINE(1); - - deltax = DOUBLE_4U16(X, X, X, X); - deltay = DOUBLE_4U16(Y, Y, Y, Y); - -#pragma pipeloop(0) - for (i = 0; i < size; i++) { - sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT); - s0 = LUT(sp[0]); - s1 = LUT(sp[1]); - s2 = LUT(sp[srcYStride]); - s3 = LUT(sp[srcYStride + 1]); - - BL_SUM(); - - pbuff[i] = dd; - X += dX; - Y += dY; - } - - if (nchan == 3) { - mlib_ImageColorTrue2IndexLine_S16_S16_3_in_4((void*)pbuff, (void*)dl, size, colormap); - } else { - mlib_ImageColorTrue2IndexLine_S16_S16_4((void*)pbuff, (void*)dl, size, colormap); - } - } - - if (pbuff != buff) { - mlib_free(pbuff); - } - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef DTYPE -#define DTYPE mlib_u8 - -mlib_status FUN_NAME(u8_i)(mlib_affine_param *param, - const void *colormap) -{ - DECLAREVAR(); - mlib_s32 nchan = mlib_ImageGetLutChannels(colormap); - mlib_s32 lut_off = mlib_ImageGetLutOffset(colormap); - mlib_d64 *plut = (mlib_d64*)mlib_ImageGetLutNormalTable(colormap) - lut_off; - mlib_s32 max_xsize = param -> max_xsize; - mlib_d64 buff[BUF_SIZE], *pbuff = buff; - - if (max_xsize > BUF_SIZE) { - pbuff = mlib_malloc(max_xsize*sizeof(mlib_d64)); - - if (pbuff == NULL) return MLIB_FAILURE; - } - - dX = (dX - (dX >> 31)) &~ 1; /* rounding towards ZERO */ - dY = (dY - (dY >> 31)) &~ 1; /* rounding towards ZERO */ - dx64 = vis_to_double_dup((((dX >> 1) & 0xFFFF) << 16) | ((dX >> 1) & 0xFFFF)); - dy64 = vis_to_double_dup((((dY >> 1) & 0xFFFF) << 16) | ((dY >> 1) & 0xFFFF)); - - for (j = yStart; j <= yFinish; j++) { - DTYPE *sp; - - NEW_LINE(1); - - deltax = DOUBLE_4U16(X, X, X, X); - deltay = DOUBLE_4U16(Y, Y, Y, Y); - -#pragma pipeloop(0) - for (i = 0; i < size; i++) { - sp = *(DTYPE**)((mlib_u8*)lineAddr + PTR_SHIFT(Y)) + (X >> MLIB_SHIFT); - s0 = LUT(sp[0]); - s1 = LUT(sp[1]); - s2 = LUT(sp[srcYStride]); - s3 = LUT(sp[srcYStride + 1]); - - BL_SUM(); - - pbuff[i] = dd; - X += dX; - Y += dY; - } - - if (nchan == 3) { - mlib_ImageColorTrue2IndexLine_S16_U8_3_in_4((void*)pbuff, (void*)dl, size, colormap); - } else { - mlib_ImageColorTrue2IndexLine_S16_U8_4((void*)pbuff, (void*)dl, size, colormap); - } - } - - if (pbuff != buff) { - mlib_free(pbuff); - } - - return MLIB_SUCCESS; -} - -/***************************************************************/ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_U16.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_U16.c index b9de874c46c..bc2b7e9e087 100644 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_U16.c +++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffine_BL_U16.c @@ -33,7 +33,6 @@ #include "vis_proto.h" #include "mlib_image.h" -#include "mlib_ImageColormap.h" #include "mlib_ImageCopy.h" #include "mlib_ImageAffine.h" #include "mlib_v_ImageFilters.h" diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.c deleted file mode 100644 index 6d3d92b1f45..00000000000 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.c +++ /dev/null @@ -1,825 +0,0 @@ -/* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - -/* - * FUNCTIONS - * mlib_ImageChannelExtract - Copy the selected channels of the source - * image into the destination image - * - * SYNOPSIS - * mlib_status mlib_ImageChannelExtract(mlib_image *dst, - * mlib_image *src, - * mlib_s32 cmask); - * ARGUMENT - * dst Pointer to destination image. - * src Pointer to source image. - * cmask Source channel selection mask. - * The least significant bit (LSB) is corresponding to the - * last channel in the source image data. - * The bits with value 1 stand for the channels selected. - * If more than N channels are selected, the leftmost N - * channels are extracted, where N is the number of channels - * in the destination image. - * - * RESTRICTION - * The src and dst must have the same width, height and data type. - * The src and dst can have 1, 2, 3 or 4 channels. - * The src and dst can be either MLIB_BYTE, MLIB_SHORT, MLIB_INT, - * MLIB_FLOAT or MLIB_DOUBLE. - * - * DESCRIPTION - * Copy the selected channels of the source image into the - * destination image - */ - -#include -#include "mlib_image.h" -#include "mlib_ImageCheck.h" - -/***************************************************************/ -/* functions defined in mlib_ImageChannelExtract_1.c */ - -void -mlib_v_ImageChannelExtract_U8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 channels, mlib_s32 channeld, - mlib_s32 width, mlib_s32 height, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16(mlib_u16 *src, mlib_s32 slb, - mlib_u16 *dst, mlib_s32 dlb, - mlib_s32 channels, mlib_s32 channeld, - mlib_s32 width, mlib_s32 height, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S32(mlib_s32 *src, mlib_s32 slb, - mlib_s32 *dst, mlib_s32 dlb, - mlib_s32 channels, mlib_s32 channeld, - mlib_s32 width, mlib_s32 height, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_D64(mlib_d64 *src, mlib_s32 slb, - mlib_d64 *dst, mlib_s32 dlb, - mlib_s32 channels, mlib_s32 channeld, - mlib_s32 width, mlib_s32 height, - mlib_s32 cmask); - -/***************************************************************/ - -void mlib_v_ImageChannelExtract_U8_2_1(mlib_u8 *sl, mlib_s32 slb, - mlib_u8 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height); - -void mlib_v_ImageChannelExtract_U8_3_2(mlib_u8 *sl, mlib_s32 slb, - mlib_u8 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height, - mlib_s32 count1); - -void mlib_v_ImageChannelExtract_U8_4_2(mlib_u8 *sl, mlib_s32 slb, - mlib_u8 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height, - mlib_s32 count1); - -void mlib_v_ImageChannelExtract_32_2_1(mlib_f32 *sl, mlib_s32 slb, - mlib_f32 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height); - -void mlib_v_ImageChannelExtract_32_3_1(mlib_f32 *sl, mlib_s32 slb, - mlib_f32 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height); - -void mlib_v_ImageChannelExtract_32_3_2(mlib_f32 *sp, mlib_s32 slb, - mlib_f32 *dp, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height, - mlib_s32 deltac1); - -void mlib_v_ImageChannelExtract_32_4_1(mlib_f32 *sl, mlib_s32 slb, - mlib_f32 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height); - -void mlib_v_ImageChannelExtract_32_4_2(mlib_f32 *sp, mlib_s32 slb, - mlib_f32 *dp, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height, - mlib_s32 deltac1); - -void mlib_v_ImageChannelExtract_32_4_3(mlib_f32 *sl, mlib_s32 slb, - mlib_f32 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height, - mlib_s32 mask_off); - -/***************************************************************/ - -void -mlib_v_ImageChannelExtract_U8_21_A8D1X8(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_U8_21_A8D2X8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_U8_21_D1(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_U8_21(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_U8_31_A8D1X8(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_U8_31_A8D2X8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_U8_31_D1(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_U8_31(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_U8_41_A8D1X8(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_U8_41_A8D2X8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_U8_41_D1(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_U8_41(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16_11_A8D1X4(mlib_s16 *src, mlib_s16 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelExtract_S16_21_A8D1X4(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16_21_A8D2X4(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16_21_D1(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16_21(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16_31_A8D1X4(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16_31_A8D2X4(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16_31_D1(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16_31(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16_41_A8D1X4(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16_41_A8D2X4(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16_41_D1(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelExtract_S16_41(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); - -/***************************************************************/ -/* functions defined in mlib_ImageChannelExtract_43.c */ - -void -mlib_v_ImageChannelExtract_U8_43R_A8D1X8(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelExtract_U8_43R_A8D2X8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelExtract_U8_43R_D1(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelExtract_U8_43R(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelExtract_S16_43R_A8D1X4(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelExtract_S16_43R_A8D2X4(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelExtract_S16_43R_D1(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelExtract_S16_43R(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelExtract_U8_43L_A8D1X8(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelExtract_U8_43L_A8D2X8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelExtract_U8_43L_D1(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelExtract_U8_43L(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelExtract_S16_43L_A8D1X4(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelExtract_S16_43L_A8D2X4(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelExtract_S16_43L_D1(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelExtract_S16_43L(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); - -/***************************************************************/ - -#ifdef MLIB_TEST -mlib_status -mlib_v_ImageChannelExtract(mlib_image *dst, - mlib_image *src, - mlib_s32 cmask) -#else -mlib_status -mlib_ImageChannelExtract(mlib_image *dst, - mlib_image *src, - mlib_s32 cmask) -#endif -{ - const mlib_s32 X8 = 0x7; - const mlib_s32 X4 = 0x3; - const mlib_s32 X2 = 0x1; - const mlib_s32 A8D1 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_ONEDVECTOR; - const mlib_s32 A8D2X8 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH8X; - const mlib_s32 A8D2X4 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH4X; - const mlib_s32 A8D2X2 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH2X; - void *sp; /* pointer for pixel in src */ - void *dp; /* pointer for pixel in dst */ - mlib_s32 ncmask = 0; /* normalized channel mask */ - mlib_s32 channels; /* number of channels for src */ - mlib_s32 channeld; /* number of channels for dst */ - mlib_s32 width, height; /* for src and dst */ - mlib_s32 strides; /* strides in bytes for src */ - mlib_s32 strided; /* strides in bytes for dst */ - mlib_s32 flags; - mlib_s32 flagd; - mlib_s32 dsize; - int delta0 = 0; /* offset of first selected channel */ - int count1 = 0; /* number of channels in first group */ - int i, bit1count = 0; - - MLIB_IMAGE_CHECK(src); - MLIB_IMAGE_CHECK(dst); - MLIB_IMAGE_TYPE_EQUAL(src, dst); - MLIB_IMAGE_SIZE_EQUAL(src, dst); - - channels = mlib_ImageGetChannels(src); - channeld = mlib_ImageGetChannels(dst); - width = mlib_ImageGetWidth(src); - height = mlib_ImageGetHeight(src); - strides = mlib_ImageGetStride(src); - strided = mlib_ImageGetStride(dst); - sp = mlib_ImageGetData(src); - dp = mlib_ImageGetData(dst); - flags = mlib_ImageGetFlags(src); - flagd = mlib_ImageGetFlags(dst); - dsize = width * height; - - /* normalize the cmask, and count the number of bit with value 1 */ - for (i = (channels - 1); i >= 0; i--) { - if (((cmask & (1 << i)) != 0) && (bit1count < channeld)) { - ncmask += (1 << i); - bit1count++; - } - } - - /* do not support the cases in which the number of selected channels is - * less than the nubmber of channels in the destination image */ - if (bit1count < channeld) { - return MLIB_FAILURE; - } - - if (channels == channeld) { -#ifdef MLIB_TEST - mlib_v_ImageCopy(dst, src); -#else - mlib_ImageCopy(dst, src); -#endif - return MLIB_SUCCESS; - } - - switch (mlib_ImageGetType(src)) { - case MLIB_BYTE: - if (channeld == 1) { - switch (channels) { - case 2: - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X8) == 0)) { - mlib_v_ImageChannelExtract_U8_21_A8D1X8((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize, - ncmask); - } - else if (((flags & A8D2X8) == 0) && - ((flagd & A8D2X8) == 0)) { - mlib_v_ImageChannelExtract_U8_21_A8D2X8((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height, - ncmask); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelExtract_U8_21_D1((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize, - ncmask); - } - else { - mlib_v_ImageChannelExtract_U8_21((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height, - ncmask); - } - return MLIB_SUCCESS; - - case 3: - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X8) == 0)) { - mlib_v_ImageChannelExtract_U8_31_A8D1X8((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize, - ncmask); - } - else if (((flags & A8D2X8) == 0) && - ((flagd & A8D2X8) == 0)) { - mlib_v_ImageChannelExtract_U8_31_A8D2X8((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height, - ncmask); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelExtract_U8_31_D1((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize, - ncmask); - } - else { - mlib_v_ImageChannelExtract_U8_31((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height, - ncmask); - } - return MLIB_SUCCESS; - - case 4: - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X8) == 0)) { - mlib_v_ImageChannelExtract_U8_41_A8D1X8((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize, - ncmask); - } - else if (((flags & A8D2X8) == 0) && - ((flagd & A8D2X8) == 0)) { - mlib_v_ImageChannelExtract_U8_41_A8D2X8((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height, - ncmask); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelExtract_U8_41_D1((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize, - ncmask); - } - else { - mlib_v_ImageChannelExtract_U8_41((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height, - ncmask); - } - return MLIB_SUCCESS; - - default: - return MLIB_FAILURE; - } - } - else if ((channels == 4) && (channeld == 3) && (ncmask == 7)) { - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X8) == 0)) { - mlib_v_ImageChannelExtract_U8_43R_A8D1X8((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize); - } - else if (((flags & A8D2X8) == 0) && - ((flagd & A8D2X8) == 0)) { - mlib_v_ImageChannelExtract_U8_43R_A8D2X8((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelExtract_U8_43R_D1((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize); - } - else { - mlib_v_ImageChannelExtract_U8_43R((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height); - } - return MLIB_SUCCESS; - } - else if ((channels == 4) && (channeld == 3) && (ncmask == 14)) { - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X8) == 0)) { - mlib_v_ImageChannelExtract_U8_43L_A8D1X8((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize); - } - else if (((flags & A8D2X8) == 0) && - ((flagd & A8D2X8) == 0)) { - mlib_v_ImageChannelExtract_U8_43L_A8D2X8((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelExtract_U8_43L_D1((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize); - } - else { - mlib_v_ImageChannelExtract_U8_43L((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height); - } - return MLIB_SUCCESS; - } - break; - - case MLIB_SHORT: - if (channeld == 1) { - switch (channels) { - case 2: - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X4) == 0)) { - mlib_v_ImageChannelExtract_S16_21_A8D1X4((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize, - ncmask); - } - else if (((flags & A8D2X4) == 0) && - ((flagd & A8D2X4) == 0)) { - mlib_v_ImageChannelExtract_S16_21_A8D2X4((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height, - ncmask); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelExtract_S16_21_D1((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize, - ncmask); - } - else { - mlib_v_ImageChannelExtract_S16_21((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height, - ncmask); - } - return MLIB_SUCCESS; - - case 3: - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X4) == 0)) { - mlib_v_ImageChannelExtract_S16_31_A8D1X4((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize, - ncmask); - } - else if (((flags & A8D2X4) == 0) && - ((flagd & A8D2X4) == 0)) { - mlib_v_ImageChannelExtract_S16_31_A8D2X4((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height, - ncmask); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelExtract_S16_31_D1((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize, - ncmask); - } - else { - mlib_v_ImageChannelExtract_S16_31((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height, - ncmask); - } - return MLIB_SUCCESS; - - case 4: - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X4) == 0)) { - mlib_v_ImageChannelExtract_S16_41_A8D1X4((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize, - ncmask); - } - else if (((flags & A8D2X4) == 0) && - ((flagd & A8D2X4) == 0)) { - mlib_v_ImageChannelExtract_S16_41_A8D2X4((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height, - ncmask); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelExtract_S16_41_D1((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize, - ncmask); - } - else { - mlib_v_ImageChannelExtract_S16_41((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height, - ncmask); - } - return MLIB_SUCCESS; - default: - return MLIB_FAILURE; - } - } - else if ((channels == 4) && (channeld == 3) && (ncmask == 7)) { - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X4) == 0)) { - mlib_v_ImageChannelExtract_S16_43R_A8D1X4((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize); - } - else if (((flags & A8D2X4) == 0) && - ((flagd & A8D2X4) == 0)) { - mlib_v_ImageChannelExtract_S16_43R_A8D2X4((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelExtract_S16_43R_D1((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize); - } - else { - mlib_v_ImageChannelExtract_S16_43R((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height); - } - return MLIB_SUCCESS; - } - else if ((channels == 4) && (channeld == 3) && (ncmask == 14)) { - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X4) == 0)) { - mlib_v_ImageChannelExtract_S16_43L_A8D1X4((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize); - } - else if (((flags & A8D2X4) == 0) && - ((flagd & A8D2X4) == 0)) { - mlib_v_ImageChannelExtract_S16_43L_A8D2X4((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelExtract_S16_43L_D1((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize); - } - else { - mlib_v_ImageChannelExtract_S16_43L((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height); - } - return MLIB_SUCCESS; - } - break; - - } - -/***************************************************************/ - /* From C version */ - - for (i = (channels - 1); i >= 0; i--) { - if (!(ncmask & (1 << i))) delta0++; - else break; - } - for (; i >= 0; i--) { - if (ncmask & (1 << i)) count1++; - else break; - } - - switch (mlib_ImageGetType(src)) { - case MLIB_BYTE: - { - mlib_u8 *sl = (mlib_u8 *)sp + delta0; - mlib_u8 *dl = (mlib_u8 *)dp; - - switch (channels*10 + channeld) { - case 32: - mlib_v_ImageChannelExtract_U8_3_2(sl, strides, dl, strided, width, height, count1); - return MLIB_SUCCESS; - - case 42: - if (ncmask == 0xA || ncmask == 0x5) { /* mask 1010 or 0101 */ - mlib_v_ImageChannelExtract_U8_2_1(sl, strides, dl, strided, 2*width, height); - return MLIB_SUCCESS; - } - mlib_v_ImageChannelExtract_U8_4_2(sl, strides, dl, strided, width, height, count1); - return MLIB_SUCCESS; - - case 43: - mlib_v_ImageChannelExtract_U8((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - channels, channeld, - width, height, - ncmask); - return MLIB_SUCCESS; - - default: return MLIB_FAILURE; - } - } - - case MLIB_SHORT: - mlib_v_ImageChannelExtract_S16((mlib_u16 *)sp, strides, - (mlib_u16 *)dp, strided, - channels, channeld, - width, height, - ncmask); - break; - - case MLIB_INT: - case MLIB_FLOAT: - { - mlib_f32 *sl = (mlib_f32 *)sp + delta0; - mlib_f32 *dl = (mlib_f32 *)dp; - strides /= 4; - strided /= 4; - - switch (channels*10 + channeld) { - case 21: - mlib_v_ImageChannelExtract_32_2_1(sl, strides, dl, strided, width, height); - return MLIB_SUCCESS; - - case 31: - mlib_v_ImageChannelExtract_32_3_1(sl, strides, dl, strided, width, height); - return MLIB_SUCCESS; - - case 32: - mlib_v_ImageChannelExtract_32_3_2(sl, strides, dl, strided, width, height, count1); - return MLIB_SUCCESS; - - case 41: - mlib_v_ImageChannelExtract_32_4_1(sl, strides, dl, strided, width, height); - return MLIB_SUCCESS; - - case 42: - if (ncmask == 0xA || ncmask == 0x5) { /* mask 1010 or 0101 */ - mlib_v_ImageChannelExtract_32_2_1(sl, strides, dl, strided, 2*width, height); - } else { - mlib_v_ImageChannelExtract_32_4_2(sl, strides, dl, strided, width, height, count1); - } - return MLIB_SUCCESS; - - case 43: - mlib_v_ImageChannelExtract_32_4_3(sl, strides, dl, strided, width, height, count1); - return MLIB_SUCCESS; - - default: - return MLIB_FAILURE; - } - } - case MLIB_DOUBLE: - mlib_v_ImageChannelExtract_D64((mlib_d64 *)sp, strides, - (mlib_d64 *)dp, strided, - channels, channeld, - width, height, - ncmask); - break; - - case MLIB_BIT: - default: - return MLIB_FAILURE; /* MLIB_BIT is not supported here */ - } - - return MLIB_SUCCESS; -} - -/***************************************************************/ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.h b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.h index 6193ec130e3..7c5946423d9 100644 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.h +++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.h @@ -32,348 +32,29 @@ extern "C" { #endif /* __cplusplus */ -void mlib_v_ImageChannelExtract_U8_21_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_U8_21_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - void mlib_v_ImageChannelExtract_U8_21_D1(const mlib_u8 *src, mlib_u8 *dst, mlib_s32 dsize, mlib_s32 cmask); -void mlib_v_ImageChannelExtract_U8_21(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_U8_31_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_U8_31_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - void mlib_v_ImageChannelExtract_U8_31_D1(const mlib_u8 *src, mlib_u8 *dst, mlib_s32 dsize, mlib_s32 cmask); -void mlib_v_ImageChannelExtract_U8_31(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_U8_41_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_U8_41_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - void mlib_v_ImageChannelExtract_U8_41_D1(const mlib_u8 *src, mlib_u8 *dst, mlib_s32 dsize, mlib_s32 cmask); -void mlib_v_ImageChannelExtract_U8_41(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16_21_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16_21_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16_21_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16_21(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16_31_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16_31_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16_31_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16_31(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16_41_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16_41_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16_41_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16_41(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_U8_43R_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelExtract_U8_43R_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelExtract_U8_43R_D1(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelExtract_U8_43R(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelExtract_S16_43R_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelExtract_S16_43R_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelExtract_S16_43R_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelExtract_S16_43R(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelExtract_U8_43L_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelExtract_U8_43L_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - void mlib_v_ImageChannelExtract_U8_43L_D1(const mlib_u8 *src, mlib_u8 *dst, mlib_s32 dsize); -void mlib_v_ImageChannelExtract_U8_43L(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelExtract_S16_43L_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelExtract_S16_43L_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - void mlib_v_ImageChannelExtract_S16_43L_D1(const mlib_s16 *src, mlib_s16 *dst, mlib_s32 dsize); -void mlib_v_ImageChannelExtract_S16_43L(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelExtract_U8_2_1(const mlib_u8 *sl, - mlib_s32 slb, - mlib_u8 *dl, - mlib_s32 dlb, - mlib_s32 width, - mlib_s32 height); - -void mlib_v_ImageChannelExtract_U8_3_2(const mlib_u8 *sl, - mlib_s32 slb, - mlib_u8 *dl, - mlib_s32 dlb, - mlib_s32 width, - mlib_s32 height, - mlib_s32 count1); - -void mlib_v_ImageChannelExtract_U8_4_2(const mlib_u8 *sl, - mlib_s32 slb, - mlib_u8 *dl, - mlib_s32 dlb, - mlib_s32 width, - mlib_s32 height, - mlib_s32 count1); - -void mlib_v_ImageChannelExtract_32_2_1(const mlib_f32 *sp, - mlib_s32 slb, - mlib_f32 *dp, - mlib_s32 dlb, - mlib_s32 width, - mlib_s32 height); - -void mlib_v_ImageChannelExtract_32_3_1(const mlib_f32 *sl, - mlib_s32 slb, - mlib_f32 *dl, - mlib_s32 dlb, - mlib_s32 width, - mlib_s32 height); - -void mlib_v_ImageChannelExtract_32_3_2(const mlib_f32 *sl, - mlib_s32 slb, - mlib_f32 *dl, - mlib_s32 dlb, - mlib_s32 width, - mlib_s32 height, - mlib_s32 count1); - -void mlib_v_ImageChannelExtract_32_4_1(const mlib_f32 *sp, - mlib_s32 slb, - mlib_f32 *dp, - mlib_s32 dlb, - mlib_s32 width, - mlib_s32 height); - -void mlib_v_ImageChannelExtract_32_4_2(const mlib_f32 *sl, - mlib_s32 slb, - mlib_f32 *dl, - mlib_s32 dlb, - mlib_s32 width, - mlib_s32 height, - mlib_s32 count1); - -void mlib_v_ImageChannelExtract_32_4_3(const mlib_f32 *sl, - mlib_s32 slb, - mlib_f32 *dl, - mlib_s32 dlb, - mlib_s32 width, - mlib_s32 height, - mlib_s32 count1); - -void mlib_v_ImageChannelExtract_U8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, - mlib_s32 height, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_S16(const mlib_u16 *src, - mlib_s32 slb, - mlib_u16 *dst, - mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, - mlib_s32 height, - mlib_s32 cmask); - -void mlib_v_ImageChannelExtract_D64(const mlib_d64 *src, - mlib_s32 slb, - mlib_d64 *dst, - mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, - mlib_s32 height, - mlib_s32 cmask); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_1.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_1.c index 69ae7231737..54f26d5eb77 100644 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_1.c +++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_1.c @@ -29,30 +29,9 @@ * FILENAME: mlib_ImageChannelExtract_1.c * * FUNCTIONS - * mlib_v_ImageChannelExtract_U8_21_A8D1X8 - * mlib_v_ImageChannelExtract_U8_21_A8D2X8 * mlib_v_ImageChannelExtract_U8_21_D1 - * mlib_v_ImageChannelExtract_U8_21 - * mlib_v_ImageChannelExtract_U8_31_A8D1X8 - * mlib_v_ImageChannelExtract_U8_31_A8D2X8 * mlib_v_ImageChannelExtract_U8_31_D1 - * mlib_v_ImageChannelExtract_U8_31 - * mlib_v_ImageChannelExtract_U8_41_A8D1X8 - * mlib_v_ImageChannelExtract_U8_41_A8D2X8 * mlib_v_ImageChannelExtract_U8_41_D1 - * mlib_v_ImageChannelExtract_U8_41 - * mlib_v_ImageChannelExtract_S16_21_A8D1X4 - * mlib_v_ImageChannelExtract_S16_21_A8D2X4 - * mlib_v_ImageChannelExtract_S16_21_D1 - * mlib_v_ImageChannelExtract_S16_21 - * mlib_v_ImageChannelExtract_S16_31_A8D1X4 - * mlib_v_ImageChannelExtract_S16_31_A8D2X4 - * mlib_v_ImageChannelExtract_S16_31_D1 - * mlib_v_ImageChannelExtract_S16_31 - * mlib_v_ImageChannelExtract_S16_41_A8D1X4 - * mlib_v_ImageChannelExtract_S16_41_A8D2X4 - * mlib_v_ImageChannelExtract_S16_41_D1 - * mlib_v_ImageChannelExtract_S16_41 * * ARGUMENT * src pointer to source image data @@ -93,100 +72,6 @@ sdd = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sdb)); \ dd = vis_fpmerge(vis_read_lo(sdc), vis_read_lo(sdd)) -/***************************************************************/ -/* extract one channel from a 2-channel image. - * both source and destination image data are 8-byte aligned. - * xsize is multiple of 8. - */ - -void mlib_v_ImageChannelExtract_U8_21_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 sd0, sd1; - mlib_d64 sda, sdb, sdc, sdd; - mlib_d64 dd; - mlib_s32 i; - - sp = (mlib_d64 *) src; - dp = (mlib_d64 *) dst; - - if (cmask == 2) { -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - CHANNELEXTRACT_U8_21L(sd0, sd1, dd); - *dp++ = dd; - } - } - else { -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - CHANNELEXTRACT_U8_21R(sd0, sd1, dd); - *dp++ = dd; - } - } -} - -/***************************************************************/ -/* extract one channel from a 2-channel image. - * both source and destination image data are 8-byte aligned. - * xsize is multiple of 8. - */ - -void mlib_v_ImageChannelExtract_U8_21_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 *sl, *dl; - mlib_d64 sd0, sd1; - mlib_d64 sda, sdb, sdc, sdd; - mlib_d64 dd; - mlib_s32 i, j; - - sp = sl = (mlib_d64 *) src; - dp = dl = (mlib_d64 *) dst; - - if (cmask == 2) { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - CHANNELEXTRACT_U8_21L(sd0, sd1, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - CHANNELEXTRACT_U8_21R(sd0, sd1, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } -} - /***************************************************************/ /* extract one channel from a 2-channel image. */ @@ -414,32 +299,6 @@ void mlib_v_ImageChannelExtract_U8_21_D1(const mlib_u8 *src, } } -/***************************************************************/ -/* extract one channel from a 2-channel image. - */ - -void mlib_v_ImageChannelExtract_U8_21(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_u8 *sa, *da; - mlib_u8 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelExtract_U8_21_D1(sa, da, xsize, cmask); - sa = sl += slb; - da = dl += dlb; - } -} - /***************************************************************/ #define CHANNELEXTRACT_U8_31L(sd0, sd1, sd2, dd) \ sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1)); \ @@ -467,119 +326,6 @@ void mlib_v_ImageChannelExtract_U8_21(const mlib_u8 *src, sde = vis_fpmerge(vis_read_hi(sdb), vis_read_lo(sdc)); \ dd = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde)) -/***************************************************************/ -void mlib_v_ImageChannelExtract_U8_31_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 sd0, sd1, sd2; - mlib_d64 sda, sdb, sdc, sdd, sde; - mlib_d64 dd; - mlib_s32 i; - - sp = (mlib_d64 *) src; - dp = (mlib_d64 *) dst; - - if (cmask == 4) { -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_U8_31L(sd0, sd1, sd2, dd); - *dp++ = dd; - } - } - else if (cmask == 2) { -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_U8_31M(sd0, sd1, sd2, dd); - *dp++ = dd; - } - } - else { -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_U8_31R(sd0, sd1, sd2, dd); - *dp++ = dd; - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_U8_31_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 *sl, *dl; - mlib_d64 sd0, sd1, sd2; - mlib_d64 sda, sdb, sdc, sdd, sde; - mlib_d64 dd; - mlib_s32 i, j; - - sp = sl = (mlib_d64 *) src; - dp = dl = (mlib_d64 *) dst; - - if (cmask == 4) { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_U8_31L(sd0, sd1, sd2, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else if (cmask == 2) { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_U8_31M(sd0, sd1, sd2, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_U8_31R(sd0, sd1, sd2, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } -} - /***************************************************************/ void mlib_v_ImageChannelExtract_U8_31_D1(const mlib_u8 *src, mlib_u8 *dst, @@ -931,29 +677,6 @@ void mlib_v_ImageChannelExtract_U8_31_D1(const mlib_u8 *src, } } -/***************************************************************/ -void mlib_v_ImageChannelExtract_U8_31(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_u8 *sa, *da; - mlib_u8 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelExtract_U8_31_D1(sa, da, xsize, cmask); - sa = sl += slb; - da = dl += dlb; - } -} - /***************************************************************/ #define CHANNELEXTRACT_U8_41L(sd0, sd1, sd2, sd3, dd) \ sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd2)); \ @@ -994,152 +717,6 @@ void mlib_v_ImageChannelExtract_U8_31(const mlib_u8 *src, sdf = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdd)); \ dd = vis_fpmerge(vis_read_lo(sde), vis_read_lo(sdf)) -/***************************************************************/ -void mlib_v_ImageChannelExtract_U8_41_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 sd0, sd1, sd2, sd3; - mlib_d64 sda, sdb, sdc, sdd, sde, sdf; - mlib_d64 dd; - mlib_s32 i; - - sp = (mlib_d64 *) src; - dp = (mlib_d64 *) dst; - - if (cmask == 8) { -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_U8_41L(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - } - else if (cmask == 4) { -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_U8_41ML(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - } - else if (cmask == 2) { -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_U8_41MR(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - } - else { -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_U8_41R(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_U8_41_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 *sl, *dl; - mlib_d64 sd0, sd1, sd2, sd3; - mlib_d64 sda, sdb, sdc, sdd, sde, sdf; - mlib_d64 dd; - mlib_s32 i, j; - - sp = sl = (mlib_d64 *) src; - dp = dl = (mlib_d64 *) dst; - - if (cmask == 8) { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_U8_41L(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else if (cmask == 4) { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_U8_41ML(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else if (cmask == 2) { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_U8_41MR(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_U8_41R(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } -} - /***************************************************************/ void mlib_v_ImageChannelExtract_U8_41_D1(const mlib_u8 *src, mlib_u8 *dst, @@ -1632,1560 +1209,3 @@ void mlib_v_ImageChannelExtract_U8_41_D1(const mlib_u8 *src, } /***************************************************************/ -void mlib_v_ImageChannelExtract_U8_41(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_u8 *sa, *da; - mlib_u8 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelExtract_U8_41_D1(sa, da, xsize, cmask); - sa = sl += slb; - da = dl += dlb; - } -} - -/***************************************************************/ -#define CHANNELEXTRACT_S16_21L(sd0, sd1, dd) \ - sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd1)); \ - sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd1)); \ - sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sdb)); \ - dd = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc)) - -/***************************************************************/ -#define CHANNELEXTRACT_S16_21R(sd0, sd1, dd) \ - sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd1)); \ - sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd1)); \ - sdc = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sdb)); \ - dd = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc)) - -/***************************************************************/ -/* extract one channel from a 2-channel image. - * both source and destination image data are 8-byte aligned. - * dsize is multiple of 4. - */ - -void mlib_v_ImageChannelExtract_S16_21_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 sd0, sd1; - mlib_d64 sda, sdb, sdc; - mlib_d64 dd; - mlib_s32 i; - - sp = (mlib_d64 *) src; - dp = (mlib_d64 *) dst; - - if (cmask == 2) { -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - CHANNELEXTRACT_S16_21L(sd0, sd1, dd); - *dp++ = dd; - } - } - else { -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - CHANNELEXTRACT_S16_21R(sd0, sd1, dd); - *dp++ = dd; - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_S16_21_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 *sl, *dl; - mlib_d64 sd0, sd1; - mlib_d64 sda, sdb, sdc; - mlib_d64 dd; - mlib_s32 i, j; - - sp = sl = (mlib_d64 *) src; - dp = dl = (mlib_d64 *) dst; - - if (cmask == 2) { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - CHANNELEXTRACT_S16_21L(sd0, sd1, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - CHANNELEXTRACT_S16_21R(sd0, sd1, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_S16_21_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_s16 *sa, *da; - mlib_s16 *dend, *dend2; /* end points in dst */ - mlib_d64 *dp; /* 8-byte aligned start points in dst */ - mlib_d64 *sp; /* 8-byte aligned start point in src */ - mlib_d64 sd0, sd1, sd2, sd3; /* 8-byte source data */ - mlib_d64 sda, sdb, sdc; - mlib_d64 dd0, dd1; - mlib_s32 soff; /* offset of address in src */ - mlib_s32 doff; /* offset of address in dst */ - mlib_s32 off; /* offset of dst over src */ - mlib_s32 emask; /* edge mask */ - mlib_s32 i, n; - - sa = (void *)src; - da = dst; - - /* prepare the source address */ - sp = (mlib_d64 *) ((mlib_addr) sa & (~7)); - soff = ((mlib_addr) sa & 7); - - /* prepare the destination addresses */ - dp = (mlib_d64 *) ((mlib_addr) da & (~7)); - doff = ((mlib_addr) da & 7); - dend = da + dsize - 1; - dend2 = dend - 3; - - /* calculate the src's offset over dst */ - if (cmask == 2) { - off = (soff / 4) * 2 - doff; - } - else { - off = ((soff + 3) / 4) * 2 - doff; - } - - if (((cmask == 2) && (soff % 4 == 0)) || ((cmask == 1) && (soff % 4 != 0))) { /* extract even words */ - - if (off == 0) { /* src and dst have same alignment */ - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - /* load 16 bytes */ - sd0 = *sp++; - sd1 = *sp++; - - /* extract, including some garbage at the start point */ - CHANNELEXTRACT_S16_21L(sd0, sd1, dd0); - - /* store 8 bytes result */ - vis_pst_16(dd0, dp++, emask); - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - sd0 = *sp++; - sd1 = *sp++; - CHANNELEXTRACT_S16_21L(sd0, sd1, dd0); - *dp++ = dd0; - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - sd0 = *sp++; - sd1 = *sp++; - CHANNELEXTRACT_S16_21L(sd0, sd1, dd0); - vis_pst_16(dd0, dp++, emask); - } - } - else { - vis_alignaddr((void *)0, off); - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - if (off < 0) { - /* load 16 bytes */ - sd2 = *sp++; - sd3 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_21L(sd2, sd3, dd1); - vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask); - } - else { - /* load 32 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_21L(sd0, sd1, dd0); - CHANNELEXTRACT_S16_21L(sd2, sd3, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - dd0 = dd1; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_21L(sd2, sd3, dd1); - *dp++ = vis_faligndata(dd0, dd1); - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - dd0 = dd1; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_21L(sd2, sd3, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - } - } - else { /* extract odd words */ - - if (off == 0) { /* src and dst have same alignment */ - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - /* load 16 bytes, don't care the garbage at the start point */ - sd0 = *sp++; - sd1 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_21R(sd0, sd1, dd0); - vis_pst_16(dd0, dp++, emask); - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - sd0 = *sp++; - sd1 = *sp++; - CHANNELEXTRACT_S16_21R(sd0, sd1, dd0); - *dp++ = dd0; - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - sd0 = *sp++; - sd1 = *sp++; - CHANNELEXTRACT_S16_21R(sd0, sd1, dd0); - vis_pst_16(dd0, dp++, emask); - } - } - else { - vis_alignaddr((void *)0, off); - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - if (off < 0) { - /* load 16 bytes */ - sd2 = *sp++; - sd3 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_21R(sd2, sd3, dd1); - vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask); - } - else { - /* load 32 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_21R(sd0, sd1, dd0); - CHANNELEXTRACT_S16_21R(sd2, sd3, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - dd0 = dd1; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_21R(sd2, sd3, dd1); - *dp++ = vis_faligndata(dd0, dd1); - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - dd0 = dd1; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_21R(sd2, sd3, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_S16_21(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_s16 *sa, *da; - mlib_s16 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelExtract_S16_21_D1(sa, da, xsize, cmask); - sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb); - da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } -} - -/***************************************************************/ -#define CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd) \ - /* extract the left channel */ \ - sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1)); \ - sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2)); \ - sdc = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb)); \ - dd = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc)) - -/***************************************************************/ -#define CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd) \ - /* extract the middle channel */ \ - sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1)); \ - sdb = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2)); \ - sdc = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdb)); \ - dd = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc)) - -/***************************************************************/ -#define CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd) \ - /* extract the right channel */ \ - sda = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2)); \ - sdb = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2)); \ - sdc = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb)); \ - dd = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc)) - -/***************************************************************/ -void mlib_v_ImageChannelExtract_S16_31_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 sd0, sd1, sd2; - mlib_d64 sda, sdb, sdc; - mlib_d64 dd; - mlib_s32 i; - - sp = (mlib_d64 *) src; - dp = (mlib_d64 *) dst; - - if (cmask == 4) { -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd); - *dp++ = dd; - } - } - else if (cmask == 2) { -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd); - *dp++ = dd; - } - } - else { -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd); - *dp++ = dd; - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_S16_31_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 *sl, *dl; - mlib_d64 sd0, sd1, sd2; - mlib_d64 sda, sdb, sdc; - mlib_d64 dd; - mlib_s32 i, j; - - sp = sl = (mlib_d64 *) src; - dp = dl = (mlib_d64 *) dst; - - if (cmask == 4) { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else if (cmask == 2) { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_S16_31_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_s16 *sa, *da; - mlib_s16 *dend, *dend2; /* end points in dst */ - mlib_d64 *dp; /* 8-byte aligned start points in dst */ - mlib_d64 *sp; /* 8-byte aligned start point in src */ - mlib_d64 sd0, sd1, sd2; /* 8-byte source data */ - mlib_d64 sd3, sd4, sd5; - mlib_d64 sda, sdb, sdc; - mlib_d64 dd0, dd1; - mlib_s32 soff; /* offset of address in src */ - mlib_s32 doff; /* offset of address in dst */ - mlib_s32 off; /* offset of src over dst */ - mlib_s32 emask; /* edge mask */ - mlib_s32 i, n; - - sa = (void *)src; - da = dst; - - /* prepare the source address */ - sp = (mlib_d64 *) ((mlib_addr) sa & (~7)); - soff = ((mlib_addr) sa & 7); - - /* prepare the destination addresses */ - dp = (mlib_d64 *) ((mlib_addr) da & (~7)); - doff = ((mlib_addr) da & 7); - dend = da + dsize - 1; - dend2 = dend - 3; - - /* calculate the src's offset over dst */ - if (cmask == 4) { - off = (soff / 6) * 2 - doff; - } - else if (cmask == 2) { - off = ((soff + 2) / 6) * 2 - doff; - } - else { - off = ((soff + 4) / 6) * 2 - doff; - } - - if (((cmask == 4) && (soff % 6 == 0)) || - ((cmask == 2) && (soff % 6 == 4)) || - ((cmask == 1) && (soff % 6 == 2))) { /* extract left channel */ - - if (off == 0) { /* src and dst have same alignment */ - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - /* load 16 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - - /* extract, including some garbage at the start point */ - CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd0); - - /* store 8 bytes result */ - vis_pst_16(dd0, dp++, emask); - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd0); - *dp++ = dd0; - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd0); - vis_pst_16(dd0, dp++, emask); - } - } - else { - vis_alignaddr((void *)0, off); - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - if (off < 0) { - /* load 24 bytes */ - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_31L(sd3, sd4, sd5, dd1); - vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask); - } - else { - /* load 48 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_31L(sd0, sd1, sd2, dd0); - CHANNELEXTRACT_S16_31L(sd3, sd4, sd5, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - dd0 = dd1; - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - CHANNELEXTRACT_S16_31L(sd3, sd4, sd5, dd1); - *dp++ = vis_faligndata(dd0, dd1); - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - dd0 = dd1; - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - CHANNELEXTRACT_S16_31L(sd3, sd4, sd5, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - } - } - else if (((cmask == 4) && (soff % 6 == 2)) || - ((cmask == 2) && (soff % 6 == 0)) || - ((cmask == 1) && (soff % 6 == 4))) { - /* extract middle channel */ - - if (off == 0) { /* src and dst have same alignment */ - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - /* load 16 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - - /* extract, including some garbage at the start point */ - CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd0); - - /* store 8 bytes result */ - vis_pst_16(dd0, dp++, emask); - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd0); - *dp++ = dd0; - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd0); - vis_pst_16(dd0, dp++, emask); - } - } - else { - vis_alignaddr((void *)0, off); - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - if (off < 0) { - /* load 24 bytes */ - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_31M(sd3, sd4, sd5, dd1); - vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask); - } - else { - /* load 48 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_31M(sd0, sd1, sd2, dd0); - CHANNELEXTRACT_S16_31M(sd3, sd4, sd5, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - dd0 = dd1; - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - CHANNELEXTRACT_S16_31M(sd3, sd4, sd5, dd1); - *dp++ = vis_faligndata(dd0, dd1); - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - dd0 = dd1; - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - CHANNELEXTRACT_S16_31M(sd3, sd4, sd5, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - } - } - else { /* extract right channel */ - - if (off == 0) { /* src and dst have same alignment */ - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - /* load 16 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - - /* extract, including some garbage at the start point */ - CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd0); - - /* store 8 bytes result */ - vis_pst_16(dd0, dp++, emask); - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd0); - *dp++ = dd0; - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd0); - vis_pst_16(dd0, dp++, emask); - } - } - else { - vis_alignaddr((void *)0, off); - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - if (off < 0) { - /* load 24 bytes */ - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_31R(sd3, sd4, sd5, dd1); - vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask); - } - else { - /* load 48 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_31R(sd0, sd1, sd2, dd0); - CHANNELEXTRACT_S16_31R(sd3, sd4, sd5, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - dd0 = dd1; - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - CHANNELEXTRACT_S16_31R(sd3, sd4, sd5, dd1); - *dp++ = vis_faligndata(dd0, dd1); - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - dd0 = dd1; - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - CHANNELEXTRACT_S16_31R(sd3, sd4, sd5, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_S16_31(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_s16 *sa, *da; - mlib_s16 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelExtract_S16_31_D1(sa, da, xsize, cmask); - sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb); - da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } -} - -/***************************************************************/ -#define CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd) \ - /* extract the left channel */ \ - sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd2)); \ - sdb = vis_fpmerge(vis_read_hi(sd1), vis_read_hi(sd3)); \ - sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sdb)); \ - dd = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc)) - -/***************************************************************/ -#define CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd) \ - /* extract the middle left channel */ \ - sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd2)); \ - sdb = vis_fpmerge(vis_read_hi(sd1), vis_read_hi(sd3)); \ - sdc = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sdb)); \ - dd = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc)) - -/***************************************************************/ -#define CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd) \ - /* extract the middle right channel */ \ - sda = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd2)); \ - sdb = vis_fpmerge(vis_read_lo(sd1), vis_read_lo(sd3)); \ - sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sdb)); \ - dd = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc)) - -/***************************************************************/ -#define CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd) \ - /* extract the right channel */ \ - sda = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd2)); \ - sdb = vis_fpmerge(vis_read_lo(sd1), vis_read_lo(sd3)); \ - sdc = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sdb)); \ - dd = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc)) - -/***************************************************************/ -void mlib_v_ImageChannelExtract_S16_41_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 sd0, sd1, sd2, sd3; - mlib_d64 sda, sdb, sdc; - mlib_d64 dd; - mlib_s32 i; - - sp = (mlib_d64 *) src; - dp = (mlib_d64 *) dst; - - if (cmask == 8) { -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - } - else if (cmask == 4) { -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - } - else if (cmask == 2) { -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - } - else { -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_S16_41_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 *sl, *dl; - mlib_d64 sd0, sd1, sd2, sd3; - mlib_d64 sda, sdb, sdc; - mlib_d64 dd; - mlib_s32 i, j; - - sp = sl = (mlib_d64 *) src; - dp = dl = (mlib_d64 *) dst; - - if (cmask == 8) { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else if (cmask == 4) { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else if (cmask == 2) { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else { - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd); - *dp++ = dd; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_S16_41_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_s16 *sa, *da; - mlib_s16 *dend, *dend2; /* end points in dst */ - mlib_d64 *dp; /* 8-byte aligned start points in dst */ - mlib_d64 *sp; /* 8-byte aligned start point in src */ - mlib_d64 sd0, sd1, sd2, sd3; /* 8-byte source data */ - mlib_d64 sd4, sd5, sd6, sd7; - mlib_d64 sda, sdb, sdc; - mlib_d64 dd0, dd1; - mlib_s32 soff; /* offset of address in src */ - mlib_s32 doff; /* offset of address in dst */ - mlib_s32 off; /* offset of src over dst */ - mlib_s32 emask; /* edge mask */ - mlib_s32 i, n; - - sa = (void *)src; - da = dst; - - /* prepare the source address */ - sp = (mlib_d64 *) ((mlib_addr) sa & (~7)); - soff = ((mlib_addr) sa & 7); - - /* prepare the destination addresses */ - dp = (mlib_d64 *) ((mlib_addr) da & (~7)); - doff = ((mlib_addr) da & 7); - dend = da + dsize - 1; - dend2 = dend - 3; - - /* calculate the src's offset over dst */ - if (cmask == 8) { - off = (soff / 8) * 2 - doff; - } - else if (cmask == 4) { - off = ((soff + 2) / 8) * 2 - doff; - } - else if (cmask == 2) { - off = ((soff + 4) / 8) * 2 - doff; - } - else { - off = ((soff + 6) / 8) * 2 - doff; - } - - if (((cmask == 8) && (soff == 0)) || - ((cmask == 4) && (soff == 6)) || - ((cmask == 2) && (soff == 4)) || - ((cmask == 1) && (soff == 2))) { /* extract left channel */ - - if (off == 0) { /* src and dst have same alignment */ - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - /* load 16 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - - /* extract, including some garbage at the start point */ - CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd0); - - /* store 8 bytes result */ - vis_pst_16(dd0, dp++, emask); - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd0); - *dp++ = dd0; - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd0); - vis_pst_16(dd0, dp++, emask); - } - } - else { - vis_alignaddr((void *)0, off); - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - if (off < 0) { - /* load 24 bytes */ - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_41L(sd4, sd5, sd6, sd7, dd1); - vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask); - } - else { - /* load 48 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_41L(sd0, sd1, sd2, sd3, dd0); - CHANNELEXTRACT_S16_41L(sd4, sd5, sd6, sd7, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - dd0 = dd1; - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - CHANNELEXTRACT_S16_41L(sd4, sd5, sd6, sd7, dd1); - *dp++ = vis_faligndata(dd0, dd1); - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - dd0 = dd1; - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - CHANNELEXTRACT_S16_41L(sd4, sd5, sd6, sd7, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - } - } - else if (((cmask == 8) && (soff == 2)) || - ((cmask == 4) && (soff == 0)) || - ((cmask == 2) && (soff == 6)) || - ((cmask == 1) && (soff == 4))) { /* extract middle left channel */ - - if (off == 0) { /* src and dst have same alignment */ - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - /* load 16 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - - /* extract, including some garbage at the start point */ - CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd0); - - /* store 8 bytes result */ - vis_pst_16(dd0, dp++, emask); - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd0); - *dp++ = dd0; - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd0); - vis_pst_16(dd0, dp++, emask); - } - } - else { - vis_alignaddr((void *)0, off); - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - if (off < 0) { - /* load 24 bytes */ - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_41ML(sd4, sd5, sd6, sd7, dd1); - vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask); - } - else { - /* load 48 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_41ML(sd0, sd1, sd2, sd3, dd0); - CHANNELEXTRACT_S16_41ML(sd4, sd5, sd6, sd7, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - dd0 = dd1; - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - CHANNELEXTRACT_S16_41ML(sd4, sd5, sd6, sd7, dd1); - *dp++ = vis_faligndata(dd0, dd1); - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - dd0 = dd1; - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - CHANNELEXTRACT_S16_41ML(sd4, sd5, sd6, sd7, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - } - } - else if (((cmask == 8) && (soff == 4)) || - ((cmask == 4) && (soff == 2)) || - ((cmask == 2) && (soff == 0)) || - ((cmask == 1) && (soff == 6))) { /* extract middle right channel */ - - if (off == 0) { /* src and dst have same alignment */ - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - /* load 16 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - - /* extract, including some garbage at the start point */ - CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd0); - - /* store 8 bytes result */ - vis_pst_16(dd0, dp++, emask); - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd0); - *dp++ = dd0; - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd0); - vis_pst_16(dd0, dp++, emask); - } - } - else { - vis_alignaddr((void *)0, off); - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - if (off < 0) { - /* load 24 bytes */ - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_41MR(sd4, sd5, sd6, sd7, dd1); - vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask); - } - else { - /* load 48 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_41MR(sd0, sd1, sd2, sd3, dd0); - CHANNELEXTRACT_S16_41MR(sd4, sd5, sd6, sd7, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - dd0 = dd1; - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - CHANNELEXTRACT_S16_41MR(sd4, sd5, sd6, sd7, dd1); - *dp++ = vis_faligndata(dd0, dd1); - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - dd0 = dd1; - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - CHANNELEXTRACT_S16_41MR(sd4, sd5, sd6, sd7, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - } - } - else { /* extract right channel */ - if (off == 0) { /* src and dst have same alignment */ - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - /* load 16 bytes */ - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - - /* extract, including some garbage at the start point */ - CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd0); - - /* store 8 bytes result */ - vis_pst_16(dd0, dp++, emask); - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd0); - *dp++ = dd0; - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - sd0 = *sp++; - sd1 = *sp++; - sd2 = *sp++; - sd3 = *sp++; - CHANNELEXTRACT_S16_41R(sd0, sd1, sd2, sd3, dd0); - vis_pst_16(dd0, dp++, emask); - } - } - else { - vis_alignaddr((void *)0, off); - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - if (off < 0) { - /* load 24 bytes */ - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - - /* extract and store 8 bytes */ - CHANNELEXTRACT_S16_41R(sd4, sd5, sd6, sd7, dd1); - vis_pst_16(vis_faligndata(dd1, dd1), dp++, emask); - } - - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 8 + 1; - - /* 8-pixel column loop, emask not needed */ -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - dd0 = dd1; - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - CHANNELEXTRACT_S16_41R(sd4, sd5, sd6, sd7, dd1); - *dp++ = vis_faligndata(dd0, dd1); - } - } - - /* end point handling */ - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - dd0 = dd1; - sd4 = *sp++; - sd5 = *sp++; - sd6 = *sp++; - sd7 = *sp++; - CHANNELEXTRACT_S16_41R(sd4, sd5, sd6, sd7, dd1); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - } - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_S16_41(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_s16 *sa, *da; - mlib_s16 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelExtract_S16_41_D1(sa, da, xsize, cmask); - sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb); - da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } -} - -/***************************************************************/ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_43.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_43.c index cf6ec42372e..9924a29c73c 100644 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_43.c +++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_43.c @@ -29,22 +29,8 @@ * FILENAME: mlib_v_ImageChannelExtract_43.c * * FUNCTIONS - * mlib_v_ImageChannelExtract_U8_43R_A8D1X8 - * mlib_v_ImageChannelExtract_U8_43R_A8D2X8 - * mlib_v_ImageChannelExtract_U8_43R_D1 - * mlib_v_ImageChannelExtract_U8_43R - * mlib_v_ImageChannelExtract_S16_43R_A8D1X4 - * mlib_v_ImageChannelExtract_S16_43R_A8D2X4 - * mlib_v_ImageChannelExtract_S16_43R_D1 - * mlib_v_ImageChannelExtract_S16_43R - * mlib_v_ImageChannelExtract_U8_43L_A8D1X8 - * mlib_v_ImageChannelExtract_U8_43L_A8D2X8 * mlib_v_ImageChannelExtract_U8_43L_D1 - * mlib_v_ImageChannelExtract_U8_43L - * mlib_v_ImageChannelExtract_S16_43L_A8D1X4 - * mlib_v_ImageChannelExtract_S16_43L_A8D2X4 * mlib_v_ImageChannelExtract_S16_43L_D1 - * mlib_v_ImageChannelExtract_S16_43L * * SYNOPSIS * @@ -73,705 +59,6 @@ #include "mlib_image.h" #include "mlib_v_ImageChannelExtract.h" -/***************************************************************/ -#define EXTRACT_U8_43R_old /* shift right */ \ - dd2 = vis_faligndata(sd3, dd2); /* r7-------------- */ \ - sd3 = vis_faligndata(sd3, sd3); \ - dd2 = vis_faligndata(sd3, dd2); /* g7r7------------ */ \ - sd3 = vis_faligndata(sd3, sd3); \ - dd2 = vis_faligndata(sd3, dd2); /* b7g7r7---------- */ \ - sd3 = vis_faligndata(sd3, sd3); \ - sd3 = vis_faligndata(sd3, sd3); \ - dd2 = vis_faligndata(sd3, dd2); /* r6b7g7r7-------- */ \ - sd3 = vis_faligndata(sd3, sd3); \ - dd2 = vis_faligndata(sd3, dd2); /* g6r6b7g7r7------ */ \ - sd3 = vis_faligndata(sd3, sd3); \ - dd2 = vis_faligndata(sd3, dd2); /* b6g6r6b7g7r7---- */ \ - \ - dd2 = vis_faligndata(sd2, dd2); /* r5b6g6r6b7g7r7-- */ \ - sd2 = vis_faligndata(sd2, sd2); \ - dd2 = vis_faligndata(sd2, dd2); /* g5r5b6g6r6b7g7r7 */ \ - \ - sd2 = vis_faligndata(sd2, sd2); \ - dd1 = vis_faligndata(sd2, dd1); /* b5-------------- */ \ - sd2 = vis_faligndata(sd2, sd2); \ - sd2 = vis_faligndata(sd2, sd2); \ - dd1 = vis_faligndata(sd2, dd1); /* r4b5------------ */ \ - sd2 = vis_faligndata(sd2, sd2); \ - dd1 = vis_faligndata(sd2, dd1); /* g4r4b5---------- */ \ - sd2 = vis_faligndata(sd2, sd2); \ - dd1 = vis_faligndata(sd2, dd1); /* b4g4r4b5-------- */ \ - \ - dd1 = vis_faligndata(sd1, dd1); /* r3b4g4r4b5------ */ \ - sd1 = vis_faligndata(sd1, sd1); \ - dd1 = vis_faligndata(sd1, dd1); /* g3r3b4g4r4b5---- */ \ - sd1 = vis_faligndata(sd1, sd1); \ - dd1 = vis_faligndata(sd1, dd1); /* b3g3r3b4g4r4b5-- */ \ - sd1 = vis_faligndata(sd1, sd1); \ - sd1 = vis_faligndata(sd1, sd1); \ - dd1 = vis_faligndata(sd1, dd1); /* r2b3g3r3b4g4r4b5 */ \ - \ - sd1 = vis_faligndata(sd1, sd1); \ - dd0 = vis_faligndata(sd1, dd0); /* g2-------------- */ \ - sd1 = vis_faligndata(sd1, sd1); \ - dd0 = vis_faligndata(sd1, dd0); /* b2g2------------ */ \ - \ - dd0 = vis_faligndata(sd0, dd0); /* r1b2g2---------- */ \ - sd0 = vis_faligndata(sd0, sd0); \ - dd0 = vis_faligndata(sd0, dd0); /* g1r1b2g2-------- */ \ - sd0 = vis_faligndata(sd0, sd0); \ - dd0 = vis_faligndata(sd0, dd0); /* b1g1r1b2g2------ */ \ - sd0 = vis_faligndata(sd0, sd0); \ - sd0 = vis_faligndata(sd0, sd0); \ - dd0 = vis_faligndata(sd0, dd0); /* r0b1g1r1b2g2---- */ \ - sd0 = vis_faligndata(sd0, sd0); \ - dd0 = vis_faligndata(sd0, dd0); /* g0r0b1g1r1b2g2-- */ \ - sd0 = vis_faligndata(sd0, sd0); \ - dd0 = vis_faligndata(sd0, dd0); /* b0g0r0b1g1r1b2g2 */ - -/***************************************************************/ -#define EXTRACT_U8_43R /* shift right */ \ - vis_alignaddr((void *)0, 5); \ - dd2 = vis_faligndata(sd3, dd2); /* b7g7r7---------- */ \ - sda = vis_freg_pair(vis_read_hi(sd3), vis_read_hi(sd3)); \ - dd2 = vis_faligndata(sda, dd2); /* b6g6r6b7g7r7---- */ \ - \ - vis_alignaddr((void *)0, 6); \ - dd2 = vis_faligndata(sd2, dd2); /* g5r5b6g6r6b7g7r7 */ \ - \ - vis_alignaddr((void *)0, 5); \ - dd1 = vis_faligndata(sd2, dd1); /* b5g5r5---------- */ \ - sda = vis_freg_pair(vis_read_hi(sd2), vis_read_hi(sd2)); \ - dd1 = vis_faligndata(sda, dd1); /* b4g4r4b5g5r5---- */ \ - dd1 = vis_faligndata(sd1, dd1); /* b3g3r3b4g4r4b5g5 */ \ - sda = vis_freg_pair(vis_read_hi(sd1), vis_read_hi(sd1)); \ - vis_alignaddr((void *)0, 7); \ - dd1 = vis_faligndata(sda, dd1); /* r2b3g3r3b4g4r4b5 */ \ - \ - vis_alignaddr((void *)0, 5); \ - dd0 = vis_faligndata(sda, dd0); /* b2g2r2---------- */ \ - dd0 = vis_faligndata(sd0, dd0); /* b1g1r1b2g2r2---- */ \ - sda = vis_freg_pair(vis_read_hi(sd0), vis_read_hi(sd0)); \ - dd0 = vis_faligndata(sda, dd0); /* b0g0r0b1g1r1b2g2 */ - -/***************************************************************/ -#define LOAD_EXTRACT_U8_43R_STORE \ - sd0 = *sp++; /* --b0g0r0--b1g1r1 */ \ - sd1 = *sp++; /* --b2g2r2--b3g3r3 */ \ - sd2 = *sp++; /* --b4g4r4--b5g5r5 */ \ - sd3 = *sp++; /* --b6g6r6--b7g7r7 */ \ - EXTRACT_U8_43R; \ - *dp++ = dd0; /* b0g0r0b1g1r1b2g2 */ \ - *dp++ = dd1; /* r2b3g3r3b4g4r4b5 */ \ - *dp++ = dd2; /* g5r5b6g6r6b7g7r7 */ - -/***************************************************************/ -#define LOAD_EXTRACT_U8_43R \ - vis_alignaddr((void *)soff, 0); \ - s0 = s4; \ - s1 = sp[1]; \ - s2 = sp[2]; \ - s3 = sp[3]; \ - s4 = sp[4]; \ - sd0 = vis_faligndata(s0, s1); \ - sd1 = vis_faligndata(s1, s2); \ - sd2 = vis_faligndata(s2, s3); \ - sd3 = vis_faligndata(s3, s4); \ - sp += 4; \ - dd2old = dd2; \ - EXTRACT_U8_43R - -/***************************************************************/ -/* - * Both source and destination image data are 1-d vectors and - * 8-byte aligned. And dsize is multiple of 8. - */ - -void mlib_v_ImageChannelExtract_U8_43R_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize) -{ - mlib_d64 *sp, *dp; - mlib_d64 sd0, sd1, sd2, sd3; /* source data */ - mlib_d64 dd0, dd1, dd2; /* dst data */ - mlib_d64 sda; - mlib_s32 i; - - sp = (mlib_d64 *) src; - dp = (mlib_d64 *) dst; - - /* set GSR.offset for vis_faligndata() */ -/* vis_alignaddr((void *)0, 7); *//* only for _old */ - -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - LOAD_EXTRACT_U8_43R_STORE; - } -} - -/***************************************************************/ -/* - * Either source or destination image data are not 1-d vectors, but - * they are 8-byte aligned. And slb and dlb are multiple of 8. - * The xsize is multiple of 8. - */ - -void mlib_v_ImageChannelExtract_U8_43R_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize) -{ - mlib_d64 *sp, *dp; /* 8-byte aligned pointer for pixel */ - mlib_d64 *sl, *dl; /* 8-byte aligned pointer for line */ - mlib_d64 sd0, sd1, sd2, sd3; /* source data */ - mlib_d64 dd0, dd1, dd2; /* dst data */ - mlib_d64 sda; - mlib_s32 i, j; /* indices for x, y */ - - /* set GSR.offset for vis_faligndata() */ -/* vis_alignaddr((void *)0, 7); *//* only for _old */ - - sp = sl = (mlib_d64 *) src; - dp = dl = (mlib_d64 *) dst; - - /* row loop */ - for (j = 0; j < ysize; j++) { - /* 8-byte column loop */ -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - LOAD_EXTRACT_U8_43R_STORE; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } -} - -/***************************************************************/ -/* - * Either source or destination data are not 8-byte aligned. - * And dsize is in pixels. - */ - -void mlib_v_ImageChannelExtract_U8_43R_D1(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize) -{ - mlib_u8 *sa, *da; - mlib_u8 *dend, *dend2; /* end points in dst */ - mlib_d64 *dp; /* 8-byte aligned start points in dst */ - mlib_d64 *sp; /* 8-byte aligned start point in src */ - mlib_d64 s0, s1, s2, s3, s4; /* 8-byte source row data */ - mlib_d64 sd0, sd1, sd2, sd3; /* 8-byte source data */ - mlib_d64 dd0, dd1, dd2; /* dst data */ - mlib_d64 dd2old; /* the last datum of the last step */ - mlib_d64 sda; - mlib_s32 soff; /* offset of address in src */ - mlib_s32 doff; /* offset of address in dst */ - mlib_s32 emask; /* edge mask */ - mlib_s32 i, n; - - sa = (void *)src; - da = dst; - - /* prepare the source address */ - sp = (mlib_d64 *) ((mlib_addr) sa & (~7)); - soff = ((mlib_addr) sa & 7); - - /* prepare the destination addresses */ - dp = (mlib_d64 *) ((mlib_addr) da & (~7)); - dend = da + dsize * 3 - 1; - dend2 = dend - 23; - doff = 8 - ((mlib_addr) da & 7); - - /* generate edge mask for the start point */ - emask = vis_edge8(da, dend); - - /* load 32 byte, convert, store 24 bytes */ - s4 = sp[0]; /* initial value */ - LOAD_EXTRACT_U8_43R; - - if (dsize >= 8) { - if (doff == 8) { - vis_pst_8(dd0, dp++, emask); - *dp++ = dd1; - *dp++ = dd2; - } - else { - vis_alignaddr((void *)doff, 0); - vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask); - *dp++ = vis_faligndata(dd0, dd1); - *dp++ = vis_faligndata(dd1, dd2); - } - } - else { /* for very small size */ - if (doff == 8) { - vis_pst_8(dd0, dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd1, dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd2, dp++, emask); - } - } - } - else { - vis_alignaddr((void *)doff, 0); - vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd2, dd2), dp++, emask); - } - } - } - } - } - - /* no edge handling is needed in the loop */ - if (doff == 8) { - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 24 + 1; -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - LOAD_EXTRACT_U8_43R; - *dp++ = dd0; - *dp++ = dd1; - *dp++ = dd2; - } - } - } - else { - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 24 + 1; -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - LOAD_EXTRACT_U8_43R; - vis_alignaddr((void *)doff, 0); - *dp++ = vis_faligndata(dd2old, dd0); - *dp++ = vis_faligndata(dd0, dd1); - *dp++ = vis_faligndata(dd1, dd2); - } - } - } - - if ((mlib_addr) dp <= (mlib_addr) dend) { - LOAD_EXTRACT_U8_43R; - emask = vis_edge8(dp, dend); - if (doff == 8) { - vis_pst_8(dd0, dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd1, dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd2, dp++, emask); - } - } - } - else { - vis_alignaddr((void *)doff, 0); - vis_pst_8(vis_faligndata(dd2old, dd0), dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask); - } - } - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_U8_43R(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize) -{ - mlib_u8 *sa, *da; - mlib_u8 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelExtract_U8_43R_D1(sa, da, xsize); - sa = sl += slb; - da = dl += dlb; - } -} - -/***************************************************************/ -#define EXTRACT_S16_43R_old /* shift right */ \ - \ - dd2 = vis_faligndata(sd3, dd2); /* r3------ */ \ - sd3 = vis_faligndata(sd3, sd3); \ - dd2 = vis_faligndata(sd3, dd2); /* g3r3---- */ \ - sd3 = vis_faligndata(sd3, sd3); \ - dd2 = vis_faligndata(sd3, dd2); /* b3g3r3-- */ \ - \ - dd2 = vis_faligndata(sd2, dd2); /* r2b3g3r3 */ \ - sd2 = vis_faligndata(sd2, sd2); \ - dd1 = vis_faligndata(sd2, dd1); /* g2------ */ \ - sd2 = vis_faligndata(sd2, sd2); \ - dd1 = vis_faligndata(sd2, dd1); /* b2g2---- */ \ - \ - dd1 = vis_faligndata(sd1, dd1); /* r1b2g2-- */ \ - sd1 = vis_faligndata(sd1, sd1); \ - dd1 = vis_faligndata(sd1, dd1); /* g1r1b2g2 */ \ - sd1 = vis_faligndata(sd1, sd1); \ - dd0 = vis_faligndata(sd1, dd0); /* b1------ */ \ - \ - dd0 = vis_faligndata(sd0, dd0); /* r0b1---- */ \ - sd0 = vis_faligndata(sd0, sd0); \ - dd0 = vis_faligndata(sd0, dd0); /* g0r0b1-- */ \ - sd0 = vis_faligndata(sd0, sd0); \ - dd0 = vis_faligndata(sd0, dd0); /* b0g0r0b1 */ - -/***************************************************************/ -#define EXTRACT_S16_43R /* shift right */ \ - \ - vis_alignaddr((void *)0, 2); \ - dd2 = vis_faligndata(sd3, dd2); /* b3g3r3-- */ \ - \ - vis_alignaddr((void *)0, 6); \ - dd2 = vis_faligndata(sd2, dd2); /* r2b3g3r3 */ \ - vis_alignaddr((void *)0, 2); \ - dd1 = vis_faligndata(sd2, dd1); /* b2g2r2-- */ \ - \ - vis_alignaddr((void *)0, 4); \ - dd1 = vis_faligndata(sd1, dd1); /* g1r1b2g2 */ \ - vis_alignaddr((void *)0, 2); \ - dd0 = vis_faligndata(sd1, dd0); /* b1g1r1-- */ \ - dd0 = vis_faligndata(sd0, dd0); /* b0g0r0b1 */ - -/***************************************************************/ -#define LOAD_EXTRACT_S16_43R_STORE \ - \ - sd0 = *sp++; /* --b0g0r0 */ \ - sd1 = *sp++; /* --b1g1r1 */ \ - sd2 = *sp++; /* --b2g2r2 */ \ - sd3 = *sp++; /* --b3g3r3 */ \ - \ - EXTRACT_S16_43R; \ - \ - *dp++ = dd0; /* b0g0r0b1 */ \ - *dp++ = dd1; /* g1r1b2g2 */ \ - *dp++ = dd2; /* r2b3g3r3 */ - -/***************************************************************/ -#define LOAD_EXTRACT_S16_43R \ - \ - vis_alignaddr((void *)soff, 0); \ - s0 = s4; \ - s1 = sp[1]; \ - s2 = sp[2]; \ - s3 = sp[3]; \ - s4 = sp[4]; \ - sd0 = vis_faligndata(s0, s1); \ - sd1 = vis_faligndata(s1, s2); \ - sd2 = vis_faligndata(s2, s3); \ - sd3 = vis_faligndata(s3, s4); \ - sp += 4; \ - dd2old = dd2; \ - EXTRACT_S16_43R - -/***************************************************************/ -/* - * Both source and destination image data are 1-d vectors and - * 8-byte aligned. And size is in 4-pixels. - */ - -void mlib_v_ImageChannelExtract_S16_43R_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize) -{ - mlib_d64 *sp, *dp; /* 8-byte aligned pointer for pixel */ - mlib_d64 sd0, sd1, sd2, sd3; /* source data */ - mlib_d64 dd0, dd1, dd2; /* dst data */ - mlib_s32 i; - - sp = (mlib_d64 *) src; - dp = (mlib_d64 *) dst; - - /* set GSR.offset for vis_faligndata() */ -/* vis_alignaddr((void *)0, 6); *//* only for _old */ - -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - LOAD_EXTRACT_S16_43R_STORE; - } -} - -/***************************************************************/ -/* - * Either source or destination image data are not 1-d vectors, but - * they are 8-byte aligned. The xsize is multiple of 8. - * slb and dlb are multiple of 8. - */ - -void mlib_v_ImageChannelExtract_S16_43R_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize) -{ - mlib_d64 *sp, *dp; /* 8-byte aligned pointer for pixel */ - mlib_d64 *sl, *dl; /* 8-byte aligned pointer for line */ - mlib_d64 sd0, sd1, sd2, sd3; /* source data */ - mlib_d64 dd0, dd1, dd2; /* dst data */ - mlib_s32 i, j; /* indices for x, y */ - - /* set GSR.offset for vis_faligndata() */ -/* vis_alignaddr((void *)0, 6); *//* only for _old */ - - sp = sl = (mlib_d64 *) src; - dp = dl = (mlib_d64 *) dst; - - /* row loop */ - for (j = 0; j < ysize; j++) { - /* 4-pixel column loop */ -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - LOAD_EXTRACT_S16_43R_STORE; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } -} - -/***************************************************************/ -/* - * Either source or destination data are not 8-byte aligned. - * And dsize is multiple of 8. - */ - -void mlib_v_ImageChannelExtract_S16_43R_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize) -{ - mlib_s16 *sa, *da; /* pointer for pixel */ - mlib_s16 *dend, *dend2; /* end points in dst */ - mlib_d64 *dp; /* 8-byte aligned start points in dst */ - mlib_d64 *sp; /* 8-byte aligned start point in src */ - mlib_d64 s0, s1, s2, s3, s4; /* 8-byte source row data */ - mlib_d64 sd0, sd1, sd2, sd3; /* 8-byte source data */ - mlib_d64 dd0, dd1, dd2; /* dst data */ - mlib_d64 dd2old; /* the last datum of the last step */ - mlib_s32 soff; /* offset of address in src */ - mlib_s32 doff; /* offset of address in dst */ - mlib_s32 emask; /* edge mask */ - mlib_s32 i, n; - - sa = (void *)src; - da = dst; - - /* prepare the source address */ - sp = (mlib_d64 *) ((mlib_addr) sa & (~7)); - soff = ((mlib_addr) sa & 7); - - /* prepare the destination addresses */ - dp = (mlib_d64 *) ((mlib_addr) da & (~7)); - dend = da + dsize * 3 - 1; - dend2 = dend - 11; - doff = 8 - ((mlib_addr) da & 7); - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - /* load 32 byte, convert, store 24 bytes */ - s4 = sp[0]; /* initial value */ - LOAD_EXTRACT_S16_43R; - - if (dsize >= 4) { - if (doff == 8) { - vis_pst_16(dd0, dp++, emask); - *dp++ = dd1; - *dp++ = dd2; - } - else { - vis_alignaddr((void *)doff, 0); - vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask); - *dp++ = vis_faligndata(dd0, dd1); - *dp++ = vis_faligndata(dd1, dd2); - } - } - else { /* for very small size */ - if (doff == 8) { - vis_pst_16(dd0, dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(dd1, dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(dd2, dp++, emask); - } - } - } - else { - vis_alignaddr((void *)doff, 0); - vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask); - } - } - } - } - - /* no edge handling is needed in the loop */ - if (doff == 8) { - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 24 + 1; -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - LOAD_EXTRACT_S16_43R; - *dp++ = dd0; - *dp++ = dd1; - *dp++ = dd2; - } - } - } - else { - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *) dend2 - (mlib_u8 *) dp) / 24 + 1; -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - LOAD_EXTRACT_S16_43R; - vis_alignaddr((void *)doff, 0); - *dp++ = vis_faligndata(dd2old, dd0); - *dp++ = vis_faligndata(dd0, dd1); - *dp++ = vis_faligndata(dd1, dd2); - } - } - } - - if ((mlib_addr) dp <= (mlib_addr) dend) { - LOAD_EXTRACT_S16_43R; - emask = vis_edge16(dp, dend); - if (doff == 8) { - vis_pst_16(dd0, dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(dd1, dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(dd2, dp++, emask); - } - } - } - else { - vis_alignaddr((void *)doff, 0); - vis_pst_16(vis_faligndata(dd2old, dd0), dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask); - } - } - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelExtract_S16_43R(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize) -{ - mlib_s16 *sa, *da; - mlib_s16 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelExtract_S16_43R_D1(sa, da, xsize); - sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb); - da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } -} - -/***************************************************************/ -#define EXTRACT_U8_43L_old /* shift left */ \ - \ - dd0 = vis_faligndata(dd0, sd0); /* --------------r0 */ \ - sd0 = vis_faligndata(sd0, sd0); \ - dd0 = vis_faligndata(dd0, sd0); /* ------------r0g0 */ \ - sd0 = vis_faligndata(sd0, sd0); \ - dd0 = vis_faligndata(dd0, sd0); /* ----------r0g0b0 */ \ - sd0 = vis_faligndata(sd0, sd0); \ - sd0 = vis_faligndata(sd0, sd0); \ - dd0 = vis_faligndata(dd0, sd0); /* --------r0g0b0r1 */ \ - sd0 = vis_faligndata(sd0, sd0); \ - dd0 = vis_faligndata(dd0, sd0); /* ------r0g0b0r1g1 */ \ - sd0 = vis_faligndata(sd0, sd0); \ - dd0 = vis_faligndata(dd0, sd0); /* ----r0g0b0r1g1b1 */ \ - \ - dd0 = vis_faligndata(dd0, sd1); /* --r0g0b0r1g1b1r2 */ \ - sd1 = vis_faligndata(sd1, sd1); \ - dd0 = vis_faligndata(dd0, sd1); /* r0g0b0r1g1b1r2g2 */ \ - \ - sd1 = vis_faligndata(sd1, sd1); \ - dd1 = vis_faligndata(dd1, sd1); /* --------------b2 */ \ - sd1 = vis_faligndata(sd1, sd1); \ - sd1 = vis_faligndata(sd1, sd1); \ - dd1 = vis_faligndata(dd1, sd1); /* ------------b2r3 */ \ - sd1 = vis_faligndata(sd1, sd1); \ - dd1 = vis_faligndata(dd1, sd1); /* ----------b2r3g3 */ \ - sd1 = vis_faligndata(sd1, sd1); \ - dd1 = vis_faligndata(dd1, sd1); /* --------b2r3g3b3 */ \ - \ - dd1 = vis_faligndata(dd1, sd2); /* ------b2r3g3b3r4 */ \ - sd2 = vis_faligndata(sd2, sd2); \ - dd1 = vis_faligndata(dd1, sd2); /* ----b2r3g3b3r4g4 */ \ - sd2 = vis_faligndata(sd2, sd2); \ - dd1 = vis_faligndata(dd1, sd2); /* --b2r3g3b3r4g4b4 */ \ - sd2 = vis_faligndata(sd2, sd2); \ - sd2 = vis_faligndata(sd2, sd2); \ - dd1 = vis_faligndata(dd1, sd2); /* b2r3g3b3r4g4b4r5 */ \ - \ - sd2 = vis_faligndata(sd2, sd2); \ - dd2 = vis_faligndata(dd2, sd2); /* --------------g5 */ \ - sd2 = vis_faligndata(sd2, sd2); \ - dd2 = vis_faligndata(dd2, sd2); /* ------------g5b5 */ \ - \ - dd2 = vis_faligndata(dd2, sd3); /* ----------g5b5r6 */ \ - sd3 = vis_faligndata(sd3, sd3); \ - dd2 = vis_faligndata(dd2, sd3); /* --------g5b5r6g6 */ \ - sd3 = vis_faligndata(sd3, sd3); \ - dd2 = vis_faligndata(dd2, sd3); /* ------g5b5r6g6b6 */ \ - sd3 = vis_faligndata(sd3, sd3); \ - sd3 = vis_faligndata(sd3, sd3); \ - dd2 = vis_faligndata(dd2, sd3); /* ----g5b5r6g6b6r7 */ \ - sd3 = vis_faligndata(sd3, sd3); \ - dd2 = vis_faligndata(dd2, sd3); /* --g5b5r6g6b6r7g7 */ \ - sd3 = vis_faligndata(sd3, sd3); \ - dd2 = vis_faligndata(dd2, sd3); /* g5b5r6g6b6r7g7b7 */ - /***************************************************************/ #define EXTRACT_U8_43L /* shift left */ \ \ @@ -800,20 +87,6 @@ void mlib_v_ImageChannelExtract_S16_43R(const mlib_s16 *src, sda = vis_freg_pair(vis_read_lo(sd3), vis_read_hi(sd3)); \ dd2 = vis_faligndata(dd2, sda); /* g5b5r6g6b6r7g7b7 */ -/***************************************************************/ -#define LOAD_EXTRACT_U8_43L_STORE \ - \ - sd0 = *sp++; /* r0g0b0--r1g1b1-- */ \ - sd1 = *sp++; /* r2g2b2--r3g3b3-- */ \ - sd2 = *sp++; /* r4g4b4--r5g5b5-- */ \ - sd3 = *sp++; /* r6g6b6--r7g7b7-- */ \ - \ - EXTRACT_U8_43L; \ - \ - *dp++ = dd0; /* r0g0b0r1g1b1r2g2 */ \ - *dp++ = dd1; /* b2r3g3b3r4g4b4r5 */ \ - *dp++ = dd2; /* g5b5r6g6b6r7g7b7 */ - /***************************************************************/ #define LOAD_EXTRACT_U8_43L \ \ @@ -833,74 +106,6 @@ void mlib_v_ImageChannelExtract_S16_43R(const mlib_s16 *src, dd2old = dd2; \ EXTRACT_U8_43L -/***************************************************************/ -/* - * Both source and destination image data are 1-d vectors and - * 8-byte aligned. And dsize is multiple of 8. - */ - -void mlib_v_ImageChannelExtract_U8_43L_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize) -{ - mlib_d64 *sp, *dp; - mlib_d64 sd0, sd1, sd2, sd3; /* source data */ - mlib_d64 dd0, dd1, dd2; /* dst data */ - mlib_d64 sda; - mlib_s32 i; - - sp = (mlib_d64 *) src; - dp = (mlib_d64 *) dst; - - /* set GSR.offset for vis_faligndata() */ -/* vis_alignaddr((void *)0, 1); *//* for _old only */ - -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - LOAD_EXTRACT_U8_43L_STORE; - } -} - -/***************************************************************/ -/* - * Either source or destination image data are not 1-d vectors, but - * they are 8-byte aligned. And slb and dlb are multiple of 8. - * The xsize is multiple of 8. - */ - -void mlib_v_ImageChannelExtract_U8_43L_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize) -{ - mlib_d64 *sp, *dp; /* 8-byte aligned pointer for pixel */ - mlib_d64 *sl, *dl; /* 8-byte aligned pointer for line */ - mlib_d64 sd0, sd1, sd2, sd3; /* source data */ - mlib_d64 dd0, dd1, dd2; /* dst data */ - mlib_d64 sda; - mlib_s32 i, j; /* indices for x, y */ - - /* set GSR.offset for vis_faligndata() */ -/* vis_alignaddr((void *)0, 1); *//* for _old only */ - - sp = sl = (mlib_d64 *) src; - dp = dl = (mlib_d64 *) dst; - - /* row loop */ - for (j = 0; j < ysize; j++) { - /* 8-byte column loop */ -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - LOAD_EXTRACT_U8_43L_STORE; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } -} - /***************************************************************/ /* * Either source or destination data are not 8-byte aligned. @@ -1044,28 +249,6 @@ void mlib_v_ImageChannelExtract_U8_43L_D1(const mlib_u8 *src, } } -/***************************************************************/ -void mlib_v_ImageChannelExtract_U8_43L(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize) -{ - mlib_u8 *sa, *da; - mlib_u8 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelExtract_U8_43L_D1(sa, da, xsize); - sa = sl += slb; - da = dl += dlb; - } -} - /***************************************************************/ #define EXTRACT_S16_43L /* shift left */ \ vis_alignaddr((void *)0, 6); \ @@ -1082,20 +265,6 @@ void mlib_v_ImageChannelExtract_U8_43L(const mlib_u8 *src, dd2 = vis_faligndata(dd2, sd2); /* --r2g2b2 */ \ dd2 = vis_faligndata(dd2, sd3); /* b2r3g3b3 */ -/***************************************************************/ -#define LOAD_EXTRACT_S16_43L_STORE \ - \ - sd0 = *sp++; /* r0g0b0-- */ \ - sd1 = *sp++; /* r1g1b1-- */ \ - sd2 = *sp++; /* r2g2b2-- */ \ - sd3 = *sp++; /* r3g3b3-- */ \ - \ - EXTRACT_S16_43L; \ - \ - *dp++ = dd0; /* r0g0b0r1 */ \ - *dp++ = dd1; /* g1b1r2g2 */ \ - *dp++ = dd2; /* b2r3g3b3 */ - /***************************************************************/ #define LOAD_EXTRACT_S16_43L \ \ @@ -1113,72 +282,6 @@ void mlib_v_ImageChannelExtract_U8_43L(const mlib_u8 *src, dd2old = dd2; \ EXTRACT_S16_43L -/***************************************************************/ -/* - * Both source and destination image data are 1-d vectors and - * 8-byte aligned. And dsize is multiple of 4. - */ - -void mlib_v_ImageChannelExtract_S16_43L_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize) -{ - mlib_d64 *sp, *dp; /* 8-byte aligned pointer for pixel */ - mlib_d64 sd0, sd1, sd2, sd3; /* source data */ - mlib_d64 dd0, dd1, dd2; /* dst data */ - mlib_s32 i; - - sp = (mlib_d64 *) src; - dp = (mlib_d64 *) dst; - - /* set GSR.offset for vis_faligndata() */ -/* vis_alignaddr((void *)0, 2); *//* only for _old */ - -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - LOAD_EXTRACT_S16_43L_STORE; - } -} - -/***************************************************************/ -/* - * Either source or destination image data are not 1-d vectors, but - * they are 8-byte aligned. The xsize is multiple of 4. - * And slb and dlb are multiple of 8. - */ - -void mlib_v_ImageChannelExtract_S16_43L_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize) -{ - mlib_d64 *sp, *dp; /* 8-byte aligned pointer for pixel */ - mlib_d64 *sl, *dl; /* 8-byte aligned pointer for line */ - mlib_d64 sd0, sd1, sd2, sd3; /* source data */ - mlib_d64 dd0, dd1, dd2; /* dst data */ - mlib_s32 i, j; /* indices for x, y */ - - /* set GSR.offset for vis_faligndata() */ -/* vis_alignaddr((void *)0, 2); *//* only for _old */ - - sp = sl = (mlib_d64 *) src; - dp = dl = (mlib_d64 *) dst; - - /* row loop */ - for (j = 0; j < ysize; j++) { - /* 4-pixel column loop */ -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - LOAD_EXTRACT_S16_43L_STORE; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } -} - /***************************************************************/ /* * Either source or destination data are not 8-byte aligned. @@ -1318,25 +421,3 @@ void mlib_v_ImageChannelExtract_S16_43L_D1(const mlib_s16 *src, } /***************************************************************/ -void mlib_v_ImageChannelExtract_S16_43L(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize) -{ - mlib_s16 *sa, *da; - mlib_s16 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelExtract_S16_43L_D1(sa, da, xsize); - sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb); - da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } -} - -/***************************************************************/ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_f.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_f.c deleted file mode 100644 index da12ebaace7..00000000000 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_f.c +++ /dev/null @@ -1,784 +0,0 @@ -/* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - - -#include -#include "mlib_image.h" -#include "mlib_ImageCheck.h" - -typedef union { - double d64; - struct { - float f0; - float f1; - } f32s; -} d64_2_f32; - -/***************************************************************/ - -void mlib_v_ImageChannelExtract_U8_2_1(mlib_u8 *sl, mlib_s32 slb, - mlib_u8 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height) -{ - mlib_u8 *sp = sl; - mlib_u8 *dp = dl; - int i, j; - - for (j = 0; j < height; j++) { - mlib_u8 *dend = dl + width; - mlib_u32 *sp2; - while (((mlib_addr)sp & 7) > 1) { - *dp++ = *sp; - sp += 2; - if (dp >= dend) break; - } - if ((mlib_addr)sp & 7) { - sp2 = (mlib_u32 *)(sp - 1); -#pragma pipeloop(0) - for (; dp <= (dend-2); dp += 2) { - mlib_u32 s0; - s0 = *sp2++; - dp[0] = s0 >> 16; - dp[1] = s0; - } - if (dp < dend) { - dp[0] = sp2[0] >> 16; - } - } else { - sp2 = (mlib_u32 *)sp; -#pragma pipeloop(0) - for (; dp <= (dend-2); dp += 2) { - mlib_u32 s0; - s0 = *sp2++; - dp[0] = s0 >> 24; - dp[1] = s0 >> 8; - } - if (dp < dend) { - dp[0] = sp2[0] >> 24; - } - } - sp = sl += slb; - dp = dl += dlb; - } -} - -/***************************************************************/ - -void mlib_v_ImageChannelExtract_U8_3_2(mlib_u8 *sl, mlib_s32 slb, - mlib_u8 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height, - mlib_s32 count1) -{ - mlib_u8 *sp = sl; - mlib_u8 *dp = dl; - mlib_u32 *sp2; - mlib_u16 *dp2; - mlib_u16 *d2end; - mlib_u32 s0, s1, s2, s3; - int i, j, off, count_off; - - for (j = 0; j < height; j++) { - mlib_u8 *dend = dl + 2*width; - - if (count1 == 1) { - if (dp < dend) *dp++ = sp[0]; - sp += 2; - } - - if ((mlib_addr)dp & 1) { -#pragma pipeloop(0) - for (; dp <= (dend-2); dp += 2) { - dp[0] = sp[0]; - dp[1] = sp[1]; - sp += 3; - } - if (dp < dend) { - dp[0] = sp[0]; - } - sp = sl += slb; - dp = dl += dlb; - continue; - } - - dp2 = (mlib_u16*)dp; - d2end = (mlib_u16*)((mlib_addr)dend &~ 1); - off = (mlib_addr)sp & 3; - sp2 = (mlib_u32 *)(sp - off); - - switch (off) { - - case 0: -#pragma pipeloop(0) - for (; dp2 <= (d2end-4); dp2 += 4) { - s0 = sp2[0]; - s1 = sp2[1]; - s2 = sp2[2]; - dp2[0] = s0 >> 16; - dp2[1] = (s0 << 8) | (s1 >> 24); - dp2[2] = s1; - dp2[3] = s2 >> 8; - sp2 += 3; - } - break; - - case 1: -#pragma pipeloop(0) - for (; dp2 <= (d2end-4); dp2 += 4) { - s0 = sp2[0]; - s1 = sp2[1]; - s2 = sp2[2]; - dp2[0] = s0 >> 8; - dp2[1] = s1 >> 16; - dp2[2] = (s1 << 8) | (s2 >> 24); - dp2[3] = s2; - sp2 += 3; - } - break; - - case 2: -#pragma pipeloop(0) - s3 = sp2[0]; - for (; dp2 <= (d2end-4); dp2 += 4) { - s0 = s3; - s1 = sp2[1]; - s2 = sp2[2]; - s3 = sp2[3]; - dp2[0] = s0; - dp2[1] = s1 >> 8; - dp2[2] = s2 >> 16; - dp2[3] = (s2 << 8) | (s3 >> 24); - sp2 += 3; - } - break; - - case 3: -#pragma pipeloop(0) - s3 = sp2[0]; - for (; dp2 <= (d2end-4); dp2 += 4) { - s0 = s3; - s1 = sp2[1]; - s2 = sp2[2]; - s3 = sp2[3]; - dp2[0] = (s0 << 8) | (s1 >> 24); - dp2[1] = s1; - dp2[2] = s2 >> 8; - dp2[3] = s3 >> 16; - sp2 += 3; - } - } - - sp = (mlib_u8 *)sp2 + off; - dp = (mlib_u8 *)dp2; - while (dp < dend) { - *dp++ = sp[0]; - if (dp < dend) *dp++ = sp[1]; - sp += 3; - } - - sp = sl += slb; - dp = dl += dlb; - } -} - -/***************************************************************/ - -void mlib_v_ImageChannelExtract_U8_4_2(mlib_u8 *sl, mlib_s32 slb, - mlib_u8 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height, - mlib_s32 count1) -{ - mlib_u8 *sp = sl; - mlib_u8 *dp = dl; - mlib_u32 *sp2; - mlib_u16 *dp2; - mlib_u16 *d2end; - mlib_u32 s0, s1, s2, s3; - int i, j, off, count_off; - - for (j = 0; j < height; j++) { - mlib_u8 *dend = dl + 2*width; - - if (count1 == 1) { - if (dp < dend) *dp++ = sp[0]; - sp += 3; - } - - off = (mlib_addr)sp & 3; - - if (((mlib_addr)dp & 1) || (off == 3)) { -#pragma pipeloop(0) - for (; dp <= (dend-2); dp += 2) { - dp[0] = sp[0]; - dp[1] = sp[1]; - sp += 4; - } - if (dp < dend) { - dp[0] = sp[0]; - } - sp = sl += slb; - dp = dl += dlb; - continue; - } - - dp2 = (mlib_u16*)dp; - d2end = (mlib_u16*)((mlib_addr)dend &~ 1); - sp2 = (mlib_u32 *)(sp - off); - - switch (off) { - - case 0: -#pragma pipeloop(0) - for (; dp2 < d2end; dp2++) { - s0 = sp2[0]; - dp2[0] = s0 >> 16; - sp2++; - } - break; - - case 1: -#pragma pipeloop(0) - for (; dp2 < d2end; dp2++) { - s0 = sp2[0]; - dp2[0] = s0 >> 8; - sp2++; - } - break; - - case 2: -#pragma pipeloop(0) - for (; dp2 < d2end; dp2++) { - s0 = sp2[0]; - dp2[0] = s0; - sp2++; - } - break; - } - - sp = (mlib_u8 *)sp2 + off; - dp = (mlib_u8 *)dp2; - if (dp < dend) { - *dp++ = sp[0]; - } - - sp = sl += slb; - dp = dl += dlb; - } -} - -/***************************************************************/ - -void mlib_v_ImageChannelExtract_32_2_1(mlib_f32 *sp, mlib_s32 slb, - mlib_f32 *dp, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height) -{ - mlib_d64 *sp2; - int i, j, off; - - for (j = 0; j < height; j++) { - - if (((mlib_addr)sp & 7) == 0) { - sp2 = (mlib_d64 *)sp; -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - d64_2_f32 d; - d.d64 = sp2[i]; - dp[i] = d.f32s.f0; - } - } else { - sp2 = (mlib_d64 *)(sp - 1); -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - d64_2_f32 d; - d.d64 = sp2[i]; - dp[i] = d.f32s.f1; - } - } - - sp += slb; - dp += dlb; - } -} - -/***************************************************************/ - -void mlib_v_ImageChannelExtract_32_3_1(mlib_f32 *sl, mlib_s32 slb, - mlib_f32 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height) -{ - mlib_f32 *sp = sl; - mlib_f32 *dp = dl; - mlib_d64 *sp2; - d64_2_f32 d0; - int i, j, off; - - for (j = 0; j < height; j++) { - mlib_f32 *dend = dl + width; - - if ((mlib_addr)sp & 7) { - dp[0] = sp[0]; - sp += 3; - dp ++; - } - - sp2 = (mlib_d64 *)sp; -#pragma pipeloop(0) - for (; dp <= (dend-2); dp += 2) { - d64_2_f32 d0, d1; - d0.d64 = sp2[0]; - d1.d64 = sp2[1]; - dp[0] = d0.f32s.f0; - dp[1] = d1.f32s.f1; - sp2 += 3; - } - - if (dp < dend) { - d0.d64 = sp2[0]; - dp[0] = d0.f32s.f0; - } - - sp = sl += slb; - dp = dl += dlb; - } -} - -/***************************************************************/ - -void mlib_v_ImageChannelExtract_32_3_2(mlib_f32 *sl, mlib_s32 slb, - mlib_f32 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height, - mlib_s32 count1) -{ - mlib_f32 *sp = sl; - mlib_f32 *dp = dl; - mlib_d64 *sp2; - d64_2_f32 d0; - int i, j, off; - - for (j = 0; j < height; j++) { - mlib_f32 *dend = dl + 2*width; - - if (count1 == 1) { - if (dp < dend) *dp++ = sp[0]; - sp += 2; - } - - if ((mlib_addr)sp & 7) { - if (dp < dend) *dp++ = sp[0]; - if (dp < dend) *dp++ = sp[1]; - sp += 3; - } - - sp2 = (mlib_d64 *)sp; -#pragma pipeloop(0) - for (; dp <= (dend-4); dp += 4) { - d64_2_f32 d0, d1, d2; - d0.d64 = sp2[0]; - d1.d64 = sp2[1]; - d2.d64 = sp2[2]; - dp[0] = d0.f32s.f0; - dp[1] = d0.f32s.f1; - dp[2] = d1.f32s.f1; - dp[3] = d2.f32s.f0; - sp2 += 3; - } - - if (dp < dend) { - sp = (mlib_f32 *)sp2; - *dp++ = sp[0]; - if (dp < dend) *dp++ = sp[1]; - if (dp < dend) *dp++ = sp[3]; - } - - sp = sl += slb; - dp = dl += dlb; - } -} - -/***************************************************************/ - -void mlib_v_ImageChannelExtract_32_4_1(mlib_f32 *sp, mlib_s32 slb, - mlib_f32 *dp, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height) -{ - mlib_d64 *sp2; - int i, j, off; - - for (j = 0; j < height; j++) { - - if (((mlib_addr)sp & 7) == 0) { - sp2 = (mlib_d64 *)sp; -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - d64_2_f32 d; - d.d64 = sp2[2*i]; - dp[i] = d.f32s.f0; - } - } else { - sp2 = (mlib_d64 *)(sp - 1); -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - d64_2_f32 d; - d.d64 = sp2[2*i]; - dp[i] = d.f32s.f1; - } - } - - sp += slb; - dp += dlb; - } -} - -/***************************************************************/ - -void mlib_v_ImageChannelExtract_32_4_2(mlib_f32 *sl, mlib_s32 slb, - mlib_f32 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height, - mlib_s32 count1) -{ - mlib_f32 *sp = sl; - mlib_f32 *dp = dl; - mlib_d64 *sp2; - int i, j, off; - d64_2_f32 d0, d1; - - for (j = 0; j < height; j++) { - mlib_f32 *dend = dl + 2*width; - - if (count1 == 1) { - dp[0] = sp[0]; - sp += 3; - dp ++; - } - - if (((mlib_addr)sp & 7) == 0) { - sp2 = (mlib_d64 *)sp; -#pragma pipeloop(0) - for (; dp <= (dend-2); dp += 2) { - d64_2_f32 d; - d.d64 = sp2[0]; - dp[0] = d.f32s.f0; - dp[1] = d.f32s.f1; - sp2 += 2; - } - if (dp < dend) { - d0.d64 = sp2[0]; - dp[0] = d0.f32s.f0; - } - } else { - sp2 = (mlib_d64 *)(sp - 1); -#pragma pipeloop(0) - for (; dp <= (dend-2); dp += 2) { - d64_2_f32 d0, d1; - d0.d64 = sp2[0]; - d1.d64 = sp2[1]; - dp[0] = d0.f32s.f1; - dp[1] = d1.f32s.f0; - sp2 += 2; - } - if (dp < dend) { - d0.d64 = sp2[0]; - dp[0] = d0.f32s.f1; - } - } - - sp = sl += slb; - dp = dl += dlb; - } -} - -/***************************************************************/ - -void mlib_v_ImageChannelExtract_32_4_3(mlib_f32 *sl, mlib_s32 slb, - mlib_f32 *dl, mlib_s32 dlb, - mlib_s32 width, mlib_s32 height, - mlib_s32 count1) -{ - mlib_f32 *sp = sl; - mlib_f32 *dp = dl; - mlib_d64 *sp2; - int i, j, k; - d64_2_f32 d0, d1; - - for (j = 0; j < height; j++) { - mlib_f32 *dend = dl + 3*width; - - for (k = 0; k < count1; k++) { - if (dp < dend) *dp++ = *sp++; - } - sp++; - - if (((mlib_addr)sp & 7) == 0) { - sp2 = (mlib_d64 *)sp; -#pragma pipeloop(0) - for (; dp <= (dend-3); dp += 3) { - d64_2_f32 d0, d1; - d0.d64 = sp2[0]; - d1.d64 = sp2[1]; - dp[0] = d0.f32s.f0; - dp[1] = d0.f32s.f1; - dp[2] = d1.f32s.f0; - sp2 += 2; - } - if (dp < dend) { - d0.d64 = sp2[0]; - *dp++ = d0.f32s.f0; - if (dp < dend) *dp++ = d0.f32s.f1; - } - } else { - sp2 = (mlib_d64 *)(sp - 1); -#pragma pipeloop(0) - for (; dp <= (dend-3); dp += 3) { - d64_2_f32 d0, d1; - d0.d64 = sp2[0]; - d1.d64 = sp2[1]; - dp[0] = d0.f32s.f1; - dp[1] = d1.f32s.f0; - dp[2] = d1.f32s.f1; - sp2 += 2; - } - if (dp < dend) { - d0.d64 = sp2[0]; - d1.d64 = sp2[1]; - *dp++ = d0.f32s.f1; - if (dp < dend) *dp++ = d1.f32s.f0; - } - } - - sp = sl += slb; - dp = dl += dlb; - } -} - -/***************************************************************/ -/* general channel extraction: slower due to the inner loop */ - -void mlib_v_ImageChannelExtract_U8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 channels, mlib_s32 channeld, - mlib_s32 width, mlib_s32 height, - mlib_s32 cmask) -{ - mlib_u8 *sp; /* pointer for pixel in src */ - mlib_u8 *sl; /* pointer for line in src */ - mlib_u8 *dp; /* pointer for pixel in dst */ - mlib_u8 *dl; /* pointer for line in dst */ - int i, j, k; /* indices for x, y, channel */ - int deltac[5] = { 0, 1, 1, 1, 1 }; - int inc0, inc1, inc2, inc3; - mlib_u8 s0, s1, s2, s3; - - deltac[channeld] = 1; - for (i = (channels - 1), k = 0; i >= 0; i--) { - if ((cmask & (1 << i)) == 0) - deltac[k]++; - else - k++; - } - - deltac[channeld] = channels; - for (i = 1; i < channeld; i++) { - deltac[channeld] -= deltac[i]; - } - - sp = sl = src + deltac[0]; - dp = dl = dst; - -/* Only THREE CHANNEL CASE could be executed here!!! */ - - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - inc2 = deltac[3] + inc1; - for (j = 0; j < height; j++) { - for (i = 0; i < width; i++) { -#pragma pipeloop(0) - s0 = sp[0]; s1 = sp[inc0]; s2 = sp[inc1]; - dp[0] = s0; - dp[1] = s1; - dp[2] = s2; - sp += inc2; - dp += 3; - } - sp = sl += slb; - dp = dl += dlb; - } -} - -/***************************************************************/ -/* general channel extraction: slower due to the inner loop */ - -void mlib_v_ImageChannelExtract_S16(mlib_u16 *src, mlib_s32 slb, - mlib_u16 *dst, mlib_s32 dlb, - mlib_s32 channels, mlib_s32 channeld, - mlib_s32 width, mlib_s32 height, - mlib_s32 cmask) -{ - mlib_u16 *sp; /* pointer for pixel in src */ - mlib_u16 *sl; /* pointer for line in src */ - mlib_u16 *dp; /* pointer for pixel in dst */ - mlib_u16 *dl; /* pointer for line in dst */ - int i, j, k; /* indices for x, y, channel */ - int deltac[5] = { 0, 1, 1, 1, 1 }; - int inc0, inc1, inc2, inc3; - mlib_u16 s0, s1, s2, s3; - - slb >>= 1; - dlb >>= 1; - - deltac[channeld] = 1; - for (i = (channels - 1), k = 0; i >= 0; i--) { - if ((cmask & (1 << i)) == 0) - deltac[k]++; - else - k++; - } - - deltac[channeld] = channels; - for (i = 1; i < channeld; i++) { - deltac[channeld] -= deltac[i]; - } - - sp = sl = src + deltac[0]; - dp = dl = dst; - - if (channeld == 2) { - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; s1 = sp[inc0]; - dp[0] = s0; - dp[1] = s1; - sp += inc1; - dp += 2; - } - sp = sl = sl + slb; - dp = dl = dl + dlb; - } - } else - - if (channeld == 3) { - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - inc2 = deltac[3] + inc1; - for (j = 0; j < height; j++) { - for (i = 0; i < width; i++) { -#pragma pipeloop(0) - s0 = sp[0]; s1 = sp[inc0]; s2 = sp[inc1]; - dp[0] = s0; - dp[1] = s1; - dp[2] = s2; - sp += inc2; - dp += 3; - } - sp = sl = sl + slb; - dp = dl = dl + dlb; - } - }} - -/***************************************************************/ -/* general channel extraction: slower due to the inner loop */ - -void mlib_v_ImageChannelExtract_D64(mlib_d64 *src, mlib_s32 slb, - mlib_d64 *dst, mlib_s32 dlb, - mlib_s32 channels, mlib_s32 channeld, - mlib_s32 width, mlib_s32 height, - mlib_s32 cmask) -{ - mlib_d64 *sp; /* pointer for pixel in src */ - mlib_d64 *sl; /* pointer for line in src */ - mlib_d64 *dp; /* pointer for pixel in dst */ - mlib_d64 *dl; /* pointer for line in dst */ - int i, j, k; /* indices for x, y, channel */ - int deltac[5] = { 0, 1, 1, 1, 1 }; - int inc0, inc1, inc2, inc3; - mlib_d64 s0, s1, s2, s3; - - deltac[channeld] = 1; - for (i = (channels - 1), k = 0; i >= 0; i--) { - if ((cmask & (1 << i)) == 0) - deltac[k]++; - else - k++; - } - - deltac[channeld] = channels; - for (i = 1; i < channeld; i++) { - deltac[channeld] -= deltac[i]; - } - - sp = sl = src + deltac[0]; - dp = dl = dst; - - if (channeld == 1) { - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; - dp[i] = s0; - sp += channels; - } - sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb); - dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb); - } - } else - - if (channeld == 2) { - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; s1 = sp[inc0]; - dp[0] = s0; - dp[1] = s1; - sp += inc1; - dp += 2; - } - sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb); - dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb); - } - } else - - if (channeld == 3) { - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - inc2 = deltac[3] + inc1; - for (j = 0; j < height; j++) { - for (i = 0; i < width; i++) { -#pragma pipeloop(0) - s0 = sp[0]; s1 = sp[inc0]; s2 = sp[inc1]; - dp[0] = s0; - dp[1] = s1; - dp[2] = s2; - sp += inc2; - dp += 3; - } - sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb); - dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb); - } - } -} diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.c deleted file mode 100644 index f9fbf93e677..00000000000 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.c +++ /dev/null @@ -1,715 +0,0 @@ -/* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - - - -/* - * FUNCTIONS - * mlib_ImageChannelInsert - Copy the source image into the selected - * channels of the destination image - * - * SYNOPSIS - * mlib_status mlib_ImageChannelInsert(mlib_image *dst, - * mlib_image *src, - * mlib_s32 cmask); - * - * ARGUMENT - * dst Pointer to destination image. - * src Pointer to source image. - * cmask Destination channel selection mask. - * The least significant bit (LSB) is corresponding to the - * last channel in the destination image data. - * The bits with value 1 stand for the channels selected. - * If more than N channels are selected, the leftmost N - * channels are inserted, where N is the number of channels - * in the source image. - * - * RESTRICTION - * The src and dst must have the same width, height and data type. - * The src and dst can have 1, 2, 3 or 4 channels. - * The src and dst can be either MLIB_BYTE, MLIB_SHORT, MLIB_INT, - * MLIB_FLOAT or MLIB_DOUBLE. - * - * DESCRIPTION - * Copy the source image into the selected channels of the destination - * image - */ - -#include -#include "mlib_image.h" -#include "mlib_ImageCheck.h" - -/***************************************************************/ -/* functions defined in mlib_v_ImageChannelInsert_1.c */ - -void -mlib_v_ImageChannelInsert_U8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, mlib_s32 height, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_D64(mlib_d64 *src, mlib_s32 slb, - mlib_d64 *dst, mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, mlib_s32 height, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, mlib_s32 height, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S32(mlib_s32 *src, mlib_s32 slb, - mlib_s32 *dst, mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, mlib_s32 height, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_U8_12_A8D1X8(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_U8_12_A8D2X8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_U8_12_D1(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_U8_12(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_U8_13_A8D1X8(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_U8_13_A8D2X8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_U8_13_D1(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_U8_13(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_U8_14_A8D1X8(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_U8_14_A8D2X8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_U8_14_D1(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_U8_14(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16_12_A8D1X4(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16_12_A8D2X4(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16_12_D1(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16_12(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16_13_A8D1X4(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16_13_A8D2X4(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16_13_D1(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16_13(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16_14_A8D1X4(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16_14_A8D2X4(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16_14_D1(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); -void -mlib_v_ImageChannelInsert_S16_14(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize, - mlib_s32 cmask); - -/***************************************************************/ -/* functions defined in mlib_v_ImageChannelInsert_34.c */ - -void -mlib_v_ImageChannelInsert_U8_34R_A8D1X8(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelInsert_U8_34R_A8D2X8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelInsert_U8_34R_D1(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelInsert_U8_34R(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelInsert_S16_34R_A8D1X4(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelInsert_S16_34R_A8D2X4(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelInsert_S16_34R_D1(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelInsert_S16_34R(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelInsert_U8_34L_A8D1X8(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelInsert_U8_34L_A8D2X8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelInsert_U8_34L_D1(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelInsert_U8_34L(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelInsert_S16_34L_A8D1X4(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelInsert_S16_34L_A8D2X4(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); -void -mlib_v_ImageChannelInsert_S16_34L_D1(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); -void -mlib_v_ImageChannelInsert_S16_34L(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize); - - -/***************************************************************/ - -#ifdef MLIB_TEST -mlib_status -mlib_v_ImageChannelInsert(mlib_image *dst, - mlib_image *src, - mlib_s32 cmask) -#else -mlib_status -mlib_ImageChannelInsert(mlib_image *dst, - mlib_image *src, - mlib_s32 cmask) -#endif -{ - const mlib_s32 X8 = 0x7; - const mlib_s32 X4 = 0x3; - const mlib_s32 X2 = 0x1; - const mlib_s32 A8D1 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_ONEDVECTOR; - const mlib_s32 A8D2X8 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH8X; - const mlib_s32 A8D2X4 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH4X; - const mlib_s32 A8D2X2 = MLIB_IMAGE_ALIGNED8 | MLIB_IMAGE_STRIDE8X | MLIB_IMAGE_WIDTH2X; - - void *sp; /* pointer for pixel in src */ - void *dp; /* pointer for pixel in dst */ - mlib_s32 ncmask = 0; /* normalized channel mask */ - mlib_s32 channels; /* number of channels for src */ - mlib_s32 channeld; /* number of channels for dst */ - mlib_s32 width, height;/* for src and dst */ - mlib_s32 strides; /* strides in bytes for src */ - mlib_s32 strided; /* strides in bytes for dst */ - mlib_s32 flags; - mlib_s32 flagd; - mlib_s32 dsize; - int i, bit1count = 0; - - MLIB_IMAGE_CHECK(src); - MLIB_IMAGE_CHECK(dst); - MLIB_IMAGE_TYPE_EQUAL(src,dst); - MLIB_IMAGE_SIZE_EQUAL(src,dst); - - channels = mlib_ImageGetChannels(src); - channeld = mlib_ImageGetChannels(dst); - width = mlib_ImageGetWidth(src); - height = mlib_ImageGetHeight(src); - strides = mlib_ImageGetStride(src); - strided = mlib_ImageGetStride(dst); - sp = mlib_ImageGetData(src); - dp = mlib_ImageGetData(dst); - flags = mlib_ImageGetFlags(src); - flagd = mlib_ImageGetFlags(dst); - dsize = width * height; - - /* normalize the cmask, and count the number of bit with value 1 */ - for (i = (channeld - 1); i >= 0; i--) { - if (((cmask & (1 << i)) != 0) && (bit1count < channels)) { - ncmask += (1 << i); - bit1count++; - } - } - - /* do not support the cases in which the number of selected channels is - * less than the nubmber of channels in the source image */ - if (bit1count < channels) { - return MLIB_FAILURE; - } - - if (((channels == 1) && (channeld == 1)) || - ((channels == 2) && (channeld == 2)) || - ((channels == 3) && (channeld == 3)) || - ((channels == 4) && (channeld == 4))) { - return mlib_ImageCopy(dst, src); - } - - switch (mlib_ImageGetType(src)) { - case MLIB_BYTE: - if (channels == 1) { - switch (channeld) { - case 2: - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X8) == 0)) { - mlib_v_ImageChannelInsert_U8_12_A8D1X8((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize, - ncmask); - } - else if (((flags & A8D2X8) == 0) && - ((flagd & A8D2X8) == 0)) { - mlib_v_ImageChannelInsert_U8_12_A8D2X8((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height, - ncmask); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelInsert_U8_12_D1((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize, - ncmask); - } - else { - mlib_v_ImageChannelInsert_U8_12((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height, - ncmask); - } - break; - - case 3: - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X8) == 0)) { - mlib_v_ImageChannelInsert_U8_13_A8D1X8((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize, - ncmask); - } - else if (((flags & A8D2X8) == 0) && - ((flagd & A8D2X8) == 0)) { - mlib_v_ImageChannelInsert_U8_13_A8D2X8((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height, - ncmask); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelInsert_U8_13_D1((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize, - ncmask); - } - else { - mlib_v_ImageChannelInsert_U8_13((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height, - ncmask); - } - break; - - case 4: - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X8) == 0)) { - mlib_v_ImageChannelInsert_U8_14_A8D1X8((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize, - ncmask); - } - else if (((flags & A8D2X8) == 0) && - ((flagd & A8D2X8) == 0)) { - mlib_v_ImageChannelInsert_U8_14_A8D2X8((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height, - ncmask); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelInsert_U8_14_D1((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize, - ncmask); - } - else { - mlib_v_ImageChannelInsert_U8_14((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height, - ncmask); - } - break; - - default: - return MLIB_FAILURE; - } - } - else { - if ((channels == 3) && (channeld == 4) && (ncmask == 7)) { - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X8) == 0)) { - mlib_v_ImageChannelInsert_U8_34R_A8D1X8((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize); - } - else if (((flags & A8D2X8) == 0) && - ((flagd & A8D2X8) == 0)) { - mlib_v_ImageChannelInsert_U8_34R_A8D2X8((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelInsert_U8_34R_D1((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize); - } - else { - mlib_v_ImageChannelInsert_U8_34R((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height); - } - } - else if ((channels == 3) && (channeld == 4) && (ncmask == 14)) { - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X8) == 0)) { - mlib_v_ImageChannelInsert_U8_34L_A8D1X8((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize); - } - else if (((flags & A8D2X8) == 0) && - ((flagd & A8D2X8) == 0)) { - mlib_v_ImageChannelInsert_U8_34L_A8D2X8((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelInsert_U8_34L_D1((mlib_u8 *)sp, - (mlib_u8 *)dp, - dsize); - } - else mlib_v_ImageChannelInsert_U8_34L((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - width, height); - } - else { - - mlib_v_ImageChannelInsert_U8((mlib_u8 *)sp, strides, - (mlib_u8 *)dp, strided, - channels, channeld, - width, height, - ncmask); - } - } - break; - - case MLIB_SHORT: - if (channels == 1) { - switch (channeld) { - case 2: - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X4) == 0)) { - mlib_v_ImageChannelInsert_S16_12_A8D1X4((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize, - ncmask); - } - else if (((flags & A8D2X4) == 0) && - ((flagd & A8D2X4) == 0)) { - mlib_v_ImageChannelInsert_S16_12_A8D2X4((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height, - ncmask); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelInsert_S16_12_D1((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize, - ncmask); - } - else { - mlib_v_ImageChannelInsert_S16_12((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height, - ncmask); - } - break; - - case 3: - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X4) == 0)) { - mlib_v_ImageChannelInsert_S16_13_A8D1X4((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize, - ncmask); - } - else if (((flags & A8D2X4) == 0) && - ((flagd & A8D2X4) == 0)) { - mlib_v_ImageChannelInsert_S16_13_A8D2X4((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height, - ncmask); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelInsert_S16_13_D1((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize, - ncmask); - } - else { - mlib_v_ImageChannelInsert_S16_13((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height, - ncmask); - } - break; - - case 4: - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X4) == 0)) { - mlib_v_ImageChannelInsert_S16_14_A8D1X4((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize, - ncmask); - } - else if (((flags & A8D2X4) == 0) && - ((flagd & A8D2X4) == 0)) { - mlib_v_ImageChannelInsert_S16_14_A8D2X4((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height, - ncmask); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelInsert_S16_14_D1((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize, - ncmask); - } - else { - mlib_v_ImageChannelInsert_S16_14((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height, - ncmask); - } - break; - default: - return MLIB_FAILURE; - } - } - else if ((channels == 3) && (channeld == 4) && (ncmask == 7)) { - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X4) == 0)) { - mlib_v_ImageChannelInsert_S16_34R_A8D1X4((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize); - } - else if (((flags & A8D2X4) == 0) && - ((flagd & A8D2X4) == 0)) { - mlib_v_ImageChannelInsert_S16_34R_A8D2X4((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelInsert_S16_34R_D1((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize); - } - else { - mlib_v_ImageChannelInsert_S16_34R((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height); - } - } - else if ((channels == 3) && (channeld == 4) && (ncmask == 14)) { - if (((flags & A8D1) == 0) && - ((flagd & A8D1) == 0) && - ((dsize & X4) == 0)) { - mlib_v_ImageChannelInsert_S16_34L_A8D1X4((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize); - } - else if (((flags & A8D2X4) == 0) && - ((flagd & A8D2X4) == 0)) { - mlib_v_ImageChannelInsert_S16_34L_A8D2X4((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height); - } - else if (((flags & MLIB_IMAGE_ONEDVECTOR) == 0) && - ((flagd & MLIB_IMAGE_ONEDVECTOR) == 0)) { - mlib_v_ImageChannelInsert_S16_34L_D1((mlib_s16 *)sp, - (mlib_s16 *)dp, - dsize); - } - else { - mlib_v_ImageChannelInsert_S16_34L((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - width, height); - } - } - else { - mlib_v_ImageChannelInsert_S16((mlib_s16 *)sp, strides, - (mlib_s16 *)dp, strided, - channels, channeld, - width, height, - ncmask); - } - break; - - case MLIB_INT: - mlib_v_ImageChannelInsert_S32((mlib_s32 *)sp, strides, - (mlib_s32 *)dp, strided, - channels, channeld, - width, height, - ncmask); - break; - - case MLIB_FLOAT: - mlib_v_ImageChannelInsert_S32((mlib_s32 *)sp, strides, - (mlib_s32 *)dp, strided, - channels, channeld, - width, height, - ncmask); - break; - - - case MLIB_DOUBLE: - mlib_v_ImageChannelInsert_D64((mlib_d64 *)sp, strides, - (mlib_d64 *)dp, strided, - channels, channeld, - width, height, - ncmask); - break; - - - case MLIB_BIT: - default: - return MLIB_FAILURE; /* MLIB_BIT is not supported here */ - } - - return MLIB_SUCCESS; -} -/***************************************************************/ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.h b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.h index ff3c228548d..e6840157948 100644 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.h +++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.h @@ -32,290 +32,21 @@ extern "C" { #endif /* __cplusplus */ -void mlib_v_ImageChannelInsert_U8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, - mlib_s32 height, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_D64(const mlib_d64 *src, - mlib_s32 slb, - mlib_d64 *dst, - mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, - mlib_s32 height, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, - mlib_s32 height, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S32(const mlib_s32 *src, - mlib_s32 slb, - mlib_s32 *dst, - mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, - mlib_s32 height, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_U8_12_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_U8_12_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - void mlib_v_ImageChannelInsert_U8_12_D1(const mlib_u8 *src, mlib_u8 *dst, mlib_s32 dsize, mlib_s32 cmask); -void mlib_v_ImageChannelInsert_U8_12(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_U8_13_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_U8_13_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - void mlib_v_ImageChannelInsert_U8_13_D1(const mlib_u8 *src, mlib_u8 *dst, mlib_s32 dsize, mlib_s32 cmask); -void mlib_v_ImageChannelInsert_U8_13(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_U8_14_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_U8_14_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - void mlib_v_ImageChannelInsert_U8_14_D1(const mlib_u8 *src, mlib_u8 *dst, mlib_s32 dsize, mlib_s32 cmask); -void mlib_v_ImageChannelInsert_U8_14(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16_12_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16_12_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16_12_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16_12(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16_13_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16_13_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16_13_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16_13(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16_14_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16_14_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16_14_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_S16_14(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask); - -void mlib_v_ImageChannelInsert_U8_34R_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelInsert_U8_34R_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelInsert_U8_34R_D1(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelInsert_U8_34R(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelInsert_S16_34R_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelInsert_S16_34R_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelInsert_S16_34R_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelInsert_S16_34R(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelInsert_U8_34L_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelInsert_U8_34L_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelInsert_U8_34L_D1(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelInsert_U8_34L(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelInsert_S16_34L_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelInsert_S16_34L_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - -void mlib_v_ImageChannelInsert_S16_34L_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize); - -void mlib_v_ImageChannelInsert_S16_34L(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_1.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_1.c index ae0abf0dcea..b5dcf5e5cf2 100644 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_1.c +++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_1.c @@ -27,34 +27,9 @@ /* * FUNCTIONS - * mlib_v_ImageChannelInsert_U8 - * mlib_v_ImageChannelInsert_U8_12_A8D1X8 - * mlib_v_ImageChannelInsert_U8_12_A8D2X8 * mlib_v_ImageChannelInsert_U8_12_D1 - * mlib_v_ImageChannelInsert_U8_12 - * mlib_v_ImageChannelInsert_U8_13_A8D1X8 - * mlib_v_ImageChannelInsert_U8_13_A8D2X8 * mlib_v_ImageChannelInsert_U8_13_D1 - * mlib_v_ImageChannelInsert_U8_13 - * mlib_v_ImageChannelInsert_U8_14_A8D1X8 - * mlib_v_ImageChannelInsert_U8_14_A8D2X8 * mlib_v_ImageChannelInsert_U8_14_D1 - * mlib_v_ImageChannelInsert_U8_14 - * mlib_v_ImageChannelInsert_S16 - * mlib_v_ImageChannelInsert_S16_12_A8D1X4 - * mlib_v_ImageChannelInsert_S16_12_A8D2X4 - * mlib_v_ImageChannelInsert_S16_12_D1 - * mlib_v_ImageChannelInsert_S16_12 - * mlib_v_ImageChannelInsert_S16_13_A8D1X4 - * mlib_v_ImageChannelInsert_S16_13_A8D2X4 - * mlib_v_ImageChannelInsert_S16_13_D1 - * mlib_v_ImageChannelInsert_S16_13 - * mlib_v_ImageChannelInsert_S16_14_A8D1X4 - * mlib_v_ImageChannelInsert_S16_14_A8D2X4 - * mlib_v_ImageChannelInsert_S16_14_D1 - * mlib_v_ImageChannelInsert_S16_14 - * mlib_v_ImageChannelInsert_S32 - * mlib_v_ImageChannelInsert_D64 * * ARGUMENT * src pointer to source image data @@ -79,423 +54,11 @@ #include "mlib_image.h" #include "mlib_v_ImageChannelInsert.h" -/***************************************************************/ -/* general channel insertion: slower due to the inner loop */ -void mlib_v_ImageChannelInsert_U8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, - mlib_s32 height, - mlib_s32 cmask) -{ - mlib_u8 *sp; /* pointer for pixel in src */ - mlib_u8 *sl; /* pointer for line in src */ - mlib_u8 *dp; /* pointer for pixel in dst */ - mlib_u8 *dl; /* pointer for line in dst */ - mlib_s32 i, j, k; /* indices for x, y, channel */ - mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 }; - mlib_s32 inc0, inc1, inc2; - mlib_u8 s0, s1, s2; - - deltac[channels] = 1; - for (i = (channeld - 1), k = 0; i >= 0; i--) { - if ((cmask & (1 << i)) == 0) - deltac[k]++; - else - k++; - } - - deltac[channels] = channeld; - for (i = 1; i < channels; i++) { - deltac[channels] -= deltac[i]; - } - - sp = sl = (void *)src; - dp = dl = dst + deltac[0]; - - if (channels == 2) { - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; - s1 = sp[1]; - dp[0] = s0; - dp[inc0] = s1; - dp += inc1; - sp += 2; - } - - sp = sl += slb; - dp = dl += dlb; - } - } - else if (channels == 3) { - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - inc2 = deltac[3] + inc1; - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; - s1 = sp[1]; - s2 = sp[2]; - dp[0] = s0; - dp[inc0] = s1; - dp[inc1] = s2; - dp += inc2; - sp += 3; - } - - sp = sl += slb; - dp = dl += dlb; - } - } -} - -/***************************************************************/ -/* general channel insertion: slower due to the inner loop */ -void mlib_v_ImageChannelInsert_D64(const mlib_d64 *src, - mlib_s32 slb, - mlib_d64 *dst, - mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, - mlib_s32 height, - mlib_s32 cmask) -{ - mlib_d64 *sp; /* pointer for pixel in src */ - mlib_d64 *sl; /* pointer for line in src */ - mlib_d64 *dp; /* pointer for pixel in dst */ - mlib_d64 *dl; /* pointer for line in dst */ - mlib_s32 i, j, k; /* indices for x, y, channel */ - mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 }; - mlib_s32 inc0, inc1, inc2; - mlib_d64 s0, s1, s2; - - deltac[channels] = 1; - for (i = (channeld - 1), k = 0; i >= 0; i--) { - if ((cmask & (1 << i)) == 0) - deltac[k]++; - else - k++; - } - - deltac[channels] = channeld; - for (i = 1; i < channels; i++) { - deltac[channels] -= deltac[i]; - } - - sp = sl = (void *)src; - dp = dl = dst + deltac[0]; - - if (channels == 1) { - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; - dp[0] = s0; - dp += channeld; - sp++; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else if (channels == 2) { - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; - s1 = sp[1]; - dp[0] = s0; - dp[inc0] = s1; - dp += inc1; - sp += 2; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } - else if (channels == 3) { - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - inc2 = deltac[3] + inc1; - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; - s1 = sp[1]; - s2 = sp[2]; - dp[0] = s0; - dp[inc0] = s1; - dp[inc1] = s2; - dp += inc2; - sp += 3; - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } - } -} - -/***************************************************************/ -/* general channel insertion: slower due to the inner loop */ -void mlib_v_ImageChannelInsert_S16(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, - mlib_s32 height, - mlib_s32 cmask) -{ - mlib_s16 *sp; /* pointer for pixel in src */ - mlib_s16 *sl; /* pointer for line in src */ - mlib_s16 *dp; /* pointer for pixel in dst */ - mlib_s16 *dl; /* pointer for line in dst */ - mlib_s32 i, j, k; /* indices for x, y, channel */ - mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 }; - mlib_s32 inc0, inc1, inc2; - mlib_s16 s0, s1, s2; - - deltac[channels] = 1; - for (i = (channeld - 1), k = 0; i >= 0; i--) { - if ((cmask & (1 << i)) == 0) - deltac[k]++; - else - k++; - } - - deltac[channels] = channeld; - for (i = 1; i < channels; i++) { - deltac[channels] -= deltac[i]; - } - - sp = sl = (void *)src; - dp = dl = dst + deltac[0]; - - if (channels == 2) { - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; - s1 = sp[1]; - dp[0] = s0; - dp[inc0] = s1; - dp += inc1; - sp += 2; - } - - sp = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } - } - else if (channels == 3) { - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - inc2 = deltac[3] + inc1; - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; - s1 = sp[1]; - s2 = sp[2]; - dp[0] = s0; - dp[inc0] = s1; - dp[inc1] = s2; - dp += inc2; - sp += 3; - } - - sp = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } - } -} - -/***************************************************************/ -/* general channel insertion: slower due to the inner loop */ - -void mlib_v_ImageChannelInsert_S32(const mlib_s32 *src, - mlib_s32 slb, - mlib_s32 *dst, - mlib_s32 dlb, - mlib_s32 channels, - mlib_s32 channeld, - mlib_s32 width, - mlib_s32 height, - mlib_s32 cmask) -{ - mlib_s32 *sp; /* pointer for pixel in src */ - mlib_s32 *sl; /* pointer for line in src */ - mlib_s32 *dp; /* pointer for pixel in dst */ - mlib_s32 *dl; /* pointer for line in dst */ - mlib_s32 i, j, k; /* indices for x, y, channel */ - mlib_s32 deltac[5] = { 0, 1, 1, 1, 1 }; - mlib_s32 inc0, inc1, inc2; - mlib_s32 s0, s1, s2; - - deltac[channels] = 1; - for (i = (channeld - 1), k = 0; i >= 0; i--) { - if ((cmask & (1 << i)) == 0) - deltac[k]++; - else - k++; - } - - deltac[channels] = channeld; - for (i = 1; i < channels; i++) { - deltac[channels] -= deltac[i]; - } - - sp = sl = (void *)src; - dp = dl = dst + deltac[0]; - - if (channels == 1) { - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; - dp[0] = s0; - dp += channeld; - sp++; - } - - sp = sl = (mlib_s32 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb); - } - } - else if (channels == 2) { - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; - s1 = sp[1]; - dp[0] = s0; - dp[inc0] = s1; - dp += inc1; - sp += 2; - } - - sp = sl = (mlib_s32 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb); - } - } - else if (channels == 3) { - inc0 = deltac[1]; - inc1 = deltac[2] + inc0; - inc2 = deltac[3] + inc1; - for (j = 0; j < height; j++) { -#pragma pipeloop(0) - for (i = 0; i < width; i++) { - s0 = sp[0]; - s1 = sp[1]; - s2 = sp[2]; - dp[0] = s0; - dp[inc0] = s1; - dp[inc1] = s2; - dp += inc2; - sp += 3; - } - - sp = sl = (mlib_s32 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_s32 *) ((mlib_u8 *) dl + dlb); - } - } -} - /***************************************************************/ #define INSERT_U8_12(sd0, dd0, dd1) /* channel duplicate */ \ dd0 = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd0)); \ dd1 = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd0)) -/***************************************************************/ -/* insert one channel to a 2-channel image. - * both source and destination image data are 8-byte aligned. - * dsize is multiple of 8. - */ - -void mlib_v_ImageChannelInsert_U8_12_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 sd0; - mlib_d64 dd0, dd1; - mlib_s32 bmask; - mlib_s32 i; - - bmask = cmask | (cmask << 2) | (cmask << 4) | (cmask << 6); - - sp = (mlib_d64 *) src; - dp = (mlib_d64 *) dst; - -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - sd0 = *sp++; - INSERT_U8_12(sd0, dd0, dd1); - vis_pst_8(dd0, dp++, bmask); - vis_pst_8(dd1, dp++, bmask); - } -} - -/***************************************************************/ -/* insert one channel to a 2-channel image. - * both source and destination image data are 8-byte aligned. - * xsize is multiple of 8. - */ - -void mlib_v_ImageChannelInsert_U8_12_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 *sl, *dl; - mlib_d64 sd0; - mlib_d64 dd0, dd1; - mlib_s32 bmask; - mlib_s32 i, j; - - bmask = cmask | (cmask << 2) | (cmask << 4) | (cmask << 6); - - sp = sl = (mlib_d64 *) src; - dp = dl = (mlib_d64 *) dst; - - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - sd0 = *sp++; - INSERT_U8_12(sd0, dd0, dd1); - vis_pst_8(dd0, dp++, bmask); - vis_pst_8(dd1, dp++, bmask); - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } -} - /***************************************************************/ /* insert one channel to a 2-channel image. */ @@ -723,56 +286,6 @@ void mlib_v_ImageChannelInsert_U8_12_D1(const mlib_u8 *src, } } -/***************************************************************/ -/* insert one channel to a 2-channel image. - */ - -void mlib_v_ImageChannelInsert_U8_12(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_u8 *sa, *da; - mlib_u8 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - -#pragma pipeloop(0) - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelInsert_U8_12_D1(sa, da, xsize, cmask); - sa = sl += slb; - da = dl += dlb; - } -} - -/***************************************************************/ -#define INSERT_U8_13(sd0, dd0, dd1, dd2) \ - sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd0)); \ - sdb = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sda)); \ - sdc = vis_fpmerge(vis_read_hi(sdb), vis_read_hi(sdb)); \ - sdd = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdb)); \ - dd0 = vis_fpmerge(vis_read_hi(sdc), vis_read_hi(sdd)); \ - sde = vis_fpmerge(vis_read_lo(sdc), vis_read_lo(sdd)); \ - dd1 = vis_freg_pair(vis_read_lo(dd0), vis_read_hi(sde)); \ - dd2 = vis_freg_pair(vis_read_lo(sde), vis_read_lo(sde)) - -/***************************************************************/ -#define LOAD_INSERT_STORE_U8_A8(channeld) \ - sd = *sp++; \ - vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld - /***************************************************************/ #define LOAD_INSERT_STORE_U8(channeld) \ vis_alignaddr((void *)0, off); \ @@ -789,58 +302,6 @@ void mlib_v_ImageChannelInsert_U8_12(const mlib_u8 *src, vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld; \ vis_st_u8(sd = vis_faligndata(sd, sd), da); da += channeld -/***************************************************************/ -void mlib_v_ImageChannelInsert_U8_13_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_u8 *da; - mlib_d64 *sp; - mlib_d64 sd; - mlib_s32 i; - - vis_alignaddr((void *)0, 1); /* for 1-byte left shift */ - - sp = (mlib_d64 *) src; - da = dst + (2 / cmask); /* 4,2,1 -> 0,1,2 */ - -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - LOAD_INSERT_STORE_U8_A8(3); - } -} - -/***************************************************************/ -void mlib_v_ImageChannelInsert_U8_13_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_u8 *da, *dl; - mlib_d64 *sp, *sl; - mlib_d64 sd; - mlib_s32 i, j; - - vis_alignaddr((void *)0, 1); - - sp = sl = (mlib_d64 *) src; - da = dl = dst + (2 / cmask); /* 4,2,1 -> 0,1,2 */ - - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - LOAD_INSERT_STORE_U8_A8(3); - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - da = dl = (mlib_u8 *) ((mlib_u8 *) dl + dlb); - } -} - /***************************************************************/ void mlib_v_ImageChannelInsert_U8_13_D1(const mlib_u8 *src, mlib_u8 *dst, @@ -907,30 +368,6 @@ void mlib_v_ImageChannelInsert_U8_13_D1(const mlib_u8 *src, } } -/***************************************************************/ -void mlib_v_ImageChannelInsert_U8_13(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_u8 *sa, *da; - mlib_u8 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - -#pragma pipeloop(0) - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelInsert_U8_13_D1(sa, da, xsize, cmask); - sa = sl += slb; - da = dl += dlb; - } -} - /***************************************************************/ #define INSERT_U8_14(sd0, dd0, dd1, dd2, dd3) \ sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd0)); \ @@ -940,73 +377,6 @@ void mlib_v_ImageChannelInsert_U8_13(const mlib_u8 *src, dd2 = vis_fpmerge(vis_read_hi(sdb), vis_read_hi(sdb)); \ dd3 = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdb)) -/***************************************************************/ -void mlib_v_ImageChannelInsert_U8_14_A8D1X8(const mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 sd0; - mlib_d64 sda, sdb; - mlib_d64 dd0, dd1, dd2, dd3; - mlib_s32 bmask; - mlib_s32 i; - - bmask = cmask | (cmask << 4); - - sp = (mlib_d64 *) src; - dp = (mlib_d64 *) dst; - -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - sd0 = *sp++; - INSERT_U8_14(sd0, dd0, dd1, dd2, dd3); - vis_pst_8(dd0, dp++, bmask); - vis_pst_8(dd1, dp++, bmask); - vis_pst_8(dd2, dp++, bmask); - vis_pst_8(dd3, dp++, bmask); - } -} - -/***************************************************************/ -void mlib_v_ImageChannelInsert_U8_14_A8D2X8(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_d64 *sp, *dp; - mlib_d64 *sl, *dl; - mlib_d64 sd0; - mlib_d64 sda, sdb; - mlib_d64 dd0, dd1, dd2, dd3; - mlib_s32 bmask; - mlib_s32 i, j; - - bmask = cmask | (cmask << 4); - - sp = sl = (mlib_d64 *) src; - dp = dl = (mlib_d64 *) dst; - - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - sd0 = *sp++; - INSERT_U8_14(sd0, dd0, dd1, dd2, dd3); - vis_pst_8(dd0, dp++, bmask); - vis_pst_8(dd1, dp++, bmask); - vis_pst_8(dd2, dp++, bmask); - vis_pst_8(dd3, dp++, bmask); - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - dp = dl = (mlib_d64 *) ((mlib_u8 *) dl + dlb); - } -} - /***************************************************************/ void mlib_v_ImageChannelInsert_U8_14_D1(const mlib_u8 *src, mlib_u8 *dst, @@ -1188,445 +558,5 @@ void mlib_v_ImageChannelInsert_U8_14_D1(const mlib_u8 *src, } } -/***************************************************************/ -void mlib_v_ImageChannelInsert_U8_14(const mlib_u8 *src, - mlib_s32 slb, - mlib_u8 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_u8 *sa, *da; - mlib_u8 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - -#pragma pipeloop(0) - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelInsert_U8_14_D1(sa, da, xsize, cmask); - sa = sl += slb; - da = dl += dlb; - } -} - -/***************************************************************/ -#define LOAD_INSERT_STORE_S16_1X_A8(channeld) \ - sd = *sp++; \ - vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld - -/***************************************************************/ -#define LOAD_INSERT_STORE_S16_1X(channeld) \ - vis_alignaddr((void *)0, off); \ - sd0 = sd1; \ - sd1 = *sp++; \ - sd = vis_faligndata(sd0, sd1); \ - vis_alignaddr((void *)0, 2); \ - vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld; \ - vis_st_u16(sd = vis_faligndata(sd, sd), da); da += channeld - -/***************************************************************/ -void mlib_v_ImageChannelInsert_S16_12_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_s16 *da; - mlib_d64 *sp; - mlib_d64 sd; - mlib_s32 i; - - sp = (mlib_d64 *) src; - da = dst + (2 - cmask); /* 2,1 -> 0,1 */ - - vis_alignaddr((void *)0, 2); - -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - LOAD_INSERT_STORE_S16_1X_A8(2); - } -} - -/***************************************************************/ -void mlib_v_ImageChannelInsert_S16_12_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_s16 *da, *dl; - mlib_d64 *sp, *sl; - mlib_d64 sd; - mlib_s32 i, j; - - sp = sl = (mlib_d64 *) src; - da = dl = dst + (2 - cmask); /* 2,1 -> 0,1 */ - - vis_alignaddr((void *)0, 2); - - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - LOAD_INSERT_STORE_S16_1X_A8(2); - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } -} - -/***************************************************************/ -void mlib_v_ImageChannelInsert_S16_12_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_s16 *sa, *da; - mlib_s16 *dend; /* end point in destination */ - mlib_d64 *sp; /* 8-byte aligned start points in src */ - mlib_d64 sd0, sd1, sd; /* 8-byte registers for source data */ - mlib_s32 off; /* offset of address alignment in src */ - mlib_s32 i; - - sa = (void *)src; - da = dst + (2 - cmask); /* 2,1 -> 0,1 */ - - /* prepare the src address */ - sp = (mlib_d64 *) ((mlib_addr) sa & (~7)); - off = (mlib_addr) sa & 7; - - dend = da + dsize * 2 - 1; - - sd1 = *sp++; - -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - LOAD_INSERT_STORE_S16_1X(2); - } - - /* right end handling */ - if ((mlib_addr) da <= (mlib_addr) dend) { - - vis_alignaddr((void *)0, off); - sd0 = sd1; - sd1 = *sp++; - sd = vis_faligndata(sd0, sd1); - - vis_alignaddr((void *)0, 2); - vis_st_u16(sd = vis_faligndata(sd, sd), da); - da += 2; - if ((mlib_addr) da <= (mlib_addr) dend) { - vis_st_u16(sd = vis_faligndata(sd, sd), da); - da += 2; - if ((mlib_addr) da <= (mlib_addr) dend) { - vis_st_u16(sd = vis_faligndata(sd, sd), da); - } - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelInsert_S16_12(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_s16 *sa, *da; - mlib_s16 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - -#pragma pipeloop(0) - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelInsert_S16_12_D1(sa, da, xsize, cmask); - sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb); - da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } -} - -/***************************************************************/ -void mlib_v_ImageChannelInsert_S16_13_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_s16 *da; - mlib_d64 *sp; - mlib_d64 sd; - mlib_s32 i; - - sp = (mlib_d64 *) src; - da = dst + (2 / cmask); /* 4,2,1 -> 0,1,2 */ - - vis_alignaddr((void *)0, 2); - -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - LOAD_INSERT_STORE_S16_1X_A8(3); - } -} - -/***************************************************************/ -void mlib_v_ImageChannelInsert_S16_13_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_s16 *da, *dl; - mlib_d64 *sp, *sl; - mlib_d64 sd; - mlib_s32 i, j; - - sp = sl = (mlib_d64 *) src; - da = dl = dst + (2 / cmask); /* 4,2,1 -> 0,1,2 */ - - vis_alignaddr((void *)0, 2); - - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - LOAD_INSERT_STORE_S16_1X_A8(3); - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } -} - -/***************************************************************/ -void mlib_v_ImageChannelInsert_S16_13_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_s16 *sa, *da; - mlib_s16 *dend; /* end point in destination */ - mlib_d64 *sp; /* 8-byte aligned start points in src */ - mlib_d64 sd0, sd1, sd; /* 8-byte registers for source data */ - mlib_s32 off; /* offset of address alignment in src */ - mlib_s32 i; - - sa = (void *)src; - da = dst + (2 / cmask); /* 4,2,1 -> 0,1,2 */ - - /* prepare the src address */ - sp = (mlib_d64 *) ((mlib_addr) sa & (~7)); - off = (mlib_addr) sa & 7; - - dend = da + dsize * 3 - 1; - - sd1 = *sp++; - -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - LOAD_INSERT_STORE_S16_1X(3); - } - - /* right end handling */ - if ((mlib_addr) da <= (mlib_addr) dend) { - - vis_alignaddr((void *)0, off); - sd0 = sd1; - sd1 = *sp++; - sd = vis_faligndata(sd0, sd1); - - vis_alignaddr((void *)0, 2); - vis_st_u16(sd = vis_faligndata(sd, sd), da); - da += 3; - if ((mlib_addr) da <= (mlib_addr) dend) { - vis_st_u16(sd = vis_faligndata(sd, sd), da); - da += 3; - if ((mlib_addr) da <= (mlib_addr) dend) { - vis_st_u16(sd = vis_faligndata(sd, sd), da); - } - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelInsert_S16_13(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_s16 *sa, *da; - mlib_s16 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - -#pragma pipeloop(0) - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelInsert_S16_13_D1(sa, da, xsize, cmask); - sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb); - da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } -} - -/***************************************************************/ -#define INSERT_S16_14(sp, dp, bmask) /* channel duplicate */ \ - /* obsolete: it is slower than the vis_st_u16() version*/ \ - sd0 = *sp++; \ - sda = vis_fpmerge(vis_read_hi(sd0), vis_read_hi(sd0)); \ - sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_lo(sd0)); \ - sdc = vis_fpmerge(vis_read_hi(sda), vis_read_hi(sda)); \ - sdd = vis_fpmerge(vis_read_lo(sda), vis_read_lo(sda)); \ - sde = vis_fpmerge(vis_read_hi(sdb), vis_read_hi(sdb)); \ - sdf = vis_fpmerge(vis_read_lo(sdb), vis_read_lo(sdb)); \ - dd0 = vis_fpmerge(vis_read_hi(sdc), vis_read_lo(sdc)); \ - dd1 = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sdd)); \ - dd2 = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sde)); \ - dd3 = vis_fpmerge(vis_read_hi(sdf), vis_read_lo(sdf)); \ - vis_pst_16(dd0, dp++, bmask); \ - vis_pst_16(dd1, dp++, bmask); \ - vis_pst_16(dd2, dp++, bmask); \ - vis_pst_16(dd3, dp++, bmask) - -/***************************************************************/ -void mlib_v_ImageChannelInsert_S16_14_A8D1X4(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_s16 *da; - mlib_d64 *sp; - mlib_d64 sd; - mlib_s32 i; - - sp = (mlib_d64 *) src; - da = dst + (6 / cmask + 1) / 2; /* 8,4,2,1 -> 0,1,2,3 */ - - vis_alignaddr((void *)0, 2); - -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - LOAD_INSERT_STORE_S16_1X_A8(4); - } -} - -/***************************************************************/ -void mlib_v_ImageChannelInsert_S16_14_A8D2X4(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_s16 *da, *dl; - mlib_d64 *sp, *sl; - mlib_d64 sd; - mlib_s32 i, j; - - sp = sl = (mlib_d64 *) src; - da = dl = dst + (6 / cmask + 1) / 2; /* 8,4,2,1 -> 0,1,2,3 */ - - vis_alignaddr((void *)0, 2); - - for (j = 0; j < ysize; j++) { -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - LOAD_INSERT_STORE_S16_1X_A8(4); - } - - sp = sl = (mlib_d64 *) ((mlib_u8 *) sl + slb); - da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } -} - -/***************************************************************/ -void mlib_v_ImageChannelInsert_S16_14_D1(const mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize, - mlib_s32 cmask) -{ - mlib_s16 *sa, *da; - mlib_s16 *dend; /* end point in destination */ - mlib_d64 *sp; /* 8-byte aligned start points in src */ - mlib_d64 sd0, sd1, sd; /* 8-byte registers for source data */ - mlib_s32 off; /* offset of address alignment in src */ - mlib_s32 i; - - sa = (void *)src; - da = dst + (6 / cmask + 1) / 2; /* 8,4,2,1 -> 0,1,2,3 */ - - /* prepare the src address */ - sp = (mlib_d64 *) ((mlib_addr) sa & (~7)); - off = (mlib_addr) sa & 7; - - dend = da + dsize * 4 - 1; - - sd1 = *sp++; - -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - LOAD_INSERT_STORE_S16_1X(4); - } - - /* right end handling */ - if ((mlib_addr) da <= (mlib_addr) dend) { - - vis_alignaddr((void *)0, off); - sd0 = sd1; - sd1 = *sp++; - sd = vis_faligndata(sd0, sd1); - - vis_alignaddr((void *)0, 2); - vis_st_u16(sd = vis_faligndata(sd, sd), da); - da += 4; - if ((mlib_addr) da <= (mlib_addr) dend) { - vis_st_u16(sd = vis_faligndata(sd, sd), da); - da += 4; - if ((mlib_addr) da <= (mlib_addr) dend) { - vis_st_u16(sd = vis_faligndata(sd, sd), da); - } - } - } -} - -/***************************************************************/ -void mlib_v_ImageChannelInsert_S16_14(const mlib_s16 *src, - mlib_s32 slb, - mlib_s16 *dst, - mlib_s32 dlb, - mlib_s32 xsize, - mlib_s32 ysize, - mlib_s32 cmask) -{ - mlib_s16 *sa, *da; - mlib_s16 *sl, *dl; - mlib_s32 j; - - sa = sl = (void *)src; - da = dl = dst; - -#pragma pipeloop(0) - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelInsert_S16_14_D1(sa, da, xsize, cmask); - sa = sl = (mlib_s16 *) ((mlib_u8 *) sl + slb); - da = dl = (mlib_s16 *) ((mlib_u8 *) dl + dlb); - } -} /***************************************************************/ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_34.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_34.c deleted file mode 100644 index 105409a8a56..00000000000 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_34.c +++ /dev/null @@ -1,1225 +0,0 @@ -/* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - - -/* - * FILENAME: mlib_v_ImageChannelInsert_34.c - * - * FUNCTIONS - * mlib_v_ImageChannelInsert_U8_34R_A8D1X8 - * mlib_v_ImageChannelInsert_U8_34R_A8D2X8 - * mlib_v_ImageChannelInsert_U8_34R_D1 - * mlib_v_ImageChannelInsert_U8_34R - * mlib_v_ImageChannelInsert_S16_34R_A8D1X4 - * mlib_v_ImageChannelInsert_S16_34R_A8D2X4 - * mlib_v_ImageChannelInsert_S16_34R_D1 - * mlib_v_ImageChannelInsert_S16_34R - * mlib_v_ImageChannelInsert_U8_34L_A8D1X8 - * mlib_v_ImageChannelInsert_U8_34L_A8D2X8 - * mlib_v_ImageChannelInsert_U8_34L_D1 - * mlib_v_ImageChannelInsert_U8_34L - * mlib_v_ImageChannelInsert_S16_34L_A8D1X4 - * mlib_v_ImageChannelInsert_S16_34L_A8D2X4 - * mlib_v_ImageChannelInsert_S16_34L_D1 - * mlib_v_ImageChannelInsert_S16_34L - * - * SYNOPSIS - * - * ARGUMENT - * src pointer to source image data - * dst pointer to destination image data - * slb source image line stride in bytes - * dlb destination image line stride in bytes - * dsize image data size in pixels - * xsize image width in pixels - * ysize image height in lines - * cmask channel mask - * - * DESCRIPTION - * Insert a 3-channel image into the right or left 3 channels of - * a 4-channel image low level functions. - * - * BGR => ABGR (34R), or RGB => RGBA (34L) - * - * NOTE - * These functions are separated from mlib_v_ImageChannelInsert.c - * for loop unrolling and structure clarity. - */ - -#include -#include "vis_proto.h" -#include "mlib_image.h" - -/***************************************************************/ -#define INSERT_U8_34R \ - sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1)); \ - sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2)); \ - sdc = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2)); \ - sdd = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb)); \ - sde = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdc)); \ - sdf = vis_fpmerge(vis_read_hi(sdb), vis_read_lo(sdc)); \ - sdg = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde)); \ - sdh = vis_fpmerge(vis_read_lo(sdd), vis_read_hi(sdf)); \ - sdi = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sdf)); \ - sdj = vis_fpmerge(vis_read_hi(sdg), vis_read_hi(sdi)); \ - sdk = vis_fpmerge(vis_read_lo(sdg), vis_read_lo(sdi)); \ - sdl = vis_fpmerge(vis_read_hi(sdh), vis_read_hi(sdh)); \ - sdm = vis_fpmerge(vis_read_lo(sdh), vis_read_lo(sdh)); \ - dd0 = vis_fpmerge(vis_read_hi(sdl), vis_read_hi(sdj)); \ - dd1 = vis_fpmerge(vis_read_lo(sdl), vis_read_lo(sdj)); \ - dd2 = vis_fpmerge(vis_read_hi(sdm), vis_read_hi(sdk)); \ - dd3 = vis_fpmerge(vis_read_lo(sdm), vis_read_lo(sdk)); - -/***************************************************************/ -#define LOAD_INSERT_STORE_U8_34R_A8 \ - sd0 = *sp++; /* b0g0r0b1g1r1b2g2 */ \ - sd1 = *sp++; /* r2b3g3r3b4g4r4b5 */ \ - sd2 = *sp++; /* g5r5b6g6r6b7g7r7 */ \ - INSERT_U8_34R \ - vis_pst_8(dd0, dp++, bmask); \ - vis_pst_8(dd1, dp++, bmask); \ - vis_pst_8(dd2, dp++, bmask); \ - vis_pst_8(dd3, dp++, bmask); - -/***************************************************************/ -#define LOAD_INSERT_U8_34R \ - vis_alignaddr((void *)soff, 0); \ - s0 = s3; \ - s1 = sp[1]; \ - s2 = sp[2]; \ - s3 = sp[3]; \ - sd0 = vis_faligndata(s0, s1); \ - sd1 = vis_faligndata(s1, s2); \ - sd2 = vis_faligndata(s2, s3); \ - sp += 3; \ - dd4 = dd3; \ - INSERT_U8_34R - -/***************************************************************/ -/* - * Both source and destination image data are 1-d vectors and - * 8-byte aligned. And dsize is multiple of 8. - */ - -void -mlib_v_ImageChannelInsert_U8_34R_A8D1X8(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize) -{ - mlib_d64 *sp, *dp; - mlib_d64 sd0, sd1, sd2; /* source data */ - mlib_d64 dd0, dd1, dd2, dd3; /* dst data */ - mlib_d64 sda, sdb, sdc, sdd; /* intermediate variables */ - mlib_d64 sde, sdf, sdg, sdh; - mlib_d64 sdi, sdj, sdk, sdl; - mlib_d64 sdm; - int bmask = 0x77; - int i; - - sp = (mlib_d64 *)src; - dp = (mlib_d64 *)dst; - -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - LOAD_INSERT_STORE_U8_34R_A8; - } -} - -/***************************************************************/ -/* - * Either source or destination image data are not 1-d vectors, but - * they are 8-byte aligned. And slb and dlb are multiple of 8. - * The xsize is multiple of 8. - */ - -void -mlib_v_ImageChannelInsert_U8_34R_A8D2X8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize) -{ - mlib_d64 *sp, *dp; /* 8-byte aligned pointer for pixel */ - mlib_d64 *sl, *dl; /* 8-byte aligned pointer for line */ - mlib_d64 sd0, sd1, sd2; /* source data */ - mlib_d64 dd0, dd1, dd2, dd3; /* dst data */ - mlib_d64 sda, sdb, sdc, sdd; /* intermediate variables */ - mlib_d64 sde, sdf, sdg, sdh; - mlib_d64 sdi, sdj, sdk, sdl; - mlib_d64 sdm; - int bmask = 0x77; - int i, j; /* indices for x, y */ - - sp = sl = (mlib_d64 *)src; - dp = dl = (mlib_d64 *)dst; - - /* row loop */ - for (j = 0; j < ysize; j++) { - /* 8-byte column loop */ -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - LOAD_INSERT_STORE_U8_34R_A8; - } - sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb); - dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb); - } -} - -/***************************************************************/ -/* - * either source or destination data are not 8-byte aligned. - */ - -void -mlib_v_ImageChannelInsert_U8_34R_D1(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize) -{ - mlib_u8 *sa, *da; - mlib_u8 *dend, *dend2; /* end points in dst */ - mlib_d64 *dp; /* 8-byte aligned start points in dst */ - mlib_d64 *sp; /* 8-byte aligned start point in src */ - mlib_d64 s0, s1, s2, s3; /* 8-byte source raw data */ - mlib_d64 sd0, sd1, sd2; /* 8-byte source data */ - mlib_d64 dd0, dd1, dd2, dd3; /* dst data */ - mlib_d64 dd4; /* the last datum of the last step */ - mlib_d64 sda, sdb, sdc, sdd; /* intermediate variables */ - mlib_d64 sde, sdf, sdg, sdh; - mlib_d64 sdi, sdj, sdk, sdl; - mlib_d64 sdm; - int soff; /* offset of address in src */ - int doff; /* offset of address in dst */ - int emask; /* edge mask */ - int bmask; /* channel mask */ - int i, n; - - sa = src; - da = dst; - - /* prepare the source address */ - sp = (mlib_d64 *) ((mlib_addr) sa & (~7)); - soff = ((mlib_addr) sa & 7); - - /* prepare the destination addresses */ - dp = (mlib_d64 *)((mlib_addr) da & (~7)); - dend = da + dsize * 4 - 1; - dend2 = dend - 31; - doff = ((mlib_addr) da & 7); - - /* set band mask for vis_pst_8 to store the bytes needed */ - bmask = 0xff & (0x7777 >> doff) ; - - /* generate edge mask for the start point */ - emask = vis_edge8(da, dend); - - /* load 24 bytes, convert to 32 bytes */ - s3 = sp[0]; /* initial value */ - LOAD_INSERT_U8_34R; - - if (doff == 0) { /* dst is 8-byte aligned */ - - if (dsize >= 8 ) { - vis_pst_8(dd0, dp++, emask & bmask); - vis_pst_8(dd1, dp++, bmask); - vis_pst_8(dd2, dp++, bmask); - vis_pst_8(dd3, dp++, bmask); - } - else { /* for very small size */ - vis_pst_8(dd0, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd1, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd2, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd3, dp++, emask & bmask); - } - } - } - } - - /* no edge handling is needed in the loop */ - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1; -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - LOAD_INSERT_U8_34R; - vis_pst_8(dd0, dp++, bmask); - vis_pst_8(dd1, dp++, bmask); - vis_pst_8(dd2, dp++, bmask); - vis_pst_8(dd3, dp++, bmask); - } - } - - if ((mlib_addr) dp <= (mlib_addr) dend) { - LOAD_INSERT_U8_34R; - emask = vis_edge8(dp, dend); - vis_pst_8(dd0, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd1, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd2, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd3, dp++, emask & bmask); - } - } - } - } - } - else { /* (doff != 0) */ - vis_alignaddr((void *)0, -doff); - - if (dsize >= 8 ) { - vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask); - vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask); - vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask); - vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask); - } - else { /* for very small size */ - vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd3, dd3), dp++, emask & bmask); - } - } - } - } - } - - /* no edge handling is needed in the loop */ - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1; -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - LOAD_INSERT_U8_34R; - vis_alignaddr((void *)0, -doff); - vis_pst_8(vis_faligndata(dd4, dd0), dp++, bmask); - vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask); - vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask); - vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask); - } - } - - if ((mlib_addr) dp <= (mlib_addr) dend) { - LOAD_INSERT_U8_34R; - vis_alignaddr((void *)0, -doff); - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd4, dd0), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask); - } - } - } - } - } -} - -/***************************************************************/ - -void -mlib_v_ImageChannelInsert_U8_34R(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize) -{ - mlib_u8 *sa, *da; - mlib_u8 *sl, *dl; - int j; - - sa = sl = src; - da = dl = dst; - -#pragma pipeloop(0) - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelInsert_U8_34R_D1(sa, da, xsize); - sa = sl += slb; - da = dl += dlb; - } -} - -/***************************************************************/ -#define INSERT_S16_34R \ - vis_alignaddr((void *)0, 6); \ - dd0 = vis_faligndata(sd0, sd0); /* b1b0g0r0 */ \ - vis_alignaddr((void *)0, 4); \ - dd1 = vis_faligndata(sd0, sd1); /* r0b1gbr1 */ \ - vis_alignaddr((void *)0, 2); \ - dd2 = vis_faligndata(sd1, sd2); /* r1b2g2r2 */ \ - dd3 = sd2; /* r2b3g3r3 */ - -/***************************************************************/ -#define LOAD_INSERT_STORE_S16_34R_A8 \ - sd0 = *sp++; /* b0g0r0b1 */ \ - sd1 = *sp++; /* g1r1b2g2 */ \ - sd2 = *sp++; /* r2b3g3r3 */ \ - INSERT_S16_34R \ - vis_pst_16(dd0, dp++, bmask); \ - vis_pst_16(dd1, dp++, bmask); \ - vis_pst_16(dd2, dp++, bmask); \ - vis_pst_16(dd3, dp++, bmask); - -/***************************************************************/ -#define LOAD_INSERT_S16_34R \ - vis_alignaddr((void *)soff, 0); \ - s0 = s3; \ - s1 = sp[1]; \ - s2 = sp[2]; \ - s3 = sp[3]; \ - sd0 = vis_faligndata(s0, s1); \ - sd1 = vis_faligndata(s1, s2); \ - sd2 = vis_faligndata(s2, s3); \ - sp += 3; \ - dd4 = dd3; \ - INSERT_S16_34R - -/***************************************************************/ -/* - * both source and destination image data are 1-d vectors and - * 8-byte aligned. dsize is multiple of 4. - */ - -void -mlib_v_ImageChannelInsert_S16_34R_A8D1X4(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize) -{ - mlib_d64 *sp, *dp; /* 8-byte aligned pointer for pixel */ - mlib_d64 sd0, sd1, sd2; /* source data */ - mlib_d64 dd0, dd1, dd2, dd3; /* dst data */ - int bmask = 0x07; /* channel mask */ - int i; - - sp = (mlib_d64 *)src; - dp = (mlib_d64 *)dst; - - /* set GSR.offset for vis_faligndata() */ - /* vis_alignaddr((void *)0, 2); */ /* only for _old */ - -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - LOAD_INSERT_STORE_S16_34R_A8; - } -} - -/***************************************************************/ -/* - * either source or destination image data are not 1-d vectors, but - * they are 8-byte aligned. xsize is multiple of 4. - */ - -void -mlib_v_ImageChannelInsert_S16_34R_A8D2X4(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize) -{ - mlib_d64 *sp, *dp; /* 8-byte aligned pointer for pixel */ - mlib_d64 *sl, *dl; /* 8-byte aligned pointer for line */ - mlib_d64 sd0, sd1, sd2; /* source data */ - mlib_d64 dd0, dd1, dd2, dd3; /* dst data */ - int bmask = 0x07; /* channel mask */ - int i, j; /* indices for x, y */ - - sp = sl = (mlib_d64 *)src; - dp = dl = (mlib_d64 *)dst; - - /* row loop */ - for (j = 0; j < ysize; j++) { - /* 4-pixel column loop */ -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - LOAD_INSERT_STORE_S16_34R_A8; - } - sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb); - dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb); - } -} - -/***************************************************************/ -/* - * either source or destination data are not 8-byte aligned. - */ - -void -mlib_v_ImageChannelInsert_S16_34R_D1(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize) -{ - mlib_s16 *sa, *da; /* pointer for pixel */ - mlib_s16 *dend, *dend2; /* end points in dst */ - mlib_d64 *dp; /* 8-byte aligned start points in dst */ - mlib_d64 *sp; /* 8-byte aligned start point in src */ - mlib_d64 s0, s1, s2, s3; /* 8-byte source raw data */ - mlib_d64 sd0, sd1, sd2; /* 8-byte source data */ - mlib_d64 dd0, dd1, dd2, dd3; /* dst data */ - mlib_d64 dd4; /* the last datum of the last step */ - int soff; /* offset of address in src */ - int doff; /* offset of address in dst */ - int emask; /* edge mask */ - int bmask; /* channel mask */ - int i, n; - - sa = src; - da = dst; - - /* prepare the source address */ - sp = (mlib_d64 *) ((mlib_addr) sa & (~7)); - soff = ((mlib_addr) sa & 7); - - /* prepare the destination addresses */ - dp = (mlib_d64 *)((mlib_addr) da & (~7)); - dend = da + dsize * 4 - 1; - dend2 = dend - 15; - doff = ((mlib_addr) da & 7); - - /* set channel mask for vis_pst_16 to store the words needed */ - bmask = 0xff & (0x77 >> (doff / 2)); - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - /* load 24 byte, convert, store 32 bytes */ - s3 = sp[0]; /* initial value */ - LOAD_INSERT_S16_34R; - - if (doff == 0) { /* dst is 8-byte aligned */ - - if (dsize >= 4 ) { - vis_pst_16(dd0, dp++, emask & bmask); - vis_pst_16(dd1, dp++, bmask); - vis_pst_16(dd2, dp++, bmask); - vis_pst_16(dd3, dp++, bmask); - } - else { /* for very small size */ - vis_pst_16(dd0, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(dd1, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(dd2, dp++, emask & bmask); - } - } - } - - /* no edge handling is needed in the loop */ - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1; -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - LOAD_INSERT_S16_34R; - vis_pst_16(dd0, dp++, bmask); - vis_pst_16(dd1, dp++, bmask); - vis_pst_16(dd2, dp++, bmask); - vis_pst_16(dd3, dp++, bmask); - } - } - - if ((mlib_addr) dp <= (mlib_addr) dend) { - LOAD_INSERT_S16_34R; - emask = vis_edge16(dp, dend); - vis_pst_16(dd0, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(dd1, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(dd2, dp++, emask & bmask); - } - } - } - } - else { /* (doff != 0) */ - vis_alignaddr((void *)0, -doff); - - if (dsize >= 4 ) { - vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask); - vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask); - vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask); - } - else { /* for very small size */ - vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask); - } - } - } - } - - /* no edge handling is needed in the loop */ - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1; -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - LOAD_INSERT_S16_34R; - vis_alignaddr((void *)0, -doff); - vis_pst_16(vis_faligndata(dd4, dd0), dp++, bmask); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask); - vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask); - vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask); - } - } - - if ((mlib_addr) dp <= (mlib_addr) dend) { - LOAD_INSERT_S16_34R; - vis_alignaddr((void *)0, -doff); - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd4, dd0), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask); - } - } - } - } - } -} - -/***************************************************************/ - -void -mlib_v_ImageChannelInsert_S16_34R(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize) -{ - mlib_s16 *sa, *da; - mlib_s16 *sl, *dl; - int j; - - sa = sl = src; - da = dl = dst; - -#pragma pipeloop(0) - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelInsert_S16_34R_D1(sa, da, xsize); - sa = sl = (mlib_s16 *)((mlib_u8 *)sl + slb); - da = dl = (mlib_s16 *)((mlib_u8 *)dl + dlb); - } -} - -/***************************************************************/ -#define INSERT_U8_34L \ - sda = vis_fpmerge(vis_read_hi(sd0), vis_read_lo(sd1)); \ - sdb = vis_fpmerge(vis_read_lo(sd0), vis_read_hi(sd2)); \ - sdc = vis_fpmerge(vis_read_hi(sd1), vis_read_lo(sd2)); \ - sdd = vis_fpmerge(vis_read_hi(sda), vis_read_lo(sdb)); \ - sde = vis_fpmerge(vis_read_lo(sda), vis_read_hi(sdc)); \ - sdf = vis_fpmerge(vis_read_hi(sdb), vis_read_lo(sdc)); \ - sdg = vis_fpmerge(vis_read_hi(sdd), vis_read_lo(sde)); \ - sdh = vis_fpmerge(vis_read_lo(sdd), vis_read_hi(sdf)); \ - sdi = vis_fpmerge(vis_read_hi(sde), vis_read_lo(sdf)); \ - sdj = vis_fpmerge(vis_read_hi(sdg), vis_read_hi(sdi)); \ - sdk = vis_fpmerge(vis_read_lo(sdg), vis_read_lo(sdi)); \ - sdl = vis_fpmerge(vis_read_hi(sdh), vis_read_hi(sdh)); \ - sdm = vis_fpmerge(vis_read_lo(sdh), vis_read_lo(sdh)); \ - dd0 = vis_fpmerge(vis_read_hi(sdj), vis_read_hi(sdl)); \ - dd1 = vis_fpmerge(vis_read_lo(sdj), vis_read_lo(sdl)); \ - dd2 = vis_fpmerge(vis_read_hi(sdk), vis_read_hi(sdm)); \ - dd3 = vis_fpmerge(vis_read_lo(sdk), vis_read_lo(sdm)); - -/***************************************************************/ -#define LOAD_INSERT_STORE_U8_34L_A8 \ - sd0 = *sp++; /* b0g0r0b1g1r1b2g2 */ \ - sd1 = *sp++; /* r2b3g3r3b4g4r4b5 */ \ - sd2 = *sp++; /* g5r5b6g6r6b7g7r7 */ \ - INSERT_U8_34L \ - vis_pst_8(dd0, dp++, bmask); \ - vis_pst_8(dd1, dp++, bmask); \ - vis_pst_8(dd2, dp++, bmask); \ - vis_pst_8(dd3, dp++, bmask); - -/***************************************************************/ -#define LOAD_INSERT_U8_34L \ - vis_alignaddr((void *)soff, 0); \ - s0 = s3; \ - s1 = sp[1]; \ - s2 = sp[2]; \ - s3 = sp[3]; \ - sd0 = vis_faligndata(s0, s1); \ - sd1 = vis_faligndata(s1, s2); \ - sd2 = vis_faligndata(s2, s3); \ - sp += 3; \ - dd4 = dd3; \ - INSERT_U8_34L - -/***************************************************************/ -/* - * Both source and destination image data are 1-d vectors and - * 8-byte aligned. And dsize is multiple of 8. - */ -void -mlib_v_ImageChannelInsert_U8_34L_A8D1X8(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize) -{ - mlib_d64 *sp, *dp; - mlib_d64 sd0, sd1, sd2; /* source data */ - mlib_d64 dd0, dd1, dd2, dd3; /* dst data */ - mlib_d64 sda, sdb, sdc, sdd; /* intermediate variables */ - mlib_d64 sde, sdf, sdg, sdh; - mlib_d64 sdi, sdj, sdk, sdl; - mlib_d64 sdm; - int bmask = 0xee; - int i; - - sp = (mlib_d64 *)src; - dp = (mlib_d64 *)dst; - -#pragma pipeloop(0) - for (i = 0; i < dsize / 8; i++) { - LOAD_INSERT_STORE_U8_34L_A8; - } -} - -/***************************************************************/ -/* - * Either source or destination image data are not 1-d vectors, but - * they are 8-byte aligned. And slb and dlb are multiple of 8. - * The xsize is multiple of 8. - */ -void -mlib_v_ImageChannelInsert_U8_34L_A8D2X8(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize) -{ - mlib_d64 *sp, *dp; /* 8-byte aligned pointer for pixel */ - mlib_d64 *sl, *dl; /* 8-byte aligned pointer for line */ - mlib_d64 sd0, sd1, sd2; /* source data */ - mlib_d64 dd0, dd1, dd2, dd3; /* dst data */ - mlib_d64 sda, sdb, sdc, sdd; /* intermediate variables */ - mlib_d64 sde, sdf, sdg, sdh; - mlib_d64 sdi, sdj, sdk, sdl; - mlib_d64 sdm; - int bmask = 0xee; - int i, j; /* indices for x, y */ - - sp = sl = (mlib_d64 *)src; - dp = dl = (mlib_d64 *)dst; - - /* row loop */ - for (j = 0; j < ysize; j++) { - /* 8-byte column loop */ -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - LOAD_INSERT_STORE_U8_34L_A8; - } - sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb); - dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb); - } -} - -/***************************************************************/ -/* - * either source or destination data are not 8-byte aligned. - */ -void -mlib_v_ImageChannelInsert_U8_34L_D1(mlib_u8 *src, - mlib_u8 *dst, - mlib_s32 dsize) -{ - mlib_u8 *sa, *da; - mlib_u8 *dend, *dend2; /* end points in dst */ - mlib_d64 *dp; /* 8-byte aligned start points in dst */ - mlib_d64 *sp; /* 8-byte aligned start point in src */ - mlib_d64 s0, s1, s2, s3; /* 8-byte source raw data */ - mlib_d64 sd0, sd1, sd2; /* 8-byte source data */ - mlib_d64 dd0, dd1, dd2, dd3; /* dst data */ - mlib_d64 dd4; /* the last datum of the last step */ - mlib_d64 sda, sdb, sdc, sdd; /* intermediate variables */ - mlib_d64 sde, sdf, sdg, sdh; - mlib_d64 sdi, sdj, sdk, sdl; - mlib_d64 sdm; - int soff; /* offset of address in src */ - int doff; /* offset of address in dst */ - int emask; /* edge mask */ - int bmask; /* channel mask */ - int i, n; - - sa = src; - da = dst; - - /* prepare the source address */ - sp = (mlib_d64 *) ((mlib_addr) sa & (~7)); - soff = ((mlib_addr) sa & 7); - - /* prepare the destination addresses */ - dp = (mlib_d64 *)((mlib_addr) da & (~7)); - dend = da + dsize * 4 - 1; - dend2 = dend - 31; - doff = ((mlib_addr) da & 7); - - /* set band mask for vis_pst_8 to store the bytes needed */ - bmask = 0xff & (0xeeee >> doff) ; - - /* generate edge mask for the start point */ - emask = vis_edge8(da, dend); - - /* load 24 bytes, convert to 32 bytes */ - s3 = sp[0]; /* initial value */ - LOAD_INSERT_U8_34L; - - if (doff == 0) { /* dst is 8-byte aligned */ - - if (dsize >= 8 ) { - vis_pst_8(dd0, dp++, emask & bmask); - vis_pst_8(dd1, dp++, bmask); - vis_pst_8(dd2, dp++, bmask); - vis_pst_8(dd3, dp++, bmask); - } - else { /* for very small size */ - vis_pst_8(dd0, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd1, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd2, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd3, dp++, emask & bmask); - } - } - } - } - - /* no edge handling is needed in the loop */ - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1; -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - LOAD_INSERT_U8_34L; - vis_pst_8(dd0, dp++, bmask); - vis_pst_8(dd1, dp++, bmask); - vis_pst_8(dd2, dp++, bmask); - vis_pst_8(dd3, dp++, bmask); - } - } - - if ((mlib_addr) dp <= (mlib_addr) dend) { - LOAD_INSERT_U8_34L; - emask = vis_edge8(dp, dend); - vis_pst_8(dd0, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd1, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd2, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(dd3, dp++, emask & bmask); - } - } - } - } - } - else { /* (doff != 0) */ - vis_alignaddr((void *)0, -doff); - - if (dsize >= 8 ) { - vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask); - vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask); - vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask); - vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask); - } - else { /* for very small size */ - vis_pst_8(vis_faligndata(dd0, dd0), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd3, dd3), dp++, emask & bmask); - } - } - } - } - } - - /* no edge handling is needed in the loop */ - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1; -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - LOAD_INSERT_U8_34L; - vis_alignaddr((void *)0, -doff); - vis_pst_8(vis_faligndata(dd4, dd0), dp++, bmask); - vis_pst_8(vis_faligndata(dd0, dd1), dp++, bmask); - vis_pst_8(vis_faligndata(dd1, dd2), dp++, bmask); - vis_pst_8(vis_faligndata(dd2, dd3), dp++, bmask); - } - } - - if ((mlib_addr) dp <= (mlib_addr) dend) { - LOAD_INSERT_U8_34L; - vis_alignaddr((void *)0, -doff); - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd4, dd0), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd0, dd1), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd1, dd2), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge8(dp, dend); - vis_pst_8(vis_faligndata(dd2, dd3), dp++, emask & bmask); - } - } - } - } - } -} - -/***************************************************************/ -void -mlib_v_ImageChannelInsert_U8_34L(mlib_u8 *src, mlib_s32 slb, - mlib_u8 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize) -{ - mlib_u8 *sa, *da; - mlib_u8 *sl, *dl; - int j; - - sa = sl = src; - da = dl = dst; - -#pragma pipeloop(0) - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelInsert_U8_34L_D1(sa, da, xsize); - sa = sl += slb; - da = dl += dlb; - } -} - -/***************************************************************/ -#define INSERT_S16_34L \ - dd0 = sd0; /* b0g0r0b1 */ \ - vis_alignaddr((void *)0, 6); \ - dd1 = vis_faligndata(sd0, sd1); /* b1gbr1b2 */ \ - vis_alignaddr((void *)0, 4); \ - dd2 = vis_faligndata(sd1, sd2); /* b2g2r2b3 */ \ - vis_alignaddr((void *)0, 2); \ - dd3 = vis_faligndata(sd2, sd2); /* b3g3r3r2 */ - -/***************************************************************/ -#define LOAD_INSERT_STORE_S16_34L_A8 \ - sd0 = *sp++; /* b0g0r0b1 */ \ - sd1 = *sp++; /* g1r1b2g2 */ \ - sd2 = *sp++; /* r2b3g3r3 */ \ - INSERT_S16_34L \ - vis_pst_16(dd0, dp++, bmask); \ - vis_pst_16(dd1, dp++, bmask); \ - vis_pst_16(dd2, dp++, bmask); \ - vis_pst_16(dd3, dp++, bmask); - -/***************************************************************/ -#define LOAD_INSERT_S16_34L \ - vis_alignaddr((void *)soff, 0); \ - s0 = s3; \ - s1 = sp[1]; \ - s2 = sp[2]; \ - s3 = sp[3]; \ - sd0 = vis_faligndata(s0, s1); \ - sd1 = vis_faligndata(s1, s2); \ - sd2 = vis_faligndata(s2, s3); \ - sp += 3; \ - dd4 = dd3; \ - INSERT_S16_34L - -/***************************************************************/ -/* - * both source and destination image data are 1-d vectors and - * 8-byte aligned. dsize is multiple of 4. - */ - -void -mlib_v_ImageChannelInsert_S16_34L_A8D1X4(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize) -{ - mlib_d64 *sp, *dp; /* 8-byte aligned pointer for pixel */ - mlib_d64 sd0, sd1, sd2; /* source data */ - mlib_d64 dd0, dd1, dd2, dd3; /* dst data */ - int bmask = 0x0e; /* channel mask */ - int i; - - sp = (mlib_d64 *)src; - dp = (mlib_d64 *)dst; - -#pragma pipeloop(0) - for (i = 0; i < dsize / 4; i++) { - LOAD_INSERT_STORE_S16_34L_A8; - } -} - -/***************************************************************/ -/* - * either source or destination image data are not 1-d vectors, but - * they are 8-byte aligned. xsize is multiple of 4. - */ - -void -mlib_v_ImageChannelInsert_S16_34L_A8D2X4(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize) -{ - mlib_d64 *sp, *dp; /* 8-byte aligned pointer for pixel */ - mlib_d64 *sl, *dl; /* 8-byte aligned pointer for line */ - mlib_d64 sd0, sd1, sd2; /* source data */ - mlib_d64 dd0, dd1, dd2, dd3; /* dst data */ - int bmask = 0x0e; /* channel mask */ - int i, j; /* indices for x, y */ - - sp = sl = (mlib_d64 *)src; - dp = dl = (mlib_d64 *)dst; - - /* row loop */ - for (j = 0; j < ysize; j++) { - /* 4-pixel column loop */ -#pragma pipeloop(0) - for (i = 0; i < xsize / 4; i++) { - LOAD_INSERT_STORE_S16_34L_A8; - } - sp = sl = (mlib_d64 *)((mlib_u8 *)sl + slb); - dp = dl = (mlib_d64 *)((mlib_u8 *)dl + dlb); - } -} - -/***************************************************************/ -/* - * either source or destination data are not 8-byte aligned. - */ - -void -mlib_v_ImageChannelInsert_S16_34L_D1(mlib_s16 *src, - mlib_s16 *dst, - mlib_s32 dsize) -{ - mlib_s16 *sa, *da; /* pointer for pixel */ - mlib_s16 *dend, *dend2; /* end points in dst */ - mlib_d64 *dp; /* 8-byte aligned start points in dst */ - mlib_d64 *sp; /* 8-byte aligned start point in src */ - mlib_d64 s0, s1, s2, s3; /* 8-byte source raw data */ - mlib_d64 sd0, sd1, sd2; /* 8-byte source data */ - mlib_d64 dd0, dd1, dd2, dd3; /* dst data */ - mlib_d64 dd4; /* the last datum of the last step */ - int soff; /* offset of address in src */ - int doff; /* offset of address in dst */ - int emask; /* edge mask */ - int bmask; /* channel mask */ - int i, n; - - sa = src; - da = dst; - - /* prepare the source address */ - sp = (mlib_d64 *) ((mlib_addr) sa & (~7)); - soff = ((mlib_addr) sa & 7); - - /* prepare the destination addresses */ - dp = (mlib_d64 *)((mlib_addr) da & (~7)); - dend = da + dsize * 4 - 1; - dend2 = dend - 15; - doff = ((mlib_addr) da & 7); - - /* set channel mask for vis_pst_16 to store the words needed */ - bmask = 0xff & (0xee >> (doff / 2)); - - /* generate edge mask for the start point */ - emask = vis_edge16(da, dend); - - /* load 24 byte, convert, store 32 bytes */ - s3 = sp[0]; /* initial value */ - LOAD_INSERT_S16_34L; - - if (doff == 0) { /* dst is 8-byte aligned */ - - if (dsize >= 4 ) { - vis_pst_16(dd0, dp++, emask & bmask); - vis_pst_16(dd1, dp++, bmask); - vis_pst_16(dd2, dp++, bmask); - vis_pst_16(dd3, dp++, bmask); - } - else { /* for very small size */ - vis_pst_16(dd0, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(dd1, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(dd2, dp++, emask & bmask); - } - } - } - - /* no edge handling is needed in the loop */ - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1; -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - LOAD_INSERT_S16_34L; - vis_pst_16(dd0, dp++, bmask); - vis_pst_16(dd1, dp++, bmask); - vis_pst_16(dd2, dp++, bmask); - vis_pst_16(dd3, dp++, bmask); - } - } - - if ((mlib_addr) dp <= (mlib_addr) dend) { - LOAD_INSERT_S16_34L; - emask = vis_edge16(dp, dend); - vis_pst_16(dd0, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(dd1, dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(dd2, dp++, emask & bmask); - } - } - } - } - else { /* (doff != 0) */ - vis_alignaddr((void *)0, -doff); - - if (dsize >= 4 ) { - vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask); - vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask); - vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask); - } - else { /* for very small size */ - vis_pst_16(vis_faligndata(dd0, dd0), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask); - } - } - } - } - - /* no edge handling is needed in the loop */ - if ((mlib_addr) dp <= (mlib_addr) dend2) { - n = ((mlib_u8 *)dend2 - (mlib_u8 *)dp) / 32 + 1; -#pragma pipeloop(0) - for (i = 0; i < n; i++) { - LOAD_INSERT_S16_34L; - vis_alignaddr((void *)0, -doff); - vis_pst_16(vis_faligndata(dd4, dd0), dp++, bmask); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, bmask); - vis_pst_16(vis_faligndata(dd1, dd2), dp++, bmask); - vis_pst_16(vis_faligndata(dd2, dd3), dp++, bmask); - } - } - - if ((mlib_addr) dp <= (mlib_addr) dend) { - LOAD_INSERT_S16_34L; - vis_alignaddr((void *)0, -doff); - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd4, dd0), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd0, dd1), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd1, dd2), dp++, emask & bmask); - if ((mlib_addr) dp <= (mlib_addr) dend) { - emask = vis_edge16(dp, dend); - vis_pst_16(vis_faligndata(dd2, dd3), dp++, emask & bmask); - } - } - } - } - } -} - -/***************************************************************/ - -void -mlib_v_ImageChannelInsert_S16_34L(mlib_s16 *src, mlib_s32 slb, - mlib_s16 *dst, mlib_s32 dlb, - mlib_s32 xsize, mlib_s32 ysize) -{ - mlib_s16 *sa, *da; - mlib_s16 *sl, *dl; - int j; - - sa = sl = src; - da = dl = dst; - -#pragma pipeloop(0) - for (j = 0; j < ysize; j++) { - mlib_v_ImageChannelInsert_S16_34L_D1(sa, da, xsize); - sa = sl = (mlib_s16 *)((mlib_u8 *)sl + slb); - da = dl = (mlib_s16 *)((mlib_u8 *)dl + dlb); - } -} - -/***************************************************************/ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv.h b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv.h index ea66f6798da..92a5890c5ab 100644 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv.h +++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv.h @@ -34,18 +34,6 @@ extern "C" { #if defined ( VIS ) && VIS == 0x200 -mlib_status mlib_conv2x2_8nw_f(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - -mlib_status mlib_conv3x3_8nw_f(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale, - mlib_s32 cmask); - mlib_status mlib_convMxN_8nw_f(mlib_image *dst, const mlib_image *src, mlib_s32 m, @@ -58,16 +46,6 @@ mlib_status mlib_convMxN_8nw_f(mlib_image *dst, #else -mlib_status mlib_conv2x2_8nw_f(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale); - -mlib_status mlib_conv3x3_8nw_f(mlib_image *dst, - const mlib_image *src, - const mlib_s32 *kern, - mlib_s32 scale); - mlib_status mlib_convMxN_8nw_f(mlib_image *dst, const mlib_image *src, mlib_s32 m, diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_16nw.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_16nw.c deleted file mode 100644 index 4127185b9e7..00000000000 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_16nw.c +++ /dev/null @@ -1,1673 +0,0 @@ -/* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - - -/* - * FUNCTION - * Internal functions for mlib_ImageConv* on U8 type - * and MLIB_EDGE_DST_NO_WRITE mask - * - */ - -/***************************************************************/ - -#include -#include -#include -#include - -/* - This defines switches between functions in - files: mlib_v_ImageConv_8nw.c, - mlib_v_ImageConvIndex3_8_16nw.c, - mlib_v_ImageConvIndex4_8_16nw.c, - mlib_v_ImageConvIndex3_8_16nw.c, - mlib_v_ImageConvIndex4_8_16nw.c -*/ - -#define CONV_INDEX - -#define DTYPE mlib_s16 -#define LTYPE mlib_u8 - -/***************************************************************/ - -#ifdef CONV_INDEX - -#define CONV_FUNC(KERN) \ - mlib_conv##KERN##_Index3_8_16nw(mlib_image *dst, \ - mlib_image *src, \ - mlib_s32 *kern, \ - mlib_s32 scale, \ - void *colormap) - -#else - -#define CONV_FUNC(KERN) \ - mlib_conv##KERN##_8nw_f(mlib_image *dst, \ - mlib_image *src, \ - mlib_s32 *kern, \ - mlib_s32 scale) - -#endif - -/***************************************************************/ - -#ifdef CONV_INDEX - -#define NCHAN 3 - -#else - -#define NCHAN nchan - -#endif - -/***************************************************************/ - -#define DEF_VARS \ - DTYPE *sl, *sp, *dl; \ - mlib_s32 hgt = mlib_ImageGetHeight(src); \ - mlib_s32 wid = mlib_ImageGetWidth(src); \ - mlib_s32 sll = mlib_ImageGetStride(src) / sizeof(DTYPE); \ - mlib_s32 dll = mlib_ImageGetStride(dst) / sizeof(DTYPE); \ - DTYPE *adr_src = (DTYPE *)mlib_ImageGetData(src); \ - DTYPE *adr_dst = (DTYPE *)mlib_ImageGetData(dst); \ - mlib_s32 ssize, xsize, dsize, esize, emask, buff_ind = 0; \ - mlib_d64 *pbuff, *dp; \ - mlib_f32 *karr = (mlib_f32 *)kern; \ - mlib_s32 gsr_scale = (31 - scale) << 3; \ - mlib_d64 drnd = vis_to_double_dup(mlib_round_8[31 - scale]); \ - mlib_s32 i, j, l - -/***************************************************************/ - -#ifdef CONV_INDEX - -#define DEF_EXTRA_VARS \ - int offset = mlib_ImageGetLutOffset(colormap); \ - LTYPE **lut_table = (LTYPE**)mlib_ImageGetLutData(colormap); \ - LTYPE *ltbl0 = lut_table[0] - offset; \ - LTYPE *ltbl1 = lut_table[1] - offset; \ - LTYPE *ltbl2 = lut_table[2] - offset; \ - LTYPE *ltbl3 = (NCHAN > 3) ? lut_table[3] - offset : ltbl2 - -#else - -#define DEF_EXTRA_VARS \ - mlib_s32 nchan = mlib_ImageGetChannels(dst) - -#endif - -/***************************************************************/ - -#if NCHAN == 3 - -#define LOAD_SRC() { \ - mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3]; \ - mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7]; \ - mlib_d64 t0, t1, t2; \ - \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s7), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s7), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s7), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s6), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s6), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s6), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0); \ - \ - buffn[i] = t0; \ - buffn[i + 1] = t1; \ - buffn[i + 2] = t2; \ - \ - sp += 8; \ - } - -#else - -#define LOAD_SRC() { \ - mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3]; \ - mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7]; \ - mlib_d64 t0, t1, t2; \ - \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s4), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t2); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s2), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t1); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0); \ - \ - buffn[i] = t0; \ - buffn[i + 1] = t1; \ - buffn[i + 2] = t2; \ - \ - sp += 6; \ - } - -#endif - -/***************************************************************/ - -static mlib_s32 mlib_round_8[16] = { 0x00400040, 0x00200020, 0x00100010, 0x00080008, - 0x00040004, 0x00020002, 0x00010001, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000 }; - -/***************************************************************/ - -void mlib_ImageCopy_na(mlib_u8 *sa, mlib_u8 *da, int size); - -/***************************************************************/ - -#define KSIZE 2 - -mlib_status CONV_FUNC(2x2) -{ - mlib_d64 *buffs[2*(KSIZE + 1)]; - mlib_d64 *buff0, *buff1, *buffn, *buffd, *buffe; - mlib_d64 s00, s01, s10, s11, s0, s1; - mlib_d64 d0, d1, d00, d01, d10, d11; - DEF_VARS; - DEF_EXTRA_VARS; - - sl = adr_src; - dl = adr_dst; - - ssize = NCHAN*wid; - dsize = (ssize + 7)/8; - esize = dsize + 4; - pbuff = mlib_malloc((KSIZE + 4)*esize*sizeof(mlib_d64)); - if (pbuff == NULL) return MLIB_FAILURE; - - for (i = 0; i < (KSIZE + 1); i++) buffs[i] = pbuff + i*esize; - for (i = 0; i < (KSIZE + 1); i++) buffs[(KSIZE + 1) + i] = buffs[i]; - buffd = buffs[KSIZE] + esize; - buffe = buffd + 2*esize; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - xsize = ssize - NCHAN*(KSIZE - 1); - emask = (0xFF00 >> (xsize & 7)) & 0xFF; - - vis_write_gsr(gsr_scale + 7); - - for (l = 0; l < KSIZE; l++) { - mlib_d64 *buffn = buffs[l]; - sp = sl + l*sll; - -#ifndef CONV_INDEX - if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize); - -#else -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - LOAD_SRC(); - } -#endif /* CONV_INDEX */ - } - - for (j = 0; j < hgt; j++) { - mlib_d64 **buffc = buffs + buff_ind; - mlib_f32 *pk = karr, k0, k1; - sp = sl + KSIZE*sll; - - buff0 = buffc[0]; - buff1 = buffc[1]; - buffn = buffc[KSIZE]; - -#ifndef CONV_INDEX - if ((((mlib_addr)(sl )) & 7) == 0) buff0 = (mlib_d64*)sl; - if ((((mlib_addr)(sl + sll)) & 7) == 0) buff1 = (mlib_d64*)(sl + sll); - if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize); -#endif - - k0 = pk[1]; - k1 = pk[3]; - vis_write_gsr(gsr_scale + NCHAN); - - s01 = buff0[0]; - s11 = buff1[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - s00 = s01; - s10 = s11; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = vis_fpadd16(d00, d10); - d1 = vis_fpadd16(d01, d11); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - k0 = pk[0]; - k1 = pk[2]; -#ifndef CONV_INDEX - dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl; - -#pragma pipeloop(0) - for (i = 0; i < xsize/8; i++) { - s0 = buff0[i]; - s1 = buff1[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d0, drnd); - d0 = vis_fpadd16(d0, d00); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d1, drnd); - d1 = vis_fpadd16(d1, d01); - dp[i] = vis_fpack16_pair(d0, d1); - } - - if (emask) { - s0 = buff0[i]; - s1 = buff1[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d0, drnd); - d0 = vis_fpadd16(d0, d00); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d1, drnd); - d1 = vis_fpadd16(d1, d01); - - d0 = vis_fpack16_pair(d0, d1); - vis_pst_8(d0, dp + i, emask); - } - - if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize); - -#else - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - mlib_d64 s10 = buff1[i]; - mlib_d64 s11 = buff1[i + 1]; - mlib_d64 s12 = buff1[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - d10 = vis_fmul8x16au(vis_read_hi(s10), k1); - d11 = vis_fmul8x16au(vis_read_lo(s10), k1); - d12 = vis_fmul8x16au(vis_read_hi(s11), k1); - d13 = vis_fmul8x16au(vis_read_lo(s11), k1); - d14 = vis_fmul8x16au(vis_read_hi(s12), k1); - d15 = vis_fmul8x16au(vis_read_lo(s12), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d2 = buffd[2*i + 2]; - d3 = buffd[2*i + 3]; - d4 = buffd[2*i + 4]; - d5 = buffd[2*i + 5]; - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d0, drnd); - d0 = vis_fpadd16(d0, d00); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d1, drnd); - d1 = vis_fpadd16(d1, d01); - d02 = vis_fpadd16(d02, d12); - d2 = vis_fpadd16(d2, drnd); - d2 = vis_fpadd16(d2, d02); - d03 = vis_fpadd16(d03, d13); - d3 = vis_fpadd16(d3, drnd); - d3 = vis_fpadd16(d3, d03); - d04 = vis_fpadd16(d04, d14); - d4 = vis_fpadd16(d4, drnd); - d4 = vis_fpadd16(d4, d04); - d05 = vis_fpadd16(d05, d15); - d5 = vis_fpadd16(d5, drnd); - d5 = vis_fpadd16(d5, d05); - - buffe[i ] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - LOAD_SRC(); - } - - mlib_ImageColorTrue2IndexLine_U8_S16_3((void*)buffe, dl, wid, colormap); -#endif /* CONV_INDEX */ - - sl += sll; - dl += dll; - - buff_ind++; - if (buff_ind >= (KSIZE + 1)) buff_ind = 0; - } - - mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ - -#undef KSIZE -#define KSIZE 3 - -mlib_status CONV_FUNC(3x3) -{ - mlib_d64 *buffs[2*(KSIZE + 1)]; - mlib_d64 *buff0, *buff1, *buff2, *buffn, *buffd, *buffe; - mlib_d64 s00, s01, s10, s11, s20, s21, s0, s1, s2; - mlib_d64 dd, d0, d1, d00, d01, d10, d11, d20, d21; - mlib_s32 ik, ik_last, off, doff; - DEF_VARS; - DEF_EXTRA_VARS; - - sl = adr_src; -#ifdef CONV_INDEX - dl = adr_dst + ((KSIZE - 1)/2)*(dll + 1); -#else - dl = adr_dst + ((KSIZE - 1)/2)*(dll + NCHAN); -#endif - - ssize = NCHAN*wid; - dsize = (ssize + 7)/8; - esize = dsize + 4; - pbuff = mlib_malloc((KSIZE + 4)*esize*sizeof(mlib_d64)); - if (pbuff == NULL) return MLIB_FAILURE; - - for (i = 0; i < (KSIZE + 1); i++) buffs[i] = pbuff + i*esize; - for (i = 0; i < (KSIZE + 1); i++) buffs[(KSIZE + 1) + i] = buffs[i]; - buffd = buffs[KSIZE] + esize; - buffe = buffd + 2*esize; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - xsize = ssize - NCHAN*(KSIZE - 1); - emask = (0xFF00 >> (xsize & 7)) & 0xFF; - - vis_write_gsr(gsr_scale + 7); - - for (l = 0; l < KSIZE; l++) { - mlib_d64 *buffn = buffs[l]; - sp = sl + l*sll; - -#ifndef CONV_INDEX - if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize); -#else -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - LOAD_SRC(); - } -#endif /* CONV_INDEX */ - } - - /* init buffer */ -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - for (j = 0; j < hgt; j++) { - mlib_d64 **buffc = buffs + buff_ind, *pbuff0, *pbuff1, *pbuff2; - mlib_f32 *pk = karr, k0, k1, k2; - sp = sl + KSIZE*sll; - - pbuff0 = buffc[0]; - pbuff1 = buffc[1]; - pbuff2 = buffc[2]; - buffn = buffc[KSIZE]; - -#ifndef CONV_INDEX - if ((((mlib_addr)(sl )) & 7) == 0) pbuff0 = (mlib_d64*)sl; - if ((((mlib_addr)(sl + sll)) & 7) == 0) pbuff1 = (mlib_d64*)(sl + sll); - if ((((mlib_addr)(sl + 2*sll)) & 7) == 0) pbuff2 = (mlib_d64*)(sl + 2*sll); - - if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize); -#endif - -#ifdef CONV_INDEX - ik_last = 0; -#else - ik_last = (KSIZE - 1); -#endif - - for (ik = 0; ik < KSIZE; ik++) { - k0 = pk[ik]; - k1 = pk[ik + KSIZE]; - k2 = pk[ik + 2*KSIZE]; - - off = ik*NCHAN; - doff = off/8; - off &= 7; - buff0 = pbuff0 + doff; - buff1 = pbuff1 + doff; - buff2 = pbuff2 + doff; - vis_write_gsr(gsr_scale + off); - - if (ik == ik_last) continue; - /*if (!ik_last) { - if ((off & 3) || (ik == (KSIZE - 1))) { - ik_last = ik; - continue; - } - }*/ - - if (off == 0) { -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - s0 = buff0[i]; - s1 = buff1[i]; - s2 = buff2[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d00, d0); - d0 = vis_fpadd16(d10, d0); - d0 = vis_fpadd16(d20, d0); - d1 = vis_fpadd16(d01, d1); - d1 = vis_fpadd16(d11, d1); - d1 = vis_fpadd16(d21, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } else if (off == 4) { - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - - d00 = vis_fmul8x16au(vis_read_lo(s00), k0); - d01 = vis_fmul8x16au(vis_read_hi(s01), k0); - d10 = vis_fmul8x16au(vis_read_lo(s10), k1); - d11 = vis_fmul8x16au(vis_read_hi(s11), k1); - d20 = vis_fmul8x16au(vis_read_lo(s20), k2); - d21 = vis_fmul8x16au(vis_read_hi(s21), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d00, d0); - d0 = vis_fpadd16(d10, d0); - d0 = vis_fpadd16(d20, d0); - d1 = vis_fpadd16(d01, d1); - d1 = vis_fpadd16(d11, d1); - d1 = vis_fpadd16(d21, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } else { - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d00, d0); - d0 = vis_fpadd16(d10, d0); - d0 = vis_fpadd16(d20, d0); - d1 = vis_fpadd16(d01, d1); - d1 = vis_fpadd16(d11, d1); - d1 = vis_fpadd16(d21, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - } - } - - k0 = pk[ik_last]; - k1 = pk[ik_last + KSIZE]; - k2 = pk[ik_last + 2*KSIZE]; - - off = ik_last*NCHAN; - doff = off/8; - off &= 7; - buff0 = pbuff0 + doff; - buff1 = pbuff1 + doff; - buff2 = pbuff2 + doff; - vis_write_gsr(gsr_scale + off); - -#ifndef CONV_INDEX - dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl; - - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < xsize/8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - - dd = vis_fpack16_pair(d0, d1); - dp[i] = dd; - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if (emask) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - - dd = vis_fpack16_pair(d0, d1); - vis_pst_8(dd, dp + i, emask); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize); - -#else - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d20, d21, d22, d23, d24, d25; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - mlib_d64 s10 = buff1[i]; - mlib_d64 s11 = buff1[i + 1]; - mlib_d64 s12 = buff1[i + 2]; - mlib_d64 s20 = buff2[i]; - mlib_d64 s21 = buff2[i + 1]; - mlib_d64 s22 = buff2[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - d10 = vis_fmul8x16au(vis_read_hi(s10), k1); - d11 = vis_fmul8x16au(vis_read_lo(s10), k1); - d12 = vis_fmul8x16au(vis_read_hi(s11), k1); - d13 = vis_fmul8x16au(vis_read_lo(s11), k1); - d14 = vis_fmul8x16au(vis_read_hi(s12), k1); - d15 = vis_fmul8x16au(vis_read_lo(s12), k1); - d20 = vis_fmul8x16au(vis_read_hi(s20), k2); - d21 = vis_fmul8x16au(vis_read_lo(s20), k2); - d22 = vis_fmul8x16au(vis_read_hi(s21), k2); - d23 = vis_fmul8x16au(vis_read_lo(s21), k2); - d24 = vis_fmul8x16au(vis_read_hi(s22), k2); - d25 = vis_fmul8x16au(vis_read_lo(s22), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d2 = buffd[2*i + 2]; - d3 = buffd[2*i + 3]; - d4 = buffd[2*i + 4]; - d5 = buffd[2*i + 5]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - d2 = vis_fpadd16(d2, d02); - d2 = vis_fpadd16(d2, d12); - d2 = vis_fpadd16(d2, d22); - d3 = vis_fpadd16(d3, d03); - d3 = vis_fpadd16(d3, d13); - d3 = vis_fpadd16(d3, d23); - d4 = vis_fpadd16(d4, d04); - d4 = vis_fpadd16(d4, d14); - d4 = vis_fpadd16(d4, d24); - d5 = vis_fpadd16(d5, d05); - d5 = vis_fpadd16(d5, d15); - d5 = vis_fpadd16(d5, d25); - - buffe[i ] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - buffd[2*i + 2] = drnd; - buffd[2*i + 3] = drnd; - buffd[2*i + 4] = drnd; - buffd[2*i + 5] = drnd; - - LOAD_SRC(); - } - - mlib_ImageColorTrue2IndexLine_U8_S16_3((void*)buffe, dl, wid, colormap); -#endif /* CONV_INDEX */ - - sl += sll; - dl += dll; - - buff_ind++; - if (buff_ind >= (KSIZE + 1)) buff_ind = 0; - } - - mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ - -#undef KSIZE -#define MAX_N 11 - -#ifdef CONV_INDEX - -mlib_status mlib_convMxN_Index3_8_16nw(mlib_image *dst, - mlib_image *src, - mlib_s32 m, - mlib_s32 n, - mlib_s32 dm, - mlib_s32 dn, - mlib_s32 *kern, - mlib_s32 scale, - void *colormap) - -#else - -mlib_status mlib_convMxN_8nw_f(mlib_image *dst, - mlib_image *src, - mlib_s32 m, - mlib_s32 n, - mlib_s32 dm, - mlib_s32 dn, - mlib_s32 *kern, - mlib_s32 scale) - -#endif -{ - mlib_d64 *buffs_local[3*(MAX_N + 1)], **buffs = buffs_local, **buff; - mlib_d64 *buff0, *buff1, *buff2, *buff3, *buffn, *buffd, *buffe; - mlib_d64 s00, s01, s10, s11, s20, s21, s30, s31, s0, s1, s2, s3; - mlib_d64 d00, d01, d10, d11, d20, d21, d30, d31; - mlib_d64 dd, d0, d1; - mlib_s32 ik, jk, ik_last, jk_size, coff, off, doff; - DEF_VARS; - DEF_EXTRA_VARS; - - if (n > MAX_N) { - buffs = mlib_malloc(3*(n + 1)*sizeof(mlib_d64*)); - if (buffs == NULL) return MLIB_FAILURE; - } - - buff = buffs + 2*(n + 1); - - sl = adr_src; -#ifdef CONV_INDEX - dl = adr_dst + dn*dll + dm; -#else - dl = adr_dst + dn*dll + dm*NCHAN; -#endif - - ssize = NCHAN*wid; - dsize = (ssize + 7)/8; - esize = dsize + 4; - pbuff = mlib_malloc((n + 4)*esize*sizeof(mlib_d64)); - if (pbuff == NULL) { - if (buffs != buffs_local) mlib_free(buffs); - return MLIB_FAILURE; - } - - for (i = 0; i < (n + 1); i++) buffs[i] = pbuff + i*esize; - for (i = 0; i < (n + 1); i++) buffs[(n + 1) + i] = buffs[i]; - buffd = buffs[n] + esize; - buffe = buffd + 2*esize; - - wid -= (m - 1); - hgt -= (n - 1); - xsize = ssize - NCHAN*(m - 1); - emask = (0xFF00 >> (xsize & 7)) & 0xFF; - - vis_write_gsr(gsr_scale + 7); - - for (l = 0; l < n; l++) { - mlib_d64 *buffn = buffs[l]; - sp = sl + l*sll; - -#ifndef CONV_INDEX - if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize); -#else -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - LOAD_SRC(); - } -#endif /* CONV_INDEX */ - } - - /* init buffer */ -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - for (j = 0; j < hgt; j++) { - mlib_d64 **buffc = buffs + buff_ind; - mlib_f32 *pk = karr, k0, k1, k2, k3; - sp = sl + n*sll; - - for (l = 0; l < n; l++) { - buff[l] = buffc[l]; - } - buffn = buffc[n]; - -#ifndef CONV_INDEX - for (l = 0; l < n; l++) { - if ((((mlib_addr)(sl + l*sll)) & 7) == 0) buff[l] = (mlib_d64*)(sl + l*sll); - } - if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize); -#endif - -#ifdef CONV_INDEX - ik_last = 0; -#else - ik_last = (m - 1); -#endif - - for (jk = 0; jk < n; jk += jk_size) { - jk_size = n - jk; -#ifdef CONV_INDEX - if (jk_size >= 5) jk_size = 3; - if (jk_size == 4) jk_size = 2; -#else - if (jk_size >= 6) jk_size = 4; - if (jk_size == 5) jk_size = 3; -#endif - coff = 0; - - if (jk_size == 2) { - - for (ik = 0; ik < m; ik++, coff += NCHAN) { - if (!jk && ik == ik_last) continue; - - k0 = pk[ik]; - k1 = pk[ik + m]; - - doff = coff/8; - buff0 = buff[jk ] + doff; - buff1 = buff[jk + 1] + doff; - - off = coff & 7; - vis_write_gsr(gsr_scale + off); - - s01 = buff0[0]; - s11 = buff1[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - s00 = s01; - s10 = s11; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d00, d0); - d0 = vis_fpadd16(d10, d0); - d1 = vis_fpadd16(d01, d1); - d1 = vis_fpadd16(d11, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } - - pk += 2*m; - - } else if (jk_size == 3) { - - for (ik = 0; ik < m; ik++, coff += NCHAN) { - if (!jk && ik == ik_last) continue; - - k0 = pk[ik]; - k1 = pk[ik + m]; - k2 = pk[ik + 2*m]; - - doff = coff/8; - buff0 = buff[jk ] + doff; - buff1 = buff[jk + 1] + doff; - buff2 = buff[jk + 2] + doff; - - off = coff & 7; - vis_write_gsr(gsr_scale + off); - - if (off == 0) { -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - - s0 = buff0[i]; - s1 = buff1[i]; - s2 = buff2[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d20, d0); - d0 = vis_fpadd16(d00, d0); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d21, d1); - d1 = vis_fpadd16(d01, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } else if (off == 4) { - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - - d00 = vis_fmul8x16au(vis_read_lo(s00), k0); - d01 = vis_fmul8x16au(vis_read_hi(s01), k0); - d10 = vis_fmul8x16au(vis_read_lo(s10), k1); - d11 = vis_fmul8x16au(vis_read_hi(s11), k1); - d20 = vis_fmul8x16au(vis_read_lo(s20), k2); - d21 = vis_fmul8x16au(vis_read_hi(s21), k2); - - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d20, d0); - d0 = vis_fpadd16(d00, d0); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d21, d1); - d1 = vis_fpadd16(d01, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } else { - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d20, d0); - d0 = vis_fpadd16(d00, d0); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d21, d1); - d1 = vis_fpadd16(d01, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - } - } - - pk += 3*m; - - } else { /* jk_size == 4 */ - - for (ik = 0; ik < m; ik++, coff += NCHAN) { - if (!jk && ik == ik_last) continue; - - k0 = pk[ik]; - k1 = pk[ik + m]; - k2 = pk[ik + 2*m]; - k3 = pk[ik + 3*m]; - - doff = coff/8; - buff0 = buff[jk ] + doff; - buff1 = buff[jk + 1] + doff; - buff2 = buff[jk + 2] + doff; - buff3 = buff[jk + 3] + doff; - - off = coff & 7; - vis_write_gsr(gsr_scale + off); - - if (off == 0) { - -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - - s0 = buff0[i]; - s1 = buff1[i]; - s2 = buff2[i]; - s3 = buff3[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - d30 = vis_fmul8x16au(vis_read_hi(s3), k3); - d31 = vis_fmul8x16au(vis_read_lo(s3), k3); - - d00 = vis_fpadd16(d00, d10); - d20 = vis_fpadd16(d20, d30); - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d20); - d01 = vis_fpadd16(d01, d11); - d21 = vis_fpadd16(d21, d31); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d21); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } else if (off == 4) { - - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; - s31 = buff3[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - - s00 = s01; - s10 = s11; - s20 = s21; - s30 = s31; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s31 = buff3[i + 1]; - - d00 = vis_fmul8x16au(vis_read_lo(s00), k0); - d01 = vis_fmul8x16au(vis_read_hi(s01), k0); - d10 = vis_fmul8x16au(vis_read_lo(s10), k1); - d11 = vis_fmul8x16au(vis_read_hi(s11), k1); - d20 = vis_fmul8x16au(vis_read_lo(s20), k2); - d21 = vis_fmul8x16au(vis_read_hi(s21), k2); - d30 = vis_fmul8x16au(vis_read_lo(s30), k3); - d31 = vis_fmul8x16au(vis_read_hi(s31), k3); - - d00 = vis_fpadd16(d00, d10); - d20 = vis_fpadd16(d20, d30); - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d20); - d01 = vis_fpadd16(d01, d11); - d21 = vis_fpadd16(d21, d31); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d21); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } else { - - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; - s31 = buff3[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - - s00 = s01; - s10 = s11; - s20 = s21; - s30 = s31; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s31 = buff3[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - s3 = vis_faligndata(s30, s31); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - d30 = vis_fmul8x16au(vis_read_hi(s3), k3); - d31 = vis_fmul8x16au(vis_read_lo(s3), k3); - - d00 = vis_fpadd16(d00, d10); - d20 = vis_fpadd16(d20, d30); - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d20); - d01 = vis_fpadd16(d01, d11); - d21 = vis_fpadd16(d21, d31); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d21); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - } - } - - pk += 4*m; - } - } - - /***************************************** - ***************************************** - ** Final iteration ** - ***************************************** - *****************************************/ - - jk_size = n; -#ifdef CONV_INDEX - if (jk_size >= 5) jk_size = 3; - if (jk_size == 4) jk_size = 2; -#else - if (jk_size >= 6) jk_size = 4; - if (jk_size == 5) jk_size = 3; -#endif - - k0 = karr[ik_last]; - k1 = karr[ik_last + m]; - k2 = karr[ik_last + 2*m]; - k3 = karr[ik_last + 3*m]; - - off = ik_last*NCHAN; - doff = off/8; - off &= 7; - buff0 = buff[0] + doff; - buff1 = buff[1] + doff; - buff2 = buff[2] + doff; - buff3 = buff[3] + doff; - vis_write_gsr(gsr_scale + off); - -#ifndef CONV_INDEX - if (jk_size == 2) { - dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl; - - s01 = buff0[0]; - s11 = buff1[0]; -#pragma pipeloop(0) - for (i = 0; i < xsize/8; i++) { - s00 = s01; - s10 = s11; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - - dd = vis_fpack16_pair(d0, d1); - dp[i] = dd; - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if (emask) { - s00 = s01; - s10 = s11; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - - dd = vis_fpack16_pair(d0, d1); - vis_pst_8(dd, dp + i, emask); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize); - - } else if (jk_size == 3) { - - dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl; - - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < xsize/8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - - dd = vis_fpack16_pair(d0, d1); - dp[i] = dd; - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if (emask) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - - dd = vis_fpack16_pair(d0, d1); - vis_pst_8(dd, dp + i, emask); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize); - - } else /* if (jk_size == 4) */ { - - dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl; - - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; - s31 = buff3[0]; -#pragma pipeloop(0) - for (i = 0; i < xsize/8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s30 = s31; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s31 = buff3[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - s3 = vis_faligndata(s30, s31); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - d30 = vis_fmul8x16au(vis_read_hi(s3), k3); - d31 = vis_fmul8x16au(vis_read_lo(s3), k3); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d0 = vis_fpadd16(d0, d30); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - d1 = vis_fpadd16(d1, d31); - - dd = vis_fpack16_pair(d0, d1); - dp[i] = dd; - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if (emask) { - s00 = s01; - s10 = s11; - s20 = s21; - s30 = s31; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s31 = buff3[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - s3 = vis_faligndata(s30, s31); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - d30 = vis_fmul8x16au(vis_read_hi(s3), k3); - d31 = vis_fmul8x16au(vis_read_lo(s3), k3); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d0 = vis_fpadd16(d0, d30); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - d1 = vis_fpadd16(d1, d31); - - dd = vis_fpack16_pair(d0, d1); - vis_pst_8(dd, dp + i, emask); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize); - } - -#else /* CONV_INDEX */ - - if (jk_size == 2) { - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - mlib_d64 s10 = buff1[i]; - mlib_d64 s11 = buff1[i + 1]; - mlib_d64 s12 = buff1[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - d10 = vis_fmul8x16au(vis_read_hi(s10), k1); - d11 = vis_fmul8x16au(vis_read_lo(s10), k1); - d12 = vis_fmul8x16au(vis_read_hi(s11), k1); - d13 = vis_fmul8x16au(vis_read_lo(s11), k1); - d14 = vis_fmul8x16au(vis_read_hi(s12), k1); - d15 = vis_fmul8x16au(vis_read_lo(s12), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d2 = buffd[2*i + 2]; - d3 = buffd[2*i + 3]; - d4 = buffd[2*i + 4]; - d5 = buffd[2*i + 5]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d2 = vis_fpadd16(d2, d02); - d2 = vis_fpadd16(d2, d12); - d3 = vis_fpadd16(d3, d03); - d3 = vis_fpadd16(d3, d13); - d4 = vis_fpadd16(d4, d04); - d4 = vis_fpadd16(d4, d14); - d5 = vis_fpadd16(d5, d05); - d5 = vis_fpadd16(d5, d15); - - buffe[i ] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - buffd[2*i + 2] = drnd; - buffd[2*i + 3] = drnd; - buffd[2*i + 4] = drnd; - buffd[2*i + 5] = drnd; - - LOAD_SRC(); - } - - } else /* if (jk_size == 3) */ { - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d20, d21, d22, d23, d24, d25; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - mlib_d64 s10 = buff1[i]; - mlib_d64 s11 = buff1[i + 1]; - mlib_d64 s12 = buff1[i + 2]; - mlib_d64 s20 = buff2[i]; - mlib_d64 s21 = buff2[i + 1]; - mlib_d64 s22 = buff2[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - d10 = vis_fmul8x16au(vis_read_hi(s10), k1); - d11 = vis_fmul8x16au(vis_read_lo(s10), k1); - d12 = vis_fmul8x16au(vis_read_hi(s11), k1); - d13 = vis_fmul8x16au(vis_read_lo(s11), k1); - d14 = vis_fmul8x16au(vis_read_hi(s12), k1); - d15 = vis_fmul8x16au(vis_read_lo(s12), k1); - d20 = vis_fmul8x16au(vis_read_hi(s20), k2); - d21 = vis_fmul8x16au(vis_read_lo(s20), k2); - d22 = vis_fmul8x16au(vis_read_hi(s21), k2); - d23 = vis_fmul8x16au(vis_read_lo(s21), k2); - d24 = vis_fmul8x16au(vis_read_hi(s22), k2); - d25 = vis_fmul8x16au(vis_read_lo(s22), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d2 = buffd[2*i + 2]; - d3 = buffd[2*i + 3]; - d4 = buffd[2*i + 4]; - d5 = buffd[2*i + 5]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - d2 = vis_fpadd16(d2, d02); - d2 = vis_fpadd16(d2, d12); - d2 = vis_fpadd16(d2, d22); - d3 = vis_fpadd16(d3, d03); - d3 = vis_fpadd16(d3, d13); - d3 = vis_fpadd16(d3, d23); - d4 = vis_fpadd16(d4, d04); - d4 = vis_fpadd16(d4, d14); - d4 = vis_fpadd16(d4, d24); - d5 = vis_fpadd16(d5, d05); - d5 = vis_fpadd16(d5, d15); - d5 = vis_fpadd16(d5, d25); - - buffe[i ] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - buffd[2*i + 2] = drnd; - buffd[2*i + 3] = drnd; - buffd[2*i + 4] = drnd; - buffd[2*i + 5] = drnd; - - LOAD_SRC(); - } - } -#endif /* CONV_INDEX */ - -#ifdef CONV_INDEX - mlib_ImageColorTrue2IndexLine_U8_S16_3((void*)buffe, dl, wid, colormap); -#endif /* CONV_INDEX */ - - sl += sll; - dl += dll; - - buff_ind++; - if (buff_ind >= (n + 1)) buff_ind = 0; - } - - mlib_free(pbuff); - if (buffs != buffs_local) mlib_free(buffs); - - return MLIB_SUCCESS; -} - -/***************************************************************/ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_8nw.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_8nw.c deleted file mode 100644 index ada07fe2d89..00000000000 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_8nw.c +++ /dev/null @@ -1,1673 +0,0 @@ -/* - * Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - - - -/* - * FUNCTION - * Internal functions for mlib_ImageConv* on U8 type - * and MLIB_EDGE_DST_NO_WRITE mask - * - */ - -/***************************************************************/ - -#include -#include -#include -#include - -/* - This defines switches between functions in - files: mlib_v_ImageConv_8nw.c, - mlib_v_ImageConvIndex3_8_8nw.c, - mlib_v_ImageConvIndex4_8_8nw.c, - mlib_v_ImageConvIndex3_8_16nw.c, - mlib_v_ImageConvIndex4_8_16nw.c -*/ - -#define CONV_INDEX - -#define DTYPE mlib_u8 -#define LTYPE mlib_u8 - -/***************************************************************/ - -#ifdef CONV_INDEX - -#define CONV_FUNC(KERN) \ - mlib_conv##KERN##_Index3_8_8nw(mlib_image *dst, \ - mlib_image *src, \ - mlib_s32 *kern, \ - mlib_s32 scale, \ - void *colormap) - -#else - -#define CONV_FUNC(KERN) \ - mlib_conv##KERN##_8nw_f(mlib_image *dst, \ - mlib_image *src, \ - mlib_s32 *kern, \ - mlib_s32 scale) - -#endif - -/***************************************************************/ - -#ifdef CONV_INDEX - -#define NCHAN 3 - -#else - -#define NCHAN nchan - -#endif - -/***************************************************************/ - -#define DEF_VARS \ - DTYPE *sl, *sp, *dl; \ - mlib_s32 hgt = mlib_ImageGetHeight(src); \ - mlib_s32 wid = mlib_ImageGetWidth(src); \ - mlib_s32 sll = mlib_ImageGetStride(src) / sizeof(DTYPE); \ - mlib_s32 dll = mlib_ImageGetStride(dst) / sizeof(DTYPE); \ - DTYPE *adr_src = (DTYPE *)mlib_ImageGetData(src); \ - DTYPE *adr_dst = (DTYPE *)mlib_ImageGetData(dst); \ - mlib_s32 ssize, xsize, dsize, esize, emask, buff_ind = 0; \ - mlib_d64 *pbuff, *dp; \ - mlib_f32 *karr = (mlib_f32 *)kern; \ - mlib_s32 gsr_scale = (31 - scale) << 3; \ - mlib_d64 drnd = vis_to_double_dup(mlib_round_8[31 - scale]); \ - mlib_s32 i, j, l - -/***************************************************************/ - -#ifdef CONV_INDEX - -#define DEF_EXTRA_VARS \ - int offset = mlib_ImageGetLutOffset(colormap); \ - LTYPE **lut_table = (LTYPE**)mlib_ImageGetLutData(colormap); \ - LTYPE *ltbl0 = lut_table[0] - offset; \ - LTYPE *ltbl1 = lut_table[1] - offset; \ - LTYPE *ltbl2 = lut_table[2] - offset; \ - LTYPE *ltbl3 = (NCHAN > 3) ? lut_table[3] - offset : ltbl2 - -#else - -#define DEF_EXTRA_VARS \ - mlib_s32 nchan = mlib_ImageGetChannels(dst) - -#endif - -/***************************************************************/ - -#if NCHAN == 3 - -#define LOAD_SRC() { \ - mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3]; \ - mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7]; \ - mlib_d64 t0, t1, t2; \ - \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s7), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s7), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s7), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s6), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s6), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s6), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0); \ - \ - buffn[i] = t0; \ - buffn[i + 1] = t1; \ - buffn[i + 2] = t2; \ - \ - sp += 8; \ - } - -#else - -#define LOAD_SRC() { \ - mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3]; \ - mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7]; \ - mlib_d64 t0, t1, t2; \ - \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s4), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t2); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s2), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t1); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0); \ - \ - buffn[i] = t0; \ - buffn[i + 1] = t1; \ - buffn[i + 2] = t2; \ - \ - sp += 6; \ - } - -#endif - -/***************************************************************/ - -static mlib_s32 mlib_round_8[16] = { 0x00400040, 0x00200020, 0x00100010, 0x00080008, - 0x00040004, 0x00020002, 0x00010001, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x00000000, 0x00000000 }; - -/***************************************************************/ - -void mlib_ImageCopy_na(mlib_u8 *sa, mlib_u8 *da, int size); - -/***************************************************************/ - -#define KSIZE 2 - -mlib_status CONV_FUNC(2x2) -{ - mlib_d64 *buffs[2*(KSIZE + 1)]; - mlib_d64 *buff0, *buff1, *buffn, *buffd, *buffe; - mlib_d64 s00, s01, s10, s11, s0, s1; - mlib_d64 d0, d1, d00, d01, d10, d11; - DEF_VARS; - DEF_EXTRA_VARS; - - sl = adr_src; - dl = adr_dst; - - ssize = NCHAN*wid; - dsize = (ssize + 7)/8; - esize = dsize + 4; - pbuff = mlib_malloc((KSIZE + 4)*esize*sizeof(mlib_d64)); - if (pbuff == NULL) return MLIB_FAILURE; - - for (i = 0; i < (KSIZE + 1); i++) buffs[i] = pbuff + i*esize; - for (i = 0; i < (KSIZE + 1); i++) buffs[(KSIZE + 1) + i] = buffs[i]; - buffd = buffs[KSIZE] + esize; - buffe = buffd + 2*esize; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - xsize = ssize - NCHAN*(KSIZE - 1); - emask = (0xFF00 >> (xsize & 7)) & 0xFF; - - vis_write_gsr(gsr_scale + 7); - - for (l = 0; l < KSIZE; l++) { - mlib_d64 *buffn = buffs[l]; - sp = sl + l*sll; - -#ifndef CONV_INDEX - if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize); - -#else -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - LOAD_SRC(); - } -#endif /* CONV_INDEX */ - } - - for (j = 0; j < hgt; j++) { - mlib_d64 **buffc = buffs + buff_ind; - mlib_f32 *pk = karr, k0, k1; - sp = sl + KSIZE*sll; - - buff0 = buffc[0]; - buff1 = buffc[1]; - buffn = buffc[KSIZE]; - -#ifndef CONV_INDEX - if ((((mlib_addr)(sl )) & 7) == 0) buff0 = (mlib_d64*)sl; - if ((((mlib_addr)(sl + sll)) & 7) == 0) buff1 = (mlib_d64*)(sl + sll); - if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize); -#endif - - k0 = pk[1]; - k1 = pk[3]; - vis_write_gsr(gsr_scale + NCHAN); - - s01 = buff0[0]; - s11 = buff1[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - s00 = s01; - s10 = s11; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = vis_fpadd16(d00, d10); - d1 = vis_fpadd16(d01, d11); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - k0 = pk[0]; - k1 = pk[2]; -#ifndef CONV_INDEX - dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl; - -#pragma pipeloop(0) - for (i = 0; i < xsize/8; i++) { - s0 = buff0[i]; - s1 = buff1[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d0, drnd); - d0 = vis_fpadd16(d0, d00); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d1, drnd); - d1 = vis_fpadd16(d1, d01); - dp[i] = vis_fpack16_pair(d0, d1); - } - - if (emask) { - s0 = buff0[i]; - s1 = buff1[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d0, drnd); - d0 = vis_fpadd16(d0, d00); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d1, drnd); - d1 = vis_fpadd16(d1, d01); - - d0 = vis_fpack16_pair(d0, d1); - vis_pst_8(d0, dp + i, emask); - } - - if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize); - -#else - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - mlib_d64 s10 = buff1[i]; - mlib_d64 s11 = buff1[i + 1]; - mlib_d64 s12 = buff1[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - d10 = vis_fmul8x16au(vis_read_hi(s10), k1); - d11 = vis_fmul8x16au(vis_read_lo(s10), k1); - d12 = vis_fmul8x16au(vis_read_hi(s11), k1); - d13 = vis_fmul8x16au(vis_read_lo(s11), k1); - d14 = vis_fmul8x16au(vis_read_hi(s12), k1); - d15 = vis_fmul8x16au(vis_read_lo(s12), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d2 = buffd[2*i + 2]; - d3 = buffd[2*i + 3]; - d4 = buffd[2*i + 4]; - d5 = buffd[2*i + 5]; - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d0, drnd); - d0 = vis_fpadd16(d0, d00); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d1, drnd); - d1 = vis_fpadd16(d1, d01); - d02 = vis_fpadd16(d02, d12); - d2 = vis_fpadd16(d2, drnd); - d2 = vis_fpadd16(d2, d02); - d03 = vis_fpadd16(d03, d13); - d3 = vis_fpadd16(d3, drnd); - d3 = vis_fpadd16(d3, d03); - d04 = vis_fpadd16(d04, d14); - d4 = vis_fpadd16(d4, drnd); - d4 = vis_fpadd16(d4, d04); - d05 = vis_fpadd16(d05, d15); - d5 = vis_fpadd16(d5, drnd); - d5 = vis_fpadd16(d5, d05); - - buffe[i ] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - LOAD_SRC(); - } - - mlib_ImageColorTrue2IndexLine_U8_U8_3((void*)buffe, dl, wid, colormap); -#endif /* CONV_INDEX */ - - sl += sll; - dl += dll; - - buff_ind++; - if (buff_ind >= (KSIZE + 1)) buff_ind = 0; - } - - mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ - -#undef KSIZE -#define KSIZE 3 - -mlib_status CONV_FUNC(3x3) -{ - mlib_d64 *buffs[2*(KSIZE + 1)]; - mlib_d64 *buff0, *buff1, *buff2, *buffn, *buffd, *buffe; - mlib_d64 s00, s01, s10, s11, s20, s21, s0, s1, s2; - mlib_d64 dd, d0, d1, d00, d01, d10, d11, d20, d21; - mlib_s32 ik, ik_last, off, doff; - DEF_VARS; - DEF_EXTRA_VARS; - - sl = adr_src; -#ifdef CONV_INDEX - dl = adr_dst + ((KSIZE - 1)/2)*(dll + 1); -#else - dl = adr_dst + ((KSIZE - 1)/2)*(dll + NCHAN); -#endif - - ssize = NCHAN*wid; - dsize = (ssize + 7)/8; - esize = dsize + 4; - pbuff = mlib_malloc((KSIZE + 4)*esize*sizeof(mlib_d64)); - if (pbuff == NULL) return MLIB_FAILURE; - - for (i = 0; i < (KSIZE + 1); i++) buffs[i] = pbuff + i*esize; - for (i = 0; i < (KSIZE + 1); i++) buffs[(KSIZE + 1) + i] = buffs[i]; - buffd = buffs[KSIZE] + esize; - buffe = buffd + 2*esize; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - xsize = ssize - NCHAN*(KSIZE - 1); - emask = (0xFF00 >> (xsize & 7)) & 0xFF; - - vis_write_gsr(gsr_scale + 7); - - for (l = 0; l < KSIZE; l++) { - mlib_d64 *buffn = buffs[l]; - sp = sl + l*sll; - -#ifndef CONV_INDEX - if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize); -#else -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - LOAD_SRC(); - } -#endif /* CONV_INDEX */ - } - - /* init buffer */ -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - for (j = 0; j < hgt; j++) { - mlib_d64 **buffc = buffs + buff_ind, *pbuff0, *pbuff1, *pbuff2; - mlib_f32 *pk = karr, k0, k1, k2; - sp = sl + KSIZE*sll; - - pbuff0 = buffc[0]; - pbuff1 = buffc[1]; - pbuff2 = buffc[2]; - buffn = buffc[KSIZE]; - -#ifndef CONV_INDEX - if ((((mlib_addr)(sl )) & 7) == 0) pbuff0 = (mlib_d64*)sl; - if ((((mlib_addr)(sl + sll)) & 7) == 0) pbuff1 = (mlib_d64*)(sl + sll); - if ((((mlib_addr)(sl + 2*sll)) & 7) == 0) pbuff2 = (mlib_d64*)(sl + 2*sll); - - if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize); -#endif - -#ifdef CONV_INDEX - ik_last = 0; -#else - ik_last = (KSIZE - 1); -#endif - - for (ik = 0; ik < KSIZE; ik++) { - k0 = pk[ik]; - k1 = pk[ik + KSIZE]; - k2 = pk[ik + 2*KSIZE]; - - off = ik*NCHAN; - doff = off/8; - off &= 7; - buff0 = pbuff0 + doff; - buff1 = pbuff1 + doff; - buff2 = pbuff2 + doff; - vis_write_gsr(gsr_scale + off); - - if (ik == ik_last) continue; - /*if (!ik_last) { - if ((off & 3) || (ik == (KSIZE - 1))) { - ik_last = ik; - continue; - } - }*/ - - if (off == 0) { -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - s0 = buff0[i]; - s1 = buff1[i]; - s2 = buff2[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d00, d0); - d0 = vis_fpadd16(d10, d0); - d0 = vis_fpadd16(d20, d0); - d1 = vis_fpadd16(d01, d1); - d1 = vis_fpadd16(d11, d1); - d1 = vis_fpadd16(d21, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } else if (off == 4) { - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - - d00 = vis_fmul8x16au(vis_read_lo(s00), k0); - d01 = vis_fmul8x16au(vis_read_hi(s01), k0); - d10 = vis_fmul8x16au(vis_read_lo(s10), k1); - d11 = vis_fmul8x16au(vis_read_hi(s11), k1); - d20 = vis_fmul8x16au(vis_read_lo(s20), k2); - d21 = vis_fmul8x16au(vis_read_hi(s21), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d00, d0); - d0 = vis_fpadd16(d10, d0); - d0 = vis_fpadd16(d20, d0); - d1 = vis_fpadd16(d01, d1); - d1 = vis_fpadd16(d11, d1); - d1 = vis_fpadd16(d21, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } else { - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d00, d0); - d0 = vis_fpadd16(d10, d0); - d0 = vis_fpadd16(d20, d0); - d1 = vis_fpadd16(d01, d1); - d1 = vis_fpadd16(d11, d1); - d1 = vis_fpadd16(d21, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - } - } - - k0 = pk[ik_last]; - k1 = pk[ik_last + KSIZE]; - k2 = pk[ik_last + 2*KSIZE]; - - off = ik_last*NCHAN; - doff = off/8; - off &= 7; - buff0 = pbuff0 + doff; - buff1 = pbuff1 + doff; - buff2 = pbuff2 + doff; - vis_write_gsr(gsr_scale + off); - -#ifndef CONV_INDEX - dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl; - - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < xsize/8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - - dd = vis_fpack16_pair(d0, d1); - dp[i] = dd; - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if (emask) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - - dd = vis_fpack16_pair(d0, d1); - vis_pst_8(dd, dp + i, emask); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize); - -#else - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d20, d21, d22, d23, d24, d25; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - mlib_d64 s10 = buff1[i]; - mlib_d64 s11 = buff1[i + 1]; - mlib_d64 s12 = buff1[i + 2]; - mlib_d64 s20 = buff2[i]; - mlib_d64 s21 = buff2[i + 1]; - mlib_d64 s22 = buff2[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - d10 = vis_fmul8x16au(vis_read_hi(s10), k1); - d11 = vis_fmul8x16au(vis_read_lo(s10), k1); - d12 = vis_fmul8x16au(vis_read_hi(s11), k1); - d13 = vis_fmul8x16au(vis_read_lo(s11), k1); - d14 = vis_fmul8x16au(vis_read_hi(s12), k1); - d15 = vis_fmul8x16au(vis_read_lo(s12), k1); - d20 = vis_fmul8x16au(vis_read_hi(s20), k2); - d21 = vis_fmul8x16au(vis_read_lo(s20), k2); - d22 = vis_fmul8x16au(vis_read_hi(s21), k2); - d23 = vis_fmul8x16au(vis_read_lo(s21), k2); - d24 = vis_fmul8x16au(vis_read_hi(s22), k2); - d25 = vis_fmul8x16au(vis_read_lo(s22), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d2 = buffd[2*i + 2]; - d3 = buffd[2*i + 3]; - d4 = buffd[2*i + 4]; - d5 = buffd[2*i + 5]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - d2 = vis_fpadd16(d2, d02); - d2 = vis_fpadd16(d2, d12); - d2 = vis_fpadd16(d2, d22); - d3 = vis_fpadd16(d3, d03); - d3 = vis_fpadd16(d3, d13); - d3 = vis_fpadd16(d3, d23); - d4 = vis_fpadd16(d4, d04); - d4 = vis_fpadd16(d4, d14); - d4 = vis_fpadd16(d4, d24); - d5 = vis_fpadd16(d5, d05); - d5 = vis_fpadd16(d5, d15); - d5 = vis_fpadd16(d5, d25); - - buffe[i ] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - buffd[2*i + 2] = drnd; - buffd[2*i + 3] = drnd; - buffd[2*i + 4] = drnd; - buffd[2*i + 5] = drnd; - - LOAD_SRC(); - } - - mlib_ImageColorTrue2IndexLine_U8_U8_3((void*)buffe, dl, wid, colormap); -#endif /* CONV_INDEX */ - - sl += sll; - dl += dll; - - buff_ind++; - if (buff_ind >= (KSIZE + 1)) buff_ind = 0; - } - - mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ - -#undef KSIZE -#define MAX_N 11 - -#ifdef CONV_INDEX - -mlib_status mlib_convMxN_Index3_8_8nw(mlib_image *dst, - mlib_image *src, - mlib_s32 m, - mlib_s32 n, - mlib_s32 dm, - mlib_s32 dn, - mlib_s32 *kern, - mlib_s32 scale, - void *colormap) - -#else - -mlib_status mlib_convMxN_8nw_f(mlib_image *dst, - mlib_image *src, - mlib_s32 m, - mlib_s32 n, - mlib_s32 dm, - mlib_s32 dn, - mlib_s32 *kern, - mlib_s32 scale) - -#endif -{ - mlib_d64 *buffs_local[3*(MAX_N + 1)], **buffs = buffs_local, **buff; - mlib_d64 *buff0, *buff1, *buff2, *buff3, *buffn, *buffd, *buffe; - mlib_d64 s00, s01, s10, s11, s20, s21, s30, s31, s0, s1, s2, s3; - mlib_d64 d00, d01, d10, d11, d20, d21, d30, d31; - mlib_d64 dd, d0, d1; - mlib_s32 ik, jk, ik_last, jk_size, coff, off, doff; - DEF_VARS; - DEF_EXTRA_VARS; - - if (n > MAX_N) { - buffs = mlib_malloc(3*(n + 1)*sizeof(mlib_d64*)); - if (buffs == NULL) return MLIB_FAILURE; - } - - buff = buffs + 2*(n + 1); - - sl = adr_src; -#ifdef CONV_INDEX - dl = adr_dst + dn*dll + dm; -#else - dl = adr_dst + dn*dll + dm*NCHAN; -#endif - - ssize = NCHAN*wid; - dsize = (ssize + 7)/8; - esize = dsize + 4; - pbuff = mlib_malloc((n + 4)*esize*sizeof(mlib_d64)); - if (pbuff == NULL) { - if (buffs != buffs_local) mlib_free(buffs); - return MLIB_FAILURE; - } - - for (i = 0; i < (n + 1); i++) buffs[i] = pbuff + i*esize; - for (i = 0; i < (n + 1); i++) buffs[(n + 1) + i] = buffs[i]; - buffd = buffs[n] + esize; - buffe = buffd + 2*esize; - - wid -= (m - 1); - hgt -= (n - 1); - xsize = ssize - NCHAN*(m - 1); - emask = (0xFF00 >> (xsize & 7)) & 0xFF; - - vis_write_gsr(gsr_scale + 7); - - for (l = 0; l < n; l++) { - mlib_d64 *buffn = buffs[l]; - sp = sl + l*sll; - -#ifndef CONV_INDEX - if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize); -#else -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - LOAD_SRC(); - } -#endif /* CONV_INDEX */ - } - - /* init buffer */ -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - for (j = 0; j < hgt; j++) { - mlib_d64 **buffc = buffs + buff_ind; - mlib_f32 *pk = karr, k0, k1, k2, k3; - sp = sl + n*sll; - - for (l = 0; l < n; l++) { - buff[l] = buffc[l]; - } - buffn = buffc[n]; - -#ifndef CONV_INDEX - for (l = 0; l < n; l++) { - if ((((mlib_addr)(sl + l*sll)) & 7) == 0) buff[l] = (mlib_d64*)(sl + l*sll); - } - if ((mlib_addr)sp & 7) mlib_ImageCopy_na((void*)sp, (void*)buffn, ssize); -#endif - -#ifdef CONV_INDEX - ik_last = 0; -#else - ik_last = (m - 1); -#endif - - for (jk = 0; jk < n; jk += jk_size) { - jk_size = n - jk; -#ifdef CONV_INDEX - if (jk_size >= 5) jk_size = 3; - if (jk_size == 4) jk_size = 2; -#else - if (jk_size >= 6) jk_size = 4; - if (jk_size == 5) jk_size = 3; -#endif - coff = 0; - - if (jk_size == 2) { - - for (ik = 0; ik < m; ik++, coff += NCHAN) { - if (!jk && ik == ik_last) continue; - - k0 = pk[ik]; - k1 = pk[ik + m]; - - doff = coff/8; - buff0 = buff[jk ] + doff; - buff1 = buff[jk + 1] + doff; - - off = coff & 7; - vis_write_gsr(gsr_scale + off); - - s01 = buff0[0]; - s11 = buff1[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - s00 = s01; - s10 = s11; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d00, d0); - d0 = vis_fpadd16(d10, d0); - d1 = vis_fpadd16(d01, d1); - d1 = vis_fpadd16(d11, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } - - pk += 2*m; - - } else if (jk_size == 3) { - - for (ik = 0; ik < m; ik++, coff += NCHAN) { - if (!jk && ik == ik_last) continue; - - k0 = pk[ik]; - k1 = pk[ik + m]; - k2 = pk[ik + 2*m]; - - doff = coff/8; - buff0 = buff[jk ] + doff; - buff1 = buff[jk + 1] + doff; - buff2 = buff[jk + 2] + doff; - - off = coff & 7; - vis_write_gsr(gsr_scale + off); - - if (off == 0) { -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - - s0 = buff0[i]; - s1 = buff1[i]; - s2 = buff2[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d20, d0); - d0 = vis_fpadd16(d00, d0); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d21, d1); - d1 = vis_fpadd16(d01, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } else if (off == 4) { - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - - d00 = vis_fmul8x16au(vis_read_lo(s00), k0); - d01 = vis_fmul8x16au(vis_read_hi(s01), k0); - d10 = vis_fmul8x16au(vis_read_lo(s10), k1); - d11 = vis_fmul8x16au(vis_read_hi(s11), k1); - d20 = vis_fmul8x16au(vis_read_lo(s20), k2); - d21 = vis_fmul8x16au(vis_read_hi(s21), k2); - - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d20, d0); - d0 = vis_fpadd16(d00, d0); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d21, d1); - d1 = vis_fpadd16(d01, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } else { - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d20, d0); - d0 = vis_fpadd16(d00, d0); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d21, d1); - d1 = vis_fpadd16(d01, d1); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - } - } - - pk += 3*m; - - } else { /* jk_size == 4 */ - - for (ik = 0; ik < m; ik++, coff += NCHAN) { - if (!jk && ik == ik_last) continue; - - k0 = pk[ik]; - k1 = pk[ik + m]; - k2 = pk[ik + 2*m]; - k3 = pk[ik + 3*m]; - - doff = coff/8; - buff0 = buff[jk ] + doff; - buff1 = buff[jk + 1] + doff; - buff2 = buff[jk + 2] + doff; - buff3 = buff[jk + 3] + doff; - - off = coff & 7; - vis_write_gsr(gsr_scale + off); - - if (off == 0) { - -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - - s0 = buff0[i]; - s1 = buff1[i]; - s2 = buff2[i]; - s3 = buff3[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - d30 = vis_fmul8x16au(vis_read_hi(s3), k3); - d31 = vis_fmul8x16au(vis_read_lo(s3), k3); - - d00 = vis_fpadd16(d00, d10); - d20 = vis_fpadd16(d20, d30); - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d20); - d01 = vis_fpadd16(d01, d11); - d21 = vis_fpadd16(d21, d31); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d21); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } else if (off == 4) { - - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; - s31 = buff3[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - - s00 = s01; - s10 = s11; - s20 = s21; - s30 = s31; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s31 = buff3[i + 1]; - - d00 = vis_fmul8x16au(vis_read_lo(s00), k0); - d01 = vis_fmul8x16au(vis_read_hi(s01), k0); - d10 = vis_fmul8x16au(vis_read_lo(s10), k1); - d11 = vis_fmul8x16au(vis_read_hi(s11), k1); - d20 = vis_fmul8x16au(vis_read_lo(s20), k2); - d21 = vis_fmul8x16au(vis_read_hi(s21), k2); - d30 = vis_fmul8x16au(vis_read_lo(s30), k3); - d31 = vis_fmul8x16au(vis_read_hi(s31), k3); - - d00 = vis_fpadd16(d00, d10); - d20 = vis_fpadd16(d20, d30); - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d20); - d01 = vis_fpadd16(d01, d11); - d21 = vis_fpadd16(d21, d31); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d21); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - - } else { - - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; - s31 = buff3[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7)/8; i++) { - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - - s00 = s01; - s10 = s11; - s20 = s21; - s30 = s31; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s31 = buff3[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - s3 = vis_faligndata(s30, s31); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - d30 = vis_fmul8x16au(vis_read_hi(s3), k3); - d31 = vis_fmul8x16au(vis_read_lo(s3), k3); - - d00 = vis_fpadd16(d00, d10); - d20 = vis_fpadd16(d20, d30); - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d20); - d01 = vis_fpadd16(d01, d11); - d21 = vis_fpadd16(d21, d31); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d21); - buffd[2*i] = d0; - buffd[2*i + 1] = d1; - } - } - } - - pk += 4*m; - } - } - - /***************************************** - ***************************************** - ** Final iteration ** - ***************************************** - *****************************************/ - - jk_size = n; -#ifdef CONV_INDEX - if (jk_size >= 5) jk_size = 3; - if (jk_size == 4) jk_size = 2; -#else - if (jk_size >= 6) jk_size = 4; - if (jk_size == 5) jk_size = 3; -#endif - - k0 = karr[ik_last]; - k1 = karr[ik_last + m]; - k2 = karr[ik_last + 2*m]; - k3 = karr[ik_last + 3*m]; - - off = ik_last*NCHAN; - doff = off/8; - off &= 7; - buff0 = buff[0] + doff; - buff1 = buff[1] + doff; - buff2 = buff[2] + doff; - buff3 = buff[3] + doff; - vis_write_gsr(gsr_scale + off); - -#ifndef CONV_INDEX - if (jk_size == 2) { - dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl; - - s01 = buff0[0]; - s11 = buff1[0]; -#pragma pipeloop(0) - for (i = 0; i < xsize/8; i++) { - s00 = s01; - s10 = s11; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - - dd = vis_fpack16_pair(d0, d1); - dp[i] = dd; - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if (emask) { - s00 = s01; - s10 = s11; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - - dd = vis_fpack16_pair(d0, d1); - vis_pst_8(dd, dp + i, emask); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize); - - } else if (jk_size == 3) { - - dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl; - - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < xsize/8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - - dd = vis_fpack16_pair(d0, d1); - dp[i] = dd; - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if (emask) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - - dd = vis_fpack16_pair(d0, d1); - vis_pst_8(dd, dp + i, emask); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize); - - } else /* if (jk_size == 4) */ { - - dp = ((mlib_addr)dl & 7) ? buffe : (mlib_d64*)dl; - - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; - s31 = buff3[0]; -#pragma pipeloop(0) - for (i = 0; i < xsize/8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s30 = s31; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s31 = buff3[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - s3 = vis_faligndata(s30, s31); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - d30 = vis_fmul8x16au(vis_read_hi(s3), k3); - d31 = vis_fmul8x16au(vis_read_lo(s3), k3); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d0 = vis_fpadd16(d0, d30); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - d1 = vis_fpadd16(d1, d31); - - dd = vis_fpack16_pair(d0, d1); - dp[i] = dd; - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if (emask) { - s00 = s01; - s10 = s11; - s20 = s21; - s30 = s31; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s31 = buff3[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - s3 = vis_faligndata(s30, s31); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - d30 = vis_fmul8x16au(vis_read_hi(s3), k3); - d31 = vis_fmul8x16au(vis_read_lo(s3), k3); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d0 = vis_fpadd16(d0, d30); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - d1 = vis_fpadd16(d1, d31); - - dd = vis_fpack16_pair(d0, d1); - vis_pst_8(dd, dp + i, emask); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - } - - if ((mlib_u8*)dp != dl) mlib_ImageCopy_na((void*)buffe, dl, xsize); - } - -#else /* CONV_INDEX */ - - if (jk_size == 2) { - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - mlib_d64 s10 = buff1[i]; - mlib_d64 s11 = buff1[i + 1]; - mlib_d64 s12 = buff1[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - d10 = vis_fmul8x16au(vis_read_hi(s10), k1); - d11 = vis_fmul8x16au(vis_read_lo(s10), k1); - d12 = vis_fmul8x16au(vis_read_hi(s11), k1); - d13 = vis_fmul8x16au(vis_read_lo(s11), k1); - d14 = vis_fmul8x16au(vis_read_hi(s12), k1); - d15 = vis_fmul8x16au(vis_read_lo(s12), k1); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d2 = buffd[2*i + 2]; - d3 = buffd[2*i + 3]; - d4 = buffd[2*i + 4]; - d5 = buffd[2*i + 5]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d2 = vis_fpadd16(d2, d02); - d2 = vis_fpadd16(d2, d12); - d3 = vis_fpadd16(d3, d03); - d3 = vis_fpadd16(d3, d13); - d4 = vis_fpadd16(d4, d04); - d4 = vis_fpadd16(d4, d14); - d5 = vis_fpadd16(d5, d05); - d5 = vis_fpadd16(d5, d15); - - buffe[i ] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - buffd[2*i + 2] = drnd; - buffd[2*i + 3] = drnd; - buffd[2*i + 4] = drnd; - buffd[2*i + 5] = drnd; - - LOAD_SRC(); - } - - } else /* if (jk_size == 3) */ { - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d20, d21, d22, d23, d24, d25; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - mlib_d64 s10 = buff1[i]; - mlib_d64 s11 = buff1[i + 1]; - mlib_d64 s12 = buff1[i + 2]; - mlib_d64 s20 = buff2[i]; - mlib_d64 s21 = buff2[i + 1]; - mlib_d64 s22 = buff2[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - d10 = vis_fmul8x16au(vis_read_hi(s10), k1); - d11 = vis_fmul8x16au(vis_read_lo(s10), k1); - d12 = vis_fmul8x16au(vis_read_hi(s11), k1); - d13 = vis_fmul8x16au(vis_read_lo(s11), k1); - d14 = vis_fmul8x16au(vis_read_hi(s12), k1); - d15 = vis_fmul8x16au(vis_read_lo(s12), k1); - d20 = vis_fmul8x16au(vis_read_hi(s20), k2); - d21 = vis_fmul8x16au(vis_read_lo(s20), k2); - d22 = vis_fmul8x16au(vis_read_hi(s21), k2); - d23 = vis_fmul8x16au(vis_read_lo(s21), k2); - d24 = vis_fmul8x16au(vis_read_hi(s22), k2); - d25 = vis_fmul8x16au(vis_read_lo(s22), k2); - - d0 = buffd[2*i]; - d1 = buffd[2*i + 1]; - d2 = buffd[2*i + 2]; - d3 = buffd[2*i + 3]; - d4 = buffd[2*i + 4]; - d5 = buffd[2*i + 5]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - d2 = vis_fpadd16(d2, d02); - d2 = vis_fpadd16(d2, d12); - d2 = vis_fpadd16(d2, d22); - d3 = vis_fpadd16(d3, d03); - d3 = vis_fpadd16(d3, d13); - d3 = vis_fpadd16(d3, d23); - d4 = vis_fpadd16(d4, d04); - d4 = vis_fpadd16(d4, d14); - d4 = vis_fpadd16(d4, d24); - d5 = vis_fpadd16(d5, d05); - d5 = vis_fpadd16(d5, d15); - d5 = vis_fpadd16(d5, d25); - - buffe[i ] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - buffd[2*i ] = drnd; - buffd[2*i + 1] = drnd; - buffd[2*i + 2] = drnd; - buffd[2*i + 3] = drnd; - buffd[2*i + 4] = drnd; - buffd[2*i + 5] = drnd; - - LOAD_SRC(); - } - } -#endif /* CONV_INDEX */ - -#ifdef CONV_INDEX - mlib_ImageColorTrue2IndexLine_U8_U8_3((void*)buffe, dl, wid, colormap); -#endif /* CONV_INDEX */ - - sl += sll; - dl += dll; - - buff_ind++; - if (buff_ind >= (n + 1)) buff_ind = 0; - } - - mlib_free(pbuff); - if (buffs != buffs_local) mlib_free(buffs); - - return MLIB_SUCCESS; -} - -/***************************************************************/ diff --git a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv_8nw.c b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv_8nw.c index ac2e5f025a6..0605fa4fa84 100644 --- a/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv_8nw.c +++ b/jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConv_8nw.c @@ -34,58 +34,16 @@ #include "vis_proto.h" #include "mlib_image.h" #include "mlib_ImageCheck.h" -#include "mlib_ImageColormap.h" #include "mlib_ImageCopy.h" #include "mlib_ImageConv.h" #include "mlib_v_ImageConv.h" -/* - This defines switches between functions in - files: mlib_v_ImageConvIndex3_8_8nw.c, - mlib_v_ImageConvIndex4_8_8nw.c, - mlib_v_ImageConvIndex3_8_16nw.c, - mlib_v_ImageConvIndex4_8_16nw.c -*/ - -/*#define CONV_INDEX*/ - /***************************************************************/ #define DTYPE mlib_u8 -#define LTYPE mlib_u8 - -/***************************************************************/ -#ifdef CONV_INDEX - -#define CONV_FUNC(KERN) \ - mlib_conv##KERN##_Index3_8_8nw(mlib_image *dst, \ - const mlib_image *src, \ - const mlib_s32 *kern, \ - mlib_s32 scale, \ - const void *colormap) - -#else - -#define CONV_FUNC(KERN) \ - mlib_conv##KERN##_8nw_f(mlib_image *dst, \ - const mlib_image *src, \ - const mlib_s32 *kern, \ - mlib_s32 scale) - -#endif /* CONV_INDEX */ - -#define ColorTrue2IndexLine mlib_ImageColorTrue2IndexLine_U8_U8_3 /***************************************************************/ -#ifdef CONV_INDEX - -#define NCHAN 3 - -#else - #define NCHAN nchan -#endif /* CONV_INDEX */ - /***************************************************************/ #define DEF_VARS \ DTYPE *sl, *sp, *dl; \ @@ -103,104 +61,9 @@ mlib_s32 i, j, l /***************************************************************/ -#ifdef CONV_INDEX - -#define DEF_EXTRA_VARS \ - mlib_s32 offset = mlib_ImageGetLutOffset(colormap); \ - LTYPE **lut_table = (LTYPE**)mlib_ImageGetLutData(colormap); \ - LTYPE *ltbl0 = lut_table[0] - offset; \ - LTYPE *ltbl1 = lut_table[1] - offset; \ - LTYPE *ltbl2 = lut_table[2] - offset; \ - LTYPE *ltbl3 = (NCHAN > 3) ? lut_table[3] - offset : ltbl2 - -#else - #define DEF_EXTRA_VARS \ mlib_s32 nchan = mlib_ImageGetChannels(dst) -#endif /* CONV_INDEX */ - -/***************************************************************/ -#if NCHAN == 3 - -#define LOAD_SRC() { \ - mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3]; \ - mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7]; \ - mlib_d64 t0, t1, t2; \ - \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s7), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s7), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s7), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s6), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s6), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s6), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0); \ - \ - buffn[i] = t0; \ - buffn[i + 1] = t1; \ - buffn[i + 2] = t2; \ - \ - sp += 8; \ - } - -#else - -#define LOAD_SRC() { \ - mlib_s32 s0 = sp[0], s1 = sp[1], s2 = sp[2], s3 = sp[3]; \ - mlib_s32 s4 = sp[4], s5 = sp[5], s6 = sp[6], s7 = sp[7]; \ - mlib_d64 t0, t1, t2; \ - \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s5), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl3, s4), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl2, s4), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl1, s4), t2); \ - t2 = vis_faligndata(vis_ld_u8_i(ltbl0, s4), t2); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s3), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl3, s2), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl2, s2), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl1, s2), t1); \ - t1 = vis_faligndata(vis_ld_u8_i(ltbl0, s2), t1); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s1), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl3, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl2, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl1, s0), t0); \ - t0 = vis_faligndata(vis_ld_u8_i(ltbl0, s0), t0); \ - \ - buffn[i] = t0; \ - buffn[i + 1] = t1; \ - buffn[i + 2] = t2; \ - \ - sp += 6; \ - } - -#endif /* NCHAN == 3 */ - /***************************************************************/ static const mlib_s32 mlib_round_8[16] = { 0x00400040, 0x00200020, 0x00100010, 0x00080008, @@ -210,651 +73,8 @@ static const mlib_s32 mlib_round_8[16] = { }; /***************************************************************/ -#define KSIZE 2 - -mlib_status CONV_FUNC(2x2) -{ - mlib_d64 *buffs[2 * (KSIZE + 1)]; - mlib_d64 *buff0, *buff1, *buffn, *buffd, *buffe; - mlib_d64 s00, s01, s10, s11, s0, s1; - mlib_d64 d0, d1, d00, d01, d10, d11; - DEF_VARS; - DEF_EXTRA_VARS; - - sl = adr_src; - dl = adr_dst; - - ssize = NCHAN * wid; - dsize = (ssize + 7) / 8; - esize = dsize + 4; - pbuff = mlib_malloc((KSIZE + 4) * esize * sizeof(mlib_d64)); - - if (pbuff == NULL) - return MLIB_FAILURE; - - for (i = 0; i < (KSIZE + 1); i++) - buffs[i] = pbuff + i * esize; - for (i = 0; i < (KSIZE + 1); i++) - buffs[(KSIZE + 1) + i] = buffs[i]; - buffd = buffs[KSIZE] + esize; - buffe = buffd + 2 * esize; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - xsize = ssize - NCHAN * (KSIZE - 1); - emask = (0xFF00 >> (xsize & 7)) & 0xFF; - - vis_write_gsr(gsr_scale + 7); - - for (l = 0; l < KSIZE; l++) { - mlib_d64 *buffn = buffs[l]; - sp = sl + l * sll; - -#ifndef CONV_INDEX - - if ((mlib_addr) sp & 7) - mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize); - -#else -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - LOAD_SRC(); - } - -#endif /* CONV_INDEX */ - } - - for (j = 0; j < hgt; j++) { - mlib_d64 **buffc = buffs + buff_ind; - mlib_f32 *pk = karr, k0, k1; - sp = sl + KSIZE * sll; - - buff0 = buffc[0]; - buff1 = buffc[1]; - buffn = buffc[KSIZE]; - -#ifndef CONV_INDEX - - if ((((mlib_addr) (sl)) & 7) == 0) - buff0 = (mlib_d64 *) sl; - - if ((((mlib_addr) (sl + sll)) & 7) == 0) - buff1 = (mlib_d64 *) (sl + sll); - - if ((mlib_addr) sp & 7) - mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize); -#endif /* CONV_INDEX */ - - k0 = pk[1]; - k1 = pk[3]; - vis_write_gsr(gsr_scale + NCHAN); - - s01 = buff0[0]; - s11 = buff1[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7) / 8; i++) { - s00 = s01; - s10 = s11; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = vis_fpadd16(d00, d10); - d1 = vis_fpadd16(d01, d11); - buffd[2 * i] = d0; - buffd[2 * i + 1] = d1; - } - - k0 = pk[0]; - k1 = pk[2]; -#ifndef CONV_INDEX - dp = ((mlib_addr) dl & 7) ? buffe : (mlib_d64 *) dl; - -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - s0 = buff0[i]; - s1 = buff1[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = buffd[2 * i]; - d1 = buffd[2 * i + 1]; - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d0, drnd); - d0 = vis_fpadd16(d0, d00); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d1, drnd); - d1 = vis_fpadd16(d1, d01); - dp[i] = vis_fpack16_pair(d0, d1); - } - - if (emask) { - s0 = buff0[i]; - s1 = buff1[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - - d0 = buffd[2 * i]; - d1 = buffd[2 * i + 1]; - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d0, drnd); - d0 = vis_fpadd16(d0, d00); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d1, drnd); - d1 = vis_fpadd16(d1, d01); - - d0 = vis_fpack16_pair(d0, d1); - vis_pst_8(d0, dp + i, emask); - } - - if ((mlib_u8 *) dp != dl) - mlib_ImageCopy_na((void *)buffe, dl, xsize); - -#else - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - mlib_d64 s10 = buff1[i]; - mlib_d64 s11 = buff1[i + 1]; - mlib_d64 s12 = buff1[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - d10 = vis_fmul8x16au(vis_read_hi(s10), k1); - d11 = vis_fmul8x16au(vis_read_lo(s10), k1); - d12 = vis_fmul8x16au(vis_read_hi(s11), k1); - d13 = vis_fmul8x16au(vis_read_lo(s11), k1); - d14 = vis_fmul8x16au(vis_read_hi(s12), k1); - d15 = vis_fmul8x16au(vis_read_lo(s12), k1); - - d0 = buffd[2 * i]; - d1 = buffd[2 * i + 1]; - d2 = buffd[2 * i + 2]; - d3 = buffd[2 * i + 3]; - d4 = buffd[2 * i + 4]; - d5 = buffd[2 * i + 5]; - d00 = vis_fpadd16(d00, d10); - d0 = vis_fpadd16(d0, drnd); - d0 = vis_fpadd16(d0, d00); - d01 = vis_fpadd16(d01, d11); - d1 = vis_fpadd16(d1, drnd); - d1 = vis_fpadd16(d1, d01); - d02 = vis_fpadd16(d02, d12); - d2 = vis_fpadd16(d2, drnd); - d2 = vis_fpadd16(d2, d02); - d03 = vis_fpadd16(d03, d13); - d3 = vis_fpadd16(d3, drnd); - d3 = vis_fpadd16(d3, d03); - d04 = vis_fpadd16(d04, d14); - d4 = vis_fpadd16(d4, drnd); - d4 = vis_fpadd16(d4, d04); - d05 = vis_fpadd16(d05, d15); - d5 = vis_fpadd16(d5, drnd); - d5 = vis_fpadd16(d5, d05); - - buffe[i] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - LOAD_SRC(); - } - - ColorTrue2IndexLine((void *)buffe, dl, wid, colormap); -#endif /* CONV_INDEX */ - - sl += sll; - dl += dll; - - buff_ind++; - - if (buff_ind >= (KSIZE + 1)) - buff_ind = 0; - } - - mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE -#define KSIZE 3 - -mlib_status CONV_FUNC(3x3) -{ - mlib_d64 *buffs[2 * (KSIZE + 1)]; - mlib_d64 *buff0, *buff1, *buff2, *buffn, *buffd, *buffe; - mlib_d64 s00, s01, s10, s11, s20, s21, s0, s1, s2; - mlib_d64 dd, d0, d1, d00, d01, d10, d11, d20, d21; - mlib_s32 ik, ik_last, off, doff; - DEF_VARS; - DEF_EXTRA_VARS; - - sl = adr_src; -#ifdef CONV_INDEX - dl = adr_dst + ((KSIZE - 1) / 2) * (dll + 1); -#else - dl = adr_dst + ((KSIZE - 1) / 2) * (dll + NCHAN); -#endif /* CONV_INDEX */ - - ssize = NCHAN * wid; - dsize = (ssize + 7) / 8; - esize = dsize + 4; - pbuff = mlib_malloc((KSIZE + 4) * esize * sizeof(mlib_d64)); - - if (pbuff == NULL) - return MLIB_FAILURE; - - for (i = 0; i < (KSIZE + 1); i++) - buffs[i] = pbuff + i * esize; - for (i = 0; i < (KSIZE + 1); i++) - buffs[(KSIZE + 1) + i] = buffs[i]; - buffd = buffs[KSIZE] + esize; - buffe = buffd + 2 * esize; - - wid -= (KSIZE - 1); - hgt -= (KSIZE - 1); - xsize = ssize - NCHAN * (KSIZE - 1); - emask = (0xFF00 >> (xsize & 7)) & 0xFF; - - vis_write_gsr(gsr_scale + 7); - - for (l = 0; l < KSIZE; l++) { - mlib_d64 *buffn = buffs[l]; - sp = sl + l * sll; - -#ifndef CONV_INDEX - - if ((mlib_addr) sp & 7) - mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize); -#else -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - LOAD_SRC(); - } - -#endif /* CONV_INDEX */ - } - - /* init buffer */ -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7) / 8; i++) { - buffd[2 * i] = drnd; - buffd[2 * i + 1] = drnd; - } - - for (j = 0; j < hgt; j++) { - mlib_d64 **buffc = buffs + buff_ind, *pbuff0, *pbuff1, *pbuff2; - mlib_f32 *pk = karr, k0, k1, k2; - sp = sl + KSIZE * sll; - - pbuff0 = buffc[0]; - pbuff1 = buffc[1]; - pbuff2 = buffc[2]; - buffn = buffc[KSIZE]; - -#ifndef CONV_INDEX - - if ((((mlib_addr) (sl)) & 7) == 0) - pbuff0 = (mlib_d64 *) sl; - - if ((((mlib_addr) (sl + sll)) & 7) == 0) - pbuff1 = (mlib_d64 *) (sl + sll); - - if ((((mlib_addr) (sl + 2 * sll)) & 7) == 0) - pbuff2 = (mlib_d64 *) (sl + 2 * sll); - - if ((mlib_addr) sp & 7) - mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize); -#endif /* CONV_INDEX */ - -#ifdef CONV_INDEX - ik_last = 0; -#else - ik_last = (KSIZE - 1); -#endif /* CONV_INDEX */ - - for (ik = 0; ik < KSIZE; ik++) { - k0 = pk[ik]; - k1 = pk[ik + KSIZE]; - k2 = pk[ik + 2 * KSIZE]; - - off = ik * NCHAN; - doff = off / 8; - off &= 7; - buff0 = pbuff0 + doff; - buff1 = pbuff1 + doff; - buff2 = pbuff2 + doff; - vis_write_gsr(gsr_scale + off); - - if (ik == ik_last) - continue; - /*if (!ik_last) { - * if ((off & 3) || (ik == (KSIZE - 1))) { - * ik_last = ik; - * continue; - * } - * } */ - - if (off == 0) { -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7) / 8; i++) { - s0 = buff0[i]; - s1 = buff1[i]; - s2 = buff2[i]; - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2 * i]; - d1 = buffd[2 * i + 1]; - d0 = vis_fpadd16(d00, d0); - d0 = vis_fpadd16(d10, d0); - d0 = vis_fpadd16(d20, d0); - d1 = vis_fpadd16(d01, d1); - d1 = vis_fpadd16(d11, d1); - d1 = vis_fpadd16(d21, d1); - buffd[2 * i] = d0; - buffd[2 * i + 1] = d1; - } - } - else if (off == 4) { - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7) / 8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - - d00 = vis_fmul8x16au(vis_read_lo(s00), k0); - d01 = vis_fmul8x16au(vis_read_hi(s01), k0); - d10 = vis_fmul8x16au(vis_read_lo(s10), k1); - d11 = vis_fmul8x16au(vis_read_hi(s11), k1); - d20 = vis_fmul8x16au(vis_read_lo(s20), k2); - d21 = vis_fmul8x16au(vis_read_hi(s21), k2); - - d0 = buffd[2 * i]; - d1 = buffd[2 * i + 1]; - d0 = vis_fpadd16(d00, d0); - d0 = vis_fpadd16(d10, d0); - d0 = vis_fpadd16(d20, d0); - d1 = vis_fpadd16(d01, d1); - d1 = vis_fpadd16(d11, d1); - d1 = vis_fpadd16(d21, d1); - buffd[2 * i] = d0; - buffd[2 * i + 1] = d1; - } - } - else { - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < (xsize + 7) / 8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2 * i]; - d1 = buffd[2 * i + 1]; - d0 = vis_fpadd16(d00, d0); - d0 = vis_fpadd16(d10, d0); - d0 = vis_fpadd16(d20, d0); - d1 = vis_fpadd16(d01, d1); - d1 = vis_fpadd16(d11, d1); - d1 = vis_fpadd16(d21, d1); - buffd[2 * i] = d0; - buffd[2 * i + 1] = d1; - } - } - } - - k0 = pk[ik_last]; - k1 = pk[ik_last + KSIZE]; - k2 = pk[ik_last + 2 * KSIZE]; - - off = ik_last * NCHAN; - doff = off / 8; - off &= 7; - buff0 = pbuff0 + doff; - buff1 = pbuff1 + doff; - buff2 = pbuff2 + doff; - vis_write_gsr(gsr_scale + off); - -#ifndef CONV_INDEX - dp = ((mlib_addr) dl & 7) ? buffe : (mlib_d64 *) dl; - - s01 = buff0[0]; - s11 = buff1[0]; - s21 = buff2[0]; -#pragma pipeloop(0) - for (i = 0; i < xsize / 8; i++) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2 * i]; - d1 = buffd[2 * i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - - dd = vis_fpack16_pair(d0, d1); - dp[i] = dd; - - buffd[2 * i] = drnd; - buffd[2 * i + 1] = drnd; - } - - if (emask) { - s00 = s01; - s10 = s11; - s20 = s21; - s01 = buff0[i + 1]; - s11 = buff1[i + 1]; - s21 = buff2[i + 1]; - s0 = vis_faligndata(s00, s01); - s1 = vis_faligndata(s10, s11); - s2 = vis_faligndata(s20, s21); - - d00 = vis_fmul8x16au(vis_read_hi(s0), k0); - d01 = vis_fmul8x16au(vis_read_lo(s0), k0); - d10 = vis_fmul8x16au(vis_read_hi(s1), k1); - d11 = vis_fmul8x16au(vis_read_lo(s1), k1); - d20 = vis_fmul8x16au(vis_read_hi(s2), k2); - d21 = vis_fmul8x16au(vis_read_lo(s2), k2); - - d0 = buffd[2 * i]; - d1 = buffd[2 * i + 1]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - - dd = vis_fpack16_pair(d0, d1); - vis_pst_8(dd, dp + i, emask); - - buffd[2 * i] = drnd; - buffd[2 * i + 1] = drnd; - } - - if ((mlib_u8 *) dp != dl) - mlib_ImageCopy_na((void *)buffe, dl, xsize); - -#else - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d20, d21, d22, d23, d24, d25; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - mlib_d64 s10 = buff1[i]; - mlib_d64 s11 = buff1[i + 1]; - mlib_d64 s12 = buff1[i + 2]; - mlib_d64 s20 = buff2[i]; - mlib_d64 s21 = buff2[i + 1]; - mlib_d64 s22 = buff2[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - d10 = vis_fmul8x16au(vis_read_hi(s10), k1); - d11 = vis_fmul8x16au(vis_read_lo(s10), k1); - d12 = vis_fmul8x16au(vis_read_hi(s11), k1); - d13 = vis_fmul8x16au(vis_read_lo(s11), k1); - d14 = vis_fmul8x16au(vis_read_hi(s12), k1); - d15 = vis_fmul8x16au(vis_read_lo(s12), k1); - d20 = vis_fmul8x16au(vis_read_hi(s20), k2); - d21 = vis_fmul8x16au(vis_read_lo(s20), k2); - d22 = vis_fmul8x16au(vis_read_hi(s21), k2); - d23 = vis_fmul8x16au(vis_read_lo(s21), k2); - d24 = vis_fmul8x16au(vis_read_hi(s22), k2); - d25 = vis_fmul8x16au(vis_read_lo(s22), k2); - - d0 = buffd[2 * i]; - d1 = buffd[2 * i + 1]; - d2 = buffd[2 * i + 2]; - d3 = buffd[2 * i + 3]; - d4 = buffd[2 * i + 4]; - d5 = buffd[2 * i + 5]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - d2 = vis_fpadd16(d2, d02); - d2 = vis_fpadd16(d2, d12); - d2 = vis_fpadd16(d2, d22); - d3 = vis_fpadd16(d3, d03); - d3 = vis_fpadd16(d3, d13); - d3 = vis_fpadd16(d3, d23); - d4 = vis_fpadd16(d4, d04); - d4 = vis_fpadd16(d4, d14); - d4 = vis_fpadd16(d4, d24); - d5 = vis_fpadd16(d5, d05); - d5 = vis_fpadd16(d5, d15); - d5 = vis_fpadd16(d5, d25); - - buffe[i] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - buffd[2 * i] = drnd; - buffd[2 * i + 1] = drnd; - buffd[2 * i + 2] = drnd; - buffd[2 * i + 3] = drnd; - buffd[2 * i + 4] = drnd; - buffd[2 * i + 5] = drnd; - - LOAD_SRC(); - } - - ColorTrue2IndexLine((void *)buffe, dl, wid, colormap); -#endif /* CONV_INDEX */ - - sl += sll; - dl += dll; - - buff_ind++; - - if (buff_ind >= (KSIZE + 1)) - buff_ind = 0; - } - - mlib_free(pbuff); - - return MLIB_SUCCESS; -} - -/***************************************************************/ -#undef KSIZE #define MAX_N 11 -#ifdef CONV_INDEX - -mlib_status mlib_convMxN_Index3_8_8nw(mlib_image *dst, - const mlib_image *src, - mlib_s32 m, - mlib_s32 n, - mlib_s32 dm, - mlib_s32 dn, - const mlib_s32 *kern, - mlib_s32 scale, - const void *colormap) -#else - mlib_status mlib_convMxN_8nw_f(mlib_image *dst, const mlib_image *src, mlib_s32 m, @@ -863,7 +83,6 @@ mlib_status mlib_convMxN_8nw_f(mlib_image *dst, mlib_s32 dn, const mlib_s32 *kern, mlib_s32 scale) -#endif /* CONV_INDEX */ { mlib_d64 *buffs_local[3 * (MAX_N + 1)], **buffs = buffs_local, **buff; mlib_d64 *buff0, *buff1, *buff2, *buff3, *buffn, *buffd, *buffe; @@ -884,11 +103,7 @@ mlib_status mlib_convMxN_8nw_f(mlib_image *dst, buff = buffs + 2 * (n + 1); sl = adr_src; -#ifdef CONV_INDEX - dl = adr_dst + dn * dll + dm; -#else dl = adr_dst + dn * dll + dm * NCHAN; -#endif /* CONV_INDEX */ ssize = NCHAN * wid; dsize = (ssize + 7) / 8; @@ -919,17 +134,8 @@ mlib_status mlib_convMxN_8nw_f(mlib_image *dst, mlib_d64 *buffn = buffs[l]; sp = sl + l * sll; -#ifndef CONV_INDEX - if ((mlib_addr) sp & 7) mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize); -#else -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - LOAD_SRC(); - } - -#endif /* CONV_INDEX */ } /* init buffer */ @@ -950,7 +156,6 @@ mlib_status mlib_convMxN_8nw_f(mlib_image *dst, buffn = buffc[n]; -#ifndef CONV_INDEX for (l = 0; l < n; l++) { if ((((mlib_addr) (sl + l * sll)) & 7) == 0) buff[l] = (mlib_d64 *) (sl + l * sll); @@ -958,31 +163,18 @@ mlib_status mlib_convMxN_8nw_f(mlib_image *dst, if ((mlib_addr) sp & 7) mlib_ImageCopy_na((void *)sp, (void *)buffn, ssize); -#endif /* CONV_INDEX */ -#ifdef CONV_INDEX - ik_last = 0; -#else ik_last = (m - 1); -#endif /* CONV_INDEX */ for (jk = 0; jk < n; jk += jk_size) { jk_size = n - jk; -#ifdef CONV_INDEX - - if (jk_size >= 5) - jk_size = 3; - - if (jk_size == 4) - jk_size = 2; -#else if (jk_size >= 6) jk_size = 4; if (jk_size == 5) jk_size = 3; -#endif /* CONV_INDEX */ + coff = 0; if (jk_size == 1) { @@ -1335,21 +527,12 @@ mlib_status mlib_convMxN_8nw_f(mlib_image *dst, *****************************************/ jk_size = n; -#ifdef CONV_INDEX - - if (jk_size >= 5) - jk_size = 3; - - if (jk_size == 4) - jk_size = 2; -#else if (jk_size >= 6) jk_size = 4; if (jk_size == 5) jk_size = 3; -#endif /* CONV_INDEX */ k0 = karr[ik_last]; k1 = karr[ik_last + m]; @@ -1365,8 +548,6 @@ mlib_status mlib_convMxN_8nw_f(mlib_image *dst, buff3 = buff[3] + doff; vis_write_gsr(gsr_scale + off); -#ifndef CONV_INDEX - if (jk_size == 1) { dp = ((mlib_addr) dl & 7) ? buffe : (mlib_d64 *) dl; @@ -1652,200 +833,6 @@ mlib_status mlib_convMxN_8nw_f(mlib_image *dst, mlib_ImageCopy_na((void *)buffe, dl, xsize); } -#else /* CONV_INDEX */ - - if (jk_size == 1) { - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - - d0 = buffd[2 * i]; - d1 = buffd[2 * i + 1]; - d2 = buffd[2 * i + 2]; - d3 = buffd[2 * i + 3]; - d4 = buffd[2 * i + 4]; - d5 = buffd[2 * i + 5]; - d0 = vis_fpadd16(d0, d00); - d1 = vis_fpadd16(d1, d01); - d2 = vis_fpadd16(d2, d02); - d3 = vis_fpadd16(d3, d03); - d4 = vis_fpadd16(d4, d04); - d5 = vis_fpadd16(d5, d05); - - buffe[i] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - buffd[2 * i] = drnd; - buffd[2 * i + 1] = drnd; - buffd[2 * i + 2] = drnd; - buffd[2 * i + 3] = drnd; - buffd[2 * i + 4] = drnd; - buffd[2 * i + 5] = drnd; - - LOAD_SRC(); - } - } - else if (jk_size == 2) { - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - mlib_d64 s10 = buff1[i]; - mlib_d64 s11 = buff1[i + 1]; - mlib_d64 s12 = buff1[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - d10 = vis_fmul8x16au(vis_read_hi(s10), k1); - d11 = vis_fmul8x16au(vis_read_lo(s10), k1); - d12 = vis_fmul8x16au(vis_read_hi(s11), k1); - d13 = vis_fmul8x16au(vis_read_lo(s11), k1); - d14 = vis_fmul8x16au(vis_read_hi(s12), k1); - d15 = vis_fmul8x16au(vis_read_lo(s12), k1); - - d0 = buffd[2 * i]; - d1 = buffd[2 * i + 1]; - d2 = buffd[2 * i + 2]; - d3 = buffd[2 * i + 3]; - d4 = buffd[2 * i + 4]; - d5 = buffd[2 * i + 5]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d2 = vis_fpadd16(d2, d02); - d2 = vis_fpadd16(d2, d12); - d3 = vis_fpadd16(d3, d03); - d3 = vis_fpadd16(d3, d13); - d4 = vis_fpadd16(d4, d04); - d4 = vis_fpadd16(d4, d14); - d5 = vis_fpadd16(d5, d05); - d5 = vis_fpadd16(d5, d15); - - buffe[i] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - buffd[2 * i] = drnd; - buffd[2 * i + 1] = drnd; - buffd[2 * i + 2] = drnd; - buffd[2 * i + 3] = drnd; - buffd[2 * i + 4] = drnd; - buffd[2 * i + 5] = drnd; - - LOAD_SRC(); - } - } - else { /* if (jk_size == 3) */ - - vis_write_gsr(gsr_scale + 7); - -#pragma pipeloop(0) - for (i = 0; i < dsize; i += 3) { - mlib_d64 d00, d01, d02, d03, d04, d05; - mlib_d64 d10, d11, d12, d13, d14, d15; - mlib_d64 d20, d21, d22, d23, d24, d25; - mlib_d64 d0, d1, d2, d3, d4, d5; - mlib_d64 s00 = buff0[i]; - mlib_d64 s01 = buff0[i + 1]; - mlib_d64 s02 = buff0[i + 2]; - mlib_d64 s10 = buff1[i]; - mlib_d64 s11 = buff1[i + 1]; - mlib_d64 s12 = buff1[i + 2]; - mlib_d64 s20 = buff2[i]; - mlib_d64 s21 = buff2[i + 1]; - mlib_d64 s22 = buff2[i + 2]; - - d00 = vis_fmul8x16au(vis_read_hi(s00), k0); - d01 = vis_fmul8x16au(vis_read_lo(s00), k0); - d02 = vis_fmul8x16au(vis_read_hi(s01), k0); - d03 = vis_fmul8x16au(vis_read_lo(s01), k0); - d04 = vis_fmul8x16au(vis_read_hi(s02), k0); - d05 = vis_fmul8x16au(vis_read_lo(s02), k0); - d10 = vis_fmul8x16au(vis_read_hi(s10), k1); - d11 = vis_fmul8x16au(vis_read_lo(s10), k1); - d12 = vis_fmul8x16au(vis_read_hi(s11), k1); - d13 = vis_fmul8x16au(vis_read_lo(s11), k1); - d14 = vis_fmul8x16au(vis_read_hi(s12), k1); - d15 = vis_fmul8x16au(vis_read_lo(s12), k1); - d20 = vis_fmul8x16au(vis_read_hi(s20), k2); - d21 = vis_fmul8x16au(vis_read_lo(s20), k2); - d22 = vis_fmul8x16au(vis_read_hi(s21), k2); - d23 = vis_fmul8x16au(vis_read_lo(s21), k2); - d24 = vis_fmul8x16au(vis_read_hi(s22), k2); - d25 = vis_fmul8x16au(vis_read_lo(s22), k2); - - d0 = buffd[2 * i]; - d1 = buffd[2 * i + 1]; - d2 = buffd[2 * i + 2]; - d3 = buffd[2 * i + 3]; - d4 = buffd[2 * i + 4]; - d5 = buffd[2 * i + 5]; - d0 = vis_fpadd16(d0, d00); - d0 = vis_fpadd16(d0, d10); - d0 = vis_fpadd16(d0, d20); - d1 = vis_fpadd16(d1, d01); - d1 = vis_fpadd16(d1, d11); - d1 = vis_fpadd16(d1, d21); - d2 = vis_fpadd16(d2, d02); - d2 = vis_fpadd16(d2, d12); - d2 = vis_fpadd16(d2, d22); - d3 = vis_fpadd16(d3, d03); - d3 = vis_fpadd16(d3, d13); - d3 = vis_fpadd16(d3, d23); - d4 = vis_fpadd16(d4, d04); - d4 = vis_fpadd16(d4, d14); - d4 = vis_fpadd16(d4, d24); - d5 = vis_fpadd16(d5, d05); - d5 = vis_fpadd16(d5, d15); - d5 = vis_fpadd16(d5, d25); - - buffe[i] = vis_fpack16_pair(d0, d1); - buffe[i + 1] = vis_fpack16_pair(d2, d3); - buffe[i + 2] = vis_fpack16_pair(d4, d5); - - buffd[2 * i] = drnd; - buffd[2 * i + 1] = drnd; - buffd[2 * i + 2] = drnd; - buffd[2 * i + 3] = drnd; - buffd[2 * i + 4] = drnd; - buffd[2 * i + 5] = drnd; - - LOAD_SRC(); - } - } - -#endif /* CONV_INDEX */ - -#ifdef CONV_INDEX - ColorTrue2IndexLine((void *)buffe, dl, wid, colormap); -#endif /* CONV_INDEX */ - sl += sll; dl += dll; -- GitLab From 7a40b8d5f7c69da28c5ebbbddfebdc84f08adf65 Mon Sep 17 00:00:00 2001 From: Dmitry Markov Date: Fri, 13 May 2016 12:44:53 +0300 Subject: [PATCH 067/400] 8155001: SystemTray.remove() leaks GDI Objects in Windows Reviewed-by: serb, alexp --- .../windows/native/libawt/windows/awt_TrayIcon.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp index 56280a583ac..b7ec441d556 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_TrayIcon.cpp @@ -93,6 +93,12 @@ AwtTrayIcon::~AwtTrayIcon() { void AwtTrayIcon::Dispose() { SendTrayMessage(NIM_DELETE); + + // Destroy the icon to avoid leak of GDI objects + if (m_nid.hIcon != NULL) { + ::DestroyIcon(m_nid.hIcon); + } + UnlinkObjects(); if (--sm_instCount == 0) { -- GitLab From 33bb9220fc7d003d9fdaa4c9b216406f5ea9f163 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 17 May 2016 22:28:00 +0300 Subject: [PATCH 068/400] 8157171: Hook up Unsafe.weakCompareAndSetVolatile to VarHandles Reviewed-by: psandoz, redestad --- .../lang/invoke/X-VarHandle.java.template | 9 +-- .../X-VarHandleByteArrayView.java.template | 6 +- .../VarHandles/VarHandleTestAccessInt.java | 53 ++++++++++--- .../VarHandles/VarHandleTestAccessLong.java | 53 ++++++++++--- .../VarHandles/VarHandleTestAccessString.java | 53 ++++++++++--- .../VarHandleTestMethodHandleAccessInt.java | 48 +++++++++--- .../VarHandleTestMethodHandleAccessLong.java | 48 +++++++++--- ...VarHandleTestMethodHandleAccessString.java | 48 +++++++++--- .../X-VarHandleTestAccess.java.template | 74 ++++++++++++++++--- ...HandleTestMethodHandleAccess.java.template | 48 +++++++++--- 10 files changed, 358 insertions(+), 82 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template index 17858a35c94..ebb6dd31b79 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandle.java.template @@ -165,8 +165,7 @@ final class VarHandle$Type$s { @ForceInline static boolean weakCompareAndSetVolatile(FieldInstanceReadWrite handle, Object holder, $type$ expected, $type$ value) { - // TODO defer to strong form until new Unsafe method is added - return UNSAFE.compareAndSwap$Type$(Objects.requireNonNull(handle.receiverType.cast(holder)), + return UNSAFE.weakCompareAndSwap$Type$Volatile(Objects.requireNonNull(handle.receiverType.cast(holder)), handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -347,8 +346,7 @@ final class VarHandle$Type$s { @ForceInline static boolean weakCompareAndSetVolatile(FieldStaticReadWrite handle, $type$ expected, $type$ value) { - // TODO defer to strong form until new Unsafe method is added - return UNSAFE.compareAndSwap$Type$(handle.base, + return UNSAFE.weakCompareAndSwap$Type$Volatile(handle.base, handle.fieldOffset, {#if[Object]?handle.fieldType.cast(expected):expected}, {#if[Object]?handle.fieldType.cast(value):value}); @@ -583,8 +581,7 @@ final class VarHandle$Type$s { #else[Object] $type$[] array = ($type$[]) oarray; #end[Object] - // TODO defer to strong form until new Unsafe method is added - return UNSAFE.compareAndSwap$Type$(array, + return UNSAFE.weakCompareAndSwap$Type$Volatile(array, (((long) Preconditions.checkIndex(index, array.length, AIOOBE_SUPPLIER)) << handle.ashift) + handle.abase, {#if[Object]?handle.componentType.cast(expected):expected}, {#if[Object]?handle.componentType.cast(value):value}); diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template index e3051a5cde8..a24e6c82186 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template @@ -234,8 +234,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static boolean weakCompareAndSetVolatile(ArrayHandle handle, Object oba, int index, $type$ expected, $type$ value) { byte[] ba = (byte[]) oba; - // TODO defer to strong form until new Unsafe method is added - return UNSAFE.compareAndSwap$RawType$( + return UNSAFE.weakCompareAndSwap$RawType$Volatile( ba, address(ba, index(ba, index)), convEndian(handle.be, expected), convEndian(handle.be, value)); @@ -467,8 +466,7 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { @ForceInline static boolean weakCompareAndSetVolatile(ByteBufferHandle handle, Object obb, int index, $type$ expected, $type$ value) { ByteBuffer bb = (ByteBuffer) obb; - // TODO defer to strong form until new Unsafe method is added - return UNSAFE.compareAndSwap$RawType$( + return UNSAFE.weakCompareAndSwap$RawType$Volatile( UNSAFE.getObject(bb, BYTE_BUFFER_HB), address(bb, indexRO(bb, index)), convEndian(handle.be, expected), convEndian(handle.be, value)); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java index 8f58d08ec35..3adb9b83fa7 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java @@ -105,6 +105,7 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -431,12 +432,22 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { assertEquals(x, 2, "weakCompareAndSetRelease int"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetVolatile(recv, 2, 1); + } + assertEquals(success, true, "weakCompareAndSetVolatile int"); + int x = (int) vh.get(recv); + assertEquals(x, 1, "weakCompareAndSetVolatile int value"); + } + // Compare set and get { - int o = (int) vh.getAndSet(recv, 1); - assertEquals(o, 2, "getAndSet int"); + int o = (int) vh.getAndSet(recv, 2); + assertEquals(o, 1, "getAndSet int"); int x = (int) vh.get(recv); - assertEquals(x, 1, "getAndSet int value"); + assertEquals(x, 2, "getAndSet int value"); } vh.set(recv, 1); @@ -574,12 +585,22 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { assertEquals(x, 2, "weakCompareAndSetRelease int"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(2, 1); + } + assertEquals(success, true, "weakCompareAndSetVolatile int"); + int x = (int) vh.get(); + assertEquals(x, 1, "weakCompareAndSetVolatile int"); + } + // Compare set and get { - int o = (int) vh.getAndSet( 1); - assertEquals(o, 2, "getAndSet int"); + int o = (int) vh.getAndSet(2); + assertEquals(o, 1, "getAndSet int"); int x = (int) vh.get(); - assertEquals(x, 1, "getAndSet int value"); + assertEquals(x, 2, "getAndSet int value"); } vh.set(1); @@ -720,12 +741,22 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { assertEquals(x, 2, "weakCompareAndSetRelease int"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetVolatile(array, i, 2, 1); + } + assertEquals(success, true, "weakCompareAndSetVolatile int"); + int x = (int) vh.get(array, i); + assertEquals(x, 1, "weakCompareAndSetVolatile int"); + } + // Compare set and get { - int o = (int) vh.getAndSet(array, i, 1); - assertEquals(o, 2, "getAndSet int"); + int o = (int) vh.getAndSet(array, i, 2); + assertEquals(o, 1, "getAndSet int"); int x = (int) vh.get(array, i); - assertEquals(x, 1, "getAndSet int value"); + assertEquals(x, 2, "getAndSet int value"); } vh.set(array, i, 1); @@ -805,6 +836,10 @@ public class VarHandleTestAccessInt extends VarHandleBaseTest { boolean r = vh.weakCompareAndSet(array, ci, 1, 2); }); + checkIOOBE(() -> { + boolean r = vh.weakCompareAndSetVolatile(array, ci, 1, 2); + }); + checkIOOBE(() -> { boolean r = vh.weakCompareAndSetAcquire(array, ci, 1, 2); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java index 5643a0d6def..9afb2de8320 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java @@ -105,6 +105,7 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -431,12 +432,22 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { assertEquals(x, 2L, "weakCompareAndSetRelease long"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetVolatile(recv, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetVolatile long"); + long x = (long) vh.get(recv); + assertEquals(x, 1L, "weakCompareAndSetVolatile long value"); + } + // Compare set and get { - long o = (long) vh.getAndSet(recv, 1L); - assertEquals(o, 2L, "getAndSet long"); + long o = (long) vh.getAndSet(recv, 2L); + assertEquals(o, 1L, "getAndSet long"); long x = (long) vh.get(recv); - assertEquals(x, 1L, "getAndSet long value"); + assertEquals(x, 2L, "getAndSet long value"); } vh.set(recv, 1L); @@ -574,12 +585,22 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { assertEquals(x, 2L, "weakCompareAndSetRelease long"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease(2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetVolatile long"); + long x = (long) vh.get(); + assertEquals(x, 1L, "weakCompareAndSetVolatile long"); + } + // Compare set and get { - long o = (long) vh.getAndSet( 1L); - assertEquals(o, 2L, "getAndSet long"); + long o = (long) vh.getAndSet(2L); + assertEquals(o, 1L, "getAndSet long"); long x = (long) vh.get(); - assertEquals(x, 1L, "getAndSet long value"); + assertEquals(x, 2L, "getAndSet long value"); } vh.set(1L); @@ -720,12 +741,22 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { assertEquals(x, 2L, "weakCompareAndSetRelease long"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetVolatile(array, i, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetVolatile long"); + long x = (long) vh.get(array, i); + assertEquals(x, 1L, "weakCompareAndSetVolatile long"); + } + // Compare set and get { - long o = (long) vh.getAndSet(array, i, 1L); - assertEquals(o, 2L, "getAndSet long"); + long o = (long) vh.getAndSet(array, i, 2L); + assertEquals(o, 1L, "getAndSet long"); long x = (long) vh.get(array, i); - assertEquals(x, 1L, "getAndSet long value"); + assertEquals(x, 2L, "getAndSet long value"); } vh.set(array, i, 1L); @@ -805,6 +836,10 @@ public class VarHandleTestAccessLong extends VarHandleBaseTest { boolean r = vh.weakCompareAndSet(array, ci, 1L, 2L); }); + checkIOOBE(() -> { + boolean r = vh.weakCompareAndSetVolatile(array, ci, 1L, 2L); + }); + checkIOOBE(() -> { boolean r = vh.weakCompareAndSetAcquire(array, ci, 1L, 2L); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java index b16c9340519..74f08bda535 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java @@ -105,6 +105,7 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -445,12 +446,22 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { assertEquals(x, "bar", "weakCompareAndSetRelease String"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetVolatile(recv, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetVolatile String"); + String x = (String) vh.get(recv); + assertEquals(x, "foo", "weakCompareAndSetVolatile String value"); + } + // Compare set and get { - String o = (String) vh.getAndSet(recv, "foo"); - assertEquals(o, "bar", "getAndSet String"); + String o = (String) vh.getAndSet(recv, "bar"); + assertEquals(o, "foo", "getAndSet String"); String x = (String) vh.get(recv); - assertEquals(x, "foo", "getAndSet String value"); + assertEquals(x, "bar", "getAndSet String value"); } } @@ -586,12 +597,22 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { assertEquals(x, "bar", "weakCompareAndSetRelease String"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease("bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetVolatile String"); + String x = (String) vh.get(); + assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + } + // Compare set and get { - String o = (String) vh.getAndSet( "foo"); - assertEquals(o, "bar", "getAndSet String"); + String o = (String) vh.getAndSet("bar"); + assertEquals(o, "foo", "getAndSet String"); String x = (String) vh.get(); - assertEquals(x, "foo", "getAndSet String value"); + assertEquals(x, "bar", "getAndSet String value"); } } @@ -730,12 +751,22 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { assertEquals(x, "bar", "weakCompareAndSetRelease String"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetVolatile(array, i, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetVolatile String"); + String x = (String) vh.get(array, i); + assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + } + // Compare set and get { - String o = (String) vh.getAndSet(array, i, "foo"); - assertEquals(o, "bar", "getAndSet String"); + String o = (String) vh.getAndSet(array, i, "bar"); + assertEquals(o, "foo", "getAndSet String"); String x = (String) vh.get(array, i); - assertEquals(x, "foo", "getAndSet String value"); + assertEquals(x, "bar", "getAndSet String value"); } } @@ -813,6 +844,10 @@ public class VarHandleTestAccessString extends VarHandleBaseTest { boolean r = vh.weakCompareAndSet(array, ci, "foo", "bar"); }); + checkIOOBE(() -> { + boolean r = vh.weakCompareAndSetVolatile(array, ci, "foo", "bar"); + }); + checkIOOBE(() -> { boolean r = vh.weakCompareAndSetAcquire(array, ci, "foo", "bar"); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java index 98d5be5ef71..fc0e8f214f9 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java @@ -238,12 +238,22 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { assertEquals(x, 2, "weakCompareAndSetRelease int"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2, 1); + } + assertEquals(success, true, "weakCompareAndSetVolatile int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, 1, "weakCompareAndSetVolatile int"); + } + // Compare set and get { - int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, 1); - assertEquals(o, 2, "getAndSet int"); + int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, 2); + assertEquals(o, 1, "getAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 1, "getAndSet int value"); + assertEquals(x, 2, "getAndSet int value"); } hs.get(TestAccessMode.SET).invokeExact(recv, 1); @@ -381,12 +391,22 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { assertEquals(x, 2, "weakCompareAndSetRelease int"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2, 1); + } + assertEquals(success, true, "weakCompareAndSetVolatile int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 1, "weakCompareAndSetVolatile int"); + } + // Compare set and get { - int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 1); - assertEquals(o, 2, "getAndSet int"); + int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 2); + assertEquals(o, 1, "getAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 1, "getAndSet int value"); + assertEquals(x, 2, "getAndSet int value"); } hs.get(TestAccessMode.SET).invokeExact(1); @@ -527,12 +547,22 @@ public class VarHandleTestMethodHandleAccessInt extends VarHandleBaseTest { assertEquals(x, 2, "weakCompareAndSetRelease int"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2, 1); + } + assertEquals(success, true, "weakCompareAndSetVolatile int"); + int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 1, "weakCompareAndSetVolatile int"); + } + // Compare set and get { - int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 1); - assertEquals(o, 2, "getAndSet int"); + int o = (int) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 2); + assertEquals(o, 1, "getAndSet int"); int x = (int) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 1, "getAndSet int value"); + assertEquals(x, 2, "getAndSet int value"); } hs.get(TestAccessMode.SET).invokeExact(array, i, 1); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java index 3ee73eb8d07..0f265da3f2e 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java @@ -238,12 +238,22 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { assertEquals(x, 2L, "weakCompareAndSetRelease long"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetVolatile long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, 1L, "weakCompareAndSetVolatile long"); + } + // Compare set and get { - long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, 1L); - assertEquals(o, 2L, "getAndSet long"); + long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, 2L); + assertEquals(o, 1L, "getAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, 1L, "getAndSet long value"); + assertEquals(x, 2L, "getAndSet long value"); } hs.get(TestAccessMode.SET).invokeExact(recv, 1L); @@ -381,12 +391,22 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { assertEquals(x, 2L, "weakCompareAndSetRelease long"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetVolatile long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, 1L, "weakCompareAndSetVolatile long"); + } + // Compare set and get { - long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 1L); - assertEquals(o, 2L, "getAndSet long"); + long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact( 2L); + assertEquals(o, 1L, "getAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, 1L, "getAndSet long value"); + assertEquals(x, 2L, "getAndSet long value"); } hs.get(TestAccessMode.SET).invokeExact(1L); @@ -527,12 +547,22 @@ public class VarHandleTestMethodHandleAccessLong extends VarHandleBaseTest { assertEquals(x, 2L, "weakCompareAndSetRelease long"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSetVolatile long"); + long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, 1L, "weakCompareAndSetVolatile long"); + } + // Compare set and get { - long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 1L); - assertEquals(o, 2L, "getAndSet long"); + long o = (long) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, 2L); + assertEquals(o, 1L, "getAndSet long"); long x = (long) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, 1L, "getAndSet long value"); + assertEquals(x, 2L, "getAndSet long value"); } hs.get(TestAccessMode.SET).invokeExact(array, i, 1L); diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java index 9453484c603..ce5167a0b91 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java @@ -238,12 +238,22 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { assertEquals(x, "bar", "weakCompareAndSetRelease String"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetVolatile String"); + String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + } + // Compare set and get { - String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, "foo"); - assertEquals(o, "bar", "getAndSet String"); + String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, "bar"); + assertEquals(o, "foo", "getAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, "foo", "getAndSet String value"); + assertEquals(x, "bar", "getAndSet String value"); } } @@ -377,12 +387,22 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { assertEquals(x, "bar", "weakCompareAndSetRelease String"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact("bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetVolatile String"); + String x = (String) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + } + // Compare set and get { - String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact( "foo"); - assertEquals(o, "bar", "getAndSet String"); + String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact( "bar"); + assertEquals(o, "foo", "getAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, "foo", "getAndSet String value"); + assertEquals(x, "bar", "getAndSet String value"); } } @@ -519,12 +539,22 @@ public class VarHandleTestMethodHandleAccessString extends VarHandleBaseTest { assertEquals(x, "bar", "weakCompareAndSetRelease String"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSetVolatile String"); + String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, "foo", "weakCompareAndSetVolatile String"); + } + // Compare set and get { - String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, "foo"); - assertEquals(o, "bar", "getAndSet String"); + String o = (String) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, "bar"); + assertEquals(o, "foo", "getAndSet String"); String x = (String) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, "foo", "getAndSet String value"); + assertEquals(x, "bar", "getAndSet String value"); } } diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template index 1f21e430a83..cb33f8ff070 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template @@ -106,6 +106,7 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); + assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertTrue(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -115,6 +116,7 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.COMPARE_AND_EXCHANGE_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET)); + assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_VOLATILE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_ACQUIRE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.WEAK_COMPARE_AND_SET_RELEASE)); assertFalse(vh.isAccessModeSupported(VarHandle.AccessMode.GET_AND_SET)); @@ -297,6 +299,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$); }); + checkUOE(() -> { + boolean r = vh.weakCompareAndSetVolatile(recv, $value1$, $value2$); + }); + checkUOE(() -> { boolean r = vh.weakCompareAndSetAcquire(recv, $value1$, $value2$); }); @@ -387,6 +393,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { boolean r = vh.weakCompareAndSet($value1$, $value2$); }); + checkUOE(() -> { + boolean r = vh.weakCompareAndSetVolatile($value1$, $value2$); + }); + checkUOE(() -> { boolean r = vh.weakCompareAndSetAcquire($value1$, $value2$); }); @@ -532,12 +542,22 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetVolatile(recv, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + $type$ x = ($type$) vh.get(recv); + assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$ value"); + } + // Compare set and get { - $type$ o = ($type$) vh.getAndSet(recv, $value1$); - assertEquals(o, $value2$, "getAndSet $type$"); + $type$ o = ($type$) vh.getAndSet(recv, $value2$); + assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) vh.get(recv); - assertEquals(x, $value1$, "getAndSet $type$ value"); + assertEquals(x, $value2$, "getAndSet $type$ value"); } #end[CAS] @@ -576,6 +596,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { boolean r = vh.weakCompareAndSet(recv, $value1$, $value2$); }); + checkUOE(() -> { + boolean r = vh.weakCompareAndSetVolatile(recv, $value1$, $value2$); + }); + checkUOE(() -> { boolean r = vh.weakCompareAndSetAcquire(recv, $value1$, $value2$); }); @@ -721,12 +745,22 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetRelease($value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + $type$ x = ($type$) vh.get(); + assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + } + // Compare set and get { - $type$ o = ($type$) vh.getAndSet( $value1$); - assertEquals(o, $value2$, "getAndSet $type$"); + $type$ o = ($type$) vh.getAndSet($value2$); + assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) vh.get(); - assertEquals(x, $value1$, "getAndSet $type$ value"); + assertEquals(x, $value2$, "getAndSet $type$ value"); } #end[CAS] @@ -765,6 +799,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { boolean r = vh.weakCompareAndSet($value1$, $value2$); }); + checkUOE(() -> { + boolean r = vh.weakCompareAndSetVolatile($value1$, $value2$); + }); + checkUOE(() -> { boolean r = vh.weakCompareAndSetAcquire($value1$, $value2$); }); @@ -913,12 +951,22 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = vh.weakCompareAndSetVolatile(array, i, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + $type$ x = ($type$) vh.get(array, i); + assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + } + // Compare set and get { - $type$ o = ($type$) vh.getAndSet(array, i, $value1$); - assertEquals(o, $value2$, "getAndSet $type$"); + $type$ o = ($type$) vh.getAndSet(array, i, $value2$); + assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) vh.get(array, i); - assertEquals(x, $value1$, "getAndSet $type$ value"); + assertEquals(x, $value2$, "getAndSet $type$ value"); } #end[CAS] @@ -961,6 +1009,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { boolean r = vh.weakCompareAndSet(array, i, $value1$, $value2$); }); + checkUOE(() -> { + boolean r = vh.weakCompareAndSetVolatile(array, i, $value1$, $value2$); + }); + checkUOE(() -> { boolean r = vh.weakCompareAndSetAcquire(array, i, $value1$, $value2$); }); @@ -1044,6 +1096,10 @@ public class VarHandleTestAccess$Type$ extends VarHandleBaseTest { boolean r = vh.weakCompareAndSet(array, ci, $value1$, $value2$); }); + checkIOOBE(() -> { + boolean r = vh.weakCompareAndSetVolatile(array, ci, $value1$, $value2$); + }); + checkIOOBE(() -> { boolean r = vh.weakCompareAndSetAcquire(array, ci, $value1$, $value2$); }); diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template index 1b3e4cfc370..f943bf2611b 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template @@ -239,12 +239,22 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(recv, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); + assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + } + // Compare set and get { - $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, $value1$); - assertEquals(o, $value2$, "getAndSet $type$"); + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(recv, $value2$); + assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(recv); - assertEquals(x, $value1$, "getAndSet $type$ value"); + assertEquals(x, $value2$, "getAndSet $type$ value"); } #end[CAS] @@ -412,12 +422,22 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact($value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); + assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + } + // Compare set and get { - $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact( $value1$); - assertEquals(o, $value2$, "getAndSet $type$"); + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact( $value2$); + assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(); - assertEquals(x, $value1$, "getAndSet $type$ value"); + assertEquals(x, $value2$, "getAndSet $type$ value"); } #end[CAS] @@ -588,12 +608,22 @@ public class VarHandleTestMethodHandleAccess$Type$ extends VarHandleBaseTest { assertEquals(x, $value2$, "weakCompareAndSetRelease $type$"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = (boolean) hs.get(TestAccessMode.WEAK_COMPARE_AND_SET_VOLATILE).invokeExact(array, i, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSetVolatile $type$"); + $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); + assertEquals(x, $value1$, "weakCompareAndSetVolatile $type$"); + } + // Compare set and get { - $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, $value1$); - assertEquals(o, $value2$, "getAndSet $type$"); + $type$ o = ($type$) hs.get(TestAccessMode.GET_AND_SET).invokeExact(array, i, $value2$); + assertEquals(o, $value1$, "getAndSet $type$"); $type$ x = ($type$) hs.get(TestAccessMode.GET).invokeExact(array, i); - assertEquals(x, $value1$, "getAndSet $type$ value"); + assertEquals(x, $value2$, "getAndSet $type$ value"); } #end[CAS] -- GitLab From 9cdeece6b6a4e0785c3247e90edad3ed73ce2bc6 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Tue, 17 May 2016 16:04:53 -0700 Subject: [PATCH 069/400] 8130679: Writer/StringWriter.write methods do not specify index out bounds Add throws tag indicating IndexOutOfBoundsExcepion to write() methods which have an index parameter. Reviewed-by: chegar, prappo, rriggs --- .../share/classes/java/io/BufferedWriter.java | 30 +++++++++++++------ .../classes/java/io/CharArrayWriter.java | 12 +++++++- .../share/classes/java/io/FilterWriter.java | 16 ++++++++-- .../classes/java/io/OutputStreamWriter.java | 16 ++++++++-- .../share/classes/java/io/PipedWriter.java | 18 +++++++---- .../share/classes/java/io/PrintWriter.java | 12 +++++++- .../share/classes/java/io/StringWriter.java | 12 +++++++- .../share/classes/java/io/Writer.java | 21 +++++++++---- 8 files changed, 108 insertions(+), 29 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/io/BufferedWriter.java b/jdk/src/java.base/share/classes/java/io/BufferedWriter.java index 28e170fe800..3d8e1ee1b19 100644 --- a/jdk/src/java.base/share/classes/java/io/BufferedWriter.java +++ b/jdk/src/java.base/share/classes/java/io/BufferedWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -153,13 +153,18 @@ public class BufferedWriter extends Writer { * needed. If the requested length is at least as large as the buffer, * however, then this method will flush the buffer and write the characters * directly to the underlying stream. Thus redundant - * BufferedWriters will not copy data unnecessarily. + * {@code BufferedWriter}s will not copy data unnecessarily. * * @param cbuf A character array * @param off Offset from which to start reading characters * @param len Number of characters to write * - * @exception IOException If an I/O error occurs + * @throws IndexOutOfBoundsException + * If {@code off} is negative, or {@code len} is negative, + * or {@code off + len} is negative or greater than the length + * of the given array + * + * @throws IOException If an I/O error occurs */ public void write(char cbuf[], int off, int len) throws IOException { synchronized (lock) { @@ -195,17 +200,24 @@ public class BufferedWriter extends Writer { /** * Writes a portion of a String. * - *

      If the value of the {@code len} parameter is negative then no - * characters are written. This is contrary to the specification of this - * method in the {@linkplain java.io.Writer#write(java.lang.String,int,int) - * superclass}, which requires that an {@link IndexOutOfBoundsException} be - * thrown. + * @implSpec + * While the specification of this method in the + * {@linkplain java.io.Writer#write(java.lang.String,int,int) superclass} + * recommends that an {@link IndexOutOfBoundsException} be thrown + * if {@code len} is negative or {@code off + len} is negative, + * the implementation in this class does not throw such an exception in + * these cases but instead simply writes no characters. * * @param s String to be written * @param off Offset from which to start reading characters * @param len Number of characters to be written * - * @exception IOException If an I/O error occurs + * @throws IndexOutOfBoundsException + * If {@code off} is negative, + * or {@code off + len} is greater than the length + * of the given string + * + * @throws IOException If an I/O error occurs */ public void write(String s, int off, int len) throws IOException { synchronized (lock) { diff --git a/jdk/src/java.base/share/classes/java/io/CharArrayWriter.java b/jdk/src/java.base/share/classes/java/io/CharArrayWriter.java index ed27bbae314..773b59614d9 100644 --- a/jdk/src/java.base/share/classes/java/io/CharArrayWriter.java +++ b/jdk/src/java.base/share/classes/java/io/CharArrayWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -91,6 +91,11 @@ class CharArrayWriter extends Writer { * @param c the data to be written * @param off the start offset in the data * @param len the number of chars that are written + * + * @throws IndexOutOfBoundsException + * If {@code off} is negative, or {@code len} is negative, + * or {@code off + len} is negative or greater than the length + * of the given array */ public void write(char c[], int off, int len) { if ((off < 0) || (off > c.length) || (len < 0) || @@ -114,6 +119,11 @@ class CharArrayWriter extends Writer { * @param str String to be written from * @param off Offset from which to start reading characters * @param len Number of characters to be written + * + * @throws IndexOutOfBoundsException + * If {@code off} is negative, or {@code len} is negative, + * or {@code off + len} is negative or greater than the length + * of the given string */ public void write(String str, int off, int len) { synchronized (lock) { diff --git a/jdk/src/java.base/share/classes/java/io/FilterWriter.java b/jdk/src/java.base/share/classes/java/io/FilterWriter.java index 303c674e0c0..8272b3cc8bf 100644 --- a/jdk/src/java.base/share/classes/java/io/FilterWriter.java +++ b/jdk/src/java.base/share/classes/java/io/FilterWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,7 +72,12 @@ public abstract class FilterWriter extends Writer { * @param off Offset from which to start reading characters * @param len Number of characters to be written * - * @exception IOException If an I/O error occurs + * @throws IndexOutOfBoundsException + * If the values of the {@code off} and {@code len} parameters + * cause the corresponding method of the underlying {@code Writer} + * to throw an {@code IndexOutOfBoundsException} + * + * @throws IOException If an I/O error occurs */ public void write(char cbuf[], int off, int len) throws IOException { out.write(cbuf, off, len); @@ -85,7 +90,12 @@ public abstract class FilterWriter extends Writer { * @param off Offset from which to start reading characters * @param len Number of characters to be written * - * @exception IOException If an I/O error occurs + * @throws IndexOutOfBoundsException + * If the values of the {@code off} and {@code len} parameters + * cause the corresponding method of the underlying {@code Writer} + * to throw an {@code IndexOutOfBoundsException} + * + * @throws IOException If an I/O error occurs */ public void write(String str, int off, int len) throws IOException { out.write(str, off, len); diff --git a/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java b/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java index 0d597e6bef4..4fdb148baaf 100644 --- a/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java +++ b/jdk/src/java.base/share/classes/java/io/OutputStreamWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -202,7 +202,12 @@ public class OutputStreamWriter extends Writer { * @param off Offset from which to start writing characters * @param len Number of characters to write * - * @exception IOException If an I/O error occurs + * @throws IndexOutOfBoundsException + * If {@code off} is negative, or {@code len} is negative, + * or {@code off + len} is negative or greater than the length + * of the given array + * + * @throws IOException If an I/O error occurs */ public void write(char cbuf[], int off, int len) throws IOException { se.write(cbuf, off, len); @@ -215,7 +220,12 @@ public class OutputStreamWriter extends Writer { * @param off Offset from which to start writing characters * @param len Number of characters to write * - * @exception IOException If an I/O error occurs + * @throws IndexOutOfBoundsException + * If {@code off} is negative, or {@code len} is negative, + * or {@code off + len} is negative or greater than the length + * of the given string + * + * @throws IOException If an I/O error occurs */ public void write(String str, int off, int len) throws IOException { se.write(str, off, len); diff --git a/jdk/src/java.base/share/classes/java/io/PipedWriter.java b/jdk/src/java.base/share/classes/java/io/PipedWriter.java index 02201fbec1a..a4534b8604c 100644 --- a/jdk/src/java.base/share/classes/java/io/PipedWriter.java +++ b/jdk/src/java.base/share/classes/java/io/PipedWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -125,19 +125,25 @@ public class PipedWriter extends Writer { } /** - * Writes len characters from the specified character array - * starting at offset off to this piped output stream. + * Writes {@code len} characters from the specified character array + * starting at offset {@code off} to this piped output stream. * This method blocks until all the characters are written to the output * stream. * If a thread was reading data characters from the connected piped input * stream, but the thread is no longer alive, then an - * IOException is thrown. + * {@code IOException} is thrown. * * @param cbuf the data. * @param off the start offset in the data. * @param len the number of characters to write. - * @exception IOException if the pipe is - * broken, + * + * @throws IndexOutOfBoundsException + * If {@code off} is negative, or {@code len} is negative, + * or {@code off + len} is negative or greater than the length + * of the given array + * + * @throws IOException if the pipe is + * broken, * {@link #connect(java.io.PipedReader) unconnected}, closed * or an I/O error occurs. */ diff --git a/jdk/src/java.base/share/classes/java/io/PrintWriter.java b/jdk/src/java.base/share/classes/java/io/PrintWriter.java index 662f930ef90..d516b8ef404 100644 --- a/jdk/src/java.base/share/classes/java/io/PrintWriter.java +++ b/jdk/src/java.base/share/classes/java/io/PrintWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -410,6 +410,11 @@ public class PrintWriter extends Writer { * @param buf Array of characters * @param off Offset from which to start writing characters * @param len Number of characters to write + * + * @throws IndexOutOfBoundsException + * If the values of the {@code off} and {@code len} parameters + * cause the corresponding method of the underlying {@code Writer} + * to throw an {@code IndexOutOfBoundsException} */ public void write(char buf[], int off, int len) { try { @@ -440,6 +445,11 @@ public class PrintWriter extends Writer { * @param s A String * @param off Offset from which to start writing characters * @param len Number of characters to write + * + * @throws IndexOutOfBoundsException + * If the values of the {@code off} and {@code len} parameters + * cause the corresponding method of the underlying {@code Writer} + * to throw an {@code IndexOutOfBoundsException} */ public void write(String s, int off, int len) { try { diff --git a/jdk/src/java.base/share/classes/java/io/StringWriter.java b/jdk/src/java.base/share/classes/java/io/StringWriter.java index 5d1babc3127..15022b353a8 100644 --- a/jdk/src/java.base/share/classes/java/io/StringWriter.java +++ b/jdk/src/java.base/share/classes/java/io/StringWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,6 +83,11 @@ public class StringWriter extends Writer { * @param cbuf Array of characters * @param off Offset from which to start writing characters * @param len Number of characters to write + * + * @throws IndexOutOfBoundsException + * If {@code off} is negative, or {@code len} is negative, + * or {@code off + len} is negative or greater than the length + * of the given array */ public void write(char cbuf[], int off, int len) { if ((off < 0) || (off > cbuf.length) || (len < 0) || @@ -107,6 +112,11 @@ public class StringWriter extends Writer { * @param str String to be written * @param off Offset from which to start writing characters * @param len Number of characters to write + * + * @throws IndexOutOfBoundsException + * If {@code off} is negative, or {@code len} is negative, + * or {@code off + len} is negative or greater than the length + * of the given string */ public void write(String str, int off, int len) { buf.append(str, off, off + len); diff --git a/jdk/src/java.base/share/classes/java/io/Writer.java b/jdk/src/java.base/share/classes/java/io/Writer.java index 5ad5e554fb3..17e8de3ef8a 100644 --- a/jdk/src/java.base/share/classes/java/io/Writer.java +++ b/jdk/src/java.base/share/classes/java/io/Writer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,12 +32,11 @@ package java.io; * Most subclasses, however, will override some of the methods defined here in * order to provide higher efficiency, additional functionality, or both. * - * @see Writer * @see BufferedWriter * @see CharArrayWriter * @see FilterWriter * @see OutputStreamWriter - * @see FileWriter + * @see FileWriter * @see PipedWriter * @see PrintWriter * @see StringWriter @@ -139,6 +138,12 @@ public abstract class Writer implements Appendable, Closeable, Flushable { * @param len * Number of characters to write * + * @throws IndexOutOfBoundsException + * Implementations should throw this exception + * if {@code off} is negative, or {@code len} is negative, + * or {@code off + len} is negative or greater than the length + * of the given array + * * @throws IOException * If an I/O error occurs */ @@ -160,6 +165,11 @@ public abstract class Writer implements Appendable, Closeable, Flushable { /** * Writes a portion of a string. * + * @implSpec + * The implementation in this class throws an + * {@code IndexOutOfBoundsException} for the indicated conditions; + * overriding methods may choose to do otherwise. + * * @param str * A String * @@ -170,8 +180,9 @@ public abstract class Writer implements Appendable, Closeable, Flushable { * Number of characters to write * * @throws IndexOutOfBoundsException - * If {@code off} is negative, or {@code len} is negative, - * or {@code off+len} is negative or greater than the length + * Implementations should throw this exception + * if {@code off} is negative, or {@code len} is negative, + * or {@code off + len} is negative or greater than the length * of the given string * * @throws IOException -- GitLab From 1244c2f423f05ff90c7de7358ef10c6c953193dc Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Tue, 17 May 2016 19:20:05 -0700 Subject: [PATCH 070/400] 8157011: Problem list tools/pack200/TestNormal.java and java/io/pathNames/GeneralWin32.java Reviewed-by: darcy --- jdk/test/ProblemList.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 67dd85fcd17..3766c76ec25 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -145,6 +145,12 @@ java/lang/management/MemoryMXBean/LowMemoryTest.java 8130339 generic- ############################################################################ +# jdk_io + +java/io/pathNames/GeneralWin32.java 8156595 windows-all + +############################################################################ + # jdk_jmx com/sun/management/OperatingSystemMXBean/GetProcessCpuLoad.java 8030957 aix-all @@ -329,6 +335,8 @@ tools/launcher/FXLauncherTest.java 8068049 linux-al tools/pack200/Pack200Props.java 8155857 generic-all +tools/pack200/TestNormal.java 8156807 windows-all + ############################################################################ # jdk_jdi -- GitLab From 2bb441c404b042d9fc79d2d777ff5ae5b7282737 Mon Sep 17 00:00:00 2001 From: Martin Buchholz Date: Mon, 16 May 2016 11:42:31 -0700 Subject: [PATCH 071/400] 8157069: Assorted ZipFile improvements Reviewed-by: sherman --- .../share/classes/java/util/zip/ZipFile.java | 102 +++++++++--------- .../security/util/SignatureFileVerifier.java | 9 +- 2 files changed, 56 insertions(+), 55 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java index 1cba038d6e5..b97d0cf68c6 100644 --- a/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/jdk/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -462,9 +462,13 @@ class ZipFile implements ZipConstants, Closeable { private class ZipEntryIterator implements Enumeration, Iterator { private int i = 0; + private final int entryCount; public ZipEntryIterator() { - ensureOpen(); + synchronized (ZipFile.this) { + ensureOpen(); + this.entryCount = zsrc.total; + } } public boolean hasMoreElements() { @@ -472,10 +476,7 @@ class ZipFile implements ZipConstants, Closeable { } public boolean hasNext() { - synchronized (ZipFile.this) { - ensureOpen(); - return i < zsrc.total; - } + return i < entryCount; } public ZipEntry nextElement() { @@ -485,7 +486,7 @@ class ZipFile implements ZipConstants, Closeable { public ZipEntry next() { synchronized (ZipFile.this) { ensureOpen(); - if (i >= zsrc.total) { + if (!hasNext()) { throw new NoSuchElementException(); } // each "entry" has 3 ints in table entries @@ -526,34 +527,34 @@ class ZipFile implements ZipConstants, Closeable { /* Checks ensureOpen() before invoke this method */ private ZipEntry getZipEntry(String name, int pos) { byte[] cen = zsrc.cen; - ZipEntry e = new ZipEntry(); int nlen = CENNAM(cen, pos); int elen = CENEXT(cen, pos); int clen = CENCOM(cen, pos); - e.flag = CENFLG(cen, pos); // get the flag first - if (name != null) { - e.name = name; - } else { - if (!zc.isUTF8() && (e.flag & EFS) != 0) { - e.name = zc.toStringUTF8(cen, pos + CENHDR, nlen); + int flag = CENFLG(cen, pos); + if (name == null) { + if (!zc.isUTF8() && (flag & EFS) != 0) { + name = zc.toStringUTF8(cen, pos + CENHDR, nlen); } else { - e.name = zc.toString(cen, pos + CENHDR, nlen); + name = zc.toString(cen, pos + CENHDR, nlen); } } + ZipEntry e = new ZipEntry(name); + e.flag = flag; e.xdostime = CENTIM(cen, pos); e.crc = CENCRC(cen, pos); e.size = CENLEN(cen, pos); e.csize = CENSIZ(cen, pos); e.method = CENHOW(cen, pos); if (elen != 0) { - e.setExtra0(Arrays.copyOfRange(cen, pos + CENHDR + nlen, - pos + CENHDR + nlen + elen), true); + int start = pos + CENHDR + nlen; + e.setExtra0(Arrays.copyOfRange(cen, start, start + elen), true); } if (clen != 0) { - if (!zc.isUTF8() && (e.flag & EFS) != 0) { - e.comment = zc.toStringUTF8(cen, pos + CENHDR + nlen + elen, clen); + int start = pos + CENHDR + nlen + elen; + if (!zc.isUTF8() && (flag & EFS) != 0) { + e.comment = zc.toStringUTF8(cen, start, clen); } else { - e.comment = zc.toString(cen, pos + CENHDR + nlen + elen, clen); + e.comment = zc.toString(cen, start, clen); } } return e; @@ -817,7 +818,7 @@ class ZipFile implements ZipConstants, Closeable { ); } - /* + /** * Returns an array of strings representing the names of all entries * that begin with "META-INF/" (case ignored). This method is used * in JarFile, via SharedSecrets, as an optimization when looking up @@ -827,14 +828,14 @@ class ZipFile implements ZipConstants, Closeable { private String[] getMetaInfEntryNames() { synchronized (this) { ensureOpen(); - if (zsrc.metanames.size() == 0) { + if (zsrc.metanames == null) { return null; } - String[] names = new String[zsrc.metanames.size()]; + String[] names = new String[zsrc.metanames.length]; byte[] cen = zsrc.cen; for (int i = 0; i < names.length; i++) { - int pos = zsrc.metanames.get(i); - names[i] = new String(cen, pos + CENHDR, CENNAM(cen, pos), + int pos = zsrc.metanames[i]; + names[i] = new String(cen, pos + CENHDR, CENNAM(cen, pos), StandardCharsets.UTF_8); } return names; @@ -850,7 +851,7 @@ class ZipFile implements ZipConstants, Closeable { private long locpos; // position of first LOC header (usually 0) private byte[] comment; // zip file comment // list of meta entries in META-INF dir - private ArrayList metanames = new ArrayList<>(); + private int[] metanames; private final boolean startsWithLoc; // true, if zip file starts with LOCSIG (usually true) // A Hashmap for all entries. @@ -1159,7 +1160,7 @@ class ZipFile implements ZipConstants, Closeable { int next = -1; // list for all meta entries - metanames = new ArrayList<>(); + ArrayList metanamesList = null; // Iterate through the entries in the central directory int i = 0; @@ -1194,13 +1195,21 @@ class ZipFile implements ZipConstants, Closeable { idx = addEntry(idx, hash, next, pos); // Adds name to metanames. if (isMetaName(cen, pos + CENHDR, nlen)) { - metanames.add(pos); + if (metanamesList == null) + metanamesList = new ArrayList<>(4); + metanamesList.add(pos); } // skip ext and comment pos += (CENHDR + nlen + elen + clen); i++; } total = i; + if (metanamesList != null) { + metanames = new int[metanamesList.size()]; + for (int j = 0, len = metanames.length; j < len; j++) { + metanames[j] = metanamesList.get(j); + } + } if (pos + ENDHDR != cen.length) { zerror("invalid CEN header (bad header size)"); } @@ -1265,30 +1274,23 @@ class ZipFile implements ZipConstants, Closeable { } } - private static byte[] metainf = new byte[] { - 'M', 'E', 'T', 'A', '-', 'I' , 'N', 'F', '/', - }; - - /* - * Returns true if the specified entry's name begins with the string - * "META-INF/" irrespective of case. + /** + * Returns true if the bytes represent a non-directory name + * beginning with "META-INF/", disregarding ASCII case. */ - private static boolean isMetaName(byte[] name, int off, int len) { - if (len < 9 || (name[off] != 'M' && name[off] != 'm')) { // sizeof("META-INF/") - 1 - return false; - } - off++; - for (int i = 1; i < metainf.length; i++) { - byte c = name[off++]; - // Avoid toupper; it's locale-dependent - if (c >= 'a' && c <= 'z') { - c += 'A' - 'a'; - } - if (metainf[i] != c) { - return false; - } - } - return true; + private static boolean isMetaName(byte[] name, int off, int len) { + // Use the "oldest ASCII trick in the book" + return len > 9 // "META-INF/".length() + && name[off + len - 1] != '/' // non-directory + && (name[off++] | 0x20) == 'm' + && (name[off++] | 0x20) == 'e' + && (name[off++] | 0x20) == 't' + && (name[off++] | 0x20) == 'a' + && (name[off++] ) == '-' + && (name[off++] | 0x20) == 'i' + && (name[off++] | 0x20) == 'n' + && (name[off++] | 0x20) == 'f' + && (name[off] ) == '/'; } /* diff --git a/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java b/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java index 20e66d561fb..0bf5fcbe1fc 100644 --- a/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java +++ b/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java @@ -145,11 +145,10 @@ public class SignatureFileVerifier { */ public static boolean isBlockOrSF(String s) { // we currently only support DSA and RSA PKCS7 blocks - if (s.endsWith(".SF") || s.endsWith(".DSA") || - s.endsWith(".RSA") || s.endsWith(".EC")) { - return true; - } - return false; + return s.endsWith(".SF") + || s.endsWith(".DSA") + || s.endsWith(".RSA") + || s.endsWith(".EC"); } /** -- GitLab From c4976196f5938a53ad30e4cde3132a7e238c6bba Mon Sep 17 00:00:00 2001 From: Michael Haupt Date: Wed, 18 May 2016 10:42:29 +0200 Subject: [PATCH 072/400] 8156915: introduce MethodHandle factory for array length Reviewed-by: sundar --- .../lang/invoke/InvokerBytecodeGenerator.java | 12 +- .../java/lang/invoke/MethodHandleImpl.java | 119 ++++++++++++++---- .../java/lang/invoke/MethodHandles.java | 18 ++- .../java/lang/invoke/ArrayLengthTest.java | 81 ++++++++++++ 4 files changed, 197 insertions(+), 33 deletions(-) create mode 100644 jdk/test/java/lang/invoke/ArrayLengthTest.java diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index 08e38987bf2..da1700ffdb1 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -706,6 +706,9 @@ class InvokerBytecodeGenerator { case ARRAY_STORE: emitArrayStore(name); continue; + case ARRAY_LENGTH: + emitArrayLength(name); + continue; case IDENTITY: assert(name.arguments.length == 1); emitPushArguments(name); @@ -740,15 +743,16 @@ class InvokerBytecodeGenerator { return classFile; } - void emitArrayLoad(Name name) { emitArrayOp(name, Opcodes.AALOAD); } - void emitArrayStore(Name name) { emitArrayOp(name, Opcodes.AASTORE); } + void emitArrayLoad(Name name) { emitArrayOp(name, Opcodes.AALOAD); } + void emitArrayStore(Name name) { emitArrayOp(name, Opcodes.AASTORE); } + void emitArrayLength(Name name) { emitArrayOp(name, Opcodes.ARRAYLENGTH); } void emitArrayOp(Name name, int arrayOpcode) { - assert arrayOpcode == Opcodes.AALOAD || arrayOpcode == Opcodes.AASTORE; + assert arrayOpcode == Opcodes.AALOAD || arrayOpcode == Opcodes.AASTORE || arrayOpcode == Opcodes.ARRAYLENGTH; Class elementType = name.function.methodType().parameterType(0).getComponentType(); assert elementType != null; emitPushArguments(name); - if (elementType.isPrimitive()) { + if (arrayOpcode != Opcodes.ARRAYLENGTH && elementType.isPrimitive()) { Wrapper w = Wrapper.forPrimitiveType(elementType); arrayOpcode = arrayInsnOpcode(arrayTypeCode(w), arrayOpcode); } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java index 782eff613ae..6f2f35b8773 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -66,25 +66,28 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; /// Factory methods to create method handles: - static MethodHandle makeArrayElementAccessor(Class arrayClass, boolean isSetter) { - if (arrayClass == Object[].class) - return (isSetter ? ArrayAccessor.OBJECT_ARRAY_SETTER : ArrayAccessor.OBJECT_ARRAY_GETTER); + static MethodHandle makeArrayElementAccessor(Class arrayClass, ArrayAccess access) { + if (arrayClass == Object[].class) { + return ArrayAccess.objectAccessor(access); + } if (!arrayClass.isArray()) throw newIllegalArgumentException("not an array: "+arrayClass); MethodHandle[] cache = ArrayAccessor.TYPED_ACCESSORS.get(arrayClass); - int cacheIndex = (isSetter ? ArrayAccessor.SETTER_INDEX : ArrayAccessor.GETTER_INDEX); + int cacheIndex = ArrayAccess.cacheIndex(access); MethodHandle mh = cache[cacheIndex]; if (mh != null) return mh; - mh = ArrayAccessor.getAccessor(arrayClass, isSetter); - MethodType correctType = ArrayAccessor.correctType(arrayClass, isSetter); + mh = ArrayAccessor.getAccessor(arrayClass, access); + MethodType correctType = ArrayAccessor.correctType(arrayClass, access); if (mh.type() != correctType) { assert(mh.type().parameterType(0) == Object[].class); - assert((isSetter ? mh.type().parameterType(2) : mh.type().returnType()) == Object.class); - assert(isSetter || correctType.parameterType(0).getComponentType() == correctType.returnType()); + /* if access == SET */ assert(access != ArrayAccess.SET || mh.type().parameterType(2) == Object.class); + /* if access == GET */ assert(access != ArrayAccess.GET || + (mh.type().returnType() == Object.class && + correctType.parameterType(0).getComponentType() == correctType.returnType())); // safe to view non-strictly, because element type follows from array type mh = mh.viewAsType(correctType, false); } - mh = makeIntrinsic(mh, (isSetter ? Intrinsic.ARRAY_STORE : Intrinsic.ARRAY_LOAD)); + mh = makeIntrinsic(mh, ArrayAccess.intrinsic(access)); // Atomically update accessor cache. synchronized(cache) { if (cache[cacheIndex] == null) { @@ -97,9 +100,52 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; return mh; } + enum ArrayAccess { + GET, SET, LENGTH; + + // As ArrayAccess and ArrayAccessor have a circular dependency, the ArrayAccess properties cannot be stored in + // final fields. + + static String opName(ArrayAccess a) { + switch (a) { + case GET: return "getElement"; + case SET: return "setElement"; + case LENGTH: return "length"; + } + throw new AssertionError(); + } + + static MethodHandle objectAccessor(ArrayAccess a) { + switch (a) { + case GET: return ArrayAccessor.OBJECT_ARRAY_GETTER; + case SET: return ArrayAccessor.OBJECT_ARRAY_SETTER; + case LENGTH: return ArrayAccessor.OBJECT_ARRAY_LENGTH; + } + throw new AssertionError(); + } + + static int cacheIndex(ArrayAccess a) { + switch (a) { + case GET: return ArrayAccessor.GETTER_INDEX; + case SET: return ArrayAccessor.SETTER_INDEX; + case LENGTH: return ArrayAccessor.LENGTH_INDEX; + } + throw new AssertionError(); + } + + static Intrinsic intrinsic(ArrayAccess a) { + switch (a) { + case GET: return Intrinsic.ARRAY_LOAD; + case SET: return Intrinsic.ARRAY_STORE; + case LENGTH: return Intrinsic.ARRAY_LENGTH; + } + throw new AssertionError(); + } + } + static final class ArrayAccessor { - /// Support for array element access - static final int GETTER_INDEX = 0, SETTER_INDEX = 1, INDEX_LIMIT = 2; + /// Support for array element and length access + static final int GETTER_INDEX = 0, SETTER_INDEX = 1, LENGTH_INDEX = 2, INDEX_LIMIT = 3; static final ClassValue TYPED_ACCESSORS = new ClassValue() { @Override @@ -107,14 +153,16 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; return new MethodHandle[INDEX_LIMIT]; } }; - static final MethodHandle OBJECT_ARRAY_GETTER, OBJECT_ARRAY_SETTER; + static final MethodHandle OBJECT_ARRAY_GETTER, OBJECT_ARRAY_SETTER, OBJECT_ARRAY_LENGTH; static { MethodHandle[] cache = TYPED_ACCESSORS.get(Object[].class); - cache[GETTER_INDEX] = OBJECT_ARRAY_GETTER = makeIntrinsic(getAccessor(Object[].class, false), Intrinsic.ARRAY_LOAD); - cache[SETTER_INDEX] = OBJECT_ARRAY_SETTER = makeIntrinsic(getAccessor(Object[].class, true), Intrinsic.ARRAY_STORE); + cache[GETTER_INDEX] = OBJECT_ARRAY_GETTER = makeIntrinsic(getAccessor(Object[].class, ArrayAccess.GET), Intrinsic.ARRAY_LOAD); + cache[SETTER_INDEX] = OBJECT_ARRAY_SETTER = makeIntrinsic(getAccessor(Object[].class, ArrayAccess.SET), Intrinsic.ARRAY_STORE); + cache[LENGTH_INDEX] = OBJECT_ARRAY_LENGTH = makeIntrinsic(getAccessor(Object[].class, ArrayAccess.LENGTH), Intrinsic.ARRAY_LENGTH); assert(InvokerBytecodeGenerator.isStaticallyInvocable(ArrayAccessor.OBJECT_ARRAY_GETTER.internalMemberName())); assert(InvokerBytecodeGenerator.isStaticallyInvocable(ArrayAccessor.OBJECT_ARRAY_SETTER.internalMemberName())); + assert(InvokerBytecodeGenerator.isStaticallyInvocable(ArrayAccessor.OBJECT_ARRAY_LENGTH.internalMemberName())); } static int getElementI(int[] a, int i) { return a[i]; } @@ -137,31 +185,47 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; static void setElementC(char[] a, int i, char x) { a[i] = x; } static void setElementL(Object[] a, int i, Object x) { a[i] = x; } - static String name(Class arrayClass, boolean isSetter) { + static int lengthI(int[] a) { return a.length; } + static int lengthJ(long[] a) { return a.length; } + static int lengthF(float[] a) { return a.length; } + static int lengthD(double[] a) { return a.length; } + static int lengthZ(boolean[] a) { return a.length; } + static int lengthB(byte[] a) { return a.length; } + static int lengthS(short[] a) { return a.length; } + static int lengthC(char[] a) { return a.length; } + static int lengthL(Object[] a) { return a.length; } + + static String name(Class arrayClass, ArrayAccess access) { Class elemClass = arrayClass.getComponentType(); if (elemClass == null) throw newIllegalArgumentException("not an array", arrayClass); - return (!isSetter ? "getElement" : "setElement") + Wrapper.basicTypeChar(elemClass); + return ArrayAccess.opName(access) + Wrapper.basicTypeChar(elemClass); } - static MethodType type(Class arrayClass, boolean isSetter) { + static MethodType type(Class arrayClass, ArrayAccess access) { Class elemClass = arrayClass.getComponentType(); Class arrayArgClass = arrayClass; if (!elemClass.isPrimitive()) { arrayArgClass = Object[].class; elemClass = Object.class; } - return !isSetter ? - MethodType.methodType(elemClass, arrayArgClass, int.class) : - MethodType.methodType(void.class, arrayArgClass, int.class, elemClass); + switch (access) { + case GET: return MethodType.methodType(elemClass, arrayArgClass, int.class); + case SET: return MethodType.methodType(void.class, arrayArgClass, int.class, elemClass); + case LENGTH: return MethodType.methodType(int.class, arrayArgClass); + } + throw new IllegalStateException("should not reach here"); } - static MethodType correctType(Class arrayClass, boolean isSetter) { + static MethodType correctType(Class arrayClass, ArrayAccess access) { Class elemClass = arrayClass.getComponentType(); - return !isSetter ? - MethodType.methodType(elemClass, arrayClass, int.class) : - MethodType.methodType(void.class, arrayClass, int.class, elemClass); + switch (access) { + case GET: return MethodType.methodType(elemClass, arrayClass, int.class); + case SET: return MethodType.methodType(void.class, arrayClass, int.class, elemClass); + case LENGTH: return MethodType.methodType(int.class, arrayClass); + } + throw new IllegalStateException("should not reach here"); } - static MethodHandle getAccessor(Class arrayClass, boolean isSetter) { - String name = name(arrayClass, isSetter); - MethodType type = type(arrayClass, isSetter); + static MethodHandle getAccessor(Class arrayClass, ArrayAccess access) { + String name = name(arrayClass, access); + MethodType type = type(arrayClass, access); try { return IMPL_LOOKUP.findStatic(ArrayAccessor.class, name, type); } catch (ReflectiveOperationException ex) { @@ -1282,6 +1346,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; NEW_ARRAY, ARRAY_LOAD, ARRAY_STORE, + ARRAY_LENGTH, IDENTITY, ZERO, NONE // no intrinsic associated diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index c3a97a178a3..2be727ffb0f 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -2244,6 +2244,20 @@ return mh1; return ani.asType(ani.type().changeReturnType(arrayClass)); } + /** + * Produces a method handle returning the length of an array. + * The type of the method handle will have {@code int} as return type, + * and its sole argument will be the array type. + * @param arrayClass an array type + * @return a method handle which can retrieve the length of an array of the given array type + * @throws NullPointerException if the argument is {@code null} + * @throws IllegalArgumentException if arrayClass is not an array type + */ + public static + MethodHandle arrayLength(Class arrayClass) throws IllegalArgumentException { + return MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.LENGTH); + } + /** * Produces a method handle giving read access to elements of an array. * The type of the method handle will have a return type of the array's @@ -2256,7 +2270,7 @@ return mh1; */ public static MethodHandle arrayElementGetter(Class arrayClass) throws IllegalArgumentException { - return MethodHandleImpl.makeArrayElementAccessor(arrayClass, false); + return MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.GET); } /** @@ -2271,7 +2285,7 @@ return mh1; */ public static MethodHandle arrayElementSetter(Class arrayClass) throws IllegalArgumentException { - return MethodHandleImpl.makeArrayElementAccessor(arrayClass, true); + return MethodHandleImpl.makeArrayElementAccessor(arrayClass, MethodHandleImpl.ArrayAccess.SET); } /** diff --git a/jdk/test/java/lang/invoke/ArrayLengthTest.java b/jdk/test/java/lang/invoke/ArrayLengthTest.java new file mode 100644 index 00000000000..3eabf9789c2 --- /dev/null +++ b/jdk/test/java/lang/invoke/ArrayLengthTest.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @run testng/othervm -ea -esa test.java.lang.invoke.ArrayLengthTest + */ +package test.java.lang.invoke; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; + +import static org.testng.AssertJUnit.*; + +import org.testng.annotations.*; + +public class ArrayLengthTest { + + @DataProvider + Object[][] arrayClasses() { + return new Object[][] { + {int[].class}, + {long[].class}, + {float[].class}, + {double[].class}, + {boolean[].class}, + {byte[].class}, + {short[].class}, + {char[].class}, + {Object[].class}, + {StringBuffer[].class} + }; + } + + @Test(dataProvider = "arrayClasses") + public void testArrayLength(Class arrayClass) throws Throwable { + MethodHandle arrayLength = MethodHandles.arrayLength(arrayClass); + assertEquals(int.class, arrayLength.type().returnType()); + assertEquals(arrayClass, arrayLength.type().parameterType(0)); + Object array = MethodHandles.arrayConstructor(arrayClass).invoke(10); + assertEquals(10, arrayLength.invoke(array)); + } + + @Test(dataProvider = "arrayClasses", expectedExceptions = NullPointerException.class) + public void testArrayLengthInvokeNPE(Class arrayClass) throws Throwable { + MethodHandle arrayLength = MethodHandles.arrayLength(arrayClass); + arrayLength.invoke(null); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testArrayLengthNoArray() { + MethodHandles.arrayLength(String.class); + } + + @Test(expectedExceptions = NullPointerException.class) + public void testArrayLengthNPE() { + MethodHandles.arrayLength(null); + } + +} -- GitLab From ea55d0b71be5ef90920e385a52f29a54abc7a413 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 18 May 2016 15:03:39 +0530 Subject: [PATCH 073/400] 8154192: Deprivilege java.scripting module Reviewed-by: jlaskey, alanb --- jdk/src/java.base/share/conf/security/java.policy | 4 ++++ jdk/test/javax/script/ProviderTest.sh | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/conf/security/java.policy b/jdk/src/java.base/share/conf/security/java.policy index 0400ebfd546..32d31472394 100644 --- a/jdk/src/java.base/share/conf/security/java.policy +++ b/jdk/src/java.base/share/conf/security/java.policy @@ -80,6 +80,10 @@ grant codeBase "jrt:/jdk.naming.dns" { permission java.security.AllPermission; }; +grant codeBase "jrt:/java.scripting" { + permission java.security.AllPermission; +}; + grant codeBase "jrt:/jdk.scripting.nashorn" { permission java.security.AllPermission; }; diff --git a/jdk/test/javax/script/ProviderTest.sh b/jdk/test/javax/script/ProviderTest.sh index 1db161dfcf6..24b4120912c 100644 --- a/jdk/test/javax/script/ProviderTest.sh +++ b/jdk/test/javax/script/ProviderTest.sh @@ -43,8 +43,18 @@ $JAR ${TESTTOOLVMOPTS} -cf ${TESTCLASSES}/dummy.jar \ -C ${TESTCLASSES} DummyScriptEngineFactory.class \ -C "${TESTSRC}" META-INF/services/javax.script.ScriptEngineFactory -echo "Running test ..." +echo "Running test with security manager ..." +$JAVA ${TESTVMOPTS} -Djava.security.manager -classpath \ + "${TESTCLASSES}${PS}${TESTCLASSES}/dummy.jar" \ + ProviderTest + +ret=$? +if [ $ret -ne 0 ] +then + exit $ret +fi +echo "Running test without security manager ..." $JAVA ${TESTVMOPTS} -classpath \ "${TESTCLASSES}${PS}${TESTCLASSES}/dummy.jar" \ ProviderTest -- GitLab From b67da697dfc392ce9b6c3c646d3a8317bd5e42ca Mon Sep 17 00:00:00 2001 From: Alexandre Iline Date: Wed, 18 May 2016 11:56:24 +0100 Subject: [PATCH 074/400] 8156972: java/lang/reflect/Layer/LayerAndLoadersTest.java test requires jdk.compiler Reviewed-by: alanb --- .../lang/reflect/Layer/LayerAndLoadersTest.java | 1 + jdk/test/lib/testlibrary/CompilerUtils.java | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java b/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java index b37813fd290..6a0cd78a241 100644 --- a/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java +++ b/jdk/test/java/lang/reflect/Layer/LayerAndLoadersTest.java @@ -24,6 +24,7 @@ /** * @test * @library /lib/testlibrary + * @modules jdk.compiler * @build LayerAndLoadersTest CompilerUtils ModuleUtils * @run testng LayerAndLoadersTest * @summary Tests for java.lang.reflect.Layer@createWithXXX methods diff --git a/jdk/test/lib/testlibrary/CompilerUtils.java b/jdk/test/lib/testlibrary/CompilerUtils.java index 91ca9181340..261c2c8f930 100644 --- a/jdk/test/lib/testlibrary/CompilerUtils.java +++ b/jdk/test/lib/testlibrary/CompilerUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,13 +50,21 @@ public final class CompilerUtils { * * @return true if the compilation is successful * - * @throws IOException if there is an I/O error scanning the source tree or - * creating the destination directory + * @throws IOException + * if there is an I/O error scanning the source tree or + * creating the destination directory + * @throws UnsupportedOperationException + * if there is no system java compiler */ public static boolean compile(Path source, Path destination, String ... options) throws IOException { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + if (compiler == null) { + // no compiler available + throw new UnsupportedOperationException("Unable to get system java compiler. " + + "Perhaps, jdk.compiler module is not available."); + } StandardJavaFileManager jfm = compiler.getStandardFileManager(null, null, null); List sources -- GitLab From 65713ca08e5fde04a22b25314976ca364916d409 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Wed, 18 May 2016 16:58:10 +0300 Subject: [PATCH 075/400] 8156581: Cleanup of ProblemList.txt Reviewed-by: prr, alexsch --- jdk/test/ProblemList.txt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 3766c76ec25..6e1cd7385d4 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -116,10 +116,8 @@ # jdk_beans -java/beans/XMLEncoder/Test4903007.java 8060027 generic-all -java/beans/XMLEncoder/java_awt_GridBagLayout.java 8060027 generic-all -java/beans/XMLDecoder/8028054/TestConstructorFinder.java 8060027 generic-all -java/beans/XMLDecoder/8028054/TestMethodFinder.java 8060027 generic-all +java/beans/XMLDecoder/8028054/TestConstructorFinder.java 8156579 generic-all +java/beans/XMLDecoder/8028054/TestMethodFinder.java 8156579 generic-all java/beans/Introspector/8132566/OverridePropertyInfoTest.java 8132565 generic-all java/beans/Introspector/8132566/OverrideUserDefPropertyInfoTest.java 8132565 generic-all @@ -300,7 +298,6 @@ sun/security/x509/URICertStore/ExtensionsWithLDAP.java 8134577 generic- # jdk_sound -javax/sound/midi/Gervill/SoftProvider/GetDevice.java 8059743 generic-all javax/sound/sampled/DirectAudio/bug6400879.java 8148915 linux-all ############################################################################ -- GitLab From f3c9c10b7e1faf8d8c4987e82c682182ea84acb9 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Wed, 18 May 2016 14:47:28 +0000 Subject: [PATCH 076/400] 8157035: Use stronger algorithms and keys for JSSE testing Reviewed-by: weijun, jnimeh --- jdk/test/javax/net/ssl/etc/README | 94 ++++++++++++++++++++++++++ jdk/test/javax/net/ssl/etc/keystore | Bin 4605 -> 4038 bytes jdk/test/javax/net/ssl/etc/truststore | Bin 2489 -> 2207 bytes 3 files changed, 94 insertions(+) create mode 100644 jdk/test/javax/net/ssl/etc/README diff --git a/jdk/test/javax/net/ssl/etc/README b/jdk/test/javax/net/ssl/etc/README new file mode 100644 index 00000000000..0ac6a844a86 --- /dev/null +++ b/jdk/test/javax/net/ssl/etc/README @@ -0,0 +1,94 @@ +Keystores used for the JSSE regression test suite. + +keystore +truststore +========== + +These are the primary two keystores and contain entries for testing most +of the JSSE regression test files. There are three entries, one RSA-based, +one DSA-based and one EC-based. If they expire, simply recreate them +using keytool and most of the test cases should work. + +The password on both files is: + + passphrase + +There are no individual key entry passwords at this time. + + +keystore entries +================ + +Alias name: dummy +----------------- +Creation date: May 16, 2016 +Entry type: PrivateKeyEntry +Certificate chain length: 1 +Certificate[1]: +Owner: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US +Issuer: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US +Serial number: 57399b87 +Valid from: Mon May 16 10:06:38 UTC 2016 until: Sat May 16 10:06:38 UTC 2026 +Signature algorithm name: SHA256withRSA +Version: 1 + +This can be generated using hacked (update the keytool source code so that +it can be used for version 1 X.509 certificate) keytool command: +% keytool -genkeypair -alias dummy -keyalg RSA -keysize 2048 \ + -sigalg SHA256withRSA \ + -dname "CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US" \ + -validity 3652 -keypass passphrase -keystore keystore -storepass passphrase + + +Alias name: dummyecdsa +---------------------- +Creation date: May 16, 2016 +Entry type: PrivateKeyEntry +Certificate chain length: 1 +Certificate[1]: +Owner: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US +Issuer: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US +Serial number: 57399c1d +Valid from: Mon May 16 10:09:01 UTC 2016 until: Sat May 16 10:09:01 UTC 2026 +Signature algorithm name: SHA256withECDSA +Version: 1 + +This can be generated using hacked (update the keytool source code so that +it can be used for version 1 X.509 certificate) keytool command: +% keytool -genkeypair -alias dummy -keyalg EC -keysize 256 \ + -sigalg SHA256withECDSA \ + -dname "CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US" \ + -validity 3652 -keypass passphrase -keystore keystore -storepass passphrase + +Alias name: dummydsa +-------------------- +Creation date: Mar 11, 2007 +Entry type: PrivateKeyEntry +Certificate chain length: 1 +Certificate[1]: +Owner: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US +Issuer: CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US +Serial number: 45f3a314 +Valid from: Sun Mar 11 06:35:00 UTC 2007 until: Wed Mar 08 06:35:00 UTC 2017 +Certificate fingerprints: +Signature algorithm name: SHA1withDSA +Version: 1 + +This can be generated using hacked (update the keytool source code so that +it can be used for version 1 X.509 certificate) keytool command: +% keytool -genkeypair -alias dummy -keyalg DSA -keysize 1024 \ + -sigalg SHA1withDSA \ + -dname "CN=dummy.example.com, OU=Dummy, O=Dummy, L=Cupertino, ST=CA, C=US" \ + -validity 3652 -keypass passphrase -keystore keystore -storepass passphrase + + +truststore entries +================== +This key store contains only trusted certificate entries. The same +certificates are used in both keystore and truststore. + + +unknown_keystore +================ +A keystore you can use when you don't want things to be verified. +Use this with keystore/truststore, and you'll never get a match. diff --git a/jdk/test/javax/net/ssl/etc/keystore b/jdk/test/javax/net/ssl/etc/keystore index 2eb1993f3aff3d996d7970001765fc3e8fb8d1f7..4062e1798c56b1bbd8840466fb04c4b6d46dfae6 100644 GIT binary patch delta 2691 zcmcImc{J4h8lT_Hm>K(;Wvm(GCH%%PV~~g}DOnO|MEnBE$d-dM)p3}YO+&}I)_x|ym^L)O~_k5q{`8?nA{d{*Y?UEe3i@S>u z2n4!suu6^*IMupdgy_1Du7aT;7lKU@0l)zTC@%o8K;UkaSeYxXtCNGy{IVWPaRz19Q&ewzW@NjLQ+--iThqFNCTSp z?E(~TOS~rzvLR3k(Z;Wjz+upo4}dTi2UK4V%LnoxU^Z|hM+(5sf0~2EAdpNB!E%8d zKUdlR#%NIZCx&tGUi=wXcDdq2_VIL4cJ?NN5<;9VD07+1N8jL^{I#+yil72T%_bTo*%J*jlt=zdH8l^U1{1T=&mgxr24NmZ3H z8UNty30AR&wY??@Mhpyj$eHUNBnXMk6zp%g)AbDZP7f?GFQ`eQKx2lI&98=cM>I6T z;hXE$%^unR9LHab?T^E{Uidf#0%3uHH25A!{r6i!gMW%!vs)XJ==1S2-@LPmb=Vs? z;gWTGGuvB(A(|cfy2vqF%v{8g9&0>BNaLtBx$j=WsL(jT;t5u+25GmwPDmyGh*I6h>p1*{v~sY z_nLXbc9I+KcHPqR?SYRKf=~CNT>S{WC}x=av~2I2=caj0+o(}k=|mDTShL?zw(bSf zw~PD0jKqA4((9snW>|Z#@Zik8oN1%+-t_ z#~hIj4-ngjbWO`*R^=;pb3`}5bJMP07Yn-dZPlhLqRJbL z?2d0ddwi?sBQ-wmgk6wtENwa}!k=@B&R#t5jqfvEOn#nPT1U`|on?r9hBJ~cq4NZe zG5j5P`{~=bC+|~#uPHnlo;n87wQz+dUpxNb=FZ>alYW~VSfX@ewA&yln2?us;_E+B z>Lp$}T6B#`%o6(2u+l)^)HwG2fT973>qznhjJjUdu41? z>(l2~Dl@57C4oIrRuQM;+P#{2JHfhY(F-BnDwQRj_HcOk$~Gms9Wt;+&;OzS3g$ff zIy&e4gZdqp7c)&eV~uZOC70!fZYA`#9PTNt2Rj{&Y(qNCF+Cyi?EBrR}OZI4#XiL?fRNcZ@<`gx&~i5Tim zh_sGFo)DSG*cKnS=9Zq2&zfvpK0K%)&MnmDwY^$};%2GGpw=nNS-09fRLZKdG(t;8 z-cxgZom5zHbHiOkn{$$BtD}>{8Ix=l9TVDXI=A=uUoPu=Qlwq2iw9K}O119kuC=2I zf{p-o8f7)Eq%Pd_`gMjaN{j3#-n3F|gwKw5ns&O}&UYEs{Rdl$@_Kfwt~B}Z;=8z` z2fg(M(Kp$B>lLh+*5_J@%U7p5x|x?gAEaiE^q*Y#1V6=I`$*@!zAamxeyLuxGt+H~ z0ksQ#!%D$szimYAww{0RV}_28)a1RLEpR!DnH1ASG6?8c5EUK@gKH5g` zyp@6P{rCU{IV=Z7US_p2Sp85NQoK711sKC6PABym?7nhIpyc(8YZ|d zU3~P|cS^V*(&o1+xY+6qHcC`WhPK11qtqI)(Ocsw5f#FeKr5M*HEaj#b6*jByvVcG z&9;bnGCZ;FdBSMj@$?FP>&WOTs%5ZB9T|=2t}S&Z~E-<+8WG zC+qOt`WMZDnS(T#DM*9jeri@$49JOK-GA?+zi|QpdkO7w0^?>rD)Lr z>0jH}{}I4w05@b`nAxB-0DyFg>gw2cc&%n*(rgK_t&K+3-yUsOxi|phqmwKEg->Ok{E>gK)S<@JVrqB8KibCKhpG3%S}*nH=g}EqcNa3^ zZJFA!;WNIX*SBqCEIgT3%u1RU<@ZwT(c1H%f#DR~@*F`{HJLf)lYHIL>A(+p&5k5v z60GKuhUAx-Q+lHA@s+;`^(*kRWj%~YkR>h2G{+$t$6irQwsKCZ0gvUQ-ea!mZ3b`A zQ^)+7UfyHfBj0d7@)k`OM?(5CA*5RM3${iZ{Gp%r=$?^Wpoa!WQHfmO7tHa9+a}oXXu_fweU;a_w61)C#3nEcouC z=_~XaTGa0%aYIhTyFd5sGIf|RUXnN9BdofuWpSx+vbp@4Q*O&V(K6;v(^rr|$c(zn zCoLJu(oA&Aw97>l@u$-x5QRpSgaxN)k3*QN6OK{=iQRa;8@2paf{*XWsLd0)7L407 zf)B*M+QQ<~=H;l0$;fi(_SZ;?3E~Yv-ee#B6M`;; ARsaA1 delta 2575 zcmah~do)yQAD+Eu&oG6MF*C;~xg_PX8KNSmjE1gKQ7X6G7AB&RORc$7M7hpLHzt%L zMxuriNo6#`iInIFN#q)GH+)-P-&be#UH*92+Q0Sw-nF0K`#jJ4h?Ywk&%QU`KxO*I33K&i_jSM3;osB_ zA_p>L6`RL@`Zd}N1)G2*RMl1;@Q6iZpJE4lRI|KZF2AePb2y>*14zWys(Zw))|+E8 zf{kjKHe$y{*#Xkw`O9MOY8r-vaUDp(2?sR(r?Fb6F9g(?o1(S2v{(97f;D}gVq z4vzj5aC3hT`?y251PX12*9LtWSsJoepvG+@6(^Qc7?LOxo@GZw(6v`&zsl3VEgM2L zGmE>erL`M9bBMlkZTWdx&qEUSwAdtk?oi=r;Nr?QUdT$}lW9Ts(}`)UdzDtHe#@-$ z{YB64G@}v2&7Y!Km|a#DNzy&H>dpN^4`;opEx>LfzsSpWJY~C=`8j1j57ymCoO*QE zU^vI__rb$E%LwLAqn=+koOch;J%+uflgnI}&9(YN@bFmi{cff2%Z@fH64WL>J0Ww`=*E# z1?!00L4p+`zwy5$%swbECSRqGrdK6vGi8;cwY0|shpBJiTS-m&(qkfHEeH+x2BwzY zd{K>gS!bm}f#TsCNtdb4cqaq0;37ZmE|+k{y7QInoNhzQ&9rliE7kObEAdf+LDTut zdWn?^o_6a^!xb{MnpNn-O7+VQ7)m@3v5zIwPpDlJUD#Z5K}E)1J6s`qNZ#T@`p(j8XM&zK=Z+>hqtH!T(lyVGXZjBkN7rDbL*%#f;cWbo+3^FXZc81RxzV2>bd2~i zsh|DW;@6wbFziywetLI0^l~f%ozZ`1F9rdz`qL_JUS+T}=$Rlu3GVcG0SM z1<_+$y+3zU6W*9uOVwMMEwu>jo3SqzdR(`y>Pg)qZNnPW-7z7SRCTK$O%~hfVl60Qwm0iR}D=O>zcu9DJHOy(>JfO`9F6ej}@97 zi-OtFAe)U!t@K&4r&8PIl{Jsn)-_R-wMSa)>N4&4Jm!98w5G^RB&2KApWK-9D9dZJ zkU>1)o#W%}cO}a8@ZO26o7E{!7ar}*^p|_N;eOp%W`@&tY3$w4b}VeW+j65ZO|FH16j-EN)`-p?OxdmF?Rb*-rX`2A z3@}h^f8|1@#RW!naXj3ZXy8*_@-8QyYCqm7IGS!89fxN-oRu=wf4QMDLHFeRSL6Nt z^KJ7AoN>Z)+dYCA9@ew4$>-bM%Y1uLJdb$z1O>Yx4~w=gZD<17`7aT0digedCaO^H z>T@5rk;-jeZIKM!4kjxio5nfV^8E0_eJJ<0i=$^tCuMPRBu95u4V|K~6Iun`~fHDaBG8e9@j=mS*iPw`MS$IljAZ7Xzl zY#z)`gcoDc`&5@e5E?}Hz^V&{9Ha~>t;zOhlYJB=iza%zWM-w9|67ABUR zuRRwibbj|R{;XO;ny>Z1K+=GQUg~d$hPq8$d$$MnNiJ?PXnwCFd7m^!Nr+A_T^+un z%SG~$3(m||tk+<1HD6Gv#{Gm*U9V11XOY5NpvX;k-1uJ2M%IT$-;y76C?a&oA#|Jo z{}b3B!>Ip_2qW0+U)fASh*&6pv@+rUW&8RX54%<|THrz`E;*AP<{CZ{Kvpj*r?ajF zY4o;*#fd);Fb;ZEz{#N56pv|mDO2fl(z0rI*N-*SCwad8GxD|*b+>#fS9SH1S2HeK zMH1fv_BJXmm@Aw?%J0i=0uFM_F^`H{LrQKJd|TaGlUv?K{3SDVi9l+PunSHSox%NL zdqi*xq{voQMTC+(XMrW7ywf%*Rlfmbr9;ay;)3sp3)R22R=6GAxYR5?bcf7%#g?gj zcUXh^W%p{`OjjT^jI~^El7Fq#xytg-kM+0=H4qVF1PT6I!=aY7wI)Y4}vBuReI#+6O8@= D$u>QV diff --git a/jdk/test/javax/net/ssl/etc/truststore b/jdk/test/javax/net/ssl/etc/truststore index 65a140d773206daf836779d70a5df75b51a5cd91..12da39e66a5d19aefdaa23c0810aa2dcb673c381 100644 GIT binary patch delta 1276 zcmdlfJYSIK-`jt085kItfS7r+8)4dW4jnwBlJuSEEyOW4;nNv?gio`CYEr^ zIkE;^Y#dr`9_MUXn3*O!vPn4cFgZIK3Kb(z`)YLFiM=)2#Gt{flacWa$5vbK(5eB ztw_u*$Vt^p&d)Un1G<_W>=`CTHdgIM76vY6Ck7UGW(Dh?x7>5Z7{s~nH z$axm@Y-3YiZP*$^`|a@tE^d!l0^`h8jV3+2T`;LNAyM>~hSiCFkBEBaZD|(rpPu+S zN@sR&)D*v{CCoK@VPlVK#5mWX;QfRSK+GH|My+r(=#_>1ap z4SDSke!O13pZ&MNVkTxr21Z~Q)gvMu97v1|k)n$_x7`2g<}kJD-_4ng28a2~Cin#| znO!Y(cJpGX7Rkkh7Y!`=mp&Je4etpRuwrg|t9E62bG+W9xV~pe&SukZ@850r)>S)C zNZD@dhUUzZ(a|4&Iy}$p=&9W$Z&l#IxXjNm;9b7wq7(mbPtsznU*dCtb)C(21K$s| zXJyJ~zV$vX^;t@~D8=%tnq>aPMVH>+Fu${U@s$Dzqd(RGY0K~LU00X5X#We#!1k$o zz8TyzpVcx`NJ+kmb+2W{tf)n7D}<--Yh+vQzR~<;Vq2EFa?RZYg_6G0W{#cPg@eRa zPE|2^VSehR$FUjZqTNS-9mXoK~c>@5ADaWw@ delta 1084 zcmbO)xKlXz-`jt085kItfS3hL^QV;N=2jLJC#K~Wr6#9jFfcHx>-dB$V_=QYGc~XT zDitzlV&XGsVk~E35mVhmy_g9B_%vL<8o+i)|=k~ zp5M={%s8s?^o@*G=}hM~i5rYT9@6owvzp!+JIF0%4CAZ+nsRXEdy&MRthUq!^r=6O0&oG<5G+=A~AA{ z`ieK4+@$p7?!m-7J7J536}~**4!ZqZpJbry@*z-5XK@1K+{y-d-5>Mk?1?*Wzi;Q< zQ|7FZ#Y{IPWNxPw{|T>HaNsS=kBZIbE<82=Ge2GN?>n(K>({XCEE8CD)0so^3A5Mw zgZGnOo!q|Pb|a4?v!1%fcF+0nNMT$CjF3e@9LdDV@Ni08{M?5|?+iHE*nu%~&X$F7 zqDO%YI6h1aEKLneO=0n21m#Zj$gTG@5QeH}Vr1h0Yh-3*WHw@8+4K_x+nGHgjbK4B-qX>rSxj){_`v?Hac7HaWec0?_1u3r(ef| zlOroQIRX=*p#4@88@PX&ynu<&4d~zXOf0US7mFcB6U#)mT0tYA4-L(M3DCm8%ovym zqd-2ym)zza&EO9{s_t>wb&C7_r{A|N3+6bP5dSOuMAweRohrvHj&03Vy;x(nYTvRn zr>&(Dk?E^4(z9o^C&Y$)U$*qr^r)VFev5PXE?Dn4_jU22C?5{C%`XGG!Y(fkXgkTS z!T2HHS$|2r%d)Am^JU+5MP524e(|N)QwGCb--7<$?b~_td8a-`a$|ucw~zxLdV4v0 zkBeOqzwhrfNwj_5Ubl-E3md#1yx=f-xZ?imPS)!Qo0f01U1)#iSZnn3K-Ki{8i{MS zR=LYD>I*%%9Pi@ZSJ3{nDJ9X1neo}Vss2$@WZ#HJ6?f*EboPlhhPASr>s_!uIzgxA y{}+>pH~;Vd7i{__e!??&&F?8}shh56l-%-&uzHgjaO}>Vju$K~JdUgH-UI+TS*uI{ -- GitLab From 5cf7ba5687666ba098913f3c4437846b6555c9d8 Mon Sep 17 00:00:00 2001 From: Artem Smotrakov Date: Wed, 18 May 2016 16:39:08 +0100 Subject: [PATCH 077/400] 8157107: HTTP/2 client may fail with NPE if additional logging enabled Reviewed-by: michaelm --- .../java/net/http/AsyncSSLDelegate.java | 25 +- .../share/classes/java/net/http/Log.java | 2 +- .../net/httpclient/http2/TLSConnection.java | 247 ++++++++++++++++++ .../java/net/http/Http2TestServer.java | 7 +- 4 files changed, 272 insertions(+), 9 deletions(-) create mode 100644 jdk/test/java/net/httpclient/http2/TLSConnection.java diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java index b3ff5c311e4..ae0d19c6cde 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/AsyncSSLDelegate.java @@ -26,7 +26,6 @@ package java.net.http; import java.io.Closeable; import java.io.IOException; import java.nio.ByteBuffer; -import java.util.Arrays; import java.util.LinkedList; import java.util.concurrent.ExecutorService; import java.util.function.Consumer; @@ -557,25 +556,37 @@ public class AsyncSSLDelegate implements Closeable, AsyncConnection { } static void logParams(SSLParameters p) { - if (!Log.ssl()) + if (!Log.ssl()) { return; + } + Log.logSSL("SSLParameters:"); if (p == null) { Log.logSSL("Null params"); return; } - for (String cipher : p.getCipherSuites()) { - Log.logSSL("cipher: {0}\n", cipher); + + if (p.getCipherSuites() != null) { + for (String cipher : p.getCipherSuites()) { + Log.logSSL("cipher: {0}\n", cipher); + } } + + // SSLParameters.getApplicationProtocols() can't return null for (String approto : p.getApplicationProtocols()) { Log.logSSL("application protocol: {0}\n", approto); } - for (String protocol : p.getProtocols()) { - Log.logSSL("protocol: {0}\n", protocol); + + if (p.getProtocols() != null) { + for (String protocol : p.getProtocols()) { + Log.logSSL("protocol: {0}\n", protocol); + } } - if (p.getServerNames() != null) + + if (p.getServerNames() != null) { for (SNIServerName sname : p.getServerNames()) { Log.logSSL("server name: {0}\n", sname.toString()); + } } } diff --git a/jdk/src/java.httpclient/share/classes/java/net/http/Log.java b/jdk/src/java.httpclient/share/classes/java/net/http/Log.java index 991edfefa6c..51e5ce9633e 100644 --- a/jdk/src/java.httpclient/share/classes/java/net/http/Log.java +++ b/jdk/src/java.httpclient/share/classes/java/net/http/Log.java @@ -88,7 +88,7 @@ abstract class Log implements System.Logger { logging |= TRACE; break; case "all": - logging |= CONTENT|HEADERS|REQUESTS|FRAMES|ERRORS|TRACE; + logging |= CONTENT|HEADERS|REQUESTS|FRAMES|ERRORS|TRACE|SSL; break; } if (val.startsWith("frames")) { diff --git a/jdk/test/java/net/httpclient/http2/TLSConnection.java b/jdk/test/java/net/httpclient/http2/TLSConnection.java new file mode 100644 index 00000000000..f2721eb268e --- /dev/null +++ b/jdk/test/java/net/httpclient/http2/TLSConnection.java @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.Http2Handler; +import java.net.http.Http2TestExchange; +import java.net.http.Http2TestServer; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import javax.net.ssl.SSLParameters; +import javax.net.ssl.SSLSession; + +/* + * @test + * @bug 8150769 8157107 + * @summary Checks that SSL parameters can be set for HTTP/2 connection + * @modules java.httpclient + * @compile/module=java.httpclient java/net/http/Http2Handler.java + * @compile/module=java.httpclient java/net/http/Http2TestExchange.java + * @compile/module=java.httpclient java/net/http/Http2TestServer.java + * @run main/othervm TLSConnection + */ +public class TLSConnection { + + private static final String KEYSTORE = System.getProperty("test.src") + + File.separator + "keystore.p12"; + private static final String PASSWORD = "password"; + + public static void main(String[] args) throws Exception { + + // enable all logging + System.setProperty("java.net.http.HttpClient.log", "all,frames:all"); + + // initialize JSSE + System.setProperty("javax.net.ssl.keyStore", KEYSTORE); + System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD); + System.setProperty("javax.net.ssl.trustStore", KEYSTORE); + System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD); + + Handler handler = new Handler(); + + try (Http2TestServer server = new Http2TestServer(true, 0, handler)) { + server.start(); + + int port = server.getAddress().getPort(); + String uriString = "https://127.0.0.1:" + Integer.toString(port); + + // run test cases + boolean success = true; + + SSLParameters parameters = null; + success &= expectFailure( + "Test #1: SSL parameters is null, expect NPE", + () -> connect(uriString, parameters), + NullPointerException.class); + + success &= expectSuccess( + "Test #2: default SSL parameters, " + + "expect successful connection", + () -> connect(uriString, new SSLParameters())); + success &= checkProtocol(handler.getSSLSession(), "TLSv1.2"); + + // set SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA cipher suite + // which has less priority in default cipher suite list + success &= expectSuccess( + "Test #3: SSL parameters with " + + "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA cipher suite, " + + "expect successful connection", + () -> connect(uriString, new SSLParameters( + new String[] { "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA" }))); + success &= checkProtocol(handler.getSSLSession(), "TLSv1.2"); + success &= checkCipherSuite(handler.getSSLSession(), + "SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA"); + + // set TLS_RSA_WITH_AES_128_CBC_SHA cipher suite + // which has less priority in default cipher suite list + // also set TLSv11 protocol + success &= expectSuccess( + "Test #4: SSL parameters with " + + "TLS_RSA_WITH_AES_128_CBC_SHA cipher suite," + + " expect successful connection", + () -> connect(uriString, new SSLParameters( + new String[] { "TLS_RSA_WITH_AES_128_CBC_SHA" }, + new String[] { "TLSv1.1" }))); + success &= checkProtocol(handler.getSSLSession(), "TLSv1.1"); + success &= checkCipherSuite(handler.getSSLSession(), + "TLS_RSA_WITH_AES_128_CBC_SHA"); + + if (success) { + System.out.println("Test passed"); + } else { + throw new RuntimeException("At least one test case failed"); + } + } + } + + private static interface Test { + + public void run() throws Exception; + } + + private static class Handler implements Http2Handler { + + private static final byte[] BODY = "Test response".getBytes(); + + private volatile SSLSession sslSession; + + @Override + public void handle(Http2TestExchange t) throws IOException { + System.out.println("Handler: received request to " + + t.getRequestURI()); + + try (InputStream is = t.getRequestBody()) { + byte[] body = is.readAllBytes(); + System.out.println("Handler: read " + body.length + + " bytes of body: "); + System.out.println(new String(body)); + } + + try (OutputStream os = t.getResponseBody()) { + t.sendResponseHeaders(200, BODY.length); + os.write(BODY); + } + + sslSession = t.getSSLSession(); + } + + SSLSession getSSLSession() { + return sslSession; + } + } + + private static void connect(String uriString, SSLParameters sslParameters) + throws URISyntaxException, IOException, InterruptedException { + + String body = HttpClient.create() + .sslParameters(sslParameters) + .version(HttpClient.Version.HTTP_2) + .build() + .request(new URI(uriString)) + .body(HttpRequest.fromString("body")) + .GET() + .response() + .body(HttpResponse.asString()); + + System.out.println("Response: " + body); + } + + private static boolean checkProtocol(SSLSession session, String protocol) { + if (session == null) { + System.out.println("Check protocol: no session provided"); + return false; + } + + System.out.println("Check protocol: negotiated protocol: " + + session.getProtocol()); + System.out.println("Check protocol: expected protocol: " + + protocol); + if (!protocol.equals(session.getProtocol())) { + System.out.println("Check protocol: unexpected negotiated protocol"); + return false; + } + + return true; + } + + private static boolean checkCipherSuite(SSLSession session, String ciphersuite) { + if (session == null) { + System.out.println("Check protocol: no session provided"); + return false; + } + + System.out.println("Check protocol: negotiated ciphersuite: " + + session.getCipherSuite()); + System.out.println("Check protocol: expected ciphersuite: " + + ciphersuite); + if (!ciphersuite.equals(session.getCipherSuite())) { + System.out.println("Check protocol: unexpected negotiated ciphersuite"); + return false; + } + + return true; + } + + private static boolean expectSuccess(String message, Test test) { + System.out.println(message); + try { + test.run(); + System.out.println("Passed"); + return true; + } catch (Exception e) { + System.out.println("Failed: unexpected exception:"); + e.printStackTrace(System.out); + return false; + } + } + + private static boolean expectFailure(String message, Test test, + Class expectedException) { + + System.out.println(message); + try { + test.run(); + System.out.println("Failed: unexpected successful connection"); + return false; + } catch (Exception e) { + System.out.println("Got an exception:"); + e.printStackTrace(System.out); + if (expectedException != null + && !expectedException.isAssignableFrom(e.getClass())) { + System.out.printf("Failed: expected %s, but got %s%n", + expectedException.getName(), + e.getClass().getName()); + return false; + } + System.out.println("Passed: expected exception"); + return true; + } + } + +} diff --git a/jdk/test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestServer.java b/jdk/test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestServer.java index 667a1d6ec55..3baefe142bb 100644 --- a/jdk/test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestServer.java +++ b/jdk/test/java/net/httpclient/http2/java.httpclient/java/net/http/Http2TestServer.java @@ -42,7 +42,7 @@ import javax.net.ssl.SSLServerSocketFactory; * Http2Handler on additional threads. All threads * obtained from the supplied ExecutorService. */ -public class Http2TestServer { +public class Http2TestServer implements AutoCloseable { final ServerSocket server; boolean secure; SettingsFrame serverSettings, clientSettings; @@ -156,4 +156,9 @@ public class Http2TestServer { }); } + @Override + public void close() throws Exception { + stop(); + } + } -- GitLab From 0bad445941832843531331d8b0204eaa5e3243b1 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Wed, 18 May 2016 18:46:14 +0200 Subject: [PATCH 078/400] 8157152: Atomic add for VarHandle byte[]/ByteBuffer views is incorrect for endian conversion Reviewed-by: fyuan, shade, vlivanov --- .../X-VarHandleByteArrayView.java.template | 72 ++++++++++++------- .../VarHandleTestByteArrayAsChar.java | 2 +- .../VarHandleTestByteArrayAsDouble.java | 2 +- .../VarHandleTestByteArrayAsFloat.java | 2 +- .../VarHandleTestByteArrayAsInt.java | 2 +- .../VarHandleTestByteArrayAsLong.java | 2 +- .../VarHandleTestByteArrayAsShort.java | 2 +- .../invoke/VarHandles/generate-vh-tests.sh | 16 +++-- 8 files changed, 63 insertions(+), 37 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template index a24e6c82186..66bf267476e 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template +++ b/jdk/src/java.base/share/classes/java/lang/invoke/X-VarHandleByteArrayView.java.template @@ -271,22 +271,33 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { #if[AtomicAdd] @ForceInline - static $type$ getAndAdd(ArrayHandle handle, Object oba, int index, $type$ value) { + static $type$ getAndAdd(ArrayHandle handle, Object oba, int index, $type$ delta) { byte[] ba = (byte[]) oba; - return convEndian(handle.be, - UNSAFE.getAndAdd$RawType$( - ba, - address(ba, index(ba, index)), - convEndian(handle.be, value))); + if (handle.be == BE) { + return UNSAFE.getAndAdd$RawType$( + ba, + address(ba, index(ba, index)), + delta); + } else { + return getAndAddConvEndianWithCAS(ba, index, delta); + } } @ForceInline - static $type$ addAndGet(ArrayHandle handle, Object oba, int index, $type$ value) { - byte[] ba = (byte[]) oba; - return convEndian(handle.be, UNSAFE.getAndAdd$RawType$( - ba, - address(ba, index(ba, index)), - convEndian(handle.be, value))) + value; + static $type$ getAndAddConvEndianWithCAS(byte[] ba, int index, $type$ delta) { + $type$ nativeExpectedValue, expectedValue; + long offset = address(ba, index(ba, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(ba, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(ba, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta))); + return expectedValue; + } + + @ForceInline + static $type$ addAndGet(ArrayHandle handle, Object oba, int index, $type$ delta) { + return getAndAdd(handle, oba, index, delta) + delta; } #end[AtomicAdd] @@ -503,23 +514,34 @@ final class VarHandleByteArrayAs$Type$s extends VarHandleByteArrayBase { #if[AtomicAdd] @ForceInline - static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ value) { + static $type$ getAndAdd(ByteBufferHandle handle, Object obb, int index, $type$ delta) { ByteBuffer bb = (ByteBuffer) obb; - return convEndian(handle.be, - UNSAFE.getAndAdd$RawType$( - UNSAFE.getObject(bb, BYTE_BUFFER_HB), - address(bb, indexRO(bb, index)), - convEndian(handle.be, value))); + if (handle.be == BE) { + return UNSAFE.getAndAdd$RawType$( + UNSAFE.getObject(bb, BYTE_BUFFER_HB), + address(bb, indexRO(bb, index)), + delta); + } else { + return getAndAddConvEndianWithCAS(bb, index, delta); + } } @ForceInline - static $type$ addAndGet(ByteBufferHandle handle, Object obb, int index, $type$ value) { - ByteBuffer bb = (ByteBuffer) obb; - return convEndian(handle.be, - UNSAFE.getAndAdd$RawType$( - UNSAFE.getObject(bb, BYTE_BUFFER_HB), - address(bb, indexRO(bb, index)), - convEndian(handle.be, value))) + value; + static $type$ getAndAddConvEndianWithCAS(ByteBuffer bb, int index, $type$ delta) { + $type$ nativeExpectedValue, expectedValue; + Object base = UNSAFE.getObject(bb, BYTE_BUFFER_HB); + long offset = address(bb, indexRO(bb, index)); + do { + nativeExpectedValue = UNSAFE.get$RawType$Volatile(base, offset); + expectedValue = $RawBoxType$.reverseBytes(nativeExpectedValue); + } while (!UNSAFE.weakCompareAndSwap$RawType$Volatile(base, offset, + nativeExpectedValue, $RawBoxType$.reverseBytes(expectedValue + delta))); + return expectedValue; + } + + @ForceInline + static $type$ addAndGet(ByteBufferHandle handle, Object obb, int index, $type$ delta) { + return getAndAdd(handle, obb, index, delta) + delta; } #end[AtomicAdd] diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java index 806dd1ce4f8..a2221b50a20 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java @@ -51,7 +51,7 @@ public class VarHandleTestByteArrayAsChar extends VarHandleBaseByteArrayTest { static final char VALUE_2 = (char)0x1112; - static final char VALUE_3 = (char)0x2122; + static final char VALUE_3 = (char)0xFFFE; @Override diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java index ccb0028c472..79305710ce2 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java @@ -51,7 +51,7 @@ public class VarHandleTestByteArrayAsDouble extends VarHandleBaseByteArrayTest { static final double VALUE_2 = 0x1112131415161718L; - static final double VALUE_3 = 0x2122232425262728L; + static final double VALUE_3 = 0xFFFEFDFCFBFAF9F8L; @Override diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java index 2ff6427aec7..b3545b4f69c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java @@ -51,7 +51,7 @@ public class VarHandleTestByteArrayAsFloat extends VarHandleBaseByteArrayTest { static final float VALUE_2 = 0x11121314; - static final float VALUE_3 = 0x21222324; + static final float VALUE_3 = 0xFFFEFDFC; @Override diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java index 3087a14f049..b733bb34054 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java @@ -51,7 +51,7 @@ public class VarHandleTestByteArrayAsInt extends VarHandleBaseByteArrayTest { static final int VALUE_2 = 0x11121314; - static final int VALUE_3 = 0x21222324; + static final int VALUE_3 = 0xFFFEFDFC; @Override diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java index 8388a9cdd6c..88bf198272b 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java @@ -51,7 +51,7 @@ public class VarHandleTestByteArrayAsLong extends VarHandleBaseByteArrayTest { static final long VALUE_2 = 0x1112131415161718L; - static final long VALUE_3 = 0x2122232425262728L; + static final long VALUE_3 = 0xFFFEFDFCFBFAF9F8L; @Override diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java index b13bce1e1da..5ed9d6099f7 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java @@ -51,7 +51,7 @@ public class VarHandleTestByteArrayAsShort extends VarHandleBaseByteArrayTest { static final short VALUE_2 = (short)0x1112; - static final short VALUE_3 = (short)0x2122; + static final short VALUE_3 = (short)0xFFFE; @Override diff --git a/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh b/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh index 7d6afc7b206..436d2d371d9 100644 --- a/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh +++ b/jdk/test/java/lang/invoke/VarHandles/generate-vh-tests.sh @@ -113,36 +113,40 @@ do ;; esac + # The value of `value3` is chosen such that when added to `value1` or `value2` + # it will result in carrying of bits over to the next byte, thereby detecting + # possible errors in endianness conversion e.g. if say for atomic addition the + # augend is incorrectly processed case $type in short) value1=(short)0x0102 value2=(short)0x1112 - value3=(short)0x2122 + value3=(short)0xFFFE ;; char) value1=(char)0x0102 value2=(char)0x1112 - value3=(char)0x2122 + value3=(char)0xFFFE ;; int) value1=0x01020304 value2=0x11121314 - value3=0x21222324 + value3=0xFFFEFDFC ;; long) value1=0x0102030405060708L value2=0x1112131415161718L - value3=0x2122232425262728L + value3=0xFFFEFDFCFBFAF9F8L ;; float) value1=0x01020304 value2=0x11121314 - value3=0x21222324 + value3=0xFFFEFDFC ;; double) value1=0x0102030405060708L value2=0x1112131415161718L - value3=0x2122232425262728L + value3=0xFFFEFDFCFBFAF9F8L ;; esac -- GitLab From a865c6ef6bff6e6c9d149354479448c9b8175cbd Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 18 May 2016 21:00:33 +0200 Subject: [PATCH 079/400] 8133549: Generalize jshell's EditingHistory Adding a generic EditingHistory to jdk.internal.le, for use by both jjs and jshell Reviewed-by: sundar --- .../internal/jline/console/ConsoleReader.java | 6 + .../internal/jline/extra/EditingHistory.java | 418 ++++++++++++++++++ .../share/classes/module-info.java | 5 +- .../jdk/internal/jline/extra/HistoryTest.java | 177 ++++++++ 4 files changed, 605 insertions(+), 1 deletion(-) create mode 100644 jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java create mode 100644 jdk/test/jdk/internal/jline/extra/HistoryTest.java diff --git a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java index 2c9337d6404..9b7edac4d33 100644 --- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java +++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java @@ -2498,6 +2498,12 @@ public class ConsoleReader //ignore } + if (o instanceof Runnable) { + ((Runnable) o).run(); + sb.setLength(0); + continue; + } + // Search mode. // // Note that we have to do this first, because if there is a command diff --git a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java new file mode 100644 index 00000000000..7e4bbbff6a4 --- /dev/null +++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/extra/EditingHistory.java @@ -0,0 +1,418 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.jline.extra; + +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.function.Supplier; + +import jdk.internal.jline.console.ConsoleReader; +import jdk.internal.jline.console.KeyMap; +import jdk.internal.jline.console.history.History; +import jdk.internal.jline.console.history.History.Entry; +import jdk.internal.jline.console.history.MemoryHistory; + +/*Public for tests (HistoryTest). + */ +public abstract class EditingHistory implements History { + + private final History fullHistory; + private History currentDelegate; + + protected EditingHistory(ConsoleReader in, Iterable originalHistory) { + this.fullHistory = new MemoryHistory(); + this.currentDelegate = fullHistory; + bind(in, CTRL_UP, + (Runnable) () -> moveHistoryToSnippet(in, ((EditingHistory) in.getHistory())::previousSnippet)); + bind(in, CTRL_DOWN, + (Runnable) () -> moveHistoryToSnippet(in, ((EditingHistory) in.getHistory())::nextSnippet)); + load(originalHistory); + } + + private void moveHistoryToSnippet(ConsoleReader in, Supplier action) { + if (!action.get()) { + try { + in.beep(); + } catch (IOException ex) { + throw new IllegalStateException(ex); + } + } else { + try { + //could use: + //in.resetPromptLine(in.getPrompt(), in.getHistory().current().toString(), -1); + //but that would mean more re-writing on the screen, (and prints an additional + //empty line), so using setBuffer directly: + Method setBuffer = in.getClass().getDeclaredMethod("setBuffer", String.class); + + setBuffer.setAccessible(true); + setBuffer.invoke(in, in.getHistory().current().toString()); + in.flush(); + } catch (ReflectiveOperationException | IOException ex) { + throw new IllegalStateException(ex); + } + } + } + + private void bind(ConsoleReader in, String shortcut, Object action) { + KeyMap km = in.getKeys(); + for (int i = 0; i < shortcut.length(); i++) { + Object value = km.getBound(Character.toString(shortcut.charAt(i))); + if (value instanceof KeyMap) { + km = (KeyMap) value; + } else { + km.bind(shortcut.substring(i), action); + } + } + } + + private static final String CTRL_UP = "\033\133\061\073\065\101"; //Ctrl-UP + private static final String CTRL_DOWN = "\033\133\061\073\065\102"; //Ctrl-DOWN + + @Override + public int size() { + return currentDelegate.size(); + } + + @Override + public boolean isEmpty() { + return currentDelegate.isEmpty(); + } + + @Override + public int index() { + return currentDelegate.index(); + } + + @Override + public void clear() { + if (currentDelegate != fullHistory) + throw new IllegalStateException("narrowed"); + currentDelegate.clear(); + } + + @Override + public CharSequence get(int index) { + return currentDelegate.get(index); + } + + @Override + public void add(CharSequence line) { + NarrowingHistoryLine currentLine = null; + int origIndex = fullHistory.index(); + int fullSize; + try { + fullHistory.moveToEnd(); + fullSize = fullHistory.index(); + if (currentDelegate == fullHistory) { + if (origIndex < fullHistory.index()) { + for (Entry entry : fullHistory) { + if (!(entry.value() instanceof NarrowingHistoryLine)) + continue; + int[] cluster = ((NarrowingHistoryLine) entry.value()).span; + if (cluster[0] == origIndex && cluster[1] > cluster[0]) { + currentDelegate = new MemoryHistory(); + for (int i = cluster[0]; i <= cluster[1]; i++) { + currentDelegate.add(fullHistory.get(i)); + } + } + } + } + } + fullHistory.moveToEnd(); + while (fullHistory.previous()) { + CharSequence c = fullHistory.current(); + if (c instanceof NarrowingHistoryLine) { + currentLine = (NarrowingHistoryLine) c; + break; + } + } + } finally { + fullHistory.moveTo(origIndex); + } + if (currentLine == null || currentLine.span[1] != (-1)) { + line = currentLine = new NarrowingHistoryLine(line, fullSize); + } + StringBuilder complete = new StringBuilder(); + for (int i = currentLine.span[0]; i < fullSize; i++) { + complete.append(fullHistory.get(i)); + } + complete.append(line); + if (isComplete(complete)) { + currentLine.span[1] = fullSize; //TODO: +1? + currentDelegate = fullHistory; + } + fullHistory.add(line); + } + + protected abstract boolean isComplete(CharSequence input); + + @Override + public void set(int index, CharSequence item) { + if (currentDelegate != fullHistory) + throw new IllegalStateException("narrowed"); + currentDelegate.set(index, item); + } + + @Override + public CharSequence remove(int i) { + if (currentDelegate != fullHistory) + throw new IllegalStateException("narrowed"); + return currentDelegate.remove(i); + } + + @Override + public CharSequence removeFirst() { + if (currentDelegate != fullHistory) + throw new IllegalStateException("narrowed"); + return currentDelegate.removeFirst(); + } + + @Override + public CharSequence removeLast() { + if (currentDelegate != fullHistory) + throw new IllegalStateException("narrowed"); + return currentDelegate.removeLast(); + } + + @Override + public void replace(CharSequence item) { + if (currentDelegate != fullHistory) + throw new IllegalStateException("narrowed"); + currentDelegate.replace(item); + } + + @Override + public ListIterator entries(int index) { + return currentDelegate.entries(index); + } + + @Override + public ListIterator entries() { + return currentDelegate.entries(); + } + + @Override + public Iterator iterator() { + return currentDelegate.iterator(); + } + + @Override + public CharSequence current() { + return currentDelegate.current(); + } + + @Override + public boolean previous() { + return currentDelegate.previous(); + } + + @Override + public boolean next() { + return currentDelegate.next(); + } + + @Override + public boolean moveToFirst() { + return currentDelegate.moveToFirst(); + } + + @Override + public boolean moveToLast() { + return currentDelegate.moveToLast(); + } + + @Override + public boolean moveTo(int index) { + return currentDelegate.moveTo(index); + } + + @Override + public void moveToEnd() { + currentDelegate.moveToEnd(); + } + + public boolean previousSnippet() { + for (int i = index() - 1; i >= 0; i--) { + if (get(i) instanceof NarrowingHistoryLine) { + moveTo(i); + return true; + } + } + + return false; + } + + public boolean nextSnippet() { + for (int i = index() + 1; i < size(); i++) { + if (get(i) instanceof NarrowingHistoryLine) { + moveTo(i); + return true; + } + } + + if (index() < size()) { + moveToEnd(); + return true; + } + + return false; + } + + public final void load(Iterable originalHistory) { + NarrowingHistoryLine currentHistoryLine = null; + boolean start = true; + int currentLine = 0; + for (String historyItem : originalHistory) { + StringBuilder line = new StringBuilder(historyItem); + int trailingBackSlashes = countTrailintBackslashes(line); + boolean continuation = trailingBackSlashes % 2 != 0; + line.delete(line.length() - trailingBackSlashes / 2 - (continuation ? 1 : 0), line.length()); + if (start) { + class PersistentNarrowingHistoryLine extends NarrowingHistoryLine implements PersistentEntryMarker { + public PersistentNarrowingHistoryLine(CharSequence delegate, int start) { + super(delegate, start); + } + } + fullHistory.add(currentHistoryLine = new PersistentNarrowingHistoryLine(line, currentLine)); + } else { + class PersistentLine implements CharSequence, PersistentEntryMarker { + private final CharSequence delegate; + public PersistentLine(CharSequence delegate) { + this.delegate = delegate; + } + @Override public int length() { + return delegate.length(); + } + @Override public char charAt(int index) { + return delegate.charAt(index); + } + @Override public CharSequence subSequence(int start, int end) { + return delegate.subSequence(start, end); + } + @Override public String toString() { + return delegate.toString(); + } + } + fullHistory.add(new PersistentLine(line)); + } + start = !continuation; + currentHistoryLine.span[1] = currentLine; + currentLine++; + } + } + + public Collection save() { + Collection result = new ArrayList<>(); + Iterator entries = fullHistory.iterator(); + + if (entries.hasNext()) { + Entry entry = entries.next(); + while (entry != null) { + StringBuilder historyLine = new StringBuilder(entry.value()); + int trailingBackSlashes = countTrailintBackslashes(historyLine); + for (int i = 0; i < trailingBackSlashes; i++) { + historyLine.append("\\"); + } + entry = entries.hasNext() ? entries.next() : null; + if (entry != null && !(entry.value() instanceof NarrowingHistoryLine)) { + historyLine.append("\\"); + } + result.add(historyLine.toString()); + } + } + + return result; + } + + private int countTrailintBackslashes(CharSequence text) { + int count = 0; + + for (int i = text.length() - 1; i >= 0; i--) { + if (text.charAt(i) == '\\') { + count++; + } else { + break; + } + } + + return count; + } + + public List currentSessionEntries() { + List result = new ArrayList<>(); + + for (Entry e : fullHistory) { + if (!(e.value() instanceof PersistentEntryMarker)) { + result.add(e.value().toString()); + } + } + + return result; + } + + public void fullHistoryReplace(String source) { + fullHistory.replace(source); + } + + private class NarrowingHistoryLine implements CharSequence { + private final CharSequence delegate; + private final int[] span; + + public NarrowingHistoryLine(CharSequence delegate, int start) { + this.delegate = delegate; + this.span = new int[] {start, -1}; + } + + @Override + public int length() { + return delegate.length(); + } + + @Override + public char charAt(int index) { + return delegate.charAt(index); + } + + @Override + public CharSequence subSequence(int start, int end) { + return delegate.subSequence(start, end); + } + + @Override + public String toString() { + return delegate.toString(); + } + + } + + private interface PersistentEntryMarker {} +} + diff --git a/jdk/src/jdk.internal.le/share/classes/module-info.java b/jdk/src/jdk.internal.le/share/classes/module-info.java index b4ae508ac6e..d52b3b5f98d 100644 --- a/jdk/src/jdk.internal.le/share/classes/module-info.java +++ b/jdk/src/jdk.internal.le/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,9 @@ module jdk.internal.le { exports jdk.internal.jline.console.history to jdk.scripting.nashorn.shell, jdk.jshell; + exports jdk.internal.jline.extra to + jdk.scripting.nashorn.shell, + jdk.jshell; exports jdk.internal.jline.internal to jdk.scripting.nashorn.shell, jdk.jshell; diff --git a/jdk/test/jdk/internal/jline/extra/HistoryTest.java b/jdk/test/jdk/internal/jline/extra/HistoryTest.java new file mode 100644 index 00000000000..f8d3084b767 --- /dev/null +++ b/jdk/test/jdk/internal/jline/extra/HistoryTest.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Test Completion + * @modules jdk.internal.le/jdk.internal.jline + * jdk.internal.le/jdk.internal.jline.console + * jdk.internal.le/jdk.internal.jline.console.history + * jdk.internal.le/jdk.internal.jline.extra + * @build HistoryTest + * @run testng HistoryTest + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.concurrent.atomic.AtomicBoolean; + +import jdk.internal.jline.UnsupportedTerminal; +import jdk.internal.jline.console.ConsoleReader; +import jdk.internal.jline.console.history.MemoryHistory; +import jdk.internal.jline.extra.EditingHistory; + +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + +@Test +public class HistoryTest { + + public void testHistory() throws IOException { + ConsoleReader in = new ConsoleReader(new ByteArrayInputStream(new byte[0]), new ByteArrayOutputStream(), new UnsupportedTerminal()); + AtomicBoolean complete = new AtomicBoolean(); + EditingHistory history = new EditingHistory(in, Collections.emptyList()) { + @Override + protected boolean isComplete(CharSequence input) { + return complete.get(); + } + }; + complete.set(false); history.add("void test() {"); + complete.set(false); history.add(" System.err.println(1);"); + complete.set(true); history.add("}"); + complete.set(true); history.add("/exit"); + + previousAndAssert(history, "/exit"); + + history.previous(); history.previous(); history.previous(); + + complete.set(false); history.add("void test() { /*changed*/"); + + complete.set(true); + previousAndAssert(history, "}"); + previousAndAssert(history, " System.err.println(1);"); + previousAndAssert(history, "void test() {"); + + assertFalse(history.previous()); + + nextAndAssert(history, " System.err.println(1);"); + nextAndAssert(history, "}"); + nextAndAssert(history, ""); + + complete.set(false); history.add(" System.err.println(2);"); + complete.set(true); history.add("} /*changed*/"); + + assertEquals(history.size(), 7); + + Collection persistentHistory = history.save(); + + history = new EditingHistory(in, persistentHistory) { + @Override + protected boolean isComplete(CharSequence input) { + return complete.get(); + } + }; + + previousSnippetAndAssert(history, "void test() { /*changed*/"); + previousSnippetAndAssert(history, "/exit"); + previousSnippetAndAssert(history, "void test() {"); + + assertFalse(history.previousSnippet()); + + nextSnippetAndAssert(history, "/exit"); + nextSnippetAndAssert(history, "void test() { /*changed*/"); + nextSnippetAndAssert(history, ""); + + assertFalse(history.nextSnippet()); + + complete.set(false); history.add("{"); + complete.set(true); history.add("}"); + + persistentHistory = history.save(); + + history = new EditingHistory(in, persistentHistory) { + @Override + protected boolean isComplete(CharSequence input) { + return complete.get(); + } + }; + + previousSnippetAndAssert(history, "{"); + previousSnippetAndAssert(history, "void test() { /*changed*/"); + previousSnippetAndAssert(history, "/exit"); + previousSnippetAndAssert(history, "void test() {"); + + while (history.next()); + + complete.set(true); history.add("/*current1*/"); + complete.set(true); history.add("/*current2*/"); + complete.set(true); history.add("/*current3*/"); + + assertEquals(history.currentSessionEntries(), Arrays.asList("/*current1*/", "/*current2*/", "/*current3*/")); + + history.remove(0); + + assertEquals(history.currentSessionEntries(), Arrays.asList("/*current1*/", "/*current2*/", "/*current3*/")); + + while (history.size() > 2) + history.remove(0); + + assertEquals(history.currentSessionEntries(), Arrays.asList("/*current2*/", "/*current3*/")); + + for (int i = 0; i < MemoryHistory.DEFAULT_MAX_SIZE * 2; i++) { + complete.set(true); history.add("/exit"); + } + + complete.set(false); history.add("void test() { /*after full*/"); + complete.set(false); history.add(" System.err.println(1);"); + complete.set(true); history.add("}"); + + previousSnippetAndAssert(history, "void test() { /*after full*/"); + } + + private void previousAndAssert(EditingHistory history, String expected) { + assertTrue(history.previous()); + assertEquals(history.current().toString(), expected); + } + + private void nextAndAssert(EditingHistory history, String expected) { + assertTrue(history.next()); + assertEquals(history.current().toString(), expected); + } + + private void previousSnippetAndAssert(EditingHistory history, String expected) { + assertTrue(history.previousSnippet()); + assertEquals(history.current().toString(), expected); + } + + private void nextSnippetAndAssert(EditingHistory history, String expected) { + assertTrue(history.nextSnippet()); + assertEquals(history.current().toString(), expected); + } + +} -- GitLab From 918a949448dd149d9317b6cb261429b267f5e301 Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Wed, 18 May 2016 22:55:35 +0000 Subject: [PATCH 080/400] 8151856: Note that disabledAlgorithms override the same algorithms of legacyAlgorithms Reviewed-by: mullan, weijun --- jdk/src/java.base/share/conf/security/java.security | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security index 6fa0d301d33..72c381b9747 100644 --- a/jdk/src/java.base/share/conf/security/java.security +++ b/jdk/src/java.base/share/conf/security/java.security @@ -713,6 +713,12 @@ jdk.tls.disabledAlgorithms=SSLv3, RC4, MD5withRSA, DH keySize < 1024 # See SSL/TLS specifications and "Java Cryptography Architecture Standard # Algorithm Name Documentation" for information about the algorithm names. # +# Note: If a legacy algorithm is also restricted through the +# jdk.tls.disabledAlgorithms property or the +# java.security.AlgorithmConstraints API (See +# javax.net.ssl.SSLParameters.setAlgorithmConstraints()), +# then the algorithm is completely disabled and will not be negotiated. +# # Note: This property is currently used by Oracle's JSSE implementation. # It is not guaranteed to be examined and used by other implementations. # There is no guarantee the property will continue to exist or be of the -- GitLab From 4dcf9fd923a8f63e592a9bf833ab3265efefbc71 Mon Sep 17 00:00:00 2001 From: Rajan Halade Date: Wed, 18 May 2016 16:36:52 -0700 Subject: [PATCH 081/400] 8156035: Remove intermittent key from sun/security/rsa/SpecTest.java Reviewed-by: mullan --- jdk/test/sun/security/rsa/SpecTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/test/sun/security/rsa/SpecTest.java b/jdk/test/sun/security/rsa/SpecTest.java index 24cddfe3591..7b3c52e5d1f 100644 --- a/jdk/test/sun/security/rsa/SpecTest.java +++ b/jdk/test/sun/security/rsa/SpecTest.java @@ -24,7 +24,6 @@ /** * @test * @bug 8044199 8137231 - * @key intermittent * @summary Check same KeyPair's private key and public key have same modulus. * also check public key's public exponent equals to given spec's public * exponent. Only key size 1024 is tested with RSAKeyGenParameterSpec.F0 (3). -- GitLab From ca98819c49f84d0dc5363a5babdd158a374553fb Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Wed, 18 May 2016 11:31:23 -0700 Subject: [PATCH 082/400] 8156807: Pack200 must support v53.0 class files Reviewed-by: mchung, shade --- .../com/sun/java/util/jar/pack/Constants.java | 14 ++-- .../share/native/common-unpack/constants.h | 24 +----- jdk/test/ProblemList.txt | 2 - jdk/test/tools/pack200/TestNormal.java | 80 ++++--------------- jdk/test/tools/pack200/Utils.java | 7 +- 5 files changed, 33 insertions(+), 94 deletions(-) diff --git a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java index fee0b800f2d..50dc8020b25 100644 --- a/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java +++ b/jdk/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,9 +43,10 @@ class Constants { 1.0 to 1.3.X 45,3 1.4 to 1.4.X 46,0 1.5 to 1.5.X 49,0 - 1.6 to 1.5.x 50,0 - 1.7 to 1.6.x 51,0 - 1.8 to 1.7.x 52,0 + 1.6 to 1.6.X 50,0 + 1.7 to 1.7.X 51,0 + 1.8 to 1.8.X 52,0 + 1.9 to 1.9.X 53,0 */ public static final Package.Version JAVA_MIN_CLASS_VERSION = @@ -63,6 +64,9 @@ class Constants { public static final Package.Version JAVA8_MAX_CLASS_VERSION = Package.Version.of(52, 00); + public static final Package.Version JAVA9_MAX_CLASS_VERSION = + Package.Version.of(53, 00); + public static final int JAVA_PACKAGE_MAGIC = 0xCAFED00D; public static final Package.Version JAVA5_PACKAGE_VERSION = @@ -79,7 +83,7 @@ class Constants { // upper limit, should point to the latest class version public static final Package.Version JAVA_MAX_CLASS_VERSION = - JAVA8_MAX_CLASS_VERSION; + JAVA9_MAX_CLASS_VERSION; // upper limit should point to the latest package version, for version info!. public static final Package.Version MAX_PACKAGE_VERSION = diff --git a/jdk/src/jdk.pack200/share/native/common-unpack/constants.h b/jdk/src/jdk.pack200/share/native/common-unpack/constants.h index f1a1f73edff..8d8376dd23a 100644 --- a/jdk/src/jdk.pack200/share/native/common-unpack/constants.h +++ b/jdk/src/jdk.pack200/share/native/common-unpack/constants.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,30 +23,10 @@ * questions. */ -/* - Java Class Version numbers history - 1.0 to 1.3.X 45,3 - 1.4 to 1.4.X 46,0 - 1.5 to 1.5.X 49,0 - 1.6 to 1.5.x 50,0 NOTE Assumed for now -*/ - // classfile constants #define JAVA_MAGIC 0xCAFEBABE -#define JAVA_MIN_MAJOR_VERSION 45 -#define JAVA_MIN_MINOR_VERSION 3 - -#define JAVA5_MAX_MAJOR_VERSION 49 -#define JAVA5_MAX_MINOR_VERSION 0 - -#define JAVA6_MAX_MAJOR_VERSION 50 -#define JAVA6_MAX_MINOR_VERSION 0 - -#define JAVA7_MAX_MAJOR_VERSION 51 -#define JAVA7_MAX_MINOR_VERSION 0 -#define JAVA8_MAX_MAJOR_VERSION 52 -#define JAVA8_MAX_MINOR_VERSION 0 +// Class version history, refer to Constants.java // package file constants #define JAVA_PACKAGE_MAGIC 0xCAFED00D diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 6e1cd7385d4..a3c3a99ded4 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -332,8 +332,6 @@ tools/launcher/FXLauncherTest.java 8068049 linux-al tools/pack200/Pack200Props.java 8155857 generic-all -tools/pack200/TestNormal.java 8156807 windows-all - ############################################################################ # jdk_jdi diff --git a/jdk/test/tools/pack200/TestNormal.java b/jdk/test/tools/pack200/TestNormal.java index 0172a5e65b6..a85a9d4040f 100644 --- a/jdk/test/tools/pack200/TestNormal.java +++ b/jdk/test/tools/pack200/TestNormal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,85 +25,37 @@ /* * @test * @run main/timeout=600 TestNormal - * @bug 8020802 + * @bug 8020802 8156807 * @summary Need an ability to create jar files that are invariant to the pack200 packing/unpacking * @author Alexander Zuev */ import java.io.*; -import java.util.Collections; -import java.util.Properties; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; public class TestNormal { private static String FS = File.separator; public static void main(String args[]) throws Exception { - Properties p = System.getProperties(); - String java_home = p.getProperty("test.jdk"); String testdir = Utils.TEST_CLS_DIR.getAbsolutePath(); try { - execJavaCommand(java_home, "jar cnf normalized.jar -C " + testdir + " ."); - execJavaCommand(java_home, "jar cf original.jar -C " + testdir + " ."); - execJavaCommand(java_home, "pack200 -r repacked.jar original.jar"); - compareJars(new JarFile("normalized.jar"), new JarFile("repacked.jar")); - } finally { - String[] cleanupList = {"normalized.jar", "original.jar", "repacked.jar"}; - for (String s : cleanupList) { - delete(new File(s)); - } - } - } + String jarCmd = Utils.getJarCmd(); + String packCmd = Utils.getPack200Cmd(); - public static void execJavaCommand(String java_home, String cmd) throws Exception { - Process proc = Runtime.getRuntime().exec(java_home + FS + "bin" + FS + cmd); - String s; - BufferedReader stdInput = - new BufferedReader(new InputStreamReader(proc.getInputStream())); - BufferedReader stdError = - new BufferedReader(new InputStreamReader(proc.getErrorStream())); - while ((s = stdInput.readLine()) != null) { - System.out.println(s); - } - while ((s = stdError.readLine()) != null) { - System.err.println(s); - } - } + // create the original jar + Utils.runExec(jarCmd, "cf", "original.jar", "-C", testdir, "."); - public static void compareJars(JarFile jf1, JarFile jf2) throws Exception { - try { - if (jf1.size() != jf2.size()) { - throw new Exception("Jars " + jf1.getName() + " and " + jf2.getName() - + " have different number of entries"); - } - for (JarEntry elem1 : Collections.list(jf1.entries())) { - JarEntry elem2 = jf2.getJarEntry(elem1.getName()); - if (elem2 == null) { - throw new Exception("Element " + elem1.getName() + " is missing from " + jf2.getName()); - } - if (!elem1.isDirectory() && elem1.getCrc() != elem2.getCrc()) { - throw new Exception("The crc of " + elem1.getName() + " is different."); - } - } - } finally { - jf1.close(); - jf2.close(); - } - } + // create the reference jar + Utils.runExec(packCmd, "-r", "repacked.jar", "original.jar"); - static void delete(File f) throws IOException { - if (!f.exists()) { - return; - } - if (f.isDirectory()) { - for (File c : f.listFiles()) { - delete(c); - } - } - if (!f.delete()) { - throw new FileNotFoundException("Failed to delete file: " + f); + // create the normalized jar using jar(1) + Utils.runExec(jarCmd, "cnf", "normalized.jar", "-C", testdir, "."); + + // compare archive contents bit wise, these should be identical! + Utils.doCompareBitWise(new File("repacked.jar"), + new File("normalized.jar")); + } finally { + Utils.cleanup(); } } } diff --git a/jdk/test/tools/pack200/Utils.java b/jdk/test/tools/pack200/Utils.java index f4641987e73..45e09c37abc 100644 --- a/jdk/test/tools/pack200/Utils.java +++ b/jdk/test/tools/pack200/Utils.java @@ -33,7 +33,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintStream; import java.net.URI; -import java.net.URL; import java.nio.charset.Charset; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.FileSystem; @@ -483,9 +482,15 @@ class Utils { } return out; } + + static List runExec(String... cmds) { + return runExec(Arrays.asList(cmds)); + } + static List runExec(List cmdsList) { return runExec(cmdsList, null); } + static List runExec(List cmdsList, Map penv) { ArrayList alist = new ArrayList(); ProcessBuilder pb = -- GitLab From 8aff72ba655e0d45ff87dd3a270197c498ce3c1d Mon Sep 17 00:00:00 2001 From: Shilpi Rastogi Date: Thu, 19 May 2016 11:13:52 +0200 Subject: [PATCH 083/400] 8149574: Fix java/lang/invoke/MethodHandleImpl's use of Unsafe.defineAnonymousClass() Reviewed-by: vlivanov, psandoz, sundar, mhaupt --- .../java/lang/invoke/MethodHandleImpl.java | 131 +++++++++--------- 1 file changed, 68 insertions(+), 63 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java index 6f2f35b8773..cc7e1e3fecc 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -41,9 +41,15 @@ import sun.invoke.empty.Empty; import sun.invoke.util.ValueConversions; import sun.invoke.util.VerifyType; import sun.invoke.util.Wrapper; + +import jdk.internal.org.objectweb.asm.AnnotationVisitor; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.MethodVisitor; + import static java.lang.invoke.LambdaForm.*; import static java.lang.invoke.MethodHandleStatics.*; import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; +import static jdk.internal.org.objectweb.asm.Opcodes.*; /** * Trusted implementation code for MethodHandle. @@ -1155,6 +1161,8 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; // Put the whole mess into its own nested class. // That way we can lazily load the code and set up the constants. private static class BindCaller { + private static MethodType INVOKER_MT = MethodType.methodType(Object.class, MethodHandle.class, Object[].class); + static MethodHandle bindCaller(MethodHandle mh, Class hostClass) { // Do not use this function to inject calls into system classes. @@ -1173,38 +1181,15 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; } private static MethodHandle makeInjectedInvoker(Class hostClass) { - Class bcc = UNSAFE.defineAnonymousClass(hostClass, T_BYTES, null); - if (hostClass.getClassLoader() != bcc.getClassLoader()) - throw new InternalError(hostClass.getName()+" (CL)"); - try { - if (hostClass.getProtectionDomain() != bcc.getProtectionDomain()) - throw new InternalError(hostClass.getName()+" (PD)"); - } catch (SecurityException ex) { - // Self-check was blocked by security manager. This is OK. - // In fact the whole try body could be turned into an assertion. - } - try { - MethodHandle init = IMPL_LOOKUP.findStatic(bcc, "init", MethodType.methodType(void.class)); - init.invokeExact(); // force initialization of the class - } catch (Throwable ex) { - throw uncaughtException(ex); - } - MethodHandle bccInvoker; try { - MethodType invokerMT = MethodType.methodType(Object.class, MethodHandle.class, Object[].class); - bccInvoker = IMPL_LOOKUP.findStatic(bcc, "invoke_V", invokerMT); + Class invokerClass = UNSAFE.defineAnonymousClass(hostClass, INJECTED_INVOKER_TEMPLATE, null); + assert checkInjectedInvoker(hostClass, invokerClass); + return IMPL_LOOKUP.findStatic(invokerClass, "invoke_V", INVOKER_MT); } catch (ReflectiveOperationException ex) { throw uncaughtException(ex); } - // Test the invoker, to ensure that it really injects into the right place. - try { - MethodHandle vamh = prepareForInvoker(MH_checkCallerClass); - Object ok = bccInvoker.invokeExact(vamh, new Object[]{hostClass, bcc}); - } catch (Throwable ex) { - throw new InternalError(ex); - } - return bccInvoker; } + private static ClassValue CV_makeInjectedInvoker = new ClassValue() { @Override protected MethodHandle computeValue(Class hostClass) { return makeInjectedInvoker(hostClass); @@ -1235,62 +1220,82 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; return mh; } + private static boolean checkInjectedInvoker(Class hostClass, Class invokerClass) { + assert (hostClass.getClassLoader() == invokerClass.getClassLoader()) : hostClass.getName()+" (CL)"; + try { + assert (hostClass.getProtectionDomain() == invokerClass.getProtectionDomain()) : hostClass.getName()+" (PD)"; + } catch (SecurityException ex) { + // Self-check was blocked by security manager. This is OK. + } + try { + // Test the invoker to ensure that it really injects into the right place. + MethodHandle invoker = IMPL_LOOKUP.findStatic(invokerClass, "invoke_V", INVOKER_MT); + MethodHandle vamh = prepareForInvoker(MH_checkCallerClass); + return (boolean)invoker.invoke(vamh, new Object[]{ invokerClass }); + } catch (Throwable ex) { + throw new InternalError(ex); + } + } + private static final MethodHandle MH_checkCallerClass; static { final Class THIS_CLASS = BindCaller.class; - assert(checkCallerClass(THIS_CLASS, THIS_CLASS)); + assert(checkCallerClass(THIS_CLASS)); try { MH_checkCallerClass = IMPL_LOOKUP .findStatic(THIS_CLASS, "checkCallerClass", - MethodType.methodType(boolean.class, Class.class, Class.class)); - assert((boolean) MH_checkCallerClass.invokeExact(THIS_CLASS, THIS_CLASS)); + MethodType.methodType(boolean.class, Class.class)); + assert((boolean) MH_checkCallerClass.invokeExact(THIS_CLASS)); } catch (Throwable ex) { throw new InternalError(ex); } } @CallerSensitive - private static boolean checkCallerClass(Class expected, Class expected2) { - // This method is called via MH_checkCallerClass and so it's - // correct to ask for the immediate caller here. + private static boolean checkCallerClass(Class expected) { + // This method is called via MH_checkCallerClass and so it's correct to ask for the immediate caller here. Class actual = Reflection.getCallerClass(); - if (actual != expected && actual != expected2) - throw new InternalError("found "+actual.getName()+", expected "+expected.getName() - +(expected == expected2 ? "" : ", or else "+expected2.getName())); + if (actual != expected) + throw new InternalError("found " + actual.getName() + ", expected " + expected.getName()); return true; } - private static final byte[] T_BYTES; - static { - final Object[] values = {null}; - AccessController.doPrivileged(new PrivilegedAction<>() { - public Void run() { - try { - Class tClass = T.class; - String tName = tClass.getName(); - String tResource = tName.substring(tName.lastIndexOf('.')+1)+".class"; - try (java.io.InputStream in = tClass.getResourceAsStream(tResource)) { - values[0] = in.readAllBytes(); - } - } catch (java.io.IOException ex) { - throw new InternalError(ex); - } - return null; - } - }); - T_BYTES = (byte[]) values[0]; - } + private static final byte[] INJECTED_INVOKER_TEMPLATE = generateInvokerTemplate(); - // The following class is used as a template for Unsafe.defineAnonymousClass: - private static class T { - static void init() { } // side effect: initializes this class - static Object invoke_V(MethodHandle vamh, Object[] args) throws Throwable { - return vamh.invokeExact(args); - } + /** Produces byte code for a class that is used as an injected invoker. */ + private static byte[] generateInvokerTemplate() { + ClassWriter cw = new ClassWriter(0); + + // private static class InjectedInvoker { + // @Hidden + // static Object invoke_V(MethodHandle vamh, Object[] args) throws Throwable { + // return vamh.invokeExact(args); + // } + // } + cw.visit(52, ACC_PRIVATE | ACC_SUPER, "InjectedInvoker", null, "java/lang/Object", null); + + MethodVisitor mv = cw.visitMethod(ACC_STATIC, "invoke_V", + "(Ljava/lang/invoke/MethodHandle;[Ljava/lang/Object;)Ljava/lang/Object;", + null, null); + + // Suppress invoker method in stack traces. + AnnotationVisitor av0 = mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true); + av0.visitEnd(); + + mv.visitCode(); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/invoke/MethodHandle", "invokeExact", + "([Ljava/lang/Object;)Ljava/lang/Object;", false); + mv.visitInsn(ARETURN); + mv.visitMaxs(2, 2); + mv.visitEnd(); + + cw.visitEnd(); + return cw.toByteArray(); } } - /** This subclass allows a wrapped method handle to be re-associated with an arbitrary member name. */ private static final class WrappedMember extends DelegatingMethodHandle { private final MethodHandle target; -- GitLab From 19c7dcc0120f5c3fafa6d0f4ee037a509c354cd5 Mon Sep 17 00:00:00 2001 From: Sibabrata Sahoo Date: Thu, 19 May 2016 04:20:08 -0700 Subject: [PATCH 084/400] 8141039: Test Task: Develop new tests for JEP 273: DRBG-Based SecureRandom Implementations Reviewed-by: weijun --- .../java/security/SecureRandom/ApiTest.java | 365 ++++++++++++++++++ .../security/SecureRandom/EnoughSeedTest.java | 100 +++++ .../security/SecureRandom/GetAlgorithm.java | 64 +-- .../SecureRandom/GetInstanceTest.java | 312 +++++++++++++++ .../SecureRandom/MultiThreadTest.java | 182 +++++++++ .../SecureRandom/SerializedSeedTest.java | 214 ++++++++++ .../SecureRandom/StrongSecureRandom.java | 96 +++-- .../SeedGenerator/SeedGeneratorChoice.java | 23 +- 8 files changed, 1296 insertions(+), 60 deletions(-) create mode 100644 jdk/test/java/security/SecureRandom/ApiTest.java create mode 100644 jdk/test/java/security/SecureRandom/EnoughSeedTest.java create mode 100644 jdk/test/java/security/SecureRandom/GetInstanceTest.java create mode 100644 jdk/test/java/security/SecureRandom/MultiThreadTest.java create mode 100644 jdk/test/java/security/SecureRandom/SerializedSeedTest.java diff --git a/jdk/test/java/security/SecureRandom/ApiTest.java b/jdk/test/java/security/SecureRandom/ApiTest.java new file mode 100644 index 00000000000..bf3c8374122 --- /dev/null +++ b/jdk/test/java/security/SecureRandom/ApiTest.java @@ -0,0 +1,365 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8141039 + * @library /lib/testlibrary + * @summary This test do API coverage for SecureRandom. It covers most of + * supported operations along with possible positive and negative + * parameters for DRBG mechanism. + * @run main ApiTest Hash_DRBG + * @run main ApiTest HMAC_DRBG + * @run main ApiTest CTR_DRBG + * @run main ApiTest SHA1PRNG + * @run main ApiTest NATIVE + */ +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.Security; +import java.security.SecureRandomParameters; +import java.security.DrbgParameters; +import java.security.DrbgParameters.Instantiation; +import java.security.DrbgParameters.Capability; +import javax.crypto.Cipher; + +public class ApiTest { + + private static final boolean SHOULD_PASS = true; + private static final long SEED = 1l; + private static final String INVALID_ALGO = "INVALID"; + private static final String DRBG_CONFIG = "securerandom.drbg.config"; + private static final String DRBG_CONFIG_VALUE + = Security.getProperty(DRBG_CONFIG); + + public static void main(String[] args) throws Exception { + + if (args == null || args.length < 1) { + throw new RuntimeException("No mechanism available to run test."); + } + String mech + = "NATIVE".equals(args[0]) ? supportedNativeAlgo() : args[0]; + String[] algs = null; + boolean success = true; + + try { + if (!isDRBG(mech)) { + SecureRandom random = SecureRandom.getInstance(mech); + verifyAPI(random, mech); + return; + } else if (mech.equals("CTR_DRBG")) { + algs = new String[]{"AES-128", "AES-192", "AES-256", + INVALID_ALGO}; + } else if (mech.equals("Hash_DRBG") || mech.equals("HMAC_DRBG")) { + algs = new String[]{"SHA-224", "SHA-256", "SHA-512/224", + "SHA-512/256", "SHA-384", "SHA-512", INVALID_ALGO}; + } else { + throw new RuntimeException( + String.format("Not a valid mechanism '%s'", mech)); + } + runForEachMech(mech, algs); + } catch (Exception e) { + e.printStackTrace(System.out); + success = false; + } + + if (!success) { + throw new RuntimeException("At least one test failed."); + } + } + + /** + * Run the test for a DRBG mechanism with a possible set of parameter + * combination. + * @param mech DRBG mechanism name + * @param algs Algorithm supported by each mechanism + * @throws Exception + */ + private static void runForEachMech(String mech, String[] algs) + throws Exception { + for (String alg : algs) { + runForEachAlg(mech, alg); + } + } + + private static void runForEachAlg(String mech, String alg) + throws Exception { + for (int strength : new int[]{Integer.MIN_VALUE, -1, 0, 1, 223, 224, + 192, 255, 256}) { + for (Capability cp : Capability.values()) { + for (byte[] pr : new byte[][]{null, new byte[]{}, + "personal".getBytes()}) { + SecureRandomParameters param + = DrbgParameters.instantiation(strength, cp, pr); + runForEachParam(mech, alg, param); + } + } + } + } + + private static void runForEachParam(String mech, String alg, + SecureRandomParameters param) throws Exception { + + for (boolean df : new Boolean[]{true, false}) { + try { + Security.setProperty(DRBG_CONFIG, mech + "," + alg + "," + + (df ? "use_df" : "no_df")); + System.out.printf("%nParameter for SecureRandom " + + "mechanism: %s is (param:%s, algo:%s, df:%s)", + mech, param, alg, df); + SecureRandom sr = SecureRandom.getInstance("DRBG", param); + verifyAPI(sr, mech); + } catch (NoSuchAlgorithmException e) { + // Verify exception status for current test. + checkException(getDefaultAlg(mech, alg), param, e); + } finally { + Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE); + } + } + } + + /** + * Returns the algorithm supported for input mechanism. + * @param mech Mechanism name + * @param alg Algorithm name + * @return Algorithm name + */ + private static String getDefaultAlg(String mech, String alg) + throws NoSuchAlgorithmException { + if (alg == null) { + switch (mech) { + case "Hash_DRBG": + case "HMAC_DRBG": + return "SHA-256"; + case "CTR_DRBG": + return (Cipher.getMaxAllowedKeyLength("AES") < 256) + ? "AES-128" : "AES-256"; + default: + throw new RuntimeException("Mechanism not supported"); + } + } + return alg; + } + + /** + * Verify the exception type either it is expected to occur or not. + * @param alg Algorithm name + * @param param DRBG parameter + * @param e Exception to verify + * @throws NoSuchAlgorithmException + */ + private static void checkException(String alg, SecureRandomParameters param, + NoSuchAlgorithmException e) throws NoSuchAlgorithmException { + + int strength = ((Instantiation) param).getStrength(); + boolean error = true; + switch (alg) { + case INVALID_ALGO: + error = false; + break; + case "SHA-224": + case "SHA-512/224": + if (strength > 192) { + error = false; + } + break; + case "SHA-256": + case "SHA-512/256": + case "SHA-384": + case "SHA-512": + if (strength > 256) { + error = false; + } + break; + case "AES-128": + case "AES-192": + case "AES-256": + int algoStrength = Integer.parseInt(alg.replaceAll("AES-", "")); + int maxStrengthSupported = Cipher.getMaxAllowedKeyLength("AES"); + if (strength > maxStrengthSupported + || algoStrength > maxStrengthSupported) { + error = false; + } + break; + } + if (error) { + throw new RuntimeException("Unknown :", e); + } + } + + /** + * Find if the mechanism is a DRBG mechanism. + * @param mech Mechanism name + * @return True for DRBG mechanism else False + */ + private static boolean isDRBG(String mech) { + return mech.contains("_DRBG"); + } + + /** + * Find the name of supported native mechanism name for current platform. + */ + private static String supportedNativeAlgo() { + String nativeSr = "Windows-PRNG"; + try { + SecureRandom.getInstance(nativeSr); + } catch (NoSuchAlgorithmException e) { + nativeSr = "NativePRNG"; + } + return nativeSr; + } + + /** + * Test a possible set of SecureRandom API for a SecureRandom instance. + * @param random SecureRandom instance + * @param mech Mechanism used to create SecureRandom instance + */ + private static void verifyAPI(SecureRandom random, String mech) + throws Exception { + + System.out.printf("%nTest SecureRandom mechanism: %s for provider: %s", + mech, random.getProvider().getName()); + byte[] output = new byte[2]; + + // Generate random number. + random.nextBytes(output); + + // Seed the SecureRandom with a generated seed value of lesser size. + byte[] seed = random.generateSeed(1); + random.setSeed(seed); + random.nextBytes(output); + + // Seed the SecureRandom with a fixed seed value. + random.setSeed(SEED); + random.nextBytes(output); + + // Seed the SecureRandom with a larger seed value. + seed = random.generateSeed(128); + random.setSeed(seed); + random.nextBytes(output); + + // Additional operation only supported for DRBG based SecureRandom. + // Execute the code block and expect to pass for DRBG. If it will fail + // then it should fail with specified exception type. Else the case + // will be considered as a test case failure. + matchExc(() -> { + random.reseed(); + random.nextBytes(output); + }, + isDRBG(mech), + UnsupportedOperationException.class, + String.format("PASS - Unsupported reseed() method for " + + "SecureRandom Algorithm %s ", mech)); + + matchExc(() -> { + random.reseed(DrbgParameters.reseed(false, new byte[]{})); + random.nextBytes(output); + }, + isDRBG(mech), + UnsupportedOperationException.class, + String.format("PASS - Unsupported reseed(param) method for " + + "SecureRandom Algorithm %s ", mech)); + + matchExc(() -> { + random.reseed(DrbgParameters.reseed(true, new byte[]{})); + random.nextBytes(output); + }, + isDRBG(mech), + !isSupportPR(mech, random) ? IllegalArgumentException.class + : UnsupportedOperationException.class, + String.format("PASS - Unsupported or illegal reseed(param) " + + "method for SecureRandom Algorithm %s ", mech)); + + matchExc(() -> random.nextBytes(output, + DrbgParameters.nextBytes(-1, false, new byte[]{})), + isDRBG(mech), + UnsupportedOperationException.class, + String.format("PASS - Unsupported nextBytes(out, nextByteParam)" + + " method for SecureRandom Algorithm %s ", mech)); + + matchExc(() -> random.nextBytes(output, + DrbgParameters.nextBytes(-1, true, new byte[]{})), + isDRBG(mech), + !isSupportPR(mech, random) ? IllegalArgumentException.class + : UnsupportedOperationException.class, + String.format("PASS - Unsupported or illegal " + + "nextBytes(out, nextByteParam) method for " + + "SecureRandom Algorithm %s ", mech)); + + matchExc(() -> { + random.reseed(null); + random.nextBytes(output); + }, + !SHOULD_PASS, + IllegalArgumentException.class, + "PASS - Test is expected to fail when parameter for reseed() " + + "is null"); + + matchExc(() -> random.nextBytes(output, null), + !SHOULD_PASS, + IllegalArgumentException.class, + "PASS - Test is expected to fail when parameter for nextBytes()" + + " is null"); + + } + + private static boolean isSupportPR(String mech, SecureRandom random) { + return (isDRBG(mech) && ((Instantiation) random.getParameters()) + .getCapability() + .supportsPredictionResistance()); + } + + private interface RunnableCode { + + void run() throws Exception; + } + + /** + * Execute a given code block and verify, if the exception type is expected. + * @param r Code block to run + * @param ex Expected exception type + * @param shouldPass If the code execution expected to pass without failure + * @param msg Message to log in case of expected failure + */ + private static void matchExc(RunnableCode r, boolean shouldPass, Class ex, + String msg) { + try { + r.run(); + if (!shouldPass) { + throw new RuntimeException("Excecution should fail here."); + } + } catch (Exception e) { + System.out.printf("%nOccured exception: %s - Expected exception: " + + "%s : ", e.getClass(), ex.getCanonicalName()); + if (ex.isAssignableFrom(e.getClass())) { + System.out.printf("%n%s : Expected Exception occured: %s : ", + e.getClass(), msg); + } else if (shouldPass) { + throw new RuntimeException(e); + } else { + System.out.printf("Ignore the following exception: %s%n", + e.getMessage()); + } + } + } +} diff --git a/jdk/test/java/security/SecureRandom/EnoughSeedTest.java b/jdk/test/java/security/SecureRandom/EnoughSeedTest.java new file mode 100644 index 00000000000..82c51c04fb4 --- /dev/null +++ b/jdk/test/java/security/SecureRandom/EnoughSeedTest.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8141039 + * @library /lib/testlibrary + * @summary Check SecureRandom generate expected seed counts what the caller + * asked for. + * @run main EnoughSeedTest + */ +import java.security.SecureRandom; +import java.security.Security; +import static java.lang.Math.*; + +public class EnoughSeedTest { + + private static final String DRBG_CONFIG = "securerandom.drbg.config"; + private static final String DRBG_CONFIG_VALUE + = Security.getProperty(DRBG_CONFIG); + + public static void main(String[] args) { + + boolean success = true; + for (String mech : new String[]{ + "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) { + System.out.printf("%nTest for SecureRandom algorithm: '%s'", mech); + try { + SecureRandom sr = null; + if (!mech.contains("_DRBG")) { + sr = SecureRandom.getInstance(mech); + } else { + Security.setProperty(DRBG_CONFIG, mech); + sr = SecureRandom.getInstance("DRBG"); + } + + success &= forEachSeedBytes(sr); + System.out.printf("%nCompleted test for SecureRandom " + + "mechanism: '%s'", mech); + } catch (Exception e) { + success &= false; + e.printStackTrace(System.out); + } finally { + Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE); + } + } + if (!success) { + throw new RuntimeException("At least one test failed."); + } + } + + /** + * Generates fixed number of seed bytes through a SecureRandom instance + * to verify it's seed generation status. + * @param sr SecureRandom instance + * @return The test success indicator + */ + private static boolean forEachSeedBytes(SecureRandom sr) { + boolean success = true; + sr.setSeed(1l); + for (int seedByte : new int[]{Integer.MIN_VALUE, -1, 0, 1, 256, 1024, + Short.MAX_VALUE, (int) pow(2, 20)}) { + try { + byte[] seed = sr.generateSeed(seedByte); + if (seed.length != seedByte) { + throw new RuntimeException("Not able to produce expected " + + "seed size."); + } + } catch (IllegalArgumentException e) { + if (seedByte >= 0) { + throw new RuntimeException("Unknown Exception occured.", e); + } + System.out.printf("%nPASS - Exception expected when required " + + "seed size requested is negative: %s", seedByte); + } + } + return success; + } + +} diff --git a/jdk/test/java/security/SecureRandom/GetAlgorithm.java b/jdk/test/java/security/SecureRandom/GetAlgorithm.java index b1947ef1db8..1ec3fd25ce2 100644 --- a/jdk/test/java/security/SecureRandom/GetAlgorithm.java +++ b/jdk/test/java/security/SecureRandom/GetAlgorithm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,49 +23,54 @@ /** * @test - * @bug 4915392 + * @bug 4915392 8141039 * @summary test that the getAlgorithm() method works correctly * @author Andreas Sterbenz + * @run main GetAlgorithm */ - import java.io.*; - import java.security.*; +import java.util.Arrays; +import java.util.List; public class GetAlgorithm { - private final static String BASE = System.getProperty("test.src", "."); + private static final String BASE = System.getProperty("test.src", "."); + private static final String DRBG_CONFIG = "securerandom.drbg.config"; + private static final String DRBG_CONFIG_VALUE + = Security.getProperty(DRBG_CONFIG); public static void main(String[] args) throws Exception { - SecureRandom sr; - - sr = new SecureRandom(); + SecureRandom sr = new SecureRandom(); if (sr.getAlgorithm().equals("unknown")) { throw new Exception("Unknown: " + sr.getAlgorithm()); } - sr = SecureRandom.getInstance("SHA1PRNG"); - check("SHA1PRNG", sr); - -// OutputStream out = new FileOutputStream("sha1prng.bin"); -// ObjectOutputStream oout = new ObjectOutputStream(out); -// sr.nextInt(); -// oout.writeObject(sr); -// oout.flush(); -// oout.close(); - - sr = new MySecureRandom(); - check("unknown", sr); + for (String mech : new String[]{supportedNativeAlgo(), "SHA1PRNG", + "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) { + if (!mech.contains("_DRBG")) { + check(mech, SecureRandom.getInstance(mech)); + } else { + try { + Security.setProperty(DRBG_CONFIG, mech); + check("DRBG", SecureRandom.getInstance("DRBG")); + } finally { + Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE); + } + } + } + check("unknown", new MySecureRandom()); - InputStream in = new FileInputStream(new File(BASE, "sha1prng-old.bin")); + InputStream in = new FileInputStream( + new File(BASE, "sha1prng-old.bin")); ObjectInputStream oin = new ObjectInputStream(in); - sr = (SecureRandom)oin.readObject(); + sr = (SecureRandom) oin.readObject(); oin.close(); check("unknown", sr); in = new FileInputStream(new File(BASE, "sha1prng-new.bin")); oin = new ObjectInputStream(in); - sr = (SecureRandom)oin.readObject(); + sr = (SecureRandom) oin.readObject(); oin.close(); check("SHA1PRNG", sr); @@ -83,4 +88,17 @@ public class GetAlgorithm { } + /** + * Find the name of supported native mechanism name for current platform. + */ + private static String supportedNativeAlgo() { + String nativeSr = "Windows-PRNG"; + try { + SecureRandom.getInstance(nativeSr); + } catch (NoSuchAlgorithmException e) { + nativeSr = "NativePRNG"; + } + return nativeSr; + } + } diff --git a/jdk/test/java/security/SecureRandom/GetInstanceTest.java b/jdk/test/java/security/SecureRandom/GetInstanceTest.java new file mode 100644 index 00000000000..511188a7709 --- /dev/null +++ b/jdk/test/java/security/SecureRandom/GetInstanceTest.java @@ -0,0 +1,312 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8141039 + * @library /lib/testlibrary + * @summary SecureRandom supports multiple getInstance method including + * getInstanceStrong() method. This test verifies a set of possible + * cases for getInstance with different SecureRandom mechanism + * supported in Java. + * @run main GetInstanceTest + */ +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.SecureRandom; +import java.security.SecureRandomParameters; +import java.security.DrbgParameters; + +import static java.security.DrbgParameters.Capability.*; + +import java.security.Security; +import java.util.Arrays; + +import jdk.testlibrary.Asserts; + +public class GetInstanceTest { + + private static final boolean PASS = true; + private static final String INVALID_ALGO = "INVALID"; + private static final String SUN_PROVIDER = "SUN"; + private static final String INVALID_PROVIDER = "INVALID"; + private static final String STRONG_ALG_SEC_PROP + = "securerandom.strongAlgorithms"; + private static final String DRBG_CONFIG = "securerandom.drbg.config"; + private static final String DRBG_CONFIG_VALUE + = Security.getProperty(DRBG_CONFIG); + + public static void main(String[] args) throws Exception { + + boolean success = true; + // Only accepted failure is NoSuchAlgorithmException. + // For any other failure the test case will fail here. + SecureRandom sr = matchExc(() -> SecureRandom.getInstanceStrong(), + PASS, NoSuchAlgorithmException.class, + "PASS - Undefined security Property " + + "'securerandom.strongAlgorithms'"); + System.out.format("Current platform supports mechanism: '%s' through " + + "provider: '%s' for the method getInstanceStrong().", + sr.getAlgorithm(), sr.getProvider().getName()); + + // DRBG name should appear with "securerandom.strongAlgorithms" + // security property. + String origDRBGConfig = Security.getProperty(STRONG_ALG_SEC_PROP); + if (!origDRBGConfig.contains("DRBG")) { + throw new RuntimeException("DRBG is not associated with default " + + "strong algorithm through security Property: " + + "'securerandom.strongAlgorithms'."); + } + Security.setProperty(STRONG_ALG_SEC_PROP, "DRBG:SUN"); + sr = matchExc(() -> SecureRandom.getInstanceStrong(), + PASS, NoSuchAlgorithmException.class, + "PASS - Undefined security Property " + + "'securerandom.strongAlgorithms'"); + checkAttributes(sr, "DRBG"); + Security.setProperty(STRONG_ALG_SEC_PROP, origDRBGConfig); + + for (String mech : new String[]{ + "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG", INVALID_ALGO,}) { + System.out.printf("%nTest SecureRandom mechanism: '%s'", mech); + try { + if (isDRBG(mech)) { + Security.setProperty(DRBG_CONFIG, mech); + } + verifyInstance(mech); + } catch (Exception e) { + e.printStackTrace(System.out); + success = false; + } finally { + Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE); + } + } + if (!success) { + throw new RuntimeException("At least one test failed."); + } + } + + private static void verifyInstance(String mech) throws Exception { + + String srAlgo = isDRBG(mech) ? "DRBG" : mech; + + // Test for getInstance(algorithm) method. + // It should pass for all case other than invalid algorithm name. + // If it fails then the expected exception type should be + // NoSuchAlgorithmException. Any other Exception type occured will be + // treated as failure. + checkAttributes( + matchExc(() -> SecureRandom.getInstance(srAlgo), !(nsa(mech)), + NoSuchAlgorithmException.class, + String.format("PASS - It is expected to fail for" + + " getInstance(algorithm) when algorithm: '%s'" + + " is null or invalid.", mech)), mech); + // Test for getInstance(algorithm, provider) method. + checkAttributes( + matchExc(() -> SecureRandom.getInstance(srAlgo, + Security.getProvider(SUN_PROVIDER)), + !(nsa(mech)), + NoSuchAlgorithmException.class, + String.format("PASS - It is expected to fail for" + + " getInstance(algorithm, provider) when" + + " algorithm:'%s' is null or invalid.", mech)), + mech); + // Test for getInstance(algorithm, providerName) method. + checkAttributes( + matchExc(() -> SecureRandom.getInstance(srAlgo, SUN_PROVIDER), + !(nsa(mech)), NoSuchAlgorithmException.class, + String.format("PASS - It is expected to fail for " + + "getInstance(algorithm, providerName) when " + + "algorithm: '%s' is null or invalid.", mech)), + mech); + // Test for getInstance(algorithm, providerName) method. + checkAttributes( + matchExc(() -> SecureRandom.getInstance( + srAlgo, INVALID_PROVIDER), + !PASS, NoSuchProviderException.class, + String.format("PASS - It is expected to fail for " + + "getInstance(algorithm, providerName) when " + + "provider name: '%s' is invalid and " + + "algorithm: '%s'", INVALID_PROVIDER, mech)), + mech); + + // Run the test for a set of SecureRandomParameters + for (SecureRandomParameters param : Arrays.asList(null, + DrbgParameters.instantiation(-1, NONE, null))) { + + System.out.printf("%nRunning DRBG param getInstance() methods " + + "for algorithm: %s and DRBG param type: %s", mech, + (param != null) ? param.getClass().getName() : param); + + // Following Test are applicable for new DRBG methods only. + // Test for getInstance(algorithm, params) method. + // Tests are expected to pass for DRBG type with valid parameter + // If it fails the expected exception type is derived from + // getExcType(mech, param) method. If exception type is not + // expected then the test will be considered as failure. + checkAttributes( + matchExc(() -> SecureRandom.getInstance(srAlgo, param), + (isDRBG(mech)) && (isValidDRBGParam(param)), + getExcType(mech, param), + String.format("PASS - It is expected to fail " + + "for getInstance(algorithm, params) " + + "for algorithm: %s and parameter: %s", + mech, param)), + mech); + // Test for getInstance(algorithm, params, provider) method. + checkAttributes( + matchExc(() -> SecureRandom.getInstance(srAlgo, param, + Security.getProvider(SUN_PROVIDER)), + (isDRBG(mech)) && (isValidDRBGParam(param)), + getExcType(mech, param), + String.format("PASS - It is expected to fail " + + "for getInstance(algorithm, params, " + + "provider) for algorithm: %s and " + + "parameter: %s", mech, param)), + mech); + // Test for getInstance(algorithm, params, providerName) method. + checkAttributes( + matchExc(() -> SecureRandom.getInstance(srAlgo, param, + SUN_PROVIDER), + (isDRBG(mech)) && (isValidDRBGParam(param)), + getExcType(mech, param), + String.format("PASS - It is expected to fail " + + "for getInstance(algorithm, params, " + + "providerName) for algorithm: %s and " + + "parameter: %s", mech, param)), mech); + // getInstance(algorithm, params, providerName) when + // providerName is invalid + checkAttributes( + matchExc(() -> SecureRandom.getInstance(srAlgo, param, + INVALID_PROVIDER), + !PASS, ((param == null) + ? IllegalArgumentException.class + : NoSuchProviderException.class), + String.format("PASS - It is expected to fail " + + "for getInstance(algorithm, params, " + + "providerName) when param is null or" + + " provider: %s is invalid for " + + "algorithm: '%s'", INVALID_PROVIDER, + mech)), mech); + // getInstance(algorithm, params, provider) when provider=null + checkAttributes( + matchExc(() -> SecureRandom.getInstance(srAlgo, param, + (String) null), + !PASS, IllegalArgumentException.class, + String.format("PASS - It is expected to fail " + + "for getInstance(algorithm, params, " + + "providerName) when provider name " + + "is null")), mech); + // getInstance(algorithm, params, providerName) when + // providerName is empty. + checkAttributes( + matchExc(() -> SecureRandom.getInstance( + srAlgo, param, ""), + !PASS, IllegalArgumentException.class, + String.format("PASS - It is expected to fail " + + "for getInstance(algorithm, params, " + + "providerName) when provider name " + + "is empty")), mech); + } + } + + private static boolean isValidDRBGParam(SecureRandomParameters param) { + return (param instanceof DrbgParameters.Instantiation); + } + + /** + * If the mechanism should occur NoSuchAlgorithmException. + */ + private static boolean nsa(String mech) { + return mech.equals(INVALID_ALGO); + } + + /** + * Verify if the mechanism is DRBG type. + * @param mech Mechanism name + * @return True if the mechanism name is DRBG type else False. + */ + private static boolean isDRBG(String mech) { + return mech.contains("_DRBG"); + } + + /** + * Type of exception expected for a SecureRandom instance when exception + * occurred while calling getInstance method with a fixed set of parameter. + * @param mech Mechanism used to create a SecureRandom instance + * @param param Parameter to getInstance() method + * @return Exception type expected + */ + private static Class getExcType(String mech, SecureRandomParameters param) { + return ((isDRBG(mech) && !isValidDRBGParam(param)) || param == null) + ? IllegalArgumentException.class + : NoSuchAlgorithmException.class; + } + + private interface RunnableCode { + + SecureRandom run() throws Exception; + } + + /** + * Execute a given code block and verify, if the exception type is expected. + * @param r Code block to run + * @param ex Expected exception type + * @param shouldPass If the code execution expected to pass without failure + * @param msg Message to log in case of expected failure + */ + private static SecureRandom matchExc(RunnableCode r, boolean shouldPass, + Class ex, String msg) { + SecureRandom sr = null; + try { + sr = r.run(); + if (!shouldPass) { + throw new RuntimeException("Excecution should fail here."); + } + } catch (Exception e) { + System.out.printf("%nOccured exception: %s - Expected exception: %s" + + " : ", e.getClass(), ex.getCanonicalName()); + if (ex.isAssignableFrom(e.getClass())) { + System.out.printf("%n%s : Expected Exception: %s : ", + e.getClass(), msg); + } else if (shouldPass) { + throw new RuntimeException(e); + } else { + System.out.printf("%nIgnore the following exception: %s%n", + e.getMessage()); + } + } + return sr; + } + + /** + * Check specific attributes of a SecureRandom instance. + */ + private static void checkAttributes(SecureRandom sr, String mech) { + if (sr == null) { + return; + } + Asserts.assertEquals(sr.getAlgorithm(), (isDRBG(mech) ? "DRBG" : mech)); + Asserts.assertEquals(sr.getProvider().getName(), SUN_PROVIDER); + } + +} diff --git a/jdk/test/java/security/SecureRandom/MultiThreadTest.java b/jdk/test/java/security/SecureRandom/MultiThreadTest.java new file mode 100644 index 00000000000..17ae3377377 --- /dev/null +++ b/jdk/test/java/security/SecureRandom/MultiThreadTest.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.math.BigInteger; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.Security; +import java.util.concurrent.Callable; +import java.util.concurrent.CompletionService; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorCompletionService; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; +import static java.lang.Math.*; + +/* + * @test + * @bug 8141039 + * @library /lib/testlibrary + * @summary Test behavior of a shared SecureRandom object when it is operated + * by multiple threads concurrently. + * @run main MultiThreadTest + */ +public class MultiThreadTest { + + private static final byte[] GEN_RND_BYTES = {1}; + private static final String DRBG_CONFIG = "securerandom.drbg.config"; + private static final String DRBG_CONFIG_VALUE + = Security.getProperty(DRBG_CONFIG); + + private enum SEED { + + NONE, RESEED, SETSEED + } + + public static void main(String[] args) { + + boolean success = true; + for (int byteLen : GEN_RND_BYTES) { + for (SEED reSeed : SEED.values()) { + for (String mech : new String[]{ + "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) { + try { + forEachMech(mech, byteLen, reSeed); + } catch (Exception e) { + success = false; + e.printStackTrace(System.out); + } finally { + Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE); + } + } + } + } + + if (!success) { + throw new RuntimeException("At least one test failed."); + } + } + + /** + * Generate a number of threads to fetch random numbers of certain bits + * generated through a shared SecureRandom instance. + * @param mech Mechanism name + * @param byteLen Number of bytes of random number to produce + * @param reSeed Call reseed() before generating random numbers + * @throws NoSuchAlgorithmException + * @throws InterruptedException + * @throws ExecutionException + */ + private static void forEachMech(String mech, int byteLen, SEED reSeed) + throws NoSuchAlgorithmException, InterruptedException, + ExecutionException { + + if ("SHA1PRNG".equals(mech) && SEED.RESEED.equals(reSeed)) { + System.out.printf( + "%nreseed() api is not supported for '%s'", mech); + return; + } + System.out.printf("%nTest SecureRandom mechanism: '%s' with support of" + + " reseed: '%s'", mech, reSeed); + int threadCount = (int) pow(2, 8 * byteLen); + System.out.printf("%nCreating %s number of threads to generate secure " + + "random numbers concurrently.", threadCount); + + ExecutorService executor + = Executors.newCachedThreadPool(new ThreadFactory() { + @Override + public Thread newThread(Runnable r) { + Thread t = Executors.defaultThreadFactory() + .newThread(r); + t.setDaemon(true); + return t; + } + }); + CompletionService completionService + = new ExecutorCompletionService(executor); + + CountDownLatch latch = new CountDownLatch(1); + SecureRandom rnd = null; + if (!mech.contains("_DRBG")) { + rnd = SecureRandom.getInstance(mech); + } else { + Security.setProperty(DRBG_CONFIG, mech); + rnd = SecureRandom.getInstance("DRBG"); + } + try { + for (int i = 0; i < threadCount; i++) { + completionService.submit(new Task(rnd, latch, byteLen, reSeed)); + } + latch.countDown(); + + for (int i = 0; i < threadCount; i++) { + completionService.take(); + } + } finally { + executor.shutdown(); + } + System.out.printf("%nCompleted Test for algorithm '%s' with thread " + + "counts to '%s' using reseeding '%s'", + mech, threadCount, reSeed); + + } + + /** + * Define a Task to be executed by multiple thread to produce random numbers + * from a shared SecureRandom instance. + */ + private static class Task implements Callable { + + private final SecureRandom random; + private final CountDownLatch latch; + private final SEED reSeed; + private final int byteSize; + + public Task(SecureRandom random, CountDownLatch latch, int byteSize, + SEED reSeed) { + this.random = random; + this.latch = latch; + this.byteSize = byteSize; + this.reSeed = reSeed; + } + + @Override + public Integer call() throws Exception { + latch.await(); + switch (this.reSeed) { + case RESEED: + this.random.reseed(); + break; + case SETSEED: + this.random.setSeed(1l); + break; + } + byte[] bytes = new byte[byteSize]; + random.nextBytes(bytes); + return new BigInteger(bytes).intValue(); + } + } + +} diff --git a/jdk/test/java/security/SecureRandom/SerializedSeedTest.java b/jdk/test/java/security/SecureRandom/SerializedSeedTest.java new file mode 100644 index 00000000000..ba4289ce4c7 --- /dev/null +++ b/jdk/test/java/security/SecureRandom/SerializedSeedTest.java @@ -0,0 +1,214 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8141039 + * @library /lib/testlibrary + * @summary When random number is generated through the a SecureRandom instance + * as well from it's serialized instance in the same time then the + * generated random numbers should be different when one or both are + * reseeded. + * @run main SerializedSeedTest + */ +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.ByteArrayInputStream; +import java.security.NoSuchAlgorithmException; +import java.security.SecureRandom; +import java.security.Security; +import jdk.testlibrary.Asserts; + +public class SerializedSeedTest { + + private static final byte[] SEED = "seed".getBytes(); + private static final String DRBG_CONFIG = "securerandom.drbg.config"; + private static final String DRBG_CONFIG_VALUE + = Security.getProperty(DRBG_CONFIG); + + public static void main(String[] args) { + boolean success = true; + + for (String mech : new String[]{ + "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) { + System.out.printf( + "%nRunning test for SecureRandom mechanism: '%s'", mech); + try { + // Serialize without seed and compare generated random numbers + // produced through original and serialized instances. + SecureRandom orig = getSRInstance(mech); + SecureRandom copy = deserializedCopy(orig); + System.out.printf("%nSerialize without seed. Generated random" + + " numbers should be different."); + check(orig, copy, false, mech); + + // Serialize after default seed and compare generated random + // numbers produced through original and serialized instances. + orig = getSRInstance(mech); + orig.nextInt(); // Default seeded + copy = deserializedCopy(orig); + System.out.printf("%nSerialize after default seed. Generated" + + " random numbers should be same till 20-bytes."); + check(orig, copy, !isDRBG(mech), mech); + + // Serialize after explicit seed and compare generated random + // numbers produced through original and serialized instances. + orig = getSRInstance(mech); + orig.setSeed(SEED); // Explicitly seeded + copy = deserializedCopy(orig); + System.out.printf("%nSerialize after explicit seed. Generated " + + "random numbers should be same till 20-bytes."); + check(orig, copy, !isDRBG(mech), mech); + + // Serialize without seed but original is explicitly seeded + // before generating any random number. Then compare generated + // random numbers produced through original and serialized + // instances. + orig = getSRInstance(mech); + copy = deserializedCopy(orig); + orig.setSeed(SEED); // Explicitly seeded + System.out.printf("%nSerialize without seed. When original is " + + "explicitly seeded before generating random numbers," + + " Generated random numbers should be different."); + check(orig, copy, false, mech); + + // Serialize after default seed but original is explicitly + // seeded before generating any random number. Then compare + // generated random numbers produced through original and + // serialized instances. + orig = getSRInstance(mech); + orig.nextInt(); // Default seeded + copy = deserializedCopy(orig); + orig.setSeed(SEED); // Explicitly seeded + System.out.printf("%nSerialize after default seed but original " + + "is explicitly seeded before generating random number" + + ". Generated random numbers should be different."); + check(orig, copy, false, mech); + + // Serialize after explicit seed but original is explicitly + // seeded again before generating random number. Then compare + // generated random numbers produced through original and + // serialized instances. + orig = getSRInstance(mech); + orig.setSeed(SEED); // Explicitly seeded + copy = deserializedCopy(orig); + orig.setSeed(SEED); // Explicitly seeded + System.out.printf("%nSerialize after explicit seed but " + + "original is explicitly seeded again before " + + "generating random number. Generated random " + + "numbers should be different."); + check(orig, copy, false, mech); + + } catch (Exception e) { + e.printStackTrace(System.out); + success = false; + } finally { + Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE); + } + System.out.printf("%n------Completed Test for %s------", mech); + } + + if (!success) { + throw new RuntimeException("At least one test failed."); + } + } + + /** + * Find if the mechanism is a DRBG mechanism. + * @param mech Mechanism name + * @return True for DRBG mechanism else False + */ + private static boolean isDRBG(String mech) { + return mech.contains("_DRBG"); + } + + /** + * Verify the similarity of random numbers generated though both original + * as well as deserialized instance. + */ + private static void check(SecureRandom orig, SecureRandom copy, + boolean equal, String mech) { + int o = orig.nextInt(); + int c = copy.nextInt(); + System.out.printf("%nRandom number generated for mechanism: '%s' " + + "from original instance as: '%s' and from serialized " + + "instance as: '%s'", mech, o, c); + if (equal) { + Asserts.assertEquals(o, c, mech); + } else { + Asserts.assertNotEquals(o, c, mech); + } + } + + /** + * Get a copy of SecureRandom instance through deserialization. + * @param orig Original SecureRandom instance + * @return Deserialized SecureRandom instance + * @throws IOException + * @throws ClassNotFoundException + */ + private static SecureRandom deserializedCopy(SecureRandom orig) + throws IOException, ClassNotFoundException { + return deserialize(serialize(orig)); + } + + /** + * Deserialize the SecureRandom object. + */ + private static SecureRandom deserialize(byte[] serialized) + throws IOException, ClassNotFoundException { + SecureRandom sr = null; + try (ByteArrayInputStream bis = new ByteArrayInputStream(serialized); + ObjectInputStream ois = new ObjectInputStream(bis)) { + sr = (SecureRandom) ois.readObject(); + } + return sr; + } + + /** + * Serialize the given SecureRandom object. + */ + private static byte[] serialize(SecureRandom sr) throws IOException { + try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(bos)) { + oos.writeObject(sr); + return bos.toByteArray(); + } + } + + /** + * Create a SecureRandom instance for a given mechanism. + */ + private static SecureRandom getSRInstance(String mech) + throws NoSuchAlgorithmException { + if (!isDRBG(mech)) { + return SecureRandom.getInstance(mech); + } else { + Security.setProperty(DRBG_CONFIG, mech); + return SecureRandom.getInstance("DRBG"); + } + } + +} diff --git a/jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java b/jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java index 2a45522cad8..fd0b20cfdb2 100644 --- a/jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java +++ b/jdk/test/sun/security/provider/SecureRandom/StrongSecureRandom.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,11 +21,11 @@ * questions. */ -/** +/* * @test - * @bug 6425477 + * @bug 6425477 8141039 * @summary Better support for generation of high entropy random numbers - * @run main/othervm StrongSecureRandom + * @run main StrongSecureRandom */ import java.security.*; import java.util.*; @@ -35,7 +35,10 @@ import java.util.*; */ public class StrongSecureRandom { - private static String os = System.getProperty("os.name", "unknown"); + private static final String os = System.getProperty("os.name", "unknown"); + private static final String DRBG_CONFIG = "securerandom.drbg.config"; + private static final String DRBG_CONFIG_VALUE + = Security.getProperty(DRBG_CONFIG); private static void testDefaultEgd() throws Exception { // No SecurityManager installed. @@ -47,31 +50,53 @@ public class StrongSecureRandom { } } - private static void testSHA1PRNGImpl() throws Exception { - SecureRandom sr; + /** + * Verify if the mechanism is DRBG type. + * @param mech Mechanism name + * @return True if the mechanism name is DRBG type else False. + */ + private static boolean isDRBG(String mech) { + return mech.contains("_DRBG"); + } + + private static void testSecureRandomImpl(String algo, boolean drbg) + throws Exception { + byte[] ba; + final String secureRandomSource + = Security.getProperty("securerandom.source"); + try { + String urandom = "file:/dev/urandom"; - String urandom = "file:/dev/urandom"; + System.out.println("Testing new SeedGenerator and EGD"); - System.out.println("Testing new SeedGenerator and EGD"); + Security.setProperty("securerandom.source", urandom); + if (!Security.getProperty("securerandom.source").equals(urandom)) { + throw new Exception("Couldn't set securerandom.source"); + } - Security.setProperty("securerandom.source", urandom); - if (!Security.getProperty("securerandom.source").equals(urandom)) { - throw new Exception("Couldn't set securerandom.source"); - } + /* + * Take out a large number of bytes in hopes of blocking. + * Don't expect this to happen, unless something is broken on Linux + */ + SecureRandom sr = null; + if (drbg) { + Security.setProperty(DRBG_CONFIG, algo); + sr = SecureRandom.getInstance("DRBG"); + } else { + sr = SecureRandom.getInstance(algo); + } + if (!sr.getAlgorithm().equals(isDRBG(algo) ? "DRBG" : algo)) { + throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm()); + } - /* - * Take out a large number of bytes in hopes of blocking. - * Don't expect this to happen, unless something is broken on Linux - */ - sr = SecureRandom.getInstance("SHA1PRNG"); - if (!sr.getAlgorithm().equals("SHA1PRNG")) { - throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm()); + ba = sr.generateSeed(4096); + sr.nextBytes(ba); + sr.setSeed(ba); + } finally { + Security.setProperty("securerandom.source", secureRandomSource); + Security.setProperty(DRBG_CONFIG, DRBG_CONFIG_VALUE); } - - ba = sr.generateSeed(4096); - sr.nextBytes(ba); - sr.setSeed(ba); } private static void testNativePRNGImpls() throws Exception { @@ -85,7 +110,7 @@ public class StrongSecureRandom { return; } - System.out.println(" Testing regular"); + System.out.println("Testing regular"); sr = SecureRandom.getInstance("NativePRNG"); if (!sr.getAlgorithm().equals("NativePRNG")) { throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm()); @@ -94,7 +119,7 @@ public class StrongSecureRandom { sr.nextBytes(ba); sr.setSeed(ba); - System.out.println(" Testing NonBlocking"); + System.out.println("Testing NonBlocking"); sr = SecureRandom.getInstance("NativePRNGNonBlocking"); if (!sr.getAlgorithm().equals("NativePRNGNonBlocking")) { throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm()); @@ -108,7 +133,7 @@ public class StrongSecureRandom { return; } - System.out.println(" Testing Blocking"); + System.out.println("Testing Blocking"); sr = SecureRandom.getInstance("NativePRNGBlocking"); if (!sr.getAlgorithm().equals("NativePRNGBlocking")) { throw new Exception("sr.getAlgorithm(): " + sr.getAlgorithm()); @@ -141,9 +166,15 @@ public class StrongSecureRandom { throws Exception { System.out.println("Testing: '" + property + "' " + expected); - - Security.setProperty("securerandom.strongAlgorithms", property); - testStrongInstance(expected); + final String origStrongAlgoProp + = Security.getProperty("securerandom.strongAlgorithms"); + try { + Security.setProperty("securerandom.strongAlgorithms", property); + testStrongInstance(expected); + } finally { + Security.setProperty( + "securerandom.strongAlgorithms", origStrongAlgoProp); + } } private static void testProperties() throws Exception { @@ -228,7 +259,10 @@ public class StrongSecureRandom { public static void main(String args[]) throws Exception { testDefaultEgd(); - testSHA1PRNGImpl(); + for (String algo : new String[]{ + "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) { + testSecureRandomImpl(algo, isDRBG(algo)); + } testNativePRNGImpls(); testAllImpls(); diff --git a/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java b/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java index d91ce78db4b..e6da6be10a1 100644 --- a/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java +++ b/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java @@ -1,5 +1,6 @@ /* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, 2016, Oracle and/or its affiliates. All rights + * reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +24,7 @@ /* * @test - * @bug 6998583 + * @bug 6998583 8141039 * @summary NativeSeedGenerator is making 8192 byte read requests from * entropy pool on each init. * @run main SeedGeneratorChoice @@ -39,14 +40,24 @@ * We should always fall back to the ThreadedSeedGenerator if exceptions * are encountered with user defined source of entropy. */ - import java.security.SecureRandom; +import java.security.Security; public class SeedGeneratorChoice { public static void main(String... arguments) throws Exception { - byte[] bytes; - SecureRandom prng = SecureRandom.getInstance("SHA1PRNG"); - bytes = prng.generateSeed(1); + for (String mech : new String[]{"SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", + "CTR_DRBG"}) { + + SecureRandom prng = null; + if (!mech.contains("_DRBG")) { + prng = SecureRandom.getInstance(mech); + } else { + Security.setProperty("securerandom.drbg.config", mech); + prng = SecureRandom.getInstance("DRBG"); + } + prng.generateSeed(1); + } } + } -- GitLab From 958506d2cbdbe84026189dd5e0b20aa41056e4ce Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Thu, 19 May 2016 13:08:36 +0100 Subject: [PATCH 085/400] 8157290: jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java failing Reviewed-by: chegar --- .../overlappingpackages/OverlappingPackagesTest.java | 10 ++-------- .../src/misc/{sun => jdk/internal}/misc/Unsafe.java | 2 +- .../overlappingpackages/src/misc/module-info.java | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) rename jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/{sun => jdk/internal}/misc/Unsafe.java (97%) diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java b/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java index 826e282326a..529996e8e7d 100644 --- a/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java +++ b/jdk/test/jdk/modules/scenarios/overlappingpackages/OverlappingPackagesTest.java @@ -66,13 +66,7 @@ public class OverlappingPackagesTest { } Path srcMisc = SRC_DIR.resolve("misc"); Path modsMisc = MODS_DIR.resolve("misc"); - assertTrue(CompilerUtils.compile(srcMisc.resolve("sun") - .resolve("misc") - .resolve("Unsafe.java"), - modsMisc, - "-Xmodule:java.base")); - assertTrue(CompilerUtils.compile(srcMisc.resolve("module-info.java"), - modsMisc)); + assertTrue(CompilerUtils.compile(srcMisc, modsMisc)); } /** @@ -92,7 +86,7 @@ public class OverlappingPackagesTest { /** * Run the test with "-addmods misc", the misc module has package - * sun.misc and so should overlap with the base module. + * jdk.internal.misc and so should overlap with the base module. */ public void testOverlapWithBaseModule() throws Exception { int exitValue diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java b/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/jdk/internal/misc/Unsafe.java similarity index 97% rename from jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java rename to jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/jdk/internal/misc/Unsafe.java index 135652ea9b7..0b4aa917ccd 100644 --- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java +++ b/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/jdk/internal/misc/Unsafe.java @@ -21,7 +21,7 @@ * questions. */ -package sun.misc; +package jdk.internal.misc; public class Unsafe { private Unsafe() { } diff --git a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/module-info.java b/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/module-info.java index 65cc15d749b..d4f3bd98b69 100644 --- a/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/module-info.java +++ b/jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/module-info.java @@ -22,6 +22,6 @@ */ module misc { - exports sun.misc; + exports jdk.internal.misc; } -- GitLab From bed9953556c8d5694a4fbbadb19ed52dc96c3022 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Thu, 19 May 2016 13:10:08 +0100 Subject: [PATCH 086/400] 8148834: Update module-info reader/writer to 53.0 Reviewed-by: sundar, chegar --- .../java.base/share/classes/java/lang/module/ModuleInfo.java | 2 +- .../share/classes/jdk/internal/module/ModuleInfoWriter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java b/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java index efc8c37b8a2..7bf9342ca88 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java +++ b/jdk/src/java.base/share/classes/java/lang/module/ModuleInfo.java @@ -154,7 +154,7 @@ final class ModuleInfo { int minor_version = in.readUnsignedShort(); int major_version = in.readUnsignedShort(); if (major_version < 53) { - // throw invalidModuleDescriptor"Must be >= 53.0"); + throw invalidModuleDescriptor("Must be >= 53.0"); } ConstantPool cpool = new ConstantPool(in); diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java index 1fb433b9f7c..c86416e1dab 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/ModuleInfoWriter.java @@ -54,7 +54,7 @@ public final class ModuleInfoWriter { ClassWriter cw = new ClassWriter(0); String name = md.name().replace('.', '/') + "/module-info"; - cw.visit(Opcodes.V1_8, ACC_MODULE, name, null, null, null); + cw.visit(Opcodes.V1_9, ACC_MODULE, name, null, null, null); cw.visitAttribute(new ModuleAttribute(md)); cw.visitAttribute(new ConcealedPackagesAttribute(md.conceals())); -- GitLab From 0516c0ca0cc1ceb0fa39e2cd6323888d7de1357e Mon Sep 17 00:00:00 2001 From: Aleksei Efimov Date: Thu, 19 May 2016 15:58:44 +0300 Subject: [PATCH 087/400] 8157096: [TEST_BUG] test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java is skipped by jtreg Reviewed-by: shade, joehw --- jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java b/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java index 37b817d0b4d..cc1be256343 100644 --- a/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java +++ b/jdk/test/javax/xml/bind/xjc/8145039/JaxbMarshallTest.java @@ -23,10 +23,10 @@ /* * @test - * @bug 8145039 + * @bug 8145039 8157096 * @summary Check that marshalling of xjc generated class doesn't throw * ClassCast exception. - * @modules javax.xml.bind + * @modules java.xml.bind * @library /lib/testlibrary * @run testng/othervm JaxbMarshallTest */ @@ -127,6 +127,8 @@ public class JaxbMarshallTest { // Compile java classes with javac tool void compileXjcGeneratedClasses() throws Exception { JDKToolLauncher javacLauncher = JDKToolLauncher.createUsingTestJDK("javac"); + javacLauncher.addToolArg("-addmods"); + javacLauncher.addToolArg("java.xml.bind"); javacLauncher.addToolArg(xjcResultDir.resolve("ObjectFactory.java").toString()); javacLauncher.addToolArg(xjcResultDir.resolve("TypesLongList.java").toString()); javacLauncher.addToolArg(xjcResultDir.resolve("package-info.java").toString()); -- GitLab From 4417a1f36fb6448366dc3231175df874f354fee6 Mon Sep 17 00:00:00 2001 From: Aleksei Efimov Date: Thu, 19 May 2016 16:08:39 +0300 Subject: [PATCH 088/400] 8072579: XjcOptionalPropertyTest.java creates files in test.src Reviewed-by: joehw --- .../xjc/8032884/XjcOptionalPropertyTest.java | 102 ++++++++++++++---- .../xml/bind/xjc/8032884/compile-schema.sh | 39 ------- 2 files changed, 81 insertions(+), 60 deletions(-) delete mode 100644 jdk/test/javax/xml/bind/xjc/8032884/compile-schema.sh diff --git a/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java b/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java index 4a556efce13..9cc57cfcdae 100644 --- a/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java +++ b/jdk/test/javax/xml/bind/xjc/8032884/XjcOptionalPropertyTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,47 +23,107 @@ /* * @test - * @bug 8032884 + * @bug 8032884 8072579 * @summary Globalbindings optionalProperty="primitive" does not work when minOccurs=0 - * @run shell compile-schema.sh - * @compile -addmods java.xml.bind XjcOptionalPropertyTest.java - * @run main/othervm XjcOptionalPropertyTest + * @library /lib/testlibrary + * @modules java.xml.bind + * @run testng/othervm XjcOptionalPropertyTest */ import java.io.IOException; import java.lang.reflect.Method; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; +import java.util.Arrays; +import jdk.testlibrary.JDKToolLauncher; +import org.testng.Assert; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; public class XjcOptionalPropertyTest { - public static void main(String[] args) throws IOException { - - generated.Foo foo = new generated.Foo(); - log("foo = " + foo); + @Test + public void optionalPropertyTest() throws Exception { + runXjc(); + compileXjcGeneratedClasses(); + URLClassLoader testClassLoader; + testClassLoader = URLClassLoader.newInstance(new URL[]{testWorkDirUrl}); + Class fooClass = testClassLoader.loadClass(CLASS_TO_TEST); + Object foo = fooClass.newInstance(); Method[] methods = foo.getClass().getMethods(); - log("Found [" + methods.length + "] methods"); + System.out.println("Found [" + methods.length + "] methods"); for (int i = 0; i < methods.length; i++) { Method method = methods[i]; if (method.getName().equals("setFoo")) { - log("Checking method [" + method.getName() + "]"); + System.out.println("Checking method [" + method.getName() + "]"); Class[] parameterTypes = method.getParameterTypes(); - if (parameterTypes.length != 1) - fail("more than 1 parameter"); - if (!parameterTypes[0].isPrimitive()) { - fail("Found [" + parameterTypes[0].getName() + "], but expected primitive!"); - } + Assert.assertEquals(parameterTypes.length, 1); + Assert.assertTrue(parameterTypes[0].isPrimitive()); break; } } - log("TEST PASSED."); + } + @BeforeTest + public void setUp() throws IOException { + // Create test directory inside scratch + testWorkDir = Paths.get(System.getProperty("user.dir", ".")); + // Save its URL + testWorkDirUrl = testWorkDir.toUri().toURL(); + // Get test source directory path + testSrcDir = Paths.get(System.getProperty("test.src", ".")); + // Get path of xjc result folder + xjcResultDir = testWorkDir.resolve(TEST_PACKAGE); + // Copy schema document file to scratch directory + Files.copy(testSrcDir.resolve(XSD_FILENAME), testWorkDir.resolve(XSD_FILENAME), REPLACE_EXISTING); } - private static void fail(String message) { - throw new RuntimeException(message); + // Compile schema file into java classes definitions + void runXjc() throws Exception { + // Prepare process builder to run schemagen tool and save its output + JDKToolLauncher xjcLauncher = JDKToolLauncher.createUsingTestJDK("xjc"); + xjcLauncher.addToolArg(XSD_FILENAME); + System.out.println("Executing xjc command: " + Arrays.asList(xjcLauncher.getCommand())); + ProcessBuilder pb = new ProcessBuilder(xjcLauncher.getCommand()); + // Set xjc work directory with the input java file + pb.directory(testWorkDir.toFile()); + pb.inheritIO(); + Process p = pb.start(); + p.waitFor(); + p.destroy(); } - private static void log(String msg) { - System.out.println(msg); + // Compile java classes with javac tool + void compileXjcGeneratedClasses() throws Exception { + JDKToolLauncher javacLauncher = JDKToolLauncher.createUsingTestJDK("javac"); + javacLauncher.addToolArg("-addmods"); + javacLauncher.addToolArg("java.xml.bind"); + javacLauncher.addToolArg(xjcResultDir.resolve("Foo.java").toString()); + System.out.println("Compiling xjc generated class: " + Arrays.asList(javacLauncher.getCommand())); + ProcessBuilder pb = new ProcessBuilder(javacLauncher.getCommand()); + pb.inheritIO(); + pb.directory(testWorkDir.toFile()); + Process p = pb.start(); + p.waitFor(); + p.destroy(); } + // Test schema filename + static final String XSD_FILENAME = "optional-property-schema.xsd"; + // Test package with generated class + static final String TEST_PACKAGE = "anamespace"; + // Name of generated java class + static final String CLASS_TO_TEST = TEST_PACKAGE+".Foo"; + // Test working directory + Path testWorkDir; + // Test working directory URL + URL testWorkDirUrl; + // Directory with test src + Path testSrcDir; + // Directory with java files generated by xjc + Path xjcResultDir; } diff --git a/jdk/test/javax/xml/bind/xjc/8032884/compile-schema.sh b/jdk/test/javax/xml/bind/xjc/8032884/compile-schema.sh deleted file mode 100644 index 8051abf438a..00000000000 --- a/jdk/test/javax/xml/bind/xjc/8032884/compile-schema.sh +++ /dev/null @@ -1,39 +0,0 @@ -#! /bin/sh - -# -# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# - -if [ "x$TESTJAVA" = x ]; then - TESTJAVA=$1; shift - TESTCLASSES=. -fi - -echo "cleaning generated files ..." -rm -rfv ${TESTSRC}/generated - -echo "compiling [optional-property-schema.xsd] schema ..." -$TESTJAVA/bin/xjc -p generated -d ${TESTSRC} ${TESTSRC}/optional-property-schema.xsd - -echo "Schema compiled. Verification of generated files can be done now." -- GitLab From 55889705b0a971e57a45290f691cce2b1569953f Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 19 May 2016 16:59:31 +0300 Subject: [PATCH 089/400] 8148604: JEP 280, Switch to more optimal concatenation strategy Reviewed-by: psandoz, redestad --- .../share/classes/java/lang/invoke/StringConcatFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java index 0d965ed5a54..7da455097b8 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/StringConcatFactory.java @@ -128,7 +128,7 @@ public final class StringConcatFactory { /** * Default strategy to use for concatenation. */ - private static final Strategy DEFAULT_STRATEGY = Strategy.BC_SB; + private static final Strategy DEFAULT_STRATEGY = Strategy.MH_INLINE_SIZED_EXACT; private enum Strategy { /** -- GitLab From 4b1159ce768d7a1ee3a768bf7c7c4abba270f108 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 19 May 2016 16:08:40 +0200 Subject: [PATCH 090/400] 8157239: java/lang/invoke/VarHandles/ tests fail by timeout with -Xcomp with lambda form linkage Reviewed-by: vlivanov --- .../java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java | 1 - .../java/lang/invoke/VarHandles/VarHandleTestAccessByte.java | 1 - .../java/lang/invoke/VarHandles/VarHandleTestAccessChar.java | 1 - .../java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java | 1 - .../java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java | 1 - jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java | 1 - .../java/lang/invoke/VarHandles/VarHandleTestAccessLong.java | 1 - .../java/lang/invoke/VarHandles/VarHandleTestAccessShort.java | 1 - .../java/lang/invoke/VarHandles/VarHandleTestAccessString.java | 1 - .../lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java | 1 - .../lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java | 1 - .../lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java | 1 - .../java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java | 1 - .../lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java | 1 - .../lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java | 1 - .../VarHandles/VarHandleTestMethodHandleAccessBoolean.java | 1 - .../invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java | 1 - .../invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java | 1 - .../invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java | 1 - .../invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java | 1 - .../invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java | 1 - .../invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java | 1 - .../invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java | 1 - .../invoke/VarHandles/VarHandleTestMethodHandleAccessString.java | 1 - .../lang/invoke/VarHandles/X-VarHandleTestAccess.java.template | 1 - .../invoke/VarHandles/X-VarHandleTestByteArrayView.java.template | 1 - .../VarHandles/X-VarHandleTestMethodHandleAccess.java.template | 1 - 27 files changed, 27 deletions(-) diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java index 06d2a65b1dd..9a02753d945 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessBoolean.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessBoolean * @run testng/othervm -Diters=20000 VarHandleTestAccessBoolean * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessBoolean - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessBoolean */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java index 2ba0afbef2d..17544907e8d 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessByte.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessByte * @run testng/othervm -Diters=20000 VarHandleTestAccessByte * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessByte - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessByte */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java index bcc42a3c335..88bad8475cb 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessChar.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessChar * @run testng/othervm -Diters=20000 VarHandleTestAccessChar * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessChar - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessChar */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java index 74f0765f709..1861e5919dc 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessDouble.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessDouble * @run testng/othervm -Diters=20000 VarHandleTestAccessDouble * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessDouble - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessDouble */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java index 241e0897414..dce87f72755 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessFloat.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessFloat * @run testng/othervm -Diters=20000 VarHandleTestAccessFloat * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessFloat - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessFloat */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java index 3adb9b83fa7..1897821dc06 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessInt.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessInt * @run testng/othervm -Diters=20000 VarHandleTestAccessInt * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessInt - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessInt */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java index 9afb2de8320..adea5ed82a1 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessLong.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessLong * @run testng/othervm -Diters=20000 VarHandleTestAccessLong * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessLong - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessLong */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java index a64ed990cb9..a8091a838cb 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessShort.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessShort * @run testng/othervm -Diters=20000 VarHandleTestAccessShort * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessShort - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessShort */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java index 74f08bda535..405206ef22c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestAccessString.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccessString * @run testng/othervm -Diters=20000 VarHandleTestAccessString * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccessString - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccessString */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java index a2221b50a20..8038315e391 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsChar.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsChar * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsChar * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsChar - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsChar */ import org.testng.annotations.DataProvider; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java index 79305710ce2..53db9cd239b 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsDouble.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsDouble * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsDouble * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsDouble - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsDouble */ import org.testng.annotations.DataProvider; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java index b3545b4f69c..d2688cf925a 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsFloat.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsFloat * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsFloat * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsFloat - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsFloat */ import org.testng.annotations.DataProvider; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java index b733bb34054..9e47532c20b 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsInt.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsInt * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsInt * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsInt - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsInt */ import org.testng.annotations.DataProvider; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java index 88bf198272b..f9ed92f0e07 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsLong.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsLong * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsLong * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsLong - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsLong */ import org.testng.annotations.DataProvider; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java index 5ed9d6099f7..0a9aa6e871c 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestByteArrayAsShort.java @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAsShort * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAsShort * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAsShort - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAsShort */ import org.testng.annotations.DataProvider; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java index f43fcc1b82c..32761fe0e3f 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessBoolean.java @@ -24,7 +24,6 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessBoolean - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessBoolean */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java index 3d5c27e8bfd..8c36eb861c5 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessByte.java @@ -24,7 +24,6 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessByte - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessByte */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java index bde76a69c05..fb1f3877342 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessChar.java @@ -24,7 +24,6 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessChar - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessChar */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java index de683ce6997..cd2c15d04d3 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessDouble.java @@ -24,7 +24,6 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessDouble - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessDouble */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java index 99309e5081f..58d9e295298 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessFloat.java @@ -24,7 +24,6 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessFloat - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessFloat */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java index fc0e8f214f9..00f78a57159 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessInt.java @@ -24,7 +24,6 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessInt - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessInt */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java index 0f265da3f2e..2bb8b9a1ee8 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessLong.java @@ -24,7 +24,6 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessLong - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessLong */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java index 51b51e73747..6edc9b19b68 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessShort.java @@ -24,7 +24,6 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessShort - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessShort */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java index ce5167a0b91..dc6f8ec1861 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodHandleAccessString.java @@ -24,7 +24,6 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccessString - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccessString */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template index cb33f8ff070..5dfd82f6cd7 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestAccess.java.template @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestAccess$Type$ * @run testng/othervm -Diters=20000 VarHandleTestAccess$Type$ * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestAccess$Type$ - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestAccess$Type$ */ import org.testng.annotations.BeforeClass; diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template index 1cb19b7893e..615bb528e06 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestByteArrayView.java.template @@ -27,7 +27,6 @@ * @run testng/othervm -Diters=20000 -XX:TieredStopAtLevel=1 VarHandleTestByteArrayAs$Type$ * @run testng/othervm -Diters=20000 VarHandleTestByteArrayAs$Type$ * @run testng/othervm -Diters=20000 -XX:-TieredCompilation VarHandleTestByteArrayAs$Type$ - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestByteArrayAs$Type$ */ import org.testng.annotations.DataProvider; diff --git a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template index f943bf2611b..e4bd78e8f45 100644 --- a/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template +++ b/jdk/test/java/lang/invoke/VarHandles/X-VarHandleTestMethodHandleAccess.java.template @@ -24,7 +24,6 @@ /* * @test * @run testng/othervm -Diters=20000 VarHandleTestMethodHandleAccess$Type$ - * @run testng/othervm -Diters=20000 -Djava.lang.invoke.VarHandle.VAR_HANDLE_GUARDS=false VarHandleTestMethodHandleAccess$Type$ */ import org.testng.annotations.BeforeClass; -- GitLab From 2100b2e6c212c4abe078484b0f7bb78a09e255b1 Mon Sep 17 00:00:00 2001 From: Artem Smotrakov Date: Thu, 19 May 2016 09:16:59 -0700 Subject: [PATCH 091/400] 8134267: javax/net/ssl/TLS/TestJSSE.java fails intermittently with BindException: Address already in use Reviewed-by: chegar --- .../javax/net/ssl/TLS/CipherTestUtils.java | 52 +++++++++++++------ jdk/test/javax/net/ssl/TLS/JSSEServer.java | 6 ++- jdk/test/javax/net/ssl/TLS/TestJSSE.java | 35 ++++++------- 3 files changed, 56 insertions(+), 37 deletions(-) diff --git a/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java b/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java index a86b10abd26..04020bc6f03 100644 --- a/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java +++ b/jdk/test/javax/net/ssl/TLS/CipherTestUtils.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it under @@ -202,6 +202,8 @@ public class CipherTestUtils { @Override public abstract void run(); + abstract int getPort(); + void handleRequest(InputStream in, OutputStream out) throws IOException { boolean newline = false; @@ -528,9 +530,9 @@ public class CipherTestUtils { return ks; } - public static void main(PeerFactory peerFactory, String mode, - String expectedException) - throws Exception { + public static int mainServer(PeerFactory peerFactory, + String expectedException) throws Exception { + long time = System.currentTimeMillis(); setTestedArguments(peerFactory.getTestedProtocol(), peerFactory.getTestedCipher()); @@ -540,33 +542,49 @@ public class CipherTestUtils { secureRandom.nextInt(); CipherTestUtils cipherTest = CipherTestUtils.getInstance(); - if (mode.equalsIgnoreCase("Server")) { // server mode - Thread serverThread = new Thread(peerFactory.newServer(cipherTest), - "Server"); - serverThread.start(); - } else if (mode.equalsIgnoreCase("Client")) { - peerFactory.newClient(cipherTest).run(); - cipherTest.checkResult(expectedException); - JSSEServer.closeServer = true; - } else { - throw new RuntimeException("unsupported mode"); - } + Server server = peerFactory.newServer(cipherTest, PeerFactory.FREE_PORT); + Thread serverThread = new Thread(server, "Server"); + serverThread.start(); + time = System.currentTimeMillis() - time; System.out.println("Elapsed time " + time); + return server.getPort(); + } + + public static void mainClient(PeerFactory peerFactory, int port, + String expectedException) throws Exception { + + long time = System.currentTimeMillis(); + setTestedArguments(peerFactory.getTestedProtocol(), + peerFactory.getTestedCipher()); + + System.out.print( + " Initializing test '" + peerFactory.getName() + "'..."); + secureRandom.nextInt(); + + CipherTestUtils cipherTest = CipherTestUtils.getInstance(); + peerFactory.newClient(cipherTest, port).run(); + cipherTest.checkResult(expectedException); + JSSEServer.closeServer = true; + + time = System.currentTimeMillis() - time; + System.out.println("Elapsed time " + time); } public static abstract class PeerFactory { + public static final int FREE_PORT = 0; + abstract String getName(); abstract String getTestedProtocol(); abstract String getTestedCipher(); - abstract Client newClient(CipherTestUtils cipherTest) throws Exception; + abstract Client newClient(CipherTestUtils cipherTest, int testPort) throws Exception; - abstract Server newServer(CipherTestUtils cipherTest) throws Exception; + abstract Server newServer(CipherTestUtils cipherTest, int testPort) throws Exception; boolean isSupported(String cipherSuite) { return true; diff --git a/jdk/test/javax/net/ssl/TLS/JSSEServer.java b/jdk/test/javax/net/ssl/TLS/JSSEServer.java index f6e55a31706..1ece6f0f8b8 100644 --- a/jdk/test/javax/net/ssl/TLS/JSSEServer.java +++ b/jdk/test/javax/net/ssl/TLS/JSSEServer.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it under @@ -77,4 +77,8 @@ public class JSSEServer extends CipherTestUtils.Server { } } } + + int getPort() { + return serverSocket.getLocalPort(); + } } diff --git a/jdk/test/javax/net/ssl/TLS/TestJSSE.java b/jdk/test/javax/net/ssl/TLS/TestJSSE.java index d4c41480c0b..d477e4facdf 100644 --- a/jdk/test/javax/net/ssl/TLS/TestJSSE.java +++ b/jdk/test/javax/net/ssl/TLS/TestJSSE.java @@ -27,10 +27,8 @@ import java.security.Security; /** * @test * @bug 8049429 - * @library ../../../../lib/testlibrary/ * @modules java.management * jdk.crypto.ec/sun.security.ec - * @build jdk.testlibrary.Utils * @compile CipherTestUtils.java JSSEClient.java JSSEServer.java * @summary Test that all cipher suites work in all versions and all client * authentication types. The way this is setup the server is stateless and @@ -86,7 +84,6 @@ public class TestJSSE { String serverProtocol = System.getProperty("SERVER_PROTOCOL"); String clientProtocol = System.getProperty("CLIENT_PROTOCOL"); - int port = jdk.testlibrary.Utils.getFreePort(); String cipher = System.getProperty("CIPHER"); if (serverProtocol == null || clientProtocol == null @@ -97,7 +94,7 @@ public class TestJSSE { out.println("ServerProtocol =" + serverProtocol); out.println("ClientProtocol =" + clientProtocol); out.println("Cipher =" + cipher); - server(serverProtocol, cipher, port, args); + int port = server(serverProtocol, cipher, args); client(port, clientProtocol, cipher, args); } @@ -112,28 +109,30 @@ public class TestJSSE { out.println(" Testing - Protocol : " + testProtocols); out.println(" Testing - Cipher : " + testCipher); try { - CipherTestUtils.main(new JSSEFactory(LOCAL_IP, - testPort, testProtocols, - testCipher, "client JSSE"), - "client", expectedException); + CipherTestUtils.mainClient(new JSSEFactory(LOCAL_IP, testProtocols, + testCipher, "Client JSSE"), + testPort, expectedException); } catch (Exception e) { throw new RuntimeException(e); } } - public static void server(String testProtocol, String testCipher, - int testPort, + public static int server(String testProtocol, String testCipher, String... exception) throws Exception { + String expectedException = exception.length >= 1 ? exception[0] : null; out.println(" This is Server"); out.println(" Testing Protocol: " + testProtocol); out.println(" Testing Cipher: " + testCipher); - out.println(" Testing Port: " + testPort); + try { - CipherTestUtils.main(new JSSEFactory(null, testPort, - testProtocol, testCipher, "Server JSSE"), - "Server", expectedException); + int port = CipherTestUtils.mainServer(new JSSEFactory( + null, testProtocol, testCipher, "Server JSSE"), + expectedException); + + out.println(" Testing Port: " + port); + return port; } catch (Exception e) { throw new RuntimeException(e); } @@ -142,15 +141,13 @@ public class TestJSSE { private static class JSSEFactory extends CipherTestUtils.PeerFactory { final String testedCipherSuite, testedProtocol, testHost; - final int testPort; final String name; - JSSEFactory(String testHost, int testPort, String testedProtocol, + JSSEFactory(String testHost, String testedProtocol, String testedCipherSuite, String name) { this.testedCipherSuite = testedCipherSuite; this.testedProtocol = testedProtocol; this.testHost = testHost; - this.testPort = testPort; this.name = name; } @@ -170,14 +167,14 @@ public class TestJSSE { } @Override - CipherTestUtils.Client newClient(CipherTestUtils cipherTest) + CipherTestUtils.Client newClient(CipherTestUtils cipherTest, int testPort) throws Exception { return new JSSEClient(cipherTest, testHost, testPort, testedProtocol, testedCipherSuite); } @Override - CipherTestUtils.Server newServer(CipherTestUtils cipherTest) + CipherTestUtils.Server newServer(CipherTestUtils cipherTest, int testPort) throws Exception { return new JSSEServer(cipherTest, testPort, testedProtocol, testedCipherSuite); -- GitLab From 16c12980fa42611662992f7591b23082b8812803 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 19 May 2016 17:48:02 +0000 Subject: [PATCH 092/400] Added tag jdk-9+119 for changeset 3cc95b690353 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 2b6d80debed..b7e36c324d5 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -361,3 +361,4 @@ bb8379287f3736f38c52b2d1418784e2592461d1 jdk-9+114 baeb5edb38939cdb78ae0ac6f4fd368465cbf188 jdk-9+116 4da0f73ce03aaf245b92cc040cc0ab0e3fa54dc2 jdk-9+117 e1eba5cfa5cc8c66d524396a05323dc93568730a jdk-9+118 +bad3f8a33db271a6143ba6eac0c8bd5bbd942417 jdk-9+119 -- GitLab From ab6efe7a7d33414a96aabc519487a687ffe4a54c Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Thu, 19 May 2016 11:17:35 -0700 Subject: [PATCH 093/400] 8157068: ExceptionInInitializerError if images build patched to use exploded version of jdk.internal.module.SystemModules Reviewed-by: alanb --- .../java/lang/module/SystemModuleFinder.java | 157 ++++++++---- .../jdk/internal/jimage/ImageReader.java | 11 + .../jdk/internal/module/SystemModules.java | 6 +- .../modules/patch/{ => basic}/PatchTest.java | 0 .../{ => basic}/src/test/jdk/test/Main.java | 0 .../{ => basic}/src/test/module-info.java | 0 .../src1/java.base/java/text/Annotation.java | 0 .../java.base/java/text/AnnotationBuddy.java | 0 .../com/sun/tools/javac/Main.java | 0 .../com/sun/tools/javac/MainBuddy.java | 0 .../com/sun/jndi/dns/DnsClient.java | 0 .../com/sun/jndi/dns/DnsClientBuddy.java | 0 .../src2/java.base/java/lang2/Object.java | 0 .../com/sun/tools/javac2/Main.java | 0 .../com/sun/jndi/dns2/Zone.java | 0 .../systemmodules/PatchSystemModules.java | 225 ++++++++++++++++++ .../systemmodules/src/m1/module-info.java | 26 ++ .../patch/systemmodules/src/m1/p1/Main.java | 34 +++ .../systemmodules/src/m2/module-info.java | 26 ++ .../patch/systemmodules/src/m2/p2/Lib.java | 30 +++ .../jdk/internal/modules/SystemModules.java | 32 +++ .../patch/systemmodules/src1/m2/p2/Lib.java | 30 +++ 22 files changed, 528 insertions(+), 49 deletions(-) rename jdk/test/tools/launcher/modules/patch/{ => basic}/PatchTest.java (100%) rename jdk/test/tools/launcher/modules/patch/{ => basic}/src/test/jdk/test/Main.java (100%) rename jdk/test/tools/launcher/modules/patch/{ => basic}/src/test/module-info.java (100%) rename jdk/test/tools/launcher/modules/patch/{ => basic}/src1/java.base/java/text/Annotation.java (100%) rename jdk/test/tools/launcher/modules/patch/{ => basic}/src1/java.base/java/text/AnnotationBuddy.java (100%) rename jdk/test/tools/launcher/modules/patch/{ => basic}/src1/jdk.compiler/com/sun/tools/javac/Main.java (100%) rename jdk/test/tools/launcher/modules/patch/{ => basic}/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java (100%) rename jdk/test/tools/launcher/modules/patch/{ => basic}/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java (100%) rename jdk/test/tools/launcher/modules/patch/{ => basic}/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java (100%) rename jdk/test/tools/launcher/modules/patch/{ => basic}/src2/java.base/java/lang2/Object.java (100%) rename jdk/test/tools/launcher/modules/patch/{ => basic}/src2/jdk.compiler/com/sun/tools/javac2/Main.java (100%) rename jdk/test/tools/launcher/modules/patch/{ => basic}/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java (100%) create mode 100644 jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java create mode 100644 jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/module-info.java create mode 100644 jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/p1/Main.java create mode 100644 jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/module-info.java create mode 100644 jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/p2/Lib.java create mode 100644 jdk/test/tools/launcher/modules/patch/systemmodules/src1/java.base/jdk/internal/modules/SystemModules.java create mode 100644 jdk/test/tools/launcher/modules/patch/systemmodules/src1/m2/p2/Lib.java diff --git a/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java b/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java index d14ee8d60e4..77d5392821a 100644 --- a/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java +++ b/jdk/src/java.base/share/classes/java/lang/module/SystemModuleFinder.java @@ -45,6 +45,7 @@ import jdk.internal.jimage.ImageLocation; import jdk.internal.jimage.ImageReader; import jdk.internal.jimage.ImageReaderFactory; import jdk.internal.module.ModuleHashes; +import jdk.internal.module.ModuleHashes.HashSupplier; import jdk.internal.module.SystemModules; import jdk.internal.module.ModulePatcher; import jdk.internal.perf.PerfCounter; @@ -84,57 +85,23 @@ class SystemModuleFinder implements ModuleFinder { long t0 = System.nanoTime(); imageReader = ImageReaderFactory.getImageReader(); - String[] moduleNames = SystemModules.MODULE_NAMES; - ModuleDescriptor[] descriptors = null; + String[] names = moduleNames(); + ModuleDescriptor[] descriptors = descriptors(names); - boolean fastLoad = System.getProperty("jdk.installed.modules.disable") == null; - if (fastLoad) { - // fast loading of ModuleDescriptor of installed modules - descriptors = SystemModules.modules(); - } - - int n = moduleNames.length; + int n = names.length; moduleCount.add(n); Set mods = new HashSet<>(n); Map map = new HashMap<>(n); for (int i = 0; i < n; i++) { - String mn = moduleNames[i]; - ModuleDescriptor md; - String hash; - if (fastLoad) { - md = descriptors[i]; - hash = SystemModules.MODULES_TO_HASH[i]; - } else { - // fallback to read module-info.class - // if fast loading of ModuleDescriptors is disabled - ImageLocation location = imageReader.findLocation(mn, "module-info.class"); - md = ModuleDescriptor.read(imageReader.getResourceBuffer(location)); - hash = null; - } - if (!md.name().equals(mn)) - throw new InternalError(); + ModuleDescriptor md = descriptors[i]; // create the ModuleReference - - URI uri = URI.create("jrt:/" + mn); - - Supplier readerSupplier = new Supplier<>() { - @Override - public ModuleReader get() { - return new ImageModuleReader(mn, uri); - } - }; - - ModuleReference mref = - new ModuleReference(md, uri, readerSupplier, hashSupplier(hash)); - - // may need a reference to a patched module if -Xpatch specified - mref = ModulePatcher.interposeIfNeeded(mref); + ModuleReference mref = toModuleReference(md, hashSupplier(i, names[i])); mods.add(mref); - map.put(mn, mref); + map.put(names[i], mref); // counters packageCount.add(md.packages().size()); @@ -147,16 +114,114 @@ class SystemModuleFinder implements ModuleFinder { initTime.addElapsedTimeFrom(t0); } - private static ModuleHashes.HashSupplier hashSupplier(String hash) { - if (hash == null) - return null; + /* + * Returns an array of ModuleDescriptor of the given module names. + * + * This obtains ModuleDescriptors from SystemModules class that is generated + * from the jlink system-modules plugin. ModuleDescriptors have already + * been validated at link time. + * + * If java.base is patched, or fastpath is disabled for troubleshooting + * purpose, it will fall back to find system modules via jrt file system. + */ + private static ModuleDescriptor[] descriptors(String[] names) { + // fastpath is enabled by default. + // It can be disabled for troubleshooting purpose. + boolean disabled = + System.getProperty("jdk.system.module.finder.disabledFastPath") != null; + + // fast loading of ModuleDescriptor of system modules + if (isFastPathSupported() && !disabled) + return SystemModules.modules(); + + // if fast loading of ModuleDescriptors is disabled + // fallback to read module-info.class + ModuleDescriptor[] descriptors = new ModuleDescriptor[names.length]; + for (int i = 0; i < names.length; i++) { + String mn = names[i]; + ImageLocation loc = imageReader.findLocation(mn, "module-info.class"); + descriptors[i] = ModuleDescriptor.read(imageReader.getResourceBuffer(loc)); + + // add the recorded hashes of tied modules + Hashes.add(descriptors[i]); + } + return descriptors; + } + + private static boolean isFastPathSupported() { + return SystemModules.MODULE_NAMES.length > 0; + } - return new ModuleHashes.HashSupplier() { + private static String[] moduleNames() { + if (isFastPathSupported()) + // module names recorded at link time + return SystemModules.MODULE_NAMES; + + // this happens when java.base is patched with java.base + // from an exploded image + return imageReader.getModuleNames(); + } + + private static ModuleReference toModuleReference(ModuleDescriptor md, + HashSupplier hash) + { + String mn = md.name(); + URI uri = URI.create("jrt:/" + mn); + + Supplier readerSupplier = new Supplier<>() { @Override - public String generate(String algorithm) { - return hash; + public ModuleReader get() { + return new ImageModuleReader(mn, uri); } }; + + ModuleReference mref = + new ModuleReference(md, uri, readerSupplier, hash); + + // may need a reference to a patched module if -Xpatch specified + mref = ModulePatcher.interposeIfNeeded(mref); + + return mref; + } + + private static HashSupplier hashSupplier(int index, String name) { + if (isFastPathSupported()) { + return new HashSupplier() { + @Override + public String generate(String algorithm) { + return SystemModules.MODULES_TO_HASH[index]; + } + }; + } else { + return Hashes.hashFor(name); + } + } + + /* + * This helper class is only used when SystemModules is patched. + * It will get the recorded hashes from module-info.class. + */ + private static class Hashes { + static Map hashes = new HashMap<>(); + + static void add(ModuleDescriptor descriptor) { + Optional ohashes = descriptor.hashes(); + if (ohashes.isPresent()) { + hashes.putAll(ohashes.get().hashes()); + } + } + + static HashSupplier hashFor(String name) { + if (!hashes.containsKey(name)) + return null; + + return new HashSupplier() { + @Override + public String generate(String algorithm) { + return hashes.get(name); + } + }; + } } SystemModuleFinder() { } diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java index 2c78ea9e5d5..a747ea8aa7b 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java +++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/ImageReader.java @@ -149,6 +149,17 @@ public final class ImageReader implements AutoCloseable { return reader.getEntryNames(); } + public String[] getModuleNames() { + Objects.requireNonNull(reader, "image file closed"); + int off = "/modules/".length(); + return reader.findNode("/modules") + .getChildren() + .stream() + .map(Node::getNameString) + .map(s -> s.substring(off, s.length())) + .toArray(String[]::new); + } + public long[] getAttributes(int offset) { Objects.requireNonNull(reader, "image file closed"); return reader.getAttributes(offset); diff --git a/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java b/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java index 43de2cda9f7..78619f09f4d 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java +++ b/jdk/src/java.base/share/classes/jdk/internal/module/SystemModules.java @@ -46,12 +46,12 @@ public final class SystemModules { * and read module-info.class from the run-time image instead of * the fastpath. */ - public static final String[] MODULE_NAMES = new String[1]; + public static final String[] MODULE_NAMES = new String[0]; /** * Hash of system modules. */ - public static String[] MODULES_TO_HASH = new String[1]; + public static String[] MODULES_TO_HASH = new String[0]; /** * Number of packages in the boot layer from the installed modules. @@ -67,7 +67,7 @@ public final class SystemModules { * When running an exploded image it returns an empty array. */ public static ModuleDescriptor[] modules() { - return new ModuleDescriptor[0]; + throw new InternalError("should not reach here"); } } diff --git a/jdk/test/tools/launcher/modules/patch/PatchTest.java b/jdk/test/tools/launcher/modules/patch/basic/PatchTest.java similarity index 100% rename from jdk/test/tools/launcher/modules/patch/PatchTest.java rename to jdk/test/tools/launcher/modules/patch/basic/PatchTest.java diff --git a/jdk/test/tools/launcher/modules/patch/src/test/jdk/test/Main.java b/jdk/test/tools/launcher/modules/patch/basic/src/test/jdk/test/Main.java similarity index 100% rename from jdk/test/tools/launcher/modules/patch/src/test/jdk/test/Main.java rename to jdk/test/tools/launcher/modules/patch/basic/src/test/jdk/test/Main.java diff --git a/jdk/test/tools/launcher/modules/patch/src/test/module-info.java b/jdk/test/tools/launcher/modules/patch/basic/src/test/module-info.java similarity index 100% rename from jdk/test/tools/launcher/modules/patch/src/test/module-info.java rename to jdk/test/tools/launcher/modules/patch/basic/src/test/module-info.java diff --git a/jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/Annotation.java b/jdk/test/tools/launcher/modules/patch/basic/src1/java.base/java/text/Annotation.java similarity index 100% rename from jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/Annotation.java rename to jdk/test/tools/launcher/modules/patch/basic/src1/java.base/java/text/Annotation.java diff --git a/jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/AnnotationBuddy.java b/jdk/test/tools/launcher/modules/patch/basic/src1/java.base/java/text/AnnotationBuddy.java similarity index 100% rename from jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/AnnotationBuddy.java rename to jdk/test/tools/launcher/modules/patch/basic/src1/java.base/java/text/AnnotationBuddy.java diff --git a/jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/Main.java b/jdk/test/tools/launcher/modules/patch/basic/src1/jdk.compiler/com/sun/tools/javac/Main.java similarity index 100% rename from jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/Main.java rename to jdk/test/tools/launcher/modules/patch/basic/src1/jdk.compiler/com/sun/tools/javac/Main.java diff --git a/jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java b/jdk/test/tools/launcher/modules/patch/basic/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java similarity index 100% rename from jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java rename to jdk/test/tools/launcher/modules/patch/basic/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java diff --git a/jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java b/jdk/test/tools/launcher/modules/patch/basic/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java similarity index 100% rename from jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java rename to jdk/test/tools/launcher/modules/patch/basic/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java diff --git a/jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java b/jdk/test/tools/launcher/modules/patch/basic/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java similarity index 100% rename from jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java rename to jdk/test/tools/launcher/modules/patch/basic/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java diff --git a/jdk/test/tools/launcher/modules/patch/src2/java.base/java/lang2/Object.java b/jdk/test/tools/launcher/modules/patch/basic/src2/java.base/java/lang2/Object.java similarity index 100% rename from jdk/test/tools/launcher/modules/patch/src2/java.base/java/lang2/Object.java rename to jdk/test/tools/launcher/modules/patch/basic/src2/java.base/java/lang2/Object.java diff --git a/jdk/test/tools/launcher/modules/patch/src2/jdk.compiler/com/sun/tools/javac2/Main.java b/jdk/test/tools/launcher/modules/patch/basic/src2/jdk.compiler/com/sun/tools/javac2/Main.java similarity index 100% rename from jdk/test/tools/launcher/modules/patch/src2/jdk.compiler/com/sun/tools/javac2/Main.java rename to jdk/test/tools/launcher/modules/patch/basic/src2/jdk.compiler/com/sun/tools/javac2/Main.java diff --git a/jdk/test/tools/launcher/modules/patch/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java b/jdk/test/tools/launcher/modules/patch/basic/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java similarity index 100% rename from jdk/test/tools/launcher/modules/patch/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java rename to jdk/test/tools/launcher/modules/patch/basic/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java diff --git a/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java b/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java new file mode 100644 index 00000000000..0e5345aefb3 --- /dev/null +++ b/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java @@ -0,0 +1,225 @@ +/** + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8157068 + * @summary Patch java.base and user module with Hashes attribute tied with + * other module. + * @library /lib/testlibrary + * @modules jdk.compiler + * @build CompilerUtils + * @run testng PatchSystemModules + */ + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Stream; + +import jdk.testlibrary.FileUtils; +import jdk.testlibrary.JDKToolFinder; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import static jdk.testlibrary.ProcessTools.executeCommand; +import static org.testng.Assert.*; + +public class PatchSystemModules { + private static final String JAVA_HOME = System.getProperty("java.home"); + + private static final Path TEST_SRC = Paths.get(System.getProperty("test.src")); + private static final Path PATCH_SRC_DIR = TEST_SRC.resolve("src1"); + + private static final Path JMODS = Paths.get(JAVA_HOME, "jmods"); + private static final Path MODS_DIR = Paths.get("mods"); + private static final Path JARS_DIR = Paths.get("jars"); + private static final Path PATCH_DIR = Paths.get("patches"); + private static final Path IMAGE = Paths.get("image"); + + private static final String JAVA_BASE = "java.base"; + private final String[] modules = new String[] { "m1", "m2" }; + + @BeforeTest + private void setup() throws Throwable { + Path src = TEST_SRC.resolve("src"); + for (String name : modules) { + assertTrue(CompilerUtils.compile(src.resolve(name), + MODS_DIR, + "-modulesourcepath", src.toString())); + } + + // compile patched source + assertTrue(CompilerUtils.compile(PATCH_SRC_DIR.resolve(JAVA_BASE), + PATCH_DIR.resolve(JAVA_BASE), + "-Xmodule:java.base")); + assertTrue(CompilerUtils.compile(PATCH_SRC_DIR.resolve("m2"), + PATCH_DIR.resolve("m2"))); + + // create an image with only m1 and m2 + if (Files.exists(JMODS)) { + // create an image with m1,m2 + createImage(); + } + } + + @Test + public void test() throws Throwable { + Path patchedJavaBase = PATCH_DIR.resolve(JAVA_BASE); + Path patchedM2 = PATCH_DIR.resolve("m2"); + + Path home = Paths.get(JAVA_HOME); + runTest(home, + "-mp", MODS_DIR.toString(), + "-m", "m1/p1.Main", "1"); + runTest(home, + "-Xpatch:java.base=" + patchedJavaBase.toString(), + "-mp", MODS_DIR.toString(), + "-m", "m1/p1.Main", "1"); + + runTest(home, + "-Xpatch:m2=" + patchedM2.toString(), + "-mp", MODS_DIR.toString(), + "-m", "m1/p1.Main", "2"); + } + + @Test + public void testImage() throws Throwable { + if (Files.notExists(JMODS)) + return; + + Path patchedJavaBase = PATCH_DIR.resolve(JAVA_BASE); + Path patchedM2 = PATCH_DIR.resolve("m2"); + + runTest(IMAGE, + "-m", "m1/p1.Main", "1"); + runTest(IMAGE, + "-Xpatch:java.base=" + patchedJavaBase.toString(), + "-m", "m1/p1.Main", "1"); + runTest(IMAGE, + "-Xpatch:m2=" + patchedM2.toString(), + "-m", "m1/p1.Main", "2"); + } + + @Test + public void upgradeTiedModule() throws Throwable { + if (Files.notExists(JMODS)) + return; + + Path m1 = MODS_DIR.resolve("m1.jar"); + + // create another m1.jar + jar("--create", + "--file=" + m1.toString(), + "-C", MODS_DIR.resolve("m1").toString(), "."); + + // Fail to upgrade m1.jar with mismatched hash + runTestWithExitCode(getJava(IMAGE), + "-upgrademodulepath", m1.toString(), + "-m", "m1/p1.Main"); + + runTestWithExitCode(getJava(IMAGE), + "-Xpatch:java.base=" + PATCH_DIR.resolve(JAVA_BASE).toString(), + "-upgrademodulepath", m1.toString(), + "-m", "m1/p1.Main", "1"); + } + + private void runTestWithExitCode(String... options) throws Throwable { + assertTrue(executeCommand(options) + .outputTo(System.out) + .errorTo(System.out) + .shouldContain("differs to expected hash") + .getExitValue() != 0); + } + + private void runTest(Path image, String... opts) throws Throwable { + String[] options = + Stream.concat(Stream.of(getJava(image)), + Stream.of(opts)) + .toArray(String[]::new); + + ProcessBuilder pb = new ProcessBuilder(options); + int exitValue = executeCommand(pb) + .outputTo(System.out) + .errorTo(System.out) + .getExitValue(); + + assertTrue(exitValue == 0); + } + + static void createImage() throws Throwable { + FileUtils.deleteFileTreeUnchecked(JARS_DIR); + FileUtils.deleteFileTreeUnchecked(IMAGE); + + Files.createDirectories(JARS_DIR); + Path m1 = JARS_DIR.resolve("m1.jar"); + Path m2 = JARS_DIR.resolve("m2.jar"); + + // hash m1 in m2's Hashes attribute + jar("--create", + "--file=" + m1.toString(), + "-C", MODS_DIR.resolve("m1").toString(), "."); + + jar("--create", + "--file=" + m2.toString(), + "--modulepath", JARS_DIR.toString(), + "--hash-modules", "m1", + "-C", MODS_DIR.resolve("m2").toString(), "."); + + + String mpath = JARS_DIR.toString() + File.pathSeparator + JMODS.toString(); + execTool("jlink", "--modulepath", mpath, + "--addmods", "m1", + "--output", IMAGE.toString()); + } + + static void jar(String... args) throws Throwable { + execTool("jar", args); + } + + static void execTool(String tool, String... args) throws Throwable { + String path = JDKToolFinder.getJDKTool(tool); + List commands = new ArrayList<>(); + commands.add(path); + Stream.of(args).forEach(commands::add); + ProcessBuilder pb = new ProcessBuilder(commands); + int exitValue = executeCommand(pb) + .outputTo(System.out) + .errorTo(System.out) + .shouldNotContain("no module is recorded in hash") + .getExitValue(); + + assertTrue(exitValue == 0); + } + + static String getJava(Path image) { + boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("win"); + Path java = image.resolve("bin").resolve(isWindows ? "java.exe" : "java"); + if (Files.notExists(java)) + throw new RuntimeException(java + " not found"); + return java.toAbsolutePath().toString(); + } +} diff --git a/jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/module-info.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/module-info.java new file mode 100644 index 00000000000..d23aeb1669b --- /dev/null +++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/module-info.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +module m1 { + requires m2; +} diff --git a/jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/p1/Main.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/p1/Main.java new file mode 100644 index 00000000000..2329905a0f0 --- /dev/null +++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m1/p1/Main.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p1; + +public class Main { + public static void main(String[] args) throws Exception { + int version = p2.Lib.version(); + int expected = args.length == 0 ? 1 : Integer.parseInt(args[0]); + + if (version != expected) + throw new RuntimeException(version + " != " + expected + " (expected)"); + } +} diff --git a/jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/module-info.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/module-info.java new file mode 100644 index 00000000000..bc0f12b2204 --- /dev/null +++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/module-info.java @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +module m2 { + exports p2; +} diff --git a/jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/p2/Lib.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/p2/Lib.java new file mode 100644 index 00000000000..1d43aedc718 --- /dev/null +++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src/m2/p2/Lib.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p2; + +public class Lib { + public static int version() { + return 1; + } +} diff --git a/jdk/test/tools/launcher/modules/patch/systemmodules/src1/java.base/jdk/internal/modules/SystemModules.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src1/java.base/jdk/internal/modules/SystemModules.java new file mode 100644 index 00000000000..e30761204e1 --- /dev/null +++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src1/java.base/jdk/internal/modules/SystemModules.java @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.internal.module; + +/* + * Test -Xpatch:java.base=jdk/modules/java.base to override + * java.base with an exploded image + */ +public final class SystemModules { + public static final String[] MODULE_NAMES = new String[0]; +} diff --git a/jdk/test/tools/launcher/modules/patch/systemmodules/src1/m2/p2/Lib.java b/jdk/test/tools/launcher/modules/patch/systemmodules/src1/m2/p2/Lib.java new file mode 100644 index 00000000000..5313c7e7aed --- /dev/null +++ b/jdk/test/tools/launcher/modules/patch/systemmodules/src1/m2/p2/Lib.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package p2; + +public class Lib { + public static int version() { + return 2; + } +} -- GitLab From a950576f78001fa51a5d499613549177133dfe1b Mon Sep 17 00:00:00 2001 From: Iris Clark Date: Thu, 19 May 2016 12:04:54 -0700 Subject: [PATCH 094/400] 8144062: Move jdk.Version to java.lang.Runtime.Version Reviewed-by: abuckley, alanb, forax, jjg, mchung, psandoz --- .../share/classes/java/lang/Runtime.java | 603 +++++++++++++++++- .../share/classes/java/lang/System.java | 12 +- .../share/classes/java/util/jar/JarFile.java | 6 +- .../java.base/share/classes/jdk/Version.java | 603 ------------------ .../java.base/share/classes/module-info.java | 3 - .../sun/tools/jconsole/AboutDialog.java | 4 +- .../classes/jdk/nio/zipfs/JarFileSystem.java | 6 +- .../lang/Runtime}/Version/Basic.java | 23 +- .../jar/JarFile/mrjar/MultiReleaseJarAPI.java | 7 +- .../mrjar/MultiReleaseJarIterators.java | 7 +- .../mrjar/MultiReleaseJarProperties.java | 7 +- .../mrjar/MultiReleaseJarSecurity.java | 7 +- .../jdk/nio/zipfs/MultiReleaseJarTest.java | 8 +- .../jar/MultiReleaseJarURLConnection.java | 14 +- 14 files changed, 652 insertions(+), 658 deletions(-) delete mode 100644 jdk/src/java.base/share/classes/jdk/Version.java rename jdk/test/{jdk => java/lang/Runtime}/Version/Basic.java (96%) diff --git a/jdk/src/java.base/share/classes/java/lang/Runtime.java b/jdk/src/java.base/share/classes/java/lang/Runtime.java index 3c73d5b61a3..1533130017b 100644 --- a/jdk/src/java.base/share/classes/java/lang/Runtime.java +++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,9 +26,21 @@ package java.lang; import java.io.*; +import java.math.BigInteger; +import java.util.AbstractList; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.Collections; +import java.util.List; +import java.util.Optional; +import java.util.RandomAccess; import java.util.StringTokenizer; import jdk.internal.reflect.CallerSensitive; import jdk.internal.reflect.Reflection; +import sun.security.action.GetPropertyAction; /** * Every Java application has a single instance of class @@ -46,6 +58,8 @@ import jdk.internal.reflect.Reflection; public class Runtime { private static final Runtime currentRuntime = new Runtime(); + private static Version version; + /** * Returns the runtime object associated with the current Java application. * Most of the methods of class {@code Runtime} are instance @@ -917,4 +931,591 @@ public class Runtime { return out; } + /** + * Returns the version of the Java Runtime Environment as a {@link + * Runtime.Version}. + * + * @return the {@link Runtime.Version} of the Java Runtime Environment + * + * @since 9 + */ + public static Version version() { + if (version == null) { + version = Version.parse( + GetPropertyAction.privilegedGetProperty("java.runtime.version")); + } + return version; + } + + /** + * A representation of a version string for an implemenation of the + * Java SE Platform. A version string contains a version number + * optionally followed by pre-release and build information. + * + *

      Version numbers

      + * + *

      A version number, {@code $VNUM}, is a non-empty sequence + * of elements separated by period characters (U+002E). An element is + * either zero, or a unsigned integer numeral without leading zeros. The + * final element in a version number must not be zero. The format is: + *

      + * + *
      +     *     ^[1-9][0-9]*(((\.0)*\.[1-9][0-9]*)*)*$
      +     * 
      + * + *

      The sequence may be of arbitrary length but the first three + * elements are assigned specific meanings, as follows:

      + * + *
      +     *     $MAJOR.$MINOR.$SECURITY
      +     * 
      + * + *
        + * + *
      • {@code $MAJOR} --- The major version + * number, incremented for a major release that contains significant new + * features as specified in a new edition of the Java SE Platform + * Specification, e.g., JSR 337 for + * Java SE 8. Features may be removed in a major release, given + * advance notice at least one major release ahead of time, and + * incompatible changes may be made when justified. The {@code $MAJOR} + * version number of JDK 8 is {@code 8}; the {@code $MAJOR} version + * number of JDK 9 is {@code 9}. When {@code $MAJOR} is incremented, + * all subsequent elements are removed.

      • + * + *
      • {@code $MINOR} --- The minor version + * number, incremented for a minor update release that may contain + * compatible bug fixes, revisions to standard APIs mandated by a + * Maintenance Release + * of the relevant Platform Specification, and implementation features + * outside the scope of that Specification such as new JDK-specific APIs, + * additional service providers, new garbage collectors, and ports to new + * hardware architectures.

      • + * + *
      • {@code $SECURITY} --- The security + * level, incremented for a security update release that contains critical + * fixes including those necessary to improve security. {@code $SECURITY} + * is not reset when {@code $MINOR} is incremented. A + * higher value of {@code $SECURITY} for a given {@code $MAJOR} value, + * therefore, always indicates a more secure release, regardless of the + * value of {@code $MINOR}.

      • + * + *
      + * + *

      The fourth and later elements of a version number are free for use + * by downstream consumers of this code base. Such a consumer may, + * e.g., use the fourth element to identify patch releases which + * contain a small number of critical non-security fixes in addition to + * the security fixes in the corresponding security release.

      + * + *

      The version number does not include trailing zero elements; + * i.e., {@code $SECURITY} is omitted if it has the value zero, + * and {@code $MINOR} is omitted if both {@code $MINOR} and {@code + * $SECURITY} have the value zero.

      + * + *

      The sequence of numerals in a version number is compared to another + * such sequence in numerical, pointwise fashion; e.g., {@code + * 9.9.1} is less than {@code 9.10.3}. If one sequence is shorter than + * another then the missing elements of the shorter sequence are + * considered to be less than the corresponding elements of the longer + * sequence; e.g., {@code 9.1.2} is less than {@code 9.1.2.1}. + *

      + * + *

      Version strings

      + * + *

      A version string, {@code $VSTR}, consists of a version + * number {@code $VNUM}, as described above, optionally followed by + * pre-release and build information, in the format

      + * + *
      +     *     $VNUM(-$PRE)?(\+($BUILD)?(-$OPT)?)?
      +     * 
      + * + *

      where:

      + * + *
        + * + *
      • {@code $PRE}, matching {@code ([a-zA-Z0-9]+)} + * --- A pre-release identifier. Typically {@code ea}, for a + * potentially unstable early-access release under active development, + * or {@code internal}, for an internal developer build. + * + *

      • {@code $BUILD}, matching {@code + * (0|[1-9][0-9]*)} --- The build number, incremented for each promoted + * build. {@code $BUILD} is reset to {@code 1} when any portion of {@code + * $VNUM} is incremented.

        + * + *
      • {@code $OPT}, matching {@code + * ([-a-zA-Z0-9\.]+)} --- Additional build information, if desired. In + * the case of an {@code internal} build this will often contain the date + * and time of the build.

        + * + *
      + * + *

      A version number {@code 10-ea} matches {@code $VNUM = "10"} and + * {@code $PRE = "ea"}. The version number {@code 10+-ea} matches + * {@code $VNUM = "10"} and {@code $OPT = "ea"}.

      + * + *

      When comparing two version strings, the value of {@code $OPT}, if + * present, may or may not be significant depending on the chosen + * comparison method. The comparison methods {@link #compareTo(Version) + * compareTo()} and {@link #compareToIgnoreOpt(Version) + * compareToIgnoreOpt()} should be used consistently with the + * corresponding methods {@link #equals(Object) equals()} and {@link + * #equalsIgnoreOpt(Object) equalsIgnoreOpt()}.

      + * + *

      A short version string, {@code $SVSTR}, often useful in + * less formal contexts, is a version number optionally followed by a + * pre-release identifier: + * + *

      +     *     $VNUM(-$PRE)?
      +     * 
      + * + * @since 9 + */ + public static class Version + implements Comparable + { + private final List version; + private final Optional pre; + private final Optional build; + private final Optional optional; + + + // $VNUM(-$PRE)?(\+($BUILD)?(\-$OPT)?)? + // RE limits the format of version strings + // ([1-9][0-9]*(?:(?:\.0)*\.[1-9][0-9]*)*)(?:-([a-zA-Z0-9]+))?(?:(\+)(0|[1-9][0-9]*)?)?(?:-([-a-zA-Z0-9.]+))? + + private static final String VNUM + = "(?[1-9][0-9]*(?:(?:\\.0)*\\.[1-9][0-9]*)*)"; + private static final String VNUM_GROUP = "VNUM"; + + private static final String PRE = "(?:-(?
      [a-zA-Z0-9]+))?";
      +        private static final String PRE_GROUP   = "PRE";
      +
      +        private static final String BUILD
      +            = "(?:(?\\+)(?0|[1-9][0-9]*)?)?";
      +        private static final String PLUS_GROUP  = "PLUS";
      +        private static final String BUILD_GROUP = "BUILD";
      +
      +        private static final String OPT      = "(?:-(?[-a-zA-Z0-9.]+))?";
      +        private static final String OPT_GROUP   = "OPT";
      +
      +        private static final String VSTR_FORMAT
      +            = "^" + VNUM + PRE + BUILD + OPT + "$";
      +        private static final Pattern VSTR_PATTERN = Pattern.compile(VSTR_FORMAT);
      +
      +        /**
      +         * Constructs a valid version string containing
      +         * a version number followed by pre-release and
      +         * build information.
      +         *
      +         * @param  s
      +         *         A string to be interpreted as a version
      +         *
      +         * @throws  IllegalArgumentException
      +         *          If the given string cannot be interpreted as a valid
      +         *          version
      +         *
      +         * @throws  NullPointerException
      +         *          If {@code s} is {@code null}
      +         *
      +         * @throws  NumberFormatException
      +         *          If an element of the version number or the build number
      +         *          cannot be represented as an {@link Integer}
      +         */
      +        private Version(String s) {
      +            if (s == null)
      +                throw new NullPointerException();
      +
      +            Matcher m = VSTR_PATTERN.matcher(s);
      +            if (!m.matches())
      +                throw new IllegalArgumentException("Invalid version string: '"
      +                                                   + s + "'");
      +
      +            // $VNUM is a dot-separated list of integers of arbitrary length
      +            List list = new ArrayList<>();
      +            for (String i : m.group(VNUM_GROUP).split("\\."))
      +                list.add(Integer.parseInt(i));
      +            version = Collections.unmodifiableList(list);
      +
      +            pre = Optional.ofNullable(m.group(PRE_GROUP));
      +
      +            String b = m.group(BUILD_GROUP);
      +            // $BUILD is an integer
      +            build = (b == null)
      +                ? Optional.empty()
      +                : Optional.ofNullable(Integer.parseInt(b));
      +
      +            optional = Optional.ofNullable(m.group(OPT_GROUP));
      +
      +            // empty '+'
      +            if ((m.group(PLUS_GROUP) != null) && !build.isPresent()) {
      +                if (optional.isPresent()) {
      +                    if (pre.isPresent())
      +                        throw new IllegalArgumentException("'+' found with"
      +                            + " pre-release and optional components:'" + s
      +                            + "'");
      +                } else {
      +                    throw new IllegalArgumentException("'+' found with neither"
      +                        + " build or optional components: '" + s + "'");
      +                }
      +            }
      +        }
      +
      +        /**
      +         * Parses the given string as a valid
      +         * version string containing a
      +         * version number followed by pre-release and
      +         * build information.
      +         *
      +         * @param  s
      +         *         A string to interpret as a version
      +         *
      +         * @throws  IllegalArgumentException
      +         *          If the given string cannot be interpreted as a valid
      +         *          version
      +         *
      +         * @throws  NullPointerException
      +         *          If the given string is {@code null}
      +         *
      +         * @throws  NumberFormatException
      +         *          If an element of the version number or the build number
      +         *          cannot be represented as an {@link Integer}
      +         *
      +         * @return  The Version of the given string
      +         */
      +        public static Version parse(String s) {
      +            return new Version(s);
      +        }
      +
      +        /**
      +         * Returns the major version number.
      +         *
      +         * @return  The major version number
      +         */
      +        public int major() {
      +            return version.get(0);
      +        }
      +
      +        /**
      +         * Returns the minor version number or zero if it
      +         * was not set.
      +         *
      +         * @return  The minor version number or zero if it was not set
      +         */
      +        public int minor() {
      +            return (version.size() > 1 ? version.get(1) : 0);
      +        }
      +
      +        /**
      +         * Returns the security version number or zero
      +         * if it was not set.
      +         *
      +         * @return  The security version number or zero if it was not set
      +         */
      +        public int security() {
      +            return (version.size() > 2 ? version.get(2) : 0);
      +        }
      +
      +        /**
      +         * Returns an unmodifiable {@link java.util.List List} of the
      +         * integer numerals contained in the version
      +         * number.  The {@code List} always contains at least one
      +         * element corresponding to the major version
      +         * number.
      +         *
      +         * @return  An unmodifiable list of the integer numerals
      +         *          contained in the version number
      +         */
      +        public List version() {
      +            return version;
      +        }
      +
      +        /**
      +         * Returns the optional pre-release information.
      +         *
      +         * @return  The optional pre-release information as a String
      +         */
      +        public Optional pre() {
      +            return pre;
      +        }
      +
      +        /**
      +         * Returns the build number.
      +         *
      +         * @return  The optional build number.
      +         */
      +        public Optional build() {
      +            return build;
      +        }
      +
      +        /**
      +         * Returns optional additional identifying build
      +         * information.
      +         *
      +         * @return  Additional build information as a String
      +         */
      +        public Optional optional() {
      +            return optional;
      +        }
      +
      +        /**
      +         * Compares this version to another.
      +         *
      +         * 

      Each of the components in the version is + * compared in the follow order of precedence: version numbers, + * pre-release identifiers, build numbers, optional build information. + *

      + * + *

      Comparison begins by examining the sequence of version numbers. + * If one sequence is shorter than another, then the missing elements + * of the shorter sequence are considered to be less than the + * corresponding elements of the longer sequence.

      + * + *

      A version with a pre-release identifier is always considered to + * be less than a version without one. Pre-release identifiers are + * compared numerically when they consist only of digits, and + * lexicographically otherwise. Numeric identifiers are considered to + * be less than non-numeric identifiers.

      + * + *

      A version without a build number is always less than one with a + * build number; otherwise build numbers are compared numerically.

      + * + *

      The optional build information is compared lexicographically. + * During this comparison, a version with optional build information is + * considered to be greater than a version without one.

      + * + *

      A version is not comparable to any other type of object. + * + * @param ob + * The object to be compared + * + * @return A negative integer, zero, or a positive integer if this + * {@code Version} is less than, equal to, or greater than the + * given {@code Version} + * + * @throws NullPointerException + * If the given object is {@code null} + */ + @Override + public int compareTo(Version ob) { + return compare(ob, false); + } + + /** + * Compares this version to another disregarding optional build + * information. + * + *

      Two versions are compared by examining the version string as + * described in {@link #compareTo(Version)} with the exception that the + * optional build information is always ignored.

      + * + *

      A version is not comparable to any other type of object. + * + * @param ob + * The object to be compared + * + * @return A negative integer, zero, or a positive integer if this + * {@code Version} is less than, equal to, or greater than the + * given {@code Version} + * + * @throws NullPointerException + * If the given object is {@code null} + */ + public int compareToIgnoreOpt(Version ob) { + return compare(ob, true); + } + + private int compare(Version ob, boolean ignoreOpt) { + if (ob == null) + throw new NullPointerException("Invalid argument"); + + int ret = compareVersion(ob); + if (ret != 0) + return ret; + + ret = comparePre(ob); + if (ret != 0) + return ret; + + ret = compareBuild(ob); + if (ret != 0) + return ret; + + if (!ignoreOpt) + return compareOpt(ob); + + return 0; + } + + private int compareVersion(Version ob) { + int size = version.size(); + int oSize = ob.version().size(); + int min = Math.min(size, oSize); + for (int i = 0; i < min; i++) { + Integer val = version.get(i); + Integer oVal = ob.version().get(i); + if (val != oVal) + return val - oVal; + } + if (size != oSize) + return size - oSize; + return 0; + } + + private int comparePre(Version ob) { + Optional oPre = ob.pre(); + if (!pre.isPresent()) { + if (oPre.isPresent()) + return 1; + } else { + if (!oPre.isPresent()) + return -1; + String val = pre.get(); + String oVal = oPre.get(); + if (val.matches("\\d+")) { + return (oVal.matches("\\d+") + ? (new BigInteger(val)).compareTo(new BigInteger(oVal)) + : -1); + } else { + return (oVal.matches("\\d+") + ? 1 + : val.compareTo(oVal)); + } + } + return 0; + } + + private int compareBuild(Version ob) { + Optional oBuild = ob.build(); + if (oBuild.isPresent()) { + return (build.isPresent() + ? build.get().compareTo(oBuild.get()) + : 1); + } else if (build.isPresent()) { + return -1; + } + return 0; + } + + private int compareOpt(Version ob) { + Optional oOpt = ob.optional(); + if (!optional.isPresent()) { + if (oOpt.isPresent()) + return -1; + } else { + if (!oOpt.isPresent()) + return 1; + return optional.get().compareTo(oOpt.get()); + } + return 0; + } + + /** + * Returns a string representation of this version. + * + * @return The version string + */ + @Override + public String toString() { + StringBuilder sb + = new StringBuilder(version.stream() + .map(Object::toString) + .collect(Collectors.joining("."))); + + pre.ifPresent(v -> sb.append("-").append(v)); + + if (build.isPresent()) { + sb.append("+").append(build.get()); + if (optional.isPresent()) + sb.append("-").append(optional.get()); + } else { + if (optional.isPresent()) { + sb.append(pre.isPresent() ? "-" : "+-"); + sb.append(optional.get()); + } + } + + return sb.toString(); + } + + /** + * Determines whether this {@code Version} is equal to another object. + * + *

      Two {@code Version}s are equal if and only if they represent the + * same version string. + * + *

      This method satisfies the general contract of the {@link + * Object#equals(Object) Object.equals} method.

      + * + * @param ob + * The object to which this {@code Version} is to be compared + * + * @return {@code true} if, and only if, the given object is a {@code + * Version} that is identical to this {@code Version} + * + */ + @Override + public boolean equals(Object ob) { + boolean ret = equalsIgnoreOpt(ob); + if (!ret) + return false; + + Version that = (Version)ob; + return (this.optional().equals(that.optional())); + } + + /** + * Determines whether this {@code Version} is equal to another + * disregarding optional build information. + * + *

      Two {@code Version}s are equal if and only if they represent the + * same version string disregarding the optional build information. + * + * @param ob + * The object to which this {@code Version} is to be compared + * + * @return {@code true} if, and only if, the given object is a {@code + * Version} that is identical to this {@code Version} + * ignoring the optinal build information + * + */ + public boolean equalsIgnoreOpt(Object ob) { + if (this == ob) + return true; + if (!(ob instanceof Version)) + return false; + + Version that = (Version)ob; + return (this.version().equals(that.version()) + && this.pre().equals(that.pre()) + && this.build().equals(that.build())); + } + + /** + * Returns the hash code of this version. + * + *

      This method satisfies the general contract of the {@link + * Object#hashCode Object.hashCode} method. + * + * @return The hashcode of this version + */ + @Override + public int hashCode() { + int h = 1; + int p = 17; + + h = p * h + version.hashCode(); + h = p * h + pre.hashCode(); + h = p * h + build.hashCode(); + h = p * h + optional.hashCode(); + + return h; + } + } + } diff --git a/jdk/src/java.base/share/classes/java/lang/System.java b/jdk/src/java.base/share/classes/java/lang/System.java index ab7bb02c1f7..7ac564d959a 100644 --- a/jdk/src/java.base/share/classes/java/lang/System.java +++ b/jdk/src/java.base/share/classes/java/lang/System.java @@ -576,7 +576,8 @@ public final class System { * Key * Description of Associated Value * java.version - * Java Runtime Environment version + * Java Runtime Environment version which may be interpreted + * as a {@link Runtime.Version} * java.vendor * Java Runtime Environment vendor * java.vendor.url @@ -584,19 +585,22 @@ public final class System { * java.home * Java installation directory * java.vm.specification.version - * Java Virtual Machine specification version + * Java Virtual Machine specification version which may be + * interpreted as a {@link Runtime.Version} * java.vm.specification.vendor * Java Virtual Machine specification vendor * java.vm.specification.name * Java Virtual Machine specification name * java.vm.version - * Java Virtual Machine implementation version + * Java Virtual Machine implementation version which may be + * interpreted as a {@link Runtime.Version} * java.vm.vendor * Java Virtual Machine implementation vendor * java.vm.name * Java Virtual Machine implementation name * java.specification.version - * Java Runtime Environment specification version + * Java Runtime Environment specification version which may be + * interpreted as a {@link Runtime.Version} * java.specification.vendor * Java Runtime Environment specification vendor * java.specification.name diff --git a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java index 5f08db7b1c4..aab2474fd66 100644 --- a/jdk/src/java.base/share/classes/java/util/jar/JarFile.java +++ b/jdk/src/java.base/share/classes/java/util/jar/JarFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -153,7 +153,7 @@ class JarFile extends ZipFile { SharedSecrets.setJavaUtilJarAccess(new JavaUtilJarAccessImpl()); BASE_VERSION = 8; // one less than lowest version for versioned entries - int runtimeVersion = jdk.Version.current().major(); + int runtimeVersion = Runtime.version().major(); String jarVersion = GetPropertyAction.privilegedGetProperty("jdk.util.jar.version"); if (jarVersion != null) { @@ -357,7 +357,7 @@ class JarFile extends ZipFile { } private boolean runtimeVersionExists() { - int version = jdk.Version.current().major(); + int version = Runtime.version().major(); try { Release.valueOf(version); return true; diff --git a/jdk/src/java.base/share/classes/jdk/Version.java b/jdk/src/java.base/share/classes/jdk/Version.java deleted file mode 100644 index 8afccfba6a8..00000000000 --- a/jdk/src/java.base/share/classes/jdk/Version.java +++ /dev/null @@ -1,603 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk; - -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Collectors; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import sun.security.action.GetPropertyAction; - -/** - * A representation of the JDK version-string which contains a version - * number optionally followed by pre-release and build information. - * - *

      Version numbers

      - * - * A version number, {@code $VNUM}, is a non-empty sequence of - * non-negative integer numerals, without leading or trailing zeroes, - * separated by period characters (U+002E); i.e., it matches the regular - * expression {@code ^[1-9][0-9]*(((\.0)*\.[1-9][0-9]*)*)*$}. The sequence may - * be of arbitrary length but the first three elements are assigned specific - * meanings, as follows: - * - *
      - *     $MAJOR.$MINOR.$SECURITY
      - * 
      - * - *
        - * - *
      • {@code $MAJOR} --- The major version number, - * incremented for a major release that contains significant new features as - * specified in a new edition of the Java SE Platform Specification, - * e.g., JSR 337 - * for Java SE 8. Features may be removed in a major release, given - * advance notice at least one major release ahead of time, and incompatible - * changes may be made when justified. The {@code $MAJOR} version number of - * JDK 8 was {@code 8}; the {@code $MAJOR} version number of JDK 9 - * is {@code 9}.

      • - * - *
      • {@code $MINOR} --- The minor version number, - * incremented for a minor update release that may contain compatible bug - * fixes, revisions to standard APIs mandated by a Maintenance Release of - * the relevant Platform Specification, and implementation features outside - * the scope of that Specification such as new JDK-specific APIs, additional - * service providers, new garbage collectors, and ports to new hardware - * architectures. {@code $MINOR} is reset to zero when {@code $MAJOR} is - * incremented.

      • - * - *
      • {@code $SECURITY} --- The security level, - * incremented for a security-update release that contains critical fixes - * including those necessary to improve security. {@code $SECURITY} is reset - * to zero only when {@code $MAJOR} is incremented. A higher - * value of {@code $SECURITY} for a given {@code $MAJOR} value, therefore, - * always indicates a more secure release, regardless of the value of {@code - * $MINOR}.

      • - * - *
      - * - *

      The fourth and later elements of a version number are free for use by - * downstream consumers of the JDK code base. Such a consumer may, - * e.g., use the fourth element to identify patch releases which - * contain a small number of critical non-security fixes in addition to the - * security fixes in the corresponding security release.

      - * - *

      The version number does not include trailing zero elements; - * i.e., {@code $SECURITY} is omitted if it has the value zero, and - * {@code $MINOR} is omitted if both {@code $MINOR} and {@code $SECURITY} have - * the value zero.

      - * - *

      The sequence of numerals in a version number is compared to another - * such sequence in numerical, pointwise fashion; e.g., {@code 9.9.1} - * is less than {@code 9.10.0}. If one sequence is shorter than another then - * the missing elements of the shorter sequence are considered to be zero; - * e.g., {@code 9.1.2} is equal to {@code 9.1.2.0} but less than - * {@code 9.1.2.1}.

      - * - *

      Version strings

      - * - *

      A version string {@code $VSTR} consists of a version number - * {@code $VNUM}, as described above, optionally followed by pre-release and - * build information, in the format

      - * - *
      - *     $VNUM(-$PRE)?(\+($BUILD)?(-$OPT)?)?
      - * 
      - * - *

      where:

      - * - *
        - * - *
      • {@code $PRE}, matching {@code ([a-zA-Z0-9]+)} --- - * A pre-release identifier. Typically {@code ea}, for an early-access - * release that's under active development and potentially unstable, or {@code - * internal}, for an internal developer build. - * - *

      • {@code $BUILD}, matching {@code - * (0|[1-9][0-9]*)} --- The build number, incremented for each promoted build. - * {@code $BUILD} is reset to {@code 1} when any portion of {@code $VNUM} is - * incremented.

        - * - *
      • {@code $OPT}, matching {@code ([-a-zA-Z0-9\.]+)} - * --- Additional build information, if desired. In the case of an {@code - * internal} build this will often contain the date and time of the - * build.

        - * - *
      - * - *

      When comparing two version strings the value of {@code $OPT}, if - * present, may or may not be significant depending on the chosen comparison - * method. The comparison methods {@link #compareTo(Version) compareTo()} and - * {@link #compareToIgnoreOpt(Version) compareToIgnoreOpt{}} should be used - * consistently with the corresponding methods {@link #equals(Object) equals()} - * and {@link #equalsIgnoreOpt(Object) equalsIgnoreOpt()}.

      - * - *

      A short version string ({@code $SVSTR}), often useful in less - * formal contexts, is simply {@code $VNUM} optionally ended with {@code - * -$PRE}.

      - * - * @since 9 - */ -public final class Version - implements Comparable -{ - private final List version; - private final Optional pre; - private final Optional build; - private final Optional optional; - - private static Version current; - - // $VNUM(-$PRE)?(\+($BUILD)?(\-$OPT)?)? - // RE limits the format of version strings - // ([1-9][0-9]*(?:(?:\.0)*\.[1-9][0-9]*)*)(?:-([a-zA-Z0-9]+))?(?:(\+)(0|[1-9][0-9]*)?)?(?:-([-a-zA-Z0-9.]+))? - - private static final String VNUM - = "(?[1-9][0-9]*(?:(?:\\.0)*\\.[1-9][0-9]*)*)"; - private static final String VNUM_GROUP = "VNUM"; - - private static final String PRE = "(?:-(?
      [a-zA-Z0-9]+))?";
      -    private static final String PRE_GROUP   = "PRE";
      -
      -    private static final String BUILD
      -        = "(?:(?\\+)(?0|[1-9][0-9]*)?)?";
      -    private static final String PLUS_GROUP  = "PLUS";
      -    private static final String BUILD_GROUP = "BUILD";
      -
      -    private static final String OPT      = "(?:-(?[-a-zA-Z0-9.]+))?";
      -    private static final String OPT_GROUP   = "OPT";
      -
      -    private static final String VSTR_FORMAT
      -        = "^" + VNUM + PRE + BUILD + OPT + "$";
      -    private static final Pattern VSTR_PATTERN = Pattern.compile(VSTR_FORMAT);
      -
      -    /**
      -     * Constructs a valid JDK version string containing a
      -     * version number followed by pre-release and build
      -     * information.
      -     *
      -     * @param  s
      -     *         A string to be interpreted as a version
      -     *
      -     * @throws  IllegalArgumentException
      -     *          If the given string cannot be interpreted a valid version
      -     *
      -     * @throws  NullPointerException
      -     *          If {@code s} is {@code null}
      -     *
      -     * @throws  NumberFormatException
      -     *          If an element of the version number or the build number cannot
      -     *          be represented as an {@link Integer}
      -     */
      -    private Version(String s) {
      -        if (s == null)
      -            throw new NullPointerException();
      -
      -        Matcher m = VSTR_PATTERN.matcher(s);
      -        if (!m.matches())
      -            throw new IllegalArgumentException("Invalid version string: '"
      -                                               + s + "'");
      -
      -        // $VNUM is a dot-separated list of integers of arbitrary length
      -        List list = new ArrayList<>();
      -        for (String i : m.group(VNUM_GROUP).split("\\."))
      -            list.add(Integer.parseInt(i));
      -        version = Collections.unmodifiableList(list);
      -
      -        pre = Optional.ofNullable(m.group(PRE_GROUP));
      -
      -        String b = m.group(BUILD_GROUP);
      -        // $BUILD is an integer
      -        build = (b == null)
      -             ? Optional.empty()
      -             : Optional.ofNullable(Integer.parseInt(b));
      -
      -        optional = Optional.ofNullable(m.group(OPT_GROUP));
      -
      -        // empty '+'
      -        if ((m.group(PLUS_GROUP) != null) && !build.isPresent()) {
      -            if (optional.isPresent()) {
      -                if (pre.isPresent())
      -                    throw new IllegalArgumentException("'+' found with"
      -                        + " pre-release and optional components:'" + s + "'");
      -            } else {
      -                throw new IllegalArgumentException("'+' found with neither"
      -                    + " build or optional components: '" + s + "'");
      -            }
      -        }
      -    }
      -
      -    /**
      -     * Parses the given string as a valid JDK version string containing a version number followed by pre-release and
      -     * build information.
      -     *
      -     * @param  s
      -     *         A string to interpret as a version
      -     *
      -     * @throws  IllegalArgumentException
      -     *          If the given string cannot be interpreted a valid version
      -     *
      -     * @throws  NullPointerException
      -     *          If the given string is {@code null}
      -     *
      -     * @throws  NumberFormatException
      -     *          If an element of the version number or the build number cannot
      -     *          be represented as an {@link Integer}
      -     *
      -     * @return  This version
      -     */
      -    public static Version parse(String s) {
      -        return new Version(s);
      -    }
      -
      -    /**
      -     * Returns {@code System.getProperty("java.version")} as a Version.
      -     *
      -     * @throws  SecurityException
      -     *          If a security manager exists and its {@link
      -     *          SecurityManager#checkPropertyAccess(String)
      -     *          checkPropertyAccess} method does not allow access to the
      -     *          system property "java.version"
      -     *
      -     * @return  {@code System.getProperty("java.version")} as a Version
      -     */
      -    public static Version current() {
      -        if (current == null) {
      -            current = parse(
      -                    GetPropertyAction.privilegedGetProperty("java.version"));
      -        }
      -        return current;
      -    }
      -
      -    /**
      -     * Returns the major version number.
      -     *
      -     * @return  The major version number
      -     */
      -    public int major() {
      -        return version.get(0);
      -    }
      -
      -    /**
      -     * Returns the minor version number or zero if it was
      -     * not set.
      -     *
      -     * @return  The minor version number or zero if it was not set
      -     */
      -    public int minor() {
      -        return (version.size() > 1 ? version.get(1) : 0);
      -    }
      -
      -    /**
      -     * Returns the security version number or zero if
      -     * it was not set.
      -     *
      -     * @return  The security version number or zero if it was not set
      -     */
      -    public int security() {
      -        return (version.size() > 2 ? version.get(2) : 0);
      -    }
      -
      -    /**
      -     * Returns an unmodifiable {@link java.util.List List} of the
      -     * integer numerals contained in the version
      -     * number.  The {@code List} always contains at least one
      -     * element corresponding to the major version
      -     * number.
      -     *
      -     * @return  An unmodifiable list of the integer numerals
      -     *          contained in the version number
      -     */
      -    public List version() {
      -        return version;
      -    }
      -
      -    /**
      -     * Returns the optional pre-release information.
      -     *
      -     * @return  The optional pre-release information as a String
      -     */
      -    public Optional pre() {
      -        return pre;
      -    }
      -
      -    /**
      -     * Returns the build number.
      -     *
      -     * @return The optional build number.
      -     */
      -    public Optional build() {
      -        return build;
      -    }
      -
      -    /**
      -     * Returns optional additional identifying build
      -     * information.
      -     *
      -     * @return  Additional build information as a String
      -     */
      -    public Optional optional() {
      -        return optional;
      -    }
      -
      -    /**
      -     * Compares this version to another.
      -     *
      -     * 

      Each of the components in the version is - * compared in the follow order of precedence: version numbers, - * pre-release identifiers, build numbers, optional build information.

      - * - *

      Comparison begins by examining the sequence of version numbers. If - * one sequence is shorter than another, then the missing elements of the - * shorter sequence are considered to be zero.

      - * - *

      A version with a pre-release identifier is always considered to be - * less than a version without one. Pre-release identifiers are compared - * numerically when they consist only of digits, and lexicographically - * otherwise. Numeric identifiers are considered to be less than - * non-numeric identifiers.

      - * - *

      A version without a build number is always less than one with a - * build number; otherwise build numbers are compared numerically.

      - * - *

      The optional build information is compared lexicographically. - * During this comparison, a version with optional build information is - * considered to be greater than a version without one.

      - * - *

      A version is not comparable to any other type of object. - * - * @param ob - * The object to be compared - * - * @return A negative integer, zero, or a positive integer if this - * {@code Version} is less than, equal to, or greater than the - * given {@code Version} - * - * @throws NullPointerException - * If the given object is {@code null} - */ - @Override - public int compareTo(Version ob) { - return compare(ob, false); - } - - /** - * Compares this version to another disregarding optional build - * information. - * - *

      Two versions are compared by examining the version string as - * described in {@link #compareTo(Version)} with the exception that the - * optional build information is always ignored.

      - * - *

      A version is not comparable to any other type of object. - * - * @param ob - * The object to be compared - * - * @return A negative integer, zero, or a positive integer if this - * {@code Version} is less than, equal to, or greater than the - * given {@code Version} - * - * @throws NullPointerException - * If the given object is {@code null} - */ - public int compareToIgnoreOpt(Version ob) { - return compare(ob, true); - } - - private int compare(Version ob, boolean ignoreOpt) { - if (ob == null) - throw new NullPointerException("Invalid argument"); - - int ret = compareVersion(ob); - if (ret != 0) - return ret; - - ret = comparePre(ob); - if (ret != 0) - return ret; - - ret = compareBuild(ob); - if (ret != 0) - return ret; - - if (!ignoreOpt) - return compareOpt(ob); - - return 0; - } - - private int compareVersion(Version ob) { - int size = version.size(); - int oSize = ob.version().size(); - int min = Math.min(size, oSize); - for (int i = 0; i < min; i++) { - Integer val = version.get(i); - Integer oVal = ob.version().get(i); - if (val != oVal) - return val - oVal; - } - if (size != oSize) - return size - oSize; - return 0; - } - - private int comparePre(Version ob) { - Optional oPre = ob.pre(); - if (!pre.isPresent()) { - if (oPre.isPresent()) - return 1; - } else { - if (!oPre.isPresent()) - return -1; - String val = pre.get(); - String oVal = oPre.get(); - if (val.matches("\\d+")) { - return (oVal.matches("\\d+") - ? (new BigInteger(val)).compareTo(new BigInteger(oVal)) - : -1); - } else { - return (oVal.matches("\\d+") - ? 1 - : val.compareTo(oVal)); - } - } - return 0; - } - - private int compareBuild(Version ob) { - Optional oBuild = ob.build(); - if (oBuild.isPresent()) { - return (build.isPresent() - ? build.get().compareTo(oBuild.get()) - : 1); - } else if (build.isPresent()) { - return -1; - } - return 0; - } - - private int compareOpt(Version ob) { - Optional oOpt = ob.optional(); - if (!optional.isPresent()) { - if (oOpt.isPresent()) - return -1; - } else { - if (!oOpt.isPresent()) - return 1; - return optional.get().compareTo(oOpt.get()); - } - return 0; - } - - /** - * Returns a string representation of this version. - * - * @return The version string - */ - @Override - public String toString() { - StringBuilder sb - = new StringBuilder(version.stream() - .map(Object::toString) - .collect(Collectors.joining("."))); - pre.ifPresent(v -> sb.append("-").append(v)); - - if (build.isPresent()) { - sb.append("+").append(build.get()); - if (optional.isPresent()) - sb.append("-").append(optional.get()); - } else { - if (optional.isPresent()) { - sb.append(pre.isPresent() ? "-" : "+-"); - sb.append(optional.get()); - } - } - - return sb.toString(); - } - - /** - * Determines whether this {@code Version} is equal to another object. - * - *

      Two {@code Version}s are equal if and only if they represent the - * same version string. - * - *

      This method satisfies the general contract of the {@link - * Object#equals(Object) Object.equals} method.

      - * - * @param ob - * The object to which this {@code Version} is to be compared - * - * @return {@code true} if, and only if, the given object is a {@code - * Version} that is identical to this {@code Version} - * - */ - @Override - public boolean equals(Object ob) { - boolean ret = equalsIgnoreOpt(ob); - if (!ret) - return false; - - Version that = (Version)ob; - return (this.optional().equals(that.optional())); - } - - /** - * Determines whether this {@code Version} is equal to another - * disregarding optional build information. - * - *

      Two {@code Version}s are equal if and only if they represent the - * same version string disregarding the optional build information. - * - * @param ob - * The object to which this {@code Version} is to be compared - * - * @return {@code true} if, and only if, the given object is a {@code - * Version} that is identical to this {@code Version} - * ignoring the optinal build information - * - */ - public boolean equalsIgnoreOpt(Object ob) { - if (this == ob) - return true; - if (!(ob instanceof Version)) - return false; - - Version that = (Version)ob; - return (this.version().equals(that.version()) - && this.pre().equals(that.pre()) - && this.build().equals(that.build())); - } - - /** - * Returns the hash code of this version. - * - *

      This method satisfies the general contract of the {@link - * Object#hashCode Object.hashCode} method. - * - * @return The hashcode of this version - */ - @Override - public int hashCode() { - int h = 1; - int p = 17; - - h = p * h + version.hashCode(); - h = p * h + pre.hashCode(); - h = p * h + build.hashCode(); - h = p * h + optional.hashCode(); - - return h; - } -} diff --git a/jdk/src/java.base/share/classes/module-info.java b/jdk/src/java.base/share/classes/module-info.java index 9d9fe8ec11f..a1b13336fa2 100644 --- a/jdk/src/java.base/share/classes/module-info.java +++ b/jdk/src/java.base/share/classes/module-info.java @@ -81,9 +81,6 @@ module java.base { exports javax.security.auth.x500; exports javax.security.cert; - // see JDK-8144062 - exports jdk; - // the service types defined by the APIs in this module diff --git a/jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/AboutDialog.java b/jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/AboutDialog.java index 8e54a707142..b4d4d11d150 100644 --- a/jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/AboutDialog.java +++ b/jdk/src/jdk.jconsole/share/classes/sun/tools/jconsole/AboutDialog.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -181,7 +181,7 @@ public class AboutDialog extends InternalDialog { } private static String getOnlineDocUrl() { - String version = Integer.toString(jdk.Version.current().major()); + String version = Integer.toString(Runtime.version().major()); return Resources.format(Messages.HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL, version); } diff --git a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java index 4ddeaff4c78..1e05e84e40f 100644 --- a/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java +++ b/jdk/src/jdk.zipfs/share/classes/jdk/nio/zipfs/JarFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ package jdk.nio.zipfs; import java.io.IOException; import java.io.InputStream; +import java.lang.Runtime.Version; import java.nio.file.Path; import java.util.Arrays; import java.util.HashMap; @@ -36,7 +37,6 @@ import java.util.function.Consumer; import java.util.function.Function; import java.util.jar.Attributes; import java.util.jar.Manifest; -import jdk.Version; /** * Adds aliasing to ZipFileSystem to support multi-release jar files. An alias map @@ -69,7 +69,7 @@ class JarFileSystem extends ZipFileSystem { if (o instanceof String) { String s = (String)o; if (s.equals("runtime")) { - version = jdk.Version.current().major(); + version = Runtime.version().major(); } else { version = Integer.parseInt(s); } diff --git a/jdk/test/jdk/Version/Basic.java b/jdk/test/java/lang/Runtime/Version/Basic.java similarity index 96% rename from jdk/test/jdk/Version/Basic.java rename to jdk/test/java/lang/Runtime/Version/Basic.java index b94180c8daf..0a60ad256d6 100644 --- a/jdk/test/jdk/Version/Basic.java +++ b/jdk/test/java/lang/Runtime/Version/Basic.java @@ -23,12 +23,13 @@ /* * @test - * @summary Unit test for jdk.Version. - * @bug 8072379 + * @summary Unit test for java.lang.Runtime.Version. + * @bug 8072379 8144062 */ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.lang.Runtime.Version; import java.math.BigInteger; import java.util.stream.Collectors; import java.util.Arrays; @@ -36,7 +37,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; -import jdk.Version; import static java.lang.System.out; public class Basic { @@ -116,8 +116,8 @@ public class Basic { tryCatch("1.4142+-", IAE); tryCatch("2.9979+-%", IAE); - //// Test for current() - testCurrent(); + //// Test for Runtime.version() + testVersion(); //// Test for equals{IgnoreOpt}?(), hashCode(), compareTo{IgnoreOpt}?() // compare: after "<" == -1, equal == 0, before ">" == 1 @@ -219,18 +219,19 @@ public class Basic { pass(); } - private static void testCurrent() { - Version current = Version.current(); - String javaVer = System.getProperty("java.version"); + private static void testVersion() { + Version current = Runtime.version(); + String javaVer = System.getProperty("java.runtime.version"); - // java.version == $VNUM(\-$PRE) - String [] ver = javaVer.split("-"); + // java.runtime.version == $VNUM(\-$PRE)?(\+$BUILD)?(-$OPT)? + String [] jv = javaVer.split("\\+"); + String [] ver = jv[0].split("-"); List javaVerVNum = Arrays.stream(ver[0].split("\\.")) .map(v -> Integer.parseInt(v)) .collect(Collectors.toList()); if (!javaVerVNum.equals(current.version())) { - fail("testCurrent() version()", javaVerVNum.toString(), + fail("Runtime.version()", javaVerVNum.toString(), current.version().toString()); } else { pass(); diff --git a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java index e6dd04c23af..54b889f9427 100644 --- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java +++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8132734 + * @bug 8132734 8144062 * @summary Test the extended API and the aliasing additions in JarFile that * support multi-release jar files * @library /lib/testlibrary/java/util/jar @@ -39,7 +39,6 @@ import java.util.Arrays; import java.util.jar.JarFile; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import jdk.Version; import static java.util.jar.JarFile.Release; @@ -51,7 +50,7 @@ import org.testng.annotations.Test; public class MultiReleaseJarAPI { - static final int MAJOR_VERSION = Version.current().major(); + static final int MAJOR_VERSION = Runtime.version().major(); String userdir = System.getProperty("user.dir","."); CreateMultiReleaseTestJars creator = new CreateMultiReleaseTestJars(); diff --git a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarIterators.java b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarIterators.java index 59900cf3f7a..60d5063ba71 100644 --- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarIterators.java +++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarIterators.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8132734 + * @bug 8132734 8144062 * @summary Test the extended API and the aliasing additions in JarFile that * support multi-release jar files * @library /lib/testlibrary/java/util/jar @@ -42,7 +42,6 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.stream.Collectors; import java.util.zip.ZipFile; -import jdk.Version; import static java.util.jar.JarFile.Release; @@ -54,7 +53,7 @@ import org.testng.annotations.Test; public class MultiReleaseJarIterators { - static final int MAJOR_VERSION = Version.current().major(); + static final int MAJOR_VERSION = Runtime.version().major(); String userdir = System.getProperty("user.dir", "."); File unversioned = new File(userdir, "unversioned.jar"); diff --git a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java index 6bf059fb8ea..d729c438a66 100644 --- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java +++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarProperties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8132734 + * @bug 8132734 8144062 * @summary Test the System properties for JarFile that support multi-release jar files * @library /lib/testlibrary/java/util/jar * @build Compiler JarBuilder CreateMultiReleaseTestJars @@ -54,7 +54,6 @@ import java.net.URLClassLoader; import java.nio.file.Files; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import jdk.Version; import org.testng.Assert; import org.testng.annotations.AfterClass; @@ -63,7 +62,7 @@ import org.testng.annotations.Test; public class MultiReleaseJarProperties { - static final int MAJOR_VERSION = Version.current().major(); + static final int MAJOR_VERSION = Runtime.version().major(); final static int ROOTVERSION = 8; // magic number from knowledge of internals final static String userdir = System.getProperty("user.dir", "."); diff --git a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java index 348194a3be3..538742ce192 100644 --- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java +++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarSecurity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8132734 + * @bug 8132734 8144062 * @summary Test potential security related issues * @library /lib/testlibrary/java/util/jar * @build Compiler JarBuilder CreateMultiReleaseTestJars @@ -40,7 +40,6 @@ import java.util.Arrays; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.zip.ZipFile; -import jdk.Version; import org.testng.Assert; import org.testng.annotations.AfterClass; @@ -49,7 +48,7 @@ import org.testng.annotations.Test; public class MultiReleaseJarSecurity { - static final int MAJOR_VERSION = Version.current().major(); + static final int MAJOR_VERSION = Runtime.version().major(); String userdir = System.getProperty("user.dir","."); File multirelease = new File(userdir, "multi-release.jar"); diff --git a/jdk/test/jdk/nio/zipfs/MultiReleaseJarTest.java b/jdk/test/jdk/nio/zipfs/MultiReleaseJarTest.java index 6f87dc68813..7f5f37b44fa 100644 --- a/jdk/test/jdk/nio/zipfs/MultiReleaseJarTest.java +++ b/jdk/test/jdk/nio/zipfs/MultiReleaseJarTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8144355 + * @bug 8144355 8144062 * @summary Test aliasing additions to ZipFileSystem for multi-release jar files * @library /lib/testlibrary/java/util/jar * @build Compiler JarBuilder CreateMultiReleaseTestJars @@ -34,17 +34,17 @@ import java.io.IOException; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; +import java.lang.Runtime.Version; import java.net.URI; import java.nio.file.*; import java.util.HashMap; import java.util.Map; -import jdk.Version; import org.testng.Assert; import org.testng.annotations.*; public class MultiReleaseJarTest { - final private int MAJOR_VERSION = Version.current().major(); + final private int MAJOR_VERSION = Runtime.version().major(); final private String userdir = System.getProperty("user.dir","."); final private Map stringEnv = new HashMap<>(); diff --git a/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java b/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java index 0f5545707a4..f6b01a08d40 100644 --- a/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java +++ b/jdk/test/sun/net/www/protocol/jar/MultiReleaseJarURLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8132734 + * @bug 8132734 8144062 * @summary Test that URL connections to multi-release jars can be runtime versioned * @library /lib/testlibrary/java/util/jar * @build Compiler JarBuilder CreateMultiReleaseTestJars SimpleHttpServer @@ -43,8 +43,6 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.jar.JarFile; -import jdk.Version; - import org.testng.Assert; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; @@ -94,7 +92,7 @@ public class MultiReleaseJarURLConnection { public void testRuntimeVersioning(String style, String file) throws Exception { String urlFile = "jar:file:" + file + "!/"; String baseUrlEntry = urlFile + "version/Version.java"; - String rtreturn = "return " + Version.current().major(); + String rtreturn = "return " + Runtime.version().major(); Assert.assertTrue(readAndCompare(new URL(baseUrlEntry), "return 8")); // #runtime is "magic" for a multi-release jar, but not for unversioned jar @@ -109,7 +107,7 @@ public class MultiReleaseJarURLConnection { if (style.equals("unversioned")) return; // direct access to versioned entry - String versUrlEntry = urlFile + "META-INF/versions/" + Version.current().major() + String versUrlEntry = urlFile + "META-INF/versions/" + Runtime.version().major() + "/version/Version.java"; Assert.assertTrue(readAndCompare(new URL(versUrlEntry), rtreturn)); // adding any fragment does not change things @@ -187,7 +185,7 @@ public class MultiReleaseJarURLConnection { MethodType mt = MethodType.methodType(int.class); MethodHandle mh = MethodHandles.lookup().findVirtual(vcls, "getVersion", mt); Assert.assertEquals((int)mh.invoke(vcls.newInstance()), - style.equals("unversioned") ? 8 : Version.current().major()); + style.equals("unversioned") ? 8 : Runtime.version().major()); // now get a resource and verify that we don't have a fragment attached URL vclsUrl = vcls.getResource("/version/Version.class"); @@ -206,7 +204,7 @@ public class MultiReleaseJarURLConnection { if (style.equals("unversioned")) { suffix = ".jar!/version/Version.class"; } else { - suffix = ".jar!/META-INF/versions/" + Version.current().major() + suffix = ".jar!/META-INF/versions/" + Runtime.version().major() + "/version/Version.class"; } Assert.assertTrue(rep.endsWith(suffix)); -- GitLab From 6f2785f74116747efbb319fc6e26d408f71da7b8 Mon Sep 17 00:00:00 2001 From: Anthony Scarpino Date: Thu, 19 May 2016 16:05:33 -0700 Subject: [PATCH 095/400] 8155847: SHA groups needed for jdk.security.provider.preferred Reviewed-by: valeriep, mullan --- .../sun/security/jca/ProviderList.java | 93 +++++++++++++++---- .../share/conf/security/java.security | 37 +++++--- .../security/jca/PreferredProviderTest.java | 77 ++++++++++++++- 3 files changed, 171 insertions(+), 36 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/jca/ProviderList.java b/jdk/src/java.base/share/classes/sun/security/jca/ProviderList.java index 9082670609e..971c4930b7e 100644 --- a/jdk/src/java.base/share/classes/sun/security/jca/ProviderList.java +++ b/jdk/src/java.base/share/classes/sun/security/jca/ProviderList.java @@ -650,12 +650,29 @@ public final class ProviderList { } } + /* Defined Groups for jdk.security.provider.preferred */ + private static final String SHA2Group[] = { "SHA-224", "SHA-256", + "SHA-384", "SHA-512", "SHA-512/224", "SHA-512/256" }; + private static final String HmacSHA2Group[] = { "HmacSHA224", + "HmacSHA256", "HmacSHA384", "HmacSHA512"}; + private static final String SHA2RSAGroup[] = { "SHA224withRSA", + "SHA256withRSA", "SHA384withRSA", "SHA512withRSA"}; + private static final String SHA2DSAGroup[] = { "SHA224withDSA", + "SHA256withDSA", "SHA384withDSA", "SHA512withDSA"}; + private static final String SHA2ECDSAGroup[] = { "SHA224withECDSA", + "SHA256withECDSA", "SHA384withECDSA", "SHA512withECDSA"}; + private static final String SHA3Group[] = { "SHA3-224", "SHA3-256", + "SHA3-384", "SHA3-512" }; + private static final String HmacSHA3Group[] = { "HmacSHA3-224", + "HmacSHA3-256", "HmacSHA3-384", "HmacSHA3-512"}; + // Individual preferred property entry from jdk.security.provider.preferred - private class PreferredEntry { - String type = null; - String algorithm; - String provider; - String alternateName = null; + private static class PreferredEntry { + private String type = null; + private String algorithm; + private String provider; + private String alternateNames[] = null; + private boolean group = false; PreferredEntry(String t, String p) { int i = t.indexOf('.'); @@ -667,47 +684,83 @@ public final class ProviderList { } provider = p; - if (algorithm.compareToIgnoreCase("SHA1") == 0) { - alternateName = "SHA-1"; + // Group definitions + if (type != null && type.compareToIgnoreCase("Group") == 0) { + // Currently intrinsic algorithm groups + if (algorithm.compareToIgnoreCase("SHA2") == 0) { + alternateNames = SHA2Group; + } else if (algorithm.compareToIgnoreCase("HmacSHA2") == 0) { + alternateNames = HmacSHA2Group; + } else if (algorithm.compareToIgnoreCase("SHA2RSA") == 0) { + alternateNames = SHA2RSAGroup; + } else if (algorithm.compareToIgnoreCase("SHA2DSA") == 0) { + alternateNames = SHA2DSAGroup; + } else if (algorithm.compareToIgnoreCase("SHA2ECDSA") == 0) { + alternateNames = SHA2ECDSAGroup; + } else if (algorithm.compareToIgnoreCase("SHA3") == 0) { + alternateNames = SHA3Group; + } else if (algorithm.compareToIgnoreCase("HmacSHA3") == 0) { + alternateNames = HmacSHA3Group; + } + if (alternateNames != null) { + group = true; + } + + // If the algorithm name given is SHA1 + } else if (algorithm.compareToIgnoreCase("SHA1") == 0) { + alternateNames = new String[] { "SHA-1" }; } else if (algorithm.compareToIgnoreCase("SHA-1") == 0) { - alternateName = "SHA1"; + alternateNames = new String[] { "SHA1" }; } } boolean match(String t, String a) { if (debug != null) { - debug.println("Config match: " + toString() + " == [" + t + - ", " + a + "]"); + debug.println("Config check: " + toString() + " == " + + print(t, a, null)); } // Compare service type if configured - if (type != null && type.compareToIgnoreCase(t) != 0) { + if (type != null && !group && type.compareToIgnoreCase(t) != 0) { return false; } // Compare the algorithm string. - if (a.compareToIgnoreCase(algorithm) == 0) { + if (!group && a.compareToIgnoreCase(algorithm) == 0) { if (debug != null) { - debug.println("Config entry found: " + toString()); + debug.println("Config entry matched: " + toString()); } return true; } - if (alternateName != null && - a.compareToIgnoreCase(alternateName) == 0) { - if (debug != null) { - debug.println("Config entry found (alternateName): " + - toString()); + if (alternateNames != null) { + for (String alt : alternateNames) { + if (debug != null) { + debug.println("AltName check: " + print(type, alt, + provider)); + } + if (a.compareToIgnoreCase(alt) == 0) { + if (debug != null) { + debug.println("AltName entry matched: " + + provider); + } + return true; + } } - return true; } // No match return false; } + // Print debugging output of PreferredEntry + private String print(String t, String a, String p) { + return "[" + ((t != null) ? t : "" ) + ", " + a + + ((p != null) ? " : " + p : "" ) + "] "; + } + public String toString() { - return "[" + type + ", " + algorithm + " : " + provider + "] "; + return print(type, algorithm, provider); } } diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security index 72c381b9747..caf94448f25 100644 --- a/jdk/src/java.base/share/conf/security/java.security +++ b/jdk/src/java.base/share/conf/security/java.security @@ -105,15 +105,30 @@ security.provider.tbd=SunPKCS11 # The provider is the name of the provider. Any provider that does not # also appear in the registered list will be ignored. # +# There is a special serviceType for this property only to group a set of +# algorithms together. The type is "Group" and is followed by an algorithm +# keyword. Groups are to simplify and lessen the entries on the property +# line. Current groups are: +# Group.SHA2 = SHA-224, SHA-256, SHA-384, SHA-512, SHA-512/224, SHA-512/256 +# Group.HmacSHA2 = HmacSHA224, HmacSHA256, HmacSHA384, HmacSHA512 +# Group.SHA2RSA = SHA224withRSA, SHA256withRSA, SHA384withRSA, SHA512withRSA +# Group.SHA2DSA = SHA224withDSA, SHA256withDSA, SHA384withDSA, SHA512withDSA +# Group.SHA2ECDSA = SHA224withECDSA, SHA256withECDSA, SHA384withECDSA, \ +# SHA512withECDSA +# Group.SHA3 = SHA3-224, SHA3-256, SHA3-384, SHA3-512 +# Group.HmacSHA3 = HmacSHA3-224, HmacSHA3-256, HmacSHA3-384, HmacSHA3-512 +# # Example: # jdk.security.provider.preferred=AES/GCM/NoPadding:SunJCE, \ -# MessageDigest.SHA-256:SUN +# MessageDigest.SHA-256:SUN, Group.HmacSHA2:SunJCE #ifdef solaris-sparc -jdk.security.provider.preferred=AES:SunJCE, SHA1:SUN, SHA-224:SUN, \ - SHA-256:SUN, SHA-384:SUN, SHA-512:SUN +jdk.security.provider.preferred=AES:SunJCE, SHA1:SUN, Group.SHA2:SUN, \ + HmacSHA1:SunJCE, Group.HmacSHA2:SunJCE #endif #ifdef solaris-x86 -jdk.security.provider.preferred=AES:SunJCE, RSA:SunRsaSign +jdk.security.provider.preferred=AES:SunJCE, SHA1:SUN, Group.SHA2:SUN, \ + HmacSHA1:SunJCE, Group.HmacSHA2:SunJCE, RSA:SunRsaSign, \ + SHA1withRSA:SunRsaSign, Group.SHA2RSA:SunRsaSign #endif @@ -613,14 +628,14 @@ krb5.kdc.bad.policy = tryLast # "CertConstraint" specifies additional constraints for # certificates that contain algorithms that are restricted: # -#   "jdkCA" prohibits the specified algorithm only if the algorithm is used -#     in a certificate chain that terminates at a marked trust anchor in the -#     lib/security/cacerts keystore.  All other chains are not affected. -#     If the jdkCA constraint is not set, then all chains using the -#     specified algorithm are restricted. jdkCA may only be used once in +# "jdkCA" prohibits the specified algorithm only if the algorithm is used +# in a certificate chain that terminates at a marked trust anchor in the +# lib/security/cacerts keystore.  All other chains are not affected. +# If the jdkCA constraint is not set, then all chains using the +# specified algorithm are restricted. jdkCA may only be used once in # a DisabledAlgorithm expression. -#     Example:  To apply this constraint to SHA-1 certificates, include -#     the following:  "SHA1 jdkCA" +# Example:  To apply this constraint to SHA-1 certificates, include +# the following:  "SHA1 jdkCA" # # When an algorithm must satisfy more than one constraint, it must be # delimited by an ampersand '&'. For example, to restrict certificates in a diff --git a/jdk/test/sun/security/jca/PreferredProviderTest.java b/jdk/test/sun/security/jca/PreferredProviderTest.java index 56aa4a0210e..72026222fee 100644 --- a/jdk/test/sun/security/jca/PreferredProviderTest.java +++ b/jdk/test/sun/security/jca/PreferredProviderTest.java @@ -25,15 +25,17 @@ import java.security.MessageDigest; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; import java.security.Security; +import java.security.Signature; import java.security.Provider; import java.util.Arrays; import java.util.List; import javax.crypto.Cipher; +import javax.crypto.Mac; import javax.crypto.NoSuchPaddingException; /** * @test - * @bug 8076359 8133151 8145344 8150512 + * @bug 8076359 8133151 8145344 8150512 8155847 * @summary Test the value for new jdk.security.provider.preferred * security property */ @@ -61,8 +63,8 @@ public class PreferredProviderTest { //java.security file which will be verified. switch (type) { case "sparcv9": - preferredProp = "AES:SunJCE, SHA1:SUN, SHA-224:SUN," - + " SHA-256:SUN, SHA-384:SUN, SHA-512:SUN"; + preferredProp = "AES:SunJCE, SHA1:SUN, Group.SHA2:SUN, " + + "HmacSHA1:SunJCE, Group.HmacSHA2:SunJCE"; verifyPreferredProviderProperty(os, type, preferredProp); verifyDigestProvider(os, type, Arrays.asList( @@ -71,14 +73,51 @@ public class PreferredProviderTest { new DataTuple("SHA-224", "SUN"), new DataTuple("SHA-256", "SUN"), new DataTuple("SHA-384", "SUN"), - new DataTuple("SHA-512", "SUN"))); + new DataTuple("SHA-512", "SUN"), + new DataTuple("SHA-512/224", "SUN"), + new DataTuple("SHA-512/256", "SUN"))); + + verifyMacProvider(os, type, Arrays.asList( + new DataTuple("HmacSHA1", "SunJCE"), + new DataTuple("HmacSHA224", "SunJCE"), + new DataTuple("HmacSHA256", "SunJCE"), + new DataTuple("HmacSHA384", "SunJCE"), + new DataTuple("HmacSHA512", "SunJCE"))); break; case "amd64": - preferredProp = "AES:SunJCE, RSA:SunRsaSign"; + preferredProp = "AES:SunJCE, SHA1:SUN, Group.SHA2:SUN, " + + "HmacSHA1:SunJCE, Group.HmacSHA2:SunJCE, " + + "RSA:SunRsaSign, SHA1withRSA:SunRsaSign, " + + "Group.SHA2RSA:SunRsaSign"; + verifyPreferredProviderProperty(os, type, preferredProp); verifyKeyFactoryProvider(os, type, Arrays.asList( new DataTuple("RSA", "SunRsaSign"))); + + verifyDigestProvider(os, type, Arrays.asList( + new DataTuple("SHA1", "SUN"), + new DataTuple("SHA-1", "SUN"), + new DataTuple("SHA-224", "SUN"), + new DataTuple("SHA-256", "SUN"), + new DataTuple("SHA-384", "SUN"), + new DataTuple("SHA-512", "SUN"), + new DataTuple("SHA-512/224", "SUN"), + new DataTuple("SHA-512/256", "SUN"))); + + verifyMacProvider(os, type, Arrays.asList( + new DataTuple("HmacSHA1", "SunJCE"), + new DataTuple("HmacSHA224", "SunJCE"), + new DataTuple("HmacSHA256", "SunJCE"), + new DataTuple("HmacSHA384", "SunJCE"), + new DataTuple("HmacSHA512", "SunJCE"))); + + verifySignatureProvider(os, type, Arrays.asList( + new DataTuple("SHA1withRSA", "SunRsaSign"), + new DataTuple("SHA224withRSA", "SunRsaSign"), + new DataTuple("SHA256withRSA", "SunRsaSign"), + new DataTuple("SHA384withRSA", "SunRsaSign"), + new DataTuple("SHA512withRSA", "SunRsaSign"))); break; } verifyDigestProvider(os, type, Arrays.asList( @@ -99,6 +138,8 @@ public class PreferredProviderTest { String preferredProvider = Security.getProperty("jdk.security.provider.preferred"); if (!preferredProvider.equals(preferred)) { + System.out.println("Expected: " + preferred + "\nResult: " + + preferredProvider); throw new RuntimeException(String.format( "Test Failed: wrong jdk.security.provider.preferred value " + "on %s-%s", os, arch)); @@ -120,6 +161,19 @@ public class PreferredProviderTest { "Preferred MessageDigest algorithm verification successful."); } + private static void verifyMacProvider(String os, String arch, + List algoProviders) throws NoSuchAlgorithmException { + for (DataTuple dataTuple : algoProviders) { + System.out.printf( + "Verifying Mac for '%s'%n", dataTuple.algorithm); + Mac mac = Mac.getInstance(dataTuple.algorithm); + matchProvider(mac.getProvider(), dataTuple.provider, + dataTuple.algorithm, os, arch); + } + System.out.println( + "Preferred Mac algorithm verification successful."); + } + private static void verifyKeyFactoryProvider(String os, String arch, List algoProviders) throws NoSuchAlgorithmException { for (DataTuple dataTuple : algoProviders) { @@ -133,6 +187,19 @@ public class PreferredProviderTest { "Preferred KeyFactory algorithm verification successful."); } + private static void verifySignatureProvider(String os, String arch, + List algoProviders) throws NoSuchAlgorithmException { + for (DataTuple dataTuple : algoProviders) { + System.out.printf( + "Verifying Signature for '%s'%n", dataTuple.algorithm); + Signature si = Signature.getInstance(dataTuple.algorithm); + matchProvider(si.getProvider(), dataTuple.provider, + dataTuple.algorithm, os, arch); + } + System.out.println( + "Preferred Signature algorithm verification successful."); + } + private static void matchProvider(Provider provider, String expected, String algo, String os, String arch) { if (!provider.getName().equals(expected)) { -- GitLab From 0260528ef92c4cdfd14198639b78e8e6d0c81613 Mon Sep 17 00:00:00 2001 From: Brent Christian Date: Thu, 19 May 2016 16:25:35 -0700 Subject: [PATCH 096/400] 8029891: Deadlock detected in java/lang/ClassLoader/deadlock/GetResource.java Properties now stores values in an internal ConcurrentHashMap Reviewed-by: mchung, dholmes, plevart --- .../share/classes/java/util/Hashtable.java | 68 +++- .../share/classes/java/util/Properties.java | 357 ++++++++++++++++-- jdk/test/ProblemList.txt | 2 - .../ClassLoader/deadlock/GetResource.java | 8 +- .../java/util/Properties/CheckOverrides.java | 106 ++++++ .../util/Properties/CheckUnsynchronized.java | 61 +++ .../Properties/PropertiesSerialization.java | 148 ++++++++ 7 files changed, 702 insertions(+), 48 deletions(-) create mode 100644 jdk/test/java/util/Properties/CheckOverrides.java create mode 100644 jdk/test/java/util/Properties/CheckUnsynchronized.java create mode 100644 jdk/test/java/util/Properties/PropertiesSerialization.java diff --git a/jdk/src/java.base/share/classes/java/util/Hashtable.java b/jdk/src/java.base/share/classes/java/util/Hashtable.java index 6ad2f3a933c..b541ca12a06 100644 --- a/jdk/src/java.base/share/classes/java/util/Hashtable.java +++ b/jdk/src/java.base/share/classes/java/util/Hashtable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -229,6 +229,14 @@ public class Hashtable putAll(t); } + /** + * A constructor chained from {@link Properties} keeps Hashtable fields + * uninitialized since they are not used. + * + * @param dummy a dummy parameter + */ + Hashtable(Void dummy) {} + /** * Returns the number of keys in this hashtable. * @@ -549,18 +557,23 @@ public class Hashtable * @return a clone of the hashtable */ public synchronized Object clone() { + Hashtable t = cloneHashtable(); + t.table = new Entry[table.length]; + for (int i = table.length ; i-- > 0 ; ) { + t.table[i] = (table[i] != null) + ? (Entry) table[i].clone() : null; + } + t.keySet = null; + t.entrySet = null; + t.values = null; + t.modCount = 0; + return t; + } + + /** Calls super.clone() */ + final Hashtable cloneHashtable() { try { - Hashtable t = (Hashtable)super.clone(); - t.table = new Entry[table.length]; - for (int i = table.length ; i-- > 0 ; ) { - t.table[i] = (table[i] != null) - ? (Entry) table[i].clone() : null; - } - t.keySet = null; - t.entrySet = null; - t.values = null; - t.modCount = 0; - return t; + return (Hashtable)super.clone(); } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(e); @@ -1189,6 +1202,15 @@ public class Hashtable */ private void writeObject(java.io.ObjectOutputStream s) throws IOException { + writeHashtable(s); + } + + /** + * Perform serialization of the Hashtable to an ObjectOutputStream. + * The Properties class overrides this method. + */ + void writeHashtable(java.io.ObjectOutputStream s) + throws IOException { Entry entryStack = null; synchronized (this) { @@ -1218,12 +1240,30 @@ public class Hashtable } } + /** + * Called by Properties to write out a simulated threshold and loadfactor. + */ + final void defaultWriteHashtable(java.io.ObjectOutputStream s, int length, + float loadFactor) throws IOException { + this.threshold = (int)Math.min(length * loadFactor, MAX_ARRAY_SIZE + 1); + this.loadFactor = loadFactor; + s.defaultWriteObject(); + } + /** * Reconstitute the Hashtable from a stream (i.e., deserialize it). */ private void readObject(java.io.ObjectInputStream s) - throws IOException, ClassNotFoundException - { + throws IOException, ClassNotFoundException { + readHashtable(s); + } + + /** + * Perform deserialization of the Hashtable from an ObjectInputStream. + * The Properties class overrides this method. + */ + void readHashtable(java.io.ObjectInputStream s) + throws IOException, ClassNotFoundException { // Read in the threshold and loadFactor s.defaultReadObject(); diff --git a/jdk/src/java.base/share/classes/java/util/Properties.java b/jdk/src/java.base/share/classes/java/util/Properties.java index 1eddbab3740..c2b93d250bf 100644 --- a/jdk/src/java.base/share/classes/java/util/Properties.java +++ b/jdk/src/java.base/share/classes/java/util/Properties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,13 @@ import java.io.Reader; import java.io.Writer; import java.io.OutputStreamWriter; import java.io.BufferedWriter; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.StreamCorruptedException; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.BiConsumer; +import java.util.function.BiFunction; +import java.util.function.Function; import jdk.internal.util.xml.PropertiesDefaultHandler; @@ -60,6 +67,13 @@ import jdk.internal.util.xml.PropertiesDefaultHandler; * object that contains a non-{@code String} key. * *

      + * The iterators returned by the {@code iterator} method of this class's + * "collection views" (that is, {@code entrySet()}, {@code keySet()}, and + * {@code values()}) may not fail-fast (unlike the Hashtable implementation). + * These iterators are guaranteed to traverse elements as they existed upon + * construction exactly once, and may (but are not guaranteed to) reflect any + * modifications subsequent to construction. + *

      * The {@link #load(java.io.Reader) load(Reader)} {@code /} * {@link #store(java.io.Writer, java.lang.String) store(Writer, String)} * methods load and store properties from and to a character based stream @@ -127,6 +141,15 @@ class Properties extends Hashtable { */ protected Properties defaults; + /** + * Properties does not store values in its inherited Hashtable, but instead + * in an internal ConcurrentHashMap. Synchronization is omitted from + * simple read operations. Writes and bulk operations remain synchronized, + * as in Hashtable. + */ + private transient ConcurrentHashMap map = + new ConcurrentHashMap<>(8); + /** * Creates an empty property list with no default values. */ @@ -140,6 +163,9 @@ class Properties extends Hashtable { * @param defaults the defaults. */ public Properties(Properties defaults) { + // use package-private constructor to + // initialize unused fields with dummy values + super((Void) null); this.defaults = defaults; } @@ -826,9 +852,9 @@ class Properties extends Hashtable { bw.write("#" + new Date().toString()); bw.newLine(); synchronized (this) { - for (Enumeration e = keys(); e.hasMoreElements();) { - String key = (String)e.nextElement(); - String val = (String)get(key); + for (Map.Entry e : entrySet()) { + String key = (String)e.getKey(); + String val = (String)e.getValue(); key = saveConvert(key, true, escUnicode); /* No need to escape embedded and trailing spaces for value, hence * pass false to flag. @@ -967,7 +993,7 @@ class Properties extends Hashtable { * @see #defaults */ public String getProperty(String key) { - Object oval = super.get(key); + Object oval = map.get(key); String sval = (oval instanceof String) ? (String)oval : null; return ((sval == null) && (defaults != null)) ? defaults.getProperty(key) : sval; } @@ -1029,7 +1055,7 @@ class Properties extends Hashtable { * @since 1.6 */ public Set stringPropertyNames() { - Hashtable h = new Hashtable<>(); + Map h = new HashMap<>(); enumerateStringProperties(h); return h.keySet(); } @@ -1044,11 +1070,11 @@ class Properties extends Hashtable { */ public void list(PrintStream out) { out.println("-- listing properties --"); - Hashtable h = new Hashtable<>(); + Map h = new HashMap<>(); enumerate(h); - for (Enumeration e = h.keys() ; e.hasMoreElements() ;) { - String key = e.nextElement(); - String val = (String)h.get(key); + for (Map.Entry e : h.entrySet()) { + String key = e.getKey(); + String val = (String)e.getValue(); if (val.length() > 40) { val = val.substring(0, 37) + "..."; } @@ -1072,11 +1098,11 @@ class Properties extends Hashtable { */ public void list(PrintWriter out) { out.println("-- listing properties --"); - Hashtable h = new Hashtable<>(); + Map h = new HashMap<>(); enumerate(h); - for (Enumeration e = h.keys() ; e.hasMoreElements() ;) { - String key = e.nextElement(); - String val = (String)h.get(key); + for (Map.Entry e : h.entrySet()) { + String key = e.getKey(); + String val = (String)e.getValue(); if (val.length() > 40) { val = val.substring(0, 37) + "..."; } @@ -1085,33 +1111,33 @@ class Properties extends Hashtable { } /** - * Enumerates all key/value pairs in the specified hashtable. - * @param h the hashtable + * Enumerates all key/value pairs into the specified Map. + * @param h the Map * @throws ClassCastException if any of the property keys * is not of String type. */ - private synchronized void enumerate(Hashtable h) { + private void enumerate(Map h) { if (defaults != null) { defaults.enumerate(h); } - for (Enumeration e = keys() ; e.hasMoreElements() ;) { - String key = (String)e.nextElement(); - h.put(key, get(key)); + for (Map.Entry e : entrySet()) { + String key = (String)e.getKey(); + h.put(key, e.getValue()); } } /** - * Enumerates all key/value pairs in the specified hashtable + * Enumerates all key/value pairs into the specified Map * and omits the property if the key or value is not a string. - * @param h the hashtable + * @param h the Map */ - private synchronized void enumerateStringProperties(Hashtable h) { + private void enumerateStringProperties(Map h) { if (defaults != null) { defaults.enumerateStringProperties(h); } - for (Enumeration e = keys() ; e.hasMoreElements() ;) { - Object k = e.nextElement(); - Object v = get(k); + for (Map.Entry e : entrySet()) { + Object k = e.getKey(); + Object v = e.getValue(); if (k instanceof String && v instanceof String) { h.put((String) k, (String) v); } @@ -1130,4 +1156,283 @@ class Properties extends Hashtable { private static final char[] hexDigit = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' }; + + // + // Hashtable methods overridden and delegated to a ConcurrentHashMap instance + + @Override + public int size() { + return map.size(); + } + + @Override + public boolean isEmpty() { + return map.isEmpty(); + } + + @Override + public Enumeration keys() { + // CHM.keys() returns Iterator w/ remove() - instead wrap keySet() + return Collections.enumeration(map.keySet()); + } + + @Override + public Enumeration elements() { + // CHM.elements() returns Iterator w/ remove() - instead wrap values() + return Collections.enumeration(map.values()); + } + + @Override + public boolean contains(Object value) { + return map.contains(value); + } + + @Override + public boolean containsValue(Object value) { + return map.containsValue(value); + } + + @Override + public boolean containsKey(Object key) { + return map.containsKey(key); + } + + @Override + public Object get(Object key) { + return map.get(key); + } + + @Override + public synchronized Object put(Object key, Object value) { + return map.put(key, value); + } + + @Override + public synchronized Object remove(Object key) { + return map.remove(key); + } + + @Override + public synchronized void putAll(Map t) { + map.putAll(t); + } + + @Override + public synchronized void clear() { + map.clear(); + } + + @Override + public synchronized String toString() { + return map.toString(); + } + + @Override + public Set keySet() { + return Collections.synchronizedSet(map.keySet(), this); + } + + @Override + public Collection values() { + return Collections.synchronizedCollection(map.values(), this); + } + + @Override + public Set> entrySet() { + return Collections.synchronizedSet(new EntrySet(map.entrySet()), this); + } + + /* + * Properties.entrySet() should not support add/addAll, however + * ConcurrentHashMap.entrySet() provides add/addAll. This class wraps the + * Set returned from CHM, changing add/addAll to throw UOE. + */ + private static class EntrySet implements Set> { + private Set> entrySet; + + private EntrySet(Set> entrySet) { + this.entrySet = entrySet; + } + + @Override public int size() { return entrySet.size(); } + @Override public boolean isEmpty() { return entrySet.isEmpty(); } + @Override public boolean contains(Object o) { return entrySet.contains(o); } + @Override public Object[] toArray() { return entrySet.toArray(); } + @Override public T[] toArray(T[] a) { return entrySet.toArray(a); } + @Override public void clear() { entrySet.clear(); } + @Override public boolean remove(Object o) { return entrySet.remove(o); } + + @Override + public boolean add(Map.Entry e) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean addAll(Collection> c) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean containsAll(Collection c) { + return entrySet.containsAll(c); + } + + @Override + public boolean removeAll(Collection c) { + return entrySet.removeAll(c); + } + + @Override + public boolean retainAll(Collection c) { + return entrySet.retainAll(c); + } + + @Override + public Iterator> iterator() { + return entrySet.iterator(); + } + } + + @Override + public synchronized boolean equals(Object o) { + return map.equals(o); + } + + @Override + public synchronized int hashCode() { + return map.hashCode(); + } + + @Override + public Object getOrDefault(Object key, Object defaultValue) { + return map.getOrDefault(key, defaultValue); + } + + @Override + public synchronized void forEach(BiConsumer action) { + map.forEach(action); + } + + @Override + public synchronized void replaceAll(BiFunction function) { + map.replaceAll(function); + } + + @Override + public synchronized Object putIfAbsent(Object key, Object value) { + return map.putIfAbsent(key, value); + } + + @Override + public synchronized boolean remove(Object key, Object value) { + return map.remove(key, value); + } + + /** @hidden */ + @Override + public synchronized boolean replace(Object key, Object oldValue, Object newValue) { + return map.replace(key, oldValue, newValue); + } + + @Override + public synchronized Object replace(Object key, Object value) { + return map.replace(key, value); + } + + @Override + public synchronized Object computeIfAbsent(Object key, + Function mappingFunction) { + return map.computeIfAbsent(key, mappingFunction); + } + + @Override + public synchronized Object computeIfPresent(Object key, + BiFunction remappingFunction) { + return map.computeIfPresent(key, remappingFunction); + } + + @Override + public synchronized Object compute(Object key, + BiFunction remappingFunction) { + return map.compute(key, remappingFunction); + } + + @Override + public synchronized Object merge(Object key, Object value, + BiFunction remappingFunction) { + return map.merge(key, value, remappingFunction); + } + + // + // Special Hashtable methods + + @Override + protected void rehash() { /* no-op */ } + + @Override + public synchronized Object clone() { + Properties clone = (Properties) cloneHashtable(); + clone.map = new ConcurrentHashMap<>(map); + return clone; + } + + // + // Hashtable serialization overrides + // (these should emit and consume Hashtable-compatible stream) + + @Override + void writeHashtable(ObjectOutputStream s) throws IOException { + List entryStack = new ArrayList<>(map.size() * 2); // an estimate + + for (Map.Entry entry : map.entrySet()) { + entryStack.add(entry.getValue()); + entryStack.add(entry.getKey()); + } + + // Write out the simulated threshold, loadfactor + float loadFactor = 0.75f; + int count = entryStack.size() / 2; + int length = (int)(count / loadFactor) + (count / 20) + 3; + if (length > count && (length & 1) == 0) { + length--; + } + synchronized (map) { // in case of multiple concurrent serializations + defaultWriteHashtable(s, length, loadFactor); + } + + // Write out simulated length and real count of elements + s.writeInt(length); + s.writeInt(count); + + // Write out the key/value objects from the stacked entries + for (int i = entryStack.size() - 1; i >= 0; i--) { + s.writeObject(entryStack.get(i)); + } + } + + @Override + void readHashtable(ObjectInputStream s) throws IOException, + ClassNotFoundException { + // Read in the threshold and loadfactor + s.defaultReadObject(); + + // Read the original length of the array and number of elements + int origlength = s.readInt(); + int elements = s.readInt(); + + // Validate # of elements + if (elements < 0) { + throw new StreamCorruptedException("Illegal # of Elements: " + elements); + } + + // create CHM of appropriate capacity + map = new ConcurrentHashMap<>(elements); + + // Read all the key/value objects + for (; elements > 0; elements--) { + Object key = s.readObject(); + Object value = s.readObject(); + map.put(key, value); + } + } } diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index a3c3a99ded4..2e080ae84fe 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -126,8 +126,6 @@ java/beans/Introspector/8132566/OverrideUserDefPropertyInfoTest.java 8132565 gen # jdk_lang -java/lang/ClassLoader/deadlock/GetResource.java 8029891 generic-all - java/lang/StringCoding/CheckEncodings.sh 7008363 generic-all ############################################################################ diff --git a/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java b/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java index a1a1b4e1730..26fbe3dd586 100644 --- a/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java +++ b/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,7 @@ import java.io.IOException; import java.net.URL; /* @test - * @bug 6977738 + * @bug 6977738 8029891 * @summary Test ClassLoader.getResource() that should not deadlock # if another thread is holding the system properties object * @@ -70,10 +70,6 @@ public class GetResource { go.await(); // wait until t1 holds the lock of the system properties URL u1 = Thread.currentThread().getContextClassLoader().getResource("unknownresource"); - URL u2 = Thread.currentThread().getContextClassLoader().getResource("sun/util/resources/CalendarData.class"); - if (u2 == null) { - throw new RuntimeException("Test failed: resource not found"); - } done.await(); } catch (InterruptedException e) { throw new RuntimeException(e); diff --git a/jdk/test/java/util/Properties/CheckOverrides.java b/jdk/test/java/util/Properties/CheckOverrides.java new file mode 100644 index 00000000000..327143a66cb --- /dev/null +++ b/jdk/test/java/util/Properties/CheckOverrides.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.*; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/* + * @test + * @bug 8029891 + * @summary Test that the Properties class overrides all public+protected + * methods of all ancestor classes and interfaces + * @run main CheckOverrides + */ +public class CheckOverrides { + + public static void main(String[] args) { + Set pMethodSignatures = + Stream.of(Properties.class.getDeclaredMethods()) + .filter(CheckOverrides::isMethodOfInterest) + .map(MethodSignature::new) + .collect(Collectors.toSet()); + + Map unoverriddenMethods = new HashMap<>(); + for (Class superclass = Properties.class.getSuperclass(); + superclass != Object.class; + superclass = superclass.getSuperclass()) { + Stream.of(superclass.getDeclaredMethods()) + .filter(CheckOverrides::isMethodOfInterest) + .forEach(m -> unoverriddenMethods.putIfAbsent(new MethodSignature(m), m)); + } + unoverriddenMethods.keySet().removeAll(pMethodSignatures); + + if (!unoverriddenMethods.isEmpty()) { + throw new RuntimeException( + "The following methods should be overridden by Properties class:\n" + + unoverriddenMethods.values().stream() + .map(Method::toString) + .collect(Collectors.joining("\n ", " ", "\n")) + ); + } + } + + static boolean isMethodOfInterest(Method method) { + int mods = method.getModifiers(); + return !Modifier.isStatic(mods) && + (Modifier.isPublic(mods) || Modifier.isProtected(mods)); + } + + static class MethodSignature { + final Class returnType; + final String name; + final Class[] parameterTypes; + + MethodSignature(Method method) { + this(method.getReturnType(), method.getName(), method.getParameterTypes()); + } + + private MethodSignature(Class returnType, String name, Class[] parameterTypes) { + this.returnType = returnType; + this.name = name; + this.parameterTypes = parameterTypes; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + MethodSignature that = (MethodSignature) o; + if (!returnType.equals(that.returnType)) return false; + if (!name.equals(that.name)) return false; + return Arrays.equals(parameterTypes, that.parameterTypes); + } + + @Override + public int hashCode() { + int result = returnType.hashCode(); + result = 31 * result + name.hashCode(); + result = 31 * result + Arrays.hashCode(parameterTypes); + return result; + } + } +} + diff --git a/jdk/test/java/util/Properties/CheckUnsynchronized.java b/jdk/test/java/util/Properties/CheckUnsynchronized.java new file mode 100644 index 00000000000..1b32cca0827 --- /dev/null +++ b/jdk/test/java/util/Properties/CheckUnsynchronized.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.Enumeration; +import java.util.Properties; +import java.util.concurrent.CompletableFuture; + +/* + * @test + * @bug 8029891 + * @summary Test Properties methods that do not synchronize any more + * @run main CheckUnsynchronized + */ +public class CheckUnsynchronized { + public static void main(String[] args) { + Properties props = new Properties(); + synchronized (props) { + props.setProperty("key", "value"); + System.out.println("contains(value)? " + + CompletableFuture.supplyAsync(() -> props.contains("value")).join()); + System.out.println("containsKey(key)? " + + CompletableFuture.supplyAsync(() -> props.containsKey("key")).join()); + System.out.println("containsValue(value)? " + + CompletableFuture.supplyAsync(() -> props.containsValue("value")).join()); + Enumeration elems = + CompletableFuture.supplyAsync(() -> props.elements()).join(); + System.out.println("first value from elements(): " + elems.nextElement()); + System.out.println("value from get(): " + + CompletableFuture.supplyAsync(() -> props.getProperty("key")).join()); + System.out.println("getOrDefault(\"missing\"): " + + CompletableFuture.supplyAsync(() -> props.getOrDefault("missing", "default")).join()); + System.out.println("isEmpty()? " + + CompletableFuture.supplyAsync(() -> props.isEmpty()).join()); + Enumeration keys = + CompletableFuture.supplyAsync(() -> props.keys()).join(); + System.out.println("first key from keys(): " + keys.nextElement()); + System.out.println("size(): " + + CompletableFuture.supplyAsync(() -> props.size()).join()); + } + } +} diff --git a/jdk/test/java/util/Properties/PropertiesSerialization.java b/jdk/test/java/util/Properties/PropertiesSerialization.java new file mode 100644 index 00000000000..2fcf1dc810a --- /dev/null +++ b/jdk/test/java/util/Properties/PropertiesSerialization.java @@ -0,0 +1,148 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.Base64; +import java.util.Properties; + +/** + * @test + * @bug 8029891 + * @summary tests the compatibility of Properties serial form + * @run main PropertiesSerialization read + * + * To update this test in case the serial form of Properties changes, run this + * test with the 'write' flag, and copy the resulting output back into this + * file, replacing the existing String declaration(s). + */ +public class PropertiesSerialization { + private static final Properties TEST_PROPS; + static { + TEST_PROPS = new Properties(); + TEST_PROPS.setProperty("one", "two"); + TEST_PROPS.setProperty("buckle", "shoe"); + TEST_PROPS.setProperty("three", "four"); + TEST_PROPS.setProperty("shut", "door"); + } + + /** + * Base64 encoded string for Properties object + * Java version: 1.8.0 + **/ + private static final String TEST_SER_BASE64 = + "rO0ABXNyABRqYXZhLnV0aWwuUHJvcGVydGllczkS0HpwNj6YAgABTAAIZGVmYXVs" + + "dHN0ABZMamF2YS91dGlsL1Byb3BlcnRpZXM7eHIAE2phdmEudXRpbC5IYXNodGFi" + + "bGUTuw8lIUrkuAMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4cD9AAAAAAAAI" + + "dwgAAAALAAAABHQAA29uZXQAA3R3b3QABHNodXR0AARkb29ydAAGYnVja2xldAAE" + + "c2hvZXQABXRocmVldAAEZm91cnhw"; + + public static void main(String[] args) throws IOException, + ClassNotFoundException { + if (args.length == 0) { + System.err.println("Run with 'read' or 'write'"); + System.err.println(" read mode: normal test mode."); + System.err.println(" Confirms that serial stream can"); + System.err.println(" be deserialized as expected."); + System.err.println(" write mode: meant for updating the test,"); + System.err.println(" should the serial form change."); + System.err.println(" Test output should be pasted"); + System.err.println(" back into the test source."); + return; + } + + Properties deserializedObject; + if ("read".equals(args[0])) { + ByteArrayInputStream bais = new + ByteArrayInputStream(Base64.getDecoder().decode(TEST_SER_BASE64)); + try (ObjectInputStream ois = new ObjectInputStream(bais)) { + deserializedObject = (Properties) ois.readObject(); + } + if (!TEST_PROPS.equals(deserializedObject)) { + throw new RuntimeException("deserializedObject not equals()"); + } + System.out.println("Test passed"); + } else if ("write".equals(args[0])) { + System.out.println("\nTo update the test, paste the following back " + + "into the test code:\n"); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(TEST_PROPS); + oos.flush(); + oos.close(); + + byte[] byteArray = baos.toByteArray(); + // Check that the Properties deserializes correctly + ByteArrayInputStream bais = new ByteArrayInputStream(byteArray); + ObjectInputStream ois = new ObjectInputStream(bais); + Properties deser = (Properties)ois.readObject(); + if (!TEST_PROPS.equals(deser)) { + throw new RuntimeException("write: Deserialized != original"); + } + + // Now get a Base64 string representation of the serialized bytes. + final String base64 = Base64.getEncoder().encodeToString(byteArray); + // Check that we can deserialize the Base64 string we just computed. + ByteArrayInputStream bais2 = + new ByteArrayInputStream(Base64.getDecoder().decode(base64)); + ObjectInputStream ois2 = new ObjectInputStream(bais2); + Properties deser2 = (Properties)ois2.readObject(); + if (!TEST_PROPS.equals(deser2)) { + throw new RuntimeException("write: Deserialized base64 != " + + "original"); + } + System.out.println(dumpBase64SerialStream(base64)); + } + } + + private static final String INDENT = " "; + /* Based on: + * java/util/logging/HigherResolutionTimeStamps/SerializeLogRecored.java + */ + private static String dumpBase64SerialStream(String base64) { + // Generates the Java Pseudo code that can be cut & pasted into + // this test (see Jdk8SerializedLog and Jdk9SerializedLog below) + final StringBuilder sb = new StringBuilder(); + sb.append(INDENT).append(" /**").append('\n'); + sb.append(INDENT).append(" * Base64 encoded string for Properties object\n"); + sb.append(INDENT).append(" * Java version: ") + .append(System.getProperty("java.version")).append('\n'); + sb.append(INDENT).append(" **/").append('\n'); + sb.append(INDENT).append(" private static final String TEST_SER_BASE64 = ") + .append("\n").append(INDENT).append(" "); + final int last = base64.length() - 1; + for (int i=0; i Date: Thu, 19 May 2016 19:45:04 -0700 Subject: [PATCH 097/400] 8157344: Multiple test timeouts after push for JDK-8141039 8156606: java/security/SecureRandom/Serialize.java gets time out in Linux Reviewed-by: weijun --- jdk/test/ProblemList.txt | 2 ++ jdk/test/java/security/SecureRandom/ApiTest.java | 11 ++++++----- .../java/security/SecureRandom/EnoughSeedTest.java | 3 ++- jdk/test/java/security/SecureRandom/Serialize.java | 3 +++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 2e080ae84fe..5d2113b99b1 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -292,6 +292,8 @@ sun/security/provider/NSASuiteB/TestDSAGenParameterSpec.java 8137255 generic- sun/security/x509/URICertStore/ExtensionsWithLDAP.java 8134577 generic-all +sun/security/provider/SecureRandom/StrongSecureRandom.java 8157387 linux-all + ############################################################################ # jdk_sound diff --git a/jdk/test/java/security/SecureRandom/ApiTest.java b/jdk/test/java/security/SecureRandom/ApiTest.java index bf3c8374122..e48ee4a90de 100644 --- a/jdk/test/java/security/SecureRandom/ApiTest.java +++ b/jdk/test/java/security/SecureRandom/ApiTest.java @@ -28,11 +28,11 @@ * @summary This test do API coverage for SecureRandom. It covers most of * supported operations along with possible positive and negative * parameters for DRBG mechanism. - * @run main ApiTest Hash_DRBG - * @run main ApiTest HMAC_DRBG - * @run main ApiTest CTR_DRBG - * @run main ApiTest SHA1PRNG - * @run main ApiTest NATIVE + * @run main/othervm ApiTest Hash_DRBG + * @run main/othervm ApiTest HMAC_DRBG + * @run main/othervm ApiTest CTR_DRBG + * @run main/othervm ApiTest SHA1PRNG + * @run main/othervm ApiTest NATIVE */ import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; @@ -53,6 +53,7 @@ public class ApiTest { = Security.getProperty(DRBG_CONFIG); public static void main(String[] args) throws Exception { + System.setProperty("java.security.egd", "file:/dev/urandom"); if (args == null || args.length < 1) { throw new RuntimeException("No mechanism available to run test."); diff --git a/jdk/test/java/security/SecureRandom/EnoughSeedTest.java b/jdk/test/java/security/SecureRandom/EnoughSeedTest.java index 82c51c04fb4..a42807d0530 100644 --- a/jdk/test/java/security/SecureRandom/EnoughSeedTest.java +++ b/jdk/test/java/security/SecureRandom/EnoughSeedTest.java @@ -27,7 +27,7 @@ * @library /lib/testlibrary * @summary Check SecureRandom generate expected seed counts what the caller * asked for. - * @run main EnoughSeedTest + * @run main/othervm EnoughSeedTest */ import java.security.SecureRandom; import java.security.Security; @@ -40,6 +40,7 @@ public class EnoughSeedTest { = Security.getProperty(DRBG_CONFIG); public static void main(String[] args) { + System.setProperty("java.security.egd", "file:/dev/urandom"); boolean success = true; for (String mech : new String[]{ diff --git a/jdk/test/java/security/SecureRandom/Serialize.java b/jdk/test/java/security/SecureRandom/Serialize.java index 799f1bfa428..2e364878c80 100644 --- a/jdk/test/java/security/SecureRandom/Serialize.java +++ b/jdk/test/java/security/SecureRandom/Serialize.java @@ -24,6 +24,7 @@ /* @test * @bug 4102896 * @summary Make sure that a SecureRandom object can be serialized + * @run main/othervm Serialize */ import java.security.*; @@ -32,6 +33,8 @@ import java.io.*; public class Serialize { public static void main(String args[]) throws Exception { + System.setProperty("java.security.egd", "file:/dev/urandom"); + for (String alg: new String[]{ "SHA1PRNG", "DRBG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG", "Hash_DRBG,SHA-512,192,pr_and_reseed"}) { -- GitLab From efd36db57d81ceac3bdb3ce87e023e5fb1edbc8e Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Fri, 20 May 2016 11:15:05 +0800 Subject: [PATCH 098/400] 8149521: automatic discovery of LDAP servers with Kerberos authentication Reviewed-by: vinnie --- .../share/classes/sun/security/krb5/PrincipalName.java | 3 +++ jdk/test/sun/security/krb5/canonicalize/Test.java | 6 ++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java index e60507fe443..b3a0e8bea38 100644 --- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java +++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java @@ -424,6 +424,9 @@ public class PrincipalName implements Cloneable { } catch (UnknownHostException | SecurityException e) { // not canonicalized or no permission to do so, use old } + if (hostName.endsWith(".")) { + hostName = hostName.substring(0, hostName.length() - 1); + } nameParts[1] = hostName.toLowerCase(Locale.ENGLISH); } nameStrings = nameParts; diff --git a/jdk/test/sun/security/krb5/canonicalize/Test.java b/jdk/test/sun/security/krb5/canonicalize/Test.java index 8d21a50727f..62c44de9984 100644 --- a/jdk/test/sun/security/krb5/canonicalize/Test.java +++ b/jdk/test/sun/security/krb5/canonicalize/Test.java @@ -22,7 +22,7 @@ */ /* * @test - * @bug 6682516 + * @bug 6682516 8149521 * @summary SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms * @modules java.security.jgss/sun.security.krb5 * @run main/othervm -Djava.security.krb5.conf=krb5.conf Test @@ -44,9 +44,11 @@ public class Test { check("c1", "c1.this.domain"); check("c1.this", "c1.this.domain"); check("c1.this.domain", "c1.this.domain"); + check("c1.this.domain.", "c1.this.domain"); // canonicalized name goes IP, reject check("c2", "c2"); + check("c2.", "c2"); // canonicalized name goes strange, reject check("c3", "c3"); @@ -63,4 +65,4 @@ public class Test { throw new Exception("Output is " + pn); } } - } +} -- GitLab From 06fe4b9a0bbd59817f0ac0b6896bd38e538857bc Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Fri, 20 May 2016 11:20:49 +0800 Subject: [PATCH 099/400] 8138766: New default -sigalg for keytool Reviewed-by: mullan --- .../security/tools/keytool/CertAndKeyGen.java | 18 ++++- .../sun/security/tools/keytool/Main.java | 24 +++--- .../keytool/DefaultSignatureAlgorithm.java | 80 +++++++++++++++++++ 3 files changed, 104 insertions(+), 18 deletions(-) create mode 100644 jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java diff --git a/jdk/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java b/jdk/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java index e2b4cfbb823..85037622c1b 100644 --- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java +++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/CertAndKeyGen.java @@ -67,7 +67,9 @@ public final class CertAndKeyGen { * * @param keyType type of key, e.g. "RSA", "DSA" * @param sigAlg name of the signature algorithm, e.g. "MD5WithRSA", - * "MD2WithRSA", "SHAwithDSA". + * "MD2WithRSA", "SHAwithDSA". If set to null, a default + * algorithm matching the private key will be chosen after + * the first keypair is generated. * @exception NoSuchAlgorithmException on unrecognized algorithms. */ public CertAndKeyGen (String keyType, String sigAlg) @@ -83,7 +85,9 @@ public final class CertAndKeyGen { * * @param keyType type of key, e.g. "RSA", "DSA" * @param sigAlg name of the signature algorithm, e.g. "MD5WithRSA", - * "MD2WithRSA", "SHAwithDSA". + * "MD2WithRSA", "SHAwithDSA". If set to null, a default + * algorithm matching the private key will be chosen after + * the first keypair is generated. * @param providerName name of the provider * @exception NoSuchAlgorithmException on unrecognized algorithms. * @exception NoSuchProviderException on unrecognized providers. @@ -161,8 +165,16 @@ public final class CertAndKeyGen { throw new IllegalArgumentException("Public key format is " + publicKey.getFormat() + ", must be X.509"); } - } + if (sigAlg == null) { + sigAlg = AlgorithmId.getDefaultSigAlgForKey(privateKey); + if (sigAlg == null) { + throw new IllegalArgumentException( + "Cannot derive signature algorithm from " + + privateKey.getAlgorithm()); + } + } + } /** * Returns the public key of the generated key pair if it is of type diff --git a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java index 94969b84196..3a3d5cfe91d 100644 --- a/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java +++ b/jdk/src/java.base/share/classes/sun/security/tools/keytool/Main.java @@ -54,7 +54,6 @@ import java.text.MessageFormat; import java.util.*; import java.util.jar.JarEntry; import java.util.jar.JarFile; -import java.lang.reflect.Constructor; import java.math.BigInteger; import java.net.URI; import java.net.URL; @@ -1238,7 +1237,7 @@ public final class Main { PrivateKey privateKey = (PrivateKey)recoverKey(alias, storePass, keyPass).fst; if (sigAlgName == null) { - sigAlgName = getCompatibleSigAlgName(privateKey.getAlgorithm()); + sigAlgName = getCompatibleSigAlgName(privateKey); } Signature signature = Signature.getInstance(sigAlgName); signature.initSign(privateKey); @@ -1328,7 +1327,7 @@ public final class Main { PrivateKey privateKey = (PrivateKey)recoverKey(alias, storePass, keyPass).fst; if (sigAlgName == null) { - sigAlgName = getCompatibleSigAlgName(privateKey.getAlgorithm()); + sigAlgName = getCompatibleSigAlgName(privateKey); } X509CRLEntry[] badCerts = new X509CRLEntry[ids.size()]; @@ -1387,7 +1386,7 @@ public final class Main { // Construct a Signature object, so that we can sign the request if (sigAlgName == null) { - sigAlgName = getCompatibleSigAlgName(privKey.getAlgorithm()); + sigAlgName = getCompatibleSigAlgName(privKey); } Signature signature = Signature.getInstance(sigAlgName); @@ -1619,19 +1618,17 @@ public final class Main { * If no signature algorithm was specified at the command line, * we choose one that is compatible with the selected private key */ - private static String getCompatibleSigAlgName(String keyAlgName) + private static String getCompatibleSigAlgName(PrivateKey key) throws Exception { - if ("DSA".equalsIgnoreCase(keyAlgName)) { - return "SHA256WithDSA"; - } else if ("RSA".equalsIgnoreCase(keyAlgName)) { - return "SHA256WithRSA"; - } else if ("EC".equalsIgnoreCase(keyAlgName)) { - return "SHA256withECDSA"; + String result = AlgorithmId.getDefaultSigAlgForKey(key); + if (result != null) { + return result; } else { throw new Exception(rb.getString ("Cannot.derive.signature.algorithm")); } } + /** * Creates a new key pair and self-signed certificate. */ @@ -1658,9 +1655,6 @@ public final class Main { throw new Exception(form.format(source)); } - if (sigAlgName == null) { - sigAlgName = getCompatibleSigAlgName(keyAlgName); - } CertAndKeyGen keypair = new CertAndKeyGen(keyAlgName, sigAlgName, providerName); @@ -2526,7 +2520,7 @@ public final class Main { // Determine the signature algorithm if (sigAlgName == null) { - sigAlgName = getCompatibleSigAlgName(privKey.getAlgorithm()); + sigAlgName = getCompatibleSigAlgName(privKey); } // Get the old certificate diff --git a/jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java b/jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java new file mode 100644 index 00000000000..ad6297f2b21 --- /dev/null +++ b/jdk/test/sun/security/tools/keytool/DefaultSignatureAlgorithm.java @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8138766 + * @summary New default -sigalg for keytool + * @modules java.base/sun.security.tools.keytool + */ + +import sun.security.tools.keytool.Main; + +import java.io.File; +import java.security.KeyStore; +import java.security.cert.X509Certificate; + +public class DefaultSignatureAlgorithm { + + private static int counter = 0; + + public static void main(String[] args) throws Exception { + + // Calculating large RSA keys are too slow. + run("RSA", 1024, null, "SHA256withRSA"); + run("RSA", 3072, null, "SHA256withRSA"); + run("RSA", 3073, null, "SHA384withRSA"); + + run("DSA", 1024, null, "SHA256withDSA"); + run("DSA", 3072, null, "SHA256withDSA"); + + run("EC", 192, null, "SHA256withECDSA"); + run("EC", 384, null, "SHA384withECDSA"); + run("EC", 571, null, "SHA512withECDSA"); + + // If you specify one, it will be used. + run("EC", 571, "SHA256withECDSA", "SHA256withECDSA"); + } + + private static void run(String keyAlg, int keySize, + String sigAlg, String expectedSigAlg) throws Exception { + String alias = keyAlg + keySize + (counter++); + String cmd = "-keystore ks -storepass changeit" + + " -keypass changeit -alias " + alias + + " -keyalg " + keyAlg + " -keysize " + keySize + + " -genkeypair -dname CN=" + alias + " -debug"; + if (sigAlg != null) { + cmd += " -sigalg " + sigAlg; + } + Main.main(cmd.split(" ")); + + KeyStore ks = KeyStore.getInstance( + new File("ks"), "changeit".toCharArray()); + X509Certificate cert = (X509Certificate)ks.getCertificate(alias); + String actualSigAlg = cert.getSigAlgName(); + if (!actualSigAlg.equals(expectedSigAlg)) { + throw new Exception("Failure at " + alias + ": expected " + + expectedSigAlg + ", actually " + actualSigAlg); + } + } +} -- GitLab From 93f4f6c1b50c17bf713a2cfa806e64a8d73d6770 Mon Sep 17 00:00:00 2001 From: Nishit Jain Date: Fri, 20 May 2016 13:48:58 +0900 Subject: [PATCH 100/400] 7102969: currency.properties supercede not working correctly 8149452: j.t.SimpleDateFormat.getDateFormatSymbols().getZoneStrings() returns incorrect result for some time zones 8157138: Error while fetching currency instance by Currency.getInstance(currencycode) Reviewed-by: naoto, okutsu, peytoia --- .../data/currency/CurrencyData.properties | 5 +- .../tools/cldrconverter/CLDRConverter.java | 6 +- .../GenerateCurrencyData.java | 49 +-- .../share/classes/java/util/Currency.java | 320 +++++++++++++----- .../java/util/Currency/PropertiesTest.java | 76 ++++- jdk/test/java/util/Currency/PropertiesTest.sh | 13 +- .../java/util/Currency/currency.properties | 2 +- jdk/test/java/util/Currency/tablea1.txt | 2 +- jdk/test/java/util/TimeZone/Bug8149452.java | 58 ++++ 9 files changed, 420 insertions(+), 111 deletions(-) create mode 100644 jdk/test/java/util/TimeZone/Bug8149452.java diff --git a/jdk/make/data/currency/CurrencyData.properties b/jdk/make/data/currency/CurrencyData.properties index 808d01d6958..0288b04390b 100644 --- a/jdk/make/data/currency/CurrencyData.properties +++ b/jdk/make/data/currency/CurrencyData.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,8 @@ # Version of the currency data format. # 1: initial # 2: Change in minor unit (allowing 4-9 digits) -formatVersion=2 +# 3: Change in the order of special case and other currency entries +formatVersion=3 # Version of the currency code information in this class. # It is a serial number that accompanies with each amendment. diff --git a/jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java b/jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java index f15834202b0..b72ac9225b1 100644 --- a/jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java +++ b/jdk/make/src/classes/build/tools/cldrconverter/CLDRConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -584,7 +584,9 @@ public class CLDRConverter { String[] data = (String[])e[1]; if (map.get(TIMEZONE_ID_PREFIX + tzid) == null && - handlerMetaZones.get(tzid) == null) { + handlerMetaZones.get(tzid) == null || + handlerMetaZones.get(tzid) != null && + map.get(METAZONE_ID_PREFIX + handlerMetaZones.get(tzid)) == null) { // First, check the CLDR meta key Optional> cldrMeta = handlerMetaZones.getData().entrySet().stream() diff --git a/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java b/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java index cc125638c96..ae861c5abe5 100644 --- a/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java +++ b/jdk/make/src/classes/build/tools/generatecurrencydata/GenerateCurrencyData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -121,7 +121,7 @@ public class GenerateCurrencyData { private static final int maxOtherCurrencies = 128; private static int otherCurrenciesCount = 0; - private static StringBuffer otherCurrencies = new StringBuffer(); + private static String[] otherCurrencies = new String[maxOtherCurrencies]; private static int[] otherCurrenciesDefaultFractionDigits = new int[maxOtherCurrencies]; private static int[] otherCurrenciesNumericCode= new int[maxOtherCurrencies]; @@ -318,10 +318,7 @@ public class GenerateCurrencyData { if (otherCurrenciesCount == maxOtherCurrencies) { throw new RuntimeException("too many other currencies"); } - if (otherCurrencies.length() > 0) { - otherCurrencies.append('-'); - } - otherCurrencies.append(currencyCode); + otherCurrencies[otherCurrenciesCount] = currencyCode; otherCurrenciesDefaultFractionDigits[otherCurrenciesCount] = getDefaultFractionDigits(currencyCode); otherCurrenciesNumericCode[otherCurrenciesCount] = getNumericCode(currencyCode); otherCurrenciesCount++; @@ -350,35 +347,41 @@ public class GenerateCurrencyData { out.writeInt(Integer.parseInt(dataVersion)); writeIntArray(mainTable, mainTable.length); out.writeInt(specialCaseCount); - writeLongArray(specialCaseCutOverTimes, specialCaseCount); - writeStringArray(specialCaseOldCurrencies, specialCaseCount); - writeStringArray(specialCaseNewCurrencies, specialCaseCount); - writeIntArray(specialCaseOldCurrenciesDefaultFractionDigits, specialCaseCount); - writeIntArray(specialCaseNewCurrenciesDefaultFractionDigits, specialCaseCount); - writeIntArray(specialCaseOldCurrenciesNumericCode, specialCaseCount); - writeIntArray(specialCaseNewCurrenciesNumericCode, specialCaseCount); + writeSpecialCaseEntries(); out.writeInt(otherCurrenciesCount); - out.writeUTF(otherCurrencies.toString()); - writeIntArray(otherCurrenciesDefaultFractionDigits, otherCurrenciesCount); - writeIntArray(otherCurrenciesNumericCode, otherCurrenciesCount); + writeOtherCurrencies(); } private static void writeIntArray(int[] ia, int count) throws IOException { - for (int i = 0; i < count; i ++) { + for (int i = 0; i < count; i++) { out.writeInt(ia[i]); } } - private static void writeLongArray(long[] la, int count) throws IOException { - for (int i = 0; i < count; i ++) { - out.writeLong(la[i]); + private static void writeSpecialCaseEntries() throws IOException { + for (int index = 0; index < specialCaseCount; index++) { + out.writeLong(specialCaseCutOverTimes[index]); + String str = (specialCaseOldCurrencies[index] != null) + ? specialCaseOldCurrencies[index] : ""; + out.writeUTF(str); + str = (specialCaseNewCurrencies[index] != null) + ? specialCaseNewCurrencies[index] : ""; + out.writeUTF(str); + out.writeInt(specialCaseOldCurrenciesDefaultFractionDigits[index]); + out.writeInt(specialCaseNewCurrenciesDefaultFractionDigits[index]); + out.writeInt(specialCaseOldCurrenciesNumericCode[index]); + out.writeInt(specialCaseNewCurrenciesNumericCode[index]); } } - private static void writeStringArray(String[] sa, int count) throws IOException { - for (int i = 0; i < count; i ++) { - String str = (sa[i] != null) ? sa[i] : ""; + private static void writeOtherCurrencies() throws IOException { + for (int index = 0; index < otherCurrenciesCount; index++) { + String str = (otherCurrencies[index] != null) + ? otherCurrencies[index] : ""; out.writeUTF(str); + out.writeInt(otherCurrenciesDefaultFractionDigits[index]); + out.writeInt(otherCurrenciesNumericCode[index]); } } + } diff --git a/jdk/src/java.base/share/classes/java/util/Currency.java b/jdk/src/java.base/share/classes/java/util/Currency.java index cea4cdc4f3c..6c9bbb62654 100644 --- a/jdk/src/java.base/share/classes/java/util/Currency.java +++ b/jdk/src/java.base/share/classes/java/util/Currency.java @@ -153,33 +153,13 @@ public final class Currency implements Serializable { // - bits 0-4: final char for currency code for simple country, or ID of special case // - special case IDs: // - 0: country has no currency - // - other: index into sc* arrays + 1 - // - scCutOverTimes: cut-over time in millis as returned by - // System.currentTimeMillis for special case countries that are changing - // currencies; Long.MAX_VALUE for countries that are not changing currencies - // - scOldCurrencies: old currencies for special case countries - // - scNewCurrencies: new currencies for special case countries that are - // changing currencies; null for others - // - scOldCurrenciesDFD: default fraction digits for old currencies - // - scNewCurrenciesDFD: default fraction digits for new currencies, 0 for - // countries that are not changing currencies - // - otherCurrencies: concatenation of all currency codes that are not the - // main currency of a simple country, separated by "-" - // - otherCurrenciesDFD: decimal format digits for currencies in otherCurrencies, same order + // - other: index into specialCasesList static int formatVersion; static int dataVersion; static int[] mainTable; - static long[] scCutOverTimes; - static String[] scOldCurrencies; - static String[] scNewCurrencies; - static int[] scOldCurrenciesDFD; - static int[] scNewCurrenciesDFD; - static int[] scOldCurrenciesNumericCode; - static int[] scNewCurrenciesNumericCode; - static String otherCurrencies; - static int[] otherCurrenciesDFD; - static int[] otherCurrenciesNumericCode; + static List specialCasesList; + static List otherCurrenciesList; // handy constants - must match definitions in GenerateCurrencyData // magic number @@ -214,7 +194,7 @@ public final class Currency implements Serializable { private static final int NUMERIC_CODE_SHIFT = 10; // Currency data format version - private static final int VALID_FORMAT_VERSION = 2; + private static final int VALID_FORMAT_VERSION = 3; static { AccessController.doPrivileged(new PrivilegedAction<>() { @@ -236,17 +216,9 @@ public final class Currency implements Serializable { dataVersion = dis.readInt(); mainTable = readIntArray(dis, A_TO_Z * A_TO_Z); int scCount = dis.readInt(); - scCutOverTimes = readLongArray(dis, scCount); - scOldCurrencies = readStringArray(dis, scCount); - scNewCurrencies = readStringArray(dis, scCount); - scOldCurrenciesDFD = readIntArray(dis, scCount); - scNewCurrenciesDFD = readIntArray(dis, scCount); - scOldCurrenciesNumericCode = readIntArray(dis, scCount); - scNewCurrenciesNumericCode = readIntArray(dis, scCount); + specialCasesList = readSpecialCases(dis, scCount); int ocCount = dis.readInt(); - otherCurrencies = dis.readUTF(); - otherCurrenciesDFD = readIntArray(dis, ocCount); - otherCurrenciesNumericCode = readIntArray(dis, ocCount); + otherCurrenciesList = readOtherCurrencies(dis, ocCount); } } catch (IOException e) { throw new InternalError(e); @@ -329,6 +301,7 @@ public final class Currency implements Serializable { // Currency code not internally generated, need to verify first // A currency code must have 3 characters and exist in the main table // or in the list of other currencies. + boolean found = false; if (currencyCode.length() != 3) { throw new IllegalArgumentException(); } @@ -340,17 +313,23 @@ public final class Currency implements Serializable { && currencyCode.charAt(2) - 'A' == (tableEntry & SIMPLE_CASE_COUNTRY_FINAL_CHAR_MASK)) { defaultFractionDigits = (tableEntry & SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_MASK) >> SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT; numericCode = (tableEntry & NUMERIC_CODE_MASK) >> NUMERIC_CODE_SHIFT; - } else { - // Check for '-' separately so we don't get false hits in the table. - if (currencyCode.charAt(2) == '-') { - throw new IllegalArgumentException(); + found = true; + } else { //special case + int[] fractionAndNumericCode = SpecialCaseEntry.findEntry(currencyCode); + if (fractionAndNumericCode != null) { + defaultFractionDigits = fractionAndNumericCode[0]; + numericCode = fractionAndNumericCode[1]; + found = true; } - int index = otherCurrencies.indexOf(currencyCode); - if (index == -1) { + } + + if (!found) { + OtherCurrencyEntry ocEntry = OtherCurrencyEntry.findEntry(currencyCode); + if (ocEntry == null) { throw new IllegalArgumentException(); } - defaultFractionDigits = otherCurrenciesDFD[index / 4]; - numericCode = otherCurrenciesNumericCode[index / 4]; + defaultFractionDigits = ocEntry.fraction; + numericCode = ocEntry.numericCode; } } @@ -410,13 +389,17 @@ public final class Currency implements Serializable { if (tableEntry == COUNTRY_WITHOUT_CURRENCY_ENTRY) { return null; } else { - int index = (tableEntry & SPECIAL_CASE_COUNTRY_INDEX_MASK) - SPECIAL_CASE_COUNTRY_INDEX_DELTA; - if (scCutOverTimes[index] == Long.MAX_VALUE || System.currentTimeMillis() < scCutOverTimes[index]) { - return getInstance(scOldCurrencies[index], scOldCurrenciesDFD[index], - scOldCurrenciesNumericCode[index]); + int index = SpecialCaseEntry.toIndex(tableEntry); + SpecialCaseEntry scEntry = specialCasesList.get(index); + if (scEntry.cutOverTime == Long.MAX_VALUE + || System.currentTimeMillis() < scEntry.cutOverTime) { + return getInstance(scEntry.oldCurrency, + scEntry.oldCurrencyFraction, + scEntry.oldCurrencyNumericCode); } else { - return getInstance(scNewCurrencies[index], scNewCurrenciesDFD[index], - scNewCurrenciesNumericCode[index]); + return getInstance(scEntry.newCurrency, + scEntry.newCurrencyFraction, + scEntry.newCurrencyNumericCode); } } } @@ -451,14 +434,29 @@ public final class Currency implements Serializable { sb.append(c2); sb.append(finalChar); available.add(getInstance(sb.toString(), defaultFractionDigits, numericCode)); + } else if ((tableEntry & COUNTRY_TYPE_MASK) == SPECIAL_CASE_COUNTRY_MASK + && tableEntry != INVALID_COUNTRY_ENTRY + && tableEntry != COUNTRY_WITHOUT_CURRENCY_ENTRY) { + int index = SpecialCaseEntry.toIndex(tableEntry); + SpecialCaseEntry scEntry = specialCasesList.get(index); + + if (scEntry.cutOverTime == Long.MAX_VALUE + || System.currentTimeMillis() < scEntry.cutOverTime) { + available.add(getInstance(scEntry.oldCurrency, + scEntry.oldCurrencyFraction, + scEntry.oldCurrencyNumericCode)); + } else { + available.add(getInstance(scEntry.newCurrency, + scEntry.newCurrencyFraction, + scEntry.newCurrencyNumericCode)); + } } } } // Now add other currencies - StringTokenizer st = new StringTokenizer(otherCurrencies, "-"); - while (st.hasMoreElements()) { - available.add(getInstance((String)st.nextElement())); + for (OtherCurrencyEntry entry : otherCurrenciesList) { + available.add(getInstance(entry.currencyCode)); } } } @@ -521,15 +519,15 @@ public final class Currency implements Serializable { } /** - * Gets the default number of fraction digits used with this currency. - * Note that the number of fraction digits is the same as ISO 4217's - * minor unit for the currency. - * For example, the default number of fraction digits for the Euro is 2, - * while for the Japanese Yen it's 0. - * In the case of pseudo-currencies, such as IMF Special Drawing Rights, - * -1 is returned. - * - * @return the default number of fraction digits used with this currency + * Gets the default number of fraction digits used with this currency. + * Note that the number of fraction digits is the same as ISO 4217's + * minor unit for the currency. + * For example, the default number of fraction digits for the Euro is 2, + * while for the Japanese Yen it's 0. + * In the case of pseudo-currencies, such as IMF Special Drawing Rights, + * -1 is returned. + * + * @return the default number of fraction digits used with this currency */ public int getDefaultFractionDigits() { return defaultFractionDigits; @@ -693,22 +691,55 @@ public final class Currency implements Serializable { return ret; } - private static long[] readLongArray(DataInputStream dis, int count) throws IOException { - long[] ret = new long[count]; + private static List readSpecialCases(DataInputStream dis, + int count) + throws IOException { + + List list = new ArrayList<>(count); + long cutOverTime; + String oldCurrency; + String newCurrency; + int oldCurrencyFraction; + int newCurrencyFraction; + int oldCurrencyNumericCode; + int newCurrencyNumericCode; + for (int i = 0; i < count; i++) { - ret[i] = dis.readLong(); + cutOverTime = dis.readLong(); + oldCurrency = dis.readUTF(); + newCurrency = dis.readUTF(); + oldCurrencyFraction = dis.readInt(); + newCurrencyFraction = dis.readInt(); + oldCurrencyNumericCode = dis.readInt(); + newCurrencyNumericCode = dis.readInt(); + SpecialCaseEntry sc = new SpecialCaseEntry(cutOverTime, + oldCurrency, newCurrency, + oldCurrencyFraction, newCurrencyFraction, + oldCurrencyNumericCode, newCurrencyNumericCode); + list.add(sc); } - - return ret; + return list; } - private static String[] readStringArray(DataInputStream dis, int count) throws IOException { - String[] ret = new String[count]; + private static List readOtherCurrencies(DataInputStream dis, + int count) + throws IOException { + + List list = new ArrayList<>(count); + String currencyCode; + int fraction; + int numericCode; + for (int i = 0; i < count; i++) { - ret[i] = dis.readUTF(); + currencyCode = dis.readUTF(); + fraction = dis.readInt(); + numericCode = dis.readInt(); + OtherCurrencyEntry oc = new OtherCurrencyEntry(currencyCode, + fraction, + numericCode); + list.add(oc); } - - return ret; + return list; } /** @@ -766,21 +797,27 @@ public final class Currency implements Serializable { return; } - int index; - for (index = 0; index < scOldCurrencies.length; index++) { - if (scOldCurrencies[index].equals(code)) { - break; - } + int index = SpecialCaseEntry.indexOf(code, fraction, numeric); + + /* if a country switches from simple case to special case or + * one special case to other special case which is not present + * in the sc arrays then insert the new entry in special case arrays + */ + if (index == -1 && (ctry.charAt(0) != code.charAt(0) + || ctry.charAt(1) != code.charAt(1))) { + + specialCasesList.add(new SpecialCaseEntry(code, fraction, numeric)); + index = specialCasesList.size() - 1; } - if (index == scOldCurrencies.length) { + if (index == -1) { // simple case - entry |= (fraction << SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT) | - (code.charAt(2) - 'A'); + entry |= (fraction << SIMPLE_CASE_COUNTRY_DEFAULT_DIGITS_SHIFT) + | (code.charAt(2) - 'A'); } else { // special case - entry |= SPECIAL_CASE_COUNTRY_MASK | - (index + SPECIAL_CASE_COUNTRY_INDEX_DELTA); + entry = SPECIAL_CASE_COUNTRY_MASK + | (index + SPECIAL_CASE_COUNTRY_INDEX_DELTA); } setMainTableEntry(ctry.charAt(0), ctry.charAt(1), entry); } @@ -814,5 +851,128 @@ public final class Currency implements Serializable { } } } + + /* Used to represent a special case currency entry + * - cutOverTime: cut-over time in millis as returned by + * System.currentTimeMillis for special case countries that are changing + * currencies; Long.MAX_VALUE for countries that are not changing currencies + * - oldCurrency: old currencies for special case countries + * - newCurrency: new currencies for special case countries that are + * changing currencies; null for others + * - oldCurrencyFraction: default fraction digits for old currencies + * - newCurrencyFraction: default fraction digits for new currencies, 0 for + * countries that are not changing currencies + * - oldCurrencyNumericCode: numeric code for old currencies + * - newCurrencyNumericCode: numeric code for new currencies, 0 for countries + * that are not changing currencies + */ + private static class SpecialCaseEntry { + + final private long cutOverTime; + final private String oldCurrency; + final private String newCurrency; + final private int oldCurrencyFraction; + final private int newCurrencyFraction; + final private int oldCurrencyNumericCode; + final private int newCurrencyNumericCode; + + private SpecialCaseEntry(long cutOverTime, String oldCurrency, String newCurrency, + int oldCurrencyFraction, int newCurrencyFraction, + int oldCurrencyNumericCode, int newCurrencyNumericCode) { + this.cutOverTime = cutOverTime; + this.oldCurrency = oldCurrency; + this.newCurrency = newCurrency; + this.oldCurrencyFraction = oldCurrencyFraction; + this.newCurrencyFraction = newCurrencyFraction; + this.oldCurrencyNumericCode = oldCurrencyNumericCode; + this.newCurrencyNumericCode = newCurrencyNumericCode; + } + + private SpecialCaseEntry(String currencyCode, int fraction, + int numericCode) { + this(Long.MAX_VALUE, currencyCode, "", fraction, 0, numericCode, 0); + } + + //get the index of the special case entry + private static int indexOf(String code, int fraction, int numeric) { + int size = specialCasesList.size(); + for (int index = 0; index < size; index++) { + SpecialCaseEntry scEntry = specialCasesList.get(index); + if (scEntry.oldCurrency.equals(code) + && scEntry.oldCurrencyFraction == fraction + && scEntry.oldCurrencyNumericCode == numeric + && scEntry.cutOverTime == Long.MAX_VALUE) { + return index; + } + } + return -1; + } + + // get the fraction and numericCode of the sc currencycode + private static int[] findEntry(String code) { + int[] fractionAndNumericCode = null; + int size = specialCasesList.size(); + for (int index = 0; index < size; index++) { + SpecialCaseEntry scEntry = specialCasesList.get(index); + if (scEntry.oldCurrency.equals(code) && (scEntry.cutOverTime == Long.MAX_VALUE + || System.currentTimeMillis() < scEntry.cutOverTime)) { + //consider only when there is no new currency or cutover time is not passed + fractionAndNumericCode = new int[2]; + fractionAndNumericCode[0] = scEntry.oldCurrencyFraction; + fractionAndNumericCode[1] = scEntry.oldCurrencyNumericCode; + break; + } else if (scEntry.newCurrency.equals(code) + && System.currentTimeMillis() >= scEntry.cutOverTime) { + //consider only if the cutover time is passed + fractionAndNumericCode = new int[2]; + fractionAndNumericCode[0] = scEntry.newCurrencyFraction; + fractionAndNumericCode[1] = scEntry.newCurrencyNumericCode; + break; + } + } + return fractionAndNumericCode; + } + + // convert the special case entry to sc arrays index + private static int toIndex(int tableEntry) { + return (tableEntry & SPECIAL_CASE_COUNTRY_INDEX_MASK) - SPECIAL_CASE_COUNTRY_INDEX_DELTA; + } + + } + + /* Used to represent Other currencies + * - currencyCode: currency codes that are not the main currency + * of a simple country + * - otherCurrenciesDFD: decimal format digits for other currencies + * - otherCurrenciesNumericCode: numeric code for other currencies + */ + private static class OtherCurrencyEntry { + + final private String currencyCode; + final private int fraction; + final private int numericCode; + + private OtherCurrencyEntry(String currencyCode, int fraction, + int numericCode) { + this.currencyCode = currencyCode; + this.fraction = fraction; + this.numericCode = numericCode; + } + + //get the instance of the other currency code + private static OtherCurrencyEntry findEntry(String code) { + int size = otherCurrenciesList.size(); + for (int index = 0; index < size; index++) { + OtherCurrencyEntry ocEntry = otherCurrenciesList.get(index); + if (ocEntry.currencyCode.equalsIgnoreCase(code)) { + return ocEntry; + } + } + return null; + } + + } + } + diff --git a/jdk/test/java/util/Currency/PropertiesTest.java b/jdk/test/java/util/Currency/PropertiesTest.java index 96127bf19fe..fe35f2e6161 100644 --- a/jdk/test/java/util/Currency/PropertiesTest.java +++ b/jdk/test/java/util/Currency/PropertiesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ import java.io.*; import java.text.*; import java.util.*; import java.util.regex.*; +import java.util.stream.Collectors; public class PropertiesTest { public static void main(String[] args) throws Exception { @@ -32,9 +33,14 @@ public class PropertiesTest { dump(args[1]); } else if (args.length == 4 && args[0].equals("-c")) { compare(args[1], args[2], args[3]); + } else if (args.length == 1 && args[0].equals("bug7102969")) { + bug7102969(); + } else if (args.length == 1 && args[0].equals("bug8157138")) { + bug8157138(); } else { System.err.println("Usage: java PropertiesTest -d "); System.err.println(" java PropertiesTest -c "); + System.err.println(" java PropertiesTest bug[JBS bug id number] e.g. bug7102969"); System.exit(-1); } } @@ -174,6 +180,74 @@ public class PropertiesTest { } } + private static void bug7102969() { + + // check the correct overriding of special case entries + Currency cur = Currency.getInstance(new Locale("", "JP")); + if (!cur.getCurrencyCode().equals("ABC")) { + throw new RuntimeException("[Expected: ABC as currency code of JP, found: " + + cur.getCurrencyCode() + "]"); + } + + /* check if the currency instance is returned by + * getAvailableCurrencies() method + */ + if (!Currency.getAvailableCurrencies().contains(cur)) { + throw new RuntimeException("[The Currency instance [" + + cur.getCurrencyCode() + ", " + + cur.getNumericCode() + ", " + + cur.getDefaultFractionDigits() + + "] is not available in the currencies list]"); + } + + } + + private static void bug8157138() { + + /* check the currencies which exist only as a special case are + * accessible i.e. it should not throw IllegalArgumentException + */ + try { + Currency.getInstance("MAD"); + } catch (IllegalArgumentException ex) { + throw new RuntimeException("Test Failed: " + + "special case currency instance MAD not found" + + " via Currency.getInstance(\"MAD\")"); + } + + try { + Currency.getInstance("ABC"); + } catch (IllegalArgumentException ex) { + throw new RuntimeException("Test Failed: " + + "special case currency instance ABC not found" + + " via Currency.getInstance(\"ABC\")"); + } + + /* check the currency value is returned by getAvailableCurrencies() + * method + */ + List list = Currency.getAvailableCurrencies().stream() + .filter(cur -> cur.getCurrencyCode().equals("MAD")) + .collect(Collectors.toList()); + + if (list.isEmpty()) { + throw new RuntimeException("Test Failed: " + + "special case currency instance MAD not found" + + " in Currency.getAvailableCurrencies() list"); + } + + list = Currency.getAvailableCurrencies().stream() + .filter(cur -> cur.getCurrencyCode().equals("ABC")) + .collect(Collectors.toList()); + + if (list.isEmpty()) { + throw new RuntimeException("Test Failed: " + + "special case currency instance ABC not found" + + " in Currency.getAvailableCurrencies() list"); + } + + } + private static boolean isPastCutoverDate(String s) throws IndexOutOfBoundsException, NullPointerException, ParseException { String dateString = s.substring(s.lastIndexOf(',')+1, s.length()).trim(); diff --git a/jdk/test/java/util/Currency/PropertiesTest.sh b/jdk/test/java/util/Currency/PropertiesTest.sh index a6f8a76d189..215be9229ae 100644 --- a/jdk/test/java/util/Currency/PropertiesTest.sh +++ b/jdk/test/java/util/Currency/PropertiesTest.sh @@ -23,7 +23,8 @@ # # @test -# @bug 6332666 6863624 7180362 8003846 8074350 8074351 8130246 8149735 +# @bug 6332666 6863624 7180362 8003846 8074350 8074351 8130246 8149735 7102969 +# 8157138 # @summary tests the capability of replacing the currency data with user # specified currency properties file # @build PropertiesTest @@ -113,6 +114,16 @@ ${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} PropertiesTest if [ $? != 0 ]; then failures=`expr $failures + 1`; fi if [ ! -f dump3 ]; then echo "file dump3 not created. Test cannot execute. Failed."; exit 1; fi +# run bug7102969 test +echo '' +${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} PropertiesTest bug7102969 +if [ $? != 0 ]; then failures=`expr $failures + 1`; fi + +# run bug8157138 test +echo '' +${WRITABLEJDK}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTCLASSES} PropertiesTest bug8157138 +if [ $? != 0 ]; then failures=`expr $failures + 1`; fi + # Cleanup rm -rf $WRITABLEJDK diff --git a/jdk/test/java/util/Currency/currency.properties b/jdk/test/java/util/Currency/currency.properties index d8e874d819a..57b293542b8 100644 --- a/jdk/test/java/util/Currency/currency.properties +++ b/jdk/test/java/util/Currency/currency.properties @@ -6,7 +6,7 @@ CL=CLF,990,4 CM=IED,111,2, 2004-01-01T00:70:00 ES=ESD,877,2 -JP=JPZ,123,2 +JP=ABC,999,0 MA=MAA,555,5 MC=MCC,555,6 MD=MDD,555,7 diff --git a/jdk/test/java/util/Currency/tablea1.txt b/jdk/test/java/util/Currency/tablea1.txt index 92e43adf2be..dacc0fb5210 100644 --- a/jdk/test/java/util/Currency/tablea1.txt +++ b/jdk/test/java/util/Currency/tablea1.txt @@ -5,7 +5,7 @@ # # Version -FILEVERSION=2 +FILEVERSION=3 DATAVERSION=160 # ISO 4217 currency data diff --git a/jdk/test/java/util/TimeZone/Bug8149452.java b/jdk/test/java/util/TimeZone/Bug8149452.java new file mode 100644 index 00000000000..eb4c0bced15 --- /dev/null +++ b/jdk/test/java/util/TimeZone/Bug8149452.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8149452 + * @summary Check the missing time zone names. + */ +import java.text.DateFormatSymbols; +import java.util.ArrayList; +import java.util.TimeZone; +import java.util.Arrays; +import java.util.List; + +public class Bug8149452 { + + public static void main(String[] args) { + + List listNotFound = new ArrayList<>(); + String[][] zoneStrings = DateFormatSymbols.getInstance() + .getZoneStrings(); + for (String tzID : TimeZone.getAvailableIDs()) { + if (!Arrays.stream(zoneStrings) + .anyMatch(zone -> tzID.equalsIgnoreCase(zone[0]))) { + // to ignore names for Etc/GMT[+-][0-9]+ which are not supported + if (!tzID.startsWith("Etc/GMT") && !tzID.startsWith("GMT")) { + listNotFound.add(tzID); + } + } + } + + if (!listNotFound.isEmpty()) { + throw new RuntimeException("Test Failed: Time Zone Strings for " + + listNotFound + " not found"); + } + + } + +} -- GitLab From e9883313311666c9f00d047aead7c4a720840274 Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Thu, 19 May 2016 21:59:35 -0700 Subject: [PATCH 101/400] 8156478: 3 Buffer overrun defect groups in jexec.c Reviewed-by: ksrini --- jdk/src/java.base/unix/native/launcher/jexec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/src/java.base/unix/native/launcher/jexec.c b/jdk/src/java.base/unix/native/launcher/jexec.c index 179ae4f893c..d2888234674 100644 --- a/jdk/src/java.base/unix/native/launcher/jexec.c +++ b/jdk/src/java.base/unix/native/launcher/jexec.c @@ -331,6 +331,7 @@ const char * isJar(const char * path) { off_t end = start + xlen; if (end <= count) { + end -= 4; // make sure there are 4 bytes to read at start while (start < end) { off_t xhid = SH(buf, start); off_t xdlen = SH(buf, start + 2); -- GitLab From 53ef4fecbfcc3a38c9ded5211e7e3bbcfe5ba760 Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Fri, 20 May 2016 11:47:39 +0200 Subject: [PATCH 102/400] 8130023: API java.util.stream: explicitly specify guaranteed execution of the pipeline Reviewed-by: briangoetz, redestad --- .../java/util/stream/DoubleStream.java | 5 +++ .../classes/java/util/stream/IntStream.java | 5 +++ .../classes/java/util/stream/LongStream.java | 5 +++ .../classes/java/util/stream/Stream.java | 18 ++++++++++ .../java/util/stream/package-info.java | 33 ++++++++++++++----- 5 files changed, 58 insertions(+), 8 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java index 9d25d902bb4..d25aabfbc4d 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java @@ -211,6 +211,11 @@ public interface DoubleStream extends BaseStream { * .sum(); * } * + *

      In cases where stream implementation is able to optimize away the + * production of some or all the elements (such as with short-circuiting + * operations like {@code findFirst}, or in the example described in + * {@link #count}), the action will not be invoked for those elements. + * * @param action a * non-interfering action to perform on the elements as * they are consumed from the stream diff --git a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java index 115a782937f..2586de45240 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java @@ -209,6 +209,11 @@ public interface IntStream extends BaseStream { * .sum(); * } * + *

      In cases where stream implementation is able to optimize away the + * production of some or all the elements (such as with short-circuiting + * operations like {@code findFirst}, or in the example described in + * {@link #count}), the action will not be invoked for those elements. + * * @param action a * non-interfering action to perform on the elements as * they are consumed from the stream diff --git a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java index f987820c5a8..d01b79ae507 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java @@ -209,6 +209,11 @@ public interface LongStream extends BaseStream { * .sum(); * } * + *

      In cases where stream implementation is able to optimize away the + * production of some or all the elements (such as with short-circuiting + * operations like {@code findFirst}, or in the example described in + * {@link #count}), the action will not be invoked for those elements. + * * @param action a * non-interfering action to perform on the elements as * they are consumed from the stream diff --git a/jdk/src/java.base/share/classes/java/util/stream/Stream.java b/jdk/src/java.base/share/classes/java/util/stream/Stream.java index 1dd1d43f91d..ac610dd6199 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/Stream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/Stream.java @@ -82,6 +82,19 @@ import java.util.function.UnaryOperator; * terminal operation is initiated, and source elements are consumed only * as needed. * + *

      A stream implementation is permitted significant latitude in optimizing + * the computation of the result. For example, a stream implementation is free + * to elide operations (or entire stages) from a stream pipeline -- and + * therefore elide invocation of behavioral parameters -- if it can prove that + * it would not affect the result of the computation. This means that + * side-effects of behavioral parameters may not always be executed and should + * not be relied upon, unless otherwise specified (such as by the terminal + * operations {@code forEach} and {@code forEachOrdered}). (For a specific + * example of such an optimization, see the API note documented on the + * {@link #count} operation. For more detail, see the + * side-effects section of the + * strean package documentation.) + * *

      Collections and streams, while bearing some superficial similarities, * have different goals. Collections are primarily concerned with the efficient * management of, and access to, their elements. By contrast, streams do not @@ -415,6 +428,11 @@ public interface Stream extends BaseStream> { * .collect(Collectors.toList()); * } * + *

      In cases where stream implementation is able to optimize away the + * production of some or all the elements (such as with short-circuiting + * operations like {@code findFirst}, or in the example described in + * {@link #count}), the action will not be invoked for those elements. + * * @param action a * non-interfering action to perform on the elements as * they are consumed from the stream diff --git a/jdk/src/java.base/share/classes/java/util/stream/package-info.java b/jdk/src/java.base/share/classes/java/util/stream/package-info.java index 2850e21bbbd..f580d8fb372 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/package-info.java +++ b/jdk/src/java.base/share/classes/java/util/stream/package-info.java @@ -287,18 +287,35 @@ * statelessness requirement, as well as other thread-safety hazards. * *

      If the behavioral parameters do have side-effects, unless explicitly - * stated, there are no guarantees as to the - * visibility - * of those side-effects to other threads, nor are there any guarantees that - * different operations on the "same" element within the same stream pipeline - * are executed in the same thread. Further, the ordering of those effects - * may be surprising. Even when a pipeline is constrained to produce a - * result that is consistent with the encounter order of the stream - * source (for example, {@code IntStream.range(0,5).parallel().map(x -> x*2).toArray()} + * stated, there are no guarantees as to: + *

        + *
      • the + * visibility of those side-effects to other threads;
      • + *
      • that different operations on the "same" element within the same stream + * pipeline are executed in the same thread; and
      • + *
      • that behavioral parameters are always invoked, since a stream + * implementation is free to elide operations (or entire stages) from a + * stream pipeline if it can prove that it would not affect the result of the + * computation. + *
      • + *
      + *

      The ordering of side-effects may be surprising. Even when a pipeline is + * constrained to produce a result that is consistent with the + * encounter order of the stream source (for example, + * {@code IntStream.range(0,5).parallel().map(x -> x*2).toArray()} * must produce {@code [0, 2, 4, 6, 8]}), no guarantees are made as to the order * in which the mapper function is applied to individual elements, or in what * thread any behavioral parameter is executed for a given element. * + *

      The eliding of side-effects may also be surprising. With the exception of + * terminal operations {@link java.util.stream.Stream#forEach forEach} and + * {@link java.util.stream.Stream#forEachOrdered forEachOrdered}, side-effects + * of behavioral parameters may not always be executed when the stream + * implementation can optimize away the execution of behavioral parameters + * without affecting the result of the computation. (For a specific example + * see the API note documented on the {@link java.util.stream.Stream#count count} + * operation.) + * *

      Many computations where one might be tempted to use side effects can be more * safely and efficiently expressed without side-effects, such as using * reduction instead of mutable -- GitLab From 524ec2f1de43ae20591b74148b23ff13fe7eab58 Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Fri, 20 May 2016 03:33:57 -0700 Subject: [PATCH 103/400] 8157211: Mark tools/launcher/FXLauncherTest.java as intermittently failing Reviewed-by: psandoz --- jdk/test/tools/launcher/FXLauncherTest.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/tools/launcher/FXLauncherTest.java b/jdk/test/tools/launcher/FXLauncherTest.java index 0ee9d981cda..7fec8d59d36 100644 --- a/jdk/test/tools/launcher/FXLauncherTest.java +++ b/jdk/test/tools/launcher/FXLauncherTest.java @@ -29,6 +29,7 @@ * jfx app class, a main-class for the manifest, a bogus one and none. * All should execute except the incorrect fx app class entries. * @run main/othervm FXLauncherTest + * @key intermittent */ import java.io.File; import java.io.IOException; -- GitLab From 65a33061cefd9650b06d85d8c7220a2a260996eb Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Fri, 20 May 2016 14:07:21 +0200 Subject: [PATCH 104/400] 8157437: Typos in Stream JavaDoc Reviewed-by: shade, alanb, lancea --- .../share/classes/java/util/stream/AbstractTask.java | 2 +- .../share/classes/java/util/stream/DoubleStream.java | 2 +- .../java.base/share/classes/java/util/stream/IntStream.java | 2 +- .../java.base/share/classes/java/util/stream/LongStream.java | 2 +- jdk/src/java.base/share/classes/java/util/stream/Stream.java | 4 ++-- .../share/classes/java/util/stream/StreamSpliterators.java | 3 +-- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/stream/AbstractTask.java b/jdk/src/java.base/share/classes/java/util/stream/AbstractTask.java index 33de7d5c52a..f6bd8f5fc00 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/AbstractTask.java +++ b/jdk/src/java.base/share/classes/java/util/stream/AbstractTask.java @@ -106,7 +106,7 @@ abstract class AbstractTask spliterator; /** Target leaf size, common to all tasks in a computation */ - protected long targetSize; // may be laziliy initialized + protected long targetSize; // may be lazily initialized /** * The left child. diff --git a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java index d25aabfbc4d..ad250753673 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/DoubleStream.java @@ -211,7 +211,7 @@ public interface DoubleStream extends BaseStream { * .sum(); * } * - *

      In cases where stream implementation is able to optimize away the + *

      In cases where the stream implementation is able to optimize away the * production of some or all the elements (such as with short-circuiting * operations like {@code findFirst}, or in the example described in * {@link #count}), the action will not be invoked for those elements. diff --git a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java index 2586de45240..9c729772c0c 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/IntStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/IntStream.java @@ -209,7 +209,7 @@ public interface IntStream extends BaseStream { * .sum(); * } * - *

      In cases where stream implementation is able to optimize away the + *

      In cases where the stream implementation is able to optimize away the * production of some or all the elements (such as with short-circuiting * operations like {@code findFirst}, or in the example described in * {@link #count}), the action will not be invoked for those elements. diff --git a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java index d01b79ae507..7965bfd06a6 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/LongStream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/LongStream.java @@ -209,7 +209,7 @@ public interface LongStream extends BaseStream { * .sum(); * } * - *

      In cases where stream implementation is able to optimize away the + *

      In cases where the stream implementation is able to optimize away the * production of some or all the elements (such as with short-circuiting * operations like {@code findFirst}, or in the example described in * {@link #count}), the action will not be invoked for those elements. diff --git a/jdk/src/java.base/share/classes/java/util/stream/Stream.java b/jdk/src/java.base/share/classes/java/util/stream/Stream.java index ac610dd6199..7ab71a50aee 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/Stream.java +++ b/jdk/src/java.base/share/classes/java/util/stream/Stream.java @@ -93,7 +93,7 @@ import java.util.function.UnaryOperator; * example of such an optimization, see the API note documented on the * {@link #count} operation. For more detail, see the * side-effects section of the - * strean package documentation.) + * stream package documentation.) * *

      Collections and streams, while bearing some superficial similarities, * have different goals. Collections are primarily concerned with the efficient @@ -428,7 +428,7 @@ public interface Stream extends BaseStream> { * .collect(Collectors.toList()); * } * - *

      In cases where stream implementation is able to optimize away the + *

      In cases where the stream implementation is able to optimize away the * production of some or all the elements (such as with short-circuiting * operations like {@code findFirst}, or in the example described in * {@link #count}), the action will not be invoked for those elements. diff --git a/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java b/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java index cb92b2ebfad..8236255d5ef 100644 --- a/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java +++ b/jdk/src/java.base/share/classes/java/util/stream/StreamSpliterators.java @@ -28,7 +28,6 @@ import java.util.Comparator; import java.util.Objects; import java.util.Spliterator; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ForkJoinPool; import java.util.concurrent.atomic.AtomicLong; import java.util.function.BooleanSupplier; import java.util.function.Consumer; @@ -104,7 +103,7 @@ class StreamSpliterators { T_BUFFER buffer; /** - * True if full traversal has occurred (with possible cancelation). + * True if full traversal has occurred (with possible cancellation). * If doing a partial traversal, there may be still elements in buffer. */ boolean finished; -- GitLab From 3648a0f15f2c71fc871d10bd5b71d99d5737dcff Mon Sep 17 00:00:00 2001 From: Jim Laskey Date: Fri, 20 May 2016 11:41:29 -0300 Subject: [PATCH 105/400] 8156602: javac crashes again on Windows 32-bit with ClosedChannelException Reviewed-by: alanb --- .../jdk/internal/jimage/BasicImageReader.java | 32 ++++++- .../classes/sun/nio/ch/FileChannelImpl.java | 14 ++- jdk/test/TEST.groups | 3 +- .../jdk/internal/jimage/JImageOpenTest.java | 95 +++++++++++++++++++ 4 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 jdk/test/jdk/internal/jimage/JImageOpenTest.java diff --git a/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java b/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java index 9b21fb6c1be..68b076784f5 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java +++ b/jdk/src/java.base/share/classes/jdk/internal/jimage/BasicImageReader.java @@ -27,6 +27,8 @@ package jdk.internal.jimage; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; @@ -98,8 +100,34 @@ public class BasicImageReader implements AutoCloseable { } // Open the file only if no memory map yet or is 32 bit jvm - channel = map != null && MAP_ALL ? null : - FileChannel.open(imagePath, StandardOpenOption.READ); + if (map != null && MAP_ALL) { + channel = null; + } else { + channel = FileChannel.open(imagePath, StandardOpenOption.READ); + // No lambdas during bootstrap + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + if (BasicImageReader.class.getClassLoader() == null) { + try { + Class fileChannelImpl = + Class.forName("sun.nio.ch.FileChannelImpl"); + Method setUninterruptible = + fileChannelImpl.getMethod("setUninterruptible"); + setUninterruptible.invoke(channel); + } catch (ClassNotFoundException | + NoSuchMethodException | + IllegalAccessException | + InvocationTargetException ex) { + // fall thru - will only happen on JDK-8 systems where this code + // is only used by tools using jrt-fs (non-critical.) + } + } + + return null; + } + }); + } // If no memory map yet and 64 bit jvm then memory map entire file if (MAP_ALL && map == null) { diff --git a/jdk/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java b/jdk/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java index deefc8529f9..df9364a11d8 100644 --- a/jdk/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java +++ b/jdk/src/java.base/share/classes/sun/nio/ch/FileChannelImpl.java @@ -40,7 +40,6 @@ import java.nio.channels.OverlappingFileLockException; import java.nio.channels.ReadableByteChannel; import java.nio.channels.SelectableChannel; import java.nio.channels.WritableByteChannel; -import java.security.AccessController; import java.util.ArrayList; import java.util.List; @@ -83,6 +82,9 @@ public class FileChannelImpl // Lock for operations involving position and size private final Object positionLock = new Object(); + // Positional-read is not interruptible + private volatile boolean uninterruptible; + private FileChannelImpl(FileDescriptor fd, String path, boolean readable, boolean writable, Object parent) { @@ -108,6 +110,10 @@ public class FileChannelImpl throw new ClosedChannelException(); } + public void setUninterruptible() { + uninterruptible = true; + } + // -- Standard channel operations -- protected void implCloseChannel() throws IOException { @@ -733,8 +739,10 @@ public class FileChannelImpl assert !nd.needsPositionLock() || Thread.holdsLock(positionLock); int n = 0; int ti = -1; + + boolean interruptible = !uninterruptible; try { - begin(); + if (interruptible) begin(); ti = threads.add(); if (!isOpen()) return -1; @@ -744,7 +752,7 @@ public class FileChannelImpl return IOStatus.normalize(n); } finally { threads.remove(ti); - end(n > 0); + if (interruptible) end(n > 0); assert IOStatus.check(n); } } diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index 3f5461582e5..2e82e3b2585 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -76,6 +76,7 @@ jdk_lang = \ jdk/lambda \ jdk/internal/misc \ jdk/internal/ref \ + jdk/internal/jimage \ jdk/modules \ vm @@ -352,7 +353,7 @@ jdk_desktop = \ # SwingSet3 tests. jdk_client_sanity = \ sanity/client/SwingSet - + ############################################################################### # # Serviceability sanity groups diff --git a/jdk/test/jdk/internal/jimage/JImageOpenTest.java b/jdk/test/jdk/internal/jimage/JImageOpenTest.java new file mode 100644 index 00000000000..06c19937a41 --- /dev/null +++ b/jdk/test/jdk/internal/jimage/JImageOpenTest.java @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.lang.reflect.Layer; +import java.net.URI; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/* + * jimage shared open testing. + * @test + * @summary Test to see if thread interrupt handling interferes with other threads. + * @build JImageOpenTest.java + * @run main/othervm -Djdk.image.map.all=false JImageOpenTest + */ +public class JImageOpenTest { + private static final int NTHREADS = 10; + + public static void main(String[] args) throws Exception { + + final FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/")); + final Path root = fs.getPath("/modules"); + + final List names = Files.walk(root) + .filter(p -> p.getNameCount() > 2) + .filter(p -> Layer.boot().findModule(p.getName(1).toString()).isPresent()) + .map(p -> p.subpath(2, p.getNameCount())) + .map(p -> p.toString()) + .filter(s -> s.endsWith(".class") && !s.endsWith("module-info.class")) + .collect(Collectors.toList()); + + Runnable r = new Runnable() { + @Override + public void run() { + names.forEach(name -> { + String cn = name.substring(0, name.length() - 6).replace('/', '.'); + try { + Class.forName(cn, false, ClassLoader.getSystemClassLoader()); + } catch (Exception ex) { + System.err.println(Thread.currentThread() + " " + ex.getClass()); + } + }); + } + }; + + Thread[] threads = new Thread[NTHREADS]; + + for (int i = 0; i < NTHREADS; i++) { + Thread thread = new Thread(r); + threads[i] = thread; + thread.start(); + } + + Thread.sleep(1); + + for (int i = 0; i < NTHREADS; i++) { + Thread thread = threads[i]; + + if (thread.isAlive()) { + thread.interrupt(); + break; + } + } + + for (int i = 0; i < NTHREADS; i++) { + Thread thread = threads[i]; + thread.join(); + } + } +} -- GitLab From 4880e22424934702a13e39aad880af6130d77f50 Mon Sep 17 00:00:00 2001 From: Artem Smotrakov Date: Fri, 20 May 2016 09:40:29 -0700 Subject: [PATCH 106/400] 8129389: javax/net/ssl/DTLS tests fail intermittently Reviewed-by: xuelei --- .../javax/net/ssl/DTLS/DTLSOverDatagram.java | 325 +++++++++++------- jdk/test/javax/net/ssl/DTLS/Reordered.java | 13 +- .../javax/net/ssl/DTLS/Retransmission.java | 18 +- 3 files changed, 221 insertions(+), 135 deletions(-) diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSOverDatagram.java b/jdk/test/javax/net/ssl/DTLS/DTLSOverDatagram.java index 6592555706d..35f35a5c410 100644 --- a/jdk/test/javax/net/ssl/DTLS/DTLSOverDatagram.java +++ b/jdk/test/javax/net/ssl/DTLS/DTLSOverDatagram.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,8 +47,16 @@ import sun.security.util.HexDumpEncoder; * An example to show the way to use SSLEngine in datagram connections. */ public class DTLSOverDatagram { + + static { + System.setProperty("javax.net.debug", "ssl"); + } + private static int MAX_HANDSHAKE_LOOPS = 200; private static int MAX_APP_READ_LOOPS = 60; + private static int SOCKET_TIMEOUT = 10 * 1000; // in millis + private static int BUFFER_SIZE = 1024; + private static int MAXIMUM_PACKET_SIZE = 1024; /* * The following is to set up the keystores. @@ -84,37 +92,33 @@ public class DTLSOverDatagram { /* * Define the server side of the test. */ - void doServerSide() throws Exception { - DatagramSocket socket = serverDatagramSocket; - socket.setSoTimeout(10000); // 10 second + void doServerSide(DatagramSocket socket, InetSocketAddress clientSocketAddr) + throws Exception { // create SSLEngine SSLEngine engine = createSSLEngine(false); // handshaking - handshake(engine, socket, clientSocketAddr); + handshake(engine, socket, clientSocketAddr, "Server"); // read client application data receiveAppData(engine, socket, clientApp); // write server application data deliverAppData(engine, socket, serverApp, clientSocketAddr); - - socket.close(); } /* * Define the client side of the test. */ - void doClientSide() throws Exception { - DatagramSocket socket = clientDatagramSocket; - socket.setSoTimeout(1000); // 1 second read timeout + void doClientSide(DatagramSocket socket, InetSocketAddress serverSocketAddr) + throws Exception { // create SSLEngine SSLEngine engine = createSSLEngine(true); // handshaking - handshake(engine, socket, serverSocketAddr); + handshake(engine, socket, serverSocketAddr, "Client"); // write client application data deliverAppData(engine, socket, clientApp, serverSocketAddr); @@ -132,7 +136,7 @@ public class DTLSOverDatagram { SSLEngine engine = context.createSSLEngine(); SSLParameters paras = engine.getSSLParameters(); - paras.setMaximumPacketSize(1024); + paras.setMaximumPacketSize(MAXIMUM_PACKET_SIZE); engine.setUseClientMode(isClient); engine.setSSLParameters(paras); @@ -142,7 +146,7 @@ public class DTLSOverDatagram { // handshake void handshake(SSLEngine engine, DatagramSocket socket, - SocketAddress peerAddr) throws Exception { + SocketAddress peerAddr, String side) throws Exception { boolean endLoops = false; int loops = MAX_HANDSHAKE_LOOPS; @@ -159,39 +163,60 @@ public class DTLSOverDatagram { if (hs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP || hs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP_AGAIN) { + log(side, "Receive DTLS records, handshake status is " + hs); + ByteBuffer iNet; ByteBuffer iApp; if (hs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP) { - // receive ClientHello request and other SSL/TLS records - byte[] buf = new byte[1024]; + byte[] buf = new byte[BUFFER_SIZE]; DatagramPacket packet = new DatagramPacket(buf, buf.length); try { socket.receive(packet); } catch (SocketTimeoutException ste) { - List packets = - onReceiveTimeout(engine, peerAddr); + log(side, "Warning: " + ste); + + List packets = new ArrayList<>(); + boolean finished = onReceiveTimeout( + engine, peerAddr, side, packets); + for (DatagramPacket p : packets) { socket.send(p); } + if (finished) { + log(side, "Handshake status is FINISHED " + + "after calling onReceiveTimeout(), " + + "finish the loop"); + endLoops = true; + } + + log(side, "New handshake status is " + + engine.getHandshakeStatus()); + continue; } iNet = ByteBuffer.wrap(buf, 0, packet.getLength()); - iApp = ByteBuffer.allocate(1024); + iApp = ByteBuffer.allocate(BUFFER_SIZE); } else { iNet = ByteBuffer.allocate(0); - iApp = ByteBuffer.allocate(1024); + iApp = ByteBuffer.allocate(BUFFER_SIZE); } SSLEngineResult r = engine.unwrap(iNet, iApp); SSLEngineResult.Status rs = r.getStatus(); hs = r.getHandshakeStatus(); - if (rs == SSLEngineResult.Status.BUFFER_OVERFLOW) { + if (rs == SSLEngineResult.Status.OK) { + // OK + } else if (rs == SSLEngineResult.Status.BUFFER_OVERFLOW) { + log(side, "BUFFER_OVERFLOW, handshake status is " + hs); + // the client maximum fragment size config does not work? throw new Exception("Buffer overflow: " + "incorrect client maximum fragment size"); } else if (rs == SSLEngineResult.Status.BUFFER_UNDERFLOW) { + log(side, "BUFFER_UNDERFLOW, handshake status is " + hs); + // bad packet, or the client maximum fragment size // config does not work? if (hs != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { @@ -199,31 +224,64 @@ public class DTLSOverDatagram { "incorrect client maximum fragment size"); } // otherwise, ignore this packet } else if (rs == SSLEngineResult.Status.CLOSED) { - endLoops = true; - } // otherwise, SSLEngineResult.Status.OK: + throw new Exception( + "SSL engine closed, handshake status is " + hs); + } else { + throw new Exception("Can't reach here, result is " + rs); + } - if (rs != SSLEngineResult.Status.OK) { - continue; + if (hs == SSLEngineResult.HandshakeStatus.FINISHED) { + log(side, "Handshake status is FINISHED, finish the loop"); + endLoops = true; } } else if (hs == SSLEngineResult.HandshakeStatus.NEED_WRAP) { - List packets = - produceHandshakePackets(engine, peerAddr); + List packets = new ArrayList<>(); + boolean finished = produceHandshakePackets( + engine, peerAddr, side, packets); + for (DatagramPacket p : packets) { socket.send(p); } + + if (finished) { + log(side, "Handshake status is FINISHED " + + "after producing handshake packets, " + + "finish the loop"); + endLoops = true; + } } else if (hs == SSLEngineResult.HandshakeStatus.NEED_TASK) { runDelegatedTasks(engine); } else if (hs == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { - // OK, time to do application data exchange. + log(side, "Handshake status is NOT_HANDSHAKING, finish the loop"); endLoops = true; } else if (hs == SSLEngineResult.HandshakeStatus.FINISHED) { - endLoops = true; + throw new Exception( + "Unexpected status, SSLEngine.getHandshakeStatus() " + + "shouldn't return FINISHED"); + } else { + throw new Exception("Can't reach here, handshake status is " + hs); } } SSLEngineResult.HandshakeStatus hs = engine.getHandshakeStatus(); + log(side, "Handshake finished, status is " + hs); + + if (engine.getHandshakeSession() != null) { + throw new Exception( + "Handshake finished, but handshake session is not null"); + } + + SSLSession session = engine.getSession(); + if (session == null) { + throw new Exception("Handshake finished, but session is null"); + } + log(side, "Negotiated protocol is " + session.getProtocol()); + log(side, "Negotiated cipher suite is " + session.getCipherSuite()); + + // handshake status should be NOT_HANDSHAKING + // according to the spec, SSLEngine.getHandshakeStatus() can't return FINISHED if (hs != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { - throw new Exception("Not ready for application data yet"); + throw new Exception("Unexpected handshake status " + hs); } } @@ -251,11 +309,11 @@ public class DTLSOverDatagram { "Too much loops to receive application data"); } - byte[] buf = new byte[1024]; + byte[] buf = new byte[BUFFER_SIZE]; DatagramPacket packet = new DatagramPacket(buf, buf.length); socket.receive(packet); ByteBuffer netBuffer = ByteBuffer.wrap(buf, 0, packet.getLength()); - ByteBuffer recBuffer = ByteBuffer.allocate(1024); + ByteBuffer recBuffer = ByteBuffer.allocate(BUFFER_SIZE); SSLEngineResult rs = engine.unwrap(netBuffer, recBuffer); recBuffer.flip(); if (recBuffer.remaining() != 0) { @@ -270,10 +328,9 @@ public class DTLSOverDatagram { } // produce handshake packets - List produceHandshakePackets( - SSLEngine engine, SocketAddress socketAddr) throws Exception { + boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr, + String side, List packets) throws Exception { - List packets = new ArrayList<>(); boolean endLoops = false; int loops = MAX_HANDSHAKE_LOOPS; while (!endLoops && @@ -296,6 +353,8 @@ public class DTLSOverDatagram { throw new Exception("Buffer overflow: " + "incorrect server maximum fragment size"); } else if (rs == SSLEngineResult.Status.BUFFER_UNDERFLOW) { + log(side, "Produce handshake packets: BUFFER_UNDERFLOW occured"); + log(side, "Produce handshake packets: Handshake status: " + hs); // bad packet, or the client maximum fragment size // config does not work? if (hs != SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { @@ -304,7 +363,11 @@ public class DTLSOverDatagram { } // otherwise, ignore this packet } else if (rs == SSLEngineResult.Status.CLOSED) { throw new Exception("SSLEngine has closed"); - } // otherwise, SSLEngineResult.Status.OK + } else if (rs == SSLEngineResult.Status.OK) { + // OK + } else { + throw new Exception("Can't reach here, result is " + rs); + } // SSLEngineResult.Status.OK: if (oNet.hasRemaining()) { @@ -313,25 +376,39 @@ public class DTLSOverDatagram { DatagramPacket packet = createHandshakePacket(ba, socketAddr); packets.add(packet); } + + if (hs == SSLEngineResult.HandshakeStatus.FINISHED) { + log(side, "Produce handshake packets: " + + "Handshake status is FINISHED, finish the loop"); + return true; + } + boolean endInnerLoop = false; SSLEngineResult.HandshakeStatus nhs = hs; while (!endInnerLoop) { if (nhs == SSLEngineResult.HandshakeStatus.NEED_TASK) { runDelegatedTasks(engine); - nhs = engine.getHandshakeStatus(); - } else if ((nhs == SSLEngineResult.HandshakeStatus.FINISHED) || - (nhs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP) || - (nhs == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING)) { + } else if (nhs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP || + nhs == SSLEngineResult.HandshakeStatus.NEED_UNWRAP_AGAIN || + nhs == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { endInnerLoop = true; endLoops = true; } else if (nhs == SSLEngineResult.HandshakeStatus.NEED_WRAP) { endInnerLoop = true; + } else if (nhs == SSLEngineResult.HandshakeStatus.FINISHED) { + throw new Exception( + "Unexpected status, SSLEngine.getHandshakeStatus() " + + "shouldn't return FINISHED"); + } else { + throw new Exception("Can't reach here, handshake status is " + + nhs); } + nhs = engine.getHandshakeStatus(); } } - return packets; + return false; } DatagramPacket createHandshakePacket(byte[] ba, SocketAddress socketAddr) { @@ -358,7 +435,11 @@ public class DTLSOverDatagram { throw new Exception("Buffer underflow during wraping"); } else if (rs == SSLEngineResult.Status.CLOSED) { throw new Exception("SSLEngine has closed"); - } // otherwise, SSLEngineResult.Status.OK + } else if (rs == SSLEngineResult.Status.OK) { + // OK + } else { + throw new Exception("Can't reach here, result is " + rs); + } // SSLEngineResult.Status.OK: if (appNet.hasRemaining()) { @@ -386,15 +467,15 @@ public class DTLSOverDatagram { } // retransmission if timeout - List onReceiveTimeout( - SSLEngine engine, SocketAddress socketAddr) throws Exception { + boolean onReceiveTimeout(SSLEngine engine, SocketAddress socketAddr, + String side, List packets) throws Exception { SSLEngineResult.HandshakeStatus hs = engine.getHandshakeStatus(); if (hs == SSLEngineResult.HandshakeStatus.NOT_HANDSHAKING) { - return new ArrayList(); + return false; } else { // retransmission of handshake messages - return produceHandshakePackets(engine, socketAddr); + return produceHandshakePackets(engine, socketAddr, side, packets); } } @@ -405,8 +486,13 @@ public class DTLSOverDatagram { char[] passphrase = "passphrase".toCharArray(); - ks.load(new FileInputStream(keyFilename), passphrase); - ts.load(new FileInputStream(trustFilename), passphrase); + try (FileInputStream fis = new FileInputStream(keyFilename)) { + ks.load(fis, passphrase); + } + + try (FileInputStream fis = new FileInputStream(trustFilename)) { + ts.load(fis, passphrase); + } KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509"); kmf.init(ks, passphrase); @@ -427,94 +513,84 @@ public class DTLSOverDatagram { * The remainder is support stuff to kickstart the testing. */ - // the server side SocketAddress - volatile static SocketAddress serverSocketAddr = null; - - // the client side SocketAddress - volatile static SocketAddress clientSocketAddr = null; + // Will the handshaking and application data exchange succeed? + public boolean isGoodJob() { + return true; + } - // the server side DatagramSocket instance - volatile static DatagramSocket serverDatagramSocket = null; + public final void runTest(DTLSOverDatagram testCase) throws Exception { + try (DatagramSocket serverSocket = new DatagramSocket(); + DatagramSocket clientSocket = new DatagramSocket()) { - // the server side DatagramSocket instance - volatile static DatagramSocket clientDatagramSocket = null; + serverSocket.setSoTimeout(SOCKET_TIMEOUT); + clientSocket.setSoTimeout(SOCKET_TIMEOUT); - // get server side SocketAddress object - public SocketAddress getServerSocketAddress() { - return serverSocketAddr; - } + InetSocketAddress serverSocketAddr = new InetSocketAddress( + InetAddress.getLocalHost(), serverSocket.getLocalPort()); - // get client side SocketAddress object - public SocketAddress getClientSocketAddress() { - return clientSocketAddr; - } + InetSocketAddress clientSocketAddr = new InetSocketAddress( + InetAddress.getLocalHost(), clientSocket.getLocalPort()); - // get server side DatagramSocket object - public DatagramSocket getServerDatagramSocket() { - return serverDatagramSocket; - } + ExecutorService pool = Executors.newFixedThreadPool(2); + Future server, client; - // get client side DatagramSocket object - public DatagramSocket getClientDatagramSocket() { - return clientDatagramSocket; - } + try { + server = pool.submit(new ServerCallable( + testCase, serverSocket, clientSocketAddr)); + client = pool.submit(new ClientCallable( + testCase, clientSocket, serverSocketAddr)); + } finally { + pool.shutdown(); + } - // Will the handshaking and application data exchange succeed? - public boolean isGoodJob() { - return true; - } + boolean failed = false; - public final void runTest(DTLSOverDatagram testCase) throws Exception { - serverDatagramSocket = new DatagramSocket(); - serverSocketAddr = new InetSocketAddress( - InetAddress.getLocalHost(), serverDatagramSocket.getLocalPort()); - - clientDatagramSocket = new DatagramSocket(); - clientSocketAddr = new InetSocketAddress( - InetAddress.getLocalHost(), clientDatagramSocket.getLocalPort()); - - ExecutorService pool = Executors.newFixedThreadPool(2); - List> list = new ArrayList>(); - - try { - list.add(pool.submit(new ServerCallable(testCase))); // server task - list.add(pool.submit(new ClientCallable(testCase))); // client task - } finally { - pool.shutdown(); - } + // wait for client to finish + try { + System.out.println("Client finished: " + client.get()); + } catch (CancellationException | InterruptedException + | ExecutionException e) { + System.out.println("Exception on client side: "); + e.printStackTrace(System.out); + failed = true; + } - Exception reserved = null; - for (Future fut : list) { + // wait for server to finish try { - System.out.println(fut.get()); - } catch (CancellationException | - InterruptedException | ExecutionException cie) { - if (reserved != null) { - cie.addSuppressed(reserved); - reserved = cie; - } else { - reserved = cie; - } + System.out.println("Client finished: " + server.get()); + } catch (CancellationException | InterruptedException + | ExecutionException e) { + System.out.println("Exception on server side: "); + e.printStackTrace(System.out); + failed = true; } - } - if (reserved != null) { - throw reserved; + if (failed) { + throw new RuntimeException("Test failed"); + } } } final static class ServerCallable implements Callable { - DTLSOverDatagram testCase; - ServerCallable(DTLSOverDatagram testCase) { + private final DTLSOverDatagram testCase; + private final DatagramSocket socket; + private final InetSocketAddress clientSocketAddr; + + ServerCallable(DTLSOverDatagram testCase, DatagramSocket socket, + InetSocketAddress clientSocketAddr) { + this.testCase = testCase; + this.socket = socket; + this.clientSocketAddr = clientSocketAddr; } @Override public String call() throws Exception { try { - testCase.doServerSide(); + testCase.doServerSide(socket, clientSocketAddr); } catch (Exception e) { + System.out.println("Exception in ServerCallable.call():"); e.printStackTrace(System.out); serverException = e; @@ -523,10 +599,6 @@ public class DTLSOverDatagram { } else { return "Well done, server!"; } - } finally { - if (serverDatagramSocket != null) { - serverDatagramSocket.close(); - } } if (testCase.isGoodJob()) { @@ -538,28 +610,33 @@ public class DTLSOverDatagram { } final static class ClientCallable implements Callable { - DTLSOverDatagram testCase; - ClientCallable(DTLSOverDatagram testCase) { + private final DTLSOverDatagram testCase; + private final DatagramSocket socket; + private final InetSocketAddress serverSocketAddr; + + ClientCallable(DTLSOverDatagram testCase, DatagramSocket socket, + InetSocketAddress serverSocketAddr) { + this.testCase = testCase; + this.socket = socket; + this.serverSocketAddr = serverSocketAddr; } @Override public String call() throws Exception { try { - testCase.doClientSide(); + testCase.doClientSide(socket, serverSocketAddr); } catch (Exception e) { + System.out.println("Exception in ClientCallable.call():"); e.printStackTrace(System.out); clientException = e; + if (testCase.isGoodJob()) { throw e; } else { return "Well done, client!"; } - } finally { - if (clientDatagramSocket != null) { - clientDatagramSocket.close(); - } } if (testCase.isGoodJob()) { @@ -600,4 +677,8 @@ public class DTLSOverDatagram { System.out.flush(); } } + + static void log(String side, String message) { + System.out.println(side + ": " + message); + } } diff --git a/jdk/test/javax/net/ssl/DTLS/Reordered.java b/jdk/test/javax/net/ssl/DTLS/Reordered.java index 9e91979a909..25053d221bb 100644 --- a/jdk/test/javax/net/ssl/DTLS/Reordered.java +++ b/jdk/test/javax/net/ssl/DTLS/Reordered.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,16 +51,17 @@ public class Reordered extends DTLSOverDatagram { } @Override - List produceHandshakePackets( - SSLEngine engine, SocketAddress socketAddr) throws Exception { - List packets = - super.produceHandshakePackets(engine, socketAddr); + boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr, + String side, List packets) throws Exception { + + boolean finished = super.produceHandshakePackets( + engine, socketAddr, side, packets); if (needPacketReorder && (!engine.getUseClientMode())) { needPacketReorder = false; Collections.reverse(packets); } - return packets; + return finished; } } diff --git a/jdk/test/javax/net/ssl/DTLS/Retransmission.java b/jdk/test/javax/net/ssl/DTLS/Retransmission.java index 75aecab22fb..840b08a7d7d 100644 --- a/jdk/test/javax/net/ssl/DTLS/Retransmission.java +++ b/jdk/test/javax/net/ssl/DTLS/Retransmission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,13 +52,14 @@ public class Retransmission extends DTLSOverDatagram { } @Override - List produceHandshakePackets( - SSLEngine engine, SocketAddress socketAddr) throws Exception { - List packets = - super.produceHandshakePackets(engine, socketAddr); + boolean produceHandshakePackets(SSLEngine engine, SocketAddress socketAddr, + String side, List packets) throws Exception { + + boolean finished = super.produceHandshakePackets( + engine, socketAddr, side, packets); if (!needPacketLoss || (!engine.getUseClientMode())) { - return packets; + return finished; } List parts = new ArrayList<>(); @@ -75,6 +76,9 @@ public class Retransmission extends DTLSOverDatagram { parts.add(packet); } - return parts; + packets.clear(); + packets.addAll(parts); + + return finished; } } -- GitLab From ea82a852dd3122d66948c85456b7d5e41b656f18 Mon Sep 17 00:00:00 2001 From: Sibabrata Sahoo Date: Fri, 20 May 2016 09:57:01 -0700 Subject: [PATCH 107/400] 8157417: Some of SecureRandom test might get timed out in linux Reviewed-by: weijun --- .../SecureRandom/GetInstanceTest.java | 20 +++++++++---------- .../SecureRandom/MultiThreadTest.java | 2 +- .../SecureRandom/SerializedSeedTest.java | 2 +- .../SeedGenerator/SeedGeneratorChoice.java | 1 - 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/jdk/test/java/security/SecureRandom/GetInstanceTest.java b/jdk/test/java/security/SecureRandom/GetInstanceTest.java index 511188a7709..08477da847e 100644 --- a/jdk/test/java/security/SecureRandom/GetInstanceTest.java +++ b/jdk/test/java/security/SecureRandom/GetInstanceTest.java @@ -36,12 +36,9 @@ import java.security.NoSuchProviderException; import java.security.SecureRandom; import java.security.SecureRandomParameters; import java.security.DrbgParameters; - import static java.security.DrbgParameters.Capability.*; - import java.security.Security; import java.util.Arrays; - import jdk.testlibrary.Asserts; public class GetInstanceTest { @@ -77,13 +74,16 @@ public class GetInstanceTest { + "strong algorithm through security Property: " + "'securerandom.strongAlgorithms'."); } - Security.setProperty(STRONG_ALG_SEC_PROP, "DRBG:SUN"); - sr = matchExc(() -> SecureRandom.getInstanceStrong(), - PASS, NoSuchAlgorithmException.class, - "PASS - Undefined security Property " - + "'securerandom.strongAlgorithms'"); - checkAttributes(sr, "DRBG"); - Security.setProperty(STRONG_ALG_SEC_PROP, origDRBGConfig); + try { + Security.setProperty(STRONG_ALG_SEC_PROP, "DRBG:SUN"); + sr = matchExc(() -> SecureRandom.getInstanceStrong(), + PASS, NoSuchAlgorithmException.class, + "PASS - Undefined security Property " + + "'securerandom.strongAlgorithms'"); + checkAttributes(sr, "DRBG"); + } finally { + Security.setProperty(STRONG_ALG_SEC_PROP, origDRBGConfig); + } for (String mech : new String[]{ "SHA1PRNG", "Hash_DRBG", "HMAC_DRBG", "CTR_DRBG", INVALID_ALGO,}) { diff --git a/jdk/test/java/security/SecureRandom/MultiThreadTest.java b/jdk/test/java/security/SecureRandom/MultiThreadTest.java index 17ae3377377..82c6d68dd94 100644 --- a/jdk/test/java/security/SecureRandom/MultiThreadTest.java +++ b/jdk/test/java/security/SecureRandom/MultiThreadTest.java @@ -41,7 +41,7 @@ import static java.lang.Math.*; * @library /lib/testlibrary * @summary Test behavior of a shared SecureRandom object when it is operated * by multiple threads concurrently. - * @run main MultiThreadTest + * @run main/othervm -Djava.security.egd=file:/dev/urandom MultiThreadTest */ public class MultiThreadTest { diff --git a/jdk/test/java/security/SecureRandom/SerializedSeedTest.java b/jdk/test/java/security/SecureRandom/SerializedSeedTest.java index ba4289ce4c7..9af7296c4ab 100644 --- a/jdk/test/java/security/SecureRandom/SerializedSeedTest.java +++ b/jdk/test/java/security/SecureRandom/SerializedSeedTest.java @@ -29,7 +29,7 @@ * as well from it's serialized instance in the same time then the * generated random numbers should be different when one or both are * reseeded. - * @run main SerializedSeedTest + * @run main/othervm -Djava.security.egd=file:/dev/urandom SerializedSeedTest */ import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java b/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java index e6da6be10a1..93889729058 100644 --- a/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java +++ b/jdk/test/sun/security/provider/SeedGenerator/SeedGeneratorChoice.java @@ -27,7 +27,6 @@ * @bug 6998583 8141039 * @summary NativeSeedGenerator is making 8192 byte read requests from * entropy pool on each init. - * @run main SeedGeneratorChoice * @run main/othervm -Djava.security.egd=file:/dev/random SeedGeneratorChoice * @run main/othervm -Djava.security.egd=file:filename SeedGeneratorChoice */ -- GitLab From d90c3513222eca752be8d6c31b7ebff62611b683 Mon Sep 17 00:00:00 2001 From: Svetlana Nikandrova Date: Fri, 20 May 2016 11:12:02 -0700 Subject: [PATCH 108/400] 8155575: Provider.java contains very long lines because of lambda Reviewed-by: ascarpino --- .../share/classes/java/security/Provider.java | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/security/Provider.java b/jdk/src/java.base/share/classes/java/security/Provider.java index 9ecc8ffe6ba..de09dc49240 100644 --- a/jdk/src/java.base/share/classes/java/security/Provider.java +++ b/jdk/src/java.base/share/classes/java/security/Provider.java @@ -569,7 +569,8 @@ public abstract class Provider extends Properties { * @since 1.8 */ @Override - public synchronized void replaceAll(BiFunction function) { + public synchronized void replaceAll(BiFunction function) { check("putProviderProperty." + name); if (debug != null) { @@ -597,8 +598,8 @@ public abstract class Provider extends Properties { * @since 1.8 */ @Override - public synchronized Object compute(Object key, - BiFunction remappingFunction) { + public synchronized Object compute(Object key, BiFunction remappingFunction) { check("putProviderProperty." + name); check("removeProviderProperty" + name); @@ -628,7 +629,8 @@ public abstract class Provider extends Properties { * @since 1.8 */ @Override - public synchronized Object computeIfAbsent(Object key, Function mappingFunction) { + public synchronized Object computeIfAbsent(Object key, Function mappingFunction) { check("putProviderProperty." + name); check("removeProviderProperty" + name); @@ -657,7 +659,8 @@ public abstract class Provider extends Properties { * @since 1.8 */ @Override - public synchronized Object computeIfPresent(Object key, BiFunction remappingFunction) { + public synchronized Object computeIfPresent(Object key, BiFunction remappingFunction) { check("putProviderProperty." + name); check("removeProviderProperty" + name); @@ -689,7 +692,8 @@ public abstract class Provider extends Properties { * @since 1.8 */ @Override - public synchronized Object merge(Object key, Object value, BiFunction remappingFunction) { + public synchronized Object merge(Object key, Object value, BiFunction remappingFunction) { check("putProviderProperty." + name); check("removeProviderProperty" + name); @@ -868,18 +872,21 @@ public abstract class Provider extends Properties { } @SuppressWarnings("unchecked") // Function must actually operate over strings - private void implReplaceAll(BiFunction function) { + private void implReplaceAll(BiFunction function) { legacyChanged = true; if (legacyStrings == null) { legacyStrings = new LinkedHashMap<>(); } else { - legacyStrings.replaceAll((BiFunction) function); + legacyStrings.replaceAll((BiFunction) function); } super.replaceAll(function); } @SuppressWarnings("unchecked") // Function must actually operate over strings - private Object implMerge(Object key, Object value, BiFunction remappingFunction) { + private Object implMerge(Object key, Object value, BiFunction remappingFunction) { if ((key instanceof String) && (value instanceof String)) { if (!checkLegacy(key)) { return null; @@ -891,7 +898,8 @@ public abstract class Provider extends Properties { } @SuppressWarnings("unchecked") // Function must actually operate over strings - private Object implCompute(Object key, BiFunction remappingFunction) { + private Object implCompute(Object key, BiFunction remappingFunction) { if (key instanceof String) { if (!checkLegacy(key)) { return null; @@ -903,7 +911,8 @@ public abstract class Provider extends Properties { } @SuppressWarnings("unchecked") // Function must actually operate over strings - private Object implComputeIfAbsent(Object key, Function mappingFunction) { + private Object implComputeIfAbsent(Object key, Function mappingFunction) { if (key instanceof String) { if (!checkLegacy(key)) { return null; @@ -915,7 +924,8 @@ public abstract class Provider extends Properties { } @SuppressWarnings("unchecked") // Function must actually operate over strings - private Object implComputeIfPresent(Object key, BiFunction remappingFunction) { + private Object implComputeIfPresent(Object key, BiFunction remappingFunction) { if (key instanceof String) { if (!checkLegacy(key)) { return null; -- GitLab From 409d4bd80c1e8b2aa5b093d2311ed3a8979e82d5 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Fri, 20 May 2016 20:27:28 +0200 Subject: [PATCH 109/400] 8157449: Adjust link-time generated Species classes to match JDK-8148604 usage Reviewed-by: shade --- .../jlink/internal/plugins/GenerateJLIClassesPlugin.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java index 9e0805ec361..2e075799076 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java @@ -101,8 +101,8 @@ public final class GenerateJLIClassesPlugin implements TransformerPlugin { */ public static List defaultSpecies() { return List.of("LL", "L3", "L4", "L5", "L6", "L7", "L7I", - "L7II", "L7IIL", "L8", "L9", "L10", "L11", "L11I", "L11II", - "L12", "L13", "LI", "D", "L3I", "LIL", "LLI", "LLIL", + "L7II", "L7IIL", "L8", "L9", "L10", "L10I", "L10II", "L10IIL", + "L11", "L12", "L13", "LI", "D", "L3I", "LIL", "LLI", "LLIL", "LILL", "I", "LLILL"); } -- GitLab From 5330dbf8e4ef5de5a58063630654722421f92b20 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Fri, 20 May 2016 12:47:41 -0700 Subject: [PATCH 110/400] 8143282: \p{Cn} unassigned code points should be included in \p{C} To add unassigned cp support into \p{C} Reviewed-by: martin --- .../classes/java/util/regex/CharPredicates.java | 3 ++- jdk/test/java/util/regex/RegExTest.java | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/util/regex/CharPredicates.java b/jdk/src/java.base/share/classes/java/util/regex/CharPredicates.java index 0a873c774a9..238fc6e7aeb 100644 --- a/jdk/src/java.base/share/classes/java/util/regex/CharPredicates.java +++ b/jdk/src/java.base/share/classes/java/util/regex/CharPredicates.java @@ -302,7 +302,8 @@ class CharPredicates { defCategory("C", ((1< Date: Fri, 20 May 2016 21:44:03 +0100 Subject: [PATCH 111/400] 8157154: jmod jlink properties file need copyright header Reviewed-by: alanb, mchung --- .../tools/jimage/resources/jimage.properties | 25 +++++++++++++++++++ .../tools/jlink/resources/jlink.properties | 25 +++++++++++++++++++ .../tools/jlink/resources/plugins.properties | 25 +++++++++++++++++++ .../jdk/tools/jmod/resources/jmod.properties | 25 +++++++++++++++++++ 4 files changed, 100 insertions(+) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties index ef94fd376c6..ef109232051 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jimage/resources/jimage.properties @@ -1,3 +1,28 @@ +# +# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + main.usage.summary=\ Usage: {0} jimage...\n\ use --help for a list of possible options diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties index 1aa33439525..975dc81e4ea 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties @@ -1,3 +1,28 @@ +# +# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + main.usage.summary=\ Usage: {0} --modulepath --addmods --output \n\ use --help for a list of possible options diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties index 5b036466ef6..66fc5efcec8 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties @@ -1,3 +1,28 @@ +# +# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + release-info.argument=|add:=:=:...|del: release-info.description=\ diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties index 555adb03b8f..12cb85cc919 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/resources/jmod.properties @@ -1,3 +1,28 @@ +# +# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + main.usage.summary=\ Usage: {0} (create|list|describe|hash) \n\ use --help for a list of possible options -- GitLab From 8c58aff49de6b54319626a6392c2bbd6d87b7aef Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Fri, 20 May 2016 14:41:41 -0700 Subject: [PATCH 112/400] 5100935: No way to access the 64-bit integer multiplication of 64-bit CPUs efficiently Add methods multiplyFull() and multiplyHigh() to Math and StrictMath. Reviewed-by: darcy --- .../share/classes/java/lang/Math.java | 47 ++++++++ .../share/classes/java/lang/StrictMath.java | 29 ++++- .../java/lang/Math/MultiplicationTests.java | 113 ++++++++++++++++++ 3 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/lang/Math/MultiplicationTests.java diff --git a/jdk/src/java.base/share/classes/java/lang/Math.java b/jdk/src/java.base/share/classes/java/lang/Math.java index 4244d40a3b9..7a01b69a2ae 100644 --- a/jdk/src/java.base/share/classes/java/lang/Math.java +++ b/jdk/src/java.base/share/classes/java/lang/Math.java @@ -1059,6 +1059,53 @@ public final class Math { return (int)value; } + /** + * Returns the exact mathematical product of the arguments. + * + * @param x the first value + * @param y the second value + * @return the result + */ + public static long multiplyFull(int x, int y) { + return (long)x * (long)y; + } + + /** + * Returns as a {@code long} the most significant 64 bits of the 128-bit + * product of two 64-bit factors. + * + * @param x the first value + * @param y the second value + * @return the result + */ + public static long multiplyHigh(long x, long y) { + if (x < 0 || y < 0) { + // Use technique from section 8-2 of Henry S. Warren, Jr., + // Hacker's Delight (2nd ed.) (Addison Wesley, 2013), 173-174. + long x1 = x >> 32; + long x2 = x & 0xFFFFFFFFL; + long y1 = y >> 32; + long y2 = y & 0xFFFFFFFFL; + long z2 = x2 * y2; + long t = x1 * y2 + (z2 >>> 32); + long z1 = t & 0xFFFFFFFFL; + long z0 = t >> 32; + z1 += x2 * y1; + return x1 * y1 + z0 + (z1 >> 32); + } else { + // Use Karatsuba technique with two base 2^32 digits. + long x1 = x >>> 32; + long y1 = y >>> 32; + long x2 = x & 0xFFFFFFFFL; + long y2 = y & 0xFFFFFFFFL; + long A = x1 * y1; + long B = x2 * y2; + long C = (x1 + x2) * (y1 + y2); + long K = C - A - B; + return (((B >>> 32) + K) >>> 32) + A; + } + } + /** * Returns the largest (closest to positive infinity) * {@code int} value that is less than or equal to the algebraic quotient. diff --git a/jdk/src/java.base/share/classes/java/lang/StrictMath.java b/jdk/src/java.base/share/classes/java/lang/StrictMath.java index a92f566c153..2278fe3d129 100644 --- a/jdk/src/java.base/share/classes/java/lang/StrictMath.java +++ b/jdk/src/java.base/share/classes/java/lang/StrictMath.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -831,6 +831,33 @@ public final class StrictMath { return Math.toIntExact(value); } + /** + * Returns the exact mathematical product of the arguments. + * + * @param x the first value + * @param y the second value + * @return the result + * @see Math#multiplyFull(long,long) + * @since 1.9 + */ + public static long multiplyFull(int x, int y) { + return Math.multiplyFull(x, y); + } + + /** + * Returns as a {@code long} the most significant 64 bits of the 128-bit + * product of two 64-bit factors. + * + * @param x the first value + * @param y the second value + * @return the result + * @see Math#multiplyHigh(long,long) + * @since 1.9 + */ + public static long multiplyHigh(long x, long y) { + return Math.multiplyHigh(x, y); + } + /** * Returns the largest (closest to positive infinity) * {@code int} value that is less than or equal to the algebraic quotient. diff --git a/jdk/test/java/lang/Math/MultiplicationTests.java b/jdk/test/java/lang/Math/MultiplicationTests.java new file mode 100644 index 00000000000..1a9c3da2a67 --- /dev/null +++ b/jdk/test/java/lang/Math/MultiplicationTests.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @library /lib/testlibrary/ + * @build jdk.testlibrary.* + * @run main MultiplicationTests + * @bug 5100935 + * @summary Tests for multiplication methods (use -Dseed=X to set PRNG seed) + * @key randomness + */ + +import java.math.BigInteger; +import jdk.testlibrary.RandomFactory; + +public class MultiplicationTests { + private MultiplicationTests(){} + + // Number of random products to test. + private static final int COUNT = 1 << 16; + + // Initialize shared random number generator + private static java.util.Random rnd = RandomFactory.getRandom(); + + // Calculate high 64 bits of 128 product using BigInteger. + private static long multiplyHighBigInt(long x, long y) { + return BigInteger.valueOf(x).multiply(BigInteger.valueOf(y)) + .shiftRight(64).longValue(); + } + + // Check Math.multiplyHigh(x,y) against multiplyHighBigInt(x,y) + private static boolean check(long x, long y) { + long p1 = multiplyHighBigInt(x, y); + long p2 = Math.multiplyHigh(x, y); + if (p1 != p2) { + System.err.printf("Error - x:%d y:%d p1:%d p2:%d\n", x, y, p1, p2); + return false; + } else { + return true; + } + } + + private static int testMultiplyHigh() { + int failures = 0; + + // check some boundary cases + long[][] v = new long[][]{ + {0L, 0L}, + {-1L, 0L}, + {0L, -1L}, + {1L, 0L}, + {0L, 1L}, + {-1L, -1L}, + {-1L, 1L}, + {1L, -1L}, + {1L, 1L}, + {Long.MAX_VALUE, Long.MAX_VALUE}, + {Long.MAX_VALUE, -Long.MAX_VALUE}, + {-Long.MAX_VALUE, Long.MAX_VALUE}, + {Long.MAX_VALUE, Long.MIN_VALUE}, + {Long.MIN_VALUE, Long.MAX_VALUE}, + {Long.MIN_VALUE, Long.MIN_VALUE} + }; + + for (long[] xy : v) { + if(!check(xy[0], xy[1])) { + failures++; + } + } + + // check some random values + for (int i = 0; i < COUNT; i++) { + if (!check(rnd.nextLong(), rnd.nextLong())) { + failures++; + } + } + + return failures; + } + + public static void main(String argv[]) { + int failures = testMultiplyHigh(); + + if (failures > 0) { + System.err.println("Multiplication testing encountered " + + failures + " failures."); + throw new RuntimeException(); + } else { + System.out.println("MultiplicationTests succeeded"); + } + } +} -- GitLab From 4045a8be07195acac7fb2faef0e6bf90edcaf9f8 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Fri, 20 May 2016 15:34:37 -0700 Subject: [PATCH 113/400] 4851777: Add BigDecimal sqrt method Reviewed-by: bpb --- .../share/classes/java/math/BigDecimal.java | 300 ++++++++++++++++++ .../java/math/BigDecimal/SquareRootTests.java | 227 +++++++++++++ 2 files changed, 527 insertions(+) create mode 100644 jdk/test/java/math/BigDecimal/SquareRootTests.java diff --git a/jdk/src/java.base/share/classes/java/math/BigDecimal.java b/jdk/src/java.base/share/classes/java/math/BigDecimal.java index 557c5cc2e35..dce4300c77a 100644 --- a/jdk/src/java.base/share/classes/java/math/BigDecimal.java +++ b/jdk/src/java.base/share/classes/java/math/BigDecimal.java @@ -128,6 +128,7 @@ import java.util.Arrays; * Subtractmax(minuend.scale(), subtrahend.scale()) * Multiplymultiplier.scale() + multiplicand.scale() * Dividedividend.scale() - divisor.scale() + * Square rootradicand.scale()/2 * * * These scales are the ones used by the methods which return exact @@ -346,6 +347,16 @@ public class BigDecimal extends Number implements Comparable { public static final BigDecimal TEN = ZERO_THROUGH_TEN[10]; + /** + * The value 0.1, with a scale of 1. + */ + private static final BigDecimal ONE_TENTH = valueOf(1L, 1); + + /** + * The value 0.5, with a scale of 1. + */ + private static final BigDecimal ONE_HALF = valueOf(5L, 1); + // Constructors /** @@ -1995,6 +2006,295 @@ public class BigDecimal extends Number implements Comparable { return result; } + /** + * Returns an approximation to the square root of {@code this} + * with rounding according to the context settings. + * + *

      The preferred scale of the returned result is equal to + * {@code this.scale()/2}. The value of the returned result is + * always within one ulp of the exact decimal value for the + * precision in question. If the rounding mode is {@link + * RoundingMode#HALF_UP HALF_UP}, {@link RoundingMode#HALF_DOWN + * HALF_DOWN}, or {@link RoundingMode#HALF_EVEN HALF_EVEN}, the + * result is within one half an ulp of the exact decimal value. + * + *

      Special case: + *

        + *
      • The square root of a number numerically equal to {@code + * ZERO} is numerically equal to {@code ZERO} with a preferred + * scale according to the general rule above. In particular, for + * {@code ZERO}}, {@code ZERO.sqrt(mc).equals(ZERO)} is true with + * any {@code MathContext} as an argument. + *
      + * + * @param mc the context to use. + * @return the square root of {@code this}. + * @throws ArithmeticException if {@code this} is less than zero. + * @throws ArithmeticException if an exact result is requested + * ({@code mc.getPrecision()==0}) and there is no finite decimal + * expansion of the exact result + * @throws ArithmeticException if + * {@code (mc.getRoundingMode()==RoundingMode.UNNECESSARY}) and + * the exact result cannot fit in {@code mc.getPrecision()} + * digits. + * @since 9 + */ + public BigDecimal sqrt(MathContext mc) { + int signum = signum(); + if (signum == 1) { + /* + * The following code draws on the algorithm presented in + * "Properly Rounded Variable Precision Square Root," Hull and + * Abrham, ACM Transactions on Mathematical Software, Vol 11, + * No. 3, September 1985, Pages 229-237. + * + * The BigDecimal computational model differs from the one + * presented in the paper in several ways: first BigDecimal + * numbers aren't necessarily normalized, second many more + * rounding modes are supported, including UNNECESSARY, and + * exact results can be requested. + * + * The main steps of the algorithm below are as follows, + * first argument reduce the value to the numerical range + * [1, 10) using the following relations: + * + * x = y * 10 ^ exp + * sqrt(x) = sqrt(y) * 10^(exp / 2) if exp is even + * sqrt(x) = sqrt(y/10) * 10 ^((exp+1)/2) is exp is odd + * + * Then use Newton's iteration on the reduced value to compute + * the numerical digits of the desired result. + * + * Finally, scale back to the desired exponent range and + * perform any adjustment to get the preferred scale in the + * representation. + */ + + // The code below favors relative simplicity over checking + // for special cases that could run faster. + + int preferredScale = this.scale()/2; + BigDecimal zeroWithFinalPreferredScale = valueOf(0L, preferredScale); + + // First phase of numerical normalization, strip trailing + // zeros and check for even powers of 10. + BigDecimal stripped = this.stripTrailingZeros(); + int strippedScale = stripped.scale(); + + // Numerically sqrt(10^2N) = 10^N + if (stripped.isPowerOfTen() && + strippedScale % 2 == 0) { + BigDecimal result = valueOf(1L, strippedScale/2); + if (result.scale() != preferredScale) { + // Adjust to requested precision and preferred + // scale as appropriate. + result = result.add(zeroWithFinalPreferredScale, mc); + } + return result; + } + + // After stripTrailingZeros, the representation is normalized as + // + // unscaledValue * 10^(-scale) + // + // where unscaledValue is an integer with the mimimum + // precision for the cohort of the numerical value. To + // allow binary floating-point hardware to be used to get + // approximately a 15 digit approximation to the square + // root, it is helpful to instead normalize this so that + // the significand portion is to right of the decimal + // point by roughly (scale() - precision() +1). + + // Now the precision / scale adjustment + int scaleAdjust = 0; + int scale = stripped.scale() - stripped.precision() + 1; + if (scale % 2 == 0) { + scaleAdjust = scale; + } else { + scaleAdjust = scale - 1; + } + + BigDecimal working = stripped.scaleByPowerOfTen(scaleAdjust); + + assert // Verify 0.1 <= working < 10 + ONE_TENTH.compareTo(working) <= 0 && working.compareTo(TEN) < 0; + + // Use good ole' Math.sqrt to get the initial guess for + // the Newton iteration, good to at least 15 decimal + // digits. This approach does incur the cost of a + // + // BigDecimal -> double -> BigDecimal + // + // conversion cycle, but it avoids the need for several + // Newton iterations in BigDecimal arithmetic to get the + // working answer to 15 digits of precision. If many fewer + // than 15 digits were needed, it might be faster to do + // the loop entirely in BigDecimal arithmetic. + // + // (A double value might have as much many as 17 decimal + // digits of precision; it depends on the relative density + // of binary and decimal numbers at different regions of + // the number line.) + // + // (It would be possible to check for certain special + // cases to avoid doing any Newton iterations. For + // example, if the BigDecimal -> double conversion was + // known to be exact and the rounding mode had a + // low-enough precision, the post-Newton rounding logic + // could be applied directly.) + + BigDecimal guess = new BigDecimal(Math.sqrt(working.doubleValue())); + int guessPrecision = 15; + int originalPrecision = mc.getPrecision(); + int targetPrecision; + + // If an exact value is requested, it must only need about + // half of the input digits to represent since multiplying + // an N digit number by itself yield a 2N-1 digit or 2N + // digit result. + if (originalPrecision == 0) { + targetPrecision = stripped.precision()/2 + 1; + } else { + targetPrecision = originalPrecision; + } + + // When setting the precision to use inside the Newton + // iteration loop, take care to avoid the case where the + // precision of the input exceeds the requested precision + // and rounding the input value too soon. + BigDecimal approx = guess; + int workingPrecision = working.precision(); + do { + int tmpPrecision = Math.max(Math.max(guessPrecision, targetPrecision + 2), + workingPrecision); + MathContext mcTmp = new MathContext(tmpPrecision, RoundingMode.HALF_EVEN); + // approx = 0.5 * (approx + fraction / approx) + approx = ONE_HALF.multiply(approx.add(working.divide(approx, mcTmp), mcTmp)); + guessPrecision *= 2; + } while (guessPrecision < targetPrecision + 2); + + BigDecimal result; + RoundingMode targetRm = mc.getRoundingMode(); + if (targetRm == RoundingMode.UNNECESSARY || originalPrecision == 0) { + RoundingMode tmpRm = + (targetRm == RoundingMode.UNNECESSARY) ? RoundingMode.DOWN : targetRm; + MathContext mcTmp = new MathContext(targetPrecision, tmpRm); + result = approx.scaleByPowerOfTen(-scaleAdjust/2).round(mcTmp); + + // If result*result != this numerically, the square + // root isn't exact + if (this.subtract(result.multiply(result)).compareTo(ZERO) != 0) { + throw new ArithmeticException("Computed square root not exact."); + } + } else { + result = approx.scaleByPowerOfTen(-scaleAdjust/2).round(mc); + } + + if (result.scale() != preferredScale) { + // The preferred scale of an add is + // max(addend.scale(), augend.scale()). Therefore, if + // the scale of the result is first minimized using + // stripTrailingZeros(), adding a zero of the + // preferred scale rounding the correct precision will + // perform the proper scale vs precision tradeoffs. + result = result.stripTrailingZeros(). + add(zeroWithFinalPreferredScale, + new MathContext(originalPrecision, RoundingMode.UNNECESSARY)); + } + assert squareRootResultAssertions(result, mc); + return result; + } else { + switch (signum) { + case -1: + throw new ArithmeticException("Attempted square root " + + "of negative BigDecimal"); + case 0: + return valueOf(0L, scale()/2); + + default: + throw new AssertionError("Bad value from signum"); + } + } + } + + private boolean isPowerOfTen() { + return BigInteger.ONE.equals(this.unscaledValue()); + } + + /** + * For nonzero values, check numerical correctness properties of + * the computed result for the chosen rounding mode. + * + * For the directed roundings, for DOWN and FLOOR, result^2 must + * be {@code <=} the input and (result+ulp)^2 must be {@code >} the + * input. Conversely, for UP and CEIL, result^2 must be {@code >=} the + * input and (result-ulp)^2 must be {@code <} the input. + */ + private boolean squareRootResultAssertions(BigDecimal result, MathContext mc) { + if (result.signum() == 0) { + return squareRootZeroResultAssertions(result, mc); + } else { + RoundingMode rm = mc.getRoundingMode(); + BigDecimal ulp = result.ulp(); + BigDecimal neighborUp = result.add(ulp); + // Make neighbor down accurate even for powers of ten + if (this.isPowerOfTen()) { + ulp = ulp.divide(TEN); + } + BigDecimal neighborDown = result.subtract(ulp); + + // Both the starting value and result should be nonzero and positive. + if (result.signum() != 1 || + this.signum() != 1) { + return false; + } + + switch (rm) { + case DOWN: + case FLOOR: + return + result.multiply(result).compareTo(this) <= 0 && + neighborUp.multiply(neighborUp).compareTo(this) > 0; + + case UP: + case CEILING: + return + result.multiply(result).compareTo(this) >= 0 && + neighborDown.multiply(neighborDown).compareTo(this) < 0; + + case HALF_DOWN: + case HALF_EVEN: + case HALF_UP: + BigDecimal err = result.multiply(result).subtract(this).abs(); + BigDecimal errUp = neighborUp.multiply(neighborUp).subtract(this); + BigDecimal errDown = this.subtract(neighborDown.multiply(neighborDown)); + // All error values should be positive so don't need to + // compare absolute values. + + int err_comp_errUp = err.compareTo(errUp); + int err_comp_errDown = err.compareTo(errDown); + + return + errUp.signum() == 1 && + errDown.signum() == 1 && + + err_comp_errUp <= 0 && + err_comp_errDown <= 0 && + + ((err_comp_errUp == 0 ) ? err_comp_errDown < 0 : true) && + ((err_comp_errDown == 0 ) ? err_comp_errUp < 0 : true); + // && could check for digit conditions for ties too + + default: // Definition of UNNECESSARY already verified. + return true; + } + } + } + + private boolean squareRootZeroResultAssertions(BigDecimal result, MathContext mc) { + return this.compareTo(ZERO) == 0; + } + /** * Returns a {@code BigDecimal} whose value is * (thisn), The power is computed exactly, to diff --git a/jdk/test/java/math/BigDecimal/SquareRootTests.java b/jdk/test/java/math/BigDecimal/SquareRootTests.java new file mode 100644 index 00000000000..1ad72d0f8ea --- /dev/null +++ b/jdk/test/java/math/BigDecimal/SquareRootTests.java @@ -0,0 +1,227 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 4851777 + * @summary Tests of BigDecimal.sqrt(). + */ + +import java.math.*; +import java.util.*; + +public class SquareRootTests { + + public static void main(String... args) { + int failures = 0; + + failures += negativeTests(); + failures += zeroTests(); + failures += evenPowersOfTenTests(); + failures += squareRootTwoTests(); + failures += lowPrecisionPerfectSquares(); + + if (failures > 0 ) { + throw new RuntimeException("Incurred " + failures + " failures" + + " testing BigDecimal.sqrt()."); + } + } + + private static int negativeTests() { + int failures = 0; + + for (long i = -10; i < 0; i++) { + for (int j = -5; j < 5; j++) { + try { + BigDecimal input = BigDecimal.valueOf(i, j); + BigDecimal result = input.sqrt(MathContext.DECIMAL64); + System.err.println("Unexpected sqrt of negative: (" + + input + ").sqrt() = " + result ); + failures += 1; + } catch (ArithmeticException e) { + ; // Expected + } + } + } + + return failures; + } + + private static int zeroTests() { + int failures = 0; + + for (int i = -100; i < 100; i++) { + BigDecimal expected = BigDecimal.valueOf(0L, i/2); + // These results are independent of rounding mode + failures += compare(BigDecimal.valueOf(0L, i).sqrt(MathContext.UNLIMITED), + expected, true, "zeros"); + + failures += compare(BigDecimal.valueOf(0L, i).sqrt(MathContext.DECIMAL64), + expected, true, "zeros"); + } + + return failures; + } + + /** + * sqrt(10^2N) is 10^N + * Both numerical value and representation should be verified + */ + private static int evenPowersOfTenTests() { + int failures = 0; + MathContext oneDigitExactly = new MathContext(1, RoundingMode.UNNECESSARY); + + for (int scale = -100; scale <= 100; scale++) { + BigDecimal testValue = BigDecimal.valueOf(1, 2*scale); + BigDecimal expectedNumericalResult = BigDecimal.valueOf(1, scale); + + BigDecimal result; + + + failures += equalNumerically(expectedNumericalResult, + result = testValue.sqrt(MathContext.DECIMAL64), + "Even powers of 10, DECIMAL64"); + + // Can round to one digit of precision exactly + failures += equalNumerically(expectedNumericalResult, + result = testValue.sqrt(oneDigitExactly), + "even powers of 10, 1 digit"); + if (result.precision() > 1) { + failures += 1; + System.err.println("Excess precision for " + result); + } + + + // If rounding to more than one digit, do precision / scale checking... + + } + + return failures; + } + + private static int squareRootTwoTests() { + int failures = 0; + BigDecimal TWO = new BigDecimal(2); + + // Square root of 2 truncated to 65 digits + BigDecimal highPrecisionRoot2 = + new BigDecimal("1.41421356237309504880168872420969807856967187537694807317667973799"); + + + RoundingMode[] modes = { + RoundingMode.UP, RoundingMode.DOWN, + RoundingMode.CEILING, RoundingMode.FLOOR, + RoundingMode.HALF_UP, RoundingMode.HALF_DOWN, RoundingMode.HALF_EVEN + }; + + // For each iteresting rounding mode, for precisions 1 to, say + // 63 numerically compare TWO.sqrt(mc) to + // highPrecisionRoot2.round(mc) + + for (RoundingMode mode : modes) { + for (int precision = 1; precision < 63; precision++) { + MathContext mc = new MathContext(precision, mode); + BigDecimal expected = highPrecisionRoot2.round(mc); + BigDecimal computed = TWO.sqrt(mc); + + equalNumerically(expected, computed, "sqrt(2)"); + } + } + + return failures; + } + + private static int lowPrecisionPerfectSquares() { + int failures = 0; + + // For 5^2 through 9^2, if the input is rounded to one digit + // first before the root is computed, the wrong answer will + // result. Verify results and scale for different rounding + // modes and precisions. + long[][] squaresWithOneDigitRoot = {{ 4, 2}, + { 9, 3}, + {25, 5}, + {36, 6}, + {49, 7}, + {64, 8}, + {81, 9}}; + + for (long[] squareAndRoot : squaresWithOneDigitRoot) { + BigDecimal square = new BigDecimal(squareAndRoot[0]); + BigDecimal expected = new BigDecimal(squareAndRoot[1]); + + for (int scale = 0; scale <= 4; scale++) { + BigDecimal scaledSquare = square.setScale(scale, RoundingMode.UNNECESSARY); + int expectedScale = scale/2; + for (int precision = 0; precision <= 5; precision++) { + for (RoundingMode rm : RoundingMode.values()) { + MathContext mc = new MathContext(precision, rm); + BigDecimal computedRoot = scaledSquare.sqrt(mc); + failures += equalNumerically(expected, computedRoot, "simple squares"); + int computedScale = computedRoot.scale(); + if (precision >= expectedScale + 1 && + computedScale != expectedScale) { + System.err.printf("%s\tprecision=%d\trm=%s%n", + computedRoot.toString(), precision, rm); + failures++; + System.err.printf("\t%s does not have expected scale of %d%n.", + computedRoot, expectedScale); + } + } + } + } + } + + return failures; + } + + private static int compare(BigDecimal a, BigDecimal b, boolean expected, String prefix) { + boolean result = a.equals(b); + int failed = (result==expected) ? 0 : 1; + if (failed == 1) { + System.err.println("Testing " + prefix + + "(" + a + ").compareTo(" + b + ") => " + result + + "\n\tExpected " + expected); + } + return failed; + } + + private static int equalNumerically(BigDecimal a, BigDecimal b, + String prefix) { + return compareNumerically(a, b, 0, prefix); + } + + + private static int compareNumerically(BigDecimal a, BigDecimal b, + int expected, String prefix) { + int result = a.compareTo(b); + int failed = (result==expected) ? 0 : 1; + if (failed == 1) { + System.err.println("Testing " + prefix + + "(" + a + ").compareTo(" + b + ") => " + result + + "\n\tExpected " + expected); + } + return failed; + } + +} -- GitLab From 1a2c01a37ce4748ad7752b572cb81574dc8f147d Mon Sep 17 00:00:00 2001 From: Rajan Halade Date: Fri, 20 May 2016 15:50:20 -0700 Subject: [PATCH 114/400] 8157469: DefaultProviderList.java fails with no provider class apple.security.AppleProvider found Reviewed-by: valeriep --- .../security/Provider/DefaultProviderList.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/jdk/test/java/security/Provider/DefaultProviderList.java b/jdk/test/java/security/Provider/DefaultProviderList.java index c2836642f42..ba63c76caf6 100644 --- a/jdk/test/java/security/Provider/DefaultProviderList.java +++ b/jdk/test/java/security/Provider/DefaultProviderList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,13 +23,16 @@ /** * @test - * @bug 7191662 + * @bug 7191662 8157469 * @summary Ensure non-java.base providers can be found by ServiceLoader * @author Valerie Peng */ -import java.util.*; -import java.security.*; +import java.security.Provider; +import java.security.Security; +import java.util.Arrays; +import java.util.Iterator; +import java.util.ServiceLoader; public class DefaultProviderList { @@ -44,7 +47,8 @@ public class DefaultProviderList { String pName = p.getName(); // only providers outside java.base are loaded by ServiceLoader if (pName.equals("SUN") || pName.equals("SunRsaSign") || - pName.equals("SunJCE") || pName.equals("SunJSSE")) { + pName.equals("SunJCE") || pName.equals("SunJSSE") || + pName.equals("Apple")) { System.out.println("Skip test for provider " + pName); continue; } -- GitLab From 3497da36a29f2e75a16fd97422c73fcf35e3eccc Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Tue, 29 Sep 2015 17:28:44 -0700 Subject: [PATCH 115/400] 8023217: Additional floorDiv/floorMod/multiplyExact methods for java.lang.Math Add new methods with long, int signatures. Reviewed-by: darcy, scolebourne --- .../share/classes/java/lang/Math.java | 87 +++++++++- .../share/classes/java/lang/StrictMath.java | 70 +++++++- .../share/classes/java/time/Instant.java | 4 +- .../share/classes/java/time/LocalDate.java | 4 +- .../classes/java/time/LocalDateTime.java | 4 +- .../share/classes/java/time/LocalTime.java | 4 +- .../share/classes/java/time/OffsetTime.java | 4 +- .../share/classes/java/time/YearMonth.java | 4 +- .../classes/java/time/chrono/HijrahDate.java | 4 +- jdk/test/java/lang/Math/DivModTests.java | 164 +++++++++++++++++- jdk/test/java/lang/Math/ExactArithTests.java | 60 ++++++- 11 files changed, 382 insertions(+), 27 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/Math.java b/jdk/src/java.base/share/classes/java/lang/Math.java index 7a01b69a2ae..329de1e68a6 100644 --- a/jdk/src/java.base/share/classes/java/lang/Math.java +++ b/jdk/src/java.base/share/classes/java/lang/Math.java @@ -95,7 +95,7 @@ import jdk.internal.HotSpotIntrinsicCandidate; * {@code subtractExact}, {@code multiplyExact}, and {@code toIntExact} * throw an {@code ArithmeticException} when the results overflow. * For other arithmetic operations such as divide, absolute value, - * increment, decrement, and negation overflow occurs only with + * increment by one, decrement by one, and negation, overflow occurs only with * a specific minimum or maximum value and should be checked against * the minimum or maximum as appropriate. * @@ -861,7 +861,7 @@ public final class Math { public static int subtractExact(int x, int y) { int r = x - y; // HD 2-12 Overflow iff the arguments have different signs and - // the sign of the result is different than the sign of x + // the sign of the result is different from the sign of x if (((x ^ y) & (x ^ r)) < 0) { throw new ArithmeticException("integer overflow"); } @@ -882,7 +882,7 @@ public final class Math { public static long subtractExact(long x, long y) { long r = x - y; // HD 2-12 Overflow iff the arguments have different signs and - // the sign of the result is different than the sign of x + // the sign of the result is different from the sign of x if (((x ^ y) & (x ^ r)) < 0) { throw new ArithmeticException("long overflow"); } @@ -908,6 +908,20 @@ public final class Math { return (int)r; } + /** + * Returns the product of the arguments, throwing an exception if the result + * overflows a {@code long}. + * + * @param x the first value + * @param y the second value + * @return the result + * @throws ArithmeticException if the result overflows a long + * @since 1.9 + */ + public static long multiplyExact(long x, int y) { + return multiplyExact(x, (long)y); + } + /** * Returns the product of the arguments, * throwing an exception if the result overflows a {@code long}. @@ -1112,12 +1126,12 @@ public final class Math { * There is one special case, if the dividend is the * {@linkplain Integer#MIN_VALUE Integer.MIN_VALUE} and the divisor is {@code -1}, * then integer overflow occurs and - * the result is equal to the {@code Integer.MIN_VALUE}. + * the result is equal to {@code Integer.MIN_VALUE}. *

      * Normal integer division operates under the round to zero rounding mode * (truncation). This operation instead acts under the round toward * negative infinity (floor) rounding mode. - * The floor rounding mode gives different results than truncation + * The floor rounding mode gives different results from truncation * when the exact result is negative. *

        *
      • If the signs of the arguments are the same, the results of @@ -1155,12 +1169,41 @@ public final class Math { * There is one special case, if the dividend is the * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1}, * then integer overflow occurs and - * the result is equal to the {@code Long.MIN_VALUE}. + * the result is equal to {@code Long.MIN_VALUE}. *

        * Normal integer division operates under the round to zero rounding mode * (truncation). This operation instead acts under the round toward * negative infinity (floor) rounding mode. - * The floor rounding mode gives different results than truncation + * The floor rounding mode gives different results from truncation + * when the exact result is negative. + *

        + * For examples, see {@link #floorDiv(int, int)}. + * + * @param x the dividend + * @param y the divisor + * @return the largest (closest to positive infinity) + * {@code int} value that is less than or equal to the algebraic quotient. + * @throws ArithmeticException if the divisor {@code y} is zero + * @see #floorMod(long, int) + * @see #floor(double) + * @since 1.9 + */ + public static long floorDiv(long x, int y) { + return floorDiv(x, (long)y); + } + + /** + * Returns the largest (closest to positive infinity) + * {@code long} value that is less than or equal to the algebraic quotient. + * There is one special case, if the dividend is the + * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1}, + * then integer overflow occurs and + * the result is equal to {@code Long.MIN_VALUE}. + *

        + * Normal integer division operates under the round to zero rounding mode + * (truncation). This operation instead acts under the round toward + * negative infinity (floor) rounding mode. + * The floor rounding mode gives different results from truncation * when the exact result is negative. *

        * For examples, see {@link #floorDiv(int, int)}. @@ -1228,8 +1271,34 @@ public final class Math { * @since 1.8 */ public static int floorMod(int x, int y) { - int r = x - floorDiv(x, y) * y; - return r; + return x - floorDiv(x, y) * y; + } + + /** + * Returns the floor modulus of the {@code long} and {@int} arguments. + *

        + * The floor modulus is {@code x - (floorDiv(x, y) * y)}, + * has the same sign as the divisor {@code y}, and + * is in the range of {@code -abs(y) < r < +abs(y)}. + * + *

        + * The relationship between {@code floorDiv} and {@code floorMod} is such that: + *

          + *
        • {@code floorDiv(x, y) * y + floorMod(x, y) == x} + *
        + *

        + * For examples, see {@link #floorMod(int, int)}. + * + * @param x the dividend + * @param y the divisor + * @return the floor modulus {@code x - (floorDiv(x, y) * y)} + * @throws ArithmeticException if the divisor {@code y} is zero + * @see #floorDiv(long, int) + * @since 1.9 + */ + public static int floorMod(long x, int y) { + // Result cannot overflow the range of int. + return (int)(x - floorDiv(x, y) * y); } /** diff --git a/jdk/src/java.base/share/classes/java/lang/StrictMath.java b/jdk/src/java.base/share/classes/java/lang/StrictMath.java index 2278fe3d129..a15f11d8f38 100644 --- a/jdk/src/java.base/share/classes/java/lang/StrictMath.java +++ b/jdk/src/java.base/share/classes/java/lang/StrictMath.java @@ -70,7 +70,7 @@ import jdk.internal.HotSpotIntrinsicCandidate; * {@code subtractExact}, {@code multiplyExact}, and {@code toIntExact} * throw an {@code ArithmeticException} when the results overflow. * For other arithmetic operations such as divide, absolute value, - * increment, decrement, and negation overflow occurs only with + * increment by one, decrement by one, and negation overflow occurs only with * a specific minimum or maximum value and should be checked against * the minimum or maximum as appropriate. * @@ -802,6 +802,21 @@ public final class StrictMath { return Math.multiplyExact(x, y); } + /** + * Returns the product of the arguments, throwing an exception if the result + * overflows a {@code long}. + * + * @param x the first value + * @param y the second value + * @return the result + * @throws ArithmeticException if the result overflows a long + * @see Math#multiplyExact(long,int) + * @since 1.9 + */ + public static long multiplyExact(long x, int y) { + return Math.multiplyExact(x, y); + } + /** * Returns the product of the arguments, * throwing an exception if the result overflows a {@code long}. @@ -882,6 +897,30 @@ public final class StrictMath { return Math.floorDiv(x, y); } + /** + * Returns the largest (closest to positive infinity) + * {@code long} value that is less than or equal to the algebraic quotient. + * There is one special case, if the dividend is the + * {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1}, + * then integer overflow occurs and + * the result is equal to {@code Long.MIN_VALUE}. + *

        + * See {@link Math#floorDiv(int, int) Math.floorDiv} for examples and + * a comparison to the integer division {@code /} operator. + * + * @param x the dividend + * @param y the divisor + * @return the largest (closest to positive infinity) + * {@code int} value that is less than or equal to the algebraic quotient. + * @throws ArithmeticException if the divisor {@code y} is zero + * @see Math#floorDiv(long, int) + * @see Math#floor(double) + * @since 1.9 + */ + public static long floorDiv(long x, int y) { + return Math.floorDiv(x, y); + } + /** * Returns the largest (closest to positive infinity) * {@code long} value that is less than or equal to the algebraic quotient. @@ -932,6 +971,35 @@ public final class StrictMath { public static int floorMod(int x, int y) { return Math.floorMod(x , y); } + + /** + * Returns the floor modulus of the {@code long} and {@int} arguments. + *

        + * The floor modulus is {@code x - (floorDiv(x, y) * y)}, + * has the same sign as the divisor {@code y}, and + * is in the range of {@code -abs(y) < r < +abs(y)}. + * + *

        + * The relationship between {@code floorDiv} and {@code floorMod} is such that: + *

          + *
        • {@code floorDiv(x, y) * y + floorMod(x, y) == x} + *
        + *

        + * See {@link Math#floorMod(int, int) Math.floorMod} for examples and + * a comparison to the {@code %} operator. + * + * @param x the dividend + * @param y the divisor + * @return the floor modulus {@code x - (floorDiv(x, y) * y)} + * @throws ArithmeticException if the divisor {@code y} is zero + * @see Math#floorMod(long, int) + * @see StrictMath#floorDiv(long, int) + * @since 1.9 + */ + public static int floorMod(long x, int y) { + return Math.floorMod(x , y); + } + /** * Returns the floor modulus of the {@code long} arguments. *

        diff --git a/jdk/src/java.base/share/classes/java/time/Instant.java b/jdk/src/java.base/share/classes/java/time/Instant.java index 84056b75461..7f526e68c6b 100644 --- a/jdk/src/java.base/share/classes/java/time/Instant.java +++ b/jdk/src/java.base/share/classes/java/time/Instant.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -342,7 +342,7 @@ public final class Instant */ public static Instant ofEpochMilli(long epochMilli) { long secs = Math.floorDiv(epochMilli, 1000); - int mos = (int)Math.floorMod(epochMilli, 1000); + int mos = Math.floorMod(epochMilli, 1000); return create(secs, mos * 1000_000); } diff --git a/jdk/src/java.base/share/classes/java/time/LocalDate.java b/jdk/src/java.base/share/classes/java/time/LocalDate.java index 940f21f0f1e..62db9872bcf 100644 --- a/jdk/src/java.base/share/classes/java/time/LocalDate.java +++ b/jdk/src/java.base/share/classes/java/time/LocalDate.java @@ -826,7 +826,7 @@ public final class LocalDate * @return the day-of-week, not null */ public DayOfWeek getDayOfWeek() { - int dow0 = (int)Math.floorMod(toEpochDay() + 3, 7); + int dow0 = Math.floorMod(toEpochDay() + 3, 7); return DayOfWeek.of(dow0 + 1); } @@ -1329,7 +1329,7 @@ public final class LocalDate long monthCount = year * 12L + (month - 1); long calcMonths = monthCount + monthsToAdd; // safe overflow int newYear = YEAR.checkValidIntValue(Math.floorDiv(calcMonths, 12)); - int newMonth = (int)Math.floorMod(calcMonths, 12) + 1; + int newMonth = Math.floorMod(calcMonths, 12) + 1; return resolvePreviousValid(newYear, newMonth, day); } diff --git a/jdk/src/java.base/share/classes/java/time/LocalDateTime.java b/jdk/src/java.base/share/classes/java/time/LocalDateTime.java index 2195cae5154..0366333638d 100644 --- a/jdk/src/java.base/share/classes/java/time/LocalDateTime.java +++ b/jdk/src/java.base/share/classes/java/time/LocalDateTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -418,7 +418,7 @@ public final class LocalDateTime NANO_OF_SECOND.checkValidValue(nanoOfSecond); long localSecond = epochSecond + offset.getTotalSeconds(); // overflow caught later long localEpochDay = Math.floorDiv(localSecond, SECONDS_PER_DAY); - int secsOfDay = (int)Math.floorMod(localSecond, SECONDS_PER_DAY); + int secsOfDay = Math.floorMod(localSecond, SECONDS_PER_DAY); LocalDate date = LocalDate.ofEpochDay(localEpochDay); LocalTime time = LocalTime.ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + nanoOfSecond); return new LocalDateTime(date, time); diff --git a/jdk/src/java.base/share/classes/java/time/LocalTime.java b/jdk/src/java.base/share/classes/java/time/LocalTime.java index b951c877680..4b0456adea0 100644 --- a/jdk/src/java.base/share/classes/java/time/LocalTime.java +++ b/jdk/src/java.base/share/classes/java/time/LocalTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -361,7 +361,7 @@ public final class LocalTime Objects.requireNonNull(zone, "zone"); ZoneOffset offset = zone.getRules().getOffset(instant); long localSecond = instant.getEpochSecond() + offset.getTotalSeconds(); - int secsOfDay = (int) Math.floorMod(localSecond, SECONDS_PER_DAY); + int secsOfDay = Math.floorMod(localSecond, SECONDS_PER_DAY); return ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + instant.getNano()); } diff --git a/jdk/src/java.base/share/classes/java/time/OffsetTime.java b/jdk/src/java.base/share/classes/java/time/OffsetTime.java index cbfeb19e4d4..65cf560f2bb 100644 --- a/jdk/src/java.base/share/classes/java/time/OffsetTime.java +++ b/jdk/src/java.base/share/classes/java/time/OffsetTime.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -258,7 +258,7 @@ public final class OffsetTime ZoneRules rules = zone.getRules(); ZoneOffset offset = rules.getOffset(instant); long localSecond = instant.getEpochSecond() + offset.getTotalSeconds(); // overflow caught later - int secsOfDay = (int) Math.floorMod(localSecond, SECONDS_PER_DAY); + int secsOfDay = Math.floorMod(localSecond, SECONDS_PER_DAY); LocalTime time = LocalTime.ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + instant.getNano()); return new OffsetTime(time, offset); } diff --git a/jdk/src/java.base/share/classes/java/time/YearMonth.java b/jdk/src/java.base/share/classes/java/time/YearMonth.java index 2fbd95b6ff5..31c6a5a46eb 100644 --- a/jdk/src/java.base/share/classes/java/time/YearMonth.java +++ b/jdk/src/java.base/share/classes/java/time/YearMonth.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -850,7 +850,7 @@ public final class YearMonth long monthCount = year * 12L + (month - 1); long calcMonths = monthCount + monthsToAdd; // safe overflow int newYear = YEAR.checkValidIntValue(Math.floorDiv(calcMonths, 12)); - int newMonth = (int)Math.floorMod(calcMonths, 12) + 1; + int newMonth = Math.floorMod(calcMonths, 12) + 1; return with(newYear, newMonth); } diff --git a/jdk/src/java.base/share/classes/java/time/chrono/HijrahDate.java b/jdk/src/java.base/share/classes/java/time/chrono/HijrahDate.java index 9d5059eba20..60d0529f791 100644 --- a/jdk/src/java.base/share/classes/java/time/chrono/HijrahDate.java +++ b/jdk/src/java.base/share/classes/java/time/chrono/HijrahDate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -497,7 +497,7 @@ public final class HijrahDate * @return the day-of-week; computed from the epochday */ private int getDayOfWeek() { - int dow0 = (int)Math.floorMod(toEpochDay() + 3, 7); + int dow0 = Math.floorMod(toEpochDay() + 3, 7); return dow0 + 1; } diff --git a/jdk/test/java/lang/Math/DivModTests.java b/jdk/test/java/lang/Math/DivModTests.java index fbd98e62c8a..772bb1c91f1 100644 --- a/jdk/test/java/lang/Math/DivModTests.java +++ b/jdk/test/java/lang/Math/DivModTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -184,7 +184,7 @@ public class DivModTests { } /** - * Test the integer floorDiv and floorMod methods. + * Test the long floorDiv and floorMod methods. * Math and StrictMath are tested and the same results are expected for both. */ static void testLongFloorDivMod(long x, long y, Object divExpected, Object modExpected) { @@ -252,6 +252,110 @@ public class DivModTests { } } + /** + * Test the floorDiv and floorMod methods for mixed long and int. + */ + static void testLongIntFloorDivMod() { + testLongIntFloorDivMod(4L, 0, new ArithmeticException(), new ArithmeticException()); // Should throw ArithmeticException + testLongIntFloorDivMod(4L, 3, 1L, 1); + testLongIntFloorDivMod(3L, 3, 1L, 0); + testLongIntFloorDivMod(2L, 3, 0L, 2); + testLongIntFloorDivMod(1L, 3, 0L, 1); + testLongIntFloorDivMod(0L, 3, 0L, 0); + testLongIntFloorDivMod(4L, -3, -2L, -2); + testLongIntFloorDivMod(3L, -3, -1L, 0); + testLongIntFloorDivMod(2L, -3, -1L, -1); + testLongIntFloorDivMod(1L, -3, -1L, -2); + testLongIntFloorDivMod(0L, -3, 0L, 0); + testLongIntFloorDivMod(-1L, 3, -1L, 2); + testLongIntFloorDivMod(-2L, 3, -1L, 1); + testLongIntFloorDivMod(-3L, 3, -1L, 0); + testLongIntFloorDivMod(-4L, 3, -2L, 2); + testLongIntFloorDivMod(-1L, -3, 0L, -1); + testLongIntFloorDivMod(-2L, -3, 0L, -2); + testLongIntFloorDivMod(-3L, -3, 1L, 0); + testLongIntFloorDivMod(-4L, -3, 1L, -1); + + testLongIntFloorDivMod(Long.MAX_VALUE, 1, Long.MAX_VALUE, 0L); + testLongIntFloorDivMod(Long.MAX_VALUE, -1, -Long.MAX_VALUE, 0L); + testLongIntFloorDivMod(Long.MAX_VALUE, 3, Long.MAX_VALUE / 3L, 1L); + testLongIntFloorDivMod(Long.MAX_VALUE - 1L, 3, (Long.MAX_VALUE - 1L) / 3L, 0L); + testLongIntFloorDivMod(Long.MIN_VALUE, 3, Long.MIN_VALUE / 3L - 1L, 1L); + testLongIntFloorDivMod(Long.MIN_VALUE + 1L, 3, Long.MIN_VALUE / 3L - 1L, 2L); + testLongIntFloorDivMod(Long.MIN_VALUE + 1, -1, Long.MAX_VALUE, 0L); + // Special case of integer overflow + testLongIntFloorDivMod(Long.MIN_VALUE, -1, Long.MIN_VALUE, 0L); + } + + /** + * Test the integer floorDiv and floorMod methods. + * Math and StrictMath are tested and the same results are expected for both. + */ + static void testLongIntFloorDivMod(long x, int y, Object divExpected, Object modExpected) { + testLongIntFloorDiv(x, y, divExpected); + testLongIntFloorMod(x, y, modExpected); + } + + /** + * Test FloorDiv with long arguments against expected value. + * The expected value is usually a Long but in some cases is + * an ArithmeticException. + * + * @param x dividend + * @param y modulus + * @param expected expected value, + */ + static void testLongIntFloorDiv(long x, int y, Object expected) { + Object result = doFloorDiv(x, y); + if (!resultEquals(result, expected)) { + fail("FAIL: long Math.floorDiv(%d, %d) = %s; expected %s%n", x, y, result, expected); + } + + Object strict_result = doStrictFloorDiv(x, y); + if (!resultEquals(strict_result, expected)) { + fail("FAIL: long StrictMath.floorDiv(%d, %d) = %s; expected %s%n", x, y, strict_result, expected); + } + } + + /** + * Test FloorMod of long arguments against expected value. + * The expected value is usually a Long but in some cases is + * an ArithmeticException. + * + * @param x dividend + * @param y modulus + * @param expected expected value + */ + static void testLongIntFloorMod(long x, int y, Object expected) { + Object result = doFloorMod(x, y); + if (!resultEquals(result, expected)) { + fail("FAIL: long Math.floorMod(%d, %d) = %s; expected %s%n", x, y, result, expected); + } + + Object strict_result = doStrictFloorMod(x, y); + if (!resultEquals(strict_result, expected)) { + fail("FAIL: long StrictMath.floorMod(%d, %d) = %s; expected %s%n", x, y, strict_result, expected); + } + + try { + // Verify the result against BigDecimal rounding mode. + BigDecimal xD = new BigDecimal(x); + BigDecimal yD = new BigDecimal(y); + BigDecimal resultD = xD.divide(yD, RoundingMode.FLOOR); + resultD = resultD.multiply(yD); + resultD = xD.subtract(resultD); + long fr = resultD.longValue(); + if (!result.equals(fr)) { + fail("FAIL: Long.floorMod(%d, %d) = %d is different than BigDecimal result: %d%n", x, y, result, fr); + + } + } catch (ArithmeticException ae) { + if (y != 0) { + fail("FAIL: long Math.floorMod(%d, %d); unexpected ArithmeticException from bigdecimal"); + } + } + } + /** * Invoke floorDiv and return the result or any exception. * @param x the x value @@ -266,6 +370,20 @@ public class DivModTests { } } + /** + * Invoke floorDiv and return the result or any exception. + * @param x the x value + * @param y the y value + * @return the result Integer or an exception. + */ + static Object doFloorDiv(long x, int y) { + try { + return Math.floorDiv(x, y); + } catch (ArithmeticException ae) { + return ae; + } + } + /** * Invoke floorDiv and return the result or any exception. * @param x the x value @@ -294,6 +412,20 @@ public class DivModTests { } } + /** + * Invoke floorDiv and return the result or any exception. + * @param x the x value + * @param y the y value + * @return the result Integer or an exception. + */ + static Object doFloorMod(long x, int y) { + try { + return Math.floorMod(x, y); + } catch (ArithmeticException ae) { + return ae; + } + } + /** * Invoke floorDiv and return the result or any exception. * @param x the x value @@ -322,6 +454,20 @@ public class DivModTests { } } + /** + * Invoke floorDiv and return the result or any exception. + * @param x the x value + * @param y the y value + * @return the result Integer or an exception. + */ + static Object doStrictFloorDiv(long x, int y) { + try { + return StrictMath.floorDiv(x, y); + } catch (ArithmeticException ae) { + return ae; + } + } + /** * Invoke floorDiv and return the result or any exception. * @param x the x value @@ -350,6 +496,20 @@ public class DivModTests { } } + /** + * Invoke floorDiv and return the result or any exception. + * @param x the x value + * @param y the y value + * @return the result Integer or an exception. + */ + static Object doStrictFloorMod(long x, int y) { + try { + return StrictMath.floorMod(x, y); + } catch (ArithmeticException ae) { + return ae; + } + } + /** * Invoke floorDiv and return the result or any exception. * @param x the x value diff --git a/jdk/test/java/lang/Math/ExactArithTests.java b/jdk/test/java/lang/Math/ExactArithTests.java index 709ea618cb0..37a8a1f009c 100644 --- a/jdk/test/java/lang/Math/ExactArithTests.java +++ b/jdk/test/java/lang/Math/ExactArithTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,6 +43,7 @@ public class ExactArithTests { public static void main(String[] args) { testIntegerExact(); testLongExact(); + testLongIntExact(); if (errors > 0) { throw new RuntimeException(errors + " errors found in ExactArithTests."); @@ -132,6 +133,7 @@ public class ExactArithTests { fail("FAIL: int Math.multiplyExact(" + x + " * " + y + ")" + "; Unexpected exception: " + ex); } } + try { // Test incrementExact int inc = Math.incrementExact(x); @@ -345,4 +347,60 @@ public class ExactArithTests { static boolean inLongRange(BigInteger value) { return value.bitLength() <= 63; } + + /** + * Test Math.multiplyExact method with {@code long} and {@code int} + * arguments. + */ + static void testLongIntExact() { + testLongIntExact(0, 0); + testLongIntExact(1, 1); + testLongIntExact(1, -1); + testLongIntExact(1000, 2000); + + testLongIntExact(Long.MIN_VALUE, Integer.MIN_VALUE); + testLongIntExact(Long.MAX_VALUE, Integer.MAX_VALUE); + testLongIntExact(Long.MIN_VALUE, 1); + testLongIntExact(Long.MAX_VALUE, 1); + testLongIntExact(Long.MIN_VALUE, 2); + testLongIntExact(Long.MAX_VALUE, 2); + testLongIntExact(Long.MIN_VALUE, -1); + testLongIntExact(Long.MAX_VALUE, -1); + testLongIntExact(Long.MIN_VALUE, -2); + testLongIntExact(Long.MAX_VALUE, -2); + testLongIntExact(Long.MIN_VALUE/2, 2); + testLongIntExact(Long.MAX_VALUE, 2); + testLongIntExact(Integer.MAX_VALUE, Integer.MAX_VALUE); + testLongIntExact(Integer.MAX_VALUE, -Integer.MAX_VALUE); + testLongIntExact((long)Integer.MAX_VALUE+1L, Integer.MAX_VALUE); + testLongIntExact((long)Integer.MAX_VALUE+1L, -Integer.MAX_VALUE+1); + testLongIntExact((long)Integer.MIN_VALUE-1L, Integer.MIN_VALUE); + testLongIntExact((long)Integer.MIN_VALUE-1, Integer.MAX_VALUE); + testLongIntExact(Integer.MIN_VALUE/2, 2); + } + + /** + * Test long-int exact arithmetic by comparing with the same operations using BigInteger + * and checking that the result is the same as the long truncation. + * Errors are reported with {@link fail}. + * + * @param x first parameter + * @param y second parameter + */ + static void testLongIntExact(long x, int y) { + BigInteger resultBig = null; + final BigInteger xBig = BigInteger.valueOf(x); + final BigInteger yBig = BigInteger.valueOf(y); + + try { + // Test multiplyExact + resultBig = xBig.multiply(yBig); + long product = Math.multiplyExact(x, y); + checkResult("long Math.multiplyExact", x, y, product, resultBig); + } catch (ArithmeticException ex) { + if (inLongRange(resultBig)) { + fail("FAIL: long Math.multiplyExact(" + x + " * " + y + ")" + "; Unexpected exception: " + ex); + } + } + } } -- GitLab From 43c73dc321c3eadb3ea9d1312485f5959c6468e6 Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Fri, 18 Mar 2016 15:20:43 +0100 Subject: [PATCH 116/400] 8154154: Separate G1 specific policy code from the CollectorPolicy class hierarchy Move G1 runtime policy code to new class G1Policy which is unrelated to CollectorPolicy Reviewed-by: kbarrett, ehelin --- .../share/vm/gc/g1/collectionSetChooser.cpp | 1 - .../src/share/vm/gc/g1/concurrentG1Refine.cpp | 1 - .../vm/gc/g1/concurrentG1RefineThread.cpp | 1 - .../share/vm/gc/g1/concurrentMarkThread.cpp | 6 +- .../share/vm/gc/g1/concurrentMarkThread.hpp | 4 +- hotspot/src/share/vm/gc/g1/g1Allocator.cpp | 1 - hotspot/src/share/vm/gc/g1/g1CardCounts.cpp | 2 - .../src/share/vm/gc/g1/g1CollectedHeap.cpp | 12 +- .../src/share/vm/gc/g1/g1CollectedHeap.hpp | 8 +- .../share/vm/gc/g1/g1CollectedHeap.inline.hpp | 1 - .../share/vm/gc/g1/g1CollectedHeap_ext.cpp | 4 + .../src/share/vm/gc/g1/g1CollectionSet.cpp | 6 +- .../src/share/vm/gc/g1/g1CollectionSet.hpp | 11 +- .../src/share/vm/gc/g1/g1CollectorPolicy.cpp | 1169 +--------------- .../src/share/vm/gc/g1/g1CollectorPolicy.hpp | 402 +----- .../src/share/vm/gc/g1/g1ConcurrentMark.cpp | 12 +- .../src/share/vm/gc/g1/g1HeapTransition.cpp | 2 +- hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp | 1 + .../share/vm/gc/g1/g1MonitoringSupport.cpp | 2 +- .../share/vm/gc/g1/g1ParScanThreadState.hpp | 2 +- hotspot/src/share/vm/gc/g1/g1Policy.cpp | 1187 +++++++++++++++++ hotspot/src/share/vm/gc/g1/g1Policy.hpp | 434 ++++++ hotspot/src/share/vm/gc/g1/g1RemSet.cpp | 1 - hotspot/src/share/vm/gc/g1/g1RemSet.hpp | 4 +- .../src/share/vm/gc/g1/g1RootProcessor.cpp | 2 +- .../src/share/vm/gc/g1/g1YoungGenSizer.cpp | 9 +- .../src/share/vm/gc/g1/g1YoungGenSizer.hpp | 12 +- .../vm/gc/g1/g1YoungRemSetSamplingThread.cpp | 4 +- .../vm/gc/g1/g1YoungRemSetSamplingThread.hpp | 2 +- hotspot/src/share/vm/gc/g1/heapRegion.cpp | 2 +- .../src/share/vm/gc/g1/vm_operations_g1.cpp | 2 +- hotspot/src/share/vm/gc/g1/youngList.cpp | 2 +- .../src/share/vm/gc/shared/vmGCOperations.cpp | 1 + .../src/share/vm/services/g1MemoryPool.cpp | 2 - 34 files changed, 1692 insertions(+), 1620 deletions(-) create mode 100644 hotspot/src/share/vm/gc/g1/g1Policy.cpp create mode 100644 hotspot/src/share/vm/gc/g1/g1Policy.hpp diff --git a/hotspot/src/share/vm/gc/g1/collectionSetChooser.cpp b/hotspot/src/share/vm/gc/g1/collectionSetChooser.cpp index caa45950f62..cc9dbf46e67 100644 --- a/hotspot/src/share/vm/gc/g1/collectionSetChooser.cpp +++ b/hotspot/src/share/vm/gc/g1/collectionSetChooser.cpp @@ -25,7 +25,6 @@ #include "precompiled.hpp" #include "gc/g1/collectionSetChooser.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/shared/space.inline.hpp" #include "runtime/atomic.inline.hpp" diff --git a/hotspot/src/share/vm/gc/g1/concurrentG1Refine.cpp b/hotspot/src/share/vm/gc/g1/concurrentG1Refine.cpp index e67c8932a8b..9295f71e656 100644 --- a/hotspot/src/share/vm/gc/g1/concurrentG1Refine.cpp +++ b/hotspot/src/share/vm/gc/g1/concurrentG1Refine.cpp @@ -27,7 +27,6 @@ #include "gc/g1/concurrentG1RefineThread.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1HotCardCache.hpp" -#include "gc/g1/g1Predictions.hpp" #include "runtime/java.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" diff --git a/hotspot/src/share/vm/gc/g1/concurrentG1RefineThread.cpp b/hotspot/src/share/vm/gc/g1/concurrentG1RefineThread.cpp index 8f9ebfbfb68..24826d50f74 100644 --- a/hotspot/src/share/vm/gc/g1/concurrentG1RefineThread.cpp +++ b/hotspot/src/share/vm/gc/g1/concurrentG1RefineThread.cpp @@ -26,7 +26,6 @@ #include "gc/g1/concurrentG1Refine.hpp" #include "gc/g1/concurrentG1RefineThread.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/suspendibleThreadSet.hpp" #include "logging/log.hpp" #include "memory/resourceArea.hpp" diff --git a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp index 9727b023268..469412245bf 100644 --- a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp +++ b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.cpp @@ -27,9 +27,9 @@ #include "gc/g1/concurrentMarkThread.inline.hpp" #include "gc/g1/g1Analytics.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/g1ConcurrentMark.inline.hpp" #include "gc/g1/g1MMUTracker.hpp" +#include "gc/g1/g1Policy.hpp" #include "gc/g1/suspendibleThreadSet.hpp" #include "gc/g1/vm_operations_g1.hpp" #include "gc/shared/gcId.hpp" @@ -80,7 +80,7 @@ public: }; // Marking pauses can be scheduled flexibly, so we might delay marking to meet MMU. -void ConcurrentMarkThread::delay_to_keep_mmu(G1CollectorPolicy* g1_policy, bool remark) { +void ConcurrentMarkThread::delay_to_keep_mmu(G1Policy* g1_policy, bool remark) { const G1Analytics* analytics = g1_policy->analytics(); if (g1_policy->adaptive_young_list_length()) { double now = os::elapsedTime(); @@ -111,7 +111,7 @@ void ConcurrentMarkThread::run_service() { _vtime_start = os::elapsedVTime(); G1CollectedHeap* g1h = G1CollectedHeap::heap(); - G1CollectorPolicy* g1_policy = g1h->g1_policy(); + G1Policy* g1_policy = g1h->g1_policy(); while (!should_terminate()) { // wait until started is set. diff --git a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.hpp b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.hpp index 2bdd7f3116d..be24fe8cfcb 100644 --- a/hotspot/src/share/vm/gc/g1/concurrentMarkThread.hpp +++ b/hotspot/src/share/vm/gc/g1/concurrentMarkThread.hpp @@ -31,7 +31,7 @@ // as well as handling various marking cleanup. class G1ConcurrentMark; -class G1CollectorPolicy; +class G1Policy; class ConcurrentMarkThread: public ConcurrentGCThread { friend class VMStructs; @@ -51,7 +51,7 @@ class ConcurrentMarkThread: public ConcurrentGCThread { volatile State _state; void sleepBeforeNextCycle(); - void delay_to_keep_mmu(G1CollectorPolicy* g1_policy, bool remark); + void delay_to_keep_mmu(G1Policy* g1_policy, bool remark); void run_service(); void stop_service(); diff --git a/hotspot/src/share/vm/gc/g1/g1Allocator.cpp b/hotspot/src/share/vm/gc/g1/g1Allocator.cpp index ad5aa0c556c..92c00936dff 100644 --- a/hotspot/src/share/vm/gc/g1/g1Allocator.cpp +++ b/hotspot/src/share/vm/gc/g1/g1Allocator.cpp @@ -27,7 +27,6 @@ #include "gc/g1/g1AllocRegion.inline.hpp" #include "gc/g1/g1EvacStats.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/g1MarkSweep.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionSet.inline.hpp" diff --git a/hotspot/src/share/vm/gc/g1/g1CardCounts.cpp b/hotspot/src/share/vm/gc/g1/g1CardCounts.cpp index af078c2b9b8..efa35bce179 100644 --- a/hotspot/src/share/vm/gc/g1/g1CardCounts.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CardCounts.cpp @@ -25,8 +25,6 @@ #include "precompiled.hpp" #include "gc/g1/g1CardCounts.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" -#include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/shared/cardTableModRefBS.hpp" #include "services/memTracker.hpp" #include "utilities/copy.hpp" diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index 3a775d5bca1..4c74bc8ce43 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -45,6 +45,7 @@ #include "gc/g1/g1MarkSweep.hpp" #include "gc/g1/g1OopClosures.inline.hpp" #include "gc/g1/g1ParScanThreadState.inline.hpp" +#include "gc/g1/g1Policy.hpp" #include "gc/g1/g1RegionToSpaceMapper.hpp" #include "gc/g1/g1RemSet.inline.hpp" #include "gc/g1/g1RootClosures.hpp" @@ -1744,10 +1745,11 @@ void G1CollectedHeap::shrink(size_t shrink_bytes) { // Public methods. -G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* policy_) : +G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* collector_policy) : CollectedHeap(), - _g1_policy(policy_), - _collection_set(this), + _collector_policy(collector_policy), + _g1_policy(create_g1_policy()), + _collection_set(this, _g1_policy), _dirty_card_queue_set(false), _is_alive_closure_cm(this), _is_alive_closure_stw(this), @@ -2134,7 +2136,7 @@ void G1CollectedHeap::ref_processing_init() { } CollectorPolicy* G1CollectedHeap::collector_policy() const { - return g1_policy(); + return _collector_policy; } size_t G1CollectedHeap::capacity() const { @@ -4859,7 +4861,7 @@ void G1CollectedHeap::free_collection_set(HeapRegion* cs_head, EvacuationInfo& e // head and length, and unlink any young regions in the code below _young_list->clear(); - G1CollectorPolicy* policy = g1_policy(); + G1Policy* policy = g1_policy(); double start_sec = os::elapsedTime(); bool non_young = true; diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp index e98d57af7fb..03a5f845a0f 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp @@ -68,6 +68,7 @@ class CompactibleSpaceClosure; class Space; class G1CollectionSet; class G1CollectorPolicy; +class G1Policy; class G1RemSet; class HeapRegionRemSetIterator; class G1ConcurrentMark; @@ -137,6 +138,7 @@ class G1CollectedHeap : public CollectedHeap { private: WorkGang* _workers; + G1CollectorPolicy* _collector_policy; static size_t _humongous_object_threshold_in_words; @@ -290,6 +292,8 @@ private: size_t size, size_t translation_factor); + static G1Policy* create_g1_policy(); + void trace_heap(GCWhen::Type when, const GCTracer* tracer); void process_weak_jni_handles(); @@ -360,7 +364,7 @@ protected: YoungList* _young_list; // The current policy object for the collector. - G1CollectorPolicy* _g1_policy; + G1Policy* _g1_policy; G1HeapSizingPolicy* _heap_sizing_policy; G1CollectionSet _collection_set; @@ -979,7 +983,7 @@ public: G1CollectorState* collector_state() { return &_collector_state; } // The current policy object for the collector. - G1CollectorPolicy* g1_policy() const { return _g1_policy; } + G1Policy* g1_policy() const { return _g1_policy; } const G1CollectionSet* collection_set() const { return &_collection_set; } G1CollectionSet* collection_set() { return &_collection_set; } diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.inline.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.inline.hpp index 040367b5be1..05b24e0bf52 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.inline.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.inline.hpp @@ -26,7 +26,6 @@ #define SHARE_VM_GC_G1_G1COLLECTEDHEAP_INLINE_HPP #include "gc/g1/g1CollectedHeap.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/g1CollectorState.hpp" #include "gc/g1/g1ConcurrentMark.inline.hpp" #include "gc/g1/g1SATBCardTableModRefBS.hpp" diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp index a4a9617edb4..a58901f32a8 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp @@ -38,3 +38,7 @@ HeapRegion* G1CollectedHeap::new_heap_region(uint hrs_index, MemRegion mr) { return new HeapRegion(hrs_index, bot(), mr); } + +G1Policy* G1CollectedHeap::create_g1_policy() { + return new G1Policy; +} diff --git a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp index 720c828d1bc..bb041c65258 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp @@ -25,8 +25,8 @@ #include "precompiled.hpp" #include "gc/g1/g1CollectedHeap.hpp" #include "gc/g1/g1CollectionSet.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/g1CollectorState.hpp" +#include "gc/g1/g1Policy.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" #include "gc/g1/heapRegionSet.hpp" @@ -49,9 +49,9 @@ double G1CollectionSet::predict_region_elapsed_time_ms(HeapRegion* hr) { } -G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h) : +G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy) : _g1(g1h), - _policy(NULL), + _policy(policy), _cset_chooser(new CollectionSetChooser()), _eden_region_length(0), _survivor_region_length(0), diff --git a/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp b/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp index 75f93071624..0ab3b8766b8 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp @@ -31,14 +31,14 @@ #include "utilities/globalDefinitions.hpp" class G1CollectedHeap; -class G1CollectorPolicy; class G1CollectorState; class G1GCPhaseTimes; +class G1Policy; class HeapRegion; class G1CollectionSet VALUE_OBJ_CLASS_SPEC { G1CollectedHeap* _g1; - G1CollectorPolicy* _policy; + G1Policy* _policy; CollectionSetChooser* _cset_chooser; @@ -110,14 +110,9 @@ class G1CollectionSet VALUE_OBJ_CLASS_SPEC { double predict_region_elapsed_time_ms(HeapRegion* hr); public: - G1CollectionSet(G1CollectedHeap* g1h); + G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy); ~G1CollectionSet(); - void set_policy(G1CollectorPolicy* g1p) { - assert(_policy == NULL, "should only initialize once"); - _policy = g1p; - } - CollectionSetChooser* cset_chooser(); void init_region_lengths(uint eden_cset_region_length, diff --git a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp index 75c75ded31c..30e01594668 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp @@ -23,43 +23,16 @@ */ #include "precompiled.hpp" -#include "gc/g1/concurrentG1Refine.hpp" -#include "gc/g1/concurrentMarkThread.inline.hpp" #include "gc/g1/g1Analytics.hpp" -#include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectionSet.hpp" #include "gc/g1/g1CollectorPolicy.hpp" -#include "gc/g1/g1ConcurrentMark.hpp" -#include "gc/g1/g1IHOPControl.hpp" -#include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1YoungGenSizer.hpp" -#include "gc/g1/heapRegion.inline.hpp" +#include "gc/g1/heapRegion.hpp" #include "gc/g1/heapRegionRemSet.hpp" #include "gc/shared/gcPolicyCounters.hpp" -#include "runtime/arguments.hpp" -#include "runtime/java.hpp" -#include "runtime/mutexLocker.hpp" +#include "runtime/globals.hpp" #include "utilities/debug.hpp" -#include "utilities/pair.hpp" -G1CollectorPolicy::G1CollectorPolicy() : - _predictor(G1ConfidencePercent / 100.0), - _analytics(new G1Analytics(&_predictor)), - _pause_time_target_ms((double) MaxGCPauseMillis), - _rs_lengths_prediction(0), - _max_survivor_regions(0), - _survivors_age_table(true), - - _bytes_allocated_in_old_since_last_gc(0), - _ihop_control(NULL), - _initial_mark_to_mixed() { - - // SurvRateGroups below must be initialized after the predictor because they - // indirectly use it through this object passed to their constructor. - _short_lived_surv_rate_group = - new SurvRateGroup(&_predictor, "Short Lived", G1YoungSurvRateNumRegionsSummary); - _survivor_surv_rate_group = - new SurvRateGroup(&_predictor, "Survivor", G1YoungSurvRateNumRegionsSummary); +G1CollectorPolicy::G1CollectorPolicy() { // Set up the region size and associated fields. Given that the // policy is created before the heap, we have to set this up here, @@ -75,8 +48,6 @@ G1CollectorPolicy::G1CollectorPolicy() : HeapRegion::setup_heap_region_size(InitialHeapSize, MaxHeapSize); HeapRegionRemSet::setup_remset_size(); - _phase_times = new G1GCPhaseTimes(ParallelGCThreads); - // Below, we might need to calculate the pause time target based on // the pause interval. When we do so we are going to give G1 maximum // flexibility and allow it to do pauses when it needs to. So, we'll @@ -113,25 +84,6 @@ G1CollectorPolicy::G1CollectorPolicy() : } guarantee(GCPauseIntervalMillis >= 1, "Constraint for GCPauseIntervalMillis should guarantee that value is >= 1"); guarantee(GCPauseIntervalMillis > MaxGCPauseMillis, "Constraint for GCPauseIntervalMillis should guarantee that GCPauseIntervalMillis > MaxGCPauseMillis"); - - double max_gc_time = (double) MaxGCPauseMillis / 1000.0; - double time_slice = (double) GCPauseIntervalMillis / 1000.0; - _mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time); - - _tenuring_threshold = MaxTenuringThreshold; - - - guarantee(G1ReservePercent <= 50, "Range checking should not allow values over 50."); - _reserve_factor = (double) G1ReservePercent / 100.0; - // This will be set when the heap is expanded - // for the first time during initialization. - _reserve_regions = 0; - - _ihop_control = create_ihop_control(); -} - -G1CollectorPolicy::~G1CollectorPolicy() { - delete _ihop_control; } void G1CollectorPolicy::initialize_alignments() { @@ -141,16 +93,6 @@ void G1CollectorPolicy::initialize_alignments() { _heap_alignment = MAX3(card_table_alignment, _space_alignment, page_size); } -G1CollectorState* G1CollectorPolicy::collector_state() const { return _g1->collector_state(); } - -void G1CollectorPolicy::post_heap_initialize() { - uintx max_regions = G1CollectedHeap::heap()->max_regions(); - size_t max_young_size = (size_t)_young_gen_sizer->max_young_length(max_regions) * HeapRegion::GrainBytes; - if (max_young_size != MaxNewSize) { - FLAG_SET_ERGO(size_t, MaxNewSize, max_young_size); - } -} - void G1CollectorPolicy::initialize_flags() { if (G1HeapRegionSize != HeapRegion::GrainBytes) { FLAG_SET_ERGO(size_t, G1HeapRegionSize, HeapRegion::GrainBytes); @@ -159,1114 +101,9 @@ void G1CollectorPolicy::initialize_flags() { guarantee(SurvivorRatio >= 1, "Range checking for SurvivorRatio should guarantee that value is >= 1"); CollectorPolicy::initialize_flags(); - _young_gen_sizer = new G1YoungGenSizer(); // Must be after call to initialize_flags -} - - -void G1CollectorPolicy::init() { - // Set aside an initial future to_space. - _g1 = G1CollectedHeap::heap(); - _collection_set = _g1->collection_set(); - _collection_set->set_policy(this); - - assert(Heap_lock->owned_by_self(), "Locking discipline."); - - initialize_gc_policy_counters(); - - if (adaptive_young_list_length()) { - _young_list_fixed_length = 0; - } else { - _young_list_fixed_length = _young_gen_sizer->min_desired_young_length(); - } - _free_regions_at_end_of_collection = _g1->num_free_regions(); - - update_young_list_max_and_target_length(); - // We may immediately start allocating regions and placing them on the - // collection set list. Initialize the per-collection set info - _collection_set->start_incremental_building(); -} - -void G1CollectorPolicy::note_gc_start() { - phase_times()->note_gc_start(); } // Create the jstat counters for the policy. void G1CollectorPolicy::initialize_gc_policy_counters() { _gc_policy_counters = new GCPolicyCounters("GarbageFirst", 1, 3); } - -bool G1CollectorPolicy::predict_will_fit(uint young_length, - double base_time_ms, - uint base_free_regions, - double target_pause_time_ms) const { - if (young_length >= base_free_regions) { - // end condition 1: not enough space for the young regions - return false; - } - - double accum_surv_rate = accum_yg_surv_rate_pred((int) young_length - 1); - size_t bytes_to_copy = - (size_t) (accum_surv_rate * (double) HeapRegion::GrainBytes); - double copy_time_ms = _analytics->predict_object_copy_time_ms(bytes_to_copy, - collector_state()->during_concurrent_mark()); - double young_other_time_ms = _analytics->predict_young_other_time_ms(young_length); - double pause_time_ms = base_time_ms + copy_time_ms + young_other_time_ms; - if (pause_time_ms > target_pause_time_ms) { - // end condition 2: prediction is over the target pause time - return false; - } - - size_t free_bytes = (base_free_regions - young_length) * HeapRegion::GrainBytes; - - // When copying, we will likely need more bytes free than is live in the region. - // Add some safety margin to factor in the confidence of our guess, and the - // natural expected waste. - // (100.0 / G1ConfidencePercent) is a scale factor that expresses the uncertainty - // of the calculation: the lower the confidence, the more headroom. - // (100 + TargetPLABWastePct) represents the increase in expected bytes during - // copying due to anticipated waste in the PLABs. - double safety_factor = (100.0 / G1ConfidencePercent) * (100 + TargetPLABWastePct) / 100.0; - size_t expected_bytes_to_copy = (size_t)(safety_factor * bytes_to_copy); - - if (expected_bytes_to_copy > free_bytes) { - // end condition 3: out-of-space - return false; - } - - // success! - return true; -} - -void G1CollectorPolicy::record_new_heap_size(uint new_number_of_regions) { - // re-calculate the necessary reserve - double reserve_regions_d = (double) new_number_of_regions * _reserve_factor; - // We use ceiling so that if reserve_regions_d is > 0.0 (but - // smaller than 1.0) we'll get 1. - _reserve_regions = (uint) ceil(reserve_regions_d); - - _young_gen_sizer->heap_size_changed(new_number_of_regions); - - _ihop_control->update_target_occupancy(new_number_of_regions * HeapRegion::GrainBytes); -} - -uint G1CollectorPolicy::calculate_young_list_desired_min_length( - uint base_min_length) const { - uint desired_min_length = 0; - if (adaptive_young_list_length()) { - if (_analytics->num_alloc_rate_ms() > 3) { - double now_sec = os::elapsedTime(); - double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0; - double alloc_rate_ms = _analytics->predict_alloc_rate_ms(); - desired_min_length = (uint) ceil(alloc_rate_ms * when_ms); - } else { - // otherwise we don't have enough info to make the prediction - } - } - desired_min_length += base_min_length; - // make sure we don't go below any user-defined minimum bound - return MAX2(_young_gen_sizer->min_desired_young_length(), desired_min_length); -} - -uint G1CollectorPolicy::calculate_young_list_desired_max_length() const { - // Here, we might want to also take into account any additional - // constraints (i.e., user-defined minimum bound). Currently, we - // effectively don't set this bound. - return _young_gen_sizer->max_desired_young_length(); -} - -uint G1CollectorPolicy::update_young_list_max_and_target_length() { - return update_young_list_max_and_target_length(_analytics->predict_rs_lengths()); -} - -uint G1CollectorPolicy::update_young_list_max_and_target_length(size_t rs_lengths) { - uint unbounded_target_length = update_young_list_target_length(rs_lengths); - update_max_gc_locker_expansion(); - return unbounded_target_length; -} - -uint G1CollectorPolicy::update_young_list_target_length(size_t rs_lengths) { - YoungTargetLengths young_lengths = young_list_target_lengths(rs_lengths); - _young_list_target_length = young_lengths.first; - return young_lengths.second; -} - -G1CollectorPolicy::YoungTargetLengths G1CollectorPolicy::young_list_target_lengths(size_t rs_lengths) const { - YoungTargetLengths result; - - // Calculate the absolute and desired min bounds first. - - // This is how many young regions we already have (currently: the survivors). - const uint base_min_length = _g1->young_list()->survivor_length(); - uint desired_min_length = calculate_young_list_desired_min_length(base_min_length); - // This is the absolute minimum young length. Ensure that we - // will at least have one eden region available for allocation. - uint absolute_min_length = base_min_length + MAX2(_g1->young_list()->eden_length(), (uint)1); - // If we shrank the young list target it should not shrink below the current size. - desired_min_length = MAX2(desired_min_length, absolute_min_length); - // Calculate the absolute and desired max bounds. - - uint desired_max_length = calculate_young_list_desired_max_length(); - - uint young_list_target_length = 0; - if (adaptive_young_list_length()) { - if (collector_state()->gcs_are_young()) { - young_list_target_length = - calculate_young_list_target_length(rs_lengths, - base_min_length, - desired_min_length, - desired_max_length); - } else { - // Don't calculate anything and let the code below bound it to - // the desired_min_length, i.e., do the next GC as soon as - // possible to maximize how many old regions we can add to it. - } - } else { - // The user asked for a fixed young gen so we'll fix the young gen - // whether the next GC is young or mixed. - young_list_target_length = _young_list_fixed_length; - } - - result.second = young_list_target_length; - - // We will try our best not to "eat" into the reserve. - uint absolute_max_length = 0; - if (_free_regions_at_end_of_collection > _reserve_regions) { - absolute_max_length = _free_regions_at_end_of_collection - _reserve_regions; - } - if (desired_max_length > absolute_max_length) { - desired_max_length = absolute_max_length; - } - - // Make sure we don't go over the desired max length, nor under the - // desired min length. In case they clash, desired_min_length wins - // which is why that test is second. - if (young_list_target_length > desired_max_length) { - young_list_target_length = desired_max_length; - } - if (young_list_target_length < desired_min_length) { - young_list_target_length = desired_min_length; - } - - assert(young_list_target_length > base_min_length, - "we should be able to allocate at least one eden region"); - assert(young_list_target_length >= absolute_min_length, "post-condition"); - - result.first = young_list_target_length; - return result; -} - -uint -G1CollectorPolicy::calculate_young_list_target_length(size_t rs_lengths, - uint base_min_length, - uint desired_min_length, - uint desired_max_length) const { - assert(adaptive_young_list_length(), "pre-condition"); - assert(collector_state()->gcs_are_young(), "only call this for young GCs"); - - // In case some edge-condition makes the desired max length too small... - if (desired_max_length <= desired_min_length) { - return desired_min_length; - } - - // We'll adjust min_young_length and max_young_length not to include - // the already allocated young regions (i.e., so they reflect the - // min and max eden regions we'll allocate). The base_min_length - // will be reflected in the predictions by the - // survivor_regions_evac_time prediction. - assert(desired_min_length > base_min_length, "invariant"); - uint min_young_length = desired_min_length - base_min_length; - assert(desired_max_length > base_min_length, "invariant"); - uint max_young_length = desired_max_length - base_min_length; - - double target_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0; - double survivor_regions_evac_time = predict_survivor_regions_evac_time(); - size_t pending_cards = _analytics->predict_pending_cards(); - size_t adj_rs_lengths = rs_lengths + _analytics->predict_rs_length_diff(); - size_t scanned_cards = _analytics->predict_card_num(adj_rs_lengths, /* gcs_are_young */ true); - double base_time_ms = - predict_base_elapsed_time_ms(pending_cards, scanned_cards) + - survivor_regions_evac_time; - uint available_free_regions = _free_regions_at_end_of_collection; - uint base_free_regions = 0; - if (available_free_regions > _reserve_regions) { - base_free_regions = available_free_regions - _reserve_regions; - } - - // Here, we will make sure that the shortest young length that - // makes sense fits within the target pause time. - - if (predict_will_fit(min_young_length, base_time_ms, - base_free_regions, target_pause_time_ms)) { - // The shortest young length will fit into the target pause time; - // we'll now check whether the absolute maximum number of young - // regions will fit in the target pause time. If not, we'll do - // a binary search between min_young_length and max_young_length. - if (predict_will_fit(max_young_length, base_time_ms, - base_free_regions, target_pause_time_ms)) { - // The maximum young length will fit into the target pause time. - // We are done so set min young length to the maximum length (as - // the result is assumed to be returned in min_young_length). - min_young_length = max_young_length; - } else { - // The maximum possible number of young regions will not fit within - // the target pause time so we'll search for the optimal - // length. The loop invariants are: - // - // min_young_length < max_young_length - // min_young_length is known to fit into the target pause time - // max_young_length is known not to fit into the target pause time - // - // Going into the loop we know the above hold as we've just - // checked them. Every time around the loop we check whether - // the middle value between min_young_length and - // max_young_length fits into the target pause time. If it - // does, it becomes the new min. If it doesn't, it becomes - // the new max. This way we maintain the loop invariants. - - assert(min_young_length < max_young_length, "invariant"); - uint diff = (max_young_length - min_young_length) / 2; - while (diff > 0) { - uint young_length = min_young_length + diff; - if (predict_will_fit(young_length, base_time_ms, - base_free_regions, target_pause_time_ms)) { - min_young_length = young_length; - } else { - max_young_length = young_length; - } - assert(min_young_length < max_young_length, "invariant"); - diff = (max_young_length - min_young_length) / 2; - } - // The results is min_young_length which, according to the - // loop invariants, should fit within the target pause time. - - // These are the post-conditions of the binary search above: - assert(min_young_length < max_young_length, - "otherwise we should have discovered that max_young_length " - "fits into the pause target and not done the binary search"); - assert(predict_will_fit(min_young_length, base_time_ms, - base_free_regions, target_pause_time_ms), - "min_young_length, the result of the binary search, should " - "fit into the pause target"); - assert(!predict_will_fit(min_young_length + 1, base_time_ms, - base_free_regions, target_pause_time_ms), - "min_young_length, the result of the binary search, should be " - "optimal, so no larger length should fit into the pause target"); - } - } else { - // Even the minimum length doesn't fit into the pause time - // target, return it as the result nevertheless. - } - return base_min_length + min_young_length; -} - -double G1CollectorPolicy::predict_survivor_regions_evac_time() const { - double survivor_regions_evac_time = 0.0; - for (HeapRegion * r = _g1->young_list()->first_survivor_region(); - r != NULL && r != _g1->young_list()->last_survivor_region()->get_next_young_region(); - r = r->get_next_young_region()) { - survivor_regions_evac_time += predict_region_elapsed_time_ms(r, collector_state()->gcs_are_young()); - } - return survivor_regions_evac_time; -} - -void G1CollectorPolicy::revise_young_list_target_length_if_necessary(size_t rs_lengths) { - guarantee( adaptive_young_list_length(), "should not call this otherwise" ); - - if (rs_lengths > _rs_lengths_prediction) { - // add 10% to avoid having to recalculate often - size_t rs_lengths_prediction = rs_lengths * 1100 / 1000; - update_rs_lengths_prediction(rs_lengths_prediction); - - update_young_list_max_and_target_length(rs_lengths_prediction); - } -} - -void G1CollectorPolicy::update_rs_lengths_prediction() { - update_rs_lengths_prediction(_analytics->predict_rs_lengths()); -} - -void G1CollectorPolicy::update_rs_lengths_prediction(size_t prediction) { - if (collector_state()->gcs_are_young() && adaptive_young_list_length()) { - _rs_lengths_prediction = prediction; - } -} - -#ifndef PRODUCT -bool G1CollectorPolicy::verify_young_ages() { - HeapRegion* head = _g1->young_list()->first_region(); - return - verify_young_ages(head, _short_lived_surv_rate_group); - // also call verify_young_ages on any additional surv rate groups -} - -bool -G1CollectorPolicy::verify_young_ages(HeapRegion* head, - SurvRateGroup *surv_rate_group) { - guarantee( surv_rate_group != NULL, "pre-condition" ); - - const char* name = surv_rate_group->name(); - bool ret = true; - int prev_age = -1; - - for (HeapRegion* curr = head; - curr != NULL; - curr = curr->get_next_young_region()) { - SurvRateGroup* group = curr->surv_rate_group(); - if (group == NULL && !curr->is_survivor()) { - log_error(gc, verify)("## %s: encountered NULL surv_rate_group", name); - ret = false; - } - - if (surv_rate_group == group) { - int age = curr->age_in_surv_rate_group(); - - if (age < 0) { - log_error(gc, verify)("## %s: encountered negative age", name); - ret = false; - } - - if (age <= prev_age) { - log_error(gc, verify)("## %s: region ages are not strictly increasing (%d, %d)", name, age, prev_age); - ret = false; - } - prev_age = age; - } - } - - return ret; -} -#endif // PRODUCT - -void G1CollectorPolicy::record_full_collection_start() { - _full_collection_start_sec = os::elapsedTime(); - // Release the future to-space so that it is available for compaction into. - collector_state()->set_full_collection(true); -} - -void G1CollectorPolicy::record_full_collection_end() { - // Consider this like a collection pause for the purposes of allocation - // since last pause. - double end_sec = os::elapsedTime(); - double full_gc_time_sec = end_sec - _full_collection_start_sec; - double full_gc_time_ms = full_gc_time_sec * 1000.0; - - _analytics->update_recent_gc_times(end_sec, full_gc_time_ms); - - collector_state()->set_full_collection(false); - - // "Nuke" the heuristics that control the young/mixed GC - // transitions and make sure we start with young GCs after the Full GC. - collector_state()->set_gcs_are_young(true); - collector_state()->set_last_young_gc(false); - collector_state()->set_initiate_conc_mark_if_possible(need_to_start_conc_mark("end of Full GC", 0)); - collector_state()->set_during_initial_mark_pause(false); - collector_state()->set_in_marking_window(false); - collector_state()->set_in_marking_window_im(false); - - _short_lived_surv_rate_group->start_adding_regions(); - // also call this on any additional surv rate groups - - _free_regions_at_end_of_collection = _g1->num_free_regions(); - // Reset survivors SurvRateGroup. - _survivor_surv_rate_group->reset(); - update_young_list_max_and_target_length(); - update_rs_lengths_prediction(); - cset_chooser()->clear(); - - _bytes_allocated_in_old_since_last_gc = 0; - - record_pause(FullGC, _full_collection_start_sec, end_sec); -} - -void G1CollectorPolicy::record_collection_pause_start(double start_time_sec) { - // We only need to do this here as the policy will only be applied - // to the GC we're about to start. so, no point is calculating this - // every time we calculate / recalculate the target young length. - update_survivors_policy(); - - assert(_g1->used() == _g1->recalculate_used(), - "sanity, used: " SIZE_FORMAT " recalculate_used: " SIZE_FORMAT, - _g1->used(), _g1->recalculate_used()); - - phase_times()->record_cur_collection_start_sec(start_time_sec); - _pending_cards = _g1->pending_card_num(); - - _collection_set->reset_bytes_used_before(); - _bytes_copied_during_gc = 0; - - collector_state()->set_last_gc_was_young(false); - - // do that for any other surv rate groups - _short_lived_surv_rate_group->stop_adding_regions(); - _survivors_age_table.clear(); - - assert( verify_young_ages(), "region age verification" ); -} - -void G1CollectorPolicy::record_concurrent_mark_init_end(double - mark_init_elapsed_time_ms) { - collector_state()->set_during_marking(true); - assert(!collector_state()->initiate_conc_mark_if_possible(), "we should have cleared it by now"); - collector_state()->set_during_initial_mark_pause(false); -} - -void G1CollectorPolicy::record_concurrent_mark_remark_start() { - _mark_remark_start_sec = os::elapsedTime(); - collector_state()->set_during_marking(false); -} - -void G1CollectorPolicy::record_concurrent_mark_remark_end() { - double end_time_sec = os::elapsedTime(); - double elapsed_time_ms = (end_time_sec - _mark_remark_start_sec)*1000.0; - _analytics->report_concurrent_mark_remark_times_ms(elapsed_time_ms); - _analytics->append_prev_collection_pause_end_ms(elapsed_time_ms); - - record_pause(Remark, _mark_remark_start_sec, end_time_sec); -} - -void G1CollectorPolicy::record_concurrent_mark_cleanup_start() { - _mark_cleanup_start_sec = os::elapsedTime(); -} - -void G1CollectorPolicy::record_concurrent_mark_cleanup_completed() { - bool should_continue_with_reclaim = next_gc_should_be_mixed("request last young-only gc", - "skip last young-only gc"); - collector_state()->set_last_young_gc(should_continue_with_reclaim); - // We skip the marking phase. - if (!should_continue_with_reclaim) { - abort_time_to_mixed_tracking(); - } - collector_state()->set_in_marking_window(false); -} - -double G1CollectorPolicy::average_time_ms(G1GCPhaseTimes::GCParPhases phase) const { - return phase_times()->average_time_ms(phase); -} - -double G1CollectorPolicy::young_other_time_ms() const { - return phase_times()->young_cset_choice_time_ms() + - phase_times()->young_free_cset_time_ms(); -} - -double G1CollectorPolicy::non_young_other_time_ms() const { - return phase_times()->non_young_cset_choice_time_ms() + - phase_times()->non_young_free_cset_time_ms(); - -} - -double G1CollectorPolicy::other_time_ms(double pause_time_ms) const { - return pause_time_ms - - average_time_ms(G1GCPhaseTimes::UpdateRS) - - average_time_ms(G1GCPhaseTimes::ScanRS) - - average_time_ms(G1GCPhaseTimes::ObjCopy) - - average_time_ms(G1GCPhaseTimes::Termination); -} - -double G1CollectorPolicy::constant_other_time_ms(double pause_time_ms) const { - return other_time_ms(pause_time_ms) - young_other_time_ms() - non_young_other_time_ms(); -} - -CollectionSetChooser* G1CollectorPolicy::cset_chooser() const { - return _collection_set->cset_chooser(); -} - -bool G1CollectorPolicy::about_to_start_mixed_phase() const { - return _g1->concurrent_mark()->cmThread()->during_cycle() || collector_state()->last_young_gc(); -} - -bool G1CollectorPolicy::need_to_start_conc_mark(const char* source, size_t alloc_word_size) { - if (about_to_start_mixed_phase()) { - return false; - } - - size_t marking_initiating_used_threshold = _ihop_control->get_conc_mark_start_threshold(); - - size_t cur_used_bytes = _g1->non_young_capacity_bytes(); - size_t alloc_byte_size = alloc_word_size * HeapWordSize; - size_t marking_request_bytes = cur_used_bytes + alloc_byte_size; - - bool result = false; - if (marking_request_bytes > marking_initiating_used_threshold) { - result = collector_state()->gcs_are_young() && !collector_state()->last_young_gc(); - log_debug(gc, ergo, ihop)("%s occupancy: " SIZE_FORMAT "B allocation request: " SIZE_FORMAT "B threshold: " SIZE_FORMAT "B (%1.2f) source: %s", - result ? "Request concurrent cycle initiation (occupancy higher than threshold)" : "Do not request concurrent cycle initiation (still doing mixed collections)", - cur_used_bytes, alloc_byte_size, marking_initiating_used_threshold, (double) marking_initiating_used_threshold / _g1->capacity() * 100, source); - } - - return result; -} - -// Anything below that is considered to be zero -#define MIN_TIMER_GRANULARITY 0.0000001 - -void G1CollectorPolicy::record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) { - double end_time_sec = os::elapsedTime(); - - size_t cur_used_bytes = _g1->used(); - assert(cur_used_bytes == _g1->recalculate_used(), "It should!"); - bool last_pause_included_initial_mark = false; - bool update_stats = !_g1->evacuation_failed(); - - NOT_PRODUCT(_short_lived_surv_rate_group->print()); - - record_pause(young_gc_pause_kind(), end_time_sec - pause_time_ms / 1000.0, end_time_sec); - - last_pause_included_initial_mark = collector_state()->during_initial_mark_pause(); - if (last_pause_included_initial_mark) { - record_concurrent_mark_init_end(0.0); - } else { - maybe_start_marking(); - } - - double app_time_ms = (phase_times()->cur_collection_start_sec() * 1000.0 - _analytics->prev_collection_pause_end_ms()); - if (app_time_ms < MIN_TIMER_GRANULARITY) { - // This usually happens due to the timer not having the required - // granularity. Some Linuxes are the usual culprits. - // We'll just set it to something (arbitrarily) small. - app_time_ms = 1.0; - } - - if (update_stats) { - // We maintain the invariant that all objects allocated by mutator - // threads will be allocated out of eden regions. So, we can use - // the eden region number allocated since the previous GC to - // calculate the application's allocate rate. The only exception - // to that is humongous objects that are allocated separately. But - // given that humongous object allocations do not really affect - // either the pause's duration nor when the next pause will take - // place we can safely ignore them here. - uint regions_allocated = _collection_set->eden_region_length(); - double alloc_rate_ms = (double) regions_allocated / app_time_ms; - _analytics->report_alloc_rate_ms(alloc_rate_ms); - - double interval_ms = - (end_time_sec - _analytics->last_known_gc_end_time_sec()) * 1000.0; - _analytics->update_recent_gc_times(end_time_sec, pause_time_ms); - _analytics->compute_pause_time_ratio(interval_ms, pause_time_ms); - } - - bool new_in_marking_window = collector_state()->in_marking_window(); - bool new_in_marking_window_im = false; - if (last_pause_included_initial_mark) { - new_in_marking_window = true; - new_in_marking_window_im = true; - } - - if (collector_state()->last_young_gc()) { - // This is supposed to to be the "last young GC" before we start - // doing mixed GCs. Here we decide whether to start mixed GCs or not. - assert(!last_pause_included_initial_mark, "The last young GC is not allowed to be an initial mark GC"); - - if (next_gc_should_be_mixed("start mixed GCs", - "do not start mixed GCs")) { - collector_state()->set_gcs_are_young(false); - } else { - // We aborted the mixed GC phase early. - abort_time_to_mixed_tracking(); - } - - collector_state()->set_last_young_gc(false); - } - - if (!collector_state()->last_gc_was_young()) { - // This is a mixed GC. Here we decide whether to continue doing - // mixed GCs or not. - if (!next_gc_should_be_mixed("continue mixed GCs", - "do not continue mixed GCs")) { - collector_state()->set_gcs_are_young(true); - - maybe_start_marking(); - } - } - - _short_lived_surv_rate_group->start_adding_regions(); - // Do that for any other surv rate groups - - double scan_hcc_time_ms = ConcurrentG1Refine::hot_card_cache_enabled() ? average_time_ms(G1GCPhaseTimes::ScanHCC) : 0.0; - - if (update_stats) { - double cost_per_card_ms = 0.0; - if (_pending_cards > 0) { - cost_per_card_ms = (average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms) / (double) _pending_cards; - _analytics->report_cost_per_card_ms(cost_per_card_ms); - } - _analytics->report_cost_scan_hcc(scan_hcc_time_ms); - - double cost_per_entry_ms = 0.0; - if (cards_scanned > 10) { - cost_per_entry_ms = average_time_ms(G1GCPhaseTimes::ScanRS) / (double) cards_scanned; - _analytics->report_cost_per_entry_ms(cost_per_entry_ms, collector_state()->last_gc_was_young()); - } - - if (_max_rs_lengths > 0) { - double cards_per_entry_ratio = - (double) cards_scanned / (double) _max_rs_lengths; - _analytics->report_cards_per_entry_ratio(cards_per_entry_ratio, collector_state()->last_gc_was_young()); - } - - // This is defensive. For a while _max_rs_lengths could get - // smaller than _recorded_rs_lengths which was causing - // rs_length_diff to get very large and mess up the RSet length - // predictions. The reason was unsafe concurrent updates to the - // _inc_cset_recorded_rs_lengths field which the code below guards - // against (see CR 7118202). This bug has now been fixed (see CR - // 7119027). However, I'm still worried that - // _inc_cset_recorded_rs_lengths might still end up somewhat - // inaccurate. The concurrent refinement thread calculates an - // RSet's length concurrently with other CR threads updating it - // which might cause it to calculate the length incorrectly (if, - // say, it's in mid-coarsening). So I'll leave in the defensive - // conditional below just in case. - size_t rs_length_diff = 0; - size_t recorded_rs_lengths = _collection_set->recorded_rs_lengths(); - if (_max_rs_lengths > recorded_rs_lengths) { - rs_length_diff = _max_rs_lengths - recorded_rs_lengths; - } - _analytics->report_rs_length_diff((double) rs_length_diff); - - size_t freed_bytes = heap_used_bytes_before_gc - cur_used_bytes; - size_t copied_bytes = _collection_set->bytes_used_before() - freed_bytes; - double cost_per_byte_ms = 0.0; - - if (copied_bytes > 0) { - cost_per_byte_ms = average_time_ms(G1GCPhaseTimes::ObjCopy) / (double) copied_bytes; - _analytics->report_cost_per_byte_ms(cost_per_byte_ms, collector_state()->in_marking_window()); - } - - if (_collection_set->young_region_length() > 0) { - _analytics->report_young_other_cost_per_region_ms(young_other_time_ms() / - _collection_set->young_region_length()); - } - - if (_collection_set->old_region_length() > 0) { - _analytics->report_non_young_other_cost_per_region_ms(non_young_other_time_ms() / - _collection_set->old_region_length()); - } - - _analytics->report_constant_other_time_ms(constant_other_time_ms(pause_time_ms)); - - _analytics->report_pending_cards((double) _pending_cards); - _analytics->report_rs_lengths((double) _max_rs_lengths); - } - - collector_state()->set_in_marking_window(new_in_marking_window); - collector_state()->set_in_marking_window_im(new_in_marking_window_im); - _free_regions_at_end_of_collection = _g1->num_free_regions(); - // IHOP control wants to know the expected young gen length if it were not - // restrained by the heap reserve. Using the actual length would make the - // prediction too small and the limit the young gen every time we get to the - // predicted target occupancy. - size_t last_unrestrained_young_length = update_young_list_max_and_target_length(); - update_rs_lengths_prediction(); - - update_ihop_prediction(app_time_ms / 1000.0, - _bytes_allocated_in_old_since_last_gc, - last_unrestrained_young_length * HeapRegion::GrainBytes); - _bytes_allocated_in_old_since_last_gc = 0; - - _ihop_control->send_trace_event(_g1->gc_tracer_stw()); - - // Note that _mmu_tracker->max_gc_time() returns the time in seconds. - double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0; - - if (update_rs_time_goal_ms < scan_hcc_time_ms) { - log_debug(gc, ergo, refine)("Adjust concurrent refinement thresholds (scanning the HCC expected to take longer than Update RS time goal)." - "Update RS time goal: %1.2fms Scan HCC time: %1.2fms", - update_rs_time_goal_ms, scan_hcc_time_ms); - - update_rs_time_goal_ms = 0; - } else { - update_rs_time_goal_ms -= scan_hcc_time_ms; - } - _g1->concurrent_g1_refine()->adjust(average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms, - phase_times()->sum_thread_work_items(G1GCPhaseTimes::UpdateRS), - update_rs_time_goal_ms); - - cset_chooser()->verify(); -} - -G1IHOPControl* G1CollectorPolicy::create_ihop_control() const { - if (G1UseAdaptiveIHOP) { - return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent, - &_predictor, - G1ReservePercent, - G1HeapWastePercent); - } else { - return new G1StaticIHOPControl(InitiatingHeapOccupancyPercent); - } -} - -void G1CollectorPolicy::update_ihop_prediction(double mutator_time_s, - size_t mutator_alloc_bytes, - size_t young_gen_size) { - // Always try to update IHOP prediction. Even evacuation failures give information - // about e.g. whether to start IHOP earlier next time. - - // Avoid using really small application times that might create samples with - // very high or very low values. They may be caused by e.g. back-to-back gcs. - double const min_valid_time = 1e-6; - - bool report = false; - - double marking_to_mixed_time = -1.0; - if (!collector_state()->last_gc_was_young() && _initial_mark_to_mixed.has_result()) { - marking_to_mixed_time = _initial_mark_to_mixed.last_marking_time(); - assert(marking_to_mixed_time > 0.0, - "Initial mark to mixed time must be larger than zero but is %.3f", - marking_to_mixed_time); - if (marking_to_mixed_time > min_valid_time) { - _ihop_control->update_marking_length(marking_to_mixed_time); - report = true; - } - } - - // As an approximation for the young gc promotion rates during marking we use - // all of them. In many applications there are only a few if any young gcs during - // marking, which makes any prediction useless. This increases the accuracy of the - // prediction. - if (collector_state()->last_gc_was_young() && mutator_time_s > min_valid_time) { - _ihop_control->update_allocation_info(mutator_time_s, mutator_alloc_bytes, young_gen_size); - report = true; - } - - if (report) { - report_ihop_statistics(); - } -} - -void G1CollectorPolicy::report_ihop_statistics() { - _ihop_control->print(); -} - -void G1CollectorPolicy::print_phases() { - phase_times()->print(); -} - -double G1CollectorPolicy::predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const { - TruncatedSeq* seq = surv_rate_group->get_seq(age); - guarantee(seq->num() > 0, "There should be some young gen survivor samples available. Tried to access with age %d", age); - double pred = _predictor.get_new_prediction(seq); - if (pred > 1.0) { - pred = 1.0; - } - return pred; -} - -double G1CollectorPolicy::predict_yg_surv_rate(int age) const { - return predict_yg_surv_rate(age, _short_lived_surv_rate_group); -} - -double G1CollectorPolicy::accum_yg_surv_rate_pred(int age) const { - return _short_lived_surv_rate_group->accum_surv_rate_pred(age); -} - -double G1CollectorPolicy::predict_base_elapsed_time_ms(size_t pending_cards, - size_t scanned_cards) const { - return - _analytics->predict_rs_update_time_ms(pending_cards) + - _analytics->predict_rs_scan_time_ms(scanned_cards, collector_state()->gcs_are_young()) + - _analytics->predict_constant_other_time_ms(); -} - -double G1CollectorPolicy::predict_base_elapsed_time_ms(size_t pending_cards) const { - size_t rs_length = _analytics->predict_rs_lengths() + _analytics->predict_rs_length_diff(); - size_t card_num = _analytics->predict_card_num(rs_length, collector_state()->gcs_are_young()); - return predict_base_elapsed_time_ms(pending_cards, card_num); -} - -size_t G1CollectorPolicy::predict_bytes_to_copy(HeapRegion* hr) const { - size_t bytes_to_copy; - if (hr->is_marked()) - bytes_to_copy = hr->max_live_bytes(); - else { - assert(hr->is_young() && hr->age_in_surv_rate_group() != -1, "invariant"); - int age = hr->age_in_surv_rate_group(); - double yg_surv_rate = predict_yg_surv_rate(age, hr->surv_rate_group()); - bytes_to_copy = (size_t) (hr->used() * yg_surv_rate); - } - return bytes_to_copy; -} - -double G1CollectorPolicy::predict_region_elapsed_time_ms(HeapRegion* hr, - bool for_young_gc) const { - size_t rs_length = hr->rem_set()->occupied(); - // Predicting the number of cards is based on which type of GC - // we're predicting for. - size_t card_num = _analytics->predict_card_num(rs_length, for_young_gc); - size_t bytes_to_copy = predict_bytes_to_copy(hr); - - double region_elapsed_time_ms = - _analytics->predict_rs_scan_time_ms(card_num, collector_state()->gcs_are_young()) + - _analytics->predict_object_copy_time_ms(bytes_to_copy, collector_state()->during_concurrent_mark()); - - // The prediction of the "other" time for this region is based - // upon the region type and NOT the GC type. - if (hr->is_young()) { - region_elapsed_time_ms += _analytics->predict_young_other_time_ms(1); - } else { - region_elapsed_time_ms += _analytics->predict_non_young_other_time_ms(1); - } - return region_elapsed_time_ms; -} - - -void G1CollectorPolicy::print_yg_surv_rate_info() const { -#ifndef PRODUCT - _short_lived_surv_rate_group->print_surv_rate_summary(); - // add this call for any other surv rate groups -#endif // PRODUCT -} - -bool G1CollectorPolicy::is_young_list_full() const { - uint young_list_length = _g1->young_list()->length(); - uint young_list_target_length = _young_list_target_length; - return young_list_length >= young_list_target_length; -} - -bool G1CollectorPolicy::can_expand_young_list() const { - uint young_list_length = _g1->young_list()->length(); - uint young_list_max_length = _young_list_max_length; - return young_list_length < young_list_max_length; -} - -bool G1CollectorPolicy::adaptive_young_list_length() const { - return _young_gen_sizer->adaptive_young_list_length(); -} - -void G1CollectorPolicy::update_max_gc_locker_expansion() { - uint expansion_region_num = 0; - if (GCLockerEdenExpansionPercent > 0) { - double perc = (double) GCLockerEdenExpansionPercent / 100.0; - double expansion_region_num_d = perc * (double) _young_list_target_length; - // We use ceiling so that if expansion_region_num_d is > 0.0 (but - // less than 1.0) we'll get 1. - expansion_region_num = (uint) ceil(expansion_region_num_d); - } else { - assert(expansion_region_num == 0, "sanity"); - } - _young_list_max_length = _young_list_target_length + expansion_region_num; - assert(_young_list_target_length <= _young_list_max_length, "post-condition"); -} - -// Calculates survivor space parameters. -void G1CollectorPolicy::update_survivors_policy() { - double max_survivor_regions_d = - (double) _young_list_target_length / (double) SurvivorRatio; - // We use ceiling so that if max_survivor_regions_d is > 0.0 (but - // smaller than 1.0) we'll get 1. - _max_survivor_regions = (uint) ceil(max_survivor_regions_d); - - _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold( - HeapRegion::GrainWords * _max_survivor_regions, counters()); -} - -bool G1CollectorPolicy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) { - // We actually check whether we are marking here and not if we are in a - // reclamation phase. This means that we will schedule a concurrent mark - // even while we are still in the process of reclaiming memory. - bool during_cycle = _g1->concurrent_mark()->cmThread()->during_cycle(); - if (!during_cycle) { - log_debug(gc, ergo)("Request concurrent cycle initiation (requested by GC cause). GC cause: %s", GCCause::to_string(gc_cause)); - collector_state()->set_initiate_conc_mark_if_possible(true); - return true; - } else { - log_debug(gc, ergo)("Do not request concurrent cycle initiation (concurrent cycle already in progress). GC cause: %s", GCCause::to_string(gc_cause)); - return false; - } -} - -void G1CollectorPolicy::initiate_conc_mark() { - collector_state()->set_during_initial_mark_pause(true); - collector_state()->set_initiate_conc_mark_if_possible(false); -} - -void G1CollectorPolicy::decide_on_conc_mark_initiation() { - // We are about to decide on whether this pause will be an - // initial-mark pause. - - // First, collector_state()->during_initial_mark_pause() should not be already set. We - // will set it here if we have to. However, it should be cleared by - // the end of the pause (it's only set for the duration of an - // initial-mark pause). - assert(!collector_state()->during_initial_mark_pause(), "pre-condition"); - - if (collector_state()->initiate_conc_mark_if_possible()) { - // We had noticed on a previous pause that the heap occupancy has - // gone over the initiating threshold and we should start a - // concurrent marking cycle. So we might initiate one. - - if (!about_to_start_mixed_phase() && collector_state()->gcs_are_young()) { - // Initiate a new initial mark if there is no marking or reclamation going on. - initiate_conc_mark(); - log_debug(gc, ergo)("Initiate concurrent cycle (concurrent cycle initiation requested)"); - } else if (_g1->is_user_requested_concurrent_full_gc(_g1->gc_cause())) { - // Initiate a user requested initial mark. An initial mark must be young only - // GC, so the collector state must be updated to reflect this. - collector_state()->set_gcs_are_young(true); - collector_state()->set_last_young_gc(false); - - abort_time_to_mixed_tracking(); - initiate_conc_mark(); - log_debug(gc, ergo)("Initiate concurrent cycle (user requested concurrent cycle)"); - } else { - // The concurrent marking thread is still finishing up the - // previous cycle. If we start one right now the two cycles - // overlap. In particular, the concurrent marking thread might - // be in the process of clearing the next marking bitmap (which - // we will use for the next cycle if we start one). Starting a - // cycle now will be bad given that parts of the marking - // information might get cleared by the marking thread. And we - // cannot wait for the marking thread to finish the cycle as it - // periodically yields while clearing the next marking bitmap - // and, if it's in a yield point, it's waiting for us to - // finish. So, at this point we will not start a cycle and we'll - // let the concurrent marking thread complete the last one. - log_debug(gc, ergo)("Do not initiate concurrent cycle (concurrent cycle already in progress)"); - } - } -} - -void G1CollectorPolicy::record_concurrent_mark_cleanup_end() { - cset_chooser()->rebuild(_g1->workers(), _g1->num_regions()); - - double end_sec = os::elapsedTime(); - double elapsed_time_ms = (end_sec - _mark_cleanup_start_sec) * 1000.0; - _analytics->report_concurrent_mark_cleanup_times_ms(elapsed_time_ms); - _analytics->append_prev_collection_pause_end_ms(elapsed_time_ms); - - record_pause(Cleanup, _mark_cleanup_start_sec, end_sec); -} - -double G1CollectorPolicy::reclaimable_bytes_perc(size_t reclaimable_bytes) const { - // Returns the given amount of reclaimable bytes (that represents - // the amount of reclaimable space still to be collected) as a - // percentage of the current heap capacity. - size_t capacity_bytes = _g1->capacity(); - return (double) reclaimable_bytes * 100.0 / (double) capacity_bytes; -} - -void G1CollectorPolicy::maybe_start_marking() { - if (need_to_start_conc_mark("end of GC")) { - // Note: this might have already been set, if during the last - // pause we decided to start a cycle but at the beginning of - // this pause we decided to postpone it. That's OK. - collector_state()->set_initiate_conc_mark_if_possible(true); - } -} - -G1CollectorPolicy::PauseKind G1CollectorPolicy::young_gc_pause_kind() const { - assert(!collector_state()->full_collection(), "must be"); - if (collector_state()->during_initial_mark_pause()) { - assert(collector_state()->last_gc_was_young(), "must be"); - assert(!collector_state()->last_young_gc(), "must be"); - return InitialMarkGC; - } else if (collector_state()->last_young_gc()) { - assert(!collector_state()->during_initial_mark_pause(), "must be"); - assert(collector_state()->last_gc_was_young(), "must be"); - return LastYoungGC; - } else if (!collector_state()->last_gc_was_young()) { - assert(!collector_state()->during_initial_mark_pause(), "must be"); - assert(!collector_state()->last_young_gc(), "must be"); - return MixedGC; - } else { - assert(collector_state()->last_gc_was_young(), "must be"); - assert(!collector_state()->during_initial_mark_pause(), "must be"); - assert(!collector_state()->last_young_gc(), "must be"); - return YoungOnlyGC; - } -} - -void G1CollectorPolicy::record_pause(PauseKind kind, double start, double end) { - // Manage the MMU tracker. For some reason it ignores Full GCs. - if (kind != FullGC) { - _mmu_tracker->add_pause(start, end); - } - // Manage the mutator time tracking from initial mark to first mixed gc. - switch (kind) { - case FullGC: - abort_time_to_mixed_tracking(); - break; - case Cleanup: - case Remark: - case YoungOnlyGC: - case LastYoungGC: - _initial_mark_to_mixed.add_pause(end - start); - break; - case InitialMarkGC: - _initial_mark_to_mixed.record_initial_mark_end(end); - break; - case MixedGC: - _initial_mark_to_mixed.record_mixed_gc_start(start); - break; - default: - ShouldNotReachHere(); - } -} - -void G1CollectorPolicy::abort_time_to_mixed_tracking() { - _initial_mark_to_mixed.reset(); -} - -bool G1CollectorPolicy::next_gc_should_be_mixed(const char* true_action_str, - const char* false_action_str) const { - if (cset_chooser()->is_empty()) { - log_debug(gc, ergo)("%s (candidate old regions not available)", false_action_str); - return false; - } - - // Is the amount of uncollected reclaimable space above G1HeapWastePercent? - size_t reclaimable_bytes = cset_chooser()->remaining_reclaimable_bytes(); - double reclaimable_perc = reclaimable_bytes_perc(reclaimable_bytes); - double threshold = (double) G1HeapWastePercent; - if (reclaimable_perc <= threshold) { - log_debug(gc, ergo)("%s (reclaimable percentage not over threshold). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT, - false_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_perc, G1HeapWastePercent); - return false; - } - log_debug(gc, ergo)("%s (candidate old regions available). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT, - true_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_perc, G1HeapWastePercent); - return true; -} - -uint G1CollectorPolicy::calc_min_old_cset_length() const { - // The min old CSet region bound is based on the maximum desired - // number of mixed GCs after a cycle. I.e., even if some old regions - // look expensive, we should add them to the CSet anyway to make - // sure we go through the available old regions in no more than the - // maximum desired number of mixed GCs. - // - // The calculation is based on the number of marked regions we added - // to the CSet chooser in the first place, not how many remain, so - // that the result is the same during all mixed GCs that follow a cycle. - - const size_t region_num = (size_t) cset_chooser()->length(); - const size_t gc_num = (size_t) MAX2(G1MixedGCCountTarget, (uintx) 1); - size_t result = region_num / gc_num; - // emulate ceiling - if (result * gc_num < region_num) { - result += 1; - } - return (uint) result; -} - -uint G1CollectorPolicy::calc_max_old_cset_length() const { - // The max old CSet region bound is based on the threshold expressed - // as a percentage of the heap size. I.e., it should bound the - // number of old regions added to the CSet irrespective of how many - // of them are available. - - const G1CollectedHeap* g1h = G1CollectedHeap::heap(); - const size_t region_num = g1h->num_regions(); - const size_t perc = (size_t) G1OldCSetRegionThresholdPercent; - size_t result = region_num * perc / 100; - // emulate ceiling - if (100 * result < region_num * perc) { - result += 1; - } - return (uint) result; -} - -void G1CollectorPolicy::finalize_collection_set(double target_pause_time_ms) { - double time_remaining_ms = _collection_set->finalize_young_part(target_pause_time_ms); - _collection_set->finalize_old_part(time_remaining_ms); -} diff --git a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp index 01396394eb1..3203770eab2 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp @@ -25,419 +25,27 @@ #ifndef SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP #define SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP -#include "gc/g1/g1CollectorState.hpp" -#include "gc/g1/g1GCPhaseTimes.hpp" -#include "gc/g1/g1InCSetState.hpp" -#include "gc/g1/g1InitialMarkToMixedTimeTracker.hpp" -#include "gc/g1/g1MMUTracker.hpp" -#include "gc/g1/g1Predictions.hpp" #include "gc/shared/collectorPolicy.hpp" -#include "utilities/pair.hpp" -// A G1CollectorPolicy makes policy decisions that determine the -// characteristics of the collector. Examples include: -// * choice of collection set. -// * when to collect. +// G1CollectorPolicy is primarily used during initialization and to expose the +// functionality of the CollectorPolicy interface to the rest of the VM. -class HeapRegion; -class G1CollectionSet; -class CollectionSetChooser; -class G1IHOPControl; -class G1Analytics; class G1YoungGenSizer; class G1CollectorPolicy: public CollectorPolicy { - private: - G1IHOPControl* _ihop_control; - - G1IHOPControl* create_ihop_control() const; - // Update the IHOP control with necessary statistics. - void update_ihop_prediction(double mutator_time_s, - size_t mutator_alloc_bytes, - size_t young_gen_size); - void report_ihop_statistics(); - - G1Predictions _predictor; - G1Analytics* _analytics; - G1MMUTracker* _mmu_tracker; - +protected: void initialize_alignments(); void initialize_flags(); - double _full_collection_start_sec; - - uint _young_list_target_length; - uint _young_list_fixed_length; - - // The max number of regions we can extend the eden by while the GC - // locker is active. This should be >= _young_list_target_length; - uint _young_list_max_length; - - SurvRateGroup* _short_lived_surv_rate_group; - SurvRateGroup* _survivor_surv_rate_group; - - double _reserve_factor; - uint _reserve_regions; - - G1YoungGenSizer* _young_gen_sizer; - - uint _free_regions_at_end_of_collection; - - size_t _max_rs_lengths; - - size_t _rs_lengths_prediction; - -#ifndef PRODUCT - bool verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group); -#endif // PRODUCT - - double _pause_time_target_ms; - - size_t _pending_cards; - - // The amount of allocated bytes in old gen during the last mutator and the following - // young GC phase. - size_t _bytes_allocated_in_old_since_last_gc; - - G1InitialMarkToMixedTimeTracker _initial_mark_to_mixed; public: - const G1Predictions& predictor() const { return _predictor; } - const G1Analytics* analytics() const { return const_cast(_analytics); } - - // Add the given number of bytes to the total number of allocated bytes in the old gen. - void add_bytes_allocated_in_old_since_last_gc(size_t bytes) { _bytes_allocated_in_old_since_last_gc += bytes; } - - // Accessors - - void set_region_eden(HeapRegion* hr, int young_index_in_cset) { - hr->set_eden(); - hr->install_surv_rate_group(_short_lived_surv_rate_group); - hr->set_young_index_in_cset(young_index_in_cset); - } - - void set_region_survivor(HeapRegion* hr, int young_index_in_cset) { - assert(hr->is_survivor(), "pre-condition"); - hr->install_surv_rate_group(_survivor_surv_rate_group); - hr->set_young_index_in_cset(young_index_in_cset); - } - -#ifndef PRODUCT - bool verify_young_ages(); -#endif // PRODUCT - - void record_max_rs_lengths(size_t rs_lengths) { - _max_rs_lengths = rs_lengths; - } - - - double predict_base_elapsed_time_ms(size_t pending_cards) const; - double predict_base_elapsed_time_ms(size_t pending_cards, - size_t scanned_cards) const; - size_t predict_bytes_to_copy(HeapRegion* hr) const; - double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const; - - double predict_survivor_regions_evac_time() const; - - bool should_update_surv_rate_group_predictors() { - return collector_state()->last_gc_was_young() && !collector_state()->in_marking_window(); - } - - void cset_regions_freed() { - bool update = should_update_surv_rate_group_predictors(); - - _short_lived_surv_rate_group->all_surviving_words_recorded(update); - _survivor_surv_rate_group->all_surviving_words_recorded(update); - } - - G1MMUTracker* mmu_tracker() { - return _mmu_tracker; - } - - const G1MMUTracker* mmu_tracker() const { - return _mmu_tracker; - } - - double max_pause_time_ms() const { - return _mmu_tracker->max_gc_time() * 1000.0; - } - - // Returns an estimate of the survival rate of the region at yg-age - // "yg_age". - double predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const; - - double predict_yg_surv_rate(int age) const; - - double accum_yg_surv_rate_pred(int age) const; - -protected: - G1CollectionSet* _collection_set; - virtual double average_time_ms(G1GCPhaseTimes::GCParPhases phase) const; - virtual double other_time_ms(double pause_time_ms) const; - - double young_other_time_ms() const; - double non_young_other_time_ms() const; - double constant_other_time_ms(double pause_time_ms) const; - - CollectionSetChooser* cset_chooser() const; -private: - - // The number of bytes copied during the GC. - size_t _bytes_copied_during_gc; - - // Stash a pointer to the g1 heap. - G1CollectedHeap* _g1; - - G1GCPhaseTimes* _phase_times; - - // This set of variables tracks the collector efficiency, in order to - // determine whether we should initiate a new marking. - double _mark_remark_start_sec; - double _mark_cleanup_start_sec; - - // Updates the internal young list maximum and target lengths. Returns the - // unbounded young list target length. - uint update_young_list_max_and_target_length(); - uint update_young_list_max_and_target_length(size_t rs_lengths); - - // Update the young list target length either by setting it to the - // desired fixed value or by calculating it using G1's pause - // prediction model. If no rs_lengths parameter is passed, predict - // the RS lengths using the prediction model, otherwise use the - // given rs_lengths as the prediction. - // Returns the unbounded young list target length. - uint update_young_list_target_length(size_t rs_lengths); - - // Calculate and return the minimum desired young list target - // length. This is the minimum desired young list length according - // to the user's inputs. - uint calculate_young_list_desired_min_length(uint base_min_length) const; - - // Calculate and return the maximum desired young list target - // length. This is the maximum desired young list length according - // to the user's inputs. - uint calculate_young_list_desired_max_length() const; - - // Calculate and return the maximum young list target length that - // can fit into the pause time goal. The parameters are: rs_lengths - // represent the prediction of how large the young RSet lengths will - // be, base_min_length is the already existing number of regions in - // the young list, min_length and max_length are the desired min and - // max young list length according to the user's inputs. - uint calculate_young_list_target_length(size_t rs_lengths, - uint base_min_length, - uint desired_min_length, - uint desired_max_length) const; - - // Result of the bounded_young_list_target_length() method, containing both the - // bounded as well as the unbounded young list target lengths in this order. - typedef Pair YoungTargetLengths; - YoungTargetLengths young_list_target_lengths(size_t rs_lengths) const; - - void update_rs_lengths_prediction(); - void update_rs_lengths_prediction(size_t prediction); - - // Check whether a given young length (young_length) fits into the - // given target pause time and whether the prediction for the amount - // of objects to be copied for the given length will fit into the - // given free space (expressed by base_free_regions). It is used by - // calculate_young_list_target_length(). - bool predict_will_fit(uint young_length, double base_time_ms, - uint base_free_regions, double target_pause_time_ms) const; - -public: - size_t pending_cards() const { return _pending_cards; } - - // Calculate the minimum number of old regions we'll add to the CSet - // during a mixed GC. - uint calc_min_old_cset_length() const; - - // Calculate the maximum number of old regions we'll add to the CSet - // during a mixed GC. - uint calc_max_old_cset_length() const; - - // Returns the given amount of uncollected reclaimable space - // as a percentage of the current heap capacity. - double reclaimable_bytes_perc(size_t reclaimable_bytes) const; - -private: - // Sets up marking if proper conditions are met. - void maybe_start_marking(); - - // The kind of STW pause. - enum PauseKind { - FullGC, - YoungOnlyGC, - MixedGC, - LastYoungGC, - InitialMarkGC, - Cleanup, - Remark - }; - - // Calculate PauseKind from internal state. - PauseKind young_gc_pause_kind() const; - // Record the given STW pause with the given start and end times (in s). - void record_pause(PauseKind kind, double start, double end); - // Indicate that we aborted marking before doing any mixed GCs. - void abort_time_to_mixed_tracking(); -public: - G1CollectorPolicy(); - virtual ~G1CollectorPolicy(); - - virtual G1CollectorPolicy* as_g1_policy() { return this; } - - G1CollectorState* collector_state() const; - - G1GCPhaseTimes* phase_times() const { return _phase_times; } - - // Check the current value of the young list RSet lengths and - // compare it against the last prediction. If the current value is - // higher, recalculate the young list target length prediction. - void revise_young_list_target_length_if_necessary(size_t rs_lengths); + G1CollectorPolicy* as_g1_policy() { return this; } - // This should be called after the heap is resized. - void record_new_heap_size(uint new_number_of_regions); - - void init(); - - virtual void note_gc_start(); + void post_heap_initialize() {} // Nothing needed. // Create jstat counters for the policy. virtual void initialize_gc_policy_counters(); - - bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0); - - bool about_to_start_mixed_phase() const; - - // Record the start and end of an evacuation pause. - void record_collection_pause_start(double start_time_sec); - void record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc); - - // Record the start and end of a full collection. - void record_full_collection_start(); - void record_full_collection_end(); - - // Must currently be called while the world is stopped. - void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms); - - // Record start and end of remark. - void record_concurrent_mark_remark_start(); - void record_concurrent_mark_remark_end(); - - // Record start, end, and completion of cleanup. - void record_concurrent_mark_cleanup_start(); - void record_concurrent_mark_cleanup_end(); - void record_concurrent_mark_cleanup_completed(); - - virtual void print_phases(); - - // Record how much space we copied during a GC. This is typically - // called when a GC alloc region is being retired. - void record_bytes_copied_during_gc(size_t bytes) { - _bytes_copied_during_gc += bytes; - } - - // The amount of space we copied during a GC. - size_t bytes_copied_during_gc() const { - return _bytes_copied_during_gc; - } - - // Determine whether there are candidate regions so that the - // next GC should be mixed. The two action strings are used - // in the ergo output when the method returns true or false. - bool next_gc_should_be_mixed(const char* true_action_str, - const char* false_action_str) const; - - virtual void finalize_collection_set(double target_pause_time_ms); -private: - // Set the state to start a concurrent marking cycle and clear - // _initiate_conc_mark_if_possible because it has now been - // acted on. - void initiate_conc_mark(); - -public: - // This sets the initiate_conc_mark_if_possible() flag to start a - // new cycle, as long as we are not already in one. It's best if it - // is called during a safepoint when the test whether a cycle is in - // progress or not is stable. - bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause); - - // This is called at the very beginning of an evacuation pause (it - // has to be the first thing that the pause does). If - // initiate_conc_mark_if_possible() is true, and the concurrent - // marking thread has completed its work during the previous cycle, - // it will set during_initial_mark_pause() to so that the pause does - // the initial-mark work and start a marking cycle. - void decide_on_conc_mark_initiation(); - - // Print stats on young survival ratio - void print_yg_surv_rate_info() const; - - void finished_recalculating_age_indexes(bool is_survivors) { - if (is_survivors) { - _survivor_surv_rate_group->finished_recalculating_age_indexes(); - } else { - _short_lived_surv_rate_group->finished_recalculating_age_indexes(); - } - } - - size_t young_list_target_length() const { return _young_list_target_length; } - - bool is_young_list_full() const; - - bool can_expand_young_list() const; - - uint young_list_max_length() const { - return _young_list_max_length; - } - - bool adaptive_young_list_length() const; - - virtual bool should_process_references() const { - return true; - } - -private: - // - // Survivor regions policy. - // - - // Current tenuring threshold, set to 0 if the collector reaches the - // maximum amount of survivors regions. - uint _tenuring_threshold; - - // The limit on the number of regions allocated for survivors. - uint _max_survivor_regions; - - AgeTable _survivors_age_table; - -public: - uint tenuring_threshold() const { return _tenuring_threshold; } - - uint max_survivor_regions() { - return _max_survivor_regions; - } - - void note_start_adding_survivor_regions() { - _survivor_surv_rate_group->start_adding_regions(); - } - - void note_stop_adding_survivor_regions() { - _survivor_surv_rate_group->stop_adding_regions(); - } - - void record_age_table(AgeTable* age_table) { - _survivors_age_table.merge(age_table); - } - - void update_max_gc_locker_expansion(); - - // Calculates survivor space parameters. - void update_survivors_policy(); - - virtual void post_heap_initialize(); }; #endif // SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp index b36583e9822..1a3b1f79852 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp @@ -28,12 +28,12 @@ #include "code/codeCache.hpp" #include "gc/g1/concurrentMarkThread.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/g1CollectorState.hpp" #include "gc/g1/g1ConcurrentMark.inline.hpp" #include "gc/g1/g1HeapVerifier.hpp" #include "gc/g1/g1OopClosures.inline.hpp" #include "gc/g1/g1CardLiveData.inline.hpp" +#include "gc/g1/g1Policy.hpp" #include "gc/g1/g1StringDedup.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" @@ -739,8 +739,8 @@ public: }; void G1ConcurrentMark::checkpointRootsInitialPre() { - G1CollectedHeap* g1h = G1CollectedHeap::heap(); - G1CollectorPolicy* g1p = g1h->g1_policy(); + G1CollectedHeap* g1h = G1CollectedHeap::heap(); + G1Policy* g1p = g1h->g1_policy(); _has_aborted = false; @@ -1056,7 +1056,7 @@ void G1ConcurrentMark::checkpointRootsFinal(bool clear_all_soft_refs) { } g1h->verifier()->check_bitmaps("Remark Start"); - G1CollectorPolicy* g1p = g1h->g1_policy(); + G1Policy* g1p = g1h->g1_policy(); g1p->record_concurrent_mark_remark_start(); double start = os::elapsedTime(); @@ -1240,7 +1240,7 @@ void G1ConcurrentMark::cleanup() { } g1h->verifier()->check_bitmaps("Cleanup Start"); - G1CollectorPolicy* g1p = g1h->g1_policy(); + G1Policy* g1p = g1h->g1_policy(); g1p->record_concurrent_mark_cleanup_start(); double start = os::elapsedTime(); @@ -2609,7 +2609,7 @@ void G1CMTask::do_marking_step(double time_target_ms, assert(time_target_ms >= 1.0, "minimum granularity is 1ms"); assert(concurrent() == _cm->concurrent(), "they should be the same"); - G1CollectorPolicy* g1_policy = _g1h->g1_policy(); + G1Policy* g1_policy = _g1h->g1_policy(); assert(_task_queues != NULL, "invariant"); assert(_task_queue != NULL, "invariant"); assert(_task_queues->queue(_worker_id) == _task_queue, "invariant"); diff --git a/hotspot/src/share/vm/gc/g1/g1HeapTransition.cpp b/hotspot/src/share/vm/gc/g1/g1HeapTransition.cpp index 2d1562ea05a..528fe6e7475 100644 --- a/hotspot/src/share/vm/gc/g1/g1HeapTransition.cpp +++ b/hotspot/src/share/vm/gc/g1/g1HeapTransition.cpp @@ -24,8 +24,8 @@ #include "precompiled.hpp" #include "gc/g1/g1CollectedHeap.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/g1HeapTransition.hpp" +#include "gc/g1/g1Policy.hpp" #include "logging/log.hpp" #include "memory/metaspace.hpp" diff --git a/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp b/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp index ddbdfad5f14..20856e57d1e 100644 --- a/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp +++ b/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp @@ -29,6 +29,7 @@ #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1HeapVerifier.hpp" #include "gc/g1/g1MarkSweep.hpp" +#include "gc/g1/g1Policy.hpp" #include "gc/g1/g1RemSet.hpp" #include "gc/g1/g1RootProcessor.hpp" #include "gc/g1/heapRegion.hpp" diff --git a/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp b/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp index 1dcbcc24c36..5c0b5236de5 100644 --- a/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp +++ b/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp @@ -24,8 +24,8 @@ #include "precompiled.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/g1MonitoringSupport.hpp" +#include "gc/g1/g1Policy.hpp" G1GenerationCounters::G1GenerationCounters(G1MonitoringSupport* g1mm, const char* name, diff --git a/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp b/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp index 6accb48c1de..6b399ae975c 100644 --- a/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp +++ b/hotspot/src/share/vm/gc/g1/g1ParScanThreadState.hpp @@ -27,8 +27,8 @@ #include "gc/g1/dirtyCardQueue.hpp" #include "gc/g1/g1CollectedHeap.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/g1OopClosures.hpp" +#include "gc/g1/g1Policy.hpp" #include "gc/g1/g1RemSet.hpp" #include "gc/g1/g1SATBCardTableModRefBS.hpp" #include "gc/shared/ageTable.hpp" diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.cpp b/hotspot/src/share/vm/gc/g1/g1Policy.cpp new file mode 100644 index 00000000000..135a626cf46 --- /dev/null +++ b/hotspot/src/share/vm/gc/g1/g1Policy.cpp @@ -0,0 +1,1187 @@ +/* + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "gc/g1/concurrentG1Refine.hpp" +#include "gc/g1/concurrentMarkThread.inline.hpp" +#include "gc/g1/g1Analytics.hpp" +#include "gc/g1/g1CollectedHeap.inline.hpp" +#include "gc/g1/g1CollectionSet.hpp" +#include "gc/g1/g1ConcurrentMark.hpp" +#include "gc/g1/g1IHOPControl.hpp" +#include "gc/g1/g1GCPhaseTimes.hpp" +#include "gc/g1/g1Policy.hpp" +#include "gc/g1/g1YoungGenSizer.hpp" +#include "gc/g1/heapRegion.inline.hpp" +#include "gc/g1/heapRegionRemSet.hpp" +#include "gc/shared/gcPolicyCounters.hpp" +#include "runtime/arguments.hpp" +#include "runtime/java.hpp" +#include "runtime/mutexLocker.hpp" +#include "utilities/debug.hpp" +#include "utilities/pair.hpp" + +G1Policy::G1Policy() : + _predictor(G1ConfidencePercent / 100.0), + _analytics(new G1Analytics(&_predictor)), + _pause_time_target_ms((double) MaxGCPauseMillis), + _rs_lengths_prediction(0), + _max_survivor_regions(0), + _survivors_age_table(true), + + _bytes_allocated_in_old_since_last_gc(0), + _ihop_control(NULL), + _initial_mark_to_mixed() { + + // SurvRateGroups below must be initialized after the predictor because they + // indirectly use it through this object passed to their constructor. + _short_lived_surv_rate_group = + new SurvRateGroup(&_predictor, "Short Lived", G1YoungSurvRateNumRegionsSummary); + _survivor_surv_rate_group = + new SurvRateGroup(&_predictor, "Survivor", G1YoungSurvRateNumRegionsSummary); + + _phase_times = new G1GCPhaseTimes(ParallelGCThreads); + + double max_gc_time = (double) MaxGCPauseMillis / 1000.0; + double time_slice = (double) GCPauseIntervalMillis / 1000.0; + _mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time); + + _tenuring_threshold = MaxTenuringThreshold; + + + guarantee(G1ReservePercent <= 50, "Range checking should not allow values over 50."); + _reserve_factor = (double) G1ReservePercent / 100.0; + // This will be set when the heap is expanded + // for the first time during initialization. + _reserve_regions = 0; + + _ihop_control = create_ihop_control(); +} + +G1Policy::~G1Policy() { + delete _ihop_control; +} + +G1CollectorState* G1Policy::collector_state() const { return _g1->collector_state(); } + +void G1Policy::init() { + // Set aside an initial future to_space. + _g1 = G1CollectedHeap::heap(); + _collection_set = _g1->collection_set(); + + assert(Heap_lock->owned_by_self(), "Locking discipline."); + + _g1->collector_policy()->initialize_gc_policy_counters(); + + if (adaptive_young_list_length()) { + _young_list_fixed_length = 0; + } else { + _young_list_fixed_length = _young_gen_sizer.min_desired_young_length(); + } + _young_gen_sizer.adjust_max_new_size(_g1->max_regions()); + + _free_regions_at_end_of_collection = _g1->num_free_regions(); + + update_young_list_max_and_target_length(); + // We may immediately start allocating regions and placing them on the + // collection set list. Initialize the per-collection set info + _collection_set->start_incremental_building(); +} + +void G1Policy::note_gc_start() { + phase_times()->note_gc_start(); +} + +bool G1Policy::predict_will_fit(uint young_length, + double base_time_ms, + uint base_free_regions, + double target_pause_time_ms) const { + if (young_length >= base_free_regions) { + // end condition 1: not enough space for the young regions + return false; + } + + double accum_surv_rate = accum_yg_surv_rate_pred((int) young_length - 1); + size_t bytes_to_copy = + (size_t) (accum_surv_rate * (double) HeapRegion::GrainBytes); + double copy_time_ms = _analytics->predict_object_copy_time_ms(bytes_to_copy, + collector_state()->during_concurrent_mark()); + double young_other_time_ms = _analytics->predict_young_other_time_ms(young_length); + double pause_time_ms = base_time_ms + copy_time_ms + young_other_time_ms; + if (pause_time_ms > target_pause_time_ms) { + // end condition 2: prediction is over the target pause time + return false; + } + + size_t free_bytes = (base_free_regions - young_length) * HeapRegion::GrainBytes; + + // When copying, we will likely need more bytes free than is live in the region. + // Add some safety margin to factor in the confidence of our guess, and the + // natural expected waste. + // (100.0 / G1ConfidencePercent) is a scale factor that expresses the uncertainty + // of the calculation: the lower the confidence, the more headroom. + // (100 + TargetPLABWastePct) represents the increase in expected bytes during + // copying due to anticipated waste in the PLABs. + double safety_factor = (100.0 / G1ConfidencePercent) * (100 + TargetPLABWastePct) / 100.0; + size_t expected_bytes_to_copy = (size_t)(safety_factor * bytes_to_copy); + + if (expected_bytes_to_copy > free_bytes) { + // end condition 3: out-of-space + return false; + } + + // success! + return true; +} + +void G1Policy::record_new_heap_size(uint new_number_of_regions) { + // re-calculate the necessary reserve + double reserve_regions_d = (double) new_number_of_regions * _reserve_factor; + // We use ceiling so that if reserve_regions_d is > 0.0 (but + // smaller than 1.0) we'll get 1. + _reserve_regions = (uint) ceil(reserve_regions_d); + + _young_gen_sizer.heap_size_changed(new_number_of_regions); + + _ihop_control->update_target_occupancy(new_number_of_regions * HeapRegion::GrainBytes); +} + +uint G1Policy::calculate_young_list_desired_min_length(uint base_min_length) const { + uint desired_min_length = 0; + if (adaptive_young_list_length()) { + if (_analytics->num_alloc_rate_ms() > 3) { + double now_sec = os::elapsedTime(); + double when_ms = _mmu_tracker->when_max_gc_sec(now_sec) * 1000.0; + double alloc_rate_ms = _analytics->predict_alloc_rate_ms(); + desired_min_length = (uint) ceil(alloc_rate_ms * when_ms); + } else { + // otherwise we don't have enough info to make the prediction + } + } + desired_min_length += base_min_length; + // make sure we don't go below any user-defined minimum bound + return MAX2(_young_gen_sizer.min_desired_young_length(), desired_min_length); +} + +uint G1Policy::calculate_young_list_desired_max_length() const { + // Here, we might want to also take into account any additional + // constraints (i.e., user-defined minimum bound). Currently, we + // effectively don't set this bound. + return _young_gen_sizer.max_desired_young_length(); +} + +uint G1Policy::update_young_list_max_and_target_length() { + return update_young_list_max_and_target_length(_analytics->predict_rs_lengths()); +} + +uint G1Policy::update_young_list_max_and_target_length(size_t rs_lengths) { + uint unbounded_target_length = update_young_list_target_length(rs_lengths); + update_max_gc_locker_expansion(); + return unbounded_target_length; +} + +uint G1Policy::update_young_list_target_length(size_t rs_lengths) { + YoungTargetLengths young_lengths = young_list_target_lengths(rs_lengths); + _young_list_target_length = young_lengths.first; + return young_lengths.second; +} + +G1Policy::YoungTargetLengths G1Policy::young_list_target_lengths(size_t rs_lengths) const { + YoungTargetLengths result; + + // Calculate the absolute and desired min bounds first. + + // This is how many young regions we already have (currently: the survivors). + const uint base_min_length = _g1->young_list()->survivor_length(); + uint desired_min_length = calculate_young_list_desired_min_length(base_min_length); + // This is the absolute minimum young length. Ensure that we + // will at least have one eden region available for allocation. + uint absolute_min_length = base_min_length + MAX2(_g1->young_list()->eden_length(), (uint)1); + // If we shrank the young list target it should not shrink below the current size. + desired_min_length = MAX2(desired_min_length, absolute_min_length); + // Calculate the absolute and desired max bounds. + + uint desired_max_length = calculate_young_list_desired_max_length(); + + uint young_list_target_length = 0; + if (adaptive_young_list_length()) { + if (collector_state()->gcs_are_young()) { + young_list_target_length = + calculate_young_list_target_length(rs_lengths, + base_min_length, + desired_min_length, + desired_max_length); + } else { + // Don't calculate anything and let the code below bound it to + // the desired_min_length, i.e., do the next GC as soon as + // possible to maximize how many old regions we can add to it. + } + } else { + // The user asked for a fixed young gen so we'll fix the young gen + // whether the next GC is young or mixed. + young_list_target_length = _young_list_fixed_length; + } + + result.second = young_list_target_length; + + // We will try our best not to "eat" into the reserve. + uint absolute_max_length = 0; + if (_free_regions_at_end_of_collection > _reserve_regions) { + absolute_max_length = _free_regions_at_end_of_collection - _reserve_regions; + } + if (desired_max_length > absolute_max_length) { + desired_max_length = absolute_max_length; + } + + // Make sure we don't go over the desired max length, nor under the + // desired min length. In case they clash, desired_min_length wins + // which is why that test is second. + if (young_list_target_length > desired_max_length) { + young_list_target_length = desired_max_length; + } + if (young_list_target_length < desired_min_length) { + young_list_target_length = desired_min_length; + } + + assert(young_list_target_length > base_min_length, + "we should be able to allocate at least one eden region"); + assert(young_list_target_length >= absolute_min_length, "post-condition"); + + result.first = young_list_target_length; + return result; +} + +uint +G1Policy::calculate_young_list_target_length(size_t rs_lengths, + uint base_min_length, + uint desired_min_length, + uint desired_max_length) const { + assert(adaptive_young_list_length(), "pre-condition"); + assert(collector_state()->gcs_are_young(), "only call this for young GCs"); + + // In case some edge-condition makes the desired max length too small... + if (desired_max_length <= desired_min_length) { + return desired_min_length; + } + + // We'll adjust min_young_length and max_young_length not to include + // the already allocated young regions (i.e., so they reflect the + // min and max eden regions we'll allocate). The base_min_length + // will be reflected in the predictions by the + // survivor_regions_evac_time prediction. + assert(desired_min_length > base_min_length, "invariant"); + uint min_young_length = desired_min_length - base_min_length; + assert(desired_max_length > base_min_length, "invariant"); + uint max_young_length = desired_max_length - base_min_length; + + double target_pause_time_ms = _mmu_tracker->max_gc_time() * 1000.0; + double survivor_regions_evac_time = predict_survivor_regions_evac_time(); + size_t pending_cards = _analytics->predict_pending_cards(); + size_t adj_rs_lengths = rs_lengths + _analytics->predict_rs_length_diff(); + size_t scanned_cards = _analytics->predict_card_num(adj_rs_lengths, /* gcs_are_young */ true); + double base_time_ms = + predict_base_elapsed_time_ms(pending_cards, scanned_cards) + + survivor_regions_evac_time; + uint available_free_regions = _free_regions_at_end_of_collection; + uint base_free_regions = 0; + if (available_free_regions > _reserve_regions) { + base_free_regions = available_free_regions - _reserve_regions; + } + + // Here, we will make sure that the shortest young length that + // makes sense fits within the target pause time. + + if (predict_will_fit(min_young_length, base_time_ms, + base_free_regions, target_pause_time_ms)) { + // The shortest young length will fit into the target pause time; + // we'll now check whether the absolute maximum number of young + // regions will fit in the target pause time. If not, we'll do + // a binary search between min_young_length and max_young_length. + if (predict_will_fit(max_young_length, base_time_ms, + base_free_regions, target_pause_time_ms)) { + // The maximum young length will fit into the target pause time. + // We are done so set min young length to the maximum length (as + // the result is assumed to be returned in min_young_length). + min_young_length = max_young_length; + } else { + // The maximum possible number of young regions will not fit within + // the target pause time so we'll search for the optimal + // length. The loop invariants are: + // + // min_young_length < max_young_length + // min_young_length is known to fit into the target pause time + // max_young_length is known not to fit into the target pause time + // + // Going into the loop we know the above hold as we've just + // checked them. Every time around the loop we check whether + // the middle value between min_young_length and + // max_young_length fits into the target pause time. If it + // does, it becomes the new min. If it doesn't, it becomes + // the new max. This way we maintain the loop invariants. + + assert(min_young_length < max_young_length, "invariant"); + uint diff = (max_young_length - min_young_length) / 2; + while (diff > 0) { + uint young_length = min_young_length + diff; + if (predict_will_fit(young_length, base_time_ms, + base_free_regions, target_pause_time_ms)) { + min_young_length = young_length; + } else { + max_young_length = young_length; + } + assert(min_young_length < max_young_length, "invariant"); + diff = (max_young_length - min_young_length) / 2; + } + // The results is min_young_length which, according to the + // loop invariants, should fit within the target pause time. + + // These are the post-conditions of the binary search above: + assert(min_young_length < max_young_length, + "otherwise we should have discovered that max_young_length " + "fits into the pause target and not done the binary search"); + assert(predict_will_fit(min_young_length, base_time_ms, + base_free_regions, target_pause_time_ms), + "min_young_length, the result of the binary search, should " + "fit into the pause target"); + assert(!predict_will_fit(min_young_length + 1, base_time_ms, + base_free_regions, target_pause_time_ms), + "min_young_length, the result of the binary search, should be " + "optimal, so no larger length should fit into the pause target"); + } + } else { + // Even the minimum length doesn't fit into the pause time + // target, return it as the result nevertheless. + } + return base_min_length + min_young_length; +} + +double G1Policy::predict_survivor_regions_evac_time() const { + double survivor_regions_evac_time = 0.0; + for (HeapRegion * r = _g1->young_list()->first_survivor_region(); + r != NULL && r != _g1->young_list()->last_survivor_region()->get_next_young_region(); + r = r->get_next_young_region()) { + survivor_regions_evac_time += predict_region_elapsed_time_ms(r, collector_state()->gcs_are_young()); + } + return survivor_regions_evac_time; +} + +void G1Policy::revise_young_list_target_length_if_necessary(size_t rs_lengths) { + guarantee( adaptive_young_list_length(), "should not call this otherwise" ); + + if (rs_lengths > _rs_lengths_prediction) { + // add 10% to avoid having to recalculate often + size_t rs_lengths_prediction = rs_lengths * 1100 / 1000; + update_rs_lengths_prediction(rs_lengths_prediction); + + update_young_list_max_and_target_length(rs_lengths_prediction); + } +} + +void G1Policy::update_rs_lengths_prediction() { + update_rs_lengths_prediction(_analytics->predict_rs_lengths()); +} + +void G1Policy::update_rs_lengths_prediction(size_t prediction) { + if (collector_state()->gcs_are_young() && adaptive_young_list_length()) { + _rs_lengths_prediction = prediction; + } +} + +#ifndef PRODUCT +bool G1Policy::verify_young_ages() { + HeapRegion* head = _g1->young_list()->first_region(); + return + verify_young_ages(head, _short_lived_surv_rate_group); + // also call verify_young_ages on any additional surv rate groups +} + +bool G1Policy::verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group) { + guarantee( surv_rate_group != NULL, "pre-condition" ); + + const char* name = surv_rate_group->name(); + bool ret = true; + int prev_age = -1; + + for (HeapRegion* curr = head; + curr != NULL; + curr = curr->get_next_young_region()) { + SurvRateGroup* group = curr->surv_rate_group(); + if (group == NULL && !curr->is_survivor()) { + log_error(gc, verify)("## %s: encountered NULL surv_rate_group", name); + ret = false; + } + + if (surv_rate_group == group) { + int age = curr->age_in_surv_rate_group(); + + if (age < 0) { + log_error(gc, verify)("## %s: encountered negative age", name); + ret = false; + } + + if (age <= prev_age) { + log_error(gc, verify)("## %s: region ages are not strictly increasing (%d, %d)", name, age, prev_age); + ret = false; + } + prev_age = age; + } + } + + return ret; +} +#endif // PRODUCT + +void G1Policy::record_full_collection_start() { + _full_collection_start_sec = os::elapsedTime(); + // Release the future to-space so that it is available for compaction into. + collector_state()->set_full_collection(true); +} + +void G1Policy::record_full_collection_end() { + // Consider this like a collection pause for the purposes of allocation + // since last pause. + double end_sec = os::elapsedTime(); + double full_gc_time_sec = end_sec - _full_collection_start_sec; + double full_gc_time_ms = full_gc_time_sec * 1000.0; + + _analytics->update_recent_gc_times(end_sec, full_gc_time_ms); + + collector_state()->set_full_collection(false); + + // "Nuke" the heuristics that control the young/mixed GC + // transitions and make sure we start with young GCs after the Full GC. + collector_state()->set_gcs_are_young(true); + collector_state()->set_last_young_gc(false); + collector_state()->set_initiate_conc_mark_if_possible(need_to_start_conc_mark("end of Full GC", 0)); + collector_state()->set_during_initial_mark_pause(false); + collector_state()->set_in_marking_window(false); + collector_state()->set_in_marking_window_im(false); + + _short_lived_surv_rate_group->start_adding_regions(); + // also call this on any additional surv rate groups + + _free_regions_at_end_of_collection = _g1->num_free_regions(); + // Reset survivors SurvRateGroup. + _survivor_surv_rate_group->reset(); + update_young_list_max_and_target_length(); + update_rs_lengths_prediction(); + cset_chooser()->clear(); + + _bytes_allocated_in_old_since_last_gc = 0; + + record_pause(FullGC, _full_collection_start_sec, end_sec); +} + +void G1Policy::record_collection_pause_start(double start_time_sec) { + // We only need to do this here as the policy will only be applied + // to the GC we're about to start. so, no point is calculating this + // every time we calculate / recalculate the target young length. + update_survivors_policy(); + + assert(_g1->used() == _g1->recalculate_used(), + "sanity, used: " SIZE_FORMAT " recalculate_used: " SIZE_FORMAT, + _g1->used(), _g1->recalculate_used()); + + phase_times()->record_cur_collection_start_sec(start_time_sec); + _pending_cards = _g1->pending_card_num(); + + _collection_set->reset_bytes_used_before(); + _bytes_copied_during_gc = 0; + + collector_state()->set_last_gc_was_young(false); + + // do that for any other surv rate groups + _short_lived_surv_rate_group->stop_adding_regions(); + _survivors_age_table.clear(); + + assert( verify_young_ages(), "region age verification" ); +} + +void G1Policy::record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) { + collector_state()->set_during_marking(true); + assert(!collector_state()->initiate_conc_mark_if_possible(), "we should have cleared it by now"); + collector_state()->set_during_initial_mark_pause(false); +} + +void G1Policy::record_concurrent_mark_remark_start() { + _mark_remark_start_sec = os::elapsedTime(); + collector_state()->set_during_marking(false); +} + +void G1Policy::record_concurrent_mark_remark_end() { + double end_time_sec = os::elapsedTime(); + double elapsed_time_ms = (end_time_sec - _mark_remark_start_sec)*1000.0; + _analytics->report_concurrent_mark_remark_times_ms(elapsed_time_ms); + _analytics->append_prev_collection_pause_end_ms(elapsed_time_ms); + + record_pause(Remark, _mark_remark_start_sec, end_time_sec); +} + +void G1Policy::record_concurrent_mark_cleanup_start() { + _mark_cleanup_start_sec = os::elapsedTime(); +} + +void G1Policy::record_concurrent_mark_cleanup_completed() { + bool should_continue_with_reclaim = next_gc_should_be_mixed("request last young-only gc", + "skip last young-only gc"); + collector_state()->set_last_young_gc(should_continue_with_reclaim); + // We skip the marking phase. + if (!should_continue_with_reclaim) { + abort_time_to_mixed_tracking(); + } + collector_state()->set_in_marking_window(false); +} + +double G1Policy::average_time_ms(G1GCPhaseTimes::GCParPhases phase) const { + return phase_times()->average_time_ms(phase); +} + +double G1Policy::young_other_time_ms() const { + return phase_times()->young_cset_choice_time_ms() + + phase_times()->young_free_cset_time_ms(); +} + +double G1Policy::non_young_other_time_ms() const { + return phase_times()->non_young_cset_choice_time_ms() + + phase_times()->non_young_free_cset_time_ms(); + +} + +double G1Policy::other_time_ms(double pause_time_ms) const { + return pause_time_ms - + average_time_ms(G1GCPhaseTimes::UpdateRS) - + average_time_ms(G1GCPhaseTimes::ScanRS) - + average_time_ms(G1GCPhaseTimes::ObjCopy) - + average_time_ms(G1GCPhaseTimes::Termination); +} + +double G1Policy::constant_other_time_ms(double pause_time_ms) const { + return other_time_ms(pause_time_ms) - young_other_time_ms() - non_young_other_time_ms(); +} + +CollectionSetChooser* G1Policy::cset_chooser() const { + return _collection_set->cset_chooser(); +} + +bool G1Policy::about_to_start_mixed_phase() const { + return _g1->concurrent_mark()->cmThread()->during_cycle() || collector_state()->last_young_gc(); +} + +bool G1Policy::need_to_start_conc_mark(const char* source, size_t alloc_word_size) { + if (about_to_start_mixed_phase()) { + return false; + } + + size_t marking_initiating_used_threshold = _ihop_control->get_conc_mark_start_threshold(); + + size_t cur_used_bytes = _g1->non_young_capacity_bytes(); + size_t alloc_byte_size = alloc_word_size * HeapWordSize; + size_t marking_request_bytes = cur_used_bytes + alloc_byte_size; + + bool result = false; + if (marking_request_bytes > marking_initiating_used_threshold) { + result = collector_state()->gcs_are_young() && !collector_state()->last_young_gc(); + log_debug(gc, ergo, ihop)("%s occupancy: " SIZE_FORMAT "B allocation request: " SIZE_FORMAT "B threshold: " SIZE_FORMAT "B (%1.2f) source: %s", + result ? "Request concurrent cycle initiation (occupancy higher than threshold)" : "Do not request concurrent cycle initiation (still doing mixed collections)", + cur_used_bytes, alloc_byte_size, marking_initiating_used_threshold, (double) marking_initiating_used_threshold / _g1->capacity() * 100, source); + } + + return result; +} + +// Anything below that is considered to be zero +#define MIN_TIMER_GRANULARITY 0.0000001 + +void G1Policy::record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) { + double end_time_sec = os::elapsedTime(); + + size_t cur_used_bytes = _g1->used(); + assert(cur_used_bytes == _g1->recalculate_used(), "It should!"); + bool last_pause_included_initial_mark = false; + bool update_stats = !_g1->evacuation_failed(); + + NOT_PRODUCT(_short_lived_surv_rate_group->print()); + + record_pause(young_gc_pause_kind(), end_time_sec - pause_time_ms / 1000.0, end_time_sec); + + last_pause_included_initial_mark = collector_state()->during_initial_mark_pause(); + if (last_pause_included_initial_mark) { + record_concurrent_mark_init_end(0.0); + } else { + maybe_start_marking(); + } + + double app_time_ms = (phase_times()->cur_collection_start_sec() * 1000.0 - _analytics->prev_collection_pause_end_ms()); + if (app_time_ms < MIN_TIMER_GRANULARITY) { + // This usually happens due to the timer not having the required + // granularity. Some Linuxes are the usual culprits. + // We'll just set it to something (arbitrarily) small. + app_time_ms = 1.0; + } + + if (update_stats) { + // We maintain the invariant that all objects allocated by mutator + // threads will be allocated out of eden regions. So, we can use + // the eden region number allocated since the previous GC to + // calculate the application's allocate rate. The only exception + // to that is humongous objects that are allocated separately. But + // given that humongous object allocations do not really affect + // either the pause's duration nor when the next pause will take + // place we can safely ignore them here. + uint regions_allocated = _collection_set->eden_region_length(); + double alloc_rate_ms = (double) regions_allocated / app_time_ms; + _analytics->report_alloc_rate_ms(alloc_rate_ms); + + double interval_ms = + (end_time_sec - _analytics->last_known_gc_end_time_sec()) * 1000.0; + _analytics->update_recent_gc_times(end_time_sec, pause_time_ms); + _analytics->compute_pause_time_ratio(interval_ms, pause_time_ms); + } + + bool new_in_marking_window = collector_state()->in_marking_window(); + bool new_in_marking_window_im = false; + if (last_pause_included_initial_mark) { + new_in_marking_window = true; + new_in_marking_window_im = true; + } + + if (collector_state()->last_young_gc()) { + // This is supposed to to be the "last young GC" before we start + // doing mixed GCs. Here we decide whether to start mixed GCs or not. + assert(!last_pause_included_initial_mark, "The last young GC is not allowed to be an initial mark GC"); + + if (next_gc_should_be_mixed("start mixed GCs", + "do not start mixed GCs")) { + collector_state()->set_gcs_are_young(false); + } else { + // We aborted the mixed GC phase early. + abort_time_to_mixed_tracking(); + } + + collector_state()->set_last_young_gc(false); + } + + if (!collector_state()->last_gc_was_young()) { + // This is a mixed GC. Here we decide whether to continue doing + // mixed GCs or not. + if (!next_gc_should_be_mixed("continue mixed GCs", + "do not continue mixed GCs")) { + collector_state()->set_gcs_are_young(true); + + maybe_start_marking(); + } + } + + _short_lived_surv_rate_group->start_adding_regions(); + // Do that for any other surv rate groups + + double scan_hcc_time_ms = ConcurrentG1Refine::hot_card_cache_enabled() ? average_time_ms(G1GCPhaseTimes::ScanHCC) : 0.0; + + if (update_stats) { + double cost_per_card_ms = 0.0; + if (_pending_cards > 0) { + cost_per_card_ms = (average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms) / (double) _pending_cards; + _analytics->report_cost_per_card_ms(cost_per_card_ms); + } + _analytics->report_cost_scan_hcc(scan_hcc_time_ms); + + double cost_per_entry_ms = 0.0; + if (cards_scanned > 10) { + cost_per_entry_ms = average_time_ms(G1GCPhaseTimes::ScanRS) / (double) cards_scanned; + _analytics->report_cost_per_entry_ms(cost_per_entry_ms, collector_state()->last_gc_was_young()); + } + + if (_max_rs_lengths > 0) { + double cards_per_entry_ratio = + (double) cards_scanned / (double) _max_rs_lengths; + _analytics->report_cards_per_entry_ratio(cards_per_entry_ratio, collector_state()->last_gc_was_young()); + } + + // This is defensive. For a while _max_rs_lengths could get + // smaller than _recorded_rs_lengths which was causing + // rs_length_diff to get very large and mess up the RSet length + // predictions. The reason was unsafe concurrent updates to the + // _inc_cset_recorded_rs_lengths field which the code below guards + // against (see CR 7118202). This bug has now been fixed (see CR + // 7119027). However, I'm still worried that + // _inc_cset_recorded_rs_lengths might still end up somewhat + // inaccurate. The concurrent refinement thread calculates an + // RSet's length concurrently with other CR threads updating it + // which might cause it to calculate the length incorrectly (if, + // say, it's in mid-coarsening). So I'll leave in the defensive + // conditional below just in case. + size_t rs_length_diff = 0; + size_t recorded_rs_lengths = _collection_set->recorded_rs_lengths(); + if (_max_rs_lengths > recorded_rs_lengths) { + rs_length_diff = _max_rs_lengths - recorded_rs_lengths; + } + _analytics->report_rs_length_diff((double) rs_length_diff); + + size_t freed_bytes = heap_used_bytes_before_gc - cur_used_bytes; + size_t copied_bytes = _collection_set->bytes_used_before() - freed_bytes; + double cost_per_byte_ms = 0.0; + + if (copied_bytes > 0) { + cost_per_byte_ms = average_time_ms(G1GCPhaseTimes::ObjCopy) / (double) copied_bytes; + _analytics->report_cost_per_byte_ms(cost_per_byte_ms, collector_state()->in_marking_window()); + } + + if (_collection_set->young_region_length() > 0) { + _analytics->report_young_other_cost_per_region_ms(young_other_time_ms() / + _collection_set->young_region_length()); + } + + if (_collection_set->old_region_length() > 0) { + _analytics->report_non_young_other_cost_per_region_ms(non_young_other_time_ms() / + _collection_set->old_region_length()); + } + + _analytics->report_constant_other_time_ms(constant_other_time_ms(pause_time_ms)); + + _analytics->report_pending_cards((double) _pending_cards); + _analytics->report_rs_lengths((double) _max_rs_lengths); + } + + collector_state()->set_in_marking_window(new_in_marking_window); + collector_state()->set_in_marking_window_im(new_in_marking_window_im); + _free_regions_at_end_of_collection = _g1->num_free_regions(); + // IHOP control wants to know the expected young gen length if it were not + // restrained by the heap reserve. Using the actual length would make the + // prediction too small and the limit the young gen every time we get to the + // predicted target occupancy. + size_t last_unrestrained_young_length = update_young_list_max_and_target_length(); + update_rs_lengths_prediction(); + + update_ihop_prediction(app_time_ms / 1000.0, + _bytes_allocated_in_old_since_last_gc, + last_unrestrained_young_length * HeapRegion::GrainBytes); + _bytes_allocated_in_old_since_last_gc = 0; + + _ihop_control->send_trace_event(_g1->gc_tracer_stw()); + + // Note that _mmu_tracker->max_gc_time() returns the time in seconds. + double update_rs_time_goal_ms = _mmu_tracker->max_gc_time() * MILLIUNITS * G1RSetUpdatingPauseTimePercent / 100.0; + + if (update_rs_time_goal_ms < scan_hcc_time_ms) { + log_debug(gc, ergo, refine)("Adjust concurrent refinement thresholds (scanning the HCC expected to take longer than Update RS time goal)." + "Update RS time goal: %1.2fms Scan HCC time: %1.2fms", + update_rs_time_goal_ms, scan_hcc_time_ms); + + update_rs_time_goal_ms = 0; + } else { + update_rs_time_goal_ms -= scan_hcc_time_ms; + } + _g1->concurrent_g1_refine()->adjust(average_time_ms(G1GCPhaseTimes::UpdateRS) - scan_hcc_time_ms, + phase_times()->sum_thread_work_items(G1GCPhaseTimes::UpdateRS), + update_rs_time_goal_ms); + + cset_chooser()->verify(); +} + +G1IHOPControl* G1Policy::create_ihop_control() const { + if (G1UseAdaptiveIHOP) { + return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent, + &_predictor, + G1ReservePercent, + G1HeapWastePercent); + } else { + return new G1StaticIHOPControl(InitiatingHeapOccupancyPercent); + } +} + +void G1Policy::update_ihop_prediction(double mutator_time_s, + size_t mutator_alloc_bytes, + size_t young_gen_size) { + // Always try to update IHOP prediction. Even evacuation failures give information + // about e.g. whether to start IHOP earlier next time. + + // Avoid using really small application times that might create samples with + // very high or very low values. They may be caused by e.g. back-to-back gcs. + double const min_valid_time = 1e-6; + + bool report = false; + + double marking_to_mixed_time = -1.0; + if (!collector_state()->last_gc_was_young() && _initial_mark_to_mixed.has_result()) { + marking_to_mixed_time = _initial_mark_to_mixed.last_marking_time(); + assert(marking_to_mixed_time > 0.0, + "Initial mark to mixed time must be larger than zero but is %.3f", + marking_to_mixed_time); + if (marking_to_mixed_time > min_valid_time) { + _ihop_control->update_marking_length(marking_to_mixed_time); + report = true; + } + } + + // As an approximation for the young gc promotion rates during marking we use + // all of them. In many applications there are only a few if any young gcs during + // marking, which makes any prediction useless. This increases the accuracy of the + // prediction. + if (collector_state()->last_gc_was_young() && mutator_time_s > min_valid_time) { + _ihop_control->update_allocation_info(mutator_time_s, mutator_alloc_bytes, young_gen_size); + report = true; + } + + if (report) { + report_ihop_statistics(); + } +} + +void G1Policy::report_ihop_statistics() { + _ihop_control->print(); +} + +void G1Policy::print_phases() { + phase_times()->print(); +} + +double G1Policy::predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const { + TruncatedSeq* seq = surv_rate_group->get_seq(age); + guarantee(seq->num() > 0, "There should be some young gen survivor samples available. Tried to access with age %d", age); + double pred = _predictor.get_new_prediction(seq); + if (pred > 1.0) { + pred = 1.0; + } + return pred; +} + +double G1Policy::predict_yg_surv_rate(int age) const { + return predict_yg_surv_rate(age, _short_lived_surv_rate_group); +} + +double G1Policy::accum_yg_surv_rate_pred(int age) const { + return _short_lived_surv_rate_group->accum_surv_rate_pred(age); +} + +double G1Policy::predict_base_elapsed_time_ms(size_t pending_cards, + size_t scanned_cards) const { + return + _analytics->predict_rs_update_time_ms(pending_cards) + + _analytics->predict_rs_scan_time_ms(scanned_cards, collector_state()->gcs_are_young()) + + _analytics->predict_constant_other_time_ms(); +} + +double G1Policy::predict_base_elapsed_time_ms(size_t pending_cards) const { + size_t rs_length = _analytics->predict_rs_lengths() + _analytics->predict_rs_length_diff(); + size_t card_num = _analytics->predict_card_num(rs_length, collector_state()->gcs_are_young()); + return predict_base_elapsed_time_ms(pending_cards, card_num); +} + +size_t G1Policy::predict_bytes_to_copy(HeapRegion* hr) const { + size_t bytes_to_copy; + if (hr->is_marked()) + bytes_to_copy = hr->max_live_bytes(); + else { + assert(hr->is_young() && hr->age_in_surv_rate_group() != -1, "invariant"); + int age = hr->age_in_surv_rate_group(); + double yg_surv_rate = predict_yg_surv_rate(age, hr->surv_rate_group()); + bytes_to_copy = (size_t) (hr->used() * yg_surv_rate); + } + return bytes_to_copy; +} + +double G1Policy::predict_region_elapsed_time_ms(HeapRegion* hr, + bool for_young_gc) const { + size_t rs_length = hr->rem_set()->occupied(); + // Predicting the number of cards is based on which type of GC + // we're predicting for. + size_t card_num = _analytics->predict_card_num(rs_length, for_young_gc); + size_t bytes_to_copy = predict_bytes_to_copy(hr); + + double region_elapsed_time_ms = + _analytics->predict_rs_scan_time_ms(card_num, collector_state()->gcs_are_young()) + + _analytics->predict_object_copy_time_ms(bytes_to_copy, collector_state()->during_concurrent_mark()); + + // The prediction of the "other" time for this region is based + // upon the region type and NOT the GC type. + if (hr->is_young()) { + region_elapsed_time_ms += _analytics->predict_young_other_time_ms(1); + } else { + region_elapsed_time_ms += _analytics->predict_non_young_other_time_ms(1); + } + return region_elapsed_time_ms; +} + + +void G1Policy::print_yg_surv_rate_info() const { +#ifndef PRODUCT + _short_lived_surv_rate_group->print_surv_rate_summary(); + // add this call for any other surv rate groups +#endif // PRODUCT +} + +bool G1Policy::is_young_list_full() const { + uint young_list_length = _g1->young_list()->length(); + uint young_list_target_length = _young_list_target_length; + return young_list_length >= young_list_target_length; +} + +bool G1Policy::can_expand_young_list() const { + uint young_list_length = _g1->young_list()->length(); + uint young_list_max_length = _young_list_max_length; + return young_list_length < young_list_max_length; +} + +bool G1Policy::adaptive_young_list_length() const { + return _young_gen_sizer.adaptive_young_list_length(); +} + +void G1Policy::update_max_gc_locker_expansion() { + uint expansion_region_num = 0; + if (GCLockerEdenExpansionPercent > 0) { + double perc = (double) GCLockerEdenExpansionPercent / 100.0; + double expansion_region_num_d = perc * (double) _young_list_target_length; + // We use ceiling so that if expansion_region_num_d is > 0.0 (but + // less than 1.0) we'll get 1. + expansion_region_num = (uint) ceil(expansion_region_num_d); + } else { + assert(expansion_region_num == 0, "sanity"); + } + _young_list_max_length = _young_list_target_length + expansion_region_num; + assert(_young_list_target_length <= _young_list_max_length, "post-condition"); +} + +// Calculates survivor space parameters. +void G1Policy::update_survivors_policy() { + double max_survivor_regions_d = + (double) _young_list_target_length / (double) SurvivorRatio; + // We use ceiling so that if max_survivor_regions_d is > 0.0 (but + // smaller than 1.0) we'll get 1. + _max_survivor_regions = (uint) ceil(max_survivor_regions_d); + + GCPolicyCounters* counters = _g1->collector_policy()->counters(); + _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold( + HeapRegion::GrainWords * _max_survivor_regions, counters); +} + +bool G1Policy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) { + // We actually check whether we are marking here and not if we are in a + // reclamation phase. This means that we will schedule a concurrent mark + // even while we are still in the process of reclaiming memory. + bool during_cycle = _g1->concurrent_mark()->cmThread()->during_cycle(); + if (!during_cycle) { + log_debug(gc, ergo)("Request concurrent cycle initiation (requested by GC cause). GC cause: %s", GCCause::to_string(gc_cause)); + collector_state()->set_initiate_conc_mark_if_possible(true); + return true; + } else { + log_debug(gc, ergo)("Do not request concurrent cycle initiation (concurrent cycle already in progress). GC cause: %s", GCCause::to_string(gc_cause)); + return false; + } +} + +void G1Policy::initiate_conc_mark() { + collector_state()->set_during_initial_mark_pause(true); + collector_state()->set_initiate_conc_mark_if_possible(false); +} + +void G1Policy::decide_on_conc_mark_initiation() { + // We are about to decide on whether this pause will be an + // initial-mark pause. + + // First, collector_state()->during_initial_mark_pause() should not be already set. We + // will set it here if we have to. However, it should be cleared by + // the end of the pause (it's only set for the duration of an + // initial-mark pause). + assert(!collector_state()->during_initial_mark_pause(), "pre-condition"); + + if (collector_state()->initiate_conc_mark_if_possible()) { + // We had noticed on a previous pause that the heap occupancy has + // gone over the initiating threshold and we should start a + // concurrent marking cycle. So we might initiate one. + + if (!about_to_start_mixed_phase() && collector_state()->gcs_are_young()) { + // Initiate a new initial mark if there is no marking or reclamation going on. + initiate_conc_mark(); + log_debug(gc, ergo)("Initiate concurrent cycle (concurrent cycle initiation requested)"); + } else if (_g1->is_user_requested_concurrent_full_gc(_g1->gc_cause())) { + // Initiate a user requested initial mark. An initial mark must be young only + // GC, so the collector state must be updated to reflect this. + collector_state()->set_gcs_are_young(true); + collector_state()->set_last_young_gc(false); + + abort_time_to_mixed_tracking(); + initiate_conc_mark(); + log_debug(gc, ergo)("Initiate concurrent cycle (user requested concurrent cycle)"); + } else { + // The concurrent marking thread is still finishing up the + // previous cycle. If we start one right now the two cycles + // overlap. In particular, the concurrent marking thread might + // be in the process of clearing the next marking bitmap (which + // we will use for the next cycle if we start one). Starting a + // cycle now will be bad given that parts of the marking + // information might get cleared by the marking thread. And we + // cannot wait for the marking thread to finish the cycle as it + // periodically yields while clearing the next marking bitmap + // and, if it's in a yield point, it's waiting for us to + // finish. So, at this point we will not start a cycle and we'll + // let the concurrent marking thread complete the last one. + log_debug(gc, ergo)("Do not initiate concurrent cycle (concurrent cycle already in progress)"); + } + } +} + +void G1Policy::record_concurrent_mark_cleanup_end() { + cset_chooser()->rebuild(_g1->workers(), _g1->num_regions()); + + double end_sec = os::elapsedTime(); + double elapsed_time_ms = (end_sec - _mark_cleanup_start_sec) * 1000.0; + _analytics->report_concurrent_mark_cleanup_times_ms(elapsed_time_ms); + _analytics->append_prev_collection_pause_end_ms(elapsed_time_ms); + + record_pause(Cleanup, _mark_cleanup_start_sec, end_sec); +} + +double G1Policy::reclaimable_bytes_perc(size_t reclaimable_bytes) const { + // Returns the given amount of reclaimable bytes (that represents + // the amount of reclaimable space still to be collected) as a + // percentage of the current heap capacity. + size_t capacity_bytes = _g1->capacity(); + return (double) reclaimable_bytes * 100.0 / (double) capacity_bytes; +} + +void G1Policy::maybe_start_marking() { + if (need_to_start_conc_mark("end of GC")) { + // Note: this might have already been set, if during the last + // pause we decided to start a cycle but at the beginning of + // this pause we decided to postpone it. That's OK. + collector_state()->set_initiate_conc_mark_if_possible(true); + } +} + +G1Policy::PauseKind G1Policy::young_gc_pause_kind() const { + assert(!collector_state()->full_collection(), "must be"); + if (collector_state()->during_initial_mark_pause()) { + assert(collector_state()->last_gc_was_young(), "must be"); + assert(!collector_state()->last_young_gc(), "must be"); + return InitialMarkGC; + } else if (collector_state()->last_young_gc()) { + assert(!collector_state()->during_initial_mark_pause(), "must be"); + assert(collector_state()->last_gc_was_young(), "must be"); + return LastYoungGC; + } else if (!collector_state()->last_gc_was_young()) { + assert(!collector_state()->during_initial_mark_pause(), "must be"); + assert(!collector_state()->last_young_gc(), "must be"); + return MixedGC; + } else { + assert(collector_state()->last_gc_was_young(), "must be"); + assert(!collector_state()->during_initial_mark_pause(), "must be"); + assert(!collector_state()->last_young_gc(), "must be"); + return YoungOnlyGC; + } +} + +void G1Policy::record_pause(PauseKind kind, double start, double end) { + // Manage the MMU tracker. For some reason it ignores Full GCs. + if (kind != FullGC) { + _mmu_tracker->add_pause(start, end); + } + // Manage the mutator time tracking from initial mark to first mixed gc. + switch (kind) { + case FullGC: + abort_time_to_mixed_tracking(); + break; + case Cleanup: + case Remark: + case YoungOnlyGC: + case LastYoungGC: + _initial_mark_to_mixed.add_pause(end - start); + break; + case InitialMarkGC: + _initial_mark_to_mixed.record_initial_mark_end(end); + break; + case MixedGC: + _initial_mark_to_mixed.record_mixed_gc_start(start); + break; + default: + ShouldNotReachHere(); + } +} + +void G1Policy::abort_time_to_mixed_tracking() { + _initial_mark_to_mixed.reset(); +} + +bool G1Policy::next_gc_should_be_mixed(const char* true_action_str, + const char* false_action_str) const { + if (cset_chooser()->is_empty()) { + log_debug(gc, ergo)("%s (candidate old regions not available)", false_action_str); + return false; + } + + // Is the amount of uncollected reclaimable space above G1HeapWastePercent? + size_t reclaimable_bytes = cset_chooser()->remaining_reclaimable_bytes(); + double reclaimable_perc = reclaimable_bytes_perc(reclaimable_bytes); + double threshold = (double) G1HeapWastePercent; + if (reclaimable_perc <= threshold) { + log_debug(gc, ergo)("%s (reclaimable percentage not over threshold). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT, + false_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_perc, G1HeapWastePercent); + return false; + } + log_debug(gc, ergo)("%s (candidate old regions available). candidate old regions: %u reclaimable: " SIZE_FORMAT " (%1.2f) threshold: " UINTX_FORMAT, + true_action_str, cset_chooser()->remaining_regions(), reclaimable_bytes, reclaimable_perc, G1HeapWastePercent); + return true; +} + +uint G1Policy::calc_min_old_cset_length() const { + // The min old CSet region bound is based on the maximum desired + // number of mixed GCs after a cycle. I.e., even if some old regions + // look expensive, we should add them to the CSet anyway to make + // sure we go through the available old regions in no more than the + // maximum desired number of mixed GCs. + // + // The calculation is based on the number of marked regions we added + // to the CSet chooser in the first place, not how many remain, so + // that the result is the same during all mixed GCs that follow a cycle. + + const size_t region_num = (size_t) cset_chooser()->length(); + const size_t gc_num = (size_t) MAX2(G1MixedGCCountTarget, (uintx) 1); + size_t result = region_num / gc_num; + // emulate ceiling + if (result * gc_num < region_num) { + result += 1; + } + return (uint) result; +} + +uint G1Policy::calc_max_old_cset_length() const { + // The max old CSet region bound is based on the threshold expressed + // as a percentage of the heap size. I.e., it should bound the + // number of old regions added to the CSet irrespective of how many + // of them are available. + + const G1CollectedHeap* g1h = G1CollectedHeap::heap(); + const size_t region_num = g1h->num_regions(); + const size_t perc = (size_t) G1OldCSetRegionThresholdPercent; + size_t result = region_num * perc / 100; + // emulate ceiling + if (100 * result < region_num * perc) { + result += 1; + } + return (uint) result; +} + +void G1Policy::finalize_collection_set(double target_pause_time_ms) { + double time_remaining_ms = _collection_set->finalize_young_part(target_pause_time_ms); + _collection_set->finalize_old_part(time_remaining_ms); +} diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.hpp b/hotspot/src/share/vm/gc/g1/g1Policy.hpp new file mode 100644 index 00000000000..9bbf22ab669 --- /dev/null +++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp @@ -0,0 +1,434 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_GC_G1_G1POLICY_HPP +#define SHARE_VM_GC_G1_G1POLICY_HPP + +#include "gc/g1/g1CollectorState.hpp" +#include "gc/g1/g1GCPhaseTimes.hpp" +#include "gc/g1/g1InCSetState.hpp" +#include "gc/g1/g1InitialMarkToMixedTimeTracker.hpp" +#include "gc/g1/g1MMUTracker.hpp" +#include "gc/g1/g1Predictions.hpp" +#include "gc/g1/g1YoungGenSizer.hpp" +#include "gc/shared/gcCause.hpp" +#include "utilities/pair.hpp" + +// A G1Policy makes policy decisions that determine the +// characteristics of the collector. Examples include: +// * choice of collection set. +// * when to collect. + +class HeapRegion; +class G1CollectionSet; +class CollectionSetChooser; +class G1IHOPControl; +class G1Analytics; +class G1YoungGenSizer; + +class G1Policy: public CHeapObj { + private: + G1IHOPControl* _ihop_control; + + G1IHOPControl* create_ihop_control() const; + // Update the IHOP control with necessary statistics. + void update_ihop_prediction(double mutator_time_s, + size_t mutator_alloc_bytes, + size_t young_gen_size); + void report_ihop_statistics(); + + G1Predictions _predictor; + G1Analytics* _analytics; + G1MMUTracker* _mmu_tracker; + + double _full_collection_start_sec; + + uint _young_list_target_length; + uint _young_list_fixed_length; + + // The max number of regions we can extend the eden by while the GC + // locker is active. This should be >= _young_list_target_length; + uint _young_list_max_length; + + SurvRateGroup* _short_lived_surv_rate_group; + SurvRateGroup* _survivor_surv_rate_group; + + double _reserve_factor; + uint _reserve_regions; + + G1YoungGenSizer _young_gen_sizer; + + uint _free_regions_at_end_of_collection; + + size_t _max_rs_lengths; + + size_t _rs_lengths_prediction; + +#ifndef PRODUCT + bool verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group); +#endif // PRODUCT + + double _pause_time_target_ms; + + size_t _pending_cards; + + // The amount of allocated bytes in old gen during the last mutator and the following + // young GC phase. + size_t _bytes_allocated_in_old_since_last_gc; + + G1InitialMarkToMixedTimeTracker _initial_mark_to_mixed; +public: + const G1Predictions& predictor() const { return _predictor; } + const G1Analytics* analytics() const { return const_cast(_analytics); } + + // Add the given number of bytes to the total number of allocated bytes in the old gen. + void add_bytes_allocated_in_old_since_last_gc(size_t bytes) { _bytes_allocated_in_old_since_last_gc += bytes; } + + // Accessors + + void set_region_eden(HeapRegion* hr, int young_index_in_cset) { + hr->set_eden(); + hr->install_surv_rate_group(_short_lived_surv_rate_group); + hr->set_young_index_in_cset(young_index_in_cset); + } + + void set_region_survivor(HeapRegion* hr, int young_index_in_cset) { + assert(hr->is_survivor(), "pre-condition"); + hr->install_surv_rate_group(_survivor_surv_rate_group); + hr->set_young_index_in_cset(young_index_in_cset); + } + +#ifndef PRODUCT + bool verify_young_ages(); +#endif // PRODUCT + + void record_max_rs_lengths(size_t rs_lengths) { + _max_rs_lengths = rs_lengths; + } + + + double predict_base_elapsed_time_ms(size_t pending_cards) const; + double predict_base_elapsed_time_ms(size_t pending_cards, + size_t scanned_cards) const; + size_t predict_bytes_to_copy(HeapRegion* hr) const; + double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const; + + double predict_survivor_regions_evac_time() const; + + bool should_update_surv_rate_group_predictors() { + return collector_state()->last_gc_was_young() && !collector_state()->in_marking_window(); + } + + void cset_regions_freed() { + bool update = should_update_surv_rate_group_predictors(); + + _short_lived_surv_rate_group->all_surviving_words_recorded(update); + _survivor_surv_rate_group->all_surviving_words_recorded(update); + } + + G1MMUTracker* mmu_tracker() { + return _mmu_tracker; + } + + const G1MMUTracker* mmu_tracker() const { + return _mmu_tracker; + } + + double max_pause_time_ms() const { + return _mmu_tracker->max_gc_time() * 1000.0; + } + + // Returns an estimate of the survival rate of the region at yg-age + // "yg_age". + double predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const; + + double predict_yg_surv_rate(int age) const; + + double accum_yg_surv_rate_pred(int age) const; + +protected: + G1CollectionSet* _collection_set; + virtual double average_time_ms(G1GCPhaseTimes::GCParPhases phase) const; + virtual double other_time_ms(double pause_time_ms) const; + + double young_other_time_ms() const; + double non_young_other_time_ms() const; + double constant_other_time_ms(double pause_time_ms) const; + + CollectionSetChooser* cset_chooser() const; +private: + + // The number of bytes copied during the GC. + size_t _bytes_copied_during_gc; + + // Stash a pointer to the g1 heap. + G1CollectedHeap* _g1; + + G1GCPhaseTimes* _phase_times; + + // This set of variables tracks the collector efficiency, in order to + // determine whether we should initiate a new marking. + double _mark_remark_start_sec; + double _mark_cleanup_start_sec; + + // Updates the internal young list maximum and target lengths. Returns the + // unbounded young list target length. + uint update_young_list_max_and_target_length(); + uint update_young_list_max_and_target_length(size_t rs_lengths); + + // Update the young list target length either by setting it to the + // desired fixed value or by calculating it using G1's pause + // prediction model. If no rs_lengths parameter is passed, predict + // the RS lengths using the prediction model, otherwise use the + // given rs_lengths as the prediction. + // Returns the unbounded young list target length. + uint update_young_list_target_length(size_t rs_lengths); + + // Calculate and return the minimum desired young list target + // length. This is the minimum desired young list length according + // to the user's inputs. + uint calculate_young_list_desired_min_length(uint base_min_length) const; + + // Calculate and return the maximum desired young list target + // length. This is the maximum desired young list length according + // to the user's inputs. + uint calculate_young_list_desired_max_length() const; + + // Calculate and return the maximum young list target length that + // can fit into the pause time goal. The parameters are: rs_lengths + // represent the prediction of how large the young RSet lengths will + // be, base_min_length is the already existing number of regions in + // the young list, min_length and max_length are the desired min and + // max young list length according to the user's inputs. + uint calculate_young_list_target_length(size_t rs_lengths, + uint base_min_length, + uint desired_min_length, + uint desired_max_length) const; + + // Result of the bounded_young_list_target_length() method, containing both the + // bounded as well as the unbounded young list target lengths in this order. + typedef Pair YoungTargetLengths; + YoungTargetLengths young_list_target_lengths(size_t rs_lengths) const; + + void update_rs_lengths_prediction(); + void update_rs_lengths_prediction(size_t prediction); + + // Check whether a given young length (young_length) fits into the + // given target pause time and whether the prediction for the amount + // of objects to be copied for the given length will fit into the + // given free space (expressed by base_free_regions). It is used by + // calculate_young_list_target_length(). + bool predict_will_fit(uint young_length, double base_time_ms, + uint base_free_regions, double target_pause_time_ms) const; + +public: + size_t pending_cards() const { return _pending_cards; } + + // Calculate the minimum number of old regions we'll add to the CSet + // during a mixed GC. + uint calc_min_old_cset_length() const; + + // Calculate the maximum number of old regions we'll add to the CSet + // during a mixed GC. + uint calc_max_old_cset_length() const; + + // Returns the given amount of uncollected reclaimable space + // as a percentage of the current heap capacity. + double reclaimable_bytes_perc(size_t reclaimable_bytes) const; + +private: + // Sets up marking if proper conditions are met. + void maybe_start_marking(); + + // The kind of STW pause. + enum PauseKind { + FullGC, + YoungOnlyGC, + MixedGC, + LastYoungGC, + InitialMarkGC, + Cleanup, + Remark + }; + + // Calculate PauseKind from internal state. + PauseKind young_gc_pause_kind() const; + // Record the given STW pause with the given start and end times (in s). + void record_pause(PauseKind kind, double start, double end); + // Indicate that we aborted marking before doing any mixed GCs. + void abort_time_to_mixed_tracking(); +public: + + G1Policy(); + + virtual ~G1Policy(); + + G1CollectorState* collector_state() const; + + G1GCPhaseTimes* phase_times() const { return _phase_times; } + + // Check the current value of the young list RSet lengths and + // compare it against the last prediction. If the current value is + // higher, recalculate the young list target length prediction. + void revise_young_list_target_length_if_necessary(size_t rs_lengths); + + // This should be called after the heap is resized. + void record_new_heap_size(uint new_number_of_regions); + + void init(); + + virtual void note_gc_start(); + + bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0); + + bool about_to_start_mixed_phase() const; + + // Record the start and end of an evacuation pause. + void record_collection_pause_start(double start_time_sec); + void record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc); + + // Record the start and end of a full collection. + void record_full_collection_start(); + void record_full_collection_end(); + + // Must currently be called while the world is stopped. + void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms); + + // Record start and end of remark. + void record_concurrent_mark_remark_start(); + void record_concurrent_mark_remark_end(); + + // Record start, end, and completion of cleanup. + void record_concurrent_mark_cleanup_start(); + void record_concurrent_mark_cleanup_end(); + void record_concurrent_mark_cleanup_completed(); + + virtual void print_phases(); + + // Record how much space we copied during a GC. This is typically + // called when a GC alloc region is being retired. + void record_bytes_copied_during_gc(size_t bytes) { + _bytes_copied_during_gc += bytes; + } + + // The amount of space we copied during a GC. + size_t bytes_copied_during_gc() const { + return _bytes_copied_during_gc; + } + + // Determine whether there are candidate regions so that the + // next GC should be mixed. The two action strings are used + // in the ergo output when the method returns true or false. + bool next_gc_should_be_mixed(const char* true_action_str, + const char* false_action_str) const; + + virtual void finalize_collection_set(double target_pause_time_ms); +private: + // Set the state to start a concurrent marking cycle and clear + // _initiate_conc_mark_if_possible because it has now been + // acted on. + void initiate_conc_mark(); + +public: + // This sets the initiate_conc_mark_if_possible() flag to start a + // new cycle, as long as we are not already in one. It's best if it + // is called during a safepoint when the test whether a cycle is in + // progress or not is stable. + bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause); + + // This is called at the very beginning of an evacuation pause (it + // has to be the first thing that the pause does). If + // initiate_conc_mark_if_possible() is true, and the concurrent + // marking thread has completed its work during the previous cycle, + // it will set during_initial_mark_pause() to so that the pause does + // the initial-mark work and start a marking cycle. + void decide_on_conc_mark_initiation(); + + // Print stats on young survival ratio + void print_yg_surv_rate_info() const; + + void finished_recalculating_age_indexes(bool is_survivors) { + if (is_survivors) { + _survivor_surv_rate_group->finished_recalculating_age_indexes(); + } else { + _short_lived_surv_rate_group->finished_recalculating_age_indexes(); + } + } + + size_t young_list_target_length() const { return _young_list_target_length; } + + bool is_young_list_full() const; + + bool can_expand_young_list() const; + + uint young_list_max_length() const { + return _young_list_max_length; + } + + bool adaptive_young_list_length() const; + + virtual bool should_process_references() const { + return true; + } + +private: + // + // Survivor regions policy. + // + + // Current tenuring threshold, set to 0 if the collector reaches the + // maximum amount of survivors regions. + uint _tenuring_threshold; + + // The limit on the number of regions allocated for survivors. + uint _max_survivor_regions; + + AgeTable _survivors_age_table; + +public: + uint tenuring_threshold() const { return _tenuring_threshold; } + + uint max_survivor_regions() { + return _max_survivor_regions; + } + + void note_start_adding_survivor_regions() { + _survivor_surv_rate_group->start_adding_regions(); + } + + void note_stop_adding_survivor_regions() { + _survivor_surv_rate_group->stop_adding_regions(); + } + + void record_age_table(AgeTable* age_table) { + _survivors_age_table.merge(age_table); + } + + void update_max_gc_locker_expansion(); + + // Calculates survivor space parameters. + void update_survivors_policy(); +}; + +#endif // SHARE_VM_GC_G1_G1POLICY_HPP diff --git a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp index 12ed0506d94..458d2b82ba7 100644 --- a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp @@ -28,7 +28,6 @@ #include "gc/g1/dirtyCardQueue.hpp" #include "gc/g1/g1BlockOffsetTable.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/g1FromCardCache.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1HotCardCache.hpp" diff --git a/hotspot/src/share/vm/gc/g1/g1RemSet.hpp b/hotspot/src/share/vm/gc/g1/g1RemSet.hpp index 381d5fd8f72..515069f7b19 100644 --- a/hotspot/src/share/vm/gc/g1/g1RemSet.hpp +++ b/hotspot/src/share/vm/gc/g1/g1RemSet.hpp @@ -41,8 +41,8 @@ class G1BlockOffsetTable; class ConcurrentG1Refine; class CodeBlobClosure; class G1CollectedHeap; -class G1CollectorPolicy; class G1ParPushHeapRSClosure; +class G1Policy; class G1SATBCardTableModRefBS; class HeapRegionClaimer; @@ -68,7 +68,7 @@ protected: protected: CardTableModRefBS* _ct_bs; - G1CollectorPolicy* _g1p; + G1Policy* _g1p; ConcurrentG1Refine* _cg1r; diff --git a/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp b/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp index 14b175320b3..077a2350f34 100644 --- a/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp @@ -30,9 +30,9 @@ #include "gc/g1/bufferingOopClosure.hpp" #include "gc/g1/g1CodeBlobClosure.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/g1CollectorState.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" +#include "gc/g1/g1Policy.hpp" #include "gc/g1/g1RootClosures.hpp" #include "gc/g1/g1RootProcessor.hpp" #include "gc/g1/heapRegion.inline.hpp" diff --git a/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.cpp b/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.cpp index e049f4da639..c5058739df5 100644 --- a/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.cpp +++ b/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.cpp @@ -108,13 +108,18 @@ void G1YoungGenSizer::recalculate_min_max_young_length(uint number_of_heap_regio assert(*min_young_length <= *max_young_length, "Invalid min/max young gen size values"); } -uint G1YoungGenSizer::max_young_length(uint number_of_heap_regions) { +void G1YoungGenSizer::adjust_max_new_size(uint number_of_heap_regions) { + // We need to pass the desired values because recalculation may not update these // values in some cases. uint temp = _min_desired_young_length; uint result = _max_desired_young_length; recalculate_min_max_young_length(number_of_heap_regions, &temp, &result); - return result; + + size_t max_young_size = result * HeapRegion::GrainBytes; + if (max_young_size != MaxNewSize) { + FLAG_SET_ERGO(size_t, MaxNewSize, max_young_size); + } } void G1YoungGenSizer::heap_size_changed(uint new_number_of_heap_regions) { diff --git a/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.hpp b/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.hpp index 1d5421b2802..895cf6eb227 100644 --- a/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.hpp +++ b/hotspot/src/share/vm/gc/g1/g1YoungGenSizer.hpp @@ -22,6 +22,9 @@ * */ +#ifndef SHARE_VM_GC_G1_G1YOUNGGENSIZER_HPP +#define SHARE_VM_GC_G1_G1YOUNGGENSIZER_HPP + #include "memory/allocation.hpp" // There are three command line options related to the young gen size: @@ -60,7 +63,7 @@ // // NewSize and MaxNewSize override NewRatio. So, NewRatio is ignored if it is // combined with either NewSize or MaxNewSize. (A warning message is printed.) -class G1YoungGenSizer : public CHeapObj { +class G1YoungGenSizer VALUE_OBJ_CLASS_SPEC { private: enum SizerKind { SizerDefaults, @@ -84,13 +87,13 @@ public: G1YoungGenSizer(); // Calculate the maximum length of the young gen given the number of regions // depending on the sizing algorithm. - uint max_young_length(uint number_of_heap_regions); + void adjust_max_new_size(uint number_of_heap_regions); void heap_size_changed(uint new_number_of_heap_regions); - uint min_desired_young_length() { + uint min_desired_young_length() const { return _min_desired_young_length; } - uint max_desired_young_length() { + uint max_desired_young_length() const { return _max_desired_young_length; } @@ -99,3 +102,4 @@ public: } }; +#endif // SHARE_VM_GC_G1_G1YOUNGGENSIZER_HPP diff --git a/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp b/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp index b435c052cad..5ba7ffa04bf 100644 --- a/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp +++ b/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp @@ -24,8 +24,8 @@ #include "precompiled.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/g1CollectionSet.hpp" +#include "gc/g1/g1Policy.hpp" #include "gc/g1/g1YoungRemSetSamplingThread.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" @@ -74,7 +74,7 @@ void G1YoungRemSetSamplingThread::stop_service() { void G1YoungRemSetSamplingThread::sample_young_list_rs_lengths() { SuspendibleThreadSetJoiner sts; G1CollectedHeap* g1h = G1CollectedHeap::heap(); - G1CollectorPolicy* g1p = g1h->g1_policy(); + G1Policy* g1p = g1h->g1_policy(); if (g1p->adaptive_young_list_length()) { int regions_visited = 0; HeapRegion* hr = g1h->young_list()->first_region(); diff --git a/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.hpp b/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.hpp index 31cf79ed500..b5215efbd19 100644 --- a/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.hpp +++ b/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.hpp @@ -37,7 +37,7 @@ // The assumption is that a significant part of the GC is spent on scanning // the remembered sets (and many other components), so this thread constantly // reevaluates the prediction for the remembered set scanning costs, and potentially -// G1CollectorPolicy resizes the young gen. This may do a premature GC or even +// G1Policy resizes the young gen. This may do a premature GC or even // increase the young gen size to keep pause time length goal. class G1YoungRemSetSamplingThread: public ConcurrentGCThread { private: diff --git a/hotspot/src/share/vm/gc/g1/heapRegion.cpp b/hotspot/src/share/vm/gc/g1/heapRegion.cpp index b88145da9c1..92f65ac1d68 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegion.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegion.cpp @@ -204,7 +204,7 @@ void HeapRegion::calc_gc_efficiency() { // GC efficiency is the ratio of how much space would be // reclaimed over how long we predict it would take to reclaim it. G1CollectedHeap* g1h = G1CollectedHeap::heap(); - G1CollectorPolicy* g1p = g1h->g1_policy(); + G1Policy* g1p = g1h->g1_policy(); // Retrieve a prediction of the elapsed time for this region for // a mixed gc because the region will only be evacuated during a diff --git a/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp b/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp index 62d610d966b..333499a0a97 100644 --- a/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp +++ b/hotspot/src/share/vm/gc/g1/vm_operations_g1.cpp @@ -25,7 +25,7 @@ #include "precompiled.hpp" #include "gc/g1/concurrentMarkThread.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" +#include "gc/g1/g1Policy.hpp" #include "gc/shared/gcId.hpp" #include "gc/g1/vm_operations_g1.hpp" #include "gc/shared/gcTimer.hpp" diff --git a/hotspot/src/share/vm/gc/g1/youngList.cpp b/hotspot/src/share/vm/gc/g1/youngList.cpp index 5d57d5cb2f1..c68e665185e 100644 --- a/hotspot/src/share/vm/gc/g1/youngList.cpp +++ b/hotspot/src/share/vm/gc/g1/youngList.cpp @@ -25,7 +25,7 @@ #include "precompiled.hpp" #include "gc/g1/g1CollectedHeap.hpp" #include "gc/g1/g1CollectionSet.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" +#include "gc/g1/g1Policy.hpp" #include "gc/g1/heapRegion.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" diff --git a/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp b/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp index 004a5f4f285..9ac7d42e0a0 100644 --- a/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp +++ b/hotspot/src/share/vm/gc/shared/vmGCOperations.cpp @@ -40,6 +40,7 @@ #include "utilities/preserveException.hpp" #if INCLUDE_ALL_GCS #include "gc/g1/g1CollectedHeap.inline.hpp" +#include "gc/g1/g1Policy.hpp" #endif // INCLUDE_ALL_GCS VM_GC_Operation::~VM_GC_Operation() { diff --git a/hotspot/src/share/vm/services/g1MemoryPool.cpp b/hotspot/src/share/vm/services/g1MemoryPool.cpp index 49328908920..92daa7b726d 100644 --- a/hotspot/src/share/vm/services/g1MemoryPool.cpp +++ b/hotspot/src/share/vm/services/g1MemoryPool.cpp @@ -24,8 +24,6 @@ #include "precompiled.hpp" #include "gc/g1/g1CollectedHeap.hpp" -#include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1CollectorPolicy.hpp" #include "gc/g1/heapRegion.hpp" #include "services/g1MemoryPool.hpp" -- GitLab From 429b1c80a1f74277e16676ca1ee632858acd8427 Mon Sep 17 00:00:00 2001 From: Ivan Krylov Date: Wed, 30 Mar 2016 17:04:14 +0200 Subject: [PATCH 117/400] 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic Adds c1 & c2 x86 intrinsics for j.l.Runtime.onSpinWait() that utilize the PAUSE instruction Co-authored-by: Yuri Gaevsky Reviewed-by: iveresov, kvn --- .../aarch64/vm/c1_LIRAssembler_aarch64.cpp | 4 + .../src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp | 3 + .../cpu/sparc/vm/c1_LIRAssembler_sparc.cpp | 3 + .../src/cpu/x86/vm/c1_LIRAssembler_x86.cpp | 4 + hotspot/src/cpu/x86/vm/vm_version_x86.hpp | 5 ++ hotspot/src/cpu/x86/vm/x86.ad | 22 +++++ hotspot/src/share/vm/c1/c1_Compiler.cpp | 3 + hotspot/src/share/vm/c1/c1_LIR.cpp | 2 + hotspot/src/share/vm/c1/c1_LIR.hpp | 3 + hotspot/src/share/vm/c1/c1_LIRAssembler.cpp | 4 + hotspot/src/share/vm/c1/c1_LIRAssembler.hpp | 1 + hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 4 +- hotspot/src/share/vm/classfile/vmSymbols.hpp | 4 + hotspot/src/share/vm/opto/c2compiler.cpp | 3 + hotspot/src/share/vm/opto/classes.hpp | 1 + hotspot/src/share/vm/opto/library_call.cpp | 8 ++ hotspot/src/share/vm/opto/matcher.cpp | 1 + hotspot/src/share/vm/opto/memnode.cpp | 1 + hotspot/src/share/vm/opto/memnode.hpp | 7 ++ hotspot/src/share/vm/runtime/vmStructs.cpp | 1 + hotspot/src/share/vm/runtime/vm_version.hpp | 3 + .../compiler/onSpinWait/TestOnSpinWait.java | 86 +++++++++++++++++++ 22 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 hotspot/test/compiler/onSpinWait/TestOnSpinWait.java diff --git a/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp index 976e69133bc..e34c6fa2691 100644 --- a/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/c1_LIRAssembler_aarch64.cpp @@ -2942,6 +2942,10 @@ void LIR_Assembler::membar_loadstore() { __ membar(MacroAssembler::LoadStore); } void LIR_Assembler::membar_storeload() { __ membar(MacroAssembler::StoreLoad); } +void LIR_Assembler::on_spin_wait() { + Unimplemented(); +} + void LIR_Assembler::get_thread(LIR_Opr result_reg) { __ mov(result_reg->as_register(), rthread); } diff --git a/hotspot/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp b/hotspot/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp index b7bc0cbf50d..ed381b9d631 100644 --- a/hotspot/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp @@ -2845,6 +2845,9 @@ void LIR_Assembler::membar_storeload() { __ membar(Assembler::StoreLoad); } +void LIR_Assembler::on_spin_wait() { + Unimplemented(); +} void LIR_Assembler::leal(LIR_Opr addr_opr, LIR_Opr dest) { LIR_Address* addr = addr_opr->as_address_ptr(); diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp index 128f6c31171..8a9ef34eb46 100644 --- a/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_LIRAssembler_sparc.cpp @@ -3313,6 +3313,9 @@ void LIR_Assembler::membar_storeload() { __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad)); } +void LIR_Assembler::on_spin_wait() { + Unimplemented(); +} // Pack two sequential registers containing 32 bit values // into a single 64 bit register. diff --git a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp index fb36620c19b..0a5f1994ec0 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @@ -3886,6 +3886,10 @@ void LIR_Assembler::membar_storeload() { __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad)); } +void LIR_Assembler::on_spin_wait() { + __ pause (); +} + void LIR_Assembler::get_thread(LIR_Opr result_reg) { assert(result_reg->is_register(), "check"); #ifdef _LP64 diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp index 8dca27b546b..a4c02654cad 100644 --- a/hotspot/src/cpu/x86/vm/vm_version_x86.hpp +++ b/hotspot/src/cpu/x86/vm/vm_version_x86.hpp @@ -844,6 +844,11 @@ public: static uint32_t get_xsave_header_upper_segment() { return _cpuid_info.xem_xcr0_edx; } + + // SSE2 and later processors implement a 'pause' instruction + // that can be used for efficient implementation of + // the intrinsic for java.lang.Thread.onSpinWait() + static bool supports_on_spin_wait() { return supports_sse2(); } }; #endif // CPU_X86_VM_VM_VERSION_X86_HPP diff --git a/hotspot/src/cpu/x86/vm/x86.ad b/hotspot/src/cpu/x86/vm/x86.ad index 603e00beef4..d1549a5df0b 100644 --- a/hotspot/src/cpu/x86/vm/x86.ad +++ b/hotspot/src/cpu/x86/vm/x86.ad @@ -1719,6 +1719,10 @@ const bool Matcher::match_rule_supported(int opcode) { if (!(UseSSE > 4)) ret_value = false; break; + case Op_OnSpinWait: + if (VM_Version::supports_on_spin_wait() == false) + ret_value = false; + break; } return ret_value; // Per default match rules are supported. @@ -2996,6 +3000,24 @@ instruct sqrtD_imm(regD dst, immD con) %{ ins_pipe(pipe_slow); %} +instruct onspinwait() %{ + match(OnSpinWait); + ins_cost(200); + + format %{ + $$template + if (os::is_MP()) { + $$emit$$"pause\t! membar_onspinwait" + } else { + $$emit$$"MEMBAR-onspinwait ! (empty encoding)" + } + %} + ins_encode %{ + __ pause(); + %} + ins_pipe(pipe_slow); +%} + // ====================VECTOR INSTRUCTIONS===================================== // Load vectors (4 bytes long) diff --git a/hotspot/src/share/vm/c1/c1_Compiler.cpp b/hotspot/src/share/vm/c1/c1_Compiler.cpp index 1829ff8f887..4903ab682f3 100644 --- a/hotspot/src/share/vm/c1/c1_Compiler.cpp +++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp @@ -131,6 +131,9 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) { if (!VM_Version::supports_atomic_getset4()) return false; #endif break; + case vmIntrinsics::_onSpinWait: + if (!VM_Version::supports_on_spin_wait()) return false; + break; case vmIntrinsics::_arraycopy: case vmIntrinsics::_currentTimeMillis: case vmIntrinsics::_nanoTime: diff --git a/hotspot/src/share/vm/c1/c1_LIR.cpp b/hotspot/src/share/vm/c1/c1_LIR.cpp index 6077c282472..9058585ff7b 100644 --- a/hotspot/src/share/vm/c1/c1_LIR.cpp +++ b/hotspot/src/share/vm/c1/c1_LIR.cpp @@ -483,6 +483,7 @@ void LIR_OpVisitState::visit(LIR_Op* op) { case lir_membar_storestore: // result and info always invalid case lir_membar_loadstore: // result and info always invalid case lir_membar_storeload: // result and info always invalid + case lir_on_spin_wait: { assert(op->as_Op0() != NULL, "must be"); assert(op->_info == NULL, "info not used by this instruction"); @@ -1691,6 +1692,7 @@ const char * LIR_Op::name() const { case lir_word_align: s = "word_align"; break; case lir_label: s = "label"; break; case lir_nop: s = "nop"; break; + case lir_on_spin_wait: s = "on_spin_wait"; break; case lir_backwardbranch_target: s = "backbranch"; break; case lir_std_entry: s = "std_entry"; break; case lir_osr_entry: s = "osr_entry"; break; diff --git a/hotspot/src/share/vm/c1/c1_LIR.hpp b/hotspot/src/share/vm/c1/c1_LIR.hpp index c5e52dec265..a96c1a43242 100644 --- a/hotspot/src/share/vm/c1/c1_LIR.hpp +++ b/hotspot/src/share/vm/c1/c1_LIR.hpp @@ -920,6 +920,7 @@ enum LIR_Code { , lir_membar_loadstore , lir_membar_storeload , lir_get_thread + , lir_on_spin_wait , end_op0 , begin_op1 , lir_fxch @@ -2101,6 +2102,8 @@ class LIR_List: public CompilationResourceObj { void std_entry(LIR_Opr receiver) { append(new LIR_Op0(lir_std_entry, receiver)); } void osr_entry(LIR_Opr osrPointer) { append(new LIR_Op0(lir_osr_entry, osrPointer)); } + void on_spin_wait() { append(new LIR_Op0(lir_on_spin_wait)); } + void branch_destination(Label* lbl) { append(new LIR_OpLabel(lbl)); } void negate(LIR_Opr from, LIR_Opr to) { append(new LIR_Op1(lir_neg, from, to)); } diff --git a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp index 230a7bf0273..553fc4b2b8b 100644 --- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp @@ -678,6 +678,10 @@ void LIR_Assembler::emit_op0(LIR_Op0* op) { get_thread(op->result_opr()); break; + case lir_on_spin_wait: + on_spin_wait(); + break; + default: ShouldNotReachHere(); break; diff --git a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp index 8c2c97ece41..a562bc19eb1 100644 --- a/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.hpp @@ -251,6 +251,7 @@ class LIR_Assembler: public CompilationResourceObj { void membar_storestore(); void membar_loadstore(); void membar_storeload(); + void on_spin_wait(); void get_thread(LIR_Opr result); void verify_oop_map(CodeEmitInfo* info); diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index 3c8454e5260..c5f4d307784 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -3161,7 +3161,9 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) { case vmIntrinsics::_fullFence : if (os::is_MP()) __ membar(); break; - + case vmIntrinsics::_onSpinWait: + __ on_spin_wait(); + break; case vmIntrinsics::_Reference_get: do_Reference_get(x); break; diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index 90a95e75794..42e4a2bc583 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -889,6 +889,10 @@ do_name( newArray_name, "newArray") \ do_signature(newArray_signature, "(Ljava/lang/Class;I)Ljava/lang/Object;") \ \ + do_intrinsic(_onSpinWait, java_lang_Thread, onSpinWait_name, onSpinWait_signature, F_S) \ + do_name( onSpinWait_name, "onSpinWait") \ + do_alias( onSpinWait_signature, void_method_signature) \ + \ do_intrinsic(_copyOf, java_util_Arrays, copyOf_name, copyOf_signature, F_S) \ do_name( copyOf_name, "copyOf") \ do_signature(copyOf_signature, "([Ljava/lang/Object;ILjava/lang/Class;)[Ljava/lang/Object;") \ diff --git a/hotspot/src/share/vm/opto/c2compiler.cpp b/hotspot/src/share/vm/opto/c2compiler.cpp index a93742fe545..b46b3c8d30f 100644 --- a/hotspot/src/share/vm/opto/c2compiler.cpp +++ b/hotspot/src/share/vm/opto/c2compiler.cpp @@ -361,6 +361,9 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt case vmIntrinsics::_getCallerClass: if (SystemDictionary::reflect_CallerSensitive_klass() == NULL) return false; break; + case vmIntrinsics::_onSpinWait: + if (!Matcher::match_rule_supported(Op_OnSpinWait)) return false; + break; case vmIntrinsics::_hashCode: case vmIntrinsics::_identityHashCode: case vmIntrinsics::_getClass: diff --git a/hotspot/src/share/vm/opto/classes.hpp b/hotspot/src/share/vm/opto/classes.hpp index ee36282de38..7bb2f74ad6c 100644 --- a/hotspot/src/share/vm/opto/classes.hpp +++ b/hotspot/src/share/vm/opto/classes.hpp @@ -205,6 +205,7 @@ macro(Multi) macro(NegD) macro(NegF) macro(NeverBranch) +macro(OnSpinWait) macro(Opaque1) macro(Opaque2) macro(Opaque3) diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 3eec8057f64..6041fd7b417 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -280,6 +280,7 @@ class LibraryCallKit : public GraphKit { MemNode::MemOrd access_kind_to_memord(AccessKind access_kind); bool inline_unsafe_load_store(BasicType type, LoadStoreKind kind, AccessKind access_kind); bool inline_unsafe_fence(vmIntrinsics::ID id); + bool inline_onspinwait(); bool inline_fp_conversions(vmIntrinsics::ID id); bool inline_number_methods(vmIntrinsics::ID id); bool inline_reference_get(); @@ -695,6 +696,8 @@ bool LibraryCallKit::try_to_inline(int predicate) { case vmIntrinsics::_storeFence: case vmIntrinsics::_fullFence: return inline_unsafe_fence(intrinsic_id()); + case vmIntrinsics::_onSpinWait: return inline_onspinwait(); + case vmIntrinsics::_currentThread: return inline_native_currentThread(); case vmIntrinsics::_isInterrupted: return inline_native_isInterrupted(); @@ -3126,6 +3129,11 @@ bool LibraryCallKit::inline_unsafe_fence(vmIntrinsics::ID id) { } } +bool LibraryCallKit::inline_onspinwait() { + insert_mem_bar(Op_OnSpinWait); + return true; +} + bool LibraryCallKit::klass_needs_init_guard(Node* kls) { if (!kls->is_Con()) { return true; diff --git a/hotspot/src/share/vm/opto/matcher.cpp b/hotspot/src/share/vm/opto/matcher.cpp index 1df9f7ca1c0..3ef140af0a3 100644 --- a/hotspot/src/share/vm/opto/matcher.cpp +++ b/hotspot/src/share/vm/opto/matcher.cpp @@ -943,6 +943,7 @@ static void match_alias_type(Compile* C, Node* n, Node* m) { case Op_MemBarCPUOrder: // %%% these ideals should have narrower adr_type? case Op_StrInflatedCopy: case Op_StrCompressedCopy: + case Op_OnSpinWait: case Op_EncodeISOArray: nidx = Compile::AliasIdxTop; nat = NULL; diff --git a/hotspot/src/share/vm/opto/memnode.cpp b/hotspot/src/share/vm/opto/memnode.cpp index e79abac0c19..bfa80950912 100644 --- a/hotspot/src/share/vm/opto/memnode.cpp +++ b/hotspot/src/share/vm/opto/memnode.cpp @@ -2978,6 +2978,7 @@ MemBarNode* MemBarNode::make(Compile* C, int opcode, int atp, Node* pn) { case Op_MemBarReleaseLock: return new MemBarReleaseLockNode(C, atp, pn); case Op_MemBarVolatile: return new MemBarVolatileNode(C, atp, pn); case Op_MemBarCPUOrder: return new MemBarCPUOrderNode(C, atp, pn); + case Op_OnSpinWait: return new OnSpinWaitNode(C, atp, pn); case Op_Initialize: return new InitializeNode(C, atp, pn); case Op_MemBarStoreStore: return new MemBarStoreStoreNode(C, atp, pn); default: ShouldNotReachHere(); return NULL; diff --git a/hotspot/src/share/vm/opto/memnode.hpp b/hotspot/src/share/vm/opto/memnode.hpp index 87238ac4cfe..438fc7476e6 100644 --- a/hotspot/src/share/vm/opto/memnode.hpp +++ b/hotspot/src/share/vm/opto/memnode.hpp @@ -1186,6 +1186,13 @@ public: virtual uint ideal_reg() const { return 0; } // not matched in the AD file }; +class OnSpinWaitNode: public MemBarNode { +public: + OnSpinWaitNode(Compile* C, int alias_idx, Node* precedent) + : MemBarNode(C, alias_idx, precedent) {} + virtual int Opcode() const; +}; + // Isolation of object setup after an AllocateNode and before next safepoint. // (See comment in memnode.cpp near InitializeNode::InitializeNode for semantics.) class InitializeNode: public MemBarNode { diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 948073d98dd..350e90fcde0 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -1926,6 +1926,7 @@ typedef CompactHashtable SymbolCompactHashTable; declare_c2_type(StoreFenceNode, MemBarNode) \ declare_c2_type(MemBarVolatileNode, MemBarNode) \ declare_c2_type(MemBarCPUOrderNode, MemBarNode) \ + declare_c2_type(OnSpinWaitNode, MemBarNode) \ declare_c2_type(InitializeNode, MemBarNode) \ declare_c2_type(ThreadLocalNode, Node) \ declare_c2_type(Opaque1Node, Node) \ diff --git a/hotspot/src/share/vm/runtime/vm_version.hpp b/hotspot/src/share/vm/runtime/vm_version.hpp index 5d07fc703b7..50e4b616d34 100644 --- a/hotspot/src/share/vm/runtime/vm_version.hpp +++ b/hotspot/src/share/vm/runtime/vm_version.hpp @@ -162,6 +162,9 @@ class Abstract_VM_Version: AllStatic { // Calculates and returns the number of parallel threads. May // be VM version specific. static unsigned int calc_parallel_worker_threads(); + + // Does this CPU support spin wait instruction? + static bool supports_on_spin_wait() { return false; } }; #ifdef TARGET_ARCH_x86 diff --git a/hotspot/test/compiler/onSpinWait/TestOnSpinWait.java b/hotspot/test/compiler/onSpinWait/TestOnSpinWait.java new file mode 100644 index 00000000000..76861ca687f --- /dev/null +++ b/hotspot/test/compiler/onSpinWait/TestOnSpinWait.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright 2016 Azul Systems, Inc. All Rights Reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test TestOnSpinWait + * @summary (x86 only) checks that java.lang.Thread.onSpinWait is intrinsified + * @bug 8147844 + * @library /testlibrary + * @requires os.arch=="x86" | os.arch=="amd64" | os.arch=="x86_64" + * @run main TestOnSpinWait + */ + +import java.lang.invoke.*; +import jdk.test.lib.*; +import static jdk.test.lib.Asserts.*; + +public class TestOnSpinWait { + + public static void main(String[] args) throws Exception { + + // Test C1 compiler + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", + "-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1", "-Xbatch", + "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", + "-XX:+PrintInlining", "TestOnSpinWait$Launcher"); + + OutputAnalyzer analyzer = new OutputAnalyzer(pb.start()); + + analyzer.shouldHaveExitValue(0); + + // The test is applicable only to C1 (present in Server VM). + analyzer.shouldContain("java.lang.Thread::onSpinWait (1 bytes) intrinsic"); + + // Test C2 compiler + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+IgnoreUnrecognizedVMOptions", "-showversion", + "-XX:-TieredCompilation", "-Xbatch", + "-XX:+PrintCompilation", "-XX:+UnlockDiagnosticVMOptions", + "-XX:+PrintInlining", "TestOnSpinWait$Launcher"); + + analyzer = new OutputAnalyzer(pb.start()); + + analyzer.shouldHaveExitValue(0); + + // The test is applicable only to C2 (present in Server VM). + if (analyzer.getStderr().contains("Server VM")) { + analyzer.shouldContain("java.lang.Thread::onSpinWait (1 bytes) (intrinsic)"); + } + } + + static class Launcher { + + public static void main(final String[] args) throws Exception { + int end = 20_000; + + for (int i=0; i < end; i++) { + test(); + } + } + static void test() { + java.lang.Thread.onSpinWait(); + } + } +} -- GitLab From cce84da126d0ad36a9f505f7fe3e42537b24f6ca Mon Sep 17 00:00:00 2001 From: Konstantin Shefov Date: Fri, 1 Apr 2016 10:43:35 +0300 Subject: [PATCH 118/400] 8153165: Fix MX tool config script to make the tool work with TESTNG Reviewed-by: dnsimon, twisti --- hotspot/.mx.jvmci/suite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/.mx.jvmci/suite.py b/hotspot/.mx.jvmci/suite.py index 514994c5190..fe37b6646a5 100644 --- a/hotspot/.mx.jvmci/suite.py +++ b/hotspot/.mx.jvmci/suite.py @@ -164,7 +164,7 @@ suite = { "subDir" : "test/compiler/jvmci", "sourceDirs" : ["src"], "dependencies" : [ - "mx:TESTNG", + "TESTNG", "jdk.vm.ci.hotspot", ], "checkstyle" : "jdk.vm.ci.services", -- GitLab From d650ab04e295c352359e51a2d03f5ee1d4a8396c Mon Sep 17 00:00:00 2001 From: Jon Masamitsu Date: Fri, 1 Apr 2016 12:32:34 -0700 Subject: [PATCH 119/400] 8150994: UseParallelGC fails with UseDynamicNumberOfGCThreads with specjbb2005 Reviewed-by: tschatzl, kbarrett --- hotspot/src/share/vm/gc/parallel/pcTasks.cpp | 67 ++----------------- hotspot/src/share/vm/gc/parallel/pcTasks.hpp | 23 ------- .../vm/gc/parallel/psCompactionManager.cpp | 62 +---------------- .../vm/gc/parallel/psCompactionManager.hpp | 45 +------------ .../vm/gc/parallel/psParallelCompact.cpp | 30 ++------- .../vm/gc/parallel/psParallelCompact.hpp | 2 +- 6 files changed, 16 insertions(+), 213 deletions(-) diff --git a/hotspot/src/share/vm/gc/parallel/pcTasks.cpp b/hotspot/src/share/vm/gc/parallel/pcTasks.cpp index e7a4acfcbbd..df3d9a7f08d 100644 --- a/hotspot/src/share/vm/gc/parallel/pcTasks.cpp +++ b/hotspot/src/share/vm/gc/parallel/pcTasks.cpp @@ -232,36 +232,16 @@ void StealRegionCompactionTask::do_it(GCTaskManager* manager, uint which) { ParCompactionManager* cm = ParCompactionManager::gc_thread_compaction_manager(which); - - // If not all threads are active, get a draining stack - // from the list. Else, just use this threads draining stack. - uint which_stack_index; - bool use_all_workers = manager->all_workers_active(); - if (use_all_workers) { - which_stack_index = which; - assert(manager->active_workers() == ParallelGCThreads, - "all_workers_active has been incorrectly set: " - " active %d ParallelGCThreads %u", manager->active_workers(), - ParallelGCThreads); - } else { - which_stack_index = ParCompactionManager::pop_recycled_stack_index(); - } - - cm->set_region_stack_index(which_stack_index); - cm->set_region_stack(ParCompactionManager::region_list(which_stack_index)); - - // Has to drain stacks first because there may be regions on - // preloaded onto the stack and this thread may never have - // done a draining task. Are the draining tasks needed? + // Drain the stacks that have been preloaded with regions + // that are ready to fill. cm->drain_region_stacks(); + guarantee(cm->region_stack()->is_empty(), "Not empty"); + size_t region_index = 0; int random_seed = 17; - // If we're the termination task, try 10 rounds of stealing before - // setting the termination flag - while(true) { if (ParCompactionManager::steal(which, &random_seed, region_index)) { PSParallelCompact::fill_and_update_region(cm, region_index); @@ -293,42 +273,3 @@ void UpdateDensePrefixTask::do_it(GCTaskManager* manager, uint which) { _region_index_start, _region_index_end); } - -void DrainStacksCompactionTask::do_it(GCTaskManager* manager, uint which) { - assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc"); - - ParCompactionManager* cm = - ParCompactionManager::gc_thread_compaction_manager(which); - - uint which_stack_index; - bool use_all_workers = manager->all_workers_active(); - if (use_all_workers) { - which_stack_index = which; - assert(manager->active_workers() == ParallelGCThreads, - "all_workers_active has been incorrectly set: " - " active %d ParallelGCThreads %u", manager->active_workers(), - ParallelGCThreads); - } else { - which_stack_index = stack_index(); - } - - cm->set_region_stack(ParCompactionManager::region_list(which_stack_index)); - - cm->set_region_stack_index(which_stack_index); - - // Process any regions already in the compaction managers stacks. - cm->drain_region_stacks(); - - assert(cm->region_stack()->is_empty(), "Not empty"); - - if (!use_all_workers) { - // Always give up the region stack. - assert(cm->region_stack() == - ParCompactionManager::region_list(cm->region_stack_index()), - "region_stack and region_stack_index are inconsistent"); - ParCompactionManager::push_recycled_stack_index(cm->region_stack_index()); - - cm->set_region_stack(NULL); - cm->set_region_stack_index((uint)max_uintx); - } -} diff --git a/hotspot/src/share/vm/gc/parallel/pcTasks.hpp b/hotspot/src/share/vm/gc/parallel/pcTasks.hpp index 40a2009a2c5..6769f75a481 100644 --- a/hotspot/src/share/vm/gc/parallel/pcTasks.hpp +++ b/hotspot/src/share/vm/gc/parallel/pcTasks.hpp @@ -234,27 +234,4 @@ class UpdateDensePrefixTask : public GCTask { virtual void do_it(GCTaskManager* manager, uint which); }; - -// -// DrainStacksCompactionTask -// -// This task processes regions that have been added to the stacks of each -// compaction manager. -// -// Trying to use one draining thread does not work because there are no -// guarantees about which task will be picked up by which thread. For example, -// if thread A gets all the preloaded regions, thread A may not get a draining -// task (they may all be done by other threads). -// - -class DrainStacksCompactionTask : public GCTask { - uint _stack_index; - uint stack_index() { return _stack_index; } - public: - DrainStacksCompactionTask(uint stack_index) : GCTask(), - _stack_index(stack_index) {}; - char* name() { return (char *)"drain-region-task"; } - virtual void do_it(GCTaskManager* manager, uint which); -}; - #endif // SHARE_VM_GC_PARALLEL_PCTASKS_HPP diff --git a/hotspot/src/share/vm/gc/parallel/psCompactionManager.cpp b/hotspot/src/share/vm/gc/parallel/psCompactionManager.cpp index 433b4dc2a06..2884b4c7df6 100644 --- a/hotspot/src/share/vm/gc/parallel/psCompactionManager.cpp +++ b/hotspot/src/share/vm/gc/parallel/psCompactionManager.cpp @@ -43,8 +43,6 @@ PSOldGen* ParCompactionManager::_old_gen = NULL; ParCompactionManager** ParCompactionManager::_manager_array = NULL; -RegionTaskQueue** ParCompactionManager::_region_list = NULL; - OopTaskQueueSet* ParCompactionManager::_stack_array = NULL; ParCompactionManager::ObjArrayTaskQueueSet* ParCompactionManager::_objarray_queues = NULL; @@ -52,14 +50,8 @@ ObjectStartArray* ParCompactionManager::_start_array = NULL; ParMarkBitMap* ParCompactionManager::_mark_bitmap = NULL; RegionTaskQueueSet* ParCompactionManager::_region_array = NULL; -uint* ParCompactionManager::_recycled_stack_index = NULL; -int ParCompactionManager::_recycled_top = -1; -int ParCompactionManager::_recycled_bottom = -1; - ParCompactionManager::ParCompactionManager() : - _action(CopyAndUpdate), - _region_stack(NULL), - _region_stack_index((uint)max_uintx) { + _action(CopyAndUpdate) { ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); @@ -68,14 +60,11 @@ ParCompactionManager::ParCompactionManager() : marking_stack()->initialize(); _objarray_stack.initialize(); + _region_stack.initialize(); reset_bitmap_query_cache(); } -ParCompactionManager::~ParCompactionManager() { - delete _recycled_stack_index; -} - void ParCompactionManager::initialize(ParMarkBitMap* mbm) { assert(PSParallelCompact::gc_task_manager() != NULL, "Needed for initialization"); @@ -88,19 +77,6 @@ void ParCompactionManager::initialize(ParMarkBitMap* mbm) { _manager_array = NEW_C_HEAP_ARRAY(ParCompactionManager*, parallel_gc_threads+1, mtGC); guarantee(_manager_array != NULL, "Could not allocate manager_array"); - _region_list = NEW_C_HEAP_ARRAY(RegionTaskQueue*, - parallel_gc_threads+1, mtGC); - guarantee(_region_list != NULL, "Could not initialize promotion manager"); - - _recycled_stack_index = NEW_C_HEAP_ARRAY(uint, parallel_gc_threads, mtGC); - - // parallel_gc-threads + 1 to be consistent with the number of - // compaction managers. - for(uint i=0; iinitialize(); - } - _stack_array = new OopTaskQueueSet(parallel_gc_threads); guarantee(_stack_array != NULL, "Could not allocate stack_array"); _objarray_queues = new ObjArrayTaskQueueSet(parallel_gc_threads); @@ -114,7 +90,7 @@ void ParCompactionManager::initialize(ParMarkBitMap* mbm) { guarantee(_manager_array[i] != NULL, "Could not create ParCompactionManager"); stack_array()->register_queue(i, _manager_array[i]->marking_stack()); _objarray_queues->register_queue(i, &_manager_array[i]->_objarray_stack); - region_array()->register_queue(i, region_list(i)); + region_array()->register_queue(i, _manager_array[i]->region_stack()); } // The VMThread gets its own ParCompactionManager, which is not available @@ -133,29 +109,6 @@ void ParCompactionManager::reset_all_bitmap_query_caches() { } } -int ParCompactionManager::pop_recycled_stack_index() { - assert(_recycled_bottom <= _recycled_top, "list is empty"); - // Get the next available index - if (_recycled_bottom < _recycled_top) { - uint cur, next, last; - do { - cur = _recycled_bottom; - next = cur + 1; - last = Atomic::cmpxchg(next, &_recycled_bottom, cur); - } while (cur != last); - return _recycled_stack_index[next]; - } else { - return -1; - } -} - -void ParCompactionManager::push_recycled_stack_index(uint v) { - // Get the next available index - int cur = Atomic::add(1, &_recycled_top); - _recycled_stack_index[cur] = v; - assert(_recycled_bottom <= _recycled_top, "list top and bottom are wrong"); -} - bool ParCompactionManager::should_update() { assert(action() != NotValid, "Action is not set"); return (action() == ParCompactionManager::Update) || @@ -170,15 +123,6 @@ bool ParCompactionManager::should_copy() { (action() == ParCompactionManager::UpdateAndCopy); } -void ParCompactionManager::region_list_push(uint list_index, - size_t region_index) { - region_list(list_index)->push(region_index); -} - -void ParCompactionManager::verify_region_list_empty(uint list_index) { - assert(region_list(list_index)->is_empty(), "Not empty"); -} - ParCompactionManager* ParCompactionManager::gc_thread_compaction_manager(uint index) { assert(index < ParallelGCThreads, "index out of range"); diff --git a/hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp b/hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp index 9e35ff29d9e..90819712d26 100644 --- a/hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp +++ b/hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp @@ -79,31 +79,7 @@ private: // Is there a way to reuse the _marking_stack for the // saving empty regions? For now just create a different // type of TaskQueue. - RegionTaskQueue* _region_stack; - - static RegionTaskQueue** _region_list; - // Index in _region_list for current _region_stack. - uint _region_stack_index; - - // Indexes of recycled region stacks/overflow stacks - // Stacks of regions to be compacted are embedded in the tasks doing - // the compaction. A thread that executes the task extracts the - // region stack and drains it. These threads keep these region - // stacks for use during compaction task stealing. If a thread - // gets a second draining task, it pushed its current region stack - // index into the array _recycled_stack_index and gets a new - // region stack from the task. A thread that is executing a - // compaction stealing task without ever having executing a - // draining task, will get a region stack from _recycled_stack_index. - // - // Array of indexes into the array of region stacks. - static uint* _recycled_stack_index; - // The index into _recycled_stack_index of the last region stack index - // pushed. If -1, there are no entries into _recycled_stack_index. - static int _recycled_top; - // The index into _recycled_stack_index of the last region stack index - // popped. If -1, there has not been any entry popped. - static int _recycled_bottom; + RegionTaskQueue _region_stack; static ParMarkBitMap* _mark_bitmap; @@ -151,32 +127,15 @@ private: static void reset_all_bitmap_query_caches(); - RegionTaskQueue* region_stack() { return _region_stack; } - void set_region_stack(RegionTaskQueue* v) { _region_stack = v; } + RegionTaskQueue* region_stack() { return &_region_stack; } inline static ParCompactionManager* manager_array(uint index); - inline static RegionTaskQueue* region_list(int index) { - return _region_list[index]; - } - - uint region_stack_index() { return _region_stack_index; } - void set_region_stack_index(uint v) { _region_stack_index = v; } - - // Pop and push unique reusable stack index - static int pop_recycled_stack_index(); - static void push_recycled_stack_index(uint v); - static void reset_recycled_stack_index() { - _recycled_bottom = _recycled_top = -1; - } - ParCompactionManager(); - ~ParCompactionManager(); // Pushes onto the region stack at the given index. If the // region stack is full, // pushes onto the region overflow stack. - static void region_list_push(uint stack_index, size_t region_index); static void verify_region_list_empty(uint stack_index); ParMarkBitMap* mark_bitmap() { return _mark_bitmap; } diff --git a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp index e37ccf97e9a..98bdefd3734 100644 --- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp @@ -1929,7 +1929,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) { ParCompactionManager* const cm = ParCompactionManager::manager_array(int(i)); assert(cm->marking_stack()->is_empty(), "should be empty"); - assert(ParCompactionManager::region_list(int(i))->is_empty(), "should be empty"); + assert(cm->region_stack()->is_empty(), "should be empty"); } #endif // ASSERT @@ -2238,7 +2238,7 @@ public: } }; -void PSParallelCompact::enqueue_region_draining_tasks(GCTaskQueue* q, +void PSParallelCompact::prepare_region_draining_tasks(GCTaskQueue* q, uint parallel_gc_threads) { GCTraceTime(Trace, gc, phases) tm("Drain Task Setup", &_gc_timer); @@ -2246,29 +2246,12 @@ void PSParallelCompact::enqueue_region_draining_tasks(GCTaskQueue* q, // Find the threads that are active unsigned int which = 0; - const uint task_count = MAX2(parallel_gc_threads, 1U); - for (uint j = 0; j < task_count; j++) { - q->enqueue(new DrainStacksCompactionTask(j)); - ParCompactionManager::verify_region_list_empty(j); - // Set the region stacks variables to "no" region stack values - // so that they will be recognized and needing a region stack - // in the stealing tasks if they do not get one by executing - // a draining stack. - ParCompactionManager* cm = ParCompactionManager::manager_array(j); - cm->set_region_stack(NULL); - cm->set_region_stack_index((uint)max_uintx); - } - ParCompactionManager::reset_recycled_stack_index(); - // Find all regions that are available (can be filled immediately) and // distribute them to the thread stacks. The iteration is done in reverse // order (high to low) so the regions will be removed in ascending order. const ParallelCompactData& sd = PSParallelCompact::summary_data(); - // A region index which corresponds to the tasks created above. - // "which" must be 0 <= which < task_count - which = 0; // id + 1 is used to test termination so unsigned can // be used with an old_space_id == 0. @@ -2284,12 +2267,11 @@ void PSParallelCompact::enqueue_region_draining_tasks(GCTaskQueue* q, for (size_t cur = end_region - 1; cur + 1 > beg_region; --cur) { if (sd.region(cur)->claim_unsafe()) { - ParCompactionManager::region_list_push(which, cur); + ParCompactionManager* cm = ParCompactionManager::manager_array(which); + cm->region_stack()->push(cur); region_logger.handle(cur); // Assign regions to tasks in round-robin fashion. - if (++which == task_count) { - assert(which <= parallel_gc_threads, - "Inconsistent number of workers"); + if (++which == parallel_gc_threads) { which = 0; } } @@ -2448,7 +2430,7 @@ void PSParallelCompact::compact() { ParallelTaskTerminator terminator(active_gc_threads, qset); GCTaskQueue* q = GCTaskQueue::create(); - enqueue_region_draining_tasks(q, active_gc_threads); + prepare_region_draining_tasks(q, active_gc_threads); enqueue_dense_prefix_tasks(q, active_gc_threads); enqueue_region_stealing_tasks(q, &terminator, active_gc_threads); diff --git a/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp b/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp index 5af827c92dd..50b7bfb23f5 100644 --- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp +++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp @@ -1079,7 +1079,7 @@ class PSParallelCompact : AllStatic { static void compact(); // Add available regions to the stack and draining tasks to the task queue. - static void enqueue_region_draining_tasks(GCTaskQueue* q, + static void prepare_region_draining_tasks(GCTaskQueue* q, uint parallel_gc_threads); // Add dense prefix update tasks to the task queue. -- GitLab From ad79a5ae65d24861ead3ae96cf148c8bc0f02736 Mon Sep 17 00:00:00 2001 From: Shravya Rukmannagari Date: Wed, 6 Apr 2016 10:29:26 -0700 Subject: [PATCH 120/400] 8152907: Update for x86 tan and log10 in the math lib Optimize Math.tan() and log10() for 64 and 32 bit X86 architecture using Intel LIBM implementation. Reviewed-by: kvn, twisti --- hotspot/src/cpu/x86/vm/assembler_x86.cpp | 13 +- hotspot/src/cpu/x86/vm/assembler_x86.hpp | 2 + .../src/cpu/x86/vm/c1_LIRAssembler_x86.cpp | 5 - .../src/cpu/x86/vm/c1_LIRGenerator_x86.cpp | 94 +- hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp | 52 - hotspot/src/cpu/x86/vm/globals_x86.hpp | 7 +- .../cpu/x86/vm/macroAssembler_libm_x86_32.cpp | 4571 ----------------- .../cpu/x86/vm/macroAssembler_libm_x86_64.cpp | 3945 -------------- hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp | 20 + .../src/cpu/x86/vm/macroAssembler_x86_cos.cpp | 889 ++++ .../src/cpu/x86/vm/macroAssembler_x86_exp.cpp | 674 +++ .../src/cpu/x86/vm/macroAssembler_x86_log.cpp | 655 +++ .../cpu/x86/vm/macroAssembler_x86_log10.cpp | 687 +++ .../src/cpu/x86/vm/macroAssembler_x86_pow.cpp | 3592 +++++++++++++ .../src/cpu/x86/vm/macroAssembler_x86_sin.cpp | 2448 +++++++++ .../src/cpu/x86/vm/macroAssembler_x86_tan.cpp | 2144 ++++++++ .../src/cpu/x86/vm/stubGenerator_x86_32.cpp | 109 +- .../src/cpu/x86/vm/stubGenerator_x86_64.cpp | 152 +- hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp | 23 + hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp | 62 + .../templateInterpreterGenerator_x86_32.cpp | 48 +- .../templateInterpreterGenerator_x86_64.cpp | 59 +- hotspot/src/cpu/x86/vm/x86_32.ad | 56 - hotspot/src/cpu/x86/vm/x86_64.ad | 28 - hotspot/src/share/vm/c1/c1_LIR.cpp | 27 - hotspot/src/share/vm/c1/c1_Runtime1.cpp | 2 + hotspot/src/share/vm/opto/classes.hpp | 2 - hotspot/src/share/vm/opto/library_call.cpp | 18 +- hotspot/src/share/vm/opto/subnode.cpp | 22 - hotspot/src/share/vm/opto/subnode.hpp | 29 - hotspot/src/share/vm/runtime/stubRoutines.cpp | 3 + hotspot/src/share/vm/runtime/stubRoutines.hpp | 6 + hotspot/src/share/vm/runtime/vmStructs.cpp | 4 +- 33 files changed, 11547 insertions(+), 8901 deletions(-) delete mode 100644 hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_32.cpp delete mode 100644 hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_64.cpp create mode 100644 hotspot/src/cpu/x86/vm/macroAssembler_x86_cos.cpp create mode 100644 hotspot/src/cpu/x86/vm/macroAssembler_x86_exp.cpp create mode 100644 hotspot/src/cpu/x86/vm/macroAssembler_x86_log.cpp create mode 100644 hotspot/src/cpu/x86/vm/macroAssembler_x86_log10.cpp create mode 100644 hotspot/src/cpu/x86/vm/macroAssembler_x86_pow.cpp create mode 100644 hotspot/src/cpu/x86/vm/macroAssembler_x86_sin.cpp create mode 100644 hotspot/src/cpu/x86/vm/macroAssembler_x86_tan.cpp diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp index e30a0289b32..564db640d56 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp @@ -1827,6 +1827,15 @@ void Assembler::cvttss2sil(Register dst, XMMRegister src) { emit_int8((unsigned char)(0xC0 | encode)); } +void Assembler::cvttpd2dq(XMMRegister dst, XMMRegister src) { + NOT_LP64(assert(VM_Version::supports_sse2(), "")); + int vector_len = VM_Version::supports_avx512novl() ? AVX_512bit : AVX_128bit; + InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xE6); + emit_int8((unsigned char)(0xC0 | encode)); +} + void Assembler::decl(Address dst) { // Don't use it directly. Use MacroAssembler::decrement() instead. InstructionMark im(this); @@ -4993,7 +5002,7 @@ void Assembler::paddq(XMMRegister dst, XMMRegister src) { } void Assembler::phaddw(XMMRegister dst, XMMRegister src) { - NOT_LP64(assert(VM_Version::supports_sse3(), "")); + assert(VM_Version::supports_sse3(), ""); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); emit_int8(0x01); @@ -5001,7 +5010,7 @@ void Assembler::phaddw(XMMRegister dst, XMMRegister src) { } void Assembler::phaddd(XMMRegister dst, XMMRegister src) { - NOT_LP64(assert(VM_Version::supports_sse3(), "")); + assert(VM_Version::supports_sse3(), ""); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); emit_int8(0x02); diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp index fd3053d1e6f..1297aa2406f 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp @@ -1048,6 +1048,8 @@ private: void cvttss2sil(Register dst, XMMRegister src); void cvttss2siq(Register dst, XMMRegister src); + void cvttpd2dq(XMMRegister dst, XMMRegister src); + // Divide Scalar Double-Precision Floating-Point Values void divsd(XMMRegister dst, Address src); void divsd(XMMRegister dst, XMMRegister src); diff --git a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp index 0a5f1994ec0..08d261deadc 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRAssembler_x86.cpp @@ -2365,13 +2365,8 @@ void LIR_Assembler::intrinsic_op(LIR_Code code, LIR_Opr value, LIR_Opr unused, L } else if (value->is_double_fpu()) { assert(value->fpu_regnrLo() == 0 && dest->fpu_regnrLo() == 0, "both must be on TOS"); switch(code) { - case lir_log10 : __ flog10() ; break; case lir_abs : __ fabs() ; break; case lir_sqrt : __ fsqrt(); break; - case lir_tan : - // Should consider not saving rbx, if not necessary - __ trigfunc('t', op->as_Op2()->fpu_stack_size()); - break; default : ShouldNotReachHere(); } } else { diff --git a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp index b545d0b6989..149b129d257 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp @@ -812,7 +812,8 @@ void LIRGenerator::do_MathIntrinsic(Intrinsic* x) { if (x->id() == vmIntrinsics::_dexp || x->id() == vmIntrinsics::_dlog || x->id() == vmIntrinsics::_dpow || x->id() == vmIntrinsics::_dcos || - x->id() == vmIntrinsics::_dsin) { + x->id() == vmIntrinsics::_dsin || x->id() == vmIntrinsics::_dtan || + x->id() == vmIntrinsics::_dlog10) { do_LibmIntrinsic(x); return; } @@ -820,58 +821,17 @@ void LIRGenerator::do_MathIntrinsic(Intrinsic* x) { LIRItem value(x->argument_at(0), this); bool use_fpu = false; - if (UseSSE >= 2) { - switch(x->id()) { - case vmIntrinsics::_dtan: - case vmIntrinsics::_dlog10: - use_fpu = true; - break; - } - } else { + if (UseSSE < 2) { value.set_destroys_register(); } - value.load_item(); LIR_Opr calc_input = value.result(); - LIR_Opr calc_input2 = NULL; - if (x->id() == vmIntrinsics::_dpow) { - LIRItem extra_arg(x->argument_at(1), this); - if (UseSSE < 2) { - extra_arg.set_destroys_register(); - } - extra_arg.load_item(); - calc_input2 = extra_arg.result(); - } LIR_Opr calc_result = rlock_result(x); - // sin, cos, pow and exp need two free fpu stack slots, so register - // two temporary operands - LIR_Opr tmp1 = FrameMap::caller_save_fpu_reg_at(0); - LIR_Opr tmp2 = FrameMap::caller_save_fpu_reg_at(1); - - if (use_fpu) { - LIR_Opr tmp = FrameMap::fpu0_double_opr; - int tmp_start = 1; - if (calc_input2 != NULL) { - __ move(calc_input2, tmp); - tmp_start = 2; - calc_input2 = tmp; - } - __ move(calc_input, tmp); - - calc_input = tmp; - calc_result = tmp; - - tmp1 = FrameMap::caller_save_fpu_reg_at(tmp_start); - tmp2 = FrameMap::caller_save_fpu_reg_at(tmp_start + 1); - } - switch(x->id()) { case vmIntrinsics::_dabs: __ abs (calc_input, calc_result, LIR_OprFact::illegalOpr); break; case vmIntrinsics::_dsqrt: __ sqrt (calc_input, calc_result, LIR_OprFact::illegalOpr); break; - case vmIntrinsics::_dtan: __ tan (calc_input, calc_result, tmp1, tmp2); break; - case vmIntrinsics::_dlog10: __ log10(calc_input, calc_result, tmp1); break; default: ShouldNotReachHere(); } @@ -912,21 +872,28 @@ void LIRGenerator::do_LibmIntrinsic(Intrinsic* x) { result_reg = tmp; switch(x->id()) { case vmIntrinsics::_dexp: - if (VM_Version::supports_sse2()) { + if (StubRoutines::dexp() != NULL) { __ call_runtime_leaf(StubRoutines::dexp(), getThreadTemp(), result_reg, cc->args()); } else { __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dexp), getThreadTemp(), result_reg, cc->args()); } break; case vmIntrinsics::_dlog: - if (VM_Version::supports_sse2()) { + if (StubRoutines::dlog() != NULL) { __ call_runtime_leaf(StubRoutines::dlog(), getThreadTemp(), result_reg, cc->args()); } else { __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dlog), getThreadTemp(), result_reg, cc->args()); } break; + case vmIntrinsics::_dlog10: + if (StubRoutines::dlog10() != NULL) { + __ call_runtime_leaf(StubRoutines::dlog10(), getThreadTemp(), result_reg, cc->args()); + } else { + __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10), getThreadTemp(), result_reg, cc->args()); + } + break; case vmIntrinsics::_dpow: - if (VM_Version::supports_sse2()) { + if (StubRoutines::dpow() != NULL) { __ call_runtime_leaf(StubRoutines::dpow(), getThreadTemp(), result_reg, cc->args()); } else { __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dpow), getThreadTemp(), result_reg, cc->args()); @@ -946,18 +913,44 @@ void LIRGenerator::do_LibmIntrinsic(Intrinsic* x) { __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dcos), getThreadTemp(), result_reg, cc->args()); } break; + case vmIntrinsics::_dtan: + if (StubRoutines::dtan() != NULL) { + __ call_runtime_leaf(StubRoutines::dtan(), getThreadTemp(), result_reg, cc->args()); + } else { + __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtan), getThreadTemp(), result_reg, cc->args()); + } + break; default: ShouldNotReachHere(); } #else switch (x->id()) { case vmIntrinsics::_dexp: - __ call_runtime_leaf(StubRoutines::dexp(), getThreadTemp(), result_reg, cc->args()); + if (StubRoutines::dexp() != NULL) { + __ call_runtime_leaf(StubRoutines::dexp(), getThreadTemp(), result_reg, cc->args()); + } else { + __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dexp), getThreadTemp(), result_reg, cc->args()); + } break; case vmIntrinsics::_dlog: + if (StubRoutines::dlog() != NULL) { __ call_runtime_leaf(StubRoutines::dlog(), getThreadTemp(), result_reg, cc->args()); + } else { + __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dlog), getThreadTemp(), result_reg, cc->args()); + } + break; + case vmIntrinsics::_dlog10: + if (StubRoutines::dlog10() != NULL) { + __ call_runtime_leaf(StubRoutines::dlog10(), getThreadTemp(), result_reg, cc->args()); + } else { + __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10), getThreadTemp(), result_reg, cc->args()); + } break; case vmIntrinsics::_dpow: + if (StubRoutines::dpow() != NULL) { __ call_runtime_leaf(StubRoutines::dpow(), getThreadTemp(), result_reg, cc->args()); + } else { + __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dpow), getThreadTemp(), result_reg, cc->args()); + } break; case vmIntrinsics::_dsin: if (StubRoutines::dsin() != NULL) { @@ -973,6 +966,13 @@ void LIRGenerator::do_LibmIntrinsic(Intrinsic* x) { __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dcos), getThreadTemp(), result_reg, cc->args()); } break; + case vmIntrinsics::_dtan: + if (StubRoutines::dtan() != NULL) { + __ call_runtime_leaf(StubRoutines::dtan(), getThreadTemp(), result_reg, cc->args()); + } else { + __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtan), getThreadTemp(), result_reg, cc->args()); + } + break; default: ShouldNotReachHere(); } #endif // _LP64 diff --git a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp index c3108727fec..5da8e5ba844 100644 --- a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp @@ -786,58 +786,6 @@ void FpuStackAllocator::handle_op2(LIR_Op2* op2) { break; } - case lir_log10: { - // log and log10 need one temporary fpu stack slot, so - // there is one temporary registers stored in temp of the - // operation. the stack allocator must guarantee that the stack - // slots are really free, otherwise there might be a stack - // overflow. - assert(right->is_illegal(), "must be"); - assert(left->is_fpu_register(), "must be"); - assert(res->is_fpu_register(), "must be"); - assert(op2->tmp1_opr()->is_fpu_register(), "must be"); - - insert_free_if_dead(op2->tmp1_opr()); - insert_free_if_dead(res, left); - insert_exchange(left); - do_rename(left, res); - - new_left = to_fpu_stack_top(res); - new_res = new_left; - - op2->set_fpu_stack_size(sim()->stack_size()); - assert(sim()->stack_size() <= 7, "at least one stack slot must be free"); - break; - } - - - case lir_tan: { - // sin, cos and exp need two temporary fpu stack slots, so there are two temporary - // registers (stored in right and temp of the operation). - // the stack allocator must guarantee that the stack slots are really free, - // otherwise there might be a stack overflow. - assert(left->is_fpu_register(), "must be"); - assert(res->is_fpu_register(), "must be"); - // assert(left->is_last_use(), "old value gets destroyed"); - assert(right->is_fpu_register(), "right is used as the first temporary register"); - assert(op2->tmp1_opr()->is_fpu_register(), "temp is used as the second temporary register"); - assert(fpu_num(left) != fpu_num(right) && fpu_num(right) != fpu_num(op2->tmp1_opr()) && fpu_num(op2->tmp1_opr()) != fpu_num(res), "need distinct temp registers"); - - insert_free_if_dead(right); - insert_free_if_dead(op2->tmp1_opr()); - - insert_free_if_dead(res, left); - insert_exchange(left); - do_rename(left, res); - - new_left = to_fpu_stack_top(res); - new_res = new_left; - - op2->set_fpu_stack_size(sim()->stack_size()); - assert(sim()->stack_size() <= 6, "at least two stack slots must be free"); - break; - } - default: { assert(false, "missed a fpu-operation"); } diff --git a/hotspot/src/cpu/x86/vm/globals_x86.hpp b/hotspot/src/cpu/x86/vm/globals_x86.hpp index a8d36092b58..407a8af217a 100644 --- a/hotspot/src/cpu/x86/vm/globals_x86.hpp +++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp @@ -194,9 +194,6 @@ define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong); product(bool, UseBMI2Instructions, false, \ "Use BMI2 instructions") \ \ - diagnostic(bool, UseLibmSinIntrinsic, true, \ - "Use Libm Sin Intrinsic") \ - \ - diagnostic(bool, UseLibmCosIntrinsic, true, \ - "Use Libm Cos Intrinsic") + diagnostic(bool, UseLibmIntrinsic, true, \ + "Use Libm Intrinsics") #endif // CPU_X86_VM_GLOBALS_X86_HPP diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_32.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_32.cpp deleted file mode 100644 index 923e8fc39b5..00000000000 --- a/hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_32.cpp +++ /dev/null @@ -1,4571 +0,0 @@ -/* - * Copyright (c) 2015, Intel Corporation. - * Intel Math Library (LIBM) Source Code - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "asm/assembler.hpp" -#include "asm/assembler.inline.hpp" -#include "runtime/stubRoutines.hpp" -#include "macroAssembler_x86.hpp" - -#ifdef _MSC_VER -#define ALIGNED_(x) __declspec(align(x)) -#else -#define ALIGNED_(x) __attribute__ ((aligned(x))) -#endif - -// The 32 bit code is at most SSE2 compliant - -/******************************************************************************/ -// ALGORITHM DESCRIPTION - EXP() -// --------------------- -// -// Description: -// Let K = 64 (table size). -// x x/log(2) n -// e = 2 = 2 * T[j] * (1 + P(y)) -// where -// x = m*log(2)/K + y, y in [-log(2)/K..log(2)/K] -// m = n*K + j, m,n,j - signed integer, j in [-K/2..K/2] -// j/K -// values of 2 are tabulated as T[j] = T_hi[j] ( 1 + T_lo[j]). -// -// P(y) is a minimax polynomial approximation of exp(x)-1 -// on small interval [-log(2)/K..log(2)/K] (were calculated by Maple V). -// -// To avoid problems with arithmetic overflow and underflow, -// n n1 n2 -// value of 2 is safely computed as 2 * 2 where n1 in [-BIAS/2..BIAS/2] -// where BIAS is a value of exponent bias. -// -// Special cases: -// exp(NaN) = NaN -// exp(+INF) = +INF -// exp(-INF) = 0 -// exp(x) = 1 for subnormals -// for finite argument, only exp(0)=1 is exact -// For IEEE double -// if x > 709.782712893383973096 then exp(x) overflow -// if x < -745.133219101941108420 then exp(x) underflow -// -/******************************************************************************/ - -ALIGNED_(16) juint _static_const_table[] = -{ - 0x00000000UL, 0xfff00000UL, 0x00000000UL, 0xfff00000UL, 0xffffffc0UL, - 0x00000000UL, 0xffffffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL, - 0x0000ffc0UL, 0x00000000UL, 0x00000000UL, 0x43380000UL, 0x00000000UL, - 0x43380000UL, 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL, - 0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL, 0xbc9e3b3aUL, - 0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xfffffffeUL, 0x3fdfffffUL, - 0xfffffffeUL, 0x3fdfffffUL, 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, - 0x3fa55555UL, 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL, - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0e03754dUL, - 0x3cad7bbfUL, 0x3e778060UL, 0x00002c9aUL, 0x3567f613UL, 0x3c8cd252UL, - 0xd3158574UL, 0x000059b0UL, 0x61e6c861UL, 0x3c60f74eUL, 0x18759bc8UL, - 0x00008745UL, 0x5d837b6cUL, 0x3c979aa6UL, 0x6cf9890fUL, 0x0000b558UL, - 0x702f9cd1UL, 0x3c3ebe3dUL, 0x32d3d1a2UL, 0x0000e3ecUL, 0x1e63bcd8UL, - 0x3ca3516eUL, 0xd0125b50UL, 0x00011301UL, 0x26f0387bUL, 0x3ca4c554UL, - 0xaea92ddfUL, 0x0001429aUL, 0x62523fb6UL, 0x3ca95153UL, 0x3c7d517aUL, - 0x000172b8UL, 0x3f1353bfUL, 0x3c8b898cUL, 0xeb6fcb75UL, 0x0001a35bUL, - 0x3e3a2f5fUL, 0x3c9aecf7UL, 0x3168b9aaUL, 0x0001d487UL, 0x44a6c38dUL, - 0x3c8a6f41UL, 0x88628cd6UL, 0x0002063bUL, 0xe3a8a894UL, 0x3c968efdUL, - 0x6e756238UL, 0x0002387aUL, 0x981fe7f2UL, 0x3c80472bUL, 0x65e27cddUL, - 0x00026b45UL, 0x6d09ab31UL, 0x3c82f7e1UL, 0xf51fdee1UL, 0x00029e9dUL, - 0x720c0ab3UL, 0x3c8b3782UL, 0xa6e4030bUL, 0x0002d285UL, 0x4db0abb6UL, - 0x3c834d75UL, 0x0a31b715UL, 0x000306feUL, 0x5dd3f84aUL, 0x3c8fdd39UL, - 0xb26416ffUL, 0x00033c08UL, 0xcc187d29UL, 0x3ca12f8cUL, 0x373aa9caUL, - 0x000371a7UL, 0x738b5e8bUL, 0x3ca7d229UL, 0x34e59ff6UL, 0x0003a7dbUL, - 0xa72a4c6dUL, 0x3c859f48UL, 0x4c123422UL, 0x0003dea6UL, 0x259d9205UL, - 0x3ca8b846UL, 0x21f72e29UL, 0x0004160aUL, 0x60c2ac12UL, 0x3c4363edUL, - 0x6061892dUL, 0x00044e08UL, 0xdaa10379UL, 0x3c6ecce1UL, 0xb5c13cd0UL, - 0x000486a2UL, 0xbb7aafb0UL, 0x3c7690ceUL, 0xd5362a27UL, 0x0004bfdaUL, - 0x9b282a09UL, 0x3ca083ccUL, 0x769d2ca6UL, 0x0004f9b2UL, 0xc1aae707UL, - 0x3ca509b0UL, 0x569d4f81UL, 0x0005342bUL, 0x18fdd78eUL, 0x3c933505UL, - 0x36b527daUL, 0x00056f47UL, 0xe21c5409UL, 0x3c9063e1UL, 0xdd485429UL, - 0x0005ab07UL, 0x2b64c035UL, 0x3c9432e6UL, 0x15ad2148UL, 0x0005e76fUL, - 0x99f08c0aUL, 0x3ca01284UL, 0xb03a5584UL, 0x0006247eUL, 0x0073dc06UL, - 0x3c99f087UL, 0x82552224UL, 0x00066238UL, 0x0da05571UL, 0x3c998d4dUL, - 0x667f3bccUL, 0x0006a09eUL, 0x86ce4786UL, 0x3ca52bb9UL, 0x3c651a2eUL, - 0x0006dfb2UL, 0x206f0dabUL, 0x3ca32092UL, 0xe8ec5f73UL, 0x00071f75UL, - 0x8e17a7a6UL, 0x3ca06122UL, 0x564267c8UL, 0x00075febUL, 0x461e9f86UL, - 0x3ca244acUL, 0x73eb0186UL, 0x0007a114UL, 0xabd66c55UL, 0x3c65ebe1UL, - 0x36cf4e62UL, 0x0007e2f3UL, 0xbbff67d0UL, 0x3c96fe9fUL, 0x994cce12UL, - 0x00082589UL, 0x14c801dfUL, 0x3c951f14UL, 0x9b4492ecUL, 0x000868d9UL, - 0xc1f0eab4UL, 0x3c8db72fUL, 0x422aa0dbUL, 0x0008ace5UL, 0x59f35f44UL, - 0x3c7bf683UL, 0x99157736UL, 0x0008f1aeUL, 0x9c06283cUL, 0x3ca360baUL, - 0xb0cdc5e4UL, 0x00093737UL, 0x20f962aaUL, 0x3c95e8d1UL, 0x9fde4e4fUL, - 0x00097d82UL, 0x2b91ce27UL, 0x3c71affcUL, 0x82a3f090UL, 0x0009c491UL, - 0x589a2ebdUL, 0x3c9b6d34UL, 0x7b5de564UL, 0x000a0c66UL, 0x9ab89880UL, - 0x3c95277cUL, 0xb23e255cUL, 0x000a5503UL, 0x6e735ab3UL, 0x3c846984UL, - 0x5579fdbfUL, 0x000a9e6bUL, 0x92cb3387UL, 0x3c8c1a77UL, 0x995ad3adUL, - 0x000ae89fUL, 0xdc2d1d96UL, 0x3ca22466UL, 0xb84f15faUL, 0x000b33a2UL, - 0xb19505aeUL, 0x3ca1112eUL, 0xf2fb5e46UL, 0x000b7f76UL, 0x0a5fddcdUL, - 0x3c74ffd7UL, 0x904bc1d2UL, 0x000bcc1eUL, 0x30af0cb3UL, 0x3c736eaeUL, - 0xdd85529cUL, 0x000c199bUL, 0xd10959acUL, 0x3c84e08fUL, 0x2e57d14bUL, - 0x000c67f1UL, 0x6c921968UL, 0x3c676b2cUL, 0xdcef9069UL, 0x000cb720UL, - 0x36df99b3UL, 0x3c937009UL, 0x4a07897bUL, 0x000d072dUL, 0xa63d07a7UL, - 0x3c74a385UL, 0xdcfba487UL, 0x000d5818UL, 0xd5c192acUL, 0x3c8e5a50UL, - 0x03db3285UL, 0x000da9e6UL, 0x1c4a9792UL, 0x3c98bb73UL, 0x337b9b5eUL, - 0x000dfc97UL, 0x603a88d3UL, 0x3c74b604UL, 0xe78b3ff6UL, 0x000e502eUL, - 0x92094926UL, 0x3c916f27UL, 0xa2a490d9UL, 0x000ea4afUL, 0x41aa2008UL, - 0x3c8ec3bcUL, 0xee615a27UL, 0x000efa1bUL, 0x31d185eeUL, 0x3c8a64a9UL, - 0x5b6e4540UL, 0x000f5076UL, 0x4d91cd9dUL, 0x3c77893bUL, 0x819e90d8UL, - 0x000fa7c1UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x7ff00000UL, - 0x00000000UL, 0x00000000UL, 0xffffffffUL, 0x7fefffffUL, 0x00000000UL, - 0x00100000UL -}; - -//registers, -// input: (rbp + 8) -// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 -// rax, rdx, rcx, rbx (tmp) - -// Code generated by Intel C compiler for LIBM library - -void MacroAssembler::fast_exp(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) { - Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; - Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; - Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2; - Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start; - - assert_different_registers(tmp, eax, ecx, edx); - jmp(start); - address static_const_table = (address)_static_const_table; - - bind(start); - subl(rsp, 120); - movl(Address(rsp, 64), tmp); - lea(tmp, ExternalAddress(static_const_table)); - movdqu(xmm0, Address(rsp, 128)); - unpcklpd(xmm0, xmm0); - movdqu(xmm1, Address(tmp, 64)); // 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL - movdqu(xmm6, Address(tmp, 48)); // 0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL - movdqu(xmm2, Address(tmp, 80)); // 0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL - movdqu(xmm3, Address(tmp, 96)); // 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL - pextrw(eax, xmm0, 3); - andl(eax, 32767); - movl(edx, 16527); - subl(edx, eax); - subl(eax, 15504); - orl(edx, eax); - cmpl(edx, INT_MIN); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); - mulpd(xmm1, xmm0); - addpd(xmm1, xmm6); - movapd(xmm7, xmm1); - subpd(xmm1, xmm6); - mulpd(xmm2, xmm1); - movdqu(xmm4, Address(tmp, 128)); // 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL - mulpd(xmm3, xmm1); - movdqu(xmm5, Address(tmp, 144)); // 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL - subpd(xmm0, xmm2); - movdl(eax, xmm7); - movl(ecx, eax); - andl(ecx, 63); - shll(ecx, 4); - sarl(eax, 6); - movl(edx, eax); - movdqu(xmm6, Address(tmp, 16)); // 0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL - pand(xmm7, xmm6); - movdqu(xmm6, Address(tmp, 32)); // 0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL - paddq(xmm7, xmm6); - psllq(xmm7, 46); - subpd(xmm0, xmm3); - movdqu(xmm2, Address(tmp, ecx, Address::times_1, 160)); - mulpd(xmm4, xmm0); - movapd(xmm6, xmm0); - movapd(xmm1, xmm0); - mulpd(xmm6, xmm6); - mulpd(xmm0, xmm6); - addpd(xmm5, xmm4); - mulsd(xmm0, xmm6); - mulpd(xmm6, Address(tmp, 112)); // 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL, 0x3fdfffffUL - addsd(xmm1, xmm2); - unpckhpd(xmm2, xmm2); - mulpd(xmm0, xmm5); - addsd(xmm1, xmm0); - por(xmm2, xmm7); - unpckhpd(xmm0, xmm0); - addsd(xmm0, xmm1); - addsd(xmm0, xmm6); - addl(edx, 894); - cmpl(edx, 1916); - jcc (Assembler::above, L_2TAG_PACKET_1_0_2); - mulsd(xmm0, xmm2); - addsd(xmm0, xmm2); - jmp(L_2TAG_PACKET_2_0_2); - - bind(L_2TAG_PACKET_1_0_2); - fnstcw(Address(rsp, 24)); - movzwl(edx, Address(rsp, 24)); - orl(edx, 768); - movw(Address(rsp, 28), edx); - fldcw(Address(rsp, 28)); - movl(edx, eax); - sarl(eax, 1); - subl(edx, eax); - movdqu(xmm6, Address(tmp, 0)); // 0x00000000UL, 0xfff00000UL, 0x00000000UL, 0xfff00000UL - pandn(xmm6, xmm2); - addl(eax, 1023); - movdl(xmm3, eax); - psllq(xmm3, 52); - por(xmm6, xmm3); - addl(edx, 1023); - movdl(xmm4, edx); - psllq(xmm4, 52); - movsd(Address(rsp, 8), xmm0); - fld_d(Address(rsp, 8)); - movsd(Address(rsp, 16), xmm6); - fld_d(Address(rsp, 16)); - fmula(1); - faddp(1); - movsd(Address(rsp, 8), xmm4); - fld_d(Address(rsp, 8)); - fmulp(1); - fstp_d(Address(rsp, 8)); - movsd(xmm0,Address(rsp, 8)); - fldcw(Address(rsp, 24)); - pextrw(ecx, xmm0, 3); - andl(ecx, 32752); - cmpl(ecx, 32752); - jcc(Assembler::greaterEqual, L_2TAG_PACKET_3_0_2); - cmpl(ecx, 0); - jcc(Assembler::equal, L_2TAG_PACKET_4_0_2); - jmp(L_2TAG_PACKET_2_0_2); - cmpl(ecx, INT_MIN); - jcc(Assembler::less, L_2TAG_PACKET_3_0_2); - cmpl(ecx, -1064950997); - jcc(Assembler::less, L_2TAG_PACKET_2_0_2); - jcc(Assembler::greater, L_2TAG_PACKET_4_0_2); - movl(edx, Address(rsp, 128)); - cmpl(edx ,-17155601); - jcc(Assembler::less, L_2TAG_PACKET_2_0_2); - jmp(L_2TAG_PACKET_4_0_2); - - bind(L_2TAG_PACKET_3_0_2); - movl(edx, 14); - jmp(L_2TAG_PACKET_5_0_2); - - bind(L_2TAG_PACKET_4_0_2); - movl(edx, 15); - - bind(L_2TAG_PACKET_5_0_2); - movsd(Address(rsp, 0), xmm0); - movsd(xmm0, Address(rsp, 128)); - fld_d(Address(rsp, 0)); - jmp(L_2TAG_PACKET_6_0_2); - - bind(L_2TAG_PACKET_7_0_2); - cmpl(eax, 2146435072); - jcc(Assembler::greaterEqual, L_2TAG_PACKET_8_0_2); - movl(eax, Address(rsp, 132)); - cmpl(eax, INT_MIN); - jcc(Assembler::greaterEqual, L_2TAG_PACKET_9_0_2); - movsd(xmm0, Address(tmp, 1208)); // 0xffffffffUL, 0x7fefffffUL - mulsd(xmm0, xmm0); - movl(edx, 14); - jmp(L_2TAG_PACKET_5_0_2); - - bind(L_2TAG_PACKET_9_0_2); - movsd(xmm0, Address(tmp, 1216)); - mulsd(xmm0, xmm0); - movl(edx, 15); - jmp(L_2TAG_PACKET_5_0_2); - - bind(L_2TAG_PACKET_8_0_2); - movl(edx, Address(rsp, 128)); - cmpl(eax, 2146435072); - jcc(Assembler::above, L_2TAG_PACKET_10_0_2); - cmpl(edx, 0); - jcc(Assembler::notEqual, L_2TAG_PACKET_10_0_2); - movl(eax, Address(rsp, 132)); - cmpl(eax, 2146435072); - jcc(Assembler::notEqual, L_2TAG_PACKET_11_0_2); - movsd(xmm0, Address(tmp, 1192)); // 0x00000000UL, 0x7ff00000UL - jmp(L_2TAG_PACKET_2_0_2); - - bind(L_2TAG_PACKET_11_0_2); - movsd(xmm0, Address(tmp, 1200)); // 0x00000000UL, 0x00000000UL - jmp(L_2TAG_PACKET_2_0_2); - - bind(L_2TAG_PACKET_10_0_2); - movsd(xmm0, Address(rsp, 128)); - addsd(xmm0, xmm0); - jmp(L_2TAG_PACKET_2_0_2); - - bind(L_2TAG_PACKET_0_0_2); - movl(eax, Address(rsp, 132)); - andl(eax, 2147483647); - cmpl(eax, 1083179008); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_7_0_2); - movsd(xmm0, Address(rsp, 128)); - addsd(xmm0, Address(tmp, 1184)); // 0x00000000UL, 0x3ff00000UL - jmp(L_2TAG_PACKET_2_0_2); - - bind(L_2TAG_PACKET_2_0_2); - movsd(Address(rsp, 48), xmm0); - fld_d(Address(rsp, 48)); - - bind(L_2TAG_PACKET_6_0_2); - movl(tmp, Address(rsp, 64)); -} - -/******************************************************************************/ -// ALGORITHM DESCRIPTION - LOG() -// --------------------- -// -// x=2^k * mx, mx in [1,2) -// -// Get B~1/mx based on the output of rcpss instruction (B0) -// B = int((B0*2^7+0.5))/2^7 -// -// Reduced argument: r=B*mx-1.0 (computed accurately in high and low parts) -// -// Result: k*log(2) - log(B) + p(r) if |x-1| >= small value (2^-6) and -// p(r) is a degree 7 polynomial -// -log(B) read from data table (high, low parts) -// Result is formed from high and low parts -// -// Special cases: -// log(NaN) = quiet NaN, and raise invalid exception -// log(+INF) = that INF -// log(0) = -INF with divide-by-zero exception raised -// log(1) = +0 -// log(x) = NaN with invalid exception raised if x < -0, including -INF -// -/******************************************************************************/ - -ALIGNED_(16) juint _static_const_table_log[] = -{ - 0xfefa3800UL, 0x3fe62e42UL, 0x93c76730UL, 0x3d2ef357UL, 0xaa241800UL, - 0x3fe5ee82UL, 0x0cda46beUL, 0x3d220238UL, 0x5c364800UL, 0x3fe5af40UL, - 0xac10c9fbUL, 0x3d2dfa63UL, 0x26bb8c00UL, 0x3fe5707aUL, 0xff3303ddUL, - 0x3d09980bUL, 0x26867800UL, 0x3fe5322eUL, 0x5d257531UL, 0x3d05ccc4UL, - 0x835a5000UL, 0x3fe4f45aUL, 0x6d93b8fbUL, 0xbd2e6c51UL, 0x6f970c00UL, - 0x3fe4b6fdUL, 0xed4c541cUL, 0x3cef7115UL, 0x27e8a400UL, 0x3fe47a15UL, - 0xf94d60aaUL, 0xbd22cb6aUL, 0xf2f92400UL, 0x3fe43d9fUL, 0x481051f7UL, - 0xbcfd984fUL, 0x2125cc00UL, 0x3fe4019cUL, 0x30f0c74cUL, 0xbd26ce79UL, - 0x0c36c000UL, 0x3fe3c608UL, 0x7cfe13c2UL, 0xbd02b736UL, 0x17197800UL, - 0x3fe38ae2UL, 0xbb5569a4UL, 0xbd218b7aUL, 0xad9d8c00UL, 0x3fe35028UL, - 0x9527e6acUL, 0x3d10b83fUL, 0x44340800UL, 0x3fe315daUL, 0xc5a0ed9cUL, - 0xbd274e93UL, 0x57b0e000UL, 0x3fe2dbf5UL, 0x07b9dc11UL, 0xbd17a6e5UL, - 0x6d0ec000UL, 0x3fe2a278UL, 0xe797882dUL, 0x3d206d2bUL, 0x1134dc00UL, - 0x3fe26962UL, 0x05226250UL, 0xbd0b61f1UL, 0xd8bebc00UL, 0x3fe230b0UL, - 0x6e48667bUL, 0x3d12fc06UL, 0x5fc61800UL, 0x3fe1f863UL, 0xc9fe81d3UL, - 0xbd2a7242UL, 0x49ae6000UL, 0x3fe1c078UL, 0xed70e667UL, 0x3cccacdeUL, - 0x40f23c00UL, 0x3fe188eeUL, 0xf8ab4650UL, 0x3d14cc4eUL, 0xf6f29800UL, - 0x3fe151c3UL, 0xa293ae49UL, 0xbd2edd97UL, 0x23c75c00UL, 0x3fe11af8UL, - 0xbb9ddcb2UL, 0xbd258647UL, 0x8611cc00UL, 0x3fe0e489UL, 0x07801742UL, - 0x3d1c2998UL, 0xe2d05400UL, 0x3fe0ae76UL, 0x887e7e27UL, 0x3d1f486bUL, - 0x0533c400UL, 0x3fe078bfUL, 0x41edf5fdUL, 0x3d268122UL, 0xbe760400UL, - 0x3fe04360UL, 0xe79539e0UL, 0xbd04c45fUL, 0xe5b20800UL, 0x3fe00e5aUL, - 0xb1727b1cUL, 0xbd053ba3UL, 0xaf7a4800UL, 0x3fdfb358UL, 0x3c164935UL, - 0x3d0085faUL, 0xee031800UL, 0x3fdf4aa7UL, 0x6f014a8bUL, 0x3d12cde5UL, - 0x56b41000UL, 0x3fdee2a1UL, 0x5a470251UL, 0x3d2f27f4UL, 0xc3ddb000UL, - 0x3fde7b42UL, 0x5372bd08UL, 0xbd246550UL, 0x1a272800UL, 0x3fde148aUL, - 0x07322938UL, 0xbd1326b2UL, 0x484c9800UL, 0x3fddae75UL, 0x60dc616aUL, - 0xbd1ea42dUL, 0x46def800UL, 0x3fdd4902UL, 0xe9a767a8UL, 0x3d235bafUL, - 0x18064800UL, 0x3fdce42fUL, 0x3ec7a6b0UL, 0xbd0797c3UL, 0xc7455800UL, - 0x3fdc7ff9UL, 0xc15249aeUL, 0xbd29b6ddUL, 0x693fa000UL, 0x3fdc1c60UL, - 0x7fe8e180UL, 0x3d2cec80UL, 0x1b80e000UL, 0x3fdbb961UL, 0xf40a666dUL, - 0x3d27d85bUL, 0x04462800UL, 0x3fdb56faUL, 0x2d841995UL, 0x3d109525UL, - 0x5248d000UL, 0x3fdaf529UL, 0x52774458UL, 0xbd217cc5UL, 0x3c8ad800UL, - 0x3fda93edUL, 0xbea77a5dUL, 0x3d1e36f2UL, 0x0224f800UL, 0x3fda3344UL, - 0x7f9d79f5UL, 0x3d23c645UL, 0xea15f000UL, 0x3fd9d32bUL, 0x10d0c0b0UL, - 0xbd26279eUL, 0x43135800UL, 0x3fd973a3UL, 0xa502d9f0UL, 0xbd152313UL, - 0x635bf800UL, 0x3fd914a8UL, 0x2ee6307dUL, 0xbd1766b5UL, 0xa88b3000UL, - 0x3fd8b639UL, 0xe5e70470UL, 0xbd205ae1UL, 0x776dc800UL, 0x3fd85855UL, - 0x3333778aUL, 0x3d2fd56fUL, 0x3bd81800UL, 0x3fd7fafaUL, 0xc812566aUL, - 0xbd272090UL, 0x687cf800UL, 0x3fd79e26UL, 0x2efd1778UL, 0x3d29ec7dUL, - 0x76c67800UL, 0x3fd741d8UL, 0x49dc60b3UL, 0x3d2d8b09UL, 0xe6af1800UL, - 0x3fd6e60eUL, 0x7c222d87UL, 0x3d172165UL, 0x3e9c6800UL, 0x3fd68ac8UL, - 0x2756eba0UL, 0x3d20a0d3UL, 0x0b3ab000UL, 0x3fd63003UL, 0xe731ae00UL, - 0xbd2db623UL, 0xdf596000UL, 0x3fd5d5bdUL, 0x08a465dcUL, 0xbd0a0b2aUL, - 0x53c8d000UL, 0x3fd57bf7UL, 0xee5d40efUL, 0x3d1fadedUL, 0x0738a000UL, - 0x3fd522aeUL, 0x8164c759UL, 0x3d2ebe70UL, 0x9e173000UL, 0x3fd4c9e0UL, - 0x1b0ad8a4UL, 0xbd2e2089UL, 0xc271c800UL, 0x3fd4718dUL, 0x0967d675UL, - 0xbd2f27ceUL, 0x23d5e800UL, 0x3fd419b4UL, 0xec90e09dUL, 0x3d08e436UL, - 0x77333000UL, 0x3fd3c252UL, 0xb606bd5cUL, 0x3d183b54UL, 0x76be1000UL, - 0x3fd36b67UL, 0xb0f177c8UL, 0x3d116ecdUL, 0xe1d36000UL, 0x3fd314f1UL, - 0xd3213cb8UL, 0xbd28e27aUL, 0x7cdc9000UL, 0x3fd2bef0UL, 0x4a5004f4UL, - 0x3d2a9cfaUL, 0x1134d800UL, 0x3fd26962UL, 0xdf5bb3b6UL, 0x3d2c93c1UL, - 0x6d0eb800UL, 0x3fd21445UL, 0xba46baeaUL, 0x3d0a87deUL, 0x635a6800UL, - 0x3fd1bf99UL, 0x5147bdb7UL, 0x3d2ca6edUL, 0xcbacf800UL, 0x3fd16b5cUL, - 0xf7a51681UL, 0x3d2b9acdUL, 0x8227e800UL, 0x3fd1178eUL, 0x63a5f01cUL, - 0xbd2c210eUL, 0x67616000UL, 0x3fd0c42dUL, 0x163ceae9UL, 0x3d27188bUL, - 0x604d5800UL, 0x3fd07138UL, 0x16ed4e91UL, 0x3cf89cdbUL, 0x5626c800UL, - 0x3fd01eaeUL, 0x1485e94aUL, 0xbd16f08cUL, 0x6cb3b000UL, 0x3fcf991cUL, - 0xca0cdf30UL, 0x3d1bcbecUL, 0xe4dd0000UL, 0x3fcef5adUL, 0x65bb8e11UL, - 0xbcca2115UL, 0xffe71000UL, 0x3fce530eUL, 0x6041f430UL, 0x3cc21227UL, - 0xb0d49000UL, 0x3fcdb13dUL, 0xf715b035UL, 0xbd2aff2aUL, 0xf2656000UL, - 0x3fcd1037UL, 0x75b6f6e4UL, 0xbd084a7eUL, 0xc6f01000UL, 0x3fcc6ffbUL, - 0xc5962bd2UL, 0xbcf1ec72UL, 0x383be000UL, 0x3fcbd087UL, 0x595412b6UL, - 0xbd2d4bc4UL, 0x575bd000UL, 0x3fcb31d8UL, 0x4eace1aaUL, 0xbd0c358dUL, - 0x3c8ae000UL, 0x3fca93edUL, 0x50562169UL, 0xbd287243UL, 0x07089000UL, - 0x3fc9f6c4UL, 0x6865817aUL, 0x3d29904dUL, 0xdcf70000UL, 0x3fc95a5aUL, - 0x58a0ff6fUL, 0x3d07f228UL, 0xeb390000UL, 0x3fc8beafUL, 0xaae92cd1UL, - 0xbd073d54UL, 0x6551a000UL, 0x3fc823c1UL, 0x9a631e83UL, 0x3d1e0ddbUL, - 0x85445000UL, 0x3fc7898dUL, 0x70914305UL, 0xbd1c6610UL, 0x8b757000UL, - 0x3fc6f012UL, 0xe59c21e1UL, 0xbd25118dUL, 0xbe8c1000UL, 0x3fc6574eUL, - 0x2c3c2e78UL, 0x3d19cf8bUL, 0x6b544000UL, 0x3fc5bf40UL, 0xeb68981cUL, - 0xbd127023UL, 0xe4a1b000UL, 0x3fc527e5UL, 0xe5697dc7UL, 0x3d2633e8UL, - 0x8333b000UL, 0x3fc4913dUL, 0x54fdb678UL, 0x3d258379UL, 0xa5993000UL, - 0x3fc3fb45UL, 0x7e6a354dUL, 0xbd2cd1d8UL, 0xb0159000UL, 0x3fc365fcUL, - 0x234b7289UL, 0x3cc62fa8UL, 0x0c868000UL, 0x3fc2d161UL, 0xcb81b4a1UL, - 0x3d039d6cUL, 0x2a49c000UL, 0x3fc23d71UL, 0x8fd3df5cUL, 0x3d100d23UL, - 0x7e23f000UL, 0x3fc1aa2bUL, 0x44389934UL, 0x3d2ca78eUL, 0x8227e000UL, - 0x3fc1178eUL, 0xce2d07f2UL, 0x3d21ef78UL, 0xb59e4000UL, 0x3fc08598UL, - 0x7009902cUL, 0xbd27e5ddUL, 0x39dbe000UL, 0x3fbfe891UL, 0x4fa10afdUL, - 0xbd2534d6UL, 0x830a2000UL, 0x3fbec739UL, 0xafe645e0UL, 0xbd2dc068UL, - 0x63844000UL, 0x3fbda727UL, 0x1fa71733UL, 0x3d1a8940UL, 0x01bc4000UL, - 0x3fbc8858UL, 0xc65aacd3UL, 0x3d2646d1UL, 0x8dad6000UL, 0x3fbb6ac8UL, - 0x2bf768e5UL, 0xbd139080UL, 0x40b1c000UL, 0x3fba4e76UL, 0xb94407c8UL, - 0xbd0e42b6UL, 0x5d594000UL, 0x3fb9335eUL, 0x3abd47daUL, 0x3d23115cUL, - 0x2f40e000UL, 0x3fb8197eUL, 0xf96ffdf7UL, 0x3d0f80dcUL, 0x0aeac000UL, - 0x3fb700d3UL, 0xa99ded32UL, 0x3cec1e8dUL, 0x4d97a000UL, 0x3fb5e95aUL, - 0x3c5d1d1eUL, 0xbd2c6906UL, 0x5d208000UL, 0x3fb4d311UL, 0x82f4e1efUL, - 0xbcf53a25UL, 0xa7d1e000UL, 0x3fb3bdf5UL, 0xa5db4ed7UL, 0x3d2cc85eUL, - 0xa4472000UL, 0x3fb2aa04UL, 0xae9c697dUL, 0xbd20b6e8UL, 0xd1466000UL, - 0x3fb1973bUL, 0x560d9e9bUL, 0xbd25325dUL, 0xb59e4000UL, 0x3fb08598UL, - 0x7009902cUL, 0xbd17e5ddUL, 0xc006c000UL, 0x3faeea31UL, 0x4fc93b7bUL, - 0xbd0e113eUL, 0xcdddc000UL, 0x3faccb73UL, 0x47d82807UL, 0xbd1a68f2UL, - 0xd0fb0000UL, 0x3faaaef2UL, 0x353bb42eUL, 0x3d20fc1aUL, 0x149fc000UL, - 0x3fa894aaUL, 0xd05a267dUL, 0xbd197995UL, 0xf2d4c000UL, 0x3fa67c94UL, - 0xec19afa2UL, 0xbd029efbUL, 0xd42e0000UL, 0x3fa466aeUL, 0x75bdfd28UL, - 0xbd2c1673UL, 0x2f8d0000UL, 0x3fa252f3UL, 0xe021b67bUL, 0x3d283e9aUL, - 0x89e74000UL, 0x3fa0415dUL, 0x5cf1d753UL, 0x3d0111c0UL, 0xec148000UL, - 0x3f9c63d2UL, 0x3f9eb2f3UL, 0x3d2578c6UL, 0x28c90000UL, 0x3f984925UL, - 0x325a0c34UL, 0xbd2aa0baUL, 0x25980000UL, 0x3f9432a9UL, 0x928637feUL, - 0x3d098139UL, 0x58938000UL, 0x3f902056UL, 0x06e2f7d2UL, 0xbd23dc5bUL, - 0xa3890000UL, 0x3f882448UL, 0xda74f640UL, 0xbd275577UL, 0x75890000UL, - 0x3f801015UL, 0x999d2be8UL, 0xbd10c76bUL, 0x59580000UL, 0x3f700805UL, - 0xcb31c67bUL, 0x3d2166afUL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x80000000UL, 0xfefa3800UL, 0x3fa62e42UL, 0x93c76730UL, 0x3ceef357UL, - 0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL, 0x3d6fb175UL, - 0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL, 0x9999999aUL, 0x3fc99999UL, - 0x00000000UL, 0xbfe00000UL, 0x00000000UL, 0xffffe000UL, 0x00000000UL, - 0xffffe000UL -}; -//registers, -// input: xmm0 -// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 -// rax, rdx, rcx, rbx (tmp) - -void MacroAssembler::fast_log(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) { - Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; - Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; - Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2; - Label L_2TAG_PACKET_10_0_2, start; - - assert_different_registers(tmp, eax, ecx, edx); - jmp(start); - address static_const_table = (address)_static_const_table_log; - - bind(start); - subl(rsp, 104); - movl(Address(rsp, 40), tmp); - lea(tmp, ExternalAddress(static_const_table)); - xorpd(xmm2, xmm2); - movl(eax, 16368); - pinsrw(xmm2, eax, 3); - xorpd(xmm3, xmm3); - movl(edx, 30704); - pinsrw(xmm3, edx, 3); - movsd(xmm0, Address(rsp, 112)); - movapd(xmm1, xmm0); - movl(ecx, 32768); - movdl(xmm4, ecx); - movsd(xmm5, Address(tmp, 2128)); // 0x00000000UL, 0xffffe000UL - pextrw(eax, xmm0, 3); - por(xmm0, xmm2); - psllq(xmm0, 5); - movl(ecx, 16352); - psrlq(xmm0, 34); - rcpss(xmm0, xmm0); - psllq(xmm1, 12); - pshufd(xmm6, xmm5, 228); - psrlq(xmm1, 12); - subl(eax, 16); - cmpl(eax, 32736); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); - - bind(L_2TAG_PACKET_1_0_2); - paddd(xmm0, xmm4); - por(xmm1, xmm3); - movdl(edx, xmm0); - psllq(xmm0, 29); - pand(xmm5, xmm1); - pand(xmm0, xmm6); - subsd(xmm1, xmm5); - mulpd(xmm5, xmm0); - andl(eax, 32752); - subl(eax, ecx); - cvtsi2sdl(xmm7, eax); - mulsd(xmm1, xmm0); - movsd(xmm6, Address(tmp, 2064)); // 0xfefa3800UL, 0x3fa62e42UL - movdqu(xmm3, Address(tmp, 2080)); // 0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL - subsd(xmm5, xmm2); - andl(edx, 16711680); - shrl(edx, 12); - movdqu(xmm0, Address(tmp, edx)); - movdqu(xmm4, Address(tmp, 2096)); // 0x3d6fb175UL, 0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL - addsd(xmm1, xmm5); - movdqu(xmm2, Address(tmp, 2112)); // 0x9999999aUL, 0x3fc99999UL, 0x00000000UL, 0xbfe00000UL - mulsd(xmm6, xmm7); - pshufd(xmm5, xmm1, 68); - mulsd(xmm7, Address(tmp, 2072)); // 0x93c76730UL, 0x3ceef357UL, 0x92492492UL, 0x3fc24924UL - mulsd(xmm3, xmm1); - addsd(xmm0, xmm6); - mulpd(xmm4, xmm5); - mulpd(xmm5, xmm5); - pshufd(xmm6, xmm0, 228); - addsd(xmm0, xmm1); - addpd(xmm4, xmm2); - mulpd(xmm3, xmm5); - subsd(xmm6, xmm0); - mulsd(xmm4, xmm1); - pshufd(xmm2, xmm0, 238); - addsd(xmm1, xmm6); - mulsd(xmm5, xmm5); - addsd(xmm7, xmm2); - addpd(xmm4, xmm3); - addsd(xmm1, xmm7); - mulpd(xmm4, xmm5); - addsd(xmm1, xmm4); - pshufd(xmm5, xmm4, 238); - addsd(xmm1, xmm5); - addsd(xmm0, xmm1); - jmp(L_2TAG_PACKET_2_0_2); - - bind(L_2TAG_PACKET_0_0_2); - movsd(xmm0, Address(rsp, 112)); - movdqu(xmm1, xmm0); - addl(eax, 16); - cmpl(eax, 32768); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_3_0_2); - cmpl(eax, 16); - jcc(Assembler::below, L_2TAG_PACKET_4_0_2); - - bind(L_2TAG_PACKET_5_0_2); - addsd(xmm0, xmm0); - jmp(L_2TAG_PACKET_2_0_2); - - bind(L_2TAG_PACKET_6_0_2); - jcc(Assembler::above, L_2TAG_PACKET_5_0_2); - cmpl(edx, 0); - jcc(Assembler::above, L_2TAG_PACKET_5_0_2); - jmp(L_2TAG_PACKET_7_0_2); - - bind(L_2TAG_PACKET_3_0_2); - movdl(edx, xmm1); - psrlq(xmm1, 32); - movdl(ecx, xmm1); - addl(ecx, ecx); - cmpl(ecx, -2097152); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_6_0_2); - orl(edx, ecx); - cmpl(edx, 0); - jcc(Assembler::equal, L_2TAG_PACKET_8_0_2); - - bind(L_2TAG_PACKET_7_0_2); - xorpd(xmm1, xmm1); - xorpd(xmm0, xmm0); - movl(eax, 32752); - pinsrw(xmm1, eax, 3); - movl(edx, 3); - mulsd(xmm0, xmm1); - - bind(L_2TAG_PACKET_9_0_2); - movsd(Address(rsp, 0), xmm0); - movsd(xmm0, Address(rsp, 112)); - fld_d(Address(rsp, 0)); - jmp(L_2TAG_PACKET_10_0_2); - - bind(L_2TAG_PACKET_8_0_2); - xorpd(xmm1, xmm1); - xorpd(xmm0, xmm0); - movl(eax, 49136); - pinsrw(xmm0, eax, 3); - divsd(xmm0, xmm1); - movl(edx, 2); - jmp(L_2TAG_PACKET_9_0_2); - - bind(L_2TAG_PACKET_4_0_2); - movdl(edx, xmm1); - psrlq(xmm1, 32); - movdl(ecx, xmm1); - orl(edx, ecx); - cmpl(edx, 0); - jcc(Assembler::equal, L_2TAG_PACKET_8_0_2); - xorpd(xmm1, xmm1); - movl(eax, 18416); - pinsrw(xmm1, eax, 3); - mulsd(xmm0, xmm1); - movapd(xmm1, xmm0); - pextrw(eax, xmm0, 3); - por(xmm0, xmm2); - psllq(xmm0, 5); - movl(ecx, 18416); - psrlq(xmm0, 34); - rcpss(xmm0, xmm0); - psllq(xmm1, 12); - pshufd(xmm6, xmm5, 228); - psrlq(xmm1, 12); - jmp(L_2TAG_PACKET_1_0_2); - - bind(L_2TAG_PACKET_2_0_2); - movsd(Address(rsp, 24), xmm0); - fld_d(Address(rsp, 24)); - - bind(L_2TAG_PACKET_10_0_2); - movl(tmp, Address(rsp, 40)); -} - -/******************************************************************************/ -// ALGORITHM DESCRIPTION - POW() -// --------------------- -// -// Let x=2^k * mx, mx in [1,2) -// -// log2(x) calculation: -// -// Get B~1/mx based on the output of rcpps instruction (B0) -// B = int((B0*LH*2^9+0.5))/2^9 -// LH is a short approximation for log2(e) -// -// Reduced argument, scaled by LH: -// r=B*mx-LH (computed accurately in high and low parts) -// -// log2(x) result: k - log2(B) + p(r) -// p(r) is a degree 8 polynomial -// -log2(B) read from data table (high, low parts) -// log2(x) is formed from high and low parts -// For |x| in [1-1/32, 1+1/16), a slower but more accurate computation -// based om the same table design is performed. -// -// Main path is taken if | floor(log2(|log2(|x|)|) + floor(log2|y|) | < 8, -// to filter out all potential OF/UF cases. -// exp2(y*log2(x)) is computed using an 8-bit index table and a degree 5 -// polynomial -// -// Special cases: -// pow(-0,y) = -INF and raises the divide-by-zero exception for y an odd -// integer < 0. -// pow(-0,y) = +INF and raises the divide-by-zero exception for y < 0 and -// not an odd integer. -// pow(-0,y) = -0 for y an odd integer > 0. -// pow(-0,y) = +0 for y > 0 and not an odd integer. -// pow(-1,-INF) = NaN. -// pow(+1,y) = NaN for any y, even a NaN. -// pow(x,-0) = 1 for any x, even a NaN. -// pow(x,y) = a NaN and raises the invalid exception for finite x < 0 and -// finite non-integer y. -// pow(x,-INF) = +INF for |x|<1. -// pow(x,-INF) = +0 for |x|>1. -// pow(x,+INF) = +0 for |x|<1. -// pow(x,+INF) = +INF for |x|>1. -// pow(-INF,y) = -0 for y an odd integer < 0. -// pow(-INF,y) = +0 for y < 0 and not an odd integer. -// pow(-INF,y) = -INF for y an odd integer > 0. -// pow(-INF,y) = +INF for y > 0 and not an odd integer. -// pow(+INF,y) = +0 for y <0. -// pow(+INF,y) = +INF for y >0. -// -/******************************************************************************/ - -ALIGNED_(16) juint _static_const_table_pow[] = -{ - 0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL, 0xf8000000UL, - 0xffffffffUL, 0x00000000UL, 0xfffff800UL, 0x00000000UL, 0x3ff00000UL, - 0x00000000UL, 0x00000000UL, 0x20000000UL, 0x3feff00aUL, 0x96621f95UL, - 0x3e5b1856UL, 0xe0000000UL, 0x3fefe019UL, 0xe5916f9eUL, 0xbe325278UL, - 0x00000000UL, 0x3fefd02fUL, 0x859a1062UL, 0x3e595fb7UL, 0xc0000000UL, - 0x3fefc049UL, 0xb245f18fUL, 0xbe529c38UL, 0xe0000000UL, 0x3fefb069UL, - 0xad2880a7UL, 0xbe501230UL, 0x60000000UL, 0x3fefa08fUL, 0xc8e72420UL, - 0x3e597bd1UL, 0x80000000UL, 0x3fef90baUL, 0xc30c4500UL, 0xbe5d6c75UL, - 0xe0000000UL, 0x3fef80eaUL, 0x02c63f43UL, 0x3e2e1318UL, 0xc0000000UL, - 0x3fef7120UL, 0xb3d4ccccUL, 0xbe44c52aUL, 0x00000000UL, 0x3fef615cUL, - 0xdbd91397UL, 0xbe4e7d6cUL, 0xa0000000UL, 0x3fef519cUL, 0x65c5cd68UL, - 0xbe522dc8UL, 0xa0000000UL, 0x3fef41e2UL, 0x46d1306cUL, 0xbe5a840eUL, - 0xe0000000UL, 0x3fef322dUL, 0xd2980e94UL, 0x3e5071afUL, 0xa0000000UL, - 0x3fef227eUL, 0x773abadeUL, 0xbe5891e5UL, 0xa0000000UL, 0x3fef12d4UL, - 0xdc6bf46bUL, 0xbe5cccbeUL, 0xe0000000UL, 0x3fef032fUL, 0xbc7247faUL, - 0xbe2bab83UL, 0x80000000UL, 0x3feef390UL, 0xbcaa1e46UL, 0xbe53bb3bUL, - 0x60000000UL, 0x3feee3f6UL, 0x5f6c682dUL, 0xbe54c619UL, 0x80000000UL, - 0x3feed461UL, 0x5141e368UL, 0xbe4b6d86UL, 0xe0000000UL, 0x3feec4d1UL, - 0xec678f76UL, 0xbe369af6UL, 0x80000000UL, 0x3feeb547UL, 0x41301f55UL, - 0xbe2d4312UL, 0x60000000UL, 0x3feea5c2UL, 0x676da6bdUL, 0xbe4d8dd0UL, - 0x60000000UL, 0x3fee9642UL, 0x57a891c4UL, 0x3e51f991UL, 0xa0000000UL, - 0x3fee86c7UL, 0xe4eb491eUL, 0x3e579bf9UL, 0x20000000UL, 0x3fee7752UL, - 0xfddc4a2cUL, 0xbe3356e6UL, 0xc0000000UL, 0x3fee67e1UL, 0xd75b5bf1UL, - 0xbe449531UL, 0x80000000UL, 0x3fee5876UL, 0xbd423b8eUL, 0x3df54fe4UL, - 0x60000000UL, 0x3fee4910UL, 0x330e51b9UL, 0x3e54289cUL, 0x80000000UL, - 0x3fee39afUL, 0x8651a95fUL, 0xbe55aad6UL, 0xa0000000UL, 0x3fee2a53UL, - 0x5e98c708UL, 0xbe2fc4a9UL, 0xe0000000UL, 0x3fee1afcUL, 0x0989328dUL, - 0x3e23958cUL, 0x40000000UL, 0x3fee0babUL, 0xee642abdUL, 0xbe425dd8UL, - 0xa0000000UL, 0x3fedfc5eUL, 0xc394d236UL, 0x3e526362UL, 0x20000000UL, - 0x3feded17UL, 0xe104aa8eUL, 0x3e4ce247UL, 0xc0000000UL, 0x3fedddd4UL, - 0x265a9be4UL, 0xbe5bb77aUL, 0x40000000UL, 0x3fedce97UL, 0x0ecac52fUL, - 0x3e4a7cb1UL, 0xe0000000UL, 0x3fedbf5eUL, 0x124cb3b8UL, 0x3e257024UL, - 0x80000000UL, 0x3fedb02bUL, 0xe6d4febeUL, 0xbe2033eeUL, 0x20000000UL, - 0x3feda0fdUL, 0x39cca00eUL, 0xbe3ddabcUL, 0xc0000000UL, 0x3fed91d3UL, - 0xef8a552aUL, 0xbe543390UL, 0x40000000UL, 0x3fed82afUL, 0xb8e85204UL, - 0x3e513850UL, 0xe0000000UL, 0x3fed738fUL, 0x3d59fe08UL, 0xbe5db728UL, - 0x40000000UL, 0x3fed6475UL, 0x3aa7ead1UL, 0x3e58804bUL, 0xc0000000UL, - 0x3fed555fUL, 0xf8a35ba9UL, 0xbe5298b0UL, 0x00000000UL, 0x3fed464fUL, - 0x9a88dd15UL, 0x3e5a8cdbUL, 0x40000000UL, 0x3fed3743UL, 0xb0b0a190UL, - 0x3e598635UL, 0x80000000UL, 0x3fed283cUL, 0xe2113295UL, 0xbe5c1119UL, - 0x80000000UL, 0x3fed193aUL, 0xafbf1728UL, 0xbe492e9cUL, 0x60000000UL, - 0x3fed0a3dUL, 0xe4a4ccf3UL, 0x3e19b90eUL, 0x20000000UL, 0x3fecfb45UL, - 0xba3cbeb8UL, 0x3e406b50UL, 0xc0000000UL, 0x3fecec51UL, 0x110f7dddUL, - 0x3e0d6806UL, 0x40000000UL, 0x3fecdd63UL, 0x7dd7d508UL, 0xbe5a8943UL, - 0x80000000UL, 0x3fecce79UL, 0x9b60f271UL, 0xbe50676aUL, 0x80000000UL, - 0x3fecbf94UL, 0x0b9ad660UL, 0x3e59174fUL, 0x60000000UL, 0x3fecb0b4UL, - 0x00823d9cUL, 0x3e5bbf72UL, 0x20000000UL, 0x3feca1d9UL, 0x38a6ec89UL, - 0xbe4d38f9UL, 0x80000000UL, 0x3fec9302UL, 0x3a0b7d8eUL, 0x3e53dbfdUL, - 0xc0000000UL, 0x3fec8430UL, 0xc6826b34UL, 0xbe27c5c9UL, 0xc0000000UL, - 0x3fec7563UL, 0x0c706381UL, 0xbe593653UL, 0x60000000UL, 0x3fec669bUL, - 0x7df34ec7UL, 0x3e461ab5UL, 0xe0000000UL, 0x3fec57d7UL, 0x40e5e7e8UL, - 0xbe5c3daeUL, 0x00000000UL, 0x3fec4919UL, 0x5602770fUL, 0xbe55219dUL, - 0xc0000000UL, 0x3fec3a5eUL, 0xec7911ebUL, 0x3e5a5d25UL, 0x60000000UL, - 0x3fec2ba9UL, 0xb39ea225UL, 0xbe53c00bUL, 0x80000000UL, 0x3fec1cf8UL, - 0x967a212eUL, 0x3e5a8ddfUL, 0x60000000UL, 0x3fec0e4cUL, 0x580798bdUL, - 0x3e5f53abUL, 0x00000000UL, 0x3febffa5UL, 0xb8282df6UL, 0xbe46b874UL, - 0x20000000UL, 0x3febf102UL, 0xe33a6729UL, 0x3e54963fUL, 0x00000000UL, - 0x3febe264UL, 0x3b53e88aUL, 0xbe3adce1UL, 0x60000000UL, 0x3febd3caUL, - 0xc2585084UL, 0x3e5cde9fUL, 0x80000000UL, 0x3febc535UL, 0xa335c5eeUL, - 0xbe39fd9cUL, 0x20000000UL, 0x3febb6a5UL, 0x7325b04dUL, 0x3e42ba15UL, - 0x60000000UL, 0x3feba819UL, 0x1564540fUL, 0x3e3a9f35UL, 0x40000000UL, - 0x3feb9992UL, 0x83fff592UL, 0xbe5465ceUL, 0xa0000000UL, 0x3feb8b0fUL, - 0xb9da63d3UL, 0xbe4b1a0aUL, 0x80000000UL, 0x3feb7c91UL, 0x6d6f1ea4UL, - 0x3e557657UL, 0x00000000UL, 0x3feb6e18UL, 0x5e80a1bfUL, 0x3e4ddbb6UL, - 0x00000000UL, 0x3feb5fa3UL, 0x1c9eacb5UL, 0x3e592877UL, 0xa0000000UL, - 0x3feb5132UL, 0x6d40beb3UL, 0xbe51858cUL, 0xa0000000UL, 0x3feb42c6UL, - 0xd740c67bUL, 0x3e427ad2UL, 0x40000000UL, 0x3feb345fUL, 0xa3e0cceeUL, - 0xbe5c2fc4UL, 0x40000000UL, 0x3feb25fcUL, 0x8e752b50UL, 0xbe3da3c2UL, - 0xc0000000UL, 0x3feb179dUL, 0xa892e7deUL, 0x3e1fb481UL, 0xc0000000UL, - 0x3feb0943UL, 0x21ed71e9UL, 0xbe365206UL, 0x20000000UL, 0x3feafaeeUL, - 0x0e1380a3UL, 0x3e5c5b7bUL, 0x20000000UL, 0x3feaec9dUL, 0x3c3d640eUL, - 0xbe5dbbd0UL, 0x60000000UL, 0x3feade50UL, 0x8f97a715UL, 0x3e3a8ec5UL, - 0x20000000UL, 0x3fead008UL, 0x23ab2839UL, 0x3e2fe98aUL, 0x40000000UL, - 0x3feac1c4UL, 0xf4bbd50fUL, 0x3e54d8f6UL, 0xe0000000UL, 0x3feab384UL, - 0x14757c4dUL, 0xbe48774cUL, 0xc0000000UL, 0x3feaa549UL, 0x7c7b0eeaUL, - 0x3e5b51bbUL, 0x20000000UL, 0x3fea9713UL, 0xf56f7013UL, 0x3e386200UL, - 0xe0000000UL, 0x3fea88e0UL, 0xbe428ebeUL, 0xbe514af5UL, 0xe0000000UL, - 0x3fea7ab2UL, 0x8d0e4496UL, 0x3e4f9165UL, 0x60000000UL, 0x3fea6c89UL, - 0xdbacc5d5UL, 0xbe5c063bUL, 0x20000000UL, 0x3fea5e64UL, 0x3f19d970UL, - 0xbe5a0c8cUL, 0x20000000UL, 0x3fea5043UL, 0x09ea3e6bUL, 0x3e5065dcUL, - 0x80000000UL, 0x3fea4226UL, 0x78df246cUL, 0x3e5e05f6UL, 0x40000000UL, - 0x3fea340eUL, 0x4057d4a0UL, 0x3e431b2bUL, 0x40000000UL, 0x3fea25faUL, - 0x82867bb5UL, 0x3e4b76beUL, 0xa0000000UL, 0x3fea17eaUL, 0x9436f40aUL, - 0xbe5aad39UL, 0x20000000UL, 0x3fea09dfUL, 0x4b5253b3UL, 0x3e46380bUL, - 0x00000000UL, 0x3fe9fbd8UL, 0x8fc52466UL, 0xbe386f9bUL, 0x20000000UL, - 0x3fe9edd5UL, 0x22d3f344UL, 0xbe538347UL, 0x60000000UL, 0x3fe9dfd6UL, - 0x1ac33522UL, 0x3e5dbc53UL, 0x00000000UL, 0x3fe9d1dcUL, 0xeabdff1dUL, - 0x3e40fc0cUL, 0xe0000000UL, 0x3fe9c3e5UL, 0xafd30e73UL, 0xbe585e63UL, - 0xe0000000UL, 0x3fe9b5f3UL, 0xa52f226aUL, 0xbe43e8f9UL, 0x20000000UL, - 0x3fe9a806UL, 0xecb8698dUL, 0xbe515b36UL, 0x80000000UL, 0x3fe99a1cUL, - 0xf2b4e89dUL, 0x3e48b62bUL, 0x20000000UL, 0x3fe98c37UL, 0x7c9a88fbUL, - 0x3e44414cUL, 0x00000000UL, 0x3fe97e56UL, 0xda015741UL, 0xbe5d13baUL, - 0xe0000000UL, 0x3fe97078UL, 0x5fdace06UL, 0x3e51b947UL, 0x00000000UL, - 0x3fe962a0UL, 0x956ca094UL, 0x3e518785UL, 0x40000000UL, 0x3fe954cbUL, - 0x01164c1dUL, 0x3e5d5b57UL, 0xc0000000UL, 0x3fe946faUL, 0xe63b3767UL, - 0xbe4f84e7UL, 0x40000000UL, 0x3fe9392eUL, 0xe57cc2a9UL, 0x3e34eda3UL, - 0xe0000000UL, 0x3fe92b65UL, 0x8c75b544UL, 0x3e5766a0UL, 0xc0000000UL, - 0x3fe91da1UL, 0x37d1d087UL, 0xbe5e2ab1UL, 0x80000000UL, 0x3fe90fe1UL, - 0xa953dc20UL, 0x3e5fa1f3UL, 0x80000000UL, 0x3fe90225UL, 0xdbd3f369UL, - 0x3e47d6dbUL, 0xa0000000UL, 0x3fe8f46dUL, 0x1c9be989UL, 0xbe5e2b0aUL, - 0xa0000000UL, 0x3fe8e6b9UL, 0x3c93d76aUL, 0x3e5c8618UL, 0xe0000000UL, - 0x3fe8d909UL, 0x2182fc9aUL, 0xbe41aa9eUL, 0x20000000UL, 0x3fe8cb5eUL, - 0xe6b3539dUL, 0xbe530d19UL, 0x60000000UL, 0x3fe8bdb6UL, 0x49e58cc3UL, - 0xbe3bb374UL, 0xa0000000UL, 0x3fe8b012UL, 0xa7cfeb8fUL, 0x3e56c412UL, - 0x00000000UL, 0x3fe8a273UL, 0x8d52bc19UL, 0x3e1429b8UL, 0x60000000UL, - 0x3fe894d7UL, 0x4dc32c6cUL, 0xbe48604cUL, 0xc0000000UL, 0x3fe8873fUL, - 0x0c868e56UL, 0xbe564ee5UL, 0x00000000UL, 0x3fe879acUL, 0x56aee828UL, - 0x3e5e2fd8UL, 0x60000000UL, 0x3fe86c1cUL, 0x7ceab8ecUL, 0x3e493365UL, - 0xc0000000UL, 0x3fe85e90UL, 0x78d4dadcUL, 0xbe4f7f25UL, 0x00000000UL, - 0x3fe85109UL, 0x0ccd8280UL, 0x3e31e7a2UL, 0x40000000UL, 0x3fe84385UL, - 0x34ba4e15UL, 0x3e328077UL, 0x80000000UL, 0x3fe83605UL, 0xa670975aUL, - 0xbe53eee5UL, 0xa0000000UL, 0x3fe82889UL, 0xf61b77b2UL, 0xbe43a20aUL, - 0xa0000000UL, 0x3fe81b11UL, 0x13e6643bUL, 0x3e5e5fe5UL, 0xc0000000UL, - 0x3fe80d9dUL, 0x82cc94e8UL, 0xbe5ff1f9UL, 0xa0000000UL, 0x3fe8002dUL, - 0x8a0c9c5dUL, 0xbe42b0e7UL, 0x60000000UL, 0x3fe7f2c1UL, 0x22a16f01UL, - 0x3e5d9ea0UL, 0x20000000UL, 0x3fe7e559UL, 0xc38cd451UL, 0x3e506963UL, - 0xc0000000UL, 0x3fe7d7f4UL, 0x9902bc71UL, 0x3e4503d7UL, 0x40000000UL, - 0x3fe7ca94UL, 0xdef2a3c0UL, 0x3e3d98edUL, 0xa0000000UL, 0x3fe7bd37UL, - 0xed49abb0UL, 0x3e24c1ffUL, 0xe0000000UL, 0x3fe7afdeUL, 0xe3b0be70UL, - 0xbe40c467UL, 0x00000000UL, 0x3fe7a28aUL, 0xaf9f193cUL, 0xbe5dff6cUL, - 0xe0000000UL, 0x3fe79538UL, 0xb74cf6b6UL, 0xbe258ed0UL, 0xa0000000UL, - 0x3fe787ebUL, 0x1d9127c7UL, 0x3e345fb0UL, 0x40000000UL, 0x3fe77aa2UL, - 0x1028c21dUL, 0xbe4619bdUL, 0xa0000000UL, 0x3fe76d5cUL, 0x7cb0b5e4UL, - 0x3e40f1a2UL, 0xe0000000UL, 0x3fe7601aUL, 0x2b1bc4adUL, 0xbe32e8bbUL, - 0xe0000000UL, 0x3fe752dcUL, 0x6839f64eUL, 0x3e41f57bUL, 0xc0000000UL, - 0x3fe745a2UL, 0xc4121f7eUL, 0xbe52c40aUL, 0x60000000UL, 0x3fe7386cUL, - 0xd6852d72UL, 0xbe5c4e6bUL, 0xc0000000UL, 0x3fe72b39UL, 0x91d690f7UL, - 0xbe57f88fUL, 0xe0000000UL, 0x3fe71e0aUL, 0x627a2159UL, 0xbe4425d5UL, - 0xc0000000UL, 0x3fe710dfUL, 0x50a54033UL, 0x3e422b7eUL, 0x60000000UL, - 0x3fe703b8UL, 0x3b0b5f91UL, 0x3e5d3857UL, 0xe0000000UL, 0x3fe6f694UL, - 0x84d628a2UL, 0xbe51f090UL, 0x00000000UL, 0x3fe6e975UL, 0x306d8894UL, - 0xbe414d83UL, 0xe0000000UL, 0x3fe6dc58UL, 0x30bf24aaUL, 0xbe4650caUL, - 0x80000000UL, 0x3fe6cf40UL, 0xd4628d69UL, 0xbe5db007UL, 0xc0000000UL, - 0x3fe6c22bUL, 0xa2aae57bUL, 0xbe31d279UL, 0xc0000000UL, 0x3fe6b51aUL, - 0x860edf7eUL, 0xbe2d4c4aUL, 0x80000000UL, 0x3fe6a80dUL, 0xf3559341UL, - 0xbe5f7e98UL, 0xe0000000UL, 0x3fe69b03UL, 0xa885899eUL, 0xbe5c2011UL, - 0xe0000000UL, 0x3fe68dfdUL, 0x2bdc6d37UL, 0x3e224a82UL, 0xa0000000UL, - 0x3fe680fbUL, 0xc12ad1b9UL, 0xbe40cf56UL, 0x00000000UL, 0x3fe673fdUL, - 0x1bcdf659UL, 0xbdf52f2dUL, 0x00000000UL, 0x3fe66702UL, 0x5df10408UL, - 0x3e5663e0UL, 0xc0000000UL, 0x3fe65a0aUL, 0xa4070568UL, 0xbe40b12fUL, - 0x00000000UL, 0x3fe64d17UL, 0x71c54c47UL, 0x3e5f5e8bUL, 0x00000000UL, - 0x3fe64027UL, 0xbd4b7e83UL, 0x3e42ead6UL, 0xa0000000UL, 0x3fe6333aUL, - 0x61598bd2UL, 0xbe4c48d4UL, 0xc0000000UL, 0x3fe62651UL, 0x6f538d61UL, - 0x3e548401UL, 0xa0000000UL, 0x3fe6196cUL, 0x14344120UL, 0xbe529af6UL, - 0x00000000UL, 0x3fe60c8bUL, 0x5982c587UL, 0xbe3e1e4fUL, 0x00000000UL, - 0x3fe5ffadUL, 0xfe51d4eaUL, 0xbe4c897aUL, 0x80000000UL, 0x3fe5f2d2UL, - 0xfd46ebe1UL, 0x3e552e00UL, 0xa0000000UL, 0x3fe5e5fbUL, 0xa4695699UL, - 0x3e5ed471UL, 0x60000000UL, 0x3fe5d928UL, 0x80d118aeUL, 0x3e456b61UL, - 0xa0000000UL, 0x3fe5cc58UL, 0x304c330bUL, 0x3e54dc29UL, 0x80000000UL, - 0x3fe5bf8cUL, 0x0af2dedfUL, 0xbe3aa9bdUL, 0xe0000000UL, 0x3fe5b2c3UL, - 0x15fc9258UL, 0xbe479a37UL, 0xc0000000UL, 0x3fe5a5feUL, 0x9292c7eaUL, - 0x3e188650UL, 0x20000000UL, 0x3fe5993dUL, 0x33b4d380UL, 0x3e5d6d93UL, - 0x20000000UL, 0x3fe58c7fUL, 0x02fd16c7UL, 0x3e2fe961UL, 0xa0000000UL, - 0x3fe57fc4UL, 0x4a05edb6UL, 0xbe4d55b4UL, 0xa0000000UL, 0x3fe5730dUL, - 0x3d443abbUL, 0xbe5e6954UL, 0x00000000UL, 0x3fe5665aUL, 0x024acfeaUL, - 0x3e50e61bUL, 0x00000000UL, 0x3fe559aaUL, 0xcc9edd09UL, 0xbe325403UL, - 0x60000000UL, 0x3fe54cfdUL, 0x1fe26950UL, 0x3e5d500eUL, 0x60000000UL, - 0x3fe54054UL, 0x6c5ae164UL, 0xbe4a79b4UL, 0xc0000000UL, 0x3fe533aeUL, - 0x154b0287UL, 0xbe401571UL, 0xa0000000UL, 0x3fe5270cUL, 0x0673f401UL, - 0xbe56e56bUL, 0xe0000000UL, 0x3fe51a6dUL, 0x751b639cUL, 0x3e235269UL, - 0xa0000000UL, 0x3fe50dd2UL, 0x7c7b2bedUL, 0x3ddec887UL, 0xc0000000UL, - 0x3fe5013aUL, 0xafab4e17UL, 0x3e5e7575UL, 0x60000000UL, 0x3fe4f4a6UL, - 0x2e308668UL, 0x3e59aed6UL, 0x80000000UL, 0x3fe4e815UL, 0xf33e2a76UL, - 0xbe51f184UL, 0xe0000000UL, 0x3fe4db87UL, 0x839f3e3eUL, 0x3e57db01UL, - 0xc0000000UL, 0x3fe4cefdUL, 0xa9eda7bbUL, 0x3e535e0fUL, 0x00000000UL, - 0x3fe4c277UL, 0x2a8f66a5UL, 0x3e5ce451UL, 0xc0000000UL, 0x3fe4b5f3UL, - 0x05192456UL, 0xbe4e8518UL, 0xc0000000UL, 0x3fe4a973UL, 0x4aa7cd1dUL, - 0x3e46784aUL, 0x40000000UL, 0x3fe49cf7UL, 0x8e23025eUL, 0xbe5749f2UL, - 0x00000000UL, 0x3fe4907eUL, 0x18d30215UL, 0x3e360f39UL, 0x20000000UL, - 0x3fe48408UL, 0x63dcf2f3UL, 0x3e5e00feUL, 0xc0000000UL, 0x3fe47795UL, - 0x46182d09UL, 0xbe5173d9UL, 0xa0000000UL, 0x3fe46b26UL, 0x8f0e62aaUL, - 0xbe48f281UL, 0xe0000000UL, 0x3fe45ebaUL, 0x5775c40cUL, 0xbe56aad4UL, - 0x60000000UL, 0x3fe45252UL, 0x0fe25f69UL, 0x3e48bd71UL, 0x40000000UL, - 0x3fe445edUL, 0xe9989ec5UL, 0x3e590d97UL, 0x80000000UL, 0x3fe4398bUL, - 0xb3d9ffe3UL, 0x3e479dbcUL, 0x20000000UL, 0x3fe42d2dUL, 0x388e4d2eUL, - 0xbe5eed80UL, 0xe0000000UL, 0x3fe420d1UL, 0x6f797c18UL, 0x3e554b4cUL, - 0x20000000UL, 0x3fe4147aUL, 0x31048bb4UL, 0xbe5b1112UL, 0x80000000UL, - 0x3fe40825UL, 0x2efba4f9UL, 0x3e48ebc7UL, 0x40000000UL, 0x3fe3fbd4UL, - 0x50201119UL, 0x3e40b701UL, 0x40000000UL, 0x3fe3ef86UL, 0x0a4db32cUL, - 0x3e551de8UL, 0xa0000000UL, 0x3fe3e33bUL, 0x0c9c148bUL, 0xbe50c1f6UL, - 0x20000000UL, 0x3fe3d6f4UL, 0xc9129447UL, 0x3e533fa0UL, 0x00000000UL, - 0x3fe3cab0UL, 0xaae5b5a0UL, 0xbe22b68eUL, 0x20000000UL, 0x3fe3be6fUL, - 0x02305e8aUL, 0xbe54fc08UL, 0x60000000UL, 0x3fe3b231UL, 0x7f908258UL, - 0x3e57dc05UL, 0x00000000UL, 0x3fe3a5f7UL, 0x1a09af78UL, 0x3e08038bUL, - 0xe0000000UL, 0x3fe399bfUL, 0x490643c1UL, 0xbe5dbe42UL, 0xe0000000UL, - 0x3fe38d8bUL, 0x5e8ad724UL, 0xbe3c2b72UL, 0x20000000UL, 0x3fe3815bUL, - 0xc67196b6UL, 0x3e1713cfUL, 0xa0000000UL, 0x3fe3752dUL, 0x6182e429UL, - 0xbe3ec14cUL, 0x40000000UL, 0x3fe36903UL, 0xab6eb1aeUL, 0x3e5a2cc5UL, - 0x40000000UL, 0x3fe35cdcUL, 0xfe5dc064UL, 0xbe5c5878UL, 0x40000000UL, - 0x3fe350b8UL, 0x0ba6b9e4UL, 0x3e51619bUL, 0x80000000UL, 0x3fe34497UL, - 0x857761aaUL, 0x3e5fff53UL, 0x00000000UL, 0x3fe3387aUL, 0xf872d68cUL, - 0x3e484f4dUL, 0xa0000000UL, 0x3fe32c5fUL, 0x087e97c2UL, 0x3e52842eUL, - 0x80000000UL, 0x3fe32048UL, 0x73d6d0c0UL, 0xbe503edfUL, 0x80000000UL, - 0x3fe31434UL, 0x0c1456a1UL, 0xbe5f72adUL, 0xa0000000UL, 0x3fe30823UL, - 0x83a1a4d5UL, 0xbe5e65ccUL, 0xe0000000UL, 0x3fe2fc15UL, 0x855a7390UL, - 0xbe506438UL, 0x40000000UL, 0x3fe2f00bUL, 0xa2898287UL, 0x3e3d22a2UL, - 0xe0000000UL, 0x3fe2e403UL, 0x8b56f66fUL, 0xbe5aa5fdUL, 0x80000000UL, - 0x3fe2d7ffUL, 0x52db119aUL, 0x3e3a2e3dUL, 0x60000000UL, 0x3fe2cbfeUL, - 0xe2ddd4c0UL, 0xbe586469UL, 0x40000000UL, 0x3fe2c000UL, 0x6b01bf10UL, - 0x3e352b9dUL, 0x40000000UL, 0x3fe2b405UL, 0xb07a1cdfUL, 0x3e5c5cdaUL, - 0x80000000UL, 0x3fe2a80dUL, 0xc7b5f868UL, 0xbe5668b3UL, 0xc0000000UL, - 0x3fe29c18UL, 0x185edf62UL, 0xbe563d66UL, 0x00000000UL, 0x3fe29027UL, - 0xf729e1ccUL, 0x3e59a9a0UL, 0x80000000UL, 0x3fe28438UL, 0x6433c727UL, - 0xbe43cc89UL, 0x00000000UL, 0x3fe2784dUL, 0x41782631UL, 0xbe30750cUL, - 0xa0000000UL, 0x3fe26c64UL, 0x914911b7UL, 0xbe58290eUL, 0x40000000UL, - 0x3fe2607fUL, 0x3dcc73e1UL, 0xbe4269cdUL, 0x00000000UL, 0x3fe2549dUL, - 0x2751bf70UL, 0xbe5a6998UL, 0xc0000000UL, 0x3fe248bdUL, 0x4248b9fbUL, - 0xbe4ddb00UL, 0x80000000UL, 0x3fe23ce1UL, 0xf35cf82fUL, 0x3e561b71UL, - 0x60000000UL, 0x3fe23108UL, 0x8e481a2dUL, 0x3e518fb9UL, 0x60000000UL, - 0x3fe22532UL, 0x5ab96edcUL, 0xbe5fafc5UL, 0x40000000UL, 0x3fe2195fUL, - 0x80943911UL, 0xbe07f819UL, 0x40000000UL, 0x3fe20d8fUL, 0x386f2d6cUL, - 0xbe54ba8bUL, 0x40000000UL, 0x3fe201c2UL, 0xf29664acUL, 0xbe5eb815UL, - 0x20000000UL, 0x3fe1f5f8UL, 0x64f03390UL, 0x3e5e320cUL, 0x20000000UL, - 0x3fe1ea31UL, 0x747ff696UL, 0x3e5ef0a5UL, 0x40000000UL, 0x3fe1de6dUL, - 0x3e9ceb51UL, 0xbe5f8d27UL, 0x20000000UL, 0x3fe1d2acUL, 0x4ae0b55eUL, - 0x3e5faa21UL, 0x20000000UL, 0x3fe1c6eeUL, 0x28569a5eUL, 0x3e598a4fUL, - 0x20000000UL, 0x3fe1bb33UL, 0x54b33e07UL, 0x3e46130aUL, 0x20000000UL, - 0x3fe1af7bUL, 0x024f1078UL, 0xbe4dbf93UL, 0x00000000UL, 0x3fe1a3c6UL, - 0xb0783bfaUL, 0x3e419248UL, 0xe0000000UL, 0x3fe19813UL, 0x2f02b836UL, - 0x3e4e02b7UL, 0xc0000000UL, 0x3fe18c64UL, 0x28dec9d4UL, 0x3e09064fUL, - 0x80000000UL, 0x3fe180b8UL, 0x45cbf406UL, 0x3e5b1f46UL, 0x40000000UL, - 0x3fe1750fUL, 0x03d9964cUL, 0x3e5b0a79UL, 0x00000000UL, 0x3fe16969UL, - 0x8b5b882bUL, 0xbe238086UL, 0xa0000000UL, 0x3fe15dc5UL, 0x73bad6f8UL, - 0xbdf1fca4UL, 0x20000000UL, 0x3fe15225UL, 0x5385769cUL, 0x3e5e8d76UL, - 0xa0000000UL, 0x3fe14687UL, 0x1676dc6bUL, 0x3e571d08UL, 0x20000000UL, - 0x3fe13aedUL, 0xa8c41c7fUL, 0xbe598a25UL, 0x60000000UL, 0x3fe12f55UL, - 0xc4e1aaf0UL, 0x3e435277UL, 0xa0000000UL, 0x3fe123c0UL, 0x403638e1UL, - 0xbe21aa7cUL, 0xc0000000UL, 0x3fe1182eUL, 0x557a092bUL, 0xbdd0116bUL, - 0xc0000000UL, 0x3fe10c9fUL, 0x7d779f66UL, 0x3e4a61baUL, 0xc0000000UL, - 0x3fe10113UL, 0x2b09c645UL, 0xbe5d586eUL, 0x20000000UL, 0x3fe0ea04UL, - 0xea2cad46UL, 0x3e5aa97cUL, 0x20000000UL, 0x3fe0d300UL, 0x23190e54UL, - 0x3e50f1a7UL, 0xa0000000UL, 0x3fe0bc07UL, 0x1379a5a6UL, 0xbe51619dUL, - 0x60000000UL, 0x3fe0a51aUL, 0x926a3d4aUL, 0x3e5cf019UL, 0xa0000000UL, - 0x3fe08e38UL, 0xa8c24358UL, 0x3e35241eUL, 0x20000000UL, 0x3fe07762UL, - 0x24317e7aUL, 0x3e512cfaUL, 0x00000000UL, 0x3fe06097UL, 0xfd9cf274UL, - 0xbe55bef3UL, 0x00000000UL, 0x3fe049d7UL, 0x3689b49dUL, 0xbe36d26dUL, - 0x40000000UL, 0x3fe03322UL, 0xf72ef6c4UL, 0xbe54cd08UL, 0xa0000000UL, - 0x3fe01c78UL, 0x23702d2dUL, 0xbe5900bfUL, 0x00000000UL, 0x3fe005daUL, - 0x3f59c14cUL, 0x3e57d80bUL, 0x40000000UL, 0x3fdfde8dUL, 0xad67766dUL, - 0xbe57fad4UL, 0x40000000UL, 0x3fdfb17cUL, 0x644f4ae7UL, 0x3e1ee43bUL, - 0x40000000UL, 0x3fdf8481UL, 0x903234d2UL, 0x3e501a86UL, 0x40000000UL, - 0x3fdf579cUL, 0xafe9e509UL, 0xbe267c3eUL, 0x00000000UL, 0x3fdf2acdUL, - 0xb7dfda0bUL, 0xbe48149bUL, 0x40000000UL, 0x3fdefe13UL, 0x3b94305eUL, - 0x3e5f4ea7UL, 0x80000000UL, 0x3fded16fUL, 0x5d95da61UL, 0xbe55c198UL, - 0x00000000UL, 0x3fdea4e1UL, 0x406960c9UL, 0xbdd99a19UL, 0x00000000UL, - 0x3fde7868UL, 0xd22f3539UL, 0x3e470c78UL, 0x80000000UL, 0x3fde4c04UL, - 0x83eec535UL, 0xbe3e1232UL, 0x40000000UL, 0x3fde1fb6UL, 0x3dfbffcbUL, - 0xbe4b7d71UL, 0x40000000UL, 0x3fddf37dUL, 0x7e1be4e0UL, 0xbe5b8f8fUL, - 0x40000000UL, 0x3fddc759UL, 0x46dae887UL, 0xbe350458UL, 0x80000000UL, - 0x3fdd9b4aUL, 0xed6ecc49UL, 0xbe5f0045UL, 0x80000000UL, 0x3fdd6f50UL, - 0x2e9e883cUL, 0x3e2915daUL, 0x80000000UL, 0x3fdd436bUL, 0xf0bccb32UL, - 0x3e4a68c9UL, 0x80000000UL, 0x3fdd179bUL, 0x9bbfc779UL, 0xbe54a26aUL, - 0x00000000UL, 0x3fdcebe0UL, 0x7cea33abUL, 0x3e43c6b7UL, 0x40000000UL, - 0x3fdcc039UL, 0xe740fd06UL, 0x3e5526c2UL, 0x40000000UL, 0x3fdc94a7UL, - 0x9eadeb1aUL, 0xbe396d8dUL, 0xc0000000UL, 0x3fdc6929UL, 0xf0a8f95aUL, - 0xbe5c0ab2UL, 0x80000000UL, 0x3fdc3dc0UL, 0x6ee2693bUL, 0x3e0992e6UL, - 0xc0000000UL, 0x3fdc126bUL, 0x5ac6b581UL, 0xbe2834b6UL, 0x40000000UL, - 0x3fdbe72bUL, 0x8cc226ffUL, 0x3e3596a6UL, 0x00000000UL, 0x3fdbbbffUL, - 0xf92a74bbUL, 0x3e3c5813UL, 0x00000000UL, 0x3fdb90e7UL, 0x479664c0UL, - 0xbe50d644UL, 0x00000000UL, 0x3fdb65e3UL, 0x5004975bUL, 0xbe55258fUL, - 0x00000000UL, 0x3fdb3af3UL, 0xe4b23194UL, 0xbe588407UL, 0xc0000000UL, - 0x3fdb1016UL, 0xe65d4d0aUL, 0x3e527c26UL, 0x80000000UL, 0x3fdae54eUL, - 0x814fddd6UL, 0x3e5962a2UL, 0x40000000UL, 0x3fdaba9aUL, 0xe19d0913UL, - 0xbe562f4eUL, 0x80000000UL, 0x3fda8ff9UL, 0x43cfd006UL, 0xbe4cfdebUL, - 0x40000000UL, 0x3fda656cUL, 0x686f0a4eUL, 0x3e5e47a8UL, 0xc0000000UL, - 0x3fda3af2UL, 0x7200d410UL, 0x3e5e1199UL, 0xc0000000UL, 0x3fda108cUL, - 0xabd2266eUL, 0x3e5ee4d1UL, 0x40000000UL, 0x3fd9e63aUL, 0x396f8f2cUL, - 0x3e4dbffbUL, 0x00000000UL, 0x3fd9bbfbUL, 0xe32b25ddUL, 0x3e5c3a54UL, - 0x40000000UL, 0x3fd991cfUL, 0x431e4035UL, 0xbe457925UL, 0x80000000UL, - 0x3fd967b6UL, 0x7bed3dd3UL, 0x3e40c61dUL, 0x00000000UL, 0x3fd93db1UL, - 0xd7449365UL, 0x3e306419UL, 0x80000000UL, 0x3fd913beUL, 0x1746e791UL, - 0x3e56fcfcUL, 0x40000000UL, 0x3fd8e9dfUL, 0xf3a9028bUL, 0xbe5041b9UL, - 0xc0000000UL, 0x3fd8c012UL, 0x56840c50UL, 0xbe26e20aUL, 0x40000000UL, - 0x3fd89659UL, 0x19763102UL, 0xbe51f466UL, 0x80000000UL, 0x3fd86cb2UL, - 0x7032de7cUL, 0xbe4d298aUL, 0x80000000UL, 0x3fd8431eUL, 0xdeb39fabUL, - 0xbe4361ebUL, 0x40000000UL, 0x3fd8199dUL, 0x5d01cbe0UL, 0xbe5425b3UL, - 0x80000000UL, 0x3fd7f02eUL, 0x3ce99aa9UL, 0x3e146fa8UL, 0x80000000UL, - 0x3fd7c6d2UL, 0xd1a262b9UL, 0xbe5a1a69UL, 0xc0000000UL, 0x3fd79d88UL, - 0x8606c236UL, 0x3e423a08UL, 0x80000000UL, 0x3fd77451UL, 0x8fd1e1b7UL, - 0x3e5a6a63UL, 0xc0000000UL, 0x3fd74b2cUL, 0xe491456aUL, 0x3e42c1caUL, - 0x40000000UL, 0x3fd7221aUL, 0x4499a6d7UL, 0x3e36a69aUL, 0x00000000UL, - 0x3fd6f91aUL, 0x5237df94UL, 0xbe0f8f02UL, 0x00000000UL, 0x3fd6d02cUL, - 0xb6482c6eUL, 0xbe5abcf7UL, 0x00000000UL, 0x3fd6a750UL, 0x1919fd61UL, - 0xbe57ade2UL, 0x00000000UL, 0x3fd67e86UL, 0xaa7a994dUL, 0xbe3f3fbdUL, - 0x00000000UL, 0x3fd655ceUL, 0x67db014cUL, 0x3e33c550UL, 0x00000000UL, - 0x3fd62d28UL, 0xa82856b7UL, 0xbe1409d1UL, 0xc0000000UL, 0x3fd60493UL, - 0x1e6a300dUL, 0x3e55d899UL, 0x80000000UL, 0x3fd5dc11UL, 0x1222bd5cUL, - 0xbe35bfc0UL, 0xc0000000UL, 0x3fd5b3a0UL, 0x6e8dc2d3UL, 0x3e5d4d79UL, - 0x00000000UL, 0x3fd58b42UL, 0xe0e4ace6UL, 0xbe517303UL, 0x80000000UL, - 0x3fd562f4UL, 0xb306e0a8UL, 0x3e5edf0fUL, 0xc0000000UL, 0x3fd53ab8UL, - 0x6574bc54UL, 0x3e5ee859UL, 0x80000000UL, 0x3fd5128eUL, 0xea902207UL, - 0x3e5f6188UL, 0xc0000000UL, 0x3fd4ea75UL, 0x9f911d79UL, 0x3e511735UL, - 0x80000000UL, 0x3fd4c26eUL, 0xf9c77397UL, 0xbe5b1643UL, 0x40000000UL, - 0x3fd49a78UL, 0x15fc9258UL, 0x3e479a37UL, 0x80000000UL, 0x3fd47293UL, - 0xd5a04dd9UL, 0xbe426e56UL, 0xc0000000UL, 0x3fd44abfUL, 0xe04042f5UL, - 0x3e56f7c6UL, 0x40000000UL, 0x3fd422fdUL, 0x1d8bf2c8UL, 0x3e5d8810UL, - 0x00000000UL, 0x3fd3fb4cUL, 0x88a8ddeeUL, 0xbe311454UL, 0xc0000000UL, - 0x3fd3d3abUL, 0x3e3b5e47UL, 0xbe5d1b72UL, 0x40000000UL, 0x3fd3ac1cUL, - 0xc2ab5d59UL, 0x3e31b02bUL, 0xc0000000UL, 0x3fd3849dUL, 0xd4e34b9eUL, - 0x3e51cb2fUL, 0x40000000UL, 0x3fd35d30UL, 0x177204fbUL, 0xbe2b8cd7UL, - 0x80000000UL, 0x3fd335d3UL, 0xfcd38c82UL, 0xbe4356e1UL, 0x80000000UL, - 0x3fd30e87UL, 0x64f54accUL, 0xbe4e6224UL, 0x00000000UL, 0x3fd2e74cUL, - 0xaa7975d9UL, 0x3e5dc0feUL, 0x80000000UL, 0x3fd2c021UL, 0x516dab3fUL, - 0xbe50ffa3UL, 0x40000000UL, 0x3fd29907UL, 0x2bfb7313UL, 0x3e5674a2UL, - 0xc0000000UL, 0x3fd271fdUL, 0x0549fc99UL, 0x3e385d29UL, 0xc0000000UL, - 0x3fd24b04UL, 0x55b63073UL, 0xbe500c6dUL, 0x00000000UL, 0x3fd2241cUL, - 0x3f91953aUL, 0x3e389977UL, 0xc0000000UL, 0x3fd1fd43UL, 0xa1543f71UL, - 0xbe3487abUL, 0xc0000000UL, 0x3fd1d67bUL, 0x4ec8867cUL, 0x3df6a2dcUL, - 0x00000000UL, 0x3fd1afc4UL, 0x4328e3bbUL, 0x3e41d9c0UL, 0x80000000UL, - 0x3fd1891cUL, 0x2e1cda84UL, 0x3e3bdd87UL, 0x40000000UL, 0x3fd16285UL, - 0x4b5331aeUL, 0xbe53128eUL, 0x00000000UL, 0x3fd13bfeUL, 0xb9aec164UL, - 0xbe52ac98UL, 0xc0000000UL, 0x3fd11586UL, 0xd91e1316UL, 0xbe350630UL, - 0x80000000UL, 0x3fd0ef1fUL, 0x7cacc12cUL, 0x3e3f5219UL, 0x40000000UL, - 0x3fd0c8c8UL, 0xbce277b7UL, 0x3e3d30c0UL, 0x00000000UL, 0x3fd0a281UL, - 0x2a63447dUL, 0xbe541377UL, 0x80000000UL, 0x3fd07c49UL, 0xfac483b5UL, - 0xbe5772ecUL, 0xc0000000UL, 0x3fd05621UL, 0x36b8a570UL, 0xbe4fd4bdUL, - 0xc0000000UL, 0x3fd03009UL, 0xbae505f7UL, 0xbe450388UL, 0x80000000UL, - 0x3fd00a01UL, 0x3e35aeadUL, 0xbe5430fcUL, 0x80000000UL, 0x3fcfc811UL, - 0x707475acUL, 0x3e38806eUL, 0x80000000UL, 0x3fcf7c3fUL, 0xc91817fcUL, - 0xbe40cceaUL, 0x80000000UL, 0x3fcf308cUL, 0xae05d5e9UL, 0xbe4919b8UL, - 0x80000000UL, 0x3fcee4f8UL, 0xae6cc9e6UL, 0xbe530b94UL, 0x00000000UL, - 0x3fce9983UL, 0x1efe3e8eUL, 0x3e57747eUL, 0x00000000UL, 0x3fce4e2dUL, - 0xda78d9bfUL, 0xbe59a608UL, 0x00000000UL, 0x3fce02f5UL, 0x8abe2c2eUL, - 0x3e4a35adUL, 0x00000000UL, 0x3fcdb7dcUL, 0x1495450dUL, 0xbe0872ccUL, - 0x80000000UL, 0x3fcd6ce1UL, 0x86ee0ba0UL, 0xbe4f59a0UL, 0x00000000UL, - 0x3fcd2205UL, 0xe81ca888UL, 0x3e5402c3UL, 0x00000000UL, 0x3fccd747UL, - 0x3b4424b9UL, 0x3e5dfdc3UL, 0x80000000UL, 0x3fcc8ca7UL, 0xd305b56cUL, - 0x3e202da6UL, 0x00000000UL, 0x3fcc4226UL, 0x399a6910UL, 0xbe482a1cUL, - 0x80000000UL, 0x3fcbf7c2UL, 0x747f7938UL, 0xbe587372UL, 0x80000000UL, - 0x3fcbad7cUL, 0x6fc246a0UL, 0x3e50d83dUL, 0x00000000UL, 0x3fcb6355UL, - 0xee9e9be5UL, 0xbe5c35bdUL, 0x80000000UL, 0x3fcb194aUL, 0x8416c0bcUL, - 0x3e546d4fUL, 0x00000000UL, 0x3fcacf5eUL, 0x49f7f08fUL, 0x3e56da76UL, - 0x00000000UL, 0x3fca858fUL, 0x5dc30de2UL, 0x3e5f390cUL, 0x00000000UL, - 0x3fca3bdeUL, 0x950583b6UL, 0xbe5e4169UL, 0x80000000UL, 0x3fc9f249UL, - 0x33631553UL, 0x3e52aeb1UL, 0x00000000UL, 0x3fc9a8d3UL, 0xde8795a6UL, - 0xbe59a504UL, 0x00000000UL, 0x3fc95f79UL, 0x076bf41eUL, 0x3e5122feUL, - 0x80000000UL, 0x3fc9163cUL, 0x2914c8e7UL, 0x3e3dd064UL, 0x00000000UL, - 0x3fc8cd1dUL, 0x3a30eca3UL, 0xbe21b4aaUL, 0x80000000UL, 0x3fc8841aUL, - 0xb2a96650UL, 0xbe575444UL, 0x80000000UL, 0x3fc83b34UL, 0x2376c0cbUL, - 0xbe2a74c7UL, 0x80000000UL, 0x3fc7f26bUL, 0xd8a0b653UL, 0xbe5181b6UL, - 0x00000000UL, 0x3fc7a9bfUL, 0x32257882UL, 0xbe4a78b4UL, 0x00000000UL, - 0x3fc7612fUL, 0x1eee8bd9UL, 0xbe1bfe9dUL, 0x80000000UL, 0x3fc718bbUL, - 0x0c603cc4UL, 0x3e36fdc9UL, 0x80000000UL, 0x3fc6d064UL, 0x3728b8cfUL, - 0xbe1e542eUL, 0x80000000UL, 0x3fc68829UL, 0xc79a4067UL, 0x3e5c380fUL, - 0x00000000UL, 0x3fc6400bUL, 0xf69eac69UL, 0x3e550a84UL, 0x80000000UL, - 0x3fc5f808UL, 0xb7a780a4UL, 0x3e5d9224UL, 0x80000000UL, 0x3fc5b022UL, - 0xad9dfb1eUL, 0xbe55242fUL, 0x00000000UL, 0x3fc56858UL, 0x659b18beUL, - 0xbe4bfda3UL, 0x80000000UL, 0x3fc520a9UL, 0x66ee3631UL, 0xbe57d769UL, - 0x80000000UL, 0x3fc4d916UL, 0x1ec62819UL, 0x3e2427f7UL, 0x80000000UL, - 0x3fc4919fUL, 0xdec25369UL, 0xbe435431UL, 0x00000000UL, 0x3fc44a44UL, - 0xa8acfc4bUL, 0xbe3c62e8UL, 0x00000000UL, 0x3fc40304UL, 0xcf1d3eabUL, - 0xbdfba29fUL, 0x80000000UL, 0x3fc3bbdfUL, 0x79aba3eaUL, 0xbdf1b7c8UL, - 0x80000000UL, 0x3fc374d6UL, 0xb8d186daUL, 0xbe5130cfUL, 0x80000000UL, - 0x3fc32de8UL, 0x9d74f152UL, 0x3e2285b6UL, 0x00000000UL, 0x3fc2e716UL, - 0x50ae7ca9UL, 0xbe503920UL, 0x80000000UL, 0x3fc2a05eUL, 0x6caed92eUL, - 0xbe533924UL, 0x00000000UL, 0x3fc259c2UL, 0x9cb5034eUL, 0xbe510e31UL, - 0x80000000UL, 0x3fc21340UL, 0x12c4d378UL, 0xbe540b43UL, 0x80000000UL, - 0x3fc1ccd9UL, 0xcc418706UL, 0x3e59887aUL, 0x00000000UL, 0x3fc1868eUL, - 0x921f4106UL, 0xbe528e67UL, 0x80000000UL, 0x3fc1405cUL, 0x3969441eUL, - 0x3e5d8051UL, 0x00000000UL, 0x3fc0fa46UL, 0xd941ef5bUL, 0x3e5f9079UL, - 0x80000000UL, 0x3fc0b44aUL, 0x5a3e81b2UL, 0xbe567691UL, 0x00000000UL, - 0x3fc06e69UL, 0x9d66afe7UL, 0xbe4d43fbUL, 0x00000000UL, 0x3fc028a2UL, - 0x0a92a162UL, 0xbe52f394UL, 0x00000000UL, 0x3fbfc5eaUL, 0x209897e5UL, - 0x3e529e37UL, 0x00000000UL, 0x3fbf3ac5UL, 0x8458bd7bUL, 0x3e582831UL, - 0x00000000UL, 0x3fbeafd5UL, 0xb8d8b4b8UL, 0xbe486b4aUL, 0x00000000UL, - 0x3fbe2518UL, 0xe0a3b7b6UL, 0x3e5bafd2UL, 0x00000000UL, 0x3fbd9a90UL, - 0x2bf2710eUL, 0x3e383b2bUL, 0x00000000UL, 0x3fbd103cUL, 0x73eb6ab7UL, - 0xbe56d78dUL, 0x00000000UL, 0x3fbc861bUL, 0x32ceaff5UL, 0xbe32dc5aUL, - 0x00000000UL, 0x3fbbfc2eUL, 0xbee04cb7UL, 0xbe4a71a4UL, 0x00000000UL, - 0x3fbb7274UL, 0x35ae9577UL, 0x3e38142fUL, 0x00000000UL, 0x3fbae8eeUL, - 0xcbaddab4UL, 0xbe5490f0UL, 0x00000000UL, 0x3fba5f9aUL, 0x95ce1114UL, - 0x3e597c71UL, 0x00000000UL, 0x3fb9d67aUL, 0x6d7c0f78UL, 0x3e3abc2dUL, - 0x00000000UL, 0x3fb94d8dUL, 0x2841a782UL, 0xbe566cbcUL, 0x00000000UL, - 0x3fb8c4d2UL, 0x6ed429c6UL, 0xbe3cfff9UL, 0x00000000UL, 0x3fb83c4aUL, - 0xe4a49fbbUL, 0xbe552964UL, 0x00000000UL, 0x3fb7b3f4UL, 0x2193d81eUL, - 0xbe42fa72UL, 0x00000000UL, 0x3fb72bd0UL, 0xdd70c122UL, 0x3e527a8cUL, - 0x00000000UL, 0x3fb6a3dfUL, 0x03108a54UL, 0xbe450393UL, 0x00000000UL, - 0x3fb61c1fUL, 0x30ff7954UL, 0x3e565840UL, 0x00000000UL, 0x3fb59492UL, - 0xdedd460cUL, 0xbe5422b5UL, 0x00000000UL, 0x3fb50d36UL, 0x950f9f45UL, - 0xbe5313f6UL, 0x00000000UL, 0x3fb4860bUL, 0x582cdcb1UL, 0x3e506d39UL, - 0x00000000UL, 0x3fb3ff12UL, 0x7216d3a6UL, 0x3e4aa719UL, 0x00000000UL, - 0x3fb3784aUL, 0x57a423fdUL, 0x3e5a9b9fUL, 0x00000000UL, 0x3fb2f1b4UL, - 0x7a138b41UL, 0xbe50b418UL, 0x00000000UL, 0x3fb26b4eUL, 0x2fbfd7eaUL, - 0x3e23a53eUL, 0x00000000UL, 0x3fb1e519UL, 0x18913ccbUL, 0x3e465fc1UL, - 0x00000000UL, 0x3fb15f15UL, 0x7ea24e21UL, 0x3e042843UL, 0x00000000UL, - 0x3fb0d941UL, 0x7c6d9c77UL, 0x3e59f61eUL, 0x00000000UL, 0x3fb0539eUL, - 0x114efd44UL, 0x3e4ccab7UL, 0x00000000UL, 0x3faf9c56UL, 0x1777f657UL, - 0x3e552f65UL, 0x00000000UL, 0x3fae91d2UL, 0xc317b86aUL, 0xbe5a61e0UL, - 0x00000000UL, 0x3fad87acUL, 0xb7664efbUL, 0xbe41f64eUL, 0x00000000UL, - 0x3fac7de6UL, 0x5d3d03a9UL, 0x3e0807a0UL, 0x00000000UL, 0x3fab7480UL, - 0x743c38ebUL, 0xbe3726e1UL, 0x00000000UL, 0x3faa6b78UL, 0x06a253f1UL, - 0x3e5ad636UL, 0x00000000UL, 0x3fa962d0UL, 0xa35f541bUL, 0x3e5a187aUL, - 0x00000000UL, 0x3fa85a88UL, 0x4b86e446UL, 0xbe508150UL, 0x00000000UL, - 0x3fa7529cUL, 0x2589cacfUL, 0x3e52938aUL, 0x00000000UL, 0x3fa64b10UL, - 0xaf6b11f2UL, 0xbe3454cdUL, 0x00000000UL, 0x3fa543e2UL, 0x97506fefUL, - 0xbe5fdec5UL, 0x00000000UL, 0x3fa43d10UL, 0xe75f7dd9UL, 0xbe388dd3UL, - 0x00000000UL, 0x3fa3369cUL, 0xa4139632UL, 0xbdea5177UL, 0x00000000UL, - 0x3fa23086UL, 0x352d6f1eUL, 0xbe565ad6UL, 0x00000000UL, 0x3fa12accUL, - 0x77449eb7UL, 0xbe50d5c7UL, 0x00000000UL, 0x3fa0256eUL, 0x7478da78UL, - 0x3e404724UL, 0x00000000UL, 0x3f9e40dcUL, 0xf59cef7fUL, 0xbe539d0aUL, - 0x00000000UL, 0x3f9c3790UL, 0x1511d43cUL, 0x3e53c2c8UL, 0x00000000UL, - 0x3f9a2f00UL, 0x9b8bff3cUL, 0xbe43b3e1UL, 0x00000000UL, 0x3f982724UL, - 0xad1e22a5UL, 0x3e46f0bdUL, 0x00000000UL, 0x3f962000UL, 0x130d9356UL, - 0x3e475ba0UL, 0x00000000UL, 0x3f941994UL, 0x8f86f883UL, 0xbe513d0bUL, - 0x00000000UL, 0x3f9213dcUL, 0x914d0dc8UL, 0xbe534335UL, 0x00000000UL, - 0x3f900ed8UL, 0x2d73e5e7UL, 0xbe22ba75UL, 0x00000000UL, 0x3f8c1510UL, - 0xc5b7d70eUL, 0x3e599c5dUL, 0x00000000UL, 0x3f880de0UL, 0x8a27857eUL, - 0xbe3d28c8UL, 0x00000000UL, 0x3f840810UL, 0xda767328UL, 0x3e531b3dUL, - 0x00000000UL, 0x3f8003b0UL, 0x77bacaf3UL, 0xbe5f04e3UL, 0x00000000UL, - 0x3f780150UL, 0xdf4b0720UL, 0x3e5a8bffUL, 0x00000000UL, 0x3f6ffc40UL, - 0x34c48e71UL, 0xbe3fcd99UL, 0x00000000UL, 0x3f5ff6c0UL, 0x1ad218afUL, - 0xbe4c78a7UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x80000000UL, - 0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL, 0x00000000UL, - 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL, 0x6dc96112UL, 0xbf836578UL, - 0xee241472UL, 0xbf9b0301UL, 0x9f95985aUL, 0xbfb528dbUL, 0xb3841d2aUL, - 0xbfd619b6UL, 0x518775e3UL, 0x3f9004f2UL, 0xac8349bbUL, 0x3fa76c9bUL, - 0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, 0xbf5dabe1UL, 0x9f95985aUL, - 0xbfb528dbUL, 0xf8b5787dUL, 0x3ef2531eUL, 0x486ececbUL, 0x3fc4635eUL, - 0x412055ccUL, 0xbdd61bb2UL, 0x00000000UL, 0xfffffff8UL, 0x00000000UL, - 0xffffffffUL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3b700000UL, - 0xfa5abcbfUL, 0x3ff00b1aUL, 0xa7609f71UL, 0xbc84f6b2UL, 0xa9fb3335UL, - 0x3ff0163dUL, 0x9ab8cdb7UL, 0x3c9b6129UL, 0x143b0281UL, 0x3ff02168UL, - 0x0fc54eb6UL, 0xbc82bf31UL, 0x3e778061UL, 0x3ff02c9aUL, 0x535b085dUL, - 0xbc719083UL, 0x2e11bbccUL, 0x3ff037d4UL, 0xeeade11aUL, 0x3c656811UL, - 0xe86e7f85UL, 0x3ff04315UL, 0x1977c96eUL, 0xbc90a31cUL, 0x72f654b1UL, - 0x3ff04e5fUL, 0x3aa0d08cUL, 0x3c84c379UL, 0xd3158574UL, 0x3ff059b0UL, - 0xa475b465UL, 0x3c8d73e2UL, 0x0e3c1f89UL, 0x3ff0650aUL, 0x5799c397UL, - 0xbc95cb7bUL, 0x29ddf6deUL, 0x3ff0706bUL, 0xe2b13c27UL, 0xbc8c91dfUL, - 0x2b72a836UL, 0x3ff07bd4UL, 0x54458700UL, 0x3c832334UL, 0x18759bc8UL, - 0x3ff08745UL, 0x4bb284ffUL, 0x3c6186beUL, 0xf66607e0UL, 0x3ff092bdUL, - 0x800a3fd1UL, 0xbc968063UL, 0xcac6f383UL, 0x3ff09e3eUL, 0x18316136UL, - 0x3c914878UL, 0x9b1f3919UL, 0x3ff0a9c7UL, 0x873d1d38UL, 0x3c85d16cUL, - 0x6cf9890fUL, 0x3ff0b558UL, 0x4adc610bUL, 0x3c98a62eUL, 0x45e46c85UL, - 0x3ff0c0f1UL, 0x06d21cefUL, 0x3c94f989UL, 0x2b7247f7UL, 0x3ff0cc92UL, - 0x16e24f71UL, 0x3c901edcUL, 0x23395decUL, 0x3ff0d83bUL, 0xe43f316aUL, - 0xbc9bc14dUL, 0x32d3d1a2UL, 0x3ff0e3ecUL, 0x27c57b52UL, 0x3c403a17UL, - 0x5fdfa9c5UL, 0x3ff0efa5UL, 0xbc54021bUL, 0xbc949db9UL, 0xaffed31bUL, - 0x3ff0fb66UL, 0xc44ebd7bUL, 0xbc6b9bedUL, 0x28d7233eUL, 0x3ff10730UL, - 0x1692fdd5UL, 0x3c8d46ebUL, 0xd0125b51UL, 0x3ff11301UL, 0x39449b3aUL, - 0xbc96c510UL, 0xab5e2ab6UL, 0x3ff11edbUL, 0xf703fb72UL, 0xbc9ca454UL, - 0xc06c31ccUL, 0x3ff12abdUL, 0xb36ca5c7UL, 0xbc51b514UL, 0x14f204abUL, - 0x3ff136a8UL, 0xba48dcf0UL, 0xbc67108fUL, 0xaea92de0UL, 0x3ff1429aUL, - 0x9af1369eUL, 0xbc932fbfUL, 0x934f312eUL, 0x3ff14e95UL, 0x39bf44abUL, - 0xbc8b91e8UL, 0xc8a58e51UL, 0x3ff15a98UL, 0xb9eeab0aUL, 0x3c82406aUL, - 0x5471c3c2UL, 0x3ff166a4UL, 0x82ea1a32UL, 0x3c58f23bUL, 0x3c7d517bUL, - 0x3ff172b8UL, 0xb9d78a76UL, 0xbc819041UL, 0x8695bbc0UL, 0x3ff17ed4UL, - 0xe2ac5a64UL, 0x3c709e3fUL, 0x388c8deaUL, 0x3ff18af9UL, 0xd1970f6cUL, - 0xbc911023UL, 0x58375d2fUL, 0x3ff19726UL, 0x85f17e08UL, 0x3c94aaddUL, - 0xeb6fcb75UL, 0x3ff1a35bUL, 0x7b4968e4UL, 0x3c8e5b4cUL, 0xf8138a1cUL, - 0x3ff1af99UL, 0xa4b69280UL, 0x3c97bf85UL, 0x84045cd4UL, 0x3ff1bbe0UL, - 0x352ef607UL, 0xbc995386UL, 0x95281c6bUL, 0x3ff1c82fUL, 0x8010f8c9UL, - 0x3c900977UL, 0x3168b9aaUL, 0x3ff1d487UL, 0x00a2643cUL, 0x3c9e016eUL, - 0x5eb44027UL, 0x3ff1e0e7UL, 0x088cb6deUL, 0xbc96fdd8UL, 0x22fcd91dUL, - 0x3ff1ed50UL, 0x027bb78cUL, 0xbc91df98UL, 0x8438ce4dUL, 0x3ff1f9c1UL, - 0xa097af5cUL, 0xbc9bf524UL, 0x88628cd6UL, 0x3ff2063bUL, 0x814a8495UL, - 0x3c8dc775UL, 0x3578a819UL, 0x3ff212beUL, 0x2cfcaac9UL, 0x3c93592dUL, - 0x917ddc96UL, 0x3ff21f49UL, 0x9494a5eeUL, 0x3c82a97eUL, 0xa27912d1UL, - 0x3ff22bddUL, 0x5577d69fUL, 0x3c8d34fbUL, 0x6e756238UL, 0x3ff2387aUL, - 0xb6c70573UL, 0x3c99b07eUL, 0xfb82140aUL, 0x3ff2451fUL, 0x911ca996UL, - 0x3c8acfccUL, 0x4fb2a63fUL, 0x3ff251ceUL, 0xbef4f4a4UL, 0x3c8ac155UL, - 0x711ece75UL, 0x3ff25e85UL, 0x4ac31b2cUL, 0x3c93e1a2UL, 0x65e27cddUL, - 0x3ff26b45UL, 0x9940e9d9UL, 0x3c82bd33UL, 0x341ddf29UL, 0x3ff2780eUL, - 0x05f9e76cUL, 0x3c9e067cUL, 0xe1f56381UL, 0x3ff284dfUL, 0x8c3f0d7eUL, - 0xbc9a4c3aUL, 0x7591bb70UL, 0x3ff291baUL, 0x28401cbdUL, 0xbc82cc72UL, - 0xf51fdee1UL, 0x3ff29e9dUL, 0xafad1255UL, 0x3c8612e8UL, 0x66d10f13UL, - 0x3ff2ab8aUL, 0x191690a7UL, 0xbc995743UL, 0xd0dad990UL, 0x3ff2b87fUL, - 0xd6381aa4UL, 0xbc410adcUL, 0x39771b2fUL, 0x3ff2c57eUL, 0xa6eb5124UL, - 0xbc950145UL, 0xa6e4030bUL, 0x3ff2d285UL, 0x54db41d5UL, 0x3c900247UL, - 0x1f641589UL, 0x3ff2df96UL, 0xfbbce198UL, 0x3c9d16cfUL, 0xa93e2f56UL, - 0x3ff2ecafUL, 0x45d52383UL, 0x3c71ca0fUL, 0x4abd886bUL, 0x3ff2f9d2UL, - 0x532bda93UL, 0xbc653c55UL, 0x0a31b715UL, 0x3ff306feUL, 0xd23182e4UL, - 0x3c86f46aUL, 0xedeeb2fdUL, 0x3ff31432UL, 0xf3f3fcd1UL, 0x3c8959a3UL, - 0xfc4cd831UL, 0x3ff32170UL, 0x8e18047cUL, 0x3c8a9ce7UL, 0x3ba8ea32UL, - 0x3ff32eb8UL, 0x3cb4f318UL, 0xbc9c45e8UL, 0xb26416ffUL, 0x3ff33c08UL, - 0x843659a6UL, 0x3c932721UL, 0x66e3fa2dUL, 0x3ff34962UL, 0x930881a4UL, - 0xbc835a75UL, 0x5f929ff1UL, 0x3ff356c5UL, 0x5c4e4628UL, 0xbc8b5ceeUL, - 0xa2de883bUL, 0x3ff36431UL, 0xa06cb85eUL, 0xbc8c3144UL, 0x373aa9cbUL, - 0x3ff371a7UL, 0xbf42eae2UL, 0xbc963aeaUL, 0x231e754aUL, 0x3ff37f26UL, - 0x9eceb23cUL, 0xbc99f5caUL, 0x6d05d866UL, 0x3ff38caeUL, 0x3c9904bdUL, - 0xbc9e958dUL, 0x1b7140efUL, 0x3ff39a40UL, 0xfc8e2934UL, 0xbc99a9a5UL, - 0x34e59ff7UL, 0x3ff3a7dbUL, 0xd661f5e3UL, 0xbc75e436UL, 0xbfec6cf4UL, - 0x3ff3b57fUL, 0xe26fff18UL, 0x3c954c66UL, 0xc313a8e5UL, 0x3ff3c32dUL, - 0x375d29c3UL, 0xbc9efff8UL, 0x44ede173UL, 0x3ff3d0e5UL, 0x8c284c71UL, - 0x3c7fe8d0UL, 0x4c123422UL, 0x3ff3dea6UL, 0x11f09ebcUL, 0x3c8ada09UL, - 0xdf1c5175UL, 0x3ff3ec70UL, 0x7b8c9bcaUL, 0xbc8af663UL, 0x04ac801cUL, - 0x3ff3fa45UL, 0xf956f9f3UL, 0xbc97d023UL, 0xc367a024UL, 0x3ff40822UL, - 0xb6f4d048UL, 0x3c8bddf8UL, 0x21f72e2aUL, 0x3ff4160aUL, 0x1c309278UL, - 0xbc5ef369UL, 0x2709468aUL, 0x3ff423fbUL, 0xc0b314ddUL, 0xbc98462dUL, - 0xd950a897UL, 0x3ff431f5UL, 0xe35f7999UL, 0xbc81c7ddUL, 0x3f84b9d4UL, - 0x3ff43ffaUL, 0x9704c003UL, 0x3c8880beUL, 0x6061892dUL, 0x3ff44e08UL, - 0x04ef80d0UL, 0x3c489b7aUL, 0x42a7d232UL, 0x3ff45c20UL, 0x82fb1f8eUL, - 0xbc686419UL, 0xed1d0057UL, 0x3ff46a41UL, 0xd1648a76UL, 0x3c9c944bUL, - 0x668b3237UL, 0x3ff4786dUL, 0xed445733UL, 0xbc9c20f0UL, 0xb5c13cd0UL, - 0x3ff486a2UL, 0xb69062f0UL, 0x3c73c1a3UL, 0xe192aed2UL, 0x3ff494e1UL, - 0x5e499ea0UL, 0xbc83b289UL, 0xf0d7d3deUL, 0x3ff4a32aUL, 0xf3d1be56UL, - 0x3c99cb62UL, 0xea6db7d7UL, 0x3ff4b17dUL, 0x7f2897f0UL, 0xbc8125b8UL, - 0xd5362a27UL, 0x3ff4bfdaUL, 0xafec42e2UL, 0x3c7d4397UL, 0xb817c114UL, - 0x3ff4ce41UL, 0x690abd5dUL, 0x3c905e29UL, 0x99fddd0dUL, 0x3ff4dcb2UL, - 0xbc6a7833UL, 0x3c98ecdbUL, 0x81d8abffUL, 0x3ff4eb2dUL, 0x2e5d7a52UL, - 0xbc95257dUL, 0x769d2ca7UL, 0x3ff4f9b2UL, 0xd25957e3UL, 0xbc94b309UL, - 0x7f4531eeUL, 0x3ff50841UL, 0x49b7465fUL, 0x3c7a249bUL, 0xa2cf6642UL, - 0x3ff516daUL, 0x69bd93efUL, 0xbc8f7685UL, 0xe83f4eefUL, 0x3ff5257dUL, - 0x43efef71UL, 0xbc7c998dUL, 0x569d4f82UL, 0x3ff5342bUL, 0x1db13cadUL, - 0xbc807abeUL, 0xf4f6ad27UL, 0x3ff542e2UL, 0x192d5f7eUL, 0x3c87926dUL, - 0xca5d920fUL, 0x3ff551a4UL, 0xefede59bUL, 0xbc8d689cUL, 0xdde910d2UL, - 0x3ff56070UL, 0x168eebf0UL, 0xbc90fb6eUL, 0x36b527daUL, 0x3ff56f47UL, - 0x011d93adUL, 0x3c99bb2cUL, 0xdbe2c4cfUL, 0x3ff57e27UL, 0x8a57b9c4UL, - 0xbc90b98cUL, 0xd497c7fdUL, 0x3ff58d12UL, 0x5b9a1de8UL, 0x3c8295e1UL, - 0x27ff07ccUL, 0x3ff59c08UL, 0xe467e60fUL, 0xbc97e2ceUL, 0xdd485429UL, - 0x3ff5ab07UL, 0x054647adUL, 0x3c96324cUL, 0xfba87a03UL, 0x3ff5ba11UL, - 0x4c233e1aUL, 0xbc9b77a1UL, 0x8a5946b7UL, 0x3ff5c926UL, 0x816986a2UL, - 0x3c3c4b1bUL, 0x90998b93UL, 0x3ff5d845UL, 0xa8b45643UL, 0xbc9cd6a7UL, - 0x15ad2148UL, 0x3ff5e76fUL, 0x3080e65eUL, 0x3c9ba6f9UL, 0x20dceb71UL, - 0x3ff5f6a3UL, 0xe3cdcf92UL, 0xbc89eaddUL, 0xb976dc09UL, 0x3ff605e1UL, - 0x9b56de47UL, 0xbc93e242UL, 0xe6cdf6f4UL, 0x3ff6152aUL, 0x4ab84c27UL, - 0x3c9e4b3eUL, 0xb03a5585UL, 0x3ff6247eUL, 0x7e40b497UL, 0xbc9383c1UL, - 0x1d1929fdUL, 0x3ff633ddUL, 0xbeb964e5UL, 0x3c984710UL, 0x34ccc320UL, - 0x3ff64346UL, 0x759d8933UL, 0xbc8c483cUL, 0xfebc8fb7UL, 0x3ff652b9UL, - 0xc9a73e09UL, 0xbc9ae3d5UL, 0x82552225UL, 0x3ff66238UL, 0x87591c34UL, - 0xbc9bb609UL, 0xc70833f6UL, 0x3ff671c1UL, 0x586c6134UL, 0xbc8e8732UL, - 0xd44ca973UL, 0x3ff68155UL, 0x44f73e65UL, 0x3c6038aeUL, 0xb19e9538UL, - 0x3ff690f4UL, 0x9aeb445dUL, 0x3c8804bdUL, 0x667f3bcdUL, 0x3ff6a09eUL, - 0x13b26456UL, 0xbc9bdd34UL, 0xfa75173eUL, 0x3ff6b052UL, 0x2c9a9d0eUL, - 0x3c7a38f5UL, 0x750bdabfUL, 0x3ff6c012UL, 0x67ff0b0dUL, 0xbc728956UL, - 0xddd47645UL, 0x3ff6cfdcUL, 0xb6f17309UL, 0x3c9c7aa9UL, 0x3c651a2fUL, - 0x3ff6dfb2UL, 0x683c88abUL, 0xbc6bbe3aUL, 0x98593ae5UL, 0x3ff6ef92UL, - 0x9e1ac8b2UL, 0xbc90b974UL, 0xf9519484UL, 0x3ff6ff7dUL, 0x25860ef6UL, - 0xbc883c0fUL, 0x66f42e87UL, 0x3ff70f74UL, 0xd45aa65fUL, 0x3c59d644UL, - 0xe8ec5f74UL, 0x3ff71f75UL, 0x86887a99UL, 0xbc816e47UL, 0x86ead08aUL, - 0x3ff72f82UL, 0x2cd62c72UL, 0xbc920aa0UL, 0x48a58174UL, 0x3ff73f9aUL, - 0x6c65d53cUL, 0xbc90a8d9UL, 0x35d7cbfdUL, 0x3ff74fbdUL, 0x618a6e1cUL, - 0x3c9047fdUL, 0x564267c9UL, 0x3ff75febUL, 0x57316dd3UL, 0xbc902459UL, - 0xb1ab6e09UL, 0x3ff77024UL, 0x169147f8UL, 0x3c9b7877UL, 0x4fde5d3fUL, - 0x3ff78069UL, 0x0a02162dUL, 0x3c9866b8UL, 0x38ac1cf6UL, 0x3ff790b9UL, - 0x62aadd3eUL, 0x3c9349a8UL, 0x73eb0187UL, 0x3ff7a114UL, 0xee04992fUL, - 0xbc841577UL, 0x0976cfdbUL, 0x3ff7b17bUL, 0x8468dc88UL, 0xbc9bebb5UL, - 0x0130c132UL, 0x3ff7c1edUL, 0xd1164dd6UL, 0x3c9f124cUL, 0x62ff86f0UL, - 0x3ff7d26aUL, 0xfb72b8b4UL, 0x3c91bddbUL, 0x36cf4e62UL, 0x3ff7e2f3UL, - 0xba15797eUL, 0x3c705d02UL, 0x8491c491UL, 0x3ff7f387UL, 0xcf9311aeUL, - 0xbc807f11UL, 0x543e1a12UL, 0x3ff80427UL, 0x626d972bUL, 0xbc927c86UL, - 0xadd106d9UL, 0x3ff814d2UL, 0x0d151d4dUL, 0x3c946437UL, 0x994cce13UL, - 0x3ff82589UL, 0xd41532d8UL, 0xbc9d4c1dUL, 0x1eb941f7UL, 0x3ff8364cUL, - 0x31df2bd5UL, 0x3c999b9aUL, 0x4623c7adUL, 0x3ff8471aUL, 0xa341cdfbUL, - 0xbc88d684UL, 0x179f5b21UL, 0x3ff857f4UL, 0xf8b216d0UL, 0xbc5ba748UL, - 0x9b4492edUL, 0x3ff868d9UL, 0x9bd4f6baUL, 0xbc9fc6f8UL, 0xd931a436UL, - 0x3ff879caUL, 0xd2db47bdUL, 0x3c85d2d7UL, 0xd98a6699UL, 0x3ff88ac7UL, - 0xf37cb53aUL, 0x3c9994c2UL, 0xa478580fUL, 0x3ff89bd0UL, 0x4475202aUL, - 0x3c9d5395UL, 0x422aa0dbUL, 0x3ff8ace5UL, 0x56864b27UL, 0x3c96e9f1UL, - 0xbad61778UL, 0x3ff8be05UL, 0xfc43446eUL, 0x3c9ecb5eUL, 0x16b5448cUL, - 0x3ff8cf32UL, 0x32e9e3aaUL, 0xbc70d55eUL, 0x5e0866d9UL, 0x3ff8e06aUL, - 0x6fc9b2e6UL, 0xbc97114aUL, 0x99157736UL, 0x3ff8f1aeUL, 0xa2e3976cUL, - 0x3c85cc13UL, 0xd0282c8aUL, 0x3ff902feUL, 0x85fe3fd2UL, 0x3c9592caUL, - 0x0b91ffc6UL, 0x3ff9145bUL, 0x2e582524UL, 0xbc9dd679UL, 0x53aa2fe2UL, - 0x3ff925c3UL, 0xa639db7fUL, 0xbc83455fUL, 0xb0cdc5e5UL, 0x3ff93737UL, - 0x81b57ebcUL, 0xbc675fc7UL, 0x2b5f98e5UL, 0x3ff948b8UL, 0x797d2d99UL, - 0xbc8dc3d6UL, 0xcbc8520fUL, 0x3ff95a44UL, 0x96a5f039UL, 0xbc764b7cUL, - 0x9a7670b3UL, 0x3ff96bddUL, 0x7f19c896UL, 0xbc5ba596UL, 0x9fde4e50UL, - 0x3ff97d82UL, 0x7c1b85d1UL, 0xbc9d185bUL, 0xe47a22a2UL, 0x3ff98f33UL, - 0xa24c78ecUL, 0x3c7cabdaUL, 0x70ca07baUL, 0x3ff9a0f1UL, 0x91cee632UL, - 0xbc9173bdUL, 0x4d53fe0dUL, 0x3ff9b2bbUL, 0x4df6d518UL, 0xbc9dd84eUL, - 0x82a3f090UL, 0x3ff9c491UL, 0xb071f2beUL, 0x3c7c7c46UL, 0x194bb8d5UL, - 0x3ff9d674UL, 0xa3dd8233UL, 0xbc9516beUL, 0x19e32323UL, 0x3ff9e863UL, - 0x78e64c6eUL, 0x3c7824caUL, 0x8d07f29eUL, 0x3ff9fa5eUL, 0xaaf1faceUL, - 0xbc84a9ceUL, 0x7b5de565UL, 0x3ffa0c66UL, 0x5d1cd533UL, 0xbc935949UL, - 0xed8eb8bbUL, 0x3ffa1e7aUL, 0xee8be70eUL, 0x3c9c6618UL, 0xec4a2d33UL, - 0x3ffa309bUL, 0x7ddc36abUL, 0x3c96305cUL, 0x80460ad8UL, 0x3ffa42c9UL, - 0x589fb120UL, 0xbc9aa780UL, 0xb23e255dUL, 0x3ffa5503UL, 0xdb8d41e1UL, - 0xbc9d2f6eUL, 0x8af46052UL, 0x3ffa674aUL, 0x30670366UL, 0x3c650f56UL, - 0x1330b358UL, 0x3ffa799eUL, 0xcac563c7UL, 0x3c9bcb7eUL, 0x53c12e59UL, - 0x3ffa8bfeUL, 0xb2ba15a9UL, 0xbc94f867UL, 0x5579fdbfUL, 0x3ffa9e6bUL, - 0x0ef7fd31UL, 0x3c90fac9UL, 0x21356ebaUL, 0x3ffab0e5UL, 0xdae94545UL, - 0x3c889c31UL, 0xbfd3f37aUL, 0x3ffac36bUL, 0xcae76cd0UL, 0xbc8f9234UL, - 0x3a3c2774UL, 0x3ffad5ffUL, 0xb6b1b8e5UL, 0x3c97ef3bUL, 0x995ad3adUL, - 0x3ffae89fUL, 0x345dcc81UL, 0x3c97a1cdUL, 0xe622f2ffUL, 0x3ffafb4cUL, - 0x0f315ecdUL, 0xbc94b2fcUL, 0x298db666UL, 0x3ffb0e07UL, 0x4c80e425UL, - 0xbc9bdef5UL, 0x6c9a8952UL, 0x3ffb20ceUL, 0x4a0756ccUL, 0x3c94dd02UL, - 0xb84f15fbUL, 0x3ffb33a2UL, 0x3084d708UL, 0xbc62805eUL, 0x15b749b1UL, - 0x3ffb4684UL, 0xe9df7c90UL, 0xbc7f763dUL, 0x8de5593aUL, 0x3ffb5972UL, - 0xbbba6de3UL, 0xbc9c71dfUL, 0x29f1c52aUL, 0x3ffb6c6eUL, 0x52883f6eUL, - 0x3c92a8f3UL, 0xf2fb5e47UL, 0x3ffb7f76UL, 0x7e54ac3bUL, 0xbc75584fUL, - 0xf22749e4UL, 0x3ffb928cUL, 0x54cb65c6UL, 0xbc9b7216UL, 0x30a1064aUL, - 0x3ffba5b0UL, 0x0e54292eUL, 0xbc9efcd3UL, 0xb79a6f1fUL, 0x3ffbb8e0UL, - 0xc9696205UL, 0xbc3f52d1UL, 0x904bc1d2UL, 0x3ffbcc1eUL, 0x7a2d9e84UL, - 0x3c823dd0UL, 0xc3f3a207UL, 0x3ffbdf69UL, 0x60ea5b53UL, 0xbc3c2623UL, - 0x5bd71e09UL, 0x3ffbf2c2UL, 0x3f6b9c73UL, 0xbc9efdcaUL, 0x6141b33dUL, - 0x3ffc0628UL, 0xa1fbca34UL, 0xbc8d8a5aUL, 0xdd85529cUL, 0x3ffc199bUL, - 0x895048ddUL, 0x3c811065UL, 0xd9fa652cUL, 0x3ffc2d1cUL, 0x17c8a5d7UL, - 0xbc96e516UL, 0x5fffd07aUL, 0x3ffc40abUL, 0xe083c60aUL, 0x3c9b4537UL, - 0x78fafb22UL, 0x3ffc5447UL, 0x2493b5afUL, 0x3c912f07UL, 0x2e57d14bUL, - 0x3ffc67f1UL, 0xff483cadUL, 0x3c92884dUL, 0x8988c933UL, 0x3ffc7ba8UL, - 0xbe255559UL, 0xbc8e76bbUL, 0x9406e7b5UL, 0x3ffc8f6dUL, 0x48805c44UL, - 0x3c71acbcUL, 0x5751c4dbUL, 0x3ffca340UL, 0xd10d08f5UL, 0xbc87f2beUL, - 0xdcef9069UL, 0x3ffcb720UL, 0xd1e949dbUL, 0x3c7503cbUL, 0x2e6d1675UL, - 0x3ffccb0fUL, 0x86009092UL, 0xbc7d220fUL, 0x555dc3faUL, 0x3ffcdf0bUL, - 0x53829d72UL, 0xbc8dd83bUL, 0x5b5bab74UL, 0x3ffcf315UL, 0xb86dff57UL, - 0xbc9a08e9UL, 0x4a07897cUL, 0x3ffd072dUL, 0x43797a9cUL, 0xbc9cbc37UL, - 0x2b08c968UL, 0x3ffd1b53UL, 0x219a36eeUL, 0x3c955636UL, 0x080d89f2UL, - 0x3ffd2f87UL, 0x719d8578UL, 0xbc9d487bUL, 0xeacaa1d6UL, 0x3ffd43c8UL, - 0xbf5a1614UL, 0x3c93db53UL, 0xdcfba487UL, 0x3ffd5818UL, 0xd75b3707UL, - 0x3c82ed02UL, 0xe862e6d3UL, 0x3ffd6c76UL, 0x4a8165a0UL, 0x3c5fe87aUL, - 0x16c98398UL, 0x3ffd80e3UL, 0x8beddfe8UL, 0xbc911ec1UL, 0x71ff6075UL, - 0x3ffd955dUL, 0xbb9af6beUL, 0x3c9a052dUL, 0x03db3285UL, 0x3ffda9e6UL, - 0x696db532UL, 0x3c9c2300UL, 0xd63a8315UL, 0x3ffdbe7cUL, 0x926b8be4UL, - 0xbc9b76f1UL, 0xf301b460UL, 0x3ffdd321UL, 0x78f018c3UL, 0x3c92da57UL, - 0x641c0658UL, 0x3ffde7d5UL, 0x8e79ba8fUL, 0xbc9ca552UL, 0x337b9b5fUL, - 0x3ffdfc97UL, 0x4f184b5cUL, 0xbc91a5cdUL, 0x6b197d17UL, 0x3ffe1167UL, - 0xbd5c7f44UL, 0xbc72b529UL, 0x14f5a129UL, 0x3ffe2646UL, 0x817a1496UL, - 0xbc97b627UL, 0x3b16ee12UL, 0x3ffe3b33UL, 0x31fdc68bUL, 0xbc99f4a4UL, - 0xe78b3ff6UL, 0x3ffe502eUL, 0x80a9cc8fUL, 0x3c839e89UL, 0x24676d76UL, - 0x3ffe6539UL, 0x7522b735UL, 0xbc863ff8UL, 0xfbc74c83UL, 0x3ffe7a51UL, - 0xca0c8de2UL, 0x3c92d522UL, 0x77cdb740UL, 0x3ffe8f79UL, 0x80b054b1UL, - 0xbc910894UL, 0xa2a490daUL, 0x3ffea4afUL, 0x179c2893UL, 0xbc9e9c23UL, - 0x867cca6eUL, 0x3ffeb9f4UL, 0x2293e4f2UL, 0x3c94832fUL, 0x2d8e67f1UL, - 0x3ffecf48UL, 0xb411ad8cUL, 0xbc9c93f3UL, 0xa2188510UL, 0x3ffee4aaUL, - 0xa487568dUL, 0x3c91c68dUL, 0xee615a27UL, 0x3ffefa1bUL, 0x86a4b6b0UL, - 0x3c9dc7f4UL, 0x1cb6412aUL, 0x3fff0f9cUL, 0x65181d45UL, 0xbc932200UL, - 0x376bba97UL, 0x3fff252bUL, 0xbf0d8e43UL, 0x3c93a1a5UL, 0x48dd7274UL, - 0x3fff3ac9UL, 0x3ed837deUL, 0xbc795a5aUL, 0x5b6e4540UL, 0x3fff5076UL, - 0x2dd8a18bUL, 0x3c99d3e1UL, 0x798844f8UL, 0x3fff6632UL, 0x3539343eUL, - 0x3c9fa37bUL, 0xad9cbe14UL, 0x3fff7bfdUL, 0xd006350aUL, 0xbc9dbb12UL, - 0x02243c89UL, 0x3fff91d8UL, 0xa779f689UL, 0xbc612ea8UL, 0x819e90d8UL, - 0x3fffa7c1UL, 0xf3a5931eUL, 0x3c874853UL, 0x3692d514UL, 0x3fffbdbaUL, - 0x15098eb6UL, 0xbc796773UL, 0x2b8f71f1UL, 0x3fffd3c2UL, 0x966579e7UL, - 0x3c62eb74UL, 0x6b2a23d9UL, 0x3fffe9d9UL, 0x7442fde3UL, 0x3c74a603UL, - 0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL, 0x6fba4e77UL, - 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL, 0xfefa39efUL, 0x3fe62e42UL, - 0x00000000UL, 0x00000000UL, 0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL, - 0xbfe62e42UL, 0xf8000000UL, 0xffffffffUL, 0xf8000000UL, 0xffffffffUL, - 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x00000000UL - -}; - -//registers, -// input: xmm0, xmm1 -// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 -// eax, edx, ecx, ebx - -// Code generated by Intel C compiler for LIBM library - -void MacroAssembler::fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) { - Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; - Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; - Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2; - Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, L_2TAG_PACKET_14_0_2, L_2TAG_PACKET_15_0_2; - Label L_2TAG_PACKET_16_0_2, L_2TAG_PACKET_17_0_2, L_2TAG_PACKET_18_0_2, L_2TAG_PACKET_19_0_2; - Label L_2TAG_PACKET_20_0_2, L_2TAG_PACKET_21_0_2, L_2TAG_PACKET_22_0_2, L_2TAG_PACKET_23_0_2; - Label L_2TAG_PACKET_24_0_2, L_2TAG_PACKET_25_0_2, L_2TAG_PACKET_26_0_2, L_2TAG_PACKET_27_0_2; - Label L_2TAG_PACKET_28_0_2, L_2TAG_PACKET_29_0_2, L_2TAG_PACKET_30_0_2, L_2TAG_PACKET_31_0_2; - Label L_2TAG_PACKET_32_0_2, L_2TAG_PACKET_33_0_2, L_2TAG_PACKET_34_0_2, L_2TAG_PACKET_35_0_2; - Label L_2TAG_PACKET_36_0_2, L_2TAG_PACKET_37_0_2, L_2TAG_PACKET_38_0_2, L_2TAG_PACKET_39_0_2; - Label L_2TAG_PACKET_40_0_2, L_2TAG_PACKET_41_0_2, L_2TAG_PACKET_42_0_2, L_2TAG_PACKET_43_0_2; - Label L_2TAG_PACKET_44_0_2, L_2TAG_PACKET_45_0_2, L_2TAG_PACKET_46_0_2, L_2TAG_PACKET_47_0_2; - Label L_2TAG_PACKET_48_0_2, L_2TAG_PACKET_49_0_2, L_2TAG_PACKET_50_0_2, L_2TAG_PACKET_51_0_2; - Label L_2TAG_PACKET_52_0_2, L_2TAG_PACKET_53_0_2, L_2TAG_PACKET_54_0_2, L_2TAG_PACKET_55_0_2; - Label L_2TAG_PACKET_56_0_2, L_2TAG_PACKET_57_0_2, L_2TAG_PACKET_58_0_2, start; - - assert_different_registers(tmp, eax, ecx, edx); - - address static_const_table_pow = (address)_static_const_table_pow; - - bind(start); - subl(rsp, 120); - movl(Address(rsp, 64), tmp); - lea(tmp, ExternalAddress(static_const_table_pow)); - movsd(xmm0, Address(rsp, 128)); - movsd(xmm1, Address(rsp, 136)); - xorpd(xmm2, xmm2); - movl(eax, 16368); - pinsrw(xmm2, eax, 3); - movl(ecx, 1069088768); - movdl(xmm7, ecx); - movsd(Address(rsp, 16), xmm1); - xorpd(xmm1, xmm1); - movl(edx, 30704); - pinsrw(xmm1, edx, 3); - movsd(Address(rsp, 8), xmm0); - movdqu(xmm3, xmm0); - movl(edx, 8192); - movdl(xmm4, edx); - movdqu(xmm6, Address(tmp, 8240)); - pextrw(eax, xmm0, 3); - por(xmm0, xmm2); - psllq(xmm0, 5); - movsd(xmm2, Address(tmp, 8256)); - psrlq(xmm0, 34); - movl(edx, eax); - andl(edx, 32752); - subl(edx, 16368); - movl(ecx, edx); - sarl(edx, 31); - addl(ecx, edx); - xorl(ecx, edx); - rcpss(xmm0, xmm0); - psllq(xmm3, 12); - addl(ecx, 16); - bsrl(ecx, ecx); - psrlq(xmm3, 12); - movl(Address(rsp, 24), rsi); - subl(eax, 16); - cmpl(eax, 32736); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); - movl(rsi, 0); - - bind(L_2TAG_PACKET_1_0_2); - mulss(xmm0, xmm7); - movl(edx, -1); - subl(ecx, 4); - shll(edx); - movdl(xmm5, edx); - por(xmm3, xmm1); - subl(eax, 16351); - cmpl(eax, 1); - jcc(Assembler::belowEqual, L_2TAG_PACKET_2_0_2); - paddd(xmm0, xmm4); - psllq(xmm5, 32); - movdl(edx, xmm0); - psllq(xmm0, 29); - pand(xmm5, xmm3); - - bind(L_2TAG_PACKET_3_0_2); - pand(xmm0, xmm6); - subsd(xmm3, xmm5); - subl(eax, 1); - sarl(eax, 4); - cvtsi2sdl(xmm7, eax); - mulpd(xmm5, xmm0); - - bind(L_2TAG_PACKET_4_0_2); - mulsd(xmm3, xmm0); - movdqu(xmm1, Address(tmp, 8272)); - subsd(xmm5, xmm2); - movdqu(xmm4, Address(tmp, 8288)); - movl(ecx, eax); - sarl(eax, 31); - addl(ecx, eax); - xorl(eax, ecx); - addl(eax, 1); - bsrl(eax, eax); - unpcklpd(xmm5, xmm3); - movdqu(xmm6, Address(tmp, 8304)); - addsd(xmm3, xmm5); - andl(edx, 16760832); - shrl(edx, 10); - addpd(xmm5, Address(tmp, edx, Address::times_1, -3616)); - movdqu(xmm0, Address(tmp, 8320)); - pshufd(xmm2, xmm3, 68); - mulsd(xmm3, xmm3); - mulpd(xmm1, xmm2); - mulpd(xmm4, xmm2); - addsd(xmm5, xmm7); - mulsd(xmm2, xmm3); - addpd(xmm6, xmm1); - mulsd(xmm3, xmm3); - addpd(xmm0, xmm4); - movsd(xmm1, Address(rsp, 16)); - movzwl(ecx, Address(rsp, 22)); - pshufd(xmm7, xmm5, 238); - movsd(xmm4, Address(tmp, 8368)); - mulpd(xmm6, xmm2); - pshufd(xmm3, xmm3, 68); - mulpd(xmm0, xmm2); - shll(eax, 4); - subl(eax, 15872); - andl(ecx, 32752); - addl(eax, ecx); - mulpd(xmm3, xmm6); - cmpl(eax, 624); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2); - xorpd(xmm6, xmm6); - movl(edx, 17080); - pinsrw(xmm6, edx, 3); - movdqu(xmm2, xmm1); - pand(xmm4, xmm1); - subsd(xmm1, xmm4); - mulsd(xmm4, xmm5); - addsd(xmm0, xmm7); - mulsd(xmm1, xmm5); - movdqu(xmm7, xmm6); - addsd(xmm6, xmm4); - addpd(xmm3, xmm0); - movdl(edx, xmm6); - subsd(xmm6, xmm7); - pshufd(xmm0, xmm3, 238); - subsd(xmm4, xmm6); - addsd(xmm0, xmm3); - movl(ecx, edx); - andl(edx, 255); - addl(edx, edx); - movdqu(xmm5, Address(tmp, edx, Address::times_8, 8384)); - addsd(xmm4, xmm1); - mulsd(xmm2, xmm0); - movdqu(xmm7, Address(tmp, 12480)); - movdqu(xmm3, Address(tmp, 12496)); - shll(ecx, 12); - xorl(ecx, rsi); - andl(ecx, -1048576); - movdl(xmm6, ecx); - addsd(xmm2, xmm4); - movsd(xmm1, Address(tmp, 12512)); - pshufd(xmm0, xmm2, 68); - pshufd(xmm4, xmm2, 68); - mulpd(xmm0, xmm0); - movl(rsi, Address(rsp, 24)); - mulpd(xmm7, xmm4); - pshufd(xmm6, xmm6, 17); - mulsd(xmm1, xmm2); - mulsd(xmm0, xmm0); - paddd(xmm5, xmm6); - addpd(xmm3, xmm7); - mulsd(xmm1, xmm5); - pshufd(xmm6, xmm5, 238); - mulpd(xmm0, xmm3); - addsd(xmm1, xmm6); - pshufd(xmm3, xmm0, 238); - mulsd(xmm0, xmm5); - mulsd(xmm3, xmm5); - addsd(xmm0, xmm1); - addsd(xmm0, xmm3); - addsd(xmm0, xmm5); - movsd(Address(rsp, 0), xmm0); - fld_d(Address(rsp, 0)); - jmp(L_2TAG_PACKET_6_0_2); - - bind(L_2TAG_PACKET_7_0_2); - movsd(xmm0, Address(rsp, 128)); - movsd(xmm1, Address(rsp, 136)); - mulsd(xmm0, xmm1); - movsd(Address(rsp, 0), xmm0); - fld_d(Address(rsp, 0)); - jmp(L_2TAG_PACKET_6_0_2); - - bind(L_2TAG_PACKET_0_0_2); - addl(eax, 16); - movl(edx, 32752); - andl(edx, eax); - cmpl(edx, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_8_0_2); - testl(eax, 32768); - jcc(Assembler::notEqual, L_2TAG_PACKET_9_0_2); - - bind(L_2TAG_PACKET_10_0_2); - movl(ecx, Address(rsp, 16)); - xorl(edx, edx); - testl(ecx, ecx); - movl(ecx, 1); - cmovl(Assembler::notEqual, edx, ecx); - orl(edx, Address(rsp, 20)); - cmpl(edx, 1072693248); - jcc(Assembler::equal, L_2TAG_PACKET_7_0_2); - movsd(xmm0, Address(rsp, 8)); - movsd(xmm3, Address(rsp, 8)); - movdl(edx, xmm3); - psrlq(xmm3, 32); - movdl(ecx, xmm3); - orl(edx, ecx); - cmpl(edx, 0); - jcc(Assembler::equal, L_2TAG_PACKET_11_0_2); - xorpd(xmm3, xmm3); - movl(eax, 18416); - pinsrw(xmm3, eax, 3); - mulsd(xmm0, xmm3); - xorpd(xmm2, xmm2); - movl(eax, 16368); - pinsrw(xmm2, eax, 3); - movdqu(xmm3, xmm0); - pextrw(eax, xmm0, 3); - por(xmm0, xmm2); - movl(ecx, 18416); - psllq(xmm0, 5); - movsd(xmm2, Address(tmp, 8256)); - psrlq(xmm0, 34); - rcpss(xmm0, xmm0); - psllq(xmm3, 12); - movdqu(xmm6, Address(tmp, 8240)); - psrlq(xmm3, 12); - mulss(xmm0, xmm7); - movl(edx, -1024); - movdl(xmm5, edx); - por(xmm3, xmm1); - paddd(xmm0, xmm4); - psllq(xmm5, 32); - movdl(edx, xmm0); - psllq(xmm0, 29); - pand(xmm5, xmm3); - movl(rsi, 0); - pand(xmm0, xmm6); - subsd(xmm3, xmm5); - andl(eax, 32752); - subl(eax, 18416); - sarl(eax, 4); - cvtsi2sdl(xmm7, eax); - mulpd(xmm5, xmm0); - jmp(L_2TAG_PACKET_4_0_2); - - bind(L_2TAG_PACKET_12_0_2); - movl(ecx, Address(rsp, 16)); - xorl(edx, edx); - testl(ecx, ecx); - movl(ecx, 1); - cmovl(Assembler::notEqual, edx, ecx); - orl(edx, Address(rsp, 20)); - cmpl(edx, 1072693248); - jcc(Assembler::equal, L_2TAG_PACKET_7_0_2); - movsd(xmm0, Address(rsp, 8)); - movsd(xmm3, Address(rsp, 8)); - movdl(edx, xmm3); - psrlq(xmm3, 32); - movdl(ecx, xmm3); - orl(edx, ecx); - cmpl(edx, 0); - jcc(Assembler::equal, L_2TAG_PACKET_11_0_2); - xorpd(xmm3, xmm3); - movl(eax, 18416); - pinsrw(xmm3, eax, 3); - mulsd(xmm0, xmm3); - xorpd(xmm2, xmm2); - movl(eax, 16368); - pinsrw(xmm2, eax, 3); - movdqu(xmm3, xmm0); - pextrw(eax, xmm0, 3); - por(xmm0, xmm2); - movl(ecx, 18416); - psllq(xmm0, 5); - movsd(xmm2, Address(tmp, 8256)); - psrlq(xmm0, 34); - rcpss(xmm0, xmm0); - psllq(xmm3, 12); - movdqu(xmm6, Address(tmp, 8240)); - psrlq(xmm3, 12); - mulss(xmm0, xmm7); - movl(edx, -1024); - movdl(xmm5, edx); - por(xmm3, xmm1); - paddd(xmm0, xmm4); - psllq(xmm5, 32); - movdl(edx, xmm0); - psllq(xmm0, 29); - pand(xmm5, xmm3); - movl(rsi, INT_MIN); - pand(xmm0, xmm6); - subsd(xmm3, xmm5); - andl(eax, 32752); - subl(eax, 18416); - sarl(eax, 4); - cvtsi2sdl(xmm7, eax); - mulpd(xmm5, xmm0); - jmp(L_2TAG_PACKET_4_0_2); - - bind(L_2TAG_PACKET_5_0_2); - cmpl(eax, 0); - jcc(Assembler::less, L_2TAG_PACKET_13_0_2); - cmpl(eax, 752); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_14_0_2); - - bind(L_2TAG_PACKET_15_0_2); - addsd(xmm0, xmm7); - movsd(xmm2, Address(tmp, 12544)); - addpd(xmm3, xmm0); - xorpd(xmm6, xmm6); - movl(eax, 17080); - pinsrw(xmm6, eax, 3); - pshufd(xmm0, xmm3, 238); - addsd(xmm0, xmm3); - movdqu(xmm3, xmm5); - addsd(xmm5, xmm0); - movdqu(xmm4, xmm2); - subsd(xmm3, xmm5); - movdqu(xmm7, xmm5); - pand(xmm5, xmm2); - movdqu(xmm2, xmm1); - pand(xmm4, xmm1); - subsd(xmm7, xmm5); - addsd(xmm0, xmm3); - subsd(xmm1, xmm4); - mulsd(xmm4, xmm5); - addsd(xmm0, xmm7); - mulsd(xmm2, xmm0); - movdqu(xmm7, xmm6); - mulsd(xmm1, xmm5); - addsd(xmm6, xmm4); - movdl(eax, xmm6); - subsd(xmm6, xmm7); - addsd(xmm2, xmm1); - movdqu(xmm7, Address(tmp, 12480)); - movdqu(xmm3, Address(tmp, 12496)); - subsd(xmm4, xmm6); - pextrw(edx, xmm6, 3); - movl(ecx, eax); - andl(eax, 255); - addl(eax, eax); - movdqu(xmm5, Address(tmp, eax, Address::times_8, 8384)); - addsd(xmm2, xmm4); - sarl(ecx, 8); - movl(eax, ecx); - sarl(ecx, 1); - subl(eax, ecx); - shll(ecx, 20); - xorl(ecx, rsi); - movdl(xmm6, ecx); - movsd(xmm1, Address(tmp, 12512)); - andl(edx, 32767); - cmpl(edx, 16529); - jcc(Assembler::above, L_2TAG_PACKET_14_0_2); - pshufd(xmm0, xmm2, 68); - pshufd(xmm4, xmm2, 68); - mulpd(xmm0, xmm0); - mulpd(xmm7, xmm4); - pshufd(xmm6, xmm6, 17); - mulsd(xmm1, xmm2); - mulsd(xmm0, xmm0); - paddd(xmm5, xmm6); - addpd(xmm3, xmm7); - mulsd(xmm1, xmm5); - pshufd(xmm6, xmm5, 238); - mulpd(xmm0, xmm3); - addsd(xmm1, xmm6); - pshufd(xmm3, xmm0, 238); - mulsd(xmm0, xmm5); - mulsd(xmm3, xmm5); - shll(eax, 4); - xorpd(xmm4, xmm4); - addl(eax, 16368); - pinsrw(xmm4, eax, 3); - addsd(xmm0, xmm1); - movl(rsi, Address(rsp, 24)); - addsd(xmm0, xmm3); - movdqu(xmm1, xmm0); - addsd(xmm0, xmm5); - mulsd(xmm0, xmm4); - pextrw(eax, xmm0, 3); - andl(eax, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_16_0_2); - cmpl(eax, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_17_0_2); - - bind(L_2TAG_PACKET_18_0_2); - movsd(Address(rsp, 0), xmm0); - fld_d(Address(rsp, 0)); - jmp(L_2TAG_PACKET_6_0_2); - - bind(L_2TAG_PACKET_8_0_2); - movsd(xmm1, Address(rsp, 16)); - movsd(xmm0, Address(rsp, 8)); - movdqu(xmm2, xmm0); - movdl(eax, xmm2); - psrlq(xmm2, 20); - movdl(edx, xmm2); - orl(eax, edx); - jcc(Assembler::equal, L_2TAG_PACKET_19_0_2); - addsd(xmm0, xmm0); - movdl(eax, xmm1); - psrlq(xmm1, 32); - movdl(edx, xmm1); - movl(ecx, edx); - addl(edx, edx); - orl(eax, edx); - jcc(Assembler::equal, L_2TAG_PACKET_20_0_2); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_20_0_2); - xorpd(xmm0, xmm0); - movl(eax, 16368); - pinsrw(xmm0, eax, 3); - movl(edx, 29); - jmp(L_2TAG_PACKET_21_0_2); - - bind(L_2TAG_PACKET_22_0_2); - movsd(xmm0, Address(rsp, 16)); - addpd(xmm0, xmm0); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_19_0_2); - movdl(eax, xmm1); - movdqu(xmm2, xmm1); - psrlq(xmm1, 32); - movdl(edx, xmm1); - movl(ecx, edx); - addl(edx, edx); - orl(eax, edx); - jcc(Assembler::equal, L_2TAG_PACKET_23_0_2); - pextrw(eax, xmm2, 3); - andl(eax, 32752); - cmpl(eax, 32752); - jcc(Assembler::notEqual, L_2TAG_PACKET_24_0_2); - movdl(eax, xmm2); - psrlq(xmm2, 20); - movdl(edx, xmm2); - orl(eax, edx); - jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2); - - bind(L_2TAG_PACKET_24_0_2); - pextrw(eax, xmm0, 3); - testl(eax, 32768); - jcc(Assembler::notEqual, L_2TAG_PACKET_25_0_2); - testl(ecx, INT_MIN); - jcc(Assembler::notEqual, L_2TAG_PACKET_26_0_2); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_27_0_2); - movsd(xmm1, Address(rsp, 16)); - movdl(eax, xmm1); - testl(eax, 1); - jcc(Assembler::notEqual, L_2TAG_PACKET_28_0_2); - testl(eax, 2); - jcc(Assembler::notEqual, L_2TAG_PACKET_29_0_2); - jmp(L_2TAG_PACKET_28_0_2); - - bind(L_2TAG_PACKET_25_0_2); - shrl(ecx, 20); - andl(ecx, 2047); - cmpl(ecx, 1075); - jcc(Assembler::above, L_2TAG_PACKET_28_0_2); - jcc(Assembler::equal, L_2TAG_PACKET_30_0_2); - cmpl(ecx, 1074); - jcc(Assembler::above, L_2TAG_PACKET_27_0_2); - cmpl(ecx, 1023); - jcc(Assembler::below, L_2TAG_PACKET_28_0_2); - movsd(xmm1, Address(rsp, 16)); - movl(eax, 17208); - xorpd(xmm3, xmm3); - pinsrw(xmm3, eax, 3); - movdqu(xmm4, xmm3); - addsd(xmm3, xmm1); - subsd(xmm4, xmm3); - addsd(xmm1, xmm4); - pextrw(eax, xmm1, 3); - andl(eax, 32752); - jcc(Assembler::notEqual, L_2TAG_PACKET_28_0_2); - movdl(eax, xmm3); - andl(eax, 1); - jcc(Assembler::equal, L_2TAG_PACKET_28_0_2); - - bind(L_2TAG_PACKET_29_0_2); - movsd(xmm1, Address(rsp, 16)); - pextrw(eax, xmm1, 3); - andl(eax, 32768); - jcc(Assembler::equal, L_2TAG_PACKET_18_0_2); - xorpd(xmm0, xmm0); - movl(eax, 32768); - pinsrw(xmm0, eax, 3); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_28_0_2); - movsd(xmm1, Address(rsp, 16)); - pextrw(eax, xmm1, 3); - andl(eax, 32768); - jcc(Assembler::notEqual, L_2TAG_PACKET_26_0_2); - - bind(L_2TAG_PACKET_31_0_2); - xorpd(xmm0, xmm0); - movl(eax, 32752); - pinsrw(xmm0, eax, 3); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_30_0_2); - movsd(xmm1, Address(rsp, 16)); - movdl(eax, xmm1); - andl(eax, 1); - jcc(Assembler::equal, L_2TAG_PACKET_28_0_2); - jmp(L_2TAG_PACKET_29_0_2); - - bind(L_2TAG_PACKET_32_0_2); - movdl(eax, xmm1); - psrlq(xmm1, 20); - movdl(edx, xmm1); - orl(eax, edx); - jcc(Assembler::equal, L_2TAG_PACKET_33_0_2); - movsd(xmm0, Address(rsp, 16)); - addsd(xmm0, xmm0); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_33_0_2); - movsd(xmm0, Address(rsp, 8)); - pextrw(eax, xmm0, 3); - cmpl(eax, 49136); - jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2); - movdl(ecx, xmm0); - psrlq(xmm0, 20); - movdl(edx, xmm0); - orl(ecx, edx); - jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2); - xorpd(xmm0, xmm0); - movl(eax, 32760); - pinsrw(xmm0, eax, 3); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_34_0_2); - movsd(xmm1, Address(rsp, 16)); - andl(eax, 32752); - subl(eax, 16368); - pextrw(edx, xmm1, 3); - xorpd(xmm0, xmm0); - xorl(eax, edx); - andl(eax, 32768); - jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2); - movl(ecx, 32752); - pinsrw(xmm0, ecx, 3); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_35_0_2); - movdl(eax, xmm1); - cmpl(edx, 17184); - jcc(Assembler::above, L_2TAG_PACKET_36_0_2); - testl(eax, 1); - jcc(Assembler::notEqual, L_2TAG_PACKET_37_0_2); - testl(eax, 2); - jcc(Assembler::equal, L_2TAG_PACKET_38_0_2); - jmp(L_2TAG_PACKET_39_0_2); - - bind(L_2TAG_PACKET_36_0_2); - testl(eax, 1); - jcc(Assembler::equal, L_2TAG_PACKET_38_0_2); - jmp(L_2TAG_PACKET_39_0_2); - - bind(L_2TAG_PACKET_9_0_2); - movsd(xmm2, Address(rsp, 8)); - movdl(eax, xmm2); - psrlq(xmm2, 31); - movdl(ecx, xmm2); - orl(eax, ecx); - jcc(Assembler::equal, L_2TAG_PACKET_11_0_2); - movsd(xmm1, Address(rsp, 16)); - pextrw(edx, xmm1, 3); - movdl(eax, xmm1); - movdqu(xmm2, xmm1); - psrlq(xmm2, 32); - movdl(ecx, xmm2); - addl(ecx, ecx); - orl(ecx, eax); - jcc(Assembler::equal, L_2TAG_PACKET_40_0_2); - andl(edx, 32752); - cmpl(edx, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_32_0_2); - cmpl(edx, 17200); - jcc(Assembler::above, L_2TAG_PACKET_38_0_2); - cmpl(edx, 17184); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_35_0_2); - cmpl(edx, 16368); - jcc(Assembler::below, L_2TAG_PACKET_37_0_2); - movl(eax, 17208); - xorpd(xmm2, xmm2); - pinsrw(xmm2, eax, 3); - movdqu(xmm4, xmm2); - addsd(xmm2, xmm1); - subsd(xmm4, xmm2); - addsd(xmm1, xmm4); - pextrw(eax, xmm1, 3); - andl(eax, 32767); - jcc(Assembler::notEqual, L_2TAG_PACKET_37_0_2); - movdl(eax, xmm2); - andl(eax, 1); - jcc(Assembler::equal, L_2TAG_PACKET_38_0_2); - - bind(L_2TAG_PACKET_39_0_2); - xorpd(xmm1, xmm1); - movl(edx, 30704); - pinsrw(xmm1, edx, 3); - movsd(xmm2, Address(tmp, 8256)); - movsd(xmm4, Address(rsp, 8)); - pextrw(eax, xmm4, 3); - movl(edx, 8192); - movdl(xmm4, edx); - andl(eax, 32767); - subl(eax, 16); - jcc(Assembler::less, L_2TAG_PACKET_12_0_2); - movl(edx, eax); - andl(edx, 32752); - subl(edx, 16368); - movl(ecx, edx); - sarl(edx, 31); - addl(ecx, edx); - xorl(ecx, edx); - addl(ecx, 16); - bsrl(ecx, ecx); - movl(rsi, INT_MIN); - jmp(L_2TAG_PACKET_1_0_2); - - bind(L_2TAG_PACKET_37_0_2); - xorpd(xmm1, xmm1); - movl(eax, 32752); - pinsrw(xmm1, eax, 3); - xorpd(xmm0, xmm0); - mulsd(xmm0, xmm1); - movl(edx, 28); - jmp(L_2TAG_PACKET_21_0_2); - - bind(L_2TAG_PACKET_38_0_2); - xorpd(xmm1, xmm1); - movl(edx, 30704); - pinsrw(xmm1, edx, 3); - movsd(xmm2, Address(tmp, 8256)); - movsd(xmm4, Address(rsp, 8)); - pextrw(eax, xmm4, 3); - movl(edx, 8192); - movdl(xmm4, edx); - andl(eax, 32767); - subl(eax, 16); - jcc(Assembler::less, L_2TAG_PACKET_10_0_2); - movl(edx, eax); - andl(edx, 32752); - subl(edx, 16368); - movl(ecx, edx); - sarl(edx, 31); - addl(ecx, edx); - xorl(ecx, edx); - addl(ecx, 16); - bsrl(ecx, ecx); - movl(rsi, 0); - jmp(L_2TAG_PACKET_1_0_2); - - bind(L_2TAG_PACKET_23_0_2); - xorpd(xmm0, xmm0); - movl(eax, 16368); - pinsrw(xmm0, eax, 3); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_26_0_2); - xorpd(xmm0, xmm0); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_13_0_2); - addl(eax, 384); - cmpl(eax, 0); - jcc(Assembler::less, L_2TAG_PACKET_41_0_2); - mulsd(xmm5, xmm1); - addsd(xmm0, xmm7); - shrl(rsi, 31); - addpd(xmm3, xmm0); - pshufd(xmm0, xmm3, 238); - addsd(xmm3, xmm0); - movsd(xmm4, Address(tmp, rsi, Address::times_8, 12528)); - mulsd(xmm1, xmm3); - xorpd(xmm0, xmm0); - movl(eax, 16368); - shll(rsi, 15); - orl(eax, rsi); - pinsrw(xmm0, eax, 3); - addsd(xmm5, xmm1); - movl(rsi, Address(rsp, 24)); - mulsd(xmm5, xmm4); - addsd(xmm0, xmm5); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_41_0_2); - movl(rsi, Address(rsp, 24)); - xorpd(xmm0, xmm0); - movl(eax, 16368); - pinsrw(xmm0, eax, 3); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_40_0_2); - xorpd(xmm0, xmm0); - movl(eax, 16368); - pinsrw(xmm0, eax, 3); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_42_0_2); - xorpd(xmm0, xmm0); - movl(eax, 16368); - pinsrw(xmm0, eax, 3); - movl(edx, 26); - jmp(L_2TAG_PACKET_21_0_2); - - bind(L_2TAG_PACKET_11_0_2); - movsd(xmm1, Address(rsp, 16)); - movdqu(xmm2, xmm1); - pextrw(eax, xmm1, 3); - andl(eax, 32752); - cmpl(eax, 32752); - jcc(Assembler::notEqual, L_2TAG_PACKET_43_0_2); - movdl(eax, xmm2); - psrlq(xmm2, 20); - movdl(edx, xmm2); - orl(eax, edx); - jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2); - - bind(L_2TAG_PACKET_43_0_2); - movdl(eax, xmm1); - psrlq(xmm1, 32); - movdl(edx, xmm1); - movl(ecx, edx); - addl(edx, edx); - orl(eax, edx); - jcc(Assembler::equal, L_2TAG_PACKET_42_0_2); - shrl(edx, 21); - cmpl(edx, 1075); - jcc(Assembler::above, L_2TAG_PACKET_44_0_2); - jcc(Assembler::equal, L_2TAG_PACKET_45_0_2); - cmpl(edx, 1023); - jcc(Assembler::below, L_2TAG_PACKET_44_0_2); - movsd(xmm1, Address(rsp, 16)); - movl(eax, 17208); - xorpd(xmm3, xmm3); - pinsrw(xmm3, eax, 3); - movdqu(xmm4, xmm3); - addsd(xmm3, xmm1); - subsd(xmm4, xmm3); - addsd(xmm1, xmm4); - pextrw(eax, xmm1, 3); - andl(eax, 32752); - jcc(Assembler::notEqual, L_2TAG_PACKET_44_0_2); - movdl(eax, xmm3); - andl(eax, 1); - jcc(Assembler::equal, L_2TAG_PACKET_44_0_2); - - bind(L_2TAG_PACKET_46_0_2); - movsd(xmm0, Address(rsp, 8)); - testl(ecx, INT_MIN); - jcc(Assembler::notEqual, L_2TAG_PACKET_47_0_2); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_45_0_2); - movsd(xmm1, Address(rsp, 16)); - movdl(eax, xmm1); - testl(eax, 1); - jcc(Assembler::notEqual, L_2TAG_PACKET_46_0_2); - - bind(L_2TAG_PACKET_44_0_2); - testl(ecx, INT_MIN); - jcc(Assembler::equal, L_2TAG_PACKET_26_0_2); - xorpd(xmm0, xmm0); - - bind(L_2TAG_PACKET_47_0_2); - movl(eax, 16368); - xorpd(xmm1, xmm1); - pinsrw(xmm1, eax, 3); - divsd(xmm1, xmm0); - movdqu(xmm0, xmm1); - movl(edx, 27); - jmp(L_2TAG_PACKET_21_0_2); - - bind(L_2TAG_PACKET_14_0_2); - movsd(xmm2, Address(rsp, 8)); - movsd(xmm6, Address(rsp, 16)); - pextrw(eax, xmm2, 3); - pextrw(edx, xmm6, 3); - movl(ecx, 32752); - andl(ecx, edx); - cmpl(ecx, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_48_0_2); - andl(eax, 32752); - subl(eax, 16368); - xorl(edx, eax); - testl(edx, 32768); - jcc(Assembler::notEqual, L_2TAG_PACKET_49_0_2); - - bind(L_2TAG_PACKET_50_0_2); - movl(eax, 32736); - pinsrw(xmm0, eax, 3); - shrl(rsi, 16); - orl(eax, rsi); - pinsrw(xmm1, eax, 3); - movl(rsi, Address(rsp, 24)); - mulsd(xmm0, xmm1); - - bind(L_2TAG_PACKET_17_0_2); - movl(edx, 24); - - bind(L_2TAG_PACKET_21_0_2); - movsd(Address(rsp, 0), xmm0); - fld_d(Address(rsp, 0)); - jmp(L_2TAG_PACKET_6_0_2); - - bind(L_2TAG_PACKET_49_0_2); - movl(eax, 16); - pinsrw(xmm0, eax, 3); - mulsd(xmm0, xmm0); - testl(rsi, INT_MIN); - jcc(Assembler::equal, L_2TAG_PACKET_51_0_2); - movsd(xmm2, Address(tmp, 12560)); - xorpd(xmm0, xmm2); - - bind(L_2TAG_PACKET_51_0_2); - movl(rsi, Address(rsp, 24)); - movl(edx, 25); - jmp(L_2TAG_PACKET_21_0_2); - - bind(L_2TAG_PACKET_16_0_2); - pextrw(ecx, xmm5, 3); - pextrw(edx, xmm4, 3); - movl(eax, -1); - andl(ecx, 32752); - subl(ecx, 16368); - andl(edx, 32752); - addl(edx, ecx); - movl(ecx, -31); - sarl(edx, 4); - subl(ecx, edx); - jcc(Assembler::lessEqual, L_2TAG_PACKET_52_0_2); - cmpl(ecx, 20); - jcc(Assembler::above, L_2TAG_PACKET_53_0_2); - shll(eax); - - bind(L_2TAG_PACKET_52_0_2); - movdl(xmm0, eax); - psllq(xmm0, 32); - pand(xmm0, xmm5); - subsd(xmm5, xmm0); - addsd(xmm5, xmm1); - mulsd(xmm0, xmm4); - mulsd(xmm5, xmm4); - addsd(xmm0, xmm5); - - bind(L_2TAG_PACKET_53_0_2); - movl(edx, 25); - jmp(L_2TAG_PACKET_21_0_2); - - bind(L_2TAG_PACKET_2_0_2); - movzwl(ecx, Address(rsp, 22)); - movl(edx, INT_MIN); - movdl(xmm1, edx); - xorpd(xmm7, xmm7); - paddd(xmm0, xmm4); - psllq(xmm5, 32); - movdl(edx, xmm0); - psllq(xmm0, 29); - paddq(xmm1, xmm3); - pand(xmm5, xmm1); - andl(ecx, 32752); - cmpl(ecx, 16560); - jcc(Assembler::below, L_2TAG_PACKET_3_0_2); - pand(xmm0, xmm6); - subsd(xmm3, xmm5); - addl(eax, 16351); - shrl(eax, 4); - subl(eax, 1022); - cvtsi2sdl(xmm7, eax); - mulpd(xmm5, xmm0); - movsd(xmm4, Address(tmp, 0)); - mulsd(xmm3, xmm0); - movsd(xmm6, Address(tmp, 0)); - subsd(xmm5, xmm2); - movsd(xmm1, Address(tmp, 8)); - pshufd(xmm2, xmm3, 68); - unpcklpd(xmm5, xmm3); - addsd(xmm3, xmm5); - movsd(xmm0, Address(tmp, 8)); - andl(edx, 16760832); - shrl(edx, 10); - addpd(xmm7, Address(tmp, edx, Address::times_1, -3616)); - mulsd(xmm4, xmm5); - mulsd(xmm0, xmm5); - mulsd(xmm6, xmm2); - mulsd(xmm1, xmm2); - movdqu(xmm2, xmm5); - mulsd(xmm4, xmm5); - addsd(xmm5, xmm0); - movdqu(xmm0, xmm7); - addsd(xmm2, xmm3); - addsd(xmm7, xmm5); - mulsd(xmm6, xmm2); - subsd(xmm0, xmm7); - movdqu(xmm2, xmm7); - addsd(xmm7, xmm4); - addsd(xmm0, xmm5); - subsd(xmm2, xmm7); - addsd(xmm4, xmm2); - pshufd(xmm2, xmm5, 238); - movdqu(xmm5, xmm7); - addsd(xmm7, xmm2); - addsd(xmm4, xmm0); - movdqu(xmm0, Address(tmp, 8272)); - subsd(xmm5, xmm7); - addsd(xmm6, xmm4); - movdqu(xmm4, xmm7); - addsd(xmm5, xmm2); - addsd(xmm7, xmm1); - movdqu(xmm2, Address(tmp, 8336)); - subsd(xmm4, xmm7); - addsd(xmm6, xmm5); - addsd(xmm4, xmm1); - pshufd(xmm5, xmm7, 238); - movdqu(xmm1, xmm7); - addsd(xmm7, xmm5); - subsd(xmm1, xmm7); - addsd(xmm1, xmm5); - movdqu(xmm5, Address(tmp, 8352)); - pshufd(xmm3, xmm3, 68); - addsd(xmm6, xmm4); - addsd(xmm6, xmm1); - movdqu(xmm1, Address(tmp, 8304)); - mulpd(xmm0, xmm3); - mulpd(xmm2, xmm3); - pshufd(xmm4, xmm3, 68); - mulpd(xmm3, xmm3); - addpd(xmm0, xmm1); - addpd(xmm5, xmm2); - mulsd(xmm4, xmm3); - movsd(xmm2, Address(tmp, 16)); - mulpd(xmm3, xmm3); - movsd(xmm1, Address(rsp, 16)); - movzwl(ecx, Address(rsp, 22)); - mulpd(xmm0, xmm4); - pextrw(eax, xmm7, 3); - mulpd(xmm5, xmm4); - mulpd(xmm0, xmm3); - movsd(xmm4, Address(tmp, 8376)); - pand(xmm2, xmm7); - addsd(xmm5, xmm6); - subsd(xmm7, xmm2); - addpd(xmm5, xmm0); - andl(eax, 32752); - subl(eax, 16368); - andl(ecx, 32752); - cmpl(ecx, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_48_0_2); - addl(ecx, eax); - cmpl(ecx, 16576); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_54_0_2); - pshufd(xmm0, xmm5, 238); - pand(xmm4, xmm1); - movdqu(xmm3, xmm1); - addsd(xmm5, xmm0); - subsd(xmm1, xmm4); - xorpd(xmm6, xmm6); - movl(edx, 17080); - pinsrw(xmm6, edx, 3); - addsd(xmm7, xmm5); - mulsd(xmm4, xmm2); - mulsd(xmm1, xmm2); - movdqu(xmm5, xmm6); - mulsd(xmm3, xmm7); - addsd(xmm6, xmm4); - addsd(xmm1, xmm3); - movdqu(xmm7, Address(tmp, 12480)); - movdl(edx, xmm6); - subsd(xmm6, xmm5); - movdqu(xmm3, Address(tmp, 12496)); - movsd(xmm2, Address(tmp, 12512)); - subsd(xmm4, xmm6); - movl(ecx, edx); - andl(edx, 255); - addl(edx, edx); - movdqu(xmm5, Address(tmp, edx, Address::times_8, 8384)); - addsd(xmm4, xmm1); - pextrw(edx, xmm6, 3); - shrl(ecx, 8); - movl(eax, ecx); - shrl(ecx, 1); - subl(eax, ecx); - shll(ecx, 20); - movdl(xmm6, ecx); - pshufd(xmm0, xmm4, 68); - pshufd(xmm1, xmm4, 68); - mulpd(xmm0, xmm0); - mulpd(xmm7, xmm1); - pshufd(xmm6, xmm6, 17); - mulsd(xmm2, xmm4); - andl(edx, 32767); - cmpl(edx, 16529); - jcc(Assembler::above, L_2TAG_PACKET_14_0_2); - mulsd(xmm0, xmm0); - paddd(xmm5, xmm6); - addpd(xmm3, xmm7); - mulsd(xmm2, xmm5); - pshufd(xmm6, xmm5, 238); - mulpd(xmm0, xmm3); - addsd(xmm2, xmm6); - pshufd(xmm3, xmm0, 238); - addl(eax, 1023); - shll(eax, 20); - orl(eax, rsi); - movdl(xmm4, eax); - mulsd(xmm0, xmm5); - mulsd(xmm3, xmm5); - addsd(xmm0, xmm2); - psllq(xmm4, 32); - addsd(xmm0, xmm3); - movdqu(xmm1, xmm0); - addsd(xmm0, xmm5); - movl(rsi, Address(rsp, 24)); - mulsd(xmm0, xmm4); - pextrw(eax, xmm0, 3); - andl(eax, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_16_0_2); - cmpl(eax, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_17_0_2); - - bind(L_2TAG_PACKET_55_0_2); - movsd(Address(rsp, 0), xmm0); - fld_d(Address(rsp, 0)); - jmp(L_2TAG_PACKET_6_0_2); - - bind(L_2TAG_PACKET_48_0_2); - movl(rsi, Address(rsp, 24)); - - bind(L_2TAG_PACKET_56_0_2); - movsd(xmm0, Address(rsp, 8)); - movsd(xmm1, Address(rsp, 16)); - addsd(xmm1, xmm1); - xorpd(xmm2, xmm2); - movl(eax, 49136); - pinsrw(xmm2, eax, 3); - addsd(xmm2, xmm0); - pextrw(eax, xmm2, 3); - cmpl(eax, 0); - jcc(Assembler::notEqual, L_2TAG_PACKET_57_0_2); - xorpd(xmm0, xmm0); - movl(eax, 32760); - pinsrw(xmm0, eax, 3); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_57_0_2); - movdl(edx, xmm1); - movdqu(xmm3, xmm1); - psrlq(xmm3, 20); - movdl(ecx, xmm3); - orl(ecx, edx); - jcc(Assembler::equal, L_2TAG_PACKET_58_0_2); - addsd(xmm1, xmm1); - movdqu(xmm0, xmm1); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_58_0_2); - pextrw(eax, xmm0, 3); - andl(eax, 32752); - pextrw(edx, xmm1, 3); - xorpd(xmm0, xmm0); - subl(eax, 16368); - xorl(eax, edx); - testl(eax, 32768); - jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2); - movl(edx, 32752); - pinsrw(xmm0, edx, 3); - jmp(L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_54_0_2); - pextrw(eax, xmm1, 3); - pextrw(ecx, xmm2, 3); - xorl(eax, ecx); - testl(eax, 32768); - jcc(Assembler::equal, L_2TAG_PACKET_50_0_2); - jmp(L_2TAG_PACKET_49_0_2); - - bind(L_2TAG_PACKET_6_0_2); - movl(tmp, Address(rsp, 64)); - -} - -/******************************************************************************/ -// ALGORITHM DESCRIPTION - SIN() -// --------------------- -// -// 1. RANGE REDUCTION -// -// We perform an initial range reduction from X to r with -// -// X =~= N * pi/32 + r -// -// so that |r| <= pi/64 + epsilon. We restrict inputs to those -// where |N| <= 932560. Beyond this, the range reduction is -// insufficiently accurate. For extremely small inputs, -// denormalization can occur internally, impacting performance. -// This means that the main path is actually only taken for -// 2^-252 <= |X| < 90112. -// -// To avoid branches, we perform the range reduction to full -// accuracy each time. -// -// X - N * (P_1 + P_2 + P_3) -// -// where P_1 and P_2 are 32-bit numbers (so multiplication by N -// is exact) and P_3 is a 53-bit number. Together, these -// approximate pi well enough for all cases in the restricted -// range. -// -// The main reduction sequence is: -// -// y = 32/pi * x -// N = integer(y) -// (computed by adding and subtracting off SHIFTER) -// -// m_1 = N * P_1 -// m_2 = N * P_2 -// r_1 = x - m_1 -// r = r_1 - m_2 -// (this r can be used for most of the calculation) -// -// c_1 = r_1 - r -// m_3 = N * P_3 -// c_2 = c_1 - m_2 -// c = c_2 - m_3 -// -// 2. MAIN ALGORITHM -// -// The algorithm uses a table lookup based on B = M * pi / 32 -// where M = N mod 64. The stored values are: -// sigma closest power of 2 to cos(B) -// C_hl 53-bit cos(B) - sigma -// S_hi + S_lo 2 * 53-bit sin(B) -// -// The computation is organized as follows: -// -// sin(B + r + c) = [sin(B) + sigma * r] + -// r * (cos(B) - sigma) + -// sin(B) * [cos(r + c) - 1] + -// cos(B) * [sin(r + c) - r] -// -// which is approximately: -// -// [S_hi + sigma * r] + -// C_hl * r + -// S_lo + S_hi * [(cos(r) - 1) - r * c] + -// (C_hl + sigma) * [(sin(r) - r) + c] -// -// and this is what is actually computed. We separate this sum -// into four parts: -// -// hi + med + pols + corr -// -// where -// -// hi = S_hi + sigma r -// med = C_hl * r -// pols = S_hi * (cos(r) - 1) + (C_hl + sigma) * (sin(r) - r) -// corr = S_lo + c * ((C_hl + sigma) - S_hi * r) -// -// 3. POLYNOMIAL -// -// The polynomial S_hi * (cos(r) - 1) + (C_hl + sigma) * -// (sin(r) - r) can be rearranged freely, since it is quite -// small, so we exploit parallelism to the fullest. -// -// psc4 = SC_4 * r_1 -// msc4 = psc4 * r -// r2 = r * r -// msc2 = SC_2 * r2 -// r4 = r2 * r2 -// psc3 = SC_3 + msc4 -// psc1 = SC_1 + msc2 -// msc3 = r4 * psc3 -// sincospols = psc1 + msc3 -// pols = sincospols * -// -// -// 4. CORRECTION TERM -// -// This is where the "c" component of the range reduction is -// taken into account; recall that just "r" is used for most of -// the calculation. -// -// -c = m_3 - c_2 -// -d = S_hi * r - (C_hl + sigma) -// corr = -c * -d + S_lo -// -// 5. COMPENSATED SUMMATIONS -// -// The two successive compensated summations add up the high -// and medium parts, leaving just the low parts to add up at -// the end. -// -// rs = sigma * r -// res_int = S_hi + rs -// k_0 = S_hi - res_int -// k_2 = k_0 + rs -// med = C_hl * r -// res_hi = res_int + med -// k_1 = res_int - res_hi -// k_3 = k_1 + med -// -// 6. FINAL SUMMATION -// -// We now add up all the small parts: -// -// res_lo = pols(hi) + pols(lo) + corr + k_1 + k_3 -// -// Now the overall result is just: -// -// res_hi + res_lo -// -// 7. SMALL ARGUMENTS -// -// If |x| < SNN (SNN meaning the smallest normal number), we -// simply perform 0.1111111 cdots 1111 * x. For SNN <= |x|, we -// do 2^-55 * (2^55 * x - x). -// -// Special cases: -// sin(NaN) = quiet NaN, and raise invalid exception -// sin(INF) = NaN and raise invalid exception -// sin(+/-0) = +/-0 -// -/******************************************************************************/ - -ALIGNED_(8) juint _zero_none[] = -{ - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL -}; - -ALIGNED_(4) juint __4onpi_d[] = -{ - 0x6dc9c883UL, 0x3ff45f30UL -}; - -ALIGNED_(4) juint _TWO_32H[] = -{ - 0x00000000UL, 0x41f80000UL -}; - -ALIGNED_(4) juint _pi04_3d[] = -{ - 0x54442d00UL, 0x3fe921fbUL, 0x98cc5180UL, 0x3ce84698UL, 0xcbb5bf6cUL, - 0xb9dfc8f8UL -}; - -ALIGNED_(4) juint _pi04_5d[] = -{ - 0x54400000UL, 0x3fe921fbUL, 0x1a600000UL, 0x3dc0b461UL, 0x2e000000UL, - 0x3b93198aUL, 0x25200000UL, 0x396b839aUL, 0x533e63a0UL, 0x37027044UL -}; - -ALIGNED_(4) juint _SCALE[] = -{ - 0x00000000UL, 0x32600000UL -}; - -ALIGNED_(4) juint _zeros[] = -{ - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x80000000UL -}; - -ALIGNED_(4) juint _pi04_2d[] = -{ - 0x54400000UL, 0x3fe921fbUL, 0x1a626331UL, 0x3dc0b461UL -}; - -ALIGNED_(4) juint _TWO_12H[] = -{ - 0x00000000UL, 0x40b80000UL -}; - -ALIGNED_(2) jushort __4onpi_31l[] = -{ - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x836e, 0xa2f9, - 0x40d8, 0x0000, 0x0000, 0x0000, 0x2a50, 0x9c88, 0x40b7, 0x0000, 0x0000, 0x0000, - 0xabe8, 0xfe13, 0x4099, 0x0000, 0x0000, 0x0000, 0x6ee0, 0xfa9a, 0x4079, 0x0000, - 0x0000, 0x0000, 0x9580, 0xdb62, 0x4058, 0x0000, 0x0000, 0x0000, 0x1c82, 0xc9e2, - 0x403d, 0x0000, 0x0000, 0x0000, 0xb1c0, 0xff28, 0x4019, 0x0000, 0x0000, 0x0000, - 0xef14, 0xaf7a, 0x3ffe, 0x0000, 0x0000, 0x0000, 0x48dc, 0xc36e, 0x3fdf, 0x0000, - 0x0000, 0x0000, 0x3740, 0xe909, 0x3fbe, 0x0000, 0x0000, 0x0000, 0x924a, 0xb801, - 0x3fa2, 0x0000, 0x0000, 0x0000, 0x3a32, 0xdd41, 0x3f83, 0x0000, 0x0000, 0x0000, - 0x8778, 0x873f, 0x3f62, 0x0000, 0x0000, 0x0000, 0x1298, 0xb1cb, 0x3f44, 0x0000, - 0x0000, 0x0000, 0xa208, 0x9cfb, 0x3f26, 0x0000, 0x0000, 0x0000, 0xbaec, 0xd7d4, - 0x3f06, 0x0000, 0x0000, 0x0000, 0xd338, 0x8909, 0x3ee7, 0x0000, 0x0000, 0x0000, - 0x68b8, 0xe04d, 0x3ec7, 0x0000, 0x0000, 0x0000, 0x4e64, 0xdf90, 0x3eaa, 0x0000, - 0x0000, 0x0000, 0xc1a8, 0xeb1c, 0x3e89, 0x0000, 0x0000, 0x0000, 0x2720, 0xce7d, - 0x3e6a, 0x0000, 0x0000, 0x0000, 0x77b8, 0x8bf1, 0x3e4b, 0x0000, 0x0000, 0x0000, - 0xec7e, 0xe4a0, 0x3e2e, 0x0000, 0x0000, 0x0000, 0xffbc, 0xf12f, 0x3e0f, 0x0000, - 0x0000, 0x0000, 0xfdc0, 0xb301, 0x3deb, 0x0000, 0x0000, 0x0000, 0xc5ac, 0x9788, - 0x3dd1, 0x0000, 0x0000, 0x0000, 0x47da, 0x829b, 0x3db2, 0x0000, 0x0000, 0x0000, - 0xd9e4, 0xa6cf, 0x3d93, 0x0000, 0x0000, 0x0000, 0x36e8, 0xf961, 0x3d73, 0x0000, - 0x0000, 0x0000, 0xf668, 0xf463, 0x3d54, 0x0000, 0x0000, 0x0000, 0x5168, 0xf2ff, - 0x3d35, 0x0000, 0x0000, 0x0000, 0x758e, 0xea4f, 0x3d17, 0x0000, 0x0000, 0x0000, - 0xf17a, 0xebe5, 0x3cf8, 0x0000, 0x0000, 0x0000, 0x9cfa, 0x9e83, 0x3cd9, 0x0000, - 0x0000, 0x0000, 0xa4ba, 0xe294, 0x3cba, 0x0000, 0x0000, 0x0000, 0xd7ec, 0x9afe, - 0x3c9a, 0x0000, 0x0000, 0x0000, 0xae80, 0x8fc6, 0x3c79, 0x0000, 0x0000, 0x0000, - 0x3304, 0x8560, 0x3c5c, 0x0000, 0x0000, 0x0000, 0x6d70, 0xdf8f, 0x3c3b, 0x0000, - 0x0000, 0x0000, 0x3ef0, 0xafc3, 0x3c1e, 0x0000, 0x0000, 0x0000, 0xd0d8, 0x826b, - 0x3bfe, 0x0000, 0x0000, 0x0000, 0x1c80, 0xed4f, 0x3bdd, 0x0000, 0x0000, 0x0000, - 0x730c, 0xb0af, 0x3bc1, 0x0000, 0x0000, 0x0000, 0x6660, 0xc219, 0x3ba2, 0x0000, - 0x0000, 0x0000, 0x940c, 0xabe2, 0x3b83, 0x0000, 0x0000, 0x0000, 0xdffc, 0x8408, - 0x3b64, 0x0000, 0x0000, 0x0000, 0x6b98, 0xc402, 0x3b45, 0x0000, 0x0000, 0x0000, - 0x1818, 0x9cc4, 0x3b26, 0x0000, 0x0000, 0x0000, 0x5390, 0xaab6, 0x3b05, 0x0000, - 0x0000, 0x0000, 0xb070, 0xd464, 0x3ae9, 0x0000, 0x0000, 0x0000, 0x231a, 0x9ef0, - 0x3aca, 0x0000, 0x0000, 0x0000, 0x0670, 0xd1f1, 0x3aaa, 0x0000, 0x0000, 0x0000, - 0x7738, 0xd9f3, 0x3a8a, 0x0000, 0x0000, 0x0000, 0xa834, 0x8092, 0x3a6c, 0x0000, - 0x0000, 0x0000, 0xb45c, 0xce23, 0x3a4d, 0x0000, 0x0000, 0x0000, 0x36e8, 0xb0e5, - 0x3a2d, 0x0000, 0x0000, 0x0000, 0xd156, 0xaf44, 0x3a10, 0x0000, 0x0000, 0x0000, - 0x9f52, 0x8c82, 0x39f1, 0x0000, 0x0000, 0x0000, 0x829c, 0xff83, 0x39d1, 0x0000, - 0x0000, 0x0000, 0x7d06, 0xefc6, 0x39b3, 0x0000, 0x0000, 0x0000, 0x93e0, 0xb0b7, - 0x3992, 0x0000, 0x0000, 0x0000, 0xedde, 0xc193, 0x3975, 0x0000, 0x0000, 0x0000, - 0xbbc0, 0xcf49, 0x3952, 0x0000, 0x0000, 0x0000, 0xbdf0, 0xd63c, 0x3937, 0x0000, - 0x0000, 0x0000, 0x1f34, 0x9f3a, 0x3918, 0x0000, 0x0000, 0x0000, 0x3f8e, 0xe579, - 0x38f9, 0x0000, 0x0000, 0x0000, 0x90c8, 0xc3f8, 0x38d9, 0x0000, 0x0000, 0x0000, - 0x48c0, 0xf8f8, 0x38b7, 0x0000, 0x0000, 0x0000, 0xed56, 0xafa6, 0x389c, 0x0000, - 0x0000, 0x0000, 0x8218, 0xb969, 0x387d, 0x0000, 0x0000, 0x0000, 0x1852, 0xec57, - 0x385e, 0x0000, 0x0000, 0x0000, 0x670c, 0xd674, 0x383e, 0x0000, 0x0000, 0x0000, - 0xad40, 0xc2c4, 0x3820, 0x0000, 0x0000, 0x0000, 0x2e80, 0xa696, 0x3801, 0x0000, - 0x0000, 0x0000, 0xd800, 0xc467, 0x37dc, 0x0000, 0x0000, 0x0000, 0x3c72, 0xc5ae, - 0x37c3, 0x0000, 0x0000, 0x0000, 0xb006, 0xac69, 0x37a4, 0x0000, 0x0000, 0x0000, - 0x34a0, 0x8cdf, 0x3782, 0x0000, 0x0000, 0x0000, 0x9ed2, 0xd25e, 0x3766, 0x0000, - 0x0000, 0x0000, 0x6fec, 0xaaaa, 0x3747, 0x0000, 0x0000, 0x0000, 0x6040, 0xfb5c, - 0x3726, 0x0000, 0x0000, 0x0000, 0x764c, 0xa3fc, 0x3708, 0x0000, 0x0000, 0x0000, - 0xb254, 0x954e, 0x36e9, 0x0000, 0x0000, 0x0000, 0x3e1c, 0xf5dc, 0x36ca, 0x0000, - 0x0000, 0x0000, 0x7b06, 0xc635, 0x36ac, 0x0000, 0x0000, 0x0000, 0xa8ba, 0xd738, - 0x368d, 0x0000, 0x0000, 0x0000, 0x06cc, 0xb24e, 0x366d, 0x0000, 0x0000, 0x0000, - 0x7108, 0xac76, 0x364f, 0x0000, 0x0000, 0x0000, 0x2324, 0xa7cb, 0x3630, 0x0000, - 0x0000, 0x0000, 0xac40, 0xef15, 0x360f, 0x0000, 0x0000, 0x0000, 0xae46, 0xd516, - 0x35f2, 0x0000, 0x0000, 0x0000, 0x615e, 0xe003, 0x35d3, 0x0000, 0x0000, 0x0000, - 0x0cf0, 0xefe7, 0x35b1, 0x0000, 0x0000, 0x0000, 0xfb50, 0xf98c, 0x3595, 0x0000, - 0x0000, 0x0000, 0x0abc, 0xf333, 0x3575, 0x0000, 0x0000, 0x0000, 0xdd60, 0xca3f, - 0x3555, 0x0000, 0x0000, 0x0000, 0x7eb6, 0xd87f, 0x3538, 0x0000, 0x0000, 0x0000, - 0x44f4, 0xb291, 0x3519, 0x0000, 0x0000, 0x0000, 0xff80, 0xc982, 0x34f6, 0x0000, - 0x0000, 0x0000, 0x9de0, 0xd9b8, 0x34db, 0x0000, 0x0000, 0x0000, 0xcd42, 0x9366, - 0x34bc, 0x0000, 0x0000, 0x0000, 0xbef0, 0xfaee, 0x349d, 0x0000, 0x0000, 0x0000, - 0xdac4, 0xb6f1, 0x347d, 0x0000, 0x0000, 0x0000, 0xf140, 0x94de, 0x345d, 0x0000, - 0x0000, 0x0000, 0xa218, 0x8b4b, 0x343e, 0x0000, 0x0000, 0x0000, 0x6380, 0xa135, - 0x341e, 0x0000, 0x0000, 0x0000, 0xb184, 0x8cb2, 0x3402, 0x0000, 0x0000, 0x0000, - 0x196e, 0xdc61, 0x33e3, 0x0000, 0x0000, 0x0000, 0x0c00, 0xde05, 0x33c4, 0x0000, - 0x0000, 0x0000, 0xef9a, 0xbd38, 0x33a5, 0x0000, 0x0000, 0x0000, 0xc1a0, 0xdf00, - 0x3385, 0x0000, 0x0000, 0x0000, 0x1090, 0x9973, 0x3365, 0x0000, 0x0000, 0x0000, - 0x4882, 0x8301, 0x3348, 0x0000, 0x0000, 0x0000, 0x7abe, 0xadc7, 0x3329, 0x0000, - 0x0000, 0x0000, 0x7cba, 0xec2b, 0x330a, 0x0000, 0x0000, 0x0000, 0xa520, 0x8f21, - 0x32e9, 0x0000, 0x0000, 0x0000, 0x710c, 0x8d36, 0x32cc, 0x0000, 0x0000, 0x0000, - 0x5212, 0xc6ed, 0x32ad, 0x0000, 0x0000, 0x0000, 0x7308, 0xfd76, 0x328d, 0x0000, - 0x0000, 0x0000, 0x5014, 0xd548, 0x326f, 0x0000, 0x0000, 0x0000, 0xd3f2, 0xb499, - 0x3250, 0x0000, 0x0000, 0x0000, 0x7f74, 0xa606, 0x3230, 0x0000, 0x0000, 0x0000, - 0xf0a8, 0xd720, 0x3212, 0x0000, 0x0000, 0x0000, 0x185c, 0xe20f, 0x31f2, 0x0000, - 0x0000, 0x0000, 0xa5a8, 0x8738, 0x31d4, 0x0000, 0x0000, 0x0000, 0xdd74, 0xcafb, - 0x31b4, 0x0000, 0x0000, 0x0000, 0x98b6, 0xbd8e, 0x3196, 0x0000, 0x0000, 0x0000, - 0xe9de, 0x977f, 0x3177, 0x0000, 0x0000, 0x0000, 0x67c0, 0x818d, 0x3158, 0x0000, - 0x0000, 0x0000, 0xe52a, 0x9322, 0x3139, 0x0000, 0x0000, 0x0000, 0xe568, 0x9b6c, - 0x3119, 0x0000, 0x0000, 0x0000, 0x2358, 0xaa0a, 0x30fa, 0x0000, 0x0000, 0x0000, - 0xe480, 0xe13b, 0x30d9, 0x0000, 0x0000, 0x0000, 0x3024, 0x90a1, 0x30bd, 0x0000, - 0x0000, 0x0000, 0x9620, 0xda30, 0x309d, 0x0000, 0x0000, 0x0000, 0x898a, 0xb388, - 0x307f, 0x0000, 0x0000, 0x0000, 0xb24c, 0xc891, 0x3060, 0x0000, 0x0000, 0x0000, - 0x8056, 0xf98b, 0x3041, 0x0000, 0x0000, 0x0000, 0x72a4, 0xa1ea, 0x3021, 0x0000, - 0x0000, 0x0000, 0x6af8, 0x9488, 0x3001, 0x0000, 0x0000, 0x0000, 0xe00c, 0xdfcb, - 0x2fe4, 0x0000, 0x0000, 0x0000, 0xeeec, 0xc941, 0x2fc4, 0x0000, 0x0000, 0x0000, - 0x53e0, 0xe70f, 0x2fa4, 0x0000, 0x0000, 0x0000, 0x8f60, 0x9c07, 0x2f85, 0x0000, - 0x0000, 0x0000, 0xb328, 0xc3e7, 0x2f68, 0x0000, 0x0000, 0x0000, 0x9404, 0xf8c7, - 0x2f48, 0x0000, 0x0000, 0x0000, 0x38e0, 0xc99f, 0x2f29, 0x0000, 0x0000, 0x0000, - 0x9778, 0xd984, 0x2f09, 0x0000, 0x0000, 0x0000, 0xe700, 0xd142, 0x2eea, 0x0000, - 0x0000, 0x0000, 0xd904, 0x9443, 0x2ecd, 0x0000, 0x0000, 0x0000, 0xd4ba, 0xae7e, - 0x2eae, 0x0000, 0x0000, 0x0000, 0x8e5e, 0x8524, 0x2e8f, 0x0000, 0x0000, 0x0000, - 0xb550, 0xc9ed, 0x2e6e, 0x0000, 0x0000, 0x0000, 0x53b8, 0x8648, 0x2e51, 0x0000, - 0x0000, 0x0000, 0xdae4, 0x87f9, 0x2e32, 0x0000, 0x0000, 0x0000, 0x2942, 0xd966, - 0x2e13, 0x0000, 0x0000, 0x0000, 0x4f28, 0xcf3c, 0x2df3, 0x0000, 0x0000, 0x0000, - 0xfa40, 0xc4ef, 0x2dd1, 0x0000, 0x0000, 0x0000, 0x4424, 0xbca7, 0x2db5, 0x0000, - 0x0000, 0x0000, 0x2e62, 0xcdc5, 0x2d97, 0x0000, 0x0000, 0x0000, 0xed88, 0x996b, - 0x2d78, 0x0000, 0x0000, 0x0000, 0x7c30, 0xd97d, 0x2d56, 0x0000, 0x0000, 0x0000, - 0xed26, 0xbf6e, 0x2d3a, 0x0000, 0x0000, 0x0000, 0x2918, 0x921b, 0x2d1a, 0x0000, - 0x0000, 0x0000, 0x4e24, 0xe84e, 0x2cfb, 0x0000, 0x0000, 0x0000, 0x6dc0, 0x92ec, - 0x2cdd, 0x0000, 0x0000, 0x0000, 0x4f2c, 0xacf8, 0x2cbd, 0x0000, 0x0000, 0x0000, - 0xc634, 0xf094, 0x2c9e, 0x0000, 0x0000, 0x0000, 0xdc70, 0xe5d3, 0x2c7e, 0x0000, - 0x0000, 0x0000, 0x2180, 0xa600, 0x2c5b, 0x0000, 0x0000, 0x0000, 0x8480, 0xd680, - 0x2c3c, 0x0000, 0x0000, 0x0000, 0x8b24, 0xd63b, 0x2c22, 0x0000, 0x0000, 0x0000, - 0x02e0, 0xaa47, 0x2c00, 0x0000, 0x0000, 0x0000, 0x9ad0, 0xee84, 0x2be3, 0x0000, - 0x0000, 0x0000, 0xf7dc, 0xf699, 0x2bc6, 0x0000, 0x0000, 0x0000, 0xddde, 0xe490, - 0x2ba7, 0x0000, 0x0000, 0x0000, 0x34a0, 0xb4fd, 0x2b85, 0x0000, 0x0000, 0x0000, - 0x91b4, 0x8ef6, 0x2b68, 0x0000, 0x0000, 0x0000, 0xa3e0, 0xa2a7, 0x2b47, 0x0000, - 0x0000, 0x0000, 0xcce4, 0x82b3, 0x2b2a, 0x0000, 0x0000, 0x0000, 0xe4be, 0x8207, - 0x2b0c, 0x0000, 0x0000, 0x0000, 0x1d92, 0xab43, 0x2aed, 0x0000, 0x0000, 0x0000, - 0xe818, 0xf9f6, 0x2acd, 0x0000, 0x0000, 0x0000, 0xff12, 0xba80, 0x2aaf, 0x0000, - 0x0000, 0x0000, 0x5254, 0x8529, 0x2a90, 0x0000, 0x0000, 0x0000, 0x1b88, 0xe032, - 0x2a71, 0x0000, 0x0000, 0x0000, 0x3248, 0xd86d, 0x2a50, 0x0000, 0x0000, 0x0000, - 0x3140, 0xc9d5, 0x2a2e, 0x0000, 0x0000, 0x0000, 0x14e6, 0xbd47, 0x2a14, 0x0000, - 0x0000, 0x0000, 0x5c10, 0xe544, 0x29f4, 0x0000, 0x0000, 0x0000, 0x9f50, 0x90b6, - 0x29d4, 0x0000, 0x0000, 0x0000, 0x9850, 0xab55, 0x29b6, 0x0000, 0x0000, 0x0000, - 0x2750, 0x9d07, 0x2998, 0x0000, 0x0000, 0x0000, 0x6700, 0x8bbb, 0x2973, 0x0000, - 0x0000, 0x0000, 0x5dba, 0xed31, 0x295a, 0x0000, 0x0000, 0x0000, 0x61dc, 0x85fe, - 0x293a, 0x0000, 0x0000, 0x0000, 0x9ba2, 0xd6b4, 0x291c, 0x0000, 0x0000, 0x0000, - 0x2d30, 0xe3a5, 0x28fb, 0x0000, 0x0000, 0x0000, 0x6630, 0xb566, 0x28dd, 0x0000, - 0x0000, 0x0000, 0x5ad4, 0xa829, 0x28bf, 0x0000, 0x0000, 0x0000, 0x89d8, 0xe290, - 0x28a0, 0x0000, 0x0000, 0x0000, 0x3916, 0xc428, 0x2881, 0x0000, 0x0000, 0x0000, - 0x0490, 0xbea4, 0x2860, 0x0000, 0x0000, 0x0000, 0xee06, 0x80ee, 0x2843, 0x0000, - 0x0000, 0x0000, 0xfc00, 0xf327, 0x2820, 0x0000, 0x0000, 0x0000, 0xea40, 0xa871, - 0x2800, 0x0000, 0x0000, 0x0000, 0x63d8, 0x9c26, 0x27e4, 0x0000, 0x0000, 0x0000, - 0x07ba, 0xc0c9, 0x27c7, 0x0000, 0x0000, 0x0000, 0x3fa2, 0x9797, 0x27a8, 0x0000, - 0x0000, 0x0000, 0x21c6, 0xfeca, 0x2789, 0x0000, 0x0000, 0x0000, 0xde40, 0x860d, - 0x2768, 0x0000, 0x0000, 0x0000, 0x9cc8, 0x98ce, 0x2749, 0x0000, 0x0000, 0x0000, - 0x3778, 0xa31c, 0x272a, 0x0000, 0x0000, 0x0000, 0xe778, 0xf6e2, 0x270b, 0x0000, - 0x0000, 0x0000, 0x59b8, 0xf841, 0x26ed, 0x0000, 0x0000, 0x0000, 0x02e0, 0xad04, - 0x26cd, 0x0000, 0x0000, 0x0000, 0x5a92, 0x9380, 0x26b0, 0x0000, 0x0000, 0x0000, - 0xc740, 0x8886, 0x268d, 0x0000, 0x0000, 0x0000, 0x0680, 0xfaf8, 0x266c, 0x0000, - 0x0000, 0x0000, 0xfb60, 0x897f, 0x2653, 0x0000, 0x0000, 0x0000, 0x8760, 0xf903, - 0x2634, 0x0000, 0x0000, 0x0000, 0xad2a, 0xc2c8, 0x2615, 0x0000, 0x0000, 0x0000, - 0x2d86, 0x8aef, 0x25f6, 0x0000, 0x0000, 0x0000, 0x1ef4, 0xe627, 0x25d6, 0x0000, - 0x0000, 0x0000, 0x09e4, 0x8020, 0x25b7, 0x0000, 0x0000, 0x0000, 0x7548, 0xd227, - 0x2598, 0x0000, 0x0000, 0x0000, 0x75dc, 0xfb5b, 0x2579, 0x0000, 0x0000, 0x0000, - 0xea84, 0xc8b6, 0x255a, 0x0000, 0x0000, 0x0000, 0xe4d0, 0x8145, 0x253b, 0x0000, - 0x0000, 0x0000, 0x3640, 0x9768, 0x251c, 0x0000, 0x0000, 0x0000, 0x246a, 0xccec, - 0x24fe, 0x0000, 0x0000, 0x0000, 0x51d0, 0xa075, 0x24dd, 0x0000, 0x0000, 0x0000, - 0x4638, 0xa385, 0x24bf, 0x0000, 0x0000, 0x0000, 0xd788, 0xd776, 0x24a1, 0x0000, - 0x0000, 0x0000, 0x1370, 0x8997, 0x2482, 0x0000, 0x0000, 0x0000, 0x1e88, 0x9b67, - 0x2462, 0x0000, 0x0000, 0x0000, 0x6c08, 0xd975, 0x2444, 0x0000, 0x0000, 0x0000, - 0xfdb0, 0xcfc0, 0x2422, 0x0000, 0x0000, 0x0000, 0x3100, 0xc026, 0x2406, 0x0000, - 0x0000, 0x0000, 0xc5b4, 0xae64, 0x23e6, 0x0000, 0x0000, 0x0000, 0x2280, 0xf687, - 0x23c3, 0x0000, 0x0000, 0x0000, 0x2de0, 0x9006, 0x23a9, 0x0000, 0x0000, 0x0000, - 0x24bc, 0xf631, 0x238a, 0x0000, 0x0000, 0x0000, 0xb8d4, 0xa975, 0x236b, 0x0000, - 0x0000, 0x0000, 0xd9a4, 0xb949, 0x234b, 0x0000, 0x0000, 0x0000, 0xb54e, 0xbd39, - 0x232d, 0x0000, 0x0000, 0x0000, 0x4aac, 0x9a52, 0x230e, 0x0000, 0x0000, 0x0000, - 0xbbbc, 0xd085, 0x22ef, 0x0000, 0x0000, 0x0000, 0xdf18, 0xc633, 0x22cf, 0x0000, - 0x0000, 0x0000, 0x16d0, 0xeca5, 0x22af, 0x0000, 0x0000, 0x0000, 0xf2a0, 0xdf6f, - 0x228e, 0x0000, 0x0000, 0x0000, 0x8c44, 0xe86b, 0x2272, 0x0000, 0x0000, 0x0000, - 0x35c0, 0xbbf4, 0x2253, 0x0000, 0x0000, 0x0000, 0x0c40, 0xdafb, 0x2230, 0x0000, - 0x0000, 0x0000, 0x92dc, 0x9935, 0x2216, 0x0000, 0x0000, 0x0000, 0x0ca0, 0xbda6, - 0x21f3, 0x0000, 0x0000, 0x0000, 0x5958, 0xa6fd, 0x21d6, 0x0000, 0x0000, 0x0000, - 0xa3dc, 0x9d7f, 0x21b9, 0x0000, 0x0000, 0x0000, 0x79dc, 0xfcb5, 0x2199, 0x0000, - 0x0000, 0x0000, 0xf264, 0xcebb, 0x217b, 0x0000, 0x0000, 0x0000, 0x0abe, 0x8308, - 0x215c, 0x0000, 0x0000, 0x0000, 0x30ae, 0xb463, 0x213d, 0x0000, 0x0000, 0x0000, - 0x6228, 0xb040, 0x211c, 0x0000, 0x0000, 0x0000, 0xc9b2, 0xf43b, 0x20ff, 0x0000, - 0x0000, 0x0000, 0x3d8e, 0xa4b3, 0x20e0, 0x0000, 0x0000, 0x0000, 0x84e6, 0x8dab, - 0x20c1, 0x0000, 0x0000, 0x0000, 0xa124, 0x9b74, 0x20a1, 0x0000, 0x0000, 0x0000, - 0xc276, 0xd497, 0x2083, 0x0000, 0x0000, 0x0000, 0x6354, 0xa466, 0x2063, 0x0000, - 0x0000, 0x0000, 0x8654, 0xaf0a, 0x2044, 0x0000, 0x0000, 0x0000, 0x1d20, 0xfa5c, - 0x2024, 0x0000, 0x0000, 0x0000, 0xbcd0, 0xf3f0, 0x2004, 0x0000, 0x0000, 0x0000, - 0xedf0, 0xf0b6, 0x1fe7, 0x0000, 0x0000, 0x0000, 0x45bc, 0x9182, 0x1fc9, 0x0000, - 0x0000, 0x0000, 0xe254, 0xdc85, 0x1faa, 0x0000, 0x0000, 0x0000, 0xb898, 0xe9b1, - 0x1f8a, 0x0000, 0x0000, 0x0000, 0x0ebe, 0xe6f0, 0x1f6c, 0x0000, 0x0000, 0x0000, - 0xa9b8, 0xf584, 0x1f4c, 0x0000, 0x0000, 0x0000, 0x12e8, 0xdf6b, 0x1f2e, 0x0000, - 0x0000, 0x0000, 0x9f9e, 0xcd55, 0x1f0f, 0x0000, 0x0000, 0x0000, 0x05a0, 0xec3a, - 0x1eef, 0x0000, 0x0000, 0x0000, 0xd8e0, 0x96f8, 0x1ed1, 0x0000, 0x0000, 0x0000, - 0x3bd4, 0xccc6, 0x1eb1, 0x0000, 0x0000, 0x0000, 0x4910, 0xb87b, 0x1e93, 0x0000, - 0x0000, 0x0000, 0xbefc, 0xd40b, 0x1e73, 0x0000, 0x0000, 0x0000, 0x317e, 0xa406, - 0x1e55, 0x0000, 0x0000, 0x0000, 0x6bb2, 0xc2b2, 0x1e36, 0x0000, 0x0000, 0x0000, - 0xb87e, 0xbb78, 0x1e17, 0x0000, 0x0000, 0x0000, 0xa03c, 0xdbbd, 0x1df7, 0x0000, - 0x0000, 0x0000, 0x5b6c, 0xe3c8, 0x1dd9, 0x0000, 0x0000, 0x0000, 0x8968, 0xca8e, - 0x1dba, 0x0000, 0x0000, 0x0000, 0xc024, 0xe6ab, 0x1d9a, 0x0000, 0x0000, 0x0000, - 0x4110, 0xd4eb, 0x1d7a, 0x0000, 0x0000, 0x0000, 0xa168, 0xbdb5, 0x1d5d, 0x0000, - 0x0000, 0x0000, 0x012e, 0xa5fa, 0x1d3e, 0x0000, 0x0000, 0x0000, 0x6838, 0x9c1f, - 0x1d1e, 0x0000, 0x0000, 0x0000, 0xa158, 0xaa76, 0x1d00, 0x0000, 0x0000, 0x0000, - 0x090a, 0xbd95, 0x1ce1, 0x0000, 0x0000, 0x0000, 0xf73e, 0x8b6d, 0x1cc2, 0x0000, - 0x0000, 0x0000, 0x5fda, 0xbcbf, 0x1ca3, 0x0000, 0x0000, 0x0000, 0xdbe8, 0xb89f, - 0x1c84, 0x0000, 0x0000, 0x0000, 0x6e4c, 0x96c7, 0x1c64, 0x0000, 0x0000, 0x0000, - 0x19c2, 0xf2a4, 0x1c46, 0x0000, 0x0000, 0x0000, 0xb800, 0xf855, 0x1c1e, 0x0000, - 0x0000, 0x0000, 0x87fc, 0x85ff, 0x1c08, 0x0000, 0x0000, 0x0000, 0x1418, 0x839f, - 0x1be9, 0x0000, 0x0000, 0x0000, 0x6186, 0xd9d8, 0x1bca, 0x0000, 0x0000, 0x0000, - 0xf500, 0xabaa, 0x1ba6, 0x0000, 0x0000, 0x0000, 0x7b36, 0xdafe, 0x1b8c, 0x0000, - 0x0000, 0x0000, 0xf394, 0xe6d8, 0x1b6c, 0x0000, 0x0000, 0x0000, 0x6efc, 0x9e55, - 0x1b4e, 0x0000, 0x0000, 0x0000, 0x5e10, 0xc523, 0x1b2e, 0x0000, 0x0000, 0x0000, - 0x8210, 0xb6f9, 0x1b0d, 0x0000, 0x0000, 0x0000, 0x9ab0, 0x96e3, 0x1af1, 0x0000, - 0x0000, 0x0000, 0x3864, 0x92e7, 0x1ad1, 0x0000, 0x0000, 0x0000, 0x9878, 0xdc65, - 0x1ab1, 0x0000, 0x0000, 0x0000, 0xfa20, 0xd6cb, 0x1a94, 0x0000, 0x0000, 0x0000, - 0x6c00, 0xa4e4, 0x1a70, 0x0000, 0x0000, 0x0000, 0xab40, 0xb41b, 0x1a53, 0x0000, - 0x0000, 0x0000, 0x43a4, 0x8ede, 0x1a37, 0x0000, 0x0000, 0x0000, 0x22e0, 0x9314, - 0x1a15, 0x0000, 0x0000, 0x0000, 0x6170, 0xb949, 0x19f8, 0x0000, 0x0000, 0x0000, - 0x6b00, 0xe056, 0x19d8, 0x0000, 0x0000, 0x0000, 0x9ba8, 0xa94c, 0x19b9, 0x0000, - 0x0000, 0x0000, 0xfaa0, 0xaa16, 0x199b, 0x0000, 0x0000, 0x0000, 0x899a, 0xf627, - 0x197d, 0x0000, 0x0000, 0x0000, 0x9f20, 0xfb70, 0x195d, 0x0000, 0x0000, 0x0000, - 0xa4b8, 0xc176, 0x193e, 0x0000, 0x0000, 0x0000, 0xb21c, 0x85c3, 0x1920, 0x0000, - 0x0000, 0x0000, 0x50d2, 0x9b19, 0x1901, 0x0000, 0x0000, 0x0000, 0xd4b0, 0xb708, - 0x18e0, 0x0000, 0x0000, 0x0000, 0xfb88, 0xf510, 0x18c1, 0x0000, 0x0000, 0x0000, - 0x31ec, 0xdc8d, 0x18a3, 0x0000, 0x0000, 0x0000, 0x3c00, 0xbff9, 0x1885, 0x0000, - 0x0000, 0x0000, 0x5020, 0xc30b, 0x1862, 0x0000, 0x0000, 0x0000, 0xd4f0, 0xda0c, - 0x1844, 0x0000, 0x0000, 0x0000, 0x20d2, 0x99a5, 0x1828, 0x0000, 0x0000, 0x0000, - 0x852e, 0xd159, 0x1809, 0x0000, 0x0000, 0x0000, 0x7cd8, 0x97a1, 0x17e9, 0x0000, - 0x0000, 0x0000, 0x423a, 0x997b, 0x17cb, 0x0000, 0x0000, 0x0000, 0xc1c0, 0xbe7d, - 0x17a8, 0x0000, 0x0000, 0x0000, 0xe8bc, 0xdcdd, 0x178d, 0x0000, 0x0000, 0x0000, - 0x8b28, 0xae06, 0x176e, 0x0000, 0x0000, 0x0000, 0x102e, 0xb8d4, 0x174f, 0x0000, - 0x0000, 0x0000, 0xaa00, 0xaa5c, 0x172f, 0x0000, 0x0000, 0x0000, 0x51f0, 0x9fc0, - 0x170e, 0x0000, 0x0000, 0x0000, 0xf858, 0xe181, 0x16f2, 0x0000, 0x0000, 0x0000, - 0x91a8, 0x8162, 0x16d3, 0x0000, 0x0000, 0x0000, 0x5f40, 0xcb6f, 0x16b1, 0x0000, - 0x0000, 0x0000, 0xbb50, 0xe55f, 0x1693, 0x0000, 0x0000, 0x0000, 0xacd2, 0xd895, - 0x1676, 0x0000, 0x0000, 0x0000, 0xef30, 0x97bf, 0x1654, 0x0000, 0x0000, 0x0000, - 0xf700, 0xb3d7, 0x1633, 0x0000, 0x0000, 0x0000, 0x3454, 0xa7b5, 0x1619, 0x0000, - 0x0000, 0x0000, 0x6b00, 0xa929, 0x15f6, 0x0000, 0x0000, 0x0000, 0x9f04, 0x89f7, - 0x15db, 0x0000, 0x0000, 0x0000, 0xad78, 0xd985, 0x15bc, 0x0000, 0x0000, 0x0000, - 0xa46a, 0xae3f, 0x159d, 0x0000, 0x0000, 0x0000, 0x63a0, 0xd0da, 0x157c, 0x0000, - 0x0000, 0x0000, 0x5e90, 0x817d, 0x155e, 0x0000, 0x0000, 0x0000, 0x1494, 0xb13f, - 0x1540, 0x0000, 0x0000, 0x0000, 0x0090, 0x9c40, 0x1521, 0x0000, 0x0000, 0x0000, - 0xdd70, 0xcc86, 0x1500, 0x0000, 0x0000, 0x0000, 0x64f8, 0xdb6f, 0x14e1, 0x0000, - 0x0000, 0x0000, 0xe22c, 0xac17, 0x14c3, 0x0000, 0x0000, 0x0000, 0x60e0, 0xa9ad, - 0x14a3, 0x0000, 0x0000, 0x0000, 0x4640, 0xd658, 0x1481, 0x0000, 0x0000, 0x0000, - 0x6490, 0xa181, 0x1467, 0x0000, 0x0000, 0x0000, 0x1df4, 0xaaa2, 0x1447, 0x0000, - 0x0000, 0x0000, 0xb94a, 0x8f61, 0x1429, 0x0000, 0x0000, 0x0000, 0x5198, 0x9d83, - 0x1409, 0x0000, 0x0000, 0x0000, 0x0f7a, 0xa818, 0x13eb, 0x0000, 0x0000, 0x0000, - 0xc45e, 0xc06c, 0x13cc, 0x0000, 0x0000, 0x0000, 0x4ec0, 0xfa29, 0x13a8, 0x0000, - 0x0000, 0x0000, 0x6418, 0x8cad, 0x138c, 0x0000, 0x0000, 0x0000, 0xbcc8, 0xe7d1, - 0x136f, 0x0000, 0x0000, 0x0000, 0xc934, 0xf9b0, 0x134f, 0x0000, 0x0000, 0x0000, - 0x6ce0, 0x98df, 0x1331, 0x0000, 0x0000, 0x0000, 0x3516, 0xe5e9, 0x1312, 0x0000, - 0x0000, 0x0000, 0xc6c0, 0xef8b, 0x12ef, 0x0000, 0x0000, 0x0000, 0xaf02, 0x913d, - 0x12d4, 0x0000, 0x0000, 0x0000, 0xd230, 0xe1d5, 0x12b5, 0x0000, 0x0000, 0x0000, - 0xfba8, 0xc232, 0x1295, 0x0000, 0x0000, 0x0000, 0x7ba4, 0xabeb, 0x1277, 0x0000, - 0x0000, 0x0000, 0x6e5c, 0xc692, 0x1258, 0x0000, 0x0000, 0x0000, 0x76a2, 0x9756, - 0x1239, 0x0000, 0x0000, 0x0000, 0xe180, 0xe423, 0x1214, 0x0000, 0x0000, 0x0000, - 0x8c3c, 0x90f8, 0x11fb, 0x0000, 0x0000, 0x0000, 0x9f3c, 0x9fd2, 0x11dc, 0x0000, - 0x0000, 0x0000, 0x53e0, 0xb73e, 0x11bd, 0x0000, 0x0000, 0x0000, 0x45be, 0x88d6, - 0x119e, 0x0000, 0x0000, 0x0000, 0x111a, 0x8bc0, 0x117f, 0x0000, 0x0000, 0x0000, - 0xe26a, 0xd7ff, 0x1160, 0x0000, 0x0000, 0x0000, 0xfb60, 0xdd8d, 0x113f, 0x0000, - 0x0000, 0x0000, 0x9370, 0xc108, 0x1120, 0x0000, 0x0000, 0x0000, 0x9654, 0x8baf, - 0x1103, 0x0000, 0x0000, 0x0000, 0xd6ec, 0xd6b9, 0x10e4, 0x0000, 0x0000, 0x0000, - 0x23e4, 0xd7b7, 0x10c4, 0x0000, 0x0000, 0x0000, 0x1aa6, 0xa847, 0x10a6, 0x0000, - 0x0000, 0x0000, 0xbee6, 0x9fef, 0x1087, 0x0000, 0x0000, 0x0000, 0x26d0, 0xa6eb, - 0x1066, 0x0000, 0x0000, 0x0000, 0x5b86, 0xa880, 0x1049, 0x0000, 0x0000, 0x0000, - 0x125c, 0xd971, 0x1029, 0x0000, 0x0000, 0x0000, 0x1f78, 0x9d18, 0x100a, 0x0000, - 0x0000, 0x0000, 0x0e84, 0xb15b, 0x0feb, 0x0000, 0x0000, 0x0000, 0xd0c0, 0xc150, - 0x0fcc, 0x0000, 0x0000, 0x0000, 0xa330, 0xc40c, 0x0fad, 0x0000, 0x0000, 0x0000, - 0x5202, 0xfc2c, 0x0f8f, 0x0000, 0x0000, 0x0000, 0x3f7c, 0xecf5, 0x0f6f, 0x0000, - 0x0000, 0x0000, 0xef44, 0xfdfd, 0x0f50, 0x0000, 0x0000, 0x0000, 0x3f6c, 0xab1b, - 0x0f31, 0x0000, 0x0000, 0x0000, 0xf658, 0x89ec, 0x0f11, 0x0000, 0x0000, 0x0000, - 0xbfc8, 0x9ba8, 0x0ef4, 0x0000, 0x0000, 0x0000, 0x3d40, 0xbe21, 0x0ed5, 0x0000, - 0x0000, 0x0000, 0xbbc4, 0xc70d, 0x0eb6, 0x0000, 0x0000, 0x0000, 0x5158, 0xdb16, - 0x0e96, 0x0000, 0x0000, 0x0000, 0xb5a8, 0xa8d8, 0x0e78, 0x0000, 0x0000, 0x0000, - 0xcccc, 0xb40e, 0x0e58, 0x0000, 0x0000, 0x0000, 0x448c, 0xcb62, 0x0e3a, 0x0000, - 0x0000, 0x0000, 0xf12a, 0x8aed, 0x0e1b, 0x0000, 0x0000, 0x0000, 0x79d0, 0xc59c, - 0x0dfb, 0x0000, 0x0000, 0x0000, 0x06b4, 0xcdc9, 0x0ddd, 0x0000, 0x0000, 0x0000, - 0xae70, 0xa979, 0x0dbe, 0x0000, 0x0000, 0x0000, 0x317c, 0xa8fb, 0x0d9e, 0x0000, - 0x0000, 0x0000, 0x5fe0, 0x8a50, 0x0d7d, 0x0000, 0x0000, 0x0000, 0x70b6, 0xfdfa, - 0x0d61, 0x0000, 0x0000, 0x0000, 0x1640, 0x9dc7, 0x0d41, 0x0000, 0x0000, 0x0000, - 0x9a9c, 0xdc50, 0x0d23, 0x0000, 0x0000, 0x0000, 0x4fcc, 0x9a9b, 0x0d04, 0x0000, - 0x0000, 0x0000, 0x7e48, 0x8f77, 0x0ce5, 0x0000, 0x0000, 0x0000, 0x84e4, 0xd4b9, - 0x0cc6, 0x0000, 0x0000, 0x0000, 0x84e0, 0xbd10, 0x0ca6, 0x0000, 0x0000, 0x0000, - 0x1b0a, 0xc8d9, 0x0c88, 0x0000, 0x0000, 0x0000, 0x6a48, 0xfc81, 0x0c68, 0x0000, - 0x0000, 0x0000, 0x070a, 0xbef6, 0x0c4a, 0x0000, 0x0000, 0x0000, 0x8a70, 0xf096, - 0x0c2b, 0x0000, 0x0000, 0x0000, 0xecc2, 0xc994, 0x0c0c, 0x0000, 0x0000, 0x0000, - 0x1540, 0x9537, 0x0bea, 0x0000, 0x0000, 0x0000, 0x1b02, 0xab5b, 0x0bce, 0x0000, - 0x0000, 0x0000, 0x5dc0, 0xb0c8, 0x0bad, 0x0000, 0x0000, 0x0000, 0xc928, 0xe034, - 0x0b8f, 0x0000, 0x0000, 0x0000, 0x2d12, 0xb4b0, 0x0b71, 0x0000, 0x0000, 0x0000, - 0x8fc2, 0xbb94, 0x0b52, 0x0000, 0x0000, 0x0000, 0xe236, 0xe22f, 0x0b33, 0x0000, - 0x0000, 0x0000, 0xb97c, 0xbe9e, 0x0b13, 0x0000, 0x0000, 0x0000, 0xe1a6, 0xe16d, - 0x0af5, 0x0000, 0x0000, 0x0000, 0xd330, 0xbaf0, 0x0ad6, 0x0000, 0x0000, 0x0000, - 0xc0bc, 0xbbd0, 0x0ab7, 0x0000, 0x0000, 0x0000, 0x8e66, 0xdd9b, 0x0a98, 0x0000, - 0x0000, 0x0000, 0xc95c, 0xf799, 0x0a79, 0x0000, 0x0000, 0x0000, 0xdac0, 0xbe4c, - 0x0a55, 0x0000, 0x0000, 0x0000, 0xafc0, 0xc378, 0x0a37, 0x0000, 0x0000, 0x0000, - 0xa880, 0xe341, 0x0a19, 0x0000, 0x0000, 0x0000, 0xc242, 0x81f6, 0x09fd, 0x0000, - 0x0000, 0x0000, 0x7470, 0xc777, 0x09de, 0x0000, 0x0000, 0x0000, 0x62bc, 0xb684, - 0x09be, 0x0000, 0x0000, 0x0000, 0x43ac, 0x8c58, 0x099f, 0x0000, 0x0000, 0x0000, - 0xcc3c, 0xf9ac, 0x0981, 0x0000, 0x0000, 0x0000, 0x1526, 0xb670, 0x0962, 0x0000, - 0x0000, 0x0000, 0xc9fe, 0xdf50, 0x0943, 0x0000, 0x0000, 0x0000, 0x6ae6, 0xc065, - 0x0924, 0x0000, 0x0000, 0x0000, 0xb114, 0xcf29, 0x0905, 0x0000, 0x0000, 0x0000, - 0xd388, 0x922a, 0x08e4, 0x0000, 0x0000, 0x0000, 0xcf54, 0xb926, 0x08c7, 0x0000, - 0x0000, 0x0000, 0x3826, 0xe855, 0x08a8, 0x0000, 0x0000, 0x0000, 0xe7c8, 0x829b, - 0x0888, 0x0000, 0x0000, 0x0000, 0x546c, 0xa903, 0x086a, 0x0000, 0x0000, 0x0000, - 0x8768, 0x99cc, 0x0849, 0x0000, 0x0000, 0x0000, 0x00ac, 0xf529, 0x082b, 0x0000, - 0x0000, 0x0000, 0x2658, 0x9f0b, 0x080c, 0x0000, 0x0000, 0x0000, 0xfe5c, 0x9e21, - 0x07ee, 0x0000, 0x0000, 0x0000, 0x6da2, 0x9910, 0x07cf, 0x0000, 0x0000, 0x0000, - 0x9220, 0xf9b3, 0x07b0, 0x0000, 0x0000, 0x0000, 0x3d90, 0xa541, 0x0791, 0x0000, - 0x0000, 0x0000, 0x6e4c, 0xe7cc, 0x0771, 0x0000, 0x0000, 0x0000, 0xa8fa, 0xe80a, - 0x0753, 0x0000, 0x0000, 0x0000, 0x4e14, 0xc3a7, 0x0734, 0x0000, 0x0000, 0x0000, - 0xf7e0, 0xbad9, 0x0712, 0x0000, 0x0000, 0x0000, 0xfea0, 0xeff2, 0x06f5, 0x0000, - 0x0000, 0x0000, 0xcef6, 0xbd48, 0x06d7, 0x0000, 0x0000, 0x0000, 0x7544, 0xf559, - 0x06b7, 0x0000, 0x0000, 0x0000, 0x2388, 0xf655, 0x0698, 0x0000, 0x0000, 0x0000, - 0xe900, 0xad56, 0x0676, 0x0000, 0x0000, 0x0000, 0x2cc0, 0x8437, 0x0659, 0x0000, - 0x0000, 0x0000, 0x3068, 0xc544, 0x063b, 0x0000, 0x0000, 0x0000, 0xdc70, 0xe73c, - 0x061b, 0x0000, 0x0000, 0x0000, 0xee50, 0x9d49, 0x05fc, 0x0000, 0x0000, 0x0000, - 0x93d2, 0x81f6, 0x05df, 0x0000, 0x0000, 0x0000, 0x941c, 0xadff, 0x05bf, 0x0000, - 0x0000, 0x0000, 0x2ce2, 0x8e45, 0x05a1, 0x0000, 0x0000, 0x0000, 0x4a60, 0x95fd, - 0x0581, 0x0000, 0x0000, 0x0000, 0x79f8, 0xb83a, 0x0563, 0x0000, 0x0000, 0x0000, - 0xcb58, 0xa1f5, 0x0543, 0x0000, 0x0000, 0x0000, 0x2a3a, 0xdc36, 0x0525, 0x0000, - 0x0000, 0x0000, 0x14ee, 0x890e, 0x0506, 0x0000, 0x0000, 0x0000, 0x8f20, 0xc432, - 0x04e3, 0x0000, 0x0000, 0x0000, 0x8440, 0xb21d, 0x04c6, 0x0000, 0x0000, 0x0000, - 0x5430, 0xf698, 0x04a7, 0x0000, 0x0000, 0x0000, 0x04ae, 0x8b20, 0x048a, 0x0000, - 0x0000, 0x0000, 0x04d0, 0xe872, 0x046b, 0x0000, 0x0000, 0x0000, 0xc78e, 0x8893, - 0x044c, 0x0000, 0x0000, 0x0000, 0x0f78, 0x9895, 0x042b, 0x0000, 0x0000, 0x0000, - 0x11d4, 0xdf2e, 0x040d, 0x0000, 0x0000, 0x0000, 0xe84c, 0x89d5, 0x03ef, 0x0000, - 0x0000, 0x0000, 0xf7be, 0x8a67, 0x03d0, 0x0000, 0x0000, 0x0000, 0x95d0, 0xc906, - 0x03b1, 0x0000, 0x0000, 0x0000, 0x64ce, 0xd96c, 0x0392, 0x0000, 0x0000, 0x0000, - 0x97ba, 0xa16f, 0x0373, 0x0000, 0x0000, 0x0000, 0x463c, 0xc51a, 0x0354, 0x0000, - 0x0000, 0x0000, 0xef0a, 0xe93e, 0x0335, 0x0000, 0x0000, 0x0000, 0x526a, 0xa466, - 0x0316, 0x0000, 0x0000, 0x0000, 0x4140, 0xa94d, 0x02f5, 0x0000, 0x0000, 0x0000, - 0xb4ec, 0xce68, 0x02d8, 0x0000, 0x0000, 0x0000, 0x4fa2, 0x8490, 0x02b9, 0x0000, - 0x0000, 0x0000, 0x4e60, 0xca98, 0x0298, 0x0000, 0x0000, 0x0000, 0x08dc, 0xe09c, - 0x027a, 0x0000, 0x0000, 0x0000, 0x2b90, 0xc7e3, 0x025c, 0x0000, 0x0000, 0x0000, - 0x5a7c, 0xf8ef, 0x023c, 0x0000, 0x0000, 0x0000, 0x5022, 0x9d58, 0x021e, 0x0000, - 0x0000, 0x0000, 0x553a, 0xe242, 0x01ff, 0x0000, 0x0000, 0x0000, 0x7e6e, 0xb54d, - 0x01e0, 0x0000, 0x0000, 0x0000, 0xd2d4, 0xa88c, 0x01c1, 0x0000, 0x0000, 0x0000, - 0x75b6, 0xfe6d, 0x01a2, 0x0000, 0x0000, 0x0000, 0x3bb2, 0xf04c, 0x0183, 0x0000, - 0x0000, 0x0000, 0xc2d0, 0xc046, 0x0163, 0x0000, 0x0000, 0x0000, 0x250c, 0xf9d6, - 0x0145, 0x0000, 0x0000, 0x0000, 0xb7b4, 0x8a0d, 0x0126, 0x0000, 0x0000, 0x0000, - 0x1a72, 0xe4f5, 0x0107, 0x0000, 0x0000, 0x0000, 0x825c, 0xa9b8, 0x00e8, 0x0000, - 0x0000, 0x0000, 0x6c90, 0xc9ad, 0x00c6, 0x0000, 0x0000, 0x0000, 0x4d00, 0xd1bb, - 0x00aa, 0x0000, 0x0000, 0x0000, 0xa4a0, 0xee01, 0x0087, 0x0000, 0x0000, 0x0000, - 0x89a8, 0xbe9f, 0x006b, 0x0000, 0x0000, 0x0000, 0x038e, 0xc80c, 0x004d, 0x0000, - 0x0000, 0x0000, 0xfe26, 0x8384, 0x002e, 0x0000, 0x0000, 0x0000, 0xcd90, 0xca57, - 0x000e, 0x0000 -}; - -void MacroAssembler::libm_reduce_pi04l(Register eax, Register ecx, Register edx, Register ebx, Register esi, Register edi, Register ebp, Register esp) { - Label B1_1, B1_2, B1_3, B1_4, B1_5, B1_6, B1_7, B1_8, B1_9, B1_10, B1_11, B1_12; - Label B1_13, B1_14, B1_15; - - assert_different_registers(ebx, eax, ecx, edx, esi, edi, ebp, esp); - - address zero_none = (address)_zero_none; - address _4onpi_d = (address)__4onpi_d; - address TWO_32H = (address)_TWO_32H; - address pi04_3d = (address)_pi04_3d; - address pi04_5d = (address)_pi04_5d; - address SCALE = (address)_SCALE; - address zeros = (address)_zeros; - address pi04_2d = (address)_pi04_2d; - address TWO_12H = (address)_TWO_12H; - address _4onpi_31l = (address)__4onpi_31l; - - bind(B1_1); - push(ebp); - movl(ebp, esp); - andl(esp, -16); - push(esi); - push(edi); - push(ebx); - subl(esp, 20); - movzwl(ebx, Address(ebp, 16)); - andl(ebx, 32767); - movl(eax, Address(ebp, 20)); - cmpl(ebx, 16413); - movl(esi, Address(ebp, 24)); - movl(Address(esp, 4), eax); - jcc(Assembler::greaterEqual, B1_8); - - bind(B1_2); - fld_x(Address(ebp, 8)); - fld_d(ExternalAddress(_4onpi_d)); //0x6dc9c883UL, 0x3ff45f30UL - fmul(1); - fstp_x(Address(esp, 8)); - movzwl(ecx, Address(esp, 16)); - negl(ecx); - addl(ecx, 30); - movl(eax, Address(esp, 12)); - shrl(eax); - cmpl(Address(esp, 4), 0); - jcc(Assembler::notEqual, B1_4); - - bind(B1_3); - lea(ecx, Address(eax, 1)); - andl(ecx, -2); - jmp(B1_5); - - bind(B1_4); - movl(ecx, eax); - addl(eax, Address(esp, 4)); - movl(edx, eax); - andl(edx, 1); - addl(ecx, edx); - - bind(B1_5); - fld_d(ExternalAddress(TWO_32H)); //0x00000000UL, 0x41f80000UL - cmpl(ebx, 16400); - movl(Address(esp, 0), ecx); - fild_s(Address(esp, 0)); - jcc(Assembler::greaterEqual, B1_7); - - bind(B1_6); - fld_d(ExternalAddress(pi04_3d)); //0x54442d00UL, 0x3fe921fbUL - fmul(1); - fsubp(3); - fxch(1); - fmul(2); - fld_s(2); - fadd(1); - fsubrp(1); - fld_s(0); - fxch(1); - fsuba(3); - fld_d(ExternalAddress(8 + pi04_3d)); //0x98cc5180UL, 0x3ce84698UL - fmul(3); - fsuba(2); - fxch(1); - fsub(2); - fsubrp(1); - faddp(3); - fld_d(ExternalAddress(16 + pi04_3d)); //0xcbb5bf6cUL, 0xb9dfc8f8UL - fmulp(2); - fld_s(1); - fsubr(1); - fsuba(1); - fxch(2); - fsubp(1); - faddp(2); - fxch(1); - jmp(B1_15); - - bind(B1_7); - fld_d(ExternalAddress(pi04_5d)); //0x54400000UL, 0x3fe921fbUL - fmul(1); - fsubp(3); - fxch(1); - fmul(2); - fld_s(2); - fadd(1); - fsubrp(1); - fld_s(0); - fxch(1); - fsuba(3); - fld_d(ExternalAddress(8 + pi04_5d)); //0x1a600000UL, 0x3dc0b461UL - fmul(3); - fsuba(2); - fxch(1); - fsub(2); - fsubrp(1); - faddp(3); - fld_d(ExternalAddress(16 + pi04_5d)); //0x2e000000UL, 0x3b93198aUL - fmul(2); - fld_s(0); - fsubr(2); - fsuba(2); - fxch(1); - fsubp(2); - fxch(1); - faddp(3); - fld_d(ExternalAddress(24 + pi04_5d)); //0x25200000UL, 0x396b839aUL - fmul(2); - fld_s(0); - fsubr(2); - fsuba(2); - fxch(1); - fsubp(2); - fxch(1); - faddp(3); - fld_d(ExternalAddress(32 + pi04_5d)); //0x533e63a0UL, 0x37027044UL - fmulp(2); - fld_s(1); - fsubr(1); - fsuba(1); - fxch(2); - fsubp(1); - faddp(2); - fxch(1); - jmp(B1_15); - - bind(B1_8); - fld_x(Address(ebp, 8)); - addl(ebx, -16417); - fmul_d(as_Address(ExternalAddress(SCALE))); //0x00000000UL, 0x32600000UL - movl(eax, -2078209981); - imull(ebx); - addl(edx, ebx); - movl(ecx, ebx); - sarl(edx, 4); - sarl(ecx, 31); - subl(edx, ecx); - movl(eax, edx); - shll(eax, 5); - fstp_x(Address(ebp, 8)); - fld_x(Address(ebp, 8)); - subl(eax, edx); - movl(Address(ebp, 8), 0); - subl(ebx, eax); - fld_x(Address(ebp, 8)); - cmpl(ebx, 17); - fsuba(1); - jcc(Assembler::less, B1_10); - - bind(B1_9); - lea(eax, Address(noreg, edx, Address::times_8)); - lea(ecx, Address(eax, edx, Address::times_4)); - incl(edx); - fld_x(Address(_4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); - fmul(2); - fld_x(Address(12 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); - fmul(2); - fld_s(0); - fadd(2); - fsuba(2); - fxch(1); - faddp(2); - fld_s(1); - fadd(1); - fstp_x(Address(esp, 8)); - andl(Address(esp, 8), -16777216); - fld_x(Address(esp, 8)); - fsubp(1); - jmp(B1_11); - - bind(B1_10); - fld_d(ExternalAddress(zeros)); //0x00000000UL, 0x00000000UL - fld_s(0); - - bind(B1_11); - fld_s(0); - lea(eax, Address(noreg, edx, Address::times_8)); - fld_s(3); - lea(edx, Address(eax, edx, Address::times_4)); - fld_x(Address(_4onpi_31l, RelocationHolder::none).plus_disp(edx, Address::times_1)); - fmul(6); - movl(Address(esp, 0), edx); - fadda(2); - fxch(2); - fsuba(3); - fxch(2); - faddp(3); - fxch(2); - faddp(3); - fld_x(Address(12 + _4onpi_31l, RelocationHolder::none).plus_disp(edx, Address::times_1)); - fmula(2); - fld_s(2); - fadd(2); - fld_s(0); - fxch(1); - fsubra(3); - fxch(3); - fchs(); - faddp(4); - fxch(3); - faddp(4); - fxch(2); - fadd(3); - fxch(2); - fmul(5); - fadda(2); - fld_s(4); - fld_x(Address(24 + _4onpi_31l, RelocationHolder::none).plus_disp(edx, Address::times_1)); - fmula(1); - fxch(1); - fadda(4); - fxch(4); - fstp_x(Address(esp, 8)); - movzwl(ebx, Address(esp, 16)); - andl(ebx, 32767); - cmpl(ebx, 16415); - jcc(Assembler::greaterEqual, B1_13); - - bind(B1_12); - negl(ebx); - addl(ebx, 30); - movl(ecx, ebx); - movl(eax, Address(esp, 12)); - shrl(eax); - shll(eax); - movl(Address(esp, 12), eax); - movl(Address(esp, 8), 0); - shrl(eax); - jmp(B1_14); - - bind(B1_13); - negl(ebx); - addl(ebx, 30); - movl(ecx, ebx); - movl(edx, Address(esp, 8)); - shrl(edx); - shll(edx); - negl(ecx); - movl(eax, Address(esp, 12)); - shll(eax); - movl(ecx, ebx); - movl(Address(esp, 8), edx); - shrl(edx); - orl(eax, edx); - - bind(B1_14); - fld_x(Address(esp, 8)); - addl(eax, Address(esp, 4)); - fsubp(3); - fmul(6); - fld_s(4); - movl(edx, eax); - andl(edx, 1); - fadd(3); - movl(ecx, Address(esp, 0)); - fsuba(3); - fxch(3); - faddp(5); - fld_s(1); - fxch(3); - fadd_d(Address(zero_none, RelocationHolder::none).plus_disp(edx, Address::times_8)); - fadda(3); - fsub(3); - faddp(2); - fxch(1); - faddp(4); - fld_s(2); - fadd(2); - fsuba(2); - fxch(3); - faddp(2); - fxch(1); - faddp(3); - fld_s(0); - fadd(2); - fsuba(2); - fxch(1); - faddp(2); - fxch(1); - faddp(2); - fld_s(2); - fld_x(Address(36 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); - fmula(1); - fld_s(1); - fadd(3); - fsuba(3); - fxch(2); - faddp(3); - fxch(2); - faddp(3); - fxch(1); - fmul(4); - fld_s(0); - fadd(2); - fsuba(2); - fxch(1); - faddp(2); - fxch(1); - faddp(2); - fld_s(2); - fld_x(Address(48 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); - fmula(1); - fld_s(1); - fadd(3); - fsuba(3); - fxch(2); - faddp(3); - fxch(2); - faddp(3); - fld_s(3); - fxch(2); - fmul(5); - fld_x(Address(60 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); - fmula(3); - fxch(3); - faddp(1); - fld_s(0); - fadd(2); - fsuba(2); - fxch(1); - faddp(2); - fxch(1); - faddp(3); - fld_s(3); - fxch(2); - fmul(5); - fld_x(Address(72 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); - fmula(3); - fxch(3); - faddp(1); - fld_s(0); - fadd(2); - fsuba(2); - fxch(1); - faddp(2); - fxch(1); - faddp(3); - fxch(1); - fmulp(4); - fld_x(Address(84 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); - fmulp(3); - fxch(2); - faddp(3); - fld_s(2); - fadd(2); - fld_d(ExternalAddress(TWO_32H)); //0x00000000UL, 0x41f80000UL - fmul(1); - fadda(1); - fsubp(1); - fsuba(2); - fxch(3); - faddp(2); - faddp(1); - fld_d(ExternalAddress(pi04_2d)); //0x54400000UL, 0x3fe921fbUL - fld_s(0); - fmul(2); - fxch(2); - fadd(3); - fxch(1); - fmulp(3); - fmul_d(as_Address(ExternalAddress(8 + pi04_2d))); //0x1a626331UL, 0x3dc0b461UL - faddp(1); - - bind(B1_15); - fld_d(ExternalAddress(TWO_12H)); //0x00000000UL, 0x40b80000UL - fld_s(2); - fadd(2); - fmula(1); - fstp_x(Address(esp, 8)); - fld_x(Address(esp, 8)); - fadd(1); - fsubrp(1); - fst_d(Address(esi, 0)); - fsubp(2); - faddp(1); - fstp_d(Address(esi, 8)); - addl(esp, 20); - pop(ebx); - pop(edi); - pop(esi); - movl(esp, ebp); - pop(ebp); - ret(0); -} - -ALIGNED_(16) juint _L_2il0floatpacket_0[] = -{ - 0xffffffffUL, 0x7fffffffUL, 0x00000000UL, 0x00000000UL -}; - -ALIGNED_(16) juint _Pi4Inv[] = -{ - 0x6dc9c883UL, 0x3ff45f30UL -}; - -ALIGNED_(16) juint _Pi4x3[] = -{ - 0x54443000UL, 0xbfe921fbUL, 0x3b39a000UL, 0x3d373dcbUL, 0xe0e68948UL, - 0xba845c06UL -}; - -ALIGNED_(16) juint _Pi4x4[] = -{ - 0x54400000UL, 0xbfe921fbUL, 0x1a600000UL, 0xbdc0b461UL, 0x2e000000UL, - 0xbb93198aUL, 0x252049c1UL, 0xb96b839aUL -}; - -ALIGNED_(16) jushort _SP[] = -{ - 0xaaab, 0xaaaa, 0xaaaa, 0xaaaa, 0xbffc, 0x0000, 0x8887, 0x8888, 0x8888, 0x8888, - 0x3ff8, 0x0000, 0xc527, 0x0d00, 0x00d0, 0xd00d, 0xbff2, 0x0000, 0x45f6, 0xb616, - 0x1d2a, 0xb8ef, 0x3fec, 0x0000, 0x825b, 0x3997, 0x2b3f, 0xd732, 0xbfe5, 0x0000, - 0xbf33, 0x8bb4, 0x2fda, 0xb092, 0x3fde, 0x0000, 0x44a6, 0xed1a, 0x29ef, 0xd73e, - 0xbfd6, 0x0000, 0x8610, 0x307f, 0x62a1, 0xc921, 0x3fce, 0x0000 -}; - -ALIGNED_(16) jushort _CP[] = -{ - 0x0000, 0x0000, 0x0000, 0x8000, 0xbffe, 0x0000, 0xaaa5, 0xaaaa, 0xaaaa, 0xaaaa, - 0x3ffa, 0x0000, 0x9c2f, 0x0b60, 0x60b6, 0xb60b, 0xbff5, 0x0000, 0xf024, 0x0cac, - 0x00d0, 0xd00d, 0x3fef, 0x0000, 0x03fe, 0x3f65, 0x7dbb, 0x93f2, 0xbfe9, 0x0000, - 0xd84d, 0xadee, 0xc698, 0x8f76, 0x3fe2, 0x0000, 0xdaba, 0xfe79, 0xea36, 0xc9c9, - 0xbfda, 0x0000, 0x3ac6, 0x0ba0, 0x07ce, 0xd585, 0x3fd2, 0x0000 -}; - -ALIGNED_(16) juint _ones[] = -{ - 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xbff00000UL -}; - -void MacroAssembler::libm_sincos_huge(XMMRegister xmm0, XMMRegister xmm1, Register eax, Register ecx, Register edx, Register ebx, Register esi, Register edi, Register ebp, Register esp) { - Label B1_1, B1_2, B1_3, B1_4, B1_5, B1_6, B1_7, B1_8, B1_9, B1_10, B1_11, B1_12; - Label B1_13, B1_14, B1_15, B1_16, B1_17, B1_18, B1_19, B1_20, B1_21, B1_22, B1_23; - Label B1_24, B1_25, B1_26, B1_27, B1_28, B1_29, B1_30, B1_31, B1_32, B1_33, B1_34; - Label B1_35, B1_36, B1_37, B1_38, B1_39, B1_40, B1_41, B1_42, B1_43, B1_44, B1_45, B1_46; - - assert_different_registers(ebx, eax, ecx, edx, esi, edi, ebp, esp); - - address L_2il0floatpacket_0 = (address)_L_2il0floatpacket_0; - address Pi4Inv = (address)_Pi4Inv; - address Pi4x3 = (address)_Pi4x3; - address Pi4x4 = (address)_Pi4x4; - address ones = (address)_ones; - address CP = (address)_CP; - address SP = (address)_SP; - - bind(B1_1); - push(ebp); - movl(ebp, esp); - andl(esp, -64); - push(esi); - push(edi); - push(ebx); - subl(esp, 52); - movl(eax, Address(ebp, 16)); - movl(edx, Address(ebp, 20)); - movl(Address(esp, 32), eax); - movl(Address(esp, 36), edx); - - bind(B1_2); - fnstcw(Address(esp, 30)); - - bind(B1_3); - movsd(xmm1, Address(ebp, 8)); - movl(esi, Address(ebp, 12)); - movl(eax, esi); - andl(eax, 2147483647); - andps(xmm1, ExternalAddress(L_2il0floatpacket_0)); //0xffffffffUL, 0x7fffffffUL, 0x00000000UL, 0x00000000UL - shrl(esi, 31); - movl(Address(esp, 40), eax); - cmpl(eax, 1104150528); - movsd(Address(ebp, 8), xmm1); - jcc(Assembler::aboveEqual, B1_11); - - bind(B1_4); - movsd(xmm0, ExternalAddress(Pi4Inv)); //0x6dc9c883UL, 0x3ff45f30UL - mulsd(xmm0, xmm1); - movzwl(edx, Address(esp, 30)); - movl(eax, edx); - andl(eax, 768); - movsd(Address(esp, 0), xmm0); - cmpl(eax, 768); - jcc(Assembler::equal, B1_42); - - bind(B1_5); - orl(edx, -64768); - movw(Address(esp, 28), edx); - - bind(B1_6); - fldcw(Address(esp, 28)); - - bind(B1_7); - movsd(xmm1, Address(ebp, 8)); - movl(ebx, 1); - - bind(B1_8); - movl(Address(esp, 12), ebx); - movl(ebx, Address(esp, 4)); - movl(eax, ebx); - movl(Address(esp, 8), esi); - movl(esi, ebx); - shrl(esi, 20); - andl(eax, 1048575); - movl(ecx, esi); - orl(eax, 1048576); - negl(ecx); - movl(edx, eax); - addl(ecx, 19); - addl(esi, 13); - movl(Address(esp, 24), ecx); - shrl(edx); - movl(ecx, esi); - shll(eax); - movl(ecx, Address(esp, 24)); - movl(esi, Address(esp, 0)); - shrl(esi); - orl(eax, esi); - cmpl(ebx, 1094713344); - movsd(Address(esp, 16), xmm1); - fld_d(Address(esp, 16)); - cmov32(Assembler::below, eax, edx); - movl(esi, Address(esp, 8)); - lea(edx, Address(eax, 1)); - movl(ebx, edx); - andl(ebx, -2); - movl(Address(esp, 16), ebx); - fild_s(Address(esp, 16)); - movl(ebx, Address(esp, 12)); - cmpl(Address(esp, 40), 1094713344); - jcc(Assembler::aboveEqual, B1_10); - - bind(B1_9); - fld_d(ExternalAddress(Pi4x3)); //0x54443000UL, 0xbfe921fbUL - fmul(1); - faddp(2); - fld_d(ExternalAddress(8 + Pi4x3)); //0x3b39a000UL, 0x3d373dcbUL - fmul(1); - faddp(2); - fld_d(ExternalAddress(16 + Pi4x3)); //0xe0e68948UL, 0xba845c06UL - fmulp(1); - faddp(1); - jmp(B1_17); - - bind(B1_10); - fld_d(ExternalAddress(Pi4x4)); //0x54400000UL, 0xbfe921fbUL - fmul(1); - faddp(2); - fld_d(ExternalAddress(8 + Pi4x4)); //0x1a600000UL, 0xbdc0b461UL - fmul(1); - faddp(2); - fld_d(ExternalAddress(16 + Pi4x4)); //0x2e000000UL, 0xbb93198aUL - fmul(1); - faddp(2); - fld_d(ExternalAddress(24 + Pi4x4)); //0x252049c1UL, 0xb96b839aUL - fmulp(1); - faddp(1); - jmp(B1_17); - - bind(B1_11); - movzwl(edx, Address(esp, 30)); - movl(eax, edx); - andl(eax, 768); - cmpl(eax, 768); - jcc(Assembler::equal, B1_43); - bind(B1_12); - orl(edx, -64768); - movw(Address(esp, 28), edx); - - bind(B1_13); - fldcw(Address(esp, 28)); - - bind(B1_14); - movsd(xmm1, Address(ebp, 8)); - movl(ebx, 1); - - bind(B1_15); - movsd(Address(esp, 16), xmm1); - fld_d(Address(esp, 16)); - addl(esp, -32); - lea(eax, Address(esp, 32)); - fstp_x(Address(esp, 0)); - movl(Address(esp, 12), 0); - movl(Address(esp, 16), eax); - call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_reduce_pi04l()))); - - bind(B1_46); - addl(esp, 32); - - bind(B1_16); - fld_d(Address(esp, 0)); - lea(edx, Address(eax, 1)); - fld_d(Address(esp, 8)); - faddp(1); - - bind(B1_17); - movl(ecx, edx); - addl(eax, 3); - shrl(ecx, 2); - andl(ecx, 1); - shrl(eax, 2); - xorl(esi, ecx); - movl(ecx, Address(esp, 36)); - andl(eax, 1); - andl(ecx, 3); - cmpl(ecx, 3); - jcc(Assembler::notEqual, B1_25); - - bind(B1_18); - fld_x(ExternalAddress(84 + SP)); //0x8610, 0x307f, 0x62 - fld_s(1); - fmul((2)); - testb(edx, 2); - fmula((1)); - fld_x(ExternalAddress(72 + SP)); //0x44a6, 0xed1a, 0x29 - faddp(2); - fmula(1); - fld_x(ExternalAddress(60 + SP)); //0xbf33, 0x8bb4, 0x2f - faddp(2); - fmula(1); - fld_x(ExternalAddress(48 + SP)); //0x825b, 0x3997, 0x2b - faddp(2); - fmula(1); - fld_x(ExternalAddress(36 + SP)); //0x45f6, 0xb616, 0x1d - faddp(2); - fmula(1); - fld_x(ExternalAddress(24 + SP)); //0xc527, 0x0d00, 0x00 - faddp(2); - fmula(1); - fld_x(ExternalAddress(12 + SP)); //0x8887, 0x8888, 0x88 - faddp(2); - fmula(1); - fld_x(ExternalAddress(SP)); //0xaaab, 0xaaaa, 0xaa - faddp(2); - fmula(1); - fld_x(ExternalAddress(84 + CP)); //0x3ac6, 0x0ba0, 0x07 - fmul(1); - fld_x(ExternalAddress(72 + CP)); //0xdaba, 0xfe79, 0xea - faddp(1); - fmul(1); - fld_x(ExternalAddress(62 + CP)); //0xd84d, 0xadee, 0xc6 - faddp(1); - fmul(1); - fld_x(ExternalAddress(48 + CP)); //0x03fe, 0x3f65, 0x7d - faddp(1); - fmul(1); - fld_x(ExternalAddress(36 + CP)); //0xf024, 0x0cac, 0x00 - faddp(1); - fmul(1); - fld_x(ExternalAddress(24 + CP)); //0x9c2f, 0x0b60, 0x60 - faddp(1); - fmul(1); - fld_x(ExternalAddress(12 + CP)); //0xaaa5, 0xaaaa, 0xaa - faddp(1); - fmul(1); - fld_x(ExternalAddress(CP)); //0x0000, 0x0000, 0x00 - faddp(1); - fmulp(1); - fld_d(Address(ones, RelocationHolder::none).plus_disp(esi, Address::times_8)); - fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8)); - jcc(Assembler::equal, B1_22); - - bind(B1_19); - fmulp(4); - testl(ebx, ebx); - fxch(2); - fmul(3); - movl(eax, Address(esp, 2)); - faddp(3); - fxch(2); - fstp_d(Address(eax, 0)); - fmula(1); - faddp(1); - fstp_d(Address(eax, 8)); - jcc(Assembler::equal, B1_21); - - bind(B1_20); - fldcw(Address(esp, 30)); - - bind(B1_21); - addl(esp, 52); - pop(ebx); - pop(edi); - pop(esi); - movl(esp, ebp); - pop(ebp); - ret(0); - - bind(B1_22); - fxch(1); - fmulp(4); - testl(ebx, ebx); - fxch(2); - fmul(3); - movl(eax, Address(esp, 32)); - faddp(3); - fxch(2); - fstp_d(Address(eax, 8)); - fmula(1); - faddp(1); - fstp_d(Address(eax, 0)); - jcc(Assembler::equal, B1_24); - - bind(B1_23); - fldcw(Address(esp, 30)); - - bind(B1_24); - addl(esp, 52); - pop(ebx); - pop(edi); - pop(esi); - movl(esp, ebp); - pop(ebp); - ret(0); - - bind(B1_25); - testb(Address(esp, 36), 2); - jcc(Assembler::equal, B1_33); - - bind(B1_26); - fld_s(0); - testb(edx, 2); - fmul(1); - fld_s(0); - fmul(1); - jcc(Assembler::equal, B1_30); - - bind(B1_27); - fstp_d(2); - fld_x(ExternalAddress(84 + CP)); //0x3ac6, 0x0ba0, 0x07 - testl(ebx, ebx); - fmul(2); - fld_x(ExternalAddress(72 + CP)); //0xdaba, 0xfe79, 0xea - fmul(3); - fld_x(ExternalAddress(60 + CP)); //0xd84d, 0xadee, 0xc6 - movl(eax, Address(rsp, 32)); - faddp(2); - fxch(1); - fmul(3); - fld_x(ExternalAddress(48 + CP)); //0x03fe, 0x3f65, 0x7d - faddp(2); - fxch(1); - fmul(3); - fld_x(ExternalAddress(36 + CP)); //0xf024, 0x0cac, 0x00 - faddp(2); - fxch(1); - fmul(3); - fld_x(ExternalAddress(24 + CP)); //0x9c2f, 0x0b60, 0x60 - faddp(2); - fxch(1); - fmul(3); - fld_x(ExternalAddress(12 + CP)); //0xaaa5, 0xaaaa, 0xaa - faddp(2); - fxch(1); - fmulp(3); - fld_x(ExternalAddress(CP)); //0x0000, 0x0000, 0x00 - faddp(1); - fmulp(1); - faddp(1); - fld_d(Address(ones, RelocationHolder::none).plus_disp(rsi, Address::times_8)); - fmula(1); - faddp(1); - fstp_d(Address(eax, 8)); - jcc(Assembler::equal, B1_29); - - bind(B1_28); - fldcw(Address(esp, 30)); - - bind(B1_29); - addl(esp, 52); - pop(ebx); - pop(edi); - pop(esi); - movl(esp, ebp); - pop(ebp); - ret(0); - - bind(B1_30); - fld_x(ExternalAddress(84 + SP)); //0x8610, 0x307f, 0x62 - testl(ebx, ebx); - fmul(1); - fld_x(ExternalAddress(72 + SP)); //0x44a6, 0xed1a, 0x29 - fmul(2); - fld_x(ExternalAddress(60 + SP)); //0xbf33, 0x8bb4, 0x2f - movl(eax, Address(rsp, 32)); - faddp(2); - fxch(1); - fmul(2); - fld_x(ExternalAddress(48 + SP)); //0x825b, 0x3997, 0x2b - faddp(2); - fxch(1); - fmul(2); - fld_x(ExternalAddress(36 + SP)); //0x45f6, 0xb616, 0x1d - faddp(2); - fxch(1); - fmul(2); - fld_x(ExternalAddress(24 + SP)); //0xc527, 0x0d00, 0x00 - faddp(2); - fxch(1); - fmul(2); - fld_x(ExternalAddress(12 + SP)); //0x8887, 0x8888, 0x88 - faddp(2); - fxch(1); - fmulp(2); - fld_x(ExternalAddress(SP)); //0xaaab, 0xaaaa, 0xaa - faddp(1); - fmulp(2); - faddp(1); - fld_d(Address(ones, RelocationHolder::none).plus_disp(rsi, Address::times_8)); - fmulp(2); - fmul(1); - faddp(1); - fstp_d(Address(eax, 8)); - jcc(Assembler::equal, B1_32); - - bind(B1_31); - fldcw(Address(esp, 30)); - - bind(B1_32); - addl(esp, 52); - pop(ebx); - pop(edi); - pop(esi); - movl(esp, ebp); - pop(ebp); - ret(0); - - bind(B1_33); - testb(Address(esp, 36), 1); - jcc(Assembler::equal, B1_41); - - bind(B1_34); - fld_s(0); - testb(edx, 2); - fmul(1); - fld_s(0); - fmul(1); - jcc(Assembler::equal, B1_38); - - bind(B1_35); - fld_x(ExternalAddress(84 + SP)); //0x8610, 0x307f, 0x62 - testl(ebx, ebx); - fmul(1); - fld_x(ExternalAddress(72 + SP)); //0x44a6, 0xed1a, 0x29 - fmul(2); - fld_x(ExternalAddress(60 + SP)); //0xbf33, 0x8bb4, 0x2f - faddp(2); - fxch(1); - fmul(2); - fld_x(ExternalAddress(48 + SP)); //0x825b, 0x3997, 0x2b - faddp(2); - fxch(1); - fmul(2); - fld_x(ExternalAddress(36 + SP)); //0x45f6, 0xb616, 0x1d - faddp(2); - fxch(1); - fmul(2); - fld_x(ExternalAddress(24 + SP)); //0xc527, 0x0d00, 0x00 - faddp(2); - fxch(1); - fmul(2); - fld_x(ExternalAddress(12 + SP)); //0x8887, 0x8888, 0x88 - faddp(2); - fxch(1); - fmulp(2); - fld_x(ExternalAddress(SP)); //0xaaab, 0xaaaa, 0xaa - faddp(1); - fmulp(2); - faddp(1); - fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8)); - fmulp(2); - fmul(1); - movl(eax, Address(esp, 32)); - faddp(1); - fstp_d(Address(eax, 0)); - jcc(Assembler::equal, B1_37); - - bind(B1_36); - fldcw(Address(esp, 30)); - - bind(B1_37); - addl(esp, 52); - pop(ebx); - pop(edi); - pop(esi); - movl(esp, ebp); - pop(ebp); - ret(0); - - bind(B1_38); - fstp_d(2); - fld_x(ExternalAddress(84 + CP)); //0x3ac6, 0x0ba0, 0x07 - testl(ebx, ebx); - fmul(2); - fld_x(ExternalAddress(72 + CP)); //0xdaba, 0xfe79, 0xea - fmul(3); - fld_x(ExternalAddress(60 + CP)); //0xd84d, 0xadee, 0xc6 - faddp(2); - fxch(1); - fmul(3); - fld_x(ExternalAddress(48 + CP)); //0x03fe, 0x3f65, 0x7d - faddp(2); - fxch(1); - fmul(3); - fld_x(ExternalAddress(36 + CP)); //0xf024, 0x0cac, 0x00 - faddp(2); - fxch(1); - fmul(3); - fld_x(ExternalAddress(24 + CP)); //0x9c2f, 0x0b60, 0x60 - faddp(2); - fxch(1); - fmul(3); - fld_x(ExternalAddress(12 + CP)); //0xaaa5, 0xaaaa, 0xaa - faddp(2); - fxch(1); - fmulp(3); - fld_x(ExternalAddress(CP)); //0x0000, 0x0000, 0x00 - faddp(1); - fmulp(1); - faddp(1); - fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8)); - fmula(1); - movl(eax, Address(esp, 32)); - faddp(1); - fstp_d(Address(eax, 0)); - jcc(Assembler::equal, B1_40); - - bind(B1_39); - fldcw(Address(esp, 30)); - bind(B1_40); - addl(esp, 52); - pop(ebx); - pop(edi); - pop(esi); - movl(esp, ebp); - pop(ebp); - ret(0); - bind(B1_41); - fstp_d(0); - addl(esp, 52); - pop(ebx); - pop(edi); - pop(esi); - movl(esp, ebp); - pop(ebp); - ret(0); - bind(B1_42); - xorl(ebx, ebx); - jmp(B1_8); - bind(B1_43); - xorl(ebx, ebx); - jmp(B1_15); -} - -ALIGNED_(16) juint _static_const_table_sin[] = -{ - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, 0xbf73b92eUL, - 0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL, - 0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, - 0xc0000000UL, 0xbc626d19UL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, - 0xbfa60beaUL, 0x2ed59f06UL, 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, - 0x00000000UL, 0x3ff00000UL, 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, - 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, 0x00000000UL, 0x3ff00000UL, - 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, 0x20000000UL, - 0x3c5e0d89UL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, 0xbfc59267UL, - 0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL, - 0x3ff00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, - 0x20000000UL, 0x3c68076aUL, 0x00000000UL, 0x3ff00000UL, 0x99fcef32UL, - 0x3fca8279UL, 0x667f3bcdUL, 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, - 0x00000000UL, 0x3fe00000UL, 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, - 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, 0x00000000UL, 0x3fe00000UL, - 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, 0xe0000000UL, - 0x3c39f630UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, 0xbf9d4a2cUL, - 0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL, - 0x3fe00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0x3fed906bUL, - 0x20000000UL, 0x3c7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x76acf82dUL, - 0x3fa4a031UL, 0x56c62ddaUL, 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, - 0x00000000UL, 0x3fd00000UL, 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, - 0x3fef6297UL, 0x20000000UL, 0x3c756217UL, 0x00000000UL, 0x3fd00000UL, - 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, 0x40000000UL, - 0xbc887df6UL, 0x00000000UL, 0x3fc00000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, - 0x40000000UL, 0xbc887df6UL, 0x00000000UL, 0xbfc00000UL, 0x0e5967d5UL, - 0x3fac1d1fUL, 0xcff75cb0UL, 0x3fef6297UL, 0x20000000UL, 0x3c756217UL, - 0x00000000UL, 0xbfd00000UL, 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, - 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, 0x00000000UL, 0xbfd00000UL, - 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, 0x3fed906bUL, 0x20000000UL, - 0x3c7457e6UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, 0x3f9d4a2cUL, - 0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL, - 0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, - 0xe0000000UL, 0x3c39f630UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, - 0xbfc133ccUL, 0x6b151741UL, 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, - 0x00000000UL, 0xbfe00000UL, 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, - 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, 0x00000000UL, 0xbfe00000UL, - 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, 0x20000000UL, - 0x3c68076aUL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, 0x3fc59267UL, - 0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL, - 0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, - 0x20000000UL, 0x3c5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, - 0x3fb37ca1UL, 0xa6aea963UL, 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, - 0x00000000UL, 0xbff00000UL, 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, - 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, 0x00000000UL, 0xbff00000UL, - 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, 0xc0000000UL, - 0xbc626d19UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, 0x3f73b92eUL, - 0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL, - 0xbff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, - 0x3f73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL, - 0x00000000UL, 0xbff00000UL, 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, - 0xbfc8f8b8UL, 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0xbff00000UL, - 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, - 0x3c75d28dUL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, 0x3fb37ca1UL, - 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, 0x3c672cedUL, 0x00000000UL, - 0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0xbfde2b5dUL, - 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, - 0x3fc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL, - 0x00000000UL, 0xbff00000UL, 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, - 0xbfe44cf3UL, 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0xbff00000UL, - 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, - 0x3c8bdd34UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, 0xbfc133ccUL, - 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, 0x3c82c5e1UL, 0x00000000UL, - 0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0xbfea9b66UL, - 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, - 0x3f9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL, - 0x00000000UL, 0xbfe00000UL, 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, - 0xbfed906bUL, 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0xbfe00000UL, - 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, - 0xbc8760b1UL, 0x00000000UL, 0xbfd00000UL, 0x0e5967d5UL, 0x3fac1d1fUL, - 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, 0xbc756217UL, 0x00000000UL, - 0xbfd00000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0xbfefd88dUL, - 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0xbfc00000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, - 0xbfefd88dUL, 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0x3fc00000UL, - 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, - 0xbc756217UL, 0x00000000UL, 0x3fd00000UL, 0x76acf82dUL, 0x3fa4a031UL, - 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, 0xbc8760b1UL, 0x00000000UL, - 0x3fd00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0xbfed906bUL, - 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, - 0xbf9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL, - 0x00000000UL, 0x3fe00000UL, 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, - 0xbfea9b66UL, 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0x3fe00000UL, - 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, - 0x3c82c5e1UL, 0x00000000UL, 0x3fe00000UL, 0x99fcef32UL, 0x3fca8279UL, - 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, 0x3c8bdd34UL, 0x00000000UL, - 0x3fe00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0xbfe44cf3UL, - 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, - 0xbfc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL, - 0x00000000UL, 0x3ff00000UL, 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, - 0xbfde2b5dUL, 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0x3ff00000UL, - 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, - 0x3c672cedUL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, 0xbfa60beaUL, - 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, 0x3c75d28dUL, 0x00000000UL, - 0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0xbfc8f8b8UL, - 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, - 0xbf73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL, - 0x00000000UL, 0x3ff00000UL, 0x55555555UL, 0xbfc55555UL, 0x00000000UL, - 0xbfe00000UL, 0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL, - 0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL, 0xa556c734UL, - 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL, 0x1a600000UL, 0x3d90b461UL, - 0x1a600000UL, 0x3d90b461UL, 0x54400000UL, 0x3fb921fbUL, 0x00000000UL, - 0x00000000UL, 0x2e037073UL, 0x3b63198aUL, 0x00000000UL, 0x00000000UL, - 0x6dc9c883UL, 0x40245f30UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x43380000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x43600000UL, - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x3c800000UL, 0x00000000UL, - 0x00000000UL, 0xffffffffUL, 0x3fefffffUL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x80000000UL, 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x3fe00000UL, - 0x00000000UL, 0x3fe00000UL -}; - -void MacroAssembler::fast_sin(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ebx, Register edx) { - - Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; - Label L_2TAG_PACKET_4_0_2, start; - assert_different_registers(eax, ebx, edx); - address static_const_table_sin = (address)_static_const_table_sin; - - bind(start); - subl(rsp, 120); - movl(Address(rsp, 56), ebx); - lea(ebx, ExternalAddress(static_const_table_sin)); - movsd(xmm0, Address(rsp, 128)); - pextrw(eax, xmm0, 3); - andl(eax, 32767); - subl(eax, 12336); - cmpl(eax, 4293); - jcc(Assembler::above, L_2TAG_PACKET_0_0_2); - movsd(xmm1, Address(ebx, 2160)); - mulsd(xmm1, xmm0); - movsd(xmm5, Address(ebx, 2272)); - movdqu(xmm4, Address(ebx, 2256)); - pand(xmm4, xmm0); - por(xmm5, xmm4); - movsd(xmm3, Address(ebx, 2128)); - movdqu(xmm2, Address(ebx, 2112)); - addpd(xmm1, xmm5); - cvttsd2sil(edx, xmm1); - cvtsi2sdl(xmm1, edx); - mulsd(xmm3, xmm1); - unpcklpd(xmm1, xmm1); - addl(edx, 1865216); - movdqu(xmm4, xmm0); - andl(edx, 63); - movdqu(xmm5, Address(ebx, 2096)); - lea(eax, Address(ebx, 0)); - shll(edx, 5); - addl(eax, edx); - mulpd(xmm2, xmm1); - subsd(xmm0, xmm3); - mulsd(xmm1, Address(ebx, 2144)); - subsd(xmm4, xmm3); - movsd(xmm7, Address(eax, 8)); - unpcklpd(xmm0, xmm0); - movapd(xmm3, xmm4); - subsd(xmm4, xmm2); - mulpd(xmm5, xmm0); - subpd(xmm0, xmm2); - movdqu(xmm6, Address(ebx, 2064)); - mulsd(xmm7, xmm4); - subsd(xmm3, xmm4); - mulpd(xmm5, xmm0); - mulpd(xmm0, xmm0); - subsd(xmm3, xmm2); - movdqu(xmm2, Address(eax, 0)); - subsd(xmm1, xmm3); - movsd(xmm3, Address(eax, 24)); - addsd(xmm2, xmm3); - subsd(xmm7, xmm2); - mulsd(xmm2, xmm4); - mulpd(xmm6, xmm0); - mulsd(xmm3, xmm4); - mulpd(xmm2, xmm0); - mulpd(xmm0, xmm0); - addpd(xmm5, Address(ebx, 2080)); - mulsd(xmm4, Address(eax, 0)); - addpd(xmm6, Address(ebx, 2048)); - mulpd(xmm5, xmm0); - movapd(xmm0, xmm3); - addsd(xmm3, Address(eax, 8)); - mulpd(xmm1, xmm7); - movapd(xmm7, xmm4); - addsd(xmm4, xmm3); - addpd(xmm6, xmm5); - movsd(xmm5, Address(eax, 8)); - subsd(xmm5, xmm3); - subsd(xmm3, xmm4); - addsd(xmm1, Address(eax, 16)); - mulpd(xmm6, xmm2); - addsd(xmm5, xmm0); - addsd(xmm3, xmm7); - addsd(xmm1, xmm5); - addsd(xmm1, xmm3); - addsd(xmm1, xmm6); - unpckhpd(xmm6, xmm6); - addsd(xmm1, xmm6); - addsd(xmm4, xmm1); - movsd(Address(rsp, 0), xmm4); - fld_d(Address(rsp, 0)); - jmp(L_2TAG_PACKET_1_0_2); - - bind(L_2TAG_PACKET_0_0_2); - jcc(Assembler::greater, L_2TAG_PACKET_2_0_2); - shrl(eax, 4); - cmpl(eax, 268434685); - jcc(Assembler::notEqual, L_2TAG_PACKET_3_0_2); - movsd(Address(rsp, 0), xmm0); - fld_d(Address(rsp, 0)); - jmp(L_2TAG_PACKET_1_0_2); - - bind(L_2TAG_PACKET_3_0_2); - movsd(xmm3, Address(ebx, 2192)); - mulsd(xmm3, xmm0); - subsd(xmm3, xmm0); - mulsd(xmm3, Address(ebx, 2208)); - movsd(Address(rsp, 0), xmm0); - fld_d(Address(rsp, 0)); - jmp(L_2TAG_PACKET_1_0_2); - - bind(L_2TAG_PACKET_2_0_2); - movl(eax, Address(rsp, 132)); - andl(eax, 2146435072); - cmpl(eax, 2146435072); - jcc(Assembler::equal, L_2TAG_PACKET_4_0_2); - subl(rsp, 32); - movsd(Address(rsp, 0), xmm0); - lea(eax, Address(rsp, 40)); - movl(Address(rsp, 8), eax); - movl(eax, 2); - movl(Address(rsp, 12), eax); - call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_sin_cos_huge()))); - addl(rsp, 32); - fld_d(Address(rsp, 16)); - jmp(L_2TAG_PACKET_1_0_2); - bind(L_2TAG_PACKET_4_0_2); - fld_d(Address(rsp, 128)); - fmul_d(Address(ebx, 2240)); - bind(L_2TAG_PACKET_1_0_2); - movl(ebx, Address(rsp, 56)); -} - -/******************************************************************************/ -// ALGORITHM DESCRIPTION - COS() -// --------------------- -// -// 1. RANGE REDUCTION -// -// We perform an initial range reduction from X to r with -// -// X =~= N * pi/32 + r -// -// so that |r| <= pi/64 + epsilon. We restrict inputs to those -// where |N| <= 932560. Beyond this, the range reduction is -// insufficiently accurate. For extremely small inputs, -// denormalization can occur internally, impacting performance. -// This means that the main path is actually only taken for -// 2^-252 <= |X| < 90112. -// -// To avoid branches, we perform the range reduction to full -// accuracy each time. -// -// X - N * (P_1 + P_2 + P_3) -// -// where P_1 and P_2 are 32-bit numbers (so multiplication by N -// is exact) and P_3 is a 53-bit number. Together, these -// approximate pi well enough for all cases in the restricted -// range. -// -// The main reduction sequence is: -// -// y = 32/pi * x -// N = integer(y) -// (computed by adding and subtracting off SHIFTER) -// -// m_1 = N * P_1 -// m_2 = N * P_2 -// r_1 = x - m_1 -// r = r_1 - m_2 -// (this r can be used for most of the calculation) -// -// c_1 = r_1 - r -// m_3 = N * P_3 -// c_2 = c_1 - m_2 -// c = c_2 - m_3 -// -// 2. MAIN ALGORITHM -// -// The algorithm uses a table lookup based on B = M * pi / 32 -// where M = N mod 64. The stored values are: -// sigma closest power of 2 to cos(B) -// C_hl 53-bit cos(B) - sigma -// S_hi + S_lo 2 * 53-bit sin(B) -// -// The computation is organized as follows: -// -// sin(B + r + c) = [sin(B) + sigma * r] + -// r * (cos(B) - sigma) + -// sin(B) * [cos(r + c) - 1] + -// cos(B) * [sin(r + c) - r] -// -// which is approximately: -// -// [S_hi + sigma * r] + -// C_hl * r + -// S_lo + S_hi * [(cos(r) - 1) - r * c] + -// (C_hl + sigma) * [(sin(r) - r) + c] -// -// and this is what is actually computed. We separate this sum -// into four parts: -// -// hi + med + pols + corr -// -// where -// -// hi = S_hi + sigma r -// med = C_hl * r -// pols = S_hi * (cos(r) - 1) + (C_hl + sigma) * (sin(r) - r) -// corr = S_lo + c * ((C_hl + sigma) - S_hi * r) -// -// 3. POLYNOMIAL -// -// The polynomial S_hi * (cos(r) - 1) + (C_hl + sigma) * -// (sin(r) - r) can be rearranged freely, since it is quite -// small, so we exploit parallelism to the fullest. -// -// psc4 = SC_4 * r_1 -// msc4 = psc4 * r -// r2 = r * r -// msc2 = SC_2 * r2 -// r4 = r2 * r2 -// psc3 = SC_3 + msc4 -// psc1 = SC_1 + msc2 -// msc3 = r4 * psc3 -// sincospols = psc1 + msc3 -// pols = sincospols * -// -// -// 4. CORRECTION TERM -// -// This is where the "c" component of the range reduction is -// taken into account; recall that just "r" is used for most of -// the calculation. -// -// -c = m_3 - c_2 -// -d = S_hi * r - (C_hl + sigma) -// corr = -c * -d + S_lo -// -// 5. COMPENSATED SUMMATIONS -// -// The two successive compensated summations add up the high -// and medium parts, leaving just the low parts to add up at -// the end. -// -// rs = sigma * r -// res_int = S_hi + rs -// k_0 = S_hi - res_int -// k_2 = k_0 + rs -// med = C_hl * r -// res_hi = res_int + med -// k_1 = res_int - res_hi -// k_3 = k_1 + med -// -// 6. FINAL SUMMATION -// -// We now add up all the small parts: -// -// res_lo = pols(hi) + pols(lo) + corr + k_1 + k_3 -// -// Now the overall result is just: -// -// res_hi + res_lo -// -// 7. SMALL ARGUMENTS -// -// Inputs with |X| < 2^-252 are treated specially as -// 1 - |x|. -// -// Special cases: -// cos(NaN) = quiet NaN, and raise invalid exception -// cos(INF) = NaN and raise invalid exception -// cos(0) = 1 -// -/******************************************************************************/ - -ALIGNED_(16) juint _static_const_table_cos[] = -{ - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, 0xbf73b92eUL, - 0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL, - 0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, - 0xc0000000UL, 0xbc626d19UL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, - 0xbfa60beaUL, 0x2ed59f06UL, 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, - 0x00000000UL, 0x3ff00000UL, 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, - 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, 0x00000000UL, 0x3ff00000UL, - 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, 0x20000000UL, - 0x3c5e0d89UL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, 0xbfc59267UL, - 0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL, - 0x3ff00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, - 0x20000000UL, 0x3c68076aUL, 0x00000000UL, 0x3ff00000UL, 0x99fcef32UL, - 0x3fca8279UL, 0x667f3bcdUL, 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, - 0x00000000UL, 0x3fe00000UL, 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, - 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, 0x00000000UL, 0x3fe00000UL, - 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, 0xe0000000UL, - 0x3c39f630UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, 0xbf9d4a2cUL, - 0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL, - 0x3fe00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0x3fed906bUL, - 0x20000000UL, 0x3c7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x76acf82dUL, - 0x3fa4a031UL, 0x56c62ddaUL, 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, - 0x00000000UL, 0x3fd00000UL, 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, - 0x3fef6297UL, 0x20000000UL, 0x3c756217UL, 0x00000000UL, 0x3fd00000UL, - 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, 0x40000000UL, - 0xbc887df6UL, 0x00000000UL, 0x3fc00000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, - 0x40000000UL, 0xbc887df6UL, 0x00000000UL, 0xbfc00000UL, 0x0e5967d5UL, - 0x3fac1d1fUL, 0xcff75cb0UL, 0x3fef6297UL, 0x20000000UL, 0x3c756217UL, - 0x00000000UL, 0xbfd00000UL, 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, - 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, 0x00000000UL, 0xbfd00000UL, - 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, 0x3fed906bUL, 0x20000000UL, - 0x3c7457e6UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, 0x3f9d4a2cUL, - 0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL, - 0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, - 0xe0000000UL, 0x3c39f630UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, - 0xbfc133ccUL, 0x6b151741UL, 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, - 0x00000000UL, 0xbfe00000UL, 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, - 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, 0x00000000UL, 0xbfe00000UL, - 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, 0x20000000UL, - 0x3c68076aUL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, 0x3fc59267UL, - 0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL, - 0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, - 0x20000000UL, 0x3c5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, - 0x3fb37ca1UL, 0xa6aea963UL, 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, - 0x00000000UL, 0xbff00000UL, 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, - 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, 0x00000000UL, 0xbff00000UL, - 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, 0xc0000000UL, - 0xbc626d19UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, 0x3f73b92eUL, - 0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL, - 0xbff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, - 0x3f73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL, - 0x00000000UL, 0xbff00000UL, 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, - 0xbfc8f8b8UL, 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0xbff00000UL, - 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, - 0x3c75d28dUL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, 0x3fb37ca1UL, - 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, 0x3c672cedUL, 0x00000000UL, - 0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0xbfde2b5dUL, - 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, - 0x3fc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL, - 0x00000000UL, 0xbff00000UL, 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, - 0xbfe44cf3UL, 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0xbff00000UL, - 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, - 0x3c8bdd34UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, 0xbfc133ccUL, - 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, 0x3c82c5e1UL, 0x00000000UL, - 0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0xbfea9b66UL, - 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, - 0x3f9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL, - 0x00000000UL, 0xbfe00000UL, 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, - 0xbfed906bUL, 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0xbfe00000UL, - 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, - 0xbc8760b1UL, 0x00000000UL, 0xbfd00000UL, 0x0e5967d5UL, 0x3fac1d1fUL, - 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, 0xbc756217UL, 0x00000000UL, - 0xbfd00000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0xbfefd88dUL, - 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0xbfc00000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, - 0xbfefd88dUL, 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0x3fc00000UL, - 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, - 0xbc756217UL, 0x00000000UL, 0x3fd00000UL, 0x76acf82dUL, 0x3fa4a031UL, - 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, 0xbc8760b1UL, 0x00000000UL, - 0x3fd00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0xbfed906bUL, - 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, - 0xbf9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL, - 0x00000000UL, 0x3fe00000UL, 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, - 0xbfea9b66UL, 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0x3fe00000UL, - 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, - 0x3c82c5e1UL, 0x00000000UL, 0x3fe00000UL, 0x99fcef32UL, 0x3fca8279UL, - 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, 0x3c8bdd34UL, 0x00000000UL, - 0x3fe00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0xbfe44cf3UL, - 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, - 0xbfc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL, - 0x00000000UL, 0x3ff00000UL, 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, - 0xbfde2b5dUL, 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0x3ff00000UL, - 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, - 0x3c672cedUL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, 0xbfa60beaUL, - 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, 0x3c75d28dUL, 0x00000000UL, - 0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0xbfc8f8b8UL, - 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, - 0xbf73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL, - 0x00000000UL, 0x3ff00000UL, 0x55555555UL, 0xbfc55555UL, 0x00000000UL, - 0xbfe00000UL, 0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL, - 0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL, 0xa556c734UL, - 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL, 0x1a600000UL, 0x3d90b461UL, - 0x1a600000UL, 0x3d90b461UL, 0x54400000UL, 0x3fb921fbUL, 0x00000000UL, - 0x00000000UL, 0x2e037073UL, 0x3b63198aUL, 0x00000000UL, 0x00000000UL, - 0x6dc9c883UL, 0x40245f30UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x43380000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x3ff00000UL, - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x80000000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL -}; - -//registers, -// input: (rbp + 8) -// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 -// rax, rdx, rcx, rbx (tmp) - -// Code generated by Intel C compiler for LIBM library - -void MacroAssembler::fast_cos(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) { - Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; - Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; - Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2; - Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start; - - assert_different_registers(tmp, eax, ecx, edx); - - address static_const_table_cos = (address)_static_const_table_cos; - - bind(start); - subl(rsp, 120); - movl(Address(rsp, 56), tmp); - lea(tmp, ExternalAddress(static_const_table_cos)); - movsd(xmm0, Address(rsp, 128)); - pextrw(eax, xmm0, 3); - andl(eax, 32767); - subl(eax, 12336); - cmpl(eax, 4293); - jcc(Assembler::above, L_2TAG_PACKET_0_0_2); - movsd(xmm1, Address(tmp, 2160)); - mulsd(xmm1, xmm0); - movdqu(xmm5, Address(tmp, 2240)); - movsd(xmm4, Address(tmp, 2224)); - pand(xmm4, xmm0); - por(xmm5, xmm4); - movsd(xmm3, Address(tmp, 2128)); - movdqu(xmm2, Address(tmp, 2112)); - addpd(xmm1, xmm5); - cvttsd2sil(edx, xmm1); - cvtsi2sdl(xmm1, edx); - mulsd(xmm3, xmm1); - unpcklpd(xmm1, xmm1); - addl(edx, 1865232); - movdqu(xmm4, xmm0); - andl(edx, 63); - movdqu(xmm5, Address(tmp, 2096)); - lea(eax, Address(tmp, 0)); - shll(edx, 5); - addl(eax, edx); - mulpd(xmm2, xmm1); - subsd(xmm0, xmm3); - mulsd(xmm1, Address(tmp, 2144)); - subsd(xmm4, xmm3); - movsd(xmm7, Address(eax, 8)); - unpcklpd(xmm0, xmm0); - movapd(xmm3, xmm4); - subsd(xmm4, xmm2); - mulpd(xmm5, xmm0); - subpd(xmm0, xmm2); - movdqu(xmm6, Address(tmp, 2064)); - mulsd(xmm7, xmm4); - subsd(xmm3, xmm4); - mulpd(xmm5, xmm0); - mulpd(xmm0, xmm0); - subsd(xmm3, xmm2); - movdqu(xmm2, Address(eax, 0)); - subsd(xmm1, xmm3); - movsd(xmm3, Address(eax, 24)); - addsd(xmm2, xmm3); - subsd(xmm7, xmm2); - mulsd(xmm2, xmm4); - mulpd(xmm6, xmm0); - mulsd(xmm3, xmm4); - mulpd(xmm2, xmm0); - mulpd(xmm0, xmm0); - addpd(xmm5, Address(tmp, 2080)); - mulsd(xmm4, Address(eax, 0)); - addpd(xmm6, Address(tmp, 2048)); - mulpd(xmm5, xmm0); - movapd(xmm0, xmm3); - addsd(xmm3, Address(eax, 8)); - mulpd(xmm1, xmm7); - movapd(xmm7, xmm4); - addsd(xmm4, xmm3); - addpd(xmm6, xmm5); - movsd(xmm5, Address(eax, 8)); - subsd(xmm5, xmm3); - subsd(xmm3, xmm4); - addsd(xmm1, Address(eax, 16)); - mulpd(xmm6, xmm2); - addsd(xmm5, xmm0); - addsd(xmm3, xmm7); - addsd(xmm1, xmm5); - addsd(xmm1, xmm3); - addsd(xmm1, xmm6); - unpckhpd(xmm6, xmm6); - addsd(xmm1, xmm6); - addsd(xmm4, xmm1); - movsd(Address(rsp, 0), xmm4); - fld_d(Address(rsp, 0)); - jmp(L_2TAG_PACKET_1_0_2); - - bind(L_2TAG_PACKET_0_0_2); - jcc(Assembler::greater, L_2TAG_PACKET_2_0_2); - pextrw(eax, xmm0, 3); - andl(eax, 32767); - pinsrw(xmm0, eax, 3); - movsd(xmm1, Address(tmp, 2192)); - subsd(xmm1, xmm0); - movsd(Address(rsp, 0), xmm1); - fld_d(Address(rsp, 0)); - jmp(L_2TAG_PACKET_1_0_2); - - bind(L_2TAG_PACKET_2_0_2); - movl(eax, Address(rsp, 132)); - andl(eax, 2146435072); - cmpl(eax, 2146435072); - jcc(Assembler::equal, L_2TAG_PACKET_3_0_2); - subl(rsp, 32); - movsd(Address(rsp, 0), xmm0); - lea(eax, Address(rsp, 40)); - movl(Address(rsp, 8), eax); - movl(eax, 1); - movl(Address(rsp, 12), eax); - call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_sin_cos_huge()))); - addl(rsp, 32); - fld_d(Address(rsp, 8)); - jmp(L_2TAG_PACKET_1_0_2); - - bind(L_2TAG_PACKET_3_0_2); - fld_d(Address(rsp, 128)); - fmul_d(Address(tmp, 2208)); - - bind(L_2TAG_PACKET_1_0_2); - movl(tmp, Address(rsp, 56)); -} - diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_64.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_64.cpp deleted file mode 100644 index f2f2211d88b..00000000000 --- a/hotspot/src/cpu/x86/vm/macroAssembler_libm_x86_64.cpp +++ /dev/null @@ -1,3945 +0,0 @@ -/* - * Copyright (c) 2015, Intel Corporation. - * Intel Math Library (LIBM) Source Code - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "asm/assembler.hpp" -#include "asm/assembler.inline.hpp" -#include "macroAssembler_x86.hpp" - -#ifdef _MSC_VER -#define ALIGNED_(x) __declspec(align(x)) -#else -#define ALIGNED_(x) __attribute__ ((aligned(x))) -#endif - -// The 64 bit code is at most SSE2 compliant - -/******************************************************************************/ -// ALGORITHM DESCRIPTION - EXP() -// --------------------- -// -// Description: -// Let K = 64 (table size). -// x x/log(2) n -// e = 2 = 2 * T[j] * (1 + P(y)) -// where -// x = m*log(2)/K + y, y in [-log(2)/K..log(2)/K] -// m = n*K + j, m,n,j - signed integer, j in [-K/2..K/2] -// j/K -// values of 2 are tabulated as T[j] = T_hi[j] ( 1 + T_lo[j]). -// -// P(y) is a minimax polynomial approximation of exp(x)-1 -// on small interval [-log(2)/K..log(2)/K] (were calculated by Maple V). -// -// To avoid problems with arithmetic overflow and underflow, -// n n1 n2 -// value of 2 is safely computed as 2 * 2 where n1 in [-BIAS/2..BIAS/2] -// where BIAS is a value of exponent bias. -// -// Special cases: -// exp(NaN) = NaN -// exp(+INF) = +INF -// exp(-INF) = 0 -// exp(x) = 1 for subnormals -// for finite argument, only exp(0)=1 is exact -// For IEEE double -// if x > 709.782712893383973096 then exp(x) overflow -// if x < -745.133219101941108420 then exp(x) underflow -// -/******************************************************************************/ - -ALIGNED_(16) juint _cv[] = -{ - 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL, 0xfefa0000UL, - 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL, 0xbc9e3b3aUL, 0x3d1cf79aUL, - 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL, - 0x3fdfffffUL, 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL, - 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL -}; - -ALIGNED_(16) juint _shifter[] = -{ - 0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL -}; - -ALIGNED_(16) juint _mmask[] = -{ - 0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL -}; - -ALIGNED_(16) juint _bias[] = -{ - 0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL -}; - -ALIGNED_(16) juint _Tbl_addr[] = -{ - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0e03754dUL, - 0x3cad7bbfUL, 0x3e778060UL, 0x00002c9aUL, 0x3567f613UL, 0x3c8cd252UL, - 0xd3158574UL, 0x000059b0UL, 0x61e6c861UL, 0x3c60f74eUL, 0x18759bc8UL, - 0x00008745UL, 0x5d837b6cUL, 0x3c979aa6UL, 0x6cf9890fUL, 0x0000b558UL, - 0x702f9cd1UL, 0x3c3ebe3dUL, 0x32d3d1a2UL, 0x0000e3ecUL, 0x1e63bcd8UL, - 0x3ca3516eUL, 0xd0125b50UL, 0x00011301UL, 0x26f0387bUL, 0x3ca4c554UL, - 0xaea92ddfUL, 0x0001429aUL, 0x62523fb6UL, 0x3ca95153UL, 0x3c7d517aUL, - 0x000172b8UL, 0x3f1353bfUL, 0x3c8b898cUL, 0xeb6fcb75UL, 0x0001a35bUL, - 0x3e3a2f5fUL, 0x3c9aecf7UL, 0x3168b9aaUL, 0x0001d487UL, 0x44a6c38dUL, - 0x3c8a6f41UL, 0x88628cd6UL, 0x0002063bUL, 0xe3a8a894UL, 0x3c968efdUL, - 0x6e756238UL, 0x0002387aUL, 0x981fe7f2UL, 0x3c80472bUL, 0x65e27cddUL, - 0x00026b45UL, 0x6d09ab31UL, 0x3c82f7e1UL, 0xf51fdee1UL, 0x00029e9dUL, - 0x720c0ab3UL, 0x3c8b3782UL, 0xa6e4030bUL, 0x0002d285UL, 0x4db0abb6UL, - 0x3c834d75UL, 0x0a31b715UL, 0x000306feUL, 0x5dd3f84aUL, 0x3c8fdd39UL, - 0xb26416ffUL, 0x00033c08UL, 0xcc187d29UL, 0x3ca12f8cUL, 0x373aa9caUL, - 0x000371a7UL, 0x738b5e8bUL, 0x3ca7d229UL, 0x34e59ff6UL, 0x0003a7dbUL, - 0xa72a4c6dUL, 0x3c859f48UL, 0x4c123422UL, 0x0003dea6UL, 0x259d9205UL, - 0x3ca8b846UL, 0x21f72e29UL, 0x0004160aUL, 0x60c2ac12UL, 0x3c4363edUL, - 0x6061892dUL, 0x00044e08UL, 0xdaa10379UL, 0x3c6ecce1UL, 0xb5c13cd0UL, - 0x000486a2UL, 0xbb7aafb0UL, 0x3c7690ceUL, 0xd5362a27UL, 0x0004bfdaUL, - 0x9b282a09UL, 0x3ca083ccUL, 0x769d2ca6UL, 0x0004f9b2UL, 0xc1aae707UL, - 0x3ca509b0UL, 0x569d4f81UL, 0x0005342bUL, 0x18fdd78eUL, 0x3c933505UL, - 0x36b527daUL, 0x00056f47UL, 0xe21c5409UL, 0x3c9063e1UL, 0xdd485429UL, - 0x0005ab07UL, 0x2b64c035UL, 0x3c9432e6UL, 0x15ad2148UL, 0x0005e76fUL, - 0x99f08c0aUL, 0x3ca01284UL, 0xb03a5584UL, 0x0006247eUL, 0x0073dc06UL, - 0x3c99f087UL, 0x82552224UL, 0x00066238UL, 0x0da05571UL, 0x3c998d4dUL, - 0x667f3bccUL, 0x0006a09eUL, 0x86ce4786UL, 0x3ca52bb9UL, 0x3c651a2eUL, - 0x0006dfb2UL, 0x206f0dabUL, 0x3ca32092UL, 0xe8ec5f73UL, 0x00071f75UL, - 0x8e17a7a6UL, 0x3ca06122UL, 0x564267c8UL, 0x00075febUL, 0x461e9f86UL, - 0x3ca244acUL, 0x73eb0186UL, 0x0007a114UL, 0xabd66c55UL, 0x3c65ebe1UL, - 0x36cf4e62UL, 0x0007e2f3UL, 0xbbff67d0UL, 0x3c96fe9fUL, 0x994cce12UL, - 0x00082589UL, 0x14c801dfUL, 0x3c951f14UL, 0x9b4492ecUL, 0x000868d9UL, - 0xc1f0eab4UL, 0x3c8db72fUL, 0x422aa0dbUL, 0x0008ace5UL, 0x59f35f44UL, - 0x3c7bf683UL, 0x99157736UL, 0x0008f1aeUL, 0x9c06283cUL, 0x3ca360baUL, - 0xb0cdc5e4UL, 0x00093737UL, 0x20f962aaUL, 0x3c95e8d1UL, 0x9fde4e4fUL, - 0x00097d82UL, 0x2b91ce27UL, 0x3c71affcUL, 0x82a3f090UL, 0x0009c491UL, - 0x589a2ebdUL, 0x3c9b6d34UL, 0x7b5de564UL, 0x000a0c66UL, 0x9ab89880UL, - 0x3c95277cUL, 0xb23e255cUL, 0x000a5503UL, 0x6e735ab3UL, 0x3c846984UL, - 0x5579fdbfUL, 0x000a9e6bUL, 0x92cb3387UL, 0x3c8c1a77UL, 0x995ad3adUL, - 0x000ae89fUL, 0xdc2d1d96UL, 0x3ca22466UL, 0xb84f15faUL, 0x000b33a2UL, - 0xb19505aeUL, 0x3ca1112eUL, 0xf2fb5e46UL, 0x000b7f76UL, 0x0a5fddcdUL, - 0x3c74ffd7UL, 0x904bc1d2UL, 0x000bcc1eUL, 0x30af0cb3UL, 0x3c736eaeUL, - 0xdd85529cUL, 0x000c199bUL, 0xd10959acUL, 0x3c84e08fUL, 0x2e57d14bUL, - 0x000c67f1UL, 0x6c921968UL, 0x3c676b2cUL, 0xdcef9069UL, 0x000cb720UL, - 0x36df99b3UL, 0x3c937009UL, 0x4a07897bUL, 0x000d072dUL, 0xa63d07a7UL, - 0x3c74a385UL, 0xdcfba487UL, 0x000d5818UL, 0xd5c192acUL, 0x3c8e5a50UL, - 0x03db3285UL, 0x000da9e6UL, 0x1c4a9792UL, 0x3c98bb73UL, 0x337b9b5eUL, - 0x000dfc97UL, 0x603a88d3UL, 0x3c74b604UL, 0xe78b3ff6UL, 0x000e502eUL, - 0x92094926UL, 0x3c916f27UL, 0xa2a490d9UL, 0x000ea4afUL, 0x41aa2008UL, - 0x3c8ec3bcUL, 0xee615a27UL, 0x000efa1bUL, 0x31d185eeUL, 0x3c8a64a9UL, - 0x5b6e4540UL, 0x000f5076UL, 0x4d91cd9dUL, 0x3c77893bUL, 0x819e90d8UL, - 0x000fa7c1UL -}; - -ALIGNED_(16) juint _ALLONES[] = -{ - 0xffffffffUL, 0xffffffffUL, 0xffffffffUL, 0xffffffffUL -}; - -ALIGNED_(16) juint _ebias[] = -{ - 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3ff00000UL -}; - -ALIGNED_(4) juint _XMAX[] = -{ - 0xffffffffUL, 0x7fefffffUL -}; - -ALIGNED_(4) juint _XMIN[] = -{ - 0x00000000UL, 0x00100000UL -}; - -ALIGNED_(4) juint _INF[] = -{ - 0x00000000UL, 0x7ff00000UL -}; - -ALIGNED_(4) juint _ZERO[] = -{ - 0x00000000UL, 0x00000000UL -}; - -ALIGNED_(4) juint _ONE_val[] = -{ - 0x00000000UL, 0x3ff00000UL -}; - - -// Registers: -// input: xmm0 -// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 -// rax, rdx, rcx, tmp - r11 - -// Code generated by Intel C compiler for LIBM library - -void MacroAssembler::fast_exp(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) { - Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; - Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; - Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2; - Label L_2TAG_PACKET_12_0_2, B1_3, B1_5, start; - - assert_different_registers(tmp, eax, ecx, edx); - jmp(start); - address cv = (address)_cv; - address Shifter = (address)_shifter; - address mmask = (address)_mmask; - address bias = (address)_bias; - address Tbl_addr = (address)_Tbl_addr; - address ALLONES = (address)_ALLONES; - address ebias = (address)_ebias; - address XMAX = (address)_XMAX; - address XMIN = (address)_XMIN; - address INF = (address)_INF; - address ZERO = (address)_ZERO; - address ONE_val = (address)_ONE_val; - - bind(start); - subq(rsp, 24); - movsd(Address(rsp, 8), xmm0); - unpcklpd(xmm0, xmm0); - movdqu(xmm1, ExternalAddress(cv)); // 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL - movdqu(xmm6, ExternalAddress(Shifter)); // 0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL - movdqu(xmm2, ExternalAddress(16+cv)); // 0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL - movdqu(xmm3, ExternalAddress(32+cv)); // 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL - pextrw(eax, xmm0, 3); - andl(eax, 32767); - movl(edx, 16527); - subl(edx, eax); - subl(eax, 15504); - orl(edx, eax); - cmpl(edx, INT_MIN); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); - mulpd(xmm1, xmm0); - addpd(xmm1, xmm6); - movapd(xmm7, xmm1); - subpd(xmm1, xmm6); - mulpd(xmm2, xmm1); - movdqu(xmm4, ExternalAddress(64+cv)); // 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL - mulpd(xmm3, xmm1); - movdqu(xmm5, ExternalAddress(80+cv)); // 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL - subpd(xmm0, xmm2); - movdl(eax, xmm7); - movl(ecx, eax); - andl(ecx, 63); - shll(ecx, 4); - sarl(eax, 6); - movl(edx, eax); - movdqu(xmm6, ExternalAddress(mmask)); // 0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL - pand(xmm7, xmm6); - movdqu(xmm6, ExternalAddress(bias)); // 0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL - paddq(xmm7, xmm6); - psllq(xmm7, 46); - subpd(xmm0, xmm3); - lea(tmp, ExternalAddress(Tbl_addr)); - movdqu(xmm2, Address(ecx,tmp)); - mulpd(xmm4, xmm0); - movapd(xmm6, xmm0); - movapd(xmm1, xmm0); - mulpd(xmm6, xmm6); - mulpd(xmm0, xmm6); - addpd(xmm5, xmm4); - mulsd(xmm0, xmm6); - mulpd(xmm6, ExternalAddress(48+cv)); // 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL, 0x3fdfffffUL - addsd(xmm1, xmm2); - unpckhpd(xmm2, xmm2); - mulpd(xmm0, xmm5); - addsd(xmm1, xmm0); - por(xmm2, xmm7); - unpckhpd(xmm0, xmm0); - addsd(xmm0, xmm1); - addsd(xmm0, xmm6); - addl(edx, 894); - cmpl(edx, 1916); - jcc (Assembler::above, L_2TAG_PACKET_1_0_2); - mulsd(xmm0, xmm2); - addsd(xmm0, xmm2); - jmp (B1_5); - - bind(L_2TAG_PACKET_1_0_2); - xorpd(xmm3, xmm3); - movdqu(xmm4, ExternalAddress(ALLONES)); // 0xffffffffUL, 0xffffffffUL, 0xffffffffUL, 0xffffffffUL - movl(edx, -1022); - subl(edx, eax); - movdl(xmm5, edx); - psllq(xmm4, xmm5); - movl(ecx, eax); - sarl(eax, 1); - pinsrw(xmm3, eax, 3); - movdqu(xmm6, ExternalAddress(ebias)); // 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3ff00000UL - psllq(xmm3, 4); - psubd(xmm2, xmm3); - mulsd(xmm0, xmm2); - cmpl(edx, 52); - jcc(Assembler::greater, L_2TAG_PACKET_2_0_2); - pand(xmm4, xmm2); - paddd(xmm3, xmm6); - subsd(xmm2, xmm4); - addsd(xmm0, xmm2); - cmpl(ecx, 1023); - jcc(Assembler::greaterEqual, L_2TAG_PACKET_3_0_2); - pextrw(ecx, xmm0, 3); - andl(ecx, 32768); - orl(edx, ecx); - cmpl(edx, 0); - jcc(Assembler::equal, L_2TAG_PACKET_4_0_2); - movapd(xmm6, xmm0); - addsd(xmm0, xmm4); - mulsd(xmm0, xmm3); - pextrw(ecx, xmm0, 3); - andl(ecx, 32752); - cmpl(ecx, 0); - jcc(Assembler::equal, L_2TAG_PACKET_5_0_2); - jmp(B1_5); - - bind(L_2TAG_PACKET_5_0_2); - mulsd(xmm6, xmm3); - mulsd(xmm4, xmm3); - movdqu(xmm0, xmm6); - pxor(xmm6, xmm4); - psrad(xmm6, 31); - pshufd(xmm6, xmm6, 85); - psllq(xmm0, 1); - psrlq(xmm0, 1); - pxor(xmm0, xmm6); - psrlq(xmm6, 63); - paddq(xmm0, xmm6); - paddq(xmm0, xmm4); - movl(Address(rsp,0), 15); - jmp(L_2TAG_PACKET_6_0_2); - - bind(L_2TAG_PACKET_4_0_2); - addsd(xmm0, xmm4); - mulsd(xmm0, xmm3); - jmp(B1_5); - - bind(L_2TAG_PACKET_3_0_2); - addsd(xmm0, xmm4); - mulsd(xmm0, xmm3); - pextrw(ecx, xmm0, 3); - andl(ecx, 32752); - cmpl(ecx, 32752); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_7_0_2); - jmp(B1_5); - - bind(L_2TAG_PACKET_2_0_2); - paddd(xmm3, xmm6); - addpd(xmm0, xmm2); - mulsd(xmm0, xmm3); - movl(Address(rsp,0), 15); - jmp(L_2TAG_PACKET_6_0_2); - - bind(L_2TAG_PACKET_8_0_2); - cmpl(eax, 2146435072); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_9_0_2); - movl(eax, Address(rsp,12)); - cmpl(eax, INT_MIN); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_10_0_2); - movsd(xmm0, ExternalAddress(XMAX)); // 0xffffffffUL, 0x7fefffffUL - mulsd(xmm0, xmm0); - - bind(L_2TAG_PACKET_7_0_2); - movl(Address(rsp,0), 14); - jmp(L_2TAG_PACKET_6_0_2); - - bind(L_2TAG_PACKET_10_0_2); - movsd(xmm0, ExternalAddress(XMIN)); // 0x00000000UL, 0x00100000UL - mulsd(xmm0, xmm0); - movl(Address(rsp,0), 15); - jmp(L_2TAG_PACKET_6_0_2); - - bind(L_2TAG_PACKET_9_0_2); - movl(edx, Address(rsp,8)); - cmpl(eax, 2146435072); - jcc(Assembler::above, L_2TAG_PACKET_11_0_2); - cmpl(edx, 0); - jcc(Assembler::notEqual, L_2TAG_PACKET_11_0_2); - movl(eax, Address(rsp,12)); - cmpl(eax, 2146435072); - jcc(Assembler::notEqual, L_2TAG_PACKET_12_0_2); - movsd(xmm0, ExternalAddress(INF)); // 0x00000000UL, 0x7ff00000UL - jmp(B1_5); - - bind(L_2TAG_PACKET_12_0_2); - movsd(xmm0, ExternalAddress(ZERO)); // 0x00000000UL, 0x00000000UL - jmp(B1_5); - - bind(L_2TAG_PACKET_11_0_2); - movsd(xmm0, Address(rsp, 8)); - addsd(xmm0, xmm0); - jmp(B1_5); - - bind(L_2TAG_PACKET_0_0_2); - movl(eax, Address(rsp, 12)); - andl(eax, 2147483647); - cmpl(eax, 1083179008); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_8_0_2); - movsd(Address(rsp, 8), xmm0); - addsd(xmm0, ExternalAddress(ONE_val)); // 0x00000000UL, 0x3ff00000UL - jmp(B1_5); - - bind(L_2TAG_PACKET_6_0_2); - movq(Address(rsp, 16), xmm0); - - bind(B1_3); - movq(xmm0, Address(rsp, 16)); - - bind(B1_5); - addq(rsp, 24); -} - -/******************************************************************************/ -// ALGORITHM DESCRIPTION - LOG() -// --------------------- -// -// x=2^k * mx, mx in [1,2) -// -// Get B~1/mx based on the output of rcpss instruction (B0) -// B = int((B0*2^7+0.5))/2^7 -// -// Reduced argument: r=B*mx-1.0 (computed accurately in high and low parts) -// -// Result: k*log(2) - log(B) + p(r) if |x-1| >= small value (2^-6) and -// p(r) is a degree 7 polynomial -// -log(B) read from data table (high, low parts) -// Result is formed from high and low parts -// -// Special cases: -// log(NaN) = quiet NaN, and raise invalid exception -// log(+INF) = that INF -// log(0) = -INF with divide-by-zero exception raised -// log(1) = +0 -// log(x) = NaN with invalid exception raised if x < -0, including -INF -// -/******************************************************************************/ - -ALIGNED_(16) juint _L_tbl[] = -{ - 0xfefa3800UL, 0x3fe62e42UL, 0x93c76730UL, 0x3d2ef357UL, 0xaa241800UL, - 0x3fe5ee82UL, 0x0cda46beUL, 0x3d220238UL, 0x5c364800UL, 0x3fe5af40UL, - 0xac10c9fbUL, 0x3d2dfa63UL, 0x26bb8c00UL, 0x3fe5707aUL, 0xff3303ddUL, - 0x3d09980bUL, 0x26867800UL, 0x3fe5322eUL, 0x5d257531UL, 0x3d05ccc4UL, - 0x835a5000UL, 0x3fe4f45aUL, 0x6d93b8fbUL, 0xbd2e6c51UL, 0x6f970c00UL, - 0x3fe4b6fdUL, 0xed4c541cUL, 0x3cef7115UL, 0x27e8a400UL, 0x3fe47a15UL, - 0xf94d60aaUL, 0xbd22cb6aUL, 0xf2f92400UL, 0x3fe43d9fUL, 0x481051f7UL, - 0xbcfd984fUL, 0x2125cc00UL, 0x3fe4019cUL, 0x30f0c74cUL, 0xbd26ce79UL, - 0x0c36c000UL, 0x3fe3c608UL, 0x7cfe13c2UL, 0xbd02b736UL, 0x17197800UL, - 0x3fe38ae2UL, 0xbb5569a4UL, 0xbd218b7aUL, 0xad9d8c00UL, 0x3fe35028UL, - 0x9527e6acUL, 0x3d10b83fUL, 0x44340800UL, 0x3fe315daUL, 0xc5a0ed9cUL, - 0xbd274e93UL, 0x57b0e000UL, 0x3fe2dbf5UL, 0x07b9dc11UL, 0xbd17a6e5UL, - 0x6d0ec000UL, 0x3fe2a278UL, 0xe797882dUL, 0x3d206d2bUL, 0x1134dc00UL, - 0x3fe26962UL, 0x05226250UL, 0xbd0b61f1UL, 0xd8bebc00UL, 0x3fe230b0UL, - 0x6e48667bUL, 0x3d12fc06UL, 0x5fc61800UL, 0x3fe1f863UL, 0xc9fe81d3UL, - 0xbd2a7242UL, 0x49ae6000UL, 0x3fe1c078UL, 0xed70e667UL, 0x3cccacdeUL, - 0x40f23c00UL, 0x3fe188eeUL, 0xf8ab4650UL, 0x3d14cc4eUL, 0xf6f29800UL, - 0x3fe151c3UL, 0xa293ae49UL, 0xbd2edd97UL, 0x23c75c00UL, 0x3fe11af8UL, - 0xbb9ddcb2UL, 0xbd258647UL, 0x8611cc00UL, 0x3fe0e489UL, 0x07801742UL, - 0x3d1c2998UL, 0xe2d05400UL, 0x3fe0ae76UL, 0x887e7e27UL, 0x3d1f486bUL, - 0x0533c400UL, 0x3fe078bfUL, 0x41edf5fdUL, 0x3d268122UL, 0xbe760400UL, - 0x3fe04360UL, 0xe79539e0UL, 0xbd04c45fUL, 0xe5b20800UL, 0x3fe00e5aUL, - 0xb1727b1cUL, 0xbd053ba3UL, 0xaf7a4800UL, 0x3fdfb358UL, 0x3c164935UL, - 0x3d0085faUL, 0xee031800UL, 0x3fdf4aa7UL, 0x6f014a8bUL, 0x3d12cde5UL, - 0x56b41000UL, 0x3fdee2a1UL, 0x5a470251UL, 0x3d2f27f4UL, 0xc3ddb000UL, - 0x3fde7b42UL, 0x5372bd08UL, 0xbd246550UL, 0x1a272800UL, 0x3fde148aUL, - 0x07322938UL, 0xbd1326b2UL, 0x484c9800UL, 0x3fddae75UL, 0x60dc616aUL, - 0xbd1ea42dUL, 0x46def800UL, 0x3fdd4902UL, 0xe9a767a8UL, 0x3d235bafUL, - 0x18064800UL, 0x3fdce42fUL, 0x3ec7a6b0UL, 0xbd0797c3UL, 0xc7455800UL, - 0x3fdc7ff9UL, 0xc15249aeUL, 0xbd29b6ddUL, 0x693fa000UL, 0x3fdc1c60UL, - 0x7fe8e180UL, 0x3d2cec80UL, 0x1b80e000UL, 0x3fdbb961UL, 0xf40a666dUL, - 0x3d27d85bUL, 0x04462800UL, 0x3fdb56faUL, 0x2d841995UL, 0x3d109525UL, - 0x5248d000UL, 0x3fdaf529UL, 0x52774458UL, 0xbd217cc5UL, 0x3c8ad800UL, - 0x3fda93edUL, 0xbea77a5dUL, 0x3d1e36f2UL, 0x0224f800UL, 0x3fda3344UL, - 0x7f9d79f5UL, 0x3d23c645UL, 0xea15f000UL, 0x3fd9d32bUL, 0x10d0c0b0UL, - 0xbd26279eUL, 0x43135800UL, 0x3fd973a3UL, 0xa502d9f0UL, 0xbd152313UL, - 0x635bf800UL, 0x3fd914a8UL, 0x2ee6307dUL, 0xbd1766b5UL, 0xa88b3000UL, - 0x3fd8b639UL, 0xe5e70470UL, 0xbd205ae1UL, 0x776dc800UL, 0x3fd85855UL, - 0x3333778aUL, 0x3d2fd56fUL, 0x3bd81800UL, 0x3fd7fafaUL, 0xc812566aUL, - 0xbd272090UL, 0x687cf800UL, 0x3fd79e26UL, 0x2efd1778UL, 0x3d29ec7dUL, - 0x76c67800UL, 0x3fd741d8UL, 0x49dc60b3UL, 0x3d2d8b09UL, 0xe6af1800UL, - 0x3fd6e60eUL, 0x7c222d87UL, 0x3d172165UL, 0x3e9c6800UL, 0x3fd68ac8UL, - 0x2756eba0UL, 0x3d20a0d3UL, 0x0b3ab000UL, 0x3fd63003UL, 0xe731ae00UL, - 0xbd2db623UL, 0xdf596000UL, 0x3fd5d5bdUL, 0x08a465dcUL, 0xbd0a0b2aUL, - 0x53c8d000UL, 0x3fd57bf7UL, 0xee5d40efUL, 0x3d1fadedUL, 0x0738a000UL, - 0x3fd522aeUL, 0x8164c759UL, 0x3d2ebe70UL, 0x9e173000UL, 0x3fd4c9e0UL, - 0x1b0ad8a4UL, 0xbd2e2089UL, 0xc271c800UL, 0x3fd4718dUL, 0x0967d675UL, - 0xbd2f27ceUL, 0x23d5e800UL, 0x3fd419b4UL, 0xec90e09dUL, 0x3d08e436UL, - 0x77333000UL, 0x3fd3c252UL, 0xb606bd5cUL, 0x3d183b54UL, 0x76be1000UL, - 0x3fd36b67UL, 0xb0f177c8UL, 0x3d116ecdUL, 0xe1d36000UL, 0x3fd314f1UL, - 0xd3213cb8UL, 0xbd28e27aUL, 0x7cdc9000UL, 0x3fd2bef0UL, 0x4a5004f4UL, - 0x3d2a9cfaUL, 0x1134d800UL, 0x3fd26962UL, 0xdf5bb3b6UL, 0x3d2c93c1UL, - 0x6d0eb800UL, 0x3fd21445UL, 0xba46baeaUL, 0x3d0a87deUL, 0x635a6800UL, - 0x3fd1bf99UL, 0x5147bdb7UL, 0x3d2ca6edUL, 0xcbacf800UL, 0x3fd16b5cUL, - 0xf7a51681UL, 0x3d2b9acdUL, 0x8227e800UL, 0x3fd1178eUL, 0x63a5f01cUL, - 0xbd2c210eUL, 0x67616000UL, 0x3fd0c42dUL, 0x163ceae9UL, 0x3d27188bUL, - 0x604d5800UL, 0x3fd07138UL, 0x16ed4e91UL, 0x3cf89cdbUL, 0x5626c800UL, - 0x3fd01eaeUL, 0x1485e94aUL, 0xbd16f08cUL, 0x6cb3b000UL, 0x3fcf991cUL, - 0xca0cdf30UL, 0x3d1bcbecUL, 0xe4dd0000UL, 0x3fcef5adUL, 0x65bb8e11UL, - 0xbcca2115UL, 0xffe71000UL, 0x3fce530eUL, 0x6041f430UL, 0x3cc21227UL, - 0xb0d49000UL, 0x3fcdb13dUL, 0xf715b035UL, 0xbd2aff2aUL, 0xf2656000UL, - 0x3fcd1037UL, 0x75b6f6e4UL, 0xbd084a7eUL, 0xc6f01000UL, 0x3fcc6ffbUL, - 0xc5962bd2UL, 0xbcf1ec72UL, 0x383be000UL, 0x3fcbd087UL, 0x595412b6UL, - 0xbd2d4bc4UL, 0x575bd000UL, 0x3fcb31d8UL, 0x4eace1aaUL, 0xbd0c358dUL, - 0x3c8ae000UL, 0x3fca93edUL, 0x50562169UL, 0xbd287243UL, 0x07089000UL, - 0x3fc9f6c4UL, 0x6865817aUL, 0x3d29904dUL, 0xdcf70000UL, 0x3fc95a5aUL, - 0x58a0ff6fUL, 0x3d07f228UL, 0xeb390000UL, 0x3fc8beafUL, 0xaae92cd1UL, - 0xbd073d54UL, 0x6551a000UL, 0x3fc823c1UL, 0x9a631e83UL, 0x3d1e0ddbUL, - 0x85445000UL, 0x3fc7898dUL, 0x70914305UL, 0xbd1c6610UL, 0x8b757000UL, - 0x3fc6f012UL, 0xe59c21e1UL, 0xbd25118dUL, 0xbe8c1000UL, 0x3fc6574eUL, - 0x2c3c2e78UL, 0x3d19cf8bUL, 0x6b544000UL, 0x3fc5bf40UL, 0xeb68981cUL, - 0xbd127023UL, 0xe4a1b000UL, 0x3fc527e5UL, 0xe5697dc7UL, 0x3d2633e8UL, - 0x8333b000UL, 0x3fc4913dUL, 0x54fdb678UL, 0x3d258379UL, 0xa5993000UL, - 0x3fc3fb45UL, 0x7e6a354dUL, 0xbd2cd1d8UL, 0xb0159000UL, 0x3fc365fcUL, - 0x234b7289UL, 0x3cc62fa8UL, 0x0c868000UL, 0x3fc2d161UL, 0xcb81b4a1UL, - 0x3d039d6cUL, 0x2a49c000UL, 0x3fc23d71UL, 0x8fd3df5cUL, 0x3d100d23UL, - 0x7e23f000UL, 0x3fc1aa2bUL, 0x44389934UL, 0x3d2ca78eUL, 0x8227e000UL, - 0x3fc1178eUL, 0xce2d07f2UL, 0x3d21ef78UL, 0xb59e4000UL, 0x3fc08598UL, - 0x7009902cUL, 0xbd27e5ddUL, 0x39dbe000UL, 0x3fbfe891UL, 0x4fa10afdUL, - 0xbd2534d6UL, 0x830a2000UL, 0x3fbec739UL, 0xafe645e0UL, 0xbd2dc068UL, - 0x63844000UL, 0x3fbda727UL, 0x1fa71733UL, 0x3d1a8940UL, 0x01bc4000UL, - 0x3fbc8858UL, 0xc65aacd3UL, 0x3d2646d1UL, 0x8dad6000UL, 0x3fbb6ac8UL, - 0x2bf768e5UL, 0xbd139080UL, 0x40b1c000UL, 0x3fba4e76UL, 0xb94407c8UL, - 0xbd0e42b6UL, 0x5d594000UL, 0x3fb9335eUL, 0x3abd47daUL, 0x3d23115cUL, - 0x2f40e000UL, 0x3fb8197eUL, 0xf96ffdf7UL, 0x3d0f80dcUL, 0x0aeac000UL, - 0x3fb700d3UL, 0xa99ded32UL, 0x3cec1e8dUL, 0x4d97a000UL, 0x3fb5e95aUL, - 0x3c5d1d1eUL, 0xbd2c6906UL, 0x5d208000UL, 0x3fb4d311UL, 0x82f4e1efUL, - 0xbcf53a25UL, 0xa7d1e000UL, 0x3fb3bdf5UL, 0xa5db4ed7UL, 0x3d2cc85eUL, - 0xa4472000UL, 0x3fb2aa04UL, 0xae9c697dUL, 0xbd20b6e8UL, 0xd1466000UL, - 0x3fb1973bUL, 0x560d9e9bUL, 0xbd25325dUL, 0xb59e4000UL, 0x3fb08598UL, - 0x7009902cUL, 0xbd17e5ddUL, 0xc006c000UL, 0x3faeea31UL, 0x4fc93b7bUL, - 0xbd0e113eUL, 0xcdddc000UL, 0x3faccb73UL, 0x47d82807UL, 0xbd1a68f2UL, - 0xd0fb0000UL, 0x3faaaef2UL, 0x353bb42eUL, 0x3d20fc1aUL, 0x149fc000UL, - 0x3fa894aaUL, 0xd05a267dUL, 0xbd197995UL, 0xf2d4c000UL, 0x3fa67c94UL, - 0xec19afa2UL, 0xbd029efbUL, 0xd42e0000UL, 0x3fa466aeUL, 0x75bdfd28UL, - 0xbd2c1673UL, 0x2f8d0000UL, 0x3fa252f3UL, 0xe021b67bUL, 0x3d283e9aUL, - 0x89e74000UL, 0x3fa0415dUL, 0x5cf1d753UL, 0x3d0111c0UL, 0xec148000UL, - 0x3f9c63d2UL, 0x3f9eb2f3UL, 0x3d2578c6UL, 0x28c90000UL, 0x3f984925UL, - 0x325a0c34UL, 0xbd2aa0baUL, 0x25980000UL, 0x3f9432a9UL, 0x928637feUL, - 0x3d098139UL, 0x58938000UL, 0x3f902056UL, 0x06e2f7d2UL, 0xbd23dc5bUL, - 0xa3890000UL, 0x3f882448UL, 0xda74f640UL, 0xbd275577UL, 0x75890000UL, - 0x3f801015UL, 0x999d2be8UL, 0xbd10c76bUL, 0x59580000UL, 0x3f700805UL, - 0xcb31c67bUL, 0x3d2166afUL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x80000000UL -}; - -ALIGNED_(16) juint _log2[] = -{ - 0xfefa3800UL, 0x3fa62e42UL, 0x93c76730UL, 0x3ceef357UL -}; - -ALIGNED_(16) juint _coeff[] = -{ - 0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL, 0x3d6fb175UL, - 0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL, 0x9999999aUL, 0x3fc99999UL, - 0x00000000UL, 0xbfe00000UL -}; - -//registers, -// input: xmm0 -// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 -// rax, rdx, rcx, r8, r11 - -void MacroAssembler::fast_log(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp1, Register tmp2) { - Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; - Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; - Label L_2TAG_PACKET_8_0_2; - Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start; - - assert_different_registers(tmp1, tmp2, eax, ecx, edx); - jmp(start); - address L_tbl = (address)_L_tbl; - address log2 = (address)_log2; - address coeff = (address)_coeff; - - bind(start); - subq(rsp, 24); - movsd(Address(rsp, 0), xmm0); - mov64(rax, 0x3ff0000000000000); - movdq(xmm2, rax); - mov64(rdx, 0x77f0000000000000); - movdq(xmm3, rdx); - movl(ecx, 32768); - movdl(xmm4, rcx); - mov64(tmp1, 0xffffe00000000000); - movdq(xmm5, tmp1); - movdqu(xmm1, xmm0); - pextrw(eax, xmm0, 3); - por(xmm0, xmm2); - movl(ecx, 16352); - psrlq(xmm0, 27); - lea(tmp2, ExternalAddress(L_tbl)); - psrld(xmm0, 2); - rcpps(xmm0, xmm0); - psllq(xmm1, 12); - pshufd(xmm6, xmm5, 228); - psrlq(xmm1, 12); - subl(eax, 16); - cmpl(eax, 32736); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); - - bind(L_2TAG_PACKET_1_0_2); - paddd(xmm0, xmm4); - por(xmm1, xmm3); - movdl(edx, xmm0); - psllq(xmm0, 29); - pand(xmm5, xmm1); - pand(xmm0, xmm6); - subsd(xmm1, xmm5); - mulpd(xmm5, xmm0); - andl(eax, 32752); - subl(eax, ecx); - cvtsi2sdl(xmm7, eax); - mulsd(xmm1, xmm0); - movq(xmm6, ExternalAddress(log2)); // 0xfefa3800UL, 0x3fa62e42UL - movdqu(xmm3, ExternalAddress(coeff)); // 0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL - subsd(xmm5, xmm2); - andl(edx, 16711680); - shrl(edx, 12); - movdqu(xmm0, Address(tmp2, edx)); - movdqu(xmm4, ExternalAddress(16 + coeff)); // 0x3d6fb175UL, 0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL - addsd(xmm1, xmm5); - movdqu(xmm2, ExternalAddress(32 + coeff)); // 0x9999999aUL, 0x3fc99999UL, 0x00000000UL, 0xbfe00000UL - mulsd(xmm6, xmm7); - if (VM_Version::supports_sse3()) { - movddup(xmm5, xmm1); - } else { - movdqu(xmm5, xmm1); - movlhps(xmm5, xmm5); - } - mulsd(xmm7, ExternalAddress(8 + log2)); // 0x93c76730UL, 0x3ceef357UL - mulsd(xmm3, xmm1); - addsd(xmm0, xmm6); - mulpd(xmm4, xmm5); - mulpd(xmm5, xmm5); - if (VM_Version::supports_sse3()) { - movddup(xmm6, xmm0); - } else { - movdqu(xmm6, xmm0); - movlhps(xmm6, xmm6); - } - addsd(xmm0, xmm1); - addpd(xmm4, xmm2); - mulpd(xmm3, xmm5); - subsd(xmm6, xmm0); - mulsd(xmm4, xmm1); - pshufd(xmm2, xmm0, 238); - addsd(xmm1, xmm6); - mulsd(xmm5, xmm5); - addsd(xmm7, xmm2); - addpd(xmm4, xmm3); - addsd(xmm1, xmm7); - mulpd(xmm4, xmm5); - addsd(xmm1, xmm4); - pshufd(xmm5, xmm4, 238); - addsd(xmm1, xmm5); - addsd(xmm0, xmm1); - jmp(B1_5); - - bind(L_2TAG_PACKET_0_0_2); - movq(xmm0, Address(rsp, 0)); - movq(xmm1, Address(rsp, 0)); - addl(eax, 16); - cmpl(eax, 32768); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_2_0_2); - cmpl(eax, 16); - jcc(Assembler::below, L_2TAG_PACKET_3_0_2); - - bind(L_2TAG_PACKET_4_0_2); - addsd(xmm0, xmm0); - jmp(B1_5); - - bind(L_2TAG_PACKET_5_0_2); - jcc(Assembler::above, L_2TAG_PACKET_4_0_2); - cmpl(edx, 0); - jcc(Assembler::above, L_2TAG_PACKET_4_0_2); - jmp(L_2TAG_PACKET_6_0_2); - - bind(L_2TAG_PACKET_3_0_2); - xorpd(xmm1, xmm1); - addsd(xmm1, xmm0); - movdl(edx, xmm1); - psrlq(xmm1, 32); - movdl(ecx, xmm1); - orl(edx, ecx); - cmpl(edx, 0); - jcc(Assembler::equal, L_2TAG_PACKET_7_0_2); - xorpd(xmm1, xmm1); - movl(eax, 18416); - pinsrw(xmm1, eax, 3); - mulsd(xmm0, xmm1); - movdqu(xmm1, xmm0); - pextrw(eax, xmm0, 3); - por(xmm0, xmm2); - psrlq(xmm0, 27); - movl(ecx, 18416); - psrld(xmm0, 2); - rcpps(xmm0, xmm0); - psllq(xmm1, 12); - pshufd(xmm6, xmm5, 228); - psrlq(xmm1, 12); - jmp(L_2TAG_PACKET_1_0_2); - - bind(L_2TAG_PACKET_2_0_2); - movdl(edx, xmm1); - psrlq(xmm1, 32); - movdl(ecx, xmm1); - addl(ecx, ecx); - cmpl(ecx, -2097152); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2); - orl(edx, ecx); - cmpl(edx, 0); - jcc(Assembler::equal, L_2TAG_PACKET_7_0_2); - - bind(L_2TAG_PACKET_6_0_2); - xorpd(xmm1, xmm1); - xorpd(xmm0, xmm0); - movl(eax, 32752); - pinsrw(xmm1, eax, 3); - mulsd(xmm0, xmm1); - movl(Address(rsp, 16), 3); - jmp(L_2TAG_PACKET_8_0_2); - bind(L_2TAG_PACKET_7_0_2); - xorpd(xmm1, xmm1); - xorpd(xmm0, xmm0); - movl(eax, 49136); - pinsrw(xmm0, eax, 3); - divsd(xmm0, xmm1); - movl(Address(rsp, 16), 2); - - bind(L_2TAG_PACKET_8_0_2); - movq(Address(rsp, 8), xmm0); - - bind(B1_3); - movq(xmm0, Address(rsp, 8)); - - bind(B1_5); - addq(rsp, 24); -} - -/******************************************************************************/ -// ALGORITHM DESCRIPTION - POW() -// --------------------- -// -// Let x=2^k * mx, mx in [1,2) -// -// log2(x) calculation: -// -// Get B~1/mx based on the output of rcpps instruction (B0) -// B = int((B0*LH*2^9+0.5))/2^9 -// LH is a short approximation for log2(e) -// -// Reduced argument, scaled by LH: -// r=B*mx-LH (computed accurately in high and low parts) -// -// log2(x) result: k - log2(B) + p(r) -// p(r) is a degree 8 polynomial -// -log2(B) read from data table (high, low parts) -// log2(x) is formed from high and low parts -// For |x| in [1-1/32, 1+1/16), a slower but more accurate computation -// based om the same table design is performed. -// -// Main path is taken if | floor(log2(|log2(|x|)|) + floor(log2|y|) | < 8, -// to filter out all potential OF/UF cases. -// exp2(y*log2(x)) is computed using an 8-bit index table and a degree 5 -// polynomial -// -// Special cases: -// pow(-0,y) = -INF and raises the divide-by-zero exception for y an odd -// integer < 0. -// pow(-0,y) = +INF and raises the divide-by-zero exception for y < 0 and -// not an odd integer. -// pow(-0,y) = -0 for y an odd integer > 0. -// pow(-0,y) = +0 for y > 0 and not an odd integer. -// pow(-1,-INF) = NaN. -// pow(+1,y) = NaN for any y, even a NaN. -// pow(x,-0) = 1 for any x, even a NaN. -// pow(x,y) = a NaN and raises the invalid exception for finite x < 0 and -// finite non-integer y. -// pow(x,-INF) = +INF for |x|<1. -// pow(x,-INF) = +0 for |x|>1. -// pow(x,+INF) = +0 for |x|<1. -// pow(x,+INF) = +INF for |x|>1. -// pow(-INF,y) = -0 for y an odd integer < 0. -// pow(-INF,y) = +0 for y < 0 and not an odd integer. -// pow(-INF,y) = -INF for y an odd integer > 0. -// pow(-INF,y) = +INF for y > 0 and not an odd integer. -// pow(+INF,y) = +0 for y <0. -// pow(+INF,y) = +INF for y >0. -// -/******************************************************************************/ - -ALIGNED_(16) juint _HIGHSIGMASK[] = -{ - 0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL -}; - -ALIGNED_(16) juint _LOG2_E[] = -{ - 0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL -}; - -ALIGNED_(16) juint _HIGHMASK_Y[] = -{ - 0x00000000UL, 0xfffffff8UL, 0x00000000UL, 0xffffffffUL -}; - -ALIGNED_(16) juint _T_exp[] = -{ - 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3b700000UL, 0xfa5abcbfUL, - 0x3ff00b1aUL, 0xa7609f71UL, 0xbc84f6b2UL, 0xa9fb3335UL, 0x3ff0163dUL, - 0x9ab8cdb7UL, 0x3c9b6129UL, 0x143b0281UL, 0x3ff02168UL, 0x0fc54eb6UL, - 0xbc82bf31UL, 0x3e778061UL, 0x3ff02c9aUL, 0x535b085dUL, 0xbc719083UL, - 0x2e11bbccUL, 0x3ff037d4UL, 0xeeade11aUL, 0x3c656811UL, 0xe86e7f85UL, - 0x3ff04315UL, 0x1977c96eUL, 0xbc90a31cUL, 0x72f654b1UL, 0x3ff04e5fUL, - 0x3aa0d08cUL, 0x3c84c379UL, 0xd3158574UL, 0x3ff059b0UL, 0xa475b465UL, - 0x3c8d73e2UL, 0x0e3c1f89UL, 0x3ff0650aUL, 0x5799c397UL, 0xbc95cb7bUL, - 0x29ddf6deUL, 0x3ff0706bUL, 0xe2b13c27UL, 0xbc8c91dfUL, 0x2b72a836UL, - 0x3ff07bd4UL, 0x54458700UL, 0x3c832334UL, 0x18759bc8UL, 0x3ff08745UL, - 0x4bb284ffUL, 0x3c6186beUL, 0xf66607e0UL, 0x3ff092bdUL, 0x800a3fd1UL, - 0xbc968063UL, 0xcac6f383UL, 0x3ff09e3eUL, 0x18316136UL, 0x3c914878UL, - 0x9b1f3919UL, 0x3ff0a9c7UL, 0x873d1d38UL, 0x3c85d16cUL, 0x6cf9890fUL, - 0x3ff0b558UL, 0x4adc610bUL, 0x3c98a62eUL, 0x45e46c85UL, 0x3ff0c0f1UL, - 0x06d21cefUL, 0x3c94f989UL, 0x2b7247f7UL, 0x3ff0cc92UL, 0x16e24f71UL, - 0x3c901edcUL, 0x23395decUL, 0x3ff0d83bUL, 0xe43f316aUL, 0xbc9bc14dUL, - 0x32d3d1a2UL, 0x3ff0e3ecUL, 0x27c57b52UL, 0x3c403a17UL, 0x5fdfa9c5UL, - 0x3ff0efa5UL, 0xbc54021bUL, 0xbc949db9UL, 0xaffed31bUL, 0x3ff0fb66UL, - 0xc44ebd7bUL, 0xbc6b9bedUL, 0x28d7233eUL, 0x3ff10730UL, 0x1692fdd5UL, - 0x3c8d46ebUL, 0xd0125b51UL, 0x3ff11301UL, 0x39449b3aUL, 0xbc96c510UL, - 0xab5e2ab6UL, 0x3ff11edbUL, 0xf703fb72UL, 0xbc9ca454UL, 0xc06c31ccUL, - 0x3ff12abdUL, 0xb36ca5c7UL, 0xbc51b514UL, 0x14f204abUL, 0x3ff136a8UL, - 0xba48dcf0UL, 0xbc67108fUL, 0xaea92de0UL, 0x3ff1429aUL, 0x9af1369eUL, - 0xbc932fbfUL, 0x934f312eUL, 0x3ff14e95UL, 0x39bf44abUL, 0xbc8b91e8UL, - 0xc8a58e51UL, 0x3ff15a98UL, 0xb9eeab0aUL, 0x3c82406aUL, 0x5471c3c2UL, - 0x3ff166a4UL, 0x82ea1a32UL, 0x3c58f23bUL, 0x3c7d517bUL, 0x3ff172b8UL, - 0xb9d78a76UL, 0xbc819041UL, 0x8695bbc0UL, 0x3ff17ed4UL, 0xe2ac5a64UL, - 0x3c709e3fUL, 0x388c8deaUL, 0x3ff18af9UL, 0xd1970f6cUL, 0xbc911023UL, - 0x58375d2fUL, 0x3ff19726UL, 0x85f17e08UL, 0x3c94aaddUL, 0xeb6fcb75UL, - 0x3ff1a35bUL, 0x7b4968e4UL, 0x3c8e5b4cUL, 0xf8138a1cUL, 0x3ff1af99UL, - 0xa4b69280UL, 0x3c97bf85UL, 0x84045cd4UL, 0x3ff1bbe0UL, 0x352ef607UL, - 0xbc995386UL, 0x95281c6bUL, 0x3ff1c82fUL, 0x8010f8c9UL, 0x3c900977UL, - 0x3168b9aaUL, 0x3ff1d487UL, 0x00a2643cUL, 0x3c9e016eUL, 0x5eb44027UL, - 0x3ff1e0e7UL, 0x088cb6deUL, 0xbc96fdd8UL, 0x22fcd91dUL, 0x3ff1ed50UL, - 0x027bb78cUL, 0xbc91df98UL, 0x8438ce4dUL, 0x3ff1f9c1UL, 0xa097af5cUL, - 0xbc9bf524UL, 0x88628cd6UL, 0x3ff2063bUL, 0x814a8495UL, 0x3c8dc775UL, - 0x3578a819UL, 0x3ff212beUL, 0x2cfcaac9UL, 0x3c93592dUL, 0x917ddc96UL, - 0x3ff21f49UL, 0x9494a5eeUL, 0x3c82a97eUL, 0xa27912d1UL, 0x3ff22bddUL, - 0x5577d69fUL, 0x3c8d34fbUL, 0x6e756238UL, 0x3ff2387aUL, 0xb6c70573UL, - 0x3c99b07eUL, 0xfb82140aUL, 0x3ff2451fUL, 0x911ca996UL, 0x3c8acfccUL, - 0x4fb2a63fUL, 0x3ff251ceUL, 0xbef4f4a4UL, 0x3c8ac155UL, 0x711ece75UL, - 0x3ff25e85UL, 0x4ac31b2cUL, 0x3c93e1a2UL, 0x65e27cddUL, 0x3ff26b45UL, - 0x9940e9d9UL, 0x3c82bd33UL, 0x341ddf29UL, 0x3ff2780eUL, 0x05f9e76cUL, - 0x3c9e067cUL, 0xe1f56381UL, 0x3ff284dfUL, 0x8c3f0d7eUL, 0xbc9a4c3aUL, - 0x7591bb70UL, 0x3ff291baUL, 0x28401cbdUL, 0xbc82cc72UL, 0xf51fdee1UL, - 0x3ff29e9dUL, 0xafad1255UL, 0x3c8612e8UL, 0x66d10f13UL, 0x3ff2ab8aUL, - 0x191690a7UL, 0xbc995743UL, 0xd0dad990UL, 0x3ff2b87fUL, 0xd6381aa4UL, - 0xbc410adcUL, 0x39771b2fUL, 0x3ff2c57eUL, 0xa6eb5124UL, 0xbc950145UL, - 0xa6e4030bUL, 0x3ff2d285UL, 0x54db41d5UL, 0x3c900247UL, 0x1f641589UL, - 0x3ff2df96UL, 0xfbbce198UL, 0x3c9d16cfUL, 0xa93e2f56UL, 0x3ff2ecafUL, - 0x45d52383UL, 0x3c71ca0fUL, 0x4abd886bUL, 0x3ff2f9d2UL, 0x532bda93UL, - 0xbc653c55UL, 0x0a31b715UL, 0x3ff306feUL, 0xd23182e4UL, 0x3c86f46aUL, - 0xedeeb2fdUL, 0x3ff31432UL, 0xf3f3fcd1UL, 0x3c8959a3UL, 0xfc4cd831UL, - 0x3ff32170UL, 0x8e18047cUL, 0x3c8a9ce7UL, 0x3ba8ea32UL, 0x3ff32eb8UL, - 0x3cb4f318UL, 0xbc9c45e8UL, 0xb26416ffUL, 0x3ff33c08UL, 0x843659a6UL, - 0x3c932721UL, 0x66e3fa2dUL, 0x3ff34962UL, 0x930881a4UL, 0xbc835a75UL, - 0x5f929ff1UL, 0x3ff356c5UL, 0x5c4e4628UL, 0xbc8b5ceeUL, 0xa2de883bUL, - 0x3ff36431UL, 0xa06cb85eUL, 0xbc8c3144UL, 0x373aa9cbUL, 0x3ff371a7UL, - 0xbf42eae2UL, 0xbc963aeaUL, 0x231e754aUL, 0x3ff37f26UL, 0x9eceb23cUL, - 0xbc99f5caUL, 0x6d05d866UL, 0x3ff38caeUL, 0x3c9904bdUL, 0xbc9e958dUL, - 0x1b7140efUL, 0x3ff39a40UL, 0xfc8e2934UL, 0xbc99a9a5UL, 0x34e59ff7UL, - 0x3ff3a7dbUL, 0xd661f5e3UL, 0xbc75e436UL, 0xbfec6cf4UL, 0x3ff3b57fUL, - 0xe26fff18UL, 0x3c954c66UL, 0xc313a8e5UL, 0x3ff3c32dUL, 0x375d29c3UL, - 0xbc9efff8UL, 0x44ede173UL, 0x3ff3d0e5UL, 0x8c284c71UL, 0x3c7fe8d0UL, - 0x4c123422UL, 0x3ff3dea6UL, 0x11f09ebcUL, 0x3c8ada09UL, 0xdf1c5175UL, - 0x3ff3ec70UL, 0x7b8c9bcaUL, 0xbc8af663UL, 0x04ac801cUL, 0x3ff3fa45UL, - 0xf956f9f3UL, 0xbc97d023UL, 0xc367a024UL, 0x3ff40822UL, 0xb6f4d048UL, - 0x3c8bddf8UL, 0x21f72e2aUL, 0x3ff4160aUL, 0x1c309278UL, 0xbc5ef369UL, - 0x2709468aUL, 0x3ff423fbUL, 0xc0b314ddUL, 0xbc98462dUL, 0xd950a897UL, - 0x3ff431f5UL, 0xe35f7999UL, 0xbc81c7ddUL, 0x3f84b9d4UL, 0x3ff43ffaUL, - 0x9704c003UL, 0x3c8880beUL, 0x6061892dUL, 0x3ff44e08UL, 0x04ef80d0UL, - 0x3c489b7aUL, 0x42a7d232UL, 0x3ff45c20UL, 0x82fb1f8eUL, 0xbc686419UL, - 0xed1d0057UL, 0x3ff46a41UL, 0xd1648a76UL, 0x3c9c944bUL, 0x668b3237UL, - 0x3ff4786dUL, 0xed445733UL, 0xbc9c20f0UL, 0xb5c13cd0UL, 0x3ff486a2UL, - 0xb69062f0UL, 0x3c73c1a3UL, 0xe192aed2UL, 0x3ff494e1UL, 0x5e499ea0UL, - 0xbc83b289UL, 0xf0d7d3deUL, 0x3ff4a32aUL, 0xf3d1be56UL, 0x3c99cb62UL, - 0xea6db7d7UL, 0x3ff4b17dUL, 0x7f2897f0UL, 0xbc8125b8UL, 0xd5362a27UL, - 0x3ff4bfdaUL, 0xafec42e2UL, 0x3c7d4397UL, 0xb817c114UL, 0x3ff4ce41UL, - 0x690abd5dUL, 0x3c905e29UL, 0x99fddd0dUL, 0x3ff4dcb2UL, 0xbc6a7833UL, - 0x3c98ecdbUL, 0x81d8abffUL, 0x3ff4eb2dUL, 0x2e5d7a52UL, 0xbc95257dUL, - 0x769d2ca7UL, 0x3ff4f9b2UL, 0xd25957e3UL, 0xbc94b309UL, 0x7f4531eeUL, - 0x3ff50841UL, 0x49b7465fUL, 0x3c7a249bUL, 0xa2cf6642UL, 0x3ff516daUL, - 0x69bd93efUL, 0xbc8f7685UL, 0xe83f4eefUL, 0x3ff5257dUL, 0x43efef71UL, - 0xbc7c998dUL, 0x569d4f82UL, 0x3ff5342bUL, 0x1db13cadUL, 0xbc807abeUL, - 0xf4f6ad27UL, 0x3ff542e2UL, 0x192d5f7eUL, 0x3c87926dUL, 0xca5d920fUL, - 0x3ff551a4UL, 0xefede59bUL, 0xbc8d689cUL, 0xdde910d2UL, 0x3ff56070UL, - 0x168eebf0UL, 0xbc90fb6eUL, 0x36b527daUL, 0x3ff56f47UL, 0x011d93adUL, - 0x3c99bb2cUL, 0xdbe2c4cfUL, 0x3ff57e27UL, 0x8a57b9c4UL, 0xbc90b98cUL, - 0xd497c7fdUL, 0x3ff58d12UL, 0x5b9a1de8UL, 0x3c8295e1UL, 0x27ff07ccUL, - 0x3ff59c08UL, 0xe467e60fUL, 0xbc97e2ceUL, 0xdd485429UL, 0x3ff5ab07UL, - 0x054647adUL, 0x3c96324cUL, 0xfba87a03UL, 0x3ff5ba11UL, 0x4c233e1aUL, - 0xbc9b77a1UL, 0x8a5946b7UL, 0x3ff5c926UL, 0x816986a2UL, 0x3c3c4b1bUL, - 0x90998b93UL, 0x3ff5d845UL, 0xa8b45643UL, 0xbc9cd6a7UL, 0x15ad2148UL, - 0x3ff5e76fUL, 0x3080e65eUL, 0x3c9ba6f9UL, 0x20dceb71UL, 0x3ff5f6a3UL, - 0xe3cdcf92UL, 0xbc89eaddUL, 0xb976dc09UL, 0x3ff605e1UL, 0x9b56de47UL, - 0xbc93e242UL, 0xe6cdf6f4UL, 0x3ff6152aUL, 0x4ab84c27UL, 0x3c9e4b3eUL, - 0xb03a5585UL, 0x3ff6247eUL, 0x7e40b497UL, 0xbc9383c1UL, 0x1d1929fdUL, - 0x3ff633ddUL, 0xbeb964e5UL, 0x3c984710UL, 0x34ccc320UL, 0x3ff64346UL, - 0x759d8933UL, 0xbc8c483cUL, 0xfebc8fb7UL, 0x3ff652b9UL, 0xc9a73e09UL, - 0xbc9ae3d5UL, 0x82552225UL, 0x3ff66238UL, 0x87591c34UL, 0xbc9bb609UL, - 0xc70833f6UL, 0x3ff671c1UL, 0x586c6134UL, 0xbc8e8732UL, 0xd44ca973UL, - 0x3ff68155UL, 0x44f73e65UL, 0x3c6038aeUL, 0xb19e9538UL, 0x3ff690f4UL, - 0x9aeb445dUL, 0x3c8804bdUL, 0x667f3bcdUL, 0x3ff6a09eUL, 0x13b26456UL, - 0xbc9bdd34UL, 0xfa75173eUL, 0x3ff6b052UL, 0x2c9a9d0eUL, 0x3c7a38f5UL, - 0x750bdabfUL, 0x3ff6c012UL, 0x67ff0b0dUL, 0xbc728956UL, 0xddd47645UL, - 0x3ff6cfdcUL, 0xb6f17309UL, 0x3c9c7aa9UL, 0x3c651a2fUL, 0x3ff6dfb2UL, - 0x683c88abUL, 0xbc6bbe3aUL, 0x98593ae5UL, 0x3ff6ef92UL, 0x9e1ac8b2UL, - 0xbc90b974UL, 0xf9519484UL, 0x3ff6ff7dUL, 0x25860ef6UL, 0xbc883c0fUL, - 0x66f42e87UL, 0x3ff70f74UL, 0xd45aa65fUL, 0x3c59d644UL, 0xe8ec5f74UL, - 0x3ff71f75UL, 0x86887a99UL, 0xbc816e47UL, 0x86ead08aUL, 0x3ff72f82UL, - 0x2cd62c72UL, 0xbc920aa0UL, 0x48a58174UL, 0x3ff73f9aUL, 0x6c65d53cUL, - 0xbc90a8d9UL, 0x35d7cbfdUL, 0x3ff74fbdUL, 0x618a6e1cUL, 0x3c9047fdUL, - 0x564267c9UL, 0x3ff75febUL, 0x57316dd3UL, 0xbc902459UL, 0xb1ab6e09UL, - 0x3ff77024UL, 0x169147f8UL, 0x3c9b7877UL, 0x4fde5d3fUL, 0x3ff78069UL, - 0x0a02162dUL, 0x3c9866b8UL, 0x38ac1cf6UL, 0x3ff790b9UL, 0x62aadd3eUL, - 0x3c9349a8UL, 0x73eb0187UL, 0x3ff7a114UL, 0xee04992fUL, 0xbc841577UL, - 0x0976cfdbUL, 0x3ff7b17bUL, 0x8468dc88UL, 0xbc9bebb5UL, 0x0130c132UL, - 0x3ff7c1edUL, 0xd1164dd6UL, 0x3c9f124cUL, 0x62ff86f0UL, 0x3ff7d26aUL, - 0xfb72b8b4UL, 0x3c91bddbUL, 0x36cf4e62UL, 0x3ff7e2f3UL, 0xba15797eUL, - 0x3c705d02UL, 0x8491c491UL, 0x3ff7f387UL, 0xcf9311aeUL, 0xbc807f11UL, - 0x543e1a12UL, 0x3ff80427UL, 0x626d972bUL, 0xbc927c86UL, 0xadd106d9UL, - 0x3ff814d2UL, 0x0d151d4dUL, 0x3c946437UL, 0x994cce13UL, 0x3ff82589UL, - 0xd41532d8UL, 0xbc9d4c1dUL, 0x1eb941f7UL, 0x3ff8364cUL, 0x31df2bd5UL, - 0x3c999b9aUL, 0x4623c7adUL, 0x3ff8471aUL, 0xa341cdfbUL, 0xbc88d684UL, - 0x179f5b21UL, 0x3ff857f4UL, 0xf8b216d0UL, 0xbc5ba748UL, 0x9b4492edUL, - 0x3ff868d9UL, 0x9bd4f6baUL, 0xbc9fc6f8UL, 0xd931a436UL, 0x3ff879caUL, - 0xd2db47bdUL, 0x3c85d2d7UL, 0xd98a6699UL, 0x3ff88ac7UL, 0xf37cb53aUL, - 0x3c9994c2UL, 0xa478580fUL, 0x3ff89bd0UL, 0x4475202aUL, 0x3c9d5395UL, - 0x422aa0dbUL, 0x3ff8ace5UL, 0x56864b27UL, 0x3c96e9f1UL, 0xbad61778UL, - 0x3ff8be05UL, 0xfc43446eUL, 0x3c9ecb5eUL, 0x16b5448cUL, 0x3ff8cf32UL, - 0x32e9e3aaUL, 0xbc70d55eUL, 0x5e0866d9UL, 0x3ff8e06aUL, 0x6fc9b2e6UL, - 0xbc97114aUL, 0x99157736UL, 0x3ff8f1aeUL, 0xa2e3976cUL, 0x3c85cc13UL, - 0xd0282c8aUL, 0x3ff902feUL, 0x85fe3fd2UL, 0x3c9592caUL, 0x0b91ffc6UL, - 0x3ff9145bUL, 0x2e582524UL, 0xbc9dd679UL, 0x53aa2fe2UL, 0x3ff925c3UL, - 0xa639db7fUL, 0xbc83455fUL, 0xb0cdc5e5UL, 0x3ff93737UL, 0x81b57ebcUL, - 0xbc675fc7UL, 0x2b5f98e5UL, 0x3ff948b8UL, 0x797d2d99UL, 0xbc8dc3d6UL, - 0xcbc8520fUL, 0x3ff95a44UL, 0x96a5f039UL, 0xbc764b7cUL, 0x9a7670b3UL, - 0x3ff96bddUL, 0x7f19c896UL, 0xbc5ba596UL, 0x9fde4e50UL, 0x3ff97d82UL, - 0x7c1b85d1UL, 0xbc9d185bUL, 0xe47a22a2UL, 0x3ff98f33UL, 0xa24c78ecUL, - 0x3c7cabdaUL, 0x70ca07baUL, 0x3ff9a0f1UL, 0x91cee632UL, 0xbc9173bdUL, - 0x4d53fe0dUL, 0x3ff9b2bbUL, 0x4df6d518UL, 0xbc9dd84eUL, 0x82a3f090UL, - 0x3ff9c491UL, 0xb071f2beUL, 0x3c7c7c46UL, 0x194bb8d5UL, 0x3ff9d674UL, - 0xa3dd8233UL, 0xbc9516beUL, 0x19e32323UL, 0x3ff9e863UL, 0x78e64c6eUL, - 0x3c7824caUL, 0x8d07f29eUL, 0x3ff9fa5eUL, 0xaaf1faceUL, 0xbc84a9ceUL, - 0x7b5de565UL, 0x3ffa0c66UL, 0x5d1cd533UL, 0xbc935949UL, 0xed8eb8bbUL, - 0x3ffa1e7aUL, 0xee8be70eUL, 0x3c9c6618UL, 0xec4a2d33UL, 0x3ffa309bUL, - 0x7ddc36abUL, 0x3c96305cUL, 0x80460ad8UL, 0x3ffa42c9UL, 0x589fb120UL, - 0xbc9aa780UL, 0xb23e255dUL, 0x3ffa5503UL, 0xdb8d41e1UL, 0xbc9d2f6eUL, - 0x8af46052UL, 0x3ffa674aUL, 0x30670366UL, 0x3c650f56UL, 0x1330b358UL, - 0x3ffa799eUL, 0xcac563c7UL, 0x3c9bcb7eUL, 0x53c12e59UL, 0x3ffa8bfeUL, - 0xb2ba15a9UL, 0xbc94f867UL, 0x5579fdbfUL, 0x3ffa9e6bUL, 0x0ef7fd31UL, - 0x3c90fac9UL, 0x21356ebaUL, 0x3ffab0e5UL, 0xdae94545UL, 0x3c889c31UL, - 0xbfd3f37aUL, 0x3ffac36bUL, 0xcae76cd0UL, 0xbc8f9234UL, 0x3a3c2774UL, - 0x3ffad5ffUL, 0xb6b1b8e5UL, 0x3c97ef3bUL, 0x995ad3adUL, 0x3ffae89fUL, - 0x345dcc81UL, 0x3c97a1cdUL, 0xe622f2ffUL, 0x3ffafb4cUL, 0x0f315ecdUL, - 0xbc94b2fcUL, 0x298db666UL, 0x3ffb0e07UL, 0x4c80e425UL, 0xbc9bdef5UL, - 0x6c9a8952UL, 0x3ffb20ceUL, 0x4a0756ccUL, 0x3c94dd02UL, 0xb84f15fbUL, - 0x3ffb33a2UL, 0x3084d708UL, 0xbc62805eUL, 0x15b749b1UL, 0x3ffb4684UL, - 0xe9df7c90UL, 0xbc7f763dUL, 0x8de5593aUL, 0x3ffb5972UL, 0xbbba6de3UL, - 0xbc9c71dfUL, 0x29f1c52aUL, 0x3ffb6c6eUL, 0x52883f6eUL, 0x3c92a8f3UL, - 0xf2fb5e47UL, 0x3ffb7f76UL, 0x7e54ac3bUL, 0xbc75584fUL, 0xf22749e4UL, - 0x3ffb928cUL, 0x54cb65c6UL, 0xbc9b7216UL, 0x30a1064aUL, 0x3ffba5b0UL, - 0x0e54292eUL, 0xbc9efcd3UL, 0xb79a6f1fUL, 0x3ffbb8e0UL, 0xc9696205UL, - 0xbc3f52d1UL, 0x904bc1d2UL, 0x3ffbcc1eUL, 0x7a2d9e84UL, 0x3c823dd0UL, - 0xc3f3a207UL, 0x3ffbdf69UL, 0x60ea5b53UL, 0xbc3c2623UL, 0x5bd71e09UL, - 0x3ffbf2c2UL, 0x3f6b9c73UL, 0xbc9efdcaUL, 0x6141b33dUL, 0x3ffc0628UL, - 0xa1fbca34UL, 0xbc8d8a5aUL, 0xdd85529cUL, 0x3ffc199bUL, 0x895048ddUL, - 0x3c811065UL, 0xd9fa652cUL, 0x3ffc2d1cUL, 0x17c8a5d7UL, 0xbc96e516UL, - 0x5fffd07aUL, 0x3ffc40abUL, 0xe083c60aUL, 0x3c9b4537UL, 0x78fafb22UL, - 0x3ffc5447UL, 0x2493b5afUL, 0x3c912f07UL, 0x2e57d14bUL, 0x3ffc67f1UL, - 0xff483cadUL, 0x3c92884dUL, 0x8988c933UL, 0x3ffc7ba8UL, 0xbe255559UL, - 0xbc8e76bbUL, 0x9406e7b5UL, 0x3ffc8f6dUL, 0x48805c44UL, 0x3c71acbcUL, - 0x5751c4dbUL, 0x3ffca340UL, 0xd10d08f5UL, 0xbc87f2beUL, 0xdcef9069UL, - 0x3ffcb720UL, 0xd1e949dbUL, 0x3c7503cbUL, 0x2e6d1675UL, 0x3ffccb0fUL, - 0x86009092UL, 0xbc7d220fUL, 0x555dc3faUL, 0x3ffcdf0bUL, 0x53829d72UL, - 0xbc8dd83bUL, 0x5b5bab74UL, 0x3ffcf315UL, 0xb86dff57UL, 0xbc9a08e9UL, - 0x4a07897cUL, 0x3ffd072dUL, 0x43797a9cUL, 0xbc9cbc37UL, 0x2b08c968UL, - 0x3ffd1b53UL, 0x219a36eeUL, 0x3c955636UL, 0x080d89f2UL, 0x3ffd2f87UL, - 0x719d8578UL, 0xbc9d487bUL, 0xeacaa1d6UL, 0x3ffd43c8UL, 0xbf5a1614UL, - 0x3c93db53UL, 0xdcfba487UL, 0x3ffd5818UL, 0xd75b3707UL, 0x3c82ed02UL, - 0xe862e6d3UL, 0x3ffd6c76UL, 0x4a8165a0UL, 0x3c5fe87aUL, 0x16c98398UL, - 0x3ffd80e3UL, 0x8beddfe8UL, 0xbc911ec1UL, 0x71ff6075UL, 0x3ffd955dUL, - 0xbb9af6beUL, 0x3c9a052dUL, 0x03db3285UL, 0x3ffda9e6UL, 0x696db532UL, - 0x3c9c2300UL, 0xd63a8315UL, 0x3ffdbe7cUL, 0x926b8be4UL, 0xbc9b76f1UL, - 0xf301b460UL, 0x3ffdd321UL, 0x78f018c3UL, 0x3c92da57UL, 0x641c0658UL, - 0x3ffde7d5UL, 0x8e79ba8fUL, 0xbc9ca552UL, 0x337b9b5fUL, 0x3ffdfc97UL, - 0x4f184b5cUL, 0xbc91a5cdUL, 0x6b197d17UL, 0x3ffe1167UL, 0xbd5c7f44UL, - 0xbc72b529UL, 0x14f5a129UL, 0x3ffe2646UL, 0x817a1496UL, 0xbc97b627UL, - 0x3b16ee12UL, 0x3ffe3b33UL, 0x31fdc68bUL, 0xbc99f4a4UL, 0xe78b3ff6UL, - 0x3ffe502eUL, 0x80a9cc8fUL, 0x3c839e89UL, 0x24676d76UL, 0x3ffe6539UL, - 0x7522b735UL, 0xbc863ff8UL, 0xfbc74c83UL, 0x3ffe7a51UL, 0xca0c8de2UL, - 0x3c92d522UL, 0x77cdb740UL, 0x3ffe8f79UL, 0x80b054b1UL, 0xbc910894UL, - 0xa2a490daUL, 0x3ffea4afUL, 0x179c2893UL, 0xbc9e9c23UL, 0x867cca6eUL, - 0x3ffeb9f4UL, 0x2293e4f2UL, 0x3c94832fUL, 0x2d8e67f1UL, 0x3ffecf48UL, - 0xb411ad8cUL, 0xbc9c93f3UL, 0xa2188510UL, 0x3ffee4aaUL, 0xa487568dUL, - 0x3c91c68dUL, 0xee615a27UL, 0x3ffefa1bUL, 0x86a4b6b0UL, 0x3c9dc7f4UL, - 0x1cb6412aUL, 0x3fff0f9cUL, 0x65181d45UL, 0xbc932200UL, 0x376bba97UL, - 0x3fff252bUL, 0xbf0d8e43UL, 0x3c93a1a5UL, 0x48dd7274UL, 0x3fff3ac9UL, - 0x3ed837deUL, 0xbc795a5aUL, 0x5b6e4540UL, 0x3fff5076UL, 0x2dd8a18bUL, - 0x3c99d3e1UL, 0x798844f8UL, 0x3fff6632UL, 0x3539343eUL, 0x3c9fa37bUL, - 0xad9cbe14UL, 0x3fff7bfdUL, 0xd006350aUL, 0xbc9dbb12UL, 0x02243c89UL, - 0x3fff91d8UL, 0xa779f689UL, 0xbc612ea8UL, 0x819e90d8UL, 0x3fffa7c1UL, - 0xf3a5931eUL, 0x3c874853UL, 0x3692d514UL, 0x3fffbdbaUL, 0x15098eb6UL, - 0xbc796773UL, 0x2b8f71f1UL, 0x3fffd3c2UL, 0x966579e7UL, 0x3c62eb74UL, - 0x6b2a23d9UL, 0x3fffe9d9UL, 0x7442fde3UL, 0x3c74a603UL -}; - -ALIGNED_(16) juint _e_coeff[] = -{ - 0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL, 0x6fba4e77UL, - 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL, 0xfefa39efUL, 0x3fe62e42UL, - 0x00000000UL, 0x00000000UL -}; - -ALIGNED_(16) juint _coeff_h[] = -{ - 0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL -}; - -ALIGNED_(16) juint _HIGHMASK_LOG_X[] = -{ - 0xf8000000UL, 0xffffffffUL, 0x00000000UL, 0xfffff800UL -}; - -ALIGNED_(8) juint _HALFMASK[] = -{ - 0xf8000000UL, 0xffffffffUL, 0xf8000000UL, 0xffffffffUL -}; - -ALIGNED_(16) juint _coeff_pow[] = -{ - 0x6dc96112UL, 0xbf836578UL, 0xee241472UL, 0xbf9b0301UL, 0x9f95985aUL, - 0xbfb528dbUL, 0xb3841d2aUL, 0xbfd619b6UL, 0x518775e3UL, 0x3f9004f2UL, - 0xac8349bbUL, 0x3fa76c9bUL, 0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, - 0xbf5dabe1UL, 0x9f95985aUL, 0xbfb528dbUL, 0xf8b5787dUL, 0x3ef2531eUL, - 0x486ececbUL, 0x3fc4635eUL, 0x412055ccUL, 0xbdd61bb2UL -}; - -ALIGNED_(16) juint _L_tbl_pow[] = -{ - 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x20000000UL, - 0x3feff00aUL, 0x96621f95UL, 0x3e5b1856UL, 0xe0000000UL, 0x3fefe019UL, - 0xe5916f9eUL, 0xbe325278UL, 0x00000000UL, 0x3fefd02fUL, 0x859a1062UL, - 0x3e595fb7UL, 0xc0000000UL, 0x3fefc049UL, 0xb245f18fUL, 0xbe529c38UL, - 0xe0000000UL, 0x3fefb069UL, 0xad2880a7UL, 0xbe501230UL, 0x60000000UL, - 0x3fefa08fUL, 0xc8e72420UL, 0x3e597bd1UL, 0x80000000UL, 0x3fef90baUL, - 0xc30c4500UL, 0xbe5d6c75UL, 0xe0000000UL, 0x3fef80eaUL, 0x02c63f43UL, - 0x3e2e1318UL, 0xc0000000UL, 0x3fef7120UL, 0xb3d4ccccUL, 0xbe44c52aUL, - 0x00000000UL, 0x3fef615cUL, 0xdbd91397UL, 0xbe4e7d6cUL, 0xa0000000UL, - 0x3fef519cUL, 0x65c5cd68UL, 0xbe522dc8UL, 0xa0000000UL, 0x3fef41e2UL, - 0x46d1306cUL, 0xbe5a840eUL, 0xe0000000UL, 0x3fef322dUL, 0xd2980e94UL, - 0x3e5071afUL, 0xa0000000UL, 0x3fef227eUL, 0x773abadeUL, 0xbe5891e5UL, - 0xa0000000UL, 0x3fef12d4UL, 0xdc6bf46bUL, 0xbe5cccbeUL, 0xe0000000UL, - 0x3fef032fUL, 0xbc7247faUL, 0xbe2bab83UL, 0x80000000UL, 0x3feef390UL, - 0xbcaa1e46UL, 0xbe53bb3bUL, 0x60000000UL, 0x3feee3f6UL, 0x5f6c682dUL, - 0xbe54c619UL, 0x80000000UL, 0x3feed461UL, 0x5141e368UL, 0xbe4b6d86UL, - 0xe0000000UL, 0x3feec4d1UL, 0xec678f76UL, 0xbe369af6UL, 0x80000000UL, - 0x3feeb547UL, 0x41301f55UL, 0xbe2d4312UL, 0x60000000UL, 0x3feea5c2UL, - 0x676da6bdUL, 0xbe4d8dd0UL, 0x60000000UL, 0x3fee9642UL, 0x57a891c4UL, - 0x3e51f991UL, 0xa0000000UL, 0x3fee86c7UL, 0xe4eb491eUL, 0x3e579bf9UL, - 0x20000000UL, 0x3fee7752UL, 0xfddc4a2cUL, 0xbe3356e6UL, 0xc0000000UL, - 0x3fee67e1UL, 0xd75b5bf1UL, 0xbe449531UL, 0x80000000UL, 0x3fee5876UL, - 0xbd423b8eUL, 0x3df54fe4UL, 0x60000000UL, 0x3fee4910UL, 0x330e51b9UL, - 0x3e54289cUL, 0x80000000UL, 0x3fee39afUL, 0x8651a95fUL, 0xbe55aad6UL, - 0xa0000000UL, 0x3fee2a53UL, 0x5e98c708UL, 0xbe2fc4a9UL, 0xe0000000UL, - 0x3fee1afcUL, 0x0989328dUL, 0x3e23958cUL, 0x40000000UL, 0x3fee0babUL, - 0xee642abdUL, 0xbe425dd8UL, 0xa0000000UL, 0x3fedfc5eUL, 0xc394d236UL, - 0x3e526362UL, 0x20000000UL, 0x3feded17UL, 0xe104aa8eUL, 0x3e4ce247UL, - 0xc0000000UL, 0x3fedddd4UL, 0x265a9be4UL, 0xbe5bb77aUL, 0x40000000UL, - 0x3fedce97UL, 0x0ecac52fUL, 0x3e4a7cb1UL, 0xe0000000UL, 0x3fedbf5eUL, - 0x124cb3b8UL, 0x3e257024UL, 0x80000000UL, 0x3fedb02bUL, 0xe6d4febeUL, - 0xbe2033eeUL, 0x20000000UL, 0x3feda0fdUL, 0x39cca00eUL, 0xbe3ddabcUL, - 0xc0000000UL, 0x3fed91d3UL, 0xef8a552aUL, 0xbe543390UL, 0x40000000UL, - 0x3fed82afUL, 0xb8e85204UL, 0x3e513850UL, 0xe0000000UL, 0x3fed738fUL, - 0x3d59fe08UL, 0xbe5db728UL, 0x40000000UL, 0x3fed6475UL, 0x3aa7ead1UL, - 0x3e58804bUL, 0xc0000000UL, 0x3fed555fUL, 0xf8a35ba9UL, 0xbe5298b0UL, - 0x00000000UL, 0x3fed464fUL, 0x9a88dd15UL, 0x3e5a8cdbUL, 0x40000000UL, - 0x3fed3743UL, 0xb0b0a190UL, 0x3e598635UL, 0x80000000UL, 0x3fed283cUL, - 0xe2113295UL, 0xbe5c1119UL, 0x80000000UL, 0x3fed193aUL, 0xafbf1728UL, - 0xbe492e9cUL, 0x60000000UL, 0x3fed0a3dUL, 0xe4a4ccf3UL, 0x3e19b90eUL, - 0x20000000UL, 0x3fecfb45UL, 0xba3cbeb8UL, 0x3e406b50UL, 0xc0000000UL, - 0x3fecec51UL, 0x110f7dddUL, 0x3e0d6806UL, 0x40000000UL, 0x3fecdd63UL, - 0x7dd7d508UL, 0xbe5a8943UL, 0x80000000UL, 0x3fecce79UL, 0x9b60f271UL, - 0xbe50676aUL, 0x80000000UL, 0x3fecbf94UL, 0x0b9ad660UL, 0x3e59174fUL, - 0x60000000UL, 0x3fecb0b4UL, 0x00823d9cUL, 0x3e5bbf72UL, 0x20000000UL, - 0x3feca1d9UL, 0x38a6ec89UL, 0xbe4d38f9UL, 0x80000000UL, 0x3fec9302UL, - 0x3a0b7d8eUL, 0x3e53dbfdUL, 0xc0000000UL, 0x3fec8430UL, 0xc6826b34UL, - 0xbe27c5c9UL, 0xc0000000UL, 0x3fec7563UL, 0x0c706381UL, 0xbe593653UL, - 0x60000000UL, 0x3fec669bUL, 0x7df34ec7UL, 0x3e461ab5UL, 0xe0000000UL, - 0x3fec57d7UL, 0x40e5e7e8UL, 0xbe5c3daeUL, 0x00000000UL, 0x3fec4919UL, - 0x5602770fUL, 0xbe55219dUL, 0xc0000000UL, 0x3fec3a5eUL, 0xec7911ebUL, - 0x3e5a5d25UL, 0x60000000UL, 0x3fec2ba9UL, 0xb39ea225UL, 0xbe53c00bUL, - 0x80000000UL, 0x3fec1cf8UL, 0x967a212eUL, 0x3e5a8ddfUL, 0x60000000UL, - 0x3fec0e4cUL, 0x580798bdUL, 0x3e5f53abUL, 0x00000000UL, 0x3febffa5UL, - 0xb8282df6UL, 0xbe46b874UL, 0x20000000UL, 0x3febf102UL, 0xe33a6729UL, - 0x3e54963fUL, 0x00000000UL, 0x3febe264UL, 0x3b53e88aUL, 0xbe3adce1UL, - 0x60000000UL, 0x3febd3caUL, 0xc2585084UL, 0x3e5cde9fUL, 0x80000000UL, - 0x3febc535UL, 0xa335c5eeUL, 0xbe39fd9cUL, 0x20000000UL, 0x3febb6a5UL, - 0x7325b04dUL, 0x3e42ba15UL, 0x60000000UL, 0x3feba819UL, 0x1564540fUL, - 0x3e3a9f35UL, 0x40000000UL, 0x3feb9992UL, 0x83fff592UL, 0xbe5465ceUL, - 0xa0000000UL, 0x3feb8b0fUL, 0xb9da63d3UL, 0xbe4b1a0aUL, 0x80000000UL, - 0x3feb7c91UL, 0x6d6f1ea4UL, 0x3e557657UL, 0x00000000UL, 0x3feb6e18UL, - 0x5e80a1bfUL, 0x3e4ddbb6UL, 0x00000000UL, 0x3feb5fa3UL, 0x1c9eacb5UL, - 0x3e592877UL, 0xa0000000UL, 0x3feb5132UL, 0x6d40beb3UL, 0xbe51858cUL, - 0xa0000000UL, 0x3feb42c6UL, 0xd740c67bUL, 0x3e427ad2UL, 0x40000000UL, - 0x3feb345fUL, 0xa3e0cceeUL, 0xbe5c2fc4UL, 0x40000000UL, 0x3feb25fcUL, - 0x8e752b50UL, 0xbe3da3c2UL, 0xc0000000UL, 0x3feb179dUL, 0xa892e7deUL, - 0x3e1fb481UL, 0xc0000000UL, 0x3feb0943UL, 0x21ed71e9UL, 0xbe365206UL, - 0x20000000UL, 0x3feafaeeUL, 0x0e1380a3UL, 0x3e5c5b7bUL, 0x20000000UL, - 0x3feaec9dUL, 0x3c3d640eUL, 0xbe5dbbd0UL, 0x60000000UL, 0x3feade50UL, - 0x8f97a715UL, 0x3e3a8ec5UL, 0x20000000UL, 0x3fead008UL, 0x23ab2839UL, - 0x3e2fe98aUL, 0x40000000UL, 0x3feac1c4UL, 0xf4bbd50fUL, 0x3e54d8f6UL, - 0xe0000000UL, 0x3feab384UL, 0x14757c4dUL, 0xbe48774cUL, 0xc0000000UL, - 0x3feaa549UL, 0x7c7b0eeaUL, 0x3e5b51bbUL, 0x20000000UL, 0x3fea9713UL, - 0xf56f7013UL, 0x3e386200UL, 0xe0000000UL, 0x3fea88e0UL, 0xbe428ebeUL, - 0xbe514af5UL, 0xe0000000UL, 0x3fea7ab2UL, 0x8d0e4496UL, 0x3e4f9165UL, - 0x60000000UL, 0x3fea6c89UL, 0xdbacc5d5UL, 0xbe5c063bUL, 0x20000000UL, - 0x3fea5e64UL, 0x3f19d970UL, 0xbe5a0c8cUL, 0x20000000UL, 0x3fea5043UL, - 0x09ea3e6bUL, 0x3e5065dcUL, 0x80000000UL, 0x3fea4226UL, 0x78df246cUL, - 0x3e5e05f6UL, 0x40000000UL, 0x3fea340eUL, 0x4057d4a0UL, 0x3e431b2bUL, - 0x40000000UL, 0x3fea25faUL, 0x82867bb5UL, 0x3e4b76beUL, 0xa0000000UL, - 0x3fea17eaUL, 0x9436f40aUL, 0xbe5aad39UL, 0x20000000UL, 0x3fea09dfUL, - 0x4b5253b3UL, 0x3e46380bUL, 0x00000000UL, 0x3fe9fbd8UL, 0x8fc52466UL, - 0xbe386f9bUL, 0x20000000UL, 0x3fe9edd5UL, 0x22d3f344UL, 0xbe538347UL, - 0x60000000UL, 0x3fe9dfd6UL, 0x1ac33522UL, 0x3e5dbc53UL, 0x00000000UL, - 0x3fe9d1dcUL, 0xeabdff1dUL, 0x3e40fc0cUL, 0xe0000000UL, 0x3fe9c3e5UL, - 0xafd30e73UL, 0xbe585e63UL, 0xe0000000UL, 0x3fe9b5f3UL, 0xa52f226aUL, - 0xbe43e8f9UL, 0x20000000UL, 0x3fe9a806UL, 0xecb8698dUL, 0xbe515b36UL, - 0x80000000UL, 0x3fe99a1cUL, 0xf2b4e89dUL, 0x3e48b62bUL, 0x20000000UL, - 0x3fe98c37UL, 0x7c9a88fbUL, 0x3e44414cUL, 0x00000000UL, 0x3fe97e56UL, - 0xda015741UL, 0xbe5d13baUL, 0xe0000000UL, 0x3fe97078UL, 0x5fdace06UL, - 0x3e51b947UL, 0x00000000UL, 0x3fe962a0UL, 0x956ca094UL, 0x3e518785UL, - 0x40000000UL, 0x3fe954cbUL, 0x01164c1dUL, 0x3e5d5b57UL, 0xc0000000UL, - 0x3fe946faUL, 0xe63b3767UL, 0xbe4f84e7UL, 0x40000000UL, 0x3fe9392eUL, - 0xe57cc2a9UL, 0x3e34eda3UL, 0xe0000000UL, 0x3fe92b65UL, 0x8c75b544UL, - 0x3e5766a0UL, 0xc0000000UL, 0x3fe91da1UL, 0x37d1d087UL, 0xbe5e2ab1UL, - 0x80000000UL, 0x3fe90fe1UL, 0xa953dc20UL, 0x3e5fa1f3UL, 0x80000000UL, - 0x3fe90225UL, 0xdbd3f369UL, 0x3e47d6dbUL, 0xa0000000UL, 0x3fe8f46dUL, - 0x1c9be989UL, 0xbe5e2b0aUL, 0xa0000000UL, 0x3fe8e6b9UL, 0x3c93d76aUL, - 0x3e5c8618UL, 0xe0000000UL, 0x3fe8d909UL, 0x2182fc9aUL, 0xbe41aa9eUL, - 0x20000000UL, 0x3fe8cb5eUL, 0xe6b3539dUL, 0xbe530d19UL, 0x60000000UL, - 0x3fe8bdb6UL, 0x49e58cc3UL, 0xbe3bb374UL, 0xa0000000UL, 0x3fe8b012UL, - 0xa7cfeb8fUL, 0x3e56c412UL, 0x00000000UL, 0x3fe8a273UL, 0x8d52bc19UL, - 0x3e1429b8UL, 0x60000000UL, 0x3fe894d7UL, 0x4dc32c6cUL, 0xbe48604cUL, - 0xc0000000UL, 0x3fe8873fUL, 0x0c868e56UL, 0xbe564ee5UL, 0x00000000UL, - 0x3fe879acUL, 0x56aee828UL, 0x3e5e2fd8UL, 0x60000000UL, 0x3fe86c1cUL, - 0x7ceab8ecUL, 0x3e493365UL, 0xc0000000UL, 0x3fe85e90UL, 0x78d4dadcUL, - 0xbe4f7f25UL, 0x00000000UL, 0x3fe85109UL, 0x0ccd8280UL, 0x3e31e7a2UL, - 0x40000000UL, 0x3fe84385UL, 0x34ba4e15UL, 0x3e328077UL, 0x80000000UL, - 0x3fe83605UL, 0xa670975aUL, 0xbe53eee5UL, 0xa0000000UL, 0x3fe82889UL, - 0xf61b77b2UL, 0xbe43a20aUL, 0xa0000000UL, 0x3fe81b11UL, 0x13e6643bUL, - 0x3e5e5fe5UL, 0xc0000000UL, 0x3fe80d9dUL, 0x82cc94e8UL, 0xbe5ff1f9UL, - 0xa0000000UL, 0x3fe8002dUL, 0x8a0c9c5dUL, 0xbe42b0e7UL, 0x60000000UL, - 0x3fe7f2c1UL, 0x22a16f01UL, 0x3e5d9ea0UL, 0x20000000UL, 0x3fe7e559UL, - 0xc38cd451UL, 0x3e506963UL, 0xc0000000UL, 0x3fe7d7f4UL, 0x9902bc71UL, - 0x3e4503d7UL, 0x40000000UL, 0x3fe7ca94UL, 0xdef2a3c0UL, 0x3e3d98edUL, - 0xa0000000UL, 0x3fe7bd37UL, 0xed49abb0UL, 0x3e24c1ffUL, 0xe0000000UL, - 0x3fe7afdeUL, 0xe3b0be70UL, 0xbe40c467UL, 0x00000000UL, 0x3fe7a28aUL, - 0xaf9f193cUL, 0xbe5dff6cUL, 0xe0000000UL, 0x3fe79538UL, 0xb74cf6b6UL, - 0xbe258ed0UL, 0xa0000000UL, 0x3fe787ebUL, 0x1d9127c7UL, 0x3e345fb0UL, - 0x40000000UL, 0x3fe77aa2UL, 0x1028c21dUL, 0xbe4619bdUL, 0xa0000000UL, - 0x3fe76d5cUL, 0x7cb0b5e4UL, 0x3e40f1a2UL, 0xe0000000UL, 0x3fe7601aUL, - 0x2b1bc4adUL, 0xbe32e8bbUL, 0xe0000000UL, 0x3fe752dcUL, 0x6839f64eUL, - 0x3e41f57bUL, 0xc0000000UL, 0x3fe745a2UL, 0xc4121f7eUL, 0xbe52c40aUL, - 0x60000000UL, 0x3fe7386cUL, 0xd6852d72UL, 0xbe5c4e6bUL, 0xc0000000UL, - 0x3fe72b39UL, 0x91d690f7UL, 0xbe57f88fUL, 0xe0000000UL, 0x3fe71e0aUL, - 0x627a2159UL, 0xbe4425d5UL, 0xc0000000UL, 0x3fe710dfUL, 0x50a54033UL, - 0x3e422b7eUL, 0x60000000UL, 0x3fe703b8UL, 0x3b0b5f91UL, 0x3e5d3857UL, - 0xe0000000UL, 0x3fe6f694UL, 0x84d628a2UL, 0xbe51f090UL, 0x00000000UL, - 0x3fe6e975UL, 0x306d8894UL, 0xbe414d83UL, 0xe0000000UL, 0x3fe6dc58UL, - 0x30bf24aaUL, 0xbe4650caUL, 0x80000000UL, 0x3fe6cf40UL, 0xd4628d69UL, - 0xbe5db007UL, 0xc0000000UL, 0x3fe6c22bUL, 0xa2aae57bUL, 0xbe31d279UL, - 0xc0000000UL, 0x3fe6b51aUL, 0x860edf7eUL, 0xbe2d4c4aUL, 0x80000000UL, - 0x3fe6a80dUL, 0xf3559341UL, 0xbe5f7e98UL, 0xe0000000UL, 0x3fe69b03UL, - 0xa885899eUL, 0xbe5c2011UL, 0xe0000000UL, 0x3fe68dfdUL, 0x2bdc6d37UL, - 0x3e224a82UL, 0xa0000000UL, 0x3fe680fbUL, 0xc12ad1b9UL, 0xbe40cf56UL, - 0x00000000UL, 0x3fe673fdUL, 0x1bcdf659UL, 0xbdf52f2dUL, 0x00000000UL, - 0x3fe66702UL, 0x5df10408UL, 0x3e5663e0UL, 0xc0000000UL, 0x3fe65a0aUL, - 0xa4070568UL, 0xbe40b12fUL, 0x00000000UL, 0x3fe64d17UL, 0x71c54c47UL, - 0x3e5f5e8bUL, 0x00000000UL, 0x3fe64027UL, 0xbd4b7e83UL, 0x3e42ead6UL, - 0xa0000000UL, 0x3fe6333aUL, 0x61598bd2UL, 0xbe4c48d4UL, 0xc0000000UL, - 0x3fe62651UL, 0x6f538d61UL, 0x3e548401UL, 0xa0000000UL, 0x3fe6196cUL, - 0x14344120UL, 0xbe529af6UL, 0x00000000UL, 0x3fe60c8bUL, 0x5982c587UL, - 0xbe3e1e4fUL, 0x00000000UL, 0x3fe5ffadUL, 0xfe51d4eaUL, 0xbe4c897aUL, - 0x80000000UL, 0x3fe5f2d2UL, 0xfd46ebe1UL, 0x3e552e00UL, 0xa0000000UL, - 0x3fe5e5fbUL, 0xa4695699UL, 0x3e5ed471UL, 0x60000000UL, 0x3fe5d928UL, - 0x80d118aeUL, 0x3e456b61UL, 0xa0000000UL, 0x3fe5cc58UL, 0x304c330bUL, - 0x3e54dc29UL, 0x80000000UL, 0x3fe5bf8cUL, 0x0af2dedfUL, 0xbe3aa9bdUL, - 0xe0000000UL, 0x3fe5b2c3UL, 0x15fc9258UL, 0xbe479a37UL, 0xc0000000UL, - 0x3fe5a5feUL, 0x9292c7eaUL, 0x3e188650UL, 0x20000000UL, 0x3fe5993dUL, - 0x33b4d380UL, 0x3e5d6d93UL, 0x20000000UL, 0x3fe58c7fUL, 0x02fd16c7UL, - 0x3e2fe961UL, 0xa0000000UL, 0x3fe57fc4UL, 0x4a05edb6UL, 0xbe4d55b4UL, - 0xa0000000UL, 0x3fe5730dUL, 0x3d443abbUL, 0xbe5e6954UL, 0x00000000UL, - 0x3fe5665aUL, 0x024acfeaUL, 0x3e50e61bUL, 0x00000000UL, 0x3fe559aaUL, - 0xcc9edd09UL, 0xbe325403UL, 0x60000000UL, 0x3fe54cfdUL, 0x1fe26950UL, - 0x3e5d500eUL, 0x60000000UL, 0x3fe54054UL, 0x6c5ae164UL, 0xbe4a79b4UL, - 0xc0000000UL, 0x3fe533aeUL, 0x154b0287UL, 0xbe401571UL, 0xa0000000UL, - 0x3fe5270cUL, 0x0673f401UL, 0xbe56e56bUL, 0xe0000000UL, 0x3fe51a6dUL, - 0x751b639cUL, 0x3e235269UL, 0xa0000000UL, 0x3fe50dd2UL, 0x7c7b2bedUL, - 0x3ddec887UL, 0xc0000000UL, 0x3fe5013aUL, 0xafab4e17UL, 0x3e5e7575UL, - 0x60000000UL, 0x3fe4f4a6UL, 0x2e308668UL, 0x3e59aed6UL, 0x80000000UL, - 0x3fe4e815UL, 0xf33e2a76UL, 0xbe51f184UL, 0xe0000000UL, 0x3fe4db87UL, - 0x839f3e3eUL, 0x3e57db01UL, 0xc0000000UL, 0x3fe4cefdUL, 0xa9eda7bbUL, - 0x3e535e0fUL, 0x00000000UL, 0x3fe4c277UL, 0x2a8f66a5UL, 0x3e5ce451UL, - 0xc0000000UL, 0x3fe4b5f3UL, 0x05192456UL, 0xbe4e8518UL, 0xc0000000UL, - 0x3fe4a973UL, 0x4aa7cd1dUL, 0x3e46784aUL, 0x40000000UL, 0x3fe49cf7UL, - 0x8e23025eUL, 0xbe5749f2UL, 0x00000000UL, 0x3fe4907eUL, 0x18d30215UL, - 0x3e360f39UL, 0x20000000UL, 0x3fe48408UL, 0x63dcf2f3UL, 0x3e5e00feUL, - 0xc0000000UL, 0x3fe47795UL, 0x46182d09UL, 0xbe5173d9UL, 0xa0000000UL, - 0x3fe46b26UL, 0x8f0e62aaUL, 0xbe48f281UL, 0xe0000000UL, 0x3fe45ebaUL, - 0x5775c40cUL, 0xbe56aad4UL, 0x60000000UL, 0x3fe45252UL, 0x0fe25f69UL, - 0x3e48bd71UL, 0x40000000UL, 0x3fe445edUL, 0xe9989ec5UL, 0x3e590d97UL, - 0x80000000UL, 0x3fe4398bUL, 0xb3d9ffe3UL, 0x3e479dbcUL, 0x20000000UL, - 0x3fe42d2dUL, 0x388e4d2eUL, 0xbe5eed80UL, 0xe0000000UL, 0x3fe420d1UL, - 0x6f797c18UL, 0x3e554b4cUL, 0x20000000UL, 0x3fe4147aUL, 0x31048bb4UL, - 0xbe5b1112UL, 0x80000000UL, 0x3fe40825UL, 0x2efba4f9UL, 0x3e48ebc7UL, - 0x40000000UL, 0x3fe3fbd4UL, 0x50201119UL, 0x3e40b701UL, 0x40000000UL, - 0x3fe3ef86UL, 0x0a4db32cUL, 0x3e551de8UL, 0xa0000000UL, 0x3fe3e33bUL, - 0x0c9c148bUL, 0xbe50c1f6UL, 0x20000000UL, 0x3fe3d6f4UL, 0xc9129447UL, - 0x3e533fa0UL, 0x00000000UL, 0x3fe3cab0UL, 0xaae5b5a0UL, 0xbe22b68eUL, - 0x20000000UL, 0x3fe3be6fUL, 0x02305e8aUL, 0xbe54fc08UL, 0x60000000UL, - 0x3fe3b231UL, 0x7f908258UL, 0x3e57dc05UL, 0x00000000UL, 0x3fe3a5f7UL, - 0x1a09af78UL, 0x3e08038bUL, 0xe0000000UL, 0x3fe399bfUL, 0x490643c1UL, - 0xbe5dbe42UL, 0xe0000000UL, 0x3fe38d8bUL, 0x5e8ad724UL, 0xbe3c2b72UL, - 0x20000000UL, 0x3fe3815bUL, 0xc67196b6UL, 0x3e1713cfUL, 0xa0000000UL, - 0x3fe3752dUL, 0x6182e429UL, 0xbe3ec14cUL, 0x40000000UL, 0x3fe36903UL, - 0xab6eb1aeUL, 0x3e5a2cc5UL, 0x40000000UL, 0x3fe35cdcUL, 0xfe5dc064UL, - 0xbe5c5878UL, 0x40000000UL, 0x3fe350b8UL, 0x0ba6b9e4UL, 0x3e51619bUL, - 0x80000000UL, 0x3fe34497UL, 0x857761aaUL, 0x3e5fff53UL, 0x00000000UL, - 0x3fe3387aUL, 0xf872d68cUL, 0x3e484f4dUL, 0xa0000000UL, 0x3fe32c5fUL, - 0x087e97c2UL, 0x3e52842eUL, 0x80000000UL, 0x3fe32048UL, 0x73d6d0c0UL, - 0xbe503edfUL, 0x80000000UL, 0x3fe31434UL, 0x0c1456a1UL, 0xbe5f72adUL, - 0xa0000000UL, 0x3fe30823UL, 0x83a1a4d5UL, 0xbe5e65ccUL, 0xe0000000UL, - 0x3fe2fc15UL, 0x855a7390UL, 0xbe506438UL, 0x40000000UL, 0x3fe2f00bUL, - 0xa2898287UL, 0x3e3d22a2UL, 0xe0000000UL, 0x3fe2e403UL, 0x8b56f66fUL, - 0xbe5aa5fdUL, 0x80000000UL, 0x3fe2d7ffUL, 0x52db119aUL, 0x3e3a2e3dUL, - 0x60000000UL, 0x3fe2cbfeUL, 0xe2ddd4c0UL, 0xbe586469UL, 0x40000000UL, - 0x3fe2c000UL, 0x6b01bf10UL, 0x3e352b9dUL, 0x40000000UL, 0x3fe2b405UL, - 0xb07a1cdfUL, 0x3e5c5cdaUL, 0x80000000UL, 0x3fe2a80dUL, 0xc7b5f868UL, - 0xbe5668b3UL, 0xc0000000UL, 0x3fe29c18UL, 0x185edf62UL, 0xbe563d66UL, - 0x00000000UL, 0x3fe29027UL, 0xf729e1ccUL, 0x3e59a9a0UL, 0x80000000UL, - 0x3fe28438UL, 0x6433c727UL, 0xbe43cc89UL, 0x00000000UL, 0x3fe2784dUL, - 0x41782631UL, 0xbe30750cUL, 0xa0000000UL, 0x3fe26c64UL, 0x914911b7UL, - 0xbe58290eUL, 0x40000000UL, 0x3fe2607fUL, 0x3dcc73e1UL, 0xbe4269cdUL, - 0x00000000UL, 0x3fe2549dUL, 0x2751bf70UL, 0xbe5a6998UL, 0xc0000000UL, - 0x3fe248bdUL, 0x4248b9fbUL, 0xbe4ddb00UL, 0x80000000UL, 0x3fe23ce1UL, - 0xf35cf82fUL, 0x3e561b71UL, 0x60000000UL, 0x3fe23108UL, 0x8e481a2dUL, - 0x3e518fb9UL, 0x60000000UL, 0x3fe22532UL, 0x5ab96edcUL, 0xbe5fafc5UL, - 0x40000000UL, 0x3fe2195fUL, 0x80943911UL, 0xbe07f819UL, 0x40000000UL, - 0x3fe20d8fUL, 0x386f2d6cUL, 0xbe54ba8bUL, 0x40000000UL, 0x3fe201c2UL, - 0xf29664acUL, 0xbe5eb815UL, 0x20000000UL, 0x3fe1f5f8UL, 0x64f03390UL, - 0x3e5e320cUL, 0x20000000UL, 0x3fe1ea31UL, 0x747ff696UL, 0x3e5ef0a5UL, - 0x40000000UL, 0x3fe1de6dUL, 0x3e9ceb51UL, 0xbe5f8d27UL, 0x20000000UL, - 0x3fe1d2acUL, 0x4ae0b55eUL, 0x3e5faa21UL, 0x20000000UL, 0x3fe1c6eeUL, - 0x28569a5eUL, 0x3e598a4fUL, 0x20000000UL, 0x3fe1bb33UL, 0x54b33e07UL, - 0x3e46130aUL, 0x20000000UL, 0x3fe1af7bUL, 0x024f1078UL, 0xbe4dbf93UL, - 0x00000000UL, 0x3fe1a3c6UL, 0xb0783bfaUL, 0x3e419248UL, 0xe0000000UL, - 0x3fe19813UL, 0x2f02b836UL, 0x3e4e02b7UL, 0xc0000000UL, 0x3fe18c64UL, - 0x28dec9d4UL, 0x3e09064fUL, 0x80000000UL, 0x3fe180b8UL, 0x45cbf406UL, - 0x3e5b1f46UL, 0x40000000UL, 0x3fe1750fUL, 0x03d9964cUL, 0x3e5b0a79UL, - 0x00000000UL, 0x3fe16969UL, 0x8b5b882bUL, 0xbe238086UL, 0xa0000000UL, - 0x3fe15dc5UL, 0x73bad6f8UL, 0xbdf1fca4UL, 0x20000000UL, 0x3fe15225UL, - 0x5385769cUL, 0x3e5e8d76UL, 0xa0000000UL, 0x3fe14687UL, 0x1676dc6bUL, - 0x3e571d08UL, 0x20000000UL, 0x3fe13aedUL, 0xa8c41c7fUL, 0xbe598a25UL, - 0x60000000UL, 0x3fe12f55UL, 0xc4e1aaf0UL, 0x3e435277UL, 0xa0000000UL, - 0x3fe123c0UL, 0x403638e1UL, 0xbe21aa7cUL, 0xc0000000UL, 0x3fe1182eUL, - 0x557a092bUL, 0xbdd0116bUL, 0xc0000000UL, 0x3fe10c9fUL, 0x7d779f66UL, - 0x3e4a61baUL, 0xc0000000UL, 0x3fe10113UL, 0x2b09c645UL, 0xbe5d586eUL, - 0x20000000UL, 0x3fe0ea04UL, 0xea2cad46UL, 0x3e5aa97cUL, 0x20000000UL, - 0x3fe0d300UL, 0x23190e54UL, 0x3e50f1a7UL, 0xa0000000UL, 0x3fe0bc07UL, - 0x1379a5a6UL, 0xbe51619dUL, 0x60000000UL, 0x3fe0a51aUL, 0x926a3d4aUL, - 0x3e5cf019UL, 0xa0000000UL, 0x3fe08e38UL, 0xa8c24358UL, 0x3e35241eUL, - 0x20000000UL, 0x3fe07762UL, 0x24317e7aUL, 0x3e512cfaUL, 0x00000000UL, - 0x3fe06097UL, 0xfd9cf274UL, 0xbe55bef3UL, 0x00000000UL, 0x3fe049d7UL, - 0x3689b49dUL, 0xbe36d26dUL, 0x40000000UL, 0x3fe03322UL, 0xf72ef6c4UL, - 0xbe54cd08UL, 0xa0000000UL, 0x3fe01c78UL, 0x23702d2dUL, 0xbe5900bfUL, - 0x00000000UL, 0x3fe005daUL, 0x3f59c14cUL, 0x3e57d80bUL, 0x40000000UL, - 0x3fdfde8dUL, 0xad67766dUL, 0xbe57fad4UL, 0x40000000UL, 0x3fdfb17cUL, - 0x644f4ae7UL, 0x3e1ee43bUL, 0x40000000UL, 0x3fdf8481UL, 0x903234d2UL, - 0x3e501a86UL, 0x40000000UL, 0x3fdf579cUL, 0xafe9e509UL, 0xbe267c3eUL, - 0x00000000UL, 0x3fdf2acdUL, 0xb7dfda0bUL, 0xbe48149bUL, 0x40000000UL, - 0x3fdefe13UL, 0x3b94305eUL, 0x3e5f4ea7UL, 0x80000000UL, 0x3fded16fUL, - 0x5d95da61UL, 0xbe55c198UL, 0x00000000UL, 0x3fdea4e1UL, 0x406960c9UL, - 0xbdd99a19UL, 0x00000000UL, 0x3fde7868UL, 0xd22f3539UL, 0x3e470c78UL, - 0x80000000UL, 0x3fde4c04UL, 0x83eec535UL, 0xbe3e1232UL, 0x40000000UL, - 0x3fde1fb6UL, 0x3dfbffcbUL, 0xbe4b7d71UL, 0x40000000UL, 0x3fddf37dUL, - 0x7e1be4e0UL, 0xbe5b8f8fUL, 0x40000000UL, 0x3fddc759UL, 0x46dae887UL, - 0xbe350458UL, 0x80000000UL, 0x3fdd9b4aUL, 0xed6ecc49UL, 0xbe5f0045UL, - 0x80000000UL, 0x3fdd6f50UL, 0x2e9e883cUL, 0x3e2915daUL, 0x80000000UL, - 0x3fdd436bUL, 0xf0bccb32UL, 0x3e4a68c9UL, 0x80000000UL, 0x3fdd179bUL, - 0x9bbfc779UL, 0xbe54a26aUL, 0x00000000UL, 0x3fdcebe0UL, 0x7cea33abUL, - 0x3e43c6b7UL, 0x40000000UL, 0x3fdcc039UL, 0xe740fd06UL, 0x3e5526c2UL, - 0x40000000UL, 0x3fdc94a7UL, 0x9eadeb1aUL, 0xbe396d8dUL, 0xc0000000UL, - 0x3fdc6929UL, 0xf0a8f95aUL, 0xbe5c0ab2UL, 0x80000000UL, 0x3fdc3dc0UL, - 0x6ee2693bUL, 0x3e0992e6UL, 0xc0000000UL, 0x3fdc126bUL, 0x5ac6b581UL, - 0xbe2834b6UL, 0x40000000UL, 0x3fdbe72bUL, 0x8cc226ffUL, 0x3e3596a6UL, - 0x00000000UL, 0x3fdbbbffUL, 0xf92a74bbUL, 0x3e3c5813UL, 0x00000000UL, - 0x3fdb90e7UL, 0x479664c0UL, 0xbe50d644UL, 0x00000000UL, 0x3fdb65e3UL, - 0x5004975bUL, 0xbe55258fUL, 0x00000000UL, 0x3fdb3af3UL, 0xe4b23194UL, - 0xbe588407UL, 0xc0000000UL, 0x3fdb1016UL, 0xe65d4d0aUL, 0x3e527c26UL, - 0x80000000UL, 0x3fdae54eUL, 0x814fddd6UL, 0x3e5962a2UL, 0x40000000UL, - 0x3fdaba9aUL, 0xe19d0913UL, 0xbe562f4eUL, 0x80000000UL, 0x3fda8ff9UL, - 0x43cfd006UL, 0xbe4cfdebUL, 0x40000000UL, 0x3fda656cUL, 0x686f0a4eUL, - 0x3e5e47a8UL, 0xc0000000UL, 0x3fda3af2UL, 0x7200d410UL, 0x3e5e1199UL, - 0xc0000000UL, 0x3fda108cUL, 0xabd2266eUL, 0x3e5ee4d1UL, 0x40000000UL, - 0x3fd9e63aUL, 0x396f8f2cUL, 0x3e4dbffbUL, 0x00000000UL, 0x3fd9bbfbUL, - 0xe32b25ddUL, 0x3e5c3a54UL, 0x40000000UL, 0x3fd991cfUL, 0x431e4035UL, - 0xbe457925UL, 0x80000000UL, 0x3fd967b6UL, 0x7bed3dd3UL, 0x3e40c61dUL, - 0x00000000UL, 0x3fd93db1UL, 0xd7449365UL, 0x3e306419UL, 0x80000000UL, - 0x3fd913beUL, 0x1746e791UL, 0x3e56fcfcUL, 0x40000000UL, 0x3fd8e9dfUL, - 0xf3a9028bUL, 0xbe5041b9UL, 0xc0000000UL, 0x3fd8c012UL, 0x56840c50UL, - 0xbe26e20aUL, 0x40000000UL, 0x3fd89659UL, 0x19763102UL, 0xbe51f466UL, - 0x80000000UL, 0x3fd86cb2UL, 0x7032de7cUL, 0xbe4d298aUL, 0x80000000UL, - 0x3fd8431eUL, 0xdeb39fabUL, 0xbe4361ebUL, 0x40000000UL, 0x3fd8199dUL, - 0x5d01cbe0UL, 0xbe5425b3UL, 0x80000000UL, 0x3fd7f02eUL, 0x3ce99aa9UL, - 0x3e146fa8UL, 0x80000000UL, 0x3fd7c6d2UL, 0xd1a262b9UL, 0xbe5a1a69UL, - 0xc0000000UL, 0x3fd79d88UL, 0x8606c236UL, 0x3e423a08UL, 0x80000000UL, - 0x3fd77451UL, 0x8fd1e1b7UL, 0x3e5a6a63UL, 0xc0000000UL, 0x3fd74b2cUL, - 0xe491456aUL, 0x3e42c1caUL, 0x40000000UL, 0x3fd7221aUL, 0x4499a6d7UL, - 0x3e36a69aUL, 0x00000000UL, 0x3fd6f91aUL, 0x5237df94UL, 0xbe0f8f02UL, - 0x00000000UL, 0x3fd6d02cUL, 0xb6482c6eUL, 0xbe5abcf7UL, 0x00000000UL, - 0x3fd6a750UL, 0x1919fd61UL, 0xbe57ade2UL, 0x00000000UL, 0x3fd67e86UL, - 0xaa7a994dUL, 0xbe3f3fbdUL, 0x00000000UL, 0x3fd655ceUL, 0x67db014cUL, - 0x3e33c550UL, 0x00000000UL, 0x3fd62d28UL, 0xa82856b7UL, 0xbe1409d1UL, - 0xc0000000UL, 0x3fd60493UL, 0x1e6a300dUL, 0x3e55d899UL, 0x80000000UL, - 0x3fd5dc11UL, 0x1222bd5cUL, 0xbe35bfc0UL, 0xc0000000UL, 0x3fd5b3a0UL, - 0x6e8dc2d3UL, 0x3e5d4d79UL, 0x00000000UL, 0x3fd58b42UL, 0xe0e4ace6UL, - 0xbe517303UL, 0x80000000UL, 0x3fd562f4UL, 0xb306e0a8UL, 0x3e5edf0fUL, - 0xc0000000UL, 0x3fd53ab8UL, 0x6574bc54UL, 0x3e5ee859UL, 0x80000000UL, - 0x3fd5128eUL, 0xea902207UL, 0x3e5f6188UL, 0xc0000000UL, 0x3fd4ea75UL, - 0x9f911d79UL, 0x3e511735UL, 0x80000000UL, 0x3fd4c26eUL, 0xf9c77397UL, - 0xbe5b1643UL, 0x40000000UL, 0x3fd49a78UL, 0x15fc9258UL, 0x3e479a37UL, - 0x80000000UL, 0x3fd47293UL, 0xd5a04dd9UL, 0xbe426e56UL, 0xc0000000UL, - 0x3fd44abfUL, 0xe04042f5UL, 0x3e56f7c6UL, 0x40000000UL, 0x3fd422fdUL, - 0x1d8bf2c8UL, 0x3e5d8810UL, 0x00000000UL, 0x3fd3fb4cUL, 0x88a8ddeeUL, - 0xbe311454UL, 0xc0000000UL, 0x3fd3d3abUL, 0x3e3b5e47UL, 0xbe5d1b72UL, - 0x40000000UL, 0x3fd3ac1cUL, 0xc2ab5d59UL, 0x3e31b02bUL, 0xc0000000UL, - 0x3fd3849dUL, 0xd4e34b9eUL, 0x3e51cb2fUL, 0x40000000UL, 0x3fd35d30UL, - 0x177204fbUL, 0xbe2b8cd7UL, 0x80000000UL, 0x3fd335d3UL, 0xfcd38c82UL, - 0xbe4356e1UL, 0x80000000UL, 0x3fd30e87UL, 0x64f54accUL, 0xbe4e6224UL, - 0x00000000UL, 0x3fd2e74cUL, 0xaa7975d9UL, 0x3e5dc0feUL, 0x80000000UL, - 0x3fd2c021UL, 0x516dab3fUL, 0xbe50ffa3UL, 0x40000000UL, 0x3fd29907UL, - 0x2bfb7313UL, 0x3e5674a2UL, 0xc0000000UL, 0x3fd271fdUL, 0x0549fc99UL, - 0x3e385d29UL, 0xc0000000UL, 0x3fd24b04UL, 0x55b63073UL, 0xbe500c6dUL, - 0x00000000UL, 0x3fd2241cUL, 0x3f91953aUL, 0x3e389977UL, 0xc0000000UL, - 0x3fd1fd43UL, 0xa1543f71UL, 0xbe3487abUL, 0xc0000000UL, 0x3fd1d67bUL, - 0x4ec8867cUL, 0x3df6a2dcUL, 0x00000000UL, 0x3fd1afc4UL, 0x4328e3bbUL, - 0x3e41d9c0UL, 0x80000000UL, 0x3fd1891cUL, 0x2e1cda84UL, 0x3e3bdd87UL, - 0x40000000UL, 0x3fd16285UL, 0x4b5331aeUL, 0xbe53128eUL, 0x00000000UL, - 0x3fd13bfeUL, 0xb9aec164UL, 0xbe52ac98UL, 0xc0000000UL, 0x3fd11586UL, - 0xd91e1316UL, 0xbe350630UL, 0x80000000UL, 0x3fd0ef1fUL, 0x7cacc12cUL, - 0x3e3f5219UL, 0x40000000UL, 0x3fd0c8c8UL, 0xbce277b7UL, 0x3e3d30c0UL, - 0x00000000UL, 0x3fd0a281UL, 0x2a63447dUL, 0xbe541377UL, 0x80000000UL, - 0x3fd07c49UL, 0xfac483b5UL, 0xbe5772ecUL, 0xc0000000UL, 0x3fd05621UL, - 0x36b8a570UL, 0xbe4fd4bdUL, 0xc0000000UL, 0x3fd03009UL, 0xbae505f7UL, - 0xbe450388UL, 0x80000000UL, 0x3fd00a01UL, 0x3e35aeadUL, 0xbe5430fcUL, - 0x80000000UL, 0x3fcfc811UL, 0x707475acUL, 0x3e38806eUL, 0x80000000UL, - 0x3fcf7c3fUL, 0xc91817fcUL, 0xbe40cceaUL, 0x80000000UL, 0x3fcf308cUL, - 0xae05d5e9UL, 0xbe4919b8UL, 0x80000000UL, 0x3fcee4f8UL, 0xae6cc9e6UL, - 0xbe530b94UL, 0x00000000UL, 0x3fce9983UL, 0x1efe3e8eUL, 0x3e57747eUL, - 0x00000000UL, 0x3fce4e2dUL, 0xda78d9bfUL, 0xbe59a608UL, 0x00000000UL, - 0x3fce02f5UL, 0x8abe2c2eUL, 0x3e4a35adUL, 0x00000000UL, 0x3fcdb7dcUL, - 0x1495450dUL, 0xbe0872ccUL, 0x80000000UL, 0x3fcd6ce1UL, 0x86ee0ba0UL, - 0xbe4f59a0UL, 0x00000000UL, 0x3fcd2205UL, 0xe81ca888UL, 0x3e5402c3UL, - 0x00000000UL, 0x3fccd747UL, 0x3b4424b9UL, 0x3e5dfdc3UL, 0x80000000UL, - 0x3fcc8ca7UL, 0xd305b56cUL, 0x3e202da6UL, 0x00000000UL, 0x3fcc4226UL, - 0x399a6910UL, 0xbe482a1cUL, 0x80000000UL, 0x3fcbf7c2UL, 0x747f7938UL, - 0xbe587372UL, 0x80000000UL, 0x3fcbad7cUL, 0x6fc246a0UL, 0x3e50d83dUL, - 0x00000000UL, 0x3fcb6355UL, 0xee9e9be5UL, 0xbe5c35bdUL, 0x80000000UL, - 0x3fcb194aUL, 0x8416c0bcUL, 0x3e546d4fUL, 0x00000000UL, 0x3fcacf5eUL, - 0x49f7f08fUL, 0x3e56da76UL, 0x00000000UL, 0x3fca858fUL, 0x5dc30de2UL, - 0x3e5f390cUL, 0x00000000UL, 0x3fca3bdeUL, 0x950583b6UL, 0xbe5e4169UL, - 0x80000000UL, 0x3fc9f249UL, 0x33631553UL, 0x3e52aeb1UL, 0x00000000UL, - 0x3fc9a8d3UL, 0xde8795a6UL, 0xbe59a504UL, 0x00000000UL, 0x3fc95f79UL, - 0x076bf41eUL, 0x3e5122feUL, 0x80000000UL, 0x3fc9163cUL, 0x2914c8e7UL, - 0x3e3dd064UL, 0x00000000UL, 0x3fc8cd1dUL, 0x3a30eca3UL, 0xbe21b4aaUL, - 0x80000000UL, 0x3fc8841aUL, 0xb2a96650UL, 0xbe575444UL, 0x80000000UL, - 0x3fc83b34UL, 0x2376c0cbUL, 0xbe2a74c7UL, 0x80000000UL, 0x3fc7f26bUL, - 0xd8a0b653UL, 0xbe5181b6UL, 0x00000000UL, 0x3fc7a9bfUL, 0x32257882UL, - 0xbe4a78b4UL, 0x00000000UL, 0x3fc7612fUL, 0x1eee8bd9UL, 0xbe1bfe9dUL, - 0x80000000UL, 0x3fc718bbUL, 0x0c603cc4UL, 0x3e36fdc9UL, 0x80000000UL, - 0x3fc6d064UL, 0x3728b8cfUL, 0xbe1e542eUL, 0x80000000UL, 0x3fc68829UL, - 0xc79a4067UL, 0x3e5c380fUL, 0x00000000UL, 0x3fc6400bUL, 0xf69eac69UL, - 0x3e550a84UL, 0x80000000UL, 0x3fc5f808UL, 0xb7a780a4UL, 0x3e5d9224UL, - 0x80000000UL, 0x3fc5b022UL, 0xad9dfb1eUL, 0xbe55242fUL, 0x00000000UL, - 0x3fc56858UL, 0x659b18beUL, 0xbe4bfda3UL, 0x80000000UL, 0x3fc520a9UL, - 0x66ee3631UL, 0xbe57d769UL, 0x80000000UL, 0x3fc4d916UL, 0x1ec62819UL, - 0x3e2427f7UL, 0x80000000UL, 0x3fc4919fUL, 0xdec25369UL, 0xbe435431UL, - 0x00000000UL, 0x3fc44a44UL, 0xa8acfc4bUL, 0xbe3c62e8UL, 0x00000000UL, - 0x3fc40304UL, 0xcf1d3eabUL, 0xbdfba29fUL, 0x80000000UL, 0x3fc3bbdfUL, - 0x79aba3eaUL, 0xbdf1b7c8UL, 0x80000000UL, 0x3fc374d6UL, 0xb8d186daUL, - 0xbe5130cfUL, 0x80000000UL, 0x3fc32de8UL, 0x9d74f152UL, 0x3e2285b6UL, - 0x00000000UL, 0x3fc2e716UL, 0x50ae7ca9UL, 0xbe503920UL, 0x80000000UL, - 0x3fc2a05eUL, 0x6caed92eUL, 0xbe533924UL, 0x00000000UL, 0x3fc259c2UL, - 0x9cb5034eUL, 0xbe510e31UL, 0x80000000UL, 0x3fc21340UL, 0x12c4d378UL, - 0xbe540b43UL, 0x80000000UL, 0x3fc1ccd9UL, 0xcc418706UL, 0x3e59887aUL, - 0x00000000UL, 0x3fc1868eUL, 0x921f4106UL, 0xbe528e67UL, 0x80000000UL, - 0x3fc1405cUL, 0x3969441eUL, 0x3e5d8051UL, 0x00000000UL, 0x3fc0fa46UL, - 0xd941ef5bUL, 0x3e5f9079UL, 0x80000000UL, 0x3fc0b44aUL, 0x5a3e81b2UL, - 0xbe567691UL, 0x00000000UL, 0x3fc06e69UL, 0x9d66afe7UL, 0xbe4d43fbUL, - 0x00000000UL, 0x3fc028a2UL, 0x0a92a162UL, 0xbe52f394UL, 0x00000000UL, - 0x3fbfc5eaUL, 0x209897e5UL, 0x3e529e37UL, 0x00000000UL, 0x3fbf3ac5UL, - 0x8458bd7bUL, 0x3e582831UL, 0x00000000UL, 0x3fbeafd5UL, 0xb8d8b4b8UL, - 0xbe486b4aUL, 0x00000000UL, 0x3fbe2518UL, 0xe0a3b7b6UL, 0x3e5bafd2UL, - 0x00000000UL, 0x3fbd9a90UL, 0x2bf2710eUL, 0x3e383b2bUL, 0x00000000UL, - 0x3fbd103cUL, 0x73eb6ab7UL, 0xbe56d78dUL, 0x00000000UL, 0x3fbc861bUL, - 0x32ceaff5UL, 0xbe32dc5aUL, 0x00000000UL, 0x3fbbfc2eUL, 0xbee04cb7UL, - 0xbe4a71a4UL, 0x00000000UL, 0x3fbb7274UL, 0x35ae9577UL, 0x3e38142fUL, - 0x00000000UL, 0x3fbae8eeUL, 0xcbaddab4UL, 0xbe5490f0UL, 0x00000000UL, - 0x3fba5f9aUL, 0x95ce1114UL, 0x3e597c71UL, 0x00000000UL, 0x3fb9d67aUL, - 0x6d7c0f78UL, 0x3e3abc2dUL, 0x00000000UL, 0x3fb94d8dUL, 0x2841a782UL, - 0xbe566cbcUL, 0x00000000UL, 0x3fb8c4d2UL, 0x6ed429c6UL, 0xbe3cfff9UL, - 0x00000000UL, 0x3fb83c4aUL, 0xe4a49fbbUL, 0xbe552964UL, 0x00000000UL, - 0x3fb7b3f4UL, 0x2193d81eUL, 0xbe42fa72UL, 0x00000000UL, 0x3fb72bd0UL, - 0xdd70c122UL, 0x3e527a8cUL, 0x00000000UL, 0x3fb6a3dfUL, 0x03108a54UL, - 0xbe450393UL, 0x00000000UL, 0x3fb61c1fUL, 0x30ff7954UL, 0x3e565840UL, - 0x00000000UL, 0x3fb59492UL, 0xdedd460cUL, 0xbe5422b5UL, 0x00000000UL, - 0x3fb50d36UL, 0x950f9f45UL, 0xbe5313f6UL, 0x00000000UL, 0x3fb4860bUL, - 0x582cdcb1UL, 0x3e506d39UL, 0x00000000UL, 0x3fb3ff12UL, 0x7216d3a6UL, - 0x3e4aa719UL, 0x00000000UL, 0x3fb3784aUL, 0x57a423fdUL, 0x3e5a9b9fUL, - 0x00000000UL, 0x3fb2f1b4UL, 0x7a138b41UL, 0xbe50b418UL, 0x00000000UL, - 0x3fb26b4eUL, 0x2fbfd7eaUL, 0x3e23a53eUL, 0x00000000UL, 0x3fb1e519UL, - 0x18913ccbUL, 0x3e465fc1UL, 0x00000000UL, 0x3fb15f15UL, 0x7ea24e21UL, - 0x3e042843UL, 0x00000000UL, 0x3fb0d941UL, 0x7c6d9c77UL, 0x3e59f61eUL, - 0x00000000UL, 0x3fb0539eUL, 0x114efd44UL, 0x3e4ccab7UL, 0x00000000UL, - 0x3faf9c56UL, 0x1777f657UL, 0x3e552f65UL, 0x00000000UL, 0x3fae91d2UL, - 0xc317b86aUL, 0xbe5a61e0UL, 0x00000000UL, 0x3fad87acUL, 0xb7664efbUL, - 0xbe41f64eUL, 0x00000000UL, 0x3fac7de6UL, 0x5d3d03a9UL, 0x3e0807a0UL, - 0x00000000UL, 0x3fab7480UL, 0x743c38ebUL, 0xbe3726e1UL, 0x00000000UL, - 0x3faa6b78UL, 0x06a253f1UL, 0x3e5ad636UL, 0x00000000UL, 0x3fa962d0UL, - 0xa35f541bUL, 0x3e5a187aUL, 0x00000000UL, 0x3fa85a88UL, 0x4b86e446UL, - 0xbe508150UL, 0x00000000UL, 0x3fa7529cUL, 0x2589cacfUL, 0x3e52938aUL, - 0x00000000UL, 0x3fa64b10UL, 0xaf6b11f2UL, 0xbe3454cdUL, 0x00000000UL, - 0x3fa543e2UL, 0x97506fefUL, 0xbe5fdec5UL, 0x00000000UL, 0x3fa43d10UL, - 0xe75f7dd9UL, 0xbe388dd3UL, 0x00000000UL, 0x3fa3369cUL, 0xa4139632UL, - 0xbdea5177UL, 0x00000000UL, 0x3fa23086UL, 0x352d6f1eUL, 0xbe565ad6UL, - 0x00000000UL, 0x3fa12accUL, 0x77449eb7UL, 0xbe50d5c7UL, 0x00000000UL, - 0x3fa0256eUL, 0x7478da78UL, 0x3e404724UL, 0x00000000UL, 0x3f9e40dcUL, - 0xf59cef7fUL, 0xbe539d0aUL, 0x00000000UL, 0x3f9c3790UL, 0x1511d43cUL, - 0x3e53c2c8UL, 0x00000000UL, 0x3f9a2f00UL, 0x9b8bff3cUL, 0xbe43b3e1UL, - 0x00000000UL, 0x3f982724UL, 0xad1e22a5UL, 0x3e46f0bdUL, 0x00000000UL, - 0x3f962000UL, 0x130d9356UL, 0x3e475ba0UL, 0x00000000UL, 0x3f941994UL, - 0x8f86f883UL, 0xbe513d0bUL, 0x00000000UL, 0x3f9213dcUL, 0x914d0dc8UL, - 0xbe534335UL, 0x00000000UL, 0x3f900ed8UL, 0x2d73e5e7UL, 0xbe22ba75UL, - 0x00000000UL, 0x3f8c1510UL, 0xc5b7d70eUL, 0x3e599c5dUL, 0x00000000UL, - 0x3f880de0UL, 0x8a27857eUL, 0xbe3d28c8UL, 0x00000000UL, 0x3f840810UL, - 0xda767328UL, 0x3e531b3dUL, 0x00000000UL, 0x3f8003b0UL, 0x77bacaf3UL, - 0xbe5f04e3UL, 0x00000000UL, 0x3f780150UL, 0xdf4b0720UL, 0x3e5a8bffUL, - 0x00000000UL, 0x3f6ffc40UL, 0x34c48e71UL, 0xbe3fcd99UL, 0x00000000UL, - 0x3f5ff6c0UL, 0x1ad218afUL, 0xbe4c78a7UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x80000000UL -}; - -ALIGNED_(8) juint _log2_pow[] = -{ - 0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL, 0xbfe62e42UL -}; - -//registers, -// input: xmm0, xmm1 -// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 -// rax, rdx, rcx, r8, r11 - -// Code generated by Intel C compiler for LIBM library - -void MacroAssembler::fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp1, Register tmp2, Register tmp3, Register tmp4) { - Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; - Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; - Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2; - Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, L_2TAG_PACKET_14_0_2, L_2TAG_PACKET_15_0_2; - Label L_2TAG_PACKET_16_0_2, L_2TAG_PACKET_17_0_2, L_2TAG_PACKET_18_0_2, L_2TAG_PACKET_19_0_2; - Label L_2TAG_PACKET_20_0_2, L_2TAG_PACKET_21_0_2, L_2TAG_PACKET_22_0_2, L_2TAG_PACKET_23_0_2; - Label L_2TAG_PACKET_24_0_2, L_2TAG_PACKET_25_0_2, L_2TAG_PACKET_26_0_2, L_2TAG_PACKET_27_0_2; - Label L_2TAG_PACKET_28_0_2, L_2TAG_PACKET_29_0_2, L_2TAG_PACKET_30_0_2, L_2TAG_PACKET_31_0_2; - Label L_2TAG_PACKET_32_0_2, L_2TAG_PACKET_33_0_2, L_2TAG_PACKET_34_0_2, L_2TAG_PACKET_35_0_2; - Label L_2TAG_PACKET_36_0_2, L_2TAG_PACKET_37_0_2, L_2TAG_PACKET_38_0_2, L_2TAG_PACKET_39_0_2; - Label L_2TAG_PACKET_40_0_2, L_2TAG_PACKET_41_0_2, L_2TAG_PACKET_42_0_2, L_2TAG_PACKET_43_0_2; - Label L_2TAG_PACKET_44_0_2, L_2TAG_PACKET_45_0_2, L_2TAG_PACKET_46_0_2, L_2TAG_PACKET_47_0_2; - Label L_2TAG_PACKET_48_0_2, L_2TAG_PACKET_49_0_2, L_2TAG_PACKET_50_0_2, L_2TAG_PACKET_51_0_2; - Label L_2TAG_PACKET_52_0_2, L_2TAG_PACKET_53_0_2, L_2TAG_PACKET_54_0_2, L_2TAG_PACKET_55_0_2; - Label L_2TAG_PACKET_56_0_2; - Label B1_2, B1_3, B1_5, start; - - assert_different_registers(tmp1, tmp2, eax, ecx, edx); - jmp(start); - address HIGHSIGMASK = (address)_HIGHSIGMASK; - address LOG2_E = (address)_LOG2_E; - address coeff = (address)_coeff_pow; - address L_tbl = (address)_L_tbl_pow; - address HIGHMASK_Y = (address)_HIGHMASK_Y; - address T_exp = (address)_T_exp; - address e_coeff = (address)_e_coeff; - address coeff_h = (address)_coeff_h; - address HIGHMASK_LOG_X = (address)_HIGHMASK_LOG_X; - address HALFMASK = (address)_HALFMASK; - address log2 = (address)_log2_pow; - - - bind(start); - subq(rsp, 40); - movsd(Address(rsp, 8), xmm0); - movsd(Address(rsp, 16), xmm1); - - bind(B1_2); - pextrw(eax, xmm0, 3); - xorpd(xmm2, xmm2); - mov64(tmp2, 0x3ff0000000000000); - movdq(xmm2, tmp2); - movl(tmp1, 1069088768); - movdq(xmm7, tmp1); - xorpd(xmm1, xmm1); - mov64(tmp3, 0x77f0000000000000); - movdq(xmm1, tmp3); - movdqu(xmm3, xmm0); - movl(edx, 32752); - andl(edx, eax); - subl(edx, 16368); - movl(ecx, edx); - sarl(edx, 31); - addl(ecx, edx); - xorl(ecx, edx); - por(xmm0, xmm2); - movdqu(xmm6, ExternalAddress(HIGHSIGMASK)); //0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL - psrlq(xmm0, 27); - movq(xmm2, ExternalAddress(LOG2_E)); //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL - psrld(xmm0, 2); - addl(ecx, 16); - bsrl(ecx, ecx); - rcpps(xmm0, xmm0); - psllq(xmm3, 12); - movl(tmp4, 8192); - movdq(xmm4, tmp4); - psrlq(xmm3, 12); - subl(eax, 16); - cmpl(eax, 32736); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); - movl(tmp1, 0); - - bind(L_2TAG_PACKET_1_0_2); - mulss(xmm0, xmm7); - movl(edx, -1); - subl(ecx, 4); - shll(edx); - shlq(edx, 32); - movdq(xmm5, edx); - por(xmm3, xmm1); - subl(eax, 16351); - cmpl(eax, 1); - jcc(Assembler::belowEqual, L_2TAG_PACKET_2_0_2); - paddd(xmm0, xmm4); - pand(xmm5, xmm3); - movdl(edx, xmm0); - psllq(xmm0, 29); - - bind(L_2TAG_PACKET_3_0_2); - subsd(xmm3, xmm5); - pand(xmm0, xmm6); - subl(eax, 1); - sarl(eax, 4); - cvtsi2sdl(xmm7, eax); - mulpd(xmm5, xmm0); - - bind(L_2TAG_PACKET_4_0_2); - mulsd(xmm3, xmm0); - movdqu(xmm1, ExternalAddress(coeff)); //0x6dc96112UL, 0xbf836578UL, 0xee241472UL, 0xbf9b0301UL - lea(tmp4, ExternalAddress(L_tbl)); - subsd(xmm5, xmm2); - movdqu(xmm4, ExternalAddress(16 + coeff)); //0x9f95985aUL, 0xbfb528dbUL, 0xb3841d2aUL, 0xbfd619b6UL - movl(ecx, eax); - sarl(eax, 31); - addl(ecx, eax); - xorl(eax, ecx); - addl(eax, 1); - bsrl(eax, eax); - unpcklpd(xmm5, xmm3); - movdqu(xmm6, ExternalAddress(32 + coeff)); //0x518775e3UL, 0x3f9004f2UL, 0xac8349bbUL, 0x3fa76c9bUL - addsd(xmm3, xmm5); - andl(edx, 16760832); - shrl(edx, 10); - addpd(xmm5, Address(tmp4, edx, Address::times_1, -3648)); - movdqu(xmm0, ExternalAddress(48 + coeff)); //0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, 0xbf5dabe1UL - pshufd(xmm2, xmm3, 68); - mulsd(xmm3, xmm3); - mulpd(xmm1, xmm2); - mulpd(xmm4, xmm2); - addsd(xmm5, xmm7); - mulsd(xmm2, xmm3); - addpd(xmm6, xmm1); - mulsd(xmm3, xmm3); - addpd(xmm0, xmm4); - movq(xmm1, Address(rsp, 16)); - movw(ecx, Address(rsp, 22)); - pshufd(xmm7, xmm5, 238); - movq(xmm4, ExternalAddress(HIGHMASK_Y)); //0x00000000UL, 0xfffffff8UL, 0x00000000UL, 0xffffffffUL - mulpd(xmm6, xmm2); - pshufd(xmm3, xmm3, 68); - mulpd(xmm0, xmm2); - shll(eax, 4); - subl(eax, 15872); - andl(ecx, 32752); - addl(eax, ecx); - mulpd(xmm3, xmm6); - cmpl(eax, 624); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2); - xorpd(xmm6, xmm6); - movl(edx, 17080); - pinsrw(xmm6, edx, 3); - movdqu(xmm2, xmm1); - pand(xmm4, xmm1); - subsd(xmm1, xmm4); - mulsd(xmm4, xmm5); - addsd(xmm0, xmm7); - mulsd(xmm1, xmm5); - movdqu(xmm7, xmm6); - addsd(xmm6, xmm4); - lea(tmp4, ExternalAddress(T_exp)); - addpd(xmm3, xmm0); - movdl(edx, xmm6); - subsd(xmm6, xmm7); - pshufd(xmm0, xmm3, 238); - subsd(xmm4, xmm6); - addsd(xmm0, xmm3); - movl(ecx, edx); - andl(edx, 255); - addl(edx, edx); - movdqu(xmm5, Address(tmp4, edx, Address::times_8, 0)); - addsd(xmm4, xmm1); - mulsd(xmm2, xmm0); - movdqu(xmm7, ExternalAddress(e_coeff)); //0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL - movdqu(xmm3, ExternalAddress(16 + e_coeff)); //0x6fba4e77UL, 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL - shll(ecx, 12); - xorl(ecx, tmp1); - andl(rcx, -1048576); - movdq(xmm6, rcx); - addsd(xmm2, xmm4); - mov64(tmp2, 0x3fe62e42fefa39ef); - movdq(xmm1, tmp2); - pshufd(xmm0, xmm2, 68); - pshufd(xmm4, xmm2, 68); - mulsd(xmm1, xmm2); - pshufd(xmm6, xmm6, 17); - mulpd(xmm0, xmm0); - mulpd(xmm7, xmm4); - paddd(xmm5, xmm6); - mulsd(xmm1, xmm5); - pshufd(xmm6, xmm5, 238); - mulsd(xmm0, xmm0); - addpd(xmm3, xmm7); - addsd(xmm1, xmm6); - mulpd(xmm0, xmm3); - pshufd(xmm3, xmm0, 238); - mulsd(xmm0, xmm5); - mulsd(xmm3, xmm5); - addsd(xmm0, xmm1); - addsd(xmm0, xmm3); - addsd(xmm0, xmm5); - jmp(B1_5); - - bind(L_2TAG_PACKET_0_0_2); - addl(eax, 16); - movl(edx, 32752); - andl(edx, eax); - cmpl(edx, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_6_0_2); - testl(eax, 32768); - jcc(Assembler::notEqual, L_2TAG_PACKET_7_0_2); - - bind(L_2TAG_PACKET_8_0_2); - movq(xmm0, Address(rsp, 8)); - movq(xmm3, Address(rsp, 8)); - movdl(edx, xmm3); - psrlq(xmm3, 32); - movdl(ecx, xmm3); - orl(edx, ecx); - cmpl(edx, 0); - jcc(Assembler::equal, L_2TAG_PACKET_9_0_2); - xorpd(xmm3, xmm3); - movl(eax, 18416); - pinsrw(xmm3, eax, 3); - mulsd(xmm0, xmm3); - xorpd(xmm2, xmm2); - movl(eax, 16368); - pinsrw(xmm2, eax, 3); - movdqu(xmm3, xmm0); - pextrw(eax, xmm0, 3); - por(xmm0, xmm2); - movl(ecx, 18416); - psrlq(xmm0, 27); - movq(xmm2, ExternalAddress(LOG2_E)); //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL - psrld(xmm0, 2); - rcpps(xmm0, xmm0); - psllq(xmm3, 12); - movdqu(xmm6, ExternalAddress(HIGHSIGMASK)); //0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL - psrlq(xmm3, 12); - mulss(xmm0, xmm7); - movl(edx, -1024); - movdl(xmm5, edx); - por(xmm3, xmm1); - paddd(xmm0, xmm4); - psllq(xmm5, 32); - movdl(edx, xmm0); - psllq(xmm0, 29); - pand(xmm5, xmm3); - movl(tmp1, 0); - pand(xmm0, xmm6); - subsd(xmm3, xmm5); - andl(eax, 32752); - subl(eax, 18416); - sarl(eax, 4); - cvtsi2sdl(xmm7, eax); - mulpd(xmm5, xmm0); - jmp(L_2TAG_PACKET_4_0_2); - - bind(L_2TAG_PACKET_10_0_2); - movq(xmm0, Address(rsp, 8)); - movq(xmm3, Address(rsp, 8)); - movdl(edx, xmm3); - psrlq(xmm3, 32); - movdl(ecx, xmm3); - orl(edx, ecx); - cmpl(edx, 0); - jcc(Assembler::equal, L_2TAG_PACKET_9_0_2); - xorpd(xmm3, xmm3); - movl(eax, 18416); - pinsrw(xmm3, eax, 3); - mulsd(xmm0, xmm3); - xorpd(xmm2, xmm2); - movl(eax, 16368); - pinsrw(xmm2, eax, 3); - movdqu(xmm3, xmm0); - pextrw(eax, xmm0, 3); - por(xmm0, xmm2); - movl(ecx, 18416); - psrlq(xmm0, 27); - movq(xmm2, ExternalAddress(LOG2_E)); //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL - psrld(xmm0, 2); - rcpps(xmm0, xmm0); - psllq(xmm3, 12); - movdqu(xmm6, ExternalAddress(HIGHSIGMASK)); //0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL - psrlq(xmm3, 12); - mulss(xmm0, xmm7); - movl(edx, -1024); - movdl(xmm5, edx); - por(xmm3, xmm1); - paddd(xmm0, xmm4); - psllq(xmm5, 32); - movdl(edx, xmm0); - psllq(xmm0, 29); - pand(xmm5, xmm3); - movl(tmp1, INT_MIN); - pand(xmm0, xmm6); - subsd(xmm3, xmm5); - andl(eax, 32752); - subl(eax, 18416); - sarl(eax, 4); - cvtsi2sdl(xmm7, eax); - mulpd(xmm5, xmm0); - jmp(L_2TAG_PACKET_4_0_2); - - bind(L_2TAG_PACKET_5_0_2); - cmpl(eax, 0); - jcc(Assembler::less, L_2TAG_PACKET_11_0_2); - cmpl(eax, 752); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_12_0_2); - addsd(xmm0, xmm7); - movq(xmm2, ExternalAddress(HALFMASK)); //0xf8000000UL, 0xffffffffUL, 0xf8000000UL, 0xffffffffUL - addpd(xmm3, xmm0); - xorpd(xmm6, xmm6); - movl(eax, 17080); - pinsrw(xmm6, eax, 3); - pshufd(xmm0, xmm3, 238); - addsd(xmm0, xmm3); - movdqu(xmm3, xmm5); - addsd(xmm5, xmm0); - movdqu(xmm4, xmm2); - subsd(xmm3, xmm5); - movdqu(xmm7, xmm5); - pand(xmm5, xmm2); - movdqu(xmm2, xmm1); - pand(xmm4, xmm1); - subsd(xmm7, xmm5); - addsd(xmm0, xmm3); - subsd(xmm1, xmm4); - mulsd(xmm4, xmm5); - addsd(xmm0, xmm7); - mulsd(xmm2, xmm0); - movdqu(xmm7, xmm6); - mulsd(xmm1, xmm5); - addsd(xmm6, xmm4); - movdl(eax, xmm6); - subsd(xmm6, xmm7); - lea(tmp4, ExternalAddress(T_exp)); - addsd(xmm2, xmm1); - movdqu(xmm7, ExternalAddress(e_coeff)); //0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL - movdqu(xmm3, ExternalAddress(16 + e_coeff)); //0x6fba4e77UL, 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL - subsd(xmm4, xmm6); - pextrw(edx, xmm6, 3); - movl(ecx, eax); - andl(eax, 255); - addl(eax, eax); - movdqu(xmm5, Address(tmp4, rax, Address::times_8, 0)); - addsd(xmm2, xmm4); - sarl(ecx, 8); - movl(eax, ecx); - sarl(ecx, 1); - subl(eax, ecx); - shll(ecx, 20); - xorl(ecx, tmp1); - movdl(xmm6, ecx); - movq(xmm1, ExternalAddress(32 + e_coeff)); //0xfefa39efUL, 0x3fe62e42UL, 0x00000000UL, 0x00000000UL - andl(edx, 32767); - cmpl(edx, 16529); - jcc(Assembler::above, L_2TAG_PACKET_12_0_2); - pshufd(xmm0, xmm2, 68); - pshufd(xmm4, xmm2, 68); - mulpd(xmm0, xmm0); - mulpd(xmm7, xmm4); - pshufd(xmm6, xmm6, 17); - mulsd(xmm1, xmm2); - mulsd(xmm0, xmm0); - paddd(xmm5, xmm6); - addpd(xmm3, xmm7); - mulsd(xmm1, xmm5); - pshufd(xmm6, xmm5, 238); - mulpd(xmm0, xmm3); - addsd(xmm1, xmm6); - pshufd(xmm3, xmm0, 238); - mulsd(xmm0, xmm5); - mulsd(xmm3, xmm5); - shll(eax, 4); - xorpd(xmm4, xmm4); - addl(eax, 16368); - pinsrw(xmm4, eax, 3); - addsd(xmm0, xmm1); - addsd(xmm0, xmm3); - movdqu(xmm1, xmm0); - addsd(xmm0, xmm5); - mulsd(xmm0, xmm4); - pextrw(eax, xmm0, 3); - andl(eax, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_13_0_2); - cmpl(eax, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_14_0_2); - jmp(B1_5); - - bind(L_2TAG_PACKET_6_0_2); - movq(xmm1, Address(rsp, 16)); - movq(xmm0, Address(rsp, 8)); - movdqu(xmm2, xmm0); - movdl(eax, xmm2); - psrlq(xmm2, 20); - movdl(edx, xmm2); - orl(eax, edx); - jcc(Assembler::equal, L_2TAG_PACKET_15_0_2); - movdl(eax, xmm1); - psrlq(xmm1, 32); - movdl(edx, xmm1); - movl(ecx, edx); - addl(edx, edx); - orl(eax, edx); - jcc(Assembler::equal, L_2TAG_PACKET_16_0_2); - addsd(xmm0, xmm0); - jmp(B1_5); - - bind(L_2TAG_PACKET_16_0_2); - xorpd(xmm0, xmm0); - movl(eax, 16368); - pinsrw(xmm0, eax, 3); - movl(Address(rsp, 0), 29); - jmp(L_2TAG_PACKET_17_0_2); - - bind(L_2TAG_PACKET_18_0_2); - movq(xmm0, Address(rsp, 16)); - addpd(xmm0, xmm0); - jmp(B1_5); - - bind(L_2TAG_PACKET_15_0_2); - movdl(eax, xmm1); - movdqu(xmm2, xmm1); - psrlq(xmm1, 32); - movdl(edx, xmm1); - movl(ecx, edx); - addl(edx, edx); - orl(eax, edx); - jcc(Assembler::equal, L_2TAG_PACKET_19_0_2); - pextrw(eax, xmm2, 3); - andl(eax, 32752); - cmpl(eax, 32752); - jcc(Assembler::notEqual, L_2TAG_PACKET_20_0_2); - movdl(eax, xmm2); - psrlq(xmm2, 20); - movdl(edx, xmm2); - orl(eax, edx); - jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_20_0_2); - pextrw(eax, xmm0, 3); - testl(eax, 32768); - jcc(Assembler::notEqual, L_2TAG_PACKET_21_0_2); - testl(ecx, INT_MIN); - jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2); - jmp(B1_5); - - bind(L_2TAG_PACKET_23_0_2); - movq(xmm1, Address(rsp, 16)); - movdl(eax, xmm1); - testl(eax, 1); - jcc(Assembler::notEqual, L_2TAG_PACKET_24_0_2); - testl(eax, 2); - jcc(Assembler::notEqual, L_2TAG_PACKET_25_0_2); - jmp(L_2TAG_PACKET_24_0_2); - - bind(L_2TAG_PACKET_21_0_2); - shrl(ecx, 20); - andl(ecx, 2047); - cmpl(ecx, 1075); - jcc(Assembler::above, L_2TAG_PACKET_24_0_2); - jcc(Assembler::equal, L_2TAG_PACKET_26_0_2); - cmpl(ecx, 1074); - jcc(Assembler::above, L_2TAG_PACKET_23_0_2); - cmpl(ecx, 1023); - jcc(Assembler::below, L_2TAG_PACKET_24_0_2); - movq(xmm1, Address(rsp, 16)); - movl(eax, 17208); - xorpd(xmm3, xmm3); - pinsrw(xmm3, eax, 3); - movdqu(xmm4, xmm3); - addsd(xmm3, xmm1); - subsd(xmm4, xmm3); - addsd(xmm1, xmm4); - pextrw(eax, xmm1, 3); - andl(eax, 32752); - jcc(Assembler::notEqual, L_2TAG_PACKET_24_0_2); - movdl(eax, xmm3); - andl(eax, 1); - jcc(Assembler::equal, L_2TAG_PACKET_24_0_2); - - bind(L_2TAG_PACKET_25_0_2); - movq(xmm1, Address(rsp, 16)); - pextrw(eax, xmm1, 3); - andl(eax, 32768); - jcc(Assembler::notEqual, L_2TAG_PACKET_27_0_2); - jmp(B1_5); - - bind(L_2TAG_PACKET_27_0_2); - xorpd(xmm0, xmm0); - movl(eax, 32768); - pinsrw(xmm0, eax, 3); - jmp(B1_5); - - bind(L_2TAG_PACKET_24_0_2); - movq(xmm1, Address(rsp, 16)); - pextrw(eax, xmm1, 3); - andl(eax, 32768); - jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2); - xorpd(xmm0, xmm0); - movl(eax, 32752); - pinsrw(xmm0, eax, 3); - jmp(B1_5); - - bind(L_2TAG_PACKET_26_0_2); - movq(xmm1, Address(rsp, 16)); - movdl(eax, xmm1); - andl(eax, 1); - jcc(Assembler::equal, L_2TAG_PACKET_24_0_2); - jmp(L_2TAG_PACKET_25_0_2); - - bind(L_2TAG_PACKET_28_0_2); - movdl(eax, xmm1); - psrlq(xmm1, 20); - movdl(edx, xmm1); - orl(eax, edx); - jcc(Assembler::equal, L_2TAG_PACKET_29_0_2); - movq(xmm0, Address(rsp, 16)); - addsd(xmm0, xmm0); - jmp(B1_5); - - bind(L_2TAG_PACKET_29_0_2); - movq(xmm0, Address(rsp, 8)); - pextrw(eax, xmm0, 3); - cmpl(eax, 49136); - jcc(Assembler::notEqual, L_2TAG_PACKET_30_0_2); - movdl(ecx, xmm0); - psrlq(xmm0, 20); - movdl(edx, xmm0); - orl(ecx, edx); - jcc(Assembler::notEqual, L_2TAG_PACKET_30_0_2); - xorpd(xmm0, xmm0); - movl(eax, 32760); - pinsrw(xmm0, eax, 3); - jmp(B1_5); - - bind(L_2TAG_PACKET_30_0_2); - movq(xmm1, Address(rsp, 16)); - andl(eax, 32752); - subl(eax, 16368); - pextrw(edx, xmm1, 3); - xorpd(xmm0, xmm0); - xorl(eax, edx); - andl(eax, 32768); - jcc(Assembler::equal, L_2TAG_PACKET_31_0_2); - jmp(B1_5); - - bind(L_2TAG_PACKET_31_0_2); - movl(ecx, 32752); - pinsrw(xmm0, ecx, 3); - jmp(B1_5); - - bind(L_2TAG_PACKET_32_0_2); - movdl(eax, xmm1); - cmpl(edx, 17184); - jcc(Assembler::above, L_2TAG_PACKET_33_0_2); - testl(eax, 1); - jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2); - testl(eax, 2); - jcc(Assembler::equal, L_2TAG_PACKET_35_0_2); - jmp(L_2TAG_PACKET_36_0_2); - - bind(L_2TAG_PACKET_33_0_2); - testl(eax, 1); - jcc(Assembler::equal, L_2TAG_PACKET_35_0_2); - jmp(L_2TAG_PACKET_36_0_2); - - bind(L_2TAG_PACKET_7_0_2); - movq(xmm2, Address(rsp, 8)); - movdl(eax, xmm2); - psrlq(xmm2, 31); - movdl(ecx, xmm2); - orl(eax, ecx); - jcc(Assembler::equal, L_2TAG_PACKET_9_0_2); - movq(xmm1, Address(rsp, 16)); - pextrw(edx, xmm1, 3); - movdl(eax, xmm1); - movdqu(xmm2, xmm1); - psrlq(xmm2, 32); - movdl(ecx, xmm2); - addl(ecx, ecx); - orl(ecx, eax); - jcc(Assembler::equal, L_2TAG_PACKET_37_0_2); - andl(edx, 32752); - cmpl(edx, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_28_0_2); - cmpl(edx, 17200); - jcc(Assembler::above, L_2TAG_PACKET_35_0_2); - cmpl(edx, 17184); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_32_0_2); - cmpl(edx, 16368); - jcc(Assembler::below, L_2TAG_PACKET_34_0_2); - movl(eax, 17208); - xorpd(xmm2, xmm2); - pinsrw(xmm2, eax, 3); - movdqu(xmm4, xmm2); - addsd(xmm2, xmm1); - subsd(xmm4, xmm2); - addsd(xmm1, xmm4); - pextrw(eax, xmm1, 3); - andl(eax, 32767); - jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2); - movdl(eax, xmm2); - andl(eax, 1); - jcc(Assembler::equal, L_2TAG_PACKET_35_0_2); - - bind(L_2TAG_PACKET_36_0_2); - xorpd(xmm1, xmm1); - movl(edx, 30704); - pinsrw(xmm1, edx, 3); - movq(xmm2, ExternalAddress(LOG2_E)); //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL - movq(xmm4, Address(rsp, 8)); - pextrw(eax, xmm4, 3); - movl(edx, 8192); - movdl(xmm4, edx); - andl(eax, 32767); - subl(eax, 16); - jcc(Assembler::less, L_2TAG_PACKET_10_0_2); - movl(edx, eax); - andl(edx, 32752); - subl(edx, 16368); - movl(ecx, edx); - sarl(edx, 31); - addl(ecx, edx); - xorl(ecx, edx); - addl(ecx, 16); - bsrl(ecx, ecx); - movl(tmp1, INT_MIN); - jmp(L_2TAG_PACKET_1_0_2); - - bind(L_2TAG_PACKET_34_0_2); - xorpd(xmm1, xmm1); - movl(eax, 32752); - pinsrw(xmm1, eax, 3); - xorpd(xmm0, xmm0); - mulsd(xmm0, xmm1); - movl(Address(rsp, 0), 28); - jmp(L_2TAG_PACKET_17_0_2); - - bind(L_2TAG_PACKET_35_0_2); - xorpd(xmm1, xmm1); - movl(edx, 30704); - pinsrw(xmm1, edx, 3); - movq(xmm2, ExternalAddress(LOG2_E)); //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL - movq(xmm4, Address(rsp, 8)); - pextrw(eax, xmm4, 3); - movl(edx, 8192); - movdl(xmm4, edx); - andl(eax, 32767); - subl(eax, 16); - jcc(Assembler::less, L_2TAG_PACKET_8_0_2); - movl(edx, eax); - andl(edx, 32752); - subl(edx, 16368); - movl(ecx, edx); - sarl(edx, 31); - addl(ecx, edx); - xorl(ecx, edx); - addl(ecx, 16); - bsrl(ecx, ecx); - movl(tmp1, 0); - jmp(L_2TAG_PACKET_1_0_2); - - bind(L_2TAG_PACKET_19_0_2); - xorpd(xmm0, xmm0); - movl(eax, 16368); - pinsrw(xmm0, eax, 3); - jmp(B1_5); - - bind(L_2TAG_PACKET_22_0_2); - xorpd(xmm0, xmm0); - jmp(B1_5); - - bind(L_2TAG_PACKET_11_0_2); - addl(eax, 384); - cmpl(eax, 0); - jcc(Assembler::less, L_2TAG_PACKET_38_0_2); - mulsd(xmm5, xmm1); - addsd(xmm0, xmm7); - shrl(tmp1, 31); - addpd(xmm3, xmm0); - pshufd(xmm0, xmm3, 238); - addsd(xmm3, xmm0); - lea(tmp4, ExternalAddress(log2)); //0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL, 0xbfe62e42UL - movq(xmm4, Address(tmp4, tmp1, Address::times_8, 0)); - mulsd(xmm1, xmm3); - xorpd(xmm0, xmm0); - movl(eax, 16368); - shll(tmp1, 15); - orl(eax, tmp1); - pinsrw(xmm0, eax, 3); - addsd(xmm5, xmm1); - mulsd(xmm5, xmm4); - addsd(xmm0, xmm5); - jmp(B1_5); - - bind(L_2TAG_PACKET_38_0_2); - - bind(L_2TAG_PACKET_37_0_2); - xorpd(xmm0, xmm0); - movl(eax, 16368); - pinsrw(xmm0, eax, 3); - jmp(B1_5); - - bind(L_2TAG_PACKET_39_0_2); - xorpd(xmm0, xmm0); - movl(eax, 16368); - pinsrw(xmm0, eax, 3); - movl(Address(rsp, 0), 26); - jmp(L_2TAG_PACKET_17_0_2); - - bind(L_2TAG_PACKET_9_0_2); - movq(xmm1, Address(rsp, 16)); - movdqu(xmm2, xmm1); - pextrw(eax, xmm1, 3); - andl(eax, 32752); - cmpl(eax, 32752); - jcc(Assembler::notEqual, L_2TAG_PACKET_40_0_2); - movdl(eax, xmm2); - psrlq(xmm2, 20); - movdl(edx, xmm2); - orl(eax, edx); - jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2); - - bind(L_2TAG_PACKET_40_0_2); - movdl(eax, xmm1); - psrlq(xmm1, 32); - movdl(edx, xmm1); - movl(ecx, edx); - addl(edx, edx); - orl(eax, edx); - jcc(Assembler::equal, L_2TAG_PACKET_39_0_2); - shrl(edx, 21); - cmpl(edx, 1075); - jcc(Assembler::above, L_2TAG_PACKET_41_0_2); - jcc(Assembler::equal, L_2TAG_PACKET_42_0_2); - cmpl(edx, 1023); - jcc(Assembler::below, L_2TAG_PACKET_41_0_2); - movq(xmm1, Address(rsp, 16)); - movl(eax, 17208); - xorpd(xmm3, xmm3); - pinsrw(xmm3, eax, 3); - movdqu(xmm4, xmm3); - addsd(xmm3, xmm1); - subsd(xmm4, xmm3); - addsd(xmm1, xmm4); - pextrw(eax, xmm1, 3); - andl(eax, 32752); - jcc(Assembler::notEqual, L_2TAG_PACKET_41_0_2); - movdl(eax, xmm3); - andl(eax, 1); - jcc(Assembler::equal, L_2TAG_PACKET_41_0_2); - - bind(L_2TAG_PACKET_43_0_2); - movq(xmm0, Address(rsp, 8)); - testl(ecx, INT_MIN); - jcc(Assembler::notEqual, L_2TAG_PACKET_44_0_2); - jmp(B1_5); - - bind(L_2TAG_PACKET_42_0_2); - movq(xmm1, Address(rsp, 16)); - movdl(eax, xmm1); - testl(eax, 1); - jcc(Assembler::notEqual, L_2TAG_PACKET_43_0_2); - - bind(L_2TAG_PACKET_41_0_2); - testl(ecx, INT_MIN); - jcc(Assembler::equal, L_2TAG_PACKET_22_0_2); - xorpd(xmm0, xmm0); - - bind(L_2TAG_PACKET_44_0_2); - movl(eax, 16368); - xorpd(xmm1, xmm1); - pinsrw(xmm1, eax, 3); - divsd(xmm1, xmm0); - movdqu(xmm0, xmm1); - movl(Address(rsp, 0), 27); - jmp(L_2TAG_PACKET_17_0_2); - - bind(L_2TAG_PACKET_12_0_2); - movq(xmm2, Address(rsp, 8)); - movq(xmm6, Address(rsp, 16)); - pextrw(eax, xmm2, 3); - pextrw(edx, xmm6, 3); - movl(ecx, 32752); - andl(ecx, edx); - cmpl(ecx, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_45_0_2); - andl(eax, 32752); - subl(eax, 16368); - xorl(edx, eax); - testl(edx, 32768); - jcc(Assembler::notEqual, L_2TAG_PACKET_46_0_2); - - bind(L_2TAG_PACKET_47_0_2); - movl(eax, 32736); - pinsrw(xmm0, eax, 3); - shrl(tmp1, 16); - orl(eax, tmp1); - pinsrw(xmm1, eax, 3); - mulsd(xmm0, xmm1); - - bind(L_2TAG_PACKET_14_0_2); - movl(Address(rsp, 0), 24); - jmp(L_2TAG_PACKET_17_0_2); - - bind(L_2TAG_PACKET_46_0_2); - movl(eax, 16); - pinsrw(xmm0, eax, 3); - mulsd(xmm0, xmm0); - testl(tmp1, INT_MIN); - jcc(Assembler::equal, L_2TAG_PACKET_48_0_2); - mov64(tmp2, 0x8000000000000000); - movdq(xmm2, tmp2); - xorpd(xmm0, xmm2); - - bind(L_2TAG_PACKET_48_0_2); - movl(Address(rsp, 0), 25); - jmp(L_2TAG_PACKET_17_0_2); - - bind(L_2TAG_PACKET_13_0_2); - pextrw(ecx, xmm5, 3); - pextrw(edx, xmm4, 3); - movl(eax, -1); - andl(ecx, 32752); - subl(ecx, 16368); - andl(edx, 32752); - addl(edx, ecx); - movl(ecx, -31); - sarl(edx, 4); - subl(ecx, edx); - jcc(Assembler::lessEqual, L_2TAG_PACKET_49_0_2); - cmpl(ecx, 20); - jcc(Assembler::above, L_2TAG_PACKET_50_0_2); - shll(eax); - - bind(L_2TAG_PACKET_49_0_2); - movdl(xmm0, eax); - psllq(xmm0, 32); - pand(xmm0, xmm5); - subsd(xmm5, xmm0); - addsd(xmm5, xmm1); - mulsd(xmm0, xmm4); - mulsd(xmm5, xmm4); - addsd(xmm0, xmm5); - - bind(L_2TAG_PACKET_50_0_2); - jmp(L_2TAG_PACKET_48_0_2); - - bind(L_2TAG_PACKET_2_0_2); - movw(ecx, Address(rsp, 22)); - movl(edx, INT_MIN); - movdl(xmm1, rdx); - xorpd(xmm7, xmm7); - paddd(xmm0, xmm4); - movdl(edx, xmm0); - psllq(xmm0, 29); - paddq(xmm1, xmm3); - pand(xmm5, xmm1); - andl(ecx, 32752); - cmpl(ecx, 16560); - jcc(Assembler::less, L_2TAG_PACKET_3_0_2); - pand(xmm0, xmm6); - subsd(xmm3, xmm5); - addl(eax, 16351); - shrl(eax, 4); - subl(eax, 1022); - cvtsi2sdl(xmm7, eax); - mulpd(xmm5, xmm0); - lea(r11, ExternalAddress(L_tbl)); - movq(xmm4, ExternalAddress(coeff_h)); //0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL - mulsd(xmm3, xmm0); - movq(xmm6, ExternalAddress(coeff_h)); //0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL - subsd(xmm5, xmm2); - movq(xmm1, ExternalAddress(8 + coeff_h)); //0x00000000UL, 0xbf5dabe1UL - pshufd(xmm2, xmm3, 68); - unpcklpd(xmm5, xmm3); - addsd(xmm3, xmm5); - movq(xmm0, ExternalAddress(8 + coeff_h)); //0x00000000UL, 0xbf5dabe1UL - andl(edx, 16760832); - shrl(edx, 10); - addpd(xmm7, Address(tmp4, edx, Address::times_1, -3648)); - mulsd(xmm4, xmm5); - mulsd(xmm0, xmm5); - mulsd(xmm6, xmm2); - mulsd(xmm1, xmm2); - movdqu(xmm2, xmm5); - mulsd(xmm4, xmm5); - addsd(xmm5, xmm0); - movdqu(xmm0, xmm7); - addsd(xmm2, xmm3); - addsd(xmm7, xmm5); - mulsd(xmm6, xmm2); - subsd(xmm0, xmm7); - movdqu(xmm2, xmm7); - addsd(xmm7, xmm4); - addsd(xmm0, xmm5); - subsd(xmm2, xmm7); - addsd(xmm4, xmm2); - pshufd(xmm2, xmm5, 238); - movdqu(xmm5, xmm7); - addsd(xmm7, xmm2); - addsd(xmm4, xmm0); - movdqu(xmm0, ExternalAddress(coeff)); //0x6dc96112UL, 0xbf836578UL, 0xee241472UL, 0xbf9b0301UL - subsd(xmm5, xmm7); - addsd(xmm6, xmm4); - movdqu(xmm4, xmm7); - addsd(xmm5, xmm2); - addsd(xmm7, xmm1); - movdqu(xmm2, ExternalAddress(64 + coeff)); //0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, 0xbf5dabe1UL - subsd(xmm4, xmm7); - addsd(xmm6, xmm5); - addsd(xmm4, xmm1); - pshufd(xmm5, xmm7, 238); - movapd(xmm1, xmm7); - addsd(xmm7, xmm5); - subsd(xmm1, xmm7); - addsd(xmm1, xmm5); - movdqu(xmm5, ExternalAddress(80 + coeff)); //0x9f95985aUL, 0xbfb528dbUL, 0xf8b5787dUL, 0x3ef2531eUL - pshufd(xmm3, xmm3, 68); - addsd(xmm6, xmm4); - addsd(xmm6, xmm1); - movdqu(xmm1, ExternalAddress(32 + coeff)); //0x9f95985aUL, 0xbfb528dbUL, 0xb3841d2aUL, 0xbfd619b6UL - mulpd(xmm0, xmm3); - mulpd(xmm2, xmm3); - pshufd(xmm4, xmm3, 68); - mulpd(xmm3, xmm3); - addpd(xmm0, xmm1); - addpd(xmm5, xmm2); - mulsd(xmm4, xmm3); - movq(xmm2, ExternalAddress(HIGHMASK_LOG_X)); //0xf8000000UL, 0xffffffffUL, 0x00000000UL, 0xfffff800UL - mulpd(xmm3, xmm3); - movq(xmm1, Address(rsp, 16)); - movw(ecx, Address(rsp, 22)); - mulpd(xmm0, xmm4); - pextrw(eax, xmm7, 3); - mulpd(xmm5, xmm4); - mulpd(xmm0, xmm3); - movq(xmm4, ExternalAddress(8 + HIGHMASK_Y)); //0x00000000UL, 0xffffffffUL - pand(xmm2, xmm7); - addsd(xmm5, xmm6); - subsd(xmm7, xmm2); - addpd(xmm5, xmm0); - andl(eax, 32752); - subl(eax, 16368); - andl(ecx, 32752); - cmpl(ecx, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_45_0_2); - addl(ecx, eax); - cmpl(ecx, 16576); - jcc(Assembler::aboveEqual, L_2TAG_PACKET_51_0_2); - pshufd(xmm0, xmm5, 238); - pand(xmm4, xmm1); - movdqu(xmm3, xmm1); - addsd(xmm5, xmm0); - subsd(xmm1, xmm4); - xorpd(xmm6, xmm6); - movl(edx, 17080); - pinsrw(xmm6, edx, 3); - addsd(xmm7, xmm5); - mulsd(xmm4, xmm2); - mulsd(xmm1, xmm2); - movdqu(xmm5, xmm6); - mulsd(xmm3, xmm7); - addsd(xmm6, xmm4); - addsd(xmm1, xmm3); - movdqu(xmm7, ExternalAddress(e_coeff)); //0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL - movdl(edx, xmm6); - subsd(xmm6, xmm5); - lea(tmp4, ExternalAddress(T_exp)); - movdqu(xmm3, ExternalAddress(16 + e_coeff)); //0x6fba4e77UL, 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL - movq(xmm2, ExternalAddress(32 + e_coeff)); //0xfefa39efUL, 0x3fe62e42UL, 0x00000000UL, 0x00000000UL - subsd(xmm4, xmm6); - movl(ecx, edx); - andl(edx, 255); - addl(edx, edx); - movdqu(xmm5, Address(tmp4, edx, Address::times_8, 0)); - addsd(xmm4, xmm1); - pextrw(edx, xmm6, 3); - shrl(ecx, 8); - movl(eax, ecx); - shrl(ecx, 1); - subl(eax, ecx); - shll(ecx, 20); - movdl(xmm6, ecx); - pshufd(xmm0, xmm4, 68); - pshufd(xmm1, xmm4, 68); - mulpd(xmm0, xmm0); - mulpd(xmm7, xmm1); - pshufd(xmm6, xmm6, 17); - mulsd(xmm2, xmm4); - andl(edx, 32767); - cmpl(edx, 16529); - jcc(Assembler::above, L_2TAG_PACKET_12_0_2); - mulsd(xmm0, xmm0); - paddd(xmm5, xmm6); - addpd(xmm3, xmm7); - mulsd(xmm2, xmm5); - pshufd(xmm6, xmm5, 238); - mulpd(xmm0, xmm3); - addsd(xmm2, xmm6); - pshufd(xmm3, xmm0, 238); - addl(eax, 1023); - shll(eax, 20); - orl(eax, tmp1); - movdl(xmm4, eax); - mulsd(xmm0, xmm5); - mulsd(xmm3, xmm5); - addsd(xmm0, xmm2); - psllq(xmm4, 32); - addsd(xmm0, xmm3); - movdqu(xmm1, xmm0); - addsd(xmm0, xmm5); - mulsd(xmm0, xmm4); - pextrw(eax, xmm0, 3); - andl(eax, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_13_0_2); - cmpl(eax, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_14_0_2); - - bind(L_2TAG_PACKET_52_0_2); - jmp(B1_5); - - bind(L_2TAG_PACKET_45_0_2); - movq(xmm0, Address(rsp, 8)); - xorpd(xmm2, xmm2); - movl(eax, 49136); - pinsrw(xmm2, eax, 3); - addsd(xmm2, xmm0); - pextrw(eax, xmm2, 3); - cmpl(eax, 0); - jcc(Assembler::notEqual, L_2TAG_PACKET_53_0_2); - xorpd(xmm0, xmm0); - movl(eax, 32760); - pinsrw(xmm0, eax, 3); - jmp(B1_5); - - bind(L_2TAG_PACKET_53_0_2); - movq(xmm1, Address(rsp, 16)); - movdl(edx, xmm1); - movdqu(xmm3, xmm1); - psrlq(xmm3, 20); - movdl(ecx, xmm3); - orl(ecx, edx); - jcc(Assembler::equal, L_2TAG_PACKET_54_0_2); - addsd(xmm1, xmm1); - movdqu(xmm0, xmm1); - jmp(B1_5); - - bind(L_2TAG_PACKET_51_0_2); - pextrw(eax, xmm1, 3); - pextrw(ecx, xmm2, 3); - xorl(eax, ecx); - testl(eax, 32768); - jcc(Assembler::equal, L_2TAG_PACKET_47_0_2); - jmp(L_2TAG_PACKET_46_0_2); - - bind(L_2TAG_PACKET_54_0_2); - pextrw(eax, xmm0, 3); - andl(eax, 32752); - pextrw(edx, xmm1, 3); - xorpd(xmm0, xmm0); - subl(eax, 16368); - xorl(eax, edx); - testl(eax, 32768); - jcc(Assembler::equal, L_2TAG_PACKET_55_0_2); - jmp(B1_5); - - bind(L_2TAG_PACKET_55_0_2); - movl(edx, 32752); - pinsrw(xmm0, edx, 3); - jmp(B1_5); - - bind(L_2TAG_PACKET_17_0_2); - movq(Address(rsp, 24), xmm0); - - bind(B1_3); - movq(xmm0, Address(rsp, 24)); - - bind(L_2TAG_PACKET_56_0_2); - - bind(B1_5); - addq(rsp, 40); -} - -/******************************************************************************/ -// ALGORITHM DESCRIPTION - SIN() -// --------------------- -// -// 1. RANGE REDUCTION -// -// We perform an initial range reduction from X to r with -// -// X =~= N * pi/32 + r -// -// so that |r| <= pi/64 + epsilon. We restrict inputs to those -// where |N| <= 932560. Beyond this, the range reduction is -// insufficiently accurate. For extremely small inputs, -// denormalization can occur internally, impacting performance. -// This means that the main path is actually only taken for -// 2^-252 <= |X| < 90112. -// -// To avoid branches, we perform the range reduction to full -// accuracy each time. -// -// X - N * (P_1 + P_2 + P_3) -// -// where P_1 and P_2 are 32-bit numbers (so multiplication by N -// is exact) and P_3 is a 53-bit number. Together, these -// approximate pi well enough for all cases in the restricted -// range. -// -// The main reduction sequence is: -// -// y = 32/pi * x -// N = integer(y) -// (computed by adding and subtracting off SHIFTER) -// -// m_1 = N * P_1 -// m_2 = N * P_2 -// r_1 = x - m_1 -// r = r_1 - m_2 -// (this r can be used for most of the calculation) -// -// c_1 = r_1 - r -// m_3 = N * P_3 -// c_2 = c_1 - m_2 -// c = c_2 - m_3 -// -// 2. MAIN ALGORITHM -// -// The algorithm uses a table lookup based on B = M * pi / 32 -// where M = N mod 64. The stored values are: -// sigma closest power of 2 to cos(B) -// C_hl 53-bit cos(B) - sigma -// S_hi + S_lo 2 * 53-bit sin(B) -// -// The computation is organized as follows: -// -// sin(B + r + c) = [sin(B) + sigma * r] + -// r * (cos(B) - sigma) + -// sin(B) * [cos(r + c) - 1] + -// cos(B) * [sin(r + c) - r] -// -// which is approximately: -// -// [S_hi + sigma * r] + -// C_hl * r + -// S_lo + S_hi * [(cos(r) - 1) - r * c] + -// (C_hl + sigma) * [(sin(r) - r) + c] -// -// and this is what is actually computed. We separate this sum -// into four parts: -// -// hi + med + pols + corr -// -// where -// -// hi = S_hi + sigma r -// med = C_hl * r -// pols = S_hi * (cos(r) - 1) + (C_hl + sigma) * (sin(r) - r) -// corr = S_lo + c * ((C_hl + sigma) - S_hi * r) -// -// 3. POLYNOMIAL -// -// The polynomial S_hi * (cos(r) - 1) + (C_hl + sigma) * -// (sin(r) - r) can be rearranged freely, since it is quite -// small, so we exploit parallelism to the fullest. -// -// psc4 = SC_4 * r_1 -// msc4 = psc4 * r -// r2 = r * r -// msc2 = SC_2 * r2 -// r4 = r2 * r2 -// psc3 = SC_3 + msc4 -// psc1 = SC_1 + msc2 -// msc3 = r4 * psc3 -// sincospols = psc1 + msc3 -// pols = sincospols * -// -// -// 4. CORRECTION TERM -// -// This is where the "c" component of the range reduction is -// taken into account; recall that just "r" is used for most of -// the calculation. -// -// -c = m_3 - c_2 -// -d = S_hi * r - (C_hl + sigma) -// corr = -c * -d + S_lo -// -// 5. COMPENSATED SUMMATIONS -// -// The two successive compensated summations add up the high -// and medium parts, leaving just the low parts to add up at -// the end. -// -// rs = sigma * r -// res_int = S_hi + rs -// k_0 = S_hi - res_int -// k_2 = k_0 + rs -// med = C_hl * r -// res_hi = res_int + med -// k_1 = res_int - res_hi -// k_3 = k_1 + med -// -// 6. FINAL SUMMATION -// -// We now add up all the small parts: -// -// res_lo = pols(hi) + pols(lo) + corr + k_1 + k_3 -// -// Now the overall result is just: -// -// res_hi + res_lo -// -// 7. SMALL ARGUMENTS -// -// If |x| < SNN (SNN meaning the smallest normal number), we -// simply perform 0.1111111 cdots 1111 * x. For SNN <= |x|, we -// do 2^-55 * (2^55 * x - x). -// -// Special cases: -// sin(NaN) = quiet NaN, and raise invalid exception -// sin(INF) = NaN and raise invalid exception -// sin(+/-0) = +/-0 -// -/******************************************************************************/ - -ALIGNED_(16) juint _ONEHALF[] = -{ - 0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL -}; - -ALIGNED_(16) juint _P_2[] = -{ - 0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL -}; - -ALIGNED_(16) juint _SC_4[] = -{ - 0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL -}; - -ALIGNED_(16) juint _Ctable[] = -{ - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, 0xbf73b92eUL, - 0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL, - 0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, - 0xc0000000UL, 0xbc626d19UL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, - 0xbfa60beaUL, 0x2ed59f06UL, 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, - 0x00000000UL, 0x3ff00000UL, 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, - 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, 0x00000000UL, 0x3ff00000UL, - 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, 0x20000000UL, - 0x3c5e0d89UL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, 0xbfc59267UL, - 0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL, - 0x3ff00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, - 0x20000000UL, 0x3c68076aUL, 0x00000000UL, 0x3ff00000UL, 0x99fcef32UL, - 0x3fca8279UL, 0x667f3bcdUL, 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, - 0x00000000UL, 0x3fe00000UL, 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, - 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, 0x00000000UL, 0x3fe00000UL, - 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, 0xe0000000UL, - 0x3c39f630UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, 0xbf9d4a2cUL, - 0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL, - 0x3fe00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0x3fed906bUL, - 0x20000000UL, 0x3c7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x76acf82dUL, - 0x3fa4a031UL, 0x56c62ddaUL, 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, - 0x00000000UL, 0x3fd00000UL, 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, - 0x3fef6297UL, 0x20000000UL, 0x3c756217UL, 0x00000000UL, 0x3fd00000UL, - 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, 0x40000000UL, - 0xbc887df6UL, 0x00000000UL, 0x3fc00000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, - 0x40000000UL, 0xbc887df6UL, 0x00000000UL, 0xbfc00000UL, 0x0e5967d5UL, - 0x3fac1d1fUL, 0xcff75cb0UL, 0x3fef6297UL, 0x20000000UL, 0x3c756217UL, - 0x00000000UL, 0xbfd00000UL, 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, - 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, 0x00000000UL, 0xbfd00000UL, - 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, 0x3fed906bUL, 0x20000000UL, - 0x3c7457e6UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, 0x3f9d4a2cUL, - 0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL, - 0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, - 0xe0000000UL, 0x3c39f630UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, - 0xbfc133ccUL, 0x6b151741UL, 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, - 0x00000000UL, 0xbfe00000UL, 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, - 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, 0x00000000UL, 0xbfe00000UL, - 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, 0x20000000UL, - 0x3c68076aUL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, 0x3fc59267UL, - 0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL, - 0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, - 0x20000000UL, 0x3c5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, - 0x3fb37ca1UL, 0xa6aea963UL, 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, - 0x00000000UL, 0xbff00000UL, 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, - 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, 0x00000000UL, 0xbff00000UL, - 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, 0xc0000000UL, - 0xbc626d19UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, 0x3f73b92eUL, - 0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL, - 0xbff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, - 0x3f73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL, - 0x00000000UL, 0xbff00000UL, 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, - 0xbfc8f8b8UL, 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0xbff00000UL, - 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, - 0x3c75d28dUL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, 0x3fb37ca1UL, - 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, 0x3c672cedUL, 0x00000000UL, - 0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0xbfde2b5dUL, - 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, - 0x3fc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL, - 0x00000000UL, 0xbff00000UL, 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, - 0xbfe44cf3UL, 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0xbff00000UL, - 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, - 0x3c8bdd34UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, 0xbfc133ccUL, - 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, 0x3c82c5e1UL, 0x00000000UL, - 0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0xbfea9b66UL, - 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, - 0x3f9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL, - 0x00000000UL, 0xbfe00000UL, 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, - 0xbfed906bUL, 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0xbfe00000UL, - 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, - 0xbc8760b1UL, 0x00000000UL, 0xbfd00000UL, 0x0e5967d5UL, 0x3fac1d1fUL, - 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, 0xbc756217UL, 0x00000000UL, - 0xbfd00000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0xbfefd88dUL, - 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0xbfc00000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x00000000UL, 0x00000000UL, - 0x00000000UL, 0x00000000UL, 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, - 0xbfefd88dUL, 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0x3fc00000UL, - 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, - 0xbc756217UL, 0x00000000UL, 0x3fd00000UL, 0x76acf82dUL, 0x3fa4a031UL, - 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, 0xbc8760b1UL, 0x00000000UL, - 0x3fd00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0xbfed906bUL, - 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, - 0xbf9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL, - 0x00000000UL, 0x3fe00000UL, 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, - 0xbfea9b66UL, 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0x3fe00000UL, - 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, - 0x3c82c5e1UL, 0x00000000UL, 0x3fe00000UL, 0x99fcef32UL, 0x3fca8279UL, - 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, 0x3c8bdd34UL, 0x00000000UL, - 0x3fe00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0xbfe44cf3UL, - 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, - 0xbfc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL, - 0x00000000UL, 0x3ff00000UL, 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, - 0xbfde2b5dUL, 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0x3ff00000UL, - 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, - 0x3c672cedUL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, 0xbfa60beaUL, - 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, 0x3c75d28dUL, 0x00000000UL, - 0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0xbfc8f8b8UL, - 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, - 0xbf73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL, - 0x00000000UL, 0x3ff00000UL -}; - -ALIGNED_(16) juint _SC_2[] = -{ - 0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL -}; - -ALIGNED_(16) juint _SC_3[] = -{ - 0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL -}; - -ALIGNED_(16) juint _SC_1[] = -{ - 0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL -}; - -ALIGNED_(16) juint _PI_INV_TABLE[] = -{ - 0x00000000UL, 0x00000000UL, 0xa2f9836eUL, 0x4e441529UL, 0xfc2757d1UL, - 0xf534ddc0UL, 0xdb629599UL, 0x3c439041UL, 0xfe5163abUL, 0xdebbc561UL, - 0xb7246e3aUL, 0x424dd2e0UL, 0x06492eeaUL, 0x09d1921cUL, 0xfe1deb1cUL, - 0xb129a73eUL, 0xe88235f5UL, 0x2ebb4484UL, 0xe99c7026UL, 0xb45f7e41UL, - 0x3991d639UL, 0x835339f4UL, 0x9c845f8bUL, 0xbdf9283bUL, 0x1ff897ffUL, - 0xde05980fUL, 0xef2f118bUL, 0x5a0a6d1fUL, 0x6d367ecfUL, 0x27cb09b7UL, - 0x4f463f66UL, 0x9e5fea2dUL, 0x7527bac7UL, 0xebe5f17bUL, 0x3d0739f7UL, - 0x8a5292eaUL, 0x6bfb5fb1UL, 0x1f8d5d08UL, 0x56033046UL, 0xfc7b6babUL, - 0xf0cfbc21UL -}; - -ALIGNED_(8) juint _PI_4[] = -{ - 0x40000000UL, 0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL -}; - -ALIGNED_(8) juint _PI32INV[] = -{ - 0x6dc9c883UL, 0x40245f30UL -}; - -ALIGNED_(8) juint _SHIFTER[] = -{ - 0x00000000UL, 0x43380000UL -}; - -ALIGNED_(8) juint _SIGN_MASK[] = -{ - 0x00000000UL, 0x80000000UL -}; - -ALIGNED_(8) juint _P_3[] = -{ - 0x2e037073UL, 0x3b63198aUL -}; - -ALIGNED_(8) juint _ALL_ONES[] = -{ - 0xffffffffUL, 0x3fefffffUL -}; - -ALIGNED_(8) juint _TWO_POW_55[] = -{ - 0x00000000UL, 0x43600000UL -}; - -ALIGNED_(8) juint _TWO_POW_M55[] = -{ - 0x00000000UL, 0x3c800000ULL -}; - -ALIGNED_(8) juint _P_1[] = -{ - 0x54400000UL, 0x3fb921fbUL -}; - -ALIGNED_(8) juint _NEG_ZERO[] = -{ - 0x00000000UL, 0x80000000UL -}; - -void MacroAssembler::fast_sin(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ebx, Register ecx, Register edx, Register tmp1, Register tmp2, Register tmp3, Register tmp4) { - Label L_2TAG_PACKET_0_0_1, L_2TAG_PACKET_1_0_1, L_2TAG_PACKET_2_0_1, L_2TAG_PACKET_3_0_1; - Label L_2TAG_PACKET_4_0_1, L_2TAG_PACKET_5_0_1, L_2TAG_PACKET_6_0_1, L_2TAG_PACKET_7_0_1; - Label L_2TAG_PACKET_8_0_1, L_2TAG_PACKET_9_0_1, L_2TAG_PACKET_10_0_1, L_2TAG_PACKET_11_0_1; - Label L_2TAG_PACKET_13_0_1, L_2TAG_PACKET_14_0_1; - Label L_2TAG_PACKET_12_0_1, B1_1, B1_2, B1_4, start; - - assert_different_registers(tmp1, tmp2, tmp3, tmp4, eax, ebx, ecx, edx); - address ONEHALF = (address)_ONEHALF; - address P_2 = (address)_P_2; - address SC_4 = (address)_SC_4; - address Ctable = (address)_Ctable; - address SC_2 = (address)_SC_2; - address SC_3 = (address)_SC_3; - address SC_1 = (address)_SC_1; - address PI_INV_TABLE = (address)_PI_INV_TABLE; - address PI_4 = (address)_PI_4; - address PI32INV = (address)_PI32INV; - address SHIFTER = (address)_SHIFTER; - address SIGN_MASK = (address)_SIGN_MASK; - address P_3 = (address)_P_3; - address ALL_ONES = (address)_ALL_ONES; - address TWO_POW_55 = (address)_TWO_POW_55; - address TWO_POW_M55 = (address)_TWO_POW_M55; - address P_1 = (address)_P_1; - address NEG_ZERO = (address)_NEG_ZERO; - - bind(start); - push(rbx); - subq(rsp, 16); - movsd(Address(rsp, 8), xmm0); - movl(eax, Address(rsp, 12)); - movq(xmm1, ExternalAddress(PI32INV)); //0x6dc9c883UL, 0x40245f30UL - movq(xmm2, ExternalAddress(SHIFTER)); //0x00000000UL, 0x43380000UL - andl(eax, 2147418112); - subl(eax, 808452096); - cmpl(eax, 281346048); - jcc(Assembler::above, L_2TAG_PACKET_0_0_1); - mulsd(xmm1, xmm0); - movdqu(xmm5, ExternalAddress(ONEHALF)); //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL - movq(xmm4, ExternalAddress(SIGN_MASK)); //0x00000000UL, 0x80000000UL - pand(xmm4, xmm0); - por(xmm5, xmm4); - addpd(xmm1, xmm5); - cvttsd2sil(edx, xmm1); - cvtsi2sdl(xmm1, edx); - movdqu(xmm6, ExternalAddress(P_2)); //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL - mov64(r8, 0x3fb921fb54400000); - movdq(xmm3, r8); - movdqu(xmm5, ExternalAddress(SC_4)); //0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL - pshufd(xmm4, xmm0, 68); - mulsd(xmm3, xmm1); - movddup(xmm1, xmm1); - andl(edx, 63); - shll(edx, 5); - lea(rax, ExternalAddress(Ctable)); - addq(rax, rdx); - mulpd(xmm6, xmm1); - mulsd(xmm1, ExternalAddress(P_3)); //0x2e037073UL, 0x3b63198aUL - subsd(xmm4, xmm3); - movq(xmm7, Address(rax, 8)); - subsd(xmm0, xmm3); - movddup(xmm3, xmm4); - subsd(xmm4, xmm6); - pshufd(xmm0, xmm0, 68); - movdqu(xmm2, Address(rax, 0)); - mulpd(xmm5, xmm0); - subpd(xmm0, xmm6); - mulsd(xmm7, xmm4); - subsd(xmm3, xmm4); - mulpd(xmm5, xmm0); - mulpd(xmm0, xmm0); - subsd(xmm3, xmm6); - movdqu(xmm6, ExternalAddress(SC_2)); //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL - subsd(xmm1, xmm3); - movq(xmm3, Address(rax, 24)); - addsd(xmm2, xmm3); - subsd(xmm7, xmm2); - mulsd(xmm2, xmm4); - mulpd(xmm6, xmm0); - mulsd(xmm3, xmm4); - mulpd(xmm2, xmm0); - mulpd(xmm0, xmm0); - addpd(xmm5, ExternalAddress(SC_3)); //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL - mulsd(xmm4, Address(rax, 0)); - addpd(xmm6, ExternalAddress(SC_1)); //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL - mulpd(xmm5, xmm0); - movdqu(xmm0, xmm3); - addsd(xmm3, Address(rax, 8)); - mulpd(xmm1, xmm7); - movdqu(xmm7, xmm4); - addsd(xmm4, xmm3); - addpd(xmm6, xmm5); - movq(xmm5, Address(rax, 8)); - subsd(xmm5, xmm3); - subsd(xmm3, xmm4); - addsd(xmm1, Address(rax, 16)); - mulpd(xmm6, xmm2); - addsd(xmm5, xmm0); - addsd(xmm3, xmm7); - addsd(xmm1, xmm5); - addsd(xmm1, xmm3); - addsd(xmm1, xmm6); - unpckhpd(xmm6, xmm6); - movdqu(xmm0, xmm4); - addsd(xmm1, xmm6); - addsd(xmm0, xmm1); - jmp(B1_4); - - bind(L_2TAG_PACKET_0_0_1); - jcc(Assembler::greater, L_2TAG_PACKET_1_0_1); - shrl(eax, 20); - cmpl(eax, 3325); - jcc(Assembler::notEqual, L_2TAG_PACKET_2_0_1); - mulsd(xmm0, ExternalAddress(ALL_ONES)); //0xffffffffUL, 0x3fefffffUL - jmp(B1_4); - - bind(L_2TAG_PACKET_2_0_1); - movq(xmm3, ExternalAddress(TWO_POW_55)); //0x00000000UL, 0x43600000UL - mulsd(xmm3, xmm0); - subsd(xmm3, xmm0); - mulsd(xmm3, ExternalAddress(TWO_POW_M55)); //0x00000000UL, 0x3c800000UL - jmp(B1_4); - - bind(L_2TAG_PACKET_1_0_1); - pextrw(eax, xmm0, 3); - andl(eax, 32752); - cmpl(eax, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_3_0_1); - pextrw(ecx, xmm0, 3); - andl(ecx, 32752); - subl(ecx, 16224); - shrl(ecx, 7); - andl(ecx, 65532); - lea(r11, ExternalAddress(PI_INV_TABLE)); - addq(rcx, r11); - movdq(rax, xmm0); - movl(r10, Address(rcx, 20)); - movl(r8, Address(rcx, 24)); - movl(edx, eax); - shrq(rax, 21); - orl(eax, INT_MIN); - shrl(eax, 11); - movl(r9, r10); - imulq(r10, rdx); - imulq(r9, rax); - imulq(r8, rax); - movl(rsi, Address(rcx, 16)); - movl(rdi, Address(rcx, 12)); - movl(r11, r10); - shrq(r10, 32); - addq(r9, r10); - addq(r11, r8); - movl(r8, r11); - shrq(r11, 32); - addq(r9, r11); - movl(r10, rsi); - imulq(rsi, rdx); - imulq(r10, rax); - movl(r11, rdi); - imulq(rdi, rdx); - movl(ebx, rsi); - shrq(rsi, 32); - addq(r9, rbx); - movl(ebx, r9); - shrq(r9, 32); - addq(r10, rsi); - addq(r10, r9); - shlq(rbx, 32); - orq(r8, rbx); - imulq(r11, rax); - movl(r9, Address(rcx, 8)); - movl(rsi, Address(rcx, 4)); - movl(ebx, rdi); - shrq(rdi, 32); - addq(r10, rbx); - movl(ebx, r10); - shrq(r10, 32); - addq(r11, rdi); - addq(r11, r10); - movq(rdi, r9); - imulq(r9, rdx); - imulq(rdi, rax); - movl(r10, r9); - shrq(r9, 32); - addq(r11, r10); - movl(r10, r11); - shrq(r11, 32); - addq(rdi, r9); - addq(rdi, r11); - movq(r9, rsi); - imulq(rsi, rdx); - imulq(r9, rax); - shlq(r10, 32); - orq(r10, rbx); - movl(eax, Address(rcx, 0)); - movl(r11, rsi); - shrq(rsi, 32); - addq(rdi, r11); - movl(r11, rdi); - shrq(rdi, 32); - addq(r9, rsi); - addq(r9, rdi); - imulq(rdx, rax); - pextrw(ebx, xmm0, 3); - lea(rdi, ExternalAddress(PI_INV_TABLE)); - subq(rcx, rdi); - addl(ecx, ecx); - addl(ecx, ecx); - addl(ecx, ecx); - addl(ecx, 19); - movl(rsi, 32768); - andl(rsi, ebx); - shrl(ebx, 4); - andl(ebx, 2047); - subl(ebx, 1023); - subl(ecx, ebx); - addq(r9, rdx); - movl(edx, ecx); - addl(edx, 32); - cmpl(ecx, 1); - jcc(Assembler::less, L_2TAG_PACKET_4_0_1); - negl(ecx); - addl(ecx, 29); - shll(r9); - movl(rdi, r9); - andl(r9, 536870911); - testl(r9, 268435456); - jcc(Assembler::notEqual, L_2TAG_PACKET_5_0_1); - shrl(r9); - movl(ebx, 0); - shlq(r9, 32); - orq(r9, r11); - - bind(L_2TAG_PACKET_6_0_1); - - bind(L_2TAG_PACKET_7_0_1); - - cmpq(r9, 0); - jcc(Assembler::equal, L_2TAG_PACKET_8_0_1); - - bind(L_2TAG_PACKET_9_0_1); - bsrq(r11, r9); - movl(ecx, 29); - subl(ecx, r11); - jcc(Assembler::lessEqual, L_2TAG_PACKET_10_0_1); - shlq(r9); - movq(rax, r10); - shlq(r10); - addl(edx, ecx); - negl(ecx); - addl(ecx, 64); - shrq(rax); - shrq(r8); - orq(r9, rax); - orq(r10, r8); - - bind(L_2TAG_PACKET_11_0_1); - cvtsi2sdq(xmm0, r9); - shrq(r10, 1); - cvtsi2sdq(xmm3, r10); - xorpd(xmm4, xmm4); - shll(edx, 4); - negl(edx); - addl(edx, 16368); - orl(edx, rsi); - xorl(edx, ebx); - pinsrw(xmm4, edx, 3); - movq(xmm2, ExternalAddress(PI_4)); //0x40000000UL, 0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL - movq(xmm6, ExternalAddress(8 + PI_4)); //0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL - xorpd(xmm5, xmm5); - subl(edx, 1008); - pinsrw(xmm5, edx, 3); - mulsd(xmm0, xmm4); - shll(rsi, 16); - sarl(rsi, 31); - mulsd(xmm3, xmm5); - movdqu(xmm1, xmm0); - mulsd(xmm0, xmm2); - shrl(rdi, 29); - addsd(xmm1, xmm3); - mulsd(xmm3, xmm2); - addl(rdi, rsi); - xorl(rdi, rsi); - mulsd(xmm6, xmm1); - movl(eax, rdi); - addsd(xmm6, xmm3); - movdqu(xmm2, xmm0); - addsd(xmm0, xmm6); - subsd(xmm2, xmm0); - addsd(xmm6, xmm2); - - bind(L_2TAG_PACKET_12_0_1); - movq(xmm1, ExternalAddress(PI32INV)); //0x6dc9c883UL, 0x40245f30UL - mulsd(xmm1, xmm0); - movq(xmm5, ExternalAddress(ONEHALF)); //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL - movq(xmm4, ExternalAddress(SIGN_MASK)); //0x00000000UL, 0x80000000UL - pand(xmm4, xmm0); - por(xmm5, xmm4); - addpd(xmm1, xmm5); - cvttsd2sil(edx, xmm1); - cvtsi2sdl(xmm1, edx); - movq(xmm3, ExternalAddress(P_1)); //0x54400000UL, 0x3fb921fbUL - movdqu(xmm2, ExternalAddress(P_2)); //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL - mulsd(xmm3, xmm1); - unpcklpd(xmm1, xmm1); - shll(eax, 3); - addl(edx, 1865216); - movdqu(xmm4, xmm0); - addl(edx, eax); - andl(edx, 63); - movdqu(xmm5, ExternalAddress(SC_4)); //0x54400000UL, 0x3fb921fbUL - lea(rax, ExternalAddress(Ctable)); - shll(edx, 5); - addq(rax, rdx); - mulpd(xmm2, xmm1); - subsd(xmm0, xmm3); - mulsd(xmm1, ExternalAddress(P_3)); //0x2e037073UL, 0x3b63198aUL - subsd(xmm4, xmm3); - movq(xmm7, Address(rax, 8)); - unpcklpd(xmm0, xmm0); - movdqu(xmm3, xmm4); - subsd(xmm4, xmm2); - mulpd(xmm5, xmm0); - subpd(xmm0, xmm2); - mulsd(xmm7, xmm4); - subsd(xmm3, xmm4); - mulpd(xmm5, xmm0); - mulpd(xmm0, xmm0); - subsd(xmm3, xmm2); - movdqu(xmm2, Address(rax, 0)); - subsd(xmm1, xmm3); - movq(xmm3, Address(rax, 24)); - addsd(xmm2, xmm3); - subsd(xmm7, xmm2); - subsd(xmm1, xmm6); - movdqu(xmm6, ExternalAddress(SC_2)); //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL - mulsd(xmm2, xmm4); - mulpd(xmm6, xmm0); - mulsd(xmm3, xmm4); - mulpd(xmm2, xmm0); - mulpd(xmm0, xmm0); - addpd(xmm5, ExternalAddress(SC_3)); //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL - mulsd(xmm4, Address(rax, 0)); - addpd(xmm6, ExternalAddress(SC_1)); //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL - mulpd(xmm5, xmm0); - movdqu(xmm0, xmm3); - addsd(xmm3, Address(rax, 8)); - mulpd(xmm1, xmm7); - movdqu(xmm7, xmm4); - addsd(xmm4, xmm3); - addpd(xmm6, xmm5); - movq(xmm5, Address(rax, 8)); - subsd(xmm5, xmm3); - subsd(xmm3, xmm4); - addsd(xmm1, Address(rax, 16)); - mulpd(xmm6, xmm2); - addsd(xmm5, xmm0); - addsd(xmm3, xmm7); - addsd(xmm1, xmm5); - addsd(xmm1, xmm3); - addsd(xmm1, xmm6); - unpckhpd(xmm6, xmm6); - movdqu(xmm0, xmm4); - addsd(xmm1, xmm6); - addsd(xmm0, xmm1); - jmp(B1_4); - - bind(L_2TAG_PACKET_8_0_1); - addl(edx, 64); - movq(r9, r10); - movq(r10, r8); - movl(r8, 0); - cmpq(r9, 0); - jcc(Assembler::notEqual, L_2TAG_PACKET_9_0_1); - addl(edx, 64); - movq(r9, r10); - movq(r10, r8); - cmpq(r9, 0); - jcc(Assembler::notEqual, L_2TAG_PACKET_9_0_1); - xorpd(xmm0, xmm0); - xorpd(xmm6, xmm6); - jmp(L_2TAG_PACKET_12_0_1); - - bind(L_2TAG_PACKET_10_0_1); - jcc(Assembler::equal, L_2TAG_PACKET_11_0_1); - negl(ecx); - shrq(r10); - movq(rax, r9); - shrq(r9); - subl(edx, ecx); - negl(ecx); - addl(ecx, 64); - shlq(rax); - orq(r10, rax); - jmp(L_2TAG_PACKET_11_0_1); - - bind(L_2TAG_PACKET_4_0_1); - negl(ecx); - shlq(r9, 32); - orq(r9, r11); - shlq(r9); - movq(rdi, r9); - testl(r9, INT_MIN); - jcc(Assembler::notEqual, L_2TAG_PACKET_13_0_1); - shrl(r9); - movl(ebx, 0); - shrq(rdi, 3); - jmp(L_2TAG_PACKET_7_0_1); - - bind(L_2TAG_PACKET_5_0_1); - shrl(r9); - movl(ebx, 536870912); - shrl(ebx); - shlq(r9, 32); - orq(r9, r11); - shlq(rbx, 32); - addl(rdi, 536870912); - movl(rcx, 0); - movl(r11, 0); - subq(rcx, r8); - sbbq(r11, r10); - sbbq(rbx, r9); - movq(r8, rcx); - movq(r10, r11); - movq(r9, rbx); - movl(ebx, 32768); - jmp(L_2TAG_PACKET_6_0_1); - - bind(L_2TAG_PACKET_13_0_1); - shrl(r9); - mov64(rbx, 0x100000000); - shrq(rbx); - movl(rcx, 0); - movl(r11, 0); - subq(rcx, r8); - sbbq(r11, r10); - sbbq(rbx, r9); - movq(r8, rcx); - movq(r10, r11); - movq(r9, rbx); - movl(ebx, 32768); - shrq(rdi, 3); - addl(rdi, 536870912); - jmp(L_2TAG_PACKET_7_0_1); - - bind(L_2TAG_PACKET_3_0_1); - movq(xmm0, Address(rsp, 8)); - mulsd(xmm0, ExternalAddress(NEG_ZERO)); //0x00000000UL, 0x80000000UL - movq(Address(rsp, 0), xmm0); - - bind(L_2TAG_PACKET_14_0_1); - - bind(B1_4); - addq(rsp, 16); - pop(rbx); -} - -/******************************************************************************/ -// ALGORITHM DESCRIPTION - COS() -// --------------------- -// -// 1. RANGE REDUCTION -// -// We perform an initial range reduction from X to r with -// -// X =~= N * pi/32 + r -// -// so that |r| <= pi/64 + epsilon. We restrict inputs to those -// where |N| <= 932560. Beyond this, the range reduction is -// insufficiently accurate. For extremely small inputs, -// denormalization can occur internally, impacting performance. -// This means that the main path is actually only taken for -// 2^-252 <= |X| < 90112. -// -// To avoid branches, we perform the range reduction to full -// accuracy each time. -// -// X - N * (P_1 + P_2 + P_3) -// -// where P_1 and P_2 are 32-bit numbers (so multiplication by N -// is exact) and P_3 is a 53-bit number. Together, these -// approximate pi well enough for all cases in the restricted -// range. -// -// The main reduction sequence is: -// -// y = 32/pi * x -// N = integer(y) -// (computed by adding and subtracting off SHIFTER) -// -// m_1 = N * P_1 -// m_2 = N * P_2 -// r_1 = x - m_1 -// r = r_1 - m_2 -// (this r can be used for most of the calculation) -// -// c_1 = r_1 - r -// m_3 = N * P_3 -// c_2 = c_1 - m_2 -// c = c_2 - m_3 -// -// 2. MAIN ALGORITHM -// -// The algorithm uses a table lookup based on B = M * pi / 32 -// where M = N mod 64. The stored values are: -// sigma closest power of 2 to cos(B) -// C_hl 53-bit cos(B) - sigma -// S_hi + S_lo 2 * 53-bit sin(B) -// -// The computation is organized as follows: -// -// sin(B + r + c) = [sin(B) + sigma * r] + -// r * (cos(B) - sigma) + -// sin(B) * [cos(r + c) - 1] + -// cos(B) * [sin(r + c) - r] -// -// which is approximately: -// -// [S_hi + sigma * r] + -// C_hl * r + -// S_lo + S_hi * [(cos(r) - 1) - r * c] + -// (C_hl + sigma) * [(sin(r) - r) + c] -// -// and this is what is actually computed. We separate this sum -// into four parts: -// -// hi + med + pols + corr -// -// where -// -// hi = S_hi + sigma r -// med = C_hl * r -// pols = S_hi * (cos(r) - 1) + (C_hl + sigma) * (sin(r) - r) -// corr = S_lo + c * ((C_hl + sigma) - S_hi * r) -// -// 3. POLYNOMIAL -// -// The polynomial S_hi * (cos(r) - 1) + (C_hl + sigma) * -// (sin(r) - r) can be rearranged freely, since it is quite -// small, so we exploit parallelism to the fullest. -// -// psc4 = SC_4 * r_1 -// msc4 = psc4 * r -// r2 = r * r -// msc2 = SC_2 * r2 -// r4 = r2 * r2 -// psc3 = SC_3 + msc4 -// psc1 = SC_1 + msc2 -// msc3 = r4 * psc3 -// sincospols = psc1 + msc3 -// pols = sincospols * -// -// -// 4. CORRECTION TERM -// -// This is where the "c" component of the range reduction is -// taken into account; recall that just "r" is used for most of -// the calculation. -// -// -c = m_3 - c_2 -// -d = S_hi * r - (C_hl + sigma) -// corr = -c * -d + S_lo -// -// 5. COMPENSATED SUMMATIONS -// -// The two successive compensated summations add up the high -// and medium parts, leaving just the low parts to add up at -// the end. -// -// rs = sigma * r -// res_int = S_hi + rs -// k_0 = S_hi - res_int -// k_2 = k_0 + rs -// med = C_hl * r -// res_hi = res_int + med -// k_1 = res_int - res_hi -// k_3 = k_1 + med -// -// 6. FINAL SUMMATION -// -// We now add up all the small parts: -// -// res_lo = pols(hi) + pols(lo) + corr + k_1 + k_3 -// -// Now the overall result is just: -// -// res_hi + res_lo -// -// 7. SMALL ARGUMENTS -// -// Inputs with |X| < 2^-252 are treated specially as -// 1 - |x|. -// -// Special cases: -// cos(NaN) = quiet NaN, and raise invalid exception -// cos(INF) = NaN and raise invalid exception -// cos(0) = 1 -// -/******************************************************************************/ - -ALIGNED_(8) juint _ONE[] = -{ - 0x00000000UL, 0x3ff00000UL -}; - -void MacroAssembler::fast_cos(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register r8, Register r9, Register r10, Register r11) { - Label L_2TAG_PACKET_0_0_1, L_2TAG_PACKET_1_0_1, L_2TAG_PACKET_2_0_1, L_2TAG_PACKET_3_0_1; - Label L_2TAG_PACKET_4_0_1, L_2TAG_PACKET_5_0_1, L_2TAG_PACKET_6_0_1, L_2TAG_PACKET_7_0_1; - Label L_2TAG_PACKET_8_0_1, L_2TAG_PACKET_9_0_1, L_2TAG_PACKET_10_0_1, L_2TAG_PACKET_11_0_1; - Label L_2TAG_PACKET_12_0_1, L_2TAG_PACKET_13_0_1, B1_2, B1_3, B1_4, B1_5, start; - - assert_different_registers(r8, r9, r10, r11, eax, ecx, edx); - - address ONEHALF = (address)_ONEHALF; - address P_2 = (address)_P_2; - address SC_4 = (address)_SC_4; - address Ctable = (address)_Ctable; - address SC_2 = (address)_SC_2; - address SC_3 = (address)_SC_3; - address SC_1 = (address)_SC_1; - address PI_INV_TABLE = (address)_PI_INV_TABLE; - address PI_4 = (address)_PI_4; - address PI32INV = (address)_PI32INV; - address SIGN_MASK = (address)_SIGN_MASK; - address P_1 = (address)_P_1; - address P_3 = (address)_P_3; - address ONE = (address)_ONE; - address NEG_ZERO = (address)_NEG_ZERO; - - bind(start); - push(rbx); - subq(rsp, 16); - movsd(Address(rsp, 8), xmm0); - - bind(B1_2); - movl(eax, Address(rsp, 12)); - movq(xmm1, ExternalAddress(PI32INV)); //0x6dc9c883UL, 0x40245f30UL - andl(eax, 2147418112); - subl(eax, 808452096); - cmpl(eax, 281346048); - jcc(Assembler::above, L_2TAG_PACKET_0_0_1); - mulsd(xmm1, xmm0); - movdqu(xmm5, ExternalAddress(ONEHALF)); //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL - movq(xmm4, ExternalAddress(SIGN_MASK)); //0x00000000UL, 0x80000000UL - pand(xmm4, xmm0); - por(xmm5, xmm4); - addpd(xmm1, xmm5); - cvttsd2sil(edx, xmm1); - cvtsi2sdl(xmm1, edx); - movdqu(xmm2, ExternalAddress(P_2)); //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL - movq(xmm3, ExternalAddress(P_1)); //0x54400000UL, 0x3fb921fbUL - mulsd(xmm3, xmm1); - unpcklpd(xmm1, xmm1); - addq(rdx, 1865232); - movdqu(xmm4, xmm0); - andq(rdx, 63); - movdqu(xmm5, ExternalAddress(SC_4)); //0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL - lea(rax, ExternalAddress(Ctable)); - shlq(rdx, 5); - addq(rax, rdx); - mulpd(xmm2, xmm1); - subsd(xmm0, xmm3); - mulsd(xmm1, ExternalAddress(P_3)); //0x2e037073UL, 0x3b63198aUL - subsd(xmm4, xmm3); - movq(xmm7, Address(rax, 8)); - unpcklpd(xmm0, xmm0); - movdqu(xmm3, xmm4); - subsd(xmm4, xmm2); - mulpd(xmm5, xmm0); - subpd(xmm0, xmm2); - movdqu(xmm6, ExternalAddress(SC_2)); //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL - mulsd(xmm7, xmm4); - subsd(xmm3, xmm4); - mulpd(xmm5, xmm0); - mulpd(xmm0, xmm0); - subsd(xmm3, xmm2); - movdqu(xmm2, Address(rax, 0)); - subsd(xmm1, xmm3); - movq(xmm3, Address(rax, 24)); - addsd(xmm2, xmm3); - subsd(xmm7, xmm2); - mulsd(xmm2, xmm4); - mulpd(xmm6, xmm0); - mulsd(xmm3, xmm4); - mulpd(xmm2, xmm0); - mulpd(xmm0, xmm0); - addpd(xmm5, ExternalAddress(SC_3)); //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL - mulsd(xmm4, Address(rax, 0)); - addpd(xmm6, ExternalAddress(SC_1)); //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL - mulpd(xmm5, xmm0); - movdqu(xmm0, xmm3); - addsd(xmm3, Address(rax, 8)); - mulpd(xmm1, xmm7); - movdqu(xmm7, xmm4); - addsd(xmm4, xmm3); - addpd(xmm6, xmm5); - movq(xmm5, Address(rax, 8)); - subsd(xmm5, xmm3); - subsd(xmm3, xmm4); - addsd(xmm1, Address(rax, 16)); - mulpd(xmm6, xmm2); - addsd(xmm0, xmm5); - addsd(xmm3, xmm7); - addsd(xmm0, xmm1); - addsd(xmm0, xmm3); - addsd(xmm0, xmm6); - unpckhpd(xmm6, xmm6); - addsd(xmm0, xmm6); - addsd(xmm0, xmm4); - jmp(B1_4); - - bind(L_2TAG_PACKET_0_0_1); - jcc(Assembler::greater, L_2TAG_PACKET_1_0_1); - pextrw(eax, xmm0, 3); - andl(eax, 32767); - pinsrw(xmm0, eax, 3); - movq(xmm1, ExternalAddress(ONE)); //0x00000000UL, 0x3ff00000UL - subsd(xmm1, xmm0); - movdqu(xmm0, xmm1); - jmp(B1_4); - - bind(L_2TAG_PACKET_1_0_1); - pextrw(eax, xmm0, 3); - andl(eax, 32752); - cmpl(eax, 32752); - jcc(Assembler::equal, L_2TAG_PACKET_2_0_1); - pextrw(ecx, xmm0, 3); - andl(ecx, 32752); - subl(ecx, 16224); - shrl(ecx, 7); - andl(ecx, 65532); - lea(r11, ExternalAddress(PI_INV_TABLE)); - addq(rcx, r11); - movdq(rax, xmm0); - movl(r10, Address(rcx, 20)); - movl(r8, Address(rcx, 24)); - movl(edx, eax); - shrq(rax, 21); - orl(eax, INT_MIN); - shrl(eax, 11); - movl(r9, r10); - imulq(r10, rdx); - imulq(r9, rax); - imulq(r8, rax); - movl(rsi, Address(rcx, 16)); - movl(rdi, Address(rcx, 12)); - movl(r11, r10); - shrq(r10, 32); - addq(r9, r10); - addq(r11, r8); - movl(r8, r11); - shrq(r11, 32); - addq(r9, r11); - movl(r10, rsi); - imulq(rsi, rdx); - imulq(r10, rax); - movl(r11, rdi); - imulq(rdi, rdx); - movl(rbx, rsi); - shrq(rsi, 32); - addq(r9, rbx); - movl(rbx, r9); - shrq(r9, 32); - addq(r10, rsi); - addq(r10, r9); - shlq(rbx, 32); - orq(r8, rbx); - imulq(r11, rax); - movl(r9, Address(rcx, 8)); - movl(rsi, Address(rcx, 4)); - movl(rbx, rdi); - shrq(rdi, 32); - addq(r10, rbx); - movl(rbx, r10); - shrq(r10, 32); - addq(r11, rdi); - addq(r11, r10); - movq(rdi, r9); - imulq(r9, rdx); - imulq(rdi, rax); - movl(r10, r9); - shrq(r9, 32); - addq(r11, r10); - movl(r10, r11); - shrq(r11, 32); - addq(rdi, r9); - addq(rdi, r11); - movq(r9, rsi); - imulq(rsi, rdx); - imulq(r9, rax); - shlq(r10, 32); - orq(r10, rbx); - movl(eax, Address(rcx, 0)); - movl(r11, rsi); - shrq(rsi, 32); - addq(rdi, r11); - movl(r11, rdi); - shrq(rdi, 32); - addq(r9, rsi); - addq(r9, rdi); - imulq(rdx, rax); - pextrw(rbx, xmm0, 3); - lea(rdi, ExternalAddress(PI_INV_TABLE)); - subq(rcx, rdi); - addl(ecx, ecx); - addl(ecx, ecx); - addl(ecx, ecx); - addl(ecx, 19); - movl(rsi, 32768); - andl(rsi, rbx); - shrl(rbx, 4); - andl(rbx, 2047); - subl(rbx, 1023); - subl(ecx, rbx); - addq(r9, rdx); - movl(edx, ecx); - addl(edx, 32); - cmpl(ecx, 1); - jcc(Assembler::less, L_2TAG_PACKET_3_0_1); - negl(ecx); - addl(ecx, 29); - shll(r9); - movl(rdi, r9); - andl(r9, 536870911); - testl(r9, 268435456); - jcc(Assembler::notEqual, L_2TAG_PACKET_4_0_1); - shrl(r9); - movl(rbx, 0); - shlq(r9, 32); - orq(r9, r11); - - bind(L_2TAG_PACKET_5_0_1); - - bind(L_2TAG_PACKET_6_0_1); - cmpq(r9, 0); - jcc(Assembler::equal, L_2TAG_PACKET_7_0_1); - - bind(L_2TAG_PACKET_8_0_1); - bsrq(r11, r9); - movl(ecx, 29); - subl(ecx, r11); - jcc(Assembler::lessEqual, L_2TAG_PACKET_9_0_1); - shlq(r9); - movq(rax, r10); - shlq(r10); - addl(edx, ecx); - negl(ecx); - addl(ecx, 64); - shrq(rax); - shrq(r8); - orq(r9, rax); - orq(r10, r8); - - bind(L_2TAG_PACKET_10_0_1); - cvtsi2sdq(xmm0, r9); - shrq(r10, 1); - cvtsi2sdq(xmm3, r10); - xorpd(xmm4, xmm4); - shll(edx, 4); - negl(edx); - addl(edx, 16368); - orl(edx, rsi); - xorl(edx, rbx); - pinsrw(xmm4, edx, 3); - movq(xmm2, ExternalAddress(PI_4)); //0x40000000UL, 0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL - movq(xmm6, ExternalAddress(8 + PI_4)); //0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL - xorpd(xmm5, xmm5); - subl(edx, 1008); - pinsrw(xmm5, edx, 3); - mulsd(xmm0, xmm4); - shll(rsi, 16); - sarl(rsi, 31); - mulsd(xmm3, xmm5); - movdqu(xmm1, xmm0); - mulsd(xmm0, xmm2); - shrl(rdi, 29); - addsd(xmm1, xmm3); - mulsd(xmm3, xmm2); - addl(rdi, rsi); - xorl(rdi, rsi); - mulsd(xmm6, xmm1); - movl(eax, rdi); - addsd(xmm6, xmm3); - movdqu(xmm2, xmm0); - addsd(xmm0, xmm6); - subsd(xmm2, xmm0); - addsd(xmm6, xmm2); - - bind(L_2TAG_PACKET_11_0_1); - movq(xmm1, ExternalAddress(PI32INV)); //0x6dc9c883UL, 0x40245f30UL - mulsd(xmm1, xmm0); - movq(xmm5, ExternalAddress(ONEHALF)); //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL - movq(xmm4, ExternalAddress(SIGN_MASK)); //0x00000000UL, 0x80000000UL - pand(xmm4, xmm0); - por(xmm5, xmm4); - addpd(xmm1, xmm5); - cvttsd2siq(rdx, xmm1); - cvtsi2sdq(xmm1, rdx); - movq(xmm3, ExternalAddress(P_1)); //0x54400000UL, 0x3fb921fbUL - movdqu(xmm2, ExternalAddress(P_2)); //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL - mulsd(xmm3, xmm1); - unpcklpd(xmm1, xmm1); - shll(eax, 3); - addl(edx, 1865232); - movdqu(xmm4, xmm0); - addl(edx, eax); - andl(edx, 63); - movdqu(xmm5, ExternalAddress(SC_4)); //0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL - lea(rax, ExternalAddress(Ctable)); - shll(edx, 5); - addq(rax, rdx); - mulpd(xmm2, xmm1); - subsd(xmm0, xmm3); - mulsd(xmm1, ExternalAddress(P_3)); //0x2e037073UL, 0x3b63198aUL - subsd(xmm4, xmm3); - movq(xmm7, Address(rax, 8)); - unpcklpd(xmm0, xmm0); - movdqu(xmm3, xmm4); - subsd(xmm4, xmm2); - mulpd(xmm5, xmm0); - subpd(xmm0, xmm2); - mulsd(xmm7, xmm4); - subsd(xmm3, xmm4); - mulpd(xmm5, xmm0); - mulpd(xmm0, xmm0); - subsd(xmm3, xmm2); - movdqu(xmm2, Address(rax, 0)); - subsd(xmm1, xmm3); - movq(xmm3, Address(rax, 24)); - addsd(xmm2, xmm3); - subsd(xmm7, xmm2); - subsd(xmm1, xmm6); - movdqu(xmm6, ExternalAddress(SC_2)); //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL - mulsd(xmm2, xmm4); - mulpd(xmm6, xmm0); - mulsd(xmm3, xmm4); - mulpd(xmm2, xmm0); - mulpd(xmm0, xmm0); - addpd(xmm5, ExternalAddress(SC_3)); //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL - mulsd(xmm4, Address(rax, 0)); - addpd(xmm6, ExternalAddress(SC_1)); //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL - mulpd(xmm5, xmm0); - movdqu(xmm0, xmm3); - addsd(xmm3, Address(rax, 8)); - mulpd(xmm1, xmm7); - movdqu(xmm7, xmm4); - addsd(xmm4, xmm3); - addpd(xmm6, xmm5); - movq(xmm5, Address(rax, 8)); - subsd(xmm5, xmm3); - subsd(xmm3, xmm4); - addsd(xmm1, Address(rax, 16)); - mulpd(xmm6, xmm2); - addsd(xmm5, xmm0); - addsd(xmm3, xmm7); - addsd(xmm1, xmm5); - addsd(xmm1, xmm3); - addsd(xmm1, xmm6); - unpckhpd(xmm6, xmm6); - movdqu(xmm0, xmm4); - addsd(xmm1, xmm6); - addsd(xmm0, xmm1); - jmp(B1_4); - - bind(L_2TAG_PACKET_7_0_1); - addl(edx, 64); - movq(r9, r10); - movq(r10, r8); - movl(r8, 0); - cmpq(r9, 0); - jcc(Assembler::notEqual, L_2TAG_PACKET_8_0_1); - addl(edx, 64); - movq(r9, r10); - movq(r10, r8); - cmpq(r9, 0); - jcc(Assembler::notEqual, L_2TAG_PACKET_8_0_1); - xorpd(xmm0, xmm0); - xorpd(xmm6, xmm6); - jmp(L_2TAG_PACKET_11_0_1); - - bind(L_2TAG_PACKET_9_0_1); - jcc(Assembler::equal, L_2TAG_PACKET_10_0_1); - negl(ecx); - shrq(r10); - movq(rax, r9); - shrq(r9); - subl(edx, ecx); - negl(ecx); - addl(ecx, 64); - shlq(rax); - orq(r10, rax); - jmp(L_2TAG_PACKET_10_0_1); - bind(L_2TAG_PACKET_3_0_1); - negl(ecx); - shlq(r9, 32); - orq(r9, r11); - shlq(r9); - movq(rdi, r9); - testl(r9, INT_MIN); - jcc(Assembler::notEqual, L_2TAG_PACKET_12_0_1); - shrl(r9); - movl(rbx, 0); - shrq(rdi, 3); - jmp(L_2TAG_PACKET_6_0_1); - - bind(L_2TAG_PACKET_4_0_1); - shrl(r9); - movl(rbx, 536870912); - shrl(rbx); - shlq(r9, 32); - orq(r9, r11); - shlq(rbx, 32); - addl(rdi, 536870912); - movl(rcx, 0); - movl(r11, 0); - subq(rcx, r8); - sbbq(r11, r10); - sbbq(rbx, r9); - movq(r8, rcx); - movq(r10, r11); - movq(r9, rbx); - movl(rbx, 32768); - jmp(L_2TAG_PACKET_5_0_1); - - bind(L_2TAG_PACKET_12_0_1); - shrl(r9); - mov64(rbx, 0x100000000); - shrq(rbx); - movl(rcx, 0); - movl(r11, 0); - subq(rcx, r8); - sbbq(r11, r10); - sbbq(rbx, r9); - movq(r8, rcx); - movq(r10, r11); - movq(r9, rbx); - movl(rbx, 32768); - shrq(rdi, 3); - addl(rdi, 536870912); - jmp(L_2TAG_PACKET_6_0_1); - - bind(L_2TAG_PACKET_2_0_1); - movsd(xmm0, Address(rsp, 8)); - mulsd(xmm0, ExternalAddress(NEG_ZERO)); //0x00000000UL, 0x80000000UL - movq(Address(rsp, 0), xmm0); - - bind(L_2TAG_PACKET_13_0_1); - - bind(B1_4); - addq(rsp, 16); - pop(rbx); -} diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp index 836f8c4fb45..3c703186b3b 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp @@ -928,6 +928,10 @@ class MacroAssembler: public Assembler { XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register rax, Register rcx, Register rdx, Register tmp1, Register tmp2); + void fast_log10(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, + XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, + Register rax, Register rcx, Register rdx, Register r11); + void fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register rax, Register rcx, Register rdx, Register tmp1, Register tmp2, Register tmp3, Register tmp4); @@ -941,11 +945,19 @@ class MacroAssembler: public Assembler { XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register rax, Register rcx, Register rdx, Register tmp1, Register tmp2, Register tmp3, Register tmp4); + void fast_tan(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, + XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, + Register rax, Register rcx, Register rdx, Register tmp1, + Register tmp2, Register tmp3, Register tmp4); #else void fast_log(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register rax, Register rcx, Register rdx, Register tmp1); + void fast_log10(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, + XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, + Register rax, Register rcx, Register rdx, Register tmp); + void fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register rax, Register rcx, Register rdx, Register tmp); @@ -964,6 +976,14 @@ class MacroAssembler: public Assembler { void libm_reduce_pi04l(Register eax, Register ecx, Register edx, Register ebx, Register esi, Register edi, Register ebp, Register esp); + + void libm_tancot_huge(XMMRegister xmm0, XMMRegister xmm1, Register eax, Register ecx, + Register edx, Register ebx, Register esi, Register edi, + Register ebp, Register esp); + + void fast_tan(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, + XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, + Register rax, Register rcx, Register rdx, Register tmp); #endif void increase_precision(); diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_cos.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_cos.cpp new file mode 100644 index 00000000000..1ebed3523ab --- /dev/null +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_cos.cpp @@ -0,0 +1,889 @@ +/* +* Copyright (c) 2016, Intel Corporation. +* Intel Math Library (LIBM) Source Code +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 only, as +* published by the Free Software Foundation. +* +* This code is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* version 2 for more details (a copy is included in the LICENSE file that +* accompanied this code). +* +* You should have received a copy of the GNU General Public License version +* 2 along with this work; if not, write to the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +* or visit www.oracle.com if you need additional information or have any +* questions. +* +*/ + +#include "precompiled.hpp" +#include "asm/assembler.hpp" +#include "asm/assembler.inline.hpp" +#include "runtime/stubRoutines.hpp" +#include "macroAssembler_x86.hpp" + +#ifdef _MSC_VER +#define ALIGNED_(x) __declspec(align(x)) +#else +#define ALIGNED_(x) __attribute__ ((aligned(x))) +#endif + +/******************************************************************************/ +// ALGORITHM DESCRIPTION - COS() +// --------------------- +// +// 1. RANGE REDUCTION +// +// We perform an initial range reduction from X to r with +// +// X =~= N * pi/32 + r +// +// so that |r| <= pi/64 + epsilon. We restrict inputs to those +// where |N| <= 932560. Beyond this, the range reduction is +// insufficiently accurate. For extremely small inputs, +// denormalization can occur internally, impacting performance. +// This means that the main path is actually only taken for +// 2^-252 <= |X| < 90112. +// +// To avoid branches, we perform the range reduction to full +// accuracy each time. +// +// X - N * (P_1 + P_2 + P_3) +// +// where P_1 and P_2 are 32-bit numbers (so multiplication by N +// is exact) and P_3 is a 53-bit number. Together, these +// approximate pi well enough for all cases in the restricted +// range. +// +// The main reduction sequence is: +// +// y = 32/pi * x +// N = integer(y) +// (computed by adding and subtracting off SHIFTER) +// +// m_1 = N * P_1 +// m_2 = N * P_2 +// r_1 = x - m_1 +// r = r_1 - m_2 +// (this r can be used for most of the calculation) +// +// c_1 = r_1 - r +// m_3 = N * P_3 +// c_2 = c_1 - m_2 +// c = c_2 - m_3 +// +// 2. MAIN ALGORITHM +// +// The algorithm uses a table lookup based on B = M * pi / 32 +// where M = N mod 64. The stored values are: +// sigma closest power of 2 to cos(B) +// C_hl 53-bit cos(B) - sigma +// S_hi + S_lo 2 * 53-bit sin(B) +// +// The computation is organized as follows: +// +// sin(B + r + c) = [sin(B) + sigma * r] + +// r * (cos(B) - sigma) + +// sin(B) * [cos(r + c) - 1] + +// cos(B) * [sin(r + c) - r] +// +// which is approximately: +// +// [S_hi + sigma * r] + +// C_hl * r + +// S_lo + S_hi * [(cos(r) - 1) - r * c] + +// (C_hl + sigma) * [(sin(r) - r) + c] +// +// and this is what is actually computed. We separate this sum +// into four parts: +// +// hi + med + pols + corr +// +// where +// +// hi = S_hi + sigma r +// med = C_hl * r +// pols = S_hi * (cos(r) - 1) + (C_hl + sigma) * (sin(r) - r) +// corr = S_lo + c * ((C_hl + sigma) - S_hi * r) +// +// 3. POLYNOMIAL +// +// The polynomial S_hi * (cos(r) - 1) + (C_hl + sigma) * +// (sin(r) - r) can be rearranged freely, since it is quite +// small, so we exploit parallelism to the fullest. +// +// psc4 = SC_4 * r_1 +// msc4 = psc4 * r +// r2 = r * r +// msc2 = SC_2 * r2 +// r4 = r2 * r2 +// psc3 = SC_3 + msc4 +// psc1 = SC_1 + msc2 +// msc3 = r4 * psc3 +// sincospols = psc1 + msc3 +// pols = sincospols * +// +// +// 4. CORRECTION TERM +// +// This is where the "c" component of the range reduction is +// taken into account; recall that just "r" is used for most of +// the calculation. +// +// -c = m_3 - c_2 +// -d = S_hi * r - (C_hl + sigma) +// corr = -c * -d + S_lo +// +// 5. COMPENSATED SUMMATIONS +// +// The two successive compensated summations add up the high +// and medium parts, leaving just the low parts to add up at +// the end. +// +// rs = sigma * r +// res_int = S_hi + rs +// k_0 = S_hi - res_int +// k_2 = k_0 + rs +// med = C_hl * r +// res_hi = res_int + med +// k_1 = res_int - res_hi +// k_3 = k_1 + med +// +// 6. FINAL SUMMATION +// +// We now add up all the small parts: +// +// res_lo = pols(hi) + pols(lo) + corr + k_1 + k_3 +// +// Now the overall result is just: +// +// res_hi + res_lo +// +// 7. SMALL ARGUMENTS +// +// Inputs with |X| < 2^-252 are treated specially as +// 1 - |x|. +// +// Special cases: +// cos(NaN) = quiet NaN, and raise invalid exception +// cos(INF) = NaN and raise invalid exception +// cos(0) = 1 +// +/******************************************************************************/ + +#ifdef _LP64 +// The 64 bit code is at most SSE2 compliant +ALIGNED_(8) juint _ONE[] = +{ + 0x00000000UL, 0x3ff00000UL +}; +void MacroAssembler::fast_cos(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register r8, Register r9, Register r10, Register r11) { + + Label L_2TAG_PACKET_0_0_1, L_2TAG_PACKET_1_0_1, L_2TAG_PACKET_2_0_1, L_2TAG_PACKET_3_0_1; + Label L_2TAG_PACKET_4_0_1, L_2TAG_PACKET_5_0_1, L_2TAG_PACKET_6_0_1, L_2TAG_PACKET_7_0_1; + Label L_2TAG_PACKET_8_0_1, L_2TAG_PACKET_9_0_1, L_2TAG_PACKET_10_0_1, L_2TAG_PACKET_11_0_1; + Label L_2TAG_PACKET_12_0_1, L_2TAG_PACKET_13_0_1, B1_2, B1_3, B1_4, B1_5, start; + + assert_different_registers(r8, r9, r10, r11, eax, ecx, edx); + + address ONEHALF = StubRoutines::x86::_ONEHALF_addr(); + address P_2 = StubRoutines::x86::_P_2_addr(); + address SC_4 = StubRoutines::x86::_SC_4_addr(); + address Ctable = StubRoutines::x86::_Ctable_addr(); + address SC_2 = StubRoutines::x86::_SC_2_addr(); + address SC_3 = StubRoutines::x86::_SC_3_addr(); + address SC_1 = StubRoutines::x86::_SC_1_addr(); + address PI_INV_TABLE = StubRoutines::x86::_PI_INV_TABLE_addr(); + address PI_4 = (address)StubRoutines::x86::_PI_4_addr(); + address PI32INV = (address)StubRoutines::x86::_PI32INV_addr(); + address SIGN_MASK = (address)StubRoutines::x86::_SIGN_MASK_addr(); + address P_1 = (address)StubRoutines::x86::_P_1_addr(); + address P_3 = (address)StubRoutines::x86::_P_3_addr(); + address ONE = (address)_ONE; + address NEG_ZERO = (address)StubRoutines::x86::_NEG_ZERO_addr(); + + bind(start); + push(rbx); + subq(rsp, 16); + movsd(Address(rsp, 8), xmm0); + + bind(B1_2); + movl(eax, Address(rsp, 12)); + movq(xmm1, ExternalAddress(PI32INV)); //0x6dc9c883UL, 0x40245f30UL + andl(eax, 2147418112); + subl(eax, 808452096); + cmpl(eax, 281346048); + jcc(Assembler::above, L_2TAG_PACKET_0_0_1); + mulsd(xmm1, xmm0); + movdqu(xmm5, ExternalAddress(ONEHALF)); //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL + movq(xmm4, ExternalAddress(SIGN_MASK)); //0x00000000UL, 0x80000000UL + pand(xmm4, xmm0); + por(xmm5, xmm4); + addpd(xmm1, xmm5); + cvttsd2sil(edx, xmm1); + cvtsi2sdl(xmm1, edx); + movdqu(xmm2, ExternalAddress(P_2)); //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL + movq(xmm3, ExternalAddress(P_1)); //0x54400000UL, 0x3fb921fbUL + mulsd(xmm3, xmm1); + unpcklpd(xmm1, xmm1); + addq(rdx, 1865232); + movdqu(xmm4, xmm0); + andq(rdx, 63); + movdqu(xmm5, ExternalAddress(SC_4)); //0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL + lea(rax, ExternalAddress(Ctable)); + shlq(rdx, 5); + addq(rax, rdx); + mulpd(xmm2, xmm1); + subsd(xmm0, xmm3); + mulsd(xmm1, ExternalAddress(P_3)); //0x2e037073UL, 0x3b63198aUL + subsd(xmm4, xmm3); + movq(xmm7, Address(rax, 8)); + unpcklpd(xmm0, xmm0); + movdqu(xmm3, xmm4); + subsd(xmm4, xmm2); + mulpd(xmm5, xmm0); + subpd(xmm0, xmm2); + movdqu(xmm6, ExternalAddress(SC_2)); //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL + mulsd(xmm7, xmm4); + subsd(xmm3, xmm4); + mulpd(xmm5, xmm0); + mulpd(xmm0, xmm0); + subsd(xmm3, xmm2); + movdqu(xmm2, Address(rax, 0)); + subsd(xmm1, xmm3); + movq(xmm3, Address(rax, 24)); + addsd(xmm2, xmm3); + subsd(xmm7, xmm2); + mulsd(xmm2, xmm4); + mulpd(xmm6, xmm0); + mulsd(xmm3, xmm4); + mulpd(xmm2, xmm0); + mulpd(xmm0, xmm0); + addpd(xmm5, ExternalAddress(SC_3)); //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL + mulsd(xmm4, Address(rax, 0)); + addpd(xmm6, ExternalAddress(SC_1)); //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL + mulpd(xmm5, xmm0); + movdqu(xmm0, xmm3); + addsd(xmm3, Address(rax, 8)); + mulpd(xmm1, xmm7); + movdqu(xmm7, xmm4); + addsd(xmm4, xmm3); + addpd(xmm6, xmm5); + movq(xmm5, Address(rax, 8)); + subsd(xmm5, xmm3); + subsd(xmm3, xmm4); + addsd(xmm1, Address(rax, 16)); + mulpd(xmm6, xmm2); + addsd(xmm0, xmm5); + addsd(xmm3, xmm7); + addsd(xmm0, xmm1); + addsd(xmm0, xmm3); + addsd(xmm0, xmm6); + unpckhpd(xmm6, xmm6); + addsd(xmm0, xmm6); + addsd(xmm0, xmm4); + jmp(B1_4); + + bind(L_2TAG_PACKET_0_0_1); + jcc(Assembler::greater, L_2TAG_PACKET_1_0_1); + pextrw(eax, xmm0, 3); + andl(eax, 32767); + pinsrw(xmm0, eax, 3); + movq(xmm1, ExternalAddress(ONE)); //0x00000000UL, 0x3ff00000UL + subsd(xmm1, xmm0); + movdqu(xmm0, xmm1); + jmp(B1_4); + + bind(L_2TAG_PACKET_1_0_1); + pextrw(eax, xmm0, 3); + andl(eax, 32752); + cmpl(eax, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_2_0_1); + pextrw(ecx, xmm0, 3); + andl(ecx, 32752); + subl(ecx, 16224); + shrl(ecx, 7); + andl(ecx, 65532); + lea(r11, ExternalAddress(PI_INV_TABLE)); + addq(rcx, r11); + movdq(rax, xmm0); + movl(r10, Address(rcx, 20)); + movl(r8, Address(rcx, 24)); + movl(edx, eax); + shrq(rax, 21); + orl(eax, INT_MIN); + shrl(eax, 11); + movl(r9, r10); + imulq(r10, rdx); + imulq(r9, rax); + imulq(r8, rax); + movl(rsi, Address(rcx, 16)); + movl(rdi, Address(rcx, 12)); + movl(r11, r10); + shrq(r10, 32); + addq(r9, r10); + addq(r11, r8); + movl(r8, r11); + shrq(r11, 32); + addq(r9, r11); + movl(r10, rsi); + imulq(rsi, rdx); + imulq(r10, rax); + movl(r11, rdi); + imulq(rdi, rdx); + movl(rbx, rsi); + shrq(rsi, 32); + addq(r9, rbx); + movl(rbx, r9); + shrq(r9, 32); + addq(r10, rsi); + addq(r10, r9); + shlq(rbx, 32); + orq(r8, rbx); + imulq(r11, rax); + movl(r9, Address(rcx, 8)); + movl(rsi, Address(rcx, 4)); + movl(rbx, rdi); + shrq(rdi, 32); + addq(r10, rbx); + movl(rbx, r10); + shrq(r10, 32); + addq(r11, rdi); + addq(r11, r10); + movq(rdi, r9); + imulq(r9, rdx); + imulq(rdi, rax); + movl(r10, r9); + shrq(r9, 32); + addq(r11, r10); + movl(r10, r11); + shrq(r11, 32); + addq(rdi, r9); + addq(rdi, r11); + movq(r9, rsi); + imulq(rsi, rdx); + imulq(r9, rax); + shlq(r10, 32); + orq(r10, rbx); + movl(eax, Address(rcx, 0)); + movl(r11, rsi); + shrq(rsi, 32); + addq(rdi, r11); + movl(r11, rdi); + shrq(rdi, 32); + addq(r9, rsi); + addq(r9, rdi); + imulq(rdx, rax); + pextrw(rbx, xmm0, 3); + lea(rdi, ExternalAddress(PI_INV_TABLE)); + subq(rcx, rdi); + addl(ecx, ecx); + addl(ecx, ecx); + addl(ecx, ecx); + addl(ecx, 19); + movl(rsi, 32768); + andl(rsi, rbx); + shrl(rbx, 4); + andl(rbx, 2047); + subl(rbx, 1023); + subl(ecx, rbx); + addq(r9, rdx); + movl(edx, ecx); + addl(edx, 32); + cmpl(ecx, 1); + jcc(Assembler::less, L_2TAG_PACKET_3_0_1); + negl(ecx); + addl(ecx, 29); + shll(r9); + movl(rdi, r9); + andl(r9, 536870911); + testl(r9, 268435456); + jcc(Assembler::notEqual, L_2TAG_PACKET_4_0_1); + shrl(r9); + movl(rbx, 0); + shlq(r9, 32); + orq(r9, r11); + + bind(L_2TAG_PACKET_5_0_1); + + bind(L_2TAG_PACKET_6_0_1); + cmpq(r9, 0); + jcc(Assembler::equal, L_2TAG_PACKET_7_0_1); + + bind(L_2TAG_PACKET_8_0_1); + bsrq(r11, r9); + movl(ecx, 29); + subl(ecx, r11); + jcc(Assembler::lessEqual, L_2TAG_PACKET_9_0_1); + shlq(r9); + movq(rax, r10); + shlq(r10); + addl(edx, ecx); + negl(ecx); + addl(ecx, 64); + shrq(rax); + shrq(r8); + orq(r9, rax); + orq(r10, r8); + + bind(L_2TAG_PACKET_10_0_1); + cvtsi2sdq(xmm0, r9); + shrq(r10, 1); + cvtsi2sdq(xmm3, r10); + xorpd(xmm4, xmm4); + shll(edx, 4); + negl(edx); + addl(edx, 16368); + orl(edx, rsi); + xorl(edx, rbx); + pinsrw(xmm4, edx, 3); + movq(xmm2, ExternalAddress(PI_4)); //0x40000000UL, 0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL + movq(xmm6, ExternalAddress(8 + PI_4)); //0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL + xorpd(xmm5, xmm5); + subl(edx, 1008); + pinsrw(xmm5, edx, 3); + mulsd(xmm0, xmm4); + shll(rsi, 16); + sarl(rsi, 31); + mulsd(xmm3, xmm5); + movdqu(xmm1, xmm0); + mulsd(xmm0, xmm2); + shrl(rdi, 29); + addsd(xmm1, xmm3); + mulsd(xmm3, xmm2); + addl(rdi, rsi); + xorl(rdi, rsi); + mulsd(xmm6, xmm1); + movl(eax, rdi); + addsd(xmm6, xmm3); + movdqu(xmm2, xmm0); + addsd(xmm0, xmm6); + subsd(xmm2, xmm0); + addsd(xmm6, xmm2); + + bind(L_2TAG_PACKET_11_0_1); + movq(xmm1, ExternalAddress(PI32INV)); //0x6dc9c883UL, 0x40245f30UL + mulsd(xmm1, xmm0); + movq(xmm5, ExternalAddress(ONEHALF)); //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL + movq(xmm4, ExternalAddress(SIGN_MASK)); //0x00000000UL, 0x80000000UL + pand(xmm4, xmm0); + por(xmm5, xmm4); + addpd(xmm1, xmm5); + cvttsd2siq(rdx, xmm1); + cvtsi2sdq(xmm1, rdx); + movq(xmm3, ExternalAddress(P_1)); //0x54400000UL, 0x3fb921fbUL + movdqu(xmm2, ExternalAddress(P_2)); //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL + mulsd(xmm3, xmm1); + unpcklpd(xmm1, xmm1); + shll(eax, 3); + addl(edx, 1865232); + movdqu(xmm4, xmm0); + addl(edx, eax); + andl(edx, 63); + movdqu(xmm5, ExternalAddress(SC_4)); //0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL + lea(rax, ExternalAddress(Ctable)); + shll(edx, 5); + addq(rax, rdx); + mulpd(xmm2, xmm1); + subsd(xmm0, xmm3); + mulsd(xmm1, ExternalAddress(P_3)); //0x2e037073UL, 0x3b63198aUL + subsd(xmm4, xmm3); + movq(xmm7, Address(rax, 8)); + unpcklpd(xmm0, xmm0); + movdqu(xmm3, xmm4); + subsd(xmm4, xmm2); + mulpd(xmm5, xmm0); + subpd(xmm0, xmm2); + mulsd(xmm7, xmm4); + subsd(xmm3, xmm4); + mulpd(xmm5, xmm0); + mulpd(xmm0, xmm0); + subsd(xmm3, xmm2); + movdqu(xmm2, Address(rax, 0)); + subsd(xmm1, xmm3); + movq(xmm3, Address(rax, 24)); + addsd(xmm2, xmm3); + subsd(xmm7, xmm2); + subsd(xmm1, xmm6); + movdqu(xmm6, ExternalAddress(SC_2)); //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL + mulsd(xmm2, xmm4); + mulpd(xmm6, xmm0); + mulsd(xmm3, xmm4); + mulpd(xmm2, xmm0); + mulpd(xmm0, xmm0); + addpd(xmm5, ExternalAddress(SC_3)); //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL + mulsd(xmm4, Address(rax, 0)); + addpd(xmm6, ExternalAddress(SC_1)); //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL + mulpd(xmm5, xmm0); + movdqu(xmm0, xmm3); + addsd(xmm3, Address(rax, 8)); + mulpd(xmm1, xmm7); + movdqu(xmm7, xmm4); + addsd(xmm4, xmm3); + addpd(xmm6, xmm5); + movq(xmm5, Address(rax, 8)); + subsd(xmm5, xmm3); + subsd(xmm3, xmm4); + addsd(xmm1, Address(rax, 16)); + mulpd(xmm6, xmm2); + addsd(xmm5, xmm0); + addsd(xmm3, xmm7); + addsd(xmm1, xmm5); + addsd(xmm1, xmm3); + addsd(xmm1, xmm6); + unpckhpd(xmm6, xmm6); + movdqu(xmm0, xmm4); + addsd(xmm1, xmm6); + addsd(xmm0, xmm1); + jmp(B1_4); + + bind(L_2TAG_PACKET_7_0_1); + addl(edx, 64); + movq(r9, r10); + movq(r10, r8); + movl(r8, 0); + cmpq(r9, 0); + jcc(Assembler::notEqual, L_2TAG_PACKET_8_0_1); + addl(edx, 64); + movq(r9, r10); + movq(r10, r8); + cmpq(r9, 0); + jcc(Assembler::notEqual, L_2TAG_PACKET_8_0_1); + xorpd(xmm0, xmm0); + xorpd(xmm6, xmm6); + jmp(L_2TAG_PACKET_11_0_1); + + bind(L_2TAG_PACKET_9_0_1); + jcc(Assembler::equal, L_2TAG_PACKET_10_0_1); + negl(ecx); + shrq(r10); + movq(rax, r9); + shrq(r9); + subl(edx, ecx); + negl(ecx); + addl(ecx, 64); + shlq(rax); + orq(r10, rax); + jmp(L_2TAG_PACKET_10_0_1); + bind(L_2TAG_PACKET_3_0_1); + negl(ecx); + shlq(r9, 32); + orq(r9, r11); + shlq(r9); + movq(rdi, r9); + testl(r9, INT_MIN); + jcc(Assembler::notEqual, L_2TAG_PACKET_12_0_1); + shrl(r9); + movl(rbx, 0); + shrq(rdi, 3); + jmp(L_2TAG_PACKET_6_0_1); + + bind(L_2TAG_PACKET_4_0_1); + shrl(r9); + movl(rbx, 536870912); + shrl(rbx); + shlq(r9, 32); + orq(r9, r11); + shlq(rbx, 32); + addl(rdi, 536870912); + movl(rcx, 0); + movl(r11, 0); + subq(rcx, r8); + sbbq(r11, r10); + sbbq(rbx, r9); + movq(r8, rcx); + movq(r10, r11); + movq(r9, rbx); + movl(rbx, 32768); + jmp(L_2TAG_PACKET_5_0_1); + + bind(L_2TAG_PACKET_12_0_1); + shrl(r9); + mov64(rbx, 0x100000000); + shrq(rbx); + movl(rcx, 0); + movl(r11, 0); + subq(rcx, r8); + sbbq(r11, r10); + sbbq(rbx, r9); + movq(r8, rcx); + movq(r10, r11); + movq(r9, rbx); + movl(rbx, 32768); + shrq(rdi, 3); + addl(rdi, 536870912); + jmp(L_2TAG_PACKET_6_0_1); + + bind(L_2TAG_PACKET_2_0_1); + movsd(xmm0, Address(rsp, 8)); + mulsd(xmm0, ExternalAddress(NEG_ZERO)); //0x00000000UL, 0x80000000UL + movq(Address(rsp, 0), xmm0); + + bind(L_2TAG_PACKET_13_0_1); + + bind(B1_4); + addq(rsp, 16); + pop(rbx); +} +#else +// The 32 bit code is at most SSE2 compliant + +ALIGNED_(16) juint _static_const_table_cos[] = +{ + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, 0xbf73b92eUL, + 0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL, + 0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, + 0xc0000000UL, 0xbc626d19UL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, + 0xbfa60beaUL, 0x2ed59f06UL, 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, + 0x00000000UL, 0x3ff00000UL, 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, + 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, 0x00000000UL, 0x3ff00000UL, + 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, 0x20000000UL, + 0x3c5e0d89UL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, 0xbfc59267UL, + 0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL, + 0x3ff00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, + 0x20000000UL, 0x3c68076aUL, 0x00000000UL, 0x3ff00000UL, 0x99fcef32UL, + 0x3fca8279UL, 0x667f3bcdUL, 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, + 0x00000000UL, 0x3fe00000UL, 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, + 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, 0x00000000UL, 0x3fe00000UL, + 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, 0xe0000000UL, + 0x3c39f630UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, 0xbf9d4a2cUL, + 0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL, + 0x3fe00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0x3fed906bUL, + 0x20000000UL, 0x3c7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x76acf82dUL, + 0x3fa4a031UL, 0x56c62ddaUL, 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, + 0x00000000UL, 0x3fd00000UL, 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, + 0x3fef6297UL, 0x20000000UL, 0x3c756217UL, 0x00000000UL, 0x3fd00000UL, + 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, 0x40000000UL, + 0xbc887df6UL, 0x00000000UL, 0x3fc00000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, + 0x40000000UL, 0xbc887df6UL, 0x00000000UL, 0xbfc00000UL, 0x0e5967d5UL, + 0x3fac1d1fUL, 0xcff75cb0UL, 0x3fef6297UL, 0x20000000UL, 0x3c756217UL, + 0x00000000UL, 0xbfd00000UL, 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, + 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, 0x00000000UL, 0xbfd00000UL, + 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, 0x3fed906bUL, 0x20000000UL, + 0x3c7457e6UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, 0x3f9d4a2cUL, + 0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL, + 0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, + 0xe0000000UL, 0x3c39f630UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, + 0xbfc133ccUL, 0x6b151741UL, 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, + 0x00000000UL, 0xbfe00000UL, 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, + 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, 0x00000000UL, 0xbfe00000UL, + 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, 0x20000000UL, + 0x3c68076aUL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, 0x3fc59267UL, + 0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL, + 0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, + 0x20000000UL, 0x3c5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, + 0x3fb37ca1UL, 0xa6aea963UL, 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, + 0x00000000UL, 0xbff00000UL, 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, + 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, 0x00000000UL, 0xbff00000UL, + 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, 0xc0000000UL, + 0xbc626d19UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, 0x3f73b92eUL, + 0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL, + 0xbff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, + 0x3f73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL, + 0x00000000UL, 0xbff00000UL, 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, + 0xbfc8f8b8UL, 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0xbff00000UL, + 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, + 0x3c75d28dUL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, 0x3fb37ca1UL, + 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, 0x3c672cedUL, 0x00000000UL, + 0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0xbfde2b5dUL, + 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, + 0x3fc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL, + 0x00000000UL, 0xbff00000UL, 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, + 0xbfe44cf3UL, 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0xbff00000UL, + 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, + 0x3c8bdd34UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, 0xbfc133ccUL, + 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, 0x3c82c5e1UL, 0x00000000UL, + 0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0xbfea9b66UL, + 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, + 0x3f9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL, + 0x00000000UL, 0xbfe00000UL, 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, + 0xbfed906bUL, 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0xbfe00000UL, + 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, + 0xbc8760b1UL, 0x00000000UL, 0xbfd00000UL, 0x0e5967d5UL, 0x3fac1d1fUL, + 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, 0xbc756217UL, 0x00000000UL, + 0xbfd00000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0xbfefd88dUL, + 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0xbfc00000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, + 0xbfefd88dUL, 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0x3fc00000UL, + 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, + 0xbc756217UL, 0x00000000UL, 0x3fd00000UL, 0x76acf82dUL, 0x3fa4a031UL, + 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, 0xbc8760b1UL, 0x00000000UL, + 0x3fd00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0xbfed906bUL, + 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, + 0xbf9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL, + 0x00000000UL, 0x3fe00000UL, 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, + 0xbfea9b66UL, 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0x3fe00000UL, + 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, + 0x3c82c5e1UL, 0x00000000UL, 0x3fe00000UL, 0x99fcef32UL, 0x3fca8279UL, + 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, 0x3c8bdd34UL, 0x00000000UL, + 0x3fe00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0xbfe44cf3UL, + 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, + 0xbfc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL, + 0x00000000UL, 0x3ff00000UL, 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, + 0xbfde2b5dUL, 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0x3ff00000UL, + 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, + 0x3c672cedUL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, 0xbfa60beaUL, + 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, 0x3c75d28dUL, 0x00000000UL, + 0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0xbfc8f8b8UL, + 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, + 0xbf73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL, + 0x00000000UL, 0x3ff00000UL, 0x55555555UL, 0xbfc55555UL, 0x00000000UL, + 0xbfe00000UL, 0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL, + 0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL, 0xa556c734UL, + 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL, 0x1a600000UL, 0x3d90b461UL, + 0x1a600000UL, 0x3d90b461UL, 0x54400000UL, 0x3fb921fbUL, 0x00000000UL, + 0x00000000UL, 0x2e037073UL, 0x3b63198aUL, 0x00000000UL, 0x00000000UL, + 0x6dc9c883UL, 0x40245f30UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x43380000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x3ff00000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x80000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL +}; +//registers, +// input: (rbp + 8) +// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 +// rax, rdx, rcx, rbx (tmp) + +// Code generated by Intel C compiler for LIBM library + +void MacroAssembler::fast_cos(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) { + Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; + Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; + Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2; + Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start; + + assert_different_registers(tmp, eax, ecx, edx); + + address static_const_table_cos = (address)_static_const_table_cos; + + bind(start); + subl(rsp, 120); + movl(Address(rsp, 56), tmp); + lea(tmp, ExternalAddress(static_const_table_cos)); + movsd(xmm0, Address(rsp, 128)); + pextrw(eax, xmm0, 3); + andl(eax, 32767); + subl(eax, 12336); + cmpl(eax, 4293); + jcc(Assembler::above, L_2TAG_PACKET_0_0_2); + movsd(xmm1, Address(tmp, 2160)); + mulsd(xmm1, xmm0); + movdqu(xmm5, Address(tmp, 2240)); + movsd(xmm4, Address(tmp, 2224)); + pand(xmm4, xmm0); + por(xmm5, xmm4); + movsd(xmm3, Address(tmp, 2128)); + movdqu(xmm2, Address(tmp, 2112)); + addpd(xmm1, xmm5); + cvttsd2sil(edx, xmm1); + cvtsi2sdl(xmm1, edx); + mulsd(xmm3, xmm1); + unpcklpd(xmm1, xmm1); + addl(edx, 1865232); + movdqu(xmm4, xmm0); + andl(edx, 63); + movdqu(xmm5, Address(tmp, 2096)); + lea(eax, Address(tmp, 0)); + shll(edx, 5); + addl(eax, edx); + mulpd(xmm2, xmm1); + subsd(xmm0, xmm3); + mulsd(xmm1, Address(tmp, 2144)); + subsd(xmm4, xmm3); + movsd(xmm7, Address(eax, 8)); + unpcklpd(xmm0, xmm0); + movapd(xmm3, xmm4); + subsd(xmm4, xmm2); + mulpd(xmm5, xmm0); + subpd(xmm0, xmm2); + movdqu(xmm6, Address(tmp, 2064)); + mulsd(xmm7, xmm4); + subsd(xmm3, xmm4); + mulpd(xmm5, xmm0); + mulpd(xmm0, xmm0); + subsd(xmm3, xmm2); + movdqu(xmm2, Address(eax, 0)); + subsd(xmm1, xmm3); + movsd(xmm3, Address(eax, 24)); + addsd(xmm2, xmm3); + subsd(xmm7, xmm2); + mulsd(xmm2, xmm4); + mulpd(xmm6, xmm0); + mulsd(xmm3, xmm4); + mulpd(xmm2, xmm0); + mulpd(xmm0, xmm0); + addpd(xmm5, Address(tmp, 2080)); + mulsd(xmm4, Address(eax, 0)); + addpd(xmm6, Address(tmp, 2048)); + mulpd(xmm5, xmm0); + movapd(xmm0, xmm3); + addsd(xmm3, Address(eax, 8)); + mulpd(xmm1, xmm7); + movapd(xmm7, xmm4); + addsd(xmm4, xmm3); + addpd(xmm6, xmm5); + movsd(xmm5, Address(eax, 8)); + subsd(xmm5, xmm3); + subsd(xmm3, xmm4); + addsd(xmm1, Address(eax, 16)); + mulpd(xmm6, xmm2); + addsd(xmm5, xmm0); + addsd(xmm3, xmm7); + addsd(xmm1, xmm5); + addsd(xmm1, xmm3); + addsd(xmm1, xmm6); + unpckhpd(xmm6, xmm6); + addsd(xmm1, xmm6); + addsd(xmm4, xmm1); + movsd(Address(rsp, 0), xmm4); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_0_0_2); + jcc(Assembler::greater, L_2TAG_PACKET_2_0_2); + pextrw(eax, xmm0, 3); + andl(eax, 32767); + pinsrw(xmm0, eax, 3); + movsd(xmm1, Address(tmp, 2192)); + subsd(xmm1, xmm0); + movsd(Address(rsp, 0), xmm1); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_2_0_2); + movl(eax, Address(rsp, 132)); + andl(eax, 2146435072); + cmpl(eax, 2146435072); + jcc(Assembler::equal, L_2TAG_PACKET_3_0_2); + subl(rsp, 32); + movsd(Address(rsp, 0), xmm0); + lea(eax, Address(rsp, 40)); + movl(Address(rsp, 8), eax); + movl(eax, 1); + movl(Address(rsp, 12), eax); + call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_sin_cos_huge()))); + addl(rsp, 32); + fld_d(Address(rsp, 8)); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_3_0_2); + fld_d(Address(rsp, 128)); + fmul_d(Address(tmp, 2208)); + + bind(L_2TAG_PACKET_1_0_2); + movl(tmp, Address(rsp, 56)); +} +#endif diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_exp.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_exp.cpp new file mode 100644 index 00000000000..faea7b9434b --- /dev/null +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_exp.cpp @@ -0,0 +1,674 @@ +/* +* Copyright (c) 2016, Intel Corporation. +* Intel Math Library (LIBM) Source Code +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 only, as +* published by the Free Software Foundation. +* +* This code is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* version 2 for more details (a copy is included in the LICENSE file that +* accompanied this code). +* +* You should have received a copy of the GNU General Public License version +* 2 along with this work; if not, write to the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +* or visit www.oracle.com if you need additional information or have any +* questions. +* +*/ + +#include "precompiled.hpp" +#include "asm/assembler.hpp" +#include "asm/assembler.inline.hpp" +#include "runtime/stubRoutines.hpp" +#include "macroAssembler_x86.hpp" + +#ifdef _MSC_VER +#define ALIGNED_(x) __declspec(align(x)) +#else +#define ALIGNED_(x) __attribute__ ((aligned(x))) +#endif + +/******************************************************************************/ +// ALGORITHM DESCRIPTION - EXP() +// --------------------- +// +// Description: +// Let K = 64 (table size). +// x x/log(2) n +// e = 2 = 2 * T[j] * (1 + P(y)) +// where +// x = m*log(2)/K + y, y in [-log(2)/K..log(2)/K] +// m = n*K + j, m,n,j - signed integer, j in [-K/2..K/2] +// j/K +// values of 2 are tabulated as T[j] = T_hi[j] ( 1 + T_lo[j]). +// +// P(y) is a minimax polynomial approximation of exp(x)-1 +// on small interval [-log(2)/K..log(2)/K] (were calculated by Maple V). +// +// To avoid problems with arithmetic overflow and underflow, +// n n1 n2 +// value of 2 is safely computed as 2 * 2 where n1 in [-BIAS/2..BIAS/2] +// where BIAS is a value of exponent bias. +// +// Special cases: +// exp(NaN) = NaN +// exp(+INF) = +INF +// exp(-INF) = 0 +// exp(x) = 1 for subnormals +// for finite argument, only exp(0)=1 is exact +// For IEEE double +// if x > 709.782712893383973096 then exp(x) overflow +// if x < -745.133219101941108420 then exp(x) underflow +// +/******************************************************************************/ + +#ifdef _LP64 +// The 64 bit code is at most SSE2 compliant +ALIGNED_(16) juint _cv[] = +{ + 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL, 0xfefa0000UL, + 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL, 0xbc9e3b3aUL, 0x3d1cf79aUL, + 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL, + 0x3fdfffffUL, 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL, + 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL +}; + +ALIGNED_(16) juint _shifter[] = +{ + 0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL +}; + +ALIGNED_(16) juint _mmask[] = +{ + 0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL +}; + +ALIGNED_(16) juint _bias[] = +{ + 0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL +}; + +ALIGNED_(16) juint _Tbl_addr[] = +{ + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0e03754dUL, + 0x3cad7bbfUL, 0x3e778060UL, 0x00002c9aUL, 0x3567f613UL, 0x3c8cd252UL, + 0xd3158574UL, 0x000059b0UL, 0x61e6c861UL, 0x3c60f74eUL, 0x18759bc8UL, + 0x00008745UL, 0x5d837b6cUL, 0x3c979aa6UL, 0x6cf9890fUL, 0x0000b558UL, + 0x702f9cd1UL, 0x3c3ebe3dUL, 0x32d3d1a2UL, 0x0000e3ecUL, 0x1e63bcd8UL, + 0x3ca3516eUL, 0xd0125b50UL, 0x00011301UL, 0x26f0387bUL, 0x3ca4c554UL, + 0xaea92ddfUL, 0x0001429aUL, 0x62523fb6UL, 0x3ca95153UL, 0x3c7d517aUL, + 0x000172b8UL, 0x3f1353bfUL, 0x3c8b898cUL, 0xeb6fcb75UL, 0x0001a35bUL, + 0x3e3a2f5fUL, 0x3c9aecf7UL, 0x3168b9aaUL, 0x0001d487UL, 0x44a6c38dUL, + 0x3c8a6f41UL, 0x88628cd6UL, 0x0002063bUL, 0xe3a8a894UL, 0x3c968efdUL, + 0x6e756238UL, 0x0002387aUL, 0x981fe7f2UL, 0x3c80472bUL, 0x65e27cddUL, + 0x00026b45UL, 0x6d09ab31UL, 0x3c82f7e1UL, 0xf51fdee1UL, 0x00029e9dUL, + 0x720c0ab3UL, 0x3c8b3782UL, 0xa6e4030bUL, 0x0002d285UL, 0x4db0abb6UL, + 0x3c834d75UL, 0x0a31b715UL, 0x000306feUL, 0x5dd3f84aUL, 0x3c8fdd39UL, + 0xb26416ffUL, 0x00033c08UL, 0xcc187d29UL, 0x3ca12f8cUL, 0x373aa9caUL, + 0x000371a7UL, 0x738b5e8bUL, 0x3ca7d229UL, 0x34e59ff6UL, 0x0003a7dbUL, + 0xa72a4c6dUL, 0x3c859f48UL, 0x4c123422UL, 0x0003dea6UL, 0x259d9205UL, + 0x3ca8b846UL, 0x21f72e29UL, 0x0004160aUL, 0x60c2ac12UL, 0x3c4363edUL, + 0x6061892dUL, 0x00044e08UL, 0xdaa10379UL, 0x3c6ecce1UL, 0xb5c13cd0UL, + 0x000486a2UL, 0xbb7aafb0UL, 0x3c7690ceUL, 0xd5362a27UL, 0x0004bfdaUL, + 0x9b282a09UL, 0x3ca083ccUL, 0x769d2ca6UL, 0x0004f9b2UL, 0xc1aae707UL, + 0x3ca509b0UL, 0x569d4f81UL, 0x0005342bUL, 0x18fdd78eUL, 0x3c933505UL, + 0x36b527daUL, 0x00056f47UL, 0xe21c5409UL, 0x3c9063e1UL, 0xdd485429UL, + 0x0005ab07UL, 0x2b64c035UL, 0x3c9432e6UL, 0x15ad2148UL, 0x0005e76fUL, + 0x99f08c0aUL, 0x3ca01284UL, 0xb03a5584UL, 0x0006247eUL, 0x0073dc06UL, + 0x3c99f087UL, 0x82552224UL, 0x00066238UL, 0x0da05571UL, 0x3c998d4dUL, + 0x667f3bccUL, 0x0006a09eUL, 0x86ce4786UL, 0x3ca52bb9UL, 0x3c651a2eUL, + 0x0006dfb2UL, 0x206f0dabUL, 0x3ca32092UL, 0xe8ec5f73UL, 0x00071f75UL, + 0x8e17a7a6UL, 0x3ca06122UL, 0x564267c8UL, 0x00075febUL, 0x461e9f86UL, + 0x3ca244acUL, 0x73eb0186UL, 0x0007a114UL, 0xabd66c55UL, 0x3c65ebe1UL, + 0x36cf4e62UL, 0x0007e2f3UL, 0xbbff67d0UL, 0x3c96fe9fUL, 0x994cce12UL, + 0x00082589UL, 0x14c801dfUL, 0x3c951f14UL, 0x9b4492ecUL, 0x000868d9UL, + 0xc1f0eab4UL, 0x3c8db72fUL, 0x422aa0dbUL, 0x0008ace5UL, 0x59f35f44UL, + 0x3c7bf683UL, 0x99157736UL, 0x0008f1aeUL, 0x9c06283cUL, 0x3ca360baUL, + 0xb0cdc5e4UL, 0x00093737UL, 0x20f962aaUL, 0x3c95e8d1UL, 0x9fde4e4fUL, + 0x00097d82UL, 0x2b91ce27UL, 0x3c71affcUL, 0x82a3f090UL, 0x0009c491UL, + 0x589a2ebdUL, 0x3c9b6d34UL, 0x7b5de564UL, 0x000a0c66UL, 0x9ab89880UL, + 0x3c95277cUL, 0xb23e255cUL, 0x000a5503UL, 0x6e735ab3UL, 0x3c846984UL, + 0x5579fdbfUL, 0x000a9e6bUL, 0x92cb3387UL, 0x3c8c1a77UL, 0x995ad3adUL, + 0x000ae89fUL, 0xdc2d1d96UL, 0x3ca22466UL, 0xb84f15faUL, 0x000b33a2UL, + 0xb19505aeUL, 0x3ca1112eUL, 0xf2fb5e46UL, 0x000b7f76UL, 0x0a5fddcdUL, + 0x3c74ffd7UL, 0x904bc1d2UL, 0x000bcc1eUL, 0x30af0cb3UL, 0x3c736eaeUL, + 0xdd85529cUL, 0x000c199bUL, 0xd10959acUL, 0x3c84e08fUL, 0x2e57d14bUL, + 0x000c67f1UL, 0x6c921968UL, 0x3c676b2cUL, 0xdcef9069UL, 0x000cb720UL, + 0x36df99b3UL, 0x3c937009UL, 0x4a07897bUL, 0x000d072dUL, 0xa63d07a7UL, + 0x3c74a385UL, 0xdcfba487UL, 0x000d5818UL, 0xd5c192acUL, 0x3c8e5a50UL, + 0x03db3285UL, 0x000da9e6UL, 0x1c4a9792UL, 0x3c98bb73UL, 0x337b9b5eUL, + 0x000dfc97UL, 0x603a88d3UL, 0x3c74b604UL, 0xe78b3ff6UL, 0x000e502eUL, + 0x92094926UL, 0x3c916f27UL, 0xa2a490d9UL, 0x000ea4afUL, 0x41aa2008UL, + 0x3c8ec3bcUL, 0xee615a27UL, 0x000efa1bUL, 0x31d185eeUL, 0x3c8a64a9UL, + 0x5b6e4540UL, 0x000f5076UL, 0x4d91cd9dUL, 0x3c77893bUL, 0x819e90d8UL, + 0x000fa7c1UL +}; + +ALIGNED_(16) juint _ALLONES[] = +{ + 0xffffffffUL, 0xffffffffUL, 0xffffffffUL, 0xffffffffUL +}; + +ALIGNED_(16) juint _ebias[] = +{ + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3ff00000UL +}; + +ALIGNED_(4) juint _XMAX[] = +{ + 0xffffffffUL, 0x7fefffffUL +}; + +ALIGNED_(4) juint _XMIN[] = +{ + 0x00000000UL, 0x00100000UL +}; + +ALIGNED_(4) juint _INF[] = +{ + 0x00000000UL, 0x7ff00000UL +}; + +ALIGNED_(4) juint _ZERO[] = +{ + 0x00000000UL, 0x00000000UL +}; + +ALIGNED_(4) juint _ONE_val[] = +{ + 0x00000000UL, 0x3ff00000UL +}; + + +// Registers: +// input: xmm0 +// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 +// rax, rdx, rcx, tmp - r11 + +// Code generated by Intel C compiler for LIBM library + +void MacroAssembler::fast_exp(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) { + Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; + Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; + Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2; + Label L_2TAG_PACKET_12_0_2, B1_3, B1_5, start; + + assert_different_registers(tmp, eax, ecx, edx); + jmp(start); + address cv = (address)_cv; + address Shifter = (address)_shifter; + address mmask = (address)_mmask; + address bias = (address)_bias; + address Tbl_addr = (address)_Tbl_addr; + address ALLONES = (address)_ALLONES; + address ebias = (address)_ebias; + address XMAX = (address)_XMAX; + address XMIN = (address)_XMIN; + address INF = (address)_INF; + address ZERO = (address)_ZERO; + address ONE_val = (address)_ONE_val; + + bind(start); + subq(rsp, 24); + movsd(Address(rsp, 8), xmm0); + unpcklpd(xmm0, xmm0); + movdqu(xmm1, ExternalAddress(cv)); // 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL + movdqu(xmm6, ExternalAddress(Shifter)); // 0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL + movdqu(xmm2, ExternalAddress(16 + cv)); // 0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL + movdqu(xmm3, ExternalAddress(32 + cv)); // 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL + pextrw(eax, xmm0, 3); + andl(eax, 32767); + movl(edx, 16527); + subl(edx, eax); + subl(eax, 15504); + orl(edx, eax); + cmpl(edx, INT_MIN); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); + mulpd(xmm1, xmm0); + addpd(xmm1, xmm6); + movapd(xmm7, xmm1); + subpd(xmm1, xmm6); + mulpd(xmm2, xmm1); + movdqu(xmm4, ExternalAddress(64 + cv)); // 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL + mulpd(xmm3, xmm1); + movdqu(xmm5, ExternalAddress(80 + cv)); // 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL + subpd(xmm0, xmm2); + movdl(eax, xmm7); + movl(ecx, eax); + andl(ecx, 63); + shll(ecx, 4); + sarl(eax, 6); + movl(edx, eax); + movdqu(xmm6, ExternalAddress(mmask)); // 0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL + pand(xmm7, xmm6); + movdqu(xmm6, ExternalAddress(bias)); // 0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL + paddq(xmm7, xmm6); + psllq(xmm7, 46); + subpd(xmm0, xmm3); + lea(tmp, ExternalAddress(Tbl_addr)); + movdqu(xmm2, Address(ecx, tmp)); + mulpd(xmm4, xmm0); + movapd(xmm6, xmm0); + movapd(xmm1, xmm0); + mulpd(xmm6, xmm6); + mulpd(xmm0, xmm6); + addpd(xmm5, xmm4); + mulsd(xmm0, xmm6); + mulpd(xmm6, ExternalAddress(48 + cv)); // 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL, 0x3fdfffffUL + addsd(xmm1, xmm2); + unpckhpd(xmm2, xmm2); + mulpd(xmm0, xmm5); + addsd(xmm1, xmm0); + por(xmm2, xmm7); + unpckhpd(xmm0, xmm0); + addsd(xmm0, xmm1); + addsd(xmm0, xmm6); + addl(edx, 894); + cmpl(edx, 1916); + jcc(Assembler::above, L_2TAG_PACKET_1_0_2); + mulsd(xmm0, xmm2); + addsd(xmm0, xmm2); + jmp(B1_5); + + bind(L_2TAG_PACKET_1_0_2); + xorpd(xmm3, xmm3); + movdqu(xmm4, ExternalAddress(ALLONES)); // 0xffffffffUL, 0xffffffffUL, 0xffffffffUL, 0xffffffffUL + movl(edx, -1022); + subl(edx, eax); + movdl(xmm5, edx); + psllq(xmm4, xmm5); + movl(ecx, eax); + sarl(eax, 1); + pinsrw(xmm3, eax, 3); + movdqu(xmm6, ExternalAddress(ebias)); // 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3ff00000UL + psllq(xmm3, 4); + psubd(xmm2, xmm3); + mulsd(xmm0, xmm2); + cmpl(edx, 52); + jcc(Assembler::greater, L_2TAG_PACKET_2_0_2); + pand(xmm4, xmm2); + paddd(xmm3, xmm6); + subsd(xmm2, xmm4); + addsd(xmm0, xmm2); + cmpl(ecx, 1023); + jcc(Assembler::greaterEqual, L_2TAG_PACKET_3_0_2); + pextrw(ecx, xmm0, 3); + andl(ecx, 32768); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_4_0_2); + movapd(xmm6, xmm0); + addsd(xmm0, xmm4); + mulsd(xmm0, xmm3); + pextrw(ecx, xmm0, 3); + andl(ecx, 32752); + cmpl(ecx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_5_0_2); + jmp(B1_5); + + bind(L_2TAG_PACKET_5_0_2); + mulsd(xmm6, xmm3); + mulsd(xmm4, xmm3); + movdqu(xmm0, xmm6); + pxor(xmm6, xmm4); + psrad(xmm6, 31); + pshufd(xmm6, xmm6, 85); + psllq(xmm0, 1); + psrlq(xmm0, 1); + pxor(xmm0, xmm6); + psrlq(xmm6, 63); + paddq(xmm0, xmm6); + paddq(xmm0, xmm4); + movl(Address(rsp, 0), 15); + jmp(L_2TAG_PACKET_6_0_2); + + bind(L_2TAG_PACKET_4_0_2); + addsd(xmm0, xmm4); + mulsd(xmm0, xmm3); + jmp(B1_5); + + bind(L_2TAG_PACKET_3_0_2); + addsd(xmm0, xmm4); + mulsd(xmm0, xmm3); + pextrw(ecx, xmm0, 3); + andl(ecx, 32752); + cmpl(ecx, 32752); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_7_0_2); + jmp(B1_5); + + bind(L_2TAG_PACKET_2_0_2); + paddd(xmm3, xmm6); + addpd(xmm0, xmm2); + mulsd(xmm0, xmm3); + movl(Address(rsp, 0), 15); + jmp(L_2TAG_PACKET_6_0_2); + + bind(L_2TAG_PACKET_8_0_2); + cmpl(eax, 2146435072); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_9_0_2); + movl(eax, Address(rsp, 12)); + cmpl(eax, INT_MIN); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_10_0_2); + movsd(xmm0, ExternalAddress(XMAX)); // 0xffffffffUL, 0x7fefffffUL + mulsd(xmm0, xmm0); + + bind(L_2TAG_PACKET_7_0_2); + movl(Address(rsp, 0), 14); + jmp(L_2TAG_PACKET_6_0_2); + + bind(L_2TAG_PACKET_10_0_2); + movsd(xmm0, ExternalAddress(XMIN)); // 0x00000000UL, 0x00100000UL + mulsd(xmm0, xmm0); + movl(Address(rsp, 0), 15); + jmp(L_2TAG_PACKET_6_0_2); + + bind(L_2TAG_PACKET_9_0_2); + movl(edx, Address(rsp, 8)); + cmpl(eax, 2146435072); + jcc(Assembler::above, L_2TAG_PACKET_11_0_2); + cmpl(edx, 0); + jcc(Assembler::notEqual, L_2TAG_PACKET_11_0_2); + movl(eax, Address(rsp, 12)); + cmpl(eax, 2146435072); + jcc(Assembler::notEqual, L_2TAG_PACKET_12_0_2); + movsd(xmm0, ExternalAddress(INF)); // 0x00000000UL, 0x7ff00000UL + jmp(B1_5); + + bind(L_2TAG_PACKET_12_0_2); + movsd(xmm0, ExternalAddress(ZERO)); // 0x00000000UL, 0x00000000UL + jmp(B1_5); + + bind(L_2TAG_PACKET_11_0_2); + movsd(xmm0, Address(rsp, 8)); + addsd(xmm0, xmm0); + jmp(B1_5); + + bind(L_2TAG_PACKET_0_0_2); + movl(eax, Address(rsp, 12)); + andl(eax, 2147483647); + cmpl(eax, 1083179008); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_8_0_2); + movsd(Address(rsp, 8), xmm0); + addsd(xmm0, ExternalAddress(ONE_val)); // 0x00000000UL, 0x3ff00000UL + jmp(B1_5); + + bind(L_2TAG_PACKET_6_0_2); + movq(Address(rsp, 16), xmm0); + + bind(B1_3); + movq(xmm0, Address(rsp, 16)); + + bind(B1_5); + addq(rsp, 24); +} +#else +// The 32 bit code is at most SSE2 compliant +ALIGNED_(16) juint _static_const_table[] = +{ + 0x00000000UL, 0xfff00000UL, 0x00000000UL, 0xfff00000UL, 0xffffffc0UL, + 0x00000000UL, 0xffffffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL, + 0x0000ffc0UL, 0x00000000UL, 0x00000000UL, 0x43380000UL, 0x00000000UL, + 0x43380000UL, 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL, + 0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL, 0xbc9e3b3aUL, + 0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xfffffffeUL, 0x3fdfffffUL, + 0xfffffffeUL, 0x3fdfffffUL, 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, + 0x3fa55555UL, 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x0e03754dUL, + 0x3cad7bbfUL, 0x3e778060UL, 0x00002c9aUL, 0x3567f613UL, 0x3c8cd252UL, + 0xd3158574UL, 0x000059b0UL, 0x61e6c861UL, 0x3c60f74eUL, 0x18759bc8UL, + 0x00008745UL, 0x5d837b6cUL, 0x3c979aa6UL, 0x6cf9890fUL, 0x0000b558UL, + 0x702f9cd1UL, 0x3c3ebe3dUL, 0x32d3d1a2UL, 0x0000e3ecUL, 0x1e63bcd8UL, + 0x3ca3516eUL, 0xd0125b50UL, 0x00011301UL, 0x26f0387bUL, 0x3ca4c554UL, + 0xaea92ddfUL, 0x0001429aUL, 0x62523fb6UL, 0x3ca95153UL, 0x3c7d517aUL, + 0x000172b8UL, 0x3f1353bfUL, 0x3c8b898cUL, 0xeb6fcb75UL, 0x0001a35bUL, + 0x3e3a2f5fUL, 0x3c9aecf7UL, 0x3168b9aaUL, 0x0001d487UL, 0x44a6c38dUL, + 0x3c8a6f41UL, 0x88628cd6UL, 0x0002063bUL, 0xe3a8a894UL, 0x3c968efdUL, + 0x6e756238UL, 0x0002387aUL, 0x981fe7f2UL, 0x3c80472bUL, 0x65e27cddUL, + 0x00026b45UL, 0x6d09ab31UL, 0x3c82f7e1UL, 0xf51fdee1UL, 0x00029e9dUL, + 0x720c0ab3UL, 0x3c8b3782UL, 0xa6e4030bUL, 0x0002d285UL, 0x4db0abb6UL, + 0x3c834d75UL, 0x0a31b715UL, 0x000306feUL, 0x5dd3f84aUL, 0x3c8fdd39UL, + 0xb26416ffUL, 0x00033c08UL, 0xcc187d29UL, 0x3ca12f8cUL, 0x373aa9caUL, + 0x000371a7UL, 0x738b5e8bUL, 0x3ca7d229UL, 0x34e59ff6UL, 0x0003a7dbUL, + 0xa72a4c6dUL, 0x3c859f48UL, 0x4c123422UL, 0x0003dea6UL, 0x259d9205UL, + 0x3ca8b846UL, 0x21f72e29UL, 0x0004160aUL, 0x60c2ac12UL, 0x3c4363edUL, + 0x6061892dUL, 0x00044e08UL, 0xdaa10379UL, 0x3c6ecce1UL, 0xb5c13cd0UL, + 0x000486a2UL, 0xbb7aafb0UL, 0x3c7690ceUL, 0xd5362a27UL, 0x0004bfdaUL, + 0x9b282a09UL, 0x3ca083ccUL, 0x769d2ca6UL, 0x0004f9b2UL, 0xc1aae707UL, + 0x3ca509b0UL, 0x569d4f81UL, 0x0005342bUL, 0x18fdd78eUL, 0x3c933505UL, + 0x36b527daUL, 0x00056f47UL, 0xe21c5409UL, 0x3c9063e1UL, 0xdd485429UL, + 0x0005ab07UL, 0x2b64c035UL, 0x3c9432e6UL, 0x15ad2148UL, 0x0005e76fUL, + 0x99f08c0aUL, 0x3ca01284UL, 0xb03a5584UL, 0x0006247eUL, 0x0073dc06UL, + 0x3c99f087UL, 0x82552224UL, 0x00066238UL, 0x0da05571UL, 0x3c998d4dUL, + 0x667f3bccUL, 0x0006a09eUL, 0x86ce4786UL, 0x3ca52bb9UL, 0x3c651a2eUL, + 0x0006dfb2UL, 0x206f0dabUL, 0x3ca32092UL, 0xe8ec5f73UL, 0x00071f75UL, + 0x8e17a7a6UL, 0x3ca06122UL, 0x564267c8UL, 0x00075febUL, 0x461e9f86UL, + 0x3ca244acUL, 0x73eb0186UL, 0x0007a114UL, 0xabd66c55UL, 0x3c65ebe1UL, + 0x36cf4e62UL, 0x0007e2f3UL, 0xbbff67d0UL, 0x3c96fe9fUL, 0x994cce12UL, + 0x00082589UL, 0x14c801dfUL, 0x3c951f14UL, 0x9b4492ecUL, 0x000868d9UL, + 0xc1f0eab4UL, 0x3c8db72fUL, 0x422aa0dbUL, 0x0008ace5UL, 0x59f35f44UL, + 0x3c7bf683UL, 0x99157736UL, 0x0008f1aeUL, 0x9c06283cUL, 0x3ca360baUL, + 0xb0cdc5e4UL, 0x00093737UL, 0x20f962aaUL, 0x3c95e8d1UL, 0x9fde4e4fUL, + 0x00097d82UL, 0x2b91ce27UL, 0x3c71affcUL, 0x82a3f090UL, 0x0009c491UL, + 0x589a2ebdUL, 0x3c9b6d34UL, 0x7b5de564UL, 0x000a0c66UL, 0x9ab89880UL, + 0x3c95277cUL, 0xb23e255cUL, 0x000a5503UL, 0x6e735ab3UL, 0x3c846984UL, + 0x5579fdbfUL, 0x000a9e6bUL, 0x92cb3387UL, 0x3c8c1a77UL, 0x995ad3adUL, + 0x000ae89fUL, 0xdc2d1d96UL, 0x3ca22466UL, 0xb84f15faUL, 0x000b33a2UL, + 0xb19505aeUL, 0x3ca1112eUL, 0xf2fb5e46UL, 0x000b7f76UL, 0x0a5fddcdUL, + 0x3c74ffd7UL, 0x904bc1d2UL, 0x000bcc1eUL, 0x30af0cb3UL, 0x3c736eaeUL, + 0xdd85529cUL, 0x000c199bUL, 0xd10959acUL, 0x3c84e08fUL, 0x2e57d14bUL, + 0x000c67f1UL, 0x6c921968UL, 0x3c676b2cUL, 0xdcef9069UL, 0x000cb720UL, + 0x36df99b3UL, 0x3c937009UL, 0x4a07897bUL, 0x000d072dUL, 0xa63d07a7UL, + 0x3c74a385UL, 0xdcfba487UL, 0x000d5818UL, 0xd5c192acUL, 0x3c8e5a50UL, + 0x03db3285UL, 0x000da9e6UL, 0x1c4a9792UL, 0x3c98bb73UL, 0x337b9b5eUL, + 0x000dfc97UL, 0x603a88d3UL, 0x3c74b604UL, 0xe78b3ff6UL, 0x000e502eUL, + 0x92094926UL, 0x3c916f27UL, 0xa2a490d9UL, 0x000ea4afUL, 0x41aa2008UL, + 0x3c8ec3bcUL, 0xee615a27UL, 0x000efa1bUL, 0x31d185eeUL, 0x3c8a64a9UL, + 0x5b6e4540UL, 0x000f5076UL, 0x4d91cd9dUL, 0x3c77893bUL, 0x819e90d8UL, + 0x000fa7c1UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x7ff00000UL, + 0x00000000UL, 0x00000000UL, 0xffffffffUL, 0x7fefffffUL, 0x00000000UL, + 0x00100000UL +}; + +//registers, +// input: (rbp + 8) +// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 +// rax, rdx, rcx, rbx (tmp) + +// Code generated by Intel C compiler for LIBM library + +void MacroAssembler::fast_exp(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) { + Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; + Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; + Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2; + Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start; + + assert_different_registers(tmp, eax, ecx, edx); + jmp(start); + address static_const_table = (address)_static_const_table; + + bind(start); + subl(rsp, 120); + movl(Address(rsp, 64), tmp); + lea(tmp, ExternalAddress(static_const_table)); + movdqu(xmm0, Address(rsp, 128)); + unpcklpd(xmm0, xmm0); + movdqu(xmm1, Address(tmp, 64)); // 0x652b82feUL, 0x40571547UL, 0x652b82feUL, 0x40571547UL + movdqu(xmm6, Address(tmp, 48)); // 0x00000000UL, 0x43380000UL, 0x00000000UL, 0x43380000UL + movdqu(xmm2, Address(tmp, 80)); // 0xfefa0000UL, 0x3f862e42UL, 0xfefa0000UL, 0x3f862e42UL + movdqu(xmm3, Address(tmp, 96)); // 0xbc9e3b3aUL, 0x3d1cf79aUL, 0xbc9e3b3aUL, 0x3d1cf79aUL + pextrw(eax, xmm0, 3); + andl(eax, 32767); + movl(edx, 16527); + subl(edx, eax); + subl(eax, 15504); + orl(edx, eax); + cmpl(edx, INT_MIN); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); + mulpd(xmm1, xmm0); + addpd(xmm1, xmm6); + movapd(xmm7, xmm1); + subpd(xmm1, xmm6); + mulpd(xmm2, xmm1); + movdqu(xmm4, Address(tmp, 128)); // 0xe3289860UL, 0x3f56c15cUL, 0x555b9e25UL, 0x3fa55555UL + mulpd(xmm3, xmm1); + movdqu(xmm5, Address(tmp, 144)); // 0xc090cf0fUL, 0x3f811115UL, 0x55548ba1UL, 0x3fc55555UL + subpd(xmm0, xmm2); + movdl(eax, xmm7); + movl(ecx, eax); + andl(ecx, 63); + shll(ecx, 4); + sarl(eax, 6); + movl(edx, eax); + movdqu(xmm6, Address(tmp, 16)); // 0xffffffc0UL, 0x00000000UL, 0xffffffc0UL, 0x00000000UL + pand(xmm7, xmm6); + movdqu(xmm6, Address(tmp, 32)); // 0x0000ffc0UL, 0x00000000UL, 0x0000ffc0UL, 0x00000000UL + paddq(xmm7, xmm6); + psllq(xmm7, 46); + subpd(xmm0, xmm3); + movdqu(xmm2, Address(tmp, ecx, Address::times_1, 160)); + mulpd(xmm4, xmm0); + movapd(xmm6, xmm0); + movapd(xmm1, xmm0); + mulpd(xmm6, xmm6); + mulpd(xmm0, xmm6); + addpd(xmm5, xmm4); + mulsd(xmm0, xmm6); + mulpd(xmm6, Address(tmp, 112)); // 0xfffffffeUL, 0x3fdfffffUL, 0xfffffffeUL, 0x3fdfffffUL + addsd(xmm1, xmm2); + unpckhpd(xmm2, xmm2); + mulpd(xmm0, xmm5); + addsd(xmm1, xmm0); + por(xmm2, xmm7); + unpckhpd(xmm0, xmm0); + addsd(xmm0, xmm1); + addsd(xmm0, xmm6); + addl(edx, 894); + cmpl(edx, 1916); + jcc(Assembler::above, L_2TAG_PACKET_1_0_2); + mulsd(xmm0, xmm2); + addsd(xmm0, xmm2); + jmp(L_2TAG_PACKET_2_0_2); + + bind(L_2TAG_PACKET_1_0_2); + fnstcw(Address(rsp, 24)); + movzwl(edx, Address(rsp, 24)); + orl(edx, 768); + movw(Address(rsp, 28), edx); + fldcw(Address(rsp, 28)); + movl(edx, eax); + sarl(eax, 1); + subl(edx, eax); + movdqu(xmm6, Address(tmp, 0)); // 0x00000000UL, 0xfff00000UL, 0x00000000UL, 0xfff00000UL + pandn(xmm6, xmm2); + addl(eax, 1023); + movdl(xmm3, eax); + psllq(xmm3, 52); + por(xmm6, xmm3); + addl(edx, 1023); + movdl(xmm4, edx); + psllq(xmm4, 52); + movsd(Address(rsp, 8), xmm0); + fld_d(Address(rsp, 8)); + movsd(Address(rsp, 16), xmm6); + fld_d(Address(rsp, 16)); + fmula(1); + faddp(1); + movsd(Address(rsp, 8), xmm4); + fld_d(Address(rsp, 8)); + fmulp(1); + fstp_d(Address(rsp, 8)); + movsd(xmm0, Address(rsp, 8)); + fldcw(Address(rsp, 24)); + pextrw(ecx, xmm0, 3); + andl(ecx, 32752); + cmpl(ecx, 32752); + jcc(Assembler::greaterEqual, L_2TAG_PACKET_3_0_2); + cmpl(ecx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_4_0_2); + jmp(L_2TAG_PACKET_2_0_2); + cmpl(ecx, INT_MIN); + jcc(Assembler::less, L_2TAG_PACKET_3_0_2); + cmpl(ecx, -1064950997); + jcc(Assembler::less, L_2TAG_PACKET_2_0_2); + jcc(Assembler::greater, L_2TAG_PACKET_4_0_2); + movl(edx, Address(rsp, 128)); + cmpl(edx, -17155601); + jcc(Assembler::less, L_2TAG_PACKET_2_0_2); + jmp(L_2TAG_PACKET_4_0_2); + + bind(L_2TAG_PACKET_3_0_2); + movl(edx, 14); + jmp(L_2TAG_PACKET_5_0_2); + + bind(L_2TAG_PACKET_4_0_2); + movl(edx, 15); + + bind(L_2TAG_PACKET_5_0_2); + movsd(Address(rsp, 0), xmm0); + movsd(xmm0, Address(rsp, 128)); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_6_0_2); + + bind(L_2TAG_PACKET_7_0_2); + cmpl(eax, 2146435072); + jcc(Assembler::greaterEqual, L_2TAG_PACKET_8_0_2); + movl(eax, Address(rsp, 132)); + cmpl(eax, INT_MIN); + jcc(Assembler::greaterEqual, L_2TAG_PACKET_9_0_2); + movsd(xmm0, Address(tmp, 1208)); // 0xffffffffUL, 0x7fefffffUL + mulsd(xmm0, xmm0); + movl(edx, 14); + jmp(L_2TAG_PACKET_5_0_2); + + bind(L_2TAG_PACKET_9_0_2); + movsd(xmm0, Address(tmp, 1216)); + mulsd(xmm0, xmm0); + movl(edx, 15); + jmp(L_2TAG_PACKET_5_0_2); + + bind(L_2TAG_PACKET_8_0_2); + movl(edx, Address(rsp, 128)); + cmpl(eax, 2146435072); + jcc(Assembler::above, L_2TAG_PACKET_10_0_2); + cmpl(edx, 0); + jcc(Assembler::notEqual, L_2TAG_PACKET_10_0_2); + movl(eax, Address(rsp, 132)); + cmpl(eax, 2146435072); + jcc(Assembler::notEqual, L_2TAG_PACKET_11_0_2); + movsd(xmm0, Address(tmp, 1192)); // 0x00000000UL, 0x7ff00000UL + jmp(L_2TAG_PACKET_2_0_2); + + bind(L_2TAG_PACKET_11_0_2); + movsd(xmm0, Address(tmp, 1200)); // 0x00000000UL, 0x00000000UL + jmp(L_2TAG_PACKET_2_0_2); + + bind(L_2TAG_PACKET_10_0_2); + movsd(xmm0, Address(rsp, 128)); + addsd(xmm0, xmm0); + jmp(L_2TAG_PACKET_2_0_2); + + bind(L_2TAG_PACKET_0_0_2); + movl(eax, Address(rsp, 132)); + andl(eax, 2147483647); + cmpl(eax, 1083179008); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_7_0_2); + movsd(xmm0, Address(rsp, 128)); + addsd(xmm0, Address(tmp, 1184)); // 0x00000000UL, 0x3ff00000UL + jmp(L_2TAG_PACKET_2_0_2); + + bind(L_2TAG_PACKET_2_0_2); + movsd(Address(rsp, 48), xmm0); + fld_d(Address(rsp, 48)); + + bind(L_2TAG_PACKET_6_0_2); + movl(tmp, Address(rsp, 64)); +} +#endif diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_log.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_log.cpp new file mode 100644 index 00000000000..cd4ed0d79d8 --- /dev/null +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_log.cpp @@ -0,0 +1,655 @@ +/* +* Copyright (c) 2016, Intel Corporation. +* Intel Math Library (LIBM) Source Code +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 only, as +* published by the Free Software Foundation. +* +* This code is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* version 2 for more details (a copy is included in the LICENSE file that +* accompanied this code). +* +* You should have received a copy of the GNU General Public License version +* 2 along with this work; if not, write to the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +* or visit www.oracle.com if you need additional information or have any +* questions. +* +*/ + +#include "precompiled.hpp" +#include "asm/assembler.hpp" +#include "asm/assembler.inline.hpp" +#include "macroAssembler_x86.hpp" + +#ifdef _MSC_VER +#define ALIGNED_(x) __declspec(align(x)) +#else +#define ALIGNED_(x) __attribute__ ((aligned(x))) +#endif + +/******************************************************************************/ +// ALGORITHM DESCRIPTION - LOG() +// --------------------- +// +// x=2^k * mx, mx in [1,2) +// +// Get B~1/mx based on the output of rcpss instruction (B0) +// B = int((B0*2^7+0.5))/2^7 +// +// Reduced argument: r=B*mx-1.0 (computed accurately in high and low parts) +// +// Result: k*log(2) - log(B) + p(r) if |x-1| >= small value (2^-6) and +// p(r) is a degree 7 polynomial +// -log(B) read from data table (high, low parts) +// Result is formed from high and low parts +// +// Special cases: +// log(NaN) = quiet NaN, and raise invalid exception +// log(+INF) = that INF +// log(0) = -INF with divide-by-zero exception raised +// log(1) = +0 +// log(x) = NaN with invalid exception raised if x < -0, including -INF +// +/******************************************************************************/ + +#ifdef _LP64 +// The 64 bit code is at most SSE2 compliant +ALIGNED_(16) juint _L_tbl[] = +{ + 0xfefa3800UL, 0x3fe62e42UL, 0x93c76730UL, 0x3d2ef357UL, 0xaa241800UL, + 0x3fe5ee82UL, 0x0cda46beUL, 0x3d220238UL, 0x5c364800UL, 0x3fe5af40UL, + 0xac10c9fbUL, 0x3d2dfa63UL, 0x26bb8c00UL, 0x3fe5707aUL, 0xff3303ddUL, + 0x3d09980bUL, 0x26867800UL, 0x3fe5322eUL, 0x5d257531UL, 0x3d05ccc4UL, + 0x835a5000UL, 0x3fe4f45aUL, 0x6d93b8fbUL, 0xbd2e6c51UL, 0x6f970c00UL, + 0x3fe4b6fdUL, 0xed4c541cUL, 0x3cef7115UL, 0x27e8a400UL, 0x3fe47a15UL, + 0xf94d60aaUL, 0xbd22cb6aUL, 0xf2f92400UL, 0x3fe43d9fUL, 0x481051f7UL, + 0xbcfd984fUL, 0x2125cc00UL, 0x3fe4019cUL, 0x30f0c74cUL, 0xbd26ce79UL, + 0x0c36c000UL, 0x3fe3c608UL, 0x7cfe13c2UL, 0xbd02b736UL, 0x17197800UL, + 0x3fe38ae2UL, 0xbb5569a4UL, 0xbd218b7aUL, 0xad9d8c00UL, 0x3fe35028UL, + 0x9527e6acUL, 0x3d10b83fUL, 0x44340800UL, 0x3fe315daUL, 0xc5a0ed9cUL, + 0xbd274e93UL, 0x57b0e000UL, 0x3fe2dbf5UL, 0x07b9dc11UL, 0xbd17a6e5UL, + 0x6d0ec000UL, 0x3fe2a278UL, 0xe797882dUL, 0x3d206d2bUL, 0x1134dc00UL, + 0x3fe26962UL, 0x05226250UL, 0xbd0b61f1UL, 0xd8bebc00UL, 0x3fe230b0UL, + 0x6e48667bUL, 0x3d12fc06UL, 0x5fc61800UL, 0x3fe1f863UL, 0xc9fe81d3UL, + 0xbd2a7242UL, 0x49ae6000UL, 0x3fe1c078UL, 0xed70e667UL, 0x3cccacdeUL, + 0x40f23c00UL, 0x3fe188eeUL, 0xf8ab4650UL, 0x3d14cc4eUL, 0xf6f29800UL, + 0x3fe151c3UL, 0xa293ae49UL, 0xbd2edd97UL, 0x23c75c00UL, 0x3fe11af8UL, + 0xbb9ddcb2UL, 0xbd258647UL, 0x8611cc00UL, 0x3fe0e489UL, 0x07801742UL, + 0x3d1c2998UL, 0xe2d05400UL, 0x3fe0ae76UL, 0x887e7e27UL, 0x3d1f486bUL, + 0x0533c400UL, 0x3fe078bfUL, 0x41edf5fdUL, 0x3d268122UL, 0xbe760400UL, + 0x3fe04360UL, 0xe79539e0UL, 0xbd04c45fUL, 0xe5b20800UL, 0x3fe00e5aUL, + 0xb1727b1cUL, 0xbd053ba3UL, 0xaf7a4800UL, 0x3fdfb358UL, 0x3c164935UL, + 0x3d0085faUL, 0xee031800UL, 0x3fdf4aa7UL, 0x6f014a8bUL, 0x3d12cde5UL, + 0x56b41000UL, 0x3fdee2a1UL, 0x5a470251UL, 0x3d2f27f4UL, 0xc3ddb000UL, + 0x3fde7b42UL, 0x5372bd08UL, 0xbd246550UL, 0x1a272800UL, 0x3fde148aUL, + 0x07322938UL, 0xbd1326b2UL, 0x484c9800UL, 0x3fddae75UL, 0x60dc616aUL, + 0xbd1ea42dUL, 0x46def800UL, 0x3fdd4902UL, 0xe9a767a8UL, 0x3d235bafUL, + 0x18064800UL, 0x3fdce42fUL, 0x3ec7a6b0UL, 0xbd0797c3UL, 0xc7455800UL, + 0x3fdc7ff9UL, 0xc15249aeUL, 0xbd29b6ddUL, 0x693fa000UL, 0x3fdc1c60UL, + 0x7fe8e180UL, 0x3d2cec80UL, 0x1b80e000UL, 0x3fdbb961UL, 0xf40a666dUL, + 0x3d27d85bUL, 0x04462800UL, 0x3fdb56faUL, 0x2d841995UL, 0x3d109525UL, + 0x5248d000UL, 0x3fdaf529UL, 0x52774458UL, 0xbd217cc5UL, 0x3c8ad800UL, + 0x3fda93edUL, 0xbea77a5dUL, 0x3d1e36f2UL, 0x0224f800UL, 0x3fda3344UL, + 0x7f9d79f5UL, 0x3d23c645UL, 0xea15f000UL, 0x3fd9d32bUL, 0x10d0c0b0UL, + 0xbd26279eUL, 0x43135800UL, 0x3fd973a3UL, 0xa502d9f0UL, 0xbd152313UL, + 0x635bf800UL, 0x3fd914a8UL, 0x2ee6307dUL, 0xbd1766b5UL, 0xa88b3000UL, + 0x3fd8b639UL, 0xe5e70470UL, 0xbd205ae1UL, 0x776dc800UL, 0x3fd85855UL, + 0x3333778aUL, 0x3d2fd56fUL, 0x3bd81800UL, 0x3fd7fafaUL, 0xc812566aUL, + 0xbd272090UL, 0x687cf800UL, 0x3fd79e26UL, 0x2efd1778UL, 0x3d29ec7dUL, + 0x76c67800UL, 0x3fd741d8UL, 0x49dc60b3UL, 0x3d2d8b09UL, 0xe6af1800UL, + 0x3fd6e60eUL, 0x7c222d87UL, 0x3d172165UL, 0x3e9c6800UL, 0x3fd68ac8UL, + 0x2756eba0UL, 0x3d20a0d3UL, 0x0b3ab000UL, 0x3fd63003UL, 0xe731ae00UL, + 0xbd2db623UL, 0xdf596000UL, 0x3fd5d5bdUL, 0x08a465dcUL, 0xbd0a0b2aUL, + 0x53c8d000UL, 0x3fd57bf7UL, 0xee5d40efUL, 0x3d1fadedUL, 0x0738a000UL, + 0x3fd522aeUL, 0x8164c759UL, 0x3d2ebe70UL, 0x9e173000UL, 0x3fd4c9e0UL, + 0x1b0ad8a4UL, 0xbd2e2089UL, 0xc271c800UL, 0x3fd4718dUL, 0x0967d675UL, + 0xbd2f27ceUL, 0x23d5e800UL, 0x3fd419b4UL, 0xec90e09dUL, 0x3d08e436UL, + 0x77333000UL, 0x3fd3c252UL, 0xb606bd5cUL, 0x3d183b54UL, 0x76be1000UL, + 0x3fd36b67UL, 0xb0f177c8UL, 0x3d116ecdUL, 0xe1d36000UL, 0x3fd314f1UL, + 0xd3213cb8UL, 0xbd28e27aUL, 0x7cdc9000UL, 0x3fd2bef0UL, 0x4a5004f4UL, + 0x3d2a9cfaUL, 0x1134d800UL, 0x3fd26962UL, 0xdf5bb3b6UL, 0x3d2c93c1UL, + 0x6d0eb800UL, 0x3fd21445UL, 0xba46baeaUL, 0x3d0a87deUL, 0x635a6800UL, + 0x3fd1bf99UL, 0x5147bdb7UL, 0x3d2ca6edUL, 0xcbacf800UL, 0x3fd16b5cUL, + 0xf7a51681UL, 0x3d2b9acdUL, 0x8227e800UL, 0x3fd1178eUL, 0x63a5f01cUL, + 0xbd2c210eUL, 0x67616000UL, 0x3fd0c42dUL, 0x163ceae9UL, 0x3d27188bUL, + 0x604d5800UL, 0x3fd07138UL, 0x16ed4e91UL, 0x3cf89cdbUL, 0x5626c800UL, + 0x3fd01eaeUL, 0x1485e94aUL, 0xbd16f08cUL, 0x6cb3b000UL, 0x3fcf991cUL, + 0xca0cdf30UL, 0x3d1bcbecUL, 0xe4dd0000UL, 0x3fcef5adUL, 0x65bb8e11UL, + 0xbcca2115UL, 0xffe71000UL, 0x3fce530eUL, 0x6041f430UL, 0x3cc21227UL, + 0xb0d49000UL, 0x3fcdb13dUL, 0xf715b035UL, 0xbd2aff2aUL, 0xf2656000UL, + 0x3fcd1037UL, 0x75b6f6e4UL, 0xbd084a7eUL, 0xc6f01000UL, 0x3fcc6ffbUL, + 0xc5962bd2UL, 0xbcf1ec72UL, 0x383be000UL, 0x3fcbd087UL, 0x595412b6UL, + 0xbd2d4bc4UL, 0x575bd000UL, 0x3fcb31d8UL, 0x4eace1aaUL, 0xbd0c358dUL, + 0x3c8ae000UL, 0x3fca93edUL, 0x50562169UL, 0xbd287243UL, 0x07089000UL, + 0x3fc9f6c4UL, 0x6865817aUL, 0x3d29904dUL, 0xdcf70000UL, 0x3fc95a5aUL, + 0x58a0ff6fUL, 0x3d07f228UL, 0xeb390000UL, 0x3fc8beafUL, 0xaae92cd1UL, + 0xbd073d54UL, 0x6551a000UL, 0x3fc823c1UL, 0x9a631e83UL, 0x3d1e0ddbUL, + 0x85445000UL, 0x3fc7898dUL, 0x70914305UL, 0xbd1c6610UL, 0x8b757000UL, + 0x3fc6f012UL, 0xe59c21e1UL, 0xbd25118dUL, 0xbe8c1000UL, 0x3fc6574eUL, + 0x2c3c2e78UL, 0x3d19cf8bUL, 0x6b544000UL, 0x3fc5bf40UL, 0xeb68981cUL, + 0xbd127023UL, 0xe4a1b000UL, 0x3fc527e5UL, 0xe5697dc7UL, 0x3d2633e8UL, + 0x8333b000UL, 0x3fc4913dUL, 0x54fdb678UL, 0x3d258379UL, 0xa5993000UL, + 0x3fc3fb45UL, 0x7e6a354dUL, 0xbd2cd1d8UL, 0xb0159000UL, 0x3fc365fcUL, + 0x234b7289UL, 0x3cc62fa8UL, 0x0c868000UL, 0x3fc2d161UL, 0xcb81b4a1UL, + 0x3d039d6cUL, 0x2a49c000UL, 0x3fc23d71UL, 0x8fd3df5cUL, 0x3d100d23UL, + 0x7e23f000UL, 0x3fc1aa2bUL, 0x44389934UL, 0x3d2ca78eUL, 0x8227e000UL, + 0x3fc1178eUL, 0xce2d07f2UL, 0x3d21ef78UL, 0xb59e4000UL, 0x3fc08598UL, + 0x7009902cUL, 0xbd27e5ddUL, 0x39dbe000UL, 0x3fbfe891UL, 0x4fa10afdUL, + 0xbd2534d6UL, 0x830a2000UL, 0x3fbec739UL, 0xafe645e0UL, 0xbd2dc068UL, + 0x63844000UL, 0x3fbda727UL, 0x1fa71733UL, 0x3d1a8940UL, 0x01bc4000UL, + 0x3fbc8858UL, 0xc65aacd3UL, 0x3d2646d1UL, 0x8dad6000UL, 0x3fbb6ac8UL, + 0x2bf768e5UL, 0xbd139080UL, 0x40b1c000UL, 0x3fba4e76UL, 0xb94407c8UL, + 0xbd0e42b6UL, 0x5d594000UL, 0x3fb9335eUL, 0x3abd47daUL, 0x3d23115cUL, + 0x2f40e000UL, 0x3fb8197eUL, 0xf96ffdf7UL, 0x3d0f80dcUL, 0x0aeac000UL, + 0x3fb700d3UL, 0xa99ded32UL, 0x3cec1e8dUL, 0x4d97a000UL, 0x3fb5e95aUL, + 0x3c5d1d1eUL, 0xbd2c6906UL, 0x5d208000UL, 0x3fb4d311UL, 0x82f4e1efUL, + 0xbcf53a25UL, 0xa7d1e000UL, 0x3fb3bdf5UL, 0xa5db4ed7UL, 0x3d2cc85eUL, + 0xa4472000UL, 0x3fb2aa04UL, 0xae9c697dUL, 0xbd20b6e8UL, 0xd1466000UL, + 0x3fb1973bUL, 0x560d9e9bUL, 0xbd25325dUL, 0xb59e4000UL, 0x3fb08598UL, + 0x7009902cUL, 0xbd17e5ddUL, 0xc006c000UL, 0x3faeea31UL, 0x4fc93b7bUL, + 0xbd0e113eUL, 0xcdddc000UL, 0x3faccb73UL, 0x47d82807UL, 0xbd1a68f2UL, + 0xd0fb0000UL, 0x3faaaef2UL, 0x353bb42eUL, 0x3d20fc1aUL, 0x149fc000UL, + 0x3fa894aaUL, 0xd05a267dUL, 0xbd197995UL, 0xf2d4c000UL, 0x3fa67c94UL, + 0xec19afa2UL, 0xbd029efbUL, 0xd42e0000UL, 0x3fa466aeUL, 0x75bdfd28UL, + 0xbd2c1673UL, 0x2f8d0000UL, 0x3fa252f3UL, 0xe021b67bUL, 0x3d283e9aUL, + 0x89e74000UL, 0x3fa0415dUL, 0x5cf1d753UL, 0x3d0111c0UL, 0xec148000UL, + 0x3f9c63d2UL, 0x3f9eb2f3UL, 0x3d2578c6UL, 0x28c90000UL, 0x3f984925UL, + 0x325a0c34UL, 0xbd2aa0baUL, 0x25980000UL, 0x3f9432a9UL, 0x928637feUL, + 0x3d098139UL, 0x58938000UL, 0x3f902056UL, 0x06e2f7d2UL, 0xbd23dc5bUL, + 0xa3890000UL, 0x3f882448UL, 0xda74f640UL, 0xbd275577UL, 0x75890000UL, + 0x3f801015UL, 0x999d2be8UL, 0xbd10c76bUL, 0x59580000UL, 0x3f700805UL, + 0xcb31c67bUL, 0x3d2166afUL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x80000000UL +}; + +ALIGNED_(16) juint _log2[] = +{ + 0xfefa3800UL, 0x3fa62e42UL, 0x93c76730UL, 0x3ceef357UL +}; + +ALIGNED_(16) juint _coeff[] = +{ + 0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL, 0x3d6fb175UL, + 0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL, 0x9999999aUL, 0x3fc99999UL, + 0x00000000UL, 0xbfe00000UL +}; + +//registers, +// input: xmm0 +// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 +// rax, rdx, rcx, r8, r11 + +void MacroAssembler::fast_log(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp1, Register tmp2) { + Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; + Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; + Label L_2TAG_PACKET_8_0_2; + Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start; + + assert_different_registers(tmp1, tmp2, eax, ecx, edx); + jmp(start); + address L_tbl = (address)_L_tbl; + address log2 = (address)_log2; + address coeff = (address)_coeff; + + bind(start); + subq(rsp, 24); + movsd(Address(rsp, 0), xmm0); + mov64(rax, 0x3ff0000000000000); + movdq(xmm2, rax); + mov64(rdx, 0x77f0000000000000); + movdq(xmm3, rdx); + movl(ecx, 32768); + movdl(xmm4, rcx); + mov64(tmp1, 0xffffe00000000000); + movdq(xmm5, tmp1); + movdqu(xmm1, xmm0); + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + movl(ecx, 16352); + psrlq(xmm0, 27); + lea(tmp2, ExternalAddress(L_tbl)); + psrld(xmm0, 2); + rcpps(xmm0, xmm0); + psllq(xmm1, 12); + pshufd(xmm6, xmm5, 228); + psrlq(xmm1, 12); + subl(eax, 16); + cmpl(eax, 32736); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); + + bind(L_2TAG_PACKET_1_0_2); + paddd(xmm0, xmm4); + por(xmm1, xmm3); + movdl(edx, xmm0); + psllq(xmm0, 29); + pand(xmm5, xmm1); + pand(xmm0, xmm6); + subsd(xmm1, xmm5); + mulpd(xmm5, xmm0); + andl(eax, 32752); + subl(eax, ecx); + cvtsi2sdl(xmm7, eax); + mulsd(xmm1, xmm0); + movq(xmm6, ExternalAddress(log2)); // 0xfefa3800UL, 0x3fa62e42UL + movdqu(xmm3, ExternalAddress(coeff)); // 0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL + subsd(xmm5, xmm2); + andl(edx, 16711680); + shrl(edx, 12); + movdqu(xmm0, Address(tmp2, edx)); + movdqu(xmm4, ExternalAddress(16 + coeff)); // 0x3d6fb175UL, 0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL + addsd(xmm1, xmm5); + movdqu(xmm2, ExternalAddress(32 + coeff)); // 0x9999999aUL, 0x3fc99999UL, 0x00000000UL, 0xbfe00000UL + mulsd(xmm6, xmm7); + if (VM_Version::supports_sse3()) { + movddup(xmm5, xmm1); + } + else { + movdqu(xmm5, xmm1); + movlhps(xmm5, xmm5); + } + mulsd(xmm7, ExternalAddress(8 + log2)); // 0x93c76730UL, 0x3ceef357UL + mulsd(xmm3, xmm1); + addsd(xmm0, xmm6); + mulpd(xmm4, xmm5); + mulpd(xmm5, xmm5); + if (VM_Version::supports_sse3()) { + movddup(xmm6, xmm0); + } + else { + movdqu(xmm6, xmm0); + movlhps(xmm6, xmm6); + } + addsd(xmm0, xmm1); + addpd(xmm4, xmm2); + mulpd(xmm3, xmm5); + subsd(xmm6, xmm0); + mulsd(xmm4, xmm1); + pshufd(xmm2, xmm0, 238); + addsd(xmm1, xmm6); + mulsd(xmm5, xmm5); + addsd(xmm7, xmm2); + addpd(xmm4, xmm3); + addsd(xmm1, xmm7); + mulpd(xmm4, xmm5); + addsd(xmm1, xmm4); + pshufd(xmm5, xmm4, 238); + addsd(xmm1, xmm5); + addsd(xmm0, xmm1); + jmp(B1_5); + + bind(L_2TAG_PACKET_0_0_2); + movq(xmm0, Address(rsp, 0)); + movq(xmm1, Address(rsp, 0)); + addl(eax, 16); + cmpl(eax, 32768); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_2_0_2); + cmpl(eax, 16); + jcc(Assembler::below, L_2TAG_PACKET_3_0_2); + + bind(L_2TAG_PACKET_4_0_2); + addsd(xmm0, xmm0); + jmp(B1_5); + + bind(L_2TAG_PACKET_5_0_2); + jcc(Assembler::above, L_2TAG_PACKET_4_0_2); + cmpl(edx, 0); + jcc(Assembler::above, L_2TAG_PACKET_4_0_2); + jmp(L_2TAG_PACKET_6_0_2); + + bind(L_2TAG_PACKET_3_0_2); + xorpd(xmm1, xmm1); + addsd(xmm1, xmm0); + movdl(edx, xmm1); + psrlq(xmm1, 32); + movdl(ecx, xmm1); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_7_0_2); + xorpd(xmm1, xmm1); + movl(eax, 18416); + pinsrw(xmm1, eax, 3); + mulsd(xmm0, xmm1); + movdqu(xmm1, xmm0); + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + psrlq(xmm0, 27); + movl(ecx, 18416); + psrld(xmm0, 2); + rcpps(xmm0, xmm0); + psllq(xmm1, 12); + pshufd(xmm6, xmm5, 228); + psrlq(xmm1, 12); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_2_0_2); + movdl(edx, xmm1); + psrlq(xmm1, 32); + movdl(ecx, xmm1); + addl(ecx, ecx); + cmpl(ecx, -2097152); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_7_0_2); + + bind(L_2TAG_PACKET_6_0_2); + xorpd(xmm1, xmm1); + xorpd(xmm0, xmm0); + movl(eax, 32752); + pinsrw(xmm1, eax, 3); + mulsd(xmm0, xmm1); + movl(Address(rsp, 16), 3); + jmp(L_2TAG_PACKET_8_0_2); + bind(L_2TAG_PACKET_7_0_2); + xorpd(xmm1, xmm1); + xorpd(xmm0, xmm0); + movl(eax, 49136); + pinsrw(xmm0, eax, 3); + divsd(xmm0, xmm1); + movl(Address(rsp, 16), 2); + + bind(L_2TAG_PACKET_8_0_2); + movq(Address(rsp, 8), xmm0); + + bind(B1_3); + movq(xmm0, Address(rsp, 8)); + + bind(B1_5); + addq(rsp, 24); +} +#else +// The 32 bit code is at most SSE2 compliant +ALIGNED_(16) juint _static_const_table_log[] = +{ + 0xfefa3800UL, 0x3fe62e42UL, 0x93c76730UL, 0x3d2ef357UL, 0xaa241800UL, + 0x3fe5ee82UL, 0x0cda46beUL, 0x3d220238UL, 0x5c364800UL, 0x3fe5af40UL, + 0xac10c9fbUL, 0x3d2dfa63UL, 0x26bb8c00UL, 0x3fe5707aUL, 0xff3303ddUL, + 0x3d09980bUL, 0x26867800UL, 0x3fe5322eUL, 0x5d257531UL, 0x3d05ccc4UL, + 0x835a5000UL, 0x3fe4f45aUL, 0x6d93b8fbUL, 0xbd2e6c51UL, 0x6f970c00UL, + 0x3fe4b6fdUL, 0xed4c541cUL, 0x3cef7115UL, 0x27e8a400UL, 0x3fe47a15UL, + 0xf94d60aaUL, 0xbd22cb6aUL, 0xf2f92400UL, 0x3fe43d9fUL, 0x481051f7UL, + 0xbcfd984fUL, 0x2125cc00UL, 0x3fe4019cUL, 0x30f0c74cUL, 0xbd26ce79UL, + 0x0c36c000UL, 0x3fe3c608UL, 0x7cfe13c2UL, 0xbd02b736UL, 0x17197800UL, + 0x3fe38ae2UL, 0xbb5569a4UL, 0xbd218b7aUL, 0xad9d8c00UL, 0x3fe35028UL, + 0x9527e6acUL, 0x3d10b83fUL, 0x44340800UL, 0x3fe315daUL, 0xc5a0ed9cUL, + 0xbd274e93UL, 0x57b0e000UL, 0x3fe2dbf5UL, 0x07b9dc11UL, 0xbd17a6e5UL, + 0x6d0ec000UL, 0x3fe2a278UL, 0xe797882dUL, 0x3d206d2bUL, 0x1134dc00UL, + 0x3fe26962UL, 0x05226250UL, 0xbd0b61f1UL, 0xd8bebc00UL, 0x3fe230b0UL, + 0x6e48667bUL, 0x3d12fc06UL, 0x5fc61800UL, 0x3fe1f863UL, 0xc9fe81d3UL, + 0xbd2a7242UL, 0x49ae6000UL, 0x3fe1c078UL, 0xed70e667UL, 0x3cccacdeUL, + 0x40f23c00UL, 0x3fe188eeUL, 0xf8ab4650UL, 0x3d14cc4eUL, 0xf6f29800UL, + 0x3fe151c3UL, 0xa293ae49UL, 0xbd2edd97UL, 0x23c75c00UL, 0x3fe11af8UL, + 0xbb9ddcb2UL, 0xbd258647UL, 0x8611cc00UL, 0x3fe0e489UL, 0x07801742UL, + 0x3d1c2998UL, 0xe2d05400UL, 0x3fe0ae76UL, 0x887e7e27UL, 0x3d1f486bUL, + 0x0533c400UL, 0x3fe078bfUL, 0x41edf5fdUL, 0x3d268122UL, 0xbe760400UL, + 0x3fe04360UL, 0xe79539e0UL, 0xbd04c45fUL, 0xe5b20800UL, 0x3fe00e5aUL, + 0xb1727b1cUL, 0xbd053ba3UL, 0xaf7a4800UL, 0x3fdfb358UL, 0x3c164935UL, + 0x3d0085faUL, 0xee031800UL, 0x3fdf4aa7UL, 0x6f014a8bUL, 0x3d12cde5UL, + 0x56b41000UL, 0x3fdee2a1UL, 0x5a470251UL, 0x3d2f27f4UL, 0xc3ddb000UL, + 0x3fde7b42UL, 0x5372bd08UL, 0xbd246550UL, 0x1a272800UL, 0x3fde148aUL, + 0x07322938UL, 0xbd1326b2UL, 0x484c9800UL, 0x3fddae75UL, 0x60dc616aUL, + 0xbd1ea42dUL, 0x46def800UL, 0x3fdd4902UL, 0xe9a767a8UL, 0x3d235bafUL, + 0x18064800UL, 0x3fdce42fUL, 0x3ec7a6b0UL, 0xbd0797c3UL, 0xc7455800UL, + 0x3fdc7ff9UL, 0xc15249aeUL, 0xbd29b6ddUL, 0x693fa000UL, 0x3fdc1c60UL, + 0x7fe8e180UL, 0x3d2cec80UL, 0x1b80e000UL, 0x3fdbb961UL, 0xf40a666dUL, + 0x3d27d85bUL, 0x04462800UL, 0x3fdb56faUL, 0x2d841995UL, 0x3d109525UL, + 0x5248d000UL, 0x3fdaf529UL, 0x52774458UL, 0xbd217cc5UL, 0x3c8ad800UL, + 0x3fda93edUL, 0xbea77a5dUL, 0x3d1e36f2UL, 0x0224f800UL, 0x3fda3344UL, + 0x7f9d79f5UL, 0x3d23c645UL, 0xea15f000UL, 0x3fd9d32bUL, 0x10d0c0b0UL, + 0xbd26279eUL, 0x43135800UL, 0x3fd973a3UL, 0xa502d9f0UL, 0xbd152313UL, + 0x635bf800UL, 0x3fd914a8UL, 0x2ee6307dUL, 0xbd1766b5UL, 0xa88b3000UL, + 0x3fd8b639UL, 0xe5e70470UL, 0xbd205ae1UL, 0x776dc800UL, 0x3fd85855UL, + 0x3333778aUL, 0x3d2fd56fUL, 0x3bd81800UL, 0x3fd7fafaUL, 0xc812566aUL, + 0xbd272090UL, 0x687cf800UL, 0x3fd79e26UL, 0x2efd1778UL, 0x3d29ec7dUL, + 0x76c67800UL, 0x3fd741d8UL, 0x49dc60b3UL, 0x3d2d8b09UL, 0xe6af1800UL, + 0x3fd6e60eUL, 0x7c222d87UL, 0x3d172165UL, 0x3e9c6800UL, 0x3fd68ac8UL, + 0x2756eba0UL, 0x3d20a0d3UL, 0x0b3ab000UL, 0x3fd63003UL, 0xe731ae00UL, + 0xbd2db623UL, 0xdf596000UL, 0x3fd5d5bdUL, 0x08a465dcUL, 0xbd0a0b2aUL, + 0x53c8d000UL, 0x3fd57bf7UL, 0xee5d40efUL, 0x3d1fadedUL, 0x0738a000UL, + 0x3fd522aeUL, 0x8164c759UL, 0x3d2ebe70UL, 0x9e173000UL, 0x3fd4c9e0UL, + 0x1b0ad8a4UL, 0xbd2e2089UL, 0xc271c800UL, 0x3fd4718dUL, 0x0967d675UL, + 0xbd2f27ceUL, 0x23d5e800UL, 0x3fd419b4UL, 0xec90e09dUL, 0x3d08e436UL, + 0x77333000UL, 0x3fd3c252UL, 0xb606bd5cUL, 0x3d183b54UL, 0x76be1000UL, + 0x3fd36b67UL, 0xb0f177c8UL, 0x3d116ecdUL, 0xe1d36000UL, 0x3fd314f1UL, + 0xd3213cb8UL, 0xbd28e27aUL, 0x7cdc9000UL, 0x3fd2bef0UL, 0x4a5004f4UL, + 0x3d2a9cfaUL, 0x1134d800UL, 0x3fd26962UL, 0xdf5bb3b6UL, 0x3d2c93c1UL, + 0x6d0eb800UL, 0x3fd21445UL, 0xba46baeaUL, 0x3d0a87deUL, 0x635a6800UL, + 0x3fd1bf99UL, 0x5147bdb7UL, 0x3d2ca6edUL, 0xcbacf800UL, 0x3fd16b5cUL, + 0xf7a51681UL, 0x3d2b9acdUL, 0x8227e800UL, 0x3fd1178eUL, 0x63a5f01cUL, + 0xbd2c210eUL, 0x67616000UL, 0x3fd0c42dUL, 0x163ceae9UL, 0x3d27188bUL, + 0x604d5800UL, 0x3fd07138UL, 0x16ed4e91UL, 0x3cf89cdbUL, 0x5626c800UL, + 0x3fd01eaeUL, 0x1485e94aUL, 0xbd16f08cUL, 0x6cb3b000UL, 0x3fcf991cUL, + 0xca0cdf30UL, 0x3d1bcbecUL, 0xe4dd0000UL, 0x3fcef5adUL, 0x65bb8e11UL, + 0xbcca2115UL, 0xffe71000UL, 0x3fce530eUL, 0x6041f430UL, 0x3cc21227UL, + 0xb0d49000UL, 0x3fcdb13dUL, 0xf715b035UL, 0xbd2aff2aUL, 0xf2656000UL, + 0x3fcd1037UL, 0x75b6f6e4UL, 0xbd084a7eUL, 0xc6f01000UL, 0x3fcc6ffbUL, + 0xc5962bd2UL, 0xbcf1ec72UL, 0x383be000UL, 0x3fcbd087UL, 0x595412b6UL, + 0xbd2d4bc4UL, 0x575bd000UL, 0x3fcb31d8UL, 0x4eace1aaUL, 0xbd0c358dUL, + 0x3c8ae000UL, 0x3fca93edUL, 0x50562169UL, 0xbd287243UL, 0x07089000UL, + 0x3fc9f6c4UL, 0x6865817aUL, 0x3d29904dUL, 0xdcf70000UL, 0x3fc95a5aUL, + 0x58a0ff6fUL, 0x3d07f228UL, 0xeb390000UL, 0x3fc8beafUL, 0xaae92cd1UL, + 0xbd073d54UL, 0x6551a000UL, 0x3fc823c1UL, 0x9a631e83UL, 0x3d1e0ddbUL, + 0x85445000UL, 0x3fc7898dUL, 0x70914305UL, 0xbd1c6610UL, 0x8b757000UL, + 0x3fc6f012UL, 0xe59c21e1UL, 0xbd25118dUL, 0xbe8c1000UL, 0x3fc6574eUL, + 0x2c3c2e78UL, 0x3d19cf8bUL, 0x6b544000UL, 0x3fc5bf40UL, 0xeb68981cUL, + 0xbd127023UL, 0xe4a1b000UL, 0x3fc527e5UL, 0xe5697dc7UL, 0x3d2633e8UL, + 0x8333b000UL, 0x3fc4913dUL, 0x54fdb678UL, 0x3d258379UL, 0xa5993000UL, + 0x3fc3fb45UL, 0x7e6a354dUL, 0xbd2cd1d8UL, 0xb0159000UL, 0x3fc365fcUL, + 0x234b7289UL, 0x3cc62fa8UL, 0x0c868000UL, 0x3fc2d161UL, 0xcb81b4a1UL, + 0x3d039d6cUL, 0x2a49c000UL, 0x3fc23d71UL, 0x8fd3df5cUL, 0x3d100d23UL, + 0x7e23f000UL, 0x3fc1aa2bUL, 0x44389934UL, 0x3d2ca78eUL, 0x8227e000UL, + 0x3fc1178eUL, 0xce2d07f2UL, 0x3d21ef78UL, 0xb59e4000UL, 0x3fc08598UL, + 0x7009902cUL, 0xbd27e5ddUL, 0x39dbe000UL, 0x3fbfe891UL, 0x4fa10afdUL, + 0xbd2534d6UL, 0x830a2000UL, 0x3fbec739UL, 0xafe645e0UL, 0xbd2dc068UL, + 0x63844000UL, 0x3fbda727UL, 0x1fa71733UL, 0x3d1a8940UL, 0x01bc4000UL, + 0x3fbc8858UL, 0xc65aacd3UL, 0x3d2646d1UL, 0x8dad6000UL, 0x3fbb6ac8UL, + 0x2bf768e5UL, 0xbd139080UL, 0x40b1c000UL, 0x3fba4e76UL, 0xb94407c8UL, + 0xbd0e42b6UL, 0x5d594000UL, 0x3fb9335eUL, 0x3abd47daUL, 0x3d23115cUL, + 0x2f40e000UL, 0x3fb8197eUL, 0xf96ffdf7UL, 0x3d0f80dcUL, 0x0aeac000UL, + 0x3fb700d3UL, 0xa99ded32UL, 0x3cec1e8dUL, 0x4d97a000UL, 0x3fb5e95aUL, + 0x3c5d1d1eUL, 0xbd2c6906UL, 0x5d208000UL, 0x3fb4d311UL, 0x82f4e1efUL, + 0xbcf53a25UL, 0xa7d1e000UL, 0x3fb3bdf5UL, 0xa5db4ed7UL, 0x3d2cc85eUL, + 0xa4472000UL, 0x3fb2aa04UL, 0xae9c697dUL, 0xbd20b6e8UL, 0xd1466000UL, + 0x3fb1973bUL, 0x560d9e9bUL, 0xbd25325dUL, 0xb59e4000UL, 0x3fb08598UL, + 0x7009902cUL, 0xbd17e5ddUL, 0xc006c000UL, 0x3faeea31UL, 0x4fc93b7bUL, + 0xbd0e113eUL, 0xcdddc000UL, 0x3faccb73UL, 0x47d82807UL, 0xbd1a68f2UL, + 0xd0fb0000UL, 0x3faaaef2UL, 0x353bb42eUL, 0x3d20fc1aUL, 0x149fc000UL, + 0x3fa894aaUL, 0xd05a267dUL, 0xbd197995UL, 0xf2d4c000UL, 0x3fa67c94UL, + 0xec19afa2UL, 0xbd029efbUL, 0xd42e0000UL, 0x3fa466aeUL, 0x75bdfd28UL, + 0xbd2c1673UL, 0x2f8d0000UL, 0x3fa252f3UL, 0xe021b67bUL, 0x3d283e9aUL, + 0x89e74000UL, 0x3fa0415dUL, 0x5cf1d753UL, 0x3d0111c0UL, 0xec148000UL, + 0x3f9c63d2UL, 0x3f9eb2f3UL, 0x3d2578c6UL, 0x28c90000UL, 0x3f984925UL, + 0x325a0c34UL, 0xbd2aa0baUL, 0x25980000UL, 0x3f9432a9UL, 0x928637feUL, + 0x3d098139UL, 0x58938000UL, 0x3f902056UL, 0x06e2f7d2UL, 0xbd23dc5bUL, + 0xa3890000UL, 0x3f882448UL, 0xda74f640UL, 0xbd275577UL, 0x75890000UL, + 0x3f801015UL, 0x999d2be8UL, 0xbd10c76bUL, 0x59580000UL, 0x3f700805UL, + 0xcb31c67bUL, 0x3d2166afUL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x80000000UL, 0xfefa3800UL, 0x3fa62e42UL, 0x93c76730UL, 0x3ceef357UL, + 0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL, 0x3d6fb175UL, + 0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL, 0x9999999aUL, 0x3fc99999UL, + 0x00000000UL, 0xbfe00000UL, 0x00000000UL, 0xffffe000UL, 0x00000000UL, + 0xffffe000UL +}; +//registers, +// input: xmm0 +// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 +// rax, rdx, rcx, rbx (tmp) + +void MacroAssembler::fast_log(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) { + Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; + Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; + Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2; + Label L_2TAG_PACKET_10_0_2, start; + + assert_different_registers(tmp, eax, ecx, edx); + jmp(start); + address static_const_table = (address)_static_const_table_log; + + bind(start); + subl(rsp, 104); + movl(Address(rsp, 40), tmp); + lea(tmp, ExternalAddress(static_const_table)); + xorpd(xmm2, xmm2); + movl(eax, 16368); + pinsrw(xmm2, eax, 3); + xorpd(xmm3, xmm3); + movl(edx, 30704); + pinsrw(xmm3, edx, 3); + movsd(xmm0, Address(rsp, 112)); + movapd(xmm1, xmm0); + movl(ecx, 32768); + movdl(xmm4, ecx); + movsd(xmm5, Address(tmp, 2128)); // 0x00000000UL, 0xffffe000UL + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + psllq(xmm0, 5); + movl(ecx, 16352); + psrlq(xmm0, 34); + rcpss(xmm0, xmm0); + psllq(xmm1, 12); + pshufd(xmm6, xmm5, 228); + psrlq(xmm1, 12); + subl(eax, 16); + cmpl(eax, 32736); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); + + bind(L_2TAG_PACKET_1_0_2); + paddd(xmm0, xmm4); + por(xmm1, xmm3); + movdl(edx, xmm0); + psllq(xmm0, 29); + pand(xmm5, xmm1); + pand(xmm0, xmm6); + subsd(xmm1, xmm5); + mulpd(xmm5, xmm0); + andl(eax, 32752); + subl(eax, ecx); + cvtsi2sdl(xmm7, eax); + mulsd(xmm1, xmm0); + movsd(xmm6, Address(tmp, 2064)); // 0xfefa3800UL, 0x3fa62e42UL + movdqu(xmm3, Address(tmp, 2080)); // 0x92492492UL, 0x3fc24924UL, 0x00000000UL, 0xbfd00000UL + subsd(xmm5, xmm2); + andl(edx, 16711680); + shrl(edx, 12); + movdqu(xmm0, Address(tmp, edx)); + movdqu(xmm4, Address(tmp, 2096)); // 0x3d6fb175UL, 0xbfc5555eUL, 0x55555555UL, 0x3fd55555UL + addsd(xmm1, xmm5); + movdqu(xmm2, Address(tmp, 2112)); // 0x9999999aUL, 0x3fc99999UL, 0x00000000UL, 0xbfe00000UL + mulsd(xmm6, xmm7); + pshufd(xmm5, xmm1, 68); + mulsd(xmm7, Address(tmp, 2072)); // 0x93c76730UL, 0x3ceef357UL, 0x92492492UL, 0x3fc24924UL + mulsd(xmm3, xmm1); + addsd(xmm0, xmm6); + mulpd(xmm4, xmm5); + mulpd(xmm5, xmm5); + pshufd(xmm6, xmm0, 228); + addsd(xmm0, xmm1); + addpd(xmm4, xmm2); + mulpd(xmm3, xmm5); + subsd(xmm6, xmm0); + mulsd(xmm4, xmm1); + pshufd(xmm2, xmm0, 238); + addsd(xmm1, xmm6); + mulsd(xmm5, xmm5); + addsd(xmm7, xmm2); + addpd(xmm4, xmm3); + addsd(xmm1, xmm7); + mulpd(xmm4, xmm5); + addsd(xmm1, xmm4); + pshufd(xmm5, xmm4, 238); + addsd(xmm1, xmm5); + addsd(xmm0, xmm1); + jmp(L_2TAG_PACKET_2_0_2); + + bind(L_2TAG_PACKET_0_0_2); + movsd(xmm0, Address(rsp, 112)); + movdqu(xmm1, xmm0); + addl(eax, 16); + cmpl(eax, 32768); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_3_0_2); + cmpl(eax, 16); + jcc(Assembler::below, L_2TAG_PACKET_4_0_2); + + bind(L_2TAG_PACKET_5_0_2); + addsd(xmm0, xmm0); + jmp(L_2TAG_PACKET_2_0_2); + + bind(L_2TAG_PACKET_6_0_2); + jcc(Assembler::above, L_2TAG_PACKET_5_0_2); + cmpl(edx, 0); + jcc(Assembler::above, L_2TAG_PACKET_5_0_2); + jmp(L_2TAG_PACKET_7_0_2); + + bind(L_2TAG_PACKET_3_0_2); + movdl(edx, xmm1); + psrlq(xmm1, 32); + movdl(ecx, xmm1); + addl(ecx, ecx); + cmpl(ecx, -2097152); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_6_0_2); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_8_0_2); + + bind(L_2TAG_PACKET_7_0_2); + xorpd(xmm1, xmm1); + xorpd(xmm0, xmm0); + movl(eax, 32752); + pinsrw(xmm1, eax, 3); + movl(edx, 3); + mulsd(xmm0, xmm1); + + bind(L_2TAG_PACKET_9_0_2); + movsd(Address(rsp, 0), xmm0); + movsd(xmm0, Address(rsp, 112)); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_10_0_2); + + bind(L_2TAG_PACKET_8_0_2); + xorpd(xmm1, xmm1); + xorpd(xmm0, xmm0); + movl(eax, 49136); + pinsrw(xmm0, eax, 3); + divsd(xmm0, xmm1); + movl(edx, 2); + jmp(L_2TAG_PACKET_9_0_2); + + bind(L_2TAG_PACKET_4_0_2); + movdl(edx, xmm1); + psrlq(xmm1, 32); + movdl(ecx, xmm1); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_8_0_2); + xorpd(xmm1, xmm1); + movl(eax, 18416); + pinsrw(xmm1, eax, 3); + mulsd(xmm0, xmm1); + movapd(xmm1, xmm0); + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + psllq(xmm0, 5); + movl(ecx, 18416); + psrlq(xmm0, 34); + rcpss(xmm0, xmm0); + psllq(xmm1, 12); + pshufd(xmm6, xmm5, 228); + psrlq(xmm1, 12); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_2_0_2); + movsd(Address(rsp, 24), xmm0); + fld_d(Address(rsp, 24)); + + bind(L_2TAG_PACKET_10_0_2); + movl(tmp, Address(rsp, 40)); +} +#endif diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_log10.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_log10.cpp new file mode 100644 index 00000000000..72a8aba01c7 --- /dev/null +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_log10.cpp @@ -0,0 +1,687 @@ +/* +* Copyright (c) 2016, Intel Corporation. +* Intel Math Library (LIBM) Source Code +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 only, as +* published by the Free Software Foundation. +* +* This code is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* version 2 for more details (a copy is included in the LICENSE file that +* accompanied this code). +* +* You should have received a copy of the GNU General Public License version +* 2 along with this work; if not, write to the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +* or visit www.oracle.com if you need additional information or have any +* questions. +* +*/ + +#include "precompiled.hpp" +#include "asm/assembler.hpp" +#include "asm/assembler.inline.hpp" +#include "runtime/stubRoutines.hpp" +#include "macroAssembler_x86.hpp" + +#ifdef _MSC_VER +#define ALIGNED_(x) __declspec(align(x)) +#else +#define ALIGNED_(x) __attribute__ ((aligned(x))) +#endif + +/******************************************************************************/ +// ALGORITHM DESCRIPTION - LOG10() +// --------------------- +// +// Let x=2^k * mx, mx in [1,2) +// +// Get B~1/mx based on the output of rcpss instruction (B0) +// B = int((B0*LH*2^7+0.5))/2^7 +// LH is a short approximation for log10(e) +// +// Reduced argument: r=B*mx-LH (computed accurately in high and low parts) +// +// Result: k*log10(2) - log(B) + p(r) +// p(r) is a degree 7 polynomial +// -log(B) read from data table (high, low parts) +// Result is formed from high and low parts +// +// Special cases: +// log10(0) = -INF with divide-by-zero exception raised +// log10(1) = +0 +// log10(x) = NaN with invalid exception raised if x < -0, including -INF +// log10(+INF) = +INF +// +/******************************************************************************/ + +#ifdef _LP64 +// The 64 bit code is at most SSE2 compliant +ALIGNED_(16) juint _HIGHSIGMASK_log10[] = +{ + 0xf8000000UL, 0xffffffffUL, 0x00000000UL, 0xffffe000UL +}; + +ALIGNED_(16) juint _LOG10_E[] = +{ + 0x00000000UL, 0x3fdbc000UL, 0xbf2e4108UL, 0x3f5a7a6cUL +}; + +ALIGNED_(16) juint _L_tbl_log10[] = +{ + 0x509f7800UL, 0x3fd34413UL, 0x1f12b358UL, 0x3d1fef31UL, 0x80333400UL, + 0x3fd32418UL, 0xc671d9d0UL, 0xbcf542bfUL, 0x51195000UL, 0x3fd30442UL, + 0x78a4b0c3UL, 0x3d18216aUL, 0x6fc79400UL, 0x3fd2e490UL, 0x80fa389dUL, + 0xbc902869UL, 0x89d04000UL, 0x3fd2c502UL, 0x75c2f564UL, 0x3d040754UL, + 0x4ddd1c00UL, 0x3fd2a598UL, 0xd219b2c3UL, 0xbcfa1d84UL, 0x6baa7c00UL, + 0x3fd28651UL, 0xfd9abec1UL, 0x3d1be6d3UL, 0x94028800UL, 0x3fd2672dUL, + 0xe289a455UL, 0xbd1ede5eUL, 0x78b86400UL, 0x3fd2482cUL, 0x6734d179UL, + 0x3d1fe79bUL, 0xcca3c800UL, 0x3fd2294dUL, 0x981a40b8UL, 0xbced34eaUL, + 0x439c5000UL, 0x3fd20a91UL, 0xcc392737UL, 0xbd1a9cc3UL, 0x92752c00UL, + 0x3fd1ebf6UL, 0x03c9afe7UL, 0x3d1e98f8UL, 0x6ef8dc00UL, 0x3fd1cd7dUL, + 0x71dae7f4UL, 0x3d08a86cUL, 0x8fe4dc00UL, 0x3fd1af25UL, 0xee9185a1UL, + 0xbcff3412UL, 0xace59400UL, 0x3fd190eeUL, 0xc2cab353UL, 0x3cf17ed9UL, + 0x7e925000UL, 0x3fd172d8UL, 0x6952c1b2UL, 0x3cf1521cUL, 0xbe694400UL, + 0x3fd154e2UL, 0xcacb79caUL, 0xbd0bdc78UL, 0x26cbac00UL, 0x3fd1370dUL, + 0xf71f4de1UL, 0xbd01f8beUL, 0x72fa0800UL, 0x3fd11957UL, 0x55bf910bUL, + 0x3c946e2bUL, 0x5f106000UL, 0x3fd0fbc1UL, 0x39e639c1UL, 0x3d14a84bUL, + 0xa802a800UL, 0x3fd0de4aUL, 0xd3f31d5dUL, 0xbd178385UL, 0x0b992000UL, + 0x3fd0c0f3UL, 0x3843106fUL, 0xbd1f602fUL, 0x486ce800UL, 0x3fd0a3baUL, + 0x8819497cUL, 0x3cef987aUL, 0x1de49400UL, 0x3fd086a0UL, 0x1caa0467UL, + 0x3d0faec7UL, 0x4c30cc00UL, 0x3fd069a4UL, 0xa4424372UL, 0xbd1618fcUL, + 0x94490000UL, 0x3fd04cc6UL, 0x946517d2UL, 0xbd18384bUL, 0xb7e84000UL, + 0x3fd03006UL, 0xe0109c37UL, 0xbd19a6acUL, 0x798a0c00UL, 0x3fd01364UL, + 0x5121e864UL, 0xbd164cf7UL, 0x38ce8000UL, 0x3fcfedbfUL, 0x46214d1aUL, + 0xbcbbc402UL, 0xc8e62000UL, 0x3fcfb4efUL, 0xdab93203UL, 0x3d1e0176UL, + 0x2cb02800UL, 0x3fcf7c5aUL, 0x2a2ea8e4UL, 0xbcfec86aUL, 0xeeeaa000UL, + 0x3fcf43fdUL, 0xc18e49a4UL, 0x3cf110a8UL, 0x9bb6e800UL, 0x3fcf0bdaUL, + 0x923cc9c0UL, 0xbd15ce99UL, 0xc093f000UL, 0x3fced3efUL, 0x4d4b51e9UL, + 0x3d1a04c7UL, 0xec58f800UL, 0x3fce9c3cUL, 0x163cad59UL, 0x3cac8260UL, + 0x9a907000UL, 0x3fce2d7dUL, 0x3fa93646UL, 0x3ce4a1c0UL, 0x37311000UL, + 0x3fcdbf99UL, 0x32abd1fdUL, 0x3d07ea9dUL, 0x6744b800UL, 0x3fcd528cUL, + 0x4dcbdfd4UL, 0xbd1b08e2UL, 0xe36de800UL, 0x3fcce653UL, 0x0b7b7f7fUL, + 0xbd1b8f03UL, 0x77506800UL, 0x3fcc7aecUL, 0xa821c9fbUL, 0x3d13c163UL, + 0x00ff8800UL, 0x3fcc1053UL, 0x536bca76UL, 0xbd074ee5UL, 0x70719800UL, + 0x3fcba684UL, 0xd7da9b6bUL, 0xbd1fbf16UL, 0xc6f8d800UL, 0x3fcb3d7dUL, + 0xe2220bb3UL, 0x3d1a295dUL, 0x16c15800UL, 0x3fcad53cUL, 0xe724911eUL, + 0xbcf55822UL, 0x82533800UL, 0x3fca6dbcUL, 0x6d982371UL, 0x3cac567cUL, + 0x3c19e800UL, 0x3fca06fcUL, 0x84d17d80UL, 0x3d1da204UL, 0x85ef8000UL, + 0x3fc9a0f8UL, 0x54466a6aUL, 0xbd002204UL, 0xb0ac2000UL, 0x3fc93baeUL, + 0xd601fd65UL, 0x3d18840cUL, 0x1bb9b000UL, 0x3fc8d71cUL, 0x7bf58766UL, + 0xbd14f897UL, 0x34aae800UL, 0x3fc8733eUL, 0x3af6ac24UL, 0xbd0f5c45UL, + 0x76d68000UL, 0x3fc81012UL, 0x4303e1a1UL, 0xbd1f9a80UL, 0x6af57800UL, + 0x3fc7ad96UL, 0x43fbcb46UL, 0x3cf4c33eUL, 0xa6c51000UL, 0x3fc74bc7UL, + 0x70f0eac5UL, 0xbd192e3bUL, 0xccab9800UL, 0x3fc6eaa3UL, 0xc0093dfeUL, + 0xbd0faf15UL, 0x8b60b800UL, 0x3fc68a28UL, 0xde78d5fdUL, 0xbc9ea4eeUL, + 0x9d987000UL, 0x3fc62a53UL, 0x962bea6eUL, 0xbd194084UL, 0xc9b0e800UL, + 0x3fc5cb22UL, 0x888dd999UL, 0x3d1fe201UL, 0xe1634800UL, 0x3fc56c93UL, + 0x16ada7adUL, 0x3d1b1188UL, 0xc176c000UL, 0x3fc50ea4UL, 0x4159b5b5UL, + 0xbcf09c08UL, 0x51766000UL, 0x3fc4b153UL, 0x84393d23UL, 0xbcf6a89cUL, + 0x83695000UL, 0x3fc4549dUL, 0x9f0b8bbbUL, 0x3d1c4b8cUL, 0x538d5800UL, + 0x3fc3f881UL, 0xf49df747UL, 0x3cf89b99UL, 0xc8138000UL, 0x3fc39cfcUL, + 0xd503b834UL, 0xbd13b99fUL, 0xf0df0800UL, 0x3fc3420dUL, 0xf011b386UL, + 0xbd05d8beUL, 0xe7466800UL, 0x3fc2e7b2UL, 0xf39c7bc2UL, 0xbd1bb94eUL, + 0xcdd62800UL, 0x3fc28de9UL, 0x05e6d69bUL, 0xbd10ed05UL, 0xd015d800UL, + 0x3fc234b0UL, 0xe29b6c9dUL, 0xbd1ff967UL, 0x224ea800UL, 0x3fc1dc06UL, + 0x727711fcUL, 0xbcffb30dUL, 0x01540000UL, 0x3fc183e8UL, 0x39786c5aUL, + 0x3cc23f57UL, 0xb24d9800UL, 0x3fc12c54UL, 0xc905a342UL, 0x3d003a1dUL, + 0x82835800UL, 0x3fc0d54aUL, 0x9b9920c0UL, 0x3d03b25aUL, 0xc72ac000UL, + 0x3fc07ec7UL, 0x46f26a24UL, 0x3cf0fa41UL, 0xdd35d800UL, 0x3fc028caUL, + 0x41d9d6dcUL, 0x3d034a65UL, 0x52474000UL, 0x3fbfa6a4UL, 0x44f66449UL, + 0x3d19cad3UL, 0x2da3d000UL, 0x3fbefcb8UL, 0x67832999UL, 0x3d18400fUL, + 0x32a10000UL, 0x3fbe53ceUL, 0x9c0e3b1aUL, 0xbcff62fdUL, 0x556b7000UL, + 0x3fbdabe3UL, 0x02976913UL, 0xbcf8243bUL, 0x97e88000UL, 0x3fbd04f4UL, + 0xec793797UL, 0x3d1c0578UL, 0x09647000UL, 0x3fbc5effUL, 0x05fc0565UL, + 0xbd1d799eUL, 0xc6426000UL, 0x3fbbb9ffUL, 0x4625f5edUL, 0x3d1f5723UL, + 0xf7afd000UL, 0x3fbb15f3UL, 0xdd5aae61UL, 0xbd1a7e1eUL, 0xd358b000UL, + 0x3fba72d8UL, 0x3314e4d3UL, 0x3d17bc91UL, 0x9b1f5000UL, 0x3fb9d0abUL, + 0x9a4d514bUL, 0x3cf18c9bUL, 0x9cd4e000UL, 0x3fb92f69UL, 0x7e4496abUL, + 0x3cf1f96dUL, 0x31f4f000UL, 0x3fb88f10UL, 0xf56479e7UL, 0x3d165818UL, + 0xbf628000UL, 0x3fb7ef9cUL, 0x26bf486dUL, 0xbd1113a6UL, 0xb526b000UL, + 0x3fb7510cUL, 0x1a1c3384UL, 0x3ca9898dUL, 0x8e31e000UL, 0x3fb6b35dUL, + 0xb3875361UL, 0xbd0661acUL, 0xd01de000UL, 0x3fb6168cUL, 0x2a7cacfaUL, + 0xbd1bdf10UL, 0x0af23000UL, 0x3fb57a98UL, 0xff868816UL, 0x3cf046d0UL, + 0xd8ea0000UL, 0x3fb4df7cUL, 0x1515fbe7UL, 0xbd1fd529UL, 0xde3b2000UL, + 0x3fb44538UL, 0x6e59a132UL, 0x3d1faeeeUL, 0xc8df9000UL, 0x3fb3abc9UL, + 0xf1322361UL, 0xbd198807UL, 0x505f1000UL, 0x3fb3132dUL, 0x0888e6abUL, + 0x3d1e5380UL, 0x359bd000UL, 0x3fb27b61UL, 0xdfbcbb22UL, 0xbcfe2724UL, + 0x429ee000UL, 0x3fb1e463UL, 0x6eb4c58cUL, 0xbcfe4dd6UL, 0x4a673000UL, + 0x3fb14e31UL, 0x4ce1ac9bUL, 0x3d1ba691UL, 0x28b96000UL, 0x3fb0b8c9UL, + 0x8c7813b8UL, 0xbd0b3872UL, 0xc1f08000UL, 0x3fb02428UL, 0xc2bc8c2cUL, + 0x3cb5ea6bUL, 0x05a1a000UL, 0x3faf209cUL, 0x72e8f18eUL, 0xbce8df84UL, + 0xc0b5e000UL, 0x3fadfa6dUL, 0x9fdef436UL, 0x3d087364UL, 0xaf416000UL, + 0x3facd5c2UL, 0x1068c3a9UL, 0x3d0827e7UL, 0xdb356000UL, 0x3fabb296UL, + 0x120a34d3UL, 0x3d101a9fUL, 0x5dfea000UL, 0x3faa90e6UL, 0xdaded264UL, + 0xbd14c392UL, 0x6034c000UL, 0x3fa970adUL, 0x1c9d06a9UL, 0xbd1b705eUL, + 0x194c6000UL, 0x3fa851e8UL, 0x83996ad9UL, 0xbd0117bcUL, 0xcf4ac000UL, + 0x3fa73492UL, 0xb1a94a62UL, 0xbca5ea42UL, 0xd67b4000UL, 0x3fa618a9UL, + 0x75aed8caUL, 0xbd07119bUL, 0x9126c000UL, 0x3fa4fe29UL, 0x5291d533UL, + 0x3d12658fUL, 0x6f4d4000UL, 0x3fa3e50eUL, 0xcd2c5cd9UL, 0x3d1d5c70UL, + 0xee608000UL, 0x3fa2cd54UL, 0xd1008489UL, 0x3d1a4802UL, 0x9900e000UL, + 0x3fa1b6f9UL, 0x54fb5598UL, 0xbd16593fUL, 0x06bb6000UL, 0x3fa0a1f9UL, + 0x64ef57b4UL, 0xbd17636bUL, 0xb7940000UL, 0x3f9f1c9fUL, 0xee6a4737UL, + 0x3cb5d479UL, 0x91aa0000UL, 0x3f9cf7f5UL, 0x3a16373cUL, 0x3d087114UL, + 0x156b8000UL, 0x3f9ad5edUL, 0x836c554aUL, 0x3c6900b0UL, 0xd4764000UL, + 0x3f98b67fUL, 0xed12f17bUL, 0xbcffc974UL, 0x77dec000UL, 0x3f9699a7UL, + 0x232ce7eaUL, 0x3d1e35bbUL, 0xbfbf4000UL, 0x3f947f5dUL, 0xd84ffa6eUL, + 0x3d0e0a49UL, 0x82c7c000UL, 0x3f92679cUL, 0x8d170e90UL, 0xbd14d9f2UL, + 0xadd20000UL, 0x3f90525dUL, 0x86d9f88eUL, 0x3cdeb986UL, 0x86f10000UL, + 0x3f8c7f36UL, 0xb9e0a517UL, 0x3ce29faaUL, 0xb75c8000UL, 0x3f885e9eUL, + 0x542568cbUL, 0xbd1f7bdbUL, 0x46b30000UL, 0x3f8442e8UL, 0xb954e7d9UL, + 0x3d1e5287UL, 0xb7e60000UL, 0x3f802c07UL, 0x22da0b17UL, 0xbd19fb27UL, + 0x6c8b0000UL, 0x3f7833e3UL, 0x821271efUL, 0xbd190f96UL, 0x29910000UL, + 0x3f701936UL, 0xbc3491a5UL, 0xbd1bcf45UL, 0x354a0000UL, 0x3f600fe3UL, + 0xc0ff520aUL, 0xbd19d71cUL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL +}; + +ALIGNED_(16) juint _log2_log10[] = +{ + 0x509f7800UL, 0x3f934413UL, 0x1f12b358UL, 0x3cdfef31UL +}; + +ALIGNED_(16) juint _coeff_log10[] = +{ + 0xc1a5f12eUL, 0x40358874UL, 0x64d4ef0dUL, 0xc0089309UL, 0x385593b1UL, + 0xc025c917UL, 0xdc963467UL, 0x3ffc6a02UL, 0x7f9d3aa1UL, 0x4016ab9fUL, + 0xdc77b115UL, 0xbff27af2UL +}; + +// Registers: +// input: xmm0 +// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 +// rax, rdx, rcx, tmp - r11 + +// Code generated by Intel C compiler for LIBM library + +void MacroAssembler::fast_log10(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register r11) { + Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; + Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; + Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, B1_2, B1_3, B1_4, B1_5, start; + + assert_different_registers(r11, eax, ecx, edx); + + address HIGHSIGMASK = (address)_HIGHSIGMASK_log10; + address LOG10_E = (address)_LOG10_E; + address L_tbl = (address)_L_tbl_log10; + address log2 = (address)_log2_log10; + address coeff = (address)_coeff_log10; + + bind(start); + subq(rsp, 24); + movsd(Address(rsp, 0), xmm0); + + bind(B1_2); + xorpd(xmm2, xmm2); + movl(eax, 16368); + pinsrw(xmm2, eax, 3); + movl(ecx, 1054736384); + movdl(xmm7, ecx); + xorpd(xmm3, xmm3); + movl(edx, 30704); + pinsrw(xmm3, edx, 3); + movdqu(xmm1, xmm0); + movl(edx, 32768); + movdl(xmm4, edx); + movdqu(xmm5, ExternalAddress(HIGHSIGMASK)); //0xf8000000UL, 0xffffffffUL, 0x00000000UL, 0xffffe000UL + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + movl(ecx, 16352); + psrlq(xmm0, 27); + movdqu(xmm2, ExternalAddress(LOG10_E)); //0x00000000UL, 0x3fdbc000UL, 0xbf2e4108UL, 0x3f5a7a6cUL + psrld(xmm0, 2); + rcpps(xmm0, xmm0); + psllq(xmm1, 12); + pshufd(xmm6, xmm5, 78); + psrlq(xmm1, 12); + subl(eax, 16); + cmpl(eax, 32736); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); + + bind(L_2TAG_PACKET_1_0_2); + mulss(xmm0, xmm7); + por(xmm1, xmm3); + lea(r11, ExternalAddress(L_tbl)); + andpd(xmm5, xmm1); + paddd(xmm0, xmm4); + subsd(xmm1, xmm5); + movdl(edx, xmm0); + psllq(xmm0, 29); + andpd(xmm0, xmm6); + andl(eax, 32752); + subl(eax, ecx); + cvtsi2sdl(xmm7, eax); + mulpd(xmm5, xmm0); + mulsd(xmm1, xmm0); + movq(xmm6, ExternalAddress(log2)); //0x509f7800UL, 0x3f934413UL, 0x1f12b358UL, 0x3cdfef31UL + movdqu(xmm3, ExternalAddress(coeff)); //0xc1a5f12eUL, 0x40358874UL, 0x64d4ef0dUL, 0xc0089309UL + subsd(xmm5, xmm2); + andl(edx, 16711680); + shrl(edx, 12); + movdqu(xmm0, Address(r11, rdx, Address::times_1, -1504)); + movdqu(xmm4, ExternalAddress(16 + coeff)); //0x385593b1UL, 0xc025c917UL, 0xdc963467UL, 0x3ffc6a02UL + addsd(xmm1, xmm5); + movdqu(xmm2, ExternalAddress(32 + coeff)); //0x7f9d3aa1UL, 0x4016ab9fUL, 0xdc77b115UL, 0xbff27af2UL + mulsd(xmm6, xmm7); + pshufd(xmm5, xmm1, 68); + mulsd(xmm7, ExternalAddress(8 + log2)); //0x1f12b358UL, 0x3cdfef31UL + mulsd(xmm3, xmm1); + addsd(xmm0, xmm6); + mulpd(xmm4, xmm5); + movq(xmm6, ExternalAddress(8 + LOG10_E)); //0xbf2e4108UL, 0x3f5a7a6cUL + mulpd(xmm5, xmm5); + addpd(xmm4, xmm2); + mulpd(xmm3, xmm5); + pshufd(xmm2, xmm0, 228); + addsd(xmm0, xmm1); + mulsd(xmm4, xmm1); + subsd(xmm2, xmm0); + mulsd(xmm6, xmm1); + addsd(xmm1, xmm2); + pshufd(xmm2, xmm0, 238); + mulsd(xmm5, xmm5); + addsd(xmm7, xmm2); + addsd(xmm1, xmm6); + addpd(xmm4, xmm3); + addsd(xmm1, xmm7); + mulpd(xmm4, xmm5); + addsd(xmm1, xmm4); + pshufd(xmm5, xmm4, 238); + addsd(xmm1, xmm5); + addsd(xmm0, xmm1); + jmp(B1_5); + + bind(L_2TAG_PACKET_0_0_2); + movq(xmm0, Address(rsp, 0)); + movq(xmm1, Address(rsp, 0)); + addl(eax, 16); + cmpl(eax, 32768); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_2_0_2); + cmpl(eax, 16); + jcc(Assembler::below, L_2TAG_PACKET_3_0_2); + + bind(L_2TAG_PACKET_4_0_2); + addsd(xmm0, xmm0); + jmp(B1_5); + + bind(L_2TAG_PACKET_5_0_2); + jcc(Assembler::above, L_2TAG_PACKET_4_0_2); + cmpl(edx, 0); + jcc(Assembler::above, L_2TAG_PACKET_4_0_2); + jmp(L_2TAG_PACKET_6_0_2); + + bind(L_2TAG_PACKET_3_0_2); + xorpd(xmm1, xmm1); + addsd(xmm1, xmm0); + movdl(edx, xmm1); + psrlq(xmm1, 32); + movdl(ecx, xmm1); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_7_0_2); + xorpd(xmm1, xmm1); + movl(eax, 18416); + pinsrw(xmm1, eax, 3); + mulsd(xmm0, xmm1); + xorpd(xmm2, xmm2); + movl(eax, 16368); + pinsrw(xmm2, eax, 3); + movdqu(xmm1, xmm0); + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + movl(ecx, 18416); + psrlq(xmm0, 27); + movdqu(xmm2, ExternalAddress(LOG10_E)); //0x00000000UL, 0x3fdbc000UL, 0xbf2e4108UL, 0x3f5a7a6cUL + psrld(xmm0, 2); + rcpps(xmm0, xmm0); + psllq(xmm1, 12); + pshufd(xmm6, xmm5, 78); + psrlq(xmm1, 12); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_2_0_2); + movdl(edx, xmm1); + psrlq(xmm1, 32); + movdl(ecx, xmm1); + addl(ecx, ecx); + cmpl(ecx, -2097152); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_7_0_2); + + bind(L_2TAG_PACKET_6_0_2); + xorpd(xmm1, xmm1); + xorpd(xmm0, xmm0); + movl(eax, 32752); + pinsrw(xmm1, eax, 3); + mulsd(xmm0, xmm1); + movl(Address(rsp, 16), 9); + jmp(L_2TAG_PACKET_8_0_2); + + bind(L_2TAG_PACKET_7_0_2); + xorpd(xmm1, xmm1); + xorpd(xmm0, xmm0); + movl(eax, 49136); + pinsrw(xmm0, eax, 3); + divsd(xmm0, xmm1); + movl(Address(rsp, 16), 8); + + bind(L_2TAG_PACKET_8_0_2); + movq(Address(rsp, 8), xmm0); + + bind(B1_3); + movq(xmm0, Address(rsp, 8)); + + bind(L_2TAG_PACKET_9_0_2); + + bind(B1_5); + addq(rsp, 24); + +} +#else +// The 32 bit code is at most SSE2 compliant +ALIGNED_(16) juint _static_const_table_log10[] = +{ + 0x509f7800UL, 0x3fd34413UL, 0x1f12b358UL, 0x3d1fef31UL, 0x80333400UL, + 0x3fd32418UL, 0xc671d9d0UL, 0xbcf542bfUL, 0x51195000UL, 0x3fd30442UL, + 0x78a4b0c3UL, 0x3d18216aUL, 0x6fc79400UL, 0x3fd2e490UL, 0x80fa389dUL, + 0xbc902869UL, 0x89d04000UL, 0x3fd2c502UL, 0x75c2f564UL, 0x3d040754UL, + 0x4ddd1c00UL, 0x3fd2a598UL, 0xd219b2c3UL, 0xbcfa1d84UL, 0x6baa7c00UL, + 0x3fd28651UL, 0xfd9abec1UL, 0x3d1be6d3UL, 0x94028800UL, 0x3fd2672dUL, + 0xe289a455UL, 0xbd1ede5eUL, 0x78b86400UL, 0x3fd2482cUL, 0x6734d179UL, + 0x3d1fe79bUL, 0xcca3c800UL, 0x3fd2294dUL, 0x981a40b8UL, 0xbced34eaUL, + 0x439c5000UL, 0x3fd20a91UL, 0xcc392737UL, 0xbd1a9cc3UL, 0x92752c00UL, + 0x3fd1ebf6UL, 0x03c9afe7UL, 0x3d1e98f8UL, 0x6ef8dc00UL, 0x3fd1cd7dUL, + 0x71dae7f4UL, 0x3d08a86cUL, 0x8fe4dc00UL, 0x3fd1af25UL, 0xee9185a1UL, + 0xbcff3412UL, 0xace59400UL, 0x3fd190eeUL, 0xc2cab353UL, 0x3cf17ed9UL, + 0x7e925000UL, 0x3fd172d8UL, 0x6952c1b2UL, 0x3cf1521cUL, 0xbe694400UL, + 0x3fd154e2UL, 0xcacb79caUL, 0xbd0bdc78UL, 0x26cbac00UL, 0x3fd1370dUL, + 0xf71f4de1UL, 0xbd01f8beUL, 0x72fa0800UL, 0x3fd11957UL, 0x55bf910bUL, + 0x3c946e2bUL, 0x5f106000UL, 0x3fd0fbc1UL, 0x39e639c1UL, 0x3d14a84bUL, + 0xa802a800UL, 0x3fd0de4aUL, 0xd3f31d5dUL, 0xbd178385UL, 0x0b992000UL, + 0x3fd0c0f3UL, 0x3843106fUL, 0xbd1f602fUL, 0x486ce800UL, 0x3fd0a3baUL, + 0x8819497cUL, 0x3cef987aUL, 0x1de49400UL, 0x3fd086a0UL, 0x1caa0467UL, + 0x3d0faec7UL, 0x4c30cc00UL, 0x3fd069a4UL, 0xa4424372UL, 0xbd1618fcUL, + 0x94490000UL, 0x3fd04cc6UL, 0x946517d2UL, 0xbd18384bUL, 0xb7e84000UL, + 0x3fd03006UL, 0xe0109c37UL, 0xbd19a6acUL, 0x798a0c00UL, 0x3fd01364UL, + 0x5121e864UL, 0xbd164cf7UL, 0x38ce8000UL, 0x3fcfedbfUL, 0x46214d1aUL, + 0xbcbbc402UL, 0xc8e62000UL, 0x3fcfb4efUL, 0xdab93203UL, 0x3d1e0176UL, + 0x2cb02800UL, 0x3fcf7c5aUL, 0x2a2ea8e4UL, 0xbcfec86aUL, 0xeeeaa000UL, + 0x3fcf43fdUL, 0xc18e49a4UL, 0x3cf110a8UL, 0x9bb6e800UL, 0x3fcf0bdaUL, + 0x923cc9c0UL, 0xbd15ce99UL, 0xc093f000UL, 0x3fced3efUL, 0x4d4b51e9UL, + 0x3d1a04c7UL, 0xec58f800UL, 0x3fce9c3cUL, 0x163cad59UL, 0x3cac8260UL, + 0x9a907000UL, 0x3fce2d7dUL, 0x3fa93646UL, 0x3ce4a1c0UL, 0x37311000UL, + 0x3fcdbf99UL, 0x32abd1fdUL, 0x3d07ea9dUL, 0x6744b800UL, 0x3fcd528cUL, + 0x4dcbdfd4UL, 0xbd1b08e2UL, 0xe36de800UL, 0x3fcce653UL, 0x0b7b7f7fUL, + 0xbd1b8f03UL, 0x77506800UL, 0x3fcc7aecUL, 0xa821c9fbUL, 0x3d13c163UL, + 0x00ff8800UL, 0x3fcc1053UL, 0x536bca76UL, 0xbd074ee5UL, 0x70719800UL, + 0x3fcba684UL, 0xd7da9b6bUL, 0xbd1fbf16UL, 0xc6f8d800UL, 0x3fcb3d7dUL, + 0xe2220bb3UL, 0x3d1a295dUL, 0x16c15800UL, 0x3fcad53cUL, 0xe724911eUL, + 0xbcf55822UL, 0x82533800UL, 0x3fca6dbcUL, 0x6d982371UL, 0x3cac567cUL, + 0x3c19e800UL, 0x3fca06fcUL, 0x84d17d80UL, 0x3d1da204UL, 0x85ef8000UL, + 0x3fc9a0f8UL, 0x54466a6aUL, 0xbd002204UL, 0xb0ac2000UL, 0x3fc93baeUL, + 0xd601fd65UL, 0x3d18840cUL, 0x1bb9b000UL, 0x3fc8d71cUL, 0x7bf58766UL, + 0xbd14f897UL, 0x34aae800UL, 0x3fc8733eUL, 0x3af6ac24UL, 0xbd0f5c45UL, + 0x76d68000UL, 0x3fc81012UL, 0x4303e1a1UL, 0xbd1f9a80UL, 0x6af57800UL, + 0x3fc7ad96UL, 0x43fbcb46UL, 0x3cf4c33eUL, 0xa6c51000UL, 0x3fc74bc7UL, + 0x70f0eac5UL, 0xbd192e3bUL, 0xccab9800UL, 0x3fc6eaa3UL, 0xc0093dfeUL, + 0xbd0faf15UL, 0x8b60b800UL, 0x3fc68a28UL, 0xde78d5fdUL, 0xbc9ea4eeUL, + 0x9d987000UL, 0x3fc62a53UL, 0x962bea6eUL, 0xbd194084UL, 0xc9b0e800UL, + 0x3fc5cb22UL, 0x888dd999UL, 0x3d1fe201UL, 0xe1634800UL, 0x3fc56c93UL, + 0x16ada7adUL, 0x3d1b1188UL, 0xc176c000UL, 0x3fc50ea4UL, 0x4159b5b5UL, + 0xbcf09c08UL, 0x51766000UL, 0x3fc4b153UL, 0x84393d23UL, 0xbcf6a89cUL, + 0x83695000UL, 0x3fc4549dUL, 0x9f0b8bbbUL, 0x3d1c4b8cUL, 0x538d5800UL, + 0x3fc3f881UL, 0xf49df747UL, 0x3cf89b99UL, 0xc8138000UL, 0x3fc39cfcUL, + 0xd503b834UL, 0xbd13b99fUL, 0xf0df0800UL, 0x3fc3420dUL, 0xf011b386UL, + 0xbd05d8beUL, 0xe7466800UL, 0x3fc2e7b2UL, 0xf39c7bc2UL, 0xbd1bb94eUL, + 0xcdd62800UL, 0x3fc28de9UL, 0x05e6d69bUL, 0xbd10ed05UL, 0xd015d800UL, + 0x3fc234b0UL, 0xe29b6c9dUL, 0xbd1ff967UL, 0x224ea800UL, 0x3fc1dc06UL, + 0x727711fcUL, 0xbcffb30dUL, 0x01540000UL, 0x3fc183e8UL, 0x39786c5aUL, + 0x3cc23f57UL, 0xb24d9800UL, 0x3fc12c54UL, 0xc905a342UL, 0x3d003a1dUL, + 0x82835800UL, 0x3fc0d54aUL, 0x9b9920c0UL, 0x3d03b25aUL, 0xc72ac000UL, + 0x3fc07ec7UL, 0x46f26a24UL, 0x3cf0fa41UL, 0xdd35d800UL, 0x3fc028caUL, + 0x41d9d6dcUL, 0x3d034a65UL, 0x52474000UL, 0x3fbfa6a4UL, 0x44f66449UL, + 0x3d19cad3UL, 0x2da3d000UL, 0x3fbefcb8UL, 0x67832999UL, 0x3d18400fUL, + 0x32a10000UL, 0x3fbe53ceUL, 0x9c0e3b1aUL, 0xbcff62fdUL, 0x556b7000UL, + 0x3fbdabe3UL, 0x02976913UL, 0xbcf8243bUL, 0x97e88000UL, 0x3fbd04f4UL, + 0xec793797UL, 0x3d1c0578UL, 0x09647000UL, 0x3fbc5effUL, 0x05fc0565UL, + 0xbd1d799eUL, 0xc6426000UL, 0x3fbbb9ffUL, 0x4625f5edUL, 0x3d1f5723UL, + 0xf7afd000UL, 0x3fbb15f3UL, 0xdd5aae61UL, 0xbd1a7e1eUL, 0xd358b000UL, + 0x3fba72d8UL, 0x3314e4d3UL, 0x3d17bc91UL, 0x9b1f5000UL, 0x3fb9d0abUL, + 0x9a4d514bUL, 0x3cf18c9bUL, 0x9cd4e000UL, 0x3fb92f69UL, 0x7e4496abUL, + 0x3cf1f96dUL, 0x31f4f000UL, 0x3fb88f10UL, 0xf56479e7UL, 0x3d165818UL, + 0xbf628000UL, 0x3fb7ef9cUL, 0x26bf486dUL, 0xbd1113a6UL, 0xb526b000UL, + 0x3fb7510cUL, 0x1a1c3384UL, 0x3ca9898dUL, 0x8e31e000UL, 0x3fb6b35dUL, + 0xb3875361UL, 0xbd0661acUL, 0xd01de000UL, 0x3fb6168cUL, 0x2a7cacfaUL, + 0xbd1bdf10UL, 0x0af23000UL, 0x3fb57a98UL, 0xff868816UL, 0x3cf046d0UL, + 0xd8ea0000UL, 0x3fb4df7cUL, 0x1515fbe7UL, 0xbd1fd529UL, 0xde3b2000UL, + 0x3fb44538UL, 0x6e59a132UL, 0x3d1faeeeUL, 0xc8df9000UL, 0x3fb3abc9UL, + 0xf1322361UL, 0xbd198807UL, 0x505f1000UL, 0x3fb3132dUL, 0x0888e6abUL, + 0x3d1e5380UL, 0x359bd000UL, 0x3fb27b61UL, 0xdfbcbb22UL, 0xbcfe2724UL, + 0x429ee000UL, 0x3fb1e463UL, 0x6eb4c58cUL, 0xbcfe4dd6UL, 0x4a673000UL, + 0x3fb14e31UL, 0x4ce1ac9bUL, 0x3d1ba691UL, 0x28b96000UL, 0x3fb0b8c9UL, + 0x8c7813b8UL, 0xbd0b3872UL, 0xc1f08000UL, 0x3fb02428UL, 0xc2bc8c2cUL, + 0x3cb5ea6bUL, 0x05a1a000UL, 0x3faf209cUL, 0x72e8f18eUL, 0xbce8df84UL, + 0xc0b5e000UL, 0x3fadfa6dUL, 0x9fdef436UL, 0x3d087364UL, 0xaf416000UL, + 0x3facd5c2UL, 0x1068c3a9UL, 0x3d0827e7UL, 0xdb356000UL, 0x3fabb296UL, + 0x120a34d3UL, 0x3d101a9fUL, 0x5dfea000UL, 0x3faa90e6UL, 0xdaded264UL, + 0xbd14c392UL, 0x6034c000UL, 0x3fa970adUL, 0x1c9d06a9UL, 0xbd1b705eUL, + 0x194c6000UL, 0x3fa851e8UL, 0x83996ad9UL, 0xbd0117bcUL, 0xcf4ac000UL, + 0x3fa73492UL, 0xb1a94a62UL, 0xbca5ea42UL, 0xd67b4000UL, 0x3fa618a9UL, + 0x75aed8caUL, 0xbd07119bUL, 0x9126c000UL, 0x3fa4fe29UL, 0x5291d533UL, + 0x3d12658fUL, 0x6f4d4000UL, 0x3fa3e50eUL, 0xcd2c5cd9UL, 0x3d1d5c70UL, + 0xee608000UL, 0x3fa2cd54UL, 0xd1008489UL, 0x3d1a4802UL, 0x9900e000UL, + 0x3fa1b6f9UL, 0x54fb5598UL, 0xbd16593fUL, 0x06bb6000UL, 0x3fa0a1f9UL, + 0x64ef57b4UL, 0xbd17636bUL, 0xb7940000UL, 0x3f9f1c9fUL, 0xee6a4737UL, + 0x3cb5d479UL, 0x91aa0000UL, 0x3f9cf7f5UL, 0x3a16373cUL, 0x3d087114UL, + 0x156b8000UL, 0x3f9ad5edUL, 0x836c554aUL, 0x3c6900b0UL, 0xd4764000UL, + 0x3f98b67fUL, 0xed12f17bUL, 0xbcffc974UL, 0x77dec000UL, 0x3f9699a7UL, + 0x232ce7eaUL, 0x3d1e35bbUL, 0xbfbf4000UL, 0x3f947f5dUL, 0xd84ffa6eUL, + 0x3d0e0a49UL, 0x82c7c000UL, 0x3f92679cUL, 0x8d170e90UL, 0xbd14d9f2UL, + 0xadd20000UL, 0x3f90525dUL, 0x86d9f88eUL, 0x3cdeb986UL, 0x86f10000UL, + 0x3f8c7f36UL, 0xb9e0a517UL, 0x3ce29faaUL, 0xb75c8000UL, 0x3f885e9eUL, + 0x542568cbUL, 0xbd1f7bdbUL, 0x46b30000UL, 0x3f8442e8UL, 0xb954e7d9UL, + 0x3d1e5287UL, 0xb7e60000UL, 0x3f802c07UL, 0x22da0b17UL, 0xbd19fb27UL, + 0x6c8b0000UL, 0x3f7833e3UL, 0x821271efUL, 0xbd190f96UL, 0x29910000UL, + 0x3f701936UL, 0xbc3491a5UL, 0xbd1bcf45UL, 0x354a0000UL, 0x3f600fe3UL, + 0xc0ff520aUL, 0xbd19d71cUL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x509f7800UL, 0x3f934413UL, 0x1f12b358UL, 0x3cdfef31UL, + 0xc1a5f12eUL, 0x40358874UL, 0x64d4ef0dUL, 0xc0089309UL, 0x385593b1UL, + 0xc025c917UL, 0xdc963467UL, 0x3ffc6a02UL, 0x7f9d3aa1UL, 0x4016ab9fUL, + 0xdc77b115UL, 0xbff27af2UL, 0xf8000000UL, 0xffffffffUL, 0x00000000UL, + 0xffffe000UL, 0x00000000UL, 0x3fdbc000UL, 0xbf2e4108UL, 0x3f5a7a6cUL +}; +//registers, +// input: xmm0 +// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 +// rax, rdx, rcx, rbx (tmp) + +void MacroAssembler::fast_log10(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) { + + Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; + Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; + Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, start; + + assert_different_registers(tmp, eax, ecx, edx); + + address static_const_table_log10 = (address)_static_const_table_log10; + + bind(start); + subl(rsp, 104); + movl(Address(rsp, 40), tmp); + lea(tmp, ExternalAddress(static_const_table_log10)); + xorpd(xmm2, xmm2); + movl(eax, 16368); + pinsrw(xmm2, eax, 3); + movl(ecx, 1054736384); + movdl(xmm7, ecx); + xorpd(xmm3, xmm3); + movl(edx, 30704); + pinsrw(xmm3, edx, 3); + movsd(xmm0, Address(rsp, 112)); + movdqu(xmm1, xmm0); + movl(edx, 32768); + movdl(xmm4, edx); + movdqu(xmm5, Address(tmp, 2128)); //0x3ffc6a02UL, 0x7f9d3aa1UL, 0x4016ab9fUL, 0xdc77b115UL + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + movl(ecx, 16352); + psllq(xmm0, 5); + movsd(xmm2, Address(tmp, 2144)); //0xbff27af2UL, 0xf8000000UL, 0xffffffffUL, 0x00000000UL + psrlq(xmm0, 34); + rcpss(xmm0, xmm0); + psllq(xmm1, 12); + pshufd(xmm6, xmm5, 78); + psrlq(xmm1, 12); + subl(eax, 16); + cmpl(eax, 32736); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); + + bind(L_2TAG_PACKET_1_0_2); + mulss(xmm0, xmm7); + por(xmm1, xmm3); + andpd(xmm5, xmm1); + paddd(xmm0, xmm4); + subsd(xmm1, xmm5); + movdl(edx, xmm0); + psllq(xmm0, 29); + andpd(xmm0, xmm6); + andl(eax, 32752); + subl(eax, ecx); + cvtsi2sdl(xmm7, eax); + mulpd(xmm5, xmm0); + mulsd(xmm1, xmm0); + movsd(xmm6, Address(tmp, 2064)); //0xbd19d71cUL, 0x00000000UL, 0x00000000UL, 0x00000000UL + movdqu(xmm3, Address(tmp, 2080)); //0x00000000UL, 0x509f7800UL, 0x3f934413UL, 0x1f12b358UL + subsd(xmm5, xmm2); + andl(edx, 16711680); + shrl(edx, 12); + movdqu(xmm0, Address(tmp, edx, Address::times_1, -1504)); + movdqu(xmm4, Address(tmp, 2096)); //0x3cdfef31UL, 0xc1a5f12eUL, 0x40358874UL, 0x64d4ef0dUL + addsd(xmm1, xmm5); + movdqu(xmm2, Address(tmp, 2112)); //0xc0089309UL, 0x385593b1UL, 0xc025c917UL, 0xdc963467UL + mulsd(xmm6, xmm7); + pshufd(xmm5, xmm1, 68); + mulsd(xmm7, Address(tmp, 2072)); //0x00000000UL, 0x00000000UL, 0x00000000UL, 0x509f7800UL + mulsd(xmm3, xmm1); + addsd(xmm0, xmm6); + mulpd(xmm4, xmm5); + movsd(xmm6, Address(tmp, 2152)); //0xffffffffUL, 0x00000000UL, 0xffffe000UL, 0x00000000UL + mulpd(xmm5, xmm5); + addpd(xmm4, xmm2); + mulpd(xmm3, xmm5); + pshufd(xmm2, xmm0, 228); + addsd(xmm0, xmm1); + mulsd(xmm4, xmm1); + subsd(xmm2, xmm0); + mulsd(xmm6, xmm1); + addsd(xmm1, xmm2); + pshufd(xmm2, xmm0, 238); + mulsd(xmm5, xmm5); + addsd(xmm7, xmm2); + addsd(xmm1, xmm6); + addpd(xmm4, xmm3); + addsd(xmm1, xmm7); + mulpd(xmm4, xmm5); + addsd(xmm1, xmm4); + pshufd(xmm5, xmm4, 238); + addsd(xmm1, xmm5); + addsd(xmm0, xmm1); + jmp(L_2TAG_PACKET_2_0_2); + + bind(L_2TAG_PACKET_0_0_2); + movsd(xmm0, Address(rsp, 112)); //0xbcfa1d84UL, 0x6baa7c00UL, 0x3fd28651UL, 0xfd9abec1UL + movdqu(xmm1, xmm0); + addl(eax, 16); + cmpl(eax, 32768); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_3_0_2); + cmpl(eax, 16); + jcc(Assembler::below, L_2TAG_PACKET_4_0_2); + + bind(L_2TAG_PACKET_5_0_2); + addsd(xmm0, xmm0); + jmp(L_2TAG_PACKET_2_0_2); + + bind(L_2TAG_PACKET_6_0_2); + jcc(Assembler::above, L_2TAG_PACKET_5_0_2); + cmpl(edx, 0); + jcc(Assembler::above, L_2TAG_PACKET_5_0_2); + jmp(L_2TAG_PACKET_7_0_2); + + bind(L_2TAG_PACKET_3_0_2); + movdl(edx, xmm1); + psrlq(xmm1, 32); + movdl(ecx, xmm1); + addl(ecx, ecx); + cmpl(ecx, -2097152); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_6_0_2); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_8_0_2); + + bind(L_2TAG_PACKET_7_0_2); + xorpd(xmm1, xmm1); + xorpd(xmm0, xmm0); + movl(eax, 32752); + pinsrw(xmm1, eax, 3); + movl(edx, 9); + mulsd(xmm0, xmm1); + + bind(L_2TAG_PACKET_9_0_2); + movsd(Address(rsp, 0), xmm0); + movsd(xmm0, Address(rsp, 112)); //0xbcfa1d84UL, 0x6baa7c00UL, 0x3fd28651UL, 0xfd9abec1UL + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_10_0_2); + + bind(L_2TAG_PACKET_8_0_2); + xorpd(xmm1, xmm1); + xorpd(xmm0, xmm0); + movl(eax, 49136); + pinsrw(xmm0, eax, 3); + divsd(xmm0, xmm1); + movl(edx, 8); + jmp(L_2TAG_PACKET_9_0_2); + + bind(L_2TAG_PACKET_4_0_2); + movdl(edx, xmm1); + psrlq(xmm1, 32); + movdl(ecx, xmm1); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_8_0_2); + xorpd(xmm1, xmm1); + movl(eax, 18416); + pinsrw(xmm1, eax, 3); + mulsd(xmm0, xmm1); + xorpd(xmm2, xmm2); + movl(eax, 16368); + pinsrw(xmm2, eax, 3); + movdqu(xmm1, xmm0); + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + movl(ecx, 18416); + psllq(xmm0, 5); + movsd(xmm2, Address(tmp, 2144)); //0xbff27af2UL, 0xf8000000UL, 0xffffffffUL, 0x00000000UL + psrlq(xmm0, 34); + rcpss(xmm0, xmm0); + psllq(xmm1, 12); + pshufd(xmm6, xmm5, 78); + psrlq(xmm1, 12); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_2_0_2); + movsd(Address(rsp, 24), xmm0); + fld_d(Address(rsp, 24)); + + bind(L_2TAG_PACKET_10_0_2); + movl(tmp, Address(rsp, 40)); + +} +#endif diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_pow.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_pow.cpp new file mode 100644 index 00000000000..12b38d8c5ef --- /dev/null +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_pow.cpp @@ -0,0 +1,3592 @@ +/* +* Copyright (c) 2016, Intel Corporation. +* Intel Math Library (LIBM) Source Code +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 only, as +* published by the Free Software Foundation. +* +* This code is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* version 2 for more details (a copy is included in the LICENSE file that +* accompanied this code). +* +* You should have received a copy of the GNU General Public License version +* 2 along with this work; if not, write to the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +* or visit www.oracle.com if you need additional information or have any +* questions. +* +*/ + +#include "precompiled.hpp" +#include "asm/assembler.hpp" +#include "asm/assembler.inline.hpp" +#include "runtime/stubRoutines.hpp" +#include "macroAssembler_x86.hpp" + +#ifdef _MSC_VER +#define ALIGNED_(x) __declspec(align(x)) +#else +#define ALIGNED_(x) __attribute__ ((aligned(x))) +#endif + +/******************************************************************************/ +// ALGORITHM DESCRIPTION - POW() +// --------------------- +// +// Let x=2^k * mx, mx in [1,2) +// +// log2(x) calculation: +// +// Get B~1/mx based on the output of rcpps instruction (B0) +// B = int((B0*LH*2^9+0.5))/2^9 +// LH is a short approximation for log2(e) +// +// Reduced argument, scaled by LH: +// r=B*mx-LH (computed accurately in high and low parts) +// +// log2(x) result: k - log2(B) + p(r) +// p(r) is a degree 8 polynomial +// -log2(B) read from data table (high, low parts) +// log2(x) is formed from high and low parts +// For |x| in [1-1/32, 1+1/16), a slower but more accurate computation +// based om the same table design is performed. +// +// Main path is taken if | floor(log2(|log2(|x|)|) + floor(log2|y|) | < 8, +// to filter out all potential OF/UF cases. +// exp2(y*log2(x)) is computed using an 8-bit index table and a degree 5 +// polynomial +// +// Special cases: +// pow(-0,y) = -INF and raises the divide-by-zero exception for y an odd +// integer < 0. +// pow(-0,y) = +INF and raises the divide-by-zero exception for y < 0 and +// not an odd integer. +// pow(-0,y) = -0 for y an odd integer > 0. +// pow(-0,y) = +0 for y > 0 and not an odd integer. +// pow(-1,-INF) = NaN. +// pow(+1,y) = NaN for any y, even a NaN. +// pow(x,-0) = 1 for any x, even a NaN. +// pow(x,y) = a NaN and raises the invalid exception for finite x < 0 and +// finite non-integer y. +// pow(x,-INF) = +INF for |x|<1. +// pow(x,-INF) = +0 for |x|>1. +// pow(x,+INF) = +0 for |x|<1. +// pow(x,+INF) = +INF for |x|>1. +// pow(-INF,y) = -0 for y an odd integer < 0. +// pow(-INF,y) = +0 for y < 0 and not an odd integer. +// pow(-INF,y) = -INF for y an odd integer > 0. +// pow(-INF,y) = +INF for y > 0 and not an odd integer. +// pow(+INF,y) = +0 for y <0. +// pow(+INF,y) = +INF for y >0. +// +/******************************************************************************/ + +#ifdef _LP64 +// The 64 bit code is at most SSE2 compliant +ALIGNED_(16) juint _HIGHSIGMASK[] = +{ + 0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL +}; + +ALIGNED_(16) juint _LOG2_E[] = +{ + 0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL +}; + +ALIGNED_(16) juint _HIGHMASK_Y[] = +{ + 0x00000000UL, 0xfffffff8UL, 0x00000000UL, 0xffffffffUL +}; + +ALIGNED_(16) juint _T_exp[] = +{ + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3b700000UL, 0xfa5abcbfUL, + 0x3ff00b1aUL, 0xa7609f71UL, 0xbc84f6b2UL, 0xa9fb3335UL, 0x3ff0163dUL, + 0x9ab8cdb7UL, 0x3c9b6129UL, 0x143b0281UL, 0x3ff02168UL, 0x0fc54eb6UL, + 0xbc82bf31UL, 0x3e778061UL, 0x3ff02c9aUL, 0x535b085dUL, 0xbc719083UL, + 0x2e11bbccUL, 0x3ff037d4UL, 0xeeade11aUL, 0x3c656811UL, 0xe86e7f85UL, + 0x3ff04315UL, 0x1977c96eUL, 0xbc90a31cUL, 0x72f654b1UL, 0x3ff04e5fUL, + 0x3aa0d08cUL, 0x3c84c379UL, 0xd3158574UL, 0x3ff059b0UL, 0xa475b465UL, + 0x3c8d73e2UL, 0x0e3c1f89UL, 0x3ff0650aUL, 0x5799c397UL, 0xbc95cb7bUL, + 0x29ddf6deUL, 0x3ff0706bUL, 0xe2b13c27UL, 0xbc8c91dfUL, 0x2b72a836UL, + 0x3ff07bd4UL, 0x54458700UL, 0x3c832334UL, 0x18759bc8UL, 0x3ff08745UL, + 0x4bb284ffUL, 0x3c6186beUL, 0xf66607e0UL, 0x3ff092bdUL, 0x800a3fd1UL, + 0xbc968063UL, 0xcac6f383UL, 0x3ff09e3eUL, 0x18316136UL, 0x3c914878UL, + 0x9b1f3919UL, 0x3ff0a9c7UL, 0x873d1d38UL, 0x3c85d16cUL, 0x6cf9890fUL, + 0x3ff0b558UL, 0x4adc610bUL, 0x3c98a62eUL, 0x45e46c85UL, 0x3ff0c0f1UL, + 0x06d21cefUL, 0x3c94f989UL, 0x2b7247f7UL, 0x3ff0cc92UL, 0x16e24f71UL, + 0x3c901edcUL, 0x23395decUL, 0x3ff0d83bUL, 0xe43f316aUL, 0xbc9bc14dUL, + 0x32d3d1a2UL, 0x3ff0e3ecUL, 0x27c57b52UL, 0x3c403a17UL, 0x5fdfa9c5UL, + 0x3ff0efa5UL, 0xbc54021bUL, 0xbc949db9UL, 0xaffed31bUL, 0x3ff0fb66UL, + 0xc44ebd7bUL, 0xbc6b9bedUL, 0x28d7233eUL, 0x3ff10730UL, 0x1692fdd5UL, + 0x3c8d46ebUL, 0xd0125b51UL, 0x3ff11301UL, 0x39449b3aUL, 0xbc96c510UL, + 0xab5e2ab6UL, 0x3ff11edbUL, 0xf703fb72UL, 0xbc9ca454UL, 0xc06c31ccUL, + 0x3ff12abdUL, 0xb36ca5c7UL, 0xbc51b514UL, 0x14f204abUL, 0x3ff136a8UL, + 0xba48dcf0UL, 0xbc67108fUL, 0xaea92de0UL, 0x3ff1429aUL, 0x9af1369eUL, + 0xbc932fbfUL, 0x934f312eUL, 0x3ff14e95UL, 0x39bf44abUL, 0xbc8b91e8UL, + 0xc8a58e51UL, 0x3ff15a98UL, 0xb9eeab0aUL, 0x3c82406aUL, 0x5471c3c2UL, + 0x3ff166a4UL, 0x82ea1a32UL, 0x3c58f23bUL, 0x3c7d517bUL, 0x3ff172b8UL, + 0xb9d78a76UL, 0xbc819041UL, 0x8695bbc0UL, 0x3ff17ed4UL, 0xe2ac5a64UL, + 0x3c709e3fUL, 0x388c8deaUL, 0x3ff18af9UL, 0xd1970f6cUL, 0xbc911023UL, + 0x58375d2fUL, 0x3ff19726UL, 0x85f17e08UL, 0x3c94aaddUL, 0xeb6fcb75UL, + 0x3ff1a35bUL, 0x7b4968e4UL, 0x3c8e5b4cUL, 0xf8138a1cUL, 0x3ff1af99UL, + 0xa4b69280UL, 0x3c97bf85UL, 0x84045cd4UL, 0x3ff1bbe0UL, 0x352ef607UL, + 0xbc995386UL, 0x95281c6bUL, 0x3ff1c82fUL, 0x8010f8c9UL, 0x3c900977UL, + 0x3168b9aaUL, 0x3ff1d487UL, 0x00a2643cUL, 0x3c9e016eUL, 0x5eb44027UL, + 0x3ff1e0e7UL, 0x088cb6deUL, 0xbc96fdd8UL, 0x22fcd91dUL, 0x3ff1ed50UL, + 0x027bb78cUL, 0xbc91df98UL, 0x8438ce4dUL, 0x3ff1f9c1UL, 0xa097af5cUL, + 0xbc9bf524UL, 0x88628cd6UL, 0x3ff2063bUL, 0x814a8495UL, 0x3c8dc775UL, + 0x3578a819UL, 0x3ff212beUL, 0x2cfcaac9UL, 0x3c93592dUL, 0x917ddc96UL, + 0x3ff21f49UL, 0x9494a5eeUL, 0x3c82a97eUL, 0xa27912d1UL, 0x3ff22bddUL, + 0x5577d69fUL, 0x3c8d34fbUL, 0x6e756238UL, 0x3ff2387aUL, 0xb6c70573UL, + 0x3c99b07eUL, 0xfb82140aUL, 0x3ff2451fUL, 0x911ca996UL, 0x3c8acfccUL, + 0x4fb2a63fUL, 0x3ff251ceUL, 0xbef4f4a4UL, 0x3c8ac155UL, 0x711ece75UL, + 0x3ff25e85UL, 0x4ac31b2cUL, 0x3c93e1a2UL, 0x65e27cddUL, 0x3ff26b45UL, + 0x9940e9d9UL, 0x3c82bd33UL, 0x341ddf29UL, 0x3ff2780eUL, 0x05f9e76cUL, + 0x3c9e067cUL, 0xe1f56381UL, 0x3ff284dfUL, 0x8c3f0d7eUL, 0xbc9a4c3aUL, + 0x7591bb70UL, 0x3ff291baUL, 0x28401cbdUL, 0xbc82cc72UL, 0xf51fdee1UL, + 0x3ff29e9dUL, 0xafad1255UL, 0x3c8612e8UL, 0x66d10f13UL, 0x3ff2ab8aUL, + 0x191690a7UL, 0xbc995743UL, 0xd0dad990UL, 0x3ff2b87fUL, 0xd6381aa4UL, + 0xbc410adcUL, 0x39771b2fUL, 0x3ff2c57eUL, 0xa6eb5124UL, 0xbc950145UL, + 0xa6e4030bUL, 0x3ff2d285UL, 0x54db41d5UL, 0x3c900247UL, 0x1f641589UL, + 0x3ff2df96UL, 0xfbbce198UL, 0x3c9d16cfUL, 0xa93e2f56UL, 0x3ff2ecafUL, + 0x45d52383UL, 0x3c71ca0fUL, 0x4abd886bUL, 0x3ff2f9d2UL, 0x532bda93UL, + 0xbc653c55UL, 0x0a31b715UL, 0x3ff306feUL, 0xd23182e4UL, 0x3c86f46aUL, + 0xedeeb2fdUL, 0x3ff31432UL, 0xf3f3fcd1UL, 0x3c8959a3UL, 0xfc4cd831UL, + 0x3ff32170UL, 0x8e18047cUL, 0x3c8a9ce7UL, 0x3ba8ea32UL, 0x3ff32eb8UL, + 0x3cb4f318UL, 0xbc9c45e8UL, 0xb26416ffUL, 0x3ff33c08UL, 0x843659a6UL, + 0x3c932721UL, 0x66e3fa2dUL, 0x3ff34962UL, 0x930881a4UL, 0xbc835a75UL, + 0x5f929ff1UL, 0x3ff356c5UL, 0x5c4e4628UL, 0xbc8b5ceeUL, 0xa2de883bUL, + 0x3ff36431UL, 0xa06cb85eUL, 0xbc8c3144UL, 0x373aa9cbUL, 0x3ff371a7UL, + 0xbf42eae2UL, 0xbc963aeaUL, 0x231e754aUL, 0x3ff37f26UL, 0x9eceb23cUL, + 0xbc99f5caUL, 0x6d05d866UL, 0x3ff38caeUL, 0x3c9904bdUL, 0xbc9e958dUL, + 0x1b7140efUL, 0x3ff39a40UL, 0xfc8e2934UL, 0xbc99a9a5UL, 0x34e59ff7UL, + 0x3ff3a7dbUL, 0xd661f5e3UL, 0xbc75e436UL, 0xbfec6cf4UL, 0x3ff3b57fUL, + 0xe26fff18UL, 0x3c954c66UL, 0xc313a8e5UL, 0x3ff3c32dUL, 0x375d29c3UL, + 0xbc9efff8UL, 0x44ede173UL, 0x3ff3d0e5UL, 0x8c284c71UL, 0x3c7fe8d0UL, + 0x4c123422UL, 0x3ff3dea6UL, 0x11f09ebcUL, 0x3c8ada09UL, 0xdf1c5175UL, + 0x3ff3ec70UL, 0x7b8c9bcaUL, 0xbc8af663UL, 0x04ac801cUL, 0x3ff3fa45UL, + 0xf956f9f3UL, 0xbc97d023UL, 0xc367a024UL, 0x3ff40822UL, 0xb6f4d048UL, + 0x3c8bddf8UL, 0x21f72e2aUL, 0x3ff4160aUL, 0x1c309278UL, 0xbc5ef369UL, + 0x2709468aUL, 0x3ff423fbUL, 0xc0b314ddUL, 0xbc98462dUL, 0xd950a897UL, + 0x3ff431f5UL, 0xe35f7999UL, 0xbc81c7ddUL, 0x3f84b9d4UL, 0x3ff43ffaUL, + 0x9704c003UL, 0x3c8880beUL, 0x6061892dUL, 0x3ff44e08UL, 0x04ef80d0UL, + 0x3c489b7aUL, 0x42a7d232UL, 0x3ff45c20UL, 0x82fb1f8eUL, 0xbc686419UL, + 0xed1d0057UL, 0x3ff46a41UL, 0xd1648a76UL, 0x3c9c944bUL, 0x668b3237UL, + 0x3ff4786dUL, 0xed445733UL, 0xbc9c20f0UL, 0xb5c13cd0UL, 0x3ff486a2UL, + 0xb69062f0UL, 0x3c73c1a3UL, 0xe192aed2UL, 0x3ff494e1UL, 0x5e499ea0UL, + 0xbc83b289UL, 0xf0d7d3deUL, 0x3ff4a32aUL, 0xf3d1be56UL, 0x3c99cb62UL, + 0xea6db7d7UL, 0x3ff4b17dUL, 0x7f2897f0UL, 0xbc8125b8UL, 0xd5362a27UL, + 0x3ff4bfdaUL, 0xafec42e2UL, 0x3c7d4397UL, 0xb817c114UL, 0x3ff4ce41UL, + 0x690abd5dUL, 0x3c905e29UL, 0x99fddd0dUL, 0x3ff4dcb2UL, 0xbc6a7833UL, + 0x3c98ecdbUL, 0x81d8abffUL, 0x3ff4eb2dUL, 0x2e5d7a52UL, 0xbc95257dUL, + 0x769d2ca7UL, 0x3ff4f9b2UL, 0xd25957e3UL, 0xbc94b309UL, 0x7f4531eeUL, + 0x3ff50841UL, 0x49b7465fUL, 0x3c7a249bUL, 0xa2cf6642UL, 0x3ff516daUL, + 0x69bd93efUL, 0xbc8f7685UL, 0xe83f4eefUL, 0x3ff5257dUL, 0x43efef71UL, + 0xbc7c998dUL, 0x569d4f82UL, 0x3ff5342bUL, 0x1db13cadUL, 0xbc807abeUL, + 0xf4f6ad27UL, 0x3ff542e2UL, 0x192d5f7eUL, 0x3c87926dUL, 0xca5d920fUL, + 0x3ff551a4UL, 0xefede59bUL, 0xbc8d689cUL, 0xdde910d2UL, 0x3ff56070UL, + 0x168eebf0UL, 0xbc90fb6eUL, 0x36b527daUL, 0x3ff56f47UL, 0x011d93adUL, + 0x3c99bb2cUL, 0xdbe2c4cfUL, 0x3ff57e27UL, 0x8a57b9c4UL, 0xbc90b98cUL, + 0xd497c7fdUL, 0x3ff58d12UL, 0x5b9a1de8UL, 0x3c8295e1UL, 0x27ff07ccUL, + 0x3ff59c08UL, 0xe467e60fUL, 0xbc97e2ceUL, 0xdd485429UL, 0x3ff5ab07UL, + 0x054647adUL, 0x3c96324cUL, 0xfba87a03UL, 0x3ff5ba11UL, 0x4c233e1aUL, + 0xbc9b77a1UL, 0x8a5946b7UL, 0x3ff5c926UL, 0x816986a2UL, 0x3c3c4b1bUL, + 0x90998b93UL, 0x3ff5d845UL, 0xa8b45643UL, 0xbc9cd6a7UL, 0x15ad2148UL, + 0x3ff5e76fUL, 0x3080e65eUL, 0x3c9ba6f9UL, 0x20dceb71UL, 0x3ff5f6a3UL, + 0xe3cdcf92UL, 0xbc89eaddUL, 0xb976dc09UL, 0x3ff605e1UL, 0x9b56de47UL, + 0xbc93e242UL, 0xe6cdf6f4UL, 0x3ff6152aUL, 0x4ab84c27UL, 0x3c9e4b3eUL, + 0xb03a5585UL, 0x3ff6247eUL, 0x7e40b497UL, 0xbc9383c1UL, 0x1d1929fdUL, + 0x3ff633ddUL, 0xbeb964e5UL, 0x3c984710UL, 0x34ccc320UL, 0x3ff64346UL, + 0x759d8933UL, 0xbc8c483cUL, 0xfebc8fb7UL, 0x3ff652b9UL, 0xc9a73e09UL, + 0xbc9ae3d5UL, 0x82552225UL, 0x3ff66238UL, 0x87591c34UL, 0xbc9bb609UL, + 0xc70833f6UL, 0x3ff671c1UL, 0x586c6134UL, 0xbc8e8732UL, 0xd44ca973UL, + 0x3ff68155UL, 0x44f73e65UL, 0x3c6038aeUL, 0xb19e9538UL, 0x3ff690f4UL, + 0x9aeb445dUL, 0x3c8804bdUL, 0x667f3bcdUL, 0x3ff6a09eUL, 0x13b26456UL, + 0xbc9bdd34UL, 0xfa75173eUL, 0x3ff6b052UL, 0x2c9a9d0eUL, 0x3c7a38f5UL, + 0x750bdabfUL, 0x3ff6c012UL, 0x67ff0b0dUL, 0xbc728956UL, 0xddd47645UL, + 0x3ff6cfdcUL, 0xb6f17309UL, 0x3c9c7aa9UL, 0x3c651a2fUL, 0x3ff6dfb2UL, + 0x683c88abUL, 0xbc6bbe3aUL, 0x98593ae5UL, 0x3ff6ef92UL, 0x9e1ac8b2UL, + 0xbc90b974UL, 0xf9519484UL, 0x3ff6ff7dUL, 0x25860ef6UL, 0xbc883c0fUL, + 0x66f42e87UL, 0x3ff70f74UL, 0xd45aa65fUL, 0x3c59d644UL, 0xe8ec5f74UL, + 0x3ff71f75UL, 0x86887a99UL, 0xbc816e47UL, 0x86ead08aUL, 0x3ff72f82UL, + 0x2cd62c72UL, 0xbc920aa0UL, 0x48a58174UL, 0x3ff73f9aUL, 0x6c65d53cUL, + 0xbc90a8d9UL, 0x35d7cbfdUL, 0x3ff74fbdUL, 0x618a6e1cUL, 0x3c9047fdUL, + 0x564267c9UL, 0x3ff75febUL, 0x57316dd3UL, 0xbc902459UL, 0xb1ab6e09UL, + 0x3ff77024UL, 0x169147f8UL, 0x3c9b7877UL, 0x4fde5d3fUL, 0x3ff78069UL, + 0x0a02162dUL, 0x3c9866b8UL, 0x38ac1cf6UL, 0x3ff790b9UL, 0x62aadd3eUL, + 0x3c9349a8UL, 0x73eb0187UL, 0x3ff7a114UL, 0xee04992fUL, 0xbc841577UL, + 0x0976cfdbUL, 0x3ff7b17bUL, 0x8468dc88UL, 0xbc9bebb5UL, 0x0130c132UL, + 0x3ff7c1edUL, 0xd1164dd6UL, 0x3c9f124cUL, 0x62ff86f0UL, 0x3ff7d26aUL, + 0xfb72b8b4UL, 0x3c91bddbUL, 0x36cf4e62UL, 0x3ff7e2f3UL, 0xba15797eUL, + 0x3c705d02UL, 0x8491c491UL, 0x3ff7f387UL, 0xcf9311aeUL, 0xbc807f11UL, + 0x543e1a12UL, 0x3ff80427UL, 0x626d972bUL, 0xbc927c86UL, 0xadd106d9UL, + 0x3ff814d2UL, 0x0d151d4dUL, 0x3c946437UL, 0x994cce13UL, 0x3ff82589UL, + 0xd41532d8UL, 0xbc9d4c1dUL, 0x1eb941f7UL, 0x3ff8364cUL, 0x31df2bd5UL, + 0x3c999b9aUL, 0x4623c7adUL, 0x3ff8471aUL, 0xa341cdfbUL, 0xbc88d684UL, + 0x179f5b21UL, 0x3ff857f4UL, 0xf8b216d0UL, 0xbc5ba748UL, 0x9b4492edUL, + 0x3ff868d9UL, 0x9bd4f6baUL, 0xbc9fc6f8UL, 0xd931a436UL, 0x3ff879caUL, + 0xd2db47bdUL, 0x3c85d2d7UL, 0xd98a6699UL, 0x3ff88ac7UL, 0xf37cb53aUL, + 0x3c9994c2UL, 0xa478580fUL, 0x3ff89bd0UL, 0x4475202aUL, 0x3c9d5395UL, + 0x422aa0dbUL, 0x3ff8ace5UL, 0x56864b27UL, 0x3c96e9f1UL, 0xbad61778UL, + 0x3ff8be05UL, 0xfc43446eUL, 0x3c9ecb5eUL, 0x16b5448cUL, 0x3ff8cf32UL, + 0x32e9e3aaUL, 0xbc70d55eUL, 0x5e0866d9UL, 0x3ff8e06aUL, 0x6fc9b2e6UL, + 0xbc97114aUL, 0x99157736UL, 0x3ff8f1aeUL, 0xa2e3976cUL, 0x3c85cc13UL, + 0xd0282c8aUL, 0x3ff902feUL, 0x85fe3fd2UL, 0x3c9592caUL, 0x0b91ffc6UL, + 0x3ff9145bUL, 0x2e582524UL, 0xbc9dd679UL, 0x53aa2fe2UL, 0x3ff925c3UL, + 0xa639db7fUL, 0xbc83455fUL, 0xb0cdc5e5UL, 0x3ff93737UL, 0x81b57ebcUL, + 0xbc675fc7UL, 0x2b5f98e5UL, 0x3ff948b8UL, 0x797d2d99UL, 0xbc8dc3d6UL, + 0xcbc8520fUL, 0x3ff95a44UL, 0x96a5f039UL, 0xbc764b7cUL, 0x9a7670b3UL, + 0x3ff96bddUL, 0x7f19c896UL, 0xbc5ba596UL, 0x9fde4e50UL, 0x3ff97d82UL, + 0x7c1b85d1UL, 0xbc9d185bUL, 0xe47a22a2UL, 0x3ff98f33UL, 0xa24c78ecUL, + 0x3c7cabdaUL, 0x70ca07baUL, 0x3ff9a0f1UL, 0x91cee632UL, 0xbc9173bdUL, + 0x4d53fe0dUL, 0x3ff9b2bbUL, 0x4df6d518UL, 0xbc9dd84eUL, 0x82a3f090UL, + 0x3ff9c491UL, 0xb071f2beUL, 0x3c7c7c46UL, 0x194bb8d5UL, 0x3ff9d674UL, + 0xa3dd8233UL, 0xbc9516beUL, 0x19e32323UL, 0x3ff9e863UL, 0x78e64c6eUL, + 0x3c7824caUL, 0x8d07f29eUL, 0x3ff9fa5eUL, 0xaaf1faceUL, 0xbc84a9ceUL, + 0x7b5de565UL, 0x3ffa0c66UL, 0x5d1cd533UL, 0xbc935949UL, 0xed8eb8bbUL, + 0x3ffa1e7aUL, 0xee8be70eUL, 0x3c9c6618UL, 0xec4a2d33UL, 0x3ffa309bUL, + 0x7ddc36abUL, 0x3c96305cUL, 0x80460ad8UL, 0x3ffa42c9UL, 0x589fb120UL, + 0xbc9aa780UL, 0xb23e255dUL, 0x3ffa5503UL, 0xdb8d41e1UL, 0xbc9d2f6eUL, + 0x8af46052UL, 0x3ffa674aUL, 0x30670366UL, 0x3c650f56UL, 0x1330b358UL, + 0x3ffa799eUL, 0xcac563c7UL, 0x3c9bcb7eUL, 0x53c12e59UL, 0x3ffa8bfeUL, + 0xb2ba15a9UL, 0xbc94f867UL, 0x5579fdbfUL, 0x3ffa9e6bUL, 0x0ef7fd31UL, + 0x3c90fac9UL, 0x21356ebaUL, 0x3ffab0e5UL, 0xdae94545UL, 0x3c889c31UL, + 0xbfd3f37aUL, 0x3ffac36bUL, 0xcae76cd0UL, 0xbc8f9234UL, 0x3a3c2774UL, + 0x3ffad5ffUL, 0xb6b1b8e5UL, 0x3c97ef3bUL, 0x995ad3adUL, 0x3ffae89fUL, + 0x345dcc81UL, 0x3c97a1cdUL, 0xe622f2ffUL, 0x3ffafb4cUL, 0x0f315ecdUL, + 0xbc94b2fcUL, 0x298db666UL, 0x3ffb0e07UL, 0x4c80e425UL, 0xbc9bdef5UL, + 0x6c9a8952UL, 0x3ffb20ceUL, 0x4a0756ccUL, 0x3c94dd02UL, 0xb84f15fbUL, + 0x3ffb33a2UL, 0x3084d708UL, 0xbc62805eUL, 0x15b749b1UL, 0x3ffb4684UL, + 0xe9df7c90UL, 0xbc7f763dUL, 0x8de5593aUL, 0x3ffb5972UL, 0xbbba6de3UL, + 0xbc9c71dfUL, 0x29f1c52aUL, 0x3ffb6c6eUL, 0x52883f6eUL, 0x3c92a8f3UL, + 0xf2fb5e47UL, 0x3ffb7f76UL, 0x7e54ac3bUL, 0xbc75584fUL, 0xf22749e4UL, + 0x3ffb928cUL, 0x54cb65c6UL, 0xbc9b7216UL, 0x30a1064aUL, 0x3ffba5b0UL, + 0x0e54292eUL, 0xbc9efcd3UL, 0xb79a6f1fUL, 0x3ffbb8e0UL, 0xc9696205UL, + 0xbc3f52d1UL, 0x904bc1d2UL, 0x3ffbcc1eUL, 0x7a2d9e84UL, 0x3c823dd0UL, + 0xc3f3a207UL, 0x3ffbdf69UL, 0x60ea5b53UL, 0xbc3c2623UL, 0x5bd71e09UL, + 0x3ffbf2c2UL, 0x3f6b9c73UL, 0xbc9efdcaUL, 0x6141b33dUL, 0x3ffc0628UL, + 0xa1fbca34UL, 0xbc8d8a5aUL, 0xdd85529cUL, 0x3ffc199bUL, 0x895048ddUL, + 0x3c811065UL, 0xd9fa652cUL, 0x3ffc2d1cUL, 0x17c8a5d7UL, 0xbc96e516UL, + 0x5fffd07aUL, 0x3ffc40abUL, 0xe083c60aUL, 0x3c9b4537UL, 0x78fafb22UL, + 0x3ffc5447UL, 0x2493b5afUL, 0x3c912f07UL, 0x2e57d14bUL, 0x3ffc67f1UL, + 0xff483cadUL, 0x3c92884dUL, 0x8988c933UL, 0x3ffc7ba8UL, 0xbe255559UL, + 0xbc8e76bbUL, 0x9406e7b5UL, 0x3ffc8f6dUL, 0x48805c44UL, 0x3c71acbcUL, + 0x5751c4dbUL, 0x3ffca340UL, 0xd10d08f5UL, 0xbc87f2beUL, 0xdcef9069UL, + 0x3ffcb720UL, 0xd1e949dbUL, 0x3c7503cbUL, 0x2e6d1675UL, 0x3ffccb0fUL, + 0x86009092UL, 0xbc7d220fUL, 0x555dc3faUL, 0x3ffcdf0bUL, 0x53829d72UL, + 0xbc8dd83bUL, 0x5b5bab74UL, 0x3ffcf315UL, 0xb86dff57UL, 0xbc9a08e9UL, + 0x4a07897cUL, 0x3ffd072dUL, 0x43797a9cUL, 0xbc9cbc37UL, 0x2b08c968UL, + 0x3ffd1b53UL, 0x219a36eeUL, 0x3c955636UL, 0x080d89f2UL, 0x3ffd2f87UL, + 0x719d8578UL, 0xbc9d487bUL, 0xeacaa1d6UL, 0x3ffd43c8UL, 0xbf5a1614UL, + 0x3c93db53UL, 0xdcfba487UL, 0x3ffd5818UL, 0xd75b3707UL, 0x3c82ed02UL, + 0xe862e6d3UL, 0x3ffd6c76UL, 0x4a8165a0UL, 0x3c5fe87aUL, 0x16c98398UL, + 0x3ffd80e3UL, 0x8beddfe8UL, 0xbc911ec1UL, 0x71ff6075UL, 0x3ffd955dUL, + 0xbb9af6beUL, 0x3c9a052dUL, 0x03db3285UL, 0x3ffda9e6UL, 0x696db532UL, + 0x3c9c2300UL, 0xd63a8315UL, 0x3ffdbe7cUL, 0x926b8be4UL, 0xbc9b76f1UL, + 0xf301b460UL, 0x3ffdd321UL, 0x78f018c3UL, 0x3c92da57UL, 0x641c0658UL, + 0x3ffde7d5UL, 0x8e79ba8fUL, 0xbc9ca552UL, 0x337b9b5fUL, 0x3ffdfc97UL, + 0x4f184b5cUL, 0xbc91a5cdUL, 0x6b197d17UL, 0x3ffe1167UL, 0xbd5c7f44UL, + 0xbc72b529UL, 0x14f5a129UL, 0x3ffe2646UL, 0x817a1496UL, 0xbc97b627UL, + 0x3b16ee12UL, 0x3ffe3b33UL, 0x31fdc68bUL, 0xbc99f4a4UL, 0xe78b3ff6UL, + 0x3ffe502eUL, 0x80a9cc8fUL, 0x3c839e89UL, 0x24676d76UL, 0x3ffe6539UL, + 0x7522b735UL, 0xbc863ff8UL, 0xfbc74c83UL, 0x3ffe7a51UL, 0xca0c8de2UL, + 0x3c92d522UL, 0x77cdb740UL, 0x3ffe8f79UL, 0x80b054b1UL, 0xbc910894UL, + 0xa2a490daUL, 0x3ffea4afUL, 0x179c2893UL, 0xbc9e9c23UL, 0x867cca6eUL, + 0x3ffeb9f4UL, 0x2293e4f2UL, 0x3c94832fUL, 0x2d8e67f1UL, 0x3ffecf48UL, + 0xb411ad8cUL, 0xbc9c93f3UL, 0xa2188510UL, 0x3ffee4aaUL, 0xa487568dUL, + 0x3c91c68dUL, 0xee615a27UL, 0x3ffefa1bUL, 0x86a4b6b0UL, 0x3c9dc7f4UL, + 0x1cb6412aUL, 0x3fff0f9cUL, 0x65181d45UL, 0xbc932200UL, 0x376bba97UL, + 0x3fff252bUL, 0xbf0d8e43UL, 0x3c93a1a5UL, 0x48dd7274UL, 0x3fff3ac9UL, + 0x3ed837deUL, 0xbc795a5aUL, 0x5b6e4540UL, 0x3fff5076UL, 0x2dd8a18bUL, + 0x3c99d3e1UL, 0x798844f8UL, 0x3fff6632UL, 0x3539343eUL, 0x3c9fa37bUL, + 0xad9cbe14UL, 0x3fff7bfdUL, 0xd006350aUL, 0xbc9dbb12UL, 0x02243c89UL, + 0x3fff91d8UL, 0xa779f689UL, 0xbc612ea8UL, 0x819e90d8UL, 0x3fffa7c1UL, + 0xf3a5931eUL, 0x3c874853UL, 0x3692d514UL, 0x3fffbdbaUL, 0x15098eb6UL, + 0xbc796773UL, 0x2b8f71f1UL, 0x3fffd3c2UL, 0x966579e7UL, 0x3c62eb74UL, + 0x6b2a23d9UL, 0x3fffe9d9UL, 0x7442fde3UL, 0x3c74a603UL +}; + +ALIGNED_(16) juint _e_coeff[] = +{ + 0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL, 0x6fba4e77UL, + 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL, 0xfefa39efUL, 0x3fe62e42UL, + 0x00000000UL, 0x00000000UL +}; + +ALIGNED_(16) juint _coeff_h[] = +{ + 0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL +}; + +ALIGNED_(16) juint _HIGHMASK_LOG_X[] = +{ + 0xf8000000UL, 0xffffffffUL, 0x00000000UL, 0xfffff800UL +}; + +ALIGNED_(8) juint _HALFMASK[] = +{ + 0xf8000000UL, 0xffffffffUL, 0xf8000000UL, 0xffffffffUL +}; + +ALIGNED_(16) juint _coeff_pow[] = +{ + 0x6dc96112UL, 0xbf836578UL, 0xee241472UL, 0xbf9b0301UL, 0x9f95985aUL, + 0xbfb528dbUL, 0xb3841d2aUL, 0xbfd619b6UL, 0x518775e3UL, 0x3f9004f2UL, + 0xac8349bbUL, 0x3fa76c9bUL, 0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, + 0xbf5dabe1UL, 0x9f95985aUL, 0xbfb528dbUL, 0xf8b5787dUL, 0x3ef2531eUL, + 0x486ececbUL, 0x3fc4635eUL, 0x412055ccUL, 0xbdd61bb2UL +}; + +ALIGNED_(16) juint _L_tbl_pow[] = +{ + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x20000000UL, + 0x3feff00aUL, 0x96621f95UL, 0x3e5b1856UL, 0xe0000000UL, 0x3fefe019UL, + 0xe5916f9eUL, 0xbe325278UL, 0x00000000UL, 0x3fefd02fUL, 0x859a1062UL, + 0x3e595fb7UL, 0xc0000000UL, 0x3fefc049UL, 0xb245f18fUL, 0xbe529c38UL, + 0xe0000000UL, 0x3fefb069UL, 0xad2880a7UL, 0xbe501230UL, 0x60000000UL, + 0x3fefa08fUL, 0xc8e72420UL, 0x3e597bd1UL, 0x80000000UL, 0x3fef90baUL, + 0xc30c4500UL, 0xbe5d6c75UL, 0xe0000000UL, 0x3fef80eaUL, 0x02c63f43UL, + 0x3e2e1318UL, 0xc0000000UL, 0x3fef7120UL, 0xb3d4ccccUL, 0xbe44c52aUL, + 0x00000000UL, 0x3fef615cUL, 0xdbd91397UL, 0xbe4e7d6cUL, 0xa0000000UL, + 0x3fef519cUL, 0x65c5cd68UL, 0xbe522dc8UL, 0xa0000000UL, 0x3fef41e2UL, + 0x46d1306cUL, 0xbe5a840eUL, 0xe0000000UL, 0x3fef322dUL, 0xd2980e94UL, + 0x3e5071afUL, 0xa0000000UL, 0x3fef227eUL, 0x773abadeUL, 0xbe5891e5UL, + 0xa0000000UL, 0x3fef12d4UL, 0xdc6bf46bUL, 0xbe5cccbeUL, 0xe0000000UL, + 0x3fef032fUL, 0xbc7247faUL, 0xbe2bab83UL, 0x80000000UL, 0x3feef390UL, + 0xbcaa1e46UL, 0xbe53bb3bUL, 0x60000000UL, 0x3feee3f6UL, 0x5f6c682dUL, + 0xbe54c619UL, 0x80000000UL, 0x3feed461UL, 0x5141e368UL, 0xbe4b6d86UL, + 0xe0000000UL, 0x3feec4d1UL, 0xec678f76UL, 0xbe369af6UL, 0x80000000UL, + 0x3feeb547UL, 0x41301f55UL, 0xbe2d4312UL, 0x60000000UL, 0x3feea5c2UL, + 0x676da6bdUL, 0xbe4d8dd0UL, 0x60000000UL, 0x3fee9642UL, 0x57a891c4UL, + 0x3e51f991UL, 0xa0000000UL, 0x3fee86c7UL, 0xe4eb491eUL, 0x3e579bf9UL, + 0x20000000UL, 0x3fee7752UL, 0xfddc4a2cUL, 0xbe3356e6UL, 0xc0000000UL, + 0x3fee67e1UL, 0xd75b5bf1UL, 0xbe449531UL, 0x80000000UL, 0x3fee5876UL, + 0xbd423b8eUL, 0x3df54fe4UL, 0x60000000UL, 0x3fee4910UL, 0x330e51b9UL, + 0x3e54289cUL, 0x80000000UL, 0x3fee39afUL, 0x8651a95fUL, 0xbe55aad6UL, + 0xa0000000UL, 0x3fee2a53UL, 0x5e98c708UL, 0xbe2fc4a9UL, 0xe0000000UL, + 0x3fee1afcUL, 0x0989328dUL, 0x3e23958cUL, 0x40000000UL, 0x3fee0babUL, + 0xee642abdUL, 0xbe425dd8UL, 0xa0000000UL, 0x3fedfc5eUL, 0xc394d236UL, + 0x3e526362UL, 0x20000000UL, 0x3feded17UL, 0xe104aa8eUL, 0x3e4ce247UL, + 0xc0000000UL, 0x3fedddd4UL, 0x265a9be4UL, 0xbe5bb77aUL, 0x40000000UL, + 0x3fedce97UL, 0x0ecac52fUL, 0x3e4a7cb1UL, 0xe0000000UL, 0x3fedbf5eUL, + 0x124cb3b8UL, 0x3e257024UL, 0x80000000UL, 0x3fedb02bUL, 0xe6d4febeUL, + 0xbe2033eeUL, 0x20000000UL, 0x3feda0fdUL, 0x39cca00eUL, 0xbe3ddabcUL, + 0xc0000000UL, 0x3fed91d3UL, 0xef8a552aUL, 0xbe543390UL, 0x40000000UL, + 0x3fed82afUL, 0xb8e85204UL, 0x3e513850UL, 0xe0000000UL, 0x3fed738fUL, + 0x3d59fe08UL, 0xbe5db728UL, 0x40000000UL, 0x3fed6475UL, 0x3aa7ead1UL, + 0x3e58804bUL, 0xc0000000UL, 0x3fed555fUL, 0xf8a35ba9UL, 0xbe5298b0UL, + 0x00000000UL, 0x3fed464fUL, 0x9a88dd15UL, 0x3e5a8cdbUL, 0x40000000UL, + 0x3fed3743UL, 0xb0b0a190UL, 0x3e598635UL, 0x80000000UL, 0x3fed283cUL, + 0xe2113295UL, 0xbe5c1119UL, 0x80000000UL, 0x3fed193aUL, 0xafbf1728UL, + 0xbe492e9cUL, 0x60000000UL, 0x3fed0a3dUL, 0xe4a4ccf3UL, 0x3e19b90eUL, + 0x20000000UL, 0x3fecfb45UL, 0xba3cbeb8UL, 0x3e406b50UL, 0xc0000000UL, + 0x3fecec51UL, 0x110f7dddUL, 0x3e0d6806UL, 0x40000000UL, 0x3fecdd63UL, + 0x7dd7d508UL, 0xbe5a8943UL, 0x80000000UL, 0x3fecce79UL, 0x9b60f271UL, + 0xbe50676aUL, 0x80000000UL, 0x3fecbf94UL, 0x0b9ad660UL, 0x3e59174fUL, + 0x60000000UL, 0x3fecb0b4UL, 0x00823d9cUL, 0x3e5bbf72UL, 0x20000000UL, + 0x3feca1d9UL, 0x38a6ec89UL, 0xbe4d38f9UL, 0x80000000UL, 0x3fec9302UL, + 0x3a0b7d8eUL, 0x3e53dbfdUL, 0xc0000000UL, 0x3fec8430UL, 0xc6826b34UL, + 0xbe27c5c9UL, 0xc0000000UL, 0x3fec7563UL, 0x0c706381UL, 0xbe593653UL, + 0x60000000UL, 0x3fec669bUL, 0x7df34ec7UL, 0x3e461ab5UL, 0xe0000000UL, + 0x3fec57d7UL, 0x40e5e7e8UL, 0xbe5c3daeUL, 0x00000000UL, 0x3fec4919UL, + 0x5602770fUL, 0xbe55219dUL, 0xc0000000UL, 0x3fec3a5eUL, 0xec7911ebUL, + 0x3e5a5d25UL, 0x60000000UL, 0x3fec2ba9UL, 0xb39ea225UL, 0xbe53c00bUL, + 0x80000000UL, 0x3fec1cf8UL, 0x967a212eUL, 0x3e5a8ddfUL, 0x60000000UL, + 0x3fec0e4cUL, 0x580798bdUL, 0x3e5f53abUL, 0x00000000UL, 0x3febffa5UL, + 0xb8282df6UL, 0xbe46b874UL, 0x20000000UL, 0x3febf102UL, 0xe33a6729UL, + 0x3e54963fUL, 0x00000000UL, 0x3febe264UL, 0x3b53e88aUL, 0xbe3adce1UL, + 0x60000000UL, 0x3febd3caUL, 0xc2585084UL, 0x3e5cde9fUL, 0x80000000UL, + 0x3febc535UL, 0xa335c5eeUL, 0xbe39fd9cUL, 0x20000000UL, 0x3febb6a5UL, + 0x7325b04dUL, 0x3e42ba15UL, 0x60000000UL, 0x3feba819UL, 0x1564540fUL, + 0x3e3a9f35UL, 0x40000000UL, 0x3feb9992UL, 0x83fff592UL, 0xbe5465ceUL, + 0xa0000000UL, 0x3feb8b0fUL, 0xb9da63d3UL, 0xbe4b1a0aUL, 0x80000000UL, + 0x3feb7c91UL, 0x6d6f1ea4UL, 0x3e557657UL, 0x00000000UL, 0x3feb6e18UL, + 0x5e80a1bfUL, 0x3e4ddbb6UL, 0x00000000UL, 0x3feb5fa3UL, 0x1c9eacb5UL, + 0x3e592877UL, 0xa0000000UL, 0x3feb5132UL, 0x6d40beb3UL, 0xbe51858cUL, + 0xa0000000UL, 0x3feb42c6UL, 0xd740c67bUL, 0x3e427ad2UL, 0x40000000UL, + 0x3feb345fUL, 0xa3e0cceeUL, 0xbe5c2fc4UL, 0x40000000UL, 0x3feb25fcUL, + 0x8e752b50UL, 0xbe3da3c2UL, 0xc0000000UL, 0x3feb179dUL, 0xa892e7deUL, + 0x3e1fb481UL, 0xc0000000UL, 0x3feb0943UL, 0x21ed71e9UL, 0xbe365206UL, + 0x20000000UL, 0x3feafaeeUL, 0x0e1380a3UL, 0x3e5c5b7bUL, 0x20000000UL, + 0x3feaec9dUL, 0x3c3d640eUL, 0xbe5dbbd0UL, 0x60000000UL, 0x3feade50UL, + 0x8f97a715UL, 0x3e3a8ec5UL, 0x20000000UL, 0x3fead008UL, 0x23ab2839UL, + 0x3e2fe98aUL, 0x40000000UL, 0x3feac1c4UL, 0xf4bbd50fUL, 0x3e54d8f6UL, + 0xe0000000UL, 0x3feab384UL, 0x14757c4dUL, 0xbe48774cUL, 0xc0000000UL, + 0x3feaa549UL, 0x7c7b0eeaUL, 0x3e5b51bbUL, 0x20000000UL, 0x3fea9713UL, + 0xf56f7013UL, 0x3e386200UL, 0xe0000000UL, 0x3fea88e0UL, 0xbe428ebeUL, + 0xbe514af5UL, 0xe0000000UL, 0x3fea7ab2UL, 0x8d0e4496UL, 0x3e4f9165UL, + 0x60000000UL, 0x3fea6c89UL, 0xdbacc5d5UL, 0xbe5c063bUL, 0x20000000UL, + 0x3fea5e64UL, 0x3f19d970UL, 0xbe5a0c8cUL, 0x20000000UL, 0x3fea5043UL, + 0x09ea3e6bUL, 0x3e5065dcUL, 0x80000000UL, 0x3fea4226UL, 0x78df246cUL, + 0x3e5e05f6UL, 0x40000000UL, 0x3fea340eUL, 0x4057d4a0UL, 0x3e431b2bUL, + 0x40000000UL, 0x3fea25faUL, 0x82867bb5UL, 0x3e4b76beUL, 0xa0000000UL, + 0x3fea17eaUL, 0x9436f40aUL, 0xbe5aad39UL, 0x20000000UL, 0x3fea09dfUL, + 0x4b5253b3UL, 0x3e46380bUL, 0x00000000UL, 0x3fe9fbd8UL, 0x8fc52466UL, + 0xbe386f9bUL, 0x20000000UL, 0x3fe9edd5UL, 0x22d3f344UL, 0xbe538347UL, + 0x60000000UL, 0x3fe9dfd6UL, 0x1ac33522UL, 0x3e5dbc53UL, 0x00000000UL, + 0x3fe9d1dcUL, 0xeabdff1dUL, 0x3e40fc0cUL, 0xe0000000UL, 0x3fe9c3e5UL, + 0xafd30e73UL, 0xbe585e63UL, 0xe0000000UL, 0x3fe9b5f3UL, 0xa52f226aUL, + 0xbe43e8f9UL, 0x20000000UL, 0x3fe9a806UL, 0xecb8698dUL, 0xbe515b36UL, + 0x80000000UL, 0x3fe99a1cUL, 0xf2b4e89dUL, 0x3e48b62bUL, 0x20000000UL, + 0x3fe98c37UL, 0x7c9a88fbUL, 0x3e44414cUL, 0x00000000UL, 0x3fe97e56UL, + 0xda015741UL, 0xbe5d13baUL, 0xe0000000UL, 0x3fe97078UL, 0x5fdace06UL, + 0x3e51b947UL, 0x00000000UL, 0x3fe962a0UL, 0x956ca094UL, 0x3e518785UL, + 0x40000000UL, 0x3fe954cbUL, 0x01164c1dUL, 0x3e5d5b57UL, 0xc0000000UL, + 0x3fe946faUL, 0xe63b3767UL, 0xbe4f84e7UL, 0x40000000UL, 0x3fe9392eUL, + 0xe57cc2a9UL, 0x3e34eda3UL, 0xe0000000UL, 0x3fe92b65UL, 0x8c75b544UL, + 0x3e5766a0UL, 0xc0000000UL, 0x3fe91da1UL, 0x37d1d087UL, 0xbe5e2ab1UL, + 0x80000000UL, 0x3fe90fe1UL, 0xa953dc20UL, 0x3e5fa1f3UL, 0x80000000UL, + 0x3fe90225UL, 0xdbd3f369UL, 0x3e47d6dbUL, 0xa0000000UL, 0x3fe8f46dUL, + 0x1c9be989UL, 0xbe5e2b0aUL, 0xa0000000UL, 0x3fe8e6b9UL, 0x3c93d76aUL, + 0x3e5c8618UL, 0xe0000000UL, 0x3fe8d909UL, 0x2182fc9aUL, 0xbe41aa9eUL, + 0x20000000UL, 0x3fe8cb5eUL, 0xe6b3539dUL, 0xbe530d19UL, 0x60000000UL, + 0x3fe8bdb6UL, 0x49e58cc3UL, 0xbe3bb374UL, 0xa0000000UL, 0x3fe8b012UL, + 0xa7cfeb8fUL, 0x3e56c412UL, 0x00000000UL, 0x3fe8a273UL, 0x8d52bc19UL, + 0x3e1429b8UL, 0x60000000UL, 0x3fe894d7UL, 0x4dc32c6cUL, 0xbe48604cUL, + 0xc0000000UL, 0x3fe8873fUL, 0x0c868e56UL, 0xbe564ee5UL, 0x00000000UL, + 0x3fe879acUL, 0x56aee828UL, 0x3e5e2fd8UL, 0x60000000UL, 0x3fe86c1cUL, + 0x7ceab8ecUL, 0x3e493365UL, 0xc0000000UL, 0x3fe85e90UL, 0x78d4dadcUL, + 0xbe4f7f25UL, 0x00000000UL, 0x3fe85109UL, 0x0ccd8280UL, 0x3e31e7a2UL, + 0x40000000UL, 0x3fe84385UL, 0x34ba4e15UL, 0x3e328077UL, 0x80000000UL, + 0x3fe83605UL, 0xa670975aUL, 0xbe53eee5UL, 0xa0000000UL, 0x3fe82889UL, + 0xf61b77b2UL, 0xbe43a20aUL, 0xa0000000UL, 0x3fe81b11UL, 0x13e6643bUL, + 0x3e5e5fe5UL, 0xc0000000UL, 0x3fe80d9dUL, 0x82cc94e8UL, 0xbe5ff1f9UL, + 0xa0000000UL, 0x3fe8002dUL, 0x8a0c9c5dUL, 0xbe42b0e7UL, 0x60000000UL, + 0x3fe7f2c1UL, 0x22a16f01UL, 0x3e5d9ea0UL, 0x20000000UL, 0x3fe7e559UL, + 0xc38cd451UL, 0x3e506963UL, 0xc0000000UL, 0x3fe7d7f4UL, 0x9902bc71UL, + 0x3e4503d7UL, 0x40000000UL, 0x3fe7ca94UL, 0xdef2a3c0UL, 0x3e3d98edUL, + 0xa0000000UL, 0x3fe7bd37UL, 0xed49abb0UL, 0x3e24c1ffUL, 0xe0000000UL, + 0x3fe7afdeUL, 0xe3b0be70UL, 0xbe40c467UL, 0x00000000UL, 0x3fe7a28aUL, + 0xaf9f193cUL, 0xbe5dff6cUL, 0xe0000000UL, 0x3fe79538UL, 0xb74cf6b6UL, + 0xbe258ed0UL, 0xa0000000UL, 0x3fe787ebUL, 0x1d9127c7UL, 0x3e345fb0UL, + 0x40000000UL, 0x3fe77aa2UL, 0x1028c21dUL, 0xbe4619bdUL, 0xa0000000UL, + 0x3fe76d5cUL, 0x7cb0b5e4UL, 0x3e40f1a2UL, 0xe0000000UL, 0x3fe7601aUL, + 0x2b1bc4adUL, 0xbe32e8bbUL, 0xe0000000UL, 0x3fe752dcUL, 0x6839f64eUL, + 0x3e41f57bUL, 0xc0000000UL, 0x3fe745a2UL, 0xc4121f7eUL, 0xbe52c40aUL, + 0x60000000UL, 0x3fe7386cUL, 0xd6852d72UL, 0xbe5c4e6bUL, 0xc0000000UL, + 0x3fe72b39UL, 0x91d690f7UL, 0xbe57f88fUL, 0xe0000000UL, 0x3fe71e0aUL, + 0x627a2159UL, 0xbe4425d5UL, 0xc0000000UL, 0x3fe710dfUL, 0x50a54033UL, + 0x3e422b7eUL, 0x60000000UL, 0x3fe703b8UL, 0x3b0b5f91UL, 0x3e5d3857UL, + 0xe0000000UL, 0x3fe6f694UL, 0x84d628a2UL, 0xbe51f090UL, 0x00000000UL, + 0x3fe6e975UL, 0x306d8894UL, 0xbe414d83UL, 0xe0000000UL, 0x3fe6dc58UL, + 0x30bf24aaUL, 0xbe4650caUL, 0x80000000UL, 0x3fe6cf40UL, 0xd4628d69UL, + 0xbe5db007UL, 0xc0000000UL, 0x3fe6c22bUL, 0xa2aae57bUL, 0xbe31d279UL, + 0xc0000000UL, 0x3fe6b51aUL, 0x860edf7eUL, 0xbe2d4c4aUL, 0x80000000UL, + 0x3fe6a80dUL, 0xf3559341UL, 0xbe5f7e98UL, 0xe0000000UL, 0x3fe69b03UL, + 0xa885899eUL, 0xbe5c2011UL, 0xe0000000UL, 0x3fe68dfdUL, 0x2bdc6d37UL, + 0x3e224a82UL, 0xa0000000UL, 0x3fe680fbUL, 0xc12ad1b9UL, 0xbe40cf56UL, + 0x00000000UL, 0x3fe673fdUL, 0x1bcdf659UL, 0xbdf52f2dUL, 0x00000000UL, + 0x3fe66702UL, 0x5df10408UL, 0x3e5663e0UL, 0xc0000000UL, 0x3fe65a0aUL, + 0xa4070568UL, 0xbe40b12fUL, 0x00000000UL, 0x3fe64d17UL, 0x71c54c47UL, + 0x3e5f5e8bUL, 0x00000000UL, 0x3fe64027UL, 0xbd4b7e83UL, 0x3e42ead6UL, + 0xa0000000UL, 0x3fe6333aUL, 0x61598bd2UL, 0xbe4c48d4UL, 0xc0000000UL, + 0x3fe62651UL, 0x6f538d61UL, 0x3e548401UL, 0xa0000000UL, 0x3fe6196cUL, + 0x14344120UL, 0xbe529af6UL, 0x00000000UL, 0x3fe60c8bUL, 0x5982c587UL, + 0xbe3e1e4fUL, 0x00000000UL, 0x3fe5ffadUL, 0xfe51d4eaUL, 0xbe4c897aUL, + 0x80000000UL, 0x3fe5f2d2UL, 0xfd46ebe1UL, 0x3e552e00UL, 0xa0000000UL, + 0x3fe5e5fbUL, 0xa4695699UL, 0x3e5ed471UL, 0x60000000UL, 0x3fe5d928UL, + 0x80d118aeUL, 0x3e456b61UL, 0xa0000000UL, 0x3fe5cc58UL, 0x304c330bUL, + 0x3e54dc29UL, 0x80000000UL, 0x3fe5bf8cUL, 0x0af2dedfUL, 0xbe3aa9bdUL, + 0xe0000000UL, 0x3fe5b2c3UL, 0x15fc9258UL, 0xbe479a37UL, 0xc0000000UL, + 0x3fe5a5feUL, 0x9292c7eaUL, 0x3e188650UL, 0x20000000UL, 0x3fe5993dUL, + 0x33b4d380UL, 0x3e5d6d93UL, 0x20000000UL, 0x3fe58c7fUL, 0x02fd16c7UL, + 0x3e2fe961UL, 0xa0000000UL, 0x3fe57fc4UL, 0x4a05edb6UL, 0xbe4d55b4UL, + 0xa0000000UL, 0x3fe5730dUL, 0x3d443abbUL, 0xbe5e6954UL, 0x00000000UL, + 0x3fe5665aUL, 0x024acfeaUL, 0x3e50e61bUL, 0x00000000UL, 0x3fe559aaUL, + 0xcc9edd09UL, 0xbe325403UL, 0x60000000UL, 0x3fe54cfdUL, 0x1fe26950UL, + 0x3e5d500eUL, 0x60000000UL, 0x3fe54054UL, 0x6c5ae164UL, 0xbe4a79b4UL, + 0xc0000000UL, 0x3fe533aeUL, 0x154b0287UL, 0xbe401571UL, 0xa0000000UL, + 0x3fe5270cUL, 0x0673f401UL, 0xbe56e56bUL, 0xe0000000UL, 0x3fe51a6dUL, + 0x751b639cUL, 0x3e235269UL, 0xa0000000UL, 0x3fe50dd2UL, 0x7c7b2bedUL, + 0x3ddec887UL, 0xc0000000UL, 0x3fe5013aUL, 0xafab4e17UL, 0x3e5e7575UL, + 0x60000000UL, 0x3fe4f4a6UL, 0x2e308668UL, 0x3e59aed6UL, 0x80000000UL, + 0x3fe4e815UL, 0xf33e2a76UL, 0xbe51f184UL, 0xe0000000UL, 0x3fe4db87UL, + 0x839f3e3eUL, 0x3e57db01UL, 0xc0000000UL, 0x3fe4cefdUL, 0xa9eda7bbUL, + 0x3e535e0fUL, 0x00000000UL, 0x3fe4c277UL, 0x2a8f66a5UL, 0x3e5ce451UL, + 0xc0000000UL, 0x3fe4b5f3UL, 0x05192456UL, 0xbe4e8518UL, 0xc0000000UL, + 0x3fe4a973UL, 0x4aa7cd1dUL, 0x3e46784aUL, 0x40000000UL, 0x3fe49cf7UL, + 0x8e23025eUL, 0xbe5749f2UL, 0x00000000UL, 0x3fe4907eUL, 0x18d30215UL, + 0x3e360f39UL, 0x20000000UL, 0x3fe48408UL, 0x63dcf2f3UL, 0x3e5e00feUL, + 0xc0000000UL, 0x3fe47795UL, 0x46182d09UL, 0xbe5173d9UL, 0xa0000000UL, + 0x3fe46b26UL, 0x8f0e62aaUL, 0xbe48f281UL, 0xe0000000UL, 0x3fe45ebaUL, + 0x5775c40cUL, 0xbe56aad4UL, 0x60000000UL, 0x3fe45252UL, 0x0fe25f69UL, + 0x3e48bd71UL, 0x40000000UL, 0x3fe445edUL, 0xe9989ec5UL, 0x3e590d97UL, + 0x80000000UL, 0x3fe4398bUL, 0xb3d9ffe3UL, 0x3e479dbcUL, 0x20000000UL, + 0x3fe42d2dUL, 0x388e4d2eUL, 0xbe5eed80UL, 0xe0000000UL, 0x3fe420d1UL, + 0x6f797c18UL, 0x3e554b4cUL, 0x20000000UL, 0x3fe4147aUL, 0x31048bb4UL, + 0xbe5b1112UL, 0x80000000UL, 0x3fe40825UL, 0x2efba4f9UL, 0x3e48ebc7UL, + 0x40000000UL, 0x3fe3fbd4UL, 0x50201119UL, 0x3e40b701UL, 0x40000000UL, + 0x3fe3ef86UL, 0x0a4db32cUL, 0x3e551de8UL, 0xa0000000UL, 0x3fe3e33bUL, + 0x0c9c148bUL, 0xbe50c1f6UL, 0x20000000UL, 0x3fe3d6f4UL, 0xc9129447UL, + 0x3e533fa0UL, 0x00000000UL, 0x3fe3cab0UL, 0xaae5b5a0UL, 0xbe22b68eUL, + 0x20000000UL, 0x3fe3be6fUL, 0x02305e8aUL, 0xbe54fc08UL, 0x60000000UL, + 0x3fe3b231UL, 0x7f908258UL, 0x3e57dc05UL, 0x00000000UL, 0x3fe3a5f7UL, + 0x1a09af78UL, 0x3e08038bUL, 0xe0000000UL, 0x3fe399bfUL, 0x490643c1UL, + 0xbe5dbe42UL, 0xe0000000UL, 0x3fe38d8bUL, 0x5e8ad724UL, 0xbe3c2b72UL, + 0x20000000UL, 0x3fe3815bUL, 0xc67196b6UL, 0x3e1713cfUL, 0xa0000000UL, + 0x3fe3752dUL, 0x6182e429UL, 0xbe3ec14cUL, 0x40000000UL, 0x3fe36903UL, + 0xab6eb1aeUL, 0x3e5a2cc5UL, 0x40000000UL, 0x3fe35cdcUL, 0xfe5dc064UL, + 0xbe5c5878UL, 0x40000000UL, 0x3fe350b8UL, 0x0ba6b9e4UL, 0x3e51619bUL, + 0x80000000UL, 0x3fe34497UL, 0x857761aaUL, 0x3e5fff53UL, 0x00000000UL, + 0x3fe3387aUL, 0xf872d68cUL, 0x3e484f4dUL, 0xa0000000UL, 0x3fe32c5fUL, + 0x087e97c2UL, 0x3e52842eUL, 0x80000000UL, 0x3fe32048UL, 0x73d6d0c0UL, + 0xbe503edfUL, 0x80000000UL, 0x3fe31434UL, 0x0c1456a1UL, 0xbe5f72adUL, + 0xa0000000UL, 0x3fe30823UL, 0x83a1a4d5UL, 0xbe5e65ccUL, 0xe0000000UL, + 0x3fe2fc15UL, 0x855a7390UL, 0xbe506438UL, 0x40000000UL, 0x3fe2f00bUL, + 0xa2898287UL, 0x3e3d22a2UL, 0xe0000000UL, 0x3fe2e403UL, 0x8b56f66fUL, + 0xbe5aa5fdUL, 0x80000000UL, 0x3fe2d7ffUL, 0x52db119aUL, 0x3e3a2e3dUL, + 0x60000000UL, 0x3fe2cbfeUL, 0xe2ddd4c0UL, 0xbe586469UL, 0x40000000UL, + 0x3fe2c000UL, 0x6b01bf10UL, 0x3e352b9dUL, 0x40000000UL, 0x3fe2b405UL, + 0xb07a1cdfUL, 0x3e5c5cdaUL, 0x80000000UL, 0x3fe2a80dUL, 0xc7b5f868UL, + 0xbe5668b3UL, 0xc0000000UL, 0x3fe29c18UL, 0x185edf62UL, 0xbe563d66UL, + 0x00000000UL, 0x3fe29027UL, 0xf729e1ccUL, 0x3e59a9a0UL, 0x80000000UL, + 0x3fe28438UL, 0x6433c727UL, 0xbe43cc89UL, 0x00000000UL, 0x3fe2784dUL, + 0x41782631UL, 0xbe30750cUL, 0xa0000000UL, 0x3fe26c64UL, 0x914911b7UL, + 0xbe58290eUL, 0x40000000UL, 0x3fe2607fUL, 0x3dcc73e1UL, 0xbe4269cdUL, + 0x00000000UL, 0x3fe2549dUL, 0x2751bf70UL, 0xbe5a6998UL, 0xc0000000UL, + 0x3fe248bdUL, 0x4248b9fbUL, 0xbe4ddb00UL, 0x80000000UL, 0x3fe23ce1UL, + 0xf35cf82fUL, 0x3e561b71UL, 0x60000000UL, 0x3fe23108UL, 0x8e481a2dUL, + 0x3e518fb9UL, 0x60000000UL, 0x3fe22532UL, 0x5ab96edcUL, 0xbe5fafc5UL, + 0x40000000UL, 0x3fe2195fUL, 0x80943911UL, 0xbe07f819UL, 0x40000000UL, + 0x3fe20d8fUL, 0x386f2d6cUL, 0xbe54ba8bUL, 0x40000000UL, 0x3fe201c2UL, + 0xf29664acUL, 0xbe5eb815UL, 0x20000000UL, 0x3fe1f5f8UL, 0x64f03390UL, + 0x3e5e320cUL, 0x20000000UL, 0x3fe1ea31UL, 0x747ff696UL, 0x3e5ef0a5UL, + 0x40000000UL, 0x3fe1de6dUL, 0x3e9ceb51UL, 0xbe5f8d27UL, 0x20000000UL, + 0x3fe1d2acUL, 0x4ae0b55eUL, 0x3e5faa21UL, 0x20000000UL, 0x3fe1c6eeUL, + 0x28569a5eUL, 0x3e598a4fUL, 0x20000000UL, 0x3fe1bb33UL, 0x54b33e07UL, + 0x3e46130aUL, 0x20000000UL, 0x3fe1af7bUL, 0x024f1078UL, 0xbe4dbf93UL, + 0x00000000UL, 0x3fe1a3c6UL, 0xb0783bfaUL, 0x3e419248UL, 0xe0000000UL, + 0x3fe19813UL, 0x2f02b836UL, 0x3e4e02b7UL, 0xc0000000UL, 0x3fe18c64UL, + 0x28dec9d4UL, 0x3e09064fUL, 0x80000000UL, 0x3fe180b8UL, 0x45cbf406UL, + 0x3e5b1f46UL, 0x40000000UL, 0x3fe1750fUL, 0x03d9964cUL, 0x3e5b0a79UL, + 0x00000000UL, 0x3fe16969UL, 0x8b5b882bUL, 0xbe238086UL, 0xa0000000UL, + 0x3fe15dc5UL, 0x73bad6f8UL, 0xbdf1fca4UL, 0x20000000UL, 0x3fe15225UL, + 0x5385769cUL, 0x3e5e8d76UL, 0xa0000000UL, 0x3fe14687UL, 0x1676dc6bUL, + 0x3e571d08UL, 0x20000000UL, 0x3fe13aedUL, 0xa8c41c7fUL, 0xbe598a25UL, + 0x60000000UL, 0x3fe12f55UL, 0xc4e1aaf0UL, 0x3e435277UL, 0xa0000000UL, + 0x3fe123c0UL, 0x403638e1UL, 0xbe21aa7cUL, 0xc0000000UL, 0x3fe1182eUL, + 0x557a092bUL, 0xbdd0116bUL, 0xc0000000UL, 0x3fe10c9fUL, 0x7d779f66UL, + 0x3e4a61baUL, 0xc0000000UL, 0x3fe10113UL, 0x2b09c645UL, 0xbe5d586eUL, + 0x20000000UL, 0x3fe0ea04UL, 0xea2cad46UL, 0x3e5aa97cUL, 0x20000000UL, + 0x3fe0d300UL, 0x23190e54UL, 0x3e50f1a7UL, 0xa0000000UL, 0x3fe0bc07UL, + 0x1379a5a6UL, 0xbe51619dUL, 0x60000000UL, 0x3fe0a51aUL, 0x926a3d4aUL, + 0x3e5cf019UL, 0xa0000000UL, 0x3fe08e38UL, 0xa8c24358UL, 0x3e35241eUL, + 0x20000000UL, 0x3fe07762UL, 0x24317e7aUL, 0x3e512cfaUL, 0x00000000UL, + 0x3fe06097UL, 0xfd9cf274UL, 0xbe55bef3UL, 0x00000000UL, 0x3fe049d7UL, + 0x3689b49dUL, 0xbe36d26dUL, 0x40000000UL, 0x3fe03322UL, 0xf72ef6c4UL, + 0xbe54cd08UL, 0xa0000000UL, 0x3fe01c78UL, 0x23702d2dUL, 0xbe5900bfUL, + 0x00000000UL, 0x3fe005daUL, 0x3f59c14cUL, 0x3e57d80bUL, 0x40000000UL, + 0x3fdfde8dUL, 0xad67766dUL, 0xbe57fad4UL, 0x40000000UL, 0x3fdfb17cUL, + 0x644f4ae7UL, 0x3e1ee43bUL, 0x40000000UL, 0x3fdf8481UL, 0x903234d2UL, + 0x3e501a86UL, 0x40000000UL, 0x3fdf579cUL, 0xafe9e509UL, 0xbe267c3eUL, + 0x00000000UL, 0x3fdf2acdUL, 0xb7dfda0bUL, 0xbe48149bUL, 0x40000000UL, + 0x3fdefe13UL, 0x3b94305eUL, 0x3e5f4ea7UL, 0x80000000UL, 0x3fded16fUL, + 0x5d95da61UL, 0xbe55c198UL, 0x00000000UL, 0x3fdea4e1UL, 0x406960c9UL, + 0xbdd99a19UL, 0x00000000UL, 0x3fde7868UL, 0xd22f3539UL, 0x3e470c78UL, + 0x80000000UL, 0x3fde4c04UL, 0x83eec535UL, 0xbe3e1232UL, 0x40000000UL, + 0x3fde1fb6UL, 0x3dfbffcbUL, 0xbe4b7d71UL, 0x40000000UL, 0x3fddf37dUL, + 0x7e1be4e0UL, 0xbe5b8f8fUL, 0x40000000UL, 0x3fddc759UL, 0x46dae887UL, + 0xbe350458UL, 0x80000000UL, 0x3fdd9b4aUL, 0xed6ecc49UL, 0xbe5f0045UL, + 0x80000000UL, 0x3fdd6f50UL, 0x2e9e883cUL, 0x3e2915daUL, 0x80000000UL, + 0x3fdd436bUL, 0xf0bccb32UL, 0x3e4a68c9UL, 0x80000000UL, 0x3fdd179bUL, + 0x9bbfc779UL, 0xbe54a26aUL, 0x00000000UL, 0x3fdcebe0UL, 0x7cea33abUL, + 0x3e43c6b7UL, 0x40000000UL, 0x3fdcc039UL, 0xe740fd06UL, 0x3e5526c2UL, + 0x40000000UL, 0x3fdc94a7UL, 0x9eadeb1aUL, 0xbe396d8dUL, 0xc0000000UL, + 0x3fdc6929UL, 0xf0a8f95aUL, 0xbe5c0ab2UL, 0x80000000UL, 0x3fdc3dc0UL, + 0x6ee2693bUL, 0x3e0992e6UL, 0xc0000000UL, 0x3fdc126bUL, 0x5ac6b581UL, + 0xbe2834b6UL, 0x40000000UL, 0x3fdbe72bUL, 0x8cc226ffUL, 0x3e3596a6UL, + 0x00000000UL, 0x3fdbbbffUL, 0xf92a74bbUL, 0x3e3c5813UL, 0x00000000UL, + 0x3fdb90e7UL, 0x479664c0UL, 0xbe50d644UL, 0x00000000UL, 0x3fdb65e3UL, + 0x5004975bUL, 0xbe55258fUL, 0x00000000UL, 0x3fdb3af3UL, 0xe4b23194UL, + 0xbe588407UL, 0xc0000000UL, 0x3fdb1016UL, 0xe65d4d0aUL, 0x3e527c26UL, + 0x80000000UL, 0x3fdae54eUL, 0x814fddd6UL, 0x3e5962a2UL, 0x40000000UL, + 0x3fdaba9aUL, 0xe19d0913UL, 0xbe562f4eUL, 0x80000000UL, 0x3fda8ff9UL, + 0x43cfd006UL, 0xbe4cfdebUL, 0x40000000UL, 0x3fda656cUL, 0x686f0a4eUL, + 0x3e5e47a8UL, 0xc0000000UL, 0x3fda3af2UL, 0x7200d410UL, 0x3e5e1199UL, + 0xc0000000UL, 0x3fda108cUL, 0xabd2266eUL, 0x3e5ee4d1UL, 0x40000000UL, + 0x3fd9e63aUL, 0x396f8f2cUL, 0x3e4dbffbUL, 0x00000000UL, 0x3fd9bbfbUL, + 0xe32b25ddUL, 0x3e5c3a54UL, 0x40000000UL, 0x3fd991cfUL, 0x431e4035UL, + 0xbe457925UL, 0x80000000UL, 0x3fd967b6UL, 0x7bed3dd3UL, 0x3e40c61dUL, + 0x00000000UL, 0x3fd93db1UL, 0xd7449365UL, 0x3e306419UL, 0x80000000UL, + 0x3fd913beUL, 0x1746e791UL, 0x3e56fcfcUL, 0x40000000UL, 0x3fd8e9dfUL, + 0xf3a9028bUL, 0xbe5041b9UL, 0xc0000000UL, 0x3fd8c012UL, 0x56840c50UL, + 0xbe26e20aUL, 0x40000000UL, 0x3fd89659UL, 0x19763102UL, 0xbe51f466UL, + 0x80000000UL, 0x3fd86cb2UL, 0x7032de7cUL, 0xbe4d298aUL, 0x80000000UL, + 0x3fd8431eUL, 0xdeb39fabUL, 0xbe4361ebUL, 0x40000000UL, 0x3fd8199dUL, + 0x5d01cbe0UL, 0xbe5425b3UL, 0x80000000UL, 0x3fd7f02eUL, 0x3ce99aa9UL, + 0x3e146fa8UL, 0x80000000UL, 0x3fd7c6d2UL, 0xd1a262b9UL, 0xbe5a1a69UL, + 0xc0000000UL, 0x3fd79d88UL, 0x8606c236UL, 0x3e423a08UL, 0x80000000UL, + 0x3fd77451UL, 0x8fd1e1b7UL, 0x3e5a6a63UL, 0xc0000000UL, 0x3fd74b2cUL, + 0xe491456aUL, 0x3e42c1caUL, 0x40000000UL, 0x3fd7221aUL, 0x4499a6d7UL, + 0x3e36a69aUL, 0x00000000UL, 0x3fd6f91aUL, 0x5237df94UL, 0xbe0f8f02UL, + 0x00000000UL, 0x3fd6d02cUL, 0xb6482c6eUL, 0xbe5abcf7UL, 0x00000000UL, + 0x3fd6a750UL, 0x1919fd61UL, 0xbe57ade2UL, 0x00000000UL, 0x3fd67e86UL, + 0xaa7a994dUL, 0xbe3f3fbdUL, 0x00000000UL, 0x3fd655ceUL, 0x67db014cUL, + 0x3e33c550UL, 0x00000000UL, 0x3fd62d28UL, 0xa82856b7UL, 0xbe1409d1UL, + 0xc0000000UL, 0x3fd60493UL, 0x1e6a300dUL, 0x3e55d899UL, 0x80000000UL, + 0x3fd5dc11UL, 0x1222bd5cUL, 0xbe35bfc0UL, 0xc0000000UL, 0x3fd5b3a0UL, + 0x6e8dc2d3UL, 0x3e5d4d79UL, 0x00000000UL, 0x3fd58b42UL, 0xe0e4ace6UL, + 0xbe517303UL, 0x80000000UL, 0x3fd562f4UL, 0xb306e0a8UL, 0x3e5edf0fUL, + 0xc0000000UL, 0x3fd53ab8UL, 0x6574bc54UL, 0x3e5ee859UL, 0x80000000UL, + 0x3fd5128eUL, 0xea902207UL, 0x3e5f6188UL, 0xc0000000UL, 0x3fd4ea75UL, + 0x9f911d79UL, 0x3e511735UL, 0x80000000UL, 0x3fd4c26eUL, 0xf9c77397UL, + 0xbe5b1643UL, 0x40000000UL, 0x3fd49a78UL, 0x15fc9258UL, 0x3e479a37UL, + 0x80000000UL, 0x3fd47293UL, 0xd5a04dd9UL, 0xbe426e56UL, 0xc0000000UL, + 0x3fd44abfUL, 0xe04042f5UL, 0x3e56f7c6UL, 0x40000000UL, 0x3fd422fdUL, + 0x1d8bf2c8UL, 0x3e5d8810UL, 0x00000000UL, 0x3fd3fb4cUL, 0x88a8ddeeUL, + 0xbe311454UL, 0xc0000000UL, 0x3fd3d3abUL, 0x3e3b5e47UL, 0xbe5d1b72UL, + 0x40000000UL, 0x3fd3ac1cUL, 0xc2ab5d59UL, 0x3e31b02bUL, 0xc0000000UL, + 0x3fd3849dUL, 0xd4e34b9eUL, 0x3e51cb2fUL, 0x40000000UL, 0x3fd35d30UL, + 0x177204fbUL, 0xbe2b8cd7UL, 0x80000000UL, 0x3fd335d3UL, 0xfcd38c82UL, + 0xbe4356e1UL, 0x80000000UL, 0x3fd30e87UL, 0x64f54accUL, 0xbe4e6224UL, + 0x00000000UL, 0x3fd2e74cUL, 0xaa7975d9UL, 0x3e5dc0feUL, 0x80000000UL, + 0x3fd2c021UL, 0x516dab3fUL, 0xbe50ffa3UL, 0x40000000UL, 0x3fd29907UL, + 0x2bfb7313UL, 0x3e5674a2UL, 0xc0000000UL, 0x3fd271fdUL, 0x0549fc99UL, + 0x3e385d29UL, 0xc0000000UL, 0x3fd24b04UL, 0x55b63073UL, 0xbe500c6dUL, + 0x00000000UL, 0x3fd2241cUL, 0x3f91953aUL, 0x3e389977UL, 0xc0000000UL, + 0x3fd1fd43UL, 0xa1543f71UL, 0xbe3487abUL, 0xc0000000UL, 0x3fd1d67bUL, + 0x4ec8867cUL, 0x3df6a2dcUL, 0x00000000UL, 0x3fd1afc4UL, 0x4328e3bbUL, + 0x3e41d9c0UL, 0x80000000UL, 0x3fd1891cUL, 0x2e1cda84UL, 0x3e3bdd87UL, + 0x40000000UL, 0x3fd16285UL, 0x4b5331aeUL, 0xbe53128eUL, 0x00000000UL, + 0x3fd13bfeUL, 0xb9aec164UL, 0xbe52ac98UL, 0xc0000000UL, 0x3fd11586UL, + 0xd91e1316UL, 0xbe350630UL, 0x80000000UL, 0x3fd0ef1fUL, 0x7cacc12cUL, + 0x3e3f5219UL, 0x40000000UL, 0x3fd0c8c8UL, 0xbce277b7UL, 0x3e3d30c0UL, + 0x00000000UL, 0x3fd0a281UL, 0x2a63447dUL, 0xbe541377UL, 0x80000000UL, + 0x3fd07c49UL, 0xfac483b5UL, 0xbe5772ecUL, 0xc0000000UL, 0x3fd05621UL, + 0x36b8a570UL, 0xbe4fd4bdUL, 0xc0000000UL, 0x3fd03009UL, 0xbae505f7UL, + 0xbe450388UL, 0x80000000UL, 0x3fd00a01UL, 0x3e35aeadUL, 0xbe5430fcUL, + 0x80000000UL, 0x3fcfc811UL, 0x707475acUL, 0x3e38806eUL, 0x80000000UL, + 0x3fcf7c3fUL, 0xc91817fcUL, 0xbe40cceaUL, 0x80000000UL, 0x3fcf308cUL, + 0xae05d5e9UL, 0xbe4919b8UL, 0x80000000UL, 0x3fcee4f8UL, 0xae6cc9e6UL, + 0xbe530b94UL, 0x00000000UL, 0x3fce9983UL, 0x1efe3e8eUL, 0x3e57747eUL, + 0x00000000UL, 0x3fce4e2dUL, 0xda78d9bfUL, 0xbe59a608UL, 0x00000000UL, + 0x3fce02f5UL, 0x8abe2c2eUL, 0x3e4a35adUL, 0x00000000UL, 0x3fcdb7dcUL, + 0x1495450dUL, 0xbe0872ccUL, 0x80000000UL, 0x3fcd6ce1UL, 0x86ee0ba0UL, + 0xbe4f59a0UL, 0x00000000UL, 0x3fcd2205UL, 0xe81ca888UL, 0x3e5402c3UL, + 0x00000000UL, 0x3fccd747UL, 0x3b4424b9UL, 0x3e5dfdc3UL, 0x80000000UL, + 0x3fcc8ca7UL, 0xd305b56cUL, 0x3e202da6UL, 0x00000000UL, 0x3fcc4226UL, + 0x399a6910UL, 0xbe482a1cUL, 0x80000000UL, 0x3fcbf7c2UL, 0x747f7938UL, + 0xbe587372UL, 0x80000000UL, 0x3fcbad7cUL, 0x6fc246a0UL, 0x3e50d83dUL, + 0x00000000UL, 0x3fcb6355UL, 0xee9e9be5UL, 0xbe5c35bdUL, 0x80000000UL, + 0x3fcb194aUL, 0x8416c0bcUL, 0x3e546d4fUL, 0x00000000UL, 0x3fcacf5eUL, + 0x49f7f08fUL, 0x3e56da76UL, 0x00000000UL, 0x3fca858fUL, 0x5dc30de2UL, + 0x3e5f390cUL, 0x00000000UL, 0x3fca3bdeUL, 0x950583b6UL, 0xbe5e4169UL, + 0x80000000UL, 0x3fc9f249UL, 0x33631553UL, 0x3e52aeb1UL, 0x00000000UL, + 0x3fc9a8d3UL, 0xde8795a6UL, 0xbe59a504UL, 0x00000000UL, 0x3fc95f79UL, + 0x076bf41eUL, 0x3e5122feUL, 0x80000000UL, 0x3fc9163cUL, 0x2914c8e7UL, + 0x3e3dd064UL, 0x00000000UL, 0x3fc8cd1dUL, 0x3a30eca3UL, 0xbe21b4aaUL, + 0x80000000UL, 0x3fc8841aUL, 0xb2a96650UL, 0xbe575444UL, 0x80000000UL, + 0x3fc83b34UL, 0x2376c0cbUL, 0xbe2a74c7UL, 0x80000000UL, 0x3fc7f26bUL, + 0xd8a0b653UL, 0xbe5181b6UL, 0x00000000UL, 0x3fc7a9bfUL, 0x32257882UL, + 0xbe4a78b4UL, 0x00000000UL, 0x3fc7612fUL, 0x1eee8bd9UL, 0xbe1bfe9dUL, + 0x80000000UL, 0x3fc718bbUL, 0x0c603cc4UL, 0x3e36fdc9UL, 0x80000000UL, + 0x3fc6d064UL, 0x3728b8cfUL, 0xbe1e542eUL, 0x80000000UL, 0x3fc68829UL, + 0xc79a4067UL, 0x3e5c380fUL, 0x00000000UL, 0x3fc6400bUL, 0xf69eac69UL, + 0x3e550a84UL, 0x80000000UL, 0x3fc5f808UL, 0xb7a780a4UL, 0x3e5d9224UL, + 0x80000000UL, 0x3fc5b022UL, 0xad9dfb1eUL, 0xbe55242fUL, 0x00000000UL, + 0x3fc56858UL, 0x659b18beUL, 0xbe4bfda3UL, 0x80000000UL, 0x3fc520a9UL, + 0x66ee3631UL, 0xbe57d769UL, 0x80000000UL, 0x3fc4d916UL, 0x1ec62819UL, + 0x3e2427f7UL, 0x80000000UL, 0x3fc4919fUL, 0xdec25369UL, 0xbe435431UL, + 0x00000000UL, 0x3fc44a44UL, 0xa8acfc4bUL, 0xbe3c62e8UL, 0x00000000UL, + 0x3fc40304UL, 0xcf1d3eabUL, 0xbdfba29fUL, 0x80000000UL, 0x3fc3bbdfUL, + 0x79aba3eaUL, 0xbdf1b7c8UL, 0x80000000UL, 0x3fc374d6UL, 0xb8d186daUL, + 0xbe5130cfUL, 0x80000000UL, 0x3fc32de8UL, 0x9d74f152UL, 0x3e2285b6UL, + 0x00000000UL, 0x3fc2e716UL, 0x50ae7ca9UL, 0xbe503920UL, 0x80000000UL, + 0x3fc2a05eUL, 0x6caed92eUL, 0xbe533924UL, 0x00000000UL, 0x3fc259c2UL, + 0x9cb5034eUL, 0xbe510e31UL, 0x80000000UL, 0x3fc21340UL, 0x12c4d378UL, + 0xbe540b43UL, 0x80000000UL, 0x3fc1ccd9UL, 0xcc418706UL, 0x3e59887aUL, + 0x00000000UL, 0x3fc1868eUL, 0x921f4106UL, 0xbe528e67UL, 0x80000000UL, + 0x3fc1405cUL, 0x3969441eUL, 0x3e5d8051UL, 0x00000000UL, 0x3fc0fa46UL, + 0xd941ef5bUL, 0x3e5f9079UL, 0x80000000UL, 0x3fc0b44aUL, 0x5a3e81b2UL, + 0xbe567691UL, 0x00000000UL, 0x3fc06e69UL, 0x9d66afe7UL, 0xbe4d43fbUL, + 0x00000000UL, 0x3fc028a2UL, 0x0a92a162UL, 0xbe52f394UL, 0x00000000UL, + 0x3fbfc5eaUL, 0x209897e5UL, 0x3e529e37UL, 0x00000000UL, 0x3fbf3ac5UL, + 0x8458bd7bUL, 0x3e582831UL, 0x00000000UL, 0x3fbeafd5UL, 0xb8d8b4b8UL, + 0xbe486b4aUL, 0x00000000UL, 0x3fbe2518UL, 0xe0a3b7b6UL, 0x3e5bafd2UL, + 0x00000000UL, 0x3fbd9a90UL, 0x2bf2710eUL, 0x3e383b2bUL, 0x00000000UL, + 0x3fbd103cUL, 0x73eb6ab7UL, 0xbe56d78dUL, 0x00000000UL, 0x3fbc861bUL, + 0x32ceaff5UL, 0xbe32dc5aUL, 0x00000000UL, 0x3fbbfc2eUL, 0xbee04cb7UL, + 0xbe4a71a4UL, 0x00000000UL, 0x3fbb7274UL, 0x35ae9577UL, 0x3e38142fUL, + 0x00000000UL, 0x3fbae8eeUL, 0xcbaddab4UL, 0xbe5490f0UL, 0x00000000UL, + 0x3fba5f9aUL, 0x95ce1114UL, 0x3e597c71UL, 0x00000000UL, 0x3fb9d67aUL, + 0x6d7c0f78UL, 0x3e3abc2dUL, 0x00000000UL, 0x3fb94d8dUL, 0x2841a782UL, + 0xbe566cbcUL, 0x00000000UL, 0x3fb8c4d2UL, 0x6ed429c6UL, 0xbe3cfff9UL, + 0x00000000UL, 0x3fb83c4aUL, 0xe4a49fbbUL, 0xbe552964UL, 0x00000000UL, + 0x3fb7b3f4UL, 0x2193d81eUL, 0xbe42fa72UL, 0x00000000UL, 0x3fb72bd0UL, + 0xdd70c122UL, 0x3e527a8cUL, 0x00000000UL, 0x3fb6a3dfUL, 0x03108a54UL, + 0xbe450393UL, 0x00000000UL, 0x3fb61c1fUL, 0x30ff7954UL, 0x3e565840UL, + 0x00000000UL, 0x3fb59492UL, 0xdedd460cUL, 0xbe5422b5UL, 0x00000000UL, + 0x3fb50d36UL, 0x950f9f45UL, 0xbe5313f6UL, 0x00000000UL, 0x3fb4860bUL, + 0x582cdcb1UL, 0x3e506d39UL, 0x00000000UL, 0x3fb3ff12UL, 0x7216d3a6UL, + 0x3e4aa719UL, 0x00000000UL, 0x3fb3784aUL, 0x57a423fdUL, 0x3e5a9b9fUL, + 0x00000000UL, 0x3fb2f1b4UL, 0x7a138b41UL, 0xbe50b418UL, 0x00000000UL, + 0x3fb26b4eUL, 0x2fbfd7eaUL, 0x3e23a53eUL, 0x00000000UL, 0x3fb1e519UL, + 0x18913ccbUL, 0x3e465fc1UL, 0x00000000UL, 0x3fb15f15UL, 0x7ea24e21UL, + 0x3e042843UL, 0x00000000UL, 0x3fb0d941UL, 0x7c6d9c77UL, 0x3e59f61eUL, + 0x00000000UL, 0x3fb0539eUL, 0x114efd44UL, 0x3e4ccab7UL, 0x00000000UL, + 0x3faf9c56UL, 0x1777f657UL, 0x3e552f65UL, 0x00000000UL, 0x3fae91d2UL, + 0xc317b86aUL, 0xbe5a61e0UL, 0x00000000UL, 0x3fad87acUL, 0xb7664efbUL, + 0xbe41f64eUL, 0x00000000UL, 0x3fac7de6UL, 0x5d3d03a9UL, 0x3e0807a0UL, + 0x00000000UL, 0x3fab7480UL, 0x743c38ebUL, 0xbe3726e1UL, 0x00000000UL, + 0x3faa6b78UL, 0x06a253f1UL, 0x3e5ad636UL, 0x00000000UL, 0x3fa962d0UL, + 0xa35f541bUL, 0x3e5a187aUL, 0x00000000UL, 0x3fa85a88UL, 0x4b86e446UL, + 0xbe508150UL, 0x00000000UL, 0x3fa7529cUL, 0x2589cacfUL, 0x3e52938aUL, + 0x00000000UL, 0x3fa64b10UL, 0xaf6b11f2UL, 0xbe3454cdUL, 0x00000000UL, + 0x3fa543e2UL, 0x97506fefUL, 0xbe5fdec5UL, 0x00000000UL, 0x3fa43d10UL, + 0xe75f7dd9UL, 0xbe388dd3UL, 0x00000000UL, 0x3fa3369cUL, 0xa4139632UL, + 0xbdea5177UL, 0x00000000UL, 0x3fa23086UL, 0x352d6f1eUL, 0xbe565ad6UL, + 0x00000000UL, 0x3fa12accUL, 0x77449eb7UL, 0xbe50d5c7UL, 0x00000000UL, + 0x3fa0256eUL, 0x7478da78UL, 0x3e404724UL, 0x00000000UL, 0x3f9e40dcUL, + 0xf59cef7fUL, 0xbe539d0aUL, 0x00000000UL, 0x3f9c3790UL, 0x1511d43cUL, + 0x3e53c2c8UL, 0x00000000UL, 0x3f9a2f00UL, 0x9b8bff3cUL, 0xbe43b3e1UL, + 0x00000000UL, 0x3f982724UL, 0xad1e22a5UL, 0x3e46f0bdUL, 0x00000000UL, + 0x3f962000UL, 0x130d9356UL, 0x3e475ba0UL, 0x00000000UL, 0x3f941994UL, + 0x8f86f883UL, 0xbe513d0bUL, 0x00000000UL, 0x3f9213dcUL, 0x914d0dc8UL, + 0xbe534335UL, 0x00000000UL, 0x3f900ed8UL, 0x2d73e5e7UL, 0xbe22ba75UL, + 0x00000000UL, 0x3f8c1510UL, 0xc5b7d70eUL, 0x3e599c5dUL, 0x00000000UL, + 0x3f880de0UL, 0x8a27857eUL, 0xbe3d28c8UL, 0x00000000UL, 0x3f840810UL, + 0xda767328UL, 0x3e531b3dUL, 0x00000000UL, 0x3f8003b0UL, 0x77bacaf3UL, + 0xbe5f04e3UL, 0x00000000UL, 0x3f780150UL, 0xdf4b0720UL, 0x3e5a8bffUL, + 0x00000000UL, 0x3f6ffc40UL, 0x34c48e71UL, 0xbe3fcd99UL, 0x00000000UL, + 0x3f5ff6c0UL, 0x1ad218afUL, 0xbe4c78a7UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x80000000UL +}; + +ALIGNED_(8) juint _log2_pow[] = +{ + 0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL, 0xbfe62e42UL +}; + +//registers, +// input: xmm0, xmm1 +// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 +// rax, rdx, rcx, r8, r11 + +// Code generated by Intel C compiler for LIBM library + +void MacroAssembler::fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp1, Register tmp2, Register tmp3, Register tmp4) { + Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; + Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; + Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2; + Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, L_2TAG_PACKET_14_0_2, L_2TAG_PACKET_15_0_2; + Label L_2TAG_PACKET_16_0_2, L_2TAG_PACKET_17_0_2, L_2TAG_PACKET_18_0_2, L_2TAG_PACKET_19_0_2; + Label L_2TAG_PACKET_20_0_2, L_2TAG_PACKET_21_0_2, L_2TAG_PACKET_22_0_2, L_2TAG_PACKET_23_0_2; + Label L_2TAG_PACKET_24_0_2, L_2TAG_PACKET_25_0_2, L_2TAG_PACKET_26_0_2, L_2TAG_PACKET_27_0_2; + Label L_2TAG_PACKET_28_0_2, L_2TAG_PACKET_29_0_2, L_2TAG_PACKET_30_0_2, L_2TAG_PACKET_31_0_2; + Label L_2TAG_PACKET_32_0_2, L_2TAG_PACKET_33_0_2, L_2TAG_PACKET_34_0_2, L_2TAG_PACKET_35_0_2; + Label L_2TAG_PACKET_36_0_2, L_2TAG_PACKET_37_0_2, L_2TAG_PACKET_38_0_2, L_2TAG_PACKET_39_0_2; + Label L_2TAG_PACKET_40_0_2, L_2TAG_PACKET_41_0_2, L_2TAG_PACKET_42_0_2, L_2TAG_PACKET_43_0_2; + Label L_2TAG_PACKET_44_0_2, L_2TAG_PACKET_45_0_2, L_2TAG_PACKET_46_0_2, L_2TAG_PACKET_47_0_2; + Label L_2TAG_PACKET_48_0_2, L_2TAG_PACKET_49_0_2, L_2TAG_PACKET_50_0_2, L_2TAG_PACKET_51_0_2; + Label L_2TAG_PACKET_52_0_2, L_2TAG_PACKET_53_0_2, L_2TAG_PACKET_54_0_2, L_2TAG_PACKET_55_0_2; + Label L_2TAG_PACKET_56_0_2; + Label B1_2, B1_3, B1_5, start; + + assert_different_registers(tmp1, tmp2, eax, ecx, edx); + jmp(start); + address HIGHSIGMASK = (address)_HIGHSIGMASK; + address LOG2_E = (address)_LOG2_E; + address coeff = (address)_coeff_pow; + address L_tbl = (address)_L_tbl_pow; + address HIGHMASK_Y = (address)_HIGHMASK_Y; + address T_exp = (address)_T_exp; + address e_coeff = (address)_e_coeff; + address coeff_h = (address)_coeff_h; + address HIGHMASK_LOG_X = (address)_HIGHMASK_LOG_X; + address HALFMASK = (address)_HALFMASK; + address log2 = (address)_log2_pow; + + + bind(start); + subq(rsp, 40); + movsd(Address(rsp, 8), xmm0); + movsd(Address(rsp, 16), xmm1); + + bind(B1_2); + pextrw(eax, xmm0, 3); + xorpd(xmm2, xmm2); + mov64(tmp2, 0x3ff0000000000000); + movdq(xmm2, tmp2); + movl(tmp1, 1069088768); + movdq(xmm7, tmp1); + xorpd(xmm1, xmm1); + mov64(tmp3, 0x77f0000000000000); + movdq(xmm1, tmp3); + movdqu(xmm3, xmm0); + movl(edx, 32752); + andl(edx, eax); + subl(edx, 16368); + movl(ecx, edx); + sarl(edx, 31); + addl(ecx, edx); + xorl(ecx, edx); + por(xmm0, xmm2); + movdqu(xmm6, ExternalAddress(HIGHSIGMASK)); //0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL + psrlq(xmm0, 27); + movq(xmm2, ExternalAddress(LOG2_E)); //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL + psrld(xmm0, 2); + addl(ecx, 16); + bsrl(ecx, ecx); + rcpps(xmm0, xmm0); + psllq(xmm3, 12); + movl(tmp4, 8192); + movdq(xmm4, tmp4); + psrlq(xmm3, 12); + subl(eax, 16); + cmpl(eax, 32736); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); + movl(tmp1, 0); + + bind(L_2TAG_PACKET_1_0_2); + mulss(xmm0, xmm7); + movl(edx, -1); + subl(ecx, 4); + shll(edx); + shlq(edx, 32); + movdq(xmm5, edx); + por(xmm3, xmm1); + subl(eax, 16351); + cmpl(eax, 1); + jcc(Assembler::belowEqual, L_2TAG_PACKET_2_0_2); + paddd(xmm0, xmm4); + pand(xmm5, xmm3); + movdl(edx, xmm0); + psllq(xmm0, 29); + + bind(L_2TAG_PACKET_3_0_2); + subsd(xmm3, xmm5); + pand(xmm0, xmm6); + subl(eax, 1); + sarl(eax, 4); + cvtsi2sdl(xmm7, eax); + mulpd(xmm5, xmm0); + + bind(L_2TAG_PACKET_4_0_2); + mulsd(xmm3, xmm0); + movdqu(xmm1, ExternalAddress(coeff)); //0x6dc96112UL, 0xbf836578UL, 0xee241472UL, 0xbf9b0301UL + lea(tmp4, ExternalAddress(L_tbl)); + subsd(xmm5, xmm2); + movdqu(xmm4, ExternalAddress(16 + coeff)); //0x9f95985aUL, 0xbfb528dbUL, 0xb3841d2aUL, 0xbfd619b6UL + movl(ecx, eax); + sarl(eax, 31); + addl(ecx, eax); + xorl(eax, ecx); + addl(eax, 1); + bsrl(eax, eax); + unpcklpd(xmm5, xmm3); + movdqu(xmm6, ExternalAddress(32 + coeff)); //0x518775e3UL, 0x3f9004f2UL, 0xac8349bbUL, 0x3fa76c9bUL + addsd(xmm3, xmm5); + andl(edx, 16760832); + shrl(edx, 10); + addpd(xmm5, Address(tmp4, edx, Address::times_1, -3648)); + movdqu(xmm0, ExternalAddress(48 + coeff)); //0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, 0xbf5dabe1UL + pshufd(xmm2, xmm3, 68); + mulsd(xmm3, xmm3); + mulpd(xmm1, xmm2); + mulpd(xmm4, xmm2); + addsd(xmm5, xmm7); + mulsd(xmm2, xmm3); + addpd(xmm6, xmm1); + mulsd(xmm3, xmm3); + addpd(xmm0, xmm4); + movq(xmm1, Address(rsp, 16)); + movw(ecx, Address(rsp, 22)); + pshufd(xmm7, xmm5, 238); + movq(xmm4, ExternalAddress(HIGHMASK_Y)); //0x00000000UL, 0xfffffff8UL, 0x00000000UL, 0xffffffffUL + mulpd(xmm6, xmm2); + pshufd(xmm3, xmm3, 68); + mulpd(xmm0, xmm2); + shll(eax, 4); + subl(eax, 15872); + andl(ecx, 32752); + addl(eax, ecx); + mulpd(xmm3, xmm6); + cmpl(eax, 624); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2); + xorpd(xmm6, xmm6); + movl(edx, 17080); + pinsrw(xmm6, edx, 3); + movdqu(xmm2, xmm1); + pand(xmm4, xmm1); + subsd(xmm1, xmm4); + mulsd(xmm4, xmm5); + addsd(xmm0, xmm7); + mulsd(xmm1, xmm5); + movdqu(xmm7, xmm6); + addsd(xmm6, xmm4); + lea(tmp4, ExternalAddress(T_exp)); + addpd(xmm3, xmm0); + movdl(edx, xmm6); + subsd(xmm6, xmm7); + pshufd(xmm0, xmm3, 238); + subsd(xmm4, xmm6); + addsd(xmm0, xmm3); + movl(ecx, edx); + andl(edx, 255); + addl(edx, edx); + movdqu(xmm5, Address(tmp4, edx, Address::times_8, 0)); + addsd(xmm4, xmm1); + mulsd(xmm2, xmm0); + movdqu(xmm7, ExternalAddress(e_coeff)); //0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL + movdqu(xmm3, ExternalAddress(16 + e_coeff)); //0x6fba4e77UL, 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL + shll(ecx, 12); + xorl(ecx, tmp1); + andl(rcx, -1048576); + movdq(xmm6, rcx); + addsd(xmm2, xmm4); + mov64(tmp2, 0x3fe62e42fefa39ef); + movdq(xmm1, tmp2); + pshufd(xmm0, xmm2, 68); + pshufd(xmm4, xmm2, 68); + mulsd(xmm1, xmm2); + pshufd(xmm6, xmm6, 17); + mulpd(xmm0, xmm0); + mulpd(xmm7, xmm4); + paddd(xmm5, xmm6); + mulsd(xmm1, xmm5); + pshufd(xmm6, xmm5, 238); + mulsd(xmm0, xmm0); + addpd(xmm3, xmm7); + addsd(xmm1, xmm6); + mulpd(xmm0, xmm3); + pshufd(xmm3, xmm0, 238); + mulsd(xmm0, xmm5); + mulsd(xmm3, xmm5); + addsd(xmm0, xmm1); + addsd(xmm0, xmm3); + addsd(xmm0, xmm5); + jmp(B1_5); + + bind(L_2TAG_PACKET_0_0_2); + addl(eax, 16); + movl(edx, 32752); + andl(edx, eax); + cmpl(edx, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_6_0_2); + testl(eax, 32768); + jcc(Assembler::notEqual, L_2TAG_PACKET_7_0_2); + + bind(L_2TAG_PACKET_8_0_2); + movq(xmm0, Address(rsp, 8)); + movq(xmm3, Address(rsp, 8)); + movdl(edx, xmm3); + psrlq(xmm3, 32); + movdl(ecx, xmm3); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_9_0_2); + xorpd(xmm3, xmm3); + movl(eax, 18416); + pinsrw(xmm3, eax, 3); + mulsd(xmm0, xmm3); + xorpd(xmm2, xmm2); + movl(eax, 16368); + pinsrw(xmm2, eax, 3); + movdqu(xmm3, xmm0); + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + movl(ecx, 18416); + psrlq(xmm0, 27); + movq(xmm2, ExternalAddress(LOG2_E)); //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL + psrld(xmm0, 2); + rcpps(xmm0, xmm0); + psllq(xmm3, 12); + movdqu(xmm6, ExternalAddress(HIGHSIGMASK)); //0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL + psrlq(xmm3, 12); + mulss(xmm0, xmm7); + movl(edx, -1024); + movdl(xmm5, edx); + por(xmm3, xmm1); + paddd(xmm0, xmm4); + psllq(xmm5, 32); + movdl(edx, xmm0); + psllq(xmm0, 29); + pand(xmm5, xmm3); + movl(tmp1, 0); + pand(xmm0, xmm6); + subsd(xmm3, xmm5); + andl(eax, 32752); + subl(eax, 18416); + sarl(eax, 4); + cvtsi2sdl(xmm7, eax); + mulpd(xmm5, xmm0); + jmp(L_2TAG_PACKET_4_0_2); + + bind(L_2TAG_PACKET_10_0_2); + movq(xmm0, Address(rsp, 8)); + movq(xmm3, Address(rsp, 8)); + movdl(edx, xmm3); + psrlq(xmm3, 32); + movdl(ecx, xmm3); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_9_0_2); + xorpd(xmm3, xmm3); + movl(eax, 18416); + pinsrw(xmm3, eax, 3); + mulsd(xmm0, xmm3); + xorpd(xmm2, xmm2); + movl(eax, 16368); + pinsrw(xmm2, eax, 3); + movdqu(xmm3, xmm0); + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + movl(ecx, 18416); + psrlq(xmm0, 27); + movq(xmm2, ExternalAddress(LOG2_E)); //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL + psrld(xmm0, 2); + rcpps(xmm0, xmm0); + psllq(xmm3, 12); + movdqu(xmm6, ExternalAddress(HIGHSIGMASK)); //0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL + psrlq(xmm3, 12); + mulss(xmm0, xmm7); + movl(edx, -1024); + movdl(xmm5, edx); + por(xmm3, xmm1); + paddd(xmm0, xmm4); + psllq(xmm5, 32); + movdl(edx, xmm0); + psllq(xmm0, 29); + pand(xmm5, xmm3); + movl(tmp1, INT_MIN); + pand(xmm0, xmm6); + subsd(xmm3, xmm5); + andl(eax, 32752); + subl(eax, 18416); + sarl(eax, 4); + cvtsi2sdl(xmm7, eax); + mulpd(xmm5, xmm0); + jmp(L_2TAG_PACKET_4_0_2); + + bind(L_2TAG_PACKET_5_0_2); + cmpl(eax, 0); + jcc(Assembler::less, L_2TAG_PACKET_11_0_2); + cmpl(eax, 752); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_12_0_2); + addsd(xmm0, xmm7); + movq(xmm2, ExternalAddress(HALFMASK)); //0xf8000000UL, 0xffffffffUL, 0xf8000000UL, 0xffffffffUL + addpd(xmm3, xmm0); + xorpd(xmm6, xmm6); + movl(eax, 17080); + pinsrw(xmm6, eax, 3); + pshufd(xmm0, xmm3, 238); + addsd(xmm0, xmm3); + movdqu(xmm3, xmm5); + addsd(xmm5, xmm0); + movdqu(xmm4, xmm2); + subsd(xmm3, xmm5); + movdqu(xmm7, xmm5); + pand(xmm5, xmm2); + movdqu(xmm2, xmm1); + pand(xmm4, xmm1); + subsd(xmm7, xmm5); + addsd(xmm0, xmm3); + subsd(xmm1, xmm4); + mulsd(xmm4, xmm5); + addsd(xmm0, xmm7); + mulsd(xmm2, xmm0); + movdqu(xmm7, xmm6); + mulsd(xmm1, xmm5); + addsd(xmm6, xmm4); + movdl(eax, xmm6); + subsd(xmm6, xmm7); + lea(tmp4, ExternalAddress(T_exp)); + addsd(xmm2, xmm1); + movdqu(xmm7, ExternalAddress(e_coeff)); //0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL + movdqu(xmm3, ExternalAddress(16 + e_coeff)); //0x6fba4e77UL, 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL + subsd(xmm4, xmm6); + pextrw(edx, xmm6, 3); + movl(ecx, eax); + andl(eax, 255); + addl(eax, eax); + movdqu(xmm5, Address(tmp4, rax, Address::times_8, 0)); + addsd(xmm2, xmm4); + sarl(ecx, 8); + movl(eax, ecx); + sarl(ecx, 1); + subl(eax, ecx); + shll(ecx, 20); + xorl(ecx, tmp1); + movdl(xmm6, ecx); + movq(xmm1, ExternalAddress(32 + e_coeff)); //0xfefa39efUL, 0x3fe62e42UL, 0x00000000UL, 0x00000000UL + andl(edx, 32767); + cmpl(edx, 16529); + jcc(Assembler::above, L_2TAG_PACKET_12_0_2); + pshufd(xmm0, xmm2, 68); + pshufd(xmm4, xmm2, 68); + mulpd(xmm0, xmm0); + mulpd(xmm7, xmm4); + pshufd(xmm6, xmm6, 17); + mulsd(xmm1, xmm2); + mulsd(xmm0, xmm0); + paddd(xmm5, xmm6); + addpd(xmm3, xmm7); + mulsd(xmm1, xmm5); + pshufd(xmm6, xmm5, 238); + mulpd(xmm0, xmm3); + addsd(xmm1, xmm6); + pshufd(xmm3, xmm0, 238); + mulsd(xmm0, xmm5); + mulsd(xmm3, xmm5); + shll(eax, 4); + xorpd(xmm4, xmm4); + addl(eax, 16368); + pinsrw(xmm4, eax, 3); + addsd(xmm0, xmm1); + addsd(xmm0, xmm3); + movdqu(xmm1, xmm0); + addsd(xmm0, xmm5); + mulsd(xmm0, xmm4); + pextrw(eax, xmm0, 3); + andl(eax, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_13_0_2); + cmpl(eax, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_14_0_2); + jmp(B1_5); + + bind(L_2TAG_PACKET_6_0_2); + movq(xmm1, Address(rsp, 16)); + movq(xmm0, Address(rsp, 8)); + movdqu(xmm2, xmm0); + movdl(eax, xmm2); + psrlq(xmm2, 20); + movdl(edx, xmm2); + orl(eax, edx); + jcc(Assembler::equal, L_2TAG_PACKET_15_0_2); + movdl(eax, xmm1); + psrlq(xmm1, 32); + movdl(edx, xmm1); + movl(ecx, edx); + addl(edx, edx); + orl(eax, edx); + jcc(Assembler::equal, L_2TAG_PACKET_16_0_2); + addsd(xmm0, xmm0); + jmp(B1_5); + + bind(L_2TAG_PACKET_16_0_2); + xorpd(xmm0, xmm0); + movl(eax, 16368); + pinsrw(xmm0, eax, 3); + movl(Address(rsp, 0), 29); + jmp(L_2TAG_PACKET_17_0_2); + + bind(L_2TAG_PACKET_18_0_2); + movq(xmm0, Address(rsp, 16)); + addpd(xmm0, xmm0); + jmp(B1_5); + + bind(L_2TAG_PACKET_15_0_2); + movdl(eax, xmm1); + movdqu(xmm2, xmm1); + psrlq(xmm1, 32); + movdl(edx, xmm1); + movl(ecx, edx); + addl(edx, edx); + orl(eax, edx); + jcc(Assembler::equal, L_2TAG_PACKET_19_0_2); + pextrw(eax, xmm2, 3); + andl(eax, 32752); + cmpl(eax, 32752); + jcc(Assembler::notEqual, L_2TAG_PACKET_20_0_2); + movdl(eax, xmm2); + psrlq(xmm2, 20); + movdl(edx, xmm2); + orl(eax, edx); + jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_20_0_2); + pextrw(eax, xmm0, 3); + testl(eax, 32768); + jcc(Assembler::notEqual, L_2TAG_PACKET_21_0_2); + testl(ecx, INT_MIN); + jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2); + jmp(B1_5); + + bind(L_2TAG_PACKET_23_0_2); + movq(xmm1, Address(rsp, 16)); + movdl(eax, xmm1); + testl(eax, 1); + jcc(Assembler::notEqual, L_2TAG_PACKET_24_0_2); + testl(eax, 2); + jcc(Assembler::notEqual, L_2TAG_PACKET_25_0_2); + jmp(L_2TAG_PACKET_24_0_2); + + bind(L_2TAG_PACKET_21_0_2); + shrl(ecx, 20); + andl(ecx, 2047); + cmpl(ecx, 1075); + jcc(Assembler::above, L_2TAG_PACKET_24_0_2); + jcc(Assembler::equal, L_2TAG_PACKET_26_0_2); + cmpl(ecx, 1074); + jcc(Assembler::above, L_2TAG_PACKET_23_0_2); + cmpl(ecx, 1023); + jcc(Assembler::below, L_2TAG_PACKET_24_0_2); + movq(xmm1, Address(rsp, 16)); + movl(eax, 17208); + xorpd(xmm3, xmm3); + pinsrw(xmm3, eax, 3); + movdqu(xmm4, xmm3); + addsd(xmm3, xmm1); + subsd(xmm4, xmm3); + addsd(xmm1, xmm4); + pextrw(eax, xmm1, 3); + andl(eax, 32752); + jcc(Assembler::notEqual, L_2TAG_PACKET_24_0_2); + movdl(eax, xmm3); + andl(eax, 1); + jcc(Assembler::equal, L_2TAG_PACKET_24_0_2); + + bind(L_2TAG_PACKET_25_0_2); + movq(xmm1, Address(rsp, 16)); + pextrw(eax, xmm1, 3); + andl(eax, 32768); + jcc(Assembler::notEqual, L_2TAG_PACKET_27_0_2); + jmp(B1_5); + + bind(L_2TAG_PACKET_27_0_2); + xorpd(xmm0, xmm0); + movl(eax, 32768); + pinsrw(xmm0, eax, 3); + jmp(B1_5); + + bind(L_2TAG_PACKET_24_0_2); + movq(xmm1, Address(rsp, 16)); + pextrw(eax, xmm1, 3); + andl(eax, 32768); + jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2); + xorpd(xmm0, xmm0); + movl(eax, 32752); + pinsrw(xmm0, eax, 3); + jmp(B1_5); + + bind(L_2TAG_PACKET_26_0_2); + movq(xmm1, Address(rsp, 16)); + movdl(eax, xmm1); + andl(eax, 1); + jcc(Assembler::equal, L_2TAG_PACKET_24_0_2); + jmp(L_2TAG_PACKET_25_0_2); + + bind(L_2TAG_PACKET_28_0_2); + movdl(eax, xmm1); + psrlq(xmm1, 20); + movdl(edx, xmm1); + orl(eax, edx); + jcc(Assembler::equal, L_2TAG_PACKET_29_0_2); + movq(xmm0, Address(rsp, 16)); + addsd(xmm0, xmm0); + jmp(B1_5); + + bind(L_2TAG_PACKET_29_0_2); + movq(xmm0, Address(rsp, 8)); + pextrw(eax, xmm0, 3); + cmpl(eax, 49136); + jcc(Assembler::notEqual, L_2TAG_PACKET_30_0_2); + movdl(ecx, xmm0); + psrlq(xmm0, 20); + movdl(edx, xmm0); + orl(ecx, edx); + jcc(Assembler::notEqual, L_2TAG_PACKET_30_0_2); + xorpd(xmm0, xmm0); + movl(eax, 32760); + pinsrw(xmm0, eax, 3); + jmp(B1_5); + + bind(L_2TAG_PACKET_30_0_2); + movq(xmm1, Address(rsp, 16)); + andl(eax, 32752); + subl(eax, 16368); + pextrw(edx, xmm1, 3); + xorpd(xmm0, xmm0); + xorl(eax, edx); + andl(eax, 32768); + jcc(Assembler::equal, L_2TAG_PACKET_31_0_2); + jmp(B1_5); + + bind(L_2TAG_PACKET_31_0_2); + movl(ecx, 32752); + pinsrw(xmm0, ecx, 3); + jmp(B1_5); + + bind(L_2TAG_PACKET_32_0_2); + movdl(eax, xmm1); + cmpl(edx, 17184); + jcc(Assembler::above, L_2TAG_PACKET_33_0_2); + testl(eax, 1); + jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2); + testl(eax, 2); + jcc(Assembler::equal, L_2TAG_PACKET_35_0_2); + jmp(L_2TAG_PACKET_36_0_2); + + bind(L_2TAG_PACKET_33_0_2); + testl(eax, 1); + jcc(Assembler::equal, L_2TAG_PACKET_35_0_2); + jmp(L_2TAG_PACKET_36_0_2); + + bind(L_2TAG_PACKET_7_0_2); + movq(xmm2, Address(rsp, 8)); + movdl(eax, xmm2); + psrlq(xmm2, 31); + movdl(ecx, xmm2); + orl(eax, ecx); + jcc(Assembler::equal, L_2TAG_PACKET_9_0_2); + movq(xmm1, Address(rsp, 16)); + pextrw(edx, xmm1, 3); + movdl(eax, xmm1); + movdqu(xmm2, xmm1); + psrlq(xmm2, 32); + movdl(ecx, xmm2); + addl(ecx, ecx); + orl(ecx, eax); + jcc(Assembler::equal, L_2TAG_PACKET_37_0_2); + andl(edx, 32752); + cmpl(edx, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_28_0_2); + cmpl(edx, 17200); + jcc(Assembler::above, L_2TAG_PACKET_35_0_2); + cmpl(edx, 17184); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_32_0_2); + cmpl(edx, 16368); + jcc(Assembler::below, L_2TAG_PACKET_34_0_2); + movl(eax, 17208); + xorpd(xmm2, xmm2); + pinsrw(xmm2, eax, 3); + movdqu(xmm4, xmm2); + addsd(xmm2, xmm1); + subsd(xmm4, xmm2); + addsd(xmm1, xmm4); + pextrw(eax, xmm1, 3); + andl(eax, 32767); + jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2); + movdl(eax, xmm2); + andl(eax, 1); + jcc(Assembler::equal, L_2TAG_PACKET_35_0_2); + + bind(L_2TAG_PACKET_36_0_2); + xorpd(xmm1, xmm1); + movl(edx, 30704); + pinsrw(xmm1, edx, 3); + movq(xmm2, ExternalAddress(LOG2_E)); //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL + movq(xmm4, Address(rsp, 8)); + pextrw(eax, xmm4, 3); + movl(edx, 8192); + movdl(xmm4, edx); + andl(eax, 32767); + subl(eax, 16); + jcc(Assembler::less, L_2TAG_PACKET_10_0_2); + movl(edx, eax); + andl(edx, 32752); + subl(edx, 16368); + movl(ecx, edx); + sarl(edx, 31); + addl(ecx, edx); + xorl(ecx, edx); + addl(ecx, 16); + bsrl(ecx, ecx); + movl(tmp1, INT_MIN); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_34_0_2); + xorpd(xmm1, xmm1); + movl(eax, 32752); + pinsrw(xmm1, eax, 3); + xorpd(xmm0, xmm0); + mulsd(xmm0, xmm1); + movl(Address(rsp, 0), 28); + jmp(L_2TAG_PACKET_17_0_2); + + bind(L_2TAG_PACKET_35_0_2); + xorpd(xmm1, xmm1); + movl(edx, 30704); + pinsrw(xmm1, edx, 3); + movq(xmm2, ExternalAddress(LOG2_E)); //0x00000000UL, 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL + movq(xmm4, Address(rsp, 8)); + pextrw(eax, xmm4, 3); + movl(edx, 8192); + movdl(xmm4, edx); + andl(eax, 32767); + subl(eax, 16); + jcc(Assembler::less, L_2TAG_PACKET_8_0_2); + movl(edx, eax); + andl(edx, 32752); + subl(edx, 16368); + movl(ecx, edx); + sarl(edx, 31); + addl(ecx, edx); + xorl(ecx, edx); + addl(ecx, 16); + bsrl(ecx, ecx); + movl(tmp1, 0); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_19_0_2); + xorpd(xmm0, xmm0); + movl(eax, 16368); + pinsrw(xmm0, eax, 3); + jmp(B1_5); + + bind(L_2TAG_PACKET_22_0_2); + xorpd(xmm0, xmm0); + jmp(B1_5); + + bind(L_2TAG_PACKET_11_0_2); + addl(eax, 384); + cmpl(eax, 0); + jcc(Assembler::less, L_2TAG_PACKET_38_0_2); + mulsd(xmm5, xmm1); + addsd(xmm0, xmm7); + shrl(tmp1, 31); + addpd(xmm3, xmm0); + pshufd(xmm0, xmm3, 238); + addsd(xmm3, xmm0); + lea(tmp4, ExternalAddress(log2)); //0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL, 0xbfe62e42UL + movq(xmm4, Address(tmp4, tmp1, Address::times_8, 0)); + mulsd(xmm1, xmm3); + xorpd(xmm0, xmm0); + movl(eax, 16368); + shll(tmp1, 15); + orl(eax, tmp1); + pinsrw(xmm0, eax, 3); + addsd(xmm5, xmm1); + mulsd(xmm5, xmm4); + addsd(xmm0, xmm5); + jmp(B1_5); + + bind(L_2TAG_PACKET_38_0_2); + + bind(L_2TAG_PACKET_37_0_2); + xorpd(xmm0, xmm0); + movl(eax, 16368); + pinsrw(xmm0, eax, 3); + jmp(B1_5); + + bind(L_2TAG_PACKET_39_0_2); + xorpd(xmm0, xmm0); + movl(eax, 16368); + pinsrw(xmm0, eax, 3); + movl(Address(rsp, 0), 26); + jmp(L_2TAG_PACKET_17_0_2); + + bind(L_2TAG_PACKET_9_0_2); + movq(xmm1, Address(rsp, 16)); + movdqu(xmm2, xmm1); + pextrw(eax, xmm1, 3); + andl(eax, 32752); + cmpl(eax, 32752); + jcc(Assembler::notEqual, L_2TAG_PACKET_40_0_2); + movdl(eax, xmm2); + psrlq(xmm2, 20); + movdl(edx, xmm2); + orl(eax, edx); + jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_40_0_2); + movdl(eax, xmm1); + psrlq(xmm1, 32); + movdl(edx, xmm1); + movl(ecx, edx); + addl(edx, edx); + orl(eax, edx); + jcc(Assembler::equal, L_2TAG_PACKET_39_0_2); + shrl(edx, 21); + cmpl(edx, 1075); + jcc(Assembler::above, L_2TAG_PACKET_41_0_2); + jcc(Assembler::equal, L_2TAG_PACKET_42_0_2); + cmpl(edx, 1023); + jcc(Assembler::below, L_2TAG_PACKET_41_0_2); + movq(xmm1, Address(rsp, 16)); + movl(eax, 17208); + xorpd(xmm3, xmm3); + pinsrw(xmm3, eax, 3); + movdqu(xmm4, xmm3); + addsd(xmm3, xmm1); + subsd(xmm4, xmm3); + addsd(xmm1, xmm4); + pextrw(eax, xmm1, 3); + andl(eax, 32752); + jcc(Assembler::notEqual, L_2TAG_PACKET_41_0_2); + movdl(eax, xmm3); + andl(eax, 1); + jcc(Assembler::equal, L_2TAG_PACKET_41_0_2); + + bind(L_2TAG_PACKET_43_0_2); + movq(xmm0, Address(rsp, 8)); + testl(ecx, INT_MIN); + jcc(Assembler::notEqual, L_2TAG_PACKET_44_0_2); + jmp(B1_5); + + bind(L_2TAG_PACKET_42_0_2); + movq(xmm1, Address(rsp, 16)); + movdl(eax, xmm1); + testl(eax, 1); + jcc(Assembler::notEqual, L_2TAG_PACKET_43_0_2); + + bind(L_2TAG_PACKET_41_0_2); + testl(ecx, INT_MIN); + jcc(Assembler::equal, L_2TAG_PACKET_22_0_2); + xorpd(xmm0, xmm0); + + bind(L_2TAG_PACKET_44_0_2); + movl(eax, 16368); + xorpd(xmm1, xmm1); + pinsrw(xmm1, eax, 3); + divsd(xmm1, xmm0); + movdqu(xmm0, xmm1); + movl(Address(rsp, 0), 27); + jmp(L_2TAG_PACKET_17_0_2); + + bind(L_2TAG_PACKET_12_0_2); + movq(xmm2, Address(rsp, 8)); + movq(xmm6, Address(rsp, 16)); + pextrw(eax, xmm2, 3); + pextrw(edx, xmm6, 3); + movl(ecx, 32752); + andl(ecx, edx); + cmpl(ecx, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_45_0_2); + andl(eax, 32752); + subl(eax, 16368); + xorl(edx, eax); + testl(edx, 32768); + jcc(Assembler::notEqual, L_2TAG_PACKET_46_0_2); + + bind(L_2TAG_PACKET_47_0_2); + movl(eax, 32736); + pinsrw(xmm0, eax, 3); + shrl(tmp1, 16); + orl(eax, tmp1); + pinsrw(xmm1, eax, 3); + mulsd(xmm0, xmm1); + + bind(L_2TAG_PACKET_14_0_2); + movl(Address(rsp, 0), 24); + jmp(L_2TAG_PACKET_17_0_2); + + bind(L_2TAG_PACKET_46_0_2); + movl(eax, 16); + pinsrw(xmm0, eax, 3); + mulsd(xmm0, xmm0); + testl(tmp1, INT_MIN); + jcc(Assembler::equal, L_2TAG_PACKET_48_0_2); + mov64(tmp2, 0x8000000000000000); + movdq(xmm2, tmp2); + xorpd(xmm0, xmm2); + + bind(L_2TAG_PACKET_48_0_2); + movl(Address(rsp, 0), 25); + jmp(L_2TAG_PACKET_17_0_2); + + bind(L_2TAG_PACKET_13_0_2); + pextrw(ecx, xmm5, 3); + pextrw(edx, xmm4, 3); + movl(eax, -1); + andl(ecx, 32752); + subl(ecx, 16368); + andl(edx, 32752); + addl(edx, ecx); + movl(ecx, -31); + sarl(edx, 4); + subl(ecx, edx); + jcc(Assembler::lessEqual, L_2TAG_PACKET_49_0_2); + cmpl(ecx, 20); + jcc(Assembler::above, L_2TAG_PACKET_50_0_2); + shll(eax); + + bind(L_2TAG_PACKET_49_0_2); + movdl(xmm0, eax); + psllq(xmm0, 32); + pand(xmm0, xmm5); + subsd(xmm5, xmm0); + addsd(xmm5, xmm1); + mulsd(xmm0, xmm4); + mulsd(xmm5, xmm4); + addsd(xmm0, xmm5); + + bind(L_2TAG_PACKET_50_0_2); + jmp(L_2TAG_PACKET_48_0_2); + + bind(L_2TAG_PACKET_2_0_2); + movw(ecx, Address(rsp, 22)); + movl(edx, INT_MIN); + movdl(xmm1, rdx); + xorpd(xmm7, xmm7); + paddd(xmm0, xmm4); + movdl(edx, xmm0); + psllq(xmm0, 29); + paddq(xmm1, xmm3); + pand(xmm5, xmm1); + andl(ecx, 32752); + cmpl(ecx, 16560); + jcc(Assembler::less, L_2TAG_PACKET_3_0_2); + pand(xmm0, xmm6); + subsd(xmm3, xmm5); + addl(eax, 16351); + shrl(eax, 4); + subl(eax, 1022); + cvtsi2sdl(xmm7, eax); + mulpd(xmm5, xmm0); + lea(r11, ExternalAddress(L_tbl)); + movq(xmm4, ExternalAddress(coeff_h)); //0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL + mulsd(xmm3, xmm0); + movq(xmm6, ExternalAddress(coeff_h)); //0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL + subsd(xmm5, xmm2); + movq(xmm1, ExternalAddress(8 + coeff_h)); //0x00000000UL, 0xbf5dabe1UL + pshufd(xmm2, xmm3, 68); + unpcklpd(xmm5, xmm3); + addsd(xmm3, xmm5); + movq(xmm0, ExternalAddress(8 + coeff_h)); //0x00000000UL, 0xbf5dabe1UL + andl(edx, 16760832); + shrl(edx, 10); + addpd(xmm7, Address(tmp4, edx, Address::times_1, -3648)); + mulsd(xmm4, xmm5); + mulsd(xmm0, xmm5); + mulsd(xmm6, xmm2); + mulsd(xmm1, xmm2); + movdqu(xmm2, xmm5); + mulsd(xmm4, xmm5); + addsd(xmm5, xmm0); + movdqu(xmm0, xmm7); + addsd(xmm2, xmm3); + addsd(xmm7, xmm5); + mulsd(xmm6, xmm2); + subsd(xmm0, xmm7); + movdqu(xmm2, xmm7); + addsd(xmm7, xmm4); + addsd(xmm0, xmm5); + subsd(xmm2, xmm7); + addsd(xmm4, xmm2); + pshufd(xmm2, xmm5, 238); + movdqu(xmm5, xmm7); + addsd(xmm7, xmm2); + addsd(xmm4, xmm0); + movdqu(xmm0, ExternalAddress(coeff)); //0x6dc96112UL, 0xbf836578UL, 0xee241472UL, 0xbf9b0301UL + subsd(xmm5, xmm7); + addsd(xmm6, xmm4); + movdqu(xmm4, xmm7); + addsd(xmm5, xmm2); + addsd(xmm7, xmm1); + movdqu(xmm2, ExternalAddress(64 + coeff)); //0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, 0xbf5dabe1UL + subsd(xmm4, xmm7); + addsd(xmm6, xmm5); + addsd(xmm4, xmm1); + pshufd(xmm5, xmm7, 238); + movapd(xmm1, xmm7); + addsd(xmm7, xmm5); + subsd(xmm1, xmm7); + addsd(xmm1, xmm5); + movdqu(xmm5, ExternalAddress(80 + coeff)); //0x9f95985aUL, 0xbfb528dbUL, 0xf8b5787dUL, 0x3ef2531eUL + pshufd(xmm3, xmm3, 68); + addsd(xmm6, xmm4); + addsd(xmm6, xmm1); + movdqu(xmm1, ExternalAddress(32 + coeff)); //0x9f95985aUL, 0xbfb528dbUL, 0xb3841d2aUL, 0xbfd619b6UL + mulpd(xmm0, xmm3); + mulpd(xmm2, xmm3); + pshufd(xmm4, xmm3, 68); + mulpd(xmm3, xmm3); + addpd(xmm0, xmm1); + addpd(xmm5, xmm2); + mulsd(xmm4, xmm3); + movq(xmm2, ExternalAddress(HIGHMASK_LOG_X)); //0xf8000000UL, 0xffffffffUL, 0x00000000UL, 0xfffff800UL + mulpd(xmm3, xmm3); + movq(xmm1, Address(rsp, 16)); + movw(ecx, Address(rsp, 22)); + mulpd(xmm0, xmm4); + pextrw(eax, xmm7, 3); + mulpd(xmm5, xmm4); + mulpd(xmm0, xmm3); + movq(xmm4, ExternalAddress(8 + HIGHMASK_Y)); //0x00000000UL, 0xffffffffUL + pand(xmm2, xmm7); + addsd(xmm5, xmm6); + subsd(xmm7, xmm2); + addpd(xmm5, xmm0); + andl(eax, 32752); + subl(eax, 16368); + andl(ecx, 32752); + cmpl(ecx, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_45_0_2); + addl(ecx, eax); + cmpl(ecx, 16576); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_51_0_2); + pshufd(xmm0, xmm5, 238); + pand(xmm4, xmm1); + movdqu(xmm3, xmm1); + addsd(xmm5, xmm0); + subsd(xmm1, xmm4); + xorpd(xmm6, xmm6); + movl(edx, 17080); + pinsrw(xmm6, edx, 3); + addsd(xmm7, xmm5); + mulsd(xmm4, xmm2); + mulsd(xmm1, xmm2); + movdqu(xmm5, xmm6); + mulsd(xmm3, xmm7); + addsd(xmm6, xmm4); + addsd(xmm1, xmm3); + movdqu(xmm7, ExternalAddress(e_coeff)); //0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL + movdl(edx, xmm6); + subsd(xmm6, xmm5); + lea(tmp4, ExternalAddress(T_exp)); + movdqu(xmm3, ExternalAddress(16 + e_coeff)); //0x6fba4e77UL, 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL + movq(xmm2, ExternalAddress(32 + e_coeff)); //0xfefa39efUL, 0x3fe62e42UL, 0x00000000UL, 0x00000000UL + subsd(xmm4, xmm6); + movl(ecx, edx); + andl(edx, 255); + addl(edx, edx); + movdqu(xmm5, Address(tmp4, edx, Address::times_8, 0)); + addsd(xmm4, xmm1); + pextrw(edx, xmm6, 3); + shrl(ecx, 8); + movl(eax, ecx); + shrl(ecx, 1); + subl(eax, ecx); + shll(ecx, 20); + movdl(xmm6, ecx); + pshufd(xmm0, xmm4, 68); + pshufd(xmm1, xmm4, 68); + mulpd(xmm0, xmm0); + mulpd(xmm7, xmm1); + pshufd(xmm6, xmm6, 17); + mulsd(xmm2, xmm4); + andl(edx, 32767); + cmpl(edx, 16529); + jcc(Assembler::above, L_2TAG_PACKET_12_0_2); + mulsd(xmm0, xmm0); + paddd(xmm5, xmm6); + addpd(xmm3, xmm7); + mulsd(xmm2, xmm5); + pshufd(xmm6, xmm5, 238); + mulpd(xmm0, xmm3); + addsd(xmm2, xmm6); + pshufd(xmm3, xmm0, 238); + addl(eax, 1023); + shll(eax, 20); + orl(eax, tmp1); + movdl(xmm4, eax); + mulsd(xmm0, xmm5); + mulsd(xmm3, xmm5); + addsd(xmm0, xmm2); + psllq(xmm4, 32); + addsd(xmm0, xmm3); + movdqu(xmm1, xmm0); + addsd(xmm0, xmm5); + mulsd(xmm0, xmm4); + pextrw(eax, xmm0, 3); + andl(eax, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_13_0_2); + cmpl(eax, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_14_0_2); + + bind(L_2TAG_PACKET_52_0_2); + jmp(B1_5); + + bind(L_2TAG_PACKET_45_0_2); + movq(xmm0, Address(rsp, 8)); + xorpd(xmm2, xmm2); + movl(eax, 49136); + pinsrw(xmm2, eax, 3); + addsd(xmm2, xmm0); + pextrw(eax, xmm2, 3); + cmpl(eax, 0); + jcc(Assembler::notEqual, L_2TAG_PACKET_53_0_2); + xorpd(xmm0, xmm0); + movl(eax, 32760); + pinsrw(xmm0, eax, 3); + jmp(B1_5); + + bind(L_2TAG_PACKET_53_0_2); + movq(xmm1, Address(rsp, 16)); + movdl(edx, xmm1); + movdqu(xmm3, xmm1); + psrlq(xmm3, 20); + movdl(ecx, xmm3); + orl(ecx, edx); + jcc(Assembler::equal, L_2TAG_PACKET_54_0_2); + addsd(xmm1, xmm1); + movdqu(xmm0, xmm1); + jmp(B1_5); + + bind(L_2TAG_PACKET_51_0_2); + pextrw(eax, xmm1, 3); + pextrw(ecx, xmm2, 3); + xorl(eax, ecx); + testl(eax, 32768); + jcc(Assembler::equal, L_2TAG_PACKET_47_0_2); + jmp(L_2TAG_PACKET_46_0_2); + + bind(L_2TAG_PACKET_54_0_2); + pextrw(eax, xmm0, 3); + andl(eax, 32752); + pextrw(edx, xmm1, 3); + xorpd(xmm0, xmm0); + subl(eax, 16368); + xorl(eax, edx); + testl(eax, 32768); + jcc(Assembler::equal, L_2TAG_PACKET_55_0_2); + jmp(B1_5); + + bind(L_2TAG_PACKET_55_0_2); + movl(edx, 32752); + pinsrw(xmm0, edx, 3); + jmp(B1_5); + + bind(L_2TAG_PACKET_17_0_2); + movq(Address(rsp, 24), xmm0); + + bind(B1_3); + movq(xmm0, Address(rsp, 24)); + + bind(L_2TAG_PACKET_56_0_2); + + bind(B1_5); + addq(rsp, 40); +} +#else +// The 32 bit code is at most SSE2 compliant +ALIGNED_(16) juint _static_const_table_pow[] = +{ + 0x00000000UL, 0xbfd61a00UL, 0x00000000UL, 0xbf5dabe1UL, 0xf8000000UL, + 0xffffffffUL, 0x00000000UL, 0xfffff800UL, 0x00000000UL, 0x3ff00000UL, + 0x00000000UL, 0x00000000UL, 0x20000000UL, 0x3feff00aUL, 0x96621f95UL, + 0x3e5b1856UL, 0xe0000000UL, 0x3fefe019UL, 0xe5916f9eUL, 0xbe325278UL, + 0x00000000UL, 0x3fefd02fUL, 0x859a1062UL, 0x3e595fb7UL, 0xc0000000UL, + 0x3fefc049UL, 0xb245f18fUL, 0xbe529c38UL, 0xe0000000UL, 0x3fefb069UL, + 0xad2880a7UL, 0xbe501230UL, 0x60000000UL, 0x3fefa08fUL, 0xc8e72420UL, + 0x3e597bd1UL, 0x80000000UL, 0x3fef90baUL, 0xc30c4500UL, 0xbe5d6c75UL, + 0xe0000000UL, 0x3fef80eaUL, 0x02c63f43UL, 0x3e2e1318UL, 0xc0000000UL, + 0x3fef7120UL, 0xb3d4ccccUL, 0xbe44c52aUL, 0x00000000UL, 0x3fef615cUL, + 0xdbd91397UL, 0xbe4e7d6cUL, 0xa0000000UL, 0x3fef519cUL, 0x65c5cd68UL, + 0xbe522dc8UL, 0xa0000000UL, 0x3fef41e2UL, 0x46d1306cUL, 0xbe5a840eUL, + 0xe0000000UL, 0x3fef322dUL, 0xd2980e94UL, 0x3e5071afUL, 0xa0000000UL, + 0x3fef227eUL, 0x773abadeUL, 0xbe5891e5UL, 0xa0000000UL, 0x3fef12d4UL, + 0xdc6bf46bUL, 0xbe5cccbeUL, 0xe0000000UL, 0x3fef032fUL, 0xbc7247faUL, + 0xbe2bab83UL, 0x80000000UL, 0x3feef390UL, 0xbcaa1e46UL, 0xbe53bb3bUL, + 0x60000000UL, 0x3feee3f6UL, 0x5f6c682dUL, 0xbe54c619UL, 0x80000000UL, + 0x3feed461UL, 0x5141e368UL, 0xbe4b6d86UL, 0xe0000000UL, 0x3feec4d1UL, + 0xec678f76UL, 0xbe369af6UL, 0x80000000UL, 0x3feeb547UL, 0x41301f55UL, + 0xbe2d4312UL, 0x60000000UL, 0x3feea5c2UL, 0x676da6bdUL, 0xbe4d8dd0UL, + 0x60000000UL, 0x3fee9642UL, 0x57a891c4UL, 0x3e51f991UL, 0xa0000000UL, + 0x3fee86c7UL, 0xe4eb491eUL, 0x3e579bf9UL, 0x20000000UL, 0x3fee7752UL, + 0xfddc4a2cUL, 0xbe3356e6UL, 0xc0000000UL, 0x3fee67e1UL, 0xd75b5bf1UL, + 0xbe449531UL, 0x80000000UL, 0x3fee5876UL, 0xbd423b8eUL, 0x3df54fe4UL, + 0x60000000UL, 0x3fee4910UL, 0x330e51b9UL, 0x3e54289cUL, 0x80000000UL, + 0x3fee39afUL, 0x8651a95fUL, 0xbe55aad6UL, 0xa0000000UL, 0x3fee2a53UL, + 0x5e98c708UL, 0xbe2fc4a9UL, 0xe0000000UL, 0x3fee1afcUL, 0x0989328dUL, + 0x3e23958cUL, 0x40000000UL, 0x3fee0babUL, 0xee642abdUL, 0xbe425dd8UL, + 0xa0000000UL, 0x3fedfc5eUL, 0xc394d236UL, 0x3e526362UL, 0x20000000UL, + 0x3feded17UL, 0xe104aa8eUL, 0x3e4ce247UL, 0xc0000000UL, 0x3fedddd4UL, + 0x265a9be4UL, 0xbe5bb77aUL, 0x40000000UL, 0x3fedce97UL, 0x0ecac52fUL, + 0x3e4a7cb1UL, 0xe0000000UL, 0x3fedbf5eUL, 0x124cb3b8UL, 0x3e257024UL, + 0x80000000UL, 0x3fedb02bUL, 0xe6d4febeUL, 0xbe2033eeUL, 0x20000000UL, + 0x3feda0fdUL, 0x39cca00eUL, 0xbe3ddabcUL, 0xc0000000UL, 0x3fed91d3UL, + 0xef8a552aUL, 0xbe543390UL, 0x40000000UL, 0x3fed82afUL, 0xb8e85204UL, + 0x3e513850UL, 0xe0000000UL, 0x3fed738fUL, 0x3d59fe08UL, 0xbe5db728UL, + 0x40000000UL, 0x3fed6475UL, 0x3aa7ead1UL, 0x3e58804bUL, 0xc0000000UL, + 0x3fed555fUL, 0xf8a35ba9UL, 0xbe5298b0UL, 0x00000000UL, 0x3fed464fUL, + 0x9a88dd15UL, 0x3e5a8cdbUL, 0x40000000UL, 0x3fed3743UL, 0xb0b0a190UL, + 0x3e598635UL, 0x80000000UL, 0x3fed283cUL, 0xe2113295UL, 0xbe5c1119UL, + 0x80000000UL, 0x3fed193aUL, 0xafbf1728UL, 0xbe492e9cUL, 0x60000000UL, + 0x3fed0a3dUL, 0xe4a4ccf3UL, 0x3e19b90eUL, 0x20000000UL, 0x3fecfb45UL, + 0xba3cbeb8UL, 0x3e406b50UL, 0xc0000000UL, 0x3fecec51UL, 0x110f7dddUL, + 0x3e0d6806UL, 0x40000000UL, 0x3fecdd63UL, 0x7dd7d508UL, 0xbe5a8943UL, + 0x80000000UL, 0x3fecce79UL, 0x9b60f271UL, 0xbe50676aUL, 0x80000000UL, + 0x3fecbf94UL, 0x0b9ad660UL, 0x3e59174fUL, 0x60000000UL, 0x3fecb0b4UL, + 0x00823d9cUL, 0x3e5bbf72UL, 0x20000000UL, 0x3feca1d9UL, 0x38a6ec89UL, + 0xbe4d38f9UL, 0x80000000UL, 0x3fec9302UL, 0x3a0b7d8eUL, 0x3e53dbfdUL, + 0xc0000000UL, 0x3fec8430UL, 0xc6826b34UL, 0xbe27c5c9UL, 0xc0000000UL, + 0x3fec7563UL, 0x0c706381UL, 0xbe593653UL, 0x60000000UL, 0x3fec669bUL, + 0x7df34ec7UL, 0x3e461ab5UL, 0xe0000000UL, 0x3fec57d7UL, 0x40e5e7e8UL, + 0xbe5c3daeUL, 0x00000000UL, 0x3fec4919UL, 0x5602770fUL, 0xbe55219dUL, + 0xc0000000UL, 0x3fec3a5eUL, 0xec7911ebUL, 0x3e5a5d25UL, 0x60000000UL, + 0x3fec2ba9UL, 0xb39ea225UL, 0xbe53c00bUL, 0x80000000UL, 0x3fec1cf8UL, + 0x967a212eUL, 0x3e5a8ddfUL, 0x60000000UL, 0x3fec0e4cUL, 0x580798bdUL, + 0x3e5f53abUL, 0x00000000UL, 0x3febffa5UL, 0xb8282df6UL, 0xbe46b874UL, + 0x20000000UL, 0x3febf102UL, 0xe33a6729UL, 0x3e54963fUL, 0x00000000UL, + 0x3febe264UL, 0x3b53e88aUL, 0xbe3adce1UL, 0x60000000UL, 0x3febd3caUL, + 0xc2585084UL, 0x3e5cde9fUL, 0x80000000UL, 0x3febc535UL, 0xa335c5eeUL, + 0xbe39fd9cUL, 0x20000000UL, 0x3febb6a5UL, 0x7325b04dUL, 0x3e42ba15UL, + 0x60000000UL, 0x3feba819UL, 0x1564540fUL, 0x3e3a9f35UL, 0x40000000UL, + 0x3feb9992UL, 0x83fff592UL, 0xbe5465ceUL, 0xa0000000UL, 0x3feb8b0fUL, + 0xb9da63d3UL, 0xbe4b1a0aUL, 0x80000000UL, 0x3feb7c91UL, 0x6d6f1ea4UL, + 0x3e557657UL, 0x00000000UL, 0x3feb6e18UL, 0x5e80a1bfUL, 0x3e4ddbb6UL, + 0x00000000UL, 0x3feb5fa3UL, 0x1c9eacb5UL, 0x3e592877UL, 0xa0000000UL, + 0x3feb5132UL, 0x6d40beb3UL, 0xbe51858cUL, 0xa0000000UL, 0x3feb42c6UL, + 0xd740c67bUL, 0x3e427ad2UL, 0x40000000UL, 0x3feb345fUL, 0xa3e0cceeUL, + 0xbe5c2fc4UL, 0x40000000UL, 0x3feb25fcUL, 0x8e752b50UL, 0xbe3da3c2UL, + 0xc0000000UL, 0x3feb179dUL, 0xa892e7deUL, 0x3e1fb481UL, 0xc0000000UL, + 0x3feb0943UL, 0x21ed71e9UL, 0xbe365206UL, 0x20000000UL, 0x3feafaeeUL, + 0x0e1380a3UL, 0x3e5c5b7bUL, 0x20000000UL, 0x3feaec9dUL, 0x3c3d640eUL, + 0xbe5dbbd0UL, 0x60000000UL, 0x3feade50UL, 0x8f97a715UL, 0x3e3a8ec5UL, + 0x20000000UL, 0x3fead008UL, 0x23ab2839UL, 0x3e2fe98aUL, 0x40000000UL, + 0x3feac1c4UL, 0xf4bbd50fUL, 0x3e54d8f6UL, 0xe0000000UL, 0x3feab384UL, + 0x14757c4dUL, 0xbe48774cUL, 0xc0000000UL, 0x3feaa549UL, 0x7c7b0eeaUL, + 0x3e5b51bbUL, 0x20000000UL, 0x3fea9713UL, 0xf56f7013UL, 0x3e386200UL, + 0xe0000000UL, 0x3fea88e0UL, 0xbe428ebeUL, 0xbe514af5UL, 0xe0000000UL, + 0x3fea7ab2UL, 0x8d0e4496UL, 0x3e4f9165UL, 0x60000000UL, 0x3fea6c89UL, + 0xdbacc5d5UL, 0xbe5c063bUL, 0x20000000UL, 0x3fea5e64UL, 0x3f19d970UL, + 0xbe5a0c8cUL, 0x20000000UL, 0x3fea5043UL, 0x09ea3e6bUL, 0x3e5065dcUL, + 0x80000000UL, 0x3fea4226UL, 0x78df246cUL, 0x3e5e05f6UL, 0x40000000UL, + 0x3fea340eUL, 0x4057d4a0UL, 0x3e431b2bUL, 0x40000000UL, 0x3fea25faUL, + 0x82867bb5UL, 0x3e4b76beUL, 0xa0000000UL, 0x3fea17eaUL, 0x9436f40aUL, + 0xbe5aad39UL, 0x20000000UL, 0x3fea09dfUL, 0x4b5253b3UL, 0x3e46380bUL, + 0x00000000UL, 0x3fe9fbd8UL, 0x8fc52466UL, 0xbe386f9bUL, 0x20000000UL, + 0x3fe9edd5UL, 0x22d3f344UL, 0xbe538347UL, 0x60000000UL, 0x3fe9dfd6UL, + 0x1ac33522UL, 0x3e5dbc53UL, 0x00000000UL, 0x3fe9d1dcUL, 0xeabdff1dUL, + 0x3e40fc0cUL, 0xe0000000UL, 0x3fe9c3e5UL, 0xafd30e73UL, 0xbe585e63UL, + 0xe0000000UL, 0x3fe9b5f3UL, 0xa52f226aUL, 0xbe43e8f9UL, 0x20000000UL, + 0x3fe9a806UL, 0xecb8698dUL, 0xbe515b36UL, 0x80000000UL, 0x3fe99a1cUL, + 0xf2b4e89dUL, 0x3e48b62bUL, 0x20000000UL, 0x3fe98c37UL, 0x7c9a88fbUL, + 0x3e44414cUL, 0x00000000UL, 0x3fe97e56UL, 0xda015741UL, 0xbe5d13baUL, + 0xe0000000UL, 0x3fe97078UL, 0x5fdace06UL, 0x3e51b947UL, 0x00000000UL, + 0x3fe962a0UL, 0x956ca094UL, 0x3e518785UL, 0x40000000UL, 0x3fe954cbUL, + 0x01164c1dUL, 0x3e5d5b57UL, 0xc0000000UL, 0x3fe946faUL, 0xe63b3767UL, + 0xbe4f84e7UL, 0x40000000UL, 0x3fe9392eUL, 0xe57cc2a9UL, 0x3e34eda3UL, + 0xe0000000UL, 0x3fe92b65UL, 0x8c75b544UL, 0x3e5766a0UL, 0xc0000000UL, + 0x3fe91da1UL, 0x37d1d087UL, 0xbe5e2ab1UL, 0x80000000UL, 0x3fe90fe1UL, + 0xa953dc20UL, 0x3e5fa1f3UL, 0x80000000UL, 0x3fe90225UL, 0xdbd3f369UL, + 0x3e47d6dbUL, 0xa0000000UL, 0x3fe8f46dUL, 0x1c9be989UL, 0xbe5e2b0aUL, + 0xa0000000UL, 0x3fe8e6b9UL, 0x3c93d76aUL, 0x3e5c8618UL, 0xe0000000UL, + 0x3fe8d909UL, 0x2182fc9aUL, 0xbe41aa9eUL, 0x20000000UL, 0x3fe8cb5eUL, + 0xe6b3539dUL, 0xbe530d19UL, 0x60000000UL, 0x3fe8bdb6UL, 0x49e58cc3UL, + 0xbe3bb374UL, 0xa0000000UL, 0x3fe8b012UL, 0xa7cfeb8fUL, 0x3e56c412UL, + 0x00000000UL, 0x3fe8a273UL, 0x8d52bc19UL, 0x3e1429b8UL, 0x60000000UL, + 0x3fe894d7UL, 0x4dc32c6cUL, 0xbe48604cUL, 0xc0000000UL, 0x3fe8873fUL, + 0x0c868e56UL, 0xbe564ee5UL, 0x00000000UL, 0x3fe879acUL, 0x56aee828UL, + 0x3e5e2fd8UL, 0x60000000UL, 0x3fe86c1cUL, 0x7ceab8ecUL, 0x3e493365UL, + 0xc0000000UL, 0x3fe85e90UL, 0x78d4dadcUL, 0xbe4f7f25UL, 0x00000000UL, + 0x3fe85109UL, 0x0ccd8280UL, 0x3e31e7a2UL, 0x40000000UL, 0x3fe84385UL, + 0x34ba4e15UL, 0x3e328077UL, 0x80000000UL, 0x3fe83605UL, 0xa670975aUL, + 0xbe53eee5UL, 0xa0000000UL, 0x3fe82889UL, 0xf61b77b2UL, 0xbe43a20aUL, + 0xa0000000UL, 0x3fe81b11UL, 0x13e6643bUL, 0x3e5e5fe5UL, 0xc0000000UL, + 0x3fe80d9dUL, 0x82cc94e8UL, 0xbe5ff1f9UL, 0xa0000000UL, 0x3fe8002dUL, + 0x8a0c9c5dUL, 0xbe42b0e7UL, 0x60000000UL, 0x3fe7f2c1UL, 0x22a16f01UL, + 0x3e5d9ea0UL, 0x20000000UL, 0x3fe7e559UL, 0xc38cd451UL, 0x3e506963UL, + 0xc0000000UL, 0x3fe7d7f4UL, 0x9902bc71UL, 0x3e4503d7UL, 0x40000000UL, + 0x3fe7ca94UL, 0xdef2a3c0UL, 0x3e3d98edUL, 0xa0000000UL, 0x3fe7bd37UL, + 0xed49abb0UL, 0x3e24c1ffUL, 0xe0000000UL, 0x3fe7afdeUL, 0xe3b0be70UL, + 0xbe40c467UL, 0x00000000UL, 0x3fe7a28aUL, 0xaf9f193cUL, 0xbe5dff6cUL, + 0xe0000000UL, 0x3fe79538UL, 0xb74cf6b6UL, 0xbe258ed0UL, 0xa0000000UL, + 0x3fe787ebUL, 0x1d9127c7UL, 0x3e345fb0UL, 0x40000000UL, 0x3fe77aa2UL, + 0x1028c21dUL, 0xbe4619bdUL, 0xa0000000UL, 0x3fe76d5cUL, 0x7cb0b5e4UL, + 0x3e40f1a2UL, 0xe0000000UL, 0x3fe7601aUL, 0x2b1bc4adUL, 0xbe32e8bbUL, + 0xe0000000UL, 0x3fe752dcUL, 0x6839f64eUL, 0x3e41f57bUL, 0xc0000000UL, + 0x3fe745a2UL, 0xc4121f7eUL, 0xbe52c40aUL, 0x60000000UL, 0x3fe7386cUL, + 0xd6852d72UL, 0xbe5c4e6bUL, 0xc0000000UL, 0x3fe72b39UL, 0x91d690f7UL, + 0xbe57f88fUL, 0xe0000000UL, 0x3fe71e0aUL, 0x627a2159UL, 0xbe4425d5UL, + 0xc0000000UL, 0x3fe710dfUL, 0x50a54033UL, 0x3e422b7eUL, 0x60000000UL, + 0x3fe703b8UL, 0x3b0b5f91UL, 0x3e5d3857UL, 0xe0000000UL, 0x3fe6f694UL, + 0x84d628a2UL, 0xbe51f090UL, 0x00000000UL, 0x3fe6e975UL, 0x306d8894UL, + 0xbe414d83UL, 0xe0000000UL, 0x3fe6dc58UL, 0x30bf24aaUL, 0xbe4650caUL, + 0x80000000UL, 0x3fe6cf40UL, 0xd4628d69UL, 0xbe5db007UL, 0xc0000000UL, + 0x3fe6c22bUL, 0xa2aae57bUL, 0xbe31d279UL, 0xc0000000UL, 0x3fe6b51aUL, + 0x860edf7eUL, 0xbe2d4c4aUL, 0x80000000UL, 0x3fe6a80dUL, 0xf3559341UL, + 0xbe5f7e98UL, 0xe0000000UL, 0x3fe69b03UL, 0xa885899eUL, 0xbe5c2011UL, + 0xe0000000UL, 0x3fe68dfdUL, 0x2bdc6d37UL, 0x3e224a82UL, 0xa0000000UL, + 0x3fe680fbUL, 0xc12ad1b9UL, 0xbe40cf56UL, 0x00000000UL, 0x3fe673fdUL, + 0x1bcdf659UL, 0xbdf52f2dUL, 0x00000000UL, 0x3fe66702UL, 0x5df10408UL, + 0x3e5663e0UL, 0xc0000000UL, 0x3fe65a0aUL, 0xa4070568UL, 0xbe40b12fUL, + 0x00000000UL, 0x3fe64d17UL, 0x71c54c47UL, 0x3e5f5e8bUL, 0x00000000UL, + 0x3fe64027UL, 0xbd4b7e83UL, 0x3e42ead6UL, 0xa0000000UL, 0x3fe6333aUL, + 0x61598bd2UL, 0xbe4c48d4UL, 0xc0000000UL, 0x3fe62651UL, 0x6f538d61UL, + 0x3e548401UL, 0xa0000000UL, 0x3fe6196cUL, 0x14344120UL, 0xbe529af6UL, + 0x00000000UL, 0x3fe60c8bUL, 0x5982c587UL, 0xbe3e1e4fUL, 0x00000000UL, + 0x3fe5ffadUL, 0xfe51d4eaUL, 0xbe4c897aUL, 0x80000000UL, 0x3fe5f2d2UL, + 0xfd46ebe1UL, 0x3e552e00UL, 0xa0000000UL, 0x3fe5e5fbUL, 0xa4695699UL, + 0x3e5ed471UL, 0x60000000UL, 0x3fe5d928UL, 0x80d118aeUL, 0x3e456b61UL, + 0xa0000000UL, 0x3fe5cc58UL, 0x304c330bUL, 0x3e54dc29UL, 0x80000000UL, + 0x3fe5bf8cUL, 0x0af2dedfUL, 0xbe3aa9bdUL, 0xe0000000UL, 0x3fe5b2c3UL, + 0x15fc9258UL, 0xbe479a37UL, 0xc0000000UL, 0x3fe5a5feUL, 0x9292c7eaUL, + 0x3e188650UL, 0x20000000UL, 0x3fe5993dUL, 0x33b4d380UL, 0x3e5d6d93UL, + 0x20000000UL, 0x3fe58c7fUL, 0x02fd16c7UL, 0x3e2fe961UL, 0xa0000000UL, + 0x3fe57fc4UL, 0x4a05edb6UL, 0xbe4d55b4UL, 0xa0000000UL, 0x3fe5730dUL, + 0x3d443abbUL, 0xbe5e6954UL, 0x00000000UL, 0x3fe5665aUL, 0x024acfeaUL, + 0x3e50e61bUL, 0x00000000UL, 0x3fe559aaUL, 0xcc9edd09UL, 0xbe325403UL, + 0x60000000UL, 0x3fe54cfdUL, 0x1fe26950UL, 0x3e5d500eUL, 0x60000000UL, + 0x3fe54054UL, 0x6c5ae164UL, 0xbe4a79b4UL, 0xc0000000UL, 0x3fe533aeUL, + 0x154b0287UL, 0xbe401571UL, 0xa0000000UL, 0x3fe5270cUL, 0x0673f401UL, + 0xbe56e56bUL, 0xe0000000UL, 0x3fe51a6dUL, 0x751b639cUL, 0x3e235269UL, + 0xa0000000UL, 0x3fe50dd2UL, 0x7c7b2bedUL, 0x3ddec887UL, 0xc0000000UL, + 0x3fe5013aUL, 0xafab4e17UL, 0x3e5e7575UL, 0x60000000UL, 0x3fe4f4a6UL, + 0x2e308668UL, 0x3e59aed6UL, 0x80000000UL, 0x3fe4e815UL, 0xf33e2a76UL, + 0xbe51f184UL, 0xe0000000UL, 0x3fe4db87UL, 0x839f3e3eUL, 0x3e57db01UL, + 0xc0000000UL, 0x3fe4cefdUL, 0xa9eda7bbUL, 0x3e535e0fUL, 0x00000000UL, + 0x3fe4c277UL, 0x2a8f66a5UL, 0x3e5ce451UL, 0xc0000000UL, 0x3fe4b5f3UL, + 0x05192456UL, 0xbe4e8518UL, 0xc0000000UL, 0x3fe4a973UL, 0x4aa7cd1dUL, + 0x3e46784aUL, 0x40000000UL, 0x3fe49cf7UL, 0x8e23025eUL, 0xbe5749f2UL, + 0x00000000UL, 0x3fe4907eUL, 0x18d30215UL, 0x3e360f39UL, 0x20000000UL, + 0x3fe48408UL, 0x63dcf2f3UL, 0x3e5e00feUL, 0xc0000000UL, 0x3fe47795UL, + 0x46182d09UL, 0xbe5173d9UL, 0xa0000000UL, 0x3fe46b26UL, 0x8f0e62aaUL, + 0xbe48f281UL, 0xe0000000UL, 0x3fe45ebaUL, 0x5775c40cUL, 0xbe56aad4UL, + 0x60000000UL, 0x3fe45252UL, 0x0fe25f69UL, 0x3e48bd71UL, 0x40000000UL, + 0x3fe445edUL, 0xe9989ec5UL, 0x3e590d97UL, 0x80000000UL, 0x3fe4398bUL, + 0xb3d9ffe3UL, 0x3e479dbcUL, 0x20000000UL, 0x3fe42d2dUL, 0x388e4d2eUL, + 0xbe5eed80UL, 0xe0000000UL, 0x3fe420d1UL, 0x6f797c18UL, 0x3e554b4cUL, + 0x20000000UL, 0x3fe4147aUL, 0x31048bb4UL, 0xbe5b1112UL, 0x80000000UL, + 0x3fe40825UL, 0x2efba4f9UL, 0x3e48ebc7UL, 0x40000000UL, 0x3fe3fbd4UL, + 0x50201119UL, 0x3e40b701UL, 0x40000000UL, 0x3fe3ef86UL, 0x0a4db32cUL, + 0x3e551de8UL, 0xa0000000UL, 0x3fe3e33bUL, 0x0c9c148bUL, 0xbe50c1f6UL, + 0x20000000UL, 0x3fe3d6f4UL, 0xc9129447UL, 0x3e533fa0UL, 0x00000000UL, + 0x3fe3cab0UL, 0xaae5b5a0UL, 0xbe22b68eUL, 0x20000000UL, 0x3fe3be6fUL, + 0x02305e8aUL, 0xbe54fc08UL, 0x60000000UL, 0x3fe3b231UL, 0x7f908258UL, + 0x3e57dc05UL, 0x00000000UL, 0x3fe3a5f7UL, 0x1a09af78UL, 0x3e08038bUL, + 0xe0000000UL, 0x3fe399bfUL, 0x490643c1UL, 0xbe5dbe42UL, 0xe0000000UL, + 0x3fe38d8bUL, 0x5e8ad724UL, 0xbe3c2b72UL, 0x20000000UL, 0x3fe3815bUL, + 0xc67196b6UL, 0x3e1713cfUL, 0xa0000000UL, 0x3fe3752dUL, 0x6182e429UL, + 0xbe3ec14cUL, 0x40000000UL, 0x3fe36903UL, 0xab6eb1aeUL, 0x3e5a2cc5UL, + 0x40000000UL, 0x3fe35cdcUL, 0xfe5dc064UL, 0xbe5c5878UL, 0x40000000UL, + 0x3fe350b8UL, 0x0ba6b9e4UL, 0x3e51619bUL, 0x80000000UL, 0x3fe34497UL, + 0x857761aaUL, 0x3e5fff53UL, 0x00000000UL, 0x3fe3387aUL, 0xf872d68cUL, + 0x3e484f4dUL, 0xa0000000UL, 0x3fe32c5fUL, 0x087e97c2UL, 0x3e52842eUL, + 0x80000000UL, 0x3fe32048UL, 0x73d6d0c0UL, 0xbe503edfUL, 0x80000000UL, + 0x3fe31434UL, 0x0c1456a1UL, 0xbe5f72adUL, 0xa0000000UL, 0x3fe30823UL, + 0x83a1a4d5UL, 0xbe5e65ccUL, 0xe0000000UL, 0x3fe2fc15UL, 0x855a7390UL, + 0xbe506438UL, 0x40000000UL, 0x3fe2f00bUL, 0xa2898287UL, 0x3e3d22a2UL, + 0xe0000000UL, 0x3fe2e403UL, 0x8b56f66fUL, 0xbe5aa5fdUL, 0x80000000UL, + 0x3fe2d7ffUL, 0x52db119aUL, 0x3e3a2e3dUL, 0x60000000UL, 0x3fe2cbfeUL, + 0xe2ddd4c0UL, 0xbe586469UL, 0x40000000UL, 0x3fe2c000UL, 0x6b01bf10UL, + 0x3e352b9dUL, 0x40000000UL, 0x3fe2b405UL, 0xb07a1cdfUL, 0x3e5c5cdaUL, + 0x80000000UL, 0x3fe2a80dUL, 0xc7b5f868UL, 0xbe5668b3UL, 0xc0000000UL, + 0x3fe29c18UL, 0x185edf62UL, 0xbe563d66UL, 0x00000000UL, 0x3fe29027UL, + 0xf729e1ccUL, 0x3e59a9a0UL, 0x80000000UL, 0x3fe28438UL, 0x6433c727UL, + 0xbe43cc89UL, 0x00000000UL, 0x3fe2784dUL, 0x41782631UL, 0xbe30750cUL, + 0xa0000000UL, 0x3fe26c64UL, 0x914911b7UL, 0xbe58290eUL, 0x40000000UL, + 0x3fe2607fUL, 0x3dcc73e1UL, 0xbe4269cdUL, 0x00000000UL, 0x3fe2549dUL, + 0x2751bf70UL, 0xbe5a6998UL, 0xc0000000UL, 0x3fe248bdUL, 0x4248b9fbUL, + 0xbe4ddb00UL, 0x80000000UL, 0x3fe23ce1UL, 0xf35cf82fUL, 0x3e561b71UL, + 0x60000000UL, 0x3fe23108UL, 0x8e481a2dUL, 0x3e518fb9UL, 0x60000000UL, + 0x3fe22532UL, 0x5ab96edcUL, 0xbe5fafc5UL, 0x40000000UL, 0x3fe2195fUL, + 0x80943911UL, 0xbe07f819UL, 0x40000000UL, 0x3fe20d8fUL, 0x386f2d6cUL, + 0xbe54ba8bUL, 0x40000000UL, 0x3fe201c2UL, 0xf29664acUL, 0xbe5eb815UL, + 0x20000000UL, 0x3fe1f5f8UL, 0x64f03390UL, 0x3e5e320cUL, 0x20000000UL, + 0x3fe1ea31UL, 0x747ff696UL, 0x3e5ef0a5UL, 0x40000000UL, 0x3fe1de6dUL, + 0x3e9ceb51UL, 0xbe5f8d27UL, 0x20000000UL, 0x3fe1d2acUL, 0x4ae0b55eUL, + 0x3e5faa21UL, 0x20000000UL, 0x3fe1c6eeUL, 0x28569a5eUL, 0x3e598a4fUL, + 0x20000000UL, 0x3fe1bb33UL, 0x54b33e07UL, 0x3e46130aUL, 0x20000000UL, + 0x3fe1af7bUL, 0x024f1078UL, 0xbe4dbf93UL, 0x00000000UL, 0x3fe1a3c6UL, + 0xb0783bfaUL, 0x3e419248UL, 0xe0000000UL, 0x3fe19813UL, 0x2f02b836UL, + 0x3e4e02b7UL, 0xc0000000UL, 0x3fe18c64UL, 0x28dec9d4UL, 0x3e09064fUL, + 0x80000000UL, 0x3fe180b8UL, 0x45cbf406UL, 0x3e5b1f46UL, 0x40000000UL, + 0x3fe1750fUL, 0x03d9964cUL, 0x3e5b0a79UL, 0x00000000UL, 0x3fe16969UL, + 0x8b5b882bUL, 0xbe238086UL, 0xa0000000UL, 0x3fe15dc5UL, 0x73bad6f8UL, + 0xbdf1fca4UL, 0x20000000UL, 0x3fe15225UL, 0x5385769cUL, 0x3e5e8d76UL, + 0xa0000000UL, 0x3fe14687UL, 0x1676dc6bUL, 0x3e571d08UL, 0x20000000UL, + 0x3fe13aedUL, 0xa8c41c7fUL, 0xbe598a25UL, 0x60000000UL, 0x3fe12f55UL, + 0xc4e1aaf0UL, 0x3e435277UL, 0xa0000000UL, 0x3fe123c0UL, 0x403638e1UL, + 0xbe21aa7cUL, 0xc0000000UL, 0x3fe1182eUL, 0x557a092bUL, 0xbdd0116bUL, + 0xc0000000UL, 0x3fe10c9fUL, 0x7d779f66UL, 0x3e4a61baUL, 0xc0000000UL, + 0x3fe10113UL, 0x2b09c645UL, 0xbe5d586eUL, 0x20000000UL, 0x3fe0ea04UL, + 0xea2cad46UL, 0x3e5aa97cUL, 0x20000000UL, 0x3fe0d300UL, 0x23190e54UL, + 0x3e50f1a7UL, 0xa0000000UL, 0x3fe0bc07UL, 0x1379a5a6UL, 0xbe51619dUL, + 0x60000000UL, 0x3fe0a51aUL, 0x926a3d4aUL, 0x3e5cf019UL, 0xa0000000UL, + 0x3fe08e38UL, 0xa8c24358UL, 0x3e35241eUL, 0x20000000UL, 0x3fe07762UL, + 0x24317e7aUL, 0x3e512cfaUL, 0x00000000UL, 0x3fe06097UL, 0xfd9cf274UL, + 0xbe55bef3UL, 0x00000000UL, 0x3fe049d7UL, 0x3689b49dUL, 0xbe36d26dUL, + 0x40000000UL, 0x3fe03322UL, 0xf72ef6c4UL, 0xbe54cd08UL, 0xa0000000UL, + 0x3fe01c78UL, 0x23702d2dUL, 0xbe5900bfUL, 0x00000000UL, 0x3fe005daUL, + 0x3f59c14cUL, 0x3e57d80bUL, 0x40000000UL, 0x3fdfde8dUL, 0xad67766dUL, + 0xbe57fad4UL, 0x40000000UL, 0x3fdfb17cUL, 0x644f4ae7UL, 0x3e1ee43bUL, + 0x40000000UL, 0x3fdf8481UL, 0x903234d2UL, 0x3e501a86UL, 0x40000000UL, + 0x3fdf579cUL, 0xafe9e509UL, 0xbe267c3eUL, 0x00000000UL, 0x3fdf2acdUL, + 0xb7dfda0bUL, 0xbe48149bUL, 0x40000000UL, 0x3fdefe13UL, 0x3b94305eUL, + 0x3e5f4ea7UL, 0x80000000UL, 0x3fded16fUL, 0x5d95da61UL, 0xbe55c198UL, + 0x00000000UL, 0x3fdea4e1UL, 0x406960c9UL, 0xbdd99a19UL, 0x00000000UL, + 0x3fde7868UL, 0xd22f3539UL, 0x3e470c78UL, 0x80000000UL, 0x3fde4c04UL, + 0x83eec535UL, 0xbe3e1232UL, 0x40000000UL, 0x3fde1fb6UL, 0x3dfbffcbUL, + 0xbe4b7d71UL, 0x40000000UL, 0x3fddf37dUL, 0x7e1be4e0UL, 0xbe5b8f8fUL, + 0x40000000UL, 0x3fddc759UL, 0x46dae887UL, 0xbe350458UL, 0x80000000UL, + 0x3fdd9b4aUL, 0xed6ecc49UL, 0xbe5f0045UL, 0x80000000UL, 0x3fdd6f50UL, + 0x2e9e883cUL, 0x3e2915daUL, 0x80000000UL, 0x3fdd436bUL, 0xf0bccb32UL, + 0x3e4a68c9UL, 0x80000000UL, 0x3fdd179bUL, 0x9bbfc779UL, 0xbe54a26aUL, + 0x00000000UL, 0x3fdcebe0UL, 0x7cea33abUL, 0x3e43c6b7UL, 0x40000000UL, + 0x3fdcc039UL, 0xe740fd06UL, 0x3e5526c2UL, 0x40000000UL, 0x3fdc94a7UL, + 0x9eadeb1aUL, 0xbe396d8dUL, 0xc0000000UL, 0x3fdc6929UL, 0xf0a8f95aUL, + 0xbe5c0ab2UL, 0x80000000UL, 0x3fdc3dc0UL, 0x6ee2693bUL, 0x3e0992e6UL, + 0xc0000000UL, 0x3fdc126bUL, 0x5ac6b581UL, 0xbe2834b6UL, 0x40000000UL, + 0x3fdbe72bUL, 0x8cc226ffUL, 0x3e3596a6UL, 0x00000000UL, 0x3fdbbbffUL, + 0xf92a74bbUL, 0x3e3c5813UL, 0x00000000UL, 0x3fdb90e7UL, 0x479664c0UL, + 0xbe50d644UL, 0x00000000UL, 0x3fdb65e3UL, 0x5004975bUL, 0xbe55258fUL, + 0x00000000UL, 0x3fdb3af3UL, 0xe4b23194UL, 0xbe588407UL, 0xc0000000UL, + 0x3fdb1016UL, 0xe65d4d0aUL, 0x3e527c26UL, 0x80000000UL, 0x3fdae54eUL, + 0x814fddd6UL, 0x3e5962a2UL, 0x40000000UL, 0x3fdaba9aUL, 0xe19d0913UL, + 0xbe562f4eUL, 0x80000000UL, 0x3fda8ff9UL, 0x43cfd006UL, 0xbe4cfdebUL, + 0x40000000UL, 0x3fda656cUL, 0x686f0a4eUL, 0x3e5e47a8UL, 0xc0000000UL, + 0x3fda3af2UL, 0x7200d410UL, 0x3e5e1199UL, 0xc0000000UL, 0x3fda108cUL, + 0xabd2266eUL, 0x3e5ee4d1UL, 0x40000000UL, 0x3fd9e63aUL, 0x396f8f2cUL, + 0x3e4dbffbUL, 0x00000000UL, 0x3fd9bbfbUL, 0xe32b25ddUL, 0x3e5c3a54UL, + 0x40000000UL, 0x3fd991cfUL, 0x431e4035UL, 0xbe457925UL, 0x80000000UL, + 0x3fd967b6UL, 0x7bed3dd3UL, 0x3e40c61dUL, 0x00000000UL, 0x3fd93db1UL, + 0xd7449365UL, 0x3e306419UL, 0x80000000UL, 0x3fd913beUL, 0x1746e791UL, + 0x3e56fcfcUL, 0x40000000UL, 0x3fd8e9dfUL, 0xf3a9028bUL, 0xbe5041b9UL, + 0xc0000000UL, 0x3fd8c012UL, 0x56840c50UL, 0xbe26e20aUL, 0x40000000UL, + 0x3fd89659UL, 0x19763102UL, 0xbe51f466UL, 0x80000000UL, 0x3fd86cb2UL, + 0x7032de7cUL, 0xbe4d298aUL, 0x80000000UL, 0x3fd8431eUL, 0xdeb39fabUL, + 0xbe4361ebUL, 0x40000000UL, 0x3fd8199dUL, 0x5d01cbe0UL, 0xbe5425b3UL, + 0x80000000UL, 0x3fd7f02eUL, 0x3ce99aa9UL, 0x3e146fa8UL, 0x80000000UL, + 0x3fd7c6d2UL, 0xd1a262b9UL, 0xbe5a1a69UL, 0xc0000000UL, 0x3fd79d88UL, + 0x8606c236UL, 0x3e423a08UL, 0x80000000UL, 0x3fd77451UL, 0x8fd1e1b7UL, + 0x3e5a6a63UL, 0xc0000000UL, 0x3fd74b2cUL, 0xe491456aUL, 0x3e42c1caUL, + 0x40000000UL, 0x3fd7221aUL, 0x4499a6d7UL, 0x3e36a69aUL, 0x00000000UL, + 0x3fd6f91aUL, 0x5237df94UL, 0xbe0f8f02UL, 0x00000000UL, 0x3fd6d02cUL, + 0xb6482c6eUL, 0xbe5abcf7UL, 0x00000000UL, 0x3fd6a750UL, 0x1919fd61UL, + 0xbe57ade2UL, 0x00000000UL, 0x3fd67e86UL, 0xaa7a994dUL, 0xbe3f3fbdUL, + 0x00000000UL, 0x3fd655ceUL, 0x67db014cUL, 0x3e33c550UL, 0x00000000UL, + 0x3fd62d28UL, 0xa82856b7UL, 0xbe1409d1UL, 0xc0000000UL, 0x3fd60493UL, + 0x1e6a300dUL, 0x3e55d899UL, 0x80000000UL, 0x3fd5dc11UL, 0x1222bd5cUL, + 0xbe35bfc0UL, 0xc0000000UL, 0x3fd5b3a0UL, 0x6e8dc2d3UL, 0x3e5d4d79UL, + 0x00000000UL, 0x3fd58b42UL, 0xe0e4ace6UL, 0xbe517303UL, 0x80000000UL, + 0x3fd562f4UL, 0xb306e0a8UL, 0x3e5edf0fUL, 0xc0000000UL, 0x3fd53ab8UL, + 0x6574bc54UL, 0x3e5ee859UL, 0x80000000UL, 0x3fd5128eUL, 0xea902207UL, + 0x3e5f6188UL, 0xc0000000UL, 0x3fd4ea75UL, 0x9f911d79UL, 0x3e511735UL, + 0x80000000UL, 0x3fd4c26eUL, 0xf9c77397UL, 0xbe5b1643UL, 0x40000000UL, + 0x3fd49a78UL, 0x15fc9258UL, 0x3e479a37UL, 0x80000000UL, 0x3fd47293UL, + 0xd5a04dd9UL, 0xbe426e56UL, 0xc0000000UL, 0x3fd44abfUL, 0xe04042f5UL, + 0x3e56f7c6UL, 0x40000000UL, 0x3fd422fdUL, 0x1d8bf2c8UL, 0x3e5d8810UL, + 0x00000000UL, 0x3fd3fb4cUL, 0x88a8ddeeUL, 0xbe311454UL, 0xc0000000UL, + 0x3fd3d3abUL, 0x3e3b5e47UL, 0xbe5d1b72UL, 0x40000000UL, 0x3fd3ac1cUL, + 0xc2ab5d59UL, 0x3e31b02bUL, 0xc0000000UL, 0x3fd3849dUL, 0xd4e34b9eUL, + 0x3e51cb2fUL, 0x40000000UL, 0x3fd35d30UL, 0x177204fbUL, 0xbe2b8cd7UL, + 0x80000000UL, 0x3fd335d3UL, 0xfcd38c82UL, 0xbe4356e1UL, 0x80000000UL, + 0x3fd30e87UL, 0x64f54accUL, 0xbe4e6224UL, 0x00000000UL, 0x3fd2e74cUL, + 0xaa7975d9UL, 0x3e5dc0feUL, 0x80000000UL, 0x3fd2c021UL, 0x516dab3fUL, + 0xbe50ffa3UL, 0x40000000UL, 0x3fd29907UL, 0x2bfb7313UL, 0x3e5674a2UL, + 0xc0000000UL, 0x3fd271fdUL, 0x0549fc99UL, 0x3e385d29UL, 0xc0000000UL, + 0x3fd24b04UL, 0x55b63073UL, 0xbe500c6dUL, 0x00000000UL, 0x3fd2241cUL, + 0x3f91953aUL, 0x3e389977UL, 0xc0000000UL, 0x3fd1fd43UL, 0xa1543f71UL, + 0xbe3487abUL, 0xc0000000UL, 0x3fd1d67bUL, 0x4ec8867cUL, 0x3df6a2dcUL, + 0x00000000UL, 0x3fd1afc4UL, 0x4328e3bbUL, 0x3e41d9c0UL, 0x80000000UL, + 0x3fd1891cUL, 0x2e1cda84UL, 0x3e3bdd87UL, 0x40000000UL, 0x3fd16285UL, + 0x4b5331aeUL, 0xbe53128eUL, 0x00000000UL, 0x3fd13bfeUL, 0xb9aec164UL, + 0xbe52ac98UL, 0xc0000000UL, 0x3fd11586UL, 0xd91e1316UL, 0xbe350630UL, + 0x80000000UL, 0x3fd0ef1fUL, 0x7cacc12cUL, 0x3e3f5219UL, 0x40000000UL, + 0x3fd0c8c8UL, 0xbce277b7UL, 0x3e3d30c0UL, 0x00000000UL, 0x3fd0a281UL, + 0x2a63447dUL, 0xbe541377UL, 0x80000000UL, 0x3fd07c49UL, 0xfac483b5UL, + 0xbe5772ecUL, 0xc0000000UL, 0x3fd05621UL, 0x36b8a570UL, 0xbe4fd4bdUL, + 0xc0000000UL, 0x3fd03009UL, 0xbae505f7UL, 0xbe450388UL, 0x80000000UL, + 0x3fd00a01UL, 0x3e35aeadUL, 0xbe5430fcUL, 0x80000000UL, 0x3fcfc811UL, + 0x707475acUL, 0x3e38806eUL, 0x80000000UL, 0x3fcf7c3fUL, 0xc91817fcUL, + 0xbe40cceaUL, 0x80000000UL, 0x3fcf308cUL, 0xae05d5e9UL, 0xbe4919b8UL, + 0x80000000UL, 0x3fcee4f8UL, 0xae6cc9e6UL, 0xbe530b94UL, 0x00000000UL, + 0x3fce9983UL, 0x1efe3e8eUL, 0x3e57747eUL, 0x00000000UL, 0x3fce4e2dUL, + 0xda78d9bfUL, 0xbe59a608UL, 0x00000000UL, 0x3fce02f5UL, 0x8abe2c2eUL, + 0x3e4a35adUL, 0x00000000UL, 0x3fcdb7dcUL, 0x1495450dUL, 0xbe0872ccUL, + 0x80000000UL, 0x3fcd6ce1UL, 0x86ee0ba0UL, 0xbe4f59a0UL, 0x00000000UL, + 0x3fcd2205UL, 0xe81ca888UL, 0x3e5402c3UL, 0x00000000UL, 0x3fccd747UL, + 0x3b4424b9UL, 0x3e5dfdc3UL, 0x80000000UL, 0x3fcc8ca7UL, 0xd305b56cUL, + 0x3e202da6UL, 0x00000000UL, 0x3fcc4226UL, 0x399a6910UL, 0xbe482a1cUL, + 0x80000000UL, 0x3fcbf7c2UL, 0x747f7938UL, 0xbe587372UL, 0x80000000UL, + 0x3fcbad7cUL, 0x6fc246a0UL, 0x3e50d83dUL, 0x00000000UL, 0x3fcb6355UL, + 0xee9e9be5UL, 0xbe5c35bdUL, 0x80000000UL, 0x3fcb194aUL, 0x8416c0bcUL, + 0x3e546d4fUL, 0x00000000UL, 0x3fcacf5eUL, 0x49f7f08fUL, 0x3e56da76UL, + 0x00000000UL, 0x3fca858fUL, 0x5dc30de2UL, 0x3e5f390cUL, 0x00000000UL, + 0x3fca3bdeUL, 0x950583b6UL, 0xbe5e4169UL, 0x80000000UL, 0x3fc9f249UL, + 0x33631553UL, 0x3e52aeb1UL, 0x00000000UL, 0x3fc9a8d3UL, 0xde8795a6UL, + 0xbe59a504UL, 0x00000000UL, 0x3fc95f79UL, 0x076bf41eUL, 0x3e5122feUL, + 0x80000000UL, 0x3fc9163cUL, 0x2914c8e7UL, 0x3e3dd064UL, 0x00000000UL, + 0x3fc8cd1dUL, 0x3a30eca3UL, 0xbe21b4aaUL, 0x80000000UL, 0x3fc8841aUL, + 0xb2a96650UL, 0xbe575444UL, 0x80000000UL, 0x3fc83b34UL, 0x2376c0cbUL, + 0xbe2a74c7UL, 0x80000000UL, 0x3fc7f26bUL, 0xd8a0b653UL, 0xbe5181b6UL, + 0x00000000UL, 0x3fc7a9bfUL, 0x32257882UL, 0xbe4a78b4UL, 0x00000000UL, + 0x3fc7612fUL, 0x1eee8bd9UL, 0xbe1bfe9dUL, 0x80000000UL, 0x3fc718bbUL, + 0x0c603cc4UL, 0x3e36fdc9UL, 0x80000000UL, 0x3fc6d064UL, 0x3728b8cfUL, + 0xbe1e542eUL, 0x80000000UL, 0x3fc68829UL, 0xc79a4067UL, 0x3e5c380fUL, + 0x00000000UL, 0x3fc6400bUL, 0xf69eac69UL, 0x3e550a84UL, 0x80000000UL, + 0x3fc5f808UL, 0xb7a780a4UL, 0x3e5d9224UL, 0x80000000UL, 0x3fc5b022UL, + 0xad9dfb1eUL, 0xbe55242fUL, 0x00000000UL, 0x3fc56858UL, 0x659b18beUL, + 0xbe4bfda3UL, 0x80000000UL, 0x3fc520a9UL, 0x66ee3631UL, 0xbe57d769UL, + 0x80000000UL, 0x3fc4d916UL, 0x1ec62819UL, 0x3e2427f7UL, 0x80000000UL, + 0x3fc4919fUL, 0xdec25369UL, 0xbe435431UL, 0x00000000UL, 0x3fc44a44UL, + 0xa8acfc4bUL, 0xbe3c62e8UL, 0x00000000UL, 0x3fc40304UL, 0xcf1d3eabUL, + 0xbdfba29fUL, 0x80000000UL, 0x3fc3bbdfUL, 0x79aba3eaUL, 0xbdf1b7c8UL, + 0x80000000UL, 0x3fc374d6UL, 0xb8d186daUL, 0xbe5130cfUL, 0x80000000UL, + 0x3fc32de8UL, 0x9d74f152UL, 0x3e2285b6UL, 0x00000000UL, 0x3fc2e716UL, + 0x50ae7ca9UL, 0xbe503920UL, 0x80000000UL, 0x3fc2a05eUL, 0x6caed92eUL, + 0xbe533924UL, 0x00000000UL, 0x3fc259c2UL, 0x9cb5034eUL, 0xbe510e31UL, + 0x80000000UL, 0x3fc21340UL, 0x12c4d378UL, 0xbe540b43UL, 0x80000000UL, + 0x3fc1ccd9UL, 0xcc418706UL, 0x3e59887aUL, 0x00000000UL, 0x3fc1868eUL, + 0x921f4106UL, 0xbe528e67UL, 0x80000000UL, 0x3fc1405cUL, 0x3969441eUL, + 0x3e5d8051UL, 0x00000000UL, 0x3fc0fa46UL, 0xd941ef5bUL, 0x3e5f9079UL, + 0x80000000UL, 0x3fc0b44aUL, 0x5a3e81b2UL, 0xbe567691UL, 0x00000000UL, + 0x3fc06e69UL, 0x9d66afe7UL, 0xbe4d43fbUL, 0x00000000UL, 0x3fc028a2UL, + 0x0a92a162UL, 0xbe52f394UL, 0x00000000UL, 0x3fbfc5eaUL, 0x209897e5UL, + 0x3e529e37UL, 0x00000000UL, 0x3fbf3ac5UL, 0x8458bd7bUL, 0x3e582831UL, + 0x00000000UL, 0x3fbeafd5UL, 0xb8d8b4b8UL, 0xbe486b4aUL, 0x00000000UL, + 0x3fbe2518UL, 0xe0a3b7b6UL, 0x3e5bafd2UL, 0x00000000UL, 0x3fbd9a90UL, + 0x2bf2710eUL, 0x3e383b2bUL, 0x00000000UL, 0x3fbd103cUL, 0x73eb6ab7UL, + 0xbe56d78dUL, 0x00000000UL, 0x3fbc861bUL, 0x32ceaff5UL, 0xbe32dc5aUL, + 0x00000000UL, 0x3fbbfc2eUL, 0xbee04cb7UL, 0xbe4a71a4UL, 0x00000000UL, + 0x3fbb7274UL, 0x35ae9577UL, 0x3e38142fUL, 0x00000000UL, 0x3fbae8eeUL, + 0xcbaddab4UL, 0xbe5490f0UL, 0x00000000UL, 0x3fba5f9aUL, 0x95ce1114UL, + 0x3e597c71UL, 0x00000000UL, 0x3fb9d67aUL, 0x6d7c0f78UL, 0x3e3abc2dUL, + 0x00000000UL, 0x3fb94d8dUL, 0x2841a782UL, 0xbe566cbcUL, 0x00000000UL, + 0x3fb8c4d2UL, 0x6ed429c6UL, 0xbe3cfff9UL, 0x00000000UL, 0x3fb83c4aUL, + 0xe4a49fbbUL, 0xbe552964UL, 0x00000000UL, 0x3fb7b3f4UL, 0x2193d81eUL, + 0xbe42fa72UL, 0x00000000UL, 0x3fb72bd0UL, 0xdd70c122UL, 0x3e527a8cUL, + 0x00000000UL, 0x3fb6a3dfUL, 0x03108a54UL, 0xbe450393UL, 0x00000000UL, + 0x3fb61c1fUL, 0x30ff7954UL, 0x3e565840UL, 0x00000000UL, 0x3fb59492UL, + 0xdedd460cUL, 0xbe5422b5UL, 0x00000000UL, 0x3fb50d36UL, 0x950f9f45UL, + 0xbe5313f6UL, 0x00000000UL, 0x3fb4860bUL, 0x582cdcb1UL, 0x3e506d39UL, + 0x00000000UL, 0x3fb3ff12UL, 0x7216d3a6UL, 0x3e4aa719UL, 0x00000000UL, + 0x3fb3784aUL, 0x57a423fdUL, 0x3e5a9b9fUL, 0x00000000UL, 0x3fb2f1b4UL, + 0x7a138b41UL, 0xbe50b418UL, 0x00000000UL, 0x3fb26b4eUL, 0x2fbfd7eaUL, + 0x3e23a53eUL, 0x00000000UL, 0x3fb1e519UL, 0x18913ccbUL, 0x3e465fc1UL, + 0x00000000UL, 0x3fb15f15UL, 0x7ea24e21UL, 0x3e042843UL, 0x00000000UL, + 0x3fb0d941UL, 0x7c6d9c77UL, 0x3e59f61eUL, 0x00000000UL, 0x3fb0539eUL, + 0x114efd44UL, 0x3e4ccab7UL, 0x00000000UL, 0x3faf9c56UL, 0x1777f657UL, + 0x3e552f65UL, 0x00000000UL, 0x3fae91d2UL, 0xc317b86aUL, 0xbe5a61e0UL, + 0x00000000UL, 0x3fad87acUL, 0xb7664efbUL, 0xbe41f64eUL, 0x00000000UL, + 0x3fac7de6UL, 0x5d3d03a9UL, 0x3e0807a0UL, 0x00000000UL, 0x3fab7480UL, + 0x743c38ebUL, 0xbe3726e1UL, 0x00000000UL, 0x3faa6b78UL, 0x06a253f1UL, + 0x3e5ad636UL, 0x00000000UL, 0x3fa962d0UL, 0xa35f541bUL, 0x3e5a187aUL, + 0x00000000UL, 0x3fa85a88UL, 0x4b86e446UL, 0xbe508150UL, 0x00000000UL, + 0x3fa7529cUL, 0x2589cacfUL, 0x3e52938aUL, 0x00000000UL, 0x3fa64b10UL, + 0xaf6b11f2UL, 0xbe3454cdUL, 0x00000000UL, 0x3fa543e2UL, 0x97506fefUL, + 0xbe5fdec5UL, 0x00000000UL, 0x3fa43d10UL, 0xe75f7dd9UL, 0xbe388dd3UL, + 0x00000000UL, 0x3fa3369cUL, 0xa4139632UL, 0xbdea5177UL, 0x00000000UL, + 0x3fa23086UL, 0x352d6f1eUL, 0xbe565ad6UL, 0x00000000UL, 0x3fa12accUL, + 0x77449eb7UL, 0xbe50d5c7UL, 0x00000000UL, 0x3fa0256eUL, 0x7478da78UL, + 0x3e404724UL, 0x00000000UL, 0x3f9e40dcUL, 0xf59cef7fUL, 0xbe539d0aUL, + 0x00000000UL, 0x3f9c3790UL, 0x1511d43cUL, 0x3e53c2c8UL, 0x00000000UL, + 0x3f9a2f00UL, 0x9b8bff3cUL, 0xbe43b3e1UL, 0x00000000UL, 0x3f982724UL, + 0xad1e22a5UL, 0x3e46f0bdUL, 0x00000000UL, 0x3f962000UL, 0x130d9356UL, + 0x3e475ba0UL, 0x00000000UL, 0x3f941994UL, 0x8f86f883UL, 0xbe513d0bUL, + 0x00000000UL, 0x3f9213dcUL, 0x914d0dc8UL, 0xbe534335UL, 0x00000000UL, + 0x3f900ed8UL, 0x2d73e5e7UL, 0xbe22ba75UL, 0x00000000UL, 0x3f8c1510UL, + 0xc5b7d70eUL, 0x3e599c5dUL, 0x00000000UL, 0x3f880de0UL, 0x8a27857eUL, + 0xbe3d28c8UL, 0x00000000UL, 0x3f840810UL, 0xda767328UL, 0x3e531b3dUL, + 0x00000000UL, 0x3f8003b0UL, 0x77bacaf3UL, 0xbe5f04e3UL, 0x00000000UL, + 0x3f780150UL, 0xdf4b0720UL, 0x3e5a8bffUL, 0x00000000UL, 0x3f6ffc40UL, + 0x34c48e71UL, 0xbe3fcd99UL, 0x00000000UL, 0x3f5ff6c0UL, 0x1ad218afUL, + 0xbe4c78a7UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x80000000UL, + 0x00000000UL, 0xfffff800UL, 0x00000000UL, 0xfffff800UL, 0x00000000UL, + 0x3ff72000UL, 0x161bb241UL, 0xbf5dabe1UL, 0x6dc96112UL, 0xbf836578UL, + 0xee241472UL, 0xbf9b0301UL, 0x9f95985aUL, 0xbfb528dbUL, 0xb3841d2aUL, + 0xbfd619b6UL, 0x518775e3UL, 0x3f9004f2UL, 0xac8349bbUL, 0x3fa76c9bUL, + 0x486ececcUL, 0x3fc4635eUL, 0x161bb241UL, 0xbf5dabe1UL, 0x9f95985aUL, + 0xbfb528dbUL, 0xf8b5787dUL, 0x3ef2531eUL, 0x486ececbUL, 0x3fc4635eUL, + 0x412055ccUL, 0xbdd61bb2UL, 0x00000000UL, 0xfffffff8UL, 0x00000000UL, + 0xffffffffUL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x3b700000UL, + 0xfa5abcbfUL, 0x3ff00b1aUL, 0xa7609f71UL, 0xbc84f6b2UL, 0xa9fb3335UL, + 0x3ff0163dUL, 0x9ab8cdb7UL, 0x3c9b6129UL, 0x143b0281UL, 0x3ff02168UL, + 0x0fc54eb6UL, 0xbc82bf31UL, 0x3e778061UL, 0x3ff02c9aUL, 0x535b085dUL, + 0xbc719083UL, 0x2e11bbccUL, 0x3ff037d4UL, 0xeeade11aUL, 0x3c656811UL, + 0xe86e7f85UL, 0x3ff04315UL, 0x1977c96eUL, 0xbc90a31cUL, 0x72f654b1UL, + 0x3ff04e5fUL, 0x3aa0d08cUL, 0x3c84c379UL, 0xd3158574UL, 0x3ff059b0UL, + 0xa475b465UL, 0x3c8d73e2UL, 0x0e3c1f89UL, 0x3ff0650aUL, 0x5799c397UL, + 0xbc95cb7bUL, 0x29ddf6deUL, 0x3ff0706bUL, 0xe2b13c27UL, 0xbc8c91dfUL, + 0x2b72a836UL, 0x3ff07bd4UL, 0x54458700UL, 0x3c832334UL, 0x18759bc8UL, + 0x3ff08745UL, 0x4bb284ffUL, 0x3c6186beUL, 0xf66607e0UL, 0x3ff092bdUL, + 0x800a3fd1UL, 0xbc968063UL, 0xcac6f383UL, 0x3ff09e3eUL, 0x18316136UL, + 0x3c914878UL, 0x9b1f3919UL, 0x3ff0a9c7UL, 0x873d1d38UL, 0x3c85d16cUL, + 0x6cf9890fUL, 0x3ff0b558UL, 0x4adc610bUL, 0x3c98a62eUL, 0x45e46c85UL, + 0x3ff0c0f1UL, 0x06d21cefUL, 0x3c94f989UL, 0x2b7247f7UL, 0x3ff0cc92UL, + 0x16e24f71UL, 0x3c901edcUL, 0x23395decUL, 0x3ff0d83bUL, 0xe43f316aUL, + 0xbc9bc14dUL, 0x32d3d1a2UL, 0x3ff0e3ecUL, 0x27c57b52UL, 0x3c403a17UL, + 0x5fdfa9c5UL, 0x3ff0efa5UL, 0xbc54021bUL, 0xbc949db9UL, 0xaffed31bUL, + 0x3ff0fb66UL, 0xc44ebd7bUL, 0xbc6b9bedUL, 0x28d7233eUL, 0x3ff10730UL, + 0x1692fdd5UL, 0x3c8d46ebUL, 0xd0125b51UL, 0x3ff11301UL, 0x39449b3aUL, + 0xbc96c510UL, 0xab5e2ab6UL, 0x3ff11edbUL, 0xf703fb72UL, 0xbc9ca454UL, + 0xc06c31ccUL, 0x3ff12abdUL, 0xb36ca5c7UL, 0xbc51b514UL, 0x14f204abUL, + 0x3ff136a8UL, 0xba48dcf0UL, 0xbc67108fUL, 0xaea92de0UL, 0x3ff1429aUL, + 0x9af1369eUL, 0xbc932fbfUL, 0x934f312eUL, 0x3ff14e95UL, 0x39bf44abUL, + 0xbc8b91e8UL, 0xc8a58e51UL, 0x3ff15a98UL, 0xb9eeab0aUL, 0x3c82406aUL, + 0x5471c3c2UL, 0x3ff166a4UL, 0x82ea1a32UL, 0x3c58f23bUL, 0x3c7d517bUL, + 0x3ff172b8UL, 0xb9d78a76UL, 0xbc819041UL, 0x8695bbc0UL, 0x3ff17ed4UL, + 0xe2ac5a64UL, 0x3c709e3fUL, 0x388c8deaUL, 0x3ff18af9UL, 0xd1970f6cUL, + 0xbc911023UL, 0x58375d2fUL, 0x3ff19726UL, 0x85f17e08UL, 0x3c94aaddUL, + 0xeb6fcb75UL, 0x3ff1a35bUL, 0x7b4968e4UL, 0x3c8e5b4cUL, 0xf8138a1cUL, + 0x3ff1af99UL, 0xa4b69280UL, 0x3c97bf85UL, 0x84045cd4UL, 0x3ff1bbe0UL, + 0x352ef607UL, 0xbc995386UL, 0x95281c6bUL, 0x3ff1c82fUL, 0x8010f8c9UL, + 0x3c900977UL, 0x3168b9aaUL, 0x3ff1d487UL, 0x00a2643cUL, 0x3c9e016eUL, + 0x5eb44027UL, 0x3ff1e0e7UL, 0x088cb6deUL, 0xbc96fdd8UL, 0x22fcd91dUL, + 0x3ff1ed50UL, 0x027bb78cUL, 0xbc91df98UL, 0x8438ce4dUL, 0x3ff1f9c1UL, + 0xa097af5cUL, 0xbc9bf524UL, 0x88628cd6UL, 0x3ff2063bUL, 0x814a8495UL, + 0x3c8dc775UL, 0x3578a819UL, 0x3ff212beUL, 0x2cfcaac9UL, 0x3c93592dUL, + 0x917ddc96UL, 0x3ff21f49UL, 0x9494a5eeUL, 0x3c82a97eUL, 0xa27912d1UL, + 0x3ff22bddUL, 0x5577d69fUL, 0x3c8d34fbUL, 0x6e756238UL, 0x3ff2387aUL, + 0xb6c70573UL, 0x3c99b07eUL, 0xfb82140aUL, 0x3ff2451fUL, 0x911ca996UL, + 0x3c8acfccUL, 0x4fb2a63fUL, 0x3ff251ceUL, 0xbef4f4a4UL, 0x3c8ac155UL, + 0x711ece75UL, 0x3ff25e85UL, 0x4ac31b2cUL, 0x3c93e1a2UL, 0x65e27cddUL, + 0x3ff26b45UL, 0x9940e9d9UL, 0x3c82bd33UL, 0x341ddf29UL, 0x3ff2780eUL, + 0x05f9e76cUL, 0x3c9e067cUL, 0xe1f56381UL, 0x3ff284dfUL, 0x8c3f0d7eUL, + 0xbc9a4c3aUL, 0x7591bb70UL, 0x3ff291baUL, 0x28401cbdUL, 0xbc82cc72UL, + 0xf51fdee1UL, 0x3ff29e9dUL, 0xafad1255UL, 0x3c8612e8UL, 0x66d10f13UL, + 0x3ff2ab8aUL, 0x191690a7UL, 0xbc995743UL, 0xd0dad990UL, 0x3ff2b87fUL, + 0xd6381aa4UL, 0xbc410adcUL, 0x39771b2fUL, 0x3ff2c57eUL, 0xa6eb5124UL, + 0xbc950145UL, 0xa6e4030bUL, 0x3ff2d285UL, 0x54db41d5UL, 0x3c900247UL, + 0x1f641589UL, 0x3ff2df96UL, 0xfbbce198UL, 0x3c9d16cfUL, 0xa93e2f56UL, + 0x3ff2ecafUL, 0x45d52383UL, 0x3c71ca0fUL, 0x4abd886bUL, 0x3ff2f9d2UL, + 0x532bda93UL, 0xbc653c55UL, 0x0a31b715UL, 0x3ff306feUL, 0xd23182e4UL, + 0x3c86f46aUL, 0xedeeb2fdUL, 0x3ff31432UL, 0xf3f3fcd1UL, 0x3c8959a3UL, + 0xfc4cd831UL, 0x3ff32170UL, 0x8e18047cUL, 0x3c8a9ce7UL, 0x3ba8ea32UL, + 0x3ff32eb8UL, 0x3cb4f318UL, 0xbc9c45e8UL, 0xb26416ffUL, 0x3ff33c08UL, + 0x843659a6UL, 0x3c932721UL, 0x66e3fa2dUL, 0x3ff34962UL, 0x930881a4UL, + 0xbc835a75UL, 0x5f929ff1UL, 0x3ff356c5UL, 0x5c4e4628UL, 0xbc8b5ceeUL, + 0xa2de883bUL, 0x3ff36431UL, 0xa06cb85eUL, 0xbc8c3144UL, 0x373aa9cbUL, + 0x3ff371a7UL, 0xbf42eae2UL, 0xbc963aeaUL, 0x231e754aUL, 0x3ff37f26UL, + 0x9eceb23cUL, 0xbc99f5caUL, 0x6d05d866UL, 0x3ff38caeUL, 0x3c9904bdUL, + 0xbc9e958dUL, 0x1b7140efUL, 0x3ff39a40UL, 0xfc8e2934UL, 0xbc99a9a5UL, + 0x34e59ff7UL, 0x3ff3a7dbUL, 0xd661f5e3UL, 0xbc75e436UL, 0xbfec6cf4UL, + 0x3ff3b57fUL, 0xe26fff18UL, 0x3c954c66UL, 0xc313a8e5UL, 0x3ff3c32dUL, + 0x375d29c3UL, 0xbc9efff8UL, 0x44ede173UL, 0x3ff3d0e5UL, 0x8c284c71UL, + 0x3c7fe8d0UL, 0x4c123422UL, 0x3ff3dea6UL, 0x11f09ebcUL, 0x3c8ada09UL, + 0xdf1c5175UL, 0x3ff3ec70UL, 0x7b8c9bcaUL, 0xbc8af663UL, 0x04ac801cUL, + 0x3ff3fa45UL, 0xf956f9f3UL, 0xbc97d023UL, 0xc367a024UL, 0x3ff40822UL, + 0xb6f4d048UL, 0x3c8bddf8UL, 0x21f72e2aUL, 0x3ff4160aUL, 0x1c309278UL, + 0xbc5ef369UL, 0x2709468aUL, 0x3ff423fbUL, 0xc0b314ddUL, 0xbc98462dUL, + 0xd950a897UL, 0x3ff431f5UL, 0xe35f7999UL, 0xbc81c7ddUL, 0x3f84b9d4UL, + 0x3ff43ffaUL, 0x9704c003UL, 0x3c8880beUL, 0x6061892dUL, 0x3ff44e08UL, + 0x04ef80d0UL, 0x3c489b7aUL, 0x42a7d232UL, 0x3ff45c20UL, 0x82fb1f8eUL, + 0xbc686419UL, 0xed1d0057UL, 0x3ff46a41UL, 0xd1648a76UL, 0x3c9c944bUL, + 0x668b3237UL, 0x3ff4786dUL, 0xed445733UL, 0xbc9c20f0UL, 0xb5c13cd0UL, + 0x3ff486a2UL, 0xb69062f0UL, 0x3c73c1a3UL, 0xe192aed2UL, 0x3ff494e1UL, + 0x5e499ea0UL, 0xbc83b289UL, 0xf0d7d3deUL, 0x3ff4a32aUL, 0xf3d1be56UL, + 0x3c99cb62UL, 0xea6db7d7UL, 0x3ff4b17dUL, 0x7f2897f0UL, 0xbc8125b8UL, + 0xd5362a27UL, 0x3ff4bfdaUL, 0xafec42e2UL, 0x3c7d4397UL, 0xb817c114UL, + 0x3ff4ce41UL, 0x690abd5dUL, 0x3c905e29UL, 0x99fddd0dUL, 0x3ff4dcb2UL, + 0xbc6a7833UL, 0x3c98ecdbUL, 0x81d8abffUL, 0x3ff4eb2dUL, 0x2e5d7a52UL, + 0xbc95257dUL, 0x769d2ca7UL, 0x3ff4f9b2UL, 0xd25957e3UL, 0xbc94b309UL, + 0x7f4531eeUL, 0x3ff50841UL, 0x49b7465fUL, 0x3c7a249bUL, 0xa2cf6642UL, + 0x3ff516daUL, 0x69bd93efUL, 0xbc8f7685UL, 0xe83f4eefUL, 0x3ff5257dUL, + 0x43efef71UL, 0xbc7c998dUL, 0x569d4f82UL, 0x3ff5342bUL, 0x1db13cadUL, + 0xbc807abeUL, 0xf4f6ad27UL, 0x3ff542e2UL, 0x192d5f7eUL, 0x3c87926dUL, + 0xca5d920fUL, 0x3ff551a4UL, 0xefede59bUL, 0xbc8d689cUL, 0xdde910d2UL, + 0x3ff56070UL, 0x168eebf0UL, 0xbc90fb6eUL, 0x36b527daUL, 0x3ff56f47UL, + 0x011d93adUL, 0x3c99bb2cUL, 0xdbe2c4cfUL, 0x3ff57e27UL, 0x8a57b9c4UL, + 0xbc90b98cUL, 0xd497c7fdUL, 0x3ff58d12UL, 0x5b9a1de8UL, 0x3c8295e1UL, + 0x27ff07ccUL, 0x3ff59c08UL, 0xe467e60fUL, 0xbc97e2ceUL, 0xdd485429UL, + 0x3ff5ab07UL, 0x054647adUL, 0x3c96324cUL, 0xfba87a03UL, 0x3ff5ba11UL, + 0x4c233e1aUL, 0xbc9b77a1UL, 0x8a5946b7UL, 0x3ff5c926UL, 0x816986a2UL, + 0x3c3c4b1bUL, 0x90998b93UL, 0x3ff5d845UL, 0xa8b45643UL, 0xbc9cd6a7UL, + 0x15ad2148UL, 0x3ff5e76fUL, 0x3080e65eUL, 0x3c9ba6f9UL, 0x20dceb71UL, + 0x3ff5f6a3UL, 0xe3cdcf92UL, 0xbc89eaddUL, 0xb976dc09UL, 0x3ff605e1UL, + 0x9b56de47UL, 0xbc93e242UL, 0xe6cdf6f4UL, 0x3ff6152aUL, 0x4ab84c27UL, + 0x3c9e4b3eUL, 0xb03a5585UL, 0x3ff6247eUL, 0x7e40b497UL, 0xbc9383c1UL, + 0x1d1929fdUL, 0x3ff633ddUL, 0xbeb964e5UL, 0x3c984710UL, 0x34ccc320UL, + 0x3ff64346UL, 0x759d8933UL, 0xbc8c483cUL, 0xfebc8fb7UL, 0x3ff652b9UL, + 0xc9a73e09UL, 0xbc9ae3d5UL, 0x82552225UL, 0x3ff66238UL, 0x87591c34UL, + 0xbc9bb609UL, 0xc70833f6UL, 0x3ff671c1UL, 0x586c6134UL, 0xbc8e8732UL, + 0xd44ca973UL, 0x3ff68155UL, 0x44f73e65UL, 0x3c6038aeUL, 0xb19e9538UL, + 0x3ff690f4UL, 0x9aeb445dUL, 0x3c8804bdUL, 0x667f3bcdUL, 0x3ff6a09eUL, + 0x13b26456UL, 0xbc9bdd34UL, 0xfa75173eUL, 0x3ff6b052UL, 0x2c9a9d0eUL, + 0x3c7a38f5UL, 0x750bdabfUL, 0x3ff6c012UL, 0x67ff0b0dUL, 0xbc728956UL, + 0xddd47645UL, 0x3ff6cfdcUL, 0xb6f17309UL, 0x3c9c7aa9UL, 0x3c651a2fUL, + 0x3ff6dfb2UL, 0x683c88abUL, 0xbc6bbe3aUL, 0x98593ae5UL, 0x3ff6ef92UL, + 0x9e1ac8b2UL, 0xbc90b974UL, 0xf9519484UL, 0x3ff6ff7dUL, 0x25860ef6UL, + 0xbc883c0fUL, 0x66f42e87UL, 0x3ff70f74UL, 0xd45aa65fUL, 0x3c59d644UL, + 0xe8ec5f74UL, 0x3ff71f75UL, 0x86887a99UL, 0xbc816e47UL, 0x86ead08aUL, + 0x3ff72f82UL, 0x2cd62c72UL, 0xbc920aa0UL, 0x48a58174UL, 0x3ff73f9aUL, + 0x6c65d53cUL, 0xbc90a8d9UL, 0x35d7cbfdUL, 0x3ff74fbdUL, 0x618a6e1cUL, + 0x3c9047fdUL, 0x564267c9UL, 0x3ff75febUL, 0x57316dd3UL, 0xbc902459UL, + 0xb1ab6e09UL, 0x3ff77024UL, 0x169147f8UL, 0x3c9b7877UL, 0x4fde5d3fUL, + 0x3ff78069UL, 0x0a02162dUL, 0x3c9866b8UL, 0x38ac1cf6UL, 0x3ff790b9UL, + 0x62aadd3eUL, 0x3c9349a8UL, 0x73eb0187UL, 0x3ff7a114UL, 0xee04992fUL, + 0xbc841577UL, 0x0976cfdbUL, 0x3ff7b17bUL, 0x8468dc88UL, 0xbc9bebb5UL, + 0x0130c132UL, 0x3ff7c1edUL, 0xd1164dd6UL, 0x3c9f124cUL, 0x62ff86f0UL, + 0x3ff7d26aUL, 0xfb72b8b4UL, 0x3c91bddbUL, 0x36cf4e62UL, 0x3ff7e2f3UL, + 0xba15797eUL, 0x3c705d02UL, 0x8491c491UL, 0x3ff7f387UL, 0xcf9311aeUL, + 0xbc807f11UL, 0x543e1a12UL, 0x3ff80427UL, 0x626d972bUL, 0xbc927c86UL, + 0xadd106d9UL, 0x3ff814d2UL, 0x0d151d4dUL, 0x3c946437UL, 0x994cce13UL, + 0x3ff82589UL, 0xd41532d8UL, 0xbc9d4c1dUL, 0x1eb941f7UL, 0x3ff8364cUL, + 0x31df2bd5UL, 0x3c999b9aUL, 0x4623c7adUL, 0x3ff8471aUL, 0xa341cdfbUL, + 0xbc88d684UL, 0x179f5b21UL, 0x3ff857f4UL, 0xf8b216d0UL, 0xbc5ba748UL, + 0x9b4492edUL, 0x3ff868d9UL, 0x9bd4f6baUL, 0xbc9fc6f8UL, 0xd931a436UL, + 0x3ff879caUL, 0xd2db47bdUL, 0x3c85d2d7UL, 0xd98a6699UL, 0x3ff88ac7UL, + 0xf37cb53aUL, 0x3c9994c2UL, 0xa478580fUL, 0x3ff89bd0UL, 0x4475202aUL, + 0x3c9d5395UL, 0x422aa0dbUL, 0x3ff8ace5UL, 0x56864b27UL, 0x3c96e9f1UL, + 0xbad61778UL, 0x3ff8be05UL, 0xfc43446eUL, 0x3c9ecb5eUL, 0x16b5448cUL, + 0x3ff8cf32UL, 0x32e9e3aaUL, 0xbc70d55eUL, 0x5e0866d9UL, 0x3ff8e06aUL, + 0x6fc9b2e6UL, 0xbc97114aUL, 0x99157736UL, 0x3ff8f1aeUL, 0xa2e3976cUL, + 0x3c85cc13UL, 0xd0282c8aUL, 0x3ff902feUL, 0x85fe3fd2UL, 0x3c9592caUL, + 0x0b91ffc6UL, 0x3ff9145bUL, 0x2e582524UL, 0xbc9dd679UL, 0x53aa2fe2UL, + 0x3ff925c3UL, 0xa639db7fUL, 0xbc83455fUL, 0xb0cdc5e5UL, 0x3ff93737UL, + 0x81b57ebcUL, 0xbc675fc7UL, 0x2b5f98e5UL, 0x3ff948b8UL, 0x797d2d99UL, + 0xbc8dc3d6UL, 0xcbc8520fUL, 0x3ff95a44UL, 0x96a5f039UL, 0xbc764b7cUL, + 0x9a7670b3UL, 0x3ff96bddUL, 0x7f19c896UL, 0xbc5ba596UL, 0x9fde4e50UL, + 0x3ff97d82UL, 0x7c1b85d1UL, 0xbc9d185bUL, 0xe47a22a2UL, 0x3ff98f33UL, + 0xa24c78ecUL, 0x3c7cabdaUL, 0x70ca07baUL, 0x3ff9a0f1UL, 0x91cee632UL, + 0xbc9173bdUL, 0x4d53fe0dUL, 0x3ff9b2bbUL, 0x4df6d518UL, 0xbc9dd84eUL, + 0x82a3f090UL, 0x3ff9c491UL, 0xb071f2beUL, 0x3c7c7c46UL, 0x194bb8d5UL, + 0x3ff9d674UL, 0xa3dd8233UL, 0xbc9516beUL, 0x19e32323UL, 0x3ff9e863UL, + 0x78e64c6eUL, 0x3c7824caUL, 0x8d07f29eUL, 0x3ff9fa5eUL, 0xaaf1faceUL, + 0xbc84a9ceUL, 0x7b5de565UL, 0x3ffa0c66UL, 0x5d1cd533UL, 0xbc935949UL, + 0xed8eb8bbUL, 0x3ffa1e7aUL, 0xee8be70eUL, 0x3c9c6618UL, 0xec4a2d33UL, + 0x3ffa309bUL, 0x7ddc36abUL, 0x3c96305cUL, 0x80460ad8UL, 0x3ffa42c9UL, + 0x589fb120UL, 0xbc9aa780UL, 0xb23e255dUL, 0x3ffa5503UL, 0xdb8d41e1UL, + 0xbc9d2f6eUL, 0x8af46052UL, 0x3ffa674aUL, 0x30670366UL, 0x3c650f56UL, + 0x1330b358UL, 0x3ffa799eUL, 0xcac563c7UL, 0x3c9bcb7eUL, 0x53c12e59UL, + 0x3ffa8bfeUL, 0xb2ba15a9UL, 0xbc94f867UL, 0x5579fdbfUL, 0x3ffa9e6bUL, + 0x0ef7fd31UL, 0x3c90fac9UL, 0x21356ebaUL, 0x3ffab0e5UL, 0xdae94545UL, + 0x3c889c31UL, 0xbfd3f37aUL, 0x3ffac36bUL, 0xcae76cd0UL, 0xbc8f9234UL, + 0x3a3c2774UL, 0x3ffad5ffUL, 0xb6b1b8e5UL, 0x3c97ef3bUL, 0x995ad3adUL, + 0x3ffae89fUL, 0x345dcc81UL, 0x3c97a1cdUL, 0xe622f2ffUL, 0x3ffafb4cUL, + 0x0f315ecdUL, 0xbc94b2fcUL, 0x298db666UL, 0x3ffb0e07UL, 0x4c80e425UL, + 0xbc9bdef5UL, 0x6c9a8952UL, 0x3ffb20ceUL, 0x4a0756ccUL, 0x3c94dd02UL, + 0xb84f15fbUL, 0x3ffb33a2UL, 0x3084d708UL, 0xbc62805eUL, 0x15b749b1UL, + 0x3ffb4684UL, 0xe9df7c90UL, 0xbc7f763dUL, 0x8de5593aUL, 0x3ffb5972UL, + 0xbbba6de3UL, 0xbc9c71dfUL, 0x29f1c52aUL, 0x3ffb6c6eUL, 0x52883f6eUL, + 0x3c92a8f3UL, 0xf2fb5e47UL, 0x3ffb7f76UL, 0x7e54ac3bUL, 0xbc75584fUL, + 0xf22749e4UL, 0x3ffb928cUL, 0x54cb65c6UL, 0xbc9b7216UL, 0x30a1064aUL, + 0x3ffba5b0UL, 0x0e54292eUL, 0xbc9efcd3UL, 0xb79a6f1fUL, 0x3ffbb8e0UL, + 0xc9696205UL, 0xbc3f52d1UL, 0x904bc1d2UL, 0x3ffbcc1eUL, 0x7a2d9e84UL, + 0x3c823dd0UL, 0xc3f3a207UL, 0x3ffbdf69UL, 0x60ea5b53UL, 0xbc3c2623UL, + 0x5bd71e09UL, 0x3ffbf2c2UL, 0x3f6b9c73UL, 0xbc9efdcaUL, 0x6141b33dUL, + 0x3ffc0628UL, 0xa1fbca34UL, 0xbc8d8a5aUL, 0xdd85529cUL, 0x3ffc199bUL, + 0x895048ddUL, 0x3c811065UL, 0xd9fa652cUL, 0x3ffc2d1cUL, 0x17c8a5d7UL, + 0xbc96e516UL, 0x5fffd07aUL, 0x3ffc40abUL, 0xe083c60aUL, 0x3c9b4537UL, + 0x78fafb22UL, 0x3ffc5447UL, 0x2493b5afUL, 0x3c912f07UL, 0x2e57d14bUL, + 0x3ffc67f1UL, 0xff483cadUL, 0x3c92884dUL, 0x8988c933UL, 0x3ffc7ba8UL, + 0xbe255559UL, 0xbc8e76bbUL, 0x9406e7b5UL, 0x3ffc8f6dUL, 0x48805c44UL, + 0x3c71acbcUL, 0x5751c4dbUL, 0x3ffca340UL, 0xd10d08f5UL, 0xbc87f2beUL, + 0xdcef9069UL, 0x3ffcb720UL, 0xd1e949dbUL, 0x3c7503cbUL, 0x2e6d1675UL, + 0x3ffccb0fUL, 0x86009092UL, 0xbc7d220fUL, 0x555dc3faUL, 0x3ffcdf0bUL, + 0x53829d72UL, 0xbc8dd83bUL, 0x5b5bab74UL, 0x3ffcf315UL, 0xb86dff57UL, + 0xbc9a08e9UL, 0x4a07897cUL, 0x3ffd072dUL, 0x43797a9cUL, 0xbc9cbc37UL, + 0x2b08c968UL, 0x3ffd1b53UL, 0x219a36eeUL, 0x3c955636UL, 0x080d89f2UL, + 0x3ffd2f87UL, 0x719d8578UL, 0xbc9d487bUL, 0xeacaa1d6UL, 0x3ffd43c8UL, + 0xbf5a1614UL, 0x3c93db53UL, 0xdcfba487UL, 0x3ffd5818UL, 0xd75b3707UL, + 0x3c82ed02UL, 0xe862e6d3UL, 0x3ffd6c76UL, 0x4a8165a0UL, 0x3c5fe87aUL, + 0x16c98398UL, 0x3ffd80e3UL, 0x8beddfe8UL, 0xbc911ec1UL, 0x71ff6075UL, + 0x3ffd955dUL, 0xbb9af6beUL, 0x3c9a052dUL, 0x03db3285UL, 0x3ffda9e6UL, + 0x696db532UL, 0x3c9c2300UL, 0xd63a8315UL, 0x3ffdbe7cUL, 0x926b8be4UL, + 0xbc9b76f1UL, 0xf301b460UL, 0x3ffdd321UL, 0x78f018c3UL, 0x3c92da57UL, + 0x641c0658UL, 0x3ffde7d5UL, 0x8e79ba8fUL, 0xbc9ca552UL, 0x337b9b5fUL, + 0x3ffdfc97UL, 0x4f184b5cUL, 0xbc91a5cdUL, 0x6b197d17UL, 0x3ffe1167UL, + 0xbd5c7f44UL, 0xbc72b529UL, 0x14f5a129UL, 0x3ffe2646UL, 0x817a1496UL, + 0xbc97b627UL, 0x3b16ee12UL, 0x3ffe3b33UL, 0x31fdc68bUL, 0xbc99f4a4UL, + 0xe78b3ff6UL, 0x3ffe502eUL, 0x80a9cc8fUL, 0x3c839e89UL, 0x24676d76UL, + 0x3ffe6539UL, 0x7522b735UL, 0xbc863ff8UL, 0xfbc74c83UL, 0x3ffe7a51UL, + 0xca0c8de2UL, 0x3c92d522UL, 0x77cdb740UL, 0x3ffe8f79UL, 0x80b054b1UL, + 0xbc910894UL, 0xa2a490daUL, 0x3ffea4afUL, 0x179c2893UL, 0xbc9e9c23UL, + 0x867cca6eUL, 0x3ffeb9f4UL, 0x2293e4f2UL, 0x3c94832fUL, 0x2d8e67f1UL, + 0x3ffecf48UL, 0xb411ad8cUL, 0xbc9c93f3UL, 0xa2188510UL, 0x3ffee4aaUL, + 0xa487568dUL, 0x3c91c68dUL, 0xee615a27UL, 0x3ffefa1bUL, 0x86a4b6b0UL, + 0x3c9dc7f4UL, 0x1cb6412aUL, 0x3fff0f9cUL, 0x65181d45UL, 0xbc932200UL, + 0x376bba97UL, 0x3fff252bUL, 0xbf0d8e43UL, 0x3c93a1a5UL, 0x48dd7274UL, + 0x3fff3ac9UL, 0x3ed837deUL, 0xbc795a5aUL, 0x5b6e4540UL, 0x3fff5076UL, + 0x2dd8a18bUL, 0x3c99d3e1UL, 0x798844f8UL, 0x3fff6632UL, 0x3539343eUL, + 0x3c9fa37bUL, 0xad9cbe14UL, 0x3fff7bfdUL, 0xd006350aUL, 0xbc9dbb12UL, + 0x02243c89UL, 0x3fff91d8UL, 0xa779f689UL, 0xbc612ea8UL, 0x819e90d8UL, + 0x3fffa7c1UL, 0xf3a5931eUL, 0x3c874853UL, 0x3692d514UL, 0x3fffbdbaUL, + 0x15098eb6UL, 0xbc796773UL, 0x2b8f71f1UL, 0x3fffd3c2UL, 0x966579e7UL, + 0x3c62eb74UL, 0x6b2a23d9UL, 0x3fffe9d9UL, 0x7442fde3UL, 0x3c74a603UL, + 0xe78a6731UL, 0x3f55d87fUL, 0xd704a0c0UL, 0x3fac6b08UL, 0x6fba4e77UL, + 0x3f83b2abUL, 0xff82c58fUL, 0x3fcebfbdUL, 0xfefa39efUL, 0x3fe62e42UL, + 0x00000000UL, 0x00000000UL, 0xfefa39efUL, 0x3fe62e42UL, 0xfefa39efUL, + 0xbfe62e42UL, 0xf8000000UL, 0xffffffffUL, 0xf8000000UL, 0xffffffffUL, + 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x00000000UL + +}; + +//registers, +// input: xmm0, xmm1 +// scratch: xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7 +// eax, edx, ecx, ebx + +// Code generated by Intel C compiler for LIBM library + +void MacroAssembler::fast_pow(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) { + Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; + Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; + Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2; + Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, L_2TAG_PACKET_14_0_2, L_2TAG_PACKET_15_0_2; + Label L_2TAG_PACKET_16_0_2, L_2TAG_PACKET_17_0_2, L_2TAG_PACKET_18_0_2, L_2TAG_PACKET_19_0_2; + Label L_2TAG_PACKET_20_0_2, L_2TAG_PACKET_21_0_2, L_2TAG_PACKET_22_0_2, L_2TAG_PACKET_23_0_2; + Label L_2TAG_PACKET_24_0_2, L_2TAG_PACKET_25_0_2, L_2TAG_PACKET_26_0_2, L_2TAG_PACKET_27_0_2; + Label L_2TAG_PACKET_28_0_2, L_2TAG_PACKET_29_0_2, L_2TAG_PACKET_30_0_2, L_2TAG_PACKET_31_0_2; + Label L_2TAG_PACKET_32_0_2, L_2TAG_PACKET_33_0_2, L_2TAG_PACKET_34_0_2, L_2TAG_PACKET_35_0_2; + Label L_2TAG_PACKET_36_0_2, L_2TAG_PACKET_37_0_2, L_2TAG_PACKET_38_0_2, L_2TAG_PACKET_39_0_2; + Label L_2TAG_PACKET_40_0_2, L_2TAG_PACKET_41_0_2, L_2TAG_PACKET_42_0_2, L_2TAG_PACKET_43_0_2; + Label L_2TAG_PACKET_44_0_2, L_2TAG_PACKET_45_0_2, L_2TAG_PACKET_46_0_2, L_2TAG_PACKET_47_0_2; + Label L_2TAG_PACKET_48_0_2, L_2TAG_PACKET_49_0_2, L_2TAG_PACKET_50_0_2, L_2TAG_PACKET_51_0_2; + Label L_2TAG_PACKET_52_0_2, L_2TAG_PACKET_53_0_2, L_2TAG_PACKET_54_0_2, L_2TAG_PACKET_55_0_2; + Label L_2TAG_PACKET_56_0_2, L_2TAG_PACKET_57_0_2, L_2TAG_PACKET_58_0_2, start; + + assert_different_registers(tmp, eax, ecx, edx); + + address static_const_table_pow = (address)_static_const_table_pow; + + bind(start); + subl(rsp, 120); + movl(Address(rsp, 64), tmp); + lea(tmp, ExternalAddress(static_const_table_pow)); + movsd(xmm0, Address(rsp, 128)); + movsd(xmm1, Address(rsp, 136)); + xorpd(xmm2, xmm2); + movl(eax, 16368); + pinsrw(xmm2, eax, 3); + movl(ecx, 1069088768); + movdl(xmm7, ecx); + movsd(Address(rsp, 16), xmm1); + xorpd(xmm1, xmm1); + movl(edx, 30704); + pinsrw(xmm1, edx, 3); + movsd(Address(rsp, 8), xmm0); + movdqu(xmm3, xmm0); + movl(edx, 8192); + movdl(xmm4, edx); + movdqu(xmm6, Address(tmp, 8240)); + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + psllq(xmm0, 5); + movsd(xmm2, Address(tmp, 8256)); + psrlq(xmm0, 34); + movl(edx, eax); + andl(edx, 32752); + subl(edx, 16368); + movl(ecx, edx); + sarl(edx, 31); + addl(ecx, edx); + xorl(ecx, edx); + rcpss(xmm0, xmm0); + psllq(xmm3, 12); + addl(ecx, 16); + bsrl(ecx, ecx); + psrlq(xmm3, 12); + movl(Address(rsp, 24), rsi); + subl(eax, 16); + cmpl(eax, 32736); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_0_0_2); + movl(rsi, 0); + + bind(L_2TAG_PACKET_1_0_2); + mulss(xmm0, xmm7); + movl(edx, -1); + subl(ecx, 4); + shll(edx); + movdl(xmm5, edx); + por(xmm3, xmm1); + subl(eax, 16351); + cmpl(eax, 1); + jcc(Assembler::belowEqual, L_2TAG_PACKET_2_0_2); + paddd(xmm0, xmm4); + psllq(xmm5, 32); + movdl(edx, xmm0); + psllq(xmm0, 29); + pand(xmm5, xmm3); + + bind(L_2TAG_PACKET_3_0_2); + pand(xmm0, xmm6); + subsd(xmm3, xmm5); + subl(eax, 1); + sarl(eax, 4); + cvtsi2sdl(xmm7, eax); + mulpd(xmm5, xmm0); + + bind(L_2TAG_PACKET_4_0_2); + mulsd(xmm3, xmm0); + movdqu(xmm1, Address(tmp, 8272)); + subsd(xmm5, xmm2); + movdqu(xmm4, Address(tmp, 8288)); + movl(ecx, eax); + sarl(eax, 31); + addl(ecx, eax); + xorl(eax, ecx); + addl(eax, 1); + bsrl(eax, eax); + unpcklpd(xmm5, xmm3); + movdqu(xmm6, Address(tmp, 8304)); + addsd(xmm3, xmm5); + andl(edx, 16760832); + shrl(edx, 10); + addpd(xmm5, Address(tmp, edx, Address::times_1, -3616)); + movdqu(xmm0, Address(tmp, 8320)); + pshufd(xmm2, xmm3, 68); + mulsd(xmm3, xmm3); + mulpd(xmm1, xmm2); + mulpd(xmm4, xmm2); + addsd(xmm5, xmm7); + mulsd(xmm2, xmm3); + addpd(xmm6, xmm1); + mulsd(xmm3, xmm3); + addpd(xmm0, xmm4); + movsd(xmm1, Address(rsp, 16)); + movzwl(ecx, Address(rsp, 22)); + pshufd(xmm7, xmm5, 238); + movsd(xmm4, Address(tmp, 8368)); + mulpd(xmm6, xmm2); + pshufd(xmm3, xmm3, 68); + mulpd(xmm0, xmm2); + shll(eax, 4); + subl(eax, 15872); + andl(ecx, 32752); + addl(eax, ecx); + mulpd(xmm3, xmm6); + cmpl(eax, 624); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_5_0_2); + xorpd(xmm6, xmm6); + movl(edx, 17080); + pinsrw(xmm6, edx, 3); + movdqu(xmm2, xmm1); + pand(xmm4, xmm1); + subsd(xmm1, xmm4); + mulsd(xmm4, xmm5); + addsd(xmm0, xmm7); + mulsd(xmm1, xmm5); + movdqu(xmm7, xmm6); + addsd(xmm6, xmm4); + addpd(xmm3, xmm0); + movdl(edx, xmm6); + subsd(xmm6, xmm7); + pshufd(xmm0, xmm3, 238); + subsd(xmm4, xmm6); + addsd(xmm0, xmm3); + movl(ecx, edx); + andl(edx, 255); + addl(edx, edx); + movdqu(xmm5, Address(tmp, edx, Address::times_8, 8384)); + addsd(xmm4, xmm1); + mulsd(xmm2, xmm0); + movdqu(xmm7, Address(tmp, 12480)); + movdqu(xmm3, Address(tmp, 12496)); + shll(ecx, 12); + xorl(ecx, rsi); + andl(ecx, -1048576); + movdl(xmm6, ecx); + addsd(xmm2, xmm4); + movsd(xmm1, Address(tmp, 12512)); + pshufd(xmm0, xmm2, 68); + pshufd(xmm4, xmm2, 68); + mulpd(xmm0, xmm0); + movl(rsi, Address(rsp, 24)); + mulpd(xmm7, xmm4); + pshufd(xmm6, xmm6, 17); + mulsd(xmm1, xmm2); + mulsd(xmm0, xmm0); + paddd(xmm5, xmm6); + addpd(xmm3, xmm7); + mulsd(xmm1, xmm5); + pshufd(xmm6, xmm5, 238); + mulpd(xmm0, xmm3); + addsd(xmm1, xmm6); + pshufd(xmm3, xmm0, 238); + mulsd(xmm0, xmm5); + mulsd(xmm3, xmm5); + addsd(xmm0, xmm1); + addsd(xmm0, xmm3); + addsd(xmm0, xmm5); + movsd(Address(rsp, 0), xmm0); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_6_0_2); + + bind(L_2TAG_PACKET_7_0_2); + movsd(xmm0, Address(rsp, 128)); + movsd(xmm1, Address(rsp, 136)); + mulsd(xmm0, xmm1); + movsd(Address(rsp, 0), xmm0); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_6_0_2); + + bind(L_2TAG_PACKET_0_0_2); + addl(eax, 16); + movl(edx, 32752); + andl(edx, eax); + cmpl(edx, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_8_0_2); + testl(eax, 32768); + jcc(Assembler::notEqual, L_2TAG_PACKET_9_0_2); + + bind(L_2TAG_PACKET_10_0_2); + movl(ecx, Address(rsp, 16)); + xorl(edx, edx); + testl(ecx, ecx); + movl(ecx, 1); + cmovl(Assembler::notEqual, edx, ecx); + orl(edx, Address(rsp, 20)); + cmpl(edx, 1072693248); + jcc(Assembler::equal, L_2TAG_PACKET_7_0_2); + movsd(xmm0, Address(rsp, 8)); + movsd(xmm3, Address(rsp, 8)); + movdl(edx, xmm3); + psrlq(xmm3, 32); + movdl(ecx, xmm3); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_11_0_2); + xorpd(xmm3, xmm3); + movl(eax, 18416); + pinsrw(xmm3, eax, 3); + mulsd(xmm0, xmm3); + xorpd(xmm2, xmm2); + movl(eax, 16368); + pinsrw(xmm2, eax, 3); + movdqu(xmm3, xmm0); + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + movl(ecx, 18416); + psllq(xmm0, 5); + movsd(xmm2, Address(tmp, 8256)); + psrlq(xmm0, 34); + rcpss(xmm0, xmm0); + psllq(xmm3, 12); + movdqu(xmm6, Address(tmp, 8240)); + psrlq(xmm3, 12); + mulss(xmm0, xmm7); + movl(edx, -1024); + movdl(xmm5, edx); + por(xmm3, xmm1); + paddd(xmm0, xmm4); + psllq(xmm5, 32); + movdl(edx, xmm0); + psllq(xmm0, 29); + pand(xmm5, xmm3); + movl(rsi, 0); + pand(xmm0, xmm6); + subsd(xmm3, xmm5); + andl(eax, 32752); + subl(eax, 18416); + sarl(eax, 4); + cvtsi2sdl(xmm7, eax); + mulpd(xmm5, xmm0); + jmp(L_2TAG_PACKET_4_0_2); + + bind(L_2TAG_PACKET_12_0_2); + movl(ecx, Address(rsp, 16)); + xorl(edx, edx); + testl(ecx, ecx); + movl(ecx, 1); + cmovl(Assembler::notEqual, edx, ecx); + orl(edx, Address(rsp, 20)); + cmpl(edx, 1072693248); + jcc(Assembler::equal, L_2TAG_PACKET_7_0_2); + movsd(xmm0, Address(rsp, 8)); + movsd(xmm3, Address(rsp, 8)); + movdl(edx, xmm3); + psrlq(xmm3, 32); + movdl(ecx, xmm3); + orl(edx, ecx); + cmpl(edx, 0); + jcc(Assembler::equal, L_2TAG_PACKET_11_0_2); + xorpd(xmm3, xmm3); + movl(eax, 18416); + pinsrw(xmm3, eax, 3); + mulsd(xmm0, xmm3); + xorpd(xmm2, xmm2); + movl(eax, 16368); + pinsrw(xmm2, eax, 3); + movdqu(xmm3, xmm0); + pextrw(eax, xmm0, 3); + por(xmm0, xmm2); + movl(ecx, 18416); + psllq(xmm0, 5); + movsd(xmm2, Address(tmp, 8256)); + psrlq(xmm0, 34); + rcpss(xmm0, xmm0); + psllq(xmm3, 12); + movdqu(xmm6, Address(tmp, 8240)); + psrlq(xmm3, 12); + mulss(xmm0, xmm7); + movl(edx, -1024); + movdl(xmm5, edx); + por(xmm3, xmm1); + paddd(xmm0, xmm4); + psllq(xmm5, 32); + movdl(edx, xmm0); + psllq(xmm0, 29); + pand(xmm5, xmm3); + movl(rsi, INT_MIN); + pand(xmm0, xmm6); + subsd(xmm3, xmm5); + andl(eax, 32752); + subl(eax, 18416); + sarl(eax, 4); + cvtsi2sdl(xmm7, eax); + mulpd(xmm5, xmm0); + jmp(L_2TAG_PACKET_4_0_2); + + bind(L_2TAG_PACKET_5_0_2); + cmpl(eax, 0); + jcc(Assembler::less, L_2TAG_PACKET_13_0_2); + cmpl(eax, 752); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_14_0_2); + + bind(L_2TAG_PACKET_15_0_2); + addsd(xmm0, xmm7); + movsd(xmm2, Address(tmp, 12544)); + addpd(xmm3, xmm0); + xorpd(xmm6, xmm6); + movl(eax, 17080); + pinsrw(xmm6, eax, 3); + pshufd(xmm0, xmm3, 238); + addsd(xmm0, xmm3); + movdqu(xmm3, xmm5); + addsd(xmm5, xmm0); + movdqu(xmm4, xmm2); + subsd(xmm3, xmm5); + movdqu(xmm7, xmm5); + pand(xmm5, xmm2); + movdqu(xmm2, xmm1); + pand(xmm4, xmm1); + subsd(xmm7, xmm5); + addsd(xmm0, xmm3); + subsd(xmm1, xmm4); + mulsd(xmm4, xmm5); + addsd(xmm0, xmm7); + mulsd(xmm2, xmm0); + movdqu(xmm7, xmm6); + mulsd(xmm1, xmm5); + addsd(xmm6, xmm4); + movdl(eax, xmm6); + subsd(xmm6, xmm7); + addsd(xmm2, xmm1); + movdqu(xmm7, Address(tmp, 12480)); + movdqu(xmm3, Address(tmp, 12496)); + subsd(xmm4, xmm6); + pextrw(edx, xmm6, 3); + movl(ecx, eax); + andl(eax, 255); + addl(eax, eax); + movdqu(xmm5, Address(tmp, eax, Address::times_8, 8384)); + addsd(xmm2, xmm4); + sarl(ecx, 8); + movl(eax, ecx); + sarl(ecx, 1); + subl(eax, ecx); + shll(ecx, 20); + xorl(ecx, rsi); + movdl(xmm6, ecx); + movsd(xmm1, Address(tmp, 12512)); + andl(edx, 32767); + cmpl(edx, 16529); + jcc(Assembler::above, L_2TAG_PACKET_14_0_2); + pshufd(xmm0, xmm2, 68); + pshufd(xmm4, xmm2, 68); + mulpd(xmm0, xmm0); + mulpd(xmm7, xmm4); + pshufd(xmm6, xmm6, 17); + mulsd(xmm1, xmm2); + mulsd(xmm0, xmm0); + paddd(xmm5, xmm6); + addpd(xmm3, xmm7); + mulsd(xmm1, xmm5); + pshufd(xmm6, xmm5, 238); + mulpd(xmm0, xmm3); + addsd(xmm1, xmm6); + pshufd(xmm3, xmm0, 238); + mulsd(xmm0, xmm5); + mulsd(xmm3, xmm5); + shll(eax, 4); + xorpd(xmm4, xmm4); + addl(eax, 16368); + pinsrw(xmm4, eax, 3); + addsd(xmm0, xmm1); + movl(rsi, Address(rsp, 24)); + addsd(xmm0, xmm3); + movdqu(xmm1, xmm0); + addsd(xmm0, xmm5); + mulsd(xmm0, xmm4); + pextrw(eax, xmm0, 3); + andl(eax, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_16_0_2); + cmpl(eax, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_17_0_2); + + bind(L_2TAG_PACKET_18_0_2); + movsd(Address(rsp, 0), xmm0); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_6_0_2); + + bind(L_2TAG_PACKET_8_0_2); + movsd(xmm1, Address(rsp, 16)); + movsd(xmm0, Address(rsp, 8)); + movdqu(xmm2, xmm0); + movdl(eax, xmm2); + psrlq(xmm2, 20); + movdl(edx, xmm2); + orl(eax, edx); + jcc(Assembler::equal, L_2TAG_PACKET_19_0_2); + addsd(xmm0, xmm0); + movdl(eax, xmm1); + psrlq(xmm1, 32); + movdl(edx, xmm1); + movl(ecx, edx); + addl(edx, edx); + orl(eax, edx); + jcc(Assembler::equal, L_2TAG_PACKET_20_0_2); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_20_0_2); + xorpd(xmm0, xmm0); + movl(eax, 16368); + pinsrw(xmm0, eax, 3); + movl(edx, 29); + jmp(L_2TAG_PACKET_21_0_2); + + bind(L_2TAG_PACKET_22_0_2); + movsd(xmm0, Address(rsp, 16)); + addpd(xmm0, xmm0); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_19_0_2); + movdl(eax, xmm1); + movdqu(xmm2, xmm1); + psrlq(xmm1, 32); + movdl(edx, xmm1); + movl(ecx, edx); + addl(edx, edx); + orl(eax, edx); + jcc(Assembler::equal, L_2TAG_PACKET_23_0_2); + pextrw(eax, xmm2, 3); + andl(eax, 32752); + cmpl(eax, 32752); + jcc(Assembler::notEqual, L_2TAG_PACKET_24_0_2); + movdl(eax, xmm2); + psrlq(xmm2, 20); + movdl(edx, xmm2); + orl(eax, edx); + jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2); + + bind(L_2TAG_PACKET_24_0_2); + pextrw(eax, xmm0, 3); + testl(eax, 32768); + jcc(Assembler::notEqual, L_2TAG_PACKET_25_0_2); + testl(ecx, INT_MIN); + jcc(Assembler::notEqual, L_2TAG_PACKET_26_0_2); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_27_0_2); + movsd(xmm1, Address(rsp, 16)); + movdl(eax, xmm1); + testl(eax, 1); + jcc(Assembler::notEqual, L_2TAG_PACKET_28_0_2); + testl(eax, 2); + jcc(Assembler::notEqual, L_2TAG_PACKET_29_0_2); + jmp(L_2TAG_PACKET_28_0_2); + + bind(L_2TAG_PACKET_25_0_2); + shrl(ecx, 20); + andl(ecx, 2047); + cmpl(ecx, 1075); + jcc(Assembler::above, L_2TAG_PACKET_28_0_2); + jcc(Assembler::equal, L_2TAG_PACKET_30_0_2); + cmpl(ecx, 1074); + jcc(Assembler::above, L_2TAG_PACKET_27_0_2); + cmpl(ecx, 1023); + jcc(Assembler::below, L_2TAG_PACKET_28_0_2); + movsd(xmm1, Address(rsp, 16)); + movl(eax, 17208); + xorpd(xmm3, xmm3); + pinsrw(xmm3, eax, 3); + movdqu(xmm4, xmm3); + addsd(xmm3, xmm1); + subsd(xmm4, xmm3); + addsd(xmm1, xmm4); + pextrw(eax, xmm1, 3); + andl(eax, 32752); + jcc(Assembler::notEqual, L_2TAG_PACKET_28_0_2); + movdl(eax, xmm3); + andl(eax, 1); + jcc(Assembler::equal, L_2TAG_PACKET_28_0_2); + + bind(L_2TAG_PACKET_29_0_2); + movsd(xmm1, Address(rsp, 16)); + pextrw(eax, xmm1, 3); + andl(eax, 32768); + jcc(Assembler::equal, L_2TAG_PACKET_18_0_2); + xorpd(xmm0, xmm0); + movl(eax, 32768); + pinsrw(xmm0, eax, 3); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_28_0_2); + movsd(xmm1, Address(rsp, 16)); + pextrw(eax, xmm1, 3); + andl(eax, 32768); + jcc(Assembler::notEqual, L_2TAG_PACKET_26_0_2); + + bind(L_2TAG_PACKET_31_0_2); + xorpd(xmm0, xmm0); + movl(eax, 32752); + pinsrw(xmm0, eax, 3); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_30_0_2); + movsd(xmm1, Address(rsp, 16)); + movdl(eax, xmm1); + andl(eax, 1); + jcc(Assembler::equal, L_2TAG_PACKET_28_0_2); + jmp(L_2TAG_PACKET_29_0_2); + + bind(L_2TAG_PACKET_32_0_2); + movdl(eax, xmm1); + psrlq(xmm1, 20); + movdl(edx, xmm1); + orl(eax, edx); + jcc(Assembler::equal, L_2TAG_PACKET_33_0_2); + movsd(xmm0, Address(rsp, 16)); + addsd(xmm0, xmm0); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_33_0_2); + movsd(xmm0, Address(rsp, 8)); + pextrw(eax, xmm0, 3); + cmpl(eax, 49136); + jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2); + movdl(ecx, xmm0); + psrlq(xmm0, 20); + movdl(edx, xmm0); + orl(ecx, edx); + jcc(Assembler::notEqual, L_2TAG_PACKET_34_0_2); + xorpd(xmm0, xmm0); + movl(eax, 32760); + pinsrw(xmm0, eax, 3); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_34_0_2); + movsd(xmm1, Address(rsp, 16)); + andl(eax, 32752); + subl(eax, 16368); + pextrw(edx, xmm1, 3); + xorpd(xmm0, xmm0); + xorl(eax, edx); + andl(eax, 32768); + jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2); + movl(ecx, 32752); + pinsrw(xmm0, ecx, 3); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_35_0_2); + movdl(eax, xmm1); + cmpl(edx, 17184); + jcc(Assembler::above, L_2TAG_PACKET_36_0_2); + testl(eax, 1); + jcc(Assembler::notEqual, L_2TAG_PACKET_37_0_2); + testl(eax, 2); + jcc(Assembler::equal, L_2TAG_PACKET_38_0_2); + jmp(L_2TAG_PACKET_39_0_2); + + bind(L_2TAG_PACKET_36_0_2); + testl(eax, 1); + jcc(Assembler::equal, L_2TAG_PACKET_38_0_2); + jmp(L_2TAG_PACKET_39_0_2); + + bind(L_2TAG_PACKET_9_0_2); + movsd(xmm2, Address(rsp, 8)); + movdl(eax, xmm2); + psrlq(xmm2, 31); + movdl(ecx, xmm2); + orl(eax, ecx); + jcc(Assembler::equal, L_2TAG_PACKET_11_0_2); + movsd(xmm1, Address(rsp, 16)); + pextrw(edx, xmm1, 3); + movdl(eax, xmm1); + movdqu(xmm2, xmm1); + psrlq(xmm2, 32); + movdl(ecx, xmm2); + addl(ecx, ecx); + orl(ecx, eax); + jcc(Assembler::equal, L_2TAG_PACKET_40_0_2); + andl(edx, 32752); + cmpl(edx, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_32_0_2); + cmpl(edx, 17200); + jcc(Assembler::above, L_2TAG_PACKET_38_0_2); + cmpl(edx, 17184); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_35_0_2); + cmpl(edx, 16368); + jcc(Assembler::below, L_2TAG_PACKET_37_0_2); + movl(eax, 17208); + xorpd(xmm2, xmm2); + pinsrw(xmm2, eax, 3); + movdqu(xmm4, xmm2); + addsd(xmm2, xmm1); + subsd(xmm4, xmm2); + addsd(xmm1, xmm4); + pextrw(eax, xmm1, 3); + andl(eax, 32767); + jcc(Assembler::notEqual, L_2TAG_PACKET_37_0_2); + movdl(eax, xmm2); + andl(eax, 1); + jcc(Assembler::equal, L_2TAG_PACKET_38_0_2); + + bind(L_2TAG_PACKET_39_0_2); + xorpd(xmm1, xmm1); + movl(edx, 30704); + pinsrw(xmm1, edx, 3); + movsd(xmm2, Address(tmp, 8256)); + movsd(xmm4, Address(rsp, 8)); + pextrw(eax, xmm4, 3); + movl(edx, 8192); + movdl(xmm4, edx); + andl(eax, 32767); + subl(eax, 16); + jcc(Assembler::less, L_2TAG_PACKET_12_0_2); + movl(edx, eax); + andl(edx, 32752); + subl(edx, 16368); + movl(ecx, edx); + sarl(edx, 31); + addl(ecx, edx); + xorl(ecx, edx); + addl(ecx, 16); + bsrl(ecx, ecx); + movl(rsi, INT_MIN); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_37_0_2); + xorpd(xmm1, xmm1); + movl(eax, 32752); + pinsrw(xmm1, eax, 3); + xorpd(xmm0, xmm0); + mulsd(xmm0, xmm1); + movl(edx, 28); + jmp(L_2TAG_PACKET_21_0_2); + + bind(L_2TAG_PACKET_38_0_2); + xorpd(xmm1, xmm1); + movl(edx, 30704); + pinsrw(xmm1, edx, 3); + movsd(xmm2, Address(tmp, 8256)); + movsd(xmm4, Address(rsp, 8)); + pextrw(eax, xmm4, 3); + movl(edx, 8192); + movdl(xmm4, edx); + andl(eax, 32767); + subl(eax, 16); + jcc(Assembler::less, L_2TAG_PACKET_10_0_2); + movl(edx, eax); + andl(edx, 32752); + subl(edx, 16368); + movl(ecx, edx); + sarl(edx, 31); + addl(ecx, edx); + xorl(ecx, edx); + addl(ecx, 16); + bsrl(ecx, ecx); + movl(rsi, 0); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_23_0_2); + xorpd(xmm0, xmm0); + movl(eax, 16368); + pinsrw(xmm0, eax, 3); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_26_0_2); + xorpd(xmm0, xmm0); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_13_0_2); + addl(eax, 384); + cmpl(eax, 0); + jcc(Assembler::less, L_2TAG_PACKET_41_0_2); + mulsd(xmm5, xmm1); + addsd(xmm0, xmm7); + shrl(rsi, 31); + addpd(xmm3, xmm0); + pshufd(xmm0, xmm3, 238); + addsd(xmm3, xmm0); + movsd(xmm4, Address(tmp, rsi, Address::times_8, 12528)); + mulsd(xmm1, xmm3); + xorpd(xmm0, xmm0); + movl(eax, 16368); + shll(rsi, 15); + orl(eax, rsi); + pinsrw(xmm0, eax, 3); + addsd(xmm5, xmm1); + movl(rsi, Address(rsp, 24)); + mulsd(xmm5, xmm4); + addsd(xmm0, xmm5); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_41_0_2); + movl(rsi, Address(rsp, 24)); + xorpd(xmm0, xmm0); + movl(eax, 16368); + pinsrw(xmm0, eax, 3); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_40_0_2); + xorpd(xmm0, xmm0); + movl(eax, 16368); + pinsrw(xmm0, eax, 3); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_42_0_2); + xorpd(xmm0, xmm0); + movl(eax, 16368); + pinsrw(xmm0, eax, 3); + movl(edx, 26); + jmp(L_2TAG_PACKET_21_0_2); + + bind(L_2TAG_PACKET_11_0_2); + movsd(xmm1, Address(rsp, 16)); + movdqu(xmm2, xmm1); + pextrw(eax, xmm1, 3); + andl(eax, 32752); + cmpl(eax, 32752); + jcc(Assembler::notEqual, L_2TAG_PACKET_43_0_2); + movdl(eax, xmm2); + psrlq(xmm2, 20); + movdl(edx, xmm2); + orl(eax, edx); + jcc(Assembler::notEqual, L_2TAG_PACKET_22_0_2); + + bind(L_2TAG_PACKET_43_0_2); + movdl(eax, xmm1); + psrlq(xmm1, 32); + movdl(edx, xmm1); + movl(ecx, edx); + addl(edx, edx); + orl(eax, edx); + jcc(Assembler::equal, L_2TAG_PACKET_42_0_2); + shrl(edx, 21); + cmpl(edx, 1075); + jcc(Assembler::above, L_2TAG_PACKET_44_0_2); + jcc(Assembler::equal, L_2TAG_PACKET_45_0_2); + cmpl(edx, 1023); + jcc(Assembler::below, L_2TAG_PACKET_44_0_2); + movsd(xmm1, Address(rsp, 16)); + movl(eax, 17208); + xorpd(xmm3, xmm3); + pinsrw(xmm3, eax, 3); + movdqu(xmm4, xmm3); + addsd(xmm3, xmm1); + subsd(xmm4, xmm3); + addsd(xmm1, xmm4); + pextrw(eax, xmm1, 3); + andl(eax, 32752); + jcc(Assembler::notEqual, L_2TAG_PACKET_44_0_2); + movdl(eax, xmm3); + andl(eax, 1); + jcc(Assembler::equal, L_2TAG_PACKET_44_0_2); + + bind(L_2TAG_PACKET_46_0_2); + movsd(xmm0, Address(rsp, 8)); + testl(ecx, INT_MIN); + jcc(Assembler::notEqual, L_2TAG_PACKET_47_0_2); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_45_0_2); + movsd(xmm1, Address(rsp, 16)); + movdl(eax, xmm1); + testl(eax, 1); + jcc(Assembler::notEqual, L_2TAG_PACKET_46_0_2); + + bind(L_2TAG_PACKET_44_0_2); + testl(ecx, INT_MIN); + jcc(Assembler::equal, L_2TAG_PACKET_26_0_2); + xorpd(xmm0, xmm0); + + bind(L_2TAG_PACKET_47_0_2); + movl(eax, 16368); + xorpd(xmm1, xmm1); + pinsrw(xmm1, eax, 3); + divsd(xmm1, xmm0); + movdqu(xmm0, xmm1); + movl(edx, 27); + jmp(L_2TAG_PACKET_21_0_2); + + bind(L_2TAG_PACKET_14_0_2); + movsd(xmm2, Address(rsp, 8)); + movsd(xmm6, Address(rsp, 16)); + pextrw(eax, xmm2, 3); + pextrw(edx, xmm6, 3); + movl(ecx, 32752); + andl(ecx, edx); + cmpl(ecx, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_48_0_2); + andl(eax, 32752); + subl(eax, 16368); + xorl(edx, eax); + testl(edx, 32768); + jcc(Assembler::notEqual, L_2TAG_PACKET_49_0_2); + + bind(L_2TAG_PACKET_50_0_2); + movl(eax, 32736); + pinsrw(xmm0, eax, 3); + shrl(rsi, 16); + orl(eax, rsi); + pinsrw(xmm1, eax, 3); + movl(rsi, Address(rsp, 24)); + mulsd(xmm0, xmm1); + + bind(L_2TAG_PACKET_17_0_2); + movl(edx, 24); + + bind(L_2TAG_PACKET_21_0_2); + movsd(Address(rsp, 0), xmm0); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_6_0_2); + + bind(L_2TAG_PACKET_49_0_2); + movl(eax, 16); + pinsrw(xmm0, eax, 3); + mulsd(xmm0, xmm0); + testl(rsi, INT_MIN); + jcc(Assembler::equal, L_2TAG_PACKET_51_0_2); + movsd(xmm2, Address(tmp, 12560)); + xorpd(xmm0, xmm2); + + bind(L_2TAG_PACKET_51_0_2); + movl(rsi, Address(rsp, 24)); + movl(edx, 25); + jmp(L_2TAG_PACKET_21_0_2); + + bind(L_2TAG_PACKET_16_0_2); + pextrw(ecx, xmm5, 3); + pextrw(edx, xmm4, 3); + movl(eax, -1); + andl(ecx, 32752); + subl(ecx, 16368); + andl(edx, 32752); + addl(edx, ecx); + movl(ecx, -31); + sarl(edx, 4); + subl(ecx, edx); + jcc(Assembler::lessEqual, L_2TAG_PACKET_52_0_2); + cmpl(ecx, 20); + jcc(Assembler::above, L_2TAG_PACKET_53_0_2); + shll(eax); + + bind(L_2TAG_PACKET_52_0_2); + movdl(xmm0, eax); + psllq(xmm0, 32); + pand(xmm0, xmm5); + subsd(xmm5, xmm0); + addsd(xmm5, xmm1); + mulsd(xmm0, xmm4); + mulsd(xmm5, xmm4); + addsd(xmm0, xmm5); + + bind(L_2TAG_PACKET_53_0_2); + movl(edx, 25); + jmp(L_2TAG_PACKET_21_0_2); + + bind(L_2TAG_PACKET_2_0_2); + movzwl(ecx, Address(rsp, 22)); + movl(edx, INT_MIN); + movdl(xmm1, edx); + xorpd(xmm7, xmm7); + paddd(xmm0, xmm4); + psllq(xmm5, 32); + movdl(edx, xmm0); + psllq(xmm0, 29); + paddq(xmm1, xmm3); + pand(xmm5, xmm1); + andl(ecx, 32752); + cmpl(ecx, 16560); + jcc(Assembler::below, L_2TAG_PACKET_3_0_2); + pand(xmm0, xmm6); + subsd(xmm3, xmm5); + addl(eax, 16351); + shrl(eax, 4); + subl(eax, 1022); + cvtsi2sdl(xmm7, eax); + mulpd(xmm5, xmm0); + movsd(xmm4, Address(tmp, 0)); + mulsd(xmm3, xmm0); + movsd(xmm6, Address(tmp, 0)); + subsd(xmm5, xmm2); + movsd(xmm1, Address(tmp, 8)); + pshufd(xmm2, xmm3, 68); + unpcklpd(xmm5, xmm3); + addsd(xmm3, xmm5); + movsd(xmm0, Address(tmp, 8)); + andl(edx, 16760832); + shrl(edx, 10); + addpd(xmm7, Address(tmp, edx, Address::times_1, -3616)); + mulsd(xmm4, xmm5); + mulsd(xmm0, xmm5); + mulsd(xmm6, xmm2); + mulsd(xmm1, xmm2); + movdqu(xmm2, xmm5); + mulsd(xmm4, xmm5); + addsd(xmm5, xmm0); + movdqu(xmm0, xmm7); + addsd(xmm2, xmm3); + addsd(xmm7, xmm5); + mulsd(xmm6, xmm2); + subsd(xmm0, xmm7); + movdqu(xmm2, xmm7); + addsd(xmm7, xmm4); + addsd(xmm0, xmm5); + subsd(xmm2, xmm7); + addsd(xmm4, xmm2); + pshufd(xmm2, xmm5, 238); + movdqu(xmm5, xmm7); + addsd(xmm7, xmm2); + addsd(xmm4, xmm0); + movdqu(xmm0, Address(tmp, 8272)); + subsd(xmm5, xmm7); + addsd(xmm6, xmm4); + movdqu(xmm4, xmm7); + addsd(xmm5, xmm2); + addsd(xmm7, xmm1); + movdqu(xmm2, Address(tmp, 8336)); + subsd(xmm4, xmm7); + addsd(xmm6, xmm5); + addsd(xmm4, xmm1); + pshufd(xmm5, xmm7, 238); + movdqu(xmm1, xmm7); + addsd(xmm7, xmm5); + subsd(xmm1, xmm7); + addsd(xmm1, xmm5); + movdqu(xmm5, Address(tmp, 8352)); + pshufd(xmm3, xmm3, 68); + addsd(xmm6, xmm4); + addsd(xmm6, xmm1); + movdqu(xmm1, Address(tmp, 8304)); + mulpd(xmm0, xmm3); + mulpd(xmm2, xmm3); + pshufd(xmm4, xmm3, 68); + mulpd(xmm3, xmm3); + addpd(xmm0, xmm1); + addpd(xmm5, xmm2); + mulsd(xmm4, xmm3); + movsd(xmm2, Address(tmp, 16)); + mulpd(xmm3, xmm3); + movsd(xmm1, Address(rsp, 16)); + movzwl(ecx, Address(rsp, 22)); + mulpd(xmm0, xmm4); + pextrw(eax, xmm7, 3); + mulpd(xmm5, xmm4); + mulpd(xmm0, xmm3); + movsd(xmm4, Address(tmp, 8376)); + pand(xmm2, xmm7); + addsd(xmm5, xmm6); + subsd(xmm7, xmm2); + addpd(xmm5, xmm0); + andl(eax, 32752); + subl(eax, 16368); + andl(ecx, 32752); + cmpl(ecx, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_48_0_2); + addl(ecx, eax); + cmpl(ecx, 16576); + jcc(Assembler::aboveEqual, L_2TAG_PACKET_54_0_2); + pshufd(xmm0, xmm5, 238); + pand(xmm4, xmm1); + movdqu(xmm3, xmm1); + addsd(xmm5, xmm0); + subsd(xmm1, xmm4); + xorpd(xmm6, xmm6); + movl(edx, 17080); + pinsrw(xmm6, edx, 3); + addsd(xmm7, xmm5); + mulsd(xmm4, xmm2); + mulsd(xmm1, xmm2); + movdqu(xmm5, xmm6); + mulsd(xmm3, xmm7); + addsd(xmm6, xmm4); + addsd(xmm1, xmm3); + movdqu(xmm7, Address(tmp, 12480)); + movdl(edx, xmm6); + subsd(xmm6, xmm5); + movdqu(xmm3, Address(tmp, 12496)); + movsd(xmm2, Address(tmp, 12512)); + subsd(xmm4, xmm6); + movl(ecx, edx); + andl(edx, 255); + addl(edx, edx); + movdqu(xmm5, Address(tmp, edx, Address::times_8, 8384)); + addsd(xmm4, xmm1); + pextrw(edx, xmm6, 3); + shrl(ecx, 8); + movl(eax, ecx); + shrl(ecx, 1); + subl(eax, ecx); + shll(ecx, 20); + movdl(xmm6, ecx); + pshufd(xmm0, xmm4, 68); + pshufd(xmm1, xmm4, 68); + mulpd(xmm0, xmm0); + mulpd(xmm7, xmm1); + pshufd(xmm6, xmm6, 17); + mulsd(xmm2, xmm4); + andl(edx, 32767); + cmpl(edx, 16529); + jcc(Assembler::above, L_2TAG_PACKET_14_0_2); + mulsd(xmm0, xmm0); + paddd(xmm5, xmm6); + addpd(xmm3, xmm7); + mulsd(xmm2, xmm5); + pshufd(xmm6, xmm5, 238); + mulpd(xmm0, xmm3); + addsd(xmm2, xmm6); + pshufd(xmm3, xmm0, 238); + addl(eax, 1023); + shll(eax, 20); + orl(eax, rsi); + movdl(xmm4, eax); + mulsd(xmm0, xmm5); + mulsd(xmm3, xmm5); + addsd(xmm0, xmm2); + psllq(xmm4, 32); + addsd(xmm0, xmm3); + movdqu(xmm1, xmm0); + addsd(xmm0, xmm5); + movl(rsi, Address(rsp, 24)); + mulsd(xmm0, xmm4); + pextrw(eax, xmm0, 3); + andl(eax, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_16_0_2); + cmpl(eax, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_17_0_2); + + bind(L_2TAG_PACKET_55_0_2); + movsd(Address(rsp, 0), xmm0); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_6_0_2); + + bind(L_2TAG_PACKET_48_0_2); + movl(rsi, Address(rsp, 24)); + + bind(L_2TAG_PACKET_56_0_2); + movsd(xmm0, Address(rsp, 8)); + movsd(xmm1, Address(rsp, 16)); + addsd(xmm1, xmm1); + xorpd(xmm2, xmm2); + movl(eax, 49136); + pinsrw(xmm2, eax, 3); + addsd(xmm2, xmm0); + pextrw(eax, xmm2, 3); + cmpl(eax, 0); + jcc(Assembler::notEqual, L_2TAG_PACKET_57_0_2); + xorpd(xmm0, xmm0); + movl(eax, 32760); + pinsrw(xmm0, eax, 3); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_57_0_2); + movdl(edx, xmm1); + movdqu(xmm3, xmm1); + psrlq(xmm3, 20); + movdl(ecx, xmm3); + orl(ecx, edx); + jcc(Assembler::equal, L_2TAG_PACKET_58_0_2); + addsd(xmm1, xmm1); + movdqu(xmm0, xmm1); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_58_0_2); + pextrw(eax, xmm0, 3); + andl(eax, 32752); + pextrw(edx, xmm1, 3); + xorpd(xmm0, xmm0); + subl(eax, 16368); + xorl(eax, edx); + testl(eax, 32768); + jcc(Assembler::notEqual, L_2TAG_PACKET_18_0_2); + movl(edx, 32752); + pinsrw(xmm0, edx, 3); + jmp(L_2TAG_PACKET_18_0_2); + + bind(L_2TAG_PACKET_54_0_2); + pextrw(eax, xmm1, 3); + pextrw(ecx, xmm2, 3); + xorl(eax, ecx); + testl(eax, 32768); + jcc(Assembler::equal, L_2TAG_PACKET_50_0_2); + jmp(L_2TAG_PACKET_49_0_2); + + bind(L_2TAG_PACKET_6_0_2); + movl(tmp, Address(rsp, 64)); + +} +#endif diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_sin.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sin.cpp new file mode 100644 index 00000000000..97cfd27b936 --- /dev/null +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sin.cpp @@ -0,0 +1,2448 @@ +/* +* Copyright (c) 2016, Intel Corporation. +* Intel Math Library (LIBM) Source Code +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 only, as +* published by the Free Software Foundation. +* +* This code is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* version 2 for more details (a copy is included in the LICENSE file that +* accompanied this code). +* +* You should have received a copy of the GNU General Public License version +* 2 along with this work; if not, write to the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +* or visit www.oracle.com if you need additional information or have any +* questions. +* +*/ + +#include "precompiled.hpp" +#include "asm/assembler.hpp" +#include "asm/assembler.inline.hpp" +#include "runtime/stubRoutines.hpp" +#include "stubRoutines_x86.hpp" +#include "macroAssembler_x86.hpp" + +#ifdef _MSC_VER +#define ALIGNED_(x) __declspec(align(x)) +#else +#define ALIGNED_(x) __attribute__ ((aligned(x))) +#endif + +/******************************************************************************/ +// ALGORITHM DESCRIPTION - SIN() +// --------------------- +// +// 1. RANGE REDUCTION +// +// We perform an initial range reduction from X to r with +// +// X =~= N * pi/32 + r +// +// so that |r| <= pi/64 + epsilon. We restrict inputs to those +// where |N| <= 932560. Beyond this, the range reduction is +// insufficiently accurate. For extremely small inputs, +// denormalization can occur internally, impacting performance. +// This means that the main path is actually only taken for +// 2^-252 <= |X| < 90112. +// +// To avoid branches, we perform the range reduction to full +// accuracy each time. +// +// X - N * (P_1 + P_2 + P_3) +// +// where P_1 and P_2 are 32-bit numbers (so multiplication by N +// is exact) and P_3 is a 53-bit number. Together, these +// approximate pi well enough for all cases in the restricted +// range. +// +// The main reduction sequence is: +// +// y = 32/pi * x +// N = integer(y) +// (computed by adding and subtracting off SHIFTER) +// +// m_1 = N * P_1 +// m_2 = N * P_2 +// r_1 = x - m_1 +// r = r_1 - m_2 +// (this r can be used for most of the calculation) +// +// c_1 = r_1 - r +// m_3 = N * P_3 +// c_2 = c_1 - m_2 +// c = c_2 - m_3 +// +// 2. MAIN ALGORITHM +// +// The algorithm uses a table lookup based on B = M * pi / 32 +// where M = N mod 64. The stored values are: +// sigma closest power of 2 to cos(B) +// C_hl 53-bit cos(B) - sigma +// S_hi + S_lo 2 * 53-bit sin(B) +// +// The computation is organized as follows: +// +// sin(B + r + c) = [sin(B) + sigma * r] + +// r * (cos(B) - sigma) + +// sin(B) * [cos(r + c) - 1] + +// cos(B) * [sin(r + c) - r] +// +// which is approximately: +// +// [S_hi + sigma * r] + +// C_hl * r + +// S_lo + S_hi * [(cos(r) - 1) - r * c] + +// (C_hl + sigma) * [(sin(r) - r) + c] +// +// and this is what is actually computed. We separate this sum +// into four parts: +// +// hi + med + pols + corr +// +// where +// +// hi = S_hi + sigma r +// med = C_hl * r +// pols = S_hi * (cos(r) - 1) + (C_hl + sigma) * (sin(r) - r) +// corr = S_lo + c * ((C_hl + sigma) - S_hi * r) +// +// 3. POLYNOMIAL +// +// The polynomial S_hi * (cos(r) - 1) + (C_hl + sigma) * +// (sin(r) - r) can be rearranged freely, since it is quite +// small, so we exploit parallelism to the fullest. +// +// psc4 = SC_4 * r_1 +// msc4 = psc4 * r +// r2 = r * r +// msc2 = SC_2 * r2 +// r4 = r2 * r2 +// psc3 = SC_3 + msc4 +// psc1 = SC_1 + msc2 +// msc3 = r4 * psc3 +// sincospols = psc1 + msc3 +// pols = sincospols * +// +// +// 4. CORRECTION TERM +// +// This is where the "c" component of the range reduction is +// taken into account; recall that just "r" is used for most of +// the calculation. +// +// -c = m_3 - c_2 +// -d = S_hi * r - (C_hl + sigma) +// corr = -c * -d + S_lo +// +// 5. COMPENSATED SUMMATIONS +// +// The two successive compensated summations add up the high +// and medium parts, leaving just the low parts to add up at +// the end. +// +// rs = sigma * r +// res_int = S_hi + rs +// k_0 = S_hi - res_int +// k_2 = k_0 + rs +// med = C_hl * r +// res_hi = res_int + med +// k_1 = res_int - res_hi +// k_3 = k_1 + med +// +// 6. FINAL SUMMATION +// +// We now add up all the small parts: +// +// res_lo = pols(hi) + pols(lo) + corr + k_1 + k_3 +// +// Now the overall result is just: +// +// res_hi + res_lo +// +// 7. SMALL ARGUMENTS +// +// If |x| < SNN (SNN meaning the smallest normal number), we +// simply perform 0.1111111 cdots 1111 * x. For SNN <= |x|, we +// do 2^-55 * (2^55 * x - x). +// +// Special cases: +// sin(NaN) = quiet NaN, and raise invalid exception +// sin(INF) = NaN and raise invalid exception +// sin(+/-0) = +/-0 +// +/******************************************************************************/ + +#ifdef _LP64 +// The 64 bit code is at most SSE2 compliant +ALIGNED_(16) juint StubRoutines::x86::_ONEHALF[] = +{ + 0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL +}; + +ALIGNED_(16) juint StubRoutines::x86::_P_2[] = +{ + 0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL +}; + +ALIGNED_(16) juint StubRoutines::x86::_SC_4[] = +{ + 0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL +}; + +ALIGNED_(16) juint StubRoutines::x86::_Ctable[] = +{ + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, 0xbf73b92eUL, + 0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL, + 0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, + 0xc0000000UL, 0xbc626d19UL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, + 0xbfa60beaUL, 0x2ed59f06UL, 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, + 0x00000000UL, 0x3ff00000UL, 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, + 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, 0x00000000UL, 0x3ff00000UL, + 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, 0x20000000UL, + 0x3c5e0d89UL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, 0xbfc59267UL, + 0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL, + 0x3ff00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, + 0x20000000UL, 0x3c68076aUL, 0x00000000UL, 0x3ff00000UL, 0x99fcef32UL, + 0x3fca8279UL, 0x667f3bcdUL, 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, + 0x00000000UL, 0x3fe00000UL, 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, + 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, 0x00000000UL, 0x3fe00000UL, + 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, 0xe0000000UL, + 0x3c39f630UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, 0xbf9d4a2cUL, + 0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL, + 0x3fe00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0x3fed906bUL, + 0x20000000UL, 0x3c7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x76acf82dUL, + 0x3fa4a031UL, 0x56c62ddaUL, 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, + 0x00000000UL, 0x3fd00000UL, 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, + 0x3fef6297UL, 0x20000000UL, 0x3c756217UL, 0x00000000UL, 0x3fd00000UL, + 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, 0x40000000UL, + 0xbc887df6UL, 0x00000000UL, 0x3fc00000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, + 0x40000000UL, 0xbc887df6UL, 0x00000000UL, 0xbfc00000UL, 0x0e5967d5UL, + 0x3fac1d1fUL, 0xcff75cb0UL, 0x3fef6297UL, 0x20000000UL, 0x3c756217UL, + 0x00000000UL, 0xbfd00000UL, 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, + 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, 0x00000000UL, 0xbfd00000UL, + 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, 0x3fed906bUL, 0x20000000UL, + 0x3c7457e6UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, 0x3f9d4a2cUL, + 0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL, + 0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, + 0xe0000000UL, 0x3c39f630UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, + 0xbfc133ccUL, 0x6b151741UL, 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, + 0x00000000UL, 0xbfe00000UL, 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, + 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, 0x00000000UL, 0xbfe00000UL, + 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, 0x20000000UL, + 0x3c68076aUL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, 0x3fc59267UL, + 0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL, + 0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, + 0x20000000UL, 0x3c5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, + 0x3fb37ca1UL, 0xa6aea963UL, 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, + 0x00000000UL, 0xbff00000UL, 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, + 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, 0x00000000UL, 0xbff00000UL, + 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, 0xc0000000UL, + 0xbc626d19UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, 0x3f73b92eUL, + 0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL, + 0xbff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, + 0x3f73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL, + 0x00000000UL, 0xbff00000UL, 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, + 0xbfc8f8b8UL, 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0xbff00000UL, + 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, + 0x3c75d28dUL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, 0x3fb37ca1UL, + 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, 0x3c672cedUL, 0x00000000UL, + 0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0xbfde2b5dUL, + 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, + 0x3fc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL, + 0x00000000UL, 0xbff00000UL, 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, + 0xbfe44cf3UL, 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0xbff00000UL, + 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, + 0x3c8bdd34UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, 0xbfc133ccUL, + 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, 0x3c82c5e1UL, 0x00000000UL, + 0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0xbfea9b66UL, + 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, + 0x3f9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL, + 0x00000000UL, 0xbfe00000UL, 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, + 0xbfed906bUL, 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0xbfe00000UL, + 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, + 0xbc8760b1UL, 0x00000000UL, 0xbfd00000UL, 0x0e5967d5UL, 0x3fac1d1fUL, + 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, 0xbc756217UL, 0x00000000UL, + 0xbfd00000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0xbfefd88dUL, + 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0xbfc00000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, + 0xbfefd88dUL, 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0x3fc00000UL, + 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, + 0xbc756217UL, 0x00000000UL, 0x3fd00000UL, 0x76acf82dUL, 0x3fa4a031UL, + 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, 0xbc8760b1UL, 0x00000000UL, + 0x3fd00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0xbfed906bUL, + 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, + 0xbf9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL, + 0x00000000UL, 0x3fe00000UL, 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, + 0xbfea9b66UL, 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0x3fe00000UL, + 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, + 0x3c82c5e1UL, 0x00000000UL, 0x3fe00000UL, 0x99fcef32UL, 0x3fca8279UL, + 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, 0x3c8bdd34UL, 0x00000000UL, + 0x3fe00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0xbfe44cf3UL, + 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, + 0xbfc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL, + 0x00000000UL, 0x3ff00000UL, 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, + 0xbfde2b5dUL, 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0x3ff00000UL, + 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, + 0x3c672cedUL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, 0xbfa60beaUL, + 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, 0x3c75d28dUL, 0x00000000UL, + 0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0xbfc8f8b8UL, + 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, + 0xbf73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL, + 0x00000000UL, 0x3ff00000UL +}; + +ALIGNED_(16) juint StubRoutines::x86::_SC_2[] = +{ + 0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL +}; + +ALIGNED_(16) juint StubRoutines::x86::_SC_3[] = +{ + 0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL +}; + +ALIGNED_(16) juint StubRoutines::x86::_SC_1[] = +{ + 0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL +}; + +ALIGNED_(16) juint StubRoutines::x86::_PI_INV_TABLE[] = +{ + 0x00000000UL, 0x00000000UL, 0xa2f9836eUL, 0x4e441529UL, 0xfc2757d1UL, + 0xf534ddc0UL, 0xdb629599UL, 0x3c439041UL, 0xfe5163abUL, 0xdebbc561UL, + 0xb7246e3aUL, 0x424dd2e0UL, 0x06492eeaUL, 0x09d1921cUL, 0xfe1deb1cUL, + 0xb129a73eUL, 0xe88235f5UL, 0x2ebb4484UL, 0xe99c7026UL, 0xb45f7e41UL, + 0x3991d639UL, 0x835339f4UL, 0x9c845f8bUL, 0xbdf9283bUL, 0x1ff897ffUL, + 0xde05980fUL, 0xef2f118bUL, 0x5a0a6d1fUL, 0x6d367ecfUL, 0x27cb09b7UL, + 0x4f463f66UL, 0x9e5fea2dUL, 0x7527bac7UL, 0xebe5f17bUL, 0x3d0739f7UL, + 0x8a5292eaUL, 0x6bfb5fb1UL, 0x1f8d5d08UL, 0x56033046UL, 0xfc7b6babUL, + 0xf0cfbc21UL +}; + +ALIGNED_(8) juint StubRoutines::x86::_PI_4[] = +{ + 0x40000000UL, 0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL +}; + +ALIGNED_(8) juint StubRoutines::x86::_PI32INV[] = +{ + 0x6dc9c883UL, 0x40245f30UL +}; + +ALIGNED_(8) juint _SHIFTER[] = +{ + 0x00000000UL, 0x43380000UL +}; + +ALIGNED_(8) juint StubRoutines::x86::_SIGN_MASK[] = +{ + 0x00000000UL, 0x80000000UL +}; + +ALIGNED_(8) juint StubRoutines::x86::_P_3[] = +{ + 0x2e037073UL, 0x3b63198aUL +}; + +ALIGNED_(8) juint _ALL_ONES[] = +{ + 0xffffffffUL, 0x3fefffffUL +}; + +ALIGNED_(8) juint _TWO_POW_55[] = +{ + 0x00000000UL, 0x43600000UL +}; + +ALIGNED_(8) juint _TWO_POW_M55[] = +{ + 0x00000000UL, 0x3c800000UL +}; + +ALIGNED_(8) juint StubRoutines::x86::_P_1[] = +{ + 0x54400000UL, 0x3fb921fbUL +}; + +ALIGNED_(8) juint StubRoutines::x86::_NEG_ZERO[] = +{ + 0x00000000UL, 0x3c800000UL +}; + +void MacroAssembler::fast_sin(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ebx, Register ecx, Register edx, Register tmp1, Register tmp2, Register tmp3, Register tmp4) { + Label L_2TAG_PACKET_0_0_1, L_2TAG_PACKET_1_0_1, L_2TAG_PACKET_2_0_1, L_2TAG_PACKET_3_0_1; + Label L_2TAG_PACKET_4_0_1, L_2TAG_PACKET_5_0_1, L_2TAG_PACKET_6_0_1, L_2TAG_PACKET_7_0_1; + Label L_2TAG_PACKET_8_0_1, L_2TAG_PACKET_9_0_1, L_2TAG_PACKET_10_0_1, L_2TAG_PACKET_11_0_1; + Label L_2TAG_PACKET_13_0_1, L_2TAG_PACKET_14_0_1; + Label L_2TAG_PACKET_12_0_1, B1_1, B1_2, B1_4, start; + + assert_different_registers(tmp1, tmp2, tmp3, tmp4, eax, ebx, ecx, edx); + address ONEHALF = StubRoutines::x86::_ONEHALF_addr(); + address P_2 = StubRoutines::x86::_P_2_addr(); + address SC_4 = StubRoutines::x86::_SC_4_addr(); + address Ctable = StubRoutines::x86::_Ctable_addr(); + address SC_2 = StubRoutines::x86::_SC_2_addr(); + address SC_3 = StubRoutines::x86::_SC_3_addr(); + address SC_1 = StubRoutines::x86::_SC_1_addr(); + address PI_INV_TABLE = StubRoutines::x86::_PI_INV_TABLE_addr(); + address PI_4 = (address)StubRoutines::x86::_PI_4_addr(); + address PI32INV = (address)StubRoutines::x86::_PI32INV_addr(); + address SHIFTER = (address)_SHIFTER; + address SIGN_MASK = (address)StubRoutines::x86::_SIGN_MASK_addr(); + address P_3 = (address)StubRoutines::x86::_P_3_addr(); + address ALL_ONES = (address)_ALL_ONES; + address TWO_POW_55 = (address)_TWO_POW_55; + address TWO_POW_M55 = (address)_TWO_POW_M55; + address P_1 = (address)StubRoutines::x86::_P_1_addr(); + address NEG_ZERO = (address)StubRoutines::x86::_NEG_ZERO_addr(); + + bind(start); + push(rbx); + subq(rsp, 16); + movsd(Address(rsp, 8), xmm0); + movl(eax, Address(rsp, 12)); + movq(xmm1, ExternalAddress(PI32INV)); //0x6dc9c883UL, 0x40245f30UL + movq(xmm2, ExternalAddress(SHIFTER)); //0x00000000UL, 0x43380000UL + andl(eax, 2147418112); + subl(eax, 808452096); + cmpl(eax, 281346048); + jcc(Assembler::above, L_2TAG_PACKET_0_0_1); + mulsd(xmm1, xmm0); + movdqu(xmm5, ExternalAddress(ONEHALF)); //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL + movq(xmm4, ExternalAddress(SIGN_MASK)); //0x00000000UL, 0x80000000UL + pand(xmm4, xmm0); + por(xmm5, xmm4); + addpd(xmm1, xmm5); + cvttsd2sil(edx, xmm1); + cvtsi2sdl(xmm1, edx); + movdqu(xmm6, ExternalAddress(P_2)); //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL + mov64(r8, 0x3fb921fb54400000); + movdq(xmm3, r8); + movdqu(xmm5, ExternalAddress(SC_4)); //0xa556c734UL, 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL + pshufd(xmm4, xmm0, 68); + mulsd(xmm3, xmm1); + if (VM_Version::supports_sse3()) { + movddup(xmm1, xmm1); + } + else { + movlhps(xmm1, xmm1); + } + andl(edx, 63); + shll(edx, 5); + lea(rax, ExternalAddress(Ctable)); + addq(rax, rdx); + mulpd(xmm6, xmm1); + mulsd(xmm1, ExternalAddress(P_3)); //0x2e037073UL, 0x3b63198aUL + subsd(xmm4, xmm3); + movq(xmm7, Address(rax, 8)); + subsd(xmm0, xmm3); + if (VM_Version::supports_sse3()) { + movddup(xmm3, xmm4); + } + else { + movdqu(xmm3, xmm4); + movlhps(xmm3, xmm3); + } + subsd(xmm4, xmm6); + pshufd(xmm0, xmm0, 68); + movdqu(xmm2, Address(rax, 0)); + mulpd(xmm5, xmm0); + subpd(xmm0, xmm6); + mulsd(xmm7, xmm4); + subsd(xmm3, xmm4); + mulpd(xmm5, xmm0); + mulpd(xmm0, xmm0); + subsd(xmm3, xmm6); + movdqu(xmm6, ExternalAddress(SC_2)); //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL + subsd(xmm1, xmm3); + movq(xmm3, Address(rax, 24)); + addsd(xmm2, xmm3); + subsd(xmm7, xmm2); + mulsd(xmm2, xmm4); + mulpd(xmm6, xmm0); + mulsd(xmm3, xmm4); + mulpd(xmm2, xmm0); + mulpd(xmm0, xmm0); + addpd(xmm5, ExternalAddress(SC_3)); //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL + mulsd(xmm4, Address(rax, 0)); + addpd(xmm6, ExternalAddress(SC_1)); //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL + mulpd(xmm5, xmm0); + movdqu(xmm0, xmm3); + addsd(xmm3, Address(rax, 8)); + mulpd(xmm1, xmm7); + movdqu(xmm7, xmm4); + addsd(xmm4, xmm3); + addpd(xmm6, xmm5); + movq(xmm5, Address(rax, 8)); + subsd(xmm5, xmm3); + subsd(xmm3, xmm4); + addsd(xmm1, Address(rax, 16)); + mulpd(xmm6, xmm2); + addsd(xmm5, xmm0); + addsd(xmm3, xmm7); + addsd(xmm1, xmm5); + addsd(xmm1, xmm3); + addsd(xmm1, xmm6); + unpckhpd(xmm6, xmm6); + movdqu(xmm0, xmm4); + addsd(xmm1, xmm6); + addsd(xmm0, xmm1); + jmp(B1_4); + + bind(L_2TAG_PACKET_0_0_1); + jcc(Assembler::greater, L_2TAG_PACKET_1_0_1); + shrl(eax, 20); + cmpl(eax, 3325); + jcc(Assembler::notEqual, L_2TAG_PACKET_2_0_1); + mulsd(xmm0, ExternalAddress(ALL_ONES)); //0xffffffffUL, 0x3fefffffUL + jmp(B1_4); + + bind(L_2TAG_PACKET_2_0_1); + movq(xmm3, ExternalAddress(TWO_POW_55)); //0x00000000UL, 0x43600000UL + mulsd(xmm3, xmm0); + subsd(xmm3, xmm0); + mulsd(xmm3, ExternalAddress(TWO_POW_M55)); //0x00000000UL, 0x3c800000UL + jmp(B1_4); + + bind(L_2TAG_PACKET_1_0_1); + pextrw(eax, xmm0, 3); + andl(eax, 32752); + cmpl(eax, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_3_0_1); + pextrw(ecx, xmm0, 3); + andl(ecx, 32752); + subl(ecx, 16224); + shrl(ecx, 7); + andl(ecx, 65532); + lea(r11, ExternalAddress(PI_INV_TABLE)); + addq(rcx, r11); + movdq(rax, xmm0); + movl(r10, Address(rcx, 20)); + movl(r8, Address(rcx, 24)); + movl(edx, eax); + shrq(rax, 21); + orl(eax, INT_MIN); + shrl(eax, 11); + movl(r9, r10); + imulq(r10, rdx); + imulq(r9, rax); + imulq(r8, rax); + movl(rsi, Address(rcx, 16)); + movl(rdi, Address(rcx, 12)); + movl(r11, r10); + shrq(r10, 32); + addq(r9, r10); + addq(r11, r8); + movl(r8, r11); + shrq(r11, 32); + addq(r9, r11); + movl(r10, rsi); + imulq(rsi, rdx); + imulq(r10, rax); + movl(r11, rdi); + imulq(rdi, rdx); + movl(ebx, rsi); + shrq(rsi, 32); + addq(r9, rbx); + movl(ebx, r9); + shrq(r9, 32); + addq(r10, rsi); + addq(r10, r9); + shlq(rbx, 32); + orq(r8, rbx); + imulq(r11, rax); + movl(r9, Address(rcx, 8)); + movl(rsi, Address(rcx, 4)); + movl(ebx, rdi); + shrq(rdi, 32); + addq(r10, rbx); + movl(ebx, r10); + shrq(r10, 32); + addq(r11, rdi); + addq(r11, r10); + movq(rdi, r9); + imulq(r9, rdx); + imulq(rdi, rax); + movl(r10, r9); + shrq(r9, 32); + addq(r11, r10); + movl(r10, r11); + shrq(r11, 32); + addq(rdi, r9); + addq(rdi, r11); + movq(r9, rsi); + imulq(rsi, rdx); + imulq(r9, rax); + shlq(r10, 32); + orq(r10, rbx); + movl(eax, Address(rcx, 0)); + movl(r11, rsi); + shrq(rsi, 32); + addq(rdi, r11); + movl(r11, rdi); + shrq(rdi, 32); + addq(r9, rsi); + addq(r9, rdi); + imulq(rdx, rax); + pextrw(ebx, xmm0, 3); + lea(rdi, ExternalAddress(PI_INV_TABLE)); + subq(rcx, rdi); + addl(ecx, ecx); + addl(ecx, ecx); + addl(ecx, ecx); + addl(ecx, 19); + movl(rsi, 32768); + andl(rsi, ebx); + shrl(ebx, 4); + andl(ebx, 2047); + subl(ebx, 1023); + subl(ecx, ebx); + addq(r9, rdx); + movl(edx, ecx); + addl(edx, 32); + cmpl(ecx, 1); + jcc(Assembler::less, L_2TAG_PACKET_4_0_1); + negl(ecx); + addl(ecx, 29); + shll(r9); + movl(rdi, r9); + andl(r9, 536870911); + testl(r9, 268435456); + jcc(Assembler::notEqual, L_2TAG_PACKET_5_0_1); + shrl(r9); + movl(ebx, 0); + shlq(r9, 32); + orq(r9, r11); + + bind(L_2TAG_PACKET_6_0_1); + + bind(L_2TAG_PACKET_7_0_1); + + cmpq(r9, 0); + jcc(Assembler::equal, L_2TAG_PACKET_8_0_1); + + bind(L_2TAG_PACKET_9_0_1); + bsrq(r11, r9); + movl(ecx, 29); + subl(ecx, r11); + jcc(Assembler::lessEqual, L_2TAG_PACKET_10_0_1); + shlq(r9); + movq(rax, r10); + shlq(r10); + addl(edx, ecx); + negl(ecx); + addl(ecx, 64); + shrq(rax); + shrq(r8); + orq(r9, rax); + orq(r10, r8); + + bind(L_2TAG_PACKET_11_0_1); + cvtsi2sdq(xmm0, r9); + shrq(r10, 1); + cvtsi2sdq(xmm3, r10); + xorpd(xmm4, xmm4); + shll(edx, 4); + negl(edx); + addl(edx, 16368); + orl(edx, rsi); + xorl(edx, ebx); + pinsrw(xmm4, edx, 3); + movq(xmm2, ExternalAddress(PI_4)); //0x40000000UL, 0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL + movq(xmm6, ExternalAddress(8 + PI_4)); //0x3fe921fbUL, 0x18469899UL, 0x3e64442dUL + xorpd(xmm5, xmm5); + subl(edx, 1008); + pinsrw(xmm5, edx, 3); + mulsd(xmm0, xmm4); + shll(rsi, 16); + sarl(rsi, 31); + mulsd(xmm3, xmm5); + movdqu(xmm1, xmm0); + mulsd(xmm0, xmm2); + shrl(rdi, 29); + addsd(xmm1, xmm3); + mulsd(xmm3, xmm2); + addl(rdi, rsi); + xorl(rdi, rsi); + mulsd(xmm6, xmm1); + movl(eax, rdi); + addsd(xmm6, xmm3); + movdqu(xmm2, xmm0); + addsd(xmm0, xmm6); + subsd(xmm2, xmm0); + addsd(xmm6, xmm2); + + bind(L_2TAG_PACKET_12_0_1); + movq(xmm1, ExternalAddress(PI32INV)); //0x6dc9c883UL, 0x40245f30UL + mulsd(xmm1, xmm0); + movq(xmm5, ExternalAddress(ONEHALF)); //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL + movq(xmm4, ExternalAddress(SIGN_MASK)); //0x00000000UL, 0x80000000UL + pand(xmm4, xmm0); + por(xmm5, xmm4); + addpd(xmm1, xmm5); + cvttsd2sil(edx, xmm1); + cvtsi2sdl(xmm1, edx); + movq(xmm3, ExternalAddress(P_1)); //0x54400000UL, 0x3fb921fbUL + movdqu(xmm2, ExternalAddress(P_2)); //0x1a600000UL, 0x3d90b461UL, 0x1a600000UL, 0x3d90b461UL + mulsd(xmm3, xmm1); + unpcklpd(xmm1, xmm1); + shll(eax, 3); + addl(edx, 1865216); + movdqu(xmm4, xmm0); + addl(edx, eax); + andl(edx, 63); + movdqu(xmm5, ExternalAddress(SC_4)); //0x54400000UL, 0x3fb921fbUL + lea(rax, ExternalAddress(Ctable)); + shll(edx, 5); + addq(rax, rdx); + mulpd(xmm2, xmm1); + subsd(xmm0, xmm3); + mulsd(xmm1, ExternalAddress(P_3)); //0x2e037073UL, 0x3b63198aUL + subsd(xmm4, xmm3); + movq(xmm7, Address(rax, 8)); + unpcklpd(xmm0, xmm0); + movdqu(xmm3, xmm4); + subsd(xmm4, xmm2); + mulpd(xmm5, xmm0); + subpd(xmm0, xmm2); + mulsd(xmm7, xmm4); + subsd(xmm3, xmm4); + mulpd(xmm5, xmm0); + mulpd(xmm0, xmm0); + subsd(xmm3, xmm2); + movdqu(xmm2, Address(rax, 0)); + subsd(xmm1, xmm3); + movq(xmm3, Address(rax, 24)); + addsd(xmm2, xmm3); + subsd(xmm7, xmm2); + subsd(xmm1, xmm6); + movdqu(xmm6, ExternalAddress(SC_2)); //0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL + mulsd(xmm2, xmm4); + mulpd(xmm6, xmm0); + mulsd(xmm3, xmm4); + mulpd(xmm2, xmm0); + mulpd(xmm0, xmm0); + addpd(xmm5, ExternalAddress(SC_3)); //0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL + mulsd(xmm4, Address(rax, 0)); + addpd(xmm6, ExternalAddress(SC_1)); //0x55555555UL, 0xbfc55555UL, 0x00000000UL, 0xbfe00000UL + mulpd(xmm5, xmm0); + movdqu(xmm0, xmm3); + addsd(xmm3, Address(rax, 8)); + mulpd(xmm1, xmm7); + movdqu(xmm7, xmm4); + addsd(xmm4, xmm3); + addpd(xmm6, xmm5); + movq(xmm5, Address(rax, 8)); + subsd(xmm5, xmm3); + subsd(xmm3, xmm4); + addsd(xmm1, Address(rax, 16)); + mulpd(xmm6, xmm2); + addsd(xmm5, xmm0); + addsd(xmm3, xmm7); + addsd(xmm1, xmm5); + addsd(xmm1, xmm3); + addsd(xmm1, xmm6); + unpckhpd(xmm6, xmm6); + movdqu(xmm0, xmm4); + addsd(xmm1, xmm6); + addsd(xmm0, xmm1); + jmp(B1_4); + + bind(L_2TAG_PACKET_8_0_1); + addl(edx, 64); + movq(r9, r10); + movq(r10, r8); + movl(r8, 0); + cmpq(r9, 0); + jcc(Assembler::notEqual, L_2TAG_PACKET_9_0_1); + addl(edx, 64); + movq(r9, r10); + movq(r10, r8); + cmpq(r9, 0); + jcc(Assembler::notEqual, L_2TAG_PACKET_9_0_1); + xorpd(xmm0, xmm0); + xorpd(xmm6, xmm6); + jmp(L_2TAG_PACKET_12_0_1); + + bind(L_2TAG_PACKET_10_0_1); + jcc(Assembler::equal, L_2TAG_PACKET_11_0_1); + negl(ecx); + shrq(r10); + movq(rax, r9); + shrq(r9); + subl(edx, ecx); + negl(ecx); + addl(ecx, 64); + shlq(rax); + orq(r10, rax); + jmp(L_2TAG_PACKET_11_0_1); + + bind(L_2TAG_PACKET_4_0_1); + negl(ecx); + shlq(r9, 32); + orq(r9, r11); + shlq(r9); + movq(rdi, r9); + testl(r9, INT_MIN); + jcc(Assembler::notEqual, L_2TAG_PACKET_13_0_1); + shrl(r9); + movl(ebx, 0); + shrq(rdi, 3); + jmp(L_2TAG_PACKET_7_0_1); + + bind(L_2TAG_PACKET_5_0_1); + shrl(r9); + movl(ebx, 536870912); + shrl(ebx); + shlq(r9, 32); + orq(r9, r11); + shlq(rbx, 32); + addl(rdi, 536870912); + movl(rcx, 0); + movl(r11, 0); + subq(rcx, r8); + sbbq(r11, r10); + sbbq(rbx, r9); + movq(r8, rcx); + movq(r10, r11); + movq(r9, rbx); + movl(ebx, 32768); + jmp(L_2TAG_PACKET_6_0_1); + + bind(L_2TAG_PACKET_13_0_1); + shrl(r9); + mov64(rbx, 0x100000000); + shrq(rbx); + movl(rcx, 0); + movl(r11, 0); + subq(rcx, r8); + sbbq(r11, r10); + sbbq(rbx, r9); + movq(r8, rcx); + movq(r10, r11); + movq(r9, rbx); + movl(ebx, 32768); + shrq(rdi, 3); + addl(rdi, 536870912); + jmp(L_2TAG_PACKET_7_0_1); + + bind(L_2TAG_PACKET_3_0_1); + movq(xmm0, Address(rsp, 8)); + mulsd(xmm0, ExternalAddress(NEG_ZERO)); //0x00000000UL, 0x80000000UL + movq(Address(rsp, 0), xmm0); + + bind(L_2TAG_PACKET_14_0_1); + + bind(B1_4); + addq(rsp, 16); + pop(rbx); +} +#else +// The 32 bit code is at most SSE2 compliant +ALIGNED_(8) juint _zero_none[] = +{ + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL +}; + +ALIGNED_(4) juint __4onpi_d[] = +{ + 0x6dc9c883UL, 0x3ff45f30UL +}; + +ALIGNED_(4) juint _TWO_32H[] = +{ + 0x00000000UL, 0x41f80000UL +}; + +ALIGNED_(4) juint _pi04_3d[] = +{ + 0x54442d00UL, 0x3fe921fbUL, 0x98cc5180UL, 0x3ce84698UL, 0xcbb5bf6cUL, + 0xb9dfc8f8UL +}; + +ALIGNED_(4) juint _pi04_5d[] = +{ + 0x54400000UL, 0x3fe921fbUL, 0x1a600000UL, 0x3dc0b461UL, 0x2e000000UL, + 0x3b93198aUL, 0x25200000UL, 0x396b839aUL, 0x533e63a0UL, 0x37027044UL +}; + +ALIGNED_(4) juint _SCALE[] = +{ + 0x00000000UL, 0x32600000UL +}; + +ALIGNED_(4) juint _zeros[] = +{ + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x80000000UL +}; + +ALIGNED_(4) juint _pi04_2d[] = +{ + 0x54400000UL, 0x3fe921fbUL, 0x1a626331UL, 0x3dc0b461UL +}; + +ALIGNED_(4) juint _TWO_12H[] = +{ + 0x00000000UL, 0x40b80000UL +}; + +ALIGNED_(2) jushort __4onpi_31l[] = +{ + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x836e, 0xa2f9, + 0x40d8, 0x0000, 0x0000, 0x0000, 0x2a50, 0x9c88, 0x40b7, 0x0000, 0x0000, 0x0000, + 0xabe8, 0xfe13, 0x4099, 0x0000, 0x0000, 0x0000, 0x6ee0, 0xfa9a, 0x4079, 0x0000, + 0x0000, 0x0000, 0x9580, 0xdb62, 0x4058, 0x0000, 0x0000, 0x0000, 0x1c82, 0xc9e2, + 0x403d, 0x0000, 0x0000, 0x0000, 0xb1c0, 0xff28, 0x4019, 0x0000, 0x0000, 0x0000, + 0xef14, 0xaf7a, 0x3ffe, 0x0000, 0x0000, 0x0000, 0x48dc, 0xc36e, 0x3fdf, 0x0000, + 0x0000, 0x0000, 0x3740, 0xe909, 0x3fbe, 0x0000, 0x0000, 0x0000, 0x924a, 0xb801, + 0x3fa2, 0x0000, 0x0000, 0x0000, 0x3a32, 0xdd41, 0x3f83, 0x0000, 0x0000, 0x0000, + 0x8778, 0x873f, 0x3f62, 0x0000, 0x0000, 0x0000, 0x1298, 0xb1cb, 0x3f44, 0x0000, + 0x0000, 0x0000, 0xa208, 0x9cfb, 0x3f26, 0x0000, 0x0000, 0x0000, 0xbaec, 0xd7d4, + 0x3f06, 0x0000, 0x0000, 0x0000, 0xd338, 0x8909, 0x3ee7, 0x0000, 0x0000, 0x0000, + 0x68b8, 0xe04d, 0x3ec7, 0x0000, 0x0000, 0x0000, 0x4e64, 0xdf90, 0x3eaa, 0x0000, + 0x0000, 0x0000, 0xc1a8, 0xeb1c, 0x3e89, 0x0000, 0x0000, 0x0000, 0x2720, 0xce7d, + 0x3e6a, 0x0000, 0x0000, 0x0000, 0x77b8, 0x8bf1, 0x3e4b, 0x0000, 0x0000, 0x0000, + 0xec7e, 0xe4a0, 0x3e2e, 0x0000, 0x0000, 0x0000, 0xffbc, 0xf12f, 0x3e0f, 0x0000, + 0x0000, 0x0000, 0xfdc0, 0xb301, 0x3deb, 0x0000, 0x0000, 0x0000, 0xc5ac, 0x9788, + 0x3dd1, 0x0000, 0x0000, 0x0000, 0x47da, 0x829b, 0x3db2, 0x0000, 0x0000, 0x0000, + 0xd9e4, 0xa6cf, 0x3d93, 0x0000, 0x0000, 0x0000, 0x36e8, 0xf961, 0x3d73, 0x0000, + 0x0000, 0x0000, 0xf668, 0xf463, 0x3d54, 0x0000, 0x0000, 0x0000, 0x5168, 0xf2ff, + 0x3d35, 0x0000, 0x0000, 0x0000, 0x758e, 0xea4f, 0x3d17, 0x0000, 0x0000, 0x0000, + 0xf17a, 0xebe5, 0x3cf8, 0x0000, 0x0000, 0x0000, 0x9cfa, 0x9e83, 0x3cd9, 0x0000, + 0x0000, 0x0000, 0xa4ba, 0xe294, 0x3cba, 0x0000, 0x0000, 0x0000, 0xd7ec, 0x9afe, + 0x3c9a, 0x0000, 0x0000, 0x0000, 0xae80, 0x8fc6, 0x3c79, 0x0000, 0x0000, 0x0000, + 0x3304, 0x8560, 0x3c5c, 0x0000, 0x0000, 0x0000, 0x6d70, 0xdf8f, 0x3c3b, 0x0000, + 0x0000, 0x0000, 0x3ef0, 0xafc3, 0x3c1e, 0x0000, 0x0000, 0x0000, 0xd0d8, 0x826b, + 0x3bfe, 0x0000, 0x0000, 0x0000, 0x1c80, 0xed4f, 0x3bdd, 0x0000, 0x0000, 0x0000, + 0x730c, 0xb0af, 0x3bc1, 0x0000, 0x0000, 0x0000, 0x6660, 0xc219, 0x3ba2, 0x0000, + 0x0000, 0x0000, 0x940c, 0xabe2, 0x3b83, 0x0000, 0x0000, 0x0000, 0xdffc, 0x8408, + 0x3b64, 0x0000, 0x0000, 0x0000, 0x6b98, 0xc402, 0x3b45, 0x0000, 0x0000, 0x0000, + 0x1818, 0x9cc4, 0x3b26, 0x0000, 0x0000, 0x0000, 0x5390, 0xaab6, 0x3b05, 0x0000, + 0x0000, 0x0000, 0xb070, 0xd464, 0x3ae9, 0x0000, 0x0000, 0x0000, 0x231a, 0x9ef0, + 0x3aca, 0x0000, 0x0000, 0x0000, 0x0670, 0xd1f1, 0x3aaa, 0x0000, 0x0000, 0x0000, + 0x7738, 0xd9f3, 0x3a8a, 0x0000, 0x0000, 0x0000, 0xa834, 0x8092, 0x3a6c, 0x0000, + 0x0000, 0x0000, 0xb45c, 0xce23, 0x3a4d, 0x0000, 0x0000, 0x0000, 0x36e8, 0xb0e5, + 0x3a2d, 0x0000, 0x0000, 0x0000, 0xd156, 0xaf44, 0x3a10, 0x0000, 0x0000, 0x0000, + 0x9f52, 0x8c82, 0x39f1, 0x0000, 0x0000, 0x0000, 0x829c, 0xff83, 0x39d1, 0x0000, + 0x0000, 0x0000, 0x7d06, 0xefc6, 0x39b3, 0x0000, 0x0000, 0x0000, 0x93e0, 0xb0b7, + 0x3992, 0x0000, 0x0000, 0x0000, 0xedde, 0xc193, 0x3975, 0x0000, 0x0000, 0x0000, + 0xbbc0, 0xcf49, 0x3952, 0x0000, 0x0000, 0x0000, 0xbdf0, 0xd63c, 0x3937, 0x0000, + 0x0000, 0x0000, 0x1f34, 0x9f3a, 0x3918, 0x0000, 0x0000, 0x0000, 0x3f8e, 0xe579, + 0x38f9, 0x0000, 0x0000, 0x0000, 0x90c8, 0xc3f8, 0x38d9, 0x0000, 0x0000, 0x0000, + 0x48c0, 0xf8f8, 0x38b7, 0x0000, 0x0000, 0x0000, 0xed56, 0xafa6, 0x389c, 0x0000, + 0x0000, 0x0000, 0x8218, 0xb969, 0x387d, 0x0000, 0x0000, 0x0000, 0x1852, 0xec57, + 0x385e, 0x0000, 0x0000, 0x0000, 0x670c, 0xd674, 0x383e, 0x0000, 0x0000, 0x0000, + 0xad40, 0xc2c4, 0x3820, 0x0000, 0x0000, 0x0000, 0x2e80, 0xa696, 0x3801, 0x0000, + 0x0000, 0x0000, 0xd800, 0xc467, 0x37dc, 0x0000, 0x0000, 0x0000, 0x3c72, 0xc5ae, + 0x37c3, 0x0000, 0x0000, 0x0000, 0xb006, 0xac69, 0x37a4, 0x0000, 0x0000, 0x0000, + 0x34a0, 0x8cdf, 0x3782, 0x0000, 0x0000, 0x0000, 0x9ed2, 0xd25e, 0x3766, 0x0000, + 0x0000, 0x0000, 0x6fec, 0xaaaa, 0x3747, 0x0000, 0x0000, 0x0000, 0x6040, 0xfb5c, + 0x3726, 0x0000, 0x0000, 0x0000, 0x764c, 0xa3fc, 0x3708, 0x0000, 0x0000, 0x0000, + 0xb254, 0x954e, 0x36e9, 0x0000, 0x0000, 0x0000, 0x3e1c, 0xf5dc, 0x36ca, 0x0000, + 0x0000, 0x0000, 0x7b06, 0xc635, 0x36ac, 0x0000, 0x0000, 0x0000, 0xa8ba, 0xd738, + 0x368d, 0x0000, 0x0000, 0x0000, 0x06cc, 0xb24e, 0x366d, 0x0000, 0x0000, 0x0000, + 0x7108, 0xac76, 0x364f, 0x0000, 0x0000, 0x0000, 0x2324, 0xa7cb, 0x3630, 0x0000, + 0x0000, 0x0000, 0xac40, 0xef15, 0x360f, 0x0000, 0x0000, 0x0000, 0xae46, 0xd516, + 0x35f2, 0x0000, 0x0000, 0x0000, 0x615e, 0xe003, 0x35d3, 0x0000, 0x0000, 0x0000, + 0x0cf0, 0xefe7, 0x35b1, 0x0000, 0x0000, 0x0000, 0xfb50, 0xf98c, 0x3595, 0x0000, + 0x0000, 0x0000, 0x0abc, 0xf333, 0x3575, 0x0000, 0x0000, 0x0000, 0xdd60, 0xca3f, + 0x3555, 0x0000, 0x0000, 0x0000, 0x7eb6, 0xd87f, 0x3538, 0x0000, 0x0000, 0x0000, + 0x44f4, 0xb291, 0x3519, 0x0000, 0x0000, 0x0000, 0xff80, 0xc982, 0x34f6, 0x0000, + 0x0000, 0x0000, 0x9de0, 0xd9b8, 0x34db, 0x0000, 0x0000, 0x0000, 0xcd42, 0x9366, + 0x34bc, 0x0000, 0x0000, 0x0000, 0xbef0, 0xfaee, 0x349d, 0x0000, 0x0000, 0x0000, + 0xdac4, 0xb6f1, 0x347d, 0x0000, 0x0000, 0x0000, 0xf140, 0x94de, 0x345d, 0x0000, + 0x0000, 0x0000, 0xa218, 0x8b4b, 0x343e, 0x0000, 0x0000, 0x0000, 0x6380, 0xa135, + 0x341e, 0x0000, 0x0000, 0x0000, 0xb184, 0x8cb2, 0x3402, 0x0000, 0x0000, 0x0000, + 0x196e, 0xdc61, 0x33e3, 0x0000, 0x0000, 0x0000, 0x0c00, 0xde05, 0x33c4, 0x0000, + 0x0000, 0x0000, 0xef9a, 0xbd38, 0x33a5, 0x0000, 0x0000, 0x0000, 0xc1a0, 0xdf00, + 0x3385, 0x0000, 0x0000, 0x0000, 0x1090, 0x9973, 0x3365, 0x0000, 0x0000, 0x0000, + 0x4882, 0x8301, 0x3348, 0x0000, 0x0000, 0x0000, 0x7abe, 0xadc7, 0x3329, 0x0000, + 0x0000, 0x0000, 0x7cba, 0xec2b, 0x330a, 0x0000, 0x0000, 0x0000, 0xa520, 0x8f21, + 0x32e9, 0x0000, 0x0000, 0x0000, 0x710c, 0x8d36, 0x32cc, 0x0000, 0x0000, 0x0000, + 0x5212, 0xc6ed, 0x32ad, 0x0000, 0x0000, 0x0000, 0x7308, 0xfd76, 0x328d, 0x0000, + 0x0000, 0x0000, 0x5014, 0xd548, 0x326f, 0x0000, 0x0000, 0x0000, 0xd3f2, 0xb499, + 0x3250, 0x0000, 0x0000, 0x0000, 0x7f74, 0xa606, 0x3230, 0x0000, 0x0000, 0x0000, + 0xf0a8, 0xd720, 0x3212, 0x0000, 0x0000, 0x0000, 0x185c, 0xe20f, 0x31f2, 0x0000, + 0x0000, 0x0000, 0xa5a8, 0x8738, 0x31d4, 0x0000, 0x0000, 0x0000, 0xdd74, 0xcafb, + 0x31b4, 0x0000, 0x0000, 0x0000, 0x98b6, 0xbd8e, 0x3196, 0x0000, 0x0000, 0x0000, + 0xe9de, 0x977f, 0x3177, 0x0000, 0x0000, 0x0000, 0x67c0, 0x818d, 0x3158, 0x0000, + 0x0000, 0x0000, 0xe52a, 0x9322, 0x3139, 0x0000, 0x0000, 0x0000, 0xe568, 0x9b6c, + 0x3119, 0x0000, 0x0000, 0x0000, 0x2358, 0xaa0a, 0x30fa, 0x0000, 0x0000, 0x0000, + 0xe480, 0xe13b, 0x30d9, 0x0000, 0x0000, 0x0000, 0x3024, 0x90a1, 0x30bd, 0x0000, + 0x0000, 0x0000, 0x9620, 0xda30, 0x309d, 0x0000, 0x0000, 0x0000, 0x898a, 0xb388, + 0x307f, 0x0000, 0x0000, 0x0000, 0xb24c, 0xc891, 0x3060, 0x0000, 0x0000, 0x0000, + 0x8056, 0xf98b, 0x3041, 0x0000, 0x0000, 0x0000, 0x72a4, 0xa1ea, 0x3021, 0x0000, + 0x0000, 0x0000, 0x6af8, 0x9488, 0x3001, 0x0000, 0x0000, 0x0000, 0xe00c, 0xdfcb, + 0x2fe4, 0x0000, 0x0000, 0x0000, 0xeeec, 0xc941, 0x2fc4, 0x0000, 0x0000, 0x0000, + 0x53e0, 0xe70f, 0x2fa4, 0x0000, 0x0000, 0x0000, 0x8f60, 0x9c07, 0x2f85, 0x0000, + 0x0000, 0x0000, 0xb328, 0xc3e7, 0x2f68, 0x0000, 0x0000, 0x0000, 0x9404, 0xf8c7, + 0x2f48, 0x0000, 0x0000, 0x0000, 0x38e0, 0xc99f, 0x2f29, 0x0000, 0x0000, 0x0000, + 0x9778, 0xd984, 0x2f09, 0x0000, 0x0000, 0x0000, 0xe700, 0xd142, 0x2eea, 0x0000, + 0x0000, 0x0000, 0xd904, 0x9443, 0x2ecd, 0x0000, 0x0000, 0x0000, 0xd4ba, 0xae7e, + 0x2eae, 0x0000, 0x0000, 0x0000, 0x8e5e, 0x8524, 0x2e8f, 0x0000, 0x0000, 0x0000, + 0xb550, 0xc9ed, 0x2e6e, 0x0000, 0x0000, 0x0000, 0x53b8, 0x8648, 0x2e51, 0x0000, + 0x0000, 0x0000, 0xdae4, 0x87f9, 0x2e32, 0x0000, 0x0000, 0x0000, 0x2942, 0xd966, + 0x2e13, 0x0000, 0x0000, 0x0000, 0x4f28, 0xcf3c, 0x2df3, 0x0000, 0x0000, 0x0000, + 0xfa40, 0xc4ef, 0x2dd1, 0x0000, 0x0000, 0x0000, 0x4424, 0xbca7, 0x2db5, 0x0000, + 0x0000, 0x0000, 0x2e62, 0xcdc5, 0x2d97, 0x0000, 0x0000, 0x0000, 0xed88, 0x996b, + 0x2d78, 0x0000, 0x0000, 0x0000, 0x7c30, 0xd97d, 0x2d56, 0x0000, 0x0000, 0x0000, + 0xed26, 0xbf6e, 0x2d3a, 0x0000, 0x0000, 0x0000, 0x2918, 0x921b, 0x2d1a, 0x0000, + 0x0000, 0x0000, 0x4e24, 0xe84e, 0x2cfb, 0x0000, 0x0000, 0x0000, 0x6dc0, 0x92ec, + 0x2cdd, 0x0000, 0x0000, 0x0000, 0x4f2c, 0xacf8, 0x2cbd, 0x0000, 0x0000, 0x0000, + 0xc634, 0xf094, 0x2c9e, 0x0000, 0x0000, 0x0000, 0xdc70, 0xe5d3, 0x2c7e, 0x0000, + 0x0000, 0x0000, 0x2180, 0xa600, 0x2c5b, 0x0000, 0x0000, 0x0000, 0x8480, 0xd680, + 0x2c3c, 0x0000, 0x0000, 0x0000, 0x8b24, 0xd63b, 0x2c22, 0x0000, 0x0000, 0x0000, + 0x02e0, 0xaa47, 0x2c00, 0x0000, 0x0000, 0x0000, 0x9ad0, 0xee84, 0x2be3, 0x0000, + 0x0000, 0x0000, 0xf7dc, 0xf699, 0x2bc6, 0x0000, 0x0000, 0x0000, 0xddde, 0xe490, + 0x2ba7, 0x0000, 0x0000, 0x0000, 0x34a0, 0xb4fd, 0x2b85, 0x0000, 0x0000, 0x0000, + 0x91b4, 0x8ef6, 0x2b68, 0x0000, 0x0000, 0x0000, 0xa3e0, 0xa2a7, 0x2b47, 0x0000, + 0x0000, 0x0000, 0xcce4, 0x82b3, 0x2b2a, 0x0000, 0x0000, 0x0000, 0xe4be, 0x8207, + 0x2b0c, 0x0000, 0x0000, 0x0000, 0x1d92, 0xab43, 0x2aed, 0x0000, 0x0000, 0x0000, + 0xe818, 0xf9f6, 0x2acd, 0x0000, 0x0000, 0x0000, 0xff12, 0xba80, 0x2aaf, 0x0000, + 0x0000, 0x0000, 0x5254, 0x8529, 0x2a90, 0x0000, 0x0000, 0x0000, 0x1b88, 0xe032, + 0x2a71, 0x0000, 0x0000, 0x0000, 0x3248, 0xd86d, 0x2a50, 0x0000, 0x0000, 0x0000, + 0x3140, 0xc9d5, 0x2a2e, 0x0000, 0x0000, 0x0000, 0x14e6, 0xbd47, 0x2a14, 0x0000, + 0x0000, 0x0000, 0x5c10, 0xe544, 0x29f4, 0x0000, 0x0000, 0x0000, 0x9f50, 0x90b6, + 0x29d4, 0x0000, 0x0000, 0x0000, 0x9850, 0xab55, 0x29b6, 0x0000, 0x0000, 0x0000, + 0x2750, 0x9d07, 0x2998, 0x0000, 0x0000, 0x0000, 0x6700, 0x8bbb, 0x2973, 0x0000, + 0x0000, 0x0000, 0x5dba, 0xed31, 0x295a, 0x0000, 0x0000, 0x0000, 0x61dc, 0x85fe, + 0x293a, 0x0000, 0x0000, 0x0000, 0x9ba2, 0xd6b4, 0x291c, 0x0000, 0x0000, 0x0000, + 0x2d30, 0xe3a5, 0x28fb, 0x0000, 0x0000, 0x0000, 0x6630, 0xb566, 0x28dd, 0x0000, + 0x0000, 0x0000, 0x5ad4, 0xa829, 0x28bf, 0x0000, 0x0000, 0x0000, 0x89d8, 0xe290, + 0x28a0, 0x0000, 0x0000, 0x0000, 0x3916, 0xc428, 0x2881, 0x0000, 0x0000, 0x0000, + 0x0490, 0xbea4, 0x2860, 0x0000, 0x0000, 0x0000, 0xee06, 0x80ee, 0x2843, 0x0000, + 0x0000, 0x0000, 0xfc00, 0xf327, 0x2820, 0x0000, 0x0000, 0x0000, 0xea40, 0xa871, + 0x2800, 0x0000, 0x0000, 0x0000, 0x63d8, 0x9c26, 0x27e4, 0x0000, 0x0000, 0x0000, + 0x07ba, 0xc0c9, 0x27c7, 0x0000, 0x0000, 0x0000, 0x3fa2, 0x9797, 0x27a8, 0x0000, + 0x0000, 0x0000, 0x21c6, 0xfeca, 0x2789, 0x0000, 0x0000, 0x0000, 0xde40, 0x860d, + 0x2768, 0x0000, 0x0000, 0x0000, 0x9cc8, 0x98ce, 0x2749, 0x0000, 0x0000, 0x0000, + 0x3778, 0xa31c, 0x272a, 0x0000, 0x0000, 0x0000, 0xe778, 0xf6e2, 0x270b, 0x0000, + 0x0000, 0x0000, 0x59b8, 0xf841, 0x26ed, 0x0000, 0x0000, 0x0000, 0x02e0, 0xad04, + 0x26cd, 0x0000, 0x0000, 0x0000, 0x5a92, 0x9380, 0x26b0, 0x0000, 0x0000, 0x0000, + 0xc740, 0x8886, 0x268d, 0x0000, 0x0000, 0x0000, 0x0680, 0xfaf8, 0x266c, 0x0000, + 0x0000, 0x0000, 0xfb60, 0x897f, 0x2653, 0x0000, 0x0000, 0x0000, 0x8760, 0xf903, + 0x2634, 0x0000, 0x0000, 0x0000, 0xad2a, 0xc2c8, 0x2615, 0x0000, 0x0000, 0x0000, + 0x2d86, 0x8aef, 0x25f6, 0x0000, 0x0000, 0x0000, 0x1ef4, 0xe627, 0x25d6, 0x0000, + 0x0000, 0x0000, 0x09e4, 0x8020, 0x25b7, 0x0000, 0x0000, 0x0000, 0x7548, 0xd227, + 0x2598, 0x0000, 0x0000, 0x0000, 0x75dc, 0xfb5b, 0x2579, 0x0000, 0x0000, 0x0000, + 0xea84, 0xc8b6, 0x255a, 0x0000, 0x0000, 0x0000, 0xe4d0, 0x8145, 0x253b, 0x0000, + 0x0000, 0x0000, 0x3640, 0x9768, 0x251c, 0x0000, 0x0000, 0x0000, 0x246a, 0xccec, + 0x24fe, 0x0000, 0x0000, 0x0000, 0x51d0, 0xa075, 0x24dd, 0x0000, 0x0000, 0x0000, + 0x4638, 0xa385, 0x24bf, 0x0000, 0x0000, 0x0000, 0xd788, 0xd776, 0x24a1, 0x0000, + 0x0000, 0x0000, 0x1370, 0x8997, 0x2482, 0x0000, 0x0000, 0x0000, 0x1e88, 0x9b67, + 0x2462, 0x0000, 0x0000, 0x0000, 0x6c08, 0xd975, 0x2444, 0x0000, 0x0000, 0x0000, + 0xfdb0, 0xcfc0, 0x2422, 0x0000, 0x0000, 0x0000, 0x3100, 0xc026, 0x2406, 0x0000, + 0x0000, 0x0000, 0xc5b4, 0xae64, 0x23e6, 0x0000, 0x0000, 0x0000, 0x2280, 0xf687, + 0x23c3, 0x0000, 0x0000, 0x0000, 0x2de0, 0x9006, 0x23a9, 0x0000, 0x0000, 0x0000, + 0x24bc, 0xf631, 0x238a, 0x0000, 0x0000, 0x0000, 0xb8d4, 0xa975, 0x236b, 0x0000, + 0x0000, 0x0000, 0xd9a4, 0xb949, 0x234b, 0x0000, 0x0000, 0x0000, 0xb54e, 0xbd39, + 0x232d, 0x0000, 0x0000, 0x0000, 0x4aac, 0x9a52, 0x230e, 0x0000, 0x0000, 0x0000, + 0xbbbc, 0xd085, 0x22ef, 0x0000, 0x0000, 0x0000, 0xdf18, 0xc633, 0x22cf, 0x0000, + 0x0000, 0x0000, 0x16d0, 0xeca5, 0x22af, 0x0000, 0x0000, 0x0000, 0xf2a0, 0xdf6f, + 0x228e, 0x0000, 0x0000, 0x0000, 0x8c44, 0xe86b, 0x2272, 0x0000, 0x0000, 0x0000, + 0x35c0, 0xbbf4, 0x2253, 0x0000, 0x0000, 0x0000, 0x0c40, 0xdafb, 0x2230, 0x0000, + 0x0000, 0x0000, 0x92dc, 0x9935, 0x2216, 0x0000, 0x0000, 0x0000, 0x0ca0, 0xbda6, + 0x21f3, 0x0000, 0x0000, 0x0000, 0x5958, 0xa6fd, 0x21d6, 0x0000, 0x0000, 0x0000, + 0xa3dc, 0x9d7f, 0x21b9, 0x0000, 0x0000, 0x0000, 0x79dc, 0xfcb5, 0x2199, 0x0000, + 0x0000, 0x0000, 0xf264, 0xcebb, 0x217b, 0x0000, 0x0000, 0x0000, 0x0abe, 0x8308, + 0x215c, 0x0000, 0x0000, 0x0000, 0x30ae, 0xb463, 0x213d, 0x0000, 0x0000, 0x0000, + 0x6228, 0xb040, 0x211c, 0x0000, 0x0000, 0x0000, 0xc9b2, 0xf43b, 0x20ff, 0x0000, + 0x0000, 0x0000, 0x3d8e, 0xa4b3, 0x20e0, 0x0000, 0x0000, 0x0000, 0x84e6, 0x8dab, + 0x20c1, 0x0000, 0x0000, 0x0000, 0xa124, 0x9b74, 0x20a1, 0x0000, 0x0000, 0x0000, + 0xc276, 0xd497, 0x2083, 0x0000, 0x0000, 0x0000, 0x6354, 0xa466, 0x2063, 0x0000, + 0x0000, 0x0000, 0x8654, 0xaf0a, 0x2044, 0x0000, 0x0000, 0x0000, 0x1d20, 0xfa5c, + 0x2024, 0x0000, 0x0000, 0x0000, 0xbcd0, 0xf3f0, 0x2004, 0x0000, 0x0000, 0x0000, + 0xedf0, 0xf0b6, 0x1fe7, 0x0000, 0x0000, 0x0000, 0x45bc, 0x9182, 0x1fc9, 0x0000, + 0x0000, 0x0000, 0xe254, 0xdc85, 0x1faa, 0x0000, 0x0000, 0x0000, 0xb898, 0xe9b1, + 0x1f8a, 0x0000, 0x0000, 0x0000, 0x0ebe, 0xe6f0, 0x1f6c, 0x0000, 0x0000, 0x0000, + 0xa9b8, 0xf584, 0x1f4c, 0x0000, 0x0000, 0x0000, 0x12e8, 0xdf6b, 0x1f2e, 0x0000, + 0x0000, 0x0000, 0x9f9e, 0xcd55, 0x1f0f, 0x0000, 0x0000, 0x0000, 0x05a0, 0xec3a, + 0x1eef, 0x0000, 0x0000, 0x0000, 0xd8e0, 0x96f8, 0x1ed1, 0x0000, 0x0000, 0x0000, + 0x3bd4, 0xccc6, 0x1eb1, 0x0000, 0x0000, 0x0000, 0x4910, 0xb87b, 0x1e93, 0x0000, + 0x0000, 0x0000, 0xbefc, 0xd40b, 0x1e73, 0x0000, 0x0000, 0x0000, 0x317e, 0xa406, + 0x1e55, 0x0000, 0x0000, 0x0000, 0x6bb2, 0xc2b2, 0x1e36, 0x0000, 0x0000, 0x0000, + 0xb87e, 0xbb78, 0x1e17, 0x0000, 0x0000, 0x0000, 0xa03c, 0xdbbd, 0x1df7, 0x0000, + 0x0000, 0x0000, 0x5b6c, 0xe3c8, 0x1dd9, 0x0000, 0x0000, 0x0000, 0x8968, 0xca8e, + 0x1dba, 0x0000, 0x0000, 0x0000, 0xc024, 0xe6ab, 0x1d9a, 0x0000, 0x0000, 0x0000, + 0x4110, 0xd4eb, 0x1d7a, 0x0000, 0x0000, 0x0000, 0xa168, 0xbdb5, 0x1d5d, 0x0000, + 0x0000, 0x0000, 0x012e, 0xa5fa, 0x1d3e, 0x0000, 0x0000, 0x0000, 0x6838, 0x9c1f, + 0x1d1e, 0x0000, 0x0000, 0x0000, 0xa158, 0xaa76, 0x1d00, 0x0000, 0x0000, 0x0000, + 0x090a, 0xbd95, 0x1ce1, 0x0000, 0x0000, 0x0000, 0xf73e, 0x8b6d, 0x1cc2, 0x0000, + 0x0000, 0x0000, 0x5fda, 0xbcbf, 0x1ca3, 0x0000, 0x0000, 0x0000, 0xdbe8, 0xb89f, + 0x1c84, 0x0000, 0x0000, 0x0000, 0x6e4c, 0x96c7, 0x1c64, 0x0000, 0x0000, 0x0000, + 0x19c2, 0xf2a4, 0x1c46, 0x0000, 0x0000, 0x0000, 0xb800, 0xf855, 0x1c1e, 0x0000, + 0x0000, 0x0000, 0x87fc, 0x85ff, 0x1c08, 0x0000, 0x0000, 0x0000, 0x1418, 0x839f, + 0x1be9, 0x0000, 0x0000, 0x0000, 0x6186, 0xd9d8, 0x1bca, 0x0000, 0x0000, 0x0000, + 0xf500, 0xabaa, 0x1ba6, 0x0000, 0x0000, 0x0000, 0x7b36, 0xdafe, 0x1b8c, 0x0000, + 0x0000, 0x0000, 0xf394, 0xe6d8, 0x1b6c, 0x0000, 0x0000, 0x0000, 0x6efc, 0x9e55, + 0x1b4e, 0x0000, 0x0000, 0x0000, 0x5e10, 0xc523, 0x1b2e, 0x0000, 0x0000, 0x0000, + 0x8210, 0xb6f9, 0x1b0d, 0x0000, 0x0000, 0x0000, 0x9ab0, 0x96e3, 0x1af1, 0x0000, + 0x0000, 0x0000, 0x3864, 0x92e7, 0x1ad1, 0x0000, 0x0000, 0x0000, 0x9878, 0xdc65, + 0x1ab1, 0x0000, 0x0000, 0x0000, 0xfa20, 0xd6cb, 0x1a94, 0x0000, 0x0000, 0x0000, + 0x6c00, 0xa4e4, 0x1a70, 0x0000, 0x0000, 0x0000, 0xab40, 0xb41b, 0x1a53, 0x0000, + 0x0000, 0x0000, 0x43a4, 0x8ede, 0x1a37, 0x0000, 0x0000, 0x0000, 0x22e0, 0x9314, + 0x1a15, 0x0000, 0x0000, 0x0000, 0x6170, 0xb949, 0x19f8, 0x0000, 0x0000, 0x0000, + 0x6b00, 0xe056, 0x19d8, 0x0000, 0x0000, 0x0000, 0x9ba8, 0xa94c, 0x19b9, 0x0000, + 0x0000, 0x0000, 0xfaa0, 0xaa16, 0x199b, 0x0000, 0x0000, 0x0000, 0x899a, 0xf627, + 0x197d, 0x0000, 0x0000, 0x0000, 0x9f20, 0xfb70, 0x195d, 0x0000, 0x0000, 0x0000, + 0xa4b8, 0xc176, 0x193e, 0x0000, 0x0000, 0x0000, 0xb21c, 0x85c3, 0x1920, 0x0000, + 0x0000, 0x0000, 0x50d2, 0x9b19, 0x1901, 0x0000, 0x0000, 0x0000, 0xd4b0, 0xb708, + 0x18e0, 0x0000, 0x0000, 0x0000, 0xfb88, 0xf510, 0x18c1, 0x0000, 0x0000, 0x0000, + 0x31ec, 0xdc8d, 0x18a3, 0x0000, 0x0000, 0x0000, 0x3c00, 0xbff9, 0x1885, 0x0000, + 0x0000, 0x0000, 0x5020, 0xc30b, 0x1862, 0x0000, 0x0000, 0x0000, 0xd4f0, 0xda0c, + 0x1844, 0x0000, 0x0000, 0x0000, 0x20d2, 0x99a5, 0x1828, 0x0000, 0x0000, 0x0000, + 0x852e, 0xd159, 0x1809, 0x0000, 0x0000, 0x0000, 0x7cd8, 0x97a1, 0x17e9, 0x0000, + 0x0000, 0x0000, 0x423a, 0x997b, 0x17cb, 0x0000, 0x0000, 0x0000, 0xc1c0, 0xbe7d, + 0x17a8, 0x0000, 0x0000, 0x0000, 0xe8bc, 0xdcdd, 0x178d, 0x0000, 0x0000, 0x0000, + 0x8b28, 0xae06, 0x176e, 0x0000, 0x0000, 0x0000, 0x102e, 0xb8d4, 0x174f, 0x0000, + 0x0000, 0x0000, 0xaa00, 0xaa5c, 0x172f, 0x0000, 0x0000, 0x0000, 0x51f0, 0x9fc0, + 0x170e, 0x0000, 0x0000, 0x0000, 0xf858, 0xe181, 0x16f2, 0x0000, 0x0000, 0x0000, + 0x91a8, 0x8162, 0x16d3, 0x0000, 0x0000, 0x0000, 0x5f40, 0xcb6f, 0x16b1, 0x0000, + 0x0000, 0x0000, 0xbb50, 0xe55f, 0x1693, 0x0000, 0x0000, 0x0000, 0xacd2, 0xd895, + 0x1676, 0x0000, 0x0000, 0x0000, 0xef30, 0x97bf, 0x1654, 0x0000, 0x0000, 0x0000, + 0xf700, 0xb3d7, 0x1633, 0x0000, 0x0000, 0x0000, 0x3454, 0xa7b5, 0x1619, 0x0000, + 0x0000, 0x0000, 0x6b00, 0xa929, 0x15f6, 0x0000, 0x0000, 0x0000, 0x9f04, 0x89f7, + 0x15db, 0x0000, 0x0000, 0x0000, 0xad78, 0xd985, 0x15bc, 0x0000, 0x0000, 0x0000, + 0xa46a, 0xae3f, 0x159d, 0x0000, 0x0000, 0x0000, 0x63a0, 0xd0da, 0x157c, 0x0000, + 0x0000, 0x0000, 0x5e90, 0x817d, 0x155e, 0x0000, 0x0000, 0x0000, 0x1494, 0xb13f, + 0x1540, 0x0000, 0x0000, 0x0000, 0x0090, 0x9c40, 0x1521, 0x0000, 0x0000, 0x0000, + 0xdd70, 0xcc86, 0x1500, 0x0000, 0x0000, 0x0000, 0x64f8, 0xdb6f, 0x14e1, 0x0000, + 0x0000, 0x0000, 0xe22c, 0xac17, 0x14c3, 0x0000, 0x0000, 0x0000, 0x60e0, 0xa9ad, + 0x14a3, 0x0000, 0x0000, 0x0000, 0x4640, 0xd658, 0x1481, 0x0000, 0x0000, 0x0000, + 0x6490, 0xa181, 0x1467, 0x0000, 0x0000, 0x0000, 0x1df4, 0xaaa2, 0x1447, 0x0000, + 0x0000, 0x0000, 0xb94a, 0x8f61, 0x1429, 0x0000, 0x0000, 0x0000, 0x5198, 0x9d83, + 0x1409, 0x0000, 0x0000, 0x0000, 0x0f7a, 0xa818, 0x13eb, 0x0000, 0x0000, 0x0000, + 0xc45e, 0xc06c, 0x13cc, 0x0000, 0x0000, 0x0000, 0x4ec0, 0xfa29, 0x13a8, 0x0000, + 0x0000, 0x0000, 0x6418, 0x8cad, 0x138c, 0x0000, 0x0000, 0x0000, 0xbcc8, 0xe7d1, + 0x136f, 0x0000, 0x0000, 0x0000, 0xc934, 0xf9b0, 0x134f, 0x0000, 0x0000, 0x0000, + 0x6ce0, 0x98df, 0x1331, 0x0000, 0x0000, 0x0000, 0x3516, 0xe5e9, 0x1312, 0x0000, + 0x0000, 0x0000, 0xc6c0, 0xef8b, 0x12ef, 0x0000, 0x0000, 0x0000, 0xaf02, 0x913d, + 0x12d4, 0x0000, 0x0000, 0x0000, 0xd230, 0xe1d5, 0x12b5, 0x0000, 0x0000, 0x0000, + 0xfba8, 0xc232, 0x1295, 0x0000, 0x0000, 0x0000, 0x7ba4, 0xabeb, 0x1277, 0x0000, + 0x0000, 0x0000, 0x6e5c, 0xc692, 0x1258, 0x0000, 0x0000, 0x0000, 0x76a2, 0x9756, + 0x1239, 0x0000, 0x0000, 0x0000, 0xe180, 0xe423, 0x1214, 0x0000, 0x0000, 0x0000, + 0x8c3c, 0x90f8, 0x11fb, 0x0000, 0x0000, 0x0000, 0x9f3c, 0x9fd2, 0x11dc, 0x0000, + 0x0000, 0x0000, 0x53e0, 0xb73e, 0x11bd, 0x0000, 0x0000, 0x0000, 0x45be, 0x88d6, + 0x119e, 0x0000, 0x0000, 0x0000, 0x111a, 0x8bc0, 0x117f, 0x0000, 0x0000, 0x0000, + 0xe26a, 0xd7ff, 0x1160, 0x0000, 0x0000, 0x0000, 0xfb60, 0xdd8d, 0x113f, 0x0000, + 0x0000, 0x0000, 0x9370, 0xc108, 0x1120, 0x0000, 0x0000, 0x0000, 0x9654, 0x8baf, + 0x1103, 0x0000, 0x0000, 0x0000, 0xd6ec, 0xd6b9, 0x10e4, 0x0000, 0x0000, 0x0000, + 0x23e4, 0xd7b7, 0x10c4, 0x0000, 0x0000, 0x0000, 0x1aa6, 0xa847, 0x10a6, 0x0000, + 0x0000, 0x0000, 0xbee6, 0x9fef, 0x1087, 0x0000, 0x0000, 0x0000, 0x26d0, 0xa6eb, + 0x1066, 0x0000, 0x0000, 0x0000, 0x5b86, 0xa880, 0x1049, 0x0000, 0x0000, 0x0000, + 0x125c, 0xd971, 0x1029, 0x0000, 0x0000, 0x0000, 0x1f78, 0x9d18, 0x100a, 0x0000, + 0x0000, 0x0000, 0x0e84, 0xb15b, 0x0feb, 0x0000, 0x0000, 0x0000, 0xd0c0, 0xc150, + 0x0fcc, 0x0000, 0x0000, 0x0000, 0xa330, 0xc40c, 0x0fad, 0x0000, 0x0000, 0x0000, + 0x5202, 0xfc2c, 0x0f8f, 0x0000, 0x0000, 0x0000, 0x3f7c, 0xecf5, 0x0f6f, 0x0000, + 0x0000, 0x0000, 0xef44, 0xfdfd, 0x0f50, 0x0000, 0x0000, 0x0000, 0x3f6c, 0xab1b, + 0x0f31, 0x0000, 0x0000, 0x0000, 0xf658, 0x89ec, 0x0f11, 0x0000, 0x0000, 0x0000, + 0xbfc8, 0x9ba8, 0x0ef4, 0x0000, 0x0000, 0x0000, 0x3d40, 0xbe21, 0x0ed5, 0x0000, + 0x0000, 0x0000, 0xbbc4, 0xc70d, 0x0eb6, 0x0000, 0x0000, 0x0000, 0x5158, 0xdb16, + 0x0e96, 0x0000, 0x0000, 0x0000, 0xb5a8, 0xa8d8, 0x0e78, 0x0000, 0x0000, 0x0000, + 0xcccc, 0xb40e, 0x0e58, 0x0000, 0x0000, 0x0000, 0x448c, 0xcb62, 0x0e3a, 0x0000, + 0x0000, 0x0000, 0xf12a, 0x8aed, 0x0e1b, 0x0000, 0x0000, 0x0000, 0x79d0, 0xc59c, + 0x0dfb, 0x0000, 0x0000, 0x0000, 0x06b4, 0xcdc9, 0x0ddd, 0x0000, 0x0000, 0x0000, + 0xae70, 0xa979, 0x0dbe, 0x0000, 0x0000, 0x0000, 0x317c, 0xa8fb, 0x0d9e, 0x0000, + 0x0000, 0x0000, 0x5fe0, 0x8a50, 0x0d7d, 0x0000, 0x0000, 0x0000, 0x70b6, 0xfdfa, + 0x0d61, 0x0000, 0x0000, 0x0000, 0x1640, 0x9dc7, 0x0d41, 0x0000, 0x0000, 0x0000, + 0x9a9c, 0xdc50, 0x0d23, 0x0000, 0x0000, 0x0000, 0x4fcc, 0x9a9b, 0x0d04, 0x0000, + 0x0000, 0x0000, 0x7e48, 0x8f77, 0x0ce5, 0x0000, 0x0000, 0x0000, 0x84e4, 0xd4b9, + 0x0cc6, 0x0000, 0x0000, 0x0000, 0x84e0, 0xbd10, 0x0ca6, 0x0000, 0x0000, 0x0000, + 0x1b0a, 0xc8d9, 0x0c88, 0x0000, 0x0000, 0x0000, 0x6a48, 0xfc81, 0x0c68, 0x0000, + 0x0000, 0x0000, 0x070a, 0xbef6, 0x0c4a, 0x0000, 0x0000, 0x0000, 0x8a70, 0xf096, + 0x0c2b, 0x0000, 0x0000, 0x0000, 0xecc2, 0xc994, 0x0c0c, 0x0000, 0x0000, 0x0000, + 0x1540, 0x9537, 0x0bea, 0x0000, 0x0000, 0x0000, 0x1b02, 0xab5b, 0x0bce, 0x0000, + 0x0000, 0x0000, 0x5dc0, 0xb0c8, 0x0bad, 0x0000, 0x0000, 0x0000, 0xc928, 0xe034, + 0x0b8f, 0x0000, 0x0000, 0x0000, 0x2d12, 0xb4b0, 0x0b71, 0x0000, 0x0000, 0x0000, + 0x8fc2, 0xbb94, 0x0b52, 0x0000, 0x0000, 0x0000, 0xe236, 0xe22f, 0x0b33, 0x0000, + 0x0000, 0x0000, 0xb97c, 0xbe9e, 0x0b13, 0x0000, 0x0000, 0x0000, 0xe1a6, 0xe16d, + 0x0af5, 0x0000, 0x0000, 0x0000, 0xd330, 0xbaf0, 0x0ad6, 0x0000, 0x0000, 0x0000, + 0xc0bc, 0xbbd0, 0x0ab7, 0x0000, 0x0000, 0x0000, 0x8e66, 0xdd9b, 0x0a98, 0x0000, + 0x0000, 0x0000, 0xc95c, 0xf799, 0x0a79, 0x0000, 0x0000, 0x0000, 0xdac0, 0xbe4c, + 0x0a55, 0x0000, 0x0000, 0x0000, 0xafc0, 0xc378, 0x0a37, 0x0000, 0x0000, 0x0000, + 0xa880, 0xe341, 0x0a19, 0x0000, 0x0000, 0x0000, 0xc242, 0x81f6, 0x09fd, 0x0000, + 0x0000, 0x0000, 0x7470, 0xc777, 0x09de, 0x0000, 0x0000, 0x0000, 0x62bc, 0xb684, + 0x09be, 0x0000, 0x0000, 0x0000, 0x43ac, 0x8c58, 0x099f, 0x0000, 0x0000, 0x0000, + 0xcc3c, 0xf9ac, 0x0981, 0x0000, 0x0000, 0x0000, 0x1526, 0xb670, 0x0962, 0x0000, + 0x0000, 0x0000, 0xc9fe, 0xdf50, 0x0943, 0x0000, 0x0000, 0x0000, 0x6ae6, 0xc065, + 0x0924, 0x0000, 0x0000, 0x0000, 0xb114, 0xcf29, 0x0905, 0x0000, 0x0000, 0x0000, + 0xd388, 0x922a, 0x08e4, 0x0000, 0x0000, 0x0000, 0xcf54, 0xb926, 0x08c7, 0x0000, + 0x0000, 0x0000, 0x3826, 0xe855, 0x08a8, 0x0000, 0x0000, 0x0000, 0xe7c8, 0x829b, + 0x0888, 0x0000, 0x0000, 0x0000, 0x546c, 0xa903, 0x086a, 0x0000, 0x0000, 0x0000, + 0x8768, 0x99cc, 0x0849, 0x0000, 0x0000, 0x0000, 0x00ac, 0xf529, 0x082b, 0x0000, + 0x0000, 0x0000, 0x2658, 0x9f0b, 0x080c, 0x0000, 0x0000, 0x0000, 0xfe5c, 0x9e21, + 0x07ee, 0x0000, 0x0000, 0x0000, 0x6da2, 0x9910, 0x07cf, 0x0000, 0x0000, 0x0000, + 0x9220, 0xf9b3, 0x07b0, 0x0000, 0x0000, 0x0000, 0x3d90, 0xa541, 0x0791, 0x0000, + 0x0000, 0x0000, 0x6e4c, 0xe7cc, 0x0771, 0x0000, 0x0000, 0x0000, 0xa8fa, 0xe80a, + 0x0753, 0x0000, 0x0000, 0x0000, 0x4e14, 0xc3a7, 0x0734, 0x0000, 0x0000, 0x0000, + 0xf7e0, 0xbad9, 0x0712, 0x0000, 0x0000, 0x0000, 0xfea0, 0xeff2, 0x06f5, 0x0000, + 0x0000, 0x0000, 0xcef6, 0xbd48, 0x06d7, 0x0000, 0x0000, 0x0000, 0x7544, 0xf559, + 0x06b7, 0x0000, 0x0000, 0x0000, 0x2388, 0xf655, 0x0698, 0x0000, 0x0000, 0x0000, + 0xe900, 0xad56, 0x0676, 0x0000, 0x0000, 0x0000, 0x2cc0, 0x8437, 0x0659, 0x0000, + 0x0000, 0x0000, 0x3068, 0xc544, 0x063b, 0x0000, 0x0000, 0x0000, 0xdc70, 0xe73c, + 0x061b, 0x0000, 0x0000, 0x0000, 0xee50, 0x9d49, 0x05fc, 0x0000, 0x0000, 0x0000, + 0x93d2, 0x81f6, 0x05df, 0x0000, 0x0000, 0x0000, 0x941c, 0xadff, 0x05bf, 0x0000, + 0x0000, 0x0000, 0x2ce2, 0x8e45, 0x05a1, 0x0000, 0x0000, 0x0000, 0x4a60, 0x95fd, + 0x0581, 0x0000, 0x0000, 0x0000, 0x79f8, 0xb83a, 0x0563, 0x0000, 0x0000, 0x0000, + 0xcb58, 0xa1f5, 0x0543, 0x0000, 0x0000, 0x0000, 0x2a3a, 0xdc36, 0x0525, 0x0000, + 0x0000, 0x0000, 0x14ee, 0x890e, 0x0506, 0x0000, 0x0000, 0x0000, 0x8f20, 0xc432, + 0x04e3, 0x0000, 0x0000, 0x0000, 0x8440, 0xb21d, 0x04c6, 0x0000, 0x0000, 0x0000, + 0x5430, 0xf698, 0x04a7, 0x0000, 0x0000, 0x0000, 0x04ae, 0x8b20, 0x048a, 0x0000, + 0x0000, 0x0000, 0x04d0, 0xe872, 0x046b, 0x0000, 0x0000, 0x0000, 0xc78e, 0x8893, + 0x044c, 0x0000, 0x0000, 0x0000, 0x0f78, 0x9895, 0x042b, 0x0000, 0x0000, 0x0000, + 0x11d4, 0xdf2e, 0x040d, 0x0000, 0x0000, 0x0000, 0xe84c, 0x89d5, 0x03ef, 0x0000, + 0x0000, 0x0000, 0xf7be, 0x8a67, 0x03d0, 0x0000, 0x0000, 0x0000, 0x95d0, 0xc906, + 0x03b1, 0x0000, 0x0000, 0x0000, 0x64ce, 0xd96c, 0x0392, 0x0000, 0x0000, 0x0000, + 0x97ba, 0xa16f, 0x0373, 0x0000, 0x0000, 0x0000, 0x463c, 0xc51a, 0x0354, 0x0000, + 0x0000, 0x0000, 0xef0a, 0xe93e, 0x0335, 0x0000, 0x0000, 0x0000, 0x526a, 0xa466, + 0x0316, 0x0000, 0x0000, 0x0000, 0x4140, 0xa94d, 0x02f5, 0x0000, 0x0000, 0x0000, + 0xb4ec, 0xce68, 0x02d8, 0x0000, 0x0000, 0x0000, 0x4fa2, 0x8490, 0x02b9, 0x0000, + 0x0000, 0x0000, 0x4e60, 0xca98, 0x0298, 0x0000, 0x0000, 0x0000, 0x08dc, 0xe09c, + 0x027a, 0x0000, 0x0000, 0x0000, 0x2b90, 0xc7e3, 0x025c, 0x0000, 0x0000, 0x0000, + 0x5a7c, 0xf8ef, 0x023c, 0x0000, 0x0000, 0x0000, 0x5022, 0x9d58, 0x021e, 0x0000, + 0x0000, 0x0000, 0x553a, 0xe242, 0x01ff, 0x0000, 0x0000, 0x0000, 0x7e6e, 0xb54d, + 0x01e0, 0x0000, 0x0000, 0x0000, 0xd2d4, 0xa88c, 0x01c1, 0x0000, 0x0000, 0x0000, + 0x75b6, 0xfe6d, 0x01a2, 0x0000, 0x0000, 0x0000, 0x3bb2, 0xf04c, 0x0183, 0x0000, + 0x0000, 0x0000, 0xc2d0, 0xc046, 0x0163, 0x0000, 0x0000, 0x0000, 0x250c, 0xf9d6, + 0x0145, 0x0000, 0x0000, 0x0000, 0xb7b4, 0x8a0d, 0x0126, 0x0000, 0x0000, 0x0000, + 0x1a72, 0xe4f5, 0x0107, 0x0000, 0x0000, 0x0000, 0x825c, 0xa9b8, 0x00e8, 0x0000, + 0x0000, 0x0000, 0x6c90, 0xc9ad, 0x00c6, 0x0000, 0x0000, 0x0000, 0x4d00, 0xd1bb, + 0x00aa, 0x0000, 0x0000, 0x0000, 0xa4a0, 0xee01, 0x0087, 0x0000, 0x0000, 0x0000, + 0x89a8, 0xbe9f, 0x006b, 0x0000, 0x0000, 0x0000, 0x038e, 0xc80c, 0x004d, 0x0000, + 0x0000, 0x0000, 0xfe26, 0x8384, 0x002e, 0x0000, 0x0000, 0x0000, 0xcd90, 0xca57, + 0x000e, 0x0000 +}; + +void MacroAssembler::libm_reduce_pi04l(Register eax, Register ecx, Register edx, Register ebx, Register esi, Register edi, Register ebp, Register esp) { + Label B1_1, B1_2, B1_3, B1_4, B1_5, B1_6, B1_7, B1_8, B1_9, B1_10, B1_11, B1_12; + Label B1_13, B1_14, B1_15; + + assert_different_registers(ebx, eax, ecx, edx, esi, edi, ebp, esp); + + address zero_none = (address)_zero_none; + address _4onpi_d = (address)__4onpi_d; + address TWO_32H = (address)_TWO_32H; + address pi04_3d = (address)_pi04_3d; + address pi04_5d = (address)_pi04_5d; + address SCALE = (address)_SCALE; + address zeros = (address)_zeros; + address pi04_2d = (address)_pi04_2d; + address TWO_12H = (address)_TWO_12H; + address _4onpi_31l = (address)__4onpi_31l; + + bind(B1_1); + push(ebp); + movl(ebp, esp); + andl(esp, -16); + push(esi); + push(edi); + push(ebx); + subl(esp, 20); + movzwl(ebx, Address(ebp, 16)); + andl(ebx, 32767); + movl(eax, Address(ebp, 20)); + cmpl(ebx, 16413); + movl(esi, Address(ebp, 24)); + movl(Address(esp, 4), eax); + jcc(Assembler::greaterEqual, B1_8); + + bind(B1_2); + fld_x(Address(ebp, 8)); + fld_d(ExternalAddress(_4onpi_d)); //0x6dc9c883UL, 0x3ff45f30UL + fmul(1); + fstp_x(Address(esp, 8)); + movzwl(ecx, Address(esp, 16)); + negl(ecx); + addl(ecx, 30); + movl(eax, Address(esp, 12)); + shrl(eax); + cmpl(Address(esp, 4), 0); + jcc(Assembler::notEqual, B1_4); + + bind(B1_3); + lea(ecx, Address(eax, 1)); + andl(ecx, -2); + jmp(B1_5); + + bind(B1_4); + movl(ecx, eax); + addl(eax, Address(esp, 4)); + movl(edx, eax); + andl(edx, 1); + addl(ecx, edx); + + bind(B1_5); + fld_d(ExternalAddress(TWO_32H)); //0x00000000UL, 0x41f80000UL + cmpl(ebx, 16400); + movl(Address(esp, 0), ecx); + fild_s(Address(esp, 0)); + jcc(Assembler::greaterEqual, B1_7); + + bind(B1_6); + fld_d(ExternalAddress(pi04_3d)); //0x54442d00UL, 0x3fe921fbUL + fmul(1); + fsubp(3); + fxch(1); + fmul(2); + fld_s(2); + fadd(1); + fsubrp(1); + fld_s(0); + fxch(1); + fsuba(3); + fld_d(ExternalAddress(8 + pi04_3d)); //0x98cc5180UL, 0x3ce84698UL + fmul(3); + fsuba(2); + fxch(1); + fsub(2); + fsubrp(1); + faddp(3); + fld_d(ExternalAddress(16 + pi04_3d)); //0xcbb5bf6cUL, 0xb9dfc8f8UL + fmulp(2); + fld_s(1); + fsubr(1); + fsuba(1); + fxch(2); + fsubp(1); + faddp(2); + fxch(1); + jmp(B1_15); + + bind(B1_7); + fld_d(ExternalAddress(pi04_5d)); //0x54400000UL, 0x3fe921fbUL + fmul(1); + fsubp(3); + fxch(1); + fmul(2); + fld_s(2); + fadd(1); + fsubrp(1); + fld_s(0); + fxch(1); + fsuba(3); + fld_d(ExternalAddress(8 + pi04_5d)); //0x1a600000UL, 0x3dc0b461UL + fmul(3); + fsuba(2); + fxch(1); + fsub(2); + fsubrp(1); + faddp(3); + fld_d(ExternalAddress(16 + pi04_5d)); //0x2e000000UL, 0x3b93198aUL + fmul(2); + fld_s(0); + fsubr(2); + fsuba(2); + fxch(1); + fsubp(2); + fxch(1); + faddp(3); + fld_d(ExternalAddress(24 + pi04_5d)); //0x25200000UL, 0x396b839aUL + fmul(2); + fld_s(0); + fsubr(2); + fsuba(2); + fxch(1); + fsubp(2); + fxch(1); + faddp(3); + fld_d(ExternalAddress(32 + pi04_5d)); //0x533e63a0UL, 0x37027044UL + fmulp(2); + fld_s(1); + fsubr(1); + fsuba(1); + fxch(2); + fsubp(1); + faddp(2); + fxch(1); + jmp(B1_15); + + bind(B1_8); + fld_x(Address(ebp, 8)); + addl(ebx, -16417); + fmul_d(as_Address(ExternalAddress(SCALE))); //0x00000000UL, 0x32600000UL + movl(eax, -2078209981); + imull(ebx); + addl(edx, ebx); + movl(ecx, ebx); + sarl(edx, 4); + sarl(ecx, 31); + subl(edx, ecx); + movl(eax, edx); + shll(eax, 5); + fstp_x(Address(ebp, 8)); + fld_x(Address(ebp, 8)); + subl(eax, edx); + movl(Address(ebp, 8), 0); + subl(ebx, eax); + fld_x(Address(ebp, 8)); + cmpl(ebx, 17); + fsuba(1); + jcc(Assembler::less, B1_10); + + bind(B1_9); + lea(eax, Address(noreg, edx, Address::times_8)); + lea(ecx, Address(eax, edx, Address::times_4)); + incl(edx); + fld_x(Address(_4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); + fmul(2); + fld_x(Address(12 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); + fmul(2); + fld_s(0); + fadd(2); + fsuba(2); + fxch(1); + faddp(2); + fld_s(1); + fadd(1); + fstp_x(Address(esp, 8)); + andl(Address(esp, 8), -16777216); + fld_x(Address(esp, 8)); + fsubp(1); + jmp(B1_11); + + bind(B1_10); + fld_d(ExternalAddress(zeros)); //0x00000000UL, 0x00000000UL + fld_s(0); + + bind(B1_11); + fld_s(0); + lea(eax, Address(noreg, edx, Address::times_8)); + fld_s(3); + lea(edx, Address(eax, edx, Address::times_4)); + fld_x(Address(_4onpi_31l, RelocationHolder::none).plus_disp(edx, Address::times_1)); + fmul(6); + movl(Address(esp, 0), edx); + fadda(2); + fxch(2); + fsuba(3); + fxch(2); + faddp(3); + fxch(2); + faddp(3); + fld_x(Address(12 + _4onpi_31l, RelocationHolder::none).plus_disp(edx, Address::times_1)); + fmula(2); + fld_s(2); + fadd(2); + fld_s(0); + fxch(1); + fsubra(3); + fxch(3); + fchs(); + faddp(4); + fxch(3); + faddp(4); + fxch(2); + fadd(3); + fxch(2); + fmul(5); + fadda(2); + fld_s(4); + fld_x(Address(24 + _4onpi_31l, RelocationHolder::none).plus_disp(edx, Address::times_1)); + fmula(1); + fxch(1); + fadda(4); + fxch(4); + fstp_x(Address(esp, 8)); + movzwl(ebx, Address(esp, 16)); + andl(ebx, 32767); + cmpl(ebx, 16415); + jcc(Assembler::greaterEqual, B1_13); + + bind(B1_12); + negl(ebx); + addl(ebx, 30); + movl(ecx, ebx); + movl(eax, Address(esp, 12)); + shrl(eax); + shll(eax); + movl(Address(esp, 12), eax); + movl(Address(esp, 8), 0); + shrl(eax); + jmp(B1_14); + + bind(B1_13); + negl(ebx); + addl(ebx, 30); + movl(ecx, ebx); + movl(edx, Address(esp, 8)); + shrl(edx); + shll(edx); + negl(ecx); + movl(eax, Address(esp, 12)); + shll(eax); + movl(ecx, ebx); + movl(Address(esp, 8), edx); + shrl(edx); + orl(eax, edx); + + bind(B1_14); + fld_x(Address(esp, 8)); + addl(eax, Address(esp, 4)); + fsubp(3); + fmul(6); + fld_s(4); + movl(edx, eax); + andl(edx, 1); + fadd(3); + movl(ecx, Address(esp, 0)); + fsuba(3); + fxch(3); + faddp(5); + fld_s(1); + fxch(3); + fadd_d(Address(zero_none, RelocationHolder::none).plus_disp(edx, Address::times_8)); + fadda(3); + fsub(3); + faddp(2); + fxch(1); + faddp(4); + fld_s(2); + fadd(2); + fsuba(2); + fxch(3); + faddp(2); + fxch(1); + faddp(3); + fld_s(0); + fadd(2); + fsuba(2); + fxch(1); + faddp(2); + fxch(1); + faddp(2); + fld_s(2); + fld_x(Address(36 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); + fmula(1); + fld_s(1); + fadd(3); + fsuba(3); + fxch(2); + faddp(3); + fxch(2); + faddp(3); + fxch(1); + fmul(4); + fld_s(0); + fadd(2); + fsuba(2); + fxch(1); + faddp(2); + fxch(1); + faddp(2); + fld_s(2); + fld_x(Address(48 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); + fmula(1); + fld_s(1); + fadd(3); + fsuba(3); + fxch(2); + faddp(3); + fxch(2); + faddp(3); + fld_s(3); + fxch(2); + fmul(5); + fld_x(Address(60 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); + fmula(3); + fxch(3); + faddp(1); + fld_s(0); + fadd(2); + fsuba(2); + fxch(1); + faddp(2); + fxch(1); + faddp(3); + fld_s(3); + fxch(2); + fmul(5); + fld_x(Address(72 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); + fmula(3); + fxch(3); + faddp(1); + fld_s(0); + fadd(2); + fsuba(2); + fxch(1); + faddp(2); + fxch(1); + faddp(3); + fxch(1); + fmulp(4); + fld_x(Address(84 + _4onpi_31l, RelocationHolder::none).plus_disp(ecx, Address::times_1)); + fmulp(3); + fxch(2); + faddp(3); + fld_s(2); + fadd(2); + fld_d(ExternalAddress(TWO_32H)); //0x00000000UL, 0x41f80000UL + fmul(1); + fadda(1); + fsubp(1); + fsuba(2); + fxch(3); + faddp(2); + faddp(1); + fld_d(ExternalAddress(pi04_2d)); //0x54400000UL, 0x3fe921fbUL + fld_s(0); + fmul(2); + fxch(2); + fadd(3); + fxch(1); + fmulp(3); + fmul_d(as_Address(ExternalAddress(8 + pi04_2d))); //0x1a626331UL, 0x3dc0b461UL + faddp(1); + + bind(B1_15); + fld_d(ExternalAddress(TWO_12H)); //0x00000000UL, 0x40b80000UL + fld_s(2); + fadd(2); + fmula(1); + fstp_x(Address(esp, 8)); + fld_x(Address(esp, 8)); + fadd(1); + fsubrp(1); + fst_d(Address(esi, 0)); + fsubp(2); + faddp(1); + fstp_d(Address(esi, 8)); + addl(esp, 20); + pop(ebx); + pop(edi); + pop(esi); + movl(esp, ebp); + pop(ebp); + ret(0); +} + +ALIGNED_(16) juint StubRoutines::x86::_L_2il0floatpacket_0[] = +{ + 0xffffffffUL, 0x7fffffffUL, 0x00000000UL, 0x00000000UL +}; + +ALIGNED_(16) juint StubRoutines::x86::_Pi4Inv[] = +{ + 0x6dc9c883UL, 0x3ff45f30UL +}; + +ALIGNED_(16) juint StubRoutines::x86::_Pi4x3[] = +{ + 0x54443000UL, 0xbfe921fbUL, 0x3b39a000UL, 0x3d373dcbUL, 0xe0e68948UL, + 0xba845c06UL +}; + +ALIGNED_(16) juint StubRoutines::x86::_Pi4x4[] = +{ + 0x54400000UL, 0xbfe921fbUL, 0x1a600000UL, 0xbdc0b461UL, 0x2e000000UL, + 0xbb93198aUL, 0x252049c1UL, 0xb96b839aUL +}; + +ALIGNED_(16) jushort _SP[] = +{ + 0xaaab, 0xaaaa, 0xaaaa, 0xaaaa, 0xbffc, 0x0000, 0x8887, 0x8888, 0x8888, 0x8888, + 0x3ff8, 0x0000, 0xc527, 0x0d00, 0x00d0, 0xd00d, 0xbff2, 0x0000, 0x45f6, 0xb616, + 0x1d2a, 0xb8ef, 0x3fec, 0x0000, 0x825b, 0x3997, 0x2b3f, 0xd732, 0xbfe5, 0x0000, + 0xbf33, 0x8bb4, 0x2fda, 0xb092, 0x3fde, 0x0000, 0x44a6, 0xed1a, 0x29ef, 0xd73e, + 0xbfd6, 0x0000, 0x8610, 0x307f, 0x62a1, 0xc921, 0x3fce, 0x0000 +}; + +ALIGNED_(16) jushort _CP[] = +{ + 0x0000, 0x0000, 0x0000, 0x8000, 0xbffe, 0x0000, 0xaaa5, 0xaaaa, 0xaaaa, 0xaaaa, + 0x3ffa, 0x0000, 0x9c2f, 0x0b60, 0x60b6, 0xb60b, 0xbff5, 0x0000, 0xf024, 0x0cac, + 0x00d0, 0xd00d, 0x3fef, 0x0000, 0x03fe, 0x3f65, 0x7dbb, 0x93f2, 0xbfe9, 0x0000, + 0xd84d, 0xadee, 0xc698, 0x8f76, 0x3fe2, 0x0000, 0xdaba, 0xfe79, 0xea36, 0xc9c9, + 0xbfda, 0x0000, 0x3ac6, 0x0ba0, 0x07ce, 0xd585, 0x3fd2, 0x0000 +}; + +ALIGNED_(16) juint StubRoutines::x86::_ones[] = +{ + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xbff00000UL +}; + +void MacroAssembler::libm_sincos_huge(XMMRegister xmm0, XMMRegister xmm1, Register eax, Register ecx, Register edx, Register ebx, Register esi, Register edi, Register ebp, Register esp) { + Label B1_1, B1_2, B1_3, B1_4, B1_5, B1_6, B1_7, B1_8, B1_9, B1_10, B1_11, B1_12; + Label B1_13, B1_14, B1_15, B1_16, B1_17, B1_18, B1_19, B1_20, B1_21, B1_22, B1_23; + Label B1_24, B1_25, B1_26, B1_27, B1_28, B1_29, B1_30, B1_31, B1_32, B1_33, B1_34; + Label B1_35, B1_36, B1_37, B1_38, B1_39, B1_40, B1_41, B1_42, B1_43, B1_44, B1_45, B1_46; + + assert_different_registers(ebx, eax, ecx, edx, esi, edi, ebp, esp); + + address L_2il0floatpacket_0 = StubRoutines::x86::_L_2il0floatpacket_0_addr(); + address Pi4Inv = StubRoutines::x86::_Pi4Inv_addr(); + address Pi4x3 = StubRoutines::x86::_Pi4x3_addr(); + address Pi4x4 = StubRoutines::x86::_Pi4x4_addr(); + address ones = StubRoutines::x86::_ones_addr(); + address CP = (address)_CP; + address SP = (address)_SP; + + bind(B1_1); + push(ebp); + movl(ebp, esp); + andl(esp, -64); + push(esi); + push(edi); + push(ebx); + subl(esp, 52); + movl(eax, Address(ebp, 16)); + movl(edx, Address(ebp, 20)); + movl(Address(esp, 32), eax); + movl(Address(esp, 36), edx); + + bind(B1_2); + fnstcw(Address(esp, 30)); + + bind(B1_3); + movsd(xmm1, Address(ebp, 8)); + movl(esi, Address(ebp, 12)); + movl(eax, esi); + andl(eax, 2147483647); + andps(xmm1, ExternalAddress(L_2il0floatpacket_0)); //0xffffffffUL, 0x7fffffffUL, 0x00000000UL, 0x00000000UL + shrl(esi, 31); + movl(Address(esp, 40), eax); + cmpl(eax, 1104150528); + movsd(Address(ebp, 8), xmm1); + jcc(Assembler::aboveEqual, B1_11); + + bind(B1_4); + movsd(xmm0, ExternalAddress(Pi4Inv)); //0x6dc9c883UL, 0x3ff45f30UL + mulsd(xmm0, xmm1); + movzwl(edx, Address(esp, 30)); + movl(eax, edx); + andl(eax, 768); + movsd(Address(esp, 0), xmm0); + cmpl(eax, 768); + jcc(Assembler::equal, B1_42); + + bind(B1_5); + orl(edx, -64768); + movw(Address(esp, 28), edx); + + bind(B1_6); + fldcw(Address(esp, 28)); + + bind(B1_7); + movsd(xmm1, Address(ebp, 8)); + movl(ebx, 1); + + bind(B1_8); + movl(Address(esp, 12), ebx); + movl(ebx, Address(esp, 4)); + movl(eax, ebx); + movl(Address(esp, 8), esi); + movl(esi, ebx); + shrl(esi, 20); + andl(eax, 1048575); + movl(ecx, esi); + orl(eax, 1048576); + negl(ecx); + movl(edx, eax); + addl(ecx, 19); + addl(esi, 13); + movl(Address(esp, 24), ecx); + shrl(edx); + movl(ecx, esi); + shll(eax); + movl(ecx, Address(esp, 24)); + movl(esi, Address(esp, 0)); + shrl(esi); + orl(eax, esi); + cmpl(ebx, 1094713344); + movsd(Address(esp, 16), xmm1); + fld_d(Address(esp, 16)); + cmov32(Assembler::below, eax, edx); + movl(esi, Address(esp, 8)); + lea(edx, Address(eax, 1)); + movl(ebx, edx); + andl(ebx, -2); + movl(Address(esp, 16), ebx); + fild_s(Address(esp, 16)); + movl(ebx, Address(esp, 12)); + cmpl(Address(esp, 40), 1094713344); + jcc(Assembler::aboveEqual, B1_10); + + bind(B1_9); + fld_d(ExternalAddress(Pi4x3)); //0x54443000UL, 0xbfe921fbUL + fmul(1); + faddp(2); + fld_d(ExternalAddress(8 + Pi4x3)); //0x3b39a000UL, 0x3d373dcbUL + fmul(1); + faddp(2); + fld_d(ExternalAddress(16 + Pi4x3)); //0xe0e68948UL, 0xba845c06UL + fmulp(1); + faddp(1); + jmp(B1_17); + + bind(B1_10); + fld_d(ExternalAddress(Pi4x4)); //0x54400000UL, 0xbfe921fbUL + fmul(1); + faddp(2); + fld_d(ExternalAddress(8 + Pi4x4)); //0x1a600000UL, 0xbdc0b461UL + fmul(1); + faddp(2); + fld_d(ExternalAddress(16 + Pi4x4)); //0x2e000000UL, 0xbb93198aUL + fmul(1); + faddp(2); + fld_d(ExternalAddress(24 + Pi4x4)); //0x252049c1UL, 0xb96b839aUL + fmulp(1); + faddp(1); + jmp(B1_17); + + bind(B1_11); + movzwl(edx, Address(esp, 30)); + movl(eax, edx); + andl(eax, 768); + cmpl(eax, 768); + jcc(Assembler::equal, B1_43); + bind(B1_12); + orl(edx, -64768); + movw(Address(esp, 28), edx); + + bind(B1_13); + fldcw(Address(esp, 28)); + + bind(B1_14); + movsd(xmm1, Address(ebp, 8)); + movl(ebx, 1); + + bind(B1_15); + movsd(Address(esp, 16), xmm1); + fld_d(Address(esp, 16)); + addl(esp, -32); + lea(eax, Address(esp, 32)); + fstp_x(Address(esp, 0)); + movl(Address(esp, 12), 0); + movl(Address(esp, 16), eax); + call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_reduce_pi04l()))); + + bind(B1_46); + addl(esp, 32); + + bind(B1_16); + fld_d(Address(esp, 0)); + lea(edx, Address(eax, 1)); + fld_d(Address(esp, 8)); + faddp(1); + + bind(B1_17); + movl(ecx, edx); + addl(eax, 3); + shrl(ecx, 2); + andl(ecx, 1); + shrl(eax, 2); + xorl(esi, ecx); + movl(ecx, Address(esp, 36)); + andl(eax, 1); + andl(ecx, 3); + cmpl(ecx, 3); + jcc(Assembler::notEqual, B1_25); + + bind(B1_18); + fld_x(ExternalAddress(84 + SP)); //0x8610, 0x307f, 0x62 + fld_s(1); + fmul((2)); + testb(edx, 2); + fmula((1)); + fld_x(ExternalAddress(72 + SP)); //0x44a6, 0xed1a, 0x29 + faddp(2); + fmula(1); + fld_x(ExternalAddress(60 + SP)); //0xbf33, 0x8bb4, 0x2f + faddp(2); + fmula(1); + fld_x(ExternalAddress(48 + SP)); //0x825b, 0x3997, 0x2b + faddp(2); + fmula(1); + fld_x(ExternalAddress(36 + SP)); //0x45f6, 0xb616, 0x1d + faddp(2); + fmula(1); + fld_x(ExternalAddress(24 + SP)); //0xc527, 0x0d00, 0x00 + faddp(2); + fmula(1); + fld_x(ExternalAddress(12 + SP)); //0x8887, 0x8888, 0x88 + faddp(2); + fmula(1); + fld_x(ExternalAddress(SP)); //0xaaab, 0xaaaa, 0xaa + faddp(2); + fmula(1); + fld_x(ExternalAddress(84 + CP)); //0x3ac6, 0x0ba0, 0x07 + fmul(1); + fld_x(ExternalAddress(72 + CP)); //0xdaba, 0xfe79, 0xea + faddp(1); + fmul(1); + fld_x(ExternalAddress(62 + CP)); //0xd84d, 0xadee, 0xc6 + faddp(1); + fmul(1); + fld_x(ExternalAddress(48 + CP)); //0x03fe, 0x3f65, 0x7d + faddp(1); + fmul(1); + fld_x(ExternalAddress(36 + CP)); //0xf024, 0x0cac, 0x00 + faddp(1); + fmul(1); + fld_x(ExternalAddress(24 + CP)); //0x9c2f, 0x0b60, 0x60 + faddp(1); + fmul(1); + fld_x(ExternalAddress(12 + CP)); //0xaaa5, 0xaaaa, 0xaa + faddp(1); + fmul(1); + fld_x(ExternalAddress(CP)); //0x0000, 0x0000, 0x00 + faddp(1); + fmulp(1); + fld_d(Address(ones, RelocationHolder::none).plus_disp(esi, Address::times_8)); + fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8)); + jcc(Assembler::equal, B1_22); + + bind(B1_19); + fmulp(4); + testl(ebx, ebx); + fxch(2); + fmul(3); + movl(eax, Address(esp, 2)); + faddp(3); + fxch(2); + fstp_d(Address(eax, 0)); + fmula(1); + faddp(1); + fstp_d(Address(eax, 8)); + jcc(Assembler::equal, B1_21); + + bind(B1_20); + fldcw(Address(esp, 30)); + + bind(B1_21); + addl(esp, 52); + pop(ebx); + pop(edi); + pop(esi); + movl(esp, ebp); + pop(ebp); + ret(0); + + bind(B1_22); + fxch(1); + fmulp(4); + testl(ebx, ebx); + fxch(2); + fmul(3); + movl(eax, Address(esp, 32)); + faddp(3); + fxch(2); + fstp_d(Address(eax, 8)); + fmula(1); + faddp(1); + fstp_d(Address(eax, 0)); + jcc(Assembler::equal, B1_24); + + bind(B1_23); + fldcw(Address(esp, 30)); + + bind(B1_24); + addl(esp, 52); + pop(ebx); + pop(edi); + pop(esi); + movl(esp, ebp); + pop(ebp); + ret(0); + + bind(B1_25); + testb(Address(esp, 36), 2); + jcc(Assembler::equal, B1_33); + + bind(B1_26); + fld_s(0); + testb(edx, 2); + fmul(1); + fld_s(0); + fmul(1); + jcc(Assembler::equal, B1_30); + + bind(B1_27); + fstp_d(2); + fld_x(ExternalAddress(84 + CP)); //0x3ac6, 0x0ba0, 0x07 + testl(ebx, ebx); + fmul(2); + fld_x(ExternalAddress(72 + CP)); //0xdaba, 0xfe79, 0xea + fmul(3); + fld_x(ExternalAddress(60 + CP)); //0xd84d, 0xadee, 0xc6 + movl(eax, Address(rsp, 32)); + faddp(2); + fxch(1); + fmul(3); + fld_x(ExternalAddress(48 + CP)); //0x03fe, 0x3f65, 0x7d + faddp(2); + fxch(1); + fmul(3); + fld_x(ExternalAddress(36 + CP)); //0xf024, 0x0cac, 0x00 + faddp(2); + fxch(1); + fmul(3); + fld_x(ExternalAddress(24 + CP)); //0x9c2f, 0x0b60, 0x60 + faddp(2); + fxch(1); + fmul(3); + fld_x(ExternalAddress(12 + CP)); //0xaaa5, 0xaaaa, 0xaa + faddp(2); + fxch(1); + fmulp(3); + fld_x(ExternalAddress(CP)); //0x0000, 0x0000, 0x00 + faddp(1); + fmulp(1); + faddp(1); + fld_d(Address(ones, RelocationHolder::none).plus_disp(rsi, Address::times_8)); + fmula(1); + faddp(1); + fstp_d(Address(eax, 8)); + jcc(Assembler::equal, B1_29); + + bind(B1_28); + fldcw(Address(esp, 30)); + + bind(B1_29); + addl(esp, 52); + pop(ebx); + pop(edi); + pop(esi); + movl(esp, ebp); + pop(ebp); + ret(0); + + bind(B1_30); + fld_x(ExternalAddress(84 + SP)); //0x8610, 0x307f, 0x62 + testl(ebx, ebx); + fmul(1); + fld_x(ExternalAddress(72 + SP)); //0x44a6, 0xed1a, 0x29 + fmul(2); + fld_x(ExternalAddress(60 + SP)); //0xbf33, 0x8bb4, 0x2f + movl(eax, Address(rsp, 32)); + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(48 + SP)); //0x825b, 0x3997, 0x2b + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(36 + SP)); //0x45f6, 0xb616, 0x1d + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(24 + SP)); //0xc527, 0x0d00, 0x00 + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(12 + SP)); //0x8887, 0x8888, 0x88 + faddp(2); + fxch(1); + fmulp(2); + fld_x(ExternalAddress(SP)); //0xaaab, 0xaaaa, 0xaa + faddp(1); + fmulp(2); + faddp(1); + fld_d(Address(ones, RelocationHolder::none).plus_disp(rsi, Address::times_8)); + fmulp(2); + fmul(1); + faddp(1); + fstp_d(Address(eax, 8)); + jcc(Assembler::equal, B1_32); + + bind(B1_31); + fldcw(Address(esp, 30)); + + bind(B1_32); + addl(esp, 52); + pop(ebx); + pop(edi); + pop(esi); + movl(esp, ebp); + pop(ebp); + ret(0); + + bind(B1_33); + testb(Address(esp, 36), 1); + jcc(Assembler::equal, B1_41); + + bind(B1_34); + fld_s(0); + testb(edx, 2); + fmul(1); + fld_s(0); + fmul(1); + jcc(Assembler::equal, B1_38); + + bind(B1_35); + fld_x(ExternalAddress(84 + SP)); //0x8610, 0x307f, 0x62 + testl(ebx, ebx); + fmul(1); + fld_x(ExternalAddress(72 + SP)); //0x44a6, 0xed1a, 0x29 + fmul(2); + fld_x(ExternalAddress(60 + SP)); //0xbf33, 0x8bb4, 0x2f + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(48 + SP)); //0x825b, 0x3997, 0x2b + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(36 + SP)); //0x45f6, 0xb616, 0x1d + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(24 + SP)); //0xc527, 0x0d00, 0x00 + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(12 + SP)); //0x8887, 0x8888, 0x88 + faddp(2); + fxch(1); + fmulp(2); + fld_x(ExternalAddress(SP)); //0xaaab, 0xaaaa, 0xaa + faddp(1); + fmulp(2); + faddp(1); + fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8)); + fmulp(2); + fmul(1); + movl(eax, Address(esp, 32)); + faddp(1); + fstp_d(Address(eax, 0)); + jcc(Assembler::equal, B1_37); + + bind(B1_36); + fldcw(Address(esp, 30)); + + bind(B1_37); + addl(esp, 52); + pop(ebx); + pop(edi); + pop(esi); + movl(esp, ebp); + pop(ebp); + ret(0); + + bind(B1_38); + fstp_d(2); + fld_x(ExternalAddress(84 + CP)); //0x3ac6, 0x0ba0, 0x07 + testl(ebx, ebx); + fmul(2); + fld_x(ExternalAddress(72 + CP)); //0xdaba, 0xfe79, 0xea + fmul(3); + fld_x(ExternalAddress(60 + CP)); //0xd84d, 0xadee, 0xc6 + faddp(2); + fxch(1); + fmul(3); + fld_x(ExternalAddress(48 + CP)); //0x03fe, 0x3f65, 0x7d + faddp(2); + fxch(1); + fmul(3); + fld_x(ExternalAddress(36 + CP)); //0xf024, 0x0cac, 0x00 + faddp(2); + fxch(1); + fmul(3); + fld_x(ExternalAddress(24 + CP)); //0x9c2f, 0x0b60, 0x60 + faddp(2); + fxch(1); + fmul(3); + fld_x(ExternalAddress(12 + CP)); //0xaaa5, 0xaaaa, 0xaa + faddp(2); + fxch(1); + fmulp(3); + fld_x(ExternalAddress(CP)); //0x0000, 0x0000, 0x00 + faddp(1); + fmulp(1); + faddp(1); + fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8)); + fmula(1); + movl(eax, Address(esp, 32)); + faddp(1); + fstp_d(Address(eax, 0)); + jcc(Assembler::equal, B1_40); + + bind(B1_39); + fldcw(Address(esp, 30)); + bind(B1_40); + addl(esp, 52); + pop(ebx); + pop(edi); + pop(esi); + movl(esp, ebp); + pop(ebp); + ret(0); + bind(B1_41); + fstp_d(0); + addl(esp, 52); + pop(ebx); + pop(edi); + pop(esi); + movl(esp, ebp); + pop(ebp); + ret(0); + bind(B1_42); + xorl(ebx, ebx); + jmp(B1_8); + bind(B1_43); + xorl(ebx, ebx); + jmp(B1_15); +} + +ALIGNED_(16) juint _static_const_table_sin[] = +{ + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, 0xbf73b92eUL, + 0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL, + 0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, + 0xc0000000UL, 0xbc626d19UL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, + 0xbfa60beaUL, 0x2ed59f06UL, 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, + 0x00000000UL, 0x3ff00000UL, 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, + 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, 0x00000000UL, 0x3ff00000UL, + 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, 0x20000000UL, + 0x3c5e0d89UL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, 0xbfc59267UL, + 0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL, + 0x3ff00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, + 0x20000000UL, 0x3c68076aUL, 0x00000000UL, 0x3ff00000UL, 0x99fcef32UL, + 0x3fca8279UL, 0x667f3bcdUL, 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, + 0x00000000UL, 0x3fe00000UL, 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, + 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, 0x00000000UL, 0x3fe00000UL, + 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, 0xe0000000UL, + 0x3c39f630UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, 0xbf9d4a2cUL, + 0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL, + 0x3fe00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0x3fed906bUL, + 0x20000000UL, 0x3c7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x76acf82dUL, + 0x3fa4a031UL, 0x56c62ddaUL, 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, + 0x00000000UL, 0x3fd00000UL, 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, + 0x3fef6297UL, 0x20000000UL, 0x3c756217UL, 0x00000000UL, 0x3fd00000UL, + 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, 0x40000000UL, + 0xbc887df6UL, 0x00000000UL, 0x3fc00000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0x3fefd88dUL, + 0x40000000UL, 0xbc887df6UL, 0x00000000UL, 0xbfc00000UL, 0x0e5967d5UL, + 0x3fac1d1fUL, 0xcff75cb0UL, 0x3fef6297UL, 0x20000000UL, 0x3c756217UL, + 0x00000000UL, 0xbfd00000UL, 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, + 0x3fee9f41UL, 0xe0000000UL, 0x3c8760b1UL, 0x00000000UL, 0xbfd00000UL, + 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, 0x3fed906bUL, 0x20000000UL, + 0x3c7457e6UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, 0x3f9d4a2cUL, + 0xf180bdb1UL, 0x3fec38b2UL, 0x80000000UL, 0xbc76e0b1UL, 0x00000000UL, + 0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0x3fea9b66UL, + 0xe0000000UL, 0x3c39f630UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, + 0xbfc133ccUL, 0x6b151741UL, 0x3fe8bc80UL, 0x20000000UL, 0xbc82c5e1UL, + 0x00000000UL, 0xbfe00000UL, 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, + 0x3fe6a09eUL, 0x20000000UL, 0xbc8bdd34UL, 0x00000000UL, 0xbfe00000UL, + 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, 0x3fe44cf3UL, 0x20000000UL, + 0x3c68076aUL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, 0x3fc59267UL, + 0x39ae68c8UL, 0x3fe1c73bUL, 0x20000000UL, 0x3c8b25ddUL, 0x00000000UL, + 0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0x3fde2b5dUL, + 0x20000000UL, 0x3c5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, + 0x3fb37ca1UL, 0xa6aea963UL, 0x3fd87de2UL, 0xe0000000UL, 0xbc672cedUL, + 0x00000000UL, 0xbff00000UL, 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, + 0x3fd29406UL, 0xa0000000UL, 0xbc75d28dUL, 0x00000000UL, 0xbff00000UL, + 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, 0x3fc8f8b8UL, 0xc0000000UL, + 0xbc626d19UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, 0x3f73b92eUL, + 0xbc29b42cUL, 0x3fb917a6UL, 0xe0000000UL, 0xbc3e2718UL, 0x00000000UL, + 0xbff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x176d6d31UL, + 0x3f73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL, + 0x00000000UL, 0xbff00000UL, 0x011469fbUL, 0x3f93ad06UL, 0x3c69a60bUL, + 0xbfc8f8b8UL, 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0xbff00000UL, + 0x939d225aUL, 0x3fa60beaUL, 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, + 0x3c75d28dUL, 0x00000000UL, 0xbff00000UL, 0x866b95cfUL, 0x3fb37ca1UL, + 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, 0x3c672cedUL, 0x00000000UL, + 0xbff00000UL, 0x73fa1279UL, 0x3fbe3a68UL, 0x3806f63bUL, 0xbfde2b5dUL, + 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0xbff00000UL, 0x5bc57974UL, + 0x3fc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL, + 0x00000000UL, 0xbff00000UL, 0x53aba2fdUL, 0x3fcd0dfeUL, 0x25091dd6UL, + 0xbfe44cf3UL, 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0xbff00000UL, + 0x99fcef32UL, 0xbfca8279UL, 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, + 0x3c8bdd34UL, 0x00000000UL, 0xbfe00000UL, 0x94247758UL, 0xbfc133ccUL, + 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, 0x3c82c5e1UL, 0x00000000UL, + 0xbfe00000UL, 0x9ae68c87UL, 0xbfac73b3UL, 0x290ea1a3UL, 0xbfea9b66UL, + 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0xbfe00000UL, 0x7f909c4eUL, + 0x3f9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL, + 0x00000000UL, 0xbfe00000UL, 0x65455a75UL, 0x3fbe0875UL, 0xcf328d46UL, + 0xbfed906bUL, 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0xbfe00000UL, + 0x76acf82dUL, 0xbfa4a031UL, 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, + 0xbc8760b1UL, 0x00000000UL, 0xbfd00000UL, 0x0e5967d5UL, 0x3fac1d1fUL, + 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, 0xbc756217UL, 0x00000000UL, + 0xbfd00000UL, 0x0f592f50UL, 0x3f9ba165UL, 0xa3d12526UL, 0xbfefd88dUL, + 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0xbfc00000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0xbff00000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x0f592f50UL, 0xbf9ba165UL, 0xa3d12526UL, + 0xbfefd88dUL, 0x40000000UL, 0x3c887df6UL, 0x00000000UL, 0x3fc00000UL, + 0x0e5967d5UL, 0xbfac1d1fUL, 0xcff75cb0UL, 0xbfef6297UL, 0x20000000UL, + 0xbc756217UL, 0x00000000UL, 0x3fd00000UL, 0x76acf82dUL, 0x3fa4a031UL, + 0x56c62ddaUL, 0xbfee9f41UL, 0xe0000000UL, 0xbc8760b1UL, 0x00000000UL, + 0x3fd00000UL, 0x65455a75UL, 0xbfbe0875UL, 0xcf328d46UL, 0xbfed906bUL, + 0x20000000UL, 0xbc7457e6UL, 0x00000000UL, 0x3fe00000UL, 0x7f909c4eUL, + 0xbf9d4a2cUL, 0xf180bdb1UL, 0xbfec38b2UL, 0x80000000UL, 0x3c76e0b1UL, + 0x00000000UL, 0x3fe00000UL, 0x9ae68c87UL, 0x3fac73b3UL, 0x290ea1a3UL, + 0xbfea9b66UL, 0xe0000000UL, 0xbc39f630UL, 0x00000000UL, 0x3fe00000UL, + 0x94247758UL, 0x3fc133ccUL, 0x6b151741UL, 0xbfe8bc80UL, 0x20000000UL, + 0x3c82c5e1UL, 0x00000000UL, 0x3fe00000UL, 0x99fcef32UL, 0x3fca8279UL, + 0x667f3bcdUL, 0xbfe6a09eUL, 0x20000000UL, 0x3c8bdd34UL, 0x00000000UL, + 0x3fe00000UL, 0x53aba2fdUL, 0xbfcd0dfeUL, 0x25091dd6UL, 0xbfe44cf3UL, + 0x20000000UL, 0xbc68076aUL, 0x00000000UL, 0x3ff00000UL, 0x5bc57974UL, + 0xbfc59267UL, 0x39ae68c8UL, 0xbfe1c73bUL, 0x20000000UL, 0xbc8b25ddUL, + 0x00000000UL, 0x3ff00000UL, 0x73fa1279UL, 0xbfbe3a68UL, 0x3806f63bUL, + 0xbfde2b5dUL, 0x20000000UL, 0xbc5e0d89UL, 0x00000000UL, 0x3ff00000UL, + 0x866b95cfUL, 0xbfb37ca1UL, 0xa6aea963UL, 0xbfd87de2UL, 0xe0000000UL, + 0x3c672cedUL, 0x00000000UL, 0x3ff00000UL, 0x939d225aUL, 0xbfa60beaUL, + 0x2ed59f06UL, 0xbfd29406UL, 0xa0000000UL, 0x3c75d28dUL, 0x00000000UL, + 0x3ff00000UL, 0x011469fbUL, 0xbf93ad06UL, 0x3c69a60bUL, 0xbfc8f8b8UL, + 0xc0000000UL, 0x3c626d19UL, 0x00000000UL, 0x3ff00000UL, 0x176d6d31UL, + 0xbf73b92eUL, 0xbc29b42cUL, 0xbfb917a6UL, 0xe0000000UL, 0x3c3e2718UL, + 0x00000000UL, 0x3ff00000UL, 0x55555555UL, 0xbfc55555UL, 0x00000000UL, + 0xbfe00000UL, 0x11111111UL, 0x3f811111UL, 0x55555555UL, 0x3fa55555UL, + 0x1a01a01aUL, 0xbf2a01a0UL, 0x16c16c17UL, 0xbf56c16cUL, 0xa556c734UL, + 0x3ec71de3UL, 0x1a01a01aUL, 0x3efa01a0UL, 0x1a600000UL, 0x3d90b461UL, + 0x1a600000UL, 0x3d90b461UL, 0x54400000UL, 0x3fb921fbUL, 0x00000000UL, + 0x00000000UL, 0x2e037073UL, 0x3b63198aUL, 0x00000000UL, 0x00000000UL, + 0x6dc9c883UL, 0x40245f30UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x43380000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x43600000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x3c800000UL, 0x00000000UL, + 0x00000000UL, 0xffffffffUL, 0x3fefffffUL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x80000000UL, 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x3fe00000UL, + 0x00000000UL, 0x3fe00000UL +}; + +void MacroAssembler::fast_sin(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ebx, Register edx) { + + Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; + Label L_2TAG_PACKET_4_0_2, start; + assert_different_registers(eax, ebx, edx); + address static_const_table_sin = (address)_static_const_table_sin; + + bind(start); + subl(rsp, 120); + movl(Address(rsp, 56), ebx); + lea(ebx, ExternalAddress(static_const_table_sin)); + movsd(xmm0, Address(rsp, 128)); + pextrw(eax, xmm0, 3); + andl(eax, 32767); + subl(eax, 12336); + cmpl(eax, 4293); + jcc(Assembler::above, L_2TAG_PACKET_0_0_2); + movsd(xmm1, Address(ebx, 2160)); + mulsd(xmm1, xmm0); + movsd(xmm5, Address(ebx, 2272)); + movdqu(xmm4, Address(ebx, 2256)); + pand(xmm4, xmm0); + por(xmm5, xmm4); + movsd(xmm3, Address(ebx, 2128)); + movdqu(xmm2, Address(ebx, 2112)); + addpd(xmm1, xmm5); + cvttsd2sil(edx, xmm1); + cvtsi2sdl(xmm1, edx); + mulsd(xmm3, xmm1); + unpcklpd(xmm1, xmm1); + addl(edx, 1865216); + movdqu(xmm4, xmm0); + andl(edx, 63); + movdqu(xmm5, Address(ebx, 2096)); + lea(eax, Address(ebx, 0)); + shll(edx, 5); + addl(eax, edx); + mulpd(xmm2, xmm1); + subsd(xmm0, xmm3); + mulsd(xmm1, Address(ebx, 2144)); + subsd(xmm4, xmm3); + movsd(xmm7, Address(eax, 8)); + unpcklpd(xmm0, xmm0); + movapd(xmm3, xmm4); + subsd(xmm4, xmm2); + mulpd(xmm5, xmm0); + subpd(xmm0, xmm2); + movdqu(xmm6, Address(ebx, 2064)); + mulsd(xmm7, xmm4); + subsd(xmm3, xmm4); + mulpd(xmm5, xmm0); + mulpd(xmm0, xmm0); + subsd(xmm3, xmm2); + movdqu(xmm2, Address(eax, 0)); + subsd(xmm1, xmm3); + movsd(xmm3, Address(eax, 24)); + addsd(xmm2, xmm3); + subsd(xmm7, xmm2); + mulsd(xmm2, xmm4); + mulpd(xmm6, xmm0); + mulsd(xmm3, xmm4); + mulpd(xmm2, xmm0); + mulpd(xmm0, xmm0); + addpd(xmm5, Address(ebx, 2080)); + mulsd(xmm4, Address(eax, 0)); + addpd(xmm6, Address(ebx, 2048)); + mulpd(xmm5, xmm0); + movapd(xmm0, xmm3); + addsd(xmm3, Address(eax, 8)); + mulpd(xmm1, xmm7); + movapd(xmm7, xmm4); + addsd(xmm4, xmm3); + addpd(xmm6, xmm5); + movsd(xmm5, Address(eax, 8)); + subsd(xmm5, xmm3); + subsd(xmm3, xmm4); + addsd(xmm1, Address(eax, 16)); + mulpd(xmm6, xmm2); + addsd(xmm5, xmm0); + addsd(xmm3, xmm7); + addsd(xmm1, xmm5); + addsd(xmm1, xmm3); + addsd(xmm1, xmm6); + unpckhpd(xmm6, xmm6); + addsd(xmm1, xmm6); + addsd(xmm4, xmm1); + movsd(Address(rsp, 0), xmm4); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_0_0_2); + jcc(Assembler::greater, L_2TAG_PACKET_2_0_2); + shrl(eax, 4); + cmpl(eax, 268434685); + jcc(Assembler::notEqual, L_2TAG_PACKET_3_0_2); + movsd(Address(rsp, 0), xmm0); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_3_0_2); + movsd(xmm3, Address(ebx, 2192)); + mulsd(xmm3, xmm0); + subsd(xmm3, xmm0); + mulsd(xmm3, Address(ebx, 2208)); + movsd(Address(rsp, 0), xmm0); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_2_0_2); + movl(eax, Address(rsp, 132)); + andl(eax, 2146435072); + cmpl(eax, 2146435072); + jcc(Assembler::equal, L_2TAG_PACKET_4_0_2); + subl(rsp, 32); + movsd(Address(rsp, 0), xmm0); + lea(eax, Address(rsp, 40)); + movl(Address(rsp, 8), eax); + movl(eax, 2); + movl(Address(rsp, 12), eax); + call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_sin_cos_huge()))); + addl(rsp, 32); + fld_d(Address(rsp, 16)); + jmp(L_2TAG_PACKET_1_0_2); + bind(L_2TAG_PACKET_4_0_2); + fld_d(Address(rsp, 128)); + fmul_d(Address(ebx, 2240)); + bind(L_2TAG_PACKET_1_0_2); + movl(ebx, Address(rsp, 56)); +} +#endif diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_tan.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_tan.cpp new file mode 100644 index 00000000000..18fe151cd33 --- /dev/null +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_tan.cpp @@ -0,0 +1,2144 @@ +/* +* Copyright (c) 2016, Intel Corporation. +* Intel Math Library (LIBM) Source Code +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License version 2 only, as +* published by the Free Software Foundation. +* +* This code is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* version 2 for more details (a copy is included in the LICENSE file that +* accompanied this code). +* +* You should have received a copy of the GNU General Public License version +* 2 along with this work; if not, write to the Free Software Foundation, +* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +* +* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +* or visit www.oracle.com if you need additional information or have any +* questions. +* +*/ + +#include "precompiled.hpp" +#include "asm/assembler.hpp" +#include "asm/assembler.inline.hpp" +#include "runtime/stubRoutines.hpp" +#include "macroAssembler_x86.hpp" + +#ifdef _MSC_VER +#define ALIGNED_(x) __declspec(align(x)) +#else +#define ALIGNED_(x) __attribute__ ((aligned(x))) +#endif + +/******************************************************************************/ +// ALGORITHM DESCRIPTION - TAN() +// --------------------- +// +// Polynomials coefficients and other constants. +// +// Note that in this algorithm, there is a different polynomial for +// each breakpoint, so there are 32 sets of polynomial coefficients +// as well as 32 instances of the other constants. +// +// The polynomial coefficients and constants are offset from the start +// of the main block as follows: +// +// 0: c8 | c0 +// 16: c9 | c1 +// 32: c10 | c2 +// 48: c11 | c3 +// 64: c12 | c4 +// 80: c13 | c5 +// 96: c14 | c6 +// 112: c15 | c7 +// 128: T_hi +// 136: T_lo +// 144: Sigma +// 152: T_hl +// 160: Tau +// 168: Mask +// 176: (end of block) +// +// The total table size is therefore 5632 bytes. +// +// Note that c0 and c1 are always zero. We could try storing +// other constants here, and just loading the low part of the +// SIMD register in these cases, after ensuring the high part +// is zero. +// +// The higher terms of the polynomial are computed in the *low* +// part of the SIMD register. This is so we can overlap the +// multiplication by r^8 and the unpacking of the other part. +// +// The constants are: +// T_hi + T_lo = accurate constant term in power series +// Sigma + T_hl = accurate coefficient of r in power series (Sigma=1 bit) +// Tau = multiplier for the reciprocal, always -1 or 0 +// +// The basic reconstruction formula using these constants is: +// +// High = tau * recip_hi + t_hi +// Med = (sgn * r + t_hl * r)_hi +// Low = (sgn * r + t_hl * r)_lo + +// tau * recip_lo + T_lo + (T_hl + sigma) * c + pol +// +// where pol = c0 + c1 * r + c2 * r^2 + ... + c15 * r^15 +// +// (c0 = c1 = 0, but using them keeps SIMD regularity) +// +// We then do a compensated sum High + Med, add the low parts together +// and then do the final sum. +// +// Here recip_hi + recip_lo is an accurate reciprocal of the remainder +// modulo pi/2 +// +// Special cases: +// tan(NaN) = quiet NaN, and raise invalid exception +// tan(INF) = NaN and raise invalid exception +// tan(+/-0) = +/-0 +// +/******************************************************************************/ + +#ifdef _LP64 +// The 64 bit code is at most SSE2 compliant +ALIGNED_(16) juint _ONEHALF_tan[] = +{ + 0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL +}; + +ALIGNED_(16) juint _MUL16[] = +{ + 0x00000000UL, 0x40300000UL, 0x00000000UL, 0x3ff00000UL +}; + +ALIGNED_(16) juint _sign_mask_tan[] = +{ + 0x00000000UL, 0x80000000UL, 0x00000000UL, 0x80000000UL +}; + +ALIGNED_(16) juint _PI32INV_tan[] = +{ + 0x6dc9c883UL, 0x3fe45f30UL, 0x6dc9c883UL, 0x40245f30UL +}; + +ALIGNED_(16) juint _P_1_tan[] = +{ + 0x54444000UL, 0x3fb921fbUL, 0x54440000UL, 0x3fb921fbUL +}; + +ALIGNED_(16) juint _P_2_tan[] = +{ + 0x67674000UL, 0xbd32e7b9UL, 0x4c4c0000UL, 0x3d468c23UL +}; + +ALIGNED_(16) juint _P_3_tan[] = +{ + 0x3707344aUL, 0x3aa8a2e0UL, 0x03707345UL, 0x3ae98a2eUL +}; + +ALIGNED_(16) juint _Ctable_tan[] = +{ + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x882c10faUL, + 0x3f9664f4UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x55e6c23dUL, 0x3f8226e3UL, 0x55555555UL, + 0x3fd55555UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x0e157de0UL, 0x3f6d6d3dUL, 0x11111111UL, 0x3fc11111UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x452b75e3UL, 0x3f57da36UL, + 0x1ba1ba1cUL, 0x3faba1baUL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x4e435f9bUL, + 0x3f953f83UL, 0x00000000UL, 0x00000000UL, 0x3c6e8e46UL, 0x3f9b74eaUL, + 0x00000000UL, 0x00000000UL, 0xda5b7511UL, 0x3f85ad63UL, 0xdc230b9bUL, + 0x3fb97558UL, 0x26cb3788UL, 0x3f881308UL, 0x76fc4985UL, 0x3fd62ac9UL, + 0x77bb08baUL, 0x3f757c85UL, 0xb6247521UL, 0x3fb1381eUL, 0x5922170cUL, + 0x3f754e95UL, 0x8746482dUL, 0x3fc27f83UL, 0x11055b30UL, 0x3f64e391UL, + 0x3e666320UL, 0x3fa3e609UL, 0x0de9dae3UL, 0x3f6301dfUL, 0x1f1dca06UL, + 0x3fafa8aeUL, 0x8c5b2da2UL, 0x3fb936bbUL, 0x4e88f7a5UL, 0x3c587d05UL, + 0x00000000UL, 0x3ff00000UL, 0xa8935dd9UL, 0x3f83dde2UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x5a279ea3UL, 0x3faa3407UL, + 0x00000000UL, 0x00000000UL, 0x432d65faUL, 0x3fa70153UL, 0x00000000UL, + 0x00000000UL, 0x891a4602UL, 0x3f9d03efUL, 0xd62ca5f8UL, 0x3fca77d9UL, + 0xb35f4628UL, 0x3f97a265UL, 0x433258faUL, 0x3fd8cf51UL, 0xb58fd909UL, + 0x3f8f88e3UL, 0x01771ceaUL, 0x3fc2b154UL, 0xf3562f8eUL, 0x3f888f57UL, + 0xc028a723UL, 0x3fc7370fUL, 0x20b7f9f0UL, 0x3f80f44cUL, 0x214368e9UL, + 0x3fb6dfaaUL, 0x28891863UL, 0x3f79b4b6UL, 0x172dbbf0UL, 0x3fb6cb8eUL, + 0xe0553158UL, 0x3fc975f5UL, 0x593fe814UL, 0x3c2ef5d3UL, 0x00000000UL, + 0x3ff00000UL, 0x03dec550UL, 0x3fa44203UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x9314533eUL, 0x3fbb8ec5UL, 0x00000000UL, + 0x00000000UL, 0x09aa36d0UL, 0x3fb6d3f4UL, 0x00000000UL, 0x00000000UL, + 0xdcb427fdUL, 0x3fb13950UL, 0xd87ab0bbUL, 0x3fd5335eUL, 0xce0ae8a5UL, + 0x3fabb382UL, 0x79143126UL, 0x3fddba41UL, 0x5f2b28d4UL, 0x3fa552f1UL, + 0x59f21a6dUL, 0x3fd015abUL, 0x22c27d95UL, 0x3fa0e984UL, 0xe19fc6aaUL, + 0x3fd0576cUL, 0x8f2c2950UL, 0x3f9a4898UL, 0xc0b3f22cUL, 0x3fc59462UL, + 0x1883a4b8UL, 0x3f94b61cUL, 0x3f838640UL, 0x3fc30eb8UL, 0x355c63dcUL, + 0x3fd36a08UL, 0x1dce993dUL, 0xbc6d704dUL, 0x00000000UL, 0x3ff00000UL, + 0x2b82ab63UL, 0x3fb78e92UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x56f37042UL, 0x3fccfc56UL, 0x00000000UL, 0x00000000UL, + 0xaa563951UL, 0x3fc90125UL, 0x00000000UL, 0x00000000UL, 0x3d0e7c5dUL, + 0x3fc50533UL, 0x9bed9b2eUL, 0x3fdf0ed9UL, 0x5fe7c47cUL, 0x3fc1f250UL, + 0x96c125e5UL, 0x3fe2edd9UL, 0x5a02bbd8UL, 0x3fbe5c71UL, 0x86362c20UL, + 0x3fda08b7UL, 0x4b4435edUL, 0x3fb9d342UL, 0x4b494091UL, 0x3fd911bdUL, + 0xb56658beUL, 0x3fb5e4c7UL, 0x93a2fd76UL, 0x3fd3c092UL, 0xda271794UL, + 0x3fb29910UL, 0x3303df2bUL, 0x3fd189beUL, 0x99fcef32UL, 0x3fda8279UL, + 0xb68c1467UL, 0x3c708b2fUL, 0x00000000UL, 0x3ff00000UL, 0x980c4337UL, + 0x3fc5f619UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0xcc03e501UL, 0x3fdff10fUL, 0x00000000UL, 0x00000000UL, 0x44a4e845UL, + 0x3fddb63bUL, 0x00000000UL, 0x00000000UL, 0x3768ad9fUL, 0x3fdb72a4UL, + 0x3dd01ccaUL, 0x3fe5fdb9UL, 0xa61d2811UL, 0x3fd972b2UL, 0x5645ad0bUL, + 0x3fe977f9UL, 0xd013b3abUL, 0x3fd78ca3UL, 0xbf0bf914UL, 0x3fe4f192UL, + 0x4d53e730UL, 0x3fd5d060UL, 0x3f8b9000UL, 0x3fe49933UL, 0xe2b82f08UL, + 0x3fd4322aUL, 0x5936a835UL, 0x3fe27ae1UL, 0xb1c61c9bUL, 0x3fd2b3fbUL, + 0xef478605UL, 0x3fe1659eUL, 0x190834ecUL, 0x3fe11ab7UL, 0xcdb625eaUL, + 0xbc8e564bUL, 0x00000000UL, 0x3ff00000UL, 0xb07217e3UL, 0x3fd248f1UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x2b2c49d0UL, + 0x3ff2de9cUL, 0x00000000UL, 0x00000000UL, 0x2655bc98UL, 0x3ff33e58UL, + 0x00000000UL, 0x00000000UL, 0xff691fa2UL, 0x3ff3972eUL, 0xe93463bdUL, + 0x3feeed87UL, 0x070e10a0UL, 0x3ff3f5b2UL, 0xf4d790a4UL, 0x3ff20c10UL, + 0xa04e8ea3UL, 0x3ff4541aUL, 0x386accd3UL, 0x3ff1369eUL, 0x222a66ddUL, + 0x3ff4b521UL, 0x22a9777eUL, 0x3ff20817UL, 0x52a04a6eUL, 0x3ff5178fUL, + 0xddaa0031UL, 0x3ff22137UL, 0x4447d47cUL, 0x3ff57c01UL, 0x1e9c7f1dUL, + 0x3ff29311UL, 0x2ab7f990UL, 0x3fe561b8UL, 0x209c7df1UL, 0x3c87a8c5UL, + 0x00000000UL, 0x3ff00000UL, 0x4170bcc6UL, 0x3fdc92d8UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xc7ab4d5aUL, 0x40085e24UL, + 0x00000000UL, 0x00000000UL, 0xe93ea75dUL, 0x400b963dUL, 0x00000000UL, + 0x00000000UL, 0x94a7f25aUL, 0x400f37e2UL, 0x4b6261cbUL, 0x3ff5f984UL, + 0x5a9dd812UL, 0x4011aab0UL, 0x74c30018UL, 0x3ffaf5a5UL, 0x7f2ce8e3UL, + 0x4013fe8bUL, 0xfe8e54faUL, 0x3ffd7334UL, 0x670d618dUL, 0x4016a10cUL, + 0x4db97058UL, 0x4000e012UL, 0x24df44ddUL, 0x40199c5fUL, 0x697d6eceUL, + 0x4003006eUL, 0x83298b82UL, 0x401cfc4dUL, 0x19d490d6UL, 0x40058c19UL, + 0x2ae42850UL, 0x3fea4300UL, 0x118e20e6UL, 0xbc7a6db8UL, 0x00000000UL, + 0x40000000UL, 0xe33345b8UL, 0xbfd4e526UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x65965966UL, 0x40219659UL, 0x00000000UL, + 0x00000000UL, 0x882c10faUL, 0x402664f4UL, 0x00000000UL, 0x00000000UL, + 0x83cd3723UL, 0x402c8342UL, 0x00000000UL, 0x40000000UL, 0x55e6c23dUL, + 0x403226e3UL, 0x55555555UL, 0x40055555UL, 0x34451939UL, 0x40371c96UL, + 0xaaaaaaabUL, 0x400aaaaaUL, 0x0e157de0UL, 0x403d6d3dUL, 0x11111111UL, + 0x40111111UL, 0xa738201fUL, 0x4042bbceUL, 0x05b05b06UL, 0x4015b05bUL, + 0x452b75e3UL, 0x4047da36UL, 0x1ba1ba1cUL, 0x401ba1baUL, 0x00000000UL, + 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x40000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x4f48b8d3UL, 0xbf33eaf9UL, 0x00000000UL, 0x00000000UL, + 0x0cf7586fUL, 0x3f20b8eaUL, 0x00000000UL, 0x00000000UL, 0xd0258911UL, + 0xbf0abaf3UL, 0x23e49fe9UL, 0xbfab5a8cUL, 0x2d53222eUL, 0x3ef60d15UL, + 0x21169451UL, 0x3fa172b2UL, 0xbb254dbcUL, 0xbee1d3b5UL, 0xdbf93b8eUL, + 0xbf84c7dbUL, 0x05b4630bUL, 0x3ecd3364UL, 0xee9aada7UL, 0x3f743924UL, + 0x794a8297UL, 0xbeb7b7b9UL, 0xe015f797UL, 0xbf5d41f5UL, 0xe41a4a56UL, + 0x3ea35dfbUL, 0xe4c2a251UL, 0x3f49a2abUL, 0x5af9e000UL, 0xbfce49ceUL, + 0x8c743719UL, 0x3d1eb860UL, 0x00000000UL, 0x00000000UL, 0x1b4863cfUL, + 0x3fd78294UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, + 0x535ad890UL, 0xbf2b9320UL, 0x00000000UL, 0x00000000UL, 0x018fdf1fUL, + 0x3f16d61dUL, 0x00000000UL, 0x00000000UL, 0x0359f1beUL, 0xbf0139e4UL, + 0xa4317c6dUL, 0xbfa67e17UL, 0x82672d0fUL, 0x3eebb405UL, 0x2f1b621eUL, + 0x3f9f455bUL, 0x51ccf238UL, 0xbed55317UL, 0xf437b9acUL, 0xbf804beeUL, + 0xc791a2b5UL, 0x3ec0e993UL, 0x919a1db2UL, 0x3f7080c2UL, 0x336a5b0eUL, + 0xbeaa48a2UL, 0x0a268358UL, 0xbf55a443UL, 0xdfd978e4UL, 0x3e94b61fUL, + 0xd7767a58UL, 0x3f431806UL, 0x2aea0000UL, 0xbfc9bbe8UL, 0x7723ea61UL, + 0xbd3a2369UL, 0x00000000UL, 0x00000000UL, 0xdf7796ffUL, 0x3fd6e642UL, + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0xb9ff07ceUL, + 0xbf231c78UL, 0x00000000UL, 0x00000000UL, 0xa5517182UL, 0x3f0ff0e0UL, + 0x00000000UL, 0x00000000UL, 0x790b4cbcUL, 0xbef66191UL, 0x848a46c6UL, + 0xbfa21ac0UL, 0xb16435faUL, 0x3ee1d3ecUL, 0x2a1aa832UL, 0x3f9c71eaUL, + 0xfdd299efUL, 0xbec9dd1aUL, 0x3f8dbaafUL, 0xbf793363UL, 0x309fc6eaUL, + 0x3eb415d6UL, 0xbee60471UL, 0x3f6b83baUL, 0x94a0a697UL, 0xbe9dae11UL, + 0x3e5c67b3UL, 0xbf4fd07bUL, 0x9a8f3e3eUL, 0x3e86bd75UL, 0xa4beb7a4UL, + 0x3f3d1eb1UL, 0x29cfc000UL, 0xbfc549ceUL, 0xbf159358UL, 0xbd397b33UL, + 0x00000000UL, 0x00000000UL, 0x871fee6cUL, 0x3fd666f0UL, 0x00000000UL, + 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x7d98a556UL, 0xbf1a3958UL, + 0x00000000UL, 0x00000000UL, 0x9d88dc01UL, 0x3f0704c2UL, 0x00000000UL, + 0x00000000UL, 0x73742a2bUL, 0xbeed054aUL, 0x58844587UL, 0xbf9c2a13UL, + 0x55688a79UL, 0x3ed7a326UL, 0xee33f1d6UL, 0x3f9a48f4UL, 0xa8dc9888UL, + 0xbebf8939UL, 0xaad4b5b8UL, 0xbf72f746UL, 0x9102efa1UL, 0x3ea88f82UL, + 0xdabc29cfUL, 0x3f678228UL, 0x9289afb8UL, 0xbe90f456UL, 0x741fb4edUL, + 0xbf46f3a3UL, 0xa97f6663UL, 0x3e79b4bfUL, 0xca89ff3fUL, 0x3f36db70UL, + 0xa8a2a000UL, 0xbfc0ee13UL, 0x3da24be1UL, 0xbd338b9fUL, 0x00000000UL, + 0x00000000UL, 0x11cd6c69UL, 0x3fd601fdUL, 0x00000000UL, 0x3ff00000UL, + 0x00000000UL, 0xfffffff8UL, 0x1a154b97UL, 0xbf116b01UL, 0x00000000UL, + 0x00000000UL, 0x2d427630UL, 0x3f0147bfUL, 0x00000000UL, 0x00000000UL, + 0xb93820c8UL, 0xbee264d4UL, 0xbb6cbb18UL, 0xbf94ab8cUL, 0x888d4d92UL, + 0x3ed0568bUL, 0x60730f7cUL, 0x3f98b19bUL, 0xe4b1fb11UL, 0xbeb2f950UL, + 0x22cf9f74UL, 0xbf6b21cdUL, 0x4a3ff0a6UL, 0x3e9f499eUL, 0xfd2b83ceUL, + 0x3f64aad7UL, 0x637b73afUL, 0xbe83487cUL, 0xe522591aUL, 0xbf3fc092UL, + 0xa158e8bcUL, 0x3e6e3aaeUL, 0xe5e82ffaUL, 0x3f329d2fUL, 0xd636a000UL, + 0xbfb9477fUL, 0xc2c2d2bcUL, 0xbd135ef9UL, 0x00000000UL, 0x00000000UL, + 0xf2fdb123UL, 0x3fd5b566UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, + 0xfffffff8UL, 0xc41acb64UL, 0xbf05448dUL, 0x00000000UL, 0x00000000UL, + 0xdbb03d6fUL, 0x3efb7ad2UL, 0x00000000UL, 0x00000000UL, 0x9e42962dUL, + 0xbed5aea5UL, 0x2579f8efUL, 0xbf8b2398UL, 0x288a1ed9UL, 0x3ec81441UL, + 0xb0198dc5UL, 0x3f979a3aUL, 0x2fdfe253UL, 0xbea57cd3UL, 0x5766336fUL, + 0xbf617caaUL, 0x600944c3UL, 0x3e954ed6UL, 0xa4e0aaf8UL, 0x3f62c646UL, + 0x6b8fb29cUL, 0xbe74e3a3UL, 0xdc4c0409UL, 0xbf33f952UL, 0x9bffe365UL, + 0x3e6301ecUL, 0xb8869e44UL, 0x3f2fc566UL, 0xe1e04000UL, 0xbfb0cc62UL, + 0x016b907fUL, 0xbd119cbcUL, 0x00000000UL, 0x00000000UL, 0xe6b9d8faUL, + 0x3fd57fb3UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, + 0x5daf22a6UL, 0xbef429d7UL, 0x00000000UL, 0x00000000UL, 0x06bca545UL, + 0x3ef7a27dUL, 0x00000000UL, 0x00000000UL, 0x7211c19aUL, 0xbec41c3eUL, + 0x956ed53eUL, 0xbf7ae3f4UL, 0xee750e72UL, 0x3ec3901bUL, 0x91d443f5UL, + 0x3f96f713UL, 0x36661e6cUL, 0xbe936e09UL, 0x506f9381UL, 0xbf5122e8UL, + 0xcb6dd43fUL, 0x3e9041b9UL, 0x6698b2ffUL, 0x3f61b0c7UL, 0x576bf12bUL, + 0xbe625a8aUL, 0xe5a0e9dcUL, 0xbf23499dUL, 0x110384ddUL, 0x3e5b1c2cUL, + 0x68d43db6UL, 0x3f2cb899UL, 0x6ecac000UL, 0xbfa0c414UL, 0xcd7dd58cUL, + 0x3d13500fUL, 0x00000000UL, 0x00000000UL, 0x85a2c8fbUL, 0x3fd55fe0UL, + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x2bf70ebeUL, 0x3ef66a8fUL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0xd644267fUL, 0x3ec22805UL, 0x16c16c17UL, 0x3f96c16cUL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xc4e09162UL, + 0x3e8d6db2UL, 0xbc011567UL, 0x3f61566aUL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x1f79955cUL, 0x3e57da4eUL, 0x9334ef0bUL, + 0x3f2bbd77UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x55555555UL, 0x3fd55555UL, 0x00000000UL, + 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x5daf22a6UL, 0x3ef429d7UL, + 0x00000000UL, 0x00000000UL, 0x06bca545UL, 0x3ef7a27dUL, 0x00000000UL, + 0x00000000UL, 0x7211c19aUL, 0x3ec41c3eUL, 0x956ed53eUL, 0x3f7ae3f4UL, + 0xee750e72UL, 0x3ec3901bUL, 0x91d443f5UL, 0x3f96f713UL, 0x36661e6cUL, + 0x3e936e09UL, 0x506f9381UL, 0x3f5122e8UL, 0xcb6dd43fUL, 0x3e9041b9UL, + 0x6698b2ffUL, 0x3f61b0c7UL, 0x576bf12bUL, 0x3e625a8aUL, 0xe5a0e9dcUL, + 0x3f23499dUL, 0x110384ddUL, 0x3e5b1c2cUL, 0x68d43db6UL, 0x3f2cb899UL, + 0x6ecac000UL, 0x3fa0c414UL, 0xcd7dd58cUL, 0xbd13500fUL, 0x00000000UL, + 0x00000000UL, 0x85a2c8fbUL, 0x3fd55fe0UL, 0x00000000UL, 0x3ff00000UL, + 0x00000000UL, 0xfffffff8UL, 0xc41acb64UL, 0x3f05448dUL, 0x00000000UL, + 0x00000000UL, 0xdbb03d6fUL, 0x3efb7ad2UL, 0x00000000UL, 0x00000000UL, + 0x9e42962dUL, 0x3ed5aea5UL, 0x2579f8efUL, 0x3f8b2398UL, 0x288a1ed9UL, + 0x3ec81441UL, 0xb0198dc5UL, 0x3f979a3aUL, 0x2fdfe253UL, 0x3ea57cd3UL, + 0x5766336fUL, 0x3f617caaUL, 0x600944c3UL, 0x3e954ed6UL, 0xa4e0aaf8UL, + 0x3f62c646UL, 0x6b8fb29cUL, 0x3e74e3a3UL, 0xdc4c0409UL, 0x3f33f952UL, + 0x9bffe365UL, 0x3e6301ecUL, 0xb8869e44UL, 0x3f2fc566UL, 0xe1e04000UL, + 0x3fb0cc62UL, 0x016b907fUL, 0x3d119cbcUL, 0x00000000UL, 0x00000000UL, + 0xe6b9d8faUL, 0x3fd57fb3UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, + 0xfffffff8UL, 0x1a154b97UL, 0x3f116b01UL, 0x00000000UL, 0x00000000UL, + 0x2d427630UL, 0x3f0147bfUL, 0x00000000UL, 0x00000000UL, 0xb93820c8UL, + 0x3ee264d4UL, 0xbb6cbb18UL, 0x3f94ab8cUL, 0x888d4d92UL, 0x3ed0568bUL, + 0x60730f7cUL, 0x3f98b19bUL, 0xe4b1fb11UL, 0x3eb2f950UL, 0x22cf9f74UL, + 0x3f6b21cdUL, 0x4a3ff0a6UL, 0x3e9f499eUL, 0xfd2b83ceUL, 0x3f64aad7UL, + 0x637b73afUL, 0x3e83487cUL, 0xe522591aUL, 0x3f3fc092UL, 0xa158e8bcUL, + 0x3e6e3aaeUL, 0xe5e82ffaUL, 0x3f329d2fUL, 0xd636a000UL, 0x3fb9477fUL, + 0xc2c2d2bcUL, 0x3d135ef9UL, 0x00000000UL, 0x00000000UL, 0xf2fdb123UL, + 0x3fd5b566UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, + 0x7d98a556UL, 0x3f1a3958UL, 0x00000000UL, 0x00000000UL, 0x9d88dc01UL, + 0x3f0704c2UL, 0x00000000UL, 0x00000000UL, 0x73742a2bUL, 0x3eed054aUL, + 0x58844587UL, 0x3f9c2a13UL, 0x55688a79UL, 0x3ed7a326UL, 0xee33f1d6UL, + 0x3f9a48f4UL, 0xa8dc9888UL, 0x3ebf8939UL, 0xaad4b5b8UL, 0x3f72f746UL, + 0x9102efa1UL, 0x3ea88f82UL, 0xdabc29cfUL, 0x3f678228UL, 0x9289afb8UL, + 0x3e90f456UL, 0x741fb4edUL, 0x3f46f3a3UL, 0xa97f6663UL, 0x3e79b4bfUL, + 0xca89ff3fUL, 0x3f36db70UL, 0xa8a2a000UL, 0x3fc0ee13UL, 0x3da24be1UL, + 0x3d338b9fUL, 0x00000000UL, 0x00000000UL, 0x11cd6c69UL, 0x3fd601fdUL, + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0xb9ff07ceUL, + 0x3f231c78UL, 0x00000000UL, 0x00000000UL, 0xa5517182UL, 0x3f0ff0e0UL, + 0x00000000UL, 0x00000000UL, 0x790b4cbcUL, 0x3ef66191UL, 0x848a46c6UL, + 0x3fa21ac0UL, 0xb16435faUL, 0x3ee1d3ecUL, 0x2a1aa832UL, 0x3f9c71eaUL, + 0xfdd299efUL, 0x3ec9dd1aUL, 0x3f8dbaafUL, 0x3f793363UL, 0x309fc6eaUL, + 0x3eb415d6UL, 0xbee60471UL, 0x3f6b83baUL, 0x94a0a697UL, 0x3e9dae11UL, + 0x3e5c67b3UL, 0x3f4fd07bUL, 0x9a8f3e3eUL, 0x3e86bd75UL, 0xa4beb7a4UL, + 0x3f3d1eb1UL, 0x29cfc000UL, 0x3fc549ceUL, 0xbf159358UL, 0x3d397b33UL, + 0x00000000UL, 0x00000000UL, 0x871fee6cUL, 0x3fd666f0UL, 0x00000000UL, + 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x535ad890UL, 0x3f2b9320UL, + 0x00000000UL, 0x00000000UL, 0x018fdf1fUL, 0x3f16d61dUL, 0x00000000UL, + 0x00000000UL, 0x0359f1beUL, 0x3f0139e4UL, 0xa4317c6dUL, 0x3fa67e17UL, + 0x82672d0fUL, 0x3eebb405UL, 0x2f1b621eUL, 0x3f9f455bUL, 0x51ccf238UL, + 0x3ed55317UL, 0xf437b9acUL, 0x3f804beeUL, 0xc791a2b5UL, 0x3ec0e993UL, + 0x919a1db2UL, 0x3f7080c2UL, 0x336a5b0eUL, 0x3eaa48a2UL, 0x0a268358UL, + 0x3f55a443UL, 0xdfd978e4UL, 0x3e94b61fUL, 0xd7767a58UL, 0x3f431806UL, + 0x2aea0000UL, 0x3fc9bbe8UL, 0x7723ea61UL, 0x3d3a2369UL, 0x00000000UL, + 0x00000000UL, 0xdf7796ffUL, 0x3fd6e642UL, 0x00000000UL, 0x3ff00000UL, + 0x00000000UL, 0xfffffff8UL, 0x4f48b8d3UL, 0x3f33eaf9UL, 0x00000000UL, + 0x00000000UL, 0x0cf7586fUL, 0x3f20b8eaUL, 0x00000000UL, 0x00000000UL, + 0xd0258911UL, 0x3f0abaf3UL, 0x23e49fe9UL, 0x3fab5a8cUL, 0x2d53222eUL, + 0x3ef60d15UL, 0x21169451UL, 0x3fa172b2UL, 0xbb254dbcUL, 0x3ee1d3b5UL, + 0xdbf93b8eUL, 0x3f84c7dbUL, 0x05b4630bUL, 0x3ecd3364UL, 0xee9aada7UL, + 0x3f743924UL, 0x794a8297UL, 0x3eb7b7b9UL, 0xe015f797UL, 0x3f5d41f5UL, + 0xe41a4a56UL, 0x3ea35dfbUL, 0xe4c2a251UL, 0x3f49a2abUL, 0x5af9e000UL, + 0x3fce49ceUL, 0x8c743719UL, 0xbd1eb860UL, 0x00000000UL, 0x00000000UL, + 0x1b4863cfUL, 0x3fd78294UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, + 0xfffffff8UL, 0x65965966UL, 0xc0219659UL, 0x00000000UL, 0x00000000UL, + 0x882c10faUL, 0x402664f4UL, 0x00000000UL, 0x00000000UL, 0x83cd3723UL, + 0xc02c8342UL, 0x00000000UL, 0xc0000000UL, 0x55e6c23dUL, 0x403226e3UL, + 0x55555555UL, 0x40055555UL, 0x34451939UL, 0xc0371c96UL, 0xaaaaaaabUL, + 0xc00aaaaaUL, 0x0e157de0UL, 0x403d6d3dUL, 0x11111111UL, 0x40111111UL, + 0xa738201fUL, 0xc042bbceUL, 0x05b05b06UL, 0xc015b05bUL, 0x452b75e3UL, + 0x4047da36UL, 0x1ba1ba1cUL, 0x401ba1baUL, 0x00000000UL, 0xbff00000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x40000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0xc7ab4d5aUL, 0xc0085e24UL, 0x00000000UL, 0x00000000UL, 0xe93ea75dUL, + 0x400b963dUL, 0x00000000UL, 0x00000000UL, 0x94a7f25aUL, 0xc00f37e2UL, + 0x4b6261cbUL, 0xbff5f984UL, 0x5a9dd812UL, 0x4011aab0UL, 0x74c30018UL, + 0x3ffaf5a5UL, 0x7f2ce8e3UL, 0xc013fe8bUL, 0xfe8e54faUL, 0xbffd7334UL, + 0x670d618dUL, 0x4016a10cUL, 0x4db97058UL, 0x4000e012UL, 0x24df44ddUL, + 0xc0199c5fUL, 0x697d6eceUL, 0xc003006eUL, 0x83298b82UL, 0x401cfc4dUL, + 0x19d490d6UL, 0x40058c19UL, 0x2ae42850UL, 0xbfea4300UL, 0x118e20e6UL, + 0x3c7a6db8UL, 0x00000000UL, 0x40000000UL, 0xe33345b8UL, 0xbfd4e526UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x2b2c49d0UL, + 0xbff2de9cUL, 0x00000000UL, 0x00000000UL, 0x2655bc98UL, 0x3ff33e58UL, + 0x00000000UL, 0x00000000UL, 0xff691fa2UL, 0xbff3972eUL, 0xe93463bdUL, + 0xbfeeed87UL, 0x070e10a0UL, 0x3ff3f5b2UL, 0xf4d790a4UL, 0x3ff20c10UL, + 0xa04e8ea3UL, 0xbff4541aUL, 0x386accd3UL, 0xbff1369eUL, 0x222a66ddUL, + 0x3ff4b521UL, 0x22a9777eUL, 0x3ff20817UL, 0x52a04a6eUL, 0xbff5178fUL, + 0xddaa0031UL, 0xbff22137UL, 0x4447d47cUL, 0x3ff57c01UL, 0x1e9c7f1dUL, + 0x3ff29311UL, 0x2ab7f990UL, 0xbfe561b8UL, 0x209c7df1UL, 0xbc87a8c5UL, + 0x00000000UL, 0x3ff00000UL, 0x4170bcc6UL, 0x3fdc92d8UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xcc03e501UL, 0xbfdff10fUL, + 0x00000000UL, 0x00000000UL, 0x44a4e845UL, 0x3fddb63bUL, 0x00000000UL, + 0x00000000UL, 0x3768ad9fUL, 0xbfdb72a4UL, 0x3dd01ccaUL, 0xbfe5fdb9UL, + 0xa61d2811UL, 0x3fd972b2UL, 0x5645ad0bUL, 0x3fe977f9UL, 0xd013b3abUL, + 0xbfd78ca3UL, 0xbf0bf914UL, 0xbfe4f192UL, 0x4d53e730UL, 0x3fd5d060UL, + 0x3f8b9000UL, 0x3fe49933UL, 0xe2b82f08UL, 0xbfd4322aUL, 0x5936a835UL, + 0xbfe27ae1UL, 0xb1c61c9bUL, 0x3fd2b3fbUL, 0xef478605UL, 0x3fe1659eUL, + 0x190834ecUL, 0xbfe11ab7UL, 0xcdb625eaUL, 0x3c8e564bUL, 0x00000000UL, + 0x3ff00000UL, 0xb07217e3UL, 0x3fd248f1UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x56f37042UL, 0xbfccfc56UL, 0x00000000UL, + 0x00000000UL, 0xaa563951UL, 0x3fc90125UL, 0x00000000UL, 0x00000000UL, + 0x3d0e7c5dUL, 0xbfc50533UL, 0x9bed9b2eUL, 0xbfdf0ed9UL, 0x5fe7c47cUL, + 0x3fc1f250UL, 0x96c125e5UL, 0x3fe2edd9UL, 0x5a02bbd8UL, 0xbfbe5c71UL, + 0x86362c20UL, 0xbfda08b7UL, 0x4b4435edUL, 0x3fb9d342UL, 0x4b494091UL, + 0x3fd911bdUL, 0xb56658beUL, 0xbfb5e4c7UL, 0x93a2fd76UL, 0xbfd3c092UL, + 0xda271794UL, 0x3fb29910UL, 0x3303df2bUL, 0x3fd189beUL, 0x99fcef32UL, + 0xbfda8279UL, 0xb68c1467UL, 0xbc708b2fUL, 0x00000000UL, 0x3ff00000UL, + 0x980c4337UL, 0x3fc5f619UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x9314533eUL, 0xbfbb8ec5UL, 0x00000000UL, 0x00000000UL, + 0x09aa36d0UL, 0x3fb6d3f4UL, 0x00000000UL, 0x00000000UL, 0xdcb427fdUL, + 0xbfb13950UL, 0xd87ab0bbUL, 0xbfd5335eUL, 0xce0ae8a5UL, 0x3fabb382UL, + 0x79143126UL, 0x3fddba41UL, 0x5f2b28d4UL, 0xbfa552f1UL, 0x59f21a6dUL, + 0xbfd015abUL, 0x22c27d95UL, 0x3fa0e984UL, 0xe19fc6aaUL, 0x3fd0576cUL, + 0x8f2c2950UL, 0xbf9a4898UL, 0xc0b3f22cUL, 0xbfc59462UL, 0x1883a4b8UL, + 0x3f94b61cUL, 0x3f838640UL, 0x3fc30eb8UL, 0x355c63dcUL, 0xbfd36a08UL, + 0x1dce993dUL, 0x3c6d704dUL, 0x00000000UL, 0x3ff00000UL, 0x2b82ab63UL, + 0x3fb78e92UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x5a279ea3UL, 0xbfaa3407UL, 0x00000000UL, 0x00000000UL, 0x432d65faUL, + 0x3fa70153UL, 0x00000000UL, 0x00000000UL, 0x891a4602UL, 0xbf9d03efUL, + 0xd62ca5f8UL, 0xbfca77d9UL, 0xb35f4628UL, 0x3f97a265UL, 0x433258faUL, + 0x3fd8cf51UL, 0xb58fd909UL, 0xbf8f88e3UL, 0x01771ceaUL, 0xbfc2b154UL, + 0xf3562f8eUL, 0x3f888f57UL, 0xc028a723UL, 0x3fc7370fUL, 0x20b7f9f0UL, + 0xbf80f44cUL, 0x214368e9UL, 0xbfb6dfaaUL, 0x28891863UL, 0x3f79b4b6UL, + 0x172dbbf0UL, 0x3fb6cb8eUL, 0xe0553158UL, 0xbfc975f5UL, 0x593fe814UL, + 0xbc2ef5d3UL, 0x00000000UL, 0x3ff00000UL, 0x03dec550UL, 0x3fa44203UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x4e435f9bUL, + 0xbf953f83UL, 0x00000000UL, 0x00000000UL, 0x3c6e8e46UL, 0x3f9b74eaUL, + 0x00000000UL, 0x00000000UL, 0xda5b7511UL, 0xbf85ad63UL, 0xdc230b9bUL, + 0xbfb97558UL, 0x26cb3788UL, 0x3f881308UL, 0x76fc4985UL, 0x3fd62ac9UL, + 0x77bb08baUL, 0xbf757c85UL, 0xb6247521UL, 0xbfb1381eUL, 0x5922170cUL, + 0x3f754e95UL, 0x8746482dUL, 0x3fc27f83UL, 0x11055b30UL, 0xbf64e391UL, + 0x3e666320UL, 0xbfa3e609UL, 0x0de9dae3UL, 0x3f6301dfUL, 0x1f1dca06UL, + 0x3fafa8aeUL, 0x8c5b2da2UL, 0xbfb936bbUL, 0x4e88f7a5UL, 0xbc587d05UL, + 0x00000000UL, 0x3ff00000UL, 0xa8935dd9UL, 0x3f83dde2UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL +}; + +ALIGNED_(16) juint _MASK_35_tan[] = +{ + 0xfffc0000UL, 0xffffffffUL, 0x00000000UL, 0x00000000UL +}; + +ALIGNED_(16) juint _Q_11_tan[] = +{ + 0xb8fe4d77UL, 0x3f82609aUL +}; + +ALIGNED_(16) juint _Q_9_tan[] = +{ + 0xbf847a43UL, 0x3f9664a0UL +}; + +ALIGNED_(16) juint _Q_7_tan[] = +{ + 0x52c4c8abUL, 0x3faba1baUL +}; + +ALIGNED_(16) juint _Q_5_tan[] = +{ + 0x11092746UL, 0x3fc11111UL +}; + +ALIGNED_(16) juint _Q_3_tan[] = +{ + 0x55555612UL, 0x3fd55555UL +}; + +ALIGNED_(16) juint _PI_INV_TABLE_tan[] = +{ + 0x00000000UL, 0x00000000UL, 0xa2f9836eUL, 0x4e441529UL, 0xfc2757d1UL, + 0xf534ddc0UL, 0xdb629599UL, 0x3c439041UL, 0xfe5163abUL, 0xdebbc561UL, + 0xb7246e3aUL, 0x424dd2e0UL, 0x06492eeaUL, 0x09d1921cUL, 0xfe1deb1cUL, + 0xb129a73eUL, 0xe88235f5UL, 0x2ebb4484UL, 0xe99c7026UL, 0xb45f7e41UL, + 0x3991d639UL, 0x835339f4UL, 0x9c845f8bUL, 0xbdf9283bUL, 0x1ff897ffUL, + 0xde05980fUL, 0xef2f118bUL, 0x5a0a6d1fUL, 0x6d367ecfUL, 0x27cb09b7UL, + 0x4f463f66UL, 0x9e5fea2dUL, 0x7527bac7UL, 0xebe5f17bUL, 0x3d0739f7UL, + 0x8a5292eaUL, 0x6bfb5fb1UL, 0x1f8d5d08UL, 0x56033046UL, 0xfc7b6babUL, + 0xf0cfbc21UL +}; + +ALIGNED_(8) juint _PI_4_tan[] = +{ + 0x00000000UL, 0x3fe921fbUL, 0x4611a626UL, 0x3e85110bUL +}; + +ALIGNED_(8) juint _QQ_2_tan[] = +{ + 0x676733afUL, 0x3d32e7b9UL +}; + +ALIGNED_(8) juint _ONE_tan[] = +{ + 0x00000000UL, 0x3ff00000UL +}; + +ALIGNED_(8) juint _TWO_POW_55_tan[] = +{ + 0x00000000UL, 0x43600000UL +}; + +ALIGNED_(4) juint _TWO_POW_M55_tan[] = +{ + 0x00000000UL, 0x3c800000UL +}; + +ALIGNED_(4) juint _NEG_ZERO_tan[] = +{ + 0x00000000UL, 0x80000000UL +}; + +void MacroAssembler::fast_tan(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register r8, Register r9, Register r10, Register r11) { + + Label L_2TAG_PACKET_0_0_1, L_2TAG_PACKET_1_0_1, L_2TAG_PACKET_2_0_1, L_2TAG_PACKET_3_0_1; + Label L_2TAG_PACKET_4_0_1, L_2TAG_PACKET_5_0_1, L_2TAG_PACKET_6_0_1, L_2TAG_PACKET_7_0_1; + Label L_2TAG_PACKET_8_0_1, L_2TAG_PACKET_9_0_1, L_2TAG_PACKET_10_0_1, L_2TAG_PACKET_11_0_1; + Label L_2TAG_PACKET_12_0_1, L_2TAG_PACKET_13_0_1, L_2TAG_PACKET_14_0_1, B1_2, B1_3, B1_4, B1_5, start; + + address ONEHALF = (address)_ONEHALF_tan; + address MUL16 = (address)_MUL16; + address sign_mask = (address)_sign_mask_tan; + address PI32INV = (address)_PI32INV_tan; + address P_1 = (address)_P_1_tan; + address P_2 = (address)_P_2_tan; + address P_3 = (address)_P_3_tan; + address Ctable = (address)_Ctable_tan; + address MASK_35 = (address)_MASK_35_tan; + address Q_11 = (address)_Q_11_tan; + address Q_9 = (address)_Q_9_tan; + address Q_7 = (address)_Q_7_tan; + address Q_5 = (address)_Q_5_tan; + address Q_3 = (address)_Q_3_tan; + address PI_INV_TABLE = (address)_PI_INV_TABLE_tan; + address PI_4 = (address)_PI_4_tan; + address QQ_2 = (address)_QQ_2_tan; + address ONE = (address)_ONE_tan; + address TWO_POW_55 = (address)_TWO_POW_55_tan; + address TWO_POW_M55 = (address)_TWO_POW_M55_tan; + address NEG_ZERO = (address)_NEG_ZERO_tan; + + bind(start); + push(rbx); + subq(rsp, 16); + movsd(Address(rsp, 8), xmm0); + + bind(B1_2); + pextrw(eax, xmm0, 3); + andl(eax, 32767); + subl(eax, 16314); + cmpl(eax, 270); + jcc(Assembler::above, L_2TAG_PACKET_0_0_1); + movdqu(xmm5, ExternalAddress(ONEHALF)); //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL + movdqu(xmm6, ExternalAddress(MUL16)); //0x00000000UL, 0x40300000UL, 0x00000000UL, 0x3ff00000UL + unpcklpd(xmm0, xmm0); + movdqu(xmm4, ExternalAddress(sign_mask)); //0x00000000UL, 0x80000000UL, 0x00000000UL, 0x80000000UL + andpd(xmm4, xmm0); + movdqu(xmm1, ExternalAddress(PI32INV)); //0x6dc9c883UL, 0x3fe45f30UL, 0x6dc9c883UL, 0x40245f30UL + mulpd(xmm1, xmm0); + por(xmm5, xmm4); + addpd(xmm1, xmm5); + movdqu(xmm7, xmm1); + unpckhpd(xmm7, xmm7); + cvttsd2sil(edx, xmm7); + cvttpd2dq(xmm1, xmm1); + cvtdq2pd(xmm1, xmm1); + mulpd(xmm1, xmm6); + movdqu(xmm3, ExternalAddress(P_1)); //0x54444000UL, 0x3fb921fbUL, 0x54440000UL, 0x3fb921fbUL + movq(xmm5, ExternalAddress(QQ_2)); //0x676733afUL, 0x3d32e7b9UL + addq(rdx, 469248); + movdqu(xmm4, ExternalAddress(P_2)); //0x67674000UL, 0xbd32e7b9UL, 0x4c4c0000UL, 0x3d468c23UL + mulpd(xmm3, xmm1); + andq(rdx, 31); + mulsd(xmm5, xmm1); + movq(rcx, rdx); + mulpd(xmm4, xmm1); + shlq(rcx, 1); + subpd(xmm0, xmm3); + mulpd(xmm1, ExternalAddress(P_3)); //0x3707344aUL, 0x3aa8a2e0UL, 0x03707345UL, 0x3ae98a2eUL + addq(rdx, rcx); + shlq(rcx, 2); + addq(rdx, rcx); + addsd(xmm5, xmm0); + movdqu(xmm2, xmm0); + subpd(xmm0, xmm4); + movq(xmm6, ExternalAddress(ONE)); //0x00000000UL, 0x3ff00000UL + shlq(rdx, 4); + lea(rax, ExternalAddress(Ctable)); + andpd(xmm5, ExternalAddress(MASK_35)); //0xfffc0000UL, 0xffffffffUL, 0x00000000UL, 0x00000000UL + movdqu(xmm3, xmm0); + addq(rax, rdx); + subpd(xmm2, xmm0); + unpckhpd(xmm0, xmm0); + divsd(xmm6, xmm5); + subpd(xmm2, xmm4); + movdqu(xmm7, Address(rax, 16)); + subsd(xmm3, xmm5); + mulpd(xmm7, xmm0); + subpd(xmm2, xmm1); + movdqu(xmm1, Address(rax, 48)); + mulpd(xmm1, xmm0); + movdqu(xmm4, Address(rax, 96)); + mulpd(xmm4, xmm0); + addsd(xmm2, xmm3); + movdqu(xmm3, xmm0); + mulpd(xmm0, xmm0); + addpd(xmm7, Address(rax, 0)); + addpd(xmm1, Address(rax, 32)); + mulpd(xmm1, xmm0); + addpd(xmm4, Address(rax, 80)); + addpd(xmm7, xmm1); + movdqu(xmm1, Address(rax, 112)); + mulpd(xmm1, xmm0); + mulpd(xmm0, xmm0); + addpd(xmm4, xmm1); + movdqu(xmm1, Address(rax, 64)); + mulpd(xmm1, xmm0); + addpd(xmm7, xmm1); + movdqu(xmm1, xmm3); + mulpd(xmm3, xmm0); + mulsd(xmm0, xmm0); + mulpd(xmm1, Address(rax, 144)); + mulpd(xmm4, xmm3); + movdqu(xmm3, xmm1); + addpd(xmm7, xmm4); + movdqu(xmm4, xmm1); + mulsd(xmm0, xmm7); + unpckhpd(xmm7, xmm7); + addsd(xmm0, xmm7); + unpckhpd(xmm1, xmm1); + addsd(xmm3, xmm1); + subsd(xmm4, xmm3); + addsd(xmm1, xmm4); + movdqu(xmm4, xmm2); + movq(xmm7, Address(rax, 144)); + unpckhpd(xmm2, xmm2); + addsd(xmm7, Address(rax, 152)); + mulsd(xmm7, xmm2); + addsd(xmm7, Address(rax, 136)); + addsd(xmm7, xmm1); + addsd(xmm0, xmm7); + movq(xmm7, ExternalAddress(ONE)); //0x00000000UL, 0x3ff00000UL + mulsd(xmm4, xmm6); + movq(xmm2, Address(rax, 168)); + andpd(xmm2, xmm6); + mulsd(xmm5, xmm2); + mulsd(xmm6, Address(rax, 160)); + subsd(xmm7, xmm5); + subsd(xmm2, Address(rax, 128)); + subsd(xmm7, xmm4); + mulsd(xmm7, xmm6); + movdqu(xmm4, xmm3); + subsd(xmm3, xmm2); + addsd(xmm2, xmm3); + subsd(xmm4, xmm2); + addsd(xmm0, xmm4); + subsd(xmm0, xmm7); + addsd(xmm0, xmm3); + jmp(B1_4); + + bind(L_2TAG_PACKET_0_0_1); + jcc(Assembler::greater, L_2TAG_PACKET_1_0_1); + pextrw(eax, xmm0, 3); + movl(edx, eax); + andl(eax, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_2_0_1); + andl(edx, 32767); + cmpl(edx, 15904); + jcc(Assembler::below, L_2TAG_PACKET_3_0_1); + movdqu(xmm2, xmm0); + movdqu(xmm3, xmm0); + movq(xmm1, ExternalAddress(Q_11)); //0xb8fe4d77UL, 0x3f82609aUL + mulsd(xmm2, xmm0); + mulsd(xmm3, xmm2); + mulsd(xmm1, xmm2); + addsd(xmm1, ExternalAddress(Q_9)); //0xbf847a43UL, 0x3f9664a0UL + mulsd(xmm1, xmm2); + addsd(xmm1, ExternalAddress(Q_7)); //0x52c4c8abUL, 0x3faba1baUL + mulsd(xmm1, xmm2); + addsd(xmm1, ExternalAddress(Q_5)); //0x11092746UL, 0x3fc11111UL + mulsd(xmm1, xmm2); + addsd(xmm1, ExternalAddress(Q_3)); //0x55555612UL, 0x3fd55555UL + mulsd(xmm1, xmm3); + addsd(xmm0, xmm1); + jmp(B1_4); + + bind(L_2TAG_PACKET_3_0_1); + movq(xmm3, ExternalAddress(TWO_POW_55)); //0x00000000UL, 0x43600000UL + mulsd(xmm3, xmm0); + addsd(xmm0, xmm3); + mulsd(xmm0, ExternalAddress(TWO_POW_M55)); //0x00000000UL, 0x3c800000UL + jmp(B1_4); + + bind(L_2TAG_PACKET_2_0_1); + movdqu(xmm1, xmm0); + mulsd(xmm1, xmm1); + jmp(B1_4); + + bind(L_2TAG_PACKET_1_0_1); + pextrw(eax, xmm0, 3); + andl(eax, 32752); + cmpl(eax, 32752); + jcc(Assembler::equal, L_2TAG_PACKET_4_0_1); + pextrw(ecx, xmm0, 3); + andl(ecx, 32752); + subl(ecx, 16224); + shrl(ecx, 7); + andl(ecx, 65532); + lea(r11, ExternalAddress(PI_INV_TABLE)); + addq(rcx, r11); + movdq(rax, xmm0); + movl(r10, Address(rcx, 20)); + movl(r8, Address(rcx, 24)); + movl(edx, eax); + shrq(rax, 21); + orl(eax, INT_MIN); + shrl(eax, 11); + movl(r9, r10); + imulq(r10, rdx); + imulq(r9, rax); + imulq(r8, rax); + movl(rsi, Address(rcx, 16)); + movl(rdi, Address(rcx, 12)); + movl(r11, r10); + shrq(r10, 32); + addq(r9, r10); + addq(r11, r8); + movl(r8, r11); + shrq(r11, 32); + addq(r9, r11); + movl(r10, rsi); + imulq(rsi, rdx); + imulq(r10, rax); + movl(r11, rdi); + imulq(rdi, rdx); + movl(rbx, rsi); + shrq(rsi, 32); + addq(r9, rbx); + movl(rbx, r9); + shrq(r9, 32); + addq(r10, rsi); + addq(r10, r9); + shlq(rbx, 32); + orq(r8, rbx); + imulq(r11, rax); + movl(r9, Address(rcx, 8)); + movl(rsi, Address(rcx, 4)); + movl(rbx, rdi); + shrq(rdi, 32); + addq(r10, rbx); + movl(rbx, r10); + shrq(r10, 32); + addq(r11, rdi); + addq(r11, r10); + movq(rdi, r9); + imulq(r9, rdx); + imulq(rdi, rax); + movl(r10, r9); + shrq(r9, 32); + addq(r11, r10); + movl(r10, r11); + shrq(r11, 32); + addq(rdi, r9); + addq(rdi, r11); + movq(r9, rsi); + imulq(rsi, rdx); + imulq(r9, rax); + shlq(r10, 32); + orq(r10, rbx); + movl(eax, Address(rcx, 0)); + movl(r11, rsi); + shrq(rsi, 32); + addq(rdi, r11); + movl(r11, rdi); + shrq(rdi, 32); + addq(r9, rsi); + addq(r9, rdi); + imulq(rdx, rax); + pextrw(rbx, xmm0, 3); + lea(rdi, ExternalAddress(PI_INV_TABLE)); + subq(rcx, rdi); + addl(ecx, ecx); + addl(ecx, ecx); + addl(ecx, ecx); + addl(ecx, 19); + movl(rsi, 32768); + andl(rsi, rbx); + shrl(rbx, 4); + andl(rbx, 2047); + subl(rbx, 1023); + subl(ecx, rbx); + addq(r9, rdx); + movl(edx, ecx); + addl(edx, 32); + cmpl(ecx, 0); + jcc(Assembler::less, L_2TAG_PACKET_5_0_1); + negl(ecx); + addl(ecx, 29); + shll(r9); + movl(rdi, r9); + andl(r9, 1073741823); + testl(r9, 536870912); + jcc(Assembler::notEqual, L_2TAG_PACKET_6_0_1); + shrl(r9); + movl(rbx, 0); + shlq(r9, 32); + orq(r9, r11); + + bind(L_2TAG_PACKET_7_0_1); + + bind(L_2TAG_PACKET_8_0_1); + cmpq(r9, 0); + jcc(Assembler::equal, L_2TAG_PACKET_9_0_1); + + bind(L_2TAG_PACKET_10_0_1); + bsrq(r11, r9); + movl(ecx, 29); + subl(ecx, r11); + jcc(Assembler::lessEqual, L_2TAG_PACKET_11_0_1); + shlq(r9); + movq(rax, r10); + shlq(r10); + addl(edx, ecx); + negl(ecx); + addl(ecx, 64); + shrq(rax); + shrq(r8); + orq(r9, rax); + orq(r10, r8); + + bind(L_2TAG_PACKET_12_0_1); + cvtsi2sdq(xmm0, r9); + shrq(r10, 1); + cvtsi2sdq(xmm3, r10); + xorpd(xmm4, xmm4); + shll(edx, 4); + negl(edx); + addl(edx, 16368); + orl(edx, rsi); + xorl(edx, rbx); + pinsrw(xmm4, edx, 3); + movq(xmm2, ExternalAddress(PI_4)); //0x00000000UL, 0x3fe921fbUL, 0x4611a626UL, 0x3e85110bUL + movq(xmm7, ExternalAddress(8 + PI_4)); //0x3fe921fbUL, 0x4611a626UL, 0x3e85110bUL + xorpd(xmm5, xmm5); + subl(edx, 1008); + pinsrw(xmm5, edx, 3); + mulsd(xmm0, xmm4); + shll(rsi, 16); + sarl(rsi, 31); + mulsd(xmm3, xmm5); + movdqu(xmm1, xmm0); + mulsd(xmm0, xmm2); + shrl(rdi, 30); + addsd(xmm1, xmm3); + mulsd(xmm3, xmm2); + addl(rdi, rsi); + xorl(rdi, rsi); + mulsd(xmm7, xmm1); + movl(eax, rdi); + addsd(xmm7, xmm3); + movdqu(xmm2, xmm0); + addsd(xmm0, xmm7); + subsd(xmm2, xmm0); + addsd(xmm7, xmm2); + movdqu(xmm1, ExternalAddress(PI32INV)); //0x6dc9c883UL, 0x3fe45f30UL, 0x6dc9c883UL, 0x40245f30UL + if (VM_Version::supports_sse3()) { + movddup(xmm0, xmm0); + } + else { + movlhps(xmm0, xmm0); + } + movdqu(xmm4, ExternalAddress(sign_mask)); //0x00000000UL, 0x80000000UL, 0x00000000UL, 0x80000000UL + andpd(xmm4, xmm0); + mulpd(xmm1, xmm0); + if (VM_Version::supports_sse3()) { + movddup(xmm7, xmm7); + } + else { + movlhps(xmm7, xmm7); + } + movdqu(xmm5, ExternalAddress(ONEHALF)); //0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL + movdqu(xmm6, ExternalAddress(MUL16)); //0x00000000UL, 0x40300000UL, 0x00000000UL, 0x3ff00000UL + por(xmm5, xmm4); + addpd(xmm1, xmm5); + movdqu(xmm5, xmm1); + unpckhpd(xmm5, xmm5); + cvttsd2sil(edx, xmm5); + cvttpd2dq(xmm1, xmm1); + cvtdq2pd(xmm1, xmm1); + mulpd(xmm1, xmm6); + movdqu(xmm3, ExternalAddress(P_1)); //0x54444000UL, 0x3fb921fbUL, 0x54440000UL, 0x3fb921fbUL + movq(xmm5, ExternalAddress(QQ_2)); //0x676733afUL, 0x3d32e7b9UL + shll(eax, 4); + addl(edx, 469248); + movdqu(xmm4, ExternalAddress(P_2)); //0x67674000UL, 0xbd32e7b9UL, 0x4c4c0000UL, 0x3d468c23UL + mulpd(xmm3, xmm1); + addl(edx, eax); + andl(edx, 31); + mulsd(xmm5, xmm1); + movl(ecx, edx); + mulpd(xmm4, xmm1); + shll(ecx, 1); + subpd(xmm0, xmm3); + mulpd(xmm1, ExternalAddress(P_3)); //0x3707344aUL, 0x3aa8a2e0UL, 0x03707345UL, 0x3ae98a2eUL + addl(edx, ecx); + shll(ecx, 2); + addl(edx, ecx); + addsd(xmm5, xmm0); + movdqu(xmm2, xmm0); + subpd(xmm0, xmm4); + movq(xmm6, ExternalAddress(ONE)); //0x00000000UL, 0x3ff00000UL + shll(edx, 4); + lea(rax, ExternalAddress(Ctable)); + andpd(xmm5, ExternalAddress(MASK_35)); //0xfffc0000UL, 0xffffffffUL, 0x00000000UL, 0x00000000UL + movdqu(xmm3, xmm0); + addq(rax, rdx); + subpd(xmm2, xmm0); + unpckhpd(xmm0, xmm0); + divsd(xmm6, xmm5); + subpd(xmm2, xmm4); + subsd(xmm3, xmm5); + subpd(xmm2, xmm1); + movdqu(xmm1, Address(rax, 48)); + addpd(xmm2, xmm7); + movdqu(xmm7, Address(rax, 16)); + mulpd(xmm7, xmm0); + movdqu(xmm4, Address(rax, 96)); + mulpd(xmm1, xmm0); + mulpd(xmm4, xmm0); + addsd(xmm2, xmm3); + movdqu(xmm3, xmm0); + mulpd(xmm0, xmm0); + addpd(xmm7, Address(rax, 0)); + addpd(xmm1, Address(rax, 32)); + mulpd(xmm1, xmm0); + addpd(xmm4, Address(rax, 80)); + addpd(xmm7, xmm1); + movdqu(xmm1, Address(rax, 112)); + mulpd(xmm1, xmm0); + mulpd(xmm0, xmm0); + addpd(xmm4, xmm1); + movdqu(xmm1, Address(rax, 64)); + mulpd(xmm1, xmm0); + addpd(xmm7, xmm1); + movdqu(xmm1, xmm3); + mulpd(xmm3, xmm0); + mulsd(xmm0, xmm0); + mulpd(xmm1, Address(rax, 144)); + mulpd(xmm4, xmm3); + movdqu(xmm3, xmm1); + addpd(xmm7, xmm4); + movdqu(xmm4, xmm1); + mulsd(xmm0, xmm7); + unpckhpd(xmm7, xmm7); + addsd(xmm0, xmm7); + unpckhpd(xmm1, xmm1); + addsd(xmm3, xmm1); + subsd(xmm4, xmm3); + addsd(xmm1, xmm4); + movdqu(xmm4, xmm2); + movq(xmm7, Address(rax, 144)); + unpckhpd(xmm2, xmm2); + addsd(xmm7, Address(rax, 152)); + mulsd(xmm7, xmm2); + addsd(xmm7, Address(rax, 136)); + addsd(xmm7, xmm1); + addsd(xmm0, xmm7); + movq(xmm7, ExternalAddress(ONE)); //0x00000000UL, 0x3ff00000UL + mulsd(xmm4, xmm6); + movq(xmm2, Address(rax, 168)); + andpd(xmm2, xmm6); + mulsd(xmm5, xmm2); + mulsd(xmm6, Address(rax, 160)); + subsd(xmm7, xmm5); + subsd(xmm2, Address(rax, 128)); + subsd(xmm7, xmm4); + mulsd(xmm7, xmm6); + movdqu(xmm4, xmm3); + subsd(xmm3, xmm2); + addsd(xmm2, xmm3); + subsd(xmm4, xmm2); + addsd(xmm0, xmm4); + subsd(xmm0, xmm7); + addsd(xmm0, xmm3); + jmp(B1_4); + + bind(L_2TAG_PACKET_9_0_1); + addl(edx, 64); + movq(r9, r10); + movq(r10, r8); + movl(r8, 0); + cmpq(r9, 0); + jcc(Assembler::notEqual, L_2TAG_PACKET_10_0_1); + addl(edx, 64); + movq(r9, r10); + movq(r10, r8); + cmpq(r9, 0); + jcc(Assembler::notEqual, L_2TAG_PACKET_10_0_1); + jmp(L_2TAG_PACKET_12_0_1); + + bind(L_2TAG_PACKET_11_0_1); + jcc(Assembler::equal, L_2TAG_PACKET_12_0_1); + negl(ecx); + shrq(r10); + movq(rax, r9); + shrq(r9); + subl(edx, ecx); + negl(ecx); + addl(ecx, 64); + shlq(rax); + orq(r10, rax); + jmp(L_2TAG_PACKET_12_0_1); + + bind(L_2TAG_PACKET_5_0_1); + notl(ecx); + shlq(r9, 32); + orq(r9, r11); + shlq(r9); + movq(rdi, r9); + testl(r9, INT_MIN); + jcc(Assembler::notEqual, L_2TAG_PACKET_13_0_1); + shrl(r9); + movl(rbx, 0); + shrq(rdi, 2); + jmp(L_2TAG_PACKET_8_0_1); + + bind(L_2TAG_PACKET_6_0_1); + shrl(r9); + movl(rbx, 1073741824); + shrl(rbx); + shlq(r9, 32); + orq(r9, r11); + shlq(rbx, 32); + addl(rdi, 1073741824); + movl(rcx, 0); + movl(r11, 0); + subq(rcx, r8); + sbbq(r11, r10); + sbbq(rbx, r9); + movq(r8, rcx); + movq(r10, r11); + movq(r9, rbx); + movl(rbx, 32768); + jmp(L_2TAG_PACKET_7_0_1); + + bind(L_2TAG_PACKET_13_0_1); + shrl(r9); + mov64(rbx, 0x100000000); + shrq(rbx); + movl(rcx, 0); + movl(r11, 0); + subq(rcx, r8); + sbbq(r11, r10); + sbbq(rbx, r9); + movq(r8, rcx); + movq(r10, r11); + movq(r9, rbx); + movl(rbx, 32768); + shrq(rdi, 2); + addl(rdi, 1073741824); + jmp(L_2TAG_PACKET_8_0_1); + + bind(L_2TAG_PACKET_4_0_1); + movq(xmm0, Address(rsp, 8)); + mulsd(xmm0, ExternalAddress(NEG_ZERO)); //0x00000000UL, 0x80000000UL + movq(Address(rsp, 0), xmm0); + + bind(L_2TAG_PACKET_14_0_1); + + bind(B1_4); + addq(rsp, 16); + +} +#else +// The 32 bit code is at most SSE2 compliant +ALIGNED_(16) jushort _TP[] = +{ + 0x4cd6, 0xaf6c, 0xc710, 0xc662, 0xbffd, 0x0000, 0x4b06, 0xb0ac, 0xd3b2, 0xcc2c, + 0x3ff9, 0x0000, 0x00e3, 0xc850, 0xaa28, 0x9533, 0xbff3, 0x0000, 0x2ff0, 0x466d, + 0x1a3b, 0xb266, 0x3fe5, 0x0000 +}; + +ALIGNED_(16) jushort _TQ[] = +{ + 0x399c, 0x8391, 0x154c, 0x94ca, 0xbfff, 0x0000, 0xb6a3, 0xc36a, 0x44e2, 0x8a2c, + 0x3ffe, 0x0000, 0xb70f, 0xd068, 0xa6ce, 0xe9dd, 0xbff9, 0x0000, 0x820f, 0x51ce, + 0x7d76, 0x9bff, 0x3ff3, 0x0000 +}; + +ALIGNED_(16) jushort _GP[] = +{ + 0xaaab, 0xaaaa, 0xaaaa, 0xaaaa, 0xbffd, 0x0000, 0xb62f, 0x0b60, 0x60b6, 0xb60b, + 0xbff9, 0x0000, 0xdfa7, 0x08aa, 0x55e0, 0x8ab3, 0xbff6, 0x0000, 0x85a0, 0xa819, + 0xbc99, 0xddeb, 0xbff2, 0x0000, 0x7065, 0x6a37, 0x795f, 0xb354, 0xbfef, 0x0000, + 0xa8f9, 0x83f1, 0x2ec8, 0x9140, 0xbfec, 0x0000, 0xf3ca, 0x8c96, 0x8e0b, 0xeb6d, + 0xbfe8, 0x0000, 0x355b, 0xd910, 0x67c9, 0xbed3, 0xbfe5, 0x0000, 0x286b, 0xb49e, + 0xb854, 0x9a98, 0xbfe2, 0x0000, 0x0871, 0x1a2f, 0x6477, 0xfcc4, 0xbfde, 0x0000, + 0xa559, 0x1da9, 0xaed2, 0xba76, 0xbfdb, 0x0000, 0x00a3, 0x7fea, 0x9bc3, 0xf205, + 0xbfd8, 0x0000 +}; + +void MacroAssembler::libm_tancot_huge(XMMRegister xmm0, XMMRegister xmm1, Register eax, Register ecx, Register edx, Register ebx, Register esi, Register edi, Register ebp, Register esp) { + Label B1_1, B1_2, B1_3, B1_4, B1_5, B1_6, B1_7, B1_8, B1_9, B1_10, B1_11, B1_12; + Label B1_13, B1_14, B1_15, B1_16, B1_17, B1_18, B1_19, B1_20, B1_21, B1_22, B1_23; + Label B1_24, B1_25, B1_26, B1_27, B1_28, B1_29, B1_30, B1_31, B1_32, B1_33, B1_34; + Label B1_35, B1_36, B1_37, B1_38, B1_39, B1_40, B1_41, B1_42, B1_43, B1_44, B1_45, B1_46; + + assert_different_registers(ebx, eax, ecx, edx, esi, edi, ebp, esp); + + address L_2il0floatpacket_0 = StubRoutines::x86::_L_2il0floatpacket_0_addr(); + address Pi4Inv = StubRoutines::x86::_Pi4Inv_addr(); + address Pi4x3 = StubRoutines::x86::_Pi4x3_addr(); + address Pi4x4 = StubRoutines::x86::_Pi4x4_addr(); + address ones = StubRoutines::x86::_ones_addr(); + address TP = (address)_TP; + address TQ = (address)_TQ; + address GP = (address)_GP; + + bind(B1_1); + push(ebp); + movl(ebp, esp); + andl(esp, -64); + push(esi); + push(edi); + push(ebx); + subl(esp, 52); + movl(eax, Address(ebp, 16)); + movl(ebx, Address(ebp, 20)); + movl(Address(esp, 40), eax); + + bind(B1_2); + fnstcw(Address(esp, 38)); + + bind(B1_3); + movl(edx, Address(ebp, 12)); + movl(eax, edx); + andl(eax, 2147483647); + shrl(edx, 31); + movl(Address(esp, 44), edx); + cmpl(eax, 1104150528); + jcc(Assembler::aboveEqual, B1_11); + + bind(B1_4); + movsd(xmm1, Address(ebp, 8)); + movzwl(ecx, Address(esp, 38)); + movl(edx, ecx); + andl(edx, 768); + andps(xmm1, ExternalAddress(L_2il0floatpacket_0)); //0xffffffffUL, 0x7fffffffUL, 0x00000000UL, 0x00000000UL + cmpl(edx, 768); + movsd(xmm0, ExternalAddress(Pi4Inv)); ////0x6dc9c883UL, 0x3ff45f30UL + mulsd(xmm0, xmm1); + movsd(Address(ebp, 8), xmm1); + movsd(Address(esp, 0), xmm0); + jcc(Assembler::equal, B1_39); + + bind(B1_5); + orl(ecx, -64768); + movw(Address(esp, 36), ecx); + + bind(B1_6); + fldcw(Address(esp, 36)); + + bind(B1_7); + movsd(xmm1, Address(ebp, 8)); + movl(edi, 1); + + bind(B1_8); + movl(Address(esp, 12), esi); + movl(esi, Address(esp, 4)); + movl(edx, esi); + movl(Address(esp, 24), edi); + movl(edi, esi); + shrl(edi, 20); + andl(edx, 1048575); + movl(ecx, edi); + orl(edx, 1048576); + negl(ecx); + addl(edi, 13); + movl(Address(esp, 8), ebx); + addl(ecx, 19); + movl(ebx, edx); + movl(Address(esp, 28), ecx); + shrl(ebx); + movl(ecx, edi); + shll(edx); + movl(ecx, Address(esp, 28)); + movl(edi, Address(esp, 0)); + shrl(edi); + orl(edx, edi); + cmpl(esi, 1094713344); + movsd(Address(esp, 16), xmm1); + fld_d(Address(esp, 16)); + cmov32(Assembler::below, edx, ebx); + movl(edi, Address(esp, 24)); + movl(esi, Address(esp, 12)); + lea(ebx, Address(edx, 1)); + andl(ebx, -2); + movl(Address(esp, 16), ebx); + cmpl(eax, 1094713344); + fild_s(Address(esp, 16)); + movl(ebx, Address(esp, 8)); + jcc(Assembler::aboveEqual, B1_10); + + bind(B1_9); + fld_d(ExternalAddress(Pi4x3)); //0x54443000UL, 0xbfe921fbUL + fmul(1); + faddp(2); + fld_d(ExternalAddress(8 + Pi4x3)); //0x3b39a000UL, 0x3d373dcbUL + fmul(1); + faddp(2); + fld_d(ExternalAddress(16 + Pi4x3)); //0xe0e68948UL, 0xba845c06UL + fmulp(1); + faddp(1); + jmp(B1_17); + + bind(B1_10); + fld_d(ExternalAddress(Pi4x4)); //0x54400000UL, 0xbfe921fbUL + fmul(1); + faddp(2); + fld_d(ExternalAddress(8 + Pi4x4)); //0x1a600000UL, 0xbdc0b461UL + fmul(1); + faddp(2); + fld_d(ExternalAddress(16 + Pi4x4)); //0x2e000000UL, 0xbb93198aUL + fmul(1); + faddp(2); + fld_d(ExternalAddress(24 + Pi4x4)); //0x252049c1UL, 0xb96b839aUL + fmulp(1); + faddp(1); + jmp(B1_17); + + bind(B1_11); + movzwl(edx, Address(esp, 38)); + movl(eax, edx); + andl(eax, 768); + cmpl(eax, 768); + jcc(Assembler::equal, B1_40); + + bind(B1_12); + orl(edx, -64768); + movw(Address(esp, 36), edx); + + bind(B1_13); + fldcw(Address(esp, 36)); + + bind(B1_14); + movl(edi, 1); + + bind(B1_15); + movsd(xmm0, Address(ebp, 8)); + addl(esp, -32); + andps(xmm0, ExternalAddress(L_2il0floatpacket_0)); //0xffffffffUL, 0x7fffffffUL, 0x00000000UL, 0x00000000UL + lea(eax, Address(esp, 32)); + movsd(Address(eax, 16), xmm0); + fld_d(Address(eax, 16)); + fstp_x(Address(esp, 0)); + movl(Address(esp, 12), 0); + movl(Address(esp, 16), eax); + call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_reduce_pi04l()))); + + bind(B1_43); + movl(edx, eax); + addl(esp, 32); + + bind(B1_16); + fld_d(Address(esp, 0)); + fld_d(Address(esp, 8)); + faddp(1); + + bind(B1_17); + movl(eax, ebx); + andl(eax, 3); + cmpl(eax, 3); + jcc(Assembler::notEqual, B1_24); + + bind(B1_18); + fld_d(ExternalAddress(ones)); + incl(edx); + fdiv(1); + testb(edx, 2); + fstp_x(Address(esp, 24)); + fld_s(0); + fmul(1); + fld_s(0); + fmul(1); + fld_x(ExternalAddress(36 + TP)); //0x2ff0, 0x466d, 0x1a + fmul(2); + fld_x(ExternalAddress(24 + TP)); //0x00e3, 0xc850, 0xaa + faddp(1); + fmul(2); + fld_x(ExternalAddress(12 + TP)); //0x4b06, 0xb0ac, 0xd3 + faddp(1); + fmul(2); + fld_x(ExternalAddress(36 + TQ)); //0x820f, 0x51ce, 0x7d + fmul(3); + fld_x(ExternalAddress(24 + TQ)); //0xb70f, 0xd068, 0xa6 + faddp(1); + fmul(3); + fld_x(ExternalAddress(12 + TQ)); //0xb6a3, 0xc36a, 0x44 + faddp(1); + fmul(3); + fld_x(ExternalAddress(TQ)); //0x399c, 0x8391, 0x15 + faddp(1); + fld_x(ExternalAddress(TP)); //0x4cd6, 0xaf6c, 0xc7 + faddp(2); + fld_x(ExternalAddress(132 + GP)); //0x00a3, 0x7fea, 0x9b + fmul(3); + fld_x(ExternalAddress(120 + GP)); //0xa559, 0x1da9, 0xae + fmul(4); + fld_x(ExternalAddress(108 + GP)); //0x0871, 0x1a2f, 0x64 + faddp(2); + fxch(1); + fmul(4); + fld_x(ExternalAddress(96 + GP)); //0x286b, 0xb49e, 0xb8 + faddp(2); + fxch(1); + fmul(4); + fld_x(ExternalAddress(84 + GP)); //0x355b, 0xd910, 0x67 + faddp(2); + fxch(1); + fmul(4); + fld_x(ExternalAddress(72 + GP)); //0x8c96, 0x8e0b, 0xeb + faddp(2); + fxch(1); + fmul(4); + fld_x(ExternalAddress(60 + GP)); //0xa8f9, 0x83f1, 0x2e + faddp(2); + fxch(1); + fmul(4); + fld_x(ExternalAddress(48 + GP)); //0x7065, 0x6a37, 0x79 + faddp(2); + fxch(1); + fmul(4); + fld_x(ExternalAddress(36 + GP)); //0x85a0, 0xa819, 0xbc + faddp(2); + fxch(1); + fmul(4); + fld_x(ExternalAddress(24 + GP)); //0xdfa7, 0x08aa, 0x55 + faddp(2); + fxch(1); + fmulp(4); + fld_x(ExternalAddress(12 + GP)); //0xb62f, 0x0b60, 0x60 + faddp(1); + fmul(4); + fmul(5); + fld_x(ExternalAddress(GP)); //0xaaab, 0xaaaa, 0xaa + faddp(4); + fxch(3); + fmul(5); + faddp(3); + jcc(Assembler::equal, B1_20); + + bind(B1_19); + fld_x(Address(esp, 24)); + fxch(1); + fdivrp(2); + fxch(1); + fmulp(3); + movl(eax, Address(esp, 44)); + xorl(eax, 1); + fxch(2); + fmul(3); + fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8)); + fmula(2); + fmula(3); + fxch(3); + faddp(2); + fxch(1); + fstp_d(Address(esp, 16)); + fmul(1); + fxch(1); + fmulp(2); + movsd(xmm0, Address(esp, 16)); + faddp(1); + fstp_d(Address(esp, 16)); + movsd(xmm1, Address(esp, 16)); + jmp(B1_21); + + bind(B1_20); + fdivrp(1); + fmulp(2); + fxch(1); + fmul(2); + movl(eax, Address(esp, 44)); + fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8)); + fmula(1); + fmula(3); + fxch(3); + faddp(1); + fstp_d(Address(esp, 16)); + fmul(1); + fld_x(Address(esp, 24)); + fmulp(2); + movsd(xmm0, Address(esp, 16)); + faddp(1); + fstp_d(Address(esp, 16)); + movsd(xmm1, Address(esp, 16)); + + bind(B1_21); + testl(edi, edi); + jcc(Assembler::equal, B1_23); + + bind(B1_22); + fldcw(Address(esp, 38)); + + bind(B1_23); + movl(eax, Address(esp, 40)); + movsd(Address(eax, 0), xmm0); + movsd(Address(eax, 8), xmm1); + addl(esp, 52); + pop(ebx); + pop(edi); + pop(esi); + movl(esp, ebp); + pop(ebp); + ret(0); + + bind(B1_24); + testb(ebx, 2); + jcc(Assembler::equal, B1_31); + + bind(B1_25); + incl(edx); + fld_s(0); + fmul(1); + testb(edx, 2); + jcc(Assembler::equal, B1_27); + + bind(B1_26); + fld_d(ExternalAddress(ones)); + fdiv(2); + fld_s(1); + fmul(2); + fld_x(ExternalAddress(132 + GP)); //0x00a3, 0x7fea, 0x9b + fmul(1); + fld_x(ExternalAddress(120 + GP)); //0xa559, 0x1da9, 0xae + fmul(2); + fld_x(ExternalAddress(108 + GP)); //0x67c9, 0xbed3, 0xbf + movl(eax, Address(esp, 44)); + faddp(2); + fxch(1); + fmul(2); + xorl(eax, 1); + fld_x(ExternalAddress(96 + GP)); //0x286b, 0xb49e, 0xb8 + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(84 + GP)); //0x355b, 0xd910, 0x67 + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(72 + GP)); //0xf3ca, 0x8c96, 0x8e + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(60 + GP)); //0xa8f9, 0x83f1, 0x2e + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(48 + GP)); //0x7065, 0x6a37, 0x79 + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(36 + GP)); //0x85a0, 0xa819, 0xbc + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(24 + GP)); //0xdfa7, 0x08aa, 0x55 + faddp(2); + fxch(1); + fmulp(2); + fld_x(ExternalAddress(12 + GP)); //0xb62f, 0x0b60, 0x60 + faddp(1); + fmulp(3); + fld_x(ExternalAddress(GP)); //0xaaab, 0xaaaa, 0xaa + faddp(1); + fmul(3); + fxch(2); + fmulp(3); + fxch(1); + faddp(2); + fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8)); + fmula(2); + fmulp(1); + faddp(1); + fstp_d(Address(esp, 16)); + movsd(xmm0, Address(esp, 16)); + jmp(B1_28); + + bind(B1_27); + fld_x(ExternalAddress(36 + TP)); //0x2ff0, 0x466d, 0x1a + fmul(1); + fld_x(ExternalAddress(24 + TP)); //0x00e3, 0xc850, 0xaa + movl(eax, Address(esp, 44)); + faddp(1); + fmul(1); + fld_x(ExternalAddress(36 + TQ)); //0x820f, 0x51ce, 0x7d + fmul(2); + fld_x(ExternalAddress(24 + TQ)); //0xb70f, 0xd068, 0xa6 + faddp(1); + fmul(2); + fld_x(ExternalAddress(12 + TQ)); //0xb6a3, 0xc36a, 0x44 + faddp(1); + fmul(2); + fld_x(ExternalAddress(TQ)); //0x399c, 0x8391, 0x15 + faddp(1); + fld_x(ExternalAddress(12 + TP)); //0x4b06, 0xb0ac, 0xd3 + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(TP)); //0x4cd6, 0xaf6c, 0xc7 + faddp(1); + fdivrp(1); + fmulp(1); + fmul(1); + fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8)); + fmula(1); + fmulp(2); + faddp(1); + fstp_d(Address(esp, 16)); + movsd(xmm0, Address(esp, 16)); + + bind(B1_28); + testl(edi, edi); + jcc(Assembler::equal, B1_30); + + bind(B1_29); + fldcw(Address(esp, 38)); + + bind(B1_30); + movl(eax, Address(esp, 40)); + movsd(Address(eax, 0), xmm0); + addl(esp, 52); + pop(ebx); + pop(edi); + pop(esi); + movl(esp, ebp); + pop(ebp); + ret(0); + + bind(B1_31); + testb(ebx, 1); + jcc(Assembler::equal, B1_38); + + bind(B1_32); + incl(edx); + fld_s(0); + fmul(1); + testb(edx, 2); + jcc(Assembler::equal, B1_34); + + bind(B1_33); + fld_x(ExternalAddress(36 + TP)); //0x2ff0, 0x466d, 0x1a + fmul(1); + fld_x(ExternalAddress(24 + TP)); //0x00e3, 0xc850, 0xaa + movl(eax, Address(esp, 44)); + faddp(1); + fmul(1); + xorl(eax, 1); + fld_x(ExternalAddress(36 + TQ)); //0x820f, 0x51ce, 0x7d + fmul(2); + fld_x(ExternalAddress(24 + TQ)); //0xb70f, 0xd068, 0xa6 + faddp(1); + fmul(2); + fld_x(ExternalAddress(12 + TQ)); //0xb6a3, 0xc36a, 0x44 + faddp(1); + fmul(2); + fld_x(ExternalAddress(TQ)); //0x399c, 0x8391, 0x15 + faddp(1); + fld_x(ExternalAddress(12 + TP)); //0x4b06, 0xb0ac, 0xd3 + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(TP)); //0x4cd6, 0xaf6c, 0xc7 + faddp(1); + fdivrp(1); + fmulp(1); + fmul(1); + fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8)); + fmula(1); + fmulp(2); + faddp(1); + fstp_d(Address(esp, 16)); + movsd(xmm0, Address(esp, 16)); + jmp(B1_35); + + bind(B1_34); + fld_d(ExternalAddress(ones)); + fdiv(2); + fld_s(1); + fmul(2); + fld_x(ExternalAddress(132 + GP)); //0x00a3, 0x7fea, 0x9b + fmul(1); + fld_x(ExternalAddress(120 + GP)); //0xa559, 0x1da9, 0xae + fmul(2); + fld_x(ExternalAddress(108 + GP)); //0x67c9, 0xbed3, 0xbf + movl(eax, Address(esp, 44)); + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(96 + GP)); //0x286b, 0xb49e, 0xb8 + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(84 + GP)); //0x355b, 0xd910, 0x67 + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(72 + GP)); //0xf3ca, 0x8c96, 0x8e + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(60 + GP)); //0xa8f9, 0x83f1, 0x2e + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(48 + GP)); //0x7065, 0x6a37, 0x79 + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(36 + GP)); //0x85a0, 0xa819, 0xbc + faddp(2); + fxch(1); + fmul(2); + fld_x(ExternalAddress(24 + GP)); //0xdfa7, 0x08aa, 0x55 + faddp(2); + fxch(1); + fmulp(2); + fld_x(ExternalAddress(12 + GP)); //0xb62f, 0x0b60, 0x60 + faddp(1); + fmulp(3); + fld_x(ExternalAddress(GP)); //0xaaab, 0xaaaa, 0xaa + faddp(1); + fmul(3); + fxch(2); + fmulp(3); + fxch(1); + faddp(2); + fld_d(Address(ones, RelocationHolder::none).plus_disp(eax, Address::times_8)); + fmula(2); + fmulp(1); + faddp(1); + fstp_d(Address(esp, 16)); + movsd(xmm0, Address(esp, 16)); + + bind(B1_35); + testl(edi, edi); + jcc(Assembler::equal, B1_37); + + bind(B1_36); + fldcw(Address(esp, 38)); + + bind(B1_37); + movl(eax, Address(esp, 40)); + movsd(Address(eax, 8), xmm0); + addl(esp, 52); + pop(ebx); + pop(edi); + pop(esi); + mov(esp, ebp); + pop(ebp); + ret(0); + + bind(B1_38); + fstp_d(0); + addl(esp, 52); + pop(ebx); + pop(edi); + pop(esi); + mov(esp, ebp); + pop(ebp); + ret(0); + + bind(B1_39); + xorl(edi, edi); + jmp(B1_8); + + bind(B1_40); + xorl(edi, edi); + jmp(B1_15); +} + +ALIGNED_(16) juint _static_const_table_tan[] = +{ + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x882c10faUL, + 0x3f9664f4UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x55e6c23dUL, 0x3f8226e3UL, 0x55555555UL, + 0x3fd55555UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x0e157de0UL, 0x3f6d6d3dUL, 0x11111111UL, 0x3fc11111UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x452b75e3UL, 0x3f57da36UL, + 0x1ba1ba1cUL, 0x3faba1baUL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x4e435f9bUL, + 0x3f953f83UL, 0x00000000UL, 0x00000000UL, 0x3c6e8e46UL, 0x3f9b74eaUL, + 0x00000000UL, 0x00000000UL, 0xda5b7511UL, 0x3f85ad63UL, 0xdc230b9bUL, + 0x3fb97558UL, 0x26cb3788UL, 0x3f881308UL, 0x76fc4985UL, 0x3fd62ac9UL, + 0x77bb08baUL, 0x3f757c85UL, 0xb6247521UL, 0x3fb1381eUL, 0x5922170cUL, + 0x3f754e95UL, 0x8746482dUL, 0x3fc27f83UL, 0x11055b30UL, 0x3f64e391UL, + 0x3e666320UL, 0x3fa3e609UL, 0x0de9dae3UL, 0x3f6301dfUL, 0x1f1dca06UL, + 0x3fafa8aeUL, 0x8c5b2da2UL, 0x3fb936bbUL, 0x4e88f7a5UL, 0x3c587d05UL, + 0x00000000UL, 0x3ff00000UL, 0xa8935dd9UL, 0x3f83dde2UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x5a279ea3UL, 0x3faa3407UL, + 0x00000000UL, 0x00000000UL, 0x432d65faUL, 0x3fa70153UL, 0x00000000UL, + 0x00000000UL, 0x891a4602UL, 0x3f9d03efUL, 0xd62ca5f8UL, 0x3fca77d9UL, + 0xb35f4628UL, 0x3f97a265UL, 0x433258faUL, 0x3fd8cf51UL, 0xb58fd909UL, + 0x3f8f88e3UL, 0x01771ceaUL, 0x3fc2b154UL, 0xf3562f8eUL, 0x3f888f57UL, + 0xc028a723UL, 0x3fc7370fUL, 0x20b7f9f0UL, 0x3f80f44cUL, 0x214368e9UL, + 0x3fb6dfaaUL, 0x28891863UL, 0x3f79b4b6UL, 0x172dbbf0UL, 0x3fb6cb8eUL, + 0xe0553158UL, 0x3fc975f5UL, 0x593fe814UL, 0x3c2ef5d3UL, 0x00000000UL, + 0x3ff00000UL, 0x03dec550UL, 0x3fa44203UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x9314533eUL, 0x3fbb8ec5UL, 0x00000000UL, + 0x00000000UL, 0x09aa36d0UL, 0x3fb6d3f4UL, 0x00000000UL, 0x00000000UL, + 0xdcb427fdUL, 0x3fb13950UL, 0xd87ab0bbUL, 0x3fd5335eUL, 0xce0ae8a5UL, + 0x3fabb382UL, 0x79143126UL, 0x3fddba41UL, 0x5f2b28d4UL, 0x3fa552f1UL, + 0x59f21a6dUL, 0x3fd015abUL, 0x22c27d95UL, 0x3fa0e984UL, 0xe19fc6aaUL, + 0x3fd0576cUL, 0x8f2c2950UL, 0x3f9a4898UL, 0xc0b3f22cUL, 0x3fc59462UL, + 0x1883a4b8UL, 0x3f94b61cUL, 0x3f838640UL, 0x3fc30eb8UL, 0x355c63dcUL, + 0x3fd36a08UL, 0x1dce993dUL, 0xbc6d704dUL, 0x00000000UL, 0x3ff00000UL, + 0x2b82ab63UL, 0x3fb78e92UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x56f37042UL, 0x3fccfc56UL, 0x00000000UL, 0x00000000UL, + 0xaa563951UL, 0x3fc90125UL, 0x00000000UL, 0x00000000UL, 0x3d0e7c5dUL, + 0x3fc50533UL, 0x9bed9b2eUL, 0x3fdf0ed9UL, 0x5fe7c47cUL, 0x3fc1f250UL, + 0x96c125e5UL, 0x3fe2edd9UL, 0x5a02bbd8UL, 0x3fbe5c71UL, 0x86362c20UL, + 0x3fda08b7UL, 0x4b4435edUL, 0x3fb9d342UL, 0x4b494091UL, 0x3fd911bdUL, + 0xb56658beUL, 0x3fb5e4c7UL, 0x93a2fd76UL, 0x3fd3c092UL, 0xda271794UL, + 0x3fb29910UL, 0x3303df2bUL, 0x3fd189beUL, 0x99fcef32UL, 0x3fda8279UL, + 0xb68c1467UL, 0x3c708b2fUL, 0x00000000UL, 0x3ff00000UL, 0x980c4337UL, + 0x3fc5f619UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0xcc03e501UL, 0x3fdff10fUL, 0x00000000UL, 0x00000000UL, 0x44a4e845UL, + 0x3fddb63bUL, 0x00000000UL, 0x00000000UL, 0x3768ad9fUL, 0x3fdb72a4UL, + 0x3dd01ccaUL, 0x3fe5fdb9UL, 0xa61d2811UL, 0x3fd972b2UL, 0x5645ad0bUL, + 0x3fe977f9UL, 0xd013b3abUL, 0x3fd78ca3UL, 0xbf0bf914UL, 0x3fe4f192UL, + 0x4d53e730UL, 0x3fd5d060UL, 0x3f8b9000UL, 0x3fe49933UL, 0xe2b82f08UL, + 0x3fd4322aUL, 0x5936a835UL, 0x3fe27ae1UL, 0xb1c61c9bUL, 0x3fd2b3fbUL, + 0xef478605UL, 0x3fe1659eUL, 0x190834ecUL, 0x3fe11ab7UL, 0xcdb625eaUL, + 0xbc8e564bUL, 0x00000000UL, 0x3ff00000UL, 0xb07217e3UL, 0x3fd248f1UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x2b2c49d0UL, + 0x3ff2de9cUL, 0x00000000UL, 0x00000000UL, 0x2655bc98UL, 0x3ff33e58UL, + 0x00000000UL, 0x00000000UL, 0xff691fa2UL, 0x3ff3972eUL, 0xe93463bdUL, + 0x3feeed87UL, 0x070e10a0UL, 0x3ff3f5b2UL, 0xf4d790a4UL, 0x3ff20c10UL, + 0xa04e8ea3UL, 0x3ff4541aUL, 0x386accd3UL, 0x3ff1369eUL, 0x222a66ddUL, + 0x3ff4b521UL, 0x22a9777eUL, 0x3ff20817UL, 0x52a04a6eUL, 0x3ff5178fUL, + 0xddaa0031UL, 0x3ff22137UL, 0x4447d47cUL, 0x3ff57c01UL, 0x1e9c7f1dUL, + 0x3ff29311UL, 0x2ab7f990UL, 0x3fe561b8UL, 0x209c7df1UL, 0x3c87a8c5UL, + 0x00000000UL, 0x3ff00000UL, 0x4170bcc6UL, 0x3fdc92d8UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xc7ab4d5aUL, 0x40085e24UL, + 0x00000000UL, 0x00000000UL, 0xe93ea75dUL, 0x400b963dUL, 0x00000000UL, + 0x00000000UL, 0x94a7f25aUL, 0x400f37e2UL, 0x4b6261cbUL, 0x3ff5f984UL, + 0x5a9dd812UL, 0x4011aab0UL, 0x74c30018UL, 0x3ffaf5a5UL, 0x7f2ce8e3UL, + 0x4013fe8bUL, 0xfe8e54faUL, 0x3ffd7334UL, 0x670d618dUL, 0x4016a10cUL, + 0x4db97058UL, 0x4000e012UL, 0x24df44ddUL, 0x40199c5fUL, 0x697d6eceUL, + 0x4003006eUL, 0x83298b82UL, 0x401cfc4dUL, 0x19d490d6UL, 0x40058c19UL, + 0x2ae42850UL, 0x3fea4300UL, 0x118e20e6UL, 0xbc7a6db8UL, 0x00000000UL, + 0x40000000UL, 0xe33345b8UL, 0xbfd4e526UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x65965966UL, 0x40219659UL, 0x00000000UL, + 0x00000000UL, 0x882c10faUL, 0x402664f4UL, 0x00000000UL, 0x00000000UL, + 0x83cd3723UL, 0x402c8342UL, 0x00000000UL, 0x40000000UL, 0x55e6c23dUL, + 0x403226e3UL, 0x55555555UL, 0x40055555UL, 0x34451939UL, 0x40371c96UL, + 0xaaaaaaabUL, 0x400aaaaaUL, 0x0e157de0UL, 0x403d6d3dUL, 0x11111111UL, + 0x40111111UL, 0xa738201fUL, 0x4042bbceUL, 0x05b05b06UL, 0x4015b05bUL, + 0x452b75e3UL, 0x4047da36UL, 0x1ba1ba1cUL, 0x401ba1baUL, 0x00000000UL, + 0x3ff00000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x40000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x4f48b8d3UL, 0xbf33eaf9UL, 0x00000000UL, 0x00000000UL, + 0x0cf7586fUL, 0x3f20b8eaUL, 0x00000000UL, 0x00000000UL, 0xd0258911UL, + 0xbf0abaf3UL, 0x23e49fe9UL, 0xbfab5a8cUL, 0x2d53222eUL, 0x3ef60d15UL, + 0x21169451UL, 0x3fa172b2UL, 0xbb254dbcUL, 0xbee1d3b5UL, 0xdbf93b8eUL, + 0xbf84c7dbUL, 0x05b4630bUL, 0x3ecd3364UL, 0xee9aada7UL, 0x3f743924UL, + 0x794a8297UL, 0xbeb7b7b9UL, 0xe015f797UL, 0xbf5d41f5UL, 0xe41a4a56UL, + 0x3ea35dfbUL, 0xe4c2a251UL, 0x3f49a2abUL, 0x5af9e000UL, 0xbfce49ceUL, + 0x8c743719UL, 0x3d1eb860UL, 0x00000000UL, 0x00000000UL, 0x1b4863cfUL, + 0x3fd78294UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, + 0x535ad890UL, 0xbf2b9320UL, 0x00000000UL, 0x00000000UL, 0x018fdf1fUL, + 0x3f16d61dUL, 0x00000000UL, 0x00000000UL, 0x0359f1beUL, 0xbf0139e4UL, + 0xa4317c6dUL, 0xbfa67e17UL, 0x82672d0fUL, 0x3eebb405UL, 0x2f1b621eUL, + 0x3f9f455bUL, 0x51ccf238UL, 0xbed55317UL, 0xf437b9acUL, 0xbf804beeUL, + 0xc791a2b5UL, 0x3ec0e993UL, 0x919a1db2UL, 0x3f7080c2UL, 0x336a5b0eUL, + 0xbeaa48a2UL, 0x0a268358UL, 0xbf55a443UL, 0xdfd978e4UL, 0x3e94b61fUL, + 0xd7767a58UL, 0x3f431806UL, 0x2aea0000UL, 0xbfc9bbe8UL, 0x7723ea61UL, + 0xbd3a2369UL, 0x00000000UL, 0x00000000UL, 0xdf7796ffUL, 0x3fd6e642UL, + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0xb9ff07ceUL, + 0xbf231c78UL, 0x00000000UL, 0x00000000UL, 0xa5517182UL, 0x3f0ff0e0UL, + 0x00000000UL, 0x00000000UL, 0x790b4cbcUL, 0xbef66191UL, 0x848a46c6UL, + 0xbfa21ac0UL, 0xb16435faUL, 0x3ee1d3ecUL, 0x2a1aa832UL, 0x3f9c71eaUL, + 0xfdd299efUL, 0xbec9dd1aUL, 0x3f8dbaafUL, 0xbf793363UL, 0x309fc6eaUL, + 0x3eb415d6UL, 0xbee60471UL, 0x3f6b83baUL, 0x94a0a697UL, 0xbe9dae11UL, + 0x3e5c67b3UL, 0xbf4fd07bUL, 0x9a8f3e3eUL, 0x3e86bd75UL, 0xa4beb7a4UL, + 0x3f3d1eb1UL, 0x29cfc000UL, 0xbfc549ceUL, 0xbf159358UL, 0xbd397b33UL, + 0x00000000UL, 0x00000000UL, 0x871fee6cUL, 0x3fd666f0UL, 0x00000000UL, + 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x7d98a556UL, 0xbf1a3958UL, + 0x00000000UL, 0x00000000UL, 0x9d88dc01UL, 0x3f0704c2UL, 0x00000000UL, + 0x00000000UL, 0x73742a2bUL, 0xbeed054aUL, 0x58844587UL, 0xbf9c2a13UL, + 0x55688a79UL, 0x3ed7a326UL, 0xee33f1d6UL, 0x3f9a48f4UL, 0xa8dc9888UL, + 0xbebf8939UL, 0xaad4b5b8UL, 0xbf72f746UL, 0x9102efa1UL, 0x3ea88f82UL, + 0xdabc29cfUL, 0x3f678228UL, 0x9289afb8UL, 0xbe90f456UL, 0x741fb4edUL, + 0xbf46f3a3UL, 0xa97f6663UL, 0x3e79b4bfUL, 0xca89ff3fUL, 0x3f36db70UL, + 0xa8a2a000UL, 0xbfc0ee13UL, 0x3da24be1UL, 0xbd338b9fUL, 0x00000000UL, + 0x00000000UL, 0x11cd6c69UL, 0x3fd601fdUL, 0x00000000UL, 0x3ff00000UL, + 0x00000000UL, 0xfffffff8UL, 0x1a154b97UL, 0xbf116b01UL, 0x00000000UL, + 0x00000000UL, 0x2d427630UL, 0x3f0147bfUL, 0x00000000UL, 0x00000000UL, + 0xb93820c8UL, 0xbee264d4UL, 0xbb6cbb18UL, 0xbf94ab8cUL, 0x888d4d92UL, + 0x3ed0568bUL, 0x60730f7cUL, 0x3f98b19bUL, 0xe4b1fb11UL, 0xbeb2f950UL, + 0x22cf9f74UL, 0xbf6b21cdUL, 0x4a3ff0a6UL, 0x3e9f499eUL, 0xfd2b83ceUL, + 0x3f64aad7UL, 0x637b73afUL, 0xbe83487cUL, 0xe522591aUL, 0xbf3fc092UL, + 0xa158e8bcUL, 0x3e6e3aaeUL, 0xe5e82ffaUL, 0x3f329d2fUL, 0xd636a000UL, + 0xbfb9477fUL, 0xc2c2d2bcUL, 0xbd135ef9UL, 0x00000000UL, 0x00000000UL, + 0xf2fdb123UL, 0x3fd5b566UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, + 0xfffffff8UL, 0xc41acb64UL, 0xbf05448dUL, 0x00000000UL, 0x00000000UL, + 0xdbb03d6fUL, 0x3efb7ad2UL, 0x00000000UL, 0x00000000UL, 0x9e42962dUL, + 0xbed5aea5UL, 0x2579f8efUL, 0xbf8b2398UL, 0x288a1ed9UL, 0x3ec81441UL, + 0xb0198dc5UL, 0x3f979a3aUL, 0x2fdfe253UL, 0xbea57cd3UL, 0x5766336fUL, + 0xbf617caaUL, 0x600944c3UL, 0x3e954ed6UL, 0xa4e0aaf8UL, 0x3f62c646UL, + 0x6b8fb29cUL, 0xbe74e3a3UL, 0xdc4c0409UL, 0xbf33f952UL, 0x9bffe365UL, + 0x3e6301ecUL, 0xb8869e44UL, 0x3f2fc566UL, 0xe1e04000UL, 0xbfb0cc62UL, + 0x016b907fUL, 0xbd119cbcUL, 0x00000000UL, 0x00000000UL, 0xe6b9d8faUL, + 0x3fd57fb3UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, + 0x5daf22a6UL, 0xbef429d7UL, 0x00000000UL, 0x00000000UL, 0x06bca545UL, + 0x3ef7a27dUL, 0x00000000UL, 0x00000000UL, 0x7211c19aUL, 0xbec41c3eUL, + 0x956ed53eUL, 0xbf7ae3f4UL, 0xee750e72UL, 0x3ec3901bUL, 0x91d443f5UL, + 0x3f96f713UL, 0x36661e6cUL, 0xbe936e09UL, 0x506f9381UL, 0xbf5122e8UL, + 0xcb6dd43fUL, 0x3e9041b9UL, 0x6698b2ffUL, 0x3f61b0c7UL, 0x576bf12bUL, + 0xbe625a8aUL, 0xe5a0e9dcUL, 0xbf23499dUL, 0x110384ddUL, 0x3e5b1c2cUL, + 0x68d43db6UL, 0x3f2cb899UL, 0x6ecac000UL, 0xbfa0c414UL, 0xcd7dd58cUL, + 0x3d13500fUL, 0x00000000UL, 0x00000000UL, 0x85a2c8fbUL, 0x3fd55fe0UL, + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x2bf70ebeUL, 0x3ef66a8fUL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0xd644267fUL, 0x3ec22805UL, 0x16c16c17UL, 0x3f96c16cUL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xc4e09162UL, + 0x3e8d6db2UL, 0xbc011567UL, 0x3f61566aUL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x1f79955cUL, 0x3e57da4eUL, 0x9334ef0bUL, + 0x3f2bbd77UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x55555555UL, 0x3fd55555UL, 0x00000000UL, + 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x5daf22a6UL, 0x3ef429d7UL, + 0x00000000UL, 0x00000000UL, 0x06bca545UL, 0x3ef7a27dUL, 0x00000000UL, + 0x00000000UL, 0x7211c19aUL, 0x3ec41c3eUL, 0x956ed53eUL, 0x3f7ae3f4UL, + 0xee750e72UL, 0x3ec3901bUL, 0x91d443f5UL, 0x3f96f713UL, 0x36661e6cUL, + 0x3e936e09UL, 0x506f9381UL, 0x3f5122e8UL, 0xcb6dd43fUL, 0x3e9041b9UL, + 0x6698b2ffUL, 0x3f61b0c7UL, 0x576bf12bUL, 0x3e625a8aUL, 0xe5a0e9dcUL, + 0x3f23499dUL, 0x110384ddUL, 0x3e5b1c2cUL, 0x68d43db6UL, 0x3f2cb899UL, + 0x6ecac000UL, 0x3fa0c414UL, 0xcd7dd58cUL, 0xbd13500fUL, 0x00000000UL, + 0x00000000UL, 0x85a2c8fbUL, 0x3fd55fe0UL, 0x00000000UL, 0x3ff00000UL, + 0x00000000UL, 0xfffffff8UL, 0xc41acb64UL, 0x3f05448dUL, 0x00000000UL, + 0x00000000UL, 0xdbb03d6fUL, 0x3efb7ad2UL, 0x00000000UL, 0x00000000UL, + 0x9e42962dUL, 0x3ed5aea5UL, 0x2579f8efUL, 0x3f8b2398UL, 0x288a1ed9UL, + 0x3ec81441UL, 0xb0198dc5UL, 0x3f979a3aUL, 0x2fdfe253UL, 0x3ea57cd3UL, + 0x5766336fUL, 0x3f617caaUL, 0x600944c3UL, 0x3e954ed6UL, 0xa4e0aaf8UL, + 0x3f62c646UL, 0x6b8fb29cUL, 0x3e74e3a3UL, 0xdc4c0409UL, 0x3f33f952UL, + 0x9bffe365UL, 0x3e6301ecUL, 0xb8869e44UL, 0x3f2fc566UL, 0xe1e04000UL, + 0x3fb0cc62UL, 0x016b907fUL, 0x3d119cbcUL, 0x00000000UL, 0x00000000UL, + 0xe6b9d8faUL, 0x3fd57fb3UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, + 0xfffffff8UL, 0x1a154b97UL, 0x3f116b01UL, 0x00000000UL, 0x00000000UL, + 0x2d427630UL, 0x3f0147bfUL, 0x00000000UL, 0x00000000UL, 0xb93820c8UL, + 0x3ee264d4UL, 0xbb6cbb18UL, 0x3f94ab8cUL, 0x888d4d92UL, 0x3ed0568bUL, + 0x60730f7cUL, 0x3f98b19bUL, 0xe4b1fb11UL, 0x3eb2f950UL, 0x22cf9f74UL, + 0x3f6b21cdUL, 0x4a3ff0a6UL, 0x3e9f499eUL, 0xfd2b83ceUL, 0x3f64aad7UL, + 0x637b73afUL, 0x3e83487cUL, 0xe522591aUL, 0x3f3fc092UL, 0xa158e8bcUL, + 0x3e6e3aaeUL, 0xe5e82ffaUL, 0x3f329d2fUL, 0xd636a000UL, 0x3fb9477fUL, + 0xc2c2d2bcUL, 0x3d135ef9UL, 0x00000000UL, 0x00000000UL, 0xf2fdb123UL, + 0x3fd5b566UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, + 0x7d98a556UL, 0x3f1a3958UL, 0x00000000UL, 0x00000000UL, 0x9d88dc01UL, + 0x3f0704c2UL, 0x00000000UL, 0x00000000UL, 0x73742a2bUL, 0x3eed054aUL, + 0x58844587UL, 0x3f9c2a13UL, 0x55688a79UL, 0x3ed7a326UL, 0xee33f1d6UL, + 0x3f9a48f4UL, 0xa8dc9888UL, 0x3ebf8939UL, 0xaad4b5b8UL, 0x3f72f746UL, + 0x9102efa1UL, 0x3ea88f82UL, 0xdabc29cfUL, 0x3f678228UL, 0x9289afb8UL, + 0x3e90f456UL, 0x741fb4edUL, 0x3f46f3a3UL, 0xa97f6663UL, 0x3e79b4bfUL, + 0xca89ff3fUL, 0x3f36db70UL, 0xa8a2a000UL, 0x3fc0ee13UL, 0x3da24be1UL, + 0x3d338b9fUL, 0x00000000UL, 0x00000000UL, 0x11cd6c69UL, 0x3fd601fdUL, + 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0xb9ff07ceUL, + 0x3f231c78UL, 0x00000000UL, 0x00000000UL, 0xa5517182UL, 0x3f0ff0e0UL, + 0x00000000UL, 0x00000000UL, 0x790b4cbcUL, 0x3ef66191UL, 0x848a46c6UL, + 0x3fa21ac0UL, 0xb16435faUL, 0x3ee1d3ecUL, 0x2a1aa832UL, 0x3f9c71eaUL, + 0xfdd299efUL, 0x3ec9dd1aUL, 0x3f8dbaafUL, 0x3f793363UL, 0x309fc6eaUL, + 0x3eb415d6UL, 0xbee60471UL, 0x3f6b83baUL, 0x94a0a697UL, 0x3e9dae11UL, + 0x3e5c67b3UL, 0x3f4fd07bUL, 0x9a8f3e3eUL, 0x3e86bd75UL, 0xa4beb7a4UL, + 0x3f3d1eb1UL, 0x29cfc000UL, 0x3fc549ceUL, 0xbf159358UL, 0x3d397b33UL, + 0x00000000UL, 0x00000000UL, 0x871fee6cUL, 0x3fd666f0UL, 0x00000000UL, + 0x3ff00000UL, 0x00000000UL, 0xfffffff8UL, 0x535ad890UL, 0x3f2b9320UL, + 0x00000000UL, 0x00000000UL, 0x018fdf1fUL, 0x3f16d61dUL, 0x00000000UL, + 0x00000000UL, 0x0359f1beUL, 0x3f0139e4UL, 0xa4317c6dUL, 0x3fa67e17UL, + 0x82672d0fUL, 0x3eebb405UL, 0x2f1b621eUL, 0x3f9f455bUL, 0x51ccf238UL, + 0x3ed55317UL, 0xf437b9acUL, 0x3f804beeUL, 0xc791a2b5UL, 0x3ec0e993UL, + 0x919a1db2UL, 0x3f7080c2UL, 0x336a5b0eUL, 0x3eaa48a2UL, 0x0a268358UL, + 0x3f55a443UL, 0xdfd978e4UL, 0x3e94b61fUL, 0xd7767a58UL, 0x3f431806UL, + 0x2aea0000UL, 0x3fc9bbe8UL, 0x7723ea61UL, 0x3d3a2369UL, 0x00000000UL, + 0x00000000UL, 0xdf7796ffUL, 0x3fd6e642UL, 0x00000000UL, 0x3ff00000UL, + 0x00000000UL, 0xfffffff8UL, 0x4f48b8d3UL, 0x3f33eaf9UL, 0x00000000UL, + 0x00000000UL, 0x0cf7586fUL, 0x3f20b8eaUL, 0x00000000UL, 0x00000000UL, + 0xd0258911UL, 0x3f0abaf3UL, 0x23e49fe9UL, 0x3fab5a8cUL, 0x2d53222eUL, + 0x3ef60d15UL, 0x21169451UL, 0x3fa172b2UL, 0xbb254dbcUL, 0x3ee1d3b5UL, + 0xdbf93b8eUL, 0x3f84c7dbUL, 0x05b4630bUL, 0x3ecd3364UL, 0xee9aada7UL, + 0x3f743924UL, 0x794a8297UL, 0x3eb7b7b9UL, 0xe015f797UL, 0x3f5d41f5UL, + 0xe41a4a56UL, 0x3ea35dfbUL, 0xe4c2a251UL, 0x3f49a2abUL, 0x5af9e000UL, + 0x3fce49ceUL, 0x8c743719UL, 0xbd1eb860UL, 0x00000000UL, 0x00000000UL, + 0x1b4863cfUL, 0x3fd78294UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, + 0xfffffff8UL, 0x65965966UL, 0xc0219659UL, 0x00000000UL, 0x00000000UL, + 0x882c10faUL, 0x402664f4UL, 0x00000000UL, 0x00000000UL, 0x83cd3723UL, + 0xc02c8342UL, 0x00000000UL, 0xc0000000UL, 0x55e6c23dUL, 0x403226e3UL, + 0x55555555UL, 0x40055555UL, 0x34451939UL, 0xc0371c96UL, 0xaaaaaaabUL, + 0xc00aaaaaUL, 0x0e157de0UL, 0x403d6d3dUL, 0x11111111UL, 0x40111111UL, + 0xa738201fUL, 0xc042bbceUL, 0x05b05b06UL, 0xc015b05bUL, 0x452b75e3UL, + 0x4047da36UL, 0x1ba1ba1cUL, 0x401ba1baUL, 0x00000000UL, 0xbff00000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x40000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0xc7ab4d5aUL, 0xc0085e24UL, 0x00000000UL, 0x00000000UL, 0xe93ea75dUL, + 0x400b963dUL, 0x00000000UL, 0x00000000UL, 0x94a7f25aUL, 0xc00f37e2UL, + 0x4b6261cbUL, 0xbff5f984UL, 0x5a9dd812UL, 0x4011aab0UL, 0x74c30018UL, + 0x3ffaf5a5UL, 0x7f2ce8e3UL, 0xc013fe8bUL, 0xfe8e54faUL, 0xbffd7334UL, + 0x670d618dUL, 0x4016a10cUL, 0x4db97058UL, 0x4000e012UL, 0x24df44ddUL, + 0xc0199c5fUL, 0x697d6eceUL, 0xc003006eUL, 0x83298b82UL, 0x401cfc4dUL, + 0x19d490d6UL, 0x40058c19UL, 0x2ae42850UL, 0xbfea4300UL, 0x118e20e6UL, + 0x3c7a6db8UL, 0x00000000UL, 0x40000000UL, 0xe33345b8UL, 0xbfd4e526UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x2b2c49d0UL, + 0xbff2de9cUL, 0x00000000UL, 0x00000000UL, 0x2655bc98UL, 0x3ff33e58UL, + 0x00000000UL, 0x00000000UL, 0xff691fa2UL, 0xbff3972eUL, 0xe93463bdUL, + 0xbfeeed87UL, 0x070e10a0UL, 0x3ff3f5b2UL, 0xf4d790a4UL, 0x3ff20c10UL, + 0xa04e8ea3UL, 0xbff4541aUL, 0x386accd3UL, 0xbff1369eUL, 0x222a66ddUL, + 0x3ff4b521UL, 0x22a9777eUL, 0x3ff20817UL, 0x52a04a6eUL, 0xbff5178fUL, + 0xddaa0031UL, 0xbff22137UL, 0x4447d47cUL, 0x3ff57c01UL, 0x1e9c7f1dUL, + 0x3ff29311UL, 0x2ab7f990UL, 0xbfe561b8UL, 0x209c7df1UL, 0xbc87a8c5UL, + 0x00000000UL, 0x3ff00000UL, 0x4170bcc6UL, 0x3fdc92d8UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0xcc03e501UL, 0xbfdff10fUL, + 0x00000000UL, 0x00000000UL, 0x44a4e845UL, 0x3fddb63bUL, 0x00000000UL, + 0x00000000UL, 0x3768ad9fUL, 0xbfdb72a4UL, 0x3dd01ccaUL, 0xbfe5fdb9UL, + 0xa61d2811UL, 0x3fd972b2UL, 0x5645ad0bUL, 0x3fe977f9UL, 0xd013b3abUL, + 0xbfd78ca3UL, 0xbf0bf914UL, 0xbfe4f192UL, 0x4d53e730UL, 0x3fd5d060UL, + 0x3f8b9000UL, 0x3fe49933UL, 0xe2b82f08UL, 0xbfd4322aUL, 0x5936a835UL, + 0xbfe27ae1UL, 0xb1c61c9bUL, 0x3fd2b3fbUL, 0xef478605UL, 0x3fe1659eUL, + 0x190834ecUL, 0xbfe11ab7UL, 0xcdb625eaUL, 0x3c8e564bUL, 0x00000000UL, + 0x3ff00000UL, 0xb07217e3UL, 0x3fd248f1UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x56f37042UL, 0xbfccfc56UL, 0x00000000UL, + 0x00000000UL, 0xaa563951UL, 0x3fc90125UL, 0x00000000UL, 0x00000000UL, + 0x3d0e7c5dUL, 0xbfc50533UL, 0x9bed9b2eUL, 0xbfdf0ed9UL, 0x5fe7c47cUL, + 0x3fc1f250UL, 0x96c125e5UL, 0x3fe2edd9UL, 0x5a02bbd8UL, 0xbfbe5c71UL, + 0x86362c20UL, 0xbfda08b7UL, 0x4b4435edUL, 0x3fb9d342UL, 0x4b494091UL, + 0x3fd911bdUL, 0xb56658beUL, 0xbfb5e4c7UL, 0x93a2fd76UL, 0xbfd3c092UL, + 0xda271794UL, 0x3fb29910UL, 0x3303df2bUL, 0x3fd189beUL, 0x99fcef32UL, + 0xbfda8279UL, 0xb68c1467UL, 0xbc708b2fUL, 0x00000000UL, 0x3ff00000UL, + 0x980c4337UL, 0x3fc5f619UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x9314533eUL, 0xbfbb8ec5UL, 0x00000000UL, 0x00000000UL, + 0x09aa36d0UL, 0x3fb6d3f4UL, 0x00000000UL, 0x00000000UL, 0xdcb427fdUL, + 0xbfb13950UL, 0xd87ab0bbUL, 0xbfd5335eUL, 0xce0ae8a5UL, 0x3fabb382UL, + 0x79143126UL, 0x3fddba41UL, 0x5f2b28d4UL, 0xbfa552f1UL, 0x59f21a6dUL, + 0xbfd015abUL, 0x22c27d95UL, 0x3fa0e984UL, 0xe19fc6aaUL, 0x3fd0576cUL, + 0x8f2c2950UL, 0xbf9a4898UL, 0xc0b3f22cUL, 0xbfc59462UL, 0x1883a4b8UL, + 0x3f94b61cUL, 0x3f838640UL, 0x3fc30eb8UL, 0x355c63dcUL, 0xbfd36a08UL, + 0x1dce993dUL, 0x3c6d704dUL, 0x00000000UL, 0x3ff00000UL, 0x2b82ab63UL, + 0x3fb78e92UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, + 0x5a279ea3UL, 0xbfaa3407UL, 0x00000000UL, 0x00000000UL, 0x432d65faUL, + 0x3fa70153UL, 0x00000000UL, 0x00000000UL, 0x891a4602UL, 0xbf9d03efUL, + 0xd62ca5f8UL, 0xbfca77d9UL, 0xb35f4628UL, 0x3f97a265UL, 0x433258faUL, + 0x3fd8cf51UL, 0xb58fd909UL, 0xbf8f88e3UL, 0x01771ceaUL, 0xbfc2b154UL, + 0xf3562f8eUL, 0x3f888f57UL, 0xc028a723UL, 0x3fc7370fUL, 0x20b7f9f0UL, + 0xbf80f44cUL, 0x214368e9UL, 0xbfb6dfaaUL, 0x28891863UL, 0x3f79b4b6UL, + 0x172dbbf0UL, 0x3fb6cb8eUL, 0xe0553158UL, 0xbfc975f5UL, 0x593fe814UL, + 0xbc2ef5d3UL, 0x00000000UL, 0x3ff00000UL, 0x03dec550UL, 0x3fa44203UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x4e435f9bUL, + 0xbf953f83UL, 0x00000000UL, 0x00000000UL, 0x3c6e8e46UL, 0x3f9b74eaUL, + 0x00000000UL, 0x00000000UL, 0xda5b7511UL, 0xbf85ad63UL, 0xdc230b9bUL, + 0xbfb97558UL, 0x26cb3788UL, 0x3f881308UL, 0x76fc4985UL, 0x3fd62ac9UL, + 0x77bb08baUL, 0xbf757c85UL, 0xb6247521UL, 0xbfb1381eUL, 0x5922170cUL, + 0x3f754e95UL, 0x8746482dUL, 0x3fc27f83UL, 0x11055b30UL, 0xbf64e391UL, + 0x3e666320UL, 0xbfa3e609UL, 0x0de9dae3UL, 0x3f6301dfUL, 0x1f1dca06UL, + 0x3fafa8aeUL, 0x8c5b2da2UL, 0xbfb936bbUL, 0x4e88f7a5UL, 0xbc587d05UL, + 0x00000000UL, 0x3ff00000UL, 0xa8935dd9UL, 0x3f83dde2UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x6dc9c883UL, 0x3fe45f30UL, + 0x6dc9c883UL, 0x40245f30UL, 0x00000000UL, 0x43780000UL, 0x00000000UL, + 0x43380000UL, 0x54444000UL, 0x3fb921fbUL, 0x54440000UL, 0x3fb921fbUL, + 0x67674000UL, 0xbd32e7b9UL, 0x4c4c0000UL, 0x3d468c23UL, 0x3707344aUL, + 0x3aa8a2e0UL, 0x03707345UL, 0x3ae98a2eUL, 0x00000000UL, 0x80000000UL, + 0x00000000UL, 0x80000000UL, 0x676733afUL, 0x3d32e7b9UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x3ff00000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x7ff00000UL, 0x00000000UL, 0x00000000UL, 0xfffc0000UL, + 0xffffffffUL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x43600000UL, + 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x3c800000UL, 0x00000000UL, + 0x00000000UL, 0x00000000UL, 0x3ca00000UL, 0x00000000UL, 0x00000000UL, + 0x00000000UL, 0x3fe00000UL, 0x00000000UL, 0x3fe00000UL, 0x00000000UL, + 0x40300000UL, 0x00000000UL, 0x3ff00000UL +}; + +void MacroAssembler::fast_tan(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ecx, Register edx, Register tmp) { + + Label L_2TAG_PACKET_0_0_2, L_2TAG_PACKET_1_0_2, L_2TAG_PACKET_2_0_2, L_2TAG_PACKET_3_0_2; + Label L_2TAG_PACKET_4_0_2, L_2TAG_PACKET_5_0_2, L_2TAG_PACKET_6_0_2, L_2TAG_PACKET_7_0_2; + Label L_2TAG_PACKET_8_0_2, L_2TAG_PACKET_9_0_2, L_2TAG_PACKET_10_0_2, L_2TAG_PACKET_11_0_2; + Label L_2TAG_PACKET_12_0_2, L_2TAG_PACKET_13_0_2, B1_3, B1_5, start; + + assert_different_registers(tmp, eax, ecx, edx); + + address static_const_table_tan = (address)_static_const_table_tan; + + bind(start); + subl(rsp, 120); + movl(Address(rsp, 56), tmp); + lea(tmp, ExternalAddress(static_const_table_tan)); + movsd(xmm0, Address(rsp, 128)); + pextrw(eax, xmm0, 3); + andl(eax, 32767); + subl(eax, 14368); + cmpl(eax, 2216); + jcc(Assembler::above, L_2TAG_PACKET_0_0_2); + movdqu(xmm5, Address(tmp, 5840)); + movdqu(xmm6, Address(tmp, 5856)); + unpcklpd(xmm0, xmm0); + movdqu(xmm4, Address(tmp, 5712)); + andpd(xmm4, xmm0); + movdqu(xmm1, Address(tmp, 5632)); + mulpd(xmm1, xmm0); + por(xmm5, xmm4); + addpd(xmm1, xmm5); + movdqu(xmm7, xmm1); + unpckhpd(xmm7, xmm7); + cvttsd2sil(edx, xmm7); + cvttpd2dq(xmm1, xmm1); + cvtdq2pd(xmm1, xmm1); + mulpd(xmm1, xmm6); + movdqu(xmm3, Address(tmp, 5664)); + movsd(xmm5, Address(tmp, 5728)); + addl(edx, 469248); + movdqu(xmm4, Address(tmp, 5680)); + mulpd(xmm3, xmm1); + andl(edx, 31); + mulsd(xmm5, xmm1); + movl(ecx, edx); + mulpd(xmm4, xmm1); + shll(ecx, 1); + subpd(xmm0, xmm3); + mulpd(xmm1, Address(tmp, 5696)); + addl(edx, ecx); + shll(ecx, 2); + addl(edx, ecx); + addsd(xmm5, xmm0); + movdqu(xmm2, xmm0); + subpd(xmm0, xmm4); + movsd(xmm6, Address(tmp, 5744)); + shll(edx, 4); + lea(eax, Address(tmp, 0)); + andpd(xmm5, Address(tmp, 5776)); + movdqu(xmm3, xmm0); + addl(eax, edx); + subpd(xmm2, xmm0); + unpckhpd(xmm0, xmm0); + divsd(xmm6, xmm5); + subpd(xmm2, xmm4); + movdqu(xmm7, Address(eax, 16)); + subsd(xmm3, xmm5); + mulpd(xmm7, xmm0); + subpd(xmm2, xmm1); + movdqu(xmm1, Address(eax, 48)); + mulpd(xmm1, xmm0); + movdqu(xmm4, Address(eax, 96)); + mulpd(xmm4, xmm0); + addsd(xmm2, xmm3); + movdqu(xmm3, xmm0); + mulpd(xmm0, xmm0); + addpd(xmm7, Address(eax, 0)); + addpd(xmm1, Address(eax, 32)); + mulpd(xmm1, xmm0); + addpd(xmm4, Address(eax, 80)); + addpd(xmm7, xmm1); + movdqu(xmm1, Address(eax, 112)); + mulpd(xmm1, xmm0); + mulpd(xmm0, xmm0); + addpd(xmm4, xmm1); + movdqu(xmm1, Address(eax, 64)); + mulpd(xmm1, xmm0); + addpd(xmm7, xmm1); + movdqu(xmm1, xmm3); + mulpd(xmm3, xmm0); + mulsd(xmm0, xmm0); + mulpd(xmm1, Address(eax, 144)); + mulpd(xmm4, xmm3); + movdqu(xmm3, xmm1); + addpd(xmm7, xmm4); + movdqu(xmm4, xmm1); + mulsd(xmm0, xmm7); + unpckhpd(xmm7, xmm7); + addsd(xmm0, xmm7); + unpckhpd(xmm1, xmm1); + addsd(xmm3, xmm1); + subsd(xmm4, xmm3); + addsd(xmm1, xmm4); + movdqu(xmm4, xmm2); + movsd(xmm7, Address(eax, 144)); + unpckhpd(xmm2, xmm2); + addsd(xmm7, Address(eax, 152)); + mulsd(xmm7, xmm2); + addsd(xmm7, Address(eax, 136)); + addsd(xmm7, xmm1); + addsd(xmm0, xmm7); + movsd(xmm7, Address(tmp, 5744)); + mulsd(xmm4, xmm6); + movsd(xmm2, Address(eax, 168)); + andpd(xmm2, xmm6); + mulsd(xmm5, xmm2); + mulsd(xmm6, Address(eax, 160)); + subsd(xmm7, xmm5); + subsd(xmm2, Address(eax, 128)); + subsd(xmm7, xmm4); + mulsd(xmm7, xmm6); + movdqu(xmm4, xmm3); + subsd(xmm3, xmm2); + addsd(xmm2, xmm3); + subsd(xmm4, xmm2); + addsd(xmm0, xmm4); + subsd(xmm0, xmm7); + addsd(xmm0, xmm3); + movsd(Address(rsp, 0), xmm0); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_0_0_2); + jcc(Assembler::greater, L_2TAG_PACKET_2_0_2); + shrl(eax, 4); + cmpl(eax, 268434558); + jcc(Assembler::notEqual, L_2TAG_PACKET_3_0_2); + movdqu(xmm3, xmm0); + mulsd(xmm3, Address(tmp, 5808)); + + bind(L_2TAG_PACKET_3_0_2); + movsd(xmm3, Address(tmp, 5792)); + mulsd(xmm3, xmm0); + addsd(xmm3, xmm0); + mulsd(xmm3, Address(tmp, 5808)); + movsd(Address(rsp, 0), xmm3); + fld_d(Address(rsp, 0)); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_2_0_2); + movq(xmm7, Address(tmp, 5712)); + andpd(xmm7, xmm0); + xorpd(xmm7, xmm0); + ucomisd(xmm7, Address(tmp, 5760)); + jcc(Assembler::equal, L_2TAG_PACKET_4_0_2); + subl(rsp, 32); + movsd(Address(rsp, 0), xmm0); + lea(eax, Address(rsp, 40)); + movl(Address(rsp, 8), eax); + movl(eax, 2); + movl(Address(rsp, 12), eax); + call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlibm_tan_cot_huge()))); + addl(rsp, 32); + fld_d(Address(rsp, 8)); + jmp(L_2TAG_PACKET_1_0_2); + + bind(L_2TAG_PACKET_4_0_2); + movq(Address(rsp, 0), xmm0); + fld_d(Address(rsp, 0)); + fsub_d(Address(rsp, 0)); + + bind(L_2TAG_PACKET_1_0_2); + movl(tmp, Address(rsp, 56)); +} +#endif diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp index 756c032861e..d1dee9841ea 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp @@ -2093,25 +2093,6 @@ class StubGenerator: public StubCodeGenerator { entry_checkcast_arraycopy); } - void generate_math_stubs() { - { - StubCodeMark mark(this, "StubRoutines", "log10"); - StubRoutines::_intrinsic_log10 = (double (*)(double)) __ pc(); - - __ fld_d(Address(rsp, 4)); - __ flog10(); - __ ret(0); - } - { - StubCodeMark mark(this, "StubRoutines", "tan"); - StubRoutines::_intrinsic_tan = (double (*)(double)) __ pc(); - - __ fld_d(Address(rsp, 4)); - __ trigfunc('t'); - __ ret(0); - } - } - // AES intrinsic stubs enum {AESBlockSize = 16}; @@ -3534,6 +3515,31 @@ class StubGenerator: public StubCodeGenerator { } + address generate_libmLog10() { + address start = __ pc(); + + const XMMRegister x0 = xmm0; + const XMMRegister x1 = xmm1; + const XMMRegister x2 = xmm2; + const XMMRegister x3 = xmm3; + + const XMMRegister x4 = xmm4; + const XMMRegister x5 = xmm5; + const XMMRegister x6 = xmm6; + const XMMRegister x7 = xmm7; + + const Register tmp = rbx; + + BLOCK_COMMENT("Entry:"); + __ enter(); // required for proper stackwalking of RuntimeStub frame + __ fast_log10(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp); + __ leave(); // required for proper stackwalking of RuntimeStub frame + __ ret(0); + + return start; + + } + address generate_libmPow() { address start = __ pc(); @@ -3628,6 +3634,44 @@ class StubGenerator: public StubCodeGenerator { return start; + } + + address generate_libm_tan_cot_huge() { + address start = __ pc(); + + const XMMRegister x0 = xmm0; + const XMMRegister x1 = xmm1; + + BLOCK_COMMENT("Entry:"); + __ libm_tancot_huge(x0, x1, rax, rcx, rdx, rbx, rsi, rdi, rbp, rsp); + + return start; + + } + + address generate_libmTan() { + address start = __ pc(); + + const XMMRegister x0 = xmm0; + const XMMRegister x1 = xmm1; + const XMMRegister x2 = xmm2; + const XMMRegister x3 = xmm3; + + const XMMRegister x4 = xmm4; + const XMMRegister x5 = xmm5; + const XMMRegister x6 = xmm6; + const XMMRegister x7 = xmm7; + + const Register tmp = rbx; + + BLOCK_COMMENT("Entry:"); + __ enter(); // required for proper stackwalking of RuntimeStub frame + __ fast_tan(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp); + __ leave(); // required for proper stackwalking of RuntimeStub frame + __ ret(0); + + return start; + } // Safefetch stubs. @@ -3853,24 +3897,25 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_crc32c_table_addr = (address)StubRoutines::x86::_crc32c_table; StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(supports_clmul); } - if (VM_Version::supports_sse2()) { + if (VM_Version::supports_sse2() && UseLibmIntrinsic) { + StubRoutines::x86::_L_2il0floatpacket_0_adr = (address)StubRoutines::x86::_L_2il0floatpacket_0; + StubRoutines::x86::_Pi4Inv_adr = (address)StubRoutines::x86::_Pi4Inv; + StubRoutines::x86::_Pi4x3_adr = (address)StubRoutines::x86::_Pi4x3; + StubRoutines::x86::_Pi4x4_adr = (address)StubRoutines::x86::_Pi4x4; + StubRoutines::x86::_ones_adr = (address)StubRoutines::x86::_ones; StubRoutines::_dexp = generate_libmExp(); StubRoutines::_dlog = generate_libmLog(); + StubRoutines::_dlog10 = generate_libmLog10(); StubRoutines::_dpow = generate_libmPow(); - if (UseLibmSinIntrinsic || UseLibmCosIntrinsic) { - StubRoutines::_dlibm_reduce_pi04l = generate_libm_reduce_pi04l(); - StubRoutines::_dlibm_sin_cos_huge = generate_libm_sin_cos_huge(); - } - if (UseLibmSinIntrinsic) { - StubRoutines::_dsin = generate_libmSin(); - } - if (UseLibmCosIntrinsic) { - StubRoutines::_dcos = generate_libmCos(); - } + StubRoutines::_dlibm_reduce_pi04l = generate_libm_reduce_pi04l(); + StubRoutines::_dlibm_sin_cos_huge = generate_libm_sin_cos_huge(); + StubRoutines::_dsin = generate_libmSin(); + StubRoutines::_dcos = generate_libmCos(); + StubRoutines::_dlibm_tan_cot_huge = generate_libm_tan_cot_huge(); + StubRoutines::_dtan = generate_libmTan(); } } - void generate_all() { // Generates all stubs and initializes the entry points @@ -3889,8 +3934,6 @@ class StubGenerator: public StubCodeGenerator { // arraycopy stubs used by compilers generate_arraycopy_stubs(); - generate_math_stubs(); - // don't bother generating these AES intrinsic stubs unless global flag is set if (UseAESIntrinsics) { StubRoutines::x86::_key_shuffle_mask_addr = generate_key_shuffle_mask(); // might be needed by the others diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp index 882969c5695..309eaea5d68 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp @@ -2972,35 +2972,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_arrayof_oop_arraycopy_uninit = StubRoutines::_oop_arraycopy_uninit; } - void generate_math_stubs() { - { - StubCodeMark mark(this, "StubRoutines", "log10"); - StubRoutines::_intrinsic_log10 = (double (*)(double)) __ pc(); - - __ subq(rsp, 8); - __ movdbl(Address(rsp, 0), xmm0); - __ fld_d(Address(rsp, 0)); - __ flog10(); - __ fstp_d(Address(rsp, 0)); - __ movdbl(xmm0, Address(rsp, 0)); - __ addq(rsp, 8); - __ ret(0); - } - { - StubCodeMark mark(this, "StubRoutines", "tan"); - StubRoutines::_intrinsic_tan = (double (*)(double)) __ pc(); - - __ subq(rsp, 8); - __ movdbl(Address(rsp, 0), xmm0); - __ fld_d(Address(rsp, 0)); - __ trigfunc('t'); - __ fstp_d(Address(rsp, 0)); - __ movdbl(xmm0, Address(rsp, 0)); - __ addq(rsp, 8); - __ ret(0); - } - } - // AES intrinsic stubs enum {AESBlockSize = 16}; @@ -4731,6 +4702,46 @@ class StubGenerator: public StubCodeGenerator { #endif __ fast_log(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2); +#ifdef _WIN64 + // restore xmm regs belonging to calling function + __ movdqu(xmm6, Address(rsp, 0)); + __ movdqu(xmm7, Address(rsp, 2 * wordSize)); + __ addptr(rsp, 4 * wordSize); +#endif + + __ leave(); // required for proper stackwalking of RuntimeStub frame + __ ret(0); + + return start; + + } + + address generate_libmLog10() { + address start = __ pc(); + + const XMMRegister x0 = xmm0; + const XMMRegister x1 = xmm1; + const XMMRegister x2 = xmm2; + const XMMRegister x3 = xmm3; + + const XMMRegister x4 = xmm4; + const XMMRegister x5 = xmm5; + const XMMRegister x6 = xmm6; + const XMMRegister x7 = xmm7; + + const Register tmp = r11; + + BLOCK_COMMENT("Entry:"); + __ enter(); // required for proper stackwalking of RuntimeStub frame + +#ifdef _WIN64 + // save the xmm registers which must be preserved 6-7 + __ subptr(rsp, 4 * wordSize); + __ movdqu(Address(rsp, 0), xmm6); + __ movdqu(Address(rsp, 2 * wordSize), xmm7); +#endif + __ fast_log10(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp); + #ifdef _WIN64 // restore xmm regs belonging to calling function __ movdqu(xmm6, Address(rsp, 0)); @@ -4810,6 +4821,8 @@ class StubGenerator: public StubCodeGenerator { __ enter(); // required for proper stackwalking of RuntimeStub frame #ifdef _WIN64 + __ push(rsi); + __ push(rdi); // save the xmm registers which must be preserved 6-7 __ subptr(rsp, 4 * wordSize); __ movdqu(Address(rsp, 0), xmm6); @@ -4822,6 +4835,8 @@ class StubGenerator: public StubCodeGenerator { __ movdqu(xmm6, Address(rsp, 0)); __ movdqu(xmm7, Address(rsp, 2 * wordSize)); __ addptr(rsp, 4 * wordSize); + __ pop(rdi); + __ pop(rsi); #endif __ leave(); // required for proper stackwalking of RuntimeStub frame @@ -4853,6 +4868,8 @@ class StubGenerator: public StubCodeGenerator { __ enter(); // required for proper stackwalking of RuntimeStub frame #ifdef _WIN64 + __ push(rsi); + __ push(rdi); // save the xmm registers which must be preserved 6-7 __ subptr(rsp, 4 * wordSize); __ movdqu(Address(rsp, 0), xmm6); @@ -4865,6 +4882,55 @@ class StubGenerator: public StubCodeGenerator { __ movdqu(xmm6, Address(rsp, 0)); __ movdqu(xmm7, Address(rsp, 2 * wordSize)); __ addptr(rsp, 4 * wordSize); + __ pop(rdi); + __ pop(rsi); +#endif + + __ leave(); // required for proper stackwalking of RuntimeStub frame + __ ret(0); + + return start; + + } + + address generate_libmTan() { + address start = __ pc(); + + const XMMRegister x0 = xmm0; + const XMMRegister x1 = xmm1; + const XMMRegister x2 = xmm2; + const XMMRegister x3 = xmm3; + + const XMMRegister x4 = xmm4; + const XMMRegister x5 = xmm5; + const XMMRegister x6 = xmm6; + const XMMRegister x7 = xmm7; + + const Register tmp1 = r8; + const Register tmp2 = r9; + const Register tmp3 = r10; + const Register tmp4 = r11; + + BLOCK_COMMENT("Entry:"); + __ enter(); // required for proper stackwalking of RuntimeStub frame + +#ifdef _WIN64 + __ push(rsi); + __ push(rdi); + // save the xmm registers which must be preserved 6-7 + __ subptr(rsp, 4 * wordSize); + __ movdqu(Address(rsp, 0), xmm6); + __ movdqu(Address(rsp, 2 * wordSize), xmm7); +#endif + __ fast_tan(x0, x1, x2, x3, x4, x5, x6, x7, rax, rcx, rdx, tmp1, tmp2, tmp3, tmp4); + +#ifdef _WIN64 + // restore xmm regs belonging to calling function + __ movdqu(xmm6, Address(rsp, 0)); + __ movdqu(xmm7, Address(rsp, 2 * wordSize)); + __ addptr(rsp, 4 * wordSize); + __ pop(rdi); + __ pop(rsi); #endif __ leave(); // required for proper stackwalking of RuntimeStub frame @@ -5065,16 +5131,28 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_crc32c_table_addr = (address)StubRoutines::x86::_crc32c_table; StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(supports_clmul); } - if (VM_Version::supports_sse2()) { + if (VM_Version::supports_sse2() && UseLibmIntrinsic) { + StubRoutines::x86::_ONEHALF_adr = (address)StubRoutines::x86::_ONEHALF; + StubRoutines::x86::_P_2_adr = (address)StubRoutines::x86::_P_2; + StubRoutines::x86::_SC_4_adr = (address)StubRoutines::x86::_SC_4; + StubRoutines::x86::_Ctable_adr = (address)StubRoutines::x86::_Ctable; + StubRoutines::x86::_SC_2_adr = (address)StubRoutines::x86::_SC_2; + StubRoutines::x86::_SC_3_adr = (address)StubRoutines::x86::_SC_3; + StubRoutines::x86::_SC_1_adr = (address)StubRoutines::x86::_SC_1; + StubRoutines::x86::_PI_INV_TABLE_adr = (address)StubRoutines::x86::_PI_INV_TABLE; + StubRoutines::x86::_PI_4_adr = (address)StubRoutines::x86::_PI_4; + StubRoutines::x86::_PI32INV_adr = (address)StubRoutines::x86::_PI32INV; + StubRoutines::x86::_SIGN_MASK_adr = (address)StubRoutines::x86::_SIGN_MASK; + StubRoutines::x86::_P_1_adr = (address)StubRoutines::x86::_P_1; + StubRoutines::x86::_P_3_adr = (address)StubRoutines::x86::_P_3; + StubRoutines::x86::_NEG_ZERO_adr = (address)StubRoutines::x86::_NEG_ZERO; StubRoutines::_dexp = generate_libmExp(); StubRoutines::_dlog = generate_libmLog(); + StubRoutines::_dlog10 = generate_libmLog10(); StubRoutines::_dpow = generate_libmPow(); - if (UseLibmSinIntrinsic) { - StubRoutines::_dsin = generate_libmSin(); - } - if (UseLibmCosIntrinsic) { - StubRoutines::_dcos = generate_libmCos(); - } + StubRoutines::_dtan = generate_libmTan(); + StubRoutines::_dsin = generate_libmSin(); + StubRoutines::_dcos = generate_libmCos(); } } @@ -5119,8 +5197,6 @@ class StubGenerator: public StubCodeGenerator { // arraycopy stubs used by compilers generate_arraycopy_stubs(); - generate_math_stubs(); - // don't bother generating these AES intrinsic stubs unless global flag is set if (UseAESIntrinsics) { StubRoutines::x86::_key_shuffle_mask_addr = generate_key_shuffle_mask(); // needed by the others diff --git a/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp b/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp index 141fbf048eb..7d723a39624 100644 --- a/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp +++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp @@ -48,6 +48,29 @@ address StubRoutines::x86::_shuffle_byte_flip_mask_addr = NULL; address StubRoutines::x86::_k256_adr = NULL; address StubRoutines::x86::_pshuffle_byte_flip_mask_addr = NULL; +//tables common for sin and cos +address StubRoutines::x86::_ONEHALF_adr = NULL; +address StubRoutines::x86::_P_2_adr = NULL; +address StubRoutines::x86::_SC_4_adr = NULL; +address StubRoutines::x86::_Ctable_adr = NULL; +address StubRoutines::x86::_SC_2_adr = NULL; +address StubRoutines::x86::_SC_3_adr = NULL; +address StubRoutines::x86::_SC_1_adr = NULL; +address StubRoutines::x86::_PI_INV_TABLE_adr = NULL; +address StubRoutines::x86::_PI_4_adr = NULL; +address StubRoutines::x86::_PI32INV_adr = NULL; +address StubRoutines::x86::_SIGN_MASK_adr = NULL; +address StubRoutines::x86::_P_1_adr = NULL; +address StubRoutines::x86::_P_3_adr = NULL; +address StubRoutines::x86::_NEG_ZERO_adr = NULL; + +//tables common for sincos and tancot +address StubRoutines::x86::_L_2il0floatpacket_0_adr = NULL; +address StubRoutines::x86::_Pi4Inv_adr = NULL; +address StubRoutines::x86::_Pi4x3_adr = NULL; +address StubRoutines::x86::_Pi4x4_adr = NULL; +address StubRoutines::x86::_ones_adr = NULL; + uint64_t StubRoutines::x86::_crc_by128_masks[] = { /* The fields in this structure are arranged so that they can be diff --git a/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp b/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp index 4c9ce0153fd..34020920eae 100644 --- a/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp +++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp @@ -57,6 +57,48 @@ // byte flip mask for sha256 static address _pshuffle_byte_flip_mask_addr; + //tables common for LIBM sin and cos + static juint _ONEHALF[]; + static address _ONEHALF_adr; + static juint _P_2[]; + static address _P_2_adr; + static juint _SC_4[]; + static address _SC_4_adr; + static juint _Ctable[]; + static address _Ctable_adr; + static juint _SC_2[]; + static address _SC_2_adr; + static juint _SC_3[]; + static address _SC_3_adr; + static juint _SC_1[]; + static address _SC_1_adr; + static juint _PI_INV_TABLE[]; + static address _PI_INV_TABLE_adr; + static juint _PI_4[]; + static address _PI_4_adr; + static juint _PI32INV[]; + static address _PI32INV_adr; + static juint _SIGN_MASK[]; + static address _SIGN_MASK_adr; + static juint _P_1[]; + static address _P_1_adr; + static juint _P_3[]; + static address _P_3_adr; + static juint _NEG_ZERO[]; + static address _NEG_ZERO_adr; + + //tables common for LIBM sincos and tancot + static juint _L_2il0floatpacket_0[]; + static address _L_2il0floatpacket_0_adr; + static juint _Pi4Inv[]; + static address _Pi4Inv_adr; + static juint _Pi4x3[]; + static address _Pi4x3_adr; + static juint _Pi4x4[]; + static address _Pi4x4_adr; + static juint _ones[]; + static address _ones_adr; + public: static address verify_mxcsr_entry() { return _verify_mxcsr_entry; } static address key_shuffle_mask_addr() { return _key_shuffle_mask_addr; } @@ -69,4 +111,24 @@ static address k256_addr() { return _k256_adr; } static address pshuffle_byte_flip_mask_addr() { return _pshuffle_byte_flip_mask_addr; } static void generate_CRC32C_table(bool is_pclmulqdq_supported); + static address _ONEHALF_addr() { return _ONEHALF_adr; } + static address _P_2_addr() { return _P_2_adr; } + static address _SC_4_addr() { return _SC_4_adr; } + static address _Ctable_addr() { return _Ctable_adr; } + static address _SC_2_addr() { return _SC_2_adr; } + static address _SC_3_addr() { return _SC_3_adr; } + static address _SC_1_addr() { return _SC_1_adr; } + static address _PI_INV_TABLE_addr() { return _PI_INV_TABLE_adr; } + static address _PI_4_addr() { return _PI_4_adr; } + static address _PI32INV_addr() { return _PI32INV_adr; } + static address _SIGN_MASK_addr() { return _SIGN_MASK_adr; } + static address _P_1_addr() { return _P_1_adr; } + static address _P_3_addr() { return _P_3_adr; } + static address _NEG_ZERO_addr() { return _NEG_ZERO_adr; } + static address _L_2il0floatpacket_0_addr() { return _L_2il0floatpacket_0_adr; } + static address _Pi4Inv_addr() { return _Pi4Inv_adr; } + static address _Pi4x3_addr() { return _Pi4x3_adr; } + static address _Pi4x4_addr() { return _Pi4x4_adr; } + static address _ones_addr() { return _ones_adr; } + #endif // CPU_X86_VM_STUBROUTINES_X86_32_HPP diff --git a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp index f5c286ec784..1339b1e065e 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_32.cpp @@ -345,13 +345,34 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M __ fld_d(Address(rsp, 1*wordSize)); switch (kind) { case Interpreter::java_lang_math_sin : - __ trigfunc('s'); + __ subptr(rsp, 2 * wordSize); + __ fstp_d(Address(rsp, 0)); + if (VM_Version::supports_sse2() && StubRoutines::dsin() != NULL) { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dsin()))); + } else { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dsin))); + } + __ addptr(rsp, 2 * wordSize); break; case Interpreter::java_lang_math_cos : - __ trigfunc('c'); + __ subptr(rsp, 2 * wordSize); + __ fstp_d(Address(rsp, 0)); + if (VM_Version::supports_sse2() && StubRoutines::dcos() != NULL) { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dcos()))); + } else { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dcos))); + } + __ addptr(rsp, 2 * wordSize); break; case Interpreter::java_lang_math_tan : - __ trigfunc('t'); + __ subptr(rsp, 2 * wordSize); + __ fstp_d(Address(rsp, 0)); + if (StubRoutines::dtan() != NULL) { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dtan()))); + } else { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtan))); + } + __ addptr(rsp, 2 * wordSize); break; case Interpreter::java_lang_math_sqrt: __ fsqrt(); @@ -362,26 +383,29 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M case Interpreter::java_lang_math_log: __ subptr(rsp, 2 * wordSize); __ fstp_d(Address(rsp, 0)); - if (VM_Version::supports_sse2()) { + if (StubRoutines::dlog() != NULL) { __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog()))); - } - else { + } else { __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog))); } __ addptr(rsp, 2 * wordSize); break; case Interpreter::java_lang_math_log10: - __ flog10(); - // Store to stack to convert 80bit precision back to 64bits - __ push_fTOS(); - __ pop_fTOS(); + __ subptr(rsp, 2 * wordSize); + __ fstp_d(Address(rsp, 0)); + if (StubRoutines::dlog10() != NULL) { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog10()))); + } else { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10))); + } + __ addptr(rsp, 2 * wordSize); break; case Interpreter::java_lang_math_pow: __ fld_d(Address(rsp, 3*wordSize)); // second argument __ subptr(rsp, 4 * wordSize); __ fstp_d(Address(rsp, 0)); __ fstp_d(Address(rsp, 2 * wordSize)); - if (VM_Version::supports_sse2()) { + if (StubRoutines::dpow() != NULL) { __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow()))); } else { __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dpow))); @@ -391,7 +415,7 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M case Interpreter::java_lang_math_exp: __ subptr(rsp, 2*wordSize); __ fstp_d(Address(rsp, 0)); - if (VM_Version::supports_sse2()) { + if (StubRoutines::dexp() != NULL) { __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp()))); } else { __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp))); diff --git a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp index 3345cfee795..6af708febf5 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp @@ -29,6 +29,7 @@ #include "interpreter/interpreterRuntime.hpp" #include "interpreter/templateInterpreterGenerator.hpp" #include "runtime/arguments.hpp" +#include "runtime/sharedRuntime.hpp" #define __ _masm-> @@ -373,32 +374,60 @@ address TemplateInterpreterGenerator::generate_math_entry(AbstractInterpreter::M __ sqrtsd(xmm0, Address(rsp, wordSize)); } else if (kind == Interpreter::java_lang_math_exp) { __ movdbl(xmm0, Address(rsp, wordSize)); - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp()))); + if (StubRoutines::dexp() != NULL) { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dexp()))); + } else { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dexp))); + } } else if (kind == Interpreter::java_lang_math_log) { __ movdbl(xmm0, Address(rsp, wordSize)); - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog()))); + if (StubRoutines::dlog() != NULL) { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog()))); + } else { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog))); + } + } else if (kind == Interpreter::java_lang_math_log10) { + __ movdbl(xmm0, Address(rsp, wordSize)); + if (StubRoutines::dlog10() != NULL) { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dlog10()))); + } else { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dlog10))); + } + } else if (kind == Interpreter::java_lang_math_sin) { + __ movdbl(xmm0, Address(rsp, wordSize)); + if (StubRoutines::dsin() != NULL) { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dsin()))); + } else { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dsin))); + } + } else if (kind == Interpreter::java_lang_math_cos) { + __ movdbl(xmm0, Address(rsp, wordSize)); + if (StubRoutines::dcos() != NULL) { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dcos()))); + } else { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dcos))); + } } else if (kind == Interpreter::java_lang_math_pow) { __ movdbl(xmm1, Address(rsp, wordSize)); __ movdbl(xmm0, Address(rsp, 3 * wordSize)); - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow()))); + if (StubRoutines::dpow() != NULL) { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dpow()))); + } else { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dpow))); + } + } else if (kind == Interpreter::java_lang_math_tan) { + __ movdbl(xmm0, Address(rsp, wordSize)); + if (StubRoutines::dtan() != NULL) { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, StubRoutines::dtan()))); + } else { + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, SharedRuntime::dtan))); + } } else { __ fld_d(Address(rsp, wordSize)); switch (kind) { - case Interpreter::java_lang_math_sin : - __ trigfunc('s'); - break; - case Interpreter::java_lang_math_cos : - __ trigfunc('c'); - break; - case Interpreter::java_lang_math_tan : - __ trigfunc('t'); - break; case Interpreter::java_lang_math_abs: __ fabs(); break; - case Interpreter::java_lang_math_log10: - __ flog10(); - break; default : ShouldNotReachHere(); } diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad index a7ee85d03ae..9cdea2eacb2 100644 --- a/hotspot/src/cpu/x86/vm/x86_32.ad +++ b/hotspot/src/cpu/x86/vm/x86_32.ad @@ -9828,27 +9828,6 @@ instruct modD_reg(regD dst, regD src0, regD src1, eAXRegI rax, eFlagsReg cr) %{ ins_pipe( pipe_slow ); %} -instruct tanDPR_reg(regDPR1 dst, regDPR1 src) %{ - predicate (UseSSE<=1); - match(Set dst(TanD src)); - format %{ "DTAN $dst" %} - ins_encode( Opcode(0xD9), Opcode(0xF2), // fptan - Opcode(0xDD), Opcode(0xD8)); // fstp st - ins_pipe( pipe_slow ); -%} - -instruct tanD_reg(regD dst, eFlagsReg cr) %{ - predicate (UseSSE>=2); - match(Set dst(TanD dst)); - effect(KILL cr); // Push_{Src|Result}D() uses "{SUB|ADD} ESP,8" - format %{ "DTAN $dst" %} - ins_encode( Push_SrcD(dst), - Opcode(0xD9), Opcode(0xF2), // fptan - Opcode(0xDD), Opcode(0xD8), // fstp st - Push_ResultD(dst) ); - ins_pipe( pipe_slow ); -%} - instruct atanDPR_reg(regDPR dst, regDPR src) %{ predicate (UseSSE<=1); match(Set dst(AtanD dst src)); @@ -9880,41 +9859,6 @@ instruct sqrtDPR_reg(regDPR dst, regDPR src) %{ ins_pipe( pipe_slow ); %} -instruct log10DPR_reg(regDPR1 dst, regDPR1 src) %{ - predicate (UseSSE<=1); - // The source Double operand on FPU stack - match(Set dst (Log10D src)); - // fldlg2 ; push log_10(2) on the FPU stack; full 80-bit number - // fxch ; swap ST(0) with ST(1) - // fyl2x ; compute log_10(2) * log_2(x) - format %{ "FLDLG2 \t\t\t#Log10\n\t" - "FXCH \n\t" - "FYL2X \t\t\t# Q=Log10*Log_2(x)" - %} - ins_encode( Opcode(0xD9), Opcode(0xEC), // fldlg2 - Opcode(0xD9), Opcode(0xC9), // fxch - Opcode(0xD9), Opcode(0xF1)); // fyl2x - - ins_pipe( pipe_slow ); -%} - -instruct log10D_reg(regD dst, regD src, eFlagsReg cr) %{ - predicate (UseSSE>=2); - effect(KILL cr); - match(Set dst (Log10D src)); - // fldlg2 ; push log_10(2) on the FPU stack; full 80-bit number - // fyl2x ; compute log_10(2) * log_2(x) - format %{ "FLDLG2 \t\t\t#Log10\n\t" - "FYL2X \t\t\t# Q=Log10*Log_2(x)" - %} - ins_encode( Opcode(0xD9), Opcode(0xEC), // fldlg2 - Push_SrcD(src), - Opcode(0xD9), Opcode(0xF1), // fyl2x - Push_ResultD(dst)); - - ins_pipe( pipe_slow ); -%} - //-------------Float Instructions------------------------------- // Float Math diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad index 9579436fb20..03bcd3d3b55 100644 --- a/hotspot/src/cpu/x86/vm/x86_64.ad +++ b/hotspot/src/cpu/x86/vm/x86_64.ad @@ -9897,34 +9897,6 @@ instruct cmpD_imm(rRegI dst, regD src, immD con, rFlagsReg cr) %{ ins_pipe(pipe_slow); %} -// -----------Trig and Trancendental Instructions------------------------------ -instruct tanD_reg(regD dst) %{ - match(Set dst (TanD dst)); - - format %{ "dtan $dst\n\t" %} - ins_encode( Push_SrcXD(dst), - Opcode(0xD9), Opcode(0xF2), //fptan - Opcode(0xDD), Opcode(0xD8), //fstp st - Push_ResultXD(dst) ); - ins_pipe( pipe_slow ); -%} - -instruct log10D_reg(regD dst) %{ - // The source and result Double operands in XMM registers - match(Set dst (Log10D dst)); - // fldlg2 ; push log_10(2) on the FPU stack; full 80-bit number - // fyl2x ; compute log_10(2) * log_2(x) - format %{ "fldlg2\t\t\t#Log10\n\t" - "fyl2x\t\t\t# Q=Log10*Log_2(x)\n\t" - %} - ins_encode(Opcode(0xD9), Opcode(0xEC), // fldlg2 - Push_SrcXD(dst), - Opcode(0xD9), Opcode(0xF1), // fyl2x - Push_ResultXD(dst)); - - ins_pipe( pipe_slow ); -%} - //----------Arithmetic Conversion Instructions--------------------------------- instruct roundFloat_nop(regF dst) diff --git a/hotspot/src/share/vm/c1/c1_LIR.cpp b/hotspot/src/share/vm/c1/c1_LIR.cpp index 9058585ff7b..c650ec0b9df 100644 --- a/hotspot/src/share/vm/c1/c1_LIR.cpp +++ b/hotspot/src/share/vm/c1/c1_LIR.cpp @@ -728,31 +728,6 @@ void LIR_OpVisitState::visit(LIR_Op* op) { break; } - - case lir_tan: - case lir_log10: { - assert(op->as_Op2() != NULL, "must be"); - LIR_Op2* op2 = (LIR_Op2*)op; - - // On x86 tan/sin/cos need two temporary fpu stack slots and - // log/log10 need one so handle opr2 and tmp as temp inputs. - // Register input operand as temp to guarantee that it doesn't - // overlap with the input. - assert(op2->_info == NULL, "not used"); - assert(op2->_tmp5->is_illegal(), "not used"); - assert(op2->_opr1->is_valid(), "used"); - do_input(op2->_opr1); do_temp(op2->_opr1); - - if (op2->_opr2->is_valid()) do_temp(op2->_opr2); - if (op2->_tmp1->is_valid()) do_temp(op2->_tmp1); - if (op2->_tmp2->is_valid()) do_temp(op2->_tmp2); - if (op2->_tmp3->is_valid()) do_temp(op2->_tmp3); - if (op2->_tmp4->is_valid()) do_temp(op2->_tmp4); - if (op2->_result->is_valid()) do_output(op2->_result); - - break; - } - // LIR_Op3 case lir_idiv: case lir_irem: { @@ -1740,8 +1715,6 @@ const char * LIR_Op::name() const { case lir_rem: s = "rem"; break; case lir_abs: s = "abs"; break; case lir_sqrt: s = "sqrt"; break; - case lir_tan: s = "tan"; break; - case lir_log10: s = "log10"; break; case lir_logic_and: s = "logic_and"; break; case lir_logic_or: s = "logic_or"; break; case lir_logic_xor: s = "logic_xor"; break; diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp index 56531ae9ea3..e01976a6687 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp @@ -320,9 +320,11 @@ const char* Runtime1::name_for_address(address entry) { FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32()); FUNCTION_CASE(entry, StubRoutines::dexp()); FUNCTION_CASE(entry, StubRoutines::dlog()); + FUNCTION_CASE(entry, StubRoutines::dlog10()); FUNCTION_CASE(entry, StubRoutines::dpow()); FUNCTION_CASE(entry, StubRoutines::dsin()); FUNCTION_CASE(entry, StubRoutines::dcos()); + FUNCTION_CASE(entry, StubRoutines::dtan()); #undef FUNCTION_CASE diff --git a/hotspot/src/share/vm/opto/classes.hpp b/hotspot/src/share/vm/opto/classes.hpp index 7bb2f74ad6c..b6a57085ad5 100644 --- a/hotspot/src/share/vm/opto/classes.hpp +++ b/hotspot/src/share/vm/opto/classes.hpp @@ -171,7 +171,6 @@ macro(LoadN) macro(LoadRange) macro(LoadS) macro(Lock) -macro(Log10D) macro(Loop) macro(LoopLimit) macro(Mach) @@ -265,7 +264,6 @@ macro(SubI) macro(SubL) macro(TailCall) macro(TailJump) -macro(TanD) macro(ThreadLocal) macro(Unlock) macro(URShiftI) diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 6041fd7b417..eb3718f8381 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -1679,7 +1679,6 @@ bool LibraryCallKit::inline_math(vmIntrinsics::ID id) { switch (id) { case vmIntrinsics::_dabs: n = new AbsDNode( arg); break; case vmIntrinsics::_dsqrt: n = new SqrtDNode(C, control(), arg); break; - case vmIntrinsics::_dlog10: n = new Log10DNode(C, control(), arg); break; default: fatal_unexpected_iid(id); break; } set_result(_gvn.transform(n)); @@ -1693,10 +1692,6 @@ bool LibraryCallKit::inline_trig(vmIntrinsics::ID id) { Node* arg = round_double_node(argument(0)); Node* n = NULL; - switch (id) { - case vmIntrinsics::_dtan: n = new TanDNode(C, control(), arg); break; - default: fatal_unexpected_iid(id); break; - } n = _gvn.transform(n); // Rounding required? Check for argument reduction! @@ -1814,15 +1809,18 @@ bool LibraryCallKit::inline_math_native(vmIntrinsics::ID id) { return StubRoutines::dcos() != NULL ? runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dcos(), "dcos") : runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dcos), "COS"); - case vmIntrinsics::_dtan: return Matcher::has_match_rule(Op_TanD) ? inline_trig(id) : - runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dtan), "TAN"); - + case vmIntrinsics::_dtan: + return StubRoutines::dtan() != NULL ? + runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dtan(), "dtan") : + runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dtan), "TAN"); case vmIntrinsics::_dlog: return StubRoutines::dlog() != NULL ? runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dlog(), "dlog") : runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog), "LOG"); - case vmIntrinsics::_dlog10: return Matcher::has_match_rule(Op_Log10D) ? inline_math(id) : - runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog10), "LOG10"); + case vmIntrinsics::_dlog10: + return StubRoutines::dlog10() != NULL ? + runtime_math(OptoRuntime::Math_D_D_Type(), StubRoutines::dlog10(), "dlog10") : + runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog10), "LOG10"); // These intrinsics are supported on all hardware case vmIntrinsics::_dsqrt: return Matcher::match_rule_supported(Op_SqrtD) ? inline_math(id) : false; diff --git a/hotspot/src/share/vm/opto/subnode.cpp b/hotspot/src/share/vm/opto/subnode.cpp index 0d06c083183..022f28cb8af 100644 --- a/hotspot/src/share/vm/opto/subnode.cpp +++ b/hotspot/src/share/vm/opto/subnode.cpp @@ -1533,25 +1533,3 @@ const Type* SqrtDNode::Value(PhaseGVN* phase) const { if( d < 0.0 ) return Type::DOUBLE; return TypeD::make( sqrt( d ) ); } - -//============================================================================= -//------------------------------Value------------------------------------------ -// Compute tan -const Type* TanDNode::Value(PhaseGVN* phase) const { - const Type *t1 = phase->type( in(1) ); - if( t1 == Type::TOP ) return Type::TOP; - if( t1->base() != Type::DoubleCon ) return Type::DOUBLE; - double d = t1->getd(); - return TypeD::make( StubRoutines::intrinsic_tan( d ) ); -} - -//============================================================================= -//------------------------------Value------------------------------------------ -// Compute log10 -const Type* Log10DNode::Value(PhaseGVN* phase) const { - const Type *t1 = phase->type( in(1) ); - if( t1 == Type::TOP ) return Type::TOP; - if( t1->base() != Type::DoubleCon ) return Type::DOUBLE; - double d = t1->getd(); - return TypeD::make( StubRoutines::intrinsic_log10( d ) ); -} diff --git a/hotspot/src/share/vm/opto/subnode.hpp b/hotspot/src/share/vm/opto/subnode.hpp index 1812853a8a9..63bcd3cc2b4 100644 --- a/hotspot/src/share/vm/opto/subnode.hpp +++ b/hotspot/src/share/vm/opto/subnode.hpp @@ -408,21 +408,6 @@ public: virtual uint ideal_reg() const { return Op_RegD; } }; -//------------------------------TanDNode--------------------------------------- -// tangens of a double -class TanDNode : public Node { -public: - TanDNode(Compile* C, Node *c,Node *in1) : Node(c, in1) { - init_flags(Flag_is_expensive); - C->add_expensive_node(this); - } - virtual int Opcode() const; - const Type *bottom_type() const { return Type::DOUBLE; } - virtual uint ideal_reg() const { return Op_RegD; } - virtual const Type* Value(PhaseGVN* phase) const; -}; - - //------------------------------AtanDNode-------------------------------------- // arcus tangens of a double class AtanDNode : public Node { @@ -448,20 +433,6 @@ public: virtual const Type* Value(PhaseGVN* phase) const; }; -//------------------------------Log10DNode--------------------------------------- -// Log_10 of a double -class Log10DNode : public Node { -public: - Log10DNode(Compile* C, Node *c, Node *in1) : Node(c, in1) { - init_flags(Flag_is_expensive); - C->add_expensive_node(this); - } - virtual int Opcode() const; - const Type *bottom_type() const { return Type::DOUBLE; } - virtual uint ideal_reg() const { return Op_RegD; } - virtual const Type* Value(PhaseGVN* phase) const; -}; - //-------------------------------ReverseBytesINode-------------------------------- // reverse bytes of an integer class ReverseBytesINode : public Node { diff --git a/hotspot/src/share/vm/runtime/stubRoutines.cpp b/hotspot/src/share/vm/runtime/stubRoutines.cpp index 71080e5b76c..043b61310e9 100644 --- a/hotspot/src/share/vm/runtime/stubRoutines.cpp +++ b/hotspot/src/share/vm/runtime/stubRoutines.cpp @@ -154,11 +154,14 @@ address StubRoutines::_vectorizedMismatch = NULL; address StubRoutines::_dexp = NULL; address StubRoutines::_dlog = NULL; +address StubRoutines::_dlog10 = NULL; address StubRoutines::_dpow = NULL; address StubRoutines::_dsin = NULL; address StubRoutines::_dcos = NULL; address StubRoutines::_dlibm_sin_cos_huge = NULL; address StubRoutines::_dlibm_reduce_pi04l = NULL; +address StubRoutines::_dlibm_tan_cot_huge = NULL; +address StubRoutines::_dtan = NULL; double (* StubRoutines::_intrinsic_log10 )(double) = NULL; double (* StubRoutines::_intrinsic_sin )(double) = NULL; diff --git a/hotspot/src/share/vm/runtime/stubRoutines.hpp b/hotspot/src/share/vm/runtime/stubRoutines.hpp index 38fe86e631b..6e63417141d 100644 --- a/hotspot/src/share/vm/runtime/stubRoutines.hpp +++ b/hotspot/src/share/vm/runtime/stubRoutines.hpp @@ -213,11 +213,14 @@ class StubRoutines: AllStatic { static address _dexp; static address _dlog; + static address _dlog10; static address _dpow; static address _dsin; static address _dcos; static address _dlibm_sin_cos_huge; static address _dlibm_reduce_pi04l; + static address _dlibm_tan_cot_huge; + static address _dtan; // These are versions of the java.lang.Math methods which perform // the same operations as the intrinsic version. They are used for @@ -391,11 +394,14 @@ class StubRoutines: AllStatic { static address dexp() { return _dexp; } static address dlog() { return _dlog; } + static address dlog10() { return _dlog10; } static address dpow() { return _dpow; } static address dsin() { return _dsin; } static address dcos() { return _dcos; } static address dlibm_reduce_pi04l() { return _dlibm_reduce_pi04l; } static address dlibm_sin_cos_huge() { return _dlibm_sin_cos_huge; } + static address dlibm_tan_cot_huge() { return _dlibm_tan_cot_huge; } + static address dtan() { return _dtan; } static address select_fill_function(BasicType t, bool aligned, const char* &name); diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 350e90fcde0..52c69eb39ee 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -859,9 +859,11 @@ typedef CompactHashtable SymbolCompactHashTable; static_field(StubRoutines, _mulAdd, address) \ static_field(StubRoutines, _dexp, address) \ static_field(StubRoutines, _dlog, address) \ + static_field(StubRoutines, _dlog10, address) \ static_field(StubRoutines, _dpow, address) \ static_field(StubRoutines, _dsin, address) \ static_field(StubRoutines, _dcos, address) \ + static_field(StubRoutines, _dtan, address) \ static_field(StubRoutines, _vectorizedMismatch, address) \ static_field(StubRoutines, _jbyte_arraycopy, address) \ static_field(StubRoutines, _jshort_arraycopy, address) \ @@ -2066,10 +2068,8 @@ typedef CompactHashtable SymbolCompactHashTable; declare_c2_type(NegNode, Node) \ declare_c2_type(NegFNode, NegNode) \ declare_c2_type(NegDNode, NegNode) \ - declare_c2_type(TanDNode, Node) \ declare_c2_type(AtanDNode, Node) \ declare_c2_type(SqrtDNode, Node) \ - declare_c2_type(Log10DNode, Node) \ declare_c2_type(ReverseBytesINode, Node) \ declare_c2_type(ReverseBytesLNode, Node) \ declare_c2_type(ReductionNode, Node) \ -- GitLab From b349843be48e3f4120a9850d53a4df7b85689051 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 6 Apr 2016 10:55:46 +0300 Subject: [PATCH 121/400] 8153265: [TESTBUG] compiler/whitebox/ForceNMethodSweepTest should not assume asserts are benign Reviewed-by: twisti, ikrylov --- hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java index 8661b32126f..5b6e7a59edf 100644 --- a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java +++ b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java @@ -34,7 +34,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; /* * @test - * @bug 8059624 8064669 + * @bug 8059624 8064669 8153265 * @library /testlibrary /test/lib / * @modules java.management * @build ForceNMethodSweepTest @@ -60,6 +60,12 @@ public class ForceNMethodSweepTest extends CompilerWhiteBoxTest { @Override protected void test() throws Exception { + // prime the asserts: get their bytecodes loaded, any lazy computation + // resolved, and executed once + Asserts.assertGT(1, 0, "message"); + Asserts.assertLTE(0, 0, "message"); + Asserts.assertLT(-1, 0, "message"); + checkNotCompiled(); guaranteedSweep(); int usage = getTotalUsage(); -- GitLab From c70e07ccbe305561b05afb469d288cc9f9dadfa6 Mon Sep 17 00:00:00 2001 From: Nils Eliasson Date: Wed, 6 Apr 2016 14:48:45 +0200 Subject: [PATCH 122/400] 8151880: EnqueueMethodForCompilationTest.java still fails to compile method Extract SimpleTestCaseHelper inner class Reviewed-by: kvn --- .../whitebox/ClearMethodStateTest.java | 10 +-- .../whitebox/CompilerWhiteBoxTest.java | 8 ++- .../compiler/whitebox/DeoptimizeAllTest.java | 4 +- .../whitebox/DeoptimizeFramesTest.java | 6 +- .../whitebox/DeoptimizeMethodTest.java | 6 +- .../EnqueueMethodForCompilationTest.java | 13 ++-- .../whitebox/ForceNMethodSweepTest.java | 8 +-- .../compiler/whitebox/GetNMethodTest.java | 6 +- .../whitebox/IsMethodCompilableTest.java | 11 ++-- .../whitebox/LockCompilationTest.java | 4 +- .../whitebox/MakeMethodNotCompilableTest.java | 12 ++-- .../compiler/whitebox/SimpleTestCase.java | 64 +++++++++---------- 12 files changed, 81 insertions(+), 71 deletions(-) diff --git a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java index dfc630155fe..8df5e9de4a0 100644 --- a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java +++ b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java @@ -31,9 +31,9 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @library /testlibrary /test/lib / * @modules java.management * @build ClearMethodStateTest - * @run main ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ClearMethodStateTest + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+PrintCompilation -XX:-UseCounterDecay ClearMethodStateTest * @summary testing of WB::clearMethodState() * @author igor.ignatyev@oracle.com */ @@ -41,8 +41,8 @@ public class ClearMethodStateTest extends CompilerWhiteBoxTest { public static void main(String[] args) throws Exception { String directive = - "[{ match:\"*SimpleTestCase$Helper.*\", BackgroundCompilation: false }, " + - " { match:\"*.*\", inline:\"-*SimpleTestCase$Helper.*\"}]"; + "[{ match:\"*SimpleTestCaseHelper.*\", BackgroundCompilation: false }, " + + " { match:\"*.*\", inline:\"-*SimpleTestCaseHelper.*\"}]"; if (WHITE_BOX.addCompilerDirective(directive) != 2) { throw new RuntimeException("Could not add directive"); } diff --git a/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java b/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java index 5bec2eabd84..e83cd1e96c7 100644 --- a/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java +++ b/hotspot/test/compiler/whitebox/CompilerWhiteBoxTest.java @@ -24,6 +24,7 @@ package compiler.whitebox; import sun.hotspot.WhiteBox; import sun.hotspot.code.NMethod; + import java.lang.reflect.Executable; import java.util.Objects; import java.util.concurrent.Callable; @@ -58,6 +59,8 @@ public abstract class CompilerWhiteBoxTest { /** Value of {@code -XX:BackgroundCompilation} */ protected static final boolean BACKGROUND_COMPILATION = Boolean.valueOf(getVMOption("BackgroundCompilation", "true")); + protected static final boolean USE_COUNTER_DECAY + = Boolean.valueOf(getVMOption("UseCounterDecay", "true")); /** Value of {@code -XX:TieredCompilation} */ protected static final boolean TIERED_COMPILATION = Boolean.valueOf(getVMOption("TieredCompilation", "false")); @@ -370,7 +373,10 @@ public abstract class CompilerWhiteBoxTest { * @return accumulated result * @see #compile(int) */ - protected final int compile() { + protected final int compile() throws Exception { + if (USE_COUNTER_DECAY) { + throw new Exception("Tests using compile method must turn off counter decay for reliability"); + } if (testCase.isOsr()) { return compile(1); } else { diff --git a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java index b5ecf979e54..7d56a52319e 100644 --- a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java +++ b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java @@ -29,9 +29,9 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @library /testlibrary /test/lib / * @modules java.management * @build DeoptimizeAllTest - * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* DeoptimizeAllTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* DeoptimizeAllTest * @summary testing of WB::deoptimizeAll() * @author igor.ignatyev@oracle.com */ diff --git a/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java b/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java index 75ac8cdc1ea..8dd85ad114e 100644 --- a/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java +++ b/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java @@ -29,15 +29,15 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @library /testlibrary /test/lib / * @modules java.management * @build DeoptimizeFramesTest - * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -Xmixed + * -XX:+WhiteBoxAPI -Xmixed -XX:-UseCounterDecay * -XX:CompileCommand=compileonly,DeoptimizeFramesTest$TestCaseImpl::method * -XX:+IgnoreUnrecognizedVMOptions -XX:-DeoptimizeRandom -XX:-DeoptimizeALot * DeoptimizeFramesTest true * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -Xmixed + * -XX:+WhiteBoxAPI -Xmixed -XX:-UseCounterDecay * -XX:CompileCommand=compileonly,DeoptimizeFramesTest$TestCaseImpl::method * -XX:+IgnoreUnrecognizedVMOptions -XX:-DeoptimizeRandom -XX:-DeoptimizeALot * DeoptimizeFramesTest false diff --git a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java index 473f56ce178..fa543d99730 100644 --- a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java +++ b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java @@ -29,9 +29,9 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @library /testlibrary /test/lib / * @modules java.management * @build DeoptimizeMethodTest - * @run main ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* DeoptimizeMethodTest + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* DeoptimizeMethodTest * @summary testing of WB::deoptimizeMethod() * @author igor.ignatyev@oracle.com */ diff --git a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java index cde67e20f60..b1e40036e4d 100644 --- a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java +++ b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java @@ -29,9 +29,9 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @library /testlibrary /test/lib / * @modules java.management * @build EnqueueMethodForCompilationTest - * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI EnqueueMethodForCompilationTest + * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+PrintCompilation -XX:-UseCounterDecay EnqueueMethodForCompilationTest * @summary testing of WB::enqueueMethodForCompilation() * @author igor.ignatyev@oracle.com */ @@ -39,8 +39,8 @@ public class EnqueueMethodForCompilationTest extends CompilerWhiteBoxTest { public static void main(String[] args) throws Exception { String directive = - "[{ match:\"*SimpleTestCase$Helper.*\", BackgroundCompilation: false }, " + - " { match:\"*.*\", inline:\"-*SimpleTestCase$Helper.*\"}]"; + "[{ match:\"*SimpleTestCaseHelper.*\", BackgroundCompilation: false }, " + + " { match:\"*.*\", inline:\"-*SimpleTestCaseHelper.*\"}]"; if (WHITE_BOX.addCompilerDirective(directive) != 2) { throw new RuntimeException("Could not add directive"); } @@ -86,7 +86,10 @@ public class EnqueueMethodForCompilationTest extends CompilerWhiteBoxTest { checkNotCompiled(); WHITE_BOX.clearMethodState(method); - WHITE_BOX.enqueueMethodForCompilation(method, compLevel, bci); + if (!WHITE_BOX.enqueueMethodForCompilation(method, compLevel, bci)) { + throw new RuntimeException(method + + " could not be enqueued for compilation"); + } checkCompiled(); deoptimize(); checkNotCompiled(); diff --git a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java index 5b6e7a59edf..593c60ac68e 100644 --- a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java +++ b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java @@ -38,12 +38,12 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @library /testlibrary /test/lib / * @modules java.management * @build ForceNMethodSweepTest - * @run main ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:-TieredCompilation -XX:+WhiteBoxAPI - * -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* - * -XX:-BackgroundCompilation ForceNMethodSweepTest + * -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* + * -XX:-BackgroundCompilation -XX:-UseCounterDecay ForceNMethodSweepTest * @summary testing of WB::forceNMethodSweep */ public class ForceNMethodSweepTest extends CompilerWhiteBoxTest { diff --git a/hotspot/test/compiler/whitebox/GetNMethodTest.java b/hotspot/test/compiler/whitebox/GetNMethodTest.java index 285a300c43b..80a70f86349 100644 --- a/hotspot/test/compiler/whitebox/GetNMethodTest.java +++ b/hotspot/test/compiler/whitebox/GetNMethodTest.java @@ -33,9 +33,9 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @library /testlibrary /test/lib / * @modules java.management * @build GetNMethodTest - * @run main ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* GetNMethodTest + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* GetNMethodTest * @summary testing of WB::getNMethod() * @author igor.ignatyev@oracle.com */ diff --git a/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java b/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java index 2178acf4028..ed169f24536 100644 --- a/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java +++ b/hotspot/test/compiler/whitebox/IsMethodCompilableTest.java @@ -27,12 +27,13 @@ * @library /testlibrary /test/lib / * @modules java.base/sun.misc * java.management - * @build jdk.test.lib.* sun.hotspot.WhiteBox + * @build jdk.test.lib.* + * sun.hotspot.WhiteBox * @build IsMethodCompilableTest - * @run main ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main ClassFileInstaller jdk.test.lib.Platform - * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -Xmixed -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:PerMethodRecompilationCutoff=3 -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* IsMethodCompilableTest + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * jdk.test.lib.Platform + * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -Xmixed -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:PerMethodRecompilationCutoff=3 -XX:-UseCounterDecay -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* IsMethodCompilableTest * @summary testing of WB::isMethodCompilable() * @author igor.ignatyev@oracle.com */ diff --git a/hotspot/test/compiler/whitebox/LockCompilationTest.java b/hotspot/test/compiler/whitebox/LockCompilationTest.java index 4ba039699e4..7a3d9fcbaff 100644 --- a/hotspot/test/compiler/whitebox/LockCompilationTest.java +++ b/hotspot/test/compiler/whitebox/LockCompilationTest.java @@ -29,7 +29,7 @@ * @build LockCompilationTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI LockCompilationTest + * @run main/othervm -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay LockCompilationTest * @summary testing of WB::lock/unlockCompilation() */ @@ -50,7 +50,7 @@ public class LockCompilationTest extends CompilerWhiteBoxTest { // Only compile SimpleTestCase$Helper.method and exclude all other to ensure no // contention on the compile queue causes problems. String directive = - "[{ match:\"*SimpleTestCase$Helper.method\", Exclude:false}, " + + "[{ match:\"*SimpleTestCaseHelper.method\", Exclude:false}, " + " { match:\"*.*\", Exclude:true}]"; if (WHITE_BOX.addCompilerDirective(directive) != 2) { throw new RuntimeException("Could not add directive"); diff --git a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java index 1e86bfb5594..7ebc004bb42 100644 --- a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java +++ b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java @@ -29,9 +29,9 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @library /testlibrary /test/lib / * @modules java.management * @build MakeMethodNotCompilableTest - * @run main ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmixed MakeMethodNotCompilableTest + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xmixed -XX:-UseCounterDecay MakeMethodNotCompilableTest * @summary testing of WB::makeMethodNotCompilable() * @author igor.ignatyev@oracle.com */ @@ -39,8 +39,8 @@ public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest { private int bci; public static void main(String[] args) throws Exception { String directive = - "[{ match:\"*SimpleTestCase$Helper.*\", BackgroundCompilation: false }, " + - " { match:\"*.*\", inline:\"-*SimpleTestCase$Helper.*\"}]"; + "[{ match:\"*SimpleTestCaseHelper.*\", BackgroundCompilation: false }, " + + " { match:\"*.*\", inline:\"-*SimpleTestCaseHelper.*\"}]"; if (WHITE_BOX.addCompilerDirective(directive) != 2) { throw new RuntimeException("Could not add directive"); } @@ -227,7 +227,7 @@ public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest { return false; } - private int getBci() { + private int getBci() throws Exception { compile(); checkCompiled(); int result = WHITE_BOX.getMethodEntryBci(method); diff --git a/hotspot/test/compiler/whitebox/SimpleTestCase.java b/hotspot/test/compiler/whitebox/SimpleTestCase.java index 76954acf20d..2de860e4fe9 100644 --- a/hotspot/test/compiler/whitebox/SimpleTestCase.java +++ b/hotspot/test/compiler/whitebox/SimpleTestCase.java @@ -31,18 +31,17 @@ import sun.hotspot.WhiteBox; public enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { /** constructor test case */ - CONSTRUCTOR_TEST(Helper.CONSTRUCTOR, Helper.CONSTRUCTOR_CALLABLE, false), + CONSTRUCTOR_TEST(SimpleTestCaseHelper.CONSTRUCTOR, SimpleTestCaseHelper.CONSTRUCTOR_CALLABLE, false), /** method test case */ - METHOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE, false), + METHOD_TEST(SimpleTestCaseHelper.METHOD, SimpleTestCaseHelper.METHOD_CALLABLE, false), /** static method test case */ - STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE, false), + STATIC_TEST(SimpleTestCaseHelper.STATIC, SimpleTestCaseHelper.STATIC_CALLABLE, false), /** OSR constructor test case */ - OSR_CONSTRUCTOR_TEST(Helper.OSR_CONSTRUCTOR, - Helper.OSR_CONSTRUCTOR_CALLABLE, true), + OSR_CONSTRUCTOR_TEST(SimpleTestCaseHelper.OSR_CONSTRUCTOR, SimpleTestCaseHelper.OSR_CONSTRUCTOR_CALLABLE, true), /** OSR method test case */ - OSR_METHOD_TEST(Helper.OSR_METHOD, Helper.OSR_METHOD_CALLABLE, true), + OSR_METHOD_TEST(SimpleTestCaseHelper.OSR_METHOD, SimpleTestCaseHelper.OSR_METHOD_CALLABLE, true), /** OSR static method test case */ - OSR_STATIC_TEST(Helper.OSR_STATIC, Helper.OSR_STATIC_CALLABLE, true); + OSR_STATIC_TEST(SimpleTestCaseHelper.OSR_STATIC, SimpleTestCaseHelper.OSR_STATIC_CALLABLE, true); private final Executable executable; private final Callable callable; @@ -69,20 +68,21 @@ public enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { public boolean isOsr() { return isOsr; } +} - private static class Helper { + class SimpleTestCaseHelper { - private static final Callable CONSTRUCTOR_CALLABLE + public static final Callable CONSTRUCTOR_CALLABLE = new Callable() { @Override public Integer call() throws Exception { - return new Helper(1337).hashCode(); + return new SimpleTestCaseHelper(1337).hashCode(); } }; - private static final Callable METHOD_CALLABLE + public static final Callable METHOD_CALLABLE = new Callable() { - private final Helper helper = new Helper(); + private final SimpleTestCaseHelper helper = new SimpleTestCaseHelper(); @Override public Integer call() throws Exception { @@ -90,7 +90,7 @@ public enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { } }; - private static final Callable STATIC_CALLABLE + public static final Callable STATIC_CALLABLE = new Callable() { @Override public Integer call() throws Exception { @@ -98,17 +98,17 @@ public enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { } }; - private static final Callable OSR_CONSTRUCTOR_CALLABLE + public static final Callable OSR_CONSTRUCTOR_CALLABLE = new Callable() { @Override public Integer call() throws Exception { - return new Helper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode(); + return new SimpleTestCaseHelper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode(); } }; - private static final Callable OSR_METHOD_CALLABLE + public static final Callable OSR_METHOD_CALLABLE = new Callable() { - private final Helper helper = new Helper(); + private final SimpleTestCaseHelper helper = new SimpleTestCaseHelper(); @Override public Integer call() throws Exception { @@ -116,7 +116,7 @@ public enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { } }; - private static final Callable OSR_STATIC_CALLABLE + public static final Callable OSR_STATIC_CALLABLE = new Callable() { @Override public Integer call() throws Exception { @@ -124,22 +124,22 @@ public enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { } }; - private static final Constructor CONSTRUCTOR; - private static final Constructor OSR_CONSTRUCTOR; - private static final Method METHOD; - private static final Method STATIC; - private static final Method OSR_METHOD; - private static final Method OSR_STATIC; + public static final Constructor CONSTRUCTOR; + public static final Constructor OSR_CONSTRUCTOR; + public static final Method METHOD; + public static final Method STATIC; + public static final Method OSR_METHOD; + public static final Method OSR_STATIC; static { try { - CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class); + CONSTRUCTOR = SimpleTestCaseHelper.class.getDeclaredConstructor(int.class); } catch (NoSuchMethodException | SecurityException e) { throw new RuntimeException( "exception on getting method Helper.(int)", e); } try { - OSR_CONSTRUCTOR = Helper.class.getDeclaredConstructor( + OSR_CONSTRUCTOR = SimpleTestCaseHelper.class.getDeclaredConstructor( Object.class, long.class); } catch (NoSuchMethodException | SecurityException e) { throw new RuntimeException( @@ -153,7 +153,7 @@ public enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { private static Method getMethod(String name, Class... parameterTypes) { try { - return Helper.class.getDeclaredMethod(name, parameterTypes); + return SimpleTestCaseHelper.class.getDeclaredMethod(name, parameterTypes); } catch (NoSuchMethodException | SecurityException e) { throw new RuntimeException( "exception on getting method Helper." + name, e); @@ -195,7 +195,7 @@ public enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { */ private static int warmup(Method m) throws Exception { waitAndDeoptimize(m); - Helper helper = new Helper(); + SimpleTestCaseHelper helper = new SimpleTestCaseHelper(); int result = 0; for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; ++i) { result += (int)m.invoke(helper, 1); @@ -254,12 +254,12 @@ public enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { private final int x; // for method and OSR method test case - public Helper() { + public SimpleTestCaseHelper() { x = 0; } // for OSR constructor test case - private Helper(Object o, long limit) throws Exception { + private SimpleTestCaseHelper(Object o, long limit) throws Exception { int result = 0; if (limit != 1) { result = warmup(OSR_CONSTRUCTOR); @@ -272,7 +272,7 @@ public enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { } // for constructor test case - private Helper(int x) { + private SimpleTestCaseHelper(int x) { this.x = x; } @@ -281,4 +281,4 @@ public enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { return x; } } -} + -- GitLab From 28e72b267564ebc261980d01bc3a82728cf4bc11 Mon Sep 17 00:00:00 2001 From: Rahul Raghavan Date: Thu, 7 Apr 2016 01:56:16 -0700 Subject: [PATCH 123/400] 8149488: Incorrect declaration of bitsInByte in regmask.cpp Corrected BITS_IN_BYTE_ARRAY_SIZE value as 256 for all bitsInByte usage. Reviewed-by: dlong, mcberg, thartmann, vlivanov --- hotspot/src/share/vm/libadt/vectset.cpp | 2 +- hotspot/src/share/vm/libadt/vectset.hpp | 2 ++ hotspot/src/share/vm/opto/regmask.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/libadt/vectset.cpp b/hotspot/src/share/vm/libadt/vectset.cpp index 256b0a9a1a9..2db14514f3e 100644 --- a/hotspot/src/share/vm/libadt/vectset.cpp +++ b/hotspot/src/share/vm/libadt/vectset.cpp @@ -31,7 +31,7 @@ // BitsInByte is a lookup table which tells the number of bits that // are in the looked-up number. It is very useful in VectorSet_Size. -uint8_t bitsInByte[256] = { +uint8_t bitsInByte[BITS_IN_BYTE_ARRAY_SIZE] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5, diff --git a/hotspot/src/share/vm/libadt/vectset.hpp b/hotspot/src/share/vm/libadt/vectset.hpp index d94ce44d35f..887329de1ee 100644 --- a/hotspot/src/share/vm/libadt/vectset.hpp +++ b/hotspot/src/share/vm/libadt/vectset.hpp @@ -27,6 +27,8 @@ #include "libadt/set.hpp" +#define BITS_IN_BYTE_ARRAY_SIZE 256 + // Vector Sets - An Abstract Data Type //INTERFACE diff --git a/hotspot/src/share/vm/opto/regmask.cpp b/hotspot/src/share/vm/opto/regmask.cpp index 80b418bda08..2e04c42eb7e 100644 --- a/hotspot/src/share/vm/opto/regmask.cpp +++ b/hotspot/src/share/vm/opto/regmask.cpp @@ -389,7 +389,7 @@ bool RegMask::is_UP() const { //------------------------------Size------------------------------------------- // Compute size of register mask in bits uint RegMask::Size() const { - extern uint8_t bitsInByte[512]; + extern uint8_t bitsInByte[BITS_IN_BYTE_ARRAY_SIZE]; uint sum = 0; for( int i = 0; i < RM_SIZE; i++ ) sum += -- GitLab From a6c687cd6a81daf053a04583efa54fd804d28038 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Thu, 7 Apr 2016 16:51:37 +0200 Subject: [PATCH 124/400] 8153514: Whitebox API should allow compilation of Added Whitebox API method to trigger compilation of static initializer. Reviewed-by: zmajo, kvn, iignatyev --- hotspot/src/share/vm/prims/whitebox.cpp | 23 +++++++++++++++++------ hotspot/src/share/vm/prims/whitebox.hpp | 1 + 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index c6aafd33ed4..ff20fc3bae3 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -637,17 +637,26 @@ WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject m return result; WB_END -WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci)) - // Screen for unavailable/bad comp level - if (CompileBroker::compiler(comp_level) == NULL) { +bool WhiteBox::compile_method(Method* method, int comp_level, int bci, Thread* THREAD) { + // Screen for unavailable/bad comp level or null method + if (method == NULL || CompileBroker::compiler(comp_level) == NULL) { return false; } - jmethodID jmid = reflected_method_to_jmid(thread, env, method); - CHECK_JNI_EXCEPTION_(env, JNI_FALSE); - methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); + methodHandle mh(THREAD, method); nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD); MutexLockerEx mu(Compile_lock); return (mh->queued_for_compilation() || nm != NULL); +} + +WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci)) + jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION_(env, JNI_FALSE); + return WhiteBox::compile_method(Method::checked_resolve_jmethod_id(jmid), comp_level, bci, THREAD); +WB_END + +WB_ENTRY(jboolean, WB_EnqueueInitializerForCompilation(JNIEnv* env, jobject o, jclass klass, jint comp_level)) + instanceKlassHandle ikh(java_lang_Class::as_Klass(JNIHandles::resolve(klass))); + return WhiteBox::compile_method(ikh->class_initializer(), comp_level, InvocationEntryBci, THREAD); WB_END WB_ENTRY(jboolean, WB_ShouldPrintAssembly(JNIEnv* env, jobject o, jobject method, jint comp_level)) @@ -1643,6 +1652,8 @@ static JNINativeMethod methods[] = { CC"(Ljava/lang/reflect/Executable;Z)Z", (void*)&WB_TestSetForceInlineMethod}, {CC"enqueueMethodForCompilation0", CC"(Ljava/lang/reflect/Executable;II)Z", (void*)&WB_EnqueueMethodForCompilation}, + {CC"enqueueInitializerForCompilation0", + CC"(Ljava/lang/Class;I)Z", (void*)&WB_EnqueueInitializerForCompilation}, {CC"clearMethodState0", CC"(Ljava/lang/reflect/Executable;)V", (void*)&WB_ClearMethodState}, {CC"lockCompilation", CC"()V", (void*)&WB_LockCompilation}, diff --git a/hotspot/src/share/vm/prims/whitebox.hpp b/hotspot/src/share/vm/prims/whitebox.hpp index 3ebada8fe5e..6398b4ca0d9 100644 --- a/hotspot/src/share/vm/prims/whitebox.hpp +++ b/hotspot/src/share/vm/prims/whitebox.hpp @@ -77,6 +77,7 @@ class WhiteBox : public AllStatic { static void register_methods(JNIEnv* env, jclass wbclass, JavaThread* thread, JNINativeMethod* method_array, int method_count); static void register_extended(JNIEnv* env, jclass wbclass, JavaThread* thread); + static bool compile_method(Method* method, int comp_level, int bci, Thread* THREAD); }; -- GitLab From 1131e05b662a7aa2b20463d1e79f7fd4be94e199 Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Thu, 7 Apr 2016 08:57:26 -1000 Subject: [PATCH 125/400] 8153439: do not install an empty SpeculationLog in an nmethod Reviewed-by: iveresov, twisti --- hotspot/.mx.jvmci/suite.py | 15 +++++++++++ .../ci/hotspot/HotSpotCodeCacheProvider.java | 4 ++- .../vm/ci/hotspot/HotSpotSpeculationLog.java | 7 ++++- .../src/jdk/vm/ci/meta/SpeculationLog.java | 7 +++++ .../ci/code/test}/CodeInstallationTest.java | 11 ++++---- .../jdk/vm/ci/code/test}/DataPatchTest.java | 6 ++--- .../jdk/vm/ci/code/test}/DebugInfoTest.java | 4 +-- .../code/test}/InterpreterFrameSizeTest.java | 16 +++++------ .../test}/SimpleCodeInstallationTest.java | 11 ++++---- .../vm/ci/code/test}/SimpleDebugInfoTest.java | 16 +++++------ .../jdk/vm/ci/code/test}/TestAssembler.java | 2 +- .../test}/VirtualObjectDebugInfoTest.java | 27 ++++++++++--------- .../code/test}/amd64/AMD64TestAssembler.java | 19 +++++++------ .../code/test}/sparc/SPARCTestAssembler.java | 23 +++++++++------- 14 files changed, 101 insertions(+), 67 deletions(-) rename hotspot/test/compiler/jvmci/{code => jdk.vm.ci.code.test/src/jdk/vm/ci/code/test}/CodeInstallationTest.java (96%) rename hotspot/test/compiler/jvmci/{code => jdk.vm.ci.code.test/src/jdk/vm/ci/code/test}/DataPatchTest.java (97%) rename hotspot/test/compiler/jvmci/{code => jdk.vm.ci.code.test/src/jdk/vm/ci/code/test}/DebugInfoTest.java (95%) rename hotspot/test/compiler/jvmci/{code => jdk.vm.ci.code.test/src/jdk/vm/ci/code/test}/InterpreterFrameSizeTest.java (92%) rename hotspot/test/compiler/jvmci/{code => jdk.vm.ci.code.test/src/jdk/vm/ci/code/test}/SimpleCodeInstallationTest.java (87%) rename hotspot/test/compiler/jvmci/{code => jdk.vm.ci.code.test/src/jdk/vm/ci/code/test}/SimpleDebugInfoTest.java (96%) rename hotspot/test/compiler/jvmci/{code => jdk.vm.ci.code.test/src/jdk/vm/ci/code/test}/TestAssembler.java (99%) rename hotspot/test/compiler/jvmci/{code => jdk.vm.ci.code.test/src/jdk/vm/ci/code/test}/VirtualObjectDebugInfoTest.java (89%) rename hotspot/test/compiler/jvmci/{code => jdk.vm.ci.code.test/src/jdk/vm/ci/code/test}/amd64/AMD64TestAssembler.java (96%) rename hotspot/test/compiler/jvmci/{code => jdk.vm.ci.code.test/src/jdk/vm/ci/code/test}/sparc/SPARCTestAssembler.java (96%) diff --git a/hotspot/.mx.jvmci/suite.py b/hotspot/.mx.jvmci/suite.py index fe37b6646a5..3da6124dbca 100644 --- a/hotspot/.mx.jvmci/suite.py +++ b/hotspot/.mx.jvmci/suite.py @@ -83,6 +83,21 @@ suite = { "workingSets" : "API,JVMCI", }, + "jdk.vm.ci.code.test" : { + "subDir" : "test/compiler/jvmci", + "sourceDirs" : ["src"], + "dependencies" : [ + "mx:JUNIT", + "jdk.vm.ci.amd64", + "jdk.vm.ci.sparc", + "jdk.vm.ci.code", + "jdk.vm.ci.hotspot", + ], + "checkstyle" : "jdk.vm.ci.services", + "javaCompliance" : "1.8", + "workingSets" : "API,JVMCI", + }, + "jdk.vm.ci.runtime" : { "subDir" : "src/jdk.vm.ci/share/classes", "sourceDirs" : ["src"], diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java index a01a304d2a8..dac0fb3a553 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotCodeCacheProvider.java @@ -120,7 +120,9 @@ public class HotSpotCodeCacheProvider implements CodeCacheProvider { resultInstalledCode = installedCode; } - int result = runtime.getCompilerToVM().installCode(target, (HotSpotCompiledCode) compiledCode, resultInstalledCode, (HotSpotSpeculationLog) log); + HotSpotSpeculationLog speculationLog = (log != null && log.hasSpeculations()) ? (HotSpotSpeculationLog) log : null; + + int result = runtime.getCompilerToVM().installCode(target, (HotSpotCompiledCode) compiledCode, resultInstalledCode, speculationLog); if (result != config.codeInstallResultOk) { String resultDesc = config.getCodeInstallResultDescription(result); if (compiledCode instanceof HotSpotCompiledNmethod) { diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java index e619fb45ee7..0cd643fa3ca 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSpeculationLog.java @@ -38,7 +38,7 @@ public class HotSpotSpeculationLog implements SpeculationLog { /** All speculations that have been a deoptimization reason. */ private Set failedSpeculations; - /** Strong references to all reasons embededded in the current nmethod. */ + /** Strong references to all reasons embedded in the current nmethod. */ private volatile Collection speculations; @Override @@ -81,4 +81,9 @@ public class HotSpotSpeculationLog implements SpeculationLog { return HotSpotObjectConstantImpl.forObject(reason); } + + @Override + public synchronized boolean hasSpeculations() { + return speculations != null && !speculations.isEmpty(); + } } diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/SpeculationLog.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/SpeculationLog.java index 4330e65715e..b81f5f25a53 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/SpeculationLog.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/SpeculationLog.java @@ -56,4 +56,11 @@ public interface SpeculationLog { * argument to the deoptimization function. */ JavaConstant speculate(SpeculationReason reason); + + /** + * Returns if this log has speculations. + * + * @return true if there are speculations, false otherwise + */ + boolean hasSpeculations(); } diff --git a/hotspot/test/compiler/jvmci/code/CodeInstallationTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java similarity index 96% rename from hotspot/test/compiler/jvmci/code/CodeInstallationTest.java rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java index 550665cf342..67a66660ca1 100644 --- a/hotspot/test/compiler/jvmci/code/CodeInstallationTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/CodeInstallationTest.java @@ -20,15 +20,19 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package compiler.jvmci.code; +package jdk.vm.ci.code.test; import java.lang.reflect.Method; +import org.junit.Assert; + import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.code.Architecture; import jdk.vm.ci.code.CodeCacheProvider; import jdk.vm.ci.code.InstalledCode; import jdk.vm.ci.code.TargetDescription; +import jdk.vm.ci.code.test.amd64.AMD64TestAssembler; +import jdk.vm.ci.code.test.sparc.SPARCTestAssembler; import jdk.vm.ci.hotspot.HotSpotCompiledCode; import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; import jdk.vm.ci.meta.ConstantReflectionProvider; @@ -37,11 +41,6 @@ import jdk.vm.ci.runtime.JVMCI; import jdk.vm.ci.runtime.JVMCIBackend; import jdk.vm.ci.sparc.SPARC; -import org.junit.Assert; - -import compiler.jvmci.code.amd64.AMD64TestAssembler; -import compiler.jvmci.code.sparc.SPARCTestAssembler; - /** * Base class for code installation tests. */ diff --git a/hotspot/test/compiler/jvmci/code/DataPatchTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java similarity index 97% rename from hotspot/test/compiler/jvmci/code/DataPatchTest.java rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java index 294d21e571d..3b7c421b2c5 100644 --- a/hotspot/test/compiler/jvmci/code/DataPatchTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java @@ -32,10 +32,11 @@ * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.code.DataPatchTest + * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java + * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.DataPatchTest */ -package compiler.jvmci.code; +package jdk.vm.ci.code.test; import jdk.vm.ci.code.Register; import jdk.vm.ci.code.site.DataSectionReference; @@ -158,7 +159,6 @@ public class DataPatchTest extends CodeInstallationTest { }); } - public static long getConstSymbol(HotSpotMetaAccessProvider meta) { HotSpotSymbol symbol = meta.lookupSymbol("java/lang/Object"); return symbol.getMetaspacePointer(); diff --git a/hotspot/test/compiler/jvmci/code/DebugInfoTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DebugInfoTest.java similarity index 95% rename from hotspot/test/compiler/jvmci/code/DebugInfoTest.java rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DebugInfoTest.java index 3b3c33a1c02..c1bdc039196 100644 --- a/hotspot/test/compiler/jvmci/code/DebugInfoTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DebugInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -20,7 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package compiler.jvmci.code; +package jdk.vm.ci.code.test; import java.lang.reflect.Method; diff --git a/hotspot/test/compiler/jvmci/code/InterpreterFrameSizeTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java similarity index 92% rename from hotspot/test/compiler/jvmci/code/InterpreterFrameSizeTest.java rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java index 59c3e228c7a..098871da3b1 100644 --- a/hotspot/test/compiler/jvmci/code/InterpreterFrameSizeTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/InterpreterFrameSizeTest.java @@ -33,23 +33,20 @@ * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.code.InterpreterFrameSizeTest + * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.InterpreterFrameSizeTest */ -package compiler.jvmci.code; +package jdk.vm.ci.code.test; -import java.lang.reflect.Method; +import org.junit.Assert; +import org.junit.Test; import jdk.vm.ci.code.BytecodeFrame; +import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.JavaValue; import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.hotspot.HotSpotCodeCacheProvider; - -import org.junit.Assert; -import org.junit.Test; - public class InterpreterFrameSizeTest extends CodeInstallationTest { HotSpotCodeCacheProvider hotspotCodeCache() { @@ -61,7 +58,7 @@ public class InterpreterFrameSizeTest extends CodeInstallationTest { try { hotspotCodeCache().interpreterFrameSize(null); } catch (NullPointerException npe) { - System.out.println("threw NPE as expected"); + // Threw NPE as expected. return; } Assert.fail("expected NullPointerException"); @@ -78,7 +75,6 @@ public class InterpreterFrameSizeTest extends CodeInstallationTest { JavaKind[] slotKinds = new JavaKind[numLocals]; BytecodeFrame frame = new BytecodeFrame(null, resolvedMethod, bci, false, false, values, slotKinds, numLocals, numStack, 0); int size = hotspotCodeCache().interpreterFrameSize(frame); - System.out.println("Frame size is " + size + " bytes"); if (size <= 0) { Assert.fail("expected non-zero result"); } diff --git a/hotspot/test/compiler/jvmci/code/SimpleCodeInstallationTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java similarity index 87% rename from hotspot/test/compiler/jvmci/code/SimpleCodeInstallationTest.java rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java index 6c1377c8935..0b8ca5c19f7 100644 --- a/hotspot/test/compiler/jvmci/code/SimpleCodeInstallationTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleCodeInstallationTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,15 +32,16 @@ * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.code.SimpleCodeInstallationTest + * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java + * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.SimpleCodeInstallationTest */ -package compiler.jvmci.code; - -import jdk.vm.ci.code.Register; +package jdk.vm.ci.code.test; import org.junit.Test; +import jdk.vm.ci.code.Register; + /** * Test simple code installation. */ diff --git a/hotspot/test/compiler/jvmci/code/SimpleDebugInfoTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java similarity index 96% rename from hotspot/test/compiler/jvmci/code/SimpleDebugInfoTest.java rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java index b27802ce47a..5b00cb75a3c 100644 --- a/hotspot/test/compiler/jvmci/code/SimpleDebugInfoTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/SimpleDebugInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,10 +32,14 @@ * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.code.SimpleDebugInfoTest + * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java + * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.SimpleDebugInfoTest */ -package compiler.jvmci.code; +package jdk.vm.ci.code.test; + +import org.junit.Assume; +import org.junit.Test; import jdk.vm.ci.code.Register; import jdk.vm.ci.hotspot.HotSpotConstant; @@ -45,9 +49,6 @@ import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.ResolvedJavaType; import jdk.vm.ci.meta.Value; -import org.junit.Assume; -import org.junit.Test; - public class SimpleDebugInfoTest extends DebugInfoTest { public static int intOnStack() { @@ -99,7 +100,6 @@ public class SimpleDebugInfoTest extends DebugInfoTest { testIntInLocal(compiler); } - public static float floatOnStack() { return 42.0f; } @@ -149,7 +149,6 @@ public class SimpleDebugInfoTest extends DebugInfoTest { testFloatInLocal(compiler); } - public static long longOnStack() { return 42; } @@ -202,7 +201,6 @@ public class SimpleDebugInfoTest extends DebugInfoTest { testLongInLocal(compiler); } - public static Class objectOnStack() { return SimpleDebugInfoTest.class; } diff --git a/hotspot/test/compiler/jvmci/code/TestAssembler.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java similarity index 99% rename from hotspot/test/compiler/jvmci/code/TestAssembler.java rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java index 5034027a762..9e10e46ae80 100644 --- a/hotspot/test/compiler/jvmci/code/TestAssembler.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/TestAssembler.java @@ -21,7 +21,7 @@ * questions. */ -package compiler.jvmci.code; +package jdk.vm.ci.code.test; import java.nio.ByteBuffer; import java.nio.ByteOrder; diff --git a/hotspot/test/compiler/jvmci/code/VirtualObjectDebugInfoTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java similarity index 89% rename from hotspot/test/compiler/jvmci/code/VirtualObjectDebugInfoTest.java rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java index c06c5076eae..04dd67ccf0d 100644 --- a/hotspot/test/compiler/jvmci/code/VirtualObjectDebugInfoTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/VirtualObjectDebugInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,14 +32,18 @@ * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.amd64 * jdk.vm.ci/jdk.vm.ci.sparc - * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI compiler.jvmci.code.VirtualObjectDebugInfoTest + * @compile CodeInstallationTest.java DebugInfoTest.java TestAssembler.java amd64/AMD64TestAssembler.java sparc/SPARCTestAssembler.java + * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.code.test.VirtualObjectDebugInfoTest */ -package compiler.jvmci.code; +package jdk.vm.ci.code.test; import java.util.ArrayList; import java.util.Objects; +import org.junit.Assert; +import org.junit.Test; + import jdk.vm.ci.code.Register; import jdk.vm.ci.code.VirtualObject; import jdk.vm.ci.hotspot.HotSpotConstant; @@ -49,9 +53,6 @@ import jdk.vm.ci.meta.JavaValue; import jdk.vm.ci.meta.ResolvedJavaField; import jdk.vm.ci.meta.ResolvedJavaType; -import org.junit.Assert; -import org.junit.Test; - public class VirtualObjectDebugInfoTest extends DebugInfoTest { private static class TestClass { @@ -61,11 +62,11 @@ public class VirtualObjectDebugInfoTest extends DebugInfoTest { private float floatField; private Object[] arrayField; - public TestClass() { + TestClass() { this.longField = 8472; this.intField = 42; this.floatField = 3.14f; - this.arrayField = new Object[] { Integer.valueOf(58), this, null, Integer.valueOf(17), "Hello, World!" }; + this.arrayField = new Object[]{Integer.valueOf(58), this, null, Integer.valueOf(17), "Hello, World!"}; } @Override @@ -75,10 +76,7 @@ public class VirtualObjectDebugInfoTest extends DebugInfoTest { } TestClass other = (TestClass) o; - if (this.longField != other.longField - || this.intField != other.intField - || this.floatField != other.floatField - || this.arrayField.length != other.arrayField.length) { + if (this.longField != other.longField || this.intField != other.intField || this.floatField != other.floatField || this.arrayField.length != other.arrayField.length) { return false; } @@ -95,6 +93,11 @@ public class VirtualObjectDebugInfoTest extends DebugInfoTest { return true; } + + @Override + public int hashCode() { + return super.hashCode(); + } } public static TestClass buildObject() { diff --git a/hotspot/test/compiler/jvmci/code/amd64/AMD64TestAssembler.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java similarity index 96% rename from hotspot/test/compiler/jvmci/code/amd64/AMD64TestAssembler.java rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java index 4ed0625932b..7d249d67b37 100644 --- a/hotspot/test/compiler/jvmci/code/amd64/AMD64TestAssembler.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/amd64/AMD64TestAssembler.java @@ -21,7 +21,7 @@ * questions. */ -package compiler.jvmci.code.amd64; +package jdk.vm.ci.code.test.amd64; import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.amd64.AMD64Kind; @@ -31,6 +31,7 @@ import jdk.vm.ci.code.Register; import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.site.ConstantReference; import jdk.vm.ci.code.site.DataSectionReference; +import jdk.vm.ci.code.test.TestAssembler; import jdk.vm.ci.hotspot.HotSpotCallingConventionType; import jdk.vm.ci.hotspot.HotSpotConstant; import jdk.vm.ci.hotspot.HotSpotForeignCallTarget; @@ -39,8 +40,6 @@ import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.LIRKind; import jdk.vm.ci.meta.VMConstant; -import compiler.jvmci.code.TestAssembler; - public class AMD64TestAssembler extends TestAssembler { public AMD64TestAssembler(CodeCacheProvider codeCache) { @@ -161,7 +160,7 @@ public class AMD64TestAssembler extends TestAssembler { code.emitInt(0xDEADDEAD); return ret; } else { - return emitLoadLong(0xDEADDEADDEADDEADl); + return emitLoadLong(0xDEADDEADDEADDEADL); } } @@ -195,14 +194,16 @@ public class AMD64TestAssembler extends TestAssembler { @Override public StackSlot emitIntToStack(Register a) { StackSlot ret = newStackSlot(LIRKind.value(AMD64Kind.DWORD)); - emitModRMMemory(false, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); // MOV r/m32,r32 + // MOV r/m32,r32 + emitModRMMemory(false, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); return ret; } @Override public StackSlot emitLongToStack(Register a) { StackSlot ret = newStackSlot(LIRKind.value(AMD64Kind.QWORD)); - emitModRMMemory(true, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); // MOV r/m64,r64 + // MOV r/m64,r64 + emitModRMMemory(true, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); return ret; } @@ -221,14 +222,16 @@ public class AMD64TestAssembler extends TestAssembler { @Override public StackSlot emitPointerToStack(Register a) { StackSlot ret = newStackSlot(LIRKind.reference(AMD64Kind.QWORD)); - emitModRMMemory(true, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); // MOV r/m64,r64 + // MOV r/m64,r64 + emitModRMMemory(true, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); return ret; } @Override public StackSlot emitNarrowPointerToStack(Register a) { StackSlot ret = newStackSlot(LIRKind.reference(AMD64Kind.DWORD)); - emitModRMMemory(false, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); // MOV r/m32,r32 + // MOV r/m32,r32 + emitModRMMemory(false, 0x89, a.encoding, AMD64.rbp.encoding, ret.getRawOffset() + 16); return ret; } diff --git a/hotspot/test/compiler/jvmci/code/sparc/SPARCTestAssembler.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/sparc/SPARCTestAssembler.java similarity index 96% rename from hotspot/test/compiler/jvmci/code/sparc/SPARCTestAssembler.java rename to hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/sparc/SPARCTestAssembler.java index 5b2cd7f1453..7c7aa7bab92 100644 --- a/hotspot/test/compiler/jvmci/code/sparc/SPARCTestAssembler.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/sparc/SPARCTestAssembler.java @@ -21,7 +21,7 @@ * questions. */ -package compiler.jvmci.code.sparc; +package jdk.vm.ci.code.test.sparc; import jdk.vm.ci.code.CodeCacheProvider; import jdk.vm.ci.code.DebugInfo; @@ -29,6 +29,7 @@ import jdk.vm.ci.code.Register; import jdk.vm.ci.code.StackSlot; import jdk.vm.ci.code.site.ConstantReference; import jdk.vm.ci.code.site.DataSectionReference; +import jdk.vm.ci.code.test.TestAssembler; import jdk.vm.ci.hotspot.HotSpotCallingConventionType; import jdk.vm.ci.hotspot.HotSpotCompiledCode; import jdk.vm.ci.hotspot.HotSpotConstant; @@ -41,8 +42,6 @@ import jdk.vm.ci.meta.VMConstant; import jdk.vm.ci.sparc.SPARC; import jdk.vm.ci.sparc.SPARCKind; -import compiler.jvmci.code.TestAssembler; - public class SPARCTestAssembler extends TestAssembler { private static final int MASK13 = (1 << 13) - 1; @@ -69,7 +68,8 @@ public class SPARCTestAssembler extends TestAssembler { @Override public void emitPrologue() { - emitOp3(0b10, SPARC.sp, 0b111100, SPARC.sp, -SPARC.REGISTER_SAFE_AREA_SIZE); // SAVE sp, -128, sp + // SAVE sp, -128, sp + emitOp3(0b10, SPARC.sp, 0b111100, SPARC.sp, -SPARC.REGISTER_SAFE_AREA_SIZE); setDeoptRescueSlot(newStackSlot(LIRKind.value(SPARCKind.XWORD))); } @@ -195,35 +195,40 @@ public class SPARCTestAssembler extends TestAssembler { @Override public StackSlot emitIntToStack(Register a) { StackSlot ret = newStackSlot(LIRKind.value(SPARCKind.WORD)); - emitOp3(0b11, a, 0b000100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STW a, [fp+offset] + // STW a, [fp+offset] + emitOp3(0b11, a, 0b000100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); return ret; } @Override public StackSlot emitLongToStack(Register a) { StackSlot ret = newStackSlot(LIRKind.value(SPARCKind.XWORD)); - emitOp3(0b11, a, 0b001110, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STX a, [fp+offset] + // STX a, [fp+offset] + emitOp3(0b11, a, 0b001110, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); return ret; } @Override public StackSlot emitFloatToStack(Register a) { StackSlot ret = newStackSlot(LIRKind.value(SPARCKind.SINGLE)); - emitOp3(0b11, a, 0b100100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STF a, [fp+offset] + // STF a, [fp+offset] + emitOp3(0b11, a, 0b100100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); return ret; } @Override public StackSlot emitPointerToStack(Register a) { StackSlot ret = newStackSlot(LIRKind.reference(SPARCKind.XWORD)); - emitOp3(0b11, a, 0b001110, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STX a, [fp+offset] + // STX a, [fp+offset] + emitOp3(0b11, a, 0b001110, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); return ret; } @Override public StackSlot emitNarrowPointerToStack(Register a) { StackSlot ret = newStackSlot(LIRKind.reference(SPARCKind.WORD)); - emitOp3(0b11, a, 0b000100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); // STW a, [fp+offset] + // STW a, [fp+offset] + emitOp3(0b11, a, 0b000100, SPARC.fp, ret.getRawOffset() + SPARC.STACK_BIAS); return ret; } -- GitLab From 19d90c789d46153ba8db9560bb88c9c11a5a5c4f Mon Sep 17 00:00:00 2001 From: Long Chen Date: Thu, 7 Apr 2016 22:36:16 +0000 Subject: [PATCH 126/400] 8153797: aarch64: Add Arrays.fill stub code Reviewed-by: aph --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 53 +------ .../cpu/aarch64/vm/macroAssembler_aarch64.cpp | 55 +++++++ .../cpu/aarch64/vm/macroAssembler_aarch64.hpp | 3 + .../cpu/aarch64/vm/stubGenerator_aarch64.cpp | 136 ++++++++++++++++++ 4 files changed, 197 insertions(+), 50 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index e92411bab18..499a2d0013e 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -4190,55 +4190,6 @@ encode %{ } %} - enc_class aarch64_enc_clear_array_reg_reg(iRegL_R11 cnt, iRegP_R10 base) %{ - MacroAssembler _masm(&cbuf); - Register cnt_reg = as_Register($cnt$$reg); - Register base_reg = as_Register($base$$reg); - // base is word aligned - // cnt is count of words - - Label loop; - Label entry; - -// Algorithm: -// -// scratch1 = cnt & 7; -// cnt -= scratch1; -// p += scratch1; -// switch (scratch1) { -// do { -// cnt -= 8; -// p[-8] = 0; -// case 7: -// p[-7] = 0; -// case 6: -// p[-6] = 0; -// // ... -// case 1: -// p[-1] = 0; -// case 0: -// p += 8; -// } while (cnt); -// } - - const int unroll = 8; // Number of str(zr) instructions we'll unroll - - __ andr(rscratch1, cnt_reg, unroll - 1); // tmp1 = cnt % unroll - __ sub(cnt_reg, cnt_reg, rscratch1); // cnt -= unroll - // base_reg always points to the end of the region we're about to zero - __ add(base_reg, base_reg, rscratch1, Assembler::LSL, exact_log2(wordSize)); - __ adr(rscratch2, entry); - __ sub(rscratch2, rscratch2, rscratch1, Assembler::LSL, 2); - __ br(rscratch2); - __ bind(loop); - __ sub(cnt_reg, cnt_reg, unroll); - for (int i = -unroll; i < 0; i++) - __ str(zr, Address(base_reg, i * wordSize)); - __ bind(entry); - __ add(base_reg, base_reg, unroll * wordSize); - __ cbnz(cnt_reg, loop); - %} - /// mov envcodings enc_class aarch64_enc_movw_imm(iRegI dst, immI src) %{ @@ -13363,7 +13314,9 @@ instruct clearArray_reg_reg(iRegL_R11 cnt, iRegP_R10 base, Universe dummy, rFlag ins_cost(4 * INSN_COST); format %{ "ClearArray $cnt, $base" %} - ins_encode(aarch64_enc_clear_array_reg_reg(cnt, base)); + ins_encode %{ + __ zero_words($base$$Register, $cnt$$Register); + %} ins_pipe(pipe_class_memory); %} diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp index 0ede2e9847a..cb87e7d4887 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp @@ -4670,6 +4670,61 @@ void MacroAssembler::arrays_equals(Register a1, Register a2, BLOCK_COMMENT(is_string ? "} string_equals" : "} array_equals"); } +// base: Address of a buffer to be zeroed, 8 bytes aligned. +// cnt: Count in 8-byte unit. +void MacroAssembler::zero_words(Register base, Register cnt) +{ + fill_words(base, cnt, zr); +} + +// base: Address of a buffer to be filled, 8 bytes aligned. +// cnt: Count in 8-byte unit. +// value: Value to be filled with. +// base will point to the end of the buffer after filling. +void MacroAssembler::fill_words(Register base, Register cnt, Register value) +{ +// Algorithm: +// +// scratch1 = cnt & 7; +// cnt -= scratch1; +// p += scratch1; +// switch (scratch1) { +// do { +// cnt -= 8; +// p[-8] = v; +// case 7: +// p[-7] = v; +// case 6: +// p[-6] = v; +// // ... +// case 1: +// p[-1] = v; +// case 0: +// p += 8; +// } while (cnt); +// } + + assert_different_registers(base, cnt, value, rscratch1, rscratch2); + + Label entry, loop; + const int unroll = 8; // Number of str instructions we'll unroll + + andr(rscratch1, cnt, unroll - 1); // tmp1 = cnt % unroll + cbz(rscratch1, entry); + sub(cnt, cnt, rscratch1); // cnt -= tmp1 + // base always points to the end of the region we're about to fill + add(base, base, rscratch1, Assembler::LSL, 3); + adr(rscratch2, entry); + sub(rscratch2, rscratch2, rscratch1, Assembler::LSL, 2); + br(rscratch2); + bind(loop); + add(base, base, unroll * 8); + sub(cnt, cnt, unroll); + for (int i = -unroll; i < 0; i++) + str(value, Address(base, i * 8)); + bind(entry); + cbnz(cnt, loop); +} // encode char[] to byte[] in ISO_8859_1 void MacroAssembler::encode_iso_array(Register src, Register dst, diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp index b114e1b9c80..da989486e98 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp @@ -1184,6 +1184,9 @@ public: Register result, Register cnt1, int elem_size, bool is_string); + void fill_words(Register base, Register cnt, Register value); + void zero_words(Register base, Register cnt); + void encode_iso_array(Register src, Register dst, Register len, Register result, FloatRegister Vtmp1, FloatRegister Vtmp2, diff --git a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp index d618c0351f7..f1bf5beeb76 100644 --- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp @@ -2022,6 +2022,136 @@ class StubGenerator: public StubCodeGenerator { return start; } + // + // Generate stub for array fill. If "aligned" is true, the + // "to" address is assumed to be heapword aligned. + // + // Arguments for generated stub: + // to: c_rarg0 + // value: c_rarg1 + // count: c_rarg2 treated as signed + // + address generate_fill(BasicType t, bool aligned, const char *name) { + __ align(CodeEntryAlignment); + StubCodeMark mark(this, "StubRoutines", name); + address start = __ pc(); + + BLOCK_COMMENT("Entry:"); + + const Register to = c_rarg0; // source array address + const Register value = c_rarg1; // value + const Register count = c_rarg2; // elements count + const Register cnt_words = c_rarg3; // temp register + + __ enter(); + + Label L_fill_elements, L_exit1; + + int shift = -1; + switch (t) { + case T_BYTE: + shift = 0; + __ cmpw(count, 8 >> shift); // Short arrays (< 8 bytes) fill by element + __ bfi(value, value, 8, 8); // 8 bit -> 16 bit + __ bfi(value, value, 16, 16); // 16 bit -> 32 bit + __ br(Assembler::LO, L_fill_elements); + break; + case T_SHORT: + shift = 1; + __ cmpw(count, 8 >> shift); // Short arrays (< 8 bytes) fill by element + __ bfi(value, value, 16, 16); // 16 bit -> 32 bit + __ br(Assembler::LO, L_fill_elements); + break; + case T_INT: + shift = 2; + __ cmpw(count, 8 >> shift); // Short arrays (< 8 bytes) fill by element + __ br(Assembler::LO, L_fill_elements); + break; + default: ShouldNotReachHere(); + } + + // Align source address at 8 bytes address boundary. + Label L_skip_align1, L_skip_align2, L_skip_align4; + if (!aligned) { + switch (t) { + case T_BYTE: + // One byte misalignment happens only for byte arrays. + __ tbz(to, 0, L_skip_align1); + __ strb(value, Address(__ post(to, 1))); + __ subw(count, count, 1); + __ bind(L_skip_align1); + // Fallthrough + case T_SHORT: + // Two bytes misalignment happens only for byte and short (char) arrays. + __ tbz(to, 1, L_skip_align2); + __ strh(value, Address(__ post(to, 2))); + __ subw(count, count, 2 >> shift); + __ bind(L_skip_align2); + // Fallthrough + case T_INT: + // Align to 8 bytes, we know we are 4 byte aligned to start. + __ tbz(to, 2, L_skip_align4); + __ strw(value, Address(__ post(to, 4))); + __ subw(count, count, 4 >> shift); + __ bind(L_skip_align4); + break; + default: ShouldNotReachHere(); + } + } + + // + // Fill large chunks + // + __ lsrw(cnt_words, count, 3 - shift); // number of words + __ bfi(value, value, 32, 32); // 32 bit -> 64 bit + __ subw(count, count, cnt_words, Assembler::LSL, 3 - shift); + __ fill_words(to, cnt_words, value); + + // Remaining count is less than 8 bytes. Fill it by a single store. + // Note that the total length is no less than 8 bytes. + if (t == T_BYTE || t == T_SHORT) { + Label L_exit1; + __ cbzw(count, L_exit1); + __ add(to, to, count, Assembler::LSL, shift); // points to the end + __ str(value, Address(to, -8)); // overwrite some elements + __ bind(L_exit1); + __ leave(); + __ ret(lr); + } + + // Handle copies less than 8 bytes. + Label L_fill_2, L_fill_4, L_exit2; + __ bind(L_fill_elements); + switch (t) { + case T_BYTE: + __ tbz(count, 0, L_fill_2); + __ strb(value, Address(__ post(to, 1))); + __ bind(L_fill_2); + __ tbz(count, 1, L_fill_4); + __ strh(value, Address(__ post(to, 2))); + __ bind(L_fill_4); + __ tbz(count, 2, L_exit2); + __ strw(value, Address(to)); + break; + case T_SHORT: + __ tbz(count, 0, L_fill_4); + __ strh(value, Address(__ post(to, 2))); + __ bind(L_fill_4); + __ tbz(count, 1, L_exit2); + __ strw(value, Address(to)); + break; + case T_INT: + __ cbzw(count, L_exit2); + __ strw(value, Address(to)); + break; + default: ShouldNotReachHere(); + } + __ bind(L_exit2); + __ leave(); + __ ret(lr); + return start; + } + void generate_arraycopy_stubs() { address entry; address entry_jbyte_arraycopy; @@ -2125,6 +2255,12 @@ class StubGenerator: public StubCodeGenerator { entry_jlong_arraycopy, entry_checkcast_arraycopy); + StubRoutines::_jbyte_fill = generate_fill(T_BYTE, false, "jbyte_fill"); + StubRoutines::_jshort_fill = generate_fill(T_SHORT, false, "jshort_fill"); + StubRoutines::_jint_fill = generate_fill(T_INT, false, "jint_fill"); + StubRoutines::_arrayof_jbyte_fill = generate_fill(T_BYTE, true, "arrayof_jbyte_fill"); + StubRoutines::_arrayof_jshort_fill = generate_fill(T_SHORT, true, "arrayof_jshort_fill"); + StubRoutines::_arrayof_jint_fill = generate_fill(T_INT, true, "arrayof_jint_fill"); } void generate_math_stubs() { Unimplemented(); } -- GitLab From 0c233de7ff0d61bd027f4fbf13d95f4de9bdaf73 Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Mon, 11 Apr 2016 21:42:31 +0300 Subject: [PATCH 127/400] 8138861: C2 complains about unreasonably large method running Octane zlib in Nashorn Reviewed-by: kvn --- hotspot/src/share/vm/opto/output.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp index 7d90d638ed4..5774d637cda 100644 --- a/hotspot/src/share/vm/opto/output.cpp +++ b/hotspot/src/share/vm/opto/output.cpp @@ -1483,8 +1483,6 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { // Compute the size of the first block _first_block_size = blk_labels[1].loc_pos() - blk_labels[0].loc_pos(); - assert(cb->insts_size() < 500000, "method is unreasonably large"); - #ifdef ASSERT for (uint i = 0; i < nblocks; i++) { // For all blocks if (jmp_target[i] != 0) { -- GitLab From 7fc81004e34da21d3eb9f34d8eb8be635b705101 Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Mon, 11 Apr 2016 21:42:55 +0300 Subject: [PATCH 128/400] 8152590: C2: @Stable support doesn't always work w/ incremental inlining Reviewed-by: kvn --- hotspot/src/share/vm/c1/c1_Canonicalizer.cpp | 2 +- hotspot/src/share/vm/c1/c1_GraphBuilder.cpp | 36 ++-- hotspot/src/share/vm/ci/ciConstant.hpp | 3 + hotspot/src/share/vm/ci/ciField.cpp | 143 ++++++-------- hotspot/src/share/vm/ci/ciField.hpp | 56 +++--- hotspot/src/share/vm/ci/ciInstance.cpp | 67 +++---- hotspot/src/share/vm/ci/ciInstance.hpp | 3 + hotspot/src/share/vm/ci/ciKlass.cpp | 7 +- hotspot/src/share/vm/ci/ciSymbol.cpp | 4 +- hotspot/src/share/vm/opto/graphKit.cpp | 19 ++ hotspot/src/share/vm/opto/graphKit.hpp | 2 + hotspot/src/share/vm/opto/library_call.cpp | 8 +- hotspot/src/share/vm/opto/macro.cpp | 2 +- hotspot/src/share/vm/opto/memnode.cpp | 104 ++-------- hotspot/src/share/vm/opto/parse3.cpp | 14 +- hotspot/src/share/vm/opto/stringopts.cpp | 2 +- hotspot/src/share/vm/opto/type.cpp | 186 +++++++++++++----- hotspot/src/share/vm/opto/type.hpp | 23 ++- .../unsafe/UnsafeGetConstantField.java | 2 +- .../unsafe/UnsafeGetStableArrayElement.java | 27 +-- 20 files changed, 351 insertions(+), 359 deletions(-) diff --git a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp index c4a084a4518..a7971dcfbb3 100644 --- a/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp +++ b/hotspot/src/share/vm/c1/c1_Canonicalizer.cpp @@ -247,7 +247,7 @@ void Canonicalizer::do_ArrayLength (ArrayLength* x) { } else if ((lf = x->array()->as_LoadField()) != NULL) { ciField* field = lf->field(); - if (field->is_constant() && field->is_static()) { + if (field->is_static_constant()) { assert(PatchALot || ScavengeRootsInCode < 2, "Constant field loads are folded during parsing"); ciObject* c = field->constant_value().as_object(); if (!c->is_null_object()) { diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index a15a521adaf..26c2fd33cff 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -1520,6 +1520,8 @@ void GraphBuilder::method_return(Value x) { } Value GraphBuilder::make_constant(ciConstant field_value, ciField* field) { + if (!field_value.is_valid()) return NULL; + BasicType field_type = field_value.basic_type(); ValueType* value = as_ValueType(field_value); @@ -1587,9 +1589,8 @@ void GraphBuilder::access_field(Bytecodes::Code code) { case Bytecodes::_getstatic: { // check for compile-time constants, i.e., initialized static final fields Value constant = NULL; - if (field->is_constant() && !PatchALot) { + if (field->is_static_constant() && !PatchALot) { ciConstant field_value = field->constant_value(); - // Stable static fields are checked for non-default values in ciField::initialize_from(). assert(!field->is_stable() || !field_value.is_null_or_zero(), "stable static w/ default value shouldn't be a constant"); constant = make_constant(field_value, field); @@ -1618,31 +1619,18 @@ void GraphBuilder::access_field(Bytecodes::Code code) { Value constant = NULL; obj = apop(); ObjectType* obj_type = obj->type()->as_ObjectType(); - if (obj_type->is_constant() && !PatchALot) { + if (field->is_constant() && obj_type->is_constant() && !PatchALot) { ciObject* const_oop = obj_type->constant_value(); if (!const_oop->is_null_object() && const_oop->is_loaded()) { - if (field->is_constant()) { - ciConstant field_value = field->constant_value_of(const_oop); - if (FoldStableValues && field->is_stable() && field_value.is_null_or_zero()) { - // Stable field with default value can't be constant. - constant = NULL; - } else { - constant = make_constant(field_value, field); - } - } else { - // For CallSite objects treat the target field as a compile time constant. - if (const_oop->is_call_site()) { + ciConstant field_value = field->constant_value_of(const_oop); + if (field_value.is_valid()) { + constant = make_constant(field_value, field); + // For CallSite objects add a dependency for invalidation of the optimization. + if (field->is_call_site_target()) { ciCallSite* call_site = const_oop->as_call_site(); - if (field->is_call_site_target()) { - ciMethodHandle* target = call_site->get_target(); - if (target != NULL) { // just in case - ciConstant field_val(T_OBJECT, target); - constant = new Constant(as_ValueType(field_val)); - // Add a dependence for invalidation of the optimization. - if (!call_site->is_constant_call_site()) { - dependency_recorder()->assert_call_site_target_value(call_site, target); - } - } + if (!call_site->is_constant_call_site()) { + ciMethodHandle* target = field_value.as_object()->as_method_handle(); + dependency_recorder()->assert_call_site_target_value(call_site, target); } } } diff --git a/hotspot/src/share/vm/ci/ciConstant.hpp b/hotspot/src/share/vm/ci/ciConstant.hpp index 5af058f4e9b..513653392d1 100644 --- a/hotspot/src/share/vm/ci/ciConstant.hpp +++ b/hotspot/src/share/vm/ci/ciConstant.hpp @@ -124,6 +124,9 @@ public: } } + bool is_valid() const { + return basic_type() != T_ILLEGAL; + } // Debugging output void print(); }; diff --git a/hotspot/src/share/vm/ci/ciField.cpp b/hotspot/src/share/vm/ci/ciField.cpp index 0078f44ed21..4d37c923ffe 100644 --- a/hotspot/src/share/vm/ci/ciField.cpp +++ b/hotspot/src/share/vm/ci/ciField.cpp @@ -235,94 +235,75 @@ void ciField::initialize_from(fieldDescriptor* fd) { _holder = CURRENT_ENV->get_instance_klass(fd->field_holder()); // Check to see if the field is constant. - bool is_final = this->is_final(); - bool is_stable = FoldStableValues && this->is_stable(); - if (_holder->is_initialized() && (is_final || is_stable)) { - if (!this->is_static()) { - // A field can be constant if it's a final static field or if + Klass* k = _holder->get_Klass(); + bool is_stable_field = FoldStableValues && is_stable(); + if (is_final() || is_stable_field) { + if (is_static()) { + // This field just may be constant. The only case where it will + // not be constant is when the field is a *special* static & final field + // whose value may change. The three examples are java.lang.System.in, + // java.lang.System.out, and java.lang.System.err. + assert(SystemDictionary::System_klass() != NULL, "Check once per vm"); + if (k == SystemDictionary::System_klass()) { + // Check offsets for case 2: System.in, System.out, or System.err + if( _offset == java_lang_System::in_offset_in_bytes() || + _offset == java_lang_System::out_offset_in_bytes() || + _offset == java_lang_System::err_offset_in_bytes() ) { + _is_constant = false; + return; + } + } + _is_constant = true; + } else { + // An instance field can be constant if it's a final static field or if // it's a final non-static field of a trusted class (classes in // java.lang.invoke and sun.invoke packages and subpackages). - if (is_stable || trust_final_non_static_fields(_holder)) { - _is_constant = true; - return; - } + _is_constant = is_stable_field || trust_final_non_static_fields(_holder); + } + } else { + // For CallSite objects treat the target field as a compile time constant. + assert(SystemDictionary::CallSite_klass() != NULL, "should be already initialized"); + if (k == SystemDictionary::CallSite_klass() && + _offset == java_lang_invoke_CallSite::target_offset_in_bytes()) { + _is_constant = true; + } else { + // Non-final & non-stable fields are not constants. _is_constant = false; - return; } + } +} - // This field just may be constant. The only case where it will - // not be constant is when the field is a *special* static&final field - // whose value may change. The three examples are java.lang.System.in, - // java.lang.System.out, and java.lang.System.err. - - KlassHandle k = _holder->get_Klass(); - assert( SystemDictionary::System_klass() != NULL, "Check once per vm"); - if( k() == SystemDictionary::System_klass() ) { - // Check offsets for case 2: System.in, System.out, or System.err - if( _offset == java_lang_System::in_offset_in_bytes() || - _offset == java_lang_System::out_offset_in_bytes() || - _offset == java_lang_System::err_offset_in_bytes() ) { - _is_constant = false; - return; - } - } +// ------------------------------------------------------------------ +// ciField::constant_value +// Get the constant value of a this static field. +ciConstant ciField::constant_value() { + assert(is_static() && is_constant(), "illegal call to constant_value()"); + if (!_holder->is_initialized()) { + return ciConstant(); // Not initialized yet + } + if (_constant_value.basic_type() == T_ILLEGAL) { + // Static fields are placed in mirror objects. + VM_ENTRY_MARK; + ciInstance* mirror = CURRENT_ENV->get_instance(_holder->get_Klass()->java_mirror()); + _constant_value = mirror->field_value_impl(type()->basic_type(), offset()); + } + if (FoldStableValues && is_stable() && _constant_value.is_null_or_zero()) { + return ciConstant(); + } + return _constant_value; +} - Handle mirror = k->java_mirror(); - - switch(type()->basic_type()) { - case T_BYTE: - _constant_value = ciConstant(type()->basic_type(), mirror->byte_field(_offset)); - break; - case T_CHAR: - _constant_value = ciConstant(type()->basic_type(), mirror->char_field(_offset)); - break; - case T_SHORT: - _constant_value = ciConstant(type()->basic_type(), mirror->short_field(_offset)); - break; - case T_BOOLEAN: - _constant_value = ciConstant(type()->basic_type(), mirror->bool_field(_offset)); - break; - case T_INT: - _constant_value = ciConstant(type()->basic_type(), mirror->int_field(_offset)); - break; - case T_FLOAT: - _constant_value = ciConstant(mirror->float_field(_offset)); - break; - case T_DOUBLE: - _constant_value = ciConstant(mirror->double_field(_offset)); - break; - case T_LONG: - _constant_value = ciConstant(mirror->long_field(_offset)); - break; - case T_OBJECT: - case T_ARRAY: - { - oop o = mirror->obj_field(_offset); - - // A field will be "constant" if it is known always to be - // a non-null reference to an instance of a particular class, - // or to a particular array. This can happen even if the instance - // or array is not perm. In such a case, an "unloaded" ciArray - // or ciInstance is created. The compiler may be able to use - // information about the object's class (which is exact) or length. - - if (o == NULL) { - _constant_value = ciConstant(type()->basic_type(), ciNullObject::make()); - } else { - _constant_value = ciConstant(type()->basic_type(), CURRENT_ENV->get_object(o)); - assert(_constant_value.as_object() == CURRENT_ENV->get_object(o), "check interning"); - } - } - } - if (is_stable && _constant_value.is_null_or_zero()) { - // It is not a constant after all; treat it as uninitialized. - _is_constant = false; - } else { - _is_constant = true; - } - } else { - _is_constant = false; +// ------------------------------------------------------------------ +// ciField::constant_value_of +// Get the constant value of non-static final field in the given object. +ciConstant ciField::constant_value_of(ciObject* object) { + assert(!is_static() && is_constant(), "only if field is non-static constant"); + assert(object->is_instance(), "must be instance"); + ciConstant field_value = object->as_instance()->field_value(this); + if (FoldStableValues && is_stable() && field_value.is_null_or_zero()) { + return ciConstant(); } + return field_value; } // ------------------------------------------------------------------ diff --git a/hotspot/src/share/vm/ci/ciField.hpp b/hotspot/src/share/vm/ci/ciField.hpp index dd07a9973f9..f30e7144e12 100644 --- a/hotspot/src/share/vm/ci/ciField.hpp +++ b/hotspot/src/share/vm/ci/ciField.hpp @@ -62,7 +62,7 @@ private: void initialize_from(fieldDescriptor* fd); public: - ciFlags flags() { return _flags; } + ciFlags flags() const { return _flags; } // Of which klass is this field a member? // @@ -89,13 +89,13 @@ public: // // In that case the declared holder of f would be B and // the canonical holder of f would be A. - ciInstanceKlass* holder() { return _holder; } + ciInstanceKlass* holder() const { return _holder; } // Name of this field? - ciSymbol* name() { return _name; } + ciSymbol* name() const { return _name; } // Signature of this field? - ciSymbol* signature() { return _signature; } + ciSymbol* signature() const { return _signature; } // Of what type is this field? ciType* type() { return (_type == NULL) ? compute_type() : _type; } @@ -107,13 +107,13 @@ public: int size_in_bytes() { return type2aelembytes(layout_type()); } // What is the offset of this field? - int offset() { + int offset() const { assert(_offset >= 1, "illegal call to offset()"); return _offset; } // Same question, explicit units. (Fields are aligned to the byte level.) - int offset_in_bytes() { + int offset_in_bytes() const { return offset(); } @@ -127,31 +127,27 @@ public: // // Clarification: A field is considered constant if: // 1. The field is both static and final - // 2. The canonical holder of the field has undergone - // static initialization. - // 3. The field is not one of the special static/final + // 2. The field is not one of the special static/final // non-constant fields. These are java.lang.System.in // and java.lang.System.out. Abomination. // // A field is also considered constant if it is marked @Stable // and is non-null (or non-zero, if a primitive). - // For non-static fields, the null/zero check must be - // arranged by the user, as constant_value().is_null_or_zero(). - bool is_constant() { return _is_constant; } - - // Get the constant value of this field. - ciConstant constant_value() { - assert(is_static() && is_constant(), "illegal call to constant_value()"); - return _constant_value; + // + // A user should also check the field value (constant_value().is_valid()), since + // constant fields of non-initialized classes don't have values yet. + bool is_constant() const { return _is_constant; } + + // Get the constant value of the static field. + ciConstant constant_value(); + + bool is_static_constant() { + return is_static() && is_constant() && constant_value().is_valid(); } // Get the constant value of non-static final field in the given // object. - ciConstant constant_value_of(ciObject* object) { - assert(!is_static() && is_constant(), "only if field is non-static constant"); - assert(object->is_instance(), "must be instance"); - return object->as_instance()->field_value(this); - } + ciConstant constant_value_of(ciObject* object); // Check for link time errors. Accessing a field from a // certain class via a certain bytecode may or may not be legal. @@ -165,14 +161,14 @@ public: Bytecodes::Code bc); // Java access flags - bool is_public () { return flags().is_public(); } - bool is_private () { return flags().is_private(); } - bool is_protected () { return flags().is_protected(); } - bool is_static () { return flags().is_static(); } - bool is_final () { return flags().is_final(); } - bool is_stable () { return flags().is_stable(); } - bool is_volatile () { return flags().is_volatile(); } - bool is_transient () { return flags().is_transient(); } + bool is_public () const { return flags().is_public(); } + bool is_private () const { return flags().is_private(); } + bool is_protected () const { return flags().is_protected(); } + bool is_static () const { return flags().is_static(); } + bool is_final () const { return flags().is_final(); } + bool is_stable () const { return flags().is_stable(); } + bool is_volatile () const { return flags().is_volatile(); } + bool is_transient () const { return flags().is_transient(); } bool is_call_site_target() { ciInstanceKlass* callsite_klass = CURRENT_ENV->CallSite_klass(); diff --git a/hotspot/src/share/vm/ci/ciInstance.cpp b/hotspot/src/share/vm/ci/ciInstance.cpp index f276a53fb5d..d2073abdbf1 100644 --- a/hotspot/src/share/vm/ci/ciInstance.cpp +++ b/hotspot/src/share/vm/ci/ciInstance.cpp @@ -56,49 +56,21 @@ ciType* ciInstance::java_mirror_type() { } // ------------------------------------------------------------------ -// ciInstance::field_value -// -// Constant value of a field. -ciConstant ciInstance::field_value(ciField* field) { - assert(is_loaded(), "invalid access - must be loaded"); - assert(field->holder()->is_loaded(), "invalid access - holder must be loaded"); - assert(klass()->is_subclass_of(field->holder()), "invalid access - must be subclass"); - - VM_ENTRY_MARK; - ciConstant result; +// ciInstance::field_value_impl +ciConstant ciInstance::field_value_impl(BasicType field_btype, int offset) { Handle obj = get_oop(); assert(!obj.is_null(), "bad oop"); - BasicType field_btype = field->type()->basic_type(); - int offset = field->offset(); - switch(field_btype) { - case T_BYTE: - return ciConstant(field_btype, obj->byte_field(offset)); - break; - case T_CHAR: - return ciConstant(field_btype, obj->char_field(offset)); - break; - case T_SHORT: - return ciConstant(field_btype, obj->short_field(offset)); - break; - case T_BOOLEAN: - return ciConstant(field_btype, obj->bool_field(offset)); - break; - case T_INT: - return ciConstant(field_btype, obj->int_field(offset)); - break; - case T_FLOAT: - return ciConstant(obj->float_field(offset)); - break; - case T_DOUBLE: - return ciConstant(obj->double_field(offset)); - break; - case T_LONG: - return ciConstant(obj->long_field(offset)); - break; - case T_OBJECT: - case T_ARRAY: - { + case T_BYTE: return ciConstant(field_btype, obj->byte_field(offset)); + case T_CHAR: return ciConstant(field_btype, obj->char_field(offset)); + case T_SHORT: return ciConstant(field_btype, obj->short_field(offset)); + case T_BOOLEAN: return ciConstant(field_btype, obj->bool_field(offset)); + case T_INT: return ciConstant(field_btype, obj->int_field(offset)); + case T_FLOAT: return ciConstant(obj->float_field(offset)); + case T_DOUBLE: return ciConstant(obj->double_field(offset)); + case T_LONG: return ciConstant(obj->long_field(offset)); + case T_OBJECT: // fall through + case T_ARRAY: { oop o = obj->obj_field(offset); // A field will be "constant" if it is known always to be @@ -115,11 +87,22 @@ ciConstant ciInstance::field_value(ciField* field) { } } } - ShouldNotReachHere(); - // to shut up the compiler + fatal("no field value: %s", type2name(field_btype)); return ciConstant(); } +// ------------------------------------------------------------------ +// ciInstance::field_value +// +// Constant value of a field. +ciConstant ciInstance::field_value(ciField* field) { + assert(is_loaded(), "invalid access - must be loaded"); + assert(field->holder()->is_loaded(), "invalid access - holder must be loaded"); + assert(field->is_static() || klass()->is_subclass_of(field->holder()), "invalid access - must be subclass"); + + GUARDED_VM_ENTRY(return field_value_impl(field->type()->basic_type(), field->offset());) +} + // ------------------------------------------------------------------ // ciInstance::field_value_by_offset // diff --git a/hotspot/src/share/vm/ci/ciInstance.hpp b/hotspot/src/share/vm/ci/ciInstance.hpp index a33aabbc0ce..96c470e54ee 100644 --- a/hotspot/src/share/vm/ci/ciInstance.hpp +++ b/hotspot/src/share/vm/ci/ciInstance.hpp @@ -36,6 +36,7 @@ // instance of java.lang.Object. class ciInstance : public ciObject { CI_PACKAGE_ACCESS + friend class ciField; protected: ciInstance(instanceHandle h_i) : ciObject(h_i) { @@ -50,6 +51,8 @@ protected: void print_impl(outputStream* st); + ciConstant field_value_impl(BasicType field_btype, int offset); + public: // If this object is a java mirror, return the corresponding type. // Otherwise, return NULL. diff --git a/hotspot/src/share/vm/ci/ciKlass.cpp b/hotspot/src/share/vm/ci/ciKlass.cpp index 75c3c140a8e..ab980fafafc 100644 --- a/hotspot/src/share/vm/ci/ciKlass.cpp +++ b/hotspot/src/share/vm/ci/ciKlass.cpp @@ -88,12 +88,7 @@ bool ciKlass::is_subclass_of(ciKlass* that) { assert(this->is_loaded(), "must be loaded: %s", this->name()->as_quoted_ascii()); assert(that->is_loaded(), "must be loaded: %s", that->name()->as_quoted_ascii()); - VM_ENTRY_MARK; - Klass* this_klass = get_Klass(); - Klass* that_klass = that->get_Klass(); - bool result = this_klass->is_subclass_of(that_klass); - - return result; + GUARDED_VM_ENTRY(return get_Klass()->is_subclass_of(that->get_Klass());) } // ------------------------------------------------------------------ diff --git a/hotspot/src/share/vm/ci/ciSymbol.cpp b/hotspot/src/share/vm/ci/ciSymbol.cpp index f141832df14..fa4c165bbef 100644 --- a/hotspot/src/share/vm/ci/ciSymbol.cpp +++ b/hotspot/src/share/vm/ci/ciSymbol.cpp @@ -58,9 +58,7 @@ ciSymbol::ciSymbol(Symbol* s) // // The text of the symbol as a null-terminated C string. const char* ciSymbol::as_utf8() { - VM_QUICK_ENTRY_MARK; - Symbol* s = get_symbol(); - return s->as_utf8(); + GUARDED_VM_QUICK_ENTRY(return get_symbol()->as_utf8();) } // The text of the symbol as a null-terminated C string. diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp index 37af6913e54..b97558d2475 100644 --- a/hotspot/src/share/vm/opto/graphKit.cpp +++ b/hotspot/src/share/vm/opto/graphKit.cpp @@ -4466,6 +4466,25 @@ void GraphKit::inflate_string_slow(Node* src, Node* dst, Node* start, Node* coun set_memory(st, TypeAryPtr::BYTES); } +Node* GraphKit::make_constant_from_field(ciField* field, Node* obj) { + if (!field->is_constant()) { + return NULL; // Field not marked as constant. + } + ciInstance* holder = NULL; + if (!field->is_static()) { + ciObject* const_oop = obj->bottom_type()->is_oopptr()->const_oop(); + if (const_oop != NULL && const_oop->is_instance()) { + holder = const_oop->as_instance(); + } + } + const Type* con_type = Type::make_constant_from_field(field, holder, field->layout_type(), + /*is_unsigned_load=*/false); + if (con_type != NULL) { + return makecon(con_type); + } + return NULL; +} + Node* GraphKit::cast_array_to_stable(Node* ary, const TypeAryPtr* ary_type) { // Reify the property as a CastPP node in Ideal graph to comply with monotonicity // assumption of CCP analysis. diff --git a/hotspot/src/share/vm/opto/graphKit.hpp b/hotspot/src/share/vm/opto/graphKit.hpp index 218e937818b..797705d3a42 100644 --- a/hotspot/src/share/vm/opto/graphKit.hpp +++ b/hotspot/src/share/vm/opto/graphKit.hpp @@ -910,6 +910,8 @@ class GraphKit : public Phase { void add_predicate(int nargs = 0); void add_predicate_impl(Deoptimization::DeoptReason reason, int nargs); + Node* make_constant_from_field(ciField* field, Node* obj); + // Produce new array node of stable type Node* cast_array_to_stable(Node* ary, const TypeAryPtr* ary_type); }; diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index eb3718f8381..cb94c6102d5 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -2550,13 +2550,9 @@ bool LibraryCallKit::inline_unsafe_access(const bool is_native_ptr, bool is_stor Node* p = NULL; // Try to constant fold a load from a constant field ciField* field = alias_type->field(); - if (heap_base_oop != top() && - field != NULL && field->is_constant() && !mismatched) { + if (heap_base_oop != top() && field != NULL && field->is_constant() && !mismatched) { // final or stable field - const Type* con_type = Type::make_constant(alias_type->field(), heap_base_oop); - if (con_type != NULL) { - p = makecon(con_type); - } + p = make_constant_from_field(field, heap_base_oop); } if (p == NULL) { // To be valid, unsafe loads may depend on other conditions than diff --git a/hotspot/src/share/vm/opto/macro.cpp b/hotspot/src/share/vm/opto/macro.cpp index 06f443b3fe7..f67f8ca218d 100644 --- a/hotspot/src/share/vm/opto/macro.cpp +++ b/hotspot/src/share/vm/opto/macro.cpp @@ -860,7 +860,7 @@ bool PhaseMacroExpand::scalar_replacement(AllocateNode *alloc, GrowableArray is_loaded()) { field_type = TypeInstPtr::BOTTOM; - } else if (field != NULL && field->is_constant() && field->is_static()) { + } else if (field != NULL && field->is_static_constant()) { // This can happen if the constant oop is non-perm. ciObject* con = field->constant_value().as_object(); // Do not "join" in the previous type; it doesn't add value, diff --git a/hotspot/src/share/vm/opto/memnode.cpp b/hotspot/src/share/vm/opto/memnode.cpp index bfa80950912..ba8a24d16e4 100644 --- a/hotspot/src/share/vm/opto/memnode.cpp +++ b/hotspot/src/share/vm/opto/memnode.cpp @@ -796,7 +796,7 @@ Node *LoadNode::make(PhaseGVN& gvn, Node *ctl, Node *mem, Node *adr, const TypeP #endif { assert(!adr->bottom_type()->is_ptr_to_narrowoop() && !adr->bottom_type()->is_ptr_to_narrowklass(), "should have got back a narrow oop"); - load = new LoadPNode(ctl, mem, adr, adr_type, rt->is_oopptr(), mo, control_dependency); + load = new LoadPNode(ctl, mem, adr, adr_type, rt->is_ptr(), mo, control_dependency); } break; } @@ -1620,72 +1620,6 @@ LoadNode::load_array_final_field(const TypeKlassPtr *tkls, return NULL; } -static ciConstant check_mismatched_access(ciConstant con, BasicType loadbt, bool is_unsigned) { - BasicType conbt = con.basic_type(); - switch (conbt) { - case T_BOOLEAN: conbt = T_BYTE; break; - case T_ARRAY: conbt = T_OBJECT; break; - } - switch (loadbt) { - case T_BOOLEAN: loadbt = T_BYTE; break; - case T_NARROWOOP: loadbt = T_OBJECT; break; - case T_ARRAY: loadbt = T_OBJECT; break; - case T_ADDRESS: loadbt = T_OBJECT; break; - } - if (conbt == loadbt) { - if (is_unsigned && conbt == T_BYTE) { - // LoadB (T_BYTE) with a small mask (<=8-bit) is converted to LoadUB (T_BYTE). - return ciConstant(T_INT, con.as_int() & 0xFF); - } else { - return con; - } - } - if (conbt == T_SHORT && loadbt == T_CHAR) { - // LoadS (T_SHORT) with a small mask (<=16-bit) is converted to LoadUS (T_CHAR). - return ciConstant(T_INT, con.as_int() & 0xFFFF); - } - return ciConstant(); // T_ILLEGAL -} - -// Try to constant-fold a stable array element. -static const Type* fold_stable_ary_elem(const TypeAryPtr* ary, int off, bool is_unsigned_load, BasicType loadbt) { - assert(ary->const_oop(), "array should be constant"); - assert(ary->is_stable(), "array should be stable"); - - // Decode the results of GraphKit::array_element_address. - ciArray* aobj = ary->const_oop()->as_array(); - ciConstant element_value = aobj->element_value_by_offset(off); - if (element_value.basic_type() == T_ILLEGAL) { - return NULL; // wrong offset - } - ciConstant con = check_mismatched_access(element_value, loadbt, is_unsigned_load); - assert(con.basic_type() != T_ILLEGAL, "elembt=%s; loadbt=%s; unsigned=%d", - type2name(element_value.basic_type()), type2name(loadbt), is_unsigned_load); - - if (con.basic_type() != T_ILLEGAL && // not a mismatched access - !con.is_null_or_zero()) { // not a default value - const Type* con_type = Type::make_from_constant(con); - if (con_type != NULL) { - if (con_type->isa_aryptr()) { - // Join with the array element type, in case it is also stable. - int dim = ary->stable_dimension(); - con_type = con_type->is_aryptr()->cast_to_stable(true, dim-1); - } - if (loadbt == T_NARROWOOP && con_type->isa_oopptr()) { - con_type = con_type->make_narrowoop(); - } -#ifndef PRODUCT - if (TraceIterativeGVN) { - tty->print("FoldStableValues: array element [off=%d]: con_type=", off); - con_type->dump(); tty->cr(); - } -#endif //PRODUCT - return con_type; - } - } - return NULL; -} - //------------------------------Value----------------------------------------- const Type* LoadNode::Value(PhaseGVN* phase) const { // Either input is TOP ==> the result is TOP @@ -1714,10 +1648,14 @@ const Type* LoadNode::Value(PhaseGVN* phase) const { const bool off_beyond_header = ((uint)off >= (uint)min_base_off); // Try to constant-fold a stable array element. - if (FoldStableValues && !is_mismatched_access() && ary->is_stable() && ary->const_oop() != NULL) { + if (FoldStableValues && !is_mismatched_access() && ary->is_stable()) { // Make sure the reference is not into the header and the offset is constant - if (off_beyond_header && adr->is_AddP() && off != Type::OffsetBot) { - const Type* con_type = fold_stable_ary_elem(ary, off, is_unsigned(), memory_type()); + ciObject* aobj = ary->const_oop(); + if (aobj != NULL && off_beyond_header && adr->is_AddP() && off != Type::OffsetBot) { + int stable_dimension = (ary->stable_dimension() > 0 ? ary->stable_dimension() - 1 : 0); + const Type* con_type = Type::make_constant_from_array_element(aobj->as_array(), off, + stable_dimension, + memory_type(), is_unsigned()); if (con_type != NULL) { return con_type; } @@ -1784,28 +1722,10 @@ const Type* LoadNode::Value(PhaseGVN* phase) const { // For oop loads, we expect the _type to be precise. // Optimizations for constant objects ciObject* const_oop = tinst->const_oop(); - if (const_oop != NULL) { - // For constant CallSites treat the target field as a compile time constant. - if (const_oop->is_call_site()) { - ciCallSite* call_site = const_oop->as_call_site(); - ciField* field = call_site->klass()->as_instance_klass()->get_field_by_offset(off, /*is_static=*/ false); - if (field != NULL && field->is_call_site_target()) { - ciMethodHandle* target = call_site->get_target(); - if (target != NULL) { // just in case - ciConstant constant(T_OBJECT, target); - const Type* t; - if (adr->bottom_type()->is_ptr_to_narrowoop()) { - t = TypeNarrowOop::make_from_constant(constant.as_object(), true); - } else { - t = TypeOopPtr::make_from_constant(constant.as_object(), true); - } - // Add a dependence for invalidation of the optimization. - if (!call_site->is_constant_call_site()) { - C->dependencies()->assert_call_site_target_value(call_site, target); - } - return t; - } - } + if (const_oop != NULL && const_oop->is_instance()) { + const Type* con_type = Type::make_constant_from_field(const_oop->as_instance(), off, is_unsigned(), memory_type()); + if (con_type != NULL) { + return con_type; } } } else if (tp->base() == Type::KlassPtr) { diff --git a/hotspot/src/share/vm/opto/parse3.cpp b/hotspot/src/share/vm/opto/parse3.cpp index d9ad4ced928..bd6dcf30b84 100644 --- a/hotspot/src/share/vm/opto/parse3.cpp +++ b/hotspot/src/share/vm/opto/parse3.cpp @@ -149,9 +149,9 @@ void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) { // Does this field have a constant value? If so, just push the value. if (field->is_constant()) { // final or stable field - const Type* con_type = Type::make_constant(field, obj); - if (con_type != NULL) { - push_node(con_type->basic_type(), makecon(con_type)); + Node* con = make_constant_from_field(field, obj); + if (con != NULL) { + push_node(field->layout_type(), con); return; } } @@ -174,12 +174,16 @@ void Parse::do_get_xxx(Node* obj, ciField* field, bool is_field) { if (!field->type()->is_loaded()) { type = TypeInstPtr::BOTTOM; must_assert_null = true; - } else if (field->is_constant() && field->is_static()) { + } else if (field->is_static_constant()) { // This can happen if the constant oop is non-perm. ciObject* con = field->constant_value().as_object(); // Do not "join" in the previous type; it doesn't add value, // and may yield a vacuous result if the field is of interface type. - type = TypeOopPtr::make_from_constant(con)->isa_oopptr(); + if (con->is_null_object()) { + type = TypePtr::NULL_PTR; + } else { + type = TypeOopPtr::make_from_constant(con)->isa_oopptr(); + } assert(type != NULL, "field singleton type must be consistent"); } else { type = TypeOopPtr::make_from_klass(field_klass->as_klass()); diff --git a/hotspot/src/share/vm/opto/stringopts.cpp b/hotspot/src/share/vm/opto/stringopts.cpp index af5c5c4cfaa..4ec1419250b 100644 --- a/hotspot/src/share/vm/opto/stringopts.cpp +++ b/hotspot/src/share/vm/opto/stringopts.cpp @@ -1112,7 +1112,7 @@ Node* PhaseStringOpts::fetch_static_field(GraphKit& kit, ciField* field) { if( bt == T_OBJECT ) { if (!field->type()->is_loaded()) { type = TypeInstPtr::BOTTOM; - } else if (field->is_constant()) { + } else if (field->is_static_constant()) { // This can happen if the constant oop is non-perm. ciObject* con = field->constant_value().as_object(); // Do not "join" in the previous type; it doesn't add value, diff --git a/hotspot/src/share/vm/opto/type.cpp b/hotspot/src/share/vm/opto/type.cpp index 42b290bd29e..5462fe7d3f2 100644 --- a/hotspot/src/share/vm/opto/type.cpp +++ b/hotspot/src/share/vm/opto/type.cpp @@ -225,74 +225,156 @@ const Type* Type::get_typeflow_type(ciType* type) { //-----------------------make_from_constant------------------------------------ -const Type* Type::make_from_constant(ciConstant constant, bool require_constant) { +const Type* Type::make_from_constant(ciConstant constant, bool require_constant, + int stable_dimension, bool is_narrow_oop, + bool is_autobox_cache) { switch (constant.basic_type()) { - case T_BOOLEAN: return TypeInt::make(constant.as_boolean()); - case T_CHAR: return TypeInt::make(constant.as_char()); - case T_BYTE: return TypeInt::make(constant.as_byte()); - case T_SHORT: return TypeInt::make(constant.as_short()); - case T_INT: return TypeInt::make(constant.as_int()); - case T_LONG: return TypeLong::make(constant.as_long()); - case T_FLOAT: return TypeF::make(constant.as_float()); - case T_DOUBLE: return TypeD::make(constant.as_double()); - case T_ARRAY: - case T_OBJECT: - { - // cases: - // can_be_constant = (oop not scavengable || ScavengeRootsInCode != 0) - // should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2) - // An oop is not scavengable if it is in the perm gen. - ciObject* oop_constant = constant.as_object(); - if (oop_constant->is_null_object()) { - return Type::get_zero_type(T_OBJECT); - } else if (require_constant || oop_constant->should_be_constant()) { - return TypeOopPtr::make_from_constant(oop_constant, require_constant); + case T_BOOLEAN: return TypeInt::make(constant.as_boolean()); + case T_CHAR: return TypeInt::make(constant.as_char()); + case T_BYTE: return TypeInt::make(constant.as_byte()); + case T_SHORT: return TypeInt::make(constant.as_short()); + case T_INT: return TypeInt::make(constant.as_int()); + case T_LONG: return TypeLong::make(constant.as_long()); + case T_FLOAT: return TypeF::make(constant.as_float()); + case T_DOUBLE: return TypeD::make(constant.as_double()); + case T_ARRAY: + case T_OBJECT: { + // cases: + // can_be_constant = (oop not scavengable || ScavengeRootsInCode != 0) + // should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2) + // An oop is not scavengable if it is in the perm gen. + const Type* con_type = NULL; + ciObject* oop_constant = constant.as_object(); + if (oop_constant->is_null_object()) { + con_type = Type::get_zero_type(T_OBJECT); + } else if (require_constant || oop_constant->should_be_constant()) { + con_type = TypeOopPtr::make_from_constant(oop_constant, require_constant); + if (con_type != NULL) { + if (Compile::current()->eliminate_boxing() && is_autobox_cache) { + con_type = con_type->is_aryptr()->cast_to_autobox_cache(true); + } + if (stable_dimension > 0) { + assert(FoldStableValues, "sanity"); + assert(!con_type->is_zero_type(), "default value for stable field"); + con_type = con_type->is_aryptr()->cast_to_stable(true, stable_dimension); + } + } + } + if (is_narrow_oop) { + con_type = con_type->make_narrowoop(); + } + return con_type; } - } - case T_ILLEGAL: - // Invalid ciConstant returned due to OutOfMemoryError in the CI - assert(Compile::current()->env()->failing(), "otherwise should not see this"); - return NULL; + case T_ILLEGAL: + // Invalid ciConstant returned due to OutOfMemoryError in the CI + assert(Compile::current()->env()->failing(), "otherwise should not see this"); + return NULL; } // Fall through to failure return NULL; } +static ciConstant check_mismatched_access(ciConstant con, BasicType loadbt, bool is_unsigned) { + BasicType conbt = con.basic_type(); + switch (conbt) { + case T_BOOLEAN: conbt = T_BYTE; break; + case T_ARRAY: conbt = T_OBJECT; break; + } + switch (loadbt) { + case T_BOOLEAN: loadbt = T_BYTE; break; + case T_NARROWOOP: loadbt = T_OBJECT; break; + case T_ARRAY: loadbt = T_OBJECT; break; + case T_ADDRESS: loadbt = T_OBJECT; break; + } + if (conbt == loadbt) { + if (is_unsigned && conbt == T_BYTE) { + // LoadB (T_BYTE) with a small mask (<=8-bit) is converted to LoadUB (T_BYTE). + return ciConstant(T_INT, con.as_int() & 0xFF); + } else { + return con; + } + } + if (conbt == T_SHORT && loadbt == T_CHAR) { + // LoadS (T_SHORT) with a small mask (<=16-bit) is converted to LoadUS (T_CHAR). + return ciConstant(T_INT, con.as_int() & 0xFFFF); + } + return ciConstant(); // T_ILLEGAL +} + +// Try to constant-fold a stable array element. +const Type* Type::make_constant_from_array_element(ciArray* array, int off, int stable_dimension, + BasicType loadbt, bool is_unsigned_load) { + // Decode the results of GraphKit::array_element_address. + ciConstant element_value = array->element_value_by_offset(off); + if (element_value.basic_type() == T_ILLEGAL) { + return NULL; // wrong offset + } + ciConstant con = check_mismatched_access(element_value, loadbt, is_unsigned_load); + + assert(con.basic_type() != T_ILLEGAL, "elembt=%s; loadbt=%s; unsigned=%d", + type2name(element_value.basic_type()), type2name(loadbt), is_unsigned_load); + + if (con.is_valid() && // not a mismatched access + !con.is_null_or_zero()) { // not a default value + bool is_narrow_oop = (loadbt == T_NARROWOOP); + return Type::make_from_constant(con, /*require_constant=*/true, stable_dimension, is_narrow_oop, /*is_autobox_cache=*/false); + } + return NULL; +} -const Type* Type::make_constant(ciField* field, Node* obj) { - if (!field->is_constant()) return NULL; +const Type* Type::make_constant_from_field(ciInstance* holder, int off, bool is_unsigned_load, BasicType loadbt) { + ciField* field; + ciType* type = holder->java_mirror_type(); + if (type != NULL && type->is_instance_klass() && off >= InstanceMirrorKlass::offset_of_static_fields()) { + // Static field + field = type->as_instance_klass()->get_field_by_offset(off, /*is_static=*/true); + } else { + // Instance field + field = holder->klass()->as_instance_klass()->get_field_by_offset(off, /*is_static=*/false); + } + if (field == NULL) { + return NULL; // Wrong offset + } + return Type::make_constant_from_field(field, holder, loadbt, is_unsigned_load); +} - const Type* con_type = NULL; +const Type* Type::make_constant_from_field(ciField* field, ciInstance* holder, + BasicType loadbt, bool is_unsigned_load) { + if (!field->is_constant()) { + return NULL; // Non-constant field + } + ciConstant field_value; if (field->is_static()) { // final static field - con_type = Type::make_from_constant(field->constant_value(), /*require_const=*/true); - if (Compile::current()->eliminate_boxing() && field->is_autobox_cache() && con_type != NULL) { - con_type = con_type->is_aryptr()->cast_to_autobox_cache(true); - } - } else { + field_value = field->constant_value(); + } else if (holder != NULL) { // final or stable non-static field // Treat final non-static fields of trusted classes (classes in // java.lang.invoke and sun.invoke packages and subpackages) as // compile time constants. - if (obj->is_Con()) { - const TypeOopPtr* oop_ptr = obj->bottom_type()->isa_oopptr(); - ciObject* constant_oop = oop_ptr->const_oop(); - ciConstant constant = field->constant_value_of(constant_oop); - con_type = Type::make_from_constant(constant, /*require_const=*/true); - } + field_value = field->constant_value_of(holder); } - if (FoldStableValues && field->is_stable() && con_type != NULL) { - if (con_type->is_zero_type()) { - return NULL; // the field hasn't been initialized yet - } else if (con_type->isa_oopptr()) { - const Type* stable_type = Type::get_const_type(field->type()); - if (field->type()->is_array_klass()) { - int stable_dimension = field->type()->as_array_klass()->dimension(); - stable_type = stable_type->is_aryptr()->cast_to_stable(true, stable_dimension); - } - if (stable_type != NULL) { - con_type = con_type->join_speculative(stable_type); - } + if (!field_value.is_valid()) { + return NULL; // Not a constant + } + + ciConstant con = check_mismatched_access(field_value, loadbt, is_unsigned_load); + + assert(con.is_valid(), "elembt=%s; loadbt=%s; unsigned=%d", + type2name(field_value.basic_type()), type2name(loadbt), is_unsigned_load); + + bool is_stable_array = FoldStableValues && field->is_stable() && field->type()->is_array_klass(); + int stable_dimension = (is_stable_array ? field->type()->as_array_klass()->dimension() : 0); + bool is_narrow_oop = (loadbt == T_NARROWOOP); + + const Type* con_type = make_from_constant(con, /*require_constant=*/ true, + stable_dimension, is_narrow_oop, + field->is_autobox_cache()); + if (con_type != NULL && field->is_call_site_target()) { + ciCallSite* call_site = holder->as_call_site(); + if (!call_site->is_constant_call_site()) { + ciMethodHandle* target = call_site->get_target(); + Compile::current()->dependencies()->assert_call_site_target_value(call_site, target); } } return con_type; diff --git a/hotspot/src/share/vm/opto/type.hpp b/hotspot/src/share/vm/opto/type.hpp index 6636af716b4..4c79e900bf2 100644 --- a/hotspot/src/share/vm/opto/type.hpp +++ b/hotspot/src/share/vm/opto/type.hpp @@ -417,9 +417,26 @@ public: static const Type* get_typeflow_type(ciType* type); static const Type* make_from_constant(ciConstant constant, - bool require_constant = false); - - static const Type* make_constant(ciField* field, Node* obj); + bool require_constant = false, + int stable_dimension = 0, + bool is_narrow = false, + bool is_autobox_cache = false); + + static const Type* make_constant_from_field(ciInstance* holder, + int off, + bool is_unsigned_load, + BasicType loadbt); + + static const Type* make_constant_from_field(ciField* field, + ciInstance* holder, + BasicType loadbt, + bool is_unsigned_load); + + static const Type* make_constant_from_array_element(ciArray* array, + int off, + int stable_dimension, + BasicType loadbt, + bool is_unsigned_load); // Speculative type helper methods. See TypePtr. virtual const TypePtr* speculative() const { return NULL; } diff --git a/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java b/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java index fead52fd530..445f1391731 100644 --- a/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java +++ b/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java @@ -33,6 +33,7 @@ * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.vm.annotation * java.base/jdk.internal.misc + * * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions * -Xbatch -XX:-TieredCompilation * -XX:+FoldStableValues @@ -63,7 +64,6 @@ import jdk.test.lib.Platform; import jdk.internal.misc.Unsafe; import java.io.IOException; -import java.lang.reflect.Field; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; diff --git a/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java b/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java index 08bdb491466..8a47786703e 100644 --- a/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java +++ b/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java @@ -26,24 +26,28 @@ /* * @test * @summary tests on constant folding of unsafe get operations from stable arrays - * @library /testlibrary /test/lib - * @ignore 8151137 + * @library /testlibrary * * @requires vm.flavor != "client" * + * @modules java.base/jdk.internal.vm.annotation + * java.base/jdk.internal.misc + * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions * -Xbatch -XX:-TieredCompilation * -XX:+FoldStableValues * -XX:CompileCommand=dontinline,*Test::test* - * UnsafeGetStableArrayElement + * compiler.unsafe.UnsafeGetStableArrayElement */ +package compiler.unsafe; + import jdk.internal.misc.Unsafe; import jdk.internal.vm.annotation.Stable; import java.util.concurrent.Callable; +import jdk.test.lib.Platform; import static jdk.internal.misc.Unsafe.*; import static jdk.test.lib.Asserts.*; -import static jdk.test.lib.Platform; public class UnsafeGetStableArrayElement { @Stable static final boolean[] STABLE_BOOLEAN_ARRAY = new boolean[16]; @@ -219,13 +223,7 @@ public class UnsafeGetStableArrayElement { Setter.reset(); } - public static void main(String[] args) throws Exception { - if (Platform.isServer()) { - test(); - } - } - - static void test() throws Exception { + static void testUnsafeAccess() throws Exception { // boolean[], aligned accesses testMatched( Test::testZ_Z, Test::changeZ); testMismatched(Test::testZ_B, Test::changeZ); @@ -329,4 +327,11 @@ public class UnsafeGetStableArrayElement { run(Test::testL_I); run(Test::testL_F); } + + public static void main(String[] args) throws Exception { + if (Platform.isServer()) { + testUnsafeAccess(); + } + System.out.println("TEST PASSED"); + } } -- GitLab From 6b6686bd43ca03e0c3e830617519362fde13a7bc Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Wed, 6 Apr 2016 18:51:03 +0300 Subject: [PATCH 129/400] 8149374: Replace C1-specific collection classes with universal collection classes Reviewed-by: kvn, mgerdin, coleenp --- .../aarch64/vm/c1_LIRGenerator_aarch64.cpp | 4 +- .../src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp | 4 +- .../cpu/sparc/vm/c1_LIRGenerator_sparc.cpp | 4 +- hotspot/src/cpu/x86/vm/c1_FpuStackSim_x86.cpp | 10 +- .../src/cpu/x86/vm/c1_LIRGenerator_x86.cpp | 4 +- hotspot/src/share/vm/c1/c1_CodeStubs.hpp | 12 +- hotspot/src/share/vm/c1/c1_Compilation.hpp | 11 +- hotspot/src/share/vm/c1/c1_FrameMap.cpp | 4 +- hotspot/src/share/vm/c1/c1_FrameMap.hpp | 4 +- hotspot/src/share/vm/c1/c1_GraphBuilder.cpp | 18 +- hotspot/src/share/vm/c1/c1_IR.cpp | 23 +- hotspot/src/share/vm/c1/c1_IR.hpp | 9 +- hotspot/src/share/vm/c1/c1_Instruction.cpp | 14 +- hotspot/src/share/vm/c1/c1_Instruction.hpp | 27 +- hotspot/src/share/vm/c1/c1_LIR.hpp | 16 +- hotspot/src/share/vm/c1/c1_LIRAssembler.cpp | 4 +- hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 6 +- hotspot/src/share/vm/c1/c1_LIRGenerator.hpp | 16 +- hotspot/src/share/vm/c1/c1_LinearScan.cpp | 31 +- hotspot/src/share/vm/c1/c1_LinearScan.hpp | 20 +- hotspot/src/share/vm/c1/c1_Optimizer.cpp | 26 +- .../share/vm/c1/c1_RangeCheckElimination.cpp | 60 ++-- .../share/vm/c1/c1_RangeCheckElimination.hpp | 21 +- hotspot/src/share/vm/c1/c1_ValueMap.cpp | 10 +- hotspot/src/share/vm/c1/c1_ValueMap.hpp | 9 +- hotspot/src/share/vm/c1/c1_ValueStack.cpp | 8 +- .../share/vm/classfile/classFileParser.cpp | 2 +- .../share/vm/classfile/classFileParser.hpp | 3 +- .../src/share/vm/gc/cms/parNewGeneration.cpp | 37 +-- hotspot/src/share/vm/interpreter/rewriter.cpp | 24 +- hotspot/src/share/vm/interpreter/rewriter.hpp | 61 ++-- hotspot/src/share/vm/oops/cpCache.cpp | 8 +- .../vm/prims/jvmtiClassFileReconstituter.cpp | 4 +- .../share/vm/prims/jvmtiRedefineClasses.cpp | 6 +- hotspot/src/share/vm/utilities/array.cpp | 90 ------ hotspot/src/share/vm/utilities/array.hpp | 272 +----------------- .../src/share/vm/utilities/growableArray.hpp | 22 ++ 37 files changed, 269 insertions(+), 635 deletions(-) delete mode 100644 hotspot/src/share/vm/utilities/array.cpp diff --git a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp index 191c4e45571..5d47ae7a9b7 100644 --- a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -1127,7 +1127,7 @@ void LIRGenerator::do_NewObjectArray(NewObjectArray* x) { void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { Values* dims = x->dims(); int i = dims->length(); - LIRItemList* items = new LIRItemList(dims->length(), NULL); + LIRItemList* items = new LIRItemList(i, i, NULL); while (i-- > 0) { LIRItem* size = new LIRItem(dims->at(i), this); items->at_put(i, size); diff --git a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp index cba04106f8c..d8f51ff9cf2 100644 --- a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -1055,7 +1055,7 @@ void LIRGenerator::do_NewObjectArray(NewObjectArray* x) { void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { Values* dims = x->dims(); int i = dims->length(); - LIRItemList* items = new LIRItemList(dims->length(), NULL); + LIRItemList* items = new LIRItemList(i, i, NULL); while (i-- > 0) { LIRItem* size = new LIRItem(dims->at(i), this); items->at_put(i, size); diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp index 6185a1d59cd..f81a79a664a 100644 --- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1033,7 +1033,7 @@ void LIRGenerator::do_NewObjectArray(NewObjectArray* x) { void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { Values* dims = x->dims(); int i = dims->length(); - LIRItemList* items = new LIRItemList(dims->length(), NULL); + LIRItemList* items = new LIRItemList(i, i, NULL); while (i-- > 0) { LIRItem* size = new LIRItem(dims->at(i), this); items->at_put(i, size); diff --git a/hotspot/src/cpu/x86/vm/c1_FpuStackSim_x86.cpp b/hotspot/src/cpu/x86/vm/c1_FpuStackSim_x86.cpp index 3fbd57c5ca3..6d91d1948e9 100644 --- a/hotspot/src/cpu/x86/vm/c1_FpuStackSim_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_FpuStackSim_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -169,18 +169,18 @@ void FpuStackSim::clear() { intArray* FpuStackSim::write_state() { intArray* res = new intArray(1 + FrameMap::nof_fpu_regs); - (*res)[0] = stack_size(); + res->append(stack_size()); for (int i = 0; i < FrameMap::nof_fpu_regs; i++) { - (*res)[1 + i] = regs_at(i); + res->append(regs_at(i)); } return res; } void FpuStackSim::read_state(intArray* fpu_stack_state) { - _stack_size = (*fpu_stack_state)[0]; + _stack_size = fpu_stack_state->at(0); for (int i = 0; i < FrameMap::nof_fpu_regs; i++) { - set_regs_at(i, (*fpu_stack_state)[1 + i]); + set_regs_at(i, fpu_stack_state->at(1 + i)); } } diff --git a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp index 149b129d257..eaebe505fb0 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1260,7 +1260,7 @@ void LIRGenerator::do_NewObjectArray(NewObjectArray* x) { void LIRGenerator::do_NewMultiArray(NewMultiArray* x) { Values* dims = x->dims(); int i = dims->length(); - LIRItemList* items = new LIRItemList(dims->length(), NULL); + LIRItemList* items = new LIRItemList(i, i, NULL); while (i-- > 0) { LIRItem* size = new LIRItem(dims->at(i), this); items->at_put(i, size); diff --git a/hotspot/src/share/vm/c1/c1_CodeStubs.hpp b/hotspot/src/share/vm/c1/c1_CodeStubs.hpp index 05a8c70506f..457c9cc14eb 100644 --- a/hotspot/src/share/vm/c1/c1_CodeStubs.hpp +++ b/hotspot/src/share/vm/c1/c1_CodeStubs.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,17 +77,13 @@ class CodeStub: public CompilationResourceObj { } }; - -define_array(CodeStubArray, CodeStub*) -define_stack(_CodeStubList, CodeStubArray) - -class CodeStubList: public _CodeStubList { +class CodeStubList: public GrowableArray { public: - CodeStubList(): _CodeStubList() {} + CodeStubList(): GrowableArray() {} void append(CodeStub* stub) { if (!contains(stub)) { - _CodeStubList::append(stub); + GrowableArray::append(stub); } } }; diff --git a/hotspot/src/share/vm/c1/c1_Compilation.hpp b/hotspot/src/share/vm/c1/c1_Compilation.hpp index 3bc07da9f7d..a60d1fd62a3 100644 --- a/hotspot/src/share/vm/c1/c1_Compilation.hpp +++ b/hotspot/src/share/vm/c1/c1_Compilation.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,12 +53,9 @@ class C1_MacroAssembler; class CFGPrinter; typedef LIR_OprDesc* LIR_Opr; - -define_array(BasicTypeArray, BasicType) -define_stack(BasicTypeList, BasicTypeArray) - -define_array(ExceptionInfoArray, ExceptionInfo*) -define_stack(ExceptionInfoList, ExceptionInfoArray) +typedef GrowableArray BasicTypeArray; +typedef GrowableArray BasicTypeList; +typedef GrowableArray ExceptionInfoList; class Compilation: public StackObj { friend class CompilationResourceObj; diff --git a/hotspot/src/share/vm/c1/c1_FrameMap.cpp b/hotspot/src/share/vm/c1/c1_FrameMap.cpp index a164d8ccb00..d9e5acbfe2c 100644 --- a/hotspot/src/share/vm/c1/c1_FrameMap.cpp +++ b/hotspot/src/share/vm/c1/c1_FrameMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -164,7 +164,7 @@ FrameMap::FrameMap(ciMethod* method, int monitors, int reserved_argument_area_si _reserved_argument_area_size = MAX2(4, reserved_argument_area_size) * BytesPerWord; _argcount = method->arg_size(); - _argument_locations = new intArray(_argcount, -1); + _argument_locations = new intArray(_argcount, _argcount, -1); _incoming_arguments = java_calling_convention(signature_type_array_for(method), false); _oop_map_arg_count = _incoming_arguments->reserved_stack_slots(); diff --git a/hotspot/src/share/vm/c1/c1_FrameMap.hpp b/hotspot/src/share/vm/c1/c1_FrameMap.hpp index d5d12ed36c3..5e29ca33aec 100644 --- a/hotspot/src/share/vm/c1/c1_FrameMap.hpp +++ b/hotspot/src/share/vm/c1/c1_FrameMap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,8 +36,6 @@ class ciMethod; class CallingConvention; -class BasicTypeArray; -class BasicTypeList; //-------------------------------------------------------- // FrameMap diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index 26c2fd33cff..bfd398a95bb 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -356,7 +356,7 @@ void BlockListBuilder::mark_loops() { _active = BitMap(BlockBegin::number_of_blocks()); _active.clear(); _visited = BitMap(BlockBegin::number_of_blocks()); _visited.clear(); - _loop_map = intArray(BlockBegin::number_of_blocks(), 0); + _loop_map = intArray(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), 0); _next_loop_index = 0; _next_block_number = _blocks.length(); @@ -1353,7 +1353,7 @@ void GraphBuilder::lookup_switch() { } else { // collect successors & keys BlockList* sux = new BlockList(l + 1, NULL); - intArray* keys = new intArray(l, 0); + intArray* keys = new intArray(l, l, 0); int i; bool has_bb = false; for (i = 0; i < l; i++) { @@ -1709,7 +1709,7 @@ void GraphBuilder::check_args_for_profiling(Values* obj_args, int expected) { bool ignored_will_link; ciSignature* declared_signature = NULL; ciMethod* real_target = method()->get_method_at_bci(bci(), ignored_will_link, &declared_signature); - assert(expected == obj_args->length() || real_target->is_method_handle_intrinsic(), "missed on arg?"); + assert(expected == obj_args->max_length() || real_target->is_method_handle_intrinsic(), "missed on arg?"); #endif } @@ -1720,7 +1720,7 @@ Values* GraphBuilder::collect_args_for_profiling(Values* args, ciMethod* target, if (obj_args == NULL) { return NULL; } - int s = obj_args->size(); + int s = obj_args->max_length(); // if called through method handle invoke, some arguments may have been popped for (int i = start, j = 0; j < s && i < args->length(); i++) { if (args->at(i)->type()->is_object_kind()) { @@ -2157,7 +2157,7 @@ void GraphBuilder::new_multi_array(int dimensions) { ciKlass* klass = stream()->get_klass(will_link); ValueStack* state_before = !klass->is_loaded() || PatchALot ? copy_state_before() : copy_state_exhandling(); - Values* dims = new Values(dimensions, NULL); + Values* dims = new Values(dimensions, dimensions, NULL); // fill in all dimensions int i = dimensions; while (i-- > 0) dims->at_put(i, ipop()); @@ -3760,9 +3760,9 @@ bool GraphBuilder::try_inline_full(ciMethod* callee, bool holder_known, Bytecode int start = 0; Values* obj_args = args_list_for_profiling(callee, start, has_receiver); if (obj_args != NULL) { - int s = obj_args->size(); + int s = obj_args->max_length(); // if called through method handle invoke, some arguments may have been popped - for (int i = args_base+start, j = 0; j < obj_args->size() && i < state()->stack_size(); ) { + for (int i = args_base+start, j = 0; j < obj_args->max_length() && i < state()->stack_size(); ) { Value v = state()->stack_at_inc(i); if (v->type()->is_object_kind()) { obj_args->push(v); @@ -4079,7 +4079,7 @@ void GraphBuilder::push_scope_for_jsr(BlockBegin* jsr_continuation, int jsr_dest // properly clone all blocks in jsr region as well as exception // handlers containing rets BlockList* new_bci2block = new BlockList(bci2block()->length()); - new_bci2block->push_all(bci2block()); + new_bci2block->appendAll(bci2block()); data->set_bci2block(new_bci2block); data->set_scope(scope()); data->setup_jsr_xhandlers(); diff --git a/hotspot/src/share/vm/c1/c1_IR.cpp b/hotspot/src/share/vm/c1/c1_IR.cpp index 105d27fcc0c..3afc9759fdf 100644 --- a/hotspot/src/share/vm/c1/c1_IR.cpp +++ b/hotspot/src/share/vm/c1/c1_IR.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -530,7 +530,7 @@ ComputeLinearScanOrder::ComputeLinearScanOrder(Compilation* c, BlockBegin* start _visited_blocks(_max_block_id), _active_blocks(_max_block_id), _dominator_blocks(_max_block_id), - _forward_branches(_max_block_id, 0), + _forward_branches(_max_block_id, _max_block_id, 0), _loop_end_blocks(8), _work_list(8), _linear_scan_order(NULL), // initialized later with correct size @@ -848,13 +848,13 @@ bool ComputeLinearScanOrder::ready_for_processing(BlockBegin* cur) { return false; } - assert(_linear_scan_order->index_of(cur) == -1, "block already processed (block can be ready only once)"); - assert(_work_list.index_of(cur) == -1, "block already in work-list (block can be ready only once)"); + assert(_linear_scan_order->find(cur) == -1, "block already processed (block can be ready only once)"); + assert(_work_list.find(cur) == -1, "block already in work-list (block can be ready only once)"); return true; } void ComputeLinearScanOrder::sort_into_work_list(BlockBegin* cur) { - assert(_work_list.index_of(cur) == -1, "block already in work list"); + assert(_work_list.find(cur) == -1, "block already in work list"); int cur_weight = compute_weight(cur); @@ -890,7 +890,7 @@ void ComputeLinearScanOrder::sort_into_work_list(BlockBegin* cur) { void ComputeLinearScanOrder::append_block(BlockBegin* cur) { TRACE_LINEAR_SCAN(3, tty->print_cr("appending block B%d (weight 0x%6x) to linear-scan order", cur->block_id(), cur->linear_scan_number())); - assert(_linear_scan_order->index_of(cur) == -1, "cannot add the same block twice"); + assert(_linear_scan_order->find(cur) == -1, "cannot add the same block twice"); // currently, the linear scan order and code emit order are equal. // therefore the linear_scan_number and the weight of a block must also @@ -1115,13 +1115,13 @@ void ComputeLinearScanOrder::verify() { BlockBegin* cur = _linear_scan_order->at(i); assert(cur->linear_scan_number() == i, "incorrect linear_scan_number"); - assert(cur->linear_scan_number() >= 0 && cur->linear_scan_number() == _linear_scan_order->index_of(cur), "incorrect linear_scan_number"); + assert(cur->linear_scan_number() >= 0 && cur->linear_scan_number() == _linear_scan_order->find(cur), "incorrect linear_scan_number"); int j; for (j = cur->number_of_sux() - 1; j >= 0; j--) { BlockBegin* sux = cur->sux_at(j); - assert(sux->linear_scan_number() >= 0 && sux->linear_scan_number() == _linear_scan_order->index_of(sux), "incorrect linear_scan_number"); + assert(sux->linear_scan_number() >= 0 && sux->linear_scan_number() == _linear_scan_order->find(sux), "incorrect linear_scan_number"); if (!sux->is_set(BlockBegin::backward_branch_target_flag)) { assert(cur->linear_scan_number() < sux->linear_scan_number(), "invalid order"); } @@ -1133,7 +1133,7 @@ void ComputeLinearScanOrder::verify() { for (j = cur->number_of_preds() - 1; j >= 0; j--) { BlockBegin* pred = cur->pred_at(j); - assert(pred->linear_scan_number() >= 0 && pred->linear_scan_number() == _linear_scan_order->index_of(pred), "incorrect linear_scan_number"); + assert(pred->linear_scan_number() >= 0 && pred->linear_scan_number() == _linear_scan_order->find(pred), "incorrect linear_scan_number"); if (!cur->is_set(BlockBegin::backward_branch_target_flag)) { assert(cur->linear_scan_number() > pred->linear_scan_number(), "invalid order"); } @@ -1255,8 +1255,7 @@ void IR::print(bool cfg_only, bool live_only) { } -define_array(BlockListArray, BlockList*) -define_stack(BlockListList, BlockListArray) +typedef GrowableArray BlockListList; class PredecessorValidator : public BlockClosure { private: @@ -1270,7 +1269,7 @@ class PredecessorValidator : public BlockClosure { public: PredecessorValidator(IR* hir) { ResourceMark rm; - _predecessors = new BlockListList(BlockBegin::number_of_blocks(), NULL); + _predecessors = new BlockListList(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), NULL); _blocks = new BlockList(); int i; diff --git a/hotspot/src/share/vm/c1/c1_IR.hpp b/hotspot/src/share/vm/c1/c1_IR.hpp index 31d3b01aff2..9a2bff70a62 100644 --- a/hotspot/src/share/vm/c1/c1_IR.hpp +++ b/hotspot/src/share/vm/c1/c1_IR.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -104,9 +104,7 @@ class XHandler: public CompilationResourceObj { bool equals(XHandler* other) const; }; -define_array(_XHandlerArray, XHandler*) -define_stack(_XHandlerList, _XHandlerArray) - +typedef GrowableArray _XHandlerList; // XHandlers is the C1 internal list of exception handlers for a method class XHandlers: public CompilationResourceObj { @@ -132,8 +130,7 @@ class XHandlers: public CompilationResourceObj { class IRScope; -define_array(IRScopeArray, IRScope*) -define_stack(IRScopeList, IRScopeArray) +typedef GrowableArray IRScopeList; class Compilation; class IRScope: public CompilationResourceObj { diff --git a/hotspot/src/share/vm/c1/c1_Instruction.cpp b/hotspot/src/share/vm/c1/c1_Instruction.cpp index a77b22ff14c..1be6266bebf 100644 --- a/hotspot/src/share/vm/c1/c1_Instruction.cpp +++ b/hotspot/src/share/vm/c1/c1_Instruction.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -564,7 +564,7 @@ void BlockBegin::disconnect_edge(BlockBegin* from, BlockBegin* to) { for (int s = 0; s < from->number_of_sux();) { BlockBegin* sux = from->sux_at(s); if (sux == to) { - int index = sux->_predecessors.index_of(from); + int index = sux->_predecessors.find(from); if (index >= 0) { sux->_predecessors.remove_at(index); } @@ -664,7 +664,7 @@ BlockBegin* BlockBegin::insert_block_between(BlockBegin* sux) { void BlockBegin::remove_successor(BlockBegin* pred) { int idx; - while ((idx = _successors.index_of(pred)) >= 0) { + while ((idx = _successors.find(pred)) >= 0) { _successors.remove_at(idx); } } @@ -677,7 +677,7 @@ void BlockBegin::add_predecessor(BlockBegin* pred) { void BlockBegin::remove_predecessor(BlockBegin* pred) { int idx; - while ((idx = _predecessors.index_of(pred)) >= 0) { + while ((idx = _predecessors.find(pred)) >= 0) { _predecessors.remove_at(idx); } } @@ -722,13 +722,15 @@ void BlockBegin::iterate_postorder(boolArray& mark, BlockClosure* closure) { void BlockBegin::iterate_preorder(BlockClosure* closure) { - boolArray mark(number_of_blocks(), false); + int mark_len = number_of_blocks(); + boolArray mark(mark_len, mark_len, false); iterate_preorder(mark, closure); } void BlockBegin::iterate_postorder(BlockClosure* closure) { - boolArray mark(number_of_blocks(), false); + int mark_len = number_of_blocks(); + boolArray mark(mark_len, mark_len, false); iterate_postorder(mark, closure); } diff --git a/hotspot/src/share/vm/c1/c1_Instruction.hpp b/hotspot/src/share/vm/c1/c1_Instruction.hpp index 8f6bf233f3d..b6e9610b51d 100644 --- a/hotspot/src/share/vm/c1/c1_Instruction.hpp +++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -115,11 +115,8 @@ class Assert; // A Value is a reference to the instruction creating the value typedef Instruction* Value; -define_array(ValueArray, Value) -define_stack(Values, ValueArray) - -define_array(ValueStackArray, ValueStack*) -define_stack(ValueStackStack, ValueStackArray) +typedef GrowableArray Values; +typedef GrowableArray ValueStackStack; // BlockClosure is the base class for block traversal/iteration. @@ -137,14 +134,13 @@ class ValueVisitor: public StackObj { // Some array and list classes -define_array(BlockBeginArray, BlockBegin*) -define_stack(_BlockList, BlockBeginArray) +typedef GrowableArray BlockBeginArray; -class BlockList: public _BlockList { +class BlockList: public GrowableArray { public: - BlockList(): _BlockList() {} - BlockList(const int size): _BlockList(size) {} - BlockList(const int size, BlockBegin* init): _BlockList(size, init) {} + BlockList(): GrowableArray() {} + BlockList(const int size): GrowableArray(size) {} + BlockList(const int size, BlockBegin* init): GrowableArray(size, size, init) {} void iterate_forward(BlockClosure* closure); void iterate_backward(BlockClosure* closure); @@ -1744,7 +1740,7 @@ LEAF(BlockBegin, StateSplit) void remove_predecessor(BlockBegin* pred); bool is_predecessor(BlockBegin* pred) const { return _predecessors.contains(pred); } int number_of_preds() const { return _predecessors.length(); } - BlockBegin* pred_at(int i) const { return _predecessors[i]; } + BlockBegin* pred_at(int i) const { return _predecessors.at(i); } // exception handlers potentially invoked by this block void add_exception_handler(BlockBegin* b); @@ -2609,10 +2605,7 @@ class BlockPair: public CompilationResourceObj { void set_from(BlockBegin* b) { _from = b; } }; - -define_array(BlockPairArray, BlockPair*) -define_stack(BlockPairList, BlockPairArray) - +typedef GrowableArray BlockPairList; inline int BlockBegin::number_of_sux() const { assert(_end == NULL || _end->number_of_sux() == _successors.length(), "mismatch"); return _successors.length(); } inline BlockBegin* BlockBegin::sux_at(int i) const { assert(_end == NULL || _end->sux_at(i) == _successors.at(i), "mismatch"); return _successors.at(i); } diff --git a/hotspot/src/share/vm/c1/c1_LIR.hpp b/hotspot/src/share/vm/c1/c1_LIR.hpp index a96c1a43242..2943b380901 100644 --- a/hotspot/src/share/vm/c1/c1_LIR.hpp +++ b/hotspot/src/share/vm/c1/c1_LIR.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,17 +59,9 @@ class LIR_OprVisitor; typedef LIR_OprDesc* LIR_Opr; typedef int RegNr; -define_array(LIR_OprArray, LIR_Opr) -define_stack(LIR_OprList, LIR_OprArray) - -define_array(LIR_OprRefArray, LIR_Opr*) -define_stack(LIR_OprRefList, LIR_OprRefArray) - -define_array(CodeEmitInfoArray, CodeEmitInfo*) -define_stack(CodeEmitInfoList, CodeEmitInfoArray) - -define_array(LIR_OpArray, LIR_Op*) -define_stack(LIR_OpList, LIR_OpArray) +typedef GrowableArray LIR_OprList; +typedef GrowableArray LIR_OpArray; +typedef GrowableArray LIR_OpList; // define LIR_OprPtr early so LIR_OprDesc can refer to it class LIR_OprPtr: public CompilationResourceObj { diff --git a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp index 553fc4b2b8b..abd1fb4d3e7 100644 --- a/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRAssembler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -127,7 +127,7 @@ void LIR_Assembler::append_code_stub(CodeStub* stub) { void LIR_Assembler::emit_stubs(CodeStubList* stub_list) { for (int m = 0; m < stub_list->length(); m++) { - CodeStub* s = (*stub_list)[m]; + CodeStub* s = stub_list->at(m); check_codespace(); CHECK_BAILOUT(); diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index c5f4d307784..eb90875a038 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -150,7 +150,7 @@ PhiResolver::~PhiResolver() { int i; // resolve any cycles in moves from and to virtual registers for (i = virtual_operands().length() - 1; i >= 0; i --) { - ResolveNode* node = virtual_operands()[i]; + ResolveNode* node = virtual_operands().at(i); if (!node->visited()) { _loop = NULL; move(NULL, node); @@ -161,7 +161,7 @@ PhiResolver::~PhiResolver() { // generate move for move from non virtual register to abitrary destination for (i = other_operands().length() - 1; i >= 0; i --) { - ResolveNode* node = other_operands()[i]; + ResolveNode* node = other_operands().at(i); for (int j = node->no_of_destinations() - 1; j >= 0; j --) { emit_move(node->operand(), node->destination_at(j)->operand()); } @@ -177,7 +177,7 @@ ResolveNode* PhiResolver::create_node(LIR_Opr opr, bool source) { assert(node == NULL || node->operand() == opr, ""); if (node == NULL) { node = new ResolveNode(opr); - vreg_table()[vreg_num] = node; + vreg_table().at_put(vreg_num, node); } // Make sure that all virtual operands show up in the list when // they are used as the source of a move. diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp index bf36d7dc10e..aae7ade53b1 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,7 @@ class Invoke; class SwitchRange; class LIRItem; -define_array(LIRItemArray, LIRItem*) -define_stack(LIRItemList, LIRItemArray) +typedef GrowableArray LIRItemList; class SwitchRange: public CompilationResourceObj { private: @@ -56,15 +55,12 @@ class SwitchRange: public CompilationResourceObj { BlockBegin* sux() const { return _sux; } }; -define_array(SwitchRangeArray, SwitchRange*) -define_stack(SwitchRangeList, SwitchRangeArray) - +typedef GrowableArray SwitchRangeArray; +typedef GrowableArray SwitchRangeList; class ResolveNode; -define_array(NodeArray, ResolveNode*); -define_stack(NodeList, NodeArray); - +typedef GrowableArray NodeList; // Node objects form a directed graph of LIR_Opr // Edges between Nodes represent moves from one Node to its destinations @@ -86,7 +82,7 @@ class ResolveNode: public CompilationResourceObj { // accessors LIR_Opr operand() const { return _operand; } int no_of_destinations() const { return _destinations.length(); } - ResolveNode* destination_at(int i) { return _destinations[i]; } + ResolveNode* destination_at(int i) { return _destinations.at(i); } bool assigned() const { return _assigned; } bool visited() const { return _visited; } bool start_node() const { return _start_node; } diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.cpp b/hotspot/src/share/vm/c1/c1_LinearScan.cpp index eb49e97d896..8685067c0f5 100644 --- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp +++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp @@ -495,8 +495,8 @@ void LinearScan::number_instructions() { } // initialize with correct length - _lir_ops = LIR_OpArray(num_instructions); - _block_of_op = BlockBeginArray(num_instructions); + _lir_ops = LIR_OpArray(num_instructions, num_instructions, NULL); + _block_of_op = BlockBeginArray(num_instructions, num_instructions, NULL); int op_id = 0; int idx = 0; @@ -2506,7 +2506,8 @@ LocationValue* _illegal_value = new (ResourceObj::C_HEAP, mtCompiler) Lo void LinearScan::init_compute_debug_info() { // cache for frequently used scope values // (cpu registers and stack slots) - _scope_value_cache = ScopeValueArray((LinearScan::nof_cpu_regs + frame_map()->argcount() + max_spills()) * 2, NULL); + int cache_size = (LinearScan::nof_cpu_regs + frame_map()->argcount() + max_spills()) * 2; + _scope_value_cache = ScopeValueArray(cache_size, cache_size, NULL); } MonitorValue* LinearScan::location_for_monitor_index(int monitor_index) { @@ -3041,7 +3042,7 @@ void LinearScan::assign_reg_num(LIR_OpList* instructions, IntervalWalker* iw) { insert_point++; } } - instructions->truncate(insert_point); + instructions->trunc_to(insert_point); } } @@ -3445,7 +3446,7 @@ class RegisterVerifier: public StackObj { RegisterVerifier(LinearScan* allocator) : _allocator(allocator) , _work_list(16) - , _saved_states(BlockBegin::number_of_blocks(), NULL) + , _saved_states(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), NULL) { } void verify(BlockBegin* start); @@ -4451,7 +4452,7 @@ Interval* Interval::split(int split_pos) { new_use_pos_and_kinds.append(_use_pos_and_kinds.at(i)); } - _use_pos_and_kinds.truncate(start_idx + 2); + _use_pos_and_kinds.trunc_to(start_idx + 2); result->_use_pos_and_kinds = _use_pos_and_kinds; _use_pos_and_kinds = new_use_pos_and_kinds; @@ -5539,7 +5540,7 @@ void LinearScanWalker::split_and_spill_intersecting_intervals(int reg, int regHi IntervalList* processed = _spill_intervals[reg]; for (int i = 0; i < _spill_intervals[regHi]->length(); i++) { Interval* it = _spill_intervals[regHi]->at(i); - if (processed->find_from_end(it) == -1) { + if (processed->find(it) == -1) { remove_from_list(it); split_and_spill_interval(it); } @@ -6210,7 +6211,7 @@ void ControlFlowOptimizer::delete_empty_blocks(BlockList* code) { _original_preds.clear(); for (j = block->number_of_preds() - 1; j >= 0; j--) { BlockBegin* pred = block->pred_at(j); - if (_original_preds.index_of(pred) == -1) { + if (_original_preds.find(pred) == -1) { _original_preds.append(pred); } } @@ -6230,7 +6231,7 @@ void ControlFlowOptimizer::delete_empty_blocks(BlockList* code) { } old_pos++; } - code->truncate(new_pos); + code->trunc_to(new_pos); DEBUG_ONLY(verify(code)); } @@ -6255,7 +6256,7 @@ void ControlFlowOptimizer::delete_unnecessary_jumps(BlockList* code) { TRACE_LINEAR_SCAN(3, tty->print_cr("Deleting unconditional branch at end of block B%d", block->block_id())); // delete last branch instruction - instructions->truncate(instructions->length() - 1); + instructions->trunc_to(instructions->length() - 1); } else { LIR_Op* prev_op = instructions->at(instructions->length() - 2); @@ -6294,7 +6295,7 @@ void ControlFlowOptimizer::delete_unnecessary_jumps(BlockList* code) { prev_branch->change_block(last_branch->block()); prev_branch->negate_cond(); prev_cmp->set_condition(prev_branch->cond()); - instructions->truncate(instructions->length() - 1); + instructions->trunc_to(instructions->length() - 1); // if we do change the condition, we have to change the cmove as well if (prev_cmove != NULL) { prev_cmove->set_condition(prev_branch->cond()); @@ -6377,19 +6378,19 @@ void ControlFlowOptimizer::verify(BlockList* code) { LIR_OpBranch* op_branch = instructions->at(j)->as_OpBranch(); if (op_branch != NULL) { - assert(op_branch->block() == NULL || code->index_of(op_branch->block()) != -1, "branch target not valid"); - assert(op_branch->ublock() == NULL || code->index_of(op_branch->ublock()) != -1, "branch target not valid"); + assert(op_branch->block() == NULL || code->find(op_branch->block()) != -1, "branch target not valid"); + assert(op_branch->ublock() == NULL || code->find(op_branch->ublock()) != -1, "branch target not valid"); } } for (j = 0; j < block->number_of_sux() - 1; j++) { BlockBegin* sux = block->sux_at(j); - assert(code->index_of(sux) != -1, "successor not valid"); + assert(code->find(sux) != -1, "successor not valid"); } for (j = 0; j < block->number_of_preds() - 1; j++) { BlockBegin* pred = block->pred_at(j); - assert(code->index_of(pred) != -1, "successor not valid"); + assert(code->find(pred) != -1, "successor not valid"); } } } diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.hpp b/hotspot/src/share/vm/c1/c1_LinearScan.hpp index 7d296e3f674..1d04913a1c1 100644 --- a/hotspot/src/share/vm/c1/c1_LinearScan.hpp +++ b/hotspot/src/share/vm/c1/c1_LinearScan.hpp @@ -44,18 +44,9 @@ class Range; typedef GrowableArray IntervalArray; typedef GrowableArray IntervalList; - -define_array(IntervalsArray, IntervalList*) -define_stack(IntervalsList, IntervalsArray) - -define_array(OopMapArray, OopMap*) -define_stack(OopMapList, OopMapArray) - -define_array(ScopeValueArray, ScopeValue*) - -define_array(LIR_OpListArray, LIR_OpList*); -define_stack(LIR_OpListStack, LIR_OpListArray); - +typedef GrowableArray IntervalsList; +typedef GrowableArray ScopeValueArray; +typedef GrowableArray LIR_OpListStack; enum IntervalUseKind { // priority of use kinds must be ascending @@ -67,9 +58,6 @@ enum IntervalUseKind { firstValidKind = 1, lastValidKind = 3 }; -define_array(UseKindArray, IntervalUseKind) -define_stack(UseKindStack, UseKindArray) - enum IntervalKind { fixedKind = 0, // interval pre-colored by LIR_Generator @@ -619,7 +607,7 @@ class Interval : public CompilationResourceObj { void add_range(int from, int to); Interval* split(int split_pos); Interval* split_from_start(int split_pos); - void remove_first_use_pos() { _use_pos_and_kinds.truncate(_use_pos_and_kinds.length() - 2); } + void remove_first_use_pos() { _use_pos_and_kinds.trunc_to(_use_pos_and_kinds.length() - 2); } // test intersection bool covers(int op_id, LIR_OpVisitState::OprMode mode) const; diff --git a/hotspot/src/share/vm/c1/c1_Optimizer.cpp b/hotspot/src/share/vm/c1/c1_Optimizer.cpp index b44d74e12b4..869701ad7d0 100644 --- a/hotspot/src/share/vm/c1/c1_Optimizer.cpp +++ b/hotspot/src/share/vm/c1/c1_Optimizer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,9 +31,7 @@ #include "utilities/bitMap.inline.hpp" #include "compiler/compileLog.hpp" -define_array(ValueSetArray, ValueSet*); -define_stack(ValueSetList, ValueSetArray); - +typedef GrowableArray ValueSetList; Optimizer::Optimizer(IR* ir) { assert(ir->is_valid(), "IR must be valid"); @@ -583,8 +581,8 @@ class NullCheckEliminator: public ValueVisitor { ValueSet* state() { return _set; } void set_state_from (ValueSet* state) { _set->set_from(state); } - ValueSet* state_for (BlockBegin* block) { return _block_states[block->block_id()]; } - void set_state_for (BlockBegin* block, ValueSet* stack) { _block_states[block->block_id()] = stack; } + ValueSet* state_for (BlockBegin* block) { return _block_states.at(block->block_id()); } + void set_state_for (BlockBegin* block, ValueSet* stack) { _block_states.at_put(block->block_id(), stack); } // Returns true if caused a change in the block's state. bool merge_state_for(BlockBegin* block, ValueSet* incoming_state); @@ -595,7 +593,7 @@ class NullCheckEliminator: public ValueVisitor { : _opt(opt) , _set(new ValueSet()) , _last_explicit_null_check(NULL) - , _block_states(BlockBegin::number_of_blocks(), NULL) + , _block_states(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), NULL) , _work_list(new BlockList()) { _visitable_instructions = new ValueSet(); _visitor.set_eliminator(this); @@ -1164,19 +1162,19 @@ void Optimizer::eliminate_null_checks() { // handlers and iterate over them as well int nblocks = BlockBegin::number_of_blocks(); BlockList blocks(nblocks); - boolArray visited_block(nblocks, false); + boolArray visited_block(nblocks, nblocks, false); blocks.push(ir()->start()); - visited_block[ir()->start()->block_id()] = true; + visited_block.at_put(ir()->start()->block_id(), true); for (int i = 0; i < blocks.length(); i++) { - BlockBegin* b = blocks[i]; + BlockBegin* b = blocks.at(i); // exception handlers need to be treated as additional roots for (int e = b->number_of_exception_handlers(); e-- > 0; ) { BlockBegin* excp = b->exception_handler_at(e); int id = excp->block_id(); - if (!visited_block[id]) { + if (!visited_block.at(id)) { blocks.push(excp); - visited_block[id] = true; + visited_block.at_put(id, true); nce.iterate(excp); } } @@ -1185,9 +1183,9 @@ void Optimizer::eliminate_null_checks() { for (int s = end->number_of_sux(); s-- > 0; ) { BlockBegin* next = end->sux_at(s); int id = next->block_id(); - if (!visited_block[id]) { + if (!visited_block.at(id)) { blocks.push(next); - visited_block[id] = true; + visited_block.at_put(id, true); } } } diff --git a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp index 71e9de00b30..0ec8d49ef33 100644 --- a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp +++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,8 +53,8 @@ void RangeCheckElimination::eliminate(IR *ir) { // Constructor RangeCheckEliminator::RangeCheckEliminator(IR *ir) : - _bounds(Instruction::number_of_instructions(), NULL), - _access_indexed_info(Instruction::number_of_instructions(), NULL) + _bounds(Instruction::number_of_instructions(), Instruction::number_of_instructions(), NULL), + _access_indexed_info(Instruction::number_of_instructions(), Instruction::number_of_instructions(), NULL) { _visitor.set_range_check_eliminator(this); _ir = ir; @@ -303,28 +303,28 @@ RangeCheckEliminator::Bound *RangeCheckEliminator::get_bound(Value v) { // Wrong type or NULL -> No bound if (!v || (!v->type()->as_IntType() && !v->type()->as_ObjectType())) return NULL; - if (!_bounds[v->id()]) { + if (!_bounds.at(v->id())) { // First (default) bound is calculated // Create BoundStack - _bounds[v->id()] = new BoundStack(); + _bounds.at_put(v->id(), new BoundStack()); _visitor.clear_bound(); Value visit_value = v; visit_value->visit(&_visitor); Bound *bound = _visitor.bound(); if (bound) { - _bounds[v->id()]->push(bound); + _bounds.at(v->id())->push(bound); } - if (_bounds[v->id()]->length() == 0) { + if (_bounds.at(v->id())->length() == 0) { assert(!(v->as_Constant() && v->type()->as_IntConstant()), "constants not handled here"); - _bounds[v->id()]->push(new Bound()); + _bounds.at(v->id())->push(new Bound()); } - } else if (_bounds[v->id()]->length() == 0) { + } else if (_bounds.at(v->id())->length() == 0) { // To avoid endless loops, bound is currently in calculation -> nothing known about it return new Bound(); } // Return bound - return _bounds[v->id()]->top(); + return _bounds.at(v->id())->top(); } // Update bound @@ -353,28 +353,28 @@ void RangeCheckEliminator::update_bound(IntegerStack &pushed, Value v, Bound *bo // No bound update for constants return; } - if (!_bounds[v->id()]) { + if (!_bounds.at(v->id())) { get_bound(v); - assert(_bounds[v->id()], "Now Stack must exist"); + assert(_bounds.at(v->id()), "Now Stack must exist"); } Bound *top = NULL; - if (_bounds[v->id()]->length() > 0) { - top = _bounds[v->id()]->top(); + if (_bounds.at(v->id())->length() > 0) { + top = _bounds.at(v->id())->top(); } if (top) { bound->and_op(top); } - _bounds[v->id()]->push(bound); + _bounds.at(v->id())->push(bound); pushed.append(v->id()); } // Add instruction + idx for in block motion void RangeCheckEliminator::add_access_indexed_info(InstructionList &indices, int idx, Value instruction, AccessIndexed *ai) { int id = instruction->id(); - AccessIndexedInfo *aii = _access_indexed_info[id]; + AccessIndexedInfo *aii = _access_indexed_info.at(id); if (aii == NULL) { aii = new AccessIndexedInfo(); - _access_indexed_info[id] = aii; + _access_indexed_info.at_put(id, aii); indices.append(instruction); aii->_min = idx; aii->_max = idx; @@ -461,7 +461,7 @@ void RangeCheckEliminator::in_block_motion(BlockBegin *block, AccessIndexedList if (_optimistic) { for (int i = 0; i < indices.length(); i++) { Instruction *index_instruction = indices.at(i); - AccessIndexedInfo *info = _access_indexed_info[index_instruction->id()]; + AccessIndexedInfo *info = _access_indexed_info.at(index_instruction->id()); assert(info != NULL, "Info must not be null"); // if idx < 0, max > 0, max + idx may fall between 0 and @@ -562,7 +562,7 @@ void RangeCheckEliminator::in_block_motion(BlockBegin *block, AccessIndexedList // Clear data structures for next array for (int i = 0; i < indices.length(); i++) { Instruction *index_instruction = indices.at(i); - _access_indexed_info[index_instruction->id()] = NULL; + _access_indexed_info.at_put(index_instruction->id(), NULL); } indices.clear(); } @@ -1005,7 +1005,7 @@ void RangeCheckEliminator::calc_bounds(BlockBegin *block, BlockBegin *loop_heade // Reset stack for (int i=0; ipop(); + _bounds.at(pushed.at(i))->pop(); } } @@ -1051,7 +1051,7 @@ void RangeCheckEliminator::dump_condition_stack(BlockBegin *block) { #endif // Verification or the IR -RangeCheckEliminator::Verification::Verification(IR *ir) : _used(BlockBegin::number_of_blocks(), false) { +RangeCheckEliminator::Verification::Verification(IR *ir) : _used(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), false) { this->_ir = ir; ir->iterate_linear_scan_order(this); } @@ -1146,14 +1146,14 @@ bool RangeCheckEliminator::Verification::can_reach(BlockBegin *start, BlockBegin if (start == end) return start != dont_use; // Simple BSF from start to end // BlockBeginList _current; - for (int i=0; i<_used.length(); i++) { - _used[i] = false; + for (int i=0; i < _used.length(); i++) { + _used.at_put(i, false); } - _current.truncate(0); - _successors.truncate(0); + _current.trunc_to(0); + _successors.trunc_to(0); if (start != dont_use) { _current.push(start); - _used[start->block_id()] = true; + _used.at_put(start->block_id(), true); } // BlockBeginList _successors; @@ -1180,17 +1180,17 @@ bool RangeCheckEliminator::Verification::can_reach(BlockBegin *start, BlockBegin } } for (int i=0; i<_successors.length(); i++) { - BlockBegin *sux = _successors[i]; + BlockBegin *sux = _successors.at(i); assert(sux != NULL, "Successor must not be NULL!"); if (sux == end) { return true; } - if (sux != dont_use && !_used[sux->block_id()]) { - _used[sux->block_id()] = true; + if (sux != dont_use && !_used.at(sux->block_id())) { + _used.at_put(sux->block_id(), true); _current.push(sux); } } - _successors.truncate(0); + _successors.trunc_to(0); } return false; diff --git a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp index 0552125b8dc..0fb97a113b2 100644 --- a/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp +++ b/hotspot/src/share/vm/c1/c1_RangeCheckElimination.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,10 +40,8 @@ private: bool _optimistic; // Insert predicates and deoptimize when they fail IR *_ir; - define_array(BlockBeginArray, BlockBegin*) - define_stack(BlockBeginList, BlockBeginArray) - define_stack(IntegerStack, intArray) - define_array(IntegerMap, IntegerStack*) + typedef GrowableArray BlockBeginList; + typedef GrowableArray IntegerStack; class Verification : public BlockClosure { // RangeCheckEliminator::Verification should never get instatiated on the heap. @@ -180,13 +178,10 @@ public: void add_assertions(Bound *bound, Instruction *instruction, Instruction *position); #endif - define_array(BoundArray, Bound *) - define_stack(BoundStack, BoundArray) - define_array(BoundMap, BoundStack *) - define_array(AccessIndexedArray, AccessIndexed *) - define_stack(AccessIndexedList, AccessIndexedArray) - define_array(InstructionArray, Instruction *) - define_stack(InstructionList, InstructionArray) + typedef GrowableArray BoundStack; + typedef GrowableArray BoundMap; + typedef GrowableArray AccessIndexedList; + typedef GrowableArray InstructionList; class AccessIndexedInfo : public CompilationResourceObj { public: @@ -195,7 +190,7 @@ public: int _max; }; - define_array(AccessIndexedInfoArray, AccessIndexedInfo *) + typedef GrowableArray AccessIndexedInfoArray; BoundMap _bounds; // Mapping from Instruction's id to current bound AccessIndexedInfoArray _access_indexed_info; // Mapping from Instruction's id to AccessIndexedInfo for in block motion Visitor _visitor; diff --git a/hotspot/src/share/vm/c1/c1_ValueMap.cpp b/hotspot/src/share/vm/c1/c1_ValueMap.cpp index fb52819facc..fb277a5616b 100644 --- a/hotspot/src/share/vm/c1/c1_ValueMap.cpp +++ b/hotspot/src/share/vm/c1/c1_ValueMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ ValueMap::ValueMap() : _nesting(0) - , _entries(ValueMapInitialSize, NULL) + , _entries(ValueMapInitialSize, ValueMapInitialSize, NULL) , _killed_values() , _entry_count(0) { @@ -56,7 +56,7 @@ ValueMap::ValueMap() ValueMap::ValueMap(ValueMap* old) : _nesting(old->_nesting + 1) - , _entries(old->_entries.length()) + , _entries(old->_entries.length(), old->_entries.length(), NULL) , _killed_values() , _entry_count(old->_entry_count) { @@ -72,7 +72,7 @@ void ValueMap::increase_table_size() { int new_size = old_size * 2 + 1; ValueMapEntryList worklist(8); - ValueMapEntryArray new_entries(new_size, NULL); + ValueMapEntryArray new_entries(new_size, new_size, NULL); int new_entry_count = 0; TRACE_VALUE_NUMBERING(tty->print_cr("increasing table size from %d to %d", old_size, new_size)); @@ -486,7 +486,7 @@ bool ShortLoopOptimizer::process(BlockBegin* loop_header) { GlobalValueNumbering::GlobalValueNumbering(IR* ir) : _current_map(NULL) - , _value_maps(ir->linear_scan_order()->length(), NULL) + , _value_maps(ir->linear_scan_order()->length(), ir->linear_scan_order()->length(), NULL) , _compilation(ir->compilation()) { TRACE_VALUE_NUMBERING(tty->print_cr("****** start of global value numbering")); diff --git a/hotspot/src/share/vm/c1/c1_ValueMap.hpp b/hotspot/src/share/vm/c1/c1_ValueMap.hpp index 3b3b02ee4b7..e2e1c1b15fe 100644 --- a/hotspot/src/share/vm/c1/c1_ValueMap.hpp +++ b/hotspot/src/share/vm/c1/c1_ValueMap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,8 +53,8 @@ class ValueMapEntry: public CompilationResourceObj { void set_next(ValueMapEntry* next) { _next = next; } }; -define_array(ValueMapEntryArray, ValueMapEntry*) -define_stack(ValueMapEntryList, ValueMapEntryArray) +typedef GrowableArray ValueMapEntryArray; +typedef GrowableArray ValueMapEntryList; // ValueMap implements nested hash tables for value numbering. It // maintains a set _killed_values which represents the instructions @@ -129,8 +129,7 @@ class ValueMap: public CompilationResourceObj { #endif }; -define_array(ValueMapArray, ValueMap*) - +typedef GrowableArray ValueMapArray; class ValueNumberingVisitor: public InstructionVisitor { protected: diff --git a/hotspot/src/share/vm/c1/c1_ValueStack.cpp b/hotspot/src/share/vm/c1/c1_ValueStack.cpp index fcf8ba2ce46..139451138b7 100644 --- a/hotspot/src/share/vm/c1/c1_ValueStack.cpp +++ b/hotspot/src/share/vm/c1/c1_ValueStack.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ ValueStack::ValueStack(IRScope* scope, ValueStack* caller_state) , _caller_state(caller_state) , _bci(-99) , _kind(Parsing) -, _locals(scope->method()->max_locals(), NULL) +, _locals(scope->method()->max_locals(), scope->method()->max_locals(), NULL) , _stack(scope->method()->max_stack()) , _locks() { @@ -178,7 +178,7 @@ void ValueStack::setup_phi_for_stack(BlockBegin* b, int index) { ValueType* t = stack_at(index)->type(); Value phi = new Phi(t, b, -index - 1); - _stack[index] = phi; + _stack.at_put(index, phi); assert(!t->is_double_word() || _stack.at(index + 1) == NULL, "hi-word of doubleword value must be NULL"); } @@ -225,7 +225,7 @@ void ValueStack::print() { if (locals_size() > 0) { InstructionPrinter ip; for (int i = 0; i < locals_size();) { - Value l = _locals[i]; + Value l = _locals.at(i); tty->print("local %d ", i); if (l == NULL) { tty->print("null"); diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 3be9d2f9b47..87a9c343ff2 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -2927,7 +2927,7 @@ static const intArray* sort_methods(Array* methods) { // If JVMTI original method ordering or sharing is enabled construct int // array remembering the original ordering if (JvmtiExport::can_maintain_original_method_order() || DumpSharedSpaces) { - method_ordering = new intArray(length); + method_ordering = new intArray(length, length, -1); for (int index = 0; index < length; index++) { Method* const m = methods->at(index); const int old_index = m->vtable_index(); diff --git a/hotspot/src/share/vm/classfile/classFileParser.hpp b/hotspot/src/share/vm/classfile/classFileParser.hpp index 3ee99df2e3b..47ec53940b2 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.hpp +++ b/hotspot/src/share/vm/classfile/classFileParser.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,6 @@ class FieldInfo; template class GrowableArray; class InstanceKlass; -class intArray; class Symbol; class TempNewSymbol; diff --git a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp index 366bf4671b3..9d93521ac1f 100644 --- a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp +++ b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp @@ -280,7 +280,7 @@ void ParScanThreadState::print_promotion_failure_size() { } } -class ParScanThreadStateSet: private ResourceArray { +class ParScanThreadStateSet: StackObj { public: // Initializes states for the specified number of threads; ParScanThreadStateSet(int num_threads, @@ -315,8 +315,10 @@ private: ParallelTaskTerminator& _term; ParNewGeneration& _young_gen; Generation& _old_gen; + ParScanThreadState* _per_thread_states; + const int _num_threads; public: - bool is_valid(int id) const { return id < length(); } + bool is_valid(int id) const { return id < _num_threads; } ParallelTaskTerminator* terminator() { return &_term; } }; @@ -329,30 +331,31 @@ ParScanThreadStateSet::ParScanThreadStateSet(int num_threads, PreservedMarksSet& preserved_marks_set, size_t desired_plab_sz, ParallelTaskTerminator& term) - : ResourceArray(sizeof(ParScanThreadState), num_threads), - _young_gen(young_gen), + : _young_gen(young_gen), _old_gen(old_gen), - _term(term) + _term(term), + _per_thread_states(NEW_RESOURCE_ARRAY(ParScanThreadState, num_threads)), + _num_threads(num_threads) { assert(num_threads > 0, "sanity check!"); assert(ParGCUseLocalOverflow == (overflow_stacks != NULL), "overflow_stack allocation mismatch"); // Initialize states. for (int i = 0; i < num_threads; ++i) { - new ((ParScanThreadState*)_data + i) - ParScanThreadState(&to_space, &young_gen, &old_gen, i, &queue_set, - overflow_stacks, preserved_marks_set.get(i), - desired_plab_sz, term); + new(_per_thread_states + i) + ParScanThreadState(&to_space, &young_gen, &old_gen, i, &queue_set, + overflow_stacks, preserved_marks_set.get(i), + desired_plab_sz, term); } } inline ParScanThreadState& ParScanThreadStateSet::thread_state(int i) { - assert(i >= 0 && i < length(), "sanity check!"); - return ((ParScanThreadState*)_data)[i]; + assert(i >= 0 && i < _num_threads, "sanity check!"); + return _per_thread_states[i]; } void ParScanThreadStateSet::trace_promotion_failed(const YoungGCTracer* gc_tracer) { - for (int i = 0; i < length(); ++i) { + for (int i = 0; i < _num_threads; ++i) { if (thread_state(i).promotion_failed()) { gc_tracer->report_promotion_failed(thread_state(i).promotion_failed_info()); thread_state(i).promotion_failed_info().reset(); @@ -363,7 +366,7 @@ void ParScanThreadStateSet::trace_promotion_failed(const YoungGCTracer* gc_trace void ParScanThreadStateSet::reset(uint active_threads, bool promotion_failed) { _term.reset_for_reuse(active_threads); if (promotion_failed) { - for (int i = 0; i < length(); ++i) { + for (int i = 0; i < _num_threads; ++i) { thread_state(i).print_promotion_failure_size(); } } @@ -378,7 +381,7 @@ void ParScanThreadState::reset_stats() { } void ParScanThreadStateSet::reset_stats() { - for (int i = 0; i < length(); ++i) { + for (int i = 0; i < _num_threads; ++i) { thread_state(i).reset_stats(); } } @@ -401,7 +404,7 @@ void ParScanThreadStateSet::print_termination_stats() { print_termination_stats_hdr(st); - for (int i = 0; i < length(); ++i) { + for (int i = 0; i < _num_threads; ++i) { const ParScanThreadState & pss = thread_state(i); const double elapsed_ms = pss.elapsed_time() * 1000.0; const double s_roots_ms = pss.strong_roots_time() * 1000.0; @@ -429,7 +432,7 @@ void ParScanThreadStateSet::print_taskqueue_stats() { print_taskqueue_stats_hdr(st); TaskQueueStats totals; - for (int i = 0; i < length(); ++i) { + for (int i = 0; i < _num_threads; ++i) { const ParScanThreadState & pss = thread_state(i); const TaskQueueStats & stats = pss.taskqueue_stats(); st->print("%3d ", i); stats.print(st); st->cr(); @@ -452,7 +455,7 @@ void ParScanThreadStateSet::flush() { // possible since this might otherwise become a bottleneck // to scaling. Should we add heavy-weight work into this // loop, consider parallelizing the loop into the worker threads. - for (int i = 0; i < length(); ++i) { + for (int i = 0; i < _num_threads; ++i) { ParScanThreadState& par_scan_state = thread_state(i); // Flush stats related to To-space PLAB activity and diff --git a/hotspot/src/share/vm/interpreter/rewriter.cpp b/hotspot/src/share/vm/interpreter/rewriter.cpp index 41e29a6ee53..7680fbf4b50 100644 --- a/hotspot/src/share/vm/interpreter/rewriter.cpp +++ b/hotspot/src/share/vm/interpreter/rewriter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,11 +65,12 @@ void Rewriter::compute_index_maps() { // Record limits of resolved reference map for constant pool cache indices record_map_limits(); - guarantee((int)_cp_cache_map.length()-1 <= (int)((u2)-1), + guarantee((int) _cp_cache_map.length() - 1 <= (int) ((u2)-1), "all cp cache indexes fit in a u2"); - if (saw_mh_symbol) - _method_handle_invokers.initialize(length, (int)0); + if (saw_mh_symbol) { + _method_handle_invokers.at_grow(length, 0); + } } // Unrewrite the bytecodes if an error occurs. @@ -193,7 +194,7 @@ void Rewriter::maybe_rewrite_invokehandle(address opc, int cp_index, int cache_i assert(_pool->tag_at(cp_index).is_method(), "wrong index"); // Determine whether this is a signature-polymorphic method. if (cp_index >= _method_handle_invokers.length()) return; - int status = _method_handle_invokers[cp_index]; + int status = _method_handle_invokers.at(cp_index); assert(status >= -1 && status <= 1, "oob tri-state"); if (status == 0) { if (_pool->klass_ref_at_noresolve(cp_index) == vmSymbols::java_lang_invoke_MethodHandle() && @@ -211,7 +212,7 @@ void Rewriter::maybe_rewrite_invokehandle(address opc, int cp_index, int cache_i } else { status = -1; } - _method_handle_invokers[cp_index] = status; + _method_handle_invokers.at(cp_index) = status; } // We use a special internal bytecode for such methods (if non-static). // The basic reason for this is that such methods need an extra "appendix" argument @@ -287,7 +288,7 @@ void Rewriter::patch_invokedynamic_bytecodes() { // add delta to each. int resolved_index = _patch_invokedynamic_refs->at(i); for (int entry = 0; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) { - assert(_invokedynamic_references_map[resolved_index+entry] == cache_index, + assert(_invokedynamic_references_map.at(resolved_index + entry) == cache_index, "should be the same index"); _invokedynamic_references_map.at_put(resolved_index+entry, cache_index + delta); @@ -520,7 +521,14 @@ void Rewriter::rewrite(instanceKlassHandle klass, TRAPS) { Rewriter::Rewriter(instanceKlassHandle klass, const constantPoolHandle& cpool, Array* methods, TRAPS) : _klass(klass), _pool(cpool), - _methods(methods) + _methods(methods), + _cp_map(cpool->length()), + _cp_cache_map(cpool->length() / 2), + _reference_map(cpool->length()), + _resolved_references_map(cpool->length() / 2), + _invokedynamic_references_map(cpool->length() / 2), + _method_handle_invokers(cpool->length()), + _invokedynamic_cp_cache_map(cpool->length() / 4) { // Rewrite bytecodes - exception here exits. diff --git a/hotspot/src/share/vm/interpreter/rewriter.hpp b/hotspot/src/share/vm/interpreter/rewriter.hpp index de25b101e84..68658537b4e 100644 --- a/hotspot/src/share/vm/interpreter/rewriter.hpp +++ b/hotspot/src/share/vm/interpreter/rewriter.hpp @@ -37,13 +37,13 @@ class Rewriter: public StackObj { instanceKlassHandle _klass; constantPoolHandle _pool; Array* _methods; - intArray _cp_map; - intStack _cp_cache_map; // for Methodref, Fieldref, - // InterfaceMethodref and InvokeDynamic - intArray _reference_map; // maps from cp index to resolved_refs index (or -1) - intStack _resolved_references_map; // for strings, methodHandle, methodType - intStack _invokedynamic_references_map; // for invokedynamic resolved refs - intArray _method_handle_invokers; + GrowableArray _cp_map; + GrowableArray _cp_cache_map; // for Methodref, Fieldref, + // InterfaceMethodref and InvokeDynamic + GrowableArray _reference_map; // maps from cp index to resolved_refs index (or -1) + GrowableArray _resolved_references_map; // for strings, methodHandle, methodType + GrowableArray _invokedynamic_references_map; // for invokedynamic resolved refs + GrowableArray _method_handle_invokers; int _resolved_reference_limit; // For mapping invokedynamic bytecodes, which are discovered during method @@ -51,28 +51,31 @@ class Rewriter: public StackObj { // If there are any invokespecial/InterfaceMethodref special case bytecodes, // these entries are added before invokedynamic entries so that the // invokespecial bytecode 16 bit index doesn't overflow. - intStack _invokedynamic_cp_cache_map; + GrowableArray _invokedynamic_cp_cache_map; // For patching. GrowableArray

        * _patch_invokedynamic_bcps; GrowableArray* _patch_invokedynamic_refs; void init_maps(int length) { - _cp_map.initialize(length, -1); - // Choose an initial value large enough that we don't get frequent - // calls to grow(). - _cp_cache_map.initialize(length/2); + _cp_map.trunc_to(0); + _cp_map.at_grow(length, -1); + + _cp_cache_map.trunc_to(0); // Also cache resolved objects, in another different cache. - _reference_map.initialize(length, -1); - _resolved_references_map.initialize(length/2); - _invokedynamic_references_map.initialize(length/2); + _reference_map.trunc_to(0); + _reference_map.at_grow(length, -1); + + _method_handle_invokers.trunc_to(0); + _resolved_references_map.trunc_to(0); + _invokedynamic_references_map.trunc_to(0); _resolved_reference_limit = -1; _first_iteration_cp_cache_limit = -1; // invokedynamic specific fields - _invokedynamic_cp_cache_map.initialize(length/4); - _patch_invokedynamic_bcps = new GrowableArray
        (length/4); - _patch_invokedynamic_refs = new GrowableArray(length/4); + _invokedynamic_cp_cache_map.trunc_to(0); + _patch_invokedynamic_bcps = new GrowableArray
        (length / 4); + _patch_invokedynamic_refs = new GrowableArray(length / 4); } int _first_iteration_cp_cache_limit; @@ -90,10 +93,10 @@ class Rewriter: public StackObj { return _cp_cache_map.length() - _first_iteration_cp_cache_limit; } - int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map[i]; } - bool has_cp_cache(int i) { return (uint)i < (uint)_cp_map.length() && _cp_map[i] >= 0; } + int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map.at(i); } + bool has_cp_cache(int i) { return (uint) i < (uint) _cp_map.length() && _cp_map.at(i) >= 0; } - int add_map_entry(int cp_index, intArray* cp_map, intStack* cp_cache_map) { + int add_map_entry(int cp_index, GrowableArray* cp_map, GrowableArray* cp_cache_map) { assert(cp_map->at(cp_index) == -1, "not twice on same cp_index"); int cache_index = cp_cache_map->append(cp_index); cp_map->at_put(cp_index, cache_index); @@ -121,7 +124,7 @@ class Rewriter: public StackObj { } int invokedynamic_cp_cache_entry_pool_index(int cache_index) { - int cp_index = _invokedynamic_cp_cache_map[cache_index]; + int cp_index = _invokedynamic_cp_cache_map.at(cache_index); return cp_index; } @@ -131,9 +134,9 @@ class Rewriter: public StackObj { assert(_first_iteration_cp_cache_limit >= 0, "add these special cache entries after first iteration"); // Don't add InterfaceMethodref if it already exists at the end. for (int i = _first_iteration_cp_cache_limit; i < _cp_cache_map.length(); i++) { - if (cp_cache_entry_pool_index(i) == cp_index) { - return i; - } + if (cp_cache_entry_pool_index(i) == cp_index) { + return i; + } } int cache_index = _cp_cache_map.append(cp_index); assert(cache_index >= _first_iteration_cp_cache_limit, ""); @@ -144,10 +147,10 @@ class Rewriter: public StackObj { int cp_entry_to_resolved_references(int cp_index) const { assert(has_entry_in_resolved_references(cp_index), "oob"); - return _reference_map[cp_index]; + return _reference_map.at(cp_index); } bool has_entry_in_resolved_references(int cp_index) const { - return (uint)cp_index < (uint)_reference_map.length() && _reference_map[cp_index] >= 0; + return (uint) cp_index < (uint) _reference_map.length() && _reference_map.at(cp_index) >= 0; } // add a new entry to the resolved_references map @@ -174,13 +177,13 @@ class Rewriter: public StackObj { } int resolved_references_entry_to_pool_index(int ref_index) { - int cp_index = _resolved_references_map[ref_index]; + int cp_index = _resolved_references_map.at(ref_index); return cp_index; } // Access the contents of _cp_cache_map to determine CP cache layout. int cp_cache_entry_pool_index(int cache_index) { - int cp_index = _cp_cache_map[cache_index]; + int cp_index = _cp_cache_map.at(cache_index); return cp_index; } diff --git a/hotspot/src/share/vm/oops/cpCache.cpp b/hotspot/src/share/vm/oops/cpCache.cpp index 1e9b0b649e9..371f6646363 100644 --- a/hotspot/src/share/vm/oops/cpCache.cpp +++ b/hotspot/src/share/vm/oops/cpCache.cpp @@ -568,7 +568,7 @@ void ConstantPoolCache::initialize(const intArray& inverse_index_map, const intArray& invokedynamic_references_map) { for (int i = 0; i < inverse_index_map.length(); i++) { ConstantPoolCacheEntry* e = entry_at(i); - int original_index = inverse_index_map[i]; + int original_index = inverse_index_map.at(i); e->initialize_entry(original_index); assert(entry_at(i) == e, "sanity"); } @@ -578,19 +578,19 @@ void ConstantPoolCache::initialize(const intArray& inverse_index_map, for (int i = 0; i < invokedynamic_inverse_index_map.length(); i++) { int offset = i + invokedynamic_offset; ConstantPoolCacheEntry* e = entry_at(offset); - int original_index = invokedynamic_inverse_index_map[i]; + int original_index = invokedynamic_inverse_index_map.at(i); e->initialize_entry(original_index); assert(entry_at(offset) == e, "sanity"); } for (int ref = 0; ref < invokedynamic_references_map.length(); ref++) { - const int cpci = invokedynamic_references_map[ref]; + const int cpci = invokedynamic_references_map.at(ref); if (cpci >= 0) { #ifdef ASSERT // invokedynamic and invokehandle have more entries; check if they // all point to the same constant pool cache entry. for (int entry = 1; entry < ConstantPoolCacheEntry::_indy_resolved_references_entries; entry++) { - const int cpci_next = invokedynamic_references_map[ref + entry]; + const int cpci_next = invokedynamic_references_map.at(ref + entry); assert(cpci == cpci_next, "%d == %d", cpci, cpci_next); } #endif diff --git a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp index c48de41227b..c197919eb1c 100644 --- a/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp +++ b/hotspot/src/share/vm/prims/jvmtiClassFileReconstituter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -693,7 +693,7 @@ void JvmtiClassFileReconstituter::write_method_infos() { if (JvmtiExport::can_maintain_original_method_order()) { int index; int original_index; - intArray method_order(num_methods, 0); + intArray method_order(num_methods, num_methods, 0); // invert the method order mapping for (index = 0; index < num_methods; index++) { diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp index 6b176ec1f70..3de8ecf7694 100644 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp @@ -1447,12 +1447,12 @@ jvmtiError VM_RedefineClasses::merge_cp_and_rewrite( ResourceMark rm(THREAD); _index_map_count = 0; - _index_map_p = new intArray(scratch_cp->length(), -1); + _index_map_p = new intArray(scratch_cp->length(), scratch_cp->length(), -1); _operands_cur_length = ConstantPool::operand_array_length(old_cp->operands()); _operands_index_map_count = 0; - _operands_index_map_p = new intArray( - ConstantPool::operand_array_length(scratch_cp->operands()), -1); + int operands_index_map_len = ConstantPool::operand_array_length(scratch_cp->operands()); + _operands_index_map_p = new intArray(operands_index_map_len, operands_index_map_len, -1); // reference to the cp holder is needed for copy_operands() merge_cp->set_pool_holder(scratch_class()); diff --git a/hotspot/src/share/vm/utilities/array.cpp b/hotspot/src/share/vm/utilities/array.cpp deleted file mode 100644 index 746f2a5e498..00000000000 --- a/hotspot/src/share/vm/utilities/array.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "memory/resourceArea.hpp" -#include "runtime/thread.inline.hpp" -#include "utilities/array.hpp" - - -#ifdef ASSERT -void ResourceArray::init_nesting() { - _nesting = Thread::current()->resource_area()->nesting(); -} -#endif - - -void ResourceArray::sort(size_t esize, ftype f) { - if (!is_empty()) qsort(_data, length(), esize, f); -} -template void CHeapArray::sort(size_t esize, ftype f) { - if (!is_empty()) qsort(_data, length(), esize, f); -} - - -void ResourceArray::expand(size_t esize, int i, int& size) { - // make sure we are expanding within the original resource mark - assert( - _nesting == Thread::current()->resource_area()->nesting(), - "allocating outside original resource mark" - ); - // determine new size - if (size == 0) size = 4; // prevent endless loop - while (i >= size) size *= 2; - // allocate and initialize new data section - void* data = resource_allocate_bytes(esize * size); - memcpy(data, _data, esize * length()); - _data = data; -} - - -template void CHeapArray::expand(size_t esize, int i, int& size) { - // determine new size - if (size == 0) size = 4; // prevent endless loop - while (i >= size) size *= 2; - // allocate and initialize new data section - void* data = NEW_C_HEAP_ARRAY(char*, esize * size, F); - memcpy(data, _data, esize * length()); - FREE_C_HEAP_ARRAY(char*, _data); - _data = data; -} - - -void ResourceArray::remove_at(size_t esize, int i) { - assert(0 <= i && i < length(), "index out of bounds"); - _length--; - void* dst = (char*)_data + i*esize; - void* src = (char*)dst + esize; - size_t cnt = (length() - i)*esize; - memmove(dst, src, cnt); -} - -template void CHeapArray::remove_at(size_t esize, int i) { - assert(0 <= i && i < length(), "index out of bounds"); - _length--; - void* dst = (char*)_data + i*esize; - void* src = (char*)dst + esize; - size_t cnt = (length() - i)*esize; - memmove(dst, src, cnt); -} diff --git a/hotspot/src/share/vm/utilities/array.hpp b/hotspot/src/share/vm/utilities/array.hpp index f759fe1c03f..d174bee19aa 100644 --- a/hotspot/src/share/vm/utilities/array.hpp +++ b/hotspot/src/share/vm/utilities/array.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,273 +30,11 @@ #include "memory/metaspace.hpp" #include "runtime/orderAccess.hpp" -// correct linkage required to compile w/o warnings -// (must be on file level - cannot be local) -extern "C" { typedef int (*ftype)(const void*, const void*); } - - -class ResourceArray: public ResourceObj { - protected: - int _length; // the number of array elements - void* _data; // the array memory -#ifdef ASSERT - int _nesting; // the resource area nesting level -#endif - - // creation - ResourceArray() { - _length = 0; - _data = NULL; - DEBUG_ONLY(init_nesting();) - // client may call initialize, at most once - } - - - ResourceArray(size_t esize, int length) { - DEBUG_ONLY(_data = NULL); - initialize(esize, length); - } - - void initialize(size_t esize, int length) { - assert(length >= 0, "illegal length"); - assert(StressRewriter || _data == NULL, "must be new object"); - _length = length; - _data = resource_allocate_bytes(esize * length); - DEBUG_ONLY(init_nesting();) - } - -#ifdef ASSERT - void init_nesting(); -#endif - - // helper functions - void sort (size_t esize, ftype f); // sort the array - void expand (size_t esize, int i, int& size);// expand the array to include slot i - void remove_at(size_t esize, int i); // remove the element in slot i - - public: - // standard operations - int length() const { return _length; } - bool is_empty() const { return length() == 0; } -}; - - -template class CHeapArray: public CHeapObj { - protected: - int _length; // the number of array elements - void* _data; // the array memory - - // creation - CHeapArray() { - _length = 0; - _data = NULL; - } - - - CHeapArray(size_t esize, int length) { - assert(length >= 0, "illegal length"); - _length = length; - _data = (void*) NEW_C_HEAP_ARRAY(char *, esize * length, F); - } - - void initialize(size_t esize, int length) { - // In debug set array to 0? - } - -#ifdef ASSERT - void init_nesting(); -#endif - - // helper functions - void sort (size_t esize, ftype f); // sort the array - void expand (size_t esize, int i, int& size);// expand the array to include slot i - void remove_at(size_t esize, int i); // remove the element in slot i - - public: - // standard operations - int length() const { return _length; } - bool is_empty() const { return length() == 0; } -}; - -#define define_generic_array(array_name,element_type, base_class) \ - class array_name: public base_class { \ - protected: \ - typedef element_type etype; \ - enum { esize = sizeof(etype) }; \ - \ - void base_remove_at(size_t size, int i) { base_class::remove_at(size, i); } \ - \ - public: \ - /* creation */ \ - array_name() : base_class() {} \ - explicit array_name(const int length) : base_class(esize, length) {} \ - array_name(const int length, const etype fx) { initialize(length, fx); } \ - void initialize(const int length) { base_class::initialize(esize, length); } \ - void initialize(const int length, const etype fx) { \ - initialize(length); \ - for (int i = 0; i < length; i++) ((etype*)_data)[i] = fx; \ - } \ - \ - /* standard operations */ \ - etype& operator [] (const int i) const { \ - assert(0 <= i && i < length(), "index out of bounds"); \ - return ((etype*)_data)[i]; \ - } \ - \ - int index_of(const etype x) const { \ - int i = length(); \ - while (i-- > 0 && ((etype*)_data)[i] != x) ; \ - /* i < 0 || ((etype*)_data)_data[i] == x */ \ - return i; \ - } \ - \ - void sort(int f(etype*, etype*)) { base_class::sort(esize, (ftype)f); } \ - bool contains(const etype x) const { return index_of(x) >= 0; } \ - \ - /* deprecated operations - for compatibility with GrowableArray only */ \ - etype at(const int i) const { return (*this)[i]; } \ - void at_put(const int i, const etype x) { (*this)[i] = x; } \ - etype* adr_at(const int i) { return &(*this)[i]; } \ - int find(const etype x) { return index_of(x); } \ - }; \ - - -#define define_array(array_name,element_type) \ - define_generic_array(array_name, element_type, ResourceArray) - - -#define define_stack(stack_name,array_name) \ - class stack_name: public array_name { \ - protected: \ - int _size; \ - \ - void grow(const int i, const etype fx) { \ - assert(i >= length(), "index too small"); \ - if (i >= size()) expand(esize, i, _size); \ - for (int j = length(); j <= i; j++) ((etype*)_data)[j] = fx; \ - _length = i+1; \ - } \ - \ - public: \ - /* creation */ \ - stack_name() : array_name() { _size = 0; } \ - stack_name(const int size) { initialize(size); } \ - stack_name(const int size, const etype fx) { initialize(size, fx); } \ - void initialize(const int size, const etype fx) { \ - _size = size; \ - array_name::initialize(size, fx); \ - /* _length == size, allocation and size are the same */ \ - } \ - void initialize(const int size) { \ - _size = size; \ - array_name::initialize(size); \ - _length = 0; /* reset length to zero; _size records the allocation */ \ - } \ - \ - /* standard operations */ \ - int size() const { return _size; } \ - \ - int push(const etype x) { \ - int len = length(); \ - if (len >= size()) expand(esize, len, _size); \ - ((etype*)_data)[len] = x; \ - _length = len+1; \ - return len; \ - } \ - \ - etype pop() { \ - assert(!is_empty(), "stack is empty"); \ - return ((etype*)_data)[--_length]; \ - } \ - \ - etype top() const { \ - assert(!is_empty(), "stack is empty"); \ - return ((etype*)_data)[length() - 1]; \ - } \ - \ - void push_all(const stack_name* stack) { \ - const int l = stack->length(); \ - for (int i = 0; i < l; i++) push(((etype*)(stack->_data))[i]); \ - } \ - \ - etype at_grow(const int i, const etype fx) { \ - if (i >= length()) grow(i, fx); \ - return ((etype*)_data)[i]; \ - } \ - \ - void at_put_grow(const int i, const etype x, const etype fx) { \ - if (i >= length()) grow(i, fx); \ - ((etype*)_data)[i] = x; \ - } \ - \ - void truncate(const int length) { \ - assert(0 <= length && length <= this->length(), "illegal length"); \ - _length = length; \ - } \ - \ - void remove_at(int i) { base_remove_at(esize, i); } \ - void remove(etype x) { remove_at(index_of(x)); } \ - \ - /* inserts the given element before the element at index i */ \ - void insert_before(const int i, const etype el) { \ - int len = length(); \ - int new_length = len + 1; \ - if (new_length >= size()) expand(esize, new_length, _size); \ - for (int j = len - 1; j >= i; j--) { \ - ((etype*)_data)[j + 1] = ((etype*)_data)[j]; \ - } \ - _length = new_length; \ - at_put(i, el); \ - } \ - \ - /* inserts contents of the given stack before the element at index i */ \ - void insert_before(const int i, const stack_name *st) { \ - if (st->length() == 0) return; \ - int len = length(); \ - int st_len = st->length(); \ - int new_length = len + st_len; \ - if (new_length >= size()) expand(esize, new_length, _size); \ - int j; \ - for (j = len - 1; j >= i; j--) { \ - ((etype*)_data)[j + st_len] = ((etype*)_data)[j]; \ - } \ - for (j = 0; j < st_len; j++) { \ - ((etype*)_data)[i + j] = ((etype*)st->_data)[j]; \ - } \ - _length = new_length; \ - } \ - \ - /* deprecated operations - for compatibility with GrowableArray only */ \ - int capacity() const { return size(); } \ - void clear() { truncate(0); } \ - void trunc_to(const int length) { truncate(length); } \ - int append(const etype x) { return push(x); } \ - void appendAll(const stack_name* stack) { push_all(stack); } \ - etype last() const { return top(); } \ - }; \ - - -#define define_resource_list(element_type) \ - define_generic_array(element_type##Array, element_type, ResourceArray) \ - define_stack(element_type##List, element_type##Array) - -#define define_resource_pointer_list(element_type) \ - define_generic_array(element_type##Array, element_type *, ResourceArray) \ - define_stack(element_type##List, element_type##Array) - -#define define_c_heap_list(element_type) \ - define_generic_array(element_type##Array, element_type, CHeapArray) \ - define_stack(element_type##List, element_type##Array) - -#define define_c_heap_pointer_list(element_type) \ - define_generic_array(element_type##Array, element_type *, CHeapArray) \ - define_stack(element_type##List, element_type##Array) - - // Arrays for basic types - -define_array(boolArray, bool) define_stack(boolStack, boolArray) -define_array(intArray , int ) define_stack(intStack , intArray ) +typedef GrowableArray intArray; +typedef GrowableArray intStack; +typedef GrowableArray boolArray; +typedef GrowableArray boolStack; // Array for metadata allocation diff --git a/hotspot/src/share/vm/utilities/growableArray.hpp b/hotspot/src/share/vm/utilities/growableArray.hpp index a2780fecca5..00d404b8859 100644 --- a/hotspot/src/share/vm/utilities/growableArray.hpp +++ b/hotspot/src/share/vm/utilities/growableArray.hpp @@ -250,6 +250,10 @@ template class GrowableArray : public GenericGrowableArray { return _data[_len-1]; } + E last() const { + return top(); + } + GrowableArrayIterator begin() const { return GrowableArrayIterator(this, 0); } @@ -363,6 +367,24 @@ template class GrowableArray : public GenericGrowableArray { _data[idx] = elem; } + void insert_before(const int idx, const GrowableArray* array) { + assert(0 <= idx && idx <= _len, "illegal index"); + check_nesting(); + int array_len = array->length(); + int new_len = _len + array_len; + if (new_len >= _max) grow(new_len); + + for (int j = _len - 1; j >= idx; j--) { + _data[j + array_len] = _data[j]; + } + + for (int j = 0; j < array_len; j++) { + _data[idx + j] = array->_data[j]; + } + + _len += array_len; + } + void appendAll(const GrowableArray* l) { for (int i = 0; i < l->_len; i++) { raw_at_put_grow(_len, l->_data[i], E()); -- GitLab From 8215de72f596936fcde48f4407d26069cdf80c83 Mon Sep 17 00:00:00 2001 From: Fei Yang Date: Tue, 12 Apr 2016 11:53:44 +0800 Subject: [PATCH 130/400] 8153713: aarch64: improve short array clearing using store pair Aarch64: generate store pair instruction to clear short arrays Reviewed-by: aph --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 14 ++++++++ .../src/cpu/aarch64/vm/globals_aarch64.hpp | 3 +- .../cpu/aarch64/vm/macroAssembler_aarch64.cpp | 33 +++++++++++++++++++ .../cpu/aarch64/vm/macroAssembler_aarch64.hpp | 1 + 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index 499a2d0013e..47c83025cb7 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -13321,6 +13321,20 @@ instruct clearArray_reg_reg(iRegL_R11 cnt, iRegP_R10 base, Universe dummy, rFlag ins_pipe(pipe_class_memory); %} +instruct clearArray_imm_reg(immL cnt, iRegP base, Universe dummy, rFlagsReg cr) +%{ + match(Set dummy (ClearArray cnt base)); + + ins_cost(4 * INSN_COST); + format %{ "ClearArray $cnt, $base" %} + + ins_encode %{ + __ zero_words($base$$Register, (u_int64_t)$cnt$$constant); + %} + + ins_pipe(pipe_class_memory); +%} + // ============================================================================ // Overflow Math Instructions diff --git a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp index 60edc02fc2a..5bd7424d4b8 100644 --- a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp @@ -76,7 +76,8 @@ define_pd_global(bool, CompactStrings, false); // avoid biased locking while we are bootstrapping the aarch64 build define_pd_global(bool, UseBiasedLocking, false); -define_pd_global(intx, InitArrayShortSize, 18*BytesPerLong); +// Clear short arrays bigger than one word in an arch-specific way +define_pd_global(intx, InitArrayShortSize, BytesPerLong); #if defined(COMPILER1) || defined(COMPILER2) define_pd_global(intx, InlineSmallCode, 1000); diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp index cb87e7d4887..cf823e4a020 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp @@ -4677,6 +4677,39 @@ void MacroAssembler::zero_words(Register base, Register cnt) fill_words(base, cnt, zr); } +// base: Address of a buffer to be zeroed, 8 bytes aligned. +// cnt: Immediate count in 8-byte unit. +#define ShortArraySize (18 * BytesPerLong) +void MacroAssembler::zero_words(Register base, u_int64_t cnt) +{ + int i = cnt & 1; // store any odd word to start + if (i) str(zr, Address(base)); + + if (cnt <= ShortArraySize / BytesPerLong) { + for (; i < (int)cnt; i += 2) + stp(zr, zr, Address(base, i * wordSize)); + } else { + const int unroll = 4; // Number of stp(zr, zr) instructions we'll unroll + int remainder = cnt % (2 * unroll); + for (; i < remainder; i += 2) + stp(zr, zr, Address(base, i * wordSize)); + + Label loop; + Register cnt_reg = rscratch1; + Register loop_base = rscratch2; + cnt = cnt - remainder; + mov(cnt_reg, cnt); + // adjust base and prebias by -2 * wordSize so we can pre-increment + add(loop_base, base, (remainder - 2) * wordSize); + bind(loop); + sub(cnt_reg, cnt_reg, 2 * unroll); + for (i = 1; i < unroll; i++) + stp(zr, zr, Address(loop_base, 2 * i * wordSize)); + stp(zr, zr, Address(pre(loop_base, 2 * unroll * wordSize))); + cbnz(cnt_reg, loop); + } +} + // base: Address of a buffer to be filled, 8 bytes aligned. // cnt: Count in 8-byte unit. // value: Value to be filled with. diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp index da989486e98..4a16a2032f8 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp @@ -1186,6 +1186,7 @@ public: void fill_words(Register base, Register cnt, Register value); void zero_words(Register base, Register cnt); + void zero_words(Register base, u_int64_t cnt); void encode_iso_array(Register src, Register dst, Register len, Register result, -- GitLab From a74ee72e1e348787fd5ea7ccef689b7dbc345126 Mon Sep 17 00:00:00 2001 From: Nils Eliasson Date: Tue, 12 Apr 2016 11:29:08 +0200 Subject: [PATCH 131/400] 8153885: [TESTBUG] few regression tests failed after 8151880 changes Test that uses compile() as missed in update Reviewed-by: kvn --- .../compiler/tiered/ConstantGettersTransitionsTest.java | 4 ++-- hotspot/test/compiler/tiered/LevelTransitionTest.java | 4 ++-- hotspot/test/compiler/tiered/NonTieredLevelsTest.java | 8 ++++---- hotspot/test/compiler/tiered/TieredLevelsTest.java | 6 +++--- hotspot/test/compiler/whitebox/LockCompilationTest.java | 2 +- .../test/compiler/whitebox/SetDontInlineMethodTest.java | 2 +- .../test/compiler/whitebox/SetForceInlineMethodTest.java | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java b/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java index 180848ab275..65a04ba4376 100644 --- a/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java +++ b/hotspot/test/compiler/tiered/ConstantGettersTransitionsTest.java @@ -31,9 +31,9 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @modules java.base/sun.misc * java.management * @build TransitionsTestExecutor ConstantGettersTransitionsTest - * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI -XX:+TieredCompilation + * -XX:+WhiteBoxAPI -XX:+TieredCompilation -XX:-UseCounterDecay * -XX:CompileCommand=compileonly,ConstantGettersTestCase$TrivialMethods::* * TransitionsTestExecutor ConstantGettersTransitionsTest * @summary Test the correctness of compilation level transitions for constant getters methods diff --git a/hotspot/test/compiler/tiered/LevelTransitionTest.java b/hotspot/test/compiler/tiered/LevelTransitionTest.java index c3b80504619..61e3eda60cb 100644 --- a/hotspot/test/compiler/tiered/LevelTransitionTest.java +++ b/hotspot/test/compiler/tiered/LevelTransitionTest.java @@ -38,7 +38,7 @@ import compiler.whitebox.SimpleTestCase; * @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+WhiteBoxAPI -XX:+TieredCompilation - * -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* + * -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* * -XX:CompileCommand=compileonly,ExtendedTestCase$CompileMethodHolder::* * TransitionsTestExecutor LevelTransitionTest * @summary Test the correctness of compilation level transitions for different methods @@ -80,7 +80,7 @@ public class LevelTransitionTest extends TieredLevelsTest { /** * Makes and verifies transitions between compilation levels */ - protected void checkTransitions() { + protected void checkTransitions() throws Exception { checkNotCompiled(); boolean finish = false; while (!finish) { diff --git a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java index 4a1a52e7219..101ad492c27 100644 --- a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java +++ b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java @@ -29,11 +29,11 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @library /testlibrary /test/lib /compiler/whitebox / * @modules java.management * @build NonTieredLevelsTest - * @run main ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm -Xbootclasspath/a:. -XX:-TieredCompilation - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay + * -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* * NonTieredLevelsTest * @summary Verify that only one level can be used * @author igor.ignatyev@oracle.com diff --git a/hotspot/test/compiler/tiered/TieredLevelsTest.java b/hotspot/test/compiler/tiered/TieredLevelsTest.java index 0790b195134..68dc01071e1 100644 --- a/hotspot/test/compiler/tiered/TieredLevelsTest.java +++ b/hotspot/test/compiler/tiered/TieredLevelsTest.java @@ -28,11 +28,11 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @library /testlibrary /test/lib /compiler/whitebox / * @modules java.management * @build TieredLevelsTest - * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm -Xbootclasspath/a:. -XX:+TieredCompilation - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:-UseCounterDecay + * -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* * TieredLevelsTest * @summary Verify that all levels < 'TieredStopAtLevel' can be used * @author igor.ignatyev@oracle.com diff --git a/hotspot/test/compiler/whitebox/LockCompilationTest.java b/hotspot/test/compiler/whitebox/LockCompilationTest.java index 7a3d9fcbaff..7aae5bfe17a 100644 --- a/hotspot/test/compiler/whitebox/LockCompilationTest.java +++ b/hotspot/test/compiler/whitebox/LockCompilationTest.java @@ -47,7 +47,7 @@ public class LockCompilationTest extends CompilerWhiteBoxTest { // This case waits for 5 seconds and verifies that the method hasn't been // compiled during that time. Only do that for one of the test cases. - // Only compile SimpleTestCase$Helper.method and exclude all other to ensure no + // Only compile SimpleTestCaseHelper.method and exclude all other to ensure no // contention on the compile queue causes problems. String directive = "[{ match:\"*SimpleTestCaseHelper.method\", Exclude:false}, " + diff --git a/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java b/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java index 94846dec932..fb2a8bdd8f8 100644 --- a/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java +++ b/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java @@ -31,7 +31,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @build SetDontInlineMethodTest * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* SetDontInlineMethodTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* SetDontInlineMethodTest * @summary testing of WB::testSetDontInlineMethod() * @author igor.ignatyev@oracle.com */ diff --git a/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java b/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java index 497e8948e91..55856c259d3 100644 --- a/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java +++ b/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java @@ -31,7 +31,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @build SetForceInlineMethodTest * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCase$Helper::* SetForceInlineMethodTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,compiler.whitebox.SimpleTestCaseHelper::* SetForceInlineMethodTest * @summary testing of WB::testSetForceInlineMethod() * @author igor.ignatyev@oracle.com */ -- GitLab From eb6d600333d93ede58e75814e267254fbe7554a8 Mon Sep 17 00:00:00 2001 From: Igor Veresov Date: Tue, 12 Apr 2016 14:55:18 -0700 Subject: [PATCH 132/400] 8153115: Move private interface check to linktime Check for private interface methods during linktime instead of runtime Reviewed-by: kvn, never, coleenp, acorn, lfoltan --- .../src/share/vm/interpreter/linkResolver.cpp | 41 ++++++++++--------- .../src/share/vm/interpreter/linkResolver.hpp | 2 +- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/hotspot/src/share/vm/interpreter/linkResolver.cpp b/hotspot/src/share/vm/interpreter/linkResolver.cpp index eb29da892a6..d4b494a6598 100644 --- a/hotspot/src/share/vm/interpreter/linkResolver.cpp +++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp @@ -612,14 +612,13 @@ methodHandle LinkResolver::resolve_method_statically(Bytecodes::Code code, } if (code == Bytecodes::_invokeinterface) { - return resolve_interface_method(link_info, true, THREAD); + return resolve_interface_method(link_info, code, THREAD); } else if (code == Bytecodes::_invokevirtual) { return resolve_method(link_info, /*require_methodref*/true, THREAD); } else if (!resolved_klass->is_interface()) { return resolve_method(link_info, /*require_methodref*/false, THREAD); } else { - bool nostatics = (code == Bytecodes::_invokestatic) ? false : true; - return resolve_interface_method(link_info, nostatics, THREAD); + return resolve_interface_method(link_info, code, THREAD); } } @@ -777,8 +776,8 @@ static void trace_method_resolution(const char* prefix, #endif // PRODUCT } -methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, - bool nostatics, TRAPS) { +// Do linktime resolution of a method in the interface within the context of the specied bytecode. +methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS) { KlassHandle resolved_klass = link_info.resolved_klass(); @@ -824,7 +823,7 @@ methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, check_method_loader_constraints(link_info, resolved_method, "interface method", CHECK_NULL); } - if (nostatics && resolved_method->is_static()) { + if (code != Bytecodes::_invokestatic && resolved_method->is_static()) { ResourceMark rm(THREAD); char buf[200]; jio_snprintf(buf, sizeof(buf), "Expected instance not static method %s", @@ -833,6 +832,19 @@ methodHandle LinkResolver::resolve_interface_method(const LinkInfo& link_info, THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } + if (code == Bytecodes::_invokeinterface && resolved_method->is_private()) { + ResourceMark rm(THREAD); + char buf[200]; + + KlassHandle current_klass = link_info.current_klass(); + jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s, caller-class:%s", + Method::name_and_sig_as_C_string(resolved_klass(), + resolved_method->name(), + resolved_method->signature()), + (current_klass.is_null() ? "" : current_klass->internal_name())); + THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); + } + if (log_develop_is_enabled(Trace, itables)) { trace_method_resolution("invokeinterface resolved method: caller-class", link_info.current_klass(), resolved_klass, @@ -984,7 +996,7 @@ methodHandle LinkResolver::linktime_resolve_static_method(const LinkInfo& link_i if (!resolved_klass->is_interface()) { resolved_method = resolve_method(link_info, /*require_methodref*/false, CHECK_NULL); } else { - resolved_method = resolve_interface_method(link_info, /*nostatics*/false, CHECK_NULL); + resolved_method = resolve_interface_method(link_info, Bytecodes::_invokestatic, CHECK_NULL); } assert(resolved_method->name() != vmSymbols::class_initializer_name(), "should have been checked in verifier"); @@ -1027,7 +1039,7 @@ methodHandle LinkResolver::linktime_resolve_special_method(const LinkInfo& link_ if (!resolved_klass->is_interface()) { resolved_method = resolve_method(link_info, /*require_methodref*/false, CHECK_NULL); } else { - resolved_method = resolve_interface_method(link_info, /*nostatics*/true, CHECK_NULL); + resolved_method = resolve_interface_method(link_info, Bytecodes::_invokespecial, CHECK_NULL); } // check if method name is , that it is found in same klass as static type @@ -1302,7 +1314,7 @@ void LinkResolver::resolve_interface_call(CallInfo& result, Handle recv, KlassHa methodHandle LinkResolver::linktime_resolve_interface_method(const LinkInfo& link_info, TRAPS) { // normal interface method resolution - methodHandle resolved_method = resolve_interface_method(link_info, true, CHECK_NULL); + methodHandle resolved_method = resolve_interface_method(link_info, Bytecodes::_invokeinterface, CHECK_NULL); assert(resolved_method->name() != vmSymbols::object_initializer_name(), "should have been checked in verifier"); assert(resolved_method->name() != vmSymbols::class_initializer_name (), "should have been checked in verifier"); @@ -1321,17 +1333,6 @@ void LinkResolver::runtime_resolve_interface_method(CallInfo& result, THROW(vmSymbols::java_lang_NullPointerException()); } - // check if private interface method - if (resolved_klass->is_interface() && resolved_method->is_private()) { - ResourceMark rm(THREAD); - char buf[200]; - jio_snprintf(buf, sizeof(buf), "private interface method requires invokespecial, not invokeinterface: method %s", - Method::name_and_sig_as_C_string(resolved_klass(), - resolved_method->name(), - resolved_method->signature())); - THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); - } - // check if receiver klass implements the resolved interface if (!recv_klass->is_subtype_of(resolved_klass())) { ResourceMark rm(THREAD); diff --git a/hotspot/src/share/vm/interpreter/linkResolver.hpp b/hotspot/src/share/vm/interpreter/linkResolver.hpp index a197070dadd..d7aab536a29 100644 --- a/hotspot/src/share/vm/interpreter/linkResolver.hpp +++ b/hotspot/src/share/vm/interpreter/linkResolver.hpp @@ -192,7 +192,7 @@ class LinkResolver: AllStatic { KlassHandle current_klass, KlassHandle sel_klass, TRAPS); - static methodHandle resolve_interface_method(const LinkInfo& link_info, bool nostatics, TRAPS); + static methodHandle resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS); static methodHandle resolve_method (const LinkInfo& link_info, bool require_methodref, TRAPS); static methodHandle linktime_resolve_static_method (const LinkInfo& link_info, TRAPS); -- GitLab From e33bf847542863f8ce3cfae3574046cc6b41d85e Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Tue, 12 Apr 2016 17:12:51 -0700 Subject: [PATCH 133/400] 8153818: Move similar CompiledIC platform specific code to shared code Reviewed-by: iveresov, twisti --- .../src/cpu/aarch64/vm/compiledIC_aarch64.cpp | 18 +----------------- hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp | 18 +----------------- hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp | 18 +----------------- hotspot/src/cpu/x86/vm/compiledIC_x86.cpp | 18 +----------------- hotspot/src/cpu/zero/vm/compiledIC_zero.cpp | 18 +----------------- hotspot/src/share/vm/code/compiledIC.cpp | 16 ++++++++++++++++ 6 files changed, 21 insertions(+), 85 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/compiledIC_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/compiledIC_aarch64.cpp index 103b936b5b4..bd4e55a5151 100644 --- a/hotspot/src/cpu/aarch64/vm/compiledIC_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/compiledIC_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -32,22 +32,6 @@ #include "runtime/mutexLocker.hpp" #include "runtime/safepoint.hpp" -// Release the CompiledICHolder* associated with this call site is there is one. -void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) { - // This call site might have become stale so inspect it carefully. - NativeCall* call = nativeCall_at(call_site->addr()); - if (is_icholder_entry(call->destination())) { - NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value()); - InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data()); - } -} - -bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) { - // This call site might have become stale so inspect it carefully. - NativeCall* call = nativeCall_at(call_site->addr()); - return is_icholder_entry(call->destination()); -} - // ---------------------------------------------------------------------------- #define __ _masm. diff --git a/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp b/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp index 68dabc4b031..e50399de682 100644 --- a/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/compiledIC_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -35,22 +35,6 @@ #include "opto/matcher.hpp" #endif -// Release the CompiledICHolder* associated with this call site is there is one. -void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) { - // This call site might have become stale so inspect it carefully. - NativeCall* call = nativeCall_at(call_site->addr()); - if (is_icholder_entry(call->destination())) { - NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value()); - InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data()); - } -} - -bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) { - // This call site might have become stale so inspect it carefully. - NativeCall* call = nativeCall_at(call_site->addr()); - return is_icholder_entry(call->destination()); -} - // ---------------------------------------------------------------------------- // A PPC CompiledStaticCall looks like this: diff --git a/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp b/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp index d56af1661b1..c544e7ae994 100644 --- a/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/compiledIC_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,22 +34,6 @@ #include "opto/matcher.hpp" #endif -// Release the CompiledICHolder* associated with this call site is there is one. -void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) { - // This call site might have become stale so inspect it carefully. - NativeCall* call = nativeCall_at(call_site->addr()); - if (is_icholder_entry(call->destination())) { - NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value()); - InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data()); - } -} - -bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) { - // This call site might have become stale so inspect it carefully. - NativeCall* call = nativeCall_at(call_site->addr()); - return is_icholder_entry(call->destination()); -} - // ---------------------------------------------------------------------------- #define __ _masm. diff --git a/hotspot/src/cpu/x86/vm/compiledIC_x86.cpp b/hotspot/src/cpu/x86/vm/compiledIC_x86.cpp index 865e149331c..6d4c06f19ff 100644 --- a/hotspot/src/cpu/x86/vm/compiledIC_x86.cpp +++ b/hotspot/src/cpu/x86/vm/compiledIC_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,22 +31,6 @@ #include "runtime/mutexLocker.hpp" #include "runtime/safepoint.hpp" -// Release the CompiledICHolder* associated with this call site is there is one. -void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) { - // This call site might have become stale so inspect it carefully. - NativeCall* call = nativeCall_at(call_site->addr()); - if (is_icholder_entry(call->destination())) { - NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value()); - InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data()); - } -} - -bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) { - // This call site might have become stale so inspect it carefully. - NativeCall* call = nativeCall_at(call_site->addr()); - return is_icholder_entry(call->destination()); -} - // ---------------------------------------------------------------------------- #define __ _masm. diff --git a/hotspot/src/cpu/zero/vm/compiledIC_zero.cpp b/hotspot/src/cpu/zero/vm/compiledIC_zero.cpp index bc3e3624e3d..8f912db7bf9 100644 --- a/hotspot/src/cpu/zero/vm/compiledIC_zero.cpp +++ b/hotspot/src/cpu/zero/vm/compiledIC_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,22 +42,6 @@ #include "utilities/events.hpp" -// Release the CompiledICHolder* associated with this call site is there is one. -void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) { - // This call site might have become stale so inspect it carefully. - NativeCall* call = nativeCall_at(call_site->addr()); - if (is_icholder_entry(call->destination())) { - NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value()); - InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data()); - } -} - -bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) { - // This call site might have become stale so inspect it carefully. - NativeCall* call = nativeCall_at(call_site->addr()); - return is_icholder_entry(call->destination()); -} - // ---------------------------------------------------------------------------- address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) { diff --git a/hotspot/src/share/vm/code/compiledIC.cpp b/hotspot/src/share/vm/code/compiledIC.cpp index f3808bd041b..994ea6447c8 100644 --- a/hotspot/src/share/vm/code/compiledIC.cpp +++ b/hotspot/src/share/vm/code/compiledIC.cpp @@ -533,6 +533,22 @@ bool CompiledIC::is_icholder_entry(address entry) { return (cb != NULL && cb->is_adapter_blob()); } +// Release the CompiledICHolder* associated with this call site is there is one. +void CompiledIC::cleanup_call_site(virtual_call_Relocation* call_site) { + // This call site might have become stale so inspect it carefully. + NativeCall* call = nativeCall_at(call_site->addr()); + if (is_icholder_entry(call->destination())) { + NativeMovConstReg* value = nativeMovConstReg_at(call_site->cached_value()); + InlineCacheBuffer::queue_for_release((CompiledICHolder*)value->data()); + } +} + +bool CompiledIC::is_icholder_call_site(virtual_call_Relocation* call_site) { + // This call site might have become stale so inspect it carefully. + NativeCall* call = nativeCall_at(call_site->addr()); + return is_icholder_entry(call->destination()); +} + // ---------------------------------------------------------------------------- void CompiledStaticCall::set_to_clean() { -- GitLab From 82dc0d42a64b435af40e09b8eb5733b9f746aca1 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Wed, 13 Apr 2016 18:31:43 +0300 Subject: [PATCH 134/400] 8140354: Unquarantine tests that failed with OutOfMemoryError Unquarantine CompilerControl tests Reviewed-by: iignatyev --- hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java | 1 - hotspot/test/compiler/compilercontrol/commands/PrintTest.java | 1 - hotspot/test/compiler/compilercontrol/directives/PrintTest.java | 1 - .../test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java | 1 - .../compiler/compilercontrol/mixed/RandomValidCommandsTest.java | 1 - 5 files changed, 5 deletions(-) diff --git a/hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java b/hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java index 5e90521eabf..97cf7e861d1 100644 --- a/hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java +++ b/hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java @@ -26,7 +26,6 @@ * @bug 8137167 * @summary Tests CompileCommand=print * @library /testlibrary /test/lib /compiler/testlibrary ../share / - * @ignore 8140354 * @build compiler.compilercontrol.commandfile.PrintTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox * compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.* diff --git a/hotspot/test/compiler/compilercontrol/commands/PrintTest.java b/hotspot/test/compiler/compilercontrol/commands/PrintTest.java index d9ac685ca8f..2e414494c1e 100644 --- a/hotspot/test/compiler/compilercontrol/commands/PrintTest.java +++ b/hotspot/test/compiler/compilercontrol/commands/PrintTest.java @@ -26,7 +26,6 @@ * @bug 8137167 * @summary Tests CompileCommand=print * @library /testlibrary /test/lib /compiler/testlibrary ../share / - * @ignore 8140354 * @build compiler.compilercontrol.commands.PrintTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox * compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.* diff --git a/hotspot/test/compiler/compilercontrol/directives/PrintTest.java b/hotspot/test/compiler/compilercontrol/directives/PrintTest.java index bbd92c1704b..7c0009f26bb 100644 --- a/hotspot/test/compiler/compilercontrol/directives/PrintTest.java +++ b/hotspot/test/compiler/compilercontrol/directives/PrintTest.java @@ -26,7 +26,6 @@ * @bug 8137167 * @summary Tests directives to be able to turn on print_assembly * @library /testlibrary /test/lib /compiler/testlibrary ../share / - * @ignore 8140354 * @build compiler.compilercontrol.directives.PrintTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox * compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.* diff --git a/hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java b/hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java index 7afd4d6f8b3..2c7ebef9389 100644 --- a/hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java +++ b/hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java @@ -26,7 +26,6 @@ * @bug 8137167 * @summary Tests jcmd to be able to add a directive to compile only specified methods * @library /testlibrary /test/lib /compiler/testlibrary ../share / - * @ignore 8140354 * @build compiler.compilercontrol.jcmd.PrintDirectivesTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox * compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.* diff --git a/hotspot/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java b/hotspot/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java index e8739e8abde..c918320d4fe 100644 --- a/hotspot/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java +++ b/hotspot/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java @@ -26,7 +26,6 @@ * @bug 8137167 * @summary Randomly generates valid commands with random types * @library /testlibrary /test/lib /compiler/testlibrary ../share / - * @ignore 8140354 * @build compiler.compilercontrol.mixed.RandomValidCommandsTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox * compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.* -- GitLab From 792ccb505612a4551f08b1d7b6d1ea68077933c1 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Wed, 13 Apr 2016 18:56:51 +0300 Subject: [PATCH 135/400] 8153852: [jittester] move TypeUtil to utils package Rewrite TypeUtil and move to utils package Reviewed-by: kvn --- .../src/jdk/test/lib/jittester/TypeUtil.java | 85 ------------------ .../AssignmentOperatorImplFactory.java | 2 +- .../BinaryArithmeticOperatorFactory.java | 2 +- .../BinaryBitwiseOperatorFactory.java | 2 +- .../factories/BinaryShiftOperatorFactory.java | 2 +- .../BitwiseInversionOperatorFactory.java | 2 +- .../lib/jittester/factories/BlockFactory.java | 2 +- ...ndArithmeticAssignmentOperatorFactory.java | 2 +- ...poundBitwiseAssignmentOperatorFactory.java | 2 +- ...ompoundShiftAssignmentOperatorFactory.java | 2 +- .../factories/CounterInitializerFactory.java | 4 +- .../jittester/factories/SwitchFactory.java | 12 +-- .../factories/TernaryOperatorFactory.java | 2 +- .../factories/TryCatchBlockFactory.java | 2 +- .../UnaryPlusMinusOperatorFactory.java | 2 +- .../test/lib/jittester/utils/TypeUtil.java | 88 +++++++++++++++++++ 16 files changed, 108 insertions(+), 105 deletions(-) delete mode 100644 hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TypeUtil.java create mode 100644 hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/TypeUtil.java diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TypeUtil.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TypeUtil.java deleted file mode 100644 index 181d0a52b9b..00000000000 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/TypeUtil.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.test.lib.jittester; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; - - -public class TypeUtil { - - public static Collection getImplicitlyCastable(Collection types, Type type) { - ArrayList result = new ArrayList<>(types); - Iterator iterator = result.iterator(); - while (iterator.hasNext()) { - if (!iterator.next().canImplicitlyCastTo(type)) { - iterator.remove(); - } - } - return result; - } - - public static Collection getExplicitlyCastable(Collection types, Type type) { - ArrayList result = new ArrayList<>(types); - Iterator iterator = result.iterator(); - while (iterator.hasNext()) { - if (!iterator.next().canExplicitlyCastTo(type)) { - iterator.remove(); - } - } - return result; - } - - public static List getMoreCapatiousThan(Collection types, BuiltInType type) { - ArrayList result = new ArrayList<>(); - Iterator iterator = types.iterator(); - while (iterator.hasNext()) { - try { - BuiltInType builtInType = (BuiltInType) iterator.next(); - if (builtInType.isMoreCapaciousThan(type)) { - result.add(builtInType); - } - } catch (Exception e) { - } - } - return result; - } - - public static List getLessCapatiousOrEqualThan(Collection types, BuiltInType type) { - ArrayList result = new ArrayList<>(); - Iterator iterator = types.iterator(); - while (iterator.hasNext()) { - try { - BuiltInType builtInType = (BuiltInType) iterator.next(); - if (!builtInType.isMoreCapaciousThan(type) || builtInType.equals(type)) { - result.add(builtInType); - } - } catch (Exception e) { - } - } - return result; - } -} diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorImplFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorImplFactory.java index 2658be21303..d5ce37986b3 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorImplFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/AssignmentOperatorImplFactory.java @@ -31,7 +31,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Rule; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.VariableBase; import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.types.TypeKlass; diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java index 96f9e1842a6..b51cec7cf5b 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryArithmeticOperatorFactory.java @@ -29,7 +29,7 @@ import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryBitwiseOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryBitwiseOperatorFactory.java index 288eac1814f..6479644db7c 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryBitwiseOperatorFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryBitwiseOperatorFactory.java @@ -28,7 +28,7 @@ import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.types.TypeKlass; diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryShiftOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryShiftOperatorFactory.java index 81ffbd9cece..d5c74e2c976 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryShiftOperatorFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BinaryShiftOperatorFactory.java @@ -28,11 +28,11 @@ import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; import jdk.test.lib.jittester.types.TypeInt; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.types.TypeLong; import jdk.test.lib.jittester.utils.PseudoRandom; +import jdk.test.lib.jittester.utils.TypeUtil; class BinaryShiftOperatorFactory extends BinaryOperatorFactory { BinaryShiftOperatorFactory(OperatorKind opKind, long complexityLimit, int operatorLimit, diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseInversionOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseInversionOperatorFactory.java index 6ed509f6728..bad0bab3a8a 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseInversionOperatorFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BitwiseInversionOperatorFactory.java @@ -28,7 +28,7 @@ import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.UnaryOperator; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.types.TypeInt; diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java index a47f4ae36cb..37b6072e123 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/BlockFactory.java @@ -33,7 +33,7 @@ import jdk.test.lib.jittester.Switch; import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.loops.DoWhile; import jdk.test.lib.jittester.loops.For; import jdk.test.lib.jittester.loops.While; diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundArithmeticAssignmentOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundArithmeticAssignmentOperatorFactory.java index a8d934c254a..e170ff5c2e6 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundArithmeticAssignmentOperatorFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundArithmeticAssignmentOperatorFactory.java @@ -30,7 +30,7 @@ import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundBitwiseAssignmentOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundBitwiseAssignmentOperatorFactory.java index 1752b0c5c77..b61d23f9519 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundBitwiseAssignmentOperatorFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundBitwiseAssignmentOperatorFactory.java @@ -30,7 +30,7 @@ import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundShiftAssignmentOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundShiftAssignmentOperatorFactory.java index 286b6d719ff..901bf438a4f 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundShiftAssignmentOperatorFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CompoundShiftAssignmentOperatorFactory.java @@ -30,7 +30,7 @@ import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.utils.PseudoRandom; diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterInitializerFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterInitializerFactory.java index 8892901b98a..9112bc124d7 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterInitializerFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/CounterInitializerFactory.java @@ -30,7 +30,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.VariableInfo; import jdk.test.lib.jittester.loops.CounterInitializer; import jdk.test.lib.jittester.types.TypeKlass; @@ -48,7 +48,7 @@ class CounterInitializerFactory extends SafeFactory { @Override protected IRNode sproduce() throws ProductionFailedException { - List types = TypeUtil.getMoreCapatiousThan(TypeList.getBuiltIn(), new TypeInt()); + List types = TypeUtil.getMoreCapaciousThan(TypeList.getBuiltIn(), new TypeInt()); types.add(new TypeInt()); final Type selectedType = PseudoRandom.randomElement(types); IRNode init = new LiteralInitializer(counterValue, selectedType); diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SwitchFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SwitchFactory.java index 8ee2ecf67ca..a1052ced09c 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SwitchFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/SwitchFactory.java @@ -34,7 +34,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Rule; import jdk.test.lib.jittester.Switch; import jdk.test.lib.jittester.Type; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.types.TypeByte; import jdk.test.lib.jittester.types.TypeChar; @@ -63,7 +63,7 @@ class SwitchFactory extends SafeFactory { @Override protected IRNode sproduce() throws ProductionFailedException { if (statementLimit > 0 && complexityLimit > 0) { - ArrayList switchTypes = new ArrayList<>(); + List switchTypes = new ArrayList<>(); switchTypes.add(new TypeChar()); switchTypes.add(new TypeByte()); switchTypes.add(new TypeShort()); @@ -78,8 +78,8 @@ class SwitchFactory extends SafeFactory { .setCanHaveReturn(canHaveReturn); MAIN_LOOP: for (Type type : switchTypes) { - ArrayList caseConsts = new ArrayList<>(); - ArrayList caseBlocks = new ArrayList<>(); + List caseConsts = new ArrayList<>(); + List caseBlocks = new ArrayList<>(); try { int accumulatedStatements = 0; int currentStatementsLimit = 0; @@ -94,10 +94,10 @@ class SwitchFactory extends SafeFactory { .getLimitedExpressionFactory() .produce(); accumulatedComplexity += currentComplexityLimit; - ArrayList caseTypes = new ArrayList<>(); + List caseTypes = new ArrayList<>(); caseTypes.add(new TypeByte()); caseTypes.add(new TypeChar()); - caseTypes = new ArrayList<>(TypeUtil.getLessCapatiousOrEqualThan(caseTypes, + caseTypes = new ArrayList<>(TypeUtil.getLessCapaciousOrEqualThan(caseTypes, (BuiltInType) type)); if (PseudoRandom.randomBoolean()) { // "default" currentStatementsLimit = (int) (PseudoRandom.random() diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TernaryOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TernaryOperatorFactory.java index 5060736bd21..24e05e40d2e 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TernaryOperatorFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TernaryOperatorFactory.java @@ -30,7 +30,7 @@ import jdk.test.lib.jittester.SymbolTable; import jdk.test.lib.jittester.TernaryOperator; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.utils.PseudoRandom; diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java index dea0c9325f6..523bfb5d0c4 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/TryCatchBlockFactory.java @@ -31,7 +31,7 @@ import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.TryCatchBlock; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.types.TypeKlass; import jdk.test.lib.jittester.utils.PseudoRandom; diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryPlusMinusOperatorFactory.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryPlusMinusOperatorFactory.java index 79b0e23a7dd..12e5e982b2c 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryPlusMinusOperatorFactory.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/factories/UnaryPlusMinusOperatorFactory.java @@ -29,7 +29,7 @@ import jdk.test.lib.jittester.OperatorKind; import jdk.test.lib.jittester.ProductionFailedException; import jdk.test.lib.jittester.Type; import jdk.test.lib.jittester.TypeList; -import jdk.test.lib.jittester.TypeUtil; +import jdk.test.lib.jittester.utils.TypeUtil; import jdk.test.lib.jittester.UnaryOperator; import jdk.test.lib.jittester.types.TypeBoolean; import jdk.test.lib.jittester.types.TypeInt; diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/TypeUtil.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/TypeUtil.java new file mode 100644 index 00000000000..f9595de5d1b --- /dev/null +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/utils/TypeUtil.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.jittester.utils; + +import jdk.test.lib.jittester.BuiltInType; +import jdk.test.lib.jittester.Type; + +import java.util.Collection; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Utility functions for type system + */ +public class TypeUtil { + /** + * Gets a list of implicitly castable types to a given one from the collection of types + * + * @param types a collection to get types from + * @param type a target type which result type could be implicitly cast to + * @return a result collection of types that match given conditions + */ + public static Collection getImplicitlyCastable(Collection types, Type type) { + return types.stream() + .filter(t -> t.canImplicitlyCastTo(type)) + .collect(Collectors.toList()); + } + + /** + * Gets a list of explicitly castable types to a given one from the collection of types + * + * @param types a collection to get types from + * @param type a target type which result type could be explicitly cast to + * @return a result collection of types that match given conditions + */ + public static Collection getExplicitlyCastable(Collection types, Type type) { + return types.stream() + .filter(t -> t.canExplicitlyCastTo(type)) + .collect(Collectors.toList()); + } + + /** + * Gets a list of more capacious types than a given one from the collection of types + * + * @param types a collection to get types from + * @param type a type to filter given types by capacity + * @return a result collection of types that match given conditions + */ + public static List getMoreCapaciousThan(Collection types, BuiltInType type) { + return types.stream() + .filter(t -> ((BuiltInType) t).isMoreCapaciousThan(type)) + .collect(Collectors.toList()); + } + + /** + * Gets a list of less or equal capacious types than a given one from the collection of types + * + * @param types a collection to get types from + * @param type a type to filter given types by capacity + * @return a result collection of types that match given conditions + */ + public static List getLessCapaciousOrEqualThan(Collection types, BuiltInType type) { + return types.stream() + .filter(t -> !((BuiltInType) t).isMoreCapaciousThan(type) || t.equals(type)) + .collect(Collectors.toList()); + } +} -- GitLab From 63403a410edce4428d82ef119223c415b0f2e134 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Thu, 14 Apr 2016 08:32:39 +0200 Subject: [PATCH 136/400] 8154073: Several compiler tests fail when are executed with C1 only Added missing flag checks to the tests and Whitebox API. Reviewed-by: kvn --- .../src/share/vm/compiler/compileBroker.cpp | 1 + hotspot/src/share/vm/prims/whitebox.cpp | 3 ++- .../arraycopy/TestArrayCopyNoInitDeopt.java | 5 ++++- .../rangechecks/TestExplicitRangeChecks.java | 18 +++++++++--------- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index c4758b2e183..dc99350fd6f 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -1060,6 +1060,7 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, assert(osr_bci == InvocationEntryBci || (0 <= osr_bci && osr_bci < method->code_size()), "bci out of range"); assert(!method->is_abstract() && (osr_bci == InvocationEntryBci || !method->is_native()), "cannot compile abstract/native methods"); assert(!method->method_holder()->is_not_initialized(), "method holder must be initialized"); + assert(!TieredCompilation || comp_level <= TieredStopAtLevel, "Invalid compilation level"); // allow any levels for WhiteBox assert(WhiteBoxAPI || TieredCompilation || comp_level == CompLevel_highest_tier, "only CompLevel_highest_tier must be used in non-tiered"); // return quickly if possible diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index 5d4a05e77bf..2d3b2f4c04e 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -641,7 +641,8 @@ WB_END bool WhiteBox::compile_method(Method* method, int comp_level, int bci, Thread* THREAD) { // Screen for unavailable/bad comp level or null method - if (method == NULL || CompileBroker::compiler(comp_level) == NULL) { + if (method == NULL || comp_level > TieredStopAtLevel || + CompileBroker::compiler(comp_level) == NULL) { return false; } methodHandle mh(THREAD, method); diff --git a/hotspot/test/compiler/arraycopy/TestArrayCopyNoInitDeopt.java b/hotspot/test/compiler/arraycopy/TestArrayCopyNoInitDeopt.java index a2430dcf478..ccd2cfe1028 100644 --- a/hotspot/test/compiler/arraycopy/TestArrayCopyNoInitDeopt.java +++ b/hotspot/test/compiler/arraycopy/TestArrayCopyNoInitDeopt.java @@ -72,6 +72,7 @@ public class TestArrayCopyNoInitDeopt { } private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + private static final int TIERED_STOP_AT_LEVEL = WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue(); static boolean deoptimize(Method method, Object src_obj) throws Exception { for (int i = 0; i < 10; i++) { @@ -84,7 +85,9 @@ public class TestArrayCopyNoInitDeopt { } static public void main(String[] args) throws Exception { - if (Platform.isServer()) { + // Only execute if C2 is available + if (Platform.isServer() && + TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) { int[] src = new int[10]; Object src_obj = new Object(); Method method_m1 = TestArrayCopyNoInitDeopt.class.getMethod("m1", Object.class); diff --git a/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java b/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java index 0053ffac156..c4627213a49 100644 --- a/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java +++ b/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ * @bug 8073480 * @summary explicit range checks should be recognized by C2 * @library /testlibrary /test/lib /compiler/whitebox / - * @build TestExplicitRangeChecks + * @build TestExplicitRangeChecks * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller jdk.test.lib.Platform * @run main/othervm -ea -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI @@ -44,8 +44,10 @@ import sun.misc.Unsafe; import compiler.whitebox.CompilerWhiteBoxTest; public class TestExplicitRangeChecks { - - static int[] array = new int[10]; + private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + private static final int TIERED_STOP_AT_LEVEL = WHITE_BOX.getIntxVMFlag("TieredStopAtLevel").intValue(); + private static int[] array = new int[10]; + private static boolean success = true; @Retention(RetentionPolicy.RUNTIME) @interface Args { @@ -366,10 +368,6 @@ public class TestExplicitRangeChecks { return true; } - static boolean success = true; - - private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); - final HashMap tests = new HashMap<>(); { for (Method m : this.getClass().getDeclaredMethods()) { @@ -439,7 +437,9 @@ public class TestExplicitRangeChecks { System.out.println(name + " bad result for bad input " + bad[i]); success = false; } - if (Platform.isServer()) { + // Only perform these additional checks if C2 is available + if (Platform.isServer() && + TIERED_STOP_AT_LEVEL == CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION) { if (deoptimize && WHITE_BOX.isMethodCompiled(m)) { System.out.println(name + " not deoptimized on invalid access"); success = false; -- GitLab From cd3197f3416225908fdfa825f6d66d668e747300 Mon Sep 17 00:00:00 2001 From: Zoltan Majo Date: Fri, 15 Apr 2016 07:54:31 +0200 Subject: [PATCH 137/400] 8151708: C1 FastTLABRefill can allocate TLABs past the end of the heap Use branch instruction that checks xcc instead of icc. Reviewed-by: kvn, thartmann --- hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp index f6770b0c3db..7c3ffae60d0 100644 --- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp @@ -3257,12 +3257,12 @@ void MacroAssembler::eden_allocate( if (var_size_in_bytes->is_valid()) { // size is unknown at compile time cmp(free, var_size_in_bytes); - br(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case + brx(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case delayed()->add(obj, var_size_in_bytes, end); } else { // size is known at compile time cmp(free, con_size_in_bytes); - br(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case + brx(Assembler::lessUnsigned, false, Assembler::pn, slow_case); // if there is not enough space go the slow case delayed()->add(obj, con_size_in_bytes, end); } // Compare obj with the value at top_addr; if still equal, swap the value of -- GitLab From 611e659be106f08d4fced6f4bcafa4696e0a6948 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Thu, 7 Apr 2016 12:33:58 +0200 Subject: [PATCH 138/400] 8153267: nmethod's exception cache not multi-thread safe Reviewed-by: aph, jcm, kvn --- hotspot/src/share/vm/code/nmethod.cpp | 11 ++++++----- hotspot/src/share/vm/code/nmethod.hpp | 13 ++++++++----- hotspot/src/share/vm/runtime/vmStructs.cpp | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 77939f06e20..50e0f957217 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -313,7 +313,8 @@ bool ExceptionCache::match_exception_with_space(Handle exception) { address ExceptionCache::test_address(address addr) { - for (int i=0; inext() == NULL, "Must be null"); - if (exception_cache() != NULL) { - new_entry->set_next(exception_cache()); + ExceptionCache *ec = exception_cache(); + if (ec != NULL) { + new_entry->set_next(ec); } - set_exception_cache(new_entry); + release_set_exception_cache(new_entry); } void nmethod::clean_exception_cache(BoolObjectClosure* is_alive) { diff --git a/hotspot/src/share/vm/code/nmethod.hpp b/hotspot/src/share/vm/code/nmethod.hpp index 1a8c82cc335..cdbf58e011a 100644 --- a/hotspot/src/share/vm/code/nmethod.hpp +++ b/hotspot/src/share/vm/code/nmethod.hpp @@ -41,15 +41,16 @@ class ExceptionCache : public CHeapObj { Klass* _exception_type; address _pc[cache_size]; address _handler[cache_size]; - int _count; + volatile int _count; ExceptionCache* _next; address pc_at(int index) { assert(index >= 0 && index < count(),""); return _pc[index]; } void set_pc_at(int index, address a) { assert(index >= 0 && index < cache_size,""); _pc[index] = a; } address handler_at(int index) { assert(index >= 0 && index < count(),""); return _handler[index]; } void set_handler_at(int index, address a) { assert(index >= 0 && index < cache_size,""); _handler[index] = a; } - int count() { return _count; } - void increment_count() { _count++; } + int count() { return OrderAccess::load_acquire(&_count); } + // increment_count is only called under lock, but there may be concurrent readers. + void increment_count() { OrderAccess::release_store(&_count, _count + 1); } public: @@ -241,7 +242,7 @@ class nmethod : public CodeBlob { // counter is decreased (by 1) while sweeping. int _hotness_counter; - ExceptionCache *_exception_cache; + ExceptionCache * volatile _exception_cache; PcDescCache _pc_desc_cache; // These are used for compiled synchronized native methods to @@ -433,7 +434,7 @@ class nmethod : public CodeBlob { // flag accessing and manipulation bool is_in_use() const { return _state == in_use; } - bool is_alive() const { return _state == in_use || _state == not_entrant; } + bool is_alive() const { unsigned char s = _state; return s == in_use || s == not_entrant; } bool is_not_entrant() const { return _state == not_entrant; } bool is_zombie() const { return _state == zombie; } bool is_unloaded() const { return _state == unloaded; } @@ -576,8 +577,10 @@ public: void set_stack_traversal_mark(long l) { _stack_traversal_mark = l; } // Exception cache support + // Note: _exception_cache may be read concurrently. We rely on memory_order_consume here. ExceptionCache* exception_cache() const { return _exception_cache; } void set_exception_cache(ExceptionCache *ec) { _exception_cache = ec; } + void release_set_exception_cache(ExceptionCache *ec) { OrderAccess::release_store_ptr(&_exception_cache, ec); } address handler_for_exception_and_pc(Handle exception, address pc); void add_handler_for_exception_and_pc(Handle exception, address pc, address handler); void clean_exception_cache(BoolObjectClosure* is_alive); diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 8171bd9880c..f4f9c5ed358 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -962,7 +962,7 @@ typedef CompactHashtable SymbolCompactHashTable; nonstatic_field(nmethod, _stack_traversal_mark, long) \ nonstatic_field(nmethod, _compile_id, int) \ nonstatic_field(nmethod, _comp_level, int) \ - nonstatic_field(nmethod, _exception_cache, ExceptionCache*) \ + volatile_nonstatic_field(nmethod, _exception_cache, ExceptionCache*) \ \ unchecked_c2_static_field(Deoptimization, _trap_reason_name, void*) \ \ -- GitLab From 1f9273ca3b5f7cec2867c48b9a10446d40ed2d30 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Thu, 7 Apr 2016 16:51:21 +0200 Subject: [PATCH 139/400] 8153514: Whitebox API should allow compilation of Added Whitebox API method to trigger compilation of static initializer. Reviewed-by: zmajo, kvn, iignatyev --- test/lib/sun/hotspot/WhiteBox.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/lib/sun/hotspot/WhiteBox.java b/test/lib/sun/hotspot/WhiteBox.java index f2c85fb95a1..e706574359a 100644 --- a/test/lib/sun/hotspot/WhiteBox.java +++ b/test/lib/sun/hotspot/WhiteBox.java @@ -307,6 +307,11 @@ public class WhiteBox { Objects.requireNonNull(method); return enqueueMethodForCompilation0(method, compLevel, entry_bci); } + private native boolean enqueueInitializerForCompilation0(Class aClass, int compLevel); + public boolean enqueueInitializerForCompilation(Class aClass, int compLevel) { + Objects.requireNonNull(aClass); + return enqueueInitializerForCompilation0(aClass, compLevel); + } private native void clearMethodState0(Executable method); public void clearMethodState(Executable method) { Objects.requireNonNull(method); -- GitLab From c8593eff81390602da63c58edeec2b68d0355d62 Mon Sep 17 00:00:00 2001 From: Nils Eliasson Date: Mon, 18 Apr 2016 11:30:10 +0200 Subject: [PATCH 140/400] 8154151: VM crashes with assert "Ensure we don't compile before compilebroker init" Drop compiles submitted with complevel_none Reviewed-by: kvn --- .../src/share/vm/compiler/compileBroker.cpp | 8 +++-- .../startup/TieredStopAtLevel0SanityTest.java | 35 +++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 hotspot/test/compiler/startup/TieredStopAtLevel0SanityTest.java diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index 5b83c4c53ed..7921a7616d1 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -1037,12 +1037,14 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, int comp_level, const methodHandle& hot_method, int hot_count, const char* comment, Thread* THREAD) { - // do nothing if compilebroker is not available - if (!_initialized) { + // Do nothing if compilebroker is not initalized or compiles are submitted on level none + if (!_initialized || comp_level == CompLevel_none) { return NULL; } + AbstractCompiler *comp = CompileBroker::compiler(comp_level); - assert(comp != NULL, "Ensure we don't compile before compilebroker init"); + assert(comp != NULL, "Ensure we have a compiler"); + DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, comp); nmethod* nm = CompileBroker::compile_method(method, osr_bci, comp_level, hot_method, hot_count, comment, directive, THREAD); DirectivesStack::release(directive); diff --git a/hotspot/test/compiler/startup/TieredStopAtLevel0SanityTest.java b/hotspot/test/compiler/startup/TieredStopAtLevel0SanityTest.java new file mode 100644 index 00000000000..a7dbf2badc0 --- /dev/null +++ b/hotspot/test/compiler/startup/TieredStopAtLevel0SanityTest.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8154151 + * @summary Sanity test flag combo that force compiles on level 0 + * @run main/othervm -Xcomp -XX:+UnlockDiagnosticVMOptions -XX:TieredStopAtLevel=0 TieredStopAtLevel0SanityTest + */ + +public class TieredStopAtLevel0SanityTest { + public static void main(String[] args) throws Exception { + System.out.println("Hello world!"); + } +} -- GitLab From 90d0e9a5669930b285e07a9806513cc636b97cf9 Mon Sep 17 00:00:00 2001 From: Nils Eliasson Date: Wed, 13 Apr 2016 14:48:22 +0200 Subject: [PATCH 141/400] 8153013: BlockingCompilation test times out Task has no invocation count and get stale at once Reviewed-by: kvn, iveresov, twisti --- hotspot/src/share/vm/ci/ciReplay.cpp | 2 +- .../src/share/vm/classfile/classLoader.cpp | 4 +- .../src/share/vm/compiler/compileBroker.cpp | 22 +++++---- .../src/share/vm/compiler/compileBroker.hpp | 9 ++-- hotspot/src/share/vm/compiler/compileTask.cpp | 12 +++-- hotspot/src/share/vm/compiler/compileTask.hpp | 48 +++++++++++++++++-- hotspot/src/share/vm/jvmci/jvmciCompiler.cpp | 2 +- hotspot/src/share/vm/prims/whitebox.cpp | 2 +- .../vm/runtime/advancedThresholdPolicy.cpp | 6 +-- .../share/vm/runtime/compilationPolicy.cpp | 14 ++---- .../vm/runtime/simpleThresholdPolicy.cpp | 2 +- .../whitebox/BlockingCompilation.java | 18 ++++--- 12 files changed, 95 insertions(+), 46 deletions(-) diff --git a/hotspot/src/share/vm/ci/ciReplay.cpp b/hotspot/src/share/vm/ci/ciReplay.cpp index c13721743e8..8e3e6fb1ae3 100644 --- a/hotspot/src/share/vm/ci/ciReplay.cpp +++ b/hotspot/src/share/vm/ci/ciReplay.cpp @@ -552,7 +552,7 @@ class CompileReplay : public StackObj { } replay_state = this; CompileBroker::compile_method(method, entry_bci, comp_level, - methodHandle(), 0, "replay", THREAD); + methodHandle(), 0, CompileTask::Reason_Replay, THREAD); replay_state = NULL; reset(); } diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 8a93eb212aa..013bd334fe9 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -1642,7 +1642,7 @@ void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) { } // Force compilation CompileBroker::compile_method(m, InvocationEntryBci, comp_level, - methodHandle(), 0, "CTW", THREAD); + methodHandle(), 0, CompileTask::Reason_CTW, THREAD); if (HAS_PENDING_EXCEPTION) { clear_pending_exception_if_not_oom(CHECK); tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name_and_sig_as_C_string()); @@ -1658,7 +1658,7 @@ void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) { m->clear_code(); } CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_full_optimization, - methodHandle(), 0, "CTW", THREAD); + methodHandle(), 0, CompileTask::Reason_CTW, THREAD); if (HAS_PENDING_EXCEPTION) { clear_pending_exception_if_not_oom(CHECK); tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name_and_sig_as_C_string()); diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index 7921a7616d1..22934de31aa 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -169,6 +169,8 @@ long CompileBroker::_peak_compilation_time = 0; CompileQueue* CompileBroker::_c2_compile_queue = NULL; CompileQueue* CompileBroker::_c1_compile_queue = NULL; + + class CompilationLog : public StringEventLog { public: CompilationLog() : StringEventLog("Compilation events") { @@ -844,7 +846,7 @@ void CompileBroker::compile_method_base(const methodHandle& method, int comp_level, const methodHandle& hot_method, int hot_count, - const char* comment, + CompileTask::CompileReason compile_reason, bool blocking, Thread* thread) { guarantee(!method->is_abstract(), "cannot compile abstract methods"); @@ -860,7 +862,7 @@ void CompileBroker::compile_method_base(const methodHandle& method, if (osr_bci != InvocationEntryBci) { tty->print(" osr_bci: %d", osr_bci); } - tty->print(" level: %d comment: %s count: %d", comp_level, comment, hot_count); + tty->print(" level: %d comment: %s count: %d", comp_level, CompileTask::reason_name(compile_reason), hot_count); if (!hot_method.is_null()) { tty->print(" hot: "); if (hot_method() != method()) { @@ -1024,7 +1026,7 @@ void CompileBroker::compile_method_base(const methodHandle& method, task = create_compile_task(queue, compile_id, method, osr_bci, comp_level, - hot_method, hot_count, comment, + hot_method, hot_count, compile_reason, blocking); } @@ -1036,7 +1038,8 @@ void CompileBroker::compile_method_base(const methodHandle& method, nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, int comp_level, const methodHandle& hot_method, int hot_count, - const char* comment, Thread* THREAD) { + CompileTask::CompileReason compile_reason, + Thread* THREAD) { // Do nothing if compilebroker is not initalized or compiles are submitted on level none if (!_initialized || comp_level == CompLevel_none) { return NULL; @@ -1046,7 +1049,7 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, assert(comp != NULL, "Ensure we have a compiler"); DirectiveSet* directive = DirectivesStack::getMatchingDirective(method, comp); - nmethod* nm = CompileBroker::compile_method(method, osr_bci, comp_level, hot_method, hot_count, comment, directive, THREAD); + nmethod* nm = CompileBroker::compile_method(method, osr_bci, comp_level, hot_method, hot_count, compile_reason, directive, THREAD); DirectivesStack::release(directive); return nm; } @@ -1054,7 +1057,8 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, int comp_level, const methodHandle& hot_method, int hot_count, - const char* comment, DirectiveSet* directive, + CompileTask::CompileReason compile_reason, + DirectiveSet* directive, Thread* THREAD) { // make sure arguments make sense @@ -1180,7 +1184,7 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, return NULL; } bool is_blocking = !directive->BackgroundCompilationOption || CompileTheWorld || ReplayCompiles; - compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, comment, is_blocking, THREAD); + compile_method_base(method, osr_bci, comp_level, hot_method, hot_count, compile_reason, is_blocking, THREAD); } // return requested nmethod @@ -1344,11 +1348,11 @@ CompileTask* CompileBroker::create_compile_task(CompileQueue* queue, int comp_level, const methodHandle& hot_method, int hot_count, - const char* comment, + CompileTask::CompileReason compile_reason, bool blocking) { CompileTask* new_task = CompileTask::allocate(); new_task->initialize(compile_id, method, osr_bci, comp_level, - hot_method, hot_count, comment, + hot_method, hot_count, compile_reason, blocking); queue->add(new_task); return new_task; diff --git a/hotspot/src/share/vm/compiler/compileBroker.hpp b/hotspot/src/share/vm/compiler/compileBroker.hpp index 01a85b59dd0..b399078e973 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.hpp +++ b/hotspot/src/share/vm/compiler/compileBroker.hpp @@ -232,7 +232,7 @@ class CompileBroker: AllStatic { int comp_level, const methodHandle& hot_method, int hot_count, - const char* comment, + CompileTask::CompileReason compile_reason, bool blocking); static void wait_for_completion(CompileTask* task); #if INCLUDE_JVMCI @@ -251,7 +251,7 @@ class CompileBroker: AllStatic { int comp_level, const methodHandle& hot_method, int hot_count, - const char* comment, + CompileTask::CompileReason compile_reason, bool blocking, Thread* thread); @@ -289,14 +289,15 @@ public: int comp_level, const methodHandle& hot_method, int hot_count, - const char* comment, Thread* thread); + CompileTask::CompileReason compile_reason, + Thread* thread); static nmethod* compile_method(const methodHandle& method, int osr_bci, int comp_level, const methodHandle& hot_method, int hot_count, - const char* comment, + CompileTask::CompileReason compile_reason, DirectiveSet* directive, Thread* thread); diff --git a/hotspot/src/share/vm/compiler/compileTask.cpp b/hotspot/src/share/vm/compiler/compileTask.cpp index c339845a1ad..9c3ea04a3ad 100644 --- a/hotspot/src/share/vm/compiler/compileTask.cpp +++ b/hotspot/src/share/vm/compiler/compileTask.cpp @@ -82,7 +82,7 @@ void CompileTask::initialize(int compile_id, int comp_level, const methodHandle& hot_method, int hot_count, - const char* comment, + CompileTask::CompileReason compile_reason, bool is_blocking) { assert(!_lock->is_locked(), "bad locking"); @@ -104,7 +104,7 @@ void CompileTask::initialize(int compile_id, _hot_method_holder = NULL; _hot_count = hot_count; _time_queued = 0; // tidy - _comment = comment; + _compile_reason = compile_reason; _failure_reason = NULL; if (LogCompilation) { @@ -309,9 +309,9 @@ void CompileTask::log_task_queued() { xtty->begin_elem("task_queued"); log_task(xtty); - if (_comment != NULL) { - xtty->print(" comment='%s'", _comment); - } + assert(_compile_reason > CompileTask::Reason_None && _compile_reason < CompileTask::Reason_Count, "Valid values"); + xtty->print(" comment='%s'", reason_name(_compile_reason)); + if (_hot_method != NULL) { methodHandle hot(thread, _hot_method); methodHandle method(thread, _method); @@ -440,3 +440,5 @@ void CompileTask::print_inlining_inner(outputStream* st, ciMethod* method, int i } st->cr(); } + + diff --git a/hotspot/src/share/vm/compiler/compileTask.hpp b/hotspot/src/share/vm/compiler/compileTask.hpp index 1725b83fe32..79a75b51826 100644 --- a/hotspot/src/share/vm/compiler/compileTask.hpp +++ b/hotspot/src/share/vm/compiler/compileTask.hpp @@ -40,6 +40,39 @@ class CompileTask : public CHeapObj { friend class VMStructs; friend class JVMCIVMStructs; + public: + // Different reasons for a compilation + // The order is important - Reason_Whitebox and higher can not become + // stale, see CompileTask::can_become_stale() + // Also mapped to reason_names[] + enum CompileReason { + Reason_None, + Reason_InvocationCount, // Simple/StackWalk-policy + Reason_BackedgeCount, // Simple/StackWalk-policy + Reason_Tiered, // Tiered-policy + Reason_CTW, // Compile the world + Reason_Replay, // ciReplay + Reason_Whitebox, // Whitebox API + Reason_MustBeCompiled, // Java callHelper, LinkResolver + Reason_Bootstrap, // JVMCI bootstrap + Reason_Count + }; + + static const char* reason_name(CompileTask::CompileReason compile_reason) { + static const char* reason_names[] = { + "no_reason", + "count", + "backedge_count", + "tiered", + "CTW", + "replay", + "whitebox", + "must_be_compiled", + "bootstrap" + }; + return reason_names[compile_reason]; + } + private: static CompileTask* _task_free_list; #ifdef ASSERT @@ -69,7 +102,7 @@ class CompileTask : public CHeapObj { Method* _hot_method; // which method actually triggered this task jobject _hot_method_holder; int _hot_count; // information about its invocation counter - const char* _comment; // more info about the task + CompileReason _compile_reason; // more info about the task const char* _failure_reason; public: @@ -78,8 +111,8 @@ class CompileTask : public CHeapObj { } void initialize(int compile_id, const methodHandle& method, int osr_bci, int comp_level, - const methodHandle& hot_method, int hot_count, const char* comment, - bool is_blocking); + const methodHandle& hot_method, int hot_count, + CompileTask::CompileReason compile_reason, bool is_blocking); static CompileTask* allocate(); static void free(CompileTask* task); @@ -91,6 +124,15 @@ class CompileTask : public CHeapObj { bool is_complete() const { return _is_complete; } bool is_blocking() const { return _is_blocking; } bool is_success() const { return _is_success; } + bool can_become_stale() const { + switch (_compile_reason) { + case Reason_BackedgeCount: + case Reason_InvocationCount: + case Reason_Tiered: + return !_is_blocking; + } + return false; + } #if INCLUDE_JVMCI bool has_waiter() const { return _has_waiter; } void clear_waiter() { _has_waiter = false; } diff --git a/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp b/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp index 3e948e3533c..8b34d14e589 100644 --- a/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp +++ b/hotspot/src/share/vm/jvmci/jvmciCompiler.cpp @@ -85,7 +85,7 @@ void JVMCICompiler::bootstrap() { if (!mh->is_native() && !mh->is_static() && !mh->is_initializer()) { ResourceMark rm; int hot_count = 10; // TODO: what's the appropriate value? - CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, "bootstrap", THREAD); + CompileBroker::compile_method(mh, InvocationEntryBci, CompLevel_full_optimization, mh, hot_count, CompileTask::Reason_Bootstrap, THREAD); } } diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index c2cecb3e8fc..734f49c3ac0 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -646,7 +646,7 @@ bool WhiteBox::compile_method(Method* method, int comp_level, int bci, Thread* T return false; } methodHandle mh(THREAD, method); - nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD); + nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), CompileTask::Reason_Whitebox, THREAD); MutexLockerEx mu(Compile_lock); return (mh->queued_for_compilation() || nm != NULL); } diff --git a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp index 17b0c45619e..f8f6a454548 100644 --- a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp +++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp @@ -191,8 +191,8 @@ CompileTask* AdvancedThresholdPolicy::select_task(CompileQueue* compile_queue) { max_method = method; } else { // If a method has been stale for some time, remove it from the queue. - // Blocking tasks don't become stale - if (!task->is_blocking() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) { + // Blocking tasks and tasks submitted from whitebox API don't become stale + if (task->can_become_stale() && is_stale(t, TieredCompileTaskTimeout, method) && !is_old(method)) { if (PrintTieredEvents) { print_event(REMOVE_FROM_QUEUE, method, method, task->osr_bci(), (CompLevel)task->comp_level()); } @@ -491,7 +491,7 @@ CompLevel AdvancedThresholdPolicy::loop_event(Method* method, CompLevel cur_leve void AdvancedThresholdPolicy::submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); update_rate(os::javaTimeMillis(), mh()); - CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", thread); + CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, thread); } // Handle the invocation event. diff --git a/hotspot/src/share/vm/runtime/compilationPolicy.cpp b/hotspot/src/share/vm/runtime/compilationPolicy.cpp index 494bf18a2dd..7333d0d1327 100644 --- a/hotspot/src/share/vm/runtime/compilationPolicy.cpp +++ b/hotspot/src/share/vm/runtime/compilationPolicy.cpp @@ -130,7 +130,7 @@ void CompilationPolicy::compile_if_required(methodHandle selected_method, TRAPS) } CompileBroker::compile_method(selected_method, InvocationEntryBci, CompilationPolicy::policy()->initial_compile_level(), - methodHandle(), 0, "must_be_compiled", CHECK); + methodHandle(), 0, CompileTask::Reason_MustBeCompiled, CHECK); } } @@ -508,12 +508,11 @@ void SimpleCompPolicy::method_invocation_event(const methodHandle& m, JavaThread const int comp_level = CompLevel_highest_tier; const int hot_count = m->invocation_count(); reset_counter_for_invocation_event(m); - const char* comment = "count"; if (is_compilation_enabled() && can_be_compiled(m, comp_level)) { CompiledMethod* nm = m->code(); if (nm == NULL ) { - CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, comment, thread); + CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, CompileTask::Reason_InvocationCount, thread); } } } @@ -521,10 +520,9 @@ void SimpleCompPolicy::method_invocation_event(const methodHandle& m, JavaThread void SimpleCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) { const int comp_level = CompLevel_highest_tier; const int hot_count = m->backedge_count(); - const char* comment = "backedge_count"; if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) { - CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread); + CompileBroker::compile_method(m, bci, comp_level, m, hot_count, CompileTask::Reason_BackedgeCount, thread); NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));) } } @@ -539,7 +537,6 @@ void StackWalkCompPolicy::method_invocation_event(const methodHandle& m, JavaThr const int comp_level = CompLevel_highest_tier; const int hot_count = m->invocation_count(); reset_counter_for_invocation_event(m); - const char* comment = "count"; if (is_compilation_enabled() && m->code() == NULL && can_be_compiled(m, comp_level)) { ResourceMark rm(thread); @@ -569,7 +566,7 @@ void StackWalkCompPolicy::method_invocation_event(const methodHandle& m, JavaThr assert(top != NULL, "findTopInlinableFrame returned null"); if (TraceCompilationPolicy) top->print(); CompileBroker::compile_method(top->top_method(), InvocationEntryBci, comp_level, - m, hot_count, comment, thread); + m, hot_count, CompileTask::Reason_InvocationCount, thread); } } } @@ -577,10 +574,9 @@ void StackWalkCompPolicy::method_invocation_event(const methodHandle& m, JavaThr void StackWalkCompPolicy::method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) { const int comp_level = CompLevel_highest_tier; const int hot_count = m->backedge_count(); - const char* comment = "backedge_count"; if (is_compilation_enabled() && can_be_osr_compiled(m, comp_level)) { - CompileBroker::compile_method(m, bci, comp_level, m, hot_count, comment, thread); + CompileBroker::compile_method(m, bci, comp_level, m, hot_count, CompileTask::Reason_BackedgeCount, thread); NOT_PRODUCT(trace_osr_completion(m->lookup_osr_nmethod_for(bci, comp_level, true));) } } diff --git a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp index 595cfa4ea75..40f4d1aaeee 100644 --- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp +++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp @@ -265,7 +265,7 @@ void SimpleThresholdPolicy::compile(const methodHandle& mh, int bci, CompLevel l // Tell the broker to compile the method void SimpleThresholdPolicy::submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread) { int hot_count = (bci == InvocationEntryBci) ? mh->invocation_count() : mh->backedge_count(); - CompileBroker::compile_method(mh, bci, level, mh, hot_count, "tiered", thread); + CompileBroker::compile_method(mh, bci, level, mh, hot_count, CompileTask::Reason_Tiered, thread); } // Call and loop predicates determine whether a transition to a higher diff --git a/hotspot/test/compiler/whitebox/BlockingCompilation.java b/hotspot/test/compiler/whitebox/BlockingCompilation.java index d960ff4264a..e93b194fe30 100644 --- a/hotspot/test/compiler/whitebox/BlockingCompilation.java +++ b/hotspot/test/compiler/whitebox/BlockingCompilation.java @@ -23,14 +23,13 @@ /* * @test - * @bug 8150646 + * @bug 8150646 8153013 * @summary Add support for blocking compiles through whitebox API * @library /testlibrary /test/lib / * @build sun.hotspot.WhiteBox * compiler.testlibrary.CompilerUtils - * @run main ClassFileInstaller sun.hotspot.WhiteBox - * sun.hotspot.WhiteBox$WhiteBoxPermission - * + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission * @run main/othervm/timeout=60 * -Xbootclasspath/a:. * -Xmixed @@ -40,11 +39,10 @@ * BlockingCompilation */ +import compiler.testlibrary.CompilerUtils; import java.lang.reflect.Method; import java.util.Random; - import sun.hotspot.WhiteBox; -import compiler.testlibrary.CompilerUtils; public class BlockingCompilation { private static final WhiteBox WB = WhiteBox.getWhiteBox(); @@ -77,7 +75,13 @@ public class BlockingCompilation { // If the compiles are blocking, this call will block until the test time out, // Progress == success // (Don't run with -Xcomp since that can cause long timeouts due to many compiles) - WB.enqueueMethodForCompilation(m, highest_level); + if (!WB.enqueueMethodForCompilation(m, highest_level)) { + throw new Exception("Failed to enqueue method on level: " + highest_level); + } + + if (!WB.isMethodQueuedForCompilation(m)) { + throw new Exception("Must be enqueued because of locked compilation"); + } // restore state WB.unlockCompilation(); -- GitLab From 2d6f4ee98fbc667e4fa500ca4903ae5e49c349e8 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Thu, 14 Apr 2016 10:57:09 +0200 Subject: [PATCH 142/400] 8154141: [TESTBUG] test/gc/g1/TestRegionLivenessPrint.java misses -XX:+UnlockDiagnosticVMOption flag Reviewed-by: dfazunen, jwilhelm --- hotspot/test/gc/g1/TestRegionLivenessPrint.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/test/gc/g1/TestRegionLivenessPrint.java b/hotspot/test/gc/g1/TestRegionLivenessPrint.java index 17af16c38a8..9abbe4c1570 100644 --- a/hotspot/test/gc/g1/TestRegionLivenessPrint.java +++ b/hotspot/test/gc/g1/TestRegionLivenessPrint.java @@ -32,7 +32,7 @@ * @build TestRegionLivenessPrint * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/othervm -Xbootclasspath/a:. -XX:+WhiteBoxAPI -XX:+UseG1GC -Xmx128M -XX:G1HeapRegionSize=1m -Xlog:gc+liveness=trace TestRegionLivenessPrint + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseG1GC -Xmx128M -XX:G1HeapRegionSize=1m -Xlog:gc+liveness=trace TestRegionLivenessPrint */ import sun.hotspot.WhiteBox; -- GitLab From 6526d15d6e9f40286a115ba5da5d5a0954c48b91 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Sun, 17 Apr 2016 19:15:52 -0700 Subject: [PATCH 143/400] 8150607: Clean up CompactHashtable Refactored code, and added test cases for serviceability agent Reviewed-by: jiangli, ccheung --- .../sun/jvm/hotspot/memory/SymbolTable.java | 10 +- .../hotspot/utilities/CompactHashTable.java | 42 +- .../share/vm/classfile/compactHashtable.cpp | 388 +++++++++--------- .../share/vm/classfile/compactHashtable.hpp | 214 +++++----- .../vm/classfile/compactHashtable.inline.hpp | 48 +-- .../src/share/vm/classfile/stringTable.cpp | 81 ++-- .../src/share/vm/classfile/stringTable.hpp | 10 +- .../src/share/vm/classfile/symbolTable.cpp | 53 +-- .../src/share/vm/classfile/symbolTable.hpp | 4 +- .../vm/classfile/systemDictionaryShared.hpp | 2 + hotspot/src/share/vm/memory/iterator.hpp | 9 +- .../src/share/vm/memory/metaspaceShared.cpp | 100 +++-- .../src/share/vm/memory/metaspaceShared.hpp | 7 +- hotspot/src/share/vm/runtime/vmStructs.cpp | 10 +- .../SharedArchiveFile/LimitSharedSizes.java | 4 +- .../SharedArchiveFile/SASymbolTableTest.java | 120 ++++++ .../SASymbolTableTestAgent.java | 142 +++++++ .../SASymbolTableTestAttachee.java | 38 ++ 18 files changed, 798 insertions(+), 484 deletions(-) create mode 100644 hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java create mode 100644 hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAgent.java create mode 100644 hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAttachee.java diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java index cefdcf2aa30..46d087332ac 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/SymbolTable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,6 +85,12 @@ public class SymbolTable extends sun.jvm.hotspot.utilities.Hashtable { tables. */ public Symbol probe(byte[] name) { long hashValue = hashSymbol(name); + + Symbol s = sharedTable.probe(name, hashValue); + if (s != null) { + return s; + } + for (HashtableEntry e = (HashtableEntry) bucket(hashToIndex(hashValue)); e != null; e = (HashtableEntry) e.next()) { if (e.hash() == hashValue) { Symbol sym = Symbol.create(e.literalValue()); @@ -94,7 +100,7 @@ public class SymbolTable extends sun.jvm.hotspot.utilities.Hashtable { } } - return sharedTable.probe(name, hashValue); + return null; } public interface SymbolVisitor { diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/CompactHashTable.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/CompactHashTable.java index e5eefb0daa6..e03a85531fe 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/CompactHashTable.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/CompactHashTable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,21 +44,23 @@ public class CompactHashTable extends VMObject { Type type = db.lookupType("SymbolCompactHashTable"); baseAddressField = type.getAddressField("_base_address"); bucketCountField = type.getCIntegerField("_bucket_count"); - tableEndOffsetField = type.getCIntegerField("_table_end_offset"); + entryCountField = type.getCIntegerField("_entry_count"); bucketsField = type.getAddressField("_buckets"); - uintSize = db.lookupType("juint").getSize(); + entriesField = type.getAddressField("_entries"); + uintSize = db.lookupType("u4").getSize(); } // Fields private static CIntegerField bucketCountField; - private static CIntegerField tableEndOffsetField; + private static CIntegerField entryCountField; private static AddressField baseAddressField; private static AddressField bucketsField; + private static AddressField entriesField; private static long uintSize; private static int BUCKET_OFFSET_MASK = 0x3FFFFFFF; private static int BUCKET_TYPE_SHIFT = 30; - private static int COMPACT_BUCKET_TYPE = 1; + private static int VALUE_ONLY_BUCKET_TYPE = 1; public CompactHashTable(Address addr) { super(addr); @@ -68,12 +70,8 @@ public class CompactHashTable extends VMObject { return (int)bucketCountField.getValue(addr); } - private int tableEndOffset() { - return (int)tableEndOffsetField.getValue(addr); - } - - private boolean isCompactBucket(int bucket_info) { - return (bucket_info >> BUCKET_TYPE_SHIFT) == COMPACT_BUCKET_TYPE; + private boolean isValueOnlyBucket(int bucket_info) { + return (bucket_info >> BUCKET_TYPE_SHIFT) == VALUE_ONLY_BUCKET_TYPE; } private int bucketOffset(int bucket_info) { @@ -81,9 +79,8 @@ public class CompactHashTable extends VMObject { } public Symbol probe(byte[] name, long hash) { - - if (bucketCount() == 0) { - // The table is invalid, so don't try to lookup + if (bucketCount() <= 0) { + // This CompactHashTable is not in use return null; } @@ -91,34 +88,33 @@ public class CompactHashTable extends VMObject { Symbol sym; Address baseAddress = baseAddressField.getValue(addr); Address bucket = bucketsField.getValue(addr); - Address bucketEnd = bucket; long index = hash % bucketCount(); int bucketInfo = (int)bucket.getCIntegerAt(index * uintSize, uintSize, true); int bucketOffset = bucketOffset(bucketInfo); int nextBucketInfo = (int)bucket.getCIntegerAt((index+1) * uintSize, uintSize, true); int nextBucketOffset = bucketOffset(nextBucketInfo); - bucket = bucket.addOffsetTo(bucketOffset * uintSize); + Address entry = entriesField.getValue(addr).addOffsetTo(bucketOffset * uintSize); - if (isCompactBucket(bucketInfo)) { - symOffset = bucket.getCIntegerAt(0, uintSize, true); + if (isValueOnlyBucket(bucketInfo)) { + symOffset = entry.getCIntegerAt(0, uintSize, true); sym = Symbol.create(baseAddress.addOffsetTo(symOffset)); if (sym.equals(name)) { return sym; } } else { - bucketEnd = bucket.addOffsetTo(nextBucketOffset * uintSize); - while (bucket.lessThan(bucketEnd)) { - long symHash = bucket.getCIntegerAt(0, uintSize, true); + Address entryMax = entriesField.getValue(addr).addOffsetTo(nextBucketOffset * uintSize); + while (entry.lessThan(entryMax)) { + long symHash = entry.getCIntegerAt(0, uintSize, true); if (symHash == hash) { - symOffset = bucket.getCIntegerAt(uintSize, uintSize, true); + symOffset = entry.getCIntegerAt(uintSize, uintSize, true); Address symAddr = baseAddress.addOffsetTo(symOffset); sym = Symbol.create(symAddr); if (sym.equals(name)) { return sym; } } - bucket = bucket.addOffsetTo(2 * uintSize); + entry = entry.addOffsetTo(2 * uintSize); } } return null; diff --git a/hotspot/src/share/vm/classfile/compactHashtable.cpp b/hotspot/src/share/vm/classfile/compactHashtable.cpp index a2c507d3078..c64a166fa1c 100644 --- a/hotspot/src/share/vm/classfile/compactHashtable.cpp +++ b/hotspot/src/share/vm/classfile/compactHashtable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "classfile/compactHashtable.inline.hpp" #include "classfile/javaClasses.hpp" +#include "memory/metadataFactory.hpp" #include "memory/metaspaceShared.hpp" #include "prims/jvm.h" #include "utilities/numberSeq.hpp" @@ -34,272 +35,261 @@ // // The compact hash table writer implementations // -CompactHashtableWriter::CompactHashtableWriter(int table_type, - int num_entries, +CompactHashtableWriter::CompactHashtableWriter(int num_buckets, CompactHashtableStats* stats) { assert(DumpSharedSpaces, "dump-time only"); - _type = table_type; - _num_entries = num_entries; - _num_buckets = number_of_buckets(_num_entries); - _buckets = NEW_C_HEAP_ARRAY(Entry*, _num_buckets, mtSymbol); - memset(_buckets, 0, sizeof(Entry*) * _num_buckets); - - /* bucket sizes table */ - _bucket_sizes = NEW_C_HEAP_ARRAY(juint, _num_buckets, mtSymbol); - memset(_bucket_sizes, 0, sizeof(juint) * _num_buckets); - - stats->hashentry_count = _num_entries; - // Compact buckets' entries will have only the 4-byte offset, but - // we don't know how many there will be at this point. So use a - // conservative estimate here. The size is adjusted later when we - // write out the buckets. - stats->hashentry_bytes = _num_entries * 8; - stats->bucket_count = _num_buckets; - stats->bucket_bytes = (_num_buckets + 1) * (sizeof(juint)); - _stats = stats; + _num_buckets = num_buckets; + _num_entries = 0; + _buckets = NEW_C_HEAP_ARRAY(GrowableArray*, _num_buckets, mtSymbol); + for (int i=0; i<_num_buckets; i++) { + _buckets[i] = new (ResourceObj::C_HEAP, mtSymbol) GrowableArray(0, true, mtSymbol); + } - // See compactHashtable.hpp for table layout - _required_bytes = sizeof(juint) * 2; // _base_address, written as 2 juints - _required_bytes+= sizeof(juint) + // num_entries - sizeof(juint) + // num_buckets - stats->hashentry_bytes + - stats->bucket_bytes; + stats->bucket_count = _num_buckets; + stats->bucket_bytes = (_num_buckets + 1) * (sizeof(u4)); + _stats = stats; + _compact_buckets = NULL; + _compact_entries = NULL; + _num_empty_buckets = 0; + _num_value_only_buckets = 0; + _num_other_buckets = 0; } CompactHashtableWriter::~CompactHashtableWriter() { for (int index = 0; index < _num_buckets; index++) { - Entry* next = NULL; - for (Entry* tent = _buckets[index]; tent; tent = next) { - next = tent->next(); - delete tent; - } + GrowableArray* bucket = _buckets[index]; + delete bucket; } - FREE_C_HEAP_ARRAY(juint, _bucket_sizes); - FREE_C_HEAP_ARRAY(Entry*, _buckets); -} - -// Calculate the number of buckets in the temporary hash table -int CompactHashtableWriter::number_of_buckets(int num_entries) { - const int buksize = (int)SharedSymbolTableBucketSize; - int num_buckets = (num_entries + buksize - 1) / buksize; - num_buckets = (num_buckets + 1) & (~0x01); - - return num_buckets; + FREE_C_HEAP_ARRAY(GrowableArray*, _buckets); } // Add a symbol entry to the temporary hash table -void CompactHashtableWriter::add(unsigned int hash, Entry* entry) { +void CompactHashtableWriter::add(unsigned int hash, u4 value) { int index = hash % _num_buckets; - entry->set_next(_buckets[index]); - _buckets[index] = entry; - _bucket_sizes[index] ++; + _buckets[index]->append_if_missing(Entry(hash, value)); + _num_entries++; } -// Write the compact table's bucket infos -juint* CompactHashtableWriter::dump_table(juint* p, juint** first_bucket, - NumberSeq* summary) { - int index; - juint* compact_table = p; - // Compute the start of the buckets, include the compact_bucket_infos table - // and the table end offset. - juint offset = _num_buckets + 1; - *first_bucket = compact_table + offset; - - for (index = 0; index < _num_buckets; index++) { - int bucket_size = _bucket_sizes[index]; +void CompactHashtableWriter::allocate_table() { + int entries_space = 0; + for (int index = 0; index < _num_buckets; index++) { + GrowableArray* bucket = _buckets[index]; + int bucket_size = bucket->length(); if (bucket_size == 1) { - // bucket with one entry is compacted and only has the symbol offset - compact_table[index] = BUCKET_INFO(offset, COMPACT_BUCKET_TYPE); - offset += bucket_size; // each entry contains symbol offset only + entries_space++; } else { - // regular bucket, each entry is a symbol (hash, offset) pair - compact_table[index] = BUCKET_INFO(offset, REGULAR_BUCKET_TYPE); - offset += bucket_size * 2; // each hash entry is 2 juints - } - if (offset & ~BUCKET_OFFSET_MASK) { - vm_exit_during_initialization("CompactHashtableWriter::dump_table: Overflow! " - "Too many symbols."); + entries_space += 2 * bucket_size; } - summary->add(bucket_size); } - // Mark the end of the table - compact_table[_num_buckets] = BUCKET_INFO(offset, TABLEEND_BUCKET_TYPE); - - return compact_table; -} -// Write the compact table's entries -juint* CompactHashtableWriter::dump_buckets(juint* compact_table, juint* p, - NumberSeq* summary) { - uintx base_address = 0; - uintx max_delta = 0; - int num_compact_buckets = 0; - if (_type == CompactHashtable::_symbol_table) { - base_address = uintx(MetaspaceShared::shared_rs()->base()); - max_delta = uintx(MetaspaceShared::shared_rs()->size()); - assert(max_delta <= MAX_SHARED_DELTA, "range check"); - } else { - assert((_type == CompactHashtable::_string_table), "unknown table"); - assert(UseCompressedOops, "UseCompressedOops is required"); + if (entries_space & ~BUCKET_OFFSET_MASK) { + vm_exit_during_initialization("CompactHashtableWriter::allocate_table: Overflow! " + "Too many entries."); } - assert(p != NULL, "sanity"); - for (int index = 0; index < _num_buckets; index++) { - juint count = 0; - int bucket_size = _bucket_sizes[index]; - int bucket_type = BUCKET_TYPE(compact_table[index]); + Thread* THREAD = VMThread::vm_thread(); + ClassLoaderData* loader_data = ClassLoaderData::the_null_class_loader_data(); + _compact_buckets = MetadataFactory::new_array(loader_data, _num_buckets + 1, THREAD); + _compact_entries = MetadataFactory::new_array(loader_data, entries_space, THREAD); + + _stats->hashentry_count = _num_entries; + _stats->hashentry_bytes = entries_space * sizeof(u4); +} +// Write the compact table's buckets +void CompactHashtableWriter::dump_table(NumberSeq* summary) { + u4 offset = 0; + for (int index = 0; index < _num_buckets; index++) { + GrowableArray* bucket = _buckets[index]; + int bucket_size = bucket->length(); if (bucket_size == 1) { - assert(bucket_type == COMPACT_BUCKET_TYPE, "Bad bucket type"); - num_compact_buckets ++; - } - for (Entry* tent = _buckets[index]; tent; - tent = tent->next()) { - if (bucket_type == REGULAR_BUCKET_TYPE) { - *p++ = juint(tent->hash()); // write entry hash + // bucket with one entry is compacted and only has the symbol offset + _compact_buckets->at_put(index, BUCKET_INFO(offset, VALUE_ONLY_BUCKET_TYPE)); + + Entry ent = bucket->at(0); + _compact_entries->at_put(offset++, ent.value()); + _num_value_only_buckets++; + } else { + // regular bucket, each entry is a symbol (hash, offset) pair + _compact_buckets->at_put(index, BUCKET_INFO(offset, REGULAR_BUCKET_TYPE)); + + for (int i=0; iat(i); + _compact_entries->at_put(offset++, u4(ent.hash())); // write entry hash + _compact_entries->at_put(offset++, ent.value()); } - if (_type == CompactHashtable::_symbol_table) { - uintx deltax = uintx(tent->value()) - base_address; - assert(deltax < max_delta, "range check"); - juint delta = juint(deltax); - *p++ = delta; // write entry offset + if (bucket_size == 0) { + _num_empty_buckets++; } else { - *p++ = oopDesc::encode_heap_oop(tent->string()); + _num_other_buckets++; } - count ++; } - assert(count == _bucket_sizes[index], "sanity"); + summary->add(bucket_size); } - // Adjust the hashentry_bytes in CompactHashtableStats. Each compact - // bucket saves 4-byte. - _stats->hashentry_bytes -= num_compact_buckets * 4; - - return p; + // Mark the end of the buckets + _compact_buckets->at_put(_num_buckets, BUCKET_INFO(offset, TABLEEND_BUCKET_TYPE)); + assert(offset == (u4)_compact_entries->length(), "sanity"); } + // Write the compact table -void CompactHashtableWriter::dump(char** top, char* end) { +void CompactHashtableWriter::dump(SimpleCompactHashtable *cht, const char* table_name) { NumberSeq summary; - char* old_top = *top; - juint* p = (juint*)(*top); - - uintx base_address = uintx(MetaspaceShared::shared_rs()->base()); - - // Now write the following at the beginning of the table: - // base_address (uintx) - // num_entries (juint) - // num_buckets (juint) - *p++ = high(base_address); - *p++ = low (base_address); // base address - *p++ = _num_entries; // number of entries in the table - *p++ = _num_buckets; // number of buckets in the table + allocate_table(); + dump_table(&summary); - juint* first_bucket = NULL; - juint* compact_table = dump_table(p, &first_bucket, &summary); - juint* bucket_end = dump_buckets(compact_table, first_bucket, &summary); - - assert(bucket_end <= (juint*)end, "cannot write past end"); - *top = (char*)bucket_end; + int table_bytes = _stats->bucket_bytes + _stats->hashentry_bytes; + address base_address = address(MetaspaceShared::shared_rs()->base()); + cht->init(base_address, _num_entries, _num_buckets, + _compact_buckets->data(), _compact_entries->data()); if (PrintSharedSpaces) { double avg_cost = 0.0; if (_num_entries > 0) { - avg_cost = double(_required_bytes)/double(_num_entries); + avg_cost = double(table_bytes)/double(_num_entries); } tty->print_cr("Shared %s table stats -------- base: " PTR_FORMAT, - table_name(), (intptr_t)base_address); + table_name, (intptr_t)base_address); tty->print_cr("Number of entries : %9d", _num_entries); - tty->print_cr("Total bytes used : %9d", (int)((*top) - old_top)); + tty->print_cr("Total bytes used : %9d", table_bytes); tty->print_cr("Average bytes per entry : %9.3f", avg_cost); tty->print_cr("Average bucket size : %9.3f", summary.avg()); tty->print_cr("Variance of bucket size : %9.3f", summary.variance()); tty->print_cr("Std. dev. of bucket size: %9.3f", summary.sd()); - tty->print_cr("Maximum bucket size : %9d", (int)summary.maximum()); + tty->print_cr("Empty buckets : %9d", _num_empty_buckets); + tty->print_cr("Value_Only buckets : %9d", _num_value_only_buckets); + tty->print_cr("Other buckets : %9d", _num_other_buckets); } } -const char* CompactHashtableWriter::table_name() { - switch (_type) { - case CompactHashtable::_symbol_table: return "symbol"; - case CompactHashtable::_string_table: return "string"; - default: - ; - } - return "unknown"; +///////////////////////////////////////////////////////////// +// +// Customization for dumping Symbol and String tables + +void CompactSymbolTableWriter::add(unsigned int hash, Symbol *symbol) { + address base_address = address(MetaspaceShared::shared_rs()->base()); + uintx max_delta = uintx(MetaspaceShared::shared_rs()->size()); + assert(max_delta <= MAX_SHARED_DELTA, "range check"); + + uintx deltax = address(symbol) - base_address; + assert(deltax < max_delta, "range check"); + u4 delta = u4(deltax); + + CompactHashtableWriter::add(hash, delta); +} + +void CompactStringTableWriter::add(unsigned int hash, oop string) { + CompactHashtableWriter::add(hash, oopDesc::encode_heap_oop(string)); +} + +void CompactSymbolTableWriter::dump(CompactHashtable *cht) { + CompactHashtableWriter::dump(cht, "symbol"); +} + +void CompactStringTableWriter::dump(CompactHashtable *cht) { + CompactHashtableWriter::dump(cht, "string"); } ///////////////////////////////////////////////////////////// // // The CompactHashtable implementation // -template const char* CompactHashtable::init( - CompactHashtableType type, const char* buffer) { - assert(!DumpSharedSpaces, "run-time only"); - _type = type; - juint*p = (juint*)buffer; - juint upper = *p++; - juint lower = *p++; - _base_address = uintx(jlong_from(upper, lower)); - _entry_count = *p++; - _bucket_count = *p++; - _buckets = p; - _table_end_offset = BUCKET_OFFSET(p[_bucket_count]); // located at the end of the bucket_info table - - juint *end = _buckets + _table_end_offset; - return (const char*)end; + +void SimpleCompactHashtable::serialize(SerializeClosure* soc) { + soc->do_ptr((void**)&_base_address); + soc->do_u4(&_entry_count); + soc->do_u4(&_bucket_count); + soc->do_ptr((void**)&_buckets); + soc->do_ptr((void**)&_entries); } -template void CompactHashtable::symbols_do(SymbolClosure *cl) { +bool SimpleCompactHashtable::exists(u4 value) { assert(!DumpSharedSpaces, "run-time only"); - for (juint i = 0; i < _bucket_count; i ++) { - juint bucket_info = _buckets[i]; - juint bucket_offset = BUCKET_OFFSET(bucket_info); - int bucket_type = BUCKET_TYPE(bucket_info); - juint* bucket = _buckets + bucket_offset; - juint* bucket_end = _buckets; - - Symbol* sym; - if (bucket_type == COMPACT_BUCKET_TYPE) { - sym = (Symbol*)((void*)(_base_address + bucket[0])); - cl->do_symbol(&sym); - } else { - bucket_end += BUCKET_OFFSET(_buckets[i + 1]); - while (bucket < bucket_end) { - sym = (Symbol*)((void*)(_base_address + bucket[1])); - cl->do_symbol(&sym); - bucket += 2; + + if (_entry_count == 0) { + return false; + } + + unsigned int hash = (unsigned int)value; + int index = hash % _bucket_count; + u4 bucket_info = _buckets[index]; + u4 bucket_offset = BUCKET_OFFSET(bucket_info); + int bucket_type = BUCKET_TYPE(bucket_info); + u4* entry = _entries + bucket_offset; + + if (bucket_type == VALUE_ONLY_BUCKET_TYPE) { + return (entry[0] == value); + } else { + u4*entry_max = _entries + BUCKET_OFFSET(_buckets[index + 1]); + while (entry void CompactHashtable::oops_do(OopClosure* f) { +template +inline void SimpleCompactHashtable::iterate(const I& iterator) { assert(!DumpSharedSpaces, "run-time only"); - assert(_type == _string_table || _bucket_count == 0, "sanity"); - for (juint i = 0; i < _bucket_count; i ++) { - juint bucket_info = _buckets[i]; - juint bucket_offset = BUCKET_OFFSET(bucket_info); - int bucket_type = BUCKET_TYPE(bucket_info); - juint* bucket = _buckets + bucket_offset; - juint* bucket_end = _buckets; - - narrowOop o; - if (bucket_type == COMPACT_BUCKET_TYPE) { - o = (narrowOop)bucket[0]; - f->do_oop(&o); + for (u4 i = 0; i < _bucket_count; i++) { + u4 bucket_info = _buckets[i]; + u4 bucket_offset = BUCKET_OFFSET(bucket_info); + int bucket_type = BUCKET_TYPE(bucket_info); + u4* entry = _entries + bucket_offset; + + if (bucket_type == VALUE_ONLY_BUCKET_TYPE) { + iterator.do_value(_base_address, entry[0]); } else { - bucket_end += BUCKET_OFFSET(_buckets[i + 1]); - while (bucket < bucket_end) { - o = (narrowOop)bucket[1]; - f->do_oop(&o); - bucket += 2; + u4*entry_max = _entries + BUCKET_OFFSET(_buckets[i + 1]); + while (entry < entry_max) { + iterator.do_value(_base_address, entry[0]); + entry += 2; } } } } +template void CompactHashtable::serialize(SerializeClosure* soc) { + SimpleCompactHashtable::serialize(soc); + soc->do_u4(&_type); +} + +class CompactHashtable_SymbolIterator { + SymbolClosure* const _closure; +public: + CompactHashtable_SymbolIterator(SymbolClosure *cl) : _closure(cl) {} + inline void do_value(address base_address, u4 offset) const { + Symbol* sym = (Symbol*)((void*)(base_address + offset)); + _closure->do_symbol(&sym); + } +}; + +template void CompactHashtable::symbols_do(SymbolClosure *cl) { + CompactHashtable_SymbolIterator iterator(cl); + iterate(iterator); +} + +class CompactHashtable_OopIterator { + OopClosure* const _closure; +public: + CompactHashtable_OopIterator(OopClosure *cl) : _closure(cl) {} + inline void do_value(address base_address, u4 offset) const { + narrowOop o = (narrowOop)offset; + _closure->do_oop(&o); + } +}; + +template void CompactHashtable::oops_do(OopClosure* cl) { + assert(_type == _string_table || _bucket_count == 0, "sanity"); + CompactHashtable_OopIterator iterator(cl); + iterate(iterator); +} + // Explicitly instantiate these types template class CompactHashtable; template class CompactHashtable; @@ -360,7 +350,7 @@ bool HashtableTextDump::skip_newline() { } else { corrupted(_p, "Unexpected character"); } - _line_no ++; + _line_no++; return true; } @@ -390,7 +380,7 @@ void HashtableTextDump::check_version(const char* ver) { } void HashtableTextDump::scan_prefix_type() { - _p ++; + _p++; if (strncmp(_p, "SECTION: String", 15) == 0) { _p += 15; _prefix_type = StringPrefix; diff --git a/hotspot/src/share/vm/classfile/compactHashtable.hpp b/hotspot/src/share/vm/classfile/compactHashtable.hpp index ea602229d94..3dd870c1158 100644 --- a/hotspot/src/share/vm/classfile/compactHashtable.hpp +++ b/hotspot/src/share/vm/classfile/compactHashtable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,10 @@ #include "services/diagnosticCommand.hpp" #include "utilities/hashtable.hpp" +template class CompactHashtable; class NumberSeq; +class SimpleCompactHashtable; +class SerializeClosure; // Stats for symbol tables in the CDS archive class CompactHashtableStats VALUE_OBJ_CLASS_SPEC { @@ -70,66 +73,74 @@ public: // class CompactHashtableWriter: public StackObj { public: - class Entry: public CHeapObj { - Entry* _next; + class Entry VALUE_OBJ_CLASS_SPEC { unsigned int _hash; - void* _literal; + u4 _value; public: - Entry(unsigned int hash, Symbol *symbol) : _next(NULL), _hash(hash), _literal(symbol) {} - Entry(unsigned int hash, oop string) : _next(NULL), _hash(hash), _literal(string) {} + Entry() {} + Entry(unsigned int hash, u4 val) : _hash(hash), _value(val) {} - void *value() { - return _literal; - } - Symbol *symbol() { - return (Symbol*)_literal; - } - oop string() { - return (oop)_literal; + u4 value() { + return _value; } unsigned int hash() { return _hash; } - Entry *next() {return _next;} - void set_next(Entry *p) {_next = p;} + + bool operator==(const CompactHashtableWriter::Entry& other) { + return (_value == other._value && _hash == other._hash); + } }; // class CompactHashtableWriter::Entry private: - static int number_of_buckets(int num_entries); - - int _type; int _num_entries; int _num_buckets; - juint* _bucket_sizes; - Entry** _buckets; - int _required_bytes; + int _num_empty_buckets; + int _num_value_only_buckets; + int _num_other_buckets; + GrowableArray** _buckets; CompactHashtableStats* _stats; + Array* _compact_buckets; + Array* _compact_entries; public: // This is called at dump-time only - CompactHashtableWriter(int table_type, int num_entries, CompactHashtableStats* stats); + CompactHashtableWriter(int num_buckets, CompactHashtableStats* stats); ~CompactHashtableWriter(); - int get_required_bytes() { - return _required_bytes; + void add(unsigned int hash, u4 value); + void add(u4 value) { + add((unsigned int)value, value); } - inline void add(unsigned int hash, Symbol* symbol); - inline void add(unsigned int hash, oop string); - private: - void add(unsigned int hash, Entry* entry); - juint* dump_table(juint* p, juint** first_bucket, NumberSeq* summary); - juint* dump_buckets(juint* table, juint* p, NumberSeq* summary); + void allocate_table(); + void dump_table(NumberSeq* summary); public: - void dump(char** top, char* end); + void dump(SimpleCompactHashtable *cht, const char* table_name); const char* table_name(); }; +class CompactSymbolTableWriter: public CompactHashtableWriter { +public: + CompactSymbolTableWriter(int num_buckets, CompactHashtableStats* stats) : + CompactHashtableWriter(num_buckets, stats) {} + void add(unsigned int hash, Symbol *symbol); + void dump(CompactHashtable *cht); +}; + +class CompactStringTableWriter: public CompactHashtableWriter { +public: + CompactStringTableWriter(int num_entries, CompactHashtableStats* stats) : + CompactHashtableWriter(num_entries, stats) {} + void add(unsigned int hash, oop string); + void dump(CompactHashtable *cht); +}; + #define REGULAR_BUCKET_TYPE 0 -#define COMPACT_BUCKET_TYPE 1 +#define VALUE_ONLY_BUCKET_TYPE 1 #define TABLEEND_BUCKET_TYPE 3 #define BUCKET_OFFSET_MASK 0x3FFFFFFF #define BUCKET_OFFSET(info) ((info) & BUCKET_OFFSET_MASK) @@ -146,90 +157,106 @@ public: // and tend to have large number of entries, we try to minimize the footprint // cost per entry. // -// Layout of compact table in the shared archive: +// The CompactHashtable is split into two arrays // -// uintx base_address; -// juint num_entries; -// juint num_buckets; -// juint bucket_infos[num_buckets+1]; // bit[31,30]: type; bit[29-0]: offset -// juint table[] +// u4 buckets[num_buckets+1]; // bit[31,30]: type; bit[29-0]: offset +// u4 entries[] // -// ----------------------------------- -// | base_address | num_entries | -// |---------------------------------| -// | num_buckets | bucket_info0 | -// |---------------------------------| -// | bucket_info1 | bucket_info2 | -// | bucket_info3 ... | -// | .... | table_end_info | -// |---------------------------------| -// | entry0 | -// | entry1 | -// | entry2 | -// | | -// | ... | -// ----------------------------------- -// -// The size of the bucket_info table is 'num_buckets + 1'. Each entry of the -// bucket_info table is a 32-bit encoding of the bucket type and bucket offset, +// The size of buckets[] is 'num_buckets + 1'. Each entry of +// buckets[] is a 32-bit encoding of the bucket type and bucket offset, // with the type in the left-most 2-bit and offset in the remaining 30-bit. -// The last entry is a special type. It contains the offset of the last -// bucket end. We use that information when traversing the compact table. +// The last entry is a special type. It contains the end of the last +// bucket. // -// There are two types of buckets, regular buckets and compact buckets. The -// compact buckets have '01' in their highest 2-bit, and regular buckets have +// There are two types of buckets, regular buckets and value_only buckets. The +// value_only buckets have '01' in their highest 2-bit, and regular buckets have // '00' in their highest 2-bit. // -// For normal buckets, each entry is 8 bytes in the table[]: -// juint hash; /* symbol/string hash */ +// For normal buckets, each entry is 8 bytes in the entries[]: +// u4 hash; /* symbol/string hash */ // union { -// juint offset; /* Symbol* sym = (Symbol*)(base_address + offset) */ +// u4 offset; /* Symbol* sym = (Symbol*)(base_address + offset) */ // narrowOop str; /* String narrowOop encoding */ // } // // -// For compact buckets, each entry has only the 4-byte 'offset' in the table[]. +// For value_only buckets, each entry has only the 4-byte 'offset' in the entries[]. +// +// Example -- note that the second bucket is a VALUE_ONLY_BUCKET_TYPE so the hash code +// is skipped. +// buckets[0, 4, 5, ....] +// | | | +// | | +---+ +// | | | +// | +----+ | +// v v v +// entries[H,O,H,O,O,H,O,H,O.....] // // See CompactHashtable::lookup() for how the table is searched at runtime. // See CompactHashtableWriter::dump() for how the table is written at CDS // dump time. // -template class CompactHashtable VALUE_OBJ_CLASS_SPEC { - friend class VMStructs; - - public: - enum CompactHashtableType { - _symbol_table = 0, - _string_table = 1 - }; +class SimpleCompactHashtable VALUE_OBJ_CLASS_SPEC { +protected: + address _base_address; + u4 _bucket_count; + u4 _entry_count; + u4* _buckets; + u4* _entries; -private: - CompactHashtableType _type; - uintx _base_address; - juint _entry_count; - juint _bucket_count; - juint _table_end_offset; - juint* _buckets; - - inline Symbol* lookup_entry(CompactHashtable* const t, - juint* addr, const char* name, int len); - - inline oop lookup_entry(CompactHashtable* const t, - juint* addr, const char* name, int len); public: - CompactHashtable() { + SimpleCompactHashtable() { _entry_count = 0; _bucket_count = 0; - _table_end_offset = 0; _buckets = 0; + _entries = 0; } - const char* init(CompactHashtableType type, const char *buffer); void reset() { - _entry_count = 0; _bucket_count = 0; - _table_end_offset = 0; + _entry_count = 0; _buckets = 0; + _entries = 0; + } + + void init(address base_address, u4 entry_count, u4 bucket_count, u4* buckets, u4* entries) { + _base_address = base_address; + _bucket_count = bucket_count; + _entry_count = entry_count; + _buckets = buckets; + _entries = entries; + } + + template inline void iterate(const I& iterator); + + bool exists(u4 value); + + // For reading from/writing to the CDS archive + void serialize(SerializeClosure* soc); +}; + +template class CompactHashtable : public SimpleCompactHashtable { + friend class VMStructs; + +public: + enum CompactHashtableType { + _symbol_table = 0, + _string_table = 1 + }; + +private: + u4 _type; + + inline Symbol* decode_entry(CompactHashtable* const t, + u4 offset, const char* name, int len); + + inline oop decode_entry(CompactHashtable* const t, + u4 offset, const char* name, int len); +public: + CompactHashtable() : SimpleCompactHashtable() {} + + void set_type(CompactHashtableType type) { + _type = (u4)type; } // Lookup an entry from the compact table @@ -240,6 +267,9 @@ public: // iterate over strings void oops_do(OopClosure* f); + + // For reading from/writing to the CDS archive + void serialize(SerializeClosure* soc); }; //////////////////////////////////////////////////////////////////////// @@ -293,7 +323,7 @@ public: u8 n = 0; while (p < end) { - char c = *p ++; + char c = *p++; if ('0' <= c && c <= '9') { n = n * 10 + (c - '0'); if (n > (u8)INT_MAX) { diff --git a/hotspot/src/share/vm/classfile/compactHashtable.inline.hpp b/hotspot/src/share/vm/classfile/compactHashtable.inline.hpp index 96aeb551ccd..24dbba11f33 100644 --- a/hotspot/src/share/vm/classfile/compactHashtable.inline.hpp +++ b/hotspot/src/share/vm/classfile/compactHashtable.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,9 +30,9 @@ #include "oops/oop.inline.hpp" template -inline Symbol* CompactHashtable::lookup_entry(CompactHashtable* const t, - juint* addr, const char* name, int len) { - Symbol* sym = (Symbol*)((void*)(_base_address + *addr)); +inline Symbol* CompactHashtable::decode_entry(CompactHashtable* const t, + u4 offset, const char* name, int len) { + Symbol* sym = (Symbol*)(_base_address + offset); if (sym->equals(name, len)) { assert(sym->refcount() == -1, "must be shared"); return sym; @@ -42,9 +42,9 @@ inline Symbol* CompactHashtable::lookup_entry(CompactHashtable -inline oop CompactHashtable::lookup_entry(CompactHashtable* const t, - juint* addr, const char* name, int len) { - narrowOop obj = (narrowOop)(*addr); +inline oop CompactHashtable::decode_entry(CompactHashtable* const t, + u4 offset, const char* name, int len) { + narrowOop obj = (narrowOop)offset; oop string = oopDesc::decode_heap_oop(obj); if (java_lang_String::equals(string, (jchar*)name, len)) { return string; @@ -56,17 +56,14 @@ inline oop CompactHashtable::lookup_entry(CompactHashtable* con template inline T CompactHashtable::lookup(const N* name, unsigned int hash, int len) { if (_entry_count > 0) { - assert(!DumpSharedSpaces, "run-time only"); int index = hash % _bucket_count; - juint bucket_info = _buckets[index]; - juint bucket_offset = BUCKET_OFFSET(bucket_info); - int bucket_type = BUCKET_TYPE(bucket_info); - juint* bucket = _buckets + bucket_offset; - juint* bucket_end = _buckets; + u4 bucket_info = _buckets[index]; + u4 bucket_offset = BUCKET_OFFSET(bucket_info); + int bucket_type = BUCKET_TYPE(bucket_info); + u4* entry = _entries + bucket_offset; - if (bucket_type == COMPACT_BUCKET_TYPE) { - // the compact bucket has one entry with entry offset only - T res = lookup_entry(this, &bucket[0], name, len); + if (bucket_type == VALUE_ONLY_BUCKET_TYPE) { + T res = decode_entry(this, entry[0], name, len); if (res != NULL) { return res; } @@ -74,29 +71,20 @@ inline T CompactHashtable::lookup(const N* name, unsigned int hash, int len // This is a regular bucket, which has more than one // entries. Each entry is a pair of entry (hash, offset). // Seek until the end of the bucket. - bucket_end += BUCKET_OFFSET(_buckets[index + 1]); - while (bucket < bucket_end) { - unsigned int h = (unsigned int)(bucket[0]); + u4* entry_max = _entries + BUCKET_OFFSET(_buckets[index + 1]); + while (entry < entry_max) { + unsigned int h = (unsigned int)(entry[0]); if (h == hash) { - T res = lookup_entry(this, &bucket[1], name, len); + T res = decode_entry(this, entry[1], name, len); if (res != NULL) { return res; } } - bucket += 2; + entry += 2; } } } return NULL; } -inline void CompactHashtableWriter::add(unsigned int hash, Symbol* symbol) { - add(hash, new Entry(hash, symbol)); -} - -inline void CompactHashtableWriter::add(unsigned int hash, oop string) { - add(hash, new Entry(hash, string)); -} - - #endif // SHARE_VM_CLASSFILE_COMPACTHASHTABLE_INLINE_HPP diff --git a/hotspot/src/share/vm/classfile/stringTable.cpp b/hotspot/src/share/vm/classfile/stringTable.cpp index 11aa5548cf5..2e10bae9b0a 100644 --- a/hotspot/src/share/vm/classfile/stringTable.cpp +++ b/hotspot/src/share/vm/classfile/stringTable.cpp @@ -662,7 +662,7 @@ int StringtableDCmd::num_arguments() { // Sharing bool StringTable::copy_shared_string(GrowableArray *string_space, - CompactHashtableWriter* ch_table) { + CompactStringTableWriter* writer) { #if INCLUDE_CDS && INCLUDE_ALL_GCS && defined(_LP64) && !defined(_WINDOWS) assert(UseG1GC, "Only support G1 GC"); assert(UseCompressedOops && UseCompressedClassPointers, @@ -713,7 +713,7 @@ bool StringTable::copy_shared_string(GrowableArray *string_space, } // add to the compact table - ch_table->add(hash, new_s); + writer->add(hash, new_s); } } @@ -723,40 +723,41 @@ bool StringTable::copy_shared_string(GrowableArray *string_space, return true; } -bool StringTable::copy_compact_table(char** top, char *end, GrowableArray *string_space, - size_t* space_size) { +void StringTable::serialize(SerializeClosure* soc, GrowableArray *string_space, + size_t* space_size) { #if INCLUDE_CDS && defined(_LP64) && !defined(_WINDOWS) - if (!(UseG1GC && UseCompressedOops && UseCompressedClassPointers)) { - if (PrintSharedSpaces) { - tty->print_cr("Shared strings are excluded from the archive as UseG1GC, " - "UseCompressedOops and UseCompressedClassPointers are required."); + _shared_table.reset(); + if (soc->writing()) { + if (!(UseG1GC && UseCompressedOops && UseCompressedClassPointers)) { + if (PrintSharedSpaces) { + tty->print_cr("Shared strings are excluded from the archive as UseG1GC, " + "UseCompressedOops and UseCompressedClassPointers are required."); + } + } else { + int num_buckets = the_table()->number_of_entries() / + SharedSymbolTableBucketSize; + CompactStringTableWriter writer(num_buckets, + &MetaspaceShared::stats()->string); + + // Copy the interned strings into the "string space" within the java heap + if (copy_shared_string(string_space, &writer)) { + for (int i = 0; i < string_space->length(); i++) { + *space_size += string_space->at(i).byte_size(); + } + writer.dump(&_shared_table); + } } - return true; } - CompactHashtableWriter ch_table(CompactHashtable::_string_table, - the_table()->number_of_entries(), - &MetaspaceShared::stats()->string); - - // Copy the interned strings into the "string space" within the java heap - if (!copy_shared_string(string_space, &ch_table)) { - return false; - } + _shared_table.set_type(CompactHashtable::_string_table); + _shared_table.serialize(soc); - for (int i = 0; i < string_space->length(); i++) { - *space_size += string_space->at(i).byte_size(); - } - - // Now dump the compact table - if (*top + ch_table.get_required_bytes() > end) { - // not enough space left - return false; + if (soc->writing()) { + _shared_table.reset(); // Sanity. Make sure we don't use the shared table at dump time + } else if (_ignore_shared_strings) { + _shared_table.reset(); } - ch_table.dump(top, end); - *top = (char*)align_ptr_up(*top, sizeof(void*)); - #endif - return true; } void StringTable::shared_oops_do(OopClosure* f) { @@ -765,25 +766,3 @@ void StringTable::shared_oops_do(OopClosure* f) { #endif } -const char* StringTable::init_shared_table(FileMapInfo *mapinfo, char *buffer) { -#if INCLUDE_CDS && defined(_LP64) && !defined(_WINDOWS) - if (mapinfo->space_capacity(MetaspaceShared::first_string) == 0) { - // no shared string data - return buffer; - } - - // initialize the shared table - juint *p = (juint*)buffer; - const char* end = _shared_table.init( - CompactHashtable::_string_table, (char*)p); - const char* aligned_end = (const char*)align_ptr_up(end, sizeof(void*)); - - if (_ignore_shared_strings) { - _shared_table.reset(); - } - - return aligned_end; -#endif - - return buffer; -} diff --git a/hotspot/src/share/vm/classfile/stringTable.hpp b/hotspot/src/share/vm/classfile/stringTable.hpp index 0840ba28180..397cbbd6f9e 100644 --- a/hotspot/src/share/vm/classfile/stringTable.hpp +++ b/hotspot/src/share/vm/classfile/stringTable.hpp @@ -29,8 +29,9 @@ #include "utilities/hashtable.hpp" template class CompactHashtable; -class CompactHashtableWriter; +class CompactStringTableWriter; class FileMapInfo; +class SerializeClosure; class StringTable : public RehashableHashtable { friend class VMStructs; @@ -155,10 +156,9 @@ public: static bool shared_string_ignored() { return _ignore_shared_strings; } static void shared_oops_do(OopClosure* f); static bool copy_shared_string(GrowableArray *string_space, - CompactHashtableWriter* ch_table); - static bool copy_compact_table(char** top, char* end, GrowableArray *string_space, - size_t* space_size); - static const char* init_shared_table(FileMapInfo *mapinfo, char* buffer); + CompactStringTableWriter* ch_table); + static void serialize(SerializeClosure* soc, GrowableArray *string_space, + size_t* space_size); static void reverse() { the_table()->Hashtable::reverse(); } diff --git a/hotspot/src/share/vm/classfile/symbolTable.cpp b/hotspot/src/share/vm/classfile/symbolTable.cpp index 56d1dfb8f8a..ffbef4c2455 100644 --- a/hotspot/src/share/vm/classfile/symbolTable.cpp +++ b/hotspot/src/share/vm/classfile/symbolTable.cpp @@ -537,37 +537,42 @@ void SymbolTable::dump(outputStream* st, bool verbose) { } } -bool SymbolTable::copy_compact_table(char** top, char*end) { +void SymbolTable::serialize(SerializeClosure* soc) { #if INCLUDE_CDS - CompactHashtableWriter ch_table(CompactHashtable::_symbol_table, - the_table()->number_of_entries(), - &MetaspaceShared::stats()->symbol); - if (*top + ch_table.get_required_bytes() > end) { - // not enough space left - return false; - } - - for (int i = 0; i < the_table()->table_size(); ++i) { - HashtableEntry* p = the_table()->bucket(i); - for ( ; p != NULL; p = p->next()) { - Symbol* s = (Symbol*)(p->literal()); + _shared_table.reset(); + if (soc->writing()) { + int num_buckets = the_table()->number_of_entries() / + SharedSymbolTableBucketSize; + CompactSymbolTableWriter writer(num_buckets, + &MetaspaceShared::stats()->symbol); + for (int i = 0; i < the_table()->table_size(); ++i) { + HashtableEntry* p = the_table()->bucket(i); + for ( ; p != NULL; p = p->next()) { + Symbol* s = (Symbol*)(p->literal()); unsigned int fixed_hash = hash_shared_symbol((char*)s->bytes(), s->utf8_length()); - assert(fixed_hash == p->hash(), "must not rehash during dumping"); - ch_table.add(fixed_hash, s); + assert(fixed_hash == p->hash(), "must not rehash during dumping"); + writer.add(fixed_hash, s); + } } + + writer.dump(&_shared_table); } - ch_table.dump(top, end); + _shared_table.set_type(CompactHashtable::_symbol_table); + _shared_table.serialize(soc); - *top = (char*)align_ptr_up(*top, sizeof(void*)); -#endif - return true; -} + if (soc->writing()) { + // Verify table is correct + Symbol* sym = vmSymbols::java_lang_Object(); + const char* name = (const char*)sym->bytes(); + int len = sym->utf8_length(); + unsigned int hash = hash_symbol(name, len); + assert(sym == _shared_table.lookup(name, hash, len), "sanity"); -const char* SymbolTable::init_shared_table(const char* buffer) { - const char* end = _shared_table.init( - CompactHashtable::_symbol_table, buffer); - return (const char*)align_ptr_up(end, sizeof(void*)); + // Sanity. Make sure we don't use the shared table at dump time + _shared_table.reset(); + } +#endif } //--------------------------------------------------------------------------- diff --git a/hotspot/src/share/vm/classfile/symbolTable.hpp b/hotspot/src/share/vm/classfile/symbolTable.hpp index f29698ad575..5a7db595335 100644 --- a/hotspot/src/share/vm/classfile/symbolTable.hpp +++ b/hotspot/src/share/vm/classfile/symbolTable.hpp @@ -41,6 +41,7 @@ class BoolObjectClosure; class outputStream; +class SerializeClosure; // TempNewSymbol acts as a handle class in a handle/body idiom and is // responsible for proper resource management of the body (which is a Symbol*). @@ -251,8 +252,7 @@ public: static void read(const char* filename, TRAPS); // Sharing - static bool copy_compact_table(char** top, char* end); - static const char* init_shared_table(const char* buffer); + static void serialize(SerializeClosure* soc); // Rehash the symbol table if it gets out of balance static void rehash_table(); diff --git a/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp b/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp index 50b5dd80920..51db47c3387 100644 --- a/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionaryShared.hpp @@ -29,6 +29,7 @@ #include "classfile/dictionary.hpp" class ClassFileStream; +class SerializeClosure; class SystemDictionaryShared: public SystemDictionary { public: @@ -77,6 +78,7 @@ public: TRAPS) { return NULL; } + static void serialize(SerializeClosure* soc) {} }; #endif // SHARE_VM_CLASSFILE_SYSTEMDICTIONARYSHARED_HPP diff --git a/hotspot/src/share/vm/memory/iterator.hpp b/hotspot/src/share/vm/memory/iterator.hpp index 3a36dc6d5f5..cd6df30bdf9 100644 --- a/hotspot/src/share/vm/memory/iterator.hpp +++ b/hotspot/src/share/vm/memory/iterator.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -355,6 +355,9 @@ public: // Read/write the void pointer pointed to by p. virtual void do_ptr(void** p) = 0; + // Read/write the 32-bit unsigned integer pointed to by p. + virtual void do_u4(u4* p) = 0; + // Read/write the region specified. virtual void do_region(u_char* start, size_t size) = 0; @@ -363,6 +366,10 @@ public: // for verification that sections of the serialized data are of the // correct length. virtual void do_tag(int tag) = 0; + + bool writing() { + return !reading(); + } }; class SymbolClosure : public StackObj { diff --git a/hotspot/src/share/vm/memory/metaspaceShared.cpp b/hotspot/src/share/vm/memory/metaspaceShared.cpp index fa4d31a54be..5eacfbc646a 100644 --- a/hotspot/src/share/vm/memory/metaspaceShared.cpp +++ b/hotspot/src/share/vm/memory/metaspaceShared.cpp @@ -31,6 +31,7 @@ #include "classfile/sharedClassUtil.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/systemDictionaryShared.hpp" #include "code/codeCache.hpp" #include "gc/shared/gcLocker.hpp" #include "interpreter/bytecodeStream.hpp" @@ -106,7 +107,8 @@ void MetaspaceShared::initialize_shared_rs(ReservedSpace* rs) { // Read/write a data stream for restoring/preserving metadata pointers and // miscellaneous data from/to the shared archive file. -void MetaspaceShared::serialize(SerializeClosure* soc) { +void MetaspaceShared::serialize(SerializeClosure* soc, GrowableArray *string_space, + size_t* space_size) { int tag = 0; soc->do_tag(--tag); @@ -128,6 +130,15 @@ void MetaspaceShared::serialize(SerializeClosure* soc) { vmSymbols::serialize(soc); soc->do_tag(--tag); + // Dump/restore the symbol and string tables + SymbolTable::serialize(soc); + StringTable::serialize(soc, string_space, space_size); + soc->do_tag(--tag); + + // Dump/restore the misc information for system dictionary + SystemDictionaryShared::serialize(soc); + soc->do_tag(--tag); + soc->do_tag(666); } @@ -314,6 +325,11 @@ public: ++top; } + void do_u4(u4* p) { + void* ptr = (void*)(uintx(*p)); + do_ptr(&ptr); + } + void do_tag(int tag) { check_space(); *top = (intptr_t)tag; @@ -348,6 +364,8 @@ public: METASPACE_OBJ_TYPES_DO(f) \ f(SymbolHashentry) \ f(SymbolBucket) \ + f(StringHashentry) \ + f(StringBucket) \ f(Other) #define SHAREDSPACE_OBJ_TYPE_DECLARE(name) name ## Type, @@ -406,13 +424,22 @@ void DumpAllocClosure::dump_stats(int ro_all, int rw_all, int md_all, int mc_all MetaspaceSharedStats *stats = MetaspaceShared::stats(); // symbols - _counts[RW][SymbolHashentryType] = stats->symbol.hashentry_count; - _bytes [RW][SymbolHashentryType] = stats->symbol.hashentry_bytes; - other_bytes -= stats->symbol.hashentry_bytes; + _counts[RO][SymbolHashentryType] = stats->symbol.hashentry_count; + _bytes [RO][SymbolHashentryType] = stats->symbol.hashentry_bytes; + _bytes [RO][TypeArrayU4Type] -= stats->symbol.hashentry_bytes; + + _counts[RO][SymbolBucketType] = stats->symbol.bucket_count; + _bytes [RO][SymbolBucketType] = stats->symbol.bucket_bytes; + _bytes [RO][TypeArrayU4Type] -= stats->symbol.bucket_bytes; - _counts[RW][SymbolBucketType] = stats->symbol.bucket_count; - _bytes [RW][SymbolBucketType] = stats->symbol.bucket_bytes; - other_bytes -= stats->symbol.bucket_bytes; + // strings + _counts[RO][StringHashentryType] = stats->string.hashentry_count; + _bytes [RO][StringHashentryType] = stats->string.hashentry_bytes; + _bytes [RO][TypeArrayU4Type] -= stats->string.hashentry_bytes; + + _counts[RO][StringBucketType] = stats->string.bucket_count; + _bytes [RO][StringBucketType] = stats->string.bucket_bytes; + _bytes [RO][TypeArrayU4Type] -= stats->string.bucket_bytes; // TODO: count things like dictionary, vtable, etc _bytes[RW][OtherType] = other_bytes; @@ -488,7 +515,6 @@ private: GrowableArray *_class_promote_order; VirtualSpace _md_vs; VirtualSpace _mc_vs; - CompactHashtableWriter* _string_cht; GrowableArray *_string_regions; public: @@ -600,39 +626,27 @@ void VM_PopulateDumpSharedSpace::doit() { // Not doing this either. SystemDictionary::reorder_dictionary(); - NOT_PRODUCT(SystemDictionary::verify();) + SystemDictionary::reverse(); + SystemDictionary::copy_buckets(&md_top, md_end); - // Copy the symbol table, string table, and the system dictionary to the shared - // space in usable form. Copy the hashtable - // buckets first [read-write], then copy the linked lists of entries - // [read-only]. + SystemDictionary::copy_table(&md_top, md_end); + // Write the other data to the output array. + // SymbolTable, StringTable and extra information for system dictionary NOT_PRODUCT(SymbolTable::verify()); - handle_misc_data_space_failure(SymbolTable::copy_compact_table(&md_top, md_end)); - + NOT_PRODUCT(StringTable::verify()); size_t ss_bytes = 0; char* ss_low; // The string space has maximum two regions. See FileMapInfo::write_string_regions() for details. _string_regions = new GrowableArray(2); - NOT_PRODUCT(StringTable::verify()); - handle_misc_data_space_failure(StringTable::copy_compact_table(&md_top, md_end, _string_regions, - &ss_bytes)); - ss_low = _string_regions->is_empty() ? NULL : (char*)_string_regions->first().start(); - SystemDictionary::reverse(); - SystemDictionary::copy_buckets(&md_top, md_end); - - SystemDictionary::copy_table(&md_top, md_end); - - // Write the other data to the output array. WriteClosure wc(md_top, md_end); - MetaspaceShared::serialize(&wc); + MetaspaceShared::serialize(&wc, _string_regions, &ss_bytes); md_top = wc.get_top(); + ss_low = _string_regions->is_empty() ? NULL : (char*)_string_regions->first().start(); // Print shared spaces all the time -// To make fmt_space be a syntactic constant (for format warnings), use #define. -#define fmt_space "%s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%4.1f%% used] at " INTPTR_FORMAT Metaspace* ro_space = _loader_data->ro_metaspace(); Metaspace* rw_space = _loader_data->rw_metaspace(); @@ -665,12 +679,13 @@ void VM_PopulateDumpSharedSpace::doit() { const double mc_u_perc = mc_bytes / double(mc_alloced) * 100.0; const double total_u_perc = total_bytes / double(total_alloced) * 100.0; +#define fmt_space "%s space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used] at " INTPTR_FORMAT tty->print_cr(fmt_space, "ro", ro_bytes, ro_t_perc, ro_alloced, ro_u_perc, p2i(ro_space->bottom())); tty->print_cr(fmt_space, "rw", rw_bytes, rw_t_perc, rw_alloced, rw_u_perc, p2i(rw_space->bottom())); tty->print_cr(fmt_space, "md", md_bytes, md_t_perc, md_alloced, md_u_perc, p2i(md_low)); tty->print_cr(fmt_space, "mc", mc_bytes, mc_t_perc, mc_alloced, mc_u_perc, p2i(mc_low)); tty->print_cr(fmt_space, "st", ss_bytes, ss_t_perc, ss_bytes, 100.0, p2i(ss_low)); - tty->print_cr("total : " SIZE_FORMAT_W(9) " [100.0%% of total] out of " SIZE_FORMAT_W(9) " bytes [%4.1f%% used]", + tty->print_cr("total : " SIZE_FORMAT_W(9) " [100.0%% of total] out of " SIZE_FORMAT_W(9) " bytes [%5.1f%% used]", total_bytes, total_alloced, total_u_perc); // Update the vtable pointers in all of the Klass objects in the @@ -974,6 +989,11 @@ public: *p = (void*)obj; } + void do_u4(u4* p) { + intptr_t obj = nextPtr(); + *p = (u4)(uintx(obj)); + } + void do_tag(int tag) { int old_tag; old_tag = (int)(intptr_t)nextPtr(); @@ -1097,21 +1117,6 @@ void MetaspaceShared::initialize_shared_spaces() { buffer += sizeof(intptr_t); buffer += vtable_size; - // Create the shared symbol table using the compact table at this spot in the - // misc data space. (Todo: move this to read-only space. Currently - // this is mapped copy-on-write but will never be written into). - - buffer = (char*)SymbolTable::init_shared_table(buffer); - SymbolTable::create_table(); - - // Create the shared string table using the compact table - buffer = (char*)StringTable::init_shared_table(mapinfo, buffer); - - // Create the shared dictionary using the bucket array at this spot in - // the misc data space. Since the shared dictionary table is never - // modified, this region (of mapped pages) will be (effectively, if - // not explicitly) read-only. - int sharedDictionaryLen = *(intptr_t*)buffer; buffer += sizeof(intptr_t); int number_of_entries = *(intptr_t*)buffer; @@ -1129,9 +1134,14 @@ void MetaspaceShared::initialize_shared_spaces() { buffer += sizeof(intptr_t); buffer += len; + // Verify various attributes of the archive, plus initialize the + // shared string/symbol tables intptr_t* array = (intptr_t*)buffer; ReadClosure rc(&array); - serialize(&rc); + serialize(&rc, NULL, NULL); + + // Initialize the run-time symbol table. + SymbolTable::create_table(); // Close the mapinfo file mapinfo->close(); diff --git a/hotspot/src/share/vm/memory/metaspaceShared.hpp b/hotspot/src/share/vm/memory/metaspaceShared.hpp index e759464591d..b0d6a6fdc28 100644 --- a/hotspot/src/share/vm/memory/metaspaceShared.hpp +++ b/hotspot/src/share/vm/memory/metaspaceShared.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ #define MIN_SHARED_READ_WRITE_SIZE (NOT_LP64(7*M) LP64_ONLY(12*M)) #define DEFAULT_SHARED_READ_ONLY_SIZE (NOT_LP64(12*M) LP64_ONLY(16*M)) -#define MIN_SHARED_READ_ONLY_SIZE (NOT_LP64(8*M) LP64_ONLY(9*M)) +#define MIN_SHARED_READ_ONLY_SIZE (NOT_LP64(9*M) LP64_ONLY(10*M)) // the MIN_SHARED_MISC_DATA_SIZE and MIN_SHARED_MISC_CODE_SIZE estimates are based on // the sizes required for dumping the archive using the default classlist. The sizes @@ -193,7 +193,8 @@ class MetaspaceShared : AllStatic { void** vtable, char** md_top, char* md_end, char** mc_top, char* mc_end); - static void serialize(SerializeClosure* sc); + static void serialize(SerializeClosure* sc, GrowableArray *string_space, + size_t* space_size); static MetaspaceSharedStats* stats() { return &_stats; diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 3cd5d1687cb..9c312dad9d2 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -662,11 +662,11 @@ typedef CompactHashtable SymbolCompactHashTable; /* CompactHashTable */ \ /********************/ \ \ - nonstatic_field(SymbolCompactHashTable, _base_address, uintx) \ - nonstatic_field(SymbolCompactHashTable, _entry_count, juint) \ - nonstatic_field(SymbolCompactHashTable, _bucket_count, juint) \ - nonstatic_field(SymbolCompactHashTable, _table_end_offset, juint) \ - nonstatic_field(SymbolCompactHashTable, _buckets, juint*) \ + nonstatic_field(SymbolCompactHashTable, _base_address, address) \ + nonstatic_field(SymbolCompactHashTable, _entry_count, u4) \ + nonstatic_field(SymbolCompactHashTable, _bucket_count, u4) \ + nonstatic_field(SymbolCompactHashTable, _buckets, u4*) \ + nonstatic_field(SymbolCompactHashTable, _entries, u4*) \ \ /********************/ \ /* SystemDictionary */ \ diff --git a/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java b/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java index 32dfb2a2445..47304b4f287 100644 --- a/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java +++ b/hotspot/test/runtime/SharedArchiveFile/LimitSharedSizes.java @@ -125,7 +125,7 @@ public class LimitSharedSizes { // test with sizes which just meet the minimum required sizes // the following tests also attempt to use the shared archive - new SharedSizeTestData(Region.RO, Platform.is64bit() ? "9M":"8M", Result.VALID_ARCHIVE), + new SharedSizeTestData(Region.RO, Platform.is64bit() ? "10M":"9M", Result.VALID_ARCHIVE), new SharedSizeTestData(Region.RW, Platform.is64bit() ? "12M":"7M", Result.VALID_ARCHIVE), new SharedSizeTestData(Region.MD, Platform.is64bit() ? "4M":"2M", Result.VALID_ARCHIVE), new SharedSizeTestData(Region.MC, "120k", Result.VALID_ARCHIVE), @@ -176,7 +176,7 @@ public class LimitSharedSizes { output.getOutput().contains("Unable to reserve shared space at required address")) && output.getExitValue() == 1) { System.out.println("Unable to use shared archive: test not executed; assumed passed"); - return; + continue; } } output.shouldHaveExitValue(0); diff --git a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java new file mode 100644 index 00000000000..2cd84536659 --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTest.java @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test SASymbolTableTest + * @summary Walk symbol table using SA, with and without CDS. + * @library /testlibrary + * @modules java.base/jdk.internal.misc + * jdk.hotspot.agent/sun.jvm.hotspot.oops + * jdk.hotspot.agent/sun.jvm.hotspot.memory + * jdk.hotspot.agent/sun.jvm.hotspot.runtime + * jdk.hotspot.agent/sun.jvm.hotspot.tools + * java.management + * @build SASymbolTableTestAgent SASymbolTableTestAttachee jdk.test.lib.* + * @run main SASymbolTableTest + */ + +import jdk.test.lib.*; + +/* + * The purpose of this test is to validate that we can use SA to + * attach a process and walk its SymbolTable, regardless whether + * the attachee process runs in CDS mode or not. + * + * SASymbolTableTest Just sets up the agent and attachee processes. + * The SymbolTable walking is done in the SASymbolTableTestAgent class. + */ +public class SASymbolTableTest { + static String jsaName = "./SASymbolTableTest.jsa"; + + public static void main(String[] args) throws Exception { + if (!Platform.shouldSAAttach()) { + System.out.println("SA attach not expected to work - test skipped."); + return; + } + createArchive(); + run(true); + run(false); + } + + private static void createArchive() throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedArchiveFile=" + jsaName, + "-Xshare:dump"); + + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("Loading classes to share"); + output.shouldHaveExitValue(0); + } + + private static void run(boolean useArchive) throws Exception { + String flag = useArchive ? "auto" : "off"; + + // (1) Launch the attachee process + ProcessBuilder attachee = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedArchiveFile=" + jsaName, + "-Xshare:" + flag, + "-showversion", // so we can see "sharing" in the output + "SASymbolTableTestAttachee"); + + final Process p = attachee.start(); + + // (2) Launch the agent process + long pid = p.getPid(); + System.out.println("Attaching agent " + pid); + ProcessBuilder tool = ProcessTools.createJavaProcessBuilder( + "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.oops=ALL-UNNAMED", + "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.memory=ALL-UNNAMED", + "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.runtime=ALL-UNNAMED", + "-XaddExports:jdk.hotspot.agent/sun.jvm.hotspot.tools=ALL-UNNAMED", + "SASymbolTableTestAgent", + Long.toString(pid)); + OutputAnalyzer output = ProcessTools.executeProcess(tool); + System.out.println(output.getOutput()); + output.shouldHaveExitValue(0); + + Thread t = new Thread() { + public void run() { + try { + OutputAnalyzer output = new OutputAnalyzer(p); + System.out.println("STDOUT["); + System.out.print(output.getStdout()); + System.out.println("]"); + System.out.println("STDERR["); + System.out.print(output.getStderr()); + System.out.println("]"); + } catch (Throwable t) { + t.printStackTrace(); + } + } + }; + t.start(); + + Thread.sleep(2 * 1000); + p.destroy(); + t.join(); + } +} diff --git a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAgent.java b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAgent.java new file mode 100644 index 00000000000..4c5193fbcc4 --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAgent.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import sun.jvm.hotspot.memory.SymbolTable; +import sun.jvm.hotspot.oops.Symbol; +import sun.jvm.hotspot.runtime.VM; +import sun.jvm.hotspot.tools.Tool; + +/** + * This class is launched in a sub-process by the main test, + * SASymbolTableTest.java. + * + * It uses SA to connect to another JVM process, whose PID is specified in args[]. + * The purpose of the test is to validate that we can walk the SymbolTable + * and CompactHashTable of the other process. Everything should work regardless + * of whether the other process runs in CDS mode or not. + * + * Note: CompactHashTable is used only when CDS is enabled. + */ +public class SASymbolTableTestAgent extends Tool { + public SASymbolTableTestAgent() { + super(); + } + public static void main(String args[]) { + SASymbolTableTestAgent tool = new SASymbolTableTestAgent(); + tool.execute(args); + } + + static String[] commonNames = { + "java/lang/Object", + "java/lang/String", + "java/lang/Class", + "java/lang/Cloneable", + "java/lang/ClassLoader", + "java/io/Serializable", + "java/lang/System", + "java/lang/Throwable", + "java/lang/Error", + "java/lang/ThreadDeath", + "java/lang/Exception", + "java/lang/RuntimeException", + "java/lang/SecurityManager", + "java/security/ProtectionDomain", + "java/security/AccessControlContext", + "java/security/SecureClassLoader", + "java/lang/ClassNotFoundException", + "java/lang/NoClassDefFoundError", + "java/lang/LinkageError", + "java/lang/ClassCastException", + "java/lang/ArrayStoreException", + "java/lang/VirtualMachineError", + "java/lang/OutOfMemoryError", + "java/lang/StackOverflowError", + "java/lang/IllegalMonitorStateException", + "java/lang/ref/Reference", + "java/lang/ref/SoftReference", + "java/lang/ref/WeakReference", + "java/lang/ref/FinalReference", + "java/lang/ref/PhantomReference", + "java/lang/ref/Finalizer", + "java/lang/Thread", + "java/lang/ThreadGroup", + "java/util/Properties", + "java/lang/reflect/AccessibleObject", + "java/lang/reflect/Field", + "java/lang/reflect/Method", + "java/lang/reflect/Constructor", + "java/lang/invoke/MethodHandle", + "java/lang/invoke/MemberName", + "java/lang/invoke/MethodHandleNatives", + "java/lang/invoke/MethodType", + "java/lang/BootstrapMethodError", + "java/lang/invoke/CallSite", + "java/lang/invoke/ConstantCallSite", + "java/lang/invoke/MutableCallSite", + "java/lang/invoke/VolatileCallSite", + "java/lang/StringBuffer", + "java/lang/StringBuilder", + "java/io/ByteArrayInputStream", + "java/io/File", + "java/net/URLClassLoader", + "java/net/URL", + "java/util/jar/Manifest", + "java/security/CodeSource", + }; + + static String[] badNames = { + "java/lang/badbadbad", + "java/io/badbadbadbad", + "this*symbol*must*not*exist" + }; + + public void run() { + System.out.println("SASymbolTableTestAgent: starting"); + VM vm = VM.getVM(); + SymbolTable table = vm.getSymbolTable(); + + // (a) These are names that are likely to exist in the symbol table + // of a JVM after start-up. They were taken from vmSymbols.hpp + // during the middle of JDK9 development. + // + // The purpose is not to check that each name must exist (a future + // version of JDK may not preload some of the classes). + // + // The purpose of this loops is to ensure that we check a lot of symbols, + // so we will (most likely) hit on both VALUE_ONLY_BUCKET_TYPE and normal bucket type + // in CompactHashTable.probe(). + for (String n : commonNames) { + Symbol s = table.probe(n); + System.out.format("%-40s = %s\n", n, s); + } + + System.out.println("======================================================================"); + + // (b) Also test a few strings that are known to not exist in the table. This will + // both the compact table (if it exists) and the regular table to be walked. + for (String n : badNames) { + Symbol s = table.probe(n); + System.out.format("%-40s = %s\n", n, s); + } + } +} diff --git a/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAttachee.java b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAttachee.java new file mode 100644 index 00000000000..e08d1a55bf5 --- /dev/null +++ b/hotspot/test/runtime/SharedArchiveFile/SASymbolTableTestAttachee.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * This class is launched in a sub-process by the main test, + * SASymbolTableTest.java. + * + * This class does nothing in particular. It just sleeps for 120 + * seconds so SASymbolTableTestAgent can have a chance to examine its + * SymbolTable. This process should be killed by the parent process + * after SASymbolTableTestAgent has completed testing. + */ +public class SASymbolTableTestAttachee { + public static void main(String args[]) throws Throwable { + System.out.println("SASymbolTableTestAttachee: sleeping to wait for SA tool to attach ..."); + Thread.sleep(120 * 1000); + } +} -- GitLab From acab1fddacfa1e322e260aecd7a8c3257a891ad2 Mon Sep 17 00:00:00 2001 From: Zoltan Majo Date: Mon, 18 Apr 2016 09:39:55 +0200 Subject: [PATCH 144/400] 8072428: Enable UseLoopCounter ergonomically if on-stack-replacement is enabled Set UseLoopCounter ergonomically if on-stack-replacement is enabled. Print warning. Reviewed-by: kvn --- hotspot/src/share/vm/runtime/arguments.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 948f80789e4..767a60b252a 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -4514,6 +4514,11 @@ jint Arguments::apply_ergo() { warning("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used"); } + if (UseOnStackReplacement && !UseLoopCounter) { + warning("On-stack-replacement requires loop counters; enabling loop counters"); + FLAG_SET_DEFAULT(UseLoopCounter, true); + } + #ifndef PRODUCT if (!LogVMOutput && FLAG_IS_DEFAULT(LogVMOutput)) { if (use_vm_log()) { -- GitLab From c05dd2fdca9eba42a90be644346f68505ec59713 Mon Sep 17 00:00:00 2001 From: Zoltan Majo Date: Mon, 18 Apr 2016 11:22:51 +0200 Subject: [PATCH 145/400] 8153357: C2 creates incorrect cast after eliminating phi with unique input Refine C2's logic to determine the type of cast node added. Reviewed-by: kvn --- hotspot/src/share/vm/opto/cfgnode.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/opto/cfgnode.cpp b/hotspot/src/share/vm/opto/cfgnode.cpp index 25e34e57738..594ffd2e70a 100644 --- a/hotspot/src/share/vm/opto/cfgnode.cpp +++ b/hotspot/src/share/vm/opto/cfgnode.cpp @@ -1703,16 +1703,19 @@ Node *PhiNode::Ideal(PhaseGVN *phase, bool can_reshape) { } if (uncasted) { - // Wait until after parsing for the type information to propagate from the casts + // Add a cast node between the phi to be removed and its unique input. + // Wait until after parsing for the type information to propagate from the casts. assert(can_reshape, "Invalid during parsing"); const Type* phi_type = bottom_type(); assert(phi_type->isa_int() || phi_type->isa_ptr(), "bad phi type"); int opcode; + // Determine the type of cast to be added. if (phi_type->isa_int()) { opcode = Op_CastII; } else { const Type* uin_type = phase->type(uin); - if (phi_type->join(TypePtr::NOTNULL) == uin_type->join(TypePtr::NOTNULL)) { + if ((phi_type->join(TypePtr::NOTNULL) == uin_type->join(TypePtr::NOTNULL)) || + (!phi_type->isa_oopptr() && !uin_type->isa_oopptr())) { opcode = Op_CastPP; } else { opcode = Op_CheckCastPP; -- GitLab From 79859bc5dd7f54847e8042f612c8bc35ecf40b10 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Mon, 18 Apr 2016 11:30:12 +0200 Subject: [PATCH 146/400] 8153275: Zero JVM fails to initialize after JDK-8152440 Use a value for InitArrayShortSize which passes validation Reviewed-by: aph, andrew, coleenp --- hotspot/src/cpu/zero/vm/globals_zero.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hotspot/src/cpu/zero/vm/globals_zero.hpp b/hotspot/src/cpu/zero/vm/globals_zero.hpp index 52a3cacbd70..eb09f466c62 100644 --- a/hotspot/src/cpu/zero/vm/globals_zero.hpp +++ b/hotspot/src/cpu/zero/vm/globals_zero.hpp @@ -43,7 +43,12 @@ define_pd_global(intx, CodeEntryAlignment, 32); define_pd_global(intx, OptoLoopAlignment, 16); define_pd_global(intx, InlineFrequencyCount, 100); define_pd_global(intx, InlineSmallCode, 1000); -define_pd_global(intx, InitArrayShortSize, -1); // not used + +// not used, but must satisfy following constraints: +// 1.) must be in the allowed range for intx *and* +// 2.) % BytesPerLong == 0 so as to not +// violate the constraint verifier on JVM start-up. +define_pd_global(intx, InitArrayShortSize, 0); #define DEFAULT_STACK_YELLOW_PAGES (2) #define DEFAULT_STACK_RED_PAGES (1) -- GitLab From 6c95220480f2bd5cbdc10af9dc83669f81925e04 Mon Sep 17 00:00:00 2001 From: Anton Ivanov Date: Mon, 18 Apr 2016 15:40:11 +0300 Subject: [PATCH 147/400] 8154174: Improve JitTester performance Reviewed-by: iignatyev --- .../lib/jittester/ProductionFailedException.java | 4 ++-- .../src/jdk/test/lib/jittester/SymbolTable.java | 15 ++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionFailedException.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionFailedException.java index d06ecb00242..acc4493669c 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionFailedException.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/ProductionFailedException.java @@ -27,10 +27,10 @@ public class ProductionFailedException extends Exception { static final long serialVersionUID = -2325617203741536725L; public ProductionFailedException(String msg) { - super(msg); + super(msg, null, false, false); } public ProductionFailedException() { - super(); + super(null, null, false, false); } } diff --git a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/SymbolTable.java b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/SymbolTable.java index 9547bdbf41f..13078380a58 100644 --- a/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/SymbolTable.java +++ b/hotspot/test/testlibrary/jittester/src/jdk/test/lib/jittester/SymbolTable.java @@ -26,6 +26,7 @@ package jdk.test.lib.jittester; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.Map; import java.util.Stack; import jdk.test.lib.jittester.types.TypeKlass; @@ -37,7 +38,7 @@ public class SymbolTable { private static int VARIABLE_NUMBER = 0; private static int FUNCTION_NUMBER = 0; - static private void initExternalSymbols() { + private static void initExternalSymbols() { String classList = ProductionParams.addExternalSymbols.value(); if (classList.equals("all")) { @@ -254,12 +255,12 @@ public class SymbolTable { public static void push() { // Do deep cloning.. HashMap> prev = SYMBOL_STACK.peek(); - SYMBOL_STACK.push(new HashMap<>()); - HashMap> top = SYMBOL_STACK.peek(); - for (Type type : prev.keySet()) { - ArrayList prevArray = prev.get(type); - top.put(type, new ArrayList<>(prevArray.size())); - ArrayList topArray = top.get(type); + HashMap> top = new HashMap<>(prev.size()); + SYMBOL_STACK.push(top); + for (Map.Entry> entry : prev.entrySet()) { + ArrayList prevArray = entry.getValue(); + ArrayList topArray = new ArrayList<>(prevArray.size()); + top.put(entry.getKey(), topArray); for (Symbol symbol : prevArray) { topArray.add(symbol.copy()); } -- GitLab From d55089d82b39566a9bf74d15c1528786eb9629ad Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 18 Apr 2016 16:51:14 +0200 Subject: [PATCH 148/400] 8153503: Move remset scan iteration claim to remset local data structure Reviewed-by: drwhite, mgerdin --- .../src/share/vm/gc/g1/g1CollectedHeap.cpp | 29 +-- hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp | 9 - hotspot/src/share/vm/gc/g1/g1RemSet.cpp | 240 ++++++++++++------ hotspot/src/share/vm/gc/g1/g1RemSet.hpp | 56 ++-- .../src/share/vm/gc/g1/heapRegionRemSet.cpp | 26 +- .../src/share/vm/gc/g1/heapRegionRemSet.hpp | 27 +- hotspot/src/share/vm/gc/g1/heapRegionSet.cpp | 1 - 7 files changed, 190 insertions(+), 198 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index 4c74bc8ce43..a4565442247 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -98,7 +98,7 @@ public: RefineCardTableEntryClosure() : _concurrent(true) { } bool do_card_ptr(jbyte* card_ptr, uint worker_i) { - bool oops_into_cset = G1CollectedHeap::heap()->g1_rem_set()->refine_card(card_ptr, worker_i, false); + bool oops_into_cset = G1CollectedHeap::heap()->g1_rem_set()->refine_card(card_ptr, worker_i, NULL); // This path is executed by the concurrent refine or mutator threads, // concurrently, and so we do not care if card_ptr contains references // that point into the collection set. @@ -3090,28 +3090,6 @@ class VerifyRegionRemSetClosure : public HeapRegionClosure { } }; -#ifdef ASSERT -class VerifyCSetClosure: public HeapRegionClosure { -public: - bool doHeapRegion(HeapRegion* hr) { - // Here we check that the CSet region's RSet is ready for parallel - // iteration. The fields that we'll verify are only manipulated - // when the region is part of a CSet and is collected. Afterwards, - // we reset these fields when we clear the region's RSet (when the - // region is freed) so they are ready when the region is - // re-allocated. The only exception to this is if there's an - // evacuation failure and instead of freeing the region we leave - // it in the heap. In that case, we reset these fields during - // evacuation failure handling. - guarantee(hr->rem_set()->verify_ready_for_par_iteration(), "verification"); - - // Here's a good place to add any other checks we'd like to - // perform on CSet regions. - return false; - } -}; -#endif // ASSERT - uint G1CollectedHeap::num_task_queues() const { return _task_queues->size(); } @@ -3354,11 +3332,6 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { } } -#ifdef ASSERT - VerifyCSetClosure cl; - collection_set_iterate(&cl); -#endif // ASSERT - // Initialize the GC alloc regions. _allocator->init_gc_alloc_regions(evacuation_info); diff --git a/hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp b/hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp index 82d655ed232..1b52407c64b 100644 --- a/hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp +++ b/hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp @@ -227,15 +227,6 @@ public: during_conc_mark); _g1h->verifier()->check_bitmaps("Self-Forwarding Ptr Removal", hr); - // In the common case (i.e. when there is no evacuation - // failure) we make sure that the following is done when - // the region is freed so that it is "ready-to-go" when it's - // re-allocated. However, when evacuation failure happens, a - // region will remain in the heap and might ultimately be added - // to a CSet in the future. So we have to be careful here and - // make sure the region's RSet is ready for parallel iteration - // whenever this might be required in the future. - hr->rem_set()->reset_for_par_iteration(); hr->reset_bot(); size_t live_bytes = remove_self_forward_ptr_by_walking_hr(hr, during_initial_mark); diff --git a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp index 458d2b82ba7..e655c1af87f 100644 --- a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp @@ -45,20 +45,108 @@ #include "utilities/intHisto.hpp" #include "utilities/stack.inline.hpp" +// Collects information about the overall remembered set scan progress during an evacuation. +class G1RemSetScanState : public CHeapObj { +private: + size_t _max_regions; + + // Scan progress for the remembered set of a single region. Transitions from + // Unclaimed -> Claimed -> Complete. + // At each of the transitions the thread that does the transition needs to perform + // some special action once. This is the reason for the extra "Claimed" state. + typedef jint G1RemsetIterState; + + static const G1RemsetIterState Unclaimed = 0; // The remembered set has not been scanned yet. + static const G1RemsetIterState Claimed = 1; // The remembered set is currently being scanned. + static const G1RemsetIterState Complete = 2; // The remembered set has been completely scanned. + + G1RemsetIterState volatile* _iter_states; + // The current location where the next thread should continue scanning in a region's + // remembered set. + size_t volatile* _iter_claims; + +public: + G1RemSetScanState() : + _max_regions(0), + _iter_states(NULL), + _iter_claims(NULL) { + + } + + ~G1RemSetScanState() { + if (_iter_states != NULL) { + FREE_C_HEAP_ARRAY(G1RemsetIterState, _iter_states); + } + if (_iter_claims != NULL) { + FREE_C_HEAP_ARRAY(size_t, _iter_claims); + } + } + + void initialize(uint max_regions) { + assert(_iter_states == NULL, "Must not be initialized twice"); + assert(_iter_claims == NULL, "Must not be initialized twice"); + _max_regions = max_regions; + _iter_states = NEW_C_HEAP_ARRAY(G1RemsetIterState, max_regions, mtGC); + _iter_claims = NEW_C_HEAP_ARRAY(size_t, max_regions, mtGC); + } + + void reset() { + for (uint i = 0; i < _max_regions; i++) { + _iter_states[i] = Unclaimed; + } + memset((void*)_iter_claims, 0, _max_regions * sizeof(size_t)); + } + + // Attempt to claim the remembered set of the region for iteration. Returns true + // if this call caused the transition from Unclaimed to Claimed. + inline bool claim_iter(uint region) { + assert(region < _max_regions, "Tried to access invalid region %u", region); + if (_iter_states[region] != Unclaimed) { + return false; + } + jint res = Atomic::cmpxchg(Claimed, (jint*)(&_iter_states[region]), Unclaimed); + return (res == Unclaimed); + } + + // Try to atomically sets the iteration state to "complete". Returns true for the + // thread that caused the transition. + inline bool set_iter_complete(uint region) { + if (iter_is_complete(region)) { + return false; + } + jint res = Atomic::cmpxchg(Complete, (jint*)(&_iter_states[region]), Claimed); + return (res == Claimed); + } + + // Returns true if the region's iteration is complete. + inline bool iter_is_complete(uint region) const { + assert(region < _max_regions, "Tried to access invalid region %u", region); + return _iter_states[region] == Complete; + } + + // The current position within the remembered set of the given region. + inline size_t iter_claimed(uint region) const { + assert(region < _max_regions, "Tried to access invalid region %u", region); + return _iter_claims[region]; + } + + // Claim the next block of cards within the remembered set of the region with + // step size. + inline size_t iter_claimed_next(uint region, size_t step) { + return Atomic::add(step, &_iter_claims[region]) - step; + } +}; + G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs) : _g1(g1), + _scan_state(new G1RemSetScanState()), _conc_refine_cards(0), _ct_bs(ct_bs), _g1p(_g1->g1_policy()), _cg1r(g1->concurrent_g1_refine()), - _cset_rs_update_cl(NULL), _prev_period_summary(), _into_cset_dirty_card_queue_set(false) { - _cset_rs_update_cl = NEW_C_HEAP_ARRAY(G1ParPushHeapRSClosure*, n_workers(), mtGC); - for (uint i = 0; i < n_workers(); i++) { - _cset_rs_update_cl[i] = NULL; - } if (log_is_enabled(Trace, gc, remset)) { _prev_period_summary.initialize(this); } @@ -74,10 +162,9 @@ G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs) : } G1RemSet::~G1RemSet() { - for (uint i = 0; i < n_workers(); i++) { - assert(_cset_rs_update_cl[i] == NULL, "it should be"); + if (_scan_state != NULL) { + delete _scan_state; } - FREE_C_HEAP_ARRAY(G1ParPushHeapRSClosure*, _cset_rs_update_cl); } uint G1RemSet::num_par_rem_sets() { @@ -86,6 +173,7 @@ uint G1RemSet::num_par_rem_sets() { void G1RemSet::initialize(size_t capacity, uint max_regions) { G1FromCardCache::initialize(num_par_rem_sets(), max_regions); + _scan_state->initialize(max_regions); { GCTraceTime(Debug, gc, marking)("Initialize Card Live Data"); _card_live_data.initialize(capacity, max_regions); @@ -96,29 +184,29 @@ void G1RemSet::initialize(size_t capacity, uint max_regions) { } } -ScanRSClosure::ScanRSClosure(G1ParPushHeapRSClosure* oc, - CodeBlobClosure* code_root_cl, - uint worker_i) : - _oc(oc), +G1ScanRSClosure::G1ScanRSClosure(G1RemSetScanState* scan_state, + G1ParPushHeapRSClosure* push_heap_cl, + CodeBlobClosure* code_root_cl, + uint worker_i) : + _scan_state(scan_state), + _push_heap_cl(push_heap_cl), _code_root_cl(code_root_cl), _strong_code_root_scan_time_sec(0.0), _cards(0), _cards_done(0), - _worker_i(worker_i), - _try_claimed(false) { + _worker_i(worker_i) { _g1h = G1CollectedHeap::heap(); _bot = _g1h->bot(); _ct_bs = _g1h->g1_barrier_set(); _block_size = MAX2(G1RSetScanBlockSize, 1); } -void ScanRSClosure::scanCard(size_t index, HeapRegion *r) { +void G1ScanRSClosure::scan_card(size_t index, HeapRegion *r) { // Stack allocate the DirtyCardToOopClosure instance - HeapRegionDCTOC cl(_g1h, r, _oc, - CardTableModRefBS::Precise); + HeapRegionDCTOC cl(_g1h, r, _push_heap_cl, CardTableModRefBS::Precise); // Set the "from" region in the closure. - _oc->set_region(r); + _push_heap_cl->set_region(r); MemRegion card_region(_bot->address_for_index(index), BOTConstants::N_words); MemRegion pre_gc_allocated(r->bottom(), r->scan_top()); MemRegion mr = pre_gc_allocated.intersection(card_region); @@ -132,37 +220,39 @@ void ScanRSClosure::scanCard(size_t index, HeapRegion *r) { } } -void ScanRSClosure::scan_strong_code_roots(HeapRegion* r) { +void G1ScanRSClosure::scan_strong_code_roots(HeapRegion* r) { double scan_start = os::elapsedTime(); r->strong_code_roots_do(_code_root_cl); _strong_code_root_scan_time_sec += (os::elapsedTime() - scan_start); } -bool ScanRSClosure::doHeapRegion(HeapRegion* r) { +bool G1ScanRSClosure::doHeapRegion(HeapRegion* r) { assert(r->in_collection_set(), "should only be called on elements of CS."); - HeapRegionRemSet* hrrs = r->rem_set(); - if (hrrs->iter_is_complete()) return false; // All done. - if (!_try_claimed && !hrrs->claim_iter()) return false; - // If we ever free the collection set concurrently, we should also - // clear the card table concurrently therefore we won't need to - // add regions of the collection set to the dirty cards region. - _g1h->push_dirty_cards_region(r); - // If we didn't return above, then - // _try_claimed || r->claim_iter() - // is true: either we're supposed to work on claimed-but-not-complete - // regions, or we successfully claimed the region. - - HeapRegionRemSetIterator iter(hrrs); + uint region_idx = r->hrm_index(); + + if (_scan_state->iter_is_complete(region_idx)) { + return false; + } + if (_scan_state->claim_iter(region_idx)) { + // If we ever free the collection set concurrently, we should also + // clear the card table concurrently therefore we won't need to + // add regions of the collection set to the dirty cards region. + _g1h->push_dirty_cards_region(r); + } + + HeapRegionRemSetIterator iter(r->rem_set()); size_t card_index; // We claim cards in block so as to reduce the contention. The block size is determined by // the G1RSetScanBlockSize parameter. - size_t jump_to_card = hrrs->iter_claimed_next(_block_size); + size_t claimed_card_block = _scan_state->iter_claimed_next(region_idx, _block_size); for (size_t current_card = 0; iter.has_next(card_index); current_card++) { - if (current_card >= jump_to_card + _block_size) { - jump_to_card = hrrs->iter_claimed_next(_block_size); + if (current_card >= claimed_card_block + _block_size) { + claimed_card_block = _scan_state->iter_claimed_next(region_idx, _block_size); + } + if (current_card < claimed_card_block) { + continue; } - if (current_card < jump_to_card) continue; HeapWord* card_start = _g1h->bot()->address_for_index(card_index); HeapRegion* card_region = _g1h->heap_region_containing(card_start); @@ -175,38 +265,33 @@ bool ScanRSClosure::doHeapRegion(HeapRegion* r) { // If the card is dirty, then we will scan it during updateRS. if (!card_region->in_collection_set() && !_ct_bs->is_card_dirty(card_index)) { - scanCard(card_index, card_region); + scan_card(card_index, card_region); } } - if (!_try_claimed) { + if (_scan_state->set_iter_complete(region_idx)) { // Scan the strong code root list attached to the current region scan_strong_code_roots(r); - - hrrs->set_iter_complete(); } return false; } -size_t G1RemSet::scanRS(G1ParPushHeapRSClosure* oc, - CodeBlobClosure* heap_region_codeblobs, - uint worker_i) { +size_t G1RemSet::scan_rem_set(G1ParPushHeapRSClosure* oops_in_heap_closure, + CodeBlobClosure* heap_region_codeblobs, + uint worker_i) { double rs_time_start = os::elapsedTime(); HeapRegion *startRegion = _g1->start_cset_region_for_worker(worker_i); - ScanRSClosure scanRScl(oc, heap_region_codeblobs, worker_i); - - _g1->collection_set_iterate_from(startRegion, &scanRScl); - scanRScl.set_try_claimed(); - _g1->collection_set_iterate_from(startRegion, &scanRScl); + G1ScanRSClosure cl(_scan_state, oops_in_heap_closure, heap_region_codeblobs, worker_i); + _g1->collection_set_iterate_from(startRegion, &cl); - double scan_rs_time_sec = (os::elapsedTime() - rs_time_start) - - scanRScl.strong_code_root_scan_time_sec(); + double scan_rs_time_sec = (os::elapsedTime() - rs_time_start) - + cl.strong_code_root_scan_time_sec(); _g1p->phase_times()->record_time_secs(G1GCPhaseTimes::ScanRS, worker_i, scan_rs_time_sec); - _g1p->phase_times()->record_time_secs(G1GCPhaseTimes::CodeRoots, worker_i, scanRScl.strong_code_root_scan_time_sec()); + _g1p->phase_times()->record_time_secs(G1GCPhaseTimes::CodeRoots, worker_i, cl.strong_code_root_scan_time_sec()); - return scanRScl.cards_done(); + return cl.cards_done(); } // Closure used for updating RSets and recording references that @@ -216,10 +301,12 @@ size_t G1RemSet::scanRS(G1ParPushHeapRSClosure* oc, class RefineRecordRefsIntoCSCardTableEntryClosure: public CardTableEntryClosure { G1RemSet* _g1rs; DirtyCardQueue* _into_cset_dcq; + G1ParPushHeapRSClosure* _cl; public: RefineRecordRefsIntoCSCardTableEntryClosure(G1CollectedHeap* g1h, - DirtyCardQueue* into_cset_dcq) : - _g1rs(g1h->g1_rem_set()), _into_cset_dcq(into_cset_dcq) + DirtyCardQueue* into_cset_dcq, + G1ParPushHeapRSClosure* cl) : + _g1rs(g1h->g1_rem_set()), _into_cset_dcq(into_cset_dcq), _cl(cl) {} bool do_card_ptr(jbyte* card_ptr, uint worker_i) { @@ -230,7 +317,7 @@ public: assert(SafepointSynchronize::is_at_safepoint(), "not during an evacuation pause"); assert(worker_i < ParallelGCThreads, "should be a GC worker"); - if (_g1rs->refine_card(card_ptr, worker_i, true)) { + if (_g1rs->refine_card(card_ptr, worker_i, _cl)) { // 'card_ptr' contains references that point into the collection // set. We need to record the card in the DCQS // (_into_cset_dirty_card_queue_set) @@ -243,8 +330,10 @@ public: } }; -void G1RemSet::updateRS(DirtyCardQueue* into_cset_dcq, uint worker_i) { - RefineRecordRefsIntoCSCardTableEntryClosure into_cset_update_rs_cl(_g1, into_cset_dcq); +void G1RemSet::update_rem_set(DirtyCardQueue* into_cset_dcq, + G1ParPushHeapRSClosure* oops_in_heap_closure, + uint worker_i) { + RefineRecordRefsIntoCSCardTableEntryClosure into_cset_update_rs_cl(_g1, into_cset_dcq, oops_in_heap_closure); G1GCParPhaseTimesTracker x(_g1p->phase_times(), G1GCPhaseTimes::UpdateRS, worker_i); if (ConcurrentG1Refine::hot_card_cache_enabled()) { @@ -260,14 +349,9 @@ void G1RemSet::cleanupHRRS() { HeapRegionRemSet::cleanup(); } -size_t G1RemSet::oops_into_collection_set_do(G1ParPushHeapRSClosure* oc, +size_t G1RemSet::oops_into_collection_set_do(G1ParPushHeapRSClosure* cl, CodeBlobClosure* heap_region_codeblobs, uint worker_i) { - // We cache the value of 'oc' closure into the appropriate slot in the - // _cset_rs_update_cl for this worker - assert(worker_i < n_workers(), "sanity"); - _cset_rs_update_cl[worker_i] = oc; - // A DirtyCardQueue that is used to hold cards containing references // that point into the collection set. This DCQ is associated with a // special DirtyCardQueueSet (see g1CollectedHeap.hpp). Under normal @@ -279,18 +363,16 @@ size_t G1RemSet::oops_into_collection_set_do(G1ParPushHeapRSClosure* oc, // DirtyCardQueueSet that is used to manage RSet updates DirtyCardQueue into_cset_dcq(&_into_cset_dirty_card_queue_set); - updateRS(&into_cset_dcq, worker_i); - size_t cards_scanned = scanRS(oc, heap_region_codeblobs, worker_i); - - // We now clear the cached values of _cset_rs_update_cl for this worker - _cset_rs_update_cl[worker_i] = NULL; - return cards_scanned; + update_rem_set(&into_cset_dcq, cl, worker_i); + return scan_rem_set(cl, heap_region_codeblobs, worker_i);; } void G1RemSet::prepare_for_oops_into_collection_set_do() { _g1->set_refine_cte_cl_concurrency(false); DirtyCardQueueSet& dcqs = JavaThread::dirty_card_queue_set(); dcqs.concatenate_logs(); + + _scan_state->reset(); } void G1RemSet::cleanup_after_oops_into_collection_set_do() { @@ -365,8 +447,9 @@ G1UpdateRSOrPushRefOopClosure(G1CollectedHeap* g1h, // into the collection set, if we're checking for such references; // false otherwise. -bool G1RemSet::refine_card(jbyte* card_ptr, uint worker_i, - bool check_for_refs_into_cset) { +bool G1RemSet::refine_card(jbyte* card_ptr, + uint worker_i, + G1ParPushHeapRSClosure* oops_in_heap_closure) { assert(_g1->is_in_exact(_ct_bs->addr_for(card_ptr)), "Card at " PTR_FORMAT " index " SIZE_FORMAT " representing heap at " PTR_FORMAT " (%u) must be in committed heap", p2i(card_ptr), @@ -374,6 +457,8 @@ bool G1RemSet::refine_card(jbyte* card_ptr, uint worker_i, p2i(_ct_bs->addr_for(card_ptr)), _g1->addr_to_region(_ct_bs->addr_for(card_ptr))); + bool check_for_refs_into_cset = oops_in_heap_closure != NULL; + // If the card is no longer dirty, nothing to do. if (*card_ptr != CardTableModRefBS::dirty_card_val()) { // No need to return that this card contains refs that point @@ -450,15 +535,6 @@ bool G1RemSet::refine_card(jbyte* card_ptr, uint worker_i, HeapWord* end = start + CardTableModRefBS::card_size_in_words; MemRegion dirtyRegion(start, end); - G1ParPushHeapRSClosure* oops_in_heap_closure = NULL; - if (check_for_refs_into_cset) { - // ConcurrentG1RefineThreads have worker numbers larger than what - // _cset_rs_update_cl[] is set up to handle. But those threads should - // only be active outside of a collection which means that when they - // reach here they should have check_for_refs_into_cset == false. - assert((size_t)worker_i < n_workers(), "index of worker larger than _cset_rs_update_cl[].length"); - oops_in_heap_closure = _cset_rs_update_cl[worker_i]; - } G1UpdateRSOrPushRefOopClosure update_rs_oop_cl(_g1, _g1->g1_rem_set(), oops_in_heap_closure, @@ -578,7 +654,7 @@ void G1RemSet::prepare_for_verify() { hot_card_cache->set_use_cache(false); DirtyCardQueue into_cset_dcq(&_into_cset_dirty_card_queue_set); - updateRS(&into_cset_dcq, 0); + update_rem_set(&into_cset_dcq, NULL, 0); _into_cset_dirty_card_queue_set.clear(); hot_card_cache->set_use_cache(use_hot_card_cache); diff --git a/hotspot/src/share/vm/gc/g1/g1RemSet.hpp b/hotspot/src/share/vm/gc/g1/g1RemSet.hpp index 515069f7b19..63b9f1fbab8 100644 --- a/hotspot/src/share/vm/gc/g1/g1RemSet.hpp +++ b/hotspot/src/share/vm/gc/g1/g1RemSet.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,7 @@ class ConcurrentG1Refine; class CodeBlobClosure; class G1CollectedHeap; class G1ParPushHeapRSClosure; +class G1RemSetScanState; class G1Policy; class G1SATBCardTableModRefBS; class HeapRegionClaimer; @@ -51,6 +52,7 @@ class HeapRegionClaimer; // so that they can be used to update the individual region remsets. class G1RemSet: public CHeapObj { private: + G1RemSetScanState* _scan_state; G1CardLiveData _card_live_data; G1RemSetSummary _prev_period_summary; @@ -72,10 +74,6 @@ protected: ConcurrentG1Refine* _cg1r; - // Used for caching the closure that is responsible for scanning - // references into the collection set. - G1ParPushHeapRSClosure** _cset_rs_update_cl; - public: // Gives an approximation on how many threads can be expected to add records to // a remembered set in parallel. This can be used for sizing data structures to @@ -95,9 +93,9 @@ public: G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs); ~G1RemSet(); - // Invoke "blk->do_oop" on all pointers into the collection set + // Invoke "cl->do_oop" on all pointers into the collection set // from objects in regions outside the collection set (having - // invoked "blk->set_region" to set the "from" region correctly + // invoked "cl->set_region" to set the "from" region correctly // beforehand.) // // Apply non_heap_roots on the oops of the unmarked nmethods @@ -112,7 +110,7 @@ public: // // Returns the number of cards scanned while looking for pointers // into the collection set. - size_t oops_into_collection_set_do(G1ParPushHeapRSClosure* blk, + size_t oops_into_collection_set_do(G1ParPushHeapRSClosure* cl, CodeBlobClosure* heap_region_codeblobs, uint worker_i); @@ -124,13 +122,15 @@ public: void prepare_for_oops_into_collection_set_do(); void cleanup_after_oops_into_collection_set_do(); - size_t scanRS(G1ParPushHeapRSClosure* oc, - CodeBlobClosure* heap_region_codeblobs, - uint worker_i); + size_t scan_rem_set(G1ParPushHeapRSClosure* oops_in_heap_closure, + CodeBlobClosure* heap_region_codeblobs, + uint worker_i); - void updateRS(DirtyCardQueue* into_cset_dcq, uint worker_i); + G1RemSetScanState* scan_state() const { return _scan_state; } - CardTableModRefBS* ct_bs() { return _ct_bs; } + // Flush remaining refinement buffers into the remembered set, + // applying oops_in_heap_closure on the references found. + void update_rem_set(DirtyCardQueue* into_cset_dcq, G1ParPushHeapRSClosure* oops_in_heap_closure, uint worker_i); // Record, if necessary, the fact that *p (where "p" is in region "from", // which is required to be non-NULL) has changed to a new non-NULL value. @@ -145,12 +145,12 @@ public: void scrub(uint worker_num, HeapRegionClaimer* hrclaimer); // Refine the card corresponding to "card_ptr". - // If check_for_refs_into_cset is true, a true result is returned + // If oops_in_heap_closure is not NULL, a true result is returned // if the given card contains oops that have references into the // current collection set. virtual bool refine_card(jbyte* card_ptr, uint worker_i, - bool check_for_refs_into_cset); + G1ParPushHeapRSClosure* oops_in_heap_closure); // Print accumulated summary info from the start of the VM. virtual void print_summary_info(); @@ -179,11 +179,14 @@ public: #endif }; -class ScanRSClosure : public HeapRegionClosure { - size_t _cards_done, _cards; +class G1ScanRSClosure : public HeapRegionClosure { + G1RemSetScanState* _scan_state; + + size_t _cards_done; + size_t _cards; G1CollectedHeap* _g1h; - G1ParPushHeapRSClosure* _oc; + G1ParPushHeapRSClosure* _push_heap_cl; CodeBlobClosure* _code_root_cl; G1BlockOffsetTable* _bot; @@ -192,26 +195,23 @@ class ScanRSClosure : public HeapRegionClosure { double _strong_code_root_scan_time_sec; uint _worker_i; size_t _block_size; - bool _try_claimed; + void scan_card(size_t index, HeapRegion *r); + void scan_strong_code_roots(HeapRegion* r); public: - ScanRSClosure(G1ParPushHeapRSClosure* oc, - CodeBlobClosure* code_root_cl, - uint worker_i); + G1ScanRSClosure(G1RemSetScanState* scan_state, + G1ParPushHeapRSClosure* push_heap_cl, + CodeBlobClosure* code_root_cl, + uint worker_i); bool doHeapRegion(HeapRegion* r); double strong_code_root_scan_time_sec() { return _strong_code_root_scan_time_sec; } + size_t cards_done() { return _cards_done;} size_t cards_looked_up() { return _cards;} - void set_try_claimed() { _try_claimed = true; } -private: - void scanCard(size_t index, HeapRegion *r); - void printCard(HeapRegion* card_region, size_t card_index, - HeapWord* card_start); - void scan_strong_code_roots(HeapRegion* r); }; class UpdateRSOopClosure: public ExtendedOopClosure { diff --git a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp index 4fee9c4ecfc..77f9bc349b6 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp @@ -692,8 +692,8 @@ HeapRegionRemSet::HeapRegionRemSet(G1BlockOffsetTable* bot, HeapRegion* hr) : _bot(bot), _m(Mutex::leaf, FormatBuffer<128>("HeapRegionRemSet lock #%u", hr->hrm_index()), true, Monitor::_safepoint_check_never), - _code_roots(), _other_regions(hr, &_m), _iter_state(Unclaimed), _iter_claimed(0) { - reset_for_par_iteration(); + _code_roots(), + _other_regions(hr, &_m) { } void HeapRegionRemSet::setup_remset_size() { @@ -710,20 +710,6 @@ void HeapRegionRemSet::setup_remset_size() { guarantee(G1RSetSparseRegionEntries > 0 && G1RSetRegionEntries > 0 , "Sanity"); } -bool HeapRegionRemSet::claim_iter() { - if (_iter_state != Unclaimed) return false; - jint res = Atomic::cmpxchg(Claimed, (jint*)(&_iter_state), Unclaimed); - return (res == Unclaimed); -} - -void HeapRegionRemSet::set_iter_complete() { - _iter_state = Complete; -} - -bool HeapRegionRemSet::iter_is_complete() { - return _iter_state == Complete; -} - #ifndef PRODUCT void HeapRegionRemSet::print() { HeapRegionRemSetIterator iter(this); @@ -760,14 +746,6 @@ void HeapRegionRemSet::clear_locked() { _code_roots.clear(); _other_regions.clear(); assert(occupied_locked() == 0, "Should be clear."); - reset_for_par_iteration(); -} - -void HeapRegionRemSet::reset_for_par_iteration() { - _iter_state = Unclaimed; - _iter_claimed = 0; - // It's good to check this to make sure that the two methods are in sync. - assert(verify_ready_for_par_iteration(), "post-condition"); } void HeapRegionRemSet::scrub(G1CardLiveData* live_data) { diff --git a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp index c884dab2484..baf2def1de6 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -185,10 +185,6 @@ private: OtherRegionsTable _other_regions; - enum ParIterState { Unclaimed, Claimed, Complete }; - volatile ParIterState _iter_state; - volatile size_t _iter_claimed; - public: HeapRegionRemSet(G1BlockOffsetTable* bot, HeapRegion* hr); @@ -240,27 +236,6 @@ public: void clear(); void clear_locked(); - // Attempt to claim the region. Returns true iff this call caused an - // atomic transition from Unclaimed to Claimed. - bool claim_iter(); - // Sets the iteration state to "complete". - void set_iter_complete(); - // Returns "true" iff the region's iteration is complete. - bool iter_is_complete(); - - // Support for claiming blocks of cards during iteration - size_t iter_claimed() const { return _iter_claimed; } - // Claim the next block of cards - size_t iter_claimed_next(size_t step) { - return Atomic::add(step, &_iter_claimed) - step; - } - - void reset_for_par_iteration(); - - bool verify_ready_for_par_iteration() { - return (_iter_state == Unclaimed) && (_iter_claimed == 0); - } - // The actual # of bytes this hr_remset takes up. // Note also includes the strong code root set. size_t mem_size() { diff --git a/hotspot/src/share/vm/gc/g1/heapRegionSet.cpp b/hotspot/src/share/vm/gc/g1/heapRegionSet.cpp index 89b5a7f044f..83bbc71bc4c 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionSet.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionSet.cpp @@ -38,7 +38,6 @@ void HeapRegionSetBase::verify_region(HeapRegion* hr) { assert(!hr->is_free() || hr->is_empty(), "Free region %u is not empty for set %s", hr->hrm_index(), name()); assert(!hr->is_empty() || hr->is_free() || hr->is_archive(), "Empty region %u is not free or archive for set %s", hr->hrm_index(), name()); - assert(hr->rem_set()->verify_ready_for_par_iteration(), "Wrong iteration state %u", hr->hrm_index()); } #endif -- GitLab From 4c2f0704f3c2f165072383c8d809bea14d86fbb6 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 18 Apr 2016 16:54:04 +0200 Subject: [PATCH 149/400] 8153170: Card Live Data does not correctly handle eager reclaim The card live data of regions eagerly reclaimed during remark and cleanup pause could be wrong, not considering that these regions were eagerly reclaimed and empty. Reviewed-by: drwhite, kbarrett --- hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp | 41 +++++++++++++++---- hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp | 13 ++++++ .../src/share/vm/gc/g1/g1CollectedHeap.hpp | 4 +- .../src/share/vm/gc/g1/g1ConcurrentMark.cpp | 2 - hotspot/src/share/vm/gc/g1/heapRegion.cpp | 3 +- hotspot/src/share/vm/gc/g1/heapRegion.hpp | 6 +-- 6 files changed, 53 insertions(+), 16 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp b/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp index 0a2ed25a29b..028ee3f5cbc 100644 --- a/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp @@ -28,6 +28,7 @@ #include "gc/g1/g1CardLiveData.inline.hpp" #include "gc/g1/suspendibleThreadSet.hpp" #include "gc/shared/workgroup.hpp" +#include "logging/log.hpp" #include "memory/universe.hpp" #include "runtime/atomic.inline.hpp" #include "runtime/globals.hpp" @@ -38,6 +39,7 @@ G1CardLiveData::G1CardLiveData() : _max_capacity(0), _cards_per_region(0), + _gc_timestamp_at_create(0), _live_regions(NULL), _live_regions_size_in_bits(0), _live_cards(NULL), @@ -127,6 +129,13 @@ private: // lots of work most of the time. BitMap::idx_t _last_marked_bit_idx; + void clear_card_bitmap_range(HeapWord* start, HeapWord* end) { + BitMap::idx_t start_idx = card_live_bitmap_index_for(start); + BitMap::idx_t end_idx = card_live_bitmap_index_for((HeapWord*)align_ptr_up(end, CardTableModRefBS::card_size)); + + _card_bm.clear_range(start_idx, end_idx); + } + // Mark the card liveness bitmap for the object spanning from start to end. void mark_card_bitmap_range(HeapWord* start, HeapWord* end) { BitMap::idx_t start_idx = card_live_bitmap_index_for(start); @@ -169,6 +178,10 @@ public: _region_bm.par_set_bit(hr->hrm_index()); } + void reset_live_data(HeapRegion* hr) { + clear_card_bitmap_range(hr->next_top_at_mark_start(), hr->end()); + } + // Mark the range of bits covered by allocations done since the last marking // in the given heap region, i.e. from NTAMS to top of the given region. // Returns if there has been some allocation in this region since the last marking. @@ -305,6 +318,8 @@ public: }; void G1CardLiveData::create(WorkGang* workers, G1CMBitMap* mark_bitmap) { + _gc_timestamp_at_create = G1CollectedHeap::heap()->get_gc_time_stamp(); + uint n_workers = workers->active_workers(); G1CreateCardLiveDataTask cl(mark_bitmap, @@ -322,14 +337,24 @@ class G1FinalizeCardLiveDataTask: public AbstractGangTask { class G1FinalizeCardLiveDataClosure: public HeapRegionClosure { private: G1CardLiveDataHelper _helper; + + uint _gc_timestamp_at_create; + + bool has_been_reclaimed(HeapRegion* hr) const { + return hr->get_gc_time_stamp() > _gc_timestamp_at_create; + } public: G1FinalizeCardLiveDataClosure(G1CollectedHeap* g1h, G1CMBitMap* bitmap, G1CardLiveData* live_data) : HeapRegionClosure(), - _helper(live_data, g1h->reserved_region().start()) { } + _helper(live_data, g1h->reserved_region().start()), + _gc_timestamp_at_create(live_data->gc_timestamp_at_create()) { } bool doHeapRegion(HeapRegion* hr) { + if (has_been_reclaimed(hr)) { + _helper.reset_live_data(hr); + } bool allocated_since_marking = _helper.mark_allocated_since_marking(hr); if (allocated_since_marking || hr->next_marked_bytes() > 0) { _helper.set_bit_for_region(hr); @@ -459,27 +484,26 @@ class G1VerifyCardLiveDataTask: public AbstractGangTask { // Verify the marked bytes for this region. if (exp_marked_bytes != act_marked_bytes) { + log_error(gc)("Expected marked bytes " SIZE_FORMAT " != actual marked bytes " SIZE_FORMAT " in region %u", exp_marked_bytes, act_marked_bytes, hr->hrm_index()); failures += 1; } else if (exp_marked_bytes > HeapRegion::GrainBytes) { + log_error(gc)("Expected marked bytes " SIZE_FORMAT " larger than possible " SIZE_FORMAT " in region %u", exp_marked_bytes, HeapRegion::GrainBytes, hr->hrm_index()); failures += 1; } // Verify the bit, for this region, in the actual and expected // (which was just calculated) region bit maps. - // We're not OK if the bit in the calculated expected region - // bitmap is set and the bit in the actual region bitmap is not. uint index = hr->hrm_index(); bool expected = _exp_live_data->is_region_live(index); bool actual = _act_live_data->is_region_live(index); - if (expected && !actual) { + if (expected != actual) { + log_error(gc)("Expected liveness %d not equal actual %d in region %u", expected, actual, hr->hrm_index()); failures += 1; } // Verify that the card bit maps for the cards spanned by the current - // region match. We have an error if we have a set bit in the expected - // bit map and the corresponding bit in the actual bitmap is not set. - + // region match. BitMap::idx_t start_idx = _helper.card_live_bitmap_index_for(hr->bottom()); BitMap::idx_t end_idx = _helper.card_live_bitmap_index_for(hr->top()); @@ -487,7 +511,8 @@ class G1VerifyCardLiveDataTask: public AbstractGangTask { expected = _exp_live_data->is_card_live_at(i); actual = _act_live_data->is_card_live_at(i); - if (expected && !actual) { + if (expected != actual) { + log_error(gc)("Expected card liveness %d not equal actual card liveness %d at card " SIZE_FORMAT " in region %u", expected, actual, i, hr->hrm_index()); failures += 1; } } diff --git a/hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp b/hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp index d76fa66d3c4..c21c5957838 100644 --- a/hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp @@ -46,6 +46,17 @@ private: size_t _max_capacity; size_t _cards_per_region; + // Regions may be reclaimed while concurrently creating live data (e.g. due to humongous + // eager reclaim). This results in wrong live data for these regions at the end. + // So we need to somehow detect these regions, and during live data finalization completely + // recreate their information. + // This _gc_timestamp_at_create tracks the global timestamp when live data creation + // has started. Any regions with a higher time stamp have been cleared after that + // point in time, and need re-finalization. + // Unsynchronized access to this variable is okay, since this value is only set during a + // concurrent phase, and read only at the Cleanup safepoint. I.e. there is always + // full memory synchronization inbetween. + uint _gc_timestamp_at_create; // The per-card liveness bitmap. bm_word_t* _live_cards; size_t _live_cards_size_in_bits; @@ -69,6 +80,8 @@ private: size_t live_region_bitmap_size_in_bits() const; size_t live_card_bitmap_size_in_bits() const; public: + uint gc_timestamp_at_create() const { return _gc_timestamp_at_create; } + inline bool is_region_live(uint region) const; inline void remove_nonlive_cards(uint region, BitMap* bm); diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp index 03a5f845a0f..61620d43c9e 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp @@ -245,7 +245,7 @@ private: // If not, we can skip a few steps. bool _has_humongous_reclaim_candidates; - volatile unsigned _gc_time_stamp; + volatile uint _gc_time_stamp; G1HRPrinter _hr_printer; @@ -999,7 +999,7 @@ public: // Try to minimize the remembered set. void scrub_rem_set(); - unsigned get_gc_time_stamp() { + uint get_gc_time_stamp() { return _gc_time_stamp; } diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp index 1a3b1f79852..9b51104b8a8 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp @@ -1144,8 +1144,6 @@ public: if (hr->is_archive()) { return false; } - // We use a claim value of zero here because all regions - // were claimed with value 1 in the FinalCount task. _g1->reset_gc_time_stamps(hr); hr->note_end_of_marking(); diff --git a/hotspot/src/share/vm/gc/g1/heapRegion.cpp b/hotspot/src/share/vm/gc/g1/heapRegion.cpp index 92f65ac1d68..7f1385f29da 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegion.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegion.cpp @@ -187,6 +187,7 @@ void HeapRegion::hr_clear(bool par, bool clear_space, bool locked) { zero_marked_bytes(); init_top_at_mark_start(); + _gc_time_stamp = G1CollectedHeap::heap()->get_gc_time_stamp(); if (clear_space) clear(SpaceDecorator::Mangle); } @@ -1044,7 +1045,7 @@ HeapWord* G1ContiguousSpace::scan_top() const { void G1ContiguousSpace::record_timestamp() { G1CollectedHeap* g1h = G1CollectedHeap::heap(); - unsigned curr_gc_time_stamp = g1h->get_gc_time_stamp(); + uint curr_gc_time_stamp = g1h->get_gc_time_stamp(); if (_gc_time_stamp < curr_gc_time_stamp) { // Setting the time stamp here tells concurrent readers to look at diff --git a/hotspot/src/share/vm/gc/g1/heapRegion.hpp b/hotspot/src/share/vm/gc/g1/heapRegion.hpp index 88d83cb2be3..4258b608c25 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegion.hpp +++ b/hotspot/src/share/vm/gc/g1/heapRegion.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -124,7 +124,7 @@ class G1ContiguousSpace: public CompactibleSpace { protected: G1BlockOffsetTablePart _bot_part; Mutex _par_alloc_lock; - volatile unsigned _gc_time_stamp; + volatile uint _gc_time_stamp; // When we need to retire an allocation region, while other threads // are also concurrently trying to allocate into it, we typically // allocate a dummy object at the end of the region to ensure that @@ -174,7 +174,7 @@ class G1ContiguousSpace: public CompactibleSpace { HeapWord* scan_top() const; void record_timestamp(); void reset_gc_time_stamp() { _gc_time_stamp = 0; } - unsigned get_gc_time_stamp() { return _gc_time_stamp; } + uint get_gc_time_stamp() { return _gc_time_stamp; } void record_retained_region(); // See the comment above in the declaration of _pre_dummy_top for an -- GitLab From 66208f1fca390124c6ab492789e8ec77e8ed113a Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Mon, 18 Apr 2016 15:37:29 +0000 Subject: [PATCH 150/400] 8152554: CompactStrings broken on AArch64 Correct the logic for string intrinsics. Reviewed-by: roland --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 41 +++++++++++++++---- .../cpu/aarch64/vm/macroAssembler_aarch64.cpp | 11 ++++- 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index e92411bab18..09ec22242d2 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -3325,9 +3325,15 @@ int HandlerImpl::emit_deopt_handler(CodeBuffer& cbuf) const bool Matcher::match_rule_supported(int opcode) { - // TODO - // identify extra cases that we might want to provide match rules for - // e.g. Op_StrEquals and other intrinsics + switch (opcode) { + case Op_StrComp: + case Op_StrIndexOf: + if (CompactStrings) return false; + break; + default: + break; + } + if (!has_match_rule(opcode)) { return false; } @@ -14797,10 +14803,10 @@ instruct partialSubtypeCheckVsZero(iRegP_R4 sub, iRegP_R0 super, iRegP_R2 temp, ins_pipe(pipe_class_memory); %} -instruct string_compare(iRegP_R1 str1, iRegI_R2 cnt1, iRegP_R3 str2, iRegI_R4 cnt2, +instruct string_compareU(iRegP_R1 str1, iRegI_R2 cnt1, iRegP_R3 str2, iRegI_R4 cnt2, iRegI_R0 result, iRegP_R10 tmp1, rFlagsReg cr) %{ - predicate(!CompactStrings); + predicate(((StrCompNode*)n)->encoding() == StrIntrinsicNode::UU); match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2))); effect(KILL tmp1, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr); @@ -14819,7 +14825,7 @@ instruct string_compare(iRegP_R1 str1, iRegI_R2 cnt1, iRegP_R3 str2, iRegI_R4 cn instruct string_indexof(iRegP_R1 str1, iRegI_R4 cnt1, iRegP_R3 str2, iRegI_R2 cnt2, iRegI_R0 result, iRegI tmp1, iRegI tmp2, iRegI tmp3, iRegI tmp4, rFlagsReg cr) %{ - predicate(!CompactStrings); + predicate(((StrIndexOfNode*)n)->encoding() == StrIntrinsicNode::UU); match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 cnt2))); effect(USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, KILL cr); @@ -14839,7 +14845,7 @@ instruct string_indexof_con(iRegP_R1 str1, iRegI_R4 cnt1, iRegP_R3 str2, immI_le_4 int_cnt2, iRegI_R0 result, iRegI tmp1, iRegI tmp2, iRegI tmp3, iRegI tmp4, rFlagsReg cr) %{ - predicate(!CompactStrings); + predicate(((StrIndexOfNode*)n)->encoding() == StrIntrinsicNode::UU); match(Set result (StrIndexOf (Binary str1 cnt1) (Binary str2 int_cnt2))); effect(USE_KILL str1, USE_KILL str2, USE_KILL cnt1, TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, KILL cr); @@ -14856,10 +14862,27 @@ instruct string_indexof_con(iRegP_R1 str1, iRegI_R4 cnt1, iRegP_R3 str2, ins_pipe(pipe_class_memory); %} -instruct string_equals(iRegP_R1 str1, iRegP_R3 str2, iRegI_R4 cnt, +instruct string_equalsL(iRegP_R1 str1, iRegP_R3 str2, iRegI_R4 cnt, + iRegI_R0 result, rFlagsReg cr) +%{ + predicate(((StrEqualsNode*)n)->encoding() == StrIntrinsicNode::LL); + match(Set result (StrEquals (Binary str1 str2) cnt)); + effect(USE_KILL str1, USE_KILL str2, USE_KILL cnt, KILL cr); + + format %{ "String Equals $str1,$str2,$cnt -> $result" %} + ins_encode %{ + // Count is in 8-bit bytes; non-Compact chars are 16 bits. + __ arrays_equals($str1$$Register, $str2$$Register, + $result$$Register, $cnt$$Register, + 1, /*is_string*/true); + %} + ins_pipe(pipe_class_memory); +%} + +instruct string_equalsU(iRegP_R1 str1, iRegP_R3 str2, iRegI_R4 cnt, iRegI_R0 result, rFlagsReg cr) %{ - predicate(!CompactStrings); + predicate(((StrEqualsNode*)n)->encoding() == StrIntrinsicNode::UU); match(Set result (StrEquals (Binary str1 str2) cnt)); effect(USE_KILL str1, USE_KILL str2, USE_KILL cnt, KILL cr); diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp index 0ede2e9847a..0859c095834 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp @@ -4585,7 +4585,16 @@ void MacroAssembler::arrays_equals(Register a1, Register a2, assert(elem_size == 1 || elem_size == 2, "must be char or byte"); assert_different_registers(a1, a2, result, cnt1, rscratch1, rscratch2); - BLOCK_COMMENT(is_string ? "string_equals {" : "array_equals {"); +#ifndef PRODUCT + { + const char kind = (elem_size == 2) ? 'U' : 'L'; + char comment[64]; + snprintf(comment, sizeof comment, "%s%c%s {", + is_string ? "string_equals" : "array_equals", + kind, "{"); + BLOCK_COMMENT(comment); + } +#endif mov(result, false); -- GitLab From e08e2ac711fcbd23a70257a60a522c4f6f6f90fe Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Mon, 18 Apr 2016 20:57:27 +0300 Subject: [PATCH 151/400] 8154135: Loop alignment may be added inside the loop body Reviewed-by: kvn, vlivanov --- hotspot/src/share/vm/opto/block.cpp | 12 +++++++++--- hotspot/src/share/vm/opto/block.hpp | 2 +- hotspot/src/share/vm/opto/c2_globals.hpp | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/opto/block.cpp b/hotspot/src/share/vm/opto/block.cpp index 2dbd3e4b894..bc3d772c3f8 100644 --- a/hotspot/src/share/vm/opto/block.cpp +++ b/hotspot/src/share/vm/opto/block.cpp @@ -73,7 +73,7 @@ void Block_List::print() { } #endif -uint Block::code_alignment() { +uint Block::code_alignment() const { // Check for Root block if (_pre_order == 0) return CodeEntryAlignment; // Check for Start block @@ -1727,8 +1727,14 @@ bool Trace::backedge(CFGEdge *e) { first_block()->set_loop_alignment(targ_block); } else { - // Backbranch into the middle of a trace - targ_block->set_loop_alignment(targ_block); + // That loop may already have a loop top (we're reaching it again + // through the backedge of an outer loop) + Block* b = prev(targ_block); + bool has_top = targ_block->head()->is_Loop() && b->has_loop_alignment() && !b->head()->is_Loop(); + if (!has_top) { + // Backbranch into the middle of a trace + targ_block->set_loop_alignment(targ_block); + } } return loop_rotated; diff --git a/hotspot/src/share/vm/opto/block.hpp b/hotspot/src/share/vm/opto/block.hpp index d7aa5bb783c..e1d4874d3ee 100644 --- a/hotspot/src/share/vm/opto/block.hpp +++ b/hotspot/src/share/vm/opto/block.hpp @@ -197,7 +197,7 @@ public: // Report the alignment required by this block. Must be a power of 2. // The previous block will insert nops to get this alignment. - uint code_alignment(); + uint code_alignment() const; uint compute_loop_alignment(); // BLOCK_FREQUENCY is a sentinel to mark uses of constant block frequencies. diff --git a/hotspot/src/share/vm/opto/c2_globals.hpp b/hotspot/src/share/vm/opto/c2_globals.hpp index ca02fd2cc8e..802b0961e1a 100644 --- a/hotspot/src/share/vm/opto/c2_globals.hpp +++ b/hotspot/src/share/vm/opto/c2_globals.hpp @@ -587,7 +587,7 @@ range(0, 100) \ \ product(bool, BlockLayoutRotateLoops, true, \ - "Allow back branches to be fall throughs in the block layour") \ + "Allow back branches to be fall throughs in the block layout") \ \ develop(bool, InlineReflectionGetCallerClass, true, \ "inline sun.reflect.Reflection.getCallerClass(), known to be " \ -- GitLab From 64cf7e6b6f4e5b05185815cb9582d30fb91baf49 Mon Sep 17 00:00:00 2001 From: Michael Berg Date: Mon, 18 Apr 2016 15:18:14 -0700 Subject: [PATCH 152/400] 8153998: Masked vector post loops Masked vectorization for post loops to execute in a single iteration in place of fixup scalar loops which used to take many iterations to complete work for user loops. Reviewed-by: twisti, kvn --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 4 + hotspot/src/cpu/ppc/vm/ppc.ad | 4 + hotspot/src/cpu/sparc/vm/sparc.ad | 4 + hotspot/src/cpu/x86/vm/assembler_x86.cpp | 179 ++++++++--- hotspot/src/cpu/x86/vm/assembler_x86.hpp | 14 + hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp | 12 + hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp | 4 + hotspot/src/cpu/x86/vm/x86.ad | 65 +++- hotspot/src/cpu/x86/vm/x86_32.ad | 65 +++- hotspot/src/cpu/x86/vm/x86_64.ad | 66 +++- hotspot/src/share/vm/opto/classes.hpp | 1 + hotspot/src/share/vm/opto/loopUnswitch.cpp | 13 +- hotspot/src/share/vm/opto/loopnode.cpp | 2 + hotspot/src/share/vm/opto/matcher.hpp | 3 + hotspot/src/share/vm/opto/node.hpp | 8 +- hotspot/src/share/vm/opto/superword.cpp | 287 ++++++++++++++---- hotspot/src/share/vm/opto/superword.hpp | 1 + hotspot/src/share/vm/opto/vectornode.hpp | 14 + hotspot/src/share/vm/runtime/vmStructs.cpp | 1 + 19 files changed, 629 insertions(+), 118 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index 47c83025cb7..3f15e6abf8f 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -3346,6 +3346,10 @@ const bool Matcher::match_rule_supported_vector(int opcode, int vlen) { return ret_value; // Per default match rules are supported. } +const bool Matcher::has_predicated_vectors(void) { + return false; +} + const int Matcher::float_pressure(int default_pressure_threshold) { return default_pressure_threshold; } diff --git a/hotspot/src/cpu/ppc/vm/ppc.ad b/hotspot/src/cpu/ppc/vm/ppc.ad index 20521eb8e18..1b38c16e199 100644 --- a/hotspot/src/cpu/ppc/vm/ppc.ad +++ b/hotspot/src/cpu/ppc/vm/ppc.ad @@ -2047,6 +2047,10 @@ const bool Matcher::match_rule_supported_vector(int opcode, int vlen) { return ret_value; // Per default match rules are supported. } +const bool Matcher::has_predicated_vectors(void) { + return false; +} + const int Matcher::float_pressure(int default_pressure_threshold) { return default_pressure_threshold; } diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad index d669d8732b8..079c45146d2 100644 --- a/hotspot/src/cpu/sparc/vm/sparc.ad +++ b/hotspot/src/cpu/sparc/vm/sparc.ad @@ -1904,6 +1904,10 @@ const bool Matcher::match_rule_supported_vector(int opcode, int vlen) { return ret_value; // Per default match rules are supported. } +const bool Matcher::has_predicated_vectors(void) { + return false; +} + const int Matcher::float_pressure(int default_pressure_threshold) { return default_pressure_threshold; } diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp index 564db640d56..f294d84cb36 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp @@ -1240,6 +1240,7 @@ void Assembler::addr_nop_8() { void Assembler::addsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x58); emit_int8((unsigned char)(0xC0 | encode)); @@ -1250,6 +1251,7 @@ void Assembler::addsd(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x58); emit_operand(dst, src); @@ -1599,6 +1601,7 @@ void Assembler::comisd(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false);; attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x2F); emit_operand(dst, src); @@ -1607,6 +1610,7 @@ void Assembler::comisd(XMMRegister dst, Address src) { void Assembler::comisd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x2F); emit_int8((unsigned char)(0xC0 | encode)); @@ -1733,6 +1737,7 @@ void Assembler::cvtdq2ps(XMMRegister dst, XMMRegister src) { void Assembler::cvtsd2ss(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x5A); emit_int8((unsigned char)(0xC0 | encode)); @@ -1743,6 +1748,7 @@ void Assembler::cvtsd2ss(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x5A); emit_operand(dst, src); @@ -1849,6 +1855,7 @@ void Assembler::divsd(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x5E); emit_operand(dst, src); @@ -1857,6 +1864,7 @@ void Assembler::divsd(XMMRegister dst, Address src) { void Assembler::divsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x5E); emit_int8((unsigned char)(0xC0 | encode)); @@ -2131,6 +2139,7 @@ void Assembler::movapd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); int vector_len = VM_Version::supports_avx512novl() ? AVX_512bit : AVX_128bit; InstructionAttr attributes(vector_len, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x28); emit_int8((unsigned char)(0xC0 | encode)); @@ -2165,6 +2174,7 @@ void Assembler::movddup(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse3(), "")); int vector_len = VM_Version::supports_avx512novl() ? AVX_512bit : AVX_128bit; InstructionAttr attributes(vector_len, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x12); emit_int8(0xC0 | encode); @@ -2202,6 +2212,15 @@ void Assembler::kmovwl(Register dst, KRegister src) { emit_int8((unsigned char)(0xC0 | encode)); } +void Assembler::kmovwl(KRegister dst, Address src) { + assert(VM_Version::supports_evex(), ""); + InstructionMark im(this); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false); + vex_prefix(src, 0, dst->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0x90); + emit_operand((Register)dst, src); +} + void Assembler::kmovdl(KRegister dst, Register src) { assert(VM_Version::supports_avx512bw(), ""); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false); @@ -2260,6 +2279,14 @@ void Assembler::kmovql(Register dst, KRegister src) { emit_int8((unsigned char)(0xC0 | encode)); } +void Assembler::knotwl(KRegister dst, KRegister src) { + assert(VM_Version::supports_evex(), ""); + InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0x44); + emit_int8((unsigned char)(0xC0 | encode)); +} + // This instruction produces ZF or CF flags void Assembler::kortestbl(KRegister src1, KRegister src2) { assert(VM_Version::supports_avx512dq(), ""); @@ -2432,6 +2459,7 @@ void Assembler::vmovdqu(Address dst, XMMRegister src) { void Assembler::evmovdqub(XMMRegister dst, XMMRegister src, int vector_len) { assert(VM_Version::supports_evex(), ""); InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3; int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes); emit_int8(0x6F); @@ -2444,6 +2472,7 @@ void Assembler::evmovdqub(XMMRegister dst, Address src, int vector_len) { InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3; attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); vex_prefix(src, 0, dst->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes); emit_int8(0x6F); emit_operand(dst, src); @@ -2456,6 +2485,7 @@ void Assembler::evmovdqub(Address dst, XMMRegister src, int vector_len) { InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3; attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); vex_prefix(dst, 0, src->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes); emit_int8(0x7F); emit_operand(src, dst); @@ -2464,6 +2494,7 @@ void Assembler::evmovdqub(Address dst, XMMRegister src, int vector_len) { void Assembler::evmovdquw(XMMRegister dst, XMMRegister src, int vector_len) { assert(VM_Version::supports_evex(), ""); InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3; int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes); emit_int8(0x6F); @@ -2475,6 +2506,7 @@ void Assembler::evmovdquw(XMMRegister dst, Address src, int vector_len) { InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3; vex_prefix(src, 0, dst->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes); emit_int8(0x6F); @@ -2487,6 +2519,7 @@ void Assembler::evmovdquw(Address dst, XMMRegister src, int vector_len) { InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3; vex_prefix(dst, 0, src->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes); emit_int8(0x7F); @@ -2518,8 +2551,8 @@ void Assembler::evmovdqul(Address dst, XMMRegister src, int vector_len) { assert(src != xnoreg, "sanity"); InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); - attributes.set_is_evex_instruction(); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F, &attributes); emit_int8(0x7F); emit_operand(src, dst); @@ -2538,8 +2571,8 @@ void Assembler::evmovdquq(XMMRegister dst, Address src, int vector_len) { assert(VM_Version::supports_evex(), ""); InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); - attributes.set_is_evex_instruction(); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); vex_prefix(src, 0, dst->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F, &attributes); emit_int8(0x6F); emit_operand(dst, src); @@ -2550,8 +2583,8 @@ void Assembler::evmovdquq(Address dst, XMMRegister src, int vector_len) { assert(src != xnoreg, "sanity"); InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); - attributes.set_is_evex_instruction(); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F, &attributes); emit_int8(0x7F); emit_operand(src, dst); @@ -2601,6 +2634,7 @@ void Assembler::movlpd(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_32bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x12); emit_operand(dst, src); @@ -2631,6 +2665,7 @@ void Assembler::movq(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, xnoreg, src, VEX_SIMD_F3, VEX_OPCODE_0F, &attributes); emit_int8(0x7E); emit_operand(dst, src); @@ -2641,6 +2676,7 @@ void Assembler::movq(Address dst, XMMRegister src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(src, xnoreg, dst, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0xD6); emit_operand(src, dst); @@ -2665,6 +2701,7 @@ void Assembler::movsbl(Register dst, Register src) { // movsxb void Assembler::movsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x10); emit_int8((unsigned char)(0xC0 | encode)); @@ -2675,6 +2712,7 @@ void Assembler::movsd(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, xnoreg, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x10); emit_operand(dst, src); @@ -2685,6 +2723,7 @@ void Assembler::movsd(Address dst, XMMRegister src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(src, xnoreg, dst, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x11); emit_operand(src, dst); @@ -2808,6 +2847,7 @@ void Assembler::mulsd(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x59); emit_operand(dst, src); @@ -2816,6 +2856,7 @@ void Assembler::mulsd(XMMRegister dst, Address src) { void Assembler::mulsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x59); emit_int8((unsigned char)(0xC0 | encode)); @@ -3795,6 +3836,7 @@ void Assembler::punpckldq(XMMRegister dst, XMMRegister src) { void Assembler::punpcklqdq(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x6C); emit_int8((unsigned char)(0xC0 | encode)); @@ -4090,6 +4132,7 @@ void Assembler::smovl() { void Assembler::sqrtsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x51); emit_int8((unsigned char)(0xC0 | encode)); @@ -4100,6 +4143,7 @@ void Assembler::sqrtsd(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x51); emit_operand(dst, src); @@ -4175,6 +4219,7 @@ void Assembler::subl(Register dst, Register src) { void Assembler::subsd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x5C); emit_int8((unsigned char)(0xC0 | encode)); @@ -4185,6 +4230,7 @@ void Assembler::subsd(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, dst, src, VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x5C); emit_operand(dst, src); @@ -4272,6 +4318,7 @@ void Assembler::ucomisd(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x2E); emit_operand(dst, src); @@ -4280,6 +4327,7 @@ void Assembler::ucomisd(XMMRegister dst, Address src) { void Assembler::ucomisd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x2E); emit_int8((unsigned char)(0xC0 | encode)); @@ -4391,6 +4439,7 @@ void Assembler::vaddsd(XMMRegister dst, XMMRegister nds, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x58); emit_operand(dst, src); @@ -4399,6 +4448,7 @@ void Assembler::vaddsd(XMMRegister dst, XMMRegister nds, Address src) { void Assembler::vaddsd(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x58); emit_int8((unsigned char)(0xC0 | encode)); @@ -4427,6 +4477,7 @@ void Assembler::vdivsd(XMMRegister dst, XMMRegister nds, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x5E); emit_operand(dst, src); @@ -4435,6 +4486,7 @@ void Assembler::vdivsd(XMMRegister dst, XMMRegister nds, Address src) { void Assembler::vdivsd(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x5E); emit_int8((unsigned char)(0xC0 | encode)); @@ -4463,6 +4515,7 @@ void Assembler::vmulsd(XMMRegister dst, XMMRegister nds, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x59); emit_operand(dst, src); @@ -4471,6 +4524,7 @@ void Assembler::vmulsd(XMMRegister dst, XMMRegister nds, Address src) { void Assembler::vmulsd(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x59); emit_int8((unsigned char)(0xC0 | encode)); @@ -4499,6 +4553,7 @@ void Assembler::vsubsd(XMMRegister dst, XMMRegister nds, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x5C); emit_operand(dst, src); @@ -4507,6 +4562,7 @@ void Assembler::vsubsd(XMMRegister dst, XMMRegister nds, Address src) { void Assembler::vsubsd(XMMRegister dst, XMMRegister nds, XMMRegister src) { assert(VM_Version::supports_avx(), ""); InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x5C); emit_int8((unsigned char)(0xC0 | encode)); @@ -4537,6 +4593,7 @@ void Assembler::vsubss(XMMRegister dst, XMMRegister nds, XMMRegister src) { void Assembler::addpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x58); emit_int8((unsigned char)(0xC0 | encode)); @@ -4546,6 +4603,7 @@ void Assembler::addpd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x58); @@ -4564,6 +4622,7 @@ void Assembler::addps(XMMRegister dst, XMMRegister src) { void Assembler::vaddpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x58); emit_int8((unsigned char)(0xC0 | encode)); @@ -4582,6 +4641,7 @@ void Assembler::vaddpd(XMMRegister dst, XMMRegister nds, Address src, int vector InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x58); emit_operand(dst, src); @@ -4600,6 +4660,7 @@ void Assembler::vaddps(XMMRegister dst, XMMRegister nds, Address src, int vector void Assembler::subpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x5C); emit_int8((unsigned char)(0xC0 | encode)); @@ -4616,6 +4677,7 @@ void Assembler::subps(XMMRegister dst, XMMRegister src) { void Assembler::vsubpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x5C); emit_int8((unsigned char)(0xC0 | encode)); @@ -4634,6 +4696,7 @@ void Assembler::vsubpd(XMMRegister dst, XMMRegister nds, Address src, int vector InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x5C); emit_operand(dst, src); @@ -4652,6 +4715,7 @@ void Assembler::vsubps(XMMRegister dst, XMMRegister nds, Address src, int vector void Assembler::mulpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x59); emit_int8((unsigned char)(0xC0 | encode)); @@ -4662,6 +4726,7 @@ void Assembler::mulpd(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x59); emit_operand(dst, src); @@ -4678,6 +4743,7 @@ void Assembler::mulps(XMMRegister dst, XMMRegister src) { void Assembler::vmulpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x59); emit_int8((unsigned char)(0xC0 | encode)); @@ -4696,6 +4762,7 @@ void Assembler::vmulpd(XMMRegister dst, XMMRegister nds, Address src, int vector InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x59); emit_operand(dst, src); @@ -4714,6 +4781,7 @@ void Assembler::vmulps(XMMRegister dst, XMMRegister nds, Address src, int vector void Assembler::divpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x5E); emit_int8((unsigned char)(0xC0 | encode)); @@ -4730,6 +4798,7 @@ void Assembler::divps(XMMRegister dst, XMMRegister src) { void Assembler::vdivpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x5E); emit_int8((unsigned char)(0xC0 | encode)); @@ -4748,6 +4817,7 @@ void Assembler::vdivpd(XMMRegister dst, XMMRegister nds, Address src, int vector InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x5E); emit_operand(dst, src); @@ -4766,6 +4836,7 @@ void Assembler::vdivps(XMMRegister dst, XMMRegister nds, Address src, int vector void Assembler::vsqrtpd(XMMRegister dst, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x51); emit_int8((unsigned char)(0xC0 | encode)); @@ -4776,6 +4847,7 @@ void Assembler::vsqrtpd(XMMRegister dst, Address src, int vector_len) { InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x51); emit_operand(dst, src); @@ -4784,6 +4856,7 @@ void Assembler::vsqrtpd(XMMRegister dst, Address src, int vector_len) { void Assembler::andpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x54); emit_int8((unsigned char)(0xC0 | encode)); @@ -4812,6 +4885,7 @@ void Assembler::andpd(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x54); emit_operand(dst, src); @@ -4820,6 +4894,7 @@ void Assembler::andpd(XMMRegister dst, Address src) { void Assembler::vandpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); InstructionAttr attributes(vector_len, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x54); emit_int8((unsigned char)(0xC0 | encode)); @@ -4838,6 +4913,7 @@ void Assembler::vandpd(XMMRegister dst, XMMRegister nds, Address src, int vector InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x54); emit_operand(dst, src); @@ -4856,6 +4932,7 @@ void Assembler::vandps(XMMRegister dst, XMMRegister nds, Address src, int vector void Assembler::unpckhpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x15); emit_int8((unsigned char)(0xC0 | encode)); @@ -4864,6 +4941,7 @@ void Assembler::unpckhpd(XMMRegister dst, XMMRegister src) { void Assembler::unpcklpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x14); emit_int8((unsigned char)(0xC0 | encode)); @@ -4872,6 +4950,7 @@ void Assembler::unpcklpd(XMMRegister dst, XMMRegister src) { void Assembler::xorpd(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x57); emit_int8((unsigned char)(0xC0 | encode)); @@ -4890,6 +4969,7 @@ void Assembler::xorpd(XMMRegister dst, Address src) { InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x57); emit_operand(dst, src); @@ -4908,6 +4988,7 @@ void Assembler::xorps(XMMRegister dst, Address src) { void Assembler::vxorpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx(), ""); InstructionAttr attributes(vector_len, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x57); emit_int8((unsigned char)(0xC0 | encode)); @@ -4926,6 +5007,7 @@ void Assembler::vxorpd(XMMRegister dst, XMMRegister nds, Address src, int vector InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x57); emit_operand(dst, src); @@ -4996,6 +5078,7 @@ void Assembler::paddd(XMMRegister dst, Address src) { void Assembler::paddq(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0xD4); emit_int8((unsigned char)(0xC0 | encode)); @@ -5044,6 +5127,7 @@ void Assembler::vpaddd(XMMRegister dst, XMMRegister nds, XMMRegister src, int ve void Assembler::vpaddq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(UseAVX > 0, "requires some form of AVX"); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0xD4); emit_int8((unsigned char)(0xC0 | encode)); @@ -5084,6 +5168,7 @@ void Assembler::vpaddq(XMMRegister dst, XMMRegister nds, Address src, int vector InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0xD4); emit_operand(dst, src); @@ -5115,6 +5200,7 @@ void Assembler::psubd(XMMRegister dst, XMMRegister src) { void Assembler::psubq(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0xFB); emit_int8((unsigned char)(0xC0 | encode)); @@ -5147,6 +5233,7 @@ void Assembler::vpsubd(XMMRegister dst, XMMRegister nds, XMMRegister src, int ve void Assembler::vpsubq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(UseAVX > 0, "requires some form of AVX"); InstructionAttr attributes(vector_len, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0xFB); emit_int8((unsigned char)(0xC0 | encode)); @@ -5187,6 +5274,7 @@ void Assembler::vpsubq(XMMRegister dst, XMMRegister nds, Address src, int vector InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0xFB); emit_operand(dst, src); @@ -5225,8 +5313,9 @@ void Assembler::vpmulld(XMMRegister dst, XMMRegister nds, XMMRegister src, int v } void Assembler::vpmullq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { - assert(UseAVX > 2, "requires some form of AVX"); - InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true); + assert(UseAVX > 2, "requires some form of EVEX"); + InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); emit_int8(0x40); emit_int8((unsigned char)(0xC0 | encode)); @@ -5253,10 +5342,11 @@ void Assembler::vpmulld(XMMRegister dst, XMMRegister nds, Address src, int vecto } void Assembler::vpmullq(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { - assert(UseAVX > 0, "requires some form of AVX"); + assert(UseAVX > 2, "requires some form of EVEX"); InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_dq, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_64bit); + attributes.set_is_evex_instruction(); vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); emit_int8(0x40); emit_operand(dst, src); @@ -5312,6 +5402,7 @@ void Assembler::pslld(XMMRegister dst, XMMRegister shift) { void Assembler::psllq(XMMRegister dst, XMMRegister shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, shift, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0xF3); emit_int8((unsigned char)(0xC0 | encode)); @@ -5341,6 +5432,7 @@ void Assembler::vpslld(XMMRegister dst, XMMRegister src, int shift, int vector_l void Assembler::vpsllq(XMMRegister dst, XMMRegister src, int shift, int vector_len) { assert(UseAVX > 0, "requires some form of AVX"); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); // XMM6 is for /6 encoding: 66 0F 73 /6 ib int encode = vex_prefix_and_encode(xmm6->encoding(), dst->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x73); @@ -5367,6 +5459,7 @@ void Assembler::vpslld(XMMRegister dst, XMMRegister src, XMMRegister shift, int void Assembler::vpsllq(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) { assert(UseAVX > 0, "requires some form of AVX"); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), src->encoding(), shift->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0xF3); emit_int8((unsigned char)(0xC0 | encode)); @@ -5398,6 +5491,7 @@ void Assembler::psrlq(XMMRegister dst, int shift) { // shifts 128 bit value in xmm register by number of bytes. NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); // XMM2 is for /2 encoding: 66 0F 73 /2 ib int encode = simd_prefix_and_encode(xmm2, dst, dst, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x73); @@ -5424,6 +5518,7 @@ void Assembler::psrld(XMMRegister dst, XMMRegister shift) { void Assembler::psrlq(XMMRegister dst, XMMRegister shift) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, shift, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0xD3); emit_int8((unsigned char)(0xC0 | encode)); @@ -5452,6 +5547,7 @@ void Assembler::vpsrld(XMMRegister dst, XMMRegister src, int shift, int vector_l void Assembler::vpsrlq(XMMRegister dst, XMMRegister src, int shift, int vector_len) { assert(UseAVX > 0, "requires some form of AVX"); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); // XMM2 is for /2 encoding: 66 0F 73 /2 ib int encode = vex_prefix_and_encode(xmm2->encoding(), dst->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x73); @@ -5478,6 +5574,7 @@ void Assembler::vpsrld(XMMRegister dst, XMMRegister src, XMMRegister shift, int void Assembler::vpsrlq(XMMRegister dst, XMMRegister src, XMMRegister shift, int vector_len) { assert(UseAVX > 0, "requires some form of AVX"); InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), src->encoding(), shift->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0xD3); emit_int8((unsigned char)(0xC0 | encode)); @@ -5587,6 +5684,7 @@ void Assembler::vpand(XMMRegister dst, XMMRegister nds, Address src, int vector_ void Assembler::pandn(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8((unsigned char)0xDF); emit_int8((unsigned char)(0xC0 | encode)); @@ -5876,9 +5974,9 @@ void Assembler::vextracti32x4(Address dst, XMMRegister src, uint8_t imm8) { } void Assembler::vextracti64x2(XMMRegister dst, XMMRegister src, uint8_t imm8) { - assert(VM_Version::supports_evex(), ""); + assert(VM_Version::supports_avx512dq(), ""); assert(imm8 <= 0x03, "imm8: %u", imm8); - InstructionAttr attributes(AVX_512bit, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + InstructionAttr attributes(AVX_512bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); int encode = vex_prefix_and_encode(src->encoding(), 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); emit_int8(0x39); emit_int8((unsigned char)(0xC0 | encode)); @@ -5966,9 +6064,9 @@ void Assembler::vextractf32x4(Address dst, XMMRegister src, uint8_t imm8) { } void Assembler::vextractf64x2(XMMRegister dst, XMMRegister src, uint8_t imm8) { - assert(VM_Version::supports_evex(), ""); + assert(VM_Version::supports_avx512dq(), ""); assert(imm8 <= 0x03, "imm8: %u", imm8); - InstructionAttr attributes(AVX_512bit, /* vex_w */ !_legacy_mode_dq, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + InstructionAttr attributes(AVX_512bit, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); int encode = vex_prefix_and_encode(src->encoding(), 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); emit_int8(0x19); emit_int8((unsigned char)(0xC0 | encode)); @@ -6093,7 +6191,8 @@ void Assembler::evpbroadcastd(XMMRegister dst, Address src, int vector_len) { // duplicate 8-byte integer data from src into programmed locations in dest : requires AVX512VL void Assembler::evpbroadcastq(XMMRegister dst, XMMRegister src, int vector_len) { assert(VM_Version::supports_evex(), ""); - InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); emit_int8(0x59); emit_int8((unsigned char)(0xC0 | encode)); @@ -6103,7 +6202,8 @@ void Assembler::evpbroadcastq(XMMRegister dst, Address src, int vector_len) { assert(VM_Version::supports_evex(), ""); assert(dst != xnoreg, "sanity"); InstructionMark im(this); - InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); // swap src<->dst for encoding vex_prefix(src, 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); @@ -6138,7 +6238,8 @@ void Assembler::evpbroadcastss(XMMRegister dst, Address src, int vector_len) { // duplicate double precision data from src into programmed locations in dest : requires AVX512VL void Assembler::evpbroadcastsd(XMMRegister dst, XMMRegister src, int vector_len) { assert(VM_Version::supports_evex(), ""); - InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); emit_int8(0x19); emit_int8((unsigned char)(0xC0 | encode)); @@ -6148,8 +6249,9 @@ void Assembler::evpbroadcastsd(XMMRegister dst, Address src, int vector_len) { assert(VM_Version::supports_evex(), ""); assert(dst != xnoreg, "sanity"); InstructionMark im(this); - InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); + attributes.set_rex_vex_w_reverted(); // swap src<->dst for encoding vex_prefix(src, 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); emit_int8(0x19); @@ -6163,12 +6265,9 @@ void Assembler::evpbroadcastsd(XMMRegister dst, Address src, int vector_len) { void Assembler::evpbroadcastb(XMMRegister dst, Register src, int vector_len) { assert(VM_Version::supports_evex(), ""); InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); - if (attributes.is_evex_instruction()) { - emit_int8(0x7A); - } else { - emit_int8(0x78); - } + emit_int8(0x7A); emit_int8((unsigned char)(0xC0 | encode)); } @@ -6176,12 +6275,9 @@ void Assembler::evpbroadcastb(XMMRegister dst, Register src, int vector_len) { void Assembler::evpbroadcastw(XMMRegister dst, Register src, int vector_len) { assert(VM_Version::supports_evex(), ""); InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); - if (attributes.is_evex_instruction()) { - emit_int8(0x7B); - } else { - emit_int8(0x79); - } + emit_int8(0x7B); emit_int8((unsigned char)(0xC0 | encode)); } @@ -6189,12 +6285,9 @@ void Assembler::evpbroadcastw(XMMRegister dst, Register src, int vector_len) { void Assembler::evpbroadcastd(XMMRegister dst, Register src, int vector_len) { assert(VM_Version::supports_evex(), ""); InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); - if (attributes.is_evex_instruction()) { - emit_int8(0x7C); - } else { - emit_int8(0x58); - } + emit_int8(0x7C); emit_int8((unsigned char)(0xC0 | encode)); } @@ -6202,12 +6295,9 @@ void Assembler::evpbroadcastd(XMMRegister dst, Register src, int vector_len) { void Assembler::evpbroadcastq(XMMRegister dst, Register src, int vector_len) { assert(VM_Version::supports_evex(), ""); InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); - if (attributes.is_evex_instruction()) { - emit_int8(0x7C); - } else { - emit_int8(0x59); - } + emit_int8(0x7C); emit_int8((unsigned char)(0xC0 | encode)); } @@ -6862,6 +6952,9 @@ void Assembler::vex_prefix(Address adr, int nds_enc, int xreg_enc, VexSimdPrefix attributes->set_is_evex_instruction(); evex_prefix(vex_r, vex_b, vex_x, evex_r, evex_v, nds_enc, pre, opc); } else { + if (UseAVX > 2 && attributes->is_rex_vex_w_reverted()) { + attributes->set_rex_vex_w(false); + } vex_prefix(vex_r, vex_b, vex_x, nds_enc, pre, opc); } } @@ -6921,6 +7014,9 @@ int Assembler::vex_prefix_and_encode(int dst_enc, int nds_enc, int src_enc, VexS attributes->set_is_evex_instruction(); evex_prefix(vex_r, vex_b, vex_x, evex_r, evex_v, nds_enc, pre, opc); } else { + if (UseAVX > 2 && attributes->is_rex_vex_w_reverted()) { + attributes->set_rex_vex_w(false); + } vex_prefix(vex_r, vex_b, vex_x, nds_enc, pre, opc); } @@ -6975,6 +7071,21 @@ void Assembler::vpblendd(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMM emit_int8((unsigned char)(0xF0 & src2_enc<<4)); } +void Assembler::shlxl(Register dst, Register src1, Register src2) { + assert(VM_Version::supports_bmi2(), ""); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false); + int encode = vex_prefix_and_encode(dst->encoding(), src2->encoding(), src1->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8((unsigned char)0xF7); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::shlxq(Register dst, Register src1, Register src2) { + assert(VM_Version::supports_bmi2(), ""); + InstructionAttr attributes(AVX_128bit, /* vex_w */ true, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false); + int encode = vex_prefix_and_encode(dst->encoding(), src2->encoding(), src1->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8((unsigned char)0xF7); + emit_int8((unsigned char)(0xC0 | encode)); +} #ifndef _LP64 diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp index 1297aa2406f..78fe0ad05ba 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp @@ -1337,6 +1337,7 @@ private: void kmovbl(KRegister dst, Register src); void kmovbl(Register dst, KRegister src); void kmovwl(KRegister dst, Register src); + void kmovwl(KRegister dst, Address src); void kmovwl(Register dst, KRegister src); void kmovdl(KRegister dst, Register src); void kmovdl(Register dst, KRegister src); @@ -1346,6 +1347,8 @@ private: void kmovql(KRegister dst, Register src); void kmovql(Register dst, KRegister src); + void knotwl(KRegister dst, KRegister src); + void kortestbl(KRegister dst, KRegister src); void kortestwl(KRegister dst, KRegister src); void kortestdl(KRegister dst, KRegister src); @@ -2052,6 +2055,8 @@ private: void cmppd(XMMRegister dst, XMMRegister nds, XMMRegister src, int cop, int vector_len); void vpblendd(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMMRegister src2, int vector_len); + void shlxl(Register dst, Register src1, Register src2); + void shlxq(Register dst, Register src1, Register src2); protected: // Next instructions require address alignment 16 bytes SSE mode. @@ -2077,6 +2082,7 @@ public: : _avx_vector_len(vector_len), _rex_vex_w(rex_vex_w), + _rex_vex_w_reverted(false), _legacy_mode(legacy_mode), _no_reg_mask(no_reg_mask), _uses_vl(uses_vl), @@ -2100,6 +2106,7 @@ public: private: int _avx_vector_len; bool _rex_vex_w; + bool _rex_vex_w_reverted; bool _legacy_mode; bool _no_reg_mask; bool _uses_vl; @@ -2116,6 +2123,7 @@ public: // query functions for field accessors int get_vector_len(void) const { return _avx_vector_len; } bool is_rex_vex_w(void) const { return _rex_vex_w; } + bool is_rex_vex_w_reverted(void) { return _rex_vex_w_reverted; } bool is_legacy_mode(void) const { return _legacy_mode; } bool is_no_reg_mask(void) const { return _no_reg_mask; } bool uses_vl(void) const { return _uses_vl; } @@ -2129,6 +2137,12 @@ public: // Set the vector len manually void set_vector_len(int vector_len) { _avx_vector_len = vector_len; } + // Set revert rex_vex_w for avx encoding + void set_rex_vex_w_reverted(void) { _rex_vex_w_reverted = true; } + + // Set rex_vex_w based on state + void set_rex_vex_w(bool state) { _rex_vex_w = state; } + // Set the instruction to be encoded in AVX mode void set_is_legacy_mode(void) { _legacy_mode = true; } diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index 7d2c73af358..d831256fd66 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -3399,6 +3399,18 @@ void MacroAssembler::movq(XMMRegister dst, AddressLiteral src) { } } +void MacroAssembler::setvectmask(Register dst, Register src) { + Assembler::movl(dst, 1); + Assembler::shlxl(dst, dst, src); + Assembler::decl(dst); + Assembler::kmovdl(k1, dst); + Assembler::movl(dst, src); +} + +void MacroAssembler::restorevectmask() { + Assembler::knotwl(k1, k0); +} + void MacroAssembler::movdbl(XMMRegister dst, AddressLiteral src) { if (reachable(src)) { if (UseXmmLoadAndClearUpper) { diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp index 3c703186b3b..b92ec2e99af 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp @@ -156,6 +156,10 @@ class MacroAssembler: public Assembler { void incrementq(Register reg, int value = 1); void incrementq(Address dst, int value = 1); + // special instructions for EVEX + void setvectmask(Register dst, Register src); + void restorevectmask(); + // Support optimal SSE move instructions. void movflt(XMMRegister dst, XMMRegister src) { if (UseXmmRegToRegMoveAll) { movaps(dst, src); return; } diff --git a/hotspot/src/cpu/x86/vm/x86.ad b/hotspot/src/cpu/x86/vm/x86.ad index d1549a5df0b..50e3d136bf0 100644 --- a/hotspot/src/cpu/x86/vm/x86.ad +++ b/hotspot/src/cpu/x86/vm/x86.ad @@ -1758,6 +1758,15 @@ const bool Matcher::match_rule_supported_vector(int opcode, int vlen) { return ret_value; // Per default match rules are supported. } +const bool Matcher::has_predicated_vectors(void) { + bool ret_value = false; + if (UseAVX > 2) { + ret_value = VM_Version::supports_avx512vl(); + } + + return ret_value; +} + const int Matcher::float_pressure(int default_pressure_threshold) { int float_pressure_threshold = default_pressure_threshold; #ifdef _LP64 @@ -1875,7 +1884,7 @@ static int vec_mov_helper(CodeBuffer *cbuf, bool do_size, int src_lo, int dst_lo __ vmovdqu(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo])); break; case Op_VecZ: - __ evmovdqul(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo]), 2); + __ evmovdquq(as_XMMRegister(Matcher::_regEncode[dst_lo]), as_XMMRegister(Matcher::_regEncode[src_lo]), 2); break; default: ShouldNotReachHere(); @@ -1930,7 +1939,7 @@ static int vec_spill_helper(CodeBuffer *cbuf, bool do_size, bool is_load, __ vmovdqu(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset)); break; case Op_VecZ: - __ evmovdqul(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset), 2); + __ evmovdquq(as_XMMRegister(Matcher::_regEncode[reg]), Address(rsp, stack_offset), 2); break; default: ShouldNotReachHere(); @@ -1950,7 +1959,7 @@ static int vec_spill_helper(CodeBuffer *cbuf, bool do_size, bool is_load, __ vmovdqu(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg])); break; case Op_VecZ: - __ evmovdqul(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg]), 2); + __ evmovdquq(Address(rsp, stack_offset), as_XMMRegister(Matcher::_regEncode[reg]), 2); break; default: ShouldNotReachHere(); @@ -2176,6 +2185,19 @@ instruct ShouldNotReachHere() %{ ins_pipe(pipe_slow); %} +// =================================EVEX special=============================== + +instruct setMask(rRegI dst, rRegI src) %{ + predicate(Matcher::has_predicated_vectors()); + match(Set dst (SetVectMaskI src)); + effect(TEMP dst); + format %{ "setvectmask $dst, $src" %} + ins_encode %{ + __ setvectmask($dst$$Register, $src$$Register); + %} + ins_pipe(pipe_slow); +%} + // ============================================================================ instruct addF_reg(regF dst, regF src) %{ @@ -3069,11 +3091,11 @@ instruct loadV32(vecY dst, memory mem) %{ %} // Load vectors (64 bytes long) -instruct loadV64(vecZ dst, memory mem) %{ - predicate(n->as_LoadVector()->memory_size() == 64); +instruct loadV64_dword(vecZ dst, memory mem) %{ + predicate(n->as_LoadVector()->memory_size() == 64 && n->as_LoadVector()->element_size() <= 4); match(Set dst (LoadVector mem)); ins_cost(125); - format %{ "vmovdqu $dst k0,$mem\t! load vector (64 bytes)" %} + format %{ "vmovdqul $dst k0,$mem\t! load vector (64 bytes)" %} ins_encode %{ int vector_len = 2; __ evmovdqul($dst$$XMMRegister, $mem$$Address, vector_len); @@ -3081,6 +3103,19 @@ instruct loadV64(vecZ dst, memory mem) %{ ins_pipe( pipe_slow ); %} +// Load vectors (64 bytes long) +instruct loadV64_qword(vecZ dst, memory mem) %{ + predicate(n->as_LoadVector()->memory_size() == 64 && n->as_LoadVector()->element_size() > 4); + match(Set dst (LoadVector mem)); + ins_cost(125); + format %{ "vmovdquq $dst k0,$mem\t! load vector (64 bytes)" %} + ins_encode %{ + int vector_len = 2; + __ evmovdquq($dst$$XMMRegister, $mem$$Address, vector_len); + %} + ins_pipe( pipe_slow ); +%} + // Store vectors instruct storeV4(memory mem, vecS src) %{ predicate(n->as_StoreVector()->memory_size() == 4); @@ -3126,11 +3161,11 @@ instruct storeV32(memory mem, vecY src) %{ ins_pipe( pipe_slow ); %} -instruct storeV64(memory mem, vecZ src) %{ - predicate(n->as_StoreVector()->memory_size() == 64); +instruct storeV64_dword(memory mem, vecZ src) %{ + predicate(n->as_StoreVector()->memory_size() == 64 && n->as_StoreVector()->element_size() <= 4); match(Set mem (StoreVector mem src)); ins_cost(145); - format %{ "vmovdqu $mem k0,$src\t! store vector (64 bytes)" %} + format %{ "vmovdqul $mem k0,$src\t! store vector (64 bytes)" %} ins_encode %{ int vector_len = 2; __ evmovdqul($mem$$Address, $src$$XMMRegister, vector_len); @@ -3138,6 +3173,18 @@ instruct storeV64(memory mem, vecZ src) %{ ins_pipe( pipe_slow ); %} +instruct storeV64_qword(memory mem, vecZ src) %{ + predicate(n->as_StoreVector()->memory_size() == 64 && n->as_StoreVector()->element_size() > 4); + match(Set mem (StoreVector mem src)); + ins_cost(145); + format %{ "vmovdquq $mem k0,$src\t! store vector (64 bytes)" %} + ins_encode %{ + int vector_len = 2; + __ evmovdquq($mem$$Address, $src$$XMMRegister, vector_len); + %} + ins_pipe( pipe_slow ); +%} + // ====================LEGACY REPLICATE======================================= instruct Repl4B_mem(vecS dst, memory mem) %{ diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad index 9cdea2eacb2..883d2bf6823 100644 --- a/hotspot/src/cpu/x86/vm/x86_32.ad +++ b/hotspot/src/cpu/x86/vm/x86_32.ad @@ -1021,10 +1021,10 @@ static int vec_stack_to_stack_helper(CodeBuffer *cbuf, bool do_size, int src_off __ vmovdqu(xmm0, Address(rsp, -32)); break; case Op_VecZ: - __ evmovdqul(Address(rsp, -64), xmm0, 2); - __ evmovdqul(xmm0, Address(rsp, src_offset), 2); - __ evmovdqul(Address(rsp, dst_offset), xmm0, 2); - __ evmovdqul(xmm0, Address(rsp, -64), 2); + __ evmovdquq(Address(rsp, -64), xmm0, 2); + __ evmovdquq(xmm0, Address(rsp, src_offset), 2); + __ evmovdquq(Address(rsp, dst_offset), xmm0, 2); + __ evmovdquq(xmm0, Address(rsp, -64), 2); break; default: ShouldNotReachHere(); @@ -12047,6 +12047,7 @@ instruct jmpCon(cmpOp cop, eFlagsReg cr, label labl) %{ // Jump Direct Conditional - Label defines a relative address from Jcc+1 instruct jmpLoopEnd(cmpOp cop, eFlagsReg cr, label labl) %{ + predicate(!n->has_vector_mask_set()); match(CountedLoopEnd cop cr); effect(USE labl); @@ -12062,6 +12063,7 @@ instruct jmpLoopEnd(cmpOp cop, eFlagsReg cr, label labl) %{ // Jump Direct Conditional - Label defines a relative address from Jcc+1 instruct jmpLoopEndU(cmpOpU cop, eFlagsRegU cmp, label labl) %{ + predicate(!n->has_vector_mask_set()); match(CountedLoopEnd cop cmp); effect(USE labl); @@ -12076,6 +12078,7 @@ instruct jmpLoopEndU(cmpOpU cop, eFlagsRegU cmp, label labl) %{ %} instruct jmpLoopEndUCF(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{ + predicate(!n->has_vector_mask_set()); match(CountedLoopEnd cop cmp); effect(USE labl); @@ -12089,6 +12092,60 @@ instruct jmpLoopEndUCF(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{ ins_pipe( pipe_jcc ); %} +// mask version +// Jump Direct Conditional - Label defines a relative address from Jcc+1 +instruct jmpLoopEnd_and_restoreMask(cmpOp cop, eFlagsReg cr, label labl) %{ + predicate(n->has_vector_mask_set()); + match(CountedLoopEnd cop cr); + effect(USE labl); + + ins_cost(400); + format %{ "J$cop $labl\t# Loop end\n\t" + "restorevectmask \t# vector mask restore for loops" %} + size(10); + ins_encode %{ + Label* L = $labl$$label; + __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump + __ restorevectmask(); + %} + ins_pipe( pipe_jcc ); +%} + +// Jump Direct Conditional - Label defines a relative address from Jcc+1 +instruct jmpLoopEndU_and_restoreMask(cmpOpU cop, eFlagsRegU cmp, label labl) %{ + predicate(n->has_vector_mask_set()); + match(CountedLoopEnd cop cmp); + effect(USE labl); + + ins_cost(400); + format %{ "J$cop,u $labl\t# Loop end\n\t" + "restorevectmask \t# vector mask restore for loops" %} + size(10); + ins_encode %{ + Label* L = $labl$$label; + __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump + __ restorevectmask(); + %} + ins_pipe( pipe_jcc ); +%} + +instruct jmpLoopEndUCF_and_restoreMask(cmpOpUCF cop, eFlagsRegUCF cmp, label labl) %{ + predicate(n->has_vector_mask_set()); + match(CountedLoopEnd cop cmp); + effect(USE labl); + + ins_cost(300); + format %{ "J$cop,u $labl\t# Loop end\n\t" + "restorevectmask \t# vector mask restore for loops" %} + size(10); + ins_encode %{ + Label* L = $labl$$label; + __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump + __ restorevectmask(); + %} + ins_pipe( pipe_jcc ); +%} + // Jump Direct Conditional - using unsigned comparison instruct jmpConU(cmpOpU cop, eFlagsRegU cmp, label labl) %{ match(If cop cmp); diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad index 03bcd3d3b55..d8409a2ddd2 100644 --- a/hotspot/src/cpu/x86/vm/x86_64.ad +++ b/hotspot/src/cpu/x86/vm/x86_64.ad @@ -1081,10 +1081,10 @@ static void vec_stack_to_stack_helper(CodeBuffer *cbuf, int src_offset, __ vmovdqu(xmm0, Address(rsp, -32)); break; case Op_VecZ: - __ evmovdqul(Address(rsp, -64), xmm0, 2); - __ evmovdqul(xmm0, Address(rsp, src_offset), 2); - __ evmovdqul(Address(rsp, dst_offset), xmm0, 2); - __ evmovdqul(xmm0, Address(rsp, -64), 2); + __ evmovdquq(Address(rsp, -64), xmm0, 2); + __ evmovdquq(xmm0, Address(rsp, src_offset), 2); + __ evmovdquq(Address(rsp, dst_offset), xmm0, 2); + __ evmovdquq(xmm0, Address(rsp, -64), 2); break; default: ShouldNotReachHere(); @@ -11443,6 +11443,7 @@ instruct jmpCon(cmpOp cop, rFlagsReg cr, label labl) // Jump Direct Conditional - Label defines a relative address from Jcc+1 instruct jmpLoopEnd(cmpOp cop, rFlagsReg cr, label labl) %{ + predicate(!n->has_vector_mask_set()); match(CountedLoopEnd cop cr); effect(USE labl); @@ -11458,6 +11459,7 @@ instruct jmpLoopEnd(cmpOp cop, rFlagsReg cr, label labl) // Jump Direct Conditional - Label defines a relative address from Jcc+1 instruct jmpLoopEndU(cmpOpU cop, rFlagsRegU cmp, label labl) %{ + predicate(!n->has_vector_mask_set()); match(CountedLoopEnd cop cmp); effect(USE labl); @@ -11472,6 +11474,7 @@ instruct jmpLoopEndU(cmpOpU cop, rFlagsRegU cmp, label labl) %{ %} instruct jmpLoopEndUCF(cmpOpUCF cop, rFlagsRegUCF cmp, label labl) %{ + predicate(!n->has_vector_mask_set()); match(CountedLoopEnd cop cmp); effect(USE labl); @@ -11485,6 +11488,61 @@ instruct jmpLoopEndUCF(cmpOpUCF cop, rFlagsRegUCF cmp, label labl) %{ ins_pipe(pipe_jcc); %} +// mask version +// Jump Direct Conditional - Label defines a relative address from Jcc+1 +instruct jmpLoopEnd_and_restoreMask(cmpOp cop, rFlagsReg cr, label labl) +%{ + predicate(n->has_vector_mask_set()); + match(CountedLoopEnd cop cr); + effect(USE labl); + + ins_cost(400); + format %{ "j$cop $labl\t# loop end\n\t" + "restorevectmask \t# vector mask restore for loops" %} + size(10); + ins_encode %{ + Label* L = $labl$$label; + __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump + __ restorevectmask(); + %} + ins_pipe(pipe_jcc); +%} + +// Jump Direct Conditional - Label defines a relative address from Jcc+1 +instruct jmpLoopEndU_and_restoreMask(cmpOpU cop, rFlagsRegU cmp, label labl) %{ + predicate(n->has_vector_mask_set()); + match(CountedLoopEnd cop cmp); + effect(USE labl); + + ins_cost(400); + format %{ "j$cop,u $labl\t# loop end\n\t" + "restorevectmask \t# vector mask restore for loops" %} + size(10); + ins_encode %{ + Label* L = $labl$$label; + __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump + __ restorevectmask(); + %} + ins_pipe(pipe_jcc); +%} + +instruct jmpLoopEndUCF_and_restoreMask(cmpOpUCF cop, rFlagsRegUCF cmp, label labl) %{ + predicate(n->has_vector_mask_set()); + match(CountedLoopEnd cop cmp); + effect(USE labl); + + ins_cost(300); + format %{ "j$cop,u $labl\t# loop end\n\t" + "restorevectmask \t# vector mask restore for loops" %} + size(10); + ins_encode %{ + Label* L = $labl$$label; + __ jcc((Assembler::Condition)($cop$$cmpcode), *L, false); // Always long jump + __ restorevectmask(); + %} + ins_pipe(pipe_jcc); +%} + // Jump Direct Conditional - using unsigned comparison instruct jmpConU(cmpOpU cop, rFlagsRegU cmp, label labl) %{ match(If cop cmp); diff --git a/hotspot/src/share/vm/opto/classes.hpp b/hotspot/src/share/vm/opto/classes.hpp index b6a57085ad5..790f4f499be 100644 --- a/hotspot/src/share/vm/opto/classes.hpp +++ b/hotspot/src/share/vm/opto/classes.hpp @@ -178,6 +178,7 @@ macro(MachProj) macro(MaxI) macro(MemBarAcquire) macro(LoadFence) +macro(SetVectMaskI) macro(MemBarAcquireLock) macro(MemBarCPUOrder) macro(MemBarRelease) diff --git a/hotspot/src/share/vm/opto/loopUnswitch.cpp b/hotspot/src/share/vm/opto/loopUnswitch.cpp index 697ff0c9f95..72201c2e282 100644 --- a/hotspot/src/share/vm/opto/loopUnswitch.cpp +++ b/hotspot/src/share/vm/opto/loopUnswitch.cpp @@ -374,10 +374,17 @@ bool CountedLoopReserveKit::create_reserve() { return false; // skip malformed counted loop } if (!cl->is_main_loop()) { - if (TraceLoopOpts) { - tty->print_cr("CountedLoopReserveKit::create_reserve: %d not main loop", cl->_idx); + bool loop_not_canonical = true; + if (cl->is_post_loop() && (cl->slp_max_unroll() > 0)) { + loop_not_canonical = false; + } + // only reject some loop forms + if (loop_not_canonical) { + if (TraceLoopOpts) { + tty->print_cr("CountedLoopReserveKit::create_reserve: %d not canonical loop", cl->_idx); + } + return false; // skip normal, pre, and post (conditionally) loops } - return false; // skip normal, pre, and post loops } _lp = _lpt->_head->as_Loop(); diff --git a/hotspot/src/share/vm/opto/loopnode.cpp b/hotspot/src/share/vm/opto/loopnode.cpp index 33f5de7f10a..4068e27bf90 100644 --- a/hotspot/src/share/vm/opto/loopnode.cpp +++ b/hotspot/src/share/vm/opto/loopnode.cpp @@ -2369,11 +2369,13 @@ void PhaseIdealLoop::build_and_optimize(bool do_split_ifs, bool skip_loop_opts) if (multi_version_post_loops(lpt, lpt_next) == false) { // Cause the rce loop to be optimized away if we fail cl->mark_is_multiversioned(); + cl->set_slp_max_unroll(0); poison_rce_post_loop(lpt); } } } } + sw.transform_loop(lpt, true); } } else if (cl->is_main_loop()) { sw.transform_loop(lpt, true); diff --git a/hotspot/src/share/vm/opto/matcher.hpp b/hotspot/src/share/vm/opto/matcher.hpp index dad3854e3f2..c9752ebc45f 100644 --- a/hotspot/src/share/vm/opto/matcher.hpp +++ b/hotspot/src/share/vm/opto/matcher.hpp @@ -273,6 +273,9 @@ public: // e.g. Op_ vector nodes and other intrinsics while guarding with vlen static const bool match_rule_supported_vector(int opcode, int vlen); + // Some microarchitectures have mask registers used on vectors + static const bool has_predicated_vectors(void); + // Some uarchs have different sized float register resources static const int float_pressure(int default_pressure_threshold); diff --git a/hotspot/src/share/vm/opto/node.hpp b/hotspot/src/share/vm/opto/node.hpp index b14505d3c4c..e368e628e6b 100644 --- a/hotspot/src/share/vm/opto/node.hpp +++ b/hotspot/src/share/vm/opto/node.hpp @@ -722,8 +722,9 @@ public: Flag_avoid_back_to_back_after = Flag_avoid_back_to_back_before << 1, Flag_has_call = Flag_avoid_back_to_back_after << 1, Flag_is_reduction = Flag_has_call << 1, - Flag_is_scheduled = Flag_is_reduction, - Flag_is_expensive = Flag_is_scheduled << 1, + Flag_is_scheduled = Flag_is_reduction << 1, + Flag_has_vector_mask_set = Flag_is_scheduled << 1, + Flag_is_expensive = Flag_has_vector_mask_set << 1, _max_flags = (Flag_is_expensive << 1) - 1 // allow flags combination }; @@ -912,6 +913,9 @@ public: // It must have the loop's phi as input and provide a def to the phi. bool is_reduction() const { return (_flags & Flag_is_reduction) != 0; } + // The node is a CountedLoopEnd with a mask annotation so as to emit a restore context + bool has_vector_mask_set() const { return (_flags & Flag_has_vector_mask_set) != 0; } + // Used in lcm to mark nodes that have scheduled bool is_scheduled() const { return (_flags & Flag_is_scheduled) != 0; } diff --git a/hotspot/src/share/vm/opto/superword.cpp b/hotspot/src/share/vm/opto/superword.cpp index 00862021ae0..7da07d6f303 100644 --- a/hotspot/src/share/vm/opto/superword.cpp +++ b/hotspot/src/share/vm/opto/superword.cpp @@ -52,6 +52,7 @@ SuperWord::SuperWord(PhaseIdealLoop* phase) : _packset(arena(), 8, 0, NULL), // packs for the current block _bb_idx(arena(), (int)(1.10 * phase->C->unique()), 0, 0), // node idx to index in bb _block(arena(), 8, 0, NULL), // nodes in current block + _post_block(arena(), 8, 0, NULL), // nodes common to current block which are marked as post loop vectorizable _data_entry(arena(), 8, 0, NULL), // nodes with all inputs from outside _mem_slice_head(arena(), 8, 0, NULL), // memory slice heads _mem_slice_tail(arena(), 8, 0, NULL), // memory slice tails @@ -100,10 +101,30 @@ void SuperWord::transform_loop(IdealLoopTree* lpt, bool do_optimization) { if (!cl->is_valid_counted_loop()) return; // skip malformed counted loop - if (!cl->is_main_loop() ) return; // skip normal, pre, and post loops + bool post_loop_allowed = (PostLoopMultiversioning && Matcher::has_predicated_vectors() && cl->is_post_loop()); + if (post_loop_allowed) { + if (cl->is_reduction_loop()) return; // no predication mapping + Node *limit = cl->limit(); + if (limit->is_Con()) return; // non constant limits only + // Now check the limit for expressions we do not handle + if (limit->is_Add()) { + Node *in2 = limit->in(2); + if (in2->is_Con()) { + int val = in2->get_int(); + // should not try to program these cases + if (val < 0) return; + } + } + } + + // skip any loop that has not been assigned max unroll by analysis + if (do_optimization) { + if (cl->slp_max_unroll() == 0) return; + } + // Check for no control flow in body (other than exit) Node *cl_exit = cl->loopexit(); - if (cl_exit->in(0) != lpt->_head) { + if (cl->is_main_loop() && (cl_exit->in(0) != lpt->_head)) { #ifndef PRODUCT if (TraceSuperWord) { tty->print_cr("SuperWord::transform_loop: loop too complicated, cl_exit->in(0) != lpt->_head"); @@ -121,15 +142,16 @@ void SuperWord::transform_loop(IdealLoopTree* lpt, bool do_optimization) { return; } - // We only re-enter slp when we vector mapped a queried loop and we want to - // continue unrolling, in this case, slp is not subsequently done. - if (cl->do_unroll_only()) return; + // Skip any loops already optimized by slp + if (cl->is_vectorized_loop()) return; - // Check for pre-loop ending with CountedLoopEnd(Bool(Cmp(x,Opaque1(limit)))) - CountedLoopEndNode* pre_end = get_pre_loop_end(cl); - if (pre_end == NULL) return; - Node *pre_opaq1 = pre_end->limit(); - if (pre_opaq1->Opcode() != Op_Opaque1) return; + if (cl->is_main_loop()) { + // Check for pre-loop ending with CountedLoopEnd(Bool(Cmp(x,Opaque1(limit)))) + CountedLoopEndNode* pre_end = get_pre_loop_end(cl); + if (pre_end == NULL) return; + Node *pre_opaq1 = pre_end->limit(); + if (pre_opaq1->Opcode() != Op_Opaque1) return; + } init(); // initialize data structures @@ -142,6 +164,19 @@ void SuperWord::transform_loop(IdealLoopTree* lpt, bool do_optimization) { if (do_optimization) { assert(_packset.length() == 0, "packset must be empty"); SLP_extract(); + if (PostLoopMultiversioning && Matcher::has_predicated_vectors()) { + if (cl->is_vectorized_loop() && cl->is_main_loop() && !cl->is_reduction_loop()) { + IdealLoopTree *lpt_next = lpt->_next; + CountedLoopNode *cl_next = lpt_next->_head->as_CountedLoop(); + _phase->has_range_checks(lpt_next); + if (cl_next->is_post_loop() && !cl_next->range_checks_present()) { + if (!cl_next->is_vectorized_loop()) { + int slp_max_unroll_factor = cl->slp_max_unroll(); + cl_next->set_slp_max_unroll(slp_max_unroll_factor); + } + } + } + } } } @@ -154,6 +189,9 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) { Node_Stack nstack((int)ignored_size); CountedLoopNode *cl = lpt()->_head->as_CountedLoop(); Node *cl_exit = cl->loopexit(); + int rpo_idx = _post_block.length(); + + assert(rpo_idx == 0, "post loop block is empty"); // First clear the entries for (uint i = 0; i < lpt()->_body.size(); i++) { @@ -161,6 +199,7 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) { } int max_vector = Matcher::max_vector_size(T_INT); + bool post_loop_allowed = (PostLoopMultiversioning && Matcher::has_predicated_vectors() && cl->is_post_loop()); // Process the loop, some/all of the stack entries will not be in order, ergo // need to preprocess the ignored initial state before we process the loop @@ -259,6 +298,7 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) { if (is_slp) { // Now we try to find the maximum supported consistent vector which the machine // description can use + bool small_basic_type = false; for (uint i = 0; i < lpt()->_body.size(); i++) { if (ignored_loop_nodes[i] != -1) continue; @@ -269,6 +309,26 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) { } else { bt = n->bottom_type()->basic_type(); } + + if (post_loop_allowed) { + if (!small_basic_type) { + switch (bt) { + case T_CHAR: + case T_BYTE: + case T_SHORT: + small_basic_type = true; + break; + + case T_LONG: + // TODO: Remove when support completed for mask context with LONG. + // Support needs to be augmented for logical qword operations, currently we map to dword + // buckets for vectors on logicals as these were legacy. + small_basic_type = true; + break; + } + } + } + if (is_java_primitive(bt) == false) continue; int cur_max_vector = Matcher::max_vector_size(bt); @@ -288,6 +348,12 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) { if (cur_max_vector < max_vector) { max_vector = cur_max_vector; } + + // We only process post loops on predicated targets where we want to + // mask map the loop to a single iteration + if (post_loop_allowed) { + _post_block.at_put_grow(rpo_idx++, n); + } } } if (is_slp) { @@ -295,7 +361,14 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) { cl->mark_passed_slp(); } cl->mark_was_slp(); - cl->set_slp_max_unroll(local_loop_unroll_factor); + if (cl->is_main_loop()) { + cl->set_slp_max_unroll(local_loop_unroll_factor); + } else if (post_loop_allowed) { + if (!small_basic_type) { + // avoid replication context for small basic types in programmable masked loops + cl->set_slp_max_unroll(local_loop_unroll_factor); + } + } } } @@ -350,66 +423,103 @@ void SuperWord::SLP_extract() { if (!construct_bb()) { return; // Exit if no interesting nodes or complex graph. } + // build _dg, _disjoint_ptrs dependence_graph(); // compute function depth(Node*) compute_max_depth(); - if (_do_vector_loop) { - if (mark_generations() != -1) { - hoist_loads_in_graph(); // this only rebuild the graph; all basic structs need rebuild explicitly - - if (!construct_bb()) { - return; // Exit if no interesting nodes or complex graph. + CountedLoopNode *cl = lpt()->_head->as_CountedLoop(); + bool post_loop_allowed = (PostLoopMultiversioning && Matcher::has_predicated_vectors() && cl->is_post_loop()); + if (cl->is_main_loop()) { + if (_do_vector_loop) { + if (mark_generations() != -1) { + hoist_loads_in_graph(); // this only rebuild the graph; all basic structs need rebuild explicitly + + if (!construct_bb()) { + return; // Exit if no interesting nodes or complex graph. + } + dependence_graph(); + compute_max_depth(); } - dependence_graph(); - compute_max_depth(); - } #ifndef PRODUCT - if (TraceSuperWord) { - tty->print_cr("\nSuperWord::_do_vector_loop: graph after hoist_loads_in_graph"); - _lpt->dump_head(); - for (int j = 0; j < _block.length(); j++) { - Node* n = _block.at(j); - int d = depth(n); - for (int i = 0; i < d; i++) tty->print("%s", " "); - tty->print("%d :", d); - n->dump(); + if (TraceSuperWord) { + tty->print_cr("\nSuperWord::_do_vector_loop: graph after hoist_loads_in_graph"); + _lpt->dump_head(); + for (int j = 0; j < _block.length(); j++) { + Node* n = _block.at(j); + int d = depth(n); + for (int i = 0; i < d; i++) tty->print("%s", " "); + tty->print("%d :", d); + n->dump(); + } } - } #endif - } + } - compute_vector_element_type(); + compute_vector_element_type(); - // Attempt vectorization + // Attempt vectorization - find_adjacent_refs(); + find_adjacent_refs(); - extend_packlist(); + extend_packlist(); - if (_do_vector_loop) { - if (_packset.length() == 0) { - if (TraceSuperWord) { - tty->print_cr("\nSuperWord::_do_vector_loop DFA could not build packset, now trying to build anyway"); + if (_do_vector_loop) { + if (_packset.length() == 0) { + if (TraceSuperWord) { + tty->print_cr("\nSuperWord::_do_vector_loop DFA could not build packset, now trying to build anyway"); + } + pack_parallel(); } - pack_parallel(); } - } - combine_packs(); + combine_packs(); - construct_my_pack_map(); + construct_my_pack_map(); - if (_do_vector_loop) { - merge_packs_to_cmovd(); - } + if (_do_vector_loop) { + merge_packs_to_cmovd(); + } + + filter_packs(); - filter_packs(); + schedule(); + } else if (post_loop_allowed) { + int saved_mapped_unroll_factor = cl->slp_max_unroll(); + if (saved_mapped_unroll_factor) { + int vector_mapped_unroll_factor = saved_mapped_unroll_factor; - schedule(); + // now reset the slp_unroll_factor so that we can check the analysis mapped + // what the vector loop was mapped to + cl->set_slp_max_unroll(0); + + // do the analysis on the post loop + unrolling_analysis(vector_mapped_unroll_factor); + + // if our analyzed loop is a canonical fit, start processing it + if (vector_mapped_unroll_factor == saved_mapped_unroll_factor) { + // now add the vector nodes to packsets + for (int i = 0; i < _post_block.length(); i++) { + Node* n = _post_block.at(i); + Node_List* singleton = new Node_List(); + singleton->push(n); + _packset.append(singleton); + set_my_pack(n, singleton); + } + + // map base types for vector usage + compute_vector_element_type(); + } else { + return; + } + } else { + // for some reason we could not map the slp analysis state of the vectorized loop + return; + } + } output(); } @@ -811,6 +921,7 @@ int SuperWord::get_iv_adjustment(MemNode* mem_ref) { // Add dependence edges to load/store nodes for memory dependence // A.out()->DependNode.in(1) and DependNode.out()->B.prec(x) void SuperWord::dependence_graph() { + CountedLoopNode *cl = lpt()->_head->as_CountedLoop(); // First, assign a dependence node to each memory node for (int i = 0; i < _block.length(); i++ ) { Node *n = _block.at(i); @@ -825,7 +936,9 @@ void SuperWord::dependence_graph() { Node* n_tail = _mem_slice_tail.at(i); // Get slice in predecessor order (last is first) - mem_slice_preds(n_tail, n, _nlist); + if (cl->is_main_loop()) { + mem_slice_preds(n_tail, n, _nlist); + } #ifndef PRODUCT if(TraceSuperWord && Verbose) { @@ -2029,20 +2142,23 @@ void SuperWord::output() { } #endif - // MUST ENSURE main loop's initial value is properly aligned: - // (iv_initial_value + min_iv_offset) % vector_width_in_bytes() == 0 + CountedLoopNode *cl = lpt()->_head->as_CountedLoop(); + if (cl->is_main_loop()) { + // MUST ENSURE main loop's initial value is properly aligned: + // (iv_initial_value + min_iv_offset) % vector_width_in_bytes() == 0 - align_initial_loop_index(align_to_ref()); + align_initial_loop_index(align_to_ref()); - // Insert extract (unpack) operations for scalar uses - for (int i = 0; i < _packset.length(); i++) { - insert_extracts(_packset.at(i)); + // Insert extract (unpack) operations for scalar uses + for (int i = 0; i < _packset.length(); i++) { + insert_extracts(_packset.at(i)); + } } Compile* C = _phase->C; - CountedLoopNode *cl = lpt()->_head->as_CountedLoop(); uint max_vlen_in_bytes = 0; uint max_vlen = 0; + bool can_process_post_loop = (PostLoopMultiversioning && Matcher::has_predicated_vectors() && cl->is_post_loop()); NOT_PRODUCT(if(is_trace_loop_reverse()) {tty->print_cr("SWPointer::output: print loop before create_reserve_version_of_loop"); print_loop(true);}) @@ -2064,6 +2180,10 @@ void SuperWord::output() { Node* vn = NULL; Node* low_adr = p->at(0); Node* first = executed_first(p); + if (can_process_post_loop) { + // override vlen with the main loops vector length + vlen = cl->slp_max_unroll(); + } NOT_PRODUCT(if(is_trace_cmov()) {tty->print_cr("SWPointer::output: %d executed first, %d executed last in pack", first->_idx, n->_idx); print_pack(p);}) int opc = n->Opcode(); if (n->is_Load()) { @@ -2153,6 +2273,10 @@ void SuperWord::output() { vn = VectorNode::make(opc, in, NULL, vlen, velt_basic_type(n)); vlen_in_bytes = vn->as_Vector()->length_in_bytes(); } else if (is_cmov_pack(p)) { + if (can_process_post_loop) { + // do not refactor of flow in post loop context + return; + } if (!n->is_CMove()) { continue; } @@ -2217,6 +2341,7 @@ void SuperWord::output() { ShouldNotReachHere(); } + _block.at_put(i, vn); _igvn.register_new_node_with_optimizer(vn); _phase->set_ctrl(vn, _phase->get_ctrl(p->at(0))); for (uint j = 0; j < p->size(); j++) { @@ -2225,6 +2350,14 @@ void SuperWord::output() { } _igvn._worklist.push(vn); + if (can_process_post_loop) { + // first check if the vector size if the maximum vector which we can use on the machine, + // other vector size have reduced values for predicated data mapping. + if (vlen_in_bytes != (uint)MaxVectorSize) { + return; + } + } + if (vlen_in_bytes > max_vlen_in_bytes) { max_vlen = vlen; max_vlen_in_bytes = vlen_in_bytes; @@ -2247,15 +2380,38 @@ void SuperWord::output() { if (TraceSuperWordLoopUnrollAnalysis) { tty->print_cr("vector loop(unroll=%d, len=%d)\n", max_vlen, max_vlen_in_bytes*BitsPerByte); } - // For atomic unrolled loops which are vector mapped, instigate more unrolling. + + // For atomic unrolled loops which are vector mapped, instigate more unrolling cl->set_notpassed_slp(); - // if vector resources are limited, do not allow additional unrolling - if (FLOATPRESSURE > 8) { - C->set_major_progress(); + if (cl->is_main_loop()) { + // if vector resources are limited, do not allow additional unrolling, also + // do not unroll more on pure vector loops which were not reduced so that we can + // program the post loop to single iteration execution. + if (FLOATPRESSURE > 8) { + C->set_major_progress(); + cl->mark_do_unroll_only(); + } } - cl->mark_do_unroll_only(); + if (do_reserve_copy()) { cl->mark_loop_vectorized(); + if (can_process_post_loop) { + // Now create the difference of trip and limit and use it as our mask index. + // Note: We limited the unroll of the vectorized loop so that + // only vlen-1 size iterations can remain to be mask programmed. + Node *incr = cl->incr(); + SubINode *index = new SubINode(cl->limit(), cl->init_trip()); + _igvn.register_new_node_with_optimizer(index); + SetVectMaskINode *mask = new SetVectMaskINode(_phase->get_ctrl(cl->init_trip()), index); + _igvn.register_new_node_with_optimizer(mask); + // make this a single iteration loop + AddINode *new_incr = new AddINode(incr->in(1), mask); + _igvn.register_new_node_with_optimizer(new_incr); + _phase->set_ctrl(new_incr, _phase->get_ctrl(incr)); + _igvn.replace_node(incr, new_incr); + cl->mark_is_multiversioned(); + cl->loopexit()->add_flag(Node::Flag_has_vector_mask_set); + } } } } @@ -2274,6 +2430,12 @@ Node* SuperWord::vector_opd(Node_List* p, int opd_idx) { Node* p0 = p->at(0); uint vlen = p->size(); Node* opd = p0->in(opd_idx); + CountedLoopNode *cl = lpt()->_head->as_CountedLoop(); + + if (PostLoopMultiversioning && Matcher::has_predicated_vectors() && cl->is_post_loop()) { + // override vlen with the main loops vector length + vlen = cl->slp_max_unroll(); + } if (same_inputs(p, opd_idx)) { if (opd->is_Vector() || opd->is_LoadVector()) { @@ -3090,13 +3252,13 @@ CountedLoopEndNode* SuperWord::get_pre_loop_end(CountedLoopNode* cl) { return pre_end; } - //------------------------------init--------------------------- void SuperWord::init() { _dg.init(); _packset.clear(); _disjoint_ptrs.clear(); _block.clear(); + _post_block.clear(); _data_entry.clear(); _mem_slice_head.clear(); _mem_slice_tail.clear(); @@ -3120,6 +3282,7 @@ void SuperWord::restart() { _packset.clear(); _disjoint_ptrs.clear(); _block.clear(); + _post_block.clear(); _data_entry.clear(); _mem_slice_head.clear(); _mem_slice_tail.clear(); diff --git a/hotspot/src/share/vm/opto/superword.hpp b/hotspot/src/share/vm/opto/superword.hpp index ccc154ff96b..eea7c555d11 100644 --- a/hotspot/src/share/vm/opto/superword.hpp +++ b/hotspot/src/share/vm/opto/superword.hpp @@ -261,6 +261,7 @@ class SuperWord : public ResourceObj { GrowableArray _bb_idx; // Map from Node _idx to index within block GrowableArray _block; // Nodes in current block + GrowableArray _post_block; // Nodes in post loop block GrowableArray _data_entry; // Nodes with all inputs from outside GrowableArray _mem_slice_head; // Memory slice head nodes GrowableArray _mem_slice_tail; // Memory slice tail nodes diff --git a/hotspot/src/share/vm/opto/vectornode.hpp b/hotspot/src/share/vm/opto/vectornode.hpp index ee7b736e7c8..04df1eb0140 100644 --- a/hotspot/src/share/vm/opto/vectornode.hpp +++ b/hotspot/src/share/vm/opto/vectornode.hpp @@ -529,6 +529,7 @@ class LoadVectorNode : public LoadNode { Node* adr, const TypePtr* atyp, uint vlen, BasicType bt, ControlDependency control_dependency = LoadNode::DependsOnlyOnTest); + uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); } }; //------------------------------StoreVectorNode-------------------------------- @@ -553,6 +554,8 @@ class StoreVectorNode : public StoreNode { static StoreVectorNode* make(int opc, Node* ctl, Node* mem, Node* adr, const TypePtr* atyp, Node* val, uint vlen); + + uint element_size(void) { return type2aelembytes(vect_type()->element_basic_type()); } }; @@ -791,4 +794,15 @@ class ExtractDNode : public ExtractNode { virtual uint ideal_reg() const { return Op_RegD; } }; +//------------------------------SetVectMaskINode------------------------------- +// Provide a mask for a vector predicate machine +class SetVectMaskINode : public Node { +public: + SetVectMaskINode(Node *c, Node *in1) : Node(c, in1) {} + virtual int Opcode() const; + const Type *bottom_type() const { return TypeInt::INT; } + virtual uint ideal_reg() const { return Op_RegI; } + virtual const Type *Value(PhaseGVN *phase) const { return TypeInt::INT; } +}; + #endif // SHARE_VM_OPTO_VECTORNODE_HPP diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index f4f9c5ed358..3260c4d597b 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -1923,6 +1923,7 @@ typedef CompactHashtable SymbolCompactHashTable; declare_c2_type(ConvL2INode, Node) \ declare_c2_type(CastX2PNode, Node) \ declare_c2_type(CastP2XNode, Node) \ + declare_c2_type(SetVectMaskINode, Node) \ declare_c2_type(MemBarNode, MultiNode) \ declare_c2_type(MemBarAcquireNode, MemBarNode) \ declare_c2_type(MemBarReleaseNode, MemBarNode) \ -- GitLab From 66777c339952d95ab98febc23c1e24c93696097a Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Tue, 19 Apr 2016 08:12:28 +0200 Subject: [PATCH 153/400] 8067785: Using AlwaysPreTouch does not always touch all pages Reviewed-by: pliden, drwhite --- hotspot/src/share/vm/memory/virtualspace.cpp | 107 +++++++++---------- 1 file changed, 49 insertions(+), 58 deletions(-) diff --git a/hotspot/src/share/vm/memory/virtualspace.cpp b/hotspot/src/share/vm/memory/virtualspace.cpp index 31fddb745c7..9b188f272e6 100644 --- a/hotspot/src/share/vm/memory/virtualspace.cpp +++ b/hotspot/src/share/vm/memory/virtualspace.cpp @@ -751,6 +751,29 @@ bool VirtualSpace::contains(const void* p) const { return low() <= (const char*) p && (const char*) p < high(); } +static void pretouch_expanded_memory(void* start, void* end) { + assert(is_ptr_aligned(start, os::vm_page_size()), "Unexpected alignment"); + assert(is_ptr_aligned(end, os::vm_page_size()), "Unexpected alignment"); + + os::pretouch_memory(start, end); +} + +static bool commit_expanded(char* start, size_t size, size_t alignment, bool pre_touch, bool executable) { + if (os::commit_memory(start, size, alignment, executable)) { + if (pre_touch || AlwaysPreTouch) { + pretouch_expanded_memory(start, start + size); + } + return true; + } + + debug_only(warning( + "INFO: os::commit_memory(" PTR_FORMAT ", " PTR_FORMAT + " size=" SIZE_FORMAT ", executable=%d) failed", + p2i(start), p2i(start + size), size, executable);) + + return false; +} + /* First we need to determine if a particular virtual space is using large pages. This is done at the initialize function and only virtual spaces @@ -764,7 +787,9 @@ bool VirtualSpace::contains(const void* p) const { allocated with default pages. */ bool VirtualSpace::expand_by(size_t bytes, bool pre_touch) { - if (uncommitted_size() < bytes) return false; + if (uncommitted_size() < bytes) { + return false; + } if (special()) { // don't commit memory if the entire space is pinned in memory @@ -774,30 +799,23 @@ bool VirtualSpace::expand_by(size_t bytes, bool pre_touch) { char* previous_high = high(); char* unaligned_new_high = high() + bytes; - assert(unaligned_new_high <= high_boundary(), - "cannot expand by more than upper boundary"); + assert(unaligned_new_high <= high_boundary(), "cannot expand by more than upper boundary"); // Calculate where the new high for each of the regions should be. If // the low_boundary() and high_boundary() are LargePageSizeInBytes aligned // then the unaligned lower and upper new highs would be the // lower_high() and upper_high() respectively. - char* unaligned_lower_new_high = - MIN2(unaligned_new_high, lower_high_boundary()); - char* unaligned_middle_new_high = - MIN2(unaligned_new_high, middle_high_boundary()); - char* unaligned_upper_new_high = - MIN2(unaligned_new_high, upper_high_boundary()); + char* unaligned_lower_new_high = MIN2(unaligned_new_high, lower_high_boundary()); + char* unaligned_middle_new_high = MIN2(unaligned_new_high, middle_high_boundary()); + char* unaligned_upper_new_high = MIN2(unaligned_new_high, upper_high_boundary()); // Align the new highs based on the regions alignment. lower and upper // alignment will always be default page size. middle alignment will be // LargePageSizeInBytes if the actual size of the virtual space is in // fact larger than LargePageSizeInBytes. - char* aligned_lower_new_high = - (char*) round_to((intptr_t) unaligned_lower_new_high, lower_alignment()); - char* aligned_middle_new_high = - (char*) round_to((intptr_t) unaligned_middle_new_high, middle_alignment()); - char* aligned_upper_new_high = - (char*) round_to((intptr_t) unaligned_upper_new_high, upper_alignment()); + char* aligned_lower_new_high = (char*) round_to((intptr_t) unaligned_lower_new_high, lower_alignment()); + char* aligned_middle_new_high = (char*) round_to((intptr_t) unaligned_middle_new_high, middle_alignment()); + char* aligned_upper_new_high = (char*) round_to((intptr_t) unaligned_upper_new_high, upper_alignment()); // Determine which regions need to grow in this expand_by call. // If you are growing in the lower region, high() must be in that @@ -808,75 +826,48 @@ bool VirtualSpace::expand_by(size_t bytes, bool pre_touch) { // is an intra or inter region growth. size_t lower_needs = 0; if (aligned_lower_new_high > lower_high()) { - lower_needs = - pointer_delta(aligned_lower_new_high, lower_high(), sizeof(char)); + lower_needs = pointer_delta(aligned_lower_new_high, lower_high(), sizeof(char)); } size_t middle_needs = 0; if (aligned_middle_new_high > middle_high()) { - middle_needs = - pointer_delta(aligned_middle_new_high, middle_high(), sizeof(char)); + middle_needs = pointer_delta(aligned_middle_new_high, middle_high(), sizeof(char)); } size_t upper_needs = 0; if (aligned_upper_new_high > upper_high()) { - upper_needs = - pointer_delta(aligned_upper_new_high, upper_high(), sizeof(char)); + upper_needs = pointer_delta(aligned_upper_new_high, upper_high(), sizeof(char)); } // Check contiguity. - assert(low_boundary() <= lower_high() && - lower_high() <= lower_high_boundary(), + assert(low_boundary() <= lower_high() && lower_high() <= lower_high_boundary(), "high address must be contained within the region"); - assert(lower_high_boundary() <= middle_high() && - middle_high() <= middle_high_boundary(), + assert(lower_high_boundary() <= middle_high() && middle_high() <= middle_high_boundary(), "high address must be contained within the region"); - assert(middle_high_boundary() <= upper_high() && - upper_high() <= upper_high_boundary(), + assert(middle_high_boundary() <= upper_high() && upper_high() <= upper_high_boundary(), "high address must be contained within the region"); // Commit regions if (lower_needs > 0) { - assert(low_boundary() <= lower_high() && - lower_high() + lower_needs <= lower_high_boundary(), - "must not expand beyond region"); - if (!os::commit_memory(lower_high(), lower_needs, _executable)) { - debug_only(warning("INFO: os::commit_memory(" PTR_FORMAT - ", lower_needs=" SIZE_FORMAT ", %d) failed", - p2i(lower_high()), lower_needs, _executable);) + assert(lower_high() + lower_needs <= lower_high_boundary(), "must not expand beyond region"); + if (!commit_expanded(lower_high(), lower_needs, _lower_alignment, pre_touch, _executable)) { return false; - } else { - _lower_high += lower_needs; } + _lower_high += lower_needs; } + if (middle_needs > 0) { - assert(lower_high_boundary() <= middle_high() && - middle_high() + middle_needs <= middle_high_boundary(), - "must not expand beyond region"); - if (!os::commit_memory(middle_high(), middle_needs, middle_alignment(), - _executable)) { - debug_only(warning("INFO: os::commit_memory(" PTR_FORMAT - ", middle_needs=" SIZE_FORMAT ", " SIZE_FORMAT - ", %d) failed", p2i(middle_high()), middle_needs, - middle_alignment(), _executable);) + assert(middle_high() + middle_needs <= middle_high_boundary(), "must not expand beyond region"); + if (!commit_expanded(middle_high(), middle_needs, _middle_alignment, pre_touch, _executable)) { return false; } _middle_high += middle_needs; } + if (upper_needs > 0) { - assert(middle_high_boundary() <= upper_high() && - upper_high() + upper_needs <= upper_high_boundary(), - "must not expand beyond region"); - if (!os::commit_memory(upper_high(), upper_needs, _executable)) { - debug_only(warning("INFO: os::commit_memory(" PTR_FORMAT - ", upper_needs=" SIZE_FORMAT ", %d) failed", - p2i(upper_high()), upper_needs, _executable);) + assert(upper_high() + upper_needs <= upper_high_boundary(), "must not expand beyond region"); + if (!commit_expanded(upper_high(), upper_needs, _upper_alignment, pre_touch, _executable)) { return false; - } else { - _upper_high += upper_needs; } - } - - if (pre_touch || AlwaysPreTouch) { - os::pretouch_memory(previous_high, unaligned_new_high); + _upper_high += upper_needs; } _high += bytes; -- GitLab From 4b7eacd933f793381a04d0340a9ff63b34ed2af7 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Tue, 19 Apr 2016 09:48:43 +0200 Subject: [PATCH 154/400] 8154235: Using deprecated flags converted to UL shows wrong hint Reviewed-by: rprotacio, mockner, coleenp --- hotspot/src/share/vm/runtime/arguments.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 7fa2ea8a7ad..2e0ad45aa8b 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -998,7 +998,7 @@ void log_deprecated_flag(const char* name, bool on, AliasedLoggingFlag alf) { int max_tags = sizeof(tagSet)/sizeof(tagSet[0]); for (int i = 0; i < max_tags && tagSet[i] != LogTag::__NO_TAG; i++) { if (i > 0) { - strncat(tagset_buffer, ",", max_tagset_len - strlen(tagset_buffer)); + strncat(tagset_buffer, "+", max_tagset_len - strlen(tagset_buffer)); } strncat(tagset_buffer, LogTag::name(tagSet[i]), max_tagset_len - strlen(tagset_buffer)); } -- GitLab From d6c8ba8845c4fc436f3ec56da9201094ec202dc0 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Tue, 19 Apr 2016 09:31:53 +0100 Subject: [PATCH 155/400] 8153756: jdk.vm.ci should not depend on sun.misc ( jdk.unsupported module ) Reviewed-by: twisti --- .../jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java | 2 +- .../jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java | 2 +- .../src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java | 2 +- .../src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java | 2 +- .../src/jdk/vm/ci/hotspot/HotSpotMethodData.java | 2 +- .../src/jdk/vm/ci/hotspot/HotSpotVMConfig.java | 2 +- .../src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java | 2 +- .../src/jdk/vm/ci/hotspot/HotSpotVmSymbols.java | 2 +- .../jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java | 2 +- hotspot/src/jdk.vm.ci/share/classes/module-info.java | 3 --- 10 files changed, 9 insertions(+), 12 deletions(-) diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java index 7668759da84..9b8f75511c4 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.common/src/jdk/vm/ci/common/UnsafeUtil.java @@ -22,7 +22,7 @@ */ package jdk.vm.ci.common; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Utilities for operating on raw memory with {@link Unsafe}. diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java index 09901998ffb..6f2d8c5e6aa 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java @@ -39,7 +39,7 @@ import jdk.vm.ci.inittimer.InitTimer; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaType; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Calls from Java into HotSpot. The behavior of all the methods in this class that take a native diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java index aa8368d9777..98fa1816065 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotInstalledCode.java @@ -25,7 +25,7 @@ package jdk.vm.ci.hotspot; import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; import jdk.vm.ci.code.InstalledCode; import jdk.vm.ci.inittimer.SuppressFBWarnings; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Implementation of {@link InstalledCode} for HotSpot. diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java index 12cc5255ead..7d6b4b287ae 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotJVMCIRuntimeProvider.java @@ -30,7 +30,7 @@ import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.JavaType; import jdk.vm.ci.meta.ResolvedJavaType; import jdk.vm.ci.runtime.JVMCIRuntime; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; //JaCoCo Exclude diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java index f42f9aff6ab..dfdc3ebf3f6 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodData.java @@ -39,7 +39,7 @@ import jdk.vm.ci.meta.JavaTypeProfile.ProfiledType; import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaType; import jdk.vm.ci.meta.TriState; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Access to a HotSpot MethodData structure (defined in methodData.hpp). diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java index 72c2552adf3..dc8fb3d407e 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java @@ -38,7 +38,7 @@ import jdk.vm.ci.hotspotvmconfig.HotSpotVMData; import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; import jdk.vm.ci.hotspotvmconfig.HotSpotVMFlag; import jdk.vm.ci.hotspotvmconfig.HotSpotVMType; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; //JaCoCo Exclude diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java index 5f82244d055..8995bd60797 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfigVerifier.java @@ -40,7 +40,7 @@ import jdk.internal.org.objectweb.asm.Label; import jdk.internal.org.objectweb.asm.MethodVisitor; import jdk.internal.org.objectweb.asm.Opcodes; import jdk.internal.org.objectweb.asm.Type; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * A {@link ClassVisitor} that verifies {@link HotSpotVMConfig} does not access {@link Unsafe} from diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVmSymbols.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVmSymbols.java index 0e1398eeaea..bcc2b8f99eb 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVmSymbols.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVmSymbols.java @@ -24,7 +24,7 @@ package jdk.vm.ci.hotspot; import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Class to access the C++ {@code vmSymbols} table. diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java index cff2ced4100..c75c449f9dd 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/UnsafeAccess.java @@ -24,7 +24,7 @@ package jdk.vm.ci.hotspot; import java.lang.reflect.Field; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Package private access to the {@link Unsafe} capability. diff --git a/hotspot/src/jdk.vm.ci/share/classes/module-info.java b/hotspot/src/jdk.vm.ci/share/classes/module-info.java index e105f01e10a..a59a37d56e2 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/module-info.java +++ b/hotspot/src/jdk.vm.ci/share/classes/module-info.java @@ -24,9 +24,6 @@ */ module jdk.vm.ci { - // 8153756 - requires jdk.unsupported; - uses jdk.vm.ci.hotspot.HotSpotVMEventListener; uses jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory; uses jdk.vm.ci.runtime.JVMCICompilerFactory; -- GitLab From 147073aa09e7b68d548c1287608c231b3c7db691 Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Tue, 19 Apr 2016 13:19:41 +0200 Subject: [PATCH 156/400] 8154251: ANSI-C Quoting bug in hotspot.m4 during configure on SLES 10 and 11 Reviewed-by: erikj --- common/autoconf/generated-configure.sh | 15 +++++++++++---- common/autoconf/hotspot.m4 | 13 ++++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 69e7160dfa3..d1d9b90a0f5 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5056,7 +5056,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1460538705 +DATE_WHEN_GENERATED=1461064700 ############################################################################### # @@ -16277,7 +16277,10 @@ $as_echo "$JVM_VARIANTS" >&6; } # Check that the selected variants are valid # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326 - INVALID_VARIANTS=`$GREP -Fvx "${VALID_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"` + # Notice that the original variant failes on SLES 10 and 11 + NEEDLE=${VALID_JVM_VARIANTS// /$'\n'} + STACK=${JVM_VARIANTS// /$'\n'} + INVALID_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"` if test "x$INVALID_VARIANTS" != x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Unknown variant(s) specified: $INVALID_VARIANTS" >&5 $as_echo "$as_me: Unknown variant(s) specified: $INVALID_VARIANTS" >&6;} @@ -16286,7 +16289,9 @@ $as_echo "$as_me: Unknown variant(s) specified: $INVALID_VARIANTS" >&6;} # All "special" variants share the same output directory ("server") VALID_MULTIPLE_JVM_VARIANTS="server client minimal" - INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"` + NEEDLE=${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'} + STACK=${JVM_VARIANTS// /$'\n'} + INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"` if test "x$INVALID_MULTIPLE_VARIANTS" != x && test "x$BUILDING_MULTIPLE_JVM_VARIANTS" = xtrue; then as_fn_error $? "You cannot build multiple variants with anything else than $VALID_MULTIPLE_JVM_VARIANTS." "$LINENO" 5 fi @@ -65556,7 +65561,9 @@ $as_echo_n "checking JVM features for JVM variant '$variant'... " >&6; } JVM_FEATURES_TO_TEST=${!features_var_name} { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JVM_FEATURES_TO_TEST" >&5 $as_echo "$JVM_FEATURES_TO_TEST" >&6; } - INVALID_FEATURES=`$GREP -Fvx "${VALID_JVM_FEATURES// /$'\n'}" <<< "${JVM_FEATURES_TO_TEST// /$'\n'}"` + NEEDLE=${VALID_JVM_FEATURES// /$'\n'} + STACK=${JVM_FEATURES_TO_TEST// /$'\n'} + INVALID_FEATURES=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"` if test "x$INVALID_FEATURES" != x; then as_fn_error $? "Invalid JVM feature(s): $INVALID_FEATURES" "$LINENO" 5 fi diff --git a/common/autoconf/hotspot.m4 b/common/autoconf/hotspot.m4 index 4fffa86983d..1917624df7a 100644 --- a/common/autoconf/hotspot.m4 +++ b/common/autoconf/hotspot.m4 @@ -93,7 +93,10 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_VARIANTS], # Check that the selected variants are valid # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326 - INVALID_VARIANTS=`$GREP -Fvx "${VALID_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"` + # Notice that the original variant failes on SLES 10 and 11 + NEEDLE=${VALID_JVM_VARIANTS// /$'\n'} + STACK=${JVM_VARIANTS// /$'\n'} + INVALID_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"` if test "x$INVALID_VARIANTS" != x; then AC_MSG_NOTICE([Unknown variant(s) specified: $INVALID_VARIANTS]) AC_MSG_ERROR([The available JVM variants are: $VALID_JVM_VARIANTS]) @@ -101,7 +104,9 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_VARIANTS], # All "special" variants share the same output directory ("server") VALID_MULTIPLE_JVM_VARIANTS="server client minimal" - INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"` + NEEDLE=${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'} + STACK=${JVM_VARIANTS// /$'\n'} + INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"` if test "x$INVALID_MULTIPLE_VARIANTS" != x && test "x$BUILDING_MULTIPLE_JVM_VARIANTS" = xtrue; then AC_MSG_ERROR([You cannot build multiple variants with anything else than $VALID_MULTIPLE_JVM_VARIANTS.]) fi @@ -293,7 +298,9 @@ AC_DEFUN_ONCE([HOTSPOT_VALIDATE_JVM_FEATURES], features_var_name=JVM_FEATURES_$variant JVM_FEATURES_TO_TEST=${!features_var_name} AC_MSG_RESULT([$JVM_FEATURES_TO_TEST]) - INVALID_FEATURES=`$GREP -Fvx "${VALID_JVM_FEATURES// /$'\n'}" <<< "${JVM_FEATURES_TO_TEST// /$'\n'}"` + NEEDLE=${VALID_JVM_FEATURES// /$'\n'} + STACK=${JVM_FEATURES_TO_TEST// /$'\n'} + INVALID_FEATURES=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"` if test "x$INVALID_FEATURES" != x; then AC_MSG_ERROR([Invalid JVM feature(s): $INVALID_FEATURES]) fi -- GitLab From 9d7444952ace74e8ba89f218b4e22c941f289076 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Tue, 19 Apr 2016 14:14:04 +0200 Subject: [PATCH 157/400] 8154041: JVMTI trace to Unified Logging Reviewed-by: sspitsyn, mlarsson --- hotspot/src/share/vm/logging/logTag.hpp | 1 + hotspot/src/share/vm/prims/jvmtiEnter.xsl | 21 +-- .../share/vm/prims/jvmtiEventController.cpp | 39 ++--- hotspot/src/share/vm/prims/jvmtiExport.cpp | 152 +++++++++--------- hotspot/src/share/vm/prims/jvmtiImpl.cpp | 32 ++-- hotspot/src/share/vm/prims/jvmtiImpl.hpp | 3 +- .../vm/prims/jvmtiManageCapabilities.cpp | 84 +++++----- .../src/share/vm/prims/jvmtiThreadState.cpp | 7 - hotspot/src/share/vm/prims/jvmtiTrace.cpp | 29 +++- 9 files changed, 189 insertions(+), 179 deletions(-) diff --git a/hotspot/src/share/vm/logging/logTag.hpp b/hotspot/src/share/vm/logging/logTag.hpp index ede507df242..6b9cd7d3d21 100644 --- a/hotspot/src/share/vm/logging/logTag.hpp +++ b/hotspot/src/share/vm/logging/logTag.hpp @@ -62,6 +62,7 @@ LOG_TAG(ihop) \ LOG_TAG(itables) \ LOG_TAG(jni) \ + LOG_TAG(jvmti) \ LOG_TAG(liveness) \ LOG_TAG(logging) \ LOG_TAG(marking) \ diff --git a/hotspot/src/share/vm/prims/jvmtiEnter.xsl b/hotspot/src/share/vm/prims/jvmtiEnter.xsl index 2d012a82129..bdb7915513d 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnter.xsl +++ b/hotspot/src/share/vm/prims/jvmtiEnter.xsl @@ -40,6 +40,7 @@ # include "memory/resourceArea.hpp" # include "utilities/macros.hpp" #if INCLUDE_JVMTI +# include "logging/log.hpp" # include "oops/oop.inline.hpp" # include "prims/jvmtiEnter.hpp" # include "prims/jvmtiRawMonitor.hpp" @@ -415,7 +416,7 @@ struct jvmtiInterface_1_ jvmti if (trace_flags) { - tty->print_cr("JVMTI [non-attached thread] %s %s", func_name, + log_trace(jvmti)("[non-attached thread] %s %s", func_name, JvmtiUtil::error_name(JVMTI_ERROR_UNATTACHED_THREAD)); @@ -452,7 +453,7 @@ struct jvmtiInterface_1_ jvmti if (trace_flags) { - tty->print_cr("JVMTI [%s] %s %s", curr_thread_name, func_name, + log_trace(jvmti)("[%s] %s %s", curr_thread_name, func_name, JvmtiUtil::error_name(JVMTI_ERROR_MUST_POSSESS_CAPABILITY)); } @@ -486,7 +487,7 @@ static jvmtiError JNICALL if (trace_flags) { - tty->print_cr("JVMTI [-] %s %s", func_name, + log_trace(jvmti)("[-] %s %s", func_name, JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE)); } @@ -509,7 +510,7 @@ static jvmtiError JNICALL if (trace_flags) { - tty->print_cr("JVMTI [-] %s %s", func_name, + log_trace(jvmti)("[-] %s %s", func_name, JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE)); } @@ -522,7 +523,7 @@ static jvmtiError JNICALL if (trace_flags) { - tty->print_cr("JVMTI [-] %s %s", func_name, + log_trace(jvmti)("[-] %s %s", func_name, JvmtiUtil::error_name(JVMTI_ERROR_WRONG_PHASE)); } @@ -541,7 +542,7 @@ static jvmtiError JNICALL if (trace_flags) { - tty->print_cr("JVMTI [%s] %s %s env=" PTR_FORMAT, curr_thread_name, func_name, + log_trace(jvmti)("[%s] %s %s env=" PTR_FORMAT, curr_thread_name, func_name, JvmtiUtil::error_name(JVMTI_ERROR_INVALID_ENVIRONMENT), p2i(env)); } @@ -667,7 +668,7 @@ static jvmtiError JNICALL } - tty->print_cr("JVMTI [%s] %s } %s - erroneous arg is + log_error(jvmti)("[%s] %s } %s - erroneous arg is ", curr_thread_name, func_name, @@ -692,10 +693,10 @@ static jvmtiError JNICALL } - tty->print_cr("JVMTI [%s] %s } %s", curr_thread_name, func_name, + log_error(jvmti)("[%s] %s } %s", curr_thread_name, func_name, JvmtiUtil::error_name(err)); } else if ((trace_flags & JvmtiTrace::SHOW_OUT) != 0) { - tty->print_cr("JVMTI [%s] %s }", curr_thread_name, func_name); + log_trace(jvmti)("[%s] %s }", curr_thread_name, func_name); } @@ -703,7 +704,7 @@ static jvmtiError JNICALL - tty->print_cr("JVMTI [%s] %s { + log_trace(jvmti)("[%s] %s { diff --git a/hotspot/src/share/vm/prims/jvmtiEventController.cpp b/hotspot/src/share/vm/prims/jvmtiEventController.cpp index 81ca1d7d6e3..006feeab4c0 100644 --- a/hotspot/src/share/vm/prims/jvmtiEventController.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEventController.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "interpreter/interpreter.hpp" #include "jvmtifiles/jvmtiEnv.hpp" +#include "logging/log.hpp" #include "memory/resourceArea.hpp" #include "prims/jvmtiEventController.hpp" #include "prims/jvmtiEventController.inline.hpp" @@ -42,7 +43,7 @@ #define EC_TRACE(out) do { \ if (JvmtiTrace::trace_event_controller()) { \ SafeResourceMark rm; \ - tty->print_cr out; \ + log_trace(jvmti) out; \ } \ } while (0) #else @@ -344,7 +345,7 @@ void VM_ChangeSingleStep::doit() { void JvmtiEventControllerPrivate::enter_interp_only_mode(JvmtiThreadState *state) { - EC_TRACE(("JVMTI [%s] # Entering interpreter only mode", + EC_TRACE(("[%s] # Entering interpreter only mode", JvmtiTrace::safe_get_thread_name(state->get_thread()))); VM_EnterInterpOnlyMode op(state); @@ -354,7 +355,7 @@ void JvmtiEventControllerPrivate::enter_interp_only_mode(JvmtiThreadState *state void JvmtiEventControllerPrivate::leave_interp_only_mode(JvmtiThreadState *state) { - EC_TRACE(("JVMTI [%s] # Leaving interpreter only mode", + EC_TRACE(("[%s] # Leaving interpreter only mode", JvmtiTrace::safe_get_thread_name(state->get_thread()))); state->leave_interp_only_mode(); } @@ -370,7 +371,7 @@ JvmtiEventControllerPrivate::trace_changed(JvmtiThreadState *state, jlong now_en jlong bit = JvmtiEventEnabled::bit_for((jvmtiEvent)ei); if (changed & bit) { // it changed, print it - tty->print_cr("JVMTI [%s] # %s event %s", + log_trace(jvmti)("[%s] # %s event %s", JvmtiTrace::safe_get_thread_name(state->get_thread()), (now_enabled & bit)? "Enabling" : "Disabling", JvmtiTrace::event_name((jvmtiEvent)ei)); } @@ -390,7 +391,7 @@ JvmtiEventControllerPrivate::trace_changed(jlong now_enabled, jlong changed) { jlong bit = JvmtiEventEnabled::bit_for((jvmtiEvent)ei); if (changed & bit) { // it changed, print it - tty->print_cr("JVMTI [-] # %s event %s", + log_trace(jvmti)("[-] # %s event %s", (now_enabled & bit)? "Enabling" : "Disabling", JvmtiTrace::event_name((jvmtiEvent)ei)); } } @@ -563,7 +564,7 @@ JvmtiEventControllerPrivate::recompute_enabled() { jlong was_any_env_thread_enabled = JvmtiEventController::_universal_global_event_enabled.get_bits(); jlong any_env_thread_enabled = 0; - EC_TRACE(("JVMTI [-] # recompute enabled - before " UINT64_FORMAT_X, was_any_env_thread_enabled)); + EC_TRACE(("[-] # recompute enabled - before " UINT64_FORMAT_X, was_any_env_thread_enabled)); // compute non-thread-filters events. // This must be done separately from thread-filtered events, since some @@ -643,7 +644,7 @@ JvmtiEventControllerPrivate::recompute_enabled() { } - EC_TRACE(("JVMTI [-] # recompute enabled - after " UINT64_FORMAT_X, any_env_thread_enabled)); + EC_TRACE(("[-] # recompute enabled - after " UINT64_FORMAT_X, any_env_thread_enabled)); } @@ -653,7 +654,7 @@ JvmtiEventControllerPrivate::thread_started(JavaThread *thread) { assert(thread == Thread::current(), "must be current thread"); assert(JvmtiEnvBase::environments_might_exist(), "to enter event controller, JVM TI environments must exist"); - EC_TRACE(("JVMTI [%s] # thread started", JvmtiTrace::safe_get_thread_name(thread))); + EC_TRACE(("[%s] # thread started", JvmtiTrace::safe_get_thread_name(thread))); // if we have any thread filtered events globally enabled, create/update the thread state if ((JvmtiEventController::_universal_global_event_enabled.get_bits() & THREAD_FILTERED_EVENT_BITS) != 0) { @@ -673,7 +674,7 @@ JvmtiEventControllerPrivate::thread_ended(JavaThread *thread) { // May be called after all environments have been disposed. assert(JvmtiThreadState_lock->is_locked(), "sanity check"); - EC_TRACE(("JVMTI [%s] # thread ended", JvmtiTrace::safe_get_thread_name(thread))); + EC_TRACE(("[%s] # thread ended", JvmtiTrace::safe_get_thread_name(thread))); JvmtiThreadState *state = thread->jvmti_thread_state(); assert(state != NULL, "else why are we here?"); @@ -684,7 +685,7 @@ void JvmtiEventControllerPrivate::set_event_callbacks(JvmtiEnvBase *env, const jvmtiEventCallbacks* callbacks, jint size_of_callbacks) { assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check"); - EC_TRACE(("JVMTI [*] # set event callbacks")); + EC_TRACE(("[*] # set event callbacks")); env->set_event_callbacks(callbacks, size_of_callbacks); jlong enabled_bits = 0; @@ -704,7 +705,7 @@ JvmtiEventControllerPrivate::set_extension_event_callback(JvmtiEnvBase *env, jvmtiExtensionEvent callback) { assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check"); - EC_TRACE(("JVMTI [*] # set extension event callback")); + EC_TRACE(("[*] # set extension event callback")); // extension events are allocated below JVMTI_MIN_EVENT_TYPE_VAL assert(extension_event_index >= (jint)EXT_MIN_EVENT_TYPE_VAL && @@ -750,7 +751,7 @@ JvmtiEventControllerPrivate::set_extension_event_callback(JvmtiEnvBase *env, void JvmtiEventControllerPrivate::env_initialize(JvmtiEnvBase *env) { assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check"); - EC_TRACE(("JVMTI [*] # env initialize")); + EC_TRACE(("[*] # env initialize")); if (JvmtiEnvBase::is_vm_live()) { // if we didn't initialize event info already (this is a late @@ -772,7 +773,7 @@ JvmtiEventControllerPrivate::env_initialize(JvmtiEnvBase *env) { void JvmtiEventControllerPrivate::env_dispose(JvmtiEnvBase *env) { assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check"); - EC_TRACE(("JVMTI [*] # env dispose")); + EC_TRACE(("[*] # env dispose")); // Before the environment is marked disposed, disable all events on this // environment (by zapping the callbacks). As a result, the disposed @@ -794,7 +795,7 @@ JvmtiEventControllerPrivate::set_user_enabled(JvmtiEnvBase *env, JavaThread *thr jvmtiEvent event_type, bool enabled) { assert(Threads::number_of_threads() == 0 || JvmtiThreadState_lock->is_locked(), "sanity check"); - EC_TRACE(("JVMTI [%s] # user %s event %s", + EC_TRACE(("[%s] # user %s event %s", thread==NULL? "ALL": JvmtiTrace::safe_get_thread_name(thread), enabled? "enabled" : "disabled", JvmtiTrace::event_name(event_type))); @@ -813,7 +814,7 @@ JvmtiEventControllerPrivate::set_user_enabled(JvmtiEnvBase *env, JavaThread *thr void JvmtiEventControllerPrivate::set_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { - EC_TRACE(("JVMTI [%s] # set frame pop - frame=%d", + EC_TRACE(("[%s] # set frame pop - frame=%d", JvmtiTrace::safe_get_thread_name(ets->get_thread()), fpop.frame_number() )); @@ -824,7 +825,7 @@ JvmtiEventControllerPrivate::set_frame_pop(JvmtiEnvThreadState *ets, JvmtiFrameP void JvmtiEventControllerPrivate::clear_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { - EC_TRACE(("JVMTI [%s] # clear frame pop - frame=%d", + EC_TRACE(("[%s] # clear frame pop - frame=%d", JvmtiTrace::safe_get_thread_name(ets->get_thread()), fpop.frame_number() )); @@ -837,7 +838,7 @@ void JvmtiEventControllerPrivate::clear_to_frame_pop(JvmtiEnvThreadState *ets, JvmtiFramePop fpop) { int cleared_cnt = ets->get_frame_pops()->clear_to(fpop); - EC_TRACE(("JVMTI [%s] # clear to frame pop - frame=%d, count=%d", + EC_TRACE(("[%s] # clear to frame pop - frame=%d, count=%d", JvmtiTrace::safe_get_thread_name(ets->get_thread()), fpop.frame_number(), cleared_cnt )); @@ -863,7 +864,7 @@ JvmtiEventControllerPrivate::change_field_watch(jvmtiEvent event_type, bool adde return; } - EC_TRACE(("JVMTI [-] # change field watch - %s %s count=%d", + EC_TRACE(("[-] # change field watch - %s %s count=%d", event_type==JVMTI_EVENT_FIELD_MODIFICATION? "modification" : "access", added? "add" : "remove", *count_addr)); @@ -893,7 +894,7 @@ JvmtiEventControllerPrivate::event_init() { return; } - EC_TRACE(("JVMTI [-] # VM live")); + EC_TRACE(("[-] # VM live")); #ifdef ASSERT // check that our idea and the spec's idea of threaded events match diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp index edaea323658..51b8f930e62 100644 --- a/hotspot/src/share/vm/prims/jvmtiExport.cpp +++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp @@ -29,6 +29,8 @@ #include "code/scopeDesc.hpp" #include "interpreter/interpreter.hpp" #include "jvmtifiles/jvmtiEnv.hpp" +#include "logging/log.hpp" +#include "logging/logStream.hpp" #include "memory/resourceArea.hpp" #include "oops/objArrayKlass.hpp" #include "oops/objArrayOop.hpp" @@ -60,8 +62,8 @@ #endif // INCLUDE_ALL_GCS #ifdef JVMTI_TRACE -#define EVT_TRACE(evt,out) if ((JvmtiTrace::event_trace_flags(evt) & JvmtiTrace::SHOW_EVENT_SENT) != 0) { SafeResourceMark rm; tty->print_cr out; } -#define EVT_TRIG_TRACE(evt,out) if ((JvmtiTrace::event_trace_flags(evt) & JvmtiTrace::SHOW_EVENT_TRIGGER) != 0) { SafeResourceMark rm; tty->print_cr out; } +#define EVT_TRACE(evt,out) if ((JvmtiTrace::event_trace_flags(evt) & JvmtiTrace::SHOW_EVENT_SENT) != 0) { SafeResourceMark rm; log_trace(jvmti) out; } +#define EVT_TRIG_TRACE(evt,out) if ((JvmtiTrace::event_trace_flags(evt) & JvmtiTrace::SHOW_EVENT_TRIGGER) != 0) { SafeResourceMark rm; log_trace(jvmti) out; } #else #define EVT_TRIG_TRACE(evt,out) #define EVT_TRACE(evt,out) @@ -423,7 +425,9 @@ JvmtiExport::add_default_read_edges(Handle h_module, TRAPS) { THREAD); if (HAS_PENDING_EXCEPTION) { - java_lang_Throwable::print(PENDING_EXCEPTION, tty); + LogTarget(Trace, jvmti) log; + LogStreamCHeap log_stream(log); + java_lang_Throwable::print(PENDING_EXCEPTION, &log_stream); CLEAR_PENDING_EXCEPTION; return; } @@ -465,7 +469,7 @@ void JvmtiExport::enter_live_phase() { // void JvmtiExport::post_early_vm_start() { - EVT_TRIG_TRACE(JVMTI_EVENT_VM_START, ("JVMTI Trg Early VM start event triggered" )); + EVT_TRIG_TRACE(JVMTI_EVENT_VM_START, ("Trg Early VM start event triggered" )); // can now enable some events JvmtiEventController::vm_start(); @@ -474,7 +478,7 @@ void JvmtiExport::post_early_vm_start() { for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { // Only early vmstart envs post early VMStart event if (env->early_vmstart_env() && env->is_enabled(JVMTI_EVENT_VM_START)) { - EVT_TRACE(JVMTI_EVENT_VM_START, ("JVMTI Evt Early VM start event sent" )); + EVT_TRACE(JVMTI_EVENT_VM_START, ("Evt Early VM start event sent" )); JavaThread *thread = JavaThread::current(); JvmtiThreadEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); @@ -487,7 +491,7 @@ void JvmtiExport::post_early_vm_start() { } void JvmtiExport::post_vm_start() { - EVT_TRIG_TRACE(JVMTI_EVENT_VM_START, ("JVMTI Trg VM start event triggered" )); + EVT_TRIG_TRACE(JVMTI_EVENT_VM_START, ("Trg VM start event triggered" )); // can now enable some events JvmtiEventController::vm_start(); @@ -496,7 +500,7 @@ void JvmtiExport::post_vm_start() { for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { // Early vmstart envs do not post normal VMStart event if (!env->early_vmstart_env() && env->is_enabled(JVMTI_EVENT_VM_START)) { - EVT_TRACE(JVMTI_EVENT_VM_START, ("JVMTI Evt VM start event sent" )); + EVT_TRACE(JVMTI_EVENT_VM_START, ("Evt VM start event sent" )); JavaThread *thread = JavaThread::current(); JvmtiThreadEventMark jem(thread); @@ -511,7 +515,7 @@ void JvmtiExport::post_vm_start() { void JvmtiExport::post_vm_initialized() { - EVT_TRIG_TRACE(JVMTI_EVENT_VM_INIT, ("JVMTI Trg VM init event triggered" )); + EVT_TRIG_TRACE(JVMTI_EVENT_VM_INIT, ("Trg VM init event triggered" )); // can now enable events JvmtiEventController::vm_init(); @@ -519,7 +523,7 @@ void JvmtiExport::post_vm_initialized() { JvmtiEnvIterator it; for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_VM_INIT)) { - EVT_TRACE(JVMTI_EVENT_VM_INIT, ("JVMTI Evt VM init event sent" )); + EVT_TRACE(JVMTI_EVENT_VM_INIT, ("Evt VM init event sent" )); JavaThread *thread = JavaThread::current(); JvmtiThreadEventMark jem(thread); @@ -534,12 +538,12 @@ void JvmtiExport::post_vm_initialized() { void JvmtiExport::post_vm_death() { - EVT_TRIG_TRACE(JVMTI_EVENT_VM_DEATH, ("JVMTI Trg VM death event triggered" )); + EVT_TRIG_TRACE(JVMTI_EVENT_VM_DEATH, ("Trg VM death event triggered" )); JvmtiEnvIterator it; for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_VM_DEATH)) { - EVT_TRACE(JVMTI_EVENT_VM_DEATH, ("JVMTI Evt VM death event sent" )); + EVT_TRACE(JVMTI_EVENT_VM_DEATH, ("Evt VM death event sent" )); JavaThread *thread = JavaThread::current(); JvmtiEventMark jem(thread); @@ -632,9 +636,6 @@ class JvmtiClassFileLoadHookPoster : public StackObj { } void post() { -// EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, -// ("JVMTI [%s] class file load hook event triggered", -// JvmtiTrace::safe_get_thread_name(_thread))); post_all_envs(); copy_modified_data(); } @@ -670,11 +671,6 @@ class JvmtiClassFileLoadHookPoster : public StackObj { } unsigned char *new_data = NULL; jint new_len = 0; -// EVT_TRACE(JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, -// ("JVMTI [%s] class file load hook event sent %s data_ptr = %d, data_len = %d", -// JvmtiTrace::safe_get_thread_name(_thread), -// _h_name == NULL ? "NULL" : _h_name->as_utf8(), -// _curr_data, _curr_len )); JvmtiClassFileLoadEventMark jem(_thread, _h_name, _class_loader, _h_protection_domain, _h_class_being_redefined); @@ -840,7 +836,7 @@ void JvmtiExport::post_compiled_method_unload( } JavaThread* thread = JavaThread::current(); EVT_TRIG_TRACE(JVMTI_EVENT_COMPILED_METHOD_UNLOAD, - ("JVMTI [%s] method compile unload event triggered", + ("[%s] method compile unload event triggered", JvmtiTrace::safe_get_thread_name(thread))); // post the event for each environment that has this event enabled. @@ -851,7 +847,7 @@ void JvmtiExport::post_compiled_method_unload( continue; } EVT_TRACE(JVMTI_EVENT_COMPILED_METHOD_UNLOAD, - ("JVMTI [%s] class compile method unload event sent jmethodID " PTR_FORMAT, + ("[%s] class compile method unload event sent jmethodID " PTR_FORMAT, JvmtiTrace::safe_get_thread_name(thread), p2i(method))); ResourceMark rm(thread); @@ -879,7 +875,7 @@ void JvmtiExport::post_raw_breakpoint(JavaThread *thread, Method* method, addres if (state == NULL) { return; } - EVT_TRIG_TRACE(JVMTI_EVENT_BREAKPOINT, ("JVMTI [%s] Trg Breakpoint triggered", + EVT_TRIG_TRACE(JVMTI_EVENT_BREAKPOINT, ("[%s] Trg Breakpoint triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { @@ -887,7 +883,7 @@ void JvmtiExport::post_raw_breakpoint(JavaThread *thread, Method* method, addres if (!ets->breakpoint_posted() && ets->is_enabled(JVMTI_EVENT_BREAKPOINT)) { ThreadState old_os_state = thread->osthread()->get_state(); thread->osthread()->set_state(BREAKPOINTED); - EVT_TRACE(JVMTI_EVENT_BREAKPOINT, ("JVMTI [%s] Evt Breakpoint sent %s.%s @ " INTX_FORMAT, + EVT_TRACE(JVMTI_EVENT_BREAKPOINT, ("[%s] Evt Breakpoint sent %s.%s @ " INTX_FORMAT, JvmtiTrace::safe_get_thread_name(thread), (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), @@ -965,7 +961,7 @@ void JvmtiExport::at_single_stepping_point(JavaThread *thread, Method* method, a if (state == NULL) { return; } - EVT_TRIG_TRACE(JVMTI_EVENT_SINGLE_STEP, ("JVMTI [%s] Trg Single Step triggered", + EVT_TRIG_TRACE(JVMTI_EVENT_SINGLE_STEP, ("[%s] Trg Single Step triggered", JvmtiTrace::safe_get_thread_name(thread))); if (!state->hide_single_stepping()) { if (state->is_pending_step_for_popframe()) { @@ -1004,7 +1000,7 @@ void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) { HandleMark hm(thread); KlassHandle kh(thread, klass); - EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_LOAD, ("JVMTI [%s] Trg Class Load triggered", + EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Trg Class Load triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiThreadState* state = thread->jvmti_thread_state(); if (state == NULL) { @@ -1017,7 +1013,7 @@ void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) { if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { continue; } - EVT_TRACE(JVMTI_EVENT_CLASS_LOAD, ("JVMTI [%s] Evt Class Load sent %s", + EVT_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Evt Class Load sent %s", JvmtiTrace::safe_get_thread_name(thread), kh()==NULL? "NULL" : kh()->external_name() )); JvmtiClassEventMark jem(thread, kh()); @@ -1038,7 +1034,7 @@ void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) { HandleMark hm(thread); KlassHandle kh(thread, klass); - EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("JVMTI [%s] Trg Class Prepare triggered", + EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Trg Class Prepare triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiThreadState* state = thread->jvmti_thread_state(); if (state == NULL) { @@ -1051,7 +1047,7 @@ void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) { if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { continue; } - EVT_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("JVMTI [%s] Evt Class Prepare sent %s", + EVT_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Evt Class Prepare sent %s", JvmtiTrace::safe_get_thread_name(thread), kh()==NULL? "NULL" : kh()->external_name() )); JvmtiClassEventMark jem(thread, kh()); @@ -1072,7 +1068,7 @@ void JvmtiExport::post_class_unload(Klass* klass) { HandleMark hm(thread); KlassHandle kh(thread, klass); - EVT_TRIG_TRACE(EXT_EVENT_CLASS_UNLOAD, ("JVMTI [?] Trg Class Unload triggered" )); + EVT_TRIG_TRACE(EXT_EVENT_CLASS_UNLOAD, ("[?] Trg Class Unload triggered" )); if (JvmtiEventController::is_enabled((jvmtiEvent)EXT_EVENT_CLASS_UNLOAD)) { assert(thread->is_VM_thread(), "wrong thread"); @@ -1086,7 +1082,7 @@ void JvmtiExport::post_class_unload(Klass* klass) { continue; } if (env->is_enabled((jvmtiEvent)EXT_EVENT_CLASS_UNLOAD)) { - EVT_TRACE(EXT_EVENT_CLASS_UNLOAD, ("JVMTI [?] Evt Class Unload sent %s", + EVT_TRACE(EXT_EVENT_CLASS_UNLOAD, ("[?] Evt Class Unload sent %s", kh()==NULL? "NULL" : kh()->external_name() )); // do everything manually, since this is a proxy - needs special care @@ -1125,7 +1121,7 @@ void JvmtiExport::post_thread_start(JavaThread *thread) { } assert(thread->thread_state() == _thread_in_vm, "must be in vm state"); - EVT_TRIG_TRACE(JVMTI_EVENT_THREAD_START, ("JVMTI [%s] Trg Thread Start event triggered", + EVT_TRIG_TRACE(JVMTI_EVENT_THREAD_START, ("[%s] Trg Thread Start event triggered", JvmtiTrace::safe_get_thread_name(thread))); // do JVMTI thread initialization (if needed) @@ -1140,7 +1136,7 @@ void JvmtiExport::post_thread_start(JavaThread *thread) { continue; } if (env->is_enabled(JVMTI_EVENT_THREAD_START)) { - EVT_TRACE(JVMTI_EVENT_THREAD_START, ("JVMTI [%s] Evt Thread Start event sent", + EVT_TRACE(JVMTI_EVENT_THREAD_START, ("[%s] Evt Thread Start event sent", JvmtiTrace::safe_get_thread_name(thread) )); JvmtiThreadEventMark jem(thread); @@ -1159,7 +1155,7 @@ void JvmtiExport::post_thread_end(JavaThread *thread) { if (JvmtiEnv::get_phase() < JVMTI_PHASE_PRIMORDIAL) { return; } - EVT_TRIG_TRACE(JVMTI_EVENT_THREAD_END, ("JVMTI [%s] Trg Thread End event triggered", + EVT_TRIG_TRACE(JVMTI_EVENT_THREAD_END, ("[%s] Trg Thread End event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiThreadState *state = thread->jvmti_thread_state(); @@ -1178,7 +1174,7 @@ void JvmtiExport::post_thread_end(JavaThread *thread) { if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { continue; } - EVT_TRACE(JVMTI_EVENT_THREAD_END, ("JVMTI [%s] Evt Thread End event sent", + EVT_TRACE(JVMTI_EVENT_THREAD_END, ("[%s] Evt Thread End event sent", JvmtiTrace::safe_get_thread_name(thread) )); JvmtiThreadEventMark jem(thread); @@ -1196,8 +1192,8 @@ void JvmtiExport::post_object_free(JvmtiEnv* env, jlong tag) { assert(SafepointSynchronize::is_at_safepoint(), "must be executed at safepoint"); assert(env->is_enabled(JVMTI_EVENT_OBJECT_FREE), "checking"); - EVT_TRIG_TRACE(JVMTI_EVENT_OBJECT_FREE, ("JVMTI [?] Trg Object Free triggered" )); - EVT_TRACE(JVMTI_EVENT_OBJECT_FREE, ("JVMTI [?] Evt Object Free sent")); + EVT_TRIG_TRACE(JVMTI_EVENT_OBJECT_FREE, ("[?] Trg Object Free triggered" )); + EVT_TRACE(JVMTI_EVENT_OBJECT_FREE, ("[?] Evt Object Free sent")); jvmtiEventObjectFree callback = env->callbacks()->ObjectFree; if (callback != NULL) { @@ -1206,12 +1202,12 @@ void JvmtiExport::post_object_free(JvmtiEnv* env, jlong tag) { } void JvmtiExport::post_resource_exhausted(jint resource_exhausted_flags, const char* description) { - EVT_TRIG_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("JVMTI Trg resource exhausted event triggered" )); + EVT_TRIG_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("Trg resource exhausted event triggered" )); JvmtiEnvIterator it; for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_RESOURCE_EXHAUSTED)) { - EVT_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("JVMTI Evt resource exhausted event sent" )); + EVT_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("Evt resource exhausted event sent" )); JavaThread *thread = JavaThread::current(); JvmtiThreadEventMark jem(thread); @@ -1229,7 +1225,7 @@ void JvmtiExport::post_method_entry(JavaThread *thread, Method* method, frame cu HandleMark hm(thread); methodHandle mh(thread, method); - EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_ENTRY, ("JVMTI [%s] Trg Method Entry triggered %s.%s", + EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_ENTRY, ("[%s] Trg Method Entry triggered %s.%s", JvmtiTrace::safe_get_thread_name(thread), (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() )); @@ -1246,7 +1242,7 @@ void JvmtiExport::post_method_entry(JavaThread *thread, Method* method, frame cu JvmtiEnvThreadStateIterator it(state); for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_METHOD_ENTRY)) { - EVT_TRACE(JVMTI_EVENT_METHOD_ENTRY, ("JVMTI [%s] Evt Method Entry sent %s.%s", + EVT_TRACE(JVMTI_EVENT_METHOD_ENTRY, ("[%s] Evt Method Entry sent %s.%s", JvmtiTrace::safe_get_thread_name(thread), (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() )); @@ -1267,7 +1263,7 @@ void JvmtiExport::post_method_exit(JavaThread *thread, Method* method, frame cur HandleMark hm(thread); methodHandle mh(thread, method); - EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_EXIT, ("JVMTI [%s] Trg Method Exit triggered %s.%s", + EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_EXIT, ("[%s] Trg Method Exit triggered %s.%s", JvmtiTrace::safe_get_thread_name(thread), (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() )); @@ -1303,7 +1299,7 @@ void JvmtiExport::post_method_exit(JavaThread *thread, Method* method, frame cur JvmtiEnvThreadStateIterator it(state); for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_METHOD_EXIT)) { - EVT_TRACE(JVMTI_EVENT_METHOD_EXIT, ("JVMTI [%s] Evt Method Exit sent %s.%s", + EVT_TRACE(JVMTI_EVENT_METHOD_EXIT, ("[%s] Evt Method Exit sent %s.%s", JvmtiTrace::safe_get_thread_name(thread), (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() )); @@ -1332,7 +1328,7 @@ void JvmtiExport::post_method_exit(JavaThread *thread, Method* method, frame cur // we have a NotifyFramePop entry for this frame. // now check that this env/thread wants this event if (ets->is_enabled(JVMTI_EVENT_FRAME_POP)) { - EVT_TRACE(JVMTI_EVENT_FRAME_POP, ("JVMTI [%s] Evt Frame Pop sent %s.%s", + EVT_TRACE(JVMTI_EVENT_FRAME_POP, ("[%s] Evt Frame Pop sent %s.%s", JvmtiTrace::safe_get_thread_name(thread), (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), (mh() == NULL) ? "NULL" : mh()->name()->as_C_string() )); @@ -1370,7 +1366,7 @@ void JvmtiExport::post_single_step(JavaThread *thread, Method* method, address l for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { ets->compare_and_set_current_location(mh(), location, JVMTI_EVENT_SINGLE_STEP); if (!ets->single_stepping_posted() && ets->is_enabled(JVMTI_EVENT_SINGLE_STEP)) { - EVT_TRACE(JVMTI_EVENT_SINGLE_STEP, ("JVMTI [%s] Evt Single Step sent %s.%s @ " INTX_FORMAT, + EVT_TRACE(JVMTI_EVENT_SINGLE_STEP, ("[%s] Evt Single Step sent %s.%s @ " INTX_FORMAT, JvmtiTrace::safe_get_thread_name(thread), (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), @@ -1401,7 +1397,7 @@ void JvmtiExport::post_exception_throw(JavaThread *thread, Method* method, addre return; } - EVT_TRIG_TRACE(JVMTI_EVENT_EXCEPTION, ("JVMTI [%s] Trg Exception thrown triggered", + EVT_TRIG_TRACE(JVMTI_EVENT_EXCEPTION, ("[%s] Trg Exception thrown triggered", JvmtiTrace::safe_get_thread_name(thread))); if (!state->is_exception_detected()) { state->set_exception_detected(); @@ -1410,7 +1406,7 @@ void JvmtiExport::post_exception_throw(JavaThread *thread, Method* method, addre if (ets->is_enabled(JVMTI_EVENT_EXCEPTION) && (exception != NULL)) { EVT_TRACE(JVMTI_EVENT_EXCEPTION, - ("JVMTI [%s] Evt Exception thrown sent %s.%s @ " INTX_FORMAT, + ("[%s] Evt Exception thrown sent %s.%s @ " INTX_FORMAT, JvmtiTrace::safe_get_thread_name(thread), (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), @@ -1486,7 +1482,7 @@ void JvmtiExport::notice_unwind_due_to_exception(JavaThread *thread, Method* met return; } EVT_TRIG_TRACE(JVMTI_EVENT_EXCEPTION_CATCH, - ("JVMTI [%s] Trg unwind_due_to_exception triggered %s.%s @ %s" INTX_FORMAT " - %s", + ("[%s] Trg unwind_due_to_exception triggered %s.%s @ %s" INTX_FORMAT " - %s", JvmtiTrace::safe_get_thread_name(thread), (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), @@ -1521,7 +1517,7 @@ void JvmtiExport::notice_unwind_due_to_exception(JavaThread *thread, Method* met for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_EXCEPTION_CATCH) && (exception_handle() != NULL)) { EVT_TRACE(JVMTI_EVENT_EXCEPTION_CATCH, - ("JVMTI [%s] Evt ExceptionCatch sent %s.%s @ " INTX_FORMAT, + ("[%s] Evt ExceptionCatch sent %s.%s @ " INTX_FORMAT, JvmtiTrace::safe_get_thread_name(thread), (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), @@ -1610,12 +1606,12 @@ void JvmtiExport::post_field_access(JavaThread *thread, Method* method, if (state == NULL) { return; } - EVT_TRIG_TRACE(JVMTI_EVENT_FIELD_ACCESS, ("JVMTI [%s] Trg Field Access event triggered", + EVT_TRIG_TRACE(JVMTI_EVENT_FIELD_ACCESS, ("[%s] Trg Field Access event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_FIELD_ACCESS)) { - EVT_TRACE(JVMTI_EVENT_FIELD_ACCESS, ("JVMTI [%s] Evt Field Access event sent %s.%s @ " INTX_FORMAT, + EVT_TRACE(JVMTI_EVENT_FIELD_ACCESS, ("[%s] Evt Field Access event sent %s.%s @ " INTX_FORMAT, JvmtiTrace::safe_get_thread_name(thread), (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), @@ -1772,14 +1768,14 @@ void JvmtiExport::post_field_modification(JavaThread *thread, Method* method, return; } EVT_TRIG_TRACE(JVMTI_EVENT_FIELD_MODIFICATION, - ("JVMTI [%s] Trg Field Modification event triggered", + ("[%s] Trg Field Modification event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_FIELD_MODIFICATION)) { EVT_TRACE(JVMTI_EVENT_FIELD_MODIFICATION, - ("JVMTI [%s] Evt Field Modification event sent %s.%s @ " INTX_FORMAT, + ("[%s] Evt Field Modification event sent %s.%s @ " INTX_FORMAT, JvmtiTrace::safe_get_thread_name(thread), (mh() == NULL) ? "NULL" : mh()->klass_name()->as_C_string(), (mh() == NULL) ? "NULL" : mh()->name()->as_C_string(), @@ -1807,14 +1803,14 @@ void JvmtiExport::post_native_method_bind(Method* method, address* function_ptr) HandleMark hm(thread); methodHandle mh(thread, method); - EVT_TRIG_TRACE(JVMTI_EVENT_NATIVE_METHOD_BIND, ("JVMTI [%s] Trg Native Method Bind event triggered", + EVT_TRIG_TRACE(JVMTI_EVENT_NATIVE_METHOD_BIND, ("[%s] Trg Native Method Bind event triggered", JvmtiTrace::safe_get_thread_name(thread))); if (JvmtiEventController::is_enabled(JVMTI_EVENT_NATIVE_METHOD_BIND)) { JvmtiEnvIterator it; for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_NATIVE_METHOD_BIND)) { - EVT_TRACE(JVMTI_EVENT_NATIVE_METHOD_BIND, ("JVMTI [%s] Evt Native Method Bind event sent", + EVT_TRACE(JVMTI_EVENT_NATIVE_METHOD_BIND, ("[%s] Evt Native Method Bind event sent", JvmtiTrace::safe_get_thread_name(thread) )); JvmtiMethodEventMark jem(thread, mh); @@ -1878,7 +1874,7 @@ void JvmtiExport::post_compiled_method_load(nmethod *nm) { JavaThread* thread = JavaThread::current(); EVT_TRIG_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD, - ("JVMTI [%s] method compile load event triggered", + ("[%s] method compile load event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvIterator it; @@ -1888,7 +1884,7 @@ void JvmtiExport::post_compiled_method_load(nmethod *nm) { continue; } EVT_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD, - ("JVMTI [%s] class compile method load event sent %s.%s ", + ("[%s] class compile method load event sent %s.%s ", JvmtiTrace::safe_get_thread_name(thread), (nm->method() == NULL) ? "NULL" : nm->method()->klass_name()->as_C_string(), (nm->method() == NULL) ? "NULL" : nm->method()->name()->as_C_string())); @@ -1921,12 +1917,12 @@ void JvmtiExport::post_compiled_method_load(JvmtiEnv* env, const jmethodID metho } JavaThread* thread = JavaThread::current(); EVT_TRIG_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD, - ("JVMTI [%s] method compile load event triggered (by GenerateEvents)", + ("[%s] method compile load event triggered (by GenerateEvents)", JvmtiTrace::safe_get_thread_name(thread))); if (env->is_enabled(JVMTI_EVENT_COMPILED_METHOD_LOAD)) { EVT_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD, - ("JVMTI [%s] class compile method load event sent (by GenerateEvents), jmethodID=" PTR_FORMAT, + ("[%s] class compile method load event sent (by GenerateEvents), jmethodID=" PTR_FORMAT, JvmtiTrace::safe_get_thread_name(thread), p2i(method))); JvmtiEventMark jem(thread); @@ -1949,13 +1945,13 @@ void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const v ThreadInVMfromUnknown __tiv; EVT_TRIG_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED, - ("JVMTI [%s] method dynamic code generated event triggered", + ("[%s] method dynamic code generated event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvIterator it; for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { EVT_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED, - ("JVMTI [%s] dynamic code generated event sent for %s", + ("[%s] dynamic code generated event sent for %s", JvmtiTrace::safe_get_thread_name(thread), name)); JvmtiEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); @@ -1991,11 +1987,11 @@ void JvmtiExport::post_dynamic_code_generated(JvmtiEnv* env, const char *name, { JavaThread* thread = JavaThread::current(); EVT_TRIG_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED, - ("JVMTI [%s] dynamic code generated event triggered (by GenerateEvents)", + ("[%s] dynamic code generated event triggered (by GenerateEvents)", JvmtiTrace::safe_get_thread_name(thread))); if (env->is_enabled(JVMTI_EVENT_DYNAMIC_CODE_GENERATED)) { EVT_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED, - ("JVMTI [%s] dynamic code generated event sent for %s", + ("[%s] dynamic code generated event sent for %s", JvmtiTrace::safe_get_thread_name(thread), name)); JvmtiEventMark jem(thread); JvmtiJavaThreadEventTransition jet(thread); @@ -2048,13 +2044,13 @@ void JvmtiExport::record_vm_internal_object_allocation(oop obj) { void JvmtiExport::post_garbage_collection_finish() { Thread *thread = Thread::current(); // this event is posted from VM-Thread. EVT_TRIG_TRACE(JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, - ("JVMTI [%s] garbage collection finish event triggered", + ("[%s] garbage collection finish event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvIterator it; for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_GARBAGE_COLLECTION_FINISH)) { EVT_TRACE(JVMTI_EVENT_GARBAGE_COLLECTION_FINISH, - ("JVMTI [%s] garbage collection finish event sent ", + ("[%s] garbage collection finish event sent", JvmtiTrace::safe_get_thread_name(thread))); JvmtiThreadEventTransition jet(thread); // JNIEnv is NULL here because this event is posted from VM Thread @@ -2069,13 +2065,13 @@ void JvmtiExport::post_garbage_collection_finish() { void JvmtiExport::post_garbage_collection_start() { Thread* thread = Thread::current(); // this event is posted from vm-thread. EVT_TRIG_TRACE(JVMTI_EVENT_GARBAGE_COLLECTION_START, - ("JVMTI [%s] garbage collection start event triggered", + ("[%s] garbage collection start event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvIterator it; for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_GARBAGE_COLLECTION_START)) { EVT_TRACE(JVMTI_EVENT_GARBAGE_COLLECTION_START, - ("JVMTI [%s] garbage collection start event sent ", + ("[%s] garbage collection start event sent", JvmtiTrace::safe_get_thread_name(thread))); JvmtiThreadEventTransition jet(thread); // JNIEnv is NULL here because this event is posted from VM Thread @@ -2090,13 +2086,13 @@ void JvmtiExport::post_garbage_collection_start() { void JvmtiExport::post_data_dump() { Thread *thread = Thread::current(); EVT_TRIG_TRACE(JVMTI_EVENT_DATA_DUMP_REQUEST, - ("JVMTI [%s] data dump request event triggered", + ("[%s] data dump request event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvIterator it; for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_DATA_DUMP_REQUEST)) { EVT_TRACE(JVMTI_EVENT_DATA_DUMP_REQUEST, - ("JVMTI [%s] data dump request event sent ", + ("[%s] data dump request event sent", JvmtiTrace::safe_get_thread_name(thread))); JvmtiThreadEventTransition jet(thread); // JNIEnv is NULL here because this event is posted from VM Thread @@ -2123,14 +2119,14 @@ void JvmtiExport::post_monitor_contended_enter(JavaThread *thread, ObjectMonitor Handle h(thread, object); EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTER, - ("JVMTI [%s] montior contended enter event triggered", + ("[%s] montior contended enter event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_MONITOR_CONTENDED_ENTER)) { EVT_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTER, - ("JVMTI [%s] monitor contended enter event sent", + ("[%s] monitor contended enter event sent", JvmtiTrace::safe_get_thread_name(thread))); JvmtiMonitorEventMark jem(thread, h()); JvmtiEnv *env = ets->get_env(); @@ -2158,14 +2154,14 @@ void JvmtiExport::post_monitor_contended_entered(JavaThread *thread, ObjectMonit Handle h(thread, object); EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, - ("JVMTI [%s] montior contended entered event triggered", + ("[%s] montior contended entered event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_MONITOR_CONTENDED_ENTERED)) { EVT_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, - ("JVMTI [%s] monitor contended enter event sent", + ("[%s] monitor contended enter event sent", JvmtiTrace::safe_get_thread_name(thread))); JvmtiMonitorEventMark jem(thread, h()); JvmtiEnv *env = ets->get_env(); @@ -2189,14 +2185,14 @@ void JvmtiExport::post_monitor_wait(JavaThread *thread, oop object, Handle h(thread, object); EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_WAIT, - ("JVMTI [%s] montior wait event triggered", + ("[%s] montior wait event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_MONITOR_WAIT)) { EVT_TRACE(JVMTI_EVENT_MONITOR_WAIT, - ("JVMTI [%s] monitor wait event sent ", + ("[%s] monitor wait event sent", JvmtiTrace::safe_get_thread_name(thread))); JvmtiMonitorEventMark jem(thread, h()); JvmtiEnv *env = ets->get_env(); @@ -2225,14 +2221,14 @@ void JvmtiExport::post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mnt Handle h(thread, object); EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_WAITED, - ("JVMTI [%s] montior waited event triggered", + ("[%s] montior waited event triggered", JvmtiTrace::safe_get_thread_name(thread))); JvmtiEnvThreadStateIterator it(state); for (JvmtiEnvThreadState* ets = it.first(); ets != NULL; ets = it.next(ets)) { if (ets->is_enabled(JVMTI_EVENT_MONITOR_WAITED)) { EVT_TRACE(JVMTI_EVENT_MONITOR_WAITED, - ("JVMTI [%s] monitor waited event sent ", + ("[%s] monitor waited event sent", JvmtiTrace::safe_get_thread_name(thread))); JvmtiMonitorEventMark jem(thread, h()); JvmtiEnv *env = ets->get_env(); @@ -2248,7 +2244,7 @@ void JvmtiExport::post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mnt void JvmtiExport::post_vm_object_alloc(JavaThread *thread, oop object) { - EVT_TRIG_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("JVMTI [%s] Trg vm object alloc triggered", + EVT_TRIG_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("[%s] Trg vm object alloc triggered", JvmtiTrace::safe_get_thread_name(thread))); if (object == NULL) { return; @@ -2258,7 +2254,7 @@ void JvmtiExport::post_vm_object_alloc(JavaThread *thread, oop object) { JvmtiEnvIterator it; for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_VM_OBJECT_ALLOC)) { - EVT_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("JVMTI [%s] Evt vmobject alloc sent %s", + EVT_TRACE(JVMTI_EVENT_VM_OBJECT_ALLOC, ("[%s] Evt vmobject alloc sent %s", JvmtiTrace::safe_get_thread_name(thread), object==NULL? "NULL" : object->klass()->external_name())); diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.cpp b/hotspot/src/share/vm/prims/jvmtiImpl.cpp index 986517d34df..129672cb607 100644 --- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp +++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp @@ -27,6 +27,8 @@ #include "interpreter/interpreter.hpp" #include "interpreter/oopMapCache.hpp" #include "jvmtifiles/jvmtiEnv.hpp" +#include "logging/log.hpp" +#include "logging/logStream.hpp" #include "memory/resourceArea.hpp" #include "oops/instanceKlass.hpp" #include "oops/oop.inline.hpp" @@ -321,12 +323,12 @@ void JvmtiBreakpoint::clear() { each_method_version_do(&Method::clear_breakpoint); } -void JvmtiBreakpoint::print() { +void JvmtiBreakpoint::print(outputStream* out) { #ifndef PRODUCT + ResourceMark rm; const char *class_name = (_method == NULL) ? "NULL" : _method->klass_name()->as_C_string(); const char *method_name = (_method == NULL) ? "NULL" : _method->name()->as_C_string(); - - tty->print("Breakpoint(%s,%s,%d,%p)",class_name, method_name, _bci, getBcp()); + out->print("Breakpoint(%s,%s,%d,%p)", class_name, method_name, _bci, getBcp()); #endif } @@ -389,16 +391,17 @@ void JvmtiBreakpoints::gc_epilogue() { _bps.gc_epilogue(); } -void JvmtiBreakpoints::print() { +void JvmtiBreakpoints::print() { #ifndef PRODUCT - ResourceMark rm; + LogTarget(Trace, jvmti) log; + LogStreamCHeap log_stream(log); int n = _bps.length(); for (int i=0; iprint("%d: ", i); - bp.print(); - tty->cr(); + log_stream.print("%d: ", i); + bp.print(&log_stream); + log_stream.cr(); } #endif } @@ -875,22 +878,21 @@ bool JvmtiSuspendControl::resume(JavaThread *java_thread) { void JvmtiSuspendControl::print() { #ifndef PRODUCT MutexLocker mu(Threads_lock); - ResourceMark rm; - - tty->print("Suspended Threads: ["); + LogStreamHandle(Trace, jvmti) log_stream; + log_stream.print("Suspended Threads: ["); for (JavaThread *thread = Threads::first(); thread != NULL; thread = thread->next()) { #ifdef JVMTI_TRACE const char *name = JvmtiTrace::safe_get_thread_name(thread); #else const char *name = ""; #endif /*JVMTI_TRACE */ - tty->print("%s(%c ", name, thread->is_being_ext_suspended() ? 'S' : '_'); + log_stream.print("%s(%c ", name, thread->is_being_ext_suspended() ? 'S' : '_'); if (!thread->has_last_Java_frame()) { - tty->print("no stack"); + log_stream.print("no stack"); } - tty->print(") "); + log_stream.print(") "); } - tty->print_cr("]"); + log_stream.print_cr("]"); #endif } diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.hpp b/hotspot/src/share/vm/prims/jvmtiImpl.hpp index c1e4b81b66e..0bf6fc23c40 100644 --- a/hotspot/src/share/vm/prims/jvmtiImpl.hpp +++ b/hotspot/src/share/vm/prims/jvmtiImpl.hpp @@ -34,6 +34,7 @@ #include "prims/jvmtiUtil.hpp" #include "runtime/stackValueCollection.hpp" #include "runtime/vm_operations.hpp" +#include "utilities/ostream.hpp" // // Forward Declarations @@ -186,7 +187,7 @@ public: void each_method_version_do(method_action meth_act); void set(); void clear(); - void print(); + void print(outputStream* out); Method* method() { return _method; } diff --git a/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp b/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp index a9ce01c93d1..1166ed6f004 100644 --- a/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp +++ b/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp @@ -24,8 +24,10 @@ #include "precompiled.hpp" #include "jvmtifiles/jvmtiEnv.hpp" +#include "logging/log.hpp" #include "prims/jvmtiExport.hpp" #include "prims/jvmtiManageCapabilities.hpp" + static const jint CAPA_SIZE = (JVMTI_INTERNAL_CAPABILITY_COUNT + 7) / 8; // capabilities which are always potentially available @@ -373,87 +375,87 @@ void JvmtiManageCapabilities::update() { #ifndef PRODUCT void JvmtiManageCapabilities:: print(const jvmtiCapabilities* cap) { - tty->print_cr("----- capabilities -----"); + log_trace(jvmti)("----- capabilities -----"); if (cap->can_tag_objects) - tty->print_cr("can_tag_objects"); + log_trace(jvmti)("can_tag_objects"); if (cap->can_generate_field_modification_events) - tty->print_cr("can_generate_field_modification_events"); + log_trace(jvmti)("can_generate_field_modification_events"); if (cap->can_generate_field_access_events) - tty->print_cr("can_generate_field_access_events"); + log_trace(jvmti)("can_generate_field_access_events"); if (cap->can_get_bytecodes) - tty->print_cr("can_get_bytecodes"); + log_trace(jvmti)("can_get_bytecodes"); if (cap->can_get_synthetic_attribute) - tty->print_cr("can_get_synthetic_attribute"); + log_trace(jvmti)("can_get_synthetic_attribute"); if (cap->can_get_owned_monitor_info) - tty->print_cr("can_get_owned_monitor_info"); + log_trace(jvmti)("can_get_owned_monitor_info"); if (cap->can_get_current_contended_monitor) - tty->print_cr("can_get_current_contended_monitor"); + log_trace(jvmti)("can_get_current_contended_monitor"); if (cap->can_get_monitor_info) - tty->print_cr("can_get_monitor_info"); + log_trace(jvmti)("can_get_monitor_info"); if (cap->can_get_constant_pool) - tty->print_cr("can_get_constant_pool"); + log_trace(jvmti)("can_get_constant_pool"); if (cap->can_pop_frame) - tty->print_cr("can_pop_frame"); + log_trace(jvmti)("can_pop_frame"); if (cap->can_force_early_return) - tty->print_cr("can_force_early_return"); + log_trace(jvmti)("can_force_early_return"); if (cap->can_redefine_classes) - tty->print_cr("can_redefine_classes"); + log_trace(jvmti)("can_redefine_classes"); if (cap->can_retransform_classes) - tty->print_cr("can_retransform_classes"); + log_trace(jvmti)("can_retransform_classes"); if (cap->can_signal_thread) - tty->print_cr("can_signal_thread"); + log_trace(jvmti)("can_signal_thread"); if (cap->can_get_source_file_name) - tty->print_cr("can_get_source_file_name"); + log_trace(jvmti)("can_get_source_file_name"); if (cap->can_get_line_numbers) - tty->print_cr("can_get_line_numbers"); + log_trace(jvmti)("can_get_line_numbers"); if (cap->can_get_source_debug_extension) - tty->print_cr("can_get_source_debug_extension"); + log_trace(jvmti)("can_get_source_debug_extension"); if (cap->can_access_local_variables) - tty->print_cr("can_access_local_variables"); + log_trace(jvmti)("can_access_local_variables"); if (cap->can_maintain_original_method_order) - tty->print_cr("can_maintain_original_method_order"); + log_trace(jvmti)("can_maintain_original_method_order"); if (cap->can_generate_single_step_events) - tty->print_cr("can_generate_single_step_events"); + log_trace(jvmti)("can_generate_single_step_events"); if (cap->can_generate_exception_events) - tty->print_cr("can_generate_exception_events"); + log_trace(jvmti)("can_generate_exception_events"); if (cap->can_generate_frame_pop_events) - tty->print_cr("can_generate_frame_pop_events"); + log_trace(jvmti)("can_generate_frame_pop_events"); if (cap->can_generate_breakpoint_events) - tty->print_cr("can_generate_breakpoint_events"); + log_trace(jvmti)("can_generate_breakpoint_events"); if (cap->can_suspend) - tty->print_cr("can_suspend"); + log_trace(jvmti)("can_suspend"); if (cap->can_redefine_any_class ) - tty->print_cr("can_redefine_any_class"); + log_trace(jvmti)("can_redefine_any_class"); if (cap->can_retransform_any_class ) - tty->print_cr("can_retransform_any_class"); + log_trace(jvmti)("can_retransform_any_class"); if (cap->can_get_current_thread_cpu_time) - tty->print_cr("can_get_current_thread_cpu_time"); + log_trace(jvmti)("can_get_current_thread_cpu_time"); if (cap->can_get_thread_cpu_time) - tty->print_cr("can_get_thread_cpu_time"); + log_trace(jvmti)("can_get_thread_cpu_time"); if (cap->can_generate_method_entry_events) - tty->print_cr("can_generate_method_entry_events"); + log_trace(jvmti)("can_generate_method_entry_events"); if (cap->can_generate_method_exit_events) - tty->print_cr("can_generate_method_exit_events"); + log_trace(jvmti)("can_generate_method_exit_events"); if (cap->can_generate_all_class_hook_events) - tty->print_cr("can_generate_all_class_hook_events"); + log_trace(jvmti)("can_generate_all_class_hook_events"); if (cap->can_generate_compiled_method_load_events) - tty->print_cr("can_generate_compiled_method_load_events"); + log_trace(jvmti)("can_generate_compiled_method_load_events"); if (cap->can_generate_monitor_events) - tty->print_cr("can_generate_monitor_events"); + log_trace(jvmti)("can_generate_monitor_events"); if (cap->can_generate_vm_object_alloc_events) - tty->print_cr("can_generate_vm_object_alloc_events"); + log_trace(jvmti)("can_generate_vm_object_alloc_events"); if (cap->can_generate_native_method_bind_events) - tty->print_cr("can_generate_native_method_bind_events"); + log_trace(jvmti)("can_generate_native_method_bind_events"); if (cap->can_generate_garbage_collection_events) - tty->print_cr("can_generate_garbage_collection_events"); + log_trace(jvmti)("can_generate_garbage_collection_events"); if (cap->can_generate_object_free_events) - tty->print_cr("can_generate_object_free_events"); + log_trace(jvmti)("can_generate_object_free_events"); if (cap->can_generate_resource_exhaustion_heap_events) - tty->print_cr("can_generate_resource_exhaustion_heap_events"); + log_trace(jvmti)("can_generate_resource_exhaustion_heap_events"); if (cap->can_generate_resource_exhaustion_threads_events) - tty->print_cr("can_generate_resource_exhaustion_threads_events"); + log_trace(jvmti)("can_generate_resource_exhaustion_threads_events"); if (cap->can_generate_early_vmstart) - tty->print_cr("can_generate_early_vmstart"); + log_trace(jvmti)("can_generate_early_vmstart"); } #endif diff --git a/hotspot/src/share/vm/prims/jvmtiThreadState.cpp b/hotspot/src/share/vm/prims/jvmtiThreadState.cpp index e98891e8ef3..1e3a6e8c03e 100644 --- a/hotspot/src/share/vm/prims/jvmtiThreadState.cpp +++ b/hotspot/src/share/vm/prims/jvmtiThreadState.cpp @@ -224,18 +224,11 @@ int JvmtiThreadState::count_frames() { RegisterMap reg_map(get_thread()); javaVFrame *jvf = get_thread()->last_java_vframe(®_map); int n = 0; - // tty->print_cr("CSD: counting frames on %s ...", - // JvmtiTrace::safe_get_thread_name(get_thread())); while (jvf != NULL) { Method* method = jvf->method(); - // tty->print_cr("CSD: frame - method %s.%s - loc %d", - // method->klass_name()->as_C_string(), - // method->name()->as_C_string(), - // jvf->bci() ); jvf = jvf->java_sender(); n++; } - // tty->print_cr("CSD: frame count: %d", n); return n; } diff --git a/hotspot/src/share/vm/prims/jvmtiTrace.cpp b/hotspot/src/share/vm/prims/jvmtiTrace.cpp index 01edd16c63f..bb92c7bb51c 100644 --- a/hotspot/src/share/vm/prims/jvmtiTrace.cpp +++ b/hotspot/src/share/vm/prims/jvmtiTrace.cpp @@ -24,6 +24,8 @@ #include "precompiled.hpp" #include "jvmtifiles/jvmtiEnv.hpp" +#include "logging/log.hpp" +#include "logging/logConfiguration.hpp" #include "memory/resourceArea.hpp" #include "prims/jvmtiTrace.hpp" @@ -80,6 +82,17 @@ void JvmtiTrace::initialize() { } else { curr = ""; // hack in fixed tracing here } + + // Enable UL for JVMTI tracing + if (strlen(curr) > 0) { + if (!log_is_enabled(Trace, jvmti)) { + log_warning(arguments)("-XX:+TraceJVMTI specified, " + "but no log output configured for the 'jvmti' tag on Trace level. " + "Defaulting to -Xlog:jvmti=trace"); + LogConfiguration::configure_stdout(LogLevel::Trace, true, LOG_TAGS(jvmti)); + } + } + very_end = curr + strlen(curr); while (curr < very_end) { const char *curr_end = strchr(curr, ','); @@ -127,7 +140,7 @@ void JvmtiTrace::initialize() { bits |= SHOW_EVENT_SENT; break; default: - tty->print_cr("Invalid trace flag '%c'", *flags); + log_warning(jvmti)("Invalid trace flag '%c'", *flags); break; } } @@ -152,7 +165,7 @@ void JvmtiTrace::initialize() { domain = ALL_EVENT | EVENT; } else if (len==2 && strncmp(curr, "ec", 2)==0) { _trace_event_controller = true; - tty->print_cr("JVMTI Tracing the event controller"); + log_trace(jvmti)("Tracing the event controller"); } else { domain = FUNC | EVENT; // go searching } @@ -161,9 +174,9 @@ void JvmtiTrace::initialize() { if (domain & FUNC) { if (domain & ALL_FUNC) { if (domain & EXCLUDE) { - tty->print("JVMTI Tracing all significant functions"); + log_trace(jvmti)("Tracing all significant functions"); } else { - tty->print_cr("JVMTI Tracing all functions"); + log_trace(jvmti)("Tracing all functions"); } } for (int i = 0; i <= _max_function_index; ++i) { @@ -178,7 +191,7 @@ void JvmtiTrace::initialize() { if (fname != NULL) { size_t fnlen = strlen(fname); if (len==fnlen && strncmp(curr, fname, fnlen)==0) { - tty->print_cr("JVMTI Tracing the function: %s", fname); + log_trace(jvmti)("Tracing the function: %s", fname); do_op = true; } } @@ -196,7 +209,7 @@ void JvmtiTrace::initialize() { } if (domain & EVENT) { if (domain & ALL_EVENT) { - tty->print_cr("JVMTI Tracing all events"); + log_trace(jvmti)("Tracing all events"); } for (int i = 0; i <= _max_event_index; ++i) { bool do_op = false; @@ -207,7 +220,7 @@ void JvmtiTrace::initialize() { if (ename != NULL) { size_t evtlen = strlen(ename); if (len==evtlen && strncmp(curr, ename, evtlen)==0) { - tty->print_cr("JVMTI Tracing the event: %s", ename); + log_trace(jvmti)("Tracing the event: %s", ename); do_op = true; } } @@ -223,7 +236,7 @@ void JvmtiTrace::initialize() { } } if (!_on && (domain & (FUNC|EVENT))) { - tty->print_cr("JVMTI Trace domain not found"); + log_warning(jvmti)("Trace domain not found"); } curr = curr_end + 1; } -- GitLab From 167be2a61cb3dc255f759a3c5a6bc5c2b983effd Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Tue, 19 Apr 2016 14:21:26 +0200 Subject: [PATCH 158/400] 8154059: JVMTI ObjectTagging to UL Reviewed-by: sspitsyn, mlarsson --- hotspot/src/share/vm/logging/logTag.hpp | 1 + hotspot/src/share/vm/prims/jvmtiEnv.cpp | 12 ++++++------ hotspot/src/share/vm/prims/jvmtiTagMap.cpp | 20 +++++--------------- hotspot/src/share/vm/runtime/arguments.cpp | 1 + 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/hotspot/src/share/vm/logging/logTag.hpp b/hotspot/src/share/vm/logging/logTag.hpp index 6b9cd7d3d21..d9759dca859 100644 --- a/hotspot/src/share/vm/logging/logTag.hpp +++ b/hotspot/src/share/vm/logging/logTag.hpp @@ -70,6 +70,7 @@ LOG_TAG(modules) \ LOG_TAG(monitorinflation) \ LOG_TAG(monitormismatch) \ + LOG_TAG(objecttagging) \ LOG_TAG(os) \ LOG_TAG(pagesize) \ LOG_TAG(phases) \ diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp index 6dffe9876a1..f0877571f6e 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp @@ -1675,7 +1675,7 @@ JvmtiEnv::FollowReferences(jint heap_filter, jclass klass, jobject initial_objec HandleMark hm(thread); KlassHandle kh (thread, k_oop); - TraceTime t("FollowReferences", TraceJVMTIObjectTagging); + TraceTime t("FollowReferences", TRACETIME_LOG(Debug, jvmti, objecttagging)); JvmtiTagMap::tag_map_for(this)->follow_references(heap_filter, kh, initial_object, callbacks, user_data); return JVMTI_ERROR_NONE; } /* end FollowReferences */ @@ -1706,7 +1706,7 @@ JvmtiEnv::IterateThroughHeap(jint heap_filter, jclass klass, const jvmtiHeapCall HandleMark hm(thread); KlassHandle kh (thread, k_oop); - TraceTime t("IterateThroughHeap", TraceJVMTIObjectTagging); + TraceTime t("IterateThroughHeap", TRACETIME_LOG(Debug, jvmti, objecttagging)); JvmtiTagMap::tag_map_for(this)->iterate_through_heap(heap_filter, kh, callbacks, user_data); return JVMTI_ERROR_NONE; } /* end IterateThroughHeap */ @@ -1738,7 +1738,7 @@ JvmtiEnv::SetTag(jobject object, jlong tag) { // tag_result_ptr - NULL is a valid value, must be checked jvmtiError JvmtiEnv::GetObjectsWithTags(jint tag_count, const jlong* tags, jint* count_ptr, jobject** object_result_ptr, jlong** tag_result_ptr) { - TraceTime t("GetObjectsWithTags", TraceJVMTIObjectTagging); + TraceTime t("GetObjectsWithTags", TRACETIME_LOG(Debug, jvmti, objecttagging)); return JvmtiTagMap::tag_map_for(this)->get_objects_with_tags((jlong*)tags, tag_count, count_ptr, object_result_ptr, tag_result_ptr); } /* end GetObjectsWithTags */ @@ -1771,7 +1771,7 @@ JvmtiEnv::IterateOverObjectsReachableFromObject(jobject object, jvmtiObjectRefer // user_data - NULL is a valid value, must be checked jvmtiError JvmtiEnv::IterateOverReachableObjects(jvmtiHeapRootCallback heap_root_callback, jvmtiStackReferenceCallback stack_ref_callback, jvmtiObjectReferenceCallback object_ref_callback, const void* user_data) { - TraceTime t("IterateOverReachableObjects", TraceJVMTIObjectTagging); + TraceTime t("IterateOverReachableObjects", TRACETIME_LOG(Debug, jvmti, objecttagging)); JvmtiTagMap::tag_map_for(this)->iterate_over_reachable_objects(heap_root_callback, stack_ref_callback, object_ref_callback, user_data); return JVMTI_ERROR_NONE; } /* end IterateOverReachableObjects */ @@ -1781,7 +1781,7 @@ JvmtiEnv::IterateOverReachableObjects(jvmtiHeapRootCallback heap_root_callback, // user_data - NULL is a valid value, must be checked jvmtiError JvmtiEnv::IterateOverHeap(jvmtiHeapObjectFilter object_filter, jvmtiHeapObjectCallback heap_object_callback, const void* user_data) { - TraceTime t("IterateOverHeap", TraceJVMTIObjectTagging); + TraceTime t("IterateOverHeap", TRACETIME_LOG(Debug, jvmti, objecttagging)); Thread *thread = Thread::current(); HandleMark hm(thread); JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, KlassHandle(), heap_object_callback, user_data); @@ -1805,7 +1805,7 @@ JvmtiEnv::IterateOverInstancesOfClass(oop k_mirror, jvmtiHeapObjectFilter object Thread *thread = Thread::current(); HandleMark hm(thread); KlassHandle klass (thread, k_oop); - TraceTime t("IterateOverInstancesOfClass", TraceJVMTIObjectTagging); + TraceTime t("IterateOverInstancesOfClass", TRACETIME_LOG(Debug, jvmti, objecttagging)); JvmtiTagMap::tag_map_for(this)->iterate_over_heap(object_filter, klass, heap_object_callback, user_data); return JVMTI_ERROR_NONE; } /* end IterateOverInstancesOfClass */ diff --git a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp index b164c7ae45a..fa9d5131e31 100644 --- a/hotspot/src/share/vm/prims/jvmtiTagMap.cpp +++ b/hotspot/src/share/vm/prims/jvmtiTagMap.cpp @@ -146,11 +146,7 @@ class JvmtiTagHashmap : public CHeapObj { _size_index = size_index; _size = initial_size; _entry_count = 0; - if (TraceJVMTIObjectTagging) { - _trace_threshold = initial_trace_threshold; - } else { - _trace_threshold = -1; - } + _trace_threshold = initial_trace_threshold; _load_factor = load_factor; _resize_threshold = (int)(_load_factor * _size); _resizing_enabled = true; @@ -329,8 +325,7 @@ class JvmtiTagHashmap : public CHeapObj { } _entry_count++; - if (trace_threshold() > 0 && entry_count() >= trace_threshold()) { - assert(TraceJVMTIObjectTagging, "should only get here when tracing"); + if (log_is_enabled(Debug, jvmti, objecttagging) && entry_count() >= trace_threshold()) { print_memory_usage(); compute_next_trace_threshold(); } @@ -409,6 +404,7 @@ void JvmtiTagHashmap::print_memory_usage() { // compute threshold for the next trace message void JvmtiTagHashmap::compute_next_trace_threshold() { + _trace_threshold = entry_count(); if (trace_threshold() < medium_trace_threshold) { _trace_threshold += small_trace_threshold; } else { @@ -3413,12 +3409,6 @@ void JvmtiTagMap::do_weak_oops(BoolObjectClosure* is_alive, OopClosure* f) { delayed_add = next; } - // stats - if (TraceJVMTIObjectTagging) { - int post_total = hashmap->_entry_count; - int pre_total = post_total + freed; - - tty->print_cr("(%d->%d, %d freed, %d total moves)", - pre_total, post_total, freed, moved); - } + log_debug(jvmti, objecttagging)("(%d->%d, %d freed, %d total moves)", + hashmap->_entry_count + freed, hashmap->_entry_count, freed, moved); } diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 2e0ad45aa8b..f0e1b54e15a 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -420,6 +420,7 @@ static AliasedLoggingFlag const aliased_logging_flags[] = { { "TraceLoaderConstraints", LogLevel::Info, true, LOG_TAGS(classload, constraints) }, { "TraceMonitorInflation", LogLevel::Debug, true, LOG_TAGS(monitorinflation) }, { "TraceSafepointCleanupTime", LogLevel::Info, true, LOG_TAGS(safepointcleanup) }, + { "TraceJVMTIObjectTagging", LogLevel::Debug, true, LOG_TAGS(jvmti, objecttagging) }, { NULL, LogLevel::Off, false, LOG_TAGS(_NO_TAG) } }; -- GitLab From 16c430d2b6dde7f550f86a32878f3066d48e6398 Mon Sep 17 00:00:00 2001 From: Max Ockner Date: Tue, 19 Apr 2016 11:03:37 -0400 Subject: [PATCH 159/400] 8151526: Print -Xlog configuration in the hs_err_pid file Logging configuration is now printed in hs_err and in vm info. Reviewed-by: coleenp, mlarsson, dholmes --- hotspot/src/share/vm/logging/logConfiguration.cpp | 12 ++++++++++-- hotspot/src/share/vm/logging/logConfiguration.hpp | 6 ++++++ hotspot/src/share/vm/utilities/vmError.cpp | 13 +++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/logging/logConfiguration.cpp b/hotspot/src/share/vm/logging/logConfiguration.cpp index 6f9f7bb2a27..870e7c0eabd 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.cpp +++ b/hotspot/src/share/vm/logging/logConfiguration.cpp @@ -382,7 +382,7 @@ bool LogConfiguration::parse_log_arguments(const char* outputstr, return true; } -void LogConfiguration::describe(outputStream* out) { +void LogConfiguration::describe_available(outputStream* out){ out->print("Available log levels:"); for (size_t i = 0; i < LogLevel::Count; i++) { out->print("%s %s", (i == 0 ? "" : ","), LogLevel::name(static_cast(i))); @@ -402,7 +402,9 @@ void LogConfiguration::describe(outputStream* out) { } out->cr(); - ConfigurationLock cl; +} + +void LogConfiguration::describe_current_configuration(outputStream* out){ out->print_cr("Log output configuration:"); for (size_t i = 0; i < _n_outputs; i++) { out->print("#" SIZE_FORMAT ": %s %s ", i, _outputs[i]->name(), _outputs[i]->config_string()); @@ -416,6 +418,12 @@ void LogConfiguration::describe(outputStream* out) { } } +void LogConfiguration::describe(outputStream* out) { + describe_available(out); + ConfigurationLock cl; + describe_current_configuration(out); +} + void LogConfiguration::print_command_line_help(FILE* out) { jio_fprintf(out, "-Xlog Usage: -Xlog[:[what][:[output][:[decorators][:output-options]]]]\n" "\t where 'what' is a combination of tags and levels on the form tag1[+tag2...][*][=level][,...]\n" diff --git a/hotspot/src/share/vm/logging/logConfiguration.hpp b/hotspot/src/share/vm/logging/logConfiguration.hpp index 9b7325b370e..9efbadddd02 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.hpp +++ b/hotspot/src/share/vm/logging/logConfiguration.hpp @@ -37,6 +37,7 @@ class LogTagLevelExpression; // kept implicitly in the LogTagSets and their LogOutputLists. During configuration the tagsets // are iterated over and updated accordingly. class LogConfiguration : public AllStatic { + friend class VMError; public: // Function for listeners typedef void (*UpdateListenerFunction)(void); @@ -79,6 +80,11 @@ class LogConfiguration : public AllStatic { // This should be called after any configuration change while still holding ConfigurationLock static void notify_update_listeners(); + // Respectively describe the built-in and runtime dependent portions of the configuration. + static void describe_available(outputStream* out); + static void describe_current_configuration(outputStream* out); + + public: // Initialization and finalization of log configuration, to be run at vm startup and shutdown respectively. static void initialize(jlong vm_start_time); diff --git a/hotspot/src/share/vm/utilities/vmError.cpp b/hotspot/src/share/vm/utilities/vmError.cpp index 4ca94f391a4..1eac0b14d0e 100644 --- a/hotspot/src/share/vm/utilities/vmError.cpp +++ b/hotspot/src/share/vm/utilities/vmError.cpp @@ -28,6 +28,7 @@ #include "compiler/compileBroker.hpp" #include "compiler/disassembler.hpp" #include "gc/shared/collectedHeap.hpp" +#include "logging/logConfiguration.hpp" #include "prims/whitebox.hpp" #include "runtime/arguments.hpp" #include "runtime/atomic.inline.hpp" @@ -774,6 +775,13 @@ void VMError::report(outputStream* st, bool _verbose) { st->cr(); } + STEP(395, "(printing log configuration)") + if (_verbose){ + st->print_cr("Logging:"); + LogConfiguration::describe_current_configuration(st); + st->cr(); + } + STEP(400, "(printing all environment variables)" ) if (_verbose) { @@ -937,6 +945,11 @@ void VMError::print_vm_info(outputStream* st) { st->cr(); } + // STEP("(printing log configuration)") + st->print_cr("Logging:"); + LogConfiguration::describe(st); + st->cr(); + // STEP("(printing all environment variables)") os::print_environment_variables(st, env_list); -- GitLab From 2aff402303141be1b02c049ef3bbd8772dbf53ce Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Thu, 21 Apr 2016 02:58:04 -0400 Subject: [PATCH 160/400] 8154280: Zero build fails with undeclared G1LastPLABAverageOccupancy Reviewed-by: twisti --- hotspot/src/share/vm/gc/g1/g1EvacStats.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/src/share/vm/gc/g1/g1EvacStats.cpp b/hotspot/src/share/vm/gc/g1/g1EvacStats.cpp index 0a66488f71d..2b6c3917800 100644 --- a/hotspot/src/share/vm/gc/g1/g1EvacStats.cpp +++ b/hotspot/src/share/vm/gc/g1/g1EvacStats.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "memory/allocation.inline.hpp" +#include "gc/g1/g1_globals.hpp" #include "gc/g1/g1EvacStats.hpp" #include "gc/shared/gcId.hpp" #include "logging/log.hpp" -- GitLab From 790431bd5dafaae11e696859b5b2b33b4ef3d890 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Wed, 20 Apr 2016 09:58:15 +0200 Subject: [PATCH 161/400] 8079843: do_young_space_rescan - comment out of sync with code Reviewed-by: mgerdin, sjohanss, ehelin, tschatzl --- .../gc/cms/concurrentMarkSweepGeneration.cpp | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp index 9e67c9b39e3..83bf54437a8 100644 --- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp @@ -2769,10 +2769,10 @@ class CMSParMarkTask : public AbstractGangTask { _collector(collector), _n_workers(n_workers) {} // Work method in support of parallel rescan ... of young gen spaces - void do_young_space_rescan(uint worker_id, OopsInGenClosure* cl, + void do_young_space_rescan(OopsInGenClosure* cl, ContiguousSpace* space, HeapWord** chunk_array, size_t chunk_top); - void work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl); + void work_on_young_gen_roots(OopsInGenClosure* cl); }; // Parallel initial mark task @@ -4255,7 +4255,7 @@ void CMSParInitialMarkTask::work(uint worker_id) { // ---------- young gen roots -------------- { - work_on_young_gen_roots(worker_id, &par_mri_cl); + work_on_young_gen_roots(&par_mri_cl); _timer.stop(); log_trace(gc, task)("Finished young gen initial mark scan work in %dth thread: %3.3f sec", worker_id, _timer.seconds()); } @@ -4346,7 +4346,7 @@ class RemarkKlassClosure : public KlassClosure { } }; -void CMSParMarkTask::work_on_young_gen_roots(uint worker_id, OopsInGenClosure* cl) { +void CMSParMarkTask::work_on_young_gen_roots(OopsInGenClosure* cl) { ParNewGeneration* young_gen = _collector->_young_gen; ContiguousSpace* eden_space = young_gen->eden(); ContiguousSpace* from_space = young_gen->from(); @@ -4360,9 +4360,9 @@ void CMSParMarkTask::work_on_young_gen_roots(uint worker_id, OopsInGenClosure* c assert(ect <= _collector->_eden_chunk_capacity, "out of bounds"); assert(sct <= _collector->_survivor_chunk_capacity, "out of bounds"); - do_young_space_rescan(worker_id, cl, to_space, NULL, 0); - do_young_space_rescan(worker_id, cl, from_space, sca, sct); - do_young_space_rescan(worker_id, cl, eden_space, eca, ect); + do_young_space_rescan(cl, to_space, NULL, 0); + do_young_space_rescan(cl, from_space, sca, sct); + do_young_space_rescan(cl, eden_space, eca, ect); } // work_queue(i) is passed to the closure @@ -4389,7 +4389,7 @@ void CMSParRemarkTask::work(uint worker_id) { // work first. // ---------- young gen roots -------------- { - work_on_young_gen_roots(worker_id, &par_mrias_cl); + work_on_young_gen_roots(&par_mrias_cl); _timer.stop(); log_trace(gc, task)("Finished young gen rescan work in %dth thread: %3.3f sec", worker_id, _timer.seconds()); } @@ -4471,9 +4471,8 @@ void CMSParRemarkTask::work(uint worker_id) { log_trace(gc, task)("Finished work stealing in %dth thread: %3.3f sec", worker_id, _timer.seconds()); } -// Note that parameter "i" is not used. void -CMSParMarkTask::do_young_space_rescan(uint worker_id, +CMSParMarkTask::do_young_space_rescan( OopsInGenClosure* cl, ContiguousSpace* space, HeapWord** chunk_array, size_t chunk_top) { // Until all tasks completed: -- GitLab From e61f2f7f5e63cd07e97377096173f2f2c7526849 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Wed, 20 Apr 2016 10:01:25 +0200 Subject: [PATCH 162/400] 8154728: JvmtiExport::add_default_read_edges hits a guarantee Reviewed-by: mgerdin, dholmes, stefank --- hotspot/src/share/vm/prims/jvmtiExport.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp index 51b8f930e62..30e9b7dcd23 100644 --- a/hotspot/src/share/vm/prims/jvmtiExport.cpp +++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp @@ -428,6 +428,7 @@ JvmtiExport::add_default_read_edges(Handle h_module, TRAPS) { LogTarget(Trace, jvmti) log; LogStreamCHeap log_stream(log); java_lang_Throwable::print(PENDING_EXCEPTION, &log_stream); + log_stream.cr(); CLEAR_PENDING_EXCEPTION; return; } -- GitLab From cdcd378bd628d41eb40889654dd180bc0abea3cd Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Wed, 20 Apr 2016 11:05:28 +0000 Subject: [PATCH 163/400] 8153310: AArch64: JEP 254: Implement byte_array_inflate Reviewed-by: roland --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 34 ++++++++ .../src/cpu/aarch64/vm/assembler_aarch64.hpp | 42 ++++++--- .../cpu/aarch64/vm/macroAssembler_aarch64.cpp | 87 ++++++++++++++++++- .../cpu/aarch64/vm/macroAssembler_aarch64.hpp | 9 ++ 4 files changed, 159 insertions(+), 13 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index 09ec22242d2..004346fcb53 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -14930,6 +14930,40 @@ instruct array_equalsC(iRegP_R1 ary1, iRegP_R2 ary2, iRegI_R0 result, %} +// fast char[] to byte[] compression +instruct string_compress(iRegP_R2 src, iRegP_R1 dst, iRegI_R3 len, + vRegD_V0 tmp1, vRegD_V1 tmp2, + vRegD_V2 tmp3, vRegD_V3 tmp4, + iRegI_R0 result, rFlagsReg cr) +%{ + match(Set result (StrCompressedCopy src (Binary dst len))); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, USE_KILL src, USE_KILL dst, USE_KILL len, KILL cr); + + format %{ "String Compress $src,$dst -> $result // KILL R1, R2, R3, R4" %} + ins_encode %{ + __ char_array_compress($src$$Register, $dst$$Register, $len$$Register, + $tmp1$$FloatRegister, $tmp2$$FloatRegister, + $tmp3$$FloatRegister, $tmp4$$FloatRegister, + $result$$Register); + %} + ins_pipe( pipe_slow ); +%} + +// fast byte[] to char[] inflation +instruct string_inflate(Universe dummy, iRegP_R0 src, iRegP_R1 dst, iRegI_R2 len, + vRegD tmp1, vRegD tmp2, vRegD tmp3, iRegP_R3 tmp4, rFlagsReg cr) +%{ + match(Set dummy (StrInflatedCopy src (Binary dst len))); + effect(TEMP tmp1, TEMP tmp2, TEMP tmp3, TEMP tmp4, USE_KILL src, USE_KILL dst, USE_KILL len, KILL cr); + + format %{ "String Inflate $src,$dst // KILL $tmp1, $tmp2" %} + ins_encode %{ + __ byte_array_inflate($src$$Register, $dst$$Register, $len$$Register, + $tmp1$$FloatRegister, $tmp2$$FloatRegister, $tmp3$$FloatRegister, $tmp4$$Register); + %} + ins_pipe(pipe_class_memory); +%} + // encode char[] to byte[] in ISO_8859_1 instruct encode_iso_array(iRegP_R2 src, iRegP_R1 dst, iRegI_R3 len, vRegD_V0 Vtmp1, vRegD_V1 Vtmp2, diff --git a/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp index 965a5c8072f..05d977b1cf8 100644 --- a/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp @@ -2245,18 +2245,18 @@ public: rf(Vn, 5), rf(Rd, 0); } -#define INSN(NAME, opc, opc2) \ - void NAME(FloatRegister Vd, SIMD_Arrangement T, FloatRegister Vn, int shift){ \ - starti; \ - /* The encodings for the immh:immb fields (bits 22:16) are \ - * 0001 xxx 8B/16B, shift = xxx \ - * 001x xxx 4H/8H, shift = xxxx \ - * 01xx xxx 2S/4S, shift = xxxxx \ - * 1xxx xxx 1D/2D, shift = xxxxxx (1D is RESERVED) \ - */ \ - assert((1 << ((T>>1)+3)) > shift, "Invalid Shift value"); \ - f(0, 31), f(T & 1, 30), f(opc, 29), f(0b011110, 28, 23), \ - f((1 << ((T>>1)+3))|shift, 22, 16); f(opc2, 15, 10), rf(Vn, 5), rf(Vd, 0); \ +#define INSN(NAME, opc, opc2) \ + void NAME(FloatRegister Vd, SIMD_Arrangement T, FloatRegister Vn, int shift){ \ + starti; \ + /* The encodings for the immh:immb fields (bits 22:16) are \ + * 0001 xxx 8B/16B, shift = xxx \ + * 001x xxx 4H/8H, shift = xxxx \ + * 01xx xxx 2S/4S, shift = xxxxx \ + * 1xxx xxx 1D/2D, shift = xxxxxx (1D is RESERVED) \ + */ \ + assert((1 << ((T>>1)+3)) > shift, "Invalid Shift value"); \ + f(0, 31), f(T & 1, 30), f(opc, 29), f(0b011110, 28, 23), \ + f((1 << ((T>>1)+3))|shift, 22, 16); f(opc2, 15, 10), rf(Vn, 5), rf(Vd, 0); \ } INSN(shl, 0, 0b010101); @@ -2347,6 +2347,24 @@ public: f(0b000001, 15, 10), rf(Vn, 5), rf(Vd, 0); } + // AdvSIMD ZIP/UZP/TRN +#define INSN(NAME, opcode) \ + void NAME(FloatRegister Vd, SIMD_Arrangement T, FloatRegister Vn, FloatRegister Vm) { \ + starti; \ + f(0, 31), f(0b001110, 29, 24), f(0, 21), f(0b001110, 15, 10); \ + rf(Vm, 16), rf(Vn, 5), rf(Vd, 0); \ + f(T & 1, 30), f(T >> 1, 23, 22); \ + } + + INSN(uzp1, 0b001); + INSN(trn1, 0b010); + INSN(zip1, 0b011); + INSN(uzp2, 0b101); + INSN(trn2, 0b110); + INSN(zip2, 0b111); + +#undef INSN + // CRC32 instructions #define INSN(NAME, c, sf, sz) \ void NAME(Register Rd, Register Rn, Register Rm) { \ diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp index 0859c095834..00f424d1b67 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp @@ -4680,7 +4680,8 @@ void MacroAssembler::arrays_equals(Register a1, Register a2, } -// encode char[] to byte[] in ISO_8859_1 +// Intrinsic for sun/nio/cs/ISO_8859_1$Encoder.implEncodeISOArray and +// java/lang/StringUTF16.compress. void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, Register result, FloatRegister Vtmp1, FloatRegister Vtmp2, @@ -4743,6 +4744,90 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, BIND(DONE); sub(result, result, len); // Return index where we stopped + // Return len == 0 if we processed all + // characters +} + + +// Inflate byte[] array to char[]. +void MacroAssembler::byte_array_inflate(Register src, Register dst, Register len, + FloatRegister vtmp1, FloatRegister vtmp2, FloatRegister vtmp3, + Register tmp4) { + Label big, done; + + assert_different_registers(src, dst, len, tmp4, rscratch1); + + fmovd(vtmp1 , zr); + lsrw(rscratch1, len, 3); + + cbnzw(rscratch1, big); + + // Short string: less than 8 bytes. + { + Label loop, around, tiny; + + subsw(len, len, 4); + andw(len, len, 3); + br(LO, tiny); + + // Use SIMD to do 4 bytes. + ldrs(vtmp2, post(src, 4)); + zip1(vtmp3, T8B, vtmp2, vtmp1); + strd(vtmp3, post(dst, 8)); + + cbzw(len, done); + + // Do the remaining bytes by steam. + bind(loop); + ldrb(tmp4, post(src, 1)); + strh(tmp4, post(dst, 2)); + subw(len, len, 1); + + bind(tiny); + cbnz(len, loop); + + bind(around); + b(done); + } + + // Unpack the bytes 8 at a time. + bind(big); + andw(len, len, 7); + + { + Label loop, around; + + bind(loop); + ldrd(vtmp2, post(src, 8)); + sub(rscratch1, rscratch1, 1); + zip1(vtmp3, T16B, vtmp2, vtmp1); + st1(vtmp3, T8H, post(dst, 16)); + cbnz(rscratch1, loop); + + bind(around); + } + + // Do the tail of up to 8 bytes. + sub(src, src, 8); + add(src, src, len, ext::uxtw, 0); + ldrd(vtmp2, Address(src)); + sub(dst, dst, 16); + add(dst, dst, len, ext::uxtw, 1); + zip1(vtmp3, T16B, vtmp2, vtmp1); + st1(vtmp3, T8H, Address(dst)); + + bind(done); +} + +// Compress char[] array to byte[]. +void MacroAssembler::char_array_compress(Register src, Register dst, Register len, + FloatRegister tmp1Reg, FloatRegister tmp2Reg, + FloatRegister tmp3Reg, FloatRegister tmp4Reg, + Register result) { + encode_iso_array(src, dst, len, result, + tmp1Reg, tmp2Reg, tmp3Reg, tmp4Reg); + cmp(len, zr); + csel(result, result, zr, EQ); } // get_thread() can be called anywhere inside generated code so we diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp index b114e1b9c80..57cf4eb7ded 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp @@ -1184,6 +1184,15 @@ public: Register result, Register cnt1, int elem_size, bool is_string); + void byte_array_inflate(Register src, Register dst, Register len, + FloatRegister vtmp1, FloatRegister vtmp2, + FloatRegister vtmp3, Register tmp4); + + void char_array_compress(Register src, Register dst, Register len, + FloatRegister tmp1Reg, FloatRegister tmp2Reg, + FloatRegister tmp3Reg, FloatRegister tmp4Reg, + Register result); + void encode_iso_array(Register src, Register dst, Register len, Register result, FloatRegister Vtmp1, FloatRegister Vtmp2, -- GitLab From 2b0d77befa509156026aad6191dc7a3a327e8429 Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Wed, 20 Apr 2016 11:14:10 +0000 Subject: [PATCH 164/400] 8154739: AArch64: TemplateTable::fast_xaccess loads in wrong mode Reviewed-by: roland --- hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp index 6c8c5ac8bac..0e74514634e 100644 --- a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp @@ -2982,7 +2982,7 @@ void TemplateTable::fast_xaccess(TosState state) __ null_check(r0); switch (state) { case itos: - __ ldr(r0, Address(r0, r1, Address::lsl(0))); + __ ldrw(r0, Address(r0, r1, Address::lsl(0))); break; case atos: __ load_heap_oop(r0, Address(r0, r1, Address::lsl(0))); @@ -3000,7 +3000,7 @@ void TemplateTable::fast_xaccess(TosState state) __ ldrw(r3, Address(r2, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset()))); __ tbz(r3, ConstantPoolCacheEntry::is_volatile_shift, notVolatile); - __ membar(MacroAssembler::LoadLoad); + __ membar(MacroAssembler::LoadLoad | MacroAssembler::LoadStore); __ bind(notVolatile); } -- GitLab From c66b2de971f745080aebc9fe191022c955c6fe47 Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Tue, 19 Apr 2016 19:13:18 +0300 Subject: [PATCH 165/400] 8138607: gc/g1/mixedgc/TestLogging.java - G1 Evacuation Pause missing from output Reviewed-by: tschatzl, dfazunen --- hotspot/test/gc/g1/mixedgc/TestLogging.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hotspot/test/gc/g1/mixedgc/TestLogging.java b/hotspot/test/gc/g1/mixedgc/TestLogging.java index 913097d50ae..f1eff8c41e5 100644 --- a/hotspot/test/gc/g1/mixedgc/TestLogging.java +++ b/hotspot/test/gc/g1/mixedgc/TestLogging.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ * @summary Check that a mixed GC is reflected in the gc logs * @requires vm.gc=="G1" | vm.gc=="null" * @library /testlibrary /test/lib - * @ignore 8138607 * @modules java.management * @build sun.hotspot.WhiteBox gc.g1.mixedgc.TestLogging * @run main ClassFileInstaller sun.hotspot.WhiteBox @@ -57,8 +56,8 @@ public class TestLogging { "-XX:SurvivorRatio=1", // Survivor-to-eden ratio is 1:1 "-Xms10M", "-Xmx10M", "-XX:MaxTenuringThreshold=1", // promote objects after first gc - "-XX:InitiatingHeapOccupancyPercent=0", // marking cycle happens - // each time + "-XX:InitiatingHeapOccupancyPercent=100", // set initial CMC threshold and disable adaptive IHOP + "-XX:-G1UseAdaptiveIHOP", // to avoid additional concurrent cycles caused by ergonomics "-XX:G1MixedGCCountTarget=4", "-XX:MaxGCPauseMillis=30000", // to have enough time "-XX:G1HeapRegionSize=1m", "-XX:G1HeapWastePercent=0", @@ -120,8 +119,8 @@ class MixedGCProvoker { // Allocates buffer and promotes it to the old gen. Mix live and dead old // objects for (int i = 0; i < TestLogging.ALLOCATION_COUNT; ++i) { - liveOldObjects.add(new byte[TestLogging.ALLOCATION_SIZE * 10]); - deadOldObjects.add(new byte[TestLogging.ALLOCATION_SIZE * 10]); + liveOldObjects.add(new byte[TestLogging.ALLOCATION_SIZE * 5]); + deadOldObjects.add(new byte[TestLogging.ALLOCATION_SIZE * 5]); } // need only 2 promotions to promote objects to the old gen -- GitLab From 4ba6969ac6ecd21e123cce76a062e9f060666bd2 Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Wed, 20 Apr 2016 19:54:51 +0300 Subject: [PATCH 166/400] 8135200: Add White Box method that enumerates G1 old regions with less than specified liveness and collects statistics Reviewed-by: tschatzl, dfazunen, iignatyev --- hotspot/src/share/vm/prims/whitebox.cpp | 64 +++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index 88a732370f6..012efed2222 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -38,6 +38,7 @@ #include "memory/iterator.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" +#include "memory/oopFactory.hpp" #include "oops/constantPool.hpp" #include "oops/oop.inline.hpp" #include "prims/wbtestmethods/parserTests.hpp" @@ -374,6 +375,68 @@ WB_ENTRY(jobject, WB_G1AuxiliaryMemoryUsage(JNIEnv* env)) Handle h = MemoryService::create_MemoryUsage_obj(usage, CHECK_NULL); return JNIHandles::make_local(env, h()); WB_END + +class OldRegionsLivenessClosure: public HeapRegionClosure { + + private: + const int _liveness; + size_t _total_count; + size_t _total_memory; + size_t _total_memory_to_free; + + public: + OldRegionsLivenessClosure(int liveness) : + _liveness(liveness), + _total_count(0), + _total_memory(0), + _total_memory_to_free(0) { } + + size_t total_count() { return _total_count; } + size_t total_memory() { return _total_memory; } + size_t total_memory_to_free() { return _total_memory_to_free; } + + bool doHeapRegion(HeapRegion* r) { + if (r->is_old()) { + size_t prev_live = r->marked_bytes(); + size_t live = r->live_bytes(); + size_t size = r->used(); + size_t reg_size = HeapRegion::GrainBytes; + if (size > 0 && ((int)(live * 100 / size) < _liveness)) { + _total_memory += size; + ++_total_count; + if (size == reg_size) { + // we don't include non-full regions since they are unlikely included in mixed gc + // for testing purposes it's enough to have lowest estimation of total memory that is expected to be freed + _total_memory_to_free += size - prev_live; + } + } + } + return false; + } +}; + + +WB_ENTRY(jlongArray, WB_G1GetMixedGCInfo(JNIEnv* env, jobject o, jint liveness)) + if (!UseG1GC) { + THROW_MSG_NULL(vmSymbols::java_lang_RuntimeException(), "WB_G1GetMixedGCInfo: G1 is not enabled"); + } + if (liveness < 0) { + THROW_MSG_NULL(vmSymbols::java_lang_IllegalArgumentException(), "liveness value should be non-negative"); + } + + G1CollectedHeap* g1h = G1CollectedHeap::heap(); + OldRegionsLivenessClosure rli(liveness); + g1h->heap_region_iterate(&rli); + + typeArrayOop result = oopFactory::new_longArray(3, CHECK_NULL); + result->long_at_put(0, rli.total_count()); + result->long_at_put(1, rli.total_memory()); + result->long_at_put(2, rli.total_memory_to_free()); + return (jlongArray) JNIHandles::make_local(env, result); +WB_END + + + #endif // INCLUDE_ALL_GCS #if INCLUDE_NMT @@ -1601,6 +1664,7 @@ static JNINativeMethod methods[] = { (void*)&WB_G1AuxiliaryMemoryUsage }, {CC"psVirtualSpaceAlignment",CC"()J", (void*)&WB_PSVirtualSpaceAlignment}, {CC"psHeapGenerationAlignment",CC"()J", (void*)&WB_PSHeapGenerationAlignment}, + {CC"g1GetMixedGCInfo", CC"(I)[J", (void*)&WB_G1GetMixedGCInfo }, #endif // INCLUDE_ALL_GCS #if INCLUDE_NMT {CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc }, -- GitLab From 2d65e6174c3d1ceb7372c67b183f20c2593d3f74 Mon Sep 17 00:00:00 2001 From: Jiangli Zhou Date: Wed, 20 Apr 2016 16:04:38 -0400 Subject: [PATCH 167/400] 8154457: runtime/SharedArchiveFile/SharedStrings Shared string table stats missing Added more information when print out message reporting disabling the shared strings at CDS dump time. Reviewed-by: lfoltan, hseigel, mseledtsov, gtriantafill --- .../src/share/vm/classfile/stringTable.cpp | 8 ++- .../SharedArchiveFile/SharedStrings.java | 54 ++++++++++++------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/hotspot/src/share/vm/classfile/stringTable.cpp b/hotspot/src/share/vm/classfile/stringTable.cpp index 2e10bae9b0a..5031a9c0d70 100644 --- a/hotspot/src/share/vm/classfile/stringTable.cpp +++ b/hotspot/src/share/vm/classfile/stringTable.cpp @@ -730,8 +730,12 @@ void StringTable::serialize(SerializeClosure* soc, GrowableArray *str if (soc->writing()) { if (!(UseG1GC && UseCompressedOops && UseCompressedClassPointers)) { if (PrintSharedSpaces) { - tty->print_cr("Shared strings are excluded from the archive as UseG1GC, " - "UseCompressedOops and UseCompressedClassPointers are required."); + tty->print_cr( + "Shared strings are excluded from the archive as UseG1GC, " + "UseCompressedOops and UseCompressedClassPointers are required." + "Current settings: UseG1GC=%s, UseCompressedOops=%s, UseCompressedClassPointers=%s.", + BOOL_TO_STR(UseG1GC), BOOL_TO_STR(UseCompressedOops), + BOOL_TO_STR(UseCompressedClassPointers)); } } else { int num_buckets = the_table()->number_of_entries() / diff --git a/hotspot/test/runtime/SharedArchiveFile/SharedStrings.java b/hotspot/test/runtime/SharedArchiveFile/SharedStrings.java index ed2b3e3dbc5..ec7bf3aaa1f 100644 --- a/hotspot/test/runtime/SharedArchiveFile/SharedStrings.java +++ b/hotspot/test/runtime/SharedArchiveFile/SharedStrings.java @@ -40,37 +40,51 @@ import jdk.test.lib.*; public class SharedStrings { public static void main(String[] args) throws Exception { + boolean test_runtime = true; ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./SharedStrings.jsa", + "-XX:+UseG1GC", + "-XX:+UseCompressedOops", "-XX:+PrintSharedSpaces", // Needed for bootclasspath match, for CDS to work with WhiteBox API "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"), "-Xshare:dump"); - new OutputAnalyzer(pb.start()) - .shouldContain("Loading classes to share") - .shouldContain("Shared string table stats") - .shouldHaveExitValue(0); + OutputAnalyzer dumpOutput = new OutputAnalyzer(pb.start()); + try { + dumpOutput.shouldContain("Loading classes to share"); + dumpOutput.shouldContain("Shared string table stats"); + dumpOutput.shouldHaveExitValue(0); + } catch (RuntimeException e) { + if (dumpOutput.getOutput().indexOf("Shared strings are excluded") != -1 || + dumpOutput.getOutput().indexOf("Cannot dump shared archive") != -1) { + test_runtime = false; + } else { + throw new RuntimeException("Unexpected failure"); + } + } - pb = ProcessTools.createJavaProcessBuilder( - "-XX:+UnlockDiagnosticVMOptions", - "-XX:SharedArchiveFile=./SharedStrings.jsa", - // these are required modes for shared strings - "-XX:+UseCompressedOops", "-XX:+UseG1GC", - // needed for access to white box test API - "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"), - "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", - "-Xshare:on", "-showversion", "SharedStringsWb"); + if (test_runtime) { + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UnlockDiagnosticVMOptions", + "-XX:SharedArchiveFile=./SharedStrings.jsa", + // these are required modes for shared strings + "-XX:+UseCompressedOops", "-XX:+UseG1GC", + // needed for access to white box test API + "-Xbootclasspath/a:" + ClassFileInstaller.getJarPath("whitebox.jar"), + "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", + "-Xshare:on", "-showversion", "SharedStringsWb"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); - try { - output.shouldContain("sharing"); - output.shouldHaveExitValue(0); - } catch (RuntimeException e) { - output.shouldContain("Unable to use shared archive"); - output.shouldHaveExitValue(1); + try { + output.shouldContain("sharing"); + output.shouldHaveExitValue(0); + } catch (RuntimeException e) { + output.shouldContain("Unable to use shared archive"); + output.shouldHaveExitValue(1); + } } } } -- GitLab From fdd7fde7402b9b222e21ae30fa1d62324d515e95 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Thu, 21 Apr 2016 09:08:33 +0200 Subject: [PATCH 168/400] 8053885: test/runtime/memory/RunUnitTestsConcurrently.java fails on solaris with largepage options Reviewed-by: jmasa, pliden --- hotspot/src/share/vm/memory/virtualspace.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hotspot/src/share/vm/memory/virtualspace.cpp b/hotspot/src/share/vm/memory/virtualspace.cpp index 9b188f272e6..3cb6d21c7e8 100644 --- a/hotspot/src/share/vm/memory/virtualspace.cpp +++ b/hotspot/src/share/vm/memory/virtualspace.cpp @@ -1083,6 +1083,12 @@ class TestReservedSpace : AllStatic { test_log("test_reserved_space3(%p, %p, %d)", (void*)(uintptr_t)size, (void*)(uintptr_t)alignment, maybe_large); + if (size < alignment) { + // Tests might set -XX:LargePageSizeInBytes= and cause unexpected input arguments for this test. + assert((size_t)os::vm_page_size() == os::large_page_size(), "Test needs further refinement"); + return; + } + assert(is_size_aligned(size, os::vm_allocation_granularity()), "Must be at least AG aligned"); assert(is_size_aligned(size, alignment), "Must be at least aligned against alignment"); -- GitLab From 39b43a87e7290759fa8923b11d98c1def4ed20cc Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Thu, 21 Apr 2016 10:18:50 +0200 Subject: [PATCH 169/400] 8154467: Cleanup initialization of GCPolicyCounters Reviewed-by: ehelin, sjohanss --- .../src/share/vm/gc/g1/g1CollectorPolicy.cpp | 4 ---- .../src/share/vm/gc/g1/g1CollectorPolicy.hpp | 2 -- hotspot/src/share/vm/gc/g1/g1Policy.cpp | 6 ++---- hotspot/src/share/vm/gc/g1/g1Policy.hpp | 3 +++ .../share/vm/gc/parallel/generationSizer.hpp | 6 ++++++ .../share/vm/gc/serial/defNewGeneration.cpp | 4 ++-- .../share/vm/gc/shared/collectorPolicy.hpp | 19 ++++++++----------- 7 files changed, 21 insertions(+), 23 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp index 30e01594668..780753866d5 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp @@ -103,7 +103,3 @@ void G1CollectorPolicy::initialize_flags() { CollectorPolicy::initialize_flags(); } -// Create the jstat counters for the policy. -void G1CollectorPolicy::initialize_gc_policy_counters() { - _gc_policy_counters = new GCPolicyCounters("GarbageFirst", 1, 3); -} diff --git a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp index 3203770eab2..a21fb7201ab 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp @@ -44,8 +44,6 @@ public: void post_heap_initialize() {} // Nothing needed. - // Create jstat counters for the policy. - virtual void initialize_gc_policy_counters(); }; #endif // SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.cpp b/hotspot/src/share/vm/gc/g1/g1Policy.cpp index 135a626cf46..a16464216ef 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1Policy.cpp @@ -52,6 +52,7 @@ G1Policy::G1Policy() : _bytes_allocated_in_old_since_last_gc(0), _ihop_control(NULL), + _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 3)), _initial_mark_to_mixed() { // SurvRateGroups below must be initialized after the predictor because they @@ -92,8 +93,6 @@ void G1Policy::init() { assert(Heap_lock->owned_by_self(), "Locking discipline."); - _g1->collector_policy()->initialize_gc_policy_counters(); - if (adaptive_young_list_length()) { _young_list_fixed_length = 0; } else { @@ -970,9 +969,8 @@ void G1Policy::update_survivors_policy() { // smaller than 1.0) we'll get 1. _max_survivor_regions = (uint) ceil(max_survivor_regions_d); - GCPolicyCounters* counters = _g1->collector_policy()->counters(); _tenuring_threshold = _survivors_age_table.compute_tenuring_threshold( - HeapRegion::GrainWords * _max_survivor_regions, counters); + HeapRegion::GrainWords * _max_survivor_regions, _policy_counters); } bool G1Policy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) { diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.hpp b/hotspot/src/share/vm/gc/g1/g1Policy.hpp index 9bbf22ab669..865a8b371bc 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp @@ -46,6 +46,7 @@ class CollectionSetChooser; class G1IHOPControl; class G1Analytics; class G1YoungGenSizer; +class GCPolicyCounters; class G1Policy: public CHeapObj { private: @@ -62,6 +63,8 @@ class G1Policy: public CHeapObj { G1Analytics* _analytics; G1MMUTracker* _mmu_tracker; + GCPolicyCounters* _policy_counters; + double _full_collection_start_sec; uint _young_list_target_length; diff --git a/hotspot/src/share/vm/gc/parallel/generationSizer.hpp b/hotspot/src/share/vm/gc/parallel/generationSizer.hpp index 539629b1c96..558476049b7 100644 --- a/hotspot/src/share/vm/gc/parallel/generationSizer.hpp +++ b/hotspot/src/share/vm/gc/parallel/generationSizer.hpp @@ -41,5 +41,11 @@ class GenerationSizer : public GenCollectorPolicy { void initialize_alignments(); void initialize_flags(); void initialize_size_info(); + + public: + // We don't have associated counters and complain if this is invoked. + void initialize_gc_policy_counters() { + ShouldNotReachHere(); + } }; #endif // SHARE_VM_GC_PARALLEL_GENERATIONSIZER_HPP diff --git a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp index 247c7e3e49a..c8d3e0f3894 100644 --- a/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp +++ b/hotspot/src/share/vm/gc/serial/defNewGeneration.cpp @@ -564,7 +564,7 @@ HeapWord* DefNewGeneration::expand_and_allocate(size_t size, void DefNewGeneration::adjust_desired_tenuring_threshold() { // Set the desired survivor size to half the real survivor space - GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->collector_policy()->counters(); + GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->gen_policy()->counters(); _tenuring_threshold = age_table()->compute_tenuring_threshold(to()->capacity()/HeapWordSize, gc_counters); } @@ -945,7 +945,7 @@ void DefNewGeneration::gc_epilogue(bool full) { // update the generation and space performance counters update_counters(); - gch->collector_policy()->counters()->update_counters(); + gch->gen_policy()->counters()->update_counters(); } void DefNewGeneration::record_spaces_top() { diff --git a/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp b/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp index 82ac817d70b..4d0eceef102 100644 --- a/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp +++ b/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp @@ -58,8 +58,6 @@ class MarkSweepPolicy; class CollectorPolicy : public CHeapObj { protected: - GCPolicyCounters* _gc_policy_counters; - virtual void initialize_alignments() = 0; virtual void initialize_flags(); virtual void initialize_size_info(); @@ -149,15 +147,6 @@ class CollectorPolicy : public CHeapObj { size_t size, Metaspace::MetadataType mdtype); - // Performance Counter support - GCPolicyCounters* counters() { return _gc_policy_counters; } - - // Create the jstat counters for the GC policy. By default, policy's - // don't have associated counters, and we complain if this is invoked. - virtual void initialize_gc_policy_counters() { - ShouldNotReachHere(); - } - // Do any updates required to global flags that are due to heap initialization // changes virtual void post_heap_initialize() = 0; @@ -197,6 +186,8 @@ class GenCollectorPolicy : public CollectorPolicy { GenerationSpec* _young_gen_spec; GenerationSpec* _old_gen_spec; + GCPolicyCounters* _gc_policy_counters; + // Return true if an allocation should be attempted in the older generation // if it fails in the younger generation. Return false, otherwise. virtual bool should_try_older_generation_allocation(size_t word_size) const; @@ -243,6 +234,12 @@ class GenCollectorPolicy : public CollectorPolicy { return _old_gen_spec; } + // Performance Counter support + GCPolicyCounters* counters() { return _gc_policy_counters; } + + // Create the jstat counters for the GC policy. + virtual void initialize_gc_policy_counters() = 0; + virtual GenCollectorPolicy* as_generation_policy() { return this; } virtual void initialize_generations() { }; -- GitLab From 7587fbdd304ff1cec8765b2b4379e1ff111a0552 Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Thu, 21 Apr 2016 10:19:00 +0200 Subject: [PATCH 170/400] 8154452: Deferred cleanups after split of G1CollectorPolicy code Reviewed-by: ehelin, sjohanss --- hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp | 1 - hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp | 11 ----------- hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp | 6 ------ hotspot/src/share/vm/gc/g1/heapRegion.cpp | 4 ++++ hotspot/src/share/vm/gc/shared/collectedHeap.cpp | 4 ---- hotspot/src/share/vm/gc/shared/collectedHeap.hpp | 2 +- hotspot/src/share/vm/gc/shared/collectorPolicy.hpp | 11 ----------- hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp | 1 - 8 files changed, 5 insertions(+), 35 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index a4565442247..3671bcd7d14 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -2058,7 +2058,6 @@ size_t G1CollectedHeap::conservative_max_heap_alignment() { } void G1CollectedHeap::post_initialize() { - CollectedHeap::post_initialize(); ref_processing_init(); } diff --git a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp index 780753866d5..2b0eab43225 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp @@ -92,14 +92,3 @@ void G1CollectorPolicy::initialize_alignments() { size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size(); _heap_alignment = MAX3(card_table_alignment, _space_alignment, page_size); } - -void G1CollectorPolicy::initialize_flags() { - if (G1HeapRegionSize != HeapRegion::GrainBytes) { - FLAG_SET_ERGO(size_t, G1HeapRegionSize, HeapRegion::GrainBytes); - } - - guarantee(SurvivorRatio >= 1, "Range checking for SurvivorRatio should guarantee that value is >= 1"); - - CollectorPolicy::initialize_flags(); -} - diff --git a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp index a21fb7201ab..6e58448a342 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.hpp @@ -35,15 +35,9 @@ class G1YoungGenSizer; class G1CollectorPolicy: public CollectorPolicy { protected: void initialize_alignments(); - void initialize_flags(); public: G1CollectorPolicy(); - - G1CollectorPolicy* as_g1_policy() { return this; } - - void post_heap_initialize() {} // Nothing needed. - }; #endif // SHARE_VM_GC_G1_G1COLLECTORPOLICY_HPP diff --git a/hotspot/src/share/vm/gc/g1/heapRegion.cpp b/hotspot/src/share/vm/gc/g1/heapRegion.cpp index 7f1385f29da..141b24789ff 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegion.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegion.cpp @@ -153,6 +153,10 @@ void HeapRegion::setup_heap_region_size(size_t initial_heap_size, size_t max_hea guarantee(CardsPerRegion == 0, "we should only set it once"); CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift; + + if (G1HeapRegionSize != GrainBytes) { + FLAG_SET_ERGO(size_t, G1HeapRegionSize, GrainBytes); + } } void HeapRegion::reset_after_compaction() { diff --git a/hotspot/src/share/vm/gc/shared/collectedHeap.cpp b/hotspot/src/share/vm/gc/shared/collectedHeap.cpp index cfd55ad3dc7..e40326066fe 100644 --- a/hotspot/src/share/vm/gc/shared/collectedHeap.cpp +++ b/hotspot/src/share/vm/gc/shared/collectedHeap.cpp @@ -510,10 +510,6 @@ void CollectedHeap::fill_with_objects(HeapWord* start, size_t words, bool zap) fill_with_object_impl(start, words, zap); } -void CollectedHeap::post_initialize() { - collector_policy()->post_heap_initialize(); -} - HeapWord* CollectedHeap::allocate_new_tlab(size_t size) { guarantee(false, "thread-local allocation buffers not supported"); return NULL; diff --git a/hotspot/src/share/vm/gc/shared/collectedHeap.hpp b/hotspot/src/share/vm/gc/shared/collectedHeap.hpp index 4c0e8d9cb1b..2b2fe90598d 100644 --- a/hotspot/src/share/vm/gc/shared/collectedHeap.hpp +++ b/hotspot/src/share/vm/gc/shared/collectedHeap.hpp @@ -209,7 +209,7 @@ class CollectedHeap : public CHeapObj { // In many heaps, there will be a need to perform some initialization activities // after the Universe is fully formed, but before general heap allocation is allowed. // This is the correct place to place such initialization methods. - virtual void post_initialize(); + virtual void post_initialize() = 0; // Stop any onging concurrent work and prepare for exit. virtual void stop() {} diff --git a/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp b/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp index 4d0eceef102..8c9b65e4848 100644 --- a/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp +++ b/hotspot/src/share/vm/gc/shared/collectorPolicy.hpp @@ -127,17 +127,14 @@ class CollectorPolicy : public CHeapObj { virtual MarkSweepPolicy* as_mark_sweep_policy() { return NULL; } #if INCLUDE_ALL_GCS virtual ConcurrentMarkSweepPolicy* as_concurrent_mark_sweep_policy() { return NULL; } - virtual G1CollectorPolicy* as_g1_policy() { return NULL; } #endif // INCLUDE_ALL_GCS // Note that these are not virtual. bool is_generation_policy() { return as_generation_policy() != NULL; } bool is_mark_sweep_policy() { return as_mark_sweep_policy() != NULL; } #if INCLUDE_ALL_GCS bool is_concurrent_mark_sweep_policy() { return as_concurrent_mark_sweep_policy() != NULL; } - bool is_g1_policy() { return as_g1_policy() != NULL; } #else // INCLUDE_ALL_GCS bool is_concurrent_mark_sweep_policy() { return false; } - bool is_g1_policy() { return false; } #endif // INCLUDE_ALL_GCS @@ -146,10 +143,6 @@ class CollectorPolicy : public CHeapObj { MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data, size_t size, Metaspace::MetadataType mdtype); - - // Do any updates required to global flags that are due to heap initialization - // changes - virtual void post_heap_initialize() = 0; }; class ClearedAllSoftRefs : public StackObj { @@ -263,10 +256,6 @@ class GenCollectorPolicy : public CollectorPolicy { virtual void initialize_size_policy(size_t init_eden_size, size_t init_promo_size, size_t init_survivor_size); - - virtual void post_heap_initialize() { - assert(_max_young_size == MaxNewSize, "Should be taken care of by initialize_size_info"); - } }; class MarkSweepPolicy : public GenCollectorPolicy { diff --git a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp index c60e3a02092..8faeedec049 100644 --- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp @@ -179,7 +179,6 @@ char* GenCollectedHeap::allocate(size_t alignment, } void GenCollectedHeap::post_initialize() { - CollectedHeap::post_initialize(); ref_processing_init(); assert((_young_gen->kind() == Generation::DefNew) || (_young_gen->kind() == Generation::ParNew), -- GitLab From 91b2afa99de146bc51f66b4289989d6834b78e5a Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Tue, 19 Apr 2016 14:53:32 +0200 Subject: [PATCH 171/400] 8154745: Move default G1 pause time target setup to argument parsing Reviewed-by: ehelin, sjohanss --- .../src/share/vm/gc/g1/g1CollectorPolicy.cpp | 37 ------------------- hotspot/src/share/vm/runtime/arguments.cpp | 22 +++++++++++ .../runtime/commandLineFlagConstraintsGC.cpp | 8 ++++ hotspot/src/share/vm/runtime/globals.hpp | 4 +- 4 files changed, 32 insertions(+), 39 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp index 2b0eab43225..c0288ed133b 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectorPolicy.cpp @@ -47,43 +47,6 @@ G1CollectorPolicy::G1CollectorPolicy() { // unaligned values for the heap. HeapRegion::setup_heap_region_size(InitialHeapSize, MaxHeapSize); HeapRegionRemSet::setup_remset_size(); - - // Below, we might need to calculate the pause time target based on - // the pause interval. When we do so we are going to give G1 maximum - // flexibility and allow it to do pauses when it needs to. So, we'll - // arrange that the pause interval to be pause time target + 1 to - // ensure that a) the pause time target is maximized with respect to - // the pause interval and b) we maintain the invariant that pause - // time target < pause interval. If the user does not want this - // maximum flexibility, they will have to set the pause interval - // explicitly. - - // First make sure that, if either parameter is set, its value is - // reasonable. - guarantee(MaxGCPauseMillis >= 1, "Range checking for MaxGCPauseMillis should guarantee that value is >= 1"); - - // Then, if the pause time target parameter was not set, set it to - // the default value. - if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { - if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) { - // The default pause time target in G1 is 200ms - FLAG_SET_DEFAULT(MaxGCPauseMillis, 200); - } else { - // We do not allow the pause interval to be set without the - // pause time target - vm_exit_during_initialization("GCPauseIntervalMillis cannot be set " - "without setting MaxGCPauseMillis"); - } - } - - // Then, if the interval parameter was not set, set it according to - // the pause time target (this will also deal with the case when the - // pause time target is the default value). - if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) { - FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1); - } - guarantee(GCPauseIntervalMillis >= 1, "Constraint for GCPauseIntervalMillis should guarantee that value is >= 1"); - guarantee(GCPauseIntervalMillis > MaxGCPauseMillis, "Constraint for GCPauseIntervalMillis should guarantee that GCPauseIntervalMillis > MaxGCPauseMillis"); } void G1CollectorPolicy::initialize_alignments() { diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index f0e1b54e15a..a7d926a5dbf 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -2116,6 +2116,28 @@ void Arguments::set_g1_gc_flags() { FLAG_SET_DEFAULT(GCTimeRatio, 12); } + // Below, we might need to calculate the pause time interval based on + // the pause target. When we do so we are going to give G1 maximum + // flexibility and allow it to do pauses when it needs to. So, we'll + // arrange that the pause interval to be pause time target + 1 to + // ensure that a) the pause time target is maximized with respect to + // the pause interval and b) we maintain the invariant that pause + // time target < pause interval. If the user does not want this + // maximum flexibility, they will have to set the pause interval + // explicitly. + + if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { + // The default pause time target in G1 is 200ms + FLAG_SET_DEFAULT(MaxGCPauseMillis, 200); + } + + // Then, if the interval parameter was not set, set it according to + // the pause time target (this will also deal with the case when the + // pause time target is the default value). + if (FLAG_IS_DEFAULT(GCPauseIntervalMillis)) { + FLAG_SET_DEFAULT(GCPauseIntervalMillis, MaxGCPauseMillis + 1); + } + log_trace(gc)("MarkStackSize: %uk MarkStackSizeMax: %uk", (unsigned int) (MarkStackSize / K), (uint) (MarkStackSizeMax / K)); log_trace(gc)("ConcGCThreads: %u", ConcGCThreads); } diff --git a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp index 5dce24113af..39b40389555 100644 --- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp +++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp @@ -599,6 +599,14 @@ Flag::Error GCPauseIntervalMillisConstraintFunc(uintx value, bool verbose) { value); return Flag::VIOLATES_CONSTRAINT; } + + if (FLAG_IS_DEFAULT(MaxGCPauseMillis)) { + CommandLineError::print(verbose, + "GCPauseIntervalMillis cannot be set " + "without setting MaxGCPauseMillis\n"); + return Flag::VIOLATES_CONSTRAINT; + } + if (value <= MaxGCPauseMillis) { CommandLineError::print(verbose, "GCPauseIntervalMillis (" UINTX_FORMAT ") must be " diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index fe2d2e615f0..0261f66aa69 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -2221,11 +2221,11 @@ public: "Adaptive size policy maximum GC pause time goal in millisecond, "\ "or (G1 Only) the maximum GC time per MMU time slice") \ range(1, max_uintx - 1) \ - constraint(MaxGCPauseMillisConstraintFunc,AfterMemoryInit) \ + constraint(MaxGCPauseMillisConstraintFunc,AfterErgo) \ \ product(uintx, GCPauseIntervalMillis, 0, \ "Time slice for MMU specification") \ - constraint(GCPauseIntervalMillisConstraintFunc,AfterMemoryInit) \ + constraint(GCPauseIntervalMillisConstraintFunc,AfterErgo) \ \ product(uintx, MaxGCMinorPauseMillis, max_uintx, \ "Adaptive size policy maximum GC minor pause time goal " \ -- GitLab From 4adb7c07880e967b97570b6e46c82b9ea4cc32be Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Tue, 19 Apr 2016 14:53:33 +0200 Subject: [PATCH 172/400] 8154752: Cleanup initialization of G1Policy Reviewed-by: ehelin, tschatzl --- .../src/share/vm/gc/g1/g1CollectedHeap.cpp | 2 +- hotspot/src/share/vm/gc/g1/g1Policy.cpp | 62 +++++++------------ hotspot/src/share/vm/gc/g1/g1Policy.hpp | 12 ++-- 3 files changed, 29 insertions(+), 47 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index 3671bcd7d14..d88d15e46bb 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -1989,7 +1989,7 @@ jint G1CollectedHeap::initialize() { } // Perform any initialization actions delegated to the policy. - g1_policy()->init(); + g1_policy()->init(this, &_collection_set); JavaThread::satb_mark_queue_set().initialize(SATB_Q_CBL_mon, SATB_Q_FL_lock, diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.cpp b/hotspot/src/share/vm/gc/g1/g1Policy.cpp index a16464216ef..e58d97a2e9e 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1Policy.cpp @@ -45,40 +45,23 @@ G1Policy::G1Policy() : _predictor(G1ConfidencePercent / 100.0), _analytics(new G1Analytics(&_predictor)), - _pause_time_target_ms((double) MaxGCPauseMillis), + _mmu_tracker(new G1MMUTrackerQueue(GCPauseIntervalMillis / 1000.0, MaxGCPauseMillis / 1000.0)), + _ihop_control(create_ihop_control(&_predictor)), + _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 3)), + _young_list_fixed_length(0), + _short_lived_surv_rate_group(new SurvRateGroup(&_predictor, "Short Lived", G1YoungSurvRateNumRegionsSummary)), + _survivor_surv_rate_group(new SurvRateGroup(&_predictor, "Survivor", G1YoungSurvRateNumRegionsSummary)), + _reserve_factor((double) G1ReservePercent / 100.0), + _reserve_regions(0), _rs_lengths_prediction(0), - _max_survivor_regions(0), - _survivors_age_table(true), - _bytes_allocated_in_old_since_last_gc(0), - _ihop_control(NULL), - _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 3)), - _initial_mark_to_mixed() { - - // SurvRateGroups below must be initialized after the predictor because they - // indirectly use it through this object passed to their constructor. - _short_lived_surv_rate_group = - new SurvRateGroup(&_predictor, "Short Lived", G1YoungSurvRateNumRegionsSummary); - _survivor_surv_rate_group = - new SurvRateGroup(&_predictor, "Survivor", G1YoungSurvRateNumRegionsSummary); - - _phase_times = new G1GCPhaseTimes(ParallelGCThreads); - - double max_gc_time = (double) MaxGCPauseMillis / 1000.0; - double time_slice = (double) GCPauseIntervalMillis / 1000.0; - _mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time); - - _tenuring_threshold = MaxTenuringThreshold; - - - guarantee(G1ReservePercent <= 50, "Range checking should not allow values over 50."); - _reserve_factor = (double) G1ReservePercent / 100.0; - // This will be set when the heap is expanded - // for the first time during initialization. - _reserve_regions = 0; - - _ihop_control = create_ihop_control(); -} + _initial_mark_to_mixed(), + _collection_set(NULL), + _g1(NULL), + _phase_times(new G1GCPhaseTimes(ParallelGCThreads)), + _tenuring_threshold(MaxTenuringThreshold), + _max_survivor_regions(0), + _survivors_age_table(true) { } G1Policy::~G1Policy() { delete _ihop_control; @@ -86,16 +69,13 @@ G1Policy::~G1Policy() { G1CollectorState* G1Policy::collector_state() const { return _g1->collector_state(); } -void G1Policy::init() { - // Set aside an initial future to_space. - _g1 = G1CollectedHeap::heap(); - _collection_set = _g1->collection_set(); +void G1Policy::init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) { + _g1 = g1h; + _collection_set = collection_set; assert(Heap_lock->owned_by_self(), "Locking discipline."); - if (adaptive_young_list_length()) { - _young_list_fixed_length = 0; - } else { + if (!adaptive_young_list_length()) { _young_list_fixed_length = _young_gen_sizer.min_desired_young_length(); } _young_gen_sizer.adjust_max_new_size(_g1->max_regions()); @@ -798,10 +778,10 @@ void G1Policy::record_collection_pause_end(double pause_time_ms, size_t cards_sc cset_chooser()->verify(); } -G1IHOPControl* G1Policy::create_ihop_control() const { +G1IHOPControl* G1Policy::create_ihop_control(const G1Predictions* predictor){ if (G1UseAdaptiveIHOP) { return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent, - &_predictor, + predictor, G1ReservePercent, G1HeapWastePercent); } else { diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.hpp b/hotspot/src/share/vm/gc/g1/g1Policy.hpp index 865a8b371bc..73b51e92d20 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp @@ -50,9 +50,8 @@ class GCPolicyCounters; class G1Policy: public CHeapObj { private: - G1IHOPControl* _ihop_control; - G1IHOPControl* create_ihop_control() const; + static G1IHOPControl* create_ihop_control(const G1Predictions* predictor); // Update the IHOP control with necessary statistics. void update_ihop_prediction(double mutator_time_s, size_t mutator_alloc_bytes, @@ -62,6 +61,7 @@ class G1Policy: public CHeapObj { G1Predictions _predictor; G1Analytics* _analytics; G1MMUTracker* _mmu_tracker; + G1IHOPControl* _ihop_control; GCPolicyCounters* _policy_counters; @@ -74,10 +74,14 @@ class G1Policy: public CHeapObj { // locker is active. This should be >= _young_list_target_length; uint _young_list_max_length; + // SurvRateGroups below must be initialized after the predictor because they + // indirectly use it through this object passed to their constructor. SurvRateGroup* _short_lived_surv_rate_group; SurvRateGroup* _survivor_surv_rate_group; double _reserve_factor; + // This will be set when the heap is expanded + // for the first time during initialization. uint _reserve_regions; G1YoungGenSizer _young_gen_sizer; @@ -92,8 +96,6 @@ class G1Policy: public CHeapObj { bool verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group); #endif // PRODUCT - double _pause_time_target_ms; - size_t _pending_cards; // The amount of allocated bytes in old gen during the last mutator and the following @@ -299,7 +301,7 @@ public: // This should be called after the heap is resized. void record_new_heap_size(uint new_number_of_regions); - void init(); + void init(G1CollectedHeap* g1h, G1CollectionSet* collection_set); virtual void note_gc_start(); -- GitLab From c791bde668e47b793e26a1cbcdd783256e05dbb4 Mon Sep 17 00:00:00 2001 From: Mikhailo Seledtsov Date: Tue, 19 Apr 2016 15:11:23 -0700 Subject: [PATCH 173/400] 8153549: [TESTBUG] remove obsolete runtime/SharedArchiveFile/BasicJarBuilder Removed the obsolete file, after ensuring no other jdk components depend on it Reviewed-by: iklam, lfoltan, hseigel, gtriantafill, ctornqvi --- .../SharedArchiveFile/BasicJarBuilder.java | 96 ------------------- 1 file changed, 96 deletions(-) delete mode 100644 hotspot/test/runtime/SharedArchiveFile/BasicJarBuilder.java diff --git a/hotspot/test/runtime/SharedArchiveFile/BasicJarBuilder.java b/hotspot/test/runtime/SharedArchiveFile/BasicJarBuilder.java deleted file mode 100644 index ab8955cb0f7..00000000000 --- a/hotspot/test/runtime/SharedArchiveFile/BasicJarBuilder.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * @summary Simple jar builder - * Input: jarName className1 className2 ... - * do not specify extensions, just the names - * E.g. prot_domain ProtDomainA ProtDomainB - * Output: A jar containing compiled classes, placed in a test classes folder - */ - -import jdk.test.lib.*; - -import java.io.File; -import java.util.ArrayList; -import sun.tools.jar.Main; - -// Using JarBuilder requires that all to-be-jarred classes should be placed -// in the current working directory, aka "." -public class BasicJarBuilder { - private static final String classDir = System.getProperty("test.classes"); - - public static void build(boolean classesInWorkDir, String jarName, - String ...classNames) throws Exception { - - if (classesInWorkDir) { - createSimpleJar(".", classDir + File.separator + jarName + ".jar", classNames); - } else { - build(jarName, classNames); - } - } - - public static void build(String jarName, String ...classNames) throws Exception { - createSimpleJar(classDir, classDir + File.separator + jarName + ".jar", - classNames); - } - - private static void createSimpleJar(String jarclassDir, String jarName, - String[] classNames) throws Exception { - ArrayList args = new ArrayList(); - args.add("cf"); - args.add(jarName); - addClassArgs(args, jarclassDir, classNames); - createJar(args); - } - - private static void addClassArgs(ArrayList args, String jarclassDir, - String[] classNames) { - - for (String name : classNames) { - args.add("-C"); - args.add(jarclassDir); - args.add(name + ".class"); - } - } - - private static void createJar(ArrayList args) { - Main jarTool = new Main(System.out, System.err, "jar"); - if (!jarTool.run(args.toArray(new String[1]))) { - throw new RuntimeException("jar operation failed"); - } - } - - // Get full path to the test jar - public static String getTestJar(String jar) { - File dir = new File(System.getProperty("test.classes", ".")); - File jarFile = new File(dir, jar); - if (!jarFile.exists()) { - throw new RuntimeException("Cannot find " + jarFile.getPath()); - } - if (!jarFile.isFile()) { - throw new RuntimeException("Not a regular file: " + jarFile.getPath()); - } - return jarFile.getPath(); - } -} -- GitLab From 794bbd1a3600e0cd2e0f7cfcbe415c7e60c8dd2f Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Tue, 19 Apr 2016 19:52:39 -0700 Subject: [PATCH 174/400] 8154537: AArch64: some integer rotate instructions are never emitted Reviewed-by: aph, adinn, kvn --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 8 +++---- .../codegen/IntRotateWithImmediate.java | 24 +++++++++++++++---- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index 3f15e6abf8f..c2742a49e1e 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -12078,21 +12078,21 @@ instruct rorL_rReg_Var_C0(iRegLNoSp dst, iRegL src, iRegI shift, immI0 c0, rFlag %} %} -instruct rorI_rReg_Var_C_32(iRegLNoSp dst, iRegL src, iRegI shift, immI_32 c_32, rFlagsReg cr) +instruct rorI_rReg_Var_C_32(iRegINoSp dst, iRegI src, iRegI shift, immI_32 c_32, rFlagsReg cr) %{ match(Set dst (OrI (URShiftI src shift) (LShiftI src (SubI c_32 shift)))); expand %{ - rorL_rReg(dst, src, shift, cr); + rorI_rReg(dst, src, shift, cr); %} %} -instruct rorI_rReg_Var_C0(iRegLNoSp dst, iRegL src, iRegI shift, immI0 c0, rFlagsReg cr) +instruct rorI_rReg_Var_C0(iRegINoSp dst, iRegI src, iRegI shift, immI0 c0, rFlagsReg cr) %{ match(Set dst (OrI (URShiftI src shift) (LShiftI src (SubI c0 shift)))); expand %{ - rorL_rReg(dst, src, shift, cr); + rorI_rReg(dst, src, shift, cr); %} %} diff --git a/hotspot/test/compiler/codegen/IntRotateWithImmediate.java b/hotspot/test/compiler/codegen/IntRotateWithImmediate.java index e174de699e8..3da2aec0afa 100644 --- a/hotspot/test/compiler/codegen/IntRotateWithImmediate.java +++ b/hotspot/test/compiler/codegen/IntRotateWithImmediate.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2015 SAP SE. All rights reserved. + * Copyright (c) 2016, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +25,7 @@ /* * @test * @bug 8080190 + * @bug 8154537 * @key regression * @summary Test that the rotate distance used in the rotate instruction is properly masked with 0x1f * @run main/othervm -Xbatch -XX:-UseOnStackReplacement IntRotateWithImmediate @@ -33,7 +35,7 @@ public class IntRotateWithImmediate { // This is currently the same as Integer.rotateRight() - static int rotateRight(int i, int distance) { + static int rotateRight1(int i, int distance) { // On some architectures (i.e. x86_64 and ppc64) the following computation is // matched in the .ad file into a single MachNode which emmits a single rotate // machine instruction. It is important that the shift amount is masked to match @@ -43,17 +45,29 @@ public class IntRotateWithImmediate { return ((i >>> distance) | (i << -distance)); } - static int compute(int x) { - return rotateRight(x, 3); + static int rotateRight2(int i, int distance) { + return ((i >>> distance) | (i << (32-distance))); + } + + static int compute1(int x) { + return rotateRight1(x, 3); + } + + static int compute2(int x) { + return rotateRight2(x, 3); } public static void main(String args[]) { int val = 4096; - int firstResult = compute(val); + int firstResult = compute1(val); for (int i = 0; i < 100000; i++) { - int newResult = compute(val); + int newResult = compute1(val); + if (firstResult != newResult) { + throw new InternalError(firstResult + " != " + newResult); + } + newResult = compute2(val); if (firstResult != newResult) { throw new InternalError(firstResult + " != " + newResult); } -- GitLab From 63484cce64f3bb9383ba2dfe3bc32a06e0fec7c2 Mon Sep 17 00:00:00 2001 From: Erik Helin Date: Wed, 20 Apr 2016 15:24:18 +0200 Subject: [PATCH 175/400] 8154753: Turn G1Policy into an interface Reviewed-by: sjohanss, mgerdin --- .../share/vm/gc/g1/g1CollectedHeap_ext.cpp | 3 +- .../g1/{g1Policy.cpp => g1DefaultPolicy.cpp} | 147 +++--- .../src/share/vm/gc/g1/g1DefaultPolicy.hpp | 440 ++++++++++++++++++ hotspot/src/share/vm/gc/g1/g1Policy.hpp | 372 +++------------ 4 files changed, 575 insertions(+), 387 deletions(-) rename hotspot/src/share/vm/gc/g1/{g1Policy.cpp => g1DefaultPolicy.cpp} (89%) create mode 100644 hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp index a58901f32a8..29766047edd 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc/g1/g1CollectedHeap.hpp" +#include "gc/g1/g1DefaultPolicy.hpp" #include "gc/g1/g1ParScanThreadState.hpp" #include "gc/g1/heapRegion.inline.hpp" @@ -40,5 +41,5 @@ HeapRegion* G1CollectedHeap::new_heap_region(uint hrs_index, } G1Policy* G1CollectedHeap::create_g1_policy() { - return new G1Policy; + return new G1DefaultPolicy(); } diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp similarity index 89% rename from hotspot/src/share/vm/gc/g1/g1Policy.cpp rename to hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index e58d97a2e9e..e34d023326d 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -29,6 +29,7 @@ #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectionSet.hpp" #include "gc/g1/g1ConcurrentMark.hpp" +#include "gc/g1/g1DefaultPolicy.hpp" #include "gc/g1/g1IHOPControl.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1Policy.hpp" @@ -42,7 +43,7 @@ #include "utilities/debug.hpp" #include "utilities/pair.hpp" -G1Policy::G1Policy() : +G1DefaultPolicy::G1DefaultPolicy() : _predictor(G1ConfidencePercent / 100.0), _analytics(new G1Analytics(&_predictor)), _mmu_tracker(new G1MMUTrackerQueue(GCPauseIntervalMillis / 1000.0, MaxGCPauseMillis / 1000.0)), @@ -63,13 +64,13 @@ G1Policy::G1Policy() : _max_survivor_regions(0), _survivors_age_table(true) { } -G1Policy::~G1Policy() { +G1DefaultPolicy::~G1DefaultPolicy() { delete _ihop_control; } -G1CollectorState* G1Policy::collector_state() const { return _g1->collector_state(); } +G1CollectorState* G1DefaultPolicy::collector_state() const { return _g1->collector_state(); } -void G1Policy::init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) { +void G1DefaultPolicy::init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) { _g1 = g1h; _collection_set = collection_set; @@ -88,14 +89,14 @@ void G1Policy::init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) { _collection_set->start_incremental_building(); } -void G1Policy::note_gc_start() { +void G1DefaultPolicy::note_gc_start() { phase_times()->note_gc_start(); } -bool G1Policy::predict_will_fit(uint young_length, - double base_time_ms, - uint base_free_regions, - double target_pause_time_ms) const { +bool G1DefaultPolicy::predict_will_fit(uint young_length, + double base_time_ms, + uint base_free_regions, + double target_pause_time_ms) const { if (young_length >= base_free_regions) { // end condition 1: not enough space for the young regions return false; @@ -134,7 +135,7 @@ bool G1Policy::predict_will_fit(uint young_length, return true; } -void G1Policy::record_new_heap_size(uint new_number_of_regions) { +void G1DefaultPolicy::record_new_heap_size(uint new_number_of_regions) { // re-calculate the necessary reserve double reserve_regions_d = (double) new_number_of_regions * _reserve_factor; // We use ceiling so that if reserve_regions_d is > 0.0 (but @@ -146,7 +147,7 @@ void G1Policy::record_new_heap_size(uint new_number_of_regions) { _ihop_control->update_target_occupancy(new_number_of_regions * HeapRegion::GrainBytes); } -uint G1Policy::calculate_young_list_desired_min_length(uint base_min_length) const { +uint G1DefaultPolicy::calculate_young_list_desired_min_length(uint base_min_length) const { uint desired_min_length = 0; if (adaptive_young_list_length()) { if (_analytics->num_alloc_rate_ms() > 3) { @@ -163,30 +164,30 @@ uint G1Policy::calculate_young_list_desired_min_length(uint base_min_length) con return MAX2(_young_gen_sizer.min_desired_young_length(), desired_min_length); } -uint G1Policy::calculate_young_list_desired_max_length() const { +uint G1DefaultPolicy::calculate_young_list_desired_max_length() const { // Here, we might want to also take into account any additional // constraints (i.e., user-defined minimum bound). Currently, we // effectively don't set this bound. return _young_gen_sizer.max_desired_young_length(); } -uint G1Policy::update_young_list_max_and_target_length() { +uint G1DefaultPolicy::update_young_list_max_and_target_length() { return update_young_list_max_and_target_length(_analytics->predict_rs_lengths()); } -uint G1Policy::update_young_list_max_and_target_length(size_t rs_lengths) { +uint G1DefaultPolicy::update_young_list_max_and_target_length(size_t rs_lengths) { uint unbounded_target_length = update_young_list_target_length(rs_lengths); update_max_gc_locker_expansion(); return unbounded_target_length; } -uint G1Policy::update_young_list_target_length(size_t rs_lengths) { +uint G1DefaultPolicy::update_young_list_target_length(size_t rs_lengths) { YoungTargetLengths young_lengths = young_list_target_lengths(rs_lengths); _young_list_target_length = young_lengths.first; return young_lengths.second; } -G1Policy::YoungTargetLengths G1Policy::young_list_target_lengths(size_t rs_lengths) const { +G1DefaultPolicy::YoungTargetLengths G1DefaultPolicy::young_list_target_lengths(size_t rs_lengths) const { YoungTargetLengths result; // Calculate the absolute and desired min bounds first. @@ -252,10 +253,10 @@ G1Policy::YoungTargetLengths G1Policy::young_list_target_lengths(size_t rs_lengt } uint -G1Policy::calculate_young_list_target_length(size_t rs_lengths, - uint base_min_length, - uint desired_min_length, - uint desired_max_length) const { +G1DefaultPolicy::calculate_young_list_target_length(size_t rs_lengths, + uint base_min_length, + uint desired_min_length, + uint desired_max_length) const { assert(adaptive_young_list_length(), "pre-condition"); assert(collector_state()->gcs_are_young(), "only call this for young GCs"); @@ -355,7 +356,7 @@ G1Policy::calculate_young_list_target_length(size_t rs_lengths, return base_min_length + min_young_length; } -double G1Policy::predict_survivor_regions_evac_time() const { +double G1DefaultPolicy::predict_survivor_regions_evac_time() const { double survivor_regions_evac_time = 0.0; for (HeapRegion * r = _g1->young_list()->first_survivor_region(); r != NULL && r != _g1->young_list()->last_survivor_region()->get_next_young_region(); @@ -365,7 +366,7 @@ double G1Policy::predict_survivor_regions_evac_time() const { return survivor_regions_evac_time; } -void G1Policy::revise_young_list_target_length_if_necessary(size_t rs_lengths) { +void G1DefaultPolicy::revise_young_list_target_length_if_necessary(size_t rs_lengths) { guarantee( adaptive_young_list_length(), "should not call this otherwise" ); if (rs_lengths > _rs_lengths_prediction) { @@ -377,25 +378,25 @@ void G1Policy::revise_young_list_target_length_if_necessary(size_t rs_lengths) { } } -void G1Policy::update_rs_lengths_prediction() { +void G1DefaultPolicy::update_rs_lengths_prediction() { update_rs_lengths_prediction(_analytics->predict_rs_lengths()); } -void G1Policy::update_rs_lengths_prediction(size_t prediction) { +void G1DefaultPolicy::update_rs_lengths_prediction(size_t prediction) { if (collector_state()->gcs_are_young() && adaptive_young_list_length()) { _rs_lengths_prediction = prediction; } } #ifndef PRODUCT -bool G1Policy::verify_young_ages() { +bool G1DefaultPolicy::verify_young_ages() { HeapRegion* head = _g1->young_list()->first_region(); return verify_young_ages(head, _short_lived_surv_rate_group); // also call verify_young_ages on any additional surv rate groups } -bool G1Policy::verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group) { +bool G1DefaultPolicy::verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group) { guarantee( surv_rate_group != NULL, "pre-condition" ); const char* name = surv_rate_group->name(); @@ -431,13 +432,13 @@ bool G1Policy::verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_grou } #endif // PRODUCT -void G1Policy::record_full_collection_start() { +void G1DefaultPolicy::record_full_collection_start() { _full_collection_start_sec = os::elapsedTime(); // Release the future to-space so that it is available for compaction into. collector_state()->set_full_collection(true); } -void G1Policy::record_full_collection_end() { +void G1DefaultPolicy::record_full_collection_end() { // Consider this like a collection pause for the purposes of allocation // since last pause. double end_sec = os::elapsedTime(); @@ -472,7 +473,7 @@ void G1Policy::record_full_collection_end() { record_pause(FullGC, _full_collection_start_sec, end_sec); } -void G1Policy::record_collection_pause_start(double start_time_sec) { +void G1DefaultPolicy::record_collection_pause_start(double start_time_sec) { // We only need to do this here as the policy will only be applied // to the GC we're about to start. so, no point is calculating this // every time we calculate / recalculate the target young length. @@ -497,18 +498,18 @@ void G1Policy::record_collection_pause_start(double start_time_sec) { assert( verify_young_ages(), "region age verification" ); } -void G1Policy::record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) { +void G1DefaultPolicy::record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) { collector_state()->set_during_marking(true); assert(!collector_state()->initiate_conc_mark_if_possible(), "we should have cleared it by now"); collector_state()->set_during_initial_mark_pause(false); } -void G1Policy::record_concurrent_mark_remark_start() { +void G1DefaultPolicy::record_concurrent_mark_remark_start() { _mark_remark_start_sec = os::elapsedTime(); collector_state()->set_during_marking(false); } -void G1Policy::record_concurrent_mark_remark_end() { +void G1DefaultPolicy::record_concurrent_mark_remark_end() { double end_time_sec = os::elapsedTime(); double elapsed_time_ms = (end_time_sec - _mark_remark_start_sec)*1000.0; _analytics->report_concurrent_mark_remark_times_ms(elapsed_time_ms); @@ -517,11 +518,11 @@ void G1Policy::record_concurrent_mark_remark_end() { record_pause(Remark, _mark_remark_start_sec, end_time_sec); } -void G1Policy::record_concurrent_mark_cleanup_start() { +void G1DefaultPolicy::record_concurrent_mark_cleanup_start() { _mark_cleanup_start_sec = os::elapsedTime(); } -void G1Policy::record_concurrent_mark_cleanup_completed() { +void G1DefaultPolicy::record_concurrent_mark_cleanup_completed() { bool should_continue_with_reclaim = next_gc_should_be_mixed("request last young-only gc", "skip last young-only gc"); collector_state()->set_last_young_gc(should_continue_with_reclaim); @@ -532,22 +533,22 @@ void G1Policy::record_concurrent_mark_cleanup_completed() { collector_state()->set_in_marking_window(false); } -double G1Policy::average_time_ms(G1GCPhaseTimes::GCParPhases phase) const { +double G1DefaultPolicy::average_time_ms(G1GCPhaseTimes::GCParPhases phase) const { return phase_times()->average_time_ms(phase); } -double G1Policy::young_other_time_ms() const { +double G1DefaultPolicy::young_other_time_ms() const { return phase_times()->young_cset_choice_time_ms() + phase_times()->young_free_cset_time_ms(); } -double G1Policy::non_young_other_time_ms() const { +double G1DefaultPolicy::non_young_other_time_ms() const { return phase_times()->non_young_cset_choice_time_ms() + phase_times()->non_young_free_cset_time_ms(); } -double G1Policy::other_time_ms(double pause_time_ms) const { +double G1DefaultPolicy::other_time_ms(double pause_time_ms) const { return pause_time_ms - average_time_ms(G1GCPhaseTimes::UpdateRS) - average_time_ms(G1GCPhaseTimes::ScanRS) - @@ -555,19 +556,19 @@ double G1Policy::other_time_ms(double pause_time_ms) const { average_time_ms(G1GCPhaseTimes::Termination); } -double G1Policy::constant_other_time_ms(double pause_time_ms) const { +double G1DefaultPolicy::constant_other_time_ms(double pause_time_ms) const { return other_time_ms(pause_time_ms) - young_other_time_ms() - non_young_other_time_ms(); } -CollectionSetChooser* G1Policy::cset_chooser() const { +CollectionSetChooser* G1DefaultPolicy::cset_chooser() const { return _collection_set->cset_chooser(); } -bool G1Policy::about_to_start_mixed_phase() const { +bool G1DefaultPolicy::about_to_start_mixed_phase() const { return _g1->concurrent_mark()->cmThread()->during_cycle() || collector_state()->last_young_gc(); } -bool G1Policy::need_to_start_conc_mark(const char* source, size_t alloc_word_size) { +bool G1DefaultPolicy::need_to_start_conc_mark(const char* source, size_t alloc_word_size) { if (about_to_start_mixed_phase()) { return false; } @@ -592,7 +593,7 @@ bool G1Policy::need_to_start_conc_mark(const char* source, size_t alloc_word_siz // Anything below that is considered to be zero #define MIN_TIMER_GRANULARITY 0.0000001 -void G1Policy::record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) { +void G1DefaultPolicy::record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) { double end_time_sec = os::elapsedTime(); size_t cur_used_bytes = _g1->used(); @@ -778,7 +779,7 @@ void G1Policy::record_collection_pause_end(double pause_time_ms, size_t cards_sc cset_chooser()->verify(); } -G1IHOPControl* G1Policy::create_ihop_control(const G1Predictions* predictor){ +G1IHOPControl* G1DefaultPolicy::create_ihop_control(const G1Predictions* predictor){ if (G1UseAdaptiveIHOP) { return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent, predictor, @@ -789,7 +790,7 @@ G1IHOPControl* G1Policy::create_ihop_control(const G1Predictions* predictor){ } } -void G1Policy::update_ihop_prediction(double mutator_time_s, +void G1DefaultPolicy::update_ihop_prediction(double mutator_time_s, size_t mutator_alloc_bytes, size_t young_gen_size) { // Always try to update IHOP prediction. Even evacuation failures give information @@ -827,15 +828,15 @@ void G1Policy::update_ihop_prediction(double mutator_time_s, } } -void G1Policy::report_ihop_statistics() { +void G1DefaultPolicy::report_ihop_statistics() { _ihop_control->print(); } -void G1Policy::print_phases() { +void G1DefaultPolicy::print_phases() { phase_times()->print(); } -double G1Policy::predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const { +double G1DefaultPolicy::predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const { TruncatedSeq* seq = surv_rate_group->get_seq(age); guarantee(seq->num() > 0, "There should be some young gen survivor samples available. Tried to access with age %d", age); double pred = _predictor.get_new_prediction(seq); @@ -845,15 +846,15 @@ double G1Policy::predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) c return pred; } -double G1Policy::predict_yg_surv_rate(int age) const { +double G1DefaultPolicy::predict_yg_surv_rate(int age) const { return predict_yg_surv_rate(age, _short_lived_surv_rate_group); } -double G1Policy::accum_yg_surv_rate_pred(int age) const { +double G1DefaultPolicy::accum_yg_surv_rate_pred(int age) const { return _short_lived_surv_rate_group->accum_surv_rate_pred(age); } -double G1Policy::predict_base_elapsed_time_ms(size_t pending_cards, +double G1DefaultPolicy::predict_base_elapsed_time_ms(size_t pending_cards, size_t scanned_cards) const { return _analytics->predict_rs_update_time_ms(pending_cards) + @@ -861,13 +862,13 @@ double G1Policy::predict_base_elapsed_time_ms(size_t pending_cards, _analytics->predict_constant_other_time_ms(); } -double G1Policy::predict_base_elapsed_time_ms(size_t pending_cards) const { +double G1DefaultPolicy::predict_base_elapsed_time_ms(size_t pending_cards) const { size_t rs_length = _analytics->predict_rs_lengths() + _analytics->predict_rs_length_diff(); size_t card_num = _analytics->predict_card_num(rs_length, collector_state()->gcs_are_young()); return predict_base_elapsed_time_ms(pending_cards, card_num); } -size_t G1Policy::predict_bytes_to_copy(HeapRegion* hr) const { +size_t G1DefaultPolicy::predict_bytes_to_copy(HeapRegion* hr) const { size_t bytes_to_copy; if (hr->is_marked()) bytes_to_copy = hr->max_live_bytes(); @@ -880,7 +881,7 @@ size_t G1Policy::predict_bytes_to_copy(HeapRegion* hr) const { return bytes_to_copy; } -double G1Policy::predict_region_elapsed_time_ms(HeapRegion* hr, +double G1DefaultPolicy::predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const { size_t rs_length = hr->rem_set()->occupied(); // Predicting the number of cards is based on which type of GC @@ -903,30 +904,30 @@ double G1Policy::predict_region_elapsed_time_ms(HeapRegion* hr, } -void G1Policy::print_yg_surv_rate_info() const { +void G1DefaultPolicy::print_yg_surv_rate_info() const { #ifndef PRODUCT _short_lived_surv_rate_group->print_surv_rate_summary(); // add this call for any other surv rate groups #endif // PRODUCT } -bool G1Policy::is_young_list_full() const { +bool G1DefaultPolicy::is_young_list_full() const { uint young_list_length = _g1->young_list()->length(); uint young_list_target_length = _young_list_target_length; return young_list_length >= young_list_target_length; } -bool G1Policy::can_expand_young_list() const { +bool G1DefaultPolicy::can_expand_young_list() const { uint young_list_length = _g1->young_list()->length(); uint young_list_max_length = _young_list_max_length; return young_list_length < young_list_max_length; } -bool G1Policy::adaptive_young_list_length() const { +bool G1DefaultPolicy::adaptive_young_list_length() const { return _young_gen_sizer.adaptive_young_list_length(); } -void G1Policy::update_max_gc_locker_expansion() { +void G1DefaultPolicy::update_max_gc_locker_expansion() { uint expansion_region_num = 0; if (GCLockerEdenExpansionPercent > 0) { double perc = (double) GCLockerEdenExpansionPercent / 100.0; @@ -942,7 +943,7 @@ void G1Policy::update_max_gc_locker_expansion() { } // Calculates survivor space parameters. -void G1Policy::update_survivors_policy() { +void G1DefaultPolicy::update_survivors_policy() { double max_survivor_regions_d = (double) _young_list_target_length / (double) SurvivorRatio; // We use ceiling so that if max_survivor_regions_d is > 0.0 (but @@ -953,7 +954,7 @@ void G1Policy::update_survivors_policy() { HeapRegion::GrainWords * _max_survivor_regions, _policy_counters); } -bool G1Policy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) { +bool G1DefaultPolicy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) { // We actually check whether we are marking here and not if we are in a // reclamation phase. This means that we will schedule a concurrent mark // even while we are still in the process of reclaiming memory. @@ -968,12 +969,12 @@ bool G1Policy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) { } } -void G1Policy::initiate_conc_mark() { +void G1DefaultPolicy::initiate_conc_mark() { collector_state()->set_during_initial_mark_pause(true); collector_state()->set_initiate_conc_mark_if_possible(false); } -void G1Policy::decide_on_conc_mark_initiation() { +void G1DefaultPolicy::decide_on_conc_mark_initiation() { // We are about to decide on whether this pause will be an // initial-mark pause. @@ -1019,7 +1020,7 @@ void G1Policy::decide_on_conc_mark_initiation() { } } -void G1Policy::record_concurrent_mark_cleanup_end() { +void G1DefaultPolicy::record_concurrent_mark_cleanup_end() { cset_chooser()->rebuild(_g1->workers(), _g1->num_regions()); double end_sec = os::elapsedTime(); @@ -1030,7 +1031,7 @@ void G1Policy::record_concurrent_mark_cleanup_end() { record_pause(Cleanup, _mark_cleanup_start_sec, end_sec); } -double G1Policy::reclaimable_bytes_perc(size_t reclaimable_bytes) const { +double G1DefaultPolicy::reclaimable_bytes_perc(size_t reclaimable_bytes) const { // Returns the given amount of reclaimable bytes (that represents // the amount of reclaimable space still to be collected) as a // percentage of the current heap capacity. @@ -1038,7 +1039,7 @@ double G1Policy::reclaimable_bytes_perc(size_t reclaimable_bytes) const { return (double) reclaimable_bytes * 100.0 / (double) capacity_bytes; } -void G1Policy::maybe_start_marking() { +void G1DefaultPolicy::maybe_start_marking() { if (need_to_start_conc_mark("end of GC")) { // Note: this might have already been set, if during the last // pause we decided to start a cycle but at the beginning of @@ -1047,7 +1048,7 @@ void G1Policy::maybe_start_marking() { } } -G1Policy::PauseKind G1Policy::young_gc_pause_kind() const { +G1DefaultPolicy::PauseKind G1DefaultPolicy::young_gc_pause_kind() const { assert(!collector_state()->full_collection(), "must be"); if (collector_state()->during_initial_mark_pause()) { assert(collector_state()->last_gc_was_young(), "must be"); @@ -1069,7 +1070,7 @@ G1Policy::PauseKind G1Policy::young_gc_pause_kind() const { } } -void G1Policy::record_pause(PauseKind kind, double start, double end) { +void G1DefaultPolicy::record_pause(PauseKind kind, double start, double end) { // Manage the MMU tracker. For some reason it ignores Full GCs. if (kind != FullGC) { _mmu_tracker->add_pause(start, end); @@ -1096,11 +1097,11 @@ void G1Policy::record_pause(PauseKind kind, double start, double end) { } } -void G1Policy::abort_time_to_mixed_tracking() { +void G1DefaultPolicy::abort_time_to_mixed_tracking() { _initial_mark_to_mixed.reset(); } -bool G1Policy::next_gc_should_be_mixed(const char* true_action_str, +bool G1DefaultPolicy::next_gc_should_be_mixed(const char* true_action_str, const char* false_action_str) const { if (cset_chooser()->is_empty()) { log_debug(gc, ergo)("%s (candidate old regions not available)", false_action_str); @@ -1121,7 +1122,7 @@ bool G1Policy::next_gc_should_be_mixed(const char* true_action_str, return true; } -uint G1Policy::calc_min_old_cset_length() const { +uint G1DefaultPolicy::calc_min_old_cset_length() const { // The min old CSet region bound is based on the maximum desired // number of mixed GCs after a cycle. I.e., even if some old regions // look expensive, we should add them to the CSet anyway to make @@ -1142,7 +1143,7 @@ uint G1Policy::calc_min_old_cset_length() const { return (uint) result; } -uint G1Policy::calc_max_old_cset_length() const { +uint G1DefaultPolicy::calc_max_old_cset_length() const { // The max old CSet region bound is based on the threshold expressed // as a percentage of the heap size. I.e., it should bound the // number of old regions added to the CSet irrespective of how many @@ -1159,7 +1160,7 @@ uint G1Policy::calc_max_old_cset_length() const { return (uint) result; } -void G1Policy::finalize_collection_set(double target_pause_time_ms) { +void G1DefaultPolicy::finalize_collection_set(double target_pause_time_ms) { double time_remaining_ms = _collection_set->finalize_young_part(target_pause_time_ms); _collection_set->finalize_old_part(time_remaining_ms); } diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp new file mode 100644 index 00000000000..9c0d22474fb --- /dev/null +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp @@ -0,0 +1,440 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_GC_G1_G1DEFAULTPOLICY_HPP +#define SHARE_VM_GC_G1_G1DEFAULTPOLICY_HPP + +#include "gc/g1/g1CollectorState.hpp" +#include "gc/g1/g1GCPhaseTimes.hpp" +#include "gc/g1/g1InCSetState.hpp" +#include "gc/g1/g1InitialMarkToMixedTimeTracker.hpp" +#include "gc/g1/g1MMUTracker.hpp" +#include "gc/g1/g1Predictions.hpp" +#include "gc/g1/g1Policy.hpp" +#include "gc/g1/g1YoungGenSizer.hpp" +#include "gc/shared/gcCause.hpp" +#include "utilities/pair.hpp" + +// A G1Policy makes policy decisions that determine the +// characteristics of the collector. Examples include: +// * choice of collection set. +// * when to collect. + +class HeapRegion; +class G1CollectionSet; +class CollectionSetChooser; +class G1IHOPControl; +class G1Analytics; +class G1YoungGenSizer; +class GCPolicyCounters; + +class G1DefaultPolicy: public G1Policy { + private: + + static G1IHOPControl* create_ihop_control(const G1Predictions* predictor); + // Update the IHOP control with necessary statistics. + void update_ihop_prediction(double mutator_time_s, + size_t mutator_alloc_bytes, + size_t young_gen_size); + void report_ihop_statistics(); + + G1Predictions _predictor; + G1Analytics* _analytics; + G1MMUTracker* _mmu_tracker; + G1IHOPControl* _ihop_control; + + GCPolicyCounters* _policy_counters; + + double _full_collection_start_sec; + + uint _young_list_target_length; + uint _young_list_fixed_length; + + // The max number of regions we can extend the eden by while the GC + // locker is active. This should be >= _young_list_target_length; + uint _young_list_max_length; + + // SurvRateGroups below must be initialized after the predictor because they + // indirectly use it through this object passed to their constructor. + SurvRateGroup* _short_lived_surv_rate_group; + SurvRateGroup* _survivor_surv_rate_group; + + double _reserve_factor; + // This will be set when the heap is expanded + // for the first time during initialization. + uint _reserve_regions; + + G1YoungGenSizer _young_gen_sizer; + + uint _free_regions_at_end_of_collection; + + size_t _max_rs_lengths; + + size_t _rs_lengths_prediction; + +#ifndef PRODUCT + bool verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group); +#endif // PRODUCT + + size_t _pending_cards; + + // The amount of allocated bytes in old gen during the last mutator and the following + // young GC phase. + size_t _bytes_allocated_in_old_since_last_gc; + + G1InitialMarkToMixedTimeTracker _initial_mark_to_mixed; +public: + const G1Predictions& predictor() const { return _predictor; } + const G1Analytics* analytics() const { return const_cast(_analytics); } + + // Add the given number of bytes to the total number of allocated bytes in the old gen. + void add_bytes_allocated_in_old_since_last_gc(size_t bytes) { _bytes_allocated_in_old_since_last_gc += bytes; } + + // Accessors + + void set_region_eden(HeapRegion* hr, int young_index_in_cset) { + hr->set_eden(); + hr->install_surv_rate_group(_short_lived_surv_rate_group); + hr->set_young_index_in_cset(young_index_in_cset); + } + + void set_region_survivor(HeapRegion* hr, int young_index_in_cset) { + assert(hr->is_survivor(), "pre-condition"); + hr->install_surv_rate_group(_survivor_surv_rate_group); + hr->set_young_index_in_cset(young_index_in_cset); + } + +#ifndef PRODUCT + bool verify_young_ages(); +#endif // PRODUCT + + void record_max_rs_lengths(size_t rs_lengths) { + _max_rs_lengths = rs_lengths; + } + + + double predict_base_elapsed_time_ms(size_t pending_cards) const; + double predict_base_elapsed_time_ms(size_t pending_cards, + size_t scanned_cards) const; + size_t predict_bytes_to_copy(HeapRegion* hr) const; + double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const; + + double predict_survivor_regions_evac_time() const; + + bool should_update_surv_rate_group_predictors() { + return collector_state()->last_gc_was_young() && !collector_state()->in_marking_window(); + } + + void cset_regions_freed() { + bool update = should_update_surv_rate_group_predictors(); + + _short_lived_surv_rate_group->all_surviving_words_recorded(update); + _survivor_surv_rate_group->all_surviving_words_recorded(update); + } + + G1MMUTracker* mmu_tracker() { + return _mmu_tracker; + } + + const G1MMUTracker* mmu_tracker() const { + return _mmu_tracker; + } + + double max_pause_time_ms() const { + return _mmu_tracker->max_gc_time() * 1000.0; + } + + // Returns an estimate of the survival rate of the region at yg-age + // "yg_age". + double predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const; + + double predict_yg_surv_rate(int age) const; + + double accum_yg_surv_rate_pred(int age) const; + +protected: + G1CollectionSet* _collection_set; + virtual double average_time_ms(G1GCPhaseTimes::GCParPhases phase) const; + virtual double other_time_ms(double pause_time_ms) const; + + double young_other_time_ms() const; + double non_young_other_time_ms() const; + double constant_other_time_ms(double pause_time_ms) const; + + CollectionSetChooser* cset_chooser() const; +private: + + // The number of bytes copied during the GC. + size_t _bytes_copied_during_gc; + + // Stash a pointer to the g1 heap. + G1CollectedHeap* _g1; + + G1GCPhaseTimes* _phase_times; + + // This set of variables tracks the collector efficiency, in order to + // determine whether we should initiate a new marking. + double _mark_remark_start_sec; + double _mark_cleanup_start_sec; + + // Updates the internal young list maximum and target lengths. Returns the + // unbounded young list target length. + uint update_young_list_max_and_target_length(); + uint update_young_list_max_and_target_length(size_t rs_lengths); + + // Update the young list target length either by setting it to the + // desired fixed value or by calculating it using G1's pause + // prediction model. If no rs_lengths parameter is passed, predict + // the RS lengths using the prediction model, otherwise use the + // given rs_lengths as the prediction. + // Returns the unbounded young list target length. + uint update_young_list_target_length(size_t rs_lengths); + + // Calculate and return the minimum desired young list target + // length. This is the minimum desired young list length according + // to the user's inputs. + uint calculate_young_list_desired_min_length(uint base_min_length) const; + + // Calculate and return the maximum desired young list target + // length. This is the maximum desired young list length according + // to the user's inputs. + uint calculate_young_list_desired_max_length() const; + + // Calculate and return the maximum young list target length that + // can fit into the pause time goal. The parameters are: rs_lengths + // represent the prediction of how large the young RSet lengths will + // be, base_min_length is the already existing number of regions in + // the young list, min_length and max_length are the desired min and + // max young list length according to the user's inputs. + uint calculate_young_list_target_length(size_t rs_lengths, + uint base_min_length, + uint desired_min_length, + uint desired_max_length) const; + + // Result of the bounded_young_list_target_length() method, containing both the + // bounded as well as the unbounded young list target lengths in this order. + typedef Pair YoungTargetLengths; + YoungTargetLengths young_list_target_lengths(size_t rs_lengths) const; + + void update_rs_lengths_prediction(); + void update_rs_lengths_prediction(size_t prediction); + + // Check whether a given young length (young_length) fits into the + // given target pause time and whether the prediction for the amount + // of objects to be copied for the given length will fit into the + // given free space (expressed by base_free_regions). It is used by + // calculate_young_list_target_length(). + bool predict_will_fit(uint young_length, double base_time_ms, + uint base_free_regions, double target_pause_time_ms) const; + +public: + size_t pending_cards() const { return _pending_cards; } + + // Calculate the minimum number of old regions we'll add to the CSet + // during a mixed GC. + uint calc_min_old_cset_length() const; + + // Calculate the maximum number of old regions we'll add to the CSet + // during a mixed GC. + uint calc_max_old_cset_length() const; + + // Returns the given amount of uncollected reclaimable space + // as a percentage of the current heap capacity. + double reclaimable_bytes_perc(size_t reclaimable_bytes) const; + +private: + // Sets up marking if proper conditions are met. + void maybe_start_marking(); + + // The kind of STW pause. + enum PauseKind { + FullGC, + YoungOnlyGC, + MixedGC, + LastYoungGC, + InitialMarkGC, + Cleanup, + Remark + }; + + // Calculate PauseKind from internal state. + PauseKind young_gc_pause_kind() const; + // Record the given STW pause with the given start and end times (in s). + void record_pause(PauseKind kind, double start, double end); + // Indicate that we aborted marking before doing any mixed GCs. + void abort_time_to_mixed_tracking(); +public: + + G1DefaultPolicy(); + + virtual ~G1DefaultPolicy(); + + G1CollectorState* collector_state() const; + + G1GCPhaseTimes* phase_times() const { return _phase_times; } + + // Check the current value of the young list RSet lengths and + // compare it against the last prediction. If the current value is + // higher, recalculate the young list target length prediction. + void revise_young_list_target_length_if_necessary(size_t rs_lengths); + + // This should be called after the heap is resized. + void record_new_heap_size(uint new_number_of_regions); + + void init(G1CollectedHeap* g1h, G1CollectionSet* collection_set); + + virtual void note_gc_start(); + + bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0); + + bool about_to_start_mixed_phase() const; + + // Record the start and end of an evacuation pause. + void record_collection_pause_start(double start_time_sec); + void record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc); + + // Record the start and end of a full collection. + void record_full_collection_start(); + void record_full_collection_end(); + + // Must currently be called while the world is stopped. + void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms); + + // Record start and end of remark. + void record_concurrent_mark_remark_start(); + void record_concurrent_mark_remark_end(); + + // Record start, end, and completion of cleanup. + void record_concurrent_mark_cleanup_start(); + void record_concurrent_mark_cleanup_end(); + void record_concurrent_mark_cleanup_completed(); + + virtual void print_phases(); + + // Record how much space we copied during a GC. This is typically + // called when a GC alloc region is being retired. + void record_bytes_copied_during_gc(size_t bytes) { + _bytes_copied_during_gc += bytes; + } + + // The amount of space we copied during a GC. + size_t bytes_copied_during_gc() const { + return _bytes_copied_during_gc; + } + + // Determine whether there are candidate regions so that the + // next GC should be mixed. The two action strings are used + // in the ergo output when the method returns true or false. + bool next_gc_should_be_mixed(const char* true_action_str, + const char* false_action_str) const; + + virtual void finalize_collection_set(double target_pause_time_ms); +private: + // Set the state to start a concurrent marking cycle and clear + // _initiate_conc_mark_if_possible because it has now been + // acted on. + void initiate_conc_mark(); + +public: + // This sets the initiate_conc_mark_if_possible() flag to start a + // new cycle, as long as we are not already in one. It's best if it + // is called during a safepoint when the test whether a cycle is in + // progress or not is stable. + bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause); + + // This is called at the very beginning of an evacuation pause (it + // has to be the first thing that the pause does). If + // initiate_conc_mark_if_possible() is true, and the concurrent + // marking thread has completed its work during the previous cycle, + // it will set during_initial_mark_pause() to so that the pause does + // the initial-mark work and start a marking cycle. + void decide_on_conc_mark_initiation(); + + // Print stats on young survival ratio + void print_yg_surv_rate_info() const; + + void finished_recalculating_age_indexes(bool is_survivors) { + if (is_survivors) { + _survivor_surv_rate_group->finished_recalculating_age_indexes(); + } else { + _short_lived_surv_rate_group->finished_recalculating_age_indexes(); + } + } + + size_t young_list_target_length() const { return _young_list_target_length; } + + bool is_young_list_full() const; + + bool can_expand_young_list() const; + + uint young_list_max_length() const { + return _young_list_max_length; + } + + bool adaptive_young_list_length() const; + + virtual bool should_process_references() const { + return true; + } + +private: + // + // Survivor regions policy. + // + + // Current tenuring threshold, set to 0 if the collector reaches the + // maximum amount of survivors regions. + uint _tenuring_threshold; + + // The limit on the number of regions allocated for survivors. + uint _max_survivor_regions; + + AgeTable _survivors_age_table; + +public: + uint tenuring_threshold() const { return _tenuring_threshold; } + + uint max_survivor_regions() { + return _max_survivor_regions; + } + + void note_start_adding_survivor_regions() { + _survivor_surv_rate_group->start_adding_regions(); + } + + void note_stop_adding_survivor_regions() { + _survivor_surv_rate_group->stop_adding_regions(); + } + + void record_age_table(AgeTable* age_table) { + _survivors_age_table.merge(age_table); + } + + void update_max_gc_locker_expansion(); + + // Calculates survivor space parameters. + void update_survivors_policy(); +}; + +#endif // SHARE_VM_GC_G1_G1DEFAULTPOLICY_HPP diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.hpp b/hotspot/src/share/vm/gc/g1/g1Policy.hpp index 73b51e92d20..992ed8a6315 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp @@ -46,321 +46,106 @@ class CollectionSetChooser; class G1IHOPControl; class G1Analytics; class G1YoungGenSizer; -class GCPolicyCounters; class G1Policy: public CHeapObj { - private: - - static G1IHOPControl* create_ihop_control(const G1Predictions* predictor); - // Update the IHOP control with necessary statistics. - void update_ihop_prediction(double mutator_time_s, - size_t mutator_alloc_bytes, - size_t young_gen_size); - void report_ihop_statistics(); - - G1Predictions _predictor; - G1Analytics* _analytics; - G1MMUTracker* _mmu_tracker; - G1IHOPControl* _ihop_control; - - GCPolicyCounters* _policy_counters; - - double _full_collection_start_sec; - - uint _young_list_target_length; - uint _young_list_fixed_length; - - // The max number of regions we can extend the eden by while the GC - // locker is active. This should be >= _young_list_target_length; - uint _young_list_max_length; - - // SurvRateGroups below must be initialized after the predictor because they - // indirectly use it through this object passed to their constructor. - SurvRateGroup* _short_lived_surv_rate_group; - SurvRateGroup* _survivor_surv_rate_group; - - double _reserve_factor; - // This will be set when the heap is expanded - // for the first time during initialization. - uint _reserve_regions; - - G1YoungGenSizer _young_gen_sizer; - - uint _free_regions_at_end_of_collection; +public: + virtual const G1Predictions& predictor() const = 0; + virtual const G1Analytics* analytics() const = 0; - size_t _max_rs_lengths; + // Add the given number of bytes to the total number of allocated bytes in the old gen. + virtual void add_bytes_allocated_in_old_since_last_gc(size_t bytes) = 0; - size_t _rs_lengths_prediction; + // Accessors -#ifndef PRODUCT - bool verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group); -#endif // PRODUCT + virtual void set_region_eden(HeapRegion* hr, int young_index_in_cset) = 0; + virtual void set_region_survivor(HeapRegion* hr, int young_index_in_cset) = 0; - size_t _pending_cards; + virtual void record_max_rs_lengths(size_t rs_lengths) = 0; - // The amount of allocated bytes in old gen during the last mutator and the following - // young GC phase. - size_t _bytes_allocated_in_old_since_last_gc; + virtual double predict_base_elapsed_time_ms(size_t pending_cards) const = 0; + virtual double predict_base_elapsed_time_ms(size_t pending_cards, + size_t scanned_cards) const = 0; - G1InitialMarkToMixedTimeTracker _initial_mark_to_mixed; -public: - const G1Predictions& predictor() const { return _predictor; } - const G1Analytics* analytics() const { return const_cast(_analytics); } + virtual double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const = 0; - // Add the given number of bytes to the total number of allocated bytes in the old gen. - void add_bytes_allocated_in_old_since_last_gc(size_t bytes) { _bytes_allocated_in_old_since_last_gc += bytes; } + virtual void cset_regions_freed() = 0; - // Accessors + virtual G1MMUTracker* mmu_tracker() = 0; - void set_region_eden(HeapRegion* hr, int young_index_in_cset) { - hr->set_eden(); - hr->install_surv_rate_group(_short_lived_surv_rate_group); - hr->set_young_index_in_cset(young_index_in_cset); - } + virtual const G1MMUTracker* mmu_tracker() const = 0; - void set_region_survivor(HeapRegion* hr, int young_index_in_cset) { - assert(hr->is_survivor(), "pre-condition"); - hr->install_surv_rate_group(_survivor_surv_rate_group); - hr->set_young_index_in_cset(young_index_in_cset); - } + virtual double max_pause_time_ms() const = 0; -#ifndef PRODUCT - bool verify_young_ages(); -#endif // PRODUCT - - void record_max_rs_lengths(size_t rs_lengths) { - _max_rs_lengths = rs_lengths; - } - - - double predict_base_elapsed_time_ms(size_t pending_cards) const; - double predict_base_elapsed_time_ms(size_t pending_cards, - size_t scanned_cards) const; - size_t predict_bytes_to_copy(HeapRegion* hr) const; - double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const; - - double predict_survivor_regions_evac_time() const; - - bool should_update_surv_rate_group_predictors() { - return collector_state()->last_gc_was_young() && !collector_state()->in_marking_window(); - } - - void cset_regions_freed() { - bool update = should_update_surv_rate_group_predictors(); - - _short_lived_surv_rate_group->all_surviving_words_recorded(update); - _survivor_surv_rate_group->all_surviving_words_recorded(update); - } - - G1MMUTracker* mmu_tracker() { - return _mmu_tracker; - } - - const G1MMUTracker* mmu_tracker() const { - return _mmu_tracker; - } - - double max_pause_time_ms() const { - return _mmu_tracker->max_gc_time() * 1000.0; - } - - // Returns an estimate of the survival rate of the region at yg-age - // "yg_age". - double predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const; - - double predict_yg_surv_rate(int age) const; - - double accum_yg_surv_rate_pred(int age) const; - -protected: - G1CollectionSet* _collection_set; - virtual double average_time_ms(G1GCPhaseTimes::GCParPhases phase) const; - virtual double other_time_ms(double pause_time_ms) const; - - double young_other_time_ms() const; - double non_young_other_time_ms() const; - double constant_other_time_ms(double pause_time_ms) const; - - CollectionSetChooser* cset_chooser() const; -private: - - // The number of bytes copied during the GC. - size_t _bytes_copied_during_gc; - - // Stash a pointer to the g1 heap. - G1CollectedHeap* _g1; - - G1GCPhaseTimes* _phase_times; - - // This set of variables tracks the collector efficiency, in order to - // determine whether we should initiate a new marking. - double _mark_remark_start_sec; - double _mark_cleanup_start_sec; - - // Updates the internal young list maximum and target lengths. Returns the - // unbounded young list target length. - uint update_young_list_max_and_target_length(); - uint update_young_list_max_and_target_length(size_t rs_lengths); - - // Update the young list target length either by setting it to the - // desired fixed value or by calculating it using G1's pause - // prediction model. If no rs_lengths parameter is passed, predict - // the RS lengths using the prediction model, otherwise use the - // given rs_lengths as the prediction. - // Returns the unbounded young list target length. - uint update_young_list_target_length(size_t rs_lengths); - - // Calculate and return the minimum desired young list target - // length. This is the minimum desired young list length according - // to the user's inputs. - uint calculate_young_list_desired_min_length(uint base_min_length) const; - - // Calculate and return the maximum desired young list target - // length. This is the maximum desired young list length according - // to the user's inputs. - uint calculate_young_list_desired_max_length() const; - - // Calculate and return the maximum young list target length that - // can fit into the pause time goal. The parameters are: rs_lengths - // represent the prediction of how large the young RSet lengths will - // be, base_min_length is the already existing number of regions in - // the young list, min_length and max_length are the desired min and - // max young list length according to the user's inputs. - uint calculate_young_list_target_length(size_t rs_lengths, - uint base_min_length, - uint desired_min_length, - uint desired_max_length) const; - - // Result of the bounded_young_list_target_length() method, containing both the - // bounded as well as the unbounded young list target lengths in this order. - typedef Pair YoungTargetLengths; - YoungTargetLengths young_list_target_lengths(size_t rs_lengths) const; - - void update_rs_lengths_prediction(); - void update_rs_lengths_prediction(size_t prediction); - - // Check whether a given young length (young_length) fits into the - // given target pause time and whether the prediction for the amount - // of objects to be copied for the given length will fit into the - // given free space (expressed by base_free_regions). It is used by - // calculate_young_list_target_length(). - bool predict_will_fit(uint young_length, double base_time_ms, - uint base_free_regions, double target_pause_time_ms) const; - -public: - size_t pending_cards() const { return _pending_cards; } + virtual size_t pending_cards() const = 0; // Calculate the minimum number of old regions we'll add to the CSet // during a mixed GC. - uint calc_min_old_cset_length() const; + virtual uint calc_min_old_cset_length() const = 0; // Calculate the maximum number of old regions we'll add to the CSet // during a mixed GC. - uint calc_max_old_cset_length() const; + virtual uint calc_max_old_cset_length() const = 0; // Returns the given amount of uncollected reclaimable space // as a percentage of the current heap capacity. - double reclaimable_bytes_perc(size_t reclaimable_bytes) const; - -private: - // Sets up marking if proper conditions are met. - void maybe_start_marking(); - - // The kind of STW pause. - enum PauseKind { - FullGC, - YoungOnlyGC, - MixedGC, - LastYoungGC, - InitialMarkGC, - Cleanup, - Remark - }; - - // Calculate PauseKind from internal state. - PauseKind young_gc_pause_kind() const; - // Record the given STW pause with the given start and end times (in s). - void record_pause(PauseKind kind, double start, double end); - // Indicate that we aborted marking before doing any mixed GCs. - void abort_time_to_mixed_tracking(); -public: - - G1Policy(); + virtual double reclaimable_bytes_perc(size_t reclaimable_bytes) const = 0; - virtual ~G1Policy(); + virtual ~G1Policy() {} - G1CollectorState* collector_state() const; + virtual G1CollectorState* collector_state() const = 0; - G1GCPhaseTimes* phase_times() const { return _phase_times; } + virtual G1GCPhaseTimes* phase_times() const = 0; // Check the current value of the young list RSet lengths and // compare it against the last prediction. If the current value is // higher, recalculate the young list target length prediction. - void revise_young_list_target_length_if_necessary(size_t rs_lengths); + virtual void revise_young_list_target_length_if_necessary(size_t rs_lengths) = 0; // This should be called after the heap is resized. - void record_new_heap_size(uint new_number_of_regions); + virtual void record_new_heap_size(uint new_number_of_regions) = 0; - void init(G1CollectedHeap* g1h, G1CollectionSet* collection_set); + virtual void init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) = 0; - virtual void note_gc_start(); + virtual void note_gc_start() = 0; - bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0); - - bool about_to_start_mixed_phase() const; + virtual bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0) = 0; // Record the start and end of an evacuation pause. - void record_collection_pause_start(double start_time_sec); - void record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc); + virtual void record_collection_pause_start(double start_time_sec) = 0; + virtual void record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) = 0; // Record the start and end of a full collection. - void record_full_collection_start(); - void record_full_collection_end(); + virtual void record_full_collection_start() = 0; + virtual void record_full_collection_end() = 0; // Must currently be called while the world is stopped. - void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms); + virtual void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) = 0; // Record start and end of remark. - void record_concurrent_mark_remark_start(); - void record_concurrent_mark_remark_end(); + virtual void record_concurrent_mark_remark_start() = 0; + virtual void record_concurrent_mark_remark_end() = 0; // Record start, end, and completion of cleanup. - void record_concurrent_mark_cleanup_start(); - void record_concurrent_mark_cleanup_end(); - void record_concurrent_mark_cleanup_completed(); + virtual void record_concurrent_mark_cleanup_start() = 0; + virtual void record_concurrent_mark_cleanup_end() = 0; + virtual void record_concurrent_mark_cleanup_completed() = 0; - virtual void print_phases(); + virtual void print_phases() = 0; // Record how much space we copied during a GC. This is typically // called when a GC alloc region is being retired. - void record_bytes_copied_during_gc(size_t bytes) { - _bytes_copied_during_gc += bytes; - } + virtual void record_bytes_copied_during_gc(size_t bytes) = 0; // The amount of space we copied during a GC. - size_t bytes_copied_during_gc() const { - return _bytes_copied_during_gc; - } - - // Determine whether there are candidate regions so that the - // next GC should be mixed. The two action strings are used - // in the ergo output when the method returns true or false. - bool next_gc_should_be_mixed(const char* true_action_str, - const char* false_action_str) const; - - virtual void finalize_collection_set(double target_pause_time_ms); -private: - // Set the state to start a concurrent marking cycle and clear - // _initiate_conc_mark_if_possible because it has now been - // acted on. - void initiate_conc_mark(); + virtual size_t bytes_copied_during_gc() const = 0; + + virtual void finalize_collection_set(double target_pause_time_ms) = 0; -public: // This sets the initiate_conc_mark_if_possible() flag to start a // new cycle, as long as we are not already in one. It's best if it // is called during a safepoint when the test whether a cycle is in // progress or not is stable. - bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause); + virtual bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) = 0; // This is called at the very beginning of an evacuation pause (it // has to be the first thing that the pause does). If @@ -368,72 +153,33 @@ public: // marking thread has completed its work during the previous cycle, // it will set during_initial_mark_pause() to so that the pause does // the initial-mark work and start a marking cycle. - void decide_on_conc_mark_initiation(); + virtual void decide_on_conc_mark_initiation() = 0; // Print stats on young survival ratio - void print_yg_surv_rate_info() const; - - void finished_recalculating_age_indexes(bool is_survivors) { - if (is_survivors) { - _survivor_surv_rate_group->finished_recalculating_age_indexes(); - } else { - _short_lived_surv_rate_group->finished_recalculating_age_indexes(); - } - } + virtual void print_yg_surv_rate_info() const = 0; - size_t young_list_target_length() const { return _young_list_target_length; } + virtual void finished_recalculating_age_indexes(bool is_survivors) = 0; - bool is_young_list_full() const; + virtual size_t young_list_target_length() const = 0; - bool can_expand_young_list() const; + virtual bool is_young_list_full() const = 0; - uint young_list_max_length() const { - return _young_list_max_length; - } + virtual bool can_expand_young_list() const = 0; - bool adaptive_young_list_length() const; - - virtual bool should_process_references() const { - return true; - } - -private: - // - // Survivor regions policy. - // - - // Current tenuring threshold, set to 0 if the collector reaches the - // maximum amount of survivors regions. - uint _tenuring_threshold; - - // The limit on the number of regions allocated for survivors. - uint _max_survivor_regions; - - AgeTable _survivors_age_table; - -public: - uint tenuring_threshold() const { return _tenuring_threshold; } + virtual uint young_list_max_length() const = 0; - uint max_survivor_regions() { - return _max_survivor_regions; - } + virtual bool adaptive_young_list_length() const = 0; - void note_start_adding_survivor_regions() { - _survivor_surv_rate_group->start_adding_regions(); - } + virtual bool should_process_references() const = 0; - void note_stop_adding_survivor_regions() { - _survivor_surv_rate_group->stop_adding_regions(); - } + virtual uint tenuring_threshold() const = 0; + virtual uint max_survivor_regions() = 0; - void record_age_table(AgeTable* age_table) { - _survivors_age_table.merge(age_table); - } + virtual void note_start_adding_survivor_regions() = 0; - void update_max_gc_locker_expansion(); + virtual void note_stop_adding_survivor_regions() = 0; - // Calculates survivor space parameters. - void update_survivors_policy(); + virtual void record_age_table(AgeTable* age_table) = 0; }; #endif // SHARE_VM_GC_G1_G1POLICY_HPP -- GitLab From df65dd52dedf155207b42602233ec0acf89ce4ca Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Wed, 20 Apr 2016 19:16:32 +0300 Subject: [PATCH 176/400] 8135200: Add White Box method that enumerates G1 old regions with less than specified liveness and collects statistics Reviewed-by: tschatzl, dfazunen, iignatyev --- test/lib/sun/hotspot/WhiteBox.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/lib/sun/hotspot/WhiteBox.java b/test/lib/sun/hotspot/WhiteBox.java index f2c85fb95a1..ea94568a8d4 100644 --- a/test/lib/sun/hotspot/WhiteBox.java +++ b/test/lib/sun/hotspot/WhiteBox.java @@ -192,6 +192,16 @@ public class WhiteBox { public native long psVirtualSpaceAlignment(); public native long psHeapGenerationAlignment(); + /** + * Enumerates old regions with liveness less than specified and produces some statistics + * @param liveness percent of region's liveness (live_objects / total_region_size * 100). + * @return long[3] array where long[0] - total count of old regions + * long[1] - total memory of old regions + * long[2] - lowest estimation of total memory of old regions to be freed (non-full + * regions are not included) + */ + public native long[] g1GetMixedGCInfo(int liveness); + // NMT public native long NMTMalloc(long size); public native void NMTFree(long mem); -- GitLab From 04dd07454a8117f6febc223a2e7b48dd31892d79 Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Wed, 20 Apr 2016 20:40:46 +0300 Subject: [PATCH 177/400] 8154145: Missing klass/method name in stack traces on error Reviewed-by: stefank, cjplummer --- hotspot/src/share/vm/runtime/frame.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/runtime/frame.cpp b/hotspot/src/share/vm/runtime/frame.cpp index b2a321687b7..10d817636a4 100644 --- a/hotspot/src/share/vm/runtime/frame.cpp +++ b/hotspot/src/share/vm/runtime/frame.cpp @@ -665,10 +665,12 @@ void frame::print_on_error(outputStream* st, char* buf, int buflen, bool verbose nmethod* nm = (nmethod*)_cb; Method* m = nm->method(); if (m != NULL) { + st->print("J %d%s", nm->compile_id(), (nm->is_osr_method() ? "%" : "")); + if (nm->compiler() != NULL) { + st->print(" %s", nm->compiler()->name()); + } m->name_and_sig_as_C_string(buf, buflen); - st->print("J %d%s %s ", - nm->compile_id(), (nm->is_osr_method() ? "%" : ""), - ((nm->compiler() != NULL) ? nm->compiler()->name() : "")); + st->print(" %s", buf); ModuleEntry* module = m->method_holder()->module(); if (module->is_named()) { module->name()->as_C_string(buf, buflen); @@ -676,8 +678,8 @@ void frame::print_on_error(outputStream* st, char* buf, int buflen, bool verbose module->version()->as_C_string(buf, buflen); st->print("@%s", buf); } - st->print("%s (%d bytes) @ " PTR_FORMAT " [" PTR_FORMAT "+" INTPTR_FORMAT "]", - buf, m->code_size(), p2i(_pc), p2i(_cb->code_begin()), _pc - _cb->code_begin()); + st->print(" (%d bytes) @ " PTR_FORMAT " [" PTR_FORMAT "+" INTPTR_FORMAT "]", + m->code_size(), p2i(_pc), p2i(_cb->code_begin()), _pc - _cb->code_begin()); #if INCLUDE_JVMCI char* jvmciName = nm->jvmci_installed_code_name(buf, buflen); if (jvmciName != NULL) { -- GitLab From 1af5fe07a008c432f4d67a58f38f87fdb9ee6d7f Mon Sep 17 00:00:00 2001 From: Zoltan Majo Date: Thu, 21 Apr 2016 09:21:48 +0200 Subject: [PATCH 178/400] 8153292: AllocateInstancePrefetchLines>AllocatePrefetchLines can trigger out-of-heap prefetching Set the size of the reserved TLAB area to the MAX of both flags. Reviewed-by: kvn, thartmann --- hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp index 93c8d40891e..72ae7883ba6 100644 --- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp @@ -112,11 +112,14 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256); } if (AllocatePrefetchInstr == 1) { - // Need a space at the end of TLAB for BIS since it - // will fault when accessing memory outside of heap. + // Need extra space at the end of TLAB for BIS, otherwise prefetching + // instructions will fault (due to accessing memory outside of heap). + // The amount of space is the max of the number of lines to + // prefetch for array and for instance allocations. (Extra space must be + // reserved to accomodate both types of allocations.) // +1 for rounding up to next cache line, +1 to be safe - int lines = AllocatePrefetchLines + 2; + int lines = MAX2(AllocatePrefetchLines, AllocateInstancePrefetchLines) + 2; int step_size = AllocatePrefetchStepSize; int distance = AllocatePrefetchDistance; _reserve_for_allocation_prefetch = (distance + step_size*lines)/(int)HeapWordSize; -- GitLab From 257c8ccafcfe780bc68c40190818ce1c0aeec9ad Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Thu, 21 Apr 2016 10:52:00 +0200 Subject: [PATCH 179/400] 8086068: VM crashes with "-Xint -XX:+UseCompiler" options Prevent incompatible compiler flag combination. Reviewed-by: zmajo, kvn, ddmitriev --- hotspot/src/share/vm/code/codeCache.cpp | 2 +- hotspot/src/share/vm/runtime/arguments.cpp | 6 +++ .../compiler/arguments/TestUseCompiler.java | 38 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 hotspot/test/compiler/arguments/TestUseCompiler.java diff --git a/hotspot/src/share/vm/code/codeCache.cpp b/hotspot/src/share/vm/code/codeCache.cpp index f2dfcee02b5..ec4ced1c3d7 100644 --- a/hotspot/src/share/vm/code/codeCache.cpp +++ b/hotspot/src/share/vm/code/codeCache.cpp @@ -336,7 +336,7 @@ bool CodeCache::heap_available(int code_blob_type) { if (!SegmentedCodeCache) { // No segmentation: use a single code heap return (code_blob_type == CodeBlobType::All); - } else if (Arguments::mode() == Arguments::_int) { + } else if (Arguments::is_interpreter_only()) { // Interpreter only: we don't need any method code heaps return (code_blob_type == CodeBlobType::NonNMethod); } else if (TieredCompilation && (TieredStopAtLevel > CompLevel_simple)) { diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 129f7a74795..f305a8c2447 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -2620,6 +2620,12 @@ bool Arguments::check_vm_args_consistency() { } FLAG_SET_CMDLINE(bool, BackgroundCompilation, false); } + if (UseCompiler && is_interpreter_only()) { + if (!FLAG_IS_DEFAULT(UseCompiler)) { + warning("UseCompiler disabled due to -Xint."); + } + FLAG_SET_CMDLINE(bool, UseCompiler, false); + } return status; } diff --git a/hotspot/test/compiler/arguments/TestUseCompiler.java b/hotspot/test/compiler/arguments/TestUseCompiler.java new file mode 100644 index 00000000000..edf3540398c --- /dev/null +++ b/hotspot/test/compiler/arguments/TestUseCompiler.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test TestUseCompiler + * @bug 8086068 + * @summary Tests execution with inconsistent UseCompiler flag combination. + * @run main/othervm -Xint -XX:+UseCompiler TestUseCompiler + * @run main/othervm -XX:+UseCompiler -Xint TestUseCompiler + */ + +public class TestUseCompiler { + + public static void main(String args[]) { + System.out.println("Passed"); + } +} + -- GitLab From 48892f6f6838658dea67edc99e9005f246e39d02 Mon Sep 17 00:00:00 2001 From: Per Liden Date: Thu, 21 Apr 2016 09:23:04 -0400 Subject: [PATCH 180/400] 8152949: Jigsaw crash when Klass in _fixup_module_field_list is unloaded During start up anonymous classes must be kept alive until after their mirror's module field is patched with java.base Co-authored-by: Stefan Karlsson Reviewed-by: coleenp, hseigel --- .../src/share/vm/classfile/classLoaderData.cpp | 17 ++++++++++++++++- .../src/share/vm/classfile/classLoaderData.hpp | 11 +++++++---- hotspot/src/share/vm/classfile/javaClasses.cpp | 1 + hotspot/src/share/vm/classfile/moduleEntry.cpp | 1 + hotspot/src/share/vm/classfile/modules.cpp | 5 +++++ hotspot/src/share/vm/prims/unsafe.cpp | 2 +- 6 files changed, 31 insertions(+), 6 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index 0c0eb37196f..5db59458529 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -84,7 +84,7 @@ ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_anonymous, Depen // An anonymous class loader data doesn't have anything to keep // it from being unloaded during parsing of the anonymous class. // The null-class-loader should always be kept alive. - _keep_alive(is_anonymous || h_class_loader.is_null()), + _keep_alive((is_anonymous || h_class_loader.is_null()) ? 1 : 0), _metaspace(NULL), _unloading(false), _klasses(NULL), _modules(NULL), _packages(NULL), _claimed(0), _jmethod_ids(NULL), _handles(NULL), _deallocate_list(NULL), @@ -114,6 +114,21 @@ bool ClassLoaderData::claim() { return (int) Atomic::cmpxchg(1, &_claimed, 0) == 0; } +// Anonymous classes have their own ClassLoaderData that is marked to keep alive +// while the class is being parsed, and if the class appears on the module fixup list. +// Due to the uniqueness that no other class shares the anonymous class' name or +// ClassLoaderData, no other non-GC thread has knowledge of the anonymous class while +// it is being defined, therefore _keep_alive is not volatile or atomic. +void ClassLoaderData::inc_keep_alive() { + assert(_keep_alive >= 0, "Invalid keep alive count"); + _keep_alive++; +} + +void ClassLoaderData::dec_keep_alive() { + assert(_keep_alive > 0, "Invalid keep alive count"); + _keep_alive--; +} + void ClassLoaderData::oops_do(OopClosure* f, KlassClosure* klass_closure, bool must_claim) { if (must_claim && !claim()) { return; diff --git a/hotspot/src/share/vm/classfile/classLoaderData.hpp b/hotspot/src/share/vm/classfile/classLoaderData.hpp index 4b6d24722d3..b1a136a77c1 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp @@ -175,8 +175,11 @@ class ClassLoaderData : public CHeapObj { // classes in the class loader are allocated. Mutex* _metaspace_lock; // Locks the metaspace for allocations and setup. bool _unloading; // true if this class loader goes away - bool _keep_alive; // if this CLD is kept alive without a keep_alive_object(). bool _is_anonymous; // if this CLD is for an anonymous class + int _keep_alive; // if this CLD is kept alive without a keep_alive_object(). + // Currently used solely for anonymous classes. + // _keep_alive does not need to be volatile or + // atomic since there is one unique CLD per anonymous class. volatile int _claimed; // true if claimed, for example during GC traces. // To avoid applying oop closure more than once. // Has to be an int because we cas it. @@ -224,7 +227,7 @@ class ClassLoaderData : public CHeapObj { bool claim(); void unload(); - bool keep_alive() const { return _keep_alive; } + bool keep_alive() const { return _keep_alive > 0; } void classes_do(void f(Klass*)); void loaded_classes_do(KlassClosure* klass_closure); void classes_do(void f(InstanceKlass*)); @@ -286,8 +289,8 @@ class ClassLoaderData : public CHeapObj { return _unloading; } - // Used to make sure that this CLD is not unloaded. - void set_keep_alive(bool value) { _keep_alive = value; } + void inc_keep_alive(); + void dec_keep_alive(); inline unsigned int identity_hash() const; diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index 5365e1df8d6..3839403981e 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -852,6 +852,7 @@ void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader, new (ResourceObj::C_HEAP, mtClass) GrowableArray(500, true); set_fixup_module_field_list(list); } + k->class_loader_data()->inc_keep_alive(); fixup_module_field_list()->push(k()); } } else { diff --git a/hotspot/src/share/vm/classfile/moduleEntry.cpp b/hotspot/src/share/vm/classfile/moduleEntry.cpp index 3386dc43c1e..f26b95ab690 100644 --- a/hotspot/src/share/vm/classfile/moduleEntry.cpp +++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp @@ -354,6 +354,7 @@ void ModuleEntryTable::patch_javabase_entries(Handle module_handle) { Thread* THREAD = Thread::current(); KlassHandle kh(THREAD, k); java_lang_Class::fixup_module_field(kh, module_handle); + k->class_loader_data()->dec_keep_alive(); } delete java_lang_Class::fixup_module_field_list(); diff --git a/hotspot/src/share/vm/classfile/modules.cpp b/hotspot/src/share/vm/classfile/modules.cpp index 6d47db68c7d..d1f272805cb 100644 --- a/hotspot/src/share/vm/classfile/modules.cpp +++ b/hotspot/src/share/vm/classfile/modules.cpp @@ -277,6 +277,11 @@ static void define_javabase_module(jobject module, jstring version, { MutexLocker m1(Module_lock, THREAD); + if (ModuleEntryTable::javabase_defined()) { + THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), + "Module java.base is already defined"); + } + // Verify that all java.base packages created during bootstrapping are in // pkg_list. If any are not in pkg_list, than a non-java.base class was // loaded erroneously pre java.base module definition. diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index f951f694f1d..ddf379efdbb 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -934,7 +934,7 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineAnonymousClass0(JNIEnv *env, jobject unsafe, j // this point. The mirror and any instances of this class have to keep // it alive afterwards. if (anon_klass() != NULL) { - anon_klass->class_loader_data()->set_keep_alive(false); + anon_klass->class_loader_data()->dec_keep_alive(); } // let caller initialize it as needed... -- GitLab From 769aba784a756ed227741f11cb176134160337e2 Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Thu, 21 Apr 2016 18:01:10 +0300 Subject: [PATCH 181/400] 8153764: Add auxiliary method that generates class by class prototype to gc testlibrary Reviewed-by: dfazunen, iignatyev --- hotspot/test/gc/testlibrary/Helpers.java | 148 +++++++++++++++++++++-- 1 file changed, 135 insertions(+), 13 deletions(-) diff --git a/hotspot/test/gc/testlibrary/Helpers.java b/hotspot/test/gc/testlibrary/Helpers.java index aa20031cd10..b28d92dd406 100644 --- a/hotspot/test/gc/testlibrary/Helpers.java +++ b/hotspot/test/gc/testlibrary/Helpers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; public class Helpers { @@ -45,14 +46,14 @@ public class Helpers { /** * According class file format theoretical amount of fields in class is u2 which is (256 * 256 - 1). - * Some service info takes place in constant pool and we really could make a class with only (256 * 256 - 29) - * fields. + * Some service info takes place in constant pool and we really could make a class with lesser amount of fields. + * * Since the exact value is not so important and I would like to avoid issues that may be caused by future changes/ - * different archs etc I selected (256 * 256 - 32) for this constant. + * different archs etc I selected (256 * 256 - 1024) for this constant. * The test works with other values too but the smaller the number the more classes we need to generate and it takes * more time */ - private static final int MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS = 256 * 256 - 32; + private static final int MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS = 256 * 256 - 1024; /** * Detects amount of extra bytes required to allocate a byte array. @@ -139,6 +140,28 @@ public class Helpers { return builder.toString(); } + /** + * Generates specified amount of long fields + * Result string will looks like this: + *

        + * long f0; + * ... + * long fNNN; + * + * @param fieldCount count of long fields + * @return generated fields + */ + private static String fieldsGenerator(long fieldCount) { + StringBuilder fieldsBuilder = new StringBuilder(); + + for (int i = 0; i < fieldCount; ++i) { + fieldsBuilder.append(String.format("long f%d;\n", i)); + } + + return fieldsBuilder.toString(); + } + + /** * Changes string from enum notation to class notation - i.e. "VERY_SMALL_CAT" to "VerySmallCat" * @@ -216,22 +239,121 @@ public class Helpers { // for the last generated class we use specified class name String clsName = (i == generatedClassesCount - 1) ? className : prefix + i; + // If we already have a file with the same name we do not create it again + if (Files.notExists(Paths.get(clsName + ".java"))) { + Helpers.compileClass(clsName, workDir, + Helpers.generate( + clsName, + // for first generated class we don't have 'extends' + (i == 0 ? null : prefix + (i - 1)), + null, + // for the last generated class we use different field count + (i == generatedClassesCount - 1) ? fieldsInLastClassCount + : MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS)); + } else { + System.out.println("Class " + clsName + + ".java already exists, skipping class' generation and compilation"); + } + + } + return classLoader.loadClass(className); + } + + /** + * Creates a class which instances will be approximately of the requested size. + * This method produces a java source from a class template by substituting values instead of parameters. + * Then the obtained source is compiled. + * Generated class will looks like this: + * classTemplate + * constructorTemplate + * long f0; + * ... + * long fNNN; + *

        + * } + * + * @param className generated class name + * @param baseClass base class + * @param classTemplate class template - the first part of class. ${ClassName} and ${BaseClass} will be replaced + * with values from className and baseClass,one entry of ${Fields} will be replaced with + * generated long fields. Class template should look like this: + * imports; + * public class ${ClassName} extends ${BaseClass} { + * public ${ClassName} { some code here;} + * some methods + * ${Fields} + * + * } + * @param constructorTemplate constructor template, ${ClassName} would be replaced on actual class name + * @param instanceSize size of generated class' instance. Size should be aligned by 8 bytes + * @param workDir working dir where generated classes are put and compiled + * @param prefix prefix for service classes (ones we use to create chain of inheritance). + * The names will be prefix_1, prefix_2,.., prefix_n + * @return Class object of generated and compiled class loaded in specified class loader + * @throws IOException if cannot write or read to workDir + */ + public static void generateByTemplateAndCompile(String className, String baseClass, String classTemplate, + String constructorTemplate, long instanceSize, Path workDir, + String prefix) throws IOException { + + if (instanceSize % SIZE_OF_LONG != 0L) { + throw new Error(String.format("Test bug: only sizes aligned by %d bytes are supported and %d was specified", + SIZE_OF_LONG, instanceSize)); + } + + int instanceSizeWithoutObjectHeaderInWords = + (int) (instanceSize - WhiteBox.getWhiteBox().getObjectSize(new Object())) / SIZE_OF_LONG; + + if (instanceSizeWithoutObjectHeaderInWords <= 0) { + throw new Error(String.format("Test bug: specified instance size is too small - %d." + + " Cannot generate any classes", instanceSize)); + } + + int sizeOfLastFile = instanceSizeWithoutObjectHeaderInWords % MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS; + int generatedClassesCount = instanceSizeWithoutObjectHeaderInWords / MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS; + + // Do all the classes have the maximum number of fields? + int fieldsInLastClassCount; + + if (sizeOfLastFile == 0) { + fieldsInLastClassCount = MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS; + } else { + generatedClassesCount++; + fieldsInLastClassCount = sizeOfLastFile; + } + + // first (generatedClassesCount - 1) classes are just fillers - just long fields and constructor + for (int i = 0; i < generatedClassesCount - 1; i++) { + String clsName = prefix + i; + Helpers.compileClass(clsName, workDir, Helpers.generate( clsName, - // for first generated class we don't have 'extends' - (i == 0 ? null : prefix + (i - 1)), - null, - // for the last generated class we use different field count - (i == generatedClassesCount - 1) ? fieldsInLastClassCount - : MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS)); + // first generated class extends base class + (i == 0 ? baseClass : prefix + (i - 1)), + constructorTemplate.replace("${ClassName}", clsName), + MAXIMUM_AMOUNT_OF_FIELDS_IN_CLASS)); } - return classLoader.loadClass(className); + + // generating last class - the one with specified className + Helpers.compileClass(className, workDir, + classTemplate.replaceAll("\\$\\{ClassName\\}", className) + // if no fillers were generated (generatedClassesCount == 1) + // the last class should extends baseClass + // otherwise it should extend last generated filler class which name is + // prefix + (generatedClassesCount - 2) + // generatedClassesCount is always not smaller than 1 + .replace("${BaseClass}", + generatedClassesCount == 1 ? baseClass : + prefix + (generatedClassesCount - 2)) + .replace("${Fields}", fieldsGenerator(fieldsInLastClassCount)) + ); } /** * Waits until Concurent Mark Cycle finishes - * @param wb Whitebox instance + * + * @param wb Whitebox instance * @param sleepTime sleep time */ public static void waitTillCMCFinished(WhiteBox wb, int sleepTime) { -- GitLab From b15c8503ab6d5eca347bab168a0dcfe1f40bde46 Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Thu, 21 Apr 2016 17:55:14 +0300 Subject: [PATCH 182/400] 8132718: Add tests which check that when humongous classloader object becomes unreachable it and all classes that were loaded in it should be collected Reviewed-by: jmasa, dfazunen --- .../ClassLoaderGenerator.java | 100 ++++++++ .../TestHumongousClassLoader.java | 220 ++++++++++++++++++ 2 files changed, 320 insertions(+) create mode 100644 hotspot/test/gc/g1/humongousObjects/ClassLoaderGenerator.java create mode 100644 hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java diff --git a/hotspot/test/gc/g1/humongousObjects/ClassLoaderGenerator.java b/hotspot/test/gc/g1/humongousObjects/ClassLoaderGenerator.java new file mode 100644 index 00000000000..6767e4b3d23 --- /dev/null +++ b/hotspot/test/gc/g1/humongousObjects/ClassLoaderGenerator.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package gc.g1.humongousObjects; + +import gc.testlibrary.Helpers; + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +/** + * Generates non-humongous and humongous class loaders. + * Since the generation depends on current host architecture it cannot be done as part of pre-compilation step + */ +public class ClassLoaderGenerator { + public static void main(String[] args) throws IOException { + + if (args.length != 1) { + throw new Error("Test Bug: Expected region size wasn't provided as command line argument"); + } + + long regionSize = Long.parseLong(args[0]) * 1024 * 1024; + + Path wrkDir = Paths.get(""); + generateClassLoader(regionSize, wrkDir); + + } + + public static void generateClassLoader(long regionSize, Path wrkDir) throws IOException { + // Generating simple classloader + String finalSimpleClassLoaderPrototype = TestHumongousClassLoader.GENERIC_PROTOTYPE + .replace("${Methods}", + TestHumongousClassLoader.LOAD_CLASS_METHOD_PROTOTYPE + .replace("${ClassLoadFilter}", + "fileName.equals(\"" + TestHumongousClassLoader.HUMONGOUS_CLASSLOADER_NAME + + "\")")) + .replace("${ClassHeader}", TestHumongousClassLoader.CLASS_HEADER) + .replace("${ConstructorClause}", TestHumongousClassLoader.CONSTUCTOR_PROTOTYPE); + + Helpers.generateByTemplateAndCompile(TestHumongousClassLoader.SIMPLE_CLASSLOADER_NAME, "ClassLoader", + finalSimpleClassLoaderPrototype, TestHumongousClassLoader.CONSTUCTOR_PROTOTYPE, regionSize / 4, + wrkDir, TestHumongousClassLoader.SIMPLE_CLASSLOADER_NAME + "Base"); + + + // Preparations for generating humongous classloader + + // Generating condition for loadClass method of generated class loader + // We want the generated class loader to load only classes from G1SampleClass enum + // All other classes should be loaded by parent classloader + // As result we get full loadClass method + StringBuilder classesToLoadBuilder = new StringBuilder(); + for (G1SampleClass g1SampleClass : G1SampleClass.values()) { + if (classesToLoadBuilder.length() != 0) { + classesToLoadBuilder.append(" || "); + } + classesToLoadBuilder.append("fileName.startsWith(\"" + Helpers.enumNameToClassName(g1SampleClass.name()) + + "\")"); + } + + // Generating final class loader prototype - with specified methods,header and constructor + String finalHumongousClassLoaderPrototype = TestHumongousClassLoader.GENERIC_PROTOTYPE + .replace("${Methods}", + TestHumongousClassLoader.LOAD_CLASS_METHOD_PROTOTYPE + .replace("${ClassLoadFilter}", classesToLoadBuilder)) + .replace("${ClassHeader}", TestHumongousClassLoader.CLASS_HEADER) + .replace("${ConstructorClause}", TestHumongousClassLoader.CONSTUCTOR_PROTOTYPE); + + + // Generating humongous classloader with specified name, base class, final class prototype and + // constructor prototype for filler classes + // Generated class instance should be humongous since we specify size of (regionSize * 3 / 4) + Helpers.generateByTemplateAndCompile(TestHumongousClassLoader.HUMONGOUS_CLASSLOADER_NAME, "ClassLoader", + finalHumongousClassLoaderPrototype, TestHumongousClassLoader.CONSTUCTOR_PROTOTYPE, + regionSize * 3 / 4, + wrkDir, TestHumongousClassLoader.HUMONGOUS_CLASSLOADER_NAME + "Base"); + + + } +} diff --git a/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java new file mode 100644 index 00000000000..075f5096d1e --- /dev/null +++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package gc.g1.humongousObjects; + +import gc.testlibrary.Helpers; +import jdk.test.lib.Asserts; +import sun.hotspot.WhiteBox; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URL; +import java.net.URLClassLoader; +import java.nio.file.Path; +import java.nio.file.Paths; + +/** + * @test gc.g1.humongousObjects.TestHumongousClassLoader + * @summary Checks that unreachable classes and unreachable humongous class loader are unloaded after GC + * @requires vm.gc=="G1" | vm.gc=="null" + * @requires vm.opt.G1HeapRegionSize == "null" | vm.opt.G1HeapRegionSize == "1M" + * @library /testlibrary /test/lib / + * @modules java.management + * @build sun.hotspot.WhiteBox + * gc.testlibrary.Helpers + * gc.g1.humongousObjects.G1SampleClass + * gc.g1.humongousObjects.ClassLoaderGenerator + * gc.g1.humongousObjects.TestHumongousClassLoader + * + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * + * @run main/othervm/timeout=240 -Xms256M -Xmx256M -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * gc.g1.humongousObjects.ClassLoaderGenerator 1 + * + * @run main/othervm -Xms256M -Xmx256M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -Xlog:classload,classunload=debug:file=TestHumongousClassLoader_Full_GC.log + * -XX:G1HeapRegionSize=1M + * gc.g1.humongousObjects.TestHumongousClassLoader FULL_GC + * + * @run main/othervm -Xms256M -Xmx256M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -Xlog:classload,classunload=debug:file=TestHumongousClassLoader_Full_GC_Mem_Pressure.log + * -XX:G1HeapRegionSize=1M + * gc.g1.humongousObjects.TestHumongousClassLoader FULL_GC_MEMORY_PRESSURE + * + *@run main/othervm -Xms256M -Xmx256M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -Xlog:classload,classunload=debug:file=TestHumongousClassLoader_CMC.log + * -XX:G1HeapRegionSize=1M -XX:MaxTenuringThreshold=1 + * gc.g1.humongousObjects.TestHumongousClassLoader CMC + * + */ + +public class TestHumongousClassLoader { + + private static final WhiteBox WB = WhiteBox.getWhiteBox(); + private static final String SAMPLE_CLASS_NAME_PREFIX = "SampleClassFiller"; + public static final String SIMPLE_CLASSLOADER_NAME = "SimpleClassLoader"; + public static final String HUMONGOUS_CLASSLOADER_NAME = "HumongousClassLoader"; + + + public static final String LOAD_CLASS_METHOD_PROTOTYPE = + " @Override\n" + + " public Class loadClass(String fileName) throws ClassNotFoundException {\n" + + " if (${ClassLoadFilter}) {\n" + + " System.out.println(\"Loading class \" + fileName);\n" + + " byte[] b = null;\n" + + " try {\n" + + " b = Files.readAllBytes(new File(fileName + \".class\").toPath());\n" + + " } catch (IOException e) {\n" + + " e.printStackTrace();\n" + + " }\n" + + " Class c = defineClass(fileName, b, 0, b.length);\n" + + " resolveClass(c);\n" + + " return c;\n" + + " } else {\n" + + " return super.loadClass(fileName);\n" + + " }\n" + + "\n" + + "\n" + + " }\n"; + + public static final String CLASS_HEADER = "import java.io.File;\n" + + "import java.io.IOException;\n" + + "import java.nio.file.Files;\n" + + "import java.nio.file.Paths;\n"; + + public static final String GENERIC_PROTOTYPE = "${ClassHeader}\n" + + "public class ${ClassName} extends ${BaseClass}{\n" + + " ${ConstructorClause}\n" + + " ${Methods}\n" + + " ${Fields}\n" + + "}\n"; + + public static final String CONSTUCTOR_PROTOTYPE = "public ${ClassName}(ClassLoader parent) { super(parent);}\n"; + + private enum GC { + FULL_GC { + @Override + public void provoke() { + System.gc(); + } + }, + CMC { + @Override + public void provoke() { + // We need 2 young gc to promote class loader to old gen + // Otherwise it will not be unloaded after CMC + WHITE_BOX.youngGC(); + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + WHITE_BOX.youngGC(); + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + WHITE_BOX.g1StartConcMarkCycle(); + Helpers.waitTillCMCFinished(WHITE_BOX, 0); + } + }, + FULL_GC_MEMORY_PRESSURE { + @Override + public void provoke() { + WHITE_BOX.fullGC(); + } + }; + private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + + public abstract void provoke(); + } + + public static void main(String[] args) throws ClassNotFoundException, InstantiationException, + IllegalAccessException, IOException, NoSuchMethodException, InvocationTargetException { + + if (args.length != 1) { + throw new Error("Test Bug: Expected GC type wasn't provided as command line argument"); + } + GC gc = GC.valueOf(args[0]); + + Path wrkDir = Paths.get(""); + URL[] url = {wrkDir.toUri().toURL()}; + URLClassLoader urlLoader = new URLClassLoader(url); + + Class simpleClassLoaderClass = urlLoader.loadClass(SIMPLE_CLASSLOADER_NAME); + + ClassLoader simpleClassLoader = (ClassLoader) simpleClassLoaderClass + .getConstructor(java.lang.ClassLoader.class) + .newInstance(TestHumongousClassLoader.class.getClassLoader()); + + // Sanity check + Asserts.assertEquals(WB.g1IsHumongous(simpleClassLoader), false, + "Test Bug: simpleClassLoader is expected to be non-humongous but it's humongous"); + + + Class humongousClassLoaderClass = simpleClassLoader.loadClass(HUMONGOUS_CLASSLOADER_NAME); + + ClassLoader humongousClassLoader = (ClassLoader) humongousClassLoaderClass + .getConstructor(java.lang.ClassLoader.class) + .newInstance(simpleClassLoader); + + // Sanity check + Asserts.assertEquals(WB.g1IsHumongous(humongousClassLoader), true, + "Test Bug: humongousClassLoader is expected to be humongous but it's non-humongous"); + + //Asserts.assertEquals(1,0); + + Object[] loadedClasses = new Object[]{ + G1SampleClass.LARGEST_NON_HUMONGOUS.getCls(humongousClassLoader, wrkDir, SAMPLE_CLASS_NAME_PREFIX) + .newInstance(), + G1SampleClass.SMALLEST_HUMONGOUS.getCls(humongousClassLoader, wrkDir, SAMPLE_CLASS_NAME_PREFIX) + .newInstance(), + G1SampleClass.ONE_REGION_HUMONGOUS.getCls(humongousClassLoader, wrkDir, SAMPLE_CLASS_NAME_PREFIX) + .newInstance(), + G1SampleClass.TWO_REGION_HUMONGOUS.getCls(humongousClassLoader, wrkDir, SAMPLE_CLASS_NAME_PREFIX) + .newInstance(), + }; + + // forgetting references to loaded classes + for (int i = 0; i < loadedClasses.length; ++i) { + loadedClasses[i] = null; + } + + // forgetting referencies to classloaders + humongousClassLoader = null; + humongousClassLoaderClass = null; + + simpleClassLoader = null; + simpleClassLoaderClass = null; + + gc.provoke(); + + // Test checks + Asserts.assertEquals(WB.isClassAlive(HUMONGOUS_CLASSLOADER_NAME), false, + String.format("Classloader class %s is loaded after we forget all references to it", + HUMONGOUS_CLASSLOADER_NAME)); + + for (G1SampleClass sampleClass : G1SampleClass.values()) { + String className = Helpers.enumNameToClassName(sampleClass.name()) + "Class"; + Asserts.assertEquals(WB.isClassAlive(className), false, + String.format("Class %s is loaded after we forget all references to it", className)); + } + } + +} -- GitLab From 391c11f0c2910d7857f842ca6f4bc37c6932b270 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Fri, 22 Apr 2016 00:08:43 +0200 Subject: [PATCH 183/400] 8154794: Add support for experimental fields/events to event-based tracing Reviewed-by: mlarsson, mgronlun --- hotspot/src/share/vm/trace/trace.dtd | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/trace/trace.dtd b/hotspot/src/share/vm/trace/trace.dtd index 155bea64c22..3c40dc9ac60 100644 --- a/hotspot/src/share/vm/trace/trace.dtd +++ b/hotspot/src/share/vm/trace/trace.dtd @@ -64,23 +64,28 @@ has_stacktrace CDATA "false" is_instant CDATA "false" is_constant CDATA "false" - is_requestable CDATA "false"> + is_requestable CDATA "false" + experimental CDATA "false"> + transition CDATA "NONE" + experimental CDATA "false"> + description CDATA #IMPLIED + experimental CDATA "false"> + description CDATA #IMPLIED + experimental CDATA "false"> + description CDATA #IMPLIED + experimental CDATA "false"> -- GitLab From 7cd3700010226adc02bf0dad849ed9ff89460914 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Thu, 21 Apr 2016 20:49:11 -0700 Subject: [PATCH 184/400] 8148195: Some InstanceKlass and MethodCounters fields can be excluded when JVMTI is not supported Removed "previous version", "cached class file", and breakpoint related fields and code when JVMTI is not supported Reviewed-by: coleenp, sspitsyn --- .../sun/jvm/hotspot/oops/BreakpointInfo.java | 7 ++++- .../sun/jvm/hotspot/oops/InstanceKlass.java | 7 ++++- .../classes/sun/jvm/hotspot/runtime/VM.java | 19 +++++++++++++- hotspot/src/share/vm/ci/ciMethod.cpp | 4 ++- hotspot/src/share/vm/oops/instanceKlass.cpp | 13 +++++++--- hotspot/src/share/vm/oops/instanceKlass.hpp | 26 +++++++++++++++++++ hotspot/src/share/vm/oops/method.cpp | 6 +++++ hotspot/src/share/vm/oops/method.hpp | 17 +++++++++++- hotspot/src/share/vm/oops/methodCounters.hpp | 8 ++++-- hotspot/src/share/vm/runtime/vmStructs.cpp | 14 +++++----- 10 files changed, 103 insertions(+), 18 deletions(-) diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BreakpointInfo.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BreakpointInfo.java index af62d291e46..207810dd99b 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BreakpointInfo.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/BreakpointInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,6 +46,11 @@ public class BreakpointInfo extends VMObject { } private static synchronized void initialize(TypeDataBase db) throws WrongTypeException { + if (!VM.getVM().isJvmtiSupported()) { + // no BreakpointInfo support without JVMTI + return; + } + Type type = db.lookupType("BreakpointInfo"); origBytecodeField = type.getCIntegerField("_orig_bytecode"); diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java index d2f15f0c606..de1221628ad 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/InstanceKlass.java @@ -85,7 +85,9 @@ public class InstanceKlass extends Klass { isMarkedDependent = new CIntField(type.getCIntegerField("_is_marked_dependent"), 0); initState = new CIntField(type.getCIntegerField("_init_state"), 0); itableLen = new CIntField(type.getCIntegerField("_itable_len"), 0); - breakpoints = type.getAddressField("_breakpoints"); + if (VM.getVM().isJvmtiSupported()) { + breakpoints = type.getAddressField("_breakpoints"); + } genericSignatureIndex = new CIntField(type.getCIntegerField("_generic_signature_index"), 0); majorVersion = new CIntField(type.getCIntegerField("_major_version"), 0); minorVersion = new CIntField(type.getCIntegerField("_minor_version"), 0); @@ -837,6 +839,9 @@ public class InstanceKlass extends Klass { /** Breakpoint support (see methods on Method* for details) */ public BreakpointInfo getBreakpoints() { + if (!VM.getVM().isJvmtiSupported()) { + return null; + } Address addr = getAddress().getAddressAt(breakpoints.getOffset()); return (BreakpointInfo) VMObjectFactory.newObject(BreakpointInfo.class, addr); } diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java index 09bb426cfb3..eb1f77f5d08 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,6 +87,8 @@ public class VM { private StubRoutines stubRoutines; private Bytes bytes; + /** Flag indicating if JVMTI support is included in the build */ + private boolean isJvmtiSupported; /** Flags indicating whether we are attached to a core, C1, or C2 build */ private boolean usingClientCompiler; private boolean usingServerCompiler; @@ -336,6 +338,16 @@ public class VM { stackBias = db.lookupIntConstant("STACK_BIAS").intValue(); invocationEntryBCI = db.lookupIntConstant("InvocationEntryBci").intValue(); + // We infer the presence of JVMTI from the presence of the InstanceKlass::_breakpoints field. + { + Type type = db.lookupType("InstanceKlass"); + if (type.getField("_breakpoints", false, false) == null) { + isJvmtiSupported = false; + } else { + isJvmtiSupported = true; + } + } + // We infer the presence of C1 or C2 from a couple of fields we // already have present in the type database { @@ -701,6 +713,11 @@ public class VM { return isBigEndian; } + /** Returns true if JVMTI is supported, false otherwise */ + public boolean isJvmtiSupported() { + return isJvmtiSupported; + } + /** Returns true if this is a "core" build, false if either C1 or C2 is present */ public boolean isCore() { diff --git a/hotspot/src/share/vm/ci/ciMethod.cpp b/hotspot/src/share/vm/ci/ciMethod.cpp index cb98f25e1c3..3def804cffd 100644 --- a/hotspot/src/share/vm/ci/ciMethod.cpp +++ b/hotspot/src/share/vm/ci/ciMethod.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -202,6 +202,7 @@ void ciMethod::load_code() { _code = (address)arena->Amalloc(code_size()); memcpy(_code, me->code_base(), code_size()); +#if INCLUDE_JVMTI // Revert any breakpoint bytecodes in ci's copy if (me->number_of_breakpoints() > 0) { BreakpointInfo* bp = me->method_holder()->breakpoints(); @@ -211,6 +212,7 @@ void ciMethod::load_code() { } } } +#endif // And load the exception table. ExceptionTable exc_table(me); diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index f97f826444b..b055f6e534f 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -2032,10 +2032,11 @@ bool InstanceKlass::check_sharing_error_state() { return (old_state != is_in_error_state()); } +#if INCLUDE_JVMTI static void clear_all_breakpoints(Method* m) { m->clear_all_breakpoints(); } - +#endif void InstanceKlass::notify_unload_class(InstanceKlass* ik) { // notify the debugger @@ -2097,6 +2098,7 @@ void InstanceKlass::release_C_heap_structures() { // DC::remove_all_dependents() when it touches unloaded nmethod. dependencies().wipe(); +#if INCLUDE_JVMTI // Deallocate breakpoint records if (breakpoints() != 0x0) { methods_do(clear_all_breakpoints); @@ -2108,6 +2110,7 @@ void InstanceKlass::release_C_heap_structures() { os::free(_cached_class_file); _cached_class_file = NULL; } +#endif // Decrement symbol reference counts associated with the unloaded class. if (_name != NULL) _name->decrement_refcount(); @@ -2841,7 +2844,7 @@ void InstanceKlass::print_on(outputStream* st) const { { bool have_pv = false; // previous versions are linked together through the InstanceKlass - for (InstanceKlass* pv_node = _previous_versions; + for (InstanceKlass* pv_node = previous_versions(); pv_node != NULL; pv_node = pv_node->previous_versions()) { if (!have_pv) @@ -3334,7 +3337,7 @@ void InstanceKlass::set_init_state(ClassState state) { } #endif - +#if INCLUDE_JVMTI // RedefineClasses() support for previous versions: int InstanceKlass::_previous_version_count = 0; @@ -3549,6 +3552,7 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, _previous_version_count++; } // end add_previous_version() +#endif // INCLUDE_JVMTI Method* InstanceKlass::method_with_idnum(int idnum) { Method* m = NULL; @@ -3598,7 +3602,7 @@ Method* InstanceKlass::method_with_orig_idnum(int idnum, int version) { return method; } - +#if INCLUDE_JVMTI jint InstanceKlass::get_cached_class_file_len() { return VM_RedefineClasses::get_cached_class_file_len(_cached_class_file); } @@ -3606,3 +3610,4 @@ jint InstanceKlass::get_cached_class_file_len() { unsigned char * InstanceKlass::get_cached_class_file_bytes() { return VM_RedefineClasses::get_cached_class_file_bytes(_cached_class_file); } +#endif diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 768b3535ab4..4fc5711a925 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -57,7 +57,9 @@ // forward declaration for class -- see below for definition +#if INCLUDE_JVMTI class BreakpointInfo; +#endif class ClassFileParser; class KlassDepChange; class DependencyContext; @@ -230,12 +232,14 @@ class InstanceKlass: public Klass { jmethodID* _methods_jmethod_ids; // jmethodIDs corresponding to method_idnum, or NULL if none intptr_t _dep_context; // packed DependencyContext structure nmethod* _osr_nmethods_head; // Head of list of on-stack replacement nmethods for this class +#if INCLUDE_JVMTI BreakpointInfo* _breakpoints; // bpt lists, managed by Method* // Linked instanceKlasses of previous versions InstanceKlass* _previous_versions; // JVMTI fields can be moved to their own structure - see 6315920 // JVMTI: cached class file, before retransformable agent modified it in CFLH JvmtiCachedClassFileData* _cached_class_file; +#endif volatile u2 _idnum_allocated_count; // JNI/JVMTI: increments with the addition of methods, old ids don't change @@ -245,7 +249,9 @@ class InstanceKlass: public Klass { u1 _init_state; // state of class u1 _reference_type; // reference type +#if INCLUDE_JVMTI JvmtiCachedClassFieldMap* _jvmti_cached_class_field_map; // JVMTI: used during heap iteration +#endif NOT_PRODUCT(int _verify_count;) // to avoid redundant verifies @@ -687,10 +693,14 @@ class InstanceKlass: public Klass { _nonstatic_oop_map_size = words; } +#if INCLUDE_JVMTI // RedefineClasses() support for previous versions: void add_previous_version(instanceKlassHandle ikh, int emcp_method_count); InstanceKlass* previous_versions() const { return _previous_versions; } +#else + InstanceKlass* previous_versions() const { return NULL; } +#endif InstanceKlass* get_klass_version(int version) { for (InstanceKlass* ik = this; ik != NULL; ik = ik->previous_versions()) { @@ -738,6 +748,8 @@ public: bool is_mirror_instance_klass() const { return is_kind(_misc_kind_mirror); } bool is_class_loader_instance_klass() const { return is_kind(_misc_kind_class_loader); } +#if INCLUDE_JVMTI + void init_previous_versions() { _previous_versions = NULL; } @@ -764,6 +776,16 @@ public: return _jvmti_cached_class_field_map; } +#else // INCLUDE_JVMTI + + static void purge_previous_versions(InstanceKlass* ik) { return; }; + static bool has_previous_versions() { return false; } + + void set_cached_class_file(JvmtiCachedClassFileData *data) { ShouldNotReachHere(); } + JvmtiCachedClassFileData * get_cached_class_file() { return (JvmtiCachedClassFileData *)NULL; } + +#endif // INCLUDE_JVMTI + bool has_default_methods() const { return (_misc_flags & _misc_has_default_methods) != 0; } @@ -882,9 +904,11 @@ public: int mark_osr_nmethods(const Method* m); nmethod* lookup_osr_nmethod(const Method* m, int bci, int level, bool match_level) const; +#if INCLUDE_JVMTI // Breakpoint support (see methods on Method* for details) BreakpointInfo* breakpoints() const { return _breakpoints; }; void set_breakpoints(BreakpointInfo* bps) { _breakpoints = bps; }; +#endif // support for stub routines static ByteSize init_state_offset() { return in_ByteSize(offset_of(InstanceKlass, _init_state)); } @@ -1253,9 +1277,11 @@ private: // Free CHeap allocated fields. void release_C_heap_structures(); +#if INCLUDE_JVMTI // RedefineClasses support void link_previous_versions(InstanceKlass* pv) { _previous_versions = pv; } void mark_newly_obsolete_methods(Array* old_methods, int emcp_method_count); +#endif public: // CDS support - remove and restore oops from metadata. Oops are not shared. virtual void remove_unshareable_info(); diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index b3f2b868b64..1b344917c33 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -1639,6 +1639,7 @@ bool CompressedLineNumberReadStream::read_pair() { return true; } +#if INCLUDE_JVMTI Bytecodes::Code Method::orig_bytecode_at(int bci) const { BreakpointInfo* bp = method_holder()->breakpoints(); @@ -1719,6 +1720,7 @@ void Method::clear_all_breakpoints() { clear_matches(this, -1); } +#endif // INCLUDE_JVMTI int Method::invocation_count() { MethodCounters *mcs = method_counters(); @@ -1784,6 +1786,8 @@ void Method::set_highest_osr_comp_level(int level) { } } +#if INCLUDE_JVMTI + BreakpointInfo::BreakpointInfo(Method* m, int bci) { _bci = bci; _name_index = m->name_index(); @@ -1821,6 +1825,8 @@ void BreakpointInfo::clear(Method* method) { method->decr_number_of_breakpoints(Thread::current()); } +#endif // INCLUDE_JVMTI + // jmethodID handling // This is a block allocating object, sort of like JNIHandleBlock, only a diff --git a/hotspot/src/share/vm/oops/method.hpp b/hotspot/src/share/vm/oops/method.hpp index a1acd932cea..ba14ba66fec 100644 --- a/hotspot/src/share/vm/oops/method.hpp +++ b/hotspot/src/share/vm/oops/method.hpp @@ -195,8 +195,18 @@ class Method : public Metadata { } // JVMTI breakpoints +#if !INCLUDE_JVMTI + Bytecodes::Code orig_bytecode_at(int bci) const { + ShouldNotReachHere(); + return Bytecodes::_shouldnotreachhere; + } + void set_orig_bytecode_at(int bci, Bytecodes::Code code) { + ShouldNotReachHere(); + }; + u2 number_of_breakpoints() const {return 0;} +#else // !INCLUDE_JVMTI Bytecodes::Code orig_bytecode_at(int bci) const; - void set_orig_bytecode_at(int bci, Bytecodes::Code code); + void set_orig_bytecode_at(int bci, Bytecodes::Code code); void set_breakpoint(int bci); void clear_breakpoint(int bci); void clear_all_breakpoints(); @@ -229,6 +239,7 @@ class Method : public Metadata { mcs->clear_number_of_breakpoints(); } } +#endif // !INCLUDE_JVMTI // index into InstanceKlass methods() array // note: also used by jfr @@ -1046,6 +1057,8 @@ class CompressedLineNumberReadStream: public CompressedReadStream { }; +#if INCLUDE_JVMTI + /// Fast Breakpoints. // If this structure gets more complicated (because bpts get numerous), @@ -1090,6 +1103,8 @@ class BreakpointInfo : public CHeapObj { void clear(Method* method); }; +#endif // INCLUDE_JVMTI + // Utility class for access exception handlers class ExceptionTable : public StackObj { private: diff --git a/hotspot/src/share/vm/oops/methodCounters.hpp b/hotspot/src/share/vm/oops/methodCounters.hpp index a0b96b6ba8b..2a06ab6eb2e 100644 --- a/hotspot/src/share/vm/oops/methodCounters.hpp +++ b/hotspot/src/share/vm/oops/methodCounters.hpp @@ -38,7 +38,9 @@ class MethodCounters: public MetaspaceObj { int _interpreter_invocation_count; // Count of times invoked (reused as prev_event_count in tiered) u2 _interpreter_throwout_count; // Count of times method was exited via exception while interpreting #endif +#if INCLUDE_JVMTI u2 _number_of_breakpoints; // fullspeed debugging support +#endif InvocationCounter _invocation_counter; // Incremented before each activation of the method - used to trigger frequency-based optimizations InvocationCounter _backedge_counter; // Incremented before each backedge taken - used to trigger frequencey-based optimizations // NMethod age is a counter for warm methods detection in the code cache sweeper. @@ -62,8 +64,7 @@ class MethodCounters: public MetaspaceObj { u1 _highest_osr_comp_level; // Same for OSR level #endif - MethodCounters(methodHandle mh) : _number_of_breakpoints(0), - _nmethod_age(INT_MAX) + MethodCounters(methodHandle mh) : _nmethod_age(INT_MAX) #ifdef TIERED , _rate(0), _prev_time(0), @@ -73,6 +74,7 @@ class MethodCounters: public MetaspaceObj { { set_interpreter_invocation_count(0); set_interpreter_throwout_count(0); + JVMTI_ONLY(clear_number_of_breakpoints()); invocation_counter()->init(); backedge_counter()->init(); @@ -153,10 +155,12 @@ class MethodCounters: public MetaspaceObj { #endif // defined(COMPILER2) || INCLUDE_JVMCI +#if INCLUDE_JVMTI u2 number_of_breakpoints() const { return _number_of_breakpoints; } void incr_number_of_breakpoints() { ++_number_of_breakpoints; } void decr_number_of_breakpoints() { --_number_of_breakpoints; } void clear_number_of_breakpoints() { _number_of_breakpoints = 0; } +#endif #ifdef TIERED jlong prev_time() const { return _prev_time; } diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index c5f1fd01f19..43b513fced6 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -337,7 +337,7 @@ typedef CompactHashtable SymbolCompactHashTable; volatile_nonstatic_field(InstanceKlass, _oop_map_cache, OopMapCache*) \ nonstatic_field(InstanceKlass, _jni_ids, JNIid*) \ nonstatic_field(InstanceKlass, _osr_nmethods_head, nmethod*) \ - nonstatic_field(InstanceKlass, _breakpoints, BreakpointInfo*) \ + JVMTI_ONLY(nonstatic_field(InstanceKlass, _breakpoints, BreakpointInfo*)) \ nonstatic_field(InstanceKlass, _generic_signature_index, u2) \ nonstatic_field(InstanceKlass, _methods_jmethod_ids, jmethodID*) \ volatile_nonstatic_field(InstanceKlass, _idnum_allocated_count, u2) \ @@ -387,7 +387,7 @@ typedef CompactHashtable SymbolCompactHashTable; nonstatic_field(MethodCounters, _backedge_mask, int) \ COMPILER2_OR_JVMCI_PRESENT(nonstatic_field(MethodCounters, _interpreter_invocation_count, int)) \ COMPILER2_OR_JVMCI_PRESENT(nonstatic_field(MethodCounters, _interpreter_throwout_count, u2)) \ - nonstatic_field(MethodCounters, _number_of_breakpoints, u2) \ + JVMTI_ONLY(nonstatic_field(MethodCounters, _number_of_breakpoints, u2)) \ nonstatic_field(MethodCounters, _invocation_counter, InvocationCounter) \ nonstatic_field(MethodCounters, _backedge_counter, InvocationCounter) \ nonstatic_field(Method, _constMethod, ConstMethod*) \ @@ -447,11 +447,11 @@ typedef CompactHashtable SymbolCompactHashTable; nonstatic_field(ExceptionTableElement, end_pc, u2) \ nonstatic_field(ExceptionTableElement, handler_pc, u2) \ nonstatic_field(ExceptionTableElement, catch_type_index, u2) \ - nonstatic_field(BreakpointInfo, _orig_bytecode, Bytecodes::Code) \ - nonstatic_field(BreakpointInfo, _bci, int) \ - nonstatic_field(BreakpointInfo, _name_index, u2) \ - nonstatic_field(BreakpointInfo, _signature_index, u2) \ - nonstatic_field(BreakpointInfo, _next, BreakpointInfo*) \ + JVMTI_ONLY(nonstatic_field(BreakpointInfo, _orig_bytecode, Bytecodes::Code)) \ + JVMTI_ONLY(nonstatic_field(BreakpointInfo, _bci, int)) \ + JVMTI_ONLY(nonstatic_field(BreakpointInfo, _name_index, u2)) \ + JVMTI_ONLY(nonstatic_field(BreakpointInfo, _signature_index, u2)) \ + JVMTI_ONLY(nonstatic_field(BreakpointInfo, _next, BreakpointInfo*)) \ /***********/ \ /* JNI IDs */ \ /***********/ \ -- GitLab From 78d48b8beee4bfc38e4c3caf43c25097697d427b Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Fri, 22 Apr 2016 10:19:22 +0200 Subject: [PATCH 185/400] 8154838: G1CardLiveData::free_large_bitmap() uses wrong calculation to determine the number of words Use the exact same calculation as G1CardLiveData::allocate_large_bitmap() in free_large_bitmap(). Reviewed-by: stefank, jmasa --- hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp b/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp index 028ee3f5cbc..05c8b9c0252 100644 --- a/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp @@ -60,7 +60,7 @@ G1CardLiveData::bm_word_t* G1CardLiveData::allocate_large_bitmap(size_t size_in_ } void G1CardLiveData::free_large_bitmap(bm_word_t* bitmap, size_t size_in_bits) { - MmapArrayAllocator::free(bitmap, size_in_bits / BitsPerWord); + MmapArrayAllocator::free(bitmap, BitMap::calc_size_in_words(size_in_bits)); } void G1CardLiveData::initialize(size_t max_capacity, uint num_max_regions) { -- GitLab From 651e264d3c92d4a4f78411912336597b9bfd8e65 Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Fri, 22 Apr 2016 14:30:58 +0200 Subject: [PATCH 186/400] 8154210: Zero: Better byte behaviour Complete support for 8132051 on Zero and fix failure on 64-bit big-endian systems Reviewed-by: andrew, chrisphi, coleenp --- hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp | 11 +++++++++-- .../src/share/vm/interpreter/bytecodeInterpreter.cpp | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp index e05e6d65bc0..9a85f43a2ec 100644 --- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp +++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp @@ -221,9 +221,16 @@ void CppInterpreter::main_loop(int recurse, TRAPS) { // Push our result for (int i = 0; i < result_slots; i++) { // Adjust result to smaller - intptr_t res = result[-i]; + union { + intptr_t res; + jint res_jint; + }; + res = result[-i]; if (result_slots == 1) { - res = narrow(method->result_type(), res); + BasicType t = method->result_type(); + if (is_subword_type(t)) { + res_jint = (jint)narrow(t, res_jint); + } } stack->push(res); } diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp index 2b42fab10b9..179940d7e22 100644 --- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp +++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp @@ -578,8 +578,9 @@ BytecodeInterpreter::run(interpreterState istate) { /* 0xDC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, /* 0xE0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, -/* 0xE4 */ &&opc_default, &&opc_fast_aldc, &&opc_fast_aldc_w, &&opc_return_register_finalizer, -/* 0xE8 */ &&opc_invokehandle,&&opc_default, &&opc_default, &&opc_default, +/* 0xE4 */ &&opc_default, &&opc_default, &&opc_fast_aldc, &&opc_fast_aldc_w, +/* 0xE8 */ &&opc_return_register_finalizer, + &&opc_invokehandle, &&opc_default, &&opc_default, /* 0xEC */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, /* 0xF0 */ &&opc_default, &&opc_default, &&opc_default, &&opc_default, -- GitLab From dafa24689bf28d43364b43edb697676822dd96bd Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 22 Apr 2016 14:57:18 +0200 Subject: [PATCH 187/400] 8154921: Fix aix after "8146879: Add option for handling existing log files in UL" Rename os::fileno to os::get_fileno because AIX defines macro 'fileno'. Reviewed-by: coleenp --- hotspot/src/os/posix/vm/os_posix.cpp | 4 ++-- hotspot/src/os/windows/vm/os_windows.cpp | 2 +- hotspot/src/share/vm/logging/logFileOutput.cpp | 2 +- hotspot/src/share/vm/runtime/os.hpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp index 1c6efe5b513..065d44b427e 100644 --- a/hotspot/src/os/posix/vm/os_posix.cpp +++ b/hotspot/src/os/posix/vm/os_posix.cpp @@ -181,8 +181,8 @@ int os::log_vsnprintf(char* buf, size_t len, const char* fmt, va_list args) { return vsnprintf(buf, len, fmt, args); } -int os::fileno(FILE* fp) { - return ::fileno(fp); +int os::get_fileno(FILE* fp) { + return NOT_AIX(::)fileno(fp); } void os::Posix::print_load_average(outputStream* st) { diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index fa401527ed7..f4ddaba010f 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -4602,7 +4602,7 @@ int os::ftruncate(int fd, jlong length) { return 0; } -int os::fileno(FILE* fp) { +int os::get_fileno(FILE* fp) { return _fileno(fp); } diff --git a/hotspot/src/share/vm/logging/logFileOutput.cpp b/hotspot/src/share/vm/logging/logFileOutput.cpp index 7f41bd995fb..ade58459ca9 100644 --- a/hotspot/src/share/vm/logging/logFileOutput.cpp +++ b/hotspot/src/share/vm/logging/logFileOutput.cpp @@ -252,7 +252,7 @@ bool LogFileOutput::initialize(const char* options, outputStream* errstream) { if (_file_count == 0 && is_regular_file(_file_name)) { log_trace(logging)("Truncating log file"); - os::ftruncate(os::fileno(_stream), 0); + os::ftruncate(os::get_fileno(_stream), 0); } return true; diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index d1ac2b45870..0e00e3bdb64 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -520,7 +520,7 @@ class os: AllStatic { static int ftruncate(int fd, jlong length); static int fsync(int fd); static int available(int fd, jlong *bytes); - static int fileno(FILE* fp); + static int get_fileno(FILE* fp); static int compare_file_modified_times(const char* file1, const char* file2); -- GitLab From 24d3db305cb0b02dc5c7a130fbfddd32e98f3380 Mon Sep 17 00:00:00 2001 From: Nils Eliasson Date: Fri, 22 Apr 2016 16:05:00 +0200 Subject: [PATCH 188/400] 8153527: break_tty_lock_for_safepoint causes "assert(false) failed: bad tag in log" and broken compile log Retake tty_lock before printing closing tag in print_optoassembly Reviewed-by: kvn --- hotspot/src/share/vm/opto/output.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hotspot/src/share/vm/opto/output.cpp b/hotspot/src/share/vm/opto/output.cpp index 5774d637cda..39f4abd80b6 100644 --- a/hotspot/src/share/vm/opto/output.cpp +++ b/hotspot/src/share/vm/opto/output.cpp @@ -1548,6 +1548,10 @@ void Compile::fill_buffer(CodeBuffer* cb, uint* blk_starts) { } dump_asm(node_offsets, node_offset_limit); if (xtty != NULL) { + // print_metadata and dump_asm above may safepoint which makes us loose the ttylock. + // Retake lock too make sure the end tag is coherent, and that xmlStream->pop_tag is done + // thread safe + ttyLocker ttyl2; xtty->tail("opto_assembly"); } } -- GitLab From 14a8adfd9fe6eb5511933e8afa8b270e028cedb8 Mon Sep 17 00:00:00 2001 From: Michail Chernov Date: Fri, 22 Apr 2016 17:46:06 +0300 Subject: [PATCH 189/400] 8154843: GC tests should be correctly marked with @module Reviewed-by: jwilhelm, dfazunen --- hotspot/test/gc/TestDisableExplicitGC.java | 3 ++- hotspot/test/gc/g1/TestGreyReclaimedHumongousObjects.java | 3 ++- hotspot/test/gc/parallel/TestDynShrinkHeap.java | 3 ++- hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java | 4 +++- hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java | 4 +++- 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/hotspot/test/gc/TestDisableExplicitGC.java b/hotspot/test/gc/TestDisableExplicitGC.java index 10199fd0bb0..ebe98b1315b 100644 --- a/hotspot/test/gc/TestDisableExplicitGC.java +++ b/hotspot/test/gc/TestDisableExplicitGC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @requires vm.opt.DisableExplicitGC == null * @summary Verify GC behavior with DisableExplicitGC flag. * @library /testlibrary + * @modules jdk.management/com.sun.management.internal * @run main/othervm -Xlog:gc=debug TestDisableExplicitGC * @run main/othervm/fail -XX:+DisableExplicitGC -Xlog:gc=debug TestDisableExplicitGC * @run main/othervm -XX:-DisableExplicitGC -Xlog:gc=debug TestDisableExplicitGC diff --git a/hotspot/test/gc/g1/TestGreyReclaimedHumongousObjects.java b/hotspot/test/gc/g1/TestGreyReclaimedHumongousObjects.java index 4c88649d1b2..f572ed0b757 100644 --- a/hotspot/test/gc/g1/TestGreyReclaimedHumongousObjects.java +++ b/hotspot/test/gc/g1/TestGreyReclaimedHumongousObjects.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ * @requires vm.gc == "G1" | vm.gc == "null" * @summary Test handling of marked but unscanned reclaimed humongous objects. * @key gc + * @modules jdk.management * @run main/othervm -XX:+UseG1GC -Xss32m -Xmx128m -XX:G1HeapRegionSize=1m * -XX:+UnlockExperimentalVMOptions * -XX:+G1EagerReclaimHumongousObjects diff --git a/hotspot/test/gc/parallel/TestDynShrinkHeap.java b/hotspot/test/gc/parallel/TestDynShrinkHeap.java index a71f335ae15..ef2a6b41f62 100644 --- a/hotspot/test/gc/parallel/TestDynShrinkHeap.java +++ b/hotspot/test/gc/parallel/TestDynShrinkHeap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @bug 8016479 * @requires vm.gc=="Parallel" | vm.gc=="null" * @summary Verify that the heap shrinks after full GC according to the current values of the Min/MaxHeapFreeRatio flags + * @modules jdk.management * @library /testlibrary * @run main/othervm -XX:+UseAdaptiveSizePolicyWithSystemGC -XX:+UseParallelGC -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 -Xmx1g -verbose:gc TestDynShrinkHeap */ diff --git a/hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java b/hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java index 1e53a234b5a..1e1e61167a4 100644 --- a/hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java +++ b/hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,8 @@ import jdk.test.lib.dcmd.PidJcmdExecutor; * @test * @summary * @library /testlibrary + * @modules java.xml + * java.management * @build jdk.test.lib.* * @build jdk.test.lib.dcmd.* * @run testng FinalizerInfoTest diff --git a/hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java b/hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java index daedf1252ef..d6f325260b0 100644 --- a/hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java +++ b/hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,8 @@ import jdk.test.lib.OutputAnalyzer; * @test * @summary Test of diagnostic command GC.heap_info * @library /testlibrary + * @modules java.xml + * java.management * @build jdk.test.lib.* * @build jdk.test.lib.dcmd.* * @run testng HeapInfoTest -- GitLab From 4397d916425ca91513b5bac40c0391e784891456 Mon Sep 17 00:00:00 2001 From: Michail Chernov Date: Fri, 22 Apr 2016 17:49:15 +0300 Subject: [PATCH 190/400] 8154759: [TESTBUG] GC tests should be changed to be able to execute with -Xlog:all=trace Reviewed-by: jmasa, dfazunen --- hotspot/test/gc/TestVerifySilently.java | 13 +++---------- hotspot/test/gc/TestVerifySubSet.java | 11 ++--------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/hotspot/test/gc/TestVerifySilently.java b/hotspot/test/gc/TestVerifySilently.java index 864a1ef8d03..a387ae4df41 100644 --- a/hotspot/test/gc/TestVerifySilently.java +++ b/hotspot/test/gc/TestVerifySilently.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ import jdk.test.lib.OutputAnalyzer; import jdk.test.lib.ProcessTools; import java.util.ArrayList; import java.util.Collections; +import jdk.test.lib.Utils; class RunSystemGC { public static void main(String args[]) throws Exception { @@ -43,19 +44,11 @@ class RunSystemGC { public class TestVerifySilently { - private static String[] getTestJavaOpts() { - String testVmOptsStr = System.getProperty("test.java.opts"); - if (!testVmOptsStr.isEmpty()) { - return testVmOptsStr.split(" "); - } else { - return new String[] {}; - } - } private static OutputAnalyzer runTest(boolean verifySilently) throws Exception { ArrayList vmOpts = new ArrayList(); - Collections.addAll(vmOpts, getTestJavaOpts()); + Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*")); Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions", "-XX:+VerifyDuringStartup", "-XX:+VerifyBeforeGC", diff --git a/hotspot/test/gc/TestVerifySubSet.java b/hotspot/test/gc/TestVerifySubSet.java index 7126b9658b5..9208d478247 100644 --- a/hotspot/test/gc/TestVerifySubSet.java +++ b/hotspot/test/gc/TestVerifySubSet.java @@ -34,6 +34,7 @@ import jdk.test.lib.OutputAnalyzer; import jdk.test.lib.ProcessTools; import java.util.ArrayList; import java.util.Collections; +import jdk.test.lib.Utils; class RunSystemGC { public static void main(String args[]) throws Exception { @@ -42,19 +43,11 @@ class RunSystemGC { } public class TestVerifySubSet { - private static String[] getTestJavaOpts() { - String testVmOptsStr = System.getProperty("test.java.opts"); - if (!testVmOptsStr.isEmpty()) { - return testVmOptsStr.split(" "); - } else { - return new String[] {}; - } - } private static OutputAnalyzer runTest(String subset) throws Exception { ArrayList vmOpts = new ArrayList(); - Collections.addAll(vmOpts, getTestJavaOpts()); + Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*")); Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions", "-XX:+VerifyBeforeGC", "-XX:+VerifyAfterGC", -- GitLab From 0fc708181a806bc5b055eb86f016d93a58c855d9 Mon Sep 17 00:00:00 2001 From: Michail Chernov Date: Fri, 22 Apr 2016 18:19:29 +0300 Subject: [PATCH 191/400] 8154341: [TESTBUG] G1 stress test for humongous objects allocation Reviewed-by: jwilhelm, dfazunen --- .../test/gc/stress/TestStressG1Humongous.java | 201 ++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 hotspot/test/gc/stress/TestStressG1Humongous.java diff --git a/hotspot/test/gc/stress/TestStressG1Humongous.java b/hotspot/test/gc/stress/TestStressG1Humongous.java new file mode 100644 index 00000000000..91a5f06a421 --- /dev/null +++ b/hotspot/test/gc/stress/TestStressG1Humongous.java @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + /* + * @test TestStressG1Humongous + * @key gc + * @key stress + * @summary Stress G1 by humongous allocations in situation near OOM + * @requires vm.gc=="G1" | vm.gc=="null" + * @run main/othervm/timeout=200 -Xlog:gc=debug -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=4m + * -Dtimeout=120 -Dthreads=3 -Dhumongoussize=1.1 -Dregionsize=4 TestStressG1Humongous + * @run main/othervm/timeout=200 -Xlog:gc=debug -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=16m + * -Dtimeout=120 -Dthreads=5 -Dhumongoussize=2.1 -Dregionsize=16 TestStressG1Humongous + * @run main/othervm/timeout=200 -Xlog:gc=debug -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=32m + * -Dtimeout=120 -Dthreads=4 -Dhumongoussize=0.6 -Dregionsize=32 TestStressG1Humongous + * @run main/othervm/timeout=700 -Xlog:gc=debug -Xmx1g -XX:+UseG1GC -XX:G1HeapRegionSize=1m + * -Dtimeout=600 -Dthreads=7 -Dhumongoussize=0.6 -Dregionsize=1 TestStressG1Humongous + */ + +import java.util.ArrayList; +import java.util.List; +import java.util.Collections; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicInteger; + +public class TestStressG1Humongous { + + // Timeout in seconds + private static final int TIMEOUT = Integer.getInteger("timeout", 60); + private static final int THREAD_COUNT = Integer.getInteger("threads", 2); + private static final int REGION_SIZE = Integer.getInteger("regionsize", 1) * 1024 * 1024; + private static final int HUMONGOUS_SIZE = (int) (REGION_SIZE * Double.parseDouble(System.getProperty("humongoussize", "1.5"))); + + private volatile boolean isRunning; + private final ExecutorService threadExecutor; + private final AtomicInteger alocatedObjectsCount; + private CountDownLatch countDownLatch; + public static final List GARBAGE = Collections.synchronizedList(new ArrayList<>()); + + public static void main(String[] args) throws InterruptedException { + new TestStressG1Humongous().run(); + } + + public TestStressG1Humongous() { + isRunning = true; + threadExecutor = Executors.newFixedThreadPool(THREAD_COUNT + 1); + alocatedObjectsCount = new AtomicInteger(0); + } + + private void run() throws InterruptedException { + threadExecutor.submit(new Timer()); + int checkedAmountOfHObjects = getExpectedAmountOfObjects(); + while (isRunning()) { + countDownLatch = new CountDownLatch(THREAD_COUNT); + startAllocationThreads(checkedAmountOfHObjects); + countDownLatch.await(); + GARBAGE.clear(); + System.out.println("Allocated " + alocatedObjectsCount.get() + " objects."); + alocatedObjectsCount.set(0); + } + threadExecutor.shutdown(); + System.out.println("Done!"); + } + + /** + * Tries to fill available memory with humongous objects to get expected amount. + * @return expected amount of humongous objects + */ + private int getExpectedAmountOfObjects() { + long maxMem = Runtime.getRuntime().maxMemory(); + int expectedHObjects = (int) (maxMem / HUMONGOUS_SIZE); + // Will allocate 1 region less to give some free space for VM. + int checkedAmountOfHObjects = checkHeapCapacity(expectedHObjects) - 1; + return checkedAmountOfHObjects; + } + + /** + * Starts several threads to allocate the requested amount of humongous objects. + * @param totalObjects total amount of object that will be created + */ + private void startAllocationThreads(int totalObjects) { + int objectsPerThread = totalObjects / THREAD_COUNT; + int objectsForLastThread = objectsPerThread + totalObjects % THREAD_COUNT; + for (int i = 0; i < THREAD_COUNT - 1; ++i) { + threadExecutor.submit(new AllocationThread(countDownLatch, objectsPerThread, alocatedObjectsCount)); + } + threadExecutor.submit(new AllocationThread(countDownLatch, objectsForLastThread, alocatedObjectsCount)); + } + + /** + * Creates a humongous object of the predefined size. + */ + private void createObject() { + GARBAGE.add(new byte[HUMONGOUS_SIZE]); + } + + /** + * Tries to create the requested amount of humongous objects. + * In case of OOME, stops creating and cleans the created garbage. + * @param expectedObjects amount of objects based on heap size + * @return amount of created objects + */ + private int checkHeapCapacity(int expectedObjects) { + int allocated = 0; + try { + while (isRunning() && allocated < expectedObjects) { + createObject(); + ++allocated; + } + } catch (OutOfMemoryError oome) { + GARBAGE.clear(); + } + return allocated; + } + + private void setDone() { + isRunning = false; + } + + private boolean isRunning() { + return isRunning; + } + + /** + * Thread which allocates requested amount of humongous objects. + */ + private class AllocationThread implements Runnable { + + private final int totalObjects; + private final CountDownLatch cdl; + private final AtomicInteger allocationCounter; + + /** + * Creates allocation thread + * @param cdl CountDownLatch + * @param objects amount of objects to allocate + * @param counter + */ + public AllocationThread(CountDownLatch cdl, int objects, AtomicInteger counter) { + totalObjects = objects; + this.cdl = cdl; + allocationCounter = counter; + } + + @Override + public void run() { + int allocatedObjects = 0; + try { + while (isRunning && allocatedObjects < totalObjects) { + createObject(); + allocatedObjects++; + allocationCounter.incrementAndGet(); + } + + } catch (OutOfMemoryError oome) { + GARBAGE.clear(); + System.out.print("OOME was caught."); + System.out.println(" Allocated in thread: " + allocatedObjects + " . Totally allocated: " + allocationCounter.get() + "."); + } finally { + cdl.countDown(); + } + } + } + + /** + * Simple Runnable which waits TIMEOUT and sets isRunning to false. + */ + class Timer implements Runnable { + + @Override + public void run() { + try { + Thread.sleep(TIMEOUT * 1000); + } catch (InterruptedException ex) { + } + setDone(); + } + } +} -- GitLab From d88ba0b30d287fc61c74c6222a9a0c4d7d82f044 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Sat, 23 Apr 2016 15:21:48 -0400 Subject: [PATCH 192/400] 8154566: os_linux.cpp parse_os_info gives non descriptive output on current SLES releases For SuSE, read the first line of the /etc/xrelease file, also get PRETTY_NAME from /etc/os_release Reviewed-by: gthornbr, coleenp --- hotspot/src/os/linux/vm/os_linux.cpp | 38 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index 4889870e8f4..a47c67c6648 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -2013,8 +2013,8 @@ void os::print_os_info(outputStream* st) { // their own specific XXX-release file as well as a redhat-release file. // Because of this the XXX-release file needs to be searched for before the // redhat-release file. -// Since Red Hat has a lsb-release file that is not very descriptive the -// search for redhat-release needs to be before lsb-release. +// Since Red Hat and SuSE have an lsb-release file that is not very descriptive the +// search for redhat-release / SuSE-release needs to be before lsb-release. // Since the lsb-release file is the new standard it needs to be searched // before the older style release files. // Searching system-release (Red Hat) and os-release (other Linuxes) are a @@ -2031,8 +2031,8 @@ const char* distro_files[] = { "/etc/mandrake-release", "/etc/sun-release", "/etc/redhat-release", - "/etc/lsb-release", "/etc/SuSE-release", + "/etc/lsb-release", "/etc/turbolinux-release", "/etc/gentoo-release", "/etc/ltib-release", @@ -2062,14 +2062,11 @@ void os::Linux::print_distro_info(outputStream* st) { st->cr(); } -static void parse_os_info(char* distro, size_t length, const char* file) { - FILE* fp = fopen(file, "r"); - if (fp != NULL) { - char buf[256]; - // get last line of the file. - while (fgets(buf, sizeof(buf), fp)) { } - // Edit out extra stuff in expected ubuntu format - if (strstr(buf, "DISTRIB_DESCRIPTION=") != NULL) { +static void parse_os_info_helper(FILE* fp, char* distro, size_t length, bool get_first_line) { + char buf[256]; + while (fgets(buf, sizeof(buf), fp)) { + // Edit out extra stuff in expected format + if (strstr(buf, "DISTRIB_DESCRIPTION=") != NULL || strstr(buf, "PRETTY_NAME=") != NULL) { char* ptr = strstr(buf, "\""); // the name is in quotes if (ptr != NULL) { ptr++; // go beyond first quote @@ -2083,13 +2080,26 @@ static void parse_os_info(char* distro, size_t length, const char* file) { if (nl != NULL) *nl = '\0'; strncpy(distro, ptr, length); } - } else { - // if not in expected Ubuntu format, print out whole line minus \n + return; + } else if (get_first_line) { char* nl = strchr(buf, '\n'); if (nl != NULL) *nl = '\0'; strncpy(distro, buf, length); + return; } - // close distro file + } + // print last line and close + char* nl = strchr(buf, '\n'); + if (nl != NULL) *nl = '\0'; + strncpy(distro, buf, length); +} + +static void parse_os_info(char* distro, size_t length, const char* file) { + FILE* fp = fopen(file, "r"); + if (fp != NULL) { + // if suse format, print out first line + bool get_first_line = (strcmp(file, "/etc/SuSE-release") == 0); + parse_os_info_helper(fp, distro, length, get_first_line); fclose(fp); } } -- GitLab From ebc384160f75c90ec885f47441ad007f9accb8cb Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Mon, 25 Apr 2016 10:51:44 +0200 Subject: [PATCH 193/400] 8154763: Crash with "assert(RangeCheckElimination)" if RangeCheckElimination is disabled Disable multiversioning if range check elimination is turned off. Reviewed-by: mcberg, kvn --- hotspot/src/share/vm/opto/loopTransform.cpp | 2 +- hotspot/src/share/vm/runtime/arguments.cpp | 8 ++++ .../TestRangeCheckEliminationDisabled.java | 37 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 hotspot/test/compiler/rangechecks/TestRangeCheckEliminationDisabled.java diff --git a/hotspot/src/share/vm/opto/loopTransform.cpp b/hotspot/src/share/vm/opto/loopTransform.cpp index f2bf2eff8da..7e33dc3dd84 100644 --- a/hotspot/src/share/vm/opto/loopTransform.cpp +++ b/hotspot/src/share/vm/opto/loopTransform.cpp @@ -2819,7 +2819,7 @@ bool IdealLoopTree::iteration_split_impl( PhaseIdealLoop *phase, Node_List &old_ if (phase->do_range_check(this, old_new) != 0) { cl->mark_has_range_checks(); } - } else { + } else if (PostLoopMultiversioning) { phase->has_range_checks(this); } diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index f305a8c2447..adc6c8895b5 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -2626,6 +2626,14 @@ bool Arguments::check_vm_args_consistency() { } FLAG_SET_CMDLINE(bool, UseCompiler, false); } +#ifdef COMPILER2 + if (PostLoopMultiversioning && !RangeCheckElimination) { + if (!FLAG_IS_DEFAULT(PostLoopMultiversioning)) { + warning("PostLoopMultiversioning disabled because RangeCheckElimination is disabled."); + } + FLAG_SET_CMDLINE(bool, PostLoopMultiversioning, false); + } +#endif return status; } diff --git a/hotspot/test/compiler/rangechecks/TestRangeCheckEliminationDisabled.java b/hotspot/test/compiler/rangechecks/TestRangeCheckEliminationDisabled.java new file mode 100644 index 00000000000..288af4ddca1 --- /dev/null +++ b/hotspot/test/compiler/rangechecks/TestRangeCheckEliminationDisabled.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test TestRangeCheckEliminationDisabled + * @bug 8154763 + * @summary Tests PostLoopMultiversioning with RangeCheckElimination disabled. + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+PostLoopMultiversioning -XX:-RangeCheckElimination TestRangeCheckEliminationDisabled + */ +public class TestRangeCheckEliminationDisabled { + + public static void main(String[] args) { + System.out.println("Passed"); + } +} + -- GitLab From 3a358f4cffce3304eda9f3b34207b21e7fab3cf7 Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Mon, 25 Apr 2016 10:53:42 +0200 Subject: [PATCH 194/400] 8086057: Crash with "modified node is not on IGVN._worklist" when running with -XX:-SplitIfBlocks Pre-loop Opaque1 node 'pre_opaq' should be put on the IGVN worklist after modification. Reviewed-by: kvn --- hotspot/src/share/vm/opto/superword.cpp | 3 +- .../loopopts/TestSplitIfBlocksDisabled.java | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 hotspot/test/compiler/loopopts/TestSplitIfBlocksDisabled.java diff --git a/hotspot/src/share/vm/opto/superword.cpp b/hotspot/src/share/vm/opto/superword.cpp index 7da07d6f303..8367e81b0e9 100644 --- a/hotspot/src/share/vm/opto/superword.cpp +++ b/hotspot/src/share/vm/opto/superword.cpp @@ -3230,8 +3230,7 @@ void SuperWord::align_initial_loop_index(MemNode* align_to_ref) { : (Node*) new MaxINode(lim, orig_limit); _igvn.register_new_node_with_optimizer(constrained); _phase->set_ctrl(constrained, pre_ctrl); - _igvn.hash_delete(pre_opaq); - pre_opaq->set_req(1, constrained); + _igvn.replace_input_of(pre_opaq, 1, constrained); } //----------------------------get_pre_loop_end--------------------------- diff --git a/hotspot/test/compiler/loopopts/TestSplitIfBlocksDisabled.java b/hotspot/test/compiler/loopopts/TestSplitIfBlocksDisabled.java new file mode 100644 index 00000000000..63745f7f348 --- /dev/null +++ b/hotspot/test/compiler/loopopts/TestSplitIfBlocksDisabled.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test TestSplitIfBlocksDisabled + * @bug 8086057 + * @summary Verifies that loop optimizations work if SplitIfBlocks is disabled. + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -Xcomp -XX:-SplitIfBlocks TestSplitIfBlocksDisabled + */ +public class TestSplitIfBlocksDisabled { + + public static void main(String[] args) { + System.out.println("Passed"); + } +} + -- GitLab From 9ca6318ece8e63acdb764e22c081ca32f64953a9 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Mon, 25 Apr 2016 11:36:14 +0200 Subject: [PATCH 195/400] 8017629: G1: UseSHM in combination with a G1HeapRegionSize > os::large_page_size() falls back to use small pages Reviewed-by: pliden, sjohanss, stuefe --- hotspot/src/os/linux/vm/os_linux.cpp | 212 ++++++++++++++++++--------- 1 file changed, 141 insertions(+), 71 deletions(-) diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index a47c67c6648..a9efaec274d 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -3051,6 +3051,48 @@ static char* anon_mmap(char* requested_addr, size_t bytes, bool fixed) { return addr == MAP_FAILED ? NULL : addr; } +// Allocate (using mmap, NO_RESERVE, with small pages) at either a given request address +// (req_addr != NULL) or with a given alignment. +// - bytes shall be a multiple of alignment. +// - req_addr can be NULL. If not NULL, it must be a multiple of alignment. +// - alignment sets the alignment at which memory shall be allocated. +// It must be a multiple of allocation granularity. +// Returns address of memory or NULL. If req_addr was not NULL, will only return +// req_addr or NULL. +static char* anon_mmap_aligned(size_t bytes, size_t alignment, char* req_addr) { + + size_t extra_size = bytes; + if (req_addr == NULL && alignment > 0) { + extra_size += alignment; + } + + char* start = (char*) ::mmap(req_addr, extra_size, PROT_NONE, + MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, + -1, 0); + if (start == MAP_FAILED) { + start = NULL; + } else { + if (req_addr != NULL) { + if (start != req_addr) { + ::munmap(start, extra_size); + start = NULL; + } + } else { + char* const start_aligned = (char*) align_ptr_up(start, alignment); + char* const end_aligned = start_aligned + bytes; + char* const end = start + extra_size; + if (start_aligned > start) { + ::munmap(start, start_aligned - start); + } + if (end_aligned < end) { + ::munmap(end_aligned, end - end_aligned); + } + start = start_aligned; + } + } + return start; +} + static int anon_munmap(char * addr, size_t size) { return ::munmap(addr, size) == 0; } @@ -3327,29 +3369,113 @@ void os::large_page_init() { #define SHM_HUGETLB 04000 #endif +#define shm_warning_format(format, ...) \ + do { \ + if (UseLargePages && \ + (!FLAG_IS_DEFAULT(UseLargePages) || \ + !FLAG_IS_DEFAULT(UseSHM) || \ + !FLAG_IS_DEFAULT(LargePageSizeInBytes))) { \ + warning(format, __VA_ARGS__); \ + } \ + } while (0) + +#define shm_warning(str) shm_warning_format("%s", str) + +#define shm_warning_with_errno(str) \ + do { \ + int err = errno; \ + shm_warning_format(str " (error = %d)", err); \ + } while (0) + +static char* shmat_with_alignment(int shmid, size_t bytes, size_t alignment) { + assert(is_size_aligned(bytes, alignment), "Must be divisible by the alignment"); + + if (!is_size_aligned(alignment, SHMLBA)) { + assert(false, "Code below assumes that alignment is at least SHMLBA aligned"); + return NULL; + } + + // To ensure that we get 'alignment' aligned memory from shmat, + // we pre-reserve aligned virtual memory and then attach to that. + + char* pre_reserved_addr = anon_mmap_aligned(bytes, alignment, NULL); + if (pre_reserved_addr == NULL) { + // Couldn't pre-reserve aligned memory. + shm_warning("Failed to pre-reserve aligned memory for shmat."); + return NULL; + } + + // SHM_REMAP is needed to allow shmat to map over an existing mapping. + char* addr = (char*)shmat(shmid, pre_reserved_addr, SHM_REMAP); + + if ((intptr_t)addr == -1) { + int err = errno; + shm_warning_with_errno("Failed to attach shared memory."); + + assert(err != EACCES, "Unexpected error"); + assert(err != EIDRM, "Unexpected error"); + assert(err != EINVAL, "Unexpected error"); + + // Since we don't know if the kernel unmapped the pre-reserved memory area + // we can't unmap it, since that would potentially unmap memory that was + // mapped from other threads. + return NULL; + } + + return addr; +} + +static char* shmat_at_address(int shmid, char* req_addr) { + if (!is_ptr_aligned(req_addr, SHMLBA)) { + assert(false, "Requested address needs to be SHMLBA aligned"); + return NULL; + } + + char* addr = (char*)shmat(shmid, req_addr, 0); + + if ((intptr_t)addr == -1) { + shm_warning_with_errno("Failed to attach shared memory."); + return NULL; + } + + return addr; +} + +static char* shmat_large_pages(int shmid, size_t bytes, size_t alignment, char* req_addr) { + // If a req_addr has been provided, we assume that the caller has already aligned the address. + if (req_addr != NULL) { + assert(is_ptr_aligned(req_addr, os::large_page_size()), "Must be divisible by the large page size"); + assert(is_ptr_aligned(req_addr, alignment), "Must be divisible by given alignment"); + return shmat_at_address(shmid, req_addr); + } + + // Since shmid has been setup with SHM_HUGETLB, shmat will automatically + // return large page size aligned memory addresses when req_addr == NULL. + // However, if the alignment is larger than the large page size, we have + // to manually ensure that the memory returned is 'alignment' aligned. + if (alignment > os::large_page_size()) { + assert(is_size_aligned(alignment, os::large_page_size()), "Must be divisible by the large page size"); + return shmat_with_alignment(shmid, bytes, alignment); + } else { + return shmat_at_address(shmid, NULL); + } +} + char* os::Linux::reserve_memory_special_shm(size_t bytes, size_t alignment, char* req_addr, bool exec) { // "exec" is passed in but not used. Creating the shared image for // the code cache doesn't have an SHM_X executable permission to check. assert(UseLargePages && UseSHM, "only for SHM large pages"); assert(is_ptr_aligned(req_addr, os::large_page_size()), "Unaligned address"); + assert(is_ptr_aligned(req_addr, alignment), "Unaligned address"); - if (!is_size_aligned(bytes, os::large_page_size()) || alignment > os::large_page_size()) { + if (!is_size_aligned(bytes, os::large_page_size())) { return NULL; // Fallback to small pages. } - key_t key = IPC_PRIVATE; - char *addr; - - bool warn_on_failure = UseLargePages && - (!FLAG_IS_DEFAULT(UseLargePages) || - !FLAG_IS_DEFAULT(UseSHM) || - !FLAG_IS_DEFAULT(LargePageSizeInBytes)); - char msg[128]; - // Create a large shared memory region to attach to based on size. - // Currently, size is the total size of the heap - int shmid = shmget(key, bytes, SHM_HUGETLB|IPC_CREAT|SHM_R|SHM_W); + // Currently, size is the total size of the heap. + int shmid = shmget(IPC_PRIVATE, bytes, SHM_HUGETLB|IPC_CREAT|SHM_R|SHM_W); if (shmid == -1) { // Possible reasons for shmget failure: // 1. shmmax is too small for Java heap. @@ -3365,16 +3491,12 @@ char* os::Linux::reserve_memory_special_shm(size_t bytes, size_t alignment, // they are so fragmented after a long run that they can't // coalesce into large pages. Try to reserve large pages when // the system is still "fresh". - if (warn_on_failure) { - jio_snprintf(msg, sizeof(msg), "Failed to reserve shared memory (errno = %d).", errno); - warning("%s", msg); - } + shm_warning_with_errno("Failed to reserve shared memory."); return NULL; } - // attach to the region - addr = (char*)shmat(shmid, req_addr, 0); - int err = errno; + // Attach to the region. + char* addr = shmat_large_pages(shmid, bytes, alignment, req_addr); // Remove shmid. If shmat() is successful, the actual shared memory segment // will be deleted when it's detached by shmdt() or when the process @@ -3382,14 +3504,6 @@ char* os::Linux::reserve_memory_special_shm(size_t bytes, size_t alignment, // segment immediately. shmctl(shmid, IPC_RMID, NULL); - if ((intptr_t)addr == -1) { - if (warn_on_failure) { - jio_snprintf(msg, sizeof(msg), "Failed to attach shared memory (errno = %d).", err); - warning("%s", msg); - } - return NULL; - } - return addr; } @@ -3432,50 +3546,6 @@ char* os::Linux::reserve_memory_special_huge_tlbfs_only(size_t bytes, return addr; } -// Helper for os::Linux::reserve_memory_special_huge_tlbfs_mixed(). -// Allocate (using mmap, NO_RESERVE, with small pages) at either a given request address -// (req_addr != NULL) or with a given alignment. -// - bytes shall be a multiple of alignment. -// - req_addr can be NULL. If not NULL, it must be a multiple of alignment. -// - alignment sets the alignment at which memory shall be allocated. -// It must be a multiple of allocation granularity. -// Returns address of memory or NULL. If req_addr was not NULL, will only return -// req_addr or NULL. -static char* anon_mmap_aligned(size_t bytes, size_t alignment, char* req_addr) { - - size_t extra_size = bytes; - if (req_addr == NULL && alignment > 0) { - extra_size += alignment; - } - - char* start = (char*) ::mmap(req_addr, extra_size, PROT_NONE, - MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, - -1, 0); - if (start == MAP_FAILED) { - start = NULL; - } else { - if (req_addr != NULL) { - if (start != req_addr) { - ::munmap(start, extra_size); - start = NULL; - } - } else { - char* const start_aligned = (char*) align_ptr_up(start, alignment); - char* const end_aligned = start_aligned + bytes; - char* const end = start + extra_size; - if (start_aligned > start) { - ::munmap(start, start_aligned - start); - } - if (end_aligned < end) { - ::munmap(end_aligned, end - end_aligned); - } - start = start_aligned; - } - } - return start; - -} - // Reserve memory using mmap(MAP_HUGETLB). // - bytes shall be a multiple of alignment. // - req_addr can be NULL. If not NULL, it must be a multiple of alignment. -- GitLab From de88e58a82255ac36b16776a98982b5d2ee07dd4 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Mon, 25 Apr 2016 09:51:00 -0400 Subject: [PATCH 196/400] 8154580: Save mirror in interpreter frame to enable cleanups of CLDClosure GC walks the mirror using OopClosure rather than using CLDClosure in oops_interpreted_do() Reviewed-by: dlong, twisti, stefank --- .../vm/abstractInterpreter_aarch64.cpp | 4 +- hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp | 6 ++- .../cpu/aarch64/vm/frame_aarch64.inline.hpp | 8 +++- .../cpu/aarch64/vm/macroAssembler_aarch64.cpp | 8 ++++ .../cpu/aarch64/vm/macroAssembler_aarch64.hpp | 4 +- .../templateInterpreterGenerator_aarch64.cpp | 37 ++++++++----------- .../cpu/ppc/vm/abstractInterpreter_ppc.cpp | 3 +- hotspot/src/cpu/ppc/vm/frame_ppc.hpp | 3 +- hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp | 7 +++- hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp | 8 ++++ hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp | 3 ++ .../vm/templateInterpreterGenerator_ppc.cpp | 24 ++++-------- .../sparc/vm/abstractInterpreter_sparc.cpp | 5 ++- hotspot/src/cpu/sparc/vm/frame_sparc.cpp | 4 +- hotspot/src/cpu/sparc/vm/frame_sparc.hpp | 5 ++- .../src/cpu/sparc/vm/frame_sparc.inline.hpp | 6 ++- .../src/cpu/sparc/vm/macroAssembler_sparc.cpp | 8 ++++ .../src/cpu/sparc/vm/macroAssembler_sparc.hpp | 2 + .../vm/templateInterpreterGenerator_sparc.cpp | 18 +++------ .../cpu/x86/vm/abstractInterpreter_x86.cpp | 4 +- hotspot/src/cpu/x86/vm/frame_x86.cpp | 3 +- hotspot/src/cpu/x86/vm/frame_x86.hpp | 3 +- hotspot/src/cpu/x86/vm/frame_x86.inline.hpp | 8 +++- hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp | 8 ++++ hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp | 2 + .../vm/templateInterpreterGenerator_x86.cpp | 16 +++----- .../cpu/zero/vm/bytecodeInterpreter_zero.cpp | 2 + .../cpu/zero/vm/bytecodeInterpreter_zero.hpp | 5 ++- .../src/cpu/zero/vm/cppInterpreter_zero.cpp | 1 + hotspot/src/cpu/zero/vm/frame_zero.inline.hpp | 6 ++- hotspot/src/share/vm/gc/g1/g1RootClosures.cpp | 4 +- hotspot/src/share/vm/gc/g1/g1RootClosures.hpp | 5 +-- .../src/share/vm/gc/g1/g1RootProcessor.cpp | 8 +--- hotspot/src/share/vm/gc/parallel/pcTasks.cpp | 6 +-- .../src/share/vm/gc/parallel/psMarkSweep.cpp | 6 +-- .../vm/gc/parallel/psParallelCompact.cpp | 3 +- hotspot/src/share/vm/gc/parallel/psTasks.cpp | 8 ++-- .../share/vm/gc/shared/genCollectedHeap.cpp | 5 +-- .../vm/interpreter/bytecodeInterpreter.hpp | 3 +- .../src/share/vm/runtime/deoptimization.cpp | 2 +- hotspot/src/share/vm/runtime/frame.cpp | 35 +++++++++--------- hotspot/src/share/vm/runtime/frame.hpp | 11 ++++-- hotspot/src/share/vm/runtime/thread.cpp | 28 +++++++------- hotspot/src/share/vm/runtime/thread.hpp | 11 +++--- hotspot/src/share/vm/runtime/vmThread.cpp | 6 +-- hotspot/src/share/vm/runtime/vmThread.hpp | 4 +- hotspot/test/TEST.groups | 2 +- .../{8003720 => MirrorFrame}/Asmator.java | 0 .../{8003720 => MirrorFrame}/Test8003720.java | 0 .../{8003720 => MirrorFrame}/Victim.java | 0 .../VictimClassLoader.java | 0 51 files changed, 202 insertions(+), 166 deletions(-) rename hotspot/test/runtime/{8003720 => MirrorFrame}/Asmator.java (100%) rename hotspot/test/runtime/{8003720 => MirrorFrame}/Test8003720.java (100%) rename hotspot/test/runtime/{8003720 => MirrorFrame}/Victim.java (100%) rename hotspot/test/runtime/{8003720 => MirrorFrame}/VictimClassLoader.java (100%) diff --git a/hotspot/src/cpu/aarch64/vm/abstractInterpreter_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/abstractInterpreter_aarch64.cpp index 77f49a72854..a09f2684af6 100644 --- a/hotspot/src/cpu/aarch64/vm/abstractInterpreter_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/abstractInterpreter_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -177,4 +177,6 @@ void AbstractInterpreter::layout_activation(Method* method, } *interpreter_frame->interpreter_frame_cache_addr() = method->constants()->cache(); + *interpreter_frame->interpreter_frame_mirror_addr() = + method->method_holder()->java_mirror(); } diff --git a/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp index 4332abce9f4..0b5fd32974d 100644 --- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -78,7 +78,9 @@ interpreter_frame_last_sp_offset = interpreter_frame_sender_sp_offset - 1, interpreter_frame_method_offset = interpreter_frame_last_sp_offset - 1, interpreter_frame_mdp_offset = interpreter_frame_method_offset - 1, - interpreter_frame_cache_offset = interpreter_frame_mdp_offset - 1, + interpreter_frame_padding_offset = interpreter_frame_mdp_offset - 1, + interpreter_frame_mirror_offset = interpreter_frame_padding_offset - 1, + interpreter_frame_cache_offset = interpreter_frame_mirror_offset - 1, interpreter_frame_locals_offset = interpreter_frame_cache_offset - 1, interpreter_frame_bcp_offset = interpreter_frame_locals_offset - 1, interpreter_frame_initial_sp_offset = interpreter_frame_bcp_offset - 1, diff --git a/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp b/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp index 7fce68be5b9..f652d6ce4c2 100644 --- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp +++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -188,6 +188,12 @@ inline Method** frame::interpreter_frame_method_addr() const { return (Method**)addr_at(interpreter_frame_method_offset); } +// Mirror + +inline oop* frame::interpreter_frame_mirror_addr() const { + return (oop*)addr_at(interpreter_frame_mirror_offset); +} + // top of expression stack inline intptr_t* frame::interpreter_frame_tos_address() const { intptr_t* last_sp = interpreter_frame_last_sp(); diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp index 84ff5f84ed4..4a3823c662e 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp @@ -3217,6 +3217,14 @@ void MacroAssembler::load_klass(Register dst, Register src) { } } +void MacroAssembler::load_mirror(Register dst, Register method) { + const int mirror_offset = in_bytes(Klass::java_mirror_offset()); + ldr(dst, Address(rmethod, Method::const_offset())); + ldr(dst, Address(dst, ConstMethod::constants_offset())); + ldr(dst, Address(dst, ConstantPool::pool_holder_offset_in_bytes())); + ldr(dst, Address(dst, mirror_offset)); +} + void MacroAssembler::cmp_klass(Register oop, Register trial_klass, Register tmp) { if (UseCompressedClassPointers) { ldrw(tmp, Address(oop, oopDesc::klass_offset_in_bytes())); diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp index 57cf4eb7ded..aef0df69069 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2015, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -770,6 +770,8 @@ public: void store_klass(Register dst, Register src); void cmp_klass(Register oop, Register trial_klass, Register tmp); + void load_mirror(Register dst, Register method); + void load_heap_oop(Register dst, Address src); void load_heap_oop_not_null(Register dst, Address src); diff --git a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp index 7fe8f147c27..e78276ed8a7 100644 --- a/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/templateInterpreterGenerator_aarch64.cpp @@ -759,18 +759,13 @@ void TemplateInterpreterGenerator::lock_method() { // get synchronization object { - const int mirror_offset = in_bytes(Klass::java_mirror_offset()); Label done; __ ldrw(r0, access_flags); __ tst(r0, JVM_ACC_STATIC); // get receiver (assume this is frequent case) __ ldr(r0, Address(rlocals, Interpreter::local_offset_in_bytes(0))); __ br(Assembler::EQ, done); - __ ldr(r0, Address(rmethod, Method::const_offset())); - __ ldr(r0, Address(r0, ConstMethod::constants_offset())); - __ ldr(r0, Address(r0, - ConstantPool::pool_holder_offset_in_bytes())); - __ ldr(r0, Address(r0, mirror_offset)); + __ load_mirror(r0, rmethod); #ifdef ASSERT { @@ -807,16 +802,16 @@ void TemplateInterpreterGenerator::lock_method() { void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { // initialize fixed part of activation frame if (native_call) { - __ sub(esp, sp, 12 * wordSize); + __ sub(esp, sp, 14 * wordSize); __ mov(rbcp, zr); - __ stp(esp, zr, Address(__ pre(sp, -12 * wordSize))); + __ stp(esp, zr, Address(__ pre(sp, -14 * wordSize))); // add 2 zero-initialized slots for native calls - __ stp(zr, zr, Address(sp, 10 * wordSize)); + __ stp(zr, zr, Address(sp, 12 * wordSize)); } else { - __ sub(esp, sp, 10 * wordSize); + __ sub(esp, sp, 12 * wordSize); __ ldr(rscratch1, Address(rmethod, Method::const_offset())); // get ConstMethod __ add(rbcp, rscratch1, in_bytes(ConstMethod::codes_offset())); // get codebase - __ stp(esp, rbcp, Address(__ pre(sp, -10 * wordSize))); + __ stp(esp, rbcp, Address(__ pre(sp, -12 * wordSize))); } if (ProfileInterpreter) { @@ -825,22 +820,26 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { __ cbz(rscratch1, method_data_continue); __ lea(rscratch1, Address(rscratch1, in_bytes(MethodData::data_offset()))); __ bind(method_data_continue); - __ stp(rscratch1, rmethod, Address(sp, 4 * wordSize)); // save Method* and mdp (method data pointer) + __ stp(rscratch1, rmethod, Address(sp, 6 * wordSize)); // save Method* and mdp (method data pointer) } else { - __ stp(zr, rmethod, Address(sp, 4 * wordSize)); // save Method* (no mdp) + __ stp(zr, rmethod, Address(sp, 6 * wordSize)); // save Method* (no mdp) } + // Get mirror and store it in the frame as GC root for this Method* + __ load_mirror(rscratch1, rmethod); + __ stp(rscratch1, zr, Address(sp, 4 * wordSize)); + __ ldr(rcpool, Address(rmethod, Method::const_offset())); __ ldr(rcpool, Address(rcpool, ConstMethod::constants_offset())); __ ldr(rcpool, Address(rcpool, ConstantPool::cache_offset_in_bytes())); __ stp(rlocals, rcpool, Address(sp, 2 * wordSize)); - __ stp(rfp, lr, Address(sp, 8 * wordSize)); - __ lea(rfp, Address(sp, 8 * wordSize)); + __ stp(rfp, lr, Address(sp, 10 * wordSize)); + __ lea(rfp, Address(sp, 10 * wordSize)); // set sender sp // leave last_sp as null - __ stp(zr, r13, Address(sp, 6 * wordSize)); + __ stp(zr, r13, Address(sp, 8 * wordSize)); // Move SP out of the way if (! native_call) { @@ -1242,15 +1241,11 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // pass mirror handle if static call { Label L; - const int mirror_offset = in_bytes(Klass::java_mirror_offset()); __ ldrw(t, Address(rmethod, Method::access_flags_offset())); __ tst(t, JVM_ACC_STATIC); __ br(Assembler::EQ, L); // get mirror - __ ldr(t, Address(rmethod, Method::const_offset())); - __ ldr(t, Address(t, ConstMethod::constants_offset())); - __ ldr(t, Address(t, ConstantPool::pool_holder_offset_in_bytes())); - __ ldr(t, Address(t, mirror_offset)); + __ load_mirror(t, rmethod); // copy mirror into activation frame __ str(t, Address(rfp, frame::interpreter_frame_oop_temp_offset * wordSize)); // pass handle to mirror diff --git a/hotspot/src/cpu/ppc/vm/abstractInterpreter_ppc.cpp b/hotspot/src/cpu/ppc/vm/abstractInterpreter_ppc.cpp index eaff19ddf71..933a2f44db3 100644 --- a/hotspot/src/cpu/ppc/vm/abstractInterpreter_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/abstractInterpreter_ppc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -152,6 +152,7 @@ void AbstractInterpreter::layout_activation(Method* method, intptr_t* top_frame_sp = is_top_frame ? sp : sp + (frame::abi_minframe_size - frame::abi_reg_args_size) / Interpreter::stackElementSize; interpreter_frame->interpreter_frame_set_method(method); + interpreter_frame->interpreter_frame_set_mirror(method->method_holder()->java_mirror()); interpreter_frame->interpreter_frame_set_locals(locals_base); interpreter_frame->interpreter_frame_set_cpcache(method->constants()->cache()); interpreter_frame->interpreter_frame_set_esp(esp); diff --git a/hotspot/src/cpu/ppc/vm/frame_ppc.hpp b/hotspot/src/cpu/ppc/vm/frame_ppc.hpp index 6f8f0296f83..ae6847ecab2 100644 --- a/hotspot/src/cpu/ppc/vm/frame_ppc.hpp +++ b/hotspot/src/cpu/ppc/vm/frame_ppc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -261,6 +261,7 @@ uint64_t ijava_reserved2; // Inserted for alignment. #endif uint64_t method; + uint64_t mirror; uint64_t locals; uint64_t monitors; uint64_t cpoolCache; diff --git a/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp b/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp index 7fce0585f10..08497bc93b0 100644 --- a/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp +++ b/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -148,6 +148,11 @@ inline BasicObjectLock* frame::interpreter_frame_monitor_begin() const { inline Method** frame::interpreter_frame_method_addr() const { return (Method**) &(get_ijava_state()->method); } + +inline oop* frame::interpreter_frame_mirror_addr() const { + return (oop*) &(get_ijava_state()->mirror); +} + inline ConstantPoolCache** frame::interpreter_frame_cpoolcache_addr() const { return (ConstantPoolCache**) &(get_ijava_state()->cpoolCache); } diff --git a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp index ce9d109dfdd..a18254f2f5b 100644 --- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp @@ -3118,6 +3118,14 @@ void MacroAssembler::load_klass(Register dst, Register src) { } } +void MacroAssembler::load_mirror(Register mirror, Register method) { + const int mirror_offset = in_bytes(Klass::java_mirror_offset()); + ld(mirror, in_bytes(Method::const_offset()), method); + ld(mirror, in_bytes(ConstMethod::constants_offset()), mirror); + ld(mirror, ConstantPool::pool_holder_offset_in_bytes(), mirror); + ld(mirror, mirror_offset, mirror); +} + // Clear Array // Kills both input registers. tmp == R0 is allowed. void MacroAssembler::clear_memory_doubleword(Register base_ptr, Register cnt_dwords, Register tmp) { diff --git a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp index 53a269a83c2..180a1ddbae9 100644 --- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp +++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp @@ -647,6 +647,9 @@ class MacroAssembler: public Assembler { void load_klass(Register dst, Register src); void store_klass(Register dst_oop, Register klass, Register tmp = R0); void store_klass_gap(Register dst_oop, Register val = noreg); // Will store 0 if val not specified. + + void load_mirror(Register mirror, Register method); + static int instr_size_for_decode_klass_not_null(); void decode_klass_not_null(Register dst, Register src = noreg); Register encode_klass_not_null(Register dst, Register src = noreg); diff --git a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp index 8979e213acf..3bde747aa45 100644 --- a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp @@ -869,7 +869,6 @@ void TemplateInterpreterGenerator::lock_method(Register Rflags, Register Rscratc // Get synchronization object to Rscratch2. { - const int mirror_offset = in_bytes(Klass::java_mirror_offset()); Label Lstatic; Label Ldone; @@ -881,10 +880,7 @@ void TemplateInterpreterGenerator::lock_method(Register Rflags, Register Rscratc __ b(Ldone); __ bind(Lstatic); // Static case: Lock the java mirror - __ ld(Robj_to_lock, in_bytes(Method::const_offset()), R19_method); - __ ld(Robj_to_lock, in_bytes(ConstMethod::constants_offset()), Robj_to_lock); - __ ld(Robj_to_lock, ConstantPool::pool_holder_offset_in_bytes(), Robj_to_lock); - __ ld(Robj_to_lock, mirror_offset, Robj_to_lock); + __ load_mirror(Robj_to_lock, R19_method); __ bind(Ldone); __ verify_oop(Robj_to_lock); @@ -1049,10 +1045,14 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call, Regist __ addi(R26_monitor, R1_SP, - frame::ijava_state_size); __ addi(R15_esp, R26_monitor, - Interpreter::stackElementSize); + // Get mirror and store it in the frame as GC root for this Method* + __ load_mirror(R12_scratch2, R19_method); + // Store values. // R15_esp, R14_bcp, R26_monitor, R28_mdx are saved at java calls // in InterpreterMacroAssembler::call_from_interpreter. __ std(R19_method, _ijava_state_neg(method), R1_SP); + __ std(R12_scratch2, _ijava_state_neg(mirror), R1_SP); __ std(R21_sender_SP, _ijava_state_neg(sender_sp), R1_SP); __ std(R27_constPoolCache, _ijava_state_neg(cpoolCache), R1_SP); __ std(R18_locals, _ijava_state_neg(locals), R1_SP); @@ -1317,21 +1317,11 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { __ testbitdi(CCR0, R0, access_flags, JVM_ACC_STATIC_BIT); __ bfalse(CCR0, method_is_not_static); - // constants = method->constants(); - __ ld(R11_scratch1, in_bytes(Method::const_offset()), R19_method); - __ ld(R11_scratch1, in_bytes(ConstMethod::constants_offset()), R11_scratch1); - // pool_holder = method->constants()->pool_holder(); - __ ld(R11_scratch1/*pool_holder*/, ConstantPool::pool_holder_offset_in_bytes(), - R11_scratch1/*constants*/); - - const int mirror_offset = in_bytes(Klass::java_mirror_offset()); - - // mirror = pool_holder->klass_part()->java_mirror(); - __ ld(R0/*mirror*/, mirror_offset, R11_scratch1/*pool_holder*/); + __ load_mirror(R12_sratch2, R19_method); // state->_native_mirror = mirror; __ ld(R11_scratch1, 0, R1_SP); - __ std(R0/*mirror*/, _ijava_state_neg(oop_tmp), R11_scratch1); + __ std(R12_scratch2/*mirror*/, _ijava_state_neg(oop_tmp), R11_scratch1); // R4_ARG2 = &state->_oop_temp; __ addi(R4_ARG2, R11_scratch1, _ijava_state_neg(oop_tmp)); BIND(method_is_not_static); diff --git a/hotspot/src/cpu/sparc/vm/abstractInterpreter_sparc.cpp b/hotspot/src/cpu/sparc/vm/abstractInterpreter_sparc.cpp index d85bd78bbbd..f9ba7983fd2 100644 --- a/hotspot/src/cpu/sparc/vm/abstractInterpreter_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/abstractInterpreter_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -281,11 +281,12 @@ void AbstractInterpreter::layout_activation(Method* method, // Llast_SP will be same as SP as there is no adapter space *interpreter_frame->register_addr(Llast_SP) = (intptr_t) interpreter_frame->sp() - STACK_BIAS; *interpreter_frame->register_addr(LcpoolCache) = (intptr_t) method->constants()->cache(); + // save the mirror in the interpreter frame + *interpreter_frame->interpreter_frame_mirror_addr() = method->method_holder()->java_mirror(); #ifdef FAST_DISPATCH *interpreter_frame->register_addr(IdispatchTables) = (intptr_t) Interpreter::dispatch_table(); #endif - #ifdef ASSERT BasicObjectLock* mp = (BasicObjectLock*)monitors; diff --git a/hotspot/src/cpu/sparc/vm/frame_sparc.cpp b/hotspot/src/cpu/sparc/vm/frame_sparc.cpp index a9ac2a97a76..aebf03b5374 100644 --- a/hotspot/src/cpu/sparc/vm/frame_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/frame_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -783,7 +783,7 @@ void frame::describe_pd(FrameValues& values, int frame_no) { if (is_interpreted_frame()) { DESCRIBE_FP_OFFSET(interpreter_frame_d_scratch_fp); DESCRIBE_FP_OFFSET(interpreter_frame_l_scratch_fp); - DESCRIBE_FP_OFFSET(interpreter_frame_padding); + DESCRIBE_FP_OFFSET(interpreter_frame_mirror); DESCRIBE_FP_OFFSET(interpreter_frame_oop_temp); // esp, according to Lesp (e.g. not depending on bci), if seems valid diff --git a/hotspot/src/cpu/sparc/vm/frame_sparc.hpp b/hotspot/src/cpu/sparc/vm/frame_sparc.hpp index cd91f52fd17..48cf45bd714 100644 --- a/hotspot/src/cpu/sparc/vm/frame_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/frame_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -209,7 +209,8 @@ // 2 words, also used to save float regs across calls to C interpreter_frame_d_scratch_fp_offset = -2, interpreter_frame_l_scratch_fp_offset = -4, - interpreter_frame_padding_offset = -5, // for native calls only + interpreter_frame_mirror_offset = -5, // keep interpreted method alive + interpreter_frame_oop_temp_offset = -6, // for native calls only interpreter_frame_vm_locals_fp_offset = -6, // should be same as above, and should be zero mod 8 diff --git a/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp b/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp index 01e24727863..e10261f5033 100644 --- a/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp +++ b/hotspot/src/cpu/sparc/vm/frame_sparc.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -163,6 +163,10 @@ inline void frame::interpreter_frame_set_monitors(BasicObjectLock* monitors) { *interpreter_frame_monitors_addr() = monitors; } +inline oop* frame::interpreter_frame_mirror_addr() const { + return (oop*)(fp() + interpreter_frame_mirror_offset); +} + // Constant pool cache // where LcpoolCache is saved: diff --git a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp index 7c3ffae60d0..5402c082025 100644 --- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp @@ -3972,6 +3972,14 @@ void MacroAssembler::card_write_barrier_post(Register store_addr, Register new_v card_table_write(bs->byte_map_base, tmp, store_addr); } +void MacroAssembler::load_mirror(Register mirror, Register method) { + const int mirror_offset = in_bytes(Klass::java_mirror_offset()); + ld_ptr(method, in_bytes(Method::const_offset()), mirror); + ld_ptr(mirror, in_bytes(ConstMethod::constants_offset()), mirror); + ld_ptr(mirror, ConstantPool::pool_holder_offset_in_bytes(), mirror); + ld_ptr(mirror, mirror_offset, mirror); +} + void MacroAssembler::load_klass(Register src_oop, Register klass) { // The number of bytes in this code is used by // MachCallDynamicJavaNode::ret_addr_offset() diff --git a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.hpp b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.hpp index dbbfbbc1267..a579f817e2c 100644 --- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.hpp @@ -1012,6 +1012,8 @@ public: inline void ldbool(const Address& a, Register d); inline void movbool( bool boolconst, Register d); + void load_mirror(Register mirror, Register method); + // klass oop manipulations if compressed void load_klass(Register src_oop, Register klass); void store_klass(Register klass, Register dst_oop); diff --git a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp index 008fcee7a6a..5182b3165d1 100644 --- a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp @@ -557,17 +557,12 @@ void TemplateInterpreterGenerator::lock_method() { // get synchronization object to O0 { Label done; - const int mirror_offset = in_bytes(Klass::java_mirror_offset()); __ btst(JVM_ACC_STATIC, O0); __ br( Assembler::zero, true, Assembler::pt, done); __ delayed()->ld_ptr(Llocals, Interpreter::local_offset_in_bytes(0), O0); // get receiver for not-static case - __ ld_ptr( Lmethod, in_bytes(Method::const_offset()), O0); - __ ld_ptr( O0, in_bytes(ConstMethod::constants_offset()), O0); - __ ld_ptr( O0, ConstantPool::pool_holder_offset_in_bytes(), O0); - // lock the mirror, not the Klass* - __ ld_ptr( O0, mirror_offset, O0); + __ load_mirror(O0, Lmethod); #ifdef ASSERT __ tst(O0); @@ -881,6 +876,10 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { __ add(Lbcp, in_bytes(ConstMethod::codes_offset()), Lbcp); } __ mov( G5_method, Lmethod); // set Lmethod + // Get mirror and store it in the frame as GC root for this Method* + Register mirror = LcpoolCache; + __ load_mirror(mirror, Lmethod); + __ st_ptr(mirror, FP, (frame::interpreter_frame_mirror_offset * wordSize) + STACK_BIAS); __ get_constant_pool_cache( LcpoolCache ); // set LcpoolCache __ sub(FP, rounded_vm_local_words * BytesPerWord, Lmonitors ); // set Lmonitors #ifdef _LP64 @@ -1297,12 +1296,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // get native function entry point(O0 is a good temp until the very end) __ delayed()->ld_ptr(Lmethod, in_bytes(Method::native_function_offset()), O0); // for static methods insert the mirror argument - const int mirror_offset = in_bytes(Klass::java_mirror_offset()); - - __ ld_ptr(Lmethod, Method:: const_offset(), O1); - __ ld_ptr(O1, ConstMethod::constants_offset(), O1); - __ ld_ptr(O1, ConstantPool::pool_holder_offset_in_bytes(), O1); - __ ld_ptr(O1, mirror_offset, O1); + __ load_mirror(O1, Lmethod); #ifdef ASSERT if (!PrintSignatureHandlers) // do not dirty the output with this { Label L; diff --git a/hotspot/src/cpu/x86/vm/abstractInterpreter_x86.cpp b/hotspot/src/cpu/x86/vm/abstractInterpreter_x86.cpp index ed991d5c1b8..5a1f37f26a7 100644 --- a/hotspot/src/cpu/x86/vm/abstractInterpreter_x86.cpp +++ b/hotspot/src/cpu/x86/vm/abstractInterpreter_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -113,6 +113,8 @@ void AbstractInterpreter::layout_activation(Method* method, } *interpreter_frame->interpreter_frame_cache_addr() = method->constants()->cache(); + *interpreter_frame->interpreter_frame_mirror_addr() = + method->method_holder()->java_mirror(); } #ifndef _LP64 diff --git a/hotspot/src/cpu/x86/vm/frame_x86.cpp b/hotspot/src/cpu/x86/vm/frame_x86.cpp index d61ae16729c..edea0e21b8b 100644 --- a/hotspot/src/cpu/x86/vm/frame_x86.cpp +++ b/hotspot/src/cpu/x86/vm/frame_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -640,6 +640,7 @@ void frame::describe_pd(FrameValues& values, int frame_no) { DESCRIBE_FP_OFFSET(interpreter_frame_sender_sp); DESCRIBE_FP_OFFSET(interpreter_frame_last_sp); DESCRIBE_FP_OFFSET(interpreter_frame_method); + DESCRIBE_FP_OFFSET(interpreter_frame_mirror); DESCRIBE_FP_OFFSET(interpreter_frame_mdp); DESCRIBE_FP_OFFSET(interpreter_frame_cache); DESCRIBE_FP_OFFSET(interpreter_frame_locals); diff --git a/hotspot/src/cpu/x86/vm/frame_x86.hpp b/hotspot/src/cpu/x86/vm/frame_x86.hpp index b10f9ce37e6..e23e9692d8c 100644 --- a/hotspot/src/cpu/x86/vm/frame_x86.hpp +++ b/hotspot/src/cpu/x86/vm/frame_x86.hpp @@ -70,7 +70,8 @@ // outgoing sp before a call to an invoked method interpreter_frame_last_sp_offset = interpreter_frame_sender_sp_offset - 1, interpreter_frame_method_offset = interpreter_frame_last_sp_offset - 1, - interpreter_frame_mdp_offset = interpreter_frame_method_offset - 1, + interpreter_frame_mirror_offset = interpreter_frame_method_offset - 1, + interpreter_frame_mdp_offset = interpreter_frame_mirror_offset - 1, interpreter_frame_cache_offset = interpreter_frame_mdp_offset - 1, interpreter_frame_locals_offset = interpreter_frame_cache_offset - 1, interpreter_frame_bcp_offset = interpreter_frame_locals_offset - 1, diff --git a/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp b/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp index 374d83ca5cd..662d67ec746 100644 --- a/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp +++ b/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -184,6 +184,12 @@ inline Method** frame::interpreter_frame_method_addr() const { return (Method**)addr_at(interpreter_frame_method_offset); } +// Mirror + +inline oop* frame::interpreter_frame_mirror_addr() const { + return (oop*)addr_at(interpreter_frame_mirror_offset); +} + // top of expression stack inline intptr_t* frame::interpreter_frame_tos_address() const { intptr_t* last_sp = interpreter_frame_last_sp(); diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index d831256fd66..2f811836cfb 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -6705,6 +6705,14 @@ void MacroAssembler::restore_cpu_control_state_after_jni() { #endif // _LP64 } +void MacroAssembler::load_mirror(Register mirror, Register method) { + // get mirror + const int mirror_offset = in_bytes(Klass::java_mirror_offset()); + movptr(mirror, Address(method, Method::const_offset())); + movptr(mirror, Address(mirror, ConstMethod::constants_offset())); + movptr(mirror, Address(mirror, ConstantPool::pool_holder_offset_in_bytes())); + movptr(mirror, Address(mirror, mirror_offset)); +} void MacroAssembler::load_klass(Register dst, Register src) { #ifdef _LP64 diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp index b92ec2e99af..d31bf44d789 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp @@ -323,6 +323,8 @@ class MacroAssembler: public Assembler { void movbool(Address dst, Register src); void testbool(Register dst); + void load_mirror(Register mirror, Register method); + // oop manipulations void load_klass(Register dst, Register src); void store_klass(Register dst, Register src); diff --git a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp index 84d07960f24..6d07051c901 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86.cpp @@ -608,18 +608,13 @@ void TemplateInterpreterGenerator::lock_method() { // get synchronization object { - const int mirror_offset = in_bytes(Klass::java_mirror_offset()); Label done; __ movl(rax, access_flags); __ testl(rax, JVM_ACC_STATIC); // get receiver (assume this is frequent case) __ movptr(rax, Address(rlocals, Interpreter::local_offset_in_bytes(0))); __ jcc(Assembler::zero, done); - __ movptr(rax, Address(rbx, Method::const_offset())); - __ movptr(rax, Address(rax, ConstMethod::constants_offset())); - __ movptr(rax, Address(rax, - ConstantPool::pool_holder_offset_in_bytes())); - __ movptr(rax, Address(rax, mirror_offset)); + __ load_mirror(rax, rbx); #ifdef ASSERT { @@ -662,6 +657,9 @@ void TemplateInterpreterGenerator::generate_fixed_frame(bool native_call) { __ movptr(rbcp, Address(rbx, Method::const_offset())); // get ConstMethod* __ lea(rbcp, Address(rbcp, ConstMethod::codes_offset())); // get codebase __ push(rbx); // save Method* + // Get mirror and store it in the frame as GC root for this Method* + __ load_mirror(rdx, rbx); + __ push(rdx); if (ProfileInterpreter) { Label method_data_continue; __ movptr(rdx, Address(rbx, in_bytes(Method::method_data_offset()))); @@ -999,15 +997,11 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { // pass mirror handle if static call { Label L; - const int mirror_offset = in_bytes(Klass::java_mirror_offset()); __ movl(t, Address(method, Method::access_flags_offset())); __ testl(t, JVM_ACC_STATIC); __ jcc(Assembler::zero, L); // get mirror - __ movptr(t, Address(method, Method::const_offset())); - __ movptr(t, Address(t, ConstMethod::constants_offset())); - __ movptr(t, Address(t, ConstantPool::pool_holder_offset_in_bytes())); - __ movptr(t, Address(t, mirror_offset)); + __ load_mirror(t, method); // copy mirror into activation frame __ movptr(Address(rbp, frame::interpreter_frame_oop_temp_offset * wordSize), t); diff --git a/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp index 2290f59d1b1..1dbe94d5469 100644 --- a/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp +++ b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.cpp @@ -49,6 +49,7 @@ const char *BytecodeInterpreter::name_of_field_at_address(address addr) { DO(_locals); DO(_constants); DO(_method); + DO(_mirror); DO(_mdx); DO(_stack); DO(_msg); @@ -77,6 +78,7 @@ void BytecodeInterpreter::layout_interpreterState(interpreterState istate, bool is_top_frame) { istate->set_locals(locals); istate->set_method(method); + istate->set_mirror(method->method_holder()->java_mirror()); istate->set_self_link(istate); istate->set_prev_link(NULL); // thread will be set by a hacky repurposing of frame::patch_pc() diff --git a/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.hpp b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.hpp index f7bcb91e547..e7ef4c1a26e 100644 --- a/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.hpp +++ b/hotspot/src/cpu/zero/vm/bytecodeInterpreter_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2011 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -44,6 +44,9 @@ inline void set_method(Method* new_method) { _method = new_method; } + inline void set_mirror(oop new_mirror) { + _mirror = new_mirror; + } inline interpreterState self_link() { return _self_link; } diff --git a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp index 9a85f43a2ec..9e91f22f266 100644 --- a/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp +++ b/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp @@ -755,6 +755,7 @@ InterpreterFrame *InterpreterFrame::build(Method* const method, TRAPS) { istate->set_locals(locals); istate->set_method(method); + istate->set_mirror(method->method_holder()->java_mirror()); istate->set_self_link(istate); istate->set_prev_link(NULL); istate->set_thread(thread); diff --git a/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp b/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp index f8011a25161..a2fc0c3eeb3 100644 --- a/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp +++ b/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -115,6 +115,10 @@ inline Method** frame::interpreter_frame_method_addr() const { return &(get_interpreterState()->_method); } +inline oop* frame::interpreter_frame_mirror_addr() const { + return &(get_interpreterState()->_mirror); +} + inline intptr_t* frame::interpreter_frame_mdp_addr() const { return (intptr_t*) &(get_interpreterState()->_mdx); } diff --git a/hotspot/src/share/vm/gc/g1/g1RootClosures.cpp b/hotspot/src/share/vm/gc/g1/g1RootClosures.cpp index 4e54a68c73a..5ecdade929a 100644 --- a/hotspot/src/share/vm/gc/g1/g1RootClosures.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RootClosures.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,6 @@ public: CLDClosure* weak_clds() { return &_closures._clds; } CLDClosure* strong_clds() { return &_closures._clds; } - CLDClosure* thread_root_clds() { return NULL; } CLDClosure* second_pass_weak_clds() { return NULL; } CodeBlobClosure* strong_codeblobs() { return &_closures._codeblobs; } @@ -89,7 +88,6 @@ public: // If MarkWeak is G1MarkFromRoot then all CLDs are processed by the weak and strong variants // return a NULL closure for the following specialized versions in that case. - CLDClosure* thread_root_clds() { return null_if(&_strong._clds); } CLDClosure* second_pass_weak_clds() { return null_if(&_weak._clds); } CodeBlobClosure* strong_codeblobs() { return &_strong._codeblobs; } diff --git a/hotspot/src/share/vm/gc/g1/g1RootClosures.hpp b/hotspot/src/share/vm/gc/g1/g1RootClosures.hpp index 34e58f0f411..571a263a197 100644 --- a/hotspot/src/share/vm/gc/g1/g1RootClosures.hpp +++ b/hotspot/src/share/vm/gc/g1/g1RootClosures.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,9 +41,6 @@ public: virtual CLDClosure* weak_clds() = 0; virtual CLDClosure* strong_clds() = 0; - // Applied to the CLDs reachable from the thread stacks. - virtual CLDClosure* thread_root_clds() = 0; - // Applied to code blobs reachable as strong roots. virtual CodeBlobClosure* strong_codeblobs() = 0; }; diff --git a/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp b/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp index 077a2350f34..f8526e778e9 100644 --- a/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RootProcessor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -152,7 +152,6 @@ public: CLDClosure* weak_clds() { return NULL; } CLDClosure* strong_clds() { return _clds; } - CLDClosure* thread_root_clds() { return _clds; } CodeBlobClosure* strong_codeblobs() { return _blobs; } }; @@ -184,9 +183,6 @@ public: // system. CLDClosure* weak_clds() { return _clds; } CLDClosure* strong_clds() { return _clds; } - // We don't want to visit CLDs more than once, so we return NULL for the - // thread root CLDs. - CLDClosure* thread_root_clds() { return NULL; } // We don't want to visit code blobs more than once, so we return NULL for the // strong case and walk the entire code cache as a separate step. @@ -211,7 +207,6 @@ void G1RootProcessor::process_all_roots(OopClosure* oops, void G1RootProcessor::process_java_roots(G1RootClosures* closures, G1GCPhaseTimes* phase_times, uint worker_i) { - assert(closures->thread_root_clds() == NULL || closures->weak_clds() == NULL, "There is overlap between those, only one may be set"); // Iterating over the CLDG and the Threads are done early to allow us to // first process the strong CLDs and nmethods and then, after a barrier, // let the thread process the weak CLDs and nmethods. @@ -227,7 +222,6 @@ void G1RootProcessor::process_java_roots(G1RootClosures* closures, bool is_par = n_workers() > 1; Threads::possibly_parallel_oops_do(is_par, closures->strong_oops(), - closures->thread_root_clds(), closures->strong_codeblobs()); } } diff --git a/hotspot/src/share/vm/gc/parallel/pcTasks.cpp b/hotspot/src/share/vm/gc/parallel/pcTasks.cpp index bc58a0dbaec..e7a4acfcbbd 100644 --- a/hotspot/src/share/vm/gc/parallel/pcTasks.cpp +++ b/hotspot/src/share/vm/gc/parallel/pcTasks.cpp @@ -58,19 +58,16 @@ void ThreadRootsMarkingTask::do_it(GCTaskManager* manager, uint which) { ParCompactionManager::gc_thread_compaction_manager(which); ParCompactionManager::MarkAndPushClosure mark_and_push_closure(cm); - CLDToOopClosure mark_and_push_from_clds(&mark_and_push_closure, true); MarkingCodeBlobClosure mark_and_push_in_blobs(&mark_and_push_closure, !CodeBlobToOopClosure::FixRelocations); if (_java_thread != NULL) _java_thread->oops_do( &mark_and_push_closure, - &mark_and_push_from_clds, &mark_and_push_in_blobs); if (_vm_thread != NULL) _vm_thread->oops_do( &mark_and_push_closure, - &mark_and_push_from_clds, &mark_and_push_in_blobs); // Do the real work @@ -99,8 +96,7 @@ void MarkFromRootsTask::do_it(GCTaskManager* manager, uint which) { { ResourceMark rm; MarkingCodeBlobClosure each_active_code_blob(&mark_and_push_closure, !CodeBlobToOopClosure::FixRelocations); - CLDToOopClosure mark_and_push_from_cld(&mark_and_push_closure); - Threads::oops_do(&mark_and_push_closure, &mark_and_push_from_cld, &each_active_code_blob); + Threads::oops_do(&mark_and_push_closure, &each_active_code_blob); } break; diff --git a/hotspot/src/share/vm/gc/parallel/psMarkSweep.cpp b/hotspot/src/share/vm/gc/parallel/psMarkSweep.cpp index e2084e9c190..9fa97309099 100644 --- a/hotspot/src/share/vm/gc/parallel/psMarkSweep.cpp +++ b/hotspot/src/share/vm/gc/parallel/psMarkSweep.cpp @@ -505,9 +505,8 @@ void PSMarkSweep::mark_sweep_phase1(bool clear_all_softrefs) { ParallelScavengeHeap::ParStrongRootsScope psrs; Universe::oops_do(mark_and_push_closure()); JNIHandles::oops_do(mark_and_push_closure()); // Global (strong) JNI handles - CLDToOopClosure mark_and_push_from_cld(mark_and_push_closure()); MarkingCodeBlobClosure each_active_code_blob(mark_and_push_closure(), !CodeBlobToOopClosure::FixRelocations); - Threads::oops_do(mark_and_push_closure(), &mark_and_push_from_cld, &each_active_code_blob); + Threads::oops_do(mark_and_push_closure(), &each_active_code_blob); ObjectSynchronizer::oops_do(mark_and_push_closure()); FlatProfiler::oops_do(mark_and_push_closure()); Management::oops_do(mark_and_push_closure()); @@ -597,8 +596,7 @@ void PSMarkSweep::mark_sweep_phase3() { // General strong roots. Universe::oops_do(adjust_pointer_closure()); JNIHandles::oops_do(adjust_pointer_closure()); // Global (strong) JNI handles - CLDToOopClosure adjust_from_cld(adjust_pointer_closure()); - Threads::oops_do(adjust_pointer_closure(), &adjust_from_cld, NULL); + Threads::oops_do(adjust_pointer_closure(), NULL); ObjectSynchronizer::oops_do(adjust_pointer_closure()); FlatProfiler::oops_do(adjust_pointer_closure()); Management::oops_do(adjust_pointer_closure()); diff --git a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp index 6b145d17c00..4808577b238 100644 --- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp @@ -2148,8 +2148,7 @@ void PSParallelCompact::adjust_roots(ParCompactionManager* cm) { // General strong roots. Universe::oops_do(&oop_closure); JNIHandles::oops_do(&oop_closure); // Global (strong) JNI handles - CLDToOopClosure adjust_from_cld(&oop_closure); - Threads::oops_do(&oop_closure, &adjust_from_cld, NULL); + Threads::oops_do(&oop_closure, NULL); ObjectSynchronizer::oops_do(&oop_closure); FlatProfiler::oops_do(&oop_closure); Management::oops_do(&oop_closure); diff --git a/hotspot/src/share/vm/gc/parallel/psTasks.cpp b/hotspot/src/share/vm/gc/parallel/psTasks.cpp index 4f372f9f0b0..9e95868b507 100644 --- a/hotspot/src/share/vm/gc/parallel/psTasks.cpp +++ b/hotspot/src/share/vm/gc/parallel/psTasks.cpp @@ -65,8 +65,7 @@ void ScavengeRootsTask::do_it(GCTaskManager* manager, uint which) { case threads: { ResourceMark rm; - CLDClosure* cld_closure = NULL; // Not needed. All CLDs are already visited. - Threads::oops_do(&roots_closure, cld_closure, NULL); + Threads::oops_do(&roots_closure, NULL); } break; @@ -122,14 +121,13 @@ void ThreadRootsTask::do_it(GCTaskManager* manager, uint which) { PSPromotionManager* pm = PSPromotionManager::gc_thread_promotion_manager(which); PSScavengeRootsClosure roots_closure(pm); - CLDClosure* roots_from_clds = NULL; // Not needed. All CLDs are already visited. MarkingCodeBlobClosure roots_in_blobs(&roots_closure, CodeBlobToOopClosure::FixRelocations); if (_java_thread != NULL) - _java_thread->oops_do(&roots_closure, roots_from_clds, &roots_in_blobs); + _java_thread->oops_do(&roots_closure, &roots_in_blobs); if (_vm_thread != NULL) - _vm_thread->oops_do(&roots_closure, roots_from_clds, &roots_in_blobs); + _vm_thread->oops_do(&roots_closure, &roots_in_blobs); // Do the real work pm->drain_stacks(false); diff --git a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp index 8faeedec049..049b675bd51 100644 --- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp @@ -582,14 +582,11 @@ void GenCollectedHeap::process_roots(StrongRootsScope* scope, ClassLoaderDataGraph::roots_cld_do(strong_cld_closure, weak_cld_closure); } - // Some CLDs contained in the thread frames should be considered strong. - // Don't process them if they will be processed during the ClassLoaderDataGraph phase. - CLDClosure* roots_from_clds_p = (strong_cld_closure != weak_cld_closure) ? strong_cld_closure : NULL; // Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway CodeBlobToOopClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots; bool is_par = scope->n_threads() > 1; - Threads::possibly_parallel_oops_do(is_par, strong_roots, roots_from_clds_p, roots_from_code_p); + Threads::possibly_parallel_oops_do(is_par, strong_roots, roots_from_code_p); if (!_process_strong_tasks->is_task_claimed(GCH_PS_Universe_oops_do)) { Universe::oops_do(strong_roots); diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.hpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.hpp index f7121d0309b..5adbe465271 100644 --- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.hpp +++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -110,6 +110,7 @@ private: intptr_t* _locals; // local variable pointer ConstantPoolCache* _constants; // constant pool cache Method* _method; // method being executed + oop _mirror; // mirror to klass containing method DataLayout* _mdx; // compiler profiling data for current bytecode intptr_t* _stack; // expression stack messages _msg; // frame manager <-> interpreter message diff --git a/hotspot/src/share/vm/runtime/deoptimization.cpp b/hotspot/src/share/vm/runtime/deoptimization.cpp index d380bf6d518..1f4c48ed068 100644 --- a/hotspot/src/share/vm/runtime/deoptimization.cpp +++ b/hotspot/src/share/vm/runtime/deoptimization.cpp @@ -762,7 +762,7 @@ JRT_LEAF(BasicType, Deoptimization::unpack_frames(JavaThread* thread, int exec_m guarantee(false, "wrong number of expression stack elements during deopt"); } VerifyOopClosure verify; - iframe->oops_interpreted_do(&verify, NULL, &rm, false); + iframe->oops_interpreted_do(&verify, &rm, false); callee_size_of_parameters = mh->size_of_parameters(); callee_max_locals = mh->max_locals(); is_top_frame = false; diff --git a/hotspot/src/share/vm/runtime/frame.cpp b/hotspot/src/share/vm/runtime/frame.cpp index 10d817636a4..78d5ffdf38b 100644 --- a/hotspot/src/share/vm/runtime/frame.cpp +++ b/hotspot/src/share/vm/runtime/frame.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -396,6 +396,11 @@ void frame::interpreter_frame_set_method(Method* method) { *interpreter_frame_method_addr() = method; } +void frame::interpreter_frame_set_mirror(oop mirror) { + assert(is_interpreted_frame(), "interpreted frame expected"); + *interpreter_frame_mirror_addr() = mirror; +} + jint frame::interpreter_frame_bci() const { assert(is_interpreted_frame(), "interpreted frame expected"); address bcp = interpreter_frame_bcp(); @@ -852,8 +857,7 @@ oop* frame::interpreter_callee_receiver_addr(Symbol* signature) { } -void frame::oops_interpreted_do(OopClosure* f, CLDClosure* cld_f, - const RegisterMap* map, bool query_oop_map_cache) { +void frame::oops_interpreted_do(OopClosure* f, const RegisterMap* map, bool query_oop_map_cache) { assert(is_interpreted_frame(), "Not an interpreted frame"); assert(map != NULL, "map must be set"); Thread *thread = Thread::current(); @@ -879,21 +883,16 @@ void frame::oops_interpreted_do(OopClosure* f, CLDClosure* cld_f, current->oops_do(f); } - // process fixed part - if (cld_f != NULL) { - // The method pointer in the frame might be the only path to the method's - // klass, and the klass needs to be kept alive while executing. The GCs - // don't trace through method pointers, so typically in similar situations - // the mirror or the class loader of the klass are installed as a GC root. - // To minimize the overhead of doing that here, we ask the GC to pass down a - // closure that knows how to keep klasses alive given a ClassLoaderData. - cld_f->do_cld(m->method_holder()->class_loader_data()); - } - - if (m->is_native() PPC32_ONLY(&& m->is_static())) { + if (m->is_native()) { f->do_oop(interpreter_frame_temp_oop_addr()); } + // The method pointer in the frame might be the only path to the method's + // klass, and the klass needs to be kept alive while executing. The GCs + // don't trace through method pointers, so the mirror of the method's klass + // is installed as a GC root. + f->do_oop(interpreter_frame_mirror_addr()); + int max_locals = m->is_native() ? m->size_of_parameters() : m->max_locals(); Symbol* signature = NULL; @@ -1093,7 +1092,7 @@ void frame::oops_entry_do(OopClosure* f, const RegisterMap* map) { } -void frame::oops_do_internal(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache) { +void frame::oops_do_internal(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache) { #ifndef PRODUCT // simulate GC crash here to dump java thread in error report if (CrashGCForDumpingJavaThread) { @@ -1102,7 +1101,7 @@ void frame::oops_do_internal(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* } #endif if (is_interpreted_frame()) { - oops_interpreted_do(f, cld_f, map, use_interpreter_oop_map_cache); + oops_interpreted_do(f, map, use_interpreter_oop_map_cache); } else if (is_entry_frame()) { oops_entry_do(f, map); } else if (CodeCache::contains(pc())) { @@ -1147,7 +1146,7 @@ void frame::verify(const RegisterMap* map) { #if defined(COMPILER2) || INCLUDE_JVMCI assert(DerivedPointerTable::is_empty(), "must be empty before verify"); #endif - oops_do_internal(&VerifyOopClosure::verify_oop, NULL, NULL, (RegisterMap*)map, false); + oops_do_internal(&VerifyOopClosure::verify_oop, NULL, (RegisterMap*)map, false); } diff --git a/hotspot/src/share/vm/runtime/frame.hpp b/hotspot/src/share/vm/runtime/frame.hpp index 0bb1d875071..b71585a5049 100644 --- a/hotspot/src/share/vm/runtime/frame.hpp +++ b/hotspot/src/share/vm/runtime/frame.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -320,6 +320,9 @@ class frame VALUE_OBJ_CLASS_SPEC { void interpreter_frame_set_method(Method* method); Method** interpreter_frame_method_addr() const; ConstantPoolCache** interpreter_frame_cache_addr() const; + oop* interpreter_frame_mirror_addr() const; + + void interpreter_frame_set_mirror(oop mirror); public: // Entry frames @@ -386,19 +389,19 @@ class frame VALUE_OBJ_CLASS_SPEC { // Oops-do's void oops_compiled_arguments_do(Symbol* signature, bool has_receiver, bool has_appendix, const RegisterMap* reg_map, OopClosure* f); - void oops_interpreted_do(OopClosure* f, CLDClosure* cld_f, const RegisterMap* map, bool query_oop_map_cache = true); + void oops_interpreted_do(OopClosure* f, const RegisterMap* map, bool query_oop_map_cache = true); private: void oops_interpreted_arguments_do(Symbol* signature, bool has_receiver, OopClosure* f); // Iteration of oops - void oops_do_internal(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache); + void oops_do_internal(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map, bool use_interpreter_oop_map_cache); void oops_entry_do(OopClosure* f, const RegisterMap* map); void oops_code_blob_do(OopClosure* f, CodeBlobClosure* cf, const RegisterMap* map); int adjust_offset(Method* method, int index); // helper for above fn public: // Memory management - void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf, RegisterMap* map) { oops_do_internal(f, cld_f, cf, map, true); } + void oops_do(OopClosure* f, CodeBlobClosure* cf, RegisterMap* map) { oops_do_internal(f, cf, map, true); } void nmethods_do(CodeBlobClosure* cf); // RedefineClasses support for finding live interpreted methods on the stack diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 719eb74b018..27d0c0d0b8f 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -785,7 +785,7 @@ bool Thread::claim_oops_do_par_case(int strong_roots_parity) { return false; } -void Thread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { +void Thread::oops_do(OopClosure* f, CodeBlobClosure* cf) { active_handles()->oops_do(f); // Do oop for ThreadShadow f->do_oop((oop*)&_pending_exception); @@ -2758,7 +2758,7 @@ class RememberProcessedThread: public StackObj { } }; -void JavaThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { +void JavaThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { // Verify that the deferred card marks have been flushed. assert(deferred_card_mark().is_empty(), "Should be empty during GC"); @@ -2766,7 +2766,7 @@ void JavaThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) // since there may be more than one thread using each ThreadProfiler. // Traverse the GCHandles - Thread::oops_do(f, cld_f, cf); + Thread::oops_do(f, cf); JVMCI_ONLY(f->do_oop((oop*)&_pending_failed_speculation);) @@ -2796,7 +2796,7 @@ void JavaThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) // Traverse the execution stack for (StackFrameStream fst(this); !fst.is_done(); fst.next()) { - fst.current()->oops_do(f, cld_f, cf, fst.register_map()); + fst.current()->oops_do(f, cf, fst.register_map()); } } @@ -2946,7 +2946,7 @@ static void frame_verify(frame* f, const RegisterMap *map) { f->verify(map); } void JavaThread::verify() { // Verify oops in the thread. - oops_do(&VerifyOopClosure::verify_oop, NULL, NULL); + oops_do(&VerifyOopClosure::verify_oop, NULL); // Verify the stack frames. frames_do(frame_verify); @@ -3186,7 +3186,7 @@ class PrintAndVerifyOopClosure: public OopClosure { static void oops_print(frame* f, const RegisterMap *map) { PrintAndVerifyOopClosure print; f->print_value(); - f->oops_do(&print, NULL, NULL, (RegisterMap*)map); + f->oops_do(&print, NULL, (RegisterMap*)map); } // Print our all the locations that contain oops and whether they are @@ -3303,8 +3303,8 @@ CodeCacheSweeperThread::CodeCacheSweeperThread() _scanned_nmethod = NULL; } -void CodeCacheSweeperThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { - JavaThread::oops_do(f, cld_f, cf); +void CodeCacheSweeperThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { + JavaThread::oops_do(f, cf); if (_scanned_nmethod != NULL && cf != NULL) { // Safepoints can occur when the sweeper is scanning an nmethod so // process it here to make sure it isn't unloaded in the middle of @@ -4291,11 +4291,11 @@ bool Threads::includes(JavaThread* p) { // uses the Threads_lock to guarantee this property. It also makes sure that // all threads gets blocked when exiting or starting). -void Threads::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { +void Threads::oops_do(OopClosure* f, CodeBlobClosure* cf) { ALL_JAVA_THREADS(p) { - p->oops_do(f, cld_f, cf); + p->oops_do(f, cf); } - VMThread::vm_thread()->oops_do(f, cld_f, cf); + VMThread::vm_thread()->oops_do(f, cf); } void Threads::change_thread_claim_parity() { @@ -4318,16 +4318,16 @@ void Threads::assert_all_threads_claimed() { } #endif // ASSERT -void Threads::possibly_parallel_oops_do(bool is_par, OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { +void Threads::possibly_parallel_oops_do(bool is_par, OopClosure* f, CodeBlobClosure* cf) { int cp = Threads::thread_claim_parity(); ALL_JAVA_THREADS(p) { if (p->claim_oops_do(is_par, cp)) { - p->oops_do(f, cld_f, cf); + p->oops_do(f, cf); } } VMThread* vmt = VMThread::vm_thread(); if (vmt->claim_oops_do(is_par, cp)) { - vmt->oops_do(f, cld_f, cf); + vmt->oops_do(f, cf); } } diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index f5d7ac5b74d..2e82227143f 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -482,10 +482,9 @@ class Thread: public ThreadShadow { // GC support // Apply "f->do_oop" to all root oops in "this". - // Apply "cld_f->do_cld" to CLDs that are otherwise not kept alive. // Used by JavaThread::oops_do. // Apply "cf->do_code_blob" (if !NULL) to all code blobs active in frames - virtual void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf); + virtual void oops_do(OopClosure* f, CodeBlobClosure* cf); // Handles the parallel case for the method below. private: @@ -1642,7 +1641,7 @@ class JavaThread: public Thread { void frames_do(void f(frame*, const RegisterMap*)); // Memory operations - void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf); + void oops_do(OopClosure* f, CodeBlobClosure* cf); // Sweeper operations virtual void nmethods_do(CodeBlobClosure* cf); @@ -1995,7 +1994,7 @@ class CodeCacheSweeperThread : public JavaThread { bool is_Code_cache_sweeper_thread() const { return true; } // Prevent GC from unloading _scanned_nmethod - void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf); + void oops_do(OopClosure* f, CodeBlobClosure* cf); void nmethods_do(CodeBlobClosure* cf); }; @@ -2122,9 +2121,9 @@ class Threads: AllStatic { // Apply "f->do_oop" to all root oops in all threads. // This version may only be called by sequential code. - static void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf); + static void oops_do(OopClosure* f, CodeBlobClosure* cf); // This version may be called by sequential or parallel code. - static void possibly_parallel_oops_do(bool is_par, OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf); + static void possibly_parallel_oops_do(bool is_par, OopClosure* f, CodeBlobClosure* cf); // This creates a list of GCTasks, one per thread. static void create_thread_roots_tasks(GCTaskQueue* q); // This creates a list of GCTasks, one per thread, for marking objects. diff --git a/hotspot/src/share/vm/runtime/vmThread.cpp b/hotspot/src/share/vm/runtime/vmThread.cpp index 138431a1475..c004a64873e 100644 --- a/hotspot/src/share/vm/runtime/vmThread.cpp +++ b/hotspot/src/share/vm/runtime/vmThread.cpp @@ -655,8 +655,8 @@ void VMThread::execute(VM_Operation* op) { } -void VMThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { - Thread::oops_do(f, cld_f, cf); +void VMThread::oops_do(OopClosure* f, CodeBlobClosure* cf) { + Thread::oops_do(f, cf); _vm_queue->oops_do(f); } @@ -688,5 +688,5 @@ void VMOperationQueue::verify_queue(int prio) { #endif void VMThread::verify() { - oops_do(&VerifyOopClosure::verify_oop, NULL, NULL); + oops_do(&VerifyOopClosure::verify_oop, NULL); } diff --git a/hotspot/src/share/vm/runtime/vmThread.hpp b/hotspot/src/share/vm/runtime/vmThread.hpp index 692fbdd164d..c55b6f493dc 100644 --- a/hotspot/src/share/vm/runtime/vmThread.hpp +++ b/hotspot/src/share/vm/runtime/vmThread.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -126,7 +126,7 @@ class VMThread: public NamedThread { static VMThread* vm_thread() { return _vm_thread; } // GC support - void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf); + void oops_do(OopClosure* f, CodeBlobClosure* cf); void verify(); diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups index 18dc949a024..729dd77d328 100644 --- a/hotspot/test/TEST.groups +++ b/hotspot/test/TEST.groups @@ -353,7 +353,7 @@ hotspot_fast_runtime = \ runtime/ \ -runtime/ErrorHandling/ErrorHandler.java \ -runtime/RedefineObject/TestRedefineObject.java \ - -runtime/8003720/Test8003720.java \ + -runtime/MirrorFrame/Test8003720.java \ -runtime/Metaspace/FragmentMetaspace.java \ -runtime/Metaspace/FragmentMetaspaceSimple.java \ -runtime/Thread/TestThreadDumpMonitorContention.java \ diff --git a/hotspot/test/runtime/8003720/Asmator.java b/hotspot/test/runtime/MirrorFrame/Asmator.java similarity index 100% rename from hotspot/test/runtime/8003720/Asmator.java rename to hotspot/test/runtime/MirrorFrame/Asmator.java diff --git a/hotspot/test/runtime/8003720/Test8003720.java b/hotspot/test/runtime/MirrorFrame/Test8003720.java similarity index 100% rename from hotspot/test/runtime/8003720/Test8003720.java rename to hotspot/test/runtime/MirrorFrame/Test8003720.java diff --git a/hotspot/test/runtime/8003720/Victim.java b/hotspot/test/runtime/MirrorFrame/Victim.java similarity index 100% rename from hotspot/test/runtime/8003720/Victim.java rename to hotspot/test/runtime/MirrorFrame/Victim.java diff --git a/hotspot/test/runtime/8003720/VictimClassLoader.java b/hotspot/test/runtime/MirrorFrame/VictimClassLoader.java similarity index 100% rename from hotspot/test/runtime/8003720/VictimClassLoader.java rename to hotspot/test/runtime/MirrorFrame/VictimClassLoader.java -- GitLab From f2ba1fde338b2245c9934c55ded1c1b290891b83 Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Mon, 25 Apr 2016 14:22:36 +0000 Subject: [PATCH 197/400] 8154957: AArch64: Better byte behavior The fix for 8132051 is needed for AArch64. Reviewed-by: roland --- .../aarch64/vm/c1_LIRGenerator_aarch64.cpp | 5 +- .../cpu/aarch64/vm/interp_masm_aarch64.cpp | 41 ++++++++++++- .../cpu/aarch64/vm/interp_masm_aarch64.hpp | 3 + .../cpu/aarch64/vm/macroAssembler_aarch64.hpp | 4 ++ .../cpu/aarch64/vm/templateTable_aarch64.cpp | 58 ++++++++++++++++++- 5 files changed, 106 insertions(+), 5 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp index 5d47ae7a9b7..eab765a85ff 100644 --- a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp @@ -331,7 +331,7 @@ void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { length.load_item(); } - if (needs_store_check) { + if (needs_store_check || x->check_boolean()) { value.load_item(); } else { value.load_for_store(x->elt_type()); @@ -380,7 +380,8 @@ void LIRGenerator::do_StoreIndexed(StoreIndexed* x) { // Seems to be a precise post_barrier(LIR_OprFact::address(array_addr), value.result()); } else { - __ move(value.result(), array_addr, null_check_info); + LIR_Opr result = maybe_mask_boolean(x, array.result(), value.result(), null_check_info); + __ move(result, array_addr, null_check_info); } } diff --git a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp index 59d06cb65ee..882cccceb2b 100644 --- a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp @@ -40,7 +40,43 @@ #include "runtime/thread.inline.hpp" -// Implementation of InterpreterMacroAssembler +void InterpreterMacroAssembler::narrow(Register result) { + + // Get method->_constMethod->_result_type + ldr(rscratch1, Address(rfp, frame::interpreter_frame_method_offset * wordSize)); + ldr(rscratch1, Address(rscratch1, Method::const_offset())); + ldrb(rscratch1, Address(rscratch1, ConstMethod::result_type_offset())); + + Label done, notBool, notByte, notChar; + + // common case first + cmpw(rscratch1, T_INT); + br(Assembler::EQ, done); + + // mask integer result to narrower return type. + cmpw(rscratch1, T_BOOLEAN); + br(Assembler::NE, notBool); + andw(result, result, 0x1); + b(done); + + bind(notBool); + cmpw(rscratch1, T_BYTE); + br(Assembler::NE, notByte); + sbfx(result, result, 0, 8); + b(done); + + bind(notByte); + cmpw(rscratch1, T_CHAR); + br(Assembler::NE, notChar); + ubfx(result, result, 0, 16); // truncate upper 16 bits + b(done); + + bind(notChar); + sbfx(result, result, 0, 16); // sign-extend short + + // Nothing to do for T_INT + bind(done); +} void InterpreterMacroAssembler::jump_to_entry(address entry) { assert(entry, "Entry must have been generated by now"); @@ -81,6 +117,7 @@ void InterpreterMacroAssembler::load_earlyret_value(TosState state) { verify_oop(r0, state); break; case ltos: ldr(r0, val_addr); break; case btos: // fall through + case ztos: // fall through case ctos: // fall through case stos: // fall through case itos: ldrw(r0, val_addr); break; @@ -314,6 +351,7 @@ void InterpreterMacroAssembler::pop(TosState state) { switch (state) { case atos: pop_ptr(); break; case btos: + case ztos: case ctos: case stos: case itos: pop_i(); break; @@ -331,6 +369,7 @@ void InterpreterMacroAssembler::push(TosState state) { switch (state) { case atos: push_ptr(); break; case btos: + case ztos: case ctos: case stos: case itos: push_i(); break; diff --git a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.hpp index d56d17ab47a..dd73bf5283d 100644 --- a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.hpp @@ -245,6 +245,9 @@ class InterpreterMacroAssembler: public MacroAssembler { void update_mdp_by_constant(Register mdp_in, int constant); void update_mdp_for_ret(Register return_bci); + // narrow int return value + void narrow(Register result); + void profile_taken_branch(Register mdp, Register bumped_count); void profile_not_taken_branch(Register mdp); void profile_call(Register mdp); diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp index 57cf4eb7ded..bfcf124515f 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp @@ -1184,6 +1184,10 @@ public: Register result, Register cnt1, int elem_size, bool is_string); + void fill_words(Register base, Register cnt, Register value); + void zero_words(Register base, Register cnt); + void zero_words(Register base, u_int64_t cnt); + void byte_array_inflate(Register src, Register dst, Register len, FloatRegister vtmp1, FloatRegister vtmp2, FloatRegister vtmp3, Register tmp4); diff --git a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp index 0e74514634e..5c1a98463bf 100644 --- a/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/templateTable_aarch64.cpp @@ -229,6 +229,7 @@ void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg, switch (bc) { case Bytecodes::_fast_aputfield: case Bytecodes::_fast_bputfield: + case Bytecodes::_fast_zputfield: case Bytecodes::_fast_cputfield: case Bytecodes::_fast_dputfield: case Bytecodes::_fast_fputfield: @@ -1082,6 +1083,17 @@ void TemplateTable::bastore() // r1: index // r3: array index_check(r3, r1); // prefer index in r1 + + // Need to check whether array is boolean or byte + // since both types share the bastore bytecode. + __ load_klass(r2, r3); + __ ldrw(r2, Address(r2, Klass::layout_helper_offset())); + int diffbit_index = exact_log2(Klass::layout_helper_boolean_diffbit()); + Label L_skip; + __ tbz(r2, diffbit_index, L_skip); + __ andw(r0, r0, 1); // if it is a T_BOOLEAN array, mask the stored value to 0/1 + __ bind(L_skip); + __ lea(rscratch1, Address(r3, r1, Address::uxtw(0))); __ strb(r0, Address(rscratch1, arrayOopDesc::base_offset_in_bytes(T_BYTE))); @@ -2193,6 +2205,13 @@ void TemplateTable::_return(TosState state) if (_desc->bytecode() == Bytecodes::_return) __ membar(MacroAssembler::StoreStore); + // Narrow result if state is itos but result type is smaller. + // Need to narrow in the return bytecode rather than in generate_return_entry + // since compiled code callers expect the result to already be narrowed. + if (state == itos) { + __ narrow(r0); + } + __ remove_activation(state); __ ret(lr); } @@ -2386,7 +2405,7 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr const Address field(obj, off); - Label Done, notByte, notInt, notShort, notChar, + Label Done, notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble; // x86 uses a shift and mask or wings it with a shift plus assert @@ -2409,6 +2428,20 @@ void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteContr __ b(Done); __ bind(notByte); + __ cmp(flags, ztos); + __ br(Assembler::NE, notBool); + + // ztos (same code as btos) + __ ldrsb(r0, field); + __ push(ztos); + // Rewrite bytecode to be faster + if (!is_static) { + // use btos rewriting, no truncating to t/f bit is needed for getfield. + patch_bytecode(Bytecodes::_fast_bgetfield, bc, r1); + } + __ b(Done); + + __ bind(notBool); __ cmp(flags, atos); __ br(Assembler::NE, notObj); // atos @@ -2604,7 +2637,7 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr // field address const Address field(obj, off); - Label notByte, notInt, notShort, notChar, + Label notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj, notDouble; // x86 uses a shift and mask or wings it with a shift plus assert @@ -2629,6 +2662,22 @@ void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteContr } __ bind(notByte); + __ cmp(flags, ztos); + __ br(Assembler::NE, notBool); + + // ztos + { + __ pop(ztos); + if (!is_static) pop_and_check_object(obj); + __ andw(r0, r0, 0x1); + __ strb(r0, field); + if (!is_static) { + patch_bytecode(Bytecodes::_fast_zputfield, bc, r1, true, byte_no); + } + __ b(Done); + } + + __ bind(notBool); __ cmp(flags, atos); __ br(Assembler::NE, notObj); @@ -2783,6 +2832,7 @@ void TemplateTable::jvmti_post_fast_field_mod() switch (bytecode()) { // load values into the jvalue object case Bytecodes::_fast_aputfield: __ push_ptr(r0); break; case Bytecodes::_fast_bputfield: // fall through + case Bytecodes::_fast_zputfield: // fall through case Bytecodes::_fast_sputfield: // fall through case Bytecodes::_fast_cputfield: // fall through case Bytecodes::_fast_iputfield: __ push_i(r0); break; @@ -2808,6 +2858,7 @@ void TemplateTable::jvmti_post_fast_field_mod() switch (bytecode()) { // restore tos values case Bytecodes::_fast_aputfield: __ pop_ptr(r0); break; case Bytecodes::_fast_bputfield: // fall through + case Bytecodes::_fast_zputfield: // fall through case Bytecodes::_fast_sputfield: // fall through case Bytecodes::_fast_cputfield: // fall through case Bytecodes::_fast_iputfield: __ pop_i(r0); break; @@ -2863,6 +2914,9 @@ void TemplateTable::fast_storefield(TosState state) case Bytecodes::_fast_iputfield: __ strw(r0, field); break; + case Bytecodes::_fast_zputfield: + __ andw(r0, r0, 0x1); // boolean is true if LSB is 1 + // fall through to bputfield case Bytecodes::_fast_bputfield: __ strb(r0, field); break; -- GitLab From 187fe4afd1a294a6e16a903cc595276b845510cb Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 25 Apr 2016 12:42:29 +0200 Subject: [PATCH 198/400] 8154996: [aix] Implement compare_file_modified_times for "8146879: Add option ..." Reviewed-by: simonis --- hotspot/src/os/aix/vm/os_aix.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp index 22e016b65f2..a39238f5db8 100644 --- a/hotspot/src/os/aix/vm/os_aix.cpp +++ b/hotspot/src/os/aix/vm/os_aix.cpp @@ -4875,3 +4875,16 @@ bool os::start_debugging(char *buf, int buflen) { } return yes; } + +static inline time_t get_mtime(const char* filename) { + struct stat st; + int ret = os::stat(filename, &st); + assert(ret == 0, "failed to stat() file '%s': %s", filename, strerror(errno)); + return st.st_mtime; +} + +int os::compare_file_modified_times(const char* file1, const char* file2) { + time_t t1 = get_mtime(file1); + time_t t2 = get_mtime(file2); + return t1 - t2; +} -- GitLab From e17b342749bd50e63f77847c5febeb88cfe81153 Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Mon, 25 Apr 2016 18:36:27 +0300 Subject: [PATCH 199/400] 8134918: C2: Type speculation produces mismatched unsafe accesses Reviewed-by: kvn --- hotspot/src/share/vm/opto/compile.cpp | 11 +++ hotspot/src/share/vm/opto/compile.hpp | 2 + hotspot/src/share/vm/opto/library_call.cpp | 64 ++++++++------ .../test/compiler/profiling/UnsafeAccess.java | 88 +++++++++++++++++++ 4 files changed, 137 insertions(+), 28 deletions(-) create mode 100644 hotspot/test/compiler/profiling/UnsafeAccess.java diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index cd212ea015c..25cb6e90a34 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -1623,6 +1623,17 @@ void Compile::AliasType::Init(int i, const TypePtr* at) { } } +BasicType Compile::AliasType::basic_type() const { + if (element() != NULL) { + const Type* element = adr_type()->is_aryptr()->elem(); + return element->isa_narrowoop() ? T_OBJECT : element->array_element_basic_type(); + } if (field() != NULL) { + return field()->layout_type(); + } else { + return T_ILLEGAL; // unknown + } +} + //---------------------------------print_on------------------------------------ #ifndef PRODUCT void Compile::AliasType::print_on(outputStream* st) { diff --git a/hotspot/src/share/vm/opto/compile.hpp b/hotspot/src/share/vm/opto/compile.hpp index 7076f4a68ef..115072630bf 100644 --- a/hotspot/src/share/vm/opto/compile.hpp +++ b/hotspot/src/share/vm/opto/compile.hpp @@ -213,6 +213,8 @@ class Compile : public Phase { _element = e; } + BasicType basic_type() const; + void print_on(outputStream* st) PRODUCT_RETURN; }; diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 54e93bb18d9..aca79cbc6e2 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -2341,6 +2341,7 @@ bool LibraryCallKit::inline_unsafe_access(const bool is_native_ptr, bool is_stor if (callee()->is_static()) return false; // caller must have the capability! guarantee(!is_store || kind != Acquire, "Acquire accesses can be produced only for loads"); guarantee( is_store || kind != Release, "Release accesses can be produced only for stores"); + assert(type != T_OBJECT || !unaligned, "unaligned access not supported with object type"); #ifndef PRODUCT { @@ -2416,14 +2417,35 @@ bool LibraryCallKit::inline_unsafe_access(const bool is_native_ptr, bool is_stor const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); - // First guess at the value type. - const Type *value_type = Type::get_const_basic_type(type); - // Try to categorize the address. If it comes up as TypeJavaPtr::BOTTOM, // there was not enough information to nail it down. Compile::AliasType* alias_type = C->alias_type(adr_type); assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here"); + assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM || + alias_type->basic_type() != T_ILLEGAL, "field, array element or unknown"); + bool mismatched = false; + BasicType bt = alias_type->basic_type(); + if (bt != T_ILLEGAL) { + if (bt == T_BYTE && adr_type->isa_aryptr()) { + // Alias type doesn't differentiate between byte[] and boolean[]). + // Use address type to get the element type. + bt = adr_type->is_aryptr()->elem()->array_element_basic_type(); + } + if (bt == T_ARRAY || bt == T_NARROWOOP) { + // accessing an array field with getObject is not a mismatch + bt = T_OBJECT; + } + if ((bt == T_OBJECT) != (type == T_OBJECT)) { + // Don't intrinsify mismatched object accesses + return false; + } + mismatched = (bt != type); + } + + // First guess at the value type. + const Type *value_type = Type::get_const_basic_type(type); + // We will need memory barriers unless we can determine a unique // alias category for this reference. (Note: If for some reason // the barriers get omitted and the unsafe reference begins to "pollute" @@ -2524,29 +2546,6 @@ bool LibraryCallKit::inline_unsafe_access(const bool is_native_ptr, bool is_stor // of safe & unsafe memory. if (need_mem_bar) insert_mem_bar(Op_MemBarCPUOrder); - assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM || - alias_type->field() != NULL || alias_type->element() != NULL, "field, array element or unknown"); - bool mismatched = false; - if (alias_type->element() != NULL || alias_type->field() != NULL) { - BasicType bt; - if (alias_type->element() != NULL) { - // Use address type to get the element type. Alias type doesn't provide - // enough information (e.g., doesn't differentiate between byte[] and boolean[]). - const Type* element = adr_type->is_aryptr()->elem(); - bt = element->isa_narrowoop() ? T_OBJECT : element->array_element_basic_type(); - } else { - bt = alias_type->field()->layout_type(); - } - if (bt == T_ARRAY) { - // accessing an array field with getObject is not a mismatch - bt = T_OBJECT; - } - if (bt != type) { - mismatched = true; - } - } - assert(type != T_OBJECT || !unaligned, "unaligned access not supported with object type"); - if (!is_store) { Node* p = NULL; // Try to constant fold a load from a constant field @@ -2814,11 +2813,20 @@ bool LibraryCallKit::inline_unsafe_load_store(const BasicType type, const LoadSt Node* adr = make_unsafe_address(base, offset); const TypePtr *adr_type = _gvn.type(adr)->isa_ptr(); + Compile::AliasType* alias_type = C->alias_type(adr_type); + assert(alias_type->adr_type() == TypeRawPtr::BOTTOM || alias_type->adr_type() == TypeOopPtr::BOTTOM || + alias_type->basic_type() != T_ILLEGAL, "field, array element or unknown"); + BasicType bt = alias_type->basic_type(); + if (bt != T_ILLEGAL && + ((bt == T_OBJECT || bt == T_ARRAY) != (type == T_OBJECT))) { + // Don't intrinsify mismatched object accesses. + return false; + } + // For CAS, unlike inline_unsafe_access, there seems no point in // trying to refine types. Just use the coarse types here. - const Type *value_type = Type::get_const_basic_type(type); - Compile::AliasType* alias_type = C->alias_type(adr_type); assert(alias_type->index() != Compile::AliasIdxBot, "no bare pointers here"); + const Type *value_type = Type::get_const_basic_type(type); switch (kind) { case LS_get_set: diff --git a/hotspot/test/compiler/profiling/UnsafeAccess.java b/hotspot/test/compiler/profiling/UnsafeAccess.java new file mode 100644 index 00000000000..780824f1bdb --- /dev/null +++ b/hotspot/test/compiler/profiling/UnsafeAccess.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/* + * @test + * @bug 8134918 + * @modules java.base/jdk.internal.misc + * @run main/bootclasspath -XX:+IgnoreUnrecognizedVMOptions -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation -Xbatch + * -XX:CompileCommand=dontinline,UnsafeAccess::test* + * UnsafeAccess + */ +import jdk.internal.misc.Unsafe; + +public class UnsafeAccess { + private static final Unsafe U = Unsafe.getUnsafe(); + + static Class cls = Object.class; + static long off = U.ARRAY_OBJECT_BASE_OFFSET; + + static Object testUnsafeAccess(Object o, boolean isObjArray) { + if (o != null && cls.isInstance(o)) { // speculates "o" type to int[] + return helperUnsafeAccess(o, isObjArray); + } + return null; + } + + static Object helperUnsafeAccess(Object o, boolean isObjArray) { + if (isObjArray) { + U.putObject(o, off, new Object()); + } + return o; + } + + static Object testUnsafeLoadStore(Object o, boolean isObjArray) { + if (o != null && cls.isInstance(o)) { // speculates "o" type to int[] + return helperUnsafeLoadStore(o, isObjArray); + } + return null; + } + + static Object helperUnsafeLoadStore(Object o, boolean isObjArray) { + if (isObjArray) { + Object o1 = U.getObject(o, off); + U.compareAndSwapObject(o, off, o1, new Object()); + } + return o; + } + + public static void main(String[] args) { + Object[] objArray = new Object[10]; + int[] intArray = new int[10]; + + for (int i = 0; i < 20_000; i++) { + helperUnsafeAccess(objArray, true); + } + for (int i = 0; i < 20_000; i++) { + testUnsafeAccess(intArray, false); + } + + for (int i = 0; i < 20_000; i++) { + helperUnsafeLoadStore(objArray, true); + } + for (int i = 0; i < 20_000; i++) { + testUnsafeLoadStore(intArray, false); + } + + System.out.println("TEST PASSED"); + } +} -- GitLab From 67ff4391ec69802f7d47fdd131b5f1f0c24bd661 Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Mon, 25 Apr 2016 21:25:22 +0300 Subject: [PATCH 200/400] 8154172: C1: NPE is thrown instead of linkage error when invoking nonexistent method Reviewed-by: kvn --- hotspot/src/share/vm/c1/c1_GraphBuilder.cpp | 82 ++++++-------- hotspot/test/compiler/linkage/CallSites.jasm | 91 +++++++++++++++ .../test/compiler/linkage/LinkageErrors.java | 106 ++++++++++++++++++ 3 files changed, 231 insertions(+), 48 deletions(-) create mode 100644 hotspot/test/compiler/linkage/CallSites.jasm create mode 100644 hotspot/test/compiler/linkage/LinkageErrors.java diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index b09eeb4bc81..9b88434f2a1 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -1742,25 +1742,14 @@ void GraphBuilder::invoke(Bytecodes::Code code) { const Bytecodes::Code bc_raw = stream()->cur_bc_raw(); assert(declared_signature != NULL, "cannot be null"); - // we have to make sure the argument size (incl. the receiver) - // is correct for compilation (the call would fail later during - // linkage anyway) - was bug (gri 7/28/99) - { - // Use raw to get rewritten bytecode. - const bool is_invokestatic = bc_raw == Bytecodes::_invokestatic; - const bool allow_static = - is_invokestatic || - bc_raw == Bytecodes::_invokehandle || - bc_raw == Bytecodes::_invokedynamic; - if (target->is_loaded()) { - if (( target->is_static() && !allow_static) || - (!target->is_static() && is_invokestatic)) { - BAILOUT("will cause link error"); - } - } - } ciInstanceKlass* klass = target->holder(); + // Make sure there are no evident problems with linking the instruction. + bool is_resolved = true; + if (klass->is_loaded() && !target->is_loaded()) { + is_resolved = false; // method not found + } + // check if CHA possible: if so, change the code to invoke_special ciInstanceKlass* calling_klass = method()->holder(); ciInstanceKlass* callee_holder = ciEnv::get_instance_klass_for_declared_method_holder(holder); @@ -1804,10 +1793,6 @@ void GraphBuilder::invoke(Bytecodes::Code code) { apush(arg); } - // NEEDS_CLEANUP - // I've added the target->is_loaded() test below but I don't really understand - // how klass->is_loaded() can be true and yet target->is_loaded() is false. - // this happened while running the JCK invokevirtual tests under doit. TKR ciMethod* cha_monomorphic_target = NULL; ciMethod* exact_target = NULL; Value better_receiver = NULL; @@ -1931,12 +1916,11 @@ void GraphBuilder::invoke(Bytecodes::Code code) { } // check if we could do inlining - if (!PatchALot && Inline && klass->is_loaded() && + if (!PatchALot && Inline && is_resolved && + klass->is_loaded() && target->is_loaded() && (klass->is_initialized() || klass->is_interface() && target->holder()->is_initialized()) - && target->is_loaded() && !patch_for_appendix) { // callee is known => check if we have static binding - assert(target->is_loaded(), "callee must be known"); if (code == Bytecodes::_invokestatic || code == Bytecodes::_invokespecial || code == Bytecodes::_invokevirtual && target->is_final_method() || @@ -1993,7 +1977,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) { // Currently only supported on Sparc. // The UseInlineCaches only controls dispatch to invokevirtuals for // loaded classes which we weren't able to statically bind. - if (!UseInlineCaches && is_loaded && code == Bytecodes::_invokevirtual + if (!UseInlineCaches && is_resolved && is_loaded && code == Bytecodes::_invokevirtual && !target->can_be_statically_bound()) { // Find a vtable index if one is available // For arrays, callee_holder is Object. Resolving the call with @@ -2006,35 +1990,37 @@ void GraphBuilder::invoke(Bytecodes::Code code) { } #endif - if (recv != NULL && - (code == Bytecodes::_invokespecial || - !is_loaded || target->is_final())) { - // invokespecial always needs a NULL check. invokevirtual where - // the target is final or where it's not known that whether the - // target is final requires a NULL check. Otherwise normal - // invokevirtual will perform the null check during the lookup - // logic or the unverified entry point. Profiling of calls - // requires that the null check is performed in all cases. - null_check(recv); - } + if (is_resolved) { + // invokespecial always needs a NULL check. invokevirtual where the target is + // final or where it's not known whether the target is final requires a NULL check. + // Otherwise normal invokevirtual will perform the null check during the lookup + // logic or the unverified entry point. Profiling of calls requires that + // the null check is performed in all cases. + bool do_null_check = (recv != NULL) && + (code == Bytecodes::_invokespecial || !is_loaded || target->is_final() || (is_profiling() && profile_calls())); - if (is_profiling()) { - if (recv != NULL && profile_calls()) { + if (do_null_check) { null_check(recv); } - // Note that we'd collect profile data in this method if we wanted it. - compilation()->set_would_profile(true); - if (profile_calls()) { - assert(cha_monomorphic_target == NULL || exact_target == NULL, "both can not be set"); - ciKlass* target_klass = NULL; - if (cha_monomorphic_target != NULL) { - target_klass = cha_monomorphic_target->holder(); - } else if (exact_target != NULL) { - target_klass = exact_target->holder(); + if (is_profiling()) { + // Note that we'd collect profile data in this method if we wanted it. + compilation()->set_would_profile(true); + + if (profile_calls()) { + assert(cha_monomorphic_target == NULL || exact_target == NULL, "both can not be set"); + ciKlass* target_klass = NULL; + if (cha_monomorphic_target != NULL) { + target_klass = cha_monomorphic_target->holder(); + } else if (exact_target != NULL) { + target_klass = exact_target->holder(); + } + profile_call(target, recv, target_klass, collect_args_for_profiling(args, NULL, false), false); } - profile_call(target, recv, target_klass, collect_args_for_profiling(args, NULL, false), false); } + } else { + // No need in null check or profiling: linkage error will be thrown at runtime + // during resolution. } Invoke* result = new Invoke(code, result_type, recv, args, vtable_index, target, state_before); diff --git a/hotspot/test/compiler/linkage/CallSites.jasm b/hotspot/test/compiler/linkage/CallSites.jasm new file mode 100644 index 00000000000..813a9df40c7 --- /dev/null +++ b/hotspot/test/compiler/linkage/CallSites.jasm @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +super class I +version 52:0 +{ + +} + + +super class CallSites +version 52:0 +{ + + // Non-existent methods. + + // I.m1()V vs I.m1(I)V + public static Method testI1:"(LI;)V" + stack 1 locals 1 + { + aload_0; + invokeinterface InterfaceMethod I."m1":"()V", 1; // throws NSME + return; + } + + // X.m1()V vs X.m1(I)V + public static Method testX1:"(LX;)V" + stack 1 locals 1 + { + aload_0; + invokevirtual Method X."m1":"()V"; // throws NSME + return; + } + + // invokestatic of instance methods. + + public static Method testI2:"()V" + stack 1 locals 0 + { + iconst_0; + invokestatic InterfaceMethod I."m1":"(I)V"; // throws ICCE + return; + } + + public static Method testX2:"()V" + stack 1 locals 0 + { + iconst_0; + invokestatic Method X."m1":"(I)V"; // throws ICCE + return; + } + + // Virtual invocation of static methods. + + public static Method testI3:"(LI;)V" + stack 1 locals 1 + { + aload_0; + invokeinterface InterfaceMethod I."s1":"()V", 1; // throws ICCE + return; + } + + public static Method testX3:"(LX;)V" + stack 1 locals 1 + { + aload_0; + invokevirtual Method X."s1":"()V"; // throws ICCE + return; + } + +} // end Class CallSites diff --git a/hotspot/test/compiler/linkage/LinkageErrors.java b/hotspot/test/compiler/linkage/LinkageErrors.java new file mode 100644 index 00000000000..0a1b2a8b954 --- /dev/null +++ b/hotspot/test/compiler/linkage/LinkageErrors.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +/* + * @test + * @bug 8132879 + * @compile CallSites.jasm + * @run main/othervm -Xverify:all -Xbatch -XX:CompileCommand=dontinline,Test::test* LinkageErrors + */ + +import java.lang.invoke.*; + +interface I { + void m1(int i); + static void s1() {} +} + +class A implements I { + public void m1(int i) {} +} + +class X { + public void m1(int i) {} + public final void f1(int i) {} + public static void s1(int i) {} +} + +public class LinkageErrors { + final static MethodHandles.Lookup L = MethodHandles.lookup(); + + static void test(MethodHandle mh) { + try { + mh.invokeExact(); + throw new AssertionError("No exception thrown"); + } catch (LinkageError e) { + return; // expected + } catch (AssertionError e) { + throw e; // rethrow + } catch (Throwable e) { + throw new AssertionError("Unexpected exception", e); + } + } + + public static void main(String args[]) throws Throwable { + Class test = Class.forName("CallSites"); + + // Non-existent method lookups. + MethodHandle testI1 = L.findStatic(test, "testI1", MethodType.methodType(void.class, I.class)); + MethodHandle testX1 = L.findStatic(test, "testX1", MethodType.methodType(void.class, X.class)); + + MethodHandle testI1_A = testI1.bindTo(new A()); + MethodHandle testI1_null = testI1.bindTo(null); + MethodHandle testX1_X = testX1.bindTo(new X()); + MethodHandle testX1_null = testX1.bindTo(null); + + // invokestatic of instance methods. + MethodHandle testI2 = L.findStatic(test, "testI2", MethodType.methodType(void.class)); + MethodHandle testX2 = L.findStatic(test, "testX2", MethodType.methodType(void.class)); + + MethodHandle testI3 = L.findStatic(test, "testI3", MethodType.methodType(void.class, I.class)); + MethodHandle testX3 = L.findStatic(test, "testX3", MethodType.methodType(void.class, X.class)); + + // Virtual invocation of static methods. + MethodHandle testI3_A = testI3.bindTo(new A()); + MethodHandle testI3_null = testI3.bindTo(null); + MethodHandle testX3_X = testX3.bindTo(new X()); + MethodHandle testX3_null = testX3.bindTo(null); + + for (int i = 0; i < 20_000; i++) { + test(testI1_A); + test(testI1_null); + test(testX1_X); + test(testX1_null); + + test(testI2); + test(testX2); + + test(testI3_A); + test(testI3_null); + test(testX3_X); + test(testX3_null); + } + + System.out.println("TEST PASSED"); + } +} -- GitLab From b853eb7f5ca24eeeda18acbb14287f706499c365 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rickard=20B=C3=A4ckman?= Date: Tue, 26 Apr 2016 10:28:51 +0200 Subject: [PATCH 201/400] 8151956: Support non-continuous CodeBlobs in HotSpot Reviewed-by: iveresov, thartmann, simonis --- hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp | 38 +- hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp | 4 +- .../cpu/aarch64/vm/frame_aarch64.inline.hpp | 10 +- .../src/cpu/aarch64/vm/nativeInst_aarch64.cpp | 2 +- hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp | 4 +- hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp | 2 +- hotspot/src/cpu/sparc/vm/frame_sparc.cpp | 18 +- hotspot/src/cpu/x86/vm/frame_x86.cpp | 40 +- hotspot/src/cpu/x86/vm/frame_x86.hpp | 2 +- hotspot/src/cpu/x86/vm/frame_x86.inline.hpp | 10 +- hotspot/src/cpu/zero/vm/frame_zero.inline.hpp | 4 +- .../sun/jvm/hotspot/code/AdapterBlob.java | 4 +- .../sun/jvm/hotspot/code/BufferBlob.java | 4 +- .../sun/jvm/hotspot/code/CodeBlob.java | 206 +++-- .../sun/jvm/hotspot/code/CompiledMethod.java | 74 ++ .../classes/sun/jvm/hotspot/code/NMethod.java | 28 +- .../sun/jvm/hotspot/code/RuntimeBlob.java | 58 ++ .../sun/jvm/hotspot/code/RuntimeStub.java | 4 +- .../sun/jvm/hotspot/code/SingletonBlob.java | 4 +- .../jdk/vm/ci/hotspot/HotSpotVMConfig.java | 2 +- .../src/os/bsd/dtrace/generateJvmOffsets.cpp | 11 +- hotspot/src/os/bsd/dtrace/libjvm_db.c | 27 +- .../os/solaris/dtrace/generateJvmOffsets.cpp | 11 +- hotspot/src/os/solaris/dtrace/libjvm_db.c | 28 +- hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp | 2 +- hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp | 2 +- .../linux_aarch64/vm/os_linux_aarch64.cpp | 2 +- .../src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp | 4 +- .../os_cpu/linux_sparc/vm/os_linux_sparc.cpp | 2 +- .../src/os_cpu/linux_x86/vm/os_linux_x86.cpp | 2 +- .../solaris_sparc/vm/os_solaris_sparc.cpp | 2 +- .../os_cpu/solaris_x86/vm/os_solaris_x86.cpp | 2 +- hotspot/src/share/vm/asm/codeBuffer.cpp | 4 +- hotspot/src/share/vm/asm/codeBuffer.hpp | 12 +- hotspot/src/share/vm/ci/ciEnv.cpp | 4 +- hotspot/src/share/vm/ci/ciMethod.cpp | 8 +- hotspot/src/share/vm/ci/ciReplay.cpp | 2 +- .../src/share/vm/classfile/classLoader.cpp | 4 +- .../src/share/vm/classfile/javaClasses.cpp | 8 +- .../vm/classfile/metadataOnStackMark.cpp | 4 +- hotspot/src/share/vm/code/codeBlob.cpp | 171 ++-- hotspot/src/share/vm/code/codeBlob.hpp | 271 ++++-- hotspot/src/share/vm/code/codeCache.cpp | 91 +- hotspot/src/share/vm/code/codeCache.hpp | 59 +- hotspot/src/share/vm/code/compiledIC.cpp | 33 +- hotspot/src/share/vm/code/compiledIC.hpp | 12 +- hotspot/src/share/vm/code/compiledMethod.cpp | 707 +++++++++++++++ hotspot/src/share/vm/code/compiledMethod.hpp | 391 +++++++++ hotspot/src/share/vm/code/debugInfo.hpp | 8 +- .../share/vm/code/exceptionHandlerTable.cpp | 14 +- .../share/vm/code/exceptionHandlerTable.hpp | 6 +- hotspot/src/share/vm/code/icBuffer.cpp | 6 +- hotspot/src/share/vm/code/nmethod.cpp | 828 ++---------------- hotspot/src/share/vm/code/nmethod.hpp | 313 ++----- hotspot/src/share/vm/code/pcDesc.cpp | 8 +- hotspot/src/share/vm/code/pcDesc.hpp | 10 +- hotspot/src/share/vm/code/relocInfo.cpp | 10 +- hotspot/src/share/vm/code/relocInfo.hpp | 22 +- hotspot/src/share/vm/code/scopeDesc.cpp | 6 +- hotspot/src/share/vm/code/scopeDesc.hpp | 10 +- .../src/share/vm/compiler/compileBroker.cpp | 15 +- hotspot/src/share/vm/compiler/compileTask.cpp | 6 +- .../src/share/vm/gc/g1/g1CollectedHeap.cpp | 54 +- .../src/share/vm/jvmci/jvmciCompilerToVM.cpp | 2 +- hotspot/src/share/vm/jvmci/jvmciEnv.cpp | 2 +- hotspot/src/share/vm/jvmci/jvmciRuntime.cpp | 26 +- .../src/share/vm/jvmci/vmStructs_jvmci.cpp | 2 +- hotspot/src/share/vm/oops/method.cpp | 6 +- hotspot/src/share/vm/oops/method.hpp | 7 +- hotspot/src/share/vm/opto/compile.cpp | 2 +- hotspot/src/share/vm/opto/runtime.cpp | 6 +- hotspot/src/share/vm/prims/whitebox.cpp | 14 +- .../vm/runtime/advancedThresholdPolicy.cpp | 4 +- .../vm/runtime/advancedThresholdPolicy.hpp | 6 +- .../share/vm/runtime/compilationPolicy.cpp | 6 +- .../share/vm/runtime/compilationPolicy.hpp | 6 +- .../src/share/vm/runtime/deoptimization.cpp | 49 +- hotspot/src/share/vm/runtime/fprofiler.cpp | 34 +- hotspot/src/share/vm/runtime/frame.cpp | 60 +- hotspot/src/share/vm/runtime/rframe.cpp | 6 +- hotspot/src/share/vm/runtime/safepoint.cpp | 4 +- .../src/share/vm/runtime/sharedRuntime.cpp | 93 +- .../src/share/vm/runtime/sharedRuntime.hpp | 4 +- .../vm/runtime/simpleThresholdPolicy.cpp | 8 +- .../vm/runtime/simpleThresholdPolicy.hpp | 10 +- hotspot/src/share/vm/runtime/stubRoutines.hpp | 6 +- hotspot/src/share/vm/runtime/sweeper.cpp | 108 +-- hotspot/src/share/vm/runtime/sweeper.hpp | 9 +- hotspot/src/share/vm/runtime/thread.cpp | 14 +- hotspot/src/share/vm/runtime/thread.hpp | 16 +- hotspot/src/share/vm/runtime/vframe.cpp | 6 +- hotspot/src/share/vm/runtime/vframe.hpp | 16 +- hotspot/src/share/vm/runtime/vframeArray.cpp | 6 +- hotspot/src/share/vm/runtime/vframe_hp.cpp | 22 +- hotspot/src/share/vm/runtime/vframe_hp.hpp | 6 +- hotspot/src/share/vm/runtime/vmStructs.cpp | 51 +- .../share/vm/utilities/globalDefinitions.hpp | 4 +- .../codecache/jmx/InitialAndMaxUsageTest.java | 4 +- .../jmx/UsageThresholdIncreasedTest.java | 4 +- .../jmx/UsageThresholdNotExceededTest.java | 9 +- 100 files changed, 2483 insertions(+), 1865 deletions(-) create mode 100644 hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CompiledMethod.java create mode 100644 hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeBlob.java create mode 100644 hotspot/src/share/vm/code/compiledMethod.cpp create mode 100644 hotspot/src/share/vm/code/compiledMethod.hpp diff --git a/hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp index bce575a10af..42c61b9a33f 100644 --- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -221,21 +221,19 @@ bool frame::safe_for_sender(JavaThread *thread) { return jcw_safe; } - if (sender_blob->is_nmethod()) { - nmethod* nm = sender_blob->as_nmethod_or_null(); - if (nm != NULL) { - if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) || - nm->method()->is_method_handle_intrinsic()) { - return false; - } - } + CompiledMethod* nm = sender_blob->as_compiled_method_or_null(); + if (nm != NULL) { + if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) || + nm->method()->is_method_handle_intrinsic()) { + return false; + } } // If the frame size is 0 something (or less) is bad because every nmethod has a non-zero frame size // because the return address counts against the callee's frame. if (sender_blob->frame_size() <= 0) { - assert(!sender_blob->is_nmethod(), "should count return address at least"); + assert(!sender_blob->is_compiled(), "should count return address at least"); return false; } @@ -244,7 +242,7 @@ bool frame::safe_for_sender(JavaThread *thread) { // should not be anything but the call stub (already covered), the interpreter (already covered) // or an nmethod. - if (!sender_blob->is_nmethod()) { + if (!sender_blob->is_compiled()) { return false; } @@ -286,7 +284,7 @@ void frame::patch_pc(Thread* thread, address pc) { assert(_pc == *pc_addr || pc == *pc_addr, "must be"); *pc_addr = pc; _cb = CodeCache::find_blob(pc); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = CompiledMethod::get_deopt_original_pc(this); if (original_pc != NULL) { assert(original_pc == _pc, "expected original PC to be stored before patching"); _deopt_state = is_deoptimized; @@ -371,7 +369,7 @@ frame frame::sender_for_entry_frame(RegisterMap* map) const { // Verifies the calculated original PC of a deoptimization PC for the // given unextended SP. #ifdef ASSERT -void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp) { +void frame::verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp) { frame fr; // This is ugly but it's better than to change {get,set}_original_pc @@ -391,12 +389,14 @@ void frame::adjust_unextended_sp() { // as any other call site. Therefore, no special action is needed when we are // returning to any of these call sites. - nmethod* sender_nm = (_cb == NULL) ? NULL : _cb->as_nmethod_or_null(); - if (sender_nm != NULL) { - // If the sender PC is a deoptimization point, get the original PC. - if (sender_nm->is_deopt_entry(_pc) || - sender_nm->is_deopt_mh_entry(_pc)) { - DEBUG_ONLY(verify_deopt_original_pc(sender_nm, _unextended_sp)); + if (_cb != NULL) { + CompiledMethod* sender_cm = _cb->as_compiled_method_or_null(); + if (sender_cm != NULL) { + // If the sender PC is a deoptimization point, get the original PC. + if (sender_cm->is_deopt_entry(_pc) || + sender_cm->is_deopt_mh_entry(_pc)) { + DEBUG_ONLY(verify_deopt_original_pc(sender_cm, _unextended_sp)); + } } } } diff --git a/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp index 4332abce9f4..a88df060204 100644 --- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -124,7 +124,7 @@ #ifdef ASSERT // Used in frame::sender_for_{interpreter,compiled}_frame - static void verify_deopt_original_pc( nmethod* nm, intptr_t* unextended_sp); + static void verify_deopt_original_pc( CompiledMethod* nm, intptr_t* unextended_sp); #endif public: diff --git a/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp b/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp index 7fce68be5b9..4250354fea3 100644 --- a/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp +++ b/hotspot/src/cpu/aarch64/vm/frame_aarch64.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Red Hat Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -55,7 +55,7 @@ inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) { _cb = CodeCache::find_blob(pc); adjust_unextended_sp(); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = CompiledMethod::get_deopt_original_pc(this); if (original_pc != NULL) { _pc = original_pc; _deopt_state = is_deoptimized; @@ -79,10 +79,10 @@ inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address _cb = CodeCache::find_blob(pc); adjust_unextended_sp(); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = CompiledMethod::get_deopt_original_pc(this); if (original_pc != NULL) { _pc = original_pc; - assert(((nmethod*)_cb)->insts_contains(_pc), "original PC must be in nmethod"); + assert(((CompiledMethod*)_cb)->insts_contains(_pc), "original PC must be in CompiledMethod"); _deopt_state = is_deoptimized; } else { _deopt_state = not_deoptimized; @@ -111,7 +111,7 @@ inline frame::frame(intptr_t* sp, intptr_t* fp) { _cb = CodeCache::find_blob(_pc); adjust_unextended_sp(); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = CompiledMethod::get_deopt_original_pc(this); if (original_pc != NULL) { _pc = original_pc; _deopt_state = is_deoptimized; diff --git a/hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.cpp index e36434cc183..88e1d3d1460 100644 --- a/hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/nativeInst_aarch64.cpp @@ -99,7 +99,7 @@ address NativeCall::get_trampoline() { address bl_destination = MacroAssembler::pd_call_destination(call_addr); - if (code->content_contains(bl_destination) && + if (code->contains(bl_destination) && is_NativeCallTrampolineStub_at(bl_destination)) return bl_destination; diff --git a/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp b/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp index 7fce0585f10..f3335918404 100644 --- a/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp +++ b/hotspot/src/cpu/ppc/vm/frame_ppc.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -40,7 +40,7 @@ inline void frame::find_codeblob_and_set_pc_and_deopt_state(address pc) { _fp = (intptr_t*)own_abi()->callers_sp; - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = CompiledMethod::get_deopt_original_pc(this); if (original_pc != NULL) { _pc = original_pc; _deopt_state = is_deoptimized; diff --git a/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp b/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp index 08704344050..70cd4ebbd91 100644 --- a/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/nativeInst_ppc.cpp @@ -137,7 +137,7 @@ address NativeCall::get_trampoline() { return NULL; address bl_destination = Assembler::bxx_destination(call_addr); - if (code->content_contains(bl_destination) && + if (code->contains(bl_destination) && is_NativeCallTrampolineStub_at(bl_destination)) return bl_destination; diff --git a/hotspot/src/cpu/sparc/vm/frame_sparc.cpp b/hotspot/src/cpu/sparc/vm/frame_sparc.cpp index a9ac2a97a76..01a8cddc337 100644 --- a/hotspot/src/cpu/sparc/vm/frame_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/frame_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -212,7 +212,7 @@ bool frame::safe_for_sender(JavaThread *thread) { // ok. adapter blobs never have a frame complete and are never ok. if (!_cb->is_frame_complete_at(_pc)) { - if (_cb->is_nmethod() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) { + if (_cb->is_compiled() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) { return false; } } @@ -304,7 +304,7 @@ bool frame::safe_for_sender(JavaThread *thread) { // because you must allocate window space if (sender_blob->frame_size() <= 0) { - assert(!sender_blob->is_nmethod(), "should count return address at least"); + assert(!sender_blob->is_compiled(), "should count return address at least"); return false; } @@ -315,7 +315,7 @@ bool frame::safe_for_sender(JavaThread *thread) { // the stack unwalkable. pd_get_top_frame_for_signal_handler tries to recover from this by unwinding // that initial frame and retrying. - if (!sender_blob->is_nmethod()) { + if (!sender_blob->is_compiled()) { return false; } @@ -358,9 +358,9 @@ void frame::init(intptr_t* sp, address pc, CodeBlob* cb) { } _deopt_state = unknown; #ifdef ASSERT - if ( _cb != NULL && _cb->is_nmethod()) { + if ( _cb != NULL && _cb->is_compiled()) { // Without a valid unextended_sp() we can't convert the pc to "original" - assert(!((nmethod*)_cb)->is_deopt_pc(_pc), "invariant broken"); + assert(!((CompiledMethod*)_cb)->is_deopt_pc(_pc), "invariant broken"); } #endif // ASSERT } @@ -393,7 +393,7 @@ frame::frame(intptr_t* sp, intptr_t* younger_sp, bool younger_frame_is_interpret // Check for MethodHandle call sites. if (_cb != NULL) { - nmethod* nm = _cb->as_nmethod_or_null(); + CompiledMethod* nm = _cb->as_compiled_method_or_null(); if (nm != NULL) { if (nm->is_deopt_mh_entry(_pc) || nm->is_method_handle_return(_pc)) { _sp_adjustment_by_callee = (intptr_t*) ((intptr_t) sp[L7_mh_SP_save->sp_offset_in_saved_window()] + STACK_BIAS) - sp; @@ -413,7 +413,7 @@ frame::frame(intptr_t* sp, intptr_t* younger_sp, bool younger_frame_is_interpret // this lookup as get_deopt_original_pc() needs a correct value for // unextended_sp() which uses _sp_adjustment_by_callee. if (_pc != NULL) { - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = CompiledMethod::get_deopt_original_pc(this); if (original_pc != NULL) { _pc = original_pc; _deopt_state = is_deoptimized; @@ -547,7 +547,7 @@ void frame::patch_pc(Thread* thread, address pc) { _cb = CodeCache::find_blob(pc); *O7_addr() = pc - pc_return_offset; _cb = CodeCache::find_blob(_pc); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = CompiledMethod::get_deopt_original_pc(this); if (original_pc != NULL) { assert(original_pc == _pc, "expected original to be stored before patching"); _deopt_state = is_deoptimized; diff --git a/hotspot/src/cpu/x86/vm/frame_x86.cpp b/hotspot/src/cpu/x86/vm/frame_x86.cpp index d61ae16729c..73d17151fe6 100644 --- a/hotspot/src/cpu/x86/vm/frame_x86.cpp +++ b/hotspot/src/cpu/x86/vm/frame_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,7 +95,7 @@ bool frame::safe_for_sender(JavaThread *thread) { // ok. adapter blobs never have a frame complete and are never ok. if (!_cb->is_frame_complete_at(_pc)) { - if (_cb->is_nmethod() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) { + if (_cb->is_compiled() || _cb->is_adapter_blob() || _cb->is_runtime_stub()) { return false; } } @@ -220,13 +220,11 @@ bool frame::safe_for_sender(JavaThread *thread) { return jcw_safe; } - if (sender_blob->is_nmethod()) { - nmethod* nm = sender_blob->as_nmethod_or_null(); - if (nm != NULL) { - if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) || - nm->method()->is_method_handle_intrinsic()) { - return false; - } + CompiledMethod* nm = sender_blob->as_compiled_method_or_null(); + if (nm != NULL) { + if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) || + nm->method()->is_method_handle_intrinsic()) { + return false; } } @@ -234,7 +232,7 @@ bool frame::safe_for_sender(JavaThread *thread) { // because the return address counts against the callee's frame. if (sender_blob->frame_size() <= 0) { - assert(!sender_blob->is_nmethod(), "should count return address at least"); + assert(!sender_blob->is_compiled(), "should count return address at least"); return false; } @@ -243,7 +241,7 @@ bool frame::safe_for_sender(JavaThread *thread) { // should not be anything but the call stub (already covered), the interpreter (already covered) // or an nmethod. - if (!sender_blob->is_nmethod()) { + if (!sender_blob->is_compiled()) { return false; } @@ -286,7 +284,7 @@ void frame::patch_pc(Thread* thread, address pc) { assert(_pc == *pc_addr || pc == *pc_addr, "must be"); *pc_addr = pc; _cb = CodeCache::find_blob(pc); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = CompiledMethod::get_deopt_original_pc(this); if (original_pc != NULL) { assert(original_pc == _pc, "expected original PC to be stored before patching"); _deopt_state = is_deoptimized; @@ -372,7 +370,7 @@ frame frame::sender_for_entry_frame(RegisterMap* map) const { // Verifies the calculated original PC of a deoptimization PC for the // given unextended SP. #ifdef ASSERT -void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp) { +void frame::verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp) { frame fr; // This is ugly but it's better than to change {get,set}_original_pc @@ -381,7 +379,7 @@ void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp) { fr._unextended_sp = unextended_sp; address original_pc = nm->get_original_pc(&fr); - assert(nm->insts_contains(original_pc), "original PC must be in nmethod"); + assert(nm->insts_contains(original_pc), "original PC must be in CompiledMethod"); } #endif @@ -392,12 +390,14 @@ void frame::adjust_unextended_sp() { // as any other call site. Therefore, no special action is needed when we are // returning to any of these call sites. - nmethod* sender_nm = (_cb == NULL) ? NULL : _cb->as_nmethod_or_null(); - if (sender_nm != NULL) { - // If the sender PC is a deoptimization point, get the original PC. - if (sender_nm->is_deopt_entry(_pc) || - sender_nm->is_deopt_mh_entry(_pc)) { - DEBUG_ONLY(verify_deopt_original_pc(sender_nm, _unextended_sp)); + if (_cb != NULL) { + CompiledMethod* sender_cm = _cb->as_compiled_method_or_null(); + if (sender_cm != NULL) { + // If the sender PC is a deoptimization point, get the original PC. + if (sender_cm->is_deopt_entry(_pc) || + sender_cm->is_deopt_mh_entry(_pc)) { + DEBUG_ONLY(verify_deopt_original_pc(sender_cm, _unextended_sp)); + } } } } diff --git a/hotspot/src/cpu/x86/vm/frame_x86.hpp b/hotspot/src/cpu/x86/vm/frame_x86.hpp index b10f9ce37e6..f4975029343 100644 --- a/hotspot/src/cpu/x86/vm/frame_x86.hpp +++ b/hotspot/src/cpu/x86/vm/frame_x86.hpp @@ -124,7 +124,7 @@ #ifdef ASSERT // Used in frame::sender_for_{interpreter,compiled}_frame - static void verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp); + static void verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp); #endif public: diff --git a/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp b/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp index 374d83ca5cd..22731021555 100644 --- a/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp +++ b/hotspot/src/cpu/x86/vm/frame_x86.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ inline void frame::init(intptr_t* sp, intptr_t* fp, address pc) { _cb = CodeCache::find_blob(pc); adjust_unextended_sp(); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = CompiledMethod::get_deopt_original_pc(this); if (original_pc != NULL) { _pc = original_pc; _deopt_state = is_deoptimized; @@ -72,10 +72,10 @@ inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address _cb = CodeCache::find_blob(pc); adjust_unextended_sp(); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = CompiledMethod::get_deopt_original_pc(this); if (original_pc != NULL) { _pc = original_pc; - assert(((nmethod*)_cb)->insts_contains(_pc), "original PC must be in nmethod"); + assert(((CompiledMethod*)_cb)->insts_contains(_pc), "original PC must be in CompiledMethod"); _deopt_state = is_deoptimized; } else { if (_cb->is_deoptimization_stub()) { @@ -106,7 +106,7 @@ inline frame::frame(intptr_t* sp, intptr_t* fp) { _cb = CodeCache::find_blob(_pc); adjust_unextended_sp(); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = CompiledMethod::get_deopt_original_pc(this); if (original_pc != NULL) { _pc = original_pc; _deopt_state = is_deoptimized; diff --git a/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp b/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp index f8011a25161..ffa12a540b5 100644 --- a/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp +++ b/hotspot/src/cpu/zero/vm/frame_zero.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -59,7 +59,7 @@ inline frame::frame(ZeroFrame* zf, intptr_t* sp) { case ZeroFrame::SHARK_FRAME: { _pc = zero_sharkframe()->pc(); _cb = CodeCache::find_blob_unsafe(pc()); - address original_pc = nmethod::get_deopt_original_pc(this); + address original_pc = CompiledMethod::get_deopt_original_pc(this); if (original_pc != NULL) { _pc = original_pc; _deopt_state = is_deoptimized; diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/AdapterBlob.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/AdapterBlob.java index 654a733bb2b..378e11858c4 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/AdapterBlob.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/AdapterBlob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.types.*; -public class AdapterBlob extends CodeBlob { +public class AdapterBlob extends RuntimeBlob { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/BufferBlob.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/BufferBlob.java index 5fa98b63fe3..d80eb9cd49e 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/BufferBlob.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/BufferBlob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.types.*; -public class BufferBlob extends CodeBlob { +public class BufferBlob extends RuntimeBlob { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java index a018ab83014..89bc1fcfce2 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CodeBlob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -19,84 +19,142 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ - package sun.jvm.hotspot.code; -import java.io.*; -import java.util.*; - -import sun.jvm.hotspot.compiler.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; +import sun.jvm.hotspot.compiler.ImmutableOopMap; +import sun.jvm.hotspot.compiler.ImmutableOopMapSet; +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.runtime.VM; +import sun.jvm.hotspot.runtime.VMObject; +import sun.jvm.hotspot.types.AddressField; +import sun.jvm.hotspot.types.CIntegerField; +import sun.jvm.hotspot.types.Type; +import sun.jvm.hotspot.types.TypeDataBase; +import sun.jvm.hotspot.utilities.Assert; + +import java.io.PrintStream; +import java.util.Observable; +import java.util.Observer; public class CodeBlob extends VMObject { - private static AddressField nameField; + private static AddressField nameField; private static CIntegerField sizeField; private static CIntegerField headerSizeField; - private static CIntegerField relocationSizeField; - private static CIntegerField contentOffsetField; - private static CIntegerField codeOffsetField; + private static AddressField contentBeginField; + private static AddressField codeBeginField; + private static AddressField codeEndField; + private static AddressField dataEndField; private static CIntegerField frameCompleteOffsetField; private static CIntegerField dataOffsetField; private static CIntegerField frameSizeField; private static AddressField oopMapsField; - // Only used by server compiler on x86; computed over in SA rather - // than relying on computation in target VM - private static final int NOT_YET_COMPUTED = -2; - private static final int UNDEFINED = -1; - private int linkOffset = NOT_YET_COMPUTED; - private static int matcherInterpreterFramePointerReg; - - static { - VM.registerVMInitializedObserver(new Observer() { - public void update(Observable o, Object data) { - initialize(VM.getVM().getTypeDataBase()); - } - }); + public CodeBlob(Address addr) { + super(addr); } + protected static int matcherInterpreterFramePointerReg; + private static void initialize(TypeDataBase db) { Type type = db.lookupType("CodeBlob"); nameField = type.getAddressField("_name"); sizeField = type.getCIntegerField("_size"); headerSizeField = type.getCIntegerField("_header_size"); - relocationSizeField = type.getCIntegerField("_relocation_size"); frameCompleteOffsetField = type.getCIntegerField("_frame_complete_offset"); - contentOffsetField = type.getCIntegerField("_content_offset"); - codeOffsetField = type.getCIntegerField("_code_offset"); + contentBeginField = type.getAddressField("_content_begin"); + codeBeginField = type.getAddressField("_code_begin"); + codeEndField = type.getAddressField("_code_end"); + dataEndField = type.getAddressField("_data_end"); dataOffsetField = type.getCIntegerField("_data_offset"); frameSizeField = type.getCIntegerField("_frame_size"); oopMapsField = type.getAddressField("_oop_maps"); if (VM.getVM().isServerCompiler()) { matcherInterpreterFramePointerReg = - db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue(); + db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue(); } } - public CodeBlob(Address addr) { - super(addr); + static { + VM.registerVMInitializedObserver(new Observer() { + public void update(Observable o, Object data) { + initialize(VM.getVM().getTypeDataBase()); + } + }); } + public Address headerBegin() { return getAddress(); } + + public Address headerEnd() { return getAddress().addOffsetTo(getHeaderSize()); } + + public Address contentBegin() { return contentBeginField.getValue(addr); } + + public Address contentEnd() { return headerBegin().addOffsetTo(getDataOffset()); } + + public Address codeBegin() { return codeBeginField.getValue(addr); } + + public Address codeEnd() { return codeEndField.getValue(addr); } + + public Address dataBegin() { return headerBegin().addOffsetTo(getDataOffset()); } + + public Address dataEnd() { return dataEndField.getValue(addr); } + + public long getFrameCompleteOffset() { return frameCompleteOffsetField.getValue(addr); } + + public int getDataOffset() { return (int) dataOffsetField.getValue(addr); } + + // Sizes + public int getSize() { return (int) sizeField.getValue(addr); } + + public int getHeaderSize() { return (int) headerSizeField.getValue(addr); } + + public long getFrameSizeWords() { + return (int) frameSizeField.getValue(addr); + } + + public String getName() { + return getName(); + } + + /** OopMap for frame; can return null if none available */ + + public ImmutableOopMapSet getOopMaps() { + Address value = oopMapsField.getValue(addr); + if (value == null) { + return null; + } + return new ImmutableOopMapSet(value); + } + + // Typing public boolean isBufferBlob() { return false; } + + public boolean isAOT() { return false; } + + public boolean isCompiled() { return false; } + public boolean isNMethod() { return false; } + public boolean isRuntimeStub() { return false; } + public boolean isDeoptimizationStub() { return false; } + public boolean isUncommonTrapStub() { return false; } + public boolean isExceptionStub() { return false; } + public boolean isSafepointStub() { return false; } + public boolean isAdapterBlob() { return false; } // Fine grain nmethod support: isNmethod() == isJavaMethod() || isNativeMethod() || isOSRMethod() public boolean isJavaMethod() { return false; } + public boolean isNativeMethod() { return false; } + /** On-Stack Replacement method */ public boolean isOSRMethod() { return false; } @@ -105,81 +163,32 @@ public class CodeBlob extends VMObject { return null; } - // Boundaries - public Address headerBegin() { - return addr; - } - - public Address headerEnd() { - return addr.addOffsetTo(headerSizeField.getValue(addr)); - } - - // FIXME: add RelocInfo - // public RelocInfo relocationBegin(); - // public RelocInfo relocationEnd(); - - public Address contentBegin() { - return headerBegin().addOffsetTo(contentOffsetField.getValue(addr)); - } - - public Address contentEnd() { - return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); - } - - public Address codeBegin() { - return headerBegin().addOffsetTo(contentOffsetField.getValue(addr)); - } - - public Address codeEnd() { - return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); - } - - public Address dataBegin() { - return headerBegin().addOffsetTo(dataOffsetField.getValue(addr)); - } - - public Address dataEnd() { - return headerBegin().addOffsetTo(sizeField.getValue(addr)); - } - - // Offsets - public int getRelocationOffset() { return (int) headerSizeField .getValue(addr); } - public int getContentOffset() { return (int) contentOffsetField.getValue(addr); } - public int getCodeOffset() { return (int) codeOffsetField .getValue(addr); } - public int getDataOffset() { return (int) dataOffsetField .getValue(addr); } - - // Sizes - public int getSize() { return (int) sizeField .getValue(addr); } - public int getHeaderSize() { return (int) headerSizeField.getValue(addr); } // FIXME: add getRelocationSize() public int getContentSize() { return (int) contentEnd().minus(contentBegin()); } + public int getCodeSize() { return (int) codeEnd() .minus(codeBegin()); } + public int getDataSize() { return (int) dataEnd() .minus(dataBegin()); } // Containment public boolean blobContains(Address addr) { return headerBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); } + // FIXME: add relocationContains public boolean contentContains(Address addr) { return contentBegin().lessThanOrEqual(addr) && contentEnd().greaterThan(addr); } + public boolean codeContains(Address addr) { return codeBegin() .lessThanOrEqual(addr) && codeEnd() .greaterThan(addr); } + public boolean dataContains(Address addr) { return dataBegin() .lessThanOrEqual(addr) && dataEnd() .greaterThan(addr); } + public boolean contains(Address addr) { return contentContains(addr); } - public boolean isFrameCompleteAt(Address a) { return codeContains(a) && a.minus(codeBegin()) >= frameCompleteOffsetField.getValue(addr); } + + public boolean isFrameCompleteAt(Address a) { return codeContains(a) && a.minus(codeBegin()) >= getFrameCompleteOffset(); } // Reclamation support (really only used by the nmethods, but in order to get asserts to work // in the CodeCache they are defined virtual here) public boolean isZombie() { return false; } - public boolean isLockedByVM() { return false; } - /** OopMap for frame; can return null if none available */ - public ImmutableOopMapSet getOopMaps() { - Address oopMapsAddr = oopMapsField.getValue(addr); - if (oopMapsAddr == null) { - return null; - } - return new ImmutableOopMapSet(oopMapsAddr); - } - // FIXME: not yet implementable - // void set_oop_maps(ImmutableOopMapSet* p); + public boolean isLockedByVM() { return false; } public ImmutableOopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) { Address pc = returnAddress; @@ -189,25 +198,14 @@ public class CodeBlob extends VMObject { return getOopMaps().findMapAtOffset(pc.minus(codeBegin()), debugging); } - // virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, void f(oop*)) { ShouldNotReachHere(); } - // FIXME; - /** NOTE: this returns a size in BYTES in this system! */ public long getFrameSize() { - return VM.getVM().getAddressSize() * frameSizeField.getValue(addr); + return VM.getVM().getAddressSize() * getFrameSizeWords(); } // Returns true, if the next frame is responsible for GC'ing oops passed as arguments public boolean callerMustGCArguments() { return false; } - public String getName() { - return CStringUtilities.getString(nameField.getValue(addr)); - } - - // FIXME: NOT FINISHED - - // FIXME: add more accessors - public void print() { printOn(System.out); } diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CompiledMethod.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CompiledMethod.java new file mode 100644 index 00000000000..9f883360be9 --- /dev/null +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/CompiledMethod.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package sun.jvm.hotspot.code; + +import java.util.*; + +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.oops.*; +import sun.jvm.hotspot.runtime.*; +import sun.jvm.hotspot.types.*; +import sun.jvm.hotspot.utilities.*; + +public abstract class CompiledMethod extends CodeBlob { + private static AddressField methodField; + private static AddressField deoptHandlerBeginField; + private static AddressField deoptMhHandlerBeginField; + private static AddressField scopesDataBeginField; + + static { + VM.registerVMInitializedObserver(new Observer() { + public void update(Observable o, Object data) { + initialize(VM.getVM().getTypeDataBase()); + } + }); + } + + private static void initialize(TypeDataBase db) { + Type type = db.lookupType("CompiledMethod"); + + methodField = type.getAddressField("_method"); + deoptHandlerBeginField = type.getAddressField("_deopt_handler_begin"); + deoptMhHandlerBeginField = type.getAddressField("_deopt_mh_handler_begin"); + scopesDataBeginField = type.getAddressField("_scopes_data_begin"); + } + + public CompiledMethod(Address addr) { + super(addr); + } + + public Method getMethod() { + return (Method)Metadata.instantiateWrapperFor(methodField.getValue(addr)); + } + + public Address deoptHandlerBegin() { return deoptHandlerBeginField.getValue(addr); } + public Address deoptMhHandlerBegin() { return deoptMhHandlerBeginField.getValue(addr); } + public Address scopesDataBegin() { return scopesDataBeginField.getValue(addr); } + + public static int getMethodOffset() { return (int) methodField.getOffset(); } + + @Override + public boolean isCompiled() { + return true; + } +} diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java index df8202dbd41..f2ae000b8df 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/NMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,15 +27,13 @@ package sun.jvm.hotspot.code; import java.io.*; import java.util.*; import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.memory.*; import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.utilities.*; -public class NMethod extends CodeBlob { +public class NMethod extends CompiledMethod { private static long pcDescSize; - private static AddressField methodField; /** != InvocationEntryBci if this nmethod is an on-stack replacement method */ private static CIntegerField entryBCIField; /** To support simple linked-list chaining of nmethods */ @@ -45,13 +43,10 @@ public class NMethod extends CodeBlob { /** Offsets for different nmethod parts */ private static CIntegerField exceptionOffsetField; - private static CIntegerField deoptOffsetField; - private static CIntegerField deoptMhOffsetField; private static CIntegerField origPCOffsetField; private static CIntegerField stubOffsetField; private static CIntegerField oopsOffsetField; private static CIntegerField metadataOffsetField; - private static CIntegerField scopesDataOffsetField; private static CIntegerField scopesPCsOffsetField; private static CIntegerField dependenciesOffsetField; private static CIntegerField handlerTableOffsetField; @@ -91,20 +86,16 @@ public class NMethod extends CodeBlob { private static void initialize(TypeDataBase db) { Type type = db.lookupType("nmethod"); - methodField = type.getAddressField("_method"); entryBCIField = type.getCIntegerField("_entry_bci"); osrLinkField = type.getAddressField("_osr_link"); scavengeRootLinkField = type.getAddressField("_scavenge_root_link"); scavengeRootStateField = type.getJByteField("_scavenge_root_state"); exceptionOffsetField = type.getCIntegerField("_exception_offset"); - deoptOffsetField = type.getCIntegerField("_deoptimize_offset"); - deoptMhOffsetField = type.getCIntegerField("_deoptimize_mh_offset"); origPCOffsetField = type.getCIntegerField("_orig_pc_offset"); stubOffsetField = type.getCIntegerField("_stub_offset"); oopsOffsetField = type.getCIntegerField("_oops_offset"); metadataOffsetField = type.getCIntegerField("_metadata_offset"); - scopesDataOffsetField = type.getCIntegerField("_scopes_data_offset"); scopesPCsOffsetField = type.getCIntegerField("_scopes_pcs_offset"); dependenciesOffsetField = type.getCIntegerField("_dependencies_offset"); handlerTableOffsetField = type.getCIntegerField("_handler_table_offset"); @@ -123,16 +114,11 @@ public class NMethod extends CodeBlob { super(addr); } - // Accessors public Address getAddress() { return addr; } - public Method getMethod() { - return (Method)Metadata.instantiateWrapperFor(methodField.getValue(addr)); - } - // Type info public boolean isNMethod() { return true; } public boolean isJavaMethod() { return !getMethod().isNative(); } @@ -145,15 +131,12 @@ public class NMethod extends CodeBlob { public Address instsBegin() { return codeBegin(); } public Address instsEnd() { return headerBegin().addOffsetTo(getStubOffset()); } public Address exceptionBegin() { return headerBegin().addOffsetTo(getExceptionOffset()); } - public Address deoptHandlerBegin() { return headerBegin().addOffsetTo(getDeoptOffset()); } - public Address deoptMhHandlerBegin() { return headerBegin().addOffsetTo(getDeoptMhOffset()); } public Address stubBegin() { return headerBegin().addOffsetTo(getStubOffset()); } public Address stubEnd() { return headerBegin().addOffsetTo(getOopsOffset()); } public Address oopsBegin() { return headerBegin().addOffsetTo(getOopsOffset()); } public Address oopsEnd() { return headerBegin().addOffsetTo(getMetadataOffset()); } public Address metadataBegin() { return headerBegin().addOffsetTo(getMetadataOffset()); } - public Address metadataEnd() { return headerBegin().addOffsetTo(getScopesDataOffset()); } - public Address scopesDataBegin() { return headerBegin().addOffsetTo(getScopesDataOffset()); } + public Address metadataEnd() { return scopesDataBegin(); } public Address scopesDataEnd() { return headerBegin().addOffsetTo(getScopesPCsOffset()); } public Address scopesPCsBegin() { return headerBegin().addOffsetTo(getScopesPCsOffset()); } public Address scopesPCsEnd() { return headerBegin().addOffsetTo(getDependenciesOffset()); } @@ -462,8 +445,6 @@ public class NMethod extends CodeBlob { public static int getVerifiedEntryPointOffset() { return (int) verifiedEntryPointField.getOffset(); } public static int getOSREntryPointOffset() { return (int) osrEntryPointField.getOffset(); } public static int getEntryBCIOffset() { return (int) entryBCIField.getOffset(); } - /** NOTE: renamed from "method_offset_in_bytes" */ - public static int getMethodOffset() { return (int) methodField.getOffset(); } public void print() { printOn(System.out); @@ -541,12 +522,9 @@ public class NMethod extends CodeBlob { private int getEntryBCI() { return (int) entryBCIField .getValue(addr); } private int getExceptionOffset() { return (int) exceptionOffsetField .getValue(addr); } - private int getDeoptOffset() { return (int) deoptOffsetField .getValue(addr); } - private int getDeoptMhOffset() { return (int) deoptMhOffsetField .getValue(addr); } private int getStubOffset() { return (int) stubOffsetField .getValue(addr); } private int getOopsOffset() { return (int) oopsOffsetField .getValue(addr); } private int getMetadataOffset() { return (int) metadataOffsetField .getValue(addr); } - private int getScopesDataOffset() { return (int) scopesDataOffsetField .getValue(addr); } private int getScopesPCsOffset() { return (int) scopesPCsOffsetField .getValue(addr); } private int getDependenciesOffset() { return (int) dependenciesOffsetField.getValue(addr); } private int getHandlerTableOffset() { return (int) handlerTableOffsetField.getValue(addr); } diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeBlob.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeBlob.java new file mode 100644 index 00000000000..c4077f995b0 --- /dev/null +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeBlob.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package sun.jvm.hotspot.code; + +import java.util.*; + +import sun.jvm.hotspot.compiler.*; +import sun.jvm.hotspot.debugger.*; +import sun.jvm.hotspot.runtime.*; +import sun.jvm.hotspot.types.*; +import sun.jvm.hotspot.utilities.*; + +public class RuntimeBlob extends CodeBlob { + + // Only used by server compiler on x86; computed over in SA rather + // than relying on computation in target VM + private static final int NOT_YET_COMPUTED = -2; + private static final int UNDEFINED = -1; + private int linkOffset = NOT_YET_COMPUTED; + + static { + VM.registerVMInitializedObserver(new Observer() { + public void update(Observable o, Object data) { + initialize(VM.getVM().getTypeDataBase()); + } + }); + } + + private static void initialize(TypeDataBase db) { + Type type = db.lookupType("RuntimeBlob"); + } + + public RuntimeBlob(Address addr) { + super(addr); + } +} diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeStub.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeStub.java index fd0d72aaace..98e3dc0cf81 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeStub.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/RuntimeStub.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.types.*; -public class RuntimeStub extends CodeBlob { +public class RuntimeStub extends RuntimeBlob { private static CIntegerField callerMustGCArgumentsField; static { diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/SingletonBlob.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/SingletonBlob.java index 32614929813..6d56f485a34 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/SingletonBlob.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/code/SingletonBlob.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,7 @@ import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.types.*; -public class SingletonBlob extends CodeBlob { +public class SingletonBlob extends RuntimeBlob { static { VM.registerVMInitializedObserver(new Observer() { public void update(Observable o, Object data) { diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java index dc8fb3d407e..4008207ee8b 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java @@ -1230,7 +1230,7 @@ public class HotSpotVMConfig { @HotSpotVMField(name = "Method::_method_counters", type = "MethodCounters*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCountersOffset; @HotSpotVMField(name = "Method::_method_data", type = "MethodData*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodDataOffset; @HotSpotVMField(name = "Method::_from_compiled_entry", type = "address", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCompiledEntryOffset; - @HotSpotVMField(name = "Method::_code", type = "nmethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCodeOffset; + @HotSpotVMField(name = "Method::_code", type = "CompiledMethod*", get = HotSpotVMField.Type.OFFSET) @Stable public int methodCodeOffset; @HotSpotVMConstant(name = "Method::_jfr_towrite") @Stable public int methodFlagsJfrTowrite; @HotSpotVMConstant(name = "Method::_caller_sensitive") @Stable public int methodFlagsCallerSensitive; diff --git a/hotspot/src/os/bsd/dtrace/generateJvmOffsets.cpp b/hotspot/src/os/bsd/dtrace/generateJvmOffsets.cpp index 6e012a9bee1..111f64491ab 100644 --- a/hotspot/src/os/bsd/dtrace/generateJvmOffsets.cpp +++ b/hotspot/src/os/bsd/dtrace/generateJvmOffsets.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -256,8 +256,9 @@ int generateJvmOffsets(GEN_variant gen_variant) { GEN_OFFS(CodeBlob, _name); GEN_OFFS(CodeBlob, _header_size); - GEN_OFFS(CodeBlob, _content_offset); - GEN_OFFS(CodeBlob, _code_offset); + GEN_OFFS(CodeBlob, _content_begin); + GEN_OFFS(CodeBlob, _code_begin); + GEN_OFFS(CodeBlob, _code_end); GEN_OFFS(CodeBlob, _data_offset); GEN_OFFS(CodeBlob, _frame_size); printf("\n"); @@ -265,10 +266,10 @@ int generateJvmOffsets(GEN_variant gen_variant) { GEN_OFFS(nmethod, _method); GEN_OFFS(nmethod, _dependencies_offset); GEN_OFFS(nmethod, _metadata_offset); - GEN_OFFS(nmethod, _scopes_data_offset); + GEN_OFFS(nmethod, _scopes_data_begin); GEN_OFFS(nmethod, _scopes_pcs_offset); GEN_OFFS(nmethod, _handler_table_offset); - GEN_OFFS(nmethod, _deoptimize_offset); + GEN_OFFS(nmethod, _deopt_handler_begin); GEN_OFFS(nmethod, _orig_pc_offset); GEN_OFFS(PcDesc, _pc_offset); diff --git a/hotspot/src/os/bsd/dtrace/libjvm_db.c b/hotspot/src/os/bsd/dtrace/libjvm_db.c index 7a7105c1b25..d68436c3f3c 100644 --- a/hotspot/src/os/bsd/dtrace/libjvm_db.c +++ b/hotspot/src/os/bsd/dtrace/libjvm_db.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -124,10 +124,10 @@ typedef struct Nmethod_t { uint64_t pc_desc; int32_t orig_pc_offset; /* _orig_pc_offset */ - int32_t instrs_beg; /* _code_offset */ - int32_t instrs_end; - int32_t deopt_beg; /* _deoptimize_offset */ - int32_t scopes_data_beg; /* _scopes_data_offset */ + uint64_t instrs_beg; /* _code_offset */ + uint64_t instrs_end; + uint64_t deopt_beg; /* _deoptimize_offset */ + uint64_t scopes_data_beg; /* _scopes_data_offset */ int32_t scopes_data_end; int32_t metadata_beg; /* _metadata_offset */ int32_t metadata_end; @@ -617,11 +617,12 @@ static int nmethod_info(Nmethod_t *N) fprintf(stderr, "\t nmethod_info: BEGIN \n"); /* Instructions */ - err = ps_pread(J->P, nm + OFFSET_CodeBlob_code_offset, &N->instrs_beg, SZ32); + err = read_pointer(J, base + OFFSET_VMStructEntryaddress, &vmp->address); + err = read_pointer(J, nm + OFFSET_CodeBlob_code_begin, &N->instrs_beg); CHECK_FAIL(err); - err = ps_pread(J->P, nm + OFFSET_CodeBlob_data_offset, &N->instrs_end, SZ32); + err = read_pointer(J, nm + OFFSET_CodeBlob_code_end, &N->instrs_end); CHECK_FAIL(err); - err = ps_pread(J->P, nm + OFFSET_nmethod_deoptimize_offset, &N->deopt_beg, SZ32); + err = read_pointer(J, nm + OFFSET_nmethod_deopt_handler_begin, &N->deopt_beg); CHECK_FAIL(err); err = ps_pread(J->P, nm + OFFSET_nmethod_orig_pc_offset, &N->orig_pc_offset, SZ32); CHECK_FAIL(err); @@ -639,7 +640,7 @@ static int nmethod_info(Nmethod_t *N) CHECK_FAIL(err); /* scopes_data */ - err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_offset, &N->scopes_data_beg, SZ32); + err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_begin, &N->scopes_data_beg, POINTER_SIZE); CHECK_FAIL(err); if (debug > 2 ) { @@ -868,7 +869,7 @@ get_real_pc(Nmethod_t *N, uint64_t pc_desc, uint64_t *real_pc) err = ps_pread(N->J->P, pc_desc + OFFSET_PcDesc_pc_offset, &pc_offset, SZ32); CHECK_FAIL(err); - *real_pc = N->nm + N->instrs_beg + pc_offset; + *real_pc = N->instrs_beg + pc_offset; if (debug > 2) { fprintf(stderr, "\t\t get_real_pc: pc_offset: %lx, real_pc: %llx\n", pc_offset, *real_pc); @@ -942,7 +943,7 @@ scope_desc_at(Nmethod_t *N, int32_t decode_offset, Vframe_t *vf) fprintf(stderr, "\t\t scope_desc_at: BEGIN \n"); } - buffer = N->nm + N->scopes_data_beg + decode_offset; + buffer = N->scopes_data_beg + decode_offset; err = raw_read_int(N->J, &buffer, &vf->sender_decode_offset); CHECK_FAIL(err); @@ -1052,11 +1053,11 @@ name_for_nmethod(jvm_agent_t* J, CHECK_FAIL(err); if (debug) { fprintf(stderr, "name_for_nmethod: pc: %#llx, deopt_pc: %#llx\n", - pc, N->nm + N->deopt_beg); + pc, N->deopt_beg); } /* check for a deoptimized frame */ - if ( pc == N->nm + N->deopt_beg) { + if ( pc == N->deopt_beg) { uint64_t base; if (debug) { fprintf(stderr, "name_for_nmethod: found deoptimized frame\n"); diff --git a/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp b/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp index ddd74b16d9e..7d23282b412 100644 --- a/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp +++ b/hotspot/src/os/solaris/dtrace/generateJvmOffsets.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -251,8 +251,9 @@ int generateJvmOffsets(GEN_variant gen_variant) { GEN_OFFS(CodeBlob, _name); GEN_OFFS(CodeBlob, _header_size); - GEN_OFFS(CodeBlob, _content_offset); - GEN_OFFS(CodeBlob, _code_offset); + GEN_OFFS(CodeBlob, _content_begin); + GEN_OFFS(CodeBlob, _code_begin); + GEN_OFFS(CodeBlob, _code_end); GEN_OFFS(CodeBlob, _data_offset); GEN_OFFS(CodeBlob, _frame_size); printf("\n"); @@ -260,10 +261,10 @@ int generateJvmOffsets(GEN_variant gen_variant) { GEN_OFFS(nmethod, _method); GEN_OFFS(nmethod, _dependencies_offset); GEN_OFFS(nmethod, _metadata_offset); - GEN_OFFS(nmethod, _scopes_data_offset); + GEN_OFFS(nmethod, _scopes_data_begin); GEN_OFFS(nmethod, _scopes_pcs_offset); GEN_OFFS(nmethod, _handler_table_offset); - GEN_OFFS(nmethod, _deoptimize_offset); + GEN_OFFS(nmethod, _deopt_handler_begin); GEN_OFFS(nmethod, _orig_pc_offset); GEN_OFFS(PcDesc, _pc_offset); diff --git a/hotspot/src/os/solaris/dtrace/libjvm_db.c b/hotspot/src/os/solaris/dtrace/libjvm_db.c index e00284532a6..73b26bcb9d5 100644 --- a/hotspot/src/os/solaris/dtrace/libjvm_db.c +++ b/hotspot/src/os/solaris/dtrace/libjvm_db.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -124,10 +124,10 @@ typedef struct Nmethod_t { uint64_t pc_desc; int32_t orig_pc_offset; /* _orig_pc_offset */ - int32_t instrs_beg; /* _code_offset */ - int32_t instrs_end; - int32_t deopt_beg; /* _deoptimize_offset */ - int32_t scopes_data_beg; /* _scopes_data_offset */ + uint64_t instrs_beg; /* _code_offset */ + uint64_t instrs_end; + uint64_t deopt_beg; /* _deoptimize_offset */ + uint64_t scopes_data_beg; /* _scopes_data_begin */ int32_t scopes_data_end; int32_t metadata_beg; /* _metadata_offset */ int32_t metadata_end; @@ -617,11 +617,11 @@ static int nmethod_info(Nmethod_t *N) fprintf(stderr, "\t nmethod_info: BEGIN \n"); /* Instructions */ - err = ps_pread(J->P, nm + OFFSET_CodeBlob_code_offset, &N->instrs_beg, SZ32); + err = read_pointer(J, nm + OFFSET_CodeBlob_code_begin, &N->instrs_beg); CHECK_FAIL(err); - err = ps_pread(J->P, nm + OFFSET_CodeBlob_data_offset, &N->instrs_end, SZ32); + err = read_pointer(J, nm + OFFSET_CodeBlob_code_end, &N->instrs_end); CHECK_FAIL(err); - err = ps_pread(J->P, nm + OFFSET_nmethod_deoptimize_offset, &N->deopt_beg, SZ32); + err = read_pointer(J, nm + OFFSET_nmethod_deopt_handler_begin, &N->deopt_beg); CHECK_FAIL(err); err = ps_pread(J->P, nm + OFFSET_nmethod_orig_pc_offset, &N->orig_pc_offset, SZ32); CHECK_FAIL(err); @@ -629,7 +629,7 @@ static int nmethod_info(Nmethod_t *N) /* Metadata */ err = ps_pread(J->P, nm + OFFSET_nmethod_metadata_offset, &N->metadata_beg, SZ32); CHECK_FAIL(err); - err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_offset, &N->metadata_end, SZ32); + err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_begin, &N->metadata_end, SZ32); CHECK_FAIL(err); /* scopes_pcs */ @@ -639,7 +639,7 @@ static int nmethod_info(Nmethod_t *N) CHECK_FAIL(err); /* scopes_data */ - err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_offset, &N->scopes_data_beg, SZ32); + err = ps_pread(J->P, nm + OFFSET_nmethod_scopes_data_begin, &N->scopes_data_beg, POINTER_SIZE); CHECK_FAIL(err); if (debug > 2 ) { @@ -868,7 +868,7 @@ get_real_pc(Nmethod_t *N, uint64_t pc_desc, uint64_t *real_pc) err = ps_pread(N->J->P, pc_desc + OFFSET_PcDesc_pc_offset, &pc_offset, SZ32); CHECK_FAIL(err); - *real_pc = N->nm + N->instrs_beg + pc_offset; + *real_pc = N->instrs_beg + pc_offset; if (debug > 2) { fprintf(stderr, "\t\t get_real_pc: pc_offset: %lx, real_pc: %llx\n", pc_offset, *real_pc); @@ -942,7 +942,7 @@ scope_desc_at(Nmethod_t *N, int32_t decode_offset, Vframe_t *vf) fprintf(stderr, "\t\t scope_desc_at: BEGIN \n"); } - buffer = N->nm + N->scopes_data_beg + decode_offset; + buffer = N->scopes_data_beg + decode_offset; err = raw_read_int(N->J, &buffer, &vf->sender_decode_offset); CHECK_FAIL(err); @@ -1052,11 +1052,11 @@ name_for_nmethod(jvm_agent_t* J, CHECK_FAIL(err); if (debug) { fprintf(stderr, "name_for_nmethod: pc: %#llx, deopt_pc: %#llx\n", - pc, N->nm + N->deopt_beg); + pc, N->deopt_beg); } /* check for a deoptimized frame */ - if ( pc == N->nm + N->deopt_beg) { + if ( pc == N->deopt_beg) { uint64_t base; if (debug) { fprintf(stderr, "name_for_nmethod: found deoptimized frame\n"); diff --git a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp index 537595f95ad..824d4d7a820 100644 --- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp +++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp @@ -390,7 +390,7 @@ JVM_handle_aix_signal(int sig, siginfo_t* info, void* ucVoid, int abort_if_unrec // BugId 4454115: A read from a MappedByteBuffer can fault here if the // underlying file has been truncated. Do not crash the VM in such a case. CodeBlob* cb = CodeCache::find_blob_unsafe(pc); - nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL; + CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { // We don't really need a stub here! Just set the pending exeption and // continue at the next instruction after the faulting read. Returning diff --git a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp index 73acdebfb47..911dfe50fed 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp +++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp @@ -582,7 +582,7 @@ JVM_handle_bsd_signal(int sig, // here if the underlying file has been truncated. // Do not crash the VM in such a case. CodeBlob* cb = CodeCache::find_blob_unsafe(pc); - nmethod* nm = (cb != NULL && cb->is_nmethod()) ? (nmethod*)cb : NULL; + CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { stub = StubRoutines::handler_for_unsafe_access(); } diff --git a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp index 2a354fbb72c..e6070b63dd6 100644 --- a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp +++ b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp @@ -385,7 +385,7 @@ JVM_handle_linux_signal(int sig, // here if the underlying file has been truncated. // Do not crash the VM in such a case. CodeBlob* cb = CodeCache::find_blob_unsafe(pc); - nmethod* nm = (cb != NULL && cb->is_nmethod()) ? (nmethod*)cb : NULL; + CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { stub = handle_unsafe_access(thread, pc); } diff --git a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp index 117bf1067f3..7ecf0ad8263 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp @@ -315,7 +315,7 @@ JVM_handle_linux_signal(int sig, ((NativeInstruction*)pc)->is_safepoint_poll() && CodeCache::contains((void*) pc) && ((cb = CodeCache::find_blob(pc)) != NULL) && - cb->is_nmethod()) { + cb->is_compiled()) { if (TraceTraps) { tty->print_cr("trap: safepoint_poll at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc)); } @@ -364,7 +364,7 @@ JVM_handle_linux_signal(int sig, // BugId 4454115: A read from a MappedByteBuffer can fault here if the // underlying file has been truncated. Do not crash the VM in such a case. CodeBlob* cb = CodeCache::find_blob_unsafe(pc); - nmethod* nm = (cb != NULL && cb->is_nmethod()) ? (nmethod*)cb : NULL; + CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { // We don't really need a stub here! Just set the pending exeption and // continue at the next instruction after the faulting read. Returning diff --git a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp index 44a5a7df1f9..4f83c606600 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp @@ -438,7 +438,7 @@ inline static bool checkByteBuffer(address pc, address* stub) { // here if the underlying file has been truncated. // Do not crash the VM in such a case. CodeBlob* cb = CodeCache::find_blob_unsafe(pc); - nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL; + CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { *stub = StubRoutines::handler_for_unsafe_access(); return true; diff --git a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp index 0eb7a9e511f..7d7aad54046 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp +++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp @@ -418,7 +418,7 @@ JVM_handle_linux_signal(int sig, // here if the underlying file has been truncated. // Do not crash the VM in such a case. CodeBlob* cb = CodeCache::find_blob_unsafe(pc); - nmethod* nm = (cb != NULL && cb->is_nmethod()) ? (nmethod*)cb : NULL; + CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { stub = StubRoutines::handler_for_unsafe_access(); } diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp index 389f2b3a59d..0fd9adf3c03 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp @@ -478,7 +478,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, // here if the underlying file has been truncated. // Do not crash the VM in such a case. CodeBlob* cb = CodeCache::find_blob_unsafe(pc); - nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL; + CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { stub = StubRoutines::handler_for_unsafe_access(); } diff --git a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp index 0784f3f25f7..d1bc192646d 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp @@ -518,7 +518,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, // Do not crash the VM in such a case. CodeBlob* cb = CodeCache::find_blob_unsafe(pc); if (cb != NULL) { - nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL; + CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { stub = StubRoutines::handler_for_unsafe_access(); } diff --git a/hotspot/src/share/vm/asm/codeBuffer.cpp b/hotspot/src/share/vm/asm/codeBuffer.cpp index 0586fbe228b..c3fba978d66 100644 --- a/hotspot/src/share/vm/asm/codeBuffer.cpp +++ b/hotspot/src/share/vm/asm/codeBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -604,7 +604,7 @@ void CodeBuffer::finalize_oop_references(const methodHandle& mh) { -csize_t CodeBuffer::total_offset_of(CodeSection* cs) const { +csize_t CodeBuffer::total_offset_of(const CodeSection* cs) const { csize_t size_so_far = 0; for (int n = (int) SECT_FIRST; n < (int) SECT_LIMIT; n++) { const CodeSection* cur_cs = code_section(n); diff --git a/hotspot/src/share/vm/asm/codeBuffer.hpp b/hotspot/src/share/vm/asm/codeBuffer.hpp index 534a81f0631..aefcbab1174 100644 --- a/hotspot/src/share/vm/asm/codeBuffer.hpp +++ b/hotspot/src/share/vm/asm/codeBuffer.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -468,9 +468,11 @@ class CodeBuffer: public StackObj { // construction. void initialize(csize_t code_size, csize_t locs_size); - CodeSection* consts() { return &_consts; } - CodeSection* insts() { return &_insts; } - CodeSection* stubs() { return &_stubs; } + CodeSection* consts() { return &_consts; } + CodeSection* insts() { return &_insts; } + CodeSection* stubs() { return &_stubs; } + + const CodeSection* insts() const { return &_insts; } // present sections in order; return NULL at end; consts is #0, etc. CodeSection* code_section(int n) { @@ -547,7 +549,7 @@ class CodeBuffer: public StackObj { // Combined offset (relative to start of first section) of given // section, as eventually found in the final CodeBlob. - csize_t total_offset_of(CodeSection* cs) const; + csize_t total_offset_of(const CodeSection* cs) const; // allocated size of all relocation data, including index, rounded up csize_t total_relocation_size() const; diff --git a/hotspot/src/share/vm/ci/ciEnv.cpp b/hotspot/src/share/vm/ci/ciEnv.cpp index 697c559151f..001c7fd13ea 100644 --- a/hotspot/src/share/vm/ci/ciEnv.cpp +++ b/hotspot/src/share/vm/ci/ciEnv.cpp @@ -1055,14 +1055,14 @@ void ciEnv::register_method(ciMethod* target, if (entry_bci == InvocationEntryBci) { if (TieredCompilation) { // If there is an old version we're done with it - nmethod* old = method->code(); + CompiledMethod* old = method->code(); if (TraceMethodReplacement && old != NULL) { ResourceMark rm; char *method_name = method->name_and_sig_as_C_string(); tty->print_cr("Replacing method %s", method_name); } if (old != NULL) { - old->make_not_entrant(); + old->make_not_used(); } } if (TraceNMethodInstalls) { diff --git a/hotspot/src/share/vm/ci/ciMethod.cpp b/hotspot/src/share/vm/ci/ciMethod.cpp index cb98f25e1c3..2dce245fb79 100644 --- a/hotspot/src/share/vm/ci/ciMethod.cpp +++ b/hotspot/src/share/vm/ci/ciMethod.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1115,7 +1115,7 @@ bool ciMethod::has_compiled_code() { int ciMethod::comp_level() { check_is_loaded(); VM_ENTRY_MARK; - nmethod* nm = get_Method()->code(); + CompiledMethod* nm = get_Method()->code(); if (nm != NULL) return nm->comp_level(); return 0; } @@ -1150,7 +1150,7 @@ int ciMethod::code_size_for_inlining() { int ciMethod::instructions_size() { if (_instructions_size == -1) { GUARDED_VM_ENTRY( - nmethod* code = get_Method()->code(); + CompiledMethod* code = get_Method()->code(); if (code != NULL && (code->comp_level() == CompLevel_full_optimization)) { _instructions_size = code->insts_end() - code->verified_entry_point(); } else { @@ -1165,7 +1165,7 @@ int ciMethod::instructions_size() { // ciMethod::log_nmethod_identity void ciMethod::log_nmethod_identity(xmlStream* log) { GUARDED_VM_ENTRY( - nmethod* code = get_Method()->code(); + CompiledMethod* code = get_Method()->code(); if (code != NULL) { code->log_identity(log); } diff --git a/hotspot/src/share/vm/ci/ciReplay.cpp b/hotspot/src/share/vm/ci/ciReplay.cpp index 65e77c13f8a..c13721743e8 100644 --- a/hotspot/src/share/vm/ci/ciReplay.cpp +++ b/hotspot/src/share/vm/ci/ciReplay.cpp @@ -546,7 +546,7 @@ class CompileReplay : public StackObj { } } // Make sure the existence of a prior compile doesn't stop this one - nmethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, comp_level, true) : method->code(); + CompiledMethod* nm = (entry_bci != InvocationEntryBci) ? method->lookup_osr_nmethod_for(entry_bci, comp_level, true) : method->code(); if (nm != NULL) { nm->make_not_entrant(); } diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index a8a86765970..8a93eb212aa 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -1651,7 +1651,7 @@ void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) { } if (TieredCompilation && TieredStopAtLevel >= CompLevel_full_optimization) { // Clobber the first compile and force second tier compilation - nmethod* nm = m->code(); + CompiledMethod* nm = m->code(); if (nm != NULL && !m->is_method_handle_intrinsic()) { // Throw out the code so that the code cache doesn't fill up nm->make_not_entrant(); @@ -1670,7 +1670,7 @@ void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) { tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_class_counter, m->name_and_sig_as_C_string()); } - nmethod* nm = m->code(); + CompiledMethod* nm = m->code(); if (nm != NULL && !m->is_method_handle_intrinsic()) { // Throw out the code so that the code cache doesn't fill up nm->make_not_entrant(); diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index 5365e1df8d6..162548ad0f0 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -1798,7 +1798,7 @@ static void print_stack_element_to_stream(outputStream* st, Handle mirror, int m // Neither sourcename nor linenumber sprintf(buf + (int)strlen(buf), "Unknown Source)"); } - nmethod* nm = method->code(); + CompiledMethod* nm = method->code(); if (WizardMode && nm != NULL) { sprintf(buf + (int)strlen(buf), "(nmethod " INTPTR_FORMAT ")", (intptr_t)nm); } @@ -1920,7 +1920,7 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, const methodHand int total_count = 0; RegisterMap map(thread, false); int decode_offset = 0; - nmethod* nm = NULL; + CompiledMethod* nm = NULL; bool skip_fillInStackTrace_check = false; bool skip_throwableInit_check = false; bool skip_hidden = !ShowHiddenFrames; @@ -1948,10 +1948,10 @@ void java_lang_Throwable::fill_in_stack_trace(Handle throwable, const methodHand // HMMM QQQ might be nice to have frame return nm as NULL if cb is non-NULL // but non nmethod fr = fr.sender(&map); - if (cb == NULL || !cb->is_nmethod()) { + if (cb == NULL || !cb->is_compiled()) { continue; } - nm = (nmethod*)cb; + nm = cb->as_compiled_method(); if (nm->method()->is_native()) { method = nm->method(); bci = 0; diff --git a/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp b/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp index 6df2d434ccf..3a62c789702 100644 --- a/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp +++ b/hotspot/src/share/vm/classfile/metadataOnStackMark.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ MetadataOnStackMark::MetadataOnStackMark(bool redefinition_walk) { if (redefinition_walk) { Threads::metadata_do(Metadata::mark_on_stack); - CodeCache::alive_nmethods_do(nmethod::mark_on_stack); + CodeCache::metadata_do(Metadata::mark_on_stack); CompileBroker::mark_on_stack(); JvmtiCurrentBreakpoints::metadata_do(Metadata::mark_on_stack); ThreadService::metadata_do(Metadata::mark_on_stack); diff --git a/hotspot/src/share/vm/code/codeBlob.cpp b/hotspot/src/share/vm/code/codeBlob.cpp index 38cae60350a..91d231e6a5f 100644 --- a/hotspot/src/share/vm/code/codeBlob.cpp +++ b/hotspot/src/share/vm/code/codeBlob.cpp @@ -65,12 +65,67 @@ unsigned int CodeBlob::allocation_size(CodeBuffer* cb, int header_size) { return size; } +CodeBlob::CodeBlob(const char* name, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments) : + _name(name), + _size(layout.size()), + _header_size(layout.header_size()), + _frame_complete_offset(frame_complete_offset), + _data_offset(layout.data_offset()), + _frame_size(frame_size), + _strings(CodeStrings()), + _oop_maps(oop_maps), + _caller_must_gc_arguments(caller_must_gc_arguments), + _code_begin(layout.code_begin()), + _code_end(layout.code_end()), + _data_end(layout.data_end()), + _relocation_begin(layout.relocation_begin()), + _relocation_end(layout.relocation_end()), + _content_begin(layout.content_begin()) +{ + assert(layout.size() == round_to(layout.size(), oopSize), "unaligned size"); + assert(layout.header_size() == round_to(layout.header_size(), oopSize), "unaligned size"); + assert(layout.relocation_size() == round_to(layout.relocation_size(), oopSize), "unaligned size"); + assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()"); +#ifdef COMPILER1 + // probably wrong for tiered + assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs"); +#endif // COMPILER1 +} + +CodeBlob::CodeBlob(const char* name, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) : + _name(name), + _size(layout.size()), + _header_size(layout.header_size()), + _frame_complete_offset(frame_complete_offset), + _data_offset(layout.data_offset()), + _frame_size(frame_size), + _strings(CodeStrings()), + _caller_must_gc_arguments(caller_must_gc_arguments), + _code_begin(layout.code_begin()), + _code_end(layout.code_end()), + _data_end(layout.data_end()), + _relocation_begin(layout.relocation_begin()), + _relocation_end(layout.relocation_end()), + _content_begin(layout.content_begin()) +{ + assert(_size == round_to(_size, oopSize), "unaligned size"); + assert(_header_size == round_to(_header_size, oopSize), "unaligned size"); + assert(_data_offset <= _size, "codeBlob is too small"); + assert(layout.code_end() == layout.content_end(), "must be the same - see code_end()"); + + set_oop_maps(oop_maps); +#ifdef COMPILER1 + // probably wrong for tiered + assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs"); +#endif // COMPILER1 +} + // Creates a simple CodeBlob. Sets up the size of the different regions. -CodeBlob::CodeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size) { - assert(size == round_to(size, oopSize), "unaligned size"); +RuntimeBlob::RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size) + : CodeBlob(name, CodeBlobLayout((address) this, size, header_size, locs_size, size), frame_complete, 0, NULL, false /* caller_must_gc_arguments */) +{ assert(locs_size == round_to(locs_size, oopSize), "unaligned size"); - assert(header_size == round_to(header_size, oopSize), "unaligned size"); assert(!UseRelocIndex, "no space allocated for reloc index yet"); // Note: If UseRelocIndex is enabled, there needs to be (at least) one @@ -79,55 +134,31 @@ CodeBlob::CodeBlob(const char* name, int header_size, int size, int frame_comple // mentation is not easily understandable and thus it is not clear // what exactly the format is supposed to be. For now, we just turn // off the use of this table (gri 7/6/2000). - - _name = name; - _size = size; - _frame_complete_offset = frame_complete; - _header_size = header_size; - _relocation_size = locs_size; - _content_offset = align_code_offset(header_size + _relocation_size); - _code_offset = _content_offset; - _data_offset = size; - _frame_size = 0; - set_oop_maps(NULL); - _strings = CodeStrings(); } -// Creates a CodeBlob from a CodeBuffer. Sets up the size of the different regions, +// Creates a RuntimeBlob from a CodeBuffer // and copy code and relocation info. -CodeBlob::CodeBlob( +RuntimeBlob::RuntimeBlob( const char* name, CodeBuffer* cb, int header_size, int size, int frame_complete, int frame_size, - OopMapSet* oop_maps -) { - assert(size == round_to(size, oopSize), "unaligned size"); - assert(header_size == round_to(header_size, oopSize), "unaligned size"); - - _name = name; - _size = size; - _frame_complete_offset = frame_complete; - _header_size = header_size; - _relocation_size = round_to(cb->total_relocation_size(), oopSize); - _content_offset = align_code_offset(header_size + _relocation_size); - _code_offset = _content_offset + cb->total_offset_of(cb->insts()); - _data_offset = _content_offset + round_to(cb->total_content_size(), oopSize); - assert(_data_offset <= size, "codeBlob is too small"); - _strings = CodeStrings(); - + OopMapSet* oop_maps, + bool caller_must_gc_arguments +) : CodeBlob(name, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete, frame_size, oop_maps, caller_must_gc_arguments) { cb->copy_code_and_locs_to(this); - set_oop_maps(oop_maps); - _frame_size = frame_size; -#ifdef COMPILER1 - // probably wrong for tiered - assert(_frame_size >= -1, "must use frame size or -1 for runtime stubs"); -#endif // COMPILER1 } +void CodeBlob::flush() { + if (_oop_maps) { + FREE_C_HEAP_ARRAY(unsigned char, _oop_maps); + _oop_maps = NULL; + } + _strings.free(); +} void CodeBlob::set_oop_maps(OopMapSet* p) { // Danger Will Robinson! This method allocates a big @@ -140,7 +171,7 @@ void CodeBlob::set_oop_maps(OopMapSet* p) { } -void CodeBlob::trace_new_stub(CodeBlob* stub, const char* name1, const char* name2) { +void RuntimeBlob::trace_new_stub(RuntimeBlob* stub, const char* name1, const char* name2) { // Do not hold the CodeCache lock during name formatting. assert(!CodeCache_lock->owned_by_self(), "release CodeCache before registering the stub"); @@ -167,19 +198,9 @@ void CodeBlob::trace_new_stub(CodeBlob* stub, const char* name1, const char* nam MemoryService::track_code_cache_memory_usage(); } - -void CodeBlob::flush() { - if (_oop_maps) { - FREE_C_HEAP_ARRAY(unsigned char, _oop_maps); - _oop_maps = NULL; - } - _strings.free(); -} - - const ImmutableOopMap* CodeBlob::oop_map_for_return_address(address return_address) { - assert(oop_maps() != NULL, "nope"); - return oop_maps()->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin()); + assert(_oop_maps != NULL, "nope"); + return _oop_maps->find_map_at_offset((intptr_t) return_address - (intptr_t) code_begin()); } void CodeBlob::print_code() { @@ -193,7 +214,7 @@ void CodeBlob::print_code() { BufferBlob::BufferBlob(const char* name, int size) -: CodeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0) +: RuntimeBlob(name, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, /*locs_size:*/ 0) {} BufferBlob* BufferBlob::create(const char* name, int buffer_size) { @@ -203,7 +224,7 @@ BufferBlob* BufferBlob::create(const char* name, int buffer_size) { unsigned int size = sizeof(BufferBlob); CodeCacheExtensions::size_blob(name, &buffer_size); // align the size to CodeEntryAlignment - size = align_code_offset(size); + size = CodeBlob::align_code_offset(size); size += round_to(buffer_size, oopSize); assert(name != NULL, "must provide a name"); { @@ -218,14 +239,14 @@ BufferBlob* BufferBlob::create(const char* name, int buffer_size) { BufferBlob::BufferBlob(const char* name, int size, CodeBuffer* cb) - : CodeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL) + : RuntimeBlob(name, cb, sizeof(BufferBlob), size, CodeOffsets::frame_never_safe, 0, NULL) {} BufferBlob* BufferBlob::create(const char* name, CodeBuffer* cb) { ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock BufferBlob* blob = NULL; - unsigned int size = allocation_size(cb, sizeof(BufferBlob)); + unsigned int size = CodeBlob::allocation_size(cb, sizeof(BufferBlob)); assert(name != NULL, "must provide a name"); { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); @@ -246,7 +267,7 @@ void BufferBlob::free(BufferBlob *blob) { blob->flush(); { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - CodeCache::free((CodeBlob*)blob); + CodeCache::free((RuntimeBlob*)blob); } // Track memory usage statistic after releasing CodeCache_lock MemoryService::track_code_cache_memory_usage(); @@ -265,7 +286,7 @@ AdapterBlob* AdapterBlob::create(CodeBuffer* cb) { ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock AdapterBlob* blob = NULL; - unsigned int size = allocation_size(cb, sizeof(AdapterBlob)); + unsigned int size = CodeBlob::allocation_size(cb, sizeof(AdapterBlob)); { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); blob = new (size) AdapterBlob(size, cb); @@ -287,7 +308,7 @@ MethodHandlesAdapterBlob* MethodHandlesAdapterBlob::create(int buffer_size) { unsigned int size = sizeof(MethodHandlesAdapterBlob); CodeCacheExtensions::size_blob("MethodHandles adapters", &buffer_size); // align the size to CodeEntryAlignment - size = align_code_offset(size); + size = CodeBlob::align_code_offset(size); size += round_to(buffer_size, oopSize); { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); @@ -314,12 +335,10 @@ RuntimeStub::RuntimeStub( OopMapSet* oop_maps, bool caller_must_gc_arguments ) -: CodeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps) +: RuntimeBlob(name, cb, sizeof(RuntimeStub), size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments) { - _caller_must_gc_arguments = caller_must_gc_arguments; } - RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name, CodeBuffer* cb, int frame_complete, @@ -332,7 +351,7 @@ RuntimeStub* RuntimeStub::new_runtime_stub(const char* stub_name, if (!CodeCacheExtensions::skip_code_generation()) { // bypass useless code generation MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - unsigned int size = allocation_size(cb, sizeof(RuntimeStub)); + unsigned int size = CodeBlob::allocation_size(cb, sizeof(RuntimeStub)); stub = new (size) RuntimeStub(stub_name, cb, size, frame_complete, frame_size, oop_maps, caller_must_gc_arguments); } stub = (RuntimeStub*) CodeCacheExtensions::handle_generated_blob(stub, stub_name); @@ -392,7 +411,7 @@ DeoptimizationBlob* DeoptimizationBlob::create( ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - unsigned int size = allocation_size(cb, sizeof(DeoptimizationBlob)); + unsigned int size = CodeBlob::allocation_size(cb, sizeof(DeoptimizationBlob)); blob = new (size) DeoptimizationBlob(cb, size, oop_maps, @@ -431,7 +450,7 @@ UncommonTrapBlob* UncommonTrapBlob::create( ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - unsigned int size = allocation_size(cb, sizeof(UncommonTrapBlob)); + unsigned int size = CodeBlob::allocation_size(cb, sizeof(UncommonTrapBlob)); blob = new (size) UncommonTrapBlob(cb, size, oop_maps, frame_size); } @@ -467,7 +486,7 @@ ExceptionBlob* ExceptionBlob::create( ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - unsigned int size = allocation_size(cb, sizeof(ExceptionBlob)); + unsigned int size = CodeBlob::allocation_size(cb, sizeof(ExceptionBlob)); blob = new (size) ExceptionBlob(cb, size, oop_maps, frame_size); } @@ -502,7 +521,7 @@ SafepointBlob* SafepointBlob::create( ThreadInVMfromUnknown __tiv; // get to VM state in case we block on CodeCache_lock { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - unsigned int size = allocation_size(cb, sizeof(SafepointBlob)); + unsigned int size = CodeBlob::allocation_size(cb, sizeof(SafepointBlob)); blob = new (size) SafepointBlob(cb, size, oop_maps, frame_size); } @@ -515,10 +534,6 @@ SafepointBlob* SafepointBlob::create( //---------------------------------------------------------------------------------------------------- // Verification and printing -void CodeBlob::verify() { - ShouldNotReachHere(); -} - void CodeBlob::print_on(outputStream* st) const { st->print_cr("[CodeBlob (" INTPTR_FORMAT ")]", p2i(this)); st->print_cr("Framesize: %d", _frame_size); @@ -528,12 +543,16 @@ void CodeBlob::print_value_on(outputStream* st) const { st->print_cr("[CodeBlob]"); } +void RuntimeBlob::verify() { + ShouldNotReachHere(); +} + void BufferBlob::verify() { // unimplemented } void BufferBlob::print_on(outputStream* st) const { - CodeBlob::print_on(st); + RuntimeBlob::print_on(st); print_value_on(st); } @@ -547,10 +566,10 @@ void RuntimeStub::verify() { void RuntimeStub::print_on(outputStream* st) const { ttyLocker ttyl; - CodeBlob::print_on(st); + RuntimeBlob::print_on(st); st->print("Runtime Stub (" INTPTR_FORMAT "): ", p2i(this)); st->print_cr("%s", name()); - Disassembler::decode((CodeBlob*)this, st); + Disassembler::decode((RuntimeBlob*)this, st); } void RuntimeStub::print_value_on(outputStream* st) const { @@ -563,9 +582,9 @@ void SingletonBlob::verify() { void SingletonBlob::print_on(outputStream* st) const { ttyLocker ttyl; - CodeBlob::print_on(st); + RuntimeBlob::print_on(st); st->print_cr("%s", name()); - Disassembler::decode((CodeBlob*)this, st); + Disassembler::decode((RuntimeBlob*)this, st); } void SingletonBlob::print_value_on(outputStream* st) const { diff --git a/hotspot/src/share/vm/code/codeBlob.hpp b/hotspot/src/share/vm/code/codeBlob.hpp index 4a45f6b96f4..30105e334bf 100644 --- a/hotspot/src/share/vm/code/codeBlob.hpp +++ b/hotspot/src/share/vm/code/codeBlob.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,12 +45,14 @@ struct CodeBlobType { // CodeBlob - superclass for all entries in the CodeCache. // -// Suptypes are: -// nmethod : Compiled Java methods (include method that calls to native code) -// RuntimeStub : Call to VM runtime methods -// DeoptimizationBlob : Used for deoptimizatation -// ExceptionBlob : Used for stack unrolling -// SafepointBlob : Used to handle illegal instruction exceptions +// Subtypes are: +// CompiledMethod : Compiled Java methods (include method that calls to native code) +// nmethod : JIT Compiled Java methods +// RuntimeBlob : Non-compiled method code; generated glue code +// RuntimeStub : Call to VM runtime methods +// DeoptimizationBlob : Used for deoptimization +// ExceptionBlob : Used for stack unrolling +// SafepointBlob : Used to handle illegal instruction exceptions // // // Layout: @@ -59,90 +61,79 @@ struct CodeBlobType { // - content space // - instruction space // - data space -class DeoptimizationBlob; -class CodeBlob VALUE_OBJ_CLASS_SPEC { +class CodeBlobLayout; + +class CodeBlob VALUE_OBJ_CLASS_SPEC { friend class VMStructs; friend class JVMCIVMStructs; friend class CodeCacheDumper; - private: +protected: const char* _name; int _size; // total size of CodeBlob in bytes int _header_size; // size of header (depends on subclass) - int _relocation_size; // size of relocation - int _content_offset; // offset to where content region begins (this includes consts, insts, stubs) - int _code_offset; // offset to where instructions region begins (this includes insts, stubs) int _frame_complete_offset; // instruction offsets in [0.._frame_complete_offset) have // not finished setting up their frame. Beware of pc's in // that range. There is a similar range(s) on returns // which we don't detect. int _data_offset; // offset to where data region begins int _frame_size; // size of stack frame + + address _code_begin; + address _code_end; + address _content_begin; // address to where content region begins (this includes consts, insts, stubs) + // address _content_end - not required, for all CodeBlobs _code_end == _content_end for now + address _data_end; + address _relocation_begin; + address _relocation_end; + ImmutableOopMapSet* _oop_maps; // OopMap for this CodeBlob - CodeStrings _strings; + bool _caller_must_gc_arguments; + CodeStrings _strings; - public: + CodeBlob(const char* name, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments); + CodeBlob(const char* name, const CodeBlobLayout& layout, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments); +public: // Returns the space needed for CodeBlob static unsigned int allocation_size(CodeBuffer* cb, int header_size); static unsigned int align_code_offset(int offset); - // Creation - // a) simple CodeBlob - // frame_complete is the offset from the beginning of the instructions - // to where the frame setup (from stackwalk viewpoint) is complete. - CodeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size); - - // b) full CodeBlob - CodeBlob( - const char* name, - CodeBuffer* cb, - int header_size, - int size, - int frame_complete, - int frame_size, - OopMapSet* oop_maps - ); - // Deletion - void flush(); + virtual void flush(); // Typing - virtual bool is_buffer_blob() const { return false; } - virtual bool is_nmethod() const { return false; } - virtual bool is_runtime_stub() const { return false; } - virtual bool is_deoptimization_stub() const { return false; } - virtual bool is_uncommon_trap_stub() const { return false; } - virtual bool is_exception_stub() const { return false; } + virtual bool is_buffer_blob() const { return false; } + virtual bool is_nmethod() const { return false; } + virtual bool is_runtime_stub() const { return false; } + virtual bool is_deoptimization_stub() const { return false; } + virtual bool is_uncommon_trap_stub() const { return false; } + virtual bool is_exception_stub() const { return false; } virtual bool is_safepoint_stub() const { return false; } virtual bool is_adapter_blob() const { return false; } virtual bool is_method_handles_adapter_blob() const { return false; } + virtual bool is_compiled() const { return false; } virtual bool is_compiled_by_c2() const { return false; } virtual bool is_compiled_by_c1() const { return false; } virtual bool is_compiled_by_jvmci() const { return false; } // Casting - nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : NULL; } + nmethod* as_nmethod_or_null() { return is_nmethod() ? (nmethod*) this : NULL; } + nmethod* as_nmethod() { assert(is_nmethod(), "must be nmethod"); return (nmethod*) this; } + CompiledMethod* as_compiled_method_or_null() { return is_compiled() ? (CompiledMethod*) this : NULL; } + CompiledMethod* as_compiled_method() { assert(is_compiled(), "must be compiled"); return (CompiledMethod*) this; } // Boundaries - address header_begin() const { return (address) this; } - address header_end() const { return ((address) this) + _header_size; }; - relocInfo* relocation_begin() const { return (relocInfo*) header_end(); }; - relocInfo* relocation_end() const { return (relocInfo*)(header_end() + _relocation_size); } - address content_begin() const { return (address) header_begin() + _content_offset; } - address content_end() const { return (address) header_begin() + _data_offset; } - address code_begin() const { return (address) header_begin() + _code_offset; } - address code_end() const { return (address) header_begin() + _data_offset; } - address data_begin() const { return (address) header_begin() + _data_offset; } - address data_end() const { return (address) header_begin() + _size; } - - // Offsets - int relocation_offset() const { return _header_size; } - int content_offset() const { return _content_offset; } - int code_offset() const { return _code_offset; } - int data_offset() const { return _data_offset; } + address header_begin() const { return (address) this; } + relocInfo* relocation_begin() const { return (relocInfo*) _relocation_begin; }; + relocInfo* relocation_end() const { return (relocInfo*) _relocation_end; } + address content_begin() const { return _content_begin; } + address content_end() const { return _code_end; } // _code_end == _content_end is true for all types of blobs for now, it is also checked in the constructor + address code_begin() const { return _code_begin; } + address code_end() const { return _code_end; } + address data_end() const { return _data_end; } // Sizes int size() const { return _size; } @@ -150,17 +141,12 @@ class CodeBlob VALUE_OBJ_CLASS_SPEC { int relocation_size() const { return (address) relocation_end() - (address) relocation_begin(); } int content_size() const { return content_end() - content_begin(); } int code_size() const { return code_end() - code_begin(); } - int data_size() const { return data_end() - data_begin(); } // Containment bool blob_contains(address addr) const { return header_begin() <= addr && addr < data_end(); } - bool relocation_contains(relocInfo* addr) const{ return relocation_begin() <= addr && addr < relocation_end(); } - bool content_contains(address addr) const { return content_begin() <= addr && addr < content_end(); } bool code_contains(address addr) const { return code_begin() <= addr && addr < code_end(); } - bool data_contains(address addr) const { return data_begin() <= addr && addr < data_end(); } - bool contains(address addr) const { return content_contains(addr); } - bool is_frame_complete_at(address addr) const { return code_contains(addr) && - addr >= code_begin() + _frame_complete_offset; } + bool contains(address addr) const { return content_begin() <= addr && addr < content_end(); } + bool is_frame_complete_at(address addr) const { return code_contains(addr) && addr >= code_begin() + _frame_complete_offset; } // CodeCache support: really only used by the nmethods, but in order to get // asserts and certain bookkeeping to work in the CodeCache they are defined @@ -178,29 +164,26 @@ class CodeBlob VALUE_OBJ_CLASS_SPEC { ImmutableOopMapSet* oop_maps() const { return _oop_maps; } void set_oop_maps(OopMapSet* p); const ImmutableOopMap* oop_map_for_return_address(address return_address); - virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { ShouldNotReachHere(); } + virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) = 0; // Frame support int frame_size() const { return _frame_size; } void set_frame_size(int size) { _frame_size = size; } // Returns true, if the next frame is responsible for GC'ing oops passed as arguments - virtual bool caller_must_gc_arguments(JavaThread* thread) const { return false; } + bool caller_must_gc_arguments(JavaThread* thread) const { return _caller_must_gc_arguments; } // Naming const char* name() const { return _name; } void set_name(const char* name) { _name = name; } // Debugging - virtual void verify(); - void print() const { print_on(tty); } + virtual void verify() = 0; + virtual void print() const { print_on(tty); }; virtual void print_on(outputStream* st) const; virtual void print_value_on(outputStream* st) const; void print_code(); - // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService. - static void trace_new_stub(CodeBlob* blob, const char* name1, const char* name2 = ""); - // Print the comment associated with offset on stream, if there is one virtual void print_block_comment(outputStream* stream, address block_begin) const { intptr_t offset = (intptr_t)(block_begin - code_begin()); @@ -221,11 +204,142 @@ class CodeBlob VALUE_OBJ_CLASS_SPEC { } }; +class CodeBlobLayout : public StackObj { +private: + int _size; + int _header_size; + int _relocation_size; + int _content_offset; + int _code_offset; + int _data_offset; + address _code_begin; + address _code_end; + address _content_begin; + address _content_end; + address _data_end; + address _relocation_begin; + address _relocation_end; + +public: + CodeBlobLayout(address code_begin, address code_end, address content_begin, address content_end, address data_end, address relocation_begin, address relocation_end) : + _size(0), + _header_size(0), + _relocation_size(0), + _content_offset(0), + _code_offset(0), + _data_offset(0), + _content_begin(content_begin), + _content_end(content_end), + _code_begin(code_begin), + _code_end(code_end), + _data_end(data_end), + _relocation_begin(relocation_begin), + _relocation_end(relocation_end) + { + } + + CodeBlobLayout(const address start, int size, int header_size, int relocation_size, int data_offset) : + _size(size), + _header_size(header_size), + _relocation_size(relocation_size), + _content_offset(CodeBlob::align_code_offset(_header_size + _relocation_size)), + _code_offset(_content_offset), + _data_offset(data_offset) + { + assert(_relocation_size == round_to(_relocation_size, oopSize), "unaligned size"); + + _code_begin = (address) start + _code_offset; + _code_end = (address) start + _data_offset; + + _content_begin = (address) start + _content_offset; + _content_end = (address) start + _data_offset; + + _data_end = (address) start + _size; + _relocation_begin = (address) start + _header_size; + _relocation_end = _relocation_begin + _relocation_size; + } + + CodeBlobLayout(const address start, int size, int header_size, const CodeBuffer* cb) : + _size(size), + _header_size(header_size), + _relocation_size(round_to(cb->total_relocation_size(), oopSize)), + _content_offset(CodeBlob::align_code_offset(_header_size + _relocation_size)), + _code_offset(_content_offset + cb->total_offset_of(cb->insts())), + _data_offset(_content_offset + round_to(cb->total_content_size(), oopSize)) + { + assert(_relocation_size == round_to(_relocation_size, oopSize), "unaligned size"); + + _code_begin = (address) start + _code_offset; + _code_end = (address) start + _data_offset; + + _content_begin = (address) start + _content_offset; + _content_end = (address) start + _data_offset; + + _data_end = (address) start + _size; + _relocation_begin = (address) start + _header_size; + _relocation_end = _relocation_begin + _relocation_size; + } + + int size() const { return _size; } + int header_size() const { return _header_size; } + int relocation_size() const { return _relocation_size; } + int content_offset() const { return _content_offset; } + int code_offset() const { return _code_offset; } + int data_offset() const { return _data_offset; } + address code_begin() const { return _code_begin; } + address code_end() const { return _code_end; } + address data_end() const { return _data_end; } + address relocation_begin() const { return _relocation_begin; } + address relocation_end() const { return _relocation_end; } + address content_begin() const { return _content_begin; } + address content_end() const { return _content_end; } +}; + + +class RuntimeBlob : public CodeBlob { + friend class VMStructs; + public: + + // Creation + // a) simple CodeBlob + // frame_complete is the offset from the beginning of the instructions + // to where the frame setup (from stackwalk viewpoint) is complete. + RuntimeBlob(const char* name, int header_size, int size, int frame_complete, int locs_size); + + // b) full CodeBlob + RuntimeBlob( + const char* name, + CodeBuffer* cb, + int header_size, + int size, + int frame_complete, + int frame_size, + OopMapSet* oop_maps, + bool caller_must_gc_arguments = false + ); + + // GC support + virtual bool is_alive() const = 0; + + void verify(); + + // OopMap for frame + virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, OopClosure* f) { ShouldNotReachHere(); } + + // Debugging + void print() const { print_on(tty); } + virtual void print_on(outputStream* st) const { CodeBlob::print_on(st); } + virtual void print_value_on(outputStream* st) const { CodeBlob::print_value_on(st); } + + // Deal with Disassembler, VTune, Forte, JvmtiExport, MemoryService. + static void trace_new_stub(RuntimeBlob* blob, const char* name1, const char* name2 = ""); +}; + class WhiteBox; //---------------------------------------------------------------------------------------------------- // BufferBlob: used to hold non-relocatable machine code such as the interpreter, stubroutines, etc. -class BufferBlob: public CodeBlob { +class BufferBlob: public RuntimeBlob { friend class VMStructs; friend class AdapterBlob; friend class MethodHandlesAdapterBlob; @@ -293,11 +407,9 @@ public: //---------------------------------------------------------------------------------------------------- // RuntimeStub: describes stubs used by compiled code to call a (static) C++ runtime routine -class RuntimeStub: public CodeBlob { +class RuntimeStub: public RuntimeBlob { friend class VMStructs; private: - bool _caller_must_gc_arguments; - // Creation support RuntimeStub( const char* name, @@ -325,10 +437,7 @@ class RuntimeStub: public CodeBlob { // Typing bool is_runtime_stub() const { return true; } - // GC support - bool caller_must_gc_arguments(JavaThread* thread) const { return _caller_must_gc_arguments; } - - address entry_point() { return code_begin(); } + address entry_point() const { return code_begin(); } // GC/Verification support void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* nothing to do */ } @@ -343,7 +452,7 @@ class RuntimeStub: public CodeBlob { //---------------------------------------------------------------------------------------------------- // Super-class for all blobs that exist in only one instance. Implements default behaviour. -class SingletonBlob: public CodeBlob { +class SingletonBlob: public RuntimeBlob { friend class VMStructs; protected: @@ -358,13 +467,15 @@ class SingletonBlob: public CodeBlob { int frame_size, OopMapSet* oop_maps ) - : CodeBlob(name, cb, header_size, size, CodeOffsets::frame_never_safe, frame_size, oop_maps) + : RuntimeBlob(name, cb, header_size, size, CodeOffsets::frame_never_safe, frame_size, oop_maps) {}; address entry_point() { return code_begin(); } bool is_alive() const { return true; } + // GC/Verification support + void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { /* nothing to do */ } void verify(); // does nothing void print_on(outputStream* st) const; void print_value_on(outputStream* st) const; diff --git a/hotspot/src/share/vm/code/codeCache.cpp b/hotspot/src/share/vm/code/codeCache.cpp index ec4ced1c3d7..36e33c4c5aa 100644 --- a/hotspot/src/share/vm/code/codeCache.cpp +++ b/hotspot/src/share/vm/code/codeCache.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -561,12 +561,12 @@ CodeBlob* CodeCache::find_blob(void* start) { // what you are doing) CodeBlob* CodeCache::find_blob_unsafe(void* start) { // NMT can walk the stack before code cache is created - if (_heaps == NULL || _heaps->is_empty()) return NULL; - - FOR_ALL_HEAPS(heap) { - CodeBlob* result = (CodeBlob*) (*heap)->find_start(start); - if (result != NULL && result->blob_contains((address)start)) { - return result; + if (_heaps != NULL && !_heaps->is_empty()) { + FOR_ALL_HEAPS(heap) { + CodeBlob* result = (CodeBlob*) (*heap)->find_start(start); + if (result != NULL && result->blob_contains((address)start)) { + return result; + } } } return NULL; @@ -595,11 +595,11 @@ void CodeCache::nmethods_do(void f(nmethod* nm)) { } } -void CodeCache::alive_nmethods_do(void f(nmethod* nm)) { +void CodeCache::metadata_do(void f(Metadata* m)) { assert_locked_or_safepoint(CodeCache_lock); NMethodIterator iter; while(iter.next_alive()) { - f(iter.method()); + iter.method()->metadata_do(f); } } @@ -614,7 +614,7 @@ int CodeCache::alignment_offset() { // Mark nmethods for unloading if they contain otherwise unreachable oops. void CodeCache::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) { assert_locked_or_safepoint(CodeCache_lock); - NMethodIterator iter; + CompiledMethodIterator iter; while(iter.next_alive()) { iter.method()->do_unloading(is_alive, unloading_occurred); } @@ -841,17 +841,18 @@ void CodeCache::gc_prologue() { void CodeCache::gc_epilogue() { assert_locked_or_safepoint(CodeCache_lock); NOT_DEBUG(if (needs_cache_clean())) { - NMethodIterator iter; + CompiledMethodIterator iter; while(iter.next_alive()) { - nmethod* nm = iter.method(); - assert(!nm->is_unloaded(), "Tautology"); + CompiledMethod* cm = iter.method(); + assert(!cm->is_unloaded(), "Tautology"); DEBUG_ONLY(if (needs_cache_clean())) { - nm->cleanup_inline_caches(); + cm->cleanup_inline_caches(); } - DEBUG_ONLY(nm->verify()); - DEBUG_ONLY(nm->verify_oop_relocations()); + DEBUG_ONLY(cm->verify()); + DEBUG_ONLY(cm->verify_oop_relocations()); } } + set_needs_cache_clean(false); prune_scavenge_root_nmethods(); @@ -1036,7 +1037,7 @@ int CodeCache::number_of_nmethods_with_dependencies() { void CodeCache::clear_inline_caches() { assert_locked_or_safepoint(CodeCache_lock); - NMethodIterator iter; + CompiledMethodIterator iter; while(iter.next_alive()) { iter.method()->clear_inline_caches(); } @@ -1083,6 +1084,11 @@ int CodeCache::mark_for_deoptimization(KlassDepChange& changes) { return number_of_marked_CodeBlobs; } +CompiledMethod* CodeCache::find_compiled(void* start) { + CodeBlob *cb = find_blob(start); + assert(cb == NULL || cb->is_compiled(), "did not find an compiled_method"); + return (CompiledMethod*)cb; +} #ifdef HOTSWAP int CodeCache::mark_for_evol_deoptimization(instanceKlassHandle dependee) { @@ -1094,16 +1100,16 @@ int CodeCache::mark_for_evol_deoptimization(instanceKlassHandle dependee) { for (int i = 0; i < old_methods->length(); i++) { ResourceMark rm; Method* old_method = old_methods->at(i); - nmethod *nm = old_method->code(); + CompiledMethod* nm = old_method->code(); if (nm != NULL) { nm->mark_for_deoptimization(); number_of_marked_CodeBlobs++; } } - NMethodIterator iter; + CompiledMethodIterator iter; while(iter.next_alive()) { - nmethod* nm = iter.method(); + CompiledMethod* nm = iter.method(); if (nm->is_marked_for_deoptimization()) { // ...Already marked in the previous pass; don't count it again. } else if (nm->is_evol_dependent_on(dependee())) { @@ -1124,9 +1130,9 @@ int CodeCache::mark_for_evol_deoptimization(instanceKlassHandle dependee) { // Deoptimize all methods void CodeCache::mark_all_nmethods_for_deoptimization() { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - NMethodIterator iter; + CompiledMethodIterator iter; while(iter.next_alive()) { - nmethod* nm = iter.method(); + CompiledMethod* nm = iter.method(); if (!nm->method()->is_method_handle_intrinsic()) { nm->mark_for_deoptimization(); } @@ -1137,9 +1143,9 @@ int CodeCache::mark_for_deoptimization(Method* dependee) { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); int number_of_marked_CodeBlobs = 0; - NMethodIterator iter; + CompiledMethodIterator iter; while(iter.next_alive()) { - nmethod* nm = iter.method(); + CompiledMethod* nm = iter.method(); if (nm->is_dependent_on_method(dependee)) { ResourceMark rm; nm->mark_for_deoptimization(); @@ -1152,9 +1158,9 @@ int CodeCache::mark_for_deoptimization(Method* dependee) { void CodeCache::make_marked_nmethods_not_entrant() { assert_locked_or_safepoint(CodeCache_lock); - NMethodIterator iter; + CompiledMethodIterator iter; while(iter.next_alive()) { - nmethod* nm = iter.method(); + CompiledMethod* nm = iter.method(); if (nm->is_marked_for_deoptimization()) { nm->make_not_entrant(); } @@ -1549,3 +1555,36 @@ void CodeCache::log_state(outputStream* st) { blob_count(), nmethod_count(), adapter_count(), unallocated_capacity()); } + +// Initialize iterator to given compiled method +void CompiledMethodIterator::initialize(CompiledMethod* cm) { + _code_blob = (CodeBlob*)cm; + if (!SegmentedCodeCache) { + // Iterate over all CodeBlobs + _code_blob_type = CodeBlobType::All; + } else if (cm != NULL) { + _code_blob_type = CodeCache::get_code_blob_type(cm); + } else { + // Only iterate over method code heaps, starting with non-profiled + _code_blob_type = CodeBlobType::MethodNonProfiled; + } +} + +// Advance iterator to the next compiled method in the current code heap +bool CompiledMethodIterator::next_compiled_method() { + // Get first method CodeBlob + if (_code_blob == NULL) { + _code_blob = CodeCache::first_blob(_code_blob_type); + if (_code_blob == NULL) { + return false; + } else if (_code_blob->is_nmethod()) { + return true; + } + } + // Search for next method CodeBlob + _code_blob = CodeCache::next_blob(_code_blob); + while (_code_blob != NULL && !_code_blob->is_compiled()) { + _code_blob = CodeCache::next_blob(_code_blob); + } + return _code_blob != NULL; +} diff --git a/hotspot/src/share/vm/code/codeCache.hpp b/hotspot/src/share/vm/code/codeCache.hpp index 47d2a7f3b1f..ba81a8ab1a9 100644 --- a/hotspot/src/share/vm/code/codeCache.hpp +++ b/hotspot/src/share/vm/code/codeCache.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,6 +78,7 @@ class CodeCache : AllStatic { friend class VMStructs; friend class JVMCIVMStructs; friend class NMethodIterator; + friend class CompiledMethodIterator; friend class WhiteBox; friend class CodeCacheLoader; private: @@ -134,12 +135,13 @@ class CodeCache : AllStatic { static void blobs_do(void f(CodeBlob* cb)); // iterates over all CodeBlobs static void blobs_do(CodeBlobClosure* f); // iterates over all CodeBlobs static void nmethods_do(void f(nmethod* nm)); // iterates over all nmethods - static void alive_nmethods_do(void f(nmethod* nm)); // iterates over all alive nmethods + static void metadata_do(void f(Metadata* m)); // iterates over metadata in alive nmethods // Lookup static CodeBlob* find_blob(void* start); // Returns the CodeBlob containing the given address static CodeBlob* find_blob_unsafe(void* start); // Same as find_blob but does not fail if looking up a zombie method static nmethod* find_nmethod(void* start); // Returns the nmethod containing the given address + static CompiledMethod* find_compiled(void* start); static int blob_count(); // Returns the total number of CodeBlobs in the cache static int blob_count(int code_blob_type); @@ -207,8 +209,8 @@ class CodeCache : AllStatic { static bool heap_available(int code_blob_type); // Returns the CodeBlobType for the given nmethod - static int get_code_blob_type(nmethod* nm) { - return get_code_heap(nm)->code_blob_type(); + static int get_code_blob_type(CompiledMethod* cm) { + return get_code_heap(cm)->code_blob_type(); } // Returns the CodeBlobType for the given compilation level @@ -337,4 +339,53 @@ private: } }; +// Iterator to iterate over compiled methods in the CodeCache. +class CompiledMethodIterator : public StackObj { + private: + CodeBlob* _code_blob; // Current CodeBlob + int _code_blob_type; // Refers to current CodeHeap + + public: + CompiledMethodIterator() { + initialize(NULL); // Set to NULL, initialized by first call to next() + } + + CompiledMethodIterator(CompiledMethod* cm) { + initialize(cm); + } + + // Advance iterator to next compiled method + bool next() { + assert_locked_or_safepoint(CodeCache_lock); + assert(_code_blob_type < CodeBlobType::NumTypes, "end reached"); + + bool result = next_compiled_method(); + while (!result && (_code_blob_type < CodeBlobType::MethodProfiled)) { + // Advance to next code heap if segmented code cache + _code_blob_type++; + result = next_compiled_method(); + } + return result; + } + + // Advance iterator to next alive compiled method + bool next_alive() { + bool result = next(); + while(result && !_code_blob->is_alive()) { + result = next(); + } + return result; + } + + bool end() const { return _code_blob == NULL; } + CompiledMethod* method() const { return (_code_blob != NULL) ? _code_blob->as_compiled_method() : NULL; } + +private: + // Initialize iterator to given compiled method + void initialize(CompiledMethod* cm); + + // Advance iterator to the next compiled method in the current code heap + bool next_compiled_method(); +}; + #endif // SHARE_VM_CODE_CODECACHE_HPP diff --git a/hotspot/src/share/vm/code/compiledIC.cpp b/hotspot/src/share/vm/code/compiledIC.cpp index 994ea6447c8..748589ef0a3 100644 --- a/hotspot/src/share/vm/code/compiledIC.cpp +++ b/hotspot/src/share/vm/code/compiledIC.cpp @@ -103,7 +103,7 @@ void CompiledIC::internal_set_ic_destination(address entry_point, bool is_icstub MutexLockerEx pl(SafepointSynchronize::is_at_safepoint() ? NULL : Patching_lock, Mutex::_no_safepoint_check_flag); #ifdef ASSERT CodeBlob* cb = CodeCache::find_blob_unsafe(_ic_call); - assert(cb != NULL && cb->is_nmethod(), "must be nmethod"); + assert(cb != NULL && cb->is_compiled(), "must be compiled"); #endif _ic_call->set_destination_mt_safe(entry_point); } @@ -182,17 +182,17 @@ void CompiledIC::initialize_from_iter(RelocIterator* iter) { } } -CompiledIC::CompiledIC(nmethod* nm, NativeCall* call) +CompiledIC::CompiledIC(CompiledMethod* cm, NativeCall* call) : _ic_call(call) { address ic_call = _ic_call->instruction_address(); assert(ic_call != NULL, "ic_call address must be set"); - assert(nm != NULL, "must pass nmethod"); - assert(nm->contains(ic_call), "must be in nmethod"); + assert(cm != NULL, "must pass compiled method"); + assert(cm->contains(ic_call), "must be in compiled method"); // Search for the ic_call at the given address. - RelocIterator iter(nm, ic_call, ic_call+1); + RelocIterator iter(cm, ic_call, ic_call+1); bool ret = iter.next(); assert(ret == true, "relocInfo must exist at this address"); assert(iter.addr() == ic_call, "must find ic_call"); @@ -205,10 +205,10 @@ CompiledIC::CompiledIC(RelocIterator* iter) { address ic_call = _ic_call->instruction_address(); - nmethod* nm = iter->code(); + CompiledMethod* nm = iter->code(); assert(ic_call != NULL, "ic_call address must be set"); - assert(nm != NULL, "must pass nmethod"); - assert(nm->contains(ic_call), "must be in nmethod"); + assert(nm != NULL, "must pass compiled method"); + assert(nm->contains(ic_call), "must be in compiled method"); initialize_from_iter(iter); } @@ -278,7 +278,7 @@ bool CompiledIC::is_call_to_compiled() const { // method is guaranteed to still exist, since we only remove methods after all inline caches // has been cleaned up CodeBlob* cb = CodeCache::find_blob_unsafe(ic_destination()); - bool is_monomorphic = (cb != NULL && cb->is_nmethod()); + bool is_monomorphic = (cb != NULL && cb->is_compiled()); // Check that the cached_value is a klass for non-optimized monomorphic calls // This assertion is invalid for compiler1: a call that does not look optimized (no static stub) can be used // for calling directly to vep without using the inline cache (i.e., cached_value == NULL). @@ -423,7 +423,7 @@ void CompiledIC::set_to_monomorphic(CompiledICInfo& info) { bool static_bound = info.is_optimized() || (info.cached_metadata() == NULL); #ifdef ASSERT CodeBlob* cb = CodeCache::find_blob_unsafe(info.entry()); - assert (cb->is_nmethod(), "must be compiled!"); + assert (cb->is_compiled(), "must be compiled!"); #endif /* ASSERT */ // This is MT safe if we come from a clean-cache and go through a @@ -469,9 +469,11 @@ void CompiledIC::compute_monomorphic_entry(const methodHandle& method, bool static_bound, CompiledICInfo& info, TRAPS) { - nmethod* method_code = method->code(); + CompiledMethod* method_code = method->code(); + address entry = NULL; if (method_code != NULL && method_code->is_in_use()) { + assert(method_code->is_compiled(), "must be compiled"); // Call to compiled code if (static_bound || is_optimized) { entry = method_code->verified_entry_point(); @@ -520,6 +522,7 @@ void CompiledIC::compute_monomorphic_entry(const methodHandle& method, info.set_interpreter_entry(method()->get_c2i_entry(), method()); } else { // Use icholder entry + assert(method_code == NULL || method_code->is_compiled(), "must be compiled"); CompiledICHolder* holder = new CompiledICHolder(method(), receiver_klass()); info.set_icholder_entry(method()->get_c2i_unverified_entry(), holder); } @@ -557,7 +560,7 @@ void CompiledStaticCall::set_to_clean() { MutexLockerEx pl(SafepointSynchronize::is_at_safepoint() ? NULL : Patching_lock, Mutex::_no_safepoint_check_flag); #ifdef ASSERT CodeBlob* cb = CodeCache::find_blob_unsafe(this); - assert(cb != NULL && cb->is_nmethod(), "must be nmethod"); + assert(cb != NULL && cb->is_compiled(), "must be compiled"); #endif set_destination_mt_safe(SharedRuntime::get_resolve_static_call_stub()); @@ -579,8 +582,8 @@ bool CompiledStaticCall::is_call_to_compiled() const { bool CompiledStaticCall::is_call_to_interpreted() const { // It is a call to interpreted, if it calls to a stub. Hence, the destination // must be in the stub part of the nmethod that contains the call - nmethod* nm = CodeCache::find_nmethod(instruction_address()); - return nm->stub_contains(destination()); + CompiledMethod* cm = CodeCache::find_compiled(instruction_address()); + return cm->stub_contains(destination()); } void CompiledStaticCall::set(const StaticCallInfo& info) { @@ -612,7 +615,7 @@ void CompiledStaticCall::set(const StaticCallInfo& info) { // Compute settings for a CompiledStaticCall. Since we might have to set // the stub when calling to the interpreter, we need to return arguments. void CompiledStaticCall::compute_entry(const methodHandle& m, StaticCallInfo& info) { - nmethod* m_code = m->code(); + CompiledMethod* m_code = m->code(); info._callee = m; if (m_code != NULL && m_code->is_in_use()) { info._to_interpreter = false; diff --git a/hotspot/src/share/vm/code/compiledIC.hpp b/hotspot/src/share/vm/code/compiledIC.hpp index cd1edbbaa36..e4786c87680 100644 --- a/hotspot/src/share/vm/code/compiledIC.hpp +++ b/hotspot/src/share/vm/code/compiledIC.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -135,7 +135,7 @@ class CompiledIC: public ResourceObj { NativeMovConstReg* _value; // patchable value cell for this IC bool _is_optimized; // an optimized virtual call (i.e., no compiled IC) - CompiledIC(nmethod* nm, NativeCall* ic_call); + CompiledIC(CompiledMethod* cm, NativeCall* ic_call); CompiledIC(RelocIterator* iter); void initialize_from_iter(RelocIterator* iter); @@ -169,8 +169,8 @@ class CompiledIC: public ResourceObj { public: // conversion (machine PC to CompiledIC*) - friend CompiledIC* CompiledIC_before(nmethod* nm, address return_addr); - friend CompiledIC* CompiledIC_at(nmethod* nm, address call_site); + friend CompiledIC* CompiledIC_before(CompiledMethod* nm, address return_addr); + friend CompiledIC* CompiledIC_at(CompiledMethod* nm, address call_site); friend CompiledIC* CompiledIC_at(Relocation* call_site); friend CompiledIC* CompiledIC_at(RelocIterator* reloc_iter); @@ -234,13 +234,13 @@ class CompiledIC: public ResourceObj { void verify() PRODUCT_RETURN; }; -inline CompiledIC* CompiledIC_before(nmethod* nm, address return_addr) { +inline CompiledIC* CompiledIC_before(CompiledMethod* nm, address return_addr) { CompiledIC* c_ic = new CompiledIC(nm, nativeCall_before(return_addr)); c_ic->verify(); return c_ic; } -inline CompiledIC* CompiledIC_at(nmethod* nm, address call_site) { +inline CompiledIC* CompiledIC_at(CompiledMethod* nm, address call_site) { CompiledIC* c_ic = new CompiledIC(nm, nativeCall_at(call_site)); c_ic->verify(); return c_ic; diff --git a/hotspot/src/share/vm/code/compiledMethod.cpp b/hotspot/src/share/vm/code/compiledMethod.cpp new file mode 100644 index 00000000000..5ca594579ce --- /dev/null +++ b/hotspot/src/share/vm/code/compiledMethod.cpp @@ -0,0 +1,707 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "code/compiledIC.hpp" +#include "code/scopeDesc.hpp" +#include "code/codeCache.hpp" +#include "prims/methodHandles.hpp" +#include "interpreter/bytecode.hpp" +#include "memory/resourceArea.hpp" +#include "runtime/mutexLocker.hpp" + +CompiledMethod::CompiledMethod(Method* method, const char* name, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments) + : CodeBlob(name, layout, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments), + _method(method), _mark_for_deoptimization_status(not_marked) { + init_defaults(); +} + +CompiledMethod::CompiledMethod(Method* method, const char* name, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments) + : CodeBlob(name, CodeBlobLayout((address) this, size, header_size, cb), cb, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments), + _method(method), _mark_for_deoptimization_status(not_marked) { + init_defaults(); +} + +void CompiledMethod::init_defaults() { + _has_unsafe_access = 0; + _has_method_handle_invokes = 0; + _lazy_critical_native = 0; + _has_wide_vectors = 0; + _unloading_clock = 0; +} + +bool CompiledMethod::is_method_handle_return(address return_pc) { + if (!has_method_handle_invokes()) return false; + PcDesc* pd = pc_desc_at(return_pc); + if (pd == NULL) + return false; + return pd->is_method_handle_invoke(); +} + +// When using JVMCI the address might be off by the size of a call instruction. +bool CompiledMethod::is_deopt_entry(address pc) { + return pc == deopt_handler_begin() +#if INCLUDE_JVMCI + || pc == (deopt_handler_begin() + NativeCall::instruction_size) +#endif + ; +} + +// Returns a string version of the method state. +const char* CompiledMethod::state() const { + int state = get_state(); + switch (state) { + case in_use: + return "in use"; + case not_used: + return "not_used"; + case not_entrant: + return "not_entrant"; + case zombie: + return "zombie"; + case unloaded: + return "unloaded"; + default: + fatal("unexpected method state: %d", state); + return NULL; + } +} + +//----------------------------------------------------------------------------- + +void CompiledMethod::add_exception_cache_entry(ExceptionCache* new_entry) { + assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock"); + assert(new_entry != NULL,"Must be non null"); + assert(new_entry->next() == NULL, "Must be null"); + + ExceptionCache *ec = exception_cache(); + if (ec != NULL) { + new_entry->set_next(ec); + } + release_set_exception_cache(new_entry); +} + +void CompiledMethod::clean_exception_cache(BoolObjectClosure* is_alive) { + ExceptionCache* prev = NULL; + ExceptionCache* curr = exception_cache(); + + while (curr != NULL) { + ExceptionCache* next = curr->next(); + + Klass* ex_klass = curr->exception_type(); + if (ex_klass != NULL && !ex_klass->is_loader_alive(is_alive)) { + if (prev == NULL) { + set_exception_cache(next); + } else { + prev->set_next(next); + } + delete curr; + // prev stays the same. + } else { + prev = curr; + } + + curr = next; + } +} + +// public method for accessing the exception cache +// These are the public access methods. +address CompiledMethod::handler_for_exception_and_pc(Handle exception, address pc) { + // We never grab a lock to read the exception cache, so we may + // have false negatives. This is okay, as it can only happen during + // the first few exception lookups for a given nmethod. + ExceptionCache* ec = exception_cache(); + while (ec != NULL) { + address ret_val; + if ((ret_val = ec->match(exception,pc)) != NULL) { + return ret_val; + } + ec = ec->next(); + } + return NULL; +} + +void CompiledMethod::add_handler_for_exception_and_pc(Handle exception, address pc, address handler) { + // There are potential race conditions during exception cache updates, so we + // must own the ExceptionCache_lock before doing ANY modifications. Because + // we don't lock during reads, it is possible to have several threads attempt + // to update the cache with the same data. We need to check for already inserted + // copies of the current data before adding it. + + MutexLocker ml(ExceptionCache_lock); + ExceptionCache* target_entry = exception_cache_entry_for_exception(exception); + + if (target_entry == NULL || !target_entry->add_address_and_handler(pc,handler)) { + target_entry = new ExceptionCache(exception,pc,handler); + add_exception_cache_entry(target_entry); + } +} + +//-------------end of code for ExceptionCache-------------- + +// private method for handling exception cache +// These methods are private, and used to manipulate the exception cache +// directly. +ExceptionCache* CompiledMethod::exception_cache_entry_for_exception(Handle exception) { + ExceptionCache* ec = exception_cache(); + while (ec != NULL) { + if (ec->match_exception_with_space(exception)) { + return ec; + } + ec = ec->next(); + } + return NULL; +} + +bool CompiledMethod::is_at_poll_return(address pc) { + RelocIterator iter(this, pc, pc+1); + while (iter.next()) { + if (iter.type() == relocInfo::poll_return_type) + return true; + } + return false; +} + + +bool CompiledMethod::is_at_poll_or_poll_return(address pc) { + RelocIterator iter(this, pc, pc+1); + while (iter.next()) { + relocInfo::relocType t = iter.type(); + if (t == relocInfo::poll_return_type || t == relocInfo::poll_type) + return true; + } + return false; +} + +void CompiledMethod::verify_oop_relocations() { + // Ensure sure that the code matches the current oop values + RelocIterator iter(this, NULL, NULL); + while (iter.next()) { + if (iter.type() == relocInfo::oop_type) { + oop_Relocation* reloc = iter.oop_reloc(); + if (!reloc->oop_is_immediate()) { + reloc->verify_oop_relocation(); + } + } + } +} + + +ScopeDesc* CompiledMethod::scope_desc_at(address pc) { + PcDesc* pd = pc_desc_at(pc); + guarantee(pd != NULL, "scope must be present"); + return new ScopeDesc(this, pd->scope_decode_offset(), + pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(), + pd->return_oop()); +} + +void CompiledMethod::cleanup_inline_caches(bool clean_all/*=false*/) { + assert_locked_or_safepoint(CompiledIC_lock); + + // If the method is not entrant or zombie then a JMP is plastered over the + // first few bytes. If an oop in the old code was there, that oop + // should not get GC'd. Skip the first few bytes of oops on + // not-entrant methods. + address low_boundary = verified_entry_point(); + if (!is_in_use() && is_nmethod()) { + low_boundary += NativeJump::instruction_size; + // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. + // This means that the low_boundary is going to be a little too high. + // This shouldn't matter, since oops of non-entrant methods are never used. + // In fact, why are we bothering to look at oops in a non-entrant method?? + } + + // Find all calls in an nmethod and clear the ones that point to non-entrant, + // zombie and unloaded nmethods. + ResourceMark rm; + RelocIterator iter(this, low_boundary); + while(iter.next()) { + switch(iter.type()) { + case relocInfo::virtual_call_type: + case relocInfo::opt_virtual_call_type: { + CompiledIC *ic = CompiledIC_at(&iter); + // Ok, to lookup references to zombies here + CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination()); + if( cb != NULL && cb->is_compiled() ) { + CompiledMethod* nm = cb->as_compiled_method(); + // Clean inline caches pointing to zombie, non-entrant and unloaded methods + if (clean_all || !nm->is_in_use() || (nm->method()->code() != nm)) ic->set_to_clean(is_alive()); + } + break; + } + case relocInfo::static_call_type: { + CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc()); + CodeBlob *cb = CodeCache::find_blob_unsafe(csc->destination()); + if( cb != NULL && cb->is_compiled() ) { + CompiledMethod* cm = cb->as_compiled_method(); + // Clean inline caches pointing to zombie, non-entrant and unloaded methods + if (clean_all || !cm->is_in_use() || (cm->method()->code() != cm)) { + csc->set_to_clean(); + } + } + break; + } + } + } +} + +int CompiledMethod::verify_icholder_relocations() { + ResourceMark rm; + int count = 0; + + RelocIterator iter(this); + while(iter.next()) { + if (iter.type() == relocInfo::virtual_call_type) { + if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) { + CompiledIC *ic = CompiledIC_at(&iter); + if (TraceCompiledIC) { + tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder())); + ic->print(); + } + assert(ic->cached_icholder() != NULL, "must be non-NULL"); + count++; + } + } + } + + return count; +} + +// Method that knows how to preserve outgoing arguments at call. This method must be +// called with a frame corresponding to a Java invoke +void CompiledMethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { +#ifndef SHARK + if (method() != NULL && !method()->is_native()) { + address pc = fr.pc(); + SimpleScopeDesc ssd(this, pc); + Bytecode_invoke call(ssd.method(), ssd.bci()); + bool has_receiver = call.has_receiver(); + bool has_appendix = call.has_appendix(); + Symbol* signature = call.signature(); + + // The method attached by JIT-compilers should be used, if present. + // Bytecode can be inaccurate in such case. + Method* callee = attached_method_before_pc(pc); + if (callee != NULL) { + has_receiver = !(callee->access_flags().is_static()); + has_appendix = false; + signature = callee->signature(); + } + + fr.oops_compiled_arguments_do(signature, has_receiver, has_appendix, reg_map, f); + } +#endif // !SHARK +} + +// ----------------------------------------------------------------------------- +// CompiledMethod::get_deopt_original_pc +// +// Return the original PC for the given PC if: +// (a) the given PC belongs to a nmethod and +// (b) it is a deopt PC +address CompiledMethod::get_deopt_original_pc(const frame* fr) { + if (fr->cb() == NULL) return NULL; + + CompiledMethod* cm = fr->cb()->as_compiled_method_or_null(); + if (cm != NULL && cm->is_deopt_pc(fr->pc())) + return cm->get_original_pc(fr); + + return NULL; +} + +Method* CompiledMethod::attached_method(address call_instr) { + assert(code_contains(call_instr), "not part of the nmethod"); + RelocIterator iter(this, call_instr, call_instr + 1); + while (iter.next()) { + if (iter.addr() == call_instr) { + switch(iter.type()) { + case relocInfo::static_call_type: return iter.static_call_reloc()->method_value(); + case relocInfo::opt_virtual_call_type: return iter.opt_virtual_call_reloc()->method_value(); + case relocInfo::virtual_call_type: return iter.virtual_call_reloc()->method_value(); + } + } + } + return NULL; // not found +} + +Method* CompiledMethod::attached_method_before_pc(address pc) { + if (NativeCall::is_call_before(pc)) { + NativeCall* ncall = nativeCall_before(pc); + return attached_method(ncall->instruction_address()); + } + return NULL; // not a call +} + +void CompiledMethod::clear_inline_caches() { + assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint"); + if (is_zombie()) { + return; + } + + RelocIterator iter(this); + while (iter.next()) { + iter.reloc()->clear_inline_cache(); + } +} + +// Clear ICStubs of all compiled ICs +void CompiledMethod::clear_ic_stubs() { + assert_locked_or_safepoint(CompiledIC_lock); + RelocIterator iter(this); + while(iter.next()) { + if (iter.type() == relocInfo::virtual_call_type) { + CompiledIC* ic = CompiledIC_at(&iter); + ic->clear_ic_stub(); + } + } +} + +#ifdef ASSERT + +class CheckClass : AllStatic { + static BoolObjectClosure* _is_alive; + + // Check class_loader is alive for this bit of metadata. + static void check_class(Metadata* md) { + Klass* klass = NULL; + if (md->is_klass()) { + klass = ((Klass*)md); + } else if (md->is_method()) { + klass = ((Method*)md)->method_holder(); + } else if (md->is_methodData()) { + klass = ((MethodData*)md)->method()->method_holder(); + } else { + md->print(); + ShouldNotReachHere(); + } + assert(klass->is_loader_alive(_is_alive), "must be alive"); + } + public: + static void do_check_class(BoolObjectClosure* is_alive, CompiledMethod* nm) { + assert(SafepointSynchronize::is_at_safepoint(), "this is only ok at safepoint"); + _is_alive = is_alive; + nm->metadata_do(check_class); + } +}; + +// This is called during a safepoint so can use static data +BoolObjectClosure* CheckClass::_is_alive = NULL; +#endif // ASSERT + +void CompiledMethod::clean_ic_if_metadata_is_dead(CompiledIC *ic, BoolObjectClosure *is_alive) { + if (ic->is_icholder_call()) { + // The only exception is compiledICHolder oops which may + // yet be marked below. (We check this further below). + CompiledICHolder* cichk_oop = ic->cached_icholder(); + + if (cichk_oop->holder_method()->method_holder()->is_loader_alive(is_alive) && + cichk_oop->holder_klass()->is_loader_alive(is_alive)) { + return; + } + } else { + Metadata* ic_oop = ic->cached_metadata(); + if (ic_oop != NULL) { + if (ic_oop->is_klass()) { + if (((Klass*)ic_oop)->is_loader_alive(is_alive)) { + return; + } + } else if (ic_oop->is_method()) { + if (((Method*)ic_oop)->method_holder()->is_loader_alive(is_alive)) { + return; + } + } else { + ShouldNotReachHere(); + } + } + } + + ic->set_to_clean(); +} + +unsigned char CompiledMethod::_global_unloading_clock = 0; + +void CompiledMethod::increase_unloading_clock() { + _global_unloading_clock++; + if (_global_unloading_clock == 0) { + // _nmethods are allocated with _unloading_clock == 0, + // so 0 is never used as a clock value. + _global_unloading_clock = 1; + } +} + +void CompiledMethod::set_unloading_clock(unsigned char unloading_clock) { + OrderAccess::release_store((volatile jubyte*)&_unloading_clock, unloading_clock); +} + +unsigned char CompiledMethod::unloading_clock() { + return (unsigned char)OrderAccess::load_acquire((volatile jubyte*)&_unloading_clock); +} + +// Processing of oop references should have been sufficient to keep +// all strong references alive. Any weak references should have been +// cleared as well. Visit all the metadata and ensure that it's +// really alive. +void CompiledMethod::verify_metadata_loaders(address low_boundary, BoolObjectClosure* is_alive) { +#ifdef ASSERT + RelocIterator iter(this, low_boundary); + while (iter.next()) { + // static_stub_Relocations may have dangling references to + // Method*s so trim them out here. Otherwise it looks like + // compiled code is maintaining a link to dead metadata. + address static_call_addr = NULL; + if (iter.type() == relocInfo::opt_virtual_call_type) { + CompiledIC* cic = CompiledIC_at(&iter); + if (!cic->is_call_to_interpreted()) { + static_call_addr = iter.addr(); + } + } else if (iter.type() == relocInfo::static_call_type) { + CompiledStaticCall* csc = compiledStaticCall_at(iter.reloc()); + if (!csc->is_call_to_interpreted()) { + static_call_addr = iter.addr(); + } + } + if (static_call_addr != NULL) { + RelocIterator sciter(this, low_boundary); + while (sciter.next()) { + if (sciter.type() == relocInfo::static_stub_type && + sciter.static_stub_reloc()->static_call() == static_call_addr) { + sciter.static_stub_reloc()->clear_inline_cache(); + } + } + } + } + // Check that the metadata embedded in the nmethod is alive + CheckClass::do_check_class(is_alive, this); +#endif +} + +// This is called at the end of the strong tracing/marking phase of a +// GC to unload an nmethod if it contains otherwise unreachable +// oops. + +void CompiledMethod::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) { + // Make sure the oop's ready to receive visitors + assert(!is_zombie() && !is_unloaded(), + "should not call follow on zombie or unloaded nmethod"); + + // If the method is not entrant then a JMP is plastered over the + // first few bytes. If an oop in the old code was there, that oop + // should not get GC'd. Skip the first few bytes of oops on + // not-entrant methods. + address low_boundary = verified_entry_point(); + if (is_not_entrant()) { + low_boundary += NativeJump::instruction_size; + // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. + // (See comment above.) + } + + // The RedefineClasses() API can cause the class unloading invariant + // to no longer be true. See jvmtiExport.hpp for details. + // Also, leave a debugging breadcrumb in local flag. + if (JvmtiExport::has_redefined_a_class()) { + // This set of the unloading_occurred flag is done before the + // call to post_compiled_method_unload() so that the unloading + // of this nmethod is reported. + unloading_occurred = true; + } + + // Exception cache + clean_exception_cache(is_alive); + + // If class unloading occurred we first iterate over all inline caches and + // clear ICs where the cached oop is referring to an unloaded klass or method. + // The remaining live cached oops will be traversed in the relocInfo::oop_type + // iteration below. + if (unloading_occurred) { + RelocIterator iter(this, low_boundary); + while(iter.next()) { + if (iter.type() == relocInfo::virtual_call_type) { + CompiledIC *ic = CompiledIC_at(&iter); + clean_ic_if_metadata_is_dead(ic, is_alive); + } + } + } + + if (do_unloading_oops(low_boundary, is_alive, unloading_occurred)) { + return; + } + +#if INCLUDE_JVMCI + if (do_unloading_jvmci(is_alive, unloading_occurred)) { + return; + } +#endif + + // Ensure that all metadata is still alive + verify_metadata_loaders(low_boundary, is_alive); +} + +template +static bool clean_if_nmethod_is_unloaded(CompiledICorStaticCall *ic, address addr, BoolObjectClosure *is_alive, CompiledMethod* from) { + // Ok, to lookup references to zombies here + CodeBlob *cb = CodeCache::find_blob_unsafe(addr); + CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; + if (nm != NULL) { + if (nm->unloading_clock() != CompiledMethod::global_unloading_clock()) { + // The nmethod has not been processed yet. + return true; + } + + // Clean inline caches pointing to both zombie and not_entrant methods + if (!nm->is_in_use() || (nm->method()->code() != nm)) { + ic->set_to_clean(); + assert(ic->is_clean(), "nmethod " PTR_FORMAT "not clean %s", p2i(from), from->method()->name_and_sig_as_C_string()); + } + } + + return false; +} + +static bool clean_if_nmethod_is_unloaded(CompiledIC *ic, BoolObjectClosure *is_alive, CompiledMethod* from) { + return clean_if_nmethod_is_unloaded(ic, ic->ic_destination(), is_alive, from); +} + +static bool clean_if_nmethod_is_unloaded(CompiledStaticCall *csc, BoolObjectClosure *is_alive, CompiledMethod* from) { + return clean_if_nmethod_is_unloaded(csc, csc->destination(), is_alive, from); +} + +bool CompiledMethod::do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred) { + ResourceMark rm; + + // Make sure the oop's ready to receive visitors + assert(!is_zombie() && !is_unloaded(), + "should not call follow on zombie or unloaded nmethod"); + + // If the method is not entrant then a JMP is plastered over the + // first few bytes. If an oop in the old code was there, that oop + // should not get GC'd. Skip the first few bytes of oops on + // not-entrant methods. + address low_boundary = verified_entry_point(); + if (is_not_entrant()) { + low_boundary += NativeJump::instruction_size; + // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. + // (See comment above.) + } + + // The RedefineClasses() API can cause the class unloading invariant + // to no longer be true. See jvmtiExport.hpp for details. + // Also, leave a debugging breadcrumb in local flag. + if (JvmtiExport::has_redefined_a_class()) { + // This set of the unloading_occurred flag is done before the + // call to post_compiled_method_unload() so that the unloading + // of this nmethod is reported. + unloading_occurred = true; + } + + // Exception cache + clean_exception_cache(is_alive); + + bool postponed = false; + + RelocIterator iter(this, low_boundary); + while(iter.next()) { + + switch (iter.type()) { + + case relocInfo::virtual_call_type: + if (unloading_occurred) { + // If class unloading occurred we first iterate over all inline caches and + // clear ICs where the cached oop is referring to an unloaded klass or method. + clean_ic_if_metadata_is_dead(CompiledIC_at(&iter), is_alive); + } + + postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this); + break; + + case relocInfo::opt_virtual_call_type: + postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this); + break; + + case relocInfo::static_call_type: + postponed |= clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this); + break; + + case relocInfo::oop_type: + // handled by do_unloading_oops below + break; + + case relocInfo::metadata_type: + break; // nothing to do. + } + } + + if (do_unloading_oops(low_boundary, is_alive, unloading_occurred)) { + return postponed; + } + +#if INCLUDE_JVMCI + if (do_unloading_jvmci(is_alive, unloading_occurred)) { + return postponed; + } +#endif + + // Ensure that all metadata is still alive + verify_metadata_loaders(low_boundary, is_alive); + + return postponed; +} + +void CompiledMethod::do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred) { + ResourceMark rm; + + // Make sure the oop's ready to receive visitors + assert(!is_zombie(), + "should not call follow on zombie nmethod"); + + // If the method is not entrant then a JMP is plastered over the + // first few bytes. If an oop in the old code was there, that oop + // should not get GC'd. Skip the first few bytes of oops on + // not-entrant methods. + address low_boundary = verified_entry_point(); + if (is_not_entrant()) { + low_boundary += NativeJump::instruction_size; + // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. + // (See comment above.) + } + + RelocIterator iter(this, low_boundary); + while(iter.next()) { + + switch (iter.type()) { + + case relocInfo::virtual_call_type: + clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this); + break; + + case relocInfo::opt_virtual_call_type: + clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this); + break; + + case relocInfo::static_call_type: + clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this); + break; + } + } +} diff --git a/hotspot/src/share/vm/code/compiledMethod.hpp b/hotspot/src/share/vm/code/compiledMethod.hpp new file mode 100644 index 00000000000..01485e74a28 --- /dev/null +++ b/hotspot/src/share/vm/code/compiledMethod.hpp @@ -0,0 +1,391 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_CODE_COMPILEDMETHOD_HPP +#define SHARE_VM_CODE_COMPILEDMETHOD_HPP + +#include "code/codeBlob.hpp" +#include "code/pcDesc.hpp" +#include "oops/metadata.hpp" + +class Dependencies; +class ExceptionHandlerTable; +class ImplicitExceptionTable; +class AbstractCompiler; +class xmlStream; +class CompiledStaticCall; + +// This class is used internally by nmethods, to cache +// exception/pc/handler information. + +class ExceptionCache : public CHeapObj { + friend class VMStructs; + private: + enum { cache_size = 16 }; + Klass* _exception_type; + address _pc[cache_size]; + address _handler[cache_size]; + volatile int _count; + ExceptionCache* _next; + + address pc_at(int index) { assert(index >= 0 && index < count(),""); return _pc[index]; } + void set_pc_at(int index, address a) { assert(index >= 0 && index < cache_size,""); _pc[index] = a; } + address handler_at(int index) { assert(index >= 0 && index < count(),""); return _handler[index]; } + void set_handler_at(int index, address a) { assert(index >= 0 && index < cache_size,""); _handler[index] = a; } + int count() { return OrderAccess::load_acquire(&_count); } + // increment_count is only called under lock, but there may be concurrent readers. + void increment_count() { OrderAccess::release_store(&_count, _count + 1); } + + public: + + ExceptionCache(Handle exception, address pc, address handler); + + Klass* exception_type() { return _exception_type; } + ExceptionCache* next() { return _next; } + void set_next(ExceptionCache *ec) { _next = ec; } + + address match(Handle exception, address pc); + bool match_exception_with_space(Handle exception) ; + address test_address(address addr); + bool add_address_and_handler(address addr, address handler) ; +}; + +class nmethod; + +// cache pc descs found in earlier inquiries +class PcDescCache VALUE_OBJ_CLASS_SPEC { + friend class VMStructs; + private: + enum { cache_size = 4 }; + // The array elements MUST be volatile! Several threads may modify + // and read from the cache concurrently. find_pc_desc_internal has + // returned wrong results. C++ compiler (namely xlC12) may duplicate + // C++ field accesses if the elements are not volatile. + typedef PcDesc* PcDescPtr; + volatile PcDescPtr _pc_descs[cache_size]; // last cache_size pc_descs found + public: + PcDescCache() { debug_only(_pc_descs[0] = NULL); } + void reset_to(PcDesc* initial_pc_desc); + PcDesc* find_pc_desc(int pc_offset, bool approximate); + void add_pc_desc(PcDesc* pc_desc); + PcDesc* last_pc_desc() { return _pc_descs[0]; } +}; + +class PcDescSearch { +private: + address _code_begin; + PcDesc* _lower; + PcDesc* _upper; +public: + PcDescSearch(address code, PcDesc* lower, PcDesc* upper) : + _code_begin(code), _lower(lower), _upper(upper) + { + } + + address code_begin() const { return _code_begin; } + PcDesc* scopes_pcs_begin() const { return _lower; } + PcDesc* scopes_pcs_end() const { return _upper; } +}; + +class PcDescContainer VALUE_OBJ_CLASS_SPEC { +private: + PcDescCache _pc_desc_cache; +public: + PcDescContainer() {} + + PcDesc* find_pc_desc_internal(address pc, bool approximate, const PcDescSearch& search); + void reset_to(PcDesc* initial_pc_desc) { _pc_desc_cache.reset_to(initial_pc_desc); } + + PcDesc* find_pc_desc(address pc, bool approximate, const PcDescSearch& search) { + address base_address = search.code_begin(); + PcDesc* desc = _pc_desc_cache.last_pc_desc(); + if (desc != NULL && desc->pc_offset() == pc - base_address) { + return desc; + } + return find_pc_desc_internal(pc, approximate, search); + } +}; + + +class CompiledMethod : public CodeBlob { + friend class VMStructs; + friend class NMethodSweeper; + + void init_defaults(); +protected: + enum MarkForDeoptimizationStatus { + not_marked, + deoptimize, + deoptimize_noupdate + }; + + MarkForDeoptimizationStatus _mark_for_deoptimization_status; // Used for stack deoptimization + + bool _is_far_code; // Code is far from CodeCache. + // Have to use far call instructions to call it from code in CodeCache. + // set during construction + unsigned int _has_unsafe_access:1; // May fault due to unsafe access. + unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes? + unsigned int _lazy_critical_native:1; // Lazy JNI critical native + unsigned int _has_wide_vectors:1; // Preserve wide vectors at safepoints + + Method* _method; + address _scopes_data_begin; + // All deoptee's will resume execution at this location described by + // this address. + address _deopt_handler_begin; + // All deoptee's at a MethodHandle call site will resume execution + // at this location described by this offset. + address _deopt_mh_handler_begin; + + PcDescContainer _pc_desc_container; + ExceptionCache * volatile _exception_cache; + + virtual void flush() = 0; +protected: + CompiledMethod(Method* method, const char* name, const CodeBlobLayout& layout, int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, bool caller_must_gc_arguments); + CompiledMethod(Method* method, const char* name, int size, int header_size, CodeBuffer* cb, int frame_complete_offset, int frame_size, OopMapSet* oop_maps, bool caller_must_gc_arguments); + +public: + virtual bool is_compiled() const { return true; } + + bool has_unsafe_access() const { return _has_unsafe_access; } + void set_has_unsafe_access(bool z) { _has_unsafe_access = z; } + + bool has_method_handle_invokes() const { return _has_method_handle_invokes; } + void set_has_method_handle_invokes(bool z) { _has_method_handle_invokes = z; } + + bool is_lazy_critical_native() const { return _lazy_critical_native; } + void set_lazy_critical_native(bool z) { _lazy_critical_native = z; } + + bool has_wide_vectors() const { return _has_wide_vectors; } + void set_has_wide_vectors(bool z) { _has_wide_vectors = z; } + + enum { in_use = 0, // executable nmethod + not_used = 1, // not entrant, but revivable + not_entrant = 2, // marked for deoptimization but activations may still exist, + // will be transformed to zombie when all activations are gone + zombie = 3, // no activations exist, nmethod is ready for purge + unloaded = 4 // there should be no activations, should not be called, + // will be transformed to zombie immediately + }; + + virtual AbstractCompiler* compiler() const = 0; + virtual bool is_in_use() const = 0; + virtual int comp_level() const = 0; + virtual int compile_id() const = 0; + + + virtual address verified_entry_point() const = 0; + virtual void log_identity(xmlStream* log) const = 0; + virtual void log_state_change() const = 0; + virtual bool make_not_used() = 0; + virtual bool make_not_entrant() = 0; + virtual bool make_entrant() = 0; + virtual address entry_point() const = 0; + virtual bool make_zombie() = 0; + virtual bool is_osr_method() const = 0; + virtual int osr_entry_bci() const = 0; + Method* method() const { return _method; } + virtual void print_pcs() = 0; + bool is_native_method() const { return _method != NULL && _method->is_native(); } + bool is_java_method() const { return _method != NULL && !_method->is_native(); } + + // ScopeDesc retrieval operation + PcDesc* pc_desc_at(address pc) { return find_pc_desc(pc, false); } + // pc_desc_near returns the first PcDesc at or after the givne pc. + PcDesc* pc_desc_near(address pc) { return find_pc_desc(pc, true); } + + // ScopeDesc for an instruction + ScopeDesc* scope_desc_at(address pc); + + bool is_at_poll_return(address pc); + bool is_at_poll_or_poll_return(address pc); + + bool is_marked_for_deoptimization() const { return _mark_for_deoptimization_status != not_marked; } + void mark_for_deoptimization(bool inc_recompile_counts = true) { + _mark_for_deoptimization_status = (inc_recompile_counts ? deoptimize : deoptimize_noupdate); + } + bool update_recompile_counts() const { + // Update recompile counts when either the update is explicitly requested (deoptimize) + // or the nmethod is not marked for deoptimization at all (not_marked). + // The latter happens during uncommon traps when deoptimized nmethod is made not entrant. + return _mark_for_deoptimization_status != deoptimize_noupdate; + } + + // tells whether frames described by this nmethod can be deoptimized + // note: native wrappers cannot be deoptimized. + bool can_be_deoptimized() const { return is_java_method(); } + + virtual oop oop_at(int index) const = 0; + virtual Metadata* metadata_at(int index) const = 0; + + address scopes_data_begin() const { return _scopes_data_begin; } + virtual address scopes_data_end() const = 0; + int scopes_data_size() const { return scopes_data_end() - scopes_data_begin(); } + + virtual PcDesc* scopes_pcs_begin() const = 0; + virtual PcDesc* scopes_pcs_end() const = 0; + int scopes_pcs_size() const { return (intptr_t) scopes_pcs_end() - (intptr_t) scopes_pcs_begin(); } + + address insts_begin() const { return code_begin(); } + address insts_end() const { return stub_begin(); } + bool insts_contains(address addr) const { return insts_begin() <= addr && addr < insts_end(); } + int insts_size() const { return insts_end() - insts_begin(); } + + virtual address consts_begin() const = 0; + virtual address consts_end() const = 0; + bool consts_contains(address addr) const { return consts_begin() <= addr && addr < consts_end(); } + int consts_size() const { return consts_end() - consts_begin(); } + + virtual address stub_begin() const = 0; + virtual address stub_end() const = 0; + bool stub_contains(address addr) const { return stub_begin() <= addr && addr < stub_end(); } + int stub_size() const { return stub_end() - stub_begin(); } + + virtual address handler_table_begin() const = 0; + virtual address handler_table_end() const = 0; + bool handler_table_contains(address addr) const { return handler_table_begin() <= addr && addr < handler_table_end(); } + int handler_table_size() const { return handler_table_end() - handler_table_begin(); } + + virtual address nul_chk_table_begin() const = 0; + virtual address nul_chk_table_end() const = 0; + bool nul_chk_table_contains(address addr) const { return nul_chk_table_begin() <= addr && addr < nul_chk_table_end(); } + int nul_chk_table_size() const { return nul_chk_table_end() - nul_chk_table_begin(); } + + virtual oop* oop_addr_at(int index) const = 0; + virtual Metadata** metadata_addr_at(int index) const = 0; + virtual void set_original_pc(const frame* fr, address pc) = 0; + + // Exception cache support + // Note: _exception_cache may be read concurrently. We rely on memory_order_consume here. + ExceptionCache* exception_cache() const { return _exception_cache; } + void set_exception_cache(ExceptionCache *ec) { _exception_cache = ec; } + void release_set_exception_cache(ExceptionCache *ec) { OrderAccess::release_store_ptr(&_exception_cache, ec); } + address handler_for_exception_and_pc(Handle exception, address pc); + void add_handler_for_exception_and_pc(Handle exception, address pc, address handler); + void clean_exception_cache(BoolObjectClosure* is_alive); + + void add_exception_cache_entry(ExceptionCache* new_entry); + ExceptionCache* exception_cache_entry_for_exception(Handle exception); + + // MethodHandle + bool is_method_handle_return(address return_pc); + address deopt_mh_handler_begin() const { return _deopt_mh_handler_begin; } + + address deopt_handler_begin() const { return _deopt_handler_begin; } + virtual address get_original_pc(const frame* fr) = 0; + // Deopt + // Return true is the PC is one would expect if the frame is being deopted. + bool is_deopt_pc (address pc) { return is_deopt_entry(pc) || is_deopt_mh_entry(pc); } + bool is_deopt_mh_entry(address pc) { return pc == deopt_mh_handler_begin(); } + bool is_deopt_entry(address pc); + + virtual bool can_convert_to_zombie() = 0; + virtual const char* compile_kind() const = 0; + virtual int get_state() const = 0; + + const char* state() const; + + bool is_far_code() const { return _is_far_code; } + + bool inlinecache_check_contains(address addr) const { + return (addr >= code_begin() && addr < verified_entry_point()); + } + + void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f); + + // implicit exceptions support + virtual address continuation_for_implicit_exception(address pc) { return NULL; } + + static address get_deopt_original_pc(const frame* fr); + + // Inline cache support + void cleanup_inline_caches(bool clean_all = false); + virtual void clear_inline_caches(); + void clear_ic_stubs(); + + // Verify and count cached icholder relocations. + int verify_icholder_relocations(); + void verify_oop_relocations(); + + virtual bool is_evol_dependent_on(Klass* dependee) = 0; + // Fast breakpoint support. Tells if this compiled method is + // dependent on the given method. Returns true if this nmethod + // corresponds to the given method as well. + virtual bool is_dependent_on_method(Method* dependee) = 0; + + Method* attached_method(address call_pc); + Method* attached_method_before_pc(address pc); + + virtual void metadata_do(void f(Metadata*)) = 0; + + // GC support + + void set_unloading_next(CompiledMethod* next) { _unloading_next = next; } + CompiledMethod* unloading_next() { return _unloading_next; } + + void static clean_ic_if_metadata_is_dead(CompiledIC *ic, BoolObjectClosure *is_alive); + + // Check that all metadata is still alive + void verify_metadata_loaders(address low_boundary, BoolObjectClosure* is_alive); + + virtual void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred); + // The parallel versions are used by G1. + virtual bool do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred); + virtual void do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred); + + static unsigned char global_unloading_clock() { return _global_unloading_clock; } + static void increase_unloading_clock(); + + void set_unloading_clock(unsigned char unloading_clock); + unsigned char unloading_clock(); + +protected: + virtual bool do_unloading_oops(address low_boundary, BoolObjectClosure* is_alive, bool unloading_occurred) = 0; +#if INCLUDE_JVMCI + virtual bool do_unloading_jvmci(BoolObjectClosure* is_alive, bool unloading_occurred) = 0; +#endif + +private: + // GC support to help figure out if an nmethod has been + // cleaned/unloaded by the current GC. + static unsigned char _global_unloading_clock; + + volatile unsigned char _unloading_clock; // Incremented after GC unloaded/cleaned the nmethod + + PcDesc* find_pc_desc(address pc, bool approximate) { + return _pc_desc_container.find_pc_desc(pc, approximate, PcDescSearch(code_begin(), scopes_pcs_begin(), scopes_pcs_end())); + } + +protected: + union { + // Used by G1 to chain nmethods. + CompiledMethod* _unloading_next; + // Used by non-G1 GCs to chain nmethods. + nmethod* _scavenge_root_link; // from CodeCache::scavenge_root_nmethods + }; +}; + +#endif //SHARE_VM_CODE_COMPILEDMETHOD_HPP diff --git a/hotspot/src/share/vm/code/debugInfo.hpp b/hotspot/src/share/vm/code/debugInfo.hpp index 7a1b666e5e0..ad59edeb546 100644 --- a/hotspot/src/share/vm/code/debugInfo.hpp +++ b/hotspot/src/share/vm/code/debugInfo.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -261,11 +261,11 @@ class MonitorValue: public ResourceObj { class DebugInfoReadStream : public CompressedReadStream { private: - const nmethod* _code; - const nmethod* code() const { return _code; } + const CompiledMethod* _code; + const CompiledMethod* code() const { return _code; } GrowableArray* _obj_pool; public: - DebugInfoReadStream(const nmethod* code, int offset, GrowableArray* obj_pool = NULL) : + DebugInfoReadStream(const CompiledMethod* code, int offset, GrowableArray* obj_pool = NULL) : CompressedReadStream(code->scopes_data_begin(), offset) { _code = code; _obj_pool = obj_pool; diff --git a/hotspot/src/share/vm/code/exceptionHandlerTable.cpp b/hotspot/src/share/vm/code/exceptionHandlerTable.cpp index b2247b89523..5308c23b4fa 100644 --- a/hotspot/src/share/vm/code/exceptionHandlerTable.cpp +++ b/hotspot/src/share/vm/code/exceptionHandlerTable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,9 +65,9 @@ ExceptionHandlerTable::ExceptionHandlerTable(int initial_size) { } -ExceptionHandlerTable::ExceptionHandlerTable(const nmethod* nm) { - _table = (HandlerTableEntry*)nm->handler_table_begin(); - _length = nm->handler_table_size() / sizeof(HandlerTableEntry); +ExceptionHandlerTable::ExceptionHandlerTable(const CompiledMethod* cm) { + _table = (HandlerTableEntry*)cm->handler_table_begin(); + _length = cm->handler_table_size() / sizeof(HandlerTableEntry); _size = 0; // no space allocated by ExeptionHandlerTable! } @@ -98,9 +98,9 @@ void ExceptionHandlerTable::add_subtable( } -void ExceptionHandlerTable::copy_to(nmethod* nm) { - assert(size_in_bytes() == nm->handler_table_size(), "size of space allocated in nmethod incorrect"); - copy_bytes_to(nm->handler_table_begin()); +void ExceptionHandlerTable::copy_to(CompiledMethod* cm) { + assert(size_in_bytes() == cm->handler_table_size(), "size of space allocated in compiled method incorrect"); + copy_bytes_to(cm->handler_table_begin()); } void ExceptionHandlerTable::copy_bytes_to(address addr) { diff --git a/hotspot/src/share/vm/code/exceptionHandlerTable.hpp b/hotspot/src/share/vm/code/exceptionHandlerTable.hpp index 338e8d56800..4fc4fdcb4b5 100644 --- a/hotspot/src/share/vm/code/exceptionHandlerTable.hpp +++ b/hotspot/src/share/vm/code/exceptionHandlerTable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -98,7 +98,7 @@ class ExceptionHandlerTable VALUE_OBJ_CLASS_SPEC { ExceptionHandlerTable(int initial_size = 8); // (run-time) construction from nmethod - ExceptionHandlerTable(const nmethod* nm); + ExceptionHandlerTable(const CompiledMethod* nm); // (compile-time) add entries void add_subtable( @@ -115,7 +115,7 @@ class ExceptionHandlerTable VALUE_OBJ_CLASS_SPEC { // nmethod support int size_in_bytes() const { return round_to(_length * sizeof(HandlerTableEntry), oopSize); } - void copy_to(nmethod* nm); + void copy_to(CompiledMethod* nm); void copy_bytes_to(address addr); // lookup diff --git a/hotspot/src/share/vm/code/icBuffer.cpp b/hotspot/src/share/vm/code/icBuffer.cpp index 65ea0b83ccd..abbe781737d 100644 --- a/hotspot/src/share/vm/code/icBuffer.cpp +++ b/hotspot/src/share/vm/code/icBuffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,8 +49,8 @@ int InlineCacheBuffer::_pending_count = 0; void ICStub::finalize() { if (!is_empty()) { ResourceMark rm; - CompiledIC *ic = CompiledIC_at(CodeCache::find_nmethod(ic_site()), ic_site()); - assert(CodeCache::find_nmethod(ic->instruction_address()) != NULL, "inline cache in non-nmethod?"); + CompiledIC *ic = CompiledIC_at(CodeCache::find_compiled(ic_site()), ic_site()); + assert(CodeCache::find_compiled(ic->instruction_address()) != NULL, "inline cache in non-compiled?"); assert(this == ICStub_from_destination_address(ic->stub_address()), "wrong owner of ic buffer"); ic->set_ic_destination_and_value(destination(), cached_value()); diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 50e0f957217..f1c9b74366e 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -73,8 +73,6 @@ #include "jvmci/jvmciJavaClasses.hpp" #endif -unsigned char nmethod::_global_unloading_clock = 0; - #ifdef DTRACE_ENABLED // Only bother with this argument setup if dtrace is available @@ -336,22 +334,6 @@ bool ExceptionCache::add_address_and_handler(address addr, address handler) { return false; } - -// private method for handling exception cache -// These methods are private, and used to manipulate the exception cache -// directly. -ExceptionCache* nmethod::exception_cache_entry_for_exception(Handle exception) { - ExceptionCache* ec = exception_cache(); - while (ec != NULL) { - if (ec->match_exception_with_space(exception)) { - return ec; - } - ec = ec->next(); - } - return NULL; -} - - //----------------------------------------------------------------------------- @@ -434,82 +416,6 @@ static int adjust_pcs_size(int pcs_size) { return nsize; } -//----------------------------------------------------------------------------- - - -void nmethod::add_exception_cache_entry(ExceptionCache* new_entry) { - assert(ExceptionCache_lock->owned_by_self(),"Must hold the ExceptionCache_lock"); - assert(new_entry != NULL,"Must be non null"); - assert(new_entry->next() == NULL, "Must be null"); - - ExceptionCache *ec = exception_cache(); - if (ec != NULL) { - new_entry->set_next(ec); - } - release_set_exception_cache(new_entry); -} - -void nmethod::clean_exception_cache(BoolObjectClosure* is_alive) { - ExceptionCache* prev = NULL; - ExceptionCache* curr = exception_cache(); - - while (curr != NULL) { - ExceptionCache* next = curr->next(); - - Klass* ex_klass = curr->exception_type(); - if (ex_klass != NULL && !ex_klass->is_loader_alive(is_alive)) { - if (prev == NULL) { - set_exception_cache(next); - } else { - prev->set_next(next); - } - delete curr; - // prev stays the same. - } else { - prev = curr; - } - - curr = next; - } -} - -// public method for accessing the exception cache -// These are the public access methods. -address nmethod::handler_for_exception_and_pc(Handle exception, address pc) { - // We never grab a lock to read the exception cache, so we may - // have false negatives. This is okay, as it can only happen during - // the first few exception lookups for a given nmethod. - ExceptionCache* ec = exception_cache(); - while (ec != NULL) { - address ret_val; - if ((ret_val = ec->match(exception,pc)) != NULL) { - return ret_val; - } - ec = ec->next(); - } - return NULL; -} - - -void nmethod::add_handler_for_exception_and_pc(Handle exception, address pc, address handler) { - // There are potential race conditions during exception cache updates, so we - // must own the ExceptionCache_lock before doing ANY modifications. Because - // we don't lock during reads, it is possible to have several threads attempt - // to update the cache with the same data. We need to check for already inserted - // copies of the current data before adding it. - - MutexLocker ml(ExceptionCache_lock); - ExceptionCache* target_entry = exception_cache_entry_for_exception(exception); - - if (target_entry == NULL || !target_entry->add_address_and_handler(pc,handler)) { - target_entry = new ExceptionCache(exception,pc,handler); - add_exception_cache_entry(target_entry); - } -} - - -//-------------end of code for ExceptionCache-------------- - int nmethod::total_size() const { return @@ -531,13 +437,7 @@ const char* nmethod::compile_kind() const { // Fill in default values for various flag fields void nmethod::init_defaults() { _state = in_use; - _unloading_clock = 0; _has_flushed_dependencies = 0; - _has_unsafe_access = 0; - _has_method_handle_invokes = 0; - _lazy_critical_native = 0; - _has_wide_vectors = 0; - _mark_for_deoptimization_status = not_marked; _lock_count = 0; _stack_traversal_mark = 0; _unload_reported = false; // jvmti state @@ -579,7 +479,7 @@ nmethod* nmethod::new_native_nmethod(const methodHandle& method, nmethod* nm = NULL; { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - int native_nmethod_size = allocation_size(code_buffer, sizeof(nmethod)); + int native_nmethod_size = CodeBlob::allocation_size(code_buffer, sizeof(nmethod)); CodeOffsets offsets; offsets.set_value(CodeOffsets::Verified_Entry, vep_offset); offsets.set_value(CodeOffsets::Frame_Complete, frame_complete); @@ -625,7 +525,7 @@ nmethod* nmethod::new_nmethod(const methodHandle& method, nmethod* nm = NULL; { MutexLockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); int nmethod_size = - allocation_size(code_buffer, sizeof(nmethod)) + CodeBlob::allocation_size(code_buffer, sizeof(nmethod)) + adjust_pcs_size(debug_info->pcs_size()) + round_to(dependencies->size_in_bytes() , oopSize) + round_to(handler_table->size_in_bytes(), oopSize) @@ -692,31 +592,31 @@ nmethod::nmethod( ByteSize basic_lock_owner_sp_offset, ByteSize basic_lock_sp_offset, OopMapSet* oop_maps ) - : CodeBlob("native nmethod", code_buffer, sizeof(nmethod), - nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps), + : CompiledMethod(method, "native nmethod", nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false), _native_receiver_sp_offset(basic_lock_owner_sp_offset), _native_basic_lock_sp_offset(basic_lock_sp_offset) { { + int scopes_data_offset = 0; + int deoptimize_offset = 0; + int deoptimize_mh_offset = 0; + debug_only(NoSafepointVerifier nsv;) assert_locked_or_safepoint(CodeCache_lock); init_defaults(); - _method = method; _entry_bci = InvocationEntryBci; // We have no exception handler or deopt handler make the // values something that will never match a pc like the nmethod vtable entry _exception_offset = 0; - _deoptimize_offset = 0; - _deoptimize_mh_offset = 0; _orig_pc_offset = 0; _consts_offset = data_offset(); _stub_offset = data_offset(); _oops_offset = data_offset(); _metadata_offset = _oops_offset + round_to(code_buffer->total_oop_size(), oopSize); - _scopes_data_offset = _metadata_offset + round_to(code_buffer->total_metadata_size(), wordSize); - _scopes_pcs_offset = _scopes_data_offset; + scopes_data_offset = _metadata_offset + round_to(code_buffer->total_metadata_size(), wordSize); + _scopes_pcs_offset = scopes_data_offset; _dependencies_offset = _scopes_pcs_offset; _handler_table_offset = _dependencies_offset; _nul_chk_table_offset = _handler_table_offset; @@ -727,9 +627,14 @@ nmethod::nmethod( _verified_entry_point = code_begin() + offsets->value(CodeOffsets::Verified_Entry); _osr_entry_point = NULL; _exception_cache = NULL; - _pc_desc_cache.reset_to(NULL); + _pc_desc_container.reset_to(NULL); _hotness_counter = NMethodSweeper::hotness_counter_reset_val(); + _scopes_data_begin = (address) this + scopes_data_offset; + _deopt_handler_begin = (address) this + deoptimize_offset; + _deopt_mh_handler_begin = (address) this + deoptimize_mh_offset; + + code_buffer->copy_code_and_locs_to(this); code_buffer->copy_values_to(this); if (ScavengeRootsInCode) { if (detect_scavenge_root_oops()) { @@ -795,8 +700,7 @@ nmethod::nmethod( Handle speculation_log #endif ) - : CodeBlob("nmethod", code_buffer, sizeof(nmethod), - nmethod_size, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps), + : CompiledMethod(method, "nmethod", nmethod_size, sizeof(nmethod), code_buffer, offsets->value(CodeOffsets::Frame_Complete), frame_size, oop_maps, false), _native_receiver_sp_offset(in_ByteSize(-1)), _native_basic_lock_sp_offset(in_ByteSize(-1)) { @@ -805,8 +709,10 @@ nmethod::nmethod( debug_only(NoSafepointVerifier nsv;) assert_locked_or_safepoint(CodeCache_lock); + _deopt_handler_begin = (address) this; + _deopt_mh_handler_begin = (address) this; + init_defaults(); - _method = method; _entry_bci = entry_bci; _compile_id = compile_id; _comp_level = comp_level; @@ -830,14 +736,14 @@ nmethod::nmethod( _exception_offset = -1; } if (offsets->value(CodeOffsets::Deopt) != -1) { - _deoptimize_offset = code_offset() + offsets->value(CodeOffsets::Deopt); + _deopt_handler_begin = (address) this + code_offset() + offsets->value(CodeOffsets::Deopt); } else { - _deoptimize_offset = -1; + _deopt_handler_begin = NULL; } if (offsets->value(CodeOffsets::DeoptMH) != -1) { - _deoptimize_mh_offset = code_offset() + offsets->value(CodeOffsets::DeoptMH); + _deopt_mh_handler_begin = (address) this + code_offset() + offsets->value(CodeOffsets::DeoptMH); } else { - _deoptimize_mh_offset = -1; + _deopt_mh_handler_begin = NULL; } } else { #endif @@ -845,12 +751,12 @@ nmethod::nmethod( assert(offsets->value(CodeOffsets::Exceptions) != -1, "must be set"); assert(offsets->value(CodeOffsets::Deopt ) != -1, "must be set"); - _exception_offset = _stub_offset + offsets->value(CodeOffsets::Exceptions); - _deoptimize_offset = _stub_offset + offsets->value(CodeOffsets::Deopt); + _exception_offset = _stub_offset + offsets->value(CodeOffsets::Exceptions); + _deopt_handler_begin = (address) this + _stub_offset + offsets->value(CodeOffsets::Deopt); if (offsets->value(CodeOffsets::DeoptMH) != -1) { - _deoptimize_mh_offset = _stub_offset + offsets->value(CodeOffsets::DeoptMH); + _deopt_mh_handler_begin = (address) this + _stub_offset + offsets->value(CodeOffsets::DeoptMH); } else { - _deoptimize_mh_offset = -1; + _deopt_mh_handler_begin = NULL; #if INCLUDE_JVMCI } #endif @@ -863,20 +769,23 @@ nmethod::nmethod( _oops_offset = data_offset(); _metadata_offset = _oops_offset + round_to(code_buffer->total_oop_size(), oopSize); - _scopes_data_offset = _metadata_offset + round_to(code_buffer->total_metadata_size(), wordSize); + int scopes_data_offset = _metadata_offset + round_to(code_buffer->total_metadata_size(), wordSize); - _scopes_pcs_offset = _scopes_data_offset + round_to(debug_info->data_size (), oopSize); + _scopes_pcs_offset = scopes_data_offset + round_to(debug_info->data_size (), oopSize); _dependencies_offset = _scopes_pcs_offset + adjust_pcs_size(debug_info->pcs_size()); _handler_table_offset = _dependencies_offset + round_to(dependencies->size_in_bytes (), oopSize); _nul_chk_table_offset = _handler_table_offset + round_to(handler_table->size_in_bytes(), oopSize); _nmethod_end_offset = _nul_chk_table_offset + round_to(nul_chk_table->size_in_bytes(), oopSize); - _entry_point = code_begin() + offsets->value(CodeOffsets::Entry); _verified_entry_point = code_begin() + offsets->value(CodeOffsets::Verified_Entry); _osr_entry_point = code_begin() + offsets->value(CodeOffsets::OSR_Entry); _exception_cache = NULL; - _pc_desc_cache.reset_to(scopes_pcs_begin()); + _scopes_data_begin = (address) this + scopes_data_offset; + + _pc_desc_container.reset_to(scopes_pcs_begin()); + + code_buffer->copy_code_and_locs_to(this); // Copy contents of ScopeDescRecorder to nmethod code_buffer->copy_values_to(this); debug_info->copy_to(this); @@ -1052,27 +961,6 @@ void nmethod::copy_values(GrowableArray* array) { } } -bool nmethod::is_at_poll_return(address pc) { - RelocIterator iter(this, pc, pc+1); - while (iter.next()) { - if (iter.type() == relocInfo::poll_return_type) - return true; - } - return false; -} - - -bool nmethod::is_at_poll_or_poll_return(address pc) { - RelocIterator iter(this, pc, pc+1); - while (iter.next()) { - relocInfo::relocType t = iter.type(); - if (t == relocInfo::poll_return_type || t == relocInfo::poll_type) - return true; - } - return false; -} - - void nmethod::fix_oop_relocations(address begin, address end, bool initialize_immediates) { // re-patch all oop-bearing instructions, just in case some oops moved RelocIterator iter(this, begin, end); @@ -1093,101 +981,6 @@ void nmethod::fix_oop_relocations(address begin, address end, bool initialize_im } -void nmethod::verify_oop_relocations() { - // Ensure sure that the code matches the current oop values - RelocIterator iter(this, NULL, NULL); - while (iter.next()) { - if (iter.type() == relocInfo::oop_type) { - oop_Relocation* reloc = iter.oop_reloc(); - if (!reloc->oop_is_immediate()) { - reloc->verify_oop_relocation(); - } - } - } -} - - -ScopeDesc* nmethod::scope_desc_at(address pc) { - PcDesc* pd = pc_desc_at(pc); - guarantee(pd != NULL, "scope must be present"); - return new ScopeDesc(this, pd->scope_decode_offset(), - pd->obj_decode_offset(), pd->should_reexecute(), pd->rethrow_exception(), - pd->return_oop()); -} - - -void nmethod::clear_inline_caches() { - assert(SafepointSynchronize::is_at_safepoint(), "cleaning of IC's only allowed at safepoint"); - if (is_zombie()) { - return; - } - - RelocIterator iter(this); - while (iter.next()) { - iter.reloc()->clear_inline_cache(); - } -} - -// Clear ICStubs of all compiled ICs -void nmethod::clear_ic_stubs() { - assert_locked_or_safepoint(CompiledIC_lock); - RelocIterator iter(this); - while(iter.next()) { - if (iter.type() == relocInfo::virtual_call_type) { - CompiledIC* ic = CompiledIC_at(&iter); - ic->clear_ic_stub(); - } - } -} - -void nmethod::cleanup_inline_caches(bool clean_all/*=false*/) { - assert_locked_or_safepoint(CompiledIC_lock); - - // If the method is not entrant or zombie then a JMP is plastered over the - // first few bytes. If an oop in the old code was there, that oop - // should not get GC'd. Skip the first few bytes of oops on - // not-entrant methods. - address low_boundary = verified_entry_point(); - if (!is_in_use()) { - low_boundary += NativeJump::instruction_size; - // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. - // This means that the low_boundary is going to be a little too high. - // This shouldn't matter, since oops of non-entrant methods are never used. - // In fact, why are we bothering to look at oops in a non-entrant method?? - } - - // Find all calls in an nmethod and clear the ones that point to non-entrant, - // zombie and unloaded nmethods. - ResourceMark rm; - RelocIterator iter(this, low_boundary); - while(iter.next()) { - switch(iter.type()) { - case relocInfo::virtual_call_type: - case relocInfo::opt_virtual_call_type: { - CompiledIC *ic = CompiledIC_at(&iter); - // Ok, to lookup references to zombies here - CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination()); - if( cb != NULL && cb->is_nmethod() ) { - nmethod* nm = (nmethod*)cb; - // Clean inline caches pointing to zombie, non-entrant and unloaded methods - if (clean_all || !nm->is_in_use() || (nm->method()->code() != nm)) ic->set_to_clean(is_alive()); - } - break; - } - case relocInfo::static_call_type: { - CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc()); - CodeBlob *cb = CodeCache::find_blob_unsafe(csc->destination()); - if( cb != NULL && cb->is_nmethod() ) { - nmethod* nm = (nmethod*)cb; - // Clean inline caches pointing to zombie, non-entrant and unloaded methods - if (clean_all || !nm->is_in_use() || (nm->method()->code() != nm)) csc->set_to_clean(); - } - break; - } - } - } -} - void nmethod::verify_clean_inline_caches() { assert_locked_or_safepoint(CompiledIC_lock); @@ -1213,8 +1006,8 @@ void nmethod::verify_clean_inline_caches() { CompiledIC *ic = CompiledIC_at(&iter); // Ok, to lookup references to zombies here CodeBlob *cb = CodeCache::find_blob_unsafe(ic->ic_destination()); - if( cb != NULL && cb->is_nmethod() ) { - nmethod* nm = (nmethod*)cb; + nmethod* nm = cb->as_nmethod_or_null(); + if( nm != NULL ) { // Verify that inline caches pointing to both zombie and not_entrant methods are clean if (!nm->is_in_use() || (nm->method()->code() != nm)) { assert(ic->is_clean(), "IC should be clean"); @@ -1225,8 +1018,8 @@ void nmethod::verify_clean_inline_caches() { case relocInfo::static_call_type: { CompiledStaticCall *csc = compiledStaticCall_at(iter.reloc()); CodeBlob *cb = CodeCache::find_blob_unsafe(csc->destination()); - if( cb != NULL && cb->is_nmethod() ) { - nmethod* nm = (nmethod*)cb; + nmethod* nm = cb->as_nmethod_or_null(); + if( nm != NULL ) { // Verify that inline caches pointing to both zombie and not_entrant methods are clean if (!nm->is_in_use() || (nm->method()->code() != nm)) { assert(csc->is_clean(), "IC should be clean"); @@ -1238,27 +1031,6 @@ void nmethod::verify_clean_inline_caches() { } } -int nmethod::verify_icholder_relocations() { - int count = 0; - - RelocIterator iter(this); - while(iter.next()) { - if (iter.type() == relocInfo::virtual_call_type) { - if (CompiledIC::is_icholder_call_site(iter.virtual_call_reloc())) { - CompiledIC *ic = CompiledIC_at(&iter); - if (TraceCompiledIC) { - tty->print("noticed icholder " INTPTR_FORMAT " ", p2i(ic->cached_icholder())); - ic->print(); - } - assert(ic->cached_icholder() != NULL, "must be non-NULL"); - count++; - } - } - } - - return count; -} - // This is a private interface with the sweeper. void nmethod::mark_as_seen_on_stack() { assert(is_alive(), "Must be an alive method"); @@ -1291,23 +1063,6 @@ void nmethod::inc_decompile_count() { mdo->inc_decompile_count(); } -void nmethod::increase_unloading_clock() { - _global_unloading_clock++; - if (_global_unloading_clock == 0) { - // _nmethods are allocated with _unloading_clock == 0, - // so 0 is never used as a clock value. - _global_unloading_clock = 1; - } -} - -void nmethod::set_unloading_clock(unsigned char unloading_clock) { - OrderAccess::release_store((volatile jubyte*)&_unloading_clock, unloading_clock); -} - -unsigned char nmethod::unloading_clock() { - return (unsigned char)OrderAccess::load_acquire((volatile jubyte*)&_unloading_clock); -} - void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) { post_compiled_method_unload(); @@ -1608,8 +1363,7 @@ void nmethod::flush() { ((SharkCompiler *) compiler())->free_compiled_method(insts_begin()); #endif // SHARK - ((CodeBlob*)(this))->flush(); - + CodeBlob::flush(); CodeCache::free(this); } @@ -1753,171 +1507,6 @@ void nmethod::post_compiled_method_unload() { set_unload_reported(); } -void static clean_ic_if_metadata_is_dead(CompiledIC *ic, BoolObjectClosure *is_alive) { - if (ic->is_icholder_call()) { - // The only exception is compiledICHolder oops which may - // yet be marked below. (We check this further below). - CompiledICHolder* cichk_oop = ic->cached_icholder(); - - if (cichk_oop->holder_method()->method_holder()->is_loader_alive(is_alive) && - cichk_oop->holder_klass()->is_loader_alive(is_alive)) { - return; - } - } else { - Metadata* ic_oop = ic->cached_metadata(); - if (ic_oop != NULL) { - if (ic_oop->is_klass()) { - if (((Klass*)ic_oop)->is_loader_alive(is_alive)) { - return; - } - } else if (ic_oop->is_method()) { - if (((Method*)ic_oop)->method_holder()->is_loader_alive(is_alive)) { - return; - } - } else { - ShouldNotReachHere(); - } - } - } - - ic->set_to_clean(); -} - -// This is called at the end of the strong tracing/marking phase of a -// GC to unload an nmethod if it contains otherwise unreachable -// oops. - -void nmethod::do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred) { - // Make sure the oop's ready to receive visitors - assert(!is_zombie() && !is_unloaded(), - "should not call follow on zombie or unloaded nmethod"); - - // If the method is not entrant then a JMP is plastered over the - // first few bytes. If an oop in the old code was there, that oop - // should not get GC'd. Skip the first few bytes of oops on - // not-entrant methods. - address low_boundary = verified_entry_point(); - if (is_not_entrant()) { - low_boundary += NativeJump::instruction_size; - // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. - // (See comment above.) - } - - // The RedefineClasses() API can cause the class unloading invariant - // to no longer be true. See jvmtiExport.hpp for details. - // Also, leave a debugging breadcrumb in local flag. - if (JvmtiExport::has_redefined_a_class()) { - // This set of the unloading_occurred flag is done before the - // call to post_compiled_method_unload() so that the unloading - // of this nmethod is reported. - unloading_occurred = true; - } - - // Exception cache - clean_exception_cache(is_alive); - - // If class unloading occurred we first iterate over all inline caches and - // clear ICs where the cached oop is referring to an unloaded klass or method. - // The remaining live cached oops will be traversed in the relocInfo::oop_type - // iteration below. - if (unloading_occurred) { - RelocIterator iter(this, low_boundary); - while(iter.next()) { - if (iter.type() == relocInfo::virtual_call_type) { - CompiledIC *ic = CompiledIC_at(&iter); - clean_ic_if_metadata_is_dead(ic, is_alive); - } - } - } - - // Compiled code - { - RelocIterator iter(this, low_boundary); - while (iter.next()) { - if (iter.type() == relocInfo::oop_type) { - oop_Relocation* r = iter.oop_reloc(); - // In this loop, we must only traverse those oops directly embedded in - // the code. Other oops (oop_index>0) are seen as part of scopes_oops. - assert(1 == (r->oop_is_immediate()) + - (r->oop_addr() >= oops_begin() && r->oop_addr() < oops_end()), - "oop must be found in exactly one place"); - if (r->oop_is_immediate() && r->oop_value() != NULL) { - if (can_unload(is_alive, r->oop_addr(), unloading_occurred)) { - return; - } - } - } - } - } - - - // Scopes - for (oop* p = oops_begin(); p < oops_end(); p++) { - if (*p == Universe::non_oop_word()) continue; // skip non-oops - if (can_unload(is_alive, p, unloading_occurred)) { - return; - } - } - -#if INCLUDE_JVMCI - // Follow JVMCI method - BarrierSet* bs = Universe::heap()->barrier_set(); - if (_jvmci_installed_code != NULL) { - if (_jvmci_installed_code->is_a(HotSpotNmethod::klass()) && HotSpotNmethod::isDefault(_jvmci_installed_code)) { - if (!is_alive->do_object_b(_jvmci_installed_code)) { - clear_jvmci_installed_code(); - } - } else { - if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) { - return; - } - } - } - - if (_speculation_log != NULL) { - if (!is_alive->do_object_b(_speculation_log)) { - bs->write_ref_nmethod_pre(&_speculation_log, this); - _speculation_log = NULL; - bs->write_ref_nmethod_post(&_speculation_log, this); - } - } -#endif - - - // Ensure that all metadata is still alive - verify_metadata_loaders(low_boundary, is_alive); -} - -template -static bool clean_if_nmethod_is_unloaded(CompiledICorStaticCall *ic, address addr, BoolObjectClosure *is_alive, nmethod* from) { - // Ok, to lookup references to zombies here - CodeBlob *cb = CodeCache::find_blob_unsafe(addr); - if (cb != NULL && cb->is_nmethod()) { - nmethod* nm = (nmethod*)cb; - - if (nm->unloading_clock() != nmethod::global_unloading_clock()) { - // The nmethod has not been processed yet. - return true; - } - - // Clean inline caches pointing to both zombie and not_entrant methods - if (!nm->is_in_use() || (nm->method()->code() != nm)) { - ic->set_to_clean(); - assert(ic->is_clean(), "nmethod " PTR_FORMAT "not clean %s", p2i(from), from->method()->name_and_sig_as_C_string()); - } - } - - return false; -} - -static bool clean_if_nmethod_is_unloaded(CompiledIC *ic, BoolObjectClosure *is_alive, nmethod* from) { - return clean_if_nmethod_is_unloaded(ic, ic->ic_destination(), is_alive, from); -} - -static bool clean_if_nmethod_is_unloaded(CompiledStaticCall *csc, BoolObjectClosure *is_alive, nmethod* from) { - return clean_if_nmethod_is_unloaded(csc, csc->destination(), is_alive, from); -} - bool nmethod::unload_if_dead_at(RelocIterator* iter_at_oop, BoolObjectClosure *is_alive, bool unloading_occurred) { assert(iter_at_oop->type() == relocInfo::oop_type, "Wrong relocation type"); @@ -1937,93 +1526,36 @@ bool nmethod::unload_if_dead_at(RelocIterator* iter_at_oop, BoolObjectClosure *i return false; } - -bool nmethod::do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred) { - ResourceMark rm; - - // Make sure the oop's ready to receive visitors - assert(!is_zombie() && !is_unloaded(), - "should not call follow on zombie or unloaded nmethod"); - - // If the method is not entrant then a JMP is plastered over the - // first few bytes. If an oop in the old code was there, that oop - // should not get GC'd. Skip the first few bytes of oops on - // not-entrant methods. - address low_boundary = verified_entry_point(); - if (is_not_entrant()) { - low_boundary += NativeJump::instruction_size; - // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. - // (See comment above.) - } - - // The RedefineClasses() API can cause the class unloading invariant - // to no longer be true. See jvmtiExport.hpp for details. - // Also, leave a debugging breadcrumb in local flag. - if (JvmtiExport::has_redefined_a_class()) { - // This set of the unloading_occurred flag is done before the - // call to post_compiled_method_unload() so that the unloading - // of this nmethod is reported. - unloading_occurred = true; - } - - // Exception cache - clean_exception_cache(is_alive); - - bool is_unloaded = false; - bool postponed = false; - - RelocIterator iter(this, low_boundary); - while(iter.next()) { - - switch (iter.type()) { - - case relocInfo::virtual_call_type: - if (unloading_occurred) { - // If class unloading occurred we first iterate over all inline caches and - // clear ICs where the cached oop is referring to an unloaded klass or method. - clean_ic_if_metadata_is_dead(CompiledIC_at(&iter), is_alive); - } - - postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this); - break; - - case relocInfo::opt_virtual_call_type: - postponed |= clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this); - break; - - case relocInfo::static_call_type: - postponed |= clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this); - break; - - case relocInfo::oop_type: - if (!is_unloaded) { - is_unloaded = unload_if_dead_at(&iter, is_alive, unloading_occurred); - } - break; - - case relocInfo::metadata_type: - break; // nothing to do. - } - } - - if (is_unloaded) { - return postponed; - } - +bool nmethod::do_unloading_scopes(BoolObjectClosure* is_alive, bool unloading_occurred) { // Scopes for (oop* p = oops_begin(); p < oops_end(); p++) { if (*p == Universe::non_oop_word()) continue; // skip non-oops if (can_unload(is_alive, p, unloading_occurred)) { - is_unloaded = true; - break; + return true; } } + return false; +} - if (is_unloaded) { - return postponed; +bool nmethod::do_unloading_oops(address low_boundary, BoolObjectClosure* is_alive, bool unloading_occurred) { + // Compiled code + { + RelocIterator iter(this, low_boundary); + while (iter.next()) { + if (iter.type() == relocInfo::oop_type) { + if (unload_if_dead_at(&iter, is_alive, unloading_occurred)) { + return true; + } + } + } } + return do_unloading_scopes(is_alive, unloading_occurred); +} + #if INCLUDE_JVMCI +bool nmethod::do_unloading_jvmci(BoolObjectClosure* is_alive, bool unloading_occurred) { + bool is_unloaded = false; // Follow JVMCI method BarrierSet* bs = Universe::heap()->barrier_set(); if (_jvmci_installed_code != NULL) { @@ -2033,7 +1565,7 @@ bool nmethod::do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_ } } else { if (can_unload(is_alive, (oop*)&_jvmci_installed_code, unloading_occurred)) { - is_unloaded = true; + return true; } } } @@ -2045,123 +1577,9 @@ bool nmethod::do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_ bs->write_ref_nmethod_post(&_speculation_log, this); } } -#endif - - // Ensure that all metadata is still alive - verify_metadata_loaders(low_boundary, is_alive); - - return postponed; -} - -void nmethod::do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred) { - ResourceMark rm; - - // Make sure the oop's ready to receive visitors - assert(!is_zombie(), - "should not call follow on zombie nmethod"); - - // If the method is not entrant then a JMP is plastered over the - // first few bytes. If an oop in the old code was there, that oop - // should not get GC'd. Skip the first few bytes of oops on - // not-entrant methods. - address low_boundary = verified_entry_point(); - if (is_not_entrant()) { - low_boundary += NativeJump::instruction_size; - // %%% Note: On SPARC we patch only a 4-byte trap, not a full NativeJump. - // (See comment above.) - } - - RelocIterator iter(this, low_boundary); - while(iter.next()) { - - switch (iter.type()) { - - case relocInfo::virtual_call_type: - clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this); - break; - - case relocInfo::opt_virtual_call_type: - clean_if_nmethod_is_unloaded(CompiledIC_at(&iter), is_alive, this); - break; - - case relocInfo::static_call_type: - clean_if_nmethod_is_unloaded(compiledStaticCall_at(iter.reloc()), is_alive, this); - break; - } - } + return is_unloaded; } - -#ifdef ASSERT - -class CheckClass : AllStatic { - static BoolObjectClosure* _is_alive; - - // Check class_loader is alive for this bit of metadata. - static void check_class(Metadata* md) { - Klass* klass = NULL; - if (md->is_klass()) { - klass = ((Klass*)md); - } else if (md->is_method()) { - klass = ((Method*)md)->method_holder(); - } else if (md->is_methodData()) { - klass = ((MethodData*)md)->method()->method_holder(); - } else { - md->print(); - ShouldNotReachHere(); - } - assert(klass->is_loader_alive(_is_alive), "must be alive"); - } - public: - static void do_check_class(BoolObjectClosure* is_alive, nmethod* nm) { - assert(SafepointSynchronize::is_at_safepoint(), "this is only ok at safepoint"); - _is_alive = is_alive; - nm->metadata_do(check_class); - } -}; - -// This is called during a safepoint so can use static data -BoolObjectClosure* CheckClass::_is_alive = NULL; -#endif // ASSERT - - -// Processing of oop references should have been sufficient to keep -// all strong references alive. Any weak references should have been -// cleared as well. Visit all the metadata and ensure that it's -// really alive. -void nmethod::verify_metadata_loaders(address low_boundary, BoolObjectClosure* is_alive) { -#ifdef ASSERT - RelocIterator iter(this, low_boundary); - while (iter.next()) { - // static_stub_Relocations may have dangling references to - // Method*s so trim them out here. Otherwise it looks like - // compiled code is maintaining a link to dead metadata. - address static_call_addr = NULL; - if (iter.type() == relocInfo::opt_virtual_call_type) { - CompiledIC* cic = CompiledIC_at(&iter); - if (!cic->is_call_to_interpreted()) { - static_call_addr = iter.addr(); - } - } else if (iter.type() == relocInfo::static_call_type) { - CompiledStaticCall* csc = compiledStaticCall_at(iter.reloc()); - if (!csc->is_call_to_interpreted()) { - static_call_addr = iter.addr(); - } - } - if (static_call_addr != NULL) { - RelocIterator sciter(this, low_boundary); - while (sciter.next()) { - if (sciter.type() == relocInfo::static_stub_type && - sciter.static_stub_reloc()->static_call() == static_call_addr) { - sciter.static_stub_reloc()->clear_inline_cache(); - } - } - } - } - // Check that the metadata embedded in the nmethod is alive - CheckClass::do_check_class(is_alive, this); #endif -} - // Iterate over metadata calling this function. Used by RedefineClasses void nmethod::metadata_do(void f(Metadata*)) { @@ -2360,32 +1778,6 @@ bool nmethod::detect_scavenge_root_oops() { return detect_scavenge_root.detected_scavenge_root(); } -// Method that knows how to preserve outgoing arguments at call. This method must be -// called with a frame corresponding to a Java invoke -void nmethod::preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, OopClosure* f) { -#ifndef SHARK - if (method() != NULL && !method()->is_native()) { - address pc = fr.pc(); - SimpleScopeDesc ssd(this, pc); - Bytecode_invoke call(ssd.method(), ssd.bci()); - bool has_receiver = call.has_receiver(); - bool has_appendix = call.has_appendix(); - Symbol* signature = call.signature(); - - // The method attached by JIT-compilers should be used, if present. - // Bytecode can be inaccurate in such case. - Method* callee = attached_method_before_pc(pc); - if (callee != NULL) { - has_receiver = !(callee->access_flags().is_static()); - has_appendix = false; - signature = callee->signature(); - } - - fr.oops_compiled_arguments_do(signature, has_receiver, has_appendix, reg_map, f); - } -#endif // !SHARK -} - inline bool includes(void* p, void* from, void* to) { return from <= p && p < to; } @@ -2415,7 +1807,7 @@ void nmethod::copy_scopes_pcs(PcDesc* pcs, int count) { break; } } - assert(has_method_handle_invokes() == (_deoptimize_mh_offset != -1), "must have deopt mh handler"); + assert(has_method_handle_invokes() == (_deopt_mh_handler_begin != NULL), "must have deopt mh handler"); int size = count * sizeof(PcDesc); assert(scopes_pcs_size() >= size, "oob"); @@ -2441,19 +1833,10 @@ void nmethod::copy_scopes_data(u_char* buffer, int size) { memcpy(scopes_data_begin(), buffer, size); } -// When using JVMCI the address might be off by the size of a call instruction. -bool nmethod::is_deopt_entry(address pc) { - return pc == deopt_handler_begin() -#if INCLUDE_JVMCI - || pc == (deopt_handler_begin() + NativeCall::instruction_size) -#endif - ; -} - #ifdef ASSERT -static PcDesc* linear_search(nmethod* nm, int pc_offset, bool approximate) { - PcDesc* lower = nm->scopes_pcs_begin(); - PcDesc* upper = nm->scopes_pcs_end(); +static PcDesc* linear_search(const PcDescSearch& search, int pc_offset, bool approximate) { + PcDesc* lower = search.scopes_pcs_begin(); + PcDesc* upper = search.scopes_pcs_end(); lower += 1; // exclude initial sentinel PcDesc* res = NULL; for (PcDesc* p = lower; p < upper; p++) { @@ -2471,8 +1854,8 @@ static PcDesc* linear_search(nmethod* nm, int pc_offset, bool approximate) { // Finds a PcDesc with real-pc equal to "pc" -PcDesc* nmethod::find_pc_desc_internal(address pc, bool approximate) { - address base_address = code_begin(); +PcDesc* PcDescContainer::find_pc_desc_internal(address pc, bool approximate, const PcDescSearch& search) { + address base_address = search.code_begin(); if ((pc < base_address) || (pc - base_address) >= (ptrdiff_t) PcDesc::upper_offset_limit) { return NULL; // PC is wildly out of range @@ -2483,7 +1866,7 @@ PcDesc* nmethod::find_pc_desc_internal(address pc, bool approximate) { // (This as an almost 100% hit rate.) PcDesc* res = _pc_desc_cache.find_pc_desc(pc_offset, approximate); if (res != NULL) { - assert(res == linear_search(this, pc_offset, approximate), "cache ok"); + assert(res == linear_search(search, pc_offset, approximate), "cache ok"); return res; } @@ -2491,8 +1874,8 @@ PcDesc* nmethod::find_pc_desc_internal(address pc, bool approximate) { // Find the last pc_offset less than the given offset. // The successor must be the required match, if there is a match at all. // (Use a fixed radix to avoid expensive affine pointer arithmetic.) - PcDesc* lower = scopes_pcs_begin(); - PcDesc* upper = scopes_pcs_end(); + PcDesc* lower = search.scopes_pcs_begin(); + PcDesc* upper = search.scopes_pcs_end(); upper -= 1; // exclude final sentinel if (lower >= upper) return NULL; // native method; no PcDescs at all @@ -2543,11 +1926,11 @@ PcDesc* nmethod::find_pc_desc_internal(address pc, bool approximate) { #undef assert_LU_OK if (match_desc(upper, pc_offset, approximate)) { - assert(upper == linear_search(this, pc_offset, approximate), "search ok"); + assert(upper == linear_search(search, pc_offset, approximate), "search ok"); _pc_desc_cache.add_pc_desc(upper); return upper; } else { - assert(NULL == linear_search(this, pc_offset, approximate), "search ok"); + assert(NULL == linear_search(search, pc_offset, approximate), "search ok"); return NULL; } } @@ -2701,53 +2084,27 @@ void nmethod_init() { // QQQ might we make this work from a frame?? nmethodLocker::nmethodLocker(address pc) { CodeBlob* cb = CodeCache::find_blob(pc); - guarantee(cb != NULL && cb->is_nmethod(), "bad pc for a nmethod found"); - _nm = (nmethod*)cb; + guarantee(cb != NULL && cb->is_compiled(), "bad pc for a nmethod found"); + _nm = cb->as_compiled_method(); lock_nmethod(_nm); } // Only JvmtiDeferredEvent::compiled_method_unload_event() // should pass zombie_ok == true. -void nmethodLocker::lock_nmethod(nmethod* nm, bool zombie_ok) { - if (nm == NULL) return; +void nmethodLocker::lock_nmethod(CompiledMethod* cm, bool zombie_ok) { + if (cm == NULL) return; + nmethod* nm = cm->as_nmethod(); Atomic::inc(&nm->_lock_count); assert(zombie_ok || !nm->is_zombie(), "cannot lock a zombie method"); } -void nmethodLocker::unlock_nmethod(nmethod* nm) { - if (nm == NULL) return; +void nmethodLocker::unlock_nmethod(CompiledMethod* cm) { + if (cm == NULL) return; + nmethod* nm = cm->as_nmethod(); Atomic::dec(&nm->_lock_count); assert(nm->_lock_count >= 0, "unmatched nmethod lock/unlock"); } -// ----------------------------------------------------------------------------- -// nmethod::get_deopt_original_pc -// -// Return the original PC for the given PC if: -// (a) the given PC belongs to a nmethod and -// (b) it is a deopt PC -address nmethod::get_deopt_original_pc(const frame* fr) { - if (fr->cb() == NULL) return NULL; - - nmethod* nm = fr->cb()->as_nmethod_or_null(); - if (nm != NULL && nm->is_deopt_pc(fr->pc())) - return nm->get_original_pc(fr); - - return NULL; -} - - -// ----------------------------------------------------------------------------- -// MethodHandle - -bool nmethod::is_method_handle_return(address return_pc) { - if (!has_method_handle_invokes()) return false; - PcDesc* pd = pc_desc_at(return_pc); - if (pd == NULL) - return false; - return pd->is_method_handle_invoke(); -} - // ----------------------------------------------------------------------------- // Verification @@ -3201,7 +2558,7 @@ void nmethod::print_nmethod_labels(outputStream* stream, address block_begin) co if (block_begin == verified_entry_point()) stream->print_cr("[Verified Entry Point]"); if (JVMCI_ONLY(_exception_offset >= 0 &&) block_begin == exception_begin()) stream->print_cr("[Exception Handler]"); if (block_begin == stub_begin()) stream->print_cr("[Stub Code]"); - if (JVMCI_ONLY(_deoptimize_offset >= 0 &&) block_begin == deopt_handler_begin()) stream->print_cr("[Deopt Handler Code]"); + if (JVMCI_ONLY(_deopt_handler_begin != NULL &&) block_begin == deopt_handler_begin()) stream->print_cr("[Deopt Handler Code]"); if (has_method_handle_invokes()) if (block_begin == deopt_mh_handler_begin()) stream->print_cr("[Deopt MH Handler Code]"); @@ -3565,26 +2922,3 @@ char* nmethod::jvmci_installed_code_name(char* buf, size_t buflen) { } #endif -Method* nmethod::attached_method(address call_instr) { - assert(code_contains(call_instr), "not part of the nmethod"); - RelocIterator iter(this, call_instr, call_instr + 1); - while (iter.next()) { - if (iter.addr() == call_instr) { - switch(iter.type()) { - case relocInfo::static_call_type: return iter.static_call_reloc()->method_value(); - case relocInfo::opt_virtual_call_type: return iter.opt_virtual_call_reloc()->method_value(); - case relocInfo::virtual_call_type: return iter.virtual_call_reloc()->method_value(); - } - } - } - return NULL; // not found -} - -Method* nmethod::attached_method_before_pc(address pc) { - if (NativeCall::is_call_before(pc)) { - NativeCall* ncall = nativeCall_before(pc); - return attached_method(ncall->instruction_address()); - } - return NULL; // not a call -} - diff --git a/hotspot/src/share/vm/code/nmethod.hpp b/hotspot/src/share/vm/code/nmethod.hpp index cdbf58e011a..16ad01a38a5 100644 --- a/hotspot/src/share/vm/code/nmethod.hpp +++ b/hotspot/src/share/vm/code/nmethod.hpp @@ -25,68 +25,11 @@ #ifndef SHARE_VM_CODE_NMETHOD_HPP #define SHARE_VM_CODE_NMETHOD_HPP -#include "code/codeBlob.hpp" -#include "code/pcDesc.hpp" -#include "oops/metadata.hpp" +#include "code/compiledMethod.hpp" +class DepChange; class DirectiveSet; -// This class is used internally by nmethods, to cache -// exception/pc/handler information. - -class ExceptionCache : public CHeapObj { - friend class VMStructs; - private: - enum { cache_size = 16 }; - Klass* _exception_type; - address _pc[cache_size]; - address _handler[cache_size]; - volatile int _count; - ExceptionCache* _next; - - address pc_at(int index) { assert(index >= 0 && index < count(),""); return _pc[index]; } - void set_pc_at(int index, address a) { assert(index >= 0 && index < cache_size,""); _pc[index] = a; } - address handler_at(int index) { assert(index >= 0 && index < count(),""); return _handler[index]; } - void set_handler_at(int index, address a) { assert(index >= 0 && index < cache_size,""); _handler[index] = a; } - int count() { return OrderAccess::load_acquire(&_count); } - // increment_count is only called under lock, but there may be concurrent readers. - void increment_count() { OrderAccess::release_store(&_count, _count + 1); } - - public: - - ExceptionCache(Handle exception, address pc, address handler); - - Klass* exception_type() { return _exception_type; } - ExceptionCache* next() { return _next; } - void set_next(ExceptionCache *ec) { _next = ec; } - - address match(Handle exception, address pc); - bool match_exception_with_space(Handle exception) ; - address test_address(address addr); - bool add_address_and_handler(address addr, address handler) ; -}; - - -// cache pc descs found in earlier inquiries -class PcDescCache VALUE_OBJ_CLASS_SPEC { - friend class VMStructs; - private: - enum { cache_size = 4 }; - // The array elements MUST be volatile! Several threads may modify - // and read from the cache concurrently. find_pc_desc_internal has - // returned wrong results. C++ compiler (namely xlC12) may duplicate - // C++ field accesses if the elements are not volatile. - typedef PcDesc* PcDescPtr; - volatile PcDescPtr _pc_descs[cache_size]; // last cache_size pc_descs found - public: - PcDescCache() { debug_only(_pc_descs[0] = NULL); } - void reset_to(PcDesc* initial_pc_desc); - PcDesc* find_pc_desc(int pc_offset, bool approximate); - void add_pc_desc(PcDesc* pc_desc); - PcDesc* last_pc_desc() { return _pc_descs[0]; } -}; - - // nmethods (native methods) are the compiled code versions of Java methods. // // An nmethod contains: @@ -108,26 +51,14 @@ class PcDescCache VALUE_OBJ_CLASS_SPEC { // [Implicit Null Pointer exception table] // - implicit null table array -class DepChange; -class Dependencies; -class ExceptionHandlerTable; -class ImplicitExceptionTable; -class AbstractCompiler; -class xmlStream; - -class nmethod : public CodeBlob { +class nmethod : public CompiledMethod { friend class VMStructs; friend class JVMCIVMStructs; friend class NMethodSweeper; friend class CodeCache; // scavengable oops private: - // GC support to help figure out if an nmethod has been - // cleaned/unloaded by the current GC. - static unsigned char _global_unloading_clock; - // Shared fields for all nmethod's - Method* _method; int _entry_bci; // != InvocationEntryBci if this nmethod is an on-stack replacement method jmethodID _jmethod_id; // Cache of method()->jmethod_id() @@ -140,13 +71,6 @@ class nmethod : public CodeBlob { // To support simple linked-list chaining of nmethods: nmethod* _osr_link; // from InstanceKlass::osr_nmethods_head - union { - // Used by G1 to chain nmethods. - nmethod* _unloading_next; - // Used by non-G1 GCs to chain nmethods. - nmethod* _scavenge_root_link; // from CodeCache::scavenge_root_nmethods - }; - static nmethod* volatile _oops_do_mark_nmethods; nmethod* volatile _oops_do_mark_link; @@ -158,13 +82,7 @@ class nmethod : public CodeBlob { address _osr_entry_point; // entry point for on stack replacement // Offsets for different nmethod parts - int _exception_offset; - // All deoptee's will resume execution at this location described by - // this offset. - int _deoptimize_offset; - // All deoptee's at a MethodHandle call site will resume execution - // at this location described by this offset. - int _deoptimize_mh_offset; + int _exception_offset; // Offset of the unwind handler if it exists int _unwind_handler_offset; @@ -179,6 +97,8 @@ class nmethod : public CodeBlob { int _nul_chk_table_offset; int _nmethod_end_offset; + int code_offset() const { return (address) code_begin() - header_begin(); } + // location in frame (offset for sp) that deopt can store the original // pc during a deopt. int _orig_pc_offset; @@ -189,27 +109,12 @@ class nmethod : public CodeBlob { // protected by CodeCache_lock bool _has_flushed_dependencies; // Used for maintenance of dependencies (CodeCache_lock) - enum MarkForDeoptimizationStatus { - not_marked, - deoptimize, - deoptimize_noupdate }; - - MarkForDeoptimizationStatus _mark_for_deoptimization_status; // Used for stack deoptimization - // used by jvmti to track if an unload event has been posted for this nmethod. bool _unload_reported; - // set during construction - unsigned int _has_unsafe_access:1; // May fault due to unsafe access. - unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes? - unsigned int _lazy_critical_native:1; // Lazy JNI critical native - unsigned int _has_wide_vectors:1; // Preserve wide vectors at safepoints - // Protected by Patching_lock volatile unsigned char _state; // {in_use, not_entrant, zombie, unloaded} - volatile unsigned char _unloading_clock; // Incremented after GC unloaded/cleaned the nmethod - #ifdef ASSERT bool _oops_are_stale; // indicates that it's no longer safe to access oops section #endif @@ -242,9 +147,6 @@ class nmethod : public CodeBlob { // counter is decreased (by 1) while sweeping. int _hotness_counter; - ExceptionCache * volatile _exception_cache; - PcDescCache _pc_desc_cache; - // These are used for compiled synchronized native methods to // locate the owner and stack slot for the BasicLock so that we can // properly revoke the bias of the owner if necessary. They are @@ -302,18 +204,21 @@ class nmethod : public CodeBlob { // Returns true if this thread changed the state of the nmethod or // false if another thread performed the transition. bool make_not_entrant_or_zombie(unsigned int state); + bool make_entrant() { Unimplemented(); return false; } void inc_decompile_count(); - // Used to manipulate the exception cache - void add_exception_cache_entry(ExceptionCache* new_entry); - ExceptionCache* exception_cache_entry_for_exception(Handle exception); - // Inform external interfaces that a compiled method has been unloaded void post_compiled_method_unload(); // Initailize fields to their default values void init_defaults(); + // Offsets + int content_offset() const { return content_begin() - header_begin(); } + int data_offset() const { return _data_offset; } + + address header_end() const { return (address) header_begin() + header_size(); } + public: // create nmethod with entry_bci static nmethod* new_nmethod(const methodHandle& method, @@ -334,7 +239,7 @@ class nmethod : public CodeBlob { , Handle installed_code = Handle(), Handle speculation_log = Handle() #endif - ); + ); static nmethod* new_native_nmethod(const methodHandle& method, int compile_id, @@ -347,13 +252,10 @@ class nmethod : public CodeBlob { OopMapSet* oop_maps); // accessors - Method* method() const { return _method; } AbstractCompiler* compiler() const { return _compiler; } // type info bool is_nmethod() const { return true; } - bool is_java_method() const { return !method()->is_native(); } - bool is_native_method() const { return method()->is_native(); } bool is_osr_method() const { return _entry_bci != InvocationEntryBci; } bool is_compiled_by_c1() const; @@ -363,22 +265,17 @@ class nmethod : public CodeBlob { // boundaries for different parts address consts_begin () const { return header_begin() + _consts_offset ; } - address consts_end () const { return header_begin() + code_offset() ; } - address insts_begin () const { return header_begin() + code_offset() ; } - address insts_end () const { return header_begin() + _stub_offset ; } + address consts_end () const { return code_begin() ; } address stub_begin () const { return header_begin() + _stub_offset ; } address stub_end () const { return header_begin() + _oops_offset ; } address exception_begin () const { return header_begin() + _exception_offset ; } - address deopt_handler_begin () const { return header_begin() + _deoptimize_offset ; } - address deopt_mh_handler_begin() const { return header_begin() + _deoptimize_mh_offset ; } address unwind_handler_begin () const { return _unwind_handler_offset != -1 ? (header_begin() + _unwind_handler_offset) : NULL; } oop* oops_begin () const { return (oop*) (header_begin() + _oops_offset) ; } oop* oops_end () const { return (oop*) (header_begin() + _metadata_offset) ; } Metadata** metadata_begin () const { return (Metadata**) (header_begin() + _metadata_offset) ; } - Metadata** metadata_end () const { return (Metadata**) (header_begin() + _scopes_data_offset) ; } + Metadata** metadata_end () const { return (Metadata**) _scopes_data_begin; } - address scopes_data_begin () const { return header_begin() + _scopes_data_offset ; } address scopes_data_end () const { return header_begin() + _scopes_pcs_offset ; } PcDesc* scopes_pcs_begin () const { return (PcDesc*)(header_begin() + _scopes_pcs_offset ); } PcDesc* scopes_pcs_end () const { return (PcDesc*)(header_begin() + _dependencies_offset) ; } @@ -390,16 +287,9 @@ class nmethod : public CodeBlob { address nul_chk_table_end () const { return header_begin() + _nmethod_end_offset ; } // Sizes - int consts_size () const { return consts_end () - consts_begin (); } - int insts_size () const { return insts_end () - insts_begin (); } - int stub_size () const { return stub_end () - stub_begin (); } int oops_size () const { return (address) oops_end () - (address) oops_begin (); } int metadata_size () const { return (address) metadata_end () - (address) metadata_begin (); } - int scopes_data_size () const { return scopes_data_end () - scopes_data_begin (); } - int scopes_pcs_size () const { return (intptr_t) scopes_pcs_end () - (intptr_t) scopes_pcs_begin (); } int dependencies_size () const { return dependencies_end () - dependencies_begin (); } - int handler_table_size() const { return handler_table_end() - handler_table_begin(); } - int nul_chk_table_size() const { return nul_chk_table_end() - nul_chk_table_begin(); } int oops_count() const { assert(oops_size() % oopSize == 0, ""); return (oops_size() / oopSize) + 1; } int metadata_count() const { assert(metadata_size() % wordSize == 0, ""); return (metadata_size() / wordSize) + 1; } @@ -411,15 +301,10 @@ class nmethod : public CodeBlob { int hotness_counter() const { return _hotness_counter; } // Containment - bool consts_contains (address addr) const { return consts_begin () <= addr && addr < consts_end (); } - bool insts_contains (address addr) const { return insts_begin () <= addr && addr < insts_end (); } - bool stub_contains (address addr) const { return stub_begin () <= addr && addr < stub_end (); } bool oops_contains (oop* addr) const { return oops_begin () <= addr && addr < oops_end (); } bool metadata_contains (Metadata** addr) const { return metadata_begin () <= addr && addr < metadata_end (); } bool scopes_data_contains (address addr) const { return scopes_data_begin () <= addr && addr < scopes_data_end (); } bool scopes_pcs_contains (PcDesc* addr) const { return scopes_pcs_begin () <= addr && addr < scopes_pcs_end (); } - bool handler_table_contains(address addr) const { return handler_table_begin() <= addr && addr < handler_table_end(); } - bool nul_chk_table_contains(address addr) const { return nul_chk_table_begin() <= addr && addr < nul_chk_table_end(); } // entry points address entry_point() const { return _entry_point; } // normal entry point @@ -434,24 +319,11 @@ class nmethod : public CodeBlob { // flag accessing and manipulation bool is_in_use() const { return _state == in_use; } - bool is_alive() const { unsigned char s = _state; return s == in_use || s == not_entrant; } + bool is_alive() const { unsigned char s = _state; return s < zombie; } bool is_not_entrant() const { return _state == not_entrant; } bool is_zombie() const { return _state == zombie; } bool is_unloaded() const { return _state == unloaded; } - // returns a string version of the nmethod state - const char* state() const { - switch(_state) { - case in_use: return "in use"; - case not_entrant: return "not_entrant"; - case zombie: return "zombie"; - case unloaded: return "unloaded"; - default: - fatal("unexpected nmethod state: %d", _state); - return NULL; - } - } - #if INCLUDE_RTM_OPT // rtm state accessing and manipulating RTMState rtm_state() const { return _rtm_state; } @@ -466,30 +338,15 @@ class nmethod : public CodeBlob { assert(!method()->is_method_handle_intrinsic(), "Cannot make MH intrinsic not entrant"); return make_not_entrant_or_zombie(not_entrant); } + bool make_not_used() { return make_not_entrant(); } bool make_zombie() { return make_not_entrant_or_zombie(zombie); } // used by jvmti to track if the unload event has been reported bool unload_reported() { return _unload_reported; } void set_unload_reported() { _unload_reported = true; } - void set_unloading_next(nmethod* next) { _unloading_next = next; } - nmethod* unloading_next() { return _unloading_next; } - - static unsigned char global_unloading_clock() { return _global_unloading_clock; } - static void increase_unloading_clock(); - - void set_unloading_clock(unsigned char unloading_clock); - unsigned char unloading_clock(); - - bool is_marked_for_deoptimization() const { return _mark_for_deoptimization_status != not_marked; } - void mark_for_deoptimization(bool inc_recompile_counts = true) { - _mark_for_deoptimization_status = (inc_recompile_counts ? deoptimize : deoptimize_noupdate); - } - bool update_recompile_counts() const { - // Update recompile counts when either the update is explicitly requested (deoptimize) - // or the nmethod is not marked for deoptimization at all (not_marked). - // The latter happens during uncommon traps when deoptimized nmethod is made not entrant. - return _mark_for_deoptimization_status != deoptimize_noupdate; + int get_state() const { + return _state; } void make_unloaded(BoolObjectClosure* is_alive, oop cause); @@ -502,18 +359,6 @@ class nmethod : public CodeBlob { _has_flushed_dependencies = 1; } - bool has_unsafe_access() const { return _has_unsafe_access; } - void set_has_unsafe_access(bool z) { _has_unsafe_access = z; } - - bool has_method_handle_invokes() const { return _has_method_handle_invokes; } - void set_has_method_handle_invokes(bool z) { _has_method_handle_invokes = z; } - - bool is_lazy_critical_native() const { return _lazy_critical_native; } - void set_lazy_critical_native(bool z) { _lazy_critical_native = z; } - - bool has_wide_vectors() const { return _has_wide_vectors; } - void set_has_wide_vectors(bool z) { _has_wide_vectors = z; } - int comp_level() const { return _comp_level; } // Support for oops in scopes and relocs: @@ -538,9 +383,6 @@ class nmethod : public CodeBlob { void copy_values(GrowableArray* oops); void copy_values(GrowableArray* metadata); - Method* attached_method(address call_pc); - Method* attached_method_before_pc(address pc); - // Relocation support private: void fix_oop_relocations(address begin, address end, bool initialize_immediates); @@ -549,10 +391,6 @@ private: public: void fix_oop_relocations(address begin, address end) { fix_oop_relocations(begin, end, false); } void fix_oop_relocations() { fix_oop_relocations(NULL, NULL, false); } - void verify_oop_relocations(); - - bool is_at_poll_return(address pc); - bool is_at_poll_or_poll_return(address pc); // Scavengable oop support bool on_scavenge_root_list() const { return (_scavenge_root_state & 1) != 0; } @@ -576,15 +414,6 @@ public: long stack_traversal_mark() { return _stack_traversal_mark; } void set_stack_traversal_mark(long l) { _stack_traversal_mark = l; } - // Exception cache support - // Note: _exception_cache may be read concurrently. We rely on memory_order_consume here. - ExceptionCache* exception_cache() const { return _exception_cache; } - void set_exception_cache(ExceptionCache *ec) { _exception_cache = ec; } - void release_set_exception_cache(ExceptionCache *ec) { OrderAccess::release_store_ptr(&_exception_cache, ec); } - address handler_for_exception_and_pc(Handle exception, address pc); - void add_handler_for_exception_and_pc(Handle exception, address pc, address handler); - void clean_exception_cache(BoolObjectClosure* is_alive); - // implicit exceptions support address continuation_for_implicit_exception(address pc); @@ -595,24 +424,8 @@ public: nmethod* osr_link() const { return _osr_link; } void set_osr_link(nmethod *n) { _osr_link = n; } - // tells whether frames described by this nmethod can be deoptimized - // note: native wrappers cannot be deoptimized. - bool can_be_deoptimized() const { return is_java_method(); } - - // Inline cache support - void clear_inline_caches(); - void clear_ic_stubs(); - void cleanup_inline_caches(bool clean_all = false); - bool inlinecache_check_contains(address addr) const { - return (addr >= code_begin() && addr < verified_entry_point()); - } - // Verify calls to dead methods have been cleaned. void verify_clean_inline_caches(); - // Verify and count cached icholder relocations. - int verify_icholder_relocations(); - // Check that all metadata is still alive - void verify_metadata_loaders(address low_boundary, BoolObjectClosure* is_alive); // unlink and deallocate this nmethod // Only NMethodSweeper class is expected to use this. NMethodSweeper is not @@ -653,20 +466,19 @@ public: public: #endif - // GC support - void do_unloading(BoolObjectClosure* is_alive, bool unloading_occurred); - // The parallel versions are used by G1. - bool do_unloading_parallel(BoolObjectClosure* is_alive, bool unloading_occurred); - void do_unloading_parallel_postponed(BoolObjectClosure* is_alive, bool unloading_occurred); + protected: + virtual bool do_unloading_oops(address low_boundary, BoolObjectClosure* is_alive, bool unloading_occurred); +#if INCLUDE_JVMCI + virtual bool do_unloading_jvmci(BoolObjectClosure* is_alive, bool unloading_occurred); +#endif private: + bool do_unloading_scopes(BoolObjectClosure* is_alive, bool unloading_occurred); // Unload a nmethod if the *root object is dead. bool can_unload(BoolObjectClosure* is_alive, oop* root, bool unloading_occurred); bool unload_if_dead_at(RelocIterator *iter_at_oop, BoolObjectClosure* is_alive, bool unloading_occurred); public: - void preserve_callee_argument_oops(frame fr, const RegisterMap *reg_map, - OopClosure* f); void oops_do(OopClosure* f) { oops_do(f, false); } void oops_do(OopClosure* f, bool allow_zombie); bool detect_scavenge_root_oops(); @@ -678,49 +490,20 @@ public: static bool oops_do_marking_is_active() { return _oops_do_mark_nmethods != NULL; } bool test_oops_do_mark() { return _oops_do_mark_link != NULL; } - // ScopeDesc for an instruction - ScopeDesc* scope_desc_at(address pc); - private: ScopeDesc* scope_desc_in(address begin, address end); address* orig_pc_addr(const frame* fr) { return (address*) ((address)fr->unextended_sp() + _orig_pc_offset); } - PcDesc* find_pc_desc_internal(address pc, bool approximate); - - PcDesc* find_pc_desc(address pc, bool approximate) { - PcDesc* desc = _pc_desc_cache.last_pc_desc(); - if (desc != NULL && desc->pc_offset() == pc - code_begin()) { - return desc; - } - return find_pc_desc_internal(pc, approximate); - } - - public: - // ScopeDesc retrieval operation - PcDesc* pc_desc_at(address pc) { return find_pc_desc(pc, false); } - // pc_desc_near returns the first PcDesc at or after the givne pc. - PcDesc* pc_desc_near(address pc) { return find_pc_desc(pc, true); } - public: // copying of debugging information void copy_scopes_pcs(PcDesc* pcs, int count); void copy_scopes_data(address buffer, int size); - // Deopt - // Return true is the PC is one would expect if the frame is being deopted. - bool is_deopt_pc (address pc) { return is_deopt_entry(pc) || is_deopt_mh_entry(pc); } - bool is_deopt_entry (address pc); - bool is_deopt_mh_entry(address pc) { return pc == deopt_mh_handler_begin(); } // Accessor/mutator for the original pc of a frame before a frame was deopted. address get_original_pc(const frame* fr) { return *orig_pc_addr(fr); } void set_original_pc(const frame* fr, address pc) { *orig_pc_addr(fr) = pc; } - static address get_deopt_original_pc(const frame* fr); - - // MethodHandle - bool is_method_handle_return(address return_pc); - // jvmti support: void post_compiled_method_load_event(); jmethodID get_and_cache_jmethod_id(); @@ -770,7 +553,7 @@ public: // are numbered in an independent sequence if CICountOSR is true, // and native method wrappers are also numbered independently if // CICountNative is true. - int compile_id() const { return _compile_id; } + virtual int compile_id() const { return _compile_id; } const char* compile_kind() const; // tells if any of this method's dependencies have been invalidated @@ -789,7 +572,7 @@ public: // Fast breakpoint support. Tells if this compiled method is // dependent on the given method. Returns true if this nmethod // corresponds to the given method as well. - bool is_dependent_on_method(Method* dependee); + virtual bool is_dependent_on_method(Method* dependee); // is it ok to patch at address? bool is_patchable_at(address instr_address); @@ -807,12 +590,7 @@ public: static int osr_entry_point_offset() { return offset_of(nmethod, _osr_entry_point); } static int state_offset() { return offset_of(nmethod, _state); } - // RedefineClasses support. Mark metadata in nmethods as on_stack so that - // redefine classes doesn't purge it. - static void mark_on_stack(nmethod* nm) { - nm->metadata_do(Metadata::mark_on_stack); - } - void metadata_do(void f(Metadata*)); + virtual void metadata_do(void f(Metadata*)); }; // Locks an nmethod so its code will not get removed and it will not @@ -821,26 +599,43 @@ public: // needs to be done, then lock_nmethod() is used directly to keep the // generated code from being reused too early. class nmethodLocker : public StackObj { - nmethod* _nm; + CompiledMethod* _nm; public: // note: nm can be NULL // Only JvmtiDeferredEvent::compiled_method_unload_event() // should pass zombie_ok == true. - static void lock_nmethod(nmethod* nm, bool zombie_ok = false); - static void unlock_nmethod(nmethod* nm); // (ditto) + static void lock_nmethod(CompiledMethod* nm, bool zombie_ok = false); + static void unlock_nmethod(CompiledMethod* nm); // (ditto) nmethodLocker(address pc); // derive nm from pc nmethodLocker(nmethod *nm) { _nm = nm; lock_nmethod(_nm); } + nmethodLocker(CompiledMethod *nm) { + _nm = nm; + lock(_nm); + } + + static void lock(CompiledMethod* method) { + if (method == NULL) return; + lock_nmethod(method); + } + + static void unlock(CompiledMethod* method) { + if (method == NULL) return; + unlock_nmethod(method); + } + nmethodLocker() { _nm = NULL; } - ~nmethodLocker() { unlock_nmethod(_nm); } + ~nmethodLocker() { + unlock(_nm); + } - nmethod* code() { return _nm; } - void set_code(nmethod* new_nm) { - unlock_nmethod(_nm); // note: This works even if _nm==new_nm. + CompiledMethod* code() { return _nm; } + void set_code(CompiledMethod* new_nm) { + unlock(_nm); // note: This works even if _nm==new_nm. _nm = new_nm; - lock_nmethod(_nm); + lock(_nm); } }; diff --git a/hotspot/src/share/vm/code/pcDesc.cpp b/hotspot/src/share/vm/code/pcDesc.cpp index a860b5b804d..ebacd8f0975 100644 --- a/hotspot/src/share/vm/code/pcDesc.cpp +++ b/hotspot/src/share/vm/code/pcDesc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,11 +36,11 @@ PcDesc::PcDesc(int pc_offset, int scope_decode_offset, int obj_decode_offset) { _flags = 0; } -address PcDesc::real_pc(const nmethod* code) const { +address PcDesc::real_pc(const CompiledMethod* code) const { return code->code_begin() + pc_offset(); } -void PcDesc::print(nmethod* code) { +void PcDesc::print(CompiledMethod* code) { #ifndef PRODUCT ResourceMark rm; tty->print_cr("PcDesc(pc=" PTR_FORMAT " offset=%x bits=%x):", p2i(real_pc(code)), pc_offset(), _flags); @@ -57,7 +57,7 @@ void PcDesc::print(nmethod* code) { #endif } -bool PcDesc::verify(nmethod* code) { +bool PcDesc::verify(CompiledMethod* code) { //Unimplemented(); return true; } diff --git a/hotspot/src/share/vm/code/pcDesc.hpp b/hotspot/src/share/vm/code/pcDesc.hpp index 83734c8f0b8..435c8af8182 100644 --- a/hotspot/src/share/vm/code/pcDesc.hpp +++ b/hotspot/src/share/vm/code/pcDesc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ // PcDescs map a physical PC (given as offset from start of nmethod) to // the corresponding source scope and byte code index. -class nmethod; +class CompiledMethod; class PcDesc VALUE_OBJ_CLASS_SPEC { friend class VMStructs; @@ -91,10 +91,10 @@ class PcDesc VALUE_OBJ_CLASS_SPEC { void set_return_oop(bool z) { set_flag(PCDESC_return_oop, z); } // Returns the real pc - address real_pc(const nmethod* code) const; + address real_pc(const CompiledMethod* code) const; - void print(nmethod* code); - bool verify(nmethod* code); + void print(CompiledMethod* code); + bool verify(CompiledMethod* code); }; #endif // SHARE_VM_CODE_PCDESC_HPP diff --git a/hotspot/src/share/vm/code/relocInfo.cpp b/hotspot/src/share/vm/code/relocInfo.cpp index 444c91c46be..45a39db8360 100644 --- a/hotspot/src/share/vm/code/relocInfo.cpp +++ b/hotspot/src/share/vm/code/relocInfo.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,7 +81,6 @@ relocInfo* relocInfo::finish_prefix(short* prefix_limit) { return (relocInfo*)prefix_limit; } - void relocInfo::set_type(relocType t) { int old_offset = addr_offset(); int old_format = format(); @@ -91,6 +90,9 @@ void relocInfo::set_type(relocType t) { assert(format()==old_format, "sanity check"); } +nmethod* RelocIterator::code_as_nmethod() const { + return _code->as_nmethod(); +} void relocInfo::set_format(int f) { int old_offset = addr_offset(); @@ -121,13 +123,13 @@ void relocInfo::remove_reloc_info_for_address(RelocIterator *itr, address pc, re // ---------------------------------------------------------------------------------------------------- // Implementation of RelocIterator -void RelocIterator::initialize(nmethod* nm, address begin, address limit) { +void RelocIterator::initialize(CompiledMethod* nm, address begin, address limit) { initialize_misc(); if (nm == NULL && begin != NULL) { // allow nmethod to be deduced from beginning address CodeBlob* cb = CodeCache::find_blob(begin); - nm = cb->as_nmethod_or_null(); + nm = cb->as_compiled_method_or_null(); } assert(nm != NULL, "must be able to deduce nmethod from other arguments"); diff --git a/hotspot/src/share/vm/code/relocInfo.hpp b/hotspot/src/share/vm/code/relocInfo.hpp index 86a454c153f..deaa38c2c1c 100644 --- a/hotspot/src/share/vm/code/relocInfo.hpp +++ b/hotspot/src/share/vm/code/relocInfo.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,8 @@ #include "memory/allocation.hpp" #include "runtime/os.hpp" +class nmethod; +class CompiledMethod; class Metadata; class NativeMovConstReg; @@ -539,7 +541,7 @@ class RelocIterator : public StackObj { address _limit; // stop producing relocations after this _addr relocInfo* _current; // the current relocation information relocInfo* _end; // end marker; we're done iterating when _current == _end - nmethod* _code; // compiled method containing _addr + CompiledMethod* _code; // compiled method containing _addr address _addr; // instruction to which the relocation applies short _databuf; // spare buffer for compressed data short* _data; // pointer to the relocation's data @@ -570,13 +572,13 @@ class RelocIterator : public StackObj { void initialize_misc(); - void initialize(nmethod* nm, address begin, address limit); + void initialize(CompiledMethod* nm, address begin, address limit); RelocIterator() { initialize_misc(); } public: // constructor - RelocIterator(nmethod* nm, address begin = NULL, address limit = NULL); + RelocIterator(CompiledMethod* nm, address begin = NULL, address limit = NULL); RelocIterator(CodeSection* cb, address begin = NULL, address limit = NULL); // get next reloc info, return !eos @@ -611,7 +613,8 @@ class RelocIterator : public StackObj { relocType type() const { return current()->type(); } int format() const { return (relocInfo::have_format) ? current()->format() : 0; } address addr() const { return _addr; } - nmethod* code() const { return _code; } + CompiledMethod* code() const { return _code; } + nmethod* code_as_nmethod() const; short* data() const { return _data; } int datalen() const { return _datalen; } bool has_current() const { return _datalen >= 0; } @@ -810,9 +813,10 @@ class Relocation VALUE_OBJ_CLASS_SPEC { public: // accessors which only make sense for a bound Relocation - address addr() const { return binding()->addr(); } - nmethod* code() const { return binding()->code(); } - bool addr_in_const() const { return binding()->addr_in_const(); } + address addr() const { return binding()->addr(); } + CompiledMethod* code() const { return binding()->code(); } + nmethod* code_as_nmethod() const { return binding()->code_as_nmethod(); } + bool addr_in_const() const { return binding()->addr_in_const(); } protected: short* data() const { return binding()->data(); } int datalen() const { return binding()->datalen(); } @@ -1371,7 +1375,7 @@ inline name##_Relocation* RelocIterator::name##_reloc() { \ APPLY_TO_RELOCATIONS(EACH_CASE); #undef EACH_CASE -inline RelocIterator::RelocIterator(nmethod* nm, address begin, address limit) { +inline RelocIterator::RelocIterator(CompiledMethod* nm, address begin, address limit) { initialize(nm, begin, limit); } diff --git a/hotspot/src/share/vm/code/scopeDesc.cpp b/hotspot/src/share/vm/code/scopeDesc.cpp index 55d4eb9830e..27eb37ad550 100644 --- a/hotspot/src/share/vm/code/scopeDesc.cpp +++ b/hotspot/src/share/vm/code/scopeDesc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,7 +30,7 @@ #include "oops/oop.inline.hpp" #include "runtime/handles.inline.hpp" -ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) { +ScopeDesc::ScopeDesc(const CompiledMethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) { _code = code; _decode_offset = decode_offset; _objects = decode_object_values(obj_decode_offset); @@ -40,7 +40,7 @@ ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offs decode_body(); } -ScopeDesc::ScopeDesc(const nmethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) { +ScopeDesc::ScopeDesc(const CompiledMethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop) { _code = code; _decode_offset = decode_offset; _objects = decode_object_values(DebugInformationRecorder::serialized_null); diff --git a/hotspot/src/share/vm/code/scopeDesc.hpp b/hotspot/src/share/vm/code/scopeDesc.hpp index 57082c08350..d1eaaac7426 100644 --- a/hotspot/src/share/vm/code/scopeDesc.hpp +++ b/hotspot/src/share/vm/code/scopeDesc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ class SimpleScopeDesc : public StackObj { int _bci; public: - SimpleScopeDesc(nmethod* code, address pc) { + SimpleScopeDesc(CompiledMethod* code, address pc) { PcDesc* pc_desc = code->pc_desc_at(pc); assert(pc_desc != NULL, "Must be able to find matching PcDesc"); DebugInfoReadStream buffer(code, pc_desc->scope_decode_offset()); @@ -60,12 +60,12 @@ class SimpleScopeDesc : public StackObj { class ScopeDesc : public ResourceObj { public: // Constructor - ScopeDesc(const nmethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, bool return_oop); + ScopeDesc(const CompiledMethod* code, int decode_offset, int obj_decode_offset, bool reexecute, bool rethrow_exception, bool return_oop); // Calls above, giving default value of "serialized_null" to the // "obj_decode_offset" argument. (We don't use a default argument to // avoid a .hpp-.hpp dependency.) - ScopeDesc(const nmethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop); + ScopeDesc(const CompiledMethod* code, int decode_offset, bool reexecute, bool rethrow_exception, bool return_oop); // JVM state Method* method() const { return _method; } @@ -110,7 +110,7 @@ class ScopeDesc : public ResourceObj { GrowableArray* _objects; // Nmethod information - const nmethod* _code; + const CompiledMethod* _code; // Decoding operations void decode_body(); diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index dc99350fd6f..5b83c4c53ed 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -1075,10 +1075,10 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, if (osr_bci == InvocationEntryBci) { // standard compilation - nmethod* method_code = method->code(); - if (method_code != NULL) { + CompiledMethod* method_code = method->code(); + if (method_code != NULL && method_code->is_nmethod()) { if (compilation_is_complete(method, osr_bci, comp_level)) { - return method_code; + return (nmethod*) method_code; } } if (method->is_not_compilable(comp_level)) { @@ -1184,7 +1184,12 @@ nmethod* CompileBroker::compile_method(const methodHandle& method, int osr_bci, // return requested nmethod // We accept a higher level osr method if (osr_bci == InvocationEntryBci) { - return method->code(); + CompiledMethod* code = method->code(); + if (code == NULL) { + return (nmethod*) code; + } else { + return code->as_nmethod_or_null(); + } } return method->lookup_osr_nmethod_for(osr_bci, comp_level, false); } @@ -1209,7 +1214,7 @@ bool CompileBroker::compilation_is_complete(const methodHandle& method, if (method->is_not_compilable(comp_level)) { return true; } else { - nmethod* result = method->code(); + CompiledMethod* result = method->code(); if (result == NULL) return false; return comp_level == result->comp_level(); } diff --git a/hotspot/src/share/vm/compiler/compileTask.cpp b/hotspot/src/share/vm/compiler/compileTask.cpp index 75dbd83d6a1..c339845a1ad 100644 --- a/hotspot/src/share/vm/compiler/compileTask.cpp +++ b/hotspot/src/share/vm/compiler/compileTask.cpp @@ -135,7 +135,11 @@ AbstractCompiler* CompileTask::compiler() { // nmethod* CompileTask::code() const { if (_code_handle == NULL) return NULL; - return _code_handle->code(); + CodeBlob *blob = _code_handle->code(); + if (blob != NULL) { + return blob->as_nmethod(); + } + return NULL; } void CompileTask::set_code(nmethod* nm) { diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index a4565442247..c988f365cae 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -3776,12 +3776,12 @@ private: const uint _num_workers; // Variables used to claim nmethods. - nmethod* _first_nmethod; - volatile nmethod* _claimed_nmethod; + CompiledMethod* _first_nmethod; + volatile CompiledMethod* _claimed_nmethod; // The list of nmethods that need to be processed by the second pass. - volatile nmethod* _postponed_list; - volatile uint _num_entered_barrier; + volatile CompiledMethod* _postponed_list; + volatile uint _num_entered_barrier; public: G1CodeCacheUnloadingTask(uint num_workers, BoolObjectClosure* is_alive, bool unloading_occurred) : @@ -3793,13 +3793,13 @@ private: _postponed_list(NULL), _num_entered_barrier(0) { - nmethod::increase_unloading_clock(); + CompiledMethod::increase_unloading_clock(); // Get first alive nmethod - NMethodIterator iter = NMethodIterator(); + CompiledMethodIterator iter = CompiledMethodIterator(); if(iter.next_alive()) { _first_nmethod = iter.method(); } - _claimed_nmethod = (volatile nmethod*)_first_nmethod; + _claimed_nmethod = (volatile CompiledMethod*)_first_nmethod; } ~G1CodeCacheUnloadingTask() { @@ -3812,15 +3812,15 @@ private: } private: - void add_to_postponed_list(nmethod* nm) { - nmethod* old; + void add_to_postponed_list(CompiledMethod* nm) { + CompiledMethod* old; do { - old = (nmethod*)_postponed_list; + old = (CompiledMethod*)_postponed_list; nm->set_unloading_next(old); - } while ((nmethod*)Atomic::cmpxchg_ptr(nm, &_postponed_list, old) != old); + } while ((CompiledMethod*)Atomic::cmpxchg_ptr(nm, &_postponed_list, old) != old); } - void clean_nmethod(nmethod* nm) { + void clean_nmethod(CompiledMethod* nm) { bool postponed = nm->do_unloading_parallel(_is_alive, _unloading_occurred); if (postponed) { @@ -3830,24 +3830,24 @@ private: // Mark that this thread has been cleaned/unloaded. // After this call, it will be safe to ask if this nmethod was unloaded or not. - nm->set_unloading_clock(nmethod::global_unloading_clock()); + nm->set_unloading_clock(CompiledMethod::global_unloading_clock()); } - void clean_nmethod_postponed(nmethod* nm) { + void clean_nmethod_postponed(CompiledMethod* nm) { nm->do_unloading_parallel_postponed(_is_alive, _unloading_occurred); } static const int MaxClaimNmethods = 16; - void claim_nmethods(nmethod** claimed_nmethods, int *num_claimed_nmethods) { - nmethod* first; - NMethodIterator last; + void claim_nmethods(CompiledMethod** claimed_nmethods, int *num_claimed_nmethods) { + CompiledMethod* first; + CompiledMethodIterator last; do { *num_claimed_nmethods = 0; - first = (nmethod*)_claimed_nmethod; - last = NMethodIterator(first); + first = (CompiledMethod*)_claimed_nmethod; + last = CompiledMethodIterator(first); if (first != NULL) { @@ -3860,22 +3860,22 @@ private: } } - } while ((nmethod*)Atomic::cmpxchg_ptr(last.method(), &_claimed_nmethod, first) != first); + } while ((CompiledMethod*)Atomic::cmpxchg_ptr(last.method(), &_claimed_nmethod, first) != first); } - nmethod* claim_postponed_nmethod() { - nmethod* claim; - nmethod* next; + CompiledMethod* claim_postponed_nmethod() { + CompiledMethod* claim; + CompiledMethod* next; do { - claim = (nmethod*)_postponed_list; + claim = (CompiledMethod*)_postponed_list; if (claim == NULL) { return NULL; } next = claim->unloading_next(); - } while ((nmethod*)Atomic::cmpxchg_ptr(next, &_postponed_list, claim) != claim); + } while ((CompiledMethod*)Atomic::cmpxchg_ptr(next, &_postponed_list, claim) != claim); return claim; } @@ -3911,7 +3911,7 @@ private: } int num_claimed_nmethods; - nmethod* claimed_nmethods[MaxClaimNmethods]; + CompiledMethod* claimed_nmethods[MaxClaimNmethods]; while (true) { claim_nmethods(claimed_nmethods, &num_claimed_nmethods); @@ -3927,7 +3927,7 @@ private: } void work_second_pass(uint worker_id) { - nmethod* nm; + CompiledMethod* nm; // Take care of postponed nmethods. while ((nm = claim_postponed_nmethod()) != NULL) { clean_nmethod_postponed(nm); diff --git a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp index 6ff1897124a..ba91a3220c5 100644 --- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp +++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp @@ -992,7 +992,7 @@ C2V_VMENTRY(void, reprofile, (JNIEnv*, jobject, jobject jvmci_method)) } NOT_PRODUCT(method->set_compiled_invocation_count(0)); - nmethod* code = method->code(); + CompiledMethod* code = method->code(); if (code != NULL) { code->make_not_entrant(); } diff --git a/hotspot/src/share/vm/jvmci/jvmciEnv.cpp b/hotspot/src/share/vm/jvmci/jvmciEnv.cpp index eb39c2764c3..502b2f7c011 100644 --- a/hotspot/src/share/vm/jvmci/jvmciEnv.cpp +++ b/hotspot/src/share/vm/jvmci/jvmciEnv.cpp @@ -546,7 +546,7 @@ JVMCIEnv::CodeInstallResult JVMCIEnv::register_method( if (entry_bci == InvocationEntryBci) { if (TieredCompilation) { // If there is an old version we're done with it - nmethod* old = method->code(); + CompiledMethod* old = method->code(); if (TraceMethodReplacement && old != NULL) { ResourceMark rm; char *method_name = method->name_and_sig_as_C_string(); diff --git a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp index 76545ebc7b1..1588eb8acad 100644 --- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp +++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp @@ -220,15 +220,15 @@ extern void vm_exit(int code); // been deoptimized. If that is the case we return the deopt blob // unpack_with_exception entry instead. This makes life for the exception blob easier // because making that same check and diverting is painful from assembly language. -JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm)) +JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, CompiledMethod*& cm)) // Reset method handle flag. thread->set_is_method_handle_return(false); Handle exception(thread, ex); - nm = CodeCache::find_nmethod(pc); - assert(nm != NULL, "this is not a compiled method"); + cm = CodeCache::find_compiled(pc); + assert(cm != NULL, "this is not a compiled method"); // Adjust the pc as needed/ - if (nm->is_deopt_pc(pc)) { + if (cm->is_deopt_pc(pc)) { RegisterMap map(thread, false); frame exception_frame = thread->last_frame().sender(&map); // if the frame isn't deopted then pc must not correspond to the caller of last_frame @@ -275,10 +275,10 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions if (guard_pages_enabled) { - address fast_continuation = nm->handler_for_exception_and_pc(exception, pc); + address fast_continuation = cm->handler_for_exception_and_pc(exception, pc); if (fast_continuation != NULL) { // Set flag if return address is a method handle call site. - thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); + thread->set_is_method_handle_return(cm->is_method_handle_return(pc)); return fast_continuation; } } @@ -299,7 +299,7 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t stringStream tempst; tempst.print("compiled method <%s>\n" " at PC" INTPTR_FORMAT " for thread " INTPTR_FORMAT, - nm->method()->print_value_string(), p2i(pc), p2i(thread)); + cm->method()->print_value_string(), p2i(pc), p2i(thread)); Exceptions::log_exception(exception, tempst); } // for AbortVMOnException flag @@ -311,19 +311,19 @@ JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* t // normal bytecode execution. thread->clear_exception_oop_and_pc(); - continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false); + continuation = SharedRuntime::compute_compiled_exc_handler(cm, pc, exception, false, false); // If an exception was thrown during exception dispatch, the exception oop may have changed thread->set_exception_oop(exception()); thread->set_exception_pc(pc); // the exception cache is used only by non-implicit exceptions if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) { - nm->add_handler_for_exception_and_pc(exception, pc, continuation); + cm->add_handler_for_exception_and_pc(exception, pc, continuation); } } // Set flag if return address is a method handle call site. - thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); + thread->set_is_method_handle_return(cm->is_method_handle_return(pc)); if (log_is_enabled(Info, exceptions)) { ResourceMark rm; @@ -345,18 +345,18 @@ address JVMCIRuntime::exception_handler_for_pc(JavaThread* thread) { address pc = thread->exception_pc(); // Still in Java mode DEBUG_ONLY(ResetNoHandleMark rnhm); - nmethod* nm = NULL; + CompiledMethod* cm = NULL; address continuation = NULL; { // Enter VM mode by calling the helper ResetNoHandleMark rnhm; - continuation = exception_handler_for_pc_helper(thread, exception, pc, nm); + continuation = exception_handler_for_pc_helper(thread, exception, pc, cm); } // Back in JAVA, use no oops DON'T safepoint // Now check to see if the compiled method we were called from is now deoptimized. // If so we must return to the deopt blob and deoptimize the nmethod - if (nm != NULL && caller_is_deopted()) { + if (cm != NULL && caller_is_deopted()) { continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); } diff --git a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp index b668737d709..9909d22feec 100644 --- a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp +++ b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp @@ -186,7 +186,7 @@ nonstatic_field(Method, _vtable_index, int) \ nonstatic_field(Method, _intrinsic_id, u2) \ nonstatic_field(Method, _flags, u2) \ - volatile_nonstatic_field(Method, _code, nmethod*) \ + volatile_nonstatic_field(Method, _code, CompiledMethod*) \ volatile_nonstatic_field(Method, _from_compiled_entry, address) \ \ nonstatic_field(MethodCounters, _invocation_counter, InvocationCounter) \ diff --git a/hotspot/src/share/vm/oops/method.cpp b/hotspot/src/share/vm/oops/method.cpp index b3f2b868b64..606f03741ae 100644 --- a/hotspot/src/share/vm/oops/method.cpp +++ b/hotspot/src/share/vm/oops/method.cpp @@ -746,7 +746,7 @@ void Method::set_native_function(address function, bool post_event_flag) { // This function can be called more than once. We must make sure that we always // use the latest registered method -> check if a stub already has been generated. // If so, we have to make it not_entrant. - nmethod* nm = code(); // Put it into local variable to guard against concurrent updates + CompiledMethod* nm = code(); // Put it into local variable to guard against concurrent updates if (nm != NULL) { nm->make_not_entrant(); } @@ -1046,12 +1046,12 @@ address Method::verified_code_entry() { // Not inline to avoid circular ref. bool Method::check_code() const { // cached in a register or local. There's a race on the value of the field. - nmethod *code = (nmethod *)OrderAccess::load_ptr_acquire(&_code); + CompiledMethod *code = (CompiledMethod *)OrderAccess::load_ptr_acquire(&_code); return code == NULL || (code->method() == NULL) || (code->method() == (Method*)this && !code->is_osr_method()); } // Install compiled code. Instantly it can execute. -void Method::set_code(methodHandle mh, nmethod *code) { +void Method::set_code(methodHandle mh, CompiledMethod *code) { assert( code, "use clear_code to remove code" ); assert( mh->check_code(), "" ); diff --git a/hotspot/src/share/vm/oops/method.hpp b/hotspot/src/share/vm/oops/method.hpp index a1acd932cea..3620225eb4c 100644 --- a/hotspot/src/share/vm/oops/method.hpp +++ b/hotspot/src/share/vm/oops/method.hpp @@ -58,6 +58,7 @@ class MethodCounters; class ConstMethod; class InlineTableSizes; class KlassSizeStats; +class CompiledMethod; class Method : public Metadata { friend class VMStructs; @@ -101,7 +102,7 @@ class Method : public Metadata { // field can come and go. It can transition from NULL to not-null at any // time (whenever a compile completes). It can transition from not-null to // NULL only at safepoints (because of a de-opt). - nmethod* volatile _code; // Points to the corresponding piece of native code + CompiledMethod* volatile _code; // Points to the corresponding piece of native code volatile address _from_interpreted_entry; // Cache of _code ? _adapter->i2c_entry() : _i2i_entry // Constructor @@ -431,9 +432,9 @@ class Method : public Metadata { // nmethod/verified compiler entry address verified_code_entry(); bool check_code() const; // Not inline to avoid circular ref - nmethod* volatile code() const { assert( check_code(), "" ); return (nmethod *)OrderAccess::load_ptr_acquire(&_code); } + CompiledMethod* volatile code() const { assert( check_code(), "" ); return (CompiledMethod *)OrderAccess::load_ptr_acquire(&_code); } void clear_code(); // Clear out any compiled code - static void set_code(methodHandle mh, nmethod* code); + static void set_code(methodHandle mh, CompiledMethod* code); void set_adapter_entry(AdapterHandlerEntry* adapter) { constMethod()->set_adapter_entry(adapter); } diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index 25cb6e90a34..ca817b5bbd9 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -565,7 +565,7 @@ uint Compile::scratch_emit_size(const Node* n) { relocInfo* locs_buf = scratch_locs_memory(); address blob_begin = blob->content_begin(); address blob_end = (address)locs_buf; - assert(blob->content_contains(blob_end), "sanity"); + assert(blob->contains(blob_end), "sanity"); CodeBuffer buf(blob_begin, blob_end - blob_begin); buf.initialize_consts_size(_scratch_const_size); buf.initialize_stubs_size(MAX_stubs_size); diff --git a/hotspot/src/share/vm/opto/runtime.cpp b/hotspot/src/share/vm/opto/runtime.cpp index 37e33ef76ba..53db5ec4d0c 100644 --- a/hotspot/src/share/vm/opto/runtime.cpp +++ b/hotspot/src/share/vm/opto/runtime.cpp @@ -1663,9 +1663,9 @@ static void trace_exception(outputStream* st, oop exception_oop, address excepti exception_oop->print_value_on(&tempst); tempst.print(" in "); CodeBlob* blob = CodeCache::find_blob(exception_pc); - if (blob->is_nmethod()) { - nmethod* nm = blob->as_nmethod_or_null(); - nm->method()->print_value_on(&tempst); + if (blob->is_compiled()) { + CompiledMethod* cm = blob->as_compiled_method_or_null(); + cm->method()->print_value_on(&tempst); } else if (blob->is_runtime_stub()) { tempst.print(""); } else { diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index 2d3b2f4c04e..c2cecb3e8fc 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -483,9 +483,9 @@ class VM_WhiteBoxDeoptimizeFrames : public VM_WhiteBoxOperation { RegisterMap* reg_map = fst.register_map(); Deoptimization::deoptimize(t, *f, reg_map); if (_make_not_entrant) { - nmethod* nm = CodeCache::find_nmethod(f->pc()); - assert(nm != NULL, "sanity check"); - nm->make_not_entrant(); + CompiledMethod* cm = CodeCache::find_compiled(f->pc()); + assert(cm != NULL, "sanity check"); + cm->make_not_entrant(); } ++_result; } @@ -533,7 +533,7 @@ WB_ENTRY(jboolean, WB_IsMethodCompiled(JNIEnv* env, jobject o, jobject method, j CHECK_JNI_EXCEPTION_(env, JNI_FALSE); MutexLockerEx mu(Compile_lock); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); - nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); + CompiledMethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); if (code == NULL) { return JNI_FALSE; } @@ -589,7 +589,7 @@ WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject meth jmethodID jmid = reflected_method_to_jmid(thread, env, method); CHECK_JNI_EXCEPTION_(env, CompLevel_none); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); - nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); + CompiledMethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); return (code != NULL ? code->comp_level() : CompLevel_none); WB_END @@ -608,7 +608,7 @@ WB_ENTRY(jint, WB_GetMethodEntryBci(JNIEnv* env, jobject o, jobject method)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); CHECK_JNI_EXCEPTION_(env, InvocationEntryBci); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); - nmethod* code = mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false); + CompiledMethod* code = mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false); return (code != NULL && code->is_osr_method() ? code->osr_entry_bci() : InvocationEntryBci); WB_END @@ -1093,7 +1093,7 @@ WB_ENTRY(jobjectArray, WB_GetNMethod(JNIEnv* env, jobject o, jobject method, jbo jmethodID jmid = reflected_method_to_jmid(thread, env, method); CHECK_JNI_EXCEPTION_(env, NULL); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); - nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); + CompiledMethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); jobjectArray result = NULL; if (code == NULL) { return result; diff --git a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp index ad739cf05d6..17b0c45619e 100644 --- a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp +++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.cpp @@ -496,7 +496,7 @@ void AdvancedThresholdPolicy::submit_compile(const methodHandle& mh, int bci, Co // Handle the invocation event. void AdvancedThresholdPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh, - CompLevel level, nmethod* nm, JavaThread* thread) { + CompLevel level, CompiledMethod* nm, JavaThread* thread) { if (should_create_mdo(mh(), level)) { create_mdo(mh, thread); } @@ -511,7 +511,7 @@ void AdvancedThresholdPolicy::method_invocation_event(const methodHandle& mh, co // Handle the back branch event. Notice that we can compile the method // with a regular entry from here. void AdvancedThresholdPolicy::method_back_branch_event(const methodHandle& mh, const methodHandle& imh, - int bci, CompLevel level, nmethod* nm, JavaThread* thread) { + int bci, CompLevel level, CompiledMethod* nm, JavaThread* thread) { if (should_create_mdo(mh(), level)) { create_mdo(mh, thread); } diff --git a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp index 2ae2ce9e151..0e8494fc020 100644 --- a/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp +++ b/hotspot/src/share/vm/runtime/advancedThresholdPolicy.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -216,9 +216,9 @@ protected: virtual void submit_compile(const methodHandle& mh, int bci, CompLevel level, JavaThread* thread); // event() from SimpleThresholdPolicy would call these. virtual void method_invocation_event(const methodHandle& method, const methodHandle& inlinee, - CompLevel level, nmethod* nm, JavaThread* thread); + CompLevel level, CompiledMethod* nm, JavaThread* thread); virtual void method_back_branch_event(const methodHandle& method, const methodHandle& inlinee, - int bci, CompLevel level, nmethod* nm, JavaThread* thread); + int bci, CompLevel level, CompiledMethod* nm, JavaThread* thread); public: AdvancedThresholdPolicy() : _start_time(0) { } // Select task is called by CompileBroker. We should return a task or NULL. diff --git a/hotspot/src/share/vm/runtime/compilationPolicy.cpp b/hotspot/src/share/vm/runtime/compilationPolicy.cpp index 3538f3d17a1..69a688982ee 100644 --- a/hotspot/src/share/vm/runtime/compilationPolicy.cpp +++ b/hotspot/src/share/vm/runtime/compilationPolicy.cpp @@ -379,7 +379,7 @@ bool NonTieredCompPolicy::is_mature(Method* method) { } nmethod* NonTieredCompPolicy::event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, - int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) { + int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) { assert(comp_level == CompLevel_none, "This should be only called from the interpreter"); NOT_PRODUCT(trace_frequency_counter_overflow(method, branch_bci, bci)); if (JvmtiExport::can_post_interpreter_events() && thread->is_interp_only_mode()) { @@ -484,7 +484,7 @@ void SimpleCompPolicy::method_invocation_event(const methodHandle& m, JavaThread const char* comment = "count"; if (is_compilation_enabled() && can_be_compiled(m, comp_level)) { - nmethod* nm = m->code(); + CompiledMethod* nm = m->code(); if (nm == NULL ) { CompileBroker::compile_method(m, InvocationEntryBci, comp_level, m, hot_count, comment, thread); } @@ -713,7 +713,7 @@ const char* StackWalkCompPolicy::shouldNotInline(const methodHandle& m) { // note: we allow ik->is_abstract() if (!m->method_holder()->is_initialized()) return (_msg = "method holder not initialized"); if (m->is_native()) return (_msg = "native method"); - nmethod* m_code = m->code(); + CompiledMethod* m_code = m->code(); if (m_code != NULL && m_code->code_size() > InlineSmallCode) return (_msg = "already compiled into a big method"); diff --git a/hotspot/src/share/vm/runtime/compilationPolicy.hpp b/hotspot/src/share/vm/runtime/compilationPolicy.hpp index ae2128adb30..5787638909b 100644 --- a/hotspot/src/share/vm/runtime/compilationPolicy.hpp +++ b/hotspot/src/share/vm/runtime/compilationPolicy.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,7 @@ public: virtual int compiler_count(CompLevel comp_level) = 0; // main notification entry, return a pointer to an nmethod if the OSR is required, // returns NULL otherwise. - virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) = 0; + virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) = 0; // safepoint() is called at the end of the safepoint virtual void do_safepoint_work() = 0; // reprofile request @@ -109,7 +109,7 @@ public: virtual bool is_mature(Method* method); virtual void initialize(); virtual CompileTask* select_task(CompileQueue* compile_queue); - virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread); + virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread); virtual void method_invocation_event(const methodHandle& m, JavaThread* thread) = 0; virtual void method_back_branch_event(const methodHandle& m, int bci, JavaThread* thread) = 0; }; diff --git a/hotspot/src/share/vm/runtime/deoptimization.cpp b/hotspot/src/share/vm/runtime/deoptimization.cpp index 9c038d74c48..97d62c3727c 100644 --- a/hotspot/src/share/vm/runtime/deoptimization.cpp +++ b/hotspot/src/share/vm/runtime/deoptimization.cpp @@ -168,9 +168,10 @@ Deoptimization::UnrollBlock* Deoptimization::fetch_unroll_info_helper(JavaThread // Now get the deoptee with a valid map frame deoptee = stub_frame.sender(&map); // Set the deoptee nmethod - assert(thread->deopt_nmethod() == NULL, "Pending deopt!"); - thread->set_deopt_nmethod(deoptee.cb()->as_nmethod_or_null()); - bool skip_internal = thread->deopt_nmethod() != NULL && !thread->deopt_nmethod()->compiler()->is_jvmci(); + assert(thread->deopt_compiled_method() == NULL, "Pending deopt!"); + CompiledMethod* cm = deoptee.cb()->as_compiled_method_or_null(); + thread->set_deopt_compiled_method(cm); + bool skip_internal = (cm != NULL) && !cm->is_compiled_by_jvmci(); if (VerifyStack) { thread->validate_frame_layout(); @@ -548,7 +549,7 @@ void Deoptimization::cleanup_deopt_info(JavaThread *thread, delete thread->deopt_mark(); thread->set_deopt_mark(NULL); - thread->set_deopt_nmethod(NULL); + thread->set_deopt_compiled_method(NULL); if (JvmtiExport::can_pop_frame()) { @@ -1292,14 +1293,14 @@ void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deopt gather_statistics(reason, Action_none, Bytecodes::_illegal); if (LogCompilation && xtty != NULL) { - nmethod* nm = fr.cb()->as_nmethod_or_null(); - assert(nm != NULL, "only compiled methods can deopt"); + CompiledMethod* cm = fr.cb()->as_compiled_method_or_null(); + assert(cm != NULL, "only compiled methods can deopt"); ttyLocker ttyl; xtty->begin_head("deoptimized thread='" UINTX_FORMAT "'", (uintx)thread->osthread()->thread_id()); - nm->log_identity(xtty); + cm->log_identity(xtty); xtty->end_head(); - for (ScopeDesc* sd = nm->scope_desc_at(fr.pc()); ; sd = sd->sender()) { + for (ScopeDesc* sd = cm->scope_desc_at(fr.pc()); ; sd = sd->sender()) { xtty->begin_elem("jvms bci='%d'", sd->bci()); xtty->method(sd->method()); xtty->end_elem(); @@ -1480,7 +1481,7 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint tra vframe* vf = vframe::new_vframe(&fr, ®_map, thread); compiledVFrame* cvf = compiledVFrame::cast(vf); - nmethod* nm = cvf->code(); + CompiledMethod* nm = cvf->code(); ScopeDesc* trap_scope = cvf->scope(); @@ -1499,7 +1500,7 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint tra oop speculation = thread->pending_failed_speculation(); if (nm->is_compiled_by_jvmci()) { if (speculation != NULL) { - oop speculation_log = nm->speculation_log(); + oop speculation_log = nm->as_nmethod()->speculation_log(); if (speculation_log != NULL) { if (TraceDeoptimization || TraceUncollectedSpeculations) { if (HotSpotSpeculationLog::lastFailed(speculation_log) != NULL) { @@ -1615,19 +1616,21 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint tra nm->method()->print_short_name(tty); tty->print(" compiler=%s compile_id=%d", nm->compiler() == NULL ? "" : nm->compiler()->name(), nm->compile_id()); #if INCLUDE_JVMCI - oop installedCode = nm->jvmci_installed_code(); - if (installedCode != NULL) { - oop installedCodeName = NULL; - if (installedCode->is_a(InstalledCode::klass())) { - installedCodeName = InstalledCode::name(installedCode); - } - if (installedCodeName != NULL) { - tty->print(" (JVMCI: installedCodeName=%s) ", java_lang_String::as_utf8_string(installedCodeName)); - } else { - tty->print(" (JVMCI: installed code has no name) "); + if (nm->is_nmethod()) { + oop installedCode = nm->as_nmethod()->jvmci_installed_code(); + if (installedCode != NULL) { + oop installedCodeName = NULL; + if (installedCode->is_a(InstalledCode::klass())) { + installedCodeName = InstalledCode::name(installedCode); + } + if (installedCodeName != NULL) { + tty->print(" (JVMCI: installedCodeName=%s) ", java_lang_String::as_utf8_string(installedCodeName)); + } else { + tty->print(" (JVMCI: installed code has no name) "); + } + } else if (nm->is_compiled_by_jvmci()) { + tty->print(" (JVMCI: no installed code) "); } - } else if (nm->is_compiled_by_jvmci()) { - tty->print(" (JVMCI: no installed code) "); } #endif tty->print(" (@" INTPTR_FORMAT ") thread=" UINTX_FORMAT " reason=%s action=%s unloaded_class_index=%d" JVMCI_ONLY(" debug_id=%d"), @@ -1867,7 +1870,7 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint tra // Assume that in new recompiled code the statistic could be different, // for example, due to different inlining. if ((reason != Reason_rtm_state_change) && (trap_mdo != NULL) && - UseRTMDeopt && (nm->rtm_state() != ProfileRTM)) { + UseRTMDeopt && (nm->as_nmethod()->rtm_state() != ProfileRTM)) { trap_mdo->atomic_set_rtm_state(ProfileRTM); } #endif diff --git a/hotspot/src/share/vm/runtime/fprofiler.cpp b/hotspot/src/share/vm/runtime/fprofiler.cpp index e5785c1f11e..fe19244d385 100644 --- a/hotspot/src/share/vm/runtime/fprofiler.cpp +++ b/hotspot/src/share/vm/runtime/fprofiler.cpp @@ -538,11 +538,12 @@ class adapterNode : public ProfilerNode { class runtimeStubNode : public ProfilerNode { private: - const CodeBlob* _stub; + const RuntimeStub* _stub; const char* _symbol; // The name of the nearest VM symbol when ProfileVM is on. Points to a unique string. public: - runtimeStubNode(const CodeBlob* stub, const char* name, TickPosition where) : ProfilerNode(), _stub(stub), _symbol(name) { + runtimeStubNode(const CodeBlob* stub, const char* name, TickPosition where) : ProfilerNode(), _stub(NULL), _symbol(name) { assert(stub->is_runtime_stub(), "wrong code blob"); + _stub = (RuntimeStub*) stub; update(where); } @@ -550,7 +551,7 @@ class runtimeStubNode : public ProfilerNode { bool runtimeStub_match(const CodeBlob* stub, const char* name) const { assert(stub->is_runtime_stub(), "wrong code blob"); - return ((RuntimeStub*)_stub)->entry_point() == ((RuntimeStub*)stub)->entry_point() && + return _stub->entry_point() == ((RuntimeStub*)stub)->entry_point() && (_symbol == name); } @@ -571,7 +572,7 @@ class runtimeStubNode : public ProfilerNode { } void print_method_on(outputStream* st) { - st->print("%s", ((RuntimeStub*)_stub)->name()); + st->print("%s", _stub->name()); print_symbol_on(st); } @@ -588,18 +589,18 @@ class unknown_compiledNode : public ProfilerNode { public: unknown_compiledNode(const CodeBlob* cb, TickPosition where) : ProfilerNode() { if ( cb->is_buffer_blob() ) - _name = ((BufferBlob*)cb)->name(); + _name = ((const BufferBlob*)cb)->name(); else - _name = ((SingletonBlob*)cb)->name(); + _name = ((const SingletonBlob*)cb)->name(); update(where); } bool is_compiled() const { return true; } bool unknown_compiled_match(const CodeBlob* cb) const { if ( cb->is_buffer_blob() ) - return !strcmp(((BufferBlob*)cb)->name(), _name); + return !strcmp(((const BufferBlob*)cb)->name(), _name); else - return !strcmp(((SingletonBlob*)cb)->name(), _name); + return !strcmp(((const SingletonBlob*)cb)->name(), _name); } Method* method() { return NULL; } @@ -993,16 +994,15 @@ void ThreadProfiler::record_compiled_tick(JavaThread* thread, frame fr, TickPosi CodeBlob* cb = fr.cb(); -// For runtime stubs, record as native rather than as compiled - if (cb->is_runtime_stub()) { - RegisterMap map(thread, false); - fr = fr.sender(&map); - cb = fr.cb(); - localwhere = tp_native; - } - Method* method = (cb->is_nmethod()) ? ((nmethod *)cb)->method() : - (Method*)NULL; + // For runtime stubs, record as native rather than as compiled + if (cb->is_runtime_stub()) { + RegisterMap map(thread, false); + fr = fr.sender(&map); + cb = fr.cb(); + localwhere = tp_native; + } + Method* method = cb->is_compiled() ? cb->as_compiled_method()->method() : (Method*) NULL; if (method == NULL) { if (cb->is_runtime_stub()) runtime_stub_update(cb, name, localwhere); diff --git a/hotspot/src/share/vm/runtime/frame.cpp b/hotspot/src/share/vm/runtime/frame.cpp index 10d817636a4..92b87f5561f 100644 --- a/hotspot/src/share/vm/runtime/frame.cpp +++ b/hotspot/src/share/vm/runtime/frame.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -132,11 +132,11 @@ void RegisterMap::print() const { address frame::raw_pc() const { if (is_deoptimized_frame()) { - nmethod* nm = cb()->as_nmethod_or_null(); - if (nm->is_method_handle_return(pc())) - return nm->deopt_mh_handler_begin() - pc_return_offset; + CompiledMethod* cm = cb()->as_compiled_method_or_null(); + if (cm->is_method_handle_return(pc())) + return cm->deopt_mh_handler_begin() - pc_return_offset; else - return nm->deopt_handler_begin() - pc_return_offset; + return cm->deopt_handler_begin() - pc_return_offset; } else { return (pc() - pc_return_offset); } @@ -183,8 +183,8 @@ bool frame::is_java_frame() const { bool frame::is_compiled_frame() const { if (_cb != NULL && - _cb->is_nmethod() && - ((nmethod*)_cb)->is_java_method()) { + _cb->is_compiled() && + ((CompiledMethod*)_cb)->is_java_method()) { return true; } return false; @@ -228,8 +228,8 @@ JavaCallWrapper* frame::entry_frame_call_wrapper_if_safe(JavaThread* thread) con bool frame::should_be_deoptimized() const { if (_deopt_state == is_deoptimized || !is_compiled_frame() ) return false; - assert(_cb != NULL && _cb->is_nmethod(), "must be an nmethod"); - nmethod* nm = (nmethod *)_cb; + assert(_cb != NULL && _cb->is_compiled(), "must be an nmethod"); + CompiledMethod* nm = (CompiledMethod *)_cb; if (TraceDependencies) { tty->print("checking (%s) ", nm->is_marked_for_deoptimization() ? "true" : "false"); nm->print_value_on(tty); @@ -246,7 +246,7 @@ bool frame::should_be_deoptimized() const { bool frame::can_be_deoptimized() const { if (!is_compiled_frame()) return false; - nmethod* nm = (nmethod*)_cb; + CompiledMethod* nm = (CompiledMethod*)_cb; if( !nm->can_be_deoptimized() ) return false; @@ -256,8 +256,7 @@ bool frame::can_be_deoptimized() const { void frame::deoptimize(JavaThread* thread) { // Schedule deoptimization of an nmethod activation with this frame. - assert(_cb != NULL && _cb->is_nmethod(), "must be"); - nmethod* nm = (nmethod*)_cb; + assert(_cb != NULL && _cb->is_compiled(), "must be"); // This is a fix for register window patching race if (NeedsDeoptSuspend && Thread::current() != thread) { @@ -316,12 +315,13 @@ void frame::deoptimize(JavaThread* thread) { // If the call site is a MethodHandle call site use the MH deopt // handler. - address deopt = nm->is_method_handle_return(pc()) ? - nm->deopt_mh_handler_begin() : - nm->deopt_handler_begin(); + CompiledMethod* cm = (CompiledMethod*) _cb; + address deopt = cm->is_method_handle_return(pc()) ? + cm->deopt_mh_handler_begin() : + cm->deopt_handler_begin(); // Save the original pc before we patch in the new one - nm->set_original_pc(this, pc()); + cm->set_original_pc(this, pc()); patch_pc(thread, deopt); #ifdef ASSERT @@ -661,13 +661,16 @@ void frame::print_on_error(outputStream* st, char* buf, int buflen, bool verbose } } else if (_cb->is_buffer_blob()) { st->print("v ~BufferBlob::%s", ((BufferBlob *)_cb)->name()); - } else if (_cb->is_nmethod()) { - nmethod* nm = (nmethod*)_cb; - Method* m = nm->method(); + } else if (_cb->is_compiled()) { + CompiledMethod* cm = (CompiledMethod*)_cb; + Method* m = cm->method(); if (m != NULL) { - st->print("J %d%s", nm->compile_id(), (nm->is_osr_method() ? "%" : "")); - if (nm->compiler() != NULL) { - st->print(" %s", nm->compiler()->name()); + if (cm->is_nmethod()) { + nmethod* nm = cm->as_nmethod(); + st->print("J %d%s", nm->compile_id(), (nm->is_osr_method() ? "%" : "")); + if (nm->compiler() != NULL) { + st->print(" %s", nm->compiler()->name()); + } } m->name_and_sig_as_C_string(buf, buflen); st->print(" %s", buf); @@ -681,9 +684,12 @@ void frame::print_on_error(outputStream* st, char* buf, int buflen, bool verbose st->print(" (%d bytes) @ " PTR_FORMAT " [" PTR_FORMAT "+" INTPTR_FORMAT "]", m->code_size(), p2i(_pc), p2i(_cb->code_begin()), _pc - _cb->code_begin()); #if INCLUDE_JVMCI - char* jvmciName = nm->jvmci_installed_code_name(buf, buflen); - if (jvmciName != NULL) { - st->print(" (%s)", jvmciName); + if (cm->is_nmethod()) { + nmethod* nm = cm->as_nmethod(); + char* jvmciName = nm->jvmci_installed_code_name(buf, buflen); + if (jvmciName != NULL) { + st->print(" (%s)", jvmciName); + } } #endif } else { @@ -1244,10 +1250,10 @@ void frame::describe(FrameValues& values, int frame_no) { values.describe(-1, info_address, err_msg("#%d entry frame", frame_no), 2); } else if (is_compiled_frame()) { // For now just label the frame - nmethod* nm = cb()->as_nmethod_or_null(); + CompiledMethod* cm = (CompiledMethod*)cb(); values.describe(-1, info_address, FormatBuffer<1024>("#%d nmethod " INTPTR_FORMAT " for method %s%s", frame_no, - p2i(nm), nm->method()->name_and_sig_as_C_string(), + p2i(cm), cm->method()->name_and_sig_as_C_string(), (_deopt_state == is_deoptimized) ? " (deoptimized)" : ((_deopt_state == unknown) ? " (state unknown)" : "")), diff --git a/hotspot/src/share/vm/runtime/rframe.cpp b/hotspot/src/share/vm/runtime/rframe.cpp index dea7ef78696..40283896d85 100644 --- a/hotspot/src/share/vm/runtime/rframe.cpp +++ b/hotspot/src/share/vm/runtime/rframe.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -127,7 +127,7 @@ int InterpretedRFrame::cost() const { } int CompiledRFrame::cost() const { - nmethod* nm = top_method()->code(); + CompiledMethod* nm = top_method()->code(); if (nm != NULL) { return nm->insts_size(); } else { @@ -139,7 +139,7 @@ void CompiledRFrame::init() { RegisterMap map(thread(), false); vframe* vf = vframe::new_vframe(&_fr, &map, thread()); assert(vf->is_compiled_frame(), "must be compiled"); - _nm = compiledVFrame::cast(vf)->code(); + _nm = compiledVFrame::cast(vf)->code()->as_nmethod(); vf = vf->top(); _vf = javaVFrame::cast(vf); _method = CodeCache::find_nmethod(_fr.pc())->method(); diff --git a/hotspot/src/share/vm/runtime/safepoint.cpp b/hotspot/src/share/vm/runtime/safepoint.cpp index ceb934ac46d..96fb3962565 100644 --- a/hotspot/src/share/vm/runtime/safepoint.cpp +++ b/hotspot/src/share/vm/runtime/safepoint.cpp @@ -1010,8 +1010,8 @@ void ThreadSafepointState::handle_polling_page_exception() { address real_return_addr = thread()->saved_exception_pc(); CodeBlob *cb = CodeCache::find_blob(real_return_addr); - assert(cb != NULL && cb->is_nmethod(), "return address should be in nmethod"); - nmethod* nm = (nmethod*)cb; + assert(cb != NULL && cb->is_compiled(), "return address should be in nmethod"); + CompiledMethod* nm = (CompiledMethod*)cb; // Find frame of caller frame stub_fr = thread()->last_frame(); diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index d38d493f198..0824a8a56df 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -540,10 +540,10 @@ address SharedRuntime::get_poll_stub(address pc) { CodeBlob *cb = CodeCache::find_blob(pc); // Should be an nmethod - assert(cb && cb->is_nmethod(), "safepoint polling: pc must refer to an nmethod"); + assert(cb && cb->is_compiled(), "safepoint polling: pc must refer to an nmethod"); // Look up the relocation information - assert(((nmethod*)cb)->is_at_poll_or_poll_return(pc), + assert(((CompiledMethod*)cb)->is_at_poll_or_poll_return(pc), "safepoint polling: type must be poll"); #ifdef ASSERT @@ -554,8 +554,8 @@ address SharedRuntime::get_poll_stub(address pc) { } #endif - bool at_poll_return = ((nmethod*)cb)->is_at_poll_return(pc); - bool has_wide_vectors = ((nmethod*)cb)->has_wide_vectors(); + bool at_poll_return = ((CompiledMethod*)cb)->is_at_poll_return(pc); + bool has_wide_vectors = ((CompiledMethod*)cb)->has_wide_vectors(); if (at_poll_return) { assert(SharedRuntime::polling_page_return_handler_blob() != NULL, "polling page return stub not created yet"); @@ -630,22 +630,22 @@ JRT_END // ret_pc points into caller; we are returning caller's exception handler // for given exception -address SharedRuntime::compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception, +address SharedRuntime::compute_compiled_exc_handler(CompiledMethod* cm, address ret_pc, Handle& exception, bool force_unwind, bool top_frame_only) { - assert(nm != NULL, "must exist"); + assert(cm != NULL, "must exist"); ResourceMark rm; #if INCLUDE_JVMCI - if (nm->is_compiled_by_jvmci()) { + if (cm->is_compiled_by_jvmci()) { // lookup exception handler for this pc - int catch_pco = ret_pc - nm->code_begin(); - ExceptionHandlerTable table(nm); + int catch_pco = ret_pc - cm->code_begin(); + ExceptionHandlerTable table(cm); HandlerTableEntry *t = table.entry_for(catch_pco, -1, 0); if (t != NULL) { - return nm->code_begin() + t->pco(); + return cm->code_begin() + t->pco(); } else { // there is no exception handler for this pc => deoptimize - nm->make_not_entrant(); + cm->make_not_entrant(); // Use Deoptimization::deoptimize for all of its side-effects: // revoking biases of monitors, gathering traps statistics, logging... @@ -662,6 +662,7 @@ address SharedRuntime::compute_compiled_exc_handler(nmethod* nm, address ret_pc, } #endif // INCLUDE_JVMCI + nmethod* nm = cm->as_nmethod(); ScopeDesc* sd = nm->scope_desc_at(ret_pc); // determine handler bci, if any EXCEPTION_MARK; @@ -797,7 +798,7 @@ void SharedRuntime::throw_StackOverflowError_common(JavaThread* thread, bool del } #if INCLUDE_JVMCI -address SharedRuntime::deoptimize_for_implicit_exception(JavaThread* thread, address pc, nmethod* nm, int deopt_reason) { +address SharedRuntime::deoptimize_for_implicit_exception(JavaThread* thread, address pc, CompiledMethod* nm, int deopt_reason) { assert(deopt_reason > Deoptimization::Reason_none && deopt_reason < Deoptimization::Reason_LIMIT, "invalid deopt reason"); thread->set_jvmci_implicit_exception_pc(pc); thread->set_pending_deoptimization(Deoptimization::make_trap_request((Deoptimization::DeoptReason)deopt_reason, Deoptimization::Action_reinterpret)); @@ -871,7 +872,7 @@ address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread, // 2. Inline-cache check in nmethod, or // 3. Implicit null exception in nmethod - if (!cb->is_nmethod()) { + if (!cb->is_compiled()) { bool is_in_blob = cb->is_adapter_blob() || cb->is_method_handles_adapter_blob(); if (!is_in_blob) { // Allow normal crash reporting to handle this @@ -882,9 +883,9 @@ address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread, return StubRoutines::throw_NullPointerException_at_call_entry(); } - // Otherwise, it's an nmethod. Consult its exception handlers. - nmethod* nm = (nmethod*)cb; - if (nm->inlinecache_check_contains(pc)) { + // Otherwise, it's a compiled method. Consult its exception handlers. + CompiledMethod* cm = (CompiledMethod*)cb; + if (cm->inlinecache_check_contains(pc)) { // exception happened inside inline-cache check code // => the nmethod is not yet active (i.e., the frame // is not set up yet) => use return address pushed by @@ -893,7 +894,7 @@ address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread, return StubRoutines::throw_NullPointerException_at_call_entry(); } - if (nm->method()->is_method_handle_intrinsic()) { + if (cm->method()->is_method_handle_intrinsic()) { // exception happened inside MH dispatch code, similar to a vtable stub Events::log_exception(thread, "NullPointerException in MH adapter " INTPTR_FORMAT, p2i(pc)); return StubRoutines::throw_NullPointerException_at_call_entry(); @@ -903,15 +904,15 @@ address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread, _implicit_null_throws++; #endif #if INCLUDE_JVMCI - if (nm->is_compiled_by_jvmci() && nm->pc_desc_at(pc) != NULL) { + if (cm->is_compiled_by_jvmci() && cm->pc_desc_at(pc) != NULL) { // If there's no PcDesc then we'll die way down inside of // deopt instead of just getting normal error reporting, // so only go there if it will succeed. - return deoptimize_for_implicit_exception(thread, pc, nm, Deoptimization::Reason_null_check); + return deoptimize_for_implicit_exception(thread, pc, cm, Deoptimization::Reason_null_check); } else { #endif // INCLUDE_JVMCI - assert (nm->is_nmethod(), "Expect nmethod"); - target_pc = nm->continuation_for_implicit_exception(pc); + assert (cm->is_nmethod(), "Expect nmethod"); + target_pc = ((nmethod*)cm)->continuation_for_implicit_exception(pc); #if INCLUDE_JVMCI } #endif // INCLUDE_JVMCI @@ -925,17 +926,17 @@ address SharedRuntime::continuation_for_implicit_exception(JavaThread* thread, case IMPLICIT_DIVIDE_BY_ZERO: { - nmethod* nm = CodeCache::find_nmethod(pc); - guarantee(nm != NULL, "must have containing compiled method for implicit division-by-zero exceptions"); + CompiledMethod* cm = CodeCache::find_compiled(pc); + guarantee(cm != NULL, "must have containing compiled method for implicit division-by-zero exceptions"); #ifndef PRODUCT _implicit_div0_throws++; #endif #if INCLUDE_JVMCI - if (nm->is_compiled_by_jvmci() && nm->pc_desc_at(pc) != NULL) { - return deoptimize_for_implicit_exception(thread, pc, nm, Deoptimization::Reason_div0_check); + if (cm->is_compiled_by_jvmci() && cm->pc_desc_at(pc) != NULL) { + return deoptimize_for_implicit_exception(thread, pc, cm, Deoptimization::Reason_div0_check); } else { #endif // INCLUDE_JVMCI - target_pc = nm->continuation_for_implicit_exception(pc); + target_pc = cm->continuation_for_implicit_exception(pc); #if INCLUDE_JVMCI } #endif // INCLUDE_JVMCI @@ -1084,14 +1085,14 @@ Handle SharedRuntime::find_callee_info(JavaThread* thread, Bytecodes::Code& bc, } methodHandle SharedRuntime::extract_attached_method(vframeStream& vfst) { - nmethod* caller_nm = vfst.nm(); + CompiledMethod* caller = vfst.nm(); - nmethodLocker caller_lock(caller_nm); + nmethodLocker caller_lock(caller); address pc = vfst.frame_pc(); { // Get call instruction under lock because another thread may be busy patching it. MutexLockerEx ml_patch(Patching_lock, Mutex::_no_safepoint_check_flag); - return caller_nm->attached_method_before_pc(pc); + return caller->attached_method_before_pc(pc); } return NULL; } @@ -1283,8 +1284,8 @@ methodHandle SharedRuntime::resolve_sub_helper(JavaThread *thread, frame caller_frame = thread->last_frame().sender(&cbl_map); CodeBlob* caller_cb = caller_frame.cb(); - guarantee(caller_cb != NULL && caller_cb->is_nmethod(), "must be called from nmethod"); - nmethod* caller_nm = caller_cb->as_nmethod_or_null(); + guarantee(caller_cb != NULL && caller_cb->is_compiled(), "must be called from compiled method"); + CompiledMethod* caller_nm = caller_cb->as_compiled_method_or_null(); // make sure caller is not getting deoptimized // and removed before we are done with it. @@ -1347,14 +1348,19 @@ methodHandle SharedRuntime::resolve_sub_helper(JavaThread *thread, // Make sure the callee nmethod does not get deoptimized and removed before // we are done patching the code. - nmethod* callee_nm = callee_method->code(); - if (callee_nm != NULL && !callee_nm->is_in_use()) { + CompiledMethod* callee = callee_method->code(); + + if (callee != NULL) { + assert(callee->is_compiled(), "must be nmethod for patching"); + } + + if (callee != NULL && !callee->is_in_use()) { // Patch call site to C2I adapter if callee nmethod is deoptimized or unloaded. - callee_nm = NULL; + callee = NULL; } - nmethodLocker nl_callee(callee_nm); + nmethodLocker nl_callee(callee); #ifdef ASSERT - address dest_entry_point = callee_nm == NULL ? 0 : callee_nm->entry_point(); // used below + address dest_entry_point = callee == NULL ? 0 : callee->entry_point(); // used below #endif if (is_virtual) { @@ -1382,12 +1388,12 @@ methodHandle SharedRuntime::resolve_sub_helper(JavaThread *thread, // which may happen when multiply alive nmethod (tiered compilation) // will be supported. if (!callee_method->is_old() && - (callee_nm == NULL || callee_nm->is_in_use() && (callee_method->code() == callee_nm))) { + (callee == NULL || callee->is_in_use() && (callee_method->code() == callee))) { #ifdef ASSERT // We must not try to patch to jump to an already unloaded method. if (dest_entry_point != 0) { CodeBlob* cb = CodeCache::find_blob(dest_entry_point); - assert((cb != NULL) && cb->is_nmethod() && (((nmethod*)cb) == callee_nm), + assert((cb != NULL) && cb->is_compiled() && (((CompiledMethod*)cb) == callee), "should not call unloaded nmethod"); } #endif @@ -1582,8 +1588,9 @@ methodHandle SharedRuntime::handle_ic_miss_helper(JavaThread *thread, TRAPS) { RegisterMap reg_map(thread, false); frame caller_frame = thread->last_frame().sender(®_map); CodeBlob* cb = caller_frame.cb(); - if (cb->is_nmethod()) { - CompiledIC* inline_cache = CompiledIC_before(((nmethod*)cb), caller_frame.pc()); + CompiledMethod* caller_nm = cb->as_compiled_method_or_null(); + if (cb->is_compiled()) { + CompiledIC* inline_cache = CompiledIC_before(((CompiledMethod*)cb), caller_frame.pc()); bool should_be_mono = false; if (inline_cache->is_optimized()) { if (TraceCallFixup) { @@ -1667,7 +1674,7 @@ methodHandle SharedRuntime::reresolve_call_site(JavaThread *thread, TRAPS) { // Check for static or virtual call bool is_static_call = false; - nmethod* caller_nm = CodeCache::find_nmethod(pc); + CompiledMethod* caller_nm = CodeCache::find_compiled(pc); // Default call_addr is the location of the "basic" call. // Determine the address of the call we a reresolving. With @@ -1802,12 +1809,12 @@ IRT_LEAF(void, SharedRuntime::fixup_callers_callsite(Method* method, address cal // ask me how I know this... CodeBlob* cb = CodeCache::find_blob(caller_pc); - if (!cb->is_nmethod() || entry_point == moop->get_c2i_entry()) { + if (!cb->is_compiled() || entry_point == moop->get_c2i_entry()) { return; } // The check above makes sure this is a nmethod. - nmethod* nm = cb->as_nmethod_or_null(); + CompiledMethod* nm = cb->as_compiled_method_or_null(); assert(nm, "must be"); // Get the return PC for the passed caller PC. diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.hpp b/hotspot/src/share/vm/runtime/sharedRuntime.hpp index 68baebc4686..52bca29cf72 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp @@ -188,7 +188,7 @@ class SharedRuntime: AllStatic { #endif // INCLUDE_ALL_GCS // exception handling and implicit exceptions - static address compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception, + static address compute_compiled_exc_handler(CompiledMethod* nm, address ret_pc, Handle& exception, bool force_unwind, bool top_frame_only); enum ImplicitExceptionKind { IMPLICIT_NULL, @@ -207,7 +207,7 @@ class SharedRuntime: AllStatic { address faulting_pc, ImplicitExceptionKind exception_kind); #if INCLUDE_JVMCI - static address deoptimize_for_implicit_exception(JavaThread* thread, address pc, nmethod* nm, int deopt_reason); + static address deoptimize_for_implicit_exception(JavaThread* thread, address pc, CompiledMethod* nm, int deopt_reason); #endif static void enable_stack_reserved_zone(JavaThread* thread); diff --git a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp index 2a0138871fc..595cfa4ea75 100644 --- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp +++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -192,7 +192,7 @@ void SimpleThresholdPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) { } nmethod* SimpleThresholdPolicy::event(const methodHandle& method, const methodHandle& inlinee, - int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread) { + int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread) { if (comp_level == CompLevel_none && JvmtiExport::can_post_interpreter_events() && thread->is_interp_only_mode()) { @@ -392,7 +392,7 @@ CompLevel SimpleThresholdPolicy::loop_event(Method* method, CompLevel cur_level) // Handle the invocation event. void SimpleThresholdPolicy::method_invocation_event(const methodHandle& mh, const methodHandle& imh, - CompLevel level, nmethod* nm, JavaThread* thread) { + CompLevel level, CompiledMethod* nm, JavaThread* thread) { if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) { CompLevel next_level = call_event(mh(), level); if (next_level != level) { @@ -404,7 +404,7 @@ void SimpleThresholdPolicy::method_invocation_event(const methodHandle& mh, cons // Handle the back branch event. Notice that we can compile the method // with a regular entry from here. void SimpleThresholdPolicy::method_back_branch_event(const methodHandle& mh, const methodHandle& imh, - int bci, CompLevel level, nmethod* nm, JavaThread* thread) { + int bci, CompLevel level, CompiledMethod* nm, JavaThread* thread) { // If the method is already compiling, quickly bail out. if (is_compilation_enabled() && !CompileBroker::compilation_is_in_queue(mh)) { // Use loop event as an opportunity to also check there's been diff --git a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp index 02a13cadc3c..d2dd9cc971c 100644 --- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp +++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,16 +81,16 @@ protected: // Get a compilation level for a given method. static CompLevel comp_level(Method* method) { - nmethod *nm = method->code(); + CompiledMethod *nm = method->code(); if (nm != NULL && nm->is_in_use()) { return (CompLevel)nm->comp_level(); } return CompLevel_none; } virtual void method_invocation_event(const methodHandle& method, const methodHandle& inlinee, - CompLevel level, nmethod* nm, JavaThread* thread); + CompLevel level, CompiledMethod* nm, JavaThread* thread); virtual void method_back_branch_event(const methodHandle& method, const methodHandle& inlinee, - int bci, CompLevel level, nmethod* nm, JavaThread* thread); + int bci, CompLevel level, CompiledMethod* nm, JavaThread* thread); public: SimpleThresholdPolicy() : _c1_count(0), _c2_count(0) { } virtual int compiler_count(CompLevel comp_level) { @@ -104,7 +104,7 @@ public: virtual void disable_compilation(Method* method) { } virtual void reprofile(ScopeDesc* trap_scope, bool is_osr); virtual nmethod* event(const methodHandle& method, const methodHandle& inlinee, - int branch_bci, int bci, CompLevel comp_level, nmethod* nm, JavaThread* thread); + int branch_bci, int bci, CompLevel comp_level, CompiledMethod* nm, JavaThread* thread); // Select task is called by CompileBroker. We should return a task or NULL. virtual CompileTask* select_task(CompileQueue* compile_queue); // Tell the runtime if we think a given method is adequately profiled. diff --git a/hotspot/src/share/vm/runtime/stubRoutines.hpp b/hotspot/src/share/vm/runtime/stubRoutines.hpp index 6699b13c134..49f3550c273 100644 --- a/hotspot/src/share/vm/runtime/stubRoutines.hpp +++ b/hotspot/src/share/vm/runtime/stubRoutines.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -254,8 +254,8 @@ class StubRoutines: AllStatic { (_code2 != NULL && _code2->blob_contains(addr)) ; } - static CodeBlob* code1() { return _code1; } - static CodeBlob* code2() { return _code2; } + static RuntimeBlob* code1() { return _code1; } + static RuntimeBlob* code2() { return _code2; } // Debugging static jint verify_oop_count() { return _verify_oop_count; } diff --git a/hotspot/src/share/vm/runtime/sweeper.cpp b/hotspot/src/share/vm/runtime/sweeper.cpp index 3bd5a0f1d29..16cf5cde781 100644 --- a/hotspot/src/share/vm/runtime/sweeper.cpp +++ b/hotspot/src/share/vm/runtime/sweeper.cpp @@ -109,13 +109,13 @@ void NMethodSweeper::report_events() { } } -void NMethodSweeper::record_sweep(nmethod* nm, int line) { +void NMethodSweeper::record_sweep(CompiledMethod* nm, int line) { if (_records != NULL) { _records[_sweep_index].traversal = _traversals; - _records[_sweep_index].traversal_mark = nm->_stack_traversal_mark; + _records[_sweep_index].traversal_mark = nm->is_nmethod() ? ((nmethod*)nm)->_stack_traversal_mark : 0; _records[_sweep_index].compile_id = nm->compile_id(); _records[_sweep_index].kind = nm->compile_kind(); - _records[_sweep_index].state = nm->_state; + _records[_sweep_index].state = nm->get_state(); _records[_sweep_index].vep = nm->verified_entry_point(); _records[_sweep_index].uep = nm->entry_point(); _records[_sweep_index].line = line; @@ -134,7 +134,7 @@ void NMethodSweeper::init_sweeper_log() { #define SWEEP(nm) #endif -NMethodIterator NMethodSweeper::_current; // Current nmethod +CompiledMethodIterator NMethodSweeper::_current; // Current compiled method long NMethodSweeper::_traversals = 0; // Stack scan count, also sweep ID. long NMethodSweeper::_total_nof_code_cache_sweeps = 0; // Total number of full sweeps of the code cache long NMethodSweeper::_time_counter = 0; // Virtual time used to periodically invoke sweeper @@ -210,10 +210,17 @@ void NMethodSweeper::mark_active_nmethods() { _time_counter++; // Check for restart - assert(CodeCache::find_blob_unsafe(_current.method()) == _current.method(), "Sweeper nmethod cached state invalid"); + if (_current.method() != NULL) { + if (_current.method()->is_nmethod()) { + assert(CodeCache::find_blob_unsafe(_current.method()) == _current.method(), "Sweeper nmethod cached state invalid"); + } else { + ShouldNotReachHere(); + } + } + if (wait_for_stack_scanning()) { _seen = 0; - _current = NMethodIterator(); + _current = CompiledMethodIterator(); // Initialize to first nmethod _current.next(); _traversals += 1; @@ -415,14 +422,15 @@ void NMethodSweeper::sweep_code_cache() { // Since we will give up the CodeCache_lock, always skip ahead // to the next nmethod. Other blobs can be deleted by other // threads but nmethods are only reclaimed by the sweeper. - nmethod* nm = _current.method(); + CompiledMethod* nm = _current.method(); _current.next(); // Now ready to process nmethod and give up CodeCache_lock { MutexUnlockerEx mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); // Save information before potentially flushing the nmethod - int size = nm->total_size(); + // Only flushing nmethods so size only matters for them. + int size = nm->is_nmethod() ? ((nmethod*)nm)->total_size() : 0; bool is_c2_method = nm->is_compiled_by_c2(); bool is_osr = nm->is_osr_method(); int compile_id = nm->compile_id(); @@ -430,7 +438,7 @@ void NMethodSweeper::sweep_code_cache() { const char* state_before = nm->state(); const char* state_after = ""; - MethodStateChange type = process_nmethod(nm); + MethodStateChange type = process_compiled_method(nm); switch (type) { case Flushed: state_after = "flushed"; @@ -532,28 +540,28 @@ void NMethodSweeper::possibly_enable_sweeper() { } } -class NMethodMarker: public StackObj { +class CompiledMethodMarker: public StackObj { private: CodeCacheSweeperThread* _thread; public: - NMethodMarker(nmethod* nm) { + CompiledMethodMarker(CompiledMethod* cm) { JavaThread* current = JavaThread::current(); assert (current->is_Code_cache_sweeper_thread(), "Must be"); _thread = (CodeCacheSweeperThread*)current; - if (!nm->is_zombie() && !nm->is_unloaded()) { + if (!cm->is_zombie() && !cm->is_unloaded()) { // Only expose live nmethods for scanning - _thread->set_scanned_nmethod(nm); + _thread->set_scanned_compiled_method(cm); } } - ~NMethodMarker() { - _thread->set_scanned_nmethod(NULL); + ~CompiledMethodMarker() { + _thread->set_scanned_compiled_method(NULL); } }; -void NMethodSweeper::release_nmethod(nmethod* nm) { +void NMethodSweeper::release_compiled_method(CompiledMethod* nm) { // Make sure the released nmethod is no longer referenced by the sweeper thread CodeCacheSweeperThread* thread = (CodeCacheSweeperThread*)JavaThread::current(); - thread->set_scanned_nmethod(NULL); + thread->set_scanned_compiled_method(NULL); // Clean up any CompiledICHolders { @@ -571,98 +579,100 @@ void NMethodSweeper::release_nmethod(nmethod* nm) { nm->flush(); } -NMethodSweeper::MethodStateChange NMethodSweeper::process_nmethod(nmethod* nm) { - assert(nm != NULL, "sanity"); +NMethodSweeper::MethodStateChange NMethodSweeper::process_compiled_method(CompiledMethod* cm) { + assert(cm != NULL, "sanity"); assert(!CodeCache_lock->owned_by_self(), "just checking"); MethodStateChange result = None; // Make sure this nmethod doesn't get unloaded during the scan, // since safepoints may happen during acquired below locks. - NMethodMarker nmm(nm); - SWEEP(nm); + CompiledMethodMarker nmm(cm); + SWEEP(cm); // Skip methods that are currently referenced by the VM - if (nm->is_locked_by_vm()) { + if (cm->is_locked_by_vm()) { // But still remember to clean-up inline caches for alive nmethods - if (nm->is_alive()) { + if (cm->is_alive()) { // Clean inline caches that point to zombie/non-entrant/unloaded nmethods MutexLocker cl(CompiledIC_lock); - nm->cleanup_inline_caches(); - SWEEP(nm); + cm->cleanup_inline_caches(); + SWEEP(cm); } return result; } - if (nm->is_zombie()) { + if (cm->is_zombie()) { // All inline caches that referred to this nmethod were cleaned in the // previous sweeper cycle. Now flush the nmethod from the code cache. - assert(!nm->is_locked_by_vm(), "must not flush locked nmethods"); - release_nmethod(nm); + assert(!cm->is_locked_by_vm(), "must not flush locked Compiled Methods"); + release_compiled_method(cm); assert(result == None, "sanity"); result = Flushed; - } else if (nm->is_not_entrant()) { + } else if (cm->is_not_entrant()) { // If there are no current activations of this method on the // stack we can safely convert it to a zombie method - if (nm->can_convert_to_zombie()) { + if (cm->can_convert_to_zombie()) { // Clear ICStubs to prevent back patching stubs of zombie or flushed // nmethods during the next safepoint (see ICStub::finalize). { MutexLocker cl(CompiledIC_lock); - nm->clear_ic_stubs(); + cm->clear_ic_stubs(); } // Code cache state change is tracked in make_zombie() - nm->make_zombie(); - SWEEP(nm); + cm->make_zombie(); + SWEEP(cm); // The nmethod may have been locked by JVMTI after being made zombie (see // JvmtiDeferredEvent::compiled_method_unload_event()). If so, we cannot // flush the osr nmethod directly but have to wait for a later sweeper cycle. - if (nm->is_osr_method() && !nm->is_locked_by_vm()) { + if (cm->is_osr_method() && !cm->is_locked_by_vm()) { // No inline caches will ever point to osr methods, so we can just remove it. // Make sure that we unregistered the nmethod with the heap and flushed all // dependencies before removing the nmethod (done in make_zombie()). - assert(nm->is_zombie(), "nmethod must be unregistered"); - release_nmethod(nm); + assert(cm->is_zombie(), "nmethod must be unregistered"); + release_compiled_method(cm); assert(result == None, "sanity"); result = Flushed; } else { assert(result == None, "sanity"); result = MadeZombie; - assert(nm->is_zombie(), "nmethod must be zombie"); + assert(cm->is_zombie(), "nmethod must be zombie"); } } else { // Still alive, clean up its inline caches MutexLocker cl(CompiledIC_lock); - nm->cleanup_inline_caches(); - SWEEP(nm); + cm->cleanup_inline_caches(); + SWEEP(cm); } - } else if (nm->is_unloaded()) { + } else if (cm->is_unloaded()) { // Code is unloaded, so there are no activations on the stack. // Convert the nmethod to zombie or flush it directly in the OSR case. { // Clean ICs of unloaded nmethods as well because they may reference other // unloaded nmethods that may be flushed earlier in the sweeper cycle. MutexLocker cl(CompiledIC_lock); - nm->cleanup_inline_caches(); + cm->cleanup_inline_caches(); } - if (nm->is_osr_method()) { - SWEEP(nm); + if (cm->is_osr_method()) { + SWEEP(cm); // No inline caches will ever point to osr methods, so we can just remove it - release_nmethod(nm); + release_compiled_method(cm); assert(result == None, "sanity"); result = Flushed; } else { // Code cache state change is tracked in make_zombie() - nm->make_zombie(); - SWEEP(nm); + cm->make_zombie(); + SWEEP(cm); assert(result == None, "sanity"); result = MadeZombie; } } else { - possibly_flush(nm); + if (cm->is_nmethod()) { + possibly_flush((nmethod*)cm); + } // Clean inline caches that point to zombie/non-entrant/unloaded nmethods MutexLocker cl(CompiledIC_lock); - nm->cleanup_inline_caches(); - SWEEP(nm); + cm->cleanup_inline_caches(); + SWEEP(cm); } return result; } diff --git a/hotspot/src/share/vm/runtime/sweeper.hpp b/hotspot/src/share/vm/runtime/sweeper.hpp index eb29e7de660..800e3811544 100644 --- a/hotspot/src/share/vm/runtime/sweeper.hpp +++ b/hotspot/src/share/vm/runtime/sweeper.hpp @@ -66,7 +66,7 @@ class NMethodSweeper : public AllStatic { static long _total_nof_code_cache_sweeps; // Total number of full sweeps of the code cache static long _time_counter; // Virtual time used to periodically invoke sweeper static long _last_sweep; // Value of _time_counter when the last sweep happened - static NMethodIterator _current; // Current nmethod + static CompiledMethodIterator _current; // Current compiled method static int _seen; // Nof. nmethod we have currently processed in current pass of CodeCache static volatile int _sweep_started; // Flag to control conc sweeper @@ -88,8 +88,8 @@ class NMethodSweeper : public AllStatic { static Monitor* _stat_lock; - static MethodStateChange process_nmethod(nmethod *nm); - static void release_nmethod(nmethod* nm); + static MethodStateChange process_compiled_method(CompiledMethod *nm); + static void release_compiled_method(CompiledMethod* nm); static void init_sweeper_log() NOT_DEBUG_RETURN; static bool wait_for_stack_scanning(); @@ -107,9 +107,8 @@ class NMethodSweeper : public AllStatic { #ifdef ASSERT - static bool is_sweeping(nmethod* which) { return _current.method() == which; } // Keep track of sweeper activity in the ring buffer - static void record_sweep(nmethod* nm, int line); + static void record_sweep(CompiledMethod* nm, int line); static void report_events(int id, address entry); static void report_events(); #endif diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index 719eb74b018..57d162a5c45 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -1432,7 +1432,7 @@ void JavaThread::initialize() { set_vframe_array_last(NULL); set_deferred_locals(NULL); set_deopt_mark(NULL); - set_deopt_nmethod(NULL); + set_deopt_compiled_method(NULL); clear_must_deopt_id(); set_monitor_chunks(NULL); set_next(NULL); @@ -3300,26 +3300,26 @@ bool CompilerThread::can_call_java() const { // Create sweeper thread CodeCacheSweeperThread::CodeCacheSweeperThread() : JavaThread(&sweeper_thread_entry) { - _scanned_nmethod = NULL; + _scanned_compiled_method = NULL; } void CodeCacheSweeperThread::oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) { JavaThread::oops_do(f, cld_f, cf); - if (_scanned_nmethod != NULL && cf != NULL) { + if (_scanned_compiled_method != NULL && cf != NULL) { // Safepoints can occur when the sweeper is scanning an nmethod so // process it here to make sure it isn't unloaded in the middle of // a scan. - cf->do_code_blob(_scanned_nmethod); + cf->do_code_blob(_scanned_compiled_method); } } void CodeCacheSweeperThread::nmethods_do(CodeBlobClosure* cf) { JavaThread::nmethods_do(cf); - if (_scanned_nmethod != NULL && cf != NULL) { + if (_scanned_compiled_method != NULL && cf != NULL) { // Safepoints can occur when the sweeper is scanning an nmethod so // process it here to make sure it isn't unloaded in the middle of // a scan. - cf->do_code_blob(_scanned_nmethod); + cf->do_code_blob(_scanned_compiled_method); } } @@ -4353,7 +4353,7 @@ void Threads::nmethods_do(CodeBlobClosure* cf) { ALL_JAVA_THREADS(p) { // This is used by the code cache sweeper to mark nmethods that are active // on the stack of a Java thread. Ignore the sweeper thread itself to avoid - // marking CodeCacheSweeperThread::_scanned_nmethod as active. + // marking CodeCacheSweeperThread::_scanned_compiled_method as active. if(!p->is_Code_cache_sweeper_thread()) { p->nmethods_do(cf); } diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index f5d7ac5b74d..c3f63440e26 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -820,7 +820,7 @@ class JavaThread: public Thread { intptr_t* _must_deopt_id; // id of frame that needs to be deopted once we // transition out of native - nmethod* _deopt_nmethod; // nmethod that is currently being deoptimized + CompiledMethod* _deopt_nmethod; // CompiledMethod that is currently being deoptimized vframeArray* _vframe_array_head; // Holds the heap of the active vframeArrays vframeArray* _vframe_array_last; // Holds last vFrameArray we popped // Because deoptimization is lazy we must save jvmti requests to set locals @@ -1298,8 +1298,8 @@ class JavaThread: public Thread { void set_must_deopt_id(intptr_t* id) { _must_deopt_id = id; } void clear_must_deopt_id() { _must_deopt_id = NULL; } - void set_deopt_nmethod(nmethod* nm) { _deopt_nmethod = nm; } - nmethod* deopt_nmethod() { return _deopt_nmethod; } + void set_deopt_compiled_method(CompiledMethod* nm) { _deopt_nmethod = nm; } + CompiledMethod* deopt_compiled_method() { return _deopt_nmethod; } Method* callee_target() const { return _callee_target; } void set_callee_target (Method* x) { _callee_target = x; } @@ -1980,13 +1980,13 @@ inline CompilerThread* JavaThread::as_CompilerThread() { // Dedicated thread to sweep the code cache class CodeCacheSweeperThread : public JavaThread { - nmethod* _scanned_nmethod; // nmethod being scanned by the sweeper + CompiledMethod* _scanned_compiled_method; // nmethod being scanned by the sweeper public: CodeCacheSweeperThread(); // Track the nmethod currently being scanned by the sweeper - void set_scanned_nmethod(nmethod* nm) { - assert(_scanned_nmethod == NULL || nm == NULL, "should reset to NULL before writing a new value"); - _scanned_nmethod = nm; + void set_scanned_compiled_method(CompiledMethod* cm) { + assert(_scanned_compiled_method == NULL || cm == NULL, "should reset to NULL before writing a new value"); + _scanned_compiled_method = cm; } // Hide sweeper thread from external view. @@ -1994,7 +1994,7 @@ class CodeCacheSweeperThread : public JavaThread { bool is_Code_cache_sweeper_thread() const { return true; } - // Prevent GC from unloading _scanned_nmethod + // Prevent GC from unloading _scanned_compiled_method void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf); void nmethods_do(CodeBlobClosure* cf); }; diff --git a/hotspot/src/share/vm/runtime/vframe.cpp b/hotspot/src/share/vm/runtime/vframe.cpp index 2716deb1987..7d9a7b39e6e 100644 --- a/hotspot/src/share/vm/runtime/vframe.cpp +++ b/hotspot/src/share/vm/runtime/vframe.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,8 +67,8 @@ vframe* vframe::new_vframe(const frame* f, const RegisterMap* reg_map, JavaThrea // Compiled frame CodeBlob* cb = f->cb(); if (cb != NULL) { - if (cb->is_nmethod()) { - nmethod* nm = (nmethod*)cb; + if (cb->is_compiled()) { + CompiledMethod* nm = (CompiledMethod*)cb; return new compiledVFrame(f, reg_map, thread, nm); } diff --git a/hotspot/src/share/vm/runtime/vframe.hpp b/hotspot/src/share/vm/runtime/vframe.hpp index dde2f246812..148244aee6f 100644 --- a/hotspot/src/share/vm/runtime/vframe.hpp +++ b/hotspot/src/share/vm/runtime/vframe.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,9 +66,9 @@ class vframe: public ResourceObj { // Accessors frame fr() const { return _fr; } CodeBlob* cb() const { return _fr.cb(); } - nmethod* nm() const { - assert( cb() != NULL && cb()->is_nmethod(), "usage"); - return (nmethod*) cb(); + CompiledMethod* nm() const { + assert( cb() != NULL && cb()->is_compiled(), "usage"); + return (CompiledMethod*) cb(); } // ???? Does this need to be a copy? @@ -326,9 +326,9 @@ class vframeStreamCommon : StackObj { } CodeBlob* cb() const { return _frame.cb(); } - nmethod* nm() const { - assert( cb() != NULL && cb()->is_nmethod(), "usage"); - return (nmethod*) cb(); + CompiledMethod* nm() const { + assert( cb() != NULL && cb()->is_compiled(), "usage"); + return (CompiledMethod*) cb(); } // Frame type @@ -449,7 +449,7 @@ inline bool vframeStreamCommon::fill_from_frame() { // Compiled frame - if (cb() != NULL && cb()->is_nmethod()) { + if (cb() != NULL && cb()->is_compiled()) { if (nm()->is_native_method()) { // Do not rely on scopeDesc since the pc might be unprecise due to the _last_native_pc trick. fill_from_compiled_native_frame(); diff --git a/hotspot/src/share/vm/runtime/vframeArray.cpp b/hotspot/src/share/vm/runtime/vframeArray.cpp index 29be4e4e4bd..483473244eb 100644 --- a/hotspot/src/share/vm/runtime/vframeArray.cpp +++ b/hotspot/src/share/vm/runtime/vframeArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -206,8 +206,8 @@ void vframeArrayElement::unpack_on_stack(int caller_actual_parameters, // in which case bcp should point to the monitorenter since it is within the exception's range. assert(*bcp != Bytecodes::_monitorenter || is_top_frame, "a _monitorenter must be a top frame"); - assert(thread->deopt_nmethod() != NULL, "nmethod should be known"); - guarantee(!(thread->deopt_nmethod()->is_compiled_by_c2() && + assert(thread->deopt_compiled_method() != NULL, "compiled method should be known"); + guarantee(!(thread->deopt_compiled_method()->is_compiled_by_c2() && *bcp == Bytecodes::_monitorenter && exec_mode == Deoptimization::Unpack_exception), "shouldn't get exception during monitorenter"); diff --git a/hotspot/src/share/vm/runtime/vframe_hp.cpp b/hotspot/src/share/vm/runtime/vframe_hp.cpp index 45617d03427..168deb03aef 100644 --- a/hotspot/src/share/vm/runtime/vframe_hp.cpp +++ b/hotspot/src/share/vm/runtime/vframe_hp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -196,7 +196,7 @@ BasicLock* compiledVFrame::resolve_monitor_lock(Location location) const { GrowableArray* compiledVFrame::monitors() const { // Natives has no scope if (scope() == NULL) { - nmethod* nm = code(); + CompiledMethod* nm = code(); Method* method = nm->method(); assert(method->is_native(), ""); if (!method->is_synchronized()) { @@ -240,13 +240,13 @@ GrowableArray* compiledVFrame::monitors() const { } -compiledVFrame::compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, nmethod* nm) +compiledVFrame::compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, CompiledMethod* nm) : javaVFrame(fr, reg_map, thread) { _scope = NULL; // Compiled method (native stub or Java code) // native wrappers have no scope data, it is implied - if (!nm->is_native_method()) { - _scope = nm->scope_desc_at(_fr.pc()); + if (!nm->is_compiled() || !nm->as_compiled_method()->is_native_method()) { + _scope = nm->scope_desc_at(_fr.pc()); } } @@ -264,15 +264,15 @@ bool compiledVFrame::is_top() const { } -nmethod* compiledVFrame::code() const { - return CodeCache::find_nmethod(_fr.pc()); +CompiledMethod* compiledVFrame::code() const { + return CodeCache::find_compiled(_fr.pc()); } Method* compiledVFrame::method() const { if (scope() == NULL) { // native nmethods have no scope the method is implied - nmethod* nm = code(); + nmethod* nm = code()->as_nmethod(); assert(nm->is_native_method(), "must be native"); return nm->method(); } @@ -289,7 +289,7 @@ int compiledVFrame::bci() const { int compiledVFrame::raw_bci() const { if (scope() == NULL) { // native nmethods have no scope the method/bci is implied - nmethod* nm = code(); + nmethod* nm = code()->as_nmethod(); assert(nm->is_native_method(), "must be native"); return 0; } @@ -299,7 +299,7 @@ int compiledVFrame::raw_bci() const { bool compiledVFrame::should_reexecute() const { if (scope() == NULL) { // native nmethods have no scope the method/bci is implied - nmethod* nm = code(); + nmethod* nm = code()->as_nmethod(); assert(nm->is_native_method(), "must be native"); return false; } @@ -310,7 +310,7 @@ vframe* compiledVFrame::sender() const { const frame f = fr(); if (scope() == NULL) { // native nmethods have no scope the method/bci is implied - nmethod* nm = code(); + nmethod* nm = code()->as_nmethod(); assert(nm->is_native_method(), "must be native"); return vframe::sender(); } else { diff --git a/hotspot/src/share/vm/runtime/vframe_hp.hpp b/hotspot/src/share/vm/runtime/vframe_hp.hpp index 21ec69efbfc..c3be6c2e1eb 100644 --- a/hotspot/src/share/vm/runtime/vframe_hp.hpp +++ b/hotspot/src/share/vm/runtime/vframe_hp.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,13 +52,13 @@ class compiledVFrame: public javaVFrame { public: // Constructors - compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, nmethod* nm); + compiledVFrame(const frame* fr, const RegisterMap* reg_map, JavaThread* thread, CompiledMethod* nm); // Update a local in a compiled frame. Update happens when deopt occurs void update_local(BasicType type, int index, jvalue value); // Returns the active nmethod - nmethod* code() const; + CompiledMethod* code() const; // Returns the scopeDesc ScopeDesc* scope() const { return _scope; } diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index da0aca7f6bc..8ac8243219b 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -398,7 +398,7 @@ typedef CompactHashtable SymbolCompactHashTable; nonstatic_field(Method, _intrinsic_id, u2) \ nonstatic_field(Method, _flags, u2) \ nonproduct_nonstatic_field(Method, _compiled_invocation_count, int) \ - volatile_nonstatic_field(Method, _code, nmethod*) \ + volatile_nonstatic_field(Method, _code, CompiledMethod*) \ nonstatic_field(Method, _i2i_entry, address) \ volatile_nonstatic_field(Method, _from_compiled_entry, address) \ volatile_nonstatic_field(Method, _from_interpreted_entry, address) \ @@ -915,40 +915,47 @@ typedef CompactHashtable SymbolCompactHashTable; /* CodeBlobs (NOTE: incomplete, but only a little) */ \ /***************************************************/ \ \ - nonstatic_field(CodeBlob, _name, const char*) \ - nonstatic_field(CodeBlob, _size, int) \ - nonstatic_field(CodeBlob, _header_size, int) \ - nonstatic_field(CodeBlob, _relocation_size, int) \ - nonstatic_field(CodeBlob, _content_offset, int) \ - nonstatic_field(CodeBlob, _code_offset, int) \ - nonstatic_field(CodeBlob, _frame_complete_offset, int) \ - nonstatic_field(CodeBlob, _data_offset, int) \ - nonstatic_field(CodeBlob, _frame_size, int) \ - nonstatic_field(CodeBlob, _oop_maps, ImmutableOopMapSet*) \ + nonstatic_field(CodeBlob, _name, const char*) \ + nonstatic_field(CodeBlob, _size, int) \ + nonstatic_field(CodeBlob, _header_size, int) \ + nonstatic_field(CodeBlob, _frame_complete_offset, int) \ + nonstatic_field(CodeBlob, _data_offset, int) \ + nonstatic_field(CodeBlob, _frame_size, int) \ + nonstatic_field(CodeBlob, _oop_maps, ImmutableOopMapSet*) \ + nonstatic_field(CodeBlob, _code_begin, address) \ + nonstatic_field(CodeBlob, _code_end, address) \ + nonstatic_field(CodeBlob, _content_begin, address) \ + nonstatic_field(CodeBlob, _data_end, address) \ \ nonstatic_field(DeoptimizationBlob, _unpack_offset, int) \ \ nonstatic_field(RuntimeStub, _caller_must_gc_arguments, bool) \ \ + /********************************************************/ \ + /* CompiledMethod (NOTE: incomplete, but only a little) */ \ + /********************************************************/ \ + \ + nonstatic_field(CompiledMethod, _method, Method*) \ + volatile_nonstatic_field(CompiledMethod, _exception_cache, ExceptionCache*) \ + nonstatic_field(CompiledMethod, _scopes_data_begin, address) \ + nonstatic_field(CompiledMethod, _deopt_handler_begin, address) \ + nonstatic_field(CompiledMethod, _deopt_mh_handler_begin, address) \ + \ /**************************************************/ \ /* NMethods (NOTE: incomplete, but only a little) */ \ /**************************************************/ \ \ - nonstatic_field(nmethod, _method, Method*) \ nonstatic_field(nmethod, _entry_bci, int) \ nonstatic_field(nmethod, _osr_link, nmethod*) \ nonstatic_field(nmethod, _scavenge_root_link, nmethod*) \ nonstatic_field(nmethod, _scavenge_root_state, jbyte) \ nonstatic_field(nmethod, _state, volatile unsigned char) \ nonstatic_field(nmethod, _exception_offset, int) \ - nonstatic_field(nmethod, _deoptimize_offset, int) \ - nonstatic_field(nmethod, _deoptimize_mh_offset, int) \ nonstatic_field(nmethod, _orig_pc_offset, int) \ nonstatic_field(nmethod, _stub_offset, int) \ nonstatic_field(nmethod, _consts_offset, int) \ nonstatic_field(nmethod, _oops_offset, int) \ nonstatic_field(nmethod, _metadata_offset, int) \ - nonstatic_field(nmethod, _scopes_data_offset, int) \ nonstatic_field(nmethod, _scopes_pcs_offset, int) \ nonstatic_field(nmethod, _dependencies_offset, int) \ nonstatic_field(nmethod, _handler_table_offset, int) \ @@ -961,7 +968,6 @@ typedef CompactHashtable SymbolCompactHashTable; nonstatic_field(nmethod, _stack_traversal_mark, long) \ nonstatic_field(nmethod, _compile_id, int) \ nonstatic_field(nmethod, _comp_level, int) \ - volatile_nonstatic_field(nmethod, _exception_cache, ExceptionCache*) \ \ unchecked_c2_static_field(Deoptimization, _trap_reason_name, void*) \ \ @@ -1744,16 +1750,18 @@ typedef CompactHashtable SymbolCompactHashTable; declare_toplevel_type(SharedRuntime) \ \ declare_toplevel_type(CodeBlob) \ - declare_type(BufferBlob, CodeBlob) \ + declare_type(RuntimeBlob, CodeBlob) \ + declare_type(BufferBlob, RuntimeBlob) \ declare_type(AdapterBlob, BufferBlob) \ declare_type(MethodHandlesAdapterBlob, BufferBlob) \ - declare_type(nmethod, CodeBlob) \ - declare_type(RuntimeStub, CodeBlob) \ - declare_type(SingletonBlob, CodeBlob) \ + declare_type(CompiledMethod, CodeBlob) \ + declare_type(nmethod, CompiledMethod) \ + declare_type(RuntimeStub, RuntimeBlob) \ + declare_type(SingletonBlob, RuntimeBlob) \ declare_type(SafepointBlob, SingletonBlob) \ declare_type(DeoptimizationBlob, SingletonBlob) \ declare_c2_type(ExceptionBlob, SingletonBlob) \ - declare_c2_type(UncommonTrapBlob, CodeBlob) \ + declare_c2_type(UncommonTrapBlob, RuntimeBlob) \ \ /***************************************/ \ /* PcDesc and other compiled code info */ \ @@ -2236,6 +2244,7 @@ typedef CompactHashtable SymbolCompactHashTable; declare_toplevel_type(BreakpointInfo) \ declare_toplevel_type(BreakpointInfo*) \ declare_toplevel_type(CodeBlob*) \ + declare_toplevel_type(RuntimeBlob*) \ declare_toplevel_type(CompressedWriteStream*) \ declare_toplevel_type(ConstantPoolCacheEntry) \ declare_toplevel_type(elapsedTimer) \ diff --git a/hotspot/src/share/vm/utilities/globalDefinitions.hpp b/hotspot/src/share/vm/utilities/globalDefinitions.hpp index 85186c1ffab..33b22d30328 100644 --- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp +++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp @@ -1003,7 +1003,9 @@ class VM_Operation; class VMOperationQueue; class CodeBlob; -class nmethod; +class CompiledMethod; +class nmethod; +class RuntimeBlob; class OSRAdapter; class I2CAdapter; class C2IAdapter; diff --git a/hotspot/test/compiler/codecache/jmx/InitialAndMaxUsageTest.java b/hotspot/test/compiler/codecache/jmx/InitialAndMaxUsageTest.java index a67812fc683..f695234cb00 100644 --- a/hotspot/test/compiler/codecache/jmx/InitialAndMaxUsageTest.java +++ b/hotspot/test/compiler/codecache/jmx/InitialAndMaxUsageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,7 +84,7 @@ public class InitialAndMaxUsageTest { Asserts.assertEQ(initialUsage, 0L, "Unexpected initial usage"); } ArrayList blobs = new ArrayList<>(); - long minAllocationUnit = CodeCacheUtils.MIN_ALLOCATION - headerSize; + long minAllocationUnit = Math.max(0, CodeCacheUtils.MIN_ALLOCATION - headerSize); /* now filling code cache with large-sized allocation first, since lots of small allocations takes too much time, so, just a small optimization */ diff --git a/hotspot/test/compiler/codecache/jmx/UsageThresholdIncreasedTest.java b/hotspot/test/compiler/codecache/jmx/UsageThresholdIncreasedTest.java index 765eede8938..8f2e6f10269 100644 --- a/hotspot/test/compiler/codecache/jmx/UsageThresholdIncreasedTest.java +++ b/hotspot/test/compiler/codecache/jmx/UsageThresholdIncreasedTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,7 +67,7 @@ public class UsageThresholdIncreasedTest { protected void runTest() { long headerSize = CodeCacheUtils.getHeaderSize(btype); - long allocationUnit = CodeCacheUtils.MIN_ALLOCATION - headerSize; + long allocationUnit = Math.max(0, CodeCacheUtils.MIN_ALLOCATION - headerSize); MemoryPoolMXBean bean = btype.getMemoryPool(); long initialCount = bean.getUsageThresholdCount(); long initialSize = bean.getUsage().getUsed(); diff --git a/hotspot/test/compiler/codecache/jmx/UsageThresholdNotExceededTest.java b/hotspot/test/compiler/codecache/jmx/UsageThresholdNotExceededTest.java index 29b5263bdad..1838226fae4 100644 --- a/hotspot/test/compiler/codecache/jmx/UsageThresholdNotExceededTest.java +++ b/hotspot/test/compiler/codecache/jmx/UsageThresholdNotExceededTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,9 +58,12 @@ public class UsageThresholdNotExceededTest { MemoryPoolMXBean bean = btype.getMemoryPool(); long initialThresholdCount = bean.getUsageThresholdCount(); long initialUsage = bean.getUsage().getUsed(); + bean.setUsageThreshold(initialUsage + 1 + CodeCacheUtils.MIN_ALLOCATION); - CodeCacheUtils.WB.allocateCodeBlob(CodeCacheUtils.MIN_ALLOCATION - - CodeCacheUtils.getHeaderSize(btype), btype.id); + long size = CodeCacheUtils.getHeaderSize(btype); + + CodeCacheUtils.WB.allocateCodeBlob(Math.max(0, CodeCacheUtils.MIN_ALLOCATION + - size), btype.id); // a gc cycle triggers usage threshold recalculation CodeCacheUtils.WB.fullGC(); CodeCacheUtils.assertEQorGTE(btype, bean.getUsageThresholdCount(), initialThresholdCount, -- GitLab From 7c4302f618333e6b006a70a0ccebc271e22c92b5 Mon Sep 17 00:00:00 2001 From: Michael Berg Date: Tue, 26 Apr 2016 20:43:59 -0700 Subject: [PATCH 202/400] 8154896: xml.transform fails intermittently on SKX Replace some short branches (jccb) to avoid problem when EVEX is used. Reviewed-by: twisti, kvn --- hotspot/src/cpu/x86/vm/assembler_x86.cpp | 2 +- hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp | 70 +++++++++---------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp index f294d84cb36..7dfaf929c97 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp @@ -2633,7 +2633,7 @@ void Assembler::movlpd(XMMRegister dst, Address src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); - attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_32bit); + attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_64bit); attributes.set_rex_vex_w_reverted(); simd_prefix(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x12); diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index d831256fd66..6cd3459ce3c 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -4332,9 +4332,7 @@ void MacroAssembler::vpcmpeqb(XMMRegister dst, XMMRegister nds, XMMRegister src, int nds_enc = nds->encoding(); int src_enc = src->encoding(); assert(dst_enc == nds_enc, ""); - if (VM_Version::supports_avxonly() || VM_Version::supports_avx512bw()) { - Assembler::vpcmpeqb(dst, nds, src, vector_len); - } else if ((dst_enc < 16) && (src_enc < 16)) { + if ((dst_enc < 16) && (src_enc < 16)) { Assembler::vpcmpeqb(dst, nds, src, vector_len); } else if (src_enc < 16) { subptr(rsp, 64); @@ -4372,9 +4370,7 @@ void MacroAssembler::vpcmpeqw(XMMRegister dst, XMMRegister nds, XMMRegister src, int nds_enc = nds->encoding(); int src_enc = src->encoding(); assert(dst_enc == nds_enc, ""); - if (VM_Version::supports_avxonly() || VM_Version::supports_avx512bw()) { - Assembler::vpcmpeqw(dst, nds, src, vector_len); - } else if ((dst_enc < 16) && (src_enc < 16)) { + if ((dst_enc < 16) && (src_enc < 16)) { Assembler::vpcmpeqw(dst, nds, src, vector_len); } else if (src_enc < 16) { subptr(rsp, 64); @@ -7330,7 +7326,7 @@ void MacroAssembler::string_indexofC8(Register str1, Register str2, decrementl(cnt1); // Shift to next element cmpl(cnt1, cnt2); - jccb(Assembler::negative, RET_NOT_FOUND); // Left less then substring + jcc(Assembler::negative, RET_NOT_FOUND); // Left less then substring addptr(result, (1< stride) { // This code is optimized for the case when whole substring @@ -7379,7 +7375,7 @@ void MacroAssembler::string_indexofC8(Register str1, Register str2, bind(MATCH_SUBSTR_HEAD); pcmpestri(vec, Address(result, 0), mode); // Reload only string if does not match - jccb(Assembler::noOverflow, RELOAD_STR); // OF == 0 + jcc(Assembler::noOverflow, RELOAD_STR); // OF == 0 Label CONT_SCAN_SUBSTR; // Compare the rest of substring (> 8 chars). @@ -7637,7 +7633,7 @@ void MacroAssembler::string_indexof(Register str1, Register str2, addl(cnt1, str1); decrementl(cnt1); // Shift to next element cmpl(cnt1, cnt2); - jccb(Assembler::negative, RET_NOT_FOUND); // Left less then substring + jcc(Assembler::negative, RET_NOT_FOUND); // Left less then substring addptr(result, (1<= 2) { cmpl(cnt1, stride); - jccb(Assembler::less, SCAN_TO_CHAR_LOOP); + jcc(Assembler::less, SCAN_TO_CHAR_LOOP); cmpl(cnt1, 2*stride); - jccb(Assembler::less, SCAN_TO_8_CHAR_INIT); + jcc(Assembler::less, SCAN_TO_8_CHAR_INIT); movdl(vec1, ch); vpbroadcastw(vec1, vec1); vpxor(vec2, vec2); @@ -7803,9 +7799,9 @@ void MacroAssembler::string_indexof_char(Register str1, Register cnt1, Register bind(SCAN_TO_8_CHAR); cmpl(cnt1, stride); if (UseAVX >= 2) { - jccb(Assembler::less, SCAN_TO_CHAR); + jcc(Assembler::less, SCAN_TO_CHAR); } else { - jccb(Assembler::less, SCAN_TO_CHAR_LOOP); + jcc(Assembler::less, SCAN_TO_CHAR_LOOP); movdl(vec1, ch); pshuflw(vec1, vec1, 0x00); pshufd(vec1, vec1, 0); @@ -8057,14 +8053,14 @@ void MacroAssembler::string_compare(Register str1, Register str2, jcc(Assembler::notZero, VECTOR_NOT_EQUAL); addptr(result, stride2); subl(cnt2, stride2); - jccb(Assembler::notZero, COMPARE_WIDE_VECTORS_LOOP); + jcc(Assembler::notZero, COMPARE_WIDE_VECTORS_LOOP); // clean upper bits of YMM registers vpxor(vec1, vec1); // compare wide vectors tail bind(COMPARE_WIDE_TAIL); testptr(result, result); - jccb(Assembler::zero, LENGTH_DIFF_LABEL); + jcc(Assembler::zero, LENGTH_DIFF_LABEL); movl(result, stride2); movl(cnt2, result); @@ -8088,7 +8084,7 @@ void MacroAssembler::string_compare(Register str1, Register str2, bind(COMPARE_TAIL_LONG); movl(cnt2, result); cmpl(cnt2, stride); - jccb(Assembler::less, COMPARE_SMALL_STR); + jcc(Assembler::less, COMPARE_SMALL_STR); if (ae == StrIntrinsicNode::LL || ae == StrIntrinsicNode::UU) { movdqu(vec1, Address(str1, 0)); @@ -8098,7 +8094,7 @@ void MacroAssembler::string_compare(Register str1, Register str2, pcmpestri(vec1, Address(str2, 0), pcmpmask); jcc(Assembler::below, COMPARE_INDEX_CHAR); subptr(cnt2, stride); - jccb(Assembler::zero, LENGTH_DIFF_LABEL); + jcc(Assembler::zero, LENGTH_DIFF_LABEL); if (ae == StrIntrinsicNode::LL || ae == StrIntrinsicNode::UU) { lea(str1, Address(str1, result, scale)); lea(str2, Address(str2, result, scale)); @@ -8121,7 +8117,7 @@ void MacroAssembler::string_compare(Register str1, Register str2, if (ae == StrIntrinsicNode::LL) { pcmpmask &= ~0x01; } - jccb(Assembler::zero, COMPARE_TAIL); + jcc(Assembler::zero, COMPARE_TAIL); if (ae == StrIntrinsicNode::LL || ae == StrIntrinsicNode::UU) { lea(str1, Address(str1, result, scale)); lea(str2, Address(str2, result, scale)); @@ -8160,7 +8156,7 @@ void MacroAssembler::string_compare(Register str1, Register str2, // compare wide vectors tail testptr(result, result); - jccb(Assembler::zero, LENGTH_DIFF_LABEL); + jcc(Assembler::zero, LENGTH_DIFF_LABEL); movl(cnt2, stride); movl(result, stride); @@ -8280,7 +8276,7 @@ void MacroAssembler::has_negatives(Register ary1, Register len, // Compare 32-byte vectors andl(result, 0x0000001f); // tail count (in bytes) andl(len, 0xffffffe0); // vector count (in bytes) - jccb(Assembler::zero, COMPARE_TAIL); + jcc(Assembler::zero, COMPARE_TAIL); lea(ary1, Address(ary1, len, Address::times_1)); negptr(len); @@ -8292,17 +8288,17 @@ void MacroAssembler::has_negatives(Register ary1, Register len, bind(COMPARE_WIDE_VECTORS); vmovdqu(vec1, Address(ary1, len, Address::times_1)); vptest(vec1, vec2); - jccb(Assembler::notZero, TRUE_LABEL); + jcc(Assembler::notZero, TRUE_LABEL); addptr(len, 32); jcc(Assembler::notZero, COMPARE_WIDE_VECTORS); testl(result, result); - jccb(Assembler::zero, FALSE_LABEL); + jcc(Assembler::zero, FALSE_LABEL); vmovdqu(vec1, Address(ary1, result, Address::times_1, -32)); vptest(vec1, vec2); - jccb(Assembler::notZero, TRUE_LABEL); - jmpb(FALSE_LABEL); + jcc(Assembler::notZero, TRUE_LABEL); + jmp(FALSE_LABEL); bind(COMPARE_TAIL); // len is zero movl(len, result); @@ -8327,12 +8323,12 @@ void MacroAssembler::has_negatives(Register ary1, Register len, bind(COMPARE_WIDE_VECTORS); movdqu(vec1, Address(ary1, len, Address::times_1)); ptest(vec1, vec2); - jccb(Assembler::notZero, TRUE_LABEL); + jcc(Assembler::notZero, TRUE_LABEL); addptr(len, 16); jcc(Assembler::notZero, COMPARE_WIDE_VECTORS); testl(result, result); - jccb(Assembler::zero, FALSE_LABEL); + jcc(Assembler::zero, FALSE_LABEL); movdqu(vec1, Address(ary1, result, Address::times_1, -16)); ptest(vec1, vec2); @@ -8494,12 +8490,12 @@ void MacroAssembler::arrays_equals(bool is_array_equ, Register ary1, Register ar vpxor(vec1, vec2); vptest(vec1, vec1); - jccb(Assembler::notZero, FALSE_LABEL); + jcc(Assembler::notZero, FALSE_LABEL); addptr(limit, 32); jcc(Assembler::notZero, COMPARE_WIDE_VECTORS); testl(result, result); - jccb(Assembler::zero, TRUE_LABEL); + jcc(Assembler::zero, TRUE_LABEL); vmovdqu(vec1, Address(ary1, result, Address::times_1, -32)); vmovdqu(vec2, Address(ary2, result, Address::times_1, -32)); @@ -8520,7 +8516,7 @@ void MacroAssembler::arrays_equals(bool is_array_equ, Register ary1, Register ar // Compare 16-byte vectors andl(result, 0x0000000f); // tail count (in bytes) andl(limit, 0xfffffff0); // vector count (in bytes) - jccb(Assembler::zero, COMPARE_TAIL); + jcc(Assembler::zero, COMPARE_TAIL); lea(ary1, Address(ary1, limit, Address::times_1)); lea(ary2, Address(ary2, limit, Address::times_1)); @@ -8532,12 +8528,12 @@ void MacroAssembler::arrays_equals(bool is_array_equ, Register ary1, Register ar pxor(vec1, vec2); ptest(vec1, vec1); - jccb(Assembler::notZero, FALSE_LABEL); + jcc(Assembler::notZero, FALSE_LABEL); addptr(limit, 16); jcc(Assembler::notZero, COMPARE_WIDE_VECTORS); testl(result, result); - jccb(Assembler::zero, TRUE_LABEL); + jcc(Assembler::zero, TRUE_LABEL); movdqu(vec1, Address(ary1, result, Address::times_1, -16)); movdqu(vec2, Address(ary2, result, Address::times_1, -16)); @@ -8872,7 +8868,7 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, movl(tmp5, 0xff00ff00); // create mask to test for Unicode chars in vector movdl(tmp1Reg, tmp5); vpbroadcastd(tmp1Reg, tmp1Reg); - jmpb(L_chars_32_check); + jmp(L_chars_32_check); bind(L_copy_32_chars); vmovdqu(tmp3Reg, Address(src, len, Address::times_2, -64)); @@ -8886,7 +8882,7 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, bind(L_chars_32_check); addptr(len, 32); - jccb(Assembler::lessEqual, L_copy_32_chars); + jcc(Assembler::lessEqual, L_copy_32_chars); bind(L_copy_32_chars_exit); subptr(len, 16); @@ -8903,7 +8899,7 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, if (UseAVX >= 2) { vmovdqu(tmp2Reg, Address(src, len, Address::times_2, -32)); vptest(tmp2Reg, tmp1Reg); - jccb(Assembler::notZero, L_copy_16_chars_exit); + jcc(Assembler::notZero, L_copy_16_chars_exit); vpackuswb(tmp2Reg, tmp2Reg, tmp1Reg, /* vector_len */ 1); vpermq(tmp3Reg, tmp2Reg, 0xD8, /* vector_len */ 1); } else { @@ -8925,7 +8921,7 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, bind(L_chars_16_check); addptr(len, 16); - jccb(Assembler::lessEqual, L_copy_16_chars); + jcc(Assembler::lessEqual, L_copy_16_chars); bind(L_copy_16_chars_exit); if (UseAVX >= 2) { -- GitLab From f2e9b827d699115f8683e9def06c249e5476fd50 Mon Sep 17 00:00:00 2001 From: Jan Civlin Date: Tue, 26 Apr 2016 21:54:21 -0700 Subject: [PATCH 203/400] 8154495: SHA256 AVX2 intrinsic (when no supports_sha() available) Reviewed-by: kvn --- hotspot/src/cpu/x86/vm/assembler_x86.cpp | 53 +- hotspot/src/cpu/x86/vm/assembler_x86.hpp | 6 + hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp | 39 ++ .../src/cpu/x86/vm/macroAssembler_x86_sha.cpp | 540 ++++++++++++++++++ .../src/cpu/x86/vm/stubGenerator_x86_64.cpp | 51 +- hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp | 9 + hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp | 7 + hotspot/src/cpu/x86/vm/vm_version_x86.cpp | 4 +- .../GenericTestCaseForUnsupportedX86CPU.java | 32 +- .../sha/predicate/IntrinsicPredicates.java | 21 +- .../cli/predicate/CPUSpecificPredicate.java | 2 +- 11 files changed, 739 insertions(+), 25 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp index 7dfaf929c97..ffbc0b1bdf3 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp @@ -3211,6 +3211,16 @@ void Assembler::vpermq(XMMRegister dst, XMMRegister src, int imm8, int vector_le emit_int8(imm8); } +void Assembler::vperm2i128(XMMRegister dst, XMMRegister nds, XMMRegister src, int imm8) { + assert(VM_Version::supports_avx2(), ""); + InstructionAttr attributes(AVX_256bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); + emit_int8(0x46); + emit_int8(0xC0 | encode); + emit_int8(imm8); +} + + void Assembler::pause() { emit_int8((unsigned char)0xF3); emit_int8((unsigned char)0x90); @@ -3679,6 +3689,16 @@ void Assembler::pshufb(XMMRegister dst, XMMRegister src) { emit_int8((unsigned char)(0xC0 | encode)); } +void Assembler::vpshufb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(vector_len == AVX_128bit? VM_Version::supports_avx() : + vector_len == AVX_256bit? VM_Version::supports_avx2() : + 0, ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, nds, src, VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x00); + emit_int8((unsigned char)(0xC0 | encode)); +} + void Assembler::pshufb(XMMRegister dst, Address src) { assert(VM_Version::supports_ssse3(), ""); InstructionMark im(this); @@ -3700,6 +3720,18 @@ void Assembler::pshufd(XMMRegister dst, XMMRegister src, int mode) { emit_int8(mode & 0xFF); } +void Assembler::vpshufd(XMMRegister dst, XMMRegister src, int mode, int vector_len) { + assert(vector_len == AVX_128bit? VM_Version::supports_avx() : + vector_len == AVX_256bit? VM_Version::supports_avx2() : + 0, ""); + NOT_LP64(assert(VM_Version::supports_sse2(), "")); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8(0x70); + emit_int8((unsigned char)(0xC0 | encode)); + emit_int8(mode & 0xFF); +} + void Assembler::pshufd(XMMRegister dst, Address src, int mode) { assert(isByte(mode), "invalid value"); NOT_LP64(assert(VM_Version::supports_sse2(), "")); @@ -3740,7 +3772,6 @@ void Assembler::psrldq(XMMRegister dst, int shift) { // Shift left 128 bit value in dst XMMRegister by shift number of bytes. NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ false); - // XMM3 is for /3 encoding: 66 0F 73 /3 ib int encode = simd_prefix_and_encode(xmm3, dst, dst, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int8(0x73); emit_int8((unsigned char)(0xC0 | encode)); @@ -4023,6 +4054,17 @@ void Assembler::palignr(XMMRegister dst, XMMRegister src, int imm8) { emit_int8(imm8); } +void Assembler::vpalignr(XMMRegister dst, XMMRegister nds, XMMRegister src, int imm8, int vector_len) { + assert(vector_len == AVX_128bit? VM_Version::supports_avx() : + vector_len == AVX_256bit? VM_Version::supports_avx2() : + 0, ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, nds, src, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); + emit_int8((unsigned char)0x0F); + emit_int8((unsigned char)(0xC0 | encode)); + emit_int8(imm8); +} + void Assembler::pblendw(XMMRegister dst, XMMRegister src, int imm8) { assert(VM_Version::supports_sse4_1(), ""); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false); @@ -8305,6 +8347,15 @@ void Assembler::rorxq(Register dst, Register src, int imm8) { emit_int8(imm8); } +void Assembler::rorxd(Register dst, Register src, int imm8) { + assert(VM_Version::supports_bmi2(), "bit manipulation instructions not supported"); + InstructionAttr attributes(AVX_128bit, /* vex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ false, /* uses_vl */ false); + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F_3A, &attributes); + emit_int8((unsigned char)0xF0); + emit_int8((unsigned char)(0xC0 | encode)); + emit_int8(imm8); +} + void Assembler::sarq(Register dst, int imm8) { assert(isShiftCount(imm8 >> 1), "illegal shift count"); int encode = prefixq_and_encode(dst->encoding()); diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp index 78fe0ad05ba..e82080507a0 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp @@ -1522,6 +1522,7 @@ private: // Pemutation of 64bit words void vpermq(XMMRegister dst, XMMRegister src, int imm8, int vector_len); void vpermq(XMMRegister dst, XMMRegister src, int imm8); + void vperm2i128(XMMRegister dst, XMMRegister nds, XMMRegister src, int imm8); void pause(); @@ -1606,10 +1607,12 @@ private: // Shuffle Bytes void pshufb(XMMRegister dst, XMMRegister src); void pshufb(XMMRegister dst, Address src); + void vpshufb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); // Shuffle Packed Doublewords void pshufd(XMMRegister dst, XMMRegister src, int mode); void pshufd(XMMRegister dst, Address src, int mode); + void vpshufd(XMMRegister dst, XMMRegister src, int mode, int vector_len); // Shuffle Packed Low Words void pshuflw(XMMRegister dst, XMMRegister src, int mode); @@ -1661,6 +1664,7 @@ private: #ifdef _LP64 void rorq(Register dst, int imm8); void rorxq(Register dst, Register src, int imm8); + void rorxd(Register dst, Register src, int imm8); #endif void sahf(); @@ -1684,6 +1688,8 @@ private: void setb(Condition cc, Register dst); void palignr(XMMRegister dst, XMMRegister src, int imm8); + void vpalignr(XMMRegister dst, XMMRegister src1, XMMRegister src2, int imm8, int vector_len); + void pblendw(XMMRegister dst, XMMRegister src, int imm8); void sha1rnds4(XMMRegister dst, XMMRegister src, int imm8); diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp index b92ec2e99af..e52306d3a1a 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp @@ -906,6 +906,45 @@ class MacroAssembler: public Assembler { void ldmxcsr(Address src) { Assembler::ldmxcsr(src); } void ldmxcsr(AddressLiteral src); +#ifdef _LP64 + private: + void sha256_AVX2_one_round_compute( + Register reg_old_h, + Register reg_a, + Register reg_b, + Register reg_c, + Register reg_d, + Register reg_e, + Register reg_f, + Register reg_g, + Register reg_h, + int iter); + void sha256_AVX2_four_rounds_compute_first(int start); + void sha256_AVX2_four_rounds_compute_last(int start); + void sha256_AVX2_one_round_and_sched( + XMMRegister xmm_0, /* == ymm4 on 0, 1, 2, 3 iterations, then rotate 4 registers left on 4, 8, 12 iterations */ + XMMRegister xmm_1, /* ymm5 */ /* full cycle is 16 iterations */ + XMMRegister xmm_2, /* ymm6 */ + XMMRegister xmm_3, /* ymm7 */ + Register reg_a, /* == eax on 0 iteration, then rotate 8 register right on each next iteration */ + Register reg_b, /* ebx */ /* full cycle is 8 iterations */ + Register reg_c, /* edi */ + Register reg_d, /* esi */ + Register reg_e, /* r8d */ + Register reg_f, /* r9d */ + Register reg_g, /* r10d */ + Register reg_h, /* r11d */ + int iter); + + void addm(int disp, Register r1, Register r2); + + public: + void sha256_AVX2(XMMRegister msg, XMMRegister state0, XMMRegister state1, XMMRegister msgtmp0, + XMMRegister msgtmp1, XMMRegister msgtmp2, XMMRegister msgtmp3, XMMRegister msgtmp4, + Register buf, Register state, Register ofs, Register limit, Register rsp, + bool multi_block, XMMRegister shuf_mask); +#endif + void fast_sha1(XMMRegister abcd, XMMRegister e0, XMMRegister e1, XMMRegister msg0, XMMRegister msg1, XMMRegister msg2, XMMRegister msg3, XMMRegister shuf_mask, Register buf, Register state, Register ofs, Register limit, Register rsp, diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp index bbc96156fe5..a0910f395bb 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sha.cpp @@ -493,3 +493,543 @@ void MacroAssembler::fast_sha256(XMMRegister msg, XMMRegister state0, XMMRegiste bind(done_hash); } + +#ifdef _LP64 +/* + The algorithm below is based on Intel publication: + "Fast SHA-256 Implementations on Intelë Architecture Processors" by Jim Guilford, Kirk Yap and Vinodh Gopal. + The assembly code was originally provided by Sean Gulley and in many places preserves + the original assembly NAMES and comments to simplify matching Java assembly with its original. + The Java version was substantially redesigned to replace 1200 assembly instruction with + much shorter run-time generator of the same code in memory. +*/ + +void MacroAssembler::sha256_AVX2_one_round_compute( + Register reg_old_h, + Register reg_a, + Register reg_b, + Register reg_c, + Register reg_d, + Register reg_e, + Register reg_f, + Register reg_g, + Register reg_h, + int iter) { + const Register& reg_y0 = r13; + const Register& reg_y1 = r14; + const Register& reg_y2 = r15; + const Register& reg_y3 = rcx; + const Register& reg_T1 = r12; + //;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; RND iter ;;;;;;;;;;;;;;;;;;;;;;;;;;; + if (iter%4 > 0) { + addl(reg_old_h, reg_y2); // reg_h = k + w + reg_h + S0 + S1 + CH = t1 + S0; -- + } + movl(reg_y2, reg_f); // reg_y2 = reg_f ; CH + rorxd(reg_y0, reg_e, 25); // reg_y0 = reg_e >> 25 ; S1A + rorxd(reg_y1, reg_e, 11); // reg_y1 = reg_e >> 11 ; S1B + xorl(reg_y2, reg_g); // reg_y2 = reg_f^reg_g ; CH + + xorl(reg_y0, reg_y1); // reg_y0 = (reg_e>>25) ^ (reg_h>>11) ; S1 + rorxd(reg_y1, reg_e, 6); // reg_y1 = (reg_e >> 6) ; S1 + andl(reg_y2, reg_e); // reg_y2 = (reg_f^reg_g)®_e ; CH + + if (iter%4 > 0) { + addl(reg_old_h, reg_y3); // reg_h = t1 + S0 + MAJ ; -- + } + + xorl(reg_y0, reg_y1); // reg_y0 = (reg_e>>25) ^ (reg_e>>11) ^ (reg_e>>6) ; S1 + rorxd(reg_T1, reg_a, 13); // reg_T1 = reg_a >> 13 ; S0B + xorl(reg_y2, reg_g); // reg_y2 = CH = ((reg_f^reg_g)®_e)^reg_g ; CH + rorxd(reg_y1, reg_a, 22); // reg_y1 = reg_a >> 22 ; S0A + movl(reg_y3, reg_a); // reg_y3 = reg_a ; MAJA + + xorl(reg_y1, reg_T1); // reg_y1 = (reg_a>>22) ^ (reg_a>>13) ; S0 + rorxd(reg_T1, reg_a, 2); // reg_T1 = (reg_a >> 2) ; S0 + addl(reg_h, Address(rsp, rdx, Address::times_1, 4*iter)); // reg_h = k + w + reg_h ; -- + orl(reg_y3, reg_c); // reg_y3 = reg_a|reg_c ; MAJA + + xorl(reg_y1, reg_T1); // reg_y1 = (reg_a>>22) ^ (reg_a>>13) ^ (reg_a>>2) ; S0 + movl(reg_T1, reg_a); // reg_T1 = reg_a ; MAJB + andl(reg_y3, reg_b); // reg_y3 = (reg_a|reg_c)®_b ; MAJA + andl(reg_T1, reg_c); // reg_T1 = reg_a®_c ; MAJB + addl(reg_y2, reg_y0); // reg_y2 = S1 + CH ; -- + + + addl(reg_d, reg_h); // reg_d = k + w + reg_h + reg_d ; -- + orl(reg_y3, reg_T1); // reg_y3 = MAJ = (reg_a|reg_c)®_b)|(reg_a®_c) ; MAJ + addl(reg_h, reg_y1); // reg_h = k + w + reg_h + S0 ; -- + + addl(reg_d, reg_y2); // reg_d = k + w + reg_h + reg_d + S1 + CH = reg_d + t1 ; -- + + + if (iter%4 == 3) { + addl(reg_h, reg_y2); // reg_h = k + w + reg_h + S0 + S1 + CH = t1 + S0; -- + addl(reg_h, reg_y3); // reg_h = t1 + S0 + MAJ ; -- + } +} + +void MacroAssembler::sha256_AVX2_four_rounds_compute_first(int start) { + sha256_AVX2_one_round_compute(rax, rax, rbx, rdi, rsi, r8, r9, r10, r11, start + 0); + sha256_AVX2_one_round_compute(r11, r11, rax, rbx, rdi, rsi, r8, r9, r10, start + 1); + sha256_AVX2_one_round_compute(r10, r10, r11, rax, rbx, rdi, rsi, r8, r9, start + 2); + sha256_AVX2_one_round_compute(r9, r9, r10, r11, rax, rbx, rdi, rsi, r8, start + 3); +} + +void MacroAssembler::sha256_AVX2_four_rounds_compute_last(int start) { + sha256_AVX2_one_round_compute(r8, r8, r9, r10, r11, rax, rbx, rdi, rsi, start + 0); + sha256_AVX2_one_round_compute(rsi, rsi, r8, r9, r10, r11, rax, rbx, rdi, start + 1); + sha256_AVX2_one_round_compute(rdi, rdi, rsi, r8, r9, r10, r11, rax, rbx, start + 2); + sha256_AVX2_one_round_compute(rbx, rbx, rdi, rsi, r8, r9, r10, r11, rax, start + 3); +} + +void MacroAssembler::sha256_AVX2_one_round_and_sched( + XMMRegister xmm_0, /* == ymm4 on 0, 1, 2, 3 iterations, then rotate 4 registers left on 4, 8, 12 iterations */ + XMMRegister xmm_1, /* ymm5 */ /* full cycle is 16 iterations */ + XMMRegister xmm_2, /* ymm6 */ + XMMRegister xmm_3, /* ymm7 */ + Register reg_a, /* == rax on 0 iteration, then rotate 8 register right on each next iteration */ + Register reg_b, /* rbx */ /* full cycle is 8 iterations */ + Register reg_c, /* rdi */ + Register reg_d, /* rsi */ + Register reg_e, /* r8 */ + Register reg_f, /* r9d */ + Register reg_g, /* r10d */ + Register reg_h, /* r11d */ + int iter) +{ + movl(rcx, reg_a); // rcx = reg_a ; MAJA + rorxd(r13, reg_e, 25); // r13 = reg_e >> 25 ; S1A + rorxd(r14, reg_e, 11); // r14 = reg_e >> 11 ; S1B + addl(reg_h, Address(rsp, rdx, Address::times_1, 4*iter)); + orl(rcx, reg_c); // rcx = reg_a|reg_c ; MAJA + + movl(r15, reg_f); // r15 = reg_f ; CH + rorxd(r12, reg_a, 13); // r12 = reg_a >> 13 ; S0B + xorl(r13, r14); // r13 = (reg_e>>25) ^ (reg_e>>11) ; S1 + xorl(r15, reg_g); // r15 = reg_f^reg_g ; CH + + rorxd(r14, reg_e, 6); // r14 = (reg_e >> 6) ; S1 + andl(r15, reg_e); // r15 = (reg_f^reg_g)®_e ; CH + + xorl(r13, r14); // r13 = (reg_e>>25) ^ (reg_e>>11) ^ (reg_e>>6) ; S1 + rorxd(r14, reg_a, 22); // r14 = reg_a >> 22 ; S0A + addl(reg_d, reg_h); // reg_d = k + w + reg_h + reg_d ; -- + + andl(rcx, reg_b); // rcx = (reg_a|reg_c)®_b ; MAJA + xorl(r14, r12); // r14 = (reg_a>>22) ^ (reg_a>>13) ; S0 + + rorxd(r12, reg_a, 2); // r12 = (reg_a >> 2) ; S0 + xorl(r15, reg_g); // r15 = CH = ((reg_f^reg_g)®_e)^reg_g ; CH + + xorl(r14, r12); // r14 = (reg_a>>22) ^ (reg_a>>13) ^ (reg_a>>2) ; S0 + movl(r12, reg_a); // r12 = reg_a ; MAJB + andl(r12, reg_c); // r12 = reg_a®_c ; MAJB + addl(r15, r13); // r15 = S1 + CH ; -- + + orl(rcx, r12); // rcx = MAJ = (reg_a|reg_c)®_b)|(reg_a®_c) ; MAJ + addl(reg_h, r14); // reg_h = k + w + reg_h + S0 ; -- + addl(reg_d, r15); // reg_d = k + w + reg_h + reg_d + S1 + CH = reg_d + t1 ; -- + + addl(reg_h, r15); // reg_h = k + w + reg_h + S0 + S1 + CH = t1 + S0; -- + addl(reg_h, rcx); // reg_h = t1 + S0 + MAJ ; -- + + if (iter%4 == 0) { + vpalignr(xmm0, xmm_3, xmm_2, 4, AVX_256bit); // ymm0 = W[-7] + vpaddd(xmm0, xmm0, xmm_0, AVX_256bit); // ymm0 = W[-7] + W[-16]; y1 = (e >> 6) ; S1 + vpalignr(xmm1, xmm_1, xmm_0, 4, AVX_256bit); // ymm1 = W[-15] + vpsrld(xmm2, xmm1, 7, AVX_256bit); + vpslld(xmm3, xmm1, 32-7, AVX_256bit); + vpor(xmm3, xmm3, xmm2, AVX_256bit); // ymm3 = W[-15] ror 7 + vpsrld(xmm2, xmm1,18, AVX_256bit); + } else if (iter%4 == 1 ) { + vpsrld(xmm8, xmm1, 3, AVX_256bit); // ymm8 = W[-15] >> 3 + vpslld(xmm1, xmm1, 32-18, AVX_256bit); + vpxor(xmm3, xmm3, xmm1, AVX_256bit); + vpxor(xmm3, xmm3, xmm2, AVX_256bit); // ymm3 = W[-15] ror 7 ^ W[-15] ror 18 + vpxor(xmm1, xmm3, xmm8, AVX_256bit); // ymm1 = s0 + vpshufd(xmm2, xmm_3, 0xFA, AVX_256bit); // 11111010b ; ymm2 = W[-2] {BBAA} + vpaddd(xmm0, xmm0, xmm1, AVX_256bit); // ymm0 = W[-16] + W[-7] + s0 + vpsrld(xmm8, xmm2, 10, AVX_256bit); // ymm8 = W[-2] >> 10 {BBAA} + } else if (iter%4 == 2) { + vpsrlq(xmm3, xmm2, 19, AVX_256bit); // ymm3 = W[-2] ror 19 {xBxA} + vpsrlq(xmm2, xmm2, 17, AVX_256bit); // ymm2 = W[-2] ror 17 {xBxA} + vpxor(xmm2, xmm2, xmm3, AVX_256bit); + vpxor(xmm8, xmm8, xmm2, AVX_256bit); // ymm8 = s1 {xBxA} + vpshufb(xmm8, xmm8, xmm10, AVX_256bit); // ymm8 = s1 {00BA} + vpaddd(xmm0, xmm0, xmm8, AVX_256bit); // ymm0 = {..., ..., W[1], W[0]} + vpshufd(xmm2, xmm0, 0x50, AVX_256bit); // 01010000b ; ymm2 = W[-2] {DDCC} + } else if (iter%4 == 3) { + vpsrld(xmm11, xmm2, 10, AVX_256bit); // ymm11 = W[-2] >> 10 {DDCC} + vpsrlq(xmm3, xmm2, 19, AVX_256bit); // ymm3 = W[-2] ror 19 {xDxC} + vpsrlq(xmm2, xmm2, 17, AVX_256bit); // ymm2 = W[-2] ror 17 {xDxC} + vpxor(xmm2, xmm2, xmm3, AVX_256bit); + vpxor(xmm11, xmm11, xmm2, AVX_256bit); // ymm11 = s1 {xDxC} + vpshufb(xmm11, xmm11, xmm12, AVX_256bit); // ymm11 = s1 {DC00} + vpaddd(xmm_0, xmm11, xmm0, AVX_256bit); // xmm_0 = {W[3], W[2], W[1], W[0]} + } +} + +void MacroAssembler::addm(int disp, Register r1, Register r2) { + addl(r2, Address(r1, disp)); + movl(Address(r1, disp), r2); +} + +void MacroAssembler::sha256_AVX2(XMMRegister msg, XMMRegister state0, XMMRegister state1, XMMRegister msgtmp0, + XMMRegister msgtmp1, XMMRegister msgtmp2, XMMRegister msgtmp3, XMMRegister msgtmp4, + Register buf, Register state, Register ofs, Register limit, Register rsp, + bool multi_block, XMMRegister shuf_mask) { + + Label loop0, loop1, loop2, loop3, + last_block_enter, do_last_block, only_one_block, done_hash, + compute_size, compute_size_end, + compute_size1, compute_size_end1; + + address K256_W = StubRoutines::x86::k256_W_addr(); + address pshuffle_byte_flip_mask = StubRoutines::x86::pshuffle_byte_flip_mask_addr(); + address pshuffle_byte_flip_mask_addr = 0; + +const XMMRegister& SHUF_00BA = xmm10; // ymm10: shuffle xBxA -> 00BA +const XMMRegister& SHUF_DC00 = xmm12; // ymm12: shuffle xDxC -> DC00 +const XMMRegister& BYTE_FLIP_MASK = xmm13; // ymm13 + +const XMMRegister& X_BYTE_FLIP_MASK = xmm13; //XMM version of BYTE_FLIP_MASK + +const Register& NUM_BLKS = r8; // 3rd arg +const Register& CTX = rdx; // 2nd arg +const Register& INP = rcx; // 1st arg + +const Register& c = rdi; +const Register& d = rsi; +const Register& e = r8; // clobbers NUM_BLKS +const Register& y3 = rcx; // clobbers INP + +const Register& TBL = rbp; +const Register& SRND = CTX; // SRND is same register as CTX + +const Register& a = rax; +const Register& b = rbx; +const Register& f = r9; +const Register& g = r10; +const Register& h = r11; + +const Register& T1 = r12; +const Register& y0 = r13; +const Register& y1 = r14; +const Register& y2 = r15; + + +enum { + _XFER_SIZE = 2*64*4, // 2 blocks, 64 rounds, 4 bytes/round +#ifndef _WIN64 + _XMM_SAVE_SIZE = 0, +#else + _XMM_SAVE_SIZE = 8*16, +#endif + _INP_END_SIZE = 8, + _INP_SIZE = 8, + _CTX_SIZE = 8, + _RSP_SIZE = 8, + + _XFER = 0, + _XMM_SAVE = _XFER + _XFER_SIZE, + _INP_END = _XMM_SAVE + _XMM_SAVE_SIZE, + _INP = _INP_END + _INP_END_SIZE, + _CTX = _INP + _INP_SIZE, + _RSP = _CTX + _CTX_SIZE, + STACK_SIZE = _RSP + _RSP_SIZE +}; + +#ifndef _WIN64 + push(rcx); // linux: this is limit, need at the end + push(rdx); // linux: this is ofs +#else + push(r8); // win64: this is ofs + push(r9); // win64: this is limit, we need them again at the very and +#endif + + + push(rbx); +#ifdef _WIN64 + push(rsi); + push(rdi); +#endif + push(rbp); + push(r12); + push(r13); + push(r14); + push(r15); + + movq(rax, rsp); + subq(rsp, STACK_SIZE); + andq(rsp, -32); + movq(Address(rsp, _RSP), rax); + +#ifndef _WIN64 + // copy linux params to win64 params, therefore the rest of code will be the same for both + movq(r9, rcx); + movq(r8, rdx); + movq(rdx, rsi); + movq(rcx, rdi); +#endif + + // setting original assembly ABI + /** message to encrypt in INP */ + lea(INP, Address(rcx, 0)); // rcx == message (buf) ;; linux: INP = buf = rdi + /** digest in CTX */ + movq(CTX, rdx); // rdx = digest (state) ;; linux: CTX = state = rsi + + /** NUM_BLK is the length of message, need to set it from ofs and limit */ + if (multi_block) { + + // Win64: cannot directly update NUM_BLKS, since NUM_BLKS = ofs = r8 + // on entry r8 = ofs + // on exit r8 = NUM_BLKS + + xorq(rax, rax); + + bind(compute_size); + cmpptr(r8, r9); // assume the original ofs <= limit ;; linux: cmp rcx, rdx + jccb(Assembler::aboveEqual, compute_size_end); + addq(r8, 64); //;; linux: ofs = rdx + addq(rax, 64); + jmpb(compute_size); + + bind(compute_size_end); + movq(NUM_BLKS, rax); // NUM_BLK (r8) ;; linux: NUM_BLK = rdx + + cmpq(NUM_BLKS, 0); + jcc(Assembler::equal, done_hash); + + } else { + xorq(NUM_BLKS, NUM_BLKS); + addq(NUM_BLKS, 64); + }//if (!multi_block) + + lea(NUM_BLKS, Address(INP, NUM_BLKS, Address::times_1, -64)); // pointer to the last block + movq(Address(rsp, _INP_END), NUM_BLKS); // + + cmpptr(INP, NUM_BLKS); //cmp INP, NUM_BLKS + jcc(Assembler::equal, only_one_block); //je only_one_block + + // load initial digest + movl(a, Address(CTX, 4*0)); + movl(b, Address(CTX, 4*1)); + movl(c, Address(CTX, 4*2)); + movl(d, Address(CTX, 4*3)); + movl(e, Address(CTX, 4*4)); + movl(f, Address(CTX, 4*5)); + movl(g, Address(CTX, 4*6)); + movl(h, Address(CTX, 4*7)); + + pshuffle_byte_flip_mask_addr = pshuffle_byte_flip_mask; + vmovdqu(BYTE_FLIP_MASK, ExternalAddress(pshuffle_byte_flip_mask_addr +0)); //[PSHUFFLE_BYTE_FLIP_MASK wrt rip] + vmovdqu(SHUF_00BA, ExternalAddress(pshuffle_byte_flip_mask_addr + 32)); //[_SHUF_00BA wrt rip] + vmovdqu(SHUF_DC00, ExternalAddress(pshuffle_byte_flip_mask_addr + 64)); //[_SHUF_DC00 wrt rip] + + movq(Address(rsp, _CTX), CTX); // store + +bind(loop0); + lea(TBL, ExternalAddress(K256_W)); + + // assume buffers not aligned + + // Load first 16 dwords from two blocks + vmovdqu(xmm0, Address(INP, 0*32)); + vmovdqu(xmm1, Address(INP, 1*32)); + vmovdqu(xmm2, Address(INP, 2*32)); + vmovdqu(xmm3, Address(INP, 3*32)); + + // byte swap data + vpshufb(xmm0, xmm0, BYTE_FLIP_MASK, AVX_256bit); + vpshufb(xmm1, xmm1, BYTE_FLIP_MASK, AVX_256bit); + vpshufb(xmm2, xmm2, BYTE_FLIP_MASK, AVX_256bit); + vpshufb(xmm3, xmm3, BYTE_FLIP_MASK, AVX_256bit); + + // transpose data into high/low halves + vperm2i128(xmm4, xmm0, xmm2, 0x20); + vperm2i128(xmm5, xmm0, xmm2, 0x31); + vperm2i128(xmm6, xmm1, xmm3, 0x20); + vperm2i128(xmm7, xmm1, xmm3, 0x31); + +bind(last_block_enter); + addq(INP, 64); + movq(Address(rsp, _INP), INP); + + //;; schedule 48 input dwords, by doing 3 rounds of 12 each + xorq(SRND, SRND); + +align(16); +bind(loop1); + vpaddd(xmm9, xmm4, Address(TBL, SRND, Address::times_1, 0*32), AVX_256bit); + vmovdqu(Address(rsp, SRND, Address::times_1, _XFER + 0*32), xmm9); + sha256_AVX2_one_round_and_sched(xmm4, xmm5, xmm6, xmm7, rax, rbx, rdi, rsi, r8, r9, r10, r11, 0); + sha256_AVX2_one_round_and_sched(xmm4, xmm5, xmm6, xmm7, r11, rax, rbx, rdi, rsi, r8, r9, r10, 1); + sha256_AVX2_one_round_and_sched(xmm4, xmm5, xmm6, xmm7, r10, r11, rax, rbx, rdi, rsi, r8, r9, 2); + sha256_AVX2_one_round_and_sched(xmm4, xmm5, xmm6, xmm7, r9, r10, r11, rax, rbx, rdi, rsi, r8, 3); + + vpaddd(xmm9, xmm5, Address(TBL, SRND, Address::times_1, 1*32), AVX_256bit); + vmovdqu(Address(rsp, SRND, Address::times_1, _XFER + 1*32), xmm9); + sha256_AVX2_one_round_and_sched(xmm5, xmm6, xmm7, xmm4, r8, r9, r10, r11, rax, rbx, rdi, rsi, 8+0); + sha256_AVX2_one_round_and_sched(xmm5, xmm6, xmm7, xmm4, rsi, r8, r9, r10, r11, rax, rbx, rdi, 8+1); + sha256_AVX2_one_round_and_sched(xmm5, xmm6, xmm7, xmm4, rdi, rsi, r8, r9, r10, r11, rax, rbx, 8+2); + sha256_AVX2_one_round_and_sched(xmm5, xmm6, xmm7, xmm4, rbx, rdi, rsi, r8, r9, r10, r11, rax, 8+3); + + vpaddd(xmm9, xmm6, Address(TBL, SRND, Address::times_1, 2*32), AVX_256bit); + vmovdqu(Address(rsp, SRND, Address::times_1, _XFER + 2*32), xmm9); + sha256_AVX2_one_round_and_sched(xmm6, xmm7, xmm4, xmm5, rax, rbx, rdi, rsi, r8, r9, r10, r11, 16+0); + sha256_AVX2_one_round_and_sched(xmm6, xmm7, xmm4, xmm5, r11, rax, rbx, rdi, rsi, r8, r9, r10, 16+1); + sha256_AVX2_one_round_and_sched(xmm6, xmm7, xmm4, xmm5, r10, r11, rax, rbx, rdi, rsi, r8, r9, 16+2); + sha256_AVX2_one_round_and_sched(xmm6, xmm7, xmm4, xmm5, r9, r10, r11, rax, rbx, rdi, rsi, r8, 16+3); + + vpaddd(xmm9, xmm7, Address(TBL, SRND, Address::times_1, 3*32), AVX_256bit); + vmovdqu(Address(rsp, SRND, Address::times_1, _XFER + 3*32), xmm9); + + sha256_AVX2_one_round_and_sched(xmm7, xmm4, xmm5, xmm6, r8, r9, r10, r11, rax, rbx, rdi, rsi, 24+0); + sha256_AVX2_one_round_and_sched(xmm7, xmm4, xmm5, xmm6, rsi, r8, r9, r10, r11, rax, rbx, rdi, 24+1); + sha256_AVX2_one_round_and_sched(xmm7, xmm4, xmm5, xmm6, rdi, rsi, r8, r9, r10, r11, rax, rbx, 24+2); + sha256_AVX2_one_round_and_sched(xmm7, xmm4, xmm5, xmm6, rbx, rdi, rsi, r8, r9, r10, r11, rax, 24+3); + + addq(SRND, 4*32); + cmpq(SRND, 3 * 4*32); + jcc(Assembler::below, loop1); + +bind(loop2); + // Do last 16 rounds with no scheduling + vpaddd(xmm9, xmm4, Address(TBL, SRND, Address::times_1, 0*32), AVX_256bit); + vmovdqu(Address(rsp, SRND, Address::times_1, _XFER + 0*32), xmm9); + sha256_AVX2_four_rounds_compute_first(0); + + vpaddd(xmm9, xmm5, Address(TBL, SRND, Address::times_1, 1*32), AVX_256bit); + vmovdqu(Address(rsp, SRND, Address::times_1, _XFER + 1*32), xmm9); + sha256_AVX2_four_rounds_compute_last(0 + 8); + + addq(SRND, 2*32); + + vmovdqu(xmm4, xmm6); + vmovdqu(xmm5, xmm7); + + cmpq(SRND, 4 * 4*32); + jcc(Assembler::below, loop2); + + movq(CTX, Address(rsp, _CTX)); + movq(INP, Address(rsp, _INP)); + + addm(4*0, CTX, a); + addm(4*1, CTX, b); + addm(4*2, CTX, c); + addm(4*3, CTX, d); + addm(4*4, CTX, e); + addm(4*5, CTX, f); + addm(4*6, CTX, g); + addm(4*7, CTX, h); + + cmpq(INP, Address(rsp, _INP_END)); + jcc(Assembler::above, done_hash); + + //Do second block using previously scheduled results + xorq(SRND, SRND); +align(16); +bind(loop3); + sha256_AVX2_four_rounds_compute_first(4); + sha256_AVX2_four_rounds_compute_last(4+8); + + addq(SRND, 2*32); + cmpq(SRND, 4 * 4*32); + jcc(Assembler::below, loop3); + + movq(CTX, Address(rsp, _CTX)); + movq(INP, Address(rsp, _INP)); + addq(INP, 64); + + addm(4*0, CTX, a); + addm(4*1, CTX, b); + addm(4*2, CTX, c); + addm(4*3, CTX, d); + addm(4*4, CTX, e); + addm(4*5, CTX, f); + addm(4*6, CTX, g); + addm(4*7, CTX, h); + + cmpq(INP, Address(rsp, _INP_END)); + jcc(Assembler::below, loop0); + jccb(Assembler::above, done_hash); + +bind(do_last_block); + lea(TBL, ExternalAddress(K256_W)); + + movdqu(xmm4, Address(INP, 0*16)); + movdqu(xmm5, Address(INP, 1*16)); + movdqu(xmm6, Address(INP, 2*16)); + movdqu(xmm7, Address(INP, 3*16)); + + vpshufb(xmm4, xmm4, xmm13, AVX_128bit); + vpshufb(xmm5, xmm5, xmm13, AVX_128bit); + vpshufb(xmm6, xmm6, xmm13, AVX_128bit); + vpshufb(xmm7, xmm7, xmm13, AVX_128bit); + + jmp(last_block_enter); + +bind(only_one_block); + + // load initial digest ;; table should be preloaded with following values + movl(a, Address(CTX, 4*0)); // 0x6a09e667 + movl(b, Address(CTX, 4*1)); // 0xbb67ae85 + movl(c, Address(CTX, 4*2)); // 0x3c6ef372 + movl(d, Address(CTX, 4*3)); // 0xa54ff53a + movl(e, Address(CTX, 4*4)); // 0x510e527f + movl(f, Address(CTX, 4*5)); // 0x9b05688c + movl(g, Address(CTX, 4*6)); // 0x1f83d9ab + movl(h, Address(CTX, 4*7)); // 0x5be0cd19 + + + pshuffle_byte_flip_mask_addr = pshuffle_byte_flip_mask; + vmovdqu(BYTE_FLIP_MASK, ExternalAddress(pshuffle_byte_flip_mask_addr + 0)); //[PSHUFFLE_BYTE_FLIP_MASK wrt rip] + vmovdqu(SHUF_00BA, ExternalAddress(pshuffle_byte_flip_mask_addr + 32)); //[_SHUF_00BA wrt rip] + vmovdqu(SHUF_DC00, ExternalAddress(pshuffle_byte_flip_mask_addr + 64)); //[_SHUF_DC00 wrt rip] + + movq(Address(rsp, _CTX), CTX); + jmpb(do_last_block); + +bind(done_hash); + + movq(rsp, Address(rsp, _RSP)); + + pop(r15); + pop(r14); + pop(r13); + pop(r12); + pop(rbp); +#ifdef _WIN64 + pop(rdi); + pop(rsi); +#endif + pop(rbx); + +#ifdef _WIN64 + pop(r9); + pop(r8); +#else + pop(rdx); + pop(rcx); +#endif + + if (multi_block) { +#ifdef _WIN64 +const Register& limit_end = r9; +const Register& ofs_end = r8; +#else +const Register& limit_end = rcx; +const Register& ofs_end = rdx; +#endif + movq(rax, ofs_end); + +bind(compute_size1); + cmpptr(rax, limit_end); // assume the original ofs <= limit + jccb(Assembler::aboveEqual, compute_size_end1); + addq(rax, 64); + jmpb(compute_size1); + +bind(compute_size_end1); + } +} +#endif //#ifdef _LP64 diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp index 0c3be673c71..3d8acc78947 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp @@ -3771,12 +3771,29 @@ class StubGenerator: public StubCodeGenerator { address start = __ pc(); __ emit_data64(0x0405060700010203, relocInfo::none); __ emit_data64(0x0c0d0e0f08090a0b, relocInfo::none); + + if (VM_Version::supports_avx2()) { + __ emit_data64(0x0405060700010203, relocInfo::none); // second copy + __ emit_data64(0x0c0d0e0f08090a0b, relocInfo::none); + // _SHUF_00BA + __ emit_data64(0x0b0a090803020100, relocInfo::none); + __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none); + __ emit_data64(0x0b0a090803020100, relocInfo::none); + __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none); + // _SHUF_DC00 + __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none); + __ emit_data64(0x0b0a090803020100, relocInfo::none); + __ emit_data64(0xFFFFFFFFFFFFFFFF, relocInfo::none); + __ emit_data64(0x0b0a090803020100, relocInfo::none); + } + return start; } // ofs and limit are use for multi-block byte array. // int com.sun.security.provider.DigestBase.implCompressMultiBlock(byte[] b, int ofs, int limit) address generate_sha256_implCompress(bool multi_block, const char *name) { + assert(VM_Version::supports_sha() || VM_Version::supports_avx2(), ""); __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", name); address start = __ pc(); @@ -3805,16 +3822,37 @@ class StubGenerator: public StubCodeGenerator { __ movdqu(Address(rsp, 0), xmm6); __ movdqu(Address(rsp, 2 * wordSize), xmm7); __ movdqu(Address(rsp, 4 * wordSize), xmm8); + + if (!VM_Version::supports_sha() && VM_Version::supports_avx2()) { + __ subptr(rsp, 10 * wordSize); + __ movdqu(Address(rsp, 0), xmm9); + __ movdqu(Address(rsp, 2 * wordSize), xmm10); + __ movdqu(Address(rsp, 4 * wordSize), xmm11); + __ movdqu(Address(rsp, 6 * wordSize), xmm12); + __ movdqu(Address(rsp, 8 * wordSize), xmm13); + } #endif __ subptr(rsp, 4 * wordSize); - __ fast_sha256(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4, - buf, state, ofs, limit, rsp, multi_block, shuf_mask); - + if (VM_Version::supports_sha()) { + __ fast_sha256(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4, + buf, state, ofs, limit, rsp, multi_block, shuf_mask); + } else if (VM_Version::supports_avx2()) { + __ sha256_AVX2(msg, state0, state1, msgtmp0, msgtmp1, msgtmp2, msgtmp3, msgtmp4, + buf, state, ofs, limit, rsp, multi_block, shuf_mask); + } __ addptr(rsp, 4 * wordSize); #ifdef _WIN64 // restore xmm regs belonging to calling function + if (!VM_Version::supports_sha() && VM_Version::supports_avx2()) { + __ movdqu(xmm9, Address(rsp, 0)); + __ movdqu(xmm10, Address(rsp, 2 * wordSize)); + __ movdqu(xmm11, Address(rsp, 4 * wordSize)); + __ movdqu(xmm12, Address(rsp, 6 * wordSize)); + __ movdqu(xmm13, Address(rsp, 8 * wordSize)); + __ addptr(rsp, 10 * wordSize); + } __ movdqu(xmm6, Address(rsp, 0)); __ movdqu(xmm7, Address(rsp, 2 * wordSize)); __ movdqu(xmm8, Address(rsp, 4 * wordSize)); @@ -5217,6 +5255,13 @@ class StubGenerator: public StubCodeGenerator { } if (UseSHA256Intrinsics) { StubRoutines::x86::_k256_adr = (address)StubRoutines::x86::_k256; + char* dst = (char*)StubRoutines::x86::_k256_W; + char* src = (char*)StubRoutines::x86::_k256; + for (int ii = 0; ii < 16; ++ii) { + memcpy(dst + 32 * ii, src + 16 * ii, 16); + memcpy(dst + 32 * ii + 16, src + 16 * ii, 16); + } + StubRoutines::x86::_k256_W_adr = (address)StubRoutines::x86::_k256_W; StubRoutines::x86::_pshuffle_byte_flip_mask_addr = generate_pshuffle_byte_flip_mask(); StubRoutines::_sha256_implCompress = generate_sha256_implCompress(false, "sha256_implCompress"); StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true, "sha256_implCompressMB"); diff --git a/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp b/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp index 7d723a39624..ea7952e9660 100644 --- a/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp +++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86.cpp @@ -46,6 +46,9 @@ address StubRoutines::x86::_ghash_byte_swap_mask_addr = NULL; address StubRoutines::x86::_upper_word_mask_addr = NULL; address StubRoutines::x86::_shuffle_byte_flip_mask_addr = NULL; address StubRoutines::x86::_k256_adr = NULL; +#ifdef _LP64 +address StubRoutines::x86::_k256_W_adr = NULL; +#endif address StubRoutines::x86::_pshuffle_byte_flip_mask_addr = NULL; //tables common for sin and cos @@ -289,3 +292,9 @@ ALIGNED_(64) juint StubRoutines::x86::_k256[] = 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL }; + +#ifdef _LP64 +// used in MacroAssembler::sha256_AVX2 +// dynamically built from _k256 +ALIGNED_(64) juint StubRoutines::x86::_k256_W[2*sizeof(StubRoutines::x86::_k256)]; +#endif diff --git a/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp b/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp index 34020920eae..eeceb0169ee 100644 --- a/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp +++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86.hpp @@ -54,6 +54,10 @@ //k256 table for sha256 static juint _k256[]; static address _k256_adr; +#ifdef _LP64 + static juint _k256_W[]; + static address _k256_W_adr; +#endif // byte flip mask for sha256 static address _pshuffle_byte_flip_mask_addr; @@ -109,6 +113,9 @@ static address upper_word_mask_addr() { return _upper_word_mask_addr; } static address shuffle_byte_flip_mask_addr() { return _shuffle_byte_flip_mask_addr; } static address k256_addr() { return _k256_adr; } +#ifdef _LP64 + static address k256_W_addr() { return _k256_W_adr; } +#endif static address pshuffle_byte_flip_mask_addr() { return _pshuffle_byte_flip_mask_addr; } static void generate_CRC32C_table(bool is_pclmulqdq_supported); static address _ONEHALF_addr() { return _ONEHALF_adr; } diff --git a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp index 6d871ce92de..65acaffe4cf 100644 --- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp +++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp @@ -732,7 +732,7 @@ void VM_Version::get_processor_features() { FLAG_SET_DEFAULT(UseGHASHIntrinsics, false); } - if (supports_sha()) { + if (supports_sha() LP64_ONLY(|| supports_avx2() && supports_bmi2())) { if (FLAG_IS_DEFAULT(UseSHA)) { UseSHA = true; } @@ -741,7 +741,7 @@ void VM_Version::get_processor_features() { FLAG_SET_DEFAULT(UseSHA, false); } - if (UseSHA) { + if (supports_sha() && UseSHA) { if (FLAG_IS_DEFAULT(UseSHA1Intrinsics)) { FLAG_SET_DEFAULT(UseSHA1Intrinsics, true); } diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java index 2014ab5c2e1..2caa1f59d6e 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,9 @@ import jdk.test.lib.ExitCode; import jdk.test.lib.Platform; import jdk.test.lib.cli.CommandLineOptionTest; +import jdk.test.lib.cli.predicate.AndPredicate; import jdk.test.lib.cli.predicate.OrPredicate; +import jdk.test.lib.cli.predicate.NotPredicate; /** * Generic test case for SHA-related options targeted to X86 CPUs that don't @@ -33,21 +35,14 @@ import jdk.test.lib.cli.predicate.OrPredicate; public class GenericTestCaseForUnsupportedX86CPU extends SHAOptionsBase.TestCase { public GenericTestCaseForUnsupportedX86CPU(String optionName) { - super(optionName, new OrPredicate(Platform::isX64, Platform::isX86)); + super(optionName, new AndPredicate(new OrPredicate(Platform::isX64, Platform::isX86), + new NotPredicate(SHAOptionsBase.getPredicateForOption( + optionName)))); } @Override protected void verifyWarnings() throws Throwable { - String shouldPassMessage = String.format("JVM should start with '-XX:+" - + "%s' flag, but output should contain warning.", optionName); - // Verify that when the tested option is explicitly enabled, then - // a warning will occur in VM output. - CommandLineOptionTest.verifySameJVMStartup(new String[] { - SHAOptionsBase.getWarningForUnsupportedCPU(optionName) - }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK, - CommandLineOptionTest.prepareBooleanFlag(optionName, true)); - - shouldPassMessage = String.format("JVM should start with '-XX:-%s' " + String shouldPassMessage = String.format("JVM should start with '-XX:-%s' " + "flag without any warnings", optionName); // Verify that the tested option could be explicitly disabled without // a warning. @@ -55,6 +50,19 @@ public class GenericTestCaseForUnsupportedX86CPU SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, shouldPassMessage, shouldPassMessage, ExitCode.OK, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); + + // Verify that when the tested option is enabled, then + // a warning will occur in VM output if UseSHA is disabled. + if (!optionName.equals(SHAOptionsBase.USE_SHA_OPTION)) { + CommandLineOptionTest.verifySameJVMStartup( + new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, + null, + shouldPassMessage, + shouldPassMessage, + ExitCode.OK, + CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false), + CommandLineOptionTest.prepareBooleanFlag(optionName, true)); + } } @Override diff --git a/hotspot/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java b/hotspot/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java index 5f423d38a2c..8d33ad65e45 100644 --- a/hotspot/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java +++ b/hotspot/test/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java @@ -59,14 +59,23 @@ public class IntrinsicPredicates { }; public static final BooleanSupplier SHA1_INSTRUCTION_AVAILABLE - = new OrPredicate( - new CPUSpecificPredicate("sparc.*", new String[] { "sha1" },null), - new CPUSpecificPredicate("aarch64.*", new String[] { "sha1" },null)); + = new OrPredicate(new CPUSpecificPredicate("x86.*", new String[] { "sha" },null), + new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "sha" },null), + new OrPredicate(new CPUSpecificPredicate("i386.*", new String[] { "sha" },null), + new OrPredicate( + new CPUSpecificPredicate("sparc.*", new String[] { "sha1" },null), + new CPUSpecificPredicate("aarch64.*", new String[] { "sha1" },null))))); public static final BooleanSupplier SHA256_INSTRUCTION_AVAILABLE - = new OrPredicate( - new CPUSpecificPredicate("sparc.*", new String[] { "sha256" },null), - new CPUSpecificPredicate("aarch64.*", new String[] { "sha256" },null)); + = new OrPredicate(new CPUSpecificPredicate("x86.*", new String[] { "sha" },null), + new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "sha" },null), + new OrPredicate(new CPUSpecificPredicate("i386.*", new String[] { +"sha" },null), + new OrPredicate(new CPUSpecificPredicate("x86_64", new String[] { "avx2", "bmi2" }, null), + new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] { "avx2", "bmi2" }, null), + new OrPredicate( + new CPUSpecificPredicate("sparc.*", new String[] { "sha256" },null), + new CPUSpecificPredicate("aarch64.*", new String[] { "sha256" },null))))))); public static final BooleanSupplier SHA512_INSTRUCTION_AVAILABLE = new OrPredicate( diff --git a/hotspot/test/testlibrary/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java b/hotspot/test/testlibrary/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java index 48306619f55..228c0270a5b 100644 --- a/hotspot/test/testlibrary/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java +++ b/hotspot/test/testlibrary/jdk/test/lib/cli/predicate/CPUSpecificPredicate.java @@ -44,7 +44,7 @@ public class CPUSpecificPredicate implements BooleanSupplier { @Override public boolean getAsBoolean() { if (!Platform.getOsArch().matches(cpuArchPattern)) { - System.out.println("CPU arch does not match " + cpuArchPattern); + System.out.println("CPU arch " + Platform.getOsArch() + " does not match " + cpuArchPattern); return false; } -- GitLab From 23ce249250a238ef022acd9d935a3e979c906f3d Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Wed, 27 Apr 2016 01:14:07 -0700 Subject: [PATCH 204/400] 8154939: 8153998 broke vectorization on aarch64 Reviewed-by: kvn, mcberg --- hotspot/src/share/vm/opto/superword.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/opto/superword.cpp b/hotspot/src/share/vm/opto/superword.cpp index 8367e81b0e9..f3a6539a2d2 100644 --- a/hotspot/src/share/vm/opto/superword.cpp +++ b/hotspot/src/share/vm/opto/superword.cpp @@ -119,7 +119,7 @@ void SuperWord::transform_loop(IdealLoopTree* lpt, bool do_optimization) { // skip any loop that has not been assigned max unroll by analysis if (do_optimization) { - if (cl->slp_max_unroll() == 0) return; + if (SuperWordLoopUnrollAnalysis && cl->slp_max_unroll() == 0) return; } // Check for no control flow in body (other than exit) -- GitLab From 15893e995b2326aaa592ad14ec38a82acce0ee04 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Mon, 25 Apr 2016 15:14:02 +0200 Subject: [PATCH 205/400] 8155015: Aarch64: bad assert in spill generation code Reviewed-by: thartmann --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index c2742a49e1e..f149ff30a83 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -3077,7 +3077,7 @@ uint MachSpillCopyNode::implementation(CodeBuffer *cbuf, PhaseRegAlloc *ra_, boo assert((src_lo_rc != rc_int && dst_lo_rc != rc_int), "sanity"); if (src_lo_rc == rc_stack && dst_lo_rc == rc_stack) { // stack->stack - assert((src_offset & 7) && (dst_offset & 7), "unaligned stack offset"); + assert((src_offset & 7) == 0 && (dst_offset & 7) == 0, "unaligned stack offset"); if (ireg == Op_VecD) { __ unspill(rscratch1, true, src_offset); __ spill(rscratch1, true, dst_offset); -- GitLab From 5619a7209c1b1e5f235b4c3e1e91ed55e3f7afa2 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Mon, 25 Apr 2016 12:11:58 -0700 Subject: [PATCH 206/400] 8154379: MIN_STACK_SHADOW_PAGES should equal DEFAULT_STACK_SHADOW_PAGES on aarch64 Undid previous change that had set it to 1. Reviewed-by: enevill, adinn, aph --- hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp index 5bd7424d4b8..fc768385179 100644 --- a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp @@ -48,9 +48,9 @@ define_pd_global(intx, InlineFrequencyCount, 100); #define DEFAULT_STACK_SHADOW_PAGES (4 DEBUG_ONLY(+5)) #define DEFAULT_STACK_RESERVED_PAGES (0) -#define MIN_STACK_YELLOW_PAGES 1 -#define MIN_STACK_RED_PAGES 1 -#define MIN_STACK_SHADOW_PAGES 1 +#define MIN_STACK_YELLOW_PAGES DEFAULT_STACK_YELLOW_PAGES +#define MIN_STACK_RED_PAGES DEFAULT_STACK_RED_PAGES +#define MIN_STACK_SHADOW_PAGES DEFAULT_STACK_SHADOW_PAGES #define MIN_STACK_RESERVED_PAGES (0) define_pd_global(intx, StackYellowPages, DEFAULT_STACK_YELLOW_PAGES); -- GitLab From 41a5d2d4305b6da5a822604f2aa8d4aab883a84c Mon Sep 17 00:00:00 2001 From: Antonios Printezis Date: Tue, 26 Apr 2016 10:19:57 +0200 Subject: [PATCH 207/400] 8154153: PS: Restore preserved marks in parallel Restore preserved marks after evacuation failure in parallel using the PreservedMark infrastructure. Reviewed-by: tschatzl --- .../vm/gc/parallel/psPromotionManager.cpp | 4 ++ .../vm/gc/parallel/psPromotionManager.hpp | 4 +- .../src/share/vm/gc/parallel/psScavenge.cpp | 2 +- .../src/share/vm/gc/shared/preservedMarks.cpp | 42 +++++++++++++++++-- .../src/share/vm/gc/shared/preservedMarks.hpp | 12 +++--- 5 files changed, 53 insertions(+), 11 deletions(-) diff --git a/hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp b/hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp index a5bf57903d4..bdd965bd5b6 100644 --- a/hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp +++ b/hotspot/src/share/vm/gc/parallel/psPromotionManager.cpp @@ -237,6 +237,10 @@ void PSPromotionManager::register_preserved_marks(PreservedMarks* preserved_mark _preserved_marks = preserved_marks; } +void PSPromotionManager::restore_preserved_marks() { + _preserved_marks_set->restore(PSScavenge::gc_task_manager()); +} + void PSPromotionManager::drain_stacks_depth(bool totally_drain) { totally_drain = totally_drain || _totally_drain; diff --git a/hotspot/src/share/vm/gc/parallel/psPromotionManager.hpp b/hotspot/src/share/vm/gc/parallel/psPromotionManager.hpp index 32159e6a48c..0946f10d664 100644 --- a/hotspot/src/share/vm/gc/parallel/psPromotionManager.hpp +++ b/hotspot/src/share/vm/gc/parallel/psPromotionManager.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -180,7 +180,7 @@ class PSPromotionManager VALUE_OBJ_CLASS_SPEC { void reset(); void register_preserved_marks(PreservedMarks* preserved_marks); - static void restore_preserved_marks() { _preserved_marks_set->restore(); } + static void restore_preserved_marks(); void flush_labs(); void drain_stacks(bool totally_drain) { diff --git a/hotspot/src/share/vm/gc/parallel/psScavenge.cpp b/hotspot/src/share/vm/gc/parallel/psScavenge.cpp index b027d68fa70..82caad39008 100644 --- a/hotspot/src/share/vm/gc/parallel/psScavenge.cpp +++ b/hotspot/src/share/vm/gc/parallel/psScavenge.cpp @@ -443,7 +443,7 @@ bool PSScavenge::invoke_no_policy() { promotion_failure_occurred = PSPromotionManager::post_scavenge(_gc_tracer); if (promotion_failure_occurred) { clean_up_failed_promotion(); - log_info(gc)("Promotion failed"); + log_info(gc, promotion)("Promotion failed"); } _gc_tracer.report_tenuring_threshold(tenuring_threshold()); diff --git a/hotspot/src/share/vm/gc/shared/preservedMarks.cpp b/hotspot/src/share/vm/gc/shared/preservedMarks.cpp index 96d124e2259..c1a2729fc36 100644 --- a/hotspot/src/share/vm/gc/shared/preservedMarks.cpp +++ b/hotspot/src/share/vm/gc/shared/preservedMarks.cpp @@ -23,9 +23,11 @@ */ #include "precompiled.hpp" +#include "gc/parallel/gcTaskManager.hpp" #include "gc/shared/preservedMarks.inline.hpp" #include "gc/shared/workgroup.hpp" #include "memory/allocation.inline.hpp" +#include "memory/resourceArea.hpp" void PreservedMarks::restore() { while (!_stack.is_empty()) { @@ -106,9 +108,43 @@ void PreservedMarksSet::restore_internal(WorkGang* workers, workers->run_task(&task); } -// temporary, used by PS -void PreservedMarksSet::restore() { - restore(NULL); +class ParRestoreGCTask : public GCTask { +private: + const uint _id; + PreservedMarksSet* const _preserved_marks_set; + volatile size_t* const _total_size_addr; + +public: + virtual char* name() { return (char*) "preserved mark restoration task"; } + + virtual void do_it(GCTaskManager* manager, uint which) { + PreservedMarks* const preserved_marks = _preserved_marks_set->get(_id); + const size_t size = preserved_marks->size(); + preserved_marks->restore(); + // Only do the atomic add if the size is > 0. + if (size > 0) { + Atomic::add(size, _total_size_addr); + } + } + + ParRestoreGCTask(uint id, + PreservedMarksSet* preserved_marks_set, + volatile size_t* total_size_addr) + : _id(id), + _preserved_marks_set(preserved_marks_set), + _total_size_addr(total_size_addr) { } +}; + +void PreservedMarksSet::restore_internal(GCTaskManager* gc_task_manager, + volatile size_t* total_size_addr) { + // GCTask / GCTaskQueue are ResourceObjs + ResourceMark rm; + + GCTaskQueue* q = GCTaskQueue::create(); + for (uint i = 0; i < num(); i += 1) { + q->enqueue(new ParRestoreGCTask(i, this, total_size_addr)); + } + gc_task_manager->execute_and_wait(q); } void PreservedMarksSet::reclaim() { diff --git a/hotspot/src/share/vm/gc/shared/preservedMarks.hpp b/hotspot/src/share/vm/gc/shared/preservedMarks.hpp index 6ab52ba0fb4..fdda6f97f7a 100644 --- a/hotspot/src/share/vm/gc/shared/preservedMarks.hpp +++ b/hotspot/src/share/vm/gc/shared/preservedMarks.hpp @@ -44,6 +44,7 @@ public: }; typedef Stack OopAndMarkOopStack; +class GCTaskManager; class WorkGang; class PreservedMarks VALUE_OBJ_CLASS_SPEC { @@ -93,6 +94,10 @@ private: // Internal version of restore() that uses a WorkGang for parallelism. void restore_internal(WorkGang* workers, volatile size_t* total_size_addr); + // Internal version of restore() that uses a GCTaskManager for parallelism. + void restore_internal(GCTaskManager* gc_task_manager, + volatile size_t* total_size_addr); + public: uint num() const { return _num; } @@ -110,14 +115,11 @@ public: // the memory taken up by the stack segments. If the executor is // NULL, restoration will be done serially. If the executor is not // NULL, restoration could be done in parallel (when it makes - // sense). Supported executors: WorkGang (Serial, CMS, G1) + // sense). Supported executors: WorkGang (Serial, CMS, G1), + // GCTaskManager (PS). template inline void restore(E* executor); - // Do the restoration serially. Temporary, to be used by PS until we - // can support GCTaskManager in restore(E*). - void restore(); - // Reclaim stack array. void reclaim(); -- GitLab From 76adc93577fdd714adf0110e1af4f70fabea439b Mon Sep 17 00:00:00 2001 From: Antonios Printezis Date: Tue, 26 Apr 2016 10:23:08 +0200 Subject: [PATCH 208/400] 8151556: Use the PreservedMarks* classes for the G1 preserved mark stacks Reviewed-by: tschatzl --- .../src/share/vm/gc/g1/g1CollectedHeap.cpp | 25 ++++++----------- .../src/share/vm/gc/g1/g1CollectedHeap.hpp | 8 ++---- hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp | 16 ++--------- hotspot/src/share/vm/gc/g1/g1EvacFailure.hpp | 9 ------ .../src/share/vm/gc/shared/preservedMarks.hpp | 28 +++++++++---------- 5 files changed, 26 insertions(+), 60 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index d88d15e46bb..e122e56b509 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -65,6 +65,7 @@ #include "gc/shared/gcTraceTime.inline.hpp" #include "gc/shared/generationSpec.hpp" #include "gc/shared/isGCActiveMark.hpp" +#include "gc/shared/preservedMarks.inline.hpp" #include "gc/shared/referenceProcessor.inline.hpp" #include "gc/shared/taskqueue.inline.hpp" #include "logging/log.hpp" @@ -1759,6 +1760,7 @@ G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* collector_policy) : _cg1r(NULL), _g1mm(NULL), _refine_cte_cl(NULL), + _preserved_marks_set(true /* in_c_heap */), _secondary_free_list("Secondary Free List", new SecondaryFreeRegionListMtSafeChecker()), _old_set("Old Set", false /* humongous */, new OldRegionSetMtSafeChecker()), _humongous_set("Master Humongous Set", true /* humongous */, new HumongousRegionSetMtSafeChecker()), @@ -2034,10 +2036,7 @@ jint G1CollectedHeap::initialize() { G1StringDedup::initialize(); - _preserved_objs = NEW_C_HEAP_ARRAY(OopAndMarkOopStack, ParallelGCThreads, mtGC); - for (uint i = 0; i < ParallelGCThreads; i++) { - new (&_preserved_objs[i]) OopAndMarkOopStack(); - } + _preserved_marks_set.init(ParallelGCThreads); return JNI_OK; } @@ -3527,11 +3526,6 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { return true; } -void G1CollectedHeap::restore_preserved_marks() { - G1RestorePreservedMarksTask rpm_task(_preserved_objs); - workers()->run_task(&rpm_task); -} - void G1CollectedHeap::remove_self_forwarding_pointers() { G1ParRemoveSelfForwardPtrsTask rsfp_task; workers()->run_task(&rsfp_task); @@ -3541,7 +3535,7 @@ void G1CollectedHeap::restore_after_evac_failure() { double remove_self_forwards_start = os::elapsedTime(); remove_self_forwarding_pointers(); - restore_preserved_marks(); + _preserved_marks_set.restore(workers()); g1_policy()->phase_times()->record_evac_fail_remove_self_forwards((os::elapsedTime() - remove_self_forwards_start) * 1000.0); } @@ -3552,13 +3546,7 @@ void G1CollectedHeap::preserve_mark_during_evac_failure(uint worker_id, oop obj, } _evacuation_failed_info_array[worker_id].register_copy_failure(obj->size()); - - // We want to call the "for_promotion_failure" version only in the - // case of a promotion failure. - if (m->must_be_preserved_for_promotion_failure(obj)) { - OopAndMarkOop elem(obj, m); - _preserved_objs[worker_id].push(elem); - } + _preserved_marks_set.get(worker_id)->push_if_necessary(obj, m); } bool G1ParEvacuateFollowersClosure::offer_termination() { @@ -4581,6 +4569,7 @@ void G1CollectedHeap::pre_evacuate_collection_set() { hot_card_cache->set_use_cache(false); g1_rem_set()->prepare_for_oops_into_collection_set_do(); + _preserved_marks_set.assert_empty(); } void G1CollectedHeap::evacuate_collection_set(EvacuationInfo& evacuation_info, G1ParScanThreadStateSet* per_thread_states) { @@ -4658,6 +4647,8 @@ void G1CollectedHeap::post_evacuate_collection_set(EvacuationInfo& evacuation_in NOT_PRODUCT(reset_evacuation_should_fail();) } + _preserved_marks_set.assert_empty(); + // Enqueue any remaining references remaining on the STW // reference processor's discovered lists. We need to do // this after the card table is cleaned (and verified) as diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp index 61620d43c9e..ddae29c9f59 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp @@ -45,6 +45,7 @@ #include "gc/shared/barrierSet.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/plab.hpp" +#include "gc/shared/preservedMarks.hpp" #include "memory/memRegion.hpp" #include "utilities/stack.hpp" @@ -797,16 +798,11 @@ protected: // forwarding pointers to themselves. Reset them. void remove_self_forwarding_pointers(); - // Restore the preserved mark words for objects with self-forwarding pointers. - void restore_preserved_marks(); - // Restore the objects in the regions in the collection set after an // evacuation failure. void restore_after_evac_failure(); - // Stores marks with the corresponding oop that we need to preserve during evacuation - // failure. - OopAndMarkOopStack* _preserved_objs; + PreservedMarksSet _preserved_marks_set; // Preserve the mark of "obj", if necessary, in preparation for its mark // word being overwritten with a self-forwarding-pointer. diff --git a/hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp b/hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp index 1b52407c64b..f6c7371de6e 100644 --- a/hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp +++ b/hotspot/src/share/vm/gc/g1/g1EvacFailure.cpp @@ -33,6 +33,7 @@ #include "gc/g1/g1_globals.hpp" #include "gc/g1/heapRegion.hpp" #include "gc/g1/heapRegionRemSet.hpp" +#include "gc/shared/preservedMarks.inline.hpp" class UpdateRSetDeferred : public OopsInHeapRegionClosure { private: @@ -122,7 +123,7 @@ public: size_t obj_size = obj->size(); _marked_bytes += (obj_size * HeapWordSize); - obj->set_mark(markOopDesc::prototype()); + PreservedMarks::init_forwarded_mark(obj); // While we were processing RSet buffers during the collection, // we actually didn't scan any cards on the collection set, @@ -253,16 +254,3 @@ void G1ParRemoveSelfForwardPtrsTask::work(uint worker_id) { HeapRegion* hr = _g1h->start_cset_region_for_worker(worker_id); _g1h->collection_set_iterate_from(hr, &rsfp_cl); } - -G1RestorePreservedMarksTask::G1RestorePreservedMarksTask(OopAndMarkOopStack* preserved_objs) : - AbstractGangTask("G1 Restore Preserved Marks"), - _preserved_objs(preserved_objs) {} - -void G1RestorePreservedMarksTask::work(uint worker_id) { - OopAndMarkOopStack& cur = _preserved_objs[worker_id]; - while (!cur.is_empty()) { - OopAndMarkOop elem = cur.pop(); - elem.set_mark(); - } - cur.clear(true); -} diff --git a/hotspot/src/share/vm/gc/g1/g1EvacFailure.hpp b/hotspot/src/share/vm/gc/g1/g1EvacFailure.hpp index eff37e8ae44..9e1945efdd9 100644 --- a/hotspot/src/share/vm/gc/g1/g1EvacFailure.hpp +++ b/hotspot/src/share/vm/gc/g1/g1EvacFailure.hpp @@ -27,7 +27,6 @@ #include "gc/g1/g1OopClosures.hpp" #include "gc/g1/heapRegionManager.hpp" - #include "gc/shared/preservedMarks.hpp" #include "gc/shared/workgroup.hpp" #include "utilities/globalDefinitions.hpp" @@ -46,12 +45,4 @@ public: void work(uint worker_id); }; -class G1RestorePreservedMarksTask : public AbstractGangTask { - OopAndMarkOopStack* _preserved_objs; - public: - G1RestorePreservedMarksTask(OopAndMarkOopStack* preserved_objs); - - void work(uint worker_id); -}; - #endif // SHARE_VM_GC_G1_G1EVACFAILURE_HPP diff --git a/hotspot/src/share/vm/gc/shared/preservedMarks.hpp b/hotspot/src/share/vm/gc/shared/preservedMarks.hpp index fdda6f97f7a..3c8ebd87cab 100644 --- a/hotspot/src/share/vm/gc/shared/preservedMarks.hpp +++ b/hotspot/src/share/vm/gc/shared/preservedMarks.hpp @@ -30,25 +30,25 @@ #include "oops/oop.hpp" #include "utilities/stack.hpp" -class OopAndMarkOop { -private: - oop _o; - markOop _m; - -public: - OopAndMarkOop(oop obj, markOop m) : _o(obj), _m(m) { } - - void set_mark() const { - _o->set_mark(_m); - } -}; -typedef Stack OopAndMarkOopStack; - class GCTaskManager; class WorkGang; class PreservedMarks VALUE_OBJ_CLASS_SPEC { private: + class OopAndMarkOop { + private: + oop _o; + markOop _m; + + public: + OopAndMarkOop(oop obj, markOop m) : _o(obj), _m(m) { } + + void set_mark() const { + _o->set_mark(_m); + } + }; + typedef Stack OopAndMarkOopStack; + OopAndMarkOopStack _stack; inline bool should_preserve_mark(oop obj, markOop m) const; -- GitLab From d58feb9912dadf1e113b8c2fe0e5610c38846c46 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Tue, 26 Apr 2016 10:58:03 +0200 Subject: [PATCH 209/400] 8154719: JvmtiBreakpoint rename method print() to print_on() Reviewed-by: mlarsson, sla, sspitsyn --- hotspot/src/share/vm/prims/jvmtiImpl.cpp | 6 +++--- hotspot/src/share/vm/prims/jvmtiImpl.hpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.cpp b/hotspot/src/share/vm/prims/jvmtiImpl.cpp index 129672cb607..34c07ee3a44 100644 --- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp +++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp @@ -278,7 +278,7 @@ bool JvmtiBreakpoint::is_valid() { _bci >= 0; } -address JvmtiBreakpoint::getBcp() { +address JvmtiBreakpoint::getBcp() const { return _method->bcp_from(_bci); } @@ -323,7 +323,7 @@ void JvmtiBreakpoint::clear() { each_method_version_do(&Method::clear_breakpoint); } -void JvmtiBreakpoint::print(outputStream* out) { +void JvmtiBreakpoint::print_on(outputStream* out) const { #ifndef PRODUCT ResourceMark rm; const char *class_name = (_method == NULL) ? "NULL" : _method->klass_name()->as_C_string(); @@ -400,7 +400,7 @@ void JvmtiBreakpoints::print() { for (int i=0; i Date: Tue, 26 Apr 2016 11:05:11 +0200 Subject: [PATCH 210/400] 8155085: [ppc] Fix Type-O in "8154580: Save mirror in interpreter frame..." Reviewed-by: dholmes, mgerdin --- hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp index 3bde747aa45..7f24f924e40 100644 --- a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp @@ -1317,7 +1317,7 @@ address TemplateInterpreterGenerator::generate_native_entry(bool synchronized) { __ testbitdi(CCR0, R0, access_flags, JVM_ACC_STATIC_BIT); __ bfalse(CCR0, method_is_not_static); - __ load_mirror(R12_sratch2, R19_method); + __ load_mirror(R12_scratch2, R19_method); // state->_native_mirror = mirror; __ ld(R11_scratch1, 0, R1_SP); -- GitLab From 7cf6a15162c794bb200e6e59fc4c81a3cb3cc652 Mon Sep 17 00:00:00 2001 From: Alexander Kulyakhtin Date: Tue, 26 Apr 2016 13:22:32 +0300 Subject: [PATCH 211/400] 8153992: Some hotspot tests fail on compact2 due to an unnecessary test library dependency Removing unnecessary dependency on java.management from the ProcessTool.getProcessId() Reviewed-by: mchung --- .../compiler/compilercontrol/share/actions/BaseAction.java | 2 +- .../gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java | 2 +- hotspot/test/gc/metaspace/PerfCounters.java | 2 +- hotspot/test/runtime/CommandLine/PrintTouchedMethods.java | 2 +- hotspot/test/runtime/NMT/BaselineWithParameter.java | 2 +- hotspot/test/runtime/NMT/JcmdBaselineDetail.java | 2 +- hotspot/test/runtime/NMT/JcmdDetailDiff.java | 2 +- hotspot/test/runtime/NMT/JcmdScale.java | 2 +- hotspot/test/runtime/NMT/JcmdScaleDetail.java | 2 +- hotspot/test/runtime/NMT/JcmdSummaryDiff.java | 2 +- hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java | 2 +- hotspot/test/runtime/NMT/MallocRoundingReportTest.java | 2 +- hotspot/test/runtime/NMT/MallocSiteHashOverflow.java | 2 +- hotspot/test/runtime/NMT/MallocStressTest.java | 2 +- hotspot/test/runtime/NMT/MallocTestType.java | 2 +- hotspot/test/runtime/NMT/MallocTrackingVerify.java | 2 +- hotspot/test/runtime/NMT/ReleaseNoCommit.java | 2 +- hotspot/test/runtime/NMT/ShutdownTwice.java | 2 +- hotspot/test/runtime/NMT/SummaryAfterShutdown.java | 2 +- hotspot/test/runtime/NMT/SummarySanityCheck.java | 2 +- hotspot/test/runtime/NMT/ThreadedMallocTestType.java | 2 +- hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java | 2 +- .../runtime/NMT/VirtualAllocCommitUncommitRecommit.java | 2 +- hotspot/test/runtime/NMT/VirtualAllocTestType.java | 2 +- .../SharedArchiveFile/DumpSymbolAndStringTable.java | 2 +- .../test/serviceability/sa/jmap-hashcode/Test8028623.java | 4 ++-- hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java | 7 ++----- .../testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java | 2 +- .../testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java | 6 +++--- 29 files changed, 33 insertions(+), 36 deletions(-) diff --git a/hotspot/test/compiler/compilercontrol/share/actions/BaseAction.java b/hotspot/test/compiler/compilercontrol/share/actions/BaseAction.java index 15cb5604fb5..3a882865676 100644 --- a/hotspot/test/compiler/compilercontrol/share/actions/BaseAction.java +++ b/hotspot/test/compiler/compilercontrol/share/actions/BaseAction.java @@ -77,7 +77,7 @@ public class BaseAction { throw new Error("TESTBUG: incorrect argument: "+ args[1]); } } - int pid; + long pid; try { pid = ProcessTools.getProcessId(); } catch (Exception e) { diff --git a/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java b/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java index 57fb611fd73..da322a6d0c7 100644 --- a/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java +++ b/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java @@ -49,7 +49,7 @@ public class CompressedClassSpaceSizeInJmapHeap { return; } - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); JDKToolLauncher jmap = JDKToolLauncher.create("jmap") .addToolArg("-heap") diff --git a/hotspot/test/gc/metaspace/PerfCounters.java b/hotspot/test/gc/metaspace/PerfCounters.java index d6848f2b7b7..9dce3bd4e70 100644 --- a/hotspot/test/gc/metaspace/PerfCounters.java +++ b/hotspot/test/gc/metaspace/PerfCounters.java @@ -40,7 +40,7 @@ public class PerfCounters { static { try { - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); VmIdentifier vmId = new VmIdentifier(pid); MonitoredHost host = MonitoredHost.getMonitoredHost(vmId); vm = host.getMonitoredVm(vmId); diff --git a/hotspot/test/runtime/CommandLine/PrintTouchedMethods.java b/hotspot/test/runtime/CommandLine/PrintTouchedMethods.java index f0661cd7431..2fd472e2af7 100644 --- a/hotspot/test/runtime/CommandLine/PrintTouchedMethods.java +++ b/hotspot/test/runtime/CommandLine/PrintTouchedMethods.java @@ -106,7 +106,7 @@ public class PrintTouchedMethods { output.shouldHaveExitValue(0); // Test jcmd PrintTouchedMethods VM.print_touched_methods - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); pb = new ProcessBuilder(); pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.print_touched_methods"}); output = new OutputAnalyzer(pb.start()); diff --git a/hotspot/test/runtime/NMT/BaselineWithParameter.java b/hotspot/test/runtime/NMT/BaselineWithParameter.java index 38d31ffcfee..b4982116fc2 100644 --- a/hotspot/test/runtime/NMT/BaselineWithParameter.java +++ b/hotspot/test/runtime/NMT/BaselineWithParameter.java @@ -38,7 +38,7 @@ public class BaselineWithParameter { public static void main(String args[]) throws Exception { // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); OutputAnalyzer output; ProcessBuilder pb = new ProcessBuilder(); diff --git a/hotspot/test/runtime/NMT/JcmdBaselineDetail.java b/hotspot/test/runtime/NMT/JcmdBaselineDetail.java index ce99b202742..1318dc339e3 100644 --- a/hotspot/test/runtime/NMT/JcmdBaselineDetail.java +++ b/hotspot/test/runtime/NMT/JcmdBaselineDetail.java @@ -37,7 +37,7 @@ public class JcmdBaselineDetail { public static void main(String args[]) throws Exception { // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); OutputAnalyzer output; ProcessBuilder pb = new ProcessBuilder(); diff --git a/hotspot/test/runtime/NMT/JcmdDetailDiff.java b/hotspot/test/runtime/NMT/JcmdDetailDiff.java index 694d47edb66..962afd155f1 100644 --- a/hotspot/test/runtime/NMT/JcmdDetailDiff.java +++ b/hotspot/test/runtime/NMT/JcmdDetailDiff.java @@ -45,7 +45,7 @@ public class JcmdDetailDiff { ProcessBuilder pb = new ProcessBuilder(); OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); long commitSize = 128 * 1024; long reserveSize = 256 * 1024; diff --git a/hotspot/test/runtime/NMT/JcmdScale.java b/hotspot/test/runtime/NMT/JcmdScale.java index 13cb50abd22..b8d8e5686e2 100644 --- a/hotspot/test/runtime/NMT/JcmdScale.java +++ b/hotspot/test/runtime/NMT/JcmdScale.java @@ -39,7 +39,7 @@ public class JcmdScale { ProcessBuilder pb = new ProcessBuilder(); OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB"}); output = new OutputAnalyzer(pb.start()); diff --git a/hotspot/test/runtime/NMT/JcmdScaleDetail.java b/hotspot/test/runtime/NMT/JcmdScaleDetail.java index 0379e234dce..27cb8c8dc47 100644 --- a/hotspot/test/runtime/NMT/JcmdScaleDetail.java +++ b/hotspot/test/runtime/NMT/JcmdScaleDetail.java @@ -39,7 +39,7 @@ public class JcmdScaleDetail { ProcessBuilder pb = new ProcessBuilder(); OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); pb.command(new String[] { JDKToolFinder.getJDKTool("jcmd"), pid, "VM.native_memory", "scale=KB"}); output = new OutputAnalyzer(pb.start()); diff --git a/hotspot/test/runtime/NMT/JcmdSummaryDiff.java b/hotspot/test/runtime/NMT/JcmdSummaryDiff.java index a53d75f999a..2c0b39cf77d 100644 --- a/hotspot/test/runtime/NMT/JcmdSummaryDiff.java +++ b/hotspot/test/runtime/NMT/JcmdSummaryDiff.java @@ -45,7 +45,7 @@ public class JcmdSummaryDiff { ProcessBuilder pb = new ProcessBuilder(); OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); long commitSize = 128 * 1024; long reserveSize = 256 * 1024; diff --git a/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java b/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java index b9c506be5d1..40818656b8f 100644 --- a/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java +++ b/hotspot/test/runtime/NMT/JcmdWithNMTDisabled.java @@ -60,7 +60,7 @@ public class JcmdWithNMTDisabled { } // Grab my own PID - pid = Integer.toString(ProcessTools.getProcessId()); + pid = Long.toString(ProcessTools.getProcessId()); jcmdCommand("summary"); jcmdCommand("detail"); diff --git a/hotspot/test/runtime/NMT/MallocRoundingReportTest.java b/hotspot/test/runtime/NMT/MallocRoundingReportTest.java index b823679c486..b5ff6dda485 100644 --- a/hotspot/test/runtime/NMT/MallocRoundingReportTest.java +++ b/hotspot/test/runtime/NMT/MallocRoundingReportTest.java @@ -46,7 +46,7 @@ public class MallocRoundingReportTest { WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); long[] additionalBytes = {0, 1, 512, 650}; diff --git a/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java b/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java index 7e754f4bbc2..bb22625ddee 100644 --- a/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java +++ b/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java @@ -48,7 +48,7 @@ public class MallocSiteHashOverflow { int MAX_HASH_SIZE = wb.NMTGetHashSize(); // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Verify that current tracking level is "detail" diff --git a/hotspot/test/runtime/NMT/MallocStressTest.java b/hotspot/test/runtime/NMT/MallocStressTest.java index af7f97f5d1f..8d7061f7ce2 100644 --- a/hotspot/test/runtime/NMT/MallocStressTest.java +++ b/hotspot/test/runtime/NMT/MallocStressTest.java @@ -74,7 +74,7 @@ public class MallocStressTest { whiteBox = WhiteBox.getWhiteBox(); // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); AllocThread[] alloc_threads = new AllocThread[256]; diff --git a/hotspot/test/runtime/NMT/MallocTestType.java b/hotspot/test/runtime/NMT/MallocTestType.java index abd04a799e4..3ee5e481a01 100644 --- a/hotspot/test/runtime/NMT/MallocTestType.java +++ b/hotspot/test/runtime/NMT/MallocTestType.java @@ -44,7 +44,7 @@ public class MallocTestType { WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Use WB API to alloc and free with the mtTest type diff --git a/hotspot/test/runtime/NMT/MallocTrackingVerify.java b/hotspot/test/runtime/NMT/MallocTrackingVerify.java index cefbcd9a012..0a77bd25bd4 100644 --- a/hotspot/test/runtime/NMT/MallocTrackingVerify.java +++ b/hotspot/test/runtime/NMT/MallocTrackingVerify.java @@ -53,7 +53,7 @@ public class MallocTrackingVerify { OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Random random = new Random(); diff --git a/hotspot/test/runtime/NMT/ReleaseNoCommit.java b/hotspot/test/runtime/NMT/ReleaseNoCommit.java index 7499d608c13..0d354115b06 100644 --- a/hotspot/test/runtime/NMT/ReleaseNoCommit.java +++ b/hotspot/test/runtime/NMT/ReleaseNoCommit.java @@ -49,7 +49,7 @@ public class ReleaseNoCommit { ProcessBuilder pb = new ProcessBuilder(); OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); addr = wb.NMTReserveMemory(reserveSize); // Check for reserved diff --git a/hotspot/test/runtime/NMT/ShutdownTwice.java b/hotspot/test/runtime/NMT/ShutdownTwice.java index 1d354168fe7..d0a7c7777e4 100644 --- a/hotspot/test/runtime/NMT/ShutdownTwice.java +++ b/hotspot/test/runtime/NMT/ShutdownTwice.java @@ -37,7 +37,7 @@ public class ShutdownTwice { public static void main(String args[]) throws Exception { // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); OutputAnalyzer output; ProcessBuilder pb = new ProcessBuilder(); diff --git a/hotspot/test/runtime/NMT/SummaryAfterShutdown.java b/hotspot/test/runtime/NMT/SummaryAfterShutdown.java index 66921152b76..aec1a808576 100644 --- a/hotspot/test/runtime/NMT/SummaryAfterShutdown.java +++ b/hotspot/test/runtime/NMT/SummaryAfterShutdown.java @@ -38,7 +38,7 @@ public class SummaryAfterShutdown { public static void main(String args[]) throws Exception { OutputAnalyzer output; // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // Run 'jcmd VM.native_memory shutdown' diff --git a/hotspot/test/runtime/NMT/SummarySanityCheck.java b/hotspot/test/runtime/NMT/SummarySanityCheck.java index d322fa649a3..511596bb61d 100644 --- a/hotspot/test/runtime/NMT/SummarySanityCheck.java +++ b/hotspot/test/runtime/NMT/SummarySanityCheck.java @@ -45,7 +45,7 @@ public class SummarySanityCheck { private static String jcmdout; public static void main(String args[]) throws Exception { // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); diff --git a/hotspot/test/runtime/NMT/ThreadedMallocTestType.java b/hotspot/test/runtime/NMT/ThreadedMallocTestType.java index a0e29fca618..2fee0c79f73 100644 --- a/hotspot/test/runtime/NMT/ThreadedMallocTestType.java +++ b/hotspot/test/runtime/NMT/ThreadedMallocTestType.java @@ -46,7 +46,7 @@ public class ThreadedMallocTestType { final WhiteBox wb = WhiteBox.getWhiteBox(); // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Thread allocThread = new Thread() { diff --git a/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java b/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java index 8ba7e7c53cd..1611b6f345d 100644 --- a/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java +++ b/hotspot/test/runtime/NMT/ThreadedVirtualAllocTestType.java @@ -45,7 +45,7 @@ public class ThreadedVirtualAllocTestType { public static void main(String args[]) throws Exception { OutputAnalyzer output; - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); Thread reserveThread = new Thread() { diff --git a/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java b/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java index fbc5fe9032b..dabdcd443a2 100644 --- a/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java +++ b/hotspot/test/runtime/NMT/VirtualAllocCommitUncommitRecommit.java @@ -48,7 +48,7 @@ public class VirtualAllocCommitUncommitRecommit { long reserveSize = 4 * 1024 * 1024; // 4096KB long addr; - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); // reserve diff --git a/hotspot/test/runtime/NMT/VirtualAllocTestType.java b/hotspot/test/runtime/NMT/VirtualAllocTestType.java index b8bd3be77a6..da611ab8b29 100644 --- a/hotspot/test/runtime/NMT/VirtualAllocTestType.java +++ b/hotspot/test/runtime/NMT/VirtualAllocTestType.java @@ -46,7 +46,7 @@ public class VirtualAllocTestType { long reserveSize = 256 * 1024; long addr; - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); addr = wb.NMTReserveMemory(reserveSize); diff --git a/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java b/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java index 1d30fd6b963..4d24b549fd4 100644 --- a/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java +++ b/hotspot/test/runtime/SharedArchiveFile/DumpSymbolAndStringTable.java @@ -36,7 +36,7 @@ import jdk.test.lib.*; public class DumpSymbolAndStringTable { public static void main(String[] args) throws Exception { // Grab my own PID - String pid = Integer.toString(ProcessTools.getProcessId()); + String pid = Long.toString(ProcessTools.getProcessId()); ProcessBuilder pb = new ProcessBuilder(); pb.command(new String[] {JDKToolFinder.getJDKTool("jcmd"), pid, "VM.symboltable", "-verbose"}); diff --git a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java index ac0ef6dca94..746ef827957 100644 --- a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java +++ b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java @@ -55,11 +55,11 @@ public class Test8028623 { System.out.println("SA attach not expected to work - test skipped."); return; } - int pid = ProcessTools.getProcessId(); + long pid = ProcessTools.getProcessId(); JDKToolLauncher jmap = JDKToolLauncher.create("jmap") .addToolArg("-F") .addToolArg("-dump:live,format=b,file=" + dumpFile) - .addToolArg(Integer.toString(pid)); + .addToolArg(Long.toString(pid)); ProcessBuilder pb = new ProcessBuilder(jmap.getCommand()); OutputBuffer output = ProcessTools.getOutput(pb); Process p = pb.start(); diff --git a/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java b/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java index 70e990ac59d..a8586dc3c1b 100644 --- a/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java +++ b/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java @@ -90,11 +90,8 @@ public final class ProcessTools { * * @return Process id */ - public static int getProcessId() throws Exception { - RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); - int pid = Integer.parseInt(runtime.getName().split("@")[0]); - - return pid; + public static long getProcessId() throws Exception { + return ProcessHandle.current().getPid(); } /** diff --git a/hotspot/test/testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java b/hotspot/test/testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java index 24836e66d9b..17ffd91b761 100644 --- a/hotspot/test/testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java +++ b/hotspot/test/testlibrary/jdk/test/lib/dcmd/FileJcmdExecutor.java @@ -55,7 +55,7 @@ public class FileJcmdExecutor extends PidJcmdExecutor { File cmdFile = createTempFile(); writeCommandToTemporaryFile(cmd, cmdFile); - return Arrays.asList(jcmdBinary, Integer.toString(pid), + return Arrays.asList(jcmdBinary, Long.toString(pid), "-f", cmdFile.getAbsolutePath()); } diff --git a/hotspot/test/testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java b/hotspot/test/testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java index bce55d7be31..f1caddb8b16 100644 --- a/hotspot/test/testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java +++ b/hotspot/test/testlibrary/jdk/test/lib/dcmd/PidJcmdExecutor.java @@ -32,7 +32,7 @@ import java.util.List; * Executes Diagnostic Commands on the target VM (specified by pid) using the jcmd tool */ public class PidJcmdExecutor extends JcmdExecutor { - protected final int pid; + protected final long pid; /** * Instantiates a new PidJcmdExecutor targeting the current VM @@ -53,11 +53,11 @@ public class PidJcmdExecutor extends JcmdExecutor { */ public PidJcmdExecutor(String target) { super(); - pid = Integer.valueOf(target); + pid = Long.valueOf(target); } protected List createCommandLine(String cmd) throws CommandExecutorException { - return Arrays.asList(jcmdBinary, Integer.toString(pid), cmd); + return Arrays.asList(jcmdBinary, Long.toString(pid), cmd); } } -- GitLab From e28d7b714ec45e3d154e21f2b66913911c365792 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 26 Apr 2016 13:35:28 +0200 Subject: [PATCH 212/400] 8150601: Remove the old Hotspot build system Reviewed-by: ihse --- hotspot/{makefiles => make}/BuildHotspot.gmk | 0 hotspot/{makefiles => make}/Dist.gmk | 0 hotspot/{makefiles => make}/HotspotCommon.gmk | 0 hotspot/make/Makefile | 895 ------------------ hotspot/make/aix/Makefile | 369 -------- hotspot/make/aix/adlc_updater | 23 - hotspot/make/aix/makefiles/adjust-mflags.sh | 87 -- hotspot/make/aix/makefiles/adlc.make | 225 ----- hotspot/make/aix/makefiles/build_vm_def.sh | 18 - hotspot/make/aix/makefiles/buildtree.make | 351 ------- hotspot/make/aix/makefiles/compiler2.make | 32 - hotspot/make/aix/makefiles/core.make | 33 - hotspot/make/aix/makefiles/debug.make | 41 - hotspot/make/aix/makefiles/defs.make | 204 ---- hotspot/make/aix/makefiles/dtrace.make | 27 - hotspot/make/aix/makefiles/fastdebug.make | 72 -- hotspot/make/aix/makefiles/jsig.make | 87 -- hotspot/make/aix/makefiles/jvmti.make | 117 --- hotspot/make/aix/makefiles/mapfile-vers-debug | 56 -- hotspot/make/aix/makefiles/mapfile-vers-jsig | 38 - .../make/aix/makefiles/mapfile-vers-product | 51 - hotspot/make/aix/makefiles/ppc64.make | 93 -- hotspot/make/aix/makefiles/product.make | 58 -- hotspot/make/aix/makefiles/rules.make | 208 ---- hotspot/make/aix/makefiles/tiered.make | 32 - hotspot/make/aix/makefiles/top.make | 147 --- hotspot/make/aix/makefiles/trace.make | 119 --- hotspot/make/aix/makefiles/vm.make | 370 -------- hotspot/make/aix/makefiles/xlc.make | 172 ---- hotspot/make/aix/platform_ppc64 | 17 - hotspot/make/altsrc.make | 96 -- hotspot/make/bsd/Makefile | 386 -------- hotspot/make/bsd/README | 26 - hotspot/make/bsd/adlc_updater | 23 - hotspot/make/bsd/makefiles/adjust-mflags.sh | 87 -- hotspot/make/bsd/makefiles/adlc.make | 233 ----- hotspot/make/bsd/makefiles/amd64.make | 47 - hotspot/make/bsd/makefiles/arm.make | 27 - hotspot/make/bsd/makefiles/build_vm_def.sh | 12 - hotspot/make/bsd/makefiles/buildtree.make | 370 -------- hotspot/make/bsd/makefiles/compiler1.make | 34 - hotspot/make/bsd/makefiles/compiler2.make | 31 - hotspot/make/bsd/makefiles/core.make | 33 - hotspot/make/bsd/makefiles/cscope.make | 160 ---- hotspot/make/bsd/makefiles/debug.make | 45 - hotspot/make/bsd/makefiles/defs.make | 382 -------- hotspot/make/bsd/makefiles/dtrace.make | 333 ------- hotspot/make/bsd/makefiles/fastdebug.make | 59 -- hotspot/make/bsd/makefiles/gcc.make | 543 ----------- hotspot/make/bsd/makefiles/hp.make | 29 - hotspot/make/bsd/makefiles/hp1.make | 29 - hotspot/make/bsd/makefiles/i486.make | 34 - hotspot/make/bsd/makefiles/ia64.make | 41 - hotspot/make/bsd/makefiles/jsig.make | 110 --- hotspot/make/bsd/makefiles/jvmti.make | 116 --- .../bsd/makefiles/mapfile-vers-darwin-debug | 40 - .../bsd/makefiles/mapfile-vers-darwin-product | 40 - hotspot/make/bsd/makefiles/mapfile-vers-debug | 51 - hotspot/make/bsd/makefiles/mapfile-vers-jsig | 40 - .../make/bsd/makefiles/mapfile-vers-product | 51 - hotspot/make/bsd/makefiles/minimal1.make | 52 - hotspot/make/bsd/makefiles/optimized.make | 46 - hotspot/make/bsd/makefiles/ppc.make | 30 - hotspot/make/bsd/makefiles/product.make | 62 -- hotspot/make/bsd/makefiles/rules.make | 212 ----- hotspot/make/bsd/makefiles/shark.make | 32 - hotspot/make/bsd/makefiles/sparc.make | 24 - hotspot/make/bsd/makefiles/sparcWorks.make | 107 --- hotspot/make/bsd/makefiles/sparcv9.make | 27 - hotspot/make/bsd/makefiles/tiered.make | 31 - hotspot/make/bsd/makefiles/top.make | 156 --- hotspot/make/bsd/makefiles/trace.make | 119 --- hotspot/make/bsd/makefiles/universal.gmk | 126 --- hotspot/make/bsd/makefiles/vm.make | 438 --------- hotspot/make/bsd/makefiles/zero.make | 32 - hotspot/make/bsd/makefiles/zeroshark.make | 62 -- hotspot/make/bsd/platform_amd64 | 15 - hotspot/make/bsd/platform_amd64.suncc | 17 - hotspot/make/bsd/platform_i486 | 15 - hotspot/make/bsd/platform_i486.suncc | 17 - hotspot/make/bsd/platform_ia64 | 15 - hotspot/make/bsd/platform_sparc | 15 - hotspot/make/bsd/platform_sparcv9 | 15 - hotspot/make/bsd/platform_zero.in | 17 - hotspot/make/build.sh | 92 -- hotspot/make/cscope.make | 141 --- hotspot/make/defs.make | 362 ------- hotspot/make/excludeSrc.make | 131 --- .../gensrc/GenerateSources.gmk | 0 .../{makefiles => make}/gensrc/GensrcAdlc.gmk | 0 .../gensrc/GensrcDtrace.gmk | 0 .../gensrc/GensrcJvmti.gmk | 0 hotspot/make/hotspot_distro | 32 - .../ide/CreateVSProject.gmk | 2 +- hotspot/make/jdk_version | 37 - hotspot/make/jprt.gmk | 77 -- .../lib/CompileDtracePostJvm.gmk | 4 +- .../lib/CompileDtracePreJvm.gmk | 0 .../{makefiles => make}/lib/CompileJvm.gmk | 0 .../lib/CompileLibjsig.gmk | 2 +- .../lib/CompileLibraries.gmk | 0 .../{makefiles => make}/lib/JvmFeatures.gmk | 0 .../{makefiles => make}/lib/JvmMapfile.gmk | 16 +- .../lib/JvmOverrideFiles.gmk | 0 hotspot/make/linux/Makefile | 385 -------- hotspot/make/linux/README | 26 - hotspot/make/linux/adlc_updater | 23 - hotspot/make/linux/makefiles/aarch64.make | 32 - hotspot/make/linux/makefiles/adjust-mflags.sh | 87 -- hotspot/make/linux/makefiles/adlc.make | 233 ----- hotspot/make/linux/makefiles/amd64.make | 42 - hotspot/make/linux/makefiles/buildtree.make | 368 ------- hotspot/make/linux/makefiles/compiler1.make | 34 - hotspot/make/linux/makefiles/compiler2.make | 31 - hotspot/make/linux/makefiles/core.make | 33 - hotspot/make/linux/makefiles/debug.make | 42 - hotspot/make/linux/makefiles/defs.make | 279 ------ hotspot/make/linux/makefiles/dtrace.make | 95 -- hotspot/make/linux/makefiles/fastdebug.make | 74 -- hotspot/make/linux/makefiles/gcc.make | 425 --------- hotspot/make/linux/makefiles/hp.make | 29 - hotspot/make/linux/makefiles/hp1.make | 29 - hotspot/make/linux/makefiles/i486.make | 42 - hotspot/make/linux/makefiles/ia64.make | 41 - hotspot/make/linux/makefiles/jsig.make | 83 -- hotspot/make/linux/makefiles/jvmti.make | 117 --- .../make/linux/makefiles/mapfile-vers-debug | 51 - .../make/linux/makefiles/mapfile-vers-jsig | 40 - .../make/linux/makefiles/mapfile-vers-product | 51 - hotspot/make/linux/makefiles/minimal1.make | 52 - hotspot/make/linux/makefiles/optimized.make | 43 - hotspot/make/linux/makefiles/ppc64.make | 51 - hotspot/make/linux/makefiles/product.make | 54 -- hotspot/make/linux/makefiles/rules.make | 214 ----- hotspot/make/linux/makefiles/shark.make | 32 - hotspot/make/linux/makefiles/sparc.make | 24 - hotspot/make/linux/makefiles/sparcWorks.make | 107 --- hotspot/make/linux/makefiles/sparcv9.make | 27 - hotspot/make/linux/makefiles/tiered.make | 31 - hotspot/make/linux/makefiles/top.make | 150 --- hotspot/make/linux/makefiles/trace.make | 119 --- hotspot/make/linux/makefiles/vm.make | 407 -------- hotspot/make/linux/makefiles/zero.make | 37 - hotspot/make/linux/makefiles/zeroshark.make | 46 - hotspot/make/linux/platform_aarch64 | 15 - hotspot/make/linux/platform_amd64 | 15 - hotspot/make/linux/platform_amd64.suncc | 17 - hotspot/make/linux/platform_i486 | 15 - hotspot/make/linux/platform_i486.suncc | 17 - hotspot/make/linux/platform_ia64 | 15 - hotspot/make/linux/platform_ppc64 | 17 - hotspot/make/linux/platform_sparc | 15 - hotspot/make/linux/platform_sparcv9 | 15 - hotspot/make/linux/platform_zero.in | 17 - .../mapfiles/libjsig/mapfile-vers-solaris | 0 .../mapfiles/libjvm_db/mapfile-vers | 0 .../mapfiles/libjvm_dtrace/mapfile-vers | 0 hotspot/make/openjdk_distro | 32 - hotspot/make/pic.make | 48 - hotspot/make/scm.make | 28 - hotspot/make/share/makefiles/mapfile-vers | 180 ---- hotspot/make/solaris/Makefile | 286 ------ hotspot/make/solaris/adlc_updater | 23 - .../make/solaris/makefiles/adjust-mflags.sh | 87 -- hotspot/make/solaris/makefiles/adlc.make | 257 ----- hotspot/make/solaris/makefiles/amd64.make | 58 -- .../make/solaris/makefiles/build_vm_def.sh | 10 - hotspot/make/solaris/makefiles/buildtree.make | 354 ------- hotspot/make/solaris/makefiles/compiler1.make | 34 - hotspot/make/solaris/makefiles/compiler2.make | 31 - hotspot/make/solaris/makefiles/core.make | 33 - hotspot/make/solaris/makefiles/debug.make | 56 -- hotspot/make/solaris/makefiles/defs.make | 279 ------ hotspot/make/solaris/makefiles/dtrace.make | 387 -------- hotspot/make/solaris/makefiles/fastdebug.make | 127 --- hotspot/make/solaris/makefiles/gcc.make | 241 ----- hotspot/make/solaris/makefiles/hp.make | 29 - hotspot/make/solaris/makefiles/hp1.make | 29 - hotspot/make/solaris/makefiles/i486.make | 42 - hotspot/make/solaris/makefiles/jsig.make | 81 -- hotspot/make/solaris/makefiles/jvmti.make | 115 --- hotspot/make/solaris/makefiles/mapfile-vers | 48 - .../solaris/makefiles/mapfile-vers-COMPILER1 | 43 - .../solaris/makefiles/mapfile-vers-COMPILER2 | 46 - .../make/solaris/makefiles/mapfile-vers-CORE | 31 - .../solaris/makefiles/mapfile-vers-TIERED | 45 - .../make/solaris/makefiles/mapfile-vers-debug | 33 - .../make/solaris/makefiles/mapfile-vers-jsig | 40 - .../solaris/makefiles/mapfile-vers-jvm_db | 38 - .../solaris/makefiles/mapfile-vers-jvm_dtrace | 37 - hotspot/make/solaris/makefiles/optimized.make | 65 -- hotspot/make/solaris/makefiles/product.make | 103 -- .../make/solaris/makefiles/reorder_CORE_amd64 | 0 hotspot/make/solaris/makefiles/rules.make | 200 ---- hotspot/make/solaris/makefiles/sparc.make | 124 --- .../make/solaris/makefiles/sparcWorks.make | 565 ----------- hotspot/make/solaris/makefiles/sparcv9.make | 48 - hotspot/make/solaris/makefiles/tiered.make | 31 - hotspot/make/solaris/makefiles/top.make | 141 --- hotspot/make/solaris/makefiles/trace.make | 119 --- hotspot/make/solaris/makefiles/vm.make | 352 ------- hotspot/make/solaris/platform_amd64 | 15 - hotspot/make/solaris/platform_amd64.gcc | 15 - hotspot/make/solaris/platform_i486 | 15 - hotspot/make/solaris/platform_i486.gcc | 15 - hotspot/make/solaris/platform_sparc | 15 - hotspot/make/solaris/platform_sparc.gcc | 15 - hotspot/make/solaris/platform_sparcv9 | 15 - hotspot/make/solaris/platform_sparcv9.gcc | 15 - .../{makefiles => make}/symbols/symbols-aix | 0 .../symbols/symbols-aix-debug | 0 .../{makefiles => make}/symbols/symbols-linux | 0 .../symbols/symbols-macosx | 0 .../symbols/symbols-shared | 0 .../symbols/symbols-solaris | 0 .../symbols/symbols-solaris-dtrace-compiler1 | 0 .../symbols/symbols-solaris-dtrace-compiler2 | 0 .../{makefiles => make}/symbols/symbols-unix | 0 hotspot/make/windows/build.bat | 85 -- hotspot/make/windows/build.make | 253 ----- hotspot/make/windows/build_vm_def.sh | 74 -- hotspot/make/windows/create.bat | 198 ---- hotspot/make/windows/create_obj_files.sh | 167 ---- hotspot/make/windows/cross_build.bat | 61 -- hotspot/make/windows/get_msc_ver.sh | 93 -- hotspot/make/windows/jvmexp.lcf | 10 - hotspot/make/windows/jvmexp_g.lcf | 10 - hotspot/make/windows/makefiles/adlc.make | 119 --- hotspot/make/windows/makefiles/compile.make | 197 ---- hotspot/make/windows/makefiles/debug.make | 68 -- hotspot/make/windows/makefiles/defs.make | 282 ------ hotspot/make/windows/makefiles/fastdebug.make | 67 -- hotspot/make/windows/makefiles/generated.make | 60 -- hotspot/make/windows/makefiles/jvmti.make | 114 --- hotspot/make/windows/makefiles/product.make | 72 -- .../windows/makefiles/projectcreator.make | 210 ---- hotspot/make/windows/makefiles/rules.make | 63 -- hotspot/make/windows/makefiles/sanity.make | 35 - hotspot/make/windows/makefiles/shared.make | 71 -- hotspot/make/windows/makefiles/top.make | 34 - hotspot/make/windows/makefiles/trace.make | 132 --- hotspot/make/windows/makefiles/vm.make | 428 --------- .../make/windows/projectfiles/common/Makefile | 132 --- .../windows/projectfiles/compiler1/Makefile | 27 - .../windows/projectfiles/compiler1/vm.def | 7 - .../windows/projectfiles/compiler1/vm.dsw | 29 - .../projectfiles/compiler2/ADLCompiler.dsp | 142 --- .../projectfiles/compiler2/ADLCompiler.dsw | 29 - .../windows/projectfiles/compiler2/Makefile | 29 - .../windows/projectfiles/compiler2/vm.def | 7 - .../windows/projectfiles/compiler2/vm.dsw | 29 - .../make/windows/projectfiles/core/Makefile | 27 - hotspot/make/windows/projectfiles/core/vm.def | 7 - hotspot/make/windows/projectfiles/core/vm.dsw | 29 - .../projectfiles/tiered/ADLCompiler.dsp | 142 --- .../projectfiles/tiered/ADLCompiler.dsw | 29 - .../make/windows/projectfiles/tiered/Makefile | 29 - .../make/windows/projectfiles/tiered/vm.def | 7 - .../make/windows/projectfiles/tiered/vm.dsw | 29 - 259 files changed, 12 insertions(+), 22969 deletions(-) rename hotspot/{makefiles => make}/BuildHotspot.gmk (100%) rename hotspot/{makefiles => make}/Dist.gmk (100%) rename hotspot/{makefiles => make}/HotspotCommon.gmk (100%) delete mode 100644 hotspot/make/Makefile delete mode 100644 hotspot/make/aix/Makefile delete mode 100644 hotspot/make/aix/adlc_updater delete mode 100644 hotspot/make/aix/makefiles/adjust-mflags.sh delete mode 100644 hotspot/make/aix/makefiles/adlc.make delete mode 100644 hotspot/make/aix/makefiles/build_vm_def.sh delete mode 100644 hotspot/make/aix/makefiles/buildtree.make delete mode 100644 hotspot/make/aix/makefiles/compiler2.make delete mode 100644 hotspot/make/aix/makefiles/core.make delete mode 100644 hotspot/make/aix/makefiles/debug.make delete mode 100644 hotspot/make/aix/makefiles/defs.make delete mode 100644 hotspot/make/aix/makefiles/dtrace.make delete mode 100644 hotspot/make/aix/makefiles/fastdebug.make delete mode 100644 hotspot/make/aix/makefiles/jsig.make delete mode 100644 hotspot/make/aix/makefiles/jvmti.make delete mode 100644 hotspot/make/aix/makefiles/mapfile-vers-debug delete mode 100644 hotspot/make/aix/makefiles/mapfile-vers-jsig delete mode 100644 hotspot/make/aix/makefiles/mapfile-vers-product delete mode 100644 hotspot/make/aix/makefiles/ppc64.make delete mode 100644 hotspot/make/aix/makefiles/product.make delete mode 100644 hotspot/make/aix/makefiles/rules.make delete mode 100644 hotspot/make/aix/makefiles/tiered.make delete mode 100644 hotspot/make/aix/makefiles/top.make delete mode 100644 hotspot/make/aix/makefiles/trace.make delete mode 100644 hotspot/make/aix/makefiles/vm.make delete mode 100644 hotspot/make/aix/makefiles/xlc.make delete mode 100644 hotspot/make/aix/platform_ppc64 delete mode 100644 hotspot/make/altsrc.make delete mode 100644 hotspot/make/bsd/Makefile delete mode 100644 hotspot/make/bsd/README delete mode 100644 hotspot/make/bsd/adlc_updater delete mode 100644 hotspot/make/bsd/makefiles/adjust-mflags.sh delete mode 100644 hotspot/make/bsd/makefiles/adlc.make delete mode 100644 hotspot/make/bsd/makefiles/amd64.make delete mode 100644 hotspot/make/bsd/makefiles/arm.make delete mode 100644 hotspot/make/bsd/makefiles/build_vm_def.sh delete mode 100644 hotspot/make/bsd/makefiles/buildtree.make delete mode 100644 hotspot/make/bsd/makefiles/compiler1.make delete mode 100644 hotspot/make/bsd/makefiles/compiler2.make delete mode 100644 hotspot/make/bsd/makefiles/core.make delete mode 100644 hotspot/make/bsd/makefiles/cscope.make delete mode 100644 hotspot/make/bsd/makefiles/debug.make delete mode 100644 hotspot/make/bsd/makefiles/defs.make delete mode 100644 hotspot/make/bsd/makefiles/dtrace.make delete mode 100644 hotspot/make/bsd/makefiles/fastdebug.make delete mode 100644 hotspot/make/bsd/makefiles/gcc.make delete mode 100644 hotspot/make/bsd/makefiles/hp.make delete mode 100644 hotspot/make/bsd/makefiles/hp1.make delete mode 100644 hotspot/make/bsd/makefiles/i486.make delete mode 100644 hotspot/make/bsd/makefiles/ia64.make delete mode 100644 hotspot/make/bsd/makefiles/jsig.make delete mode 100644 hotspot/make/bsd/makefiles/jvmti.make delete mode 100644 hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug delete mode 100644 hotspot/make/bsd/makefiles/mapfile-vers-darwin-product delete mode 100644 hotspot/make/bsd/makefiles/mapfile-vers-debug delete mode 100644 hotspot/make/bsd/makefiles/mapfile-vers-jsig delete mode 100644 hotspot/make/bsd/makefiles/mapfile-vers-product delete mode 100644 hotspot/make/bsd/makefiles/minimal1.make delete mode 100644 hotspot/make/bsd/makefiles/optimized.make delete mode 100644 hotspot/make/bsd/makefiles/ppc.make delete mode 100644 hotspot/make/bsd/makefiles/product.make delete mode 100644 hotspot/make/bsd/makefiles/rules.make delete mode 100644 hotspot/make/bsd/makefiles/shark.make delete mode 100644 hotspot/make/bsd/makefiles/sparc.make delete mode 100644 hotspot/make/bsd/makefiles/sparcWorks.make delete mode 100644 hotspot/make/bsd/makefiles/sparcv9.make delete mode 100644 hotspot/make/bsd/makefiles/tiered.make delete mode 100644 hotspot/make/bsd/makefiles/top.make delete mode 100644 hotspot/make/bsd/makefiles/trace.make delete mode 100644 hotspot/make/bsd/makefiles/universal.gmk delete mode 100644 hotspot/make/bsd/makefiles/vm.make delete mode 100644 hotspot/make/bsd/makefiles/zero.make delete mode 100644 hotspot/make/bsd/makefiles/zeroshark.make delete mode 100644 hotspot/make/bsd/platform_amd64 delete mode 100644 hotspot/make/bsd/platform_amd64.suncc delete mode 100644 hotspot/make/bsd/platform_i486 delete mode 100644 hotspot/make/bsd/platform_i486.suncc delete mode 100644 hotspot/make/bsd/platform_ia64 delete mode 100644 hotspot/make/bsd/platform_sparc delete mode 100644 hotspot/make/bsd/platform_sparcv9 delete mode 100644 hotspot/make/bsd/platform_zero.in delete mode 100644 hotspot/make/build.sh delete mode 100644 hotspot/make/cscope.make delete mode 100644 hotspot/make/defs.make delete mode 100644 hotspot/make/excludeSrc.make rename hotspot/{makefiles => make}/gensrc/GenerateSources.gmk (100%) rename hotspot/{makefiles => make}/gensrc/GensrcAdlc.gmk (100%) rename hotspot/{makefiles => make}/gensrc/GensrcDtrace.gmk (100%) rename hotspot/{makefiles => make}/gensrc/GensrcJvmti.gmk (100%) delete mode 100644 hotspot/make/hotspot_distro rename hotspot/{makefiles => make}/ide/CreateVSProject.gmk (98%) delete mode 100644 hotspot/make/jdk_version delete mode 100644 hotspot/make/jprt.gmk rename hotspot/{makefiles => make}/lib/CompileDtracePostJvm.gmk (98%) rename hotspot/{makefiles => make}/lib/CompileDtracePreJvm.gmk (100%) rename hotspot/{makefiles => make}/lib/CompileJvm.gmk (100%) rename hotspot/{makefiles => make}/lib/CompileLibjsig.gmk (97%) rename hotspot/{makefiles => make}/lib/CompileLibraries.gmk (100%) rename hotspot/{makefiles => make}/lib/JvmFeatures.gmk (100%) rename hotspot/{makefiles => make}/lib/JvmMapfile.gmk (90%) rename hotspot/{makefiles => make}/lib/JvmOverrideFiles.gmk (100%) delete mode 100644 hotspot/make/linux/Makefile delete mode 100644 hotspot/make/linux/README delete mode 100644 hotspot/make/linux/adlc_updater delete mode 100644 hotspot/make/linux/makefiles/aarch64.make delete mode 100644 hotspot/make/linux/makefiles/adjust-mflags.sh delete mode 100644 hotspot/make/linux/makefiles/adlc.make delete mode 100644 hotspot/make/linux/makefiles/amd64.make delete mode 100644 hotspot/make/linux/makefiles/buildtree.make delete mode 100644 hotspot/make/linux/makefiles/compiler1.make delete mode 100644 hotspot/make/linux/makefiles/compiler2.make delete mode 100644 hotspot/make/linux/makefiles/core.make delete mode 100644 hotspot/make/linux/makefiles/debug.make delete mode 100644 hotspot/make/linux/makefiles/defs.make delete mode 100644 hotspot/make/linux/makefiles/dtrace.make delete mode 100644 hotspot/make/linux/makefiles/fastdebug.make delete mode 100644 hotspot/make/linux/makefiles/gcc.make delete mode 100644 hotspot/make/linux/makefiles/hp.make delete mode 100644 hotspot/make/linux/makefiles/hp1.make delete mode 100644 hotspot/make/linux/makefiles/i486.make delete mode 100644 hotspot/make/linux/makefiles/ia64.make delete mode 100644 hotspot/make/linux/makefiles/jsig.make delete mode 100644 hotspot/make/linux/makefiles/jvmti.make delete mode 100644 hotspot/make/linux/makefiles/mapfile-vers-debug delete mode 100644 hotspot/make/linux/makefiles/mapfile-vers-jsig delete mode 100644 hotspot/make/linux/makefiles/mapfile-vers-product delete mode 100644 hotspot/make/linux/makefiles/minimal1.make delete mode 100644 hotspot/make/linux/makefiles/optimized.make delete mode 100644 hotspot/make/linux/makefiles/ppc64.make delete mode 100644 hotspot/make/linux/makefiles/product.make delete mode 100644 hotspot/make/linux/makefiles/rules.make delete mode 100644 hotspot/make/linux/makefiles/shark.make delete mode 100644 hotspot/make/linux/makefiles/sparc.make delete mode 100644 hotspot/make/linux/makefiles/sparcWorks.make delete mode 100644 hotspot/make/linux/makefiles/sparcv9.make delete mode 100644 hotspot/make/linux/makefiles/tiered.make delete mode 100644 hotspot/make/linux/makefiles/top.make delete mode 100644 hotspot/make/linux/makefiles/trace.make delete mode 100644 hotspot/make/linux/makefiles/vm.make delete mode 100644 hotspot/make/linux/makefiles/zero.make delete mode 100644 hotspot/make/linux/makefiles/zeroshark.make delete mode 100644 hotspot/make/linux/platform_aarch64 delete mode 100644 hotspot/make/linux/platform_amd64 delete mode 100644 hotspot/make/linux/platform_amd64.suncc delete mode 100644 hotspot/make/linux/platform_i486 delete mode 100644 hotspot/make/linux/platform_i486.suncc delete mode 100644 hotspot/make/linux/platform_ia64 delete mode 100644 hotspot/make/linux/platform_ppc64 delete mode 100644 hotspot/make/linux/platform_sparc delete mode 100644 hotspot/make/linux/platform_sparcv9 delete mode 100644 hotspot/make/linux/platform_zero.in rename hotspot/{makefiles => make}/mapfiles/libjsig/mapfile-vers-solaris (100%) rename hotspot/{makefiles => make}/mapfiles/libjvm_db/mapfile-vers (100%) rename hotspot/{makefiles => make}/mapfiles/libjvm_dtrace/mapfile-vers (100%) delete mode 100644 hotspot/make/openjdk_distro delete mode 100644 hotspot/make/pic.make delete mode 100644 hotspot/make/scm.make delete mode 100644 hotspot/make/share/makefiles/mapfile-vers delete mode 100644 hotspot/make/solaris/Makefile delete mode 100644 hotspot/make/solaris/adlc_updater delete mode 100644 hotspot/make/solaris/makefiles/adjust-mflags.sh delete mode 100644 hotspot/make/solaris/makefiles/adlc.make delete mode 100644 hotspot/make/solaris/makefiles/amd64.make delete mode 100644 hotspot/make/solaris/makefiles/build_vm_def.sh delete mode 100644 hotspot/make/solaris/makefiles/buildtree.make delete mode 100644 hotspot/make/solaris/makefiles/compiler1.make delete mode 100644 hotspot/make/solaris/makefiles/compiler2.make delete mode 100644 hotspot/make/solaris/makefiles/core.make delete mode 100644 hotspot/make/solaris/makefiles/debug.make delete mode 100644 hotspot/make/solaris/makefiles/defs.make delete mode 100644 hotspot/make/solaris/makefiles/dtrace.make delete mode 100644 hotspot/make/solaris/makefiles/fastdebug.make delete mode 100644 hotspot/make/solaris/makefiles/gcc.make delete mode 100644 hotspot/make/solaris/makefiles/hp.make delete mode 100644 hotspot/make/solaris/makefiles/hp1.make delete mode 100644 hotspot/make/solaris/makefiles/i486.make delete mode 100644 hotspot/make/solaris/makefiles/jsig.make delete mode 100644 hotspot/make/solaris/makefiles/jvmti.make delete mode 100644 hotspot/make/solaris/makefiles/mapfile-vers delete mode 100644 hotspot/make/solaris/makefiles/mapfile-vers-COMPILER1 delete mode 100644 hotspot/make/solaris/makefiles/mapfile-vers-COMPILER2 delete mode 100644 hotspot/make/solaris/makefiles/mapfile-vers-CORE delete mode 100644 hotspot/make/solaris/makefiles/mapfile-vers-TIERED delete mode 100644 hotspot/make/solaris/makefiles/mapfile-vers-debug delete mode 100644 hotspot/make/solaris/makefiles/mapfile-vers-jsig delete mode 100644 hotspot/make/solaris/makefiles/mapfile-vers-jvm_db delete mode 100644 hotspot/make/solaris/makefiles/mapfile-vers-jvm_dtrace delete mode 100644 hotspot/make/solaris/makefiles/optimized.make delete mode 100644 hotspot/make/solaris/makefiles/product.make delete mode 100644 hotspot/make/solaris/makefiles/reorder_CORE_amd64 delete mode 100644 hotspot/make/solaris/makefiles/rules.make delete mode 100644 hotspot/make/solaris/makefiles/sparc.make delete mode 100644 hotspot/make/solaris/makefiles/sparcWorks.make delete mode 100644 hotspot/make/solaris/makefiles/sparcv9.make delete mode 100644 hotspot/make/solaris/makefiles/tiered.make delete mode 100644 hotspot/make/solaris/makefiles/top.make delete mode 100644 hotspot/make/solaris/makefiles/trace.make delete mode 100644 hotspot/make/solaris/makefiles/vm.make delete mode 100644 hotspot/make/solaris/platform_amd64 delete mode 100644 hotspot/make/solaris/platform_amd64.gcc delete mode 100644 hotspot/make/solaris/platform_i486 delete mode 100644 hotspot/make/solaris/platform_i486.gcc delete mode 100644 hotspot/make/solaris/platform_sparc delete mode 100644 hotspot/make/solaris/platform_sparc.gcc delete mode 100644 hotspot/make/solaris/platform_sparcv9 delete mode 100644 hotspot/make/solaris/platform_sparcv9.gcc rename hotspot/{makefiles => make}/symbols/symbols-aix (100%) rename hotspot/{makefiles => make}/symbols/symbols-aix-debug (100%) rename hotspot/{makefiles => make}/symbols/symbols-linux (100%) rename hotspot/{makefiles => make}/symbols/symbols-macosx (100%) rename hotspot/{makefiles => make}/symbols/symbols-shared (100%) rename hotspot/{makefiles => make}/symbols/symbols-solaris (100%) rename hotspot/{makefiles => make}/symbols/symbols-solaris-dtrace-compiler1 (100%) rename hotspot/{makefiles => make}/symbols/symbols-solaris-dtrace-compiler2 (100%) rename hotspot/{makefiles => make}/symbols/symbols-unix (100%) delete mode 100644 hotspot/make/windows/build.bat delete mode 100644 hotspot/make/windows/build.make delete mode 100644 hotspot/make/windows/build_vm_def.sh delete mode 100644 hotspot/make/windows/create.bat delete mode 100644 hotspot/make/windows/create_obj_files.sh delete mode 100644 hotspot/make/windows/cross_build.bat delete mode 100644 hotspot/make/windows/get_msc_ver.sh delete mode 100644 hotspot/make/windows/jvmexp.lcf delete mode 100644 hotspot/make/windows/jvmexp_g.lcf delete mode 100644 hotspot/make/windows/makefiles/adlc.make delete mode 100644 hotspot/make/windows/makefiles/compile.make delete mode 100644 hotspot/make/windows/makefiles/debug.make delete mode 100644 hotspot/make/windows/makefiles/defs.make delete mode 100644 hotspot/make/windows/makefiles/fastdebug.make delete mode 100644 hotspot/make/windows/makefiles/generated.make delete mode 100644 hotspot/make/windows/makefiles/jvmti.make delete mode 100644 hotspot/make/windows/makefiles/product.make delete mode 100644 hotspot/make/windows/makefiles/projectcreator.make delete mode 100644 hotspot/make/windows/makefiles/rules.make delete mode 100644 hotspot/make/windows/makefiles/sanity.make delete mode 100644 hotspot/make/windows/makefiles/shared.make delete mode 100644 hotspot/make/windows/makefiles/top.make delete mode 100644 hotspot/make/windows/makefiles/trace.make delete mode 100644 hotspot/make/windows/makefiles/vm.make delete mode 100644 hotspot/make/windows/projectfiles/common/Makefile delete mode 100644 hotspot/make/windows/projectfiles/compiler1/Makefile delete mode 100644 hotspot/make/windows/projectfiles/compiler1/vm.def delete mode 100644 hotspot/make/windows/projectfiles/compiler1/vm.dsw delete mode 100644 hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsp delete mode 100644 hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsw delete mode 100644 hotspot/make/windows/projectfiles/compiler2/Makefile delete mode 100644 hotspot/make/windows/projectfiles/compiler2/vm.def delete mode 100644 hotspot/make/windows/projectfiles/compiler2/vm.dsw delete mode 100644 hotspot/make/windows/projectfiles/core/Makefile delete mode 100644 hotspot/make/windows/projectfiles/core/vm.def delete mode 100644 hotspot/make/windows/projectfiles/core/vm.dsw delete mode 100644 hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsp delete mode 100644 hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsw delete mode 100644 hotspot/make/windows/projectfiles/tiered/Makefile delete mode 100644 hotspot/make/windows/projectfiles/tiered/vm.def delete mode 100644 hotspot/make/windows/projectfiles/tiered/vm.dsw diff --git a/hotspot/makefiles/BuildHotspot.gmk b/hotspot/make/BuildHotspot.gmk similarity index 100% rename from hotspot/makefiles/BuildHotspot.gmk rename to hotspot/make/BuildHotspot.gmk diff --git a/hotspot/makefiles/Dist.gmk b/hotspot/make/Dist.gmk similarity index 100% rename from hotspot/makefiles/Dist.gmk rename to hotspot/make/Dist.gmk diff --git a/hotspot/makefiles/HotspotCommon.gmk b/hotspot/make/HotspotCommon.gmk similarity index 100% rename from hotspot/makefiles/HotspotCommon.gmk rename to hotspot/make/HotspotCommon.gmk diff --git a/hotspot/make/Makefile b/hotspot/make/Makefile deleted file mode 100644 index db2b96e25e0..00000000000 --- a/hotspot/make/Makefile +++ /dev/null @@ -1,895 +0,0 @@ -# -# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Top level gnumake file for hotspot builds -# -# Default is to build the both product images and construct an export dir. -# The default export directory name is `pwd`/export-$(PLATFORM). -# -# Use: 'gnumake help' for more information. -# -# This makefile uses the default settings for where to find compilers and -# tools, and obeys the ALT_* variable settings used by the other JDK -# workspaces. -# - -# Expected/optional make variables defined on make command line: -# LP64=1 or ARCH_DATA_MODEL=64 for 64bit build -# -# Expected/optional make variables or environment variables: -# ALT_SLASH_JAVA Location of /java or J: -# ALT_BOOTDIR Previous JDK home directory for javac compiler -# ALT_OUTPUTDIR Output directory to use for hotspot build -# ALT_EXPORT_PATH Directory to export hotspot build to -# ALT_JDK_IMPORT_PATH Current JDK build (only for create_jdk rules) -# ALT_JDK_TARGET_IMPORT_PATH Current JDK build when cross-compiling -# -# Version strings and numbers: -# VERSION_SHORT Current JDK version (e.g. 9.0.0) -# JDK_PREVIOUS_VERSION Previous (bootdir) JDK version (e.g. 1.5.0) (Only needed -# to facilitate standalone build.) -# VERSION_STRING Full version string to use (e.g. "9.0.0-ea-b42") -# VERSION_MAJOR Major number for version (e.g. 9) -# VERSION_MINOR Minor number for version (e.g. 0) -# VERSION_SECURITY Security number for version (e.g. 0) -# VERSION_PATCH Patch number for version (e.g. 0) -# - -# Default is build both product fastdebug and create export area - -# Allow to build HotSpot in local directory from sources specified by GAMMADIR. -# After make/defs.make GAMMADIR is defined. -ifdef GAMMADIR - ifndef ALT_OUTPUTDIR - ALT_OUTPUTDIR := $(shell pwd) - endif - include $(GAMMADIR)/make/defs.make -else - include defs.make -endif - -include $(GAMMADIR)/make/altsrc.make - --include $(HS_ALT_MAKE)/Makefile.make - -ifneq ($(ALT_OUTPUTDIR),) - ALT_OUT=ALT_OUTPUTDIR=$(ALT_OUTPUTDIR) -else - ALT_OUT= -endif - -# Typical C1/C2 targets made available with this Makefile -C1_VM_TARGETS=product1 fastdebug1 optimized1 debug1 -C2_VM_TARGETS=product fastdebug optimized debug -CORE_VM_TARGETS=productcore fastdebugcore optimizedcore debugcore -ZERO_VM_TARGETS=productzero fastdebugzero optimizedzero debugzero -SHARK_VM_TARGETS=productshark fastdebugshark optimizedshark debugshark -MINIMAL1_VM_TARGETS=productminimal1 fastdebugminimal1 debugminimal1 - -COMMON_VM_PRODUCT_TARGETS=product product1 docs export_product -COMMON_VM_FASTDEBUG_TARGETS=fastdebug fastdebug1 docs export_fastdebug -COMMON_VM_DEBUG_TARGETS=debug debug1 docs export_debug -COMMON_VM_OPTIMIZED_TARGETS=optimized optimized1 docs export_optimized - -# JDK directory list -JDK_DIRS=bin include lib demo - -all: all_product all_fastdebug - -ifeq ($(JVM_VARIANT_MINIMAL1),true) -all_product: productminimal1 -all_fastdebug: fastdebugminimal1 -all_debug: debugminimal1 -endif - -ifdef BUILD_CLIENT_ONLY -all_product: product1 docs export_product -all_fastdebug: fastdebug1 docs export_fastdebug -all_debug: debug1 docs export_debug -all_optimized: optimized1 docs export_optimized -else -ifeq ($(MACOSX_UNIVERSAL),true) -all_product: universal_product -all_fastdebug: universal_fastdebug -all_debug: universal_debug -all_optimized: universal_optimized -else -all_product: $(COMMON_VM_PRODUCT_TARGETS) -all_fastdebug: $(COMMON_VM_FASTDEBUG_TARGETS) -all_debug: $(COMMON_VM_DEBUG_TARGETS) -all_optimized: $(COMMON_VM_OPTIMIZED_TARGETS) -endif -endif - -allzero: all_productzero all_fastdebugzero -all_productzero: productzero docs export_product -all_fastdebugzero: fastdebugzero docs export_fastdebug -all_debugzero: debugzero docs export_debug -all_optimizedzero: optimizedzero docs export_optimized - -allshark: all_productshark all_fastdebugshark -all_productshark: productshark docs export_product -all_fastdebugshark: fastdebugshark docs export_fastdebug -all_debugshark: debugshark docs export_debug -all_optimizedshark: optimizedshark docs export_optimized - -allcore: all_productcore all_fastdebugcore -all_productcore: productcore docs export_product -all_fastdebugcore: fastdebugcore docs export_fastdebug -all_debugcore: debugcore docs export_debug -all_optimizedcore: optimizedcore docs export_optimized - -# Do everything -world: all create_jdk - -# Build or export docs -docs: -ifeq ($(OSNAME),windows) - @$(ECHO) "No docs ($(VM_TARGET)) for windows" -else -# We specify 'BUILD_FLAVOR=product' so that the proper -# ENABLE_FULL_DEBUG_SYMBOLS value is used. - $(CD) $(OUTPUTDIR); \ - $(MAKE) -f $(ABS_OS_MAKEFILE) \ - $(MAKE_ARGS) BUILD_FLAVOR=product docs -endif - -# Output directories -C1_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler1 -C2_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_compiler2 -CORE_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_core -MINIMAL1_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_minimal1 -ZERO_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_zero -SHARK_DIR =$(OUTPUTDIR)/$(VM_PLATFORM)_shark - -# Build variation of hotspot -$(C1_VM_TARGETS): - $(CD) $(GAMMADIR)/make; \ - $(MAKE) BUILD_DIR=$(C1_DIR) BUILD_FLAVOR=$(@:%1=%) VM_TARGET=$@ generic_build1 $(ALT_OUT) - -$(C2_VM_TARGETS): - $(CD) $(GAMMADIR)/make; \ - $(MAKE) BUILD_DIR=$(C2_DIR) BUILD_FLAVOR=$@ VM_TARGET=$@ generic_build2 $(ALT_OUT) - -$(CORE_VM_TARGETS): - $(CD) $(GAMMADIR)/make; \ - $(MAKE) BUILD_DIR=$(CORE_DIR) BUILD_FLAVOR=$(@:%core=%) VM_TARGET=$@ generic_buildcore $(ALT_OUT) - -$(ZERO_VM_TARGETS): - $(CD) $(GAMMADIR)/make; \ - $(MAKE) BUILD_DIR=$(ZERO_DIR) BUILD_FLAVOR=$(@:%zero=%) VM_TARGET=$@ generic_buildzero $(ALT_OUT) - -$(SHARK_VM_TARGETS): - $(CD) $(GAMMADIR)/make; \ - $(MAKE) BUILD_DIR=$(SHARK_DIR) BUILD_FLAVOR=$(@:%shark=%) VM_TARGET=$@ generic_buildshark $(ALT_OUT) - -$(MINIMAL1_VM_TARGETS): - $(CD) $(GAMMADIR)/make; \ - $(MAKE) BUILD_DIR=$(MINIMAL1_DIR) BUILD_FLAVOR=$(@:%minimal1=%) VM_TARGET=$@ generic_buildminimal1 $(ALT_OUT) - -# Install hotspot script in build directory -HOTSPOT_SCRIPT=$(BUILD_DIR)/$(BUILD_FLAVOR)/hotspot -$(HOTSPOT_SCRIPT): $(GAMMADIR)/make/hotspot.script - $(QUIETLY) $(MKDIR) -p $(BUILD_DIR)/$(BUILD_FLAVOR) - $(QUIETLY) cat $< | sed -e 's|@@LIBARCH@@|$(LIBARCH)|g' | sed -e 's|@@JDK_IMPORT_PATH@@|$(JDK_IMPORT_PATH)|g' > $@ - $(QUIETLY) chmod +x $@ - -# Build compiler1 (client) rule, different for platforms -generic_build1: $(HOTSPOT_SCRIPT) - $(MKDIR) -p $(OUTPUTDIR) -ifeq ($(OSNAME),windows) - ifeq ($(ARCH_DATA_MODEL), 32) - $(CD) $(OUTPUTDIR); \ - $(NMAKE) -f $(ABS_OS_MAKEFILE) \ - Variant=compiler1 \ - WorkSpace=$(ABS_GAMMADIR) \ - BootStrapDir=$(ABS_BOOTDIR) \ - BuildUser=$(USERNAME) \ - $(MAKE_ARGS) $(VM_TARGET:%1=%) - else - @$(ECHO) "No compiler1 ($(VM_TARGET)) for ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)" - endif -else - ifeq ($(ARCH_DATA_MODEL), 32) - $(CD) $(OUTPUTDIR); \ - $(MAKE) -f $(ABS_OS_MAKEFILE) \ - $(MAKE_ARGS) $(VM_TARGET) - else - @$(ECHO) "No compiler1 ($(VM_TARGET)) for ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)" - endif -endif - -# Build compiler2 (server) rule, different for platforms -generic_build2: $(HOTSPOT_SCRIPT) - $(MKDIR) -p $(OUTPUTDIR) -ifeq ($(OSNAME),windows) - $(CD) $(OUTPUTDIR); \ - $(NMAKE) -f $(ABS_OS_MAKEFILE) \ - Variant=compiler2 \ - WorkSpace=$(ABS_GAMMADIR) \ - BootStrapDir=$(ABS_BOOTDIR) \ - BuildUser=$(USERNAME) \ - $(MAKE_ARGS) $(VM_TARGET) -else - $(CD) $(OUTPUTDIR); \ - $(MAKE) -f $(ABS_OS_MAKEFILE) \ - $(MAKE_ARGS) $(VM_TARGET) -endif - -# NOTE: Changes in this file was just to facilitate comparison when -# developing the new build, and should not be integrated. -generic_buildcore: $(HOTSPOT_SCRIPT) -#ifeq ($(HS_ARCH),ppc) -# ifeq ($(ARCH_DATA_MODEL),64) - $(MKDIR) -p $(OUTPUTDIR) - $(CD) $(OUTPUTDIR); \ - $(MAKE) -f $(ABS_OS_MAKEFILE) \ - $(MAKE_ARGS) $(VM_TARGET) -# else -# @$(ECHO) "No ($(VM_TARGET)) for ppc ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)" -# endif -#else -# @$(ECHO) "No ($(VM_TARGET)) for $(HS_ARCH)" -#endif - -generic_buildzero: $(HOTSPOT_SCRIPT) - $(MKDIR) -p $(OUTPUTDIR) - $(CD) $(OUTPUTDIR); \ - $(MAKE) -f $(ABS_OS_MAKEFILE) \ - $(MAKE_ARGS) $(VM_TARGET) - -generic_buildshark: $(HOTSPOT_SCRIPT) - $(MKDIR) -p $(OUTPUTDIR) - $(CD) $(OUTPUTDIR); \ - $(MAKE) -f $(ABS_OS_MAKEFILE) \ - $(MAKE_ARGS) $(VM_TARGET) - -generic_buildminimal1: $(HOTSPOT_SCRIPT) -ifeq ($(JVM_VARIANT_MINIMAL1),true) - $(MKDIR) -p $(OUTPUTDIR) - ifeq ($(ARCH_DATA_MODEL), 32) - ifeq ($(OSNAME),windows) - $(ECHO) "No ($(VM_TARGET)) for $(OSNAME) ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)" ; - else - ifeq ($(OSNAME),solaris) - $(ECHO) "No ($(VM_TARGET)) for $(OSNAME) ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)" ; - else - $(CD) $(OUTPUTDIR); \ - $(MAKE) -f $(ABS_OS_MAKEFILE) $(MAKE_ARGS) $(VM_TARGET) ; - endif - endif - else - @$(ECHO) "No ($(VM_TARGET)) for $(OSNAME) ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)" - endif -else - @$(ECHO) "Error: trying to build a minimal target but JVM_VARIANT_MINIMAL1 is not true." -endif - -remove_old_debuginfo: -ifeq ($(JVM_VARIANT_CLIENT), true) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - ifeq ($(OSNAME), windows) - $(RM) -f $(EXPORT_CLIENT_DIR)/jvm.map $(EXPORT_CLIENT_DIR)/jvm.pdb - else - $(RM) -f $(EXPORT_CLIENT_DIR)/libjvm.debuginfo - endif - else - $(RM) -f $(EXPORT_CLIENT_DIR)/libjvm.diz - endif -endif -ifeq ($(findstring true, $(JVM_VARIANT_SERVER) $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - ifeq ($(OSNAME), windows) - $(RM) -f $(EXPORT_SERVER_DIR)/jvm.map $(EXPORT_SERVER_DIR)/jvm.pdb - else - ifeq ($(OS_VENDOR), Darwin) - $(RM) -rf $(EXPORT_SERVER_DIR)/libjvm.dylib.dSYM - else - $(RM) -f $(EXPORT_SERVER_DIR)/libjvm.debuginfo - endif - endif - else - $(RM) -f $(EXPORT_SERVER_DIR)/libjvm.diz - endif -endif -ifeq ($(JVM_VARIANT_MINIMAL1),true) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(RM) -f $(EXPORT_MINIMAL_DIR)/libjvm.debuginfo - else - $(RM) -f $(EXPORT_MINIMAL_DIR)/libjvm.diz - endif -endif - -# Export file rule -generic_export: $(EXPORT_LIST) remove_old_debuginfo - -export_product: - $(MAKE) BUILD_FLAVOR=$(@:export_%=%) generic_export -export_fastdebug: - $(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export -export_debug: - $(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export -export_optimized: - $(MAKE) BUILD_FLAVOR=$(@:export_%=%) EXPORT_SUBDIR=/$(@:export_%=%) generic_export - -export_product_jdk:: - $(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR) generic_export -export_optimized_jdk:: - $(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) generic_export -export_fastdebug_jdk:: - $(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) generic_export -export_debug_jdk:: - $(MAKE) BUILD_FLAVOR=$(@:export_%_jdk=%) ALT_EXPORT_PATH=$(JDK_IMAGE_DIR)/$(@:export_%_jdk=%) generic_export - -# Export file copy rules -XUSAGE=$(HS_SRC_DIR)/share/vm/Xusage.txt -DOCS_DIR=$(OUTPUTDIR)/$(VM_PLATFORM)_docs -C1_BUILD_DIR =$(C1_DIR)/$(BUILD_FLAVOR) -C2_BUILD_DIR =$(C2_DIR)/$(BUILD_FLAVOR) -CORE_BUILD_DIR =$(CORE_DIR)/$(BUILD_FLAVOR) -MINIMAL1_BUILD_DIR=$(MINIMAL1_DIR)/$(BUILD_FLAVOR) -ZERO_BUILD_DIR =$(ZERO_DIR)/$(BUILD_FLAVOR) -SHARK_BUILD_DIR =$(SHARK_DIR)/$(BUILD_FLAVOR) - -# Server (C2) -ifeq ($(JVM_VARIANT_SERVER), true) -# Common -$(EXPORT_SERVER_DIR)/%.diz: $(C2_BUILD_DIR)/%.diz - $(install-file) -$(EXPORT_LIB_DIR)/%.jar: $(C2_BUILD_DIR)/../generated/%.jar - $(install-file) -$(EXPORT_INCLUDE_DIR)/%: $(C2_BUILD_DIR)/../generated/jvmtifiles/% - $(install-file) -# Windows -$(EXPORT_SERVER_DIR)/%.dll: $(C2_BUILD_DIR)/%.dll - $(install-file) -$(EXPORT_SERVER_DIR)/%.pdb: $(C2_BUILD_DIR)/%.pdb - $(install-file) -$(EXPORT_SERVER_DIR)/%.map: $(C2_BUILD_DIR)/%.map - $(install-file) -$(EXPORT_LIB_DIR)/%.lib: $(C2_BUILD_DIR)/%.lib - $(install-file) -$(EXPORT_BIN_DIR)/%.diz: $(C2_BUILD_DIR)/%.diz - $(install-file) -$(EXPORT_BIN_DIR)/%.dll: $(C2_BUILD_DIR)/%.dll - $(install-file) -$(EXPORT_BIN_DIR)/%.pdb: $(C2_BUILD_DIR)/%.pdb - $(install-file) -$(EXPORT_BIN_DIR)/%.map: $(C2_BUILD_DIR)/%.map - $(install-file) -# Unix -$(EXPORT_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_SERVER_DIR)/64/%.$(LIBRARY_SUFFIX): $(C2_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_LIB_ARCH_DIR)/%.debuginfo: $(C2_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_SERVER_DIR)/%.debuginfo: $(C2_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_SERVER_DIR)/64/%.debuginfo: $(C2_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_LIB_ARCH_DIR)/%.diz: $(C2_BUILD_DIR)/%.diz - $(install-file) -$(EXPORT_SERVER_DIR)/64/%.diz: $(C2_BUILD_DIR)/%.diz - $(install-file) -# MacOS X -$(EXPORT_LIB_ARCH_DIR)/%.dSYM: $(C2_BUILD_DIR)/%.dSYM - $(install-dir) -$(EXPORT_SERVER_DIR)/%.dSYM: $(C2_BUILD_DIR)/%.dSYM - $(install-dir) -$(EXPORT_SERVER_DIR)/%.symbols: $(C2_BUILD_DIR)/%.symbols - $(install-file) -endif - -# Client (C1) -ifeq ($(JVM_VARIANT_CLIENT), true) -# Common -$(EXPORT_CLIENT_DIR)/%.diz: $(C1_BUILD_DIR)/%.diz - $(install-file) -$(EXPORT_LIB_DIR)/%.jar: $(C1_BUILD_DIR)/../generated/%.jar - $(install-file) -$(EXPORT_INCLUDE_DIR)/%: $(C1_BUILD_DIR)/../generated/jvmtifiles/% - $(install-file) -# Windows -$(EXPORT_CLIENT_DIR)/%.dll: $(C1_BUILD_DIR)/%.dll - $(install-file) -$(EXPORT_CLIENT_DIR)/%.pdb: $(C1_BUILD_DIR)/%.pdb - $(install-file) -$(EXPORT_CLIENT_DIR)/%.map: $(C1_BUILD_DIR)/%.map - $(install-file) -$(EXPORT_LIB_DIR)/%.lib: $(C1_BUILD_DIR)/%.lib - $(install-file) -$(EXPORT_BIN_DIR)/%.diz: $(C1_BUILD_DIR)/%.diz - $(install-file) -$(EXPORT_BIN_DIR)/%.dll: $(C1_BUILD_DIR)/%.dll - $(install-file) -$(EXPORT_BIN_DIR)/%.pdb: $(C1_BUILD_DIR)/%.pdb - $(install-file) -$(EXPORT_BIN_DIR)/%.map: $(C1_BUILD_DIR)/%.map - $(install-file) -# Unix -$(EXPORT_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_CLIENT_DIR)/%.$(LIBRARY_SUFFIX): $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_CLIENT_DIR)/64/%.$(LIBRARY_SUFFIX): $(C1_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_LIB_ARCH_DIR)/%.debuginfo: $(C1_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_CLIENT_DIR)/%.debuginfo: $(C1_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_CLIENT_DIR)/64/%.debuginfo: $(C1_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_LIB_ARCH_DIR)/%.diz: $(C1_BUILD_DIR)/%.diz - $(install-file) -$(EXPORT_CLIENT_DIR)/64/%.diz: $(C1_BUILD_DIR)/%.diz - $(install-file) -# MacOS X -$(EXPORT_LIB_ARCH_DIR)/%.dSYM: $(C1_BUILD_DIR)/%.dSYM - $(install-dir) -$(EXPORT_CLIENT_DIR)/%.dSYM: $(C1_BUILD_DIR)/%.dSYM - $(install-dir) -endif - -# Minimal1 -ifeq ($(JVM_VARIANT_MINIMAL1), true) -# Common -$(EXPORT_MINIMAL_DIR)/%.diz: $(MINIMAL1_BUILD_DIR)/%.diz - $(install-file) -$(EXPORT_LIB_DIR)/%.jar: $(MINIMAL1_BUILD_DIR)/../generated/%.jar - $(install-file) -$(EXPORT_INCLUDE_DIR)/%: $(MINIMAL1_BUILD_DIR)/../generated/jvmtifiles/% - $(install-file) -# Windows -$(EXPORT_MINIMAL_DIR)/%.dll: $(MINIMAL1_BUILD_DIR)/%.dll - $(install-file) -$(EXPORT_MINIMAL_DIR)/%.pdb: $(MINIMAL1_BUILD_DIR)/%.pdb - $(install-file) -$(EXPORT_MINIMAL_DIR)/%.map: $(MINIMAL1_BUILD_DIR)/%.map - $(install-file) -$(EXPORT_LIB_DIR)/%.lib: $(MINIMAL1_BUILD_DIR)/%.lib - $(install-file) -$(EXPORT_BIN_DIR)/%.diz: $(MINIMAL1_BUILD_DIR)/%.diz - $(install-file) -$(EXPORT_BIN_DIR)/%.dll: $(MINIMAL1_BUILD_DIR)/%.dll - $(install-file) -$(EXPORT_BIN_DIR)/%.pdb: $(MINIMAL1_BUILD_DIR)/%.pdb - $(install-file) -$(EXPORT_BIN_DIR)/%.map: $(MINIMAL1_BUILD_DIR)/%.map - $(install-file) -# Unix -$(EXPORT_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_MINIMAL_DIR)/%.$(LIBRARY_SUFFIX): $(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_MINIMAL_DIR)/64/%.$(LIBRARY_SUFFIX): $(MINIMAL1_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_LIB_ARCH_DIR)/%.debuginfo: $(MINIMAL1_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_MINIMAL_DIR)/%.debuginfo: $(MINIMAL1_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_MINIMAL_DIR)/64/%.debuginfo: $(MINIMAL1_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_LIB_ARCH_DIR)/%.diz: $(MINIMAL1_BUILD_DIR)/%.diz - $(install-file) -$(EXPORT_MINIMAL_DIR)/64/%.diz: $(MINIMAL1_BUILD_DIR)/%.diz - $(install-file) -# MacOS X does not support Minimal1 config -endif - -# Zero -ifeq ($(JVM_VARIANT_ZERO), true) -# Common -$(EXPORT_LIB_DIR)/%.jar: $(ZERO_BUILD_DIR)/../generated/%.jar - $(install-file) -$(EXPORT_INCLUDE_DIR)/%: $(ZERO_BUILD_DIR)/../generated/jvmtifiles/% - $(install-file) -# Unix -$(EXPORT_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_LIB_ARCH_DIR)/%.debuginfo: $(ZERO_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_LIB_ARCH_DIR)/%.diz: $(ZERO_BUILD_DIR)/%.diz - $(install-file) -$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(ZERO_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_SERVER_DIR)/%.debuginfo: $(ZERO_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_SERVER_DIR)/%.diz: $(ZERO_BUILD_DIR)/%.diz - $(install-file) -# MacOS X -$(EXPORT_LIB_ARCH_DIR)/%.dSYM: $(ZERO_BUILD_DIR)/%.dSYM - $(install-dir) -$(EXPORT_SERVER_DIR)/%.dSYM: $(ZERO_BUILD_DIR)/%.dSYM - $(install-dir) -endif - -# Core -ifeq ($(JVM_VARIANT_CORE), true) -# Common -$(EXPORT_LIB_DIR)/%.jar: $(CORE_BUILD_DIR)/../generated/%.jar - $(install-file) -$(EXPORT_INCLUDE_DIR)/%: $(CORE_BUILD_DIR)/../generated/jvmtifiles/% - $(install-file) -# Unix -$(EXPORT_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(CORE_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_LIB_ARCH_DIR)/%.debuginfo: $(CORE_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_LIB_ARCH_DIR)/%.diz: $(CORE_BUILD_DIR)/%.diz - $(install-file) -$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(CORE_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_SERVER_DIR)/%.debuginfo: $(CORE_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_SERVER_DIR)/%.diz: $(CORE_BUILD_DIR)/%.diz - $(install-file) -endif - -# Shark -ifeq ($(JVM_VARIANT_ZEROSHARK), true) -# Common -$(EXPORT_LIB_DIR)/%.jar: $(SHARK_BUILD_DIR)/../generated/%.jar - $(install-file) -$(EXPORT_INCLUDE_DIR)/%: $(SHARK_BUILD_DIR)/../generated/jvmtifiles/% - $(install-file) -# Unix -$(EXPORT_LIB_ARCH_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_LIB_ARCH_DIR)/%.debuginfo): $(SHARK_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_LIB_ARCH_DIR)/%.diz: $(SHARK_BUILD_DIR)/%.diz - $(install-file) -$(EXPORT_SERVER_DIR)/%.$(LIBRARY_SUFFIX): $(SHARK_BUILD_DIR)/%.$(LIBRARY_SUFFIX) - $(install-file) -$(EXPORT_SERVER_DIR)/%.debuginfo: $(SHARK_BUILD_DIR)/%.debuginfo - $(install-file) -$(EXPORT_SERVER_DIR)/%.diz: $(SHARK_BUILD_DIR)/%.diz - $(install-file) -# MacOS X -$(EXPORT_LIB_ARCH_DIR)/%.dSYM: $(SHARK_BUILD_DIR)/%.dSYM - $(install-dir) -$(EXPORT_SERVER_DIR)/%.dSYM: $(SHARK_BUILD_DIR)/%.dSYM - $(install-dir) -endif - -$(EXPORT_INCLUDE_DIR)/%: $(HS_SRC_DIR)/share/vm/code/% - $(install-file) - -$(EXPORT_INCLUDE_DIR)/%: $(HS_SRC_DIR)/share/vm/prims/% - $(install-file) - -HS_JNI_ARCH_SRC=$(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(HS_ARCH)/vm/jni_$(HS_ARCH).h) -$(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h: $(HS_JNI_ARCH_SRC) - $(install-file) - -$(EXPORT_INCLUDE_DIR)/%: $(HS_SRC_DIR)/share/vm/services/% - $(install-file) - -JFR_EXISTS=$(shell if [ -d $(HS_ALT_SRC) ]; then echo 1; else echo 0; fi) -# export jfr.h -ifeq ($JFR_EXISTS,1) -$(EXPORT_INCLUDE_DIR)/%: $(HS_ALT_SRC)/share/vm/jfr/% - $(install-file) -else -$(EXPORT_INCLUDE_DIR)/jfr.h: -endif - -# Doc files (jvmti.html) -$(EXPORT_DOCS_DIR)/platform/jvmti/%: $(DOCS_DIR)/% - $(install-file) - -# Xusage file -$(EXPORT_SERVER_DIR)/Xusage.txt $(EXPORT_CLIENT_DIR)/Xusage.txt $(EXPORT_MINIMAL_DIR)/Xusage.txt: $(XUSAGE) - $(prep-target) - $(RM) $@.temp - $(SED) 's/\(separated by \)[;:]/\1$(PATH_SEP)/g' $< > $@.temp - $(MV) $@.temp $@ - -# -# Clean rules -# -clobber clean: clean_build clean_export clean_jdk -clean_build: - $(RM) -r $(C1_DIR) - $(RM) -r $(C2_DIR) - $(RM) -r $(CORE_DIR) - $(RM) -r $(ZERO_DIR) - $(RM) -r $(SHARK_DIR) - $(RM) -r $(MINIMAL1_DIR) -clean_export: - $(RM) -r $(EXPORT_PATH) -clean_jdk: - $(RM) -r $(JDK_IMAGE_DIR) - -# -# Create JDK and place this build into it -# -create_jdk: copy_jdk update_jdk - -update_jdk: export_product_jdk export_fastdebug_jdk test_jdk - -copy_jdk: $(JDK_IMAGE_DIR)/bin/java - -$(JDK_IMAGE_DIR)/bin/java: - $(RM) -r $(JDK_IMAGE_DIR) - $(MKDIR) -p $(JDK_IMAGE_DIR) - ($(CD) $(JDK_IMPORT_PATH) && \ - $(TAR) -cf - *) | \ - ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xf -) - - -# Testing the built JVM -RUN_JVM=JAVA_HOME=$(JDK_IMPORT_PATH) $(JDK_IMPORT_PATH)/bin/java -d$(ARCH_DATA_MODEL) -XXaltjvm=$(ALTJVM_DIR) -Dsun.java.launcher.is_altjvm=true -generic_test: - @$(ECHO) "Running with: $(ALTJVM_DIR)" - @$(RUN_JVM) -Xinternalversion - @$(RUN_JVM) -showversion -help - -# C2 test targets -test_product test_optimized test_fastdebug test_debug: - @$(MAKE) generic_test ALTJVM_DIR="$(C2_DIR)/$(@:test_%=%)" - -# C1 test targets -test_product1 test_optimized1 test_fastdebug1 test_debug1: - ifeq ($(ARCH_DATA_MODEL), 32) - @$(MAKE) generic_test ALTJVM_DIR="$(C1_DIR)/$(@:test_%1=%)" - else - @$(ECHO) "No compiler1 ($(@:test_%=%)) for ARCH_DATA_MODEL=$(ARCH_DATA_MODEL)" - endif - -# Zero test targets -test_productzero test_optimizedzero test_fastdebugzero test_debugzero: - @$(MAKE) generic_test ALTJVM_DIR="$(ZERO_DIR)/$(@:test_%zero=%)" - -# Shark test targets -test_productshark test_optimizedshark test_fastdebugshark test_debugshark: - @$(MAKE) generic_test ALTJVM_DIR="$(SHARK_DIR)/$(@:test_%shark=%)" - -# Minimal1 test targets -test_productminimal1 test_optimizedminimal1 test_fastdebugminimal1 test_debugminimal1: - @$(MAKE) generic_test ALTJVM_DIR="$(MINIMAL1_DIR)/$(@:test_%minimal1=%)" - - -test_jdk: - ifeq ($(JVM_VARIANT_CLIENT), true) - $(JDK_IMAGE_DIR)/bin/java -d$(ARCH_DATA_MODEL) -client -Xinternalversion - $(JDK_IMAGE_DIR)/bin/java -d$(ARCH_DATA_MODEL) -client -version - endif - ifeq ($(findstring true, $(JVM_VARIANT_SERVER)\ - $(JVM_VARIANT_ZERO)$(JVM_VARIANT_ZEROSHARK)), true) - $(JDK_IMAGE_DIR)/bin/java -d$(ARCH_DATA_MODEL) -server -Xinternalversion - $(JDK_IMAGE_DIR)/bin/java -d$(ARCH_DATA_MODEL) -server -version - endif - -copy_product_jdk:: - $(RM) -r $(JDK_IMAGE_DIR) - $(MKDIR) -p $(JDK_IMAGE_DIR) - ($(CD) $(JDK_IMPORT_PATH) && \ - $(TAR) -cf - $(JDK_DIRS)) | \ - ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xf -) - -copy_fastdebug_jdk:: - $(RM) -r $(JDK_IMAGE_DIR)/fastdebug - $(MKDIR) -p $(JDK_IMAGE_DIR)/fastdebug - if [ -d $(JDK_IMPORT_PATH)/fastdebug ] ; then \ - ($(CD) $(JDK_IMPORT_PATH)/fastdebug && \ - $(TAR) -cf - $(JDK_DIRS)) | \ - ($(CD) $(JDK_IMAGE_DIR)/fastdebug && $(TAR) -xf -) ; \ - else \ - ($(CD) $(JDK_IMPORT_PATH) && \ - $(TAR) -cf - $(JDK_DIRS)) | \ - ($(CD) $(JDK_IMAGE_DIR)/fastdebug && $(TAR) -xf -) ; \ - fi - -copy_debug_jdk:: - $(RM) -r $(JDK_IMAGE_DIR)/debug - $(MKDIR) -p $(JDK_IMAGE_DIR)/debug - if [ -d $(JDK_IMPORT_PATH)/debug ] ; then \ - ($(CD) $(JDK_IMPORT_PATH)/debug && \ - $(TAR) -cf - $(JDK_DIRS)) | \ - ($(CD) $(JDK_IMAGE_DIR)/debug && $(TAR) -xf -) ; \ - elif [ -d $(JDK_IMPORT_PATH)/fastdebug ] ; then \ - ($(CD) $(JDK_IMPORT_PATH)/fastdebug && \ - $(TAR) -cf - $(JDK_DIRS)) | \ - ($(CD) $(JDK_IMAGE_DIR)/debug && $(TAR) -xf -) ; \ - else \ - ($(CD) $(JDK_IMPORT_PATH) && \ - $(TAR) -cf - $(JDK_DIRS)) | \ - ($(CD) $(JDK_IMAGE_DIR)/debug && $(TAR) -xf -) ; \ - fi - -copy_optimized_jdk:: - $(RM) -r $(JDK_IMAGE_DIR)/optimized - $(MKDIR) -p $(JDK_IMAGE_DIR)/optimized - if [ -d $(JDK_IMPORT_PATH)/optimized ] ; then \ - ($(CD) $(JDK_IMPORT_PATH)/optimized && \ - $(TAR) -cf - $(JDK_DIRS)) | \ - ($(CD) $(JDK_IMAGE_DIR)/optimized && $(TAR) -xf -) ; \ - else \ - ($(CD) $(JDK_IMPORT_PATH) && \ - $(TAR) -cf - $(JDK_DIRS)) | \ - ($(CD) $(JDK_IMAGE_DIR)/optimized && $(TAR) -xf -) ; \ - fi - -# -# Check target -# -check: variable_check - -# -# Help target -# -help: intro_help target_help variable_help notes_help examples_help - -# Intro help message -intro_help: - @$(ECHO) \ -"Makefile for the Hotspot workspace." - @$(ECHO) \ -"Default behavior is to build and create an export area for the j2se builds." - -# Target help -target_help: - @$(ECHO) "help: This help message" - @$(ECHO) "all: Same as: all_product all_fastdebug" - @$(ECHO) "world: Same as: all create_jdk" - @$(ECHO) "all_product: Same as: product product1 export_product" - @$(ECHO) "all_fastdebug: Same as: fastdebug fastdebug1 export_fastdebug" - @$(ECHO) "all_debug: Same as: debug debug1 export_debug" - @$(ECHO) "all_optimized: Same as: optimized optimized1 export_optimized" - @$(ECHO) "clean: Clean all areas" - @$(ECHO) "export_product: Export product files to EXPORT_PATH" - @$(ECHO) "export_fastdebug: Export fastdebug files to EXPORT_PATH" - @$(ECHO) "export_debug: Export debug files to EXPORT_PATH" - @$(ECHO) "export_optimized: Export optimized files to EXPORT_PATH" - @$(ECHO) "create_jdk: Create JDK image, export all files into it" - @$(ECHO) "update_jdk: Update JDK image with fresh exported files" - @$(ECHO) " " - @$(ECHO) "Other targets are:" - @$(ECHO) " $(C1_VM_TARGETS)" - @$(ECHO) " $(C2_VM_TARGETS)" - @$(ECHO) " $(MINIMAL1_VM_TARGETS)" - -# Variable help (only common ones used by this workspace) -variable_help: variable_help_intro variable_list variable_help_end -variable_help_intro: - @$(ECHO) "--- Common Variables ---" -variable_help_end: - @$(ECHO) " " - @$(ECHO) "--- Make Arguments ---" - @$(ECHO) "MAKE_ARGS=$(MAKE_ARGS)" - -# One line descriptions for the variables -SLASH_JAVA.desc = Root of all build tools, e.g. /java or J: -OUTPUTDIR.desc = Output directory, default is build/ -BOOTDIR.desc = JDK used to compile agent java source and test with -JDK_IMPORT_PATH.desc = Promoted JDK to copy for 'create_jdk' -JDK_IMAGE_DIR.desc = Directory to place JDK to copy -EXPORT_PATH.desc = Directory to place files to export for JDK build - -# Make variables to print out (description and value) -VARIABLE_PRINTVAL_LIST += \ - SLASH_JAVA \ - OUTPUTDIR \ - BOOTDIR \ - JDK_IMPORT_PATH \ - JDK_IMAGE_DIR \ - EXPORT_PATH - -# Make variables that should refer to directories that exist -VARIABLE_CHECKDIR_LIST += \ - SLASH_JAVA \ - BOOTDIR \ - JDK_IMPORT_PATH - -# For pattern rules below, so all are treated the same -DO_PRINTVAL_LIST=$(VARIABLE_PRINTVAL_LIST:%=%.printval) -DO_CHECKDIR_LIST=$(VARIABLE_CHECKDIR_LIST:%=%.checkdir) - -# Complete variable check -variable_check: $(DO_CHECKDIR_LIST) -variable_list: $(DO_PRINTVAL_LIST) variable_check - -# Pattern rule for printing out a variable -%.printval: - @$(ECHO) " ALT_$* - $($*.desc)" - @$(ECHO) " $*=$($*)" - -# Pattern rule for checking to see if a variable with a directory exists -%.checkdir: - @if [ ! -d $($*) ] ; then \ - $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \ - fi - -# Pattern rule for checking to see if a variable with a file exists -%.checkfil: - @if [ ! -f $($*) ] ; then \ - $(ECHO) "WARNING: $* does not exist, try $(MAKE) sanity"; \ - fi - -# Misc notes on help -notes_help: - @$(ECHO) \ -"--- Notes --- " - @$(ECHO) \ -"- JDK_IMPORT_PATH must refer to a compatible build, not all past promoted" - @$(ECHO) \ -" builds or previous release JDK builds will work." - @$(ECHO) \ -"- The fastest builds have been when the workspace and the BOOTDIR are on" - @$(ECHO) \ -" local disk." - -examples_help: - @$(ECHO) \ -"--- Examples --- " - @$(ECHO) \ -" $(MAKE) all" - @$(ECHO) \ -" $(MAKE) world" - @$(ECHO) \ -" $(MAKE) ALT_BOOTDIR=/opt/java/jdk$(JDK_PREVIOUS_VERSION)" - @$(ECHO) \ -" $(MAKE) ALT_JDK_IMPORT_PATH=/opt/java/jdk$(VERSION_STRING)" - -# Universal build support -ifeq ($(OS_VENDOR), Darwin) -ifeq ($(MACOSX_UNIVERSAL),true) -include $(GAMMADIR)/make/$(OSNAME)/makefiles/universal.gmk -endif -endif - -# Compatibility for transition to new naming -warn_jvmg_deprecated: - echo "Warning: The jvmg target has been replaced with debug" - echo "Warning: Please update your usage" - -jvmg: warn_jvmg_deprecated debug - -jvmg1: warn_jvmg_deprecated debug1 - -jvmgminimal1: warn_jvmg_deprecated debugminimal1 - -jvmgcore: warn_jvmg_deprecated debugcore - -jvmgzero: warn_jvmg_deprecated debugzero - -jvmgshark: warn_jvmg_deprecated debugshark - -# JPRT rule to build this workspace -include $(GAMMADIR)/make/jprt.gmk - -.PHONY: all world clobber clean help $(C1_VM_TARGETS) $(C2_VM_TARGETS) \ - $(MINIMAL1_VM_TARGETS) \ - generic_build1 generic_build2 generic_buildminimal1 generic_export \ - export_product export_fastdebug export_debug export_optimized \ - export_jdk_product export_jdk_fastdebug export_jdk_debug \ - create_jdk copy_jdk update_jdk test_jdk \ - copy_product_jdk copy_fastdebug_jdk copy_debug_jdk \ - $(HS_ALT_MAKE)/Makefile.make remove_old_debuginfo - -.NOTPARALLEL: diff --git a/hotspot/make/aix/Makefile b/hotspot/make/aix/Makefile deleted file mode 100644 index 951a98502fa..00000000000 --- a/hotspot/make/aix/Makefile +++ /dev/null @@ -1,369 +0,0 @@ -# -# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2015 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile creates a build tree and lights off a build. -# You can go back into the build tree and perform rebuilds or -# incremental builds as desired. Be sure to reestablish -# environment variable settings for LD_LIBRARY_PATH and JAVA_HOME. - -# The make process now relies on java and javac. These can be -# specified either implicitly on the PATH, by setting the -# (JDK-inherited) ALT_BOOTDIR environment variable to full path to a -# JDK in which bin/java and bin/javac are present and working (e.g., -# /usr/local/java/jdk1.3/solaris), or via the (JDK-inherited) -# default BOOTDIR path value. Note that one of ALT_BOOTDIR -# or BOOTDIR has to be set. We do *not* search javac, javah, rmic etc. -# from the PATH. -# -# One can set ALT_BOOTDIR or BOOTDIR to point to a jdk that runs on -# an architecture that differs from the target architecture, as long -# as the bootstrap jdk runs under the same flavor of OS as the target -# (i.e., if the target is linux, point to a jdk that runs on a linux -# box). In order to use such a bootstrap jdk, set the make variable -# REMOTE to the desired remote command mechanism, e.g., -# -# make REMOTE="rsh -l me myotherlinuxbox" - -# No tests on Aix. -TEST_IN_BUILD=false - -ifeq ($(GAMMADIR),) -include ../../make/defs.make -else -include $(GAMMADIR)/make/defs.make -endif -include $(GAMMADIR)/make/$(OSNAME)/makefiles/rules.make - -ifndef CC_INTERP - ifndef FORCE_TIERED - FORCE_TIERED=1 - endif -endif - -ifdef LP64 - ifeq ("$(filter $(LP64_ARCH),$(BUILDARCH))","") - _JUNK_ := $(shell echo >&2 \ - $(OSNAME) $(ARCH) "*** ERROR: this platform does not support 64-bit compilers!") - @exit 1 - endif -endif - -# we need to set up LP64 correctly to satisfy sanity checks in adlc -ifneq ("$(filter $(LP64_ARCH),$(BUILDARCH))","") - MFLAGS += " LP64=1 " -endif - -# pass USE_SUNCC further, through MFLAGS -ifdef USE_SUNCC - MFLAGS += " USE_SUNCC=1 " -endif - -# The following renders pathnames in generated Makefiles valid on -# machines other than the machine containing the build tree. -# -# For example, let's say my build tree lives on /files12 on -# exact.east.sun.com. This logic will cause GAMMADIR to begin with -# /net/exact/files12/... -# -# We only do this on SunOS variants, for a couple of reasons: -# * It is extremely rare that source trees exist on other systems -# * It has been claimed that the Linux automounter is flakey, so -# changing GAMMADIR in a way that exercises the automounter could -# prove to be a source of unreliability in the build process. -# Obviously, this Makefile is only relevant on SunOS boxes to begin -# with, but the SunOS conditionalization will make it easier to -# combine Makefiles in the future (assuming we ever do that). - -ifeq ($(OSNAME),solaris) - - # prepend current directory to relative pathnames. - NEW_GAMMADIR := \ - $(shell echo $(GAMMADIR) | \ - sed -e "s=^\([^/].*\)=$(shell pwd)/\1=" \ - ) - unexport NEW_GAMMADIR - - # If NEW_GAMMADIR doesn't already start with "/net/": - ifeq ($(strip $(filter /net/%,$(NEW_GAMMADIR))),) - # prepend /net/$(HOST) - # remove /net/$(HOST) if name already began with /home/ - # remove /net/$(HOST) if name already began with /java/ - # remove /net/$(HOST) if name already began with /lab/ - NEW_GAMMADIR := \ - $(shell echo $(NEW_GAMMADIR) | \ - sed -e "s=^\(.*\)=/net/$(HOST)\1=" \ - -e "s=^/net/$(HOST)/home/=/home/=" \ - -e "s=^/net/$(HOST)/java/=/java/=" \ - -e "s=^/net/$(HOST)/lab/=/lab/=" \ - ) - # Don't use the new value for GAMMADIR unless a file with the new - # name actually exists. - ifneq ($(wildcard $(NEW_GAMMADIR)),) - GAMMADIR := $(NEW_GAMMADIR) - endif - endif - -endif - -# BUILDARCH is set to "zero" for Zero builds. VARIANTARCH -# is used to give the build directories meaningful names. -VARIANTARCH = $(subst i386,i486,$(ZERO_LIBARCH)) - -# There is a (semi-) regular correspondence between make targets and actions: -# -# Target Tree Type Build Dir -# -# debug compiler2 __compiler2/debug -# fastdebug compiler2 __compiler2/fastdebug -# optimized compiler2 __compiler2/optimized -# product compiler2 __compiler2/product -# -# debug1 compiler1 __compiler1/debug -# fastdebug1 compiler1 __compiler1/fastdebug -# optimized1 compiler1 __compiler1/optimized -# product1 compiler1 __compiler1/product -# -# debugcore core __core/debug -# fastdebugcore core __core/fastdebug -# optimizedcore core __core/optimized -# productcore core __core/product -# -# debugzero zero __zero/debug -# fastdebugzero zero __zero/fastdebug -# optimizedzero zero __zero/optimized -# productzero zero __zero/product -# -# debugshark shark __shark/debug -# fastdebugshark shark __shark/fastdebug -# optimizedshark shark __shark/optimized -# productshark shark __shark/product -# -# fastdebugminimal1 minimal1 __minimal1/fastdebug -# productminimal1 minimal1 __minimal1/product -# -# What you get with each target: -# -# debug* - debug compile with asserts enabled -# fastdebug* - optimized compile, but with asserts enabled -# optimized* - optimized compile, no asserts -# product* - the shippable thing: optimized compile, no asserts, -DPRODUCT - -# This target list needs to be coordinated with the usage message -# in the build.sh script: -TARGETS = debug fastdebug optimized product - -ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - SUBDIR_DOCS = $(OSNAME)_$(VARIANTARCH)_docs -else - SUBDIR_DOCS = $(OSNAME)_$(BUILDARCH)_docs -endif -SUBDIRS_C1 = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler1/,$(TARGETS)) -SUBDIRS_C2 = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS)) -SUBDIRS_TIERED = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS)) -SUBDIRS_CORE = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS)) -SUBDIRS_ZERO = $(addprefix $(OSNAME)_$(VARIANTARCH)_zero/,$(TARGETS)) -SUBDIRS_SHARK = $(addprefix $(OSNAME)_$(VARIANTARCH)_shark/,$(TARGETS)) -SUBDIRS_MINIMAL1 = $(addprefix $(OSNAME)_$(BUILDARCH)_minimal1/,$(TARGETS)) - -TARGETS_C2 = $(TARGETS) -TARGETS_C1 = $(addsuffix 1,$(TARGETS)) -TARGETS_TIERED = $(addsuffix tiered,$(TARGETS)) -TARGETS_CORE = $(addsuffix core,$(TARGETS)) -TARGETS_ZERO = $(addsuffix zero,$(TARGETS)) -TARGETS_SHARK = $(addsuffix shark,$(TARGETS)) -TARGETS_MINIMAL1 = $(addsuffix minimal1,$(TARGETS)) - -BUILDTREE_MAKE = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make -BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) -BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING) -BUILDTREE_VARS += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY) ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) ZIPEXE=$(ZIPEXE) - -BUILDTREE = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS) - -#------------------------------------------------------------------------------- - -# Could make everything by default, but that would take a while. -all: - @echo "Try '$(MAKE) ...' where is one or more of" - @echo " $(TARGETS_C2)" - @echo " $(TARGETS_C1)" - @echo " $(TARGETS_CORE)" - @echo " $(TARGETS_ZERO)" - @echo " $(TARGETS_SHARK)" - @echo " $(TARGETS_MINIMAL1)" - -checks: check_os_version check_j2se_version - -# We do not want people accidentally building on old systems (e.g. Linux 2.2.x, -# Solaris 2.5.1, 2.6). -# Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok. - -SUPPORTED_OS_VERSION = AIX -OS_VERSION := $(shell uname -a) -EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION)) - -check_os_version: -ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),) - $(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1; -endif - -# jvmti.make requires XSLT (J2SE 1.4.x or newer): -XSLT_CHECK = $(REMOTE) $(RUN.JAVAP) javax.xml.transform.TransformerFactory -# If not found then fail fast. -check_j2se_version: - $(QUIETLY) if ! $(XSLT_CHECK) > /dev/null 2>&1; then \ - $(REMOTE) $(RUN.JAVA) -version; \ - echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \ - "to bootstrap this build" 1>&2; \ - exit 1; \ - fi - -$(SUBDIRS_TIERED): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=tiered - -$(SUBDIRS_C2): $(BUILDTREE_MAKE) -ifeq ($(FORCE_TIERED),1) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=tiered FORCE_TIERED=1 -else - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=compiler2 -endif - -$(SUBDIRS_C1): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=compiler1 - -$(SUBDIRS_CORE): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=core - -$(SUBDIRS_ZERO): $(BUILDTREE_MAKE) platform_zero - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=zero VARIANTARCH=$(VARIANTARCH) - -$(SUBDIRS_SHARK): $(BUILDTREE_MAKE) platform_zero - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=shark VARIANTARCH=$(VARIANTARCH) - -$(SUBDIRS_MINIMAL1): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=minimal1 - - -platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in - $(SED) 's/@ZERO_ARCHDEF@/$(ZERO_ARCHDEF)/g;s/@ZERO_LIBARCH@/$(ZERO_LIBARCH)/g;' < $< > $@ - -# Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME - -$(TARGETS_C2): $(SUBDIRS_C2) - cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_TIERED): $(SUBDIRS_TIERED) - cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_C1): $(SUBDIRS_C1) - cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_CORE): $(SUBDIRS_CORE) - cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_ZERO): $(SUBDIRS_ZERO) - cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_SHARK): $(SUBDIRS_SHARK) - cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_MINIMAL1): $(SUBDIRS_MINIMAL1) - cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) install -endif - -# Just build the tree, and nothing else: -tree: $(SUBDIRS_C2) -tree1: $(SUBDIRS_C1) -treecore: $(SUBDIRS_CORE) -treezero: $(SUBDIRS_ZERO) -treeshark: $(SUBDIRS_SHARK) -treeminimal1: $(SUBDIRS_MINIMAL1) - -# Doc target. This is the same for all build options. -# Hence create a docs directory beside ...$(ARCH)_[...] -# We specify 'BUILD_FLAVOR=product' so that the proper -# ENABLE_FULL_DEBUG_SYMBOLS value is used. -docs: checks - $(QUIETLY) mkdir -p $(SUBDIR_DOCS) - $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/makefiles/jvmti.make $(MFLAGS) $(BUILDTREE_VARS) JvmtiOutDir=$(SUBDIR_DOCS) BUILD_FLAVOR=product jvmtidocs - -# Synonyms for win32-like targets. -compiler2: debug product - -compiler1: debug1 product1 - -core: debugcore productcore - -zero: debugzero productzero - -shark: debugshark productshark - -clean_docs: - rm -rf $(SUBDIR_DOCS) - -clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark clean_minimal1: - rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@) - -clean: clean_compiler2 clean_compiler1 clean_core clean_zero clean_shark clean_minimal1 clean_docs - -include $(GAMMADIR)/make/cscope.make - -#------------------------------------------------------------------------------- - -.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK) $(TARGETS_MINIMAL1) -.PHONY: tree tree1 treecore treezero treeshark -.PHONY: all compiler1 compiler2 core zero shark -.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs -.PHONY: checks check_os_version check_j2se_version - -.NOTPARALLEL: diff --git a/hotspot/make/aix/adlc_updater b/hotspot/make/aix/adlc_updater deleted file mode 100644 index 99e04e333f2..00000000000 --- a/hotspot/make/aix/adlc_updater +++ /dev/null @@ -1,23 +0,0 @@ -#! /bin/sh -# -# This file is used by adlc.make to selectively update generated -# adlc files. Because source and target diretories are relative -# paths, this file is copied to the target build directory before -# use. -# -# adlc-updater -# -fix_lines() { - # repair bare #line directives in $1 to refer to $2 - # and add an override of __FILE__ with just the basename on the - # first line of the file. - awk < $1 > $1+ -v F2=$2 ' - BEGIN { print "#line 1 \"" F2 "\""; } - /^#line 999999$/ {print "#line " (NR+1) " \"" F2 "\""; next} - {print} - ' - mv $1+ $1 -} -fix_lines $2/$1 $1 -[ -f $3/$1 ] && cmp -s $2/$1 $3/$1 || \ -( [ -f $3/$1 ] && echo Updating $3/$1 ; touch $2/made-change ; mv $2/$1 $3/$1 ) diff --git a/hotspot/make/aix/makefiles/adjust-mflags.sh b/hotspot/make/aix/makefiles/adjust-mflags.sh deleted file mode 100644 index 6c06819fb74..00000000000 --- a/hotspot/make/aix/makefiles/adjust-mflags.sh +++ /dev/null @@ -1,87 +0,0 @@ -#! /bin/sh -# -# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This script is used only from top.make. -# The macro $(MFLAGS-adjusted) calls this script to -# adjust the "-j" arguments to take into account -# the HOTSPOT_BUILD_JOBS variable. The default -# handling of the "-j" argument by gnumake does -# not meet our needs, so we must adjust it ourselves. - -# This argument adjustment applies to two recursive -# calls to "$(MAKE) $(MFLAGS-adjusted)" in top.make. -# One invokes adlc.make, and the other invokes vm.make. -# The adjustment propagates the desired concurrency -# level down to the sub-make (of the adlc or vm). -# The default behavior of gnumake is to run all -# sub-makes without concurrency ("-j1"). - -# Also, we use a make variable rather than an explicit -# "-j" argument to control this setting, so that -# the concurrency setting (which must be tuned separately -# for each MP system) can be set via an environment variable. -# The recommended setting is 1.5x to 2x the number of available -# CPUs on the MP system, which is large enough to keep the CPUs -# busy (even though some jobs may be I/O bound) but not too large, -# we may presume, to overflow the system's swap space. - -set -eu - -default_build_jobs=4 - -case $# in -[12]) true;; -*) >&2 echo "Usage: $0 ${MFLAGS} ${HOTSPOT_BUILD_JOBS}"; exit 2;; -esac - -MFLAGS=$1 -HOTSPOT_BUILD_JOBS=${2-} - -# Normalize any -jN argument to the form " -j${HBJ}" -MFLAGS=` - echo "$MFLAGS" \ - | sed ' - s/^-/ -/ - s/ -\([^ I][^ I]*\)j/ -\1 -j/ - s/ -j[0-9][0-9]*/ -j/ - s/ -j\([^ ]\)/ -j -\1/ - s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/ - ' ` - -case ${HOTSPOT_BUILD_JOBS} in \ - -'') case ${MFLAGS} in - *\ -j*) - >&2 echo "# Note: -jN is ineffective for setting parallelism in this makefile." - >&2 echo "# please set HOTSPOT_BUILD_JOBS=${default_build_jobs} in the command line or environment." - esac;; - -?*) case ${MFLAGS} in - *\ -j*) true;; - *) MFLAGS="-j${HOTSPOT_BUILD_JOBS} ${MFLAGS}";; - esac;; -esac - -echo "${MFLAGS}" diff --git a/hotspot/make/aix/makefiles/adlc.make b/hotspot/make/aix/makefiles/adlc.make deleted file mode 100644 index 63dc981410f..00000000000 --- a/hotspot/make/aix/makefiles/adlc.make +++ /dev/null @@ -1,225 +0,0 @@ -# -# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (adlc.make) is included from the adlc.make in the -# build directories. -# It knows how to compile, link, and run the adlc. - -include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make - -# ######################################################################### - -# OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make: -GENERATED = ../generated -OUTDIR = $(GENERATED)/adfiles - -ARCH = $(Platform_arch) -OS = $(Platform_os_family) - -SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad - -ifeq ("${Platform_arch_model}", "${Platform_arch}") - SOURCES.AD = \ - $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) -else - SOURCES.AD = \ - $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \ - $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) -endif - -EXEC = $(OUTDIR)/adlc - -# set VPATH so make knows where to look for source files -Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc -VPATH += $(Src_Dirs_V:%=%:) - -# set INCLUDES for C preprocessor -Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED) -INCLUDES += $(Src_Dirs_I:%=-I%) - -# set flags for adlc compilation -CXXFLAGS = $(SYSDEFS) $(INCLUDES) - -# Force assertions on. -CXXFLAGS += -DASSERT - -# CFLAGS_WARN holds compiler options to suppress/enable warnings. -# Suppress warnings (for now) -CFLAGS_WARN = -w -CFLAGS += $(CFLAGS_WARN) - -OBJECTNAMES = \ - adlparse.o \ - archDesc.o \ - arena.o \ - dfa.o \ - dict2.o \ - filebuff.o \ - forms.o \ - formsopt.o \ - formssel.o \ - main.o \ - adlc-opcodes.o \ - output_c.o \ - output_h.o \ - -OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%) - -GENERATEDNAMES = \ - ad_$(Platform_arch_model).cpp \ - ad_$(Platform_arch_model).hpp \ - ad_$(Platform_arch_model)_clone.cpp \ - ad_$(Platform_arch_model)_expand.cpp \ - ad_$(Platform_arch_model)_format.cpp \ - ad_$(Platform_arch_model)_gen.cpp \ - ad_$(Platform_arch_model)_misc.cpp \ - ad_$(Platform_arch_model)_peephole.cpp \ - ad_$(Platform_arch_model)_pipeline.cpp \ - adGlobals_$(Platform_arch_model).hpp \ - dfa_$(Platform_arch_model).cpp \ - -GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%) - -# ######################################################################### - -all: $(EXEC) - -$(EXEC) : $(OBJECTS) - @echo $(LOG_INFO) Making adlc - $(QUIETLY) $(HOST.LINK_NOPROF.CXX) -o $(EXEC) $(OBJECTS) - -# Random dependencies: -$(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp - -# The source files refer to ostream.h, which sparcworks calls iostream.h -$(OBJECTS): ostream.h - -ostream.h : - @echo >$@ '#include ' - -dump: - : OUTDIR=$(OUTDIR) - : OBJECTS=$(OBJECTS) - : products = $(GENERATEDFILES) - -all: $(GENERATEDFILES) - -$(GENERATEDFILES): refresh_adfiles - -# Get a unique temporary directory name, so multiple makes can run in parallel. -# Note that product files are updated via "mv", which is atomic. -TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$) - -# Debuggable by default -CFLAGS += -g - -# Pass -D flags into ADLC. -ADLCFLAGS += $(SYSDEFS) - -# Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO. -ADLCFLAGS += -q -T - -ADLCFLAGS += -g - -ifdef LP64 -ADLCFLAGS += -D_LP64 -else -ADLCFLAGS += -U_LP64 -endif - -# -# adlc_updater is a simple sh script, under sccs control. It is -# used to selectively update generated adlc files. This should -# provide a nice compilation speed improvement. -# -ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS) -ADLC_UPDATER = adlc_updater -$(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER) - $(QUIETLY) cp $< $@; chmod +x $@ - -# This action refreshes all generated adlc files simultaneously. -# The way it works is this: -# 1) create a scratch directory to work in. -# 2) if the current working directory does not have $(ADLC_UPDATER), copy it. -# 3) run the compiled adlc executable. This will create new adlc files in the scratch directory. -# 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files. -# 5) If we actually updated any files, echo a notice. -# -refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER) - @rm -rf $(TEMPDIR); mkdir $(TEMPDIR) - $(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \ - -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \ - || { rm -rf $(TEMPDIR); exit 1; } - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) [ -f $(TEMPDIR)/made-change ] \ - || echo $(LOG_INFO) "Rescanned $(SOURCE.AD) but encountered no changes." - $(QUIETLY) rm -rf $(TEMPDIR) - - -# ######################################################################### - -$(SOURCE.AD): $(SOURCES.AD) - $(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD) - -#PROCESS_AD_FILES = cat -# Pass through #line directives, in case user enables -g option above: -PROCESS_AD_FILES = awk '{ \ - if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \ - if (need_lineno && $$0 !~ /\/\//) \ - { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \ - print }' - -$(OUTDIR)/%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(HOST.COMPILE.CXX) -o $@ $< $(COMPILE_DONE) - -# Some object files are given a prefix, to disambiguate -# them from objects of the same name built for the VM. -$(OUTDIR)/adlc-%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(HOST.COMPILE.CXX) -o $@ $< $(COMPILE_DONE) - -# ######################################################################### - -clean: - rm $(OBJECTS) - -cleanall: - rm $(OBJECTS) $(EXEC) - -# ######################################################################### - -.PHONY: all dump refresh_adfiles clean cleanall diff --git a/hotspot/make/aix/makefiles/build_vm_def.sh b/hotspot/make/aix/makefiles/build_vm_def.sh deleted file mode 100644 index 8d8e8fd2955..00000000000 --- a/hotspot/make/aix/makefiles/build_vm_def.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -# If we're cross compiling use that path for nm -if [ "$CROSS_COMPILE_ARCH" != "" ]; then -NM=$ALT_COMPILER_PATH/nm -else -# On AIX we have to prevent that we pick up the 'nm' version from the GNU binutils -# which may be installed under /opt/freeware/bin. So better use an absolute path here! -NM=/usr/bin/nm -fi - -$NM -X64 -B -C $* \ - | awk '{ - if (($2="d" || $2="D") && ($3 ~ /^__vft/ || $3 ~ /^gHotSpotVM/)) print "\t" $3 ";" - if ($3 ~ /^UseSharedSpaces$/) print "\t" $3 ";" - if ($3 ~ /^SharedArchivePath__9Arguments$/) print "\t" $3 ";" - }' \ - | sort -u diff --git a/hotspot/make/aix/makefiles/buildtree.make b/hotspot/make/aix/makefiles/buildtree.make deleted file mode 100644 index 94b71eb760f..00000000000 --- a/hotspot/make/aix/makefiles/buildtree.make +++ /dev/null @@ -1,351 +0,0 @@ -# -# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2013 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Usage: -# -# $(MAKE) -f buildtree.make SRCARCH=srcarch BUILDARCH=buildarch LIBARCH=libarch -# GAMMADIR=dir OS_FAMILY=os VARIANT=variant -# -# The macros ARCH, GAMMADIR, OS_FAMILY and VARIANT must be defined in the -# environment or on the command-line: -# -# ARCH - sparc, i486, ... HotSpot cpu and os_cpu source directory -# BUILDARCH - build directory -# LIBARCH - the corresponding directory in JDK/JRE -# GAMMADIR - top of workspace -# OS_FAMILY - operating system -# VARIANT - core, compiler1, compiler2, or tiered -# VERSION_STRING - the JDK version string as specified by JEP-223 -# HOTSPOT_VERSION_STRING - the same as VERSION_STRING, unless overridden by a standalone build -# -# Builds the directory trees with makefiles plus some convenience files in -# each directory: -# -# Makefile - for "make foo" -# flags.make - with macro settings -# vm.make - to support making "$(MAKE) -v vm.make" in makefiles -# adlc.make - -# trace.make - generate tracing event and type definitions -# jvmti.make - generate JVMTI bindings from the spec (JSR-163) -# -# The makefiles are split this way so that "make foo" will run faster by not -# having to read the dependency files for the vm. - --include $(SPEC) -include $(GAMMADIR)/make/scm.make -include $(GAMMADIR)/make/defs.make -include $(GAMMADIR)/make/altsrc.make - - -# 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details. -QUIETLY$(MAKE_VERBOSE) = @ - -ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - PLATFORM_FILE = $(shell dirname $(shell dirname $(shell pwd)))/platform_zero -else - ifdef USE_SUNCC - PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).suncc - else - PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH) - endif -endif - -# Allow overriding of the arch part of the directory but default -# to BUILDARCH if nothing is specified -ifeq ($(VARIANTARCH),) - VARIANTARCH=$(BUILDARCH) -endif - -ifdef FORCE_TIERED -ifeq ($(VARIANT),tiered) -PLATFORM_DIR = $(OS_FAMILY)_$(VARIANTARCH)_compiler2 -else -PLATFORM_DIR = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT) -endif -else -PLATFORM_DIR = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT) -endif - -# -# We do two levels of exclusion in the shared directory. -# TOPLEVEL excludes are pruned, they are not recursively searched, -# but lower level directories can be named without fear of collision. -# ALWAYS excludes are excluded at any level in the directory tree. -# - -ALWAYS_EXCLUDE_DIRS = $(SCM_DIRS) - -ifeq ($(VARIANT),tiered) -TOPLEVEL_EXCLUDE_DIRS = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name agent -else -ifeq ($(VARIANT),compiler2) -TOPLEVEL_EXCLUDE_DIRS = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name c1 -o -name agent -else -# compiler1 and core use the same exclude list -TOPLEVEL_EXCLUDE_DIRS = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name opto -o -name libadt -o -name agent -endif -endif - -# Get things from the platform file. -COMPILER = $(shell sed -n 's/^compiler[ ]*=[ ]*//p' $(PLATFORM_FILE)) - -SIMPLE_DIRS = \ - $(PLATFORM_DIR)/generated/dependencies \ - $(PLATFORM_DIR)/generated/adfiles \ - $(PLATFORM_DIR)/generated/jvmtifiles \ - $(PLATFORM_DIR)/generated/tracefiles - -TARGETS = debug fastdebug optimized product -SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS)) - -# For dependencies and recursive makes. -BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make - -BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make - -BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \ - SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT) - -# Define variables to be set in flags.make. -# Default values are set in make/defs.make. - -# Set BUILD_USER from system-dependent hints: $LOGNAME, $(whoami) -ifndef HOTSPOT_BUILD_USER - HOTSPOT_BUILD_USER := $(shell echo $$LOGNAME) -endif -ifndef HOTSPOT_BUILD_USER - HOTSPOT_BUILD_USER := $(shell whoami) -endif -# Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro -# or make/hotspot_distro. -ifndef HOTSPOT_VM_DISTRO - ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true) - include $(GAMMADIR)/make/hotspot_distro - else - include $(GAMMADIR)/make/openjdk_distro - endif -endif - -# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK -ifndef OPENJDK - ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true) - OPENJDK=true - endif -endif - -BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING) - -BUILDTREE = \ - $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_TARGETS) $(BUILDTREE_VARS) - -BUILDTREE_COMMENT = echo "\# Generated by $(BUILDTREE_MAKE)" - -all: $(SUBMAKE_DIRS) - -# Run make in each subdirectory recursively. -$(SUBMAKE_DIRS): $(SIMPLE_DIRS) FORCE - $(QUIETLY) [ -d $@ ] || { mkdir -p $@; } - +$(QUIETLY) cd $@ && $(BUILDTREE) TARGET=$(@F) - $(QUIETLY) touch $@ - -$(SIMPLE_DIRS): - $(QUIETLY) mkdir -p $@ - -# Convenience macro which takes a source relative path, applies $(1) to the -# absolute path, and then replaces $(GAMMADIR) in the result with a -# literal "$(GAMMADIR)/" suitable for inclusion in a Makefile. -gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2))) - -# This bit is needed to enable local rebuilds. -# Unless the makefile itself sets LP64, any environmental -# setting of LP64 will interfere with the build. -LP64_SETTING/32 = LP64 = \#empty -LP64_SETTING/64 = LP64 = 1 - -DATA_MODE/ppc64 = 64 - -DATA_MODE = $(DATA_MODE/$(BUILDARCH)) - -flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo "Platform_file = $(PLATFORM_FILE)" | sed 's|$(GAMMADIR)|$$(GAMMADIR)|'; \ - sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \ - echo; \ - echo "GAMMADIR = $(GAMMADIR)"; \ - echo "HS_ALT_MAKE = $(HS_ALT_MAKE)"; \ - echo "OSNAME = $(OSNAME)"; \ - echo "SYSDEFS = \$$(Platform_sysdefs)"; \ - echo "SRCARCH = $(SRCARCH)"; \ - echo "BUILDARCH = $(BUILDARCH)"; \ - echo "LIBARCH = $(LIBARCH)"; \ - echo "TARGET = $(TARGET)"; \ - echo "HOTSPOT_VERSION_STRING = $(HOTSPOT_VERSION_STRING)"; \ - echo "VERSION_STRING = $(VERSION_STRING)"; \ - echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \ - echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \ - echo "OPENJDK = $(OPENJDK)"; \ - echo "$(LP64_SETTING/$(DATA_MODE))"; \ - echo; \ - echo "# Used for platform dispatching"; \ - echo "TARGET_DEFINES = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \ - echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \ - echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \ - echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \ - echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \ - echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \ - echo "CFLAGS += \$$(TARGET_DEFINES)"; \ - echo; \ - echo "Src_Dirs_V = \\"; \ - sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \ - echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/posix/vm)"; \ - echo; \ - echo "Src_Dirs_I = \\"; \ - echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \ - echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \ - echo "$(call gamma-path,altsrc,share/vm) \\"; \ - echo "$(call gamma-path,commonsrc,share/vm) \\"; \ - echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \ - echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \ - echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/posix/vm)"; \ - [ -n "$(CFLAGS_BROWSE)" ] && \ - echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \ - [ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \ - echo && echo "ENABLE_FULL_DEBUG_SYMBOLS = $(ENABLE_FULL_DEBUG_SYMBOLS)"; \ - [ -n "$(OBJCOPY)" ] && \ - echo && echo "OBJCOPY = $(OBJCOPY)"; \ - [ -n "$(STRIP_POLICY)" ] && \ - echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \ - [ -n "$(ZIP_DEBUGINFO_FILES)" ] && \ - echo && echo "ZIP_DEBUGINFO_FILES = $(ZIP_DEBUGINFO_FILES)"; \ - [ -n "$(ZIPEXE)" ] && \ - echo && echo "ZIPEXE = $(ZIPEXE)"; \ - [ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \ - echo && \ - echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \ - echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \ - [ -n "$(INCLUDE_TRACE)" ] && \ - echo && echo "INCLUDE_TRACE = $(INCLUDE_TRACE)"; \ - echo; \ - [ -n "$(SPEC)" ] && \ - echo "include $(SPEC)"; \ - echo "CP ?= cp"; \ - echo "MV ?= mv"; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \ - echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \ - ) > $@ - -flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \ - ) > $@ - -../shared_dirs.lst: $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm - @echo $(LOG_INFO) Creating directory list $@ - $(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \ - find $(HS_ALT_SRC)/share/vm/* -prune \ - -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \ - \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \ - fi; - $(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \ - -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \ - \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@ - -Makefile: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \ - ) > $@ - -vm.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo include flags_vm.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -adlc.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -jvmti.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -trace.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -FORCE: - -.PHONY: all FORCE - -.NOTPARALLEL: diff --git a/hotspot/make/aix/makefiles/compiler2.make b/hotspot/make/aix/makefiles/compiler2.make deleted file mode 100644 index 13986308edf..00000000000 --- a/hotspot/make/aix/makefiles/compiler2.make +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2013 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making server version of VM - -TYPE=COMPILER2 - -VM_SUBDIR = server - -CFLAGS += -DCOMPILER2 diff --git a/hotspot/make/aix/makefiles/core.make b/hotspot/make/aix/makefiles/core.make deleted file mode 100644 index 56d85c8fc16..00000000000 --- a/hotspot/make/aix/makefiles/core.make +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making core version of VM - -# Select which files to use (in top.make) -TYPE=CORE - -# There is no "core" directory in JDK. Install core build in server directory. -VM_SUBDIR = server - -# Note: macros.hpp defines CORE diff --git a/hotspot/make/aix/makefiles/debug.make b/hotspot/make/aix/makefiles/debug.make deleted file mode 100644 index 1a1c4ebbd7d..00000000000 --- a/hotspot/make/aix/makefiles/debug.make +++ /dev/null @@ -1,41 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2013 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making debug version of VM - -# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make -DEBUG_CFLAGS/DEFAULT= $(DEBUG_CFLAGS) -DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@)) -CFLAGS += $(DEBUG_CFLAGS/BYFILE) - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# Linker mapfile -MAPFILE = $(GAMMADIR)/make/aix/makefiles/mapfile-vers-debug - -VERSION = debug -SYSDEFS += -DASSERT -DDEBUG -PICFLAGS = DEFAULT diff --git a/hotspot/make/aix/makefiles/defs.make b/hotspot/make/aix/makefiles/defs.make deleted file mode 100644 index b9c54e36149..00000000000 --- a/hotspot/make/aix/makefiles/defs.make +++ /dev/null @@ -1,204 +0,0 @@ -# -# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2013 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# The common definitions for hotspot AIX builds. -# Include the top level defs.make under make directory instead of this one. -# This file is included into make/defs.make. - -SLASH_JAVA ?= /java - -define print_info - ifneq ($$(LOG_LEVEL), warn) - $$(shell echo >&2 "INFO: $1") - endif -endef - -# Need PLATFORM (os-arch combo names) for jdk and hotspot, plus libarch name -#ARCH:=$(shell uname -m) -PATH_SEP = : -ifeq ($(LP64), 1) - ARCH_DATA_MODEL ?= 64 -else - ARCH_DATA_MODEL ?= 32 -endif - -ifeq ($(ARCH_DATA_MODEL), 64) - ARCH = ppc64 -else - ARCH = ppc -endif - -# PPC -ifeq ($(ARCH), ppc) - #ARCH_DATA_MODEL = 32 - PLATFORM = aix-ppc - VM_PLATFORM = aix_ppc - HS_ARCH = ppc -endif - -# PPC64 -ifeq ($(ARCH), ppc64) - #ARCH_DATA_MODEL = 64 - MAKE_ARGS += LP64=1 - PLATFORM = aix-ppc64 - VM_PLATFORM = aix_ppc64 - HS_ARCH = ppc -endif - -# On 32 bit aix we build server and client, on 64 bit just server. -ifeq ($(JVM_VARIANTS),) - ifeq ($(ARCH_DATA_MODEL), 32) - JVM_VARIANTS:=client,server - JVM_VARIANT_CLIENT:=true - JVM_VARIANT_SERVER:=true - else - JVM_VARIANTS:=server - JVM_VARIANT_SERVER:=true - endif -endif - -# The Full Debug Symbols (FDS) default for BUILD_FLAVOR == product -# builds is enabled with debug info files ZIP'ed to save space. For -# BUILD_FLAVOR != product builds, FDS is always enabled, after all a -# debug build without debug info isn't very useful. -# The ZIP_DEBUGINFO_FILES option only has meaning when FDS is enabled. -# -# If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be -# disabled for a BUILD_FLAVOR == product build. -# -# Note: Use of a different variable name for the FDS override option -# versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS -# versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass -# in options via environment variables, use of distinct variables -# prevents strange behaviours. For example, in a BUILD_FLAVOR != -# product build, the FULL_DEBUG_SYMBOLS environment variable will be -# 0, but the ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If -# the same variable name is used, then different values can be picked -# up by different parts of the build. Just to be clear, we only need -# two variable names because the incoming option value can be -# overridden in some situations, e.g., a BUILD_FLAVOR != product -# build. - -# Due to the multiple sub-make processes that occur this logic gets -# executed multiple times. We reduce the noise by at least checking that -# BUILD_FLAVOR has been set. -ifneq ($(BUILD_FLAVOR),) - ifeq ($(BUILD_FLAVOR), product) - FULL_DEBUG_SYMBOLS ?= 1 - ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) - else - # debug variants always get Full Debug Symbols (if available) - ENABLE_FULL_DEBUG_SYMBOLS = 1 - endif - $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")) - # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later - - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - # Default OBJCOPY comes from GNU Binutils on Linux - ifeq ($(CROSS_COMPILE_ARCH),) - DEF_OBJCOPY=/usr/bin/objcopy - else - # Assume objcopy is part of the cross-compilation toolset - ifneq ($(ALT_COMPILER_PATH),) - DEF_OBJCOPY=$(ALT_COMPILER_PATH)/objcopy - endif - endif - OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY)) - ifneq ($(ALT_OBJCOPY),) - $(eval $(call print_info, "ALT_OBJCOPY=$(ALT_OBJCOPY)")) - OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY)) - endif - - ifeq ($(OBJCOPY),) - $(eval $(call print_info, "no objcopy cmd found so cannot create .debuginfo files. You may need to set ALT_OBJCOPY.")) - ENABLE_FULL_DEBUG_SYMBOLS=0 - $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")) - else - $(eval $(call print_info, "$(OBJCOPY) cmd found so will create .debuginfo files.")) - - # Library stripping policies for .debuginfo configs: - # all_strip - strips everything from the library - # min_strip - strips most stuff from the library; leaves minimum symbols - # no_strip - does not strip the library at all - # - # Oracle security policy requires "all_strip". A waiver was granted on - # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE. - # - # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled. - # - STRIP_POLICY ?= min_strip - - $(eval $(call print_info, "STRIP_POLICY=$(STRIP_POLICY)")) - - ZIP_DEBUGINFO_FILES ?= 1 - - $(eval $(call print_info, "ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")) - endif - endif # ENABLE_FULL_DEBUG_SYMBOLS=1 -endif # BUILD_FLAVOR - -# unused JDK_INCLUDE_SUBDIR=aix - -# Library suffix -LIBRARY_SUFFIX=so - -EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html - -# client and server subdirectories have symbolic links to ../libjsig.so -EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX) -#ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) -# ifeq ($(ZIP_DEBUGINFO_FILES),1) -# EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.diz -# else -# EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.debuginfo -# endif -#endif -EXPORT_SERVER_DIR = $(EXPORT_LIB_ARCH_DIR)/server -EXPORT_CLIENT_DIR = $(EXPORT_LIB_ARCH_DIR)/client -EXPORT_MINIMAL_DIR = $(EXPORT_LIB_ARCH_DIR)/minimal - -ifeq ($(findstring true, $(JVM_VARIANT_SERVER) $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK) $(JVM_VARIANT_CORE)), true) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX) -# ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) -# ifeq ($(ZIP_DEBUGINFO_FILES),1) -# EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.diz -# else -# EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo -# endif -# endif -endif - -ifeq ($(JVM_VARIANT_CLIENT),true) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX) -# ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) -# ifeq ($(ZIP_DEBUGINFO_FILES),1) -# EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.diz -# else -# EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo -# endif -# endif -endif diff --git a/hotspot/make/aix/makefiles/dtrace.make b/hotspot/make/aix/makefiles/dtrace.make deleted file mode 100644 index 749877d4aee..00000000000 --- a/hotspot/make/aix/makefiles/dtrace.make +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Linux does not build jvm_db -LIBJVM_DB = - diff --git a/hotspot/make/aix/makefiles/fastdebug.make b/hotspot/make/aix/makefiles/fastdebug.make deleted file mode 100644 index c0d50079d16..00000000000 --- a/hotspot/make/aix/makefiles/fastdebug.make +++ /dev/null @@ -1,72 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2013 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making debug version of VM - -# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make -# Pare down optimization to -O2 if xlCV10.1 is in use. -OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) $(QV10_OPT_CONSERVATIVE) -OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) - -# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files) - -ifeq ($(BUILDARCH), ia64) - # Bug in GCC, causes hang. -O1 will override the -O3 specified earlier - OPT_CFLAGS/callGenerator.o += -O1 - OPT_CFLAGS/ciTypeFlow.o += -O1 - OPT_CFLAGS/compile.o += -O1 - OPT_CFLAGS/concurrentMarkSweepGeneration.o += -O1 - OPT_CFLAGS/doCall.o += -O1 - OPT_CFLAGS/generateOopMap.o += -O1 - OPT_CFLAGS/generateOptoStub.o += -O1 - OPT_CFLAGS/graphKit.o += -O1 - OPT_CFLAGS/instanceKlass.o += -O1 - OPT_CFLAGS/interpreterRT_ia64.o += -O1 - OPT_CFLAGS/output.o += -O1 - OPT_CFLAGS/parse1.o += -O1 - OPT_CFLAGS/runtime.o += -O1 - OPT_CFLAGS/synchronizer.o += -O1 -endif - - -# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings -CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# Linker mapfile -MAPFILE = $(GAMMADIR)/make/aix/makefiles/mapfile-vers-debug - -# xlc 10.1 parameters for ipa linkage. -# - remove ipa linkage altogether. Does not seem to benefit performance, -# but increases code footprint. -# - this is a debug build in the end. Extra effort for ipa linkage is thus -# not justified. -LFLAGS_QIPA= - -VERSION = optimized -SYSDEFS += -DASSERT -PICFLAGS = DEFAULT diff --git a/hotspot/make/aix/makefiles/jsig.make b/hotspot/make/aix/makefiles/jsig.make deleted file mode 100644 index 86c4bea5ae1..00000000000 --- a/hotspot/make/aix/makefiles/jsig.make +++ /dev/null @@ -1,87 +0,0 @@ -# -# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2013 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Rules to build signal interposition library, used by vm.make - -# libjsig.so: signal interposition library -JSIG = jsig -LIBJSIG = lib$(JSIG).so - -LIBJSIG_DEBUGINFO = lib$(JSIG).debuginfo -LIBJSIG_DIZ = lib$(JSIG).diz - -JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm - -DEST_JSIG = $(JDK_LIBDIR)/$(LIBJSIG) -DEST_JSIG_DEBUGINFO = $(JDK_LIBDIR)/$(LIBJSIG_DEBUGINFO) -DEST_JSIG_DIZ = $(JDK_LIBDIR)/$(LIBJSIG_DIZ) - -LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig - -# On Linux we really dont want a mapfile, as this library is small -# and preloaded using LD_PRELOAD, making functions private will -# cause problems with interposing. See CR: 6466665 -# LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE)) - -LFLAGS_JSIG += -D_GNU_SOURCE -D_REENTRANT $(LDFLAGS_HASH_STYLE) - -LFLAGS_JSIG += $(BIN_UTILS) - -# DEBUG_BINARIES overrides everything, use full -g debug information -ifeq ($(DEBUG_BINARIES), true) - JSIG_DEBUG_CFLAGS = -g -endif - -$(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE) - @echo $(LOG_INFO) Making signal interposition lib... - $(QUIETLY) $(CXX) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \ - $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) -o $@ $< -ldl - -#ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) -# $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO) -# $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@ -# ifeq ($(STRIP_POLICY),all_strip) -# $(QUIETLY) $(STRIP) $@ -# else -# ifeq ($(STRIP_POLICY),min_strip) -# $(QUIETLY) $(STRIP) -g $@ -# # implied else here is no stripping at all -# endif -# endif -# ifeq ($(ZIP_DEBUGINFO_FILES),1) -# $(ZIPEXE) -q -y $(LIBJSIG_DIZ) $(LIBJSIG_DEBUGINFO) -# $(RM) $(LIBJSIG_DEBUGINFO) -# endif -#endif - -install_jsig: $(LIBJSIG) - @echo "Copying $(LIBJSIG) to $(DEST_JSIG)" - $(QUIETLY) test -f $(LIBJSIG_DEBUGINFO) && \ - $(CP) -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO) - $(QUIETLY) test -f $(LIBJSIG_DIZ) && \ - $(CP) -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ) - $(QUIETLY) $(CP) -f $(LIBJSIG) $(DEST_JSIG) && echo "Done" - -.PHONY: install_jsig diff --git a/hotspot/make/aix/makefiles/jvmti.make b/hotspot/make/aix/makefiles/jvmti.make deleted file mode 100644 index cff6a741da6..00000000000 --- a/hotspot/make/aix/makefiles/jvmti.make +++ /dev/null @@ -1,117 +0,0 @@ -# -# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2013 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (jvmti.make) is included from the jvmti.make in the -# build directories. -# -# It knows how to build and run the tools to generate jvmti. - -include $(GAMMADIR)/make/aix/makefiles/rules.make - -# ######################################################################### - -TOPDIR = $(shell echo `pwd`) -GENERATED = $(TOPDIR)/../generated -JvmtiOutDir = $(GENERATED)/jvmtifiles - -JvmtiSrcDir = $(GAMMADIR)/src/share/vm/prims -InterpreterSrcDir = $(GAMMADIR)/src/share/vm/interpreter - -# set VPATH so make knows where to look for source files -Src_Dirs_V += $(JvmtiSrcDir) -VPATH += $(Src_Dirs_V:%=%:) - -JvmtiGeneratedNames = \ - jvmtiEnv.hpp \ - jvmtiEnter.cpp \ - jvmtiEnterTrace.cpp \ - jvmtiEnvRecommended.cpp \ - bytecodeInterpreterWithChecks.cpp \ - jvmti.h \ - -JvmtiEnvFillSource = $(JvmtiSrcDir)/jvmtiEnvFill.java -JvmtiEnvFillClass = $(JvmtiOutDir)/jvmtiEnvFill.class - -JvmtiGenSource = $(JvmtiSrcDir)/jvmtiGen.java -JvmtiGenClass = $(JvmtiOutDir)/jvmtiGen.class - -JvmtiGeneratedFiles = $(JvmtiGeneratedNames:%=$(JvmtiOutDir)/%) - -XSLT = $(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen - -.PHONY: all jvmtidocs clean cleanall - -# ######################################################################### - -all: $(JvmtiGeneratedFiles) - -both = $(JvmtiGenClass) $(JvmtiSrcDir)/jvmti.xml $(JvmtiSrcDir)/jvmtiLib.xsl - -$(JvmtiGenClass): $(JvmtiGenSource) - $(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiGenSource) - -$(JvmtiEnvFillClass): $(JvmtiEnvFillSource) - $(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiEnvFillSource) - -$(JvmtiOutDir)/jvmtiEnter.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnter.cpp -PARAM interface jvmti - -$(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp: $(JvmtiGenClass) $(InterpreterSrcDir)/bytecodeInterpreter.cpp $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml -XSL $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl -OUT $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp - -$(JvmtiOutDir)/jvmtiEnterTrace.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnterTrace.cpp -PARAM interface jvmti -PARAM trace Trace - -$(JvmtiOutDir)/jvmtiEnvRecommended.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnv.xsl $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiEnvFillClass) - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnv.xsl -OUT $(JvmtiOutDir)/jvmtiEnvStub.cpp - $(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiEnvFill $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiOutDir)/jvmtiEnvStub.cpp $(JvmtiOutDir)/jvmtiEnvRecommended.cpp - -$(JvmtiOutDir)/jvmtiEnv.hpp: $(both) $(JvmtiSrcDir)/jvmtiHpp.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiHpp.xsl -OUT $(JvmtiOutDir)/jvmtiEnv.hpp - -$(JvmtiOutDir)/jvmti.h: $(both) $(JvmtiSrcDir)/jvmtiH.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiH.xsl -OUT $(JvmtiOutDir)/jvmti.h - -jvmtidocs: $(JvmtiOutDir)/jvmti.html - -$(JvmtiOutDir)/jvmti.html: $(both) $(JvmtiSrcDir)/jvmti.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmti.xsl -OUT $(JvmtiOutDir)/jvmti.html - -# ######################################################################### - -clean : - rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles) - -cleanall : - rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles) - -# ######################################################################### diff --git a/hotspot/make/aix/makefiles/mapfile-vers-debug b/hotspot/make/aix/makefiles/mapfile-vers-debug deleted file mode 100644 index fb75f3dfcea..00000000000 --- a/hotspot/make/aix/makefiles/mapfile-vers-debug +++ /dev/null @@ -1,56 +0,0 @@ -# -# Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define public interface. - -SUNWprivate_1.1 { - global: - JVM_handle_linux_signal; - - # debug JVM - JVM_AccessVMBooleanFlag; - JVM_AccessVMIntFlag; - JVM_VMBreakPoint; - - # miscellaneous functions - jio_fprintf; - jio_printf; - jio_snprintf; - jio_vfprintf; - jio_vsnprintf; - numa_warn; - numa_error; - - # Needed because there is no JVM interface for this. - sysThreadAvailableStackWithSlack; - - # This is for Forte Analyzer profiling support. - AsyncGetCallTrace; - - # INSERT VTABLE SYMBOLS HERE - - local: - *; -}; - diff --git a/hotspot/make/aix/makefiles/mapfile-vers-jsig b/hotspot/make/aix/makefiles/mapfile-vers-jsig deleted file mode 100644 index ddb46c050ec..00000000000 --- a/hotspot/make/aix/makefiles/mapfile-vers-jsig +++ /dev/null @@ -1,38 +0,0 @@ -# -# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define library interface. - -SUNWprivate_1.1 { - global: - JVM_begin_signal_setting; - JVM_end_signal_setting; - JVM_get_libjsig_version; - JVM_get_signal_action; - sigaction; - signal; - sigset; - local: - *; -}; diff --git a/hotspot/make/aix/makefiles/mapfile-vers-product b/hotspot/make/aix/makefiles/mapfile-vers-product deleted file mode 100644 index ec0f06d8f65..00000000000 --- a/hotspot/make/aix/makefiles/mapfile-vers-product +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define public interface. - -SUNWprivate_1.1 { - global: - JVM_handle_linux_signal; - - # miscellaneous functions - jio_fprintf; - jio_printf; - jio_snprintf; - jio_vfprintf; - jio_vsnprintf; - numa_warn; - numa_error; - - # Needed because there is no JVM interface for this. - sysThreadAvailableStackWithSlack; - - # This is for Forte Analyzer profiling support. - AsyncGetCallTrace; - - # INSERT VTABLE SYMBOLS HERE - - local: - *; -}; - diff --git a/hotspot/make/aix/makefiles/ppc64.make b/hotspot/make/aix/makefiles/ppc64.make deleted file mode 100644 index d7ad9510e11..00000000000 --- a/hotspot/make/aix/makefiles/ppc64.make +++ /dev/null @@ -1,93 +0,0 @@ -# -# Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2015 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Produce 64 bits object files. -CFLAGS += -q64 - -# Balanced tuning for recent versions of the POWER architecture (if supported by xlc). -QTUNE=$(if $(CXX_SUPPORTS_BALANCED_TUNING),balanced,pwr5) - -# Try to speed up the interpreter: use ppc64 instructions and inline -# glue code for external functions. -OPT_CFLAGS += -qarch=ppc64 -qtune=$(QTUNE) -qinlglue - -# We need variable length arrays -CFLAGS += -qlanglvl=c99vla -# Just to check for unwanted macro redefinitions -CFLAGS += -qlanglvl=noredefmac - -# Suppress those "implicit private" warnings xlc gives. -# - The omitted keyword "private" is assumed for base class "...". -CFLAGS += -qsuppress=1540-0198 - -# Suppress the following numerous warning: -# - 1540-1090 (I) The destructor of "..." might not be called. -# - 1500-010: (W) WARNING in ...: Infinite loop. Program may not stop. -# There are several infinite loops in the vm, suppress. -# - 1540-1639 (I) The behavior of long type bit fields has changed ... -# ... long type bit fields now default to long, not int. -CFLAGS += -qsuppress=1540-1090 -qsuppress=1500-010 -qsuppress=1540-1639 - -# Suppress -# - 540-1088 (W) The exception specification is being ignored. -# caused by throw() in declaration of new() in nmethod.hpp. -CFLAGS += -qsuppress=1540-1088 - -# Turn off floating-point optimizations that may alter program semantics -OPT_CFLAGS += -qstrict - -# Disable aggressive optimizations for functions in sharedRuntimeTrig.cpp -# and sharedRuntimeTrans.cpp on ppc64. -# -qstrict turns off the following optimizations: -# * Performing code motion and scheduling on computations such as loads -# and floating-point computations that may trigger an exception. -# * Relaxing conformance to IEEE rules. -# * Reassociating floating-point expressions. -# When using '-qstrict' there still remains one problem -# in javasoft.sqe.tests.api.java.lang.Math.sin5Tests when run in compile-all -# mode, so don't optimize sharedRuntimeTrig.cpp at all. -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT) -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT) - -# Xlc 10.1 parameters for aggressive optimization: -# - qhot=level=1: Most aggressive loop optimizations. -# - qignerrno: Assume errno is not modified by system calls. -# - qinline: Inline method calls. No suboptions for c++ compiles. -# - qxflag=ASMMIDCOALFIX: Activate fix for -O3 problem in interpreter loop. -# - qxflag=asmfastsync: Activate fix for performance problem with inline assembler with memory clobber. -QV10_OPT=$(if $(CXX_IS_V10),-qxflag=ASMMIDCOALFIX -qxflag=asmfastsync) -QV10_OPT_AGGRESSIVE=$(if $(CXX_IS_V10),-qhot=level=1 -qignerrno -qinline) -QV10_OPT_CONSERVATIVE=$(if $(CXX_IS_V10),-qhot=level=1 -qignerrno -qinline) - -# Disallow inlining for synchronizer.cpp, but perform O3 optimizations. -OPT_CFLAGS/synchronizer.o = $(OPT_CFLAGS) -qnoinline - -# Set all the xlC V10.1 options here. -OPT_CFLAGS += $(QV10_OPT) $(QV10_OPT_AGGRESSIVE) - -export OBJECT_MODE=64 - -# Also build launcher as 64 bit executable. -LAUNCHERFLAGS += -q64 diff --git a/hotspot/make/aix/makefiles/product.make b/hotspot/make/aix/makefiles/product.make deleted file mode 100644 index f36ef69b32e..00000000000 --- a/hotspot/make/aix/makefiles/product.make +++ /dev/null @@ -1,58 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2013 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making optimized version of Gamma VM -# (This is the "product", not the "release" version.) - -# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make -OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) -OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) - -# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files) - -# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings -CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# Linker mapfile -MAPFILE = $(GAMMADIR)/make/aix/makefiles/mapfile-vers-product - -# Remove ipa linkage altogether. Does not seem to benfit performance, but increases code footprint. -LFLAGS_QIPA= - -SYSDEFS += -DPRODUCT -VERSION = optimized - -# use -g to strip library as -x will discard its symbol table; -x is fine for -# executables. -# Note: these macros are not used in .debuginfo configs -STRIP_LIBJVM = $(STRIP) -g $@ || exit 1; -STRIP_AOUT = $(STRIP) -x $@ || exit 1; - -# If we can create .debuginfo files, then the VM is stripped in vm.make -# and this macro is not used. -# LINK_LIB.CXX/POST_HOOK += $(STRIP_$(LINK_INTO)) diff --git a/hotspot/make/aix/makefiles/rules.make b/hotspot/make/aix/makefiles/rules.make deleted file mode 100644 index effca45effa..00000000000 --- a/hotspot/make/aix/makefiles/rules.make +++ /dev/null @@ -1,208 +0,0 @@ -# -# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Common rules/macros for the vm, adlc. - -# Tell make that .cpp is important -.SUFFIXES: .cpp $(SUFFIXES) - -DEMANGLER = c++filt -DEMANGLE = $(DEMANGLER) < $@ > .$@ && $(MV) -f .$@ $@ - -# $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++). -CC_COMPILE = $(CC) $(CXXFLAGS) $(CFLAGS) -CXX_COMPILE = $(CXX) $(CXXFLAGS) $(CFLAGS) - -AS.S = $(AS) $(ASFLAGS) - -COMPILE.CC = $(CC_COMPILE) -c -GENASM.CC = $(CC_COMPILE) -S -LINK.CC = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS) -LINK_LIB.CC = $(CC) $(LFLAGS) $(SHARED_FLAG) -PREPROCESS.CC = $(CC_COMPILE) -E - -COMPILE.CXX = $(CXX_COMPILE) -c -GENASM.CXX = $(CXX_COMPILE) -S -LINK.CXX = $(CXX) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS) -LINK_NOPROF.CXX = $(CXX) $(LFLAGS) $(AOUT_FLAGS) -LINK_LIB.CXX = $(CXX) $(LFLAGS) $(SHARED_FLAG) -PREPROCESS.CXX = $(CXX_COMPILE) -E - -# cross compiling the jvm with c2 requires host compilers to build -# adlc tool - -HOST.CXX_COMPILE = $(HOSTCXX) $(CXXFLAGS) $(CFLAGS) -HOST.COMPILE.CXX = $(HOST.CXX_COMPILE) -c -HOST.LINK_NOPROF.CXX = $(HOSTCXX) $(LFLAGS) $(AOUT_FLAGS) - - -# Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k". -REMOVE_TARGET = rm -f $@ - -# Note use of ALT_BOOTDIR to explicitly specify location of java and -# javac; this is the same environment variable used in the J2SE build -# process for overriding the default spec, which is BOOTDIR. -# Note also that we fall back to using JAVA_HOME if neither of these is -# specified. - -ifdef ALT_BOOTDIR - -RUN.JAVA = $(ALT_BOOTDIR)/bin/java -RUN.JAVAP = $(ALT_BOOTDIR)/bin/javap -RUN.JAVAH = $(ALT_BOOTDIR)/bin/javah -RUN.JAR = $(ALT_BOOTDIR)/bin/jar -COMPILE.JAVAC = $(ALT_BOOTDIR)/bin/javac -COMPILE.RMIC = $(ALT_BOOTDIR)/bin/rmic -BOOT_JAVA_HOME = $(ALT_BOOTDIR) - -else - -ifdef BOOTDIR - -RUN.JAVA = $(BOOTDIR)/bin/java -RUN.JAVAP = $(BOOTDIR)/bin/javap -RUN.JAVAH = $(BOOTDIR)/bin/javah -RUN.JAR = $(BOOTDIR)/bin/jar -COMPILE.JAVAC = $(BOOTDIR)/bin/javac -COMPILE.RMIC = $(BOOTDIR)/bin/rmic -BOOT_JAVA_HOME = $(BOOTDIR) - -else - -ifdef JAVA_HOME - -RUN.JAVA = $(JAVA_HOME)/bin/java -RUN.JAVAP = $(JAVA_HOME)/bin/javap -RUN.JAVAH = $(JAVA_HOME)/bin/javah -RUN.JAR = $(JAVA_HOME)/bin/jar -COMPILE.JAVAC = $(JAVA_HOME)/bin/javac -COMPILE.RMIC = $(JAVA_HOME)/bin/rmic -BOOT_JAVA_HOME = $(JAVA_HOME) - -else - -# take from the PATH, if ALT_BOOTDIR, BOOTDIR and JAVA_HOME are not defined - -RUN.JAVA = java -RUN.JAVAP = javap -RUN.JAVAH = javah -RUN.JAR = jar -COMPILE.JAVAC = javac -COMPILE.RMIC = rmic - -endif -endif -endif - -COMPILE.JAVAC += $(BOOTSTRAP_JAVAC_FLAGS) - -SUM = /usr/bin/sum - -# 'gmake MAKE_VERBOSE=y' gives all the gory details. -QUIETLY$(MAKE_VERBOSE) = @ -RUN.JAR$(MAKE_VERBOSE) += >/dev/null - -# Settings for javac -JAVAC_FLAGS = -g -encoding ascii - -# Prefer BOOT_JDK_SOURCETARGET if it's set (typically by the top build system) -# Fall back to the values here if it's not set (hotspot only builds) -ifeq ($(BOOT_JDK_SOURCETARGET),) -BOOTSTRAP_SOURCETARGET := -source 8 -target 8 -else -BOOTSTRAP_SOURCETARGET := $(BOOT_JDK_SOURCETARGET) -endif - -BOOTSTRAP_JAVAC_FLAGS = $(JAVAC_FLAGS) $(BOOTSTRAP_SOURCETARGET) - -# With parallel makes, print a message at the end of compilation. -ifeq ($(findstring j,$(MFLAGS)),j) -COMPILE_DONE = && { echo Done with $<; } -endif - -# Include $(NONPIC_OBJ_FILES) definition -ifndef LP64 -include $(GAMMADIR)/make/pic.make -endif - -include $(GAMMADIR)/make/altsrc.make - -# The non-PIC object files are only generated for 32 bit platforms. -ifdef LP64 -%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE) -else -%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \ - $(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \ - $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)) -endif - -%.o: %.s - @echo $(LOG_INFO) Assembling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(AS.S) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE) - -%.s: %.cpp - @echo $(LOG_INFO) Generating assembly for $< - $(QUIETLY) $(GENASM.CXX) -o $@ $< - $(QUIETLY) $(DEMANGLE) $(COMPILE_DONE) - -# Intermediate files (for debugging macros) -%.i: %.cpp - @echo $(LOG_INFO) Preprocessing $< to $@ - $(QUIETLY) $(PREPROCESS.CXX) $< > $@ $(COMPILE_DONE) - -# Override gnumake built-in rules which do sccs get operations badly. -# (They put the checked out code in the current directory, not in the -# directory of the original file.) Since this is a symptom of a teamware -# failure, and since not all problems can be detected by gnumake due -# to incomplete dependency checking... just complain and stop. -%:: s.% - @echo "=========================================================" - @echo File $@ - @echo is out of date with respect to its SCCS file. - @echo This file may be from an unresolved Teamware conflict. - @echo This is also a symptom of a Teamware bringover/putback failure - @echo in which SCCS files are updated but not checked out. - @echo Check for other out of date files in your workspace. - @echo "=========================================================" - @exit 666 - -%:: SCCS/s.% - @echo "=========================================================" - @echo File $@ - @echo is out of date with respect to its SCCS file. - @echo This file may be from an unresolved Teamware conflict. - @echo This is also a symptom of a Teamware bringover/putback failure - @echo in which SCCS files are updated but not checked out. - @echo Check for other out of date files in your workspace. - @echo "=========================================================" - @exit 666 - -.PHONY: default diff --git a/hotspot/make/aix/makefiles/tiered.make b/hotspot/make/aix/makefiles/tiered.make deleted file mode 100644 index f04496bdb60..00000000000 --- a/hotspot/make/aix/makefiles/tiered.make +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2015 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making tiered version of VM - -TYPE=TIERED - -VM_SUBDIR = server - -CFLAGS += -DCOMPILER2 -DCOMPILER1 diff --git a/hotspot/make/aix/makefiles/top.make b/hotspot/make/aix/makefiles/top.make deleted file mode 100644 index fa9107c039d..00000000000 --- a/hotspot/make/aix/makefiles/top.make +++ /dev/null @@ -1,147 +0,0 @@ -# -# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# top.make is included in the Makefile in the build directories. -# It DOES NOT include the vm dependency info in order to be faster. -# Its main job is to implement the incremental form of make lists. -# It also: -# -builds and runs adlc via adlc.make -# -generates JVMTI source and docs via jvmti.make (JSR-163) - -# It assumes the following flags are set: -# CFLAGS Platform_file, Src_Dirs_I, Src_Dirs_V, SYSDEFS, AOUT, Obj_Files - -# -- D. Ungar (5/97) from a file by Bill Bush - -# Don't override the built-in $(MAKE). -# Instead, use "gmake" (or "gnumake") from the command line. --Rose -#MAKE = gmake - -include $(GAMMADIR)/make/altsrc.make - -TOPDIR = $(shell echo `pwd`) -GENERATED = $(TOPDIR)/../generated -VM = $(GAMMADIR)/src/share/vm -Plat_File = $(Platform_file) -CDG = cd $(GENERATED); - -ifneq ($(USE_PRECOMPILED_HEADER),0) -UpdatePCH = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS) -else -UpdatePCH = \# precompiled header is not used -endif - -Cached_plat = $(GENERATED)/platform.current - -AD_Dir = $(GENERATED)/adfiles -ADLC = $(AD_Dir)/adlc -AD_Spec = $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad) -AD_Src = $(call altsrc-replace,$(HS_COMMON_SRC)/share/vm/adlc) -AD_Names = ad_$(Platform_arch_model).hpp ad_$(Platform_arch_model).cpp -AD_Files = $(AD_Names:%=$(AD_Dir)/%) - -# AD_Files_If_Required/COMPILER1 = ad_stuff -AD_Files_If_Required/COMPILER2 = ad_stuff -AD_Files_If_Required/TIERED = ad_stuff -AD_Files_If_Required = $(AD_Files_If_Required/$(TYPE)) - -# Wierd argument adjustment for "gnumake -j..." -adjust-mflags = $(GENERATED)/adjust-mflags -# If SPEC is set, it's from configure and it's already controlling concurrency -# for us. Skip setting -j with HOTSPOT_BUILD_JOBS. -ifeq ($(SPEC), ) - MFLAGS-adjusted = -r `$(adjust-mflags) "$(MFLAGS)" "$(HOTSPOT_BUILD_JOBS)"` -else - MFLAGS-adjusted = -r $(MFLAGS) -endif - - -# default target: update lists, make vm -# done in stages to force sequential order with parallel make -# - -default: vm_build_preliminaries the_vm - @echo All done. - -# This is an explicit dependency for the sake of parallel makes. -vm_build_preliminaries: checks $(Cached_plat) $(AD_Files_If_Required) trace_stuff jvmti_stuff - @# We need a null action here, so implicit rules don't get consulted. - -$(Cached_plat): $(Plat_File) - $(CDG) $(CP) $(Plat_File) $(Cached_plat) - -# make AD files as necessary -ad_stuff: $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f adlc.make $(MFLAGS-adjusted) - -# generate JVMTI files from the spec -jvmti_stuff: $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f jvmti.make $(MFLAGS-adjusted) - -# generate trace files -trace_stuff: jvmti_stuff $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f trace.make $(MFLAGS-adjusted) - -# and the VM: must use other makefile with dependencies included - -# We have to go to great lengths to get control over the -jN argument -# to the recursive invocation of vm.make. The problem is that gnumake -# resets -jN to -j1 for recursive runs. (How helpful.) -# Note that the user must specify the desired parallelism level via a -# command-line or environment variable name HOTSPOT_BUILD_JOBS. -$(adjust-mflags): $(GAMMADIR)/make/$(Platform_os_family)/makefiles/adjust-mflags.sh - @+rm -f $@ $@+ - @+cat $< > $@+ - @+chmod +x $@+ - @+mv $@+ $@ - -the_vm: vm_build_preliminaries $(adjust-mflags) - +@$(UpdatePCH) - @$(MAKE) -f vm.make $(MFLAGS-adjusted) - -install gamma: the_vm - @$(MAKE) -f vm.make $@ - -# next rules support "make foo.[ois]" - -%.o %.i %.s: - +$(UpdatePCH) - $(MAKE) -f vm.make $(MFLAGS) $@ - #$(MAKE) -f vm.make $@ - -# this should force everything to be rebuilt -clean: - rm -f $(GENERATED)/*.class - $(MAKE) -f vm.make $(MFLAGS) clean - -# just in case it doesn't, this should do it -realclean: - $(MAKE) -f vm.make $(MFLAGS) clean - rm -fr $(GENERATED) - -.PHONY: default vm_build_preliminaries -.PHONY: lists ad_stuff jvmti_stuff the_vm clean realclean -.PHONY: checks check_os_version install - -.NOTPARALLEL: diff --git a/hotspot/make/aix/makefiles/trace.make b/hotspot/make/aix/makefiles/trace.make deleted file mode 100644 index f17e75e1f4f..00000000000 --- a/hotspot/make/aix/makefiles/trace.make +++ /dev/null @@ -1,119 +0,0 @@ -# -# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (trace.make) is included from the trace.make in the -# build directories. -# -# It knows how to build and run the tools to generate trace files. - -include $(GAMMADIR)/make/aix/makefiles/rules.make -include $(GAMMADIR)/make/altsrc.make - -# ######################################################################### - -HAS_ALT_SRC := false -ifndef OPENJDK - ifneq ($(wildcard $(HS_ALT_SRC)/share/vm/trace), ) - HAS_ALT_SRC := true - endif -endif - -TOPDIR = $(shell echo `pwd`) -GENERATED = $(TOPDIR)/../generated -JvmtiOutDir = $(GENERATED)/jvmtifiles -TraceOutDir = $(GENERATED)/tracefiles - -TraceAltSrcDir = $(HS_ALT_SRC)/share/vm/trace -TraceSrcDir = $(HS_COMMON_SRC)/share/vm/trace - -# set VPATH so make knows where to look for source files -Src_Dirs_V += $(TraceSrcDir) $(TraceAltSrcDir) -VPATH += $(Src_Dirs_V:%=%:) - -TraceGeneratedNames = \ - traceEventClasses.hpp \ - traceEventIds.hpp \ - traceTypes.hpp - -ifeq ($(HAS_ALT_SRC), true) -TraceGeneratedNames += \ - traceRequestables.hpp \ - traceEventControl.hpp -endif - -TraceGeneratedFiles = $(TraceGeneratedNames:%=$(TraceOutDir)/%) - -XSLT = $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen - -TraceXml = $(TraceSrcDir)/trace.xml -ifeq ($(HAS_ALT_SRC), true) - TraceXml = $(TraceAltSrcDir)/trace.xml -endif - -XML_DEPS = $(TraceXml) $(TraceSrcDir)/tracetypes.xml \ - $(TraceSrcDir)/trace.dtd $(TraceSrcDir)/xinclude.mod \ - $(TraceSrcDir)/tracerelationdecls.xml $(TraceSrcDir)/traceevents.xml -ifeq ($(HAS_ALT_SRC), true) - XML_DEPS += $(TraceAltSrcDir)/traceeventscustom.xml \ - $(TraceAltSrcDir)/traceeventtypes.xml -endif - -.PHONY: all clean cleanall - -# ######################################################################### - -all: $(TraceGeneratedFiles) - -GENERATE_CODE= \ - $(QUIETLY) echo $(LOG_INFO) Generating $@; \ - $(XSLT) -IN $(word 1,$^) -XSL $(word 2,$^) -OUT $@ - -$(TraceOutDir)/traceEventIds.hpp: $(TraceXml) $(TraceSrcDir)/traceEventIds.xsl $(XML_DEPS) - $(GENERATE_CODE) - -$(TraceOutDir)/traceTypes.hpp: $(TraceXml) $(TraceSrcDir)/traceTypes.xsl $(XML_DEPS) - $(GENERATE_CODE) - -ifeq ($(HAS_ALT_SRC), false) - -$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceSrcDir)/traceEventClasses.xsl $(XML_DEPS) - $(GENERATE_CODE) - -else - -$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventClasses.xsl $(XML_DEPS) - $(GENERATE_CODE) - -$(TraceOutDir)/traceRequestables.hpp: $(TraceXml) $(TraceAltSrcDir)/traceRequestables.xsl $(XML_DEPS) - $(GENERATE_CODE) - -$(TraceOutDir)/traceEventControl.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventControl.xsl $(XML_DEPS) - $(GENERATE_CODE) - -endif - -# ######################################################################### - -clean cleanall: - rm $(TraceGeneratedFiles) diff --git a/hotspot/make/aix/makefiles/vm.make b/hotspot/make/aix/makefiles/vm.make deleted file mode 100644 index 808bb124892..00000000000 --- a/hotspot/make/aix/makefiles/vm.make +++ /dev/null @@ -1,370 +0,0 @@ -# -# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2013 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Rules to build JVM and related libraries, included from vm.make in the build -# directory. - -# Common build rules. -MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles -include $(MAKEFILES_DIR)/rules.make -include $(GAMMADIR)/make/altsrc.make - -default: build - -#---------------------------------------------------------------------- -# Defs - -GENERATED = ../generated -DEP_DIR = $(GENERATED)/dependencies - -# reads the generated files defining the set of .o's and the .o .h dependencies --include $(DEP_DIR)/*.d - -# read machine-specific adjustments (%%% should do this via buildtree.make?) -ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - include $(MAKEFILES_DIR)/zeroshark.make -else - include $(MAKEFILES_DIR)/$(BUILDARCH).make -endif - -# set VPATH so make knows where to look for source files -# Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm -# The adfiles directory contains ad_.[ch]pp. -# The jvmtifiles directory contains jvmti*.[ch]pp -Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles $(GENERATED)/tracefiles -VPATH += $(Src_Dirs_V:%=%:) - -# set INCLUDES for C preprocessor. -Src_Dirs_I += $(GENERATED) -# The order is important for the precompiled headers to work. -INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%) - -# SYMFLAG is used by jsig.make -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - # always build with debug info when we can create .debuginfo files - SYMFLAG = -g -else - ifeq (${VERSION}, debug) - SYMFLAG = -g - else - SYMFLAG = - endif -endif - -# The following variables are defined in the generated flags.make file. -JDK_VER_DEFS = -DVERSION_MAJOR=$(VERSION_MAJOR) \ - -DVERSION_MINOR=$(VERSION_MINOR) \ - -DVERSION_SECURITY=$(VERSION_SECURITY) \ - -DVERSION_PATCH=$(VERSION_PATCH) \ - -DVERSION_BUILD=$(VERSION_BUILD) -VM_VER_DEFS = -DHOTSPOT_VERSION_STRING="\"$(HOTSPOT_VERSION_STRING)\"" \ - -DVERSION_STRING="\"$(VERSION_STRING)\"" \ - -DDEBUG_LEVEL="\"$(DEBUG_LEVEL)\"" \ - $(JDK_VER_DEFS) -HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\"" -VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\"" - -CXXFLAGS = \ - ${SYSDEFS} \ - ${INCLUDES} \ - ${BUILD_USER} \ - ${HS_LIB_ARCH} \ - ${VM_DISTRO} - -# This is VERY important! The version define must only be supplied to vm_version.o -# If not, ccache will not re-use the cache at all, since the version string might contain -# a time and date. -CXXFLAGS/vm_version.o += ${VM_VER_DEFS} - -CXXFLAGS/BYFILE = $(CXXFLAGS/$@) - -# File specific flags -CXXFLAGS += $(CXXFLAGS/BYFILE) - - -# CFLAGS_WARN holds compiler options to suppress/enable warnings. -CFLAGS += $(CFLAGS_WARN/BYFILE) - -# Do not use C++ exception handling -CFLAGS += $(CFLAGS/NOEX) - -# Extra flags from gnumake's invocation or environment -CFLAGS += $(EXTRA_CFLAGS) -LFLAGS += $(EXTRA_CFLAGS) - -# Don't set excutable bit on stack segment -# the same could be done by separate execstack command -#LFLAGS += -Xlinker -z -Xlinker noexecstack - -LIBS += -lm -ldl -lpthread - -# By default, link the *.o into the library, not the executable. -LINK_INTO$(LINK_INTO) = LIBJVM - -JDK_LIBDIR = $(JAVA_HOME)/lib/$(LIBARCH) - -#---------------------------------------------------------------------- -# jvm_db & dtrace -include $(MAKEFILES_DIR)/dtrace.make - -#---------------------------------------------------------------------- -# JVM - -JVM = jvm -LIBJVM = lib$(JVM).so - -LIBJVM_DEBUGINFO = lib$(JVM).debuginfo -LIBJVM_DIZ = lib$(JVM).diz - -SPECIAL_PATHS:=adlc c1 gc opto shark libadt - -SOURCE_PATHS=\ - $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \ - \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \)) -SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm -SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm -SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(SRCARCH)/vm -SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_family)_$(SRCARCH)/vm - -CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path)) -CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles - -ifneq ($(INCLUDE_TRACE), false) -CORE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \ - find $(HS_ALT_SRC)/share/vm/jfr -type d; \ - fi) -endif - -COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1) -COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1 - -COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto) -COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt) -COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto -COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt -COMPILER2_PATHS += $(GENERATED)/adfiles - -SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark - -# Include dirs per type. -Src_Dirs/CORE := $(CORE_PATHS) -Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS) -Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS) -Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS) -Src_Dirs/ZERO := $(CORE_PATHS) -Src_Dirs/SHARK := $(CORE_PATHS) $(SHARK_PATHS) -Src_Dirs := $(Src_Dirs/$(TYPE)) - -COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\* -COMPILER1_SPECIFIC_FILES := c1_\* -SHARK_SPECIFIC_FILES := shark -ZERO_SPECIFIC_FILES := zero - -# Always exclude these. -Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp - -# Exclude per type. -Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) -Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) -Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) - -Src_Files_EXCLUDE += $(Src_Files_EXCLUDE/$(TYPE)) - -# Disable ELF decoder on AIX (AIX uses XCOFF). -Src_Files_EXCLUDE += decoder_elf.cpp elfFile.cpp elfStringTable.cpp elfSymbolTable.cpp elfFuncDescTable.cpp - -# Special handling of arch model. -ifeq ($(Platform_arch_model), x86_32) -Src_Files_EXCLUDE += \*x86_64\* -endif -ifeq ($(Platform_arch_model), x86_64) -Src_Files_EXCLUDE += \*x86_32\* -endif - -# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE. -define findsrc - $(notdir $(shell find $(1)/. ! -name . -prune \ - -a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \ - -a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \))) -endef - -Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e))) - -Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files)))) - -JVM_OBJ_FILES = $(Obj_Files) - -vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES)) - -MAPFILE_SHARE := $(GAMMADIR)/make/share/makefiles/mapfile-vers - -mapfile : $(MAPFILE) $(MAPFILE_SHARE) vm.def - rm -f $@ - awk '{ if ($$0 ~ "INSERT VTABLE SYMBOLS HERE") \ - { system ("cat ${MAPFILE_SHARE} vm.def"); } \ - else \ - { print $$0 } \ - }' > $@ < $(MAPFILE) - -mapfile_reorder : mapfile $(REORDERFILE) - rm -f $@ - cat $^ > $@ - -vm.def: $(Res_Files) $(Obj_Files) - sh $(GAMMADIR)/make/aix/makefiles/build_vm_def.sh *.o > $@ - -ifeq ($(JVM_VARIANT_ZEROSHARK), true) - STATIC_CXX = false -else - ifeq ($(ZERO_LIBARCH), ppc64) - STATIC_CXX = false - else - STATIC_CXX = true - endif -endif - -ifeq ($(LINK_INTO),AOUT) - LIBJVM.o = - LIBJVM_MAPFILE = - LIBS_VM = $(LIBS) -else - LIBJVM.o = $(JVM_OBJ_FILES) - LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder - LFLAGS_VM$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE)) -# xlC_r ignores the -o= syntax -# LFLAGS_VM += $(SONAMEFLAG:SONAME=$(LIBJVM)) - - # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to - # get around library dependency and compatibility issues. Must use gcc not - # g++ to link. - LIBS_VM += $(STATIC_STDCXX) $(LIBS) -endif - -LINK_VM = $(LINK_LIB.CXX) - -# create loadmap for libjvm.so by default. Helps in diagnosing some problems. -LFLAGS_VM += -bloadmap:libjvm.loadmap - -# rule for building precompiled header -$(PRECOMPILED_HEADER): - $(QUIETLY) echo $(LOG_INFO) Generating precompiled header $@ - $(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR) - $(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE) - -# making the library: - -ifneq ($(JVM_BASE_ADDR),) -# By default shared library is linked at base address == 0. Modify the -# linker script if JVM prefers a different base location. It can also be -# implemented with 'prelink -r'. But 'prelink' is not (yet) available on -# our build platform (AS-2.1). -LD_SCRIPT = libjvm.so.lds -$(LD_SCRIPT): $(LIBJVM_MAPFILE) - $(QUIETLY) { \ - rm -rf $@; \ - $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1 | \ - sed -e '/^======/,/^======/!d' \ - -e '/^======/d' \ - -e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/' \ - > $@; \ - } -LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT) -endif - -# With more recent Redhat releases (or the cutting edge version Fedora), if -# SELinux is configured to be enabled, the runtime linker will fail to apply -# the text relocation to libjvm.so considering that it is built as a non-PIC -# DSO. To workaround that, we run chcon to libjvm.so after it is built. See -# details in bug 6538311. -$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT) - $(QUIETLY) { \ - echo $(LOG_INFO) Linking vm...; \ - $(LINK_LIB.CXX/PRE_HOOK) \ - $(LINK_VM) $(LD_SCRIPT_FLAG) \ - $(LFLAGS_VM) -o $@ $(sort $(LIBJVM.o)) $(LIBS_VM); \ - $(LINK_LIB.CXX/POST_HOOK) \ - rm -f $@.1; ln -s $@ $@.1; \ - } -# No security contexts on AIX -# if [ \"$(CROSS_COMPILE_ARCH)\" = \"\" ] ; then \ -# if [ -x /usr/sbin/selinuxenabled ] ; then \ -# /usr/sbin/selinuxenabled; \ -# if [ $$? = 0 ] ; then \ -# /usr/bin/chcon -t textrel_shlib_t $@; \ -# if [ $$? != 0 ]; then \ -# echo "ERROR: Cannot chcon $@"; \ -# fi \ -# fi \ -# fi \ -# fi \ -# } - -#ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) -# $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO) -# $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@ -# ifeq ($(STRIP_POLICY),all_strip) -# $(QUIETLY) $(STRIP) $@ -# else -# ifeq ($(STRIP_POLICY),min_strip) -# $(QUIETLY) $(STRIP) -g $@ -# # implied else here is no stripping at all -# endif -# endif -# ifeq ($(ZIP_DEBUGINFO_FILES),1) -# $(ZIPEXE) -q -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO) -# $(RM) $(LIBJVM_DEBUGINFO) -# endif -#endif - -DEST_SUBDIR = $(JDK_LIBDIR)/$(VM_SUBDIR) -DEST_JVM = $(DEST_SUBDIR)/$(LIBJVM) -DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO) -DEST_JVM_DIZ = $(DEST_SUBDIR)/$(LIBJVM_DIZ) - -install_jvm: $(LIBJVM) - @echo "Copying $(LIBJVM) to $(DEST_JVM)" - $(QUIETLY) test -f $(LIBJVM_DEBUGINFO) && \ - $(CP) -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO) - $(QUIETLY) test -f $(LIBJVM_DIZ) && \ - $(CP) -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ) - $(QUIETLY) $(CP) -f $(LIBJVM) $(DEST_JVM) && echo "Done" - -#---------------------------------------------------------------------- -# Other files - -# Signal interposition library -include $(MAKEFILES_DIR)/jsig.make - -#---------------------------------------------------------------------- - -build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) - -install: install_jvm install_jsig - -.PHONY: default build install install_jvm diff --git a/hotspot/make/aix/makefiles/xlc.make b/hotspot/make/aix/makefiles/xlc.make deleted file mode 100644 index c44d306359e..00000000000 --- a/hotspot/make/aix/makefiles/xlc.make +++ /dev/null @@ -1,172 +0,0 @@ -# -# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2015 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -#------------------------------------------------------------------------ -# CC, CXX & AS - -# Set compiler explicitly -CXX = $(COMPILER_PATH)xlC_r -CC = $(COMPILER_PATH)xlc_r -HOSTCXX = $(CXX) -HOSTCC = $(CC) - -AS = $(CC) -c - -# get xlc version which comes as VV.RR.MMMM.LLLL where 'VV' is the version, -# 'RR' is the release, 'MMMM' is the modification and 'LLLL' is the level. -# We only use 'VV.RR.LLLL' to avoid integer overflows in bash when comparing -# the version numbers (some shells only support 32-bit integer compares!). -CXX_VERSION := $(shell $(CXX) -qversion 2>&1 | \ - sed -n 's/.*Version: \([0-9]\{2\}\).\([0-9]\{2\}\).[0-9]\{4\}.\([0-9]\{4\}\)/\1\2\3/p') - -# xlc 08.00.0000.0023 and higher supports -qtune=balanced -CXX_SUPPORTS_BALANCED_TUNING := $(shell if [ $(CXX_VERSION) -ge 08000023 ] ; then echo "true" ; fi) -# xlc 10.01 is used with aggressive optimizations to boost performance -CXX_IS_V10 := $(shell if [ $(CXX_VERSION) -ge 10010000 ] ; then echo "true" ; fi) - -# check for precompiled headers support - -# Switch off the precompiled header support. Neither xlC 8.0 nor xlC 10.0 -# support precompiled headers. Both "understand" the command line switches "-qusepcomp" and -# "-qgenpcomp" but when we specify them the following message is printed: -# "1506-755 (W) The -qusepcomp option is not supported in this release." -USE_PRECOMPILED_HEADER = 0 -ifneq ($(USE_PRECOMPILED_HEADER),0) -PRECOMPILED_HEADER_DIR=. -PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp -PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch -endif - - -#------------------------------------------------------------------------ -# Compiler flags - -# position-independent code -PICFLAG = -qpic=large - -VM_PICFLAG/LIBJVM = $(PICFLAG) -VM_PICFLAG/AOUT = -VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO)) - -CFLAGS += $(VM_PICFLAG) -CFLAGS += -qnortti -CFLAGS += -qnoeh - -# for compiler-level tls -CFLAGS += -qtls=default - -CFLAGS += -D_REENTRANT -# no xlc counterpart for -fcheck-new -# CFLAGS += -fcheck-new - -# We need to define this on the command line if we want to use the the -# predefined format specifiers from "inttypes.h". Otherwise system headrs -# can indirectly include inttypes.h before we define __STDC_FORMAT_MACROS -# in globalDefinitions.hpp -CFLAGS += -D__STDC_FORMAT_MACROS - -ARCHFLAG = -q64 - -CFLAGS += $(ARCHFLAG) -AOUT_FLAGS += $(ARCHFLAG) -LFLAGS += $(ARCHFLAG) -ASFLAGS += $(ARCHFLAG) - -# Use C++ Interpreter -ifdef CC_INTERP - CFLAGS += -DCC_INTERP -endif - -# Keep temporary files (.ii, .s) -# no counterpart on xlc for -save-temps, -pipe - -# Compiler warnings are treated as errors -# Do not treat warnings as errors -# WARNINGS_ARE_ERRORS = -Werror -# Except for a few acceptable ones -# ACCEPTABLE_WARNINGS = -Wpointer-arith -Wconversion -Wsign-compare -# CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(ACCEPTABLE_WARNINGS) -CFLAGS_WARN/COMMON = -CFLAGS_WARN/DEFAULT = $(CFLAGS_WARN/COMMON) $(EXTRA_WARNINGS) -# Special cases -CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) - -# The flags to use for an optimized build -OPT_CFLAGS += -O3 - -# Hotspot uses very unstrict aliasing turn this optimization off -OPT_CFLAGS += -qalias=noansi - -OPT_CFLAGS/NOOPT=-qnoopt - -DEPFLAGS = -qmakedep=gcc -MF $(DEP_DIR)/$(@:%=%.d) - -#------------------------------------------------------------------------ -# Linker flags - -# statically link libstdc++.so, work with gcc but ignored by g++ -STATIC_STDCXX = -Wl,-lC_r - -# Enable linker optimization -# no counterpart on xlc for this -# LFLAGS += -Xlinker -O1 - -# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. -# MAPFLAG = -Xlinker --version-script=FILENAME - -# Build shared library -SHARED_FLAG = -q64 -b64 -bexpall -G -bnoentry -qmkshrobj -brtl -bnolibpath -bernotok - -#------------------------------------------------------------------------ -# Debug flags - -# Always compile with '-g' to get symbols in the stacktraces in the hs_err file -DEBUG_CFLAGS += -g -FASTDEBUG_CFLAGS += -g -OPT_CFLAGS += -g - -# DEBUG_BINARIES overrides everything, use full -g debug information -ifeq ($(DEBUG_BINARIES), true) - DEBUG_CFLAGS = -g - CFLAGS += $(DEBUG_CFLAGS) -endif - -# If we are building HEADLESS, pass on to VM -# so it can set the java.awt.headless property -ifdef HEADLESS -CFLAGS += -DHEADLESS -endif - -# We are building Embedded for a small device -# favor code space over speed -ifdef MINIMIZE_RAM_USAGE -CFLAGS += -DMINIMIZE_RAM_USAGE -endif - -ifdef CROSS_COMPILE_ARCH - STRIP = $(ALT_COMPILER_PATH)/strip -else - STRIP = strip -endif diff --git a/hotspot/make/aix/platform_ppc64 b/hotspot/make/aix/platform_ppc64 deleted file mode 100644 index 5a21fb9c031..00000000000 --- a/hotspot/make/aix/platform_ppc64 +++ /dev/null @@ -1,17 +0,0 @@ -os_family = aix - -arch = ppc - -arch_model = ppc_64 - -os_arch = aix_ppc - -os_arch_model = aix_ppc_64 - -lib_arch = ppc64 - -compiler = xlc - -gnu_dis_arch = ppc64 - -sysdefs = -DAIX -DPPC64 diff --git a/hotspot/make/altsrc.make b/hotspot/make/altsrc.make deleted file mode 100644 index 027dc35d966..00000000000 --- a/hotspot/make/altsrc.make +++ /dev/null @@ -1,96 +0,0 @@ -# -# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This file defines variables and macros which are used in the makefiles to -# allow distributions to augment or replace common hotspot code with -# distribution-specific source files. This capability is disabled when -# an OPENJDK build is requested, unless HS_ALT_SRC_REL has been set externally. - -# Requires: GAMMADIR -# Provides: -# variables: HS_COMMON_SRC, HS_ALT_SRC, HS_COMMON_SRC_REL, and HS_ALT_SRC_REL -# functions: altsrc-equiv, if-has-altsrc, altsrc, altsrc-replace - -HS_COMMON_SRC_REL=src - -ifneq ($(OPENJDK),true) - # This needs to be changed to a more generic location, but we keep it - # as this for now for compatibility - HS_ALT_SRC_REL=src/closed -else - HS_ALT_SRC_REL=NO_SUCH_PATH -endif - -HS_COMMON_SRC=$(GAMMADIR)/$(HS_COMMON_SRC_REL) -HS_ALT_SRC=$(GAMMADIR)/$(HS_ALT_SRC_REL) - -## altsrc-equiv -# -# Convert a common source path to an alternative source path -# -# Parameter: An absolute path into the common sources -# Result: The matching path to the alternate-source location -# -altsrc-equiv=$(subst $(HS_COMMON_SRC)/,$(HS_ALT_SRC)/,$(1)) - - -## if-has-altsrc -# -# Conditional macro to test for the existence of an alternate source path -# -# Parameter: An absolute path into the common sources -# Parameter: Result if the alternative-source location exists -# Parameter: Result if the alternative-source location does not exist -# Result: expands to parameter 2 or 3 depending on existence of alternate source -# -if-has-altsrc=$(if $(wildcard $(call altsrc-equiv,$(1))),$(2),$(3)) - - -## altsrc -# -# Converts common source path to alternate source path if the alternate -# path exists, otherwise evaluates to nul (empty string) -# -# Parameter: An absolute path into the common sources -# Result: The equivalent path to the alternate-source location, if such a -# location exists on the filesystem. Otherwise it expands to empty. -# -altsrc=$(call if-has-altsrc,$(1),$(call altsrc-equiv,$(1))) - -## commonsrc -# -# Returns parameter. -# -commonsrc=$(1) - - -## altsrc-replace -# -# Converts a common source path to an alternate source path if the alternate -# source path exists. Otherwise it evaluates to the input common source path. -# -# Parameter: An absolute path into the common sources -# Result: A path to either the common or alternate sources -# -altsrc-replace=$(call if-has-altsrc,$(1),$(call altsrc-equiv,$(1)),$(1)) diff --git a/hotspot/make/bsd/Makefile b/hotspot/make/bsd/Makefile deleted file mode 100644 index d3e977f152b..00000000000 --- a/hotspot/make/bsd/Makefile +++ /dev/null @@ -1,386 +0,0 @@ -# -# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile creates a build tree and lights off a build. -# You can go back into the build tree and perform rebuilds or -# incremental builds as desired. Be sure to reestablish -# environment variable settings for LD_LIBRARY_PATH and JAVA_HOME. - -# The make process now relies on java and javac. These can be -# specified either implicitly on the PATH, by setting the -# (JDK-inherited) ALT_BOOTDIR environment variable to full path to a -# JDK in which bin/java and bin/javac are present and working (e.g., -# /usr/local/java/jdk1.3/solaris), or via the (JDK-inherited) -# default BOOTDIR path value. Note that one of ALT_BOOTDIR -# or BOOTDIR has to be set. We do *not* search javac, javah, rmic etc. -# from the PATH. -# -# One can set ALT_BOOTDIR or BOOTDIR to point to a jdk that runs on -# an architecture that differs from the target architecture, as long -# as the bootstrap jdk runs under the same flavor of OS as the target -# (i.e., if the target is linux, point to a jdk that runs on a linux -# box). In order to use such a bootstrap jdk, set the make variable -# REMOTE to the desired remote command mechanism, e.g., -# -# make REMOTE="rsh -l me myotherlinuxbox" - -ifeq ($(GAMMADIR),) -include ../../make/defs.make -else -include $(GAMMADIR)/make/defs.make -endif -include $(GAMMADIR)/make/$(OSNAME)/makefiles/rules.make - -ifndef CC_INTERP - ifndef FORCE_TIERED - FORCE_TIERED=1 - endif -endif - -ifdef LP64 - ifeq ("$(filter $(LP64_ARCH),$(BUILDARCH))","") - _JUNK_ := $(shell echo >&2 \ - $(OSNAME) $(ARCH) "*** ERROR: this platform does not support 64-bit compilers!") - @exit 1 - endif -endif - -# we need to set up LP64 correctly to satisfy sanity checks in adlc -ifneq ("$(filter $(LP64_ARCH),$(BUILDARCH))","") - MFLAGS += " LP64=1 " -endif - -# pass USE_SUNCC further, through MFLAGS -ifdef USE_SUNCC - MFLAGS += " USE_SUNCC=1 " -endif - -# The following renders pathnames in generated Makefiles valid on -# machines other than the machine containing the build tree. -# -# For example, let's say my build tree lives on /files12 on -# exact.east.sun.com. This logic will cause GAMMADIR to begin with -# /net/exact/files12/... -# -# We only do this on SunOS variants, for a couple of reasons: -# * It is extremely rare that source trees exist on other systems -# * It has been claimed that the Linux automounter is flakey, so -# changing GAMMADIR in a way that exercises the automounter could -# prove to be a source of unreliability in the build process. -# Obviously, this Makefile is only relevant on SunOS boxes to begin -# with, but the SunOS conditionalization will make it easier to -# combine Makefiles in the future (assuming we ever do that). - -ifeq ($(OSNAME),solaris) - - # prepend current directory to relative pathnames. - NEW_GAMMADIR := \ - $(shell echo $(GAMMADIR) | \ - sed -e "s=^\([^/].*\)=$(shell pwd)/\1=" \ - ) - unexport NEW_GAMMADIR - - # If NEW_GAMMADIR doesn't already start with "/net/": - ifeq ($(strip $(filter /net/%,$(NEW_GAMMADIR))),) - # prepend /net/$(HOST) - # remove /net/$(HOST) if name already began with /home/ - # remove /net/$(HOST) if name already began with /java/ - # remove /net/$(HOST) if name already began with /lab/ - NEW_GAMMADIR := \ - $(shell echo $(NEW_GAMMADIR) | \ - sed -e "s=^\(.*\)=/net/$(HOST)\1=" \ - -e "s=^/net/$(HOST)/home/=/home/=" \ - -e "s=^/net/$(HOST)/java/=/java/=" \ - -e "s=^/net/$(HOST)/lab/=/lab/=" \ - ) - # Don't use the new value for GAMMADIR unless a file with the new - # name actually exists. - ifneq ($(wildcard $(NEW_GAMMADIR)),) - GAMMADIR := $(NEW_GAMMADIR) - endif - endif - -endif - -# BUILDARCH is set to "zero" for Zero builds. VARIANTARCH -# is used to give the build directories meaningful names. -VARIANTARCH = $(subst i386,i486,$(ZERO_LIBARCH)) - -# There is a (semi-) regular correspondence between make targets and actions: -# -# Target Tree Type Build Dir -# -# debug compiler2 __compiler2/debug -# fastdebug compiler2 __compiler2/fastdebug -# optimized compiler2 __compiler2/optimized -# product compiler2 __compiler2/product -# -# debug1 compiler1 __compiler1/debug -# fastdebug1 compiler1 __compiler1/fastdebug -# optimized1 compiler1 __compiler1/optimized -# product1 compiler1 __compiler1/product -# -# debugcore core __core/debug -# fastdebugcore core __core/fastdebug -# optimizedcore core __core/optimized -# productcore core __core/product -# -# debugzero zero __zero/debug -# fastdebugzero zero __zero/fastdebug -# optimizedzero zero __zero/optimized -# productzero zero __zero/product -# -# debugshark shark __shark/debug -# fastdebugshark shark __shark/fastdebug -# optimizedshark shark __shark/optimized -# productshark shark __shark/product -# -# fastdebugminimal1 minimal1 __minimal1/fastdebug -# debugminimal1 minimal1 __minimal1/debug -# productminimal1 minimal1 __minimal1/product -# -# What you get with each target: -# -# debug* - debug compile with asserts enabled -# fastdebug* - optimized compile, but with asserts enabled -# optimized* - optimized compile, no asserts -# product* - the shippable thing: optimized compile, no asserts, -DPRODUCT - -# This target list needs to be coordinated with the usage message -# in the build.sh script: -TARGETS = debug fastdebug optimized product - -ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - SUBDIR_DOCS = $(OSNAME)_$(VARIANTARCH)_docs -else - SUBDIR_DOCS = $(OSNAME)_$(BUILDARCH)_docs -endif -SUBDIRS_C1 = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler1/,$(TARGETS)) -SUBDIRS_C2 = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS)) -SUBDIRS_TIERED = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS)) -SUBDIRS_CORE = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS)) -SUBDIRS_ZERO = $(addprefix $(OSNAME)_$(VARIANTARCH)_zero/,$(TARGETS)) -SUBDIRS_SHARK = $(addprefix $(OSNAME)_$(VARIANTARCH)_shark/,$(TARGETS)) -SUBDIRS_MINIMAL1 = $(addprefix $(OSNAME)_$(BUILDARCH)_minimal1/,$(TARGETS)) - -TARGETS_C2 = $(TARGETS) -TARGETS_C1 = $(addsuffix 1,$(TARGETS)) -TARGETS_TIERED = $(addsuffix tiered,$(TARGETS)) -TARGETS_CORE = $(addsuffix core,$(TARGETS)) -TARGETS_ZERO = $(addsuffix zero,$(TARGETS)) -TARGETS_SHARK = $(addsuffix shark,$(TARGETS)) -TARGETS_MINIMAL1 = $(addsuffix minimal1,$(TARGETS)) - -BUILDTREE_MAKE = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make -BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) LIBRARY_SUFFIX=$(LIBRARY_SUFFIX) -BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING) -BUILDTREE_VARS += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY) ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) ZIPEXE=$(ZIPEXE) - -BUILDTREE = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS) - -#------------------------------------------------------------------------------- - -# Could make everything by default, but that would take a while. -all: - @echo "Try '$(MAKE) ...' where is one or more of" - @echo " $(TARGETS_C2)" - @echo " $(TARGETS_C1)" - @echo " $(TARGETS_CORE)" - @echo " $(TARGETS_ZERO)" - @echo " $(TARGETS_SHARK)" - @echo " $(TARGETS_MINIMAL1)" - -checks: check_os_version check_j2se_version - -# We do not want people accidentally building on old systems (e.g. Linux 2.2.x, -# Solaris 2.5.1, 2.6). -# Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok. - -#SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 2.7% -DISABLE_HOTSPOT_OS_VERSION_CHECK = ok -OS_VERSION := $(shell uname -r) -EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION)) - -check_os_version: -ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),) - $(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1; -endif - -# jvmti.make requires XSLT (J2SE 1.4.x or newer): -XSLT_CHECK = $(REMOTE) $(RUN.JAVAP) javax.xml.transform.TransformerFactory -# If not found then fail fast. -check_j2se_version: - $(QUIETLY) if ! $(XSLT_CHECK) > /dev/null 2>&1; then \ - $(REMOTE) $(RUN.JAVA) -version; \ - echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \ - "to bootstrap this build" 1>&2; \ - exit 1; \ - fi - -$(SUBDIRS_TIERED): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=tiered - -$(SUBDIRS_C2): $(BUILDTREE_MAKE) -ifeq ($(FORCE_TIERED),1) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=tiered FORCE_TIERED=1 -else - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=compiler2 -endif - -$(SUBDIRS_C1): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=compiler1 - -$(SUBDIRS_CORE): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=core - -$(SUBDIRS_ZERO): $(BUILDTREE_MAKE) platform_zero - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=zero VARIANTARCH=$(VARIANTARCH) - -$(SUBDIRS_SHARK): $(BUILDTREE_MAKE) platform_zero - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=shark VARIANTARCH=$(VARIANTARCH) - -$(SUBDIRS_MINIMAL1): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=minimal1 - -platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in - $(SED) 's/@ZERO_ARCHDEF@/$(ZERO_ARCHDEF)/g;s/@ZERO_LIBARCH@/$(ZERO_LIBARCH)/g;' < $< > $@ - -# Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME - -$(TARGETS_C2): $(SUBDIRS_C2) - cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_TIERED): $(SUBDIRS_TIERED) - cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_C1): $(SUBDIRS_C1) - cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_CORE): $(SUBDIRS_CORE) - cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_ZERO): $(SUBDIRS_ZERO) - cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_SHARK): $(SUBDIRS_SHARK) - cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_MINIMAL1): $(SUBDIRS_MINIMAL1) - cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) install -endif - -# Just build the tree, and nothing else: -tree: $(SUBDIRS_C2) -tree1: $(SUBDIRS_C1) -treecore: $(SUBDIRS_CORE) -treezero: $(SUBDIRS_ZERO) -treeshark: $(SUBDIRS_SHARK) -treeminimal1: $(SUBDIRS_MINIMAL1) - -# Doc target. This is the same for all build options. -# Hence create a docs directory beside ...$(ARCH)_[...] -# We specify 'BUILD_FLAVOR=product' so that the proper -# ENABLE_FULL_DEBUG_SYMBOLS value is used. -docs: checks - $(QUIETLY) mkdir -p $(SUBDIR_DOCS) - $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/makefiles/jvmti.make $(MFLAGS) $(BUILDTREE_VARS) JvmtiOutDir=$(SUBDIR_DOCS) BUILD_FLAVOR=product jvmtidocs - -# Synonyms for win32-like targets. -compiler2: debug product - -compiler1: debug1 product1 - -core: debugcore productcore - -zero: debugzero productzero - -shark: debugshark productshark - -warn_jvmg_deprecated: - echo "Warning: The jvmg target has been replaced with debug" - echo "Warning: Please update your usage" - -jvmg: warn_jvmg_deprecated debug - -jvmg1: warn_jvmg_deprecated debug1 - -jvmgcore: warn_jvmg_deprecated debugcore - -jvmgzero: warn_jvmg_deprecated debugzero - -jvmgshark: warn_jvmg_deprecated debugshark - -clean_docs: - rm -rf $(SUBDIR_DOCS) - -clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark clean_minimal1: - rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@) - -clean: clean_compiler2 clean_compiler1 clean_core clean_zero clean_shark clean_minimal1 clean_docs - -include $(GAMMADIR)/make/cscope.make - -# -# Include alternate Makefile if it exists. -# --include $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make - -#------------------------------------------------------------------------------- - -.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK) $(TARGETS_MINIMAL1) -.PHONY: tree tree1 treecore treezero treeshark -.PHONY: all compiler1 compiler2 core zero shark -.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs -.PHONY: checks check_os_version check_j2se_version -.PHONY: $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make - -.NOTPARALLEL: diff --git a/hotspot/make/bsd/README b/hotspot/make/bsd/README deleted file mode 100644 index d3efaf8b610..00000000000 --- a/hotspot/make/bsd/README +++ /dev/null @@ -1,26 +0,0 @@ -Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - -This code is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License version 2 only, as -published by the Free Software Foundation. - -This code is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -version 2 for more details (a copy is included in the LICENSE file that -accompanied this code). - -You should have received a copy of the GNU General Public License version -2 along with this work; if not, write to the Free Software Foundation, -Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - -Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -or visit www.oracle.com if you need additional information or have any -questions. - -________________________________________________________________________ - -Please refer to the comments in the Makefile in this directory -for instructions how to build the Solaris versions. - diff --git a/hotspot/make/bsd/adlc_updater b/hotspot/make/bsd/adlc_updater deleted file mode 100644 index 99e04e333f2..00000000000 --- a/hotspot/make/bsd/adlc_updater +++ /dev/null @@ -1,23 +0,0 @@ -#! /bin/sh -# -# This file is used by adlc.make to selectively update generated -# adlc files. Because source and target diretories are relative -# paths, this file is copied to the target build directory before -# use. -# -# adlc-updater -# -fix_lines() { - # repair bare #line directives in $1 to refer to $2 - # and add an override of __FILE__ with just the basename on the - # first line of the file. - awk < $1 > $1+ -v F2=$2 ' - BEGIN { print "#line 1 \"" F2 "\""; } - /^#line 999999$/ {print "#line " (NR+1) " \"" F2 "\""; next} - {print} - ' - mv $1+ $1 -} -fix_lines $2/$1 $1 -[ -f $3/$1 ] && cmp -s $2/$1 $3/$1 || \ -( [ -f $3/$1 ] && echo Updating $3/$1 ; touch $2/made-change ; mv $2/$1 $3/$1 ) diff --git a/hotspot/make/bsd/makefiles/adjust-mflags.sh b/hotspot/make/bsd/makefiles/adjust-mflags.sh deleted file mode 100644 index 97bc02db7f1..00000000000 --- a/hotspot/make/bsd/makefiles/adjust-mflags.sh +++ /dev/null @@ -1,87 +0,0 @@ -#! /bin/sh -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This script is used only from top.make. -# The macro $(MFLAGS-adjusted) calls this script to -# adjust the "-j" arguments to take into account -# the HOTSPOT_BUILD_JOBS variable. The default -# handling of the "-j" argument by gnumake does -# not meet our needs, so we must adjust it ourselves. - -# This argument adjustment applies to two recursive -# calls to "$(MAKE) $(MFLAGS-adjusted)" in top.make. -# One invokes adlc.make, and the other invokes vm.make. -# The adjustment propagates the desired concurrency -# level down to the sub-make (of the adlc or vm). -# The default behavior of gnumake is to run all -# sub-makes without concurrency ("-j1"). - -# Also, we use a make variable rather than an explicit -# "-j" argument to control this setting, so that -# the concurrency setting (which must be tuned separately -# for each MP system) can be set via an environment variable. -# The recommended setting is 1.5x to 2x the number of available -# CPUs on the MP system, which is large enough to keep the CPUs -# busy (even though some jobs may be I/O bound) but not too large, -# we may presume, to overflow the system's swap space. - -set -eu - -default_build_jobs=4 - -case $# in -[12]) true;; -*) >&2 echo "Usage: $0 ${MFLAGS} ${HOTSPOT_BUILD_JOBS}"; exit 2;; -esac - -MFLAGS=$1 -HOTSPOT_BUILD_JOBS=${2-} - -# Normalize any -jN argument to the form " -j${HBJ}" -MFLAGS=` - echo "$MFLAGS" \ - | sed ' - s/^-/ -/ - s/ -\([^ I][^ I]*\)j/ -\1 -j/ - s/ -j[0-9][0-9]*/ -j/ - s/ -j\([^ ]\)/ -j -\1/ - s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/ - ' ` - -case ${HOTSPOT_BUILD_JOBS} in \ - -'') case ${MFLAGS} in - *\ -j*) - >&2 echo "# Note: -jN is ineffective for setting parallelism in this makefile." - >&2 echo "# please set HOTSPOT_BUILD_JOBS=${default_build_jobs} in the command line or environment." - esac;; - -?*) case ${MFLAGS} in - *\ -j*) true;; - *) MFLAGS="-j${HOTSPOT_BUILD_JOBS} ${MFLAGS}";; - esac;; -esac - -echo "${MFLAGS}" diff --git a/hotspot/make/bsd/makefiles/adlc.make b/hotspot/make/bsd/makefiles/adlc.make deleted file mode 100644 index dd3346efc66..00000000000 --- a/hotspot/make/bsd/makefiles/adlc.make +++ /dev/null @@ -1,233 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (adlc.make) is included from the adlc.make in the -# build directories. -# It knows how to compile, link, and run the adlc. - -include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make - -# ######################################################################### - -# OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make: -GENERATED = ../generated -OUTDIR = $(GENERATED)/adfiles - -ARCH = $(Platform_arch) -OS = $(Platform_os_family) - -SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad - -ifeq ("${Platform_arch_model}", "${Platform_arch}") - SOURCES.AD = \ - $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) -else - SOURCES.AD = \ - $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \ - $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) -endif - -EXEC = $(OUTDIR)/adlc - -# set VPATH so make knows where to look for source files -Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc -VPATH += $(Src_Dirs_V:%=%:) - -# set INCLUDES for C preprocessor -Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED) -INCLUDES += $(Src_Dirs_I:%=-I%) - -# set flags for adlc compilation -CXXFLAGS = $(SYSDEFS) $(INCLUDES) - -# Force assertions on. -CXXFLAGS += -DASSERT - -# CFLAGS_WARN holds compiler options to suppress/enable warnings. -# Compiler warnings are treated as errors -ifneq ($(COMPILER_WARNINGS_FATAL),false) - CFLAGS_WARN = $(WARNINGS_ARE_ERRORS) -endif -CFLAGS += $(CFLAGS_WARN) - -OBJECTNAMES = \ - adlparse.o \ - archDesc.o \ - arena.o \ - dfa.o \ - dict2.o \ - filebuff.o \ - forms.o \ - formsopt.o \ - formssel.o \ - main.o \ - adlc-opcodes.o \ - output_c.o \ - output_h.o \ - -OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%) - -GENERATEDNAMES = \ - ad_$(Platform_arch_model).cpp \ - ad_$(Platform_arch_model).hpp \ - ad_$(Platform_arch_model)_clone.cpp \ - ad_$(Platform_arch_model)_expand.cpp \ - ad_$(Platform_arch_model)_format.cpp \ - ad_$(Platform_arch_model)_gen.cpp \ - ad_$(Platform_arch_model)_misc.cpp \ - ad_$(Platform_arch_model)_peephole.cpp \ - ad_$(Platform_arch_model)_pipeline.cpp \ - adGlobals_$(Platform_arch_model).hpp \ - dfa_$(Platform_arch_model).cpp \ - -GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%) - -# ######################################################################### - -all: $(EXEC) - -$(EXEC) : $(OBJECTS) - @echo $(LOG_INFO) Making adlc - $(QUIETLY) $(HOST.LINK_NOPROF.CXX) -o $(EXEC) $(OBJECTS) - -# Random dependencies: -$(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp - -# The source files refer to ostream.h, which sparcworks calls iostream.h -$(OBJECTS): ostream.h - -ostream.h : - @echo >$@ '#include ' - -dump: - : OUTDIR=$(OUTDIR) - : OBJECTS=$(OBJECTS) - : products = $(GENERATEDFILES) - -all: $(GENERATEDFILES) - -$(GENERATEDFILES): refresh_adfiles - -# Get a unique temporary directory name, so multiple makes can run in parallel. -# Note that product files are updated via "mv", which is atomic. -TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$) - -# Debuggable by default -CFLAGS += -g - -# Pass -D flags into ADLC. -ADLCFLAGS += $(SYSDEFS) - -# Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO. -ADLCFLAGS += -q -T - -# Normally, debugging is done directly on the ad_*.cpp files. -# But -g will put #line directives in those files pointing back to .ad. -# Some builds of gcc 3.2 have a bug that gets tickled by the extra #line directives -# so skip it for 3.2 and ealier. -ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" -ADLCFLAGS += -g -endif - -ifdef LP64 -ADLCFLAGS += -D_LP64 -else -ADLCFLAGS += -U_LP64 -endif - -# -# adlc_updater is a simple sh script, under sccs control. It is -# used to selectively update generated adlc files. This should -# provide a nice compilation speed improvement. -# -ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS) -ADLC_UPDATER = adlc_updater -$(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER) - $(QUIETLY) cp $< $@; chmod +x $@ - -# This action refreshes all generated adlc files simultaneously. -# The way it works is this: -# 1) create a scratch directory to work in. -# 2) if the current working directory does not have $(ADLC_UPDATER), copy it. -# 3) run the compiled adlc executable. This will create new adlc files in the scratch directory. -# 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files. -# 5) If we actually updated any files, echo a notice. -# -refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER) - @rm -rf $(TEMPDIR); mkdir $(TEMPDIR) - $(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \ - -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \ - || { rm -rf $(TEMPDIR); exit 1; } - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) [ -f $(TEMPDIR)/made-change ] \ - || echo $(LOG_INFO) "Rescanned $(SOURCE.AD) but encountered no changes." - $(QUIETLY) rm -rf $(TEMPDIR) - - -# ######################################################################### - -$(SOURCE.AD): $(SOURCES.AD) - $(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD) - -#PROCESS_AD_FILES = cat -# Pass through #line directives, in case user enables -g option above: -PROCESS_AD_FILES = awk '{ \ - if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \ - if (need_lineno && $$0 !~ /\/\//) \ - { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \ - print }' - -$(OUTDIR)/%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(HOST.COMPILE.CXX) -o $@ $< $(COMPILE_DONE) - -# Some object files are given a prefix, to disambiguate -# them from objects of the same name built for the VM. -$(OUTDIR)/adlc-%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(HOST.COMPILE.CXX) -o $@ $< $(COMPILE_DONE) - -# ######################################################################### - -clean : - rm $(OBJECTS) - -cleanall : - rm $(OBJECTS) $(EXEC) - -# ######################################################################### - -.PHONY: all dump refresh_adfiles clean cleanall diff --git a/hotspot/make/bsd/makefiles/amd64.make b/hotspot/make/bsd/makefiles/amd64.make deleted file mode 100644 index 6512375259e..00000000000 --- a/hotspot/make/bsd/makefiles/amd64.make +++ /dev/null @@ -1,47 +0,0 @@ -# -# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT) -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT) -# Must also specify if CPU is little endian -CFLAGS += -DVM_LITTLE_ENDIAN - -CFLAGS += -D_LP64=1 - -# The serviceability agent relies on frame pointer (%rbp) to walk thread stack -ifndef USE_SUNCC - CFLAGS += -fno-omit-frame-pointer -endif - -OPT_CFLAGS/compactingPermGenGen.o = -O1 - -# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides -# of OPT_CFLAGS. Restore it here. -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS/sharedRuntimeTrig.o += -g - OPT_CFLAGS/sharedRuntimeTrans.o += -g - OPT_CFLAGS/compactingPermGenGen.o += -g -endif diff --git a/hotspot/make/bsd/makefiles/arm.make b/hotspot/make/bsd/makefiles/arm.make deleted file mode 100644 index 9e6fdd5abae..00000000000 --- a/hotspot/make/bsd/makefiles/arm.make +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -Obj_Files += bsd_arm.o - -CFLAGS += -DVM_LITTLE_ENDIAN diff --git a/hotspot/make/bsd/makefiles/build_vm_def.sh b/hotspot/make/bsd/makefiles/build_vm_def.sh deleted file mode 100644 index 91918635b26..00000000000 --- a/hotspot/make/bsd/makefiles/build_vm_def.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -# If we're cross compiling use that path for nm -if [ "$CROSS_COMPILE_ARCH" != "" ]; then -NM=$ALT_COMPILER_PATH/nm -else -NM=nm -fi - -$NM -Uj $* | awk ' - { if ($3 ~ /^_ZTV/ || $3 ~ /^gHotSpotVM/) print "\t" $3 } - ' diff --git a/hotspot/make/bsd/makefiles/buildtree.make b/hotspot/make/bsd/makefiles/buildtree.make deleted file mode 100644 index 3ae09d3dd5b..00000000000 --- a/hotspot/make/bsd/makefiles/buildtree.make +++ /dev/null @@ -1,370 +0,0 @@ -# -# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Usage: -# -# $(MAKE) -f buildtree.make SRCARCH=srcarch BUILDARCH=buildarch LIBARCH=libarch -# GAMMADIR=dir OS_FAMILY=os VARIANT=variant -# -# The macros ARCH, GAMMADIR, OS_FAMILY and VARIANT must be defined in the -# environment or on the command-line: -# -# ARCH - sparc, i486, ... HotSpot cpu and os_cpu source directory -# BUILDARCH - build directory -# LIBARCH - the corresponding directory in JDK/JRE -# GAMMADIR - top of workspace -# OS_FAMILY - operating system -# VARIANT - core, compiler1, compiler2, or tiered -# VERSION_STRING - the JDK version string as specified by JEP-223 -# HOTSPOT_VERSION_STRING - the same as VERSION_STRING, unless overridden by a standalone build -# -# Builds the directory trees with makefiles plus some convenience files in -# each directory: -# -# Makefile - for "make foo" -# flags.make - with macro settings -# vm.make - to support making "$(MAKE) -v vm.make" in makefiles -# adlc.make - -# trace.make - generate tracing event and type definitions -# jvmti.make - generate JVMTI bindings from the spec (JSR-163) -# -# The makefiles are split this way so that "make foo" will run faster by not -# having to read the dependency files for the vm. - -# needs to be set here since this Makefile doesn't include defs.make -OS_VENDOR:=$(shell uname -s) - --include $(SPEC) -include $(GAMMADIR)/make/scm.make -include $(GAMMADIR)/make/defs.make -include $(GAMMADIR)/make/altsrc.make - - -# 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details. -QUIETLY$(MAKE_VERBOSE) = @ - -ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - PLATFORM_FILE = $(shell dirname $(shell dirname $(shell pwd)))/platform_zero -else - ifdef USE_SUNCC - PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).suncc - else - PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH) - endif -endif - -# Allow overriding of the arch part of the directory but default -# to BUILDARCH if nothing is specified -ifeq ($(VARIANTARCH),) - VARIANTARCH=$(BUILDARCH) -endif - -ifdef FORCE_TIERED -ifeq ($(VARIANT),tiered) -PLATFORM_DIR = $(OS_FAMILY)_$(VARIANTARCH)_compiler2 -else -PLATFORM_DIR = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT) -endif -else -PLATFORM_DIR = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT) -endif - -# -# We do two levels of exclusion in the shared directory. -# TOPLEVEL excludes are pruned, they are not recursively searched, -# but lower level directories can be named without fear of collision. -# ALWAYS excludes are excluded at any level in the directory tree. -# - -ALWAYS_EXCLUDE_DIRS = $(SCM_DIRS) - -ifeq ($(VARIANT),tiered) -TOPLEVEL_EXCLUDE_DIRS = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name agent -else -ifeq ($(VARIANT),compiler2) -TOPLEVEL_EXCLUDE_DIRS = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name c1 -o -name agent -else -# compiler1 and core use the same exclude list -TOPLEVEL_EXCLUDE_DIRS = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name opto -o -name libadt -o -name agent -endif -endif - -# Get things from the platform file. -COMPILER = $(shell sed -n 's/^compiler[ ]*=[ ]*//p' $(PLATFORM_FILE)) - -# dtracefiles is used on BSD versions that implement Dtrace (like MacOS X) -SIMPLE_DIRS = \ - $(PLATFORM_DIR)/generated/dependencies \ - $(PLATFORM_DIR)/generated/adfiles \ - $(PLATFORM_DIR)/generated/jvmtifiles \ - $(PLATFORM_DIR)/generated/tracefiles \ - $(PLATFORM_DIR)/generated/dtracefiles - -TARGETS = debug fastdebug optimized product -SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS)) - -# For dependencies and recursive makes. -BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make - -# dtrace.make is used on BSD versions that implement Dtrace (like MacOS X) -BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make dtrace.make - -BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \ - SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT) - -# Define variables to be set in flags.make. -# Default values are set in make/defs.make. - -# Set BUILD_USER from system-dependent hints: $LOGNAME, $(whoami) -ifndef HOTSPOT_BUILD_USER - HOTSPOT_BUILD_USER := $(shell echo $$LOGNAME) -endif -ifndef HOTSPOT_BUILD_USER - HOTSPOT_BUILD_USER := $(shell whoami) -endif -# Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro -# or make/hotspot_distro. -ifndef HOTSPOT_VM_DISTRO - ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true) - include $(GAMMADIR)/make/hotspot_distro - else - include $(GAMMADIR)/make/openjdk_distro - endif -endif - -# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK -ifndef OPENJDK - ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true) - OPENJDK=true - endif -endif - -BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING) - -BUILDTREE = \ - $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_TARGETS) $(BUILDTREE_VARS) - -BUILDTREE_COMMENT = echo "\# Generated by $(BUILDTREE_MAKE)" - -all: $(SUBMAKE_DIRS) - -# Run make in each subdirectory recursively. -$(SUBMAKE_DIRS): $(SIMPLE_DIRS) FORCE - $(QUIETLY) [ -d $@ ] || { mkdir -p $@; } - +$(QUIETLY) cd $@ && $(BUILDTREE) TARGET=$(@F) - $(QUIETLY) touch $@ - -$(SIMPLE_DIRS): - $(QUIETLY) mkdir -p $@ - -# Convenience macro which takes a source relative path, applies $(1) to the -# absolute path, and then replaces $(GAMMADIR) in the result with a -# literal "$(GAMMADIR)/" suitable for inclusion in a Makefile. -gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2))) - -# This bit is needed to enable local rebuilds. -# Unless the makefile itself sets LP64, any environmental -# setting of LP64 will interfere with the build. -LP64_SETTING/32 = LP64 = \#empty -LP64_SETTING/64 = LP64 = 1 - -DATA_MODE/i486 = 32 -DATA_MODE/amd64 = 64 - -DATA_MODE = $(DATA_MODE/$(BUILDARCH)) - -flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo "Platform_file = $(PLATFORM_FILE)" | sed 's|$(GAMMADIR)|$$(GAMMADIR)|'; \ - sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \ - echo; \ - echo "GAMMADIR = $(GAMMADIR)"; \ - echo "HS_ALT_MAKE = $(HS_ALT_MAKE)"; \ - echo "OSNAME = $(OSNAME)"; \ - echo "SYSDEFS = \$$(Platform_sysdefs)"; \ - echo "SRCARCH = $(SRCARCH)"; \ - echo "BUILDARCH = $(BUILDARCH)"; \ - echo "LIBARCH = $(LIBARCH)"; \ - echo "TARGET = $(TARGET)"; \ - echo "HOTSPOT_VERSION_STRING = $(HOTSPOT_VERSION_STRING)"; \ - echo "VERSION_STRING = $(VERSION_STRING)"; \ - echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \ - echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \ - echo "OPENJDK = $(OPENJDK)"; \ - echo "$(LP64_SETTING/$(DATA_MODE))"; \ - echo; \ - echo "STATIC_BUILD = $(STATIC_BUILD)"; \ - echo "COMPILER_WARNINGS_FATAL = $(COMPILER_WARNINGS_FATAL)"; \ - echo "EXTRA_LDFLAGS = $(EXTRA_LDFLAGS)"; \ - echo "LIBRARY_SUFFIX = $(LIBRARY_SUFFIX)"; \ - echo; \ - echo "# Used for platform dispatching"; \ - echo "TARGET_DEFINES = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \ - echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \ - echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \ - echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \ - echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \ - echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \ - echo "CFLAGS += \$$(TARGET_DEFINES)"; \ - echo; \ - echo "Src_Dirs_V = \\"; \ - sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \ - echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/posix/vm)"; \ - echo; \ - echo "Src_Dirs_I = \\"; \ - echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \ - echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \ - echo "$(call gamma-path,altsrc,share/vm) \\"; \ - echo "$(call gamma-path,commonsrc,share/vm) \\"; \ - echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \ - echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \ - echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/posix/vm)"; \ - [ -n "$(CFLAGS_BROWSE)" ] && \ - echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \ - [ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \ - echo && echo "ENABLE_FULL_DEBUG_SYMBOLS = $(ENABLE_FULL_DEBUG_SYMBOLS)"; \ - [ -n "$(OBJCOPY)" ] && \ - echo && echo "OBJCOPY = $(OBJCOPY)"; \ - [ -n "$(STRIP_POLICY)" ] && \ - echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \ - [ -n "$(ZIP_DEBUGINFO_FILES)" ] && \ - echo && echo "ZIP_DEBUGINFO_FILES = $(ZIP_DEBUGINFO_FILES)"; \ - [ -n "$(ZIPEXE)" ] && \ - echo && echo "ZIPEXE = $(ZIPEXE)"; \ - [ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \ - echo && \ - echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \ - echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \ - echo; \ - [ -n "$(SPEC)" ] && \ - echo "include $(SPEC)"; \ - echo "CP ?= cp"; \ - echo "MV ?= mv"; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \ - echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \ - ) > $@ - -flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \ - ) > $@ - -../shared_dirs.lst: $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm - @echo $(LOG_INFO) Creating directory list $@ - $(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \ - find $(HS_ALT_SRC)/share/vm/* -prune \ - -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \ - \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \ - fi; - $(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \ - -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \ - \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@ - -Makefile: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \ - ) > $@ - -vm.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo include flags_vm.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -adlc.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -jvmti.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -trace.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -dtrace.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -FORCE: - -.PHONY: all FORCE - -.NOTPARALLEL: diff --git a/hotspot/make/bsd/makefiles/compiler1.make b/hotspot/make/bsd/makefiles/compiler1.make deleted file mode 100644 index d303bfc1ca4..00000000000 --- a/hotspot/make/bsd/makefiles/compiler1.make +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making client version of VM - -TYPE=COMPILER1 - -VM_SUBDIR = client - -# We don't support the JVMCI in a client VM. -INCLUDE_JVMCI := false - -CFLAGS += -DCOMPILER1 diff --git a/hotspot/make/bsd/makefiles/compiler2.make b/hotspot/make/bsd/makefiles/compiler2.make deleted file mode 100644 index c881079882e..00000000000 --- a/hotspot/make/bsd/makefiles/compiler2.make +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making server version of VM - -TYPE=COMPILER2 - -VM_SUBDIR = server - -CFLAGS += -DCOMPILER2 diff --git a/hotspot/make/bsd/makefiles/core.make b/hotspot/make/bsd/makefiles/core.make deleted file mode 100644 index e032d964f57..00000000000 --- a/hotspot/make/bsd/makefiles/core.make +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making core version of VM - -# Select which files to use (in top.make) -TYPE=CORE - -# There is no "core" directory in JDK. Install core build in server directory. -VM_SUBDIR = server - -# Note: macros.hpp defines CORE diff --git a/hotspot/make/bsd/makefiles/cscope.make b/hotspot/make/bsd/makefiles/cscope.make deleted file mode 100644 index 7a12b3bbcd1..00000000000 --- a/hotspot/make/bsd/makefiles/cscope.make +++ /dev/null @@ -1,160 +0,0 @@ -# -# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# -# The cscope.out file is made in the current directory and spans the entire -# source tree. -# -# Things to note: -# 1. We use relative names for cscope. -# 2. We *don't* remove the old cscope.out file, because cscope is smart -# enough to only build what has changed. It can be confused, however, -# if files are renamed or removed, so it may be necessary to manually -# remove cscope.out if a lot of reorganization has occurred. -# - -include $(GAMMADIR)/make/scm.make - -NAWK = awk -RM = rm -f -HG = hg -CS_TOP = ../.. - -CSDIRS = $(CS_TOP)/src $(CS_TOP)/build -CSINCS = $(CSDIRS:%=-I%) - -CSCOPE = cscope -CSCOPE_FLAGS = -b - -# Allow .java files to be added from the environment (CSCLASSES=yes). -ifdef CSCLASSES -ADDCLASSES= -o -name '*.java' -endif - -# Adding CClassHeaders also pushes the file count of a full workspace up about -# 200 files (these files also don't exist in a new workspace, and thus will -# cause the recreation of the database as they get created, which might seem -# a little confusing). Thus allow these files to be added from the environment -# (CSHEADERS=yes). -ifndef CSHEADERS -RMCCHEADERS= -o -name CClassHeaders -endif - -# Use CS_GENERATED=x to include auto-generated files in the build directories. -ifdef CS_GENERATED -CS_ADD_GENERATED = -o -name '*.incl' -else -CS_PRUNE_GENERATED = -o -name '${OS}_*_core' -o -name '${OS}_*_compiler?' -endif - -# OS-specific files for other systems are excluded by default. Use CS_OS=yes -# to include platform-specific files for other platforms. -ifndef CS_OS -CS_OS = linux macos solaris win32 bsd -CS_PRUNE_OS = $(patsubst %,-o -name '*%*',$(filter-out ${OS},${CS_OS})) -endif - -# Processor-specific files for other processors are excluded by default. Use -# CS_CPU=x to include platform-specific files for other platforms. -ifndef CS_CPU -CS_CPU = i486 sparc amd64 ia64 -CS_PRUNE_CPU = $(patsubst %,-o -name '*%*',$(filter-out ${SRCARCH},${CS_CPU})) -endif - -# What files should we include? A simple rule might be just those files under -# SCCS control, however this would miss files we create like the opcodes and -# CClassHeaders. The following attempts to find everything that is *useful*. -# (.del files are created by sccsrm, demo directories contain many .java files -# that probably aren't useful for development, and the pkgarchive may contain -# duplicates of files within the source hierarchy). - -# Directories to exclude. -CS_PRUNE_STD = $(SCM_DIRS) \ - -o -name '.del-*' \ - -o -name '*demo' \ - -o -name pkgarchive - -CS_PRUNE = $(CS_PRUNE_STD) \ - $(CS_PRUNE_OS) \ - $(CS_PRUNE_CPU) \ - $(CS_PRUNE_GENERATED) \ - $(RMCCHEADERS) - -# File names to include. -CSFILENAMES = -name '*.[ch]pp' \ - -o -name '*.[Ccshlxy]' \ - $(CS_ADD_GENERATED) \ - -o -name '*.il' \ - -o -name '*.cc' \ - -o -name '*[Mm]akefile*' \ - -o -name '*.gmk' \ - -o -name '*.make' \ - -o -name '*.ad' \ - $(ADDCLASSES) - -.PRECIOUS: cscope.out - -cscope cscope.out: cscope.files FORCE - $(CSCOPE) $(CSCOPE_FLAGS) - -# The .raw file is reordered here in an attempt to make cscope display the most -# relevant files first. -cscope.files: .cscope.files.raw - echo "$(CSINCS)" > $@ - -egrep -v "\.java|\/make\/" $< >> $@ - -fgrep ".java" $< >> $@ - -fgrep "/make/" $< >> $@ - -.cscope.files.raw: .nametable.files - -find $(CSDIRS) -type d \( $(CS_PRUNE) \) -prune -o \ - -type f \( $(CSFILENAMES) \) -print > $@ - -cscope.clean: nametable.clean - -$(RM) cscope.out cscope.files .cscope.files.raw - -TAGS: cscope.files FORCE - egrep -v '^-|^$$' $< | etags --members - - -TAGS.clean: nametable.clean - -$(RM) TAGS - -# .nametable.files and .nametable.files.tmp are used to determine if any files -# were added to/deleted from/renamed in the workspace. If not, then there's -# normally no need to rebuild the cscope database. To force a rebuild of -# the cscope database: gmake nametable.clean. -.nametable.files: .nametable.files.tmp - ( cmp -s $@ $< ) || ( cp $< $@ ) - -$(RM) $< - -# `hg status' is slightly faster than `hg fstatus'. Both are -# quite a bit slower on an NFS mounted file system, so this is -# really geared towards repos on local file systems. -.nametable.files.tmp: - -$(HG) fstatus -acmn > $@ -nametable.clean: - -$(RM) .nametable.files .nametable.files.tmp - -FORCE: - -.PHONY: cscope cscope.clean TAGS.clean nametable.clean FORCE diff --git a/hotspot/make/bsd/makefiles/debug.make b/hotspot/make/bsd/makefiles/debug.make deleted file mode 100644 index 1c4ef1418b1..00000000000 --- a/hotspot/make/bsd/makefiles/debug.make +++ /dev/null @@ -1,45 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making debug version of VM - -# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make -DEBUG_CFLAGS/DEFAULT= $(DEBUG_CFLAGS) -DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@)) - -# _NMT_NOINLINE_ informs NMT that no inlining by Compiler -CFLAGS += $(DEBUG_CFLAGS/BYFILE) -D_NMT_NOINLINE_ - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# Linker mapfile -MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug -ifeq ($(OS_VENDOR), Darwin) -MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-darwin-debug -endif - -VERSION = debug -SYSDEFS += -DASSERT -PICFLAGS = DEFAULT diff --git a/hotspot/make/bsd/makefiles/defs.make b/hotspot/make/bsd/makefiles/defs.make deleted file mode 100644 index 795bf57db00..00000000000 --- a/hotspot/make/bsd/makefiles/defs.make +++ /dev/null @@ -1,382 +0,0 @@ -# -# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# The common definitions for hotspot bsd builds. -# Include the top level defs.make under make directory instead of this one. -# This file is included into make/defs.make. - -SLASH_JAVA ?= /java - -define print_info - ifneq ($$(LOG_LEVEL), warn) - $$(shell echo >&2 "INFO: $1") - endif -endef - -# Need PLATFORM (os-arch combo names) for jdk and hotspot, plus libarch name -ARCH:=$(shell uname -m) -PATH_SEP = : -ifeq ($(LP64), 1) - ARCH_DATA_MODEL ?= 64 -else - ARCH_DATA_MODEL ?= 32 -endif - -# zero -ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - ifeq ($(ARCH_DATA_MODEL), 64) - MAKE_ARGS += LP64=1 - endif - PLATFORM = bsd-zero - VM_PLATFORM = bsd_$(subst i386,i486,$(ZERO_LIBARCH)) - HS_ARCH = zero - ARCH = zero -endif - -# ia64 -ifeq ($(ARCH), ia64) - ARCH_DATA_MODEL = 64 - MAKE_ARGS += LP64=1 - PLATFORM = bsd-ia64 - VM_PLATFORM = bsd_ia64 - HS_ARCH = ia64 -endif - -# sparc -ifeq ($(ARCH), sparc64) - ifeq ($(ARCH_DATA_MODEL), 64) - ARCH_DATA_MODEL = 64 - MAKE_ARGS += LP64=1 - PLATFORM = bsd-sparcv9 - VM_PLATFORM = bsd_sparcv9 - else - ARCH_DATA_MODEL = 32 - PLATFORM = bsd-sparc - VM_PLATFORM = bsd_sparc - endif - HS_ARCH = sparc -endif - -# amd64 -ifneq (,$(findstring $(ARCH), amd64 x86_64)) - ifeq ($(ARCH_DATA_MODEL), 64) - ARCH_DATA_MODEL = 64 - MAKE_ARGS += LP64=1 - PLATFORM = bsd-amd64 - VM_PLATFORM = bsd_amd64 - HS_ARCH = x86 - else - ARCH_DATA_MODEL = 32 - PLATFORM = bsd-i586 - VM_PLATFORM = bsd_i486 - HS_ARCH = x86 - # We have to reset ARCH to i386 since SRCARCH relies on it - ARCH = i386 - endif -endif - -# i386 -ifeq ($(ARCH), i386) - ifeq ($(ARCH_DATA_MODEL), 64) - ARCH_DATA_MODEL = 64 - MAKE_ARGS += LP64=1 - PLATFORM = bsd-amd64 - VM_PLATFORM = bsd_amd64 - HS_ARCH = x86 - # We have to reset ARCH to amd64 since SRCARCH relies on it - ARCH = amd64 - else - ARCH_DATA_MODEL = 32 - PLATFORM = bsd-i586 - VM_PLATFORM = bsd_i486 - HS_ARCH = x86 - endif -endif - -# ARM -ifeq ($(ARCH), arm) - ARCH_DATA_MODEL = 32 - PLATFORM = bsd-arm - VM_PLATFORM = bsd_arm - HS_ARCH = arm -endif - -# PPC -ifeq ($(ARCH), ppc) - ARCH_DATA_MODEL = 32 - PLATFORM = bsd-ppc - VM_PLATFORM = bsd_ppc - HS_ARCH = ppc -endif - -# On 32 bit bsd we build server and client, on 64 bit just server. -ifeq ($(JVM_VARIANTS),) - ifeq ($(ARCH_DATA_MODEL), 32) - JVM_VARIANTS:=client,server - JVM_VARIANT_CLIENT:=true - JVM_VARIANT_SERVER:=true - else - JVM_VARIANTS:=server - JVM_VARIANT_SERVER:=true - endif -endif - -OS_VENDOR:=$(shell uname -s) - -# The Full Debug Symbols (FDS) default for BUILD_FLAVOR == product -# builds is enabled with debug info files ZIP'ed to save space. For -# BUILD_FLAVOR != product builds, FDS is always enabled, after all a -# debug build without debug info isn't very useful. -# The ZIP_DEBUGINFO_FILES option only has meaning when FDS is enabled. -# -# If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be -# disabled for a BUILD_FLAVOR == product build. -# -# Note: Use of a different variable name for the FDS override option -# versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS -# versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass -# in options via environment variables, use of distinct variables -# prevents strange behaviours. For example, in a BUILD_FLAVOR != -# product build, the FULL_DEBUG_SYMBOLS environment variable will be -# 0, but the ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If -# the same variable name is used, then different values can be picked -# up by different parts of the build. Just to be clear, we only need -# two variable names because the incoming option value can be -# overridden in some situations, e.g., a BUILD_FLAVOR != product -# build. - -# Due to the multiple sub-make processes that occur this logic gets -# executed multiple times. We reduce the noise by at least checking that -# BUILD_FLAVOR has been set. -ifneq ($(BUILD_FLAVOR),) - # FULL_DEBUG_SYMBOLS not created for individual static libraries - ifeq ($(STATIC_BUILD),false) - ifeq ($(BUILD_FLAVOR), product) - FULL_DEBUG_SYMBOLS ?= 1 - ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) - else - # debug variants always get Full Debug Symbols (if available) - ENABLE_FULL_DEBUG_SYMBOLS = 1 - endif - endif - $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")) - # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later - - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(OS_VENDOR), Darwin) - # MacOS X doesn't use OBJCOPY or STRIP_POLICY - OBJCOPY= - STRIP_POLICY= - ZIP_DEBUGINFO_FILES ?= 1 - else - # Default OBJCOPY comes from GNU Binutils on BSD - ifeq ($(CROSS_COMPILE_ARCH),) - DEF_OBJCOPY=/usr/bin/objcopy - else - # Assume objcopy is part of the cross-compilation toolset - ifneq ($(ALT_COMPILER_PATH),) - DEF_OBJCOPY=$(ALT_COMPILER_PATH)/objcopy - endif - endif - OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY)) - ifneq ($(ALT_OBJCOPY),) - $(eval $(call print_info, "ALT_OBJCOPY=$(ALT_OBJCOPY)")) - OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY)) - endif - - ifeq ($(OBJCOPY),) - $(eval $(call print_info, "no objcopy cmd found so cannot create .debuginfo" \ - "files. You may need to set ALT_OBJCOPY.")) - ENABLE_FULL_DEBUG_SYMBOLS=0 - $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")) - else - $(eval $(call print_info, "$(OBJCOPY) cmd found so will create .debuginfo" \ - "files.")) - - # Library stripping policies for .debuginfo configs: - # all_strip - strips everything from the library - # min_strip - strips most stuff from the library; leaves - # minimum symbols - # no_strip - does not strip the library at all - # - # Oracle security policy requires "all_strip". A waiver was - # granted on 2011.09.01 that permits using "min_strip" in the - # Java JDK and Java JRE. - # - # Currently, STRIP_POLICY is only used when Full Debug Symbols - # is enabled. - # - STRIP_POLICY ?= min_strip - - $(eval $(call print_info, "STRIP_POLICY=$(STRIP_POLICY)")) - - ZIP_DEBUGINFO_FILES ?= 1 - endif - - $(eval $(call print_info, "ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")) - endif - endif # ENABLE_FULL_DEBUG_SYMBOLS=1 -endif # BUILD_FLAVOR - -JDK_INCLUDE_SUBDIR=bsd - -# Library suffix -ifneq ($(STATIC_BUILD),true) -ifeq ($(OS_VENDOR),Darwin) - LIBRARY_SUFFIX=dylib -else - LIBRARY_SUFFIX=so -endif -else - LIBRARY_SUFFIX=a -endif - - -EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html - -# jsig library not needed for static builds -ifneq ($(STATIC_BUILD),true) - # client and server subdirectories have symbolic links to ../libjsig.so - EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX) -endif - -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.diz - else - ifeq ($(OS_VENDOR), Darwin) - EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX).dSYM - else - EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.debuginfo - endif - endif -endif - -EXPORT_SERVER_DIR = $(EXPORT_LIB_ARCH_DIR)/server -EXPORT_CLIENT_DIR = $(EXPORT_LIB_ARCH_DIR)/client -EXPORT_MINIMAL_DIR = $(EXPORT_LIB_ARCH_DIR)/minimal - -ifeq ($(findstring true, $(JVM_VARIANT_SERVER) $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX) - ifeq ($(STATIC_BUILD),true) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.symbols - endif - - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.diz - else - ifeq ($(OS_VENDOR), Darwin) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX).dSYM - else - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo - endif - endif - endif -endif - -ifeq ($(JVM_VARIANT_CLIENT),true) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX) - ifeq ($(STATIC_BUILD),true) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.symbols - endif - - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.diz - else - ifeq ($(OS_VENDOR), Darwin) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX).dSYM - else - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo - endif - endif - endif -endif - -ifeq ($(JVM_VARIANT_MINIMAL1),true) - EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.$(LIBRARY_SUFFIX) - ifeq ($(STATIC_BUILD),true) - EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.symbols - endif -endif - -# Universal build settings -ifeq ($(OS_VENDOR), Darwin) - # Build universal binaries by default on Mac OS X - MACOSX_UNIVERSAL = true - ifneq ($(ALT_MACOSX_UNIVERSAL),) - MACOSX_UNIVERSAL = $(ALT_MACOSX_UNIVERSAL) - endif - MAKE_ARGS += MACOSX_UNIVERSAL=$(MACOSX_UNIVERSAL) - - # Universal settings - ifeq ($(MACOSX_UNIVERSAL), true) - - # Set universal export path but avoid using ARCH or PLATFORM subdirs - EXPORT_PATH=$(OUTPUTDIR)/export-universal$(EXPORT_SUBDIR) - ifneq ($(ALT_EXPORT_PATH),) - EXPORT_PATH=$(ALT_EXPORT_PATH) - endif - - # Set universal image dir - JDK_IMAGE_DIR=$(OUTPUTDIR)/jdk-universal$(EXPORT_SUBDIR) - ifneq ($(ALT_JDK_IMAGE_DIR),) - JDK_IMAGE_DIR=$(ALT_JDK_IMAGE_DIR) - endif - - # Binaries to 'universalize' if built - ifneq ($(STATIC_BUILD),true) - UNIVERSAL_LIPO_LIST += $(EXPORT_LIB_DIR)/libjsig.$(LIBRARY_SUFFIX) - endif - UNIVERSAL_LIPO_LIST += $(EXPORT_LIB_DIR)/server/libjvm.$(LIBRARY_SUFFIX) - UNIVERSAL_LIPO_LIST += $(EXPORT_LIB_DIR)/client/libjvm.$(LIBRARY_SUFFIX) - - # Files to simply copy in place - UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/server/Xusage.txt - UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/client/Xusage.txt - - ifeq ($(STATIC_BUILD),true) - UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/server/libjvm.symbols - UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/client/libjvm.symbols - UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/minimal/libjvm.symbols - endif - - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/server/libjvm.diz - UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/client/libjvm.diz - UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/libjsig.diz - else - UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/server/libjvm.$(LIBRARY_SUFFIX).dSYM - UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/client/libjvm.$(LIBRARY_SUFFIX).dSYM - UNIVERSAL_COPY_LIST += $(EXPORT_LIB_DIR)/libjsig.$(LIBRARY_SUFFIX).dSYM - endif - endif - - endif -endif diff --git a/hotspot/make/bsd/makefiles/dtrace.make b/hotspot/make/bsd/makefiles/dtrace.make deleted file mode 100644 index e2af31ea7a0..00000000000 --- a/hotspot/make/bsd/makefiles/dtrace.make +++ /dev/null @@ -1,333 +0,0 @@ -# -# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Rules to build jvm_db/dtrace, used by vm.make - -# We build libjvm_dtrace/libjvm_db/dtrace for COMPILER1 and COMPILER2 -# but not for CORE configuration. - -ifneq ("${TYPE}", "CORE") - -ifeq ($(OS_VENDOR), Darwin) -# we build dtrace for macosx using USDT2 probes - -DtraceOutDir = $(GENERATED)/dtracefiles - -# Bsd does not build libjvm_db, does not compile on macosx -# disabled in build: rule in vm.make -JVM_DB = libjvm_db -LIBJVM_DB = libjvm_db.$(LIBRARY_SUFFIX) - -LIBJVM_DB_DEBUGINFO = libjvm_db.$(LIBRARY_SUFFIX).dSYM -LIBJVM_DB_DIZ = libjvm_db.diz - -JVM_DTRACE = jvm_dtrace -LIBJVM_DTRACE = libjvm_dtrace.$(LIBRARY_SUFFIX) - -LIBJVM_DTRACE_DEBUGINFO = libjvm_dtrace.$(LIBRARY_SUFFIX).dSYM -LIBJVM_DTRACE_DIZ = libjvm_dtrace.diz - -JVMOFFS = JvmOffsets -JVMOFFS.o = $(JVMOFFS).o -GENOFFS = generate$(JVMOFFS) - -DTRACE_SRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/dtrace -DTRACE_COMMON_SRCDIR = $(GAMMADIR)/src/os/posix/dtrace -DTRACE = dtrace -DTRACE.o = $(DTRACE).o - -# to remove '-g' option which causes link problems -# also '-z nodefs' is used as workaround -GENOFFS_CFLAGS = $(shell echo $(CFLAGS) | sed -e 's/ -g / /g' -e 's/ -g0 / /g';) - -ifdef LP64 -DTRACE_OPTS = -D_LP64 -endif - -# making libjvm_db - -# Use mapfile with libjvm_db.so -LIBJVM_DB_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_db - -# Use mapfile with libjvm_dtrace.so -LIBJVM_DTRACE_MAPFILE = # no mapfile for usdt2 # $(MAKEFILES_DIR)/mapfile-vers-jvm_dtrace - -LFLAGS_JVM_DB += $(PICFLAG) # -D_REENTRANT -LFLAGS_JVM_DTRACE += $(PICFLAG) # -D_REENTRANT - -ISA = $(subst i386,i486,$(BUILDARCH)) - -# Making 64/libjvm_db.so: 64-bit version of libjvm_db.so which handles 32-bit libjvm.so -ifneq ("${ISA}","${BUILDARCH}") - -XLIBJVM_DIR = 64 -XLIBJVM_DB = $(XLIBJVM_DIR)/$(LIBJVM_DB) -XLIBJVM_DTRACE = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE) -XARCH = $(subst sparcv9,v9,$(shell echo $(ISA))) - -XLIBJVM_DB_DEBUGINFO = $(XLIBJVM_DIR)/$(LIBJVM_DB_DEBUGINFO) -XLIBJVM_DB_DIZ = $(XLIBJVM_DIR)/$(LIBJVM_DB_DIZ) -XLIBJVM_DTRACE_DEBUGINFO = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE_DEBUGINFO) -XLIBJVM_DTRACE_DIZ = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE_DIZ) - -$(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE) - @echo $(LOG_INFO) Making $@ - $(QUIETLY) mkdir -p $(XLIBJVM_DIR) ; \ - $(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. -I$(GENERATED) \ - $(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c #-lc -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(OS_VENDOR), Darwin) - $(DSYMUTIL) $@ - ifeq ($(ZIP_DEBUGINFO_FILES),1) - # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) - # is not in the archived name: - ( cd $(XLIBJVM_DIR) && $(ZIPEXE) -q -r -y $(LIBJVM_DB_DIZ) $(LIBJVM_DB_DEBUGINFO) ) - $(RM) -r $(XLIBJVM_DB_DEBUGINFO) - endif - else - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DB_DEBUGINFO) - # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) - # is not in the link name: - $(QUIETLY) ( cd $(XLIBJVM_DIR) && $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $(LIBJVM_DB) ) - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -x $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) - # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) - # is not in the archived name: - ( cd $(XLIBJVM_DIR) && $(ZIPEXE) -q -y $(LIBJVM_DB_DIZ) $(LIBJVM_DB_DEBUGINFO) ) - $(RM) $(XLIBJVM_DB_DEBUGINFO) - endif - endif -endif - -$(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE) - @echo $(LOG_INFO) Making $@ - $(QUIETLY) mkdir -p $(XLIBJVM_DIR) ; \ - $(CC) $(SYMFLAG) -xarch=$(XARCH) -D$(TYPE) -I. \ - $(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(OS_VENDOR), Darwin) - $(DSYMUTIL) $@ - ifeq ($(ZIP_DEBUGINFO_FILES),1) - # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) - # is not in the archived name: - ( cd $(XLIBJVM_DIR) && $(ZIPEXE) -q -r -y $(LIBJVM_DTRACE_DIZ) $(LIBJVM_DTRACE_DEBUGINFO) ) - $(RM) -r $(XLIBJVM_DTRACE_DEBUGINFO) - endif - else - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DTRACE_DEBUGINFO) - # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) - # is not in the link name: - ( cd $(XLIBJVM_DIR) && $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $(LIBJVM_DTRACE) ) - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -x $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) - # Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) - # is not in the archived name: - ( cd $(XLIBJVM_DIR) && $(ZIPEXE) -q -y $(LIBJVM_DTRACE_DIZ) $(LIBJVM_DTRACE_DEBUGINFO) ) - $(RM) $(XLIBJVM_DTRACE_DEBUGINFO) - endif - endif -endif - -endif # ifneq ("${ISA}","${BUILDARCH}") - -LFLAGS_GENOFFS += -L. - -lib$(GENOFFS).$(LIBRARY_SUFFIX): $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \ - $(LIBJVM.o) - $(QUIETLY) $(CXX) $(CXXFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \ - $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -ljvm - -$(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).$(LIBRARY_SUFFIX) - $(QUIETLY) $(LINK.CXX) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \ - ./lib$(GENOFFS).$(LIBRARY_SUFFIX) - -# $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs. -$(JVMOFFS).h: $(GENOFFS) - $(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -header > $@.tmp; touch $@; \ - if diff $@.tmp $@ > /dev/null 2>&1 ; \ - then rm -f $@.tmp; \ - else rm -f $@; mv $@.tmp $@; \ - fi - -$(JVMOFFS)Index.h: $(GENOFFS) - $(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -index > $@.tmp; touch $@; \ - if diff $@.tmp $@ > /dev/null 2>&1 ; \ - then rm -f $@.tmp; \ - else rm -f $@; mv $@.tmp $@; \ - fi - -$(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h - $(QUIETLY) DYLD_LIBRARY_PATH=.:$(DYLD_LIBRARY_PATH) ./$(GENOFFS) -table > $@.tmp; touch $@; \ - if diff $@.tmp $@ > /dev/null 2>&1; \ - then rm -f $@.tmp; \ - else rm -f $@; mv $@.tmp $@; \ - fi - -$(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp - $(QUIETLY) $(CXX) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp - -$(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE) - @echo $(LOG_INFO) Making $@ - $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \ - $(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -Wall # -lc -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(OS_VENDOR), Darwin) - $(DSYMUTIL) $@ - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -r -y $(LIBJVM_DB_DIZ) $(LIBJVM_DB_DEBUGINFO) - $(RM) -r $(LIBJVM_DB_DEBUGINFO) - endif - else - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DB_DEBUGINFO) - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $@ - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -x $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -y $(LIBJVM_DB_DIZ) $(LIBJVM_DB_DEBUGINFO) - $(RM) $(LIBJVM_DB_DEBUGINFO) - endif - endif -endif - -$(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE) - @echo $(LOG_INFO) Making $@ - $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. \ - $(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c #-lc -lthread -ldoor -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(OS_VENDOR), Darwin) - $(DSYMUTIL) $@ - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -r -y $(LIBJVM_DTRACE_DIZ) $(LIBJVM_DTRACE_DEBUGINFO) - $(RM) -r $(LIBJVM_DTRACE_DEBUGINFO) - endif - else - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DTRACE_DEBUGINFO) - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $@ - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -x $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -y $(LIBJVM_DTRACE_DIZ) $(LIBJVM_DTRACE_DEBUGINFO) - $(RM) $(LIBJVM_DTRACE_DEBUGINFO) - endif - endif -endif - - -$(DtraceOutDir): - mkdir $(DtraceOutDir) - -# When building using a devkit, dtrace cannot find the correct preprocessor so -# we run it explicitly before runing dtrace. -$(DtraceOutDir)/hotspot.h: $(DTRACE_COMMON_SRCDIR)/hotspot.d | $(DtraceOutDir) - $(QUIETLY) $(CC) -E $(DTRACE_OPTS) -I. -x c $(DTRACE_COMMON_SRCDIR)/hotspot.d > $(DtraceOutDir)/hotspot.d - $(QUIETLY) $(DTRACE_PROG) -h -o $@ -s $(DtraceOutDir)/hotspot.d - -$(DtraceOutDir)/hotspot_jni.h: $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d | $(DtraceOutDir) - $(QUIETLY) $(CC) -E $(DTRACE_OPTS) -I. -x c $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d > $(DtraceOutDir)/hotspot_jni.d - $(QUIETLY) $(DTRACE_PROG) -h -o $@ -s $(DtraceOutDir)/hotspot_jni.d - -$(DtraceOutDir)/hs_private.h: $(DTRACE_COMMON_SRCDIR)/hs_private.d | $(DtraceOutDir) - $(QUIETLY) $(CC) -E $(DTRACE_OPTS) -I. -x c $(DTRACE_COMMON_SRCDIR)/hs_private.d > $(DtraceOutDir)/hs_private.d - $(QUIETLY) $(DTRACE_PROG) -h -o $@ -s $(DtraceOutDir)/hs_private.d - -dtrace_gen_headers: $(DtraceOutDir)/hotspot.h $(DtraceOutDir)/hotspot_jni.h $(DtraceOutDir)/hs_private.h - - -.PHONY: dtraceCheck - -SYSTEM_DTRACE_PROG = /usr/sbin/dtrace -systemDtraceFound := $(wildcard ${SYSTEM_DTRACE_PROG}) - -ifneq ("$(systemDtraceFound)", "") -DTRACE_PROG=$(SYSTEM_DTRACE_PROG) -else - -endif - -ifneq ("${DTRACE_PROG}", "") -ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "") - -DTRACE_OBJS = $(DTRACE.o) #$(JVMOFFS.o) -CFLAGS += -DDTRACE_ENABLED #$(DTRACE_INCL) - - -dtraceCheck: - -dtrace_stuff: dtrace_gen_headers - $(QUIETLY) echo $(LOG_INFO) "dtrace headers generated" - - -else # manually disabled - -dtraceCheck: - $(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled via environment variable" - -dtrace_stuff: - -endif # ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "") - -else # No dtrace program found - -dtraceCheck: - $(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled: not supported by system" - -dtrace_stuff: - -endif # ifneq ("${dtraceFound}", "") - -endif # ifeq ($(OS_VENDOR), Darwin) - - -else # CORE build - -dtraceCheck: - $(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled for CORE builds" - -endif # ifneq ("${TYPE}", "CORE") diff --git a/hotspot/make/bsd/makefiles/fastdebug.make b/hotspot/make/bsd/makefiles/fastdebug.make deleted file mode 100644 index d57e545b5b0..00000000000 --- a/hotspot/make/bsd/makefiles/fastdebug.make +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making debug version of VM - -# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make -# They may also specify FASTDEBUG_CFLAGS, but it defaults to DEBUG_CFLAGS. - -FASTDEBUG_CFLAGS$(FASTDEBUG_CFLAGS) = $(DEBUG_CFLAGS) - -# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make -OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) -OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) - -# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files) - -# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings -CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# The following lines are copied from debug.make, except that we -# consult FASTDEBUG_CFLAGS instead of DEBUG_CFLAGS. -# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make -DEBUG_CFLAGS/DEFAULT= $(FASTDEBUG_CFLAGS) -DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@)) -CFLAGS += $(DEBUG_CFLAGS/BYFILE) - -# Linker mapfile -MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug -ifeq ($(OS_VENDOR), Darwin) -MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-darwin-debug -endif - -VERSION = fastdebug -SYSDEFS += -DASSERT -DCHECK_UNHANDLED_OOPS -PICFLAGS = DEFAULT diff --git a/hotspot/make/bsd/makefiles/gcc.make b/hotspot/make/bsd/makefiles/gcc.make deleted file mode 100644 index 1bf6521a892..00000000000 --- a/hotspot/make/bsd/makefiles/gcc.make +++ /dev/null @@ -1,543 +0,0 @@ -# -# Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -OS_VENDOR = $(shell uname -s) - -#------------------------------------------------------------------------ -# CC, CXX & AS - -# If a SPEC is not set already, then use these defaults. -ifeq ($(SPEC),) - # When cross-compiling the ALT_COMPILER_PATH points - # to the cross-compilation toolset - ifdef CROSS_COMPILE_ARCH - CXX = $(ALT_COMPILER_PATH)/g++ - CC = $(ALT_COMPILER_PATH)/gcc - HOSTCXX = g++ - HOSTCC = gcc - else ifneq ($(OS_VENDOR), Darwin) - CXX = g++ - CC = gcc - HOSTCXX = $(CXX) - HOSTCC = $(CC) - endif - - # i486 hotspot requires -mstackrealign on Darwin. - # llvm-gcc supports this in Xcode 3.2.6 and 4.0. - # gcc-4.0 supports this on earlier versions. - # Prefer llvm-gcc where available. - ifeq ($(OS_VENDOR), Darwin) - ifeq ($(origin CXX), default) - CXX = llvm-g++ - endif - ifeq ($(origin CC), default) - CC = llvm-gcc - endif - - ifeq ($(ARCH), i486) - LLVM_SUPPORTS_STACKREALIGN := $(shell \ - [ "0"`llvm-gcc -v 2>&1 | grep LLVM | sed -E "s/.*LLVM build ([0-9]+).*/\1/"` -gt "2333" ] \ - && echo true || echo false) - - ifeq ($(LLVM_SUPPORTS_STACKREALIGN), true) - CXX32 ?= llvm-g++ - CC32 ?= llvm-gcc - else - CXX32 ?= g++-4.0 - CC32 ?= gcc-4.0 - endif - CXX = $(CXX32) - CC = $(CC32) - endif - - ifeq ($(USE_CLANG), true) - CXX = clang++ - CC = clang - endif - - HOSTCXX = $(CXX) - HOSTCC = $(CC) - endif - - AS = $(CC) -c -endif - -ifeq ($(OS_VENDOR), Darwin) - ifeq ($(DSYMUTIL),) - DSYMUTIL=dsymutil - endif -endif - -ifeq ($(USE_CLANG), true) - CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1) - CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2) -else - # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only - # prints the numbers (e.g. "2.95", "3.2.1") - CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) - CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) - CC_VER_MICRO := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f3) -endif - -ifeq ($(USE_CLANG), true) - # Clang has precompiled headers support by default, but the user can switch - # it off by using 'USE_PRECOMPILED_HEADER=0'. - ifdef LP64 - ifeq ($(USE_PRECOMPILED_HEADER),) - USE_PRECOMPILED_HEADER=1 - endif - else - # We don't support precompiled headers on 32-bit builds because there some files are - # compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make) - # Clang produces an error if the PCH file was compiled with other options than the actual compilation unit. - USE_PRECOMPILED_HEADER=0 - endif - - ifeq ($(USE_PRECOMPILED_HEADER),1) - - ifndef LP64 - $(error " Precompiled Headers only supported on 64-bit platforms!") - endif - - PRECOMPILED_HEADER_DIR=. - PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp - PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch - - PCH_FLAG = -include precompiled.hpp - PCH_FLAG/DEFAULT = $(PCH_FLAG) - PCH_FLAG/NO_PCH = -DNO_PCH - PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@)) - - VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE) - VM_PCH_FLAG/AOUT = - VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO)) - - # We only use precompiled headers for the JVM build - CFLAGS += $(VM_PCH_FLAG) - - # The following files are compiled at various optimization - # levels due to optimization issues encountered at the - # 'OPT_CFLAGS_DEFAULT' level. The Clang compiler issues a compile - # time error if there is an optimization level specification - # skew between the PCH file and the C++ file. Especially if the - # PCH file is compiled at a higher optimization level than - # the C++ file. One solution might be to prepare extra optimization - # level specific PCH files for the opt build and use them here, but - # it's probably not worth the effort as long as only a few files - # need this special handling. - PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH) - PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH) - PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH) - PCH_FLAG/unsafe.o = $(PCH_FLAG/NO_PCH) - PCH_FLAG/jvmciCompilerToVM.o = $(PCH_FLAG/NO_PCH) - - endif -else # ($(USE_CLANG), true) - # check for precompiled headers support - ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0" - # Allow the user to turn off precompiled headers from the command line. - ifneq ($(USE_PRECOMPILED_HEADER),0) - PRECOMPILED_HEADER_DIR=. - PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp - PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch - endif - endif -endif - -# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. -ifeq ($(USE_PRECOMPILED_HEADER),0) - CFLAGS += -DDONT_USE_PRECOMPILED_HEADER -endif - -#------------------------------------------------------------------------ -# Compiler flags - -# position-independent code -PICFLAG = -fPIC - -VM_PICFLAG/LIBJVM = $(PICFLAG) -VM_PICFLAG/AOUT = -VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO)) - -ifeq ($(JVM_VARIANT_ZERO), true) - CFLAGS += $(LIBFFI_CFLAGS) -endif -ifeq ($(JVM_VARIANT_ZEROSHARK), true) - CFLAGS += $(LIBFFI_CFLAGS) - CFLAGS += $(LLVM_CFLAGS) -endif - -ifeq ($(STATIC_BUILD),true) -CXXFLAGS += -DSTATIC_BUILD -CFLAGS += -DSTATIC_BUILD -else -CFLAGS += $(VM_PICFLAG) -endif - -CFLAGS += -fno-rtti -CFLAGS += -fno-exceptions -ifeq ($(USE_CLANG),) - CFLAGS += -pthread - CFLAGS += -fcheck-new - # version 4 and above support fvisibility=hidden (matches jni_x86.h file) - # except 4.1.2 gives pointless warnings that can't be disabled (afaik) - ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" - CFLAGS += -fvisibility=hidden - endif -else - CFLAGS += -fvisibility=hidden -endif - -ifeq ($(USE_CLANG), true) - # Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm' - # Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment') - ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0" - STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16 - else - STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16 - endif -endif - -ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) -ARCHFLAG/i486 = -m32 -march=i586 -ARCHFLAG/amd64 = -m64 $(STACK_ALIGNMENT_OPT) -ARCHFLAG/ia64 = -ARCHFLAG/sparc = -m32 -mcpu=v9 -ARCHFLAG/sparcv9 = -m64 -mcpu=v9 -ARCHFLAG/zero = $(ZERO_ARCHFLAG) - -# Darwin-specific build flags -ifeq ($(OS_VENDOR), Darwin) - # Ineffecient 16-byte stack re-alignment on Darwin/IA32 - ARCHFLAG/i486 += -mstackrealign -endif - -CFLAGS += $(ARCHFLAG) -AOUT_FLAGS += $(ARCHFLAG) -LFLAGS += $(ARCHFLAG) -ASFLAGS += $(ARCHFLAG) - -ifdef E500V2 -CFLAGS += -DE500V2 -endif - -# Use C++ Interpreter -ifdef CC_INTERP - CFLAGS += -DCC_INTERP -endif - -# Keep temporary files (.ii, .s) -ifdef NEED_ASM - CFLAGS += -save-temps -else - CFLAGS += -pipe -endif - -# Compiler warnings are treated as errors -ifneq ($(COMPILER_WARNINGS_FATAL),false) - WARNINGS_ARE_ERRORS ?= -Werror -endif - -ifeq ($(USE_CLANG), true) - # However we need to clean the code up before we can unrestrictedly enable this option with Clang - WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses - WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-compare -# Not yet supported by clang in Xcode 4.6.2 -# WARNINGS_ARE_ERRORS += -Wno-tautological-constant-out-of-range-compare - WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess - WARNINGS_ARE_ERRORS += -Wno-empty-body -endif - -WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2 - -ifeq ($(USE_CLANG),) - # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit - # conversions which might affect the values. Only enable it in earlier versions. - ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" - WARNINGS_FLAGS += -Wconversion - endif -endif - -CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) -# Special cases -CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) -# XXXDARWIN: for _dyld_bind_fully_image_containing_address -ifeq ($(OS_VENDOR), Darwin) - CFLAGS_WARN/os_bsd.o = $(CFLAGS_WARN/DEFAULT) -Wno-deprecated-declarations -endif - -# optimization control flags (Used by fastdebug and release variants) -OPT_CFLAGS/NOOPT=-O0 -OPT_CFLAGS/DEBUG=-O0 -OPT_CFLAGS/SIZE=-Os -OPT_CFLAGS/SPEED=-O3 - -ifeq ($(OS_VENDOR), Darwin) - # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy - # - OPT_CFLAGS_DEFAULT ?= SIZE -else - OPT_CFLAGS_DEFAULT ?= SPEED -endif - -# Hotspot uses very unstrict aliasing turn this optimization off -# This option is added to CFLAGS rather than OPT_CFLAGS -# so that OPT_CFLAGS overrides get this option too. -CFLAGS += -fno-strict-aliasing - -ifdef OPT_CFLAGS - ifneq ("$(origin OPT_CFLAGS)", "command line") - $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.") - endif -endif - -OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS) - -# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp -# if we use expensive-optimizations -ifeq ($(BUILDARCH), ia64) -OPT_CFLAGS += -fno-expensive-optimizations -endif - -# Work around some compiler bugs. -ifeq ($(USE_CLANG), true) - # Clang < 6 | <= 6.1 | <= 7.0 - ifeq ($(shell expr \ - $(CC_VER_MAJOR) \< 6 \| \ - \( $(CC_VER_MAJOR) = 6 \& $(CC_VER_MINOR) \<= 1 \) \| \ - \( $(CC_VER_MAJOR) = 7 \& $(CC_VER_MINOR) \<= 0 \) \ - ), 1) - OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT) - OPT_CFLAGS/unsafe.o += -O1 - - # The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides - # of OPT_CFLAGS. Restore it here. - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS/loopTransform.o += -g - OPT_CFLAGS/unsafe.o += -g - endif - else - $(error "Update compiler workarounds for Clang $(CC_VER_MAJOR).$(CC_VER_MINOR)") - endif -else - # Do not allow GCC 4.1.1 - ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 1 \& $(CC_VER_MICRO) = 1), 1) - $(error "GCC $(CC_VER_MAJOR).$(CC_VER_MINOR).$(CC_VER_MICRO) not supported because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27724") - endif - # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. - ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1) - OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT) - endif -endif - -# Flags for generating make dependency flags. -DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) -ifeq ($(USE_CLANG),) - ifneq ($(CC_VER_MAJOR), 2) - DEPFLAGS += -fpch-deps - endif -endif - -# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. -ifeq ($(USE_PRECOMPILED_HEADER),0) -CFLAGS += -DDONT_USE_PRECOMPILED_HEADER -endif - -ifeq ($(OS_VENDOR), Darwin) - # Setting these parameters makes it an error to link to macosx APIs that are - # newer than the given OS version and makes the linked binaries compatible even - # if built on a newer version of the OS. - # The expected format is X.Y.Z - ifeq ($(MACOSX_VERSION_MIN),) - MACOSX_VERSION_MIN=10.7.0 - endif - # The macro takes the version with no dots, ex: 1070 - CFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=$(subst .,,$(MACOSX_VERSION_MIN)) \ - -mmacosx-version-min=$(MACOSX_VERSION_MIN) - LDFLAGS += -mmacosx-version-min=$(MACOSX_VERSION_MIN) -endif - - -#------------------------------------------------------------------------ -# Assembler flags - -# Enforce prerpocessing of .s files -ASFLAGS += -x assembler-with-cpp - -#------------------------------------------------------------------------ -# Linker flags - -# statically link libstdc++.so, work with gcc but ignored by g++ -STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic - -# Ensure use libstdc++ on clang, not libc++ -ifeq ($(USE_CLANG), true) - LFLAGS += -stdlib=libstdc++ -endif - -ifeq ($(USE_CLANG),) - # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. - ifneq ($(CC_VER_MAJOR), 2) - STATIC_LIBGCC += -static-libgcc - endif - - ifneq ($(OS_VENDOR), Darwin) - ifneq (, findstring(debug,$(BUILD_FLAVOR))) - # for relocations read-only - LFLAGS += -Xlinker -z -Xlinker relro - - ifeq ($(BUILD_FLAVOR), debug) - # disable incremental relocations linking - LFLAGS += -Xlinker -z -Xlinker now - endif - endif - endif - - ifeq ($(BUILDARCH), ia64) - LFLAGS += -Wl,-relax - endif -endif - -# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. -MAPFLAG = -Xlinker --version-script=FILENAME - -# -# Shared Library -# -ifeq ($(OS_VENDOR), Darwin) - # Standard linker flags - LFLAGS += - - # The apple linker has its own variant of mapfiles/version-scripts - MAPFLAG = -Xlinker -exported_symbols_list -Xlinker FILENAME - - # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj - SONAMEFLAG = - - # Build shared library - SHARED_FLAG = -Wl,-install_name,@rpath/$(@F) -dynamiclib -compatibility_version 1.0.0 -current_version 1.0.0 $(VM_PICFLAG) - - # Keep symbols even they are not used - #AOUT_FLAGS += -Xlinker -export-dynamic -else - # Enable linker optimization - LFLAGS += -Xlinker -O1 - - # Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj - SONAMEFLAG = -Xlinker -soname=SONAME - - # Build shared library - SHARED_FLAG = -shared $(VM_PICFLAG) - - # Keep symbols even they are not used - AOUT_FLAGS += -Xlinker -export-dynamic -endif - -#------------------------------------------------------------------------ -# Debug flags - -ifeq ($(USE_CLANG), true) - # Restrict the debug information created by Clang to avoid - # too big object files and speed the build up a little bit - # (see http://llvm.org/bugs/show_bug.cgi?id=7554) - CFLAGS += -flimit-debug-info -endif - -# Allow no optimizations. -DEBUG_CFLAGS=-O0 - -# DEBUG_BINARIES uses full -g debug information for all configs -ifeq ($(DEBUG_BINARIES), true) - CFLAGS += -g -else - # Use the stabs format for debugging information (this is the default - # on gcc-2.91). It's good enough, has all the information about line - # numbers and local variables, and libjvm.so is only about 16M. - # Change this back to "-g" if you want the most expressive format. - # (warning: that could easily inflate libjvm.so to 150M!) - # Note: The Itanium gcc compiler crashes when using -gstabs. - DEBUG_CFLAGS/ia64 = -g - DEBUG_CFLAGS/amd64 = -g - DEBUG_CFLAGS/arm = -g - DEBUG_CFLAGS/ppc = -g - DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) - ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) - ifeq ($(USE_CLANG), true) - # Clang doesn't understand -gstabs - DEBUG_CFLAGS += -g - else - DEBUG_CFLAGS += -gstabs - endif - endif - - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - FASTDEBUG_CFLAGS/ia64 = -g - FASTDEBUG_CFLAGS/amd64 = -g - FASTDEBUG_CFLAGS/arm = -g - FASTDEBUG_CFLAGS/ppc = -g - FASTDEBUG_CFLAGS += $(FASTDEBUG_CFLAGS/$(BUILDARCH)) - ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),) - ifeq ($(USE_CLANG), true) - # Clang doesn't understand -gstabs - FASTDEBUG_CFLAGS += -g - else - FASTDEBUG_CFLAGS += -gstabs - endif - endif - - OPT_CFLAGS/ia64 = -g - OPT_CFLAGS/amd64 = -g - OPT_CFLAGS/arm = -g - OPT_CFLAGS/ppc = -g - OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH)) - ifeq ($(OPT_CFLAGS/$(BUILDARCH)),) - ifeq ($(USE_CLANG), true) - # Clang doesn't understand -gstabs - OPT_CFLAGS += -g - else - OPT_CFLAGS += -gstabs - endif - endif - endif -endif - -ifeq ($(USE_CLANG),) - # Enable bounds checking. - ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "1" - # stack smashing checks. - DEBUG_CFLAGS += -fstack-protector-all --param ssp-buffer-size=1 - endif -endif - -# If we are building HEADLESS, pass on to VM -# so it can set the java.awt.headless property -ifdef HEADLESS -CFLAGS += -DHEADLESS -endif - -# We are building Embedded for a small device -# favor code space over speed -ifdef MINIMIZE_RAM_USAGE -CFLAGS += -DMINIMIZE_RAM_USAGE -endif diff --git a/hotspot/make/bsd/makefiles/hp.make b/hotspot/make/bsd/makefiles/hp.make deleted file mode 100644 index e0b262a8fa2..00000000000 --- a/hotspot/make/bsd/makefiles/hp.make +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making premium version of VM - -TYPE=HP - -CFLAGS += -DCOMPILER2 diff --git a/hotspot/make/bsd/makefiles/hp1.make b/hotspot/make/bsd/makefiles/hp1.make deleted file mode 100644 index 2e37a6ead33..00000000000 --- a/hotspot/make/bsd/makefiles/hp1.make +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making premium version of VM - -TYPE=HP1 - -CFLAGS += -DCOMPILER1 diff --git a/hotspot/make/bsd/makefiles/i486.make b/hotspot/make/bsd/makefiles/i486.make deleted file mode 100644 index 86e825d3e9d..00000000000 --- a/hotspot/make/bsd/makefiles/i486.make +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# TLS helper, assembled from .s file - -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT) -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT) -# Must also specify if CPU is little endian -CFLAGS += -DVM_LITTLE_ENDIAN - -OPT_CFLAGS/compactingPermGenGen.o = -O1 diff --git a/hotspot/make/bsd/makefiles/ia64.make b/hotspot/make/bsd/makefiles/ia64.make deleted file mode 100644 index 8535807a787..00000000000 --- a/hotspot/make/bsd/makefiles/ia64.make +++ /dev/null @@ -1,41 +0,0 @@ -# -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# -# IA64 only uses c++ based interpreter -CFLAGS += -DCC_INTERP -D_LP64=1 -DVM_LITTLE_ENDIAN -ifeq ($(VERSION),debug) -ASM_FLAGS= -DDEBUG -else -ASM_FLAGS= -endif -# workaround gcc bug in compiling varargs -OPT_CFLAGS/jni.o = -O0 - -# gcc/ia64 has a bug that internal gcc functions linked with libjvm.so -# are made public. Hiding those symbols will cause undefined symbol error -# when VM is dropped into older JDK. We probably will need an IA64 -# mapfile to include those symbols as a workaround. Disable linker mapfile -# for now. -LDNOMAP=true diff --git a/hotspot/make/bsd/makefiles/jsig.make b/hotspot/make/bsd/makefiles/jsig.make deleted file mode 100644 index 585a0f45ba9..00000000000 --- a/hotspot/make/bsd/makefiles/jsig.make +++ /dev/null @@ -1,110 +0,0 @@ -# -# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Rules to build signal interposition library, used by vm.make - -# libjsig.so: signal interposition library -JSIG = jsig - -ifeq ($(OS_VENDOR), Darwin) - LIBJSIG = lib$(JSIG).$(LIBRARY_SUFFIX) - - LIBJSIG_DEBUGINFO = lib$(JSIG).$(LIBRARY_SUFFIX).dSYM - LIBJSIG_DIZ = lib$(JSIG).diz -else - LIBJSIG = lib$(JSIG).so - - LIBJSIG_DEBUGINFO = lib$(JSIG).debuginfo - LIBJSIG_DIZ = lib$(JSIG).diz -endif - -JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm - -DEST_JSIG = $(JDK_LIBDIR)/$(LIBJSIG) -DEST_JSIG_DEBUGINFO = $(JDK_LIBDIR)/$(LIBJSIG_DEBUGINFO) -DEST_JSIG_DIZ = $(JDK_LIBDIR)/$(LIBJSIG_DIZ) - -LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig - -# On Bsd we really dont want a mapfile, as this library is small -# and preloaded using LD_PRELOAD, making functions private will -# cause problems with interposing. See CR: 6466665 -# LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE)) - -LFLAGS_JSIG += -D_GNU_SOURCE -pthread $(LDFLAGS_HASH_STYLE) - -# DEBUG_BINARIES overrides everything, use full -g debug information -ifeq ($(DEBUG_BINARIES), true) - JSIG_DEBUG_CFLAGS = -g -endif - -$(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE) - @echo $(LOG_INFO) Making signal interposition lib... -ifeq ($(STATIC_BUILD),true) - $(QUIETLY) $(CC) -c $(SYMFLAG) $(EXTRA_CFLAGS) $(ARCHFLAG) $(PICFLAG) \ - $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) -o $(JSIG).o $< - $(QUIETLY) $(AR) $(ARFLAGS) $@ $(JSIG).o -else - $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \ - $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) $(EXTRA_CFLAGS) -o $@ $< -endif -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(OS_VENDOR), Darwin) - $(DSYMUTIL) $@ - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -r -y $(LIBJSIG_DIZ) $(LIBJSIG_DEBUGINFO) - $(RM) -r $(LIBJSIG_DEBUGINFO) - endif - else - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO) - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@ - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -g $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -y $(LIBJSIG_DIZ) $(LIBJSIG_DEBUGINFO) - $(RM) $(LIBJSIG_DEBUGINFO) - endif - endif -endif - -install_jsig: $(LIBJSIG) - @echo "Copying $(LIBJSIG) to $(DEST_JSIG)" -ifeq ($(OS_VENDOR), Darwin) - $(QUIETLY) test ! -d $(LIBJSIG_DEBUGINFO) || \ - $(CP) -f -r $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO) -else - $(QUIETLY) test ! -f $(LIBJSIG_DEBUGINFO) || \ - $(CP) -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO) -endif - $(QUIETLY) test ! -f $(LIBJSIG_DIZ) || \ - $(CP) -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ) - $(QUIETLY) $(CP) -f $(LIBJSIG) $(DEST_JSIG) && echo "Done" - -.PHONY: install_jsig diff --git a/hotspot/make/bsd/makefiles/jvmti.make b/hotspot/make/bsd/makefiles/jvmti.make deleted file mode 100644 index cb22c2b0f4d..00000000000 --- a/hotspot/make/bsd/makefiles/jvmti.make +++ /dev/null @@ -1,116 +0,0 @@ -# -# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (jvmti.make) is included from the jvmti.make in the -# build directories. -# -# It knows how to build and run the tools to generate jvmti. - -include $(GAMMADIR)/make/bsd/makefiles/rules.make - -# ######################################################################### - -TOPDIR = $(shell echo `pwd`) -GENERATED = $(TOPDIR)/../generated -JvmtiOutDir = $(GENERATED)/jvmtifiles - -JvmtiSrcDir = $(GAMMADIR)/src/share/vm/prims -InterpreterSrcDir = $(GAMMADIR)/src/share/vm/interpreter - -# set VPATH so make knows where to look for source files -Src_Dirs_V += $(JvmtiSrcDir) -VPATH += $(Src_Dirs_V:%=%:) - -JvmtiGeneratedNames = \ - jvmtiEnv.hpp \ - jvmtiEnter.cpp \ - jvmtiEnterTrace.cpp \ - jvmtiEnvRecommended.cpp \ - bytecodeInterpreterWithChecks.cpp \ - jvmti.h \ - -JvmtiEnvFillSource = $(JvmtiSrcDir)/jvmtiEnvFill.java -JvmtiEnvFillClass = $(JvmtiOutDir)/jvmtiEnvFill.class - -JvmtiGenSource = $(JvmtiSrcDir)/jvmtiGen.java -JvmtiGenClass = $(JvmtiOutDir)/jvmtiGen.class - -JvmtiGeneratedFiles = $(JvmtiGeneratedNames:%=$(JvmtiOutDir)/%) - -XSLT = $(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen - -.PHONY: all jvmtidocs clean cleanall - -# ######################################################################### - -all: $(JvmtiGeneratedFiles) - -both = $(JvmtiGenClass) $(JvmtiSrcDir)/jvmti.xml $(JvmtiSrcDir)/jvmtiLib.xsl - -$(JvmtiGenClass): $(JvmtiGenSource) - $(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiGenSource) - -$(JvmtiEnvFillClass): $(JvmtiEnvFillSource) - $(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiEnvFillSource) - -$(JvmtiOutDir)/jvmtiEnter.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnter.cpp -PARAM interface jvmti - -$(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp: $(JvmtiGenClass) $(InterpreterSrcDir)/bytecodeInterpreter.cpp $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml -XSL $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl -OUT $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp - -$(JvmtiOutDir)/jvmtiEnterTrace.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnterTrace.cpp -PARAM interface jvmti -PARAM trace Trace - -$(JvmtiOutDir)/jvmtiEnvRecommended.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnv.xsl $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiEnvFillClass) - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnv.xsl -OUT $(JvmtiOutDir)/jvmtiEnvStub.cpp - $(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiEnvFill $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiOutDir)/jvmtiEnvStub.cpp $(JvmtiOutDir)/jvmtiEnvRecommended.cpp - -$(JvmtiOutDir)/jvmtiEnv.hpp: $(both) $(JvmtiSrcDir)/jvmtiHpp.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiHpp.xsl -OUT $(JvmtiOutDir)/jvmtiEnv.hpp - -$(JvmtiOutDir)/jvmti.h: $(both) $(JvmtiSrcDir)/jvmtiH.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiH.xsl -OUT $(JvmtiOutDir)/jvmti.h - -jvmtidocs: $(JvmtiOutDir)/jvmti.html - -$(JvmtiOutDir)/jvmti.html: $(both) $(JvmtiSrcDir)/jvmti.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmti.xsl -OUT $(JvmtiOutDir)/jvmti.html - -# ######################################################################### - -clean : - rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles) - -cleanall : - rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles) - -# ######################################################################### diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug b/hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug deleted file mode 100644 index f92fe181903..00000000000 --- a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-debug +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# -# Only used for OSX/Darwin builds - -# Define public interface. - _JVM_handle_bsd_signal - - # miscellaneous functions - _jio_fprintf - _jio_printf - _jio_snprintf - _jio_vfprintf - _jio_vsnprintf - - # This is for Forte Analyzer profiling support. - _AsyncGetCallTrace - - # INSERT VTABLE SYMBOLS HERE - diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-product b/hotspot/make/bsd/makefiles/mapfile-vers-darwin-product deleted file mode 100644 index 47b8549c2ba..00000000000 --- a/hotspot/make/bsd/makefiles/mapfile-vers-darwin-product +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# -# Only used for OSX/Darwin builds - -# Define public interface. - _JVM_handle_bsd_signal - - # miscellaneous functions - _jio_fprintf - _jio_printf - _jio_snprintf - _jio_vfprintf - _jio_vsnprintf - - # This is for Forte Analyzer profiling support. - _AsyncGetCallTrace - - # INSERT VTABLE SYMBOLS HERE - diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-debug b/hotspot/make/bsd/makefiles/mapfile-vers-debug deleted file mode 100644 index ec0f06d8f65..00000000000 --- a/hotspot/make/bsd/makefiles/mapfile-vers-debug +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define public interface. - -SUNWprivate_1.1 { - global: - JVM_handle_linux_signal; - - # miscellaneous functions - jio_fprintf; - jio_printf; - jio_snprintf; - jio_vfprintf; - jio_vsnprintf; - numa_warn; - numa_error; - - # Needed because there is no JVM interface for this. - sysThreadAvailableStackWithSlack; - - # This is for Forte Analyzer profiling support. - AsyncGetCallTrace; - - # INSERT VTABLE SYMBOLS HERE - - local: - *; -}; - diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-jsig b/hotspot/make/bsd/makefiles/mapfile-vers-jsig deleted file mode 100644 index 8a675046b6e..00000000000 --- a/hotspot/make/bsd/makefiles/mapfile-vers-jsig +++ /dev/null @@ -1,40 +0,0 @@ -# - -# -# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define library interface. - -SUNWprivate_1.1 { - global: - JVM_begin_signal_setting; - JVM_end_signal_setting; - JVM_get_libjsig_version; - JVM_get_signal_action; - sigaction; - signal; - sigset; - local: - *; -}; diff --git a/hotspot/make/bsd/makefiles/mapfile-vers-product b/hotspot/make/bsd/makefiles/mapfile-vers-product deleted file mode 100644 index ec0f06d8f65..00000000000 --- a/hotspot/make/bsd/makefiles/mapfile-vers-product +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define public interface. - -SUNWprivate_1.1 { - global: - JVM_handle_linux_signal; - - # miscellaneous functions - jio_fprintf; - jio_printf; - jio_snprintf; - jio_vfprintf; - jio_vsnprintf; - numa_warn; - numa_error; - - # Needed because there is no JVM interface for this. - sysThreadAvailableStackWithSlack; - - # This is for Forte Analyzer profiling support. - AsyncGetCallTrace; - - # INSERT VTABLE SYMBOLS HERE - - local: - *; -}; - diff --git a/hotspot/make/bsd/makefiles/minimal1.make b/hotspot/make/bsd/makefiles/minimal1.make deleted file mode 100644 index d453e789877..00000000000 --- a/hotspot/make/bsd/makefiles/minimal1.make +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -TYPE=MINIMAL1 - -# Force all variables to false, overriding any other -# setting that may have occurred in the makefiles. These -# can still be overridden by passing the variable as an -# argument to 'make' -INCLUDE_JVMTI := false -INCLUDE_FPROF := false -INCLUDE_VM_STRUCTS := false -INCLUDE_JNI_CHECK := false -INCLUDE_SERVICES := false -INCLUDE_MANAGEMENT := false -INCLUDE_ALL_GCS := false -INCLUDE_NMT := false -INCLUDE_TRACE := false -INCLUDE_CDS := false -INCLUDE_JVMCI := false - -CXXFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\" -CFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\" - -Src_Dirs/MINIMAL1 = $(CORE_PATHS) $(COMPILER1_PATHS) - -Src_Files_EXCLUDE/MINIMAL1 += $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp - --include $(HS_ALT_MAKE)/$(OSNAME)/makefiles/minimal1.make - -.PHONY: $(HS_ALT_MAKE)/$(OSNAME)/makefiles/minimal1.make diff --git a/hotspot/make/bsd/makefiles/optimized.make b/hotspot/make/bsd/makefiles/optimized.make deleted file mode 100644 index f098efdbd82..00000000000 --- a/hotspot/make/bsd/makefiles/optimized.make +++ /dev/null @@ -1,46 +0,0 @@ -# -# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making optimized version of HotSpot VM -# (This is the "product", not the "release" version.) - -# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make -OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) -OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) - -# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files) - -# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings -CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# Linker mapfile -MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-debug -ifeq ($(OS_VENDOR), Darwin) -MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-darwin-debug -endif - -VERSION = optimized diff --git a/hotspot/make/bsd/makefiles/ppc.make b/hotspot/make/bsd/makefiles/ppc.make deleted file mode 100644 index 92957f963f9..00000000000 --- a/hotspot/make/bsd/makefiles/ppc.make +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT) - -# Must also specify if CPU is big endian -CFLAGS += -DVM_BIG_ENDIAN - diff --git a/hotspot/make/bsd/makefiles/product.make b/hotspot/make/bsd/makefiles/product.make deleted file mode 100644 index 7d3c345d38c..00000000000 --- a/hotspot/make/bsd/makefiles/product.make +++ /dev/null @@ -1,62 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making optimized version of HotSpot VM -# (This is the "product", not the "release" version.) - -# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make -OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) -OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) - -# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files) - -# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings -CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# Linker mapfile -MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-product -ifeq ($(OS_VENDOR), Darwin) -MAPFILE = $(GAMMADIR)/make/bsd/makefiles/mapfile-vers-darwin-product -endif - -SYSDEFS += -DPRODUCT -VERSION = optimized - -ifneq ($(OS_VENDOR), Darwin) - # use -g to strip library as -x will discard its symbol table; -x is fine for - # executables. - ifdef CROSS_COMPILE_ARCH - STRIP = $(ALT_COMPILER_PATH)/strip - else - STRIP = strip - endif - STRIP_LIBJVM = $(STRIP) -g $@ || exit 1; - STRIP_AOUT = $(STRIP) -x $@ || exit 1; - - # Don't strip in VM build; JDK build will strip libraries later - # LINK_LIB.CXX/POST_HOOK += $(STRIP_$(LINK_INTO)) -endif diff --git a/hotspot/make/bsd/makefiles/rules.make b/hotspot/make/bsd/makefiles/rules.make deleted file mode 100644 index bb36f19a473..00000000000 --- a/hotspot/make/bsd/makefiles/rules.make +++ /dev/null @@ -1,212 +0,0 @@ -# -# Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Common rules/macros for the vm, adlc. - -# Tell make that .cpp is important -.SUFFIXES: .cpp $(SUFFIXES) - -DEMANGLER = c++filt -DEMANGLE = $(DEMANGLER) < $@ > .$@ && $(MV) -f .$@ $@ - -# $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++). -CC_COMPILE = $(CC) $(CXXFLAGS) $(CFLAGS) -CXX_COMPILE = $(CXX) $(CXXFLAGS) $(CFLAGS) - -AS.S = $(AS) $(ASFLAGS) - -COMPILE.CC = $(CC_COMPILE) -c -GENASM.CC = $(CC_COMPILE) -S -LINK.CC = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS) -ifeq ($(STATIC_BUILD),true) -LINK_LIB.CC = $(AR) $(ARFLAGS) -else -LINK_LIB.CC = $(CC) $(LFLAGS) $(SHARED_FLAG) -endif -PREPROCESS.CC = $(CC_COMPILE) -E - -COMPILE.CXX = $(CXX_COMPILE) -c -GENASM.CXX = $(CXX_COMPILE) -S -LINK.CXX = $(CXX) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS) -LINK_NOPROF.CXX = $(CXX) $(LFLAGS) $(AOUT_FLAGS) -LINK_LIB.CXX = $(CXX) $(LFLAGS) $(SHARED_FLAG) -PREPROCESS.CXX = $(CXX_COMPILE) -E - -# cross compiling the jvm with c2 requires host compilers to build -# adlc tool - -HOST.CXX_COMPILE = $(HOSTCXX) $(CXXFLAGS) $(CFLAGS) -HOST.COMPILE.CXX = $(HOST.CXX_COMPILE) -c -HOST.LINK_NOPROF.CXX = $(HOSTCXX) $(LFLAGS) $(AOUT_FLAGS) - - -# Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k". -REMOVE_TARGET = rm -f $@ - -# Note use of ALT_BOOTDIR to explicitly specify location of java and -# javac; this is the same environment variable used in the J2SE build -# process for overriding the default spec, which is BOOTDIR. -# Note also that we fall back to using JAVA_HOME if neither of these is -# specified. - -ifdef ALT_BOOTDIR - -RUN.JAVA = $(ALT_BOOTDIR)/bin/java -RUN.JAVAP = $(ALT_BOOTDIR)/bin/javap -RUN.JAVAH = $(ALT_BOOTDIR)/bin/javah -RUN.JAR = $(ALT_BOOTDIR)/bin/jar -COMPILE.JAVAC = $(ALT_BOOTDIR)/bin/javac -COMPILE.RMIC = $(ALT_BOOTDIR)/bin/rmic -BOOT_JAVA_HOME = $(ALT_BOOTDIR) - -else - -ifdef BOOTDIR - -RUN.JAVA = $(BOOTDIR)/bin/java -RUN.JAVAP = $(BOOTDIR)/bin/javap -RUN.JAVAH = $(BOOTDIR)/bin/javah -RUN.JAR = $(BOOTDIR)/bin/jar -COMPILE.JAVAC = $(BOOTDIR)/bin/javac -COMPILE.RMIC = $(BOOTDIR)/bin/rmic -BOOT_JAVA_HOME = $(BOOTDIR) - -else - -ifdef JAVA_HOME - -RUN.JAVA = $(JAVA_HOME)/bin/java -RUN.JAVAP = $(JAVA_HOME)/bin/javap -RUN.JAVAH = $(JAVA_HOME)/bin/javah -RUN.JAR = $(JAVA_HOME)/bin/jar -COMPILE.JAVAC = $(JAVA_HOME)/bin/javac -COMPILE.RMIC = $(JAVA_HOME)/bin/rmic -BOOT_JAVA_HOME = $(JAVA_HOME) - -else - -# take from the PATH, if ALT_BOOTDIR, BOOTDIR and JAVA_HOME are not defined - -RUN.JAVA = java -RUN.JAVAP = javap -RUN.JAVAH = javah -RUN.JAR = jar -COMPILE.JAVAC = javac -COMPILE.RMIC = rmic - -endif -endif -endif - -COMPILE.JAVAC += $(BOOTSTRAP_JAVAC_FLAGS) - -SUM = /usr/bin/sum - -# 'gmake MAKE_VERBOSE=y' gives all the gory details. -QUIETLY$(MAKE_VERBOSE) = @ -RUN.JAR$(MAKE_VERBOSE) += >/dev/null - -# Settings for javac -JAVAC_FLAGS = -g -encoding ascii - -# Prefer BOOT_JDK_SOURCETARGET if it's set (typically by the top build system) -# Fall back to the values here if it's not set (hotspot only builds) -ifeq ($(BOOT_JDK_SOURCETARGET),) -BOOTSTRAP_SOURCETARGET := -source 8 -target 8 -else -BOOTSTRAP_SOURCETARGET := $(BOOT_JDK_SOURCETARGET) -endif - -BOOTSTRAP_JAVAC_FLAGS = $(JAVAC_FLAGS) $(BOOTSTRAP_SOURCETARGET) - -# With parallel makes, print a message at the end of compilation. -ifeq ($(findstring j,$(MFLAGS)),j) -COMPILE_DONE = && { echo Done with $<; } -endif - -# Include $(NONPIC_OBJ_FILES) definition -ifndef LP64 -include $(GAMMADIR)/make/pic.make -endif - -include $(GAMMADIR)/make/altsrc.make - -# The non-PIC object files are only generated for 32 bit platforms. -ifdef LP64 -%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE) -else -%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \ - $(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \ - $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)) -endif - -%.o: %.s - @echo $(LOG_INFO) Assembling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(AS.S) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE) - -%.s: %.cpp - @echo $(LOG_INFO) Generating assembly for $< - $(QUIETLY) $(GENASM.CXX) -o $@ $< - $(QUIETLY) $(DEMANGLE) $(COMPILE_DONE) - -# Intermediate files (for debugging macros) -%.i: %.cpp - @echo $(LOG_INFO) Preprocessing $< to $@ - $(QUIETLY) $(PREPROCESS.CXX) $< > $@ $(COMPILE_DONE) - -# Override gnumake built-in rules which do sccs get operations badly. -# (They put the checked out code in the current directory, not in the -# directory of the original file.) Since this is a symptom of a teamware -# failure, and since not all problems can be detected by gnumake due -# to incomplete dependency checking... just complain and stop. -%:: s.% - @echo "=========================================================" - @echo File $@ - @echo is out of date with respect to its SCCS file. - @echo This file may be from an unresolved Teamware conflict. - @echo This is also a symptom of a Teamware bringover/putback failure - @echo in which SCCS files are updated but not checked out. - @echo Check for other out of date files in your workspace. - @echo "=========================================================" - @exit 666 - -%:: SCCS/s.% - @echo "=========================================================" - @echo File $@ - @echo is out of date with respect to its SCCS file. - @echo This file may be from an unresolved Teamware conflict. - @echo This is also a symptom of a Teamware bringover/putback failure - @echo in which SCCS files are updated but not checked out. - @echo Check for other out of date files in your workspace. - @echo "=========================================================" - @exit 666 - -.PHONY: default diff --git a/hotspot/make/bsd/makefiles/shark.make b/hotspot/make/bsd/makefiles/shark.make deleted file mode 100644 index ca702ee6616..00000000000 --- a/hotspot/make/bsd/makefiles/shark.make +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright 2008, 2010 Red Hat, Inc. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making Shark version of VM - -TYPE = SHARK - -VM_SUBDIR = server - -CFLAGS += -DSHARK diff --git a/hotspot/make/bsd/makefiles/sparc.make b/hotspot/make/bsd/makefiles/sparc.make deleted file mode 100644 index ddb05132fab..00000000000 --- a/hotspot/make/bsd/makefiles/sparc.make +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - diff --git a/hotspot/make/bsd/makefiles/sparcWorks.make b/hotspot/make/bsd/makefiles/sparcWorks.make deleted file mode 100644 index e39116023c5..00000000000 --- a/hotspot/make/bsd/makefiles/sparcWorks.make +++ /dev/null @@ -1,107 +0,0 @@ -# -# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -#------------------------------------------------------------------------ -# CC, CXX & AS - -# If a SPEC is not set already, then use these defaults. -ifeq ($(SPEC),) - CXX = CC - CC = cc - AS = $(CC) -c - - HOSTCXX = $(CXX) - HOSTCC = $(CC) -endif - -ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) -ARCHFLAG/i486 = -m32 -ARCHFLAG/amd64 = -m64 - -CFLAGS += $(ARCHFLAG) -AOUT_FLAGS += $(ARCHFLAG) -LFLAGS += $(ARCHFLAG) -ASFLAGS += $(ARCHFLAG) - -#------------------------------------------------------------------------ -# Compiler flags - -# position-independent code -PICFLAG = -KPIC - -CFLAGS += $(PICFLAG) -# no more exceptions -CFLAGS += -features=no%except -# Reduce code bloat by reverting back to 5.0 behavior for static initializers -CFLAGS += -features=no%split_init -# allow zero sized arrays -CFLAGS += -features=zla - -# Use C++ Interpreter -ifdef CC_INTERP - CFLAGS += -DCC_INTERP -endif - -# We don't need libCstd.so and librwtools7.so, only libCrun.so -CFLAGS += -library=Crun -LIBS += -lCrun - -CFLAGS += -mt -LFLAGS += -mt - -# Compiler warnings are treated as errors -#WARNINGS_ARE_ERRORS = -errwarn=%all -CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) -# Special cases -CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) - -# The flags to use for an Optimized build -OPT_CFLAGS+=-xO4 -OPT_CFLAGS/NOOPT=-xO0 - -# Flags for creating the dependency files. -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1) -DEPFLAGS = -xMMD -xMF $(DEP_DIR)/$(@:%=%.d) -endif - -# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. -CFLAGS += -DDONT_USE_PRECOMPILED_HEADER - -#------------------------------------------------------------------------ -# Linker flags - -# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. -MAPFLAG = -Wl,--version-script=FILENAME - -# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj -SONAMEFLAG = -h SONAME - -# Build shared library -SHARED_FLAG = -G - -#------------------------------------------------------------------------ -# Debug flags -DEBUG_CFLAGS += -g -FASTDEBUG_CFLAGS = -g0 - diff --git a/hotspot/make/bsd/makefiles/sparcv9.make b/hotspot/make/bsd/makefiles/sparcv9.make deleted file mode 100644 index b9e4e525d76..00000000000 --- a/hotspot/make/bsd/makefiles/sparcv9.make +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# gcc 4.0 miscompiles this code in -m64 -OPT_CFLAGS/macro.o = -O0 - -CFLAGS += -D_LP64=1 diff --git a/hotspot/make/bsd/makefiles/tiered.make b/hotspot/make/bsd/makefiles/tiered.make deleted file mode 100644 index da79ade9fdc..00000000000 --- a/hotspot/make/bsd/makefiles/tiered.make +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making tiered version of VM - -TYPE=TIERED - -VM_SUBDIR = server - -CFLAGS += -DCOMPILER2 -DCOMPILER1 diff --git a/hotspot/make/bsd/makefiles/top.make b/hotspot/make/bsd/makefiles/top.make deleted file mode 100644 index 47394d64a95..00000000000 --- a/hotspot/make/bsd/makefiles/top.make +++ /dev/null @@ -1,156 +0,0 @@ -# -# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# top.make is included in the Makefile in the build directories. -# It DOES NOT include the vm dependency info in order to be faster. -# Its main job is to implement the incremental form of make lists. -# It also: -# -builds and runs adlc via adlc.make -# -generates JVMTI source and docs via jvmti.make (JSR-163) - -# It assumes the following flags are set: -# CFLAGS Platform_file, Src_Dirs_I, Src_Dirs_V, SYSDEFS, AOUT, Obj_Files - -# -- D. Ungar (5/97) from a file by Bill Bush - -# Don't override the built-in $(MAKE). -# Instead, use "gmake" (or "gnumake") from the command line. --Rose -#MAKE = gmake - -include $(GAMMADIR)/make/altsrc.make - -TOPDIR = $(shell echo `pwd`) -GENERATED = $(TOPDIR)/../generated -VM = $(GAMMADIR)/src/share/vm -Plat_File = $(Platform_file) -CDG = cd $(GENERATED); - -ifneq ($(USE_PRECOMPILED_HEADER),0) -UpdatePCH = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS) -else -UpdatePCH = \# precompiled header is not used -endif - -Cached_plat = $(GENERATED)/platform.current - -AD_Dir = $(GENERATED)/adfiles -ADLC = $(AD_Dir)/adlc -AD_Spec = $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad) -AD_Src = $(call altsrc-replace,$(HS_COMMON_SRC)/share/vm/adlc) -AD_Names = ad_$(Platform_arch_model).hpp ad_$(Platform_arch_model).cpp -AD_Files = $(AD_Names:%=$(AD_Dir)/%) - -# AD_Files_If_Required/COMPILER1 = ad_stuff -AD_Files_If_Required/COMPILER2 = ad_stuff -AD_Files_If_Required/TIERED = ad_stuff -AD_Files_If_Required = $(AD_Files_If_Required/$(TYPE)) - -# Wierd argument adjustment for "gnumake -j..." -adjust-mflags = $(GENERATED)/adjust-mflags -# If SPEC is set, it's from configure and it's already controlling concurrency -# for us. Skip setting -j with HOTSPOT_BUILD_JOBS. -ifeq ($(SPEC), ) - MFLAGS-adjusted = -r `$(adjust-mflags) "$(MFLAGS)" "$(HOTSPOT_BUILD_JOBS)"` -else - MFLAGS-adjusted = -r $(MFLAGS) -endif - - -# default target: update lists, make vm -# done in stages to force sequential order with parallel make -# - -default: vm_build_preliminaries the_vm - @echo All done. - -# This is an explicit dependency for the sake of parallel makes. -vm_build_preliminaries: checks $(Cached_plat) $(AD_Files_If_Required) jvmti_stuff trace_stuff dtrace_stuff - @# We need a null action here, so implicit rules don't get consulted. - -$(Cached_plat): $(Plat_File) - $(CDG) $(CP) $(Plat_File) $(Cached_plat) - -# make AD files as necessary -ad_stuff: $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f adlc.make $(MFLAGS-adjusted) - -# generate JVMTI files from the spec -jvmti_stuff: $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f jvmti.make $(MFLAGS-adjusted) - -# generate trace files -trace_stuff: jvmti_stuff $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f trace.make $(MFLAGS-adjusted) - -ifeq ($(OS_VENDOR), Darwin) -# generate dtrace header files -dtrace_stuff: $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f dtrace.make dtrace_stuff $(MFLAGS-adjusted) GENERATED=$(GENERATED) -else -dtrace_stuff: - @# We need a null action here, so implicit rules don't get consulted. -endif - -# and the VM: must use other makefile with dependencies included - -# We have to go to great lengths to get control over the -jN argument -# to the recursive invocation of vm.make. The problem is that gnumake -# resets -jN to -j1 for recursive runs. (How helpful.) -# Note that the user must specify the desired parallelism level via a -# command-line or environment variable name HOTSPOT_BUILD_JOBS. -$(adjust-mflags): $(GAMMADIR)/make/$(Platform_os_family)/makefiles/adjust-mflags.sh - @+rm -f $@ $@+ - @+cat $< > $@+ - @+chmod +x $@+ - @+mv $@+ $@ - -the_vm: vm_build_preliminaries $(adjust-mflags) - +@$(UpdatePCH) - @$(MAKE) -f vm.make $(MFLAGS-adjusted) - -install : the_vm - @$(MAKE) -f vm.make $@ - -# next rules support "make foo.[ois]" - -%.o %.i %.s: - +$(UpdatePCH) - $(MAKE) -f vm.make $(MFLAGS) $@ - #$(MAKE) -f vm.make $@ - -# this should force everything to be rebuilt -clean: - rm -f $(GENERATED)/*.class - $(MAKE) -f vm.make $(MFLAGS) clean - -# just in case it doesn't, this should do it -realclean: - $(MAKE) -f vm.make $(MFLAGS) clean - rm -fr $(GENERATED) - -.PHONY: default vm_build_preliminaries -.PHONY: lists ad_stuff jvmti_stuff the_vm clean realclean -.PHONY: checks check_os_version install - -.NOTPARALLEL: diff --git a/hotspot/make/bsd/makefiles/trace.make b/hotspot/make/bsd/makefiles/trace.make deleted file mode 100644 index 37df4425f50..00000000000 --- a/hotspot/make/bsd/makefiles/trace.make +++ /dev/null @@ -1,119 +0,0 @@ -# -# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (trace.make) is included from the trace.make in the -# build directories. -# -# It knows how to build and run the tools to generate trace files. - -include $(GAMMADIR)/make/bsd/makefiles/rules.make -include $(GAMMADIR)/make/altsrc.make - -# ######################################################################### - -HAS_ALT_SRC := false -ifndef OPENJDK - ifneq ($(wildcard $(HS_ALT_SRC)/share/vm/trace), ) - HAS_ALT_SRC := true - endif -endif - -TOPDIR = $(shell echo `pwd`) -GENERATED = $(TOPDIR)/../generated -JvmtiOutDir = $(GENERATED)/jvmtifiles -TraceOutDir = $(GENERATED)/tracefiles - -TraceAltSrcDir = $(HS_ALT_SRC)/share/vm/trace -TraceSrcDir = $(HS_COMMON_SRC)/share/vm/trace - -# set VPATH so make knows where to look for source files -Src_Dirs_V += $(TraceSrcDir) $(TraceAltSrcDir) -VPATH += $(Src_Dirs_V:%=%:) - -TraceGeneratedNames = \ - traceEventClasses.hpp \ - traceEventIds.hpp \ - traceTypes.hpp - -ifeq ($(HAS_ALT_SRC), true) -TraceGeneratedNames += \ - traceRequestables.hpp \ - traceEventControl.hpp -endif - -TraceGeneratedFiles = $(TraceGeneratedNames:%=$(TraceOutDir)/%) - -XSLT = $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen - -TraceXml = $(TraceSrcDir)/trace.xml -ifeq ($(HAS_ALT_SRC), true) - TraceXml = $(TraceAltSrcDir)/trace.xml -endif - -XML_DEPS = $(TraceXml) $(TraceSrcDir)/tracetypes.xml \ - $(TraceSrcDir)/trace.dtd $(TraceSrcDir)/xinclude.mod \ - $(TraceSrcDir)/tracerelationdecls.xml $(TraceSrcDir)/traceevents.xml -ifeq ($(HAS_ALT_SRC), true) - XML_DEPS += $(TraceAltSrcDir)/traceeventscustom.xml \ - $(TraceAltSrcDir)/traceeventtypes.xml -endif - -.PHONY: all clean cleanall - -# ######################################################################### - -all: $(TraceGeneratedFiles) - -GENERATE_CODE= \ - $(QUIETLY) echo $(LOG_INFO) Generating $@; \ - $(XSLT) -IN $(word 1,$^) -XSL $(word 2,$^) -OUT $@ - -$(TraceOutDir)/traceEventIds.hpp: $(TraceXml) $(TraceSrcDir)/traceEventIds.xsl $(XML_DEPS) - $(GENERATE_CODE) - -$(TraceOutDir)/traceTypes.hpp: $(TraceXml) $(TraceSrcDir)/traceTypes.xsl $(XML_DEPS) - $(GENERATE_CODE) - -ifeq ($(HAS_ALT_SRC), false) - -$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceSrcDir)/traceEventClasses.xsl $(XML_DEPS) - $(GENERATE_CODE) - -else - -$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventClasses.xsl $(XML_DEPS) - $(GENERATE_CODE) - -$(TraceOutDir)/traceRequestables.hpp: $(TraceXml) $(TraceAltSrcDir)/traceRequestables.xsl $(XML_DEPS) - $(GENERATE_CODE) - -$(TraceOutDir)/traceEventControl.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventControl.xsl $(XML_DEPS) - $(GENERATE_CODE) - -endif - -# ######################################################################### - -clean cleanall: - rm $(TraceGeneratedFiles) diff --git a/hotspot/make/bsd/makefiles/universal.gmk b/hotspot/make/bsd/makefiles/universal.gmk deleted file mode 100644 index 128d21b46d6..00000000000 --- a/hotspot/make/bsd/makefiles/universal.gmk +++ /dev/null @@ -1,126 +0,0 @@ -# -# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# macosx universal builds -universal_product: - $(MAKE) MACOSX_UNIVERSAL=true all_product_universal -universal_optimized: - $(MAKE) MACOSX_UNIVERSAL=true all_optimized_universal -universal_fastdebug: - $(MAKE) MACOSX_UNIVERSAL=true all_fastdebug_universal -universal_debug: - $(MAKE) MACOSX_UNIVERSAL=true all_debug_universal - - -# Universal builds include 1 or more architectures in a single binary -all_product_universal: -# $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 $(COMMON_VM_PRODUCT_TARGETS) - $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 $(COMMON_VM_PRODUCT_TARGETS) - $(QUIETLY) $(MAKE) BUILD_FLAVOR=product EXPORT_SUBDIR= universalize -all_optimized_universal: -# $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 $(COMMON_VM_OPTIMIZED_TARGETS) - $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 $(COMMON_VM_OPTIMIZED_TARGETS) - $(QUIETLY) $(MAKE) BUILD_FLAVOR=optimized EXPORT_SUBDIR=/optimized universalize -all_fastdebug_universal: -# $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 $(COMMON_VM_FASTDEBUG_TARGETS) - $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 $(COMMON_VM_FASTDEBUG_TARGETS) - $(QUIETLY) $(MAKE) BUILD_FLAVOR=fastdebug EXPORT_SUBDIR=/fastdebug universalize -all_debug_universal: -# $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=32 $(COMMON_VM_DEBUG_TARGETS) - $(QUIETLY) $(MAKE) ARCH_DATA_MODEL=64 $(COMMON_VM_DEBUG_TARGETS) - $(QUIETLY) $(MAKE) BUILD_FLAVOR=debug EXPORT_SUBDIR=/debug universalize - - -# Consolidate architecture builds into a single Universal binary -universalize: $(UNIVERSAL_LIPO_LIST) $(UNIVERSAL_COPY_LIST) - $(RM) -r $(EXPORT_PATH)/lib/{i386,amd64} - -LIPO ?= lipo - -# Package built libraries in a universal binary -$(UNIVERSAL_LIPO_LIST): - BUILT_LIPO_FILES="`find $(EXPORT_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_LIB_DIR)/,,$@) 2>/dev/null`" || test $$? = "1"; \ - if [ -n "$${BUILT_LIPO_FILES}" ]; then \ - $(MKDIR) -p $(shell dirname $@); \ - $(LIPO) -create -output $@ $${BUILT_LIPO_FILES}; \ - fi - - -# Copy built non-universal binaries in place -# - copies directories; including empty dirs -# - copies files, symlinks, other non-directory files -$(UNIVERSAL_COPY_LIST): - BUILT_COPY_FILES="`find $(EXPORT_LIB_DIR)/{i386,amd64}/$(subst $(EXPORT_LIB_DIR)/,,$@) -prune 2>/dev/null`" || test $$? = "1"; \ - if [ -n "$${BUILT_COPY_FILES}" ]; then \ - for i in $${BUILT_COPY_FILES}; do \ - $(MKDIR) -p $(shell dirname $@); \ - $(CP) -R $${i} $@; \ - done; \ - fi - - -# Replace arch specific binaries with universal binaries -# Do not touch lib/{client,server}/libjsig.$(LIBRARY_SUFFIX) -# That symbolic link belongs to the 'jdk' build. -export_universal: - $(RM) -r $(EXPORT_PATH)/lib/{i386,amd64} - $(RM) -r $(JDK_IMAGE_DIR)/lib/{i386,amd64} - ($(CD) $(EXPORT_PATH) && \ - $(TAR) -cf - *) | \ - ($(CD) $(JDK_IMAGE_DIR) && $(TAR) -xpf -) - - -# Overlay universal binaries -# Do not touch lib/{client,server}/libjsig.$(LIBRARY_SUFFIX) -# That symbolic link belongs to the 'jdk' build. -copy_universal: - $(RM) -r $(JDK_IMAGE_DIR)$(COPY_SUBDIR)/lib/{i386,amd64} - ($(CD) $(EXPORT_PATH)$(COPY_SUBDIR) && \ - $(TAR) -cf - *) | \ - ($(CD) $(JDK_IMAGE_DIR)$(COPY_SUBDIR) && $(TAR) -xpf -) - - -# Additional processing for universal builds -export_product_jdk:: - $(MAKE) EXPORT_SUBDIR= export_universal -export_optimized_jdk:: - $(MAKE) EXPORT_SUBDIR=/optimized export_universal -export_fastdebug_jdk:: - $(MAKE) EXPORT_SUBDIR=/fastdebug export_universal -export_debug_jdk:: - $(MAKE) EXPORT_SUBDIR=/debug export_universal -copy_product_jdk:: - $(MAKE) COPY_SUBDIR= copy_universal -copy_optimized_jdk:: - $(MAKE) COPY_SUBDIR=/optimized copy_universal -copy_fastdebug_jdk:: - $(MAKE) COPY_SUBDIR=/fastdebug copy_universal -copy_debug_jdk:: - $(MAKE) COPY_SUBDIR=/debug copy_universal - -.PHONY: universal_product universal_fastdebug universal_debug \ - all_product_universal all_fastdebug_universal all_debug_universal \ - universal_optimized all_optimized_universal \ - universalize export_universal copy_universal \ - $(UNIVERSAL_LIPO_LIST) $(UNIVERSAL_COPY_LIST) diff --git a/hotspot/make/bsd/makefiles/vm.make b/hotspot/make/bsd/makefiles/vm.make deleted file mode 100644 index a3c1ce6c267..00000000000 --- a/hotspot/make/bsd/makefiles/vm.make +++ /dev/null @@ -1,438 +0,0 @@ -# -# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Rules to build JVM and related libraries, included from vm.make in the build -# directory. - -# Common build rules. -MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles -include $(MAKEFILES_DIR)/rules.make -include $(GAMMADIR)/make/altsrc.make - -default: build - -#---------------------------------------------------------------------- -# Defs - -GENERATED = ../generated -DEP_DIR = $(GENERATED)/dependencies - -# reads the generated files defining the set of .o's and the .o .h dependencies --include $(DEP_DIR)/*.d - -# read machine-specific adjustments (%%% should do this via buildtree.make?) -ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - include $(MAKEFILES_DIR)/zeroshark.make -else - include $(MAKEFILES_DIR)/$(BUILDARCH).make -endif - -# set VPATH so make knows where to look for source files -# Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm -# The adfiles directory contains ad_.[ch]pp. -# The jvmtifiles directory contains jvmti*.[ch]pp -Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles $(GENERATED)/tracefiles -VPATH += $(Src_Dirs_V:%=%:) - -# set INCLUDES for C preprocessor. -Src_Dirs_I += $(GENERATED) -# The order is important for the precompiled headers to work. -INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%) - -# SYMFLAG is used by jsig.make -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - # always build with debug info when we can create .dSYM/.debuginfo files - SYMFLAG = -g -else - ifeq (${VERSION}, debug) - SYMFLAG = -g - else - SYMFLAG = - endif -endif - -# The following variables are defined in the generated flags.make file. -JDK_VER_DEFS = -DVERSION_MAJOR=$(VERSION_MAJOR) \ - -DVERSION_MINOR=$(VERSION_MINOR) \ - -DVERSION_SECURITY=$(VERSION_SECURITY) \ - -DVERSION_PATCH=$(VERSION_PATCH) \ - -DVERSION_BUILD=$(VERSION_BUILD) -VM_VER_DEFS = -DHOTSPOT_VERSION_STRING="\"$(HOTSPOT_VERSION_STRING)\"" \ - -DVERSION_STRING="\"$(VERSION_STRING)\"" \ - -DDEBUG_LEVEL="\"$(DEBUG_LEVEL)\"" \ - $(JDK_VER_DEFS) -HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\"" -VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\"" - -CXXFLAGS = \ - ${SYSDEFS} \ - ${INCLUDES} \ - ${BUILD_USER} \ - ${HS_LIB_ARCH} \ - ${VM_DISTRO} - -# This is VERY important! The version define must only be supplied to vm_version.o -# If not, ccache will not re-use the cache at all, since the version string might contain -# a time and date. -CXXFLAGS/vm_version.o += ${VM_VER_DEFS} - -CXXFLAGS/BYFILE = $(CXXFLAGS/$@) - -# File specific flags -CXXFLAGS += $(CXXFLAGS/BYFILE) - -ifdef DEFAULT_LIBPATH -CXXFLAGS += -DDEFAULT_LIBPATH="\"$(DEFAULT_LIBPATH)\"" -endif - -# CFLAGS_WARN holds compiler options to suppress/enable warnings. -CFLAGS += $(CFLAGS_WARN/BYFILE) - -# Do not use C++ exception handling -CFLAGS += $(CFLAGS/NOEX) - -# Extra flags from gnumake's invocation or environment -CFLAGS += $(EXTRA_CFLAGS) -LFLAGS += $(EXTRA_CFLAGS) - -# Don't set excutable bit on stack segment -# the same could be done by separate execstack command -# Darwin is non-executable-stack by default -ifneq ($(OS_VENDOR), Darwin) -LFLAGS += -Xlinker -z -Xlinker noexecstack -endif - -LIBS += -lm - -ifeq ($(USE_CLANG),) - LIBS += -pthread -endif - -# By default, link the *.o into the library, not the executable. -LINK_INTO$(LINK_INTO) = LIBJVM - -JDK_LIBDIR = $(JAVA_HOME)/lib/$(LIBARCH) - -#---------------------------------------------------------------------- -# jvm_db & dtrace -include $(MAKEFILES_DIR)/dtrace.make - -#---------------------------------------------------------------------- -# JVM - -JVM = jvm -ifeq ($(OS_VENDOR), Darwin) - LIBJVM = lib$(JVM).$(LIBRARY_SUFFIX) - CFLAGS += -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE - - LIBJVM_DEBUGINFO = lib$(JVM).$(LIBRARY_SUFFIX).dSYM - LIBJVM_DIZ = lib$(JVM).diz -else - LIBJVM = lib$(JVM).so - - LIBJVM_DEBUGINFO = lib$(JVM).debuginfo - LIBJVM_DIZ = lib$(JVM).diz -endif - -SPECIAL_PATHS:=adlc c1 gc opto shark libadt - -SOURCE_PATHS=\ - $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \ - \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \)) -SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm -SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm -SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm -SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm - -CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path)) -CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles - -ifneq ($(INCLUDE_TRACE), false) -CORE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \ - find $(HS_ALT_SRC)/share/vm/jfr -type d; \ - fi) -endif - -COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1) -COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1 - -COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto) -COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt) -COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto -COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt -COMPILER2_PATHS += $(GENERATED)/adfiles - -SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark - -# Include dirs per type. -Src_Dirs/CORE := $(CORE_PATHS) -Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS) -Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS) -Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS) -Src_Dirs/ZERO := $(CORE_PATHS) -Src_Dirs/SHARK := $(CORE_PATHS) $(SHARK_PATHS) -Src_Dirs := $(Src_Dirs/$(TYPE)) - -COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\* -COMPILER1_SPECIFIC_FILES := c1_\* -SHARK_SPECIFIC_FILES := shark -ZERO_SPECIFIC_FILES := zero - -# Always exclude these. -Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp - -# Exclude per type. -Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) -Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) -Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) - -Src_Files_EXCLUDE += $(Src_Files_EXCLUDE/$(TYPE)) - -# Special handling of arch model. -ifeq ($(Platform_arch_model), x86_32) -Src_Files_EXCLUDE += \*x86_64\* -endif -ifeq ($(Platform_arch_model), x86_64) -Src_Files_EXCLUDE += \*x86_32\* -endif - -# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE. -define findsrc - $(notdir $(shell find $(1)/. ! -name . -prune \ - -a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \ - -a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \))) -endef - -Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e))) - -Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files)))) - -JVM_OBJ_FILES = $(Obj_Files) - -vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES)) - -MAPFILE_SHARE := $(GAMMADIR)/make/share/makefiles/mapfile-vers - -MAPFILE_EXT_SRC := $(HS_ALT_MAKE)/share/makefiles/mapfile-ext -ifneq ("$(wildcard $(MAPFILE_EXT_SRC))","") -MAPFILE_EXT := $(MAPFILE_EXT_SRC) -endif - -# For Darwin: add _ prefix and remove trailing ; -mapfile_extra: $(MAPFILE_SHARE) $(MAPFILE_EXT) - rm -f $@ -ifeq ($(OS_VENDOR), Darwin) - cat $(MAPFILE_SHARE) $(MAPFILE_EXT) | \ - sed -e 's/#.*//g' -e 's/[ ]*//g' -e 's/;//g' | \ - awk '{ if ($$0 ~ ".") { print "\t\t_" $$0 } }' \ - > $@ -else - cat $(MAPFILE_SHARE) $(MAPFILE_EXT) > $@ -endif - -mapfile : $(MAPFILE) mapfile_extra vm.def - rm -f $@ - awk '{ if ($$0 ~ "INSERT VTABLE SYMBOLS HERE") \ - { system ("cat mapfile_extra vm.def"); } \ - else \ - { print $$0 } \ - }' > $@ < $(MAPFILE) - -ifeq ($(STATIC_BUILD),true) -EXPORTED_SYMBOLS = libjvm.symbols - -libjvm.symbols : mapfile - $(CP) mapfile libjvm.symbols - -else -EXPORTED_SYMBOLS = -endif - -mapfile_reorder : mapfile $(REORDERFILE) - rm -f $@ - cat $^ > $@ - -vm.def: $(Res_Files) $(Obj_Files) - sh $(GAMMADIR)/make/bsd/makefiles/build_vm_def.sh *.o > $@ - -mapfile_ext: - rm -f $@ - touch $@ - if [ -f $(HS_ALT_MAKE)/bsd/makefiles/mapfile-ext ]; then \ - cat $(HS_ALT_MAKE)/bsd/makefiles/mapfile-ext > $@; \ - fi - -STATIC_CXX = false - -ifeq ($(LINK_INTO),AOUT) - LIBJVM.o = - LIBJVM_MAPFILE = - LIBS_VM = $(LIBS) -else - LIBJVM.o = $(JVM_OBJ_FILES) - LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder - LFLAGS_VM$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE)) - LFLAGS_VM += $(SONAMEFLAG:SONAME=$(LIBJVM)) - - ifeq ($(OS_VENDOR), Darwin) - ifneq ($(STATIC_BUILD),true) - LFLAGS_VM += -Xlinker -rpath -Xlinker @loader_path/. - LFLAGS_VM += -Xlinker -rpath -Xlinker @loader_path/.. - LFLAGS_VM += -Xlinker -install_name -Xlinker @rpath/$(@F) - endif - else - LFLAGS_VM += -Wl,-z,defs - endif - - # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to - # get around library dependency and compatibility issues. Must use gcc not - # g++ to link. - ifeq ($(STATIC_CXX), true) - LFLAGS_VM += $(STATIC_LIBGCC) - LIBS_VM += $(STATIC_STDCXX) - LINK_VM = $(LINK_LIB.CC) - else - LINK_VM = $(LINK_LIB.CXX) - endif - - LIBS_VM += $(LIBS) -endif -ifeq ($(JVM_VARIANT_ZERO), true) - LIBS_VM += $(LIBFFI_LIBS) -endif -ifeq ($(JVM_VARIANT_ZEROSHARK), true) - LIBS_VM += $(LIBFFI_LIBS) $(LLVM_LIBS) - LFLAGS_VM += $(LLVM_LDFLAGS) -endif - - -# rule for building precompiled header -$(PRECOMPILED_HEADER): - $(QUIETLY) echo $(LOG_INFO) Generating precompiled header $@ - $(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR) - $(QUIETLY) rm -f $@ - $(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE) - -# making the library: - -ifneq ($(JVM_BASE_ADDR),) -# By default shared library is linked at base address == 0. Modify the -# linker script if JVM prefers a different base location. It can also be -# implemented with 'prelink -r'. But 'prelink' is not (yet) available on -# our build platform (AS-2.1). -LD_SCRIPT = libjvm.so.lds -$(LD_SCRIPT): $(LIBJVM_MAPFILE) - $(QUIETLY) { \ - rm -rf $@; \ - $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1 | \ - sed -e '/^======/,/^======/!d' \ - -e '/^======/d' \ - -e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/' \ - > $@; \ - } -LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT) -endif - -$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT) -ifeq ($(STATIC_BUILD),true) - echo Linking static vm...; - $(LINK_LIB.CC) $@ $(LIBJVM.o) -else - $(QUIETLY) { \ - echo $(LOG_INFO) Linking vm...; \ - $(LINK_LIB.CXX/PRE_HOOK) \ - $(LINK_VM) $(LD_SCRIPT_FLAG) \ - $(LFLAGS_VM) -o $@ $(sort $(LIBJVM.o)) $(LIBS_VM); \ - $(LINK_LIB.CXX/POST_HOOK) \ - rm -f $@.1; ln -s $@ $@.1; \ - } - -endif - -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(OS_VENDOR), Darwin) - $(DSYMUTIL) $@ - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -r -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO) - $(RM) -r $(LIBJVM_DEBUGINFO) - endif - else - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO) - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@ - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -g $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO) - $(RM) $(LIBJVM_DEBUGINFO) - endif - endif -endif - -DEST_SUBDIR = $(JDK_LIBDIR)/$(VM_SUBDIR) -DEST_JVM = $(DEST_SUBDIR)/$(LIBJVM) -DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO) -DEST_JVM_DIZ = $(DEST_SUBDIR)/$(LIBJVM_DIZ) - -install_jvm: $(LIBJVM) - @echo "Copying $(LIBJVM) to $(DEST_JVM)" -ifeq ($(OS_VENDOR), Darwin) - $(QUIETLY) test ! -d $(LIBJVM_DEBUGINFO) || \ - $(CP) -f -r $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO) -else - $(QUIETLY) test ! -f $(LIBJVM_DEBUGINFO) || \ - $(CP) -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO) -endif - $(QUIETLY) test ! -f $(LIBJVM_DIZ) || \ - $(CP) -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ) - $(QUIETLY) $(CP) -f $(LIBJVM) $(DEST_JVM) && echo "Done" - -#---------------------------------------------------------------------- -# Other files - -# Signal interposition library -include $(MAKEFILES_DIR)/jsig.make - -#---------------------------------------------------------------------- - -ifeq ($(OS_VENDOR), Darwin) -# no libjvm_db for macosx -build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) dtraceCheck $(EXPORTED_SYMBOLS) - echo "Doing vm.make build:" -else -build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(EXPORTED_SYMBOLS) -endif - -install: install_jvm install_jsigs - -.PHONY: default build install install_jvm diff --git a/hotspot/make/bsd/makefiles/zero.make b/hotspot/make/bsd/makefiles/zero.make deleted file mode 100644 index 0270711f5cb..00000000000 --- a/hotspot/make/bsd/makefiles/zero.make +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright 2009 Red Hat, Inc. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Setup for Zero (non-Shark) version of VM - -# Select which files to use (in top.make) -TYPE = ZERO - -# Install libjvm.so, etc in in server directory. -VM_SUBDIR = server diff --git a/hotspot/make/bsd/makefiles/zeroshark.make b/hotspot/make/bsd/makefiles/zeroshark.make deleted file mode 100644 index 12c41981904..00000000000 --- a/hotspot/make/bsd/makefiles/zeroshark.make +++ /dev/null @@ -1,62 +0,0 @@ -# -# Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. -# Copyright 2007, 2008 Red Hat, Inc. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Setup common to Zero (non-Shark) and Shark versions of VM - -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT) -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT) - -# Specify that the CPU is little endian, if necessary -ifeq ($(ZERO_ENDIANNESS), little) - CFLAGS += -DVM_LITTLE_ENDIAN -endif - -# Specify that the CPU is 64 bit, if necessary -ifeq ($(ARCH_DATA_MODEL), 64) - CFLAGS += -D_LP64=1 -endif - -# Specify the path to the FFI headers -ifdef ALT_PACKAGE_PATH - PACKAGE_PATH = $(ALT_PACKAGE_PATH) -else - ifeq ($(OS_VENDOR),Apple) - PACKAGE_PATH = /opt/local - else - ifeq ($(OS_VENDOR),NetBSD) - PACKAGE_PATH = /usr/pkg - LIBS += -Wl,-R${PACKAGE_PATH}/lib - else - PACKAGE_PATH = /usr/local - endif - endif -endif - -CFLAGS += -I$(PACKAGE_PATH)/include -LIBS += -L$(PACKAGE_PATH)/lib -lffi - -OPT_CFLAGS/compactingPermGenGen.o = -O1 diff --git a/hotspot/make/bsd/platform_amd64 b/hotspot/make/bsd/platform_amd64 deleted file mode 100644 index 51b2b1cd325..00000000000 --- a/hotspot/make/bsd/platform_amd64 +++ /dev/null @@ -1,15 +0,0 @@ -os_family = bsd - -arch = x86 - -arch_model = x86_64 - -os_arch = bsd_x86 - -os_arch_model = bsd_x86_64 - -lib_arch = amd64 - -compiler = gcc - -sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DAMD64 diff --git a/hotspot/make/bsd/platform_amd64.suncc b/hotspot/make/bsd/platform_amd64.suncc deleted file mode 100644 index 68e0cc37489..00000000000 --- a/hotspot/make/bsd/platform_amd64.suncc +++ /dev/null @@ -1,17 +0,0 @@ -os_family = bsd - -arch = x86 - -arch_model = x86_64 - -os_arch = bsd_x86 - -os_arch_model = bsd_x86_64 - -lib_arch = amd64 - -compiler = sparcWorks - -gnu_dis_arch = amd64 - -sysdefs = -D_ALLBSD_SOURCE -DSPARC_WORKS -D_GNU_SOURCE -DAMD64 diff --git a/hotspot/make/bsd/platform_i486 b/hotspot/make/bsd/platform_i486 deleted file mode 100644 index 2f77e79ff56..00000000000 --- a/hotspot/make/bsd/platform_i486 +++ /dev/null @@ -1,15 +0,0 @@ -os_family = bsd - -arch = x86 - -arch_model = x86_32 - -os_arch = bsd_x86 - -os_arch_model = bsd_x86_32 - -lib_arch = i386 - -compiler = gcc - -sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DIA32 diff --git a/hotspot/make/bsd/platform_i486.suncc b/hotspot/make/bsd/platform_i486.suncc deleted file mode 100644 index 5b203cd5c5b..00000000000 --- a/hotspot/make/bsd/platform_i486.suncc +++ /dev/null @@ -1,17 +0,0 @@ -os_family = bsd - -arch = x86 - -arch_model = x86_32 - -os_arch = bsd_x86 - -os_arch_model = bsd_x86_32 - -lib_arch = i386 - -compiler = sparcWorks - -gnu_dis_arch = i386 - -sysdefs = -D_ALLBSD_SOURCE -DSPARC_WORKS -D_GNU_SOURCE -DIA32 diff --git a/hotspot/make/bsd/platform_ia64 b/hotspot/make/bsd/platform_ia64 deleted file mode 100644 index 00b9f3380b7..00000000000 --- a/hotspot/make/bsd/platform_ia64 +++ /dev/null @@ -1,15 +0,0 @@ -os_family = bsd - -arch = ia64 - -os_arch = bsd_ia64 - -lib_arch = ia64 - -compiler = gcc - -gnu_dis_arch = ia64 - -sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DIA64 -DCC_INTERP - -mark_style = alignment diff --git a/hotspot/make/bsd/platform_sparc b/hotspot/make/bsd/platform_sparc deleted file mode 100644 index 04772ad4f2a..00000000000 --- a/hotspot/make/bsd/platform_sparc +++ /dev/null @@ -1,15 +0,0 @@ -os_family = bsd - -arch = sparc - -arch_model = sparc - -os_arch = bsd_sparc - -os_arch_model = bsd_sparc - -lib_arch = sparc - -compiler = gcc - -sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DSPARC diff --git a/hotspot/make/bsd/platform_sparcv9 b/hotspot/make/bsd/platform_sparcv9 deleted file mode 100644 index 89e51c5b209..00000000000 --- a/hotspot/make/bsd/platform_sparcv9 +++ /dev/null @@ -1,15 +0,0 @@ -os_family = bsd - -arch = sparc - -arch_model = sparc - -os_arch = bsd_sparc - -os_arch_model = bsd_sparc - -lib_arch = sparcv9 - -compiler = gcc - -sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DSPARC diff --git a/hotspot/make/bsd/platform_zero.in b/hotspot/make/bsd/platform_zero.in deleted file mode 100644 index f6729c2c08c..00000000000 --- a/hotspot/make/bsd/platform_zero.in +++ /dev/null @@ -1,17 +0,0 @@ -os_family = bsd - -arch = zero - -arch_model = zero - -os_arch = bsd_zero - -os_arch_model = bsd_zero - -lib_arch = zero - -compiler = gcc - -gnu_dis_arch = zero - -sysdefs = -D_ALLBSD_SOURCE -D_GNU_SOURCE -DCC_INTERP -DZERO -D@ZERO_ARCHDEF@ -DZERO_LIBARCH=\"@ZERO_LIBARCH@\" diff --git a/hotspot/make/build.sh b/hotspot/make/build.sh deleted file mode 100644 index 27c78433046..00000000000 --- a/hotspot/make/build.sh +++ /dev/null @@ -1,92 +0,0 @@ -#! /bin/sh -# -# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Make sure the variable JAVA_HOME is set before running this script. - -set -u - - -if [ $# -lt 1 ]; then - echo "Usage : $0 BuildTarget [LP64=1] [BuildOptions]" - echo " Server VM | Client VM" - echo "BuildTarget : debug | debug1" - echo " fastdebug | fastdebug1" - echo " jvmg | jvmg1" - echo " optimized | optimized1" - echo " profiled | profiled1" - echo " product | product1" - exit 1 -fi - -if [ "${JAVA_HOME-}" = "" -o ! -d "${JAVA_HOME-}" ]; then - echo "JAVA_HOME needs to be set to a valid JDK path" - echo "JAVA_HOME: ${JAVA_HOME-}" - exit 1 -fi - -# Just in case: -JAVA_HOME=`( cd $JAVA_HOME; pwd )` - -if [ "${ALT_BOOTDIR-}" = "" -o ! -d "${ALT_BOOTDIR-}" -o ! -d ${ALT_BOOTDIR-}/lib/ ]; then - ALT_BOOTDIR=${JAVA_HOME} -fi - -# build in current directory by default -if [ "${ALT_OUTPUTDIR-}" = "" -o ! -d "${ALT_OUTPUTDIR-}" ]; then - ALT_OUTPUTDIR=`(pwd)` -fi - -HOTSPOT_SRC=`(dirname $0)`/.. -HOTSPOT_SRC=`(cd ${HOTSPOT_SRC}; pwd)` - -for gm in gmake gnumake -do - if [ "${GNUMAKE-}" != "" ]; then break; fi - ($gm --version >/dev/null) 2>/dev/null && GNUMAKE=$gm -done -: ${GNUMAKE:?'Cannot locate the gnumake program. Stop.'} - -# quiet build by default -Quiet="MAKE_VERBOSE=" - -# no debug info by default -NoDebugInfo="ENABLE_FULL_DEBUG_SYMBOLS=" - -LANG=C - -echo "### ENVIRONMENT SETTINGS:" -export HOTSPOT_SRC ; echo "HOTSPOT_SRC=$HOTSPOT_SRC" -export JAVA_HOME ; echo "JAVA_HOME=$JAVA_HOME" -export ALT_BOOTDIR ; echo "ALT_BOOTDIR=$ALT_BOOTDIR" -export ALT_OUTPUTDIR ; echo "ALT_OUTPUTDIR=$ALT_OUTPUTDIR" -export GNUMAKE ; echo "GNUMAKE=$GNUMAKE" -export LANG ; echo "LANG=$LANG" -echo "###" - -BuildOptions="$Quiet $NoDebugInfo $*" - -echo \ -${GNUMAKE} -f ${HOTSPOT_SRC}/make/Makefile $BuildOptions GAMMADIR=${HOTSPOT_SRC} -${GNUMAKE} -f ${HOTSPOT_SRC}/make/Makefile $BuildOptions GAMMADIR=${HOTSPOT_SRC} diff --git a/hotspot/make/cscope.make b/hotspot/make/cscope.make deleted file mode 100644 index c38b7a5c784..00000000000 --- a/hotspot/make/cscope.make +++ /dev/null @@ -1,141 +0,0 @@ -# -# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# The cscope.out file is generated in the current directory. The old cscope.out -# file is *not* removed because cscope is smart enough to only build what has -# changed. cscope can be confused if files are renamed or removed, so it may be -# necessary to remove cscope.out (gmake cscope.clean) if a lot of reorganization -# has occurred. - -include $(GAMMADIR)/make/scm.make - -RM = rm -f -HG = hg -CS_TOP = $(GAMMADIR) - -CSDIRS = $(CS_TOP)/src $(CS_TOP)/make -CSINCS = $(CSDIRS:%=-I%) - -CSCOPE = cscope -CSCOPE_OUT = cscope.out -CSCOPE_FLAGS = -b - -# Allow .java files to be added from the environment (CSCLASSES=yes). -ifdef CSCLASSES -ADDCLASSES= -o -name '*.java' -endif - -# Adding CClassHeaders also pushes the file count of a full workspace up about -# 200 files (these files also don't exist in a new workspace, and thus will -# cause the recreation of the database as they get created, which might seem -# a little confusing). Thus allow these files to be added from the environment -# (CSHEADERS=yes). -ifndef CSHEADERS -RMCCHEADERS= -o -name CClassHeaders -endif - -# Ignore build products. -CS_PRUNE_GENERATED = -o -name '${OSNAME}_*_core' -o \ - -name '${OSNAME}_*_compiler?' - -# O/S-specific files for all systems are included by default. Set CS_OS to a -# space-separated list of identifiers to include only those systems. -ifdef CS_OS -CS_PRUNE_OS = $(patsubst %,-o -name '*%*',\ - $(filter-out ${CS_OS},bsd linux macos solaris windows)) -endif - -# CPU-specific files for all processors are included by default. Set CS_CPU -# space-separated list identifiers to include only those CPUs. -ifdef CS_CPU -CS_PRUNE_CPU = $(patsubst %,-o -name '*%*',\ - $(filter-out ${CS_CPU},arm ppc sparc x86 zero)) -endif - -# What files should we include? A simple rule might be just those files under -# SCCS control, however this would miss files we create like the opcodes and -# CClassHeaders. The following attempts to find everything that is *useful*. -# (.del files are created by sccsrm, demo directories contain many .java files -# that probably aren't useful for development, and the pkgarchive may contain -# duplicates of files within the source hierarchy). - -# Directories to exclude. -CS_PRUNE_STD = $(SCM_DIRS) \ - -o -name '.del-*' \ - -o -name '*demo' \ - -o -name pkgarchive - -# Placeholder for user-defined excludes. -CS_PRUNE_EX = - -CS_PRUNE = $(CS_PRUNE_STD) \ - $(CS_PRUNE_OS) \ - $(CS_PRUNE_CPU) \ - $(CS_PRUNE_GENERATED) \ - $(CS_PRUNE_EX) \ - $(RMCCHEADERS) - -# File names to include. -CSFILENAMES = -name '*.[ch]pp' \ - -o -name '*.[Ccshlxy]' \ - $(CS_ADD_GENERATED) \ - -o -name '*.d' \ - -o -name '*.il' \ - -o -name '*.cc' \ - -o -name '*[Mm]akefile*' \ - -o -name '*.gmk' \ - -o -name '*.make' \ - -o -name '*.ad' \ - $(ADDCLASSES) - -.PHONY: cscope cscope.clean cscope.scratch TAGS.clean FORCE -.PRECIOUS: cscope.out - -cscope $(CSCOPE_OUT): cscope.files FORCE - $(CSCOPE) -f $(CSCOPE_OUT) $(CSCOPE_FLAGS) - -cscope.clean: - $(QUIETLY) $(RM) $(CSCOPE_OUT) cscope.files - -cscope.scratch: cscope.clean cscope - -# The raw list is reordered so cscope displays the most relevant files first. -cscope.files: - $(QUIETLY) \ - raw=cscope.$$$$; \ - find $(CSDIRS) -type d \( $(CS_PRUNE) \) -prune -o \ - -type f \( $(CSFILENAMES) \) -print > $$raw; \ - { \ - echo "$(CSINCS)"; \ - egrep -v "\.java|/make/" $$raw; \ - fgrep ".java" $$raw; \ - fgrep "/make/" $$raw; \ - } > $@; \ - rm -f $$raw - -TAGS: cscope.files FORCE - egrep -v '^-|^$$' $< | etags --members - - -TAGS.clean: - $(RM) TAGS diff --git a/hotspot/make/defs.make b/hotspot/make/defs.make deleted file mode 100644 index e02d660f349..00000000000 --- a/hotspot/make/defs.make +++ /dev/null @@ -1,362 +0,0 @@ -# -# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# The common definitions for hotspot builds. - -# Optionally include SPEC file generated by configure. -ifneq ($(SPEC),) - include $(SPEC) -endif - -ifeq ($(LOG_LEVEL),warn) - LOG_INFO := > /dev/null -else - LOG_INFO := -endif - -# Directory paths and user name -# Unless GAMMADIR is set on the command line, search upward from -# the current directory for a parent directory containing "src/share/vm". -# If that fails, look for $GAMMADIR in the environment. -# When the tree of subdirs is built, this setting is stored in each flags.make. -GAMMADIR := $(shell until ([ -d dev ]&&echo $${GAMMADIR:-/GAMMADIR/}) || ([ -d src/share/vm ]&&pwd); do cd ..; done) -HS_SRC_DIR=$(GAMMADIR)/src -HS_MAKE_DIR=$(GAMMADIR)/make -HS_BUILD_DIR=$(GAMMADIR)/build - -ifeq ($(USER),) - USER=$(USERNAME) -endif - -ifeq ($(HS_ALT_MAKE),) - ifneq ($(OPENJDK),true) - HS_ALT_MAKE=$(GAMMADIR)/make/closed - else - HS_ALT_MAKE=NO_SUCH_PATH - endif -endif - -# -# Include alternate defs.make if it exists -# --include $(HS_ALT_MAKE)/defs.make - -# Default to verbose build logs (show all compile lines): -MAKE_VERBOSE=y - -# Make macros for install files or preparing targets -CD=cd -CP=cp -ECHO=echo -GREP=grep -MKDIR=mkdir -MV=mv -PWD=pwd -RM=rm -f -SED=sed -TAR=tar -ZIPEXE=zip - -define install-file -@$(MKDIR) -p $(@D) -@$(RM) $@ -$(CP) $< $@ -endef - -# MacOS X strongly discourages 'cp -r' and provides 'cp -R' instead. -# May need to have a MacOS X specific definition of install-dir -# sometime in the future. -define install-dir -@$(MKDIR) -p $(@D) -@$(RM) -r $@ -$(CP) -r $< $@ -endef - -define prep-target -@$(MKDIR) -p $(@D) -@$(RM) $@ -endef - -# Default values for JVM_VARIANT* variables if configure hasn't set -# it already. -ifeq ($(JVM_VARIANTS),) - ifeq ($(ZERO_BUILD), true) - ifeq ($(SHARK_BUILD), true) - JVM_VARIANTS:=zeroshark - JVM_VARIANT_ZEROSHARK:=true - else - JVM_VARIANTS:=zero - JVM_VARIANT_ZERO:=true - endif - else - # A default is needed - ifeq ($(BUILD_CLIENT_ONLY), true) - JVM_VARIANTS:=client - JVM_VARIANT_CLIENT:=true - endif - # Further defaults are platform and arch specific - endif -endif - -# hotspot version definitions -include $(GAMMADIR)/make/jdk_version - -# JDK_PREVIOUS_VERSION is only needed to facilitate standalone builds -ifeq ($(JDK_PREVIOUS_VERSION),) - export JDK_PREVIOUS_VERSION=$(STANDALONE_JDK_PREVIOUS_VERSION) -endif -# Java versions needed -ifeq ($(VERSION_MAJOR),) - export VERSION_MAJOR=$(STANDALONE_JDK_MAJOR_VER) -endif -ifeq ($(VERSION_MINOR),) - export VERSION_MINOR=$(STANDALONE_JDK_MINOR_VER) -endif -ifeq ($(VERSION_SECURITY),) - export VERSION_SECURITY=$(STANDALONE_JDK_SECURITY_VER) -endif -ifeq ($(VERSION_PATCH),) - export VERSION_PATCH=$(STANDALONE_JDK_PATCH_VER) -endif -ifeq ($(VERSION_BUILD),) - export VERSION_BUILD=0 -endif -ifeq ($(VERSION_SHORT),) - export VERSION_SHORT=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_SECURITY) -endif -ifeq ($(VERSION_STRING),) - # Note that this is an extremely rough and incorrect approximation of a correct version string. - export VERSION_STRING=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_SECURITY)-internal -endif - -ifneq ($(HOTSPOT_RELEASE_VERSION),) - # Allow old command-line overrides - HOTSPOT_VERSION_STRING := $(HOTSPOT_RELEASE_VERSION) -else - # Normally get from surrounding JDK build - HOTSPOT_VERSION_STRING := $(VERSION_STRING) -endif - -ifneq ($(HOTSPOT_BUILD_VERSION),) - # If old command-lines variable exists, append to version string - HOTSPOT_VERSION_STRING := $(HOTSPOT_VERSION_STRING)-$(HOTSPOT_BUILD_VERSION) -else - ifeq ($(SPEC),) - # If building standalone, add -internal. - HOTSPOT_VERSION_STRING := $(HOTSPOT_VERSION_STRING)-internal - endif -endif - -# Windows should have OS predefined -ifeq ($(OS),) - OS := $(shell uname -s) - ifneq ($(findstring BSD,$(OS)),) - OS=bsd - endif - ifeq ($(OS), Darwin) - OS=bsd - endif - HOST := $(shell uname -n) -endif - -# If not SunOS, not Linux not BSD and not AIX, assume Windows -ifneq ($(OS), Linux) - ifneq ($(OS), SunOS) - ifneq ($(OS), bsd) - ifneq ($(OS), AIX) - OSNAME=windows - else - OSNAME=aix - endif - else - OSNAME=bsd - endif - else - OSNAME=solaris - endif -else - OSNAME=linux -endif - -# Determinations of default make arguments and platform specific settings -MAKE_ARGS= - -# ARCH_DATA_MODEL==64 is equivalent to LP64=1 -ifeq ($(ARCH_DATA_MODEL), 64) - ifndef LP64 - LP64 := 1 - endif -endif - -# Defaults set for product build -EXPORT_SUBDIR= - -# Change default /java path if requested -ifneq ($(ALT_SLASH_JAVA),) - SLASH_JAVA=$(ALT_SLASH_JAVA) -endif - -# Default OUTPUTDIR -OUTPUTDIR=$(HS_BUILD_DIR)/$(OSNAME) -ifneq ($(ALT_OUTPUTDIR),) - OUTPUTDIR=$(ALT_OUTPUTDIR) -endif - -# Find latest promoted JDK area -JDK_IMPORT_PATH=$(SLASH_JAVA)/re/j2se/$(VERSION_STRING)/promoted/latest/binaries/$(PLATFORM) -ifneq ($(ALT_JDK_IMPORT_PATH),) - JDK_IMPORT_PATH=$(ALT_JDK_IMPORT_PATH) -endif - -# Other parts of JDK build may require an import JDK that can be executed -# on the build host. For cross-compile builds we also need an import JDK -# that matches the target arch, so for that we set ALT_JDK_TARGET_IMPORT_PATH -ifneq ($(ALT_JDK_TARGET_IMPORT_PATH),) - JDK_IMPORT_PATH=$(ALT_JDK_TARGET_IMPORT_PATH) -endif - -# Find JDK used for javac compiles -BOOTDIR=$(SLASH_JAVA)/re/j2se/$(JDK_PREVIOUS_VERSION)/latest/binaries/$(PLATFORM) -ifneq ($(ALT_BOOTDIR),) - BOOTDIR=$(ALT_BOOTDIR) -endif - -# Select name of the export directory and honor ALT overrides -EXPORT_PATH=$(OUTPUTDIR)/export-$(PLATFORM)$(EXPORT_SUBDIR) -ifneq ($(ALT_EXPORT_PATH),) - EXPORT_PATH=$(ALT_EXPORT_PATH) -endif - -# Default jdk image if one is created for you with create_jdk -JDK_IMAGE_DIR=$(OUTPUTDIR)/jdk-$(PLATFORM) -ifneq ($(ALT_JDK_IMAGE_DIR),) - JDK_IMAGE_DIR=$(ALT_JDK_IMAGE_DIR) -endif - -# The platform dependent defs.make defines platform specific variable such -# as ARCH, EXPORT_LIST etc. We must place the include here after BOOTDIR is defined. -include $(GAMMADIR)/make/$(OSNAME)/makefiles/defs.make - -# We are trying to put platform specific defintions -# files to make/$(OSNAME)/makefiles dictory. However -# some definitions are common for both linux and solaris, -# so we put them here. -ifneq ($(OSNAME),windows) - ABS_OUTPUTDIR := $(shell mkdir -p $(OUTPUTDIR); $(CD) $(OUTPUTDIR); $(PWD)) - ABS_BOOTDIR := $(shell $(CD) $(BOOTDIR); $(PWD)) - ABS_GAMMADIR := $(shell $(CD) $(GAMMADIR); $(PWD)) - ABS_OS_MAKEFILE := $(shell $(CD) $(HS_MAKE_DIR)/$(OSNAME); $(PWD))/Makefile - - # uname, HotSpot source directory, build directory and JDK use different names - # for CPU architectures. - # ARCH - uname output - # SRCARCH - where to find HotSpot cpu and os_cpu source files - # BUILDARCH - build directory - # LIBARCH - directory name in JDK/JRE - - # Use uname output for SRCARCH, but deal with platform differences. If ARCH - # is not explicitly listed below, it is treated as x86. - SRCARCH ?= $(ARCH/$(filter sparc sparc64 ia64 amd64 x86_64 ppc ppc64 ppc64le aarch64 zero,$(ARCH))) - ARCH/ = x86 - ARCH/sparc = sparc - ARCH/sparc64= sparc - ARCH/ia64 = ia64 - ARCH/amd64 = x86 - ARCH/x86_64 = x86 - ARCH/ppc64 = ppc - ARCH/ppc64le= ppc - ARCH/ppc = ppc - ARCH/aarch64= aarch64 - ARCH/zero = zero - - # BUILDARCH is usually the same as SRCARCH, except for sparcv9 - BUILDARCH ?= $(SRCARCH) - ifeq ($(BUILDARCH), x86) - ifdef LP64 - BUILDARCH = amd64 - else - BUILDARCH = i486 - endif - endif - ifeq ($(BUILDARCH), sparc) - ifdef LP64 - BUILDARCH = sparcv9 - endif - endif - ifeq ($(BUILDARCH), ppc) - ifdef LP64 - BUILDARCH = ppc64 - endif - endif - - # LIBARCH is 1:1 mapping from BUILDARCH, except for ARCH=ppc64le - ifeq ($(ARCH),ppc64le) - LIBARCH ?= ppc64le - else - LIBARCH ?= $(LIBARCH/$(BUILDARCH)) - endif - - LIBARCH/i486 = i386 - LIBARCH/amd64 = amd64 - LIBARCH/sparc = sparc - LIBARCH/sparcv9 = sparcv9 - LIBARCH/ia64 = ia64 - LIBARCH/ppc64 = ppc64 - LIBARCH/aarch64 = aarch64 - LIBARCH/zero = $(ZERO_LIBARCH) - - LP64_ARCH = sparcv9 amd64 ia64 ppc64 aarch64 zero -endif - -# Required make macro settings for all platforms -MAKE_ARGS += BOOTDIR=$(ABS_BOOTDIR) -MAKE_ARGS += OUTPUTDIR=$(ABS_OUTPUTDIR) -MAKE_ARGS += GAMMADIR=$(ABS_GAMMADIR) -MAKE_ARGS += MAKE_VERBOSE=$(MAKE_VERBOSE) -MAKE_ARGS += VERSION_STRING=$(VERSION_STRING) - -MAKE_ARGS += BOOT_JDK_SOURCETARGET="$(BOOT_JDK_SOURCETARGET)" - -# Various export sub directories -EXPORT_INCLUDE_DIR = $(EXPORT_PATH)/include -EXPORT_DOCS_DIR = $(EXPORT_PATH)/docs -EXPORT_LIB_DIR = $(EXPORT_PATH)/lib -EXPORT_BIN_DIR = $(EXPORT_PATH)/bin -EXPORT_LIB_ARCH_DIR = $(EXPORT_LIB_DIR)/$(LIBARCH) - -# non-universal macosx builds need to appear universal -ifeq ($(OS_VENDOR), Darwin) - ifneq ($(MACOSX_UNIVERSAL), true) - EXPORT_LIB_ARCH_DIR = $(EXPORT_LIB_DIR) - endif -endif - -# Common export list of files -EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jvmti.h -EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jvmticmlr.h -EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jni.h -EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/$(JDK_INCLUDE_SUBDIR)/jni_md.h -EXPORT_LIST += $(EXPORT_INCLUDE_DIR)/jmm.h - -.PHONY: $(HS_ALT_MAKE)/defs.make diff --git a/hotspot/make/excludeSrc.make b/hotspot/make/excludeSrc.make deleted file mode 100644 index cab00edf842..00000000000 --- a/hotspot/make/excludeSrc.make +++ /dev/null @@ -1,131 +0,0 @@ -# -# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -include $(GAMMADIR)/make/altsrc.make - -ifeq ($(INCLUDE_JVMTI), false) - CXXFLAGS += -DINCLUDE_JVMTI=0 - CFLAGS += -DINCLUDE_JVMTI=0 - - Src_Files_EXCLUDE += jvmtiGetLoadedClasses.cpp jvmtiThreadState.cpp jvmtiExtensions.cpp \ - jvmtiImpl.cpp jvmtiManageCapabilities.cpp jvmtiRawMonitor.cpp jvmtiUtil.cpp jvmtiTrace.cpp \ - jvmtiCodeBlobEvents.cpp jvmtiEnv.cpp jvmtiRedefineClasses.cpp jvmtiEnvBase.cpp jvmtiEnvThreadState.cpp \ - jvmtiTagMap.cpp jvmtiEventController.cpp evmCompat.cpp jvmtiEnter.xsl jvmtiExport.cpp \ - jvmtiClassFileReconstituter.cpp -endif - -ifeq ($(INCLUDE_FPROF), false) - CXXFLAGS += -DINCLUDE_FPROF=0 - CFLAGS += -DINCLUDE_FPROF=0 - - Src_Files_EXCLUDE += fprofiler.cpp -endif - -ifeq ($(INCLUDE_VM_STRUCTS), false) - CXXFLAGS += -DINCLUDE_VM_STRUCTS=0 - CFLAGS += -DINCLUDE_VM_STRUCTS=0 - - Src_Files_EXCLUDE += vmStructs.cpp -endif - -ifeq ($(INCLUDE_JNI_CHECK), false) - CXXFLAGS += -DINCLUDE_JNI_CHECK=0 - CFLAGS += -DINCLUDE_JNI_CHECK=0 - - Src_Files_EXCLUDE += jniCheck.cpp -endif - -ifeq ($(INCLUDE_SERVICES), false) - CXXFLAGS += -DINCLUDE_SERVICES=0 - CFLAGS += -DINCLUDE_SERVICES=0 - - Src_Files_EXCLUDE += heapDumper.cpp heapInspection.cpp \ - attachListener_linux.cpp attachListener.cpp -endif - -ifeq ($(INCLUDE_MANAGEMENT), false) - CXXFLAGS += -DINCLUDE_MANAGEMENT=0 - CFLAGS += -DINCLUDE_MANAGEMENT=0 -endif - -ifeq ($(INCLUDE_CDS), false) - CXXFLAGS += -DINCLUDE_CDS=0 - CFLAGS += -DINCLUDE_CDS=0 - - Src_Files_EXCLUDE += classListParser.cpp classLoaderExt.cpp \ - filemap.cpp metaspaceShared*.cpp sharedClassUtil.cpp sharedPathsMiscInfo.cpp \ - systemDictionaryShared.cpp -endif - -ifeq ($(INCLUDE_ALL_GCS), false) - CXXFLAGS += -DINCLUDE_ALL_GCS=0 - CFLAGS += -DINCLUDE_ALL_GCS=0 - - gc_dir := $(HS_COMMON_SRC)/share/vm/gc - gc_dir_alt := $(HS_ALT_SRC)/share/vm/gc - gc_subdirs := cms g1 parallel - gc_exclude := $(foreach gc,$(gc_subdirs), \ - $(notdir $(wildcard $(gc_dir)/$(gc)/*.cpp)) \ - $(notdir $(wildcard $(gc_dir_alt)/$(gc)/*.cpp))) - Src_Files_EXCLUDE += $(gc_exclude) \ - concurrentGCThread.cpp \ - plab.cpp - - # src/share/vm/services - Src_Files_EXCLUDE += \ - g1MemoryPool.cpp \ - psMemoryPool.cpp -endif - -ifeq ($(INCLUDE_NMT), false) - CXXFLAGS += -DINCLUDE_NMT=0 - CFLAGS += -DINCLUDE_NMT=0 - - Src_Files_EXCLUDE += \ - memBaseline.cpp memReporter.cpp mallocTracker.cpp virtualMemoryTracker.cpp nmtCommon.cpp \ - memTracker.cpp nmtDCmd.cpp mallocSiteTable.cpp -endif - -ifneq (,$(findstring $(Platform_arch_model), aarch64, arm_64, sparc, x86_64)) - # JVMCI is supported -else - INCLUDE_JVMCI := false -endif - -ifeq ($(INCLUDE_JVMCI), false) - CXXFLAGS += -DINCLUDE_JVMCI=0 - CFLAGS += -DINCLUDE_JVMCI=0 - - jvmci_dir := $(HS_COMMON_SRC)/share/vm/jvmci - jvmci_dir_alt := $(HS_ALT_SRC)/share/vm/jvmci - jvmci_exclude := $(notdir $(wildcard $(jvmci_dir)/*.cpp)) \ - $(notdir $(wildcard $(jvmci_dir_alt)/*.cpp)) - Src_Files_EXCLUDE += $(jvmci_exclude) \ - jvmciCodeInstaller_aarch64.cpp jvmciCodeInstaller_ppc.cpp jvmciCodeInstaller_sparc.cpp \ - jvmciCodeInstaller_x86.cpp -endif - --include $(HS_ALT_MAKE)/excludeSrc.make - -.PHONY: $(HS_ALT_MAKE)/excludeSrc.make diff --git a/hotspot/makefiles/gensrc/GenerateSources.gmk b/hotspot/make/gensrc/GenerateSources.gmk similarity index 100% rename from hotspot/makefiles/gensrc/GenerateSources.gmk rename to hotspot/make/gensrc/GenerateSources.gmk diff --git a/hotspot/makefiles/gensrc/GensrcAdlc.gmk b/hotspot/make/gensrc/GensrcAdlc.gmk similarity index 100% rename from hotspot/makefiles/gensrc/GensrcAdlc.gmk rename to hotspot/make/gensrc/GensrcAdlc.gmk diff --git a/hotspot/makefiles/gensrc/GensrcDtrace.gmk b/hotspot/make/gensrc/GensrcDtrace.gmk similarity index 100% rename from hotspot/makefiles/gensrc/GensrcDtrace.gmk rename to hotspot/make/gensrc/GensrcDtrace.gmk diff --git a/hotspot/makefiles/gensrc/GensrcJvmti.gmk b/hotspot/make/gensrc/GensrcJvmti.gmk similarity index 100% rename from hotspot/makefiles/gensrc/GensrcJvmti.gmk rename to hotspot/make/gensrc/GensrcJvmti.gmk diff --git a/hotspot/make/hotspot_distro b/hotspot/make/hotspot_distro deleted file mode 100644 index 059f4d1f547..00000000000 --- a/hotspot/make/hotspot_distro +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# This file format must remain compatible with both -# GNU Makefile and Microsoft nmake formats. -# - -# Don't put quotes (fail windows build). -HOTSPOT_VM_DISTRO=Java HotSpot(TM) -COMPANY_NAME=Oracle Corporation -PRODUCT_NAME=Java(TM) Platform SE diff --git a/hotspot/makefiles/ide/CreateVSProject.gmk b/hotspot/make/ide/CreateVSProject.gmk similarity index 98% rename from hotspot/makefiles/ide/CreateVSProject.gmk rename to hotspot/make/ide/CreateVSProject.gmk index d804dcce9a8..d6f5324adb8 100644 --- a/hotspot/makefiles/ide/CreateVSProject.gmk +++ b/hotspot/make/ide/CreateVSProject.gmk @@ -90,7 +90,7 @@ ifeq ($(OPENJDK_TARGET_OS), windows) $(eval $(call SetupJavaCompilation, BUILD_PROJECT_CREATOR, \ SETUP := GENERATE_OLDBYTECODE, \ ADD_JAVAC_FLAGS := -Xlint:-auxiliaryclass, \ - SRC := $(HOTSPOT_TOPDIR)/makefiles/src/classes, \ + SRC := $(HOTSPOT_TOPDIR)/make/src/classes, \ BIN := $(TOOLS_OUTPUTDIR), \ )) diff --git a/hotspot/make/jdk_version b/hotspot/make/jdk_version deleted file mode 100644 index 90b509ed4c2..00000000000 --- a/hotspot/make/jdk_version +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# Master JDK version file. These values may be overridden by a control -# workspace build. This file format must remain compatible with both -# GNU Makefile and Microsoft nmake formats. -# - -# Don't put quotes (fail windows build). -HOTSPOT_VM_COPYRIGHT=Copyright 2015 - -STANDALONE_JDK_MAJOR_VER=9 -STANDALONE_JDK_MINOR_VER=0 -STANDALONE_JDK_SECURITY_VER=0 -STANDALONE_JDK_PATCH_VER=0 - -# Previous (bootdir) JDK version -STANDALONE_JDK_PREVIOUS_VERSION=1.8.0 diff --git a/hotspot/make/jprt.gmk b/hotspot/make/jprt.gmk deleted file mode 100644 index 41db0685c93..00000000000 --- a/hotspot/make/jprt.gmk +++ /dev/null @@ -1,77 +0,0 @@ -# -# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# JPRT rule to build this workspace - -JPRT_ARCHIVE_BUNDLE=$(ABS_OUTPUTDIR)/$(JPRT_BUILD_FLAVOR)-bundle.zip - -ifeq ($(OSNAME),windows) - ZIPFLAGS=-q -else - # store symbolic links as the link - ZIPFLAGS=-q -y -endif - -jprt_build_productEmb: - $(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_product - -jprt_build_debugEmb: - $(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_debug - -jprt_build_fastdebugEmb: - $(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_fastdebug - -jprt_build_optimizedEmb: - $(MAKE) JAVASE_EMBEDDED=true MINIMIZE_RAM_USAGE=true jprt_build_optimized - -jprt_build_productOpen: - $(MAKE) OPENJDK=true jprt_build_product - -jprt_build_debugOpen: - $(MAKE) OPENJDK=true jprt_build_debug - -jprt_build_fastdebugOpen: - $(MAKE) OPENJDK=true jprt_build_fastdebug - -jprt_build_optimizedOpen: - $(MAKE) OPENJDK=true jprt_build_optimized - -jprt_build_product: all_product copy_product_jdk export_product_jdk - ( $(CD) $(JDK_IMAGE_DIR) && \ - $(ZIPEXE) $(ZIPFLAGS) -r $(JPRT_ARCHIVE_BUNDLE) . ) - -jprt_build_fastdebug: all_fastdebug copy_fastdebug_jdk export_fastdebug_jdk - ( $(CD) $(JDK_IMAGE_DIR)/fastdebug && \ - $(ZIPEXE) $(ZIPFLAGS) -r $(JPRT_ARCHIVE_BUNDLE) . ) - -jprt_build_debug: all_debug copy_debug_jdk export_debug_jdk - ( $(CD) $(JDK_IMAGE_DIR)/debug && \ - $(ZIPEXE) $(ZIPFLAGS) -r $(JPRT_ARCHIVE_BUNDLE) . ) - -jprt_build_optimized: all_optimized copy_optimized_jdk export_optimized_jdk - ( $(CD) $(JDK_IMAGE_DIR)/optimized && \ - $(ZIPEXE) $(ZIPFLAGS) -r $(JPRT_ARCHIVE_BUNDLE) . ) - -.PHONY: jprt_build_product jprt_build_fastdebug jprt_build_debug jprt_build_optimized - diff --git a/hotspot/makefiles/lib/CompileDtracePostJvm.gmk b/hotspot/make/lib/CompileDtracePostJvm.gmk similarity index 98% rename from hotspot/makefiles/lib/CompileDtracePostJvm.gmk rename to hotspot/make/lib/CompileDtracePostJvm.gmk index 127460a562e..50a7f10d67d 100644 --- a/hotspot/makefiles/lib/CompileDtracePostJvm.gmk +++ b/hotspot/make/lib/CompileDtracePostJvm.gmk @@ -186,7 +186,7 @@ ifeq ($(call check-jvm-feature, dtrace), true) CFLAGS := -m64 -G -mt -KPIC, \ LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \ LIBS := $(LIBDL) -lc -lthread -ldoor, \ - MAPFILE := $(HOTSPOT_TOPDIR)/makefiles/mapfiles/libjvm_dtrace/mapfile-vers, \ + MAPFILE := $(HOTSPOT_TOPDIR)/make/mapfiles/libjvm_dtrace/mapfile-vers, \ OBJECT_DIR := $(LIBJVM_DTRACE_OUTPUTDIR)/objs, \ STRIP_SYMBOLS := true, \ )) @@ -204,7 +204,7 @@ ifeq ($(call check-jvm-feature, dtrace), true) -m64 -G -mt -KPIC, \ LDFLAGS := -m64 -mt -xnolib $(SHARED_LIBRARY_FLAGS), \ LIBS := -lc, \ - MAPFILE := $(HOTSPOT_TOPDIR)/makefiles/mapfiles/libjvm_db/mapfile-vers, \ + MAPFILE := $(HOTSPOT_TOPDIR)/make/mapfiles/libjvm_db/mapfile-vers, \ OBJECT_DIR := $(LIBJVM_DB_OUTPUTDIR)/objs, \ STRIP_SYMBOLS := true, \ )) diff --git a/hotspot/makefiles/lib/CompileDtracePreJvm.gmk b/hotspot/make/lib/CompileDtracePreJvm.gmk similarity index 100% rename from hotspot/makefiles/lib/CompileDtracePreJvm.gmk rename to hotspot/make/lib/CompileDtracePreJvm.gmk diff --git a/hotspot/makefiles/lib/CompileJvm.gmk b/hotspot/make/lib/CompileJvm.gmk similarity index 100% rename from hotspot/makefiles/lib/CompileJvm.gmk rename to hotspot/make/lib/CompileJvm.gmk diff --git a/hotspot/makefiles/lib/CompileLibjsig.gmk b/hotspot/make/lib/CompileLibjsig.gmk similarity index 97% rename from hotspot/makefiles/lib/CompileLibjsig.gmk rename to hotspot/make/lib/CompileLibjsig.gmk index ba9791cdef8..1c9a10fbf5c 100644 --- a/hotspot/makefiles/lib/CompileLibjsig.gmk +++ b/hotspot/make/lib/CompileLibjsig.gmk @@ -79,7 +79,7 @@ ifneq ($(OPENJDK_TARGET_OS), windows) endif LIBJSIG_SRC_FILE := $(HOTSPOT_TOPDIR)/src/os/$(HOTSPOT_TARGET_OS)/vm/jsig.c - LIBJSIG_MAPFILE := $(wildcard $(HOTSPOT_TOPDIR)/makefiles/mapfiles/libjsig/mapfile-vers-$(OPENJDK_TARGET_OS)) + LIBJSIG_MAPFILE := $(wildcard $(HOTSPOT_TOPDIR)/make/mapfiles/libjsig/mapfile-vers-$(OPENJDK_TARGET_OS)) LIBJSIG_OUTPUTDIR := $(HOTSPOT_OUTPUTDIR)/libjsig LIBJSIG_LDFLAGS += $(SHARED_LIBRARY_FLAGS) diff --git a/hotspot/makefiles/lib/CompileLibraries.gmk b/hotspot/make/lib/CompileLibraries.gmk similarity index 100% rename from hotspot/makefiles/lib/CompileLibraries.gmk rename to hotspot/make/lib/CompileLibraries.gmk diff --git a/hotspot/makefiles/lib/JvmFeatures.gmk b/hotspot/make/lib/JvmFeatures.gmk similarity index 100% rename from hotspot/makefiles/lib/JvmFeatures.gmk rename to hotspot/make/lib/JvmFeatures.gmk diff --git a/hotspot/makefiles/lib/JvmMapfile.gmk b/hotspot/make/lib/JvmMapfile.gmk similarity index 90% rename from hotspot/makefiles/lib/JvmMapfile.gmk rename to hotspot/make/lib/JvmMapfile.gmk index 9d7655b26ee..4ad3e99512b 100644 --- a/hotspot/makefiles/lib/JvmMapfile.gmk +++ b/hotspot/make/lib/JvmMapfile.gmk @@ -31,20 +31,20 @@ $(eval $(call IncludeCustomExtension, hotspot, lib/JvmMapfile.gmk)) ifneq ($(OPENJDK_TARGET_OS)-$(OPENJDK_TARGET_CPU), windows-x86_64) # On Windows x86_64, we should not have any symbols at all, since that # results in duplicate warnings from the linker (JDK-8043491). - SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-shared + SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/make/symbols/symbols-shared endif ifeq ($(OPENJDK_TARGET_OS_TYPE), unix) - SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-unix + SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/make/symbols/symbols-unix endif -ifneq ($(wildcard $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-$(OPENJDK_TARGET_OS)), ) - SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-$(OPENJDK_TARGET_OS) +ifneq ($(wildcard $(HOTSPOT_TOPDIR)/make/symbols/symbols-$(OPENJDK_TARGET_OS)), ) + SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/make/symbols/symbols-$(OPENJDK_TARGET_OS) endif ifneq ($(findstring debug, $(DEBUG_LEVEL)), ) - ifneq ($(wildcard $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-$(OPENJDK_TARGET_OS)-debug), ) - SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-$(OPENJDK_TARGET_OS)-debug + ifneq ($(wildcard $(HOTSPOT_TOPDIR)/make/symbols/symbols-$(OPENJDK_TARGET_OS)-debug), ) + SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/make/symbols/symbols-$(OPENJDK_TARGET_OS)-debug endif endif @@ -53,9 +53,9 @@ ifeq ($(OPENJDK_TARGET_OS), solaris) # Additional mapfiles that are only used when dtrace is enabled ifeq ($(call check-jvm-feature, compiler2), true) # This also covers the case of compiler1+compiler2. - SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-solaris-dtrace-compiler2 + SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/make/symbols/symbols-solaris-dtrace-compiler2 else ifeq ($(call check-jvm-feature, compiler1), true) - SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/makefiles/symbols/symbols-solaris-dtrace-compiler1 + SYMBOLS_SRC += $(HOTSPOT_TOPDIR)/make/symbols/symbols-solaris-dtrace-compiler1 endif endif endif diff --git a/hotspot/makefiles/lib/JvmOverrideFiles.gmk b/hotspot/make/lib/JvmOverrideFiles.gmk similarity index 100% rename from hotspot/makefiles/lib/JvmOverrideFiles.gmk rename to hotspot/make/lib/JvmOverrideFiles.gmk diff --git a/hotspot/make/linux/Makefile b/hotspot/make/linux/Makefile deleted file mode 100644 index dba28625eec..00000000000 --- a/hotspot/make/linux/Makefile +++ /dev/null @@ -1,385 +0,0 @@ -# -# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile creates a build tree and lights off a build. -# You can go back into the build tree and perform rebuilds or -# incremental builds as desired. Be sure to reestablish -# environment variable settings for LD_LIBRARY_PATH and JAVA_HOME. - -# The make process now relies on java and javac. These can be -# specified either implicitly on the PATH, by setting the -# (JDK-inherited) ALT_BOOTDIR environment variable to full path to a -# JDK in which bin/java and bin/javac are present and working (e.g., -# /usr/local/java/jdk1.3/solaris), or via the (JDK-inherited) -# default BOOTDIR path value. Note that one of ALT_BOOTDIR -# or BOOTDIR has to be set. We do *not* search javac, javah, rmic etc. -# from the PATH. -# -# One can set ALT_BOOTDIR or BOOTDIR to point to a jdk that runs on -# an architecture that differs from the target architecture, as long -# as the bootstrap jdk runs under the same flavor of OS as the target -# (i.e., if the target is linux, point to a jdk that runs on a linux -# box). In order to use such a bootstrap jdk, set the make variable -# REMOTE to the desired remote command mechanism, e.g., -# -# make REMOTE="rsh -l me myotherlinuxbox" - -ifeq ($(GAMMADIR),) -include ../../make/defs.make -else -include $(GAMMADIR)/make/defs.make -endif -include $(GAMMADIR)/make/$(OSNAME)/makefiles/rules.make - -ifndef CC_INTERP - ifndef FORCE_TIERED - FORCE_TIERED=1 - endif -endif - -ifdef LP64 - ifeq ("$(filter $(LP64_ARCH),$(BUILDARCH))","") - _JUNK_ := $(shell echo >&2 \ - $(OSNAME) $(ARCH) "*** ERROR: this platform does not support 64-bit compilers!") - @exit 1 - endif -endif - -# we need to set up LP64 correctly to satisfy sanity checks in adlc -ifneq ("$(filter $(LP64_ARCH),$(BUILDARCH))","") - MFLAGS += " LP64=1 " -endif - -# pass USE_SUNCC further, through MFLAGS -ifdef USE_SUNCC - MFLAGS += " USE_SUNCC=1 " -endif - -# The following renders pathnames in generated Makefiles valid on -# machines other than the machine containing the build tree. -# -# For example, let's say my build tree lives on /files12 on -# exact.east.sun.com. This logic will cause GAMMADIR to begin with -# /net/exact/files12/... -# -# We only do this on SunOS variants, for a couple of reasons: -# * It is extremely rare that source trees exist on other systems -# * It has been claimed that the Linux automounter is flakey, so -# changing GAMMADIR in a way that exercises the automounter could -# prove to be a source of unreliability in the build process. -# Obviously, this Makefile is only relevant on SunOS boxes to begin -# with, but the SunOS conditionalization will make it easier to -# combine Makefiles in the future (assuming we ever do that). - -ifeq ($(OSNAME),solaris) - - # prepend current directory to relative pathnames. - NEW_GAMMADIR := \ - $(shell echo $(GAMMADIR) | \ - sed -e "s=^\([^/].*\)=$(shell pwd)/\1=" \ - ) - unexport NEW_GAMMADIR - - # If NEW_GAMMADIR doesn't already start with "/net/": - ifeq ($(strip $(filter /net/%,$(NEW_GAMMADIR))),) - # prepend /net/$(HOST) - # remove /net/$(HOST) if name already began with /home/ - # remove /net/$(HOST) if name already began with /java/ - # remove /net/$(HOST) if name already began with /lab/ - NEW_GAMMADIR := \ - $(shell echo $(NEW_GAMMADIR) | \ - sed -e "s=^\(.*\)=/net/$(HOST)\1=" \ - -e "s=^/net/$(HOST)/home/=/home/=" \ - -e "s=^/net/$(HOST)/java/=/java/=" \ - -e "s=^/net/$(HOST)/lab/=/lab/=" \ - ) - # Don't use the new value for GAMMADIR unless a file with the new - # name actually exists. - ifneq ($(wildcard $(NEW_GAMMADIR)),) - GAMMADIR := $(NEW_GAMMADIR) - endif - endif - -endif - -# BUILDARCH is set to "zero" for Zero builds. VARIANTARCH -# is used to give the build directories meaningful names. -VARIANTARCH = $(subst i386,i486,$(ZERO_LIBARCH)) - -# There is a (semi-) regular correspondence between make targets and actions: -# -# Target Tree Type Build Dir -# -# debug compiler2 __compiler2/debug -# fastdebug compiler2 __compiler2/fastdebug -# optimized compiler2 __compiler2/optimized -# product compiler2 __compiler2/product -# -# debug1 compiler1 __compiler1/debug -# fastdebug1 compiler1 __compiler1/fastdebug -# optimized1 compiler1 __compiler1/optimized -# product1 compiler1 __compiler1/product -# -# debugcore core __core/debug -# fastdebugcore core __core/fastdebug -# optimizedcore core __core/optimized -# productcore core __core/product -# -# debugzero zero __zero/debug -# fastdebugzero zero __zero/fastdebug -# optimizedzero zero __zero/optimized -# productzero zero __zero/product -# -# debugshark shark __shark/debug -# fastdebugshark shark __shark/fastdebug -# optimizedshark shark __shark/optimized -# productshark shark __shark/product -# -# fastdebugminimal1 minimal1 __minimal1/fastdebug -# productminimal1 minimal1 __minimal1/product -# -# What you get with each target: -# -# debug* - debug compile with asserts enabled -# fastdebug* - optimized compile, but with asserts enabled -# optimized* - optimized compile, no asserts -# product* - the shippable thing: optimized compile, no asserts, -DPRODUCT - -# This target list needs to be coordinated with the usage message -# in the build.sh script: -TARGETS = debug fastdebug optimized product - -ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - SUBDIR_DOCS = $(OSNAME)_$(VARIANTARCH)_docs -else - SUBDIR_DOCS = $(OSNAME)_$(BUILDARCH)_docs -endif -SUBDIRS_C1 = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler1/,$(TARGETS)) -SUBDIRS_C2 = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS)) -SUBDIRS_TIERED = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS)) -SUBDIRS_CORE = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS)) -SUBDIRS_ZERO = $(addprefix $(OSNAME)_$(VARIANTARCH)_zero/,$(TARGETS)) -SUBDIRS_SHARK = $(addprefix $(OSNAME)_$(VARIANTARCH)_shark/,$(TARGETS)) -SUBDIRS_MINIMAL1 = $(addprefix $(OSNAME)_$(BUILDARCH)_minimal1/,$(TARGETS)) - -TARGETS_C2 = $(TARGETS) -TARGETS_C1 = $(addsuffix 1,$(TARGETS)) -TARGETS_TIERED = $(addsuffix tiered,$(TARGETS)) -TARGETS_CORE = $(addsuffix core,$(TARGETS)) -TARGETS_ZERO = $(addsuffix zero,$(TARGETS)) -TARGETS_SHARK = $(addsuffix shark,$(TARGETS)) -TARGETS_MINIMAL1 = $(addsuffix minimal1,$(TARGETS)) - -BUILDTREE_MAKE = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make -BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) -BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING) -BUILDTREE_VARS += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY) ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) ZIPEXE=$(ZIPEXE) - -BUILDTREE = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS) - -#------------------------------------------------------------------------------- - -# Could make everything by default, but that would take a while. -all: - @echo "Try '$(MAKE) ...' where is one or more of" - @echo " $(TARGETS_C2)" - @echo " $(TARGETS_C1)" - @echo " $(TARGETS_CORE)" - @echo " $(TARGETS_ZERO)" - @echo " $(TARGETS_SHARK)" - @echo " $(TARGETS_MINIMAL1)" - -checks: check_os_version check_j2se_version - -# We do not want people accidentally building on old systems (e.g. Linux 2.2.x, -# Solaris 2.5.1, 2.6). -# Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok. - -SUPPORTED_OS_VERSION = 2.4% 2.5% 2.6% 3% 4% -OS_VERSION := $(shell uname -r) -EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION)) - -check_os_version: -ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),) - $(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1; -endif - -# jvmti.make requires XSLT (J2SE 1.4.x or newer): -XSLT_CHECK = $(REMOTE) $(RUN.JAVAP) javax.xml.transform.TransformerFactory -# If not found then fail fast. -check_j2se_version: - $(QUIETLY) if ! $(XSLT_CHECK) > /dev/null 2>&1; then \ - $(REMOTE) $(RUN.JAVA) -version; \ - echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \ - "to bootstrap this build" 1>&2; \ - exit 1; \ - fi - -$(SUBDIRS_TIERED): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=tiered - -$(SUBDIRS_C2): $(BUILDTREE_MAKE) -ifeq ($(FORCE_TIERED),1) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=tiered FORCE_TIERED=1 -else - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=compiler2 -endif - -$(SUBDIRS_C1): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=compiler1 - -$(SUBDIRS_CORE): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=core - -$(SUBDIRS_ZERO): $(BUILDTREE_MAKE) platform_zero - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=zero VARIANTARCH=$(VARIANTARCH) - -$(SUBDIRS_SHARK): $(BUILDTREE_MAKE) platform_zero - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=shark VARIANTARCH=$(VARIANTARCH) - -$(SUBDIRS_MINIMAL1): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=minimal1 - - -platform_zero: $(GAMMADIR)/make/$(OSNAME)/platform_zero.in - $(SED) 's/@ZERO_ARCHDEF@/$(ZERO_ARCHDEF)/g;s/@ZERO_LIBARCH@/$(ZERO_LIBARCH)/g;' < $< > $@ - -# Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME - -$(TARGETS_C2): $(SUBDIRS_C2) - cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_TIERED): $(SUBDIRS_TIERED) - cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_C1): $(SUBDIRS_C1) - cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_CORE): $(SUBDIRS_CORE) - cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_ZERO): $(SUBDIRS_ZERO) - cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(VARIANTARCH)_zero/$(patsubst %zero,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_SHARK): $(SUBDIRS_SHARK) - cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(VARIANTARCH)_shark/$(patsubst %shark,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_MINIMAL1): $(SUBDIRS_MINIMAL1) - cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_minimal1/$(patsubst %minimal1,%,$@) && $(MAKE) $(MFLAGS) install -endif - -# Just build the tree, and nothing else: -tree: $(SUBDIRS_C2) -tree1: $(SUBDIRS_C1) -treecore: $(SUBDIRS_CORE) -treezero: $(SUBDIRS_ZERO) -treeshark: $(SUBDIRS_SHARK) -treeminimal1: $(SUBDIRS_MINIMAL1) - -# Doc target. This is the same for all build options. -# Hence create a docs directory beside ...$(ARCH)_[...] -# We specify 'BUILD_FLAVOR=product' so that the proper -# ENABLE_FULL_DEBUG_SYMBOLS value is used. -docs: checks - $(QUIETLY) mkdir -p $(SUBDIR_DOCS) - $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/makefiles/jvmti.make $(MFLAGS) $(BUILDTREE_VARS) JvmtiOutDir=$(SUBDIR_DOCS) BUILD_FLAVOR=product jvmtidocs - -# Synonyms for win32-like targets. -compiler2: debug product - -compiler1: debug1 product1 - -core: debugcore productcore - -zero: debugzero productzero - -shark: debugshark productshark - -warn_jvmg_deprecated: - echo "Warning: The jvmg target has been replaced with debug" - echo "Warning: Please update your usage" - -jvmg: warn_jvmg_deprecated debug - -jvmg1: warn_jvmg_deprecated debug1 - -jvmgcore: warn_jvmg_deprecated debugcore - -jvmgzero: warn_jvmg_deprecated debugzero - -jvmgshark: warn_jvmg_deprecated debugshark - -clean_docs: - rm -rf $(SUBDIR_DOCS) - -clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark clean_minimal1: - rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@) - -clean: clean_compiler2 clean_compiler1 clean_core clean_zero clean_shark clean_minimal1 clean_docs - -include $(GAMMADIR)/make/cscope.make - -# -# Include alternate Makefile if it exists. -# --include $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make - -#------------------------------------------------------------------------------- - -.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) $(TARGETS_ZERO) $(TARGETS_SHARK) $(TARGETS_MINIMAL1) -.PHONY: tree tree1 treecore treezero treeshark -.PHONY: all compiler1 compiler2 core zero shark -.PHONY: clean clean_compiler1 clean_compiler2 clean_core clean_zero clean_shark docs clean_docs -.PHONY: checks check_os_version check_j2se_version -.PHONY: $(HS_ALT_MAKE)/$(OSNAME)/Makefile.make - -.NOTPARALLEL: diff --git a/hotspot/make/linux/README b/hotspot/make/linux/README deleted file mode 100644 index d3efaf8b610..00000000000 --- a/hotspot/make/linux/README +++ /dev/null @@ -1,26 +0,0 @@ -Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - -This code is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License version 2 only, as -published by the Free Software Foundation. - -This code is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -version 2 for more details (a copy is included in the LICENSE file that -accompanied this code). - -You should have received a copy of the GNU General Public License version -2 along with this work; if not, write to the Free Software Foundation, -Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - -Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -or visit www.oracle.com if you need additional information or have any -questions. - -________________________________________________________________________ - -Please refer to the comments in the Makefile in this directory -for instructions how to build the Solaris versions. - diff --git a/hotspot/make/linux/adlc_updater b/hotspot/make/linux/adlc_updater deleted file mode 100644 index 99e04e333f2..00000000000 --- a/hotspot/make/linux/adlc_updater +++ /dev/null @@ -1,23 +0,0 @@ -#! /bin/sh -# -# This file is used by adlc.make to selectively update generated -# adlc files. Because source and target diretories are relative -# paths, this file is copied to the target build directory before -# use. -# -# adlc-updater -# -fix_lines() { - # repair bare #line directives in $1 to refer to $2 - # and add an override of __FILE__ with just the basename on the - # first line of the file. - awk < $1 > $1+ -v F2=$2 ' - BEGIN { print "#line 1 \"" F2 "\""; } - /^#line 999999$/ {print "#line " (NR+1) " \"" F2 "\""; next} - {print} - ' - mv $1+ $1 -} -fix_lines $2/$1 $1 -[ -f $3/$1 ] && cmp -s $2/$1 $3/$1 || \ -( [ -f $3/$1 ] && echo Updating $3/$1 ; touch $2/made-change ; mv $2/$1 $3/$1 ) diff --git a/hotspot/make/linux/makefiles/aarch64.make b/hotspot/make/linux/makefiles/aarch64.make deleted file mode 100644 index 9dedb3e29c1..00000000000 --- a/hotspot/make/linux/makefiles/aarch64.make +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT) -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT) -# Must also specify if CPU is little endian -CFLAGS += -DVM_LITTLE_ENDIAN - -CFLAGS += -D_LP64=1 diff --git a/hotspot/make/linux/makefiles/adjust-mflags.sh b/hotspot/make/linux/makefiles/adjust-mflags.sh deleted file mode 100644 index 97bc02db7f1..00000000000 --- a/hotspot/make/linux/makefiles/adjust-mflags.sh +++ /dev/null @@ -1,87 +0,0 @@ -#! /bin/sh -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This script is used only from top.make. -# The macro $(MFLAGS-adjusted) calls this script to -# adjust the "-j" arguments to take into account -# the HOTSPOT_BUILD_JOBS variable. The default -# handling of the "-j" argument by gnumake does -# not meet our needs, so we must adjust it ourselves. - -# This argument adjustment applies to two recursive -# calls to "$(MAKE) $(MFLAGS-adjusted)" in top.make. -# One invokes adlc.make, and the other invokes vm.make. -# The adjustment propagates the desired concurrency -# level down to the sub-make (of the adlc or vm). -# The default behavior of gnumake is to run all -# sub-makes without concurrency ("-j1"). - -# Also, we use a make variable rather than an explicit -# "-j" argument to control this setting, so that -# the concurrency setting (which must be tuned separately -# for each MP system) can be set via an environment variable. -# The recommended setting is 1.5x to 2x the number of available -# CPUs on the MP system, which is large enough to keep the CPUs -# busy (even though some jobs may be I/O bound) but not too large, -# we may presume, to overflow the system's swap space. - -set -eu - -default_build_jobs=4 - -case $# in -[12]) true;; -*) >&2 echo "Usage: $0 ${MFLAGS} ${HOTSPOT_BUILD_JOBS}"; exit 2;; -esac - -MFLAGS=$1 -HOTSPOT_BUILD_JOBS=${2-} - -# Normalize any -jN argument to the form " -j${HBJ}" -MFLAGS=` - echo "$MFLAGS" \ - | sed ' - s/^-/ -/ - s/ -\([^ I][^ I]*\)j/ -\1 -j/ - s/ -j[0-9][0-9]*/ -j/ - s/ -j\([^ ]\)/ -j -\1/ - s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/ - ' ` - -case ${HOTSPOT_BUILD_JOBS} in \ - -'') case ${MFLAGS} in - *\ -j*) - >&2 echo "# Note: -jN is ineffective for setting parallelism in this makefile." - >&2 echo "# please set HOTSPOT_BUILD_JOBS=${default_build_jobs} in the command line or environment." - esac;; - -?*) case ${MFLAGS} in - *\ -j*) true;; - *) MFLAGS="-j${HOTSPOT_BUILD_JOBS} ${MFLAGS}";; - esac;; -esac - -echo "${MFLAGS}" diff --git a/hotspot/make/linux/makefiles/adlc.make b/hotspot/make/linux/makefiles/adlc.make deleted file mode 100644 index 287923151d2..00000000000 --- a/hotspot/make/linux/makefiles/adlc.make +++ /dev/null @@ -1,233 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (adlc.make) is included from the adlc.make in the -# build directories. -# It knows how to compile, link, and run the adlc. - -include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make - -# ######################################################################### - -# OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make: -GENERATED = ../generated -OUTDIR = $(GENERATED)/adfiles - -ARCH = $(Platform_arch) -OS = $(Platform_os_family) - -SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad - -ifeq ("${Platform_arch_model}", "${Platform_arch}") - SOURCES.AD = \ - $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) -else - SOURCES.AD = \ - $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \ - $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) -endif - -EXEC = $(OUTDIR)/adlc - -# set VPATH so make knows where to look for source files -Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc -VPATH += $(Src_Dirs_V:%=%:) - -# set INCLUDES for C preprocessor -Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED) -INCLUDES += $(Src_Dirs_I:%=-I%) - -# set flags for adlc compilation -CXXFLAGS = $(SYSDEFS) $(INCLUDES) - -# Force assertions on. -CXXFLAGS += -DASSERT - -# CFLAGS_WARN holds compiler options to suppress/enable warnings. -# Compiler warnings are treated as errors -CFLAGS_WARN = $(WARNINGS_ARE_ERRORS) -CFLAGS += $(CFLAGS_WARN) - -OBJECTNAMES = \ - adlparse.o \ - archDesc.o \ - arena.o \ - dfa.o \ - dict2.o \ - filebuff.o \ - forms.o \ - formsopt.o \ - formssel.o \ - main.o \ - adlc-opcodes.o \ - output_c.o \ - output_h.o \ - -OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%) - -GENERATEDNAMES = \ - ad_$(Platform_arch_model).cpp \ - ad_$(Platform_arch_model).hpp \ - ad_$(Platform_arch_model)_clone.cpp \ - ad_$(Platform_arch_model)_expand.cpp \ - ad_$(Platform_arch_model)_format.cpp \ - ad_$(Platform_arch_model)_gen.cpp \ - ad_$(Platform_arch_model)_misc.cpp \ - ad_$(Platform_arch_model)_peephole.cpp \ - ad_$(Platform_arch_model)_pipeline.cpp \ - adGlobals_$(Platform_arch_model).hpp \ - dfa_$(Platform_arch_model).cpp \ - -GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%) - -# ######################################################################### - -all: $(EXEC) - -$(EXEC) : $(OBJECTS) - @echo $(LOG_INFO) Making adlc - $(QUIETLY) $(filter-out $(ARCHFLAG),$(HOST.LINK_NOPROF.CXX)) -o $(EXEC) $(OBJECTS) - -# Random dependencies: -$(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp - -# The source files refer to ostream.h, which sparcworks calls iostream.h -$(OBJECTS): ostream.h - -ostream.h : - @echo >$@ '#include ' - -dump: - : OUTDIR=$(OUTDIR) - : OBJECTS=$(OBJECTS) - : products = $(GENERATEDFILES) - -all: $(GENERATEDFILES) - -$(GENERATEDFILES): refresh_adfiles - -# Get a unique temporary directory name, so multiple makes can run in parallel. -# Note that product files are updated via "mv", which is atomic. -TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$) - -ifneq ($(DEBUG_BINARIES), true) - # Debuggable by default (unless already done by DEBUG_BINARIES) - CFLAGS += -g -endif - -# Pass -D flags into ADLC. -ADLCFLAGS += $(SYSDEFS) - -# Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO. -ADLCFLAGS += -q -T - -# Normally, debugging is done directly on the ad_*.cpp files. -# But -g will put #line directives in those files pointing back to .ad. -# Some builds of gcc 3.2 have a bug that gets tickled by the extra #line directives -# so skip it for 3.2 and ealier. -ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" -ADLCFLAGS += -g -endif - -ifdef LP64 -ADLCFLAGS += -D_LP64 -else -ADLCFLAGS += -U_LP64 -endif - -# -# adlc_updater is a simple sh script, under sccs control. It is -# used to selectively update generated adlc files. This should -# provide a nice compilation speed improvement. -# -ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS) -ADLC_UPDATER = adlc_updater -$(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER) - $(QUIETLY) cp $< $@; chmod +x $@ - -# This action refreshes all generated adlc files simultaneously. -# The way it works is this: -# 1) create a scratch directory to work in. -# 2) if the current working directory does not have $(ADLC_UPDATER), copy it. -# 3) run the compiled adlc executable. This will create new adlc files in the scratch directory. -# 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files. -# 5) If we actually updated any files, echo a notice. -# -refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER) - @rm -rf $(TEMPDIR); mkdir $(TEMPDIR) - $(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \ - -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \ - || { rm -rf $(TEMPDIR); exit 1; } - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) [ -f $(TEMPDIR)/made-change ] \ - || echo $(LOG_INFO) "Rescanned $(SOURCE.AD) but encountered no changes." - $(QUIETLY) rm -rf $(TEMPDIR) - - -# ######################################################################### - -$(SOURCE.AD): $(SOURCES.AD) - $(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD) - -#PROCESS_AD_FILES = cat -# Pass through #line directives, in case user enables -g option above: -PROCESS_AD_FILES = awk '{ \ - if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \ - if (need_lineno && $$0 !~ /\/\//) \ - { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \ - print }' - -$(OUTDIR)/%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(filter-out $(ARCHFLAG),$(HOST.COMPILE.CXX)) -o $@ $< $(COMPILE_DONE) - -# Some object files are given a prefix, to disambiguate -# them from objects of the same name built for the VM. -$(OUTDIR)/adlc-%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(filter-out $(ARCHFLAG),$(HOST.COMPILE.CXX)) -o $@ $< $(COMPILE_DONE) - -# ######################################################################### - -clean : - rm $(OBJECTS) - -cleanall : - rm $(OBJECTS) $(EXEC) - -# ######################################################################### - -.PHONY: all dump refresh_adfiles clean cleanall diff --git a/hotspot/make/linux/makefiles/amd64.make b/hotspot/make/linux/makefiles/amd64.make deleted file mode 100644 index c98a5827820..00000000000 --- a/hotspot/make/linux/makefiles/amd64.make +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT) -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT) -# Must also specify if CPU is little endian -CFLAGS += -DVM_LITTLE_ENDIAN - -CFLAGS += -D_LP64=1 - -OPT_CFLAGS/compactingPermGenGen.o = -O1 - -# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides -# of OPT_CFLAGS. Restore it here. -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS/sharedRuntimeTrig.o += -g - OPT_CFLAGS/sharedRuntimeTrans.o += -g - OPT_CFLAGS/compactingPermGenGen.o += -g -endif diff --git a/hotspot/make/linux/makefiles/buildtree.make b/hotspot/make/linux/makefiles/buildtree.make deleted file mode 100644 index b5eb37e01f7..00000000000 --- a/hotspot/make/linux/makefiles/buildtree.make +++ /dev/null @@ -1,368 +0,0 @@ -# -# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Usage: -# -# $(MAKE) -f buildtree.make SRCARCH=srcarch BUILDARCH=buildarch LIBARCH=libarch -# GAMMADIR=dir OS_FAMILY=os VARIANT=variant -# -# The macros ARCH, GAMMADIR, OS_FAMILY and VARIANT must be defined in the -# environment or on the command-line: -# -# ARCH - sparc, i486, ... HotSpot cpu and os_cpu source directory -# BUILDARCH - build directory -# LIBARCH - the corresponding directory in JDK/JRE -# GAMMADIR - top of workspace -# OS_FAMILY - operating system -# VARIANT - core, compiler1, compiler2, or tiered -# VERSION_STRING - the JDK version string as specified by JEP-223 -# HOTSPOT_VERSION_STRING - the same as VERSION_STRING, unless overridden by a standalone build -# -# Builds the directory trees with makefiles plus some convenience files in -# each directory: -# -# Makefile - for "make foo" -# flags.make - with macro settings -# vm.make - to support making "$(MAKE) -v vm.make" in makefiles -# adlc.make - -# trace.make - generate tracing event and type definitions -# jvmti.make - generate JVMTI bindings from the spec (JSR-163) -# -# The makefiles are split this way so that "make foo" will run faster by not -# having to read the dependency files for the vm. - --include $(SPEC) -include $(GAMMADIR)/make/scm.make -include $(GAMMADIR)/make/defs.make -include $(GAMMADIR)/make/altsrc.make - - -# 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details. -QUIETLY$(MAKE_VERBOSE) = @ - -ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - PLATFORM_FILE = $(shell dirname $(shell dirname $(shell pwd)))/platform_zero -else - ifdef USE_SUNCC - PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).suncc - else - PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH) - ALT_PLATFORM_FILE = $(HS_ALT_MAKE)/$(OS_FAMILY)/platform_$(BUILDARCH) - PLATFORM_FILE := $(if $(wildcard $(ALT_PLATFORM_FILE)),$(ALT_PLATFORM_FILE),$(PLATFORM_FILE)) - endif -endif - -# Allow overriding of the arch part of the directory but default -# to BUILDARCH if nothing is specified -ifeq ($(VARIANTARCH),) - VARIANTARCH=$(BUILDARCH) -endif - -ifdef FORCE_TIERED -ifeq ($(VARIANT),tiered) -PLATFORM_DIR = $(OS_FAMILY)_$(VARIANTARCH)_compiler2 -else -PLATFORM_DIR = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT) -endif -else -PLATFORM_DIR = $(OS_FAMILY)_$(VARIANTARCH)_$(VARIANT) -endif - -# -# We do two levels of exclusion in the shared directory. -# TOPLEVEL excludes are pruned, they are not recursively searched, -# but lower level directories can be named without fear of collision. -# ALWAYS excludes are excluded at any level in the directory tree. -# - -ALWAYS_EXCLUDE_DIRS = $(SCM_DIRS) - -ifeq ($(VARIANT),tiered) -TOPLEVEL_EXCLUDE_DIRS = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name agent -else -ifeq ($(VARIANT),compiler2) -TOPLEVEL_EXCLUDE_DIRS = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name c1 -o -name agent -else -# compiler1 and core use the same exclude list -TOPLEVEL_EXCLUDE_DIRS = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name opto -o -name libadt -o -name agent -endif -endif - -# Get things from the platform file. -COMPILER = $(shell sed -n 's/^compiler[ ]*=[ ]*//p' $(PLATFORM_FILE)) - -SIMPLE_DIRS = \ - $(PLATFORM_DIR)/generated/dependencies \ - $(PLATFORM_DIR)/generated/adfiles \ - $(PLATFORM_DIR)/generated/jvmtifiles \ - $(PLATFORM_DIR)/generated/tracefiles \ - $(PLATFORM_DIR)/generated/extensions - -TARGETS = debug fastdebug optimized product -SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS)) - -# For dependencies and recursive makes. -BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make - -BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make dtrace.make - -BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \ - SRCARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT) - -# Define variables to be set in flags.make. -# Default values are set in make/defs.make. - -# Set BUILD_USER from system-dependent hints: $LOGNAME, $(whoami) -ifndef HOTSPOT_BUILD_USER - HOTSPOT_BUILD_USER := $(shell echo $$LOGNAME) -endif -ifndef HOTSPOT_BUILD_USER - HOTSPOT_BUILD_USER := $(shell whoami) -endif -# Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro -# or make/hotspot_distro. -ifndef HOTSPOT_VM_DISTRO - ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true) - include $(GAMMADIR)/make/hotspot_distro - else - include $(GAMMADIR)/make/openjdk_distro - endif -endif - -# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK -ifndef OPENJDK - ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true) - OPENJDK=true - endif -endif - -BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING) - -BUILDTREE = \ - $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_TARGETS) $(BUILDTREE_VARS) - -BUILDTREE_COMMENT = echo "\# Generated by $(BUILDTREE_MAKE)" - -all: $(SUBMAKE_DIRS) - -# Run make in each subdirectory recursively. -$(SUBMAKE_DIRS): $(SIMPLE_DIRS) FORCE - $(QUIETLY) [ -d $@ ] || { mkdir -p $@; } - +$(QUIETLY) cd $@ && $(BUILDTREE) TARGET=$(@F) - $(QUIETLY) touch $@ - -$(SIMPLE_DIRS): - $(QUIETLY) mkdir -p $@ - -# Convenience macro which takes a source relative path, applies $(1) to the -# absolute path, and then replaces $(GAMMADIR) in the result with a -# literal "$(GAMMADIR)/" suitable for inclusion in a Makefile. -gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2))) - -# This bit is needed to enable local rebuilds. -# Unless the makefile itself sets LP64, any environmental -# setting of LP64 will interfere with the build. -LP64_SETTING/32 = LP64 = \#empty -LP64_SETTING/64 = LP64 = 1 - -DATA_MODE/i486 = 32 -DATA_MODE/sparc = 32 -DATA_MODE/sparcv9 = 64 -DATA_MODE/amd64 = 64 -DATA_MODE/ppc64 = 64 -DATA_MODE/aarch64 = 64 - -DATA_MODE = $(DATA_MODE/$(BUILDARCH)) - -flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo "Platform_file = $(PLATFORM_FILE)" | sed -e 's|$(HS_ALT_MAKE)|$$(HS_ALT_MAKE)|' -e 's|$(GAMMADIR)|$$(GAMMADIR)|'; \ - sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \ - echo; \ - echo "GAMMADIR = $(GAMMADIR)"; \ - echo "HS_ALT_MAKE = $(HS_ALT_MAKE)"; \ - echo "OSNAME = $(OSNAME)"; \ - echo "SYSDEFS = \$$(Platform_sysdefs)"; \ - echo "SRCARCH = $(SRCARCH)"; \ - echo "BUILDARCH = $(BUILDARCH)"; \ - echo "LIBARCH = $(LIBARCH)"; \ - echo "TARGET = $(TARGET)"; \ - echo "HOTSPOT_VERSION_STRING = $(HOTSPOT_VERSION_STRING)"; \ - echo "VERSION_STRING = $(VERSION_STRING)"; \ - echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \ - echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \ - echo "OPENJDK = $(OPENJDK)"; \ - echo "$(LP64_SETTING/$(DATA_MODE))"; \ - echo; \ - echo "# Used for platform dispatching"; \ - echo "TARGET_DEFINES = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \ - echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \ - echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \ - echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \ - echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \ - echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \ - echo "CFLAGS += \$$(TARGET_DEFINES)"; \ - echo; \ - echo "Src_Dirs_V = \\"; \ - sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \ - echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/posix/vm)"; \ - echo; \ - echo "Src_Dirs_I = \\"; \ - echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \ - echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \ - echo "$(call gamma-path,altsrc,share/vm) \\"; \ - echo "$(call gamma-path,commonsrc,share/vm) \\"; \ - echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \ - echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \ - echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/posix/vm)"; \ - [ -n "$(CFLAGS_BROWSE)" ] && \ - echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \ - [ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \ - echo && echo "ENABLE_FULL_DEBUG_SYMBOLS = $(ENABLE_FULL_DEBUG_SYMBOLS)"; \ - [ -n "$(OBJCOPY)" ] && \ - echo && echo "OBJCOPY = $(OBJCOPY)"; \ - [ -n "$(STRIP_POLICY)" ] && \ - echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \ - [ -n "$(ZIP_DEBUGINFO_FILES)" ] && \ - echo && echo "ZIP_DEBUGINFO_FILES = $(ZIP_DEBUGINFO_FILES)"; \ - [ -n "$(ZIPEXE)" ] && \ - echo && echo "ZIPEXE = $(ZIPEXE)"; \ - [ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \ - echo && \ - echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \ - echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \ - [ -n "$(INCLUDE_TRACE)" ] && \ - echo && echo "INCLUDE_TRACE = $(INCLUDE_TRACE)"; \ - echo; \ - [ -n "$(SPEC)" ] && \ - echo "include $(SPEC)"; \ - echo "CP ?= cp"; \ - echo "MV ?= mv"; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \ - echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \ - ) > $@ - -flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \ - ) > $@ - -../shared_dirs.lst: $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm - @echo $(LOG_INFO) Creating directory list $@ - $(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \ - find $(HS_ALT_SRC)/share/vm/* -prune \ - -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \ - \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \ - fi; - $(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \ - -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \ - \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@ - -Makefile: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \ - ) > $@ - -vm.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo include flags_vm.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -adlc.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -jvmti.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -trace.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -dtrace.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -FORCE: - -.PHONY: all FORCE - -.NOTPARALLEL: diff --git a/hotspot/make/linux/makefiles/compiler1.make b/hotspot/make/linux/makefiles/compiler1.make deleted file mode 100644 index d303bfc1ca4..00000000000 --- a/hotspot/make/linux/makefiles/compiler1.make +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making client version of VM - -TYPE=COMPILER1 - -VM_SUBDIR = client - -# We don't support the JVMCI in a client VM. -INCLUDE_JVMCI := false - -CFLAGS += -DCOMPILER1 diff --git a/hotspot/make/linux/makefiles/compiler2.make b/hotspot/make/linux/makefiles/compiler2.make deleted file mode 100644 index c881079882e..00000000000 --- a/hotspot/make/linux/makefiles/compiler2.make +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making server version of VM - -TYPE=COMPILER2 - -VM_SUBDIR = server - -CFLAGS += -DCOMPILER2 diff --git a/hotspot/make/linux/makefiles/core.make b/hotspot/make/linux/makefiles/core.make deleted file mode 100644 index e032d964f57..00000000000 --- a/hotspot/make/linux/makefiles/core.make +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making core version of VM - -# Select which files to use (in top.make) -TYPE=CORE - -# There is no "core" directory in JDK. Install core build in server directory. -VM_SUBDIR = server - -# Note: macros.hpp defines CORE diff --git a/hotspot/make/linux/makefiles/debug.make b/hotspot/make/linux/makefiles/debug.make deleted file mode 100644 index 7c57280a12c..00000000000 --- a/hotspot/make/linux/makefiles/debug.make +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making debug version of VM - -# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make -DEBUG_CFLAGS/DEFAULT= $(DEBUG_CFLAGS) -DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@)) - -# _NMT_NOINLINE_ informs NMT that no inlining by Compiler -CFLAGS += $(DEBUG_CFLAGS/BYFILE) -D_NMT_NOINLINE_ - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# Linker mapfile -MAPFILE = $(GAMMADIR)/make/linux/makefiles/mapfile-vers-debug - -VERSION = debug -SYSDEFS += -DASSERT -PICFLAGS = DEFAULT diff --git a/hotspot/make/linux/makefiles/defs.make b/hotspot/make/linux/makefiles/defs.make deleted file mode 100644 index f61dacd44e2..00000000000 --- a/hotspot/make/linux/makefiles/defs.make +++ /dev/null @@ -1,279 +0,0 @@ -# -# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# The common definitions for hotspot linux builds. -# Include the top level defs.make under make directory instead of this one. -# This file is included into make/defs.make. - -SLASH_JAVA ?= /java - -define print_info - ifneq ($$(LOG_LEVEL), warn) - $$(shell echo >&2 "INFO: $1") - endif -endef - -# Need PLATFORM (os-arch combo names) for jdk and hotspot, plus libarch name - -# ARCH can be set explicitly in spec.gmk -ifndef ARCH - ARCH := $(shell uname -m) - # Fold little endian PowerPC64 into big-endian (if ARCH is set in - # hotspot-spec.gmk, this will be done by the configure script). - ifeq ($(ARCH),ppc64le) - ARCH := ppc64 - endif -endif - -PATH_SEP ?= : - -ifeq ($(LP64), 1) - ARCH_DATA_MODEL ?= 64 -else - ARCH_DATA_MODEL ?= 32 -endif - -# zero -ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - ifeq ($(ARCH_DATA_MODEL), 64) - MAKE_ARGS += LP64=1 - endif - PLATFORM = linux-zero - VM_PLATFORM = linux_$(subst i386,i486,$(ZERO_LIBARCH)) - HS_ARCH = zero - ARCH = zero -endif - -# ia64 -ifeq ($(ARCH), ia64) - ARCH_DATA_MODEL = 64 - MAKE_ARGS += LP64=1 - PLATFORM = linux-ia64 - VM_PLATFORM = linux_ia64 - HS_ARCH = ia64 -endif - -# sparc -ifneq (,$(findstring $(ARCH), sparc)) - ifeq ($(ARCH_DATA_MODEL), 64) - ARCH_DATA_MODEL = 64 - MAKE_ARGS += LP64=1 - PLATFORM = linux-sparcv9 - VM_PLATFORM = linux_sparcv9 - else - ARCH_DATA_MODEL = 32 - PLATFORM = linux-sparc - VM_PLATFORM = linux_sparc - endif - HS_ARCH = sparc -endif - -# i686/i586 and amd64/x86_64 -ifneq (,$(findstring $(ARCH), amd64 x86_64 i686 i586)) - ifeq ($(ARCH_DATA_MODEL), 64) - ARCH_DATA_MODEL = 64 - MAKE_ARGS += LP64=1 - PLATFORM = linux-amd64 - VM_PLATFORM = linux_amd64 - else - ARCH_DATA_MODEL = 32 - PLATFORM = linux-i586 - VM_PLATFORM = linux_i486 - endif - - HS_ARCH = x86 -endif - -# PPC -# Notice: after 8046471 ARCH will be 'ppc' for top-level ppc64 builds but -# 'ppc64' for HotSpot-only ppc64 builds. Need to detect both variants here! -ifneq (,$(findstring $(ARCH), ppc ppc64)) - ifeq ($(ARCH_DATA_MODEL), 64) - MAKE_ARGS += LP64=1 - PLATFORM = linux-ppc64 - VM_PLATFORM = linux_ppc64 - endif - - HS_ARCH = ppc -endif - -# AARCH64 -ifeq ($(ARCH), aarch64) - ARCH_DATA_MODEL = 64 - MAKE_ARGS += LP64=1 - PLATFORM = linux-aarch64 - VM_PLATFORM = linux_aarch64 - HS_ARCH = aarch64 -endif - -# On 32 bit linux we build server and client, on 64 bit just server. -ifeq ($(JVM_VARIANTS),) - ifeq ($(ARCH_DATA_MODEL), 32) - JVM_VARIANTS:=client,server - JVM_VARIANT_CLIENT:=true - JVM_VARIANT_SERVER:=true - else - JVM_VARIANTS:=server - JVM_VARIANT_SERVER:=true - endif -endif - -# The Full Debug Symbols (FDS) default for BUILD_FLAVOR == product -# builds is enabled with debug info files ZIP'ed to save space. For -# BUILD_FLAVOR != product builds, FDS is always enabled, after all a -# debug build without debug info isn't very useful. -# The ZIP_DEBUGINFO_FILES option only has meaning when FDS is enabled. -# -# If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be -# disabled for a BUILD_FLAVOR == product build. -# -# Note: Use of a different variable name for the FDS override option -# versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS -# versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass -# in options via environment variables, use of distinct variables -# prevents strange behaviours. For example, in a BUILD_FLAVOR != -# product build, the FULL_DEBUG_SYMBOLS environment variable will be -# 0, but the ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If -# the same variable name is used, then different values can be picked -# up by different parts of the build. Just to be clear, we only need -# two variable names because the incoming option value can be -# overridden in some situations, e.g., a BUILD_FLAVOR != product -# build. - -# Due to the multiple sub-make processes that occur this logic gets -# executed multiple times. We reduce the noise by at least checking that -# BUILD_FLAVOR has been set. -ifneq ($(BUILD_FLAVOR),) - ifeq ($(BUILD_FLAVOR), product) - FULL_DEBUG_SYMBOLS ?= 1 - ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) - else - # debug variants always get Full Debug Symbols (if available) - ENABLE_FULL_DEBUG_SYMBOLS = 1 - endif - $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")) - # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later - - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - # Default OBJCOPY comes from GNU Binutils on Linux - ifeq ($(CROSS_COMPILE_ARCH),) - DEF_OBJCOPY=/usr/bin/objcopy - else - # Assume objcopy is part of the cross-compilation toolset - ifneq ($(ALT_COMPILER_PATH),) - DEF_OBJCOPY=$(ALT_COMPILER_PATH)/objcopy - endif - endif - OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY)) - ifneq ($(ALT_OBJCOPY),) - $(eval $(call print_info, "ALT_OBJCOPY=$(ALT_OBJCOPY)")) - OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY)) - endif - - ifeq ($(OBJCOPY),) - $(eval $(call print_info, "no objcopy cmd found so cannot create .debuginfo files. You may need to set ALT_OBJCOPY.")) - ENABLE_FULL_DEBUG_SYMBOLS=0 - $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")) - else - $(eval $(call print_info, "$(OBJCOPY) cmd found so will create .debuginfo files.")) - - # Library stripping policies for .debuginfo configs: - # all_strip - strips everything from the library - # min_strip - strips most stuff from the library; leaves minimum symbols - # no_strip - does not strip the library at all - # - # Oracle security policy requires "all_strip". A waiver was granted on - # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE. - # - # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled. - # - STRIP_POLICY ?= min_strip - - $(eval $(call print_info, "STRIP_POLICY=$(STRIP_POLICY)")) - - ZIP_DEBUGINFO_FILES ?= 1 - - $(eval $(call print_info, "ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")) - endif - endif # ENABLE_FULL_DEBUG_SYMBOLS=1 -endif # BUILD_FLAVOR - -JDK_INCLUDE_SUBDIR=linux - -# Library suffix -LIBRARY_SUFFIX=so - -EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html - -# client and server subdirectories have symbolic links to ../libjsig.so -EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX) -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.diz - else - EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.debuginfo - endif -endif -EXPORT_SERVER_DIR = $(EXPORT_LIB_ARCH_DIR)/server -EXPORT_CLIENT_DIR = $(EXPORT_LIB_ARCH_DIR)/client -EXPORT_MINIMAL_DIR = $(EXPORT_LIB_ARCH_DIR)/minimal - -ifeq ($(findstring true, $(JVM_VARIANT_SERVER) $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK) $(JVM_VARIANT_CORE)), true) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX) - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.diz - else - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo - endif - endif -endif - -ifeq ($(JVM_VARIANT_CLIENT),true) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX) - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.diz - else - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo - endif - endif -endif - -ifeq ($(JVM_VARIANT_MINIMAL1),true) - EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.$(LIBRARY_SUFFIX) - - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.diz - else - EXPORT_LIST += $(EXPORT_MINIMAL_DIR)/libjvm.debuginfo - endif - endif -endif - --include $(HS_ALT_MAKE)/linux/makefiles/defs.make diff --git a/hotspot/make/linux/makefiles/dtrace.make b/hotspot/make/linux/makefiles/dtrace.make deleted file mode 100644 index 2c898d0e778..00000000000 --- a/hotspot/make/linux/makefiles/dtrace.make +++ /dev/null @@ -1,95 +0,0 @@ -# -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012 Red Hat, Inc. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Linux does not build jvm_db -LIBJVM_DB = - -# Only OPENJDK builds test and support SDT probes currently. -ifndef OPENJDK -REASON = "This JDK does not support SDT probes" -else - -# We need a recent GCC for the default (4.4 or later) -ifeq "$(shell expr \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 4 \) \) \| \( $(CC_VER_MAJOR) \>= 5 \) )" "0" -REASON = "gcc version is too old" -else - -# But it does have a SystemTap dtrace compatible sys/sdt.h -ifneq ($(ALT_SDT_H),) - SDT_H_FILE = $(ALT_SDT_H) -else - ifeq ($(USE_CLANG), true) - # Clang doesn't support the -print-sysroot option and there is no known equivalent - # option, so fall back to using / as sysroot - SDT_SYSROOT= - else - SDT_SYSROOT=$(shell $(CXX) -print-sysroot) - endif - SDT_H_FILE = $(SDT_SYSROOT)/usr/include/sys/sdt.h -endif - -DTRACE_ENABLED = $(shell test -f $(SDT_H_FILE) && echo $(SDT_H_FILE)) -REASON = "$(SDT_H_FILE) not found" - -endif # GCC version -endif # OPENJDK - - -DTRACE_COMMON_SRCDIR = $(GAMMADIR)/src/os/posix/dtrace -DTRACE_PROG = dtrace -DtraceOutDir = $(GENERATED)/dtracefiles - -$(DtraceOutDir): - mkdir $(DtraceOutDir) - -$(DtraceOutDir)/hotspot.h: $(DTRACE_COMMON_SRCDIR)/hotspot.d | $(DtraceOutDir) - $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_COMMON_SRCDIR)/hotspot.d - -$(DtraceOutDir)/hotspot_jni.h: $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d | $(DtraceOutDir) - $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d - -$(DtraceOutDir)/hs_private.h: $(DTRACE_COMMON_SRCDIR)/hs_private.d | $(DtraceOutDir) - $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_COMMON_SRCDIR)/hs_private.d - -ifneq ($(DTRACE_ENABLED),) -CFLAGS += -DDTRACE_ENABLED -dtrace_gen_headers: $(DtraceOutDir)/hotspot.h $(DtraceOutDir)/hotspot_jni.h $(DtraceOutDir)/hs_private.h -else -dtrace_gen_headers: - $(QUIETLY) $(LOG_INFO) echo "**NOTICE** Dtrace support disabled: $(REASON)" -endif - -# Phony target used in vm.make build target to check whether enabled. -ifeq ($(DTRACE_ENABLED),) -dtraceCheck: - $(QUIETLY) $(LOG_INFO) echo "**NOTICE** Dtrace support disabled: $(REASON)" -else -dtraceCheck: -endif - -.PHONY: dtrace_gen_headers dtraceCheck - -# It doesn't support HAVE_DTRACE_H though. - diff --git a/hotspot/make/linux/makefiles/fastdebug.make b/hotspot/make/linux/makefiles/fastdebug.make deleted file mode 100644 index ebadd1986b3..00000000000 --- a/hotspot/make/linux/makefiles/fastdebug.make +++ /dev/null @@ -1,74 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making debug version of VM - -# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make -# They may also specify FASTDEBUG_CFLAGS, but it defaults to DEBUG_CFLAGS. - -FASTDEBUG_CFLAGS$(FASTDEBUG_CFLAGS) = $(DEBUG_CFLAGS) - -# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make -OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) -OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) - -# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files) - -ifeq ($(BUILDARCH), ia64) - # Bug in GCC, causes hang. -O1 will override the -O3 specified earlier - OPT_CFLAGS/callGenerator.o += -O1 - OPT_CFLAGS/ciTypeFlow.o += -O1 - OPT_CFLAGS/compile.o += -O1 - OPT_CFLAGS/concurrentMarkSweepGeneration.o += -O1 - OPT_CFLAGS/doCall.o += -O1 - OPT_CFLAGS/generateOopMap.o += -O1 - OPT_CFLAGS/generateOptoStub.o += -O1 - OPT_CFLAGS/graphKit.o += -O1 - OPT_CFLAGS/instanceKlass.o += -O1 - OPT_CFLAGS/interpreterRT_ia64.o += -O1 - OPT_CFLAGS/output.o += -O1 - OPT_CFLAGS/parse1.o += -O1 - OPT_CFLAGS/runtime.o += -O1 - OPT_CFLAGS/synchronizer.o += -O1 -endif - - -# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings -CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. -# The following lines are copied from debug.make, except that we -# consult FASTDEBUG_CFLAGS instead of DEBUG_CFLAGS. -# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make -DEBUG_CFLAGS/DEFAULT= $(FASTDEBUG_CFLAGS) -DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@)) -CFLAGS += $(DEBUG_CFLAGS/BYFILE) - -# Linker mapfile -MAPFILE = $(GAMMADIR)/make/linux/makefiles/mapfile-vers-debug - -VERSION = optimized -SYSDEFS += -DASSERT -DCHECK_UNHANDLED_OOPS -PICFLAGS = DEFAULT diff --git a/hotspot/make/linux/makefiles/gcc.make b/hotspot/make/linux/makefiles/gcc.make deleted file mode 100644 index 75dcaeb2c34..00000000000 --- a/hotspot/make/linux/makefiles/gcc.make +++ /dev/null @@ -1,425 +0,0 @@ -# -# Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -#------------------------------------------------------------------------ -# CC, CXX & AS - -# If a SPEC is not set already, then use these defaults. -ifeq ($(SPEC),) - # When cross-compiling the ALT_COMPILER_PATH points - # to the cross-compilation toolset - ifdef CROSS_COMPILE_ARCH - CXX = $(ALT_COMPILER_PATH)/g++ - CC = $(ALT_COMPILER_PATH)/gcc - HOSTCXX = g++ - HOSTCC = gcc - STRIP = $(ALT_COMPILER_PATH)/strip - else - ifeq ($(USE_CLANG), true) - CXX = clang++ - CC = clang - else - CXX = g++ - CC = gcc - endif - - HOSTCXX = $(CXX) - HOSTCC = $(CC) - STRIP = strip - endif - AS = $(CC) -c -endif - - -ifeq ($(USE_CLANG), true) - CC_VER_MAJOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f1) - CC_VER_MINOR := $(shell $(CC) -v 2>&1 | grep version | sed "s/.*version \([0-9]*\.[0-9]*\).*/\1/" | cut -d'.' -f2) -else - # -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only - # prints the numbers (e.g. "2.95", "3.2.1") - CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) - CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) - CC_VER_MICRO := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f3) - # Workaround Ubuntu bug where -dumpversion doesn't print a micro version - # https://bugs.launchpad.net/ubuntu/+source/gcc-4.8/+bug/1360404 - ifeq ($(CC_VER_MICRO),) - CC_VER_MICRO := "0" - endif -endif - -ifeq ($(USE_CLANG), true) - # Clang has precompiled headers support by default, but the user can switch - # it off by using 'USE_PRECOMPILED_HEADER=0'. - ifdef LP64 - ifeq ($(USE_PRECOMPILED_HEADER),) - USE_PRECOMPILED_HEADER=1 - endif - else - # We don't support precompiled headers on 32-bit builds because there some files are - # compiled with -fPIC while others are compiled without (see 'NONPIC_OBJ_FILES' rules.make) - # Clang produces an error if the PCH file was compiled with other options than the actual compilation unit. - USE_PRECOMPILED_HEADER=0 - endif - - ifeq ($(USE_PRECOMPILED_HEADER),1) - - ifndef LP64 - $(error " Precompiled Headers only supported on 64-bit platforms!") - endif - - PRECOMPILED_HEADER_DIR=. - PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp - PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.pch - - PCH_FLAG = -include precompiled.hpp - PCH_FLAG/DEFAULT = $(PCH_FLAG) - PCH_FLAG/NO_PCH = -DNO_PCH - PCH_FLAG/BY_FILE = $(PCH_FLAG/$@)$(PCH_FLAG/DEFAULT$(PCH_FLAG/$@)) - - VM_PCH_FLAG/LIBJVM = $(PCH_FLAG/BY_FILE) - VM_PCH_FLAG/AOUT = - VM_PCH_FLAG = $(VM_PCH_FLAG/$(LINK_INTO)) - - # We only use precompiled headers for the JVM build - CFLAGS += $(VM_PCH_FLAG) - - # There are some files which don't like precompiled headers - # The following files are build with 'OPT_CFLAGS/NOOPT' (-O0) in the opt build. - # But Clang doesn't support a precompiled header which was compiled with -O3 - # to be used in a compilation unit which uses '-O0'. We could also prepare an - # extra '-O0' PCH file for the opt build and use it here, but it's probably - # not worth the effort as long as only two files need this special handling. - PCH_FLAG/loopTransform.o = $(PCH_FLAG/NO_PCH) - PCH_FLAG/sharedRuntimeTrig.o = $(PCH_FLAG/NO_PCH) - PCH_FLAG/sharedRuntimeTrans.o = $(PCH_FLAG/NO_PCH) - - endif -else # ($(USE_CLANG), true) - # check for precompiled headers support - ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0" - # Allow the user to turn off precompiled headers from the command line. - ifneq ($(USE_PRECOMPILED_HEADER),0) - PRECOMPILED_HEADER_DIR=. - PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp - PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch - endif - endif -endif - -# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. -ifeq ($(USE_PRECOMPILED_HEADER),0) - CFLAGS += -DDONT_USE_PRECOMPILED_HEADER -endif - - -#------------------------------------------------------------------------ -# Compiler flags - -# position-independent code -PICFLAG = -fPIC - -VM_PICFLAG/LIBJVM = $(PICFLAG) -VM_PICFLAG/AOUT = -VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO)) - -ifeq ($(JVM_VARIANT_ZERO), true) -CFLAGS += $(LIBFFI_CFLAGS) -endif -ifeq ($(JVM_VARIANT_ZEROSHARK), true) -CFLAGS += $(LIBFFI_CFLAGS) -CFLAGS += $(LLVM_CFLAGS) -endif -CFLAGS += $(VM_PICFLAG) -CFLAGS += -fno-rtti -CFLAGS += -fno-exceptions -CFLAGS += -D_REENTRANT -ifeq ($(USE_CLANG),) - CFLAGS += -fcheck-new - # version 4 and above support fvisibility=hidden (matches jni_x86.h file) - # except 4.1.2 gives pointless warnings that can't be disabled (afaik) - ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" - CFLAGS += -fvisibility=hidden - endif -else - CFLAGS += -fvisibility=hidden -endif - -ifeq ($(USE_CLANG), true) - # Before Clang 3.1, we had to pass the stack alignment specification directly to llvm with the help of '-mllvm' - # Starting with version 3.1, Clang understands the '-mstack-alignment' (and rejects '-mllvm -stack-alignment') - ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 1 \) \))" "0" - STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mstack-alignment=16 - else - STACK_ALIGNMENT_OPT = -mno-omit-leaf-frame-pointer -mllvm -stack-alignment=16 - endif -endif - -ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) -ARCHFLAG/i486 = -m32 -march=i586 -ARCHFLAG/amd64 = -m64 $(STACK_ALIGNMENT_OPT) -ARCHFLAG/aarch64 = -ARCHFLAG/ia64 = -ARCHFLAG/sparc = -m32 -mcpu=v9 -ARCHFLAG/sparcv9 = -m64 -mcpu=v9 -ARCHFLAG/zero = $(ZERO_ARCHFLAG) -ARCHFLAG/ppc64 = -m64 - -CFLAGS += $(ARCHFLAG) -AOUT_FLAGS += $(ARCHFLAG) -LFLAGS += $(ARCHFLAG) -ASFLAGS += $(ARCHFLAG) - -# Use C++ Interpreter -ifdef CC_INTERP - CFLAGS += -DCC_INTERP -endif - -# Keep temporary files (.ii, .s) -ifdef NEED_ASM - CFLAGS += -save-temps -else - CFLAGS += -pipe -endif - -# Compiler warnings are treated as errors -WARNINGS_ARE_ERRORS ?= -Werror - -ifeq ($(USE_CLANG), true) - # However we need to clean the code up before we can unrestrictedly enable this option with Clang - WARNINGS_ARE_ERRORS += -Wno-logical-op-parentheses -Wno-parentheses-equality -Wno-parentheses - WARNINGS_ARE_ERRORS += -Wno-switch -Wno-tautological-constant-out-of-range-compare -Wno-tautological-compare - WARNINGS_ARE_ERRORS += -Wno-delete-non-virtual-dtor -Wno-deprecated -Wno-format -Wno-dynamic-class-memaccess - WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body -endif - -WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wreturn-type -Woverloaded-virtual - -ifeq ($(USE_CLANG),) - # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit - # conversions which might affect the values. Only enable it in earlier versions. - ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "0" - # GCC < 4.3 - WARNING_FLAGS += -Wconversion - endif - ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 8 \) \))" "1" - # GCC >= 4.8 - # This flag is only known since GCC 4.3. Gcc 4.8 contains a fix so that with templates no - # warnings are issued: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=11856 - WARNING_FLAGS += -Wtype-limits - # GCC < 4.8 don't accept this flag for C++. - WARNING_FLAGS += -Wno-format-zero-length - # GCC 4.8 reports less false positives than the older compilers. - WARNING_FLAGS += -Wuninitialized - endif -endif - -CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) - -# Special cases -CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) - -# optimization control flags (Used by fastdebug and release variants) -OPT_CFLAGS/NOOPT=-O0 -OPT_CFLAGS/DEBUG=-O0 -OPT_CFLAGS/SIZE=-Os -OPT_CFLAGS/SPEED=-O3 - -OPT_CFLAGS_DEFAULT ?= SPEED - -# Hotspot uses very unstrict aliasing turn this optimization off -# This option is added to CFLAGS rather than OPT_CFLAGS -# so that OPT_CFLAGS overrides get this option too. -CFLAGS += -fno-strict-aliasing - -ifdef OPT_CFLAGS - ifneq ("$(origin OPT_CFLAGS)", "command line") - $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.") - endif -endif - -OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS) - -# Variable tracking size limit exceeded for VMStructs::init() -ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 4 \) \| \( \( $(CC_VER_MAJOR) = 4 \) \& \( $(CC_VER_MINOR) \>= 3 \) \))" "1" - # GCC >= 4.3 - # Gcc 4.1.2 does not support this flag, nor does it have problems compiling the file. - OPT_CFLAGS/vmStructs.o += -fno-var-tracking-assignments - # The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides - # of OPT_CFLAGS. Restore it here. - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS/vmStructs.o += -g - endif -endif - -# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp -# if we use expensive-optimizations -ifeq ($(BUILDARCH), ia64) -OPT_CFLAGS += -fno-expensive-optimizations -endif - -# Work around some compiler bugs. -ifeq ($(USE_CLANG), true) - ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1) - OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT) - # The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides - # of OPT_CFLAGS. Restore it here. - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS/loopTransform.o += -g - endif - endif -else - # Do not allow GCC 4.1.1 - ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 1 \& $(CC_VER_MICRO) = 1), 1) - $(error "GCC $(CC_VER_MAJOR).$(CC_VER_MINOR).$(CC_VER_MICRO) not supported because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27724") - endif - # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. - ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1) - OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT) - endif -endif - -# Flags for generating make dependency flags. -DEPFLAGS = -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) -ifeq ($(USE_CLANG),) - ifneq ($(CC_VER_MAJOR), 2) - DEPFLAGS += -fpch-deps - endif -endif - -#------------------------------------------------------------------------ -# Linker flags - -# statically link libstdc++.so, work with gcc but ignored by g++ -STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic - -# Enable linker optimization -LFLAGS += -Xlinker -O1 - -ifeq ($(USE_CLANG),) - STATIC_LIBGCC += -static-libgcc - - ifneq (, findstring(debug,$(BUILD_FLAVOR))) - # for relocations read-only - LFLAGS += -Xlinker -z -Xlinker relro - - ifeq ($(BUILD_FLAVOR), debug) - # disable incremental relocations linking - LFLAGS += -Xlinker -z -Xlinker now - endif - endif - - ifeq ($(BUILDARCH), ia64) - LFLAGS += -Wl,-relax - endif - - # If this is a --hash-style=gnu system, use --hash-style=both - # The gnu .hash section won't work on some Linux systems like SuSE 10. - _HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | grep -- '--hash-style=gnu') - ifneq ($(_HAS_HASH_STYLE_GNU),) - LDFLAGS_HASH_STYLE = -Wl,--hash-style=both - endif -else - # Don't know how to find out the 'hash style' of a system as '-dumpspecs' - # doesn't work for Clang. So for now we'll alwys use --hash-style=both - LDFLAGS_HASH_STYLE = -Wl,--hash-style=both -endif - -LFLAGS += $(LDFLAGS_HASH_STYLE) - -# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. -MAPFLAG = -Xlinker --version-script=FILENAME - -# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj -SONAMEFLAG = -Xlinker -soname=SONAME - -# Build shared library -SHARED_FLAG = -shared - -# Keep symbols even they are not used -AOUT_FLAGS += -Xlinker -export-dynamic - -#------------------------------------------------------------------------ -# Debug flags - -ifeq ($(USE_CLANG), true) - # Restrict the debug information created by Clang to avoid - # too big object files and speed the build up a little bit - # (see http://llvm.org/bugs/show_bug.cgi?id=7554) - CFLAGS += -flimit-debug-info -endif - -# Allow no optimizations. -DEBUG_CFLAGS=-O0 - -# DEBUG_BINARIES uses full -g debug information for all configs -ifeq ($(DEBUG_BINARIES), true) - CFLAGS += -g -else - DEBUG_CFLAGS += $(DEBUG_CFLAGS/$(BUILDARCH)) - ifeq ($(DEBUG_CFLAGS/$(BUILDARCH)),) - DEBUG_CFLAGS += -g - endif - - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - FASTDEBUG_CFLAGS += $(FASTDEBUG_CFLAGS/$(BUILDARCH)) - ifeq ($(FASTDEBUG_CFLAGS/$(BUILDARCH)),) - FASTDEBUG_CFLAGS += -g - endif - - OPT_CFLAGS += $(OPT_CFLAGS/$(BUILDARCH)) - ifeq ($(OPT_CFLAGS/$(BUILDARCH)),) - OPT_CFLAGS += -g - endif - endif -endif - -ifeq ($(USE_CLANG),) - # Enable bounds checking. - ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "1" - # stack smashing checks. - DEBUG_CFLAGS += -fstack-protector-all --param ssp-buffer-size=1 - endif -endif - - -# If we are building HEADLESS, pass on to VM -# so it can set the java.awt.headless property -ifdef HEADLESS -CFLAGS += -DHEADLESS -endif - -# We are building Embedded for a small device -# favor code space over speed -ifdef MINIMIZE_RAM_USAGE -CFLAGS += -DMINIMIZE_RAM_USAGE -endif - -# Stack walking in the JVM relies on frame pointer (%rbp) to walk thread stack. -# Explicitly specify -fno-omit-frame-pointer because it is off by default -# starting with gcc 4.6. -ifndef USE_SUNCC - CFLAGS += -fno-omit-frame-pointer -endif - --include $(HS_ALT_MAKE)/linux/makefiles/gcc.make diff --git a/hotspot/make/linux/makefiles/hp.make b/hotspot/make/linux/makefiles/hp.make deleted file mode 100644 index e0b262a8fa2..00000000000 --- a/hotspot/make/linux/makefiles/hp.make +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making premium version of VM - -TYPE=HP - -CFLAGS += -DCOMPILER2 diff --git a/hotspot/make/linux/makefiles/hp1.make b/hotspot/make/linux/makefiles/hp1.make deleted file mode 100644 index 2e37a6ead33..00000000000 --- a/hotspot/make/linux/makefiles/hp1.make +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making premium version of VM - -TYPE=HP1 - -CFLAGS += -DCOMPILER1 diff --git a/hotspot/make/linux/makefiles/i486.make b/hotspot/make/linux/makefiles/i486.make deleted file mode 100644 index a1adda6477c..00000000000 --- a/hotspot/make/linux/makefiles/i486.make +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# TLS helper, assembled from .s file - -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT) -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT) -# Must also specify if CPU is little endian -CFLAGS += -DVM_LITTLE_ENDIAN - -OPT_CFLAGS/compactingPermGenGen.o = -O1 - -# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides -# of OPT_CFLAGS. Restore it here. -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS/sharedRuntimeTrig.o += -g - OPT_CFLAGS/sharedRuntimeTrans.o += -g - OPT_CFLAGS/compactingPermGenGen.o += -g -endif diff --git a/hotspot/make/linux/makefiles/ia64.make b/hotspot/make/linux/makefiles/ia64.make deleted file mode 100644 index 8535807a787..00000000000 --- a/hotspot/make/linux/makefiles/ia64.make +++ /dev/null @@ -1,41 +0,0 @@ -# -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# -# IA64 only uses c++ based interpreter -CFLAGS += -DCC_INTERP -D_LP64=1 -DVM_LITTLE_ENDIAN -ifeq ($(VERSION),debug) -ASM_FLAGS= -DDEBUG -else -ASM_FLAGS= -endif -# workaround gcc bug in compiling varargs -OPT_CFLAGS/jni.o = -O0 - -# gcc/ia64 has a bug that internal gcc functions linked with libjvm.so -# are made public. Hiding those symbols will cause undefined symbol error -# when VM is dropped into older JDK. We probably will need an IA64 -# mapfile to include those symbols as a workaround. Disable linker mapfile -# for now. -LDNOMAP=true diff --git a/hotspot/make/linux/makefiles/jsig.make b/hotspot/make/linux/makefiles/jsig.make deleted file mode 100644 index 58c84930824..00000000000 --- a/hotspot/make/linux/makefiles/jsig.make +++ /dev/null @@ -1,83 +0,0 @@ -# -# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Rules to build signal interposition library, used by vm.make - -# libjsig.so: signal interposition library -JSIG = jsig -LIBJSIG = lib$(JSIG).so - -LIBJSIG_DEBUGINFO = lib$(JSIG).debuginfo -LIBJSIG_DIZ = lib$(JSIG).diz - -JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm - -DEST_JSIG = $(JDK_LIBDIR)/$(LIBJSIG) -DEST_JSIG_DEBUGINFO = $(JDK_LIBDIR)/$(LIBJSIG_DEBUGINFO) -DEST_JSIG_DIZ = $(JDK_LIBDIR)/$(LIBJSIG_DIZ) - -LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig - -# On Linux we really dont want a mapfile, as this library is small -# and preloaded using LD_PRELOAD, making functions private will -# cause problems with interposing. See CR: 6466665 -# LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE)) - -LFLAGS_JSIG += -D_GNU_SOURCE -D_REENTRANT $(LDFLAGS_HASH_STYLE) - -# DEBUG_BINARIES overrides everything, use full -g debug information -ifeq ($(DEBUG_BINARIES), true) - JSIG_DEBUG_CFLAGS = -g -endif - -$(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE) - @echo $(LOG_INFO) Making signal interposition lib... - $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \ - $(LFLAGS_JSIG) $(JSIG_DEBUG_CFLAGS) $(EXTRA_CFLAGS) -o $@ $< -ldl -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO) - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@ - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -g $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -y $(LIBJSIG_DIZ) $(LIBJSIG_DEBUGINFO) - $(RM) $(LIBJSIG_DEBUGINFO) - endif -endif - -install_jsig: $(LIBJSIG) - @echo "Copying $(LIBJSIG) to $(DEST_JSIG)" - $(QUIETLY) test ! -f $(LIBJSIG_DEBUGINFO) || \ - $(CP) -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO) - $(QUIETLY) test ! -f $(LIBJSIG_DIZ) || \ - $(CP) -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ) - $(QUIETLY) $(CP) -f $(LIBJSIG) $(DEST_JSIG) && echo "Done" - -.PHONY: install_jsig diff --git a/hotspot/make/linux/makefiles/jvmti.make b/hotspot/make/linux/makefiles/jvmti.make deleted file mode 100644 index 14220e9909f..00000000000 --- a/hotspot/make/linux/makefiles/jvmti.make +++ /dev/null @@ -1,117 +0,0 @@ -# -# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (jvmti.make) is included from the jvmti.make in the -# build directories. -# -# It knows how to build and run the tools to generate jvmti. - -include $(GAMMADIR)/make/linux/makefiles/rules.make - -# ######################################################################### - -TOPDIR = $(shell echo `pwd`) -GENERATED = $(TOPDIR)/../generated -JvmtiOutDir = $(GENERATED)/jvmtifiles - -JvmtiSrcDir = $(GAMMADIR)/src/share/vm/prims -InterpreterSrcDir = $(GAMMADIR)/src/share/vm/interpreter - -# set VPATH so make knows where to look for source files -Src_Dirs_V += $(JvmtiSrcDir) -VPATH += $(Src_Dirs_V:%=%:) - -JvmtiGeneratedNames = \ - jvmtiEnv.hpp \ - jvmtiEnter.cpp \ - jvmtiEnterTrace.cpp \ - jvmtiEnvRecommended.cpp \ - bytecodeInterpreterWithChecks.cpp \ - jvmti.h \ - -JvmtiEnvFillSource = $(JvmtiSrcDir)/jvmtiEnvFill.java -JvmtiEnvFillClass = $(JvmtiOutDir)/jvmtiEnvFill.class - -JvmtiGenSource = $(JvmtiSrcDir)/jvmtiGen.java -JvmtiGenClass = $(JvmtiOutDir)/jvmtiGen.class - -JvmtiGeneratedFiles = $(JvmtiGeneratedNames:%=$(JvmtiOutDir)/%) - -XSLT = $(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen - -.PHONY: all jvmtidocs clean cleanall - -# ######################################################################### - -all: $(JvmtiGeneratedFiles) - -both = $(JvmtiGenClass) $(JvmtiSrcDir)/jvmti.xml $(JvmtiSrcDir)/jvmtiLib.xsl - -$(JvmtiGenClass): $(JvmtiGenSource) - $(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiGenSource) - -$(JvmtiEnvFillClass): $(JvmtiEnvFillSource) - $(QUIETLY) $(REMOTE) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiEnvFillSource) - -$(JvmtiOutDir)/jvmtiEnter.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnter.cpp -PARAM interface jvmti - -$(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp: $(JvmtiGenClass) $(InterpreterSrcDir)/bytecodeInterpreter.cpp $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml -XSL $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl -OUT $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp - -$(JvmtiOutDir)/jvmtiEnterTrace.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnterTrace.cpp -PARAM interface jvmti -PARAM trace Trace - -$(JvmtiOutDir)/jvmtiEnvRecommended.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnv.xsl $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiEnvFillClass) - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnv.xsl -OUT $(JvmtiOutDir)/jvmtiEnvStub.cpp - $(QUIETLY) $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiEnvFill $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiOutDir)/jvmtiEnvStub.cpp $(JvmtiOutDir)/jvmtiEnvRecommended.cpp - -$(JvmtiOutDir)/jvmtiEnv.hpp: $(both) $(JvmtiSrcDir)/jvmtiHpp.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiHpp.xsl -OUT $(JvmtiOutDir)/jvmtiEnv.hpp - -$(JvmtiOutDir)/jvmti.h: $(both) $(JvmtiSrcDir)/jvmtiH.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiH.xsl -OUT $(JvmtiOutDir)/jvmti.h - -jvmtidocs: $(JvmtiOutDir)/jvmti.html - -$(JvmtiOutDir)/jvmti.html: $(both) $(JvmtiSrcDir)/jvmti.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmti.xsl -OUT $(JvmtiOutDir)/jvmti.html - -# ######################################################################### - -clean : - rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles) - -cleanall : - rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles) - -# ######################################################################### - diff --git a/hotspot/make/linux/makefiles/mapfile-vers-debug b/hotspot/make/linux/makefiles/mapfile-vers-debug deleted file mode 100644 index ec0f06d8f65..00000000000 --- a/hotspot/make/linux/makefiles/mapfile-vers-debug +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define public interface. - -SUNWprivate_1.1 { - global: - JVM_handle_linux_signal; - - # miscellaneous functions - jio_fprintf; - jio_printf; - jio_snprintf; - jio_vfprintf; - jio_vsnprintf; - numa_warn; - numa_error; - - # Needed because there is no JVM interface for this. - sysThreadAvailableStackWithSlack; - - # This is for Forte Analyzer profiling support. - AsyncGetCallTrace; - - # INSERT VTABLE SYMBOLS HERE - - local: - *; -}; - diff --git a/hotspot/make/linux/makefiles/mapfile-vers-jsig b/hotspot/make/linux/makefiles/mapfile-vers-jsig deleted file mode 100644 index 8a675046b6e..00000000000 --- a/hotspot/make/linux/makefiles/mapfile-vers-jsig +++ /dev/null @@ -1,40 +0,0 @@ -# - -# -# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define library interface. - -SUNWprivate_1.1 { - global: - JVM_begin_signal_setting; - JVM_end_signal_setting; - JVM_get_libjsig_version; - JVM_get_signal_action; - sigaction; - signal; - sigset; - local: - *; -}; diff --git a/hotspot/make/linux/makefiles/mapfile-vers-product b/hotspot/make/linux/makefiles/mapfile-vers-product deleted file mode 100644 index ec0f06d8f65..00000000000 --- a/hotspot/make/linux/makefiles/mapfile-vers-product +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define public interface. - -SUNWprivate_1.1 { - global: - JVM_handle_linux_signal; - - # miscellaneous functions - jio_fprintf; - jio_printf; - jio_snprintf; - jio_vfprintf; - jio_vsnprintf; - numa_warn; - numa_error; - - # Needed because there is no JVM interface for this. - sysThreadAvailableStackWithSlack; - - # This is for Forte Analyzer profiling support. - AsyncGetCallTrace; - - # INSERT VTABLE SYMBOLS HERE - - local: - *; -}; - diff --git a/hotspot/make/linux/makefiles/minimal1.make b/hotspot/make/linux/makefiles/minimal1.make deleted file mode 100644 index d453e789877..00000000000 --- a/hotspot/make/linux/makefiles/minimal1.make +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -TYPE=MINIMAL1 - -# Force all variables to false, overriding any other -# setting that may have occurred in the makefiles. These -# can still be overridden by passing the variable as an -# argument to 'make' -INCLUDE_JVMTI := false -INCLUDE_FPROF := false -INCLUDE_VM_STRUCTS := false -INCLUDE_JNI_CHECK := false -INCLUDE_SERVICES := false -INCLUDE_MANAGEMENT := false -INCLUDE_ALL_GCS := false -INCLUDE_NMT := false -INCLUDE_TRACE := false -INCLUDE_CDS := false -INCLUDE_JVMCI := false - -CXXFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\" -CFLAGS += -DMINIMAL_JVM -DCOMPILER1 -DVMTYPE=\"Minimal\" - -Src_Dirs/MINIMAL1 = $(CORE_PATHS) $(COMPILER1_PATHS) - -Src_Files_EXCLUDE/MINIMAL1 += $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp - --include $(HS_ALT_MAKE)/$(OSNAME)/makefiles/minimal1.make - -.PHONY: $(HS_ALT_MAKE)/$(OSNAME)/makefiles/minimal1.make diff --git a/hotspot/make/linux/makefiles/optimized.make b/hotspot/make/linux/makefiles/optimized.make deleted file mode 100644 index 41d5e5d792e..00000000000 --- a/hotspot/make/linux/makefiles/optimized.make +++ /dev/null @@ -1,43 +0,0 @@ -# -# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making optimized version of HotSpot VM -# (This is the "product", not the "release" version.) - -# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make -OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) -OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) - -# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files) - -# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings -CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# Linker mapfile -MAPFILE = $(GAMMADIR)/make/linux/makefiles/mapfile-vers-debug - -VERSION = optimized diff --git a/hotspot/make/linux/makefiles/ppc64.make b/hotspot/make/linux/makefiles/ppc64.make deleted file mode 100644 index acb51ab2b7a..00000000000 --- a/hotspot/make/linux/makefiles/ppc64.make +++ /dev/null @@ -1,51 +0,0 @@ -# -# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved. -# Copyright (c) 2012, 2013 SAP SE. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# make c code know it is on a 64 bit platform. -CFLAGS += -D_LP64=1 - -ifeq ($(origin OPENJDK_TARGET_CPU_ENDIAN),undefined) - # This can happen during hotspot standalone build. Set endianness from - # uname. We assume build and target machines are the same. - OPENJDK_TARGET_CPU_ENDIAN:=$(if $(filter ppc64le,$(shell uname -m)),little,big) -endif - -ifeq ($(filter $(OPENJDK_TARGET_CPU_ENDIAN),big little),) - $(error OPENJDK_TARGET_CPU_ENDIAN value should be 'big' or 'little') -endif - -ifeq ($(OPENJDK_TARGET_CPU_ENDIAN),big) - # fixes `relocation truncated to fit' error for gcc 4.1. - CFLAGS += -mminimal-toc - - # finds use ppc64 instructions, but schedule for power5 - CFLAGS += -mcpu=powerpc64 -mtune=power5 -minsert-sched-nops=regroup_exact -mno-multiple -mno-string -else - # Little endian machine uses ELFv2 ABI. - CFLAGS += -DVM_LITTLE_ENDIAN -DABI_ELFv2 - - # Use Power8, this is the first CPU to support PPC64 LE with ELFv2 ABI. - CFLAGS += -mcpu=power7 -mtune=power8 -minsert-sched-nops=regroup_exact -mno-multiple -mno-string -endif diff --git a/hotspot/make/linux/makefiles/product.make b/hotspot/make/linux/makefiles/product.make deleted file mode 100644 index 70e23c6cb5e..00000000000 --- a/hotspot/make/linux/makefiles/product.make +++ /dev/null @@ -1,54 +0,0 @@ -# -# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making optimized version of HotSpot VM -# (This is the "product", not the "release" version.) - -# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make -OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) -OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) - -# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files) - -# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings -CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# Linker mapfile -MAPFILE = $(GAMMADIR)/make/linux/makefiles/mapfile-vers-product - -SYSDEFS += -DPRODUCT -VERSION = optimized - -# use -g to strip library as -x will discard its symbol table; -x is fine for -# executables. -# Note: these macros are not used in .debuginfo configs -STRIP_LIBJVM = $(STRIP) -g $@ || exit 1; -STRIP_AOUT = $(STRIP) -x $@ || exit 1; - -# If we can create .debuginfo files, then the VM is stripped in vm.make -# and this macro is not used. -# LINK_LIB.CXX/POST_HOOK += $(STRIP_$(LINK_INTO)) diff --git a/hotspot/make/linux/makefiles/rules.make b/hotspot/make/linux/makefiles/rules.make deleted file mode 100644 index 82b952d2988..00000000000 --- a/hotspot/make/linux/makefiles/rules.make +++ /dev/null @@ -1,214 +0,0 @@ -# -# Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Common rules/macros for the vm, adlc. - -# Tell make that .cpp is important -.SUFFIXES: .cpp $(SUFFIXES) - -DEMANGLER = c++filt -DEMANGLE = $(DEMANGLER) < $@ > .$@ && $(MV) -f .$@ $@ - -# $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++). -CC_COMPILE = $(CC) $(CXXFLAGS) $(CFLAGS) -CXX_COMPILE = $(CXX) $(CXXFLAGS) $(CFLAGS) - -AS.S = $(AS) $(ASFLAGS) - -COMPILE.CC = $(CC_COMPILE) -c -GENASM.CC = $(CC_COMPILE) -S -LINK.CC = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS) -LINK_LIB.CC = $(CC) $(LFLAGS) $(SHARED_FLAG) -PREPROCESS.CC = $(CC_COMPILE) -E - -COMPILE.CXX = $(CXX_COMPILE) -c -GENASM.CXX = $(CXX_COMPILE) -S -LINK.CXX = $(CXX) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS) -LINK_NOPROF.CXX = $(CXX) $(LFLAGS) $(AOUT_FLAGS) -LINK_LIB.CXX = $(CXX) $(LFLAGS) $(SHARED_FLAG) -PREPROCESS.CXX = $(CXX_COMPILE) -E - -# cross compiling the jvm with c2 requires host compilers to build -# adlc tool - -HOST.CXX_COMPILE = $(HOSTCXX) $(CXXFLAGS) $(CFLAGS) -HOST.COMPILE.CXX = $(HOST.CXX_COMPILE) -c -HOST.LINK_NOPROF.CXX = $(HOSTCXX) $(LFLAGS) $(AOUT_FLAGS) - - -# Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k". -REMOVE_TARGET = rm -f $@ - -# Note use of ALT_BOOTDIR to explicitly specify location of java and -# javac; this is the same environment variable used in the J2SE build -# process for overriding the default spec, which is BOOTDIR. -# Note also that we fall back to using JAVA_HOME if neither of these is -# specified. - -ifdef ALT_BOOTDIR - -RUN.JAVA = $(ALT_BOOTDIR)/bin/java -RUN.JAVAP = $(ALT_BOOTDIR)/bin/javap -RUN.JAVAH = $(ALT_BOOTDIR)/bin/javah -RUN.JAR = $(ALT_BOOTDIR)/bin/jar -COMPILE.JAVAC = $(ALT_BOOTDIR)/bin/javac -COMPILE.RMIC = $(ALT_BOOTDIR)/bin/rmic -BOOT_JAVA_HOME = $(ALT_BOOTDIR) - -else - -ifdef BOOTDIR - -RUN.JAVA = $(BOOTDIR)/bin/java -RUN.JAVAP = $(BOOTDIR)/bin/javap -RUN.JAVAH = $(BOOTDIR)/bin/javah -RUN.JAR = $(BOOTDIR)/bin/jar -COMPILE.JAVAC = $(BOOTDIR)/bin/javac -COMPILE.RMIC = $(BOOTDIR)/bin/rmic -BOOT_JAVA_HOME = $(BOOTDIR) - -else - -ifdef JAVA_HOME - -RUN.JAVA = $(JAVA_HOME)/bin/java -RUN.JAVAP = $(JAVA_HOME)/bin/javap -RUN.JAVAH = $(JAVA_HOME)/bin/javah -RUN.JAR = $(JAVA_HOME)/bin/jar -COMPILE.JAVAC = $(JAVA_HOME)/bin/javac -COMPILE.RMIC = $(JAVA_HOME)/bin/rmic -BOOT_JAVA_HOME = $(JAVA_HOME) - -else - -# take from the PATH, if ALT_BOOTDIR, BOOTDIR and JAVA_HOME are not defined - -RUN.JAVA = java -RUN.JAVAP = javap -RUN.JAVAH = javah -RUN.JAR = jar -COMPILE.JAVAC = javac -COMPILE.RMIC = rmic - -endif -endif -endif - -COMPILE.JAVAC += $(BOOTSTRAP_JAVAC_FLAGS) - -SUM = /usr/bin/sum - -# 'gmake MAKE_VERBOSE=y' gives all the gory details. -QUIETLY$(MAKE_VERBOSE) = @ -RUN.JAR$(MAKE_VERBOSE) += >/dev/null - -# Settings for javac -JAVAC_FLAGS = -g -encoding ascii - -# Prefer BOOT_JDK_SOURCETARGET if it's set (typically by the top build system) -# Fall back to the values here if it's not set (hotspot only builds) -ifeq ($(BOOT_JDK_SOURCETARGET),) -BOOTSTRAP_SOURCETARGET := -source 8 -target 8 -else -BOOTSTRAP_SOURCETARGET := $(BOOT_JDK_SOURCETARGET) -endif - -BOOTSTRAP_JAVAC_FLAGS = $(JAVAC_FLAGS) $(BOOTSTRAP_SOURCETARGET) - -# With parallel makes, print a message at the end of compilation. -ifeq ($(findstring j,$(MFLAGS)),j) -COMPILE_DONE = && { echo Done with $<; } -endif - -# Include $(NONPIC_OBJ_FILES) definition -ifndef LP64 -include $(GAMMADIR)/make/pic.make -endif - -include $(GAMMADIR)/make/altsrc.make - -# The non-PIC object files are only generated for 32 bit platforms. -ifdef LP64 -%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE) -else -%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \ - $(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \ - $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)) -endif - -%.o: %.s - @echo $(LOG_INFO) Assembling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(AS.S) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE) - -# gcc applies preprocessing if the file extension is .S instead of .s -%.o: %.S - @echo $(LOG_INFO) Preprocessing and assembling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(AS.S) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE) - -%.s: %.cpp - @echo $(LOG_INFO) Generating assembly for $< - $(QUIETLY) $(GENASM.CXX) -o $@ $< - $(QUIETLY) $(DEMANGLE) $(COMPILE_DONE) - -# Intermediate files (for debugging macros) -%.i: %.cpp - @echo $(LOG_INFO) Preprocessing $< to $@ - $(QUIETLY) $(PREPROCESS.CXX) $< > $@ $(COMPILE_DONE) - -# Override gnumake built-in rules which do sccs get operations badly. -# (They put the checked out code in the current directory, not in the -# directory of the original file.) Since this is a symptom of a teamware -# failure, and since not all problems can be detected by gnumake due -# to incomplete dependency checking... just complain and stop. -%:: s.% - @echo "=========================================================" - @echo File $@ - @echo is out of date with respect to its SCCS file. - @echo This file may be from an unresolved Teamware conflict. - @echo This is also a symptom of a Teamware bringover/putback failure - @echo in which SCCS files are updated but not checked out. - @echo Check for other out of date files in your workspace. - @echo "=========================================================" - @exit 666 - -%:: SCCS/s.% - @echo "=========================================================" - @echo File $@ - @echo is out of date with respect to its SCCS file. - @echo This file may be from an unresolved Teamware conflict. - @echo This is also a symptom of a Teamware bringover/putback failure - @echo in which SCCS files are updated but not checked out. - @echo Check for other out of date files in your workspace. - @echo "=========================================================" - @exit 666 - -.PHONY: default diff --git a/hotspot/make/linux/makefiles/shark.make b/hotspot/make/linux/makefiles/shark.make deleted file mode 100644 index ca702ee6616..00000000000 --- a/hotspot/make/linux/makefiles/shark.make +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright 2008, 2010 Red Hat, Inc. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making Shark version of VM - -TYPE = SHARK - -VM_SUBDIR = server - -CFLAGS += -DSHARK diff --git a/hotspot/make/linux/makefiles/sparc.make b/hotspot/make/linux/makefiles/sparc.make deleted file mode 100644 index ddb05132fab..00000000000 --- a/hotspot/make/linux/makefiles/sparc.make +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - diff --git a/hotspot/make/linux/makefiles/sparcWorks.make b/hotspot/make/linux/makefiles/sparcWorks.make deleted file mode 100644 index e39116023c5..00000000000 --- a/hotspot/make/linux/makefiles/sparcWorks.make +++ /dev/null @@ -1,107 +0,0 @@ -# -# Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -#------------------------------------------------------------------------ -# CC, CXX & AS - -# If a SPEC is not set already, then use these defaults. -ifeq ($(SPEC),) - CXX = CC - CC = cc - AS = $(CC) -c - - HOSTCXX = $(CXX) - HOSTCC = $(CC) -endif - -ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) -ARCHFLAG/i486 = -m32 -ARCHFLAG/amd64 = -m64 - -CFLAGS += $(ARCHFLAG) -AOUT_FLAGS += $(ARCHFLAG) -LFLAGS += $(ARCHFLAG) -ASFLAGS += $(ARCHFLAG) - -#------------------------------------------------------------------------ -# Compiler flags - -# position-independent code -PICFLAG = -KPIC - -CFLAGS += $(PICFLAG) -# no more exceptions -CFLAGS += -features=no%except -# Reduce code bloat by reverting back to 5.0 behavior for static initializers -CFLAGS += -features=no%split_init -# allow zero sized arrays -CFLAGS += -features=zla - -# Use C++ Interpreter -ifdef CC_INTERP - CFLAGS += -DCC_INTERP -endif - -# We don't need libCstd.so and librwtools7.so, only libCrun.so -CFLAGS += -library=Crun -LIBS += -lCrun - -CFLAGS += -mt -LFLAGS += -mt - -# Compiler warnings are treated as errors -#WARNINGS_ARE_ERRORS = -errwarn=%all -CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) -# Special cases -CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) - -# The flags to use for an Optimized build -OPT_CFLAGS+=-xO4 -OPT_CFLAGS/NOOPT=-xO0 - -# Flags for creating the dependency files. -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1) -DEPFLAGS = -xMMD -xMF $(DEP_DIR)/$(@:%=%.d) -endif - -# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. -CFLAGS += -DDONT_USE_PRECOMPILED_HEADER - -#------------------------------------------------------------------------ -# Linker flags - -# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. -MAPFLAG = -Wl,--version-script=FILENAME - -# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj -SONAMEFLAG = -h SONAME - -# Build shared library -SHARED_FLAG = -G - -#------------------------------------------------------------------------ -# Debug flags -DEBUG_CFLAGS += -g -FASTDEBUG_CFLAGS = -g0 - diff --git a/hotspot/make/linux/makefiles/sparcv9.make b/hotspot/make/linux/makefiles/sparcv9.make deleted file mode 100644 index b9e4e525d76..00000000000 --- a/hotspot/make/linux/makefiles/sparcv9.make +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# gcc 4.0 miscompiles this code in -m64 -OPT_CFLAGS/macro.o = -O0 - -CFLAGS += -D_LP64=1 diff --git a/hotspot/make/linux/makefiles/tiered.make b/hotspot/make/linux/makefiles/tiered.make deleted file mode 100644 index da79ade9fdc..00000000000 --- a/hotspot/make/linux/makefiles/tiered.make +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making tiered version of VM - -TYPE=TIERED - -VM_SUBDIR = server - -CFLAGS += -DCOMPILER2 -DCOMPILER1 diff --git a/hotspot/make/linux/makefiles/top.make b/hotspot/make/linux/makefiles/top.make deleted file mode 100644 index d798d42851e..00000000000 --- a/hotspot/make/linux/makefiles/top.make +++ /dev/null @@ -1,150 +0,0 @@ -# -# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# top.make is included in the Makefile in the build directories. -# It DOES NOT include the vm dependency info in order to be faster. -# Its main job is to implement the incremental form of make lists. -# It also: -# -builds and runs adlc via adlc.make -# -generates JVMTI source and docs via jvmti.make (JSR-163) - -# It assumes the following flags are set: -# CFLAGS Platform_file, Src_Dirs_I, Src_Dirs_V, SYSDEFS, AOUT, Obj_Files - -# -- D. Ungar (5/97) from a file by Bill Bush - -# Don't override the built-in $(MAKE). -# Instead, use "gmake" (or "gnumake") from the command line. --Rose -#MAKE = gmake - -include $(GAMMADIR)/make/altsrc.make - -TOPDIR = $(shell echo `pwd`) -GENERATED = $(TOPDIR)/../generated -VM = $(GAMMADIR)/src/share/vm -Plat_File = $(Platform_file) -CDG = cd $(GENERATED); - -ifneq ($(USE_PRECOMPILED_HEADER),0) -UpdatePCH = $(MAKE) -f vm.make $(PRECOMPILED_HEADER) $(MFLAGS) -else -UpdatePCH = \# precompiled header is not used -endif - -Cached_plat = $(GENERATED)/platform.current - -AD_Dir = $(GENERATED)/adfiles -ADLC = $(AD_Dir)/adlc -AD_Spec = $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad) -AD_Src = $(call altsrc-replace,$(HS_COMMON_SRC)/share/vm/adlc) -AD_Names = ad_$(Platform_arch_model).hpp ad_$(Platform_arch_model).cpp -AD_Files = $(AD_Names:%=$(AD_Dir)/%) - -# AD_Files_If_Required/COMPILER1 = ad_stuff -AD_Files_If_Required/COMPILER2 = ad_stuff -AD_Files_If_Required/TIERED = ad_stuff -AD_Files_If_Required = $(AD_Files_If_Required/$(TYPE)) - -# Wierd argument adjustment for "gnumake -j..." -adjust-mflags = $(GENERATED)/adjust-mflags -# If SPEC is set, it's from configure and it's already controlling concurrency -# for us. Skip setting -j with HOTSPOT_BUILD_JOBS. -ifeq ($(SPEC), ) - MFLAGS-adjusted = -r `$(adjust-mflags) "$(MFLAGS)" "$(HOTSPOT_BUILD_JOBS)"` -else - MFLAGS-adjusted = -r $(MFLAGS) -endif - - -# default target: update lists, make vm -# done in stages to force sequential order with parallel make -# - -default: vm_build_preliminaries the_vm - @echo All done. - -# This is an explicit dependency for the sake of parallel makes. -vm_build_preliminaries: checks $(Cached_plat) $(AD_Files_If_Required) trace_stuff jvmti_stuff dtrace_stuff - @# We need a null action here, so implicit rules don't get consulted. - -$(Cached_plat): $(Plat_File) - $(CDG) $(CP) $(Plat_File) $(Cached_plat) - -# make AD files as necessary -ad_stuff: $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f adlc.make $(MFLAGS-adjusted) - -# generate JVMTI files from the spec -jvmti_stuff: $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f jvmti.make $(MFLAGS-adjusted) - -# generate trace files -trace_stuff: jvmti_stuff $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f trace.make $(MFLAGS-adjusted) - -dtrace_stuff: $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f dtrace.make dtrace_gen_headers $(MFLAGS-adjusted) GENERATED=$(GENERATED) - -# and the VM: must use other makefile with dependencies included - -# We have to go to great lengths to get control over the -jN argument -# to the recursive invocation of vm.make. The problem is that gnumake -# resets -jN to -j1 for recursive runs. (How helpful.) -# Note that the user must specify the desired parallelism level via a -# command-line or environment variable name HOTSPOT_BUILD_JOBS. -$(adjust-mflags): $(GAMMADIR)/make/$(Platform_os_family)/makefiles/adjust-mflags.sh - @+rm -f $@ $@+ - @+cat $< > $@+ - @+chmod +x $@+ - @+mv $@+ $@ - -the_vm: vm_build_preliminaries $(adjust-mflags) - +@$(UpdatePCH) - @$(MAKE) -f vm.make $(MFLAGS-adjusted) - -install: the_vm - @$(MAKE) -f vm.make $@ - -# next rules support "make foo.[ois]" - -%.o %.i %.s: - +$(UpdatePCH) - $(MAKE) -f vm.make $(MFLAGS) $@ - #$(MAKE) -f vm.make $@ - -# this should force everything to be rebuilt -clean: - rm -f $(GENERATED)/*.class - $(MAKE) -f vm.make $(MFLAGS) clean - -# just in case it doesn't, this should do it -realclean: - $(MAKE) -f vm.make $(MFLAGS) clean - rm -fr $(GENERATED) - -.PHONY: default vm_build_preliminaries -.PHONY: lists ad_stuff jvmti_stuff the_vm clean realclean -.PHONY: checks check_os_version install - -.NOTPARALLEL: diff --git a/hotspot/make/linux/makefiles/trace.make b/hotspot/make/linux/makefiles/trace.make deleted file mode 100644 index 2209716d35b..00000000000 --- a/hotspot/make/linux/makefiles/trace.make +++ /dev/null @@ -1,119 +0,0 @@ -# -# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (trace.make) is included from the trace.make in the -# build directories. -# -# It knows how to build and run the tools to generate trace files. - -include $(GAMMADIR)/make/linux/makefiles/rules.make -include $(GAMMADIR)/make/altsrc.make - -# ######################################################################### - -HAS_ALT_SRC := false -ifndef OPENJDK - ifneq ($(wildcard $(HS_ALT_SRC)/share/vm/trace), ) - HAS_ALT_SRC := true - endif -endif - -TOPDIR = $(shell echo `pwd`) -GENERATED = $(TOPDIR)/../generated -JvmtiOutDir = $(GENERATED)/jvmtifiles -TraceOutDir = $(GENERATED)/tracefiles - -TraceAltSrcDir = $(HS_ALT_SRC)/share/vm/trace -TraceSrcDir = $(HS_COMMON_SRC)/share/vm/trace - -# set VPATH so make knows where to look for source files -Src_Dirs_V += $(TraceSrcDir) $(TraceAltSrcDir) -VPATH += $(Src_Dirs_V:%=%:) - -TraceGeneratedNames = \ - traceEventClasses.hpp \ - traceEventIds.hpp \ - traceTypes.hpp - -ifeq ($(HAS_ALT_SRC), true) -TraceGeneratedNames += \ - traceRequestables.hpp \ - traceEventControl.hpp -endif - -TraceGeneratedFiles = $(TraceGeneratedNames:%=$(TraceOutDir)/%) - -XSLT = $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen - -TraceXml = $(TraceSrcDir)/trace.xml -ifeq ($(HAS_ALT_SRC), true) - TraceXml = $(TraceAltSrcDir)/trace.xml -endif - -XML_DEPS = $(TraceXml) $(TraceSrcDir)/tracetypes.xml \ - $(TraceSrcDir)/trace.dtd $(TraceSrcDir)/xinclude.mod \ - $(TraceSrcDir)/tracerelationdecls.xml $(TraceSrcDir)/traceevents.xml -ifeq ($(HAS_ALT_SRC), true) - XML_DEPS += $(TraceAltSrcDir)/traceeventscustom.xml \ - $(TraceAltSrcDir)/traceeventtypes.xml -endif - -.PHONY: all clean cleanall - -# ######################################################################### - -all: $(TraceGeneratedFiles) - -GENERATE_CODE= \ - $(QUIETLY) echo $(LOG_INFO) Generating $@; \ - $(XSLT) -IN $(word 1,$^) -XSL $(word 2,$^) -OUT $@ - -$(TraceOutDir)/traceEventIds.hpp: $(TraceXml) $(TraceSrcDir)/traceEventIds.xsl $(XML_DEPS) - $(GENERATE_CODE) - -$(TraceOutDir)/traceTypes.hpp: $(TraceXml) $(TraceSrcDir)/traceTypes.xsl $(XML_DEPS) - $(GENERATE_CODE) - -ifeq ($(HAS_ALT_SRC), false) - -$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceSrcDir)/traceEventClasses.xsl $(XML_DEPS) - $(GENERATE_CODE) - -else - -$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventClasses.xsl $(XML_DEPS) - $(GENERATE_CODE) - -$(TraceOutDir)/traceRequestables.hpp: $(TraceXml) $(TraceAltSrcDir)/traceRequestables.xsl $(XML_DEPS) - $(GENERATE_CODE) - -$(TraceOutDir)/traceEventControl.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventControl.xsl $(XML_DEPS) - $(GENERATE_CODE) - -endif - -# ######################################################################### - -clean cleanall: - rm $(TraceGeneratedFiles) diff --git a/hotspot/make/linux/makefiles/vm.make b/hotspot/make/linux/makefiles/vm.make deleted file mode 100644 index f97884af1da..00000000000 --- a/hotspot/make/linux/makefiles/vm.make +++ /dev/null @@ -1,407 +0,0 @@ -# -# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Rules to build JVM and related libraries, included from vm.make in the build -# directory. - -# Common build rules. -MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles -include $(MAKEFILES_DIR)/rules.make -include $(GAMMADIR)/make/altsrc.make - -default: build - -#---------------------------------------------------------------------- -# Defs - -GENERATED = ../generated -DEP_DIR = $(GENERATED)/dependencies - -# reads the generated files defining the set of .o's and the .o .h dependencies --include $(DEP_DIR)/*.d - -# read machine-specific adjustments (%%% should do this via buildtree.make?) -ifeq ($(findstring true, $(JVM_VARIANT_ZERO) $(JVM_VARIANT_ZEROSHARK)), true) - include $(MAKEFILES_DIR)/zeroshark.make -else - BUILDARCH_MAKE = $(MAKEFILES_DIR)/$(BUILDARCH).make - ALT_BUILDARCH_MAKE = $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/$(BUILDARCH).make - include $(if $(wildcard $(ALT_BUILDARCH_MAKE)),$(ALT_BUILDARCH_MAKE),$(BUILDARCH_MAKE)) -endif - -# set VPATH so make knows where to look for source files -# Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm -# The adfiles directory contains ad_.[ch]pp. -# The jvmtifiles directory contains jvmti*.[ch]pp -Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles $(GENERATED)/tracefiles $(GENERATED)/extensions -VPATH += $(Src_Dirs_V:%=%:) - -# set INCLUDES for C preprocessor. -Src_Dirs_I += $(GENERATED) -# The order is important for the precompiled headers to work. -INCLUDES += $(PRECOMPILED_HEADER_DIR:%=-I%) $(Src_Dirs_I:%=-I%) - -# SYMFLAG is used by jsig.make -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - # always build with debug info when we can create .debuginfo files - SYMFLAG = -g -else - ifeq (${VERSION}, debug) - SYMFLAG = -g - else - SYMFLAG = - endif -endif - -# The following variables are defined in the generated flags.make file. -JDK_VER_DEFS = -DVERSION_MAJOR=$(VERSION_MAJOR) \ - -DVERSION_MINOR=$(VERSION_MINOR) \ - -DVERSION_SECURITY=$(VERSION_SECURITY) \ - -DVERSION_PATCH=$(VERSION_PATCH) \ - -DVERSION_BUILD=$(VERSION_BUILD) -VM_VER_DEFS = -DHOTSPOT_VERSION_STRING="\"$(HOTSPOT_VERSION_STRING)\"" \ - -DVERSION_STRING="\"$(VERSION_STRING)\"" \ - -DDEBUG_LEVEL="\"$(DEBUG_LEVEL)\"" \ - $(JDK_VER_DEFS) -HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\"" -VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\"" - -CXXFLAGS = \ - ${SYSDEFS} \ - ${INCLUDES} \ - ${BUILD_USER} \ - ${HS_LIB_ARCH} \ - ${VM_DISTRO} - -# This is VERY important! The version define must only be supplied to vm_version.o -# If not, ccache will not re-use the cache at all, since the version string might contain -# a time and date. -CXXFLAGS/vm_version.o += ${VM_VER_DEFS} - -CXXFLAGS/BYFILE = $(CXXFLAGS/$@) - -# File specific flags -CXXFLAGS += $(CXXFLAGS/BYFILE) - -# Large File Support -ifneq ($(LP64), 1) -CXXFLAGS/ostream.o += -D_FILE_OFFSET_BITS=64 -endif # ifneq ($(LP64), 1) - -# CFLAGS_WARN holds compiler options to suppress/enable warnings. -CFLAGS += $(CFLAGS_WARN/BYFILE) - -# Do not use C++ exception handling -CFLAGS += $(CFLAGS/NOEX) - -# Extra flags from gnumake's invocation or environment -CFLAGS += $(EXTRA_CFLAGS) -LFLAGS += $(EXTRA_CFLAGS) - -# Don't set excutable bit on stack segment -# the same could be done by separate execstack command -LFLAGS += -Xlinker -z -Xlinker noexecstack - -LIBS += -lm -ldl -lpthread - -# By default, link the *.o into the library, not the executable. -LINK_INTO$(LINK_INTO) = LIBJVM - -JDK_LIBDIR = $(JAVA_HOME)/lib/$(LIBARCH) - -#---------------------------------------------------------------------- -# jvm_db & dtrace -include $(MAKEFILES_DIR)/dtrace.make - -#---------------------------------------------------------------------- -# JVM - -JVM = jvm -LIBJVM = lib$(JVM).so - -LIBJVM_DEBUGINFO = lib$(JVM).debuginfo -LIBJVM_DIZ = lib$(JVM).diz - -SPECIAL_PATHS:=adlc c1 gc opto shark libadt - -SOURCE_PATHS=\ - $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \ - \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \)) -SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm -SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm -SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm -SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm - -CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path)) -CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles - -ifneq ($(INCLUDE_TRACE), false) -CORE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \ - find $(HS_ALT_SRC)/share/vm/jfr -type d; \ - fi) -endif - -CORE_PATHS+=$(GENERATED)/extensions - -COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1) -COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1 - -COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto) -COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt) -COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto -COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt -COMPILER2_PATHS += $(GENERATED)/adfiles - -SHARK_PATHS := $(GAMMADIR)/src/share/vm/shark - -# Include dirs per type. -Src_Dirs/CORE := $(CORE_PATHS) -Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS) -Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS) -Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS) -Src_Dirs/ZERO := $(CORE_PATHS) -Src_Dirs/SHARK := $(CORE_PATHS) $(SHARK_PATHS) -Src_Dirs := $(Src_Dirs/$(TYPE)) - -COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\* -COMPILER1_SPECIFIC_FILES := c1_\* -SHARK_SPECIFIC_FILES := shark -ZERO_SPECIFIC_FILES := zero - -# Always exclude these. -Src_Files_EXCLUDE += jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp - -# Exclude per type. -Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) -Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) -Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) - -Src_Files_EXCLUDE += $(Src_Files_EXCLUDE/$(TYPE)) - -# Special handling of arch model. -ifeq ($(Platform_arch_model), x86_32) -Src_Files_EXCLUDE += \*x86_64\* -endif -ifeq ($(Platform_arch_model), x86_64) -Src_Files_EXCLUDE += \*x86_32\* -endif - -Src_Files_BASE += \*.c \*.cpp \*.s - -# Alternate vm.make -# This has to be included here to allow changes to the source -# directories and excluded files before they are expanded -# by the definition of Src_Files. --include $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/vm.make - -# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE. -define findsrc - $(notdir $(shell find $(1)/. ! -name . -prune \ - -a \( -name DUMMY $(addprefix -o -name ,$(Src_Files_BASE)) \) \ - -a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \))) -endef - -Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e))) - -Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files))) $(EXTENDED_JVM_OBJ_FILES)) - -JVM_OBJ_FILES = $(Obj_Files) - -vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES)) - -MAPFILE_SHARE := $(GAMMADIR)/make/share/makefiles/mapfile-vers - -MAPFILE_EXT_SRC := $(HS_ALT_MAKE)/share/makefiles/mapfile-ext -ifneq ("$(wildcard $(MAPFILE_EXT_SRC))","") -MAPFILE_EXT := $(MAPFILE_EXT_SRC) -endif - -mapfile : $(MAPFILE) $(MAPFILE_SHARE) vm.def $(MAPFILE_EXT) - rm -f $@ - awk '{ if ($$0 ~ "INSERT VTABLE SYMBOLS HERE") \ - { system ("cat ${MAPFILE_SHARE} $(MAPFILE_EXT) vm.def"); } \ - else \ - { print $$0 } \ - }' > $@ < $(MAPFILE) - -mapfile_reorder : mapfile $(REORDERFILE) - rm -f $@ - cat $^ > $@ - -VMDEF_PAT = ^_ZTV -VMDEF_PAT := ^gHotSpotVM|$(VMDEF_PAT) -VMDEF_PAT := ^UseSharedSpaces$$|$(VMDEF_PAT) -VMDEF_PAT := ^_ZN9Arguments17SharedArchivePathE$$|$(VMDEF_PAT) -ifneq ($(VMDEF_PAT_EXT),) - VMDEF_PAT := $(VMDEF_PAT_EXT)|$(VMDEF_PAT) -endif - -vm.def: $(Res_Files) $(Obj_Files) $(VM_DEF_EXT) - $(QUIETLY) $(NM) --defined-only $(Obj_Files) | sort -k3 -u | \ - awk '$$3 ~ /$(VMDEF_PAT)/ { print "\t" $$3 ";" }' > $@ -ifneq ($(VM_DEF_EXT),) - cat $(VM_DEF_EXT) >> $@ -endif - -ifeq ($(JVM_VARIANT_ZEROSHARK), true) - STATIC_CXX = false -else - ifeq ($(ZERO_LIBARCH), ppc64) - STATIC_CXX = false - else - STATIC_CXX = true - endif -endif - -ifeq ($(LINK_INTO),AOUT) - LIBJVM.o = - LIBJVM_MAPFILE = - LIBS_VM = $(LIBS) -else - LIBJVM.o = $(JVM_OBJ_FILES) - LIBJVM_MAPFILE$(LDNOMAP) = mapfile_reorder - LFLAGS_VM$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE)) - LFLAGS_VM += $(SONAMEFLAG:SONAME=$(LIBJVM)) - LFLAGS_VM += -Wl,-z,defs - - # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to - # get around library dependency and compatibility issues. Must use gcc not - # g++ to link. - ifeq ($(STATIC_CXX), true) - LFLAGS_VM += $(STATIC_LIBGCC) - LIBS_VM += $(STATIC_STDCXX) - else - LIBS_VM += -lstdc++ - endif - - LIBS_VM += $(LIBS) -endif -ifeq ($(JVM_VARIANT_ZERO), true) - LIBS_VM += $(LIBFFI_LIBS) -endif -ifeq ($(JVM_VARIANT_ZEROSHARK), true) - LIBS_VM += $(LIBFFI_LIBS) $(LLVM_LIBS) - LFLAGS_VM += $(LLVM_LDFLAGS) -endif - -LINK_VM = $(LINK_LIB.CC) - -# rule for building precompiled header -$(PRECOMPILED_HEADER): - $(QUIETLY) echo $(LOG_INFO) Generating precompiled header $@ - $(QUIETLY) mkdir -p $(PRECOMPILED_HEADER_DIR) - $(QUIETLY) rm -f $@ - $(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -x c++-header $(PRECOMPILED_HEADER_SRC) -o $@ $(COMPILE_DONE) - -# making the library: - -ifneq ($(JVM_BASE_ADDR),) -# By default shared library is linked at base address == 0. Modify the -# linker script if JVM prefers a different base location. It can also be -# implemented with 'prelink -r'. But 'prelink' is not (yet) available on -# our build platform (AS-2.1). -LD_SCRIPT = libjvm.so.lds -$(LD_SCRIPT): $(LIBJVM_MAPFILE) - $(QUIETLY) { \ - rm -rf $@; \ - $(LINK_VM) -Wl,--verbose $(LFLAGS_VM) 2>&1 | \ - sed -e '/^======/,/^======/!d' \ - -e '/^======/d' \ - -e 's/0\( + SIZEOF_HEADERS\)/$(JVM_BASE_ADDR)\1/' \ - > $@; \ - } -LD_SCRIPT_FLAG = -Wl,-T,$(LD_SCRIPT) -endif - -# With more recent Redhat releases (or the cutting edge version Fedora), if -# SELinux is configured to be enabled, the runtime linker will fail to apply -# the text relocation to libjvm.so considering that it is built as a non-PIC -# DSO. To workaround that, we run chcon to libjvm.so after it is built. See -# details in bug 6538311. -$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) $(LD_SCRIPT) - $(QUIETLY) { \ - echo $(LOG_INFO) Linking vm...; \ - $(LINK_LIB.CXX/PRE_HOOK) \ - $(LINK_VM) $(LD_SCRIPT_FLAG) \ - $(LFLAGS_VM) -o $@ $(sort $(LIBJVM.o)) $(LIBS_VM); \ - $(LINK_LIB.CXX/POST_HOOK) \ - rm -f $@.1; ln -s $@ $@.1; \ - if [ \"$(CROSS_COMPILE_ARCH)\" = \"\" ] ; then \ - if [ -x /usr/sbin/selinuxenabled ] ; then \ - if /usr/sbin/selinuxenabled; then \ - if ! /usr/bin/chcon -t textrel_shlib_t $@; then \ - echo "ERROR: Cannot chcon $@"; \ - fi \ - fi \ - fi \ - fi \ - } - -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO) - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@ - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -g $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO) - $(RM) $(LIBJVM_DEBUGINFO) - endif -endif - -DEST_SUBDIR = $(JDK_LIBDIR)/$(VM_SUBDIR) -DEST_JVM = $(DEST_SUBDIR)/$(LIBJVM) -DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO) -DEST_JVM_DIZ = $(DEST_SUBDIR)/$(LIBJVM_DIZ) - -install_jvm: $(LIBJVM) - @echo "Copying $(LIBJVM) to $(DEST_JVM)" - $(QUIETLY) test ! -f $(LIBJVM_DEBUGINFO) || \ - $(CP) -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO) - $(QUIETLY) test ! -f $(LIBJVM_DIZ) || \ - $(CP) -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ) - $(QUIETLY) $(CP) -f $(LIBJVM) $(DEST_JVM) && echo "Done" - -#---------------------------------------------------------------------- -# Other files - -# Signal interposition library -include $(MAKEFILES_DIR)/jsig.make - -#---------------------------------------------------------------------- - -build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) dtraceCheck - -install: install_jvm install_jsig - -.PHONY: default build install install_jvm $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/$(BUILDARCH).make $(HS_ALT_MAKE)/$(Platform_os_family)/makefiles/vm.make diff --git a/hotspot/make/linux/makefiles/zero.make b/hotspot/make/linux/makefiles/zero.make deleted file mode 100644 index 622710f4dfa..00000000000 --- a/hotspot/make/linux/makefiles/zero.make +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# Copyright 2009 Red Hat, Inc. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Setup for Zero (non-Shark) version of VM - -# Select which files to use (in top.make) -TYPE = ZERO - -# Install libjvm.so, etc in in server directory. -VM_SUBDIR = server - -# Disable trace for zero builds -# NOTE: This is used for simple comparison with the new build system, and -# should not be merged into mainline with build-infra. -INCLUDE_TRACE := false diff --git a/hotspot/make/linux/makefiles/zeroshark.make b/hotspot/make/linux/makefiles/zeroshark.make deleted file mode 100644 index 4f9a70c98fa..00000000000 --- a/hotspot/make/linux/makefiles/zeroshark.make +++ /dev/null @@ -1,46 +0,0 @@ -# -# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. -# Copyright 2007, 2008 Red Hat, Inc. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Setup common to Zero (non-Shark) and Shark versions of VM - -# Some versions of llvm do not like -Wundef -ifeq ($(USE_CLANG), true) - WARNING_FLAGS += -Wno-undef -endif - -# The copied fdlibm routines in sharedRuntimeTrig.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrig.o = $(OPT_CFLAGS/NOOPT) -# The copied fdlibm routines in sharedRuntimeTrans.o must not be optimized -OPT_CFLAGS/sharedRuntimeTrans.o = $(OPT_CFLAGS/NOOPT) - -# Specify that the CPU is little endian, if necessary -ifeq ($(ZERO_ENDIANNESS), little) - CFLAGS += -DVM_LITTLE_ENDIAN -endif - -# Specify that the CPU is 64 bit, if necessary -ifeq ($(ARCH_DATA_MODEL), 64) - CFLAGS += -D_LP64=1 -endif diff --git a/hotspot/make/linux/platform_aarch64 b/hotspot/make/linux/platform_aarch64 deleted file mode 100644 index f0bbf337c95..00000000000 --- a/hotspot/make/linux/platform_aarch64 +++ /dev/null @@ -1,15 +0,0 @@ -os_family = linux - -arch = aarch64 - -arch_model = aarch64 - -os_arch = linux_aarch64 - -os_arch_model = linux_aarch64 - -lib_arch = aarch64 - -compiler = gcc - -sysdefs = -DLINUX -D_GNU_SOURCE -DAARCH64 diff --git a/hotspot/make/linux/platform_amd64 b/hotspot/make/linux/platform_amd64 deleted file mode 100644 index b612635958e..00000000000 --- a/hotspot/make/linux/platform_amd64 +++ /dev/null @@ -1,15 +0,0 @@ -os_family = linux - -arch = x86 - -arch_model = x86_64 - -os_arch = linux_x86 - -os_arch_model = linux_x86_64 - -lib_arch = amd64 - -compiler = gcc - -sysdefs = -DLINUX -D_GNU_SOURCE -DAMD64 diff --git a/hotspot/make/linux/platform_amd64.suncc b/hotspot/make/linux/platform_amd64.suncc deleted file mode 100644 index 4366549571d..00000000000 --- a/hotspot/make/linux/platform_amd64.suncc +++ /dev/null @@ -1,17 +0,0 @@ -os_family = linux - -arch = x86 - -arch_model = x86_64 - -os_arch = linux_x86 - -os_arch_model = linux_x86_64 - -lib_arch = amd64 - -compiler = sparcWorks - -gnu_dis_arch = amd64 - -sysdefs = -DLINUX -DSPARC_WORKS -D_GNU_SOURCE -DAMD64 diff --git a/hotspot/make/linux/platform_i486 b/hotspot/make/linux/platform_i486 deleted file mode 100644 index 610ac91ce79..00000000000 --- a/hotspot/make/linux/platform_i486 +++ /dev/null @@ -1,15 +0,0 @@ -os_family = linux - -arch = x86 - -arch_model = x86_32 - -os_arch = linux_x86 - -os_arch_model = linux_x86_32 - -lib_arch = i386 - -compiler = gcc - -sysdefs = -DLINUX -D_GNU_SOURCE -DIA32 diff --git a/hotspot/make/linux/platform_i486.suncc b/hotspot/make/linux/platform_i486.suncc deleted file mode 100644 index 325a3febd96..00000000000 --- a/hotspot/make/linux/platform_i486.suncc +++ /dev/null @@ -1,17 +0,0 @@ -os_family = linux - -arch = x86 - -arch_model = x86_32 - -os_arch = linux_x86 - -os_arch_model = linux_x86_32 - -lib_arch = i386 - -compiler = sparcWorks - -gnu_dis_arch = i386 - -sysdefs = -DLINUX -DSPARC_WORKS -D_GNU_SOURCE -DIA32 diff --git a/hotspot/make/linux/platform_ia64 b/hotspot/make/linux/platform_ia64 deleted file mode 100644 index 7474e5bf923..00000000000 --- a/hotspot/make/linux/platform_ia64 +++ /dev/null @@ -1,15 +0,0 @@ -os_family = linux - -arch = ia64 - -os_arch = linux_ia64 - -lib_arch = ia64 - -compiler = gcc - -gnu_dis_arch = ia64 - -sysdefs = -DLINUX -D_GNU_SOURCE -DIA64 -DCC_INTERP - -mark_style = alignment diff --git a/hotspot/make/linux/platform_ppc64 b/hotspot/make/linux/platform_ppc64 deleted file mode 100644 index 2fd79c4dae9..00000000000 --- a/hotspot/make/linux/platform_ppc64 +++ /dev/null @@ -1,17 +0,0 @@ -os_family = linux - -arch = ppc - -arch_model = ppc_64 - -os_arch = linux_ppc - -os_arch_model = linux_ppc_64 - -lib_arch = ppc64 - -compiler = gcc - -gnu_dis_arch = ppc64 - -sysdefs = -DLINUX -D_GNU_SOURCE -DPPC64 diff --git a/hotspot/make/linux/platform_sparc b/hotspot/make/linux/platform_sparc deleted file mode 100644 index 8d9e3ee7201..00000000000 --- a/hotspot/make/linux/platform_sparc +++ /dev/null @@ -1,15 +0,0 @@ -os_family = linux - -arch = sparc - -arch_model = sparc - -os_arch = linux_sparc - -os_arch_model = linux_sparc - -lib_arch = sparc - -compiler = gcc - -sysdefs = -DLINUX -D_GNU_SOURCE -DSPARC diff --git a/hotspot/make/linux/platform_sparcv9 b/hotspot/make/linux/platform_sparcv9 deleted file mode 100644 index c9f8722c406..00000000000 --- a/hotspot/make/linux/platform_sparcv9 +++ /dev/null @@ -1,15 +0,0 @@ -os_family = linux - -arch = sparc - -arch_model = sparc - -os_arch = linux_sparc - -os_arch_model = linux_sparc - -lib_arch = sparcv9 - -compiler = gcc - -sysdefs = -DLINUX -D_GNU_SOURCE -DSPARC diff --git a/hotspot/make/linux/platform_zero.in b/hotspot/make/linux/platform_zero.in deleted file mode 100644 index 404ad3f9b58..00000000000 --- a/hotspot/make/linux/platform_zero.in +++ /dev/null @@ -1,17 +0,0 @@ -os_family = linux - -arch = zero - -arch_model = zero - -os_arch = linux_zero - -os_arch_model = linux_zero - -lib_arch = zero - -compiler = gcc - -gnu_dis_arch = zero - -sysdefs = -DLINUX -D_GNU_SOURCE -DCC_INTERP -DZERO -D@ZERO_ARCHDEF@ -DZERO_LIBARCH=\"@ZERO_LIBARCH@\" diff --git a/hotspot/makefiles/mapfiles/libjsig/mapfile-vers-solaris b/hotspot/make/mapfiles/libjsig/mapfile-vers-solaris similarity index 100% rename from hotspot/makefiles/mapfiles/libjsig/mapfile-vers-solaris rename to hotspot/make/mapfiles/libjsig/mapfile-vers-solaris diff --git a/hotspot/makefiles/mapfiles/libjvm_db/mapfile-vers b/hotspot/make/mapfiles/libjvm_db/mapfile-vers similarity index 100% rename from hotspot/makefiles/mapfiles/libjvm_db/mapfile-vers rename to hotspot/make/mapfiles/libjvm_db/mapfile-vers diff --git a/hotspot/makefiles/mapfiles/libjvm_dtrace/mapfile-vers b/hotspot/make/mapfiles/libjvm_dtrace/mapfile-vers similarity index 100% rename from hotspot/makefiles/mapfiles/libjvm_dtrace/mapfile-vers rename to hotspot/make/mapfiles/libjvm_dtrace/mapfile-vers diff --git a/hotspot/make/openjdk_distro b/hotspot/make/openjdk_distro deleted file mode 100644 index 520b33d3457..00000000000 --- a/hotspot/make/openjdk_distro +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright (c) 2007, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# -# This file format must remain compatible with both -# GNU Makefile and Microsoft nmake formats. -# - -# Don't put quotes (fail windows build). -HOTSPOT_VM_DISTRO=OpenJDK -COMPANY_NAME= -PRODUCT_NAME=OpenJDK diff --git a/hotspot/make/pic.make b/hotspot/make/pic.make deleted file mode 100644 index 9211b5b70d6..00000000000 --- a/hotspot/make/pic.make +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# A list of object files built without the platform specific PIC flags, e.g. -# -fPIC on linux. Performance measurements show that by compiling GC related -# code, we could significantly reduce the GC pause time on 32 bit Linux/Unix -# platforms. See 6454213 for more details. -include $(GAMMADIR)/make/scm.make - -ifneq ($(OSNAME), windows) - ifndef LP64 - PARTIAL_NONPIC=1 - endif - PIC_ARCH = ppc arm - ifneq ("$(filter $(PIC_ARCH),$(BUILDARCH))","") - PARTIAL_NONPIC=0 - endif - ifeq ($(PARTIAL_NONPIC),1) - NONPIC_DIRS = memory oops gc - NONPIC_DIRS := $(foreach dir,$(NONPIC_DIRS), $(GAMMADIR)/src/share/vm/$(dir)) - # Look for source files under NONPIC_DIRS - NONPIC_FILES := $(foreach dir,$(NONPIC_DIRS),\ - $(shell find $(dir) \( $(SCM_DIRS) \) -prune -o \ - -name '*.cpp' -print)) - NONPIC_OBJ_FILES := $(notdir $(subst .cpp,.o,$(NONPIC_FILES))) - endif -endif diff --git a/hotspot/make/scm.make b/hotspot/make/scm.make deleted file mode 100644 index 011492d0516..00000000000 --- a/hotspot/make/scm.make +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# Prune out all known SCM (Source Code Management) directories -# so they will not appear on -I PATHs, when copying directory trees, -# packaging up .jar files, etc. This applies to all workspaces. -# -SCM_DIRS = -name .hg -o -name .svn -o -name CVS -o -name RCS -o -name SCCS -o -name Codemgr_wsdata -o -name deleted_files diff --git a/hotspot/make/share/makefiles/mapfile-vers b/hotspot/make/share/makefiles/mapfile-vers deleted file mode 100644 index f7d08e50b98..00000000000 --- a/hotspot/make/share/makefiles/mapfile-vers +++ /dev/null @@ -1,180 +0,0 @@ - # JNI - JNI_CreateJavaVM; - JNI_GetCreatedJavaVMs; - JNI_GetDefaultJavaVMInitArgs; - - # JVM - JVM_ActiveProcessorCount; - JVM_ArrayCopy; - JVM_AssertionStatusDirectives; - JVM_CallStackWalk; - JVM_ClassDepth; - JVM_ClassLoaderDepth; - JVM_Clone; - JVM_ConstantPoolGetClassAt; - JVM_ConstantPoolGetClassAtIfLoaded; - JVM_ConstantPoolGetClassRefIndexAt; - JVM_ConstantPoolGetDoubleAt; - JVM_ConstantPoolGetFieldAt; - JVM_ConstantPoolGetFieldAtIfLoaded; - JVM_ConstantPoolGetFloatAt; - JVM_ConstantPoolGetIntAt; - JVM_ConstantPoolGetLongAt; - JVM_ConstantPoolGetMethodAt; - JVM_ConstantPoolGetMethodAtIfLoaded; - JVM_ConstantPoolGetMemberRefInfoAt; - JVM_ConstantPoolGetNameAndTypeRefInfoAt; - JVM_ConstantPoolGetNameAndTypeRefIndexAt; - JVM_ConstantPoolGetSize; - JVM_ConstantPoolGetStringAt; - JVM_ConstantPoolGetTagAt; - JVM_ConstantPoolGetUTF8At; - JVM_CountStackFrames; - JVM_CurrentClassLoader; - JVM_CurrentLoadedClass; - JVM_CurrentThread; - JVM_CurrentTimeMillis; - JVM_DefineClass; - JVM_DefineClassWithSource; - JVM_DesiredAssertionStatus; - JVM_DoPrivileged; - JVM_DumpAllStacks; - JVM_DumpThreads; - JVM_FillInStackTrace; - JVM_FindClassFromCaller; - JVM_FindClassFromClass; - JVM_FindClassFromBootLoader; - JVM_FindLibraryEntry; - JVM_FindLoadedClass; - JVM_FindPrimitiveClass; - JVM_FindSignal; - JVM_FreeMemory; - JVM_GC; - JVM_GetAllThreads; - JVM_GetArrayElement; - JVM_GetArrayLength; - JVM_GetCPClassNameUTF; - JVM_GetCPFieldClassNameUTF; - JVM_GetCPFieldModifiers; - JVM_GetCPFieldNameUTF; - JVM_GetCPFieldSignatureUTF; - JVM_GetCPMethodClassNameUTF; - JVM_GetCPMethodModifiers; - JVM_GetCPMethodNameUTF; - JVM_GetCPMethodSignatureUTF; - JVM_GetCallerClass; - JVM_GetClassAccessFlags; - JVM_GetClassAnnotations; - JVM_GetClassCPEntriesCount; - JVM_GetClassCPTypes; - JVM_GetClassConstantPool; - JVM_GetClassContext; - JVM_GetClassDeclaredConstructors; - JVM_GetClassDeclaredFields; - JVM_GetClassDeclaredMethods; - JVM_GetClassFieldsCount; - JVM_GetClassInterfaces; - JVM_GetClassMethodsCount; - JVM_GetClassModifiers; - JVM_GetClassName; - JVM_GetClassNameUTF; - JVM_GetClassSignature; - JVM_GetClassSigners; - JVM_GetClassTypeAnnotations; - JVM_GetDeclaredClasses; - JVM_GetDeclaringClass; - JVM_GetSimpleBinaryName; - JVM_GetEnclosingMethodInfo; - JVM_GetFieldIxModifiers; - JVM_GetFieldTypeAnnotations; - JVM_GetInheritedAccessControlContext; - JVM_GetInterfaceVersion; - JVM_GetManagement; - JVM_GetMethodIxArgsSize; - JVM_GetMethodIxByteCode; - JVM_GetMethodIxByteCodeLength; - JVM_GetMethodIxExceptionIndexes; - JVM_GetMethodIxExceptionTableEntry; - JVM_GetMethodIxExceptionTableLength; - JVM_GetMethodIxExceptionsCount; - JVM_GetMethodIxLocalsCount; - JVM_GetMethodIxMaxStack; - JVM_GetMethodIxModifiers; - JVM_GetMethodIxNameUTF; - JVM_GetMethodIxSignatureUTF; - JVM_GetMethodParameters; - JVM_GetMethodTypeAnnotations; - JVM_GetNanoTimeAdjustment; - JVM_GetPrimitiveArrayElement; - JVM_GetProtectionDomain; - JVM_GetStackAccessControlContext; - JVM_GetStackTraceElements; - JVM_GetSystemPackage; - JVM_GetSystemPackages; - JVM_GetTemporaryDirectory; - JVM_GetVersionInfo; - JVM_GetVmArguments; - JVM_Halt; - JVM_HoldsLock; - JVM_IHashCode; - JVM_InitAgentProperties; - JVM_InitProperties; - JVM_InternString; - JVM_Interrupt; - JVM_InvokeMethod; - JVM_IsArrayClass; - JVM_IsConstructorIx; - JVM_IsInterface; - JVM_IsInterrupted; - JVM_IsPrimitiveClass; - JVM_IsSameClassPackage; - JVM_IsSupportedJNIVersion; - JVM_IsThreadAlive; - JVM_IsVMGeneratedMethodIx; - JVM_LatestUserDefinedLoader; - JVM_LoadLibrary; - JVM_MaxObjectInspectionAge; - JVM_MaxMemory; - JVM_MonitorNotify; - JVM_MonitorNotifyAll; - JVM_MonitorWait; - JVM_MoreStackWalk; - JVM_NanoTime; - JVM_NativePath; - JVM_NewArray; - JVM_NewInstanceFromConstructor; - JVM_NewMultiArray; - JVM_RaiseSignal; - JVM_RawMonitorCreate; - JVM_RawMonitorDestroy; - JVM_RawMonitorEnter; - JVM_RawMonitorExit; - JVM_RegisterSignal; - JVM_ReleaseUTF; - JVM_ResumeThread; - JVM_SetArrayElement; - JVM_SetClassSigners; - JVM_SetNativeThreadName; - JVM_SetPrimitiveArrayElement; - JVM_SetThreadPriority; - JVM_Sleep; - JVM_StartThread; - JVM_StopThread; - JVM_SuspendThread; - JVM_SupportsCX8; - JVM_ToStackTraceElement; - JVM_TotalMemory; - JVM_UnloadLibrary; - JVM_Yield; - - # Module related API's - JVM_AddModuleExports; - JVM_AddModuleExportsToAll; - JVM_AddModuleExportsToAllUnnamed; - JVM_AddModulePackage; - JVM_AddReadsModule; - JVM_CanReadModule; - JVM_DefineModule; - JVM_IsExportedToModule; - JVM_SetBootLoaderUnnamedModule; - JVM_GetModuleByPackageName; diff --git a/hotspot/make/solaris/Makefile b/hotspot/make/solaris/Makefile deleted file mode 100644 index 4a89bb3fcf6..00000000000 --- a/hotspot/make/solaris/Makefile +++ /dev/null @@ -1,286 +0,0 @@ -# -# Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile creates a build tree and lights off a build. -# You can go back into the build tree and perform rebuilds or -# incremental builds as desired. Be sure to reestablish -# environment variable settings for LD_LIBRARY_PATH and JAVA_HOME. - -# The make process now relies on java and javac. These can be -# specified either implicitly on the PATH, by setting the -# (JDK-inherited) ALT_BOOTDIR environment variable to full path to a -# JDK in which bin/java and bin/javac are present and working (e.g., -# /usr/local/java/jdk1.3/solaris), or via the (JDK-inherited) -# default BOOTDIR path value. Note that one of ALT_BOOTDIR -# or BOOTDIR has to be set. We do *not* search javac, javah, rmic etc. -# from the PATH. - -ifeq ($(GAMMADIR),) -include ../../make/defs.make -else -include $(GAMMADIR)/make/defs.make -endif -include $(GAMMADIR)/make/$(OSNAME)/makefiles/rules.make - -ifndef CC_INTERP - ifndef FORCE_TIERED - FORCE_TIERED=1 - endif -endif - -ifdef LP64 - ifeq ("$(filter $(LP64_ARCH),$(BUILDARCH))","") - _JUNK_ := $(shell echo >&2 \ - $(OSNAME) $(ARCH) "*** ERROR: this platform does not support 64-bit compilers!") - @exit 1 - endif -endif - -# The following renders pathnames in generated Makefiles valid on -# machines other than the machine containing the build tree. -# -# For example, let's say my build tree lives on /files12 on -# exact.east.sun.com. This logic will cause GAMMADIR to begin with -# /net/exact/files12/... -# -# We only do this on SunOS variants, for a couple of reasons: -# * It is extremely rare that source trees exist on other systems -# * It has been claimed that the Linux automounter is flakey, so -# changing GAMMADIR in a way that exercises the automounter could -# prove to be a source of unreliability in the build process. -# Obviously, this Makefile is only relevant on SunOS boxes to begin -# with, but the SunOS conditionalization will make it easier to -# combine Makefiles in the future (assuming we ever do that). - -ifeq ($(OSNAME),solaris) - - # prepend current directory to relative pathnames. - NEW_GAMMADIR := \ - $(shell echo $(GAMMADIR) | \ - sed -e "s=^\([^/].*\)=$(shell pwd)/\1=" \ - ) - unexport NEW_GAMMADIR - - # If NEW_GAMMADIR doesn't already start with "/net/": - ifeq ($(strip $(filter /net/%,$(NEW_GAMMADIR))),) - # prepend /net/$(HOST) - # remove /net/$(HOST) if name already began with /home/ - # remove /net/$(HOST) if name already began with /java/ - # remove /net/$(HOST) if name already began with /lab/ - NEW_GAMMADIR := \ - $(shell echo $(NEW_GAMMADIR) | \ - sed -e "s=^\(.*\)=/net/$(HOST)\1=" \ - -e "s=^/net/$(HOST)/home/=/home/=" \ - -e "s=^/net/$(HOST)/java/=/java/=" \ - -e "s=^/net/$(HOST)/lab/=/lab/=" \ - ) - # Don't use the new value for GAMMADIR unless a file with the new - # name actually exists. - ifneq ($(wildcard $(NEW_GAMMADIR)),) - GAMMADIR := $(NEW_GAMMADIR) - endif - endif - -endif - - -# There is a (semi-) regular correspondence between make targets and actions: -# -# Target Tree Type Build Dir -# -# debug compiler2 __compiler2/debug -# fastdebug compiler2 __compiler2/fastdebug -# optimized compiler2 __compiler2/optimized -# product compiler2 __compiler2/product -# -# debug1 compiler1 __compiler1/debug -# fastdebug1 compiler1 __compiler1/fastdebug -# optimized1 compiler1 __compiler1/optimized -# product1 compiler1 __compiler1/product -# -# debugcore core __core/debug -# fastdebugcore core __core/fastdebug -# optimizedcore core __core/optimized -# productcore core __core/product -# -# What you get with each target: -# -# debug* - debug compile with asserts enabled -# fastdebug* - optimized compile, but with asserts enabled -# optimized* - optimized compile, no asserts -# product* - the shippable thing: optimized compile, no asserts, -DPRODUCT - -# This target list needs to be coordinated with the usage message -# in the build.sh script: -TARGETS = debug fastdebug optimized product - -SUBDIR_DOCS = $(OSNAME)_$(BUILDARCH)_docs -SUBDIRS_C1 = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler1/,$(TARGETS)) -SUBDIRS_C2 = $(addprefix $(OSNAME)_$(BUILDARCH)_compiler2/,$(TARGETS)) -SUBDIRS_TIERED = $(addprefix $(OSNAME)_$(BUILDARCH)_tiered/,$(TARGETS)) -SUBDIRS_CORE = $(addprefix $(OSNAME)_$(BUILDARCH)_core/,$(TARGETS)) - -TARGETS_C2 = $(TARGETS) -TARGETS_C1 = $(addsuffix 1,$(TARGETS)) -TARGETS_TIERED = $(addsuffix tiered,$(TARGETS)) -TARGETS_CORE = $(addsuffix core,$(TARGETS)) - -BUILDTREE_MAKE = $(GAMMADIR)/make/$(OSNAME)/makefiles/buildtree.make -BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OSNAME) ARCH=$(SRCARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) -BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING) -BUILDTREE_VARS += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) OBJCOPY=$(OBJCOPY) STRIP_POLICY=$(STRIP_POLICY) ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) ZIPEXE=$(ZIPEXE) - -BUILDTREE = $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_VARS) - -#------------------------------------------------------------------------------- - -# Could make everything by default, but that would take a while. -all: - @echo "Try '$(MAKE) ...' where is one or more of" - @echo " $(TARGETS_C2)" - @echo " $(TARGETS_C1)" - @echo " $(TARGETS_CORE)" - -checks: check_os_version check_j2se_version - -# We do not want people accidentally building on old systems (e.g. Linux 2.2.x, -# Solaris 2.5.1, 2.6). -# Disable this check by setting DISABLE_HOTSPOT_OS_VERSION_CHECK=ok. - -SUPPORTED_OS_VERSION = 5.7 5.8 5.9 5.10 5.11 -OS_VERSION := $(shell uname -r) -EMPTY_IF_NOT_SUPPORTED = $(filter $(SUPPORTED_OS_VERSION),$(OS_VERSION)) - -check_os_version: -ifeq ($(DISABLE_HOTSPOT_OS_VERSION_CHECK)$(EMPTY_IF_NOT_SUPPORTED),) - $(QUIETLY) >&2 echo "*** This OS is not supported:" `uname -a`; exit 1; -endif - -# jvmti.make requires XSLT (J2SE 1.4.x or newer): -XSLT_CHECK = $(RUN.JAVAP) javax.xml.transform.TransformerFactory -# If not found then fail fast. -check_j2se_version: - $(QUIETLY) if ! $(XSLT_CHECK) > /dev/null 2>&1; then \ - $(RUN.JAVA) -version; \ - echo "*** An XSLT processor (J2SE 1.4.x or newer) is required" \ - "to bootstrap this build" 1>&2; \ - exit 1; \ - fi - -$(SUBDIRS_TIERED): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=tiered - -$(SUBDIRS_C2): $(BUILDTREE_MAKE) -ifeq ($(FORCE_TIERED),1) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=tiered FORCE_TIERED=1 -else - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=compiler2 -endif - -$(SUBDIRS_C1): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=compiler1 - -$(SUBDIRS_CORE): $(BUILDTREE_MAKE) - $(QUIETLY) $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/Makefile checks - +$(BUILDTREE) VARIANT=core - -# Define INSTALL=y at command line to automatically copy JVM into JAVA_HOME - -$(TARGETS_C2): $(SUBDIRS_C2) - cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_compiler2/$@ && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_TIERED): $(SUBDIRS_TIERED) - cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_tiered/$(patsubst %tiered,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_C1): $(SUBDIRS_C1) - cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_compiler1/$(patsubst %1,%,$@) && $(MAKE) $(MFLAGS) install -endif - -$(TARGETS_CORE): $(SUBDIRS_CORE) - cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) -ifdef INSTALL - cd $(OSNAME)_$(BUILDARCH)_core/$(patsubst %core,%,$@) && $(MAKE) $(MFLAGS) install -endif - -# Just build the tree, and nothing else: -tree: $(SUBDIRS_C2) -tree1: $(SUBDIRS_C1) -treecore: $(SUBDIRS_CORE) - -# Doc target. This is the same for all build options. -# Hence create a docs directory beside ...$(ARCH)_[...] -# We specify 'BUILD_FLAVOR=product' so that the proper -# ENABLE_FULL_DEBUG_SYMBOLS value is used. -docs: checks - $(QUIETLY) mkdir -p $(SUBDIR_DOCS) - $(MAKE) -f $(GAMMADIR)/make/$(OSNAME)/makefiles/jvmti.make $(MFLAGS) $(BUILDTREE_VARS) JvmtiOutDir=$(SUBDIR_DOCS) BUILD_FLAVOR=product jvmtidocs - -# Synonyms for win32-like targets. -compiler2: debug product - -compiler1: debug1 product1 - -core: debugcore productcore - -warn_jvmg_deprecated: - echo "Warning: The jvmg target has been replaced with debug" - echo "Warning: Please update your usage" - -jvmg: warn_jvmg_deprecated debug - -jvmg1: warn_jvmg_deprecated debug1 - -jvmgcore: warn_jvmg_deprecated debugcore - -clean_docs: - rm -rf $(SUBDIR_DOCS) - -clean_compiler1 clean_compiler2 clean_core: - rm -rf $(OSNAME)_$(BUILDARCH)_$(subst clean_,,$@) - -clean: clean_compiler2 clean_compiler1 clean_core clean_docs - -include $(GAMMADIR)/make/cscope.make - -#------------------------------------------------------------------------------- - -.PHONY: $(TARGETS_C2) $(TARGETS_C1) $(TARGETS_CORE) -.PHONY: tree tree1 treecore -.PHONY: all compiler1 compiler2 core -.PHONY: clean clean_compiler1 clean_compiler2 clean_core docs clean_docs -.PHONY: checks check_os_version check_j2se_version - -.NOTPARALLEL: diff --git a/hotspot/make/solaris/adlc_updater b/hotspot/make/solaris/adlc_updater deleted file mode 100644 index 8b1df724e60..00000000000 --- a/hotspot/make/solaris/adlc_updater +++ /dev/null @@ -1,23 +0,0 @@ -#! /bin/sh -# -# This file is used by adlc.make to selectively update generated -# adlc files. Because source and target diretories are relative -# paths, this file is copied to the target build directory before -# use. -# -# adlc-updater -# -fix_lines() { - # repair bare #line directives in $1 to refer to $2 - # and add an override of __FILE__ with just the basename on the - # first line of the file. - nawk < $1 > $1+ -v F2=$2 ' - BEGIN { print "#line 1 \"" F2 "\""; } - /^#line 999999$/ {print "#line " (NR+1) " \"" F2 "\""; next} - {print} - ' - mv $1+ $1 -} -fix_lines $2/$1 $1 -[ -f $3/$1 ] && cmp -s $2/$1 $3/$1 || \ -( [ -f $3/$1 ] && echo Updating $3/$1 ; touch $2/made-change ; mv $2/$1 $3/$1 ) diff --git a/hotspot/make/solaris/makefiles/adjust-mflags.sh b/hotspot/make/solaris/makefiles/adjust-mflags.sh deleted file mode 100644 index 97bc02db7f1..00000000000 --- a/hotspot/make/solaris/makefiles/adjust-mflags.sh +++ /dev/null @@ -1,87 +0,0 @@ -#! /bin/sh -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This script is used only from top.make. -# The macro $(MFLAGS-adjusted) calls this script to -# adjust the "-j" arguments to take into account -# the HOTSPOT_BUILD_JOBS variable. The default -# handling of the "-j" argument by gnumake does -# not meet our needs, so we must adjust it ourselves. - -# This argument adjustment applies to two recursive -# calls to "$(MAKE) $(MFLAGS-adjusted)" in top.make. -# One invokes adlc.make, and the other invokes vm.make. -# The adjustment propagates the desired concurrency -# level down to the sub-make (of the adlc or vm). -# The default behavior of gnumake is to run all -# sub-makes without concurrency ("-j1"). - -# Also, we use a make variable rather than an explicit -# "-j" argument to control this setting, so that -# the concurrency setting (which must be tuned separately -# for each MP system) can be set via an environment variable. -# The recommended setting is 1.5x to 2x the number of available -# CPUs on the MP system, which is large enough to keep the CPUs -# busy (even though some jobs may be I/O bound) but not too large, -# we may presume, to overflow the system's swap space. - -set -eu - -default_build_jobs=4 - -case $# in -[12]) true;; -*) >&2 echo "Usage: $0 ${MFLAGS} ${HOTSPOT_BUILD_JOBS}"; exit 2;; -esac - -MFLAGS=$1 -HOTSPOT_BUILD_JOBS=${2-} - -# Normalize any -jN argument to the form " -j${HBJ}" -MFLAGS=` - echo "$MFLAGS" \ - | sed ' - s/^-/ -/ - s/ -\([^ I][^ I]*\)j/ -\1 -j/ - s/ -j[0-9][0-9]*/ -j/ - s/ -j\([^ ]\)/ -j -\1/ - s/ -j/ -j'${HOTSPOT_BUILD_JOBS:-${default_build_jobs}}'/ - ' ` - -case ${HOTSPOT_BUILD_JOBS} in \ - -'') case ${MFLAGS} in - *\ -j*) - >&2 echo "# Note: -jN is ineffective for setting parallelism in this makefile." - >&2 echo "# please set HOTSPOT_BUILD_JOBS=${default_build_jobs} in the command line or environment." - esac;; - -?*) case ${MFLAGS} in - *\ -j*) true;; - *) MFLAGS="-j${HOTSPOT_BUILD_JOBS} ${MFLAGS}";; - esac;; -esac - -echo "${MFLAGS}" diff --git a/hotspot/make/solaris/makefiles/adlc.make b/hotspot/make/solaris/makefiles/adlc.make deleted file mode 100644 index 730a5a36eca..00000000000 --- a/hotspot/make/solaris/makefiles/adlc.make +++ /dev/null @@ -1,257 +0,0 @@ -# -# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (adlc.make) is included from the adlc.make in the -# build directories. -# It knows how to compile, link, and run the adlc. - -include $(GAMMADIR)/make/$(Platform_os_family)/makefiles/rules.make -include $(GAMMADIR)/make/altsrc.make - -# ######################################################################### - -# OUTDIR must be the same as AD_Dir = $(GENERATED)/adfiles in top.make: -GENERATED = ../generated -OUTDIR = $(GENERATED)/adfiles - -ARCH = $(Platform_arch) -OS = $(Platform_os_family) - -SOURCE.AD = $(OUTDIR)/$(OS)_$(Platform_arch_model).ad - -ifeq ("${Platform_arch_model}", "${Platform_arch}") - SOURCES.AD = \ - $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) -else - SOURCES.AD = \ - $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch_model).ad) \ - $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(ARCH)/vm/$(Platform_arch).ad) -endif - -EXEC = $(OUTDIR)/adlc - -# set VPATH so make knows where to look for source files -Src_Dirs_V += $(GAMMADIR)/src/share/vm/adlc -VPATH += $(Src_Dirs_V:%=%:) - -# set INCLUDES for C preprocessor -Src_Dirs_I += $(GAMMADIR)/src/share/vm/adlc $(GENERATED) -INCLUDES += $(Src_Dirs_I:%=-I%) - -# set flags for adlc compilation -CXXFLAGS = $(SYSDEFS) $(INCLUDES) - -# Force assertions on. -CXXFLAGS += -DASSERT - -ifndef USE_GCC - # We need libCstd.so for adlc - CFLAGS += -library=Cstd -g - LFLAGS += -library=Cstd -g -endif - -# CFLAGS_WARN holds compiler options to suppress/enable warnings. -CFLAGS_WARN = +w -# Compiler warnings are treated as errors -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1) - WARNINGS_ARE_ERRORS ?= -xwe -endif - -CFLAGS_WARN += $(WARNINGS_ARE_ERRORS) - -# When using compiler version 5.13 (Solaris Studio 12.4), calls to explicitly -# instantiated template functions trigger this warning when +w is active. -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 513), 1) - CFLAGS_WARN += -erroff=notemsource -endif -CFLAGS += $(CFLAGS_WARN) - -ifeq ("${Platform_compiler}", "sparcWorks") -# Enable the following CFLAGS addition if you need to compare the -# built ELF objects. -# -# The -g option makes static data global and the "-Qoption ccfe -# -xglobalstatic" option tells the compiler to not globalize static -# data using a unique globalization prefix. Instead force the use -# of a static globalization prefix based on the source filepath so -# the objects from two identical compilations are the same. -#CFLAGS += -Qoption ccfe -xglobalstatic -endif # Platform_compiler == sparcWorks - -OBJECTNAMES = \ - adlparse.o \ - archDesc.o \ - arena.o \ - dfa.o \ - dict2.o \ - filebuff.o \ - forms.o \ - formsopt.o \ - formssel.o \ - main.o \ - adlc-opcodes.o \ - output_c.o \ - output_h.o \ - -OBJECTS = $(OBJECTNAMES:%=$(OUTDIR)/%) - -GENERATEDNAMES = \ - ad_$(Platform_arch_model).cpp \ - ad_$(Platform_arch_model).hpp \ - ad_$(Platform_arch_model)_clone.cpp \ - ad_$(Platform_arch_model)_expand.cpp \ - ad_$(Platform_arch_model)_format.cpp \ - ad_$(Platform_arch_model)_gen.cpp \ - ad_$(Platform_arch_model)_misc.cpp \ - ad_$(Platform_arch_model)_peephole.cpp \ - ad_$(Platform_arch_model)_pipeline.cpp \ - adGlobals_$(Platform_arch_model).hpp \ - dfa_$(Platform_arch_model).cpp \ - -GENERATEDFILES = $(GENERATEDNAMES:%=$(OUTDIR)/%) - -# ######################################################################### - -all: $(EXEC) - -$(EXEC) : $(OBJECTS) - @echo $(LOG_INFO) Making adlc - $(QUIETLY) $(LINK_NOPROF.CXX) -o $(EXEC) $(OBJECTS) - -# Random dependencies: -$(OBJECTS): opcodes.hpp classes.hpp adlc.hpp adlcVMDeps.hpp adlparse.hpp archDesc.hpp arena.hpp dict2.hpp filebuff.hpp forms.hpp formsopt.hpp formssel.hpp - -# The source files refer to ostream.h, which sparcworks calls iostream.h -$(OBJECTS): ostream.h - -ostream.h : - @echo >$@ '#include ' - -dump: - : OUTDIR=$(OUTDIR) - : OBJECTS=$(OBJECTS) - : products = $(GENERATEDFILES) - -all: $(GENERATEDFILES) - -$(GENERATEDFILES): refresh_adfiles - -# Get a unique temporary directory name, so multiple makes can run in parallel. -# Note that product files are updated via "mv", which is atomic. -TEMPDIR := $(OUTDIR)/mktmp$(shell echo $$$$) - -# Debuggable by default -CFLAGS += -g - -# Pass -D flags into ADLC. -ADLCFLAGS += $(SYSDEFS) - -# Note "+="; it is a hook so flags.make can add more flags, like -g or -DFOO. -ADLCFLAGS += -q -T - -# Normally, debugging is done directly on the ad_*.cpp files. -# But -g will put #line directives in those files pointing back to .ad. -ADLCFLAGS += -g - -ifdef LP64 -ADLCFLAGS += -D_LP64 -else -ADLCFLAGS += -U_LP64 -endif - -# -# adlc_updater is a simple sh script, under sccs control. It is -# used to selectively update generated adlc files. This should -# provide a nice compilation speed improvement. -# -ADLC_UPDATER_DIRECTORY = $(GAMMADIR)/make/$(OS) -ADLC_UPDATER = adlc_updater -$(ADLC_UPDATER): $(ADLC_UPDATER_DIRECTORY)/$(ADLC_UPDATER) - $(QUIETLY) cp $< $@; chmod +x $@ - -# This action refreshes all generated adlc files simultaneously. -# The way it works is this: -# 1) create a scratch directory to work in. -# 2) if the current working directory does not have $(ADLC_UPDATER), copy it. -# 3) run the compiled adlc executable. This will create new adlc files in the scratch directory. -# 4) call $(ADLC_UPDATER) on each generated adlc file. It will selectively update changed or missing files. -# 5) If we actually updated any files, echo a notice. -# -refresh_adfiles: $(EXEC) $(SOURCE.AD) $(ADLC_UPDATER) - @rm -rf $(TEMPDIR); mkdir $(TEMPDIR) - $(QUIETLY) $(EXEC) $(ADLCFLAGS) $(SOURCE.AD) \ - -c$(TEMPDIR)/ad_$(Platform_arch_model).cpp -h$(TEMPDIR)/ad_$(Platform_arch_model).hpp -a$(TEMPDIR)/dfa_$(Platform_arch_model).cpp -v$(TEMPDIR)/adGlobals_$(Platform_arch_model).hpp \ - || { rm -rf $(TEMPDIR); exit 1; } - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_clone.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_expand.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_format.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_gen.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_misc.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_peephole.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) ad_$(Platform_arch_model)_pipeline.cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) adGlobals_$(Platform_arch_model).hpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) ./$(ADLC_UPDATER) dfa_$(Platform_arch_model).cpp $(TEMPDIR) $(OUTDIR) - $(QUIETLY) [ -f $(TEMPDIR)/made-change ] \ - || echo $(LOG_INFO) "Rescanned $(SOURCE.AD) but encountered no changes." - $(QUIETLY) rm -rf $(TEMPDIR) - - -# ######################################################################### - -$(SOURCE.AD): $(SOURCES.AD) - $(QUIETLY) $(PROCESS_AD_FILES) $(SOURCES.AD) > $(SOURCE.AD) - -#PROCESS_AD_FILES = cat -# Pass through #line directives, in case user enables -g option above: -PROCESS_AD_FILES = awk '{ \ - if (CUR_FN != FILENAME) { CUR_FN=FILENAME; NR_BASE=NR-1; need_lineno=1 } \ - if (need_lineno && $$0 !~ /\/\//) \ - { print "\n\n\#line " (NR-NR_BASE) " \"" FILENAME "\""; need_lineno=0 }; \ - print }' - -$(OUTDIR)/%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(COMPILE.CXX) -o $@ $< $(COMPILE_DONE) - -# Some object files are given a prefix, to disambiguate -# them from objects of the same name built for the VM. -$(OUTDIR)/adlc-%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(COMPILE.CXX) -o $@ $< $(COMPILE_DONE) - -# ######################################################################### - -clean : - rm $(OBJECTS) - -cleanall : - rm $(OBJECTS) $(EXEC) - -# ######################################################################### - -.PHONY: all dump refresh_adfiles clean cleanall diff --git a/hotspot/make/solaris/makefiles/amd64.make b/hotspot/make/solaris/makefiles/amd64.make deleted file mode 100644 index 3eb6dee9b92..00000000000 --- a/hotspot/make/solaris/makefiles/amd64.make +++ /dev/null @@ -1,58 +0,0 @@ -# -# Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Must also specify if CPU is little endian -CFLAGS += -DVM_LITTLE_ENDIAN - -# -# Special case flags for compilers and compiler versions on amd64. -# -ifeq ("${Platform_compiler}", "sparcWorks") - -# Temporary until SS10 C++ compiler is fixed -OPT_CFLAGS/generateOptoStub.o = -xO2 -# Temporary util SS12u1 C++ compiler is fixed -OPT_CFLAGS/c1_LinearScan.o = -xO2 - -# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides -# of OPT_CFLAGS. Restore it here. -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS/generateOptoStub.o += -g0 -xs - OPT_CFLAGS/c1_LinearScan.o += -g0 -xs -endif - -else - -ifeq ("${Platform_compiler}", "gcc") -# gcc -# The serviceability agent relies on frame pointer (%rbp) to walk thread stack -CFLAGS += -fno-omit-frame-pointer - -else -# error -_JUNK2_ := $(shell echo >&2 \ - "*** ERROR: this compiler is not yet supported by this code base!") - @exit 1 -endif -endif diff --git a/hotspot/make/solaris/makefiles/build_vm_def.sh b/hotspot/make/solaris/makefiles/build_vm_def.sh deleted file mode 100644 index 7f86953ddf3..00000000000 --- a/hotspot/make/solaris/makefiles/build_vm_def.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -/usr/ccs/bin/nm -p $* \ - | awk '{ - if ($2 == "U") next - if ($3 ~ /^__1c.*__vtbl_$/ || $3 ~ /^gHotSpotVM/) print "\t" $3 ";" - if ($3 ~ /^UseSharedSpaces$/) print "\t" $3 ";" - if ($3 ~ /^__1cJArgumentsRSharedArchivePath_$/) print "\t" $3 ";" - }' \ - | sort -u diff --git a/hotspot/make/solaris/makefiles/buildtree.make b/hotspot/make/solaris/makefiles/buildtree.make deleted file mode 100644 index 905eaa06ec5..00000000000 --- a/hotspot/make/solaris/makefiles/buildtree.make +++ /dev/null @@ -1,354 +0,0 @@ -# -# Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Usage: -# -# $(MAKE) -f buildtree.make ARCH=arch BUILDARCH=buildarch LIBARCH=libarch -# GAMMADIR=dir OS_FAMILY=os VARIANT=variant -# -# The macros ARCH, GAMMADIR, OS_FAMILY and VARIANT must be defined in the -# environment or on the command-line: -# -# ARCH - sparc, i486, ... HotSpot cpu and os_cpu source directory -# BUILDARCH - build directory -# LIBARCH - the corresponding directory in JDK/JRE -# GAMMADIR - top of workspace -# OS_FAMILY - operating system -# VARIANT - core, compiler1, compiler2, or tiered -# VERSION_STRING - the JDK version string as specified by JEP-223 -# HOTSPOT_VERSION_STRING - the same as VERSION_STRING, unless overridden by a standalone build -# -# Builds the directory trees with makefiles plus some convenience files in -# each directory: -# -# Makefile - for "make foo" -# flags.make - with macro settings -# vm.make - to support making "$(MAKE) -v vm.make" in makefiles -# adlc.make - -# trace.make - generate tracing event and type definitions -# jvmti.make - generate JVMTI bindings from the spec (JSR-163) -# -# The makefiles are split this way so that "make foo" will run faster by not -# having to read the dependency files for the vm. - --include $(SPEC) -include $(GAMMADIR)/make/scm.make -include $(GAMMADIR)/make/defs.make -include $(GAMMADIR)/make/altsrc.make - - -# 'gmake MAKE_VERBOSE=y' or 'gmake QUIETLY=' gives all the gory details. -QUIETLY$(MAKE_VERBOSE) = @ - -### maye ARCH_XXX instead? -ifdef USE_GCC -PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH).gcc -GCC_LIB = /usr/local/lib -else -PLATFORM_FILE = $(GAMMADIR)/make/$(OS_FAMILY)/platform_$(BUILDARCH) -GCC_LIB = -endif - -ifdef FORCE_TIERED -ifeq ($(VARIANT),tiered) -PLATFORM_DIR = $(OS_FAMILY)_$(BUILDARCH)_compiler2 -else -PLATFORM_DIR = $(OS_FAMILY)_$(BUILDARCH)_$(VARIANT) -endif -else -PLATFORM_DIR = $(OS_FAMILY)_$(BUILDARCH)_$(VARIANT) -endif - -# -# We do two levels of exclusion in the shared directory. -# TOPLEVEL excludes are pruned, they are not recursively searched, -# but lower level directories can be named without fear of collision. -# ALWAYS excludes are excluded at any level in the directory tree. -# - -ALWAYS_EXCLUDE_DIRS = $(SCM_DIRS) - -ifeq ($(VARIANT),tiered) -TOPLEVEL_EXCLUDE_DIRS = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name agent -else -ifeq ($(VARIANT),compiler2) -TOPLEVEL_EXCLUDE_DIRS = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name c1 -o -name agent -else -# compiler1 and core use the same exclude list -TOPLEVEL_EXCLUDE_DIRS = $(ALWAYS_EXCLUDE_DIRS) -o -name adlc -o -name opto -o -name libadt -o -name agent -endif -endif - -# Get things from the platform file. -COMPILER = $(shell sed -n 's/^compiler[ ]*=[ ]*//p' $(PLATFORM_FILE)) - -SIMPLE_DIRS = \ - $(PLATFORM_DIR)/generated/dependencies \ - $(PLATFORM_DIR)/generated/adfiles \ - $(PLATFORM_DIR)/generated/jvmtifiles \ - $(PLATFORM_DIR)/generated/tracefiles - -TARGETS = debug fastdebug optimized product -SUBMAKE_DIRS = $(addprefix $(PLATFORM_DIR)/,$(TARGETS)) - -# For dependencies and recursive makes. -BUILDTREE_MAKE = $(GAMMADIR)/make/$(OS_FAMILY)/makefiles/buildtree.make - -BUILDTREE_TARGETS = Makefile flags.make flags_vm.make vm.make adlc.make jvmti.make trace.make dtrace.make - -BUILDTREE_VARS = GAMMADIR=$(GAMMADIR) OS_FAMILY=$(OS_FAMILY) \ - ARCH=$(ARCH) BUILDARCH=$(BUILDARCH) LIBARCH=$(LIBARCH) VARIANT=$(VARIANT) - -# Define variables to be set in flags.make. -# Default values are set in make/defs.make. - -# Set BUILD_USER from system-dependent hints: $LOGNAME, $(whoami) -ifndef HOTSPOT_BUILD_USER - HOTSPOT_BUILD_USER := $(shell echo $$LOGNAME) -endif -ifndef HOTSPOT_BUILD_USER - HOTSPOT_BUILD_USER := $(shell whoami) -endif -# Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro -# or make/hotspot_distro. -ifndef HOTSPOT_VM_DISTRO - ifeq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true) - include $(GAMMADIR)/make/hotspot_distro - else - include $(GAMMADIR)/make/openjdk_distro - endif -endif - -# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK -ifndef OPENJDK - ifneq ($(call if-has-altsrc,$(HS_COMMON_SRC)/,true,false),true) - OPENJDK=true - endif -endif - -BUILDTREE_VARS += HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) VERSION_STRING=$(VERSION_STRING) - -BUILDTREE = \ - $(MAKE) -f $(BUILDTREE_MAKE) $(BUILDTREE_TARGETS) $(BUILDTREE_VARS) - -BUILDTREE_COMMENT = echo "\# Generated by $(BUILDTREE_MAKE)" - -all: $(SUBMAKE_DIRS) - -# Run make in each subdirectory recursively. -$(SUBMAKE_DIRS): $(SIMPLE_DIRS) FORCE - $(QUIETLY) [ -d $@ ] || { mkdir -p $@; } - +$(QUIETLY) cd $@ && $(BUILDTREE) TARGET=$(@F) - $(QUIETLY) touch $@ - -$(SIMPLE_DIRS): - $(QUIETLY) mkdir -p $@ - -# Convenience macro which takes a source relative path, applies $(1) to the -# absolute path, and then replaces $(GAMMADIR) in the result with a -# literal "$(GAMMADIR)/" suitable for inclusion in a Makefile. -gamma-path=$(subst $(GAMMADIR),\$$(GAMMADIR),$(call $(1),$(HS_COMMON_SRC)/$(2))) - -# This bit is needed to enable local rebuilds. -# Unless the makefile itself sets LP64, any environmental -# setting of LP64 will interfere with the build. -LP64_SETTING/32 = LP64 = \#empty -LP64_SETTING/64 = LP64 = 1 - -DATA_MODE/i486 = 32 -DATA_MODE/sparc = 32 -DATA_MODE/sparcv9 = 64 -DATA_MODE/amd64 = 64 - -DATA_MODE = $(DATA_MODE/$(BUILDARCH)) - -flags.make: $(BUILDTREE_MAKE) ../shared_dirs.lst - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo "Platform_file = $(PLATFORM_FILE)" | sed 's|$(GAMMADIR)|$$(GAMMADIR)|'; \ - sed -n '/=/s/^ */Platform_/p' < $(PLATFORM_FILE); \ - echo; \ - echo "GAMMADIR = $(GAMMADIR)"; \ - echo "SYSDEFS = \$$(Platform_sysdefs)"; \ - echo "SRCARCH = $(ARCH)"; \ - echo "BUILDARCH = $(BUILDARCH)"; \ - echo "LIBARCH = $(LIBARCH)"; \ - echo "TARGET = $(TARGET)"; \ - echo "HOTSPOT_VERSION_STRING = $(HOTSPOT_VERSION_STRING)"; \ - echo "VERSION_STRING = $(VERSION_STRING)"; \ - echo "HOTSPOT_BUILD_USER = $(HOTSPOT_BUILD_USER)"; \ - echo "HOTSPOT_VM_DISTRO = $(HOTSPOT_VM_DISTRO)"; \ - echo "OPENJDK = $(OPENJDK)"; \ - echo "$(LP64_SETTING/$(DATA_MODE))"; \ - echo; \ - echo "# Used for platform dispatching"; \ - echo "TARGET_DEFINES = -DTARGET_OS_FAMILY_\$$(Platform_os_family)"; \ - echo "TARGET_DEFINES += -DTARGET_ARCH_\$$(Platform_arch)"; \ - echo "TARGET_DEFINES += -DTARGET_ARCH_MODEL_\$$(Platform_arch_model)"; \ - echo "TARGET_DEFINES += -DTARGET_OS_ARCH_\$$(Platform_os_arch)"; \ - echo "TARGET_DEFINES += -DTARGET_OS_ARCH_MODEL_\$$(Platform_os_arch_model)"; \ - echo "TARGET_DEFINES += -DTARGET_COMPILER_\$$(Platform_compiler)"; \ - echo "CFLAGS += \$$(TARGET_DEFINES)"; \ - echo; \ - echo "Src_Dirs_V = \\"; \ - sed 's/$$/ \\/;s|$(GAMMADIR)|$$(GAMMADIR)|' ../shared_dirs.lst; \ - echo "$(call gamma-path,altsrc,cpu/$(ARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,cpu/$(ARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/posix/vm)"; \ - echo; \ - echo "Src_Dirs_I = \\"; \ - echo "$(call gamma-path,altsrc,share/vm/prims) \\"; \ - echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \ - echo "$(call gamma-path,altsrc,share/vm) \\"; \ - echo "$(call gamma-path,commonsrc,share/vm) \\"; \ - echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \ - echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \ - echo "$(call gamma-path,altsrc,cpu/$(ARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,cpu/$(ARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/$(OS_FAMILY)/vm) \\"; \ - echo "$(call gamma-path,altsrc,os/posix/vm) \\"; \ - echo "$(call gamma-path,commonsrc,os/posix/vm)"; \ - [ -n "$(CFLAGS_BROWSE)" ] && \ - echo && echo "CFLAGS_BROWSE = $(CFLAGS_BROWSE)"; \ - [ -n "$(ENABLE_FULL_DEBUG_SYMBOLS)" ] && \ - echo && echo "ENABLE_FULL_DEBUG_SYMBOLS = $(ENABLE_FULL_DEBUG_SYMBOLS)"; \ - [ -n "$(OBJCOPY)" ] && \ - echo && echo "OBJCOPY = $(OBJCOPY)"; \ - [ -n "$(STRIP_POLICY)" ] && \ - echo && echo "STRIP_POLICY = $(STRIP_POLICY)"; \ - [ -n "$(ZIP_DEBUGINFO_FILES)" ] && \ - echo && echo "ZIP_DEBUGINFO_FILES = $(ZIP_DEBUGINFO_FILES)"; \ - [ -n "$(ZIPEXE)" ] && \ - echo && echo "ZIPEXE = $(ZIPEXE)"; \ - [ -n "$(HS_ALT_MAKE)" ] && \ - echo && echo "HS_ALT_MAKE = $(HS_ALT_MAKE)"; \ - [ -n "$(HOTSPOT_EXTRA_SYSDEFS)" ] && \ - echo && \ - echo "HOTSPOT_EXTRA_SYSDEFS\$$(HOTSPOT_EXTRA_SYSDEFS) = $(HOTSPOT_EXTRA_SYSDEFS)" && \ - echo "SYSDEFS += \$$(HOTSPOT_EXTRA_SYSDEFS)"; \ - echo; \ - [ -n "$(SPEC)" ] && \ - echo "include $(SPEC)"; \ - echo "CP ?= cp"; \ - echo "MV ?= mv"; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(VARIANT).make"; \ - echo "include \$$(GAMMADIR)/make/excludeSrc.make"; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(COMPILER).make"; \ - ) > $@ - -flags_vm.make: $(BUILDTREE_MAKE) ../shared_dirs.lst - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(TARGET).make"; \ - ) > $@ - -../shared_dirs.lst: $(BUILDTREE_MAKE) $(GAMMADIR)/src/share/vm - @echo $(LOG_INFO) Creating directory list $@ - $(QUIETLY) if [ -d $(HS_ALT_SRC)/share/vm ]; then \ - find $(HS_ALT_SRC)/share/vm/* -prune \ - -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \ - \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; > $@; \ - fi; - $(QUIETLY) find $(HS_COMMON_SRC)/share/vm/* -prune \ - -type d \! \( $(TOPLEVEL_EXCLUDE_DIRS) \) -exec find {} \ - \( $(ALWAYS_EXCLUDE_DIRS) \) -prune -o -type d -print \; >> $@ - -Makefile: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/top.make"; \ - ) > $@ - -vm.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo include flags_vm.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -adlc.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -jvmti.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -trace.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -dtrace.make: $(BUILDTREE_MAKE) - @echo $(LOG_INFO) Creating $@ ... - $(QUIETLY) ( \ - $(BUILDTREE_COMMENT); \ - echo; \ - echo include flags.make; \ - echo; \ - echo "include \$$(GAMMADIR)/make/$(OS_FAMILY)/makefiles/$(@F)"; \ - ) > $@ - -FORCE: - -.PHONY: all FORCE - -.NOTPARALLEL: diff --git a/hotspot/make/solaris/makefiles/compiler1.make b/hotspot/make/solaris/makefiles/compiler1.make deleted file mode 100644 index d303bfc1ca4..00000000000 --- a/hotspot/make/solaris/makefiles/compiler1.make +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making client version of VM - -TYPE=COMPILER1 - -VM_SUBDIR = client - -# We don't support the JVMCI in a client VM. -INCLUDE_JVMCI := false - -CFLAGS += -DCOMPILER1 diff --git a/hotspot/make/solaris/makefiles/compiler2.make b/hotspot/make/solaris/makefiles/compiler2.make deleted file mode 100644 index c881079882e..00000000000 --- a/hotspot/make/solaris/makefiles/compiler2.make +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making server version of VM - -TYPE=COMPILER2 - -VM_SUBDIR = server - -CFLAGS += -DCOMPILER2 diff --git a/hotspot/make/solaris/makefiles/core.make b/hotspot/make/solaris/makefiles/core.make deleted file mode 100644 index 64400556fcc..00000000000 --- a/hotspot/make/solaris/makefiles/core.make +++ /dev/null @@ -1,33 +0,0 @@ -# -# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making core version of VM - -# Select which files to use (in top.make) -TYPE=CORE - -# There is no "core" directory in JDK. Install core build in server directory. -VM_SUBDIR = server - -# Note: macros.hpp defines CORE diff --git a/hotspot/make/solaris/makefiles/debug.make b/hotspot/make/solaris/makefiles/debug.make deleted file mode 100644 index 3fba8e1239d..00000000000 --- a/hotspot/make/solaris/makefiles/debug.make +++ /dev/null @@ -1,56 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making debug version of VM - -# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make -DEBUG_CFLAGS/DEFAULT= $(DEBUG_CFLAGS) -DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@)) - -ifeq ("${Platform_compiler}", "sparcWorks") - -ifeq ($(COMPILER_REV_NUMERIC),508) - # SS11 SEGV when compiling with -g and -xarch=v8, using different backend - DEBUG_CFLAGS/compileBroker.o = $(DEBUG_CFLAGS) -xO0 - DEBUG_CFLAGS/jvmtiTagMap.o = $(DEBUG_CFLAGS) -xO0 -endif -endif - -# _NMT_NOINLINE_ informs NMT that no inlining by Compiler -CFLAGS += $(DEBUG_CFLAGS/BYFILE) -D_NMT_NOINLINE_ - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# Linker mapfiles -MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers \ - $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-debug - -# This mapfile is only needed when compiling with dtrace support, -# and mustn't be otherwise. -MAPFILE_DTRACE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-$(TYPE) - -VERSION = debug -SYSDEFS += -DASSERT -PICFLAGS = DEFAULT diff --git a/hotspot/make/solaris/makefiles/defs.make b/hotspot/make/solaris/makefiles/defs.make deleted file mode 100644 index f6b913ab460..00000000000 --- a/hotspot/make/solaris/makefiles/defs.make +++ /dev/null @@ -1,279 +0,0 @@ -# -# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# The common definitions for hotspot solaris builds. -# Include the top level defs.make under make directory instead of this one. -# This file is included into make/defs.make. - -define print_info - ifneq ($$(LOG_LEVEL), warn) - $$(shell echo >&2 "INFO: $1") - endif -endef - -# Need PLATFORM (os-arch combo names) for jdk and hotspot, plus libarch name -SLASH_JAVA ?= /java -ARCH:=$(shell uname -p) -PATH_SEP = : -ifeq ($(LP64), 1) - ARCH_DATA_MODEL=64 -else - ARCH_DATA_MODEL=32 -endif - -ifeq ($(ARCH),sparc) - ifeq ($(ARCH_DATA_MODEL), 64) - MAKE_ARGS += LP64=1 - PLATFORM=solaris-sparcv9 - VM_PLATFORM=solaris_sparcv9 - else - PLATFORM=solaris-sparc - VM_PLATFORM=solaris_sparc - endif - HS_ARCH=sparc -else - ifeq ($(ARCH_DATA_MODEL), 64) - MAKE_ARGS += LP64=1 - PLATFORM=solaris-amd64 - VM_PLATFORM=solaris_amd64 - HS_ARCH=x86 - else - PLATFORM=solaris-i586 - VM_PLATFORM=solaris_i486 - HS_ARCH=x86 - endif -endif - -# On 32 bit solaris we build server and client, on 64 bit just server. -ifeq ($(JVM_VARIANTS),) - ifeq ($(ARCH_DATA_MODEL), 32) - JVM_VARIANTS:=client,server - JVM_VARIANT_CLIENT:=true - JVM_VARIANT_SERVER:=true - else - JVM_VARIANTS:=server - JVM_VARIANT_SERVER:=true - endif -endif - -# The Full Debug Symbols (FDS) default for BUILD_FLAVOR == product -# builds is enabled with debug info files ZIP'ed to save space. For -# BUILD_FLAVOR != product builds, FDS is always enabled, after all a -# debug build without debug info isn't very useful. -# The ZIP_DEBUGINFO_FILES option only has meaning when FDS is enabled. -# -# If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be -# disabled for a BUILD_FLAVOR == product build. -# -# Note: Use of a different variable name for the FDS override option -# versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS -# versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass -# in options via environment variables, use of distinct variables -# prevents strange behaviours. For example, in a BUILD_FLAVOR != -# product build, the FULL_DEBUG_SYMBOLS environment variable will be -# 0, but the ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If -# the same variable name is used, then different values can be picked -# up by different parts of the build. Just to be clear, we only need -# two variable names because the incoming option value can be -# overridden in some situations, e.g., a BUILD_FLAVOR != product -# build. - -# Due to the multiple sub-make processes that occur this logic gets -# executed multiple times. We reduce the noise by at least checking that -# BUILD_FLAVOR has been set. -ifneq ($(BUILD_FLAVOR),) - ifeq ($(BUILD_FLAVOR), product) - FULL_DEBUG_SYMBOLS ?= 1 - ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) - else - # debug variants always get Full Debug Symbols (if available) - ENABLE_FULL_DEBUG_SYMBOLS = 1 - endif - $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")) - # since objcopy is optional, we set ZIP_DEBUGINFO_FILES later - - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - # Default OBJCOPY comes from the SUNWbinutils package: - DEF_OBJCOPY=/usr/sfw/bin/gobjcopy - OBJCOPY=$(shell test -x $(DEF_OBJCOPY) && echo $(DEF_OBJCOPY)) - ifneq ($(ALT_OBJCOPY),) - $(eval $(call print_info, "ALT_OBJCOPY=$(ALT_OBJCOPY)")) - OBJCOPY=$(shell test -x $(ALT_OBJCOPY) && echo $(ALT_OBJCOPY)) - endif - - ifneq ($(OBJCOPY),) - # OBJCOPY version check: - # - version number is last blank separate word on first line - # - version number formats that have been seen: - # - . - # - .. - # - # Full Debug Symbols on Solaris needs version 2.21.1 or newer. - # - OBJCOPY_VERS_CHK := $(shell \ - $(OBJCOPY) --version \ - | sed -n \ - -e 's/.* //' \ - -e '/^[01]\./b bad' \ - -e '/^2\./{' \ - -e ' s/^2\.//' \ - -e ' /^[0-9]$$/b bad' \ - -e ' /^[0-9]\./b bad' \ - -e ' /^1[0-9]$$/b bad' \ - -e ' /^1[0-9]\./b bad' \ - -e ' /^20\./b bad' \ - -e ' /^21\.0$$/b bad' \ - -e ' /^21\.0\./b bad' \ - -e '}' \ - -e ':good' \ - -e 's/.*/VALID_VERSION/p' \ - -e 'q' \ - -e ':bad' \ - -e 's/.*/BAD_VERSION/p' \ - -e 'q' \ - ) - ifeq ($(OBJCOPY_VERS_CHK),BAD_VERSION) - _JUNK_ := $(shell \ - echo >&2 "WARNING: $(OBJCOPY) --version info:"; \ - $(OBJCOPY) --version | sed -n -e 's/^/WARNING: /p' -e 'q' >&2; \ - echo >&2 "WARNING: an objcopy version of 2.21.1 or newer" \ - "is needed to create valid .debuginfo files."; \ - echo >&2 "WARNING: ignoring above objcopy command."; \ - echo >&2 "WARNING: patch 149063-01 or newer contains the" \ - "correct Solaris 10 SPARC version."; \ - echo >&2 "WARNING: patch 149064-01 or newer contains the" \ - "correct Solaris 10 X86 version."; \ - echo >&2 "WARNING: Solaris 11 Update 1 contains the" \ - "correct version."; \ - ) - OBJCOPY= - endif - endif - - ifeq ($(OBJCOPY),) - $(eval $(call print_info, "no objcopy cmd found so cannot create .debuginfo files.")) - ENABLE_FULL_DEBUG_SYMBOLS=0 - $(eval $(call print_info, "ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)")) - else - $(eval $(call print_info, "$(OBJCOPY) cmd found so will create .debuginfo files.")) - - # Library stripping policies for .debuginfo configs: - # all_strip - strips everything from the library - # min_strip - strips most stuff from the library; leaves minimum symbols - # no_strip - does not strip the library at all - # - # Oracle security policy requires "all_strip". A waiver was granted on - # 2011.09.01 that permits using "min_strip" in the Java JDK and Java JRE. - # - # Currently, STRIP_POLICY is only used when Full Debug Symbols is enabled. - # - STRIP_POLICY ?= min_strip - - $(eval $(call print_info, "STRIP_POLICY=$(STRIP_POLICY)")) - - ZIP_DEBUGINFO_FILES ?= 1 - - $(eval $(call print_info, "ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES)")) - endif - endif # ENABLE_FULL_DEBUG_SYMBOLS=1 -endif # BUILD_FLAVOR - -JDK_INCLUDE_SUBDIR=solaris - -# Library suffix -LIBRARY_SUFFIX=so - -EXPORT_LIST += $(EXPORT_DOCS_DIR)/platform/jvmti/jvmti.html - -# client and server subdirectories have symbolic links to ../libjsig.$(LIBRARY_SUFFIX) -EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.$(LIBRARY_SUFFIX) -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.diz - else - EXPORT_LIST += $(EXPORT_LIB_ARCH_DIR)/libjsig.debuginfo - endif -endif - -EXPORT_SERVER_DIR = $(EXPORT_LIB_ARCH_DIR)/server -EXPORT_CLIENT_DIR = $(EXPORT_LIB_ARCH_DIR)/client - -ifeq ($(JVM_VARIANT_SERVER),true) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.$(LIBRARY_SUFFIX) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_db.$(LIBRARY_SUFFIX) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_dtrace.$(LIBRARY_SUFFIX) - ifeq ($(ARCH_DATA_MODEL),32) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_db.$(LIBRARY_SUFFIX) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_dtrace.$(LIBRARY_SUFFIX) - endif - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.diz - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_db.diz - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_dtrace.diz - ifeq ($(ARCH_DATA_MODEL),32) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_db.diz - EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_dtrace.diz - endif - else - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm.debuginfo - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_db.debuginfo - EXPORT_LIST += $(EXPORT_SERVER_DIR)/libjvm_dtrace.debuginfo - ifeq ($(ARCH_DATA_MODEL),32) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_db.debuginfo - EXPORT_LIST += $(EXPORT_SERVER_DIR)/64/libjvm_dtrace.debuginfo - endif - endif - endif -endif -ifeq ($(JVM_VARIANT_CLIENT),true) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.$(LIBRARY_SUFFIX) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_db.$(LIBRARY_SUFFIX) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_dtrace.$(LIBRARY_SUFFIX) - ifeq ($(ARCH_DATA_MODEL),32) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_db.$(LIBRARY_SUFFIX) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_dtrace.$(LIBRARY_SUFFIX) - endif - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.diz - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_db.diz - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_dtrace.diz - ifeq ($(ARCH_DATA_MODEL),32) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_db.diz - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_dtrace.diz - endif - else - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm.debuginfo - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_db.debuginfo - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/libjvm_dtrace.debuginfo - ifeq ($(ARCH_DATA_MODEL),32) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_db.debuginfo - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/64/libjvm_dtrace.debuginfo - endif - endif - endif -endif diff --git a/hotspot/make/solaris/makefiles/dtrace.make b/hotspot/make/solaris/makefiles/dtrace.make deleted file mode 100644 index 2c65059a213..00000000000 --- a/hotspot/make/solaris/makefiles/dtrace.make +++ /dev/null @@ -1,387 +0,0 @@ -# -# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Rules to build jvm_db/dtrace, used by vm.make - -# We build libjvm_dtrace/libjvm_db/dtrace for COMPILER1 and COMPILER2 -# but not for CORE configuration. - -ifneq ("${TYPE}", "CORE") - -ifdef USE_GCC - -dtraceCheck: - $(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled for gcc builds" - -else - -DtraceOutDir = $(GENERATED)/dtracefiles - -JVM_DB = libjvm_db -LIBJVM_DB = libjvm_db.so - -LIBJVM_DB_DEBUGINFO = libjvm_db.debuginfo -LIBJVM_DB_DIZ = libjvm_db.diz - -JVM_DTRACE = jvm_dtrace -LIBJVM_DTRACE = libjvm_dtrace.so - -LIBJVM_DTRACE_DEBUGINFO = libjvm_dtrace.debuginfo -LIBJVM_DTRACE_DIZ = libjvm_dtrace.diz - -JVMOFFS = JvmOffsets -JVMOFFS.o = $(JVMOFFS).o -GENOFFS = generate$(JVMOFFS) - -DTRACE_SRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/dtrace -DTRACE_COMMON_SRCDIR = $(GAMMADIR)/src/os/posix/dtrace -DTRACE = dtrace -DTRACE.o = $(DTRACE).o -DTRACE_JHELPER = dtrace_jhelper -DTRACE_JHELPER.o = $(DTRACE_JHELPER).o - -# to remove '-g' option which causes link problems -# also '-z nodefs' is used as workaround -GENOFFS_CFLAGS = $(shell echo $(CFLAGS) | sed -e 's/ -g / /g' -e 's/ -g0 / /g';) - -ifdef LP64 -DTRACE_OPTS = -64 -D_LP64 -endif - -# making libjvm_db - -# Use mapfile with libjvm_db.so -LIBJVM_DB_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jvm_db -LFLAGS_JVM_DB += $(MAPFLAG:FILENAME=$(LIBJVM_DB_MAPFILE)) - -# Use mapfile with libjvm_dtrace.so -LIBJVM_DTRACE_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jvm_dtrace -LFLAGS_JVM_DTRACE += $(MAPFLAG:FILENAME=$(LIBJVM_DTRACE_MAPFILE)) - -ifdef USE_GCC -LFLAGS_JVM_DB += -D_REENTRANT $(PICFLAG) -LFLAGS_JVM_DTRACE += -D_REENTRANT $(PICFLAG) -else -LFLAGS_JVM_DB += -mt $(PICFLAG) -xnolib -LFLAGS_JVM_DTRACE += -mt $(PICFLAG) -xnolib -ldl -endif - -ISA = $(subst i386,i486,$(shell isainfo -n)) - -# Making 64/libjvm_db.so: 64-bit version of libjvm_db.so which handles 32-bit libjvm.so -ifneq ("${ISA}","${BUILDARCH}") - -XLIBJVM_DIR = 64 -XLIBJVM_DB = $(XLIBJVM_DIR)/$(LIBJVM_DB) -XLIBJVM_DTRACE = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE) - -XLIBJVM_DB_DEBUGINFO = $(XLIBJVM_DIR)/$(LIBJVM_DB_DEBUGINFO) -XLIBJVM_DB_DIZ = $(XLIBJVM_DIR)/$(LIBJVM_DB_DIZ) -XLIBJVM_DTRACE_DEBUGINFO = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE_DEBUGINFO) -XLIBJVM_DTRACE_DIZ = $(XLIBJVM_DIR)/$(LIBJVM_DTRACE_DIZ) - -$(XLIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS).h $(LIBJVM_DB_MAPFILE) - @echo $(LOG_INFO) Making $@ - $(QUIETLY) mkdir -p $(XLIBJVM_DIR) ; \ - $(CC) $(SYMFLAG) $(ARCHFLAG/$(ISA)) -D$(TYPE) -I. -I$(GENERATED) \ - $(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DB_DEBUGINFO) -# Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) is not -# in the link name: - ( cd $(XLIBJVM_DIR) && $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $(LIBJVM_DB) ) - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -x $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) -# Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) is not -# in the archived name: - ( cd $(XLIBJVM_DIR) && $(ZIPEXE) -q -y $(LIBJVM_DB_DIZ) $(LIBJVM_DB_DEBUGINFO) ) - $(RM) $(XLIBJVM_DB_DEBUGINFO) - endif -endif - -$(XLIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE) - @echo $(LOG_INFO) Making $@ - $(QUIETLY) mkdir -p $(XLIBJVM_DIR) ; \ - $(CC) $(SYMFLAG) $(ARCHFLAG/$(ISA)) -D$(TYPE) -I. $(EXTRA_CFLAGS) \ - $(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c \ - $(EXTRA_LDFLAGS) -lc -lthread -ldoor -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(XLIBJVM_DTRACE_DEBUGINFO) -# Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) is not -# in the link name: - ( cd $(XLIBJVM_DIR) && $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $(LIBJVM_DTRACE) ) - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -x $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) -# Do this part in the $(XLIBJVM_DIR) subdir so $(XLIBJVM_DIR) is not -# in the archived name: - ( cd $(XLIBJVM_DIR) && $(ZIPEXE) -q -y $(LIBJVM_DTRACE_DIZ) $(LIBJVM_DTRACE_DEBUGINFO)) - $(RM) $(XLIBJVM_DTRACE_DEBUGINFO) - endif -endif - -endif # ifneq ("${ISA}","${BUILDARCH}") - -ifdef USE_GCC -LFLAGS_GENOFFS += -D_REENTRANT -else -LFLAGS_GENOFFS += -mt -xnolib -norunpath -endif - -lib$(GENOFFS).so: $(DTRACE_SRCDIR)/$(GENOFFS).cpp $(DTRACE_SRCDIR)/$(GENOFFS).h \ - $(LIBJVM.o) - $(QUIETLY) $(CXX) $(CXXFLAGS) $(GENOFFS_CFLAGS) $(SHARED_FLAG) $(PICFLAG) \ - $(LFLAGS_GENOFFS) -o $@ $(DTRACE_SRCDIR)/$(GENOFFS).cpp -lc - -$(GENOFFS): $(DTRACE_SRCDIR)/$(GENOFFS)Main.c lib$(GENOFFS).so - $(QUIETLY) $(LINK.CXX) -z nodefs -o $@ $(DTRACE_SRCDIR)/$(GENOFFS)Main.c \ - ./lib$(GENOFFS).so - -CONDITIONALLY_UPDATE_JVMOFFS_TARGET = \ - if cmp -s $@ $@.tmp; then \ - rm -f $@.tmp; \ - else \ - rm -f $@ && mv $@.tmp $@ && echo Updated $@; \ - fi - -# $@.tmp is created first to avoid an empty $(JVMOFFS).h if an error occurs. -$(JVMOFFS).h: $(GENOFFS) - $(QUIETLY) LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ./$(GENOFFS) -header > $@.tmp - $(QUIETLY) $(CONDITIONALLY_UPDATE_JVMOFFS_TARGET) - -$(JVMOFFS)Index.h: $(GENOFFS) - $(QUIETLY) LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ./$(GENOFFS) -index > $@.tmp - $(QUIETLY) $(CONDITIONALLY_UPDATE_JVMOFFS_TARGET) - -$(JVMOFFS).cpp: $(GENOFFS) $(JVMOFFS).h $(JVMOFFS)Index.h - $(QUIETLY) LD_LIBRARY_PATH=.:$(LD_LIBRARY_PATH) ./$(GENOFFS) -table > $@.tmp - $(QUIETLY) $(CONDITIONALLY_UPDATE_JVMOFFS_TARGET) - -$(JVMOFFS.o): $(JVMOFFS).h $(JVMOFFS).cpp - $(QUIETLY) $(CXX) -c -I. -o $@ $(ARCHFLAG) -D$(TYPE) $(JVMOFFS).cpp - -$(LIBJVM_DB): $(DTRACE_SRCDIR)/$(JVM_DB).c $(JVMOFFS.o) $(XLIBJVM_DB) $(LIBJVM_DB_MAPFILE) - @echo $(LOG_INFO) Making $@ - $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. -I$(GENERATED) \ - $(SHARED_FLAG) $(LFLAGS_JVM_DB) -o $@ $(DTRACE_SRCDIR)/$(JVM_DB).c -lc -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DB_DEBUGINFO) - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DB_DEBUGINFO) $@ - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -x $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -y $(LIBJVM_DB_DIZ) $(LIBJVM_DB_DEBUGINFO) - $(RM) $(LIBJVM_DB_DEBUGINFO) - endif -endif - -$(LIBJVM_DTRACE): $(DTRACE_SRCDIR)/$(JVM_DTRACE).c $(XLIBJVM_DTRACE) $(DTRACE_SRCDIR)/$(JVM_DTRACE).h $(LIBJVM_DTRACE_MAPFILE) - @echo $(LOG_INFO) Making $@ - $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) -D$(TYPE) -I. $(EXTRA_CFLAGS) \ - $(SHARED_FLAG) $(LFLAGS_JVM_DTRACE) -o $@ $(DTRACE_SRCDIR)/$(JVM_DTRACE).c \ - $(EXTRA_LDFLAGS) -lc -lthread -ldoor -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DTRACE_DEBUGINFO) - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DTRACE_DEBUGINFO) $@ - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -x $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -y $(LIBJVM_DTRACE_DIZ) $(LIBJVM_DTRACE_DEBUGINFO) - $(RM) $(LIBJVM_DTRACE_DEBUGINFO) - endif -endif - -$(DTRACE).d: $(DTRACE_COMMON_SRCDIR)/hotspot.d $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d \ - $(DTRACE_COMMON_SRCDIR)/hs_private.d - $(QUIETLY) cat $^ > $@ - -$(DTRACE_JHELPER).d: $(DTRACE_SRCDIR)/jhelper.d - $(QUIETLY) cat $^ > $@ - -DTraced_Files = ciEnv.o \ - classLoadingService.o \ - compileBroker.o \ - hashtable.o \ - instanceKlass.o \ - java.o \ - jni.o \ - jvm.o \ - memoryManager.o \ - nmethod.o \ - objectMonitor.o \ - runtimeService.o \ - sharedRuntime.o \ - synchronizer.o \ - thread.o \ - unsafe.o \ - vmThread.o \ - vmCMSOperations.o \ - vmPSOperations.o \ - vmGCOperations.o \ - -# Dtrace is available, so we build $(DTRACE.o) -$(DTRACE.o): $(DTRACE).d $(DTraced_Files) - @echo $(LOG_INFO) Compiling $(DTRACE).d - - $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -G -xlazyload -o $@ -s $(DTRACE).d \ - $(sort $(DTraced_Files)) ||\ - STATUS=$$?;\ - if [ x"$$STATUS" = x"1" ]; then \ - if [ x`uname -r` = x"5.10" -a \ - x`uname -p` = x"sparc" ]; then\ - echo "*****************************************************************";\ - echo "* If you are building server compiler, and the error message is ";\ - echo "* \"incorrect ELF machine type...\", you have run into solaris bug ";\ - echo "* 6213962, \"dtrace -G doesn't work on sparcv8+ object files\".";\ - echo "* Either patch/upgrade your system (>= S10u1_15), or set the ";\ - echo "* environment variable HOTSPOT_DISABLE_DTRACE_PROBES to disable ";\ - echo "* dtrace probes for this build.";\ - echo "*****************************************************************";\ - elif [ x`uname -r` = x"5.10" ]; then\ - echo "*****************************************************************";\ - echo "* If you are seeing 'syntax error near \"umpiconninfo_t\"' on Solaris";\ - echo "* 10, try doing 'cd /usr/lib/dtrace && gzip mpi.d' as root, ";\ - echo "* or set the environment variable HOTSPOT_DISABLE_DTRACE_PROBES";\ - echo "* to disable dtrace probes for this build.";\ - echo "*****************************************************************";\ - else \ - echo "*****************************************************************";\ - echo "* If you cannot fix dtrace build issues, try to ";\ - echo "* set the environment variable HOTSPOT_DISABLE_DTRACE_PROBES";\ - echo "* to disable dtrace probes for this build.";\ - echo "*****************************************************************";\ - fi; \ - fi;\ - exit $$STATUS - # Since some DTraced_Files are in LIBJVM.o and they are touched by this - # command, and libgenerateJvmOffsets.so depends on LIBJVM.o, 'make' will - # think it needs to rebuild libgenerateJvmOffsets.so and thus JvmOffsets* - # files, but it doesn't, so we touch the necessary files to prevent later - # recompilation. Note: we only touch the necessary files if they already - # exist in order to close a race where an empty file can be created - # before the real build rule is executed. - # But, we can't touch the *.h files: This rule depends - # on them, and that would cause an infinite cycle of rebuilding. - # Neither the *.h or *.ccp files need to be touched, since they have - # rules which do not update them when the generator file has not - # changed their contents. - $(QUIETLY) if [ -f lib$(GENOFFS).so ]; then touch lib$(GENOFFS).so; fi - $(QUIETLY) if [ -f $(GENOFFS) ]; then touch $(GENOFFS); fi - $(QUIETLY) if [ -f $(JVMOFFS.o) ]; then touch $(JVMOFFS.o); fi - - -$(DtraceOutDir): - mkdir $(DtraceOutDir) - -$(DtraceOutDir)/hotspot.h: $(DTRACE_COMMON_SRCDIR)/hotspot.d | $(DtraceOutDir) - $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_COMMON_SRCDIR)/hotspot.d - -$(DtraceOutDir)/hotspot_jni.h: $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d | $(DtraceOutDir) - $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_COMMON_SRCDIR)/hotspot_jni.d - -$(DtraceOutDir)/hs_private.h: $(DTRACE_COMMON_SRCDIR)/hs_private.d | $(DtraceOutDir) - $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -h -o $@ -s $(DTRACE_COMMON_SRCDIR)/hs_private.d - -dtrace_gen_headers: $(DtraceOutDir)/hotspot.h $(DtraceOutDir)/hotspot_jni.h $(DtraceOutDir)/hs_private.h - -# The jhelper.d and hotspot probes are separated into two different SUNW_dof sections. -# Now the jhelper.d is built without the -Xlazyload flag. -$(DTRACE_JHELPER.o) : $(DTRACE_JHELPER).d $(JVMOFFS).h $(JVMOFFS)Index.h - @echo $(LOG_INFO) Compiling $(DTRACE_JHELPER).d - $(QUIETLY) $(DTRACE_PROG) $(DTRACE_OPTS) -C -I. -G -o $@ -s $(DTRACE_JHELPER).d - -.PHONY: dtraceCheck - -SYSTEM_DTRACE_PROG = /usr/sbin/dtrace -PATCH_DTRACE_PROG = /opt/SUNWdtrd/sbin/dtrace -systemDtraceFound := $(wildcard ${SYSTEM_DTRACE_PROG}) -patchDtraceFound := $(wildcard ${PATCH_DTRACE_PROG}) - -ifneq ("$(patchDtraceFound)", "") -DTRACE_PROG=$(PATCH_DTRACE_PROG) -DTRACE_INCL=-I/opt/SUNWdtrd/include -else -ifneq ("$(systemDtraceFound)", "") -DTRACE_PROG=$(SYSTEM_DTRACE_PROG) -else - -endif # ifneq ("$(systemDtraceFound)", "") -endif # ifneq ("$(patchDtraceFound)", "") - -ifneq ("${DTRACE_PROG}", "") -ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "") - -DTRACE_OBJS = $(DTRACE.o) $(JVMOFFS.o) $(DTRACE_JHELPER.o) -CFLAGS += $(DTRACE_INCL) -DDTRACE_ENABLED -MAPFILE_DTRACE_OPT = $(MAPFILE_DTRACE) - -dtraceCheck: - -else # manually disabled - -dtraceCheck: - $(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled via environment variable" - -endif # ifeq ("${HOTSPOT_DISABLE_DTRACE_PROBES}", "") - -else # No dtrace program found - -dtraceCheck: - $(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled: not supported by system" - -endif # ifneq ("${dtraceFound}", "") - -endif # ifdef USE_GCC - -else # CORE build - -dtraceCheck: - $(QUIETLY) echo $(LOG_INFO) "**NOTICE** Dtrace support disabled for CORE builds" - -endif # ifneq ("${TYPE}", "CORE") diff --git a/hotspot/make/solaris/makefiles/fastdebug.make b/hotspot/make/solaris/makefiles/fastdebug.make deleted file mode 100644 index 3719c3edbda..00000000000 --- a/hotspot/make/solaris/makefiles/fastdebug.make +++ /dev/null @@ -1,127 +0,0 @@ -# -# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making debug version of VM - -# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make -# They may also specify FASTDEBUG_CFLAGS, but it defaults to DEBUG_CFLAGS. - -FASTDEBUG_CFLAGS$(FASTDEBUG_CFLAGS) = $(DEBUG_CFLAGS) - -# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make -OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) -OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) - -ifeq ("${Platform_compiler}", "sparcWorks") -OPT_CFLAGS/SLOWER = -xO2 - -ifeq ($(COMPILER_REV_NUMERIC), 510) -# Avoid apparent crash because of corrupted methodHandle in a tail call -OPT_CFLAGS/simpleThresholdPolicy.o = $(OPT_CFLAGS/DEFAULT) $(OPT_CCFLAGS/NO_TAIL_CALL_OPT) -# CC 5.10 has bug XXXXX with -xO4 -OPT_CFLAGS/jvmtiClassFileReconstituter.o = $(OPT_CFLAGS/SLOWER) -endif # COMPILER_REV_NUMERIC == 510 - -ifeq ($(COMPILER_REV_NUMERIC), 509) -# To avoid jvm98 crash -OPT_CFLAGS/instanceKlass.o = $(OPT_CFLAGS/SLOWER) -endif # COMPILER_NUMERIC_REV == 509 - -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1) -# dtrace cannot handle tail call optimization (6672627, 6693876) -OPT_CFLAGS/jni.o = $(OPT_CFLAGS/DEFAULT) $(OPT_CCFLAGS/NO_TAIL_CALL_OPT) -# this hangs in iropt now (7113504) -OPT_CFLAGS/compileBroker.o = $(OPT_CFLAGS/SLOWER) -endif # COMPILER_NUMERIC_REV >= 509 - -ifeq ($(COMPILER_REV_NUMERIC), 505) -# CC 5.5 has bug 4908364 with -xO4 (Fixed in 5.6) -OPT_CFLAGS/library_call.o = $(OPT_CFLAGS/SLOWER) -endif # COMPILER_REV_NUMERIC == 505 - -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \<= 504), 1) -# Compilation of *_.cpp can take an hour or more at O3. Use O2 -# See comments at top of sparc.make. -OPT_CFLAGS/ad_$(Platform_arch_model).o = $(OPT_CFLAGS/SLOWER) -OPT_CFLAGS/dfa_$(Platform_arch_model).o = $(OPT_CFLAGS/SLOWER) -endif # COMPILER_REV_NUMERIC <= 504 - -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \< 505), 1) -# Same problem with Solaris/x86 compiler (both 5.0 and 5.2) on ad_x86_{32,64}.cpp. -# CC build time is also too long for ad_$(Platform_arch_model)_{gen,misc}.o -OPT_CFLAGS/ad_$(Platform_arch_model).o = -c -OPT_CFLAGS/ad_$(Platform_arch_model)_gen.o = -c -OPT_CFLAGS/ad_$(Platform_arch_model)_misc.o = -c -ifeq ($(Platform_arch), x86) -# Same problem for the wrapper roosts: jni.o jvm.o -OPT_CFLAGS/jni.o = -c -OPT_CFLAGS/jvm.o = -c -# Same problem in parse2.o (probably the Big Switch over bytecodes) -OPT_CFLAGS/parse2.o = -c -endif # Platform_arch == x86 -endif - -# Frame size > 100k if we allow inlining via -g0! -DEBUG_CFLAGS/bytecodeInterpreter.o = -g -DEBUG_CFLAGS/bytecodeInterpreterWithChecks.o = -g -ifeq ($(Platform_arch), x86) -# ube explodes on x86 -OPT_CFLAGS/bytecodeInterpreter.o = -xO1 -OPT_CFLAGS/bytecodeInterpreterWithChecks.o = -xO1 -endif # Platform_arch == x86 - -endif # Platform_compiler == sparcWorks - -# Workaround for a bug in dtrace. If ciEnv::post_compiled_method_load_event() -# is inlined, the resulting dtrace object file needs a reference to this -# function, whose symbol name is too long for dtrace. So disable inlining -# for this method for now. (fix this when dtrace bug 6258412 is fixed) -OPT_CFLAGS/ciEnv.o = $(OPT_CFLAGS) -xinline=no%__1cFciEnvbFpost_compiled_method_load_event6MpnHnmethod__v_ - -# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files) - -# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings -CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# The following lines are copied from debug.make, except that we -# consult FASTDEBUG_CFLAGS instead of DEBUG_CFLAGS. -# Compiler specific DEBUG_CFLAGS are passed in from gcc.make, sparcWorks.make -DEBUG_CFLAGS/DEFAULT= $(FASTDEBUG_CFLAGS) -DEBUG_CFLAGS/BYFILE = $(DEBUG_CFLAGS/$@)$(DEBUG_CFLAGS/DEFAULT$(DEBUG_CFLAGS/$@)) -CFLAGS += $(DEBUG_CFLAGS/BYFILE) - -# Linker mapfiles -MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers \ - $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-debug - -# This mapfile is only needed when compiling with dtrace support, -# and mustn't be otherwise. -MAPFILE_DTRACE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-$(TYPE) - -VERSION = optimized -SYSDEFS += -DASSERT -DCHECK_UNHANDLED_OOPS -PICFLAGS = DEFAULT diff --git a/hotspot/make/solaris/makefiles/gcc.make b/hotspot/make/solaris/makefiles/gcc.make deleted file mode 100644 index d31237acbf1..00000000000 --- a/hotspot/make/solaris/makefiles/gcc.make +++ /dev/null @@ -1,241 +0,0 @@ -# -# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -#------------------------------------------------------------------------ -# CC, CXX & AS - -# If a SPEC is not set already, then use these defaults. -ifeq ($(SPEC),) - CXX = g++ - CC = gcc - AS = $(CC) -c - MCS = /usr/ccs/bin/mcs -endif - -Compiler = gcc - -# -dumpversion in gcc-2.91 shows "egcs-2.91.66". In later version, it only -# prints the numbers (e.g. "2.95", "3.2.1") -CC_VER_MAJOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) -CC_VER_MINOR := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) -CC_VER_MICRO := $(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f3) - -# Check for the versions of C++ and C compilers ($CXX and $CC) used. - -# Get the last thing on the line that looks like x.x+ (x is a digit). -COMPILER_REV := \ -$(shell $(CXX) -dumpversion | sed 's/egcs-//' | cut -d'.' -f1) -CC_COMPILER_REV := \ -$(shell $(CC) -dumpversion | sed 's/egcs-//' | cut -d'.' -f2) - - -# check for precompiled headers support -ifneq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) \| \( \( $(CC_VER_MAJOR) = 3 \) \& \( $(CC_VER_MINOR) \>= 4 \) \))" "0" -# Allow the user to turn off precompiled headers from the command line. -ifneq ($(USE_PRECOMPILED_HEADER),0) -PRECOMPILED_HEADER_DIR=. -PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp -PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch -endif -endif - - -#------------------------------------------------------------------------ -# Compiler flags - -# position-independent code -PICFLAG = -fPIC - -VM_PICFLAG/LIBJVM = $(PICFLAG) -VM_PICFLAG/AOUT = -VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO)) - -CFLAGS += $(VM_PICFLAG) -CFLAGS += -fno-rtti -CFLAGS += -fno-exceptions -CFLAGS += -D_REENTRANT -CFLAGS += -fcheck-new - -ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) - -ARCHFLAG/sparc = -m32 -mcpu=v9 -ARCHFLAG/sparcv9 = -m64 -mcpu=v9 -ARCHFLAG/i486 = -m32 -march=i586 -ARCHFLAG/amd64 = -m64 -march=k8 - - -# Optional sub-directory in /usr/lib where BUILDARCH libraries are kept. -ISA_DIR=$(ISA_DIR/$(BUILDARCH)) -ISA_DIR/amd64=/amd64 -ISA_DIR/i486= -ISA_DIR/sparcv9=/64 - - -CFLAGS += $(ARCHFLAG) -AOUT_FLAGS += $(ARCHFLAG) -LFLAGS += $(ARCHFLAG) -ASFLAGS += $(ARCHFLAG) - -ifeq ($(BUILDARCH), amd64) -ASFLAGS += -march=k8 -march=amd64 -LFLAGS += -march=k8 -endif - - -# Use C++ Interpreter -ifdef CC_INTERP - CFLAGS += -DCC_INTERP -endif - -# Keep temporary files (.ii, .s) -ifdef NEED_ASM - CFLAGS += -save-temps -else - CFLAGS += -pipe -endif - - -# Compiler warnings are treated as errors -WARNINGS_ARE_ERRORS ?= -Werror - -# Enable these warnings. See 'info gcc' about details on these options -WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef -Wformat=2 -CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) - -# Special cases -CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) - -# optimization control flags (Used by fastdebug and release variants) -OPT_CFLAGS/NOOPT=-O0 -OPT_CFLAGS/DEBUG=-O0 -OPT_CFLAGS/SIZE=-Os -OPT_CFLAGS/SPEED=-O3 - -OPT_CFLAGS_DEFAULT ?= SPEED - -# Hotspot uses very unstrict aliasing turn this optimization off -# This option is added to CFLAGS rather than OPT_CFLAGS -# so that OPT_CFLAGS overrides get this option too. -CFLAGS += -fno-strict-aliasing - -ifdef OPT_CFLAGS - ifneq ("$(origin OPT_CFLAGS)", "command line") - $(error " Use OPT_EXTRAS instead of OPT_CFLAGS to add extra flags to OPT_CFLAGS.") - endif -endif - -OPT_CFLAGS = $(OPT_CFLAGS/$(OPT_CFLAGS_DEFAULT)) $(OPT_EXTRAS) - -# The gcc compiler segv's on ia64 when compiling bytecodeInterpreter.cpp -# if we use expensive-optimizations -# Note: all ia64 setting reflect the ones for linux -# No actial testing was performed: there is no Solaris on ia64 presently -ifeq ($(BUILDARCH), ia64) -OPT_CFLAGS/bytecodeInterpreter.o += -fno-expensive-optimizations -endif - -# Work around some compiler bugs. -ifeq ($(USE_CLANG), true) - ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 2), 1) - OPT_CFLAGS/loopTransform.o += $(OPT_CFLAGS/NOOPT) - endif -else - # Do not allow GCC 4.1.1 - ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 1 \& $(CC_VER_MICRO) = 1), 1) - $(error "GCC $(CC_VER_MAJOR).$(CC_VER_MINOR).$(CC_VER_MICRO) not supported because of https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27724") - endif - # 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation. - ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1) - OPT_CFLAGS/mulnode.o += $(OPT_CFLAGS/NOOPT) - endif -endif - -# Flags for generating make dependency flags. -ifneq ($(CC_VER_MAJOR), 2) -DEPFLAGS = -fpch-deps -MMD -MP -MF $(DEP_DIR)/$(@:%=%.d) -endif - -# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. -ifeq ($(USE_PRECOMPILED_HEADER),0) -CFLAGS += -DDONT_USE_PRECOMPILED_HEADER -endif - -#------------------------------------------------------------------------ -# Linker flags - -# statically link libstdc++.so, work with gcc but ignored by g++ -STATIC_STDCXX = -Wl,-Bstatic -lstdc++ -Wl,-Bdynamic - - -ifdef USE_GNULD - # statically link libgcc and/or libgcc_s, libgcc does not exist before gcc-3.x. - ifneq ($(CC_VER_MAJOR), 2) - STATIC_LIBGCC += -static-libgcc - endif - - # Enable linker optimization - LFLAGS += -Xlinker -O1 - - ifneq (, findstring(debug,$(BUILD_FLAVOR))) - # for relocations read-only - LFLAGS += -Xlinker -z -Xlinker relro - - ifeq ($(BUILD_FLAVOR), debug) - # disable incremental relocations linking - LFLAGS += -Xlinker -z -Xlinker now - endif - endif - - ifeq ($(BUILDARCH), ia64) - # Note: all ia64 setting reflect the ones for linux - # No actual testing was performed: there is no Solaris on ia64 presently - LFLAGS += -Wl,-relax - endif - - # Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. - MAPFLAG = -Xlinker --version-script=FILENAME -else - MAPFLAG = -Xlinker -M -Xlinker FILENAME -endif - -# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj -SONAMEFLAG = -Xlinker -soname=SONAME - -# Build shared library -SHARED_FLAG = -shared - -#------------------------------------------------------------------------ -# Debug flags - -# Allow no optimizations. -DEBUG_CFLAGS=-O0 - -# Enable debug symbols -DEBUG_CFLAGS += -g - -# Enable bounds checking. -ifeq "$(shell expr \( $(CC_VER_MAJOR) \> 3 \) )" "1" - # stack smashing checks. - DEBUG_CFLAGS += -fstack-protector-all --param ssp-buffer-size=1 -endif diff --git a/hotspot/make/solaris/makefiles/hp.make b/hotspot/make/solaris/makefiles/hp.make deleted file mode 100644 index d0b10265560..00000000000 --- a/hotspot/make/solaris/makefiles/hp.make +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (c) 1998, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making premium version of VM - -TYPE=HP - -CFLAGS += -DCOMPILER2 diff --git a/hotspot/make/solaris/makefiles/hp1.make b/hotspot/make/solaris/makefiles/hp1.make deleted file mode 100644 index 2e37a6ead33..00000000000 --- a/hotspot/make/solaris/makefiles/hp1.make +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making premium version of VM - -TYPE=HP1 - -CFLAGS += -DCOMPILER1 diff --git a/hotspot/make/solaris/makefiles/i486.make b/hotspot/make/solaris/makefiles/i486.make deleted file mode 100644 index c2e6ff8395a..00000000000 --- a/hotspot/make/solaris/makefiles/i486.make +++ /dev/null @@ -1,42 +0,0 @@ -# -# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Must also specify if CPU is little endian -CFLAGS += -DVM_LITTLE_ENDIAN - -# TLS helper, assembled from .s file - -# -# Special case flags for compilers and compiler versions on i486. -# -ifeq ("${Platform_compiler}", "sparcWorks") -# ILD is gone as of SS11 (5.8), not supported in SS10 (5.7) -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \< 507), 1) - # - # Bug in ild causes it to fail randomly. Until we get a fix we can't - # use ild. - # - ILDFLAG/debug = -xildoff -endif -endif diff --git a/hotspot/make/solaris/makefiles/jsig.make b/hotspot/make/solaris/makefiles/jsig.make deleted file mode 100644 index 392f78c1651..00000000000 --- a/hotspot/make/solaris/makefiles/jsig.make +++ /dev/null @@ -1,81 +0,0 @@ -# -# Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Rules to build signal interposition library, used by vm.make - -# libjsig.so: signal interposition library -JSIG = jsig -LIBJSIG = lib$(JSIG).so - -LIBJSIG_DEBUGINFO = lib$(JSIG).debuginfo -LIBJSIG_DIZ = lib$(JSIG).diz - -JSIGSRCDIR = $(GAMMADIR)/src/os/$(Platform_os_family)/vm - -DEST_JSIG = $(JDK_LIBDIR)/$(LIBJSIG) -DEST_JSIG_DEBUGINFO = $(JDK_LIBDIR)/$(LIBJSIG_DEBUGINFO) -DEST_JSIG_DIZ = $(JDK_LIBDIR)/$(LIBJSIG_DIZ) - -LIBJSIG_MAPFILE = $(MAKEFILES_DIR)/mapfile-vers-jsig - -LFLAGS_JSIG += $(MAPFLAG:FILENAME=$(LIBJSIG_MAPFILE)) - -ifdef USE_GCC -LFLAGS_JSIG += -D_REENTRANT -else -LFLAGS_JSIG += -mt -xnolib -endif - -$(LIBJSIG): $(JSIGSRCDIR)/jsig.c $(LIBJSIG_MAPFILE) - @echo $(LOG_INFO) Making signal interposition lib... - $(QUIETLY) $(CC) $(SYMFLAG) $(ARCHFLAG) $(SHARED_FLAG) $(PICFLAG) \ - $(EXTRA_CFLAGS) \ - $(LFLAGS_JSIG) $(EXTRA_LDFLAGS) \ - -o $@ $(JSIGSRCDIR)/jsig.c -ldl -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJSIG_DEBUGINFO) - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJSIG_DEBUGINFO) $@ - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -x $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -y $(LIBJSIG_DIZ) $(LIBJSIG_DEBUGINFO) - $(RM) $(LIBJSIG_DEBUGINFO) - endif -endif - -install_jsig: $(LIBJSIG) - @echo "Copying $(LIBJSIG) to $(DEST_JSIG)" - $(QUIETLY) test ! -f $(LIBJSIG_DEBUGINFO) || \ - $(CP) -f $(LIBJSIG_DEBUGINFO) $(DEST_JSIG_DEBUGINFO) - $(QUIETLY) test ! -f $(LIBJSIG_DIZ) || \ - $(CP) -f $(LIBJSIG_DIZ) $(DEST_JSIG_DIZ) - $(QUIETLY) $(CP) -f $(LIBJSIG) $(DEST_JSIG) && echo "Done" - -.PHONY: install_jsig diff --git a/hotspot/make/solaris/makefiles/jvmti.make b/hotspot/make/solaris/makefiles/jvmti.make deleted file mode 100644 index 93b9f6ed885..00000000000 --- a/hotspot/make/solaris/makefiles/jvmti.make +++ /dev/null @@ -1,115 +0,0 @@ -# -# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (jvmti.make) is included from the jvmti.make in the -# build directories. -# -# It knows how to build and run the tools to generate jvmti. - -include $(GAMMADIR)/make/solaris/makefiles/rules.make - -# ######################################################################### - -GENERATED = ../generated -JvmtiOutDir = $(GENERATED)/jvmtifiles - -JvmtiSrcDir = $(GAMMADIR)/src/share/vm/prims -InterpreterSrcDir = $(GAMMADIR)/src/share/vm/interpreter - -# set VPATH so make knows where to look for source files -Src_Dirs_V += $(JvmtiSrcDir) -VPATH += $(Src_Dirs_V:%=%:) - -JvmtiGeneratedNames = \ - jvmtiEnv.hpp \ - jvmtiEnter.cpp \ - jvmtiEnterTrace.cpp \ - jvmtiEnvRecommended.cpp\ - bytecodeInterpreterWithChecks.cpp\ - jvmti.h \ - -JvmtiEnvFillSource = $(JvmtiSrcDir)/jvmtiEnvFill.java -JvmtiEnvFillClass = $(JvmtiOutDir)/jvmtiEnvFill.class - -JvmtiGenSource = $(JvmtiSrcDir)/jvmtiGen.java -JvmtiGenClass = $(JvmtiOutDir)/jvmtiGen.class - -JvmtiGeneratedFiles = $(JvmtiGeneratedNames:%=$(JvmtiOutDir)/%) - -XSLT = $(QUIETLY) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen - -.PHONY: all jvmtidocs clean cleanall - -# ######################################################################### - -all: $(JvmtiGeneratedFiles) - -both = $(JvmtiGenClass) $(JvmtiSrcDir)/jvmti.xml $(JvmtiSrcDir)/jvmtiLib.xsl - -$(JvmtiGenClass): $(JvmtiGenSource) - $(QUIETLY) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiGenSource) - -$(JvmtiEnvFillClass): $(JvmtiEnvFillSource) - $(QUIETLY) $(COMPILE.JAVAC) -d $(JvmtiOutDir) $(JvmtiEnvFillSource) - -$(JvmtiOutDir)/jvmtiEnter.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnter.cpp -PARAM interface jvmti - -$(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp: $(JvmtiGenClass) $(InterpreterSrcDir)/bytecodeInterpreter.cpp $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml -XSL $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl -OUT $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp - -$(JvmtiOutDir)/jvmtiEnterTrace.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnterTrace.cpp -PARAM interface jvmti -PARAM trace Trace - -$(JvmtiOutDir)/jvmtiEnvRecommended.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnv.xsl $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiEnvFillClass) - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnv.xsl -OUT $(JvmtiOutDir)/jvmtiEnvStub.cpp - $(QUIETLY) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiEnvFill $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiOutDir)/jvmtiEnvStub.cpp $(JvmtiOutDir)/jvmtiEnvRecommended.cpp - -$(JvmtiOutDir)/jvmtiEnv.hpp: $(both) $(JvmtiSrcDir)/jvmtiHpp.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiHpp.xsl -OUT $(JvmtiOutDir)/jvmtiEnv.hpp - -$(JvmtiOutDir)/jvmti.h: $(both) $(JvmtiSrcDir)/jvmtiH.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiH.xsl -OUT $(JvmtiOutDir)/jvmti.h - -jvmtidocs: $(JvmtiOutDir)/jvmti.html - -$(JvmtiOutDir)/jvmti.html: $(both) $(JvmtiSrcDir)/jvmti.xsl - @echo $(LOG_INFO) Generating $@ - $(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmti.xsl -OUT $(JvmtiOutDir)/jvmti.html - -# ######################################################################### - -clean : - rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles) - -cleanall : - rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles) - -# ######################################################################### diff --git a/hotspot/make/solaris/makefiles/mapfile-vers b/hotspot/make/solaris/makefiles/mapfile-vers deleted file mode 100644 index 3de0dd99af5..00000000000 --- a/hotspot/make/solaris/makefiles/mapfile-vers +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define public interface. - -SUNWprivate_1.1 { - global: - JVM_handle_solaris_signal; - - # miscellaneous functions - jio_fprintf; - jio_printf; - jio_snprintf; - jio_vfprintf; - jio_vsnprintf; - - # Needed because there is no JVM interface for this. - sysThreadAvailableStackWithSlack; - - # This is for Forte Analyzer profiling support. - AsyncGetCallTrace; - - # INSERT VTABLE SYMBOLS HERE - - local: - *; -}; diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-COMPILER1 b/hotspot/make/solaris/makefiles/mapfile-vers-COMPILER1 deleted file mode 100644 index f3a02560561..00000000000 --- a/hotspot/make/solaris/makefiles/mapfile-vers-COMPILER1 +++ /dev/null @@ -1,43 +0,0 @@ -# - -# -# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define public interface. - -SUNWprivate_1.1 { - global: - # Dtrace support - __1cJCodeCacheG_heaps_; - __1cIUniverseO_collectedHeap_; - __1cGMethodG__vtbl_; - __1cHnmethodG__vtbl_; - __1cICodeBlobG__vtbl_; - __1cKBufferBlobG__vtbl_; - __1cLRuntimeStubG__vtbl_; - __1cNSafepointBlobG__vtbl_; - __1cSDeoptimizationBlobG__vtbl_; - - __JvmOffsets; -}; diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-COMPILER2 b/hotspot/make/solaris/makefiles/mapfile-vers-COMPILER2 deleted file mode 100644 index 383ba3cc9a9..00000000000 --- a/hotspot/make/solaris/makefiles/mapfile-vers-COMPILER2 +++ /dev/null @@ -1,46 +0,0 @@ -# - -# -# Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define public interface. - -SUNWprivate_1.1 { - global: - # Dtrace support - __1cJCodeCacheG_heaps_; - __1cIUniverseO_collectedHeap_; - __1cGMethodG__vtbl_; - __1cHnmethodG__vtbl_; - __1cICodeBlobG__vtbl_; - __1cKBufferBlobG__vtbl_; - __1cLRuntimeStubG__vtbl_; - __1cNSafepointBlobG__vtbl_; - __1cSDeoptimizationBlobG__vtbl_; - - __1cNExceptionBlobG__vtbl_; - __1cQUncommonTrapBlobG__vtbl_; - - __JvmOffsets; -}; diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-CORE b/hotspot/make/solaris/makefiles/mapfile-vers-CORE deleted file mode 100644 index ed5896ba709..00000000000 --- a/hotspot/make/solaris/makefiles/mapfile-vers-CORE +++ /dev/null @@ -1,31 +0,0 @@ -# - -# -# Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define public interface. - -SUNWprivate_1.1 { - global: -}; diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-TIERED b/hotspot/make/solaris/makefiles/mapfile-vers-TIERED deleted file mode 100644 index 2f2c69d477e..00000000000 --- a/hotspot/make/solaris/makefiles/mapfile-vers-TIERED +++ /dev/null @@ -1,45 +0,0 @@ -# - -# -# Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define public interface. - -SUNWprivate_1.1 { - global: - # Dtrace support - __1cJCodeCacheG_heaps_; - __1cIUniverseO_collectedHeap_; - __1cGMethodG__vtbl_; - __1cHnmethodG__vtbl_; - __1cICodeBlobG__vtbl_; - __1cKBufferBlobG__vtbl_; - __1cLRuntimeStubG__vtbl_; - __1cNSafepointBlobG__vtbl_; - __1cSDeoptimizationBlobG__vtbl_; - __1cNExceptionBlobG__vtbl_; - __1cQUncommonTrapBlobG__vtbl_; - - __JvmOffsets; -}; diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-debug b/hotspot/make/solaris/makefiles/mapfile-vers-debug deleted file mode 100644 index f6b63d5a4bf..00000000000 --- a/hotspot/make/solaris/makefiles/mapfile-vers-debug +++ /dev/null @@ -1,33 +0,0 @@ -# - -# -# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define public interface. - -SUNWprivate_1.1 { - global: - - # miscellaneous -}; diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-jsig b/hotspot/make/solaris/makefiles/mapfile-vers-jsig deleted file mode 100644 index 8a675046b6e..00000000000 --- a/hotspot/make/solaris/makefiles/mapfile-vers-jsig +++ /dev/null @@ -1,40 +0,0 @@ -# - -# -# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define library interface. - -SUNWprivate_1.1 { - global: - JVM_begin_signal_setting; - JVM_end_signal_setting; - JVM_get_libjsig_version; - JVM_get_signal_action; - sigaction; - signal; - sigset; - local: - *; -}; diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-jvm_db b/hotspot/make/solaris/makefiles/mapfile-vers-jvm_db deleted file mode 100644 index 9ee418d01a2..00000000000 --- a/hotspot/make/solaris/makefiles/mapfile-vers-jvm_db +++ /dev/null @@ -1,38 +0,0 @@ -# - -# -# Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define library interface. - -SUNWprivate_1.1 { - global: - Jagent_create; - Jagent_destroy; - Jframe_iter; - #Jget_vframe; - #Jlookup_by_regs; - local: - *; -}; diff --git a/hotspot/make/solaris/makefiles/mapfile-vers-jvm_dtrace b/hotspot/make/solaris/makefiles/mapfile-vers-jvm_dtrace deleted file mode 100644 index f9aaa19ba9d..00000000000 --- a/hotspot/make/solaris/makefiles/mapfile-vers-jvm_dtrace +++ /dev/null @@ -1,37 +0,0 @@ -# - -# -# Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Define library interface for JVM-DTrace interface - -SUNWprivate_1.1 { - global: - jvm_attach; - jvm_get_last_error; - jvm_enable_dtprobes; - jvm_detach; - local: - *; -}; diff --git a/hotspot/make/solaris/makefiles/optimized.make b/hotspot/make/solaris/makefiles/optimized.make deleted file mode 100644 index f353628aec8..00000000000 --- a/hotspot/make/solaris/makefiles/optimized.make +++ /dev/null @@ -1,65 +0,0 @@ -# -# Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making optimized version of HotSpot VM -# (This is the "product", not the "release" version.) - -# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make -OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) -OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) - -# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files) -ifeq ("${Platform_compiler}", "sparcWorks") - -ifeq ($(COMPILER_REV_NUMERIC), 510) -# CC 5.10 has bug XXXXX with -xO4 -OPT_CFLAGS/jvmtiClassFileReconstituter.o = $(OPT_CFLAGS/O2) -endif # COMPILER_REV_NUMERIC == 510 - -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1) -# dtrace cannot handle tail call optimization (6672627, 6693876) -OPT_CFLAGS/jni.o = $(OPT_CFLAGS/DEFAULT) $(OPT_CCFLAGS/NO_TAIL_CALL_OPT) -endif # COMPILER_NUMERIC_REV >= 509 - -# Workaround SS11 bug 6345274 (all platforms) (Fixed in SS11 patch and SS12) -ifeq ($(COMPILER_REV_NUMERIC),508) -OPT_CFLAGS/ciTypeFlow.o = $(OPT_CFLAGS/O2) -endif # COMPILER_REV_NUMERIC == 508 - -endif # Platform_compiler == sparcWorks - -# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings -CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) - -# Linker mapfiles -MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers - -# This mapfile is only needed when compiling with dtrace support, -# and mustn't be otherwise. -MAPFILE_DTRACE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-$(TYPE) - -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -VERSION = optimized diff --git a/hotspot/make/solaris/makefiles/product.make b/hotspot/make/solaris/makefiles/product.make deleted file mode 100644 index b36159fdcc8..00000000000 --- a/hotspot/make/solaris/makefiles/product.make +++ /dev/null @@ -1,103 +0,0 @@ -# -# Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making optimized version of HotSpot VM -# (This is the "product", not the "release" version.) - -# Compiler specific OPT_CFLAGS are passed in from gcc.make, sparcWorks.make -OPT_CFLAGS/DEFAULT= $(OPT_CFLAGS) -OPT_CFLAGS/BYFILE = $(OPT_CFLAGS/$@)$(OPT_CFLAGS/DEFAULT$(OPT_CFLAGS/$@)) - -# Workaround for a bug in dtrace. If ciEnv::post_compiled_method_load_event() -# is inlined, the resulting dtrace object file needs a reference to this -# function, whose symbol name is too long for dtrace. So disable inlining -# for this method for now. (fix this when dtrace bug 6258412 is fixed) -ifndef USE_GCC -OPT_CFLAGS/ciEnv.o = $(OPT_CFLAGS) -xinline=no%__1cFciEnvbFpost_compiled_method_load_event6MpnHnmethod__v_ -# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides -# of OPT_CFLAGS. Restore it here. -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS/ciEnv.o += -g0 -xs -endif -endif - -# Need extra inlining to get oop_ps_push_contents functions to perform well enough. -ifndef USE_GCC -OPT_CFLAGS/psPromotionManager.o = $(OPT_CFLAGS) -W2,-Ainline:inc=1000 -# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides -# of OPT_CFLAGS. Restore it here. -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS/psPromotionManager.o += -g0 -xs -endif -endif - -# (OPT_CFLAGS/SLOWER is also available, to alter compilation of buggy files) -ifeq ("${Platform_compiler}", "sparcWorks") - -ifeq ($(COMPILER_REV_NUMERIC), 510) -# CC 5.10 has bug XXXXX with -xO4 -OPT_CFLAGS/jvmtiClassFileReconstituter.o = $(OPT_CFLAGS/O2) -# Avoid apparent crash because of corrupted methodHandle in a tail call -OPT_CFLAGS/simpleThresholdPolicy.o = $(OPT_CFLAGS/DEFAULT) $(OPT_CCFLAGS/NO_TAIL_CALL_OPT) -endif # COMPILER_REV_NUMERIC == 510 - -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1) -# dtrace cannot handle tail call optimization (6672627, 6693876) -OPT_CFLAGS/jni.o = $(OPT_CFLAGS/DEFAULT) $(OPT_CCFLAGS/NO_TAIL_CALL_OPT) -# The -g0 -xs flag is added to OPT_CFLAGS in sparcWorks.make, but lost in case of -# per-file overrides of OPT_CFLAGS. Restore it here. This is mainly needed -# to provide a good baseline to compare the new build against. -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS/jni.o += -g0 -xs -endif -endif # COMPILER_NUMERIC_REV >= 509 - -# Workaround SS11 bug 6345274 (all platforms) (Fixed in SS11 patch and SS12) -ifeq ($(COMPILER_REV_NUMERIC),508) -OPT_CFLAGS/ciTypeFlow.o = $(OPT_CFLAGS/O2) -endif # COMPILER_REV_NUMERIC == 508 - -endif # Platform_compiler == sparcWorks - -# If you set HOTSPARC_GENERIC=yes, you disable all OPT_CFLAGS settings -CFLAGS$(HOTSPARC_GENERIC) += $(OPT_CFLAGS/BYFILE) -# Set the environment variable HOTSPARC_GENERIC to "true" -# to inhibit the effect of the previous line on CFLAGS. - -# Linker mapfiles -MAPFILE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers - -ifndef USE_GCC -# This mapfile is only needed when compiling with dtrace support, -# and mustn't be otherwise. -MAPFILE_DTRACE = $(GAMMADIR)/make/solaris/makefiles/mapfile-vers-$(TYPE) - -endif - -# If we can create .debuginfo files, then the VM is stripped in vm.make -# and this macro is not used. -# LINK_LIB.CXX/POST_HOOK += $(STRIP_LIB.CXX/POST_HOOK) - -SYSDEFS += -DPRODUCT -VERSION = optimized diff --git a/hotspot/make/solaris/makefiles/reorder_CORE_amd64 b/hotspot/make/solaris/makefiles/reorder_CORE_amd64 deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/hotspot/make/solaris/makefiles/rules.make b/hotspot/make/solaris/makefiles/rules.make deleted file mode 100644 index a35b9dacd8c..00000000000 --- a/hotspot/make/solaris/makefiles/rules.make +++ /dev/null @@ -1,200 +0,0 @@ -# -# Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Common rules/macros for the vm, adlc. - -# Tell make that .cpp is important -.SUFFIXES: .cpp $(SUFFIXES) - -DEMANGLER = c++filt -DEMANGLE = $(DEMANGLER) < $@ > .$@ && $(MV) -f .$@ $@ - -# $(CC) is the c compiler (cc/gcc), $(CXX) is the c++ compiler (CC/g++). -CC_COMPILE = $(CC) $(CXXFLAGS) $(CFLAGS) -CXX_COMPILE = $(CXX) $(CXXFLAGS) $(CFLAGS) - -AS.S = $(AS) $(ASFLAGS) - -COMPILE.CC = $(CC_COMPILE) -c -GENASM.CC = $(CC_COMPILE) -S -LINK.CC = $(CC) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS) -LINK_LIB.CC = $(CC) $(LFLAGS) $(SHARED_FLAG) -PREPROCESS.CC = $(CC_COMPILE) -E - -COMPILE.CXX = $(CXX_COMPILE) -c -GENASM.CXX = $(CXX_COMPILE) -S -LINK.CXX = $(CXX) $(LFLAGS) $(AOUT_FLAGS) $(PROF_AOUT_FLAGS) -LINK_NOPROF.CXX = $(CXX) $(LFLAGS) $(AOUT_FLAGS) -LINK_LIB.CXX = $(CXX) $(LFLAGS) $(SHARED_FLAG) -PREPROCESS.CXX = $(CXX_COMPILE) -E - -# Effect of REMOVE_TARGET is to delete out-of-date files during "gnumake -k". -REMOVE_TARGET = rm -f $@ - -# Note use of ALT_BOOTDIR to explicitly specify location of java and -# javac; this is the same environment variable used in the J2SE build -# process for overriding the default spec, which is BOOTDIR. -# Note also that we fall back to using JAVA_HOME if neither of these is -# specified. - -ifdef ALT_BOOTDIR - -RUN.JAVA = $(ALT_BOOTDIR)/bin/java -RUN.JAVAP = $(ALT_BOOTDIR)/bin/javap -RUN.JAVAH = $(ALT_BOOTDIR)/bin/javah -RUN.JAR = $(ALT_BOOTDIR)/bin/jar -COMPILE.JAVAC = $(ALT_BOOTDIR)/bin/javac -COMPILE.RMIC = $(ALT_BOOTDIR)/bin/rmic -BOOT_JAVA_HOME = $(ALT_BOOTDIR) - -else - -ifdef BOOTDIR - -RUN.JAVA = $(BOOTDIR)/bin/java -RUN.JAVAP = $(BOOTDIR)/bin/javap -RUN.JAVAH = $(BOOTDIR)/bin/javah -RUN.JAR = $(BOOTDIR)/bin/jar -COMPILE.JAVAC = $(BOOTDIR)/bin/javac -COMPILE.RMIC = $(BOOTDIR)/bin/rmic -BOOT_JAVA_HOME = $(BOOTDIR) - -else - -ifdef JAVA_HOME - -RUN.JAVA = $(JAVA_HOME)/bin/java -RUN.JAVAP = $(JAVA_HOME)/bin/javap -RUN.JAVAH = $(JAVA_HOME)/bin/javah -RUN.JAR = $(JAVA_HOME)/bin/jar -COMPILE.JAVAC = $(JAVA_HOME)/bin/javac -COMPILE.RMIC = $(JAVA_HOME)/bin/rmic -BOOT_JAVA_HOME = $(JAVA_HOME) - -else - -# take from the PATH, if ALT_BOOTDIR, BOOTDIR and JAVA_HOME are not defined - -RUN.JAVA = java -RUN.JAVAP = javap -RUN.JAVAH = javah -RUN.JAR = jar -COMPILE.JAVAC = javac -COMPILE.RMIC = rmic - -endif -endif -endif - -COMPILE.JAVAC += $(BOOTSTRAP_JAVAC_FLAGS) - -SUM = /usr/bin/sum - -# 'gmake MAKE_VERBOSE=y' gives all the gory details. -QUIETLY$(MAKE_VERBOSE) = @ -RUN.JAR$(MAKE_VERBOSE) += >/dev/null - -# Settings for javac -JAVAC_FLAGS = -g -encoding ascii - -# Prefer BOOT_JDK_SOURCETARGET if it's set (typically by the top build system) -# Fall back to the values here if it's not set (hotspot only builds) -ifeq ($(BOOT_JDK_SOURCETARGET),) -BOOTSTRAP_SOURCETARGET := -source 8 -target 8 -else -BOOTSTRAP_SOURCETARGET := $(BOOT_JDK_SOURCETARGET) -endif - -BOOTSTRAP_JAVAC_FLAGS = $(JAVAC_FLAGS) $(BOOTSTRAP_SOURCETARGET) - -# With parallel makes, print a message at the end of compilation. -ifeq ($(findstring j,$(MFLAGS)),j) -COMPILE_DONE = && { echo Done with $<; } -endif - -# Include NONPIC_OBJ_FILES definition -ifndef LP64 -include $(GAMMADIR)/make/pic.make -endif - -include $(GAMMADIR)/make/altsrc.make - -# Sun compiler for 64 bit Solaris does not support building non-PIC object files. -ifdef LP64 -%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE) -else -%.o: %.cpp - @echo $(LOG_INFO) Compiling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(if $(findstring $@, $(NONPIC_OBJ_FILES)), \ - $(subst $(VM_PICFLAG), ,$(COMPILE.CXX)) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE), \ - $(COMPILE.CXX) $(DEPFLAGS) -o $@ $< $(COMPILE_DONE)) -endif - -%.o: %.s - @echo $(LOG_INFO) Assembling $< - $(QUIETLY) $(REMOVE_TARGET) - $(QUIETLY) $(AS.S) -o $@ $< $(COMPILE_DONE) - -%.s: %.cpp - @echo $(LOG_INFO) Generating assembly for $< - $(QUIETLY) $(GENASM.CXX) -o $@ $< - $(QUIETLY) $(DEMANGLE) $(COMPILE_DONE) - -# Intermediate files (for debugging macros) -%.i: %.cpp - @echo $(LOG_INFO) Preprocessing $< to $@ - $(QUIETLY) $(PREPROCESS.CXX) $< > $@ $(COMPILE_DONE) - -# Override gnumake built-in rules which do sccs get operations badly. -# (They put the checked out code in the current directory, not in the -# directory of the original file.) Since this is a symptom of a teamware -# failure, and since not all problems can be detected by gnumake due -# to incomplete dependency checking... just complain and stop. -%:: s.% - @echo "=========================================================" - @echo File $@ - @echo is out of date with respect to its SCCS file. - @echo This file may be from an unresolved Teamware conflict. - @echo This is also a symptom of a Teamware bringover/putback failure - @echo in which SCCS files are updated but not checked out. - @echo Check for other out of date files in your workspace. - @echo "=========================================================" - @exit 666 - -%:: SCCS/s.% - @echo "=========================================================" - @echo File $@ - @echo is out of date with respect to its SCCS file. - @echo This file may be from an unresolved Teamware conflict. - @echo This is also a symptom of a Teamware bringover/putback failure - @echo in which SCCS files are updated but not checked out. - @echo Check for other out of date files in your workspace. - @echo "=========================================================" - @exit 666 - -.PHONY: default diff --git a/hotspot/make/solaris/makefiles/sparc.make b/hotspot/make/solaris/makefiles/sparc.make deleted file mode 100644 index ff507f2fab8..00000000000 --- a/hotspot/make/solaris/makefiles/sparc.make +++ /dev/null @@ -1,124 +0,0 @@ -# -# Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -Obj_Files += solaris_sparc.o -ASFLAGS += $(AS_ARCHFLAG) - -ifeq ("${Platform_compiler}", "sparcWorks") -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \< 505), 1) -# For 5.2 ad_sparc file is compiled with -O2 %%%% remove when adlc is fixed -OPT_CFLAGS/ad_sparc.o = $(OPT_CFLAGS/SLOWER) -OPT_CFLAGS/dfa_sparc.o = $(OPT_CFLAGS/SLOWER) -# CC drops core on systemDictionary.o in -xO4 mode -OPT_CFLAGS/systemDictionary.o = $(OPT_CFLAGS/SLOWER) -# SC5.0 bug 4284168 -OPT_CFLAGS/carRememberedSet.o = $(OPT_CFLAGS/O2) -# Temporarily drop the optimization level for compiling -# jniHandles.cpp to O3 from O4; see bug 4309181 -OPT_CFLAGS/jniHandles.o = $(OPT_CFLAGS/O2) -# CC brings an US-II to its knees compiling the vmStructs asserts under -xO4 -OPT_CFLAGS/vmStructs.o = $(OPT_CFLAGS/O2) -endif # COMPILER_REV_NUMERIC < 505 -else -# Options for gcc -OPT_CFLAGS/ad_sparc.o = $(OPT_CFLAGS/SLOWER) -OPT_CFLAGS/dfa_sparc.o = $(OPT_CFLAGS/SLOWER) -OPT_CFLAGS/systemDictionary.o = $(OPT_CFLAGS/SLOWER) -OPT_CFLAGS/carRememberedSet.o = $(OPT_CFLAGS/O2) -OPT_CFLAGS/jniHandles.o = $(OPT_CFLAGS/O2) -OPT_CFLAGS/vmStructs.o = $(OPT_CFLAGS/O2) -endif - -# File-specific adjustments to the PICFLAG, applicable only to SPARC, -# which has a very tight limit on global constant references. - -# Old files which seemed hot at one point or another: -#PICFLAG/runtime.o = $(PICFLAG/BETTER) -#PICFLAG/generateOopMap.o = $(PICFLAG/BETTER) -#PICFLAG/thread.o = $(PICFLAG/BETTER) -#PICFLAG/parse2.o = $(PICFLAG/BETTER) -#PICFLAG/parse1.o = $(PICFLAG/BETTER) -#PICFLAG/universe.o = $(PICFLAG/BETTER) -#PICFLAG/safepoint.o = $(PICFLAG/BETTER) -#PICFLAG/parse3.o = $(PICFLAG/BETTER) -#PICFLAG/compile.o = $(PICFLAG/BETTER) -#PICFLAG/codeBlob.o = $(PICFLAG/BETTER) -#PICFLAG/mutexLocker.o = $(PICFLAG/BETTER) -#PICFLAG/nativeInst_sparc.o = $(PICFLAG/BETTER) -#PICFLAG/methodLiveness.o = $(PICFLAG/BETTER) -#PICFLAG/synchronizer.o = $(PICFLAG/BETTER) -#PICFLAG/method.o = $(PICFLAG/BETTER) -#PICFLAG/space.o = $(PICFLAG/BETTER) -#PICFLAG/interpreterRT_sparc.o = $(PICFLAG/BETTER) -#PICFLAG/generation.o = $(PICFLAG/BETTER) -#PICFLAG/markSweep.o = $(PICFLAG/BETTER) -#PICFLAG/parseHelper.o = $(PICFLAG/BETTER) - -# Confirmed by function-level profiling: -PICFLAG/scavenge.o = $(PICFLAG/BETTER) -PICFLAG/instanceKlass.o = $(PICFLAG/BETTER) -PICFLAG/frame.o = $(PICFLAG/BETTER) -PICFLAG/phaseX.o = $(PICFLAG/BETTER) -PICFLAG/lookupCache.o = $(PICFLAG/BETTER) -PICFLAG/chaitin.o = $(PICFLAG/BETTER) -PICFLAG/type.o = $(PICFLAG/BETTER) -PICFLAG/jvm.o = $(PICFLAG/BETTER) -PICFLAG/jni.o = $(PICFLAG/BETTER) -PICFLAG/matcher.o = $(PICFLAG/BETTER) - -# New from module-level profiling (trustworthy?): -PICFLAG/rememberedSet.o = $(PICFLAG/BETTER) -PICFLAG/frame_sparc.o = $(PICFLAG/BETTER) -PICFLAG/live.o = $(PICFLAG/BETTER) -PICFLAG/vectset.o = $(PICFLAG/BETTER) -PICFLAG/objArrayKlass.o = $(PICFLAG/BETTER) -PICFLAG/do_call.o = $(PICFLAG/BETTER) -PICFLAG/loopnode.o = $(PICFLAG/BETTER) -PICFLAG/cfgnode.o = $(PICFLAG/BETTER) -PICFLAG/ifg.o = $(PICFLAG/BETTER) -PICFLAG/vframe.o = $(PICFLAG/BETTER) -PICFLAG/postaloc.o = $(PICFLAG/BETTER) -PICFLAG/carRememberedSet.o = $(PICFLAG/BETTER) -PICFLAG/gcm.o = $(PICFLAG/BETTER) -PICFLAG/coalesce.o = $(PICFLAG/BETTER) -PICFLAG/oop.o = $(PICFLAG/BETTER) -PICFLAG/oopMap.o = $(PICFLAG/BETTER) -PICFLAG/resourceArea.o = $(PICFLAG/BETTER) -PICFLAG/node.o = $(PICFLAG/BETTER) -PICFLAG/dict.o = $(PICFLAG/BETTER) -PICFLAG/domgraph.o = $(PICFLAG/BETTER) -PICFLAG/dfa_sparc.o = $(PICFLAG/BETTER) -PICFLAG/block.o = $(PICFLAG/BETTER) -PICFLAG/javaClasses.o = $(PICFLAG/BETTER) - -# New hot files: -PICFLAG/classes.o = $(PICFLAG/BETTER) -#PICFLAG/ad_sparc.o = $(PICFLAG/BETTER) -PICFLAG/nmethod.o = $(PICFLAG/BETTER) -PICFLAG/relocInfo.o = $(PICFLAG/BETTER) -PICFLAG/codeBuffer_sparc.o = $(PICFLAG/BETTER) -PICFLAG/callnode.o = $(PICFLAG/BETTER) -PICFLAG/multnode.o = $(PICFLAG/BETTER) -PICFLAG/os_solaris.o = $(PICFLAG/BETTER) -PICFLAG/typeArrayKlass.o = $(PICFLAG/BETTER) diff --git a/hotspot/make/solaris/makefiles/sparcWorks.make b/hotspot/make/solaris/makefiles/sparcWorks.make deleted file mode 100644 index 5c66b2f3d20..00000000000 --- a/hotspot/make/solaris/makefiles/sparcWorks.make +++ /dev/null @@ -1,565 +0,0 @@ -# -# Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# If a SPEC is not set already, then use these defaults. -ifeq ($(SPEC),) - # Compiler-specific flags for sparcworks. - CC = cc - CXX = CC - - # Note that this 'as' is an older version of the Sun Studio 'fbe', and will - # use the older style options. The 'fbe' options will match 'cc' and 'CC'. - AS = /usr/ccs/bin/as - - NM = /usr/ccs/bin/nm - NAWK = /bin/nawk - - MCS = /usr/ccs/bin/mcs - STRIP = /usr/ccs/bin/strip -endif - -# Check for the versions of C++ and C compilers ($CXX and $CC) used. - -# Get the last thing on the line that looks like x.x+ (x is a digit). -COMPILER_REV := \ -$(shell $(CXX) -V 2>&1 | sed -n 's/^.*[ ,\t]C++[ ,\t]\([1-9]\.[0-9][0-9]*\).*/\1/p') -CC_COMPILER_REV := \ -$(shell $(CC) -V 2>&1 | sed -n 's/^.*[ ,\t]C[ ,\t]\([1-9]\.[0-9][0-9]*\).*/\1/p') - -# Pick which compiler is validated -# Validated compiler for JDK9 is SS12.4 (5.13) -VALIDATED_COMPILER_REVS := 5.13 -VALIDATED_CC_COMPILER_REVS := 5.13 - -# Warning messages about not using the above validated versions -ENFORCE_COMPILER_REV${ENFORCE_COMPILER_REV} := $(strip ${VALIDATED_COMPILER_REVS}) -ifeq ($(filter ${ENFORCE_COMPILER_REV},${COMPILER_REV}),) -PRINTABLE_CC_REVS := $(subst $(shell echo ' '), or ,${ENFORCE_COMPILER_REV}) -dummy_var_to_enforce_compiler_rev := $(shell \ - echo >&2 WARNING: You are using CC version ${COMPILER_REV} and \ - should be using version ${PRINTABLE_CC_REVS}.; \ - echo >&2 Set ENFORCE_COMPILER_REV=${COMPILER_REV} to avoid this \ - warning.) -endif - -ENFORCE_CC_COMPILER_REV${ENFORCE_CC_COMPILER_REV} := $(strip ${VALIDATED_CC_COMPILER_REVS}) -ifeq ($(filter ${ENFORCE_CC_COMPILER_REV},${CC_COMPILER_REV}),) -PRINTABLE_C_REVS := $(subst $(shell echo ' '), or ,${ENFORCE_CC_COMPILER_REV}) -dummy_var_to_enforce_c_compiler_rev := $(shell \ - echo >&2 WARNING: You are using cc version ${CC_COMPILER_REV} and \ - should be using version ${PRINTABLE_C_REVS}.; \ - echo >&2 Set ENFORCE_CC_COMPILER_REV=${CC_COMPILER_REV} to avoid this \ - warning.) -endif - -COMPILER_REV_NUMERIC := $(shell echo $(COMPILER_REV) | awk -F. '{ print $$1 * 100 + $$2 }') - -# Fail the build if __fabsf is used. __fabsf exists only in Solaris 8 2/04 -# and newer; objects with a dependency on this symbol will not run on older -# Solaris 8. -JVM_FAIL_IF_UNDEFINED = __fabsf - -JVM_CHECK_SYMBOLS = $(NM) -u -p $(LIBJVM.o) | \ - $(NAWK) -v f="${JVM_FAIL_IF_UNDEFINED}" \ - 'BEGIN { c=split(f,s); rc=0; } \ - /:$$/ { file = $$1; } \ - /[^:]$$/ { for(n=1;n<=c;++n) { \ - if($$1==s[n]) { \ - printf("JVM_CHECK_SYMBOLS: %s contains illegal symbol %s\n", \ - file,$$1); \ - rc=1; \ - } \ - } \ - } \ - END { exit rc; }' - -LINK_LIB.CXX/PRE_HOOK += $(JVM_CHECK_SYMBOLS) || exit 1; - -# New architecture options started in SS12 (5.9), we need both styles to build. -# The older arch options for SS11 (5.8) or older and also for /usr/ccs/bin/as. -# Note: default for 32bit sparc is now the same as v8plus, so the -# settings below have changed all 32bit sparc builds to be v8plus. -ARCHFLAG_OLD/sparc = -xarch=v8plus -ARCHFLAG_NEW/sparc = -m32 -xarch=sparc -ARCHFLAG_OLD/sparcv9 = -xarch=v9 -ARCHFLAG_NEW/sparcv9 = -m64 -xarch=sparc -ARCHFLAG_OLD/i486 = -ARCHFLAG_NEW/i486 = -m32 -ARCHFLAG_OLD/amd64 = -xarch=amd64 -ARCHFLAG_NEW/amd64 = -m64 - -# Select the ARCHFLAGs and other SS12 (5.9) options -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1) - ARCHFLAG/sparc = $(ARCHFLAG_NEW/sparc) - ARCHFLAG/sparcv9 = $(ARCHFLAG_NEW/sparcv9) - ARCHFLAG/i486 = $(ARCHFLAG_NEW/i486) - ARCHFLAG/amd64 = $(ARCHFLAG_NEW/amd64) -else - ARCHFLAG/sparc = $(ARCHFLAG_OLD/sparc) - ARCHFLAG/sparcv9 = $(ARCHFLAG_OLD/sparcv9) - ARCHFLAG/i486 = $(ARCHFLAG_OLD/i486) - ARCHFLAG/amd64 = $(ARCHFLAG_OLD/amd64) -endif - -# ARCHFLAGS for the current build arch -ARCHFLAG = $(ARCHFLAG/$(BUILDARCH)) -AS_ARCHFLAG = $(ARCHFLAG_OLD/$(BUILDARCH)) - -# Optional sub-directory in /usr/lib where BUILDARCH libraries are kept. -ISA_DIR=$(ISA_DIR/$(BUILDARCH)) -ISA_DIR/sparcv9=/sparcv9 -ISA_DIR/amd64=/amd64 - -# Use these to work around compiler bugs: -OPT_CFLAGS/SLOWER=-xO3 -OPT_CFLAGS/O2=-xO2 -OPT_CFLAGS/NOOPT=-xO1 - -# Flags for creating the dependency files. -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1) -DEPFLAGS = -xMMD -xMF $(DEP_DIR)/$(@:%=%.d) -endif - -# -DDONT_USE_PRECOMPILED_HEADER will exclude all includes in precompiled.hpp. -CFLAGS += -DDONT_USE_PRECOMPILED_HEADER - -# Compiler warnings are treated as errors -WARNINGS_ARE_ERRORS ?= -xwe -CFLAGS_WARN = $(WARNINGS_ARE_ERRORS) - -################################################ -# Begin current (>=5.9) Forte compiler options # -################################################# - -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 509), 1) -ifeq ($(Platform_arch), x86) -OPT_CFLAGS/NO_TAIL_CALL_OPT = -Wu,-O~yz -OPT_CCFLAGS/NO_TAIL_CALL_OPT = -Qoption ube -O~yz -OPT_CFLAGS/stubGenerator_x86_32.o = $(OPT_CFLAGS) -xspace -OPT_CFLAGS/stubGenerator_x86_64.o = $(OPT_CFLAGS) -xspace -# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides -# of OPT_CFLAGS. Restore it here. -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS/stubGenerator_x86_32.o += -g0 -xs - OPT_CFLAGS/stubGenerator_x86_64.o += -g0 -xs -endif -endif # Platform_arch == x86 -ifeq ("${Platform_arch}", "sparc") -OPT_CFLAGS/stubGenerator_sparc.o = $(OPT_CFLAGS) -xspace -# The debug flag is added to OPT_CFLAGS, but lost in case of per-file overrides -# of OPT_CFLAGS. Restore it here. -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS/stubGenerator_sparc.o += -g0 -xs -endif -endif -endif # COMPILER_REV_NUMERIC >= 509 - -################################################# -# Begin current (>=5.6) Forte compiler options # -################################################# - -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 506), 1) - -ifeq ("${Platform_arch}", "sparc") - -# We MUST allow data alignment of 4 for sparc (sparcv9 is ok at 8s) -ifndef LP64 -CFLAGS += -xmemalign=4s -endif - -endif - -endif - -################################################# -# Begin current (>=5.5) Forte compiler options # -################################################# - -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 505), 1) - -CFLAGS += $(ARCHFLAG) -AOUT_FLAGS += $(ARCHFLAG) -LIB_FLAGS += $(ARCHFLAG) -LFLAGS += $(ARCHFLAG) - -ifeq ("${Platform_arch}", "sparc") - -# Flags for Optimization - -# [phh] Commented out pending verification that we do indeed want -# to potentially bias against u1 and u3 targets. -#CFLAGS += -xchip=ultra2 - -OPT_CFLAGS=-xO4 $(EXTRA_OPT_CFLAGS) - -endif # sparc - -ifeq ("${Platform_arch_model}", "x86_32") - -OPT_CFLAGS=-xtarget=pentium -xO4 $(EXTRA_OPT_CFLAGS) - -endif # 32bit x86 - -ifeq ("${Platform_arch_model}", "x86_64") - -ASFLAGS += $(AS_ARCHFLAG) -CFLAGS += $(ARCHFLAG/amd64) -# this one seemed useless -LFLAGS_VM += $(ARCHFLAG/amd64) -# this one worked -LFLAGS += $(ARCHFLAG/amd64) -AOUT_FLAGS += $(ARCHFLAG/amd64) - -# -xO3 is faster than -xO4 on specjbb with SS10 compiler -OPT_CFLAGS=-xO4 $(EXTRA_OPT_CFLAGS) - -endif # 64bit x86 - -# Inline functions -CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_${Platform_arch}/vm/solaris_${Platform_arch_model}.il - -# no more exceptions -CFLAGS/NOEX=-features=no%except - - -# avoid compilation problems arising from fact that C++ compiler tries -# to search for external template definition by just compiling additional -# source files in th same context -CFLAGS += -template=no%extdef - -# Reduce code bloat by reverting back to 5.0 behavior for static initializers -CFLAGS += -features=no%split_init - -# Use -D_Crun_inline_placement so we don't get references to -# __1c2n6FIpv_0_ or void*operator new(unsigned,void*) -# This avoids the hard requirement of the newer Solaris C++ runtime patches. -# NOTE: This is an undocumented feature of the SS10 compiler. See 6306698. -CFLAGS += -D_Crun_inline_placement - -# PIC is safer for SPARC, and is considerably slower -# a file foo.o which wants to compile -pic can set "PICFLAG/foo.o = -PIC" -PICFLAG = -KPIC -PICFLAG/DEFAULT = $(PICFLAG) -# [RGV] Need to figure which files to remove to get link to work -#PICFLAG/BETTER = -pic -PICFLAG/BETTER = $(PICFLAG/DEFAULT) -PICFLAG/BYFILE = $(PICFLAG/$@)$(PICFLAG/DEFAULT$(PICFLAG/$@)) - -# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. -MAPFLAG = -M FILENAME - -# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj -SONAMEFLAG = -h SONAME - -# Build shared library -SHARED_FLAG = -G - -# We don't need libCstd.so and librwtools7.so, only libCrun.so -CFLAGS += -library=%none -LFLAGS += -library=%none - -LFLAGS += -mt - -endif # COMPILER_REV_NUMERIC >= 505 - -###################################### -# End 5.5 Forte compiler options # -###################################### - -###################################### -# Begin 5.2 Forte compiler options # -###################################### - -ifeq ($(COMPILER_REV_NUMERIC), 502) - -CFLAGS += $(ARCHFLAG) -AOUT_FLAGS += $(ARCHFLAG) -LIB_FLAGS += $(ARCHFLAG) -LFLAGS += $(ARCHFLAG) - -ifeq ("${Platform_arch}", "sparc") - -# Flags for Optimization - -# [phh] Commented out pending verification that we do indeed want -# to potentially bias against u1 and u3 targets. -#CFLAGS += -xchip=ultra2 - -ifdef LP64 -# SC5.0 tools on v9 are flakey at -xO4 -# [phh] Is this still true for 6.1? -OPT_CFLAGS=-xO3 $(EXTRA_OPT_CFLAGS) -else -OPT_CFLAGS=-xO4 $(EXTRA_OPT_CFLAGS) -endif - -endif # sparc - -ifeq ("${Platform_arch_model}", "x86_32") - -OPT_CFLAGS=-xtarget=pentium $(EXTRA_OPT_CFLAGS) - -# SC5.0 tools on x86 are flakey at -xO4 -# [phh] Is this still true for 6.1? -OPT_CFLAGS+=-xO3 - -endif # 32bit x86 - -# no more exceptions -CFLAGS/NOEX=-noex - -# Inline functions -CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_${Platform_arch}/vm/solaris_${Platform_arch_model}.il - -# Reduce code bloat by reverting back to 5.0 behavior for static initializers -CFLAGS += -Qoption ccfe -one_static_init - -# PIC is safer for SPARC, and is considerably slower -# a file foo.o which wants to compile -pic can set "PICFLAG/foo.o = -PIC" -PICFLAG = -KPIC -PICFLAG/DEFAULT = $(PICFLAG) -# [RGV] Need to figure which files to remove to get link to work -#PICFLAG/BETTER = -pic -PICFLAG/BETTER = $(PICFLAG/DEFAULT) -PICFLAG/BYFILE = $(PICFLAG/$@)$(PICFLAG/DEFAULT$(PICFLAG/$@)) - -# Use $(MAPFLAG:FILENAME=real_file_name) to specify a map file. -MAPFLAG = -M FILENAME - -# Use $(SONAMEFLAG:SONAME=soname) to specify the intrinsic name of a shared obj -SONAMEFLAG = -h SONAME - -# Build shared library -SHARED_FLAG = -G - -# Would be better if these weren't needed, since we link with CC, but -# at present removing them causes run-time errors -LFLAGS += -library=Crun -LIBS += -library=Crun -lCrun - -endif # COMPILER_REV_NUMERIC == 502 - -################################## -# End 5.2 Forte compiler options # -################################## - -################################## -# Begin old 5.1 compiler options # -################################## -ifeq ($(COMPILER_REV_NUMERIC), 501) - -_JUNK_ := $(shell echo >&2 \ - "*** ERROR: sparkWorks.make incomplete for 5.1 compiler") - @exit 1 -endif -################################## -# End old 5.1 compiler options # -################################## - -################################## -# Begin old 5.0 compiler options # -################################## - -ifeq (${COMPILER_REV_NUMERIC}, 500) - -# Had to hoist this higher apparently because of other changes. Must -# come before -xarch specification. -# NOTE: native says optimize for the machine doing the compile, bad news. -CFLAGS += -xtarget=native - -CFLAGS += $(ARCHFLAG) -AOUT_FLAGS += $(ARCHFLAG) -LIB_FLAGS += $(ARCHFLAG) -LFLAGS += $(ARCHFLAG) - -CFLAGS += -library=iostream -LFLAGS += -library=iostream -library=Crun -LIBS += -library=iostream -library=Crun -lCrun - -# Flags for Optimization -ifdef LP64 -# SC5.0 tools on v9 are flakey at -xO4 -OPT_CFLAGS=-xO3 $(EXTRA_OPT_CFLAGS) -else -OPT_CFLAGS=-xO4 $(EXTRA_OPT_CFLAGS) -endif - -ifeq ("${Platform_arch}", "sparc") - -CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.il - -endif # sparc - -ifeq ("${Platform_arch_model}", "x86_32") -OPT_CFLAGS=-xtarget=pentium $(EXTRA_OPT_CFLAGS) -ifeq ("${COMPILER_REV_NUMERIC}", "500") -# SC5.0 tools on x86 are flakey at -xO4 -OPT_CFLAGS+=-xO3 -else -OPT_CFLAGS+=-xO4 -endif - -CFLAGS += $(GAMMADIR)/src/os_cpu/solaris_x86/vm/solaris_x86_32.il - -endif # 32bit x86 - -# The following options run into misaligned ldd problem (raj) -#OPT_CFLAGS = -fast -O4 $(ARCHFLAG/sparc) -xchip=ultra - -# no more exceptions -CFLAGS/NOEX=-noex - -# PIC is safer for SPARC, and is considerably slower -# a file foo.o which wants to compile -pic can set "PICFLAG/foo.o = -PIC" -PICFLAG = -PIC -PICFLAG/DEFAULT = $(PICFLAG) -# [RGV] Need to figure which files to remove to get link to work -#PICFLAG/BETTER = -pic -PICFLAG/BETTER = $(PICFLAG/DEFAULT) -PICFLAG/BYFILE = $(PICFLAG/$@)$(PICFLAG/DEFAULT$(PICFLAG/$@)) - -endif # COMPILER_REV_NUMERIC = 500 - -################################ -# End old 5.0 compiler options # -################################ - -ifeq ("${COMPILER_REV_NUMERIC}", "402") -# 4.2 COMPILERS SHOULD NO LONGER BE USED -_JUNK_ := $(shell echo >&2 \ - "*** ERROR: SC4.2 compilers are not supported by this code base!") - @exit 1 -endif - -# do not include shared lib path in a.outs -AOUT_FLAGS += -norunpath -LFLAGS_VM = -norunpath -z noversion - -# need position-indep-code for shared libraries -# (ild appears to get errors on PIC code, so we'll try non-PIC for debug) -ifeq ($(PICFLAGS),DEFAULT) -VM_PICFLAG/LIBJVM = $(PICFLAG/DEFAULT) -else -VM_PICFLAG/LIBJVM = $(PICFLAG/BYFILE) -endif -VM_PICFLAG/AOUT = - -VM_PICFLAG = $(VM_PICFLAG/$(LINK_INTO)) -CFLAGS += $(VM_PICFLAG) - -# less dynamic linking (no PLTs, please) -#LIB_FLAGS += $(LINK_MODE) -# %%%%% despite -znodefs, -Bsymbolic gets link errors -- Rose - -LINK_MODE = $(LINK_MODE/$(VERSION)) -LINK_MODE/debug = -LINK_MODE/optimized = -Bsymbolic -znodefs - -# Have thread local errnos -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 505), 1) -CFLAGS += -mt -else -CFLAGS += -D_REENTRANT -endif - -ifdef CC_INTERP -# C++ Interpreter -CFLAGS += -DCC_INTERP -endif - -# Flags for Debugging -# The -g0 setting allows the C++ frontend to inline, which is a big win. -# The -xs setting disables 'lazy debug info' which puts everything in -# the .so instead of requiring the '.o' files. -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - OPT_CFLAGS += -g0 -xs -endif -DEBUG_CFLAGS = -g -FASTDEBUG_CFLAGS = -g0 -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - DEBUG_CFLAGS += -xs - FASTDEBUG_CFLAGS += -xs -endif - -# Enable the following CFLAGS additions if you need to compare the -# built ELF objects. -# -# The -g option makes static data global and the "-Qoption ccfe -# -xglobalstatic" option tells the compiler to not globalize static -# data using a unique globalization prefix. Instead force the use of -# a static globalization prefix based on the source filepath so the -# objects from two identical compilations are the same. -# EXTRA_CFLAGS only covers vm_version.cpp for some reason -#EXTRA_CFLAGS += -Qoption ccfe -xglobalstatic -#OPT_CFLAGS += -Qoption ccfe -xglobalstatic -#DEBUG_CFLAGS += -Qoption ccfe -xglobalstatic -#FASTDEBUG_CFLAGS += -Qoption ccfe -xglobalstatic - -ifeq (${COMPILER_REV_NUMERIC}, 502) -COMPILER_DATE := $(shell $(CXX) -V 2>&1 | sed -n '/^.*[ ]C++[ ]\([1-9]\.[0-9][0-9]*\)/p' | awk '{ print $$NF; }') -ifeq (${COMPILER_DATE}, 2001/01/31) -# disable -g0 in fastdebug since SC6.1 dated 2001/01/31 seems to be buggy -# use an innocuous value because it will get -g if it's empty -FASTDEBUG_CFLAGS = -c -endif -endif - -# Uncomment or 'gmake CFLAGS_BROWSE=-sbfast' to get source browser information. -# CFLAGS_BROWSE = -sbfast -CFLAGS += $(CFLAGS_BROWSE) - -# ILD is gone as of SS11 (5.8), not supportted in SS10 (5.7) -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \< 507), 1) - # use ild when debugging (but when optimizing we want reproducible results) - ILDFLAG = $(ILDFLAG/$(VERSION)) - ILDFLAG/debug = -xildon - ILDFLAG/optimized = - AOUT_FLAGS += $(ILDFLAG) -endif - -# Where to put the *.o files (a.out, or shared library)? -LINK_INTO = $(LINK_INTO/$(VERSION)) -LINK_INTO/debug = LIBJVM -LINK_INTO/optimized = LIBJVM - -# We link the debug version into the a.out because: -# 1. ild works on a.out but not shared libraries, and using ild -# can cut rebuild times by 25% for small changes. (ILD is gone in SS11) -# 2. dbx cannot gracefully set breakpoints in shared libraries -# - -# apply this setting to link into the shared library even in the debug version: -ifdef LP64 -LINK_INTO = LIBJVM -else -#LINK_INTO = LIBJVM -endif - -# Also, strip debug and line number information (worth about 1.7Mb). -# If we can create .debuginfo files, then the VM is stripped in vm.make -# and this macro is not used. -STRIP_LIB.CXX/POST_HOOK = $(STRIP) -x $@ || exit 1; -# STRIP_LIB.CXX/POST_HOOK is incorporated into LINK_LIB.CXX/POST_HOOK -# in certain configurations, such as product.make. Other configurations, -# such as debug.make, do not include the strip operation. diff --git a/hotspot/make/solaris/makefiles/sparcv9.make b/hotspot/make/solaris/makefiles/sparcv9.make deleted file mode 100644 index ae2fad447f9..00000000000 --- a/hotspot/make/solaris/makefiles/sparcv9.make +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -ASFLAGS += $(AS_ARCHFLAG) - -ifeq ("${Platform_compiler}", "sparcWorks") -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \< 505), 1) -# When optimized fully, stubGenerator_sparc.cpp -# has bogus code for the routine -# StubGenerator::generate_flush_callers_register_windows() -OPT_CFLAGS/stubGenerator_sparc.o = $(OPT_CFLAGS/SLOWER) - -# For now ad_sparc file is compiled with -O2 %%%% remove when adlc is fixed -OPT_CFLAGS/ad_sparc.o = $(OPT_CFLAGS/SLOWER) -OPT_CFLAGS/dfa_sparc.o = $(OPT_CFLAGS/SLOWER) - -# CC brings an US-II to its knees compiling the vmStructs asserts under -xO4 -OPT_CFLAGS/vmStructs.o = $(OPT_CFLAGS/O2) -endif - -else -#Options for gcc -OPT_CFLAGS/stubGenerator_sparc.o = $(OPT_CFLAGS/SLOWER) -OPT_CFLAGS/ad_sparc.o = $(OPT_CFLAGS/SLOWER) -OPT_CFLAGS/dfa_sparc.o = $(OPT_CFLAGS/SLOWER) -OPT_CFLAGS/vmStructs.o = $(OPT_CFLAGS/O2) -endif diff --git a/hotspot/make/solaris/makefiles/tiered.make b/hotspot/make/solaris/makefiles/tiered.make deleted file mode 100644 index da79ade9fdc..00000000000 --- a/hotspot/make/solaris/makefiles/tiered.make +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright (c) 2006, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Sets make macros for making tiered version of VM - -TYPE=TIERED - -VM_SUBDIR = server - -CFLAGS += -DCOMPILER2 -DCOMPILER1 diff --git a/hotspot/make/solaris/makefiles/top.make b/hotspot/make/solaris/makefiles/top.make deleted file mode 100644 index 0786477af79..00000000000 --- a/hotspot/make/solaris/makefiles/top.make +++ /dev/null @@ -1,141 +0,0 @@ -# -# Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# top.make is included in the Makefile in the build directories. -# It DOES NOT include the vm dependency info in order to be faster. -# Its main job is to implement the incremental form of make lists. -# It also: -# -builds and runs adlc via adlc.make -# -generates JVMTI source and docs via jvmti.make (JSR-163) - -# It assumes the following flags are set: -# CFLAGS Platform_file, Src_Dirs_I, Src_Dirs_V, SYSDEFS, AOUT, Jvm_Obj_Files - -# -- D. Ungar (5/97) from a file by Bill Bush - -# Don't override the built-in $(MAKE). -# Instead, use "gmake" (or "gnumake") from the command line. --Rose -#MAKE = gmake - -include $(GAMMADIR)/make/altsrc.make - -GENERATED = ../generated -VM = $(GAMMADIR)/src/share/vm -Plat_File = $(Platform_file) -CDG = cd $(GENERATED); - -Cached_plat = $(GENERATED)/platform.current - -AD_Dir = $(GENERATED)/adfiles -ADLC = $(AD_Dir)/adlc -AD_Spec = $(call altsrc-replace,$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad) -AD_Src = $(call altsrc-replace,$(HS_COMMON_SRC)/share/vm/adlc) -AD_Names = ad_$(Platform_arch_model).hpp ad_$(Platform_arch_model).cpp -AD_Files = $(AD_Names:%=$(AD_Dir)/%) - -# AD_Files_If_Required/COMPILER1 = ad_stuff -AD_Files_If_Required/COMPILER2 = ad_stuff -AD_Files_If_Required/TIERED = ad_stuff -AD_Files_If_Required = $(AD_Files_If_Required/$(TYPE)) - -# Wierd argument adjustment for "gnumake -j..." -adjust-mflags = $(GENERATED)/adjust-mflags -# If SPEC is set, it's from configure and it's already controlling concurrency -# for us. Skip setting -j with HOTSPOT_BUILD_JOBS. -ifeq ($(SPEC), ) - MFLAGS-adjusted = -r `$(adjust-mflags) "$(MFLAGS)" "$(HOTSPOT_BUILD_JOBS)"` -else - MFLAGS-adjusted = -r $(MFLAGS) -endif - - -# default target: update lists, make vm -# done in stages to force sequential order with parallel make -# - -default: vm_build_preliminaries the_vm - @echo All done. - -# This is an explicit dependency for the sake of parallel makes. -vm_build_preliminaries: checks $(Cached_plat) $(AD_Files_If_Required) jvmti_stuff trace_stuff dtrace_stuff - @# We need a null action here, so implicit rules don't get consulted. - -$(Cached_plat): $(Plat_File) - $(CDG) $(CP) $(Plat_File) $(Cached_plat) - -# make AD files as necessary -ad_stuff: $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f adlc.make $(MFLAGS-adjusted) - -# generate JVMTI files from the spec -jvmti_stuff: $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f jvmti.make $(MFLAGS-adjusted) - -# generate trace files -trace_stuff: jvmti_stuff $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f trace.make $(MFLAGS-adjusted) - -dtrace_stuff: $(Cached_plat) $(adjust-mflags) - @$(MAKE) -f dtrace.make dtrace_gen_headers $(MFLAGS-adjusted) GENERATED=$(GENERATED) - -# and the VM: must use other makefile with dependencies included - -# We have to go to great lengths to get control over the -jN argument -# to the recursive invocation of vm.make. The problem is that gnumake -# resets -jN to -j1 for recursive runs. (How helpful.) -# Note that the user must specify the desired parallelism level via a -# command-line or environment variable name HOTSPOT_BUILD_JOBS. -$(adjust-mflags): $(GAMMADIR)/make/$(Platform_os_family)/makefiles/adjust-mflags.sh - @+rm -f $@ $@+ - @+cat $< > $@+ - @+chmod +x $@+ - @+mv $@+ $@ - -the_vm: vm_build_preliminaries $(adjust-mflags) - @$(MAKE) -f vm.make $(MFLAGS-adjusted) - -install: the_vm - @$(MAKE) -f vm.make $@ - -# next rules support "make foo.[oi]" - -%.o %.i %.s: - $(MAKE) -f vm.make $(MFLAGS) $@ - #$(MAKE) -f vm.make $@ - -# this should force everything to be rebuilt -clean: - rm -f $(GENERATED)/*.class - $(MAKE) -f vm.make $(MFLAGS) clean - -# just in case it doesn't, this should do it -realclean: - $(MAKE) -f vm.make $(MFLAGS) clean - rm -fr $(GENERATED) - -.PHONY: default vm_build_preliminaries -.PHONY: lists ad_stuff jvmti_stuff trace_stuff the_vm clean realclean -.PHONY: checks check_os_version install - -.NOTPARALLEL: diff --git a/hotspot/make/solaris/makefiles/trace.make b/hotspot/make/solaris/makefiles/trace.make deleted file mode 100644 index effe34061ce..00000000000 --- a/hotspot/make/solaris/makefiles/trace.make +++ /dev/null @@ -1,119 +0,0 @@ -# -# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (trace.make) is included from the trace.make in the -# build directories. -# -# It knows how to build and run the tools to generate trace files. - -include $(GAMMADIR)/make/solaris/makefiles/rules.make -include $(GAMMADIR)/make/altsrc.make - -# ######################################################################### - -HAS_ALT_SRC := false -ifndef OPENJDK - ifneq ($(wildcard $(HS_ALT_SRC)/share/vm/trace), ) - HAS_ALT_SRC := true - endif -endif - -TOPDIR = $(shell echo `pwd`) -GENERATED = $(TOPDIR)/../generated -JvmtiOutDir = $(GENERATED)/jvmtifiles -TraceOutDir = $(GENERATED)/tracefiles - -TraceAltSrcDir = $(HS_ALT_SRC)/share/vm/trace -TraceSrcDir = $(HS_COMMON_SRC)/share/vm/trace - -# set VPATH so make knows where to look for source files -Src_Dirs_V += $(TraceSrcDir) $(TraceAltSrcDir) -VPATH += $(Src_Dirs_V:%=%:) - -TraceGeneratedNames = \ - traceEventClasses.hpp \ - traceEventIds.hpp \ - traceTypes.hpp - -ifeq ($(HAS_ALT_SRC), true) -TraceGeneratedNames += \ - traceRequestables.hpp \ - traceEventControl.hpp -endif - -TraceGeneratedFiles = $(TraceGeneratedNames:%=$(TraceOutDir)/%) - -XSLT = $(REMOTE) $(RUN.JAVA) -classpath $(JvmtiOutDir) jvmtiGen - -TraceXml = $(TraceSrcDir)/trace.xml -ifeq ($(HAS_ALT_SRC), true) - TraceXml = $(TraceAltSrcDir)/trace.xml -endif - -XML_DEPS = $(TraceXml) $(TraceSrcDir)/tracetypes.xml \ - $(TraceSrcDir)/trace.dtd $(TraceSrcDir)/xinclude.mod \ - $(TraceSrcDir)/tracerelationdecls.xml $(TraceSrcDir)/traceevents.xml -ifeq ($(HAS_ALT_SRC), true) - XML_DEPS += $(TraceAltSrcDir)/traceeventscustom.xml \ - $(TraceAltSrcDir)/traceeventtypes.xml -endif - -.PHONY: all clean cleanall - -# ######################################################################### - -all: $(TraceGeneratedFiles) - -GENERATE_CODE= \ - $(QUIETLY) echo $(LOG_INFO) Generating $@; \ - $(XSLT) -IN $(word 1,$^) -XSL $(word 2,$^) -OUT $@ - -$(TraceOutDir)/traceEventIds.hpp: $(TraceXml) $(TraceSrcDir)/traceEventIds.xsl $(XML_DEPS) - $(GENERATE_CODE) - -$(TraceOutDir)/traceTypes.hpp: $(TraceXml) $(TraceSrcDir)/traceTypes.xsl $(XML_DEPS) - $(GENERATE_CODE) - -ifeq ($(HAS_ALT_SRC), false) - -$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceSrcDir)/traceEventClasses.xsl $(XML_DEPS) - $(GENERATE_CODE) - -else - -$(TraceOutDir)/traceEventClasses.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventClasses.xsl $(XML_DEPS) - $(GENERATE_CODE) - -$(TraceOutDir)/traceRequestables.hpp: $(TraceXml) $(TraceAltSrcDir)/traceRequestables.xsl $(XML_DEPS) - $(GENERATE_CODE) - -$(TraceOutDir)/traceEventControl.hpp: $(TraceXml) $(TraceAltSrcDir)/traceEventControl.xsl $(XML_DEPS) - $(GENERATE_CODE) - -endif - -# ######################################################################### - -clean cleanall: - rm $(TraceGeneratedFiles) diff --git a/hotspot/make/solaris/makefiles/vm.make b/hotspot/make/solaris/makefiles/vm.make deleted file mode 100644 index 270a8ceeda1..00000000000 --- a/hotspot/make/solaris/makefiles/vm.make +++ /dev/null @@ -1,352 +0,0 @@ -# -# Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Rules to build JVM and related libraries, included from vm.make in the build -# directory. - -# Common build rules. -MAKEFILES_DIR=$(GAMMADIR)/make/$(Platform_os_family)/makefiles -include $(MAKEFILES_DIR)/rules.make -include $(GAMMADIR)/make/altsrc.make - -default: build - -#---------------------------------------------------------------------- -# Defs - -GENERATED = ../generated -DEP_DIR = $(GENERATED)/dependencies - -# reads the generated files defining the set of .o's and the .o .h dependencies --include $(DEP_DIR)/*.d - -# read machine-specific adjustments (%%% should do this via buildtree.make?) -include $(MAKEFILES_DIR)/$(BUILDARCH).make - -# set VPATH so make knows where to look for source files -# Src_Dirs_V is everything in src/share/vm/*, plus the right os/*/vm and cpu/*/vm -# The adfiles directory contains ad_.[ch]pp. -# The jvmtifiles directory contains jvmti*.[ch]pp -Src_Dirs_V += $(GENERATED)/adfiles $(GENERATED)/jvmtifiles $(GENERATED)/tracefiles -VPATH += $(Src_Dirs_V:%=%:) - -# set INCLUDES for C preprocessor -Src_Dirs_I += $(GENERATED) -INCLUDES += $(Src_Dirs_I:%=-I%) - -# SYMFLAG is used by {dtrace,jsig}.make. -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - # always build with debug info when we can create .debuginfo files - # and disable 'lazy debug info' so the .so has everything. - SYMFLAG = -g -xs -else - ifeq (${VERSION}, debug) - SYMFLAG = -g - else - SYMFLAG = - endif -endif - -# The following variables are defined in the generated flags.make file. -JDK_VER_DEFS = -DVERSION_MAJOR=$(VERSION_MAJOR) \ - -DVERSION_MINOR=$(VERSION_MINOR) \ - -DVERSION_SECURITY=$(VERSION_SECURITY) \ - -DVERSION_PATCH=$(VERSION_PATCH) \ - -DVERSION_BUILD=$(VERSION_BUILD) -VM_VER_DEFS = -DHOTSPOT_VERSION_STRING="\"$(HOTSPOT_VERSION_STRING)\"" \ - -DVERSION_STRING="\"$(VERSION_STRING)\"" \ - -DDEBUG_LEVEL="\"$(DEBUG_LEVEL)\"" \ - $(JDK_VER_DEFS) -HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\" -BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\"" -VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\"" - -CXXFLAGS = \ - ${SYSDEFS} \ - ${INCLUDES} \ - ${BUILD_USER} \ - ${HS_LIB_ARCH} \ - ${VM_DISTRO} - -# This is VERY important! The version define must only be supplied to vm_version.o -# If not, ccache will not re-use the cache at all, since the version string might contain -# a time and date. -CXXFLAGS/vm_version.o += ${VM_VER_DEFS} - -CXXFLAGS/BYFILE = $(CXXFLAGS/$@) - -# File specific flags -CXXFLAGS += $(CXXFLAGS/BYFILE) - -# Large File Support -ifneq ($(LP64), 1) -CXXFLAGS/ostream.o += -D_FILE_OFFSET_BITS=64 -endif # ifneq ($(LP64), 1) - -# CFLAGS_WARN holds compiler options to suppress/enable warnings. -CFLAGS += $(CFLAGS_WARN) - -# Do not use C++ exception handling -CFLAGS += $(CFLAGS/NOEX) - -# Extra flags from gnumake's invocation or environment -CFLAGS += $(EXTRA_CFLAGS) - -# Math Library (libm.so), do not use -lm. -# There might be two versions of libm.so on the build system: -# libm.so.1 and libm.so.2, and we want libm.so.1. -# Depending on the Solaris release being used to build with, -# /usr/lib/libm.so could point at a libm.so.2, so we are -# explicit here so that the libjvm.so you have built will work on an -# older Solaris release that might not have libm.so.2. -# This is a critical factor in allowing builds on Solaris 10 or newer -# to run on Solaris 8 or 9. -# -LIBM=/usr/lib$(ISA_DIR)/libm.so.1 - -ifeq ("${Platform_compiler}", "sparcWorks") -# The whole megilla: -ifeq ($(shell expr $(COMPILER_REV_NUMERIC) \>= 505), 1) -# Old Comment: List the libraries in the order the compiler was designed for -# Not sure what the 'designed for' comment is referring too above. -# The order may not be too significant anymore, but I have placed this -# older libm before libCrun, just to make sure it's found and used first. -LIBS += -lsocket -lsched -ldl $(LIBM) -lCrun -lthread -ldoor -lc -ldemangle -lnsl -else -ifeq ($(COMPILER_REV_NUMERIC), 502) -# SC6.1 has it's own libm.so: specifying anything else provokes a name conflict. -LIBS += -ldl -lthread -lsocket -lm -lsched -ldoor -ldemangle -else -LIBS += -ldl -lthread -lsocket $(LIBM) -lsched -ldoor -ldemangle -endif # 502 -endif # 505 -else -LIBS += -lsocket -lsched -ldl $(LIBM) -lthread -lc -ldemangle -endif # sparcWorks - -LIBS += -lkstat -lrt - -# By default, link the *.o into the library, not the executable. -LINK_INTO$(LINK_INTO) = LIBJVM - -JDK_LIBDIR = $(JAVA_HOME)/lib/$(LIBARCH) - -#---------------------------------------------------------------------- -# jvm_db & dtrace -include $(MAKEFILES_DIR)/dtrace.make - -#---------------------------------------------------------------------- -# JVM - -JVM = jvm -LIBJVM = lib$(JVM).so - -LIBJVM_DEBUGINFO = lib$(JVM).debuginfo -LIBJVM_DIZ = lib$(JVM).diz - -SPECIAL_PATHS:=adlc c1 dist gc opto shark libadt - -SOURCE_PATHS=\ - $(shell find $(HS_COMMON_SRC)/share/vm/* -type d \! \ - \( -name DUMMY $(foreach dir,$(SPECIAL_PATHS),-o -name $(dir)) \)) -SOURCE_PATHS+=$(HS_COMMON_SRC)/os/$(Platform_os_family)/vm -SOURCE_PATHS+=$(HS_COMMON_SRC)/os/posix/vm -SOURCE_PATHS+=$(HS_COMMON_SRC)/cpu/$(Platform_arch)/vm -SOURCE_PATHS+=$(HS_COMMON_SRC)/os_cpu/$(Platform_os_arch)/vm - -CORE_PATHS=$(foreach path,$(SOURCE_PATHS),$(call altsrc,$(path)) $(path)) -CORE_PATHS+=$(GENERATED)/jvmtifiles $(GENERATED)/tracefiles - -ifneq ($(INCLUDE_TRACE), false) -CORE_PATHS+=$(shell if [ -d $(HS_ALT_SRC)/share/vm/jfr ]; then \ - find $(HS_ALT_SRC)/share/vm/jfr -type d; \ - fi) -endif - -COMPILER1_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/c1) -COMPILER1_PATHS += $(HS_COMMON_SRC)/share/vm/c1 - -COMPILER2_PATHS := $(call altsrc,$(HS_COMMON_SRC)/share/vm/opto) -COMPILER2_PATHS += $(call altsrc,$(HS_COMMON_SRC)/share/vm/libadt) -COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/opto -COMPILER2_PATHS += $(HS_COMMON_SRC)/share/vm/libadt -COMPILER2_PATHS += $(GENERATED)/adfiles - -# Include dirs per type. -Src_Dirs/CORE := $(CORE_PATHS) -Src_Dirs/COMPILER1 := $(CORE_PATHS) $(COMPILER1_PATHS) -Src_Dirs/COMPILER2 := $(CORE_PATHS) $(COMPILER2_PATHS) -Src_Dirs/TIERED := $(CORE_PATHS) $(COMPILER1_PATHS) $(COMPILER2_PATHS) -Src_Dirs/ZERO := $(CORE_PATHS) -Src_Dirs/SHARK := $(CORE_PATHS) $(SHARK_PATHS) -Src_Dirs := $(Src_Dirs/$(TYPE)) - -COMPILER2_SPECIFIC_FILES := opto libadt bcEscapeAnalyzer.cpp c2_\* runtime_\* -COMPILER1_SPECIFIC_FILES := c1_\* -SHARK_SPECIFIC_FILES := shark -ZERO_SPECIFIC_FILES := zero - -# Always exclude these. -Src_Files_EXCLUDE += dtrace jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp - -# Exclude per type. -Src_Files_EXCLUDE/CORE := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER1 := $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/COMPILER2 := $(COMPILER1_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) -Src_Files_EXCLUDE/TIERED := $(ZERO_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) -Src_Files_EXCLUDE/ZERO := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(SHARK_SPECIFIC_FILES) ciTypeFlow.cpp -Src_Files_EXCLUDE/SHARK := $(COMPILER1_SPECIFIC_FILES) $(COMPILER2_SPECIFIC_FILES) $(ZERO_SPECIFIC_FILES) - -Src_Files_EXCLUDE += $(Src_Files_EXCLUDE/$(TYPE)) - -# Special handling of arch model. -ifeq ($(Platform_arch_model), x86_32) -Src_Files_EXCLUDE += \*x86_64\* -endif -ifeq ($(Platform_arch_model), x86_64) -Src_Files_EXCLUDE += \*x86_32\* -endif - -# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE. -define findsrc - $(notdir $(shell find $(1)/. ! -name . -prune \ - -a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \ - -a ! \( -name DUMMY $(addprefix -o -name ,$(Src_Files_EXCLUDE)) \))) -endef - -Src_Files := $(foreach e,$(Src_Dirs),$(call findsrc,$(e))) - -Obj_Files = $(sort $(addsuffix .o,$(basename $(Src_Files)))) - -JVM_OBJ_FILES = $(Obj_Files) $(DTRACE_OBJS) - -vm_version.o: $(filter-out vm_version.o,$(JVM_OBJ_FILES)) - -MAPFILE_SHARE := $(GAMMADIR)/make/share/makefiles/mapfile-vers - -MAPFILE_EXT_SRC := $(HS_ALT_MAKE)/share/makefiles/mapfile-ext -ifneq ("$(wildcard $(MAPFILE_EXT_SRC))","") -MAPFILE_EXT := $(MAPFILE_EXT_SRC) -endif - -mapfile : $(MAPFILE) $(MAPFILE_SHARE) vm.def $(MAPFILE_EXT) - rm -f $@ - cat $(MAPFILE) $(MAPFILE_DTRACE_OPT) \ - | $(NAWK) '{ \ - if ($$0 ~ "INSERT VTABLE SYMBOLS HERE") { \ - system ("cat ${MAPFILE_SHARE} $(MAPFILE_EXT) vm.def"); \ - } else { \ - print $$0; \ - } \ - }' > $@ - -mapfile_extended : mapfile $(MAPFILE_DTRACE_OPT) - rm -f $@ - cat $^ > $@ - -vm.def: $(Obj_Files) - sh $(GAMMADIR)/make/solaris/makefiles/build_vm_def.sh *.o > $@ - - -ifeq ($(LINK_INTO),AOUT) - LIBJVM.o = - LIBJVM_MAPFILE = - LIBS_VM = $(LIBS) -else - LIBJVM.o = $(JVM_OBJ_FILES) - LIBJVM_MAPFILE$(LDNOMAP) = mapfile_extended - LFLAGS_VM$(LDNOMAP) += $(MAPFLAG:FILENAME=$(LIBJVM_MAPFILE)) - LFLAGS_VM += $(SONAMEFLAG:SONAME=$(LIBJVM)) - LFLAGS_VM += -Wl,-z,defs -ifndef USE_GCC - LIBS_VM = $(LIBS) -else - # JVM is statically linked with libgcc[_s] and libstdc++; this is needed to - # get around library dependency and compatibility issues. Must use gcc not - # g++ to link. - LFLAGS_VM += $(STATIC_LIBGCC) - LIBS_VM += $(STATIC_STDCXX) $(LIBS) -endif -endif - -LFLAGS_VM += $(EXTRA_LDFLAGS) - -ifdef USE_GCC -LINK_VM = $(LINK_LIB.CC) -else -LINK_VM = $(LINK_LIB.CXX) -endif -# making the library: -$(LIBJVM): $(LIBJVM.o) $(LIBJVM_MAPFILE) -ifeq ($(filter -sbfast -xsbfast, $(CFLAGS_BROWSE)),) - @echo $(LOG_INFO) Linking vm... - $(QUIETLY) $(LINK_LIB.CXX/PRE_HOOK) - $(QUIETLY) $(LINK_VM) $(LFLAGS_VM) -o $@ $(sort $(LIBJVM.o)) $(LIBS_VM) - $(QUIETLY) $(LINK_LIB.CXX/POST_HOOK) - $(QUIETLY) rm -f $@.1 && ln -s $@ $@.1 -ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - $(QUIETLY) $(OBJCOPY) --only-keep-debug $@ $(LIBJVM_DEBUGINFO) - $(QUIETLY) $(OBJCOPY) --add-gnu-debuglink=$(LIBJVM_DEBUGINFO) $@ - ifeq ($(STRIP_POLICY),all_strip) - $(QUIETLY) $(STRIP) $@ - else - ifeq ($(STRIP_POLICY),min_strip) - $(QUIETLY) $(STRIP) -x $@ - # implied else here is no stripping at all - endif - endif - ifeq ($(ZIP_DEBUGINFO_FILES),1) - $(ZIPEXE) -q -y $(LIBJVM_DIZ) $(LIBJVM_DEBUGINFO) - $(RM) $(LIBJVM_DEBUGINFO) - endif -endif -endif # filter -sbfast -xsbfast - - -DEST_SUBDIR = $(JDK_LIBDIR)/$(VM_SUBDIR) -DEST_JVM = $(DEST_SUBDIR)/$(LIBJVM) -DEST_JVM_DEBUGINFO = $(DEST_SUBDIR)/$(LIBJVM_DEBUGINFO) -DEST_JVM_DIZ = $(DEST_SUBDIR)/$(LIBJVM_DIZ) - -install_jvm: $(LIBJVM) - @echo "Copying $(LIBJVM) to $(DEST_JVM)" - $(QUIETLY) test ! -f $(LIBJVM_DEBUGINFO) || \ - $(CP) -f $(LIBJVM_DEBUGINFO) $(DEST_JVM_DEBUGINFO) - $(QUIETLY) test ! -f $(LIBJVM_DIZ) || \ - $(CP) -f $(LIBJVM_DIZ) $(DEST_JVM_DIZ) - $(QUIETLY) $(CP) -f $(LIBJVM) $(DEST_JVM) && echo "Done" - -#---------------------------------------------------------------------- -# Other files - -# Signal interposition library -include $(MAKEFILES_DIR)/jsig.make - -#---------------------------------------------------------------------- - -build: $(LIBJVM) $(LAUNCHER) $(LIBJSIG) $(LIBJVM_DB) $(LIBJVM_DTRACE) dtraceCheck - -install: install_jvm install_jsig - -.PHONY: default build install install_jvm diff --git a/hotspot/make/solaris/platform_amd64 b/hotspot/make/solaris/platform_amd64 deleted file mode 100644 index f85242b1d30..00000000000 --- a/hotspot/make/solaris/platform_amd64 +++ /dev/null @@ -1,15 +0,0 @@ -os_family = solaris - -arch = x86 - -arch_model = x86_64 - -os_arch = solaris_x86 - -os_arch_model = solaris_x86_64 - -lib_arch = amd64 - -compiler = sparcWorks - -sysdefs = -DSOLARIS -DSPARC_WORKS -DAMD64 diff --git a/hotspot/make/solaris/platform_amd64.gcc b/hotspot/make/solaris/platform_amd64.gcc deleted file mode 100644 index ebd495bca40..00000000000 --- a/hotspot/make/solaris/platform_amd64.gcc +++ /dev/null @@ -1,15 +0,0 @@ -os_family = solaris - -arch = x86 - -arch_model = x86_64 - -os_arch = solaris_x86 - -os_arch_model = solaris_x86_64 - -lib_arch = amd64 - -compiler = gcc - -sysdefs = -DSOLARIS -D_GNU_SOURCE -DAMD64 diff --git a/hotspot/make/solaris/platform_i486 b/hotspot/make/solaris/platform_i486 deleted file mode 100644 index 91d4c5e7a64..00000000000 --- a/hotspot/make/solaris/platform_i486 +++ /dev/null @@ -1,15 +0,0 @@ -os_family = solaris - -arch = x86 - -arch_model = x86_32 - -os_arch = solaris_x86 - -os_arch_model = solaris_x86_32 - -lib_arch = i386 - -compiler = sparcWorks - -sysdefs = -DSOLARIS -DSPARC_WORKS -DIA32 diff --git a/hotspot/make/solaris/platform_i486.gcc b/hotspot/make/solaris/platform_i486.gcc deleted file mode 100644 index 61d55e1b59e..00000000000 --- a/hotspot/make/solaris/platform_i486.gcc +++ /dev/null @@ -1,15 +0,0 @@ -os_family = solaris - -arch = x86 - -arch_model = x86_32 - -os_arch = solaris_x86 - -os_arch_model = solaris_x86_32 - -lib_arch = i386 - -compiler = gcc - -sysdefs = -DSOLARIS -D_GNU_SOURCE -DIA32 diff --git a/hotspot/make/solaris/platform_sparc b/hotspot/make/solaris/platform_sparc deleted file mode 100644 index 424088ef53f..00000000000 --- a/hotspot/make/solaris/platform_sparc +++ /dev/null @@ -1,15 +0,0 @@ -os_family = solaris - -arch = sparc - -arch_model = sparc - -os_arch = solaris_sparc - -os_arch_model = solaris_sparc - -lib_arch = sparc - -compiler = sparcWorks - -sysdefs = -DSOLARIS -DSPARC_WORKS -DSPARC diff --git a/hotspot/make/solaris/platform_sparc.gcc b/hotspot/make/solaris/platform_sparc.gcc deleted file mode 100644 index 9a900f49384..00000000000 --- a/hotspot/make/solaris/platform_sparc.gcc +++ /dev/null @@ -1,15 +0,0 @@ -os_family = solaris - -arch = sparc - -arch_model = sparc - -os_arch = solaris_sparc - -os_arch_model = solaris_sparc - -lib_arch = sparc - -compiler = gcc - -sysdefs = -DSOLARIS -D_GNU_SOURCE -DSPARC diff --git a/hotspot/make/solaris/platform_sparcv9 b/hotspot/make/solaris/platform_sparcv9 deleted file mode 100644 index a17dd08d29d..00000000000 --- a/hotspot/make/solaris/platform_sparcv9 +++ /dev/null @@ -1,15 +0,0 @@ -os_family = solaris - -arch = sparc - -arch_model = sparc - -os_arch = solaris_sparc - -os_arch_model = solaris_sparc - -lib_arch = sparcv9 - -compiler = sparcWorks - -sysdefs = -DSOLARIS -DSPARC_WORKS -DSPARC diff --git a/hotspot/make/solaris/platform_sparcv9.gcc b/hotspot/make/solaris/platform_sparcv9.gcc deleted file mode 100644 index 2824381774b..00000000000 --- a/hotspot/make/solaris/platform_sparcv9.gcc +++ /dev/null @@ -1,15 +0,0 @@ -os_family = solaris - -arch = sparc - -arch_model = sparc - -os_arch = solaris_sparc - -os_arch_model = solaris_sparc - -lib_arch = sparcv9 - -compiler = gcc - -sysdefs = -DSOLARIS -D_GNU_SOURCE -DSPARC diff --git a/hotspot/makefiles/symbols/symbols-aix b/hotspot/make/symbols/symbols-aix similarity index 100% rename from hotspot/makefiles/symbols/symbols-aix rename to hotspot/make/symbols/symbols-aix diff --git a/hotspot/makefiles/symbols/symbols-aix-debug b/hotspot/make/symbols/symbols-aix-debug similarity index 100% rename from hotspot/makefiles/symbols/symbols-aix-debug rename to hotspot/make/symbols/symbols-aix-debug diff --git a/hotspot/makefiles/symbols/symbols-linux b/hotspot/make/symbols/symbols-linux similarity index 100% rename from hotspot/makefiles/symbols/symbols-linux rename to hotspot/make/symbols/symbols-linux diff --git a/hotspot/makefiles/symbols/symbols-macosx b/hotspot/make/symbols/symbols-macosx similarity index 100% rename from hotspot/makefiles/symbols/symbols-macosx rename to hotspot/make/symbols/symbols-macosx diff --git a/hotspot/makefiles/symbols/symbols-shared b/hotspot/make/symbols/symbols-shared similarity index 100% rename from hotspot/makefiles/symbols/symbols-shared rename to hotspot/make/symbols/symbols-shared diff --git a/hotspot/makefiles/symbols/symbols-solaris b/hotspot/make/symbols/symbols-solaris similarity index 100% rename from hotspot/makefiles/symbols/symbols-solaris rename to hotspot/make/symbols/symbols-solaris diff --git a/hotspot/makefiles/symbols/symbols-solaris-dtrace-compiler1 b/hotspot/make/symbols/symbols-solaris-dtrace-compiler1 similarity index 100% rename from hotspot/makefiles/symbols/symbols-solaris-dtrace-compiler1 rename to hotspot/make/symbols/symbols-solaris-dtrace-compiler1 diff --git a/hotspot/makefiles/symbols/symbols-solaris-dtrace-compiler2 b/hotspot/make/symbols/symbols-solaris-dtrace-compiler2 similarity index 100% rename from hotspot/makefiles/symbols/symbols-solaris-dtrace-compiler2 rename to hotspot/make/symbols/symbols-solaris-dtrace-compiler2 diff --git a/hotspot/makefiles/symbols/symbols-unix b/hotspot/make/symbols/symbols-unix similarity index 100% rename from hotspot/makefiles/symbols/symbols-unix rename to hotspot/make/symbols/symbols-unix diff --git a/hotspot/make/windows/build.bat b/hotspot/make/windows/build.bat deleted file mode 100644 index d81bb6dbd99..00000000000 --- a/hotspot/make/windows/build.bat +++ /dev/null @@ -1,85 +0,0 @@ -@echo off -REM -REM Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. -REM DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -REM -REM This code is free software; you can redistribute it and/or modify it -REM under the terms of the GNU General Public License version 2 only, as -REM published by the Free Software Foundation. -REM -REM This code is distributed in the hope that it will be useful, but WITHOUT -REM ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -REM FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -REM version 2 for more details (a copy is included in the LICENSE file that -REM accompanied this code). -REM -REM You should have received a copy of the GNU General Public License version -REM 2 along with this work; if not, write to the Free Software Foundation, -REM Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -REM -REM Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -REM or visit www.oracle.com if you need additional information or have any -REM questions. -REM -REM - -REM Set HotSpotWorkSpace to the directory two steps above this script -for %%i in ("%~dp0..") do ( set HotSpotWorkSpace=%%~dpi) - -REM -REM Since we don't have uname and we could be cross-compiling, -REM Use the compiler to determine which ARCH we are building -REM -cl 2>&1 1>&3 | findstr x64>NUL -if %errorlevel% == 0 goto amd64 -set VCPROJ=%HotSpotWorkSpace%\build\vs-i486\jvm.vcxproj -set PLATFORM=x86 -goto testmkshome -:amd64 -set VCPROJ=%HotSpotWorkSpace%\build\vs-amd64\jvm.vcxproj -set PLATFORM=x64 -goto testmkshome - -:testmkshome -if not "%HOTSPOTMKSHOME%" == "" goto testjavahome -if exist c:\cygwin\bin set HOTSPOTMKSHOME=c:\cygwin\bin -if not "%HOTSPOTMKSHOME%" == "" goto testjavahome -if exist c:\cygwin64\bin set HOTSPOTMKSHOME=c:\cygwin64\bin -if not "%HOTSPOTMKSHOME%" == "" goto testjavahome -echo Error: please set variable HOTSPOTMKSHOME to place where -echo your MKS/Cygwin installation is -echo. -goto end - -:testjavahome -if not "%JAVA_HOME%" == "" goto testbuildversion -echo Error: please set variable JAVA_HOME to a bootstrap JDK -echo. -goto end - -:testbuildversion -if "%1" == "compiler1" goto testdebuglevel -if "%1" == "tiered" goto testdebuglevel -goto usage - -:testdebuglevel -if "%2" == "product" goto build -if "%2" == "debug" goto build -if "%2" == "fastdebug" goto build -goto usage - -:build -if NOT EXIST %VCPROJ% call %~dp0\create.bat %JAVA_HOME% -msbuild /Property:Platform=%PLATFORM% /Property:Configuration=%1_%2 /v:m %VCPROJ% -goto end - -:usage -echo Usage: build version debuglevel -echo. -echo where: -echo version is "compiler1" or "tiered", -echo debuglevel is "product", "debug" or "fastdebug" -exit /b 1 - -:end -exit /b %errorlevel% diff --git a/hotspot/make/windows/build.make b/hotspot/make/windows/build.make deleted file mode 100644 index 603f15c0c0b..00000000000 --- a/hotspot/make/windows/build.make +++ /dev/null @@ -1,253 +0,0 @@ -# -# Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Note: this makefile is invoked both from build.bat and from the J2SE -# control workspace in exactly the same manner; the required -# environment variables (Variant, WorkSpace, BootStrapDir, BuildUser, HOTSPOT_BUILD_VERSION) -# are passed in as command line arguments. - -# Note: Running nmake or build.bat from the Windows command shell requires -# that "sh" be accessible on the PATH. An MKS install does this. - -# If we haven't set an ARCH yet use x86 -# create.bat and build.bat will set it, if used. -!ifndef ARCH -ARCH=x86 -!endif - - -# Must be one of these values (if value comes in from env, can't trust it) -!if "$(ARCH)" != "x86" -!if "$(ARCH)" != "ia64" -ARCH=x86 -!endif -!endif - -# At this point we should be certain that ARCH has a definition -# now determine the BUILDARCH -# - -# the default BUILDARCH -BUILDARCH=i486 - -# Allow control workspace to force Itanium or AMD64 builds with LP64 -ARCH_TEXT= -!ifdef LP64 -!if "$(LP64)" == "1" -ARCH_TEXT=64-Bit -!if "$(ARCH)" == "x86" -BUILDARCH=amd64 -!else -BUILDARCH=ia64 -!endif -!endif -!endif - -!if "$(BUILDARCH)" != "ia64" -!ifndef CC_INTERP -!ifndef FORCE_TIERED -FORCE_TIERED=1 -!endif -!endif -!endif - -!if "$(BUILDARCH)" == "amd64" -Platform_arch=x86 -Platform_arch_model=x86_64 -!endif -!if "$(BUILDARCH)" == "i486" -Platform_arch=x86 -Platform_arch_model=x86_32 -!endif - -# Supply these from the command line or the environment -# It doesn't make sense to default this one -Variant= -# It doesn't make sense to default this one -WorkSpace= - -variantDir = windows_$(BUILDARCH)_$(Variant) - -realVariant=$(Variant) -VARIANT_TEXT=Core -!if "$(Variant)" == "compiler1" -VARIANT_TEXT=Client -!elseif "$(Variant)" == "compiler2" -!if "$(FORCE_TIERED)" == "1" -VARIANT_TEXT=Server -realVariant=tiered -!else -VARIANT_TEXT=Server -!endif -!elseif "$(Variant)" == "tiered" -VARIANT_TEXT=Tiered -!endif - -######################################################################### -# Parameters for VERSIONINFO resource for jvm.dll. -# These can be overridden via the nmake.exe command line. -# They are overridden by RE during the control builds. -# -!include "$(WorkSpace)/make/jdk_version" - -# Define HOTSPOT_VM_DISTRO based on settings in make/openjdk_distro -# or make/hotspot_distro. -!ifndef HOTSPOT_VM_DISTRO -!ifndef OPENJDK -!if exists($(WorkSpace)\src\closed) -!include $(WorkSpace)\make\hotspot_distro -!else -!include $(WorkSpace)\make\openjdk_distro -!endif -!else -!include $(WorkSpace)\make\openjdk_distro -!endif -!endif - -HS_FILEDESC=$(HOTSPOT_VM_DISTRO) $(ARCH_TEXT) $(VARIANT_TEXT) VM - -# JDK ProductVersion: -# 1.5.0_-b will have DLL version 5.0.wx*10.yz -# Thus, 1.5.0_10-b04 will be 5.0.100.4 -# 1.6.0-b01 will be 6.0.0.1 -# 1.6.0_01a-b02 will be 6.0.11.2 -# -# STANDALONE_JDK_* variables are defined in make/jdk_version or on command line -# -!if "$(JDK_VER)" == "" -JDK_VER=$(STANDALONE_JDK_MAJOR_VER),$(STANDALONE_JDK_MINOR_VER),$(STANDALONE_JDK_SECURITY_VER),$(STANDALONE_JDK_PATCH_VER) -!endif -!if "$(JDK_DOTVER)" == "" -JDK_DOTVER=$(STANDALONE_JDK_MAJOR_VER).$(STANDALONE_JDK_MINOR_VER).$(STANDALONE_JDK_SECURITY_VER).$(STANDALONE_JDK_PATCH_VER) -!endif -!if "$(VERSION_SHORT)" == "" -VERSION_SHORT=$(STANDALONE_JDK_MAJOR_VER).$(STANDALONE_JDK_MINOR_VER).$(STANDALONE_JDK_SECURITY_VER) -!endif - -HS_VER=$(JDK_VER) -HS_DOTVER=$(JDK_DOTVER) - -!if "$(HOTSPOT_RELEASE_VERSION)" == "" -HOTSPOT_RELEASE_VERSION=$(VERSION_STRING) -!endif - -!if "$(HOTSPOT_VERSION_STRING)" == "" -HOTSPOT_VERSION_STRING=$(HOTSPOT_RELEASE_VERSION) -!endif - -# End VERSIONINFO parameters - -# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK -!ifndef OPENJDK -!if !exists($(WorkSpace)\src\closed) -OPENJDK=true -!endif -!endif - -######################################################################### - -defaultTarget: product - -# The product or release build is an optimized build, and is the default - -# note that since all the build targets depend on local.make that BUILDARCH -# and Platform_arch and Platform_arch_model will get set in local.make -# and there is no need to pass them thru here on the command line -# -product release optimized: checks $(variantDir) $(variantDir)\local.make sanity - cd $(variantDir) - nmake -nologo -f $(WorkSpace)\make\windows\makefiles\top.make BUILD_FLAVOR=product ARCH=$(ARCH) - -# The debug build is an optional build -debug: checks $(variantDir) $(variantDir)\local.make sanity - cd $(variantDir) - nmake -nologo -f $(WorkSpace)\make\windows\makefiles\top.make BUILD_FLAVOR=debug ARCH=$(ARCH) -fastdebug: checks $(variantDir) $(variantDir)\local.make sanity - cd $(variantDir) - nmake -nologo -f $(WorkSpace)\make\windows\makefiles\top.make BUILD_FLAVOR=fastdebug ARCH=$(ARCH) - -# target to create just the directory structure -tree: checks $(variantDir) $(variantDir)\local.make sanity - mkdir $(variantDir)\product - mkdir $(variantDir)\debug - mkdir $(variantDir)\fastdebug - -sanity: - @ echo; - @ cd $(variantDir) - @ nmake -nologo -f $(WorkSpace)\make\windows\makefiles\sanity.make - @ cd .. - @ echo; - -clean: checkVariant - - rm -r -f $(variantDir) - -$(variantDir): - mkdir $(variantDir) - -$(variantDir)\local.make: checks - @ echo # Generated file > $@ - @ echo Variant=$(realVariant) >> $@ - @ echo WorkSpace=$(WorkSpace) >> $@ - @ echo BootStrapDir=$(BootStrapDir) >> $@ - @ if "$(USERNAME)" NEQ "" echo BuildUser=$(USERNAME) >> $@ - @ echo HS_VER=$(HS_VER) >> $@ - @ echo HS_DOTVER=$(HS_DOTVER) >> $@ - @ echo HS_COMPANY=$(COMPANY_NAME) >> $@ - @ echo HS_FILEDESC=$(HS_FILEDESC) >> $@ - @ echo HOTSPOT_VM_DISTRO=$(HOTSPOT_VM_DISTRO) >> $@ - @ if "$(OPENJDK)" NEQ "" echo OPENJDK=$(OPENJDK) >> $@ - @ echo HS_COPYRIGHT=$(HOTSPOT_VM_COPYRIGHT) >> $@ - @ echo HS_NAME=$(PRODUCT_NAME) $(VERSION_SHORT) >> $@ - @ echo HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) >> $@ - @ echo JDK_VER=$(JDK_VER) >> $@ - @ echo JDK_DOTVER=$(JDK_DOTVER) >> $@ - @ echo VERSION_STRING=$(VERSION_STRING) >> $@ - @ echo BUILDARCH=$(BUILDARCH) >> $@ - @ echo Platform_arch=$(Platform_arch) >> $@ - @ echo Platform_arch_model=$(Platform_arch_model) >> $@ - @ echo CXX=$(CXX) >> $@ - @ echo LD=$(LD) >> $@ - @ echo MT=$(MT) >> $@ - @ echo RC=$(RC) >> $@ - @ sh $(WorkSpace)/make/windows/get_msc_ver.sh >> $@ - @ if "$(ENABLE_FULL_DEBUG_SYMBOLS)" NEQ "" echo ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) >> $@ - @ if "$(ZIP_DEBUGINFO_FILES)" NEQ "" echo ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) >> $@ - @ if "$(RM)" NEQ "" echo RM=$(RM) >> $@ - @ if "$(CP)" NEQ "" echo CP=$(CP) >> $@ - @ if "$(MV)" NEQ "" echo MV=$(MV) >> $@ - @ if "$(ZIPEXE)" NEQ "" echo ZIPEXE=$(ZIPEXE) >> $@ - -checks: checkVariant checkWorkSpace - -checkVariant: - @ if "$(Variant)"=="" echo Need to specify "Variant=[tiered|compiler2|compiler1|core]" && false - @ if "$(Variant)" NEQ "tiered" if "$(Variant)" NEQ "compiler2" if "$(Variant)" NEQ "compiler1" if "$(Variant)" NEQ "core" \ - echo Need to specify "Variant=[tiered|compiler2|compiler1|core]" && false - -checkWorkSpace: - @ if "$(WorkSpace)"=="" echo Need to specify "WorkSpace=..." && false - -checkBuildID: - @ if "$(BuildID)"=="" echo Need to specify "BuildID=..." && false diff --git a/hotspot/make/windows/build_vm_def.sh b/hotspot/make/windows/build_vm_def.sh deleted file mode 100644 index 7224970058a..00000000000 --- a/hotspot/make/windows/build_vm_def.sh +++ /dev/null @@ -1,74 +0,0 @@ -# -# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This shell script builds a vm.def file for the current VM variant. -# The .def file exports vtbl symbols which allow the Serviceability -# Agent to run on Windows. See make/windows/projectfiles/*/vm.def -# for more information. -# -# The script expects to be executed in the directory containing all of -# the object files. - -# Note that we currently do not have a way to set HotSpotMksHome in -# the batch build, but so far this has not seemed to be a problem. The -# reason this environment variable is necessary is that it seems that -# Windows truncates very long PATHs when executing shells like MKS's -# sh, and it has been found that sometimes `which sh` fails. -if [ "x$HOTSPOTMKSHOME" != "x" ]; then - MKS_HOME="$HOTSPOTMKSHOME" -else - SH=`which sh` - MKS_HOME=`dirname "$SH"` -fi - -AWK="$MKS_HOME/awk.exe" -if [ ! -e $AWK ]; then - AWK="$MKS_HOME/gawk.exe" -fi -GREP="$MKS_HOME/grep.exe" -SORT="$MKS_HOME/sort.exe" -UNIQ="$MKS_HOME/uniq.exe" -CAT="$MKS_HOME/cat.exe" -RM="$MKS_HOME/rm.exe" -DUMPBIN="link.exe /dump" -export VS_UNICODE_OUTPUT= - -echo "EXPORTS" > vm1.def - -# When called from IDE the first param should contain the link version, otherwise may be nill -if [ "x$1" != "x" ]; then -LD_VER="$1" -fi - -if [ "x$LD_VER" != "x800" -a "x$LD_VER" != "x900" -a "x$LD_VER" != "x1000" ]; then -$DUMPBIN /symbols *.obj | "$GREP" "??_7.*@@6B@" | "$GREP" -v "type_info" | "$AWK" '{print $7}' | "$SORT" | "$UNIQ" > vm2.def -else -# Can't use pipes when calling cl.exe or link.exe from IDE. Using transit file vm3.def -$DUMPBIN /OUT:vm3.def /symbols *.obj -"$CAT" vm3.def | "$GREP" "??_7.*@@6B@" | "$GREP" -v "type_info" | "$AWK" '{print $7}' | "$SORT" | "$UNIQ" > vm2.def -"$RM" -f vm3.def -fi - -"$CAT" vm1.def vm2.def > vm.def -"$RM" -f vm1.def vm2.def diff --git a/hotspot/make/windows/create.bat b/hotspot/make/windows/create.bat deleted file mode 100644 index a2cdaaaff0b..00000000000 --- a/hotspot/make/windows/create.bat +++ /dev/null @@ -1,198 +0,0 @@ -@echo off -REM -REM Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. -REM DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -REM -REM This code is free software; you can redistribute it and/or modify it -REM under the terms of the GNU General Public License version 2 only, as -REM published by the Free Software Foundation. -REM -REM This code is distributed in the hope that it will be useful, but WITHOUT -REM ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -REM FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -REM version 2 for more details (a copy is included in the LICENSE file that -REM accompanied this code). -REM -REM You should have received a copy of the GNU General Public License version -REM 2 along with this work; if not, write to the Free Software Foundation, -REM Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -REM -REM Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -REM or visit www.oracle.com if you need additional information or have any -REM questions. -REM -REM - -REM This is the interactive build setup script (as opposed to the batch -REM build execution script). It creates $HotSpotBuildSpace if necessary, -REM copies the appropriate files out of $HotSpotWorkSpace into it, and -REM builds and runs ProjectCreator in it. This has the side-effect of creating -REM the vm.vcproj file in the buildspace, which is then used in Visual C++. - -REM -REM Since we don't have uname and we could be cross-compiling, -REM Use the compiler to determine which ARCH we are building -REM -REM Note: Running this batch file from the Windows command shell requires -REM that "grep" be accessible on the PATH. An MKS install does this. -REM - -cl 2>NUL >NUL -if %errorlevel% == 0 goto nexttest -echo Make sure cl.exe is in your PATH before running this script. -goto end - -:nexttest -grep -V 2>NUL >NUL -if %errorlevel% == 0 goto testit -echo Make sure grep.exe is in your PATH before running this script. Either cygwin or MKS should work. -goto end - - -:testit -cl 2>&1 | grep "x64" >NUL -if %errorlevel% == 0 goto amd64 -set ARCH=x86 -set BUILDARCH=i486 -set Platform_arch=x86 -set Platform_arch_model=x86_32 -goto done -:amd64 -set ARCH=x86 -set BUILDARCH=amd64 -set Platform_arch=x86 -set Platform_arch_model=x86_64 -:done - -setlocal - -if "%1" == "" goto usage - -if not "%2" == "" goto usage - -REM Set HotSpotWorkSpace to the directy two steps above this script -for %%i in ("%~dp0..") do ( set HotSpotWorkSpace=%%~dpi) -set HotSpotBuildRoot=%HotSpotWorkSpace%build -set HotSpotBuildSpace=%HotSpotBuildRoot%\vs-%BUILDARCH% -set HotSpotJDKDist=%1 - - -REM figure out MSC version -for /F %%i in ('sh %HotSpotWorkSpace%/make/windows/get_msc_ver.sh') do set %%i - -echo ************************************************************** -echo MSC_VER = "%MSC_VER%" -set ProjectFile=%HotSpotBuildSpace%\jvm.vcxproj -echo %ProjectFile% -echo ************************************************************** - -REM Test all variables to see whether the directories they -REM reference exist - -if exist %HotSpotWorkSpace% goto test1 - -echo Error: directory pointed to by HotSpotWorkSpace -echo does not exist, or the variable is not set. -echo. -goto usage - -:test1 -if exist %HotSpotBuildSpace% goto test2 -if not "%HotSpotBuildSpace%" == "" mkdir %HotSpotBuildSpace% -if exist %HotSpotBuildSpace% goto test2 -echo Error: directory pointed to by HotSpotBuildSpace -echo does not exist, or the variable is not set. -echo. -goto usage - -:test2 -if exist %HotSpotJDKDist% goto test3 -echo Error: directory pointed to by %HotSpotJDKDist% -echo does not exist, or the variable is not set. -echo. -goto usage - -:test3 -if not "%HOTSPOTMKSHOME%" == "" goto makedir -if exist c:\cygwin\bin set HOTSPOTMKSHOME=c:\cygwin\bin -if not "%HOTSPOTMKSHOME%" == "" goto makedir -if exist c:\cygwin64\bin set HOTSPOTMKSHOME=c:\cygwin64\bin -if not "%HOTSPOTMKSHOME%" == "" goto makedir -echo Warning: please set variable HOTSPOTMKSHOME to place where -echo your MKS/Cygwin installation is -echo. -goto usage - -:generatefiles -if NOT EXIST %HotSpotBuildSpace%\%1\generated mkdir %HotSpotBuildSpace%\%1\generated -copy %HotSpotWorkSpace%\make\windows\projectfiles\%1\* %HotSpotBuildSpace%\%1\generated > NUL - -REM force regneration of ProjectFile -if exist %ProjectFile% del %ProjectFile% - -echo -- %1 -- -echo # Generated file! > %HotSpotBuildSpace%\%1\local.make -echo # Changing a variable below and then deleting %ProjectFile% will cause >> %HotSpotBuildSpace%\%1\local.make -echo # %ProjectFile% to be regenerated with the new values. Changing the >> %HotSpotBuildSpace%\%1\local.make -echo # version requires rerunning create.bat. >> %HotSpotBuildSpace%\%1\local.make -echo. >> %HotSpotBuildSpace%\%1\local.make -echo Variant=%1 >> %HotSpotBuildSpace%\%1\local.make -echo WorkSpace=%HotSpotWorkSpace% >> %HotSpotBuildSpace%\%1\local.make -echo HOTSPOTWORKSPACE=%HotSpotWorkSpace% >> %HotSpotBuildSpace%\%1\local.make -echo HOTSPOTBUILDROOT=%HotSpotBuildRoot% >> %HotSpotBuildSpace%\%1\local.make -echo HOTSPOTBUILDSPACE=%HotSpotBuildSpace% >> %HotSpotBuildSpace%\%1\local.make -echo HOTSPOTJDKDIST=%HotSpotJDKDist% >> %HotSpotBuildSpace%\%1\local.make -echo ARCH=%ARCH% >> %HotSpotBuildSpace%\%1\local.make -echo BUILDARCH=%BUILDARCH% >> %HotSpotBuildSpace%\%1\local.make -echo Platform_arch=%Platform_arch% >> %HotSpotBuildSpace%\%1\local.make -echo Platform_arch_model=%Platform_arch_model% >> %HotSpotBuildSpace%\%1\local.make -echo MSC_VER=%MSC_VER% >> %HotSpotBuildSpace%\%1\local.make - -for /D %%j in (debug, fastdebug, product) do ( - if NOT EXIST %HotSpotBuildSpace%\%1\%%j mkdir %HotSpotBuildSpace%\%1\%%j -) - -pushd %HotSpotBuildSpace%\%1\generated -nmake /nologo -popd - -goto :eof - - -:makedir -echo NOTE: Using the following settings: -echo HotSpotWorkSpace=%HotSpotWorkSpace% -echo HotSpotBuildSpace=%HotSpotBuildSpace% -echo HotSpotJDKDist=%HotSpotJDKDist% - -echo COPYFILES %BUILDARCH% -call :generatefiles compiler1 -call :generatefiles tiered - -pushd %HotSpotBuildRoot% -REM It doesn't matter which variant we use here, "tiered" is as good as any of the others - we need the common variables -nmake /nologo /F %HotSpotWorkSpace%/make/windows/projectfiles/common/Makefile LOCAL_MAKE=%HotSpotBuildSpace%\tiered\local.make %ProjectFile% - -popd - -goto end - -:usage -echo Usage: create HotSpotJDKDist -echo. -echo This is the VS build setup script (as opposed to the batch -echo build execution script). It creates a build directory if necessary, -echo copies the appropriate files out of the workspace into it, and -echo builds and runs ProjectCreator in it. This has the side-effect of creating -echo the %ProjectFile% file in the build space, which is then used in Visual C++. -echo. -echo The HotSpotJDKDist defines the JDK that should be used when running the JVM. -echo Environment variable FORCE_MSC_VER allows to override MSVC version autodetection. -echo. -echo NOTE that it is now NOT safe to modify any of the files in the build -echo space, since they may be overwritten whenever this script is run or -echo nmake is run in that directory. - -:end - -endlocal diff --git a/hotspot/make/windows/create_obj_files.sh b/hotspot/make/windows/create_obj_files.sh deleted file mode 100644 index 685f7f3b0f5..00000000000 --- a/hotspot/make/windows/create_obj_files.sh +++ /dev/null @@ -1,167 +0,0 @@ -# -# Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -set -e - -# Note that we currently do not have a way to set HotSpotMksHome in -# the batch build, but so far this has not seemed to be a problem. The -# reason this environment variable is necessary is that it seems that -# Windows truncates very long PATHs when executing shells like MKS's -# sh, and it has been found that sometimes `which sh` fails. - -if [ "x$HotSpotMksHome" != "x" ]; then - TOOL_DIR="$HotSpotMksHome" -else - # HotSpotMksHome is not set so use the directory that contains "sh". - # This works with both MKS and Cygwin. - SH=`which sh` - TOOL_DIR=`dirname "$SH"` -fi - -DIRNAME="$TOOL_DIR/dirname" -FIND="$TOOL_DIR/find" - -TYPE=$1 -Platform_arch=$2 -Platform_arch_model=$3 -Platform_os_family=windows -Platform_os_arch=windows_$Platform_arch - -WorkSpace=$4 -GENERATED=$5 - -COMMONSRC_REL=src -ALTSRC_REL=src/closed # Change this to pick up alt sources from somewhere else - -COMMONSRC=${WorkSpace}/${COMMONSRC_REL} -if [ "x$OPENJDK" != "xtrue" ]; then - ALTSRC=${WorkSpace}/${ALTSRC_REL} -else - ALTSRC=PATH_THAT_DOES_NOT_EXIST -fi - -BASE_PATHS="`if [ -d ${ALTSRC}/share/vm ]; then $FIND ${ALTSRC}/share/vm ! -name vm -prune -type d \! \( -name adlc -o -name c1 -o -name gc -o -name opto -o -name shark -o -name libadt \); fi`" -BASE_PATHS="${BASE_PATHS} ` $FIND ${COMMONSRC}/share/vm ! -name vm -prune -type d \! \( -name adlc -o -name c1 -o -name gc -o -name opto -o -name shark -o -name libadt \)`" - -for sd in \ - share/vm/gc/shared \ - os/${Platform_os_family}/vm \ - cpu/${Platform_arch}/vm \ - os_cpu/${Platform_os_arch}/vm; do - if [ -d "${ALTSRC}/${sd}" ]; then - BASE_PATHS="${BASE_PATHS} ${ALTSRC}/${sd}" - fi - BASE_PATHS="${BASE_PATHS} ${COMMONSRC}/${sd}" -done - -BASE_PATHS="${BASE_PATHS} ${GENERATED}/jvmtifiles ${GENERATED}/tracefiles" - -if [ -d "${ALTSRC}/share/vm/jfr/buffers" ]; then - BASE_PATHS="${BASE_PATHS} ${ALTSRC}/share/vm/jfr/buffers" -fi - -BASE_PATHS="${BASE_PATHS} ${COMMONSRC}/share/vm/prims/wbtestmethods" - -# shared is already in BASE_PATHS. Should add vm/memory but that one is also in BASE_PATHS. -if [ -d "${ALTSRC}/share/vm/gc" ]; then - BASE_PATHS="${BASE_PATHS} `$FIND ${ALTSRC}/share/vm/gc ! -name gc -prune -type d \! -name shared`" -fi -BASE_PATHS="${BASE_PATHS} `$FIND ${COMMONSRC}/share/vm/gc ! -name gc -prune -type d \! -name shared`" - -if [ -d "${ALTSRC}/share/vm/c1" ]; then - COMPILER1_PATHS="${ALTSRC}/share/vm/c1" -fi -COMPILER1_PATHS="${COMPILER1_PATHS} ${COMMONSRC}/share/vm/c1" - -if [ -d "${ALTSRC}/share/vm/opto" ]; then - COMPILER2_PATHS="${ALTSRC}/share/vm/opto" -fi -COMPILER2_PATHS="${COMPILER2_PATHS} ${COMMONSRC}/share/vm/opto" -if [ -d "${ALTSRC}/share/vm/libadt" ]; then - COMPILER2_PATHS="${COMPILER2_PATHS} ${ALTSRC}/share/vm/libadt" -fi -COMPILER2_PATHS="${COMPILER2_PATHS} ${COMMONSRC}/share/vm/libadt" -COMPILER2_PATHS="${COMPILER2_PATHS} ${GENERATED}/adfiles" - -# Include dirs per type. -case "${TYPE}" in - "compiler1") Src_Dirs="${BASE_PATHS} ${COMPILER1_PATHS}" ;; - "compiler2") Src_Dirs="${BASE_PATHS} ${COMPILER2_PATHS}" ;; - "tiered") Src_Dirs="${BASE_PATHS} ${COMPILER1_PATHS} ${COMPILER2_PATHS}" ;; - "zero") Src_Dirs="${BASE_PATHS}" ;; - "shark") Src_Dirs="${BASE_PATHS}" ;; -esac - -COMPILER2_SPECIFIC_FILES="opto libadt bcEscapeAnalyzer.cpp c2_* runtime_*" -COMPILER1_SPECIFIC_FILES="c1_*" -JVMCI_SPECIFIC_FILES="*jvmci* *JVMCI*" -SHARK_SPECIFIC_FILES="shark" -ZERO_SPECIFIC_FILES="zero" - -# Always exclude these. -Src_Files_EXCLUDE="jsig.c jvmtiEnvRecommended.cpp jvmtiEnvStub.cpp" - -# Exclude per type. -case "${TYPE}" in - "compiler1") Src_Files_EXCLUDE="${Src_Files_EXCLUDE} ${COMPILER2_SPECIFIC_FILES} ${JVMCI_SPECIFIC_FILES} ${ZERO_SPECIFIC_FILES} ${SHARK_SPECIFIC_FILES} ciTypeFlow.cpp" ;; - "compiler2") Src_Files_EXCLUDE="${Src_Files_EXCLUDE} ${COMPILER1_SPECIFIC_FILES} ${ZERO_SPECIFIC_FILES} ${SHARK_SPECIFIC_FILES}" ;; - "tiered") Src_Files_EXCLUDE="${Src_Files_EXCLUDE} ${ZERO_SPECIFIC_FILES} ${SHARK_SPECIFIC_FILES}" ;; - "zero") Src_Files_EXCLUDE="${Src_Files_EXCLUDE} ${COMPILER1_SPECIFIC_FILES} ${COMPILER2_SPECIFIC_FILES} ${JVMCI_SPECIFIC_FILES} ${SHARK_SPECIFIC_FILES} ciTypeFlow.cpp" ;; - "shark") Src_Files_EXCLUDE="${Src_Files_EXCLUDE} ${COMPILER1_SPECIFIC_FILES} ${COMPILER2_SPECIFIC_FILES} ${JVMCI_SPECIFIC_FILES} ${ZERO_SPECIFIC_FILES}" ;; -esac - -# Special handling of arch model. -case "${Platform_arch_model}" in - "x86_32") Src_Files_EXCLUDE="${Src_Files_EXCLUDE} *x86_64* ${JVMCI_SPECIFIC_FILES}" ;; - "x86_64") Src_Files_EXCLUDE="${Src_Files_EXCLUDE} *x86_32*" ;; -esac - -# Locate all source files in the given directory, excluding files in Src_Files_EXCLUDE. -function findsrc { - $FIND ${1}/. ! -name . -prune \ - -a \( -name \*.c -o -name \*.cpp -o -name \*.s \) \ - -a \! \( -name ${Src_Files_EXCLUDE// / -o -name } \) \ - | sed 's/.*\/\(.*\)/\1/'; -} - -Src_Files= -for e in ${Src_Dirs}; do - Src_Files="${Src_Files}`findsrc ${e}` " -done - -Obj_Files=" " -for e in ${Src_Files}; do - o="${e%\.[!.]*}.obj" - set +e - chk=`expr "${Obj_Files}" : ".* $o"` - set -e - if [ "$chk" != 0 ]; then - echo "# INFO: skipping duplicate $o" - continue - fi - Obj_Files="${Obj_Files}$o " -done -Obj_Files=`echo ${Obj_Files} | tr ' ' '\n' | LC_ALL=C sort` - -echo Obj_Files=${Obj_Files} diff --git a/hotspot/make/windows/cross_build.bat b/hotspot/make/windows/cross_build.bat deleted file mode 100644 index 36eac52b2fe..00000000000 --- a/hotspot/make/windows/cross_build.bat +++ /dev/null @@ -1,61 +0,0 @@ -@echo off -REM -REM Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. -REM DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -REM -REM This code is free software; you can redistribute it and/or modify it -REM under the terms of the GNU General Public License version 2 only, as -REM published by the Free Software Foundation. -REM -REM This code is distributed in the hope that it will be useful, but WITHOUT -REM ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -REM FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -REM version 2 for more details (a copy is included in the LICENSE file that -REM accompanied this code). -REM -REM You should have received a copy of the GNU General Public License version -REM 2 along with this work; if not, write to the Free Software Foundation, -REM Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -REM -REM Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -REM or visit www.oracle.com if you need additional information or have any -REM questions. -REM -REM - -REM Cross compile IA64 compiler2 VM -REM Usage: -REM cross_compile flavor workspace bootstrap_dir [build_id] -REM %1 %2 %3 %4 -REM -REM Set current directory -for /F %%i in ('cd') do set CD=%%i -echo Setting up Visual C++ Compilation Environment -if "%MSVCDir%" == "" goto setdir1 -goto setenv1 -:setdir1 -SET MSVCDir=C:\Program Files\Microsoft Visual Studio\VC98 -:setenv1 -SET OLDINCLUDE=%INCLUDE% -SET OLDLIB=%LIB% -SET OLDPATH=%PATH% -call "%MSVCDir%\Bin\VCVARS32" -call %2\make\windows\build %1 adlc %2 %3 %4 -SET INCLUDE=%OLDINCLUDE% -SET LIB=%OLDLIB% -SET PATH=%OLDPATH% -echo Setting up 64-BIT Compilation Environment -if "%MSSdk%" == "" goto setdir2 -goto setenv2 -:setdir2 -SET MSSdk=C:\Program Files\Microsoft SDK -:setenv2 -call "%MSSdk%\SetEnv.bat" /XP64 -SET ALT_ADLC_PATH=%CD%\windows_i486_compiler2\generated -call %2\make\windows\build %1 compiler2 %2 %3 %4 -SET INCLUDE=%OLDINCLUDE% -SET LIB=%OLDLIB% -SET PATH=%OLDPATH% -SET OLDINCLUDE= -SET OLDLIB= -SET OLDPATH= diff --git a/hotspot/make/windows/get_msc_ver.sh b/hotspot/make/windows/get_msc_ver.sh deleted file mode 100644 index 89c7a3f8c8f..00000000000 --- a/hotspot/make/windows/get_msc_ver.sh +++ /dev/null @@ -1,93 +0,0 @@ -# -# Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -set -e - -# This shell script echoes "MSC_VER=" -# It ignores the micro version component. -# Examples: -# cl version 12.00.8804 returns "MSC_VER=1200" -# cl version 13.10.3077 returns "MSC_VER=1310" -# cl version 14.00.30701 returns "MSC_VER=1399" (OLD_MSSDK version) -# cl version 14.00.40310.41 returns "MSC_VER=1400" -# cl version 15.00.21022.8 returns "MSC_VER=1500" - -# Note that we currently do not have a way to set HotSpotMksHome in -# the batch build, but so far this has not seemed to be a problem. The -# reason this environment variable is necessary is that it seems that -# Windows truncates very long PATHs when executing shells like MKS's -# sh, and it has been found that sometimes `which sh` fails. - -if [ "x$HotSpotMksHome" != "x" ]; then - TOOL_DIR="$HotSpotMksHome" -else - # HotSpotMksHome is not set so use the directory that contains "sh". - # This works with both MKS and Cygwin. - SH=`which sh` - TOOL_DIR=`dirname "$SH"` -fi - -DIRNAME="$TOOL_DIR/dirname" -HEAD="$TOOL_DIR/head" -ECHO="$TOOL_DIR/echo" -EXPR="$TOOL_DIR/expr" -CUT="$TOOL_DIR/cut" -SED="$TOOL_DIR/sed" - -if [ "x$FORCE_MSC_VER" != "x" ]; then - echo "MSC_VER=$FORCE_MSC_VER" -else - MSC_VER_RAW=`cl 2>&1 | "$HEAD" -n 1 | "$SED" 's/.*Version[\ ]*\([0-9][0-9.]*\).*/\1/'` - MSC_VER_MAJOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f1` - MSC_VER_MINOR=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f2` - MSC_VER_MICRO=`"$ECHO" $MSC_VER_RAW | "$CUT" -d'.' -f3` - if [ "${MSC_VER_MAJOR}" -eq 14 -a "${MSC_VER_MINOR}" -eq 0 -a "${MSC_VER_MICRO}" -eq 30701 ] ; then - # This said 1400 but it was really more like VS2003 (VC7) in terms of options - MSC_VER=1399 - else - MSC_VER=`"$EXPR" $MSC_VER_MAJOR \* 100 + $MSC_VER_MINOR` - fi - echo "MSC_VER=$MSC_VER" - echo "MSC_VER_RAW=$MSC_VER_RAW" -fi - -if [ "x$FORCE_LD_VER" != "x" ]; then - echo "LD_VER=$FORCE_LD_VER" -else - # use the "link" command that is co-located with the "cl" command - cl_cmd=`which cl` - if [ "x$cl_cmd" != "x" ]; then - link_cmd=`$DIRNAME "$cl_cmd"`/link - else - # which can't find "cl" so just use which ever "link" we find - link_cmd="link" - fi - LD_VER_RAW=`"$link_cmd" 2>&1 | "$HEAD" -n 1 | "$SED" 's/.*Version[\ ]*\([0-9][0-9.]*\).*/\1/'` - LD_VER_MAJOR=`"$ECHO" $LD_VER_RAW | "$CUT" -d'.' -f1` - LD_VER_MINOR=`"$ECHO" $LD_VER_RAW | "$CUT" -d'.' -f2` - LD_VER_MICRO=`"$ECHO" $LD_VER_RAW | "$CUT" -d'.' -f3` - LD_VER=`"$EXPR" $LD_VER_MAJOR \* 100 + $LD_VER_MINOR` - echo "LD_VER=$LD_VER" - echo "LD_VER_RAW=$LD_VER_RAW" -fi diff --git a/hotspot/make/windows/jvmexp.lcf b/hotspot/make/windows/jvmexp.lcf deleted file mode 100644 index 6489d02e266..00000000000 --- a/hotspot/make/windows/jvmexp.lcf +++ /dev/null @@ -1,10 +0,0 @@ --export:JNI_GetDefaultJavaVMInitArgs --export:JNI_CreateJavaVM --export:JNI_GetCreatedJavaVMs - --export:jio_snprintf --export:jio_printf --export:jio_fprintf --export:jio_vfprintf --export:jio_vsnprintf - diff --git a/hotspot/make/windows/jvmexp_g.lcf b/hotspot/make/windows/jvmexp_g.lcf deleted file mode 100644 index 6489d02e266..00000000000 --- a/hotspot/make/windows/jvmexp_g.lcf +++ /dev/null @@ -1,10 +0,0 @@ --export:JNI_GetDefaultJavaVMInitArgs --export:JNI_CreateJavaVM --export:JNI_GetCreatedJavaVMs - --export:jio_snprintf --export:jio_printf --export:jio_fprintf --export:jio_vfprintf --export:jio_vsnprintf - diff --git a/hotspot/make/windows/makefiles/adlc.make b/hotspot/make/windows/makefiles/adlc.make deleted file mode 100644 index 781e3ac4048..00000000000 --- a/hotspot/make/windows/makefiles/adlc.make +++ /dev/null @@ -1,119 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - - -# Rules for building adlc.exe - -# Need exception handling support here -# $(MS_RUNTIME_OPTION) ( with /D_STATIC_CPPLIB) -# causes adlc.exe to link with the static -# multithread Standard C++ library (libcpmt.lib) instead of -# the dynamic version (msvcprt.lib), which is not included -# in any of the free tools. -EXH_FLAGS=$(GX_OPTION) $(MS_RUNTIME_OPTION) - -!ifdef ALT_ADLC_PATH -ADLC=$(ALT_ADLC_PATH)\adlc.exe -!else -ADLC=adlc -!endif - -!ifdef LP64 -ADLCFLAGS=-q -T -D_LP64 -!else -ADLCFLAGS=-q -T -U_LP64 -!endif - -ADLC_CXX_FLAGS=$(CXX_FLAGS) /D _CRT_SECURE_NO_WARNINGS /D _CRT_SECURE_NO_DEPRECATE - -CXX_INCLUDE_DIRS=\ - /I "..\generated" \ - /I "$(WorkSpace)\src\share\vm" \ - /I "$(WorkSpace)\src\os\windows\vm" \ - /I "$(WorkSpace)\src\cpu\$(Platform_arch)\vm" - -!if "$(Platform_arch_model)" == "$(Platform_arch)" -SOURCES_AD=\ - $(WorkSpace)/src/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad -!else -SOURCES_AD=\ - $(WorkSpace)/src/cpu/$(Platform_arch)/vm/$(Platform_arch_model).ad \ - $(WorkSpace)/src/cpu/$(Platform_arch)/vm/$(Platform_arch).ad -!endif - -# NOTE! If you add any files here, you must also update GENERATED_NAMES_IN_DIR -# and ProjectCreatorIDEOptions in projectcreator.make. -GENERATED_NAMES=\ - ad_$(Platform_arch_model).cpp \ - ad_$(Platform_arch_model).hpp \ - ad_$(Platform_arch_model)_clone.cpp \ - ad_$(Platform_arch_model)_expand.cpp \ - ad_$(Platform_arch_model)_format.cpp \ - ad_$(Platform_arch_model)_gen.cpp \ - ad_$(Platform_arch_model)_misc.cpp \ - ad_$(Platform_arch_model)_peephole.cpp \ - ad_$(Platform_arch_model)_pipeline.cpp \ - adGlobals_$(Platform_arch_model).hpp \ - dfa_$(Platform_arch_model).cpp - -# NOTE! This must be kept in sync with GENERATED_NAMES -GENERATED_NAMES_IN_DIR=\ - $(AdlcOutDir)\ad_$(Platform_arch_model).cpp \ - $(AdlcOutDir)\ad_$(Platform_arch_model).hpp \ - $(AdlcOutDir)\ad_$(Platform_arch_model)_clone.cpp \ - $(AdlcOutDir)\ad_$(Platform_arch_model)_expand.cpp \ - $(AdlcOutDir)\ad_$(Platform_arch_model)_format.cpp \ - $(AdlcOutDir)\ad_$(Platform_arch_model)_gen.cpp \ - $(AdlcOutDir)\ad_$(Platform_arch_model)_misc.cpp \ - $(AdlcOutDir)\ad_$(Platform_arch_model)_peephole.cpp \ - $(AdlcOutDir)\ad_$(Platform_arch_model)_pipeline.cpp \ - $(AdlcOutDir)\adGlobals_$(Platform_arch_model).hpp \ - $(AdlcOutDir)\dfa_$(Platform_arch_model).cpp - -{$(WorkSpace)\src\share\vm\adlc}.cpp.obj:: - $(CXX) $(ADLC_CXX_FLAGS) $(EXH_FLAGS) $(CXX_INCLUDE_DIRS) /c $< - -{$(WorkSpace)\src\share\vm\opto}.cpp.obj:: - $(CXX) $(ADLC_CXX_FLAGS) $(EXH_FLAGS) $(CXX_INCLUDE_DIRS) /c $< - -adlc.exe: main.obj adlparse.obj archDesc.obj arena.obj dfa.obj dict2.obj filebuff.obj \ - forms.obj formsopt.obj formssel.obj opcodes.obj output_c.obj output_h.obj - $(LD) $(LD_FLAGS) /subsystem:console /out:$@ $** -!if "$(MT)" != "" -# The previous link command created a .manifest file that we want to -# insert into the linked artifact so we do not need to track it -# separately. Use ";#2" for .dll and ";#1" for .exe: - $(MT) /manifest $@.manifest /outputresource:$@;#1 -!endif - -$(GENERATED_NAMES_IN_DIR): $(Platform_arch_model).ad adlc.exe - rm -f $(GENERATED_NAMES) - if exist $(AdlcOutDir) rmdir /s /q $(AdlcOutDir) - mkdir $(AdlcOutDir) - $(ADLC) $(ADLCFLAGS) $(Platform_arch_model).ad - mv $(GENERATED_NAMES) $(AdlcOutDir)/ - -$(Platform_arch_model).ad: $(SOURCES_AD) - rm -f $(Platform_arch_model).ad - cat $(SOURCES_AD) >$(Platform_arch_model).ad diff --git a/hotspot/make/windows/makefiles/compile.make b/hotspot/make/windows/makefiles/compile.make deleted file mode 100644 index 0af2574c251..00000000000 --- a/hotspot/make/windows/makefiles/compile.make +++ /dev/null @@ -1,197 +0,0 @@ -# -# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Generic compiler settings -!if "x$(CXX)" == "x" -CXX=cl.exe -!endif - -# CXX Flags: (these vary slightly from VC6->VS2003->VS2005 compilers) -# /nologo Supress copyright message at every cl.exe startup -# /W3 Warning level 3 -# /Zi Include debugging information -# /d2Zi+ Extended debugging symbols for optimized code (/Zo in VS2013 Update 3 and later) -# /WX Treat any warning error as a fatal error -# /MD Use dynamic multi-threaded runtime (msvcrt.dll or msvc*NN.dll) -# /MTd Use static multi-threaded runtime debug versions -# /O1 Optimize for size (/Os), skips /Oi -# /O2 Optimize for speed (/Ot), adds /Oi to /O1 -# /Ox Old "all optimizations flag" for VC6 (in /O1) -# /Oy Use frame pointer register as GP reg (in /Ox and /O1) -# /GF Merge string constants and put in read-only memory (in /O1) -# /Gy Func level link (in /O1, allows for link-time func ordering) -# /Gs Inserts stack probes (in /O1) -# /GS Inserts security stack checks in some functions (VS2005 default) -# /Oi Use intrinsics (in /O2) -# /Od Disable all optimizations -# /MP Use multiple cores for compilation -# -# NOTE: Normally following any of the above with a '-' will turn off that flag -# -# 6655385: For VS2003/2005 we now specify /Oy- (disable frame pointer -# omission.) This has little to no effect on performance while vastly -# improving the quality of crash log stack traces involving jvm.dll. - -# These are always used in all compiles -CXX_FLAGS=$(EXTRA_CFLAGS) /nologo /W3 - -!if "$(WARNINGS_AS_ERRORS)" != "false" -CXX_FLAGS=$(CXX_FLAGS) /WX -!endif - -# Let's add debug information when Full Debug Symbols is enabled -!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1" -CXX_FLAGS=$(CXX_FLAGS) /Zi /d2Zi+ -!endif - -# Based on BUILDARCH we add some flags and select the default compiler name -!if "$(BUILDARCH)" == "ia64" -MACHINE=IA64 -CXX_FLAGS=$(CXX_FLAGS) /D "CC_INTERP" /D "_LP64" /D "IA64" -!endif - -!if "$(BUILDARCH)" == "amd64" -MACHINE=AMD64 -CXX_FLAGS=$(CXX_FLAGS) /D "_LP64" /D "AMD64" -LP64=1 -!endif - -!if "$(BUILDARCH)" == "i486" -MACHINE=I386 -# VS2013 generates bad l2f without /arch:IA32 -CXX_FLAGS=$(CXX_FLAGS) /D "IA32" /arch:IA32 -!endif - -CXX_FLAGS=$(CXX_FLAGS) /D "WIN32" /D "_WINDOWS" -# Must specify this for sharedRuntimeTrig.cpp -CXX_FLAGS=$(CXX_FLAGS) /D "VM_LITTLE_ENDIAN" - -# Used for platform dispatching -CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_FAMILY_windows -CXX_FLAGS=$(CXX_FLAGS) /D TARGET_ARCH_$(Platform_arch) -CXX_FLAGS=$(CXX_FLAGS) /D TARGET_ARCH_MODEL_$(Platform_arch_model) -CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_ARCH_windows_$(Platform_arch) -CXX_FLAGS=$(CXX_FLAGS) /D TARGET_OS_ARCH_MODEL_windows_$(Platform_arch_model) -CXX_FLAGS=$(CXX_FLAGS) /D TARGET_COMPILER_visCPP - - -# MSC_VER is a 4 digit number that tells us what compiler is being used -# and is generated when the local.make file is created by build.make -# via the script get_msc_ver.sh -# -# If MSC_VER is set, it overrides the above default setting. -# But it should be set. -# Possible values: -# 1200 is for VC6 -# 1300 and 1310 is VS2003 or VC7 -# 1399 is our fake number for the VS2005 compiler that really isn't 1400 -# 1400 is for VS2005 -# 1500 is for VS2008 -# 1600 is for VS2010 -# 1700 is for VS2012 -# 1800 is for VS2013 -# Do not confuse this MSC_VER with the predefined macro _MSC_VER that the -# compiler provides, when MSC_VER==1399, _MSC_VER will be 1400. -# Normally they are the same, but a pre-release of the VS2005 compilers -# in the Windows 64bit Platform SDK said it was 1400 when it was really -# closer to VS2003 in terms of option spellings, so we use 1399 for that -# 1400 version that really isn't 1400. -# See the file get_msc_ver.sh for more info. - -# By default, we do not want to use the debug version of the msvcrt.dll file -# but if MFC_DEBUG is defined in the environment it will be used. -MS_RUNTIME_OPTION = /MD -!if "$(MFC_DEBUG)" == "true" -MS_RUNTIME_OPTION = /MTd /D "_DEBUG" -!endif - -# VS2012 and later won't work with: -# /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB -!if "$(MSC_VER)" < "1700" -# Always add the _STATIC_CPPLIB flag -STATIC_CPPLIB_OPTION = /D _STATIC_CPPLIB /D _DISABLE_DEPRECATE_STATIC_CPPLIB -MS_RUNTIME_OPTION = $(MS_RUNTIME_OPTION) $(STATIC_CPPLIB_OPTION) -!endif -CXX_FLAGS=$(CXX_FLAGS) $(MS_RUNTIME_OPTION) - -PRODUCT_OPT_OPTION = /O2 /Oy- -FASTDEBUG_OPT_OPTION = /O2 /Oy- -DEBUG_OPT_OPTION = /Od -GX_OPTION = /EHsc -LD_FLAGS = /manifest $(LD_FLAGS) -MP_FLAG = /MP -# Manifest Tool - used in VS2005 and later to adjust manifests stored -# as resources inside build artifacts. -!if "x$(MT)" == "x" -MT=mt.exe -!endif -!if "$(BUILDARCH)" == "i486" -LD_FLAGS = /SAFESEH $(LD_FLAGS) -!endif - -CXX_FLAGS = $(CXX_FLAGS) $(MP_FLAG) - -# If NO_OPTIMIZATIONS is defined in the environment, turn everything off -!ifdef NO_OPTIMIZATIONS -PRODUCT_OPT_OPTION = $(DEBUG_OPT_OPTION) -FASTDEBUG_OPT_OPTION = $(DEBUG_OPT_OPTION) -!endif - -# Generic linker settings -!if "x$(LD)" == "x" -LD=link.exe -!endif -LD_FLAGS= $(LD_FLAGS) kernel32.lib user32.lib gdi32.lib winspool.lib \ - comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib \ - uuid.lib Wsock32.lib winmm.lib version.lib /nologo /machine:$(MACHINE) /opt:REF \ - /opt:ICF,8 -!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1" -LD_FLAGS= $(LD_FLAGS) /map /debug -!endif - - -!if $(MSC_VER) >= 1600 -LD_FLAGS= $(LD_FLAGS) psapi.lib -!endif - -# Resource compiler settings -!if "x$(RC)" == "x" -RC=rc.exe -!endif -RC_FLAGS=/D "HS_VER=$(HS_VER)" \ - /D "HS_DOTVER=$(HS_DOTVER)" \ - /D "HS_BUILD_ID=$(HS_BUILD_ID)" \ - /D "JDK_VER=$(JDK_VER)" \ - /D "JDK_DOTVER=$(JDK_DOTVER)" \ - /D "HS_COMPANY=$(HS_COMPANY)" \ - /D "HS_FILEDESC=$(HS_FILEDESC)" \ - /D "HS_COPYRIGHT=$(HS_COPYRIGHT)" \ - /D "HS_FNAME=$(HS_FNAME)" \ - /D "HS_INTERNAL_NAME=$(HS_INTERNAL_NAME)" \ - /D "HS_NAME=$(HS_NAME)" - -# Need this to match the CXX_FLAGS settings -!if "$(MFC_DEBUG)" == "true" -RC_FLAGS = $(RC_FLAGS) /D "_DEBUG" -!endif diff --git a/hotspot/make/windows/makefiles/debug.make b/hotspot/make/windows/makefiles/debug.make deleted file mode 100644 index 3ad45627467..00000000000 --- a/hotspot/make/windows/makefiles/debug.make +++ /dev/null @@ -1,68 +0,0 @@ -# -# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -HS_INTERNAL_NAME=jvm -HS_FNAME=$(HS_INTERNAL_NAME).dll -AOUT=$(HS_FNAME) -GENERATED=../generated - -# Allow the user to turn off precompiled headers from the command line. -!if "$(USE_PRECOMPILED_HEADER)" != "0" -BUILD_PCH_FILE=_build_pch_file.obj -!endif - -default:: $(BUILD_PCH_FILE) $(AOUT) - -!include ../local.make -!include compile.make - -# _NMT_NOINLINE_ informs NMT that no inlining by Compiler -CXX_FLAGS=$(CXX_FLAGS) $(DEBUG_OPT_OPTION) /D "_NMT_NOINLINE_" - -!include $(WorkSpace)/make/windows/makefiles/vm.make -!include local.make - -HS_BUILD_ID=$(HOTSPOT_VERSION_STRING)-debug - -# Force resources to be rebuilt every time -$(Res_Files): FORCE - -# NOTE: Changes in this file was just to give a proper command line when linking -# for use when developing the new build, and should not be integrated. -$(AOUT): $(Res_Files) $(Obj_Files) vm.def - $(LD) $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) -!if "$(MT)" != "" -# The previous link command created a .manifest file that we want to -# insert into the linked artifact so we do not need to track it -# separately. Use ";#2" for .dll and ";#1" for .exe: - $(MT) /manifest $@.manifest /outputresource:$@;#2 -!endif -!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1" -!if "$(ZIP_DEBUGINFO_FILES)" == "1" - $(ZIPEXE) -q $*.diz $*.map $*.pdb - $(RM) $*.map $*.pdb -!endif -!endif - -!include $(WorkSpace)/make/windows/makefiles/shared.make diff --git a/hotspot/make/windows/makefiles/defs.make b/hotspot/make/windows/makefiles/defs.make deleted file mode 100644 index fbbe6f16490..00000000000 --- a/hotspot/make/windows/makefiles/defs.make +++ /dev/null @@ -1,282 +0,0 @@ -# -# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# The common definitions for hotspot windows builds. -# Include the top level defs.make under make directory instead of this one. -# This file is included into make/defs.make. -# On windows it is only used to construct parameters for -# make/windows/build.make when make/Makefile is used to build VM. - -SLASH_JAVA ?= J: -PATH_SEP = ; - -MAKE_ARGS += WARNINGS_AS_ERRORS=$(WARNINGS_AS_ERRORS) - -# Need PLATFORM (os-arch combo names) for jdk and hotspot, plus libarch name -ifeq ($(ARCH_DATA_MODEL),32) - ARCH_DATA_MODEL=32 - PLATFORM=windows-i586 - VM_PLATFORM=windows_i486 - HS_ARCH=x86 - MAKE_ARGS += ARCH=x86 - MAKE_ARGS += BUILDARCH=i486 - MAKE_ARGS += Platform_arch=x86 - MAKE_ARGS += Platform_arch_model=x86_32 -endif - -ifneq ($(shell $(ECHO) $(PROCESSOR_IDENTIFIER) | $(GREP) x86),) - ARCH_DATA_MODEL=32 - PLATFORM=windows-i586 - VM_PLATFORM=windows_i486 - HS_ARCH=x86 - MAKE_ARGS += ARCH=x86 - MAKE_ARGS += BUILDARCH=i486 - MAKE_ARGS += Platform_arch=x86 - MAKE_ARGS += Platform_arch_model=x86_32 -endif - -ifneq ($(ARCH_DATA_MODEL),32) - ifneq ($(shell $(ECHO) $(PROCESSOR_IDENTIFIER) | $(GREP) ia64),) - ARCH_DATA_MODEL=64 - PLATFORM=windows-ia64 - VM_PLATFORM=windows_ia64 - HS_ARCH=ia64 - MAKE_ARGS += LP64=1 - MAKE_ARGS += ARCH=ia64 - MAKE_ARGS += BUILDARCH=ia64 - MAKE_ARGS += Platform_arch=ia64 - MAKE_ARGS += Platform_arch_model=ia64 - endif - -# http://support.microsoft.com/kb/888731 : this can be either -# AMD64 for AMD, or EM64T for Intel chips. - ifneq ($(shell $(ECHO) $(PROCESSOR_IDENTIFIER) | $(GREP) AMD64),) - ARCH_DATA_MODEL=64 - PLATFORM=windows-amd64 - VM_PLATFORM=windows_amd64 - HS_ARCH=x86 - MAKE_ARGS += LP64=1 - MAKE_ARGS += ARCH=x86 - MAKE_ARGS += BUILDARCH=amd64 - MAKE_ARGS += Platform_arch=x86 - MAKE_ARGS += Platform_arch_model=x86_64 - endif - -ifneq ($(shell $(ECHO) $(PROCESSOR_IDENTIFIER) | $(GREP) EM64T),) - ARCH_DATA_MODEL=64 - PLATFORM=windows-amd64 - VM_PLATFORM=windows_amd64 - HS_ARCH=x86 - MAKE_ARGS += LP64=1 - MAKE_ARGS += ARCH=x86 - MAKE_ARGS += BUILDARCH=amd64 - MAKE_ARGS += Platform_arch=x86 - MAKE_ARGS += Platform_arch_model=x86_64 - endif - -# NB later OS versions than 2003 may report "Intel64" - ifneq ($(shell $(ECHO) $(PROCESSOR_IDENTIFIER) | $(GREP) Intel64),) - ARCH_DATA_MODEL=64 - PLATFORM=windows-amd64 - VM_PLATFORM=windows_amd64 - HS_ARCH=x86 - MAKE_ARGS += LP64=1 - MAKE_ARGS += ARCH=x86 - MAKE_ARGS += BUILDARCH=amd64 - MAKE_ARGS += Platform_arch=x86 - MAKE_ARGS += Platform_arch_model=x86_64 - endif -endif - -# Full Debug Symbols has been enabled on Windows since JDK1.4.1 so -# there is no need for an "earlier than JDK7 check". -# The Full Debug Symbols (FDS) default for BUILD_FLAVOR == product -# builds is enabled with debug info files ZIP'ed to save space. For -# BUILD_FLAVOR != product builds, FDS is always enabled, after all a -# debug build without debug info isn't very useful. -# The ZIP_DEBUGINFO_FILES option only has meaning when FDS is enabled. -# -# If you invoke a build with FULL_DEBUG_SYMBOLS=0, then FDS will be -# disabled for a BUILD_FLAVOR == product build. -# -# Note: Use of a different variable name for the FDS override option -# versus the FDS enabled check is intentional (FULL_DEBUG_SYMBOLS -# versus ENABLE_FULL_DEBUG_SYMBOLS). For auto build systems that pass -# in options via environment variables, use of distinct variables -# prevents strange behaviours. For example, in a BUILD_FLAVOR != -# product build, the FULL_DEBUG_SYMBOLS environment variable will be -# 0, but the ENABLE_FULL_DEBUG_SYMBOLS make variable will be 1. If -# the same variable name is used, then different values can be picked -# up by different parts of the build. Just to be clear, we only need -# two variable names because the incoming option value can be -# overridden in some situations, e.g., a BUILD_FLAVOR != product -# build. - -# Due to the multiple sub-make processes that occur this logic gets -# executed multiple times. We reduce the noise by at least checking that -# BUILD_FLAVOR has been set. -ifneq ($(BUILD_FLAVOR),) - ifeq ($(BUILD_FLAVOR), product) - FULL_DEBUG_SYMBOLS ?= 1 - ENABLE_FULL_DEBUG_SYMBOLS = $(FULL_DEBUG_SYMBOLS) - else - # debug variants always get Full Debug Symbols (if available) - ENABLE_FULL_DEBUG_SYMBOLS = 1 - endif - _JUNK_ := $(shell \ - echo >&2 "INFO: ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS)") - MAKE_ARGS += ENABLE_FULL_DEBUG_SYMBOLS=$(ENABLE_FULL_DEBUG_SYMBOLS) - - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ZIP_DEBUGINFO_FILES ?= 1 - else - ZIP_DEBUGINFO_FILES=0 - endif - MAKE_ARGS += ZIP_DEBUGINFO_FILES=$(ZIP_DEBUGINFO_FILES) -endif - -MAKE_ARGS += RM="$(RM)" -MAKE_ARGS += ZIPEXE=$(ZIPEXE) -MAKE_ARGS += CP="${CP}" -MAKE_ARGS += MV="${MV}" - - -# On 32 bit windows we build server and client, on 64 bit just server. -ifeq ($(JVM_VARIANTS),) - ifeq ($(ARCH_DATA_MODEL), 32) - JVM_VARIANTS:=client,server - JVM_VARIANT_CLIENT:=true - JVM_VARIANT_SERVER:=true - else - JVM_VARIANTS:=server - JVM_VARIANT_SERVER:=true - endif -endif - -JDK_INCLUDE_SUBDIR=win32 - -# Library suffix -LIBRARY_SUFFIX=dll - -# next parameters are defined in $(GAMMADIR)/make/defs.make. -MAKE_ARGS += VERSION_SHORT=$(VERSION_SHORT) -MAKE_ARGS += VERSION_MAJOR=$(VERSION_MAJOR) -MAKE_ARGS += VERSION_MINOR=$(VERSION_MINOR) -MAKE_ARGS += VERSION_SECURITY=$(VERSION_SECURITY) -MAKE_ARGS += VERSION_PATCH=$(VERSION_PATCH) -MAKE_ARGS += VERSION_BUILD=$(VERSION_BUILD) -MAKE_ARGS += DEBUG_LEVEL=$(DEBUG_LEVEL) - -# JDK_DOTVER and JDK_VER are needed in Windows RC files -COMMA:=, -MAKE_ARGS += JDK_DOTVER=$(VERSION_NUMBER_FOUR_POSITIONS) -MAKE_ARGS += JDK_VER=$(subst .,$(COMMA),$(VERSION_NUMBER_FOUR_POSITIONS)) - -NMAKE= MAKEFLAGS= MFLAGS= EXTRA_CFLAGS="$(EXTRA_CFLAGS)" nmake -NOLOGO -ifndef SYSTEM_UNAME - SYSTEM_UNAME := $(shell uname) - export SYSTEM_UNAME -endif - -# Check for CYGWIN -ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME))) - USING_CYGWIN=true -else - USING_CYGWIN=false -endif -# Check for MinGW -ifneq (,$(findstring MINGW,$(SYSTEM_UNAME))) - USING_MINGW=true -endif - -# Windows wants particular paths due to nmake (must be after macros defined) -# It is important that gnumake invokes nmake with C:\\...\\ formated -# strings so that nmake gets C:\...\ style strings. -# Check for CYGWIN -ifeq ($(USING_CYGWIN), true) - ABS_OUTPUTDIR := $(subst /,\\,$(shell /bin/cygpath -m -a "$(OUTPUTDIR)")) - ABS_BOOTDIR := $(subst /,\\,$(shell /bin/cygpath -m -a "$(BOOTDIR)")) - ABS_GAMMADIR := $(subst /,\\,$(shell /bin/cygpath -m -a "$(GAMMADIR)")) - ABS_OS_MAKEFILE := $(shell /bin/cygpath -m -a "$(HS_MAKE_DIR)/$(OSNAME)")/build.make -else ifeq ($(USING_MINGW), true) - ABS_OUTPUTDIR := $(shell $(CD) $(OUTPUTDIR);$(PWD)) - ABS_BOOTDIR := $(shell $(CD) $(BOOTDIR);$(PWD)) - ABS_GAMMADIR := $(shell $(CD) $(GAMMADIR);$(PWD)) - ABS_OS_MAKEFILE := $(shell $(CD) $(HS_MAKE_DIR)/$(OSNAME);$(PWD))/build.make - else - ABS_OUTPUTDIR := $(subst /,\\,$(shell $(CD) $(OUTPUTDIR);$(PWD))) - ABS_BOOTDIR := $(subst /,\\,$(shell $(CD) $(BOOTDIR);$(PWD))) - ABS_GAMMADIR := $(subst /,\\,$(shell $(CD) $(GAMMADIR);$(PWD))) - ABS_OS_MAKEFILE := $(subst /,\\,$(shell $(CD) $(HS_MAKE_DIR)/$(OSNAME);$(PWD))/build.make) -endif - -EXPORT_SERVER_DIR = $(EXPORT_BIN_DIR)/server -EXPORT_CLIENT_DIR = $(EXPORT_BIN_DIR)/client - -ifeq ($(JVM_VARIANT_SERVER),true) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.$(LIBRARY_SUFFIX) - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.diz - else - EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.pdb - EXPORT_LIST += $(EXPORT_SERVER_DIR)/jvm.map - endif - endif -endif -ifeq ($(JVM_VARIANT_CLIENT),true) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/Xusage.txt - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.$(LIBRARY_SUFFIX) - ifeq ($(ENABLE_FULL_DEBUG_SYMBOLS),1) - ifeq ($(ZIP_DEBUGINFO_FILES),1) - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.diz - else - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.pdb - EXPORT_LIST += $(EXPORT_CLIENT_DIR)/jvm.map - endif - endif -endif - -EXPORT_LIST += $(EXPORT_LIB_DIR)/jvm.lib - -# Propagate compiler and tools paths from configure to nmake. -# Need to make sure they contain \\ and not /. -ifneq ($(SPEC),) - ifeq ($(USING_CYGWIN), true) - MAKE_ARGS += CXX="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(CXX)))" - MAKE_ARGS += LD="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(LD)))" - MAKE_ARGS += RC="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(RC)))" - MAKE_ARGS += MT="$(subst /,\\,$(shell /bin/cygpath -s -m -a $(MT)))" - else - MAKE_ARGS += CXX="$(subst /,\\,$(CXX))" - MAKE_ARGS += LD="$(subst /,\\,$(LD))" - MAKE_ARGS += RC="$(subst /,\\,$(RC))" - MAKE_ARGS += MT="$(subst /,\\,$(MT))" - endif -endif - -ifdef OPENJDK - MAKE_ARGS += OPENJDK="$(OPENJDK)" -endif diff --git a/hotspot/make/windows/makefiles/fastdebug.make b/hotspot/make/windows/makefiles/fastdebug.make deleted file mode 100644 index ea6fc41a42a..00000000000 --- a/hotspot/make/windows/makefiles/fastdebug.make +++ /dev/null @@ -1,67 +0,0 @@ -# -# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -HS_INTERNAL_NAME=jvm -HS_FNAME=$(HS_INTERNAL_NAME).dll -AOUT=$(HS_FNAME) -GENERATED=../generated - -# Allow the user to turn off precompiled headers from the command line. -!if "$(USE_PRECOMPILED_HEADER)" != "0" -BUILD_PCH_FILE=_build_pch_file.obj -!endif - -default:: $(BUILD_PCH_FILE) $(AOUT) - -!include ../local.make -!include compile.make - -CXX_FLAGS=$(CXX_FLAGS) $(FASTDEBUG_OPT_OPTION) - -!include $(WorkSpace)/make/windows/makefiles/vm.make -!include local.make - -HS_BUILD_ID=$(HOTSPOT_VERSION_STRING)-fastdebug - -# Force resources to be rebuilt every time -$(Res_Files): FORCE - -# NOTE: Changes in this file was just to give a proper command line when linking -# for use when developing the new build, and should not be integrated. -$(AOUT): $(Res_Files) $(Obj_Files) vm.def - $(LD) $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) -!if "$(MT)" != "" -# The previous link command created a .manifest file that we want to -# insert into the linked artifact so we do not need to track it -# separately. Use ";#2" for .dll and ";#1" for .exe: - $(MT) /manifest $@.manifest /outputresource:$@;#2 -!endif -!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1" -!if "$(ZIP_DEBUGINFO_FILES)" == "1" - $(ZIPEXE) -q $*.diz $*.map $*.pdb - $(RM) $*.map $*.pdb -!endif -!endif - -!include $(WorkSpace)/make/windows/makefiles/shared.make diff --git a/hotspot/make/windows/makefiles/generated.make b/hotspot/make/windows/makefiles/generated.make deleted file mode 100644 index e376c7499cb..00000000000 --- a/hotspot/make/windows/makefiles/generated.make +++ /dev/null @@ -1,60 +0,0 @@ -# -# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -!include ../local.make -!include $(WorkSpace)/make/windows/makefiles/projectcreator.make -!include local.make - -# Pick up rules for building JVMTI (JSR-163) -JvmtiOutDir=jvmtifiles -!include $(WorkSpace)/make/windows/makefiles/jvmti.make - -# Pick up rules for building trace -TraceOutDir=tracefiles -!include $(WorkSpace)/make/windows/makefiles/trace.make - -AdlcOutDir=adfiles - -!if ("$(Variant)" == "compiler2") || ("$(Variant)" == "tiered") -default:: $(AdlcOutDir)/ad_$(Platform_arch_model).cpp $(AdlcOutDir)/dfa_$(Platform_arch_model).cpp $(JvmtiGeneratedFiles) $(TraceGeneratedFiles) buildobjfiles -!else -default:: $(JvmtiGeneratedFiles) $(TraceGeneratedFiles) buildobjfiles -!endif - -buildobjfiles: - @ sh $(WorkSpace)/make/windows/create_obj_files.sh $(Variant) $(Platform_arch) $(Platform_arch_model) $(WorkSpace) . > objfiles.make - -classes/ProjectCreator.class: $(ProjectCreatorSources) - if exist classes rmdir /s /q classes - mkdir classes - $(COMPILE_JAVAC) -classpath $(WorkSpace)\src\share\tools\ProjectCreator -d classes $(ProjectCreatorSources) - -!if ("$(Variant)" == "compiler2") || ("$(Variant)" == "tiered") - -!include $(WorkSpace)/make/windows/makefiles/compile.make -!include $(WorkSpace)/make/windows/makefiles/adlc.make - -!endif - -!include $(WorkSpace)/make/windows/makefiles/shared.make diff --git a/hotspot/make/windows/makefiles/jvmti.make b/hotspot/make/windows/makefiles/jvmti.make deleted file mode 100644 index ce29fe34daa..00000000000 --- a/hotspot/make/windows/makefiles/jvmti.make +++ /dev/null @@ -1,114 +0,0 @@ -# -# Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (jvmti.make) is included from the jvmti.make in the -# build directories. -# -# It knows how to build and run the tools to generate jvmti. - -!include $(WorkSpace)/make/windows/makefiles/rules.make - -# ######################################################################### - -JvmtiSrcDir = $(WorkSpace)/src/share/vm/prims -InterpreterSrcDir = $(WorkSpace)/src/share/vm/interpreter - -JvmtiGeneratedNames = \ - jvmtiEnv.hpp \ - jvmtiEnter.cpp \ - jvmtiEnterTrace.cpp \ - jvmtiEnvRecommended.cpp \ - bytecodeInterpreterWithChecks.cpp \ - jvmti.h \ - -JvmtiEnvFillSource = $(JvmtiSrcDir)/jvmtiEnvFill.java -JvmtiEnvFillClass = $(JvmtiOutDir)/jvmtiEnvFill.class - -JvmtiGenSource = $(JvmtiSrcDir)/jvmtiGen.java -JvmtiGenClass = $(JvmtiOutDir)/jvmtiGen.class - -#Note: JvmtiGeneratedFiles must be kept in sync with JvmtiGeneratedNames by hand. -#Should be equivalent #to "JvmtiGeneratedFiles = $(JvmtiGeneratedNames:%=$(JvmtiOutDir)/%)" -JvmtiGeneratedFiles = \ - $(JvmtiOutDir)/jvmtiEnv.hpp \ - $(JvmtiOutDir)/jvmtiEnter.cpp \ - $(JvmtiOutDir)/jvmtiEnterTrace.cpp \ - $(JvmtiOutDir)/jvmtiEnvRecommended.cpp\ - $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp\ - $(JvmtiOutDir)/jvmti.h \ - -XSLT = $(RUN_JAVA) -classpath $(JvmtiOutDir) jvmtiGen - -# ######################################################################### - -both = $(JvmtiGenClass) $(JvmtiSrcDir)/jvmti.xml $(JvmtiSrcDir)/jvmtiLib.xsl - -default:: - @if not exist $(JvmtiOutDir) mkdir $(JvmtiOutDir) - -$(JvmtiGenClass): $(JvmtiGenSource) - $(COMPILE_JAVAC) -d $(JvmtiOutDir) $(JvmtiGenSource) - -$(JvmtiEnvFillClass): $(JvmtiEnvFillSource) - @$(COMPILE_JAVAC) -d $(JvmtiOutDir) $(JvmtiEnvFillSource) - -$(JvmtiOutDir)/jvmtiEnter.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl - @echo Generating $@ - @$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnter.cpp -PARAM interface jvmti - -$(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp: $(JvmtiGenClass) $(InterpreterSrcDir)/bytecodeInterpreter.cpp $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl - @echo Generating $@ - @$(XSLT) -IN $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xml -XSL $(InterpreterSrcDir)/bytecodeInterpreterWithChecks.xsl -OUT $(JvmtiOutDir)/bytecodeInterpreterWithChecks.cpp - -$(JvmtiOutDir)/jvmtiEnterTrace.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnter.xsl - @echo Generating $@ - @$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnter.xsl -OUT $(JvmtiOutDir)/jvmtiEnterTrace.cpp -PARAM interface jvmti -PARAM trace Trace - -$(JvmtiOutDir)/jvmtiEnvRecommended.cpp: $(both) $(JvmtiSrcDir)/jvmtiEnv.xsl $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiEnvFillClass) - @echo Generating $@ - @$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiEnv.xsl -OUT $(JvmtiOutDir)/jvmtiEnvStub.cpp - @$(RUN_JAVA) -classpath $(JvmtiOutDir) jvmtiEnvFill $(JvmtiSrcDir)/jvmtiEnv.cpp $(JvmtiOutDir)/jvmtiEnvStub.cpp $(JvmtiOutDir)/jvmtiEnvRecommended.cpp - -$(JvmtiOutDir)/jvmtiEnv.hpp: $(both) $(JvmtiSrcDir)/jvmtiHpp.xsl - @echo Generating $@ - @$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiHpp.xsl -OUT $(JvmtiOutDir)/jvmtiEnv.hpp - -$(JvmtiOutDir)/jvmti.h: $(both) $(JvmtiSrcDir)/jvmtiH.xsl - @echo Generating $@ - @$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmtiH.xsl -OUT $(JvmtiOutDir)/jvmti.h - -jvmtidocs: $(JvmtiOutDir)/jvmti.html - -$(JvmtiOutDir)/jvmti.html: $(both) $(JvmtiSrcDir)/jvmti.xsl - @echo Generating $@ - @$(XSLT) -IN $(JvmtiSrcDir)/jvmti.xml -XSL $(JvmtiSrcDir)/jvmti.xsl -OUT $(JvmtiOutDir)/jvmti.html - -# ######################################################################### - -cleanall : - rm $(JvmtiGenClass) $(JvmtiEnvFillClass) $(JvmtiGeneratedFiles) - -# ######################################################################### - -.PHONY: jvmtidocs cleanall diff --git a/hotspot/make/windows/makefiles/product.make b/hotspot/make/windows/makefiles/product.make deleted file mode 100644 index 09e750acc07..00000000000 --- a/hotspot/make/windows/makefiles/product.make +++ /dev/null @@ -1,72 +0,0 @@ -# -# Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -HS_INTERNAL_NAME=jvm -HS_FNAME=$(HS_INTERNAL_NAME).dll -AOUT=$(HS_FNAME) -GENERATED=../generated - -# Allow the user to turn off precompiled headers from the command line. -!if "$(USE_PRECOMPILED_HEADER)" != "0" -BUILD_PCH_FILE=_build_pch_file.obj -!endif - -default:: $(BUILD_PCH_FILE) $(AOUT) - -!include ../local.make -!include compile.make - -CXX_FLAGS=$(CXX_FLAGS) $(PRODUCT_OPT_OPTION) - -RELEASE= - -RC_FLAGS=$(RC_FLAGS) /D "NDEBUG" - -!include $(WorkSpace)/make/windows/makefiles/vm.make -!include local.make - -HS_BUILD_ID=$(HOTSPOT_VERSION_STRING) - -# Force resources to be rebuilt every time -$(Res_Files): FORCE - -# NOTE: Changes in this file was just to give a proper command line when linking -# for use when developing the new build, and should not be integrated. -$(AOUT): $(Res_Files) $(Obj_Files) vm.def - $(LD) $(LD_FLAGS) /out:$@ /implib:$*.lib /def:vm.def $(Obj_Files) $(Res_Files) - -!if "$(MT)" != "" -# The previous link command created a .manifest file that we want to -# insert into the linked artifact so we do not need to track it -# separately. Use ";#2" for .dll and ";#1" for .exe: - $(MT) /manifest $@.manifest /outputresource:$@;#2 -!endif -!if "$(ENABLE_FULL_DEBUG_SYMBOLS)" == "1" -!if "$(ZIP_DEBUGINFO_FILES)" == "1" - $(ZIPEXE) -q $*.diz $*.map $*.pdb - $(RM) $*.map $*.pdb -!endif -!endif - -!include $(WorkSpace)/make/windows/makefiles/shared.make diff --git a/hotspot/make/windows/makefiles/projectcreator.make b/hotspot/make/windows/makefiles/projectcreator.make deleted file mode 100644 index e48a07b14dc..00000000000 --- a/hotspot/make/windows/makefiles/projectcreator.make +++ /dev/null @@ -1,210 +0,0 @@ -# -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -!include $(WorkSpace)/make/windows/makefiles/rules.make - -# This is used externally by both batch and IDE builds, so can't -# reference any of the HOTSPOTWORKSPACE, HOTSPOTBUILDSPACE, -# HOTSPOTRELEASEBINDEST, or HOTSPOTDEBUGBINDEST environment variables. - -ProjectCreatorSources=\ - $(WorkSpace)\src\share\tools\ProjectCreator\ProjectCreator.java \ - $(WorkSpace)\src\share\tools\ProjectCreator\FileTreeCreator.java \ - $(WorkSpace)\src\share\tools\ProjectCreator\FileTreeCreatorVC10.java \ - $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatform.java \ - $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC10.java \ - $(WorkSpace)\src\share\tools\ProjectCreator\Util.java \ - $(WorkSpace)\src\share\tools\ProjectCreator\BuildConfig.java \ - $(WorkSpace)\src\share\tools\ProjectCreator\ArgsParser.java - -# This is only used internally -ProjectCreatorIncludesPRIVATE=\ - -relativeAltSrcInclude src\closed \ - -altRelativeInclude share\vm \ - -altRelativeInclude os\windows\vm \ - -altRelativeInclude os_cpu\windows_$(Platform_arch)\vm \ - -altRelativeInclude cpu\$(Platform_arch)\vm \ - -relativeInclude src\share\vm \ - -relativeInclude src\share\vm\precompiled \ - -relativeInclude src\share\vm\prims\wbtestmethods \ - -relativeInclude src\share\vm\prims \ - -relativeInclude src\os\windows\vm \ - -relativeInclude src\os_cpu\windows_$(Platform_arch)\vm \ - -relativeInclude src\cpu\$(Platform_arch)\vm \ - -absoluteInclude $(HOTSPOTBUILDSPACE)/%f/generated \ - -relativeSrcInclude src \ - -absoluteSrcInclude $(HOTSPOTBUILDSPACE) \ - -ignorePath $(HOTSPOTBUILDSPACE) \ - -ignorePath share\vm\adlc \ - -ignorePath share\vm\shark \ - -ignorePath share\tools \ - -ignorePath solaris \ - -ignorePath posix \ - -ignorePath sparc \ - -ignorePath linux \ - -ignorePath bsd \ - -ignorePath osx \ - -ignorePath arm \ - -ignorePath ppc \ - -ignorePath zero \ - -ignorePath aix \ - -ignorePath aarch64 \ - -ignorePath jdk.vm.ci \ - -hidePath .hg - - -# This is referenced externally by both the IDE and batch builds -ProjectCreatorOptions= - -# This is used externally, but only by the IDE builds, so we can -# reference environment variables which aren't defined in the batch -# build process. - -ProjectCreatorIDEOptions = \ - -useToGeneratePch java.cpp \ - -disablePch os_windows.cpp \ - -disablePch os_windows_$(Platform_arch).cpp \ - -disablePch osThread_windows.cpp \ - -disablePch bytecodeInterpreter.cpp \ - -disablePch bytecodeInterpreterWithChecks.cpp \ - -disablePch getThread_windows_$(Platform_arch).cpp \ - -disablePch_compiler2 opcodes.cpp - -# Common options for the IDE builds for c1, and c2 -ProjectCreatorIDEOptions=\ - $(ProjectCreatorIDEOptions) \ - -sourceBase $(HOTSPOTWORKSPACE) \ - -buildBase $(HOTSPOTBUILDSPACE)\%f\%b \ - -buildSpace $(HOTSPOTBUILDSPACE) \ - -startAt src \ - -compiler $(VcVersion) \ - -projectFileName $(HOTSPOTBUILDSPACE)\$(ProjectFile) \ - -jdkTargetRoot $(HOTSPOTJDKDIST) \ - -define ALIGN_STACK_FRAMES \ - -define VM_LITTLE_ENDIAN \ - -prelink "" "Generating vm.def..." "cd $(HOTSPOTBUILDSPACE)\%f\%b set HOTSPOTMKSHOME=$(HOTSPOTMKSHOME) set JAVA_HOME=$(HOTSPOTJDKDIST) $(HOTSPOTMKSHOME)\sh $(HOTSPOTWORKSPACE)\make\windows\build_vm_def.sh $(LD_VER)" \ - -ignorePath src\jdk.hotspot.agent \ - -ignoreFile jsig.c \ - -ignoreFile jvmtiEnvRecommended.cpp \ - -ignoreFile jvmtiEnvStub.cpp \ - -ignoreFile globalDefinitions_gcc.hpp \ - -ignoreFile globalDefinitions_sparcWorks.hpp \ - -ignoreFile version.rc \ - -ignoreFile Xusage.txt \ - -define TARGET_ARCH_x86 \ - -define TARGET_OS_ARCH_windows_x86 \ - -define TARGET_OS_FAMILY_windows \ - -define TARGET_COMPILER_visCPP \ - -define INCLUDE_TRACE=1 \ - $(ProjectCreatorIncludesPRIVATE) - -# Add in build-specific options -!if "$(BUILDARCH)" == "i486" -ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ - -platformName Win32 \ - -ignorePath x86_64 \ - -ignorePath src\share\vm\jvmci \ - -ignoreFile jvmciCodeInstaller_x86.cpp \ - -define IA32 \ - -define INCLUDE_JVMCI=0 \ - -define TARGET_ARCH_MODEL_x86_32 -!else -!if "$(BUILDARCH)" == "amd64" -ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ - -platformName x64 \ - -ignorePath x86_32 \ - -define AMD64 \ - -define _LP64 \ - -define INCLUDE_JVMCI=1 \ - -define TARGET_ARCH_MODEL_x86_64 \ - -define TARGET_OS_ARCH_MODEL_windows_x86_64 -!endif -!endif - -ProjectCreatorIDEOptionsIgnoreCompiler1=\ - -ignorePath_TARGET compiler1 \ - -ignorePath_TARGET tiered \ - -ignorePath_TARGET c1_ - -ProjectCreatorIDEOptionsIgnoreCompiler2=\ - -ignorePath_TARGET compiler2 \ - -ignorePath_TARGET tiered \ - -ignorePath_TARGET src/share/vm/opto \ - -ignorePath_TARGET src/share/vm/libadt \ - -ignorePath_TARGET adfiles \ - -ignoreFile_TARGET bcEscapeAnalyzer.cpp \ - -ignoreFile_TARGET bcEscapeAnalyzer.hpp \ - -ignorePath_TARGET chaitin \ - -ignorePath_TARGET c2_ \ - -ignorePath_TARGET runtime_ \ - -ignoreFile_TARGET ciTypeFlow.cpp \ - -ignoreFile_TARGET ciTypeFlow.hpp \ - -ignoreFile_TARGET $(Platform_arch_model).ad - -################################################## -# Client(C1) compiler specific options -################################################## -ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ - -define_compiler1 COMPILER1 \ -$(ProjectCreatorIDEOptionsIgnoreCompiler2:TARGET=compiler1) - -################################################## -# Server(C2) compiler specific options -################################################## -#NOTE! This list must be kept in sync with GENERATED_NAMES in adlc.make. -ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ - -define_compiler2 COMPILER2 \ - -additionalFile_compiler2 $(Platform_arch_model).ad \ - -additionalFile_compiler2 ad_$(Platform_arch_model).cpp \ - -additionalFile_compiler2 ad_$(Platform_arch_model).hpp \ - -additionalFile_compiler2 ad_$(Platform_arch_model)_clone.cpp \ - -additionalFile_compiler2 ad_$(Platform_arch_model)_expand.cpp \ - -additionalFile_compiler2 ad_$(Platform_arch_model)_format.cpp \ - -additionalFile_compiler2 ad_$(Platform_arch_model)_gen.cpp \ - -additionalFile_compiler2 ad_$(Platform_arch_model)_misc.cpp \ - -additionalFile_compiler2 ad_$(Platform_arch_model)_peephole.cpp \ - -additionalFile_compiler2 ad_$(Platform_arch_model)_pipeline.cpp \ - -additionalFile_compiler2 adGlobals_$(Platform_arch_model).hpp \ - -additionalFile_compiler2 dfa_$(Platform_arch_model).cpp \ - $(ProjectCreatorIDEOptionsIgnoreCompiler1:TARGET=compiler2) - -# Add in the jvmti (JSR-163) options -# NOTE: do not pull in jvmtiEnvRecommended.cpp. This file is generated -# so the programmer can diff it with jvmtiEnv.cpp to be sure the -# code merge was done correctly (@see jvmti.make and jvmtiEnvFill.java). -# If so, they would then check it in as a new version of jvmtiEnv.cpp. -ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ - -additionalFile jvmtiEnv.hpp \ - -additionalFile jvmtiEnter.cpp \ - -additionalFile jvmtiEnterTrace.cpp \ - -additionalFile jvmti.h \ - -additionalFile bytecodeInterpreterWithChecks.cpp \ - -additionalFile traceEventClasses.hpp \ - -additionalFile traceEventIds.hpp \ -!if "$(OPENJDK)" != "true" - -additionalFile traceRequestables.hpp \ - -additionalFile traceEventControl.hpp \ - -additionalFile traceProducer.cpp \ -!endif - -additionalFile traceTypes.hpp diff --git a/hotspot/make/windows/makefiles/rules.make b/hotspot/make/windows/makefiles/rules.make deleted file mode 100644 index 2bd02379060..00000000000 --- a/hotspot/make/windows/makefiles/rules.make +++ /dev/null @@ -1,63 +0,0 @@ -# -# Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# These are the commands used externally to compile and run. -# The \ are used here for traditional Windows apps and " quoted to get -# past the Unix-like shell: -!ifdef BootStrapDir -RUN_JAVA="$(BootStrapDir)\bin\java" -RUN_JAVAP="$(BootStrapDir)\bin\javap" -RUN_JAVAH="$(BootStrapDir)\bin\javah" -RUN_JAR="$(BootStrapDir)\bin\jar" -COMPILE_JAVAC="$(BootStrapDir)\bin\javac" $(BOOTSTRAP_JAVAC_FLAGS) -COMPILE_RMIC="$(BootStrapDir)\bin\rmic" -BOOT_JAVA_HOME=$(BootStrapDir) -!else -RUN_JAVA=java -RUN_JAVAP=javap -RUN_JAVAH=javah -RUN_JAR=jar -COMPILE_JAVAC=javac $(BOOTSTRAP_JAVAC_FLAGS) -COMPILE_RMIC=rmic -BOOT_JAVA_HOME= -!endif - -# Settings for javac -JAVAC_FLAGS=-g -encoding ascii - -# Prefer BOOT_JDK_SOURCETARGET if it's set (typically by the top build system) -# Fall back to the values here if it's not set (hotspot only builds) -!ifndef BOOT_JDK_SOURCETARGET -BOOTSTRAP_SOURCETARGET=-source 8 -target 8 -!else -BOOTSTRAP_SOURCETARGET=$(BOOT_JDK_SOURCETARGET) -!endif - -BOOTSTRAP_JAVAC_FLAGS=$(JAVAC_FLAGS) $(BOOTSTRAP_SOURCETARGET) - -# VS2012 and VS2013 loads VS10 projects just fine (and will -# upgrade them automatically to VS2012 format). -VcVersion=VC10 -ProjectFile=jvm.vcxproj - diff --git a/hotspot/make/windows/makefiles/sanity.make b/hotspot/make/windows/makefiles/sanity.make deleted file mode 100644 index 515b0bb1b50..00000000000 --- a/hotspot/make/windows/makefiles/sanity.make +++ /dev/null @@ -1,35 +0,0 @@ -# -# Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -!include local.make - -all: checkCL checkLink - -checkCL: - @ if "$(MSC_VER)" NEQ "1600" if "$(MSC_VER)" NEQ "1700" if "$(MSC_VER)" NEQ "1800" \ - echo *** WARNING *** Unsupported cl.exe version detected: $(MSC_VER) ($(RAW_MSC_VER)), only 1600/1700/1800 (Visual Studio 2010/2012/2013) are supported. - -checkLink: - @ if "$(LD_VER)" NEQ "1000" if "$(LD_VER)" NEQ "1100" if "$(LD_VER)" NEQ "1200" \ - echo *** WARNING *** Unsupported link.exe version detected: $(LD_VER) ($(RAW_LD_VER)), only 1000/1100/1200 (Visual Studio 2010/2012/2013) are supported. diff --git a/hotspot/make/windows/makefiles/shared.make b/hotspot/make/windows/makefiles/shared.make deleted file mode 100644 index 06cd75f0e5e..00000000000 --- a/hotspot/make/windows/makefiles/shared.make +++ /dev/null @@ -1,71 +0,0 @@ -# -# Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -DEFAULTACTIONS=clean post_update create - -default:: $(SUBDIRS) - -!ifndef DIR -DIR=. -!endif - -!ifndef CXX -CXX=cl.exe -!endif - - -!ifdef SUBDIRS -# \ is used below because $(MAKE) is nmake here, which expects Windows paths -$(SUBDIRS): FORCE - @if not exist $@ mkdir $@ - @if not exist $@/local.make echo # Empty > $@/local.make - @echo nmake $(ACTION) in $(DIR)/$@ - cd $@ && $(MAKE) -NOLOGO -f $(WorkSpace)\make\windows\makefiles\$@.make $(ACTION) DIR=$(DIR)\$@ BUILD_FLAVOR=$(BUILD_FLAVOR) -!endif - -# Creates the needed directory -create:: -!if "$(DIR)" != "." - @echo mkdir $(DIR) -!endif - -# Epilog to update for generating derived files -post_update:: - -# Removes scrap files -clean:: FORCE - -@rm -f *.OLD *.publish - -# Remove all scrap files and all generated files -pure:: clean - -@rm -f *.OLD *.publish - -$(DEFAULTACTIONS) $(ACTIONS):: -!ifdef SUBDIRS - @$(MAKE) -nologo ACTION=$@ DIR=$(DIR) -!endif - -FORCE: - - diff --git a/hotspot/make/windows/makefiles/top.make b/hotspot/make/windows/makefiles/top.make deleted file mode 100644 index fb9c2a25c2f..00000000000 --- a/hotspot/make/windows/makefiles/top.make +++ /dev/null @@ -1,34 +0,0 @@ -# -# Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -!include local.make - -!ifdef ADLC_ONLY -SUBDIRS=generated -!else -SUBDIRS=generated $(BUILD_FLAVOR) -!endif - -!include $(WorkSpace)/make/windows/makefiles/shared.make - diff --git a/hotspot/make/windows/makefiles/trace.make b/hotspot/make/windows/makefiles/trace.make deleted file mode 100644 index d52391386d0..00000000000 --- a/hotspot/make/windows/makefiles/trace.make +++ /dev/null @@ -1,132 +0,0 @@ -# -# Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# This makefile (trace.make) is included from the trace.make in the -# build directories. -# -# It knows how to build and run the tools to generate trace files. - -!include $(WorkSpace)/make/windows/makefiles/rules.make - -# ######################################################################### - - -TraceAltSrcDir = $(WorkSpace)\src\closed\share\vm\trace -TraceSrcDir = $(WorkSpace)\src\share\vm\trace - -!ifndef OPENJDK -!if EXISTS($(TraceAltSrcDir)) -HAS_ALT_SRC = true -!endif -!endif - -!ifndef OPENJDK -!if EXISTS($(TraceAltSrcDir)) -HAS_ALT_SRC = true -!endif -!endif - -TraceGeneratedNames = \ - traceEventClasses.hpp \ - traceEventIds.hpp \ - traceTypes.hpp - -!ifdef HAS_ALT_SRC -TraceGeneratedNames = $(TraceGeneratedNames) \ - traceRequestables.hpp \ - traceEventControl.hpp -!endif - - -#Note: TraceGeneratedFiles must be kept in sync with TraceGeneratedNames by hand. -#Should be equivalent to "TraceGeneratedFiles = $(TraceGeneratedNames:%=$(TraceOutDir)/%)" -TraceGeneratedFiles = \ - $(TraceOutDir)/traceEventClasses.hpp \ - $(TraceOutDir)/traceEventIds.hpp \ - $(TraceOutDir)/traceTypes.hpp - -!ifdef HAS_ALT_SRC -TraceGeneratedFiles = $(TraceGeneratedFiles) \ - $(TraceOutDir)/traceRequestables.hpp \ - $(TraceOutDir)/traceEventControl.hpp -!endif - -XSLT = $(QUIETLY) $(REMOTE) $(RUN_JAVA) -classpath $(JvmtiOutDir) jvmtiGen - -TraceXml = $(TraceSrcDir)/trace.xml - -!ifdef HAS_ALT_SRC -TraceXml = $(TraceAltSrcDir)/trace.xml -!endif - -XML_DEPS = $(TraceXml) $(TraceSrcDir)/tracetypes.xml \ - $(TraceSrcDir)/trace.dtd $(TraceSrcDir)/xinclude.mod \ - $(TraceSrcDir)/tracerelationdecls.xml $(TraceSrcDir)/traceevents.xml - -!ifdef HAS_ALT_SRC -XML_DEPS = $(XML_DEPS) $(TraceAltSrcDir)/traceeventscustom.xml \ - $(TraceAltSrcDir)/traceeventtypes.xml -!endif - -.PHONY: all clean cleanall - -# ######################################################################### - -default:: - @if not exist $(TraceOutDir) mkdir $(TraceOutDir) - -$(TraceOutDir)/traceEventIds.hpp: $(TraceSrcDir)/traceEventIds.xsl $(XML_DEPS) - @echo Generating $@ - $(XSLT) -IN $(TraceXml) -XSL $(TraceSrcDir)/traceEventIds.xsl -OUT $(TraceOutDir)/traceEventIds.hpp - -$(TraceOutDir)/traceTypes.hpp: $(TraceSrcDir)/traceTypes.xsl $(XML_DEPS) - @echo Generating $@ - $(XSLT) -IN $(TraceXml) -XSL $(TraceSrcDir)/traceTypes.xsl -OUT $(TraceOutDir)/traceTypes.hpp - -!ifndef HAS_ALT_SRC - -$(TraceOutDir)/traceEventClasses.hpp: $(TraceSrcDir)/traceEventClasses.xsl $(XML_DEPS) - @echo Generating OpenJDK $@ - $(XSLT) -IN $(TraceXml) -XSL $(TraceSrcDir)/traceEventClasses.xsl -OUT $(TraceOutDir)/traceEventClasses.hpp - -!else - -$(TraceOutDir)/traceEventClasses.hpp: $(TraceAltSrcDir)/traceEventClasses.xsl $(XML_DEPS) - @echo Generating AltSrc $@ - $(XSLT) -IN $(TraceXml) -XSL $(TraceAltSrcDir)/traceEventClasses.xsl -OUT $(TraceOutDir)/traceEventClasses.hpp - -$(TraceOutDir)/traceRequestables.hpp: $(TraceAltSrcDir)/traceRequestables.xsl $(XML_DEPS) - @echo Generating AltSrc $@ - $(XSLT) -IN $(TraceXml) -XSL $(TraceAltSrcDir)/traceRequestables.xsl -OUT $(TraceOutDir)/traceRequestables.hpp - -$(TraceOutDir)/traceEventControl.hpp: $(TraceAltSrcDir)/traceEventControl.xsl $(XML_DEPS) - @echo Generating AltSrc $@ - $(XSLT) -IN $(TraceXml) -XSL $(TraceAltSrcDir)/traceEventControl.xsl -OUT $(TraceOutDir)/traceEventControl.hpp - -!endif - -# ######################################################################### - -cleanall : - rm $(TraceGeneratedFiles) diff --git a/hotspot/make/windows/makefiles/vm.make b/hotspot/make/windows/makefiles/vm.make deleted file mode 100644 index a1391a04413..00000000000 --- a/hotspot/make/windows/makefiles/vm.make +++ /dev/null @@ -1,428 +0,0 @@ -# -# Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -# Resource file containing VERSIONINFO -Res_Files=.\version.res - -!include ..\generated\objfiles.make - -COMMONSRC=$(WorkSpace)\src -ALTSRC=$(WorkSpace)\src\closed - -!ifdef RELEASE -CXX_FLAGS=$(CXX_FLAGS) /D "PRODUCT" -!else -CXX_FLAGS=$(CXX_FLAGS) /D "ASSERT" -!if "$(BUILDARCH)" == "amd64" -CXX_FLAGS=$(CXX_FLAGS) /homeparams -!endif -!endif - -!if "$(Variant)" == "compiler1" -CXX_FLAGS=$(CXX_FLAGS) /D "COMPILER1" /D INCLUDE_JVMCI=0 -!endif - -!if "$(Variant)" == "compiler2" -CXX_FLAGS=$(CXX_FLAGS) /D "COMPILER2" -!if "$(BUILDARCH)" == "i486" -CXX_FLAGS=$(CXX_FLAGS) /D INCLUDE_JVMCI=0 -!endif -!endif - -!if "$(Variant)" == "tiered" -CXX_FLAGS=$(CXX_FLAGS) /D "COMPILER1" /D "COMPILER2" -!if "$(BUILDARCH)" == "i486" -CXX_FLAGS=$(CXX_FLAGS) /D INCLUDE_JVMCI=0 -!endif -!endif - -!if "$(BUILDARCH)" == "i486" -HOTSPOT_LIB_ARCH=i386 -!else -HOTSPOT_LIB_ARCH=$(BUILDARCH) -!endif - -# The following variables are defined in the generated local.make file. -CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_VERSION_STRING=\"$(HOTSPOT_VERSION_STRING)\"" -CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_MAJOR=$(VERSION_MAJOR)" -CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_MINOR=$(VERSION_MINOR)" -CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_SECURITY=$(VERSION_SECURITY)" -CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_PATCH=$(VERSION_PATCH)" -CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_BUILD=$(VERSION_BUILD)" -CXX_FLAGS=$(CXX_FLAGS) /D "VERSION_STRING=\"$(VERSION_STRING)\"" -CXX_FLAGS=$(CXX_FLAGS) /D "DEBUG_LEVEL=\"$(DEBUG_LEVEL)\"" -CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_LIB_ARCH=\"$(HOTSPOT_LIB_ARCH)\"" -CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_BUILD_TARGET=\"$(BUILD_FLAVOR)\"" -CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_BUILD_USER=\"$(BuildUser)\"" -CXX_FLAGS=$(CXX_FLAGS) /D "HOTSPOT_VM_DISTRO=\"$(HOTSPOT_VM_DISTRO)\"" - -CXX_FLAGS=$(CXX_FLAGS) $(CXX_INCLUDE_DIRS) - -# Define that so jni.h is on correct side -CXX_FLAGS=$(CXX_FLAGS) /D "_JNI_IMPLEMENTATION_" - -!if "$(BUILDARCH)" == "ia64" -STACK_SIZE="/STACK:1048576,262144" -!else -STACK_SIZE= -!endif - -!if "$(BUILDARCH)" == "ia64" -# AsyncGetCallTrace is not supported on IA64 yet -AGCT_EXPORT= -!else -AGCT_EXPORT=/export:AsyncGetCallTrace -!endif - -# If you modify exports below please do the corresponding changes in -# src/share/tools/ProjectCreator/WinGammaPlatformVC7.java -!if "$(BUILDARCH)" == "amd64" -EXPORT_LIST= -!else -EXPORT_LIST=/export:JNI_GetDefaultJavaVMInitArgs \ - /export:JNI_CreateJavaVM \ - /export:JVM_FindClassFromBootLoader \ - /export:JNI_GetCreatedJavaVMs \ - /export:jio_snprintf \ - /export:jio_printf \ - /export:jio_fprintf \ - /export:jio_vfprintf \ - /export:jio_vsnprintf \ - $(AGCT_EXPORT) \ - /export:JVM_GetVersionInfo \ - /export:JVM_InitAgentProperties -!endif - -LD_FLAGS=$(LD_FLAGS) $(STACK_SIZE) /subsystem:windows /dll /base:0x8000000 $(EXPORT_LIST) - -CXX_INCLUDE_DIRS=/I "..\generated" - -!ifndef OPENJDK -!if exists($(ALTSRC)\share\vm) -CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) /I "$(ALTSRC)\share\vm" -!endif - -!if exists($(ALTSRC)\os\windows\vm) -CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) /I "$(ALTSRC)\os\windows\vm" -!endif - -!if exists($(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm) -CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) /I "$(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm" -!endif - -!if exists($(ALTSRC)\cpu\$(Platform_arch)\vm) -CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) /I "$(ALTSRC)\cpu\$(Platform_arch)\vm" -!endif -!endif # OPENJDK - -CXX_INCLUDE_DIRS=$(CXX_INCLUDE_DIRS) \ - /I "$(COMMONSRC)\share\vm" \ - /I "$(COMMONSRC)\share\vm\precompiled" \ - /I "$(COMMONSRC)\share\vm\prims" \ - /I "$(COMMONSRC)\os\windows\vm" \ - /I "$(COMMONSRC)\os_cpu\windows_$(Platform_arch)\vm" \ - /I "$(COMMONSRC)\cpu\$(Platform_arch)\vm" - -CXX_DONT_USE_PCH=/D DONT_USE_PRECOMPILED_HEADER - -!if "$(USE_PRECOMPILED_HEADER)" != "0" -CXX_USE_PCH=/Fp"vm.pch" /Yu"precompiled.hpp" -!if "$(MSC_VER)" > "1600" -# VS2012 requires this object file to be listed: -LD_FLAGS=$(LD_FLAGS) _build_pch_file.obj -!endif -!else -CXX_USE_PCH=$(CXX_DONT_USE_PCH) -!endif - -# Where to find the source code for the virtual machine (is this used?) -VM_PATH=../generated -VM_PATH=$(VM_PATH);../generated/adfiles -VM_PATH=$(VM_PATH);../generated/jvmtifiles -VM_PATH=$(VM_PATH);../generated/tracefiles -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/c1 -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/jvmci -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/compiler -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/code -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/interpreter -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/ci -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/classfile -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/gc/parallel -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/gc/shared -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/gc/serial -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/gc/cms -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/gc/g1 -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/asm -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/logging -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/memory -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/oops -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/prims -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/prims/wbtestmethods -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/runtime -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/services -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/trace -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/utilities -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/libadt -VM_PATH=$(VM_PATH);$(WorkSpace)/src/os/windows/vm -VM_PATH=$(VM_PATH);$(WorkSpace)/src/os_cpu/windows_$(Platform_arch)/vm -VM_PATH=$(VM_PATH);$(WorkSpace)/src/cpu/$(Platform_arch)/vm -VM_PATH=$(VM_PATH);$(WorkSpace)/src/share/vm/opto - -!ifndef OPENJDK -!if exists($(ALTSRC)\share\vm\jfr) -VM_PATH=$(VM_PATH);$(ALTSRC)/share/vm/jfr -VM_PATH=$(VM_PATH);$(ALTSRC)/share/vm/jfr/buffers -!endif -!endif # OPENJDK - -VM_PATH={$(VM_PATH)} - -# Special case files not using precompiled header files. - -c1_RInfo_$(Platform_arch).obj: $(WorkSpace)\src\cpu\$(Platform_arch)\vm\c1_RInfo_$(Platform_arch).cpp - $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\cpu\$(Platform_arch)\vm\c1_RInfo_$(Platform_arch).cpp - -os_windows.obj: $(WorkSpace)\src\os\windows\vm\os_windows.cpp - $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os\windows\vm\os_windows.cpp - -os_windows_$(Platform_arch).obj: $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\os_windows_$(Platform_arch).cpp - $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\os_windows_$(Platform_arch).cpp - -osThread_windows.obj: $(WorkSpace)\src\os\windows\vm\osThread_windows.cpp - $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os\windows\vm\osThread_windows.cpp - -conditionVar_windows.obj: $(WorkSpace)\src\os\windows\vm\conditionVar_windows.cpp - $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os\windows\vm\conditionVar_windows.cpp - -getThread_windows_$(Platform_arch).obj: $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\getThread_windows_$(Platform_arch).cpp - $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\os_cpu\windows_$(Platform_arch)\vm\getThread_windows_$(Platform_arch).cpp - -opcodes.obj: $(WorkSpace)\src\share\vm\opto\opcodes.cpp - $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\share\vm\opto\opcodes.cpp - -bytecodeInterpreter.obj: $(WorkSpace)\src\share\vm\interpreter\bytecodeInterpreter.cpp - $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c $(WorkSpace)\src\share\vm\interpreter\bytecodeInterpreter.cpp - -bytecodeInterpreterWithChecks.obj: ..\generated\jvmtifiles\bytecodeInterpreterWithChecks.cpp - $(CXX) $(CXX_FLAGS) $(CXX_DONT_USE_PCH) /c ..\generated\jvmtifiles\bytecodeInterpreterWithChecks.cpp - -# Default rules for the Virtual Machine -{$(COMMONSRC)\share\vm\c1}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\compiler}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\code}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\interpreter}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\ci}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\classfile}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\jvmci}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\gc\parallel}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\gc\shared}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\gc\serial}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\gc\cms}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\gc\g1}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\asm}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\logging}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\memory}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\oops}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\prims}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\prims\wbtestmethods}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\runtime}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\services}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\trace}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\utilities}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\libadt}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\share\vm\opto}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\os\windows\vm}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -# This guy should remain a single colon rule because -# otherwise we can't specify the output filename. -# NOTE: Changes in this file was just to give a proper command line when linking -# for use when developing the new build, and should not be integrated. -{$(COMMONSRC)\os\windows\vm}.rc.res: - $(RC) $(RC_FLAGS) /fo"$@" $< - -{$(COMMONSRC)\cpu\$(Platform_arch)\vm}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(COMMONSRC)\os_cpu\windows_$(Platform_arch)\vm}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -!ifndef OPENJDK -{$(ALTSRC)\share\vm\c1}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\compiler}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\code}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\interpreter}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\ci}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\classfile}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\gc\parallel}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\gc\shared}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\gc\serial}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\gc\cms}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\gc\g1}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\asm}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\logging}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\memory}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\oops}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\prims}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\prims\wbtestmethods}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\runtime}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\services}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\trace}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\utilities}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\libadt}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\opto}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\os\windows\vm}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -# otherwise we can't specify the output filename. -{$(ALTSRC)\os\windows\vm}.rc.res: - @$(RC) $(RC_FLAGS) /fo"$@" $< - -{$(ALTSRC)\cpu\$(Platform_arch)\vm}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\os_cpu\windows_$(Platform_arch)\vm}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\jfr}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{$(ALTSRC)\share\vm\jfr\buffers}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< -!endif - -{..\generated\incls}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{..\generated\adfiles}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{..\generated\jvmtifiles}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -{..\generated\tracefiles}.cpp.obj:: - $(CXX) $(CXX_FLAGS) $(CXX_USE_PCH) /c $< - -default:: - -_build_pch_file.obj: - @echo #include "precompiled.hpp" > ../generated/_build_pch_file.cpp - $(CXX) $(CXX_FLAGS) /Fp"vm.pch" /Yc"precompiled.hpp" /c ../generated/_build_pch_file.cpp - -vm.def: $(Obj_Files) - sh $(WorkSpace)/make/windows/build_vm_def.sh diff --git a/hotspot/make/windows/projectfiles/common/Makefile b/hotspot/make/windows/projectfiles/common/Makefile deleted file mode 100644 index 3fe5abc938e..00000000000 --- a/hotspot/make/windows/projectfiles/common/Makefile +++ /dev/null @@ -1,132 +0,0 @@ -# -# Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -!ifdef LOCAL_MAKE -!include $(LOCAL_MAKE) -!endif - - -WorkSpace=$(HOTSPOTWORKSPACE) - -!ifdef ALT_BOOTDIR -BootStrapDir=$(ALT_BOOTDIR) -!else -!ifdef BOOTDIR -BootStrapDir=$(BOOTDIR) -!else -!ifdef JAVA_HOME -BootStrapDir=$(JAVA_HOME) -!else -!ifdef HOTSPOTJDKDIST -BootStrapDir=$(HOTSPOTJDKDIST) -!endif -!endif -!endif -!endif - -# if hotspot-only build and/or OPENJDK isn't passed down, need to set OPENJDK -!ifndef OPENJDK -!if !exists($(WorkSpace)\src\closed) -OPENJDK=true -!endif -!endif - - -!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/projectcreator.make -!include $(WorkSpace)/make/windows/makefiles/compile.make - -# Pick up rules for building JVMTI (JSR-163) -JvmtiOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\jvmtifiles -!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/jvmti.make - -# Pick up rules for building trace -TraceOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\tracefiles -!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/trace.make - -!if "$(Variant)" == "compiler2" -# Pick up rules for building adlc -!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/adlc.make -!endif - -!if "$(Variant)" == "tiered" -# Pick up rules for building adlc -!include $(HOTSPOTWORKSPACE)/make/windows/makefiles/adlc.make -!endif - -HS_INTERNAL_NAME=jvm - -default:: $(AdditionalTargets) $(JvmtiGeneratedFiles) $(TraceGeneratedFiles) - -!include $(HOTSPOTWORKSPACE)/make/jdk_version - -VERSION_MAJOR=$(STANDALONE_JDK_MAJOR_VER) -VERSION_MINOR=$(STANDALONE_JDK_MINOR_VER) -VERSION_SECURITY=$(STANDALONE_JDK_SECURITY_VER) -VERSION_PATCH=$(STANDALONE_JDK_PATCH_VER) - -!if "$(VERSION_BUILD)" == "" -VERSION_BUILD=0 -!endif - -!if "$(VERSION_OPT)" != "" -HOTSPOT_PRE = internal-$(VERSION_OPT) -!else -HOTSPOT_PRE = internal -!endif -!if "$(VERSION_STRING)" == "" -VERSION_STRING="\\\"$(VERSION_MAJOR)-$(HOTSPOT_PRE)+$(VERSION_BUILD)-$(USERNAME).vsbuild\\\"" -!endif -HOTSPOT_VERSION_STRING=$(VERSION_STRING) - -# Define HOTSPOT_VM_DISTRO if HOTSPOT_VM_DISTRO is set, -# and if it is not see if we have the src/closed directory -!if "$(HOTSPOT_VM_DISTRO)" != "" -HOTSPOT_VM_DISTRO=$(HOTSPOT_VM_DISTRO) -!else -!if exists($(HOTSPOTWORKSPACE)\src\closed) -HOTSPOT_VM_DISTRO="\\\"Java HotSpot(TM)\\\"" -!else -HOTSPOT_VM_DISTRO="\\\"OpenJDK\\\"" -!endif - -!endif - - - -ReleaseOptions = -define HOTSPOT_VM_DISTRO=$(HOTSPOT_VM_DISTRO) -define HOTSPOT_VERSION_STRING=$(HOTSPOT_VERSION_STRING) -define VERSION_MAJOR=$(VERSION_MAJOR) -define VERSION_MINOR=$(VERSION_MINOR) -define VERSION_SECURITY=$(VERSION_SECURITY) -define VERSION_PATCH=$(VERSION_PATCH) -define VERSION_BUILD=$(VERSION_BUILD) -define VERSION_STRING=$(VERSION_STRING) -ProjectCreatorIDEOptions = $(ProjectCreatorIDEOptions) $(ReleaseOptions) - -$(HOTSPOTBUILDSPACE)/$(ProjectFile): $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class - @$(RUN_JAVA) -Djava.class.path="$(HOTSPOTBUILDSPACE)/classes" ProjectCreator WinGammaPlatform$(VcVersion) $(ProjectCreatorIDEOptions) - -clean: - @rm -rf $(HOTSPOTBUILDSPACE)/classes - @rm -r $(HOTSPOTBUILDSPACE)/$(ProjectFile) - -$(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class: $(ProjectCreatorSources) - @if exist $(HOTSPOTBUILDSPACE)\classes rmdir /s /q $(HOTSPOTBUILDSPACE)\classes - @mkdir $(HOTSPOTBUILDSPACE)\classes - @$(COMPILE_JAVAC) -classpath $(HOTSPOTWORKSPACE)\src\share\tools\ProjectCreator -d $(HOTSPOTBUILDSPACE)/classes $(ProjectCreatorSources) - -FORCE: diff --git a/hotspot/make/windows/projectfiles/compiler1/Makefile b/hotspot/make/windows/projectfiles/compiler1/Makefile deleted file mode 100644 index 183a27647dd..00000000000 --- a/hotspot/make/windows/projectfiles/compiler1/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -!include ../local.make - -!include $(HOTSPOTWORKSPACE)/make/windows/projectfiles/common/Makefile diff --git a/hotspot/make/windows/projectfiles/compiler1/vm.def b/hotspot/make/windows/projectfiles/compiler1/vm.def deleted file mode 100644 index b450e81fd01..00000000000 --- a/hotspot/make/windows/projectfiles/compiler1/vm.def +++ /dev/null @@ -1,7 +0,0 @@ -; -; This .DEF file is a placeholder for one which is automatically -; generated during the build process. See -; make\windows\build_vm_def.sh and -; make\windows\makefiles\projectcreator.make (esp. the "-prelink" -; options). -; diff --git a/hotspot/make/windows/projectfiles/compiler1/vm.dsw b/hotspot/make/windows/projectfiles/compiler1/vm.dsw deleted file mode 100644 index 934f51afdb3..00000000000 --- a/hotspot/make/windows/projectfiles/compiler1/vm.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "vm"=.\vm.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsp b/hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsp deleted file mode 100644 index 557cce42c76..00000000000 --- a/hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsp +++ /dev/null @@ -1,142 +0,0 @@ -# Microsoft Developer Studio Project File - Name="ADLCompiler" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=ADLCompiler - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "ADLCompiler.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "ADLCompiler.mak" CFG="ADLCompiler - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "ADLCompiler - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "ADLCompiler - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "ADLCompiler - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\adlc\Release" -# PROP Intermediate_Dir ".\adlc\Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "." /I "$(HotSpotWorkSpace)\src\share\vm\opto" /I "$(HotSpotWorkSpace)\src\share\vm\prims" /I "$(HotSpotWorkSpace)\src\share\vm\lookup" /I "$(HotSpotWorkSpace)\src\share\vm\interpreter" /I "$(HotSpotWorkSpace)\src\share\vm\asm" /I "$(HotSpotWorkSpace)\src\share\vm\compiler" /I "$(HotSpotWorkSpace)\src\share\vm\utilities" /I "$(HotSpotWorkSpace)\src\share\vm\code" /I "$(HotSpotWorkSpace)\src\share\vm\oops" /I "$(HotSpotWorkSpace)\src\share\vm\runtime" /I "$(HotSpotWorkSpace)\src\share\vm\memory" /I "$(HotSpotWorkSpace)\src\share\vm\libadt" /I "$(HotSpotWorkSpace)\src\cpu\i486\vm" /I "$(HotSpotWorkSpace)\src\os\win32\vm" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /c -# SUBTRACT CPP /YX /Yc /Yu -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo /o".\adlc\Release\adlc.bsc" -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:".\bin\adlc.exe" - -!ELSEIF "$(CFG)" == "ADLCompiler - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir ".\adlc\Debug" -# PROP Intermediate_Dir ".\adlc\Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /ML /W3 /WX /Gm /GX /Zi /Od /I "." /I "$(HotSpotWorkSpace)\src\share\vm\opto" /I "$(HotSpotWorkSpace)\src\share\vm\prims" /I "$(HotSpotWorkSpace)\src\share\vm\lookup" /I "$(HotSpotWorkSpace)\src\share\vm\interpreter" /I "$(HotSpotWorkSpace)\src\share\vm\asm" /I "$(HotSpotWorkSpace)\src\share\vm\compiler" /I "$(HotSpotWorkSpace)\src\share\vm\utilities" /I "$(HotSpotWorkSpace)\src\share\vm\code" /I "$(HotSpotWorkSpace)\src\share\vm\oops" /I "$(HotSpotWorkSpace)\src\share\vm\runtime" /I "$(HotSpotWorkSpace)\src\share\vm\memory" /I "$(HotSpotWorkSpace)\src\share\vm\libadt" /I "$(HotSpotWorkSpace)\src\cpu\i486\vm" /I "$(HotSpotWorkSpace)\src\os\win32\vm" /D "WIN32" /D "_WINDOWS" /D "ASSERT" /Fr /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /o".\adlc\Debug\adlc.bsc" -# SUBTRACT BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 /out:".\bin\adlc.exe" - -!ENDIF - -# Begin Target - -# Name "ADLCompiler - Win32 Release" -# Name "ADLCompiler - Win32 Debug" -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\adlparse.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\archDesc.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\arena.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\dfa.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\dict2.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\filebuff.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\forms.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\formsopt.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\formssel.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\main.cpp" -# SUBTRACT CPP /YX /Yc -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\opto\opcodes.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\output_c.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\output_h.cpp" -# End Source File -# End Target -# End Project - \ No newline at end of file diff --git a/hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsw b/hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsw deleted file mode 100644 index 0ad5370ed81..00000000000 --- a/hotspot/make/windows/projectfiles/compiler2/ADLCompiler.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "ADLCompiler"=".\ADLCompiler.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/hotspot/make/windows/projectfiles/compiler2/Makefile b/hotspot/make/windows/projectfiles/compiler2/Makefile deleted file mode 100644 index 1df97d232a8..00000000000 --- a/hotspot/make/windows/projectfiles/compiler2/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -!include ../local.make -AdlcOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\adfiles -AdditionalTargets=$(AdlcOutDir)\ad_$(Platform_arch_model).cpp $(AdlcOutDir)\dfa_$(Platform_arch_model).cpp - -!include $(HOTSPOTWORKSPACE)/make/windows/projectfiles/common/Makefile diff --git a/hotspot/make/windows/projectfiles/compiler2/vm.def b/hotspot/make/windows/projectfiles/compiler2/vm.def deleted file mode 100644 index b450e81fd01..00000000000 --- a/hotspot/make/windows/projectfiles/compiler2/vm.def +++ /dev/null @@ -1,7 +0,0 @@ -; -; This .DEF file is a placeholder for one which is automatically -; generated during the build process. See -; make\windows\build_vm_def.sh and -; make\windows\makefiles\projectcreator.make (esp. the "-prelink" -; options). -; diff --git a/hotspot/make/windows/projectfiles/compiler2/vm.dsw b/hotspot/make/windows/projectfiles/compiler2/vm.dsw deleted file mode 100644 index 26aab5c3b16..00000000000 --- a/hotspot/make/windows/projectfiles/compiler2/vm.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 5.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "vm"=.\vm.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/hotspot/make/windows/projectfiles/core/Makefile b/hotspot/make/windows/projectfiles/core/Makefile deleted file mode 100644 index 5b23a8467cb..00000000000 --- a/hotspot/make/windows/projectfiles/core/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -!include ../local.make - -!include $(HOTSPOTWORKSPACE)/make/windows/projectfiles/common/Makefile diff --git a/hotspot/make/windows/projectfiles/core/vm.def b/hotspot/make/windows/projectfiles/core/vm.def deleted file mode 100644 index b450e81fd01..00000000000 --- a/hotspot/make/windows/projectfiles/core/vm.def +++ /dev/null @@ -1,7 +0,0 @@ -; -; This .DEF file is a placeholder for one which is automatically -; generated during the build process. See -; make\windows\build_vm_def.sh and -; make\windows\makefiles\projectcreator.make (esp. the "-prelink" -; options). -; diff --git a/hotspot/make/windows/projectfiles/core/vm.dsw b/hotspot/make/windows/projectfiles/core/vm.dsw deleted file mode 100644 index 934f51afdb3..00000000000 --- a/hotspot/make/windows/projectfiles/core/vm.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "vm"=.\vm.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsp b/hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsp deleted file mode 100644 index 557cce42c76..00000000000 --- a/hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsp +++ /dev/null @@ -1,142 +0,0 @@ -# Microsoft Developer Studio Project File - Name="ADLCompiler" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=ADLCompiler - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "ADLCompiler.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "ADLCompiler.mak" CFG="ADLCompiler - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "ADLCompiler - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "ADLCompiler - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "ADLCompiler - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir ".\adlc\Release" -# PROP Intermediate_Dir ".\adlc\Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /I "." /I "$(HotSpotWorkSpace)\src\share\vm\opto" /I "$(HotSpotWorkSpace)\src\share\vm\prims" /I "$(HotSpotWorkSpace)\src\share\vm\lookup" /I "$(HotSpotWorkSpace)\src\share\vm\interpreter" /I "$(HotSpotWorkSpace)\src\share\vm\asm" /I "$(HotSpotWorkSpace)\src\share\vm\compiler" /I "$(HotSpotWorkSpace)\src\share\vm\utilities" /I "$(HotSpotWorkSpace)\src\share\vm\code" /I "$(HotSpotWorkSpace)\src\share\vm\oops" /I "$(HotSpotWorkSpace)\src\share\vm\runtime" /I "$(HotSpotWorkSpace)\src\share\vm\memory" /I "$(HotSpotWorkSpace)\src\share\vm\libadt" /I "$(HotSpotWorkSpace)\src\cpu\i486\vm" /I "$(HotSpotWorkSpace)\src\os\win32\vm" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FR /FD /c -# SUBTRACT CPP /YX /Yc /Yu -# ADD BASE RSC /l 0x409 /d "NDEBUG" -# ADD RSC /l 0x409 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo /o".\adlc\Release\adlc.bsc" -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:".\bin\adlc.exe" - -!ELSEIF "$(CFG)" == "ADLCompiler - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir ".\adlc\Debug" -# PROP Intermediate_Dir ".\adlc\Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /ML /W3 /WX /Gm /GX /Zi /Od /I "." /I "$(HotSpotWorkSpace)\src\share\vm\opto" /I "$(HotSpotWorkSpace)\src\share\vm\prims" /I "$(HotSpotWorkSpace)\src\share\vm\lookup" /I "$(HotSpotWorkSpace)\src\share\vm\interpreter" /I "$(HotSpotWorkSpace)\src\share\vm\asm" /I "$(HotSpotWorkSpace)\src\share\vm\compiler" /I "$(HotSpotWorkSpace)\src\share\vm\utilities" /I "$(HotSpotWorkSpace)\src\share\vm\code" /I "$(HotSpotWorkSpace)\src\share\vm\oops" /I "$(HotSpotWorkSpace)\src\share\vm\runtime" /I "$(HotSpotWorkSpace)\src\share\vm\memory" /I "$(HotSpotWorkSpace)\src\share\vm\libadt" /I "$(HotSpotWorkSpace)\src\cpu\i486\vm" /I "$(HotSpotWorkSpace)\src\os\win32\vm" /D "WIN32" /D "_WINDOWS" /D "ASSERT" /Fr /FD /c -# ADD BASE RSC /l 0x409 -# ADD RSC /l 0x409 -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /o".\adlc\Debug\adlc.bsc" -# SUBTRACT BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib /nologo /subsystem:console /debug /machine:I386 /out:".\bin\adlc.exe" - -!ENDIF - -# Begin Target - -# Name "ADLCompiler - Win32 Release" -# Name "ADLCompiler - Win32 Debug" -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\adlparse.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\archDesc.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\arena.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\dfa.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\dict2.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\filebuff.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\forms.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\formsopt.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\formssel.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\main.cpp" -# SUBTRACT CPP /YX /Yc -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\opto\opcodes.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\output_c.cpp" -# End Source File -# Begin Source File - -SOURCE="$(HotSpotWorkSpace)\src\share\vm\adlc\output_h.cpp" -# End Source File -# End Target -# End Project - \ No newline at end of file diff --git a/hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsw b/hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsw deleted file mode 100644 index 0ad5370ed81..00000000000 --- a/hotspot/make/windows/projectfiles/tiered/ADLCompiler.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "ADLCompiler"=".\ADLCompiler.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/hotspot/make/windows/projectfiles/tiered/Makefile b/hotspot/make/windows/projectfiles/tiered/Makefile deleted file mode 100644 index 5398cb99d46..00000000000 --- a/hotspot/make/windows/projectfiles/tiered/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# -# - -!include ../local.make -AdlcOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\adfiles -AdditionalTargets=$(AdlcOutDir)\ad_$(Platform_arch_model).cpp $(AdlcOutDir)\dfa_$(Platform_arch_model).cpp - -!include $(HOTSPOTWORKSPACE)/make/windows/projectfiles/common/Makefile diff --git a/hotspot/make/windows/projectfiles/tiered/vm.def b/hotspot/make/windows/projectfiles/tiered/vm.def deleted file mode 100644 index b450e81fd01..00000000000 --- a/hotspot/make/windows/projectfiles/tiered/vm.def +++ /dev/null @@ -1,7 +0,0 @@ -; -; This .DEF file is a placeholder for one which is automatically -; generated during the build process. See -; make\windows\build_vm_def.sh and -; make\windows\makefiles\projectcreator.make (esp. the "-prelink" -; options). -; diff --git a/hotspot/make/windows/projectfiles/tiered/vm.dsw b/hotspot/make/windows/projectfiles/tiered/vm.dsw deleted file mode 100644 index 26aab5c3b16..00000000000 --- a/hotspot/make/windows/projectfiles/tiered/vm.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 5.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "vm"=.\vm.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - -- GitLab From 09add351555f32154c47fded7004b9fb46074576 Mon Sep 17 00:00:00 2001 From: Rachel Protacio Date: Tue, 26 Apr 2016 09:08:12 -0400 Subject: [PATCH 213/400] 8152844: JVM InstanceKlass Methods For Obtaining Package/Module Should Be Moved to Klass Converted package() and module() functions to pure virtual functions of Klass Reviewed-by: dholmes, coleenp, lfoltan, hseigel --- hotspot/src/share/vm/oops/instanceKlass.cpp | 2 +- hotspot/src/share/vm/oops/instanceKlass.hpp | 2 +- hotspot/src/share/vm/oops/klass.hpp | 9 +++- hotspot/src/share/vm/oops/objArrayKlass.cpp | 21 +++++--- hotspot/src/share/vm/oops/objArrayKlass.hpp | 3 ++ hotspot/src/share/vm/oops/typeArrayKlass.cpp | 13 ++++- hotspot/src/share/vm/oops/typeArrayKlass.hpp | 3 ++ hotspot/src/share/vm/runtime/reflection.cpp | 26 ++++------ .../modules/getModuleJNI/GetModule.java | 52 ++++++++++++++++++- 9 files changed, 99 insertions(+), 32 deletions(-) diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index b055f6e534f..997110cb583 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -2296,7 +2296,7 @@ bool InstanceKlass::is_same_class_package(const Klass* class2) const { PackageEntry* classpkg2; if (class2->is_instance_klass()) { classloader2 = class2->class_loader(); - classpkg2 = InstanceKlass::cast(class2)->package(); + classpkg2 = class2->package(); } else { assert(class2->is_typeArray_klass(), "should be type array"); classloader2 = NULL; diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 4fc5711a925..1c46d5bed5a 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -27,9 +27,9 @@ #include "classfile/classLoader.hpp" #include "classfile/classLoaderData.hpp" +#include "classfile/moduleEntry.hpp" #include "classfile/packageEntry.hpp" #include "gc/shared/specialized_oop_closures.hpp" -#include "classfile/moduleEntry.hpp" #include "logging/logLevel.hpp" #include "memory/referenceType.hpp" #include "oops/annotations.hpp" diff --git a/hotspot/src/share/vm/oops/klass.hpp b/hotspot/src/share/vm/oops/klass.hpp index 14675aa81ee..b6181d4b877 100644 --- a/hotspot/src/share/vm/oops/klass.hpp +++ b/hotspot/src/share/vm/oops/klass.hpp @@ -52,11 +52,13 @@ template class Array; template class GrowableArray; class ClassLoaderData; +class fieldDescriptor; +class KlassSizeStats; class klassVtable; +class ModuleEntry; +class PackageEntry; class ParCompactionManager; class PSPromotionManager; -class KlassSizeStats; -class fieldDescriptor; class vtableEntry; class Klass : public Metadata { @@ -274,6 +276,9 @@ protected: _shared_class_path_index = index; }; + // Obtain the module or package for this class + virtual ModuleEntry* module() const = 0; + virtual PackageEntry* package() const = 0; protected: // internal accessors void set_subklass(Klass* s); diff --git a/hotspot/src/share/vm/oops/objArrayKlass.cpp b/hotspot/src/share/vm/oops/objArrayKlass.cpp index 7f090471741..1abcc152fc6 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp @@ -23,6 +23,8 @@ */ #include "precompiled.hpp" +#include "classfile/moduleEntry.hpp" +#include "classfile/packageEntry.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" @@ -135,14 +137,7 @@ Klass* ObjArrayKlass::allocate_objArray_klass(ClassLoaderData* loader_data, // GC walks these as strong roots. loader_data->add_class(oak); - // The array is defined in the module of its bottom class - Klass* bottom_klass = oak->bottom_klass(); - ModuleEntry* module; - if (bottom_klass->is_instance_klass()) { - module = InstanceKlass::cast(bottom_klass)->module(); - } else { - module = ModuleEntryTable::javabase_module(); - } + ModuleEntry* module = oak->module(); assert(module != NULL, "No module entry for array"); // Call complete_create_array_klass after all instance variables has been initialized. @@ -422,6 +417,16 @@ jint ObjArrayKlass::compute_modifier_flags(TRAPS) const { | (JVM_ACC_ABSTRACT | JVM_ACC_FINAL); } +ModuleEntry* ObjArrayKlass::module() const { + assert(bottom_klass() != NULL, "ObjArrayKlass returned unexpected NULL bottom_klass"); + // The array is defined in the module of its bottom class + return bottom_klass()->module(); +} + +PackageEntry* ObjArrayKlass::package() const { + assert(bottom_klass() != NULL, "ObjArrayKlass returned unexpected NULL bottom_klass"); + return bottom_klass()->package(); +} // Printing diff --git a/hotspot/src/share/vm/oops/objArrayKlass.hpp b/hotspot/src/share/vm/oops/objArrayKlass.hpp index eabbec56c96..c2d1f7930ba 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.hpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.hpp @@ -54,6 +54,9 @@ class ObjArrayKlass : public ArrayKlass { void set_bottom_klass(Klass* k) { _bottom_klass = k; } Klass** bottom_klass_addr() { return &_bottom_klass; } + ModuleEntry* module() const; + PackageEntry* package() const; + // Compiler/Interpreter offset static ByteSize element_klass_offset() { return in_ByteSize(offset_of(ObjArrayKlass, _element_klass)); } diff --git a/hotspot/src/share/vm/oops/typeArrayKlass.cpp b/hotspot/src/share/vm/oops/typeArrayKlass.cpp index 3fa977001a0..76b2bb8e6b9 100644 --- a/hotspot/src/share/vm/oops/typeArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/typeArrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,8 @@ */ #include "precompiled.hpp" +#include "classfile/moduleEntry.hpp" +#include "classfile/packageEntry.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" @@ -341,3 +343,12 @@ void TypeArrayKlass::oop_print_on(oop obj, outputStream* st) { const char* TypeArrayKlass::internal_name() const { return Klass::external_name(); } + +// A TypeArrayKlass is an array of a primitive type, its defining module is java.base +ModuleEntry* TypeArrayKlass::module() const { + return ModuleEntryTable::javabase_module(); +} + +PackageEntry* TypeArrayKlass::package() const { + return NULL; +} diff --git a/hotspot/src/share/vm/oops/typeArrayKlass.hpp b/hotspot/src/share/vm/oops/typeArrayKlass.hpp index 7f07e4fb482..031afe8af1b 100644 --- a/hotspot/src/share/vm/oops/typeArrayKlass.hpp +++ b/hotspot/src/share/vm/oops/typeArrayKlass.hpp @@ -150,6 +150,9 @@ class TypeArrayKlass : public ArrayKlass { public: const char* internal_name() const; + + ModuleEntry* module() const; + PackageEntry* package() const; }; #endif // SHARE_VM_OOPS_TYPEARRAYKLASS_HPP diff --git a/hotspot/src/share/vm/runtime/reflection.cpp b/hotspot/src/share/vm/runtime/reflection.cpp index 625d55830de..761ced6907a 100644 --- a/hotspot/src/share/vm/runtime/reflection.cpp +++ b/hotspot/src/share/vm/runtime/reflection.cpp @@ -502,17 +502,16 @@ Reflection::VerifyClassAccessResults Reflection::verify_class_access( } // Find the module entry for current_class, the accessor - ModuleEntry* module_from = InstanceKlass::cast(current_class)->module(); + ModuleEntry* module_from = current_class->module(); // Find the module entry for new_class, the accessee if (new_class->is_objArray_klass()) { new_class = ObjArrayKlass::cast(new_class)->bottom_klass(); } - if (!new_class->is_instance_klass()) { - // Everyone can read a typearray. - assert (new_class->is_typeArray_klass(), "Unexpected klass type"); + if (new_class->is_typeArray_klass()) { + // A TypeArray's defining module is java.base, access to the TypeArray is allowed return ACCESS_OK; } - ModuleEntry* module_to = InstanceKlass::cast(new_class)->module(); + ModuleEntry* module_to = new_class->module(); // both in same (possibly unnamed) module if (module_from == module_to) { @@ -532,7 +531,7 @@ Reflection::VerifyClassAccessResults Reflection::verify_class_access( return MODULE_NOT_READABLE; } - PackageEntry* package_to = InstanceKlass::cast(new_class)->package(); + PackageEntry* package_to = new_class->package(); assert(package_to != NULL, "can not obtain new_class' package"); // Once readability is established, if module_to exports T unqualifiedly, @@ -570,20 +569,13 @@ char* Reflection::verify_class_access_msg(const Klass* current_class, char * msg = NULL; if (result != OTHER_PROBLEM && new_class != NULL && current_class != NULL) { // Find the module entry for current_class, the accessor - ModuleEntry* module_from = InstanceKlass::cast(current_class)->module(); + ModuleEntry* module_from = current_class->module(); const char * module_from_name = module_from->is_named() ? module_from->name()->as_C_string() : UNNAMED_MODULE; const char * current_class_name = current_class->external_name(); // Find the module entry for new_class, the accessee ModuleEntry* module_to = NULL; - if (new_class->is_objArray_klass()) { - new_class = ObjArrayKlass::cast(new_class)->bottom_klass(); - } - if (new_class->is_instance_klass()) { - module_to = InstanceKlass::cast(new_class)->module(); - } else { - module_to = ModuleEntryTable::javabase_module(); - } + module_to = new_class->module(); const char * module_to_name = module_to->is_named() ? module_to->name()->as_C_string() : UNNAMED_MODULE; const char * new_class_name = new_class->external_name(); @@ -611,10 +603,10 @@ char* Reflection::verify_class_access_msg(const Klass* current_class, } } else if (result == TYPE_NOT_EXPORTED) { - assert(InstanceKlass::cast(new_class)->package() != NULL, + assert(new_class->package() != NULL, "Unnamed packages are always exported"); const char * package_name = - InstanceKlass::cast(new_class)->package()->name()->as_klass_external_name(); + new_class->package()->name()->as_klass_external_name(); assert(module_to->is_named(), "Unnamed modules export all packages"); if (module_from->is_named()) { size_t len = 118 + strlen(current_class_name) + 2*strlen(module_from_name) + diff --git a/hotspot/test/runtime/modules/getModuleJNI/GetModule.java b/hotspot/test/runtime/modules/getModuleJNI/GetModule.java index bc9883c6a64..c9ef4952d4d 100644 --- a/hotspot/test/runtime/modules/getModuleJNI/GetModule.java +++ b/hotspot/test/runtime/modules/getModuleJNI/GetModule.java @@ -42,10 +42,22 @@ public class GetModule { public static void main(String[] args) { Module module; + Module javaBaseModule; + + // Module for primitive type, should be "java.base" + java.lang.Integer primitive_int = 1; + try { + javaBaseModule = (Module)callGetModule(primitive_int.getClass()); + if (!javaBaseModule.getName().equals("java.base")) { + throw new RuntimeException("Unexpected module name for primitive type: " + + javaBaseModule.getName()); + } + } catch(Throwable e) { + throw new RuntimeException("Unexpected exception for Integer: " + e.toString()); + } // Module for array of primitives, should be "java.base" int[] int_array = {1, 2, 3}; - Module javaBaseModule; try { javaBaseModule = (Module)callGetModule(int_array.getClass()); if (!javaBaseModule.getName().equals("java.base")) { @@ -56,7 +68,19 @@ public class GetModule { throw new RuntimeException("Unexpected exception for [I: " + e.toString()); } - // Module for java.lang.String + // Module for multi-dimensional array of primitives, should be "java.base" + int[][] multi_int_array = { {1, 2, 3}, {4, 5, 6} }; + try { + javaBaseModule = (Module)callGetModule(multi_int_array.getClass()); + if (!javaBaseModule.getName().equals("java.base")) { + throw new RuntimeException("Unexpected module name for multi-dimensional array of primitives: " + + javaBaseModule.getName()); + } + } catch(Throwable e) { + throw new RuntimeException("Unexpected exception for multi-dimensional Integer array: " + e.toString()); + } + + // Module for java.lang.String, should be "java.base" java.lang.String str = "abc"; try { module = (Module)callGetModule(str.getClass()); @@ -68,6 +92,30 @@ public class GetModule { throw new RuntimeException("Unexpected exception for String: " + e.toString()); } + // Module for array of java.lang.Strings, should be "java.base" + java.lang.String[] str_array = {"a", "b", "c"}; + try { + javaBaseModule = (Module)callGetModule(str_array.getClass()); + if (!javaBaseModule.getName().equals("java.base")) { + throw new RuntimeException("Unexpected module name for array of Strings: " + + javaBaseModule.getName()); + } + } catch(Throwable e) { + throw new RuntimeException("Unexpected exception for String array: " + e.toString()); + } + + // Module for multi-dimensional array of java.lang.Strings, should be "java.base" + java.lang.String[][] multi_str_array = { {"a", "b", "c"}, {"d", "e", "f"} }; + try { + javaBaseModule = (Module)callGetModule(multi_str_array.getClass()); + if (!javaBaseModule.getName().equals("java.base")) { + throw new RuntimeException("Unexpected module name for multi-dimensional array of Strings: " + + javaBaseModule.getName()); + } + } catch(Throwable e) { + throw new RuntimeException("Unexpected exception for multidimensional String array: " + e.toString()); + } + // Module for java.lang.management.LockInfo try { LockInfo li = new LockInfo("java.lang.Class", 57); -- GitLab From 75d8a4b585efa48ada63aa1f8345fc67e76f60ca Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Tue, 26 Apr 2016 16:50:34 +0300 Subject: [PATCH 214/400] 8155092: [TESTBUG] TestHumongousClassLoader.java needs UnlockDiagnosticVMOptions before WhiteBoxAPI Reviewed-by: tschatzl, dfazunen --- .../test/gc/g1/humongousObjects/TestHumongousClassLoader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java index 075f5096d1e..4e8efd6e1d9 100644 --- a/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java +++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java @@ -51,7 +51,7 @@ import java.nio.file.Paths; * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission * - * @run main/othervm/timeout=240 -Xms256M -Xmx256M -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * @run main/othervm/timeout=240 -Xms256M -Xmx256M -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. * gc.g1.humongousObjects.ClassLoaderGenerator 1 * * @run main/othervm -Xms256M -Xmx256M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. -- GitLab From afcf41b8d490bb3cac85ee43cb738a649c22049b Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Tue, 26 Apr 2016 14:38:39 +0000 Subject: [PATCH 215/400] 8155100: AArch64: Relax alignment requirement for byte_map_base Reviewed-by: roland --- hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp index 4a3823c662e..6caf07cc0da 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp @@ -4093,7 +4093,10 @@ void MacroAssembler::load_byte_map_base(Register reg) { // and it might even be negative. unsigned long offset; adrp(reg, ExternalAddress((address)byte_map_base), offset); - assert(offset == 0, "misaligned card table base"); + // We expect offset to be zero with most collectors. + if (offset != 0) { + add(reg, reg, offset); + } } else { mov(reg, (uint64_t)byte_map_base); } -- GitLab From 08e78413658a2754f4ac90cb1714e64b718b6238 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Wed, 27 Apr 2016 08:48:39 +0200 Subject: [PATCH 216/400] 8141496: BitMap set operations copy their other BitMap argument Reviewed-by: mgerdin, tschatzl --- hotspot/src/share/vm/utilities/bitMap.cpp | 52 +++++++++++------------ hotspot/src/share/vm/utilities/bitMap.hpp | 28 ++++++------ 2 files changed, 41 insertions(+), 39 deletions(-) diff --git a/hotspot/src/share/vm/utilities/bitMap.cpp b/hotspot/src/share/vm/utilities/bitMap.cpp index bb7ae8ede14..a6c08f1fd27 100644 --- a/hotspot/src/share/vm/utilities/bitMap.cpp +++ b/hotspot/src/share/vm/utilities/bitMap.cpp @@ -271,10 +271,10 @@ void BitMap::par_at_put_large_range(idx_t beg, idx_t end, bool value) { par_put_range_within_word(bit_index(end_full_word), end, value); } -bool BitMap::contains(const BitMap other) const { +bool BitMap::contains(const BitMap& other) const { assert(size() == other.size(), "must have same size"); - bm_word_t* dest_map = map(); - bm_word_t* other_map = other.map(); + const bm_word_t* dest_map = map(); + const bm_word_t* other_map = other.map(); idx_t size = size_in_words(); for (idx_t index = 0; index < size_in_words(); index++) { bm_word_t word_union = dest_map[index] | other_map[index]; @@ -285,10 +285,10 @@ bool BitMap::contains(const BitMap other) const { return true; } -bool BitMap::intersects(const BitMap other) const { +bool BitMap::intersects(const BitMap& other) const { assert(size() == other.size(), "must have same size"); - bm_word_t* dest_map = map(); - bm_word_t* other_map = other.map(); + const bm_word_t* dest_map = map(); + const bm_word_t* other_map = other.map(); idx_t size = size_in_words(); for (idx_t index = 0; index < size_in_words(); index++) { if ((dest_map[index] & other_map[index]) != 0) return true; @@ -297,10 +297,10 @@ bool BitMap::intersects(const BitMap other) const { return false; } -void BitMap::set_union(BitMap other) { +void BitMap::set_union(const BitMap& other) { assert(size() == other.size(), "must have same size"); bm_word_t* dest_map = map(); - bm_word_t* other_map = other.map(); + const bm_word_t* other_map = other.map(); idx_t size = size_in_words(); for (idx_t index = 0; index < size_in_words(); index++) { dest_map[index] = dest_map[index] | other_map[index]; @@ -308,10 +308,10 @@ void BitMap::set_union(BitMap other) { } -void BitMap::set_difference(BitMap other) { +void BitMap::set_difference(const BitMap& other) { assert(size() == other.size(), "must have same size"); bm_word_t* dest_map = map(); - bm_word_t* other_map = other.map(); + const bm_word_t* other_map = other.map(); idx_t size = size_in_words(); for (idx_t index = 0; index < size_in_words(); index++) { dest_map[index] = dest_map[index] & ~(other_map[index]); @@ -319,10 +319,10 @@ void BitMap::set_difference(BitMap other) { } -void BitMap::set_intersection(BitMap other) { +void BitMap::set_intersection(const BitMap& other) { assert(size() == other.size(), "must have same size"); bm_word_t* dest_map = map(); - bm_word_t* other_map = other.map(); + const bm_word_t* other_map = other.map(); idx_t size = size_in_words(); for (idx_t index = 0; index < size; index++) { dest_map[index] = dest_map[index] & other_map[index]; @@ -330,14 +330,14 @@ void BitMap::set_intersection(BitMap other) { } -void BitMap::set_intersection_at_offset(BitMap other, idx_t offset) { +void BitMap::set_intersection_at_offset(const BitMap& other, idx_t offset) { assert(other.size() >= offset, "offset not in range"); assert(other.size() - offset >= size(), "other not large enough"); // XXX Ideally, we would remove this restriction. guarantee((offset % (sizeof(bm_word_t) * BitsPerByte)) == 0, "Only handle aligned cases so far."); bm_word_t* dest_map = map(); - bm_word_t* other_map = other.map(); + const bm_word_t* other_map = other.map(); idx_t offset_word_ind = word_index(offset); idx_t size = size_in_words(); for (idx_t index = 0; index < size; index++) { @@ -345,11 +345,11 @@ void BitMap::set_intersection_at_offset(BitMap other, idx_t offset) { } } -bool BitMap::set_union_with_result(BitMap other) { +bool BitMap::set_union_with_result(const BitMap& other) { assert(size() == other.size(), "must have same size"); bool changed = false; bm_word_t* dest_map = map(); - bm_word_t* other_map = other.map(); + const bm_word_t* other_map = other.map(); idx_t size = size_in_words(); for (idx_t index = 0; index < size; index++) { idx_t temp = dest_map[index] | other_map[index]; @@ -360,11 +360,11 @@ bool BitMap::set_union_with_result(BitMap other) { } -bool BitMap::set_difference_with_result(BitMap other) { +bool BitMap::set_difference_with_result(const BitMap& other) { assert(size() == other.size(), "must have same size"); bool changed = false; bm_word_t* dest_map = map(); - bm_word_t* other_map = other.map(); + const bm_word_t* other_map = other.map(); idx_t size = size_in_words(); for (idx_t index = 0; index < size; index++) { bm_word_t temp = dest_map[index] & ~(other_map[index]); @@ -375,11 +375,11 @@ bool BitMap::set_difference_with_result(BitMap other) { } -bool BitMap::set_intersection_with_result(BitMap other) { +bool BitMap::set_intersection_with_result(const BitMap& other) { assert(size() == other.size(), "must have same size"); bool changed = false; bm_word_t* dest_map = map(); - bm_word_t* other_map = other.map(); + const bm_word_t* other_map = other.map(); idx_t size = size_in_words(); for (idx_t index = 0; index < size; index++) { bm_word_t orig = dest_map[index]; @@ -391,10 +391,10 @@ bool BitMap::set_intersection_with_result(BitMap other) { } -void BitMap::set_from(BitMap other) { +void BitMap::set_from(const BitMap& other) { assert(size() == other.size(), "must have same size"); bm_word_t* dest_map = map(); - bm_word_t* other_map = other.map(); + const bm_word_t* other_map = other.map(); idx_t size = size_in_words(); for (idx_t index = 0; index < size; index++) { dest_map[index] = other_map[index]; @@ -402,10 +402,10 @@ void BitMap::set_from(BitMap other) { } -bool BitMap::is_same(BitMap other) { +bool BitMap::is_same(const BitMap& other) { assert(size() == other.size(), "must have same size"); bm_word_t* dest_map = map(); - bm_word_t* other_map = other.map(); + const bm_word_t* other_map = other.map(); idx_t size = size_in_words(); for (idx_t index = 0; index < size; index++) { if (dest_map[index] != other_map[index]) return false; @@ -414,7 +414,7 @@ bool BitMap::is_same(BitMap other) { } bool BitMap::is_full() const { - bm_word_t* word = map(); + const bm_word_t* word = map(); idx_t rest = size(); for (; rest >= (idx_t) BitsPerWord; rest -= BitsPerWord) { if (*word != ~(bm_word_t)0) return false; @@ -425,7 +425,7 @@ bool BitMap::is_full() const { bool BitMap::is_empty() const { - bm_word_t* word = map(); + const bm_word_t* word = map(); idx_t rest = size(); for (; rest >= (idx_t) BitsPerWord; rest -= BitsPerWord) { if (*word != 0) return false; diff --git a/hotspot/src/share/vm/utilities/bitMap.hpp b/hotspot/src/share/vm/utilities/bitMap.hpp index b41cc12062e..924d9203635 100644 --- a/hotspot/src/share/vm/utilities/bitMap.hpp +++ b/hotspot/src/share/vm/utilities/bitMap.hpp @@ -70,11 +70,13 @@ class BitMap VALUE_OBJ_CLASS_SPEC { static idx_t bit_index(idx_t word) { return word << LogBitsPerWord; } // Return the array of bitmap words, or a specific word from it. - bm_word_t* map() const { return _map; } + bm_word_t* map() { return _map; } + const bm_word_t* map() const { return _map; } bm_word_t map(idx_t word) const { return _map[word]; } // Return a pointer to the word containing the specified bit. - bm_word_t* word_addr(idx_t bit) const { return map() + word_index(bit); } + bm_word_t* word_addr(idx_t bit) { return map() + word_index(bit); } + const bm_word_t* word_addr(idx_t bit) const { return map() + word_index(bit); } // Set a word to a specified value or to all ones; clear a word. void set_word (idx_t word, bm_word_t val) { _map[word] = val; } @@ -237,19 +239,19 @@ class BitMap VALUE_OBJ_CLASS_SPEC { idx_t count_one_bits() const; // Set operations. - void set_union(BitMap bits); - void set_difference(BitMap bits); - void set_intersection(BitMap bits); + void set_union(const BitMap& bits); + void set_difference(const BitMap& bits); + void set_intersection(const BitMap& bits); // Returns true iff "this" is a superset of "bits". - bool contains(const BitMap bits) const; + bool contains(const BitMap& bits) const; // Returns true iff "this and "bits" have a non-empty intersection. - bool intersects(const BitMap bits) const; + bool intersects(const BitMap& bits) const; // Returns result of whether this map changed // during the operation - bool set_union_with_result(BitMap bits); - bool set_difference_with_result(BitMap bits); - bool set_intersection_with_result(BitMap bits); + bool set_union_with_result(const BitMap& bits); + bool set_difference_with_result(const BitMap& bits); + bool set_intersection_with_result(const BitMap& bits); // Requires the submap of "bits" starting at offset to be at least as // large as "this". Modifies "this" to be the intersection of its @@ -258,11 +260,11 @@ class BitMap VALUE_OBJ_CLASS_SPEC { // (For expedience, currently requires the offset to be aligned to the // bitsize of a uintptr_t. This should go away in the future though it // will probably remain a good case to optimize.) - void set_intersection_at_offset(BitMap bits, idx_t offset); + void set_intersection_at_offset(const BitMap& bits, idx_t offset); - void set_from(BitMap bits); + void set_from(const BitMap& bits); - bool is_same(BitMap bits); + bool is_same(const BitMap& bits); // Test if all bits are set or cleared bool is_full() const; -- GitLab From 64ca7559f503f3184007bc7a46d946ee00a5a254 Mon Sep 17 00:00:00 2001 From: David Simms Date: Tue, 26 Apr 2016 12:46:40 +0200 Subject: [PATCH 217/400] 8149442: MonitorInUseLists should be on by default, deflate idle monitors taking too long MonitorInUseLists on by default Reviewed-by: rbackman, mlarsson --- hotspot/src/share/vm/runtime/globals.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 0261f66aa69..bfc05242309 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -1253,7 +1253,7 @@ public: product(intx, MonitorBound, 0, "Bound Monitor population") \ range(0, max_jint) \ \ - product(bool, MonitorInUseLists, false, "Track Monitors for Deflation") \ + product(bool, MonitorInUseLists, true, "Track Monitors for Deflation") \ \ experimental(intx, SyncFlags, 0, "(Unsafe, Unstable) " \ "Experimental Sync flags") \ -- GitLab From 07aa75e7fec5f4e4ab49f3807b7f799986f31a9a Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 26 Apr 2016 13:35:27 +0200 Subject: [PATCH 218/400] 8150601: Remove the old Hotspot build system Reviewed-by: ihse --- common/autoconf/basics.m4 | 2 - common/autoconf/configure.ac | 1 - common/autoconf/generated-configure.sh | 172 +------------------------ common/autoconf/hotspot-spec.gmk.in | 158 ----------------------- common/autoconf/hotspot.m4 | 137 -------------------- make/HotspotWrapper.gmk | 59 --------- make/Main.gmk | 10 +- 7 files changed, 4 insertions(+), 535 deletions(-) delete mode 100644 common/autoconf/hotspot-spec.gmk.in delete mode 100644 make/HotspotWrapper.gmk diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index f295a46d3c4..355acf4c430 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -839,8 +839,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR], # The spec.gmk file contains all variables for the make system. AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in]) - # The hotspot-spec.gmk file contains legacy variables for the hotspot make system. - AC_CONFIG_FILES([$OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in]) # The bootcycle-spec.gmk file contains support for boot cycle builds. AC_CONFIG_FILES([$OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in]) # The buildjdk-spec.gmk file contains support for building a buildjdk when cross compiling. diff --git a/common/autoconf/configure.ac b/common/autoconf/configure.ac index 291851f8d10..27bc76a9b3e 100644 --- a/common/autoconf/configure.ac +++ b/common/autoconf/configure.ac @@ -226,7 +226,6 @@ LIB_SETUP_LIBRARIES # ############################################################################### -HOTSPOT_SETUP_LEGACY_BUILD JDKOPT_DETECT_INTREE_EC JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index a901727242c..aadb16bb538 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -652,21 +652,6 @@ MEMORY_SIZE NUM_CORES BUILD_FAILURE_HANDLER ENABLE_INTREE_EC -JVM_VARIANT_CORE -JVM_VARIANT_ZEROSHARK -JVM_VARIANT_ZERO -JVM_VARIANT_HOTSPOT -JVM_VARIANT_MINIMAL1 -JVM_VARIANT_CLIENT -JVM_VARIANT_SERVER -JVM_VARIANTS_COMMA -TEST_IN_BUILD -HOTSPOT_MAKE_ARGS -MACOSX_UNIVERSAL -DEBUG_CLASSFILES -FASTDEBUG -VARIANT -USE_NEW_HOTSPOT_BUILD LIBZIP_CAN_USE_MMAP LIBDL LIBM @@ -1225,8 +1210,6 @@ with_dxsdk with_dxsdk_lib with_dxsdk_include enable_jtreg_failure_handler -enable_new_hotspot_build -enable_hotspot_test_in_build with_num_cores with_memory_size with_jobs @@ -1997,11 +1980,6 @@ Optional Features: disable bundling of the freetype library with the build result [enabled on Windows or when using --with-freetype, disabled otherwise] - --disable-new-hotspot-build - disable the new hotspot build system (use the old) - [enabled] - --enable-hotspot-test-in-build - run the Queens test after Hotspot build [disabled] --enable-jtreg-failure-handler forces build of the jtreg failure handler to be enabled, missing dependencies become fatal errors. @@ -4300,12 +4278,6 @@ VALID_JVM_VARIANTS="server client minimal core zero zeroshark custom" # -############################################################################### -# Support for old hotspot build. Remove once new hotspot build has proven -# to work satisfactory. -# - - # # Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -5070,7 +5042,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1461064700 +DATE_WHEN_GENERATED=1461670455 ############################################################################### # @@ -17015,9 +16987,6 @@ $as_echo "$as_me: The path of OUTPUT_ROOT, which resolves as \"$path\", is inval # The spec.gmk file contains all variables for the make system. ac_config_files="$ac_config_files $OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in" - # The hotspot-spec.gmk file contains legacy variables for the hotspot make system. - ac_config_files="$ac_config_files $OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in" - # The bootcycle-spec.gmk file contains support for boot cycle builds. ac_config_files="$ac_config_files $OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in" @@ -63746,144 +63715,6 @@ fi ############################################################################### - # Check whether --enable-new-hotspot-build was given. -if test "${enable_new_hotspot_build+set}" = set; then : - enableval=$enable_new_hotspot_build; -fi - - - if test "x$enable_new_hotspot_build" = "x" || test "x$enable_new_hotspot_build" = "xyes"; then - USE_NEW_HOTSPOT_BUILD=true - else - USE_NEW_HOTSPOT_BUILD=false - fi - - - case $HOTSPOT_DEBUG_LEVEL in - product ) - VARIANT="OPT" - FASTDEBUG="false" - DEBUG_CLASSFILES="false" - ;; - fastdebug ) - VARIANT="DBG" - FASTDEBUG="true" - DEBUG_CLASSFILES="true" - ;; - debug ) - VARIANT="DBG" - FASTDEBUG="false" - DEBUG_CLASSFILES="true" - ;; - optimized ) - VARIANT="OPT" - FASTDEBUG="false" - DEBUG_CLASSFILES="false" - ;; - esac - - - - - if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then - MACOSX_UNIVERSAL="true" - fi - - - - # Make sure JVM_VARIANTS_COMMA use minimal1 for backwards compatibility - JVM_VARIANTS_COMMA=`$ECHO ,$JVM_VARIANTS_OPT, | $SED -e 's/,minimal,/,minimal1,/'` - - JVM_VARIANT_SERVER=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,server,/!s/.*/false/g' -e '/,server,/s/.*/true/g'` - JVM_VARIANT_CLIENT=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,client,/!s/.*/false/g' -e '/,client,/s/.*/true/g'` - JVM_VARIANT_MINIMAL1=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,minimal1\?,/!s/.*/false/g' -e '/,minimal1\?,/s/.*/true/g'` - JVM_VARIANT_CORE=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,core,/!s/.*/false/g' -e '/,core,/s/.*/true/g'` - JVM_VARIANT_ZERO=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zero,/!s/.*/false/g' -e '/,zero,/s/.*/true/g'` - JVM_VARIANT_ZEROSHARK=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zeroshark,/!s/.*/false/g' -e '/,zeroshark,/s/.*/true/g'` - JVM_VARIANT_CUSTOM=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,custom,/!s/.*/false/g' -e '/,custom,/s/.*/true/g'` - - ##### - # Generate the legacy makefile targets for hotspot. - HOTSPOT_TARGET="" - - if test "x$JVM_VARIANT_SERVER" = xtrue; then - HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL} " - fi - - if test "x$JVM_VARIANT_CLIENT" = xtrue; then - HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}1 " - fi - - if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then - HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}minimal1 " - fi - - if test "x$JVM_VARIANT_ZERO" = xtrue; then - HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}zero " - fi - - if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then - HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}shark " - fi - - if test "x$JVM_VARIANT_CORE" = xtrue; then - HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}core " - fi - - HOTSPOT_TARGET="$HOTSPOT_TARGET docs export_$HOTSPOT_DEBUG_LEVEL" - - # On Macosx universal binaries are produced, but they only contain - # 64 bit intel. This invalidates control of which jvms are built - # from configure, but only server is valid anyway. Fix this - # when hotspot makefiles are rewritten. - if test "x$MACOSX_UNIVERSAL" = xtrue; then - HOTSPOT_TARGET=universal_${HOTSPOT_DEBUG_LEVEL} - fi - - HOTSPOT_MAKE_ARGS="$HOTSPOT_TARGET" - - - # Control wether Hotspot runs Queens test after build. - # Check whether --enable-hotspot-test-in-build was given. -if test "${enable_hotspot_test_in_build+set}" = set; then : - enableval=$enable_hotspot_test_in_build; -else - enable_hotspot_test_in_build=no -fi - - if test "x$enable_hotspot_test_in_build" = "xyes"; then - TEST_IN_BUILD=true - else - TEST_IN_BUILD=false - fi - - - if test "x$USE_NEW_HOTSPOT_BUILD" = xfalse; then - if test "x$JVM_VARIANT_CLIENT" = xtrue; then - if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then - as_fn_error $? "You cannot build a client JVM for a 64-bit machine." "$LINENO" 5 - fi - fi - if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then - if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then - as_fn_error $? "You cannot build a minimal JVM for a 64-bit machine." "$LINENO" 5 - fi - fi - if test "x$JVM_VARIANT_CUSTOM" = xtrue; then - as_fn_error $? "You cannot build a custom JVM using the old hotspot build system." "$LINENO" 5 - fi - fi - - - - - - - - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if elliptic curve crypto implementation is present" >&5 $as_echo_n "checking if elliptic curve crypto implementation is present... " >&6; } @@ -66336,7 +66167,6 @@ for ac_config_target in $ac_config_targets do case $ac_config_target in "$OUTPUT_ROOT/spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in" ;; - "$OUTPUT_ROOT/hotspot-spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in" ;; "$OUTPUT_ROOT/bootcycle-spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in" ;; "$OUTPUT_ROOT/buildjdk-spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/buildjdk-spec.gmk:$AUTOCONF_DIR/buildjdk-spec.gmk.in" ;; "$OUTPUT_ROOT/compare.sh") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/compare.sh:$AUTOCONF_DIR/compare.sh.in" ;; diff --git a/common/autoconf/hotspot-spec.gmk.in b/common/autoconf/hotspot-spec.gmk.in deleted file mode 100644 index 50d790876a6..00000000000 --- a/common/autoconf/hotspot-spec.gmk.in +++ /dev/null @@ -1,158 +0,0 @@ -# -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - - -# Chaining of spec files -HOTSPOT_SPEC:=$(dir $(SPEC))hotspot-spec.gmk -override SPEC=$(HOTSPOT_SPEC) -# Now include the base spec.gmk file -include $(BASE_SPEC) - -# Additional legacy variables defined for Hotspot - -@SET_OPENJDK@ -@HOTSPOT_SET_WARNINGS_AS_ERRORS@ - -# Legacy defines controlled by the SUPPORT_HEADLESS and SUPPORT_HEADFUL options. -@BUILD_HEADLESS@ - -JVM_VARIANTS:=@JVM_VARIANTS_COMMA@ - -JVM_VARIANT_SERVER:=@JVM_VARIANT_SERVER@ -JVM_VARIANT_CLIENT:=@JVM_VARIANT_CLIENT@ -JVM_VARIANT_MINIMAL1:=@JVM_VARIANT_MINIMAL1@ -JVM_VARIANT_CORE:=@JVM_VARIANT_CORE@ -JVM_VARIANT_ZERO:=@JVM_VARIANT_ZERO@ -JVM_VARIANT_ZEROSHARK:=@JVM_VARIANT_ZEROSHARK@ -JVM_VARIANT_CUSTOM:=@JVM_VARIANT_HOTSPOT@ - -# Legacy setting: OPT or DBG -VARIANT:=@VARIANT@ -# Legacy setting: true or false -FASTDEBUG:=@FASTDEBUG@ -# Legacy setting: debugging the class files? -DEBUG_CLASSFILES:=@DEBUG_CLASSFILES@ - -ALT_CUPS_HEADERS_PATH:=$(patsubst -I%,%,$(filter -I%,@CUPS_CFLAGS@)) - -# The HOSTCC/HOSTCXX is Hotspot terminology for the BUILD_CC/BUILD_CXX, i.e. the -# compiler that produces code that can be run on the build platform. -HOSTCC:=@FIXPATH@ @BUILD_ICECC@ @BUILD_CC@ $(BUILD_SYSROOT_CFLAGS) -HOSTCXX:=@FIXPATH@ @BUILD_ICECC@ @BUILD_CXX@ $(BUILD_SYSROOT_CFLAGS) - -#################################################### -# -# Legacy Hotspot support - -# If cross compiling, then define CROSS_COMPILE_ARCH:=cpu_name here. -@DEFINE_CROSS_COMPILE_ARCH@ - -# Old name for OPENJDK_TARGET_OS (aix,bsd,hpux,linux,macosx,solaris,windows etc) -PLATFORM=$(OPENJDK_TARGET_OS) -# 32 or 64 bit -ARCH_DATA_MODEL=$(OPENJDK_TARGET_CPU_BITS) - -ALT_BOOTDIR=$(BOOT_JDK) -# Can be /sparcv9 or /amd64 on Solaris -ISA_DIR=$(OPENJDK_TARGET_CPU_ISADIR) -# Yet another name for arch used for an extra subdir below the jvm lib. -# Uses i386 and amd64, instead of x86 and x86_64. -LIBARCH=$(OPENJDK_TARGET_CPU_LEGACY_LIB) -# Set the cpu architecture -ARCH=$(OPENJDK_TARGET_CPU_ARCH) -# Legacy setting for building for a 64 bit machine. -# If yes then this expands to _LP64:=1 -@LP64@ - -# Legacy settings for zero -ZERO_ENDIANNESS=$(OPENJDK_TARGET_CPU_ENDIAN) -ZERO_LIBARCH=$(OPENJDK_TARGET_CPU_LEGACY_LIB) -ZERO_ARCHDEF=@ZERO_ARCHDEF@ -ZERO_ARCHFLAG=@ZERO_ARCHFLAG@ -LIBFFI_CFLAGS=@LIBFFI_CFLAGS@ -LIBFFI_LIBS=@LIBFFI_LIBS@ - -# Legacy settings for zeroshark -LLVM_CFLAGS=@LLVM_CFLAGS@ -LLVM_LIBS=@LLVM_LIBS@ -LLVM_LDFLAGS=@LLVM_LDFLAGS@ - -ALT_OUTPUTDIR=$(HOTSPOT_OUTPUTDIR) -ALT_EXPORT_PATH=$(HOTSPOT_DIST) - -ifeq ($(HOTSPOT_TARGET_CPU), zero) - CC_INTERP=true -endif - -HOTSPOT_MAKE_ARGS:=@HOTSPOT_MAKE_ARGS@ @STATIC_CXX_SETTING@ -# Control wether Hotspot runs Queens test after building -TEST_IN_BUILD=@TEST_IN_BUILD@ - -USE_CLANG := @USE_CLANG@ - -# For hotspot, override compiler/tools definition to not include FIXPATH prefix. -# Hotspot has its own handling on the Windows path situation. -CXX:=@CCACHE@ @ICECC@ @HOTSPOT_CXX@ -LD:=@HOTSPOT_LD@ -MT:=@HOTSPOT_MT@ -RC:=@HOTSPOT_RC@ - -EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@ $(CFLAGS_CCACHE) $(NO_NULL_POINTER_CHECK_FLAG) \ - $(NO_LIFETIME_DSE_CFLAG) $(CXXSTD_CXXFLAG) -EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@ $(CFLAGS_CCACHE) -EXTRA_LDFLAGS=@LEGACY_EXTRA_LDFLAGS@ - -USE_PRECOMPILED_HEADER=@USE_PRECOMPILED_HEADER@ - -# Hotspot expects the variable FULL_DEBUG_SYMBOLS=1/0 to control debug symbols -# creation. -ifeq ($(COPY_DEBUG_SYMBOLS), true) - FULL_DEBUG_SYMBOLS=1 - # Ensure hotspot uses the objcopy that configure located - ALT_OBJCOPY:=$(OBJCOPY) -else - FULL_DEBUG_SYMBOLS=0 -endif - -# Hotspot expects the variable ZIP_DEBUGINFO_FILES=1/0 and not true/false. -ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true) - ZIP_DEBUGINFO_FILES:=1 -else - ZIP_DEBUGINFO_FILES:=0 -endif - -DEBUG_BINARIES := @DEBUG_BINARIES@ -STRIP_POLICY := @STRIP_POLICY@ - -ifeq ($(OPENJDK_TARGET_OS), windows) - # On Windows, the Visual Studio toolchain needs the LIB and INCLUDE - # environment variables (in Windows path style). - export INCLUDE:=@VS_INCLUDE@ - export LIB:=@VS_LIB@ -endif - -# Sneak this in via the spec.gmk file, since we don't want to mess around too much with the Hotspot make files. -# This is needed to get the LOG setting to work properly. -include $(SRC_ROOT)/make/common/MakeBase.gmk diff --git a/common/autoconf/hotspot.m4 b/common/autoconf/hotspot.m4 index 1917624df7a..5d1b7467b10 100644 --- a/common/autoconf/hotspot.m4 +++ b/common/autoconf/hotspot.m4 @@ -306,140 +306,3 @@ AC_DEFUN_ONCE([HOTSPOT_VALIDATE_JVM_FEATURES], fi done ]) - -############################################################################### -# Support for old hotspot build. Remove once new hotspot build has proven -# to work satisfactory. -# -AC_DEFUN_ONCE([HOTSPOT_SETUP_LEGACY_BUILD], -[ - AC_ARG_ENABLE(new-hotspot-build, [AS_HELP_STRING([--disable-new-hotspot-build], - [disable the new hotspot build system (use the old) @<:@enabled@:>@])]) - - if test "x$enable_new_hotspot_build" = "x" || test "x$enable_new_hotspot_build" = "xyes"; then - USE_NEW_HOTSPOT_BUILD=true - else - USE_NEW_HOTSPOT_BUILD=false - fi - AC_SUBST(USE_NEW_HOTSPOT_BUILD) - - case $HOTSPOT_DEBUG_LEVEL in - product ) - VARIANT="OPT" - FASTDEBUG="false" - DEBUG_CLASSFILES="false" - ;; - fastdebug ) - VARIANT="DBG" - FASTDEBUG="true" - DEBUG_CLASSFILES="true" - ;; - debug ) - VARIANT="DBG" - FASTDEBUG="false" - DEBUG_CLASSFILES="true" - ;; - optimized ) - VARIANT="OPT" - FASTDEBUG="false" - DEBUG_CLASSFILES="false" - ;; - esac - AC_SUBST(VARIANT) - AC_SUBST(FASTDEBUG) - AC_SUBST(DEBUG_CLASSFILES) - - if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then - MACOSX_UNIVERSAL="true" - fi - - AC_SUBST(MACOSX_UNIVERSAL) - - # Make sure JVM_VARIANTS_COMMA use minimal1 for backwards compatibility - JVM_VARIANTS_COMMA=`$ECHO ,$JVM_VARIANTS_OPT, | $SED -e 's/,minimal,/,minimal1,/'` - - JVM_VARIANT_SERVER=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,server,/!s/.*/false/g' -e '/,server,/s/.*/true/g'` - JVM_VARIANT_CLIENT=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,client,/!s/.*/false/g' -e '/,client,/s/.*/true/g'` - JVM_VARIANT_MINIMAL1=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,minimal1\?,/!s/.*/false/g' -e '/,minimal1\?,/s/.*/true/g'` - JVM_VARIANT_CORE=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,core,/!s/.*/false/g' -e '/,core,/s/.*/true/g'` - JVM_VARIANT_ZERO=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zero,/!s/.*/false/g' -e '/,zero,/s/.*/true/g'` - JVM_VARIANT_ZEROSHARK=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zeroshark,/!s/.*/false/g' -e '/,zeroshark,/s/.*/true/g'` - JVM_VARIANT_CUSTOM=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,custom,/!s/.*/false/g' -e '/,custom,/s/.*/true/g'` - - ##### - # Generate the legacy makefile targets for hotspot. - HOTSPOT_TARGET="" - - if test "x$JVM_VARIANT_SERVER" = xtrue; then - HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL} " - fi - - if test "x$JVM_VARIANT_CLIENT" = xtrue; then - HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}1 " - fi - - if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then - HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}minimal1 " - fi - - if test "x$JVM_VARIANT_ZERO" = xtrue; then - HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}zero " - fi - - if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then - HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}shark " - fi - - if test "x$JVM_VARIANT_CORE" = xtrue; then - HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}core " - fi - - HOTSPOT_TARGET="$HOTSPOT_TARGET docs export_$HOTSPOT_DEBUG_LEVEL" - - # On Macosx universal binaries are produced, but they only contain - # 64 bit intel. This invalidates control of which jvms are built - # from configure, but only server is valid anyway. Fix this - # when hotspot makefiles are rewritten. - if test "x$MACOSX_UNIVERSAL" = xtrue; then - HOTSPOT_TARGET=universal_${HOTSPOT_DEBUG_LEVEL} - fi - - HOTSPOT_MAKE_ARGS="$HOTSPOT_TARGET" - AC_SUBST(HOTSPOT_MAKE_ARGS) - - # Control wether Hotspot runs Queens test after build. - AC_ARG_ENABLE([hotspot-test-in-build], [AS_HELP_STRING([--enable-hotspot-test-in-build], - [run the Queens test after Hotspot build @<:@disabled@:>@])],, - [enable_hotspot_test_in_build=no]) - if test "x$enable_hotspot_test_in_build" = "xyes"; then - TEST_IN_BUILD=true - else - TEST_IN_BUILD=false - fi - AC_SUBST(TEST_IN_BUILD) - - if test "x$USE_NEW_HOTSPOT_BUILD" = xfalse; then - if test "x$JVM_VARIANT_CLIENT" = xtrue; then - if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then - AC_MSG_ERROR([You cannot build a client JVM for a 64-bit machine.]) - fi - fi - if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then - if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then - AC_MSG_ERROR([You cannot build a minimal JVM for a 64-bit machine.]) - fi - fi - if test "x$JVM_VARIANT_CUSTOM" = xtrue; then - AC_MSG_ERROR([You cannot build a custom JVM using the old hotspot build system.]) - fi - fi - - AC_SUBST(JVM_VARIANTS_COMMA) - AC_SUBST(JVM_VARIANT_SERVER) - AC_SUBST(JVM_VARIANT_CLIENT) - AC_SUBST(JVM_VARIANT_MINIMAL1) - AC_SUBST(JVM_VARIANT_HOTSPOT) - AC_SUBST(JVM_VARIANT_ZERO) - AC_SUBST(JVM_VARIANT_ZEROSHARK) - AC_SUBST(JVM_VARIANT_CORE) -]) diff --git a/make/HotspotWrapper.gmk b/make/HotspotWrapper.gmk deleted file mode 100644 index 663215525a3..00000000000 --- a/make/HotspotWrapper.gmk +++ /dev/null @@ -1,59 +0,0 @@ -# -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# Include the legacy hotspot-spec.gmk (which in turns includes spec.gmk) -BASE_SPEC:=$(SPEC) -# Assign to HOTSPOT_SPEC so that the variable HOTSPOT_SPEC can be -# overridden when building the buildjdk. -HOTSPOT_SPEC := $(dir $(SPEC))hotspot-spec.gmk -include $(HOTSPOT_SPEC) -include MakeBase.gmk - -# Inclusion of this pseudo-target will cause make to execute this file -# serially, regardless of -j. Recursively called makefiles will not be -# affected, however. This is required for correct dependency management. -.NOTPARALLEL: - -default: all - -# Get all files in src, make or agent subdirs in hotspot directory and -# filter out .hg. This skips the test directory. -HOTSPOT_FILES := $(shell $(FIND) -L \ - $(HOTSPOT_TOPDIR)/src $(HOTSPOT_TOPDIR)/make \ - -name ".hg" -prune -o -print) - -# The old build creates hotspot output dir before calling hotspot and -# not doing it breaks builds on msys. -$(HOTSPOT_OUTPUTDIR)/_hotspot.timestamp: $(HOTSPOT_FILES) - @$(MKDIR) -p $(HOTSPOT_OUTPUTDIR) - ($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(HOTSPOT_MAKE_ARGS) \ - LOG_LEVEL=$(LOG_LEVEL) SPEC=$(HOTSPOT_SPEC) BASE_SPEC=$(BASE_SPEC)) - $(TOUCH) $@ - -hotspot: $(HOTSPOT_OUTPUTDIR)/_hotspot.timestamp - -all: hotspot - -.PHONY: default all hotspot diff --git a/make/Main.gmk b/make/Main.gmk index a693465ec4d..37545f4743b 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -228,16 +228,12 @@ ALL_TARGETS += $(LAUNCHER_TARGETS) # Build hotspot target ifeq ($(BUILD_HOTSPOT),true) - hotspot: - ifeq ($(USE_NEW_HOTSPOT_BUILD), true) - +($(CD) $(HOTSPOT_TOPDIR)/makefiles && $(MAKE) $(MAKE_ARGS) -f BuildHotspot.gmk) - else - +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f HotspotWrapper.gmk) - endif +hotspot: + +($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f BuildHotspot.gmk) endif hotspot-ide-project: - +($(CD) $(HOTSPOT_TOPDIR)/makefiles && $(MAKE) $(MAKE_ARGS) -f ide/CreateVSProject.gmk) + +($(CD) $(HOTSPOT_TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f ide/CreateVSProject.gmk) ALL_TARGETS += hotspot hotspot-ide-project -- GitLab From cf2c110c5e444aea8ebdc488a2af7b6370ec179f Mon Sep 17 00:00:00 2001 From: Jon Masamitsu Date: Tue, 26 Apr 2016 09:19:19 -0700 Subject: [PATCH 219/400] 8154743: Internal Error: psParallelCompact.hpp assert(addr >= _region_start) failed: bad addr Reviewed-by: tschatzl, kbarrett --- .../vm/gc/parallel/psParallelCompact.cpp | 29 ++++++++++++++++++- .../vm/gc/parallel/psParallelCompact.hpp | 4 +-- .../share/vm/utilities/internalVMTests.cpp | 1 + 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp index 4808577b238..e37ccf97e9a 100644 --- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp @@ -249,7 +249,7 @@ print_generic_summary_data(ParallelCompactData& summary_data, const size_t last = summary_data.addr_to_region_idx(end_addr); HeapWord* pdest = 0; - while (i <= last) { + while (i < last) { ParallelCompactData::RegionData* c = summary_data.region(i); if (c->data_size() != 0 || c->destination() != pdest) { print_generic_summary_region(i, c); @@ -377,6 +377,33 @@ print_initial_summary_data(ParallelCompactData& summary_data, print_generic_summary_data(summary_data, space->bottom(), space->top()); } while (++id < PSParallelCompact::last_space_id); } + +void ParallelCompact_test() { + if (!UseParallelGC) { + return; + } + // Check that print_generic_summary_data() does not print the + // end region by placing a bad value in the destination of the + // end region. The end region should not be printed because it + // corresponds to the space after the end of the heap. + ParallelScavengeHeap* heap = ParallelScavengeHeap::heap(); + ParCompactionManager* const vmthread_cm = + ParCompactionManager::manager_array(ParallelGCThreads); + HeapWord* begin_heap = + (HeapWord*) heap->old_gen()->virtual_space()->low_boundary(); + HeapWord* end_heap = + (HeapWord*) heap->young_gen()->virtual_space()->high_boundary(); + + size_t end_index = + PSParallelCompact::summary_data().addr_to_region_idx(end_heap); + ParallelCompactData::RegionData* c = PSParallelCompact::summary_data().region(end_index); + + // Initialize the end region with a bad destination. + c->set_destination(begin_heap - 1); + + print_generic_summary_data(PSParallelCompact::summary_data(), + begin_heap, end_heap); +} #endif // #ifndef PRODUCT #ifdef ASSERT diff --git a/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp b/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp index ce0beda2ba8..5af827c92dd 100644 --- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp +++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.hpp @@ -631,8 +631,8 @@ ParallelCompactData::region_offset(const HeapWord* addr) const inline size_t ParallelCompactData::addr_to_region_idx(const HeapWord* addr) const { - assert(addr >= _region_start, "bad addr"); - assert(addr <= _region_end, "bad addr"); + assert(addr >= _region_start, "bad addr " PTR_FORMAT " _region_start " PTR_FORMAT, p2i(addr), p2i(_region_start)); + assert(addr <= _region_end, "bad addr " PTR_FORMAT " _region_end " PTR_FORMAT, p2i(addr), p2i(_region_end)); return pointer_delta(addr, _region_start) >> Log2RegionSize; } diff --git a/hotspot/src/share/vm/utilities/internalVMTests.cpp b/hotspot/src/share/vm/utilities/internalVMTests.cpp index 985885c2edd..d59dc716d41 100644 --- a/hotspot/src/share/vm/utilities/internalVMTests.cpp +++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp @@ -98,6 +98,7 @@ void InternalVMTests::run() { run_unit_test(test_memset_with_concurrent_readers); run_unit_test(TestPredictions_test); run_unit_test(WorkerDataArray_test); + run_unit_test(ParallelCompact_test); #endif tty->print_cr("All internal VM tests passed"); } -- GitLab From 5c6e28cc602467cdca8ae20cc13a540fc72d3af6 Mon Sep 17 00:00:00 2001 From: Shafi Ahmad Date: Tue, 26 Apr 2016 23:29:51 +0530 Subject: [PATCH 220/400] 8147026: Convert an assert in ClassLoaderData to a guarantee Guarantee is to ensure classloader is a valid oop will help catch the errors at an early stage rather than crashing the JVM later on in the GC Reviewed-by: coleenp --- hotspot/src/share/vm/classfile/classLoaderData.inline.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/classfile/classLoaderData.inline.hpp b/hotspot/src/share/vm/classfile/classLoaderData.inline.hpp index 2427838890f..3da00ad8bb7 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.inline.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.inline.hpp @@ -45,7 +45,7 @@ inline ClassLoaderData* ClassLoaderData::class_loader_data(oop loader) { inline ClassLoaderData *ClassLoaderDataGraph::find_or_create(Handle loader, TRAPS) { - assert(loader() != NULL,"Must be a class loader"); + guarantee(loader() != NULL && loader()->is_oop(), "Loader must be oop"); // Gets the class loader data out of the java/lang/ClassLoader object, if non-null // it's already in the loader_data, so no need to add ClassLoaderData* loader_data= java_lang_ClassLoader::loader_data(loader()); -- GitLab From 61541740ca92cbbb5326f6748d9d18f3998462fc Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Wed, 27 Apr 2016 11:25:16 +0200 Subject: [PATCH 221/400] 8155209: Move setting of young index in cset to G1CollectionSet Reviewed-by: sjohanss, ehelin --- .../src/share/vm/gc/g1/g1CollectionSet.cpp | 36 +++++++++++++++++-- .../src/share/vm/gc/g1/g1CollectionSet.hpp | 4 +++ .../src/share/vm/gc/g1/g1DefaultPolicy.hpp | 6 ++-- hotspot/src/share/vm/gc/g1/g1Policy.hpp | 4 +-- hotspot/src/share/vm/gc/g1/youngList.cpp | 7 ++-- 5 files changed, 43 insertions(+), 14 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp index bb041c65258..b64a820a385 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp @@ -48,7 +48,6 @@ double G1CollectionSet::predict_region_elapsed_time_ms(HeapRegion* hr) { return _policy->predict_region_elapsed_time_ms(hr, collector_state()->gcs_are_young()); } - G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy) : _g1(g1h), _policy(policy), @@ -68,7 +67,8 @@ G1CollectionSet::G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy) : _inc_recorded_rs_lengths(0), _inc_recorded_rs_lengths_diffs(0), _inc_predicted_elapsed_time_ms(0.0), - _inc_predicted_elapsed_time_ms_diffs(0.0) {} + _inc_predicted_elapsed_time_ms_diffs(0.0), + _inc_region_length(0) {} G1CollectionSet::~G1CollectionSet() { delete _cset_chooser; @@ -78,6 +78,9 @@ void G1CollectionSet::init_region_lengths(uint eden_cset_region_length, uint survivor_cset_region_length) { _eden_region_length = eden_cset_region_length; _survivor_region_length = survivor_cset_region_length; + + assert(young_region_length() == _inc_region_length, "should match %u == %u", young_region_length(), _inc_region_length); + _old_region_length = 0; } @@ -107,6 +110,7 @@ void G1CollectionSet::start_incremental_building() { _inc_head = NULL; _inc_tail = NULL; _inc_bytes_used_before = 0; + _inc_region_length = 0; _inc_recorded_rs_lengths = 0; _inc_recorded_rs_lengths_diffs = 0; @@ -177,9 +181,11 @@ void G1CollectionSet::update_young_region_prediction(HeapRegion* hr, void G1CollectionSet::add_young_region_common(HeapRegion* hr) { assert(hr->is_young(), "invariant"); - assert(hr->young_index_in_cset() > -1, "should have already been set"); assert(_inc_build_state == Active, "Precondition"); + hr->set_young_index_in_cset(_inc_region_length); + _inc_region_length++; + // This routine is used when: // * adding survivor regions to the incremental cset at the end of an // evacuation pause or @@ -306,6 +312,8 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms) { hr = hr->get_next_young_region(); } + verify_young_cset_indices(); + // Clear the fields that point to the survivor list - they are all young now. young_list->clear_survivors(); @@ -424,3 +432,25 @@ void G1CollectionSet::finalize_old_part(double time_remaining_ms) { double non_young_end_time_sec = os::elapsedTime(); phase_times()->record_non_young_cset_choice_time_ms((non_young_end_time_sec - non_young_start_time_sec) * 1000.0); } + +#ifdef ASSERT +void G1CollectionSet::verify_young_cset_indices() const { + ResourceMark rm; + uint* heap_region_indices = NEW_RESOURCE_ARRAY(uint, young_region_length()); + for (uint i = 0; i < young_region_length(); ++i) { + heap_region_indices[i] = (uint)-1; + } + + for (HeapRegion* hr = _inc_head; hr != NULL; hr = hr->next_in_collection_set()) { + const int idx = hr->young_index_in_cset(); + assert(idx > -1, "must be set for all inc cset regions"); + assert((uint)idx < young_region_length(), "young cset index too large"); + + assert(heap_region_indices[idx] == (uint)-1, + "index %d used by multiple regions, first use by %u, second by %u", + idx, heap_region_indices[idx], hr->hrm_index()); + + heap_region_indices[idx] = hr->hrm_index(); + } +} +#endif diff --git a/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp b/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp index 0ab3b8766b8..7dae216e7d0 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp @@ -104,11 +104,14 @@ class G1CollectionSet VALUE_OBJ_CLASS_SPEC { // See the comment for _inc_recorded_rs_lengths_diffs. double _inc_predicted_elapsed_time_ms_diffs; + uint _inc_region_length; + G1CollectorState* collector_state(); G1GCPhaseTimes* phase_times(); double predict_region_elapsed_time_ms(HeapRegion* hr); + void verify_young_cset_indices() const NOT_DEBUG_RETURN; public: G1CollectionSet(G1CollectedHeap* g1h, G1Policy* policy); ~G1CollectionSet(); @@ -147,6 +150,7 @@ public: void clear_incremental() { _inc_head = NULL; _inc_tail = NULL; + _inc_region_length = 0; } // Stop adding regions to the incremental collection set diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp index 7c4d253ad9a..03b7d209cd1 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp @@ -113,16 +113,14 @@ public: // Accessors - void set_region_eden(HeapRegion* hr, int young_index_in_cset) { + void set_region_eden(HeapRegion* hr) { hr->set_eden(); hr->install_surv_rate_group(_short_lived_surv_rate_group); - hr->set_young_index_in_cset(young_index_in_cset); } - void set_region_survivor(HeapRegion* hr, int young_index_in_cset) { + void set_region_survivor(HeapRegion* hr) { assert(hr->is_survivor(), "pre-condition"); hr->install_surv_rate_group(_survivor_surv_rate_group); - hr->set_young_index_in_cset(young_index_in_cset); } #ifndef PRODUCT diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.hpp b/hotspot/src/share/vm/gc/g1/g1Policy.hpp index f0c6730aced..5d308cbd9c8 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp @@ -57,8 +57,8 @@ public: // Accessors - virtual void set_region_eden(HeapRegion* hr, int young_index_in_cset) = 0; - virtual void set_region_survivor(HeapRegion* hr, int young_index_in_cset) = 0; + virtual void set_region_eden(HeapRegion* hr) = 0; + virtual void set_region_survivor(HeapRegion* hr) = 0; virtual void record_max_rs_lengths(size_t rs_lengths) = 0; diff --git a/hotspot/src/share/vm/gc/g1/youngList.cpp b/hotspot/src/share/vm/gc/g1/youngList.cpp index c68e665185e..1c10e0affa9 100644 --- a/hotspot/src/share/vm/gc/g1/youngList.cpp +++ b/hotspot/src/share/vm/gc/g1/youngList.cpp @@ -46,7 +46,7 @@ void YoungList::push_region(HeapRegion *hr) { hr->set_next_young_region(_head); _head = hr; - _g1h->g1_policy()->set_region_eden(hr, (int) _length); + _g1h->g1_policy()->set_region_eden(hr); ++_length; } @@ -145,19 +145,16 @@ YoungList::reset_auxilary_lists() { _g1h->g1_policy()->note_start_adding_survivor_regions(); _g1h->g1_policy()->finished_recalculating_age_indexes(true /* is_survivors */); - int young_index_in_cset = 0; for (HeapRegion* curr = _survivor_head; curr != NULL; curr = curr->get_next_young_region()) { - _g1h->g1_policy()->set_region_survivor(curr, young_index_in_cset); + _g1h->g1_policy()->set_region_survivor(curr); // The region is a non-empty survivor so let's add it to // the incremental collection set for the next evacuation // pause. _g1h->collection_set()->add_survivor_regions(curr); - young_index_in_cset += 1; } - assert((uint) young_index_in_cset == _survivor_length, "post-condition"); _g1h->g1_policy()->note_stop_adding_survivor_regions(); _head = _survivor_head; -- GitLab From d181cff8af7182da64553fb2be08efa2334bcc57 Mon Sep 17 00:00:00 2001 From: Erik Helin Date: Wed, 27 Apr 2016 13:01:04 +0200 Subject: [PATCH 222/400] 8155224: Bring back version control history to g1Policy.hpp and g1DefaultPolicy.* Reviewed-by: pliden, mgerdin, sjohanss --- .../share/vm/gc/g1/g1CollectedHeap_ext.cpp | 3 +- .../g1/{g1Policy.cpp => g1DefaultPolicy.cpp} | 147 +++--- .../src/share/vm/gc/g1/g1DefaultPolicy.hpp | 440 ++++++++++++++++++ hotspot/src/share/vm/gc/g1/g1Policy.hpp | 372 +++------------ 4 files changed, 575 insertions(+), 387 deletions(-) rename hotspot/src/share/vm/gc/g1/{g1Policy.cpp => g1DefaultPolicy.cpp} (89%) create mode 100644 hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp index a58901f32a8..29766047edd 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap_ext.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc/g1/g1CollectedHeap.hpp" +#include "gc/g1/g1DefaultPolicy.hpp" #include "gc/g1/g1ParScanThreadState.hpp" #include "gc/g1/heapRegion.inline.hpp" @@ -40,5 +41,5 @@ HeapRegion* G1CollectedHeap::new_heap_region(uint hrs_index, } G1Policy* G1CollectedHeap::create_g1_policy() { - return new G1Policy; + return new G1DefaultPolicy(); } diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp similarity index 89% rename from hotspot/src/share/vm/gc/g1/g1Policy.cpp rename to hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index e58d97a2e9e..e34d023326d 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -29,6 +29,7 @@ #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1CollectionSet.hpp" #include "gc/g1/g1ConcurrentMark.hpp" +#include "gc/g1/g1DefaultPolicy.hpp" #include "gc/g1/g1IHOPControl.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1Policy.hpp" @@ -42,7 +43,7 @@ #include "utilities/debug.hpp" #include "utilities/pair.hpp" -G1Policy::G1Policy() : +G1DefaultPolicy::G1DefaultPolicy() : _predictor(G1ConfidencePercent / 100.0), _analytics(new G1Analytics(&_predictor)), _mmu_tracker(new G1MMUTrackerQueue(GCPauseIntervalMillis / 1000.0, MaxGCPauseMillis / 1000.0)), @@ -63,13 +64,13 @@ G1Policy::G1Policy() : _max_survivor_regions(0), _survivors_age_table(true) { } -G1Policy::~G1Policy() { +G1DefaultPolicy::~G1DefaultPolicy() { delete _ihop_control; } -G1CollectorState* G1Policy::collector_state() const { return _g1->collector_state(); } +G1CollectorState* G1DefaultPolicy::collector_state() const { return _g1->collector_state(); } -void G1Policy::init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) { +void G1DefaultPolicy::init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) { _g1 = g1h; _collection_set = collection_set; @@ -88,14 +89,14 @@ void G1Policy::init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) { _collection_set->start_incremental_building(); } -void G1Policy::note_gc_start() { +void G1DefaultPolicy::note_gc_start() { phase_times()->note_gc_start(); } -bool G1Policy::predict_will_fit(uint young_length, - double base_time_ms, - uint base_free_regions, - double target_pause_time_ms) const { +bool G1DefaultPolicy::predict_will_fit(uint young_length, + double base_time_ms, + uint base_free_regions, + double target_pause_time_ms) const { if (young_length >= base_free_regions) { // end condition 1: not enough space for the young regions return false; @@ -134,7 +135,7 @@ bool G1Policy::predict_will_fit(uint young_length, return true; } -void G1Policy::record_new_heap_size(uint new_number_of_regions) { +void G1DefaultPolicy::record_new_heap_size(uint new_number_of_regions) { // re-calculate the necessary reserve double reserve_regions_d = (double) new_number_of_regions * _reserve_factor; // We use ceiling so that if reserve_regions_d is > 0.0 (but @@ -146,7 +147,7 @@ void G1Policy::record_new_heap_size(uint new_number_of_regions) { _ihop_control->update_target_occupancy(new_number_of_regions * HeapRegion::GrainBytes); } -uint G1Policy::calculate_young_list_desired_min_length(uint base_min_length) const { +uint G1DefaultPolicy::calculate_young_list_desired_min_length(uint base_min_length) const { uint desired_min_length = 0; if (adaptive_young_list_length()) { if (_analytics->num_alloc_rate_ms() > 3) { @@ -163,30 +164,30 @@ uint G1Policy::calculate_young_list_desired_min_length(uint base_min_length) con return MAX2(_young_gen_sizer.min_desired_young_length(), desired_min_length); } -uint G1Policy::calculate_young_list_desired_max_length() const { +uint G1DefaultPolicy::calculate_young_list_desired_max_length() const { // Here, we might want to also take into account any additional // constraints (i.e., user-defined minimum bound). Currently, we // effectively don't set this bound. return _young_gen_sizer.max_desired_young_length(); } -uint G1Policy::update_young_list_max_and_target_length() { +uint G1DefaultPolicy::update_young_list_max_and_target_length() { return update_young_list_max_and_target_length(_analytics->predict_rs_lengths()); } -uint G1Policy::update_young_list_max_and_target_length(size_t rs_lengths) { +uint G1DefaultPolicy::update_young_list_max_and_target_length(size_t rs_lengths) { uint unbounded_target_length = update_young_list_target_length(rs_lengths); update_max_gc_locker_expansion(); return unbounded_target_length; } -uint G1Policy::update_young_list_target_length(size_t rs_lengths) { +uint G1DefaultPolicy::update_young_list_target_length(size_t rs_lengths) { YoungTargetLengths young_lengths = young_list_target_lengths(rs_lengths); _young_list_target_length = young_lengths.first; return young_lengths.second; } -G1Policy::YoungTargetLengths G1Policy::young_list_target_lengths(size_t rs_lengths) const { +G1DefaultPolicy::YoungTargetLengths G1DefaultPolicy::young_list_target_lengths(size_t rs_lengths) const { YoungTargetLengths result; // Calculate the absolute and desired min bounds first. @@ -252,10 +253,10 @@ G1Policy::YoungTargetLengths G1Policy::young_list_target_lengths(size_t rs_lengt } uint -G1Policy::calculate_young_list_target_length(size_t rs_lengths, - uint base_min_length, - uint desired_min_length, - uint desired_max_length) const { +G1DefaultPolicy::calculate_young_list_target_length(size_t rs_lengths, + uint base_min_length, + uint desired_min_length, + uint desired_max_length) const { assert(adaptive_young_list_length(), "pre-condition"); assert(collector_state()->gcs_are_young(), "only call this for young GCs"); @@ -355,7 +356,7 @@ G1Policy::calculate_young_list_target_length(size_t rs_lengths, return base_min_length + min_young_length; } -double G1Policy::predict_survivor_regions_evac_time() const { +double G1DefaultPolicy::predict_survivor_regions_evac_time() const { double survivor_regions_evac_time = 0.0; for (HeapRegion * r = _g1->young_list()->first_survivor_region(); r != NULL && r != _g1->young_list()->last_survivor_region()->get_next_young_region(); @@ -365,7 +366,7 @@ double G1Policy::predict_survivor_regions_evac_time() const { return survivor_regions_evac_time; } -void G1Policy::revise_young_list_target_length_if_necessary(size_t rs_lengths) { +void G1DefaultPolicy::revise_young_list_target_length_if_necessary(size_t rs_lengths) { guarantee( adaptive_young_list_length(), "should not call this otherwise" ); if (rs_lengths > _rs_lengths_prediction) { @@ -377,25 +378,25 @@ void G1Policy::revise_young_list_target_length_if_necessary(size_t rs_lengths) { } } -void G1Policy::update_rs_lengths_prediction() { +void G1DefaultPolicy::update_rs_lengths_prediction() { update_rs_lengths_prediction(_analytics->predict_rs_lengths()); } -void G1Policy::update_rs_lengths_prediction(size_t prediction) { +void G1DefaultPolicy::update_rs_lengths_prediction(size_t prediction) { if (collector_state()->gcs_are_young() && adaptive_young_list_length()) { _rs_lengths_prediction = prediction; } } #ifndef PRODUCT -bool G1Policy::verify_young_ages() { +bool G1DefaultPolicy::verify_young_ages() { HeapRegion* head = _g1->young_list()->first_region(); return verify_young_ages(head, _short_lived_surv_rate_group); // also call verify_young_ages on any additional surv rate groups } -bool G1Policy::verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group) { +bool G1DefaultPolicy::verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group) { guarantee( surv_rate_group != NULL, "pre-condition" ); const char* name = surv_rate_group->name(); @@ -431,13 +432,13 @@ bool G1Policy::verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_grou } #endif // PRODUCT -void G1Policy::record_full_collection_start() { +void G1DefaultPolicy::record_full_collection_start() { _full_collection_start_sec = os::elapsedTime(); // Release the future to-space so that it is available for compaction into. collector_state()->set_full_collection(true); } -void G1Policy::record_full_collection_end() { +void G1DefaultPolicy::record_full_collection_end() { // Consider this like a collection pause for the purposes of allocation // since last pause. double end_sec = os::elapsedTime(); @@ -472,7 +473,7 @@ void G1Policy::record_full_collection_end() { record_pause(FullGC, _full_collection_start_sec, end_sec); } -void G1Policy::record_collection_pause_start(double start_time_sec) { +void G1DefaultPolicy::record_collection_pause_start(double start_time_sec) { // We only need to do this here as the policy will only be applied // to the GC we're about to start. so, no point is calculating this // every time we calculate / recalculate the target young length. @@ -497,18 +498,18 @@ void G1Policy::record_collection_pause_start(double start_time_sec) { assert( verify_young_ages(), "region age verification" ); } -void G1Policy::record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) { +void G1DefaultPolicy::record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) { collector_state()->set_during_marking(true); assert(!collector_state()->initiate_conc_mark_if_possible(), "we should have cleared it by now"); collector_state()->set_during_initial_mark_pause(false); } -void G1Policy::record_concurrent_mark_remark_start() { +void G1DefaultPolicy::record_concurrent_mark_remark_start() { _mark_remark_start_sec = os::elapsedTime(); collector_state()->set_during_marking(false); } -void G1Policy::record_concurrent_mark_remark_end() { +void G1DefaultPolicy::record_concurrent_mark_remark_end() { double end_time_sec = os::elapsedTime(); double elapsed_time_ms = (end_time_sec - _mark_remark_start_sec)*1000.0; _analytics->report_concurrent_mark_remark_times_ms(elapsed_time_ms); @@ -517,11 +518,11 @@ void G1Policy::record_concurrent_mark_remark_end() { record_pause(Remark, _mark_remark_start_sec, end_time_sec); } -void G1Policy::record_concurrent_mark_cleanup_start() { +void G1DefaultPolicy::record_concurrent_mark_cleanup_start() { _mark_cleanup_start_sec = os::elapsedTime(); } -void G1Policy::record_concurrent_mark_cleanup_completed() { +void G1DefaultPolicy::record_concurrent_mark_cleanup_completed() { bool should_continue_with_reclaim = next_gc_should_be_mixed("request last young-only gc", "skip last young-only gc"); collector_state()->set_last_young_gc(should_continue_with_reclaim); @@ -532,22 +533,22 @@ void G1Policy::record_concurrent_mark_cleanup_completed() { collector_state()->set_in_marking_window(false); } -double G1Policy::average_time_ms(G1GCPhaseTimes::GCParPhases phase) const { +double G1DefaultPolicy::average_time_ms(G1GCPhaseTimes::GCParPhases phase) const { return phase_times()->average_time_ms(phase); } -double G1Policy::young_other_time_ms() const { +double G1DefaultPolicy::young_other_time_ms() const { return phase_times()->young_cset_choice_time_ms() + phase_times()->young_free_cset_time_ms(); } -double G1Policy::non_young_other_time_ms() const { +double G1DefaultPolicy::non_young_other_time_ms() const { return phase_times()->non_young_cset_choice_time_ms() + phase_times()->non_young_free_cset_time_ms(); } -double G1Policy::other_time_ms(double pause_time_ms) const { +double G1DefaultPolicy::other_time_ms(double pause_time_ms) const { return pause_time_ms - average_time_ms(G1GCPhaseTimes::UpdateRS) - average_time_ms(G1GCPhaseTimes::ScanRS) - @@ -555,19 +556,19 @@ double G1Policy::other_time_ms(double pause_time_ms) const { average_time_ms(G1GCPhaseTimes::Termination); } -double G1Policy::constant_other_time_ms(double pause_time_ms) const { +double G1DefaultPolicy::constant_other_time_ms(double pause_time_ms) const { return other_time_ms(pause_time_ms) - young_other_time_ms() - non_young_other_time_ms(); } -CollectionSetChooser* G1Policy::cset_chooser() const { +CollectionSetChooser* G1DefaultPolicy::cset_chooser() const { return _collection_set->cset_chooser(); } -bool G1Policy::about_to_start_mixed_phase() const { +bool G1DefaultPolicy::about_to_start_mixed_phase() const { return _g1->concurrent_mark()->cmThread()->during_cycle() || collector_state()->last_young_gc(); } -bool G1Policy::need_to_start_conc_mark(const char* source, size_t alloc_word_size) { +bool G1DefaultPolicy::need_to_start_conc_mark(const char* source, size_t alloc_word_size) { if (about_to_start_mixed_phase()) { return false; } @@ -592,7 +593,7 @@ bool G1Policy::need_to_start_conc_mark(const char* source, size_t alloc_word_siz // Anything below that is considered to be zero #define MIN_TIMER_GRANULARITY 0.0000001 -void G1Policy::record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) { +void G1DefaultPolicy::record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) { double end_time_sec = os::elapsedTime(); size_t cur_used_bytes = _g1->used(); @@ -778,7 +779,7 @@ void G1Policy::record_collection_pause_end(double pause_time_ms, size_t cards_sc cset_chooser()->verify(); } -G1IHOPControl* G1Policy::create_ihop_control(const G1Predictions* predictor){ +G1IHOPControl* G1DefaultPolicy::create_ihop_control(const G1Predictions* predictor){ if (G1UseAdaptiveIHOP) { return new G1AdaptiveIHOPControl(InitiatingHeapOccupancyPercent, predictor, @@ -789,7 +790,7 @@ G1IHOPControl* G1Policy::create_ihop_control(const G1Predictions* predictor){ } } -void G1Policy::update_ihop_prediction(double mutator_time_s, +void G1DefaultPolicy::update_ihop_prediction(double mutator_time_s, size_t mutator_alloc_bytes, size_t young_gen_size) { // Always try to update IHOP prediction. Even evacuation failures give information @@ -827,15 +828,15 @@ void G1Policy::update_ihop_prediction(double mutator_time_s, } } -void G1Policy::report_ihop_statistics() { +void G1DefaultPolicy::report_ihop_statistics() { _ihop_control->print(); } -void G1Policy::print_phases() { +void G1DefaultPolicy::print_phases() { phase_times()->print(); } -double G1Policy::predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const { +double G1DefaultPolicy::predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const { TruncatedSeq* seq = surv_rate_group->get_seq(age); guarantee(seq->num() > 0, "There should be some young gen survivor samples available. Tried to access with age %d", age); double pred = _predictor.get_new_prediction(seq); @@ -845,15 +846,15 @@ double G1Policy::predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) c return pred; } -double G1Policy::predict_yg_surv_rate(int age) const { +double G1DefaultPolicy::predict_yg_surv_rate(int age) const { return predict_yg_surv_rate(age, _short_lived_surv_rate_group); } -double G1Policy::accum_yg_surv_rate_pred(int age) const { +double G1DefaultPolicy::accum_yg_surv_rate_pred(int age) const { return _short_lived_surv_rate_group->accum_surv_rate_pred(age); } -double G1Policy::predict_base_elapsed_time_ms(size_t pending_cards, +double G1DefaultPolicy::predict_base_elapsed_time_ms(size_t pending_cards, size_t scanned_cards) const { return _analytics->predict_rs_update_time_ms(pending_cards) + @@ -861,13 +862,13 @@ double G1Policy::predict_base_elapsed_time_ms(size_t pending_cards, _analytics->predict_constant_other_time_ms(); } -double G1Policy::predict_base_elapsed_time_ms(size_t pending_cards) const { +double G1DefaultPolicy::predict_base_elapsed_time_ms(size_t pending_cards) const { size_t rs_length = _analytics->predict_rs_lengths() + _analytics->predict_rs_length_diff(); size_t card_num = _analytics->predict_card_num(rs_length, collector_state()->gcs_are_young()); return predict_base_elapsed_time_ms(pending_cards, card_num); } -size_t G1Policy::predict_bytes_to_copy(HeapRegion* hr) const { +size_t G1DefaultPolicy::predict_bytes_to_copy(HeapRegion* hr) const { size_t bytes_to_copy; if (hr->is_marked()) bytes_to_copy = hr->max_live_bytes(); @@ -880,7 +881,7 @@ size_t G1Policy::predict_bytes_to_copy(HeapRegion* hr) const { return bytes_to_copy; } -double G1Policy::predict_region_elapsed_time_ms(HeapRegion* hr, +double G1DefaultPolicy::predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const { size_t rs_length = hr->rem_set()->occupied(); // Predicting the number of cards is based on which type of GC @@ -903,30 +904,30 @@ double G1Policy::predict_region_elapsed_time_ms(HeapRegion* hr, } -void G1Policy::print_yg_surv_rate_info() const { +void G1DefaultPolicy::print_yg_surv_rate_info() const { #ifndef PRODUCT _short_lived_surv_rate_group->print_surv_rate_summary(); // add this call for any other surv rate groups #endif // PRODUCT } -bool G1Policy::is_young_list_full() const { +bool G1DefaultPolicy::is_young_list_full() const { uint young_list_length = _g1->young_list()->length(); uint young_list_target_length = _young_list_target_length; return young_list_length >= young_list_target_length; } -bool G1Policy::can_expand_young_list() const { +bool G1DefaultPolicy::can_expand_young_list() const { uint young_list_length = _g1->young_list()->length(); uint young_list_max_length = _young_list_max_length; return young_list_length < young_list_max_length; } -bool G1Policy::adaptive_young_list_length() const { +bool G1DefaultPolicy::adaptive_young_list_length() const { return _young_gen_sizer.adaptive_young_list_length(); } -void G1Policy::update_max_gc_locker_expansion() { +void G1DefaultPolicy::update_max_gc_locker_expansion() { uint expansion_region_num = 0; if (GCLockerEdenExpansionPercent > 0) { double perc = (double) GCLockerEdenExpansionPercent / 100.0; @@ -942,7 +943,7 @@ void G1Policy::update_max_gc_locker_expansion() { } // Calculates survivor space parameters. -void G1Policy::update_survivors_policy() { +void G1DefaultPolicy::update_survivors_policy() { double max_survivor_regions_d = (double) _young_list_target_length / (double) SurvivorRatio; // We use ceiling so that if max_survivor_regions_d is > 0.0 (but @@ -953,7 +954,7 @@ void G1Policy::update_survivors_policy() { HeapRegion::GrainWords * _max_survivor_regions, _policy_counters); } -bool G1Policy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) { +bool G1DefaultPolicy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) { // We actually check whether we are marking here and not if we are in a // reclamation phase. This means that we will schedule a concurrent mark // even while we are still in the process of reclaiming memory. @@ -968,12 +969,12 @@ bool G1Policy::force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) { } } -void G1Policy::initiate_conc_mark() { +void G1DefaultPolicy::initiate_conc_mark() { collector_state()->set_during_initial_mark_pause(true); collector_state()->set_initiate_conc_mark_if_possible(false); } -void G1Policy::decide_on_conc_mark_initiation() { +void G1DefaultPolicy::decide_on_conc_mark_initiation() { // We are about to decide on whether this pause will be an // initial-mark pause. @@ -1019,7 +1020,7 @@ void G1Policy::decide_on_conc_mark_initiation() { } } -void G1Policy::record_concurrent_mark_cleanup_end() { +void G1DefaultPolicy::record_concurrent_mark_cleanup_end() { cset_chooser()->rebuild(_g1->workers(), _g1->num_regions()); double end_sec = os::elapsedTime(); @@ -1030,7 +1031,7 @@ void G1Policy::record_concurrent_mark_cleanup_end() { record_pause(Cleanup, _mark_cleanup_start_sec, end_sec); } -double G1Policy::reclaimable_bytes_perc(size_t reclaimable_bytes) const { +double G1DefaultPolicy::reclaimable_bytes_perc(size_t reclaimable_bytes) const { // Returns the given amount of reclaimable bytes (that represents // the amount of reclaimable space still to be collected) as a // percentage of the current heap capacity. @@ -1038,7 +1039,7 @@ double G1Policy::reclaimable_bytes_perc(size_t reclaimable_bytes) const { return (double) reclaimable_bytes * 100.0 / (double) capacity_bytes; } -void G1Policy::maybe_start_marking() { +void G1DefaultPolicy::maybe_start_marking() { if (need_to_start_conc_mark("end of GC")) { // Note: this might have already been set, if during the last // pause we decided to start a cycle but at the beginning of @@ -1047,7 +1048,7 @@ void G1Policy::maybe_start_marking() { } } -G1Policy::PauseKind G1Policy::young_gc_pause_kind() const { +G1DefaultPolicy::PauseKind G1DefaultPolicy::young_gc_pause_kind() const { assert(!collector_state()->full_collection(), "must be"); if (collector_state()->during_initial_mark_pause()) { assert(collector_state()->last_gc_was_young(), "must be"); @@ -1069,7 +1070,7 @@ G1Policy::PauseKind G1Policy::young_gc_pause_kind() const { } } -void G1Policy::record_pause(PauseKind kind, double start, double end) { +void G1DefaultPolicy::record_pause(PauseKind kind, double start, double end) { // Manage the MMU tracker. For some reason it ignores Full GCs. if (kind != FullGC) { _mmu_tracker->add_pause(start, end); @@ -1096,11 +1097,11 @@ void G1Policy::record_pause(PauseKind kind, double start, double end) { } } -void G1Policy::abort_time_to_mixed_tracking() { +void G1DefaultPolicy::abort_time_to_mixed_tracking() { _initial_mark_to_mixed.reset(); } -bool G1Policy::next_gc_should_be_mixed(const char* true_action_str, +bool G1DefaultPolicy::next_gc_should_be_mixed(const char* true_action_str, const char* false_action_str) const { if (cset_chooser()->is_empty()) { log_debug(gc, ergo)("%s (candidate old regions not available)", false_action_str); @@ -1121,7 +1122,7 @@ bool G1Policy::next_gc_should_be_mixed(const char* true_action_str, return true; } -uint G1Policy::calc_min_old_cset_length() const { +uint G1DefaultPolicy::calc_min_old_cset_length() const { // The min old CSet region bound is based on the maximum desired // number of mixed GCs after a cycle. I.e., even if some old regions // look expensive, we should add them to the CSet anyway to make @@ -1142,7 +1143,7 @@ uint G1Policy::calc_min_old_cset_length() const { return (uint) result; } -uint G1Policy::calc_max_old_cset_length() const { +uint G1DefaultPolicy::calc_max_old_cset_length() const { // The max old CSet region bound is based on the threshold expressed // as a percentage of the heap size. I.e., it should bound the // number of old regions added to the CSet irrespective of how many @@ -1159,7 +1160,7 @@ uint G1Policy::calc_max_old_cset_length() const { return (uint) result; } -void G1Policy::finalize_collection_set(double target_pause_time_ms) { +void G1DefaultPolicy::finalize_collection_set(double target_pause_time_ms) { double time_remaining_ms = _collection_set->finalize_young_part(target_pause_time_ms); _collection_set->finalize_old_part(time_remaining_ms); } diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp new file mode 100644 index 00000000000..9c0d22474fb --- /dev/null +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp @@ -0,0 +1,440 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_GC_G1_G1DEFAULTPOLICY_HPP +#define SHARE_VM_GC_G1_G1DEFAULTPOLICY_HPP + +#include "gc/g1/g1CollectorState.hpp" +#include "gc/g1/g1GCPhaseTimes.hpp" +#include "gc/g1/g1InCSetState.hpp" +#include "gc/g1/g1InitialMarkToMixedTimeTracker.hpp" +#include "gc/g1/g1MMUTracker.hpp" +#include "gc/g1/g1Predictions.hpp" +#include "gc/g1/g1Policy.hpp" +#include "gc/g1/g1YoungGenSizer.hpp" +#include "gc/shared/gcCause.hpp" +#include "utilities/pair.hpp" + +// A G1Policy makes policy decisions that determine the +// characteristics of the collector. Examples include: +// * choice of collection set. +// * when to collect. + +class HeapRegion; +class G1CollectionSet; +class CollectionSetChooser; +class G1IHOPControl; +class G1Analytics; +class G1YoungGenSizer; +class GCPolicyCounters; + +class G1DefaultPolicy: public G1Policy { + private: + + static G1IHOPControl* create_ihop_control(const G1Predictions* predictor); + // Update the IHOP control with necessary statistics. + void update_ihop_prediction(double mutator_time_s, + size_t mutator_alloc_bytes, + size_t young_gen_size); + void report_ihop_statistics(); + + G1Predictions _predictor; + G1Analytics* _analytics; + G1MMUTracker* _mmu_tracker; + G1IHOPControl* _ihop_control; + + GCPolicyCounters* _policy_counters; + + double _full_collection_start_sec; + + uint _young_list_target_length; + uint _young_list_fixed_length; + + // The max number of regions we can extend the eden by while the GC + // locker is active. This should be >= _young_list_target_length; + uint _young_list_max_length; + + // SurvRateGroups below must be initialized after the predictor because they + // indirectly use it through this object passed to their constructor. + SurvRateGroup* _short_lived_surv_rate_group; + SurvRateGroup* _survivor_surv_rate_group; + + double _reserve_factor; + // This will be set when the heap is expanded + // for the first time during initialization. + uint _reserve_regions; + + G1YoungGenSizer _young_gen_sizer; + + uint _free_regions_at_end_of_collection; + + size_t _max_rs_lengths; + + size_t _rs_lengths_prediction; + +#ifndef PRODUCT + bool verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group); +#endif // PRODUCT + + size_t _pending_cards; + + // The amount of allocated bytes in old gen during the last mutator and the following + // young GC phase. + size_t _bytes_allocated_in_old_since_last_gc; + + G1InitialMarkToMixedTimeTracker _initial_mark_to_mixed; +public: + const G1Predictions& predictor() const { return _predictor; } + const G1Analytics* analytics() const { return const_cast(_analytics); } + + // Add the given number of bytes to the total number of allocated bytes in the old gen. + void add_bytes_allocated_in_old_since_last_gc(size_t bytes) { _bytes_allocated_in_old_since_last_gc += bytes; } + + // Accessors + + void set_region_eden(HeapRegion* hr, int young_index_in_cset) { + hr->set_eden(); + hr->install_surv_rate_group(_short_lived_surv_rate_group); + hr->set_young_index_in_cset(young_index_in_cset); + } + + void set_region_survivor(HeapRegion* hr, int young_index_in_cset) { + assert(hr->is_survivor(), "pre-condition"); + hr->install_surv_rate_group(_survivor_surv_rate_group); + hr->set_young_index_in_cset(young_index_in_cset); + } + +#ifndef PRODUCT + bool verify_young_ages(); +#endif // PRODUCT + + void record_max_rs_lengths(size_t rs_lengths) { + _max_rs_lengths = rs_lengths; + } + + + double predict_base_elapsed_time_ms(size_t pending_cards) const; + double predict_base_elapsed_time_ms(size_t pending_cards, + size_t scanned_cards) const; + size_t predict_bytes_to_copy(HeapRegion* hr) const; + double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const; + + double predict_survivor_regions_evac_time() const; + + bool should_update_surv_rate_group_predictors() { + return collector_state()->last_gc_was_young() && !collector_state()->in_marking_window(); + } + + void cset_regions_freed() { + bool update = should_update_surv_rate_group_predictors(); + + _short_lived_surv_rate_group->all_surviving_words_recorded(update); + _survivor_surv_rate_group->all_surviving_words_recorded(update); + } + + G1MMUTracker* mmu_tracker() { + return _mmu_tracker; + } + + const G1MMUTracker* mmu_tracker() const { + return _mmu_tracker; + } + + double max_pause_time_ms() const { + return _mmu_tracker->max_gc_time() * 1000.0; + } + + // Returns an estimate of the survival rate of the region at yg-age + // "yg_age". + double predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const; + + double predict_yg_surv_rate(int age) const; + + double accum_yg_surv_rate_pred(int age) const; + +protected: + G1CollectionSet* _collection_set; + virtual double average_time_ms(G1GCPhaseTimes::GCParPhases phase) const; + virtual double other_time_ms(double pause_time_ms) const; + + double young_other_time_ms() const; + double non_young_other_time_ms() const; + double constant_other_time_ms(double pause_time_ms) const; + + CollectionSetChooser* cset_chooser() const; +private: + + // The number of bytes copied during the GC. + size_t _bytes_copied_during_gc; + + // Stash a pointer to the g1 heap. + G1CollectedHeap* _g1; + + G1GCPhaseTimes* _phase_times; + + // This set of variables tracks the collector efficiency, in order to + // determine whether we should initiate a new marking. + double _mark_remark_start_sec; + double _mark_cleanup_start_sec; + + // Updates the internal young list maximum and target lengths. Returns the + // unbounded young list target length. + uint update_young_list_max_and_target_length(); + uint update_young_list_max_and_target_length(size_t rs_lengths); + + // Update the young list target length either by setting it to the + // desired fixed value or by calculating it using G1's pause + // prediction model. If no rs_lengths parameter is passed, predict + // the RS lengths using the prediction model, otherwise use the + // given rs_lengths as the prediction. + // Returns the unbounded young list target length. + uint update_young_list_target_length(size_t rs_lengths); + + // Calculate and return the minimum desired young list target + // length. This is the minimum desired young list length according + // to the user's inputs. + uint calculate_young_list_desired_min_length(uint base_min_length) const; + + // Calculate and return the maximum desired young list target + // length. This is the maximum desired young list length according + // to the user's inputs. + uint calculate_young_list_desired_max_length() const; + + // Calculate and return the maximum young list target length that + // can fit into the pause time goal. The parameters are: rs_lengths + // represent the prediction of how large the young RSet lengths will + // be, base_min_length is the already existing number of regions in + // the young list, min_length and max_length are the desired min and + // max young list length according to the user's inputs. + uint calculate_young_list_target_length(size_t rs_lengths, + uint base_min_length, + uint desired_min_length, + uint desired_max_length) const; + + // Result of the bounded_young_list_target_length() method, containing both the + // bounded as well as the unbounded young list target lengths in this order. + typedef Pair YoungTargetLengths; + YoungTargetLengths young_list_target_lengths(size_t rs_lengths) const; + + void update_rs_lengths_prediction(); + void update_rs_lengths_prediction(size_t prediction); + + // Check whether a given young length (young_length) fits into the + // given target pause time and whether the prediction for the amount + // of objects to be copied for the given length will fit into the + // given free space (expressed by base_free_regions). It is used by + // calculate_young_list_target_length(). + bool predict_will_fit(uint young_length, double base_time_ms, + uint base_free_regions, double target_pause_time_ms) const; + +public: + size_t pending_cards() const { return _pending_cards; } + + // Calculate the minimum number of old regions we'll add to the CSet + // during a mixed GC. + uint calc_min_old_cset_length() const; + + // Calculate the maximum number of old regions we'll add to the CSet + // during a mixed GC. + uint calc_max_old_cset_length() const; + + // Returns the given amount of uncollected reclaimable space + // as a percentage of the current heap capacity. + double reclaimable_bytes_perc(size_t reclaimable_bytes) const; + +private: + // Sets up marking if proper conditions are met. + void maybe_start_marking(); + + // The kind of STW pause. + enum PauseKind { + FullGC, + YoungOnlyGC, + MixedGC, + LastYoungGC, + InitialMarkGC, + Cleanup, + Remark + }; + + // Calculate PauseKind from internal state. + PauseKind young_gc_pause_kind() const; + // Record the given STW pause with the given start and end times (in s). + void record_pause(PauseKind kind, double start, double end); + // Indicate that we aborted marking before doing any mixed GCs. + void abort_time_to_mixed_tracking(); +public: + + G1DefaultPolicy(); + + virtual ~G1DefaultPolicy(); + + G1CollectorState* collector_state() const; + + G1GCPhaseTimes* phase_times() const { return _phase_times; } + + // Check the current value of the young list RSet lengths and + // compare it against the last prediction. If the current value is + // higher, recalculate the young list target length prediction. + void revise_young_list_target_length_if_necessary(size_t rs_lengths); + + // This should be called after the heap is resized. + void record_new_heap_size(uint new_number_of_regions); + + void init(G1CollectedHeap* g1h, G1CollectionSet* collection_set); + + virtual void note_gc_start(); + + bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0); + + bool about_to_start_mixed_phase() const; + + // Record the start and end of an evacuation pause. + void record_collection_pause_start(double start_time_sec); + void record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc); + + // Record the start and end of a full collection. + void record_full_collection_start(); + void record_full_collection_end(); + + // Must currently be called while the world is stopped. + void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms); + + // Record start and end of remark. + void record_concurrent_mark_remark_start(); + void record_concurrent_mark_remark_end(); + + // Record start, end, and completion of cleanup. + void record_concurrent_mark_cleanup_start(); + void record_concurrent_mark_cleanup_end(); + void record_concurrent_mark_cleanup_completed(); + + virtual void print_phases(); + + // Record how much space we copied during a GC. This is typically + // called when a GC alloc region is being retired. + void record_bytes_copied_during_gc(size_t bytes) { + _bytes_copied_during_gc += bytes; + } + + // The amount of space we copied during a GC. + size_t bytes_copied_during_gc() const { + return _bytes_copied_during_gc; + } + + // Determine whether there are candidate regions so that the + // next GC should be mixed. The two action strings are used + // in the ergo output when the method returns true or false. + bool next_gc_should_be_mixed(const char* true_action_str, + const char* false_action_str) const; + + virtual void finalize_collection_set(double target_pause_time_ms); +private: + // Set the state to start a concurrent marking cycle and clear + // _initiate_conc_mark_if_possible because it has now been + // acted on. + void initiate_conc_mark(); + +public: + // This sets the initiate_conc_mark_if_possible() flag to start a + // new cycle, as long as we are not already in one. It's best if it + // is called during a safepoint when the test whether a cycle is in + // progress or not is stable. + bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause); + + // This is called at the very beginning of an evacuation pause (it + // has to be the first thing that the pause does). If + // initiate_conc_mark_if_possible() is true, and the concurrent + // marking thread has completed its work during the previous cycle, + // it will set during_initial_mark_pause() to so that the pause does + // the initial-mark work and start a marking cycle. + void decide_on_conc_mark_initiation(); + + // Print stats on young survival ratio + void print_yg_surv_rate_info() const; + + void finished_recalculating_age_indexes(bool is_survivors) { + if (is_survivors) { + _survivor_surv_rate_group->finished_recalculating_age_indexes(); + } else { + _short_lived_surv_rate_group->finished_recalculating_age_indexes(); + } + } + + size_t young_list_target_length() const { return _young_list_target_length; } + + bool is_young_list_full() const; + + bool can_expand_young_list() const; + + uint young_list_max_length() const { + return _young_list_max_length; + } + + bool adaptive_young_list_length() const; + + virtual bool should_process_references() const { + return true; + } + +private: + // + // Survivor regions policy. + // + + // Current tenuring threshold, set to 0 if the collector reaches the + // maximum amount of survivors regions. + uint _tenuring_threshold; + + // The limit on the number of regions allocated for survivors. + uint _max_survivor_regions; + + AgeTable _survivors_age_table; + +public: + uint tenuring_threshold() const { return _tenuring_threshold; } + + uint max_survivor_regions() { + return _max_survivor_regions; + } + + void note_start_adding_survivor_regions() { + _survivor_surv_rate_group->start_adding_regions(); + } + + void note_stop_adding_survivor_regions() { + _survivor_surv_rate_group->stop_adding_regions(); + } + + void record_age_table(AgeTable* age_table) { + _survivors_age_table.merge(age_table); + } + + void update_max_gc_locker_expansion(); + + // Calculates survivor space parameters. + void update_survivors_policy(); +}; + +#endif // SHARE_VM_GC_G1_G1DEFAULTPOLICY_HPP diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.hpp b/hotspot/src/share/vm/gc/g1/g1Policy.hpp index 73b51e92d20..992ed8a6315 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp @@ -46,321 +46,106 @@ class CollectionSetChooser; class G1IHOPControl; class G1Analytics; class G1YoungGenSizer; -class GCPolicyCounters; class G1Policy: public CHeapObj { - private: - - static G1IHOPControl* create_ihop_control(const G1Predictions* predictor); - // Update the IHOP control with necessary statistics. - void update_ihop_prediction(double mutator_time_s, - size_t mutator_alloc_bytes, - size_t young_gen_size); - void report_ihop_statistics(); - - G1Predictions _predictor; - G1Analytics* _analytics; - G1MMUTracker* _mmu_tracker; - G1IHOPControl* _ihop_control; - - GCPolicyCounters* _policy_counters; - - double _full_collection_start_sec; - - uint _young_list_target_length; - uint _young_list_fixed_length; - - // The max number of regions we can extend the eden by while the GC - // locker is active. This should be >= _young_list_target_length; - uint _young_list_max_length; - - // SurvRateGroups below must be initialized after the predictor because they - // indirectly use it through this object passed to their constructor. - SurvRateGroup* _short_lived_surv_rate_group; - SurvRateGroup* _survivor_surv_rate_group; - - double _reserve_factor; - // This will be set when the heap is expanded - // for the first time during initialization. - uint _reserve_regions; - - G1YoungGenSizer _young_gen_sizer; - - uint _free_regions_at_end_of_collection; +public: + virtual const G1Predictions& predictor() const = 0; + virtual const G1Analytics* analytics() const = 0; - size_t _max_rs_lengths; + // Add the given number of bytes to the total number of allocated bytes in the old gen. + virtual void add_bytes_allocated_in_old_since_last_gc(size_t bytes) = 0; - size_t _rs_lengths_prediction; + // Accessors -#ifndef PRODUCT - bool verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group); -#endif // PRODUCT + virtual void set_region_eden(HeapRegion* hr, int young_index_in_cset) = 0; + virtual void set_region_survivor(HeapRegion* hr, int young_index_in_cset) = 0; - size_t _pending_cards; + virtual void record_max_rs_lengths(size_t rs_lengths) = 0; - // The amount of allocated bytes in old gen during the last mutator and the following - // young GC phase. - size_t _bytes_allocated_in_old_since_last_gc; + virtual double predict_base_elapsed_time_ms(size_t pending_cards) const = 0; + virtual double predict_base_elapsed_time_ms(size_t pending_cards, + size_t scanned_cards) const = 0; - G1InitialMarkToMixedTimeTracker _initial_mark_to_mixed; -public: - const G1Predictions& predictor() const { return _predictor; } - const G1Analytics* analytics() const { return const_cast(_analytics); } + virtual double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const = 0; - // Add the given number of bytes to the total number of allocated bytes in the old gen. - void add_bytes_allocated_in_old_since_last_gc(size_t bytes) { _bytes_allocated_in_old_since_last_gc += bytes; } + virtual void cset_regions_freed() = 0; - // Accessors + virtual G1MMUTracker* mmu_tracker() = 0; - void set_region_eden(HeapRegion* hr, int young_index_in_cset) { - hr->set_eden(); - hr->install_surv_rate_group(_short_lived_surv_rate_group); - hr->set_young_index_in_cset(young_index_in_cset); - } + virtual const G1MMUTracker* mmu_tracker() const = 0; - void set_region_survivor(HeapRegion* hr, int young_index_in_cset) { - assert(hr->is_survivor(), "pre-condition"); - hr->install_surv_rate_group(_survivor_surv_rate_group); - hr->set_young_index_in_cset(young_index_in_cset); - } + virtual double max_pause_time_ms() const = 0; -#ifndef PRODUCT - bool verify_young_ages(); -#endif // PRODUCT - - void record_max_rs_lengths(size_t rs_lengths) { - _max_rs_lengths = rs_lengths; - } - - - double predict_base_elapsed_time_ms(size_t pending_cards) const; - double predict_base_elapsed_time_ms(size_t pending_cards, - size_t scanned_cards) const; - size_t predict_bytes_to_copy(HeapRegion* hr) const; - double predict_region_elapsed_time_ms(HeapRegion* hr, bool for_young_gc) const; - - double predict_survivor_regions_evac_time() const; - - bool should_update_surv_rate_group_predictors() { - return collector_state()->last_gc_was_young() && !collector_state()->in_marking_window(); - } - - void cset_regions_freed() { - bool update = should_update_surv_rate_group_predictors(); - - _short_lived_surv_rate_group->all_surviving_words_recorded(update); - _survivor_surv_rate_group->all_surviving_words_recorded(update); - } - - G1MMUTracker* mmu_tracker() { - return _mmu_tracker; - } - - const G1MMUTracker* mmu_tracker() const { - return _mmu_tracker; - } - - double max_pause_time_ms() const { - return _mmu_tracker->max_gc_time() * 1000.0; - } - - // Returns an estimate of the survival rate of the region at yg-age - // "yg_age". - double predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_group) const; - - double predict_yg_surv_rate(int age) const; - - double accum_yg_surv_rate_pred(int age) const; - -protected: - G1CollectionSet* _collection_set; - virtual double average_time_ms(G1GCPhaseTimes::GCParPhases phase) const; - virtual double other_time_ms(double pause_time_ms) const; - - double young_other_time_ms() const; - double non_young_other_time_ms() const; - double constant_other_time_ms(double pause_time_ms) const; - - CollectionSetChooser* cset_chooser() const; -private: - - // The number of bytes copied during the GC. - size_t _bytes_copied_during_gc; - - // Stash a pointer to the g1 heap. - G1CollectedHeap* _g1; - - G1GCPhaseTimes* _phase_times; - - // This set of variables tracks the collector efficiency, in order to - // determine whether we should initiate a new marking. - double _mark_remark_start_sec; - double _mark_cleanup_start_sec; - - // Updates the internal young list maximum and target lengths. Returns the - // unbounded young list target length. - uint update_young_list_max_and_target_length(); - uint update_young_list_max_and_target_length(size_t rs_lengths); - - // Update the young list target length either by setting it to the - // desired fixed value or by calculating it using G1's pause - // prediction model. If no rs_lengths parameter is passed, predict - // the RS lengths using the prediction model, otherwise use the - // given rs_lengths as the prediction. - // Returns the unbounded young list target length. - uint update_young_list_target_length(size_t rs_lengths); - - // Calculate and return the minimum desired young list target - // length. This is the minimum desired young list length according - // to the user's inputs. - uint calculate_young_list_desired_min_length(uint base_min_length) const; - - // Calculate and return the maximum desired young list target - // length. This is the maximum desired young list length according - // to the user's inputs. - uint calculate_young_list_desired_max_length() const; - - // Calculate and return the maximum young list target length that - // can fit into the pause time goal. The parameters are: rs_lengths - // represent the prediction of how large the young RSet lengths will - // be, base_min_length is the already existing number of regions in - // the young list, min_length and max_length are the desired min and - // max young list length according to the user's inputs. - uint calculate_young_list_target_length(size_t rs_lengths, - uint base_min_length, - uint desired_min_length, - uint desired_max_length) const; - - // Result of the bounded_young_list_target_length() method, containing both the - // bounded as well as the unbounded young list target lengths in this order. - typedef Pair YoungTargetLengths; - YoungTargetLengths young_list_target_lengths(size_t rs_lengths) const; - - void update_rs_lengths_prediction(); - void update_rs_lengths_prediction(size_t prediction); - - // Check whether a given young length (young_length) fits into the - // given target pause time and whether the prediction for the amount - // of objects to be copied for the given length will fit into the - // given free space (expressed by base_free_regions). It is used by - // calculate_young_list_target_length(). - bool predict_will_fit(uint young_length, double base_time_ms, - uint base_free_regions, double target_pause_time_ms) const; - -public: - size_t pending_cards() const { return _pending_cards; } + virtual size_t pending_cards() const = 0; // Calculate the minimum number of old regions we'll add to the CSet // during a mixed GC. - uint calc_min_old_cset_length() const; + virtual uint calc_min_old_cset_length() const = 0; // Calculate the maximum number of old regions we'll add to the CSet // during a mixed GC. - uint calc_max_old_cset_length() const; + virtual uint calc_max_old_cset_length() const = 0; // Returns the given amount of uncollected reclaimable space // as a percentage of the current heap capacity. - double reclaimable_bytes_perc(size_t reclaimable_bytes) const; - -private: - // Sets up marking if proper conditions are met. - void maybe_start_marking(); - - // The kind of STW pause. - enum PauseKind { - FullGC, - YoungOnlyGC, - MixedGC, - LastYoungGC, - InitialMarkGC, - Cleanup, - Remark - }; - - // Calculate PauseKind from internal state. - PauseKind young_gc_pause_kind() const; - // Record the given STW pause with the given start and end times (in s). - void record_pause(PauseKind kind, double start, double end); - // Indicate that we aborted marking before doing any mixed GCs. - void abort_time_to_mixed_tracking(); -public: - - G1Policy(); + virtual double reclaimable_bytes_perc(size_t reclaimable_bytes) const = 0; - virtual ~G1Policy(); + virtual ~G1Policy() {} - G1CollectorState* collector_state() const; + virtual G1CollectorState* collector_state() const = 0; - G1GCPhaseTimes* phase_times() const { return _phase_times; } + virtual G1GCPhaseTimes* phase_times() const = 0; // Check the current value of the young list RSet lengths and // compare it against the last prediction. If the current value is // higher, recalculate the young list target length prediction. - void revise_young_list_target_length_if_necessary(size_t rs_lengths); + virtual void revise_young_list_target_length_if_necessary(size_t rs_lengths) = 0; // This should be called after the heap is resized. - void record_new_heap_size(uint new_number_of_regions); + virtual void record_new_heap_size(uint new_number_of_regions) = 0; - void init(G1CollectedHeap* g1h, G1CollectionSet* collection_set); + virtual void init(G1CollectedHeap* g1h, G1CollectionSet* collection_set) = 0; - virtual void note_gc_start(); + virtual void note_gc_start() = 0; - bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0); - - bool about_to_start_mixed_phase() const; + virtual bool need_to_start_conc_mark(const char* source, size_t alloc_word_size = 0) = 0; // Record the start and end of an evacuation pause. - void record_collection_pause_start(double start_time_sec); - void record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc); + virtual void record_collection_pause_start(double start_time_sec) = 0; + virtual void record_collection_pause_end(double pause_time_ms, size_t cards_scanned, size_t heap_used_bytes_before_gc) = 0; // Record the start and end of a full collection. - void record_full_collection_start(); - void record_full_collection_end(); + virtual void record_full_collection_start() = 0; + virtual void record_full_collection_end() = 0; // Must currently be called while the world is stopped. - void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms); + virtual void record_concurrent_mark_init_end(double mark_init_elapsed_time_ms) = 0; // Record start and end of remark. - void record_concurrent_mark_remark_start(); - void record_concurrent_mark_remark_end(); + virtual void record_concurrent_mark_remark_start() = 0; + virtual void record_concurrent_mark_remark_end() = 0; // Record start, end, and completion of cleanup. - void record_concurrent_mark_cleanup_start(); - void record_concurrent_mark_cleanup_end(); - void record_concurrent_mark_cleanup_completed(); + virtual void record_concurrent_mark_cleanup_start() = 0; + virtual void record_concurrent_mark_cleanup_end() = 0; + virtual void record_concurrent_mark_cleanup_completed() = 0; - virtual void print_phases(); + virtual void print_phases() = 0; // Record how much space we copied during a GC. This is typically // called when a GC alloc region is being retired. - void record_bytes_copied_during_gc(size_t bytes) { - _bytes_copied_during_gc += bytes; - } + virtual void record_bytes_copied_during_gc(size_t bytes) = 0; // The amount of space we copied during a GC. - size_t bytes_copied_during_gc() const { - return _bytes_copied_during_gc; - } - - // Determine whether there are candidate regions so that the - // next GC should be mixed. The two action strings are used - // in the ergo output when the method returns true or false. - bool next_gc_should_be_mixed(const char* true_action_str, - const char* false_action_str) const; - - virtual void finalize_collection_set(double target_pause_time_ms); -private: - // Set the state to start a concurrent marking cycle and clear - // _initiate_conc_mark_if_possible because it has now been - // acted on. - void initiate_conc_mark(); + virtual size_t bytes_copied_during_gc() const = 0; + + virtual void finalize_collection_set(double target_pause_time_ms) = 0; -public: // This sets the initiate_conc_mark_if_possible() flag to start a // new cycle, as long as we are not already in one. It's best if it // is called during a safepoint when the test whether a cycle is in // progress or not is stable. - bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause); + virtual bool force_initial_mark_if_outside_cycle(GCCause::Cause gc_cause) = 0; // This is called at the very beginning of an evacuation pause (it // has to be the first thing that the pause does). If @@ -368,72 +153,33 @@ public: // marking thread has completed its work during the previous cycle, // it will set during_initial_mark_pause() to so that the pause does // the initial-mark work and start a marking cycle. - void decide_on_conc_mark_initiation(); + virtual void decide_on_conc_mark_initiation() = 0; // Print stats on young survival ratio - void print_yg_surv_rate_info() const; - - void finished_recalculating_age_indexes(bool is_survivors) { - if (is_survivors) { - _survivor_surv_rate_group->finished_recalculating_age_indexes(); - } else { - _short_lived_surv_rate_group->finished_recalculating_age_indexes(); - } - } + virtual void print_yg_surv_rate_info() const = 0; - size_t young_list_target_length() const { return _young_list_target_length; } + virtual void finished_recalculating_age_indexes(bool is_survivors) = 0; - bool is_young_list_full() const; + virtual size_t young_list_target_length() const = 0; - bool can_expand_young_list() const; + virtual bool is_young_list_full() const = 0; - uint young_list_max_length() const { - return _young_list_max_length; - } + virtual bool can_expand_young_list() const = 0; - bool adaptive_young_list_length() const; - - virtual bool should_process_references() const { - return true; - } - -private: - // - // Survivor regions policy. - // - - // Current tenuring threshold, set to 0 if the collector reaches the - // maximum amount of survivors regions. - uint _tenuring_threshold; - - // The limit on the number of regions allocated for survivors. - uint _max_survivor_regions; - - AgeTable _survivors_age_table; - -public: - uint tenuring_threshold() const { return _tenuring_threshold; } + virtual uint young_list_max_length() const = 0; - uint max_survivor_regions() { - return _max_survivor_regions; - } + virtual bool adaptive_young_list_length() const = 0; - void note_start_adding_survivor_regions() { - _survivor_surv_rate_group->start_adding_regions(); - } + virtual bool should_process_references() const = 0; - void note_stop_adding_survivor_regions() { - _survivor_surv_rate_group->stop_adding_regions(); - } + virtual uint tenuring_threshold() const = 0; + virtual uint max_survivor_regions() = 0; - void record_age_table(AgeTable* age_table) { - _survivors_age_table.merge(age_table); - } + virtual void note_start_adding_survivor_regions() = 0; - void update_max_gc_locker_expansion(); + virtual void note_stop_adding_survivor_regions() = 0; - // Calculates survivor space parameters. - void update_survivors_policy(); + virtual void record_age_table(AgeTable* age_table) = 0; }; #endif // SHARE_VM_GC_G1_G1POLICY_HPP -- GitLab From 10ed386bc7daa5d524902c1aba7e25ee3c61a143 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Wed, 27 Apr 2016 21:00:45 +0900 Subject: [PATCH 223/400] 8155089: UL: Remove trailing comma from log decoration list Reviewed-by: dsamersoff, mlarsson --- hotspot/src/share/vm/logging/logConfiguration.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/logging/logConfiguration.cpp b/hotspot/src/share/vm/logging/logConfiguration.cpp index 870e7c0eabd..de0cce51d3d 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.cpp +++ b/hotspot/src/share/vm/logging/logConfiguration.cpp @@ -408,10 +408,12 @@ void LogConfiguration::describe_current_configuration(outputStream* out){ out->print_cr("Log output configuration:"); for (size_t i = 0; i < _n_outputs; i++) { out->print("#" SIZE_FORMAT ": %s %s ", i, _outputs[i]->name(), _outputs[i]->config_string()); + char delimiter[2] = {0}; for (size_t d = 0; d < LogDecorators::Count; d++) { LogDecorators::Decorator decorator = static_cast(d); if (_outputs[i]->decorators().is_decorator(decorator)) { - out->print("%s,", LogDecorators::name(decorator)); + out->print("%s%s", delimiter, LogDecorators::name(decorator)); + *delimiter = ','; } } out->cr(); -- GitLab From b2c560bc98bd7afe2ad348aff47296f1a889c57c Mon Sep 17 00:00:00 2001 From: Stefan Johansson Date: Wed, 27 Apr 2016 16:02:02 +0200 Subject: [PATCH 224/400] 8155082: Refactor mutator region restriction Reviewed-by: mgerdin, tschatzl --- hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp | 6 +++--- hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp | 4 ++-- hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp | 2 +- hotspot/src/share/vm/gc/g1/g1Policy.hpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index e122e56b509..68b09e8255b 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -5318,14 +5318,14 @@ HeapRegion* G1CollectedHeap::new_mutator_alloc_region(size_t word_size, assert_heap_locked_or_at_safepoint(true /* should_be_vm_thread */); assert(!force || g1_policy()->can_expand_young_list(), "if force is true we should be able to expand the young list"); - bool young_list_full = g1_policy()->is_young_list_full(); - if (force || !young_list_full) { + bool should_allocate = g1_policy()->should_allocate_mutator_region(); + if (force || should_allocate) { HeapRegion* new_alloc_region = new_region(word_size, false /* is_old */, false /* do_expand */); if (new_alloc_region != NULL) { set_region_short_lived_locked(new_alloc_region); - _hr_printer.alloc(new_alloc_region, young_list_full); + _hr_printer.alloc(new_alloc_region, !should_allocate); _verifier->check_bitmaps("Mutator Region Allocation", new_alloc_region); return new_alloc_region; } diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index e34d023326d..9eda03d5707 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -911,10 +911,10 @@ void G1DefaultPolicy::print_yg_surv_rate_info() const { #endif // PRODUCT } -bool G1DefaultPolicy::is_young_list_full() const { +bool G1DefaultPolicy::should_allocate_mutator_region() const { uint young_list_length = _g1->young_list()->length(); uint young_list_target_length = _young_list_target_length; - return young_list_length >= young_list_target_length; + return young_list_length < young_list_target_length; } bool G1DefaultPolicy::can_expand_young_list() const { diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp index 9c0d22474fb..7c4d253ad9a 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp @@ -384,7 +384,7 @@ public: size_t young_list_target_length() const { return _young_list_target_length; } - bool is_young_list_full() const; + bool should_allocate_mutator_region() const; bool can_expand_young_list() const; diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.hpp b/hotspot/src/share/vm/gc/g1/g1Policy.hpp index 992ed8a6315..f0c6730aced 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp @@ -162,7 +162,7 @@ public: virtual size_t young_list_target_length() const = 0; - virtual bool is_young_list_full() const = 0; + virtual bool should_allocate_mutator_region() const = 0; virtual bool can_expand_young_list() const = 0; -- GitLab From 97a96449f92ef58f5a96612cbc47880c8f27e59b Mon Sep 17 00:00:00 2001 From: Stefan Johansson Date: Wed, 27 Apr 2016 16:02:32 +0200 Subject: [PATCH 225/400] 8155087: Calculation in other_time_ms() is incorrect Reviewed-by: tschatzl, ehelin --- hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index 9eda03d5707..7fb94ce3c7f 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -549,11 +549,7 @@ double G1DefaultPolicy::non_young_other_time_ms() const { } double G1DefaultPolicy::other_time_ms(double pause_time_ms) const { - return pause_time_ms - - average_time_ms(G1GCPhaseTimes::UpdateRS) - - average_time_ms(G1GCPhaseTimes::ScanRS) - - average_time_ms(G1GCPhaseTimes::ObjCopy) - - average_time_ms(G1GCPhaseTimes::Termination); + return pause_time_ms - phase_times()->cur_collection_par_time_ms(); } double G1DefaultPolicy::constant_other_time_ms(double pause_time_ms) const { -- GitLab From 8f81f1a52b239425eb96c78b35f68af6bb99ae23 Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Wed, 27 Apr 2016 16:11:45 +0200 Subject: [PATCH 226/400] 8150393: Maintain the set of survivor regions in an array between GCs Reviewed-by: tschatzl, sjohanss --- .../src/share/vm/gc/g1/g1CollectionSet.cpp | 8 ++- .../src/share/vm/gc/g1/g1ConcurrentMark.cpp | 39 ++++------- .../src/share/vm/gc/g1/g1ConcurrentMark.hpp | 2 +- .../src/share/vm/gc/g1/g1DefaultPolicy.cpp | 11 +-- hotspot/src/share/vm/gc/g1/youngList.cpp | 69 +++++++------------ hotspot/src/share/vm/gc/g1/youngList.hpp | 18 +++-- 6 files changed, 58 insertions(+), 89 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp index b64a820a385..370f39fed38 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp @@ -301,15 +301,17 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms) { uint eden_region_length = young_list->eden_length(); init_region_lengths(eden_region_length, survivor_region_length); - HeapRegion* hr = young_list->first_survivor_region(); - while (hr != NULL) { + const GrowableArray* survivor_regions = _g1->young_list()->survivor_regions(); + for (GrowableArrayIterator it = survivor_regions->begin(); + it != survivor_regions->end(); + ++it) { + HeapRegion* hr = *it; assert(hr->is_survivor(), "badly formed young list"); // There is a convention that all the young regions in the CSet // are tagged as "eden", so we do this for the survivors here. We // use the special set_eden_pre_gc() as it doesn't check that the // region is free (which is not the case here). hr->set_eden_pre_gc(); - hr = hr->get_next_young_region(); } verify_young_cset_indices(); diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp index d52c0ea8b79..11bc8f384bc 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp @@ -57,6 +57,7 @@ #include "runtime/java.hpp" #include "runtime/prefetch.inline.hpp" #include "services/memTracker.hpp" +#include "utilities/growableArray.hpp" // Concurrent marking bit map wrapper @@ -261,7 +262,7 @@ void G1CMMarkStack::note_end_of_gc() { G1CMRootRegions::G1CMRootRegions() : _young_list(NULL), _cm(NULL), _scan_in_progress(false), - _should_abort(false), _next_survivor(NULL) { } + _should_abort(false), _claimed_survivor_index(0) { } void G1CMRootRegions::init(G1CollectedHeap* g1h, G1ConcurrentMark* cm) { _young_list = g1h->young_list(); @@ -272,9 +273,8 @@ void G1CMRootRegions::prepare_for_scan() { assert(!scan_in_progress(), "pre-condition"); // Currently, only survivors can be root regions. - assert(_next_survivor == NULL, "pre-condition"); - _next_survivor = _young_list->first_survivor_region(); - _scan_in_progress = (_next_survivor != NULL); + _claimed_survivor_index = 0; + _scan_in_progress = true; _should_abort = false; } @@ -286,27 +286,13 @@ HeapRegion* G1CMRootRegions::claim_next() { } // Currently, only survivors can be root regions. - HeapRegion* res = _next_survivor; - if (res != NULL) { - MutexLockerEx x(RootRegionScan_lock, Mutex::_no_safepoint_check_flag); - // Read it again in case it changed while we were waiting for the lock. - res = _next_survivor; - if (res != NULL) { - if (res == _young_list->last_survivor_region()) { - // We just claimed the last survivor so store NULL to indicate - // that we're done. - _next_survivor = NULL; - } else { - _next_survivor = res->get_next_young_region(); - } - } else { - // Someone else claimed the last survivor while we were trying - // to take the lock so nothing else to do. - } - } - assert(res == NULL || res->is_survivor(), "post-condition"); + const GrowableArray* survivor_regions = _young_list->survivor_regions(); - return res; + int claimed_index = Atomic::add(1, &_claimed_survivor_index) - 1; + if (claimed_index < survivor_regions->length()) { + return survivor_regions->at(claimed_index); + } + return NULL; } void G1CMRootRegions::notify_scan_done() { @@ -324,9 +310,10 @@ void G1CMRootRegions::scan_finished() { // Currently, only survivors can be root regions. if (!_should_abort) { - assert(_next_survivor == NULL, "we should have claimed all survivors"); + assert(_claimed_survivor_index >= _young_list->survivor_regions()->length(), + "we should have claimed all survivors, claimed index = %d, length = %d", + _claimed_survivor_index, _young_list->survivor_regions()->length()); } - _next_survivor = NULL; notify_scan_done(); } diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp index 3b077d97a8a..d3148185b68 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp @@ -226,7 +226,7 @@ private: volatile bool _scan_in_progress; volatile bool _should_abort; - HeapRegion* volatile _next_survivor; + volatile int _claimed_survivor_index; void notify_scan_done(); diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index 7fb94ce3c7f..e8922f5d9d4 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -41,6 +41,7 @@ #include "runtime/java.hpp" #include "runtime/mutexLocker.hpp" #include "utilities/debug.hpp" +#include "utilities/growableArray.hpp" #include "utilities/pair.hpp" G1DefaultPolicy::G1DefaultPolicy() : @@ -358,10 +359,12 @@ G1DefaultPolicy::calculate_young_list_target_length(size_t rs_lengths, double G1DefaultPolicy::predict_survivor_regions_evac_time() const { double survivor_regions_evac_time = 0.0; - for (HeapRegion * r = _g1->young_list()->first_survivor_region(); - r != NULL && r != _g1->young_list()->last_survivor_region()->get_next_young_region(); - r = r->get_next_young_region()) { - survivor_regions_evac_time += predict_region_elapsed_time_ms(r, collector_state()->gcs_are_young()); + const GrowableArray* survivor_regions = _g1->young_list()->survivor_regions(); + + for (GrowableArrayIterator it = survivor_regions->begin(); + it != survivor_regions->end(); + ++it) { + survivor_regions_evac_time += predict_region_elapsed_time_ms(*it, collector_state()->gcs_are_young()); } return survivor_regions_evac_time; } diff --git a/hotspot/src/share/vm/gc/g1/youngList.cpp b/hotspot/src/share/vm/gc/g1/youngList.cpp index 1c10e0affa9..98dfe6c9e4e 100644 --- a/hotspot/src/share/vm/gc/g1/youngList.cpp +++ b/hotspot/src/share/vm/gc/g1/youngList.cpp @@ -31,11 +31,14 @@ #include "gc/g1/heapRegionRemSet.hpp" #include "gc/g1/youngList.hpp" #include "logging/log.hpp" +#include "utilities/growableArray.hpp" #include "utilities/ostream.hpp" YoungList::YoungList(G1CollectedHeap* g1h) : - _g1h(g1h), _head(NULL), _length(0), - _survivor_head(NULL), _survivor_tail(NULL), _survivor_length(0) { + _g1h(g1h), + _survivor_regions(new (ResourceObj::C_HEAP, mtGC) GrowableArray(8, true, mtGC)), + _head(NULL), + _length(0) { guarantee(check_list_empty(), "just making sure..."); } @@ -54,12 +57,7 @@ void YoungList::add_survivor_region(HeapRegion* hr) { assert(hr->is_survivor(), "should be flagged as survivor region"); assert(hr->get_next_young_region() == NULL, "cause it should!"); - hr->set_next_young_region(_survivor_head); - if (_survivor_head == NULL) { - _survivor_tail = hr; - } - _survivor_head = hr; - ++_survivor_length; + _survivor_regions->append(hr); } void YoungList::empty_list(HeapRegion* list) { @@ -82,14 +80,18 @@ void YoungList::empty_list() { _head = NULL; _length = 0; - empty_list(_survivor_head); - _survivor_head = NULL; - _survivor_tail = NULL; - _survivor_length = 0; + if (survivor_length() > 0) { + empty_list(_survivor_regions->last()); + } + _survivor_regions->clear(); assert(check_list_empty(), "just making sure..."); } +uint YoungList::survivor_length() { + return _survivor_regions->length(); +} + bool YoungList::check_list_well_formed() { bool ret = true; @@ -145,25 +147,25 @@ YoungList::reset_auxilary_lists() { _g1h->g1_policy()->note_start_adding_survivor_regions(); _g1h->g1_policy()->finished_recalculating_age_indexes(true /* is_survivors */); - for (HeapRegion* curr = _survivor_head; - curr != NULL; - curr = curr->get_next_young_region()) { + HeapRegion* last = NULL; + for (GrowableArrayIterator it = _survivor_regions->begin(); + it != _survivor_regions->end(); + ++it) { + HeapRegion* curr = *it; _g1h->g1_policy()->set_region_survivor(curr); // The region is a non-empty survivor so let's add it to // the incremental collection set for the next evacuation // pause. _g1h->collection_set()->add_survivor_regions(curr); + + curr->set_next_young_region(last); + last = curr; } _g1h->g1_policy()->note_stop_adding_survivor_regions(); - _head = _survivor_head; - _length = _survivor_length; - if (_survivor_head != NULL) { - assert(_survivor_tail != NULL, "cause it shouldn't be"); - assert(_survivor_length > 0, "invariant"); - _survivor_tail->set_next_young_region(NULL); - } + _head = last; + _length = _survivor_regions->length(); // Don't clear the survivor list handles until the start of // the next evacuation pause - we need it in order to re-tag @@ -174,26 +176,3 @@ YoungList::reset_auxilary_lists() { assert(check_list_well_formed(), "young list should be well formed"); } - -void YoungList::print() { - HeapRegion* lists[] = {_head, _survivor_head}; - const char* names[] = {"YOUNG", "SURVIVOR"}; - - for (uint list = 0; list < ARRAY_SIZE(lists); ++list) { - tty->print_cr("%s LIST CONTENTS", names[list]); - HeapRegion *curr = lists[list]; - if (curr == NULL) { - tty->print_cr(" empty"); - } - while (curr != NULL) { - tty->print_cr(" " HR_FORMAT ", P: " PTR_FORMAT ", N: " PTR_FORMAT ", age: %4d", - HR_FORMAT_PARAMS(curr), - p2i(curr->prev_top_at_mark_start()), - p2i(curr->next_top_at_mark_start()), - curr->age_in_surv_rate_group_cond()); - curr = curr->get_next_young_region(); - } - } - - tty->cr(); -} diff --git a/hotspot/src/share/vm/gc/g1/youngList.hpp b/hotspot/src/share/vm/gc/g1/youngList.hpp index 1030b3f9c1c..695727436c7 100644 --- a/hotspot/src/share/vm/gc/g1/youngList.hpp +++ b/hotspot/src/share/vm/gc/g1/youngList.hpp @@ -28,17 +28,17 @@ #include "memory/allocation.hpp" #include "runtime/globals.hpp" +template +class GrowableArray; + class YoungList : public CHeapObj { private: G1CollectedHeap* _g1h; + GrowableArray* _survivor_regions; HeapRegion* _head; - HeapRegion* _survivor_head; - HeapRegion* _survivor_tail; - uint _length; - uint _survivor_length; void empty_list(HeapRegion* list); @@ -52,7 +52,9 @@ public: bool is_empty() { return _length == 0; } uint length() { return _length; } uint eden_length() { return length() - survivor_length(); } - uint survivor_length() { return _survivor_length; } + uint survivor_length(); + + const GrowableArray* survivor_regions() const { return _survivor_regions; } // Currently we do not keep track of the used byte sum for the // young list and the survivors and it'd be quite a lot of work to @@ -72,14 +74,10 @@ public: void clear() { _head = NULL; _length = 0; } void clear_survivors() { - _survivor_head = NULL; - _survivor_tail = NULL; - _survivor_length = 0; + _survivor_regions->clear(); } HeapRegion* first_region() { return _head; } - HeapRegion* first_survivor_region() { return _survivor_head; } - HeapRegion* last_survivor_region() { return _survivor_tail; } // debugging bool check_list_well_formed(); -- GitLab From 023aa74fc259973fd21dfe093ae3f9d3106956aa Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Wed, 27 Apr 2016 11:40:43 -0700 Subject: [PATCH 227/400] 8154976: UseSharedSpaces error message is incomplete Reviewed-by: cjplummer, jiangli, mseledtsov --- hotspot/src/share/vm/memory/filemap.cpp | 3 ++- hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/memory/filemap.cpp b/hotspot/src/share/vm/memory/filemap.cpp index ec3b9462959..d690356f582 100644 --- a/hotspot/src/share/vm/memory/filemap.cpp +++ b/hotspot/src/share/vm/memory/filemap.cpp @@ -99,7 +99,8 @@ void FileMapInfo::fail_continue(const char *msg, ...) { fail(msg, ap); } else { if (PrintSharedSpaces) { - tty->print_cr("UseSharedSpaces: %s", msg); + tty->print("UseSharedSpaces: "); + tty->vprint_cr(msg, ap); } } UseSharedSpaces = false; diff --git a/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java b/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java index db3b5f6e173..9694382001a 100644 --- a/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java +++ b/hotspot/test/runtime/CDSCompressedKPtrs/XShareAuto.java @@ -67,6 +67,7 @@ public class XShareAuto { // if sharing failed due to ASLR or similar reasons, // check whether sharing was attempted at all (UseSharedSpaces) output.shouldContain("UseSharedSpaces:"); + output.shouldNotContain("Unable to map %s"); } output.shouldHaveExitValue(0); } -- GitLab From 367a7bd592f1845905655debbba77c677ece27a8 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Thu, 28 Apr 2016 00:36:46 -0700 Subject: [PATCH 228/400] 8153749: New capability can_generate_early_class_hook_events Add new capability Reviewed-by: alanb, dsamersoff --- hotspot/src/share/vm/prims/jvmti.xml | 28 +++++++++++++++++-- hotspot/src/share/vm/prims/jvmtiEnvBase.hpp | 5 ++++ hotspot/src/share/vm/prims/jvmtiExport.cpp | 2 +- .../vm/prims/jvmtiManageCapabilities.cpp | 3 ++ 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/prims/jvmti.xml b/hotspot/src/share/vm/prims/jvmti.xml index f6a18c771ac..aa0e065df42 100644 --- a/hotspot/src/share/vm/prims/jvmti.xml +++ b/hotspot/src/share/vm/prims/jvmti.xml @@ -9994,6 +9994,17 @@ myInit() { See . + + + Can generate the events + in the primordial phase. If this capability and + + can_generate_all_class_hook_events + are enabled then the events + can be posted for classes loaded in the primordial phase. + See . + + @@ -12404,7 +12415,7 @@ myInit() { - This event is sent when the VM obtains class file data, @@ -12420,7 +12431,13 @@ myInit() { bytecode instrumentation for usage information.

        - This event may be sent before the VM is initialized (the start + When the capabilities + + can_generate_early_class_hook_events and + + can_generate_all_class_hook_events + are enabled then this event may be sent in the primordial phase. + Otherwise, this event may be sent before the VM is initialized (the start phase). Some classes might not be compatible with the function (eg. ROMized classes) and this event will not be @@ -12470,6 +12487,7 @@ myInit() { jvmpi + @@ -12542,7 +12560,7 @@ myInit() { - The VM initialization event signals the start of the VM. + The VM start event signals the start of the VM. At this time JNI is live but the VM is not yet fully initialized. Once this event is generated, the agent is free to call any JNI function. This event signals the beginning of the start phase, @@ -14419,6 +14437,10 @@ typedef void (JNICALL *jvmtiEventVMInit) - Add new capability can_generate_early_vmstart - Allow CompiledMethodLoad events at start phase + + Support for modules: + - Add new capability can_generate_early_class_hook_events + diff --git a/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp b/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp index 1c199bd18ba..04e68694459 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp +++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp @@ -162,6 +162,11 @@ class JvmtiEnvBase : public CHeapObj { jvmtiCapabilities *get_prohibited_capabilities() { return &_prohibited_capabilities; } + bool early_class_hook_env() { + return get_capabilities()->can_generate_early_class_hook_events != 0 + && get_capabilities()->can_generate_all_class_hook_events != 0; + } + bool early_vmstart_env() { return get_capabilities()->can_generate_early_vmstart != 0; } diff --git a/hotspot/src/share/vm/prims/jvmtiExport.cpp b/hotspot/src/share/vm/prims/jvmtiExport.cpp index 1be139cbcff..a388f29dc9e 100644 --- a/hotspot/src/share/vm/prims/jvmtiExport.cpp +++ b/hotspot/src/share/vm/prims/jvmtiExport.cpp @@ -667,7 +667,7 @@ class JvmtiClassFileLoadHookPoster : public StackObj { } void post_to_env(JvmtiEnv* env, bool caching_needed) { - if (env->phase() == JVMTI_PHASE_PRIMORDIAL) { + if (env->phase() == JVMTI_PHASE_PRIMORDIAL && !env->early_class_hook_env()) { return; } unsigned char *new_data = NULL; diff --git a/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp b/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp index 1166ed6f004..e0c3cb5c34b 100644 --- a/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp +++ b/hotspot/src/share/vm/prims/jvmtiManageCapabilities.cpp @@ -136,6 +136,7 @@ jvmtiCapabilities JvmtiManageCapabilities::init_onload_capabilities() { jc.can_get_owned_monitor_stack_depth_info = 1; jc.can_get_current_contended_monitor = 1; jc.can_generate_early_vmstart = 1; + jc.can_generate_early_class_hook_events = 1; return jc; } @@ -456,6 +457,8 @@ void JvmtiManageCapabilities:: print(const jvmtiCapabilities* cap) { log_trace(jvmti)("can_generate_resource_exhaustion_threads_events"); if (cap->can_generate_early_vmstart) log_trace(jvmti)("can_generate_early_vmstart"); + if (cap->can_generate_early_class_hook_events) + log_trace(jvmti)("can_generate_early_class_hook_events"); } #endif -- GitLab From c12b6076dc7545263becad2147819d323c009baa Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Thu, 28 Apr 2016 15:52:08 +0200 Subject: [PATCH 229/400] 8155206: Internal VM test DirectiveParser_test is too verbose Reviewed-by: rehn, neliasso --- hotspot/src/share/vm/compiler/directivesParser.cpp | 8 ++++---- hotspot/src/share/vm/compiler/directivesParser.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/compiler/directivesParser.cpp b/hotspot/src/share/vm/compiler/directivesParser.cpp index 60a935be5a2..036357fc7f7 100644 --- a/hotspot/src/share/vm/compiler/directivesParser.cpp +++ b/hotspot/src/share/vm/compiler/directivesParser.cpp @@ -57,7 +57,7 @@ void DirectivesParser::clean_tmp() { } int DirectivesParser::parse_string(const char* text, outputStream* st) { - DirectivesParser cd(text, st); + DirectivesParser cd(text, st, false); if (cd.valid()) { return cd.install_directives(); } else { @@ -132,8 +132,8 @@ int DirectivesParser::install_directives() { } } -DirectivesParser::DirectivesParser(const char* text, outputStream* st) -: JSON(text, false, st), depth(0), current_directive(NULL), current_directiveset(NULL), _tmp_top(NULL), _tmp_depth(0) { +DirectivesParser::DirectivesParser(const char* text, outputStream* st, bool silent) +: JSON(text, silent, st), depth(0), current_directive(NULL), current_directiveset(NULL), _tmp_top(NULL), _tmp_depth(0) { #ifndef PRODUCT memset(stack, 0, MAX_DEPTH * sizeof(stack[0])); #endif @@ -594,7 +594,7 @@ bool DirectivesParser::callback(JSON_TYPE t, JSON_VAL* v, uint rlimit) { #ifndef PRODUCT void DirectivesParser::test(const char* text, bool should_pass) { - DirectivesParser cd(text, tty); + DirectivesParser cd(text, tty, !VerboseInternalVMTests); if (should_pass) { assert(cd.valid() == true, "failed on a valid DirectivesParser string"); if (VerboseInternalVMTests) { diff --git a/hotspot/src/share/vm/compiler/directivesParser.hpp b/hotspot/src/share/vm/compiler/directivesParser.hpp index e7c404b5b3d..ef0b48b20be 100644 --- a/hotspot/src/share/vm/compiler/directivesParser.hpp +++ b/hotspot/src/share/vm/compiler/directivesParser.hpp @@ -55,7 +55,7 @@ public: int install_directives(); private: - DirectivesParser(const char* text, outputStream* st); + DirectivesParser(const char* text, outputStream* st, bool silent); ~DirectivesParser(); bool callback(JSON_TYPE t, JSON_VAL* v, uint level); -- GitLab From 9c04e65bdacd138766daeba56bdb74a1c8cb1a54 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Thu, 28 Apr 2016 17:58:18 +0300 Subject: [PATCH 230/400] 8155034: [TESTBUG] ctw tests fail to compile: module reads package sun.reflect from both jdk.unsupported and java.base Replace sun.reflect with jdk.internal.reflect Reviewed-by: iignatyev, ddmitriev --- .../testlibrary/ctw/src/sun/hotspot/tools/ctw/Compiler.java | 4 ++-- hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java | 2 +- hotspot/test/testlibrary_tests/ctw/ClassesListTest.java | 2 +- hotspot/test/testlibrary_tests/ctw/JarDirTest.java | 2 +- hotspot/test/testlibrary_tests/ctw/JarsTest.java | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/Compiler.java b/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/Compiler.java index f05a02a61b8..96b627a3e4e 100644 --- a/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/Compiler.java +++ b/hotspot/test/testlibrary/ctw/src/sun/hotspot/tools/ctw/Compiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,7 @@ package sun.hotspot.tools.ctw; import sun.hotspot.WhiteBox; import jdk.internal.misc.SharedSecrets; -import sun.reflect.ConstantPool; +import jdk.internal.reflect.ConstantPool; import java.lang.reflect.Executable; diff --git a/hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java b/hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java index f507fb068c5..a11436606b2 100644 --- a/hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java +++ b/hotspot/test/testlibrary_tests/ctw/ClassesDirTest.java @@ -26,7 +26,7 @@ * @bug 8012447 * @library /testlibrary /test/lib /testlibrary/ctw/src * @modules java.base/jdk.internal.misc - * java.base/sun.reflect + * java.base/jdk.internal.reflect * java.management * @build ClassFileInstaller sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar diff --git a/hotspot/test/testlibrary_tests/ctw/ClassesListTest.java b/hotspot/test/testlibrary_tests/ctw/ClassesListTest.java index 5a792a0c413..f9feeaadc2c 100644 --- a/hotspot/test/testlibrary_tests/ctw/ClassesListTest.java +++ b/hotspot/test/testlibrary_tests/ctw/ClassesListTest.java @@ -26,7 +26,7 @@ * @bug 8012447 * @library /testlibrary /test/lib /testlibrary/ctw/src * @modules java.base/jdk.internal.misc - * java.base/sun.reflect + * java.base/jdk.internal.reflect * java.management * @build ClassFileInstaller sun.hotspot.tools.ctw.CompileTheWorld sun.hotspot.WhiteBox Foo Bar * @run main ClassFileInstaller sun.hotspot.WhiteBox Foo Bar diff --git a/hotspot/test/testlibrary_tests/ctw/JarDirTest.java b/hotspot/test/testlibrary_tests/ctw/JarDirTest.java index 1bfdc45db93..7bc97e6966c 100644 --- a/hotspot/test/testlibrary_tests/ctw/JarDirTest.java +++ b/hotspot/test/testlibrary_tests/ctw/JarDirTest.java @@ -26,7 +26,7 @@ * @bug 8012447 * @library /testlibrary /test/lib /testlibrary/ctw/src * @modules java.base/jdk.internal.misc - * java.base/sun.reflect + * java.base/jdk.internal.reflect * java.compiler * java.management * jdk.jvmstat/sun.jvmstat.monitor diff --git a/hotspot/test/testlibrary_tests/ctw/JarsTest.java b/hotspot/test/testlibrary_tests/ctw/JarsTest.java index 1050e512583..e35791201b8 100644 --- a/hotspot/test/testlibrary_tests/ctw/JarsTest.java +++ b/hotspot/test/testlibrary_tests/ctw/JarsTest.java @@ -26,7 +26,7 @@ * @bug 8012447 * @library /testlibrary /test/lib /testlibrary/ctw/src * @modules java.base/jdk.internal.misc - * java.base/sun.reflect + * java.base/jdk.internal.reflect * java.compiler * java.management * jdk.jvmstat/sun.jvmstat.monitor -- GitLab From d423c99efc29f678d79c7a8154a9f9202224f2de Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Thu, 28 Apr 2016 16:55:04 +0300 Subject: [PATCH 231/400] 8155527: New test TestHumongousClassLoader fails with "-XX:+ExplicitGCInvokesConcurrent" option Reviewed-by: dfazunen, drwhite, jwilhelm --- .../test/gc/g1/humongousObjects/TestHumongousClassLoader.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java index 4e8efd6e1d9..b4bb37cacba 100644 --- a/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java +++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java @@ -40,6 +40,7 @@ import java.nio.file.Paths; * @summary Checks that unreachable classes and unreachable humongous class loader are unloaded after GC * @requires vm.gc=="G1" | vm.gc=="null" * @requires vm.opt.G1HeapRegionSize == "null" | vm.opt.G1HeapRegionSize == "1M" + * @requires vm.opt.ExplicitGCInvokesConcurrent != true * @library /testlibrary /test/lib / * @modules java.management * @build sun.hotspot.WhiteBox -- GitLab From 41a3e98a61292a2a382a44e81ab9d19c62c388f9 Mon Sep 17 00:00:00 2001 From: Gerard Ziemski Date: Thu, 28 Apr 2016 10:41:53 -0500 Subject: [PATCH 232/400] 8153835: Fix range of flag MaxDirectMemorySize which is parsed at jlong Changed MaxDirectMemorySize type to uint64_t and set max to max_jlong Reviewed-by: goetz, simonis --- hotspot/src/share/vm/prims/jvm.cpp | 2 +- hotspot/src/share/vm/runtime/globals.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index 5166478e5e7..2357ad7e80c 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -389,7 +389,7 @@ JVM_ENTRY(jobject, JVM_InitProperties(JNIEnv *env, jobject properties)) PUTPROP(props, "sun.nio.MaxDirectMemorySize", "-1"); } else { char as_chars[256]; - jio_snprintf(as_chars, sizeof(as_chars), SIZE_FORMAT, MaxDirectMemorySize); + jio_snprintf(as_chars, sizeof(as_chars), JULONG_FORMAT, MaxDirectMemorySize); PUTPROP(props, "sun.nio.MaxDirectMemorySize", as_chars); } } diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index bfc05242309..a3367fe1324 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -3847,9 +3847,9 @@ public: \ /* Properties for Java libraries */ \ \ - product(size_t, MaxDirectMemorySize, 0, \ + product(uint64_t, MaxDirectMemorySize, 0, \ "Maximum total size of NIO direct-buffer allocations") \ - range(0, (size_t)SIZE_MAX) \ + range(0, max_jlong) \ \ /* Flags used for temporary code during development */ \ \ -- GitLab From d30adc68f206adbc7ab3c90e602eba05c8483e6b Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Thu, 28 Apr 2016 13:44:36 -0400 Subject: [PATCH 233/400] 8151342: Add module name/version to class histogram output Add additional column to histogram containing module@version Reviewed-by: sundar, gtriantafill --- .../src/share/vm/memory/heapInspection.cpp | 23 +++++++++++---- .../dcmd/gc/ClassHistogramTest.java | 29 ++++++++++--------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/hotspot/src/share/vm/memory/heapInspection.cpp b/hotspot/src/share/vm/memory/heapInspection.cpp index 2f8f40d3d71..0f176899243 100644 --- a/hotspot/src/share/vm/memory/heapInspection.cpp +++ b/hotspot/src/share/vm/memory/heapInspection.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/classLoaderData.hpp" +#include "classfile/moduleEntry.hpp" #include "classfile/systemDictionary.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/genCollectedHeap.hpp" @@ -105,10 +106,20 @@ void KlassInfoEntry::print_on(outputStream* st) const { ResourceMark rm; // simplify the formatting (ILP32 vs LP64) - always cast the numbers to 64-bit - st->print_cr(INT64_FORMAT_W(13) " " UINT64_FORMAT_W(13) " %s", - (int64_t)_instance_count, - (uint64_t)_instance_words * HeapWordSize, - name()); + ModuleEntry* module = _klass->module(); + if (module->is_named()) { + st->print_cr(INT64_FORMAT_W(13) " " UINT64_FORMAT_W(13) " %s (%s@%s)", + (int64_t)_instance_count, + (uint64_t)_instance_words * HeapWordSize, + name(), + module->name()->as_C_string(), + module->version() != NULL ? module->version()->as_C_string() : ""); + } else { + st->print_cr(INT64_FORMAT_W(13) " " UINT64_FORMAT_W(13) " %s", + (int64_t)_instance_count, + (uint64_t)_instance_words * HeapWordSize, + name()); + } } KlassInfoEntry* KlassInfoBucket::lookup(Klass* const k) { @@ -647,8 +658,8 @@ void KlassInfoHisto::print_histo_on(outputStream* st, bool print_stats, if (print_stats) { print_class_stats(st, csv_format, columns); } else { - st->print_cr(" num #instances #bytes class name"); - st->print_cr("----------------------------------------------"); + st->print_cr(" num #instances #bytes class name (module)"); + st->print_cr("-------------------------------------------------------"); print_elements(st); } } diff --git a/hotspot/test/serviceability/dcmd/gc/ClassHistogramTest.java b/hotspot/test/serviceability/dcmd/gc/ClassHistogramTest.java index 6434bb0f918..996074a5a67 100644 --- a/hotspot/test/serviceability/dcmd/gc/ClassHistogramTest.java +++ b/hotspot/test/serviceability/dcmd/gc/ClassHistogramTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,33 +57,34 @@ public class ClassHistogramTest { /* * example output: - * num #instances #bytes class name - * ---------------------------------------------- - * 1: 1647 1133752 [B - * 2: 6198 383168 [C - * 3: 1464 165744 java.lang.Class - * 4: 6151 147624 java.lang.String - * 5: 2304 73728 java.util.concurrent.ConcurrentHashMap$Node - * 6: 1199 64280 [Ljava.lang.Object; + * num #instances #bytes class name (module) + * ------------------------------------------------------- + * 1: 7991 757792 [B (java.base@9-internal) + * 2: 1811 217872 java.lang.Class (java.base@9-internal) + * 3: 6724 215168 java.util.HashMap$Node (java.base@9-internal) + * 4: 7852 188448 java.lang.String (java.base@9-internal) + * 5: 1378 105040 [Ljava.util.HashMap$Node; (java.base@9-internal) + * 6: 1863 95096 [Ljava.lang.Object; (java.base@9-internal) + * ... */ /* Require at least one java.lang.Class */ - output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Class\\s*$"); + output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Class \\(java.base@\\S*\\)\\s*$"); /* Require at least one java.lang.String */ - output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.String\\s*$"); + output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.String \\(java.base@\\S*\\)\\s*$"); /* Require at least one java.lang.Object */ - output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Object\\s*$"); + output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Object \\(java.base@\\S*\\)\\s*$"); /* Require at exactly one TestClass[] */ output.shouldMatch("^\\s+\\d+:\\s+1\\s+\\d+\\s+" + - Pattern.quote(TestClass[].class.getName()) + "\\s*$"); + Pattern.quote(TestClass[].class.getName()) + "\\s*$"); /* Require at exactly 1024 TestClass */ output.shouldMatch("^\\s+\\d+:\\s+1024\\s+\\d+\\s+" + - Pattern.quote(TestClass.class.getName()) + "\\s*$"); + Pattern.quote(TestClass.class.getName()) + "\\s*$"); } @Test -- GitLab From 0c5f058520b6263c0b3a75bd5ef65d66221c6889 Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Thu, 28 Apr 2016 12:25:16 -0700 Subject: [PATCH 234/400] 8153190: JVMTI GetAllModules should make it clear that it also returns unnamed module Clarify the JVMTI spec Reviewed-by: alanb --- hotspot/src/share/vm/prims/jvmti.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/src/share/vm/prims/jvmti.xml b/hotspot/src/share/vm/prims/jvmti.xml index f6a18c771ac..067a8aceb97 100644 --- a/hotspot/src/share/vm/prims/jvmti.xml +++ b/hotspot/src/share/vm/prims/jvmti.xml @@ -6482,6 +6482,7 @@ class C2 extends C1 implements I2 { Get All Modules Return an array of all modules loaded in the virtual machine. + The array includes the unnamed module for each class loader. The number of modules in the array is returned via module_count_ptr, and the array itself via modules_ptr. -- GitLab From 4956880699c1947cab78e7b3db1f705e731815d3 Mon Sep 17 00:00:00 2001 From: Stefan Johansson Date: Fri, 29 Apr 2016 08:39:22 +0200 Subject: [PATCH 235/400] 8155245: Add logging when MMU target is violated Reviewed-by: ehelin, mgerdin --- hotspot/src/share/vm/gc/g1/g1MMUTracker.cpp | 5 +++++ hotspot/src/share/vm/logging/logPrefix.hpp | 1 + hotspot/src/share/vm/logging/logTag.hpp | 1 + 3 files changed, 7 insertions(+) diff --git a/hotspot/src/share/vm/gc/g1/g1MMUTracker.cpp b/hotspot/src/share/vm/gc/g1/g1MMUTracker.cpp index e8c7a4e9f9b..fdb99afe7b7 100644 --- a/hotspot/src/share/vm/gc/g1/g1MMUTracker.cpp +++ b/hotspot/src/share/vm/gc/g1/g1MMUTracker.cpp @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "gc/g1/g1MMUTracker.hpp" #include "gc/shared/gcTrace.hpp" +#include "logging/log.hpp" #include "runtime/mutexLocker.hpp" #include "utilities/ostream.hpp" @@ -107,6 +108,10 @@ void G1MMUTrackerQueue::add_pause(double start, double end) { // Current entry needs to be added before calculating the value double slice_time = calculate_gc_time(end); G1MMUTracer::report_mmu(_time_slice, slice_time, _max_gc_time); + + if (slice_time >= _max_gc_time) { + log_info(gc, mmu)("MMU target violated: %.1lfms (%.1lfms/%.1lfms)", slice_time * 1000.0, _max_gc_time * 1000.0, _time_slice * 1000); + } } // basically the _internal call does not remove expired entries diff --git a/hotspot/src/share/vm/logging/logPrefix.hpp b/hotspot/src/share/vm/logging/logPrefix.hpp index 8d2ae12adf3..7e4da0f058e 100644 --- a/hotspot/src/share/vm/logging/logPrefix.hpp +++ b/hotspot/src/share/vm/logging/logPrefix.hpp @@ -64,6 +64,7 @@ DEBUG_ONLY(size_t Test_log_prefix_prefixer(char* buf, size_t len);) LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, liveness)) \ LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, marking)) \ LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, metaspace)) \ + LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, mmu)) \ LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, phases)) \ LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, phases, start)) \ LOG_PREFIX(GCId::print_prefix, LOG_TAGS(gc, phases, task)) \ diff --git a/hotspot/src/share/vm/logging/logTag.hpp b/hotspot/src/share/vm/logging/logTag.hpp index d9759dca859..1f0a1c31e2c 100644 --- a/hotspot/src/share/vm/logging/logTag.hpp +++ b/hotspot/src/share/vm/logging/logTag.hpp @@ -67,6 +67,7 @@ LOG_TAG(logging) \ LOG_TAG(marking) \ LOG_TAG(metaspace) \ + LOG_TAG(mmu) \ LOG_TAG(modules) \ LOG_TAG(monitorinflation) \ LOG_TAG(monitormismatch) \ -- GitLab From dec22baf4d9e7dbcb53552e000da8284c4f92d0c Mon Sep 17 00:00:00 2001 From: Eric Caspole Date: Fri, 29 Apr 2016 10:04:24 -0400 Subject: [PATCH 236/400] 8155685: Wrong indentation in ClassFileParser::post_process_parsed_stream Fix indentation Reviewed-by: dcubed --- hotspot/src/share/vm/classfile/classFileParser.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 31f296c3ccd..cebe2d2dd09 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -5800,8 +5800,8 @@ void ClassFileParser::post_process_parsed_stream(const ClassFileStream* const st guarantee_property(super_class_name == vmSymbols::java_lang_Object(), "Interfaces must have java.lang.Object as superclass in class file %s", CHECK); - } - _super_klass = (const InstanceKlass*) + } + _super_klass = (const InstanceKlass*) SystemDictionary::resolve_super_or_fail(_class_name, super_class_name, _loader_data->class_loader(), -- GitLab From da0fe9d476427f391f937e7ad7dcb117f952a63d Mon Sep 17 00:00:00 2001 From: Max Ockner Date: Fri, 29 Apr 2016 22:40:51 -0400 Subject: [PATCH 237/400] 8154110: Update class* and safepoint* logging subsystems Refactored logging tags in class and safepoint subsystems. Reviewed-by: coleenp, rehn, hseigel --- .../share/vm/classfile/classFileParser.cpp | 16 +++---- .../src/share/vm/classfile/classLoader.cpp | 12 ++--- .../share/vm/classfile/classLoaderData.cpp | 18 +++---- .../src/share/vm/classfile/javaClasses.cpp | 4 +- .../share/vm/classfile/loaderConstraints.cpp | 44 ++++++++--------- hotspot/src/share/vm/classfile/modules.cpp | 4 +- .../vm/classfile/sharedPathsMiscInfo.cpp | 6 +-- .../share/vm/classfile/systemDictionary.cpp | 4 +- .../share/vm/classfile/verificationType.cpp | 4 +- hotspot/src/share/vm/classfile/verifier.cpp | 18 +++---- hotspot/src/share/vm/classfile/verifier.hpp | 2 +- hotspot/src/share/vm/code/nmethod.cpp | 4 +- hotspot/src/share/vm/logging/logTag.hpp | 16 ++++--- hotspot/src/share/vm/memory/filemap.cpp | 12 ++--- .../src/share/vm/memory/metaspaceShared.cpp | 2 +- hotspot/src/share/vm/oops/constantPool.cpp | 14 +++--- hotspot/src/share/vm/oops/instanceKlass.cpp | 12 ++--- hotspot/src/share/vm/oops/klass.cpp | 8 ++-- hotspot/src/share/vm/prims/jni.cpp | 6 +-- hotspot/src/share/vm/prims/jvm.cpp | 14 +++--- hotspot/src/share/vm/prims/jvmtiEnv.cpp | 10 ++-- hotspot/src/share/vm/prims/whitebox.cpp | 2 +- hotspot/src/share/vm/runtime/arguments.cpp | 26 +++++----- hotspot/src/share/vm/runtime/reflection.cpp | 8 ++-- hotspot/src/share/vm/runtime/safepoint.cpp | 14 +++--- .../share/vm/services/classLoadingService.cpp | 12 ++--- .../share/vm/services/classLoadingService.hpp | 2 +- .../jsr292/CallSiteDepContextTest.java | 2 +- .../TestHumongousClassLoader.java | 6 +-- .../SharedArchiveFile/BootAppendTests.java | 14 +++--- .../logging/ClassInitializationTest.java | 10 ++-- .../runtime/logging/ClassLoadUnloadTest.java | 48 +++++++++---------- .../runtime/logging/ClassResolutionTest.java | 22 ++++----- .../logging/LoaderConstraintsTest.java | 16 +++---- .../logging/RemovedDevelopFlagsTest.java | 4 +- .../runtime/logging/SafepointCleanupTest.java | 10 ++-- .../runtime/modules/Xpatch/XpatchTraceCL.java | 8 ++-- .../test/runtime/verifier/TraceClassRes.java | 2 +- 38 files changed, 219 insertions(+), 217 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index cebe2d2dd09..1f248acdbd4 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -5349,7 +5349,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loa ClassLoadingService::notify_class_loaded(ik, false /* not shared class */); if (!is_internal()) { - if (log_is_enabled(Info, classload)) { + if (log_is_enabled(Info, class, load)) { ResourceMark rm; const char* module_name = NULL; static const size_t modules_image_name_len = strlen(MODULES_IMAGE_NAME); @@ -5361,21 +5361,21 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loa module_name = module_entry->name()->as_C_string(); } - if (log_is_enabled(Info, classload)) { + if (log_is_enabled(Info, class, load)) { ik->print_loading_log(LogLevel::Info, _loader_data, module_name, _stream); } // No 'else' here as logging levels are not mutually exclusive - if (log_is_enabled(Debug, classload)) { + if (log_is_enabled(Debug, class, load)) { ik->print_loading_log(LogLevel::Debug, _loader_data, module_name, _stream); } } - if (log_is_enabled(Debug, classresolve)) { + if (log_is_enabled(Debug, class, resolve)) { ResourceMark rm; // print out the superclass. const char * from = ik->external_name(); if (ik->java_super() != NULL) { - log_debug(classresolve)("%s %s (super)", + log_debug(class, resolve)("%s %s (super)", from, ik->java_super()->external_name()); } @@ -5386,7 +5386,7 @@ void ClassFileParser::fill_instance_klass(InstanceKlass* ik, bool changed_by_loa for (int i = 0; i < length; i++) { const Klass* const k = local_interfaces->at(i); const char * to = k->external_name(); - log_debug(classresolve)("%s %s (interface)", from, to); + log_debug(class, resolve)("%s %s (interface)", from, to); } } } @@ -5696,9 +5696,9 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, } if (!is_internal()) { - if (log_is_enabled(Debug, classload, preorder)){ + if (log_is_enabled(Debug, class, preorder)){ ResourceMark rm(THREAD); - outputStream* log = Log(classload, preorder)::debug_stream(); + outputStream* log = Log(class, preorder)::debug_stream(); log->print("%s", _class_name->as_klass_external_name()); if (stream->source() != NULL) { log->print(" source: %s", stream->source()); diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 6f9b4ec8b5a..a33e2040530 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -537,15 +537,15 @@ bool ClassPathImageEntry::is_jrt() { #if INCLUDE_CDS void ClassLoader::exit_with_path_failure(const char* error, const char* message) { assert(DumpSharedSpaces, "only called at dump time"); - tty->print_cr("Hint: enable -Xlog:classpath=info to diagnose the failure"); + tty->print_cr("Hint: enable -Xlog:class+path=info to diagnose the failure"); vm_exit_during_initialization(error, message); } #endif void ClassLoader::trace_class_path(const char* msg, const char* name) { - if (log_is_enabled(Info, classpath)) { + if (log_is_enabled(Info, class, path)) { ResourceMark rm; - outputStream* out = Log(classpath)::info_stream(); + outputStream* out = Log(class, path)::info_stream(); if (msg) { out->print("%s", msg); } @@ -711,12 +711,12 @@ ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const str } } } - log_info(classpath)("opened: %s", path); - log_info(classload)("opened: %s", path); + log_info(class, path)("opened: %s", path); + log_info(class, load)("opened: %s", path); } else { // Directory new_entry = new ClassPathDirEntry(path); - log_info(classload)("path: %s", path); + log_info(class, load)("path: %s", path); } return new_entry; } diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index 5db59458529..3ca97efb7a0 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -333,7 +333,7 @@ void ClassLoaderData::add_class(Klass* k, bool publicize /* true */) { if (publicize && k->class_loader_data() != NULL) { ResourceMark rm; - log_trace(classloaderdata)("Adding k: " PTR_FORMAT " %s to CLD: " + log_trace(class, loader, data)("Adding k: " PTR_FORMAT " %s to CLD: " PTR_FORMAT " loader: " PTR_FORMAT " %s", p2i(k), k->external_name(), @@ -371,9 +371,9 @@ void ClassLoaderData::unload() { // Tell serviceability tools these classes are unloading classes_do(InstanceKlass::notify_unload_class); - if (log_is_enabled(Debug, classloaderdata)) { + if (log_is_enabled(Debug, class, loader, data)) { ResourceMark rm; - outputStream* log = Log(classloaderdata)::debug_stream(); + outputStream* log = Log(class, loader, data)::debug_stream(); log->print(": unload loader data " INTPTR_FORMAT, p2i(this)); log->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)class_loader()), loader_name()); @@ -506,12 +506,12 @@ Metaspace* ClassLoaderData::metaspace_non_null() { set_metaspace(new Metaspace(_metaspace_lock, Metaspace::BootMetaspaceType)); } else if (is_anonymous()) { if (class_loader() != NULL) { - log_trace(classloaderdata)("is_anonymous: %s", class_loader()->klass()->internal_name()); + log_trace(class, loader, data)("is_anonymous: %s", class_loader()->klass()->internal_name()); } set_metaspace(new Metaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType)); } else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) { if (class_loader() != NULL) { - log_trace(classloaderdata)("is_reflection: %s", class_loader()->klass()->internal_name()); + log_trace(class, loader, data)("is_reflection: %s", class_loader()->klass()->internal_name()); } set_metaspace(new Metaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType)); } else { @@ -702,7 +702,7 @@ ClassLoaderData* ClassLoaderDataGraph::add(Handle loader, bool is_anonymous, TRA cld->set_next(next); ClassLoaderData* exchanged = (ClassLoaderData*)Atomic::cmpxchg_ptr(cld, list_head, next); if (exchanged == next) { - if (log_is_enabled(Debug, classloaderdata)) { + if (log_is_enabled(Debug, class, loader, data)) { PauseNoSafepointVerifier pnsv(&no_safepoints); // Need safe points for JavaCalls::call_virtual log_creation(loader, cld, CHECK_NULL); } @@ -730,7 +730,7 @@ void ClassLoaderDataGraph::log_creation(Handle loader, ClassLoaderData* cld, TRA } ResourceMark rm; - outputStream* log = Log(classloaderdata)::debug_stream(); + outputStream* log = Log(class, loader, data)::debug_stream(); log->print("create class loader data " INTPTR_FORMAT, p2i(cld)); log->print(" for instance " INTPTR_FORMAT " of %s", p2i((void *)cld->class_loader()), cld->loader_name()); @@ -871,8 +871,8 @@ GrowableArray* ClassLoaderDataGraph::new_clds() { if (!curr->claimed()) { array->push(curr); - if (log_is_enabled(Debug, classloaderdata)) { - outputStream* log = Log(classloaderdata)::debug_stream(); + if (log_is_enabled(Debug, class, loader, data)) { + outputStream* log = Log(class, loader, data)::debug_stream(); log->print("found new CLD: "); curr->print_value_on(log); log->cr(); diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index b74993524c5..70b9d4d1525 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -131,7 +131,7 @@ compute_offset(int &dest_offset, tty->print_cr(" name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_int()); } #endif //PRODUCT - vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:classload=info to see the origin of the problem class"); + vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:class+load=info to see the origin of the problem class"); } dest_offset = fd.offset(); } @@ -4059,7 +4059,7 @@ int InjectedField::compute_offset() { tty->print_cr(" name: %s, sig: %s, flags: %08x", fs.name()->as_C_string(), fs.signature()->as_C_string(), fs.access_flags().as_int()); } #endif //PRODUCT - vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:classload=info to see the origin of the problem class"); + vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:class+load=info to see the origin of the problem class"); return -1; } diff --git a/hotspot/src/share/vm/classfile/loaderConstraints.cpp b/hotspot/src/share/vm/classfile/loaderConstraints.cpp index 3e5b033acb4..5dfe4e33ae4 100644 --- a/hotspot/src/share/vm/classfile/loaderConstraints.cpp +++ b/hotspot/src/share/vm/classfile/loaderConstraints.cpp @@ -111,9 +111,9 @@ void LoaderConstraintTable::purge_loader_constraints() { if (klass != NULL && klass->class_loader_data()->is_unloading()) { probe->set_klass(NULL); - if (log_is_enabled(Info, constraints)) { + if (log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; - outputStream* out = Log(classload, constraints)::info_stream(); + outputStream* out = Log(class, loader, constraints)::info_stream(); out->print_cr("purging class object from constraint for name %s," " loader list:", probe->name()->as_C_string()); @@ -127,9 +127,9 @@ void LoaderConstraintTable::purge_loader_constraints() { int n = 0; while (n < probe->num_loaders()) { if (probe->loader_data(n)->is_unloading()) { - if (log_is_enabled(Info, classload, constraints)) { + if (log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; - outputStream* out = Log(classload, constraints)::info_stream(); + outputStream* out = Log(class, loader, constraints)::info_stream(); out->print_cr("purging loader %s from constraint for name %s", probe->loader_data(n)->loader_name(), probe->name()->as_C_string() @@ -142,9 +142,9 @@ void LoaderConstraintTable::purge_loader_constraints() { probe->set_loader_data(n, probe->loader_data(num)); probe->set_loader_data(num, NULL); - if (log_is_enabled(Info, classload, constraints)) { + if (log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; - outputStream* out = Log(classload, constraints)::info_stream(); + outputStream* out = Log(class, loader, constraints)::info_stream(); out->print_cr("new loader list:"); for (int i = 0; i < probe->num_loaders(); i++) { out->print_cr(" [%d]: %s", i, @@ -159,9 +159,9 @@ void LoaderConstraintTable::purge_loader_constraints() { } // Check whether entry should be purged if (probe->num_loaders() < 2) { - if (log_is_enabled(Info, classload, constraints)) { + if (log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; - outputStream* out = Log(classload, constraints)::info_stream(); + outputStream* out = Log(class, loader, constraints)::info_stream(); out->print_cr("purging complete constraint for name %s", probe->name()->as_C_string()); } @@ -231,9 +231,9 @@ bool LoaderConstraintTable::add_entry(Symbol* class_name, p->set_klass(klass); p->set_next(bucket(index)); set_entry(index, p); - if (log_is_enabled(Info, classload, constraints)) { + if (log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; - outputStream* out = Log(classload, constraints)::info_stream(); + outputStream* out = Log(class, loader, constraints)::info_stream(); out->print_cr("adding new constraint for name: %s, loader[0]: %s," " loader[1]: %s", class_name->as_C_string(), @@ -245,9 +245,9 @@ bool LoaderConstraintTable::add_entry(Symbol* class_name, /* constraint already imposed */ if ((*pp1)->klass() == NULL) { (*pp1)->set_klass(klass); - if (log_is_enabled(Info, classload, constraints)) { + if (log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; - outputStream* out = Log(classload, constraints)::info_stream(); + outputStream* out = Log(class, loader, constraints)::info_stream(); out->print_cr("setting class object in existing constraint for" " name: %s and loader %s", class_name->as_C_string(), @@ -267,9 +267,9 @@ bool LoaderConstraintTable::add_entry(Symbol* class_name, } } - if (failure_code != 0 && log_is_enabled(Info, classload, constraints)) { + if (failure_code != 0 && log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; - outputStream* out = Log(classload, constraints)::info_stream(); + outputStream* out = Log(class, loader, constraints)::info_stream(); const char* reason = ""; switch(failure_code) { case 1: reason = "the class objects presented by loader[0] and loader[1]" @@ -300,9 +300,9 @@ bool LoaderConstraintTable::check_or_update(instanceKlassHandle k, Symbol* name) { LoaderConstraintEntry* p = *(find_loader_constraint(name, loader)); if (p && p->klass() != NULL && p->klass() != k()) { - if (log_is_enabled(Info, classload, constraints)) { + if (log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; - outputStream* out = Log(classload, constraints)::info_stream(); + outputStream* out = Log(class, loader, constraints)::info_stream(); out->print_cr("constraint check failed for name %s, loader %s: " "the presented class object differs from that stored", name->as_C_string(), @@ -312,9 +312,9 @@ bool LoaderConstraintTable::check_or_update(instanceKlassHandle k, } else { if (p && p->klass() == NULL) { p->set_klass(k()); - if (log_is_enabled(Info, classload, constraints)) { + if (log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; - outputStream* out = Log(classload, constraints)::info_stream(); + outputStream* out = Log(class, loader, constraints)::info_stream(); out->print_cr("updating constraint for name %s, loader %s, " "by setting class object", name->as_C_string(), @@ -362,9 +362,9 @@ void LoaderConstraintTable::extend_loader_constraint(LoaderConstraintEntry* p, int num = p->num_loaders(); p->set_loader(num, loader()); p->set_num_loaders(num + 1); - if (log_is_enabled(Info, classload, constraints)) { + if (log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; - outputStream* out = Log(classload, constraints)::info_stream(); + outputStream* out = Log(class, loader, constraints)::info_stream(); out->print_cr("extending constraint for name %s by adding loader[%d]: %s %s", p->name()->as_C_string(), num, @@ -402,9 +402,9 @@ void LoaderConstraintTable::merge_loader_constraints( p1->set_num_loaders(num + 1); } - if (log_is_enabled(Info, classload, constraints)) { + if (log_is_enabled(Info, class, loader, constraints)) { ResourceMark rm; - outputStream* out = Log(classload, constraints)::info_stream(); + outputStream* out = Log(class, loader, constraints)::info_stream(); out->print_cr("merged constraints for name %s, new loader list:", p1->name()->as_C_string() ); diff --git a/hotspot/src/share/vm/classfile/modules.cpp b/hotspot/src/share/vm/classfile/modules.cpp index d1f272805cb..fcd3abe07b0 100644 --- a/hotspot/src/share/vm/classfile/modules.cpp +++ b/hotspot/src/share/vm/classfile/modules.cpp @@ -167,7 +167,7 @@ static void add_to_boot_loader_list(char *module_name, TRAPS) { ObjectLocker ol(loader_lock, THREAD); ClassLoader::prepend_to_list(prefix_path); } - log_info(classload)("opened: -Xpatch %s", prefix_path); + log_info(class, load)("opened: -Xpatch %s", prefix_path); } } } @@ -195,7 +195,7 @@ static void add_to_boot_loader_list(char *module_name, TRAPS) { Handle loader_lock = Handle(THREAD, SystemDictionary::system_loader_lock()); ObjectLocker ol(loader_lock, THREAD); - log_info(classload)("opened: %s", path); + log_info(class, load)("opened: %s", path); ClassLoader::add_to_list(path); } } diff --git a/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp b/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp index 302bb45284f..36cf234c2d1 100644 --- a/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp +++ b/hotspot/src/share/vm/classfile/sharedPathsMiscInfo.cpp @@ -34,7 +34,7 @@ #include "utilities/ostream.hpp" void SharedPathsMiscInfo::add_path(const char* path, int type) { - log_info(classpath)("type=%s ", type_name(type)); + log_info(class, path)("type=%s ", type_name(type)); ClassLoader::trace_class_path("add misc shared path ", path); write(path, strlen(path) + 1); write_jint(jint(type)); @@ -75,7 +75,7 @@ bool SharedPathsMiscInfo::fail(const char* msg, const char* name) { void SharedPathsMiscInfo::print_path(int type, const char* path) { ResourceMark rm; - outputStream* out = Log(classpath)::info_stream(); + outputStream* out = Log(class, path)::info_stream(); switch (type) { case BOOT: out->print("Expecting BOOT path=%s", path); @@ -109,7 +109,7 @@ bool SharedPathsMiscInfo::check() { if (!read_jint(&type)) { return fail("Corrupted archive file header"); } - log_info(classpath)("type=%s ", type_name(type)); + log_info(class, path)("type=%s ", type_name(type)); print_path(type, path); if (!check(type, path)) { if (!PrintSharedArchiveAndExit) { diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index 34c43946e52..ede6d4f1df9 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -1388,12 +1388,12 @@ instanceKlassHandle SystemDictionary::load_shared_class(instanceKlassHandle ik, ik->restore_unshareable_info(loader_data, protection_domain, CHECK_(nh)); } - if (log_is_enabled(Info, classload)) { + if (log_is_enabled(Info, class, load)) { ik()->print_loading_log(LogLevel::Info, loader_data, NULL, NULL); } // No 'else' here as logging levels are not mutually exclusive - if (log_is_enabled(Debug, classload)) { + if (log_is_enabled(Debug, class, load)) { ik()->print_loading_log(LogLevel::Debug, loader_data, NULL, NULL); } diff --git a/hotspot/src/share/vm/classfile/verificationType.cpp b/hotspot/src/share/vm/classfile/verificationType.cpp index 6245fcee68f..be4594f6ac5 100644 --- a/hotspot/src/share/vm/classfile/verificationType.cpp +++ b/hotspot/src/share/vm/classfile/verificationType.cpp @@ -61,7 +61,7 @@ bool VerificationType::is_reference_assignable_from( Klass* obj = SystemDictionary::resolve_or_fail( name(), Handle(THREAD, klass->class_loader()), Handle(THREAD, klass->protection_domain()), true, CHECK_false); - if (log_is_enabled(Debug, classresolve)) { + if (log_is_enabled(Debug, class, resolve)) { Verifier::trace_class_resolution(obj, klass()); } @@ -80,7 +80,7 @@ bool VerificationType::is_reference_assignable_from( Klass* from_class = SystemDictionary::resolve_or_fail( from.name(), Handle(THREAD, klass->class_loader()), Handle(THREAD, klass->protection_domain()), true, CHECK_false); - if (log_is_enabled(Debug, classresolve)) { + if (log_is_enabled(Debug, class, resolve)) { Verifier::trace_class_resolution(from_class, klass()); } return InstanceKlass::cast(from_class)->is_subclass_of(this_class()); diff --git a/hotspot/src/share/vm/classfile/verifier.cpp b/hotspot/src/share/vm/classfile/verifier.cpp index 600ca8e911f..58200d11e03 100644 --- a/hotspot/src/share/vm/classfile/verifier.cpp +++ b/hotspot/src/share/vm/classfile/verifier.cpp @@ -107,9 +107,9 @@ void Verifier::trace_class_resolution(Klass* resolve_class, InstanceKlass* verif const char* resolve = resolve_class->external_name(); // print in a single call to reduce interleaving between threads if (source_file != NULL) { - log_debug(classresolve)("%s %s %s (verification)", verify, resolve, source_file); + log_debug(class, resolve)("%s %s %s (verification)", verify, resolve, source_file); } else { - log_debug(classresolve)("%s %s (verification)", verify, resolve); + log_debug(class, resolve)("%s %s (verification)", verify, resolve); } } @@ -169,7 +169,7 @@ bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool shoul bool can_failover = FailOverToOldVerifier && klass->major_version() < NOFAILOVER_MAJOR_VERSION; - log_info(classinit)("Start class verification for: %s", klassName); + log_info(class, init)("Start class verification for: %s", klassName); if (klass->major_version() >= STACKMAP_ATTRIBUTE_MAJOR_VERSION) { ClassVerifier split_verifier(klass, THREAD); split_verifier.verify_class(THREAD); @@ -178,7 +178,7 @@ bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool shoul (exception_name == vmSymbols::java_lang_VerifyError() || exception_name == vmSymbols::java_lang_ClassFormatError())) { log_info(verification)("Fail over class verification to old verifier for: %s", klassName); - log_info(classinit)("Fail over class verification to old verifier for: %s", klassName); + log_info(class, init)("Fail over class verification to old verifier for: %s", klassName); exception_name = inference_verify( klass, message_buffer, message_buffer_len, THREAD); } @@ -190,8 +190,8 @@ bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool shoul klass, message_buffer, message_buffer_len, THREAD); } - if (log_is_enabled(Info, classinit)){ - log_end_verification(Log(classinit)::info_stream(), klassName, exception_name, THREAD); + if (log_is_enabled(Info, class, init)){ + log_end_verification(Log(class, init)::info_stream(), klassName, exception_name, THREAD); } if (log_is_enabled(Info, verification)){ log_end_verification(Log(verification)::info_stream(), klassName, exception_name, THREAD); @@ -205,7 +205,7 @@ bool Verifier::verify(instanceKlassHandle klass, Verifier::Mode mode, bool shoul ResourceMark rm(THREAD); instanceKlassHandle kls = SystemDictionary::resolve_or_fail(exception_name, true, CHECK_false); - if (log_is_enabled(Debug, classresolve)) { + if (log_is_enabled(Debug, class, resolve)) { Verifier::trace_class_resolution(kls(), klass()); } @@ -601,7 +601,7 @@ void ClassVerifier::verify_class(TRAPS) { if (was_recursively_verified()){ log_info(verification)("Recursive verification detected for: %s", _klass->external_name()); - log_info(classinit)("Recursive verification detected for: %s", + log_info(class, init)("Recursive verification detected for: %s", _klass->external_name()); } } @@ -1994,7 +1994,7 @@ Klass* ClassVerifier::load_class(Symbol* name, TRAPS) { name, Handle(THREAD, loader), Handle(THREAD, protection_domain), true, THREAD); - if (log_is_enabled(Debug, classresolve)) { + if (log_is_enabled(Debug, class, resolve)) { instanceKlassHandle cur_class = current_class(); Verifier::trace_class_resolution(kls, cur_class()); } diff --git a/hotspot/src/share/vm/classfile/verifier.hpp b/hotspot/src/share/vm/classfile/verifier.hpp index 531ef93f21a..a613c62a3d5 100644 --- a/hotspot/src/share/vm/classfile/verifier.hpp +++ b/hotspot/src/share/vm/classfile/verifier.hpp @@ -61,7 +61,7 @@ class Verifier : AllStatic { // Relax certain verifier checks to enable some broken 1.1 apps to run on 1.2. static bool relax_verify_for(oop class_loader); - // Print output for classresolve + // Print output for class+resolve static void trace_class_resolution(Klass* resolve_class, InstanceKlass* verify_class); private: diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index f1c9b74366e..3a20bc0bd21 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -1076,8 +1076,8 @@ void nmethod::make_unloaded(BoolObjectClosure* is_alive, oop cause) { flush_dependencies(is_alive); // Break cycle between nmethod & method - if (log_is_enabled(Trace, classunload)) { - outputStream* log = Log(classunload)::trace_stream(); + if (log_is_enabled(Trace, class, unload)) { + outputStream* log = Log(class, unload)::trace_stream(); log->print_cr("making nmethod " INTPTR_FORMAT " unloadable, Method*(" INTPTR_FORMAT "), cause(" INTPTR_FORMAT ")", diff --git a/hotspot/src/share/vm/logging/logTag.hpp b/hotspot/src/share/vm/logging/logTag.hpp index 1f0a1c31e2c..5e7cbbc9ea4 100644 --- a/hotspot/src/share/vm/logging/logTag.hpp +++ b/hotspot/src/share/vm/logging/logTag.hpp @@ -39,18 +39,15 @@ LOG_TAG(biasedlocking) \ LOG_TAG(bot) \ LOG_TAG(census) \ + LOG_TAG(class) \ LOG_TAG(classhisto) \ - LOG_TAG(classresolve) \ - LOG_TAG(classinit) \ - LOG_TAG(classload) /* Trace all classes loaded */ \ - LOG_TAG(classloaderdata) /* class loader loader_data lifetime */ \ - LOG_TAG(classunload) /* Trace unloading of classes */ \ - LOG_TAG(classpath) \ + LOG_TAG(cleanup) \ LOG_TAG(compaction) \ LOG_TAG(constraints) \ LOG_TAG(coops) \ LOG_TAG(cpu) \ LOG_TAG(cset) \ + LOG_TAG(data) \ LOG_TAG(defaultmethods) \ LOG_TAG(ergo) \ LOG_TAG(exceptions) \ @@ -60,10 +57,13 @@ LOG_TAG(heap) \ LOG_TAG(humongous) \ LOG_TAG(ihop) \ + LOG_TAG(init) \ LOG_TAG(itables) \ LOG_TAG(jni) \ LOG_TAG(jvmti) \ LOG_TAG(liveness) \ + LOG_TAG(load) /* Trace all classes loaded */ \ + LOG_TAG(loader) \ LOG_TAG(logging) \ LOG_TAG(marking) \ LOG_TAG(metaspace) \ @@ -74,6 +74,7 @@ LOG_TAG(objecttagging) \ LOG_TAG(os) \ LOG_TAG(pagesize) \ + LOG_TAG(path) \ LOG_TAG(phases) \ LOG_TAG(plab) \ LOG_TAG(promotion) \ @@ -83,8 +84,8 @@ LOG_TAG(refine) \ LOG_TAG(region) \ LOG_TAG(remset) \ + LOG_TAG(resolve) \ LOG_TAG(safepoint) \ - LOG_TAG(safepointcleanup) \ LOG_TAG(scavenge) \ LOG_TAG(scrub) \ LOG_TAG(stacktrace) \ @@ -101,6 +102,7 @@ LOG_TAG(thread) \ LOG_TAG(tlab) \ LOG_TAG(time) \ + LOG_TAG(unload) /* Trace unloading of classes */ \ LOG_TAG(verification) \ LOG_TAG(verify) \ LOG_TAG(vmoperation) \ diff --git a/hotspot/src/share/vm/memory/filemap.cpp b/hotspot/src/share/vm/memory/filemap.cpp index d690356f582..bf009d80b11 100644 --- a/hotspot/src/share/vm/memory/filemap.cpp +++ b/hotspot/src/share/vm/memory/filemap.cpp @@ -209,7 +209,7 @@ void FileMapInfo::allocate_classpath_entry_table() { count ++; bytes += (int)entry_size; bytes += name_bytes; - log_info(classpath)("add main shared path (%s) %s", (cpe->is_jar_file() ? "jar" : "dir"), name); + log_info(class, path)("add main shared path (%s) %s", (cpe->is_jar_file() ? "jar" : "dir"), name); } else { SharedClassPathEntry* ent = shared_classpath(cur_entry); if (cpe->is_jar_file()) { @@ -283,7 +283,7 @@ bool FileMapInfo::validate_classpath_entry_table() { struct stat st; const char* name = ent->_name; bool ok = true; - log_info(classpath)("checking shared classpath entry: %s", name); + log_info(class, path)("checking shared classpath entry: %s", name); if (os::stat(name, &st) != 0) { fail_continue("Required classpath entry does not exist: %s", name); ok = false; @@ -307,7 +307,7 @@ bool FileMapInfo::validate_classpath_entry_table() { } } if (ok) { - log_info(classpath)("ok"); + log_info(class, path)("ok"); } else if (!PrintSharedArchiveAndExit) { _validating_classpath_entry_table = false; return false; @@ -897,8 +897,8 @@ bool FileMapInfo::FileMapHeader::validate() { char header_version[JVM_IDENT_MAX]; get_header_version(header_version); if (strncmp(_jvm_ident, header_version, JVM_IDENT_MAX-1) != 0) { - log_info(classpath)("expected: %s", header_version); - log_info(classpath)("actual: %s", _jvm_ident); + log_info(class, path)("expected: %s", header_version); + log_info(class, path)("actual: %s", _jvm_ident); FileMapInfo::fail_continue("The shared archive file was created by a different" " version or build of HotSpot"); return false; @@ -926,7 +926,7 @@ bool FileMapInfo::validate_header() { if (status) { if (!ClassLoader::check_shared_paths_misc_info(_paths_misc_info, _header->_paths_misc_info_size)) { if (!PrintSharedArchiveAndExit) { - fail_continue("shared class paths mismatch (hint: enable -Xlog:classpath=info to diagnose the failure)"); + fail_continue("shared class paths mismatch (hint: enable -Xlog:class+path=info to diagnose the failure)"); status = false; } } diff --git a/hotspot/src/share/vm/memory/metaspaceShared.cpp b/hotspot/src/share/vm/memory/metaspaceShared.cpp index 5eacfbc646a..b975e9e1327 100644 --- a/hotspot/src/share/vm/memory/metaspaceShared.cpp +++ b/hotspot/src/share/vm/memory/metaspaceShared.cpp @@ -919,7 +919,7 @@ int MetaspaceShared::preload_and_dump(const char* class_list_path, InstanceKlass* ik = InstanceKlass::cast(klass); - // Should be class load order as per -Xlog:classload+preorder + // Should be class load order as per -Xlog:class+preorder class_promote_order->append(ik); // Link the class to cause the bytecodes to be rewritten and the diff --git a/hotspot/src/share/vm/oops/constantPool.cpp b/hotspot/src/share/vm/oops/constantPool.cpp index 708c2f77d86..ec22e2181c7 100644 --- a/hotspot/src/share/vm/oops/constantPool.cpp +++ b/hotspot/src/share/vm/oops/constantPool.cpp @@ -209,11 +209,11 @@ void ConstantPool::trace_class_resolution(const constantPoolHandle& this_cp, Kla if (k() != this_cp->pool_holder()) { // only print something if the classes are different if (source_file != NULL) { - log_debug(classresolve)("%s %s %s:%d", + log_debug(class, resolve)("%s %s %s:%d", this_cp->pool_holder()->external_name(), k->external_name(), source_file, line_number); } else { - log_debug(classresolve)("%s %s", + log_debug(class, resolve)("%s %s", this_cp->pool_holder()->external_name(), k->external_name()); } @@ -282,8 +282,8 @@ Klass* ConstantPool::klass_at_impl(const constantPoolHandle& this_cp, int which, ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data(); this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM - // logging for classresolve tag. - if (log_is_enabled(Debug, classresolve)){ + // logging for class+resolve. + if (log_is_enabled(Debug, class, resolve)){ trace_class_resolution(this_cp, k); } this_cp->klass_at_put(which, k()); @@ -341,7 +341,7 @@ Method* ConstantPool::method_at_if_loaded(const constantPoolHandle& cpool, int cache_index = decode_cpcache_index(which, true); if (!(cache_index >= 0 && cache_index < cpool->cache()->length())) { // FIXME: should be an assert - log_debug(classresolve)("bad operand %d in:", which); cpool->print(); + log_debug(class, resolve)("bad operand %d in:", which); cpool->print(); return NULL; } ConstantPoolCacheEntry* e = cpool->cache()->entry_at(cache_index); @@ -672,7 +672,7 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp, in Symbol* name = this_cp->method_handle_name_ref_at(index); Symbol* signature = this_cp->method_handle_signature_ref_at(index); { ResourceMark rm(THREAD); - log_debug(classresolve)("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s", + log_debug(class, resolve)("resolve JVM_CONSTANT_MethodHandle:%d [%d/%d/%d] %s.%s", ref_kind, index, this_cp->method_handle_index_at(index), callee_index, name->as_C_string(), signature->as_C_string()); } @@ -695,7 +695,7 @@ oop ConstantPool::resolve_constant_at_impl(const constantPoolHandle& this_cp, in { Symbol* signature = this_cp->method_type_signature_at(index); { ResourceMark rm(THREAD); - log_debug(classresolve)("resolve JVM_CONSTANT_MethodType [%d/%d] %s", + log_debug(class, resolve)("resolve JVM_CONSTANT_MethodType [%d/%d] %s", index, this_cp->method_type_index_at(index), signature->as_C_string()); } diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 997110cb583..4726909957a 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -450,9 +450,9 @@ void InstanceKlass::eager_initialize_impl(instanceKlassHandle this_k) { this_k->set_init_state (fully_initialized); this_k->fence_and_clear_init_lock(); // trace - if (log_is_enabled(Info, classinit)) { + if (log_is_enabled(Info, class, init)) { ResourceMark rm(THREAD); - log_info(classinit)("[Initialized %s without side effects]", this_k->external_name()); + log_info(class, init)("[Initialized %s without side effects]", this_k->external_name()); } } } @@ -1088,9 +1088,9 @@ void InstanceKlass::call_class_initializer_impl(instanceKlassHandle this_k, TRAP methodHandle h_method(THREAD, this_k->class_initializer()); assert(!this_k->is_initialized(), "we cannot initialize twice"); - if (log_is_enabled(Info, classinit)) { + if (log_is_enabled(Info, class, init)) { ResourceMark rm; - outputStream* log = Log(classinit)::info_stream(); + outputStream* log = Log(class, init)::info_stream(); log->print("%d Initializing ", call_class_initializer_impl_counter++); this_k->name()->print_value_on(log); log->print_cr("%s (" INTPTR_FORMAT ")", h_method() == NULL ? "(no method)" : "", p2i(this_k())); @@ -3014,11 +3014,11 @@ void InstanceKlass::print_loading_log(LogLevel::type type, assert(type == LogLevel::Info || type == LogLevel::Debug, "sanity"); if (type == LogLevel::Info) { - log = Log(classload)::info_stream(); + log = Log(class, load)::info_stream(); } else { assert(type == LogLevel::Debug, "print_loading_log supports only Debug and Info levels"); - log = Log(classload)::debug_stream(); + log = Log(class, load)::debug_stream(); } // Name and class hierarchy info diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index 8e3267868b8..d31e9e5706c 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -401,9 +401,9 @@ void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive Klass* sub = current->subklass(); while (sub != NULL && !sub->is_loader_alive(is_alive)) { #ifndef PRODUCT - if (log_is_enabled(Trace, classunload)) { + if (log_is_enabled(Trace, class, unload)) { ResourceMark rm; - log_trace(classunload)("unlinking class (subclass): %s", sub->external_name()); + log_trace(class, unload)("unlinking class (subclass): %s", sub->external_name()); } #endif sub = sub->next_sibling(); @@ -416,9 +416,9 @@ void Klass::clean_weak_klass_links(BoolObjectClosure* is_alive, bool clean_alive // Find and set the first alive sibling Klass* sibling = current->next_sibling(); while (sibling != NULL && !sibling->is_loader_alive(is_alive)) { - if (log_is_enabled(Trace, classunload)) { + if (log_is_enabled(Trace, class, unload)) { ResourceMark rm; - log_trace(classunload)("[Unlinking class (sibling) %s]", sibling->external_name()); + log_trace(class, unload)("[Unlinking class (sibling) %s]", sibling->external_name()); } sibling = sibling->next_sibling(); } diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index 8c1a020ac0f..a6f10fc768d 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -350,7 +350,7 @@ JNI_ENTRY(jclass, jni_DefineClass(JNIEnv *env, const char *name, jobject loaderR &st, CHECK_NULL); - if (log_is_enabled(Debug, classresolve) && k != NULL) { + if (log_is_enabled(Debug, class, resolve) && k != NULL) { trace_class_resolution(k); } @@ -420,7 +420,7 @@ JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name)) result = find_class_from_class_loader(env, sym, true, loader, protection_domain, true, thread); - if (log_is_enabled(Debug, classresolve) && result != NULL) { + if (log_is_enabled(Debug, class, resolve) && result != NULL) { trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); } @@ -3296,7 +3296,7 @@ static jclass lookupOne(JNIEnv* env, const char* name, TRAPS) { TempNewSymbol sym = SymbolTable::new_symbol(name, CHECK_NULL); jclass result = find_class_from_class_loader(env, sym, true, loader, protection_domain, true, CHECK_NULL); - if (log_is_enabled(Debug, classresolve) && result != NULL) { + if (log_is_enabled(Debug, class, resolve) && result != NULL) { trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); } return result; diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index 2357ad7e80c..f2710b6e377 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -210,9 +210,9 @@ static void trace_class_resolution_impl(Klass* to_class, TRAPS) { const char * to = to_class->external_name(); // print in a single call to reduce interleaving between threads if (source_file != NULL) { - log_debug(classresolve)("%s %s %s:%d (%s)", from, to, source_file, line_number, trace); + log_debug(class, resolve)("%s %s %s:%d (%s)", from, to, source_file, line_number, trace); } else { - log_debug(classresolve)("%s %s (%s)", from, to, trace); + log_debug(class, resolve)("%s %s (%s)", from, to, trace); } } } @@ -805,7 +805,7 @@ JVM_ENTRY(jclass, JVM_FindClassFromBootLoader(JNIEnv* env, return NULL; } - if (log_is_enabled(Debug, classresolve)) { + if (log_is_enabled(Debug, class, resolve)) { trace_class_resolution(k); } return (jclass) JNIHandles::make_local(env, k->java_mirror()); @@ -842,7 +842,7 @@ JVM_ENTRY(jclass, JVM_FindClassFromCaller(JNIEnv* env, const char* name, jclass result = find_class_from_class_loader(env, h_name, init, h_loader, h_prot, false, THREAD); - if (log_is_enabled(Debug, classresolve) && result != NULL) { + if (log_is_enabled(Debug, class, resolve) && result != NULL) { trace_class_resolution(java_lang_Class::as_Klass(JNIHandles::resolve_non_null(result))); } return result; @@ -872,7 +872,7 @@ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, jclass result = find_class_from_class_loader(env, h_name, init, h_loader, h_prot, true, thread); - if (log_is_enabled(Debug, classresolve) && result != NULL) { + if (log_is_enabled(Debug, class, resolve) && result != NULL) { // this function is generally only used for class loading during verification. ResourceMark rm; oop from_mirror = JNIHandles::resolve_non_null(from); @@ -882,7 +882,7 @@ JVM_ENTRY(jclass, JVM_FindClassFromClass(JNIEnv *env, const char *name, oop mirror = JNIHandles::resolve_non_null(result); Klass* to_class = java_lang_Class::as_Klass(mirror); const char * to = to_class->external_name(); - log_debug(classresolve)("%s %s (verification)", from_name, to); + log_debug(class, resolve)("%s %s (verification)", from_name, to); } return result; @@ -950,7 +950,7 @@ static jclass jvm_define_class_common(JNIEnv *env, const char *name, &st, CHECK_NULL); - if (log_is_enabled(Debug, classresolve) && k != NULL) { + if (log_is_enabled(Debug, class, resolve) && k != NULL) { trace_class_resolution(k); } diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp index f0877571f6e..d6f60a28f77 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp @@ -489,7 +489,7 @@ JvmtiEnv::AddToBootstrapClassLoaderSearch(const char* segment) { ObjectLocker ol(loader_lock, thread); // add the jar file to the bootclasspath - log_info(classload)("opened: %s", zip_entry->name()); + log_info(class, load)("opened: %s", zip_entry->name()); ClassLoaderExt::append_boot_classpath(zip_entry); return JVMTI_ERROR_NONE; } else { @@ -640,11 +640,11 @@ JvmtiEnv::SetVerboseFlag(jvmtiVerboseFlag flag, jboolean value) { break; case JVMTI_VERBOSE_CLASS: if (value == 0) { - LogConfiguration::parse_log_arguments("stdout", "classunload=off", NULL, NULL, NULL); - LogConfiguration::parse_log_arguments("stdout", "classload=off", NULL, NULL, NULL); + LogConfiguration::parse_log_arguments("stdout", "class+unload=off", NULL, NULL, NULL); + LogConfiguration::parse_log_arguments("stdout", "class+load=off", NULL, NULL, NULL); } else { - LogConfiguration::parse_log_arguments("stdout", "classload=info", NULL, NULL, NULL); - LogConfiguration::parse_log_arguments("stdout", "classunload=info", NULL, NULL, NULL); + LogConfiguration::parse_log_arguments("stdout", "class+load=info", NULL, NULL, NULL); + LogConfiguration::parse_log_arguments("stdout", "class+unload=info", NULL, NULL, NULL); } break; case JVMTI_VERBOSE_GC: diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index 8843aa7f661..cd12174c12e 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -1555,7 +1555,7 @@ int WhiteBox::offset_for_field(const char* field_name, oop object, if (res == NULL) { tty->print_cr("Invalid layout of %s at %s", ik->external_name(), name_symbol->as_C_string()); - vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:classload=info to see the origin of the problem class"); + vm_exit_during_initialization("Invalid layout of preloaded class: use -Xlog:class+load=info to see the origin of the problem class"); } //fetch the field at the offset we've found diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 7aaad537cf2..beddacfc014 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -411,15 +411,15 @@ static AliasedFlag const aliased_jvm_flags[] = { static AliasedLoggingFlag const aliased_logging_flags[] = { { "PrintCompressedOopsMode", LogLevel::Info, true, LOG_TAGS(gc, heap, coops) }, { "TraceBiasedLocking", LogLevel::Info, true, LOG_TAGS(biasedlocking) }, - { "TraceClassLoading", LogLevel::Info, true, LOG_TAGS(classload) }, - { "TraceClassLoadingPreorder", LogLevel::Debug, true, LOG_TAGS(classload, preorder) }, - { "TraceClassPaths", LogLevel::Info, true, LOG_TAGS(classpath) }, - { "TraceClassResolution", LogLevel::Debug, true, LOG_TAGS(classresolve) }, - { "TraceClassUnloading", LogLevel::Info, true, LOG_TAGS(classunload) }, + { "TraceClassLoading", LogLevel::Info, true, LOG_TAGS(class, load) }, + { "TraceClassLoadingPreorder", LogLevel::Debug, true, LOG_TAGS(class, preorder) }, + { "TraceClassPaths", LogLevel::Info, true, LOG_TAGS(class, path) }, + { "TraceClassResolution", LogLevel::Debug, true, LOG_TAGS(class, resolve) }, + { "TraceClassUnloading", LogLevel::Info, true, LOG_TAGS(class, unload) }, { "TraceExceptions", LogLevel::Info, true, LOG_TAGS(exceptions) }, - { "TraceLoaderConstraints", LogLevel::Info, true, LOG_TAGS(classload, constraints) }, + { "TraceLoaderConstraints", LogLevel::Info, true, LOG_TAGS(class, loader, constraints) }, { "TraceMonitorInflation", LogLevel::Debug, true, LOG_TAGS(monitorinflation) }, - { "TraceSafepointCleanupTime", LogLevel::Info, true, LOG_TAGS(safepointcleanup) }, + { "TraceSafepointCleanupTime", LogLevel::Info, true, LOG_TAGS(safepoint, cleanup) }, { "TraceJVMTIObjectTagging", LogLevel::Debug, true, LOG_TAGS(jvmti, objecttagging) }, { NULL, LogLevel::Off, false, LOG_TAGS(_NO_TAG) } }; @@ -427,8 +427,8 @@ static AliasedLoggingFlag const aliased_logging_flags[] = { #ifndef PRODUCT // These options are removed in jdk9. Remove this code for jdk10. static AliasedFlag const removed_develop_logging_flags[] = { - { "TraceClassInitialization", "-Xlog:classinit" }, - { "TraceClassLoaderData", "-Xlog:classloaderdata" }, + { "TraceClassInitialization", "-Xlog:class+init" }, + { "TraceClassLoaderData", "-Xlog:class+loader+data" }, { "TraceDefaultMethods", "-Xlog:defaultmethods=debug" }, { "TraceItables", "-Xlog:itables=debug" }, { "TraceMonitorMismatch", "-Xlog:monitormismatch=info" }, @@ -2846,8 +2846,8 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, // -verbose:[class/gc/jni] if (match_option(option, "-verbose", &tail)) { if (!strcmp(tail, ":class") || !strcmp(tail, "")) { - LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(classload)); - LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(classunload)); + LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, load)); + LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, unload)); } else if (!strcmp(tail, ":gc")) { LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(gc)); } else if (!strcmp(tail, ":jni")) { @@ -3488,7 +3488,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, // PrintSharedArchiveAndExit will turn on // -Xshare:on - // -Xlog:classpath=info + // -Xlog:class+path=info if (PrintSharedArchiveAndExit) { if (FLAG_SET_CMDLINE(bool, UseSharedSpaces, true) != Flag::SUCCESS) { return JNI_EINVAL; @@ -3496,7 +3496,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, if (FLAG_SET_CMDLINE(bool, RequireSharedSpaces, true) != Flag::SUCCESS) { return JNI_EINVAL; } - LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(classpath)); + LogConfiguration::configure_stdout(LogLevel::Info, true, LOG_TAGS(class, path)); } // Change the default value for flags which have different default values diff --git a/hotspot/src/share/vm/runtime/reflection.cpp b/hotspot/src/share/vm/runtime/reflection.cpp index 761ced6907a..f81deb6a374 100644 --- a/hotspot/src/share/vm/runtime/reflection.cpp +++ b/hotspot/src/share/vm/runtime/reflection.cpp @@ -76,9 +76,9 @@ static void trace_class_resolution(const Klass* to_class) { const char * to = to_class->external_name(); // print in a single call to reduce interleaving between threads if (source_file != NULL) { - log_debug(classresolve)("%s %s %s:%d (reflection)", from, to, source_file, line_number); + log_debug(class, resolve)("%s %s %s:%d (reflection)", from, to, source_file, line_number); } else { - log_debug(classresolve)("%s %s (reflection)", from, to); + log_debug(class, resolve)("%s %s (reflection)", from, to); } } } @@ -761,7 +761,7 @@ static oop get_mirror_from_signature(methodHandle method, Handle(THREAD, protection_domain), true, CHECK_NULL); - if (log_is_enabled(Debug, classresolve)) { + if (log_is_enabled(Debug, class, resolve)) { trace_class_resolution(k); } return k->java_mirror(); @@ -816,7 +816,7 @@ static Handle new_type(Symbol* signature, KlassHandle k, TRAPS) { Handle(THREAD, k->protection_domain()), true, CHECK_(Handle())); - if (log_is_enabled(Debug, classresolve)) { + if (log_is_enabled(Debug, class, resolve)) { trace_class_resolution(result); } diff --git a/hotspot/src/share/vm/runtime/safepoint.cpp b/hotspot/src/share/vm/runtime/safepoint.cpp index 96fb3962565..28f00fdbe03 100644 --- a/hotspot/src/share/vm/runtime/safepoint.cpp +++ b/hotspot/src/share/vm/runtime/safepoint.cpp @@ -545,7 +545,7 @@ void SafepointSynchronize::do_cleanup_tasks() { { const char* name = "deflating idle monitors"; EventSafepointCleanupTask event; - TraceTime timer(name, TRACETIME_LOG(Info, safepointcleanup)); + TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); ObjectSynchronizer::deflate_idle_monitors(); event_safepoint_cleanup_task_commit(event, name); } @@ -553,14 +553,14 @@ void SafepointSynchronize::do_cleanup_tasks() { { const char* name = "updating inline caches"; EventSafepointCleanupTask event; - TraceTime timer(name, TRACETIME_LOG(Info, safepointcleanup)); + TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); InlineCacheBuffer::update_inline_caches(); event_safepoint_cleanup_task_commit(event, name); } { const char* name = "compilation policy safepoint handler"; EventSafepointCleanupTask event; - TraceTime timer("compilation policy safepoint handler", TRACETIME_LOG(Info, safepointcleanup)); + TraceTime timer("compilation policy safepoint handler", TRACETIME_LOG(Info, safepoint, cleanup)); CompilationPolicy::policy()->do_safepoint_work(); event_safepoint_cleanup_task_commit(event, name); } @@ -568,7 +568,7 @@ void SafepointSynchronize::do_cleanup_tasks() { { const char* name = "mark nmethods"; EventSafepointCleanupTask event; - TraceTime timer(name, TRACETIME_LOG(Info, safepointcleanup)); + TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); NMethodSweeper::mark_active_nmethods(); event_safepoint_cleanup_task_commit(event, name); } @@ -576,7 +576,7 @@ void SafepointSynchronize::do_cleanup_tasks() { if (SymbolTable::needs_rehashing()) { const char* name = "rehashing symbol table"; EventSafepointCleanupTask event; - TraceTime timer(name, TRACETIME_LOG(Info, safepointcleanup)); + TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); SymbolTable::rehash_table(); event_safepoint_cleanup_task_commit(event, name); } @@ -584,7 +584,7 @@ void SafepointSynchronize::do_cleanup_tasks() { if (StringTable::needs_rehashing()) { const char* name = "rehashing string table"; EventSafepointCleanupTask event; - TraceTime timer(name, TRACETIME_LOG(Info, safepointcleanup)); + TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); StringTable::rehash_table(); event_safepoint_cleanup_task_commit(event, name); } @@ -594,7 +594,7 @@ void SafepointSynchronize::do_cleanup_tasks() { // make sure concurrent sweep is done const char* name = "purging class loader data graph"; EventSafepointCleanupTask event; - TraceTime timer(name, TRACETIME_LOG(Info, safepointcleanup)); + TraceTime timer(name, TRACETIME_LOG(Info, safepoint, cleanup)); ClassLoaderDataGraph::purge_if_needed(); event_safepoint_cleanup_task_commit(event, name); } diff --git a/hotspot/src/share/vm/services/classLoadingService.cpp b/hotspot/src/share/vm/services/classLoadingService.cpp index 67bdb223653..6d1f0cdb36f 100644 --- a/hotspot/src/share/vm/services/classLoadingService.cpp +++ b/hotspot/src/share/vm/services/classLoadingService.cpp @@ -138,9 +138,9 @@ void ClassLoadingService::notify_class_unloaded(InstanceKlass* k) { } } - if (log_is_enabled(Info, classunload)) { + if (log_is_enabled(Info, class, unload)) { ResourceMark rm; - log_info(classunload)("unloading class %s " INTPTR_FORMAT , k->external_name(), p2i(k)); + log_info(class, unload)("unloading class %s " INTPTR_FORMAT , k->external_name(), p2i(k)); } } @@ -184,9 +184,9 @@ bool ClassLoadingService::set_verbose(bool verbose) { MutexLocker m(Management_lock); // verbose will be set to the previous value if (verbose) { - LogConfiguration::parse_log_arguments("stdout", "classload=info", NULL, NULL, NULL); + LogConfiguration::parse_log_arguments("stdout", "class+load=info", NULL, NULL, NULL); } else { - LogConfiguration::parse_log_arguments("stdout", "classload=off", NULL, NULL, NULL); + LogConfiguration::parse_log_arguments("stdout", "class+load=off", NULL, NULL, NULL); } reset_trace_class_unloading(); return verbose; @@ -197,9 +197,9 @@ void ClassLoadingService::reset_trace_class_unloading() { assert(Management_lock->owned_by_self(), "Must own the Management_lock"); bool value = MemoryService::get_verbose() || ClassLoadingService::get_verbose(); if (value) { - LogConfiguration::parse_log_arguments("stdout", "classunload=info", NULL, NULL, NULL); + LogConfiguration::parse_log_arguments("stdout", "class+unload=info", NULL, NULL, NULL); } else { - LogConfiguration::parse_log_arguments("stdout", "classunload=off", NULL, NULL, NULL); + LogConfiguration::parse_log_arguments("stdout", "class+unload=off", NULL, NULL, NULL); } } diff --git a/hotspot/src/share/vm/services/classLoadingService.hpp b/hotspot/src/share/vm/services/classLoadingService.hpp index 16ff40fd4be..763abcc1656 100644 --- a/hotspot/src/share/vm/services/classLoadingService.hpp +++ b/hotspot/src/share/vm/services/classLoadingService.hpp @@ -55,7 +55,7 @@ private: public: static void init(); - static bool get_verbose() { return log_is_enabled(Info, classload); } + static bool get_verbose() { return log_is_enabled(Info, class, load); } static bool set_verbose(bool verbose); static void reset_trace_class_unloading() NOT_MANAGEMENT_RETURN; diff --git a/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java b/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java index 78ee7131476..9ab3c36e3de 100644 --- a/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java +++ b/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java @@ -27,7 +27,7 @@ * @modules java.base/jdk.internal.org.objectweb.asm * @library patches * @build java.base/java.lang.invoke.MethodHandleHelper - * @run main/bootclasspath -Xbatch -XX:+IgnoreUnrecognizedVMOptions -Xlog:classunload + * @run main/bootclasspath -Xbatch -XX:+IgnoreUnrecognizedVMOptions -Xlog:class+unload * -XX:+PrintCompilation -XX:+TraceDependencies -XX:+TraceReferenceGC * -verbose:gc compiler.jsr292.CallSiteDepContextTest */ diff --git a/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java index b4bb37cacba..3e6fa990eab 100644 --- a/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java +++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java @@ -56,17 +56,17 @@ import java.nio.file.Paths; * gc.g1.humongousObjects.ClassLoaderGenerator 1 * * @run main/othervm -Xms256M -Xmx256M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. - * -Xlog:classload,classunload=debug:file=TestHumongousClassLoader_Full_GC.log + * -Xlog:class+load,class+unload=debug:file=TestHumongousClassLoader_Full_GC.log * -XX:G1HeapRegionSize=1M * gc.g1.humongousObjects.TestHumongousClassLoader FULL_GC * * @run main/othervm -Xms256M -Xmx256M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. - * -Xlog:classload,classunload=debug:file=TestHumongousClassLoader_Full_GC_Mem_Pressure.log + * -Xlog:class+load,class+unload=debug:file=TestHumongousClassLoader_Full_GC_Mem_Pressure.log * -XX:G1HeapRegionSize=1M * gc.g1.humongousObjects.TestHumongousClassLoader FULL_GC_MEMORY_PRESSURE * *@run main/othervm -Xms256M -Xmx256M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. - * -Xlog:classload,classunload=debug:file=TestHumongousClassLoader_CMC.log + * -Xlog:class+load,class+unload=debug:file=TestHumongousClassLoader_CMC.log * -XX:G1HeapRegionSize=1M -XX:MaxTenuringThreshold=1 * gc.g1.humongousObjects.TestHumongousClassLoader CMC * diff --git a/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java b/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java index efc95b94b83..502adcf24be 100644 --- a/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java +++ b/hotspot/test/runtime/SharedArchiveFile/BootAppendTests.java @@ -154,7 +154,7 @@ public class BootAppendTests { APP_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("[classload] org.omg.CORBA.Context source: jrt:/java.corba"); + output.shouldContain("[class,load] org.omg.CORBA.Context source: jrt:/java.corba"); } } @@ -179,11 +179,11 @@ public class BootAppendTests { APP_CLASS, BOOT_APPEND_MODULE_CLASS_NAME); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("[classload] javax.sound.sampled.MyClass"); + output.shouldContain("[class,load] javax.sound.sampled.MyClass"); // When CDS is enabled, the shared class should be loaded from the archive. if (mode.equals("on")) { - output.shouldContain("[classload] javax.sound.sampled.MyClass source: shared objects file"); + output.shouldContain("[class,load] javax.sound.sampled.MyClass source: shared objects file"); } } } @@ -211,8 +211,8 @@ public class BootAppendTests { APP_CLASS, BOOT_APPEND_DUPLICATE_MODULE_CLASS_NAME); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("[classload] org.omg.CORBA.Context"); - output.shouldMatch(".*\\[classload\\] org.omg.CORBA.Context source:.*bootAppend.jar"); + output.shouldContain("[class,load] org.omg.CORBA.Context"); + output.shouldMatch(".*\\[class,load\\] org.omg.CORBA.Context source:.*bootAppend.jar"); } } @@ -235,13 +235,13 @@ public class BootAppendTests { APP_CLASS, BOOT_APPEND_CLASS_NAME); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("[classload] nonjdk.myPackage.MyClass"); + output.shouldContain("[class,load] nonjdk.myPackage.MyClass"); // If CDS is enabled, the nonjdk.myPackage.MyClass should be loaded // from the shared archive. if (mode.equals("on")) { output.shouldContain( - "[classload] nonjdk.myPackage.MyClass source: shared objects file"); + "[class,load] nonjdk.myPackage.MyClass source: shared objects file"); } } } diff --git a/hotspot/test/runtime/logging/ClassInitializationTest.java b/hotspot/test/runtime/logging/ClassInitializationTest.java index a95cc489a3e..331b8fd9bdd 100644 --- a/hotspot/test/runtime/logging/ClassInitializationTest.java +++ b/hotspot/test/runtime/logging/ClassInitializationTest.java @@ -40,7 +40,7 @@ public class ClassInitializationTest { public static void main(String... args) throws Exception { // (1) - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:classinit=info", + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+init=info", "-Xverify:all", "-Xmx64m", "BadMap50"); @@ -53,7 +53,7 @@ public class ClassInitializationTest { // (2) if (Platform.isDebugBuild()) { - pb = ProcessTools.createJavaProcessBuilder("-Xlog:classinit=info", + pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+init=info", "-Xverify:all", "-XX:+EagerInitialization", "-Xmx64m", @@ -63,13 +63,13 @@ public class ClassInitializationTest { out.shouldHaveExitValue(0); } - // (3) classinit should turn off. - pb = ProcessTools.createJavaProcessBuilder("-Xlog:classinit=off", + // (3) class+init should turn off. + pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+init=off", "-Xverify:all", "-Xmx64m", "BadMap50"); out = new OutputAnalyzer(pb.start()); - out.shouldNotContain("[classinit]"); + out.shouldNotContain("[class,init]"); out.shouldNotContain("Fail over class verification to old verifier for: BadMap50"); } diff --git a/hotspot/test/runtime/logging/ClassLoadUnloadTest.java b/hotspot/test/runtime/logging/ClassLoadUnloadTest.java index 85cf5cb2284..80dc17a37dc 100644 --- a/hotspot/test/runtime/logging/ClassLoadUnloadTest.java +++ b/hotspot/test/runtime/logging/ClassLoadUnloadTest.java @@ -79,50 +79,50 @@ public class ClassLoadUnloadTest { public static void main(String... args) throws Exception { - // -Xlog:classunload=info - pb = exec("-Xlog:classunload=info"); - checkFor("[classunload]", "unloading class"); + // -Xlog:class+unload=info + pb = exec("-Xlog:class+unload=info"); + checkFor("[class,unload]", "unloading class"); - // -Xlog:classunload=off - pb = exec("-Xlog:classunload=off"); - checkAbsent("[classunload]"); + // -Xlog:class+unload=off + pb = exec("-Xlog:class+unload=off"); + checkAbsent("[class,unload]"); // -XX:+TraceClassUnloading pb = exec("-XX:+TraceClassUnloading"); - checkFor("[classunload]", "unloading class"); + checkFor("[class,unload]", "unloading class"); // -XX:-TraceClassUnloading pb = exec("-XX:-TraceClassUnloading"); - checkAbsent("[classunload]"); + checkAbsent("[class,unload]"); - // -Xlog:classload=info - pb = exec("-Xlog:classload=info"); - checkFor("[classload]", "java.lang.Object", "source:"); + // -Xlog:class+load=info + pb = exec("-Xlog:class+load=info"); + checkFor("[class,load]", "java.lang.Object", "source:"); - // -Xlog:classload=debug - pb = exec("-Xlog:classload=debug"); - checkFor("[classload]", "java.lang.Object", "source:", "klass:", "super:", "loader:", "bytes:"); + // -Xlog:class+load=debug + pb = exec("-Xlog:class+load=debug"); + checkFor("[class,load]", "java.lang.Object", "source:", "klass:", "super:", "loader:", "bytes:"); - // -Xlog:classload=off - pb = exec("-Xlog:classload=off"); - checkAbsent("[classload]"); + // -Xlog:class+load=off + pb = exec("-Xlog:class+load=off"); + checkAbsent("[class,load]"); // -XX:+TraceClassLoading pb = exec("-XX:+TraceClassLoading"); - checkFor("[classload]", "java.lang.Object", "source:"); + checkFor("[class,load]", "java.lang.Object", "source:"); // -XX:-TraceClassLoading pb = exec("-XX:-TraceClassLoading"); - checkAbsent("[classload]"); + checkAbsent("[class,load]"); // -verbose:class pb = exec("-verbose:class"); - checkFor("[classload]", "java.lang.Object", "source:"); - checkFor("[classunload]", "unloading class"); + checkFor("[class,load]", "java.lang.Object", "source:"); + checkFor("[class,unload]", "unloading class"); - // -Xlog:classloaderdata=trace - pb = exec("-Xlog:classloaderdata=trace"); - checkFor("[classloaderdata]", "create class loader data"); + // -Xlog:class+loader+data=trace + pb = exec("-Xlog:class+loader+data=trace"); + checkFor("[class,loader,data]", "create class loader data"); } } diff --git a/hotspot/test/runtime/logging/ClassResolutionTest.java b/hotspot/test/runtime/logging/ClassResolutionTest.java index 700fc77cb29..a5b184b3829 100644 --- a/hotspot/test/runtime/logging/ClassResolutionTest.java +++ b/hotspot/test/runtime/logging/ClassResolutionTest.java @@ -58,32 +58,32 @@ public class ClassResolutionTest { public static void main(String... args) throws Exception { - // (1) classresolve should turn on. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:classresolve=debug", + // (1) class+resolve should turn on. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+resolve=debug", ClassResolutionTestMain.class.getName()); OutputAnalyzer o = new OutputAnalyzer(pb.start()); - o.shouldContain("[classresolve] ClassResolutionTest$ClassResolutionTestMain$Thing1Handler ClassResolutionTest$ClassResolutionTestMain$Thing1"); - o.shouldContain("[classresolve] resolve JVM_CONSTANT_MethodHandle"); + o.shouldContain("[class,resolve] ClassResolutionTest$ClassResolutionTestMain$Thing1Handler ClassResolutionTest$ClassResolutionTestMain$Thing1"); + o.shouldContain("[class,resolve] resolve JVM_CONSTANT_MethodHandle"); - // (2) classresolve should turn off. - pb = ProcessTools.createJavaProcessBuilder("-Xlog:classresolve=debug", - "-Xlog:classresolve=off", + // (2) class+resolve should turn off. + pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+resolve=debug", + "-Xlog:class+resolve=off", ClassResolutionTestMain.class.getName()); o = new OutputAnalyzer(pb.start()); - o.shouldNotContain("[classresolve]"); + o.shouldNotContain("[class,resolve]"); // (3) TraceClassResolution should turn on. pb = ProcessTools.createJavaProcessBuilder("-XX:+TraceClassResolution", ClassResolutionTestMain.class.getName()); o = new OutputAnalyzer(pb.start()); - o.shouldContain("[classresolve] ClassResolutionTest$ClassResolutionTestMain$Thing1Handler ClassResolutionTest$ClassResolutionTestMain$Thing1"); + o.shouldContain("[class,resolve] ClassResolutionTest$ClassResolutionTestMain$Thing1Handler ClassResolutionTest$ClassResolutionTestMain$Thing1"); // (4) TraceClassResolution should turn off. - pb = ProcessTools.createJavaProcessBuilder("-Xlog:classresolve=debug", + pb = ProcessTools.createJavaProcessBuilder("-Xlog:class+resolve=debug", "-XX:-TraceClassResolution", ClassResolutionTestMain.class.getName()); o = new OutputAnalyzer(pb.start()); - o.shouldNotContain("[classresolve]"); + o.shouldNotContain("[class,resolve]"); }; diff --git a/hotspot/test/runtime/logging/LoaderConstraintsTest.java b/hotspot/test/runtime/logging/LoaderConstraintsTest.java index 7d7fdffe87a..398a3ecc871 100644 --- a/hotspot/test/runtime/logging/LoaderConstraintsTest.java +++ b/hotspot/test/runtime/logging/LoaderConstraintsTest.java @@ -67,22 +67,22 @@ public class LoaderConstraintsTest { pb = exec("-XX:+TraceLoaderConstraints"); out = new OutputAnalyzer(pb.start()); out.getOutput(); - out.shouldContain("[classload,constraints] adding new constraint for name: java/lang/Class, loader[0]: jdk/internal/loader/ClassLoaders$AppClassLoader, loader[1]: "); + out.shouldContain("[class,loader,constraints] adding new constraint for name: java/lang/Class, loader[0]: jdk/internal/loader/ClassLoaders$AppClassLoader, loader[1]: "); - // -Xlog:classload+constraints=info - pb = exec("-Xlog:classload+constraints=info"); + // -Xlog:class+loader+constraints=info + pb = exec("-Xlog:class+loader+constraints=info"); out = new OutputAnalyzer(pb.start()); - out.shouldContain("[classload,constraints] adding new constraint for name: java/lang/Class, loader[0]: jdk/internal/loader/ClassLoaders$AppClassLoader, loader[1]: "); + out.shouldContain("[class,loader,constraints] adding new constraint for name: java/lang/Class, loader[0]: jdk/internal/loader/ClassLoaders$AppClassLoader, loader[1]: "); // -XX:-TraceLoaderConstraints pb = exec("-XX:-TraceLoaderConstraints"); out = new OutputAnalyzer(pb.start()); - out.shouldNotContain("[classload,constraints]"); + out.shouldNotContain("[class,loaderconstraints]"); - // -Xlog:classload+constraints=off - pb = exec("-Xlog:classload+constraints=off"); + // -Xlog:class+loader+constraints=off + pb = exec("-Xlog:class+loader+constraints=off"); out = new OutputAnalyzer(pb.start()); - out.shouldNotContain("[classload,constraints]"); + out.shouldNotContain("[class,loader,constraints]"); } } diff --git a/hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java b/hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java index a5d44d98116..44f5ab1144d 100644 --- a/hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java +++ b/hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java @@ -49,8 +49,8 @@ public class RemovedDevelopFlagsTest { public static void main(String... args) throws Exception { if (Platform.isDebugBuild()){ - exec("TraceClassInitialization", "-Xlog:classinit"); - exec("TraceClassLoaderData", "-Xlog:classloaderdata"); + exec("TraceClassInitialization", "-Xlog:class+init"); + exec("TraceClassLoaderData", "-Xlog:class+loader+data"); exec("TraceDefaultMethods", "-Xlog:defaultmethods=debug"); exec("TraceItables", "-Xlog:itables=debug"); exec("TraceSafepoint", "-Xlog:safepoint=debug"); diff --git a/hotspot/test/runtime/logging/SafepointCleanupTest.java b/hotspot/test/runtime/logging/SafepointCleanupTest.java index efe47cb431b..cbec3cb5763 100644 --- a/hotspot/test/runtime/logging/SafepointCleanupTest.java +++ b/hotspot/test/runtime/logging/SafepointCleanupTest.java @@ -24,7 +24,7 @@ /* * @test * @bug 8149991 - * @summary safepointcleanup=info should have output from the code + * @summary safepoint+cleanup=info should have output from the code * @library /testlibrary * @modules java.base/jdk.internal.misc * java.management @@ -38,7 +38,7 @@ import jdk.test.lib.ProcessTools; public class SafepointCleanupTest { static void analyzeOutputOn(ProcessBuilder pb) throws Exception { OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("[safepointcleanup]"); + output.shouldContain("[safepoint,cleanup]"); output.shouldContain("deflating idle monitors"); output.shouldContain("updating inline caches"); output.shouldContain("compilation policy safepoint handler"); @@ -49,12 +49,12 @@ public class SafepointCleanupTest { static void analyzeOutputOff(ProcessBuilder pb) throws Exception { OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldNotContain("[safepointcleanup]"); + output.shouldNotContain("[safepoint,cleanup]"); output.shouldHaveExitValue(0); } public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepointcleanup=info", + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepoint+cleanup=info", InnerClass.class.getName()); analyzeOutputOn(pb); @@ -62,7 +62,7 @@ public class SafepointCleanupTest { InnerClass.class.getName()); analyzeOutputOn(pb); - pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepointcleanup=off", + pb = ProcessTools.createJavaProcessBuilder("-Xlog:safepoint+cleanup=off", InnerClass.class.getName()); analyzeOutputOff(pb); diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java b/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java index 02edebf60c0..38ad2e817cf 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java +++ b/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java @@ -54,12 +54,12 @@ public class XpatchTraceCL { OutputAnalyzer output = new OutputAnalyzer(pb.start()); // "modules" jimage case. - output.shouldContain("[classload] java.lang.Thread source: jrt:/java.base"); + output.shouldContain("[class,load] java.lang.Thread source: jrt:/java.base"); // -Xpatch case. - output.shouldContain("[classload] javax.naming.spi.NamingManager source: mods" + + output.shouldContain("[class,load] javax.naming.spi.NamingManager source: mods" + File.separator + "java.naming"); // -cp case. - output.shouldContain("[classload] XpatchMain source: file"); + output.shouldContain("[class,load] XpatchMain source: file"); // Test -XX:+TraceClassLoading output for -Xbootclasspath/a source = "package XpatchTraceCL_pkg; " + @@ -77,7 +77,7 @@ public class XpatchTraceCL { "-XX:+TraceClassLoading", "XpatchMain", "XpatchTraceCL_pkg.ItIsI"); output = new OutputAnalyzer(pb.start()); // -Xbootclasspath/a case. - output.shouldContain("[classload] XpatchTraceCL_pkg.ItIsI source: xbcp"); + output.shouldContain("[class,load] XpatchTraceCL_pkg.ItIsI source: xbcp"); output.shouldHaveExitValue(0); } } diff --git a/hotspot/test/runtime/verifier/TraceClassRes.java b/hotspot/test/runtime/verifier/TraceClassRes.java index ef18a5cfe4e..ab1912aadf1 100644 --- a/hotspot/test/runtime/verifier/TraceClassRes.java +++ b/hotspot/test/runtime/verifier/TraceClassRes.java @@ -38,7 +38,7 @@ public class TraceClassRes { "-XX:+TraceClassResolution", "-verify", "-Xshare:off", "-version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("[classresolve] java.lang.ClassLoader java.lang.Throwable ClassLoader.java (verification)"); + output.shouldContain("[class,resolve] java.lang.ClassLoader java.lang.Throwable ClassLoader.java (verification)"); output.shouldHaveExitValue(0); } } -- GitLab From 85deb5aa7e9715a83d02b6bfddaa4af0dba4fe17 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Sun, 1 May 2016 12:47:00 +0300 Subject: [PATCH 238/400] 8154258: [TESTBUG] Various serviceability tests fail compilation Replace sun.misc.Unsafe with jdk.internal.misc.Unsafe Reviewed-by: chegar, kvn --- .../test/compiler/c2/5057225/Test5057225.java | 1 + hotspot/test/compiler/c2/6603011/Test.java | 1 + .../test/compiler/c2/6800154/Test6800154.java | 1 + .../test/compiler/c2/6805724/Test6805724.java | 1 + .../test/compiler/c2/6968348/Test6968348.java | 4 +-- .../c2/7190310/Test7190310_unsafe.java | 4 +-- .../compiler/c2/8004867/TestIntUnsafeCAS.java | 4 +-- .../c2/8004867/TestIntUnsafeVolatile.java | 4 +-- .../CompiledInvokeDynamic2CompiledTest.java | 1 + ...CompiledInvokeDynamic2InterpretedTest.java | 1 + .../CompiledInvokeDynamic2NativeTest.java | 1 + .../CompiledInvokeInterface2CompiledTest.java | 1 + ...mpiledInvokeInterface2InterpretedTest.java | 1 + .../CompiledInvokeInterface2NativeTest.java | 1 + .../CompiledInvokeSpecial2CompiledTest.java | 1 + ...CompiledInvokeSpecial2InterpretedTest.java | 1 + .../CompiledInvokeSpecial2NativeTest.java | 1 + .../CompiledInvokeStatic2CompiledTest.java | 1 + .../CompiledInvokeStatic2InterpretedTest.java | 1 + .../CompiledInvokeStatic2NativeTest.java | 1 + .../CompiledInvokeVirtual2CompiledTest.java | 1 + ...CompiledInvokeVirtual2InterpretedTest.java | 1 + .../CompiledInvokeVirtual2NativeTest.java | 1 + ...InterpretedInvokeDynamic2CompiledTest.java | 1 + ...erpretedInvokeDynamic2InterpretedTest.java | 1 + .../InterpretedInvokeDynamic2NativeTest.java | 1 + ...terpretedInvokeInterface2CompiledTest.java | 1 + ...pretedInvokeInterface2InterpretedTest.java | 1 + ...InterpretedInvokeInterface2NativeTest.java | 1 + ...InterpretedInvokeSpecial2CompiledTest.java | 1 + ...erpretedInvokeSpecial2InterpretedTest.java | 1 + .../InterpretedInvokeSpecial2NativeTest.java | 1 + .../InterpretedInvokeStatic2CompiledTest.java | 1 + ...terpretedInvokeStatic2InterpretedTest.java | 1 + .../InterpretedInvokeStatic2NativeTest.java | 1 + ...InterpretedInvokeVirtual2CompiledTest.java | 1 + ...erpretedInvokeVirtual2InterpretedTest.java | 1 + .../InterpretedInvokeVirtual2NativeTest.java | 1 + .../NativeInvokeSpecial2CompiledTest.java | 1 + .../NativeInvokeSpecial2InterpretedTest.java | 1 + .../NativeInvokeSpecial2NativeTest.java | 1 + .../NativeInvokeStatic2CompiledTest.java | 1 + .../NativeInvokeStatic2InterpretedTest.java | 1 + .../NativeInvokeStatic2NativeTest.java | 1 + .../NativeInvokeVirtual2CompiledTest.java | 1 + .../NativeInvokeVirtual2InterpretedTest.java | 1 + .../NativeInvokeVirtual2NativeTest.java | 1 + .../TestAnonymousClassUnloading.java | 2 +- .../methodUnloading/TestMethodUnloading.java | 1 + .../codecache/OverflowCodeCacheTest.java | 1 + .../dtrace/SegmentedCodeCacheDtraceTest.java | 1 + .../compiler/codecache/jmx/BeanTypeTest.java | 1 + .../jmx/CodeHeapBeanPresenceTest.java | 1 + .../codecache/jmx/ManagerNamesTest.java | 1 + .../jmx/MemoryPoolsPresenceTest.java | 1 + .../codecache/jmx/PoolsIndependenceTest.java | 1 + .../compiler/codegen/6823354/Test6823354.java | 1 + .../compilercontrol/InlineMatcherTest.java | 1 + .../commandfile/CompileOnlyTest.java | 1 + .../commandfile/ExcludeTest.java | 1 + .../compilercontrol/commandfile/LogTest.java | 1 + .../commandfile/PrintTest.java | 1 + .../commands/CompileOnlyTest.java | 1 + .../compilercontrol/commands/ExcludeTest.java | 1 + .../compilercontrol/commands/LogTest.java | 1 + .../compilercontrol/commands/PrintTest.java | 1 + .../directives/CompileOnlyTest.java | 1 + .../directives/ExcludeTest.java | 1 + .../compilercontrol/directives/LogTest.java | 1 + .../compilercontrol/directives/PrintTest.java | 1 + .../jcmd/AddAndRemoveTest.java | 1 + .../jcmd/AddCompileOnlyTest.java | 1 + .../compilercontrol/jcmd/AddExcludeTest.java | 1 + .../compilercontrol/jcmd/AddLogTest.java | 1 + .../jcmd/AddPrintAssemblyTest.java | 1 + .../jcmd/ClearDirectivesFileStackTest.java | 1 + .../jcmd/ClearDirectivesStackTest.java | 1 + .../jcmd/PrintDirectivesTest.java | 1 + .../jcmd/StressAddMultiThreadedTest.java | 1 + .../matcher/MethodMatcherTest.java | 1 + .../mixed/RandomCommandsTest.java | 1 + .../mixed/RandomValidCommandsTest.java | 1 + .../parser/DirectiveParserTest.java | 1 + .../parser/DirectiveStressTest.java | 1 + .../eliminateAutobox/UnsignedLoads.java | 1 + ...tUnsafePutAddressNullObjMustNotEscape.java | 8 +++--- .../test/compiler/floatingpoint/TestPow2.java | 1 + .../compiler/inlining/InlineAccessors.java | 1 + .../intrinsics/IntrinsicAvailableTest.java | 1 + .../intrinsics/IntrinsicDisabledTest.java | 1 + .../intrinsics/clone/TestObjectClone.java | 1 + .../MontgomeryMultiplyTest.java | 1 + .../string/TestStringIntrinsicMemoryFlow.java | 1 + .../string/TestStringIntrinsics2.java | 1 + .../intrinsics/unsafe/HeapByteBufferTest.java | 1 + .../TestUnsafeMismatchedArrayFieldAccess.java | 3 ++- .../unsafe/UnsafeGetAddressTest.java | 6 ++--- .../jsr292/CallSiteDepContextTest.java | 3 ++- .../ContinuousCallSiteTargetChange.java | 1 + hotspot/test/compiler/jsr292/InvokerGC.java | 1 + .../test/compiler/jsr292/MHInlineTest.java | 1 + .../jsr292/NonInlinedCall/GCTest.java | 1 + .../jsr292/NonInlinedCall/InvokeTest.java | 1 + .../compiler/jsr292/PollutedTrapCounts.java | 1 + .../compiler/jsr292/VMAnonymousClasses.java | 2 +- .../jvmci/JVM_GetJVMCIRuntimeTest.java | 1 + .../jvmci/SecurityRestrictionsTest.java | 1 + .../compilerToVM/AllocateCompileIdTest.java | 1 + .../compilerToVM/CanInlineMethodTest.java | 1 + .../compilerToVM/CollectCountersTest.java | 1 + .../jvmci/compilerToVM/DebugOutputTest.java | 1 + .../compilerToVM/DisassembleCodeBlobTest.java | 1 + .../DoNotInlineOrCompileTest.java | 1 + .../ExecuteInstalledCodeTest.java | 1 + .../FindUniqueConcreteMethodTest.java | 1 + .../jvmci/compilerToVM/GetBytecodeTest.java | 1 + .../compilerToVM/GetClassInitializerTest.java | 1 + .../compilerToVM/GetConstantPoolTest.java | 3 ++- .../compilerToVM/GetExceptionTableTest.java | 1 + .../compilerToVM/GetImplementorTest.java | 1 + .../compilerToVM/GetLineNumberTableTest.java | 1 + .../GetLocalVariableTableTest.java | 1 + .../GetMaxCallTargetOffsetTest.java | 1 + .../compilerToVM/GetNextStackFrameTest.java | 1 + .../GetResolvedJavaMethodAtSlotTest.java | 1 + .../GetResolvedJavaMethodTest.java | 3 ++- .../compilerToVM/GetResolvedJavaTypeTest.java | 3 ++- .../GetStackTraceElementTest.java | 1 + .../jvmci/compilerToVM/GetSymbolTest.java | 1 + .../GetVtableIndexForInterfaceTest.java | 1 + .../HasCompiledCodeForOSRTest.java | 1 + .../HasFinalizableSubclassTest.java | 1 + .../InitializeConfigurationTest.java | 3 ++- .../InvalidateInstalledCodeTest.java | 1 + .../jvmci/compilerToVM/IsMatureTest.java | 1 + .../JVM_RegisterJVMCINatives.java | 1 + .../jvmci/compilerToVM/LookupTypeTest.java | 1 + .../MaterializeVirtualObjectTest.java | 1 + ...ethodIsIgnoredBySecurityStackWalkTest.java | 1 + .../compilerToVM/ReadUncompressedOopTest.java | 3 ++- .../jvmci/compilerToVM/ReprofileTest.java | 1 + .../compilerToVM/ResolveFieldInPoolTest.java | 2 +- .../jvmci/compilerToVM/ResolveMethodTest.java | 3 ++- .../ShouldDebugNonSafepointsTest.java | 1 + .../compilerToVM/ShouldInlineMethodTest.java | 1 + .../JvmciCreateMetaAccessContextTest.java | 1 + .../events/JvmciNotifyInstallEventTest.java | 1 + .../jvmci/events/JvmciShutdownEventTest.java | 1 + .../jdk/vm/ci/runtime/test/ConstantTest.java | 1 + .../vm/ci/runtime/test/RedefineClassTest.java | 1 + .../test/TestConstantReflectionProvider.java | 1 + .../jdk/vm/ci/runtime/test/TestJavaField.java | 1 + .../vm/ci/runtime/test/TestJavaMethod.java | 1 + .../jdk/vm/ci/runtime/test/TestJavaType.java | 1 + .../runtime/test/TestMetaAccessProvider.java | 1 + .../runtime/test/TestResolvedJavaField.java | 1 + .../runtime/test/TestResolvedJavaMethod.java | 1 + .../ci/runtime/test/TestResolvedJavaType.java | 1 + .../jdk/vm/ci/runtime/test/TypeUniverse.java | 2 +- .../compiler/jvmci/meta/StableFieldTest.java | 1 + .../loopopts/UseCountedLoopSafepoints.java | 1 + .../TestVectorizationWithInvariant.java | 3 ++- .../compiler/onSpinWait/TestOnSpinWait.java | 1 + .../compiler/oracle/GetMethodOptionTest.java | 1 + .../compiler/oracle/MethodMatcherTest.java | 1 + .../rangechecks/TestExplicitRangeChecks.java | 3 ++- .../rtm/locking/TestRTMAbortRatio.java | 2 +- .../rtm/locking/TestRTMAfterNonRTMDeopt.java | 2 +- .../locking/TestRTMDeoptOnLowAbortRatio.java | 2 +- .../rtm/locking/TestRTMLockingThreshold.java | 2 +- .../locking/TestRTMTotalCountIncrRate.java | 2 +- .../compiler/runtime/8010927/Test8010927.java | 2 +- .../compiler/stable/TestStableBoolean.java | 1 + .../test/compiler/stable/TestStableByte.java | 1 + .../test/compiler/stable/TestStableChar.java | 1 + .../compiler/stable/TestStableDouble.java | 1 + .../test/compiler/stable/TestStableFloat.java | 1 + .../test/compiler/stable/TestStableInt.java | 1 + .../test/compiler/stable/TestStableLong.java | 1 + .../stable/TestStableMemoryBarrier.java | 1 + .../compiler/stable/TestStableObject.java | 1 + .../test/compiler/stable/TestStableShort.java | 1 + .../test/compiler/stable/TestStableUByte.java | 1 + .../compiler/stable/TestStableUShort.java | 1 + .../testlibrary/rtm/XAbortProvoker.java | 2 +- .../compiler/tiered/NonTieredLevelsTest.java | 1 + .../compiler/tiered/TieredLevelsTest.java | 1 + .../uncommontrap/8009761/Test8009761.java | 1 + .../unsafe/GetUnsafeObjectG1PreBarrier.java | 2 +- .../unsafe/TestUnsafeLoadControl.java | 3 ++- hotspot/test/compiler/unsafe/UnsafeRaw.java | 27 ++++++++++--------- .../whitebox/AllocationCodeBlobTest.java | 1 + .../whitebox/BlockingCompilation.java | 1 + .../whitebox/ClearMethodStateTest.java | 1 + .../compiler/whitebox/DeoptimizeAllTest.java | 1 + .../whitebox/DeoptimizeFramesTest.java | 1 + .../whitebox/DeoptimizeMethodTest.java | 1 + .../whitebox/DeoptimizeMultipleOSRTest.java | 1 + .../EnqueueMethodForCompilationTest.java | 1 + .../whitebox/ForceNMethodSweepTest.java | 1 + .../whitebox/GetCodeHeapEntriesTest.java | 1 + .../compiler/whitebox/GetNMethodTest.java | 1 + .../whitebox/LockCompilationTest.java | 1 + .../whitebox/MakeMethodNotCompilableTest.java | 1 + .../whitebox/SetDontInlineMethodTest.java | 1 + .../whitebox/SetForceInlineMethodTest.java | 1 + hotspot/test/gc/CondCardMark/Basic.java | 1 + hotspot/test/gc/TestDisableExplicitGC.java | 1 + hotspot/test/gc/TestSmallHeap.java | 1 + .../gc/arguments/TestDynMaxHeapFreeRatio.java | 1 + .../gc/arguments/TestDynMinHeapFreeRatio.java | 1 + .../gc/arguments/TestG1HeapRegionSize.java | 1 + .../TestMaxMinHeapFreeRatioFlags.java | 4 ++- .../gc/arguments/TestSurvivorRatioFlag.java | 1 + .../TestTargetSurvivorRatioFlag.java | 3 ++- .../TestVerifyBeforeAndAfterGCFlags.java | 1 + .../TestDynamicNumberOfGCThreads.java | 1 + .../TestHumongousAllocNearlyFullRegion.java | 1 + .../test/gc/g1/TestHumongousShrinkHeap.java | 1 + .../gc/g1/TestLargePageUseForAuxMemory.java | 1 + hotspot/test/gc/g1/TestPLABOutput.java | 1 + .../test/gc/g1/TestShrinkAuxiliaryData.java | 3 ++- .../g1/humongousObjects/TestHeapCounters.java | 1 + .../TestHumongousClassLoader.java | 1 + .../TestHumongousMovement.java | 1 + .../TestHumongousNonArrayAllocation.java | 1 + .../TestHumongousThreshold.java | 1 + .../humongousObjects/TestObjectCollected.java | 1 + hotspot/test/gc/g1/ihop/TestIHOPErgo.java | 1 + hotspot/test/gc/g1/ihop/TestIHOPStatic.java | 1 + hotspot/test/gc/g1/mixedgc/TestLogging.java | 1 + .../gc/g1/plab/TestPLABEvacuationFailure.java | 1 + .../test/gc/g1/plab/TestPLABPromotion.java | 1 + hotspot/test/gc/g1/plab/TestPLABResize.java | 1 + .../TestMetaspaceInitialization.java | 1 + .../test/gc/parallel/TestDynShrinkHeap.java | 1 + .../parallel/TestPrintGCDetailsVerbose.java | 1 + .../gc/stress/TestMultiThreadStressRSet.java | 1 + .../SurvivorAlignmentTestMain.java | 2 +- .../8026365/InvokeSpecialAnonTest.java | 2 +- .../BoolReturn/NativeSmallIntCallsTest.java | 1 + .../runtime/ClassUnload/KeepAliveClass.java | 1 + .../ClassUnload/KeepAliveClassLoader.java | 1 + .../runtime/ClassUnload/KeepAliveObject.java | 1 + .../ClassUnload/KeepAliveSoftReference.java | 1 + .../test/runtime/ClassUnload/UnloadTest.java | 1 + .../CommandLine/ObsoleteFlagErrorMessage.java | 1 + .../TestLongUnrecognizedVMOption.java | 1 + .../runtime/CommandLine/VMAliasOptions.java | 1 + .../CommandLine/VMDeprecatedOptions.java | 1 + .../VMOptionsFile/TestVMOptionsFile.java | 1 + .../ErrorHandling/CreateCoredumpOnCrash.java | 4 +-- .../runtime/ErrorHandling/ErrorHandler.java | 1 + .../ErrorHandling/ProblematicFrameTest.java | 2 +- .../SafeFetchInErrorHandlingTest.java | 1 + .../TestCrashOnOutOfMemoryError.java | 1 + .../TestExitOnOutOfMemoryError.java | 1 + .../runtime/ErrorHandling/TestOnError.java | 1 + .../ErrorHandling/TestOnOutOfMemoryError.java | 1 + .../runtime/Metaspace/FragmentMetaspace.java | 1 + .../test/runtime/NMT/ChangeTrackingLevel.java | 1 + .../runtime/NMT/MallocSiteHashOverflow.java | 1 + .../test/runtime/NMT/PrintNMTStatistics.java | 1 + .../runtime/NMT/ReleaseCommittedMemory.java | 1 + .../RedefineTests/RedefineAnnotations.java | 1 + .../RedefineTests/RedefineFinalizer.java | 1 + .../RedefineTests/RedefineRunningMethods.java | 1 + .../RedefineRunningMethodsWithBacktrace.java | 1 + ...ineRunningMethodsWithResolutionErrors.java | 1 + .../ReservedStack/ReservedStackTest.java | 1 + .../test/runtime/SameObject/SameObject.java | 1 + hotspot/test/runtime/Thread/Fibonacci.java | 1 + .../ThreadSignalMask/ThreadSignalMask.java | 1 + .../test/runtime/Throwable/TestThrowable.java | 1 + .../ThrowableIntrospectionSegfault.java | 1 + .../test/runtime/Unsafe/AllocateInstance.java | 2 +- .../test/runtime/Unsafe/AllocateMemory.java | 2 +- hotspot/test/runtime/Unsafe/CopyMemory.java | 2 +- hotspot/test/runtime/Unsafe/DefineClass.java | 2 +- hotspot/test/runtime/Unsafe/FieldOffset.java | 2 +- hotspot/test/runtime/Unsafe/GetField.java | 2 +- .../Unsafe/GetKlassPointerGetJavaMirror.java | 2 +- .../test/runtime/Unsafe/GetPutAddress.java | 2 +- .../test/runtime/Unsafe/GetPutBoolean.java | 2 +- hotspot/test/runtime/Unsafe/GetPutByte.java | 2 +- hotspot/test/runtime/Unsafe/GetPutChar.java | 2 +- hotspot/test/runtime/Unsafe/GetPutDouble.java | 2 +- hotspot/test/runtime/Unsafe/GetPutFloat.java | 2 +- hotspot/test/runtime/Unsafe/GetPutInt.java | 2 +- hotspot/test/runtime/Unsafe/GetPutLong.java | 2 +- hotspot/test/runtime/Unsafe/GetPutObject.java | 2 +- hotspot/test/runtime/Unsafe/GetPutShort.java | 2 +- .../runtime/Unsafe/GetUncompressedObject.java | 2 +- hotspot/test/runtime/Unsafe/GetUnsafe.java | 2 +- hotspot/test/runtime/Unsafe/PageSize.java | 2 +- .../runtime/Unsafe/PrimitiveHostClass.java | 2 +- hotspot/test/runtime/Unsafe/RangeCheck.java | 3 ++- hotspot/test/runtime/Unsafe/Reallocate.java | 2 +- hotspot/test/runtime/Unsafe/SetMemory.java | 2 +- .../test/runtime/Unsafe/ThrowException.java | 2 +- hotspot/test/runtime/contended/Basic.java | 3 ++- .../test/runtime/contended/DefaultValue.java | 3 ++- .../test/runtime/contended/HasNonStatic.java | 3 ++- .../test/runtime/contended/Inheritance1.java | 3 ++- hotspot/test/runtime/contended/OopMaps.java | 1 - .../runtime/contended/OopMapsSameGroup.java | 1 - .../runtime/getSysPackage/GetSysPkgTest.java | 1 + hotspot/test/runtime/interned/SanityTest.java | 1 + .../Testlibadimalloc.java | 1 + .../logging/ClassInitializationTest.java | 1 + .../runtime/logging/ClassLoadUnloadTest.java | 1 + .../runtime/logging/ClassResolutionTest.java | 1 + .../logging/LoaderConstraintsTest.java | 1 + .../runtime/logging/MonitorMismatchTest.java | 1 + .../ProtectionDomainVerificationTest.java | 1 + .../logging/RemovedDevelopFlagsTest.java | 1 + .../test/runtime/memory/ReadVMPageSize.java | 1 + .../memory/StressVirtualSpaceResize.java | 1 + .../modules/AccessCheck/CheckRead.java | 1 + .../modules/AccessCheck/DiffCL_CheckRead.java | 1 + .../AccessCheck/DiffCL_ExpQualOther.java | 1 + .../AccessCheck/DiffCL_ExpQualToM1.java | 1 + .../modules/AccessCheck/DiffCL_ExpUnqual.java | 1 + .../modules/AccessCheck/DiffCL_PkgNotExp.java | 1 + .../modules/AccessCheck/DiffCL_Umod.java | 1 + .../modules/AccessCheck/DiffCL_UmodUpkg.java | 1 + .../modules/AccessCheck/ExpQualOther.java | 1 + .../modules/AccessCheck/ExpQualToM1.java | 1 + .../modules/AccessCheck/ExpUnqual.java | 1 + .../modules/AccessCheck/ExportAllUnnamed.java | 1 + .../modules/AccessCheck/PkgNotExp.java | 1 + .../runtime/modules/AccessCheck/Umod.java | 1 + .../AccessCheck/UmodDiffCL_ExpQualOther.java | 1 + .../AccessCheck/UmodDiffCL_ExpUnqual.java | 1 + .../AccessCheck/UmodDiffCL_PkgNotExp.java | 1 + .../runtime/modules/AccessCheck/UmodUPkg.java | 1 + .../UmodUpkgDiffCL_ExpQualOther.java | 1 + .../AccessCheck/UmodUpkgDiffCL_NotExp.java | 1 + .../AccessCheck/UmodUpkg_ExpQualOther.java | 1 + .../modules/AccessCheck/UmodUpkg_NotExp.java | 1 + .../AccessCheck/Umod_ExpQualOther.java | 1 + .../modules/AccessCheck/Umod_ExpUnqual.java | 1 + .../modules/AccessCheck/Umod_PkgNotExp.java | 1 + .../modules/AccessCheckAllUnnamed.java | 1 + .../test/runtime/modules/AccessCheckExp.java | 1 + .../runtime/modules/AccessCheckJavaBase.java | 1 + .../test/runtime/modules/AccessCheckRead.java | 1 + .../runtime/modules/AccessCheckSuper.java | 1 + .../runtime/modules/AccessCheckUnnamed.java | 1 + .../runtime/modules/AccessCheckWorks.java | 1 + hotspot/test/runtime/modules/ExportTwice.java | 1 + .../JVMAddModuleExportToAllUnnamed.java | 1 + .../runtime/modules/JVMAddModuleExports.java | 1 + .../modules/JVMAddModuleExportsToAll.java | 1 + .../runtime/modules/JVMAddModulePackage.java | 1 + .../runtime/modules/JVMAddReadsModule.java | 1 + .../runtime/modules/JVMCanReadModule.java | 1 + .../test/runtime/modules/JVMDefineModule.java | 1 + .../modules/JVMGetModuleByPkgName.java | 1 + .../modules/JVMIsExportedToModule.java | 1 + .../modules/LoadUnloadModuleStress.java | 1 + .../runtime/modules/Xpatch/Xpatch2Dirs.java | 1 + .../runtime/modules/Xpatch/XpatchTest.java | 1 + .../runtime/modules/Xpatch/XpatchTraceCL.java | 1 + .../test/runtime/os/AvailableProcessors.java | 1 + .../test/runtime/verifier/TraceClassRes.java | 1 + .../test/runtime/whitebox/WBStackSize.java | 1 + .../sanity/MismatchedWhiteBox/WhiteBox.java | 1 + hotspot/test/sanity/WBApi.java | 1 + hotspot/test/serviceability/ParserTest.java | 1 + .../attach/AttachWithStalePidFile.java | 1 + .../dcmd/gc/FinalizerInfoTest.java | 1 + .../serviceability/dcmd/gc/HeapInfoTest.java | 1 + .../dcmd/jvmti/DataDumpDcmdTest.java | 1 + .../serviceability/dcmd/vm/SetVMFlagTest.java | 1 + .../logging/TestBasicLogOutput.java | 1 + .../logging/TestMultipleXlogArgs.java | 1 + .../logging/TestQuotedLogOutputs.java | 1 + .../sa/DeadlockDetectionTest.java | 1 + .../sa/TestClassLoaderStats.java | 1 + .../serviceability/sa/TestStackTrace.java | 1 + .../threads/TestFalseDeadLock.java | 1 + .../tmtools/jstack/DaemonThreadTest.java | 1 + .../tmtools/jstack/JstackThreadTest.java | 1 + .../tmtools/jstack/SpreadLockTest.java | 1 + .../tmtools/jstack/ThreadNamesTest.java | 1 + .../tmtools/jstack/TraveledLockTest.java | 1 + .../tmtools/jstack/WaitNotifyThreadTest.java | 1 + .../tmtools/jstat/GcCapacityTest.java | 1 + .../tmtools/jstat/GcCauseTest01.java | 1 + .../tmtools/jstat/GcCauseTest02.java | 1 + .../tmtools/jstat/GcCauseTest03.java | 1 + .../tmtools/jstat/GcNewTest.java | 1 + .../tmtools/jstat/GcTest01.java | 1 + .../tmtools/jstat/GcTest02.java | 1 + .../test/testlibrary/jdk/test/lib/Utils.java | 2 +- .../test/testlibrary_tests/AssertsTest.java | 1 + .../testlibrary_tests/RedefineClassTest.java | 1 + .../whitebox/BlobSanityTest.java | 1 + .../whitebox/vm_flags/DoubleTest.java | 1 + .../whitebox/vm_flags/IntxTest.java | 1 + .../whitebox/vm_flags/StringTest.java | 1 + .../whitebox/vm_flags/Uint64Test.java | 1 + 403 files changed, 444 insertions(+), 91 deletions(-) diff --git a/hotspot/test/compiler/c2/5057225/Test5057225.java b/hotspot/test/compiler/c2/5057225/Test5057225.java index 106d390b850..7cf64f90005 100644 --- a/hotspot/test/compiler/c2/5057225/Test5057225.java +++ b/hotspot/test/compiler/c2/5057225/Test5057225.java @@ -25,6 +25,7 @@ * @test * @bug 5057225 * @summary Remove useless I2L conversions + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm -Xcomp -XX:CompileOnly=Test5057225.doload Test5057225 */ diff --git a/hotspot/test/compiler/c2/6603011/Test.java b/hotspot/test/compiler/c2/6603011/Test.java index bc457073517..39c041935c6 100644 --- a/hotspot/test/compiler/c2/6603011/Test.java +++ b/hotspot/test/compiler/c2/6603011/Test.java @@ -25,6 +25,7 @@ * @test * @bug 6603011 * @summary long/int division by constant + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm -Xcomp -Xbatch -XX:-Inline Test */ diff --git a/hotspot/test/compiler/c2/6800154/Test6800154.java b/hotspot/test/compiler/c2/6800154/Test6800154.java index 05ad662d69d..b43c1556156 100644 --- a/hotspot/test/compiler/c2/6800154/Test6800154.java +++ b/hotspot/test/compiler/c2/6800154/Test6800154.java @@ -25,6 +25,7 @@ * @test * @bug 6800154 * @summary Add comments to long_by_long_mulhi() for better understandability + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm -Xcomp -XX:CompileOnly=Test6800154.divcomp Test6800154 */ diff --git a/hotspot/test/compiler/c2/6805724/Test6805724.java b/hotspot/test/compiler/c2/6805724/Test6805724.java index 922b297dbd8..afa20d278cc 100644 --- a/hotspot/test/compiler/c2/6805724/Test6805724.java +++ b/hotspot/test/compiler/c2/6805724/Test6805724.java @@ -26,6 +26,7 @@ * @bug 6805724 * @summary ModLNode::Ideal() generates functionally incorrect graph * when divisor is any (2^k-1) constant. + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm -Xcomp -XX:CompileOnly=Test6805724.fcomp Test6805724 */ diff --git a/hotspot/test/compiler/c2/6968348/Test6968348.java b/hotspot/test/compiler/c2/6968348/Test6968348.java index b13b7e638cd..432f45fad3e 100644 --- a/hotspot/test/compiler/c2/6968348/Test6968348.java +++ b/hotspot/test/compiler/c2/6968348/Test6968348.java @@ -31,7 +31,7 @@ * @run main Test6968348 */ -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.lang.reflect.*; public class Test6968348 { @@ -40,7 +40,7 @@ public class Test6968348 { static int array_long_base_offset; public static void main(String[] args) throws Exception { - Class c = Test6968348.class.getClassLoader().loadClass("sun.misc.Unsafe"); + Class c = Test6968348.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe"); Field f = c.getDeclaredField("theUnsafe"); f.setAccessible(true); unsafe = (Unsafe)f.get(c); diff --git a/hotspot/test/compiler/c2/7190310/Test7190310_unsafe.java b/hotspot/test/compiler/c2/7190310/Test7190310_unsafe.java index 08d6848df4d..de48a6e4627 100644 --- a/hotspot/test/compiler/c2/7190310/Test7190310_unsafe.java +++ b/hotspot/test/compiler/c2/7190310/Test7190310_unsafe.java @@ -32,7 +32,7 @@ import java.lang.ref.*; import java.lang.reflect.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class Test7190310_unsafe { @@ -48,7 +48,7 @@ public class Test7190310_unsafe { private TestObject obj; public static void main(String[] args) throws Exception { - Class c = Test7190310_unsafe.class.getClassLoader().loadClass("sun.misc.Unsafe"); + Class c = Test7190310_unsafe.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe"); Field f = c.getDeclaredField("theUnsafe"); f.setAccessible(true); Unsafe unsafe = (Unsafe)f.get(c); diff --git a/hotspot/test/compiler/c2/8004867/TestIntUnsafeCAS.java b/hotspot/test/compiler/c2/8004867/TestIntUnsafeCAS.java index fc8ab3bbdaa..a405f5608cf 100644 --- a/hotspot/test/compiler/c2/8004867/TestIntUnsafeCAS.java +++ b/hotspot/test/compiler/c2/8004867/TestIntUnsafeCAS.java @@ -32,7 +32,7 @@ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeCAS */ -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.lang.reflect.*; public class TestIntUnsafeCAS { @@ -47,7 +47,7 @@ public class TestIntUnsafeCAS { private static final int BASE; static { try { - Class c = TestIntUnsafeCAS.class.getClassLoader().loadClass("sun.misc.Unsafe"); + Class c = TestIntUnsafeCAS.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe"); Field f = c.getDeclaredField("theUnsafe"); f.setAccessible(true); unsafe = (Unsafe)f.get(c); diff --git a/hotspot/test/compiler/c2/8004867/TestIntUnsafeVolatile.java b/hotspot/test/compiler/c2/8004867/TestIntUnsafeVolatile.java index 3c8ddf37046..6cbab7a42c3 100644 --- a/hotspot/test/compiler/c2/8004867/TestIntUnsafeVolatile.java +++ b/hotspot/test/compiler/c2/8004867/TestIntUnsafeVolatile.java @@ -32,7 +32,7 @@ * @run main/othervm/timeout=300 -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:-TieredCompilation -XX:+OptimizeFill TestIntUnsafeVolatile */ -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.lang.reflect.*; public class TestIntUnsafeVolatile { @@ -47,7 +47,7 @@ public class TestIntUnsafeVolatile { private static final int BASE; static { try { - Class c = TestIntUnsafeVolatile.class.getClassLoader().loadClass("sun.misc.Unsafe"); + Class c = TestIntUnsafeVolatile.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe"); Field f = c.getDeclaredField("theUnsafe"); f.setAccessible(true); unsafe = (Unsafe)f.get(c); diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2CompiledTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2CompiledTest.java index 12c14cb2ee5..3124d3deb4a 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2CompiledTest.java @@ -24,6 +24,7 @@ /* * @test * @library /test/lib /testlibrary / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * @build compiler.calls.common.InvokeDynamic * @build compiler.calls.common.InvokeDynamicPatcher diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2InterpretedTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2InterpretedTest.java index 097cf9d9349..49162205a31 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2InterpretedTest.java @@ -24,6 +24,7 @@ /* * @test * @library /test/lib /testlibrary / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * @build compiler.calls.common.InvokeDynamic * @build compiler.calls.common.InvokeDynamicPatcher diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2NativeTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2NativeTest.java index 98baacb6c86..37216320574 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2NativeTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeDynamic2NativeTest.java @@ -24,6 +24,7 @@ /* * @test * @library /test/lib /testlibrary / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * @build compiler.calls.common.InvokeDynamic * @build compiler.calls.common.InvokeDynamicPatcher diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2CompiledTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2CompiledTest.java index fec0fda8aee..34f86cda1af 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2CompiledTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeInterface * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2InterpretedTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2InterpretedTest.java index 2baf4e7caa8..fb3021022de 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2InterpretedTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeInterface * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2NativeTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2NativeTest.java index ec394a10f93..a930528651b 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2NativeTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeInterface2NativeTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeInterface * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2CompiledTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2CompiledTest.java index 5d659f5bbef..39648e75aad 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2CompiledTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeSpecial * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2InterpretedTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2InterpretedTest.java index 1a6c6c9ec17..25cac6bb36c 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2InterpretedTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeSpecial * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2NativeTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2NativeTest.java index e1b64749d22..e30115a36e8 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2NativeTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeSpecial2NativeTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeSpecial * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2CompiledTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2CompiledTest.java index f31ef6ba9ff..8cda5e0af26 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2CompiledTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeStatic * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2InterpretedTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2InterpretedTest.java index 8a8b8565a05..1d998e09274 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2InterpretedTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeStatic * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2NativeTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2NativeTest.java index 955a727f00b..a0c8009b637 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2NativeTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeStatic2NativeTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeStatic * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2CompiledTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2CompiledTest.java index 53fb39ac117..6ac0e2ba09f 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2CompiledTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeVirtual * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2InterpretedTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2InterpretedTest.java index d875be780df..9f03a2c62f8 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2InterpretedTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeVirtual * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2NativeTest.java b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2NativeTest.java index 0f69bb50cf4..93643d6974b 100644 --- a/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2NativeTest.java +++ b/hotspot/test/compiler/calls/fromCompiled/CompiledInvokeVirtual2NativeTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeVirtual * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2CompiledTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2CompiledTest.java index ffc4fa94e0e..17d151253a6 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2CompiledTest.java @@ -24,6 +24,7 @@ /* * @test * @library /test/lib /testlibrary / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * @build compiler.calls.common.InvokeDynamic * @build compiler.calls.common.InvokeDynamicPatcher diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2InterpretedTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2InterpretedTest.java index 9579fc2e1ce..5988ac62599 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2InterpretedTest.java @@ -24,6 +24,7 @@ /* * @test * @library /test/lib /testlibrary / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * @build compiler.calls.common.InvokeDynamic * @build compiler.calls.common.InvokeDynamicPatcher diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2NativeTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2NativeTest.java index 78f2f556fa4..7f0015a4e9d 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2NativeTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeDynamic2NativeTest.java @@ -24,6 +24,7 @@ /* * @test * @library /test/lib /testlibrary / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * @build compiler.calls.common.InvokeDynamic * @build compiler.calls.common.InvokeDynamicPatcher diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2CompiledTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2CompiledTest.java index 84b4e5016ca..ea458db3a97 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2CompiledTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeInterface * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2InterpretedTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2InterpretedTest.java index a4f204f1d34..ed150e4f9f2 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2InterpretedTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeInterface * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2NativeTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2NativeTest.java index ca0044524e0..8adc7a6c306 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2NativeTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeInterface2NativeTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeInterface * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2CompiledTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2CompiledTest.java index d47585abf29..ad0b12f1d7f 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2CompiledTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeSpecial * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2InterpretedTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2InterpretedTest.java index 9c047fa9502..324ad867ad3 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2InterpretedTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeSpecial * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2NativeTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2NativeTest.java index 768d5eb9dae..e34cca01ab3 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2NativeTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeSpecial2NativeTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeSpecial * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2CompiledTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2CompiledTest.java index de4f6c2b995..96501a1ed15 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2CompiledTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeStatic * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2InterpretedTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2InterpretedTest.java index 06339099281..8efd93d874b 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2InterpretedTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeStatic * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2NativeTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2NativeTest.java index 2a7deda7655..0bcbb379842 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2NativeTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeStatic2NativeTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeStatic * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2CompiledTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2CompiledTest.java index fb7a645ec8d..eefe4e6debe 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2CompiledTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeVirtual * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2InterpretedTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2InterpretedTest.java index c4eecef1d80..d44e140f8e5 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2InterpretedTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeVirtual * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2NativeTest.java b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2NativeTest.java index 2ac9911b4d3..201199341e1 100644 --- a/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2NativeTest.java +++ b/hotspot/test/compiler/calls/fromInterpreted/InterpretedInvokeVirtual2NativeTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeVirtual * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2CompiledTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2CompiledTest.java index 1a303bdf088..86a0784af56 100644 --- a/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2CompiledTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeSpecial * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2InterpretedTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2InterpretedTest.java index 517422adf6e..83520cef1c7 100644 --- a/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2InterpretedTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeSpecial * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2NativeTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2NativeTest.java index 9b3d7ad166a..f9b3ce5b8b4 100644 --- a/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2NativeTest.java +++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeSpecial2NativeTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeSpecial * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2CompiledTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2CompiledTest.java index 546ed827801..71335713aaa 100644 --- a/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2CompiledTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeStatic * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2InterpretedTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2InterpretedTest.java index 5e480d82f36..541b3645a1c 100644 --- a/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2InterpretedTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeStatic * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2NativeTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2NativeTest.java index 9ace6ea67b5..34ad481e521 100644 --- a/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2NativeTest.java +++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeStatic2NativeTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeStatic * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2CompiledTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2CompiledTest.java index 56059718e81..4f86421b607 100644 --- a/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2CompiledTest.java +++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2CompiledTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeVirtual * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2InterpretedTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2InterpretedTest.java index 09777265bc3..c0d3b77110e 100644 --- a/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2InterpretedTest.java +++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2InterpretedTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeVirtual * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2NativeTest.java b/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2NativeTest.java index d4ddd119fc3..b83b9330e5e 100644 --- a/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2NativeTest.java +++ b/hotspot/test/compiler/calls/fromNative/NativeInvokeVirtual2NativeTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary / * @build compiler.calls.common.InvokeVirtual * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java b/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java index 3745d73a008..65b3d5879e9 100644 --- a/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java +++ b/hotspot/test/compiler/classUnloading/anonymousClass/TestAnonymousClassUnloading.java @@ -22,7 +22,7 @@ */ import sun.hotspot.WhiteBox; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.io.IOException; import java.lang.reflect.Method; diff --git a/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java b/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java index a824ec2bdb2..d1415465b1a 100644 --- a/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java +++ b/hotspot/test/compiler/classUnloading/methodUnloading/TestMethodUnloading.java @@ -31,6 +31,7 @@ import java.net.URLClassLoader; * @test MethodUnloadingTest * @bug 8029443 * @summary "Tests the unloading of methods to to class unloading" + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build TestMethodUnloading * @build WorkerClass diff --git a/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java b/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java index 85537e8d783..31e8d2bcc30 100644 --- a/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java +++ b/hotspot/test/compiler/codecache/OverflowCodeCacheTest.java @@ -35,6 +35,7 @@ import jdk.test.lib.Asserts; * @test OverflowCodeCacheTest * @bug 8059550 * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management * @build OverflowCodeCacheTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java b/hotspot/test/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java index b8408ea3f8e..57fc8e0f292 100644 --- a/hotspot/test/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java +++ b/hotspot/test/compiler/codecache/dtrace/SegmentedCodeCacheDtraceTest.java @@ -48,6 +48,7 @@ import java.util.stream.Collectors; * @test SegmentedCodeCacheDtraceTest * @bug 8015774 * @requires os.family=="solaris" + * @modules java.base/jdk.internal.misc * @library /testlibrary / /test/lib * @build SegmentedCodeCacheDtraceTestWorker * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/codecache/jmx/BeanTypeTest.java b/hotspot/test/compiler/codecache/jmx/BeanTypeTest.java index bea23c6a52a..f7838e50851 100644 --- a/hotspot/test/compiler/codecache/jmx/BeanTypeTest.java +++ b/hotspot/test/compiler/codecache/jmx/BeanTypeTest.java @@ -28,6 +28,7 @@ import sun.hotspot.code.BlobType; /** * @test BeanTypeTest * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management * @build BeanTypeTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/codecache/jmx/CodeHeapBeanPresenceTest.java b/hotspot/test/compiler/codecache/jmx/CodeHeapBeanPresenceTest.java index faef9a2ead7..6f99c25f952 100644 --- a/hotspot/test/compiler/codecache/jmx/CodeHeapBeanPresenceTest.java +++ b/hotspot/test/compiler/codecache/jmx/CodeHeapBeanPresenceTest.java @@ -28,6 +28,7 @@ import sun.hotspot.code.BlobType; /** * @test CodeHeapBeanPresenceTest * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management * @build CodeHeapBeanPresenceTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/codecache/jmx/ManagerNamesTest.java b/hotspot/test/compiler/codecache/jmx/ManagerNamesTest.java index 4b3b597ec06..45107f050b9 100644 --- a/hotspot/test/compiler/codecache/jmx/ManagerNamesTest.java +++ b/hotspot/test/compiler/codecache/jmx/ManagerNamesTest.java @@ -28,6 +28,7 @@ import sun.hotspot.code.BlobType; /** * @test ManagerNamesTest * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management * @build ManagerNamesTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/codecache/jmx/MemoryPoolsPresenceTest.java b/hotspot/test/compiler/codecache/jmx/MemoryPoolsPresenceTest.java index 22eecc8adc6..a3a0308bd9a 100644 --- a/hotspot/test/compiler/codecache/jmx/MemoryPoolsPresenceTest.java +++ b/hotspot/test/compiler/codecache/jmx/MemoryPoolsPresenceTest.java @@ -33,6 +33,7 @@ import sun.hotspot.code.BlobType; /** * @test MemoryPoolsPresenceTest * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management * @build MemoryPoolsPresenceTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java b/hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java index 69f10212a71..97b21431caf 100644 --- a/hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java +++ b/hotspot/test/compiler/codecache/jmx/PoolsIndependenceTest.java @@ -37,6 +37,7 @@ import sun.hotspot.code.BlobType; /* * @test PoolsIndependenceTest + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build PoolsIndependenceTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/codegen/6823354/Test6823354.java b/hotspot/test/compiler/codegen/6823354/Test6823354.java index 6f9bc0203be..1ba60e1a3b6 100644 --- a/hotspot/test/compiler/codegen/6823354/Test6823354.java +++ b/hotspot/test/compiler/codegen/6823354/Test6823354.java @@ -25,6 +25,7 @@ * @test * @bug 6823354 * @summary These methods can be instrinsified by using bit scan, bit test, and population count instructions. + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm -Xcomp -XX:CompileOnly=Test6823354.lzcomp,Test6823354.tzcomp,.dolzcomp,.dotzcomp Test6823354 */ diff --git a/hotspot/test/compiler/compilercontrol/InlineMatcherTest.java b/hotspot/test/compiler/compilercontrol/InlineMatcherTest.java index 3dc057c448d..afba82b1d7f 100644 --- a/hotspot/test/compiler/compilercontrol/InlineMatcherTest.java +++ b/hotspot/test/compiler/compilercontrol/InlineMatcherTest.java @@ -24,6 +24,7 @@ /* * @test InlineMatcherTest * @bug 8074095 + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/commandfile/CompileOnlyTest.java b/hotspot/test/compiler/compilercontrol/commandfile/CompileOnlyTest.java index 2541d9d0b83..925c1c7ef5c 100644 --- a/hotspot/test/compiler/compilercontrol/commandfile/CompileOnlyTest.java +++ b/hotspot/test/compiler/compilercontrol/commandfile/CompileOnlyTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests CompileCommand=compileonly + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.commandfile.CompileOnlyTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/commandfile/ExcludeTest.java b/hotspot/test/compiler/compilercontrol/commandfile/ExcludeTest.java index 77c2a2e0748..98b3c715276 100644 --- a/hotspot/test/compiler/compilercontrol/commandfile/ExcludeTest.java +++ b/hotspot/test/compiler/compilercontrol/commandfile/ExcludeTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests CompileCommand=exclude + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.commandfile.ExcludeTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/commandfile/LogTest.java b/hotspot/test/compiler/compilercontrol/commandfile/LogTest.java index ce45d52b11c..18dd2a7dbdd 100644 --- a/hotspot/test/compiler/compilercontrol/commandfile/LogTest.java +++ b/hotspot/test/compiler/compilercontrol/commandfile/LogTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests CompileCommand=log + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.commandfile.LogTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java b/hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java index 97cf7e861d1..f47b9a43bae 100644 --- a/hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java +++ b/hotspot/test/compiler/compilercontrol/commandfile/PrintTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests CompileCommand=print + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.commandfile.PrintTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/commands/CompileOnlyTest.java b/hotspot/test/compiler/compilercontrol/commands/CompileOnlyTest.java index 7a1b0c1da40..d4e57e94e40 100644 --- a/hotspot/test/compiler/compilercontrol/commands/CompileOnlyTest.java +++ b/hotspot/test/compiler/compilercontrol/commands/CompileOnlyTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests CompileCommand=compileonly + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.commands.CompileOnlyTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/commands/ExcludeTest.java b/hotspot/test/compiler/compilercontrol/commands/ExcludeTest.java index b84befca8c2..f8311e77c70 100644 --- a/hotspot/test/compiler/compilercontrol/commands/ExcludeTest.java +++ b/hotspot/test/compiler/compilercontrol/commands/ExcludeTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests CompileCommand=exclude + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.commands.ExcludeTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/commands/LogTest.java b/hotspot/test/compiler/compilercontrol/commands/LogTest.java index 4ffebe41a32..7f9db796be6 100644 --- a/hotspot/test/compiler/compilercontrol/commands/LogTest.java +++ b/hotspot/test/compiler/compilercontrol/commands/LogTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests CompileCommand=log + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.commands.LogTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/commands/PrintTest.java b/hotspot/test/compiler/compilercontrol/commands/PrintTest.java index 2e414494c1e..bbe9efec173 100644 --- a/hotspot/test/compiler/compilercontrol/commands/PrintTest.java +++ b/hotspot/test/compiler/compilercontrol/commands/PrintTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests CompileCommand=print + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.commands.PrintTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/directives/CompileOnlyTest.java b/hotspot/test/compiler/compilercontrol/directives/CompileOnlyTest.java index 439e5e9505d..e351c42fd07 100644 --- a/hotspot/test/compiler/compilercontrol/directives/CompileOnlyTest.java +++ b/hotspot/test/compiler/compilercontrol/directives/CompileOnlyTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests directives to be able to compile only specified methods + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.directives.CompileOnlyTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/directives/ExcludeTest.java b/hotspot/test/compiler/compilercontrol/directives/ExcludeTest.java index 0569cdfe323..5799fe20e0e 100644 --- a/hotspot/test/compiler/compilercontrol/directives/ExcludeTest.java +++ b/hotspot/test/compiler/compilercontrol/directives/ExcludeTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests directives to be able to exclude methods from compilation + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.directives.ExcludeTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/directives/LogTest.java b/hotspot/test/compiler/compilercontrol/directives/LogTest.java index 1f84d4aea5e..0d5f9cc5dd1 100644 --- a/hotspot/test/compiler/compilercontrol/directives/LogTest.java +++ b/hotspot/test/compiler/compilercontrol/directives/LogTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests directives to be able to turn on LogCompilation + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.directives.LogTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/directives/PrintTest.java b/hotspot/test/compiler/compilercontrol/directives/PrintTest.java index 7c0009f26bb..ac45d43a768 100644 --- a/hotspot/test/compiler/compilercontrol/directives/PrintTest.java +++ b/hotspot/test/compiler/compilercontrol/directives/PrintTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests directives to be able to turn on print_assembly + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.directives.PrintTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/jcmd/AddAndRemoveTest.java b/hotspot/test/compiler/compilercontrol/jcmd/AddAndRemoveTest.java index 372b50a72b6..ec296cea78a 100644 --- a/hotspot/test/compiler/compilercontrol/jcmd/AddAndRemoveTest.java +++ b/hotspot/test/compiler/compilercontrol/jcmd/AddAndRemoveTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests directives to be able to add and remove directives + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.jcmd.AddAndRemoveTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/jcmd/AddCompileOnlyTest.java b/hotspot/test/compiler/compilercontrol/jcmd/AddCompileOnlyTest.java index 5b2a9e26843..70963733f45 100644 --- a/hotspot/test/compiler/compilercontrol/jcmd/AddCompileOnlyTest.java +++ b/hotspot/test/compiler/compilercontrol/jcmd/AddCompileOnlyTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests jcmd to be able to add a directive to compile only specified methods + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.jcmd.AddCompileOnlyTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/jcmd/AddExcludeTest.java b/hotspot/test/compiler/compilercontrol/jcmd/AddExcludeTest.java index a06c32616d8..38125fb6bac 100644 --- a/hotspot/test/compiler/compilercontrol/jcmd/AddExcludeTest.java +++ b/hotspot/test/compiler/compilercontrol/jcmd/AddExcludeTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests jcmd to be able to add a directive to exclude only specified methods + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.jcmd.AddExcludeTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/jcmd/AddLogTest.java b/hotspot/test/compiler/compilercontrol/jcmd/AddLogTest.java index 266cf3c5dda..7c14e41cf3c 100644 --- a/hotspot/test/compiler/compilercontrol/jcmd/AddLogTest.java +++ b/hotspot/test/compiler/compilercontrol/jcmd/AddLogTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests jcmd to be able to add a directive to log only specified methods + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.jcmd.AddLogTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/jcmd/AddPrintAssemblyTest.java b/hotspot/test/compiler/compilercontrol/jcmd/AddPrintAssemblyTest.java index 9697711c294..ea8bd585769 100644 --- a/hotspot/test/compiler/compilercontrol/jcmd/AddPrintAssemblyTest.java +++ b/hotspot/test/compiler/compilercontrol/jcmd/AddPrintAssemblyTest.java @@ -26,6 +26,7 @@ * @bug 8137167 * @summary Tests jcmd to be able to add a directive to print assembly * only for specified methods + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.jcmd.AddPrintAssemblyTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java b/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java index da1fef49141..4635a7f91f3 100644 --- a/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java +++ b/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesFileStackTest.java @@ -26,6 +26,7 @@ * @bug 8137167 * @ignore 8140405 * @summary Tests jcmd to be able to clear directives added via options + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.jcmd.ClearDirectivesFileStackTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesStackTest.java b/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesStackTest.java index c9d9f8dcfd0..20d7a7a3441 100644 --- a/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesStackTest.java +++ b/hotspot/test/compiler/compilercontrol/jcmd/ClearDirectivesStackTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests clear JCMD command + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.jcmd.ClearDirectivesStackTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java b/hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java index 2c7ebef9389..74bc4eef3ae 100644 --- a/hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java +++ b/hotspot/test/compiler/compilercontrol/jcmd/PrintDirectivesTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests jcmd to be able to add a directive to compile only specified methods + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.jcmd.PrintDirectivesTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java b/hotspot/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java index 26c225380ac..4cf2945108d 100644 --- a/hotspot/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java +++ b/hotspot/test/compiler/compilercontrol/jcmd/StressAddMultiThreadedTest.java @@ -26,6 +26,7 @@ * @bug 8137167 * @summary Tests jcmd to be able to add a lot of huge directive files with * parallel executed jcmds until timeout has reached + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.jcmd.StressAddMultiThreadedTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/matcher/MethodMatcherTest.java b/hotspot/test/compiler/compilercontrol/matcher/MethodMatcherTest.java index 87cd26a8958..9ec1eccf6e1 100644 --- a/hotspot/test/compiler/compilercontrol/matcher/MethodMatcherTest.java +++ b/hotspot/test/compiler/compilercontrol/matcher/MethodMatcherTest.java @@ -40,6 +40,7 @@ import java.util.regex.Pattern; * @test * @bug 8135068 * @summary Tests CompilerCommand's method matcher + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox ../share / * @build compiler.compilercontrol.matcher.MethodMatcherTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/mixed/RandomCommandsTest.java b/hotspot/test/compiler/compilercontrol/mixed/RandomCommandsTest.java index c954dba9011..11d38586a96 100644 --- a/hotspot/test/compiler/compilercontrol/mixed/RandomCommandsTest.java +++ b/hotspot/test/compiler/compilercontrol/mixed/RandomCommandsTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Randomly generates commands with random types + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.mixed.RandomCommandsTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java b/hotspot/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java index c918320d4fe..46c795205a6 100644 --- a/hotspot/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java +++ b/hotspot/test/compiler/compilercontrol/mixed/RandomValidCommandsTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Randomly generates valid commands with random types + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/testlibrary ../share / * @build compiler.compilercontrol.mixed.RandomValidCommandsTest * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/compilercontrol/parser/DirectiveParserTest.java b/hotspot/test/compiler/compilercontrol/parser/DirectiveParserTest.java index f0fc0bfe632..e4fda4a87f9 100644 --- a/hotspot/test/compiler/compilercontrol/parser/DirectiveParserTest.java +++ b/hotspot/test/compiler/compilercontrol/parser/DirectiveParserTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Tests directive json parser + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib ../share / * @run driver compiler.compilercontrol.parser.DirectiveParserTest */ diff --git a/hotspot/test/compiler/compilercontrol/parser/DirectiveStressTest.java b/hotspot/test/compiler/compilercontrol/parser/DirectiveStressTest.java index ef1a311beca..c99b531f531 100644 --- a/hotspot/test/compiler/compilercontrol/parser/DirectiveStressTest.java +++ b/hotspot/test/compiler/compilercontrol/parser/DirectiveStressTest.java @@ -25,6 +25,7 @@ * @test * @bug 8137167 * @summary Stress directive json parser + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib ../share / * @run driver compiler.compilercontrol.parser.DirectiveStressTest */ diff --git a/hotspot/test/compiler/eliminateAutobox/UnsignedLoads.java b/hotspot/test/compiler/eliminateAutobox/UnsignedLoads.java index cdea3b311e8..440a4b665e0 100644 --- a/hotspot/test/compiler/eliminateAutobox/UnsignedLoads.java +++ b/hotspot/test/compiler/eliminateAutobox/UnsignedLoads.java @@ -25,6 +25,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -XX:+EliminateAutoBox * -XX:CompileOnly=::valueOf,::byteValue,::shortValue,::testUnsignedByte,::testUnsignedShort diff --git a/hotspot/test/compiler/escapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java b/hotspot/test/compiler/escapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java index 3f38678351d..73ca08fa6cd 100644 --- a/hotspot/test/compiler/escapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java +++ b/hotspot/test/compiler/escapeAnalysis/TestUnsafePutAddressNullObjMustNotEscape.java @@ -31,7 +31,7 @@ */ import java.lang.reflect.Field; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class TestUnsafePutAddressNullObjMustNotEscape { @@ -43,7 +43,7 @@ public class TestUnsafePutAddressNullObjMustNotEscape { System.out.println("EXECUTING test."); { - System.out.println("Acquiring sun.misc.Unsafe.theUnsafe using reflection."); + System.out.println("Acquiring jdk.internal.misc.Unsafe.theUnsafe using reflection."); getUnsafe(); System.out.println("Allocating raw memory."); mem = (usafe.allocateMemory(1024) + 8L) & ~7L; @@ -78,8 +78,8 @@ public class TestUnsafePutAddressNullObjMustNotEscape { } private static void getUnsafe() throws Exception { - Field field = sun.misc.Unsafe.class.getDeclaredField("theUnsafe"); + Field field = jdk.internal.misc.Unsafe.class.getDeclaredField("theUnsafe"); field.setAccessible(true); - usafe = (sun.misc.Unsafe) field.get(null); + usafe = (jdk.internal.misc.Unsafe) field.get(null); } } diff --git a/hotspot/test/compiler/floatingpoint/TestPow2.java b/hotspot/test/compiler/floatingpoint/TestPow2.java index a443062b9b4..d3893e9863c 100644 --- a/hotspot/test/compiler/floatingpoint/TestPow2.java +++ b/hotspot/test/compiler/floatingpoint/TestPow2.java @@ -26,6 +26,7 @@ * @bug 8063086 * @summary X^2 special case for C2 yields different result than interpreter * @library /testlibrary /test/lib /compiler/whitebox / + * @modules java.base/jdk.internal.misc * @modules java.management * @build TestPow2 * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/inlining/InlineAccessors.java b/hotspot/test/compiler/inlining/InlineAccessors.java index 60f8986a829..387a513f148 100644 --- a/hotspot/test/compiler/inlining/InlineAccessors.java +++ b/hotspot/test/compiler/inlining/InlineAccessors.java @@ -25,6 +25,7 @@ * @test * @bug 8140650 * @summary Method::is_accessor should cover getters and setters for all types + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm InlineAccessors */ diff --git a/hotspot/test/compiler/intrinsics/IntrinsicAvailableTest.java b/hotspot/test/compiler/intrinsics/IntrinsicAvailableTest.java index ff2c7e366df..ab582f94b18 100644 --- a/hotspot/test/compiler/intrinsics/IntrinsicAvailableTest.java +++ b/hotspot/test/compiler/intrinsics/IntrinsicAvailableTest.java @@ -29,6 +29,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; /* * @test * @bug 8130832 + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox /compiler/testlibrary / * @build IntrinsicAvailableTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/intrinsics/IntrinsicDisabledTest.java b/hotspot/test/compiler/intrinsics/IntrinsicDisabledTest.java index 1fdaf805f9a..638301a54e7 100644 --- a/hotspot/test/compiler/intrinsics/IntrinsicDisabledTest.java +++ b/hotspot/test/compiler/intrinsics/IntrinsicDisabledTest.java @@ -24,6 +24,7 @@ /* * @test * @bug 8138651 + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build IntrinsicDisabledTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/intrinsics/clone/TestObjectClone.java b/hotspot/test/compiler/intrinsics/clone/TestObjectClone.java index 2dde3fc9dc8..1e40e8442e1 100644 --- a/hotspot/test/compiler/intrinsics/clone/TestObjectClone.java +++ b/hotspot/test/compiler/intrinsics/clone/TestObjectClone.java @@ -26,6 +26,7 @@ * @test * @bug 8033626 * @summary assert(ex_map->jvms()->same_calls_as(_exceptions->jvms())) failed: all collected exceptions must come from the same place + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm -XX:-TieredCompilation -Xbatch -XX:CompileOnly=TestObjectClone::f TestObjectClone */ diff --git a/hotspot/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java b/hotspot/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java index 5a6f91c0636..cd8445bf8cf 100644 --- a/hotspot/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java +++ b/hotspot/test/compiler/intrinsics/montgomerymultiply/MontgomeryMultiplyTest.java @@ -42,6 +42,7 @@ import jdk.test.lib.Platform; * @test * @bug 8130150 8131779 8139907 * @summary Verify that the Montgomery multiply and square intrinsic works and correctly checks their arguments. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @library /testlibrary * @build MontgomeryMultiplyTest diff --git a/hotspot/test/compiler/intrinsics/string/TestStringIntrinsicMemoryFlow.java b/hotspot/test/compiler/intrinsics/string/TestStringIntrinsicMemoryFlow.java index 86d7b309179..f3cb5168901 100644 --- a/hotspot/test/compiler/intrinsics/string/TestStringIntrinsicMemoryFlow.java +++ b/hotspot/test/compiler/intrinsics/string/TestStringIntrinsicMemoryFlow.java @@ -27,6 +27,7 @@ import jdk.test.lib.Asserts; * @test * @bug 8144212 * @summary Check for correct memory flow with the String compress/inflate intrinsics. + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main TestStringIntrinsicMemoryFlow */ diff --git a/hotspot/test/compiler/intrinsics/string/TestStringIntrinsics2.java b/hotspot/test/compiler/intrinsics/string/TestStringIntrinsics2.java index 7bba5308971..ca8ca1ceebd 100644 --- a/hotspot/test/compiler/intrinsics/string/TestStringIntrinsics2.java +++ b/hotspot/test/compiler/intrinsics/string/TestStringIntrinsics2.java @@ -26,6 +26,7 @@ * @test * @bug 8145336 * @summary PPC64: fix string intrinsics after CompactStrings change + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/intrinsics/unsafe/HeapByteBufferTest.java b/hotspot/test/compiler/intrinsics/unsafe/HeapByteBufferTest.java index c9c0fc7506f..7c46ab1d555 100644 --- a/hotspot/test/compiler/intrinsics/unsafe/HeapByteBufferTest.java +++ b/hotspot/test/compiler/intrinsics/unsafe/HeapByteBufferTest.java @@ -36,6 +36,7 @@ import jdk.test.lib.Utils; /** * @test * @bug 8026049 + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:-UseUnalignedAccesses -Djdk.test.lib.random.seed=0 HeapByteBufferTest * @run main/othervm -Djdk.test.lib.random.seed=0 HeapByteBufferTest diff --git a/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java b/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java index 2c60a719827..78ef24a9338 100644 --- a/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java +++ b/hotspot/test/compiler/intrinsics/unsafe/TestUnsafeMismatchedArrayFieldAccess.java @@ -25,6 +25,7 @@ /** * @test * @bug 8142386 + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @summary Unsafe access to an array is wrongly marked as mismatched * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:-TieredCompilation TestUnsafeMismatchedArrayFieldAccess @@ -33,7 +34,7 @@ import java.lang.reflect.*; import jdk.test.lib.Utils; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class TestUnsafeMismatchedArrayFieldAccess { diff --git a/hotspot/test/compiler/intrinsics/unsafe/UnsafeGetAddressTest.java b/hotspot/test/compiler/intrinsics/unsafe/UnsafeGetAddressTest.java index 5ed225fd871..75997811d5d 100644 --- a/hotspot/test/compiler/intrinsics/unsafe/UnsafeGetAddressTest.java +++ b/hotspot/test/compiler/intrinsics/unsafe/UnsafeGetAddressTest.java @@ -30,21 +30,21 @@ * */ -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.lang.reflect.*; public class UnsafeGetAddressTest { private static Unsafe unsafe; public static void main(String[] args) throws Exception { - Class c = UnsafeGetAddressTest.class.getClassLoader().loadClass("sun.misc.Unsafe"); + Class c = UnsafeGetAddressTest.class.getClassLoader().loadClass("jdk.internal.misc.Unsafe"); Field f = c.getDeclaredField("theUnsafe"); f.setAccessible(true); unsafe = (Unsafe)f.get(c); long address = unsafe.allocateMemory(unsafe.addressSize()); unsafe.putAddress(address, 0x0000000080000000L); - // from sun.misc.Unsafe.getAddress' documentation: + // from jdk.internal.misc.Unsafe.getAddress' documentation: // "If the native pointer is less than 64 bits wide, it is // extended as an unsigned number to a Java long." result = unsafe.getAddress(address); diff --git a/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java b/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java index 9ab3c36e3de..02c4ba3faaa 100644 --- a/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java +++ b/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java @@ -24,6 +24,7 @@ /** * @test * @bug 8057967 + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * @library patches * @build java.base/java.lang.invoke.MethodHandleHelper @@ -46,7 +47,7 @@ import java.lang.ref.ReferenceQueue; import java.lang.reflect.Field; import jdk.internal.org.objectweb.asm.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.internal.org.objectweb.asm.Opcodes.*; diff --git a/hotspot/test/compiler/jsr292/ContinuousCallSiteTargetChange.java b/hotspot/test/compiler/jsr292/ContinuousCallSiteTargetChange.java index a59f962fd22..3b009e9c0d0 100644 --- a/hotspot/test/compiler/jsr292/ContinuousCallSiteTargetChange.java +++ b/hotspot/test/compiler/jsr292/ContinuousCallSiteTargetChange.java @@ -23,6 +23,7 @@ /** * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main ContinuousCallSiteTargetChange */ diff --git a/hotspot/test/compiler/jsr292/InvokerGC.java b/hotspot/test/compiler/jsr292/InvokerGC.java index c0a47184f06..a8115f70173 100644 --- a/hotspot/test/compiler/jsr292/InvokerGC.java +++ b/hotspot/test/compiler/jsr292/InvokerGC.java @@ -24,6 +24,7 @@ /* * @test * @bug 8067247 + * @modules java.base/jdk.internal.misc * @library /test/lib /compiler/whitebox / * @run main/bootclasspath -Xcomp -Xbatch * -XX:CompileCommand=compileonly,InvokerGC::test diff --git a/hotspot/test/compiler/jsr292/MHInlineTest.java b/hotspot/test/compiler/jsr292/MHInlineTest.java index 552b12209cf..915c8f1362d 100644 --- a/hotspot/test/compiler/jsr292/MHInlineTest.java +++ b/hotspot/test/compiler/jsr292/MHInlineTest.java @@ -25,6 +25,7 @@ * @test * @bug 8062280 * @summary C2: inlining failure due to access checks being too strict + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm MHInlineTest */ diff --git a/hotspot/test/compiler/jsr292/NonInlinedCall/GCTest.java b/hotspot/test/compiler/jsr292/NonInlinedCall/GCTest.java index fc705850e00..a9a713fb3e7 100644 --- a/hotspot/test/compiler/jsr292/NonInlinedCall/GCTest.java +++ b/hotspot/test/compiler/jsr292/NonInlinedCall/GCTest.java @@ -25,6 +25,7 @@ * @test * @bug 8072008 * @library /testlibrary /test/lib ../patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build java.base/java.lang.invoke.MethodHandleHelper * @build sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/jsr292/NonInlinedCall/InvokeTest.java b/hotspot/test/compiler/jsr292/NonInlinedCall/InvokeTest.java index 225db6018ce..e66c6e2df64 100644 --- a/hotspot/test/compiler/jsr292/NonInlinedCall/InvokeTest.java +++ b/hotspot/test/compiler/jsr292/NonInlinedCall/InvokeTest.java @@ -25,6 +25,7 @@ * @test * @bug 8072008 * @library /testlibrary /test/lib / ../patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build java.base/java.lang.invoke.MethodHandleHelper * @build sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/jsr292/PollutedTrapCounts.java b/hotspot/test/compiler/jsr292/PollutedTrapCounts.java index 7aecdae9f5e..b368b2f7c77 100644 --- a/hotspot/test/compiler/jsr292/PollutedTrapCounts.java +++ b/hotspot/test/compiler/jsr292/PollutedTrapCounts.java @@ -24,6 +24,7 @@ /** * @test * @bug 8074551 + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main PollutedTrapCounts */ diff --git a/hotspot/test/compiler/jsr292/VMAnonymousClasses.java b/hotspot/test/compiler/jsr292/VMAnonymousClasses.java index 50bb3432642..e251722f762 100644 --- a/hotspot/test/compiler/jsr292/VMAnonymousClasses.java +++ b/hotspot/test/compiler/jsr292/VMAnonymousClasses.java @@ -32,7 +32,7 @@ import jdk.internal.org.objectweb.asm.ClassWriter; import jdk.internal.org.objectweb.asm.MethodVisitor; import jdk.internal.org.objectweb.asm.Opcodes; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.lang.invoke.ConstantCallSite; import java.lang.invoke.MethodHandle; diff --git a/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java b/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java index 0504798c50a..13849452847 100644 --- a/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java +++ b/hotspot/test/compiler/jvmci/JVM_GetJVMCIRuntimeTest.java @@ -27,6 +27,7 @@ * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary / + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.runtime * @run main/othervm -XX:+UnlockExperimentalVMOptions * -Dcompiler.jvmci.JVM_GetJVMCIRuntimeTest.positive=true diff --git a/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java b/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java index 993cbba8a18..48c406a4adc 100644 --- a/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java +++ b/hotspot/test/compiler/jvmci/SecurityRestrictionsTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * @run main/othervm -XX:+UnlockExperimentalVMOptions diff --git a/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java b/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java index 3902acf2388..148402ee786 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/AllocateCompileIdTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java index b24d25ca005..4500a83ac56 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/CanInlineMethodTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/CollectCountersTest.java b/hotspot/test/compiler/jvmci/compilerToVM/CollectCountersTest.java index 81b7bd47d7b..dc905f3a2ae 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/CollectCountersTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/CollectCountersTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.CollectCountersTest diff --git a/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java b/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java index fe251871e07..ffe0a899cba 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/DebugOutputTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.DebugOutputTest diff --git a/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java b/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java index bd39a56e2e5..d8eedaad0c2 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/DisassembleCodeBlobTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java b/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java index 747a9cf6123..db741621e2a 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/DoNotInlineOrCompileTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java index fb89c4e5428..399ff0cca73 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ExecuteInstalledCodeTest.java @@ -25,6 +25,7 @@ import java.util.Map; * @library /testlibrary /test/lib / * @library ../common/patches * @ignore 8139383 + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java index 0cca017515d..cc5ff3d9e2d 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/FindUniqueConcreteMethodTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java index 472bc379cb5..7bfd132a5e9 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetBytecodeTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java index 1b0eacdf3c6..3f2c80f1642 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetClassInitializerTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetClassInitializerTest diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java index 3e14a684644..28463d71e75 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetConstantPoolTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper @@ -51,7 +52,7 @@ import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; import jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject; import jdk.test.lib.Utils; import sun.hotspot.WhiteBox; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Tests for jdk.vm.ci.hotspot.CompilerToVM::getConstantPool method diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java index 63f44334e4e..536972d755a 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetExceptionTableTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetImplementorTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetImplementorTest.java index 1b03ef2e79e..894791f1006 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetImplementorTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetImplementorTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetImplementorTest diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java index 99fcd9fae21..c1bfbba85ff 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetLineNumberTableTest.java @@ -29,6 +29,7 @@ * @library /testlibrary /test/lib / * @library ../common/patches * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java index 958b2e48fe4..d6f6725f723 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetLocalVariableTableTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java index c180d41d548..93653fd57a0 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetMaxCallTargetOffsetTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.GetMaxCallTargetOffsetTest diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java index 44fbb4cdaef..afca9ec85fb 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetNextStackFrameTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java index 87afff2df3b..d23aad95fb6 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodAtSlotTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java index 4735af3ee3e..6e0fea30328 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaMethodTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * jdk.vm.ci/jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject @@ -48,7 +49,7 @@ import jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject; import jdk.test.lib.Asserts; import jdk.test.lib.Utils; import sun.hotspot.WhiteBox; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.lang.reflect.Field; diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java index 0ddc246aec3..1dde0850aad 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetResolvedJavaTypeTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper @@ -59,7 +60,7 @@ import jdk.vm.ci.hotspot.PublicMetaspaceWrapperObject; import jdk.test.lib.Asserts; import jdk.test.lib.Utils; import sun.hotspot.WhiteBox; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class GetResolvedJavaTypeTest { private static enum TestCase { diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java index a6feb931eb0..970e8cbfb58 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetStackTraceElementTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetSymbolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetSymbolTest.java index 9e1f82998ca..7e10c95e0b8 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetSymbolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetSymbolTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java b/hotspot/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java index 49fd32128df..66a0bd94f7d 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/GetVtableIndexForInterfaceTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java b/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java index e45940e3e6a..9cb947eb7e1 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/HasCompiledCodeForOSRTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java b/hotspot/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java index 066e78448de..d972a22dc36 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/HasFinalizableSubclassTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.HasFinalizableSubclassTest diff --git a/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java b/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java index 3de8ec56166..9087b52baf1 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/InitializeConfigurationTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.InitializeConfigurationTest @@ -46,7 +47,7 @@ import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; import jdk.test.lib.Asserts; import jdk.test.lib.Utils; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class InitializeConfigurationTest { private static final Unsafe UNSAFE = Utils.getUnsafe(); diff --git a/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java index b7a0cfd0c19..369be8612d1 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/InvalidateInstalledCodeTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java b/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java index f6ebb8303a6..fe2f0259844 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/IsMatureTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.IsMatureTest diff --git a/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java b/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java index ac42d62f543..56a43432040 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/JVM_RegisterJVMCINatives.java @@ -27,6 +27,7 @@ * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary / + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.runtime * @run main/othervm -XX:+UnlockExperimentalVMOptions diff --git a/hotspot/test/compiler/jvmci/compilerToVM/LookupTypeTest.java b/hotspot/test/compiler/jvmci/compilerToVM/LookupTypeTest.java index 269c5a7d39c..712d5d8b2cf 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/LookupTypeTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/LookupTypeTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.LookupTypeTest diff --git a/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java b/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java index e28174905a2..43a7631617b 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/MaterializeVirtualObjectTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java b/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java index 812c2586165..d78672acfaf 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/MethodIsIgnoredBySecurityStackWalkTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.reflect * java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java index 4ec17c2e71a..154c3b28bd2 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ReadUncompressedOopTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.ReadUncompressedOopTest @@ -52,7 +53,7 @@ import jdk.vm.ci.hotspot.CompilerToVMHelper; import jdk.test.lib.Asserts; import jdk.test.lib.Utils; import sun.hotspot.WhiteBox; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.lang.reflect.Field; diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java index 1e8cb12dd89..371af37813d 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ReprofileTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java index 3c004ce0c09..8151340f9f8 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveFieldInPoolTest.java @@ -60,7 +60,7 @@ import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; import jdk.vm.ci.meta.ConstantPool; import jdk.test.lib.Asserts; import jdk.test.lib.Utils; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Test for {@code jdk.vm.ci.hotspot.CompilerToVM.resolveFieldInPool} method diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java index df6ef8b4747..98b56f8cc3c 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot @@ -56,7 +57,7 @@ import jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod; import jdk.vm.ci.hotspot.HotSpotResolvedObjectType; import jdk.test.lib.Asserts; import jdk.test.lib.Utils; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class ResolveMethodTest { private static final Unsafe UNSAFE = Utils.getUnsafe(); diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java index 69ceeffdf7d..a6dd4cfe8a3 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ShouldDebugNonSafepointsTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary /test/lib/ * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * @build jdk.vm.ci/jdk.vm.ci.hotspot.CompilerToVMHelper * @build compiler.jvmci.compilerToVM.ShouldDebugNonSafepointsTest diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java index 615b5859df6..bef796ab825 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ShouldInlineMethodTest.java @@ -28,6 +28,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.java b/hotspot/test/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.java index c8bfbff88d1..c86938943c5 100644 --- a/hotspot/test/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.java +++ b/hotspot/test/compiler/jvmci/events/JvmciCreateMetaAccessContextTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.meta diff --git a/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java b/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java index 1110b1eac31..e045775c7ee 100644 --- a/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java +++ b/hotspot/test/compiler/jvmci/events/JvmciNotifyInstallEventTest.java @@ -27,6 +27,7 @@ * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library / /testlibrary * @library ../common/patches + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.org.objectweb.asm.tree * jdk.vm.ci/jdk.vm.ci.hotspot diff --git a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java index 7dbbf8e35fa..2c2493221ad 100644 --- a/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java +++ b/hotspot/test/compiler/jvmci/events/JvmciShutdownEventTest.java @@ -26,6 +26,7 @@ * @bug 8136421 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary / + * @modules java.base/jdk.internal.misc * @modules jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.code * jdk.vm.ci/jdk.vm.ci.meta diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java index 761db0e7a06..dfa217abf84 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ConstantTest.java @@ -27,6 +27,7 @@ * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime + * java.base/jdk.internal.misc * @build jdk.vm.ci.runtime.test.ConstantTest * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.ConstantTest */ diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java index 038efdcb2d2..604d671513b 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/RedefineClassTest.java @@ -27,6 +27,7 @@ * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime + * java.base/jdk.internal.misc * @build jdk.vm.ci.runtime.test.RedefineClassTest * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.RedefineClassTest */ diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java index fe31f5907be..824a1532c62 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestConstantReflectionProvider.java @@ -27,6 +27,7 @@ * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime + * java.base/jdk.internal.misc * @build jdk.vm.ci.runtime.test.TestConstantReflectionProvider * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestConstantReflectionProvider */ diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java index 46f4e80ac89..4537b386de5 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaField.java @@ -27,6 +27,7 @@ * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime + * java.base/jdk.internal.misc * @build jdk.vm.ci.runtime.test.TestJavaField * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestJavaField */ diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java index 460abd992af..faa96b898a6 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaMethod.java @@ -27,6 +27,7 @@ * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime + * java.base/jdk.internal.misc * @build jdk.vm.ci.runtime.test.TestJavaMethod * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestJavaMethod */ diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java index 72506cf0933..23959e2059f 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestJavaType.java @@ -27,6 +27,7 @@ * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime + * java.base/jdk.internal.misc * @build jdk.vm.ci.runtime.test.TestJavaType * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestJavaType */ diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java index 10b2e70c334..904aada9059 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestMetaAccessProvider.java @@ -27,6 +27,7 @@ * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime + * java.base/jdk.internal.misc * @build jdk.vm.ci.runtime.test.TestMetaAccessProvider * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestMetaAccessProvider */ diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java index 71e9f188c43..defa1997026 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java @@ -27,6 +27,7 @@ * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime + * java.base/jdk.internal.misc * @build jdk.vm.ci.runtime.test.TestResolvedJavaField * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestResolvedJavaField */ diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java index c60a7d45e42..d96560ce11f 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java @@ -27,6 +27,7 @@ * @library ../../../../../ * @modules jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime + * java.base/jdk.internal.misc * @build jdk.vm.ci.runtime.test.TestResolvedJavaMethod * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestResolvedJavaMethod */ diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java index 8caaefddf55..917d1005b64 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java @@ -29,6 +29,7 @@ * jdk.vm.ci/jdk.vm.ci.meta * jdk.vm.ci/jdk.vm.ci.runtime * jdk.vm.ci/jdk.vm.ci.common + * java.base/jdk.internal.misc * @build jdk.vm.ci.runtime.test.TestResolvedJavaType * @run junit/othervm -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI jdk.vm.ci.runtime.test.TestResolvedJavaType */ diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java index c66068988da..59969f846e3 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TypeUniverse.java @@ -57,7 +57,7 @@ import jdk.vm.ci.runtime.JVMCI; import org.junit.Test; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; //JaCoCo Exclude diff --git a/hotspot/test/compiler/jvmci/meta/StableFieldTest.java b/hotspot/test/compiler/jvmci/meta/StableFieldTest.java index 82a3b989286..5c2bd0d9e2b 100644 --- a/hotspot/test/compiler/jvmci/meta/StableFieldTest.java +++ b/hotspot/test/compiler/jvmci/meta/StableFieldTest.java @@ -26,6 +26,7 @@ * @bug 8151664 * @requires (os.simpleArch == "x64" | os.simpleArch == "sparcv9" | os.simpleArch == "aarch64") * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * jdk.vm.ci/jdk.vm.ci.hotspot * jdk.vm.ci/jdk.vm.ci.meta diff --git a/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java b/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java index 689b7f40be7..67cd3c91b06 100644 --- a/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java +++ b/hotspot/test/compiler/loopopts/UseCountedLoopSafepoints.java @@ -27,6 +27,7 @@ * @bug 6869327 * @summary Test that C2 flag UseCountedLoopSafepoints ensures a safepoint is kept in a CountedLoop * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.base * @ignore 8146096 * @run main UseCountedLoopSafepoints diff --git a/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java b/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java index 60c47e32384..41e7769b815 100644 --- a/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java +++ b/hotspot/test/compiler/loopopts/superword/TestVectorizationWithInvariant.java @@ -23,12 +23,13 @@ */ import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * @test * @bug 8078497 * @summary Tests correct alignment of vectors with loop invariant offset. + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main TestVectorizationWithInvariant */ diff --git a/hotspot/test/compiler/onSpinWait/TestOnSpinWait.java b/hotspot/test/compiler/onSpinWait/TestOnSpinWait.java index 76861ca687f..6a3fa0d449b 100644 --- a/hotspot/test/compiler/onSpinWait/TestOnSpinWait.java +++ b/hotspot/test/compiler/onSpinWait/TestOnSpinWait.java @@ -26,6 +26,7 @@ * @test TestOnSpinWait * @summary (x86 only) checks that java.lang.Thread.onSpinWait is intrinsified * @bug 8147844 + * @modules java.base/jdk.internal.misc * @library /testlibrary * @requires os.arch=="x86" | os.arch=="amd64" | os.arch=="x86_64" * @run main TestOnSpinWait diff --git a/hotspot/test/compiler/oracle/GetMethodOptionTest.java b/hotspot/test/compiler/oracle/GetMethodOptionTest.java index a6b92b2c632..ed295f417b7 100644 --- a/hotspot/test/compiler/oracle/GetMethodOptionTest.java +++ b/hotspot/test/compiler/oracle/GetMethodOptionTest.java @@ -30,6 +30,7 @@ import sun.hotspot.WhiteBox; /* * @test * @bug 8074980 + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build sun.hotspot.WhiteBox jdk.test.lib.Asserts GetMethodOptionTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/oracle/MethodMatcherTest.java b/hotspot/test/compiler/oracle/MethodMatcherTest.java index 386f24406c8..1f158276055 100644 --- a/hotspot/test/compiler/oracle/MethodMatcherTest.java +++ b/hotspot/test/compiler/oracle/MethodMatcherTest.java @@ -23,6 +23,7 @@ /* * @test MethodMatcherTest + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java b/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java index c4627213a49..c4c97f98038 100644 --- a/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java +++ b/hotspot/test/compiler/rangechecks/TestExplicitRangeChecks.java @@ -25,6 +25,7 @@ * @test * @bug 8073480 * @summary explicit range checks should be recognized by C2 + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox / * @build TestExplicitRangeChecks * @run main ClassFileInstaller sun.hotspot.WhiteBox @@ -40,7 +41,7 @@ import java.util.*; import sun.hotspot.WhiteBox; import sun.hotspot.code.NMethod; import jdk.test.lib.Platform; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import compiler.whitebox.CompilerWhiteBoxTest; public class TestExplicitRangeChecks { diff --git a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java index 90a9f14cc3a..574b7cc74fd 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMAbortRatio.java @@ -44,7 +44,7 @@ import jdk.test.lib.cli.predicate.AndPredicate; import rtm.*; import rtm.predicate.SupportedCPU; import rtm.predicate.SupportedVM; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Test verifies that method will be deoptimized on high abort ratio diff --git a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java index 605f7953ff7..e4623c2c077 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMAfterNonRTMDeopt.java @@ -46,7 +46,7 @@ import jdk.test.lib.cli.predicate.AndPredicate; import rtm.*; import rtm.predicate.SupportedCPU; import rtm.predicate.SupportedVM; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * To verify that with +UseRTMDeopt method's RTM state will be diff --git a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java index b531aac5946..de8e8a3519f 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMDeoptOnLowAbortRatio.java @@ -43,7 +43,7 @@ import jdk.test.lib.cli.predicate.AndPredicate; import rtm.*; import rtm.predicate.SupportedCPU; import rtm.predicate.SupportedVM; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Test verifies that low abort ratio method will be deoptimized with diff --git a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java index 8b1ee985095..7280fc21b81 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMLockingThreshold.java @@ -44,7 +44,7 @@ import jdk.test.lib.cli.predicate.AndPredicate; import rtm.*; import rtm.predicate.SupportedCPU; import rtm.predicate.SupportedVM; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Test verifies that RTMLockingThreshold option actually affects how soon diff --git a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java index 4056dc9a50c..37920da4c1d 100644 --- a/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java +++ b/hotspot/test/compiler/rtm/locking/TestRTMTotalCountIncrRate.java @@ -37,7 +37,7 @@ * -XX:+WhiteBoxAPI TestRTMTotalCountIncrRate */ -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.util.List; import jdk.test.lib.*; diff --git a/hotspot/test/compiler/runtime/8010927/Test8010927.java b/hotspot/test/compiler/runtime/8010927/Test8010927.java index 127e80b9a5f..9453878cfe0 100644 --- a/hotspot/test/compiler/runtime/8010927/Test8010927.java +++ b/hotspot/test/compiler/runtime/8010927/Test8010927.java @@ -35,7 +35,7 @@ import sun.hotspot.WhiteBox; import java.lang.reflect.Field; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * The test creates uncommitted space between oldgen and young gen diff --git a/hotspot/test/compiler/stable/TestStableBoolean.java b/hotspot/test/compiler/stable/TestStableBoolean.java index ee92c9c0a8a..e47a9a783df 100644 --- a/hotspot/test/compiler/stable/TestStableBoolean.java +++ b/hotspot/test/compiler/stable/TestStableBoolean.java @@ -27,6 +27,7 @@ * @test TestStableBoolean * @summary tests on stable fields and arrays * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableBoolean diff --git a/hotspot/test/compiler/stable/TestStableByte.java b/hotspot/test/compiler/stable/TestStableByte.java index eb193b4a3e3..be41ae50fc9 100644 --- a/hotspot/test/compiler/stable/TestStableByte.java +++ b/hotspot/test/compiler/stable/TestStableByte.java @@ -27,6 +27,7 @@ * @test TestStableByte * @summary tests on stable fields and arrays * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableByte diff --git a/hotspot/test/compiler/stable/TestStableChar.java b/hotspot/test/compiler/stable/TestStableChar.java index 7f291070c7e..5a86773bfe4 100644 --- a/hotspot/test/compiler/stable/TestStableChar.java +++ b/hotspot/test/compiler/stable/TestStableChar.java @@ -27,6 +27,7 @@ * @test TestStableChar * @summary tests on stable fields and arrays * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableChar diff --git a/hotspot/test/compiler/stable/TestStableDouble.java b/hotspot/test/compiler/stable/TestStableDouble.java index df71febc523..d1dbcad6d39 100644 --- a/hotspot/test/compiler/stable/TestStableDouble.java +++ b/hotspot/test/compiler/stable/TestStableDouble.java @@ -27,6 +27,7 @@ * @test TestStableDouble * @summary tests on stable fields and arrays * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableDouble diff --git a/hotspot/test/compiler/stable/TestStableFloat.java b/hotspot/test/compiler/stable/TestStableFloat.java index 33e1bed2433..bcee1084bd6 100644 --- a/hotspot/test/compiler/stable/TestStableFloat.java +++ b/hotspot/test/compiler/stable/TestStableFloat.java @@ -27,6 +27,7 @@ * @test TestStableFloat * @summary tests on stable fields and arrays * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableFloat diff --git a/hotspot/test/compiler/stable/TestStableInt.java b/hotspot/test/compiler/stable/TestStableInt.java index 023c8737397..a57b9013736 100644 --- a/hotspot/test/compiler/stable/TestStableInt.java +++ b/hotspot/test/compiler/stable/TestStableInt.java @@ -27,6 +27,7 @@ * @test TestStableInt * @summary tests on stable fields and arrays * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableInt diff --git a/hotspot/test/compiler/stable/TestStableLong.java b/hotspot/test/compiler/stable/TestStableLong.java index 67ddedc0257..9177ccc7a7c 100644 --- a/hotspot/test/compiler/stable/TestStableLong.java +++ b/hotspot/test/compiler/stable/TestStableLong.java @@ -27,6 +27,7 @@ * @test TestStableLong * @summary tests on stable fields and arrays * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableLong diff --git a/hotspot/test/compiler/stable/TestStableMemoryBarrier.java b/hotspot/test/compiler/stable/TestStableMemoryBarrier.java index 6b413401a8a..aa4d32dc853 100644 --- a/hotspot/test/compiler/stable/TestStableMemoryBarrier.java +++ b/hotspot/test/compiler/stable/TestStableMemoryBarrier.java @@ -28,6 +28,7 @@ * @bug 8139758 * @summary tests memory barrier correctly inserted for stable fields * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * * @run main/bootclasspath -Xcomp -XX:CompileOnly=::testCompile diff --git a/hotspot/test/compiler/stable/TestStableObject.java b/hotspot/test/compiler/stable/TestStableObject.java index 31e0a5c6a40..4a4b2a6b364 100644 --- a/hotspot/test/compiler/stable/TestStableObject.java +++ b/hotspot/test/compiler/stable/TestStableObject.java @@ -27,6 +27,7 @@ * @test TestStableObject * @summary tests on stable fields and arrays * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableObject diff --git a/hotspot/test/compiler/stable/TestStableShort.java b/hotspot/test/compiler/stable/TestStableShort.java index 107c8c7537c..6e018c1b9d9 100644 --- a/hotspot/test/compiler/stable/TestStableShort.java +++ b/hotspot/test/compiler/stable/TestStableShort.java @@ -27,6 +27,7 @@ * @test TestStableShort * @summary tests on stable fields and arrays * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableShort diff --git a/hotspot/test/compiler/stable/TestStableUByte.java b/hotspot/test/compiler/stable/TestStableUByte.java index 285b0274588..cfc97f06c6b 100644 --- a/hotspot/test/compiler/stable/TestStableUByte.java +++ b/hotspot/test/compiler/stable/TestStableUByte.java @@ -27,6 +27,7 @@ * @test TestStableUByte * @summary tests on stable fields and arrays * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableUByte diff --git a/hotspot/test/compiler/stable/TestStableUShort.java b/hotspot/test/compiler/stable/TestStableUShort.java index b450582f854..43def908bc2 100644 --- a/hotspot/test/compiler/stable/TestStableUShort.java +++ b/hotspot/test/compiler/stable/TestStableUShort.java @@ -27,6 +27,7 @@ * @test TestStableUShort * @summary tests on stable fields and arrays * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableUShort diff --git a/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java b/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java index 19e3bf8c751..39916c516d8 100644 --- a/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java +++ b/hotspot/test/compiler/testlibrary/rtm/XAbortProvoker.java @@ -25,7 +25,7 @@ package rtm; import jdk.test.lib.Utils; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Current RTM locking implementation force transaction abort diff --git a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java index 101ad492c27..98fad1ee0b4 100644 --- a/hotspot/test/compiler/tiered/NonTieredLevelsTest.java +++ b/hotspot/test/compiler/tiered/NonTieredLevelsTest.java @@ -27,6 +27,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; /** * @test NonTieredLevelsTest * @library /testlibrary /test/lib /compiler/whitebox / + * @modules java.base/jdk.internal.misc * @modules java.management * @build NonTieredLevelsTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/tiered/TieredLevelsTest.java b/hotspot/test/compiler/tiered/TieredLevelsTest.java index 68dc01071e1..bf1812128fc 100644 --- a/hotspot/test/compiler/tiered/TieredLevelsTest.java +++ b/hotspot/test/compiler/tiered/TieredLevelsTest.java @@ -26,6 +26,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; /** * @test TieredLevelsTest * @library /testlibrary /test/lib /compiler/whitebox / + * @modules java.base/jdk.internal.misc * @modules java.management * @build TieredLevelsTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/uncommontrap/8009761/Test8009761.java b/hotspot/test/compiler/uncommontrap/8009761/Test8009761.java index 50979d260c6..7295581bf2a 100644 --- a/hotspot/test/compiler/uncommontrap/8009761/Test8009761.java +++ b/hotspot/test/compiler/uncommontrap/8009761/Test8009761.java @@ -27,6 +27,7 @@ import java.lang.reflect.Method; /* * @test * @bug 8009761 + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @summary Deoptimization on sparc doesn't set Llast_SP correctly in the interpreter frames it creates * @build Test8009761 diff --git a/hotspot/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java b/hotspot/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java index c7dc5cabab8..a6707d536f9 100644 --- a/hotspot/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java +++ b/hotspot/test/compiler/unsafe/GetUnsafeObjectG1PreBarrier.java @@ -31,7 +31,7 @@ import java.lang.reflect.Field; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class GetUnsafeObjectG1PreBarrier { private static final Unsafe unsafe; diff --git a/hotspot/test/compiler/unsafe/TestUnsafeLoadControl.java b/hotspot/test/compiler/unsafe/TestUnsafeLoadControl.java index edd55975378..3fc0e821a68 100644 --- a/hotspot/test/compiler/unsafe/TestUnsafeLoadControl.java +++ b/hotspot/test/compiler/unsafe/TestUnsafeLoadControl.java @@ -25,12 +25,13 @@ * @test * @bug 8077504 * @summary Unsafe load can loose control dependency and cause crash + * @modules java.base/jdk.internal.misc * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestUnsafeLoadControl * */ import java.lang.reflect.Field; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class TestUnsafeLoadControl { diff --git a/hotspot/test/compiler/unsafe/UnsafeRaw.java b/hotspot/test/compiler/unsafe/UnsafeRaw.java index 80ffd837c73..bb2e9a1aeca 100644 --- a/hotspot/test/compiler/unsafe/UnsafeRaw.java +++ b/hotspot/test/compiler/unsafe/UnsafeRaw.java @@ -33,51 +33,52 @@ import jdk.test.lib.Utils; import java.util.Random; +import jdk.internal.misc.Unsafe; public class UnsafeRaw { public static class Tests { - public static int int_index(sun.misc.Unsafe unsafe, long base, int index) throws Exception { + public static int int_index(Unsafe unsafe, long base, int index) throws Exception { return unsafe.getInt(base + (index << 2)); } - public static int long_index(sun.misc.Unsafe unsafe, long base, long index) throws Exception { + public static int long_index(Unsafe unsafe, long base, long index) throws Exception { return unsafe.getInt(base + (index << 2)); } - public static int int_index_back_ashift(sun.misc.Unsafe unsafe, long base, int index) throws Exception { + public static int int_index_back_ashift(Unsafe unsafe, long base, int index) throws Exception { return unsafe.getInt(base + (index >> 2)); } - public static int int_index_back_lshift(sun.misc.Unsafe unsafe, long base, int index) throws Exception { + public static int int_index_back_lshift(Unsafe unsafe, long base, int index) throws Exception { return unsafe.getInt(base + (index >>> 2)); } - public static int long_index_back_ashift(sun.misc.Unsafe unsafe, long base, long index) throws Exception { + public static int long_index_back_ashift(Unsafe unsafe, long base, long index) throws Exception { return unsafe.getInt(base + (index >> 2)); } - public static int long_index_back_lshift(sun.misc.Unsafe unsafe, long base, long index) throws Exception { + public static int long_index_back_lshift(Unsafe unsafe, long base, long index) throws Exception { return unsafe.getInt(base + (index >>> 2)); } - public static int int_const_12345678_index(sun.misc.Unsafe unsafe, long base) throws Exception { + public static int int_const_12345678_index(Unsafe unsafe, long base) throws Exception { int idx4 = 0x12345678; return unsafe.getInt(base + idx4); } - public static int long_const_1234567890abcdef_index(sun.misc.Unsafe unsafe, long base) throws Exception { + public static int long_const_1234567890abcdef_index(Unsafe unsafe, long base) throws Exception { long idx5 = 0x1234567890abcdefL; return unsafe.getInt(base + idx5); } - public static int int_index_mul(sun.misc.Unsafe unsafe, long base, int index) throws Exception { + public static int int_index_mul(Unsafe unsafe, long base, int index) throws Exception { return unsafe.getInt(base + (index * 4)); } - public static int long_index_mul(sun.misc.Unsafe unsafe, long base, long index) throws Exception { + public static int long_index_mul(Unsafe unsafe, long base, long index) throws Exception { return unsafe.getInt(base + (index * 4)); } - public static int int_index_mul_scale_16(sun.misc.Unsafe unsafe, long base, int index) throws Exception { + public static int int_index_mul_scale_16(Unsafe unsafe, long base, int index) throws Exception { return unsafe.getInt(base + (index * 16)); } - public static int long_index_mul_scale_16(sun.misc.Unsafe unsafe, long base, long index) throws Exception { + public static int long_index_mul_scale_16(Unsafe unsafe, long base, long index) throws Exception { return unsafe.getInt(base + (index * 16)); } } public static void main(String[] args) throws Exception { - sun.misc.Unsafe unsafe = Utils.getUnsafe(); + Unsafe unsafe = Utils.getUnsafe(); final int array_size = 128; final int element_size = 4; final int magic = 0x12345678; diff --git a/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java b/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java index 8968d3f2645..db371183ddb 100644 --- a/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java +++ b/hotspot/test/compiler/whitebox/AllocationCodeBlobTest.java @@ -35,6 +35,7 @@ import jdk.test.lib.InfiniteLoop; * @test AllocationCodeBlobTest * @bug 8059624 8064669 * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management * @build AllocationCodeBlobTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/BlockingCompilation.java b/hotspot/test/compiler/whitebox/BlockingCompilation.java index d960ff4264a..027d64dc91f 100644 --- a/hotspot/test/compiler/whitebox/BlockingCompilation.java +++ b/hotspot/test/compiler/whitebox/BlockingCompilation.java @@ -25,6 +25,7 @@ * @test * @bug 8150646 * @summary Add support for blocking compiles through whitebox API + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib / * @build sun.hotspot.WhiteBox * compiler.testlibrary.CompilerUtils diff --git a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java index 8df5e9de4a0..38eb99a672e 100644 --- a/hotspot/test/compiler/whitebox/ClearMethodStateTest.java +++ b/hotspot/test/compiler/whitebox/ClearMethodStateTest.java @@ -29,6 +29,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @test ClearMethodStateTest * @bug 8006683 8007288 8022832 * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build ClearMethodStateTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java index 7d56a52319e..e47914968d9 100644 --- a/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java +++ b/hotspot/test/compiler/whitebox/DeoptimizeAllTest.java @@ -27,6 +27,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @test DeoptimizeAllTest * @bug 8006683 8007288 8022832 * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build DeoptimizeAllTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java b/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java index 8dd85ad114e..ce210944ad8 100644 --- a/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java +++ b/hotspot/test/compiler/whitebox/DeoptimizeFramesTest.java @@ -27,6 +27,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @test DeoptimizeFramesTest * @bug 8028595 * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build DeoptimizeFramesTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java index fa543d99730..71ef586df6f 100644 --- a/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java +++ b/hotspot/test/compiler/whitebox/DeoptimizeMethodTest.java @@ -27,6 +27,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @test DeoptimizeMethodTest * @bug 8006683 8007288 8022832 * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build DeoptimizeMethodTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/DeoptimizeMultipleOSRTest.java b/hotspot/test/compiler/whitebox/DeoptimizeMultipleOSRTest.java index dfd5dd2a10a..82397fe18b5 100644 --- a/hotspot/test/compiler/whitebox/DeoptimizeMultipleOSRTest.java +++ b/hotspot/test/compiler/whitebox/DeoptimizeMultipleOSRTest.java @@ -30,6 +30,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @test DeoptimizeMultipleOSRTest * @bug 8061817 * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build DeoptimizeMultipleOSRTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java index b1e40036e4d..3bf0a1de446 100644 --- a/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java +++ b/hotspot/test/compiler/whitebox/EnqueueMethodForCompilationTest.java @@ -27,6 +27,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @test EnqueueMethodForCompilationTest * @bug 8006683 8007288 8022832 * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build EnqueueMethodForCompilationTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java index 593c60ac68e..ea22e257c83 100644 --- a/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java +++ b/hotspot/test/compiler/whitebox/ForceNMethodSweepTest.java @@ -36,6 +36,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @test * @bug 8059624 8064669 8153265 * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build ForceNMethodSweepTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java b/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java index 963258545bc..8b2acf48e28 100644 --- a/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java +++ b/hotspot/test/compiler/whitebox/GetCodeHeapEntriesTest.java @@ -34,6 +34,7 @@ import jdk.test.lib.Asserts; * @test GetCodeHeapEntriesTest * @bug 8059624 * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management * @build GetCodeHeapEntriesTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/GetNMethodTest.java b/hotspot/test/compiler/whitebox/GetNMethodTest.java index 80a70f86349..bb9f9fc08f6 100644 --- a/hotspot/test/compiler/whitebox/GetNMethodTest.java +++ b/hotspot/test/compiler/whitebox/GetNMethodTest.java @@ -31,6 +31,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @test GetNMethodTest * @bug 8038240 * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build GetNMethodTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/LockCompilationTest.java b/hotspot/test/compiler/whitebox/LockCompilationTest.java index 7aae5bfe17a..eb04651588f 100644 --- a/hotspot/test/compiler/whitebox/LockCompilationTest.java +++ b/hotspot/test/compiler/whitebox/LockCompilationTest.java @@ -25,6 +25,7 @@ * @test LockCompilationTest * @bug 8059624 8152169 * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build LockCompilationTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java index 7ebc004bb42..ba06694bd2a 100644 --- a/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java +++ b/hotspot/test/compiler/whitebox/MakeMethodNotCompilableTest.java @@ -27,6 +27,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @test MakeMethodNotCompilableTest * @bug 8012322 8006683 8007288 8022832 * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build MakeMethodNotCompilableTest * @run driver ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java b/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java index fb2a8bdd8f8..3ba7b7797b8 100644 --- a/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java +++ b/hotspot/test/compiler/whitebox/SetDontInlineMethodTest.java @@ -27,6 +27,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @test SetDontInlineMethodTest * @bug 8006683 8007288 8022832 * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build SetDontInlineMethodTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java b/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java index 55856c259d3..c04f234dea2 100644 --- a/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java +++ b/hotspot/test/compiler/whitebox/SetForceInlineMethodTest.java @@ -27,6 +27,7 @@ import compiler.whitebox.CompilerWhiteBoxTest; * @test SetForceInlineMethodTest * @bug 8006683 8007288 8022832 * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build SetForceInlineMethodTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/CondCardMark/Basic.java b/hotspot/test/gc/CondCardMark/Basic.java index f936ce88210..a6cc3a02cbf 100644 --- a/hotspot/test/gc/CondCardMark/Basic.java +++ b/hotspot/test/gc/CondCardMark/Basic.java @@ -26,6 +26,7 @@ * @bug 8076987 * @bug 8078438 * @summary Verify UseCondCardMark works + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build Basic * @run main/othervm -Xint Basic diff --git a/hotspot/test/gc/TestDisableExplicitGC.java b/hotspot/test/gc/TestDisableExplicitGC.java index ebe98b1315b..316f50c4314 100644 --- a/hotspot/test/gc/TestDisableExplicitGC.java +++ b/hotspot/test/gc/TestDisableExplicitGC.java @@ -26,6 +26,7 @@ * @requires vm.opt.DisableExplicitGC == null * @summary Verify GC behavior with DisableExplicitGC flag. * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules jdk.management/com.sun.management.internal * @run main/othervm -Xlog:gc=debug TestDisableExplicitGC * @run main/othervm/fail -XX:+DisableExplicitGC -Xlog:gc=debug TestDisableExplicitGC diff --git a/hotspot/test/gc/TestSmallHeap.java b/hotspot/test/gc/TestSmallHeap.java index ffafa078a71..9c0dba31fc0 100644 --- a/hotspot/test/gc/TestSmallHeap.java +++ b/hotspot/test/gc/TestSmallHeap.java @@ -30,6 +30,7 @@ * @requires vm.opt.UseCompressedOops != false * @summary Verify that starting the VM with a small heap works * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management/sun.management * @ignore 8076621 * @build TestSmallHeap diff --git a/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java b/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java index 4d0a2953e88..91935810e6d 100644 --- a/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java +++ b/hotspot/test/gc/arguments/TestDynMaxHeapFreeRatio.java @@ -31,6 +31,7 @@ import jdk.test.lib.DynamicVMOption; * @bug 8028391 * @summary Verify that MaxHeapFreeRatio flag is manageable * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.management * @run main TestDynMaxHeapFreeRatio * @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 TestDynMaxHeapFreeRatio diff --git a/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java b/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java index 53a21a1e9f2..f8dca9b8223 100644 --- a/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java +++ b/hotspot/test/gc/arguments/TestDynMinHeapFreeRatio.java @@ -26,6 +26,7 @@ * @bug 8028391 * @summary Verify that MinHeapFreeRatio flag is manageable * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.management * @run main TestDynMinHeapFreeRatio * @run main/othervm -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 TestDynMinHeapFreeRatio diff --git a/hotspot/test/gc/arguments/TestG1HeapRegionSize.java b/hotspot/test/gc/arguments/TestG1HeapRegionSize.java index d25b19c3439..1864a472ea5 100644 --- a/hotspot/test/gc/arguments/TestG1HeapRegionSize.java +++ b/hotspot/test/gc/arguments/TestG1HeapRegionSize.java @@ -27,6 +27,7 @@ * @bug 8021879 * @requires vm.gc=="null" | vm.gc=="G1" * @summary Verify that the flag G1HeapRegionSize is updated properly + * @modules java.base/jdk.internal.misc * @modules java.management/sun.management * @library /testlibrary * @run main TestG1HeapRegionSize diff --git a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java index 19d03b28c97..85d0fcd6031 100644 --- a/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java +++ b/hotspot/test/gc/arguments/TestMaxMinHeapFreeRatioFlags.java @@ -39,7 +39,7 @@ import jdk.test.lib.OutputAnalyzer; import jdk.test.lib.ProcessTools; import jdk.test.lib.Utils; import jdk.test.lib.HeapRegionUsageTool; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class TestMaxMinHeapFreeRatioFlags { @@ -88,6 +88,7 @@ public class TestMaxMinHeapFreeRatioFlags { (useXmaxf ? "-Xmaxf" + maxRatio / 100.0 : "-XX:MaxHeapFreeRatio=" + maxRatio), "-Xmx" + MAX_HEAP_SIZE, "-Xms" + HEAP_SIZE, + "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:NewSize=" + NEW_SIZE, "-XX:MaxNewSize=" + MAX_NEW_SIZE, "-XX:" + (shrinkHeapInSteps ? '+' : '-') + "ShrinkHeapInSteps", @@ -119,6 +120,7 @@ public class TestMaxMinHeapFreeRatioFlags { Collections.addAll(vmOptions, (useXminf ? "-Xminf" + minRatio / 100.0 : "-XX:MinHeapFreeRatio=" + minRatio), (useXmaxf ? "-Xmaxf" + maxRatio / 100.0 : "-XX:MaxHeapFreeRatio=" + maxRatio), + "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", "-version" ); ProcessBuilder procBuilder = ProcessTools.createJavaProcessBuilder(vmOptions.toArray(new String[vmOptions.size()])); diff --git a/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java b/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java index 2e386c2f6d2..2891eb1daa5 100644 --- a/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java +++ b/hotspot/test/gc/arguments/TestSurvivorRatioFlag.java @@ -74,6 +74,7 @@ public class TestSurvivorRatioFlag { Collections.addAll(vmOptions, "-Xbootclasspath/a:.", + "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:GCLockerEdenExpansionPercent=0", diff --git a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java index b1198e77251..aadb620ef9d 100644 --- a/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java +++ b/hotspot/test/gc/arguments/TestTargetSurvivorRatioFlag.java @@ -42,7 +42,7 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; import jdk.test.lib.HeapRegionUsageTool; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import jdk.test.lib.OutputAnalyzer; import jdk.test.lib.ProcessTools; import jdk.test.lib.Utils; @@ -130,6 +130,7 @@ public class TestTargetSurvivorRatioFlag { LinkedList vmOptions = new LinkedList<>(options); Collections.addAll(vmOptions, "-Xbootclasspath/a:.", + "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", "-XX:+UseAdaptiveSizePolicy", diff --git a/hotspot/test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java b/hotspot/test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java index 3706d955bda..d092c11dbca 100644 --- a/hotspot/test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java +++ b/hotspot/test/gc/arguments/TestVerifyBeforeAndAfterGCFlags.java @@ -28,6 +28,7 @@ * @summary Runs an simple application (GarbageProducer) with various combinations of -XX:{+|-}Verify{After|Before}GC flags and checks that output contain or doesn't contain expected patterns + * @modules java.base/jdk.internal.misc * @modules java.management * @library /testlibrary * @run driver TestVerifyBeforeAndAfterGCFlags diff --git a/hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java b/hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java index 1cd9e1191de..7b262fd3723 100644 --- a/hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java +++ b/hotspot/test/gc/ergonomics/TestDynamicNumberOfGCThreads.java @@ -27,6 +27,7 @@ * @summary Ensure that UseDynamicNumberOfGCThreads runs * @requires vm.gc=="null" * @key gc + * @modules java.base/jdk.internal.misc * @library /testlibrary */ diff --git a/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java b/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java index 2173dbdb9f4..a7a34442814 100644 --- a/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java +++ b/hotspot/test/gc/g1/TestHumongousAllocNearlyFullRegion.java @@ -26,6 +26,7 @@ * @bug 8143587 * @summary G1: humongous object allocations should work even when there is * not enough space in the heapRegion to fit a filler object. + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run driver TestHumongousAllocNearlyFullRegion */ diff --git a/hotspot/test/gc/g1/TestHumongousShrinkHeap.java b/hotspot/test/gc/g1/TestHumongousShrinkHeap.java index a689fbc955d..da1c08a1be8 100644 --- a/hotspot/test/gc/g1/TestHumongousShrinkHeap.java +++ b/hotspot/test/gc/g1/TestHumongousShrinkHeap.java @@ -28,6 +28,7 @@ * @summary Verify that heap shrinks after GC in the presence of fragmentation * due to humongous objects * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.management/sun.management * @run main/othervm -XX:-ExplicitGCInvokesConcurrent -XX:MinHeapFreeRatio=10 * -XX:MaxHeapFreeRatio=12 -XX:+UseG1GC -XX:G1HeapRegionSize=1M -verbose:gc diff --git a/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java b/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java index 28f1b166a4d..463fadcbbb8 100644 --- a/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java +++ b/hotspot/test/gc/g1/TestLargePageUseForAuxMemory.java @@ -26,6 +26,7 @@ * @summary Test that auxiliary data structures are allocated using large pages if available. * @bug 8058354 8079208 * @key gc + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @requires (vm.gc=="G1" | vm.gc=="null") * @build jdk.test.lib.* sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/g1/TestPLABOutput.java b/hotspot/test/gc/g1/TestPLABOutput.java index 4b85b1cbcd6..f7d7cebf89c 100644 --- a/hotspot/test/gc/g1/TestPLABOutput.java +++ b/hotspot/test/gc/g1/TestPLABOutput.java @@ -27,6 +27,7 @@ * @summary Check that G1 does not report empty PLAB statistics in the first evacuation. * @requires vm.gc=="G1" | vm.gc=="null" * @key gc + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java index 65247c6edf4..1600989394e 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData.java @@ -36,7 +36,7 @@ import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.List; -import sun.misc.Unsafe; // for ADDRESS_SIZE +import jdk.internal.misc.Unsafe; // for ADDRESS_SIZE import sun.hotspot.WhiteBox; public class TestShrinkAuxiliaryData { @@ -52,6 +52,7 @@ public class TestShrinkAuxiliaryData { "-Xlog:gc=debug", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", + "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", "-Xbootclasspath/a:.", }; diff --git a/hotspot/test/gc/g1/humongousObjects/TestHeapCounters.java b/hotspot/test/gc/g1/humongousObjects/TestHeapCounters.java index d843d35dff4..7fe5262b7f8 100644 --- a/hotspot/test/gc/g1/humongousObjects/TestHeapCounters.java +++ b/hotspot/test/gc/g1/humongousObjects/TestHeapCounters.java @@ -39,6 +39,7 @@ import java.util.List; * @summary Checks that heap counters work as expected after humongous allocations/deallocations * @requires vm.gc=="G1" | vm.gc=="null" * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build sun.hotspot.WhiteBox * gc.testlibrary.Helpers diff --git a/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java index 3e6fa990eab..03952363fb4 100644 --- a/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java +++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousClassLoader.java @@ -42,6 +42,7 @@ import java.nio.file.Paths; * @requires vm.opt.G1HeapRegionSize == "null" | vm.opt.G1HeapRegionSize == "1M" * @requires vm.opt.ExplicitGCInvokesConcurrent != true * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build sun.hotspot.WhiteBox * gc.testlibrary.Helpers diff --git a/hotspot/test/gc/g1/humongousObjects/TestHumongousMovement.java b/hotspot/test/gc/g1/humongousObjects/TestHumongousMovement.java index 66ca21bf05e..a7d1cc852e8 100644 --- a/hotspot/test/gc/g1/humongousObjects/TestHumongousMovement.java +++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousMovement.java @@ -41,6 +41,7 @@ import java.util.stream.Collectors; * @summary Checks that Humongous objects are not moved during GC * @requires vm.gc=="G1" | vm.gc=="null" * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build sun.hotspot.WhiteBox * gc.testlibrary.Helpers diff --git a/hotspot/test/gc/g1/humongousObjects/TestHumongousNonArrayAllocation.java b/hotspot/test/gc/g1/humongousObjects/TestHumongousNonArrayAllocation.java index 118c3114b0c..e1ad30c56f0 100644 --- a/hotspot/test/gc/g1/humongousObjects/TestHumongousNonArrayAllocation.java +++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousNonArrayAllocation.java @@ -40,6 +40,7 @@ import java.nio.file.Paths; * @requires vm.gc=="G1" | vm.gc=="null" * @requires vm.opt.G1HeapRegionSize == "null" | vm.opt.G1HeapRegionSize == "1M" * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build sun.hotspot.WhiteBox * gc.testlibrary.Helpers diff --git a/hotspot/test/gc/g1/humongousObjects/TestHumongousThreshold.java b/hotspot/test/gc/g1/humongousObjects/TestHumongousThreshold.java index 3b66bc7507c..8ff4a568600 100644 --- a/hotspot/test/gc/g1/humongousObjects/TestHumongousThreshold.java +++ b/hotspot/test/gc/g1/humongousObjects/TestHumongousThreshold.java @@ -33,6 +33,7 @@ import sun.hotspot.WhiteBox; * @summary Checks that objects larger than half a region are allocated as humongous * @requires vm.gc=="G1" | vm.gc=="null" * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build sun.hotspot.WhiteBox * gc.testlibrary.Helpers diff --git a/hotspot/test/gc/g1/humongousObjects/TestObjectCollected.java b/hotspot/test/gc/g1/humongousObjects/TestObjectCollected.java index be17365da8a..f5f5484b946 100644 --- a/hotspot/test/gc/g1/humongousObjects/TestObjectCollected.java +++ b/hotspot/test/gc/g1/humongousObjects/TestObjectCollected.java @@ -39,6 +39,7 @@ import java.lang.ref.WeakReference; * actual object behavior * @requires vm.gc=="G1" | vm.gc=="null" * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build sun.hotspot.WhiteBox * gc.testlibrary.Helpers diff --git a/hotspot/test/gc/g1/ihop/TestIHOPErgo.java b/hotspot/test/gc/g1/ihop/TestIHOPErgo.java index 10299299c73..95609b84d4d 100644 --- a/hotspot/test/gc/g1/ihop/TestIHOPErgo.java +++ b/hotspot/test/gc/g1/ihop/TestIHOPErgo.java @@ -29,6 +29,7 @@ * @requires vm.opt.FlightRecorder != true * @requires vm.opt.ExplicitGCInvokesConcurrent != true * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build gc.g1.ihop.TestIHOPErgo * gc.g1.ihop.lib.IhopUtils diff --git a/hotspot/test/gc/g1/ihop/TestIHOPStatic.java b/hotspot/test/gc/g1/ihop/TestIHOPStatic.java index 4e91a95c089..efbe6d6ab69 100644 --- a/hotspot/test/gc/g1/ihop/TestIHOPStatic.java +++ b/hotspot/test/gc/g1/ihop/TestIHOPStatic.java @@ -29,6 +29,7 @@ * @requires vm.opt.FlightRecorder != true * @requires vm.opt.ExplicitGCInvokesConcurrent != true * @library /testlibrary / + * @modules java.base/jdk.internal.misc * @modules java.management * @build gc.g1.ihop.TestIHOPStatic * gc.g1.ihop.lib.IhopUtils diff --git a/hotspot/test/gc/g1/mixedgc/TestLogging.java b/hotspot/test/gc/g1/mixedgc/TestLogging.java index f1eff8c41e5..f99fdbd21a4 100644 --- a/hotspot/test/gc/g1/mixedgc/TestLogging.java +++ b/hotspot/test/gc/g1/mixedgc/TestLogging.java @@ -26,6 +26,7 @@ * @summary Check that a mixed GC is reflected in the gc logs * @requires vm.gc=="G1" | vm.gc=="null" * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management * @build sun.hotspot.WhiteBox gc.g1.mixedgc.TestLogging * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/g1/plab/TestPLABEvacuationFailure.java b/hotspot/test/gc/g1/plab/TestPLABEvacuationFailure.java index 5bcad7f2404..6aa5834a79f 100644 --- a/hotspot/test/gc/g1/plab/TestPLABEvacuationFailure.java +++ b/hotspot/test/gc/g1/plab/TestPLABEvacuationFailure.java @@ -27,6 +27,7 @@ * @summary Checks PLAB statistics on evacuation failure * @requires vm.gc=="G1" | vm.gc=="null" * @library /testlibrary / + * @modules java.base/jdk.internal.misc * @modules java.management * @build gc.g1.plab.lib.LogParser * gc.g1.plab.lib.AppPLABEvacuationFailure diff --git a/hotspot/test/gc/g1/plab/TestPLABPromotion.java b/hotspot/test/gc/g1/plab/TestPLABPromotion.java index 7af09694dfa..3664897ea83 100644 --- a/hotspot/test/gc/g1/plab/TestPLABPromotion.java +++ b/hotspot/test/gc/g1/plab/TestPLABPromotion.java @@ -28,6 +28,7 @@ * @requires vm.gc=="G1" | vm.gc=="null" * @requires vm.opt.FlightRecorder != true * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build ClassFileInstaller * sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/g1/plab/TestPLABResize.java b/hotspot/test/gc/g1/plab/TestPLABResize.java index 71e00bbae8e..f3ac2aad802 100644 --- a/hotspot/test/gc/g1/plab/TestPLABResize.java +++ b/hotspot/test/gc/g1/plab/TestPLABResize.java @@ -28,6 +28,7 @@ * @requires vm.gc=="G1" | vm.gc=="null" * @requires vm.opt.FlightRecorder != true * @library /testlibrary /test/lib / + * @modules java.base/jdk.internal.misc * @modules java.management * @build ClassFileInstaller * sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/metaspace/TestMetaspaceInitialization.java b/hotspot/test/gc/metaspace/TestMetaspaceInitialization.java index c7bbcec0829..e38ef160acd 100644 --- a/hotspot/test/gc/metaspace/TestMetaspaceInitialization.java +++ b/hotspot/test/gc/metaspace/TestMetaspaceInitialization.java @@ -26,6 +26,7 @@ import java.util.ArrayList; /* @test TestMetaspaceInitialization * @bug 8042933 * @summary Tests to initialize metaspace with a very low MetaspaceSize + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm -XX:MetaspaceSize=2m TestMetaspaceInitialization */ diff --git a/hotspot/test/gc/parallel/TestDynShrinkHeap.java b/hotspot/test/gc/parallel/TestDynShrinkHeap.java index ef2a6b41f62..809706f8e32 100644 --- a/hotspot/test/gc/parallel/TestDynShrinkHeap.java +++ b/hotspot/test/gc/parallel/TestDynShrinkHeap.java @@ -26,6 +26,7 @@ * @bug 8016479 * @requires vm.gc=="Parallel" | vm.gc=="null" * @summary Verify that the heap shrinks after full GC according to the current values of the Min/MaxHeapFreeRatio flags + * @modules java.base/jdk.internal.misc * @modules jdk.management * @library /testlibrary * @run main/othervm -XX:+UseAdaptiveSizePolicyWithSystemGC -XX:+UseParallelGC -XX:MinHeapFreeRatio=0 -XX:MaxHeapFreeRatio=100 -Xmx1g -verbose:gc TestDynShrinkHeap diff --git a/hotspot/test/gc/parallel/TestPrintGCDetailsVerbose.java b/hotspot/test/gc/parallel/TestPrintGCDetailsVerbose.java index 1a7501e0981..17fd5ece8b2 100644 --- a/hotspot/test/gc/parallel/TestPrintGCDetailsVerbose.java +++ b/hotspot/test/gc/parallel/TestPrintGCDetailsVerbose.java @@ -27,6 +27,7 @@ * @summary Tests that jvm with maximally verbose GC logging does not crash when ParOldGC has no memory * @key gc * @requires vm.gc=="Parallel" | vm.gc=="null" + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm -Xmx50m -XX:+UseParallelGC -Xlog:gc*=trace TestPrintGCDetailsVerbose */ diff --git a/hotspot/test/gc/stress/TestMultiThreadStressRSet.java b/hotspot/test/gc/stress/TestMultiThreadStressRSet.java index 8947cb7237e..5a69888a502 100644 --- a/hotspot/test/gc/stress/TestMultiThreadStressRSet.java +++ b/hotspot/test/gc/stress/TestMultiThreadStressRSet.java @@ -35,6 +35,7 @@ import sun.hotspot.WhiteBox; * @requires os.maxMemory > 2G * * @summary Stress G1 Remembered Set using multiple threads + * @modules java.base/jdk.internal.misc * @library /test/lib /testlibrary * @build sun.hotspot.WhiteBox * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/gc/survivorAlignment/SurvivorAlignmentTestMain.java b/hotspot/test/gc/survivorAlignment/SurvivorAlignmentTestMain.java index 5b7e167c90b..8be8115cfe2 100644 --- a/hotspot/test/gc/survivorAlignment/SurvivorAlignmentTestMain.java +++ b/hotspot/test/gc/survivorAlignment/SurvivorAlignmentTestMain.java @@ -31,7 +31,7 @@ import java.util.regex.Pattern; import jdk.test.lib.Asserts; import com.sun.management.ThreadMXBean; import sun.hotspot.WhiteBox; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Main class for tests on {@code SurvivorAlignmentInBytes} option. diff --git a/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java b/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java index c84bf5c1806..a9f69d60f38 100644 --- a/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java +++ b/hotspot/test/runtime/8026365/InvokeSpecialAnonTest.java @@ -35,7 +35,7 @@ */ import jdk.internal.org.objectweb.asm.*; import java.lang.reflect.Constructor; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class InvokeSpecialAnonTest implements Opcodes { diff --git a/hotspot/test/runtime/BoolReturn/NativeSmallIntCallsTest.java b/hotspot/test/runtime/BoolReturn/NativeSmallIntCallsTest.java index d911435382a..6ce8cb1252c 100644 --- a/hotspot/test/runtime/BoolReturn/NativeSmallIntCallsTest.java +++ b/hotspot/test/runtime/BoolReturn/NativeSmallIntCallsTest.java @@ -24,6 +24,7 @@ /* @test * @bug 8149170 * @summary Test native functions return booleans as 0/1 but differently than java functions + * @modules java.base/jdk.internal.misc * @library /testlibrary * @compile BoolConstructor.java * @run main/native NativeSmallIntCallsTest diff --git a/hotspot/test/runtime/ClassUnload/KeepAliveClass.java b/hotspot/test/runtime/ClassUnload/KeepAliveClass.java index a1080269447..9c0b50cbe7e 100644 --- a/hotspot/test/runtime/ClassUnload/KeepAliveClass.java +++ b/hotspot/test/runtime/ClassUnload/KeepAliveClass.java @@ -24,6 +24,7 @@ /* * @test KeepAliveClass * @summary This test case uses a java.lang.Class instance to keep a class alive. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /runtime/testlibrary * @library classes * @build KeepAliveClass test.Empty diff --git a/hotspot/test/runtime/ClassUnload/KeepAliveClassLoader.java b/hotspot/test/runtime/ClassUnload/KeepAliveClassLoader.java index 21e92a108f2..ec8fa0d621b 100644 --- a/hotspot/test/runtime/ClassUnload/KeepAliveClassLoader.java +++ b/hotspot/test/runtime/ClassUnload/KeepAliveClassLoader.java @@ -24,6 +24,7 @@ /* * @test KeepAliveClassLoader * @summary This test case uses a java.lang.ClassLoader instance to keep a class alive. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /runtime/testlibrary * @library classes * @build KeepAliveClassLoader test.Empty diff --git a/hotspot/test/runtime/ClassUnload/KeepAliveObject.java b/hotspot/test/runtime/ClassUnload/KeepAliveObject.java index 4a8ffb70000..aca13b0ea0f 100644 --- a/hotspot/test/runtime/ClassUnload/KeepAliveObject.java +++ b/hotspot/test/runtime/ClassUnload/KeepAliveObject.java @@ -24,6 +24,7 @@ /* * @test KeepAliveObject * @summary This test case uses a class instance to keep the class alive. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /runtime/testlibrary * @library classes * @build KeepAliveObject test.Empty diff --git a/hotspot/test/runtime/ClassUnload/KeepAliveSoftReference.java b/hotspot/test/runtime/ClassUnload/KeepAliveSoftReference.java index 0aa3547fc3f..e6321a5ff5f 100644 --- a/hotspot/test/runtime/ClassUnload/KeepAliveSoftReference.java +++ b/hotspot/test/runtime/ClassUnload/KeepAliveSoftReference.java @@ -24,6 +24,7 @@ /* * @test KeepAliveSoftReference * @summary This test case uses a java.lang.ref.SoftReference referencing a class instance to keep a class alive. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /runtime/testlibrary * @library classes * @build KeepAliveSoftReference test.Empty diff --git a/hotspot/test/runtime/ClassUnload/UnloadTest.java b/hotspot/test/runtime/ClassUnload/UnloadTest.java index cb8f0526329..eada2704506 100644 --- a/hotspot/test/runtime/ClassUnload/UnloadTest.java +++ b/hotspot/test/runtime/ClassUnload/UnloadTest.java @@ -23,6 +23,7 @@ /* * @test UnloadTest + * @modules java.base/jdk.internal.misc * @library /runtime/testlibrary /testlibrary /test/lib * @library classes * @build ClassUnloadCommon test.Empty diff --git a/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java b/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java index b65df44590f..f2401c778d4 100644 --- a/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java +++ b/hotspot/test/runtime/CommandLine/ObsoleteFlagErrorMessage.java @@ -25,6 +25,7 @@ * @test * @bug 8060449 8073989 * @summary Newly obsolete command line options should still give useful error messages when used improperly. + * @modules java.base/jdk.internal.misc * @library /testlibrary */ diff --git a/hotspot/test/runtime/CommandLine/TestLongUnrecognizedVMOption.java b/hotspot/test/runtime/CommandLine/TestLongUnrecognizedVMOption.java index 321a435af6f..3566e5936e2 100644 --- a/hotspot/test/runtime/CommandLine/TestLongUnrecognizedVMOption.java +++ b/hotspot/test/runtime/CommandLine/TestLongUnrecognizedVMOption.java @@ -26,6 +26,7 @@ * @bug 8129786 * @summary Verify that JVM correctly processes very long unrecognized VM option * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.management * @run main TestLongUnrecognizedVMOption */ diff --git a/hotspot/test/runtime/CommandLine/VMAliasOptions.java b/hotspot/test/runtime/CommandLine/VMAliasOptions.java index fbb350611b3..ee516b9e9d2 100644 --- a/hotspot/test/runtime/CommandLine/VMAliasOptions.java +++ b/hotspot/test/runtime/CommandLine/VMAliasOptions.java @@ -28,6 +28,7 @@ import jdk.test.lib.cli.*; * @test * @bug 8061611 * @summary Test that various alias options correctly set the target options. See aliased_jvm_flags in arguments.cpp. + * @modules java.base/jdk.internal.misc * @library /testlibrary */ public class VMAliasOptions { diff --git a/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java b/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java index 2b568c0e6a2..5ea7653b7b9 100644 --- a/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java +++ b/hotspot/test/runtime/CommandLine/VMDeprecatedOptions.java @@ -28,6 +28,7 @@ import jdk.test.lib.cli.*; * @test * @bug 8066821 * @summary Test that various options are deprecated. See deprecated_jvm_flags in arguments.cpp. + * @modules java.base/jdk.internal.misc * @library /testlibrary */ public class VMDeprecatedOptions { diff --git a/hotspot/test/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java b/hotspot/test/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java index de7ed44b05a..0049548897f 100644 --- a/hotspot/test/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java +++ b/hotspot/test/runtime/CommandLine/VMOptionsFile/TestVMOptionsFile.java @@ -26,6 +26,7 @@ * @bug 8061999 8135195 8136552 * @summary Test "-XX:VMOptionsFile" VM option * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules jdk.management * @run main TestVMOptionsFile */ diff --git a/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java b/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java index 299444ffba3..a864f4d3c90 100644 --- a/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java +++ b/hotspot/test/runtime/ErrorHandling/CreateCoredumpOnCrash.java @@ -33,7 +33,7 @@ */ import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class CreateCoredumpOnCrash { private static class Crasher { @@ -56,7 +56,7 @@ public class CreateCoredumpOnCrash { public static OutputAnalyzer runTest(String option) throws Exception { return new OutputAnalyzer( ProcessTools.createJavaProcessBuilder( - "-Xmx64m", "-XX:-TransmitErrorReport", option, Crasher.class.getName()) + "-Xmx64m", "-XX:-TransmitErrorReport", "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", option, Crasher.class.getName()) .start()); } } diff --git a/hotspot/test/runtime/ErrorHandling/ErrorHandler.java b/hotspot/test/runtime/ErrorHandling/ErrorHandler.java index deabd01755f..ba5cdbc7ab9 100644 --- a/hotspot/test/runtime/ErrorHandling/ErrorHandler.java +++ b/hotspot/test/runtime/ErrorHandling/ErrorHandler.java @@ -27,6 +27,7 @@ * @bug 8015884 * @summary Exercise HotSpot error handling code by invoking java with * -XX:ErrorHandlerTest option to cause an error report. Check the results. + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run driver ErrorHandler */ diff --git a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java index 85a0749bd7a..df6b9cea1fe 100644 --- a/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java +++ b/hotspot/test/runtime/ErrorHandling/ProblematicFrameTest.java @@ -36,7 +36,7 @@ import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import jdk.test.lib.Utils; public class ProblematicFrameTest { diff --git a/hotspot/test/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java b/hotspot/test/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java index 27bcab55c1f..c34e56a49a4 100644 --- a/hotspot/test/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java +++ b/hotspot/test/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java @@ -35,6 +35,7 @@ import jdk.test.lib.ProcessTools; * @test * @bug 8074552 * @summary SafeFetch32 and SafeFetchN do not work in error handling + * @modules java.base/jdk.internal.misc * @library /testlibrary * @author Thomas Stuefe (SAP) */ diff --git a/hotspot/test/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java b/hotspot/test/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java index 0a6e82dcd3c..d658401de68 100644 --- a/hotspot/test/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java +++ b/hotspot/test/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java @@ -24,6 +24,7 @@ /* * @test TestCrashOnOutOfMemoryError * @summary Test using -XX:+CrashOnOutOfMemoryError + * @modules java.base/jdk.internal.misc * @library /testlibrary * @build jdk.test.lib.* * @run driver TestCrashOnOutOfMemoryError diff --git a/hotspot/test/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java b/hotspot/test/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java index 2f266da6c5d..79d064f6df8 100644 --- a/hotspot/test/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java +++ b/hotspot/test/runtime/ErrorHandling/TestExitOnOutOfMemoryError.java @@ -24,6 +24,7 @@ /* * @test TestExitOnOutOfMemoryError * @summary Test using -XX:ExitOnOutOfMemoryError + * @modules java.base/jdk.internal.misc * @library /testlibrary * @build jdk.test.lib.* * @run driver TestExitOnOutOfMemoryError diff --git a/hotspot/test/runtime/ErrorHandling/TestOnError.java b/hotspot/test/runtime/ErrorHandling/TestOnError.java index 4e8763f662e..4fa5c44c32b 100644 --- a/hotspot/test/runtime/ErrorHandling/TestOnError.java +++ b/hotspot/test/runtime/ErrorHandling/TestOnError.java @@ -24,6 +24,7 @@ /* * @test TestOnError * @summary Test using -XX:OnError= + * @modules java.base/jdk.internal.misc * @library /testlibrary * @build TestOnError * @run main TestOnError diff --git a/hotspot/test/runtime/ErrorHandling/TestOnOutOfMemoryError.java b/hotspot/test/runtime/ErrorHandling/TestOnOutOfMemoryError.java index 775e1bf1d5b..c81cab5e699 100644 --- a/hotspot/test/runtime/ErrorHandling/TestOnOutOfMemoryError.java +++ b/hotspot/test/runtime/ErrorHandling/TestOnOutOfMemoryError.java @@ -24,6 +24,7 @@ /* * @test TestOnOutOfMemoryError * @summary Test using -XX:OnOutOfMemoryError= + * @modules java.base/jdk.internal.misc * @library /testlibrary * @build TestOnOutOfMemoryError * @run main TestOnOutOfMemoryError diff --git a/hotspot/test/runtime/Metaspace/FragmentMetaspace.java b/hotspot/test/runtime/Metaspace/FragmentMetaspace.java index d4423a38552..acd64cd3e25 100644 --- a/hotspot/test/runtime/Metaspace/FragmentMetaspace.java +++ b/hotspot/test/runtime/Metaspace/FragmentMetaspace.java @@ -24,6 +24,7 @@ /** * @test * @library /runtime/testlibrary + * @modules java.base/jdk.internal.misc * @modules java.compiler * @build GeneratedClassLoader * @run main/othervm/timeout=200 -Xmx300m FragmentMetaspace diff --git a/hotspot/test/runtime/NMT/ChangeTrackingLevel.java b/hotspot/test/runtime/NMT/ChangeTrackingLevel.java index a5e8beb4a36..e7905480665 100644 --- a/hotspot/test/runtime/NMT/ChangeTrackingLevel.java +++ b/hotspot/test/runtime/NMT/ChangeTrackingLevel.java @@ -26,6 +26,7 @@ * @bug 8059100 * @summary Test that you can decrease NMT tracking level but not increase it. * @key nmt + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build ChangeTrackingLevel * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java b/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java index bb22625ddee..3bb39aa0afe 100644 --- a/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java +++ b/hotspot/test/runtime/NMT/MallocSiteHashOverflow.java @@ -26,6 +26,7 @@ * @summary Test corner case that overflows malloc site hashtable bucket * @requires sun.arch.data.model == "32" * @key nmt jcmd stress + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build MallocSiteHashOverflow * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/runtime/NMT/PrintNMTStatistics.java b/hotspot/test/runtime/NMT/PrintNMTStatistics.java index 7966f23704d..413ade55e80 100644 --- a/hotspot/test/runtime/NMT/PrintNMTStatistics.java +++ b/hotspot/test/runtime/NMT/PrintNMTStatistics.java @@ -26,6 +26,7 @@ * @key nmt regression * @bug 8005936 8058606 * @summary Verify PrintNMTStatistics on normal JVM exit for detail and summary tracking level + * @modules java.base/jdk.internal.misc * @library /testlibrary */ diff --git a/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java b/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java index 8453d886ed8..c67b6227754 100644 --- a/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java +++ b/hotspot/test/runtime/NMT/ReleaseCommittedMemory.java @@ -26,6 +26,7 @@ * @bug 8013120 * @summary Release committed memory and make sure NMT handles it correctly * @key nmt regression + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build ReleaseCommittedMemory * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/runtime/RedefineTests/RedefineAnnotations.java b/hotspot/test/runtime/RedefineTests/RedefineAnnotations.java index 0593014f3ee..a759574aada 100644 --- a/hotspot/test/runtime/RedefineTests/RedefineAnnotations.java +++ b/hotspot/test/runtime/RedefineTests/RedefineAnnotations.java @@ -25,6 +25,7 @@ * @test * @library /testlibrary * @summary Test that type annotations are retained after a retransform + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.instrument * jdk.jartool/sun.tools.jar diff --git a/hotspot/test/runtime/RedefineTests/RedefineFinalizer.java b/hotspot/test/runtime/RedefineTests/RedefineFinalizer.java index 394e31c3907..de76aea5b1d 100644 --- a/hotspot/test/runtime/RedefineTests/RedefineFinalizer.java +++ b/hotspot/test/runtime/RedefineTests/RedefineFinalizer.java @@ -26,6 +26,7 @@ * @bug 6904403 * @summary Don't assert if we redefine finalize method * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.compiler * java.instrument * jdk.jartool/sun.tools.jar diff --git a/hotspot/test/runtime/RedefineTests/RedefineRunningMethods.java b/hotspot/test/runtime/RedefineTests/RedefineRunningMethods.java index 525d890b4b7..9921afb1809 100644 --- a/hotspot/test/runtime/RedefineTests/RedefineRunningMethods.java +++ b/hotspot/test/runtime/RedefineTests/RedefineRunningMethods.java @@ -26,6 +26,7 @@ * @bug 8055008 * @summary Redefine EMCP and non-EMCP methods that are running in an infinite loop * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.compiler * java.instrument * jdk.jartool/sun.tools.jar diff --git a/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java b/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java index d90007f3627..283d08ddc6b 100644 --- a/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java +++ b/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithBacktrace.java @@ -26,6 +26,7 @@ * @bug 8087315 * @summary Get old method's stack trace elements after GC * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.compiler * java.instrument * jdk.jartool/sun.tools.jar diff --git a/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithResolutionErrors.java b/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithResolutionErrors.java index 29247220f69..a56907ae0af 100644 --- a/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithResolutionErrors.java +++ b/hotspot/test/runtime/RedefineTests/RedefineRunningMethodsWithResolutionErrors.java @@ -26,6 +26,7 @@ * @bug 8076110 * @summary Redefine running methods that have cached resolution errors * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.org.objectweb.asm * java.instrument * jdk.jartool/sun.tools.jar diff --git a/hotspot/test/runtime/ReservedStack/ReservedStackTest.java b/hotspot/test/runtime/ReservedStack/ReservedStackTest.java index 43177dda31e..3c60d4709ce 100644 --- a/hotspot/test/runtime/ReservedStack/ReservedStackTest.java +++ b/hotspot/test/runtime/ReservedStack/ReservedStackTest.java @@ -24,6 +24,7 @@ /* * @test ReservedStackTest * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @build jdk.test.lib.* * @run main/othervm -XX:-Inline -XX:CompileCommand=exclude,java/util/concurrent/locks/AbstractOwnableSynchronizer.setExclusiveOwnerThread ReservedStackTest diff --git a/hotspot/test/runtime/SameObject/SameObject.java b/hotspot/test/runtime/SameObject/SameObject.java index 14ca5168ff2..10bb41d1a24 100644 --- a/hotspot/test/runtime/SameObject/SameObject.java +++ b/hotspot/test/runtime/SameObject/SameObject.java @@ -30,6 +30,7 @@ import jdk.test.lib.Asserts; * @summary -Xcheck:jni overly strict in JNI method IsSameObject * Fixed in JDK1.3.1_10 * Fixed in JDK1.4.1_07 + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm/native -Xcheck:jni SameObject */ diff --git a/hotspot/test/runtime/Thread/Fibonacci.java b/hotspot/test/runtime/Thread/Fibonacci.java index c8bbed1f980..65ae1c320b1 100644 --- a/hotspot/test/runtime/Thread/Fibonacci.java +++ b/hotspot/test/runtime/Thread/Fibonacci.java @@ -28,6 +28,7 @@ * This test is skipped on 32-bit Windows: limited virtual space on Win-32 * make this test inherently unstable on Windows with 32-bit VM data model. * @requires !(os.family == "windows" & sun.arch.data.model == "32") + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm Fibonacci 15 */ diff --git a/hotspot/test/runtime/ThreadSignalMask/ThreadSignalMask.java b/hotspot/test/runtime/ThreadSignalMask/ThreadSignalMask.java index 39af699218d..1670b02656f 100644 --- a/hotspot/test/runtime/ThreadSignalMask/ThreadSignalMask.java +++ b/hotspot/test/runtime/ThreadSignalMask/ThreadSignalMask.java @@ -36,6 +36,7 @@ import jdk.test.lib.Asserts; * @bug 4345157 * @summary JDK 1.3.0 alters thread signal mask * @requires (os.simpleArch == "sparcv9") + * @modules java.base/jdk.internal.misc * @library /testlibrary * @compile Prog.java * @run main/native ThreadSignalMask diff --git a/hotspot/test/runtime/Throwable/TestThrowable.java b/hotspot/test/runtime/Throwable/TestThrowable.java index f3cb1ad2bcc..9cdef2d4b89 100644 --- a/hotspot/test/runtime/Throwable/TestThrowable.java +++ b/hotspot/test/runtime/Throwable/TestThrowable.java @@ -25,6 +25,7 @@ * @test * @bug 8150778 * @summary Test exception depths, and code to get stack traces + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm -XX:MaxJavaStackTraceDepth=1024 TestThrowable */ diff --git a/hotspot/test/runtime/Throwable/ThrowableIntrospectionSegfault.java b/hotspot/test/runtime/Throwable/ThrowableIntrospectionSegfault.java index fd4be6c88e1..71f1dc22d46 100644 --- a/hotspot/test/runtime/Throwable/ThrowableIntrospectionSegfault.java +++ b/hotspot/test/runtime/Throwable/ThrowableIntrospectionSegfault.java @@ -25,6 +25,7 @@ * @test * @bug 8033735 * @summary check backtrace field introspection + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main ThrowableIntrospectionSegfault */ diff --git a/hotspot/test/runtime/Unsafe/AllocateInstance.java b/hotspot/test/runtime/Unsafe/AllocateInstance.java index e9748e539db..6b283d3556b 100644 --- a/hotspot/test/runtime/Unsafe/AllocateInstance.java +++ b/hotspot/test/runtime/Unsafe/AllocateInstance.java @@ -31,7 +31,7 @@ */ import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class AllocateInstance { diff --git a/hotspot/test/runtime/Unsafe/AllocateMemory.java b/hotspot/test/runtime/Unsafe/AllocateMemory.java index 0af6fcbf014..d9f8a122afb 100644 --- a/hotspot/test/runtime/Unsafe/AllocateMemory.java +++ b/hotspot/test/runtime/Unsafe/AllocateMemory.java @@ -32,7 +32,7 @@ */ import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class AllocateMemory { diff --git a/hotspot/test/runtime/Unsafe/CopyMemory.java b/hotspot/test/runtime/Unsafe/CopyMemory.java index ef67517c2a2..e2328d35851 100644 --- a/hotspot/test/runtime/Unsafe/CopyMemory.java +++ b/hotspot/test/runtime/Unsafe/CopyMemory.java @@ -31,7 +31,7 @@ */ import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class CopyMemory { diff --git a/hotspot/test/runtime/Unsafe/DefineClass.java b/hotspot/test/runtime/Unsafe/DefineClass.java index bf10a393d0e..fa0d3b64ccd 100644 --- a/hotspot/test/runtime/Unsafe/DefineClass.java +++ b/hotspot/test/runtime/Unsafe/DefineClass.java @@ -34,7 +34,7 @@ import java.security.ProtectionDomain; import java.io.InputStream; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class DefineClass { diff --git a/hotspot/test/runtime/Unsafe/FieldOffset.java b/hotspot/test/runtime/Unsafe/FieldOffset.java index 6bbd785019b..abf62fc1adc 100644 --- a/hotspot/test/runtime/Unsafe/FieldOffset.java +++ b/hotspot/test/runtime/Unsafe/FieldOffset.java @@ -32,7 +32,7 @@ import java.lang.reflect.Field; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.lang.reflect.*; import static jdk.test.lib.Asserts.*; diff --git a/hotspot/test/runtime/Unsafe/GetField.java b/hotspot/test/runtime/Unsafe/GetField.java index 48e71b58b02..f01d5deeb7d 100644 --- a/hotspot/test/runtime/Unsafe/GetField.java +++ b/hotspot/test/runtime/Unsafe/GetField.java @@ -31,7 +31,7 @@ */ import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import java.lang.reflect.*; import static jdk.test.lib.Asserts.*; diff --git a/hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java b/hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java index f1fc7d52331..7a53be5e7e5 100644 --- a/hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java +++ b/hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java @@ -32,7 +32,7 @@ import static jdk.test.lib.Asserts.*; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class GetKlassPointerGetJavaMirror { diff --git a/hotspot/test/runtime/Unsafe/GetPutAddress.java b/hotspot/test/runtime/Unsafe/GetPutAddress.java index 9650d040c72..1dd0a18de83 100644 --- a/hotspot/test/runtime/Unsafe/GetPutAddress.java +++ b/hotspot/test/runtime/Unsafe/GetPutAddress.java @@ -31,7 +31,7 @@ */ import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutAddress { diff --git a/hotspot/test/runtime/Unsafe/GetPutBoolean.java b/hotspot/test/runtime/Unsafe/GetPutBoolean.java index eddbc6c23ac..51e59cf4069 100644 --- a/hotspot/test/runtime/Unsafe/GetPutBoolean.java +++ b/hotspot/test/runtime/Unsafe/GetPutBoolean.java @@ -32,7 +32,7 @@ import java.lang.reflect.Field; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutBoolean { diff --git a/hotspot/test/runtime/Unsafe/GetPutByte.java b/hotspot/test/runtime/Unsafe/GetPutByte.java index ec08dd2ad85..48f4700d95d 100644 --- a/hotspot/test/runtime/Unsafe/GetPutByte.java +++ b/hotspot/test/runtime/Unsafe/GetPutByte.java @@ -32,7 +32,7 @@ import java.lang.reflect.Field; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutByte { diff --git a/hotspot/test/runtime/Unsafe/GetPutChar.java b/hotspot/test/runtime/Unsafe/GetPutChar.java index 79e94f0a6de..86b5c80cc36 100644 --- a/hotspot/test/runtime/Unsafe/GetPutChar.java +++ b/hotspot/test/runtime/Unsafe/GetPutChar.java @@ -32,7 +32,7 @@ import java.lang.reflect.Field; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutChar { diff --git a/hotspot/test/runtime/Unsafe/GetPutDouble.java b/hotspot/test/runtime/Unsafe/GetPutDouble.java index b1d7431e3b1..1073c8e1435 100644 --- a/hotspot/test/runtime/Unsafe/GetPutDouble.java +++ b/hotspot/test/runtime/Unsafe/GetPutDouble.java @@ -32,7 +32,7 @@ import java.lang.reflect.Field; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutDouble { diff --git a/hotspot/test/runtime/Unsafe/GetPutFloat.java b/hotspot/test/runtime/Unsafe/GetPutFloat.java index 16de792dac6..f49ac7541ed 100644 --- a/hotspot/test/runtime/Unsafe/GetPutFloat.java +++ b/hotspot/test/runtime/Unsafe/GetPutFloat.java @@ -32,7 +32,7 @@ import java.lang.reflect.Field; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutFloat { diff --git a/hotspot/test/runtime/Unsafe/GetPutInt.java b/hotspot/test/runtime/Unsafe/GetPutInt.java index 0a4403668aa..49f82d5d7b4 100644 --- a/hotspot/test/runtime/Unsafe/GetPutInt.java +++ b/hotspot/test/runtime/Unsafe/GetPutInt.java @@ -31,7 +31,7 @@ import java.lang.reflect.Field; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutInt { diff --git a/hotspot/test/runtime/Unsafe/GetPutLong.java b/hotspot/test/runtime/Unsafe/GetPutLong.java index 2c524e2e516..8336c858f6b 100644 --- a/hotspot/test/runtime/Unsafe/GetPutLong.java +++ b/hotspot/test/runtime/Unsafe/GetPutLong.java @@ -32,7 +32,7 @@ import java.lang.reflect.Field; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutLong { diff --git a/hotspot/test/runtime/Unsafe/GetPutObject.java b/hotspot/test/runtime/Unsafe/GetPutObject.java index e4add8f9e76..6607db3b8f6 100644 --- a/hotspot/test/runtime/Unsafe/GetPutObject.java +++ b/hotspot/test/runtime/Unsafe/GetPutObject.java @@ -32,7 +32,7 @@ import java.lang.reflect.Field; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutObject { diff --git a/hotspot/test/runtime/Unsafe/GetPutShort.java b/hotspot/test/runtime/Unsafe/GetPutShort.java index f7b94fb0e54..2ede76c1402 100644 --- a/hotspot/test/runtime/Unsafe/GetPutShort.java +++ b/hotspot/test/runtime/Unsafe/GetPutShort.java @@ -32,7 +32,7 @@ import java.lang.reflect.Field; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetPutShort { diff --git a/hotspot/test/runtime/Unsafe/GetUncompressedObject.java b/hotspot/test/runtime/Unsafe/GetUncompressedObject.java index 9673c75aea9..dc72a5e7209 100644 --- a/hotspot/test/runtime/Unsafe/GetUncompressedObject.java +++ b/hotspot/test/runtime/Unsafe/GetUncompressedObject.java @@ -32,7 +32,7 @@ import static jdk.test.lib.Asserts.*; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class GetUncompressedObject { diff --git a/hotspot/test/runtime/Unsafe/GetUnsafe.java b/hotspot/test/runtime/Unsafe/GetUnsafe.java index 8cb95f54eae..64ad19d8bdd 100644 --- a/hotspot/test/runtime/Unsafe/GetUnsafe.java +++ b/hotspot/test/runtime/Unsafe/GetUnsafe.java @@ -29,7 +29,7 @@ * @run main GetUnsafe */ -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class GetUnsafe { diff --git a/hotspot/test/runtime/Unsafe/PageSize.java b/hotspot/test/runtime/Unsafe/PageSize.java index 6b29f6dcca5..6ce5a1c5f47 100644 --- a/hotspot/test/runtime/Unsafe/PageSize.java +++ b/hotspot/test/runtime/Unsafe/PageSize.java @@ -32,7 +32,7 @@ import java.lang.reflect.Field; import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class PageSize { diff --git a/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java b/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java index 5405d4bce08..f081efcaf80 100644 --- a/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java +++ b/hotspot/test/runtime/Unsafe/PrimitiveHostClass.java @@ -25,7 +25,7 @@ import java.awt.Component; import java.lang.reflect.Field; import static jdk.internal.org.objectweb.asm.Opcodes.*; import jdk.internal.org.objectweb.asm.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /* * @test PrimitiveHostClass diff --git a/hotspot/test/runtime/Unsafe/RangeCheck.java b/hotspot/test/runtime/Unsafe/RangeCheck.java index ecd413c3bc4..0e9b914234b 100644 --- a/hotspot/test/runtime/Unsafe/RangeCheck.java +++ b/hotspot/test/runtime/Unsafe/RangeCheck.java @@ -31,7 +31,7 @@ */ import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; public class RangeCheck { @@ -44,6 +44,7 @@ public class RangeCheck { ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( true, "-Xmx32m", + "-XaddExports:java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-TransmitErrorReport", "-XX:-CreateCoredumpOnCrash", "-XX:-InlineUnsafeOps", // The compiler intrinsics doesn't have the assert diff --git a/hotspot/test/runtime/Unsafe/Reallocate.java b/hotspot/test/runtime/Unsafe/Reallocate.java index 10992fca115..b2fe5d939e2 100644 --- a/hotspot/test/runtime/Unsafe/Reallocate.java +++ b/hotspot/test/runtime/Unsafe/Reallocate.java @@ -32,7 +32,7 @@ */ import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class Reallocate { diff --git a/hotspot/test/runtime/Unsafe/SetMemory.java b/hotspot/test/runtime/Unsafe/SetMemory.java index e1991968429..8ff36cc788b 100644 --- a/hotspot/test/runtime/Unsafe/SetMemory.java +++ b/hotspot/test/runtime/Unsafe/SetMemory.java @@ -31,7 +31,7 @@ */ import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class SetMemory { diff --git a/hotspot/test/runtime/Unsafe/ThrowException.java b/hotspot/test/runtime/Unsafe/ThrowException.java index 957be3c1db8..c263aa18684 100644 --- a/hotspot/test/runtime/Unsafe/ThrowException.java +++ b/hotspot/test/runtime/Unsafe/ThrowException.java @@ -31,7 +31,7 @@ */ import jdk.test.lib.*; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import static jdk.test.lib.Asserts.*; public class ThrowException { diff --git a/hotspot/test/runtime/contended/Basic.java b/hotspot/test/runtime/contended/Basic.java index bf64e946f29..5ffba1aa920 100644 --- a/hotspot/test/runtime/contended/Basic.java +++ b/hotspot/test/runtime/contended/Basic.java @@ -35,13 +35,14 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import jdk.internal.vm.annotation.Contended; /* * @test * @bug 8003985 * @summary Support Contended Annotation - JEP 142 + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @run main/othervm -XX:-RestrictContended Basic */ diff --git a/hotspot/test/runtime/contended/DefaultValue.java b/hotspot/test/runtime/contended/DefaultValue.java index 8ed4f064088..b61ab3d4502 100644 --- a/hotspot/test/runtime/contended/DefaultValue.java +++ b/hotspot/test/runtime/contended/DefaultValue.java @@ -35,7 +35,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import jdk.internal.vm.annotation.Contended; /* @@ -43,6 +43,7 @@ import jdk.internal.vm.annotation.Contended; * @bug 8014509 * @summary \@Contended: explicit default value behaves differently from the implicit value * + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @run main/othervm -XX:-RestrictContended DefaultValue */ diff --git a/hotspot/test/runtime/contended/HasNonStatic.java b/hotspot/test/runtime/contended/HasNonStatic.java index 3e07c09fcfe..04f2fb8708b 100644 --- a/hotspot/test/runtime/contended/HasNonStatic.java +++ b/hotspot/test/runtime/contended/HasNonStatic.java @@ -35,7 +35,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import jdk.internal.vm.annotation.Contended; /* @@ -43,6 +43,7 @@ import jdk.internal.vm.annotation.Contended; * @bug 8015270 * @summary \@Contended: fix multiple issues in the layout code * + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @run main/othervm -XX:-RestrictContended HasNonStatic */ diff --git a/hotspot/test/runtime/contended/Inheritance1.java b/hotspot/test/runtime/contended/Inheritance1.java index f3333610cf3..57dec49b3ae 100644 --- a/hotspot/test/runtime/contended/Inheritance1.java +++ b/hotspot/test/runtime/contended/Inheritance1.java @@ -35,7 +35,7 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; import jdk.internal.vm.annotation.Contended; /* @@ -43,6 +43,7 @@ import jdk.internal.vm.annotation.Contended; * @bug 8012939 * @summary \@Contended doesn't work correctly with inheritance * + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * @run main/othervm -XX:-RestrictContended Inheritance1 */ diff --git a/hotspot/test/runtime/contended/OopMaps.java b/hotspot/test/runtime/contended/OopMaps.java index 27d5ba8ddf8..a3b3e01e622 100644 --- a/hotspot/test/runtime/contended/OopMaps.java +++ b/hotspot/test/runtime/contended/OopMaps.java @@ -35,7 +35,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import sun.misc.Unsafe; import jdk.internal.vm.annotation.Contended; /* diff --git a/hotspot/test/runtime/contended/OopMapsSameGroup.java b/hotspot/test/runtime/contended/OopMapsSameGroup.java index 6975fd3dc68..5adb0129483 100644 --- a/hotspot/test/runtime/contended/OopMapsSameGroup.java +++ b/hotspot/test/runtime/contended/OopMapsSameGroup.java @@ -35,7 +35,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import sun.misc.Unsafe; import jdk.internal.vm.annotation.Contended; /* diff --git a/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java b/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java index 7e3930137e7..9923844d8c1 100644 --- a/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java +++ b/hotspot/test/runtime/getSysPackage/GetSysPkgTest.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.loader * java.desktop * @library /testlibrary diff --git a/hotspot/test/runtime/interned/SanityTest.java b/hotspot/test/runtime/interned/SanityTest.java index 6f07b0cc907..c0f2f726040 100644 --- a/hotspot/test/runtime/interned/SanityTest.java +++ b/hotspot/test/runtime/interned/SanityTest.java @@ -24,6 +24,7 @@ /* * @test SanityTest * @summary Sanity check of String.intern() & GC + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build SanityTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/runtime/libadimalloc.solaris.sparc/Testlibadimalloc.java b/hotspot/test/runtime/libadimalloc.solaris.sparc/Testlibadimalloc.java index e9a8406f0f1..49201a7aa13 100644 --- a/hotspot/test/runtime/libadimalloc.solaris.sparc/Testlibadimalloc.java +++ b/hotspot/test/runtime/libadimalloc.solaris.sparc/Testlibadimalloc.java @@ -27,6 +27,7 @@ * @bug 8141445 * @summary make sure the Solaris Sparc M7 libadimalloc.so library generates SIGSEGV's on buffer overflow * @requires (os.family == "solaris" & os.arch == "sparcv9") + * @modules java.base/jdk.internal.misc * @library /testlibrary * @build jdk.test.lib.* * @compile SEGVOverflow.java diff --git a/hotspot/test/runtime/logging/ClassInitializationTest.java b/hotspot/test/runtime/logging/ClassInitializationTest.java index 331b8fd9bdd..9ffd4d236fe 100644 --- a/hotspot/test/runtime/logging/ClassInitializationTest.java +++ b/hotspot/test/runtime/logging/ClassInitializationTest.java @@ -25,6 +25,7 @@ /* * @test ClassInitializationTest * @bug 8142976 + * @modules java.base/jdk.internal.misc * @library /testlibrary * @compile BadMap50.jasm * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.Platform jdk.test.lib.ProcessTools diff --git a/hotspot/test/runtime/logging/ClassLoadUnloadTest.java b/hotspot/test/runtime/logging/ClassLoadUnloadTest.java index 80dc17a37dc..e9c5d97ba83 100644 --- a/hotspot/test/runtime/logging/ClassLoadUnloadTest.java +++ b/hotspot/test/runtime/logging/ClassLoadUnloadTest.java @@ -25,6 +25,7 @@ /* * @test ClassLoadUnloadTest * @bug 8142506 + * @modules java.base/jdk.internal.misc * @library /testlibrary /runtime/testlibrary * @library classes * @build ClassUnloadCommon test.Empty jdk.test.lib.* jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools diff --git a/hotspot/test/runtime/logging/ClassResolutionTest.java b/hotspot/test/runtime/logging/ClassResolutionTest.java index a5b184b3829..ceebd4c3ac0 100644 --- a/hotspot/test/runtime/logging/ClassResolutionTest.java +++ b/hotspot/test/runtime/logging/ClassResolutionTest.java @@ -25,6 +25,7 @@ /* * @test ClassResolutionTest * @bug 8144874 + * @modules java.base/jdk.internal.misc * @library /testlibrary * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools * @run driver ClassResolutionTest diff --git a/hotspot/test/runtime/logging/LoaderConstraintsTest.java b/hotspot/test/runtime/logging/LoaderConstraintsTest.java index 398a3ecc871..ea6e13b673e 100644 --- a/hotspot/test/runtime/logging/LoaderConstraintsTest.java +++ b/hotspot/test/runtime/logging/LoaderConstraintsTest.java @@ -25,6 +25,7 @@ /* * @test LoaderConstraintsTest * @bug 8149996 + * @modules java.base/jdk.internal.misc * @library /testlibrary /runtime/testlibrary * @library classes * @build ClassUnloadCommon test.Empty jdk.test.lib.* jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools diff --git a/hotspot/test/runtime/logging/MonitorMismatchTest.java b/hotspot/test/runtime/logging/MonitorMismatchTest.java index 6aacb538152..82d464c49c0 100644 --- a/hotspot/test/runtime/logging/MonitorMismatchTest.java +++ b/hotspot/test/runtime/logging/MonitorMismatchTest.java @@ -25,6 +25,7 @@ /* * @test MonitorMismatchTest * @bug 8150084 + * @modules java.base/jdk.internal.misc * @library /testlibrary * @compile MonitorMismatchHelper.jasm * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools jdk.test.lib.Platform diff --git a/hotspot/test/runtime/logging/ProtectionDomainVerificationTest.java b/hotspot/test/runtime/logging/ProtectionDomainVerificationTest.java index 57790ad1248..919d9582074 100644 --- a/hotspot/test/runtime/logging/ProtectionDomainVerificationTest.java +++ b/hotspot/test/runtime/logging/ProtectionDomainVerificationTest.java @@ -24,6 +24,7 @@ /* * @test ProtectionDomainVerificationTest * @bug 8149064 + * @modules java.base/jdk.internal.misc * @library /testlibrary * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.Platform jdk.test.lib.ProcessTools * @run driver ProtectionDomainVerificationTest diff --git a/hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java b/hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java index 44f5ab1144d..47d61d1b0f2 100644 --- a/hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java +++ b/hotspot/test/runtime/logging/RemovedDevelopFlagsTest.java @@ -25,6 +25,7 @@ /* * @test RemovedDevelopFlagsTest * @bug 8146632 + * @modules java.base/jdk.internal.misc * @library /testlibrary * @build jdk.test.lib.OutputAnalyzer jdk.test.lib.ProcessTools * @run driver RemovedDevelopFlagsTest diff --git a/hotspot/test/runtime/memory/ReadVMPageSize.java b/hotspot/test/runtime/memory/ReadVMPageSize.java index bbd23c5622c..aa83ce0b582 100644 --- a/hotspot/test/runtime/memory/ReadVMPageSize.java +++ b/hotspot/test/runtime/memory/ReadVMPageSize.java @@ -24,6 +24,7 @@ /* * @test * @summary Using WhiteBox to get VM page size + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build ReadVMPageSize * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/runtime/memory/StressVirtualSpaceResize.java b/hotspot/test/runtime/memory/StressVirtualSpaceResize.java index 417c8de1463..4fd0534b873 100644 --- a/hotspot/test/runtime/memory/StressVirtualSpaceResize.java +++ b/hotspot/test/runtime/memory/StressVirtualSpaceResize.java @@ -24,6 +24,7 @@ /* * @test * @summary Stress test that expands/shrinks VirtualSpace + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build StressVirtualSpaceResize * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/runtime/modules/AccessCheck/CheckRead.java b/hotspot/test/runtime/modules/AccessCheck/CheckRead.java index ec88eef6525..bfe8a0fc823 100644 --- a/hotspot/test/runtime/modules/AccessCheck/CheckRead.java +++ b/hotspot/test/runtime/modules/AccessCheck/CheckRead.java @@ -27,6 +27,7 @@ * @test * @summary Test that if module m1 can not read module m2, then class p1.c1 * in module m1 can not access p2.c2 in module m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MySameClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_CheckRead.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_CheckRead.java index 7ccf918d232..10196ded9fe 100644 --- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_CheckRead.java +++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_CheckRead.java @@ -27,6 +27,7 @@ * @test * @summary Test that if module m1 can not read module m2, then class p1.c1 * in module m1 can not access p2.c2 in module m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MyDiffClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualOther.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualOther.java index c815a85fac7..5310abc1974 100644 --- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualOther.java +++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualOther.java @@ -28,6 +28,7 @@ * @summary Test that if module m1 can read module m2, but package p2 in m2 * is exported specifically to module m3, then class p1.c1 in m1 can not * access p2.c2 in m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MyDiffClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualToM1.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualToM1.java index c1c38fd61dc..71359b019dc 100644 --- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualToM1.java +++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpQualToM1.java @@ -27,6 +27,7 @@ * @test * @summary class p1.c1 defined in m1 tries to access p2.c2 defined in m2. * Access allowed since m1 can read m2 and package p2 is exported to m1. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MyDiffClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpUnqual.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpUnqual.java index a8668333d73..4d8db6bf1b8 100644 --- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpUnqual.java +++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_ExpUnqual.java @@ -27,6 +27,7 @@ * @test * @summary Test that if module m1 can read module m2, and package p2 in m2 is * exported unqualifiedly, then class p1.c1 in m1 can read p2.c2 in m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MyDiffClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_PkgNotExp.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_PkgNotExp.java index d4f3d62d4ec..fafb2aeb738 100644 --- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_PkgNotExp.java +++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_PkgNotExp.java @@ -27,6 +27,7 @@ * @test * @summary Test that if module m1 can read module m2, but package p2 in m2 is not * exported, then class p1.c1 in m1 can not read p2.c2 in m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MyDiffClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_Umod.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_Umod.java index 6df74bfa689..e6753435d4b 100644 --- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_Umod.java +++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_Umod.java @@ -27,6 +27,7 @@ * @test * @summary class p1.c1 defined in m1 tries to access p2.c2 defined in unnamed module. * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.module * @compile myloaders/MyDiffClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/DiffCL_UmodUpkg.java b/hotspot/test/runtime/modules/AccessCheck/DiffCL_UmodUpkg.java index 5cd133db695..8c9629b16b8 100644 --- a/hotspot/test/runtime/modules/AccessCheck/DiffCL_UmodUpkg.java +++ b/hotspot/test/runtime/modules/AccessCheck/DiffCL_UmodUpkg.java @@ -27,6 +27,7 @@ * @test * @summary class p3.c3 defined in module m1 tries to access c4 defined in an unnamed package * and an unnamed module. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MyDiffClassLoader.java * @compile c4.java diff --git a/hotspot/test/runtime/modules/AccessCheck/ExpQualOther.java b/hotspot/test/runtime/modules/AccessCheck/ExpQualOther.java index 4645d096746..c9003ad2cd5 100644 --- a/hotspot/test/runtime/modules/AccessCheck/ExpQualOther.java +++ b/hotspot/test/runtime/modules/AccessCheck/ExpQualOther.java @@ -28,6 +28,7 @@ * @summary Test that if module m1 can read module m2, but package p2 in m2 * is exported specifically to module m3, then class p1.c1 in m1 can not * access p2.c2 in m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MySameClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/ExpQualToM1.java b/hotspot/test/runtime/modules/AccessCheck/ExpQualToM1.java index fa0b0944ff1..755ffe15133 100644 --- a/hotspot/test/runtime/modules/AccessCheck/ExpQualToM1.java +++ b/hotspot/test/runtime/modules/AccessCheck/ExpQualToM1.java @@ -27,6 +27,7 @@ * @test * @summary Test that if module m1 can read module m2, AND package p2 in m2 is * exported qualifiedly to m1, then class p1.c1 in m1 can read p2.c2 in m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MySameClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/ExpUnqual.java b/hotspot/test/runtime/modules/AccessCheck/ExpUnqual.java index a7c74ba5084..7f1c1d918a1 100644 --- a/hotspot/test/runtime/modules/AccessCheck/ExpUnqual.java +++ b/hotspot/test/runtime/modules/AccessCheck/ExpUnqual.java @@ -27,6 +27,7 @@ * @test * @summary Test that if module m1 can read module m2, AND package p2 in module2 is * exported unqualifiedly, then class p1.c1 in m1 can read p2.c2 in m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MySameClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/ExportAllUnnamed.java b/hotspot/test/runtime/modules/AccessCheck/ExportAllUnnamed.java index a75fda9668f..97133f3ebaa 100644 --- a/hotspot/test/runtime/modules/AccessCheck/ExportAllUnnamed.java +++ b/hotspot/test/runtime/modules/AccessCheck/ExportAllUnnamed.java @@ -28,6 +28,7 @@ * @summary Test if package p2 in module m2 is exported to all unnamed, * then class p1.c1 in an unnamed module can read p2.c2 in module m2. * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.module * @compile myloaders/MySameClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/PkgNotExp.java b/hotspot/test/runtime/modules/AccessCheck/PkgNotExp.java index b8a56173988..04fbbead02d 100644 --- a/hotspot/test/runtime/modules/AccessCheck/PkgNotExp.java +++ b/hotspot/test/runtime/modules/AccessCheck/PkgNotExp.java @@ -27,6 +27,7 @@ * @test * @summary Test that if module m1 can read module m2, but package p2 in m2 is not * exported, then class p1.c1 in m1 can not read p2.c2 in m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MySameClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/Umod.java b/hotspot/test/runtime/modules/AccessCheck/Umod.java index 639891b4339..a08a522db37 100644 --- a/hotspot/test/runtime/modules/AccessCheck/Umod.java +++ b/hotspot/test/runtime/modules/AccessCheck/Umod.java @@ -27,6 +27,7 @@ * @test * @summary class p1.c1 defined in m1 tries to access p2.c2 defined in unnamed module. * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.module * @compile myloaders/MySameClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpQualOther.java b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpQualOther.java index 34ea50f6c1e..d9e578c750b 100644 --- a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpQualOther.java +++ b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpQualOther.java @@ -28,6 +28,7 @@ * @summary class p1.c1 defined in an unnamed module tries to access p2.c2 defined in m2. * Access is denied, since an unnamed module can read all modules but p2 in module * m2 is exported specifically to module m1, not to all modules. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MyDiffClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpUnqual.java b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpUnqual.java index 52d253b352c..c17e07f959e 100644 --- a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpUnqual.java +++ b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_ExpUnqual.java @@ -28,6 +28,7 @@ * @summary class p1.c1 defined in an unnamed module tries to access p2.c2 defined in m2. * Access allowed, an unnamed module can read all modules and p2 in module m2 * which is exported unqualifiedly. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MyDiffClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_PkgNotExp.java b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_PkgNotExp.java index ebe3e5d004e..fd5e090c011 100644 --- a/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_PkgNotExp.java +++ b/hotspot/test/runtime/modules/AccessCheck/UmodDiffCL_PkgNotExp.java @@ -28,6 +28,7 @@ * @summary class p1.c1 defined in unnamed module tries to access p2.c2 defined in m2. * Access is denied since even though unnamed module can read all modules, p2 * in module m2 is not exported at all. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MyDiffClassLoader.java * @compile p1/c1.java diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodUPkg.java b/hotspot/test/runtime/modules/AccessCheck/UmodUPkg.java index 97f781c8c7a..102236618e1 100644 --- a/hotspot/test/runtime/modules/AccessCheck/UmodUPkg.java +++ b/hotspot/test/runtime/modules/AccessCheck/UmodUPkg.java @@ -26,6 +26,7 @@ /* * @test * @summary class p3.c3 defined in module m1 tries to access c4 defined in unnamed module. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MySameClassLoader.java * @compile c4.java diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_ExpQualOther.java b/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_ExpQualOther.java index 299a41f4003..15a0e0105bf 100644 --- a/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_ExpQualOther.java +++ b/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_ExpQualOther.java @@ -28,6 +28,7 @@ * @summary class c5 defined in an unnamed module tries to access p6.c6 defined in m2. * Access is denied, since an unnamed module can read all modules but p6 in module * m2 is exported specifically to module m1, not to all modules. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MyDiffClassLoader.java * @compile p6/c6.java diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_NotExp.java b/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_NotExp.java index 9210c295ac7..30ae3fb18c2 100644 --- a/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_NotExp.java +++ b/hotspot/test/runtime/modules/AccessCheck/UmodUpkgDiffCL_NotExp.java @@ -27,6 +27,7 @@ * @test * @summary class c5 in an unnamed module can read module m2, but package p6 in module m2 is not exported. * Access denied since even though unnamed module can read all modules, p6 in module m2 is not exported at all. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MyDiffClassLoader.java * @compile p6/c6.java diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_ExpQualOther.java b/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_ExpQualOther.java index 1084294a1e5..e7a51e3438a 100644 --- a/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_ExpQualOther.java +++ b/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_ExpQualOther.java @@ -27,6 +27,7 @@ * @test * @summary Test that if class c5 in an unnamed module can read package p6 in module m2, but package p6 in module m2 is * exported qualifiedly to module m3, then class c5 in an unnamed module can not read p6.c6 in module m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MySameClassLoader.java * @compile p6/c6.java diff --git a/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_NotExp.java b/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_NotExp.java index 8ee6e92921c..5bab4fc8bc9 100644 --- a/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_NotExp.java +++ b/hotspot/test/runtime/modules/AccessCheck/UmodUpkg_NotExp.java @@ -27,6 +27,7 @@ * @test * @summary Test if package p6 in module m2 is not exported, then class c5 * in an unnamed module can not access p6.c2 in module m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MySameClassLoader.java * @compile p6/c6.java diff --git a/hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java b/hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java index fe2fb7bb076..3f827e93c3c 100644 --- a/hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java +++ b/hotspot/test/runtime/modules/AccessCheck/Umod_ExpQualOther.java @@ -27,6 +27,7 @@ * @test * @summary Test that if package p2 in module m2 is exported to module m3, * then class p1.c1 in an unnamed module can not read p2.c2 in module m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MySameClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/Umod_ExpUnqual.java b/hotspot/test/runtime/modules/AccessCheck/Umod_ExpUnqual.java index 445713c8352..fe3c88526d7 100644 --- a/hotspot/test/runtime/modules/AccessCheck/Umod_ExpUnqual.java +++ b/hotspot/test/runtime/modules/AccessCheck/Umod_ExpUnqual.java @@ -27,6 +27,7 @@ * @test * @summary Test if package p2 in module m2 is exported unqualifiedly, * then class p1.c1 in an unnamed module can read p2.c2 in module m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MySameClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheck/Umod_PkgNotExp.java b/hotspot/test/runtime/modules/AccessCheck/Umod_PkgNotExp.java index 7a346cfda1b..d1b2a223f63 100644 --- a/hotspot/test/runtime/modules/AccessCheck/Umod_PkgNotExp.java +++ b/hotspot/test/runtime/modules/AccessCheck/Umod_PkgNotExp.java @@ -27,6 +27,7 @@ * @test * @summary Test if package p2 in module m2 is not exported, then class p1.c1 * in an unnamed module can not access p2.c2 in module m2. + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @compile myloaders/MySameClassLoader.java * @compile p2/c2.java diff --git a/hotspot/test/runtime/modules/AccessCheckAllUnnamed.java b/hotspot/test/runtime/modules/AccessCheckAllUnnamed.java index a97f7ccf8d1..8846108567f 100644 --- a/hotspot/test/runtime/modules/AccessCheckAllUnnamed.java +++ b/hotspot/test/runtime/modules/AccessCheckAllUnnamed.java @@ -26,6 +26,7 @@ import static jdk.test.lib.Asserts.*; /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @compile p2/c2.java * @compile p1/c1.java diff --git a/hotspot/test/runtime/modules/AccessCheckExp.java b/hotspot/test/runtime/modules/AccessCheckExp.java index 304af7f9ee8..0adbd72c553 100644 --- a/hotspot/test/runtime/modules/AccessCheckExp.java +++ b/hotspot/test/runtime/modules/AccessCheckExp.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @compile p2/c2.java * @compile p1/c1.java diff --git a/hotspot/test/runtime/modules/AccessCheckJavaBase.java b/hotspot/test/runtime/modules/AccessCheckJavaBase.java index 764f9fb2be4..dc1b691cf17 100644 --- a/hotspot/test/runtime/modules/AccessCheckJavaBase.java +++ b/hotspot/test/runtime/modules/AccessCheckJavaBase.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @compile p2/c2.java * @build sun.hotspot.WhiteBox diff --git a/hotspot/test/runtime/modules/AccessCheckRead.java b/hotspot/test/runtime/modules/AccessCheckRead.java index 8158582e866..320ba55ec7c 100644 --- a/hotspot/test/runtime/modules/AccessCheckRead.java +++ b/hotspot/test/runtime/modules/AccessCheckRead.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @compile p2/c2.java * @compile p1/c1.java diff --git a/hotspot/test/runtime/modules/AccessCheckSuper.java b/hotspot/test/runtime/modules/AccessCheckSuper.java index bd2065b5ff0..663679b48c9 100644 --- a/hotspot/test/runtime/modules/AccessCheckSuper.java +++ b/hotspot/test/runtime/modules/AccessCheckSuper.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @compile p2/c2.java * @compile p3/c3.java diff --git a/hotspot/test/runtime/modules/AccessCheckUnnamed.java b/hotspot/test/runtime/modules/AccessCheckUnnamed.java index 0451489be56..319ee7402c2 100644 --- a/hotspot/test/runtime/modules/AccessCheckUnnamed.java +++ b/hotspot/test/runtime/modules/AccessCheckUnnamed.java @@ -26,6 +26,7 @@ import static jdk.test.lib.Asserts.*; /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @compile p2/c2.java * @compile p1/c1.java diff --git a/hotspot/test/runtime/modules/AccessCheckWorks.java b/hotspot/test/runtime/modules/AccessCheckWorks.java index 3a13b04a59b..63de8ca8b2a 100644 --- a/hotspot/test/runtime/modules/AccessCheckWorks.java +++ b/hotspot/test/runtime/modules/AccessCheckWorks.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @compile p2/c2.java * @compile p1/c1.java diff --git a/hotspot/test/runtime/modules/ExportTwice.java b/hotspot/test/runtime/modules/ExportTwice.java index b33b55ef787..93f4e682ac4 100644 --- a/hotspot/test/runtime/modules/ExportTwice.java +++ b/hotspot/test/runtime/modules/ExportTwice.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @compile p2/c2.java * @compile p1/c1.java diff --git a/hotspot/test/runtime/modules/JVMAddModuleExportToAllUnnamed.java b/hotspot/test/runtime/modules/JVMAddModuleExportToAllUnnamed.java index b7b34b7411f..8ea4f6b1106 100644 --- a/hotspot/test/runtime/modules/JVMAddModuleExportToAllUnnamed.java +++ b/hotspot/test/runtime/modules/JVMAddModuleExportToAllUnnamed.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @compile p2/c2.java * @compile p1/c1.java diff --git a/hotspot/test/runtime/modules/JVMAddModuleExports.java b/hotspot/test/runtime/modules/JVMAddModuleExports.java index 330dd923411..1f0dcae38c0 100644 --- a/hotspot/test/runtime/modules/JVMAddModuleExports.java +++ b/hotspot/test/runtime/modules/JVMAddModuleExports.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @build sun.hotspot.WhiteBox * @compile/module=java.base java/lang/reflect/ModuleHelper.java diff --git a/hotspot/test/runtime/modules/JVMAddModuleExportsToAll.java b/hotspot/test/runtime/modules/JVMAddModuleExportsToAll.java index f41d401c10d..9f6e69fc6cf 100644 --- a/hotspot/test/runtime/modules/JVMAddModuleExportsToAll.java +++ b/hotspot/test/runtime/modules/JVMAddModuleExportsToAll.java @@ -26,6 +26,7 @@ import static jdk.test.lib.Asserts.*; /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @compile p2/c2.java * @compile p1/c1.java diff --git a/hotspot/test/runtime/modules/JVMAddModulePackage.java b/hotspot/test/runtime/modules/JVMAddModulePackage.java index 430c67ca6fd..359e3f2b132 100644 --- a/hotspot/test/runtime/modules/JVMAddModulePackage.java +++ b/hotspot/test/runtime/modules/JVMAddModulePackage.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @build sun.hotspot.WhiteBox * @compile/module=java.base java/lang/reflect/ModuleHelper.java diff --git a/hotspot/test/runtime/modules/JVMAddReadsModule.java b/hotspot/test/runtime/modules/JVMAddReadsModule.java index 78f1d3bf62e..1a7de50a5c8 100644 --- a/hotspot/test/runtime/modules/JVMAddReadsModule.java +++ b/hotspot/test/runtime/modules/JVMAddReadsModule.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @build sun.hotspot.WhiteBox * @compile/module=java.base java/lang/reflect/ModuleHelper.java diff --git a/hotspot/test/runtime/modules/JVMCanReadModule.java b/hotspot/test/runtime/modules/JVMCanReadModule.java index ca131df42ec..daabd21d213 100644 --- a/hotspot/test/runtime/modules/JVMCanReadModule.java +++ b/hotspot/test/runtime/modules/JVMCanReadModule.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @build sun.hotspot.WhiteBox * @compile/module=java.base java/lang/reflect/ModuleHelper.java diff --git a/hotspot/test/runtime/modules/JVMDefineModule.java b/hotspot/test/runtime/modules/JVMDefineModule.java index 77d3c0f3940..602c5fdc0bc 100644 --- a/hotspot/test/runtime/modules/JVMDefineModule.java +++ b/hotspot/test/runtime/modules/JVMDefineModule.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @build sun.hotspot.WhiteBox * @compile/module=java.base java/lang/reflect/ModuleHelper.java diff --git a/hotspot/test/runtime/modules/JVMGetModuleByPkgName.java b/hotspot/test/runtime/modules/JVMGetModuleByPkgName.java index 25065e2812c..88ff93a5040 100644 --- a/hotspot/test/runtime/modules/JVMGetModuleByPkgName.java +++ b/hotspot/test/runtime/modules/JVMGetModuleByPkgName.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @compile p2/c2.java * @build sun.hotspot.WhiteBox diff --git a/hotspot/test/runtime/modules/JVMIsExportedToModule.java b/hotspot/test/runtime/modules/JVMIsExportedToModule.java index 0e35b7d8d1c..2d465001ce2 100644 --- a/hotspot/test/runtime/modules/JVMIsExportedToModule.java +++ b/hotspot/test/runtime/modules/JVMIsExportedToModule.java @@ -23,6 +23,7 @@ /* * @test + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @build sun.hotspot.WhiteBox * @compile/module=java.base java/lang/reflect/ModuleHelper.java diff --git a/hotspot/test/runtime/modules/LoadUnloadModuleStress.java b/hotspot/test/runtime/modules/LoadUnloadModuleStress.java index 53d45c9a892..ec30f58d2e3 100644 --- a/hotspot/test/runtime/modules/LoadUnloadModuleStress.java +++ b/hotspot/test/runtime/modules/LoadUnloadModuleStress.java @@ -24,6 +24,7 @@ /* * @test * @summary Ensure module information is cleaned when owning class loader unloads + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib /compiler/whitebox .. * @build sun.hotspot.WhiteBox * @compile/module=java.base java/lang/reflect/ModuleHelper.java diff --git a/hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java b/hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java index 014476cbd6e..3fce693defd 100644 --- a/hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java +++ b/hotspot/test/runtime/modules/Xpatch/Xpatch2Dirs.java @@ -24,6 +24,7 @@ /* * @test * @summary Make sure -Xpatch works with multiple directories. + * @modules java.base/jdk.internal.misc * @library /testlibrary * @compile Xpatch2DirsMain.java * @run main Xpatch2Dirs diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchTest.java b/hotspot/test/runtime/modules/Xpatch/XpatchTest.java index ddc873feca5..55a904f7dd3 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchTest.java +++ b/hotspot/test/runtime/modules/Xpatch/XpatchTest.java @@ -25,6 +25,7 @@ * @test * @bug 8130399 * @summary Make sure -Xpatch works for modules besides java.base. + * @modules java.base/jdk.internal.misc * @library /testlibrary * @compile XpatchMain.java * @run main XpatchTest diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java b/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java index 38ad2e817cf..98889d40c8d 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java +++ b/hotspot/test/runtime/modules/Xpatch/XpatchTraceCL.java @@ -26,6 +26,7 @@ * @bug 8069469 * @summary Make sure -XX:+TraceClassLoading works properly with "modules" jimage, -Xpatch, and with -Xbootclasspath/a + * @modules java.base/jdk.internal.misc * @library /testlibrary * @compile XpatchMain.java * @run main XpatchTraceCL diff --git a/hotspot/test/runtime/os/AvailableProcessors.java b/hotspot/test/runtime/os/AvailableProcessors.java index 529f2a0889b..a60757391ee 100644 --- a/hotspot/test/runtime/os/AvailableProcessors.java +++ b/hotspot/test/runtime/os/AvailableProcessors.java @@ -30,6 +30,7 @@ import java.util.ArrayList; * @bug 6515172 8148766 * @summary Check that availableProcessors reports the correct value when running in a cpuset on linux * @requires os.family == "linux" + * @modules java.base/jdk.internal.misc * @library /testlibrary * @build jdk.test.lib.* * @run driver AvailableProcessors diff --git a/hotspot/test/runtime/verifier/TraceClassRes.java b/hotspot/test/runtime/verifier/TraceClassRes.java index ab1912aadf1..c8b5d5e95db 100644 --- a/hotspot/test/runtime/verifier/TraceClassRes.java +++ b/hotspot/test/runtime/verifier/TraceClassRes.java @@ -25,6 +25,7 @@ * @test * @bug 8076318 * @summary split verifier needs to add TraceClassResolution + * @modules java.base/jdk.internal.misc * @library /testlibrary */ diff --git a/hotspot/test/runtime/whitebox/WBStackSize.java b/hotspot/test/runtime/whitebox/WBStackSize.java index 0d3ccc36fc5..9bc117b3927 100644 --- a/hotspot/test/runtime/whitebox/WBStackSize.java +++ b/hotspot/test/runtime/whitebox/WBStackSize.java @@ -24,6 +24,7 @@ /* * @test WBStackSize * @summary verify that whitebox functions getThreadFullStackSize() and getThreadRemainingStackSize are working + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build WBStackSize * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/sanity/MismatchedWhiteBox/WhiteBox.java b/hotspot/test/sanity/MismatchedWhiteBox/WhiteBox.java index 87d56e442cb..a6f442476d2 100644 --- a/hotspot/test/sanity/MismatchedWhiteBox/WhiteBox.java +++ b/hotspot/test/sanity/MismatchedWhiteBox/WhiteBox.java @@ -26,6 +26,7 @@ * @bug 8011675 * @summary verify that whitebox can be used even if not all functions are declared in java-part * @author igor.ignatyev@oracle.com + * @modules java.base/jdk.internal.misc * @library /testlibrary * @compile WhiteBox.java * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/sanity/WBApi.java b/hotspot/test/sanity/WBApi.java index 75ac5c3ab57..e24e672bc82 100644 --- a/hotspot/test/sanity/WBApi.java +++ b/hotspot/test/sanity/WBApi.java @@ -24,6 +24,7 @@ /* * @test WBApi * @summary verify that whitebox functions can be linked and executed + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build WBApi * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/serviceability/ParserTest.java b/hotspot/test/serviceability/ParserTest.java index a9d6c8dbb7d..58ef23bdf86 100644 --- a/hotspot/test/serviceability/ParserTest.java +++ b/hotspot/test/serviceability/ParserTest.java @@ -24,6 +24,7 @@ /* * @test * @summary Test that the diagnostic command arguemnt parser works + * @modules java.base/jdk.internal.misc * @library /testlibrary /test/lib * @build ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.parser.* * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/serviceability/attach/AttachWithStalePidFile.java b/hotspot/test/serviceability/attach/AttachWithStalePidFile.java index 8ed9b479f63..5cc42cab22f 100644 --- a/hotspot/test/serviceability/attach/AttachWithStalePidFile.java +++ b/hotspot/test/serviceability/attach/AttachWithStalePidFile.java @@ -26,6 +26,7 @@ * @bug 7162400 * @key regression * @summary Regression test for attach issue where stale pid files in /tmp lead to connection issues + * @modules java.base/jdk.internal.misc * @modules jdk.attach/sun.tools.attach * @library /testlibrary * @build jdk.test.lib.* AttachWithStalePidFileTarget diff --git a/hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java b/hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java index 1e1e61167a4..05b06270bcf 100644 --- a/hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java +++ b/hotspot/test/serviceability/dcmd/gc/FinalizerInfoTest.java @@ -36,6 +36,7 @@ import jdk.test.lib.dcmd.PidJcmdExecutor; * @test * @summary * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.xml * java.management * @build jdk.test.lib.* diff --git a/hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java b/hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java index d6f325260b0..5193e6c6821 100644 --- a/hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java +++ b/hotspot/test/serviceability/dcmd/gc/HeapInfoTest.java @@ -35,6 +35,7 @@ import jdk.test.lib.OutputAnalyzer; * @test * @summary Test of diagnostic command GC.heap_info * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.xml * java.management * @build jdk.test.lib.* diff --git a/hotspot/test/serviceability/dcmd/jvmti/DataDumpDcmdTest.java b/hotspot/test/serviceability/dcmd/jvmti/DataDumpDcmdTest.java index 1586db2d51c..b25999a77bd 100644 --- a/hotspot/test/serviceability/dcmd/jvmti/DataDumpDcmdTest.java +++ b/hotspot/test/serviceability/dcmd/jvmti/DataDumpDcmdTest.java @@ -31,6 +31,7 @@ import org.testng.annotations.Test; * @test * @bug 8054890 * @summary Test of JVMTI.data_dump diagnostic command + * @modules java.base/jdk.internal.misc * @library /testlibrary * @build jdk.test.lib.* * @run testng DataDumpDcmdTest diff --git a/hotspot/test/serviceability/dcmd/vm/SetVMFlagTest.java b/hotspot/test/serviceability/dcmd/vm/SetVMFlagTest.java index b6e674476de..9132aece076 100644 --- a/hotspot/test/serviceability/dcmd/vm/SetVMFlagTest.java +++ b/hotspot/test/serviceability/dcmd/vm/SetVMFlagTest.java @@ -31,6 +31,7 @@ import static org.testng.Assert.*; * @test * @bug 8054890 * @summary Test of VM.set_flag diagnostic command + * @modules java.base/jdk.internal.misc * @library /testlibrary * @build jdk.test.lib.* * @build jdk.test.lib.dcmd.* diff --git a/hotspot/test/serviceability/logging/TestBasicLogOutput.java b/hotspot/test/serviceability/logging/TestBasicLogOutput.java index c74a258f278..345e3737932 100644 --- a/hotspot/test/serviceability/logging/TestBasicLogOutput.java +++ b/hotspot/test/serviceability/logging/TestBasicLogOutput.java @@ -24,6 +24,7 @@ /* * @test TestBasicLogOutput * @summary Ensure logging can be enabled and successfully prints to stdout. + * @modules java.base/jdk.internal.misc * @library /testlibrary */ diff --git a/hotspot/test/serviceability/logging/TestMultipleXlogArgs.java b/hotspot/test/serviceability/logging/TestMultipleXlogArgs.java index 6914927fdb3..dfc62f7ca10 100644 --- a/hotspot/test/serviceability/logging/TestMultipleXlogArgs.java +++ b/hotspot/test/serviceability/logging/TestMultipleXlogArgs.java @@ -24,6 +24,7 @@ /* * @test TestMultipleXlogArgs * @summary Ensure multiple -Xlog arguments aggregate the logging options. + * @modules java.base/jdk.internal.misc * @library /testlibrary */ diff --git a/hotspot/test/serviceability/logging/TestQuotedLogOutputs.java b/hotspot/test/serviceability/logging/TestQuotedLogOutputs.java index 39789ea01df..77b4e007412 100644 --- a/hotspot/test/serviceability/logging/TestQuotedLogOutputs.java +++ b/hotspot/test/serviceability/logging/TestQuotedLogOutputs.java @@ -24,6 +24,7 @@ /* * @test TestQuotedLogOutputs * @summary Ensure proper parsing of quoted output names for -Xlog arguments. + * @modules java.base/jdk.internal.misc * @library /testlibrary */ diff --git a/hotspot/test/serviceability/sa/DeadlockDetectionTest.java b/hotspot/test/serviceability/sa/DeadlockDetectionTest.java index 23ce96f6399..85e5529509d 100644 --- a/hotspot/test/serviceability/sa/DeadlockDetectionTest.java +++ b/hotspot/test/serviceability/sa/DeadlockDetectionTest.java @@ -40,6 +40,7 @@ import jdk.test.lib.ProcessTools; * @summary Test deadlock detection * @library /test/lib/share/classes * @library /testlibrary + * @modules java.base/jdk.internal.misc * @modules java.management * @build jdk.test.lib.* * @build jdk.test.lib.apps.* diff --git a/hotspot/test/serviceability/sa/TestClassLoaderStats.java b/hotspot/test/serviceability/sa/TestClassLoaderStats.java index 92f843e11d9..df46c4136fc 100644 --- a/hotspot/test/serviceability/sa/TestClassLoaderStats.java +++ b/hotspot/test/serviceability/sa/TestClassLoaderStats.java @@ -32,6 +32,7 @@ import jdk.test.lib.apps.LingeredApp; /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library /testlibrary * @build jdk.test.lib.* diff --git a/hotspot/test/serviceability/sa/TestStackTrace.java b/hotspot/test/serviceability/sa/TestStackTrace.java index 203735c3125..7044f104f65 100644 --- a/hotspot/test/serviceability/sa/TestStackTrace.java +++ b/hotspot/test/serviceability/sa/TestStackTrace.java @@ -32,6 +32,7 @@ import jdk.test.lib.apps.LingeredApp; /* * @test + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library /testlibrary * @build jdk.test.lib.* diff --git a/hotspot/test/serviceability/threads/TestFalseDeadLock.java b/hotspot/test/serviceability/threads/TestFalseDeadLock.java index 2954d5d6318..e4654f4a266 100644 --- a/hotspot/test/serviceability/threads/TestFalseDeadLock.java +++ b/hotspot/test/serviceability/threads/TestFalseDeadLock.java @@ -30,6 +30,7 @@ import java.util.Random; * @test * @bug 8016304 * @summary Make sure no deadlock is reported for this program which has no deadlocks. + * @modules java.base/jdk.internal.misc * @library /testlibrary * @run main/othervm TestFalseDeadLock */ diff --git a/hotspot/test/serviceability/tmtools/jstack/DaemonThreadTest.java b/hotspot/test/serviceability/tmtools/jstack/DaemonThreadTest.java index 6b154ecc890..cebd2c7d65f 100644 --- a/hotspot/test/serviceability/tmtools/jstack/DaemonThreadTest.java +++ b/hotspot/test/serviceability/tmtools/jstack/DaemonThreadTest.java @@ -25,6 +25,7 @@ * @test * @summary Create daemon and non-deamon threads. * Check the correctness of thread's status from jstack. + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library ../share * @build common.* diff --git a/hotspot/test/serviceability/tmtools/jstack/JstackThreadTest.java b/hotspot/test/serviceability/tmtools/jstack/JstackThreadTest.java index 6ca81885814..2d0eb05686c 100644 --- a/hotspot/test/serviceability/tmtools/jstack/JstackThreadTest.java +++ b/hotspot/test/serviceability/tmtools/jstack/JstackThreadTest.java @@ -32,6 +32,7 @@ import java.util.concurrent.CountDownLatch; * @test JstackThreadTest * @bug 8151442 * @summary jstack doesn't close quotation marks properly with threads' name greater than 1996 characters + * @modules java.base/jdk.internal.misc * @library /testlibrary * @build jdk.test.lib.* * @run main JstackThreadTest diff --git a/hotspot/test/serviceability/tmtools/jstack/SpreadLockTest.java b/hotspot/test/serviceability/tmtools/jstack/SpreadLockTest.java index 92bd5e5c90a..884c8d2bfa3 100644 --- a/hotspot/test/serviceability/tmtools/jstack/SpreadLockTest.java +++ b/hotspot/test/serviceability/tmtools/jstack/SpreadLockTest.java @@ -27,6 +27,7 @@ * synchronizing on one monitor inside of each method. * After checking that lock info is correct invoke another method * and get the lock again. Repeat this action. + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library ../share * @build common.* diff --git a/hotspot/test/serviceability/tmtools/jstack/ThreadNamesTest.java b/hotspot/test/serviceability/tmtools/jstack/ThreadNamesTest.java index c5943d11e98..282bfda2186 100644 --- a/hotspot/test/serviceability/tmtools/jstack/ThreadNamesTest.java +++ b/hotspot/test/serviceability/tmtools/jstack/ThreadNamesTest.java @@ -24,6 +24,7 @@ /* * @test * @summary Checks that jstack correctly prints the thread names + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library ../share * @build common.* diff --git a/hotspot/test/serviceability/tmtools/jstack/TraveledLockTest.java b/hotspot/test/serviceability/tmtools/jstack/TraveledLockTest.java index 9f478158a3f..174bcdb7257 100644 --- a/hotspot/test/serviceability/tmtools/jstack/TraveledLockTest.java +++ b/hotspot/test/serviceability/tmtools/jstack/TraveledLockTest.java @@ -27,6 +27,7 @@ * synchronizing on one monitor inside of each method. * After checking that lock info is correct free the lock and * invoke another method. Repeat this action. + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library ../share * @build common.* diff --git a/hotspot/test/serviceability/tmtools/jstack/WaitNotifyThreadTest.java b/hotspot/test/serviceability/tmtools/jstack/WaitNotifyThreadTest.java index 198124cf3a0..6f87c0a04b3 100644 --- a/hotspot/test/serviceability/tmtools/jstack/WaitNotifyThreadTest.java +++ b/hotspot/test/serviceability/tmtools/jstack/WaitNotifyThreadTest.java @@ -27,6 +27,7 @@ * presented in the stack is correct. Call notifyAll method * monitor info have to disappear from the stack. * Repeats the same scenario calling interrupt() method + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library ../share * @build common.* diff --git a/hotspot/test/serviceability/tmtools/jstat/GcCapacityTest.java b/hotspot/test/serviceability/tmtools/jstat/GcCapacityTest.java index ec6d1bc2f4d..2ed5c0576fd 100644 --- a/hotspot/test/serviceability/tmtools/jstat/GcCapacityTest.java +++ b/hotspot/test/serviceability/tmtools/jstat/GcCapacityTest.java @@ -27,6 +27,7 @@ import utils.*; * @test * @summary Test checks the consistency of the output * displayed with jstat -gccapacity. + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library ../share * @requires vm.opt.ExplicitGCInvokesConcurrent != true diff --git a/hotspot/test/serviceability/tmtools/jstat/GcCauseTest01.java b/hotspot/test/serviceability/tmtools/jstat/GcCauseTest01.java index 508b7865a3c..688670f3d9d 100644 --- a/hotspot/test/serviceability/tmtools/jstat/GcCauseTest01.java +++ b/hotspot/test/serviceability/tmtools/jstat/GcCauseTest01.java @@ -28,6 +28,7 @@ * test several times provokes garbage collection in the debuggee application and after each garbage * collection runs jstat. jstat should show that after garbage collection number of GC events and garbage * collection time increase. + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library ../share * @requires vm.opt.ExplicitGCInvokesConcurrent != true diff --git a/hotspot/test/serviceability/tmtools/jstat/GcCauseTest02.java b/hotspot/test/serviceability/tmtools/jstat/GcCauseTest02.java index 95200d453c5..0efd59fe764 100644 --- a/hotspot/test/serviceability/tmtools/jstat/GcCauseTest02.java +++ b/hotspot/test/serviceability/tmtools/jstat/GcCauseTest02.java @@ -27,6 +27,7 @@ * Test scenario: * tests forces debuggee application eat ~70% of heap and runs jstat. * jstat should show that ~70% of heap (OC/OU ~= 70%). + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library ../share * @build common.* diff --git a/hotspot/test/serviceability/tmtools/jstat/GcCauseTest03.java b/hotspot/test/serviceability/tmtools/jstat/GcCauseTest03.java index 94514d4b634..a014c373fac 100644 --- a/hotspot/test/serviceability/tmtools/jstat/GcCauseTest03.java +++ b/hotspot/test/serviceability/tmtools/jstat/GcCauseTest03.java @@ -27,6 +27,7 @@ * Test scenario: * test forces debuggee application call System.gc(), runs jstat and checks that * cause of last garbage collection displayed by jstat (LGCC) is 'System.gc()'. + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library ../share * @build common.* diff --git a/hotspot/test/serviceability/tmtools/jstat/GcNewTest.java b/hotspot/test/serviceability/tmtools/jstat/GcNewTest.java index bdb06c1e6b2..4e2fbdc801b 100644 --- a/hotspot/test/serviceability/tmtools/jstat/GcNewTest.java +++ b/hotspot/test/serviceability/tmtools/jstat/GcNewTest.java @@ -29,6 +29,7 @@ import utils.*; * test several times provokes garbage collection in the debuggee application and after each garbage * collection runs jstat. jstat should show that after garbage collection number of GC events and garbage * collection time increase. + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library ../share * @build common.* diff --git a/hotspot/test/serviceability/tmtools/jstat/GcTest01.java b/hotspot/test/serviceability/tmtools/jstat/GcTest01.java index 2a6b0c544a8..5738da18fc3 100644 --- a/hotspot/test/serviceability/tmtools/jstat/GcTest01.java +++ b/hotspot/test/serviceability/tmtools/jstat/GcTest01.java @@ -31,6 +31,7 @@ * jstat should show that after garbage collection * number of GC events and garbage * collection time increase. + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library ../share * @requires vm.opt.ExplicitGCInvokesConcurrent != true diff --git a/hotspot/test/serviceability/tmtools/jstat/GcTest02.java b/hotspot/test/serviceability/tmtools/jstat/GcTest02.java index bcdc258c934..8924221703e 100644 --- a/hotspot/test/serviceability/tmtools/jstat/GcTest02.java +++ b/hotspot/test/serviceability/tmtools/jstat/GcTest02.java @@ -28,6 +28,7 @@ import utils.*; * Test scenario: * tests forces debuggee application eat ~70% of heap and runs jstat. * jstat should show that ~70% of heap is utilized (OC/OU ~= 70%). + * @modules java.base/jdk.internal.misc * @library /test/lib/share/classes * @library ../share * @build common.* diff --git a/hotspot/test/testlibrary/jdk/test/lib/Utils.java b/hotspot/test/testlibrary/jdk/test/lib/Utils.java index 9dcf0632ffe..8ad11fdcbb5 100644 --- a/hotspot/test/testlibrary/jdk/test/lib/Utils.java +++ b/hotspot/test/testlibrary/jdk/test/lib/Utils.java @@ -51,7 +51,7 @@ import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.regex.Matcher; import java.util.regex.Pattern; -import sun.misc.Unsafe; +import jdk.internal.misc.Unsafe; /** * Common library for various test helper functions. diff --git a/hotspot/test/testlibrary_tests/AssertsTest.java b/hotspot/test/testlibrary_tests/AssertsTest.java index baf10c99f89..449126cb31e 100644 --- a/hotspot/test/testlibrary_tests/AssertsTest.java +++ b/hotspot/test/testlibrary_tests/AssertsTest.java @@ -25,6 +25,7 @@ import static jdk.test.lib.Asserts.*; /* @test * @summary Tests the different assertions in the Assert class + * @modules java.base/jdk.internal.misc * @library /testlibrary */ public class AssertsTest { diff --git a/hotspot/test/testlibrary_tests/RedefineClassTest.java b/hotspot/test/testlibrary_tests/RedefineClassTest.java index 48905f97349..739352a815e 100644 --- a/hotspot/test/testlibrary_tests/RedefineClassTest.java +++ b/hotspot/test/testlibrary_tests/RedefineClassTest.java @@ -25,6 +25,7 @@ * @test * @library /testlibrary * @summary Proof of concept test for RedefineClassHelper + * @modules java.base/jdk.internal.misc * @modules java.compiler * java.instrument * jdk.jartool/sun.tools.jar diff --git a/hotspot/test/testlibrary_tests/whitebox/BlobSanityTest.java b/hotspot/test/testlibrary_tests/whitebox/BlobSanityTest.java index 0ee48b5fb53..3146339e093 100644 --- a/hotspot/test/testlibrary_tests/whitebox/BlobSanityTest.java +++ b/hotspot/test/testlibrary_tests/whitebox/BlobSanityTest.java @@ -25,6 +25,7 @@ * @test BlobSanityTest * @bug 8132980 * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management/sun.management * @build BlobSanityTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java index 7a15c7dd9a1..2694ba7046a 100644 --- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java +++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/DoubleTest.java @@ -25,6 +25,7 @@ * @test DoubleTest * @bug 8028756 * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management/sun.management * @build DoubleTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java index b12f3065b22..56ffc53302d 100644 --- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java +++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/IntxTest.java @@ -25,6 +25,7 @@ * @test IntxTest * @bug 8038756 * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management/sun.management * @build IntxTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java index 531f59f4e32..f8b98fa4daa 100644 --- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java +++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/StringTest.java @@ -25,6 +25,7 @@ * @test StringTest * @bug 8028756 * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management/sun.management * @build StringTest * @run main ClassFileInstaller sun.hotspot.WhiteBox diff --git a/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java b/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java index c82e35ee54e..015c02eba49 100644 --- a/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java +++ b/hotspot/test/testlibrary_tests/whitebox/vm_flags/Uint64Test.java @@ -25,6 +25,7 @@ * @test Uint64Test * @bug 8028756 * @library /testlibrary /test/lib + * @modules java.base/jdk.internal.misc * @modules java.management/sun.management * @build Uint64Test * @run main ClassFileInstaller sun.hotspot.WhiteBox -- GitLab From 238fada76264d77d6e067798c50d74fefaffb87a Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 2 May 2016 10:24:41 +0200 Subject: [PATCH 239/400] 8155232: Augment Workgang to run task with a given number of threads Add a method to run a WorkGang with a set number of threads. Reviewed-by: stefank, jmasa, mgerdin --- hotspot/src/share/vm/gc/shared/workgroup.cpp | 10 +++++++++- hotspot/src/share/vm/gc/shared/workgroup.hpp | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/gc/shared/workgroup.cpp b/hotspot/src/share/vm/gc/shared/workgroup.cpp index a8da10db4cc..715b6a1e3b6 100644 --- a/hotspot/src/share/vm/gc/shared/workgroup.cpp +++ b/hotspot/src/share/vm/gc/shared/workgroup.cpp @@ -255,7 +255,15 @@ AbstractGangWorker* WorkGang::allocate_worker(uint worker_id) { } void WorkGang::run_task(AbstractGangTask* task) { - _dispatcher->coordinator_execute_on_workers(task, active_workers()); + run_task(task, active_workers()); +} + +void WorkGang::run_task(AbstractGangTask* task, uint num_workers) { + guarantee(num_workers <= active_workers(), + "Trying to execute task %s with %u workers which is more than the amount of active workers %u.", + task->name(), num_workers, active_workers()); + guarantee(num_workers > 0, "Trying to execute task %s with zero workers", task->name()); + _dispatcher->coordinator_execute_on_workers(task, num_workers); } AbstractGangWorker::AbstractGangWorker(AbstractWorkGang* gang, uint id) { diff --git a/hotspot/src/share/vm/gc/shared/workgroup.hpp b/hotspot/src/share/vm/gc/shared/workgroup.hpp index ee6b7be4c14..657b00c9a21 100644 --- a/hotspot/src/share/vm/gc/shared/workgroup.hpp +++ b/hotspot/src/share/vm/gc/shared/workgroup.hpp @@ -192,8 +192,12 @@ public: bool are_GC_task_threads, bool are_ConcurrentGC_threads); - // Run a task, returns when the task is done. + // Run a task using the current active number of workers, returns when the task is done. virtual void run_task(AbstractGangTask* task); + // Run a task with the given number of workers, returns + // when the task is done. The number of workers must be at most the number of + // active workers. + void run_task(AbstractGangTask* task, uint num_workers); protected: virtual AbstractGangWorker* allocate_worker(uint which); -- GitLab From bd8bbf9e27740f6ea61a9df9d01d3b5682132811 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 2 May 2016 10:24:41 +0200 Subject: [PATCH 240/400] 8153507: Improve Card Table Clear Task Move card table clear code into remembered set related files. Improve work distribution of this task, and tune thread usage. Reviewed-by: jmasa, mgerdin --- .../src/share/vm/gc/g1/g1CollectedHeap.cpp | 100 --------------- .../src/share/vm/gc/g1/g1CollectedHeap.hpp | 15 +-- hotspot/src/share/vm/gc/g1/g1RemSet.cpp | 119 ++++++++++++++++-- hotspot/src/share/vm/gc/g1/heapRegion.cpp | 2 +- hotspot/src/share/vm/gc/g1/heapRegion.hpp | 8 -- 5 files changed, 114 insertions(+), 130 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index 9bad219bf78..9a1a653c11c 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -163,59 +163,6 @@ void G1RegionMappingChangedListener::on_commit(uint start_idx, size_t num_region reset_from_card_cache(start_idx, num_regions); } -void G1CollectedHeap::push_dirty_cards_region(HeapRegion* hr) -{ - // Claim the right to put the region on the dirty cards region list - // by installing a self pointer. - HeapRegion* next = hr->get_next_dirty_cards_region(); - if (next == NULL) { - HeapRegion* res = (HeapRegion*) - Atomic::cmpxchg_ptr(hr, hr->next_dirty_cards_region_addr(), - NULL); - if (res == NULL) { - HeapRegion* head; - do { - // Put the region to the dirty cards region list. - head = _dirty_cards_region_list; - next = (HeapRegion*) - Atomic::cmpxchg_ptr(hr, &_dirty_cards_region_list, head); - if (next == head) { - assert(hr->get_next_dirty_cards_region() == hr, - "hr->get_next_dirty_cards_region() != hr"); - if (next == NULL) { - // The last region in the list points to itself. - hr->set_next_dirty_cards_region(hr); - } else { - hr->set_next_dirty_cards_region(next); - } - } - } while (next != head); - } - } -} - -HeapRegion* G1CollectedHeap::pop_dirty_cards_region() -{ - HeapRegion* head; - HeapRegion* hr; - do { - head = _dirty_cards_region_list; - if (head == NULL) { - return NULL; - } - HeapRegion* new_head = head->get_next_dirty_cards_region(); - if (head == new_head) { - // The last region. - new_head = NULL; - } - hr = (HeapRegion*)Atomic::cmpxchg_ptr(new_head, &_dirty_cards_region_list, - head); - } while (hr != head); - assert(hr != NULL, "invariant"); - hr->set_next_dirty_cards_region(NULL); - return hr; -} - // Returns true if the reference points to an object that // can move in an incremental collection. bool G1CollectedHeap::is_scavengable(const void* p) { @@ -1777,7 +1724,6 @@ G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* collector_policy) : _old_marking_cycles_started(0), _old_marking_cycles_completed(0), _in_cset_fast_test(), - _dirty_cards_region_list(NULL), _worker_cset_start_region(NULL), _worker_cset_start_region_time_stamp(NULL), _gc_timer_stw(new (ResourceObj::C_HEAP, mtGC) STWGCTimer()), @@ -4743,31 +4689,6 @@ void G1CollectedHeap::decrement_summary_bytes(size_t bytes) { decrease_used(bytes); } -class G1ParCleanupCTTask : public AbstractGangTask { - G1SATBCardTableModRefBS* _ct_bs; - G1CollectedHeap* _g1h; - HeapRegion* volatile _su_head; -public: - G1ParCleanupCTTask(G1SATBCardTableModRefBS* ct_bs, - G1CollectedHeap* g1h) : - AbstractGangTask("G1 Par Cleanup CT Task"), - _ct_bs(ct_bs), _g1h(g1h) { } - - void work(uint worker_id) { - HeapRegion* r; - while (r = _g1h->pop_dirty_cards_region()) { - clear_cards(r); - } - } - - void clear_cards(HeapRegion* r) { - // Cards of the survivors should have already been dirtied. - if (!r->is_survivor()) { - _ct_bs->clear(MemRegion(r->bottom(), r->end())); - } - } -}; - class G1ParScrubRemSetTask: public AbstractGangTask { protected: G1RemSet* _g1rs; @@ -4791,27 +4712,6 @@ void G1CollectedHeap::scrub_rem_set() { workers()->run_task(&g1_par_scrub_rs_task); } -void G1CollectedHeap::cleanUpCardTable() { - G1SATBCardTableModRefBS* ct_bs = g1_barrier_set(); - double start = os::elapsedTime(); - - { - // Iterate over the dirty cards region list. - G1ParCleanupCTTask cleanup_task(ct_bs, this); - - workers()->run_task(&cleanup_task); -#ifndef PRODUCT - // Need to synchronize with concurrent cleanup since it needs to - // finish its card table clearing before we can verify. - wait_while_free_regions_coming(); - _verifier->verify_card_table_cleanup(); -#endif - } - - double elapsed = os::elapsedTime() - start; - g1_policy()->phase_times()->record_clear_ct_time(elapsed * 1000.0); -} - void G1CollectedHeap::free_collection_set(HeapRegion* cs_head, EvacuationInfo& evacuation_info, const size_t* surviving_young_words) { size_t pre_used = 0; FreeRegionList local_free_list("Local List for CSet Freeing"); diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp index ddae29c9f59..c452e1c783d 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp @@ -36,6 +36,7 @@ #include "gc/g1/g1MonitoringSupport.hpp" #include "gc/g1/g1EvacFailure.hpp" #include "gc/g1/g1EvacStats.hpp" +#include "gc/g1/g1HeapVerifier.hpp" #include "gc/g1/g1SATBCardTableModRefBS.hpp" #include "gc/g1/g1YCTypes.hpp" #include "gc/g1/hSpaceCounters.hpp" @@ -1165,10 +1166,6 @@ public: return barrier_set_cast(barrier_set()); } - // This resets the card table to all zeros. It is used after - // a collection pause which used the card table to claim cards. - void cleanUpCardTable(); - // Iteration functions. // Iterate over all objects, calling "cl.do_object" on each. @@ -1394,16 +1391,6 @@ public: ConcurrentG1Refine* concurrent_g1_refine() const { return _cg1r; } - // The dirty cards region list is used to record a subset of regions - // whose cards need clearing. The list if populated during the - // remembered set scanning and drained during the card table - // cleanup. Although the methods are reentrant, population/draining - // phases must not overlap. For synchronization purposes the last - // element on the list points to itself. - HeapRegion* _dirty_cards_region_list; - void push_dirty_cards_region(HeapRegion* hr); - HeapRegion* pop_dirty_cards_region(); - // Optimized nmethod scanning support routines // Register the given nmethod with the G1 heap. diff --git a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp index e655c1af87f..6eb4e2a0494 100644 --- a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp @@ -48,6 +48,47 @@ // Collects information about the overall remembered set scan progress during an evacuation. class G1RemSetScanState : public CHeapObj { private: + class G1ClearCardTableTask : public AbstractGangTask { + G1CollectedHeap* _g1h; + uint* _dirty_region_list; + size_t _num_dirty_regions; + size_t _chunk_length; + + size_t volatile _cur_dirty_regions; + public: + G1ClearCardTableTask(G1CollectedHeap* g1h, + uint* dirty_region_list, + size_t num_dirty_regions, + size_t chunk_length) : + AbstractGangTask("G1 Clear Card Table Task"), + _g1h(g1h), + _dirty_region_list(dirty_region_list), + _num_dirty_regions(num_dirty_regions), + _chunk_length(chunk_length), + _cur_dirty_regions(0) { + + assert(chunk_length > 0, "must be"); + } + + static size_t chunk_size() { return M; } + + void work(uint worker_id) { + G1SATBCardTableModRefBS* ct_bs = _g1h->g1_barrier_set(); + + while (_cur_dirty_regions < _num_dirty_regions) { + size_t next = Atomic::add(_chunk_length, &_cur_dirty_regions) - _chunk_length; + size_t max = MIN2(next + _chunk_length, _num_dirty_regions); + + for (size_t i = next; i < max; i++) { + HeapRegion* r = _g1h->region_at(_dirty_region_list[i]); + if (!r->is_survivor()) { + ct_bs->clear(MemRegion(r->bottom(), r->end())); + } + } + } + } + }; + size_t _max_regions; // Scan progress for the remembered set of a single region. Transitions from @@ -65,11 +106,25 @@ private: // remembered set. size_t volatile* _iter_claims; + // Temporary buffer holding the regions we used to store remembered set scan duplicate + // information. These are also called "dirty". Valid entries are from [0.._cur_dirty_region) + uint* _dirty_region_buffer; + + typedef jbyte IsDirtyRegionState; + static const IsDirtyRegionState Clean = 0; + static const IsDirtyRegionState Dirty = 1; + // Holds a flag for every region whether it is in the _dirty_region_buffer already + // to avoid duplicates. Uses jbyte since there are no atomic instructions for bools. + IsDirtyRegionState* _in_dirty_region_buffer; + size_t _cur_dirty_region; public: G1RemSetScanState() : _max_regions(0), _iter_states(NULL), - _iter_claims(NULL) { + _iter_claims(NULL), + _dirty_region_buffer(NULL), + _in_dirty_region_buffer(NULL), + _cur_dirty_region(0) { } @@ -80,6 +135,12 @@ public: if (_iter_claims != NULL) { FREE_C_HEAP_ARRAY(size_t, _iter_claims); } + if (_dirty_region_buffer != NULL) { + FREE_C_HEAP_ARRAY(uint, _dirty_region_buffer); + } + if (_in_dirty_region_buffer != NULL) { + FREE_C_HEAP_ARRAY(IsDirtyRegionState, _in_dirty_region_buffer); + } } void initialize(uint max_regions) { @@ -88,6 +149,8 @@ public: _max_regions = max_regions; _iter_states = NEW_C_HEAP_ARRAY(G1RemsetIterState, max_regions, mtGC); _iter_claims = NEW_C_HEAP_ARRAY(size_t, max_regions, mtGC); + _dirty_region_buffer = NEW_C_HEAP_ARRAY(uint, max_regions, mtGC); + _in_dirty_region_buffer = NEW_C_HEAP_ARRAY(IsDirtyRegionState, max_regions, mtGC); } void reset() { @@ -95,6 +158,8 @@ public: _iter_states[i] = Unclaimed; } memset((void*)_iter_claims, 0, _max_regions * sizeof(size_t)); + memset(_in_dirty_region_buffer, Clean, _max_regions * sizeof(IsDirtyRegionState)); + _cur_dirty_region = 0; } // Attempt to claim the remembered set of the region for iteration. Returns true @@ -135,6 +200,44 @@ public: inline size_t iter_claimed_next(uint region, size_t step) { return Atomic::add(step, &_iter_claims[region]) - step; } + + void add_dirty_region(uint region) { + if (_in_dirty_region_buffer[region] == Dirty) { + return; + } + + bool marked_as_dirty = Atomic::cmpxchg(Dirty, &_in_dirty_region_buffer[region], Clean) == Clean; + if (marked_as_dirty) { + size_t allocated = Atomic::add(1, &_cur_dirty_region) - 1; + _dirty_region_buffer[allocated] = region; + } + } + + // Clear the card table of "dirty" regions. + void clear_card_table(WorkGang* workers) { + if (_cur_dirty_region == 0) { + return; + } + + size_t const num_chunks = align_size_up(_cur_dirty_region * HeapRegion::CardsPerRegion, G1ClearCardTableTask::chunk_size()) / G1ClearCardTableTask::chunk_size(); + uint const num_workers = (uint)MIN2(num_chunks, (size_t)workers->active_workers()); + size_t const chunk_length = G1ClearCardTableTask::chunk_size() / HeapRegion::CardsPerRegion; + + // Iterate over the dirty cards region list. + G1ClearCardTableTask cl(G1CollectedHeap::heap(), _dirty_region_buffer, _cur_dirty_region, chunk_length); + + log_debug(gc, ergo)("Running %s using %u workers for " SIZE_FORMAT " " + "units of work for " SIZE_FORMAT " regions.", + cl.name(), num_workers, num_chunks, _cur_dirty_region); + workers->run_task(&cl, num_workers); + +#ifndef PRODUCT + // Need to synchronize with concurrent cleanup since it needs to + // finish its card table clearing before we can verify. + G1CollectedHeap::heap()->wait_while_free_regions_coming(); + G1CollectedHeap::heap()->verifier()->verify_card_table_cleanup(); +#endif + } }; G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs) : @@ -237,7 +340,7 @@ bool G1ScanRSClosure::doHeapRegion(HeapRegion* r) { // If we ever free the collection set concurrently, we should also // clear the card table concurrently therefore we won't need to // add regions of the collection set to the dirty cards region. - _g1h->push_dirty_cards_region(r); + _scan_state->add_dirty_region(region_idx); } HeapRegionRemSetIterator iter(r->rem_set()); @@ -258,9 +361,7 @@ bool G1ScanRSClosure::doHeapRegion(HeapRegion* r) { HeapRegion* card_region = _g1h->heap_region_containing(card_start); _cards++; - if (!card_region->is_on_dirty_cards_region_list()) { - _g1h->push_dirty_cards_region(card_region); - } + _scan_state->add_dirty_region(card_region->hrm_index()); // If the card is dirty, then we will scan it during updateRS. if (!card_region->in_collection_set() && @@ -376,10 +477,14 @@ void G1RemSet::prepare_for_oops_into_collection_set_do() { } void G1RemSet::cleanup_after_oops_into_collection_set_do() { + G1GCPhaseTimes* phase_times = _g1->g1_policy()->phase_times(); // Cleanup after copy _g1->set_refine_cte_cl_concurrency(true); + // Set all cards back to clean. - _g1->cleanUpCardTable(); + double start = os::elapsedTime(); + _scan_state->clear_card_table(_g1->workers()); + phase_times->record_clear_ct_time((os::elapsedTime() - start) * 1000.0); DirtyCardQueueSet& into_cset_dcqs = _into_cset_dirty_card_queue_set; @@ -391,7 +496,7 @@ void G1RemSet::cleanup_after_oops_into_collection_set_do() { // used to hold cards that contain references that point into the collection set // to the DCQS used to hold the deferred RS updates. _g1->dirty_card_queue_set().merge_bufferlists(&into_cset_dcqs); - _g1->g1_policy()->phase_times()->record_evac_fail_restore_remsets((os::elapsedTime() - restore_remembered_set_start) * 1000.0); + phase_times->record_evac_fail_restore_remsets((os::elapsedTime() - restore_remembered_set_start) * 1000.0); } // Free any completed buffers in the DirtyCardQueueSet used to hold cards diff --git a/hotspot/src/share/vm/gc/g1/heapRegion.cpp b/hotspot/src/share/vm/gc/g1/heapRegion.cpp index 141b24789ff..2b223545ac6 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegion.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegion.cpp @@ -288,7 +288,7 @@ HeapRegion::HeapRegion(uint hrm_index, _evacuation_failed(false), _prev_marked_bytes(0), _next_marked_bytes(0), _gc_efficiency(0.0), _next_young_region(NULL), - _next_dirty_cards_region(NULL), _next(NULL), _prev(NULL), + _next(NULL), _prev(NULL), #ifdef ASSERT _containing_set(NULL), #endif // ASSERT diff --git a/hotspot/src/share/vm/gc/g1/heapRegion.hpp b/hotspot/src/share/vm/gc/g1/heapRegion.hpp index 4258b608c25..b758c0bf753 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegion.hpp +++ b/hotspot/src/share/vm/gc/g1/heapRegion.hpp @@ -270,9 +270,6 @@ class HeapRegion: public G1ContiguousSpace { // next region in the young "generation" region set HeapRegion* _next_young_region; - // Next region whose cards need cleaning - HeapRegion* _next_dirty_cards_region; - // Fields used by the HeapRegionSetBase class and subclasses. HeapRegion* _next; HeapRegion* _prev; @@ -531,11 +528,6 @@ class HeapRegion: public G1ContiguousSpace { _next_young_region = hr; } - HeapRegion* get_next_dirty_cards_region() const { return _next_dirty_cards_region; } - HeapRegion** next_dirty_cards_region_addr() { return &_next_dirty_cards_region; } - void set_next_dirty_cards_region(HeapRegion* hr) { _next_dirty_cards_region = hr; } - bool is_on_dirty_cards_region_list() const { return get_next_dirty_cards_region() != NULL; } - // Reset HR stuff to default values. void hr_clear(bool par, bool clear_space, bool locked = false); void par_clear(); -- GitLab From 72977f4009783cbea35ec6bd3138fa8d8ee21aff Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 2 May 2016 10:24:41 +0200 Subject: [PATCH 241/400] 8155230: Tune thread usage for mark bitmap clear Reviewed-by: jmasa, mgerdin --- .../src/share/vm/gc/g1/g1ConcurrentMark.cpp | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp index 9b51104b8a8..d52c0ea8b79 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp @@ -609,6 +609,10 @@ G1ConcurrentMark::~G1ConcurrentMark() { } class G1ClearBitMapTask : public AbstractGangTask { +public: + static size_t chunk_size() { return M; } + +private: // Heap region closure used for clearing the given mark bitmap. class G1ClearBitmapHRClosure : public HeapRegionClosure { private: @@ -619,7 +623,7 @@ class G1ClearBitMapTask : public AbstractGangTask { } virtual bool doHeapRegion(HeapRegion* r) { - size_t const chunk_size_in_words = M / HeapWordSize; + size_t const chunk_size_in_words = G1ClearBitMapTask::chunk_size() / HeapWordSize; HeapWord* cur = r->bottom(); HeapWord* const end = r->end(); @@ -653,7 +657,7 @@ class G1ClearBitMapTask : public AbstractGangTask { public: G1ClearBitMapTask(G1CMBitMap* bitmap, G1ConcurrentMark* cm, uint n_workers, bool suspendible) : - AbstractGangTask("Parallel Clear Bitmap Task"), + AbstractGangTask("G1 Clear Bitmap"), _cl(bitmap, suspendible ? cm : NULL), _hr_claimer(n_workers), _suspendible(suspendible) @@ -672,9 +676,16 @@ public: void G1ConcurrentMark::clear_bitmap(G1CMBitMap* bitmap, WorkGang* workers, bool may_yield) { assert(may_yield || SafepointSynchronize::is_at_safepoint(), "Non-yielding bitmap clear only allowed at safepoint."); - G1ClearBitMapTask task(bitmap, this, workers->active_workers(), may_yield); - workers->run_task(&task); - guarantee(!may_yield || task.is_complete(), "Must have completed iteration when not yielding."); + size_t const num_bytes_to_clear = (HeapRegion::GrainBytes * _g1h->num_regions()) / G1CMBitMap::heap_map_factor(); + size_t const num_chunks = align_size_up(num_bytes_to_clear, G1ClearBitMapTask::chunk_size()) / G1ClearBitMapTask::chunk_size(); + + uint const num_workers = (uint)MIN2(num_chunks, (size_t)workers->active_workers()); + + G1ClearBitMapTask cl(bitmap, this, num_workers, may_yield); + + log_debug(gc, ergo)("Running %s with %u workers for " SIZE_FORMAT " work units.", cl.name(), num_workers, num_chunks); + workers->run_task(&cl, num_workers); + guarantee(!may_yield || cl.is_complete(), "Must have completed iteration when not yielding."); } void G1ConcurrentMark::cleanup_for_next_mark() { -- GitLab From 53d670b469ecaeb3eb1f4907e971a122c45adc0d Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 2 May 2016 10:24:41 +0200 Subject: [PATCH 242/400] 8155233: Lazy coarse map clear Only clear the coarse bitmaps of the remembered sets if they were dirtied. Reviewed-by: jmasa, mgerdin --- hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp | 16 ++++++++++++---- hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp index 77f9bc349b6..3fcfb3b76d6 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp @@ -265,7 +265,8 @@ OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) : _first_all_fine_prts(NULL), _last_all_fine_prts(NULL), _n_fine_entries(0), _n_coarse_entries(0), _fine_eviction_start(0), - _sparse_table(hr) + _sparse_table(hr), + _coarse_dirty(false) { typedef PerRegionTable* PerRegionTablePtr; @@ -504,6 +505,7 @@ PerRegionTable* OtherRegionsTable::delete_region_table() { size_t max_hrm_index = (size_t) max->hr()->hrm_index(); if (!_coarse_map.at(max_hrm_index)) { _coarse_map.at_put(max_hrm_index, true); + _coarse_dirty = true; _n_coarse_entries++; } @@ -519,8 +521,11 @@ void OtherRegionsTable::scrub(G1CardLiveData* live_data) { log_develop_trace(gc, remset, scrub)("Scrubbing region %u:", _hr->hrm_index()); log_develop_trace(gc, remset, scrub)(" Coarse map: before = " SIZE_FORMAT "...", _n_coarse_entries); - live_data->remove_nonlive_regions(&_coarse_map); - _n_coarse_entries = _coarse_map.count_one_bits(); + if (_coarse_dirty) { + live_data->remove_nonlive_regions(&_coarse_map); + _n_coarse_entries = _coarse_map.count_one_bits(); + _coarse_dirty = _n_coarse_entries != 0; + } log_develop_trace(gc, remset, scrub)(" after = " SIZE_FORMAT ".", _n_coarse_entries); // Now do the fine-grained maps. @@ -646,7 +651,10 @@ void OtherRegionsTable::clear() { _first_all_fine_prts = _last_all_fine_prts = NULL; _sparse_table.clear(); - _coarse_map.clear(); + if (_coarse_dirty) { + _coarse_map.clear(); + _coarse_dirty = false; + } _n_fine_entries = 0; _n_coarse_entries = 0; diff --git a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp index baf2def1de6..7402b613a07 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp @@ -79,6 +79,7 @@ class OtherRegionsTable VALUE_OBJ_CLASS_SPEC { HeapRegion* _hr; // These are protected by "_m". + bool _coarse_dirty; BitMap _coarse_map; size_t _n_coarse_entries; static jint _n_coarsenings; -- GitLab From 39d3c3f51232bddcf38d4904a807163982edec88 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 2 May 2016 10:24:41 +0200 Subject: [PATCH 243/400] 8155229: Tune thread usage for live data clearing Reviewed-by: mgerdin, drwhite --- hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp b/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp index 05c8b9c0252..ea629dfb01f 100644 --- a/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp @@ -424,9 +424,12 @@ void G1CardLiveData::clear(WorkGang* workers) { guarantee(Universe::is_fully_initialized(), "Should not call this during initialization."); size_t const num_chunks = align_size_up(live_cards_bm().size_in_bytes(), G1ClearCardLiveDataTask::chunk_size()) / G1ClearCardLiveDataTask::chunk_size(); + uint const num_workers = (uint)MIN2(num_chunks, (size_t)workers->active_workers()); G1ClearCardLiveDataTask cl(live_cards_bm(), num_chunks); - workers->run_task(&cl); + + log_debug(gc, ergo)("Running %s using %u workers for " SIZE_FORMAT " work units.", cl.name(), num_workers, num_chunks); + workers->run_task(&cl, num_workers); // The region live bitmap is always very small, even for huge heaps. Clear // directly. -- GitLab From a0fa7abd147b7fd32b4e7198c8c2a1459c4b1b2f Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Mon, 2 May 2016 13:39:52 +0200 Subject: [PATCH 244/400] 8155819: Support non-continuous CodeBlobs in HotSpot broke Zero Adjust to CompiledMethod changes. Reviewed-by: coleenp, rbackman --- hotspot/src/cpu/zero/vm/frame_zero.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/cpu/zero/vm/frame_zero.cpp b/hotspot/src/cpu/zero/vm/frame_zero.cpp index fe1ee4f4f95..19acf03681e 100644 --- a/hotspot/src/cpu/zero/vm/frame_zero.cpp +++ b/hotspot/src/cpu/zero/vm/frame_zero.cpp @@ -360,7 +360,7 @@ void SharkFrame::identify_word(int frame_index, case pc_off: strncpy(fieldbuf, "pc", buflen); if (method()->is_method()) { - nmethod *code = method()->code(); + CompiledMethod *code = method()->code(); if (code && code->pc_desc_at(pc())) { SimpleScopeDesc ssd(code, pc()); snprintf(valuebuf, buflen, PTR_FORMAT " (bci %d)", -- GitLab From 461078c649b937cd796fad54480f2e58db4e5026 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 2 May 2016 14:13:05 +0200 Subject: [PATCH 245/400] 8155813: Fix indentation in G1RemSetScanState::clear_card_table() Reviewed-by: mgerdin --- hotspot/src/share/vm/gc/g1/g1RemSet.cpp | 32 ++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp index 6eb4e2a0494..757179cbb94 100644 --- a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp @@ -215,27 +215,27 @@ public: // Clear the card table of "dirty" regions. void clear_card_table(WorkGang* workers) { - if (_cur_dirty_region == 0) { - return; - } + if (_cur_dirty_region == 0) { + return; + } - size_t const num_chunks = align_size_up(_cur_dirty_region * HeapRegion::CardsPerRegion, G1ClearCardTableTask::chunk_size()) / G1ClearCardTableTask::chunk_size(); - uint const num_workers = (uint)MIN2(num_chunks, (size_t)workers->active_workers()); - size_t const chunk_length = G1ClearCardTableTask::chunk_size() / HeapRegion::CardsPerRegion; + size_t const num_chunks = align_size_up(_cur_dirty_region * HeapRegion::CardsPerRegion, G1ClearCardTableTask::chunk_size()) / G1ClearCardTableTask::chunk_size(); + uint const num_workers = (uint)MIN2(num_chunks, (size_t)workers->active_workers()); + size_t const chunk_length = G1ClearCardTableTask::chunk_size() / HeapRegion::CardsPerRegion; - // Iterate over the dirty cards region list. - G1ClearCardTableTask cl(G1CollectedHeap::heap(), _dirty_region_buffer, _cur_dirty_region, chunk_length); + // Iterate over the dirty cards region list. + G1ClearCardTableTask cl(G1CollectedHeap::heap(), _dirty_region_buffer, _cur_dirty_region, chunk_length); - log_debug(gc, ergo)("Running %s using %u workers for " SIZE_FORMAT " " - "units of work for " SIZE_FORMAT " regions.", - cl.name(), num_workers, num_chunks, _cur_dirty_region); - workers->run_task(&cl, num_workers); + log_debug(gc, ergo)("Running %s using %u workers for " SIZE_FORMAT " " + "units of work for " SIZE_FORMAT " regions.", + cl.name(), num_workers, num_chunks, _cur_dirty_region); + workers->run_task(&cl, num_workers); #ifndef PRODUCT - // Need to synchronize with concurrent cleanup since it needs to - // finish its card table clearing before we can verify. - G1CollectedHeap::heap()->wait_while_free_regions_coming(); - G1CollectedHeap::heap()->verifier()->verify_card_table_cleanup(); + // Need to synchronize with concurrent cleanup since it needs to + // finish its card table clearing before we can verify. + G1CollectedHeap::heap()->wait_while_free_regions_coming(); + G1CollectedHeap::heap()->verifier()->verify_card_table_cleanup(); #endif } }; -- GitLab From d4bfb4226472fca97d9cf5427efae723eebc56e4 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Mon, 2 May 2016 14:14:16 +0200 Subject: [PATCH 246/400] 8155811: Remove HeapRegionRemSet::_coarse_dirty flag Reviewed-by: mgerdin, jmasa --- hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp | 10 +++------- hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp | 1 - 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp index 3fcfb3b76d6..e61cf55de33 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp @@ -265,8 +265,7 @@ OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) : _first_all_fine_prts(NULL), _last_all_fine_prts(NULL), _n_fine_entries(0), _n_coarse_entries(0), _fine_eviction_start(0), - _sparse_table(hr), - _coarse_dirty(false) + _sparse_table(hr) { typedef PerRegionTable* PerRegionTablePtr; @@ -505,7 +504,6 @@ PerRegionTable* OtherRegionsTable::delete_region_table() { size_t max_hrm_index = (size_t) max->hr()->hrm_index(); if (!_coarse_map.at(max_hrm_index)) { _coarse_map.at_put(max_hrm_index, true); - _coarse_dirty = true; _n_coarse_entries++; } @@ -521,10 +519,9 @@ void OtherRegionsTable::scrub(G1CardLiveData* live_data) { log_develop_trace(gc, remset, scrub)("Scrubbing region %u:", _hr->hrm_index()); log_develop_trace(gc, remset, scrub)(" Coarse map: before = " SIZE_FORMAT "...", _n_coarse_entries); - if (_coarse_dirty) { + if (_n_coarse_entries > 0) { live_data->remove_nonlive_regions(&_coarse_map); _n_coarse_entries = _coarse_map.count_one_bits(); - _coarse_dirty = _n_coarse_entries != 0; } log_develop_trace(gc, remset, scrub)(" after = " SIZE_FORMAT ".", _n_coarse_entries); @@ -651,9 +648,8 @@ void OtherRegionsTable::clear() { _first_all_fine_prts = _last_all_fine_prts = NULL; _sparse_table.clear(); - if (_coarse_dirty) { + if (_n_coarse_entries > 0) { _coarse_map.clear(); - _coarse_dirty = false; } _n_fine_entries = 0; _n_coarse_entries = 0; diff --git a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp index 7402b613a07..baf2def1de6 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp @@ -79,7 +79,6 @@ class OtherRegionsTable VALUE_OBJ_CLASS_SPEC { HeapRegion* _hr; // These are protected by "_m". - bool _coarse_dirty; BitMap _coarse_map; size_t _n_coarse_entries; static jint _n_coarsenings; -- GitLab From 081466c0e7b4e46a52b54d7ca4a364b5d7064ede Mon Sep 17 00:00:00 2001 From: Derek White Date: Mon, 2 May 2016 11:18:10 -0400 Subject: [PATCH 247/400] 8155754: Quarantine serviceability/tmtools/jstat/GcTest02.java Add @ignore 8155570 Reviewed-by: kbarrett, stefank --- hotspot/test/serviceability/tmtools/jstat/GcTest02.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/test/serviceability/tmtools/jstat/GcTest02.java b/hotspot/test/serviceability/tmtools/jstat/GcTest02.java index 8924221703e..171b87b78e5 100644 --- a/hotspot/test/serviceability/tmtools/jstat/GcTest02.java +++ b/hotspot/test/serviceability/tmtools/jstat/GcTest02.java @@ -33,6 +33,7 @@ import utils.*; * @library ../share * @build common.* * @build utils.* + * @ignore 8155570 * @run main/othervm -XX:+UsePerfData -Xmx128M -XX:MaxMetaspaceSize=128M GcTest02 */ -- GitLab From 547e7327906e8aae3b303f4fa04c6c398c592ea2 Mon Sep 17 00:00:00 2001 From: Yu Zhang Date: Mon, 2 May 2016 17:45:19 +0200 Subject: [PATCH 248/400] 8154955: Negative Other Time in gc logs due to 'Wait for Root Region Scan' not included Move the note_gc_start() call before the wait_for_root_region_scanning() one. Reviewed-by: kbarrett, tschatzl --- hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index 9a1a653c11c..e7fdb0a21b8 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -3106,6 +3106,8 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { SvcGCMarker sgcm(SvcGCMarker::MINOR); ResourceMark rm; + g1_policy()->note_gc_start(); + wait_for_root_region_scanning(); print_heap_before_gc(); @@ -3165,8 +3167,6 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { Threads::number_of_non_daemon_threads()); workers()->set_active_workers(active_workers); - g1_policy()->note_gc_start(); - TraceCollectorStats tcs(g1mm()->incremental_collection_counters()); TraceMemoryManagerStats tms(false /* fullGC */, gc_cause()); -- GitLab From c4bafa7975a7fb4079228e07a2509716c5bb074d Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Mon, 2 May 2016 12:07:58 -0400 Subject: [PATCH 249/400] 8155524: HotCardCache shouldn't be part of ConcurrentG1Refine Make G1CollectedHeap owner of HotCardCache. Reviewed-by: jmasa, mgerdin, tschatzl --- .../src/share/vm/gc/g1/concurrentG1Refine.cpp | 21 ++++------- .../src/share/vm/gc/g1/concurrentG1Refine.hpp | 26 ++++---------- .../src/share/vm/gc/g1/g1CollectedHeap.cpp | 35 ++++++++++--------- .../src/share/vm/gc/g1/g1CollectedHeap.hpp | 4 +++ .../src/share/vm/gc/g1/g1DefaultPolicy.cpp | 3 +- hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp | 6 ++-- hotspot/src/share/vm/gc/g1/g1RemSet.cpp | 21 ++++++----- hotspot/src/share/vm/gc/g1/g1RemSet.hpp | 9 ++--- .../src/share/vm/gc/g1/g1RemSetSummary.cpp | 1 + 9 files changed, 57 insertions(+), 69 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/concurrentG1Refine.cpp b/hotspot/src/share/vm/gc/g1/concurrentG1Refine.cpp index 9295f71e656..06b3f1cae5f 100644 --- a/hotspot/src/share/vm/gc/g1/concurrentG1Refine.cpp +++ b/hotspot/src/share/vm/gc/g1/concurrentG1Refine.cpp @@ -25,9 +25,10 @@ #include "precompiled.hpp" #include "gc/g1/concurrentG1Refine.hpp" #include "gc/g1/concurrentG1RefineThread.hpp" -#include "gc/g1/g1CollectedHeap.inline.hpp" -#include "gc/g1/g1HotCardCache.hpp" +#include "gc/g1/g1YoungRemSetSamplingThread.hpp" +#include "logging/log.hpp" #include "runtime/java.hpp" +#include "runtime/thread.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/pair.hpp" @@ -111,8 +112,7 @@ static Thresholds calc_thresholds(size_t green_zone, green_zone + deactivate_offset); } -ConcurrentG1Refine::ConcurrentG1Refine(G1CollectedHeap* g1h, - size_t green_zone, +ConcurrentG1Refine::ConcurrentG1Refine(size_t green_zone, size_t yellow_zone, size_t red_zone, size_t min_yellow_zone_size) : @@ -122,8 +122,7 @@ ConcurrentG1Refine::ConcurrentG1Refine(G1CollectedHeap* g1h, _green_zone(green_zone), _yellow_zone(yellow_zone), _red_zone(red_zone), - _min_yellow_zone_size(min_yellow_zone_size), - _hot_card_cache(g1h) + _min_yellow_zone_size(min_yellow_zone_size) { assert_zone_constraints_gyr(green_zone, yellow_zone, red_zone); } @@ -170,8 +169,7 @@ static size_t calc_init_red_zone(size_t green, size_t yellow) { return MIN2(yellow + size, max_red_zone); } -ConcurrentG1Refine* ConcurrentG1Refine::create(G1CollectedHeap* g1h, - CardTableEntryClosure* refine_closure, +ConcurrentG1Refine* ConcurrentG1Refine::create(CardTableEntryClosure* refine_closure, jint* ecode) { size_t min_yellow_zone_size = calc_min_yellow_zone_size(); size_t green_zone = calc_init_green_zone(); @@ -185,8 +183,7 @@ ConcurrentG1Refine* ConcurrentG1Refine::create(G1CollectedHeap* g1h, "min yellow size: " SIZE_FORMAT, green_zone, yellow_zone, red_zone, min_yellow_zone_size); - ConcurrentG1Refine* cg1r = new ConcurrentG1Refine(g1h, - green_zone, + ConcurrentG1Refine* cg1r = new ConcurrentG1Refine(green_zone, yellow_zone, red_zone, min_yellow_zone_size); @@ -240,10 +237,6 @@ ConcurrentG1Refine* ConcurrentG1Refine::create(G1CollectedHeap* g1h, return cg1r; } -void ConcurrentG1Refine::init(G1RegionToSpaceMapper* card_counts_storage) { - _hot_card_cache.initialize(card_counts_storage); -} - void ConcurrentG1Refine::stop() { for (uint i = 0; i < _n_worker_threads; i++) { _threads[i]->stop(); diff --git a/hotspot/src/share/vm/gc/g1/concurrentG1Refine.hpp b/hotspot/src/share/vm/gc/g1/concurrentG1Refine.hpp index 098d49e801d..9c3461ea107 100644 --- a/hotspot/src/share/vm/gc/g1/concurrentG1Refine.hpp +++ b/hotspot/src/share/vm/gc/g1/concurrentG1Refine.hpp @@ -25,20 +25,15 @@ #ifndef SHARE_VM_GC_G1_CONCURRENTG1REFINE_HPP #define SHARE_VM_GC_G1_CONCURRENTG1REFINE_HPP -#include "gc/g1/g1HotCardCache.hpp" -#include "gc/g1/g1YoungRemSetSamplingThread.hpp" #include "memory/allocation.hpp" -#include "runtime/thread.hpp" #include "utilities/globalDefinitions.hpp" // Forward decl +class CardTableEntryClosure; class ConcurrentG1RefineThread; -class G1CollectedHeap; -class G1HotCardCache; -class G1Predictions; -class G1RegionToSpaceMapper; -class G1RemSet; -class DirtyCardQueue; +class G1YoungRemSetSamplingThread; +class outputStream; +class ThreadClosure; class ConcurrentG1Refine: public CHeapObj { G1YoungRemSetSamplingThread* _sample_thread; @@ -67,11 +62,7 @@ class ConcurrentG1Refine: public CHeapObj { size_t _red_zone; size_t _min_yellow_zone_size; - // We delay the refinement of 'hot' cards using the hot card cache. - G1HotCardCache _hot_card_cache; - - ConcurrentG1Refine(G1CollectedHeap* g1h, - size_t green_zone, + ConcurrentG1Refine(size_t green_zone, size_t yellow_zone, size_t red_zone, size_t min_yellow_zone_size); @@ -89,9 +80,8 @@ class ConcurrentG1Refine: public CHeapObj { // Returns ConcurrentG1Refine instance if succeeded to create/initialize ConcurrentG1Refine and ConcurrentG1RefineThread. // Otherwise, returns NULL with error code. - static ConcurrentG1Refine* create(G1CollectedHeap* g1h, CardTableEntryClosure* refine_closure, jint* ecode); + static ConcurrentG1Refine* create(CardTableEntryClosure* refine_closure, jint* ecode); - void init(G1RegionToSpaceMapper* card_counts_storage); void stop(); void adjust(double update_rs_time, size_t update_rs_processed_buffers, double goal_ms); @@ -112,10 +102,6 @@ class ConcurrentG1Refine: public CHeapObj { size_t green_zone() const { return _green_zone; } size_t yellow_zone() const { return _yellow_zone; } size_t red_zone() const { return _red_zone; } - - G1HotCardCache* hot_card_cache() { return &_hot_card_cache; } - - static bool hot_card_cache_enabled() { return G1HotCardCache::default_use_cache(); } }; #endif // SHARE_VM_GC_G1_CONCURRENTG1REFINE_HPP diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index e7fdb0a21b8..e4fb2f21576 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -42,6 +42,7 @@ #include "gc/g1/g1HeapSizingPolicy.hpp" #include "gc/g1/g1HeapTransition.hpp" #include "gc/g1/g1HeapVerifier.hpp" +#include "gc/g1/g1HotCardCache.hpp" #include "gc/g1/g1MarkSweep.hpp" #include "gc/g1/g1OopClosures.inline.hpp" #include "gc/g1/g1ParScanThreadState.inline.hpp" @@ -1322,10 +1323,9 @@ bool G1CollectedHeap::do_full_collection(bool explicit_gc, // the compaction events. print_hrm_post_compaction(); - G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache(); - if (hot_card_cache->use_cache()) { - hot_card_cache->reset_card_counts(); - hot_card_cache->reset_hot_cache(); + if (_hot_card_cache->use_cache()) { + _hot_card_cache->reset_card_counts(); + _hot_card_cache->reset_hot_cache(); } // Rebuild remembered sets of all regions. @@ -1704,6 +1704,8 @@ G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* collector_policy) : _ref_processor_cm(NULL), _ref_processor_stw(NULL), _bot(NULL), + _hot_card_cache(NULL), + _g1_rem_set(NULL), _cg1r(NULL), _g1mm(NULL), _refine_cte_cl(NULL), @@ -1817,7 +1819,7 @@ jint G1CollectedHeap::initialize() { _refine_cte_cl = new RefineCardTableEntryClosure(); jint ecode = JNI_OK; - _cg1r = ConcurrentG1Refine::create(this, _refine_cte_cl, &ecode); + _cg1r = ConcurrentG1Refine::create(_refine_cte_cl, &ecode); if (_cg1r == NULL) { return ecode; } @@ -1847,8 +1849,11 @@ jint G1CollectedHeap::initialize() { assert(bs->is_a(BarrierSet::G1SATBCTLogging), "sanity"); set_barrier_set(bs); + // Create the hot card cache. + _hot_card_cache = new G1HotCardCache(this); + // Also create a G1 rem set. - _g1_rem_set = new G1RemSet(this, g1_barrier_set()); + _g1_rem_set = new G1RemSet(this, g1_barrier_set(), _hot_card_cache); // Carve out the G1 part of the heap. ReservedSpace g1_rs = heap_rs.first_part(max_byte_size); @@ -1893,8 +1898,8 @@ jint G1CollectedHeap::initialize() { _hrm.initialize(heap_storage, prev_bitmap_storage, next_bitmap_storage, bot_storage, cardtable_storage, card_counts_storage); g1_barrier_set()->initialize(cardtable_storage); - // Do later initialization work for concurrent refinement. - _cg1r->init(card_counts_storage); + // Do later initialization work for concurrent refinement. + _hot_card_cache->initialize(card_counts_storage); // 6843694 - ensure that the maximum region index can fit // in the remembered set structures. @@ -2123,7 +2128,7 @@ void G1CollectedHeap::check_gc_time_stamps() { #endif // PRODUCT void G1CollectedHeap::iterate_hcc_closure(CardTableEntryClosure* cl, uint worker_i) { - _cg1r->hot_card_cache()->drain(cl, worker_i); + _hot_card_cache->drain(cl, worker_i); } void G1CollectedHeap::iterate_dirty_card_closure(CardTableEntryClosure* cl, uint worker_i) { @@ -4510,9 +4515,8 @@ void G1CollectedHeap::pre_evacuate_collection_set() { _evacuation_failed = false; // Disable the hot card cache. - G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache(); - hot_card_cache->reset_hot_cache_claimed_index(); - hot_card_cache->set_use_cache(false); + _hot_card_cache->reset_hot_cache_claimed_index(); + _hot_card_cache->set_use_cache(false); g1_rem_set()->prepare_for_oops_into_collection_set_do(); _preserved_marks_set.assert_empty(); @@ -4615,9 +4619,8 @@ void G1CollectedHeap::post_evacuate_collection_set(EvacuationInfo& evacuation_in // Reset and re-enable the hot card cache. // Note the counts for the cards in the regions in the // collection set are reset when the collection set is freed. - G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache(); - hot_card_cache->reset_hot_cache(); - hot_card_cache->set_use_cache(true); + _hot_card_cache->reset_hot_cache(); + _hot_card_cache->set_use_cache(true); purge_code_root_memory(); @@ -4652,7 +4655,7 @@ void G1CollectedHeap::free_region(HeapRegion* hr, // Note: we only need to do this if the region is not young // (since we don't refine cards in young regions). if (!hr->is_young()) { - _cg1r->hot_card_cache()->reset_card_counts(hr); + _hot_card_cache->reset_card_counts(hr); } hr->hr_clear(par, true /* clear_space */, locked /* locked */); free_list->add_ordered(hr); diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp index c452e1c783d..2962cc24008 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp @@ -71,6 +71,7 @@ class Space; class G1CollectionSet; class G1CollectorPolicy; class G1Policy; +class G1HotCardCache; class G1RemSet; class HeapRegionRemSetIterator; class G1ConcurrentMark; @@ -762,6 +763,9 @@ protected: // Update object copying statistics. void record_obj_copy_mem_stats(); + // The hot card cache for remembered set insertion optimization. + G1HotCardCache* _hot_card_cache; + // The g1 remembered set of the heap. G1RemSet* _g1_rem_set; diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index e8922f5d9d4..03aa91cf823 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -30,6 +30,7 @@ #include "gc/g1/g1CollectionSet.hpp" #include "gc/g1/g1ConcurrentMark.hpp" #include "gc/g1/g1DefaultPolicy.hpp" +#include "gc/g1/g1HotCardCache.hpp" #include "gc/g1/g1IHOPControl.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1Policy.hpp" @@ -675,7 +676,7 @@ void G1DefaultPolicy::record_collection_pause_end(double pause_time_ms, size_t c _short_lived_surv_rate_group->start_adding_regions(); // Do that for any other surv rate groups - double scan_hcc_time_ms = ConcurrentG1Refine::hot_card_cache_enabled() ? average_time_ms(G1GCPhaseTimes::ScanHCC) : 0.0; + double scan_hcc_time_ms = G1HotCardCache::default_use_cache() ? average_time_ms(G1GCPhaseTimes::ScanHCC) : 0.0; if (update_stats) { double cost_per_card_ms = 0.0; diff --git a/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp b/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp index bc7b17cef76..f7e8b1db586 100644 --- a/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp +++ b/hotspot/src/share/vm/gc/g1/g1GCPhaseTimes.cpp @@ -23,9 +23,9 @@ */ #include "precompiled.hpp" -#include "gc/g1/concurrentG1Refine.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" +#include "gc/g1/g1HotCardCache.hpp" #include "gc/g1/g1StringDedup.hpp" #include "gc/g1/workerDataArray.inline.hpp" #include "memory/resourceArea.hpp" @@ -60,7 +60,7 @@ G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads) : _gc_par_phases[SATBFiltering] = new WorkerDataArray(max_gc_threads, "SATB Filtering (ms):"); _gc_par_phases[UpdateRS] = new WorkerDataArray(max_gc_threads, "Update RS (ms):"); - if (ConcurrentG1Refine::hot_card_cache_enabled()) { + if (G1HotCardCache::default_use_cache()) { _gc_par_phases[ScanHCC] = new WorkerDataArray(max_gc_threads, "Scan HCC (ms):"); } else { _gc_par_phases[ScanHCC] = NULL; @@ -255,7 +255,7 @@ void G1GCPhaseTimes::print() { trace_phase(_gc_par_phases[i]); } debug_phase(_gc_par_phases[UpdateRS]); - if (ConcurrentG1Refine::hot_card_cache_enabled()) { + if (G1HotCardCache::default_use_cache()) { trace_phase(_gc_par_phases[ScanHCC]); } debug_phase(_gc_par_phases[ScanRS]); diff --git a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp index 757179cbb94..9871a7ce962 100644 --- a/hotspot/src/share/vm/gc/g1/g1RemSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RemSet.cpp @@ -24,7 +24,6 @@ #include "precompiled.hpp" #include "gc/g1/concurrentG1Refine.hpp" -#include "gc/g1/concurrentG1RefineThread.hpp" #include "gc/g1/dirtyCardQueue.hpp" #include "gc/g1/g1BlockOffsetTable.inline.hpp" #include "gc/g1/g1CollectedHeap.inline.hpp" @@ -240,13 +239,15 @@ public: } }; -G1RemSet::G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs) : +G1RemSet::G1RemSet(G1CollectedHeap* g1, + CardTableModRefBS* ct_bs, + G1HotCardCache* hot_card_cache) : _g1(g1), _scan_state(new G1RemSetScanState()), _conc_refine_cards(0), _ct_bs(ct_bs), _g1p(_g1->g1_policy()), - _cg1r(g1->concurrent_g1_refine()), + _hot_card_cache(hot_card_cache), _prev_period_summary(), _into_cset_dirty_card_queue_set(false) { @@ -437,7 +438,7 @@ void G1RemSet::update_rem_set(DirtyCardQueue* into_cset_dcq, RefineRecordRefsIntoCSCardTableEntryClosure into_cset_update_rs_cl(_g1, into_cset_dcq, oops_in_heap_closure); G1GCParPhaseTimesTracker x(_g1p->phase_times(), G1GCPhaseTimes::UpdateRS, worker_i); - if (ConcurrentG1Refine::hot_card_cache_enabled()) { + if (G1HotCardCache::default_use_cache()) { // Apply the closure to the entries of the hot card cache. G1GCParPhaseTimesTracker y(_g1p->phase_times(), G1GCPhaseTimes::ScanHCC, worker_i); _g1->iterate_hcc_closure(&into_cset_update_rs_cl, worker_i); @@ -614,12 +615,11 @@ bool G1RemSet::refine_card(jbyte* card_ptr, // * a pointer to a "hot" card that was evicted from the "hot" cache. // - G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache(); - if (hot_card_cache->use_cache()) { + if (_hot_card_cache->use_cache()) { assert(!check_for_refs_into_cset, "sanity"); assert(!SafepointSynchronize::is_at_safepoint(), "sanity"); - card_ptr = hot_card_cache->insert(card_ptr); + card_ptr = _hot_card_cache->insert(card_ptr); if (card_ptr == NULL) { // There was no eviction. Nothing to do. return false; @@ -754,15 +754,14 @@ void G1RemSet::prepare_for_verify() { dcqs.concatenate_logs(); } - G1HotCardCache* hot_card_cache = _cg1r->hot_card_cache(); - bool use_hot_card_cache = hot_card_cache->use_cache(); - hot_card_cache->set_use_cache(false); + bool use_hot_card_cache = _hot_card_cache->use_cache(); + _hot_card_cache->set_use_cache(false); DirtyCardQueue into_cset_dcq(&_into_cset_dirty_card_queue_set); update_rem_set(&into_cset_dcq, NULL, 0); _into_cset_dirty_card_queue_set.clear(); - hot_card_cache->set_use_cache(use_hot_card_cache); + _hot_card_cache->set_use_cache(use_hot_card_cache); assert(JavaThread::dirty_card_queue_set().completed_buffers_num() == 0, "All should be consumed"); } } diff --git a/hotspot/src/share/vm/gc/g1/g1RemSet.hpp b/hotspot/src/share/vm/gc/g1/g1RemSet.hpp index 63b9f1fbab8..561b3cfe072 100644 --- a/hotspot/src/share/vm/gc/g1/g1RemSet.hpp +++ b/hotspot/src/share/vm/gc/g1/g1RemSet.hpp @@ -38,9 +38,9 @@ class BitMap; class CardTableModRefBS; class G1BlockOffsetTable; -class ConcurrentG1Refine; class CodeBlobClosure; class G1CollectedHeap; +class G1HotCardCache; class G1ParPushHeapRSClosure; class G1RemSetScanState; class G1Policy; @@ -71,8 +71,7 @@ protected: protected: CardTableModRefBS* _ct_bs; G1Policy* _g1p; - - ConcurrentG1Refine* _cg1r; + G1HotCardCache* _hot_card_cache; public: // Gives an approximation on how many threads can be expected to add records to @@ -90,7 +89,9 @@ public: // scanned. void cleanupHRRS(); - G1RemSet(G1CollectedHeap* g1, CardTableModRefBS* ct_bs); + G1RemSet(G1CollectedHeap* g1, + CardTableModRefBS* ct_bs, + G1HotCardCache* hot_card_cache); ~G1RemSet(); // Invoke "cl->do_oop" on all pointers into the collection set diff --git a/hotspot/src/share/vm/gc/g1/g1RemSetSummary.cpp b/hotspot/src/share/vm/gc/g1/g1RemSetSummary.cpp index 5b226d1d5a4..25da0b03f54 100644 --- a/hotspot/src/share/vm/gc/g1/g1RemSetSummary.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RemSetSummary.cpp @@ -28,6 +28,7 @@ #include "gc/g1/g1CollectedHeap.inline.hpp" #include "gc/g1/g1RemSet.inline.hpp" #include "gc/g1/g1RemSetSummary.hpp" +#include "gc/g1/g1YoungRemSetSamplingThread.hpp" #include "gc/g1/heapRegion.hpp" #include "gc/g1/heapRegionRemSet.hpp" #include "memory/allocation.inline.hpp" -- GitLab From 7933c418de72aeb992a387454a3238c833b68d3e Mon Sep 17 00:00:00 2001 From: Mikael Vidstedt Date: Tue, 3 May 2016 08:12:25 -0700 Subject: [PATCH 250/400] 8153892: Handle unsafe access error directly in signal handler instead of going through a stub Reviewed-by: stuefe, dholmes --- hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp | 13 ---- .../src/cpu/sparc/vm/stubGenerator_sparc.cpp | 75 +------------------ .../src/cpu/x86/vm/stubGenerator_x86_32.cpp | 41 +--------- .../src/cpu/x86/vm/stubGenerator_x86_64.cpp | 46 +----------- .../src/cpu/zero/vm/stubGenerator_zero.cpp | 6 +- hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp | 16 ++-- hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp | 6 +- .../linux_aarch64/vm/os_linux_aarch64.cpp | 23 +----- .../src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp | 14 ++-- .../os_cpu/linux_sparc/vm/os_linux_sparc.cpp | 8 +- .../src/os_cpu/linux_x86/vm/os_linux_x86.cpp | 6 +- .../solaris_sparc/vm/os_solaris_sparc.cpp | 4 +- .../os_cpu/solaris_x86/vm/os_solaris_x86.cpp | 6 +- .../src/share/vm/runtime/sharedRuntime.cpp | 15 ++++ .../src/share/vm/runtime/sharedRuntime.hpp | 2 + hotspot/src/share/vm/runtime/stubRoutines.cpp | 1 - hotspot/src/share/vm/runtime/stubRoutines.hpp | 5 -- 17 files changed, 54 insertions(+), 233 deletions(-) diff --git a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp index 2eba3edacef..58222baa2fa 100644 --- a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp @@ -825,17 +825,6 @@ class StubGenerator: public StubCodeGenerator { return start; } - // The following routine generates a subroutine to throw an asynchronous - // UnknownError when an unsafe access gets a fault that could not be - // reasonably prevented by the programmer. (Example: SIGBUS/OBJERR.) - // - address generate_handler_for_unsafe_access() { - StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); - address start = __ function_entry(); - __ unimplemented("StubRoutines::handler_for_unsafe_access", 93); - return start; - } - #if !defined(PRODUCT) // Wrapper which calls oopDesc::is_oop_or_null() // Only called by MacroAssembler::verify_oop @@ -3111,8 +3100,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError), false); 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); - StubRoutines::_handler_for_unsafe_access_entry = generate_handler_for_unsafe_access(); - // support for verify_oop (must happen after universe_init) StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop(); diff --git a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp index db2c5eefac8..efac738816a 100644 --- a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,20 +64,6 @@ static const Register& Lstub_temp = L2; // ------------------------------------------------------------------------------------------------------------------------- // Stub Code definitions -static address handle_unsafe_access() { - JavaThread* thread = JavaThread::current(); - address pc = thread->saved_exception_pc(); - address npc = thread->saved_exception_npc(); - // pc is the instruction which we must emulate - // doing a no-op is fine: return garbage from the load - - // request an async exception - thread->set_pending_unsafe_access_error(); - - // return address of next instruction to execute - return npc; -} - class StubGenerator: public StubCodeGenerator { private: @@ -746,62 +732,6 @@ class StubGenerator: public StubCodeGenerator { Label _atomic_add_stub; // called from other stubs - //------------------------------------------------------------------------------------------------------------------------ - // The following routine generates a subroutine to throw an asynchronous - // UnknownError when an unsafe access gets a fault that could not be - // reasonably prevented by the programmer. (Example: SIGBUS/OBJERR.) - // - // Arguments : - // - // trapping PC: O7 - // - // Results: - // posts an asynchronous exception, skips the trapping instruction - // - - address generate_handler_for_unsafe_access() { - StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); - address start = __ pc(); - - const int preserve_register_words = (64 * 2); - Address preserve_addr(FP, (-preserve_register_words * wordSize) + STACK_BIAS); - - Register Lthread = L7_thread_cache; - int i; - - __ save_frame(0); - __ mov(G1, L1); - __ mov(G2, L2); - __ mov(G3, L3); - __ mov(G4, L4); - __ mov(G5, L5); - for (i = 0; i < 64; i += 2) { - __ stf(FloatRegisterImpl::D, as_FloatRegister(i), preserve_addr, i * wordSize); - } - - address entry_point = CAST_FROM_FN_PTR(address, handle_unsafe_access); - BLOCK_COMMENT("call handle_unsafe_access"); - __ call(entry_point, relocInfo::runtime_call_type); - __ delayed()->nop(); - - __ mov(L1, G1); - __ mov(L2, G2); - __ mov(L3, G3); - __ mov(L4, G4); - __ mov(L5, G5); - for (i = 0; i < 64; i += 2) { - __ ldf(FloatRegisterImpl::D, preserve_addr, as_FloatRegister(i), i * wordSize); - } - - __ verify_thread(); - - __ jmp(O0, 0); - __ delayed()->restore(); - - return start; - } - - // Support for uint StubRoutine::Sparc::partial_subtype_check( Klass sub, Klass super ); // Arguments : // @@ -5380,9 +5310,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError)); StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call)); - StubRoutines::_handler_for_unsafe_access_entry = - generate_handler_for_unsafe_access(); - // support for verify_oop (must happen after universe_init) StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop_subroutine(); diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp index 66a819a07f7..adcfe63b39f 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,21 +63,6 @@ const int FPU_CNTRL_WRD_MASK = 0xFFFF; // ------------------------------------------------------------------------------------------------------------------------- // Stub Code definitions -static address handle_unsafe_access() { - JavaThread* thread = JavaThread::current(); - address pc = thread->saved_exception_pc(); - // pc is the instruction which we must emulate - // doing a no-op is fine: return garbage from the load - // therefore, compute npc - address npc = Assembler::locate_next_instruction(pc); - - // request an async exception - thread->set_pending_unsafe_access_error(); - - // return address of next instruction to execute - return npc; -} - class StubGenerator: public StubCodeGenerator { private: @@ -623,27 +608,6 @@ class StubGenerator: public StubCodeGenerator { } - //--------------------------------------------------------------------------- - // The following routine generates a subroutine to throw an asynchronous - // UnknownError when an unsafe access gets a fault that could not be - // reasonably prevented by the programmer. (Example: SIGBUS/OBJERR.) - address generate_handler_for_unsafe_access() { - StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); - address start = __ pc(); - - __ push(0); // hole for return address-to-be - __ pusha(); // push registers - Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord); - BLOCK_COMMENT("call handle_unsafe_access"); - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access))); - __ movptr(next_pc, rax); // stuff next address - __ popa(); - __ ret(0); // jump to next address - - return start; - } - - //---------------------------------------------------------------------------------------------------- // Non-destructive plausibility checks for oops @@ -3865,9 +3829,6 @@ class StubGenerator: public StubCodeGenerator { // These are currently used by Solaris/Intel StubRoutines::_atomic_xchg_entry = generate_atomic_xchg(); - StubRoutines::_handler_for_unsafe_access_entry = - generate_handler_for_unsafe_access(); - // platform dependent create_control_words(); diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp index 3d8acc78947..9d3bb2d03df 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,21 +61,6 @@ const int MXCSR_MASK = 0xFFC0; // Mask out any pending exceptions // Stub Code definitions -static address handle_unsafe_access() { - JavaThread* thread = JavaThread::current(); - address pc = thread->saved_exception_pc(); - // pc is the instruction which we must emulate - // doing a no-op is fine: return garbage from the load - // therefore, compute npc - address npc = Assembler::locate_next_instruction(pc); - - // request an async exception - thread->set_pending_unsafe_access_error(); - - // return address of next instruction to execute - return npc; -} - class StubGenerator: public StubCodeGenerator { private: @@ -989,32 +974,6 @@ class StubGenerator: public StubCodeGenerator { return start; } - // The following routine generates a subroutine to throw an - // asynchronous UnknownError when an unsafe access gets a fault that - // could not be reasonably prevented by the programmer. (Example: - // SIGBUS/OBJERR.) - address generate_handler_for_unsafe_access() { - StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); - address start = __ pc(); - - __ push(0); // hole for return address-to-be - __ pusha(); // push registers - Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord); - - // FIXME: this probably needs alignment logic - - __ subptr(rsp, frame::arg_reg_save_area_bytes); - BLOCK_COMMENT("call handle_unsafe_access"); - __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access))); - __ addptr(rsp, frame::arg_reg_save_area_bytes); - - __ movptr(next_pc, rax); // stuff next address - __ popa(); - __ ret(0); // jump to next address - - return start; - } - // Non-destructive plausibility checks for oops // // Arguments: @@ -5136,9 +5095,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_atomic_add_ptr_entry = generate_atomic_add_ptr(); StubRoutines::_fence_entry = generate_orderaccess_fence(); - StubRoutines::_handler_for_unsafe_access_entry = - generate_handler_for_unsafe_access(); - // platform dependent StubRoutines::x86::_get_previous_fp_entry = generate_get_previous_fp(); StubRoutines::x86::_get_previous_sp_entry = generate_get_previous_sp(); diff --git a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp index bdaec67cd73..9d64fb99e94 100644 --- a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp +++ b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2010, 2015 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -261,10 +261,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_atomic_add_entry = ShouldNotCallThisStub(); StubRoutines::_atomic_add_ptr_entry = ShouldNotCallThisStub(); StubRoutines::_fence_entry = ShouldNotCallThisStub(); - - // amd64 does this here, sparc does it in generate_all() - StubRoutines::_handler_for_unsafe_access_entry = - ShouldNotCallThisStub(); } void generate_all() { diff --git a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp index 824d4d7a820..211a2dc3323 100644 --- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp +++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp @@ -392,11 +392,9 @@ JVM_handle_aix_signal(int sig, siginfo_t* info, void* ucVoid, int abort_if_unrec CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { - // We don't really need a stub here! Just set the pending exeption and - // continue at the next instruction after the faulting read. Returning - // garbage from this read is ok. - thread->set_pending_unsafe_access_error(); - os::Aix::ucontext_set_pc(uc, pc + 4); + address next_pc = pc + 4; + next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); + os::Aix::ucontext_set_pc(uc, next_pc); return 1; } } @@ -415,11 +413,9 @@ JVM_handle_aix_signal(int sig, siginfo_t* info, void* ucVoid, int abort_if_unrec } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && thread->doing_unsafe_access()) { - // We don't really need a stub here! Just set the pending exeption and - // continue at the next instruction after the faulting read. Returning - // garbage from this read is ok. - thread->set_pending_unsafe_access_error(); - os::Aix::ucontext_set_pc(uc, pc + 4); + address next_pc = pc + 4; + next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); + os::Aix::ucontext_set_pc(uc, next_pc); return 1; } } diff --git a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp index 911dfe50fed..9fe34fc1770 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp +++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp @@ -584,7 +584,8 @@ JVM_handle_bsd_signal(int sig, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + address next_pc = Assembler::locate_next_instruction(pc); + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } } else @@ -655,7 +656,8 @@ JVM_handle_bsd_signal(int sig, } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && /* info->si_code == BUS_OBJERR && */ thread->doing_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + address next_pc = Assembler::locate_next_instruction(pc); + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } // jni_fast_GetField can trap at certain pc's if a GC kicks in diff --git a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp index e6070b63dd6..04179925e67 100644 --- a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp +++ b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp @@ -226,23 +226,6 @@ extern "C" void FetchNPFI () ; extern "C" void FetchNResume () ; #endif -// An operation in Unsafe has faulted. We're going to return to the -// instruction after the faulting load or store. We also set -// pending_unsafe_access_error so that at some point in the future our -// user will get a helpful message. -static address handle_unsafe_access(JavaThread* thread, address pc) { - // pc is the instruction which we must emulate - // doing a no-op is fine: return garbage from the load - // therefore, compute npc - address npc = pc + NativeCall::instruction_size; - - // request an async exception - thread->set_pending_unsafe_access_error(); - - // return address of next instruction to execute - return npc; -} - extern "C" JNIEXPORT int JVM_handle_linux_signal(int sig, siginfo_t* info, @@ -387,7 +370,8 @@ JVM_handle_linux_signal(int sig, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { - stub = handle_unsafe_access(thread, pc); + address next_pc = pc + NativeCall::instruction_size; + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } } else @@ -408,7 +392,8 @@ JVM_handle_linux_signal(int sig, } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && /* info->si_code == BUS_OBJERR && */ thread->doing_unsafe_access()) { - stub = handle_unsafe_access(thread, pc); + address next_pc = pc + NativeCall::instruction_size; + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } // jni_fast_GetField can trap at certain pc's if a GC kicks in diff --git a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp index 7ecf0ad8263..8cd04dce290 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp @@ -366,11 +366,9 @@ JVM_handle_linux_signal(int sig, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { - // We don't really need a stub here! Just set the pending exeption and - // continue at the next instruction after the faulting read. Returning - // garbage from this read is ok. - thread->set_pending_unsafe_access_error(); - os::Linux::ucontext_set_pc(uc, pc + 4); + address next_pc = pc + 4; + next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); + os::Linux::ucontext_set_pc(uc, next_pc); return true; } } @@ -385,10 +383,8 @@ JVM_handle_linux_signal(int sig, } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && thread->doing_unsafe_access()) { - // We don't really need a stub here! Just set the pending exeption and - // continue at the next instruction after the faulting read. Returning - // garbage from this read is ok. - thread->set_pending_unsafe_access_error(); + address next_pc = pc + 4; + next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); os::Linux::ucontext_set_pc(uc, pc + 4); return true; } diff --git a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp index 4f83c606600..4a0da12c498 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp @@ -433,14 +433,14 @@ inline static bool checkPollingPage(address pc, address fault, address* stub) { return false; } -inline static bool checkByteBuffer(address pc, address* stub) { +inline static bool checkByteBuffer(address pc, address npc, address* stub) { // BugId 4454115: A read from a MappedByteBuffer can fault // here if the underlying file has been truncated. // Do not crash the VM in such a case. CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { - *stub = StubRoutines::handler_for_unsafe_access(); + *stub = SharedRuntime::handle_unsafe_access(thread, npc); return true; } return false; @@ -613,7 +613,7 @@ JVM_handle_linux_signal(int sig, if (sig == SIGBUS && thread->thread_state() == _thread_in_vm && thread->doing_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + stub = SharedRuntime::handle_unsafe_access(thread, npc); } if (thread->thread_state() == _thread_in_Java) { @@ -625,7 +625,7 @@ JVM_handle_linux_signal(int sig, break; } - if ((sig == SIGBUS) && checkByteBuffer(pc, &stub)) { + if ((sig == SIGBUS) && checkByteBuffer(pc, npc, &stub)) { break; } diff --git a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp index 7d7aad54046..b73658ed036 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp +++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp @@ -420,7 +420,8 @@ JVM_handle_linux_signal(int sig, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + address next_pc = Assembler::locate_next_instruction(pc); + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } } else @@ -469,7 +470,8 @@ JVM_handle_linux_signal(int sig, } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && /* info->si_code == BUS_OBJERR && */ thread->doing_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + address next_pc = Assembler::locate_next_instruction(pc); + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } // jni_fast_GetField can trap at certain pc's if a GC kicks in diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp index 0fd9adf3c03..39663ed0e74 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp @@ -441,7 +441,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, if (thread->thread_state() == _thread_in_vm) { if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + stub = SharedRuntime::handle_unsafe_access(thread, npc); } } @@ -480,7 +480,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + stub = SharedRuntime::handle_unsafe_access(thread, npc); } } diff --git a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp index d1bc192646d..695fc127835 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp @@ -503,7 +503,8 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, if (thread->thread_state() == _thread_in_vm) { if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + address next_pc = Assembler::locate_next_instruction(pc); + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } } @@ -520,7 +521,8 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, if (cb != NULL) { CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { - stub = StubRoutines::handler_for_unsafe_access(); + address next_pc = Assembler::locate_next_instruction(pc); + stub = SharedRuntime::handle_unsafe_access(thread, next_pc); } } } diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index 0824a8a56df..4e0aec4a423 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -1762,6 +1762,21 @@ methodHandle SharedRuntime::reresolve_call_site(JavaThread *thread, TRAPS) { return callee_method; } +address SharedRuntime::handle_unsafe_access(JavaThread* thread, address next_pc) { + // The faulting unsafe accesses should be changed to throw the error + // synchronously instead. Meanwhile the faulting instruction will be + // skipped over (effectively turning it into a no-op) and an + // asynchronous exception will be raised which the thread will + // handle at a later point. If the instruction is a load it will + // return garbage. + + // Request an async exception. + thread->set_pending_unsafe_access_error(); + + // Return address of next instruction to execute. + return next_pc; +} + #ifdef ASSERT void SharedRuntime::check_member_name_argument_is_last_argument(const methodHandle& method, const BasicType* sig_bt, diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.hpp b/hotspot/src/share/vm/runtime/sharedRuntime.hpp index 52bca29cf72..eb9797f26f5 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp @@ -522,6 +522,8 @@ class SharedRuntime: AllStatic { static address handle_wrong_method_abstract(JavaThread* thread); static address handle_wrong_method_ic_miss(JavaThread* thread); + static address handle_unsafe_access(JavaThread* thread, address next_pc); + #ifndef PRODUCT // Collect and print inline cache miss statistics diff --git a/hotspot/src/share/vm/runtime/stubRoutines.cpp b/hotspot/src/share/vm/runtime/stubRoutines.cpp index 8a8f0fd4762..12e0e3a5b82 100644 --- a/hotspot/src/share/vm/runtime/stubRoutines.cpp +++ b/hotspot/src/share/vm/runtime/stubRoutines.cpp @@ -55,7 +55,6 @@ address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL; address StubRoutines::_throw_NullPointerException_at_call_entry = NULL; address StubRoutines::_throw_StackOverflowError_entry = NULL; address StubRoutines::_throw_delayed_StackOverflowError_entry = NULL; -address StubRoutines::_handler_for_unsafe_access_entry = NULL; jint StubRoutines::_verify_oop_count = 0; address StubRoutines::_verify_oop_subroutine_entry = NULL; address StubRoutines::_atomic_xchg_entry = NULL; diff --git a/hotspot/src/share/vm/runtime/stubRoutines.hpp b/hotspot/src/share/vm/runtime/stubRoutines.hpp index 49f3550c273..729886f04fd 100644 --- a/hotspot/src/share/vm/runtime/stubRoutines.hpp +++ b/hotspot/src/share/vm/runtime/stubRoutines.hpp @@ -111,7 +111,6 @@ class StubRoutines: AllStatic { static address _throw_NullPointerException_at_call_entry; static address _throw_StackOverflowError_entry; static address _throw_delayed_StackOverflowError_entry; - static address _handler_for_unsafe_access_entry; static address _atomic_xchg_entry; static address _atomic_xchg_ptr_entry; @@ -288,10 +287,6 @@ class StubRoutines: AllStatic { static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; } static address throw_delayed_StackOverflowError_entry() { return _throw_delayed_StackOverflowError_entry; } - // Exceptions during unsafe access - should throw Java exception rather - // than crash. - static address handler_for_unsafe_access() { return _handler_for_unsafe_access_entry; } - static address atomic_xchg_entry() { return _atomic_xchg_entry; } static address atomic_xchg_ptr_entry() { return _atomic_xchg_ptr_entry; } static address atomic_store_entry() { return _atomic_store_entry; } -- GitLab From 46d52062aae7ee95d1d9c9e177d547ead52432b5 Mon Sep 17 00:00:00 2001 From: Derek White Date: Mon, 2 May 2016 12:14:26 -0400 Subject: [PATCH 251/400] 8134889: Kitchensink stress test crashes with out of memory error Add a hard max of 16 GC threads (each for concurrent and parallel G1) on 32-bit JVMs. Reviewed-by: mgerdin, pliden --- hotspot/src/share/vm/runtime/vm_version.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/runtime/vm_version.cpp b/hotspot/src/share/vm/runtime/vm_version.cpp index c36098a31f7..dccdba36554 100644 --- a/hotspot/src/share/vm/runtime/vm_version.cpp +++ b/hotspot/src/share/vm/runtime/vm_version.cpp @@ -289,6 +289,7 @@ unsigned int Abstract_VM_Version::nof_parallel_worker_threads( unsigned int switch_pt) { if (FLAG_IS_DEFAULT(ParallelGCThreads)) { assert(ParallelGCThreads == 0, "Default ParallelGCThreads is not 0"); + unsigned int threads; // For very large machines, there are diminishing returns // for large numbers of worker threads. Instead of // hogging the whole system, use a fraction of the workers for every @@ -296,9 +297,20 @@ unsigned int Abstract_VM_Version::nof_parallel_worker_threads( // and a chosen fraction of 5/8 // use 8 + (72 - 8) * (5/8) == 48 worker threads. unsigned int ncpus = (unsigned int) os::active_processor_count(); - return (ncpus <= switch_pt) ? - ncpus : - (switch_pt + ((ncpus - switch_pt) * num) / den); + threads = (ncpus <= switch_pt) ? + ncpus : + (switch_pt + ((ncpus - switch_pt) * num) / den); +#ifndef _LP64 + // On 32-bit binaries the virtual address space available to the JVM + // is usually limited to 2-3 GB (depends on the platform). + // Do not use up address space with too many threads (stacks and per-thread + // data). Note that x86 apps running on Win64 have 2 stacks per thread. + // GC may more generally scale down threads by max heap size (etc), but the + // consequences of over-provisioning threads are higher on 32-bit JVMS, + // so add hard limit here: + threads = MIN2(threads, (2*switch_pt)); +#endif + return threads; } else { return ParallelGCThreads; } -- GitLab From 0adae4d9143ecc1cda9838051fb5c865608f079c Mon Sep 17 00:00:00 2001 From: David Holmes Date: Mon, 2 May 2016 19:38:15 -0400 Subject: [PATCH 252/400] 8154710: [Solaris] Investigate use of in-memory low-resolution timestamps for Java and internal time API's Reviewed-by: shade, rriggs, dcubed --- hotspot/src/os/solaris/vm/os_solaris.cpp | 33 +++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index 1d68dcc7721..dbb8d555b8f 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -1351,24 +1351,29 @@ double os::elapsedVTime() { return (double)gethrvtime() / (double)hrtime_hz; } -// Used internally for comparisons only -// getTimeMillis guaranteed to not move backwards on Solaris -jlong getTimeMillis() { - jlong nanotime = getTimeNanos(); - return (jlong)(nanotime / NANOSECS_PER_MILLISEC); -} +// in-memory timestamp support - has update accuracy of 1ms +typedef void (*_get_nsec_fromepoch_func_t)(hrtime_t*); +static _get_nsec_fromepoch_func_t _get_nsec_fromepoch = NULL; // Must return millis since Jan 1 1970 for JVM_CurrentTimeMillis jlong os::javaTimeMillis() { - timeval t; - if (gettimeofday(&t, NULL) == -1) { - fatal("os::javaTimeMillis: gettimeofday (%s)", os::strerror(errno)); + if (_get_nsec_fromepoch != NULL) { + hrtime_t now; + _get_nsec_fromepoch(&now); + return now / NANOSECS_PER_MILLISEC; + } + else { + timeval t; + if (gettimeofday(&t, NULL) == -1) { + fatal("os::javaTimeMillis: gettimeofday (%s)", os::strerror(errno)); + } + return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000; } - return jlong(t.tv_sec) * 1000 + jlong(t.tv_usec) / 1000; } void os::javaTimeSystemUTC(jlong &seconds, jlong &nanos) { timeval t; + // can't use get_nsec_fromepoch here as we need better accuracy than 1ms if (gettimeofday(&t, NULL) == -1) { fatal("os::javaTimeSystemUTC: gettimeofday (%s)", os::strerror(errno)); } @@ -4432,11 +4437,15 @@ void os::init(void) { // enough to allow the thread to get to user bytecode execution. Solaris::min_stack_allowed = MAX2(thr_min_stack(), Solaris::min_stack_allowed); - // retrieve entry point for pthread_setname_np + // dynamic lookup of functions that may not be available in our lowest + // supported Solaris release void * handle = dlopen("libc.so.1", RTLD_LAZY); if (handle != NULL) { - Solaris::_pthread_setname_np = + Solaris::_pthread_setname_np = // from 11.3 (Solaris::pthread_setname_np_func_t)dlsym(handle, "pthread_setname_np"); + + _get_nsec_fromepoch = // from 11.3.6 + (_get_nsec_fromepoch_func_t) dlsym(handle, "get_nsec_fromepoch"); } } -- GitLab From 462ad706f1c6700c6e00dea6b6ff4efcd37d0fb6 Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Tue, 3 May 2016 12:33:10 +0200 Subject: [PATCH 253/400] 8150721: Don't explicitly manage G1 young regions in YoungList Reviewed-by: ehelin, sjohanss, tschatzl --- .../src/share/vm/gc/g1/g1CollectedHeap.cpp | 80 ++++----- .../src/share/vm/gc/g1/g1CollectedHeap.hpp | 26 ++- .../src/share/vm/gc/g1/g1CollectionSet.cpp | 22 +-- .../src/share/vm/gc/g1/g1CollectionSet.hpp | 3 +- .../src/share/vm/gc/g1/g1ConcurrentMark.cpp | 17 +- .../src/share/vm/gc/g1/g1ConcurrentMark.hpp | 15 +- .../src/share/vm/gc/g1/g1DefaultPolicy.cpp | 69 +++++--- .../src/share/vm/gc/g1/g1DefaultPolicy.hpp | 5 +- .../src/share/vm/gc/g1/g1HeapTransition.cpp | 5 +- hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp | 4 +- .../share/vm/gc/g1/g1MonitoringSupport.cpp | 6 +- hotspot/src/share/vm/gc/g1/g1Policy.hpp | 5 +- .../vm/gc/g1/g1YoungRemSetSamplingThread.cpp | 17 +- hotspot/src/share/vm/gc/g1/heapRegion.cpp | 1 - hotspot/src/share/vm/gc/g1/heapRegion.hpp | 7 - hotspot/src/share/vm/gc/g1/youngList.cpp | 155 ++---------------- hotspot/src/share/vm/gc/g1/youngList.hpp | 64 +++----- 17 files changed, 180 insertions(+), 321 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index e4fb2f21576..cd05737ea94 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -1355,8 +1355,7 @@ bool G1CollectedHeap::do_full_collection(bool explicit_gc, // At this point there should be no regions in the // entire heap tagged as young. - assert(check_young_list_empty(true /* check_heap */), - "young list should be empty at this point"); + assert(check_young_list_empty(), "young list should be empty at this point"); // Update the number of full collections that have been completed. increment_old_marking_cycles_completed(false /* concurrent */); @@ -1717,7 +1716,6 @@ G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* collector_policy) : _has_humongous_reclaim_candidates(false), _archive_allocator(NULL), _free_regions_coming(false), - _young_list(new YoungList(this)), _gc_time_stamp(0), _summary_bytes_used(0), _survivor_evac_stats("Young", YoungPLABSize, PLABWeight), @@ -2563,11 +2561,11 @@ bool G1CollectedHeap::supports_tlab_allocation() const { } size_t G1CollectedHeap::tlab_capacity(Thread* ignored) const { - return (_g1_policy->young_list_target_length() - young_list()->survivor_length()) * HeapRegion::GrainBytes; + return (_g1_policy->young_list_target_length() - _survivor.length()) * HeapRegion::GrainBytes; } size_t G1CollectedHeap::tlab_used(Thread* ignored) const { - return young_list()->eden_used_bytes(); + return _eden.length() * HeapRegion::GrainBytes; } // For G1 TLABs should not contain humongous objects, so the maximum TLAB size @@ -2652,10 +2650,10 @@ void G1CollectedHeap::print_on(outputStream* st) const { p2i(_hrm.reserved().end())); st->cr(); st->print(" region size " SIZE_FORMAT "K, ", HeapRegion::GrainBytes / K); - uint young_regions = _young_list->length(); + uint young_regions = young_regions_count(); st->print("%u young (" SIZE_FORMAT "K), ", young_regions, (size_t) young_regions * HeapRegion::GrainBytes / K); - uint survivor_regions = _young_list->survivor_length(); + uint survivor_regions = survivor_regions_count(); st->print("%u survivors (" SIZE_FORMAT "K)", survivor_regions, (size_t) survivor_regions * HeapRegion::GrainBytes / K); st->cr(); @@ -2765,10 +2763,9 @@ void G1CollectedHeap::print_all_rsets() { #endif // PRODUCT G1HeapSummary G1CollectedHeap::create_g1_heap_summary() { - YoungList* young_list = heap()->young_list(); - size_t eden_used_bytes = young_list->eden_used_bytes(); - size_t survivor_used_bytes = young_list->survivor_used_bytes(); + size_t eden_used_bytes = heap()->eden_regions_count() * HeapRegion::GrainBytes; + size_t survivor_used_bytes = heap()->survivor_regions_count() * HeapRegion::GrainBytes; size_t heap_used = Heap_lock->owned_by_self() ? used() : used_unlocked(); size_t eden_capacity_bytes = @@ -3188,8 +3185,6 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { G1HeapTransition heap_transition(this); size_t heap_used_bytes_before_gc = used(); - assert(check_young_list_well_formed(), "young list should be well formed"); - // Don't dynamically change the number of GC threads this early. A value of // 0 is used to indicate serial work. When parallel work is done, // it will be set. @@ -3253,7 +3248,7 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { concurrent_mark()->checkpointRootsInitialPre(); } - g1_policy()->finalize_collection_set(target_pause_time_ms); + g1_policy()->finalize_collection_set(target_pause_time_ms, &_survivor); evacuation_info.set_collectionset_regions(collection_set()->region_length()); @@ -3308,14 +3303,8 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { clear_cset_fast_test(); - // Don't check the whole heap at this point as the - // GC alloc regions from this pause have been tagged - // as survivors and moved on to the survivor list. - // Survivor regions will fail the !is_young() check. - assert(check_young_list_empty(false /* check_heap */), - "young list should be empty"); - - _young_list->reset_auxilary_lists(); + guarantee(_eden.length() == 0, "eden should have been cleared"); + g1_policy()->transfer_survivors_to_cset(survivor()); if (evacuation_failed()) { set_used(recalculate_used()); @@ -4722,10 +4711,7 @@ void G1CollectedHeap::free_collection_set(HeapRegion* cs_head, EvacuationInfo& e double young_time_ms = 0.0; double non_young_time_ms = 0.0; - // Since the collection set is a superset of the the young list, - // all we need to do to clear the young list is clear its - // head and length, and unlink any young regions in the code below - _young_list->clear(); + _eden.clear(); G1Policy* policy = g1_policy(); @@ -4772,11 +4758,6 @@ void G1CollectedHeap::free_collection_set(HeapRegion* cs_head, EvacuationInfo& e size_t words_survived = surviving_young_words[index]; cur->record_surv_words_in_group(words_survived); - // At this point the we have 'popped' cur from the collection set - // (linked via next_in_collection_set()) but it is still in the - // young list (linked via next_young_region()). Clear the - // _next_young_region field. - cur->set_next_young_region(NULL); } else { int index = cur->young_index_in_cset(); assert(index == -1, "invariant"); @@ -5043,9 +5024,12 @@ bool G1CollectedHeap::is_old_gc_alloc_region(HeapRegion* hr) { } void G1CollectedHeap::set_region_short_lived_locked(HeapRegion* hr) { - _young_list->push_region(hr); + _eden.add(hr); + _g1_policy->set_region_eden(hr); } +#ifdef ASSERT + class NoYoungRegionsClosure: public HeapRegionClosure { private: bool _success; @@ -5062,18 +5046,18 @@ public: bool success() { return _success; } }; -bool G1CollectedHeap::check_young_list_empty(bool check_heap) { - bool ret = _young_list->check_list_empty(); +bool G1CollectedHeap::check_young_list_empty() { + bool ret = (young_regions_count() == 0); - if (check_heap) { - NoYoungRegionsClosure closure; - heap_region_iterate(&closure); - ret = ret && closure.success(); - } + NoYoungRegionsClosure closure; + heap_region_iterate(&closure); + ret = ret && closure.success(); return ret; } +#endif // ASSERT + class TearDownRegionSetsClosure : public HeapRegionClosure { private: HeapRegionSet *_old_set; @@ -5084,12 +5068,13 @@ public: bool doHeapRegion(HeapRegion* r) { if (r->is_old()) { _old_set->remove(r); + } else if(r->is_young()) { + r->uninstall_surv_rate_group(); } else { // We ignore free regions, we'll empty the free list afterwards. - // We ignore young regions, we'll empty the young list afterwards. // We ignore humongous regions, we're not tearing down the // humongous regions set. - assert(r->is_free() || r->is_young() || r->is_humongous(), + assert(r->is_free() || r->is_humongous(), "it cannot be another type"); } return false; @@ -5155,16 +5140,12 @@ public: r->set_allocation_context(AllocationContext::system()); _hrm->insert_into_free_list(r); } else if (!_free_list_only) { - assert(!r->is_young(), "we should not come across young regions"); if (r->is_humongous()) { // We ignore humongous regions. We left the humongous set unchanged. } else { - // Objects that were compacted would have ended up on regions - // that were previously old or free. Archive regions (which are - // old) will not have been touched. - assert(r->is_free() || r->is_old(), "invariant"); - // We now consider them old, so register as such. Leave + assert(r->is_young() || r->is_free() || r->is_old(), "invariant"); + // We now consider all regions old, so register as such. Leave // archive regions set that way, however, while still adding // them to the old set. if (!r->is_archive()) { @@ -5187,7 +5168,8 @@ void G1CollectedHeap::rebuild_region_sets(bool free_list_only) { assert_at_safepoint(true /* should_be_vm_thread */); if (!free_list_only) { - _young_list->empty_list(); + _eden.clear(); + _survivor.clear(); } RebuildRegionSetsClosure cl(free_list_only, &_old_set, &_hrm); @@ -5256,7 +5238,7 @@ bool G1CollectedHeap::has_more_regions(InCSetState dest) { if (dest.is_old()) { return true; } else { - return young_list()->survivor_length() < g1_policy()->max_survivor_regions(); + return survivor_regions_count() < g1_policy()->max_survivor_regions(); } } @@ -5279,7 +5261,7 @@ HeapRegion* G1CollectedHeap::new_gc_alloc_region(size_t word_size, InCSetState d new_alloc_region->record_timestamp(); if (is_survivor) { new_alloc_region->set_survivor(); - young_list()->add_survivor_region(new_alloc_region); + _survivor.add(new_alloc_region); _verifier->check_bitmaps("Survivor Region Allocation", new_alloc_region); } else { new_alloc_region->set_old(); diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp index 2962cc24008..ced20c1f172 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp @@ -364,7 +364,8 @@ private: protected: // The young region list. - YoungList* _young_list; + G1EdenRegions _eden; + G1SurvivorRegions _survivor; // The current policy object for the collector. G1Policy* _g1_policy; @@ -1332,18 +1333,27 @@ public: void set_region_short_lived_locked(HeapRegion* hr); // add appropriate methods for any other surv rate groups - YoungList* young_list() const { return _young_list; } + const G1SurvivorRegions* survivor() const { return &_survivor; } - uint old_regions_count() const { return _old_set.length(); } + uint survivor_regions_count() const { + return _survivor.length(); + } - uint humongous_regions_count() const { return _humongous_set.length(); } + uint eden_regions_count() const { + return _eden.length(); + } - // debugging - bool check_young_list_well_formed() { - return _young_list->check_list_well_formed(); + uint young_regions_count() const { + return _eden.length() + _survivor.length(); } - bool check_young_list_empty(bool check_heap); + uint old_regions_count() const { return _old_set.length(); } + + uint humongous_regions_count() const { return _humongous_set.length(); } + +#ifdef ASSERT + bool check_young_list_empty(); +#endif // *** Stuff related to concurrent marking. It's not clear to me that so // many of these need to be public. diff --git a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp index 370f39fed38..1e41dfd89a7 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectionSet.cpp @@ -274,10 +274,9 @@ void G1CollectionSet::print(HeapRegion* list_head, outputStream* st) { } #endif // !PRODUCT -double G1CollectionSet::finalize_young_part(double target_pause_time_ms) { +double G1CollectionSet::finalize_young_part(double target_pause_time_ms, G1SurvivorRegions* survivors) { double young_start_time_sec = os::elapsedTime(); - YoungList* young_list = _g1->young_list(); finalize_incremental_building(); guarantee(target_pause_time_ms > 0.0, @@ -297,27 +296,14 @@ double G1CollectionSet::finalize_young_part(double target_pause_time_ms) { // pause are appended to the RHS of the young list, i.e. // [Newly Young Regions ++ Survivors from last pause]. - uint survivor_region_length = young_list->survivor_length(); - uint eden_region_length = young_list->eden_length(); + uint survivor_region_length = survivors->length(); + uint eden_region_length = _g1->eden_regions_count(); init_region_lengths(eden_region_length, survivor_region_length); - const GrowableArray* survivor_regions = _g1->young_list()->survivor_regions(); - for (GrowableArrayIterator it = survivor_regions->begin(); - it != survivor_regions->end(); - ++it) { - HeapRegion* hr = *it; - assert(hr->is_survivor(), "badly formed young list"); - // There is a convention that all the young regions in the CSet - // are tagged as "eden", so we do this for the survivors here. We - // use the special set_eden_pre_gc() as it doesn't check that the - // region is free (which is not the case here). - hr->set_eden_pre_gc(); - } - verify_young_cset_indices(); // Clear the fields that point to the survivor list - they are all young now. - young_list->clear_survivors(); + survivors->convert_to_eden(); _head = _inc_head; _bytes_used_before = _inc_bytes_used_before; diff --git a/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp b/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp index 7dae216e7d0..bd6f41f7b95 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectionSet.hpp @@ -34,6 +34,7 @@ class G1CollectedHeap; class G1CollectorState; class G1GCPhaseTimes; class G1Policy; +class G1SurvivorRegions; class HeapRegion; class G1CollectionSet VALUE_OBJ_CLASS_SPEC { @@ -175,7 +176,7 @@ public: // Choose a new collection set. Marks the chosen regions as being // "in_collection_set", and links them together. The head and number of // the collection set are available via access methods. - double finalize_young_part(double target_pause_time_ms); + double finalize_young_part(double target_pause_time_ms, G1SurvivorRegions* survivors); void finalize_old_part(double time_remaining_ms); // Add old region "hr" to the CSet. diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp index 11bc8f384bc..280f0a85839 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp @@ -261,11 +261,11 @@ void G1CMMarkStack::note_end_of_gc() { } G1CMRootRegions::G1CMRootRegions() : - _young_list(NULL), _cm(NULL), _scan_in_progress(false), + _cm(NULL), _scan_in_progress(false), _should_abort(false), _claimed_survivor_index(0) { } -void G1CMRootRegions::init(G1CollectedHeap* g1h, G1ConcurrentMark* cm) { - _young_list = g1h->young_list(); +void G1CMRootRegions::init(const G1SurvivorRegions* survivors, G1ConcurrentMark* cm) { + _survivors = survivors; _cm = cm; } @@ -286,7 +286,7 @@ HeapRegion* G1CMRootRegions::claim_next() { } // Currently, only survivors can be root regions. - const GrowableArray* survivor_regions = _young_list->survivor_regions(); + const GrowableArray* survivor_regions = _survivors->regions(); int claimed_index = Atomic::add(1, &_claimed_survivor_index) - 1; if (claimed_index < survivor_regions->length()) { @@ -310,9 +310,10 @@ void G1CMRootRegions::scan_finished() { // Currently, only survivors can be root regions. if (!_should_abort) { - assert(_claimed_survivor_index >= _young_list->survivor_regions()->length(), - "we should have claimed all survivors, claimed index = %d, length = %d", - _claimed_survivor_index, _young_list->survivor_regions()->length()); + assert(_claimed_survivor_index >= 0, "otherwise comparison is invalid: %d", _claimed_survivor_index); + assert((uint)_claimed_survivor_index >= _survivors->length(), + "we should have claimed all survivors, claimed index = %u, length = %u", + (uint)_claimed_survivor_index, _survivors->length()); } notify_scan_done(); @@ -394,7 +395,7 @@ G1ConcurrentMark::G1ConcurrentMark(G1CollectedHeap* g1h, G1RegionToSpaceMapper* SATBMarkQueueSet& satb_qs = JavaThread::satb_mark_queue_set(); satb_qs.set_buffer_size(G1SATBBufferSize); - _root_regions.init(_g1h, this); + _root_regions.init(_g1h->survivor(), this); if (ConcGCThreads > ParallelGCThreads) { log_warning(gc)("Can't have more ConcGCThreads (%u) than ParallelGCThreads (%u).", diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp index d3148185b68..599500a7d2f 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp @@ -36,6 +36,7 @@ class G1CMTask; class G1ConcurrentMark; class ConcurrentGCTimer; class G1OldTracer; +class G1SurvivorRegions; typedef GenericTaskQueue G1CMTaskQueue; typedef GenericTaskQueueSet G1CMTaskQueueSet; @@ -204,8 +205,6 @@ class G1CMMarkStack VALUE_OBJ_CLASS_SPEC { template void iterate(Fn fn); }; -class YoungList; - // Root Regions are regions that are not empty at the beginning of a // marking cycle and which we might collect during an evacuation pause // while the cycle is active. Given that, during evacuation pauses, we @@ -221,19 +220,19 @@ class YoungList; // regions populated during the initial-mark pause. class G1CMRootRegions VALUE_OBJ_CLASS_SPEC { private: - YoungList* _young_list; - G1ConcurrentMark* _cm; + const G1SurvivorRegions* _survivors; + G1ConcurrentMark* _cm; - volatile bool _scan_in_progress; - volatile bool _should_abort; - volatile int _claimed_survivor_index; + volatile bool _scan_in_progress; + volatile bool _should_abort; + volatile int _claimed_survivor_index; void notify_scan_done(); public: G1CMRootRegions(); // We actually do most of the initialization in this method. - void init(G1CollectedHeap* g1h, G1ConcurrentMark* cm); + void init(const G1SurvivorRegions* survivors, G1ConcurrentMark* cm); // Reset the claiming / scanning of the root regions. void prepare_for_scan(); diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index 03aa91cf823..dd26986a68e 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -37,7 +37,9 @@ #include "gc/g1/g1YoungGenSizer.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" +#include "gc/g1/youngList.hpp" #include "gc/shared/gcPolicyCounters.hpp" +#include "logging/logStream.hpp" #include "runtime/arguments.hpp" #include "runtime/java.hpp" #include "runtime/mutexLocker.hpp" @@ -195,11 +197,11 @@ G1DefaultPolicy::YoungTargetLengths G1DefaultPolicy::young_list_target_lengths(s // Calculate the absolute and desired min bounds first. // This is how many young regions we already have (currently: the survivors). - const uint base_min_length = _g1->young_list()->survivor_length(); + const uint base_min_length = _g1->survivor_regions_count(); uint desired_min_length = calculate_young_list_desired_min_length(base_min_length); // This is the absolute minimum young length. Ensure that we // will at least have one eden region available for allocation. - uint absolute_min_length = base_min_length + MAX2(_g1->young_list()->eden_length(), (uint)1); + uint absolute_min_length = base_min_length + MAX2(_g1->eden_regions_count(), (uint)1); // If we shrank the young list target it should not shrink below the current size. desired_min_length = MAX2(desired_min_length, absolute_min_length); // Calculate the absolute and desired max bounds. @@ -360,7 +362,7 @@ G1DefaultPolicy::calculate_young_list_target_length(size_t rs_lengths, double G1DefaultPolicy::predict_survivor_regions_evac_time() const { double survivor_regions_evac_time = 0.0; - const GrowableArray* survivor_regions = _g1->young_list()->survivor_regions(); + const GrowableArray* survivor_regions = _g1->survivor()->regions(); for (GrowableArrayIterator it = survivor_regions->begin(); it != survivor_regions->end(); @@ -394,10 +396,7 @@ void G1DefaultPolicy::update_rs_lengths_prediction(size_t prediction) { #ifndef PRODUCT bool G1DefaultPolicy::verify_young_ages() { - HeapRegion* head = _g1->young_list()->first_region(); - return - verify_young_ages(head, _short_lived_surv_rate_group); - // also call verify_young_ages on any additional surv rate groups + return verify_young_ages(_collection_set->inc_head(), _short_lived_surv_rate_group); } bool G1DefaultPolicy::verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group) { @@ -405,11 +404,10 @@ bool G1DefaultPolicy::verify_young_ages(HeapRegion* head, SurvRateGroup *surv_ra const char* name = surv_rate_group->name(); bool ret = true; - int prev_age = -1; for (HeapRegion* curr = head; curr != NULL; - curr = curr->get_next_young_region()) { + curr = curr->next_in_collection_set()) { SurvRateGroup* group = curr->surv_rate_group(); if (group == NULL && !curr->is_survivor()) { log_error(gc, verify)("## %s: encountered NULL surv_rate_group", name); @@ -417,21 +415,18 @@ bool G1DefaultPolicy::verify_young_ages(HeapRegion* head, SurvRateGroup *surv_ra } if (surv_rate_group == group) { - int age = curr->age_in_surv_rate_group(); - - if (age < 0) { + if (curr->age_in_surv_rate_group() < 0) { log_error(gc, verify)("## %s: encountered negative age", name); ret = false; } - - if (age <= prev_age) { - log_error(gc, verify)("## %s: region ages are not strictly increasing (%d, %d)", name, age, prev_age); - ret = false; - } - prev_age = age; } } + if (!ret) { + LogStreamHandle(Error, gc, verify) log; + _collection_set->print(head, &log); + } + return ret; } #endif // PRODUCT @@ -912,13 +907,13 @@ void G1DefaultPolicy::print_yg_surv_rate_info() const { } bool G1DefaultPolicy::should_allocate_mutator_region() const { - uint young_list_length = _g1->young_list()->length(); + uint young_list_length = _g1->young_regions_count(); uint young_list_target_length = _young_list_target_length; return young_list_length < young_list_target_length; } bool G1DefaultPolicy::can_expand_young_list() const { - uint young_list_length = _g1->young_list()->length(); + uint young_list_length = _g1->young_regions_count(); uint young_list_max_length = _young_list_max_length; return young_list_length < young_list_max_length; } @@ -1160,7 +1155,37 @@ uint G1DefaultPolicy::calc_max_old_cset_length() const { return (uint) result; } -void G1DefaultPolicy::finalize_collection_set(double target_pause_time_ms) { - double time_remaining_ms = _collection_set->finalize_young_part(target_pause_time_ms); +void G1DefaultPolicy::finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor) { + double time_remaining_ms = _collection_set->finalize_young_part(target_pause_time_ms, survivor); _collection_set->finalize_old_part(time_remaining_ms); } + +void G1DefaultPolicy::transfer_survivors_to_cset(const G1SurvivorRegions* survivors) { + + // Add survivor regions to SurvRateGroup. + note_start_adding_survivor_regions(); + finished_recalculating_age_indexes(true /* is_survivors */); + + HeapRegion* last = NULL; + for (GrowableArrayIterator it = survivors->regions()->begin(); + it != survivors->regions()->end(); + ++it) { + HeapRegion* curr = *it; + set_region_survivor(curr); + + // The region is a non-empty survivor so let's add it to + // the incremental collection set for the next evacuation + // pause. + _collection_set->add_survivor_regions(curr); + + last = curr; + } + note_stop_adding_survivor_regions(); + + // Don't clear the survivor list handles until the start of + // the next evacuation pause - we need it in order to re-tag + // the survivor regions from this evacuation pause as 'young' + // at the start of the next. + + finished_recalculating_age_indexes(false /* is_survivors */); +} diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp index 03b7d209cd1..5c8b96f34ce 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp @@ -46,6 +46,7 @@ class G1CollectionSet; class CollectionSetChooser; class G1IHOPControl; class G1Analytics; +class G1SurvivorRegions; class G1YoungGenSizer; class GCPolicyCounters; @@ -347,7 +348,7 @@ public: bool next_gc_should_be_mixed(const char* true_action_str, const char* false_action_str) const; - virtual void finalize_collection_set(double target_pause_time_ms); + virtual void finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor); private: // Set the state to start a concurrent marking cycle and clear // _initiate_conc_mark_if_possible because it has now been @@ -396,6 +397,8 @@ public: return true; } + void transfer_survivors_to_cset(const G1SurvivorRegions* survivors); + private: // // Survivor regions policy. diff --git a/hotspot/src/share/vm/gc/g1/g1HeapTransition.cpp b/hotspot/src/share/vm/gc/g1/g1HeapTransition.cpp index 528fe6e7475..2250863b2b9 100644 --- a/hotspot/src/share/vm/gc/g1/g1HeapTransition.cpp +++ b/hotspot/src/share/vm/gc/g1/g1HeapTransition.cpp @@ -30,9 +30,8 @@ #include "memory/metaspace.hpp" G1HeapTransition::Data::Data(G1CollectedHeap* g1_heap) { - YoungList* young_list = g1_heap->young_list(); - _eden_length = young_list->eden_length(); - _survivor_length = young_list->survivor_length(); + _eden_length = g1_heap->eden_regions_count(); + _survivor_length = g1_heap->survivor_regions_count(); _old_length = g1_heap->old_regions_count(); _humongous_length = g1_heap->humongous_regions_count(); _metaspace_used_bytes = MetaspaceAux::used_bytes(); diff --git a/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp b/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp index 20856e57d1e..9ebfa4d2247 100644 --- a/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp +++ b/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp @@ -583,13 +583,13 @@ void G1HeapVerifier::verify_dirty_region(HeapRegion* hr) { void G1HeapVerifier::verify_dirty_young_list(HeapRegion* head) { G1SATBCardTableModRefBS* ct_bs = _g1h->g1_barrier_set(); - for (HeapRegion* hr = head; hr != NULL; hr = hr->get_next_young_region()) { + for (HeapRegion* hr = head; hr != NULL; hr = hr->next_in_collection_set()) { verify_dirty_region(hr); } } void G1HeapVerifier::verify_dirty_young_regions() { - verify_dirty_young_list(_g1h->young_list()->first_region()); + verify_dirty_young_list(_g1h->collection_set()->inc_head()); } bool G1HeapVerifier::verify_no_bits_over_tams(const char* bitmap_name, G1CMBitMapRO* bitmap, diff --git a/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp b/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp index 5c0b5236de5..a0cf7c2c3cf 100644 --- a/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp +++ b/hotspot/src/share/vm/gc/g1/g1MonitoringSupport.cpp @@ -177,8 +177,8 @@ void G1MonitoringSupport::recalculate_sizes() { // values we read here are possible (i.e., at a STW phase at the end // of a GC). - uint young_list_length = g1->young_list()->length(); - uint survivor_list_length = g1->young_list()->survivor_length(); + uint young_list_length = g1->young_regions_count(); + uint survivor_list_length = g1->survivor_regions_count(); assert(young_list_length >= survivor_list_length, "invariant"); uint eden_list_length = young_list_length - survivor_list_length; // Max length includes any potential extensions to the young gen @@ -237,7 +237,7 @@ void G1MonitoringSupport::recalculate_eden_size() { // When a new eden region is allocated, only the eden_used size is // affected (since we have recalculated everything else at the last GC). - uint young_region_num = g1h()->young_list()->length(); + uint young_region_num = g1h()->young_regions_count(); if (young_region_num > _young_region_num) { uint diff = young_region_num - _young_region_num; _eden_used += (size_t) diff * HeapRegion::GrainBytes; diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.hpp b/hotspot/src/share/vm/gc/g1/g1Policy.hpp index 5d308cbd9c8..f2616c6076e 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp @@ -45,6 +45,7 @@ class G1CollectionSet; class CollectionSetChooser; class G1IHOPControl; class G1Analytics; +class G1SurvivorRegions; class G1YoungGenSizer; class G1Policy: public CHeapObj { @@ -139,7 +140,7 @@ public: // The amount of space we copied during a GC. virtual size_t bytes_copied_during_gc() const = 0; - virtual void finalize_collection_set(double target_pause_time_ms) = 0; + virtual void finalize_collection_set(double target_pause_time_ms, G1SurvivorRegions* survivor) = 0; // This sets the initiate_conc_mark_if_possible() flag to start a // new cycle, as long as we are not already in one. It's best if it @@ -160,6 +161,8 @@ public: virtual void finished_recalculating_age_indexes(bool is_survivors) = 0; + virtual void transfer_survivors_to_cset(const G1SurvivorRegions* survivors) = 0; + virtual size_t young_list_target_length() const = 0; virtual bool should_allocate_mutator_region() const = 0; diff --git a/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp b/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp index 5ba7ffa04bf..5e57885d8ed 100644 --- a/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp +++ b/hotspot/src/share/vm/gc/g1/g1YoungRemSetSamplingThread.cpp @@ -75,22 +75,18 @@ void G1YoungRemSetSamplingThread::sample_young_list_rs_lengths() { SuspendibleThreadSetJoiner sts; G1CollectedHeap* g1h = G1CollectedHeap::heap(); G1Policy* g1p = g1h->g1_policy(); + G1CollectionSet* g1cs = g1h->collection_set(); if (g1p->adaptive_young_list_length()) { int regions_visited = 0; - HeapRegion* hr = g1h->young_list()->first_region(); + HeapRegion* hr = g1cs->inc_head(); size_t sampled_rs_lengths = 0; while (hr != NULL) { size_t rs_length = hr->rem_set()->occupied(); sampled_rs_lengths += rs_length; - // The current region may not yet have been added to the - // incremental collection set (it gets added when it is - // retired as the current allocation region). - if (hr->in_collection_set()) { - // Update the collection set policy information for this region - g1h->collection_set()->update_young_region_prediction(hr, rs_length); - } + // Update the collection set policy information for this region + g1cs->update_young_region_prediction(hr, rs_length); ++regions_visited; @@ -99,12 +95,13 @@ void G1YoungRemSetSamplingThread::sample_young_list_rs_lengths() { if (sts.should_yield()) { sts.yield(); // A gc may have occurred and our sampling data is stale and further - // traversal of the young list is unsafe + // traversal of the collection set is unsafe return; } regions_visited = 0; } - hr = hr->get_next_young_region(); + assert(hr == g1cs->inc_tail() || hr->next_in_collection_set() != NULL, "next should only be null at tail of icset"); + hr = hr->next_in_collection_set(); } g1p->revise_young_list_target_length_if_necessary(sampled_rs_lengths); } diff --git a/hotspot/src/share/vm/gc/g1/heapRegion.cpp b/hotspot/src/share/vm/gc/g1/heapRegion.cpp index 2b223545ac6..44ef49423b4 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegion.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegion.cpp @@ -287,7 +287,6 @@ HeapRegion::HeapRegion(uint hrm_index, _next_in_special_set(NULL), _evacuation_failed(false), _prev_marked_bytes(0), _next_marked_bytes(0), _gc_efficiency(0.0), - _next_young_region(NULL), _next(NULL), _prev(NULL), #ifdef ASSERT _containing_set(NULL), diff --git a/hotspot/src/share/vm/gc/g1/heapRegion.hpp b/hotspot/src/share/vm/gc/g1/heapRegion.hpp index b758c0bf753..10d1cc59d3e 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegion.hpp +++ b/hotspot/src/share/vm/gc/g1/heapRegion.hpp @@ -267,9 +267,6 @@ class HeapRegion: public G1ContiguousSpace { // The collection set. HeapRegion* _next_in_special_set; - // next region in the young "generation" region set - HeapRegion* _next_young_region; - // Fields used by the HeapRegionSetBase class and subclasses. HeapRegion* _next; HeapRegion* _prev; @@ -523,10 +520,6 @@ class HeapRegion: public G1ContiguousSpace { // to provide a dummy version of it. #endif // ASSERT - HeapRegion* get_next_young_region() { return _next_young_region; } - void set_next_young_region(HeapRegion* hr) { - _next_young_region = hr; - } // Reset HR stuff to default values. void hr_clear(bool par, bool clear_space, bool locked = false); diff --git a/hotspot/src/share/vm/gc/g1/youngList.cpp b/hotspot/src/share/vm/gc/g1/youngList.cpp index 98dfe6c9e4e..d4694de1071 100644 --- a/hotspot/src/share/vm/gc/g1/youngList.cpp +++ b/hotspot/src/share/vm/gc/g1/youngList.cpp @@ -23,156 +23,37 @@ */ #include "precompiled.hpp" -#include "gc/g1/g1CollectedHeap.hpp" -#include "gc/g1/g1CollectionSet.hpp" -#include "gc/g1/g1Policy.hpp" #include "gc/g1/heapRegion.hpp" -#include "gc/g1/heapRegion.inline.hpp" -#include "gc/g1/heapRegionRemSet.hpp" #include "gc/g1/youngList.hpp" -#include "logging/log.hpp" #include "utilities/growableArray.hpp" -#include "utilities/ostream.hpp" +#include "utilities/debug.hpp" -YoungList::YoungList(G1CollectedHeap* g1h) : - _g1h(g1h), - _survivor_regions(new (ResourceObj::C_HEAP, mtGC) GrowableArray(8, true, mtGC)), - _head(NULL), - _length(0) { - guarantee(check_list_empty(), "just making sure..."); -} - -void YoungList::push_region(HeapRegion *hr) { - assert(!hr->is_young(), "should not already be young"); - assert(hr->get_next_young_region() == NULL, "cause it should!"); - - hr->set_next_young_region(_head); - _head = hr; - - _g1h->g1_policy()->set_region_eden(hr); - ++_length; -} +G1SurvivorRegions::G1SurvivorRegions() : _regions(new (ResourceObj::C_HEAP, mtGC) GrowableArray(8, true, mtGC)) {} -void YoungList::add_survivor_region(HeapRegion* hr) { +void G1SurvivorRegions::add(HeapRegion* hr) { assert(hr->is_survivor(), "should be flagged as survivor region"); - assert(hr->get_next_young_region() == NULL, "cause it should!"); - - _survivor_regions->append(hr); -} - -void YoungList::empty_list(HeapRegion* list) { - while (list != NULL) { - HeapRegion* next = list->get_next_young_region(); - list->set_next_young_region(NULL); - list->uninstall_surv_rate_group(); - // This is called before a Full GC and all the non-empty / - // non-humongous regions at the end of the Full GC will end up as - // old anyway. - list->set_old(); - list = next; - } + _regions->append(hr); } -void YoungList::empty_list() { - assert(check_list_well_formed(), "young list should be well formed"); - - empty_list(_head); - _head = NULL; - _length = 0; - - if (survivor_length() > 0) { - empty_list(_survivor_regions->last()); - } - _survivor_regions->clear(); - - assert(check_list_empty(), "just making sure..."); +uint G1SurvivorRegions::length() const { + return (uint)_regions->length(); } -uint YoungList::survivor_length() { - return _survivor_regions->length(); -} - -bool YoungList::check_list_well_formed() { - bool ret = true; - - uint length = 0; - HeapRegion* curr = _head; - HeapRegion* last = NULL; - while (curr != NULL) { - if (!curr->is_young()) { - log_error(gc, verify)("### YOUNG REGION " PTR_FORMAT "-" PTR_FORMAT " " - "incorrectly tagged (y: %d, surv: %d)", - p2i(curr->bottom()), p2i(curr->end()), - curr->is_young(), curr->is_survivor()); - ret = false; - } - ++length; - last = curr; - curr = curr->get_next_young_region(); - } - ret = ret && (length == _length); - - if (!ret) { - log_error(gc, verify)("### YOUNG LIST seems not well formed!"); - log_error(gc, verify)("### list has %u entries, _length is %u", length, _length); +void G1SurvivorRegions::convert_to_eden() { + for (GrowableArrayIterator it = _regions->begin(); + it != _regions->end(); + ++it) { + HeapRegion* hr = *it; + hr->set_eden_pre_gc(); } - - return ret; + clear(); } -bool YoungList::check_list_empty() { - bool ret = true; - - if (_length != 0) { - log_error(gc, verify)("### YOUNG LIST should have 0 length, not %u", _length); - ret = false; - } - if (_head != NULL) { - log_error(gc, verify)("### YOUNG LIST does not have a NULL head"); - ret = false; - } - if (!ret) { - log_error(gc, verify)("### YOUNG LIST does not seem empty"); - } - - return ret; +void G1SurvivorRegions::clear() { + _regions->clear(); } -void -YoungList::reset_auxilary_lists() { - guarantee( is_empty(), "young list should be empty" ); - assert(check_list_well_formed(), "young list should be well formed"); - - // Add survivor regions to SurvRateGroup. - _g1h->g1_policy()->note_start_adding_survivor_regions(); - _g1h->g1_policy()->finished_recalculating_age_indexes(true /* is_survivors */); - - HeapRegion* last = NULL; - for (GrowableArrayIterator it = _survivor_regions->begin(); - it != _survivor_regions->end(); - ++it) { - HeapRegion* curr = *it; - _g1h->g1_policy()->set_region_survivor(curr); - - // The region is a non-empty survivor so let's add it to - // the incremental collection set for the next evacuation - // pause. - _g1h->collection_set()->add_survivor_regions(curr); - - curr->set_next_young_region(last); - last = curr; - } - _g1h->g1_policy()->note_stop_adding_survivor_regions(); - - _head = last; - _length = _survivor_regions->length(); - - // Don't clear the survivor list handles until the start of - // the next evacuation pause - we need it in order to re-tag - // the survivor regions from this evacuation pause as 'young' - // at the start of the next. - - _g1h->g1_policy()->finished_recalculating_age_indexes(false /* is_survivors */); - - assert(check_list_well_formed(), "young list should be well formed"); +void G1EdenRegions::add(HeapRegion* hr) { + assert(!hr->is_eden(), "should not already be set"); + _length++; } diff --git a/hotspot/src/share/vm/gc/g1/youngList.hpp b/hotspot/src/share/vm/gc/g1/youngList.hpp index 695727436c7..0555ffb0057 100644 --- a/hotspot/src/share/vm/gc/g1/youngList.hpp +++ b/hotspot/src/share/vm/gc/g1/youngList.hpp @@ -31,58 +31,38 @@ template class GrowableArray; -class YoungList : public CHeapObj { +class G1SurvivorRegions VALUE_OBJ_CLASS_SPEC { private: - G1CollectedHeap* _g1h; - GrowableArray* _survivor_regions; + GrowableArray* _regions; - HeapRegion* _head; +public: + G1SurvivorRegions(); - uint _length; + void add(HeapRegion* hr); - void empty_list(HeapRegion* list); + void convert_to_eden(); -public: - YoungList(G1CollectedHeap* g1h); - - void push_region(HeapRegion* hr); - void add_survivor_region(HeapRegion* hr); - - void empty_list(); - bool is_empty() { return _length == 0; } - uint length() { return _length; } - uint eden_length() { return length() - survivor_length(); } - uint survivor_length(); - - const GrowableArray* survivor_regions() const { return _survivor_regions; } - - // Currently we do not keep track of the used byte sum for the - // young list and the survivors and it'd be quite a lot of work to - // do so. When we'll eventually replace the young list with - // instances of HeapRegionLinkedList we'll get that for free. So, - // we'll report the more accurate information then. - size_t eden_used_bytes() { - assert(length() >= survivor_length(), "invariant"); - return (size_t) eden_length() * HeapRegion::GrainBytes; - } - size_t survivor_used_bytes() { - return (size_t) survivor_length() * HeapRegion::GrainBytes; - } + void clear(); - // for development purposes - void reset_auxilary_lists(); - void clear() { _head = NULL; _length = 0; } + uint length() const; - void clear_survivors() { - _survivor_regions->clear(); + const GrowableArray* regions() const { + return _regions; } +}; + +class G1EdenRegions VALUE_OBJ_CLASS_SPEC { +private: + int _length; + +public: + G1EdenRegions() : _length(0) {} + + void add(HeapRegion* hr); - HeapRegion* first_region() { return _head; } + void clear() { _length = 0; } - // debugging - bool check_list_well_formed(); - bool check_list_empty(); - void print(); + uint length() const { return _length; } }; #endif // SHARE_VM_GC_G1_YOUNGLIST_HPP -- GitLab From ac61c34c543d2ae171403b270cfe477186404043 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Tue, 3 May 2016 13:30:40 -0700 Subject: [PATCH 254/400] 8155958: quarantine failing tests from JDK-8155957 Reviewed-by: hseigel, gtriantafill, dsamersoff, sspitsyn --- hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java | 1 + hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java | 1 + hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java | 1 + hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java | 1 + hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java | 1 + hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java | 1 + hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java | 1 + 7 files changed, 7 insertions(+) diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java index e4149b4b7c1..ae12f5c83d3 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData00.java @@ -25,6 +25,7 @@ * @test TestShrinkAuxiliaryData00 * @bug 8038423 8061715 * @summary Checks that decommitment occurs for JVM with different + * @ignore 8155957 * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values * @requires vm.gc=="G1" | vm.gc=="null" * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null" diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java index db611f6ac09..0e00ffee174 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData05.java @@ -26,6 +26,7 @@ * @bug 8038423 8061715 8078405 * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values + * @ignore 8155957 * @requires vm.gc=="G1" | vm.gc=="null" * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null" * @library /testlibrary /test/lib diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java index 8e645ed5b7e..afad2ca15e7 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData10.java @@ -26,6 +26,7 @@ * @bug 8038423 8061715 8078405 * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values + * @ignore 8155957 * @requires vm.gc=="G1" | vm.gc=="null" * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null" * @library /testlibrary /test/lib diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java index 2b4401fa46b..598caaaa63a 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData15.java @@ -26,6 +26,7 @@ * @bug 8038423 8061715 8078405 * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values + * @ignore 8155957 * @requires vm.gc=="G1" | vm.gc=="null" * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null" * @library /testlibrary /test/lib diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java index b0854ea2a10..13ad25d305e 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData20.java @@ -26,6 +26,7 @@ * @bug 8038423 8061715 8078405 * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values + * @ignore 8155957 * @requires vm.gc=="G1" | vm.gc=="null" * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null" * @library /testlibrary /test/lib diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java index 60f6e5037c5..8e8f84f2ba9 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData25.java @@ -26,6 +26,7 @@ * @bug 8038423 8061715 8078405 * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values + * @ignore 8155957 * @requires vm.gc=="G1" | vm.gc=="null" * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null" * @library /testlibrary /test/lib diff --git a/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java b/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java index 6b73629b70a..249a7216d42 100644 --- a/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java +++ b/hotspot/test/gc/g1/TestShrinkAuxiliaryData30.java @@ -26,6 +26,7 @@ * @bug 8038423 8061715 8078405 * @summary Checks that decommitment occurs for JVM with different * G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values + * @ignore 8155957 * @requires vm.gc=="G1" | vm.gc=="null" * @requires vm.opt.AggressiveOpts=="false" | vm.opt.AggressiveOpts=="null" * @library /testlibrary /test/lib -- GitLab From f8be292b8848d39e8b56c74c817338c6bd1d9802 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Tue, 3 May 2016 22:45:27 +0200 Subject: [PATCH 255/400] 8141501: Problems with BitMap buffer management Reviewed-by: pliden, kbarrett --- hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp | 4 +- hotspot/src/share/vm/c1/c1_GraphBuilder.cpp | 22 +- hotspot/src/share/vm/c1/c1_IR.cpp | 18 +- hotspot/src/share/vm/c1/c1_IR.hpp | 2 +- hotspot/src/share/vm/c1/c1_Instruction.cpp | 2 +- hotspot/src/share/vm/c1/c1_Instruction.hpp | 42 +-- hotspot/src/share/vm/c1/c1_LIRGenerator.hpp | 2 +- hotspot/src/share/vm/c1/c1_LinearScan.cpp | 36 +- hotspot/src/share/vm/c1/c1_LinearScan.hpp | 4 +- hotspot/src/share/vm/c1/c1_ValueSet.hpp | 2 +- hotspot/src/share/vm/ci/ciMethod.cpp | 6 +- hotspot/src/share/vm/ci/ciMethod.hpp | 5 +- .../share/vm/classfile/classFileParser.cpp | 2 +- .../src/share/vm/compiler/methodLiveness.cpp | 32 +- .../src/share/vm/compiler/methodLiveness.hpp | 30 +- .../gc/cms/concurrentMarkSweepGeneration.cpp | 3 +- .../gc/cms/concurrentMarkSweepGeneration.hpp | 11 +- hotspot/src/share/vm/gc/cms/vmStructs_cms.hpp | 2 +- hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp | 12 +- hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp | 6 +- .../share/vm/gc/g1/g1CardLiveData.inline.hpp | 4 +- .../src/share/vm/gc/g1/g1ConcurrentMark.cpp | 3 +- .../src/share/vm/gc/g1/g1ConcurrentMark.hpp | 8 +- .../vm/gc/g1/g1PageBasedVirtualSpace.cpp | 10 +- .../vm/gc/g1/g1PageBasedVirtualSpace.hpp | 6 +- .../share/vm/gc/g1/g1RegionToSpaceMapper.cpp | 9 +- .../share/vm/gc/g1/g1RegionToSpaceMapper.hpp | 8 +- .../src/share/vm/gc/g1/heapRegionManager.cpp | 3 +- .../src/share/vm/gc/g1/heapRegionManager.hpp | 2 +- .../src/share/vm/gc/g1/heapRegionRemSet.cpp | 7 +- .../src/share/vm/gc/g1/heapRegionRemSet.hpp | 2 +- .../share/vm/gc/parallel/parMarkBitMap.cpp | 6 +- .../share/vm/gc/parallel/parMarkBitMap.hpp | 4 +- hotspot/src/share/vm/oops/generateOopMap.cpp | 13 +- hotspot/src/share/vm/oops/generateOopMap.hpp | 2 +- hotspot/src/share/vm/opto/parse.hpp | 2 +- hotspot/src/share/vm/opto/parse1.cpp | 2 +- hotspot/src/share/vm/runtime/vmStructs.cpp | 4 +- hotspot/src/share/vm/utilities/bitMap.cpp | 310 +++++++++++++----- hotspot/src/share/vm/utilities/bitMap.hpp | 183 +++++++++-- .../src/share/vm/utilities/bitMap.inline.hpp | 15 +- 41 files changed, 533 insertions(+), 313 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp index 5da8e5ba844..5c411814df7 100644 --- a/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LinearScan_x86.cpp @@ -67,7 +67,7 @@ void LinearScan::allocate_fpu_stack() { // register information would be incorrect. if (b->number_of_preds() > 1) { int id = b->first_lir_instruction_id(); - BitMap regs(FrameMap::nof_fpu_regs); + ResourceBitMap regs(FrameMap::nof_fpu_regs); regs.clear(); iw.walk_to(id); // walk after the first instruction (always a label) of the block @@ -1069,7 +1069,7 @@ bool FpuStackAllocator::merge_fpu_stack_with_successors(BlockBegin* block) { // clean up stack first so that there are no dead values on the stack if (ComputeExactFPURegisterUsage) { FpuStackSim* cur_sim = sim(); - BitMap live_fpu_regs = block->sux_at(0)->fpu_register_usage(); + ResourceBitMap live_fpu_regs = block->sux_at(0)->fpu_register_usage(); assert(live_fpu_regs.size() == FrameMap::nof_fpu_regs, "missing register usage"); merge_cleanup_fpu_stack(instrs, cur_sim, live_fpu_regs); diff --git a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp index 4b5324eeb92..2b4d36300a1 100644 --- a/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp +++ b/hotspot/src/share/vm/c1/c1_GraphBuilder.cpp @@ -50,11 +50,11 @@ class BlockListBuilder VALUE_OBJ_CLASS_SPEC { BlockList* _bci2block; // mapping from bci to blocks for GraphBuilder // fields used by mark_loops - BitMap _active; // for iteration of control flow graph - BitMap _visited; // for iteration of control flow graph - intArray _loop_map; // caches the information if a block is contained in a loop - int _next_loop_index; // next free loop number - int _next_block_number; // for reverse postorder numbering of blocks + ResourceBitMap _active; // for iteration of control flow graph + ResourceBitMap _visited; // for iteration of control flow graph + intArray _loop_map; // caches the information if a block is contained in a loop + int _next_loop_index; // next free loop number + int _next_block_number; // for reverse postorder numbering of blocks // accessors Compilation* compilation() const { return _compilation; } @@ -227,7 +227,7 @@ void BlockListBuilder::set_leaders() { // Without it, backward branches could jump to a bci where no block was created // during bytecode iteration. This would require the creation of a new block at the // branch target and a modification of the successor lists. - BitMap bci_block_start = method()->bci_block_start(); + const BitMap& bci_block_start = method()->bci_block_start(); ciBytecodeStream s(method()); while (s.next() != ciBytecodeStream::EOBC()) { @@ -355,8 +355,8 @@ void BlockListBuilder::set_leaders() { void BlockListBuilder::mark_loops() { ResourceMark rm; - _active = BitMap(BlockBegin::number_of_blocks()); _active.clear(); - _visited = BitMap(BlockBegin::number_of_blocks()); _visited.clear(); + _active.initialize(BlockBegin::number_of_blocks()); + _visited.initialize(BlockBegin::number_of_blocks()); _loop_map = intArray(BlockBegin::number_of_blocks(), BlockBegin::number_of_blocks(), 0); _next_loop_index = 0; _next_block_number = _blocks.length(); @@ -364,6 +364,10 @@ void BlockListBuilder::mark_loops() { // recursively iterate the control flow graph mark_loops(_bci2block->at(0), false); assert(_next_block_number >= 0, "invalid block numbers"); + + // Remove dangling Resource pointers before the ResourceMark goes out-of-scope. + _active.resize(0); + _visited.resize(0); } void BlockListBuilder::make_loop_header(BlockBegin* block) { @@ -3076,7 +3080,7 @@ void GraphBuilder::setup_osr_entry_block() { Value local; // find all the locals that the interpreter thinks contain live oops - const BitMap live_oops = method()->live_local_oops_at_bci(osr_bci); + const ResourceBitMap live_oops = method()->live_local_oops_at_bci(osr_bci); // compute the offset into the locals so that we can treat the buffer // as if the locals were still in the interpreter frame diff --git a/hotspot/src/share/vm/c1/c1_IR.cpp b/hotspot/src/share/vm/c1/c1_IR.cpp index 3a979650c31..c1c72cf74f5 100644 --- a/hotspot/src/share/vm/c1/c1_IR.cpp +++ b/hotspot/src/share/vm/c1/c1_IR.cpp @@ -460,14 +460,14 @@ class ComputeLinearScanOrder : public StackObj { BlockList* _linear_scan_order; // the resulting list of blocks in correct order - BitMap _visited_blocks; // used for recursive processing of blocks - BitMap _active_blocks; // used for recursive processing of blocks - BitMap _dominator_blocks; // temproary BitMap used for computation of dominator - intArray _forward_branches; // number of incoming forward branches for each block - BlockList _loop_end_blocks; // list of all loop end blocks collected during count_edges - BitMap2D _loop_map; // two-dimensional bit set: a bit is set if a block is contained in a loop - BlockList _work_list; // temporary list (used in mark_loops and compute_order) - BlockList _loop_headers; + ResourceBitMap _visited_blocks; // used for recursive processing of blocks + ResourceBitMap _active_blocks; // used for recursive processing of blocks + ResourceBitMap _dominator_blocks; // temproary BitMap used for computation of dominator + intArray _forward_branches; // number of incoming forward branches for each block + BlockList _loop_end_blocks; // list of all loop end blocks collected during count_edges + BitMap2D _loop_map; // two-dimensional bit set: a bit is set if a block is contained in a loop + BlockList _work_list; // temporary list (used in mark_loops and compute_order) + BlockList _loop_headers; Compilation* _compilation; @@ -535,7 +535,7 @@ ComputeLinearScanOrder::ComputeLinearScanOrder(Compilation* c, BlockBegin* start _loop_end_blocks(8), _work_list(8), _linear_scan_order(NULL), // initialized later with correct size - _loop_map(0, 0), // initialized later with correct size + _loop_map(0), // initialized later with correct size _compilation(c) { TRACE_LINEAR_SCAN(2, tty->print_cr("***** computing linear-scan block order")); diff --git a/hotspot/src/share/vm/c1/c1_IR.hpp b/hotspot/src/share/vm/c1/c1_IR.hpp index 9a2bff70a62..c40cf2605f0 100644 --- a/hotspot/src/share/vm/c1/c1_IR.hpp +++ b/hotspot/src/share/vm/c1/c1_IR.hpp @@ -151,7 +151,7 @@ class IRScope: public CompilationResourceObj { bool _wrote_volatile; // has written volatile field BlockBegin* _start; // the start block, successsors are method entries - BitMap _requires_phi_function; // bit is set if phi functions at loop headers are necessary for a local variable + ResourceBitMap _requires_phi_function; // bit is set if phi functions at loop headers are necessary for a local variable // helper functions BlockBegin* build_graph(Compilation* compilation, int osr_bci); diff --git a/hotspot/src/share/vm/c1/c1_Instruction.cpp b/hotspot/src/share/vm/c1/c1_Instruction.cpp index 1be6266bebf..ffb439d1150 100644 --- a/hotspot/src/share/vm/c1/c1_Instruction.cpp +++ b/hotspot/src/share/vm/c1/c1_Instruction.cpp @@ -787,7 +787,7 @@ bool BlockBegin::try_merge(ValueStack* new_state) { TRACE_PHI(tty->print_cr("creating phi-function %c%d for stack %d", new_state->stack_at(index)->type()->tchar(), new_state->stack_at(index)->id(), index)); } - BitMap requires_phi_function = new_state->scope()->requires_phi_function(); + BitMap& requires_phi_function = new_state->scope()->requires_phi_function(); for_each_local_value(new_state, index, new_value) { bool requires_phi = requires_phi_function.at(index) || (new_value->type()->is_double_word() && requires_phi_function.at(index + 1)); diff --git a/hotspot/src/share/vm/c1/c1_Instruction.hpp b/hotspot/src/share/vm/c1/c1_Instruction.hpp index 508bf843074..426507d301a 100644 --- a/hotspot/src/share/vm/c1/c1_Instruction.hpp +++ b/hotspot/src/share/vm/c1/c1_Instruction.hpp @@ -1596,8 +1596,8 @@ LEAF(BlockBegin, StateSplit) int _flags; // the flags associated with this block // fields used by BlockListBuilder - int _total_preds; // number of predecessors found by BlockListBuilder - BitMap _stores_to_locals; // bit is set when a local variable is stored in the block + int _total_preds; // number of predecessors found by BlockListBuilder + ResourceBitMap _stores_to_locals; // bit is set when a local variable is stored in the block // SSA specific fields: (factor out later) BlockList _successors; // the successors of this block @@ -1614,15 +1614,15 @@ LEAF(BlockBegin, StateSplit) Label _label; // the label associated with this block LIR_List* _lir; // the low level intermediate representation for this block - BitMap _live_in; // set of live LIR_Opr registers at entry to this block - BitMap _live_out; // set of live LIR_Opr registers at exit from this block - BitMap _live_gen; // set of registers used before any redefinition in this block - BitMap _live_kill; // set of registers defined in this block + ResourceBitMap _live_in; // set of live LIR_Opr registers at entry to this block + ResourceBitMap _live_out; // set of live LIR_Opr registers at exit from this block + ResourceBitMap _live_gen; // set of registers used before any redefinition in this block + ResourceBitMap _live_kill; // set of registers defined in this block - BitMap _fpu_register_usage; - intArray* _fpu_stack_state; // For x86 FPU code generation with UseLinearScan - int _first_lir_instruction_id; // ID of first LIR instruction in this block - int _last_lir_instruction_id; // ID of last LIR instruction in this block + ResourceBitMap _fpu_register_usage; + intArray* _fpu_stack_state; // For x86 FPU code generation with UseLinearScan + int _first_lir_instruction_id; // ID of first LIR instruction in this block + int _last_lir_instruction_id; // ID of last LIR instruction in this block void iterate_preorder (boolArray& mark, BlockClosure* closure); void iterate_postorder(boolArray& mark, BlockClosure* closure); @@ -1693,11 +1693,11 @@ LEAF(BlockBegin, StateSplit) Label* label() { return &_label; } LIR_List* lir() const { return _lir; } int exception_handler_pco() const { return _exception_handler_pco; } - BitMap& live_in() { return _live_in; } - BitMap& live_out() { return _live_out; } - BitMap& live_gen() { return _live_gen; } - BitMap& live_kill() { return _live_kill; } - BitMap& fpu_register_usage() { return _fpu_register_usage; } + ResourceBitMap& live_in() { return _live_in; } + ResourceBitMap& live_out() { return _live_out; } + ResourceBitMap& live_gen() { return _live_gen; } + ResourceBitMap& live_kill() { return _live_kill; } + ResourceBitMap& fpu_register_usage() { return _fpu_register_usage; } intArray* fpu_stack_state() const { return _fpu_stack_state; } int first_lir_instruction_id() const { return _first_lir_instruction_id; } int last_lir_instruction_id() const { return _last_lir_instruction_id; } @@ -1718,16 +1718,16 @@ LEAF(BlockBegin, StateSplit) void substitute_sux(BlockBegin* old_sux, BlockBegin* new_sux); void set_lir(LIR_List* lir) { _lir = lir; } void set_exception_handler_pco(int pco) { _exception_handler_pco = pco; } - void set_live_in (BitMap map) { _live_in = map; } - void set_live_out (BitMap map) { _live_out = map; } - void set_live_gen (BitMap map) { _live_gen = map; } - void set_live_kill (BitMap map) { _live_kill = map; } - void set_fpu_register_usage(BitMap map) { _fpu_register_usage = map; } + void set_live_in (const ResourceBitMap& map) { _live_in = map; } + void set_live_out (const ResourceBitMap& map) { _live_out = map; } + void set_live_gen (const ResourceBitMap& map) { _live_gen = map; } + void set_live_kill(const ResourceBitMap& map) { _live_kill = map; } + void set_fpu_register_usage(const ResourceBitMap& map) { _fpu_register_usage = map; } void set_fpu_stack_state(intArray* state) { _fpu_stack_state = state; } void set_first_lir_instruction_id(int id) { _first_lir_instruction_id = id; } void set_last_lir_instruction_id(int id) { _last_lir_instruction_id = id; } void increment_total_preds(int n = 1) { _total_preds += n; } - void init_stores_to_locals(int locals_count) { _stores_to_locals = BitMap(locals_count); _stores_to_locals.clear(); } + void init_stores_to_locals(int locals_count) { _stores_to_locals.initialize(locals_count); } // generic virtual void state_values_do(ValueVisitor* f); diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp index fec18207ec5..62bd05d21f1 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp @@ -470,7 +470,7 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { : _compilation(compilation) , _method(method) , _virtual_register_number(LIR_OprDesc::vreg_base) - , _vreg_flags(NULL, 0, num_vreg_flags) { + , _vreg_flags(num_vreg_flags) { init(); } diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.cpp b/hotspot/src/share/vm/c1/c1_LinearScan.cpp index 7b36660aa6b..991daa0791b 100644 --- a/hotspot/src/share/vm/c1/c1_LinearScan.cpp +++ b/hotspot/src/share/vm/c1/c1_LinearScan.cpp @@ -88,7 +88,7 @@ LinearScan::LinearScan(IR* ir, LIRGenerator* gen, FrameMap* frame_map) , _has_info(0) , _has_call(0) , _scope_value_cache(0) // initialized later with correct length - , _interval_in_loop(0, 0) // initialized later with correct length + , _interval_in_loop(0) // initialized later with correct length , _cached_blocks(*ir->linear_scan_order()) #ifdef X86 , _fpu_stack_allocator(NULL) @@ -524,8 +524,8 @@ void LinearScan::number_instructions() { assert(idx == num_instructions, "must match"); assert(idx * 2 == op_id, "must match"); - _has_call = BitMap(num_instructions); _has_call.clear(); - _has_info = BitMap(num_instructions); _has_info.clear(); + _has_call.initialize(num_instructions); + _has_info.initialize(num_instructions); } @@ -568,8 +568,8 @@ void LinearScan::compute_local_live_sets() { for (int i = 0; i < num_blocks; i++) { BlockBegin* block = block_at(i); - BitMap live_gen(live_size); live_gen.clear(); - BitMap live_kill(live_size); live_kill.clear(); + ResourceBitMap live_gen(live_size); live_gen.clear(); + ResourceBitMap live_kill(live_size); live_kill.clear(); if (block->is_set(BlockBegin::exception_entry_flag)) { // Phi functions at the begin of an exception handler are @@ -715,8 +715,8 @@ void LinearScan::compute_local_live_sets() { block->set_live_gen (live_gen); block->set_live_kill(live_kill); - block->set_live_in (BitMap(live_size)); block->live_in().clear(); - block->set_live_out (BitMap(live_size)); block->live_out().clear(); + block->set_live_in (ResourceBitMap(live_size)); block->live_in().clear(); + block->set_live_out (ResourceBitMap(live_size)); block->live_out().clear(); TRACE_LINEAR_SCAN(4, tty->print("live_gen B%d ", block->block_id()); print_bitmap(block->live_gen())); TRACE_LINEAR_SCAN(4, tty->print("live_kill B%d ", block->block_id()); print_bitmap(block->live_kill())); @@ -741,7 +741,7 @@ void LinearScan::compute_global_live_sets() { bool change_occurred; bool change_occurred_in_block; int iteration_count = 0; - BitMap live_out(live_set_size()); live_out.clear(); // scratch set for calculations + ResourceBitMap live_out(live_set_size()); live_out.clear(); // scratch set for calculations // Perform a backward dataflow analysis to compute live_out and live_in for each block. // The loop is executed until a fixpoint is reached (no changes in an iteration) @@ -775,7 +775,7 @@ void LinearScan::compute_global_live_sets() { if (!block->live_out().is_same(live_out)) { // A change occurred. Swap the old and new live out sets to avoid copying. - BitMap temp = block->live_out(); + ResourceBitMap temp = block->live_out(); block->set_live_out(live_out); live_out = temp; @@ -787,7 +787,7 @@ void LinearScan::compute_global_live_sets() { if (iteration_count == 0 || change_occurred_in_block) { // live_in(block) is the union of live_gen(block) with (live_out(block) & !live_kill(block)) // note: live_in has to be computed only in first iteration or if live_out has changed! - BitMap live_in = block->live_in(); + ResourceBitMap live_in = block->live_in(); live_in.set_from(block->live_out()); live_in.set_difference(block->live_kill()); live_in.set_union(block->live_gen()); @@ -826,7 +826,7 @@ void LinearScan::compute_global_live_sets() { #endif // check that the live_in set of the first block is empty - BitMap live_in_args(ir()->start()->live_in().size()); + ResourceBitMap live_in_args(ir()->start()->live_in().size()); live_in_args.clear(); if (!ir()->start()->live_in().is_same(live_in_args)) { #ifdef ASSERT @@ -1317,7 +1317,7 @@ void LinearScan::build_intervals() { assert(block_to == instructions->at(instructions->length() - 1)->id(), "must be"); // Update intervals for registers live at the end of this block; - BitMap live = block->live_out(); + ResourceBitMap live = block->live_out(); int size = (int)live.size(); for (int number = (int)live.get_next_one_offset(0, size); number < size; number = (int)live.get_next_one_offset(number + 1, size)) { assert(live.at(number), "should not stop here otherwise"); @@ -1717,7 +1717,7 @@ void LinearScan::resolve_collect_mappings(BlockBegin* from_block, BlockBegin* to const int num_regs = num_virtual_regs(); const int size = live_set_size(); - const BitMap live_at_edge = to_block->live_in(); + const ResourceBitMap live_at_edge = to_block->live_in(); // visit all registers where the live_at_edge bit is set for (int r = (int)live_at_edge.get_next_one_offset(0, size); r < size; r = (int)live_at_edge.get_next_one_offset(r + 1, size)) { @@ -1774,8 +1774,8 @@ void LinearScan::resolve_data_flow() { int num_blocks = block_count(); MoveResolver move_resolver(this); - BitMap block_completed(num_blocks); block_completed.clear(); - BitMap already_resolved(num_blocks); already_resolved.clear(); + ResourceBitMap block_completed(num_blocks); block_completed.clear(); + ResourceBitMap already_resolved(num_blocks); already_resolved.clear(); int i; for (i = 0; i < num_blocks; i++) { @@ -3397,7 +3397,7 @@ void LinearScan::verify_constants() { for (int i = 0; i < num_blocks; i++) { BlockBegin* block = block_at(i); - BitMap live_at_edge = block->live_in(); + ResourceBitMap live_at_edge = block->live_in(); // visit all registers where the live_at_edge bit is set for (int r = (int)live_at_edge.get_next_one_offset(0, size); r < size; r = (int)live_at_edge.get_next_one_offset(r + 1, size)) { @@ -3749,7 +3749,7 @@ void MoveResolver::verify_before_resolve() { } - BitMap used_regs(LinearScan::nof_regs + allocator()->frame_map()->argcount() + allocator()->max_spills()); + ResourceBitMap used_regs(LinearScan::nof_regs + allocator()->frame_map()->argcount() + allocator()->max_spills()); used_regs.clear(); if (!_multiple_reads_allowed) { for (i = 0; i < _mapping_from.length(); i++) { @@ -6317,7 +6317,7 @@ void ControlFlowOptimizer::delete_unnecessary_jumps(BlockList* code) { void ControlFlowOptimizer::delete_jumps_to_return(BlockList* code) { #ifdef ASSERT - BitMap return_converted(BlockBegin::number_of_blocks()); + ResourceBitMap return_converted(BlockBegin::number_of_blocks()); return_converted.clear(); #endif diff --git a/hotspot/src/share/vm/c1/c1_LinearScan.hpp b/hotspot/src/share/vm/c1/c1_LinearScan.hpp index 1d04913a1c1..00ed78f632a 100644 --- a/hotspot/src/share/vm/c1/c1_LinearScan.hpp +++ b/hotspot/src/share/vm/c1/c1_LinearScan.hpp @@ -140,8 +140,8 @@ class LinearScan : public CompilationResourceObj { LIR_OpArray _lir_ops; // mapping from LIR_Op id to LIR_Op node BlockBeginArray _block_of_op; // mapping from LIR_Op id to the BlockBegin containing this instruction - BitMap _has_info; // bit set for each LIR_Op id that has a CodeEmitInfo - BitMap _has_call; // bit set for each LIR_Op id that destroys all caller save registers + ResourceBitMap _has_info; // bit set for each LIR_Op id that has a CodeEmitInfo + ResourceBitMap _has_call; // bit set for each LIR_Op id that destroys all caller save registers BitMap2D _interval_in_loop; // bit set for each virtual register that is contained in each loop // cached debug info to prevent multiple creation of same object diff --git a/hotspot/src/share/vm/c1/c1_ValueSet.hpp b/hotspot/src/share/vm/c1/c1_ValueSet.hpp index 2e8dd095d11..50538121cf8 100644 --- a/hotspot/src/share/vm/c1/c1_ValueSet.hpp +++ b/hotspot/src/share/vm/c1/c1_ValueSet.hpp @@ -36,7 +36,7 @@ class ValueSet: public CompilationResourceObj { private: - BitMap _map; + ResourceBitMap _map; public: ValueSet(); diff --git a/hotspot/src/share/vm/ci/ciMethod.cpp b/hotspot/src/share/vm/ci/ciMethod.cpp index 12cecc3c27f..8294024ac9e 100644 --- a/hotspot/src/share/vm/ci/ciMethod.cpp +++ b/hotspot/src/share/vm/ci/ciMethod.cpp @@ -443,12 +443,12 @@ MethodLivenessResult ciMethod::liveness_at_bci(int bci) { // gc'ing an interpreter frame we need to use its viewpoint during // OSR when loading the locals. -BitMap ciMethod::live_local_oops_at_bci(int bci) { +ResourceBitMap ciMethod::live_local_oops_at_bci(int bci) { VM_ENTRY_MARK; InterpreterOopMap mask; OopMapCache::compute_one_oop_map(get_Method(), bci, &mask); int mask_size = max_locals(); - BitMap result(mask_size); + ResourceBitMap result(mask_size); result.clear(); int i; for (i = 0; i < mask_size ; i++ ) { @@ -463,7 +463,7 @@ BitMap ciMethod::live_local_oops_at_bci(int bci) { // ciMethod::bci_block_start // // Marks all bcis where a new basic block starts -const BitMap ciMethod::bci_block_start() { +const BitMap& ciMethod::bci_block_start() { check_is_loaded(); if (_liveness == NULL) { // Create the liveness analyzer. diff --git a/hotspot/src/share/vm/ci/ciMethod.hpp b/hotspot/src/share/vm/ci/ciMethod.hpp index 6e350b41f97..7a56f1cf2a5 100644 --- a/hotspot/src/share/vm/ci/ciMethod.hpp +++ b/hotspot/src/share/vm/ci/ciMethod.hpp @@ -36,7 +36,6 @@ class ciMethodBlocks; class MethodLiveness; -class BitMap; class Arena; class BCEscapeAnalyzer; class InlineTree; @@ -233,10 +232,10 @@ class ciMethod : public ciMetadata { // used when gc'ing an interpreter frame we need to use its viewpoint // during OSR when loading the locals. - BitMap live_local_oops_at_bci(int bci); + ResourceBitMap live_local_oops_at_bci(int bci); #ifdef COMPILER1 - const BitMap bci_block_start(); + const BitMap& bci_block_start(); #endif ciTypeFlow* get_flow_analysis(); diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 1f248acdbd4..81216bbd518 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -3967,7 +3967,7 @@ void ClassFileParser::layout_fields(ConstantPool* cp, next_nonstatic_padded_offset += ContendedPaddingWidth; // collect all contended groups - BitMap bm(cp->size()); + ResourceBitMap bm(cp->size()); for (AllFieldStream fs(_fields, cp); !fs.done(); fs.next()) { // skip already laid out fields if (fs.is_offset_set()) continue; diff --git a/hotspot/src/share/vm/compiler/methodLiveness.cpp b/hotspot/src/share/vm/compiler/methodLiveness.cpp index 177c72fee9c..e68d1244f75 100644 --- a/hotspot/src/share/vm/compiler/methodLiveness.cpp +++ b/hotspot/src/share/vm/compiler/methodLiveness.cpp @@ -131,13 +131,13 @@ elapsedTimer MethodLiveness::_time_total; MethodLiveness::MethodLiveness(Arena* arena, ciMethod* method) #ifdef COMPILER1 - : _bci_block_start((uintptr_t*)arena->Amalloc((method->code_size() >> LogBitsPerByte) + 1), method->code_size()) + : _bci_block_start(arena, method->code_size()) #endif { _arena = arena; _method = method; _bit_map_size_bits = method->max_locals(); - _bit_map_size_words = (_bit_map_size_bits / sizeof(unsigned int)) + 1; + #ifdef COMPILER1 _bci_block_start.clear(); @@ -475,7 +475,7 @@ MethodLivenessResult MethodLiveness::get_liveness_at(int entry_bci) { bci = 0; } - MethodLivenessResult answer((BitMap::bm_word_t*)NULL,0); + MethodLivenessResult answer; if (_block_count > 0) { if (TimeLivenessAnalysis) _time_total.start(); @@ -574,16 +574,11 @@ void MethodLiveness::print_times() { MethodLiveness::BasicBlock::BasicBlock(MethodLiveness *analyzer, int start, int limit) : - _gen((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()), - analyzer->bit_map_size_bits()), - _kill((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()), - analyzer->bit_map_size_bits()), - _entry((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()), - analyzer->bit_map_size_bits()), - _normal_exit((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()), - analyzer->bit_map_size_bits()), - _exception_exit((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()), - analyzer->bit_map_size_bits()), + _gen(analyzer->arena(), analyzer->bit_map_size_bits()), + _kill(analyzer->arena(), analyzer->bit_map_size_bits()), + _entry(analyzer->arena(), analyzer->bit_map_size_bits()), + _normal_exit(analyzer->arena(), analyzer->bit_map_size_bits()), + _exception_exit(analyzer->arena(), analyzer->bit_map_size_bits()), _last_bci(-1) { _analyzer = analyzer; _start_bci = start; @@ -991,17 +986,16 @@ void MethodLiveness::BasicBlock::propagate(MethodLiveness *ml) { } } -bool MethodLiveness::BasicBlock::merge_normal(BitMap other) { +bool MethodLiveness::BasicBlock::merge_normal(const BitMap& other) { return _normal_exit.set_union_with_result(other); } -bool MethodLiveness::BasicBlock::merge_exception(BitMap other) { +bool MethodLiveness::BasicBlock::merge_exception(const BitMap& other) { return _exception_exit.set_union_with_result(other); } MethodLivenessResult MethodLiveness::BasicBlock::get_liveness_at(ciMethod* method, int bci) { - MethodLivenessResult answer(NEW_RESOURCE_ARRAY(BitMap::bm_word_t, _analyzer->bit_map_size_words()), - _analyzer->bit_map_size_bits()); + MethodLivenessResult answer(_analyzer->bit_map_size_bits()); answer.set_is_valid(); #ifndef ASSERT @@ -1013,8 +1007,8 @@ MethodLivenessResult MethodLiveness::BasicBlock::get_liveness_at(ciMethod* metho #ifdef ASSERT ResourceMark rm; - BitMap g(_gen.size()); g.set_from(_gen); - BitMap k(_kill.size()); k.set_from(_kill); + ResourceBitMap g(_gen.size()); g.set_from(_gen); + ResourceBitMap k(_kill.size()); k.set_from(_kill); #endif if (_last_bci != bci || trueInDebug) { ciBytecodeStream bytes(method); diff --git a/hotspot/src/share/vm/compiler/methodLiveness.hpp b/hotspot/src/share/vm/compiler/methodLiveness.hpp index 0a63d2a19dd..60ad42a70e6 100644 --- a/hotspot/src/share/vm/compiler/methodLiveness.hpp +++ b/hotspot/src/share/vm/compiler/methodLiveness.hpp @@ -30,18 +30,18 @@ class ciMethod; -class MethodLivenessResult : public BitMap { +class MethodLivenessResult : public ResourceBitMap { private: bool _is_valid; public: - MethodLivenessResult(BitMap::bm_word_t* map, idx_t size_in_bits) - : BitMap(map, size_in_bits) + MethodLivenessResult() + : ResourceBitMap() , _is_valid(false) {} MethodLivenessResult(idx_t size_in_bits) - : BitMap(size_in_bits) + : ResourceBitMap(size_in_bits) , _is_valid(false) {} @@ -66,23 +66,23 @@ class MethodLiveness : public ResourceObj { int _limit_bci; // The liveness at the start of the block; - BitMap _entry; + ArenaBitMap _entry; // The summarized liveness effects of our direct successors reached // by normal control flow - BitMap _normal_exit; + ArenaBitMap _normal_exit; // The summarized liveness effects of our direct successors reached // by exceptional control flow - BitMap _exception_exit; + ArenaBitMap _exception_exit; // These members hold the results of the last call to // compute_gen_kill_range(). _gen is the set of locals // used before they are defined in the range. _kill is the // set of locals defined before they are used. - BitMap _gen; - BitMap _kill; - int _last_bci; + ArenaBitMap _gen; + ArenaBitMap _kill; + int _last_bci; // A list of all blocks which could come directly before this one // in normal (non-exceptional) control flow. We propagate liveness @@ -100,11 +100,11 @@ class MethodLiveness : public ResourceObj { // Our successors call this method to merge liveness information into // our _normal_exit member. - bool merge_normal(BitMap other); + bool merge_normal(const BitMap& other); // Our successors call this method to merge liveness information into // our _exception_exit member. - bool merge_exception(BitMap other); + bool merge_exception(const BitMap& other); // This helper routine is used to help compute the gen/kill pair for // the block. It is also used to answer queries. @@ -181,7 +181,6 @@ class MethodLiveness : public ResourceObj { // The size of a BitMap. int _bit_map_size_bits; - int _bit_map_size_words; // A list of all BasicBlocks. BasicBlock **_block_list; @@ -198,7 +197,7 @@ class MethodLiveness : public ResourceObj { #ifdef COMPILER1 // bcis where blocks start are marked - BitMap _bci_block_start; + ArenaBitMap _bci_block_start; #endif // COMPILER1 // -- Graph construction & Analysis @@ -218,7 +217,6 @@ class MethodLiveness : public ResourceObj { // And accessors. int bit_map_size_bits() const { return _bit_map_size_bits; } - int bit_map_size_words() const { return _bit_map_size_words; } // Work list manipulation routines. Called internally by BasicBlock. BasicBlock *work_list_get(); @@ -270,7 +268,7 @@ class MethodLiveness : public ResourceObj { MethodLivenessResult get_liveness_at(int bci); #ifdef COMPILER1 - const BitMap get_bci_block_start() const { return _bci_block_start; } + const BitMap& get_bci_block_start() const { return _bci_block_start; } #endif // COMPILER1 static void print_times() PRODUCT_RETURN; diff --git a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp index 83bf54437a8..d19b503455e 100644 --- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp @@ -5666,10 +5666,9 @@ bool CMSBitMap::allocate(MemRegion mr) { } assert(_virtual_space.committed_size() == brs.size(), "didn't reserve backing store for all of CMS bit map?"); - _bm.set_map((BitMap::bm_word_t*)_virtual_space.low()); assert(_virtual_space.committed_size() << (_shifter + LogBitsPerByte) >= _bmWordSize, "inconsistency in bit map sizing"); - _bm.set_size(_bmWordSize >> _shifter); + _bm = BitMapView((BitMap::bm_word_t*)_virtual_space.low(), _bmWordSize >> _shifter); // bm.clear(); // can we rely on getting zero'd memory? verify below assert(isAllClear(), diff --git a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp index 29636c60060..cedd3e431d4 100644 --- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp +++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.hpp @@ -83,13 +83,12 @@ class SerialOldTracer; class CMSBitMap VALUE_OBJ_CLASS_SPEC { friend class VMStructs; - HeapWord* _bmStartWord; // base address of range covered by map - size_t _bmWordSize; // map size (in #HeapWords covered) - const int _shifter; // shifts to convert HeapWord to bit position + HeapWord* _bmStartWord; // base address of range covered by map + size_t _bmWordSize; // map size (in #HeapWords covered) + const int _shifter; // shifts to convert HeapWord to bit position VirtualSpace _virtual_space; // underlying the bit map - BitMap _bm; // the bit map itself - public: - Mutex* const _lock; // mutex protecting _bm; + BitMapView _bm; // the bit map itself + Mutex* const _lock; // mutex protecting _bm; public: // constructor diff --git a/hotspot/src/share/vm/gc/cms/vmStructs_cms.hpp b/hotspot/src/share/vm/gc/cms/vmStructs_cms.hpp index e312d6b59db..5c9351bf83a 100644 --- a/hotspot/src/share/vm/gc/cms/vmStructs_cms.hpp +++ b/hotspot/src/share/vm/gc/cms/vmStructs_cms.hpp @@ -33,7 +33,7 @@ \ nonstatic_field(CMSBitMap, _bmWordSize, size_t) \ nonstatic_field(CMSBitMap, _shifter, const int) \ - nonstatic_field(CMSBitMap, _bm, BitMap) \ + nonstatic_field(CMSBitMap, _bm, BitMapView) \ nonstatic_field(CMSBitMap, _virtual_space, VirtualSpace) \ nonstatic_field(CMSCollector, _markBitMap, CMSBitMap) \ nonstatic_field(ConcurrentMarkSweepGeneration, _cmsSpace, CompactibleFreeListSpace*) \ diff --git a/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp b/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp index ea629dfb01f..100b894ecc1 100644 --- a/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CardLiveData.cpp @@ -95,8 +95,8 @@ size_t G1CardLiveData::live_card_bitmap_size_in_bits() const { // information. class G1CardLiveDataHelper VALUE_OBJ_CLASS_SPEC { private: - BitMap _region_bm; - BitMap _card_bm; + BitMapView _region_bm; + BitMapView _card_bm; // The card number of the bottom of the G1 heap. // Used in biasing indices into accounting card bitmaps. @@ -393,11 +393,11 @@ void G1CardLiveData::finalize(WorkGang* workers, G1CMBitMap* mark_bitmap) { } class G1ClearCardLiveDataTask : public AbstractGangTask { - BitMap _bitmap; - size_t _num_chunks; - size_t _cur_chunk; + BitMapView _bitmap; + size_t _num_chunks; + size_t _cur_chunk; public: - G1ClearCardLiveDataTask(BitMap bitmap, size_t num_tasks) : + G1ClearCardLiveDataTask(const BitMapView& bitmap, size_t num_tasks) : AbstractGangTask("G1 Clear Card Live Data"), _bitmap(bitmap), _num_chunks(num_tasks), diff --git a/hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp b/hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp index c21c5957838..6672d45e7b4 100644 --- a/hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CardLiveData.hpp @@ -65,15 +65,15 @@ private: size_t _live_regions_size_in_bits; // The bits in this bitmap contain for every card whether it contains // at least part of at least one live object. - BitMap live_cards_bm() const { return BitMap(_live_cards, _live_cards_size_in_bits); } + BitMapView live_cards_bm() const { return BitMapView(_live_cards, _live_cards_size_in_bits); } // The bits in this bitmap indicate that a given region contains some live objects. - BitMap live_regions_bm() const { return BitMap(_live_regions, _live_regions_size_in_bits); } + BitMapView live_regions_bm() const { return BitMapView(_live_regions, _live_regions_size_in_bits); } // Allocate a "large" bitmap from virtual memory with the given size in bits. bm_word_t* allocate_large_bitmap(size_t size_in_bits); void free_large_bitmap(bm_word_t* map, size_t size_in_bits); - inline BitMap live_card_bitmap(uint region); + inline BitMapView live_card_bitmap(uint region); inline bool is_card_live_at(BitMap::idx_t idx) const; diff --git a/hotspot/src/share/vm/gc/g1/g1CardLiveData.inline.hpp b/hotspot/src/share/vm/gc/g1/g1CardLiveData.inline.hpp index fc14ed8bcf3..b524d5942b7 100644 --- a/hotspot/src/share/vm/gc/g1/g1CardLiveData.inline.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CardLiveData.inline.hpp @@ -29,8 +29,8 @@ #include "utilities/bitMap.inline.hpp" #include "utilities/globalDefinitions.hpp" -inline BitMap G1CardLiveData::live_card_bitmap(uint region) { - return BitMap(_live_cards + ((size_t)region * _cards_per_region >> LogBitsPerWord), _cards_per_region); +inline BitMapView G1CardLiveData::live_card_bitmap(uint region) { + return BitMapView(_live_cards + ((size_t)region * _cards_per_region >> LogBitsPerWord), _cards_per_region); } inline bool G1CardLiveData::is_card_live_at(BitMap::idx_t idx) const { diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp index 11bc8f384bc..f897b7fd857 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp @@ -110,8 +110,7 @@ void G1CMBitMap::initialize(MemRegion heap, G1RegionToSpaceMapper* storage) { _bmStartWord = heap.start(); _bmWordSize = heap.word_size(); - _bm.set_map((BitMap::bm_word_t*) storage->reserved().start()); - _bm.set_size(_bmWordSize >> _shifter); + _bm = BitMapView((BitMap::bm_word_t*) storage->reserved().start(), _bmWordSize >> _shifter); storage->set_mapping_changed_listener(&_listener); } diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp index d3148185b68..9a3386ed4fb 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp @@ -58,10 +58,10 @@ class G1CMIsAliveClosure: public BoolObjectClosure { class G1CMBitMapRO VALUE_OBJ_CLASS_SPEC { protected: - HeapWord* _bmStartWord; // base address of range covered by map - size_t _bmWordSize; // map size (in #HeapWords covered) - const int _shifter; // map to char or bit - BitMap _bm; // the bit map itself + HeapWord* _bmStartWord; // base address of range covered by map + size_t _bmWordSize; // map size (in #HeapWords covered) + const int _shifter; // map to char or bit + BitMapView _bm; // the bit map itself public: // constructor diff --git a/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.cpp b/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.cpp index 0a42184f3ca..46cd63fb576 100644 --- a/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.cpp +++ b/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.cpp @@ -75,19 +75,15 @@ void G1PageBasedVirtualSpace::initialize_with_page_size(ReservedSpace rs, size_t vmassert(_committed.size() == 0, "virtual space initialized more than once"); BitMap::idx_t size_in_pages = rs.size() / page_size; - _committed.resize(size_in_pages, /* in_resource_area */ false); + _committed.initialize(size_in_pages); if (_special) { - _dirty.resize(size_in_pages, /* in_resource_area */ false); + _dirty.initialize(size_in_pages); } _tail_size = used_size % _page_size; } G1PageBasedVirtualSpace::~G1PageBasedVirtualSpace() { - release(); -} - -void G1PageBasedVirtualSpace::release() { // This does not release memory it never reserved. // Caller must release via rs.release(); _low_boundary = NULL; @@ -96,8 +92,6 @@ void G1PageBasedVirtualSpace::release() { _executable = false; _page_size = 0; _tail_size = 0; - _committed.resize(0, false); - _dirty.resize(0, false); } size_t G1PageBasedVirtualSpace::committed_size() const { diff --git a/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.hpp b/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.hpp index 23a7d53d85f..ed16fac9553 100644 --- a/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.hpp +++ b/hotspot/src/share/vm/gc/g1/g1PageBasedVirtualSpace.hpp @@ -57,13 +57,13 @@ class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC { size_t _page_size; // Bitmap used for verification of commit/uncommit operations. - BitMap _committed; + CHeapBitMap _committed; // Bitmap used to keep track of which pages are dirty or not for _special // spaces. This is needed because for those spaces the underlying memory // will only be zero filled the first time it is committed. Calls to commit // will use this bitmap and return whether or not the memory is zero filled. - BitMap _dirty; + CHeapBitMap _dirty; // Indicates that the entire space has been committed and pinned in memory, // os::commit_memory() or os::uncommit_memory() have no function. @@ -139,8 +139,6 @@ class G1PageBasedVirtualSpace VALUE_OBJ_CLASS_SPEC { return x; } - void release(); - void check_for_contiguity() PRODUCT_RETURN; // Debugging diff --git a/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.cpp b/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.cpp index cfac671de88..80b794153ed 100644 --- a/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.cpp @@ -34,11 +34,12 @@ G1RegionToSpaceMapper::G1RegionToSpaceMapper(ReservedSpace rs, size_t used_size, size_t page_size, size_t region_granularity, + size_t commit_factor, MemoryType type) : _storage(rs, used_size, page_size), _region_granularity(region_granularity), _listener(NULL), - _commit_map() { + _commit_map(rs.size() * commit_factor / region_granularity) { guarantee(is_power_of_2(page_size), "must be"); guarantee(is_power_of_2(region_granularity), "must be"); @@ -59,11 +60,10 @@ class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper { size_t alloc_granularity, size_t commit_factor, MemoryType type) : - G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, type), + G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type), _pages_per_region(alloc_granularity / (page_size * commit_factor)) { guarantee(alloc_granularity >= page_size, "allocation granularity smaller than commit granularity"); - _commit_map.resize(rs.size() * commit_factor / alloc_granularity, /* in_resource_area */ false); } virtual void commit_regions(uint start_idx, size_t num_regions) { @@ -103,12 +103,11 @@ class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper { size_t alloc_granularity, size_t commit_factor, MemoryType type) : - G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, type), + G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type), _regions_per_page((page_size * commit_factor) / alloc_granularity), _refcounts() { guarantee((page_size * commit_factor) >= alloc_granularity, "allocation granularity smaller than commit granularity"); _refcounts.initialize((HeapWord*)rs.base(), (HeapWord*)(rs.base() + align_size_up(rs.size(), page_size)), page_size); - _commit_map.resize(rs.size() * commit_factor / alloc_granularity, /* in_resource_area */ false); } virtual void commit_regions(uint start_idx, size_t num_regions) { diff --git a/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.hpp b/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.hpp index a6d085e0b8e..218ae1550ae 100644 --- a/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.hpp +++ b/hotspot/src/share/vm/gc/g1/g1RegionToSpaceMapper.hpp @@ -49,9 +49,9 @@ class G1RegionToSpaceMapper : public CHeapObj { size_t _region_granularity; // Mapping management - BitMap _commit_map; + CHeapBitMap _commit_map; - G1RegionToSpaceMapper(ReservedSpace rs, size_t used_size, size_t page_size, size_t region_granularity, MemoryType type); + G1RegionToSpaceMapper(ReservedSpace rs, size_t used_size, size_t page_size, size_t region_granularity, size_t commit_factor, MemoryType type); void fire_on_commit(uint start_idx, size_t num_regions, bool zero_filled); public: @@ -62,9 +62,7 @@ class G1RegionToSpaceMapper : public CHeapObj { void set_mapping_changed_listener(G1MappingChangedListener* listener) { _listener = listener; } - virtual ~G1RegionToSpaceMapper() { - _commit_map.resize(0, /* in_resource_area */ false); - } + virtual ~G1RegionToSpaceMapper() {} bool is_committed(uintptr_t idx) const { return _commit_map.at(idx); diff --git a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp index b5e01a00243..06b04eeefea 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.cpp @@ -51,8 +51,7 @@ void HeapRegionManager::initialize(G1RegionToSpaceMapper* heap_storage, MemRegion reserved = heap_storage->reserved(); _regions.initialize(reserved.start(), reserved.end(), HeapRegion::GrainBytes); - _available_map.resize(_regions.length(), false); - _available_map.clear(); + _available_map.initialize(_regions.length()); } bool HeapRegionManager::is_available(uint region) const { diff --git a/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp b/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp index 03bc3ed53b4..8644d3e56e6 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionManager.hpp @@ -83,7 +83,7 @@ class HeapRegionManager: public CHeapObj { // Each bit in this bitmap indicates that the corresponding region is available // for allocation. - BitMap _available_map; + CHeapBitMap _available_map; // The number of regions committed in the heap. uint _num_committed; diff --git a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp index e61cf55de33..ef32ebc3284 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp @@ -43,7 +43,7 @@ class PerRegionTable: public CHeapObj { friend class HeapRegionRemSetIterator; HeapRegion* _hr; - BitMap _bm; + CHeapBitMap _bm; jint _occupied; // next pointer for free/allocated 'all' list @@ -69,7 +69,7 @@ protected: PerRegionTable(HeapRegion* hr) : _hr(hr), _occupied(0), - _bm(HeapRegion::CardsPerRegion, false /* in-resource-area */), + _bm(HeapRegion::CardsPerRegion), _collision_list_next(NULL), _next(NULL), _prev(NULL) {} @@ -259,8 +259,7 @@ size_t OtherRegionsTable::_fine_eviction_sample_size = 0; OtherRegionsTable::OtherRegionsTable(HeapRegion* hr, Mutex* m) : _g1h(G1CollectedHeap::heap()), _hr(hr), _m(m), - _coarse_map(G1CollectedHeap::heap()->max_regions(), - false /* in-resource-area */), + _coarse_map(G1CollectedHeap::heap()->max_regions()), _fine_grain_regions(NULL), _first_all_fine_prts(NULL), _last_all_fine_prts(NULL), _n_fine_entries(0), _n_coarse_entries(0), diff --git a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp index baf2def1de6..7f740b692c8 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.hpp @@ -79,7 +79,7 @@ class OtherRegionsTable VALUE_OBJ_CLASS_SPEC { HeapRegion* _hr; // These are protected by "_m". - BitMap _coarse_map; + CHeapBitMap _coarse_map; size_t _n_coarse_entries; static jint _n_coarsenings; diff --git a/hotspot/src/share/vm/gc/parallel/parMarkBitMap.cpp b/hotspot/src/share/vm/gc/parallel/parMarkBitMap.cpp index 76241d92692..39b63acb016 100644 --- a/hotspot/src/share/vm/gc/parallel/parMarkBitMap.cpp +++ b/hotspot/src/share/vm/gc/parallel/parMarkBitMap.cpp @@ -59,10 +59,8 @@ ParMarkBitMap::initialize(MemRegion covered_region) _region_start = covered_region.start(); _region_size = covered_region.word_size(); BitMap::bm_word_t* map = (BitMap::bm_word_t*)_virtual_space->reserved_low_addr(); - _beg_bits.set_map(map); - _beg_bits.set_size(bits / 2); - _end_bits.set_map(map + words / 2); - _end_bits.set_size(bits / 2); + _beg_bits = BitMapView(map, bits / 2); + _end_bits = BitMapView(map + words / 2, bits / 2); return true; } diff --git a/hotspot/src/share/vm/gc/parallel/parMarkBitMap.hpp b/hotspot/src/share/vm/gc/parallel/parMarkBitMap.hpp index 3f29f94fc97..9457d3e6e98 100644 --- a/hotspot/src/share/vm/gc/parallel/parMarkBitMap.hpp +++ b/hotspot/src/share/vm/gc/parallel/parMarkBitMap.hpp @@ -182,8 +182,8 @@ private: HeapWord* _region_start; size_t _region_size; - BitMap _beg_bits; - BitMap _end_bits; + BitMapView _beg_bits; + BitMapView _end_bits; PSVirtualSpace* _virtual_space; size_t _reserved_byte_size; }; diff --git a/hotspot/src/share/vm/oops/generateOopMap.cpp b/hotspot/src/share/vm/oops/generateOopMap.cpp index 60738d741a5..fe8cdbc64c6 100644 --- a/hotspot/src/share/vm/oops/generateOopMap.cpp +++ b/hotspot/src/share/vm/oops/generateOopMap.cpp @@ -378,11 +378,10 @@ void CellTypeState::print(outputStream *os) { // Basicblock handling methods // -void GenerateOopMap ::initialize_bb() { +void GenerateOopMap::initialize_bb() { _gc_points = 0; _bb_count = 0; - _bb_hdr_bits.clear(); - _bb_hdr_bits.resize(method()->code_size()); + _bb_hdr_bits.reinitialize(method()->code_size()); } void GenerateOopMap::bb_mark_fct(GenerateOopMap *c, int bci, int *data) { @@ -1041,13 +1040,7 @@ void GenerateOopMap::update_basic_blocks(int bci, int delta, assert(new_method_size >= method()->code_size() + delta, "new method size is too small"); - BitMap::bm_word_t* new_bb_hdr_bits = - NEW_RESOURCE_ARRAY(BitMap::bm_word_t, - BitMap::word_align_up(new_method_size)); - _bb_hdr_bits.set_map(new_bb_hdr_bits); - _bb_hdr_bits.set_size(new_method_size); - _bb_hdr_bits.clear(); - + _bb_hdr_bits.reinitialize(new_method_size); for(int k = 0; k < _bb_count; k++) { if (_basic_blocks[k]._bci > bci) { diff --git a/hotspot/src/share/vm/oops/generateOopMap.hpp b/hotspot/src/share/vm/oops/generateOopMap.hpp index 8822ee0d839..a41d14ac897 100644 --- a/hotspot/src/share/vm/oops/generateOopMap.hpp +++ b/hotspot/src/share/vm/oops/generateOopMap.hpp @@ -350,7 +350,7 @@ class GenerateOopMap VALUE_OBJ_CLASS_SPEC { BasicBlock * _basic_blocks; // Array of basicblock info int _gc_points; int _bb_count; - BitMap _bb_hdr_bits; + ResourceBitMap _bb_hdr_bits; // Basicblocks methods void initialize_bb (); diff --git a/hotspot/src/share/vm/opto/parse.hpp b/hotspot/src/share/vm/opto/parse.hpp index b26a59f8497..cb9a3e3f104 100644 --- a/hotspot/src/share/vm/opto/parse.hpp +++ b/hotspot/src/share/vm/opto/parse.hpp @@ -168,7 +168,7 @@ class Parse : public GraphKit { // Use init_node/init_graph to initialize Blocks. // Block() : _live_locals((uintptr_t*)NULL,0) { ShouldNotReachHere(); } - Block() : _live_locals(NULL,0) { ShouldNotReachHere(); } + Block() : _live_locals() { ShouldNotReachHere(); } public: diff --git a/hotspot/src/share/vm/opto/parse1.cpp b/hotspot/src/share/vm/opto/parse1.cpp index 22b3e27292e..80885d9a836 100644 --- a/hotspot/src/share/vm/opto/parse1.cpp +++ b/hotspot/src/share/vm/opto/parse1.cpp @@ -261,7 +261,7 @@ void Parse::load_interpreter_state(Node* osr_buf) { Node *locals_addr = basic_plus_adr(osr_buf, osr_buf, (max_locals-1)*wordSize); // find all the locals that the interpreter thinks contain live oops - const BitMap live_oops = method()->live_local_oops_at_bci(osr_bci()); + const ResourceBitMap live_oops = method()->live_local_oops_at_bci(osr_bci()); for (index = 0; index < max_locals; index++) { if (!live_locals.at(index)) { diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 433fa4c8b27..f6708f19ba4 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -1594,7 +1594,6 @@ typedef CompactHashtable SymbolCompactHashTable; declare_type(TenuredGeneration, CardGeneration) \ declare_toplevel_type(GenCollectorPolicy) \ declare_toplevel_type(Space) \ - declare_toplevel_type(BitMap) \ declare_type(CompactibleSpace, Space) \ declare_type(ContiguousSpace, CompactibleSpace) \ declare_type(OffsetTableContigSpace, ContiguousSpace) \ @@ -2238,6 +2237,9 @@ typedef CompactHashtable SymbolCompactHashTable; declare_type(Array, MetaspaceObj) \ declare_type(Array, MetaspaceObj) \ \ + declare_toplevel_type(BitMap) \ + declare_type(BitMapView, BitMap) \ + \ declare_integer_type(AccessFlags) /* FIXME: wrong type (not integer) */\ declare_toplevel_type(address) /* FIXME: should this be an integer type? */\ declare_integer_type(BasicType) /* FIXME: wrong type (not integer) */\ diff --git a/hotspot/src/share/vm/utilities/bitMap.cpp b/hotspot/src/share/vm/utilities/bitMap.cpp index a6c08f1fd27..12758ab02e4 100644 --- a/hotspot/src/share/vm/utilities/bitMap.cpp +++ b/hotspot/src/share/vm/utilities/bitMap.cpp @@ -28,13 +28,144 @@ #include "runtime/atomic.inline.hpp" #include "utilities/bitMap.inline.hpp" #include "utilities/copy.hpp" +#include "utilities/debug.hpp" STATIC_ASSERT(sizeof(BitMap::bm_word_t) == BytesPerWord); // "Implementation assumption." -BitMap::BitMap(idx_t size_in_bits, bool in_resource_area) : - _map(NULL), _size(0) -{ - resize(size_in_bits, in_resource_area); +typedef BitMap::bm_word_t bm_word_t; +typedef BitMap::idx_t idx_t; + +class ResourceBitMapAllocator : StackObj { + public: + bm_word_t* allocate(idx_t size_in_words) const { + return NEW_RESOURCE_ARRAY(bm_word_t, size_in_words); + } + void free(bm_word_t* map, idx_t size_in_words) const { + // Don't free resource allocated arrays. + } +}; + +class CHeapBitMapAllocator : StackObj { + public: + bm_word_t* allocate(size_t size_in_words) const { + return ArrayAllocator::allocate(size_in_words); + } + void free(bm_word_t* map, idx_t size_in_words) const { + ArrayAllocator::free(map, size_in_words); + } +}; + +class ArenaBitMapAllocator : StackObj { + Arena* _arena; + + public: + ArenaBitMapAllocator(Arena* arena) : _arena(arena) {} + bm_word_t* allocate(idx_t size_in_words) const { + return (bm_word_t*)_arena->Amalloc(size_in_words * BytesPerWord); + } + void free(bm_word_t* map, idx_t size_in_words) const { + // ArenaBitMaps currently don't free memory. + } +}; + +template +BitMap::bm_word_t* BitMap::reallocate(const Allocator& allocator, bm_word_t* old_map, idx_t old_size_in_bits, idx_t new_size_in_bits) { + size_t old_size_in_words = calc_size_in_words(old_size_in_bits); + size_t new_size_in_words = calc_size_in_words(new_size_in_bits); + + bm_word_t* map = NULL; + + if (new_size_in_words > 0) { + map = allocator.allocate(new_size_in_words); + + Copy::disjoint_words((HeapWord*)old_map, (HeapWord*) map, + MIN2(old_size_in_words, new_size_in_words)); + + if (new_size_in_words > old_size_in_words) { + clear_range_of_words(map, old_size_in_words, new_size_in_words); + } + } + + if (old_map != NULL) { + allocator.free(old_map, old_size_in_words); + } + + return map; +} + +template +bm_word_t* BitMap::allocate(const Allocator& allocator, idx_t size_in_bits) { + // Reuse reallocate to ensure that the new memory is cleared. + return reallocate(allocator, NULL, 0, size_in_bits); +} + +template +void BitMap::free(const Allocator& allocator, bm_word_t* map, idx_t size_in_bits) { + bm_word_t* ret = reallocate(allocator, map, size_in_bits, 0); + assert(ret == NULL, "Reallocate shouldn't have allocated"); +} + +template +void BitMap::resize(const Allocator& allocator, idx_t new_size_in_bits) { + bm_word_t* new_map = reallocate(allocator, map(), size(), new_size_in_bits); + + update(new_map, new_size_in_bits); +} + +template +void BitMap::initialize(const Allocator& allocator, idx_t size_in_bits) { + assert(map() == NULL, "precondition"); + assert(size() == 0, "precondition"); + + resize(allocator, size_in_bits); +} + +template +void BitMap::reinitialize(const Allocator& allocator, idx_t new_size_in_bits) { + // Remove previous bits. + resize(allocator, 0); + + initialize(allocator, new_size_in_bits); +} + +ResourceBitMap::ResourceBitMap(idx_t size_in_bits) + : BitMap(allocate(ResourceBitMapAllocator(), size_in_bits), size_in_bits) { +} + +void ResourceBitMap::resize(idx_t new_size_in_bits) { + BitMap::resize(ResourceBitMapAllocator(), new_size_in_bits); +} + +void ResourceBitMap::initialize(idx_t size_in_bits) { + BitMap::initialize(ResourceBitMapAllocator(), size_in_bits); +} + +void ResourceBitMap::reinitialize(idx_t size_in_bits) { + BitMap::reinitialize(ResourceBitMapAllocator(), size_in_bits); +} + +ArenaBitMap::ArenaBitMap(Arena* arena, idx_t size_in_bits) + : BitMap(allocate(ArenaBitMapAllocator(arena), size_in_bits), size_in_bits) { +} + +CHeapBitMap::CHeapBitMap(idx_t size_in_bits) + : BitMap(allocate(CHeapBitMapAllocator(), size_in_bits), size_in_bits) { +} + +CHeapBitMap::~CHeapBitMap() { + free(CHeapBitMapAllocator(), map(), size()); +} + +void CHeapBitMap::resize(idx_t new_size_in_bits) { + BitMap::resize(CHeapBitMapAllocator(), new_size_in_bits); +} + +void CHeapBitMap::initialize(idx_t size_in_bits) { + BitMap::initialize(CHeapBitMapAllocator(), size_in_bits); +} + +void CHeapBitMap::reinitialize(idx_t size_in_bits) { + BitMap::reinitialize(CHeapBitMapAllocator(), size_in_bits); } #ifdef ASSERT @@ -49,25 +180,6 @@ void BitMap::verify_range(idx_t beg_index, idx_t end_index) const { } #endif // #ifdef ASSERT -void BitMap::resize(idx_t size_in_bits, bool in_resource_area) { - idx_t old_size_in_words = size_in_words(); - bm_word_t* old_map = map(); - - _size = size_in_bits; - idx_t new_size_in_words = size_in_words(); - if (in_resource_area) { - _map = NEW_RESOURCE_ARRAY(bm_word_t, new_size_in_words); - Copy::disjoint_words((HeapWord*)old_map, (HeapWord*) _map, - MIN2(old_size_in_words, new_size_in_words)); - } else { - _map = ArrayAllocator::reallocate(old_map, old_size_in_words, new_size_in_words); - } - - if (new_size_in_words > old_size_in_words) { - clear_range_of_words(old_size_in_words, new_size_in_words); - } -} - void BitMap::pretouch() { os::pretouch_memory(word_addr(0), word_addr(size())); } @@ -205,13 +317,6 @@ bool BitMap::par_at_put(idx_t bit, bool value) { return value ? par_set_bit(bit) : par_clear_bit(bit); } -void BitMap::at_put_grow(idx_t offset, bool value) { - if (offset >= size()) { - resize(2 * MAX2(size(), offset)); - } - at_put(offset, value); -} - void BitMap::at_put_range(idx_t start_offset, idx_t end_offset, bool value) { if (value) { set_range(start_offset, end_offset); @@ -532,93 +637,116 @@ void BitMap::print_on(outputStream* st) const { class TestBitMap : public AllStatic { const static BitMap::idx_t BITMAP_SIZE = 1024; - static void fillBitMap(BitMap& map) { + + template + static void fillBitMap(ResizableBitMapClass& map) { map.set_bit(1); map.set_bit(3); map.set_bit(17); map.set_bit(512); } - static void testResize(bool in_resource_area) { - { - BitMap map(0, in_resource_area); - map.resize(BITMAP_SIZE, in_resource_area); - fillBitMap(map); + template + static void testResize(BitMap::idx_t start_size) { + ResourceMark rm; - BitMap map2(BITMAP_SIZE, in_resource_area); - fillBitMap(map2); - assert(map.is_same(map2), "could be"); - } + ResizableBitMapClass map(start_size); + map.resize(BITMAP_SIZE); + fillBitMap(map); - { - BitMap map(128, in_resource_area); - map.resize(BITMAP_SIZE, in_resource_area); - fillBitMap(map); + ResizableBitMapClass map2(BITMAP_SIZE); + fillBitMap(map2); + assert(map.is_same(map2), "could be"); + } - BitMap map2(BITMAP_SIZE, in_resource_area); - fillBitMap(map2); - assert(map.is_same(map2), "could be"); - } + template + static void testResizeGrow() { + testResize(0); + testResize(128); + } - { - BitMap map(BITMAP_SIZE, in_resource_area); - map.resize(BITMAP_SIZE, in_resource_area); - fillBitMap(map); + template + static void testResizeSame() { + testResize(BITMAP_SIZE); + } - BitMap map2(BITMAP_SIZE, in_resource_area); - fillBitMap(map2); - assert(map.is_same(map2), "could be"); - } + template + static void testResizeShrink() { + testResize(BITMAP_SIZE * 2); } - static void testResizeResource() { + static void testResizeGrow() { + testResizeGrow(); + testResizeGrow(); + } + + static void testResizeSame() { + testResizeSame(); + testResizeSame(); + } + + static void testResizeShrink() { + testResizeShrink(); + testResizeShrink(); + } + + static void testResize() { + testResizeGrow(); + testResizeSame(); + testResizeShrink(); + } + + template + static void testInitialize() { ResourceMark rm; - testResize(true); + + InitializableBitMapClass map; + map.initialize(BITMAP_SIZE); + fillBitMap(map); + + InitializableBitMapClass map2(BITMAP_SIZE); + fillBitMap(map2); + assert(map.is_same(map2), "could be"); } - static void testResizeNonResource() { - const size_t bitmap_bytes = BITMAP_SIZE / BitsPerByte; + static void testInitialize() { + testInitialize(); + testInitialize(); + } - // Test the default behavior - testResize(false); + template + static void testReinitialize(BitMap::idx_t init_size) { + ResourceMark rm; - { - // Make sure that AllocatorMallocLimit is larger than our allocation request - // forcing it to call standard malloc() - SizeTFlagSetting fs(ArrayAllocatorMallocLimit, bitmap_bytes * 4); - testResize(false); - } - { - // Make sure that AllocatorMallocLimit is smaller than our allocation request - // forcing it to call mmap() (or equivalent) - SizeTFlagSetting fs(ArrayAllocatorMallocLimit, bitmap_bytes / 4); - testResize(false); - } + ReinitializableBitMapClass map(init_size); + map.reinitialize(BITMAP_SIZE); + fillBitMap(map); + + ReinitializableBitMapClass map2(BITMAP_SIZE); + fillBitMap(map2); + assert(map.is_same(map2), "could be"); + } + + template + static void testReinitialize() { + testReinitialize(0); + testReinitialize(128); + testReinitialize(BITMAP_SIZE); + } + + static void testReinitialize() { + testReinitialize(); } public: static void test() { - testResizeResource(); - testResizeNonResource(); + testResize(); + testInitialize(); + testReinitialize(); } - }; void TestBitMap_test() { TestBitMap::test(); } #endif - - -BitMap2D::BitMap2D(bm_word_t* map, idx_t size_in_slots, idx_t bits_per_slot) - : _bits_per_slot(bits_per_slot) - , _map(map, size_in_slots * bits_per_slot) -{ -} - - -BitMap2D::BitMap2D(idx_t size_in_slots, idx_t bits_per_slot) - : _bits_per_slot(bits_per_slot) - , _map(size_in_slots * bits_per_slot) -{ -} diff --git a/hotspot/src/share/vm/utilities/bitMap.hpp b/hotspot/src/share/vm/utilities/bitMap.hpp index 924d9203635..bc5cb589929 100644 --- a/hotspot/src/share/vm/utilities/bitMap.hpp +++ b/hotspot/src/share/vm/utilities/bitMap.hpp @@ -33,6 +33,16 @@ class BitMapClosure; // Operations for bitmaps represented as arrays of unsigned integers. // Bit offsets are numbered from 0 to size-1. +// The "abstract" base BitMap class. +// +// The constructor and destructor are protected to prevent +// creation of BitMap instances outside of the BitMap class. +// +// The BitMap class doesn't use virtual calls on purpose, +// this ensures that we don't get a vtable unnecessarily. +// +// The allocation of the backing storage for the BitMap are handled by +// the subclasses. BitMap doesn't allocate or delete backing storage. class BitMap VALUE_OBJ_CLASS_SPEC { friend class BitMap2D; @@ -50,10 +60,6 @@ class BitMap VALUE_OBJ_CLASS_SPEC { bm_word_t* _map; // First word in bitmap idx_t _size; // Size of bitmap (in bits) - // Puts the given value at the given offset, using resize() to size - // the bitmap appropriately if needed using factor-of-two expansion. - void at_put_grow(idx_t index, bool value); - protected: // Return the position of bit within the word that contains it (e.g., if // bitmap words are 32 bits, return a number 0 <= n <= 31). @@ -97,6 +103,8 @@ class BitMap VALUE_OBJ_CLASS_SPEC { void set_large_range_of_words (idx_t beg, idx_t end); void clear_large_range_of_words (idx_t beg, idx_t end); + static void clear_range_of_words(bm_word_t* map, idx_t beg, idx_t end); + // The index of the first full word in a range. idx_t word_index_round_up(idx_t bit) const; @@ -110,46 +118,69 @@ class BitMap VALUE_OBJ_CLASS_SPEC { static idx_t num_set_bits(bm_word_t w); static idx_t num_set_bits_from_table(unsigned char c); - public: + // Allocation Helpers. + + // Allocates and clears the bitmap memory. + template + static bm_word_t* allocate(const Allocator&, idx_t size_in_bits); + + // Reallocates and clears the new bitmap memory. + template + static bm_word_t* reallocate(const Allocator&, bm_word_t* map, idx_t old_size_in_bits, idx_t new_size_in_bits); - // Constructs a bitmap with no map, and size 0. - BitMap() : _map(NULL), _size(0) {} + // Free the bitmap memory. + template + static void free(const Allocator&, bm_word_t* map, idx_t size_in_bits); - // Constructs a bitmap with the given map and size. - BitMap(bm_word_t* map, idx_t size_in_bits) :_map(map), _size(size_in_bits) {} + // Protected functions, that are used by BitMap sub-classes that support them. - // Constructs an empty bitmap of the given size (that is, this clears the - // new bitmap). Allocates the map array in resource area if - // "in_resource_area" is true, else in the C heap. - BitMap(idx_t size_in_bits, bool in_resource_area = true); + // Resize the backing bitmap memory. + // + // Old bits are transfered to the new memory + // and the extended memory is cleared. + template + void resize(const Allocator& allocator, idx_t new_size_in_bits); + + // Set up and clear the bitmap memory. + // + // Precondition: The bitmap was default constructed and has + // not yet had memory allocated via resize or (re)initialize. + template + void initialize(const Allocator& allocator, idx_t size_in_bits); + + // Set up and clear the bitmap memory. + // + // Can be called on previously initialized bitmaps. + template + void reinitialize(const Allocator& allocator, idx_t new_size_in_bits); // Set the map and size. - void set_map(bm_word_t* map) { _map = map; } - void set_size(idx_t size_in_bits) { _size = size_in_bits; } - - // Allocates necessary data structure, either in the resource area - // or in the C heap, as indicated by "in_resource_area." - // Preserves state currently in bit map by copying data. - // Zeros any newly-addressable bits. - // If "in_resource_area" is false, frees the current map. - // (Note that this assumes that all calls to "resize" on the same BitMap - // use the same value for "in_resource_area".) - void resize(idx_t size_in_bits, bool in_resource_area = true); + void update(bm_word_t* map, idx_t size) { + _map = map; + _size = size; + } + + // Protected constructor and destructor. + BitMap(bm_word_t* map, idx_t size_in_bits) : _map(map), _size(size_in_bits) {} + ~BitMap() {} + public: // Pretouch the entire range of memory this BitMap covers. void pretouch(); // Accessing - idx_t size() const { return _size; } - idx_t size_in_bytes() const { return size_in_words() * BytesPerWord; } - idx_t size_in_words() const { - return calc_size_in_words(size()); - } - static idx_t calc_size_in_words(size_t size_in_bits) { return word_index(size_in_bits + BitsPerWord - 1); } + static idx_t calc_size_in_bytes(size_t size_in_bits) { + return calc_size_in_words(size_in_bits) * BytesPerWord; + } + + idx_t size() const { return _size; } + idx_t size_in_words() const { return calc_size_in_words(size()); } + idx_t size_in_bytes() const { return calc_size_in_bytes(size()); } + bool at(idx_t index) const { verify_index(index); return (*word_addr(index) & bit_mask(index)) != 0; @@ -279,6 +310,88 @@ class BitMap VALUE_OBJ_CLASS_SPEC { #endif }; +// A concrete implementation of the the "abstract" BitMap class. +// +// The BitMapView is used when the backing storage is managed externally. +class BitMapView : public BitMap { + public: + BitMapView() : BitMap(NULL, 0) {} + BitMapView(bm_word_t* map, idx_t size_in_bits) : BitMap(map, size_in_bits) {} +}; + +// A BitMap with storage in a ResourceArea. +class ResourceBitMap : public BitMap { + friend class TestBitMap; + + public: + ResourceBitMap() : BitMap(NULL, 0) {} + // Clears the bitmap memory. + ResourceBitMap(idx_t size_in_bits); + + // Resize the backing bitmap memory. + // + // Old bits are transfered to the new memory + // and the extended memory is cleared. + void resize(idx_t new_size_in_bits); + + // Set up and clear the bitmap memory. + // + // Precondition: The bitmap was default constructed and has + // not yet had memory allocated via resize or initialize. + void initialize(idx_t size_in_bits); + + // Set up and clear the bitmap memory. + // + // Can be called on previously initialized bitmaps. + void reinitialize(idx_t size_in_bits); +}; + +// A BitMap with storage in a specific Arena. +class ArenaBitMap : public BitMap { + public: + // Clears the bitmap memory. + ArenaBitMap(Arena* arena, idx_t size_in_bits); + + private: + // Don't allow copy or assignment. + ArenaBitMap(const ArenaBitMap&); + ArenaBitMap& operator=(const ArenaBitMap&); +}; + +// A BitMap with storage in the CHeap. +class CHeapBitMap : public BitMap { + friend class TestBitMap; + + private: + // Don't allow copy or assignment, to prevent the + // allocated memory from leaking out to other instances. + CHeapBitMap(const CHeapBitMap&); + CHeapBitMap& operator=(const CHeapBitMap&); + + public: + CHeapBitMap() : BitMap(NULL, 0) {} + // Clears the bitmap memory. + CHeapBitMap(idx_t size_in_bits); + ~CHeapBitMap(); + + // Resize the backing bitmap memory. + // + // Old bits are transfered to the new memory + // and the extended memory is cleared. + void resize(idx_t new_size_in_bits); + + // Set up and clear the bitmap memory. + // + // Precondition: The bitmap was default constructed and has + // not yet had memory allocated via resize or initialize. + void initialize(idx_t size_in_bits); + + // Set up and clear the bitmap memory. + // + // Can be called on previously initialized bitmaps. + void reinitialize(idx_t size_in_bits); +}; + // Convenience class wrapping BitMap which provides multiple bits per slot. class BitMap2D VALUE_OBJ_CLASS_SPEC { public: @@ -286,8 +399,8 @@ class BitMap2D VALUE_OBJ_CLASS_SPEC { typedef BitMap::bm_word_t bm_word_t; // Element type of array that // represents the bitmap. private: - BitMap _map; - idx_t _bits_per_slot; + ResourceBitMap _map; + idx_t _bits_per_slot; idx_t bit_index(idx_t slot_index, idx_t bit_within_slot_index) const { return slot_index * _bits_per_slot + bit_within_slot_index; @@ -299,10 +412,12 @@ class BitMap2D VALUE_OBJ_CLASS_SPEC { public: // Construction. bits_per_slot must be greater than 0. - BitMap2D(bm_word_t* map, idx_t size_in_slots, idx_t bits_per_slot); + BitMap2D(idx_t bits_per_slot) : + _map(), _bits_per_slot(bits_per_slot) {} // Allocates necessary data structure in resource area. bits_per_slot must be greater than 0. - BitMap2D(idx_t size_in_slots, idx_t bits_per_slot); + BitMap2D(idx_t size_in_slots, idx_t bits_per_slot) : + _map(size_in_slots * bits_per_slot), _bits_per_slot(bits_per_slot) {} idx_t size_in_bits() { return _map.size(); diff --git a/hotspot/src/share/vm/utilities/bitMap.inline.hpp b/hotspot/src/share/vm/utilities/bitMap.inline.hpp index 57cb847ae63..49521d8b149 100644 --- a/hotspot/src/share/vm/utilities/bitMap.inline.hpp +++ b/hotspot/src/share/vm/utilities/bitMap.inline.hpp @@ -121,18 +121,18 @@ inline void BitMap::set_range_of_words(idx_t beg, idx_t end) { for (idx_t i = beg; i < end; ++i) map[i] = ~(bm_word_t)0; } - -inline void BitMap::clear_range_of_words(idx_t beg, idx_t end) { - bm_word_t* map = _map; +inline void BitMap::clear_range_of_words(bm_word_t* map, idx_t beg, idx_t end) { for (idx_t i = beg; i < end; ++i) map[i] = 0; } +inline void BitMap::clear_range_of_words(idx_t beg, idx_t end) { + clear_range_of_words(_map, beg, end); +} inline void BitMap::clear() { clear_range_of_words(0, size_in_words()); } - inline void BitMap::par_clear_range(idx_t beg, idx_t end, RangeSizeHint hint) { if (hint == small_range && end - beg == 1) { par_at_put(beg, false); @@ -359,7 +359,12 @@ inline void BitMap2D::at_put(idx_t slot_index, idx_t bit_within_slot_index, bool inline void BitMap2D::at_put_grow(idx_t slot_index, idx_t bit_within_slot_index, bool value) { verify_bit_within_slot_index(bit_within_slot_index); - _map.at_put_grow(bit_index(slot_index, bit_within_slot_index), value); + + idx_t bit = bit_index(slot_index, bit_within_slot_index); + if (bit >= _map.size()) { + _map.resize(2 * MAX2(_map.size(), bit)); + } + _map.at_put(bit, value); } inline void BitMap2D::clear() { -- GitLab From 6663f0cfeda3af82bf1b2dd922ed289d9b4df3d2 Mon Sep 17 00:00:00 2001 From: Jon Masamitsu Date: Tue, 3 May 2016 16:19:42 -0700 Subject: [PATCH 256/400] 8155966: Assertion failures when -XX:+UseParallelGC -XX:ParallelGCThreads=1 Reviewed-by: drwhite, kbarrett --- hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp index 98bdefd3734..1586a771e48 100644 --- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp @@ -1929,7 +1929,7 @@ bool PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) { ParCompactionManager* const cm = ParCompactionManager::manager_array(int(i)); assert(cm->marking_stack()->is_empty(), "should be empty"); - assert(cm->region_stack()->is_empty(), "should be empty"); + assert(cm->region_stack()->is_empty(), "Region stack " SIZE_FORMAT " is not empty", i); } #endif // ASSERT @@ -2370,10 +2370,8 @@ void PSParallelCompact::enqueue_region_stealing_tasks( // Once a thread has drained it's stack, it should try to steal regions from // other threads. - if (parallel_gc_threads > 1) { - for (uint j = 0; j < parallel_gc_threads; j++) { - q->enqueue(new StealRegionCompactionTask(terminator_ptr)); - } + for (uint j = 0; j < parallel_gc_threads; j++) { + q->enqueue(new StealRegionCompactionTask(terminator_ptr)); } } -- GitLab From 1b213af30cd49a73075ac699e9b69609fb340aba Mon Sep 17 00:00:00 2001 From: Vivek Deshpande Date: Tue, 3 May 2016 17:11:39 -0700 Subject: [PATCH 257/400] 8155864: api/java_lang/Math/cos_cos6 and sin_sin6 fail Reviewed-by: kvn --- hotspot/src/cpu/x86/vm/macroAssembler_x86_sin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86_sin.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sin.cpp index 97cfd27b936..68547eebfdd 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86_sin.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86_sin.cpp @@ -380,7 +380,7 @@ ALIGNED_(8) juint StubRoutines::x86::_P_1[] = ALIGNED_(8) juint StubRoutines::x86::_NEG_ZERO[] = { - 0x00000000UL, 0x3c800000UL + 0x00000000UL, 0x80000000UL }; void MacroAssembler::fast_sin(XMMRegister xmm0, XMMRegister xmm1, XMMRegister xmm2, XMMRegister xmm3, XMMRegister xmm4, XMMRegister xmm5, XMMRegister xmm6, XMMRegister xmm7, Register eax, Register ebx, Register ecx, Register edx, Register tmp1, Register tmp2, Register tmp3, Register tmp4) { -- GitLab From 432cff9626977ffc83f8aa0edc9058717b1919ac Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Wed, 27 Apr 2016 16:20:05 +0200 Subject: [PATCH 258/400] 8155634: Clean out old logging and dead code from SurvRateGroup Reviewed-by: jmasa, tschatzl, sjohanss --- .../src/share/vm/gc/g1/g1CollectedHeap.cpp | 1 - .../src/share/vm/gc/g1/g1DefaultPolicy.cpp | 42 ++---- .../src/share/vm/gc/g1/g1DefaultPolicy.hpp | 7 +- hotspot/src/share/vm/gc/g1/g1Policy.hpp | 2 - hotspot/src/share/vm/gc/g1/g1_globals.hpp | 6 - hotspot/src/share/vm/gc/g1/survRateGroup.cpp | 137 +++--------------- hotspot/src/share/vm/gc/g1/survRateGroup.hpp | 34 ++--- .../runtime/commandLineFlagConstraintsGC.cpp | 14 -- .../runtime/commandLineFlagConstraintsGC.hpp | 1 - 9 files changed, 46 insertions(+), 198 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index cd05737ea94..90a7d35c144 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -2710,7 +2710,6 @@ void G1CollectedHeap::gc_threads_do(ThreadClosure* tc) const { void G1CollectedHeap::print_tracing_info() const { g1_rem_set()->print_summary_info(); concurrent_mark()->print_summary_info(); - g1_policy()->print_yg_surv_rate_info(); } #ifndef PRODUCT diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index dd26986a68e..340125ea9ce 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -54,8 +54,8 @@ G1DefaultPolicy::G1DefaultPolicy() : _ihop_control(create_ihop_control(&_predictor)), _policy_counters(new GCPolicyCounters("GarbageFirst", 1, 3)), _young_list_fixed_length(0), - _short_lived_surv_rate_group(new SurvRateGroup(&_predictor, "Short Lived", G1YoungSurvRateNumRegionsSummary)), - _survivor_surv_rate_group(new SurvRateGroup(&_predictor, "Survivor", G1YoungSurvRateNumRegionsSummary)), + _short_lived_surv_rate_group(new SurvRateGroup()), + _survivor_surv_rate_group(new SurvRateGroup()), _reserve_factor((double) G1ReservePercent / 100.0), _reserve_regions(0), _rs_lengths_prediction(0), @@ -396,35 +396,29 @@ void G1DefaultPolicy::update_rs_lengths_prediction(size_t prediction) { #ifndef PRODUCT bool G1DefaultPolicy::verify_young_ages() { - return verify_young_ages(_collection_set->inc_head(), _short_lived_surv_rate_group); -} - -bool G1DefaultPolicy::verify_young_ages(HeapRegion* head, SurvRateGroup *surv_rate_group) { - guarantee( surv_rate_group != NULL, "pre-condition" ); - - const char* name = surv_rate_group->name(); bool ret = true; - for (HeapRegion* curr = head; + for (HeapRegion* curr = _collection_set->inc_head(); curr != NULL; curr = curr->next_in_collection_set()) { + guarantee(curr->is_young(), "Region must be young"); + SurvRateGroup* group = curr->surv_rate_group(); - if (group == NULL && !curr->is_survivor()) { - log_error(gc, verify)("## %s: encountered NULL surv_rate_group", name); + + if (group == NULL) { + log_error(gc, verify)("## encountered NULL surv_rate_group in young region"); ret = false; } - if (surv_rate_group == group) { - if (curr->age_in_surv_rate_group() < 0) { - log_error(gc, verify)("## %s: encountered negative age", name); - ret = false; - } + if (curr->age_in_surv_rate_group() < 0) { + log_error(gc, verify)("## encountered negative age in young region"); + ret = false; } } if (!ret) { LogStreamHandle(Error, gc, verify) log; - _collection_set->print(head, &log); + _collection_set->print(_collection_set->inc_head(), &log); } return ret; @@ -841,10 +835,6 @@ double G1DefaultPolicy::predict_yg_surv_rate(int age, SurvRateGroup* surv_rate_g return pred; } -double G1DefaultPolicy::predict_yg_surv_rate(int age) const { - return predict_yg_surv_rate(age, _short_lived_surv_rate_group); -} - double G1DefaultPolicy::accum_yg_surv_rate_pred(int age) const { return _short_lived_surv_rate_group->accum_surv_rate_pred(age); } @@ -898,14 +888,6 @@ double G1DefaultPolicy::predict_region_elapsed_time_ms(HeapRegion* hr, return region_elapsed_time_ms; } - -void G1DefaultPolicy::print_yg_surv_rate_info() const { -#ifndef PRODUCT - _short_lived_surv_rate_group->print_surv_rate_summary(); - // add this call for any other surv rate groups -#endif // PRODUCT -} - bool G1DefaultPolicy::should_allocate_mutator_region() const { uint young_list_length = _g1->young_regions_count(); uint young_list_target_length = _young_list_target_length; diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp index 5c8b96f34ce..2627dc4517d 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.hpp @@ -148,8 +148,8 @@ public: void cset_regions_freed() { bool update = should_update_surv_rate_group_predictors(); - _short_lived_surv_rate_group->all_surviving_words_recorded(update); - _survivor_surv_rate_group->all_surviving_words_recorded(update); + _short_lived_surv_rate_group->all_surviving_words_recorded(predictor(), update); + _survivor_surv_rate_group->all_surviving_words_recorded(predictor(), update); } G1MMUTracker* mmu_tracker() { @@ -370,9 +370,6 @@ public: // the initial-mark work and start a marking cycle. void decide_on_conc_mark_initiation(); - // Print stats on young survival ratio - void print_yg_surv_rate_info() const; - void finished_recalculating_age_indexes(bool is_survivors) { if (is_survivors) { _survivor_surv_rate_group->finished_recalculating_age_indexes(); diff --git a/hotspot/src/share/vm/gc/g1/g1Policy.hpp b/hotspot/src/share/vm/gc/g1/g1Policy.hpp index f2616c6076e..78240032d2d 100644 --- a/hotspot/src/share/vm/gc/g1/g1Policy.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Policy.hpp @@ -156,8 +156,6 @@ public: // the initial-mark work and start a marking cycle. virtual void decide_on_conc_mark_initiation() = 0; - // Print stats on young survival ratio - virtual void print_yg_surv_rate_info() const = 0; virtual void finished_recalculating_age_indexes(bool is_survivors) = 0; diff --git a/hotspot/src/share/vm/gc/g1/g1_globals.hpp b/hotspot/src/share/vm/gc/g1/g1_globals.hpp index ce8d96ea3ec..e44411190f7 100644 --- a/hotspot/src/share/vm/gc/g1/g1_globals.hpp +++ b/hotspot/src/share/vm/gc/g1/g1_globals.hpp @@ -179,12 +179,6 @@ develop(bool, G1ScrubRemSets, true, \ "When true, do RS scrubbing after cleanup.") \ \ - develop(intx, G1YoungSurvRateNumRegionsSummary, 0, \ - "the number of regions for which we'll print a surv rate " \ - "summary.") \ - range(0, max_intx) \ - constraint(G1YoungSurvRateNumRegionsSummaryConstraintFunc,AfterErgo)\ - \ product(uintx, G1ReservePercent, 10, \ "It determines the minimum reserve we should have in the heap " \ "to minimize the probability of promotion failure.") \ diff --git a/hotspot/src/share/vm/gc/g1/survRateGroup.cpp b/hotspot/src/share/vm/gc/g1/survRateGroup.cpp index e201d259491..b59a7268379 100644 --- a/hotspot/src/share/vm/gc/g1/survRateGroup.cpp +++ b/hotspot/src/share/vm/gc/g1/survRateGroup.cpp @@ -30,33 +30,14 @@ #include "logging/log.hpp" #include "memory/allocation.hpp" -SurvRateGroup::SurvRateGroup(G1Predictions* predictor, - const char* name, - size_t summary_surv_rates_len) : - _predictor(predictor), _name(name), - _summary_surv_rates_len(summary_surv_rates_len), - _summary_surv_rates_max_len(0), - _summary_surv_rates(NULL), - _surv_rate(NULL), +SurvRateGroup::SurvRateGroup() : _accum_surv_rate_pred(NULL), _surv_rate_pred(NULL), _stats_arrays_length(0) { reset(); - if (summary_surv_rates_len > 0) { - size_t length = summary_surv_rates_len; - _summary_surv_rates = NEW_C_HEAP_ARRAY(NumberSeq*, length, mtGC); - for (size_t i = 0; i < length; ++i) { - _summary_surv_rates[i] = new NumberSeq(); - } - } - start_adding_regions(); } -double SurvRateGroup::get_new_prediction(TruncatedSeq const* seq) const { - return _predictor->get_new_prediction(seq); -} - void SurvRateGroup::reset() { _all_regions_allocated = 0; _setup_seq_num = 0; @@ -73,10 +54,14 @@ void SurvRateGroup::reset() { _stats_arrays_length = 0; stop_adding_regions(); + + // Seed initial _surv_rate_pred and _accum_surv_rate_pred values guarantee( _stats_arrays_length == 1, "invariant" ); guarantee( _surv_rate_pred[0] != NULL, "invariant" ); - _surv_rate_pred[0]->add(0.4); - all_surviving_words_recorded(false); + const double initial_surv_rate = 0.4; + _surv_rate_pred[0]->add(initial_surv_rate); + _last_pred = _accum_surv_rate_pred[0] = initial_surv_rate; + _region_num = 0; } @@ -87,131 +72,49 @@ void SurvRateGroup::start_adding_regions() { void SurvRateGroup::stop_adding_regions() { if (_region_num > _stats_arrays_length) { - double* old_surv_rate = _surv_rate; - double* old_accum_surv_rate_pred = _accum_surv_rate_pred; - TruncatedSeq** old_surv_rate_pred = _surv_rate_pred; - - _surv_rate = NEW_C_HEAP_ARRAY(double, _region_num, mtGC); - _accum_surv_rate_pred = NEW_C_HEAP_ARRAY(double, _region_num, mtGC); - _surv_rate_pred = NEW_C_HEAP_ARRAY(TruncatedSeq*, _region_num, mtGC); + _accum_surv_rate_pred = REALLOC_C_HEAP_ARRAY(double, _accum_surv_rate_pred, _region_num, mtGC); + _surv_rate_pred = REALLOC_C_HEAP_ARRAY(TruncatedSeq*, _surv_rate_pred, _region_num, mtGC); - for (size_t i = 0; i < _stats_arrays_length; ++i) { - _surv_rate_pred[i] = old_surv_rate_pred[i]; - } for (size_t i = _stats_arrays_length; i < _region_num; ++i) { _surv_rate_pred[i] = new TruncatedSeq(10); } _stats_arrays_length = _region_num; - - if (old_surv_rate != NULL) { - FREE_C_HEAP_ARRAY(double, old_surv_rate); - } - if (old_accum_surv_rate_pred != NULL) { - FREE_C_HEAP_ARRAY(double, old_accum_surv_rate_pred); - } - if (old_surv_rate_pred != NULL) { - FREE_C_HEAP_ARRAY(TruncatedSeq*, old_surv_rate_pred); - } - } - - for (size_t i = 0; i < _stats_arrays_length; ++i) { - _surv_rate[i] = 0.0; } } -int SurvRateGroup::next_age_index() { - ++_region_num; - return (int) ++_all_regions_allocated; -} - void SurvRateGroup::record_surviving_words(int age_in_group, size_t surv_words) { guarantee( 0 <= age_in_group && (size_t) age_in_group < _region_num, "pre-condition" ); - guarantee( _surv_rate[age_in_group] <= 0.00001, - "should only update each slot once" ); double surv_rate = (double) surv_words / (double) HeapRegion::GrainWords; - _surv_rate[age_in_group] = surv_rate; _surv_rate_pred[age_in_group]->add(surv_rate); - if ((size_t)age_in_group < _summary_surv_rates_len) { - _summary_surv_rates[age_in_group]->add(surv_rate); - if ((size_t)(age_in_group+1) > _summary_surv_rates_max_len) - _summary_surv_rates_max_len = age_in_group+1; +} + +void SurvRateGroup::all_surviving_words_recorded(const G1Predictions& predictor, bool update_predictors) { + if (update_predictors) { + fill_in_last_surv_rates(); } + finalize_predictions(predictor); } -void SurvRateGroup::all_surviving_words_recorded(bool update_predictors) { - if (update_predictors && _region_num > 0) { // conservative +void SurvRateGroup::fill_in_last_surv_rates() { + if (_region_num > 0) { // conservative double surv_rate = _surv_rate_pred[_region_num-1]->last(); for (size_t i = _region_num; i < _stats_arrays_length; ++i) { - guarantee( _surv_rate[i] <= 0.00001, - "the slot should not have been updated" ); _surv_rate_pred[i]->add(surv_rate); } } +} +void SurvRateGroup::finalize_predictions(const G1Predictions& predictor) { double accum = 0.0; double pred = 0.0; for (size_t i = 0; i < _stats_arrays_length; ++i) { - pred = get_new_prediction(_surv_rate_pred[i]); + pred = predictor.get_new_prediction(_surv_rate_pred[i]); if (pred > 1.0) pred = 1.0; accum += pred; _accum_surv_rate_pred[i] = accum; } _last_pred = pred; } - -#ifndef PRODUCT -void SurvRateGroup::print() { - log_develop_trace(gc, survivor)("Surv Rate Group: %s (" SIZE_FORMAT " entries)", _name, _region_num); - for (size_t i = 0; i < _region_num; ++i) { - log_develop_trace(gc, survivor)(" age " SIZE_FORMAT_W(4) " surv rate %6.2lf %% pred %6.2lf %%", - i, _surv_rate[i] * 100.0, - _predictor->get_new_prediction(_surv_rate_pred[i]) * 100.0); - } -} - -void -SurvRateGroup::print_surv_rate_summary() { - size_t length = _summary_surv_rates_max_len; - if (length == 0) - return; - - log_trace(gc, survivor)("%s Rate Summary (for up to age " SIZE_FORMAT ")", _name, length-1); - log_trace(gc, survivor)(" age range survival rate (avg) samples (avg)"); - log_trace(gc, survivor)(" ---------------------------------------------------------"); - - size_t index = 0; - size_t limit = MIN2((int) length, 10); - while (index < limit) { - log_trace(gc, survivor)(" " SIZE_FORMAT_W(4) " %6.2lf%% %6.2lf", - index, _summary_surv_rates[index]->avg() * 100.0, - (double) _summary_surv_rates[index]->num()); - ++index; - } - - log_trace(gc, survivor)(" ---------------------------------------------------------"); - - int num = 0; - double sum = 0.0; - int samples = 0; - while (index < length) { - ++num; - sum += _summary_surv_rates[index]->avg() * 100.0; - samples += _summary_surv_rates[index]->num(); - ++index; - - if (index == length || num % 10 == 0) { - log_trace(gc, survivor)(" " SIZE_FORMAT_W(4) " .. " SIZE_FORMAT_W(4) " %6.2lf%% %6.2lf", - (index-1) / 10 * 10, index-1, sum / (double) num, - (double) samples / (double) num); - sum = 0.0; - num = 0; - samples = 0; - } - } - - log_trace(gc, survivor)(" ---------------------------------------------------------"); -} -#endif // PRODUCT diff --git a/hotspot/src/share/vm/gc/g1/survRateGroup.hpp b/hotspot/src/share/vm/gc/g1/survRateGroup.hpp index a4fbe3bf690..58f458c79be 100644 --- a/hotspot/src/share/vm/gc/g1/survRateGroup.hpp +++ b/hotspot/src/share/vm/gc/g1/survRateGroup.hpp @@ -31,37 +31,27 @@ class G1Predictions; class SurvRateGroup : public CHeapObj { private: - G1Predictions* _predictor; - - double get_new_prediction(TruncatedSeq const* seq) const; - - const char* _name; - size_t _stats_arrays_length; - double* _surv_rate; double* _accum_surv_rate_pred; double _last_pred; TruncatedSeq** _surv_rate_pred; - NumberSeq** _summary_surv_rates; - size_t _summary_surv_rates_len; - size_t _summary_surv_rates_max_len; int _all_regions_allocated; size_t _region_num; size_t _setup_seq_num; + void fill_in_last_surv_rates(); + void finalize_predictions(const G1Predictions& predictor); public: - SurvRateGroup(G1Predictions* predictor, - const char* name, - size_t summary_surv_rates_len); + SurvRateGroup(); void reset(); void start_adding_regions(); void stop_adding_regions(); void record_surviving_words(int age_in_group, size_t surv_words); - void all_surviving_words_recorded(bool update_predictors); - const char* name() { return _name; } + void all_surviving_words_recorded(const G1Predictions& predictor, bool update_predictors); + + size_t region_num() const { return _region_num; } - size_t region_num() { return _region_num; } double accum_surv_rate_pred(int age) const { assert(age >= 0, "must be"); if ((size_t)age < _stats_arrays_length) @@ -82,8 +72,12 @@ public: return seq; } - int next_age_index(); - int age_in_group(int age_index) { + int next_age_index() { + ++_region_num; + return (int) ++_all_regions_allocated; + } + + int age_in_group(int age_index) const { int ret = (int) (_all_regions_allocated - age_index); assert( ret >= 0, "invariant" ); return ret; @@ -92,10 +86,6 @@ public: _all_regions_allocated = 0; } -#ifndef PRODUCT - void print(); - void print_surv_rate_summary(); -#endif // PRODUCT }; #endif // SHARE_VM_GC_G1_SURVRATEGROUP_HPP diff --git a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp index 39b40389555..5d14ef7dab2 100644 --- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp +++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.cpp @@ -312,20 +312,6 @@ Flag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose) { } } -Flag::Error G1YoungSurvRateNumRegionsSummaryConstraintFunc(intx value, bool verbose) { - if (!UseG1GC) return Flag::SUCCESS; - - if (value > (intx)HeapRegionBounds::target_number()) { - CommandLineError::print(verbose, - "G1YoungSurvRateNumRegionsSummary (" INTX_FORMAT ") must be " - "less than or equal to region count (" SIZE_FORMAT ")\n", - value, HeapRegionBounds::target_number()); - return Flag::VIOLATES_CONSTRAINT; - } else { - return Flag::SUCCESS; - } -} - Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose) { if (!UseG1GC) return Flag::SUCCESS; diff --git a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp index 9470a1c4ec4..1582ad0d55b 100644 --- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp +++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsGC.hpp @@ -49,7 +49,6 @@ Flag::Error MaxTenuringThresholdConstraintFunc(uintx value, bool verbose); #if INCLUDE_ALL_GCS Flag::Error G1RSetRegionEntriesConstraintFunc(intx value, bool verbose); Flag::Error G1RSetSparseRegionEntriesConstraintFunc(intx value, bool verbose); -Flag::Error G1YoungSurvRateNumRegionsSummaryConstraintFunc(intx value, bool verbose); Flag::Error G1HeapRegionSizeConstraintFunc(size_t value, bool verbose); Flag::Error G1NewSizePercentConstraintFunc(uintx value, bool verbose); Flag::Error G1MaxNewSizePercentConstraintFunc(uintx value, bool verbose); -- GitLab From 8cb0a9803275c38f9952097d84580449c722e808 Mon Sep 17 00:00:00 2001 From: Vivek Deshpande Date: Wed, 27 Apr 2016 13:37:07 -0700 Subject: [PATCH 259/400] 8154975: Update for vectorizedMismatch with AVX512 Reviewed-by: kvn --- hotspot/src/cpu/x86/vm/assembler_x86.cpp | 37 +++++++++++- hotspot/src/cpu/x86/vm/assembler_x86.hpp | 22 ++++++- hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp | 59 +++++++++++++++++-- 3 files changed, 112 insertions(+), 6 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp index ffbc0b1bdf3..dccf9c8cfb0 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp @@ -2323,6 +2323,15 @@ void Assembler::kortestql(KRegister src1, KRegister src2) { emit_int8((unsigned char)(0xC0 | encode)); } +// This instruction produces ZF or CF flags +void Assembler::ktestql(KRegister src1, KRegister src2) { + assert(VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(AVX_128bit, /* rex_w */ true, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = vex_prefix_and_encode(src1->encoding(), 0, src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0x99); + emit_int8((unsigned char)(0xC0 | encode)); +} + void Assembler::movb(Address dst, int imm8) { InstructionMark im(this); prefix(dst); @@ -2491,6 +2500,19 @@ void Assembler::evmovdqub(Address dst, XMMRegister src, int vector_len) { emit_operand(src, dst); } +void Assembler::evmovdqub(KRegister mask, XMMRegister dst, Address src, int vector_len) { + assert(VM_Version::supports_avx512vlbw(), ""); + assert(is_vector_masking(), ""); // For stub code use only + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + attributes.set_is_evex_instruction(); + vex_prefix(src, 0, dst->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); + emit_int8(0x6F); + emit_operand(dst, src); +} + void Assembler::evmovdquw(XMMRegister dst, XMMRegister src, int vector_len) { assert(VM_Version::supports_evex(), ""); InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); @@ -3285,6 +3307,19 @@ void Assembler::evpcmpeqb(KRegister kdst, XMMRegister nds, Address src, int vect emit_operand(as_Register(dst_enc), src); } +void Assembler::evpcmpeqb(KRegister mask, KRegister kdst, XMMRegister nds, Address src, int vector_len) { + assert(VM_Version::supports_avx512vlbw(), ""); + assert(is_vector_masking(), ""); // For stub code use only + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_reg_mask */ false, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + attributes.set_is_evex_instruction(); + vex_prefix(src, nds->encoding(), kdst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8(0x74); + emit_operand(as_Register(kdst->encoding()), src); +} + // In this context, the dst vector contains the components that are equal, non equal components are zeroed in dst void Assembler::pcmpeqw(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_sse2(), ""); @@ -6938,7 +6973,7 @@ void Assembler::evex_prefix(bool vex_r, bool vex_b, bool vex_x, bool evex_r, boo emit_int8(byte3); // P2: byte 4 as zL'Lbv'aaa - int byte4 = (_attributes->is_no_reg_mask()) ? 0 : 1; // kregs are implemented in the low 3 bits as aaa (hard code k1, it will be initialized for now) + int byte4 = (_attributes->is_no_reg_mask()) ? 0 : _attributes->get_embedded_opmask_register_specifier(); // kregs are implemented in the low 3 bits as aaa (hard code k1, it will be initialized for now) // EVEX.v` for extending EVEX.vvvv or VIDX byte4 |= (evex_v ? 0: EVEX_V); // third EXEC.b for broadcast actions diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp index e82080507a0..9e40bbb90dd 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp @@ -606,6 +606,7 @@ private: bool _legacy_mode_vl; bool _legacy_mode_vlbw; bool _is_managed; + bool _vector_masking; // For stub code use only class InstructionAttr *_attributes; @@ -813,6 +814,7 @@ private: _legacy_mode_vl = (VM_Version::supports_avx512vl() == false); _legacy_mode_vlbw = (VM_Version::supports_avx512vlbw() == false); _is_managed = false; + _vector_masking = false; _attributes = NULL; } @@ -823,6 +825,12 @@ private: void clear_managed(void) { _is_managed = false; } bool is_managed(void) { return _is_managed; } + // Following functions are for stub code use only + void set_vector_masking(void) { _vector_masking = true; } + void clear_vector_masking(void) { _vector_masking = false; } + bool is_vector_masking(void) { return _vector_masking; } + + void lea(Register dst, Address src); void mov(Register dst, Register src); @@ -1354,6 +1362,8 @@ private: void kortestdl(KRegister dst, KRegister src); void kortestql(KRegister dst, KRegister src); + void ktestql(KRegister dst, KRegister src); + void movdl(XMMRegister dst, Register src); void movdl(Register dst, XMMRegister src); void movdl(XMMRegister dst, Address src); @@ -1381,6 +1391,7 @@ private: void evmovdqub(Address dst, XMMRegister src, int vector_len); void evmovdqub(XMMRegister dst, Address src, int vector_len); void evmovdqub(XMMRegister dst, XMMRegister src, int vector_len); + void evmovdqub(KRegister mask, XMMRegister dst, Address src, int vector_len); void evmovdquw(Address dst, XMMRegister src, int vector_len); void evmovdquw(XMMRegister dst, Address src, int vector_len); void evmovdquw(XMMRegister dst, XMMRegister src, int vector_len); @@ -1534,6 +1545,7 @@ private: void vpcmpeqb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void evpcmpeqb(KRegister kdst, XMMRegister nds, XMMRegister src, int vector_len); void evpcmpeqb(KRegister kdst, XMMRegister nds, Address src, int vector_len); + void evpcmpeqb(KRegister mask, KRegister kdst, XMMRegister nds, Address src, int vector_len); void pcmpeqw(XMMRegister dst, XMMRegister src); void vpcmpeqw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); @@ -2098,7 +2110,8 @@ public: _evex_encoding(0), _is_clear_context(false), _is_extended_context(false), - _current_assembler(NULL) { + _current_assembler(NULL), + _embedded_opmask_register_specifier(1) { // hard code k1, it will be initialized for now if (UseAVX < 3) _legacy_mode = true; } @@ -2122,6 +2135,7 @@ private: int _evex_encoding; bool _is_clear_context; bool _is_extended_context; + int _embedded_opmask_register_specifier; Assembler *_current_assembler; @@ -2139,6 +2153,7 @@ public: int get_evex_encoding(void) const { return _evex_encoding; } bool is_clear_context(void) const { return _is_clear_context; } bool is_extended_context(void) const { return _is_extended_context; } + int get_embedded_opmask_register_specifier(void) const { return _embedded_opmask_register_specifier; } // Set the vector len manually void set_vector_len(int vector_len) { _avx_vector_len = vector_len; } @@ -2172,6 +2187,11 @@ public: } } + // Set embedded opmask register specifier. + void set_embedded_opmask_register_specifier(KRegister mask) { + _embedded_opmask_register_specifier = (*mask).encoding() & 0x7; + } + }; #endif // CPU_X86_VM_ASSEMBLER_X86_HPP diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index 6cd3459ce3c..32a33e307f2 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -9425,6 +9425,7 @@ void MacroAssembler::multiply_to_len(Register x, Register xlen, Register y, Regi void MacroAssembler::vectorized_mismatch(Register obja, Register objb, Register length, Register log2_array_indxscale, Register result, Register tmp1, Register tmp2, XMMRegister rymm0, XMMRegister rymm1, XMMRegister rymm2){ assert(UseSSE42Intrinsics, "SSE4.2 must be enabled."); + Label VECTOR64_LOOP, VECTOR64_TAIL, VECTOR64_NOT_EQUAL, VECTOR32_TAIL; Label VECTOR32_LOOP, VECTOR16_LOOP, VECTOR8_LOOP, VECTOR4_LOOP; Label VECTOR16_TAIL, VECTOR8_TAIL, VECTOR4_TAIL; Label VECTOR32_NOT_EQUAL, VECTOR16_NOT_EQUAL, VECTOR8_NOT_EQUAL, VECTOR4_NOT_EQUAL; @@ -9437,11 +9438,62 @@ void MacroAssembler::vectorized_mismatch(Register obja, Register objb, Register shlq(length); xorq(result, result); + if ((UseAVX > 2) && + VM_Version::supports_avx512vlbw()) { + set_vector_masking(); // opening of the stub context for programming mask registers + cmpq(length, 64); + jcc(Assembler::less, VECTOR32_TAIL); + movq(tmp1, length); + andq(tmp1, 0x3F); // tail count + andq(length, ~(0x3F)); //vector count + + bind(VECTOR64_LOOP); + // AVX512 code to compare 64 byte vectors. + evmovdqub(rymm0, Address(obja, result), Assembler::AVX_512bit); + evpcmpeqb(k7, rymm0, Address(objb, result), Assembler::AVX_512bit); + kortestql(k7, k7); + jcc(Assembler::aboveEqual, VECTOR64_NOT_EQUAL); // mismatch + addq(result, 64); + subq(length, 64); + jccb(Assembler::notZero, VECTOR64_LOOP); + + //bind(VECTOR64_TAIL); + testq(tmp1, tmp1); + jcc(Assembler::zero, SAME_TILL_END); + + bind(VECTOR64_TAIL); + // AVX512 code to compare upto 63 byte vectors. + // Save k1 + kmovql(k3, k1); + mov64(tmp2, 0xFFFFFFFFFFFFFFFF); + shlxq(tmp2, tmp2, tmp1); + notq(tmp2); + kmovql(k1, tmp2); + + evmovdqub(k1, rymm0, Address(obja, result), Assembler::AVX_512bit); + evpcmpeqb(k1, k7, rymm0, Address(objb, result), Assembler::AVX_512bit); + + ktestql(k7, k1); + // Restore k1 + kmovql(k1, k3); + jcc(Assembler::below, SAME_TILL_END); // not mismatch + + bind(VECTOR64_NOT_EQUAL); + kmovql(tmp1, k7); + notq(tmp1); + tzcntq(tmp1, tmp1); + addq(result, tmp1); + shrq(result); + jmp(DONE); + bind(VECTOR32_TAIL); + clear_vector_masking(); // closing of the stub context for programming mask registers + } + cmpq(length, 8); jcc(Assembler::equal, VECTOR8_LOOP); jcc(Assembler::less, VECTOR4_TAIL); - if (UseAVX >= 2){ + if (UseAVX >= 2) { cmpq(length, 16); jcc(Assembler::equal, VECTOR16_LOOP); @@ -9549,7 +9601,7 @@ void MacroAssembler::vectorized_mismatch(Register obja, Register objb, Register jccb(Assembler::notZero, BYTES_NOT_EQUAL);//mismatch found jmpb(SAME_TILL_END); - if (UseAVX >= 2){ + if (UseAVX >= 2) { bind(VECTOR32_NOT_EQUAL); vpcmpeqb(rymm2, rymm2, rymm2, Assembler::AVX_256bit); vpcmpeqb(rymm0, rymm0, rymm1, Assembler::AVX_256bit); @@ -9562,7 +9614,7 @@ void MacroAssembler::vectorized_mismatch(Register obja, Register objb, Register } bind(VECTOR16_NOT_EQUAL); - if (UseAVX >= 2){ + if (UseAVX >= 2) { vpcmpeqb(rymm2, rymm2, rymm2, Assembler::AVX_128bit); vpcmpeqb(rymm0, rymm0, rymm1, Assembler::AVX_128bit); pxor(rymm0, rymm2); @@ -9593,7 +9645,6 @@ void MacroAssembler::vectorized_mismatch(Register obja, Register objb, Register bind(DONE); } - //Helper functions for square_to_len() /** -- GitLab From 593cf3fb1638a3b538c1c18b583355331cf0f72d Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Wed, 27 Apr 2016 16:20:49 -0700 Subject: [PATCH 260/400] 8152903: [JVMCI] CompilerToVM::resolveMethod should correctly handle private methods in interfaces Reviewed-by: iveresov --- .../HotSpotResolvedObjectTypeImpl.java | 13 +-- .../hotspot/HotSpotResolvedPrimitiveType.java | 5 -- .../src/jdk/vm/ci/meta/ResolvedJavaType.java | 23 ++++-- .../src/share/vm/interpreter/linkResolver.cpp | 25 +----- .../src/share/vm/jvmci/jvmciCompilerToVM.cpp | 80 ++++++------------- .../share/vm/runtime/compilationPolicy.cpp | 27 +++++++ .../share/vm/runtime/compilationPolicy.hpp | 10 ++- hotspot/src/share/vm/runtime/javaCalls.cpp | 8 +- .../jvmci/compilerToVM/ResolveMethodTest.java | 8 +- ...lvedJavaTypeResolveConcreteMethodTest.java | 2 +- .../ResolvedJavaTypeResolveMethodTest.java | 2 +- .../ci/runtime/test/TestResolvedJavaType.java | 45 ++++------- 12 files changed, 106 insertions(+), 142 deletions(-) diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java index 6d192ef8a86..69dcc998dce 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java @@ -392,18 +392,13 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem return JavaKind.Object; } - @Override - public ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { - ResolvedJavaMethod resolvedMethod = resolveMethod(method, callerType); - if (resolvedMethod == null || resolvedMethod.isAbstract()) { - return null; - } - return resolvedMethod; - } - @Override public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { assert !callerType.isArray(); + if (isInterface()) { + // Methods can only be resolved against concrete types + return null; + } if (method.isConcrete() && method.getDeclaringClass().equals(this) && method.isPublic()) { return method; } diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java index 06e03ae69f2..6363634dea5 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java @@ -168,11 +168,6 @@ public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType return false; } - @Override - public ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { - return null; - } - @Override public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { return null; diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java index 3be863e751e..33698424c8f 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java @@ -217,27 +217,34 @@ public interface ResolvedJavaType extends JavaType, ModifiersProvider { /** * Resolves the method implementation for virtual dispatches on objects of this dynamic type. - * This resolution process only searches "up" the class hierarchy of this type. + * This resolution process only searches "up" the class hierarchy of this type. A broader search + * that also walks "down" the hierarchy is implemented by + * {@link #findUniqueConcreteMethod(ResolvedJavaMethod)}. For interface types it returns null + * since no concrete object can be an interface. * * @param method the method to select the implementation of * @param callerType the caller or context type used to perform access checks - * @return the link-time resolved method (might be abstract) or {@code null} if it can not be - * linked + * @return the method that would be selected at runtime (might be abstract) or {@code null} if + * it can not be resolved */ ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType); /** - * Resolves the method implementation for virtual dispatches on objects of this dynamic type. - * This resolution process only searches "up" the class hierarchy of this type. A broader search - * that also walks "down" the hierarchy is implemented by - * {@link #findUniqueConcreteMethod(ResolvedJavaMethod)}. + * A convenience wrapper for {@link #resolveMethod(ResolvedJavaMethod, ResolvedJavaType)} that + * only returns non-abstract methods. * * @param method the method to select the implementation of * @param callerType the caller or context type used to perform access checks * @return the concrete method that would be selected at runtime, or {@code null} if there is no * concrete implementation of {@code method} in this type or any of its superclasses */ - ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType); + default ResolvedJavaMethod resolveConcreteMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { + ResolvedJavaMethod resolvedMethod = resolveMethod(method, callerType); + if (resolvedMethod == null || resolvedMethod.isAbstract()) { + return null; + } + return resolvedMethod; + } /** * Given a {@link ResolvedJavaMethod} A, returns a concrete {@link ResolvedJavaMethod} B that is diff --git a/hotspot/src/share/vm/interpreter/linkResolver.cpp b/hotspot/src/share/vm/interpreter/linkResolver.cpp index d4b494a6598..0544e1ca476 100644 --- a/hotspot/src/share/vm/interpreter/linkResolver.cpp +++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp @@ -127,30 +127,7 @@ void CallInfo::set_common(KlassHandle resolved_klass, _resolved_appendix = Handle(); DEBUG_ONLY(verify()); // verify before making side effects - if (CompilationPolicy::must_be_compiled(selected_method)) { - // This path is unusual, mostly used by the '-Xcomp' stress test mode. - - // Note: with several active threads, the must_be_compiled may be true - // while can_be_compiled is false; remove assert - // assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile"); - if (!THREAD->can_call_java()) { - // don't force compilation, resolve was on behalf of compiler - return; - } - if (selected_method->method_holder()->is_not_initialized()) { - // 'is_not_initialized' means not only '!is_initialized', but also that - // initialization has not been started yet ('!being_initialized') - // Do not force compilation of methods in uninitialized classes. - // Note that doing this would throw an assert later, - // in CompileBroker::compile_method. - // We sometimes use the link resolver to do reflective lookups - // even before classes are initialized. - return; - } - CompileBroker::compile_method(selected_method, InvocationEntryBci, - CompilationPolicy::policy()->initial_compile_level(), - methodHandle(), 0, "must_be_compiled", CHECK); - } + CompilationPolicy::compile_if_required(selected_method, THREAD); } // utility query for unreflecting a method diff --git a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp index ba91a3220c5..5c1f8c37fea 100644 --- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp +++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp @@ -628,65 +628,35 @@ C2V_VMENTRY(jint, getVtableIndexForInterfaceMethod, (JNIEnv *, jobject, jobject C2V_END C2V_VMENTRY(jobject, resolveMethod, (JNIEnv *, jobject, jobject receiver_jvmci_type, jobject jvmci_method, jobject caller_jvmci_type)) - Klass* recv_klass = CompilerToVM::asKlass(receiver_jvmci_type); - Klass* caller_klass = CompilerToVM::asKlass(caller_jvmci_type); - Method* method = CompilerToVM::asMethod(jvmci_method); - - if (recv_klass->is_array_klass() || (InstanceKlass::cast(recv_klass)->is_linked())) { - Klass* holder_klass = method->method_holder(); - Symbol* method_name = method->name(); - Symbol* method_signature = method->signature(); + KlassHandle recv_klass = CompilerToVM::asKlass(receiver_jvmci_type); + KlassHandle caller_klass = CompilerToVM::asKlass(caller_jvmci_type); + methodHandle method = CompilerToVM::asMethod(jvmci_method); - if (holder_klass->is_interface()) { - // do link-time resolution to check all access rules. - LinkInfo link_info(holder_klass, method_name, method_signature, caller_klass, true); - methodHandle resolved_method = LinkResolver::linktime_resolve_interface_method_or_null(link_info); - if (resolved_method.is_null() || resolved_method->is_private()) { - return NULL; - } - assert(recv_klass->is_subtype_of(holder_klass), ""); - // do actual lookup - methodHandle sel_method = LinkResolver::lookup_instance_method_in_klasses(recv_klass, resolved_method->name(), resolved_method->signature(), CHECK_AND_CLEAR_0); - oop result = CompilerToVM::get_jvmci_method(sel_method, CHECK_NULL); - return JNIHandles::make_local(THREAD, result); + KlassHandle h_resolved (THREAD, method->method_holder()); + Symbol* h_name = method->name(); + Symbol* h_signature = method->signature(); + + bool check_access = true; + LinkInfo link_info(h_resolved, h_name, h_signature, caller_klass, check_access); + methodHandle m; + // Only do exact lookup if receiver klass has been linked. Otherwise, + // the vtable has not been setup, and the LinkResolver will fail. + if (recv_klass->is_array_klass() || + InstanceKlass::cast(recv_klass())->is_linked() && !recv_klass->is_interface()) { + if (h_resolved->is_interface()) { + m = LinkResolver::resolve_interface_call_or_null(recv_klass, link_info); } else { - // do link-time resolution to check all access rules. - LinkInfo link_info(holder_klass, method_name, method_signature, caller_klass, true); - methodHandle resolved_method = LinkResolver::linktime_resolve_virtual_method_or_null(link_info); - if (resolved_method.is_null()) { - return NULL; - } - // do actual lookup (see LinkResolver::runtime_resolve_virtual_method) - int vtable_index = Method::invalid_vtable_index; - Method* selected_method; - - if (resolved_method->method_holder()->is_interface()) { // miranda method - vtable_index = LinkResolver::vtable_index_of_interface_method(holder_klass, resolved_method); - assert(vtable_index >= 0 , "we should have valid vtable index at this point"); - - selected_method = recv_klass->method_at_vtable(vtable_index); - } else { - // at this point we are sure that resolved_method is virtual and not - // a miranda method; therefore, it must have a valid vtable index. - assert(!resolved_method->has_itable_index(), ""); - vtable_index = resolved_method->vtable_index(); - // We could get a negative vtable_index for final methods, - // because as an optimization they are they are never put in the vtable, - // unless they override an existing method. - // If we do get a negative, it means the resolved method is the the selected - // method, and it can never be changed by an override. - if (vtable_index == Method::nonvirtual_vtable_index) { - assert(resolved_method->can_be_statically_bound(), "cannot override this method"); - selected_method = resolved_method(); - } else { - selected_method = recv_klass->method_at_vtable(vtable_index); - } - } - oop result = CompilerToVM::get_jvmci_method(selected_method, CHECK_NULL); - return JNIHandles::make_local(THREAD, result); + m = LinkResolver::resolve_virtual_call_or_null(recv_klass, link_info); } } - return NULL; + + if (m.is_null()) { + // Return NULL only if there was a problem with lookup (uninitialized class, etc.) + return NULL; + } + + oop result = CompilerToVM::get_jvmci_method(m, CHECK_NULL); + return JNIHandles::make_local(THREAD, result); C2V_END C2V_VMENTRY(jboolean, hasFinalizableSubclass,(JNIEnv *, jobject, jobject jvmci_type)) diff --git a/hotspot/src/share/vm/runtime/compilationPolicy.cpp b/hotspot/src/share/vm/runtime/compilationPolicy.cpp index 69a688982ee..494bf18a2dd 100644 --- a/hotspot/src/share/vm/runtime/compilationPolicy.cpp +++ b/hotspot/src/share/vm/runtime/compilationPolicy.cpp @@ -107,6 +107,33 @@ bool CompilationPolicy::must_be_compiled(methodHandle m, int comp_level) { (UseCompiler && AlwaysCompileLoopMethods && m->has_loops() && CompileBroker::should_compile_new_jobs()); // eagerly compile loop methods } +void CompilationPolicy::compile_if_required(methodHandle selected_method, TRAPS) { + if (must_be_compiled(selected_method)) { + // This path is unusual, mostly used by the '-Xcomp' stress test mode. + + // Note: with several active threads, the must_be_compiled may be true + // while can_be_compiled is false; remove assert + // assert(CompilationPolicy::can_be_compiled(selected_method), "cannot compile"); + if (!THREAD->can_call_java() || THREAD->is_Compiler_thread()) { + // don't force compilation, resolve was on behalf of compiler + return; + } + if (selected_method->method_holder()->is_not_initialized()) { + // 'is_not_initialized' means not only '!is_initialized', but also that + // initialization has not been started yet ('!being_initialized') + // Do not force compilation of methods in uninitialized classes. + // Note that doing this would throw an assert later, + // in CompileBroker::compile_method. + // We sometimes use the link resolver to do reflective lookups + // even before classes are initialized. + return; + } + CompileBroker::compile_method(selected_method, InvocationEntryBci, + CompilationPolicy::policy()->initial_compile_level(), + methodHandle(), 0, "must_be_compiled", CHECK); + } +} + // Returns true if m is allowed to be compiled bool CompilationPolicy::can_be_compiled(methodHandle m, int comp_level) { // allow any levels for WhiteBox diff --git a/hotspot/src/share/vm/runtime/compilationPolicy.hpp b/hotspot/src/share/vm/runtime/compilationPolicy.hpp index 5787638909b..84d7825e274 100644 --- a/hotspot/src/share/vm/runtime/compilationPolicy.hpp +++ b/hotspot/src/share/vm/runtime/compilationPolicy.hpp @@ -43,13 +43,19 @@ class CompilationPolicy : public CHeapObj { static elapsedTimer _accumulated_time; static bool _in_vm_startup; + + // m must be compiled before executing it + static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all); + public: static void set_in_vm_startup(bool in_vm_startup) { _in_vm_startup = in_vm_startup; } static void completed_vm_startup(); static bool delay_compilation_during_startup() { return _in_vm_startup; } - // m must be compiled before executing it - static bool must_be_compiled(methodHandle m, int comp_level = CompLevel_all); + // If m must_be_compiled then request a compilation from the CompileBroker. + // This supports the -Xcomp option. + static void compile_if_required(methodHandle m, TRAPS); + // m is allowed to be compiled static bool can_be_compiled(methodHandle m, int comp_level = CompLevel_all); // m is allowed to be osr compiled diff --git a/hotspot/src/share/vm/runtime/javaCalls.cpp b/hotspot/src/share/vm/runtime/javaCalls.cpp index bf8aa7cefa7..686a2c566ab 100644 --- a/hotspot/src/share/vm/runtime/javaCalls.cpp +++ b/hotspot/src/share/vm/runtime/javaCalls.cpp @@ -343,13 +343,7 @@ void JavaCalls::call_helper(JavaValue* result, const methodHandle& method, JavaC } #endif - - assert(thread->can_call_java(), "cannot compile from the native compiler"); - if (CompilationPolicy::must_be_compiled(method)) { - CompileBroker::compile_method(method, InvocationEntryBci, - CompilationPolicy::policy()->initial_compile_level(), - methodHandle(), 0, "must_be_compiled", CHECK); - } + CompilationPolicy::compile_if_required(method, CHECK); // Since the call stub sets up like the interpreter we call the from_interpreted_entry // so we can go compiled via a i2c. Otherwise initial entry method will always diff --git a/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java b/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java index ff08b7e53bf..df6ef8b4747 100644 --- a/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java +++ b/hotspot/test/compiler/jvmci/compilerToVM/ResolveMethodTest.java @@ -137,8 +137,14 @@ public class ResolveMethodTest { HotSpotResolvedObjectType callerMetaspace = CompilerToVMHelper .lookupType(Utils.toJVMTypeSignature(tcase.caller), getClass(), /* resolve = */ true); + HotSpotResolvedObjectType receiverMetaspace = CompilerToVMHelper + .lookupType(Utils.toJVMTypeSignature(tcase.receiver), + getClass(), /* resolve = */ true); + + // Can only resolve methods on a linked class so force initialization + receiverMetaspace.initialize(); HotSpotResolvedJavaMethod resolvedMetaspaceMethod - = CompilerToVMHelper.resolveMethod(holderMetaspace, + = CompilerToVMHelper.resolveMethod(receiverMetaspace, metaspaceMethod, callerMetaspace); if (tcase.isPositive) { Asserts.assertNotNull(resolvedMetaspaceMethod, diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java index 6f1f1759e8e..b253a38f30b 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveConcreteMethodTest.java @@ -105,7 +105,7 @@ public class ResolvedJavaTypeResolveConcreteMethodTest { ResolvedJavaMethod di = getMethod(i, "d"); ResolvedJavaMethod dc = getMethod(c, "d"); - assertEquals(di, i.resolveConcreteMethod(di, c)); + assertEquals(null, i.resolveConcreteMethod(di, c)); assertEquals(di, b.resolveConcreteMethod(di, c)); assertEquals(dc, c.resolveConcreteMethod(di, c)); } diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java index ba62291d47c..0d8121b3ee7 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/ResolvedJavaTypeResolveMethodTest.java @@ -105,7 +105,7 @@ public class ResolvedJavaTypeResolveMethodTest { ResolvedJavaMethod di = getMethod(i, "d"); ResolvedJavaMethod dc = getMethod(c, "d"); - assertEquals(di, i.resolveMethod(di, c)); + assertEquals(null, i.resolveMethod(di, c)); assertEquals(di, b.resolveMethod(di, c)); assertEquals(dc, c.resolveMethod(di, c)); } diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java index 2011bc0c863..b3ead95fe6d 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java @@ -583,29 +583,20 @@ public class TestResolvedJavaType extends TypeUniverse { return declarations; } - private static void checkResolveMethod(ResolvedJavaType type, ResolvedJavaType context, ResolvedJavaMethod decl, ResolvedJavaMethod expected) { - ResolvedJavaMethod impl = type.resolveConcreteMethod(decl, context); - assertEquals(expected, impl); - } - @Test public void resolveMethodTest() { ResolvedJavaType context = metaAccess.lookupJavaType(TestResolvedJavaType.class); for (Class c : classes) { - if (c.isInterface() || c.isPrimitive()) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); + ResolvedJavaType type = metaAccess.lookupJavaType(c); + if (c.isInterface()) { for (Method m : c.getDeclaredMethods()) { - if (JAVA_VERSION <= 1.7D || (!isStatic(m.getModifiers()) && !isPrivate(m.getModifiers()))) { - ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m); - ResolvedJavaMethod impl = type.resolveMethod(resolved, context); - ResolvedJavaMethod expected = resolved.isDefault() || resolved.isAbstract() ? resolved : null; - assertEquals(m.toString(), expected, impl); - } else { - // As of JDK 8, interfaces can have static and private methods - } + ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m); + ResolvedJavaMethod impl = type.resolveMethod(resolved, context); + assertEquals(m.toString(), null, impl); } + } else if (c.isPrimitive()) { + assertEquals("No methods expected", c.getDeclaredMethods().length, 0); } else { - ResolvedJavaType type = metaAccess.lookupJavaType(c); VTable vtable = getVTable(c); for (Method impl : vtable.methods.values()) { Set decls = findDeclarations(impl, c); @@ -613,7 +604,7 @@ public class TestResolvedJavaType extends TypeUniverse { ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); if (m.isPublic()) { ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); - checkResolveMethod(type, context, m, i); + assertEquals(m.toString(), i, type.resolveMethod(m, context)); } } } @@ -625,20 +616,16 @@ public class TestResolvedJavaType extends TypeUniverse { public void resolveConcreteMethodTest() { ResolvedJavaType context = metaAccess.lookupJavaType(TestResolvedJavaType.class); for (Class c : classes) { - if (c.isInterface() || c.isPrimitive()) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); + ResolvedJavaType type = metaAccess.lookupJavaType(c); + if (c.isInterface()) { for (Method m : c.getDeclaredMethods()) { - if (JAVA_VERSION <= 1.7D || (!isStatic(m.getModifiers()) && !isPrivate(m.getModifiers()))) { - ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m); - ResolvedJavaMethod impl = type.resolveConcreteMethod(resolved, context); - ResolvedJavaMethod expected = resolved.isDefault() ? resolved : null; - assertEquals(m.toString(), expected, impl); - } else { - // As of JDK 8, interfaces can have static and private methods - } + ResolvedJavaMethod resolved = metaAccess.lookupJavaMethod(m); + ResolvedJavaMethod impl = type.resolveConcreteMethod(resolved, context); + assertEquals(m.toString(), null, impl); } + } else if (c.isPrimitive()) { + assertEquals("No methods expected", c.getDeclaredMethods().length, 0); } else { - ResolvedJavaType type = metaAccess.lookupJavaType(c); VTable vtable = getVTable(c); for (Method impl : vtable.methods.values()) { Set decls = findDeclarations(impl, c); @@ -646,7 +633,7 @@ public class TestResolvedJavaType extends TypeUniverse { ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); if (m.isPublic()) { ResolvedJavaMethod i = metaAccess.lookupJavaMethod(impl); - checkResolveMethod(type, context, m, i); + assertEquals(i, type.resolveConcreteMethod(m, context)); } } } -- GitLab From 8f2a47ba2e3bf31cca2627ee6863720fcadc9f83 Mon Sep 17 00:00:00 2001 From: Martin Doerr Date: Thu, 28 Apr 2016 10:32:12 +0200 Subject: [PATCH 261/400] 8154836: VM crash due to "Base pointers must match" Improve the handling of AddP nodes in final graph reshaping. Reviewed-by: kvn, zmajo --- hotspot/src/share/vm/opto/compile.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index ca817b5bbd9..2ccdaffa239 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -2846,7 +2846,7 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { assert( !addp->is_AddP() || addp->in(AddPNode::Base)->is_top() || // Top OK for allocation addp->in(AddPNode::Base) == n->in(AddPNode::Base), - "Base pointers must match" ); + "Base pointers must match (addp %u)", addp->_idx ); #ifdef _LP64 if ((UseCompressedOops || UseCompressedClassPointers) && addp->Opcode() == Op_ConP && @@ -2881,6 +2881,21 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { } else { nn = new DecodeNKlassNode(nn, t); } + // Check for succeeding AddP which uses the same Base. + // Otherwise we will run into the assertion above when visiting that guy. + for (uint i = 0; i < n->outcnt(); ++i) { + Node *out_i = n->raw_out(i); + if (out_i && out_i->is_AddP() && out_i->in(AddPNode::Base) == addp) { + out_i->set_req(AddPNode::Base, nn); +#ifdef ASSERT + for (uint j = 0; j < out_i->outcnt(); ++j) { + Node *out_j = out_i->raw_out(j); + assert(out_j == NULL || !out_j->is_AddP() || out_j->in(AddPNode::Base) != addp, + "more than 2 AddP nodes in a chain (out_j %u)", out_j->_idx); + } +#endif + } + } n->set_req(AddPNode::Base, nn); n->set_req(AddPNode::Address, nn); if (addp->outcnt() == 0) { -- GitLab From cca965a11db647f0db5f96d9dcb1bcc17e2de59a Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Thu, 28 Apr 2016 15:24:17 +0200 Subject: [PATCH 262/400] 8155612: Aarch64: vector nodes need to support misaligned offset Add support for misaligned offsets. Reviewed-by: aph --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 167 ++++++++++++++++++++++++-- 1 file changed, 156 insertions(+), 11 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index f149ff30a83..07deb94ea70 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -5306,6 +5306,36 @@ operand immIOffset() interface(CONST_INTER); %} +operand immIOffset4() +%{ + predicate(Address::offset_ok_for_immed(n->get_int(), 2)); + match(ConI); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immIOffset8() +%{ + predicate(Address::offset_ok_for_immed(n->get_int(), 3)); + match(ConI); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immIOffset16() +%{ + predicate(Address::offset_ok_for_immed(n->get_int(), 4)); + match(ConI); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + operand immLoffset() %{ predicate(Address::offset_ok_for_immed(n->get_long())); @@ -5316,6 +5346,36 @@ operand immLoffset() interface(CONST_INTER); %} +operand immLoffset4() +%{ + predicate(Address::offset_ok_for_immed(n->get_long(), 2)); + match(ConL); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immLoffset8() +%{ + predicate(Address::offset_ok_for_immed(n->get_long(), 3)); + match(ConL); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + +operand immLoffset16() +%{ + predicate(Address::offset_ok_for_immed(n->get_long(), 4)); + match(ConL); + + op_cost(0); + format %{ %} + interface(CONST_INTER); +%} + // 32 bit integer valid for add sub immediate operand immIAddSub() %{ @@ -6150,6 +6210,48 @@ operand indOffI(iRegP reg, immIOffset off) %} %} +operand indOffI4(iRegP reg, immIOffset4 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + +operand indOffI8(iRegP reg, immIOffset8 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + +operand indOffI16(iRegP reg, immIOffset16 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + operand indOffL(iRegP reg, immLoffset off) %{ constraint(ALLOC_IN_RC(ptr_reg)); @@ -6164,6 +6266,47 @@ operand indOffL(iRegP reg, immLoffset off) %} %} +operand indOffL4(iRegP reg, immLoffset4 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + +operand indOffL8(iRegP reg, immLoffset8 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} + +operand indOffL16(iRegP reg, immLoffset16 off) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg off); + op_cost(0); + format %{ "[$reg, $off]" %} + interface(MEMORY_INTER) %{ + base($reg); + index(0xffffffff); + scale(0x0); + disp($off); + %} +%} operand indirectN(iRegN reg) %{ @@ -6476,7 +6619,9 @@ operand iRegL2I(iRegL reg) %{ interface(REG_INTER) %} -opclass vmem(indirect, indIndex, indOffI, indOffL); +opclass vmem4(indirect, indIndex, indOffI4, indOffL4); +opclass vmem8(indirect, indIndex, indOffI8, indOffL8); +opclass vmem16(indirect, indIndex, indOffI16, indOffL16); //----------OPERAND CLASSES---------------------------------------------------- // Operand Classes are groups of operands that are used as to simplify @@ -7008,7 +7153,7 @@ pipe_class vmovi_reg_imm128(vecX dst) NEON_FP : S3; %} -pipe_class vload_reg_mem64(vecD dst, vmem mem) +pipe_class vload_reg_mem64(vecD dst, vmem8 mem) %{ single_instruction; dst : S5(write); @@ -7017,7 +7162,7 @@ pipe_class vload_reg_mem64(vecD dst, vmem mem) NEON_FP : S3; %} -pipe_class vload_reg_mem128(vecX dst, vmem mem) +pipe_class vload_reg_mem128(vecX dst, vmem16 mem) %{ single_instruction; dst : S5(write); @@ -7026,7 +7171,7 @@ pipe_class vload_reg_mem128(vecX dst, vmem mem) NEON_FP : S3; %} -pipe_class vstore_reg_mem64(vecD src, vmem mem) +pipe_class vstore_reg_mem64(vecD src, vmem8 mem) %{ single_instruction; mem : ISS(read); @@ -7035,7 +7180,7 @@ pipe_class vstore_reg_mem64(vecD src, vmem mem) NEON_FP : S3; %} -pipe_class vstore_reg_mem128(vecD src, vmem mem) +pipe_class vstore_reg_mem128(vecD src, vmem16 mem) %{ single_instruction; mem : ISS(read); @@ -14919,7 +15064,7 @@ instruct tlsLoadP(thread_RegP dst) // ====================VECTOR INSTRUCTIONS===================================== // Load vector (32 bits) -instruct loadV4(vecD dst, vmem mem) +instruct loadV4(vecD dst, vmem4 mem) %{ predicate(n->as_LoadVector()->memory_size() == 4); match(Set dst (LoadVector mem)); @@ -14930,7 +15075,7 @@ instruct loadV4(vecD dst, vmem mem) %} // Load vector (64 bits) -instruct loadV8(vecD dst, vmem mem) +instruct loadV8(vecD dst, vmem8 mem) %{ predicate(n->as_LoadVector()->memory_size() == 8); match(Set dst (LoadVector mem)); @@ -14941,7 +15086,7 @@ instruct loadV8(vecD dst, vmem mem) %} // Load Vector (128 bits) -instruct loadV16(vecX dst, vmem mem) +instruct loadV16(vecX dst, vmem16 mem) %{ predicate(n->as_LoadVector()->memory_size() == 16); match(Set dst (LoadVector mem)); @@ -14952,7 +15097,7 @@ instruct loadV16(vecX dst, vmem mem) %} // Store Vector (32 bits) -instruct storeV4(vecD src, vmem mem) +instruct storeV4(vecD src, vmem4 mem) %{ predicate(n->as_StoreVector()->memory_size() == 4); match(Set mem (StoreVector mem src)); @@ -14963,7 +15108,7 @@ instruct storeV4(vecD src, vmem mem) %} // Store Vector (64 bits) -instruct storeV8(vecD src, vmem mem) +instruct storeV8(vecD src, vmem8 mem) %{ predicate(n->as_StoreVector()->memory_size() == 8); match(Set mem (StoreVector mem src)); @@ -14974,7 +15119,7 @@ instruct storeV8(vecD src, vmem mem) %} // Store Vector (128 bits) -instruct storeV16(vecX src, vmem mem) +instruct storeV16(vecX src, vmem16 mem) %{ predicate(n->as_StoreVector()->memory_size() == 16); match(Set mem (StoreVector mem src)); -- GitLab From 06645bc9d5b5fb253ac3e7cfbe694bcf63684a3c Mon Sep 17 00:00:00 2001 From: Tobias Hartmann Date: Thu, 28 Apr 2016 17:36:37 +0200 Subject: [PATCH 263/400] 6941938: Improve array equals intrinsic on SPARC Array equals intrinsic should do 8-byte comparison on SPARC. Reviewed-by: kvn, jrose, mgerdin, twisti --- .../src/cpu/sparc/vm/macroAssembler_sparc.cpp | 129 ++++++++---------- 1 file changed, 57 insertions(+), 72 deletions(-) diff --git a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp index 7c3ffae60d0..90ba2168eab 100644 --- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp @@ -4516,18 +4516,10 @@ void MacroAssembler::string_compare(Register str1, Register str2, } // Compare the rest of the characters - if (ae == StrIntrinsicNode::UU) { - lduh(str1, limit1, chr1); - } else { - ldub(str1, limit1, chr1); - } + load_sized_value(Address(str1, limit1), chr1, (ae == StrIntrinsicNode::UU) ? 2 : 1, false); bind(Lloop); - if (ae == StrIntrinsicNode::LL) { - ldub(str2, limit2, chr2); - } else { - lduh(str2, limit2, chr2); - } + load_sized_value(Address(str2, limit2), chr2, (ae == StrIntrinsicNode::LL) ? 1 : 2, false); subcc(chr1, chr2, chr1); br(Assembler::notZero, false, Assembler::pt, Ldone); @@ -4539,11 +4531,7 @@ void MacroAssembler::string_compare(Register str1, Register str2, // annul LDUB if branch is not taken to prevent access past end of string br(Assembler::notZero, true, Assembler::pt, Lloop); - if (ae == StrIntrinsicNode::UU) { - delayed()->lduh(str1, limit2, chr1); - } else { - delayed()->ldub(str1, limit1, chr1); - } + delayed()->load_sized_value(Address(str1, limit1), chr1, (ae == StrIntrinsicNode::UU) ? 2 : 1, false); // If strings are equal up to min length, return the length difference. if (ae == StrIntrinsicNode::UU) { @@ -4563,23 +4551,24 @@ void MacroAssembler::string_compare(Register str1, Register str2, void MacroAssembler::array_equals(bool is_array_equ, Register ary1, Register ary2, Register limit, Register tmp, Register result, bool is_byte) { - Label Ldone, Lvector, Lloop; + Label Ldone, Lloop, Lremaining; assert_different_registers(ary1, ary2, limit, tmp, result); int length_offset = arrayOopDesc::length_offset_in_bytes(); int base_offset = arrayOopDesc::base_offset_in_bytes(is_byte ? T_BYTE : T_CHAR); + assert(base_offset % 8 == 0, "Base offset must be 8-byte aligned"); if (is_array_equ) { // return true if the same array cmp(ary1, ary2); brx(Assembler::equal, true, Assembler::pn, Ldone); - delayed()->add(G0, 1, result); // equal + delayed()->mov(1, result); // equal br_null(ary1, true, Assembler::pn, Ldone); - delayed()->mov(G0, result); // not equal + delayed()->clr(result); // not equal br_null(ary2, true, Assembler::pn, Ldone); - delayed()->mov(G0, result); // not equal + delayed()->clr(result); // not equal // load the lengths of arrays ld(Address(ary1, length_offset), limit); @@ -4588,81 +4577,77 @@ void MacroAssembler::array_equals(bool is_array_equ, Register ary1, Register ary // return false if the two arrays are not equal length cmp(limit, tmp); br(Assembler::notEqual, true, Assembler::pn, Ldone); - delayed()->mov(G0, result); // not equal + delayed()->clr(result); // not equal } cmp_zero_and_br(Assembler::zero, limit, Ldone, true, Assembler::pn); - delayed()->add(G0, 1, result); // zero-length arrays are equal + delayed()->mov(1, result); // zero-length arrays are equal if (is_array_equ) { // load array addresses add(ary1, base_offset, ary1); add(ary2, base_offset, ary2); + // set byte count + if (!is_byte) { + sll(limit, exact_log2(sizeof(jchar)), limit); + } } else { // We have no guarantee that on 64 bit the higher half of limit is 0 signx(limit); } - if (is_byte) { - Label Lskip; - // check for trailing byte - andcc(limit, 0x1, tmp); - br(Assembler::zero, false, Assembler::pt, Lskip); - delayed()->nop(); - - // compare the trailing byte - sub(limit, sizeof(jbyte), limit); - ldub(ary1, limit, result); - ldub(ary2, limit, tmp); - cmp(result, tmp); - br(Assembler::notEqual, true, Assembler::pt, Ldone); - delayed()->mov(G0, result); // not equal - - // only one byte? - cmp_zero_and_br(zero, limit, Ldone, true, Assembler::pn); - delayed()->add(G0, 1, result); // zero-length arrays are equal - bind(Lskip); - } else if (is_array_equ) { - // set byte count - sll(limit, exact_log2(sizeof(jchar)), limit); - } - - // check for trailing character - andcc(limit, 0x2, tmp); - br(Assembler::zero, false, Assembler::pt, Lvector); - delayed()->nop(); - - // compare the trailing char - sub(limit, sizeof(jchar), limit); - lduh(ary1, limit, result); - lduh(ary2, limit, tmp); - cmp(result, tmp); - br(Assembler::notEqual, true, Assembler::pt, Ldone); - delayed()->mov(G0, result); // not equal - - // only one char? - cmp_zero_and_br(zero, limit, Ldone, true, Assembler::pn); - delayed()->add(G0, 1, result); // zero-length arrays are equal +#ifdef ASSERT + // Sanity check for doubleword (8-byte) alignment of ary1 and ary2. + // Guaranteed on 64-bit systems (see arrayOopDesc::header_size_in_bytes()). + Label Laligned; + or3(ary1, ary2, tmp); + andcc(tmp, 7, tmp); + br_null_short(tmp, Assembler::pn, Laligned); + STOP("First array element is not 8-byte aligned."); + should_not_reach_here(); + bind(Laligned); +#endif - // word by word compare, dont't need alignment check - bind(Lvector); // Shift ary1 and ary2 to the end of the arrays, negate limit add(ary1, limit, ary1); add(ary2, limit, ary2); neg(limit, limit); - lduw(ary1, limit, result); + // MAIN LOOP + // Load and compare array elements of size 'byte_width' until the elements are not + // equal or we reached the end of the arrays. If the size of the arrays is not a + // multiple of 'byte_width', we simply read over the end of the array, bail out and + // compare the remaining bytes below by skipping the garbage bytes. + ldx(ary1, limit, result); bind(Lloop); - lduw(ary2, limit, tmp); + ldx(ary2, limit, tmp); + inccc(limit, 8); + // Bail out if we reached the end (but still do the comparison) + br(Assembler::positive, false, Assembler::pn, Lremaining); + delayed()->cmp(result, tmp); + // Check equality of elements + brx(Assembler::equal, false, Assembler::pt, target(Lloop)); + delayed()->ldx(ary1, limit, result); + + ba(Ldone); + delayed()->clr(result); // not equal + + // TAIL COMPARISON + // We got here because we reached the end of the arrays. 'limit' is the number of + // garbage bytes we may have compared by reading over the end of the arrays. Shift + // out the garbage and compare the remaining elements. + bind(Lremaining); + // Optimistic shortcut: elements potentially including garbage are equal + brx(Assembler::equal, true, Assembler::pt, target(Ldone)); + delayed()->mov(1, result); // equal + // Shift 'limit' bytes to the right and compare + sll(limit, 3, limit); // bytes to bits + srlx(result, limit, result); + srlx(tmp, limit, tmp); cmp(result, tmp); - br(Assembler::notEqual, true, Assembler::pt, Ldone); - delayed()->mov(G0, result); // not equal - inccc(limit, 2*sizeof(jchar)); - // annul LDUW if branch is not taken to prevent access past end of array - br(Assembler::notZero, true, Assembler::pt, Lloop); - delayed()->lduw(ary1, limit, result); // hoisted + clr(result); + movcc(Assembler::equal, false, xcc, 1, result); - add(G0, 1, result); // equals bind(Ldone); } -- GitLab From 41258ea37a7be4cb9922e4f4b30bbd8c09dc56da Mon Sep 17 00:00:00 2001 From: Ed Nevill Date: Thu, 28 Apr 2016 13:26:29 +0000 Subject: [PATCH 264/400] 8155617: aarch64: ClearArray does not use DC ZVA Implement block zero using DC ZVA Co-authored-by: Long Chen Reviewed-by: aph --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 3 +- .../src/cpu/aarch64/vm/assembler_aarch64.hpp | 24 +++- .../src/cpu/aarch64/vm/globals_aarch64.hpp | 5 + .../cpu/aarch64/vm/macroAssembler_aarch64.cpp | 114 +++++++++++++++--- .../cpu/aarch64/vm/macroAssembler_aarch64.hpp | 12 +- .../cpu/aarch64/vm/stubGenerator_aarch64.cpp | 55 ++++++++- .../cpu/aarch64/vm/stubRoutines_aarch64.cpp | 1 + .../cpu/aarch64/vm/stubRoutines_aarch64.hpp | 7 ++ .../src/cpu/aarch64/vm/vm_version_aarch64.cpp | 24 +++- .../src/cpu/aarch64/vm/vm_version_aarch64.hpp | 15 +++ 10 files changed, 234 insertions(+), 26 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index 07deb94ea70..8b4905d4bae 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -13470,9 +13470,10 @@ instruct clearArray_reg_reg(iRegL_R11 cnt, iRegP_R10 base, Universe dummy, rFlag ins_pipe(pipe_class_memory); %} -instruct clearArray_imm_reg(immL cnt, iRegP base, Universe dummy, rFlagsReg cr) +instruct clearArray_imm_reg(immL cnt, iRegP_R10 base, iRegL_R11 tmp, Universe dummy, rFlagsReg cr) %{ match(Set dummy (ClearArray cnt base)); + effect(USE_KILL base, TEMP tmp); ins_cost(4 * INSN_COST); format %{ "ClearArray $cnt, $base" %} diff --git a/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp index 965a5c8072f..adfb74d7d23 100644 --- a/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/assembler_aarch64.hpp @@ -1032,12 +1032,28 @@ public: system(0b00, 0b011, 0b00011, SY, 0b110); } - void dc(Register Rt) { - system(0b01, 0b011, 0b0111, 0b1011, 0b001, Rt); + void sys(int op1, int CRn, int CRm, int op2, + Register rt = (Register)0b11111) { + system(0b01, op1, CRn, CRm, op2, rt); } - void ic(Register Rt) { - system(0b01, 0b011, 0b0111, 0b0101, 0b001, Rt); + // Only implement operations accessible from EL0 or higher, i.e., + // op1 CRn CRm op2 + // IC IVAU 3 7 5 1 + // DC CVAC 3 7 10 1 + // DC CVAU 3 7 11 1 + // DC CIVAC 3 7 14 1 + // DC ZVA 3 7 4 1 + // So only deal with the CRm field. + enum icache_maintenance {IVAU = 0b0101}; + enum dcache_maintenance {CVAC = 0b1010, CVAU = 0b1011, CIVAC = 0b1110, ZVA = 0b100}; + + void dc(dcache_maintenance cm, Register Rt) { + sys(0b011, 0b0111, cm, 0b001, Rt); + } + + void ic(icache_maintenance cm, Register Rt) { + sys(0b011, 0b0111, cm, 0b001, Rt); } // A more convenient access to dmb for our purposes diff --git a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp index 5bd7424d4b8..e54b3a5ee7b 100644 --- a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp @@ -132,6 +132,11 @@ define_pd_global(intx, InlineSmallCode, 1000); "Use SIMD instructions in generated memory move code") \ product(bool, UseLSE, false, \ "Use LSE instructions") \ + product(bool, UseBlockZeroing, true, \ + "Use DC ZVA for block zeroing") \ + product(intx, BlockZeroingLowLimit, 256, \ + "Minimum size in bytes when block zeroing will be used") \ + range(1, max_jint) \ product(bool, TraceTraps, false, "Trace all traps the signal handler") #endif diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp index cf823e4a020..72aad0fd59a 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp @@ -4670,24 +4670,35 @@ void MacroAssembler::arrays_equals(Register a1, Register a2, BLOCK_COMMENT(is_string ? "} string_equals" : "} array_equals"); } -// base: Address of a buffer to be zeroed, 8 bytes aligned. -// cnt: Count in 8-byte unit. + +// base: Address of a buffer to be zeroed, 8 bytes aligned. +// cnt: Count in HeapWords. +// is_large: True when 'cnt' is known to be >= BlockZeroingLowLimit. void MacroAssembler::zero_words(Register base, Register cnt) { - fill_words(base, cnt, zr); + if (UseBlockZeroing) { + block_zero(base, cnt); + } else { + fill_words(base, cnt, zr); + } } -// base: Address of a buffer to be zeroed, 8 bytes aligned. -// cnt: Immediate count in 8-byte unit. +// r10 = base: Address of a buffer to be zeroed, 8 bytes aligned. +// cnt: Immediate count in HeapWords. +// r11 = tmp: For use as cnt if we need to call out #define ShortArraySize (18 * BytesPerLong) void MacroAssembler::zero_words(Register base, u_int64_t cnt) { + Register tmp = r11; int i = cnt & 1; // store any odd word to start if (i) str(zr, Address(base)); if (cnt <= ShortArraySize / BytesPerLong) { for (; i < (int)cnt; i += 2) stp(zr, zr, Address(base, i * wordSize)); + } else if (UseBlockZeroing && cnt >= (u_int64_t)(BlockZeroingLowLimit >> LogBytesPerWord)) { + mov(tmp, cnt); + block_zero(base, tmp, true); } else { const int unroll = 4; // Number of stp(zr, zr) instructions we'll unroll int remainder = cnt % (2 * unroll); @@ -4739,24 +4750,95 @@ void MacroAssembler::fill_words(Register base, Register cnt, Register value) assert_different_registers(base, cnt, value, rscratch1, rscratch2); - Label entry, loop; - const int unroll = 8; // Number of str instructions we'll unroll + Label fini, skip, entry, loop; + const int unroll = 8; // Number of stp instructions we'll unroll - andr(rscratch1, cnt, unroll - 1); // tmp1 = cnt % unroll - cbz(rscratch1, entry); - sub(cnt, cnt, rscratch1); // cnt -= tmp1 - // base always points to the end of the region we're about to fill + cbz(cnt, fini); + tbz(base, 3, skip); + str(value, Address(post(base, 8))); + sub(cnt, cnt, 1); + bind(skip); + + andr(rscratch1, cnt, (unroll-1) * 2); + sub(cnt, cnt, rscratch1); add(base, base, rscratch1, Assembler::LSL, 3); adr(rscratch2, entry); - sub(rscratch2, rscratch2, rscratch1, Assembler::LSL, 2); + sub(rscratch2, rscratch2, rscratch1, Assembler::LSL, 1); br(rscratch2); + bind(loop); - add(base, base, unroll * 8); - sub(cnt, cnt, unroll); for (int i = -unroll; i < 0; i++) - str(value, Address(base, i * 8)); + stp(value, value, Address(base, i * 16)); bind(entry); - cbnz(cnt, loop); + subs(cnt, cnt, unroll * 2); + add(base, base, unroll * 16); + br(Assembler::GE, loop); + + tbz(cnt, 0, fini); + str(value, Address(base, -unroll * 16)); + bind(fini); +} + +// Use DC ZVA to do fast zeroing. +// base: Address of a buffer to be zeroed, 8 bytes aligned. +// cnt: Count in HeapWords. +// is_large: True when 'cnt' is known to be >= BlockZeroingLowLimit. +void MacroAssembler::block_zero(Register base, Register cnt, bool is_large) +{ + Label small; + Label store_pair, loop_store_pair, done; + Label base_aligned; + + assert_different_registers(base, cnt, rscratch1); + + Register tmp = rscratch1; + Register tmp2 = rscratch2; + int zva_length = VM_Version::zva_length(); + + // Ensure ZVA length can be divided by 16. This is required by + // the subsequent operations. + assert (zva_length % 16 == 0, "Unexpected ZVA Length"); + + if (!is_large) cbz(cnt, done); + tbz(base, 3, base_aligned); + str(zr, Address(post(base, 8))); + sub(cnt, cnt, 1); + bind(base_aligned); + + // Ensure count >= zva_length * 2 so that it still deserves a zva after + // alignment. + if (!is_large || !(BlockZeroingLowLimit >= zva_length * 2)) { + int low_limit = MAX2(zva_length * 2, (int)BlockZeroingLowLimit); + cmp(cnt, low_limit >> 3); + br(Assembler::LT, small); + } + + far_call(StubRoutines::aarch64::get_zero_longs()); + + bind(small); + + const int unroll = 8; // Number of stp instructions we'll unroll + Label small_loop, small_table_end; + + andr(tmp, cnt, (unroll-1) * 2); + sub(cnt, cnt, tmp); + add(base, base, tmp, Assembler::LSL, 3); + adr(tmp2, small_table_end); + sub(tmp2, tmp2, tmp, Assembler::LSL, 1); + br(tmp2); + + bind(small_loop); + for (int i = -unroll; i < 0; i++) + stp(zr, zr, Address(base, i * 16)); + bind(small_table_end); + subs(cnt, cnt, unroll * 2); + add(base, base, unroll * 16); + br(Assembler::GE, small_loop); + + tbz(cnt, 0, done); + str(zr, Address(base, -unroll * 16)); + + bind(done); } // encode char[] to byte[] in ISO_8859_1 diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp index 4a16a2032f8..fd84688fd78 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.hpp @@ -536,6 +536,15 @@ public: msr(0b011, 0b0100, 0b0100, 0b001, zr); } + // DCZID_EL0: op1 == 011 + // CRn == 0000 + // CRm == 0000 + // op2 == 111 + inline void get_dczid_el0(Register reg) + { + mrs(0b011, 0b0000, 0b0000, 0b111, reg); + } + // idiv variant which deals with MINLONG as dividend and -1 as divisor int corrected_idivl(Register result, Register ra, Register rb, bool want_remainder, Register tmp = rscratch1); @@ -1185,8 +1194,9 @@ public: int elem_size, bool is_string); void fill_words(Register base, Register cnt, Register value); - void zero_words(Register base, Register cnt); void zero_words(Register base, u_int64_t cnt); + void zero_words(Register base, Register cnt); + void block_zero(Register base, Register cnt, bool is_large = false); void encode_iso_array(Register src, Register dst, Register len, Register result, diff --git a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp index b6fa5ec9986..5e838e93d02 100644 --- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp @@ -719,6 +719,43 @@ class StubGenerator: public StubCodeGenerator { } } + address generate_zero_longs(Register base, Register cnt) { + Register tmp = rscratch1; + Register tmp2 = rscratch2; + int zva_length = VM_Version::zva_length(); + Label initial_table_end, loop_zva; + + __ align(CodeEntryAlignment); + StubCodeMark mark(this, "StubRoutines", "zero_longs"); + address start = __ pc(); + + // Align base with ZVA length. + __ neg(tmp, base); + __ andr(tmp, tmp, zva_length - 1); + + // tmp: the number of bytes to be filled to align the base with ZVA length. + __ add(base, base, tmp); + __ sub(cnt, cnt, tmp, Assembler::ASR, 3); + __ adr(tmp2, initial_table_end); + __ sub(tmp2, tmp2, tmp, Assembler::LSR, 2); + __ br(tmp2); + + for (int i = -zva_length + 16; i < 0; i += 16) + __ stp(zr, zr, Address(base, i)); + __ bind(initial_table_end); + + __ sub(cnt, cnt, zva_length >> 3); + __ bind(loop_zva); + __ dc(Assembler::ZVA, base); + __ subs(cnt, cnt, zva_length >> 3); + __ add(base, base, zva_length); + __ br(Assembler::GE, loop_zva); + __ add(cnt, cnt, zva_length >> 3); // count not zeroed by DC ZVA + __ ret(lr); + + return start; + } + typedef enum { copy_forwards = 1, copy_backwards = -1 @@ -2104,7 +2141,21 @@ class StubGenerator: public StubCodeGenerator { __ lsrw(cnt_words, count, 3 - shift); // number of words __ bfi(value, value, 32, 32); // 32 bit -> 64 bit __ subw(count, count, cnt_words, Assembler::LSL, 3 - shift); - __ fill_words(to, cnt_words, value); + if (UseBlockZeroing) { + Label non_block_zeroing, rest; + // count >= BlockZeroingLowLimit && value == 0 + __ cmp(cnt_words, BlockZeroingLowLimit >> 3); + __ ccmp(value, 0 /* comparing value */, 0 /* NZCV */, Assembler::GE); + __ br(Assembler::NE, non_block_zeroing); + __ block_zero(to, cnt_words, true); + __ b(rest); + __ bind(non_block_zeroing); + __ fill_words(to, cnt_words, value); + __ bind(rest); + } + else { + __ fill_words(to, cnt_words, value); + } // Remaining count is less than 8 bytes. Fill it by a single store. // Note that the total length is no less than 8 bytes. @@ -2163,6 +2214,8 @@ class StubGenerator: public StubCodeGenerator { generate_copy_longs(copy_f, r0, r1, rscratch2, copy_forwards); generate_copy_longs(copy_b, r0, r1, rscratch2, copy_backwards); + StubRoutines::aarch64::_zero_longs = generate_zero_longs(r10, r11); + //*** jbyte // Always need aligned and unaligned versions StubRoutines::_jbyte_disjoint_arraycopy = generate_disjoint_byte_copy(false, &entry, diff --git a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp index e7d7f5bce78..f5727ee03c6 100644 --- a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.cpp @@ -43,6 +43,7 @@ address StubRoutines::aarch64::_float_sign_mask = NULL; address StubRoutines::aarch64::_float_sign_flip = NULL; address StubRoutines::aarch64::_double_sign_mask = NULL; address StubRoutines::aarch64::_double_sign_flip = NULL; +address StubRoutines::aarch64::_zero_longs = NULL; /** * crc_table[] from jdk/src/share/native/java/util/zip/zlib-1.2.5/crc32.h diff --git a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp index 8764ebf7286..1355a6836df 100644 --- a/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/stubRoutines_aarch64.hpp @@ -61,6 +61,8 @@ class aarch64 { static address _double_sign_mask; static address _double_sign_flip; + static address _zero_longs; + public: static address get_previous_fp_entry() @@ -113,6 +115,11 @@ class aarch64 { return _double_sign_flip; } + static address get_zero_longs() + { + return _zero_longs; + } + private: static juint _crc_table[]; diff --git a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp index 40275cabfa0..bf96f24d621 100644 --- a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.cpp @@ -71,6 +71,7 @@ int VM_Version::_model2; int VM_Version::_variant; int VM_Version::_revision; int VM_Version::_stepping; +VM_Version::PsrInfo VM_Version::_psr_info = { 0, }; static BufferBlob* stub_blob; static const int stub_size = 550; @@ -95,13 +96,16 @@ class VM_Version_StubGenerator: public StubCodeGenerator { __ c_stub_prolog(1, 0, MacroAssembler::ret_type_void); #endif - // void getPsrInfo(VM_Version::CpuidInfo* cpuid_info); + // void getPsrInfo(VM_Version::PsrInfo* psr_info); address entry = __ pc(); - // TODO : redefine fields in CpuidInfo and generate - // code to fill them in + __ enter(); + __ get_dczid_el0(rscratch1); + __ strw(rscratch1, Address(c_rarg0, in_bytes(VM_Version::dczid_el0_offset()))); + + __ leave(); __ ret(lr); # undef __ @@ -118,6 +122,8 @@ void VM_Version::get_processor_features() { _supports_atomic_getset8 = true; _supports_atomic_getadd8 = true; + getPsrInfo_stub(&_psr_info); + if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256); if (FLAG_IS_DEFAULT(AllocatePrefetchStepSize)) @@ -285,6 +291,18 @@ void VM_Version::get_processor_features() { FLAG_SET_DEFAULT(UseGHASHIntrinsics, false); } + if (is_zva_enabled()) { + if (FLAG_IS_DEFAULT(UseBlockZeroing)) { + FLAG_SET_DEFAULT(UseBlockZeroing, true); + } + if (FLAG_IS_DEFAULT(BlockZeroingLowLimit)) { + FLAG_SET_DEFAULT(BlockZeroingLowLimit, 4 * VM_Version::zva_length()); + } + } else if (UseBlockZeroing) { + warning("DC ZVA is not available on this CPU"); + FLAG_SET_DEFAULT(UseBlockZeroing, false); + } + // This machine allows unaligned memory accesses if (FLAG_IS_DEFAULT(UseUnalignedAccesses)) { FLAG_SET_DEFAULT(UseUnalignedAccesses, true); diff --git a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.hpp index 2ed5e7ef9bd..25f5b929b3b 100644 --- a/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/vm_version_aarch64.hpp @@ -40,6 +40,10 @@ protected: static int _revision; static int _stepping; + struct PsrInfo { + uint32_t dczid_el0; + }; + static PsrInfo _psr_info; static void get_processor_features(); public: @@ -83,6 +87,17 @@ public: static int cpu_model2() { return _model2; } static int cpu_variant() { return _variant; } static int cpu_revision() { return _revision; } + static ByteSize dczid_el0_offset() { return byte_offset_of(PsrInfo, dczid_el0); } + static bool is_zva_enabled() { + // Check the DZP bit (bit 4) of dczid_el0 is zero + // and block size (bit 0~3) is not zero. + return ((_psr_info.dczid_el0 & 0x10) == 0 && + (_psr_info.dczid_el0 & 0xf) != 0); + } + static int zva_length() { + assert(is_zva_enabled(), "ZVA not available"); + return 4 << (_psr_info.dczid_el0 & 0xf); + } }; #endif // CPU_AARCH64_VM_VM_VERSION_AARCH64_HPP -- GitLab From 413417522f392960570e4982fd35a30843ea65dc Mon Sep 17 00:00:00 2001 From: Zoltan Majo Date: Fri, 29 Apr 2016 08:32:42 +0200 Subject: [PATCH 265/400] 8153340: Disallow misconfiguration and improve the consistency of allocation prefetching Improve allocation prefetching. Reviewed-by: kvn --- hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp | 45 ++++++-------- .../classes/sun/jvm/hotspot/runtime/VM.java | 3 +- .../vm/gc/shared/threadLocalAllocBuffer.cpp | 18 ++++++ .../vm/gc/shared/threadLocalAllocBuffer.hpp | 7 ++- hotspot/src/share/vm/opto/macro.cpp | 17 ++--- .../commandLineFlagConstraintsCompiler.cpp | 62 +++++-------------- hotspot/src/share/vm/runtime/globals.hpp | 8 +-- hotspot/src/share/vm/runtime/vmStructs.cpp | 2 +- hotspot/src/share/vm/runtime/vm_version.cpp | 1 - hotspot/src/share/vm/runtime/vm_version.hpp | 7 --- .../TestOptionsWithRanges.java | 7 --- 11 files changed, 73 insertions(+), 104 deletions(-) diff --git a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp index 72ae7883ba6..f01a5bc867d 100644 --- a/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/vm_version_sparc.cpp @@ -49,9 +49,11 @@ void VM_Version::initialize() { AllocatePrefetchDistance = allocate_prefetch_distance(); AllocatePrefetchStyle = allocate_prefetch_style(); - if (AllocatePrefetchStyle == 3 && !has_blk_init()) { - warning("BIS instructions are not available on this CPU"); - FLAG_SET_DEFAULT(AllocatePrefetchStyle, 1); + if (!has_blk_init()) { + if (AllocatePrefetchInstr == 1) { + warning("BIS instructions required for AllocatePrefetchInstr 1 unavailable"); + FLAG_SET_DEFAULT(AllocatePrefetchInstr, 0); + } } UseSSE = 0; // Only on x86 and x64 @@ -88,11 +90,13 @@ void VM_Version::initialize() { if (has_blk_init() && UseTLAB && FLAG_IS_DEFAULT(AllocatePrefetchInstr)) { // Use BIS instruction for TLAB allocation prefetch. - FLAG_SET_ERGO(intx, AllocatePrefetchInstr, 1); - if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) { - FLAG_SET_ERGO(intx, AllocatePrefetchStyle, 3); - } - if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) { + FLAG_SET_DEFAULT(AllocatePrefetchInstr, 1); + } + if (FLAG_IS_DEFAULT(AllocatePrefetchDistance)) { + if (AllocatePrefetchInstr == 0) { + // Use different prefetch distance without BIS + FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256); + } else { // Use smaller prefetch distance with BIS FLAG_SET_DEFAULT(AllocatePrefetchDistance, 64); } @@ -107,25 +111,14 @@ void VM_Version::initialize() { FLAG_SET_ERGO(intx, AllocateInstancePrefetchLines, AllocateInstancePrefetchLines*2); } } - if (AllocatePrefetchStyle != 3 && FLAG_IS_DEFAULT(AllocatePrefetchDistance)) { - // Use different prefetch distance without BIS - FLAG_SET_DEFAULT(AllocatePrefetchDistance, 256); - } - if (AllocatePrefetchInstr == 1) { - // Need extra space at the end of TLAB for BIS, otherwise prefetching - // instructions will fault (due to accessing memory outside of heap). - // The amount of space is the max of the number of lines to - // prefetch for array and for instance allocations. (Extra space must be - // reserved to accomodate both types of allocations.) - - // +1 for rounding up to next cache line, +1 to be safe - int lines = MAX2(AllocatePrefetchLines, AllocateInstancePrefetchLines) + 2; - int step_size = AllocatePrefetchStepSize; - int distance = AllocatePrefetchDistance; - _reserve_for_allocation_prefetch = (distance + step_size*lines)/(int)HeapWordSize; - } } -#endif + + if (AllocatePrefetchInstr == 1) { + // Use allocation prefetch style 3 because BIS instructions + // require aligned memory addresses. + FLAG_SET_DEFAULT(AllocatePrefetchStyle, 3); + } +#endif /* COMPILER2 */ } // Use hardware population count instruction if available. diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java index 09bb426cfb3..8ba99953027 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java @@ -324,8 +324,9 @@ public class VM { Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue(); vmInternalInfo = CStringUtilities.getString(vmInternalInfoAddr); + Type threadLocalAllocBuffer = db.lookupType("ThreadLocalAllocBuffer"); CIntegerType intType = (CIntegerType) db.lookupType("int"); - CIntegerField reserveForAllocationPrefetchField = vmVersion.getCIntegerField("_reserve_for_allocation_prefetch"); + CIntegerField reserveForAllocationPrefetchField = threadLocalAllocBuffer.getCIntegerField("_reserve_for_allocation_prefetch"); reserveForAllocationPrefetch = (int)reserveForAllocationPrefetchField.getCInteger(intType); } catch (Exception exp) { throw new RuntimeException("can't determine target's VM version : " + exp.getMessage()); diff --git a/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.cpp b/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.cpp index 0c975d1e269..a9fb53f48bb 100644 --- a/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.cpp +++ b/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.cpp @@ -36,6 +36,7 @@ // static member initialization size_t ThreadLocalAllocBuffer::_max_size = 0; +int ThreadLocalAllocBuffer::_reserve_for_allocation_prefetch = 0; unsigned ThreadLocalAllocBuffer::_target_refills = 0; GlobalTLABStats* ThreadLocalAllocBuffer::_global_stats = NULL; @@ -215,6 +216,23 @@ void ThreadLocalAllocBuffer::startup_initialization() { _global_stats = new GlobalTLABStats(); + // Need extra space at the end of TLAB, otherwise prefetching + // instructions will fault (due to accessing memory outside of heap). + // The amount of space is the max of the number of lines to + // prefetch for array and for instance allocations. (Extra space must be + // reserved to accommodate both types of allocations.) + // + // Only SPARC-specific BIS instructions are known to fault. (Those + // instructions are generated if AllocatePrefetchStyle==3 and + // AllocatePrefetchInstr==1). To be on the safe side, however, + // extra space is reserved for all combinations of + // AllocatePrefetchStyle and AllocatePrefetchInstr. + + // +1 for rounding up to next cache line, +1 to be safe + int lines = MAX2(AllocatePrefetchLines, AllocateInstancePrefetchLines) + 2; + _reserve_for_allocation_prefetch = (AllocatePrefetchDistance + AllocatePrefetchStepSize * lines) / + (int)HeapWordSize; + // During jvm startup, the main (primordial) thread is initialized // before the heap is initialized. So reinitialize it now. guarantee(Thread::current()->is_Java_thread(), "tlab initialization thread not Java thread"); diff --git a/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp b/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp index 2af19576191..6a5ab498bf6 100644 --- a/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp +++ b/hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp @@ -49,8 +49,9 @@ private: size_t _refill_waste_limit; // hold onto tlab if free() is larger than this size_t _allocated_before_last_gc; // total bytes allocated up until the last gc - static size_t _max_size; // maximum size of any TLAB - static unsigned _target_refills; // expected number of refills between GCs + static size_t _max_size; // maximum size of any TLAB + static int _reserve_for_allocation_prefetch; // Reserve at the end of the TLAB + static unsigned _target_refills; // expected number of refills between GCs unsigned _number_of_refills; unsigned _fast_refill_waste; @@ -129,7 +130,7 @@ public: // Reserve space at the end of TLAB static size_t end_reserve() { int reserve_size = typeArrayOopDesc::header_size(T_INT); - return MAX2(reserve_size, VM_Version::reserve_for_allocation_prefetch()); + return MAX2(reserve_size, _reserve_for_allocation_prefetch); } static size_t alignment_reserve() { return align_object_size(end_reserve()); } static size_t alignment_reserve_in_bytes() { return alignment_reserve() * HeapWordSize; } diff --git a/hotspot/src/share/vm/opto/macro.cpp b/hotspot/src/share/vm/opto/macro.cpp index f67f8ca218d..106257aae5b 100644 --- a/hotspot/src/share/vm/opto/macro.cpp +++ b/hotspot/src/share/vm/opto/macro.cpp @@ -1897,7 +1897,7 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, Node *prefetch_adr; Node *prefetch; - uint lines = AllocatePrefetchDistance / AllocatePrefetchStepSize; + uint lines = (length != NULL) ? AllocatePrefetchLines : AllocateInstancePrefetchLines; uint step_size = AllocatePrefetchStepSize; uint distance = 0; @@ -1926,12 +1926,8 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, contended_phi_rawmem = pf_phi_rawmem; i_o = pf_phi_abio; } else if( UseTLAB && AllocatePrefetchStyle == 3 ) { - // Insert a prefetch for each allocation. - // This code is used for Sparc with BIS. - Node *pf_region = new RegionNode(3); - Node *pf_phi_rawmem = new PhiNode( pf_region, Type::MEMORY, - TypeRawPtr::BOTTOM ); - transform_later(pf_region); + // Insert a prefetch instruction for each allocation. + // This code is used for SPARC with BIS. // Generate several prefetch instructions. uint lines = (length != NULL) ? AllocatePrefetchLines : AllocateInstancePrefetchLines; @@ -1940,10 +1936,15 @@ Node* PhaseMacroExpand::prefetch_allocation(Node* i_o, Node*& needgc_false, // Next cache address. Node *cache_adr = new AddPNode(old_eden_top, old_eden_top, - _igvn.MakeConX(distance)); + _igvn.MakeConX(step_size + distance)); transform_later(cache_adr); cache_adr = new CastP2XNode(needgc_false, cache_adr); transform_later(cache_adr); + // For BIS instructions to be emitted, the address must be aligned at cache line size. + // (The VM sets AllocatePrefetchStepSize to the cache line size, unless a value is + // specified at the command line.) If the address is not aligned at cache line size + // boundary, a standard store instruction is triggered (instead of the BIS). For the + // latter, 8-byte alignment is necessary. Node* mask = _igvn.MakeConX(~(intptr_t)(step_size-1)); cache_adr = new AndXNode(cache_adr, mask); transform_later(cache_adr); diff --git a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp index bfadc319516..f3ab445a2a8 100644 --- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp +++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintsCompiler.cpp @@ -90,16 +90,29 @@ Flag::Error CICompilerCountConstraintFunc(intx value, bool verbose) { } Flag::Error AllocatePrefetchDistanceConstraintFunc(intx value, bool verbose) { - if (value < 0) { + if (value < 0 || value > 512) { CommandLineError::print(verbose, - "Unable to determine system-specific value for AllocatePrefetchDistance. " - "Please provide appropriate value, if unsure, use 0 to disable prefetching\n"); + "AllocatePrefetchDistance (" INTX_FORMAT ") must be " + "between 0 and " INTX_FORMAT "\n", + AllocatePrefetchDistance, 512); return Flag::VIOLATES_CONSTRAINT; } return Flag::SUCCESS; } +Flag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) { + if (AllocatePrefetchStyle == 3) { + if (value % wordSize != 0) { + CommandLineError::print(verbose, + "AllocatePrefetchStepSize (" INTX_FORMAT ") must be multiple of %d\n", + value, wordSize); + return Flag::VIOLATES_CONSTRAINT; + } + } + return Flag::SUCCESS; +} + Flag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) { intx max_value = max_intx; #if defined(SPARC) @@ -117,49 +130,6 @@ Flag::Error AllocatePrefetchInstrConstraintFunc(intx value, bool verbose) { return Flag::SUCCESS; } -Flag::Error AllocatePrefetchStepSizeConstraintFunc(intx value, bool verbose) { - intx max_value = 512; - if (value < 1 || value > max_value) { - CommandLineError::print(verbose, - "AllocatePrefetchStepSize (" INTX_FORMAT ") " - "must be between 1 and %d\n", - AllocatePrefetchStepSize, - max_value); - return Flag::VIOLATES_CONSTRAINT; - } - - if (AllocatePrefetchDistance % AllocatePrefetchStepSize != 0) { - CommandLineError::print(verbose, - "AllocatePrefetchDistance (" INTX_FORMAT ") " - "%% AllocatePrefetchStepSize (" INTX_FORMAT ") " - "= " INTX_FORMAT " " - "must be 0\n", - AllocatePrefetchDistance, AllocatePrefetchStepSize, - AllocatePrefetchDistance % AllocatePrefetchStepSize); - return Flag::VIOLATES_CONSTRAINT; - } - - /* The limit of 64 for the quotient of AllocatePrefetchDistance and AllocatePrefetchSize - * originates from the limit of 64 for AllocatePrefetchLines/AllocateInstancePrefetchLines. - * If AllocatePrefetchStyle == 2, the quotient from above is used in PhaseMacroExpand::prefetch_allocation() - * to determine the number of lines to prefetch. For other values of AllocatePrefetchStyle, - * AllocatePrefetchDistance and AllocatePrefetchSize is used. For consistency, all these - * quantities must have the same limit (64 in this case). - */ - if (AllocatePrefetchDistance / AllocatePrefetchStepSize > 64) { - CommandLineError::print(verbose, - "AllocatePrefetchDistance (" INTX_FORMAT ") too large or " - "AllocatePrefetchStepSize (" INTX_FORMAT ") too small; " - "try decreasing/increasing values so that " - "AllocatePrefetchDistance / AllocatePrefetchStepSize <= 64\n", - AllocatePrefetchDistance, AllocatePrefetchStepSize, - AllocatePrefetchDistance % AllocatePrefetchStepSize); - return Flag::VIOLATES_CONSTRAINT; - } - - return Flag::SUCCESS; -} - Flag::Error CompileThresholdConstraintFunc(intx value, bool verbose) { if (value < 0 || value > INT_MAX >> InvocationCounter::count_shift) { CommandLineError::print(verbose, diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index fe2d2e615f0..b01db75ad44 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -2901,9 +2901,9 @@ public: \ product(intx, AllocatePrefetchStyle, 1, \ "0 = no prefetch, " \ - "1 = prefetch instructions for each allocation, " \ + "1 = generate prefetch instructions for each allocation, " \ "2 = use TLAB watermark to gate allocation prefetch, " \ - "3 = use BIS instruction on Sparc for allocation prefetch") \ + "3 = generate one prefetch instruction per cache line") \ range(0, 3) \ \ product(intx, AllocatePrefetchDistance, -1, \ @@ -2926,8 +2926,8 @@ public: constraint(AllocatePrefetchStepSizeConstraintFunc,AfterMemoryInit)\ \ product(intx, AllocatePrefetchInstr, 0, \ - "Prefetch instruction to prefetch ahead of allocation pointer") \ - constraint(AllocatePrefetchInstrConstraintFunc, AfterErgo) \ + "Select instruction to prefetch ahead of allocation pointer") \ + constraint(AllocatePrefetchInstrConstraintFunc, AfterMemoryInit) \ \ /* deoptimization */ \ develop(bool, TraceDeoptimization, false, \ diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index da0aca7f6bc..6552ab0fe8d 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -600,6 +600,7 @@ typedef CompactHashtable SymbolCompactHashTable; nonstatic_field(ThreadLocalAllocBuffer, _pf_top, HeapWord*) \ nonstatic_field(ThreadLocalAllocBuffer, _desired_size, size_t) \ nonstatic_field(ThreadLocalAllocBuffer, _refill_waste_limit, size_t) \ + static_field(ThreadLocalAllocBuffer, _reserve_for_allocation_prefetch, int) \ static_field(ThreadLocalAllocBuffer, _target_refills, unsigned) \ nonstatic_field(ThreadLocalAllocBuffer, _number_of_refills, unsigned) \ nonstatic_field(ThreadLocalAllocBuffer, _fast_refill_waste, unsigned) \ @@ -1318,7 +1319,6 @@ typedef CompactHashtable SymbolCompactHashTable; static_field(Abstract_VM_Version, _vm_minor_version, int) \ static_field(Abstract_VM_Version, _vm_security_version, int) \ static_field(Abstract_VM_Version, _vm_build_number, int) \ - static_field(Abstract_VM_Version, _reserve_for_allocation_prefetch, int) \ \ static_field(JDK_Version, _current, JDK_Version) \ nonstatic_field(JDK_Version, _major, unsigned char) \ diff --git a/hotspot/src/share/vm/runtime/vm_version.cpp b/hotspot/src/share/vm/runtime/vm_version.cpp index c36098a31f7..310a5076a7c 100644 --- a/hotspot/src/share/vm/runtime/vm_version.cpp +++ b/hotspot/src/share/vm/runtime/vm_version.cpp @@ -43,7 +43,6 @@ bool Abstract_VM_Version::_supports_atomic_getadd4 = false; bool Abstract_VM_Version::_supports_atomic_getadd8 = false; unsigned int Abstract_VM_Version::_logical_processors_per_package = 1U; unsigned int Abstract_VM_Version::_L1_data_cache_line_size = 0; -int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0; #ifndef HOTSPOT_VERSION_STRING #error HOTSPOT_VERSION_STRING must be defined diff --git a/hotspot/src/share/vm/runtime/vm_version.hpp b/hotspot/src/share/vm/runtime/vm_version.hpp index 50e4b616d34..a9e57338af5 100644 --- a/hotspot/src/share/vm/runtime/vm_version.hpp +++ b/hotspot/src/share/vm/runtime/vm_version.hpp @@ -57,7 +57,6 @@ class Abstract_VM_Version: AllStatic { static int _vm_build_number; static unsigned int _parallel_worker_threads; static bool _parallel_worker_threads_initialized; - static int _reserve_for_allocation_prefetch; static unsigned int nof_parallel_worker_threads(unsigned int num, unsigned int dem, @@ -139,12 +138,6 @@ class Abstract_VM_Version: AllStatic { return _L1_data_cache_line_size; } - // Need a space at the end of TLAB for prefetch instructions - // which may fault when accessing memory outside of heap. - static int reserve_for_allocation_prefetch() { - return _reserve_for_allocation_prefetch; - } - // ARCH specific policy for the BiasedLocking static bool use_biased_locking() { return true; } diff --git a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java index e6ec4c5ea8d..890ac26463d 100644 --- a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java +++ b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java @@ -89,13 +89,6 @@ public class TestOptionsWithRanges { */ excludeTestMaxRange("CICompilerCount"); - /* - * JDK-8153340 - * Temporary exclude AllocatePrefetchDistance option from testing - */ - excludeTestRange("AllocatePrefetchDistance"); - - /* * JDK-8136766 * Temporarily remove ThreadStackSize from testing because Windows can set it to 0 -- GitLab From 528bf589fd0d26562b53543516595a26a042b9de Mon Sep 17 00:00:00 2001 From: Zoltan Majo Date: Fri, 29 Apr 2016 14:32:19 +0200 Subject: [PATCH 266/400] 8155653: TestVectorUnalignedOffset.java not pushed with 8155612 Add missing test. Reviewed-by: aph, adinn --- .../TestVectorUnalignedOffset.java | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 hotspot/test/compiler/vectorization/TestVectorUnalignedOffset.java diff --git a/hotspot/test/compiler/vectorization/TestVectorUnalignedOffset.java b/hotspot/test/compiler/vectorization/TestVectorUnalignedOffset.java new file mode 100644 index 00000000000..081a6d9f8b8 --- /dev/null +++ b/hotspot/test/compiler/vectorization/TestVectorUnalignedOffset.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2016, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8155612 + * @summary Aarch64: vector nodes need to support misaligned offset + * @run main/othervm -XX:-BackgroundCompilation TestVectorUnalignedOffset + * + */ + + +public class TestVectorUnalignedOffset { + + static void test1(int[] src_array, int[] dst_array, int l) { + for (int i = 0; i < l; i++) { + dst_array[i + 250] = src_array[i + 250]; + } + } + + static void test2(byte[] src_array, byte[] dst_array, int l) { + for (int i = 0; i < l; i++) { + dst_array[i + 250] = src_array[i + 250]; + } + } + + static public void main(String[] args) { + int[] int_array = new int[1000]; + byte[] byte_array = new byte[1000]; + for (int i = 0; i < 20000; i++) { + test1(int_array, int_array, int_array.length - 250); + test2(byte_array, byte_array, byte_array.length - 250); + } + } +} -- GitLab From f1eeebc17eab1062dbd0a955d0dd270ba5c2d570 Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Fri, 29 Apr 2016 12:56:27 -0700 Subject: [PATCH 267/400] 8154483: update IGV with improvements from Graal Reviewed-by: kvn --- .../hotspot/igv/coordinator/FolderNode.java | 14 +- .../igv/coordinator/OutlineTopComponent.java | 4 +- .../igv/coordinator/actions/ImportAction.java | 163 +++++++++--------- .../coordinator/actions/SaveAllAction.java | 18 +- .../com/sun/hotspot/igv/coordinator/layer.xml | 6 +- .../sun/hotspot/igv/data/GraphDocument.java | 12 +- .../com/sun/hotspot/igv/data/InputBlock.java | 6 +- .../com/sun/hotspot/igv/data/Properties.java | 65 ++++++- .../igv/data/serialization/BinaryParser.java | 76 ++++++-- .../igv/data/services/InputGraphProvider.java | 12 +- .../Graph/nbproject/project.xml | 8 + .../src/com/sun/hotspot/igv/graph/Slot.java | 5 +- .../hotspot/igv/view/DiagramViewModel.java | 47 ++++- .../igv/view/EditorInputGraphProvider.java | 12 +- .../hotspot/igv/view/EditorTopComponent.java | 7 +- .../sun/hotspot/igv/view/NodeQuickSearch.java | 106 ++++++++---- .../src/com/sun/hotspot/igv/view/layer.xml | 12 ++ .../hotspot/igv/view/widgets/LineWidget.java | 5 +- .../nbproject/project.properties | 2 +- 19 files changed, 422 insertions(+), 158 deletions(-) diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java index 713d7a1d80f..8b526cf6b64 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,11 +25,13 @@ package com.sun.hotspot.igv.coordinator; import com.sun.hotspot.igv.coordinator.actions.RemoveCookie; import com.sun.hotspot.igv.data.*; +import com.sun.hotspot.igv.util.PropertiesSheet; import java.awt.Image; import java.util.List; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; +import org.openide.nodes.Sheet; import org.openide.util.ImageUtilities; import org.openide.util.lookup.AbstractLookup; import org.openide.util.lookup.InstanceContent; @@ -74,6 +76,16 @@ public class FolderNode extends AbstractNode { } } + @Override + protected Sheet createSheet() { + Sheet s = super.createSheet(); + if (children.folder instanceof Properties.Entity) { + Properties.Entity p = (Properties.Entity) children.folder; + PropertiesSheet.initializeSheet(p.getProperties(), s); + } + return s; + } + @Override public Image getIcon(int i) { return ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.png"); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java index 292dcd4b6fb..ad43e6f8949 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -124,6 +124,8 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM public void clear() { document.clear(); + root = new FolderNode(document); + manager.setRootContext(root); } @Override diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java index 5bd6c199bf5..ee643b23cc0 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,31 +31,47 @@ import com.sun.hotspot.igv.data.serialization.GraphParser; import com.sun.hotspot.igv.data.serialization.ParseMonitor; import com.sun.hotspot.igv.data.serialization.Parser; import com.sun.hotspot.igv.settings.Settings; -import java.awt.event.InputEvent; -import java.awt.event.KeyEvent; +import java.awt.event.ActionEvent; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.nio.channels.FileChannel; import java.nio.file.StandardOpenOption; -import javax.swing.Action; +import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.JFileChooser; -import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import javax.swing.filechooser.FileFilter; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandleFactory; import org.openide.util.Exceptions; +import org.openide.util.RequestProcessor; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionReferences; +import org.openide.awt.ActionRegistration; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; -import org.openide.util.RequestProcessor; -import org.openide.util.actions.CallableSystemAction; +import org.openide.util.actions.SystemAction; /** * * @author Thomas Wuerthinger */ -public final class ImportAction extends CallableSystemAction { + +@ActionID( + category = "File", + id = "com.sun.hotspot.igv.coordinator.actions.ImportAction" +) +@ActionRegistration( + iconBase = "com/sun/hotspot/igv/coordinator/images/import.png", + displayName = "#CTL_ImportAction" +) +@ActionReferences({ + @ActionReference(path = "Menu/File", position = 0), + @ActionReference(path = "Shortcuts", name = "C-O") +}) +public final class ImportAction extends SystemAction { private static final int WORKUNITS = 10000; public static FileFilter getFileFilter() { @@ -74,74 +90,77 @@ public final class ImportAction extends CallableSystemAction { } @Override - public void performAction() { - + public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); fc.setFileFilter(ImportAction.getFileFilter()); fc.setCurrentDirectory(new File(Settings.get().get(Settings.DIRECTORY, Settings.DIRECTORY_DEFAULT))); + fc.setMultiSelectionEnabled(true); if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - - File dir = file; - if (!dir.isDirectory()) { - dir = dir.getParentFile(); - } + for (final File file : fc.getSelectedFiles()) { + File dir = file; + if (!dir.isDirectory()) { + dir = dir.getParentFile(); + } - Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath()); - try { - final FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ); - final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName()); - handle.start(WORKUNITS); - final long start = channel.size(); - ParseMonitor monitor = new ParseMonitor() { - @Override - public void updateProgress() { - try { - int prog = (int) (WORKUNITS * (double) channel.position() / (double) start); - handle.progress(prog); - } catch (IOException ex) { - } - } - @Override - public void setState(String state) { - updateProgress(); - handle.progress(state); + Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath()); + try { + final FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ); + final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName()); + handle.start(WORKUNITS); + final long startTime = System.currentTimeMillis(); + final long start = channel.size(); + ParseMonitor monitor = new ParseMonitor() { + @Override + public void updateProgress() { + try { + int prog = (int) (WORKUNITS * (double) channel.position() / (double) start); + handle.progress(prog); + } catch (IOException ex) { + } + } + @Override + public void setState(String state) { + updateProgress(); + handle.progress(state); + } + }; + final GraphParser parser; + final OutlineTopComponent component = OutlineTopComponent.findInstance(); + if (file.getName().endsWith(".xml")) { + parser = new Parser(channel, monitor, null); + } else if (file.getName().endsWith(".bgv")) { + parser = new BinaryParser(channel, monitor, component.getDocument(), null); + } else { + parser = null; } - }; - final GraphParser parser; - final OutlineTopComponent component = OutlineTopComponent.findInstance(); - if (file.getName().endsWith(".xml")) { - parser = new Parser(channel, monitor, null); - } else if (file.getName().endsWith(".bgv")) { - parser = new BinaryParser(channel, monitor, component.getDocument(), null); - } else { - parser = null; - } - RequestProcessor.getDefault().post(new Runnable() { - @Override - public void run() { - try { - final GraphDocument document = parser.parse(); - if (document != null) { - SwingUtilities.invokeLater(new Runnable(){ - @Override - public void run() { - component.requestActive(); - component.getDocument().addGraphDocument(document); + RequestProcessor.getDefault().post(new Runnable() { + @Override + public void run() { + try { + final GraphDocument document = parser.parse(); + if (document != null) { + SwingUtilities.invokeLater(new Runnable(){ + @Override + public void run() { + component.requestActive(); + component.getDocument().addGraphDocument(document); + } + }); } - }); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } + handle.finish(); + long stop = System.currentTimeMillis(); + Logger.getLogger(getClass().getName()).log(Level.INFO, "Loaded in " + file + " in " + ((stop - startTime) / 1000.0) + " seconds"); } - } catch (IOException ex) { - Exceptions.printStackTrace(ex); - } - handle.finish(); - } - }); - } catch (FileNotFoundException ex) { - Exceptions.printStackTrace(ex); - } catch (IOException ex) { - Exceptions.printStackTrace(ex); + }); + } catch (FileNotFoundException ex) { + Exceptions.printStackTrace(ex); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + } } } } @@ -151,11 +170,6 @@ public final class ImportAction extends CallableSystemAction { return NbBundle.getMessage(ImportAction.class, "CTL_ImportAction"); } - public ImportAction() { - putValue(Action.SHORT_DESCRIPTION, "Open XML graph document..."); - putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK)); - } - @Override protected String iconResource() { return "com/sun/hotspot/igv/coordinator/images/import.png"; @@ -165,9 +179,4 @@ public final class ImportAction extends CallableSystemAction { public HelpCtx getHelpCtx() { return HelpCtx.DEFAULT_HELP; } - - @Override - protected boolean asynchronous() { - return false; - } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java index eb75dd9753a..df1ed46a003 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAllAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,14 +29,30 @@ import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import javax.swing.Action; import javax.swing.KeyStroke; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionReferences; +import org.openide.awt.ActionRegistration; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; +import org.openide.util.NbBundle.Messages; import org.openide.util.actions.CallableSystemAction; /** * * @author Thomas Wuerthinger */ +@ActionID( + category = "File", + id = "com.sun.hotspot.igv.coordinator.actions.SaveAllAction" +) +@ActionRegistration( + displayName = "#CTL_SaveAllAction" +) +@ActionReferences({ + @ActionReference(path = "Menu/File", position = 0), + @ActionReference(path = "Shortcuts", name = "C-S") +}) public final class SaveAllAction extends CallableSystemAction { @Override diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml index 49fbe2fd330..ef808eed53c 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml @@ -18,6 +18,8 @@ + + @@ -43,11 +45,11 @@ - + - + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java index 8c62573b2d4..85a0494658c 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,11 +51,13 @@ public class GraphDocument extends Properties.Entity implements ChangedEventProv } public void addGraphDocument(GraphDocument document) { - for (FolderElement e : document.elements) { - e.setParent(this); - this.addElement(e); + if (document != this) { + for (FolderElement e : document.elements) { + e.setParent(this); + this.addElement(e); + } + document.clear(); } - document.clear(); getChangedEvent().fire(); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java index 2626e51e734..242623d7ada 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,7 +90,9 @@ public class InputBlock { public void addNode(int id) { InputNode node = graph.getNode(id); assert node != null; - assert !nodes.contains(node) : "duplicate : " + node; + // nodes.contains(node) is too expensive for large graphs so + // just make sure the Graph doesn't know it yet. + assert graph.getBlock(id) == null : "duplicate : " + node; graph.setBlock(node, this); nodes.add(node); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java index 2646231bfab..d0499c23524 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,9 @@ package com.sun.hotspot.igv.data; import java.io.Serializable; +import java.lang.ref.WeakReference; import java.util.*; +import java.util.Map.Entry; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; @@ -36,7 +38,7 @@ import java.util.regex.PatternSyntaxException; public class Properties implements Serializable, Iterable { public static final long serialVersionUID = 1L; - private String[] map = new String[4]; + protected String[] map = new String[4]; public Properties() { } @@ -102,6 +104,59 @@ public class Properties implements Serializable, Iterable { System.arraycopy(p.map, 0, map, 0, p.map.length); } + protected Properties(String[] map) { + this.map = map; + } + + static class SharedProperties extends Properties { + int hashCode; + + SharedProperties(String[] map) { + super(map); + this.hashCode = Arrays.hashCode(map); + } + + @Override + protected void setPropertyInternal(String name, String value) { + throw new UnsupportedOperationException(); + } + + @Override + public boolean equals(Object other) { + if (this == other) { + return true; + } + if (!(other instanceof SharedProperties)) { + return super.equals(other); + } + SharedProperties props2 = (SharedProperties) other; + return Arrays.equals(map, props2.map); + } + + @Override + public int hashCode() { + return hashCode; + } + } + + private static class PropertyCache { + static WeakHashMap> immutableCache = new WeakHashMap<>(); + + static synchronized SharedProperties intern(Properties properties) { + String[] map = properties.map; + SharedProperties key = new SharedProperties(map); + WeakReference entry = immutableCache.get(key); + if (entry != null) { + SharedProperties props = entry.get(); + if (props != null) { + return props; + } + } + immutableCache.put(key, new WeakReference<>(key)); + return key; + } + } + public static class Entity implements Provider { private Properties properties; @@ -118,6 +173,10 @@ public class Properties implements Serializable, Iterable { public Properties getProperties() { return properties; } + + public void internProperties() { + properties = PropertyCache.intern(properties); + } } public interface PropertyMatcher { @@ -322,8 +381,8 @@ public class Properties implements Serializable, Iterable { public void setProperty(String name, String value) { setPropertyInternal(name.intern(), value != null ? value.intern() : null); } - private void setPropertyInternal(String name, String value) { + protected void setPropertyInternal(String name, String value) { for (int i = 0; i < map.length; i += 2) { if (map[i] != null && map[i].equals(name)) { String p = map[i + 1]; diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java index 5529701b979..52d5a7174f1 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import java.io.EOFException; import java.io.IOException; import java.nio.ByteBuffer; import java.nio.channels.ReadableByteChannel; +import java.nio.charset.Charset; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -68,6 +69,8 @@ public class BinaryParser implements GraphParser { private static final String NO_BLOCK = "noBlock"; + private static final Charset utf8 = Charset.forName("UTF-8"); + private final GroupCallback callback; private final List constantPool; private final ByteBuffer buffer; @@ -275,28 +278,36 @@ public class BinaryParser implements GraphParser { hashStack = new LinkedList<>(); this.monitor = monitor; try { - this.digest = MessageDigest.getInstance("SHA-256"); + this.digest = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { } } private void fill() throws IOException { + // All the data between lastPosition and position has been + // used so add it to the digest. + int position = buffer.position(); + buffer.position(lastPosition); + byte[] remaining = new byte[position - buffer.position()]; + buffer.get(remaining); + digest.update(remaining); + assert position == buffer.position(); + buffer.compact(); if (channel.read(buffer) < 0) { throw new EOFException(); } buffer.flip(); + lastPosition = buffer.position(); } private void ensureAvailable(int i) throws IOException { + if (i > buffer.capacity()) { + throw new IllegalArgumentException(String.format("Can not request %d bytes: buffer capacity is %d", i, buffer.capacity())); + } while (buffer.remaining() < i) { fill(); } - buffer.mark(); - byte[] result = new byte[i]; - buffer.get(result); - digest.update(result); - buffer.reset(); } private int readByte() throws IOException { @@ -330,12 +341,7 @@ public class BinaryParser implements GraphParser { } private String readString() throws IOException { - int len = readInt(); - ensureAvailable(len * 2); - char[] chars = new char[len]; - buffer.asCharBuffer().get(chars); - buffer.position(buffer.position() + len * 2); - return new String(chars).intern(); + return new String(readBytes(), utf8).intern(); } private byte[] readBytes() throws IOException { @@ -343,10 +349,15 @@ public class BinaryParser implements GraphParser { if (len < 0) { return null; } - ensureAvailable(len); - byte[] data = new byte[len]; - buffer.get(data); - return data; + byte[] b = new byte[len]; + int bytesRead = 0; + while (bytesRead < b.length) { + int toRead = Math.min(b.length - bytesRead, buffer.capacity()); + ensureAvailable(toRead); + buffer.get(b, bytesRead, toRead); + bytesRead += toRead; + } + return b; } private String readIntsToString() throws IOException { @@ -643,6 +654,7 @@ public class BinaryParser implements GraphParser { int bci = readInt(); Group group = new Group(parent); group.getProperties().setProperty("name", name); + parseProperties(group.getProperties()); if (method != null) { InputMethod inMethod = new InputMethod(group, method.name, shortName, bci); inMethod.setBytecodes("TODO"); @@ -651,13 +663,25 @@ public class BinaryParser implements GraphParser { return group; } + int lastPosition = 0; + private InputGraph parseGraph() throws IOException { if (monitor != null) { monitor.updateProgress(); } String title = readPoolObject(String.class); digest.reset(); + lastPosition = buffer.position(); InputGraph graph = parseGraph(title); + + int position = buffer.position(); + buffer.position(lastPosition); + byte[] remaining = new byte[position - buffer.position()]; + buffer.get(remaining); + digest.update(remaining); + assert position == buffer.position(); + lastPosition = buffer.position(); + byte[] d = digest.digest(); byte[] hash = hashStack.peek(); if (hash != null && Arrays.equals(hash, d)) { @@ -669,11 +693,24 @@ public class BinaryParser implements GraphParser { return graph; } + private void parseProperties(Properties properties) throws IOException { + int propCount = readShort(); + for (int j = 0; j < propCount; j++) { + String key = readPoolObject(String.class); + Object value = readPropertyObject(); + properties.setProperty(key, value != null ? value.toString() : "null"); + } + } + private InputGraph parseGraph(String title) throws IOException { InputGraph graph = new InputGraph(title); + parseProperties(graph.getProperties()); parseNodes(graph); parseBlocks(graph); graph.ensureNodesInBlocks(); + for (InputNode node : graph.getNodes()) { + node.internProperties(); + } return graph; } @@ -822,9 +859,10 @@ public class BinaryParser implements GraphParser { } } + static final Pattern templatePattern = Pattern.compile("\\{(p|i)#([a-zA-Z0-9$_]+)(/(l|m|s))?\\}"); + private String createName(List edges, Map properties, String template) { - Pattern p = Pattern.compile("\\{(p|i)#([a-zA-Z0-9$_]+)(/(l|m|s))?\\}"); - Matcher m = p.matcher(template); + Matcher m = templatePattern.matcher(template); StringBuffer sb = new StringBuffer(); while (m.find()) { String name = m.group(2); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java index 638a065c40b..b3ef1fcb876 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/InputGraphProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,4 +37,14 @@ public interface InputGraphProvider { InputGraph getGraph(); void setSelectedNodes(Set nodes); + + /** + * @return an iterator walking forward through the {@link InputGraph}s following the {@link #getGraph()} + */ + Iterable searchForward(); + + /** + * @return an iterator walking backward through the {@link InputGraph}s preceeding the {@link #getGraph()} + */ + Iterable searchBackward(); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml index 7e3f062052b..a4aadaa4751 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml @@ -22,6 +22,14 @@ 1.0 + + com.sun.hotspot.igv.util + + + + 1.0 + + com.sun.hotspot.igv.graph diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java index da101bf7341..79d129984f1 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.Source; import com.sun.hotspot.igv.layout.Port; import com.sun.hotspot.igv.layout.Vertex; +import com.sun.hotspot.igv.util.StringUtils; import java.awt.Color; import java.awt.Font; import java.awt.FontMetrics; @@ -141,7 +142,7 @@ public abstract class Slot implements Port, Source.Provider, Properties.Provider sb.append(text); for (InputNode n : getSource().getSourceNodes()) { - sb.append("Node (ID=" + n.getId() + "): " + n.getProperties().get("name")); + sb.append(StringUtils.escapeHTML("Node (ID=" + n.getId() + "): " + n.getProperties().get("name"))); sb.append("
        "); } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java index a1ccc650230..cccca711113 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -445,5 +445,48 @@ public class DiagramViewModel extends RangeSliderModel implements ChangedListene void close() { filterChain.getChangedEvent().removeListener(filterChainChangedListener); sequenceFilterChain.getChangedEvent().removeListener(filterChainChangedListener); -} + } + + Iterable getGraphsForward() { + return new Iterable() { + + @Override + public Iterator iterator() { + return new Iterator() { + int index = getFirstPosition(); + + @Override + public boolean hasNext() { + return index + 1 < graphs.size(); + } + + @Override + public InputGraph next() { + return graphs.get(++index); + } + }; + } + }; + } + + Iterable getGraphsBackward() { + return new Iterable() { + @Override + public Iterator iterator() { + return new Iterator() { + int index = getFirstPosition(); + + @Override + public boolean hasNext() { + return index - 1 > 0; + } + + @Override + public InputGraph next() { + return graphs.get(--index); + } + }; + } + }; + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorInputGraphProvider.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorInputGraphProvider.java index cb4c9f6be96..fd7a19ae718 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorInputGraphProvider.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorInputGraphProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,4 +50,14 @@ public class EditorInputGraphProvider implements InputGraphProvider { public void setSelectedNodes(Set nodes) { editor.setSelectedNodes(nodes); } + + @Override + public Iterable searchBackward() { + return editor.getDiagramModel().getGraphsBackward(); + } + + @Override + public Iterable searchForward() { + return editor.getDiagramModel().getGraphsForward(); + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java index 6da842ceb9d..9a858385f27 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/EditorTopComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -289,7 +289,10 @@ public final class EditorTopComponent extends TopComponent implements PropertyCh quicksearch = (Component) quicksearch.getClass().getConstructor(KeyStroke.class).newInstance(new Object[]{null}); } catch (ReflectiveOperationException | IllegalArgumentException | SecurityException e) { } - quicksearch.setMinimumSize(quicksearch.getPreferredSize()); // necessary for GTK LAF + Dimension preferredSize = quicksearch.getPreferredSize(); + preferredSize = new Dimension((int) preferredSize.getWidth() * 2, (int) preferredSize.getHeight()); + quicksearch.setMinimumSize(preferredSize); // necessary for GTK LAF + quicksearch.setPreferredSize(preferredSize); toolBar.add(quicksearch); centerPanel = new JPanel(); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java index 53773a26b89..23b23ed15d0 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/NodeQuickSearch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ */ package com.sun.hotspot.igv.view; +import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.InputNode; import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.Properties.RegexpPropertyMatcher; @@ -81,57 +82,67 @@ public class NodeQuickSearch implements SearchProvider { final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class); if (p != null && p.getGraph() != null) { - List matches = null; - try { - RegexpPropertyMatcher matcher = new RegexpPropertyMatcher(name, value, Pattern.CASE_INSENSITIVE); - Properties.PropertySelector selector = new Properties.PropertySelector<>(p.getGraph().getNodes()); - - matches = selector.selectMultiple(matcher); - } catch (Exception e) { - final String msg = e.getMessage(); - response.addResult(new Runnable() { - @Override - public void run() { - Message desc = new NotifyDescriptor.Message("An exception occurred during the search, " - + "perhaps due to a malformed query string:\n" + msg, - NotifyDescriptor.WARNING_MESSAGE); - DialogDisplayer.getDefault().notify(desc); - } - }, - "(Error during search)" - ); + InputGraph matchGraph = p.getGraph(); + // Search the current graph + List matches = findMatches(name, value, p.getGraph(), response); + if (matches == null) { + // See if the it hits in a later graph + for (InputGraph graph : p.searchForward()) { + matches = findMatches(name, value, graph, response); + if (matches != null) { + matchGraph = graph; + break; + } + } + } + if (matches == null) { + // See if it hits in a earlier graph + for (InputGraph graph : p.searchBackward()) { + matches = findMatches(name, value, graph, response); + if (matches != null) { + matchGraph = graph; + break; + } + } } if (matches != null) { final Set set = new HashSet<>(matches); + final InputGraph theGraph = p.getGraph() != matchGraph ? matchGraph : null; response.addResult(new Runnable() { @Override - public void run() { - final EditorTopComponent comp = EditorTopComponent.getActive(); - if (comp != null) { - comp.setSelectedNodes(set); - comp.requestActive(); + public void run() { + final EditorTopComponent comp = EditorTopComponent.getActive(); + if (comp != null) { + if (theGraph != null) { + comp.getDiagramModel().selectGraph(theGraph); } + comp.setSelectedNodes(set); + comp.requestActive(); } - }, - "All " + matches.size() + " matching nodes (" + name + "=" + value + ")" + } + }, + "All " + matches.size() + " matching nodes (" + name + "=" + value + ")" + (theGraph != null ? " in " + theGraph.getName() : "") ); // Single matches for (final InputNode n : matches) { response.addResult(new Runnable() { @Override - public void run() { - final EditorTopComponent comp = EditorTopComponent.getActive(); - if (comp != null) { - final Set tmpSet = new HashSet<>(); - tmpSet.add(n); - comp.setSelectedNodes(tmpSet); - comp.requestActive(); + public void run() { + final EditorTopComponent comp = EditorTopComponent.getActive(); + if (comp != null) { + final Set tmpSet = new HashSet<>(); + tmpSet.add(n); + if (theGraph != null) { + comp.getDiagramModel().selectGraph(theGraph); } + comp.setSelectedNodes(tmpSet); + comp.requestActive(); } - }, - n.getProperties().get(name) + " (" + n.getId() + " " + n.getProperties().get("name") + ")" + } + }, + n.getProperties().get(name) + " (" + n.getId() + " " + n.getProperties().get("name") + ")" + (theGraph != null ? " in " + theGraph.getName() : "") ); } } @@ -139,4 +150,27 @@ public class NodeQuickSearch implements SearchProvider { System.out.println("no input graph provider!"); } } + + private List findMatches(String name, String value, InputGraph inputGraph, SearchResponse response) { + try { + RegexpPropertyMatcher matcher = new RegexpPropertyMatcher(name, value, Pattern.CASE_INSENSITIVE); + Properties.PropertySelector selector = new Properties.PropertySelector<>(inputGraph.getNodes()); + List matches = selector.selectMultiple(matcher); + return matches.size() == 0 ? null : matches; + } catch (Exception e) { + final String msg = e.getMessage(); + response.addResult(new Runnable() { + @Override + public void run() { + Message desc = new NotifyDescriptor.Message("An exception occurred during the search, " + + "perhaps due to a malformed query string:\n" + msg, + NotifyDescriptor.WARNING_MESSAGE); + DialogDisplayer.getDefault().notify(desc); + } + }, + "(Error during search)" + ); + } + return null; + } } diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/layer.xml b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/layer.xml index 66979b19e57..e37ac818667 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/layer.xml +++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/layer.xml @@ -61,14 +61,26 @@ + + + + + + + + + + + + diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java index 2d9efb8fdcc..3cf39ca34ef 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java +++ b/hotspot/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/widgets/LineWidget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ import com.sun.hotspot.igv.graph.Connection; import com.sun.hotspot.igv.graph.Figure; import com.sun.hotspot.igv.graph.InputSlot; import com.sun.hotspot.igv.graph.OutputSlot; +import com.sun.hotspot.igv.util.StringUtils; import com.sun.hotspot.igv.view.DiagramScene; import java.awt.*; import java.awt.geom.Line2D; @@ -148,7 +149,7 @@ public class LineWidget extends Widget implements PopupMenuProvider { private String generateToolTipText(List conn) { StringBuilder sb = new StringBuilder(); for (Connection c : conn) { - sb.append(c.getToolTipText()); + sb.append(StringUtils.escapeHTML(c.getToolTipText())); sb.append("
        "); } return sb.toString(); diff --git a/hotspot/src/share/tools/IdealGraphVisualizer/nbproject/project.properties b/hotspot/src/share/tools/IdealGraphVisualizer/nbproject/project.properties index 39801a7cf7a..f9a657cb6ee 100644 --- a/hotspot/src/share/tools/IdealGraphVisualizer/nbproject/project.properties +++ b/hotspot/src/share/tools/IdealGraphVisualizer/nbproject/project.properties @@ -48,5 +48,5 @@ project.com.sun.hotspot.igv.util=Util # Disable assertions for RequestProcessor to prevent annoying messages in case # of multiple SceneAnimator update tasks in the default RequestProcessor. -run.args.extra = -J-server -J-da:org.openide.util.RequestProcessor -J-Xms2g -J-Xmx8g -J-Djava.lang.Integer.IntegerCache.high=20000 +run.args.extra = -J-server -J-da:org.openide.util.RequestProcessor -J-Xms2g -J-Xmx8g -J-Djava.lang.Integer.IntegerCache.high=200000 debug.args.extra = -J-server -J-da:org.openide.util.RequestProcessor -- GitLab From 17ee5a98f33e85e4d70b654350e11c0d2fab4b50 Mon Sep 17 00:00:00 2001 From: Ed Nevill Date: Sat, 30 Apr 2016 00:57:04 -0700 Subject: [PATCH 268/400] 8155790: aarch64: debug VM fails to start after 8155617 Fix base register to point to end after zeroing Reviewed-by: aph --- hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp | 8 ++++---- hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp index 72aad0fd59a..6b6c404372b 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp @@ -4767,15 +4767,15 @@ void MacroAssembler::fill_words(Register base, Register cnt, Register value) br(rscratch2); bind(loop); + add(base, base, unroll * 16); for (int i = -unroll; i < 0; i++) stp(value, value, Address(base, i * 16)); bind(entry); subs(cnt, cnt, unroll * 2); - add(base, base, unroll * 16); br(Assembler::GE, loop); tbz(cnt, 0, fini); - str(value, Address(base, -unroll * 16)); + str(value, Address(post(base, 8))); bind(fini); } @@ -4828,15 +4828,15 @@ void MacroAssembler::block_zero(Register base, Register cnt, bool is_large) br(tmp2); bind(small_loop); + add(base, base, unroll * 16); for (int i = -unroll; i < 0; i++) stp(zr, zr, Address(base, i * 16)); bind(small_table_end); subs(cnt, cnt, unroll * 2); - add(base, base, unroll * 16); br(Assembler::GE, small_loop); tbz(cnt, 0, done); - str(zr, Address(base, -unroll * 16)); + str(zr, Address(post(base, 8))); bind(done); } diff --git a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp index 5e838e93d02..00f9502354f 100644 --- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp @@ -724,11 +724,15 @@ class StubGenerator: public StubCodeGenerator { Register tmp2 = rscratch2; int zva_length = VM_Version::zva_length(); Label initial_table_end, loop_zva; + Label fini; __ align(CodeEntryAlignment); StubCodeMark mark(this, "StubRoutines", "zero_longs"); address start = __ pc(); + // Base must be 16 byte aligned. If not just return and let caller handle it + __ tst(base, 0x0f); + __ br(Assembler::NE, fini); // Align base with ZVA length. __ neg(tmp, base); __ andr(tmp, tmp, zva_length - 1); @@ -751,6 +755,7 @@ class StubGenerator: public StubCodeGenerator { __ add(base, base, zva_length); __ br(Assembler::GE, loop_zva); __ add(cnt, cnt, zva_length >> 3); // count not zeroed by DC ZVA + __ bind(fini); __ ret(lr); return start; -- GitLab From 7982dafac24c8800fafe82a9359adfaf97a6182e Mon Sep 17 00:00:00 2001 From: Dmitrij Pochepko Date: Mon, 2 May 2016 03:20:23 +0300 Subject: [PATCH 269/400] 8155244: JVMCI: MemoryAccessProvider.readUnsafeConstant javadoc should be updated for null JavaKind case Reviewed-by: twisti --- .../jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java | 3 +++ .../src/jdk/vm/ci/meta/MemoryAccessProvider.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java index b824f0cd8d3..6914926d661 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java @@ -146,6 +146,9 @@ class HotSpotMemoryAccessProviderImpl implements HotSpotMemoryAccessProvider, Ho @Override public JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant baseConstant, long displacement) { + if (kind == null) { + throw new IllegalArgumentException("null JavaKind"); + } if (kind == JavaKind.Object) { Object o = readRawObject(baseConstant, displacement, runtime.getConfig().useCompressedOops); return HotSpotObjectConstantImpl.forObject(o); diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java index 2f10d1073c6..f98461d45e8 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/MemoryAccessProvider.java @@ -35,8 +35,8 @@ public interface MemoryAccessProvider { * @param displacement the displacement within the object in bytes * @return the read value encapsulated in a {@link JavaConstant} object, or {@code null} if the * value cannot be read. - * @throws IllegalArgumentException if {@code kind} is {@link JavaKind#Void} or not - * {@linkplain JavaKind#isPrimitive() primitive} kind + * @throws IllegalArgumentException if {@code kind} is {@code null}, {@link JavaKind#Void} or + * not {@linkplain JavaKind#isPrimitive() primitive} kind */ JavaConstant readUnsafeConstant(JavaKind kind, JavaConstant base, long displacement) throws IllegalArgumentException; -- GitLab From 73db8859bfd59f20398e100573e95050f10dcb26 Mon Sep 17 00:00:00 2001 From: Dmitrij Pochepko Date: Mon, 2 May 2016 03:24:02 +0300 Subject: [PATCH 270/400] 8155163: JVMCI: MethodHandleAccessProvider.resolveInvokeBasicTarget implementation doesn't match javadoc Reviewed-by: twisti --- .../jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java index 87cf467f6d7..1293a1083d7 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMethodHandleAccessProvider.java @@ -130,7 +130,7 @@ public class HotSpotMethodHandleAccessProvider implements MethodHandleAccessProv /* Load non-public field: LambdaForm MethodHandle.form */ JavaConstant lambdaForm = constantReflection.readFieldValue(LazyInitialization.methodHandleFormField, methodHandle); - if (lambdaForm.isNull()) { + if (lambdaForm == null || lambdaForm.isNull()) { return null; } -- GitLab From 9722354d373208536e68323ba61595fa1c649388 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Mon, 2 May 2016 14:17:19 -0700 Subject: [PATCH 271/400] 8155738: C2: fix frame_complete_offset During scratch_emit_size wrong value was set. Also set offset of ppc. Reviewed-by: kvn, dlong --- hotspot/src/cpu/ppc/vm/ppc.ad | 2 ++ hotspot/src/share/vm/opto/compile.hpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hotspot/src/cpu/ppc/vm/ppc.ad b/hotspot/src/cpu/ppc/vm/ppc.ad index 1b38c16e199..d6d7575d005 100644 --- a/hotspot/src/cpu/ppc/vm/ppc.ad +++ b/hotspot/src/cpu/ppc/vm/ppc.ad @@ -1380,6 +1380,8 @@ void MachPrologNode::emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const { // Save return pc. ___(std) std(return_pc, _abi(lr), callers_sp); } + + C->set_frame_complete(cbuf.insts_size()); } #undef ___ #undef ___stop diff --git a/hotspot/src/share/vm/opto/compile.hpp b/hotspot/src/share/vm/opto/compile.hpp index 115072630bf..3cbbf51cd1d 100644 --- a/hotspot/src/share/vm/opto/compile.hpp +++ b/hotspot/src/share/vm/opto/compile.hpp @@ -1101,7 +1101,7 @@ class Compile : public Phase { int code_size() { return _method_size; } CodeBuffer* code_buffer() { return &_code_buffer; } int first_block_size() { return _first_block_size; } - void set_frame_complete(int off) { _code_offsets.set_value(CodeOffsets::Frame_Complete, off); } + void set_frame_complete(int off) { if (!in_scratch_emit_size()) { _code_offsets.set_value(CodeOffsets::Frame_Complete, off); } } ExceptionHandlerTable* handler_table() { return &_handler_table; } ImplicitExceptionTable* inc_table() { return &_inc_table; } OopMapSet* oop_map_set() { return _oop_map_set; } -- GitLab From fc0b590c74ec4c1e1b709e7f238ea5ee82944a54 Mon Sep 17 00:00:00 2001 From: Roland Schatz Date: Tue, 3 May 2016 11:57:03 +0200 Subject: [PATCH 272/400] 8155735: use strings instead of Symbol* in JVMCI exception stubs Reviewed-by: never, twisti --- hotspot/src/share/vm/jvmci/jvmciRuntime.cpp | 15 +++++++++------ hotspot/src/share/vm/jvmci/jvmciRuntime.hpp | 6 +++--- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp index 1588eb8acad..219ad61d9f4 100644 --- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp +++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp @@ -425,19 +425,22 @@ JRT_LEAF(void, JVMCIRuntime::monitorexit(JavaThread* thread, oopDesc* obj, Basic } JRT_END -JRT_ENTRY(void, JVMCIRuntime::throw_and_post_jvmti_exception(JavaThread* thread, Symbol* name, const char* message)) - SharedRuntime::throw_and_post_jvmti_exception(thread, name, message); +JRT_ENTRY(void, JVMCIRuntime::throw_and_post_jvmti_exception(JavaThread* thread, const char* exception, const char* message)) + TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK); + SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message); JRT_END -JRT_ENTRY(void, JVMCIRuntime::throw_klass_external_name_exception(JavaThread* thread, Symbol* exception, Klass* klass)) +JRT_ENTRY(void, JVMCIRuntime::throw_klass_external_name_exception(JavaThread* thread, const char* exception, Klass* klass)) ResourceMark rm(thread); - SharedRuntime::throw_and_post_jvmti_exception(thread, exception, klass->external_name()); + TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK); + SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, klass->external_name()); JRT_END -JRT_ENTRY(void, JVMCIRuntime::throw_class_cast_exception(JavaThread* thread, Symbol* exception, Klass* caster_klass, Klass* target_klass)) +JRT_ENTRY(void, JVMCIRuntime::throw_class_cast_exception(JavaThread* thread, const char* exception, Klass* caster_klass, Klass* target_klass)) ResourceMark rm(thread); const char* message = SharedRuntime::generate_class_cast_message(caster_klass, target_klass); - SharedRuntime::throw_and_post_jvmti_exception(thread, exception, message); + TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK); + SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message); JRT_END JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, bool as_string, bool newline)) diff --git a/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp b/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp index 256872aee4d..d3deb1d8ff5 100644 --- a/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp +++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp @@ -156,10 +156,10 @@ class JVMCIRuntime: public AllStatic { static void new_store_pre_barrier(JavaThread* thread); // used to throw exceptions from compiled JVMCI code - static void throw_and_post_jvmti_exception(JavaThread* thread, Symbol* exception, const char* message); + static void throw_and_post_jvmti_exception(JavaThread* thread, const char* exception, const char* message); // helper methods to throw exception with complex messages - static void throw_klass_external_name_exception(JavaThread* thread, Symbol* exception, Klass* klass); - static void throw_class_cast_exception(JavaThread* thread, Symbol* exception, Klass* caster_klass, Klass* target_klass); + static void throw_klass_external_name_exception(JavaThread* thread, const char* exception, Klass* klass); + static void throw_class_cast_exception(JavaThread* thread, const char* exception, Klass* caster_klass, Klass* target_klass); // Test only function static int test_deoptimize_call_int(JavaThread* thread, int value); -- GitLab From 38df4e48a42c2f1e92e3fa62c0f557216be13c4f Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Tue, 3 May 2016 12:15:06 -0700 Subject: [PATCH 273/400] 8155771: [JVMCI] expose JVM_ACC_IS_CLONEABLE_FAST Reviewed-by: twisti --- .../HotSpotResolvedObjectTypeImpl.java | 5 ++++ .../hotspot/HotSpotResolvedPrimitiveType.java | 5 ++++ .../jdk/vm/ci/hotspot/HotSpotVMConfig.java | 1 + .../src/jdk/vm/ci/meta/ResolvedJavaType.java | 8 ++++++ .../src/share/vm/jvmci/vmStructs_jvmci.cpp | 1 + .../ci/runtime/test/TestResolvedJavaType.java | 25 +++++++++++++++++++ 6 files changed, 45 insertions(+) diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java index 69dcc998dce..75a76e82240 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java @@ -882,4 +882,9 @@ final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implem public boolean isTrustedInterfaceType() { return TrustedInterface.class.isAssignableFrom(mirror()); } + + @Override + public boolean isCloneableWithAllocation() { + return (getAccessFlags() & config().jvmAccIsCloneableFast) != 0; + } } diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java index 6363634dea5..64f9027fe66 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java @@ -267,4 +267,9 @@ public final class HotSpotResolvedPrimitiveType extends HotSpotResolvedJavaType public boolean isTrustedInterfaceType() { return false; } + + @Override + public boolean isCloneableWithAllocation() { + return false; + } } diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java index 4008207ee8b..e3dd24edbb4 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java @@ -1077,6 +1077,7 @@ public class HotSpotVMConfig { @HotSpotVMConstant(name = "JVM_ACC_FIELD_STABLE") @Stable public int jvmAccFieldStable; @HotSpotVMConstant(name = "JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE") @Stable public int jvmAccFieldHasGenericSignature; @HotSpotVMConstant(name = "JVM_ACC_WRITTEN_FLAGS") @Stable public int jvmAccWrittenFlags; + @HotSpotVMConstant(name = "JVM_ACC_IS_CLONEABLE_FAST") @Stable public int jvmAccIsCloneableFast; // Modifier.SYNTHETIC is not public so we get it via vmStructs. @HotSpotVMConstant(name = "JVM_ACC_SYNTHETIC") @Stable public int jvmAccSynthetic; diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java index 33698424c8f..9a882975984 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaType.java @@ -359,4 +359,12 @@ public interface ResolvedJavaType extends JavaType, ModifiersProvider { } return null; } + + /** + * Returns true if this type is {@link Cloneable} and can be safely cloned by creating a normal + * Java allocation and populating it from the fields returned by + * {@link #getInstanceFields(boolean)}. Some types may require special handling by the platform + * so they would to go through the normal {@link Object#clone} path. + */ + boolean isCloneableWithAllocation(); } diff --git a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp index 9909d22feec..7488bcc3f21 100644 --- a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp +++ b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp @@ -309,6 +309,7 @@ declare_constant(JVM_ACC_MONITOR_MATCH) \ declare_constant(JVM_ACC_HAS_MONITOR_BYTECODES) \ declare_constant(JVM_ACC_HAS_FINALIZER) \ + declare_constant(JVM_ACC_IS_CLONEABLE_FAST) \ declare_constant(JVM_ACC_FIELD_INTERNAL) \ declare_constant(JVM_ACC_FIELD_STABLE) \ declare_constant(JVM_ACC_FIELD_HAS_GENERIC_SIGNATURE) \ diff --git a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java index b3ead95fe6d..074813a60b6 100644 --- a/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java +++ b/hotspot/test/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java @@ -866,6 +866,31 @@ public class TestResolvedJavaType extends TypeUniverse { } } + static class TrivialCloneable implements Cloneable { + @Override + protected Object clone() { + return new TrivialCloneable(); + } + } + + @Test + public void isCloneableWithAllocationTest() { + ResolvedJavaType cloneable = metaAccess.lookupJavaType(Cloneable.class); + for (Class c : classes) { + ResolvedJavaType type = metaAccess.lookupJavaType(c); + if (type.isCloneableWithAllocation()) { + // Only Cloneable types should be allocation cloneable + assertTrue(c.toString(), cloneable.isAssignableFrom(type)); + } + } + /* + * We can't know for sure which types should be allocation cloneable on a particular + * platform but assume that at least totally trivial objects should be. + */ + ResolvedJavaType trivialCloneable = metaAccess.lookupJavaType(TrivialCloneable.class); + assertTrue(trivialCloneable.toString(), trivialCloneable.isCloneableWithAllocation()); + } + @Test public void findMethodTest() { try { -- GitLab From fbac01c4e5e96825e0108484d5550424445e5d53 Mon Sep 17 00:00:00 2001 From: Ed Nevill Date: Tue, 3 May 2016 20:36:17 +0000 Subject: [PATCH 274/400] 8155967: aarch64: fix register usage in block zeroing Fix array fill stub to use r10 == base and r11 == count Reviewed-by: aph --- hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp | 1 + hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp index 6b6c404372b..dccf12c425e 100644 --- a/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/macroAssembler_aarch64.cpp @@ -4790,6 +4790,7 @@ void MacroAssembler::block_zero(Register base, Register cnt, bool is_large) Label base_aligned; assert_different_registers(base, cnt, rscratch1); + guarantee(base == r10 && cnt == r11, "fix register usage"); Register tmp = rscratch1; Register tmp2 = rscratch2; diff --git a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp index 00f9502354f..2355579ceab 100644 --- a/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/stubGenerator_aarch64.cpp @@ -2082,7 +2082,9 @@ class StubGenerator: public StubCodeGenerator { const Register to = c_rarg0; // source array address const Register value = c_rarg1; // value const Register count = c_rarg2; // elements count - const Register cnt_words = c_rarg3; // temp register + + const Register bz_base = r10; // base for block_zero routine + const Register cnt_words = r11; // temp register __ enter(); @@ -2152,7 +2154,9 @@ class StubGenerator: public StubCodeGenerator { __ cmp(cnt_words, BlockZeroingLowLimit >> 3); __ ccmp(value, 0 /* comparing value */, 0 /* NZCV */, Assembler::GE); __ br(Assembler::NE, non_block_zeroing); - __ block_zero(to, cnt_words, true); + __ mov(bz_base, to); + __ block_zero(bz_base, cnt_words, true); + __ mov(to, bz_base); __ b(rest); __ bind(non_block_zeroing); __ fill_words(to, cnt_words, value); -- GitLab From a8fb392baf1c97392d21f53c160708f6022dbb8e Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 4 May 2016 17:17:10 +0300 Subject: [PATCH 275/400] 8155739: [TESTBUG] VarHandles/Unsafe tests for weakCAS should allow spurious failures Reviewed-by: psandoz, vlivanov, simonis --- ...dkInternalMiscUnsafeAccessTestBoolean.java | 2 +- .../JdkInternalMiscUnsafeAccessTestByte.java | 2 +- .../JdkInternalMiscUnsafeAccessTestChar.java | 2 +- ...JdkInternalMiscUnsafeAccessTestDouble.java | 2 +- .../JdkInternalMiscUnsafeAccessTestFloat.java | 2 +- .../JdkInternalMiscUnsafeAccessTestInt.java | 25 +++-- .../JdkInternalMiscUnsafeAccessTestLong.java | 25 +++-- ...JdkInternalMiscUnsafeAccessTestObject.java | 23 +++-- .../JdkInternalMiscUnsafeAccessTestShort.java | 2 +- .../SunMiscUnsafeAccessTestBoolean.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestByte.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestChar.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestDouble.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestFloat.java | 3 +- .../unsafe/SunMiscUnsafeAccessTestInt.java | 6 +- .../unsafe/SunMiscUnsafeAccessTestLong.java | 6 +- .../unsafe/SunMiscUnsafeAccessTestObject.java | 4 +- .../unsafe/SunMiscUnsafeAccessTestShort.java | 3 +- .../unsafe/X-UnsafeAccessTest.java.template | 24 +++-- .../compiler/unsafe/generate-unsafe-tests.sh | 97 ------------------- 20 files changed, 84 insertions(+), 156 deletions(-) delete mode 100644 hotspot/test/compiler/unsafe/generate-unsafe-tests.sh diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java index 58fe9296be8..96c1a82b971 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestBoolean.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class JdkInternalMiscUnsafeAccessTestBoolean { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final jdk.internal.misc.Unsafe UNSAFE; @@ -148,4 +149,3 @@ public class JdkInternalMiscUnsafeAccessTestBoolean { } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java index 12ae3c31a4e..2b5438e7c30 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestByte.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class JdkInternalMiscUnsafeAccessTestByte { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final jdk.internal.misc.Unsafe UNSAFE; @@ -185,4 +186,3 @@ public class JdkInternalMiscUnsafeAccessTestByte { } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java index f912b7fd86d..67f425826d3 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestChar.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class JdkInternalMiscUnsafeAccessTestChar { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final jdk.internal.misc.Unsafe UNSAFE; @@ -203,4 +204,3 @@ public class JdkInternalMiscUnsafeAccessTestChar { } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java index adbe249bafc..5304bc2c900 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestDouble.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class JdkInternalMiscUnsafeAccessTestDouble { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final jdk.internal.misc.Unsafe UNSAFE; @@ -185,4 +186,3 @@ public class JdkInternalMiscUnsafeAccessTestDouble { } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java index 6e08a213f7f..f7c542ebd6f 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestFloat.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class JdkInternalMiscUnsafeAccessTestFloat { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final jdk.internal.misc.Unsafe UNSAFE; @@ -185,4 +186,3 @@ public class JdkInternalMiscUnsafeAccessTestFloat { } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java index 47bfd7da01f..b2555b06605 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class JdkInternalMiscUnsafeAccessTestInt { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final jdk.internal.misc.Unsafe UNSAFE; @@ -251,22 +252,31 @@ public class JdkInternalMiscUnsafeAccessTestInt { } { - boolean r = UNSAFE.weakCompareAndSwapInt(base, offset, 1, 2); - assertEquals(r, true, "weakCompareAndSwap int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwapInt(base, offset, 1, 2); + } + assertEquals(success, true, "weakCompareAndSwap int"); int x = UNSAFE.getInt(base, offset); assertEquals(x, 2, "weakCompareAndSwap int value"); } { - boolean r = UNSAFE.weakCompareAndSwapIntAcquire(base, offset, 2, 1); - assertEquals(r, true, "weakCompareAndSwapAcquire int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwapIntAcquire(base, offset, 2, 1); + } + assertEquals(success, true, "weakCompareAndSwapAcquire int"); int x = UNSAFE.getInt(base, offset); assertEquals(x, 1, "weakCompareAndSwapAcquire int"); } { - boolean r = UNSAFE.weakCompareAndSwapIntRelease(base, offset, 1, 2); - assertEquals(r, true, "weakCompareAndSwapRelease int"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwapIntRelease(base, offset, 1, 2); + } + assertEquals(success, true, "weakCompareAndSwapRelease int"); int x = UNSAFE.getInt(base, offset); assertEquals(x, 2, "weakCompareAndSwapRelease int"); } @@ -286,7 +296,7 @@ public class JdkInternalMiscUnsafeAccessTestInt { int o = UNSAFE.getAndAddInt(base, offset, 2); assertEquals(o, 1, "getAndAdd int"); int x = UNSAFE.getInt(base, offset); - assertEquals(x, 1 + 2, "weakCompareAndSwapRelease int"); + assertEquals(x, 1 + 2, "getAndAdd int"); } } @@ -300,4 +310,3 @@ public class JdkInternalMiscUnsafeAccessTestInt { } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java index 9ed8b8710bc..66608a2f2ad 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class JdkInternalMiscUnsafeAccessTestLong { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final jdk.internal.misc.Unsafe UNSAFE; @@ -251,22 +252,31 @@ public class JdkInternalMiscUnsafeAccessTestLong { } { - boolean r = UNSAFE.weakCompareAndSwapLong(base, offset, 1L, 2L); - assertEquals(r, true, "weakCompareAndSwap long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwapLong(base, offset, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSwap long"); long x = UNSAFE.getLong(base, offset); assertEquals(x, 2L, "weakCompareAndSwap long value"); } { - boolean r = UNSAFE.weakCompareAndSwapLongAcquire(base, offset, 2L, 1L); - assertEquals(r, true, "weakCompareAndSwapAcquire long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwapLongAcquire(base, offset, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSwapAcquire long"); long x = UNSAFE.getLong(base, offset); assertEquals(x, 1L, "weakCompareAndSwapAcquire long"); } { - boolean r = UNSAFE.weakCompareAndSwapLongRelease(base, offset, 1L, 2L); - assertEquals(r, true, "weakCompareAndSwapRelease long"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwapLongRelease(base, offset, 1L, 2L); + } + assertEquals(success, true, "weakCompareAndSwapRelease long"); long x = UNSAFE.getLong(base, offset); assertEquals(x, 2L, "weakCompareAndSwapRelease long"); } @@ -286,7 +296,7 @@ public class JdkInternalMiscUnsafeAccessTestLong { long o = UNSAFE.getAndAddLong(base, offset, 2L); assertEquals(o, 1L, "getAndAdd long"); long x = UNSAFE.getLong(base, offset); - assertEquals(x, 1L + 2L, "weakCompareAndSwapRelease long"); + assertEquals(x, 1L + 2L, "getAndAdd long"); } } @@ -300,4 +310,3 @@ public class JdkInternalMiscUnsafeAccessTestLong { } } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java index 2db2efa9932..a667431f027 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class JdkInternalMiscUnsafeAccessTestObject { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final jdk.internal.misc.Unsafe UNSAFE; @@ -204,22 +205,31 @@ public class JdkInternalMiscUnsafeAccessTestObject { } { - boolean r = UNSAFE.weakCompareAndSwapObject(base, offset, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSwap Object"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwapObject(base, offset, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSwap Object"); Object x = UNSAFE.getObject(base, offset); assertEquals(x, "bar", "weakCompareAndSwap Object value"); } { - boolean r = UNSAFE.weakCompareAndSwapObjectAcquire(base, offset, "bar", "foo"); - assertEquals(r, true, "weakCompareAndSwapAcquire Object"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwapObjectAcquire(base, offset, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSwapAcquire Object"); Object x = UNSAFE.getObject(base, offset); assertEquals(x, "foo", "weakCompareAndSwapAcquire Object"); } { - boolean r = UNSAFE.weakCompareAndSwapObjectRelease(base, offset, "foo", "bar"); - assertEquals(r, true, "weakCompareAndSwapRelease Object"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwapObjectRelease(base, offset, "foo", "bar"); + } + assertEquals(success, true, "weakCompareAndSwapRelease Object"); Object x = UNSAFE.getObject(base, offset); assertEquals(x, "bar", "weakCompareAndSwapRelease Object"); } @@ -236,4 +246,3 @@ public class JdkInternalMiscUnsafeAccessTestObject { } - diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java index 814e0367bf0..a9fab93740b 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestShort.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class JdkInternalMiscUnsafeAccessTestShort { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final jdk.internal.misc.Unsafe UNSAFE; @@ -203,4 +204,3 @@ public class JdkInternalMiscUnsafeAccessTestShort { } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java index 7288954612b..c5349ff404c 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestBoolean.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class SunMiscUnsafeAccessTestBoolean { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final sun.misc.Unsafe UNSAFE; @@ -131,9 +132,7 @@ public class SunMiscUnsafeAccessTestBoolean { - } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java index 928f51790e6..24ab3f86ff9 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestByte.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class SunMiscUnsafeAccessTestByte { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final sun.misc.Unsafe UNSAFE; @@ -160,7 +161,6 @@ public class SunMiscUnsafeAccessTestByte { - } static void testAccess(long address) { @@ -173,4 +173,3 @@ public class SunMiscUnsafeAccessTestByte { } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java index 48aa82f9a53..70004792886 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestChar.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class SunMiscUnsafeAccessTestChar { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final sun.misc.Unsafe UNSAFE; @@ -160,7 +161,6 @@ public class SunMiscUnsafeAccessTestChar { - } static void testAccess(long address) { @@ -173,4 +173,3 @@ public class SunMiscUnsafeAccessTestChar { } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java index 0902911046d..9300fc0c17d 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestDouble.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class SunMiscUnsafeAccessTestDouble { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final sun.misc.Unsafe UNSAFE; @@ -160,7 +161,6 @@ public class SunMiscUnsafeAccessTestDouble { - } static void testAccess(long address) { @@ -173,4 +173,3 @@ public class SunMiscUnsafeAccessTestDouble { } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java index 41056dc3b2e..39a3f51b497 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestFloat.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class SunMiscUnsafeAccessTestFloat { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final sun.misc.Unsafe UNSAFE; @@ -160,7 +161,6 @@ public class SunMiscUnsafeAccessTestFloat { - } static void testAccess(long address) { @@ -173,4 +173,3 @@ public class SunMiscUnsafeAccessTestFloat { } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java index ecf79ee392e..45cb6ffbd3d 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class SunMiscUnsafeAccessTestInt { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final sun.misc.Unsafe UNSAFE; @@ -165,7 +166,6 @@ public class SunMiscUnsafeAccessTestInt { - UNSAFE.putInt(base, offset, 1); // Compare @@ -184,7 +184,6 @@ public class SunMiscUnsafeAccessTestInt { } - // Compare set and get { int o = UNSAFE.getAndSetInt(base, offset, 1); @@ -200,7 +199,7 @@ public class SunMiscUnsafeAccessTestInt { int o = UNSAFE.getAndAddInt(base, offset, 2); assertEquals(o, 1, "getAndAdd int"); int x = UNSAFE.getInt(base, offset); - assertEquals(x, 1 + 2, "weakCompareAndSwapRelease int"); + assertEquals(x, 1 + 2, "getAndAdd int"); } } @@ -214,4 +213,3 @@ public class SunMiscUnsafeAccessTestInt { } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java index 4a9b4805fc7..de0ddf5d301 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class SunMiscUnsafeAccessTestLong { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final sun.misc.Unsafe UNSAFE; @@ -165,7 +166,6 @@ public class SunMiscUnsafeAccessTestLong { - UNSAFE.putLong(base, offset, 1L); // Compare @@ -184,7 +184,6 @@ public class SunMiscUnsafeAccessTestLong { } - // Compare set and get { long o = UNSAFE.getAndSetLong(base, offset, 1L); @@ -200,7 +199,7 @@ public class SunMiscUnsafeAccessTestLong { long o = UNSAFE.getAndAddLong(base, offset, 2L); assertEquals(o, 1L, "getAndAdd long"); long x = UNSAFE.getLong(base, offset); - assertEquals(x, 1L + 2L, "weakCompareAndSwapRelease long"); + assertEquals(x, 1L + 2L, "getAndAdd long"); } } @@ -214,4 +213,3 @@ public class SunMiscUnsafeAccessTestLong { } } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java index efb15090f0e..a4d2aba6699 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class SunMiscUnsafeAccessTestObject { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final sun.misc.Unsafe UNSAFE; @@ -136,7 +137,6 @@ public class SunMiscUnsafeAccessTestObject { - UNSAFE.putObject(base, offset, "foo"); // Compare @@ -155,7 +155,6 @@ public class SunMiscUnsafeAccessTestObject { } - // Compare set and get { Object o = UNSAFE.getAndSetObject(base, offset, "foo"); @@ -168,4 +167,3 @@ public class SunMiscUnsafeAccessTestObject { } - diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java index 4e4cda0458c..c8c7284e905 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestShort.java @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class SunMiscUnsafeAccessTestShort { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final sun.misc.Unsafe UNSAFE; @@ -160,7 +161,6 @@ public class SunMiscUnsafeAccessTestShort { - } static void testAccess(long address) { @@ -173,4 +173,3 @@ public class SunMiscUnsafeAccessTestShort { } } - diff --git a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template index e1957e00a83..0af2e805b36 100644 --- a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template +++ b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template @@ -40,6 +40,7 @@ import static org.testng.Assert.*; public class $Qualifier$UnsafeAccessTest$Type$ { static final int ITERS = Integer.getInteger("iters", 1); + static final int WEAK_ATTEMPTS = Integer.getInteger("weakAttempts", 10); static final $package$.Unsafe UNSAFE; @@ -273,22 +274,31 @@ public class $Qualifier$UnsafeAccessTest$Type$ { } { - boolean r = UNSAFE.weakCompareAndSwap$Type$(base, offset, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSwap $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwap$Type$(base, offset, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSwap $type$"); $type$ x = UNSAFE.get$Type$(base, offset); assertEquals(x, $value2$, "weakCompareAndSwap $type$ value"); } { - boolean r = UNSAFE.weakCompareAndSwap$Type$Acquire(base, offset, $value2$, $value1$); - assertEquals(r, true, "weakCompareAndSwapAcquire $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwap$Type$Acquire(base, offset, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSwapAcquire $type$"); $type$ x = UNSAFE.get$Type$(base, offset); assertEquals(x, $value1$, "weakCompareAndSwapAcquire $type$"); } { - boolean r = UNSAFE.weakCompareAndSwap$Type$Release(base, offset, $value1$, $value2$); - assertEquals(r, true, "weakCompareAndSwapRelease $type$"); + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwap$Type$Release(base, offset, $value1$, $value2$); + } + assertEquals(success, true, "weakCompareAndSwapRelease $type$"); $type$ x = UNSAFE.get$Type$(base, offset); assertEquals(x, $value2$, "weakCompareAndSwapRelease $type$"); } @@ -311,7 +321,7 @@ public class $Qualifier$UnsafeAccessTest$Type$ { $type$ o = UNSAFE.getAndAdd$Type$(base, offset, $value2$); assertEquals(o, $value1$, "getAndAdd $type$"); $type$ x = UNSAFE.get$Type$(base, offset); - assertEquals(x, $value1$ + $value2$, "weakCompareAndSwapRelease $type$"); + assertEquals(x, $value1$ + $value2$, "getAndAdd $type$"); } #end[AtomicAdd] } diff --git a/hotspot/test/compiler/unsafe/generate-unsafe-tests.sh b/hotspot/test/compiler/unsafe/generate-unsafe-tests.sh deleted file mode 100644 index a20c45afa86..00000000000 --- a/hotspot/test/compiler/unsafe/generate-unsafe-tests.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash - -javac -d . ../../../../jdk/make/src/classes/build/tools/spp/Spp.java - -SPP=build.tools.spp.Spp - -# Generates unsafe access tests for objects and all primitive types -# $1 = package name to Unsafe, sun.misc | jdk.internal.misc -# $2 = test class qualifier name, SunMisc | JdkInternalMisc -function generate { - package=$1 - Qualifier=$2 - - for type in boolean byte short char int long float double Object - do - Type="$(tr '[:lower:]' '[:upper:]' <<< ${type:0:1})${type:1}" - args="-K$type -Dtype=$type -DType=$Type" - - case $type in - Object|int|long) - args="$args -KCAS -KOrdered" - ;; - esac - - case $type in - int|long) - args="$args -KAtomicAdd" - ;; - esac - - case $type in - short|char|int|long) - args="$args -KUnaligned" - ;; - esac - - case $type in - boolean) - value1=true - value2=false - value3=false - ;; - byte) - value1=(byte)1 - value2=(byte)2 - value3=(byte)3 - ;; - short) - value1=(short)1 - value2=(short)2 - value3=(short)3 - ;; - char) - value1=\'a\' - value2=\'b\' - value3=\'c\' - ;; - int) - value1=1 - value2=2 - value3=3 - ;; - long) - value1=1L - value2=2L - value3=3L - ;; - float) - value1=1.0f - value2=2.0f - value3=3.0f - ;; - double) - value1=1.0d - value2=2.0d - value3=3.0d - ;; - Object) - value1=\"foo\" - value2=\"bar\" - value3=\"baz\" - ;; - esac - - args="$args -Dvalue1=$value1 -Dvalue2=$value2 -Dvalue3=$value3" - - echo $args - - java $SPP -nel -K$Qualifier -Dpackage=$package -DQualifier=$Qualifier \ - $args < X-UnsafeAccessTest.java.template > ${Qualifier}UnsafeAccessTest${Type}.java - done -} - -generate sun.misc SunMisc -generate jdk.internal.misc JdkInternalMisc - -rm -fr build \ No newline at end of file -- GitLab From 0ab61a6e28244ecd21fb13879825c272951cb2f3 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Wed, 4 May 2016 13:32:03 -0700 Subject: [PATCH 276/400] 8155717: Aarch64: enable loop superword's unrolling analysis Reviewed-by: aph, kvn, mcberg --- hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp | 2 +- hotspot/src/share/vm/opto/superword.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp index f4170aeb85b..865ee69d1f7 100644 --- a/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/c2_globals_aarch64.hpp @@ -71,7 +71,7 @@ define_pd_global(bool, UseCISCSpill, true); define_pd_global(bool, OptoScheduling, false); define_pd_global(bool, OptoBundling, false); define_pd_global(bool, OptoRegScheduling, false); -define_pd_global(bool, SuperWordLoopUnrollAnalysis, false); +define_pd_global(bool, SuperWordLoopUnrollAnalysis, true); define_pd_global(intx, ReservedCodeCacheSize, 48*M); define_pd_global(intx, NonProfiledCodeHeapSize, 21*M); diff --git a/hotspot/src/share/vm/opto/superword.cpp b/hotspot/src/share/vm/opto/superword.cpp index f3a6539a2d2..695ab06c573 100644 --- a/hotspot/src/share/vm/opto/superword.cpp +++ b/hotspot/src/share/vm/opto/superword.cpp @@ -198,7 +198,7 @@ void SuperWord::unrolling_analysis(int &local_loop_unroll_factor) { ignored_loop_nodes[i] = -1; } - int max_vector = Matcher::max_vector_size(T_INT); + int max_vector = Matcher::max_vector_size(T_BYTE); bool post_loop_allowed = (PostLoopMultiversioning && Matcher::has_predicated_vectors() && cl->is_post_loop()); // Process the loop, some/all of the stack entries will not be in order, ergo -- GitLab From 160798c7e76fa006035cf8301158326b28bb5a75 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Fri, 29 Apr 2016 17:24:16 +0200 Subject: [PATCH 277/400] 8154943: AArch64: redundant address computation instructions with vectorization Duplicated i2l nodes can be eliminated to optimize redundant address computations Reviewed-by: kvn, dlong --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 2 ++ hotspot/src/cpu/ppc/vm/ppc.ad | 2 ++ hotspot/src/cpu/sparc/vm/sparc.ad | 2 ++ hotspot/src/cpu/x86/vm/x86.ad | 2 ++ hotspot/src/share/vm/opto/compile.cpp | 37 +++++++++++++++++++++++++++ hotspot/src/share/vm/opto/matcher.hpp | 3 +++ hotspot/src/share/vm/opto/node.cpp | 3 ++- 7 files changed, 50 insertions(+), 1 deletion(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index 8b4905d4bae..bc94004dfd7 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -3566,6 +3566,8 @@ const RegMask Matcher::method_handle_invoke_SP_save_mask() { return FP_REG_mask(); } +const bool Matcher::convi2l_type_required = false; + // helper for encoding java_to_runtime calls on sim // // this is needed to compute the extra arguments required when diff --git a/hotspot/src/cpu/ppc/vm/ppc.ad b/hotspot/src/cpu/ppc/vm/ppc.ad index d6d7575d005..b2b6ba500ea 100644 --- a/hotspot/src/cpu/ppc/vm/ppc.ad +++ b/hotspot/src/cpu/ppc/vm/ppc.ad @@ -2313,6 +2313,8 @@ const RegMask Matcher::method_handle_invoke_SP_save_mask() { return RegMask(); } +const bool Matcher::convi2l_type_required = true; + %} //----------ENCODING BLOCK----------------------------------------------------- diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad index 079c45146d2..7e610507004 100644 --- a/hotspot/src/cpu/sparc/vm/sparc.ad +++ b/hotspot/src/cpu/sparc/vm/sparc.ad @@ -2133,6 +2133,8 @@ const RegMask Matcher::method_handle_invoke_SP_save_mask() { return L7_REGP_mask(); } +const bool Matcher::convi2l_type_required = true; + %} diff --git a/hotspot/src/cpu/x86/vm/x86.ad b/hotspot/src/cpu/x86/vm/x86.ad index 50e3d136bf0..dc9a734c7f1 100644 --- a/hotspot/src/cpu/x86/vm/x86.ad +++ b/hotspot/src/cpu/x86/vm/x86.ad @@ -1861,6 +1861,8 @@ const bool Matcher::pass_original_key_for_aes() { return false; } +const bool Matcher::convi2l_type_required = true; + // Helper methods for MachSpillCopyNode::implementation(). static int vec_mov_helper(CodeBuffer *cbuf, bool do_size, int src_lo, int dst_lo, int src_hi, int dst_hi, uint ireg, outputStream* st) { diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index 2ccdaffa239..cecd3098214 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -3263,6 +3263,43 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { frc._tests.push(iff); break; } + case Op_ConvI2L: { + if (!Matcher::convi2l_type_required) { + // Code generation on some platforms doesn't need accurate + // ConvI2L types. Widening the type can help remove redundant + // address computations. + n->as_Type()->set_type(TypeLong::INT); + ResourceMark rm; + Node_List wq; + wq.push(n); + for (uint next = 0; next < wq.size(); next++) { + Node *m = wq.at(next); + + for(;;) { + // Loop over all nodes with identical inputs edges as m + Node* k = m->find_similar(m->Opcode()); + if (k == NULL) { + break; + } + // Push their uses so we get a chance to remove node made + // redundant + for (DUIterator_Fast imax, i = k->fast_outs(imax); i < imax; i++) { + Node* u = k->fast_out(i); + assert(!wq.contains(u), "shouldn't process one node several times"); + if (u->Opcode() == Op_LShiftL || + u->Opcode() == Op_AddL || + u->Opcode() == Op_SubL || + u->Opcode() == Op_AddP) { + wq.push(u); + } + } + // Replace all nodes with identical edges as m with m + k->subsume_by(m, this); + } + } + } + break; + } default: assert( !n->is_Call(), "" ); assert( !n->is_Mem(), "" ); diff --git a/hotspot/src/share/vm/opto/matcher.hpp b/hotspot/src/share/vm/opto/matcher.hpp index c9752ebc45f..aa9311d7788 100644 --- a/hotspot/src/share/vm/opto/matcher.hpp +++ b/hotspot/src/share/vm/opto/matcher.hpp @@ -488,6 +488,9 @@ public: // ourselves. static const bool need_masked_shift_count; + // Whether code generation need accurate ConvI2L types. + static const bool convi2l_type_required; + // This routine is run whenever a graph fails to match. // If it returns, the compiler should bailout to interpreter without error. // In non-product mode, SoftMatchFailure is false to detect non-canonical diff --git a/hotspot/src/share/vm/opto/node.cpp b/hotspot/src/share/vm/opto/node.cpp index 2973183f91f..6d8b13a59bc 100644 --- a/hotspot/src/share/vm/opto/node.cpp +++ b/hotspot/src/share/vm/opto/node.cpp @@ -2297,7 +2297,8 @@ Node* Node::find_similar(int opc) { if (def && def->outcnt() >= 2) { for (DUIterator_Fast dmax, i = def->fast_outs(dmax); i < dmax; i++) { Node* use = def->fast_out(i); - if (use->Opcode() == opc && + if (use != this && + use->Opcode() == opc && use->req() == req()) { uint j; for (j = 0; j < use->req(); j++) { -- GitLab From 323c1d5dbffe950acdfd94538ca1866ea79a20c8 Mon Sep 17 00:00:00 2001 From: Cheleswer Sahu Date: Mon, 2 May 2016 13:28:08 +0530 Subject: [PATCH 278/400] 8054326: Confusing message in "Current rem set statistics" Reviewed-by: pliden, kevinw --- .../src/share/vm/gc/g1/g1RemSetSummary.cpp | 61 +++++++++++-------- 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1RemSetSummary.cpp b/hotspot/src/share/vm/gc/g1/g1RemSetSummary.cpp index 25da0b03f54..53fe119389b 100644 --- a/hotspot/src/share/vm/gc/g1/g1RemSetSummary.cpp +++ b/hotspot/src/share/vm/gc/g1/g1RemSetSummary.cpp @@ -144,10 +144,6 @@ void G1RemSetSummary::subtract_from(G1RemSetSummary* other) { _sampling_thread_vtime = other->sampling_thread_vtime() - _sampling_thread_vtime; } -static size_t round_to_K(size_t value) { - return value / K; -} - class RegionTypeCounter VALUE_OBJ_CLASS_SPEC { private: const char* _name; @@ -198,8 +194,10 @@ public: size_t code_root_elems() const { return _code_root_elems; } void print_rs_mem_info_on(outputStream * out, size_t total) { - out->print_cr(" " SIZE_FORMAT_W(8) "K (%5.1f%%) by " SIZE_FORMAT " %s regions", - round_to_K(rs_mem_size()), rs_mem_size_percent_of(total), amount(), _name); + out->print_cr(" " SIZE_FORMAT_W(8) "%s (%5.1f%%) by " SIZE_FORMAT " %s regions", + byte_size_in_proper_unit(rs_mem_size()), + proper_unit_for_byte_size(rs_mem_size()), + rs_mem_size_percent_of(total), amount(), _name); } void print_cards_occupied_info_on(outputStream * out, size_t total) { @@ -208,8 +206,10 @@ public: } void print_code_root_mem_info_on(outputStream * out, size_t total) { - out->print_cr(" " SIZE_FORMAT_W(8) "K (%5.1f%%) by " SIZE_FORMAT " %s regions", - round_to_K(code_root_mem_size()), code_root_mem_size_percent_of(total), amount(), _name); + out->print_cr(" " SIZE_FORMAT_W(8) "%s (%5.1f%%) by " SIZE_FORMAT " %s regions", + byte_size_in_proper_unit(code_root_mem_size()), + proper_unit_for_byte_size(code_root_mem_size()), + code_root_mem_size_percent_of(total), amount(), _name); } void print_code_root_elems_info_on(outputStream * out, size_t total) { @@ -291,17 +291,22 @@ public: RegionTypeCounter* counters[] = { &_young, &_humongous, &_free, &_old, NULL }; out->print_cr(" Current rem set statistics"); - out->print_cr(" Total per region rem sets sizes = " SIZE_FORMAT "K." - " Max = " SIZE_FORMAT "K.", - round_to_K(total_rs_mem_sz()), round_to_K(max_rs_mem_sz())); + out->print_cr(" Total per region rem sets sizes = " SIZE_FORMAT "%s." + " Max = " SIZE_FORMAT "%s.", + byte_size_in_proper_unit(total_rs_mem_sz()), + proper_unit_for_byte_size(total_rs_mem_sz()), + byte_size_in_proper_unit(max_rs_mem_sz()), + proper_unit_for_byte_size(max_rs_mem_sz())); for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) { (*current)->print_rs_mem_info_on(out, total_rs_mem_sz()); } - out->print_cr(" Static structures = " SIZE_FORMAT "K," - " free_lists = " SIZE_FORMAT "K.", - round_to_K(HeapRegionRemSet::static_mem_size()), - round_to_K(HeapRegionRemSet::fl_mem_size())); + out->print_cr(" Static structures = " SIZE_FORMAT "%s," + " free_lists = " SIZE_FORMAT "%s.", + byte_size_in_proper_unit(HeapRegionRemSet::static_mem_size()), + proper_unit_for_byte_size(HeapRegionRemSet::static_mem_size()), + byte_size_in_proper_unit(HeapRegionRemSet::fl_mem_size()), + proper_unit_for_byte_size(HeapRegionRemSet::fl_mem_size())); out->print_cr(" " SIZE_FORMAT " occupied cards represented.", total_cards_occupied()); @@ -312,17 +317,20 @@ public: // Largest sized rem set region statistics HeapRegionRemSet* rem_set = max_rs_mem_sz_region()->rem_set(); out->print_cr(" Region with largest rem set = " HR_FORMAT ", " - "size = " SIZE_FORMAT "K, occupied = " SIZE_FORMAT "K.", + "size = " SIZE_FORMAT "%s, occupied = " SIZE_FORMAT "%s.", HR_FORMAT_PARAMS(max_rs_mem_sz_region()), - round_to_K(rem_set->mem_size()), - round_to_K(rem_set->occupied())); - + byte_size_in_proper_unit(rem_set->mem_size()), + proper_unit_for_byte_size(rem_set->mem_size()), + byte_size_in_proper_unit(rem_set->occupied()), + proper_unit_for_byte_size(rem_set->occupied())); // Strong code root statistics HeapRegionRemSet* max_code_root_rem_set = max_code_root_mem_sz_region()->rem_set(); - out->print_cr(" Total heap region code root sets sizes = " SIZE_FORMAT "K." - " Max = " SIZE_FORMAT "K.", - round_to_K(total_code_root_mem_sz()), - round_to_K(max_code_root_rem_set->strong_code_roots_mem_size())); + out->print_cr(" Total heap region code root sets sizes = " SIZE_FORMAT "%s." + " Max = " SIZE_FORMAT "%s.", + byte_size_in_proper_unit(total_code_root_mem_sz()), + proper_unit_for_byte_size(total_code_root_mem_sz()), + byte_size_in_proper_unit(max_code_root_rem_set->strong_code_roots_mem_size()), + proper_unit_for_byte_size(max_code_root_rem_set->strong_code_roots_mem_size())); for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) { (*current)->print_code_root_mem_info_on(out, total_code_root_mem_sz()); } @@ -334,10 +342,11 @@ public: } out->print_cr(" Region with largest amount of code roots = " HR_FORMAT ", " - "size = " SIZE_FORMAT "K, num_elems = " SIZE_FORMAT ".", + "size = " SIZE_FORMAT "%s, num_elems = " SIZE_FORMAT ".", HR_FORMAT_PARAMS(max_code_root_mem_sz_region()), - round_to_K(max_code_root_rem_set->strong_code_roots_mem_size()), - round_to_K(max_code_root_rem_set->strong_code_roots_list_length())); + byte_size_in_proper_unit(max_code_root_rem_set->strong_code_roots_mem_size()), + proper_unit_for_byte_size(max_code_root_rem_set->strong_code_roots_mem_size()), + max_code_root_rem_set->strong_code_roots_list_length()); } }; -- GitLab From 9cad8a6125a894a011acfdfbe443d4dd99c570b5 Mon Sep 17 00:00:00 2001 From: Mikael Gerdin Date: Wed, 4 May 2016 13:12:23 +0200 Subject: [PATCH 279/400] 8155943: Move G1Eden/SurvivorRegions into their own source files Reviewed-by: sjohanss, ehelin --- .../src/share/vm/gc/g1/g1CollectedHeap.hpp | 9 ++-- .../src/share/vm/gc/g1/g1DefaultPolicy.cpp | 2 +- hotspot/src/share/vm/gc/g1/g1EdenRegions.hpp | 50 +++++++++++++++++++ hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp | 1 - .../{youngList.cpp => g1SurvivorRegions.cpp} | 6 +-- .../{youngList.hpp => g1SurvivorRegions.hpp} | 21 ++------ 6 files changed, 61 insertions(+), 28 deletions(-) create mode 100644 hotspot/src/share/vm/gc/g1/g1EdenRegions.hpp rename hotspot/src/share/vm/gc/g1/{youngList.cpp => g1SurvivorRegions.cpp} (92%) rename hotspot/src/share/vm/gc/g1/{youngList.hpp => g1SurvivorRegions.hpp} (81%) diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp index ced20c1f172..66699651b6d 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.hpp @@ -31,18 +31,19 @@ #include "gc/g1/g1CollectionSet.hpp" #include "gc/g1/g1CollectorState.hpp" #include "gc/g1/g1ConcurrentMark.hpp" -#include "gc/g1/g1HRPrinter.hpp" -#include "gc/g1/g1InCSetState.hpp" -#include "gc/g1/g1MonitoringSupport.hpp" +#include "gc/g1/g1EdenRegions.hpp" #include "gc/g1/g1EvacFailure.hpp" #include "gc/g1/g1EvacStats.hpp" #include "gc/g1/g1HeapVerifier.hpp" +#include "gc/g1/g1HRPrinter.hpp" +#include "gc/g1/g1InCSetState.hpp" +#include "gc/g1/g1MonitoringSupport.hpp" #include "gc/g1/g1SATBCardTableModRefBS.hpp" +#include "gc/g1/g1SurvivorRegions.hpp" #include "gc/g1/g1YCTypes.hpp" #include "gc/g1/hSpaceCounters.hpp" #include "gc/g1/heapRegionManager.hpp" #include "gc/g1/heapRegionSet.hpp" -#include "gc/g1/youngList.hpp" #include "gc/shared/barrierSet.hpp" #include "gc/shared/collectedHeap.hpp" #include "gc/shared/plab.hpp" diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index 340125ea9ce..3c8eae8afee 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -34,10 +34,10 @@ #include "gc/g1/g1IHOPControl.hpp" #include "gc/g1/g1GCPhaseTimes.hpp" #include "gc/g1/g1Policy.hpp" +#include "gc/g1/g1SurvivorRegions.hpp" #include "gc/g1/g1YoungGenSizer.hpp" #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" -#include "gc/g1/youngList.hpp" #include "gc/shared/gcPolicyCounters.hpp" #include "logging/logStream.hpp" #include "runtime/arguments.hpp" diff --git a/hotspot/src/share/vm/gc/g1/g1EdenRegions.hpp b/hotspot/src/share/vm/gc/g1/g1EdenRegions.hpp new file mode 100644 index 00000000000..c83261b27b3 --- /dev/null +++ b/hotspot/src/share/vm/gc/g1/g1EdenRegions.hpp @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_GC_G1_G1EDENREGIONS_HPP +#define SHARE_VM_GC_G1_G1EDENREGIONS_HPP + +#include "gc/g1/heapRegion.hpp" +#include "memory/allocation.hpp" +#include "runtime/globals.hpp" +#include "utilities/debug.hpp" + +class G1EdenRegions VALUE_OBJ_CLASS_SPEC { +private: + int _length; + +public: + G1EdenRegions() : _length(0) {} + + void add(HeapRegion* hr) { + assert(!hr->is_eden(), "should not already be set"); + _length++; + } + + void clear() { _length = 0; } + + uint length() const { return _length; } +}; + +#endif // SHARE_VM_GC_G1_G1EDENREGIONS_HPP diff --git a/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp b/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp index 9ebfa4d2247..b8093e4fb94 100644 --- a/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp +++ b/hotspot/src/share/vm/gc/g1/g1HeapVerifier.cpp @@ -36,7 +36,6 @@ #include "gc/g1/heapRegion.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" #include "gc/g1/g1StringDedup.hpp" -#include "gc/g1/youngList.hpp" #include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" diff --git a/hotspot/src/share/vm/gc/g1/youngList.cpp b/hotspot/src/share/vm/gc/g1/g1SurvivorRegions.cpp similarity index 92% rename from hotspot/src/share/vm/gc/g1/youngList.cpp rename to hotspot/src/share/vm/gc/g1/g1SurvivorRegions.cpp index d4694de1071..ec49aea984d 100644 --- a/hotspot/src/share/vm/gc/g1/youngList.cpp +++ b/hotspot/src/share/vm/gc/g1/g1SurvivorRegions.cpp @@ -23,8 +23,8 @@ */ #include "precompiled.hpp" +#include "gc/g1/g1SurvivorRegions.hpp" #include "gc/g1/heapRegion.hpp" -#include "gc/g1/youngList.hpp" #include "utilities/growableArray.hpp" #include "utilities/debug.hpp" @@ -53,7 +53,3 @@ void G1SurvivorRegions::clear() { _regions->clear(); } -void G1EdenRegions::add(HeapRegion* hr) { - assert(!hr->is_eden(), "should not already be set"); - _length++; -} diff --git a/hotspot/src/share/vm/gc/g1/youngList.hpp b/hotspot/src/share/vm/gc/g1/g1SurvivorRegions.hpp similarity index 81% rename from hotspot/src/share/vm/gc/g1/youngList.hpp rename to hotspot/src/share/vm/gc/g1/g1SurvivorRegions.hpp index 0555ffb0057..9a8333782d7 100644 --- a/hotspot/src/share/vm/gc/g1/youngList.hpp +++ b/hotspot/src/share/vm/gc/g1/g1SurvivorRegions.hpp @@ -22,14 +22,15 @@ * */ -#ifndef SHARE_VM_GC_G1_YOUNGLIST_HPP -#define SHARE_VM_GC_G1_YOUNGLIST_HPP +#ifndef SHARE_VM_GC_G1_G1SURVIVORREGIONS_HPP +#define SHARE_VM_GC_G1_G1SURVIVORREGIONS_HPP #include "memory/allocation.hpp" #include "runtime/globals.hpp" template class GrowableArray; +class HeapRegion; class G1SurvivorRegions VALUE_OBJ_CLASS_SPEC { private: @@ -51,18 +52,4 @@ public: } }; -class G1EdenRegions VALUE_OBJ_CLASS_SPEC { -private: - int _length; - -public: - G1EdenRegions() : _length(0) {} - - void add(HeapRegion* hr); - - void clear() { _length = 0; } - - uint length() const { return _length; } -}; - -#endif // SHARE_VM_GC_G1_YOUNGLIST_HPP +#endif // SHARE_VM_GC_G1_G1SURVIVORREGIONS_HPP -- GitLab From 094416e1ecc5979741f6f81e4eab965ca64ddddc Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Wed, 4 May 2016 17:47:05 +0300 Subject: [PATCH 280/400] 8155946: Minimal VM fails to built after 8154153: PS: Restore preserved marks in parallel Reviewed-by: stefank --- hotspot/src/share/vm/gc/shared/preservedMarks.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/gc/shared/preservedMarks.cpp b/hotspot/src/share/vm/gc/shared/preservedMarks.cpp index c1a2729fc36..9312c198483 100644 --- a/hotspot/src/share/vm/gc/shared/preservedMarks.cpp +++ b/hotspot/src/share/vm/gc/shared/preservedMarks.cpp @@ -23,11 +23,14 @@ */ #include "precompiled.hpp" -#include "gc/parallel/gcTaskManager.hpp" #include "gc/shared/preservedMarks.inline.hpp" #include "gc/shared/workgroup.hpp" #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" +#include "utilities/macros.hpp" +#if INCLUDE_ALL_GCS +#include "gc/parallel/gcTaskManager.hpp" +#endif void PreservedMarks::restore() { while (!_stack.is_empty()) { @@ -108,6 +111,7 @@ void PreservedMarksSet::restore_internal(WorkGang* workers, workers->run_task(&task); } +#if INCLUDE_ALL_GCS class ParRestoreGCTask : public GCTask { private: const uint _id; @@ -146,6 +150,7 @@ void PreservedMarksSet::restore_internal(GCTaskManager* gc_task_manager, } gc_task_manager->execute_and_wait(q); } +#endif void PreservedMarksSet::reclaim() { assert_empty(); -- GitLab From 06e3a5cb60bb1aca92cd35329035ea93c5ec0077 Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Wed, 4 May 2016 15:32:26 -0400 Subject: [PATCH 281/400] 8156066: Backout JDK-8153892 Reviewed-by: coleenp, mikael --- hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp | 13 ++++ .../src/cpu/sparc/vm/stubGenerator_sparc.cpp | 75 ++++++++++++++++++- .../src/cpu/x86/vm/stubGenerator_x86_32.cpp | 41 +++++++++- .../src/cpu/x86/vm/stubGenerator_x86_64.cpp | 46 +++++++++++- .../src/cpu/zero/vm/stubGenerator_zero.cpp | 6 +- hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp | 16 ++-- hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp | 6 +- .../linux_aarch64/vm/os_linux_aarch64.cpp | 23 +++++- .../src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp | 14 ++-- .../os_cpu/linux_sparc/vm/os_linux_sparc.cpp | 8 +- .../src/os_cpu/linux_x86/vm/os_linux_x86.cpp | 6 +- .../solaris_sparc/vm/os_solaris_sparc.cpp | 4 +- .../os_cpu/solaris_x86/vm/os_solaris_x86.cpp | 6 +- .../src/share/vm/runtime/sharedRuntime.cpp | 15 ---- .../src/share/vm/runtime/sharedRuntime.hpp | 2 - hotspot/src/share/vm/runtime/stubRoutines.cpp | 1 + hotspot/src/share/vm/runtime/stubRoutines.hpp | 5 ++ 17 files changed, 233 insertions(+), 54 deletions(-) diff --git a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp index 58222baa2fa..2eba3edacef 100644 --- a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp @@ -825,6 +825,17 @@ class StubGenerator: public StubCodeGenerator { return start; } + // The following routine generates a subroutine to throw an asynchronous + // UnknownError when an unsafe access gets a fault that could not be + // reasonably prevented by the programmer. (Example: SIGBUS/OBJERR.) + // + address generate_handler_for_unsafe_access() { + StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); + address start = __ function_entry(); + __ unimplemented("StubRoutines::handler_for_unsafe_access", 93); + return start; + } + #if !defined(PRODUCT) // Wrapper which calls oopDesc::is_oop_or_null() // Only called by MacroAssembler::verify_oop @@ -3100,6 +3111,8 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError), false); 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); + StubRoutines::_handler_for_unsafe_access_entry = generate_handler_for_unsafe_access(); + // support for verify_oop (must happen after universe_init) StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop(); diff --git a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp index efac738816a..db2c5eefac8 100644 --- a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,6 +64,20 @@ static const Register& Lstub_temp = L2; // ------------------------------------------------------------------------------------------------------------------------- // Stub Code definitions +static address handle_unsafe_access() { + JavaThread* thread = JavaThread::current(); + address pc = thread->saved_exception_pc(); + address npc = thread->saved_exception_npc(); + // pc is the instruction which we must emulate + // doing a no-op is fine: return garbage from the load + + // request an async exception + thread->set_pending_unsafe_access_error(); + + // return address of next instruction to execute + return npc; +} + class StubGenerator: public StubCodeGenerator { private: @@ -732,6 +746,62 @@ class StubGenerator: public StubCodeGenerator { Label _atomic_add_stub; // called from other stubs + //------------------------------------------------------------------------------------------------------------------------ + // The following routine generates a subroutine to throw an asynchronous + // UnknownError when an unsafe access gets a fault that could not be + // reasonably prevented by the programmer. (Example: SIGBUS/OBJERR.) + // + // Arguments : + // + // trapping PC: O7 + // + // Results: + // posts an asynchronous exception, skips the trapping instruction + // + + address generate_handler_for_unsafe_access() { + StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); + address start = __ pc(); + + const int preserve_register_words = (64 * 2); + Address preserve_addr(FP, (-preserve_register_words * wordSize) + STACK_BIAS); + + Register Lthread = L7_thread_cache; + int i; + + __ save_frame(0); + __ mov(G1, L1); + __ mov(G2, L2); + __ mov(G3, L3); + __ mov(G4, L4); + __ mov(G5, L5); + for (i = 0; i < 64; i += 2) { + __ stf(FloatRegisterImpl::D, as_FloatRegister(i), preserve_addr, i * wordSize); + } + + address entry_point = CAST_FROM_FN_PTR(address, handle_unsafe_access); + BLOCK_COMMENT("call handle_unsafe_access"); + __ call(entry_point, relocInfo::runtime_call_type); + __ delayed()->nop(); + + __ mov(L1, G1); + __ mov(L2, G2); + __ mov(L3, G3); + __ mov(L4, G4); + __ mov(L5, G5); + for (i = 0; i < 64; i += 2) { + __ ldf(FloatRegisterImpl::D, preserve_addr, as_FloatRegister(i), i * wordSize); + } + + __ verify_thread(); + + __ jmp(O0, 0); + __ delayed()->restore(); + + return start; + } + + // Support for uint StubRoutine::Sparc::partial_subtype_check( Klass sub, Klass super ); // Arguments : // @@ -5310,6 +5380,9 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError)); StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call)); + StubRoutines::_handler_for_unsafe_access_entry = + generate_handler_for_unsafe_access(); + // support for verify_oop (must happen after universe_init) StubRoutines::_verify_oop_subroutine_entry = generate_verify_oop_subroutine(); diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp index adcfe63b39f..66a819a07f7 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,6 +63,21 @@ const int FPU_CNTRL_WRD_MASK = 0xFFFF; // ------------------------------------------------------------------------------------------------------------------------- // Stub Code definitions +static address handle_unsafe_access() { + JavaThread* thread = JavaThread::current(); + address pc = thread->saved_exception_pc(); + // pc is the instruction which we must emulate + // doing a no-op is fine: return garbage from the load + // therefore, compute npc + address npc = Assembler::locate_next_instruction(pc); + + // request an async exception + thread->set_pending_unsafe_access_error(); + + // return address of next instruction to execute + return npc; +} + class StubGenerator: public StubCodeGenerator { private: @@ -608,6 +623,27 @@ class StubGenerator: public StubCodeGenerator { } + //--------------------------------------------------------------------------- + // The following routine generates a subroutine to throw an asynchronous + // UnknownError when an unsafe access gets a fault that could not be + // reasonably prevented by the programmer. (Example: SIGBUS/OBJERR.) + address generate_handler_for_unsafe_access() { + StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); + address start = __ pc(); + + __ push(0); // hole for return address-to-be + __ pusha(); // push registers + Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord); + BLOCK_COMMENT("call handle_unsafe_access"); + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access))); + __ movptr(next_pc, rax); // stuff next address + __ popa(); + __ ret(0); // jump to next address + + return start; + } + + //---------------------------------------------------------------------------------------------------- // Non-destructive plausibility checks for oops @@ -3829,6 +3865,9 @@ class StubGenerator: public StubCodeGenerator { // These are currently used by Solaris/Intel StubRoutines::_atomic_xchg_entry = generate_atomic_xchg(); + StubRoutines::_handler_for_unsafe_access_entry = + generate_handler_for_unsafe_access(); + // platform dependent create_control_words(); diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp index 9d3bb2d03df..3d8acc78947 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,6 +61,21 @@ const int MXCSR_MASK = 0xFFC0; // Mask out any pending exceptions // Stub Code definitions +static address handle_unsafe_access() { + JavaThread* thread = JavaThread::current(); + address pc = thread->saved_exception_pc(); + // pc is the instruction which we must emulate + // doing a no-op is fine: return garbage from the load + // therefore, compute npc + address npc = Assembler::locate_next_instruction(pc); + + // request an async exception + thread->set_pending_unsafe_access_error(); + + // return address of next instruction to execute + return npc; +} + class StubGenerator: public StubCodeGenerator { private: @@ -974,6 +989,32 @@ class StubGenerator: public StubCodeGenerator { return start; } + // The following routine generates a subroutine to throw an + // asynchronous UnknownError when an unsafe access gets a fault that + // could not be reasonably prevented by the programmer. (Example: + // SIGBUS/OBJERR.) + address generate_handler_for_unsafe_access() { + StubCodeMark mark(this, "StubRoutines", "handler_for_unsafe_access"); + address start = __ pc(); + + __ push(0); // hole for return address-to-be + __ pusha(); // push registers + Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord); + + // FIXME: this probably needs alignment logic + + __ subptr(rsp, frame::arg_reg_save_area_bytes); + BLOCK_COMMENT("call handle_unsafe_access"); + __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access))); + __ addptr(rsp, frame::arg_reg_save_area_bytes); + + __ movptr(next_pc, rax); // stuff next address + __ popa(); + __ ret(0); // jump to next address + + return start; + } + // Non-destructive plausibility checks for oops // // Arguments: @@ -5095,6 +5136,9 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_atomic_add_ptr_entry = generate_atomic_add_ptr(); StubRoutines::_fence_entry = generate_orderaccess_fence(); + StubRoutines::_handler_for_unsafe_access_entry = + generate_handler_for_unsafe_access(); + // platform dependent StubRoutines::x86::_get_previous_fp_entry = generate_get_previous_fp(); StubRoutines::x86::_get_previous_sp_entry = generate_get_previous_sp(); diff --git a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp index 9d64fb99e94..bdaec67cd73 100644 --- a/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp +++ b/hotspot/src/cpu/zero/vm/stubGenerator_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright 2007, 2008, 2010, 2015 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -261,6 +261,10 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_atomic_add_entry = ShouldNotCallThisStub(); StubRoutines::_atomic_add_ptr_entry = ShouldNotCallThisStub(); StubRoutines::_fence_entry = ShouldNotCallThisStub(); + + // amd64 does this here, sparc does it in generate_all() + StubRoutines::_handler_for_unsafe_access_entry = + ShouldNotCallThisStub(); } void generate_all() { diff --git a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp index 211a2dc3323..824d4d7a820 100644 --- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp +++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp @@ -392,9 +392,11 @@ JVM_handle_aix_signal(int sig, siginfo_t* info, void* ucVoid, int abort_if_unrec CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { - address next_pc = pc + 4; - next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); - os::Aix::ucontext_set_pc(uc, next_pc); + // We don't really need a stub here! Just set the pending exeption and + // continue at the next instruction after the faulting read. Returning + // garbage from this read is ok. + thread->set_pending_unsafe_access_error(); + os::Aix::ucontext_set_pc(uc, pc + 4); return 1; } } @@ -413,9 +415,11 @@ JVM_handle_aix_signal(int sig, siginfo_t* info, void* ucVoid, int abort_if_unrec } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && thread->doing_unsafe_access()) { - address next_pc = pc + 4; - next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); - os::Aix::ucontext_set_pc(uc, next_pc); + // We don't really need a stub here! Just set the pending exeption and + // continue at the next instruction after the faulting read. Returning + // garbage from this read is ok. + thread->set_pending_unsafe_access_error(); + os::Aix::ucontext_set_pc(uc, pc + 4); return 1; } } diff --git a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp index 9fe34fc1770..911dfe50fed 100644 --- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp +++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp @@ -584,8 +584,7 @@ JVM_handle_bsd_signal(int sig, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { - address next_pc = Assembler::locate_next_instruction(pc); - stub = SharedRuntime::handle_unsafe_access(thread, next_pc); + stub = StubRoutines::handler_for_unsafe_access(); } } else @@ -656,8 +655,7 @@ JVM_handle_bsd_signal(int sig, } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && /* info->si_code == BUS_OBJERR && */ thread->doing_unsafe_access()) { - address next_pc = Assembler::locate_next_instruction(pc); - stub = SharedRuntime::handle_unsafe_access(thread, next_pc); + stub = StubRoutines::handler_for_unsafe_access(); } // jni_fast_GetField can trap at certain pc's if a GC kicks in diff --git a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp index 04179925e67..e6070b63dd6 100644 --- a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp +++ b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp @@ -226,6 +226,23 @@ extern "C" void FetchNPFI () ; extern "C" void FetchNResume () ; #endif +// An operation in Unsafe has faulted. We're going to return to the +// instruction after the faulting load or store. We also set +// pending_unsafe_access_error so that at some point in the future our +// user will get a helpful message. +static address handle_unsafe_access(JavaThread* thread, address pc) { + // pc is the instruction which we must emulate + // doing a no-op is fine: return garbage from the load + // therefore, compute npc + address npc = pc + NativeCall::instruction_size; + + // request an async exception + thread->set_pending_unsafe_access_error(); + + // return address of next instruction to execute + return npc; +} + extern "C" JNIEXPORT int JVM_handle_linux_signal(int sig, siginfo_t* info, @@ -370,8 +387,7 @@ JVM_handle_linux_signal(int sig, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { - address next_pc = pc + NativeCall::instruction_size; - stub = SharedRuntime::handle_unsafe_access(thread, next_pc); + stub = handle_unsafe_access(thread, pc); } } else @@ -392,8 +408,7 @@ JVM_handle_linux_signal(int sig, } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && /* info->si_code == BUS_OBJERR && */ thread->doing_unsafe_access()) { - address next_pc = pc + NativeCall::instruction_size; - stub = SharedRuntime::handle_unsafe_access(thread, next_pc); + stub = handle_unsafe_access(thread, pc); } // jni_fast_GetField can trap at certain pc's if a GC kicks in diff --git a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp index 8cd04dce290..7ecf0ad8263 100644 --- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp +++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp @@ -366,9 +366,11 @@ JVM_handle_linux_signal(int sig, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { - address next_pc = pc + 4; - next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); - os::Linux::ucontext_set_pc(uc, next_pc); + // We don't really need a stub here! Just set the pending exeption and + // continue at the next instruction after the faulting read. Returning + // garbage from this read is ok. + thread->set_pending_unsafe_access_error(); + os::Linux::ucontext_set_pc(uc, pc + 4); return true; } } @@ -383,8 +385,10 @@ JVM_handle_linux_signal(int sig, } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && thread->doing_unsafe_access()) { - address next_pc = pc + 4; - next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc); + // We don't really need a stub here! Just set the pending exeption and + // continue at the next instruction after the faulting read. Returning + // garbage from this read is ok. + thread->set_pending_unsafe_access_error(); os::Linux::ucontext_set_pc(uc, pc + 4); return true; } diff --git a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp index 4a0da12c498..4f83c606600 100644 --- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp +++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp @@ -433,14 +433,14 @@ inline static bool checkPollingPage(address pc, address fault, address* stub) { return false; } -inline static bool checkByteBuffer(address pc, address npc, address* stub) { +inline static bool checkByteBuffer(address pc, address* stub) { // BugId 4454115: A read from a MappedByteBuffer can fault // here if the underlying file has been truncated. // Do not crash the VM in such a case. CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { - *stub = SharedRuntime::handle_unsafe_access(thread, npc); + *stub = StubRoutines::handler_for_unsafe_access(); return true; } return false; @@ -613,7 +613,7 @@ JVM_handle_linux_signal(int sig, if (sig == SIGBUS && thread->thread_state() == _thread_in_vm && thread->doing_unsafe_access()) { - stub = SharedRuntime::handle_unsafe_access(thread, npc); + stub = StubRoutines::handler_for_unsafe_access(); } if (thread->thread_state() == _thread_in_Java) { @@ -625,7 +625,7 @@ JVM_handle_linux_signal(int sig, break; } - if ((sig == SIGBUS) && checkByteBuffer(pc, npc, &stub)) { + if ((sig == SIGBUS) && checkByteBuffer(pc, &stub)) { break; } diff --git a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp index b73658ed036..7d7aad54046 100644 --- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp +++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp @@ -420,8 +420,7 @@ JVM_handle_linux_signal(int sig, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL; if (nm != NULL && nm->has_unsafe_access()) { - address next_pc = Assembler::locate_next_instruction(pc); - stub = SharedRuntime::handle_unsafe_access(thread, next_pc); + stub = StubRoutines::handler_for_unsafe_access(); } } else @@ -470,8 +469,7 @@ JVM_handle_linux_signal(int sig, } else if (thread->thread_state() == _thread_in_vm && sig == SIGBUS && /* info->si_code == BUS_OBJERR && */ thread->doing_unsafe_access()) { - address next_pc = Assembler::locate_next_instruction(pc); - stub = SharedRuntime::handle_unsafe_access(thread, next_pc); + stub = StubRoutines::handler_for_unsafe_access(); } // jni_fast_GetField can trap at certain pc's if a GC kicks in diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp index 39663ed0e74..0fd9adf3c03 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/os_solaris_sparc.cpp @@ -441,7 +441,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, if (thread->thread_state() == _thread_in_vm) { if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) { - stub = SharedRuntime::handle_unsafe_access(thread, npc); + stub = StubRoutines::handler_for_unsafe_access(); } } @@ -480,7 +480,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, CodeBlob* cb = CodeCache::find_blob_unsafe(pc); CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { - stub = SharedRuntime::handle_unsafe_access(thread, npc); + stub = StubRoutines::handler_for_unsafe_access(); } } diff --git a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp index 695fc127835..d1bc192646d 100644 --- a/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp +++ b/hotspot/src/os_cpu/solaris_x86/vm/os_solaris_x86.cpp @@ -503,8 +503,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, if (thread->thread_state() == _thread_in_vm) { if (sig == SIGBUS && info->si_code == BUS_OBJERR && thread->doing_unsafe_access()) { - address next_pc = Assembler::locate_next_instruction(pc); - stub = SharedRuntime::handle_unsafe_access(thread, next_pc); + stub = StubRoutines::handler_for_unsafe_access(); } } @@ -521,8 +520,7 @@ JVM_handle_solaris_signal(int sig, siginfo_t* info, void* ucVoid, if (cb != NULL) { CompiledMethod* nm = cb->as_compiled_method_or_null(); if (nm != NULL && nm->has_unsafe_access()) { - address next_pc = Assembler::locate_next_instruction(pc); - stub = SharedRuntime::handle_unsafe_access(thread, next_pc); + stub = StubRoutines::handler_for_unsafe_access(); } } } diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index 4e0aec4a423..0824a8a56df 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -1762,21 +1762,6 @@ methodHandle SharedRuntime::reresolve_call_site(JavaThread *thread, TRAPS) { return callee_method; } -address SharedRuntime::handle_unsafe_access(JavaThread* thread, address next_pc) { - // The faulting unsafe accesses should be changed to throw the error - // synchronously instead. Meanwhile the faulting instruction will be - // skipped over (effectively turning it into a no-op) and an - // asynchronous exception will be raised which the thread will - // handle at a later point. If the instruction is a load it will - // return garbage. - - // Request an async exception. - thread->set_pending_unsafe_access_error(); - - // Return address of next instruction to execute. - return next_pc; -} - #ifdef ASSERT void SharedRuntime::check_member_name_argument_is_last_argument(const methodHandle& method, const BasicType* sig_bt, diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.hpp b/hotspot/src/share/vm/runtime/sharedRuntime.hpp index eb9797f26f5..52bca29cf72 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.hpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.hpp @@ -522,8 +522,6 @@ class SharedRuntime: AllStatic { static address handle_wrong_method_abstract(JavaThread* thread); static address handle_wrong_method_ic_miss(JavaThread* thread); - static address handle_unsafe_access(JavaThread* thread, address next_pc); - #ifndef PRODUCT // Collect and print inline cache miss statistics diff --git a/hotspot/src/share/vm/runtime/stubRoutines.cpp b/hotspot/src/share/vm/runtime/stubRoutines.cpp index 12e0e3a5b82..8a8f0fd4762 100644 --- a/hotspot/src/share/vm/runtime/stubRoutines.cpp +++ b/hotspot/src/share/vm/runtime/stubRoutines.cpp @@ -55,6 +55,7 @@ address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL; address StubRoutines::_throw_NullPointerException_at_call_entry = NULL; address StubRoutines::_throw_StackOverflowError_entry = NULL; address StubRoutines::_throw_delayed_StackOverflowError_entry = NULL; +address StubRoutines::_handler_for_unsafe_access_entry = NULL; jint StubRoutines::_verify_oop_count = 0; address StubRoutines::_verify_oop_subroutine_entry = NULL; address StubRoutines::_atomic_xchg_entry = NULL; diff --git a/hotspot/src/share/vm/runtime/stubRoutines.hpp b/hotspot/src/share/vm/runtime/stubRoutines.hpp index 729886f04fd..49f3550c273 100644 --- a/hotspot/src/share/vm/runtime/stubRoutines.hpp +++ b/hotspot/src/share/vm/runtime/stubRoutines.hpp @@ -111,6 +111,7 @@ class StubRoutines: AllStatic { static address _throw_NullPointerException_at_call_entry; static address _throw_StackOverflowError_entry; static address _throw_delayed_StackOverflowError_entry; + static address _handler_for_unsafe_access_entry; static address _atomic_xchg_entry; static address _atomic_xchg_ptr_entry; @@ -287,6 +288,10 @@ class StubRoutines: AllStatic { static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; } static address throw_delayed_StackOverflowError_entry() { return _throw_delayed_StackOverflowError_entry; } + // Exceptions during unsafe access - should throw Java exception rather + // than crash. + static address handler_for_unsafe_access() { return _handler_for_unsafe_access_entry; } + static address atomic_xchg_entry() { return _atomic_xchg_entry; } static address atomic_xchg_ptr_entry() { return _atomic_xchg_ptr_entry; } static address atomic_store_entry() { return _atomic_store_entry; } -- GitLab From d312e84812b0bf967dac9f3413602604c45d5483 Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Wed, 4 May 2016 23:08:43 +0300 Subject: [PATCH 282/400] 8155751: Some tests miss othervm for main/bootclasspath mode Reviewed-by: kvn --- .../intrinsics/bmi/verifycode/AndnTestI.java | 4 +- .../intrinsics/bmi/verifycode/AndnTestL.java | 4 +- .../jsr292/CallSiteDepContextTest.java | 6 +-- hotspot/test/compiler/jsr292/InvokerGC.java | 2 +- .../jsr292/NonInlinedCall/GCTest.java | 10 ++-- .../jsr292/NonInlinedCall/InvokeTest.java | 8 ++-- .../jsr292/NonInlinedCall/RedefineTest.java | 10 ++-- .../compiler/jsr292/VMAnonymousClasses.java | 2 +- .../test/compiler/profiling/UnsafeAccess.java | 6 +-- .../compiler/stable/TestStableBoolean.java | 40 ++++++++-------- .../test/compiler/stable/TestStableByte.java | 40 ++++++++-------- .../test/compiler/stable/TestStableChar.java | 40 ++++++++-------- .../compiler/stable/TestStableDouble.java | 40 ++++++++-------- .../test/compiler/stable/TestStableFloat.java | 40 ++++++++-------- .../test/compiler/stable/TestStableInt.java | 40 ++++++++-------- .../test/compiler/stable/TestStableLong.java | 40 ++++++++-------- .../stable/TestStableMemoryBarrier.java | 4 +- .../compiler/stable/TestStableObject.java | 40 ++++++++-------- .../test/compiler/stable/TestStableShort.java | 40 ++++++++-------- .../test/compiler/stable/TestStableUByte.java | 48 +++++++++---------- .../compiler/stable/TestStableUShort.java | 48 +++++++++---------- .../unsafe/UnsafeGetConstantField.java | 30 ++++++------ .../unsafe/UnsafeGetStableArrayElement.java | 2 +- 23 files changed, 272 insertions(+), 272 deletions(-) diff --git a/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestI.java b/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestI.java index fa72d45b0d1..faa699e63dd 100644 --- a/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestI.java +++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestI.java @@ -30,8 +30,8 @@ * @build AndnTestI * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/bootclasspath -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions AndnTestI + * @run main/bootclasspath/othervm -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions AndnTestI */ import java.lang.reflect.Method; diff --git a/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestL.java b/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestL.java index 5bd9ebdb057..218ccf85cfe 100644 --- a/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestL.java +++ b/hotspot/test/compiler/intrinsics/bmi/verifycode/AndnTestL.java @@ -30,8 +30,8 @@ * @build AndnTestL * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission - * @run main/bootclasspath -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions AndnTestL + * @run main/bootclasspath/othervm -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:+IgnoreUnrecognizedVMOptions -XX:+UseBMI1Instructions AndnTestL */ import java.lang.reflect.Method; diff --git a/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java b/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java index 02c4ba3faaa..152b28dd2f1 100644 --- a/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java +++ b/hotspot/test/compiler/jsr292/CallSiteDepContextTest.java @@ -28,9 +28,9 @@ * @modules java.base/jdk.internal.org.objectweb.asm * @library patches * @build java.base/java.lang.invoke.MethodHandleHelper - * @run main/bootclasspath -Xbatch -XX:+IgnoreUnrecognizedVMOptions -Xlog:class+unload - * -XX:+PrintCompilation -XX:+TraceDependencies -XX:+TraceReferenceGC - * -verbose:gc compiler.jsr292.CallSiteDepContextTest + * @run main/bootclasspath/othervm -Xbatch -XX:+IgnoreUnrecognizedVMOptions -Xlog:class+unload + * -XX:+PrintCompilation -XX:+TraceDependencies -XX:+TraceReferenceGC + * -verbose:gc compiler.jsr292.CallSiteDepContextTest */ package compiler.jsr292; diff --git a/hotspot/test/compiler/jsr292/InvokerGC.java b/hotspot/test/compiler/jsr292/InvokerGC.java index a8115f70173..98c69b1a0b6 100644 --- a/hotspot/test/compiler/jsr292/InvokerGC.java +++ b/hotspot/test/compiler/jsr292/InvokerGC.java @@ -26,7 +26,7 @@ * @bug 8067247 * @modules java.base/jdk.internal.misc * @library /test/lib /compiler/whitebox / - * @run main/bootclasspath -Xcomp -Xbatch + * @run main/bootclasspath/othervm -Xcomp -Xbatch * -XX:CompileCommand=compileonly,InvokerGC::test * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI * InvokerGC diff --git a/hotspot/test/compiler/jsr292/NonInlinedCall/GCTest.java b/hotspot/test/compiler/jsr292/NonInlinedCall/GCTest.java index a9a713fb3e7..3a93fe7d96e 100644 --- a/hotspot/test/compiler/jsr292/NonInlinedCall/GCTest.java +++ b/hotspot/test/compiler/jsr292/NonInlinedCall/GCTest.java @@ -29,11 +29,11 @@ * @modules java.base/jdk.internal.vm.annotation * @build java.base/java.lang.invoke.MethodHandleHelper * @build sun.hotspot.WhiteBox - * @run main/bootclasspath -XX:+IgnoreUnrecognizedVMOptions - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1 - * -XX:+FoldStableValues - * compiler.jsr292.NonInlinedCall.GCTest + * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1 + * -XX:+FoldStableValues + * compiler.jsr292.NonInlinedCall.GCTest */ package compiler.jsr292.NonInlinedCall; diff --git a/hotspot/test/compiler/jsr292/NonInlinedCall/InvokeTest.java b/hotspot/test/compiler/jsr292/NonInlinedCall/InvokeTest.java index e66c6e2df64..d413d382eef 100644 --- a/hotspot/test/compiler/jsr292/NonInlinedCall/InvokeTest.java +++ b/hotspot/test/compiler/jsr292/NonInlinedCall/InvokeTest.java @@ -30,10 +30,10 @@ * @build java.base/java.lang.invoke.MethodHandleHelper * @build sun.hotspot.WhiteBox * @build compiler.jsr292.NonInlinedCall.InvokeTest - * @run main/bootclasspath -XX:+IgnoreUnrecognizedVMOptions - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1 - * compiler.jsr292.NonInlinedCall.InvokeTest + * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1 + * compiler.jsr292.NonInlinedCall.InvokeTest */ package compiler.jsr292.NonInlinedCall; diff --git a/hotspot/test/compiler/jsr292/NonInlinedCall/RedefineTest.java b/hotspot/test/compiler/jsr292/NonInlinedCall/RedefineTest.java index 6607ec19c6c..1a77363f833 100644 --- a/hotspot/test/compiler/jsr292/NonInlinedCall/RedefineTest.java +++ b/hotspot/test/compiler/jsr292/NonInlinedCall/RedefineTest.java @@ -35,11 +35,11 @@ * @run main ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission * compiler.jsr292.NonInlinedCall.RedefineTest - * @run main/bootclasspath -javaagent:agent.jar - * -XX:+IgnoreUnrecognizedVMOptions - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI - * -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1 - * compiler.jsr292.NonInlinedCall.RedefineTest + * @run main/bootclasspath/othervm -javaagent:agent.jar + * -XX:+IgnoreUnrecognizedVMOptions + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xbatch -XX:-TieredCompilation -XX:CICompilerCount=1 + * compiler.jsr292.NonInlinedCall.RedefineTest */ package compiler.jsr292.NonInlinedCall; diff --git a/hotspot/test/compiler/jsr292/VMAnonymousClasses.java b/hotspot/test/compiler/jsr292/VMAnonymousClasses.java index e251722f762..abb9b5dc591 100644 --- a/hotspot/test/compiler/jsr292/VMAnonymousClasses.java +++ b/hotspot/test/compiler/jsr292/VMAnonymousClasses.java @@ -26,7 +26,7 @@ * @bug 8058828 * @modules java.base/jdk.internal.org.objectweb.asm * java.base/jdk.internal.misc - * @run main/bootclasspath -Xbatch VMAnonymousClasses + * @run main/bootclasspath/othervm -Xbatch VMAnonymousClasses */ import jdk.internal.org.objectweb.asm.ClassWriter; diff --git a/hotspot/test/compiler/profiling/UnsafeAccess.java b/hotspot/test/compiler/profiling/UnsafeAccess.java index 780824f1bdb..28abc34b19a 100644 --- a/hotspot/test/compiler/profiling/UnsafeAccess.java +++ b/hotspot/test/compiler/profiling/UnsafeAccess.java @@ -24,9 +24,9 @@ * @test * @bug 8134918 * @modules java.base/jdk.internal.misc - * @run main/bootclasspath -XX:+IgnoreUnrecognizedVMOptions -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation -Xbatch - * -XX:CompileCommand=dontinline,UnsafeAccess::test* - * UnsafeAccess + * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation -Xbatch + * -XX:CompileCommand=dontinline,UnsafeAccess::test* + * UnsafeAccess */ import jdk.internal.misc.Unsafe; diff --git a/hotspot/test/compiler/stable/TestStableBoolean.java b/hotspot/test/compiler/stable/TestStableBoolean.java index e47a9a783df..de0d42ea405 100644 --- a/hotspot/test/compiler/stable/TestStableBoolean.java +++ b/hotspot/test/compiler/stable/TestStableBoolean.java @@ -32,27 +32,27 @@ * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableBoolean * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableBoolean - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:-FoldStableValues - * compiler.stable.TestStableBoolean + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableBoolean + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:-FoldStableValues + * compiler.stable.TestStableBoolean * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:+TieredCompilation -XX:TieredStopAtLevel=1 - * -XX:+FoldStableValues - * compiler.stable.TestStableBoolean - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:+TieredCompilation -XX:TieredStopAtLevel=1 - * -XX:-FoldStableValues - * compiler.stable.TestStableBoolean + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:+TieredCompilation -XX:TieredStopAtLevel=1 + * -XX:+FoldStableValues + * compiler.stable.TestStableBoolean + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:+TieredCompilation -XX:TieredStopAtLevel=1 + * -XX:-FoldStableValues + * compiler.stable.TestStableBoolean */ package compiler.stable; diff --git a/hotspot/test/compiler/stable/TestStableByte.java b/hotspot/test/compiler/stable/TestStableByte.java index be41ae50fc9..74cba03c9c5 100644 --- a/hotspot/test/compiler/stable/TestStableByte.java +++ b/hotspot/test/compiler/stable/TestStableByte.java @@ -32,27 +32,27 @@ * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableByte * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableByte - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableByte + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableByte + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableByte * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableByte - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableByte + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableByte + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableByte */ package compiler.stable; diff --git a/hotspot/test/compiler/stable/TestStableChar.java b/hotspot/test/compiler/stable/TestStableChar.java index 5a86773bfe4..d03c4edfa14 100644 --- a/hotspot/test/compiler/stable/TestStableChar.java +++ b/hotspot/test/compiler/stable/TestStableChar.java @@ -32,27 +32,27 @@ * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableChar * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableChar - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableChar + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableChar + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableChar * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableChar - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableChar + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableChar + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableChar */ package compiler.stable; diff --git a/hotspot/test/compiler/stable/TestStableDouble.java b/hotspot/test/compiler/stable/TestStableDouble.java index d1dbcad6d39..883eea165e6 100644 --- a/hotspot/test/compiler/stable/TestStableDouble.java +++ b/hotspot/test/compiler/stable/TestStableDouble.java @@ -32,27 +32,27 @@ * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableDouble * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableDouble - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableDouble + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableDouble + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableDouble * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableDouble - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableDouble + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableDouble + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableDouble */ package compiler.stable; diff --git a/hotspot/test/compiler/stable/TestStableFloat.java b/hotspot/test/compiler/stable/TestStableFloat.java index bcee1084bd6..66eafc82b2a 100644 --- a/hotspot/test/compiler/stable/TestStableFloat.java +++ b/hotspot/test/compiler/stable/TestStableFloat.java @@ -32,27 +32,27 @@ * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableFloat * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableFloat - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableFloat + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableFloat + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableFloat * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableFloat - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableFloat + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableFloat + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableFloat */ package compiler.stable; diff --git a/hotspot/test/compiler/stable/TestStableInt.java b/hotspot/test/compiler/stable/TestStableInt.java index a57b9013736..0d8dcda5f02 100644 --- a/hotspot/test/compiler/stable/TestStableInt.java +++ b/hotspot/test/compiler/stable/TestStableInt.java @@ -32,27 +32,27 @@ * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableInt * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableInt - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableInt + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableInt + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableInt * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableInt - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableInt + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableInt + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableInt */ package compiler.stable; diff --git a/hotspot/test/compiler/stable/TestStableLong.java b/hotspot/test/compiler/stable/TestStableLong.java index 9177ccc7a7c..481b23704c7 100644 --- a/hotspot/test/compiler/stable/TestStableLong.java +++ b/hotspot/test/compiler/stable/TestStableLong.java @@ -32,27 +32,27 @@ * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableLong * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableLong - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableLong + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableLong + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableLong * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableLong - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableLong + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableLong + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableLong */ package compiler.stable; diff --git a/hotspot/test/compiler/stable/TestStableMemoryBarrier.java b/hotspot/test/compiler/stable/TestStableMemoryBarrier.java index aa4d32dc853..8e164a9596e 100644 --- a/hotspot/test/compiler/stable/TestStableMemoryBarrier.java +++ b/hotspot/test/compiler/stable/TestStableMemoryBarrier.java @@ -31,8 +31,8 @@ * @modules java.base/jdk.internal.misc * @modules java.base/jdk.internal.vm.annotation * - * @run main/bootclasspath -Xcomp -XX:CompileOnly=::testCompile - * compiler.stable.TestStableMemoryBarrier + * @run main/bootclasspath/othervm -Xcomp -XX:CompileOnly=::testCompile + * compiler.stable.TestStableMemoryBarrier * * @author hui.shi@linaro.org */ diff --git a/hotspot/test/compiler/stable/TestStableObject.java b/hotspot/test/compiler/stable/TestStableObject.java index 4a4b2a6b364..31a33f5abd5 100644 --- a/hotspot/test/compiler/stable/TestStableObject.java +++ b/hotspot/test/compiler/stable/TestStableObject.java @@ -32,27 +32,27 @@ * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableObject * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableObject - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableObject + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableObject + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableObject * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableObject - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableObject + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableObject + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableObject */ package compiler.stable; diff --git a/hotspot/test/compiler/stable/TestStableShort.java b/hotspot/test/compiler/stable/TestStableShort.java index 6e018c1b9d9..7ed4dc4df39 100644 --- a/hotspot/test/compiler/stable/TestStableShort.java +++ b/hotspot/test/compiler/stable/TestStableShort.java @@ -32,27 +32,27 @@ * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableShort * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableShort - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableShort + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableShort + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableShort * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableShort - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * compiler.stable.TestStableShort + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableShort + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:CompileOnly=::get,::get1,::get2,::get3,::get4 + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * compiler.stable.TestStableShort */ package compiler.stable; diff --git a/hotspot/test/compiler/stable/TestStableUByte.java b/hotspot/test/compiler/stable/TestStableUByte.java index cfc97f06c6b..788fecacde5 100644 --- a/hotspot/test/compiler/stable/TestStableUByte.java +++ b/hotspot/test/compiler/stable/TestStableUByte.java @@ -32,31 +32,31 @@ * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableUByte * - * @run main/bootclasspath -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * -XX:CompileOnly=::get,::get1 - * compiler.stable.TestStableUByte - * @run main/bootclasspath -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:-TieredCompilation - * -XX:-FoldStableValues - * -XX:CompileOnly=::get,::get1 - * compiler.stable.TestStableUByte + * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * -XX:CompileOnly=::get,::get1 + * compiler.stable.TestStableUByte + * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:-TieredCompilation + * -XX:-FoldStableValues + * -XX:CompileOnly=::get,::get1 + * compiler.stable.TestStableUByte * - * @run main/bootclasspath -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:+TieredCompilation -XX:TieredStopAtLevel=1 - * -XX:+FoldStableValues - * -XX:CompileOnly=::get,::get1 - * compiler.stable.TestStableUByte - * @run main/bootclasspath -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:+TieredCompilation -XX:TieredStopAtLevel=1 - * -XX:-FoldStableValues - * -XX:CompileOnly=::get,::get1 - * compiler.stable.TestStableUByte + * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:+TieredCompilation -XX:TieredStopAtLevel=1 + * -XX:+FoldStableValues + * -XX:CompileOnly=::get,::get1 + * compiler.stable.TestStableUByte + * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:+TieredCompilation -XX:TieredStopAtLevel=1 + * -XX:-FoldStableValues + * -XX:CompileOnly=::get,::get1 + * compiler.stable.TestStableUByte * */ package compiler.stable; diff --git a/hotspot/test/compiler/stable/TestStableUShort.java b/hotspot/test/compiler/stable/TestStableUShort.java index 43def908bc2..43ebf3c6383 100644 --- a/hotspot/test/compiler/stable/TestStableUShort.java +++ b/hotspot/test/compiler/stable/TestStableUShort.java @@ -32,31 +32,31 @@ * @build sun.hotspot.WhiteBox * @build compiler.stable.TestStableUShort * - * @run main/bootclasspath -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:-TieredCompilation - * -XX:+FoldStableValues - * -XX:CompileOnly=::get,::get1 - * compiler.stable.TestStableUShort - * @run main/bootclasspath -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:-TieredCompilation - * -XX:-FoldStableValues - * -XX:CompileOnly=::get,::get1 - * compiler.stable.TestStableUShort + * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:-TieredCompilation + * -XX:+FoldStableValues + * -XX:CompileOnly=::get,::get1 + * compiler.stable.TestStableUShort + * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:-TieredCompilation + * -XX:-FoldStableValues + * -XX:CompileOnly=::get,::get1 + * compiler.stable.TestStableUShort * - * @run main/bootclasspath -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:+TieredCompilation -XX:TieredStopAtLevel=1 - * -XX:+FoldStableValues - * -XX:CompileOnly=::get,::get1 - * compiler.stable.TestStableUShort - * @run main/bootclasspath -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp - * -XX:+TieredCompilation -XX:TieredStopAtLevel=1 - * -XX:-FoldStableValues - * -XX:CompileOnly=::get,::get1 - * compiler.stable.TestStableUShort + * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:+TieredCompilation -XX:TieredStopAtLevel=1 + * -XX:+FoldStableValues + * -XX:CompileOnly=::get,::get1 + * compiler.stable.TestStableUShort + * @run main/bootclasspath/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+AlwaysIncrementalInline + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xcomp + * -XX:+TieredCompilation -XX:TieredStopAtLevel=1 + * -XX:-FoldStableValues + * -XX:CompileOnly=::get,::get1 + * compiler.stable.TestStableUShort * */ package compiler.stable; diff --git a/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java b/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java index 445f1391731..d338047da5e 100644 --- a/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java +++ b/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java @@ -34,22 +34,22 @@ * java.base/jdk.internal.vm.annotation * java.base/jdk.internal.misc * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions - * -Xbatch -XX:-TieredCompilation - * -XX:+FoldStableValues - * -XX:CompileCommand=dontinline,UnsafeGetConstantField.checkGetAddress() - * -XX:CompileCommand=dontinline,*.test* - * -XX:+UseUnalignedAccesses - * compiler.unsafe.UnsafeGetConstantField + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions + * -Xbatch -XX:-TieredCompilation + * -XX:+FoldStableValues + * -XX:CompileCommand=dontinline,UnsafeGetConstantField.checkGetAddress() + * -XX:CompileCommand=dontinline,*.test* + * -XX:+UseUnalignedAccesses + * compiler.unsafe.UnsafeGetConstantField * - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions - * -Xbatch -XX:-TieredCompilation - * -XX:+FoldStableValues - * -XX:CompileCommand=dontinline,UnsafeGetConstantField.checkGetAddress() - * -XX:CompileCommand=dontinline,*.test* - * -XX:CompileCommand=inline,*Unsafe.get* - * -XX:-UseUnalignedAccesses - * compiler.unsafe.UnsafeGetConstantField + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions + * -Xbatch -XX:-TieredCompilation + * -XX:+FoldStableValues + * -XX:CompileCommand=dontinline,UnsafeGetConstantField.checkGetAddress() + * -XX:CompileCommand=dontinline,*.test* + * -XX:CompileCommand=inline,*Unsafe.get* + * -XX:-UseUnalignedAccesses + * compiler.unsafe.UnsafeGetConstantField */ package compiler.unsafe; diff --git a/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java b/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java index 8a47786703e..c4d56725765 100644 --- a/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java +++ b/hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java @@ -33,7 +33,7 @@ * @modules java.base/jdk.internal.vm.annotation * java.base/jdk.internal.misc - * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions + * @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions * -Xbatch -XX:-TieredCompilation * -XX:+FoldStableValues * -XX:CompileCommand=dontinline,*Test::test* -- GitLab From 34fe707dada525e142e027d5800b9804164a7897 Mon Sep 17 00:00:00 2001 From: Jiangli Zhou Date: Wed, 4 May 2016 17:32:08 -0400 Subject: [PATCH 283/400] 8155678: ClassLoader::initialize_module_loader_map should only be called when dumping CDS archive Make ClassLoader::initialize_module_loader_map explicitly CDS dump time only. Reviewed-by: ccheung, lfoltan --- hotspot/src/share/vm/classfile/classLoader.cpp | 16 +++++++++------- hotspot/src/share/vm/classfile/classLoader.hpp | 4 ++-- .../src/share/vm/classfile/classLoaderExt.hpp | 8 +++++--- hotspot/src/share/vm/oops/instanceKlass.hpp | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index a33e2040530..2a2314964d7 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -941,6 +941,10 @@ int ClassLoader::crc32(int crc, const char* buf, int len) { #if INCLUDE_CDS void ClassLoader::initialize_module_loader_map(JImageFile* jimage) { + if (!DumpSharedSpaces) { + return; // only needed for CDS dump time + } + jlong size; JImageLocationRef location = (*JImageFindResource)(jimage, "java.base", get_jimage_version_string(), MODULE_LOADER_MAP, &size); if (location == 0) { @@ -1085,6 +1089,7 @@ objArrayOop ClassLoader::get_system_packages(TRAPS) { #if INCLUDE_CDS s2 ClassLoader::module_to_classloader(const char* module_name) { + assert(DumpSharedSpaces, "dump time only"); assert(_boot_modules_array != NULL, "_boot_modules_array is NULL"); assert(_platform_modules_array != NULL, "_platform_modules_array is NULL"); @@ -1104,11 +1109,11 @@ s2 ClassLoader::module_to_classloader(const char* module_name) { return APP_LOADER; } -#endif s2 ClassLoader::classloader_type(Symbol* class_name, ClassPathEntry* e, int classpath_index, TRAPS) { -#if INCLUDE_CDS + assert(DumpSharedSpaces, "Only used for CDS dump time"); + // obtain the classloader type based on the class name. // First obtain the package name based on the class name. Then obtain // the classloader type based on the package name from the jimage using @@ -1133,10 +1138,8 @@ s2 ClassLoader::classloader_type(Symbol* class_name, ClassPathEntry* e, loader_type = ClassLoader::BOOT_LOADER; } return loader_type; -#endif - return ClassLoader::BOOT_LOADER; // the classloader type is ignored in non-CDS cases } - +#endif // caller needs ResourceMark const char* ClassLoader::file_name_for_class_name(const char* class_name, @@ -1253,8 +1256,7 @@ instanceKlassHandle ClassLoader::load_class(Symbol* name, bool search_append_onl return NULL; } - jshort loader_type = classloader_type(name, e, classpath_index, CHECK_NULL); - return context.record_result(classpath_index, loader_type, e, result, THREAD); + return context.record_result(name, e, classpath_index, result, THREAD); } // Initialize the class loader's access to methods in libzip. Parse and diff --git a/hotspot/src/share/vm/classfile/classLoader.hpp b/hotspot/src/share/vm/classfile/classLoader.hpp index fc1d335b7ab..c5fac62675e 100644 --- a/hotspot/src/share/vm/classfile/classLoader.hpp +++ b/hotspot/src/share/vm/classfile/classLoader.hpp @@ -379,9 +379,9 @@ class ClassLoader: AllStatic { static s2 module_to_classloader(const char* module_name); static void initialize_module_loader_map(JImageFile* jimage); -#endif static s2 classloader_type(Symbol* class_name, ClassPathEntry* e, - int classpath_index, TRAPS); + int classpath_index, TRAPS); +#endif static void trace_class_path(const char* msg, const char* name = NULL); diff --git a/hotspot/src/share/vm/classfile/classLoaderExt.hpp b/hotspot/src/share/vm/classfile/classLoaderExt.hpp index 7fa11b2f614..24426d10552 100644 --- a/hotspot/src/share/vm/classfile/classLoaderExt.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderExt.hpp @@ -49,12 +49,14 @@ public: return false; } - instanceKlassHandle record_result(const s2 classpath_index, - const jshort classloader_type, - const ClassPathEntry* e, + instanceKlassHandle record_result(Symbol* class_name, + ClassPathEntry* e, + const s2 classpath_index, instanceKlassHandle result, TRAPS) { if (ClassLoader::add_package(_file_name, classpath_index, THREAD)) { if (DumpSharedSpaces) { + s2 classloader_type = ClassLoader::classloader_type( + class_name, e, classpath_index, CHECK_(result)); result->set_shared_classpath_index(classpath_index); result->set_class_loader_type(classloader_type); } diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 1c46d5bed5a..125060bd80b 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -321,7 +321,7 @@ class InstanceKlass: public Klass { return (_misc_flags & _misc_is_shared_app_class) != 0; } - void set_class_loader_type(jshort loader_type) { + void set_class_loader_type(s2 loader_type) { assert(( _misc_flags & loader_type_bits()) == 0, "Should only be called once for each class."); switch (loader_type) { -- GitLab From e41ab59d6306082f0e288212c350dd402180f031 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Wed, 4 May 2016 21:53:01 -0400 Subject: [PATCH 284/400] 8153073: UL: Set filesize option with k/m/g Reviewed-by: mlarsson, dholmes --- hotspot/src/share/vm/logging/logConfiguration.cpp | 2 +- hotspot/src/share/vm/logging/logFileOutput.cpp | 10 ++++++---- hotspot/src/share/vm/runtime/arguments.cpp | 14 +++++++------- hotspot/src/share/vm/runtime/arguments.hpp | 2 ++ .../serviceability/logging/TestLogRotation.java | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/hotspot/src/share/vm/logging/logConfiguration.cpp b/hotspot/src/share/vm/logging/logConfiguration.cpp index de0cce51d3d..33281a9132b 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.cpp +++ b/hotspot/src/share/vm/logging/logConfiguration.cpp @@ -464,7 +464,7 @@ void LogConfiguration::print_command_line_help(FILE* out) { " -Xlog:gc=debug:file=gc.txt:none\n" "\t Log messages tagged with 'gc' tag using 'debug' level to file 'gc.txt' with no decorations.\n\n" - " -Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1024\n" + " -Xlog:gc=trace:file=gctrace.txt:uptimemillis,pids:filecount=5,filesize=1m\n" "\t Log messages tagged with 'gc' tag using 'trace' level to a rotating fileset of 5 files of size 1MB,\n" "\t using the base name 'gctrace.txt', with 'uptimemillis' and 'pid' decorations.\n\n" diff --git a/hotspot/src/share/vm/logging/logFileOutput.cpp b/hotspot/src/share/vm/logging/logFileOutput.cpp index ade58459ca9..17ced6f05d4 100644 --- a/hotspot/src/share/vm/logging/logFileOutput.cpp +++ b/hotspot/src/share/vm/logging/logFileOutput.cpp @@ -26,6 +26,7 @@ #include "logging/logConfiguration.hpp" #include "logging/logFileOutput.hpp" #include "memory/allocation.inline.hpp" +#include "runtime/arguments.hpp" #include "runtime/os.inline.hpp" #include "utilities/globalDefinitions.hpp" #include "utilities/defaultStream.hpp" @@ -187,14 +188,15 @@ bool LogFileOutput::parse_options(const char* options, outputStream* errstream) } _file_count = static_cast(value); } else if (strcmp(FileSizeOptionKey, key) == 0) { - size_t value = parse_value(value_str); - if (value == SIZE_MAX || value > SIZE_MAX / K) { + julong value; + success = Arguments::atojulong(value_str, &value); + if (!success || (value > SIZE_MAX)) { errstream->print_cr("Invalid option: %s must be in range [0, " - SIZE_FORMAT "]", FileSizeOptionKey, SIZE_MAX / K); + SIZE_FORMAT "]", FileSizeOptionKey, SIZE_MAX); success = false; break; } - _rotate_size = value * K; + _rotate_size = static_cast(value); } else { errstream->print_cr("Invalid option '%s' for log file output.", key); success = false; diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index beddacfc014..f49addcebe3 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -778,8 +778,8 @@ char* ArgumentBootClassPath::add_jars_to_path(char* path, const char* directory) return path; } -// Parses a memory size specification string. -static bool atomull(const char *s, julong* result) { +// Parses a size specification string. +bool Arguments::atojulong(const char *s, julong* result) { julong n = 0; int args_read = 0; bool is_hex = false; @@ -885,7 +885,7 @@ static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) return false; } - // Check the sign first since atomull() parses only unsigned values. + // Check the sign first since atojulong() parses only unsigned values. if (*value == '-') { if (!result->is_intx() && !result->is_int()) { return false; @@ -893,7 +893,7 @@ static bool set_numeric_flag(const char* name, char* value, Flag::Flags origin) value++; is_neg = true; } - if (!atomull(value, &v)) { + if (!Arguments::atojulong(value, &v)) { return false; } if (result->is_int()) { @@ -2693,12 +2693,12 @@ bool Arguments::parse_uintx(const char* value, uintx* uintx_arg, uintx min_size) { - // Check the sign first since atomull() parses only unsigned values. + // Check the sign first since atojulong() parses only unsigned values. bool value_is_positive = !(*value == '-'); if (value_is_positive) { julong n; - bool good_return = atomull(value, &n); + bool good_return = atojulong(value, &n); if (good_return) { bool above_minimum = n >= min_size; bool value_is_too_large = n > max_uintx; @@ -2715,7 +2715,7 @@ bool Arguments::parse_uintx(const char* value, Arguments::ArgsRange Arguments::parse_memory_size(const char* s, julong* long_arg, julong min_size) { - if (!atomull(s, long_arg)) return arg_unreadable; + if (!atojulong(s, long_arg)) return arg_unreadable; return check_memory_size(*long_arg, min_size); } diff --git a/hotspot/src/share/vm/runtime/arguments.hpp b/hotspot/src/share/vm/runtime/arguments.hpp index 4df23a5b485..07649d2ffe5 100644 --- a/hotspot/src/share/vm/runtime/arguments.hpp +++ b/hotspot/src/share/vm/runtime/arguments.hpp @@ -729,6 +729,8 @@ class Arguments : AllStatic { static bool copy_expand_pid(const char* src, size_t srclen, char* buf, size_t buflen); static void check_unsupported_dumping_properties() NOT_CDS_RETURN; + + static bool atojulong(const char *s, julong* result); }; // Disable options not supported in this release, with a warning if they diff --git a/hotspot/test/serviceability/logging/TestLogRotation.java b/hotspot/test/serviceability/logging/TestLogRotation.java index ca59cf6e4a4..3e3696b3fb0 100644 --- a/hotspot/test/serviceability/logging/TestLogRotation.java +++ b/hotspot/test/serviceability/logging/TestLogRotation.java @@ -75,7 +75,7 @@ public class TestLogRotation { ArrayList args = new ArrayList(); String[] logOpts = new String[]{ "-cp", System.getProperty("java.class.path"), - "-Xlog:gc=debug:" + logFileName + "::filesize=" + logFileSizeK + ",filecount=" + numberOfFiles, + "-Xlog:gc=debug:" + logFileName + "::filesize=" + logFileSizeK + "k,filecount=" + numberOfFiles, "-XX:-DisableExplicitGC", // to ensure that System.gc() works "-Xmx128M"}; // System.getProperty("test.java.opts") is '' if no options is set -- GitLab From 565780b7aa6721310c0af1eceb0471123d90c32a Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Tue, 3 May 2016 07:23:23 -0700 Subject: [PATCH 285/400] 8155239: [TESTBUG] Simple test setup for JVMTI ClassFileLoadHook Reviewed-by: cjplummer, mseledtsov --- hotspot/make/test/JtregNative.gmk | 2 + .../jvmti/libSimpleClassFileLoadHook.c | 166 ++++++++++++++++++ .../SimpleClassFileLoadHookTest.java | 49 ++++++ 3 files changed, 217 insertions(+) create mode 100644 hotspot/test/testlibrary/jvmti/libSimpleClassFileLoadHook.c create mode 100644 hotspot/test/testlibrary_tests/SimpleClassFileLoadHookTest.java diff --git a/hotspot/make/test/JtregNative.gmk b/hotspot/make/test/JtregNative.gmk index 62478ce6923..4e61967e859 100644 --- a/hotspot/make/test/JtregNative.gmk +++ b/hotspot/make/test/JtregNative.gmk @@ -51,6 +51,7 @@ BUILD_HOTSPOT_JTREG_NATIVE_SRC := \ $(HOTSPOT_TOPDIR)/test/compiler/floatingpoint/ \ $(HOTSPOT_TOPDIR)/test/compiler/calls \ $(HOTSPOT_TOPDIR)/test/compiler/native \ + $(HOTSPOT_TOPDIR)/test/testlibrary/jvmti \ # # Add conditional directories here when needed. @@ -62,6 +63,7 @@ endif ifeq ($(TOOLCHAIN_TYPE), solstudio) BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_liboverflow := -lc + BUILD_HOTSPOT_JTREG_LIBRARIES_LDFLAGS_libSimpleClassFileLoadHook := -lc endif BUILD_HOTSPOT_JTREG_OUTPUT_DIR := $(BUILD_OUTPUT)/support/test/hotspot/jtreg/native diff --git a/hotspot/test/testlibrary/jvmti/libSimpleClassFileLoadHook.c b/hotspot/test/testlibrary/jvmti/libSimpleClassFileLoadHook.c new file mode 100644 index 00000000000..2424e87c880 --- /dev/null +++ b/hotspot/test/testlibrary/jvmti/libSimpleClassFileLoadHook.c @@ -0,0 +1,166 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * A simple way to test JVMTI ClassFileLoadHook. See ../testlibrary_tests/SimpleClassFileLoadHookTest.java + * for an example. + */ +#include +#include +#include +#include + +#include +#include + +static char* CLASS_NAME = NULL; +static char* FROM = NULL; +static char* TO = NULL; +static jvmtiEnv *jvmti = NULL; +static jvmtiEventCallbacks callbacks; + +/** + * For all classes whose name equals to CLASS_NAME, we replace all occurrence of FROM to TO + * in the classfile data. CLASS_NAME must be a binary class name. + * + * FROM is usually chosen as part of a UTF8 string in the class file. For example, if the + * original class file has + * String getXXX() { return "theXXX";} + * You can set FROM=XXX, TO=YYY to rewrite the class to be + * String getYYY() { return "theYYY";} + * + * Please note that the replacement is NOT limited just the UTF8 strings, but rather applies + * to all the bytes in the classfile. So if you pick a very short FROM string like X, + * it may override any POP2 bytecodes, which have the value 88 (ascii 'X'). + * + * A good FROM string to use is 'cellphone', where the first 4 bytes represent the bytecode + * sequence DADD/LSUB/IDIV/IDIV, which does not appear in valid bytecode streams. + */ +void JNICALL +ClassFileLoadHook(jvmtiEnv *jvmti_env, JNIEnv *env, jclass class_beeing_redefined, + jobject loader, const char* name, jobject protection_domain, + jint class_data_len, const unsigned char* class_data, + jint *new_class_data_len, unsigned char** new_class_data) { + + if (name != NULL && (strcmp(name, CLASS_NAME) == 0)) { + size_t n = strlen(FROM); + unsigned char* new_data; + + if ((*jvmti)->Allocate(jvmti, class_data_len, &new_data) == JNI_OK) { + const unsigned char* s = class_data; + unsigned char* d = new_data; + unsigned char* end = d + class_data_len; + int count = 0; + + fprintf(stderr, "found class to be hooked: %s - rewriting ...\n", name); + + while (d + n < end) { + if (memcmp(s, FROM, n) == 0) { + memcpy(d, TO, n); + s += n; + d += n; + count++; + } else { + *d++ = *s++; + } + } + while (d < end) { + *d++ = *s++; + } + + *new_class_data_len = class_data_len; + *new_class_data = new_data; + + fprintf(stderr, "Rewriting done. Replaced %d occurrence(s)\n", count); + } + } +} + +static jint init_options(char *options) { + char* class_name; + char* from; + char* to; + + fprintf(stderr, "Agent library loaded with options = %s\n", options); + if ((class_name = options) != NULL && + (from = strchr(class_name, ',')) != NULL && (from[1] != 0)) { + *from = 0; + from++; + if ((to = strchr(from, ',')) != NULL && (to[1] != 0)) { + *to = 0; + to++; + if (strchr(to, ',') == NULL && + strlen(to) == strlen(from) && + strlen(class_name) > 0 && + strlen(to) > 0) { + CLASS_NAME = strdup(class_name); + FROM = strdup(from); + TO = strdup(to); + fprintf(stderr, "CLASS_NAME = %s, FROM = %s, TO = %s\n", + CLASS_NAME, FROM, TO); + return JNI_OK; + } + } + } + fprintf(stderr, + "Incorrect options. You need to start the JVM with -agentlib:ClassFileLoadHook=,,\n" + "where is the class you want to hook, is the string in the classfile to be replaced\n" + "with . and must have the same length. Example:\n" + " @run main/native -agentlib:ClassFileLoadHook=Foo,XXX,YYY ClassFileLoadHookTest\n"); + return JNI_ERR; +} + +static jint Agent_Initialize(JavaVM *jvm, char *options, void *reserved) { + int rc; + + if ((rc = (*jvm)->GetEnv(jvm, (void **)&jvmti, JVMTI_VERSION_1_1)) != JNI_OK) { + fprintf(stderr, "Unable to create jvmtiEnv, GetEnv failed, error = %d\n", rc); + return JNI_ERR; + } + if ((rc = init_options(options)) != JNI_OK) { + return JNI_ERR; + } + + (void) memset(&callbacks, 0, sizeof(callbacks)); + callbacks.ClassFileLoadHook = &ClassFileLoadHook; + if ((rc = (*jvmti)->SetEventCallbacks(jvmti, &callbacks, sizeof(callbacks))) != JNI_OK) { + fprintf(stderr, "SetEventCallbacks failed, error = %d\n", rc); + return JNI_ERR; + } + + if ((rc = (*jvmti)->SetEventNotificationMode(jvmti, JVMTI_ENABLE, + JVMTI_EVENT_CLASS_FILE_LOAD_HOOK, NULL)) != JNI_OK) { + fprintf(stderr, "SetEventNotificationMode failed, error = %d\n", rc); + return JNI_ERR; + } + + return JNI_OK; +} + +JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { + return Agent_Initialize(jvm, options, reserved); +} + +JNIEXPORT jint JNICALL Agent_OnAttach(JavaVM *jvm, char *options, void *reserved) { + return Agent_Initialize(jvm, options, reserved); +} diff --git a/hotspot/test/testlibrary_tests/SimpleClassFileLoadHookTest.java b/hotspot/test/testlibrary_tests/SimpleClassFileLoadHookTest.java new file mode 100644 index 00000000000..6f5ef8d4a71 --- /dev/null +++ b/hotspot/test/testlibrary_tests/SimpleClassFileLoadHookTest.java @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @library /testlibrary + * + * @run main/othervm/native -agentlib:SimpleClassFileLoadHook=Foo,XXX,YYY + * SimpleClassFileLoadHookTest + */ +import jdk.test.lib.Asserts; + +class Foo { + static String getValue() { + return "XXX"; + } + static String getOtherValue() { + return "xXXXxx"; + } +} +public class SimpleClassFileLoadHookTest { + public static void main(String args[]) { + System.out.println(Foo.getValue()); + System.out.println(Foo.getOtherValue()); + Asserts.assertTrue("YYY".equals(Foo.getValue()) && + "xYYYxx".equals(Foo.getOtherValue()), + "SimpleClassFileLoadHook should replace XXX with YYY"); + } +} -- GitLab From bd6db06885a5c247cb8cf684c820d5e624477835 Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Wed, 4 May 2016 18:56:24 +0300 Subject: [PATCH 286/400] 8155950: Add minimal VM in JIB profile on linux-x86 Reviewed-by: dholmes, erikj --- common/conf/jib-profiles.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js index 39196ac553a..199094abbc2 100644 --- a/common/conf/jib-profiles.js +++ b/common/conf/jib-profiles.js @@ -219,7 +219,7 @@ var getJibProfilesCommon = function (input) { common.default_make_targets_debug = common.default_make_targets; common.default_make_targets_slowdebug = common.default_make_targets; common.configure_args = ["--enable-jtreg-failure-handler"], - common.configure_args_32bit = ["--with-target-bits=32", "--with-jvm-variants=client,server"], + common.configure_args_32bit = ["--with-target-bits=32"], common.configure_args_debug = ["--enable-debug"], common.configure_args_slowdebug = ["--with-debug-level=slowdebug"], common.organization = "jpg.infra.builddeps" @@ -254,7 +254,7 @@ var getJibProfilesProfiles = function (input, common) { build_cpu: "x64", dependencies: concat(common.dependencies, "devkit"), configure_args: concat(common.configure_args, common.configure_args_32bit, - "--with-zlib=system"), + "--with-jvm-variants=minimal,client,server", "--with-zlib=system"), default_make_targets: common.default_make_targets }, @@ -295,7 +295,8 @@ var getJibProfilesProfiles = function (input, common) { target_cpu: "x86", build_cpu: "x64", dependencies: concat(common.dependencies, "devkit", "freetype"), - configure_args: concat(common.configure_args, common.configure_args_32bit), + configure_args: concat(common.configure_args, + "--with-jvm-variants=client,server", common.configure_args_32bit), default_make_targets: common.default_make_targets } }; -- GitLab From b349292b7471f7612a002f33cea4061f7b4040b1 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 3 May 2016 23:49:27 +0300 Subject: [PATCH 287/400] 8148244: Finalize and integrate GTest implementation Co-authored-by: Stefan Karlsson Co-authored-by: Stefan Sarne Co-authored-by: Jesper Wilhelmsson Co-authored-by: Erik Helin Co-authored-by: Alexandre Iline Co-authored-by: Erik Joelsson Reviewed-by: jwilhelm, erikj --- common/autoconf/buildjdk-spec.gmk.in | 5 +- common/autoconf/generated-configure.sh | 161 +- common/autoconf/libraries.m4 | 24 + common/autoconf/spec.gmk.in | 4 + make/Main.gmk | 11 +- make/common/NativeCompilation.gmk | 15 +- make/jprt.properties | 15 +- test/fmw/gtest/CHANGES | 157 + test/fmw/gtest/LICENSE | 28 + test/fmw/gtest/README | 435 ++ .../gtest/include/gtest/gtest-death-test.h | 294 + test/fmw/gtest/include/gtest/gtest-message.h | 250 + .../gtest/include/gtest/gtest-param-test.h | 1421 +++++ .../include/gtest/gtest-param-test.h.pump | 487 ++ test/fmw/gtest/include/gtest/gtest-printers.h | 855 +++ test/fmw/gtest/include/gtest/gtest-spi.h | 232 + .../fmw/gtest/include/gtest/gtest-test-part.h | 179 + .../gtest/include/gtest/gtest-typed-test.h | 259 + test/fmw/gtest/include/gtest/gtest.h | 2291 ++++++++ .../fmw/gtest/include/gtest/gtest_pred_impl.h | 358 ++ test/fmw/gtest/include/gtest/gtest_prod.h | 58 + .../internal/gtest-death-test-internal.h | 319 + .../include/gtest/internal/gtest-filepath.h | 206 + .../include/gtest/internal/gtest-internal.h | 1158 ++++ .../include/gtest/internal/gtest-linked_ptr.h | 233 + .../internal/gtest-param-util-generated.h | 5143 +++++++++++++++++ .../gtest-param-util-generated.h.pump | 301 + .../include/gtest/internal/gtest-param-util.h | 619 ++ .../gtest/include/gtest/internal/gtest-port.h | 1947 +++++++ .../include/gtest/internal/gtest-string.h | 167 + .../include/gtest/internal/gtest-tuple.h | 1012 ++++ .../include/gtest/internal/gtest-tuple.h.pump | 339 ++ .../include/gtest/internal/gtest-type-util.h | 3331 +++++++++++ .../gtest/internal/gtest-type-util.h.pump | 297 + test/fmw/gtest/src/gtest-all.cc | 48 + test/fmw/gtest/src/gtest-death-test.cc | 1344 +++++ test/fmw/gtest/src/gtest-filepath.cc | 382 ++ test/fmw/gtest/src/gtest-internal-inl.h | 1218 ++++ test/fmw/gtest/src/gtest-port.cc | 805 +++ test/fmw/gtest/src/gtest-printers.cc | 363 ++ test/fmw/gtest/src/gtest-test-part.cc | 110 + test/fmw/gtest/src/gtest-typed-test.cc | 110 + test/fmw/gtest/src/gtest.cc | 5015 ++++++++++++++++ test/fmw/gtest/src/gtest_main.cc | 38 + 44 files changed, 32036 insertions(+), 8 deletions(-) create mode 100644 test/fmw/gtest/CHANGES create mode 100644 test/fmw/gtest/LICENSE create mode 100644 test/fmw/gtest/README create mode 100644 test/fmw/gtest/include/gtest/gtest-death-test.h create mode 100644 test/fmw/gtest/include/gtest/gtest-message.h create mode 100644 test/fmw/gtest/include/gtest/gtest-param-test.h create mode 100644 test/fmw/gtest/include/gtest/gtest-param-test.h.pump create mode 100644 test/fmw/gtest/include/gtest/gtest-printers.h create mode 100644 test/fmw/gtest/include/gtest/gtest-spi.h create mode 100644 test/fmw/gtest/include/gtest/gtest-test-part.h create mode 100644 test/fmw/gtest/include/gtest/gtest-typed-test.h create mode 100644 test/fmw/gtest/include/gtest/gtest.h create mode 100644 test/fmw/gtest/include/gtest/gtest_pred_impl.h create mode 100644 test/fmw/gtest/include/gtest/gtest_prod.h create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-death-test-internal.h create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-filepath.h create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-internal.h create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-linked_ptr.h create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h.pump create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-param-util.h create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-port.h create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-string.h create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-tuple.h create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-tuple.h.pump create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-type-util.h create mode 100644 test/fmw/gtest/include/gtest/internal/gtest-type-util.h.pump create mode 100644 test/fmw/gtest/src/gtest-all.cc create mode 100644 test/fmw/gtest/src/gtest-death-test.cc create mode 100644 test/fmw/gtest/src/gtest-filepath.cc create mode 100644 test/fmw/gtest/src/gtest-internal-inl.h create mode 100644 test/fmw/gtest/src/gtest-port.cc create mode 100644 test/fmw/gtest/src/gtest-printers.cc create mode 100644 test/fmw/gtest/src/gtest-test-part.cc create mode 100644 test/fmw/gtest/src/gtest-typed-test.cc create mode 100644 test/fmw/gtest/src/gtest.cc create mode 100644 test/fmw/gtest/src/gtest_main.cc diff --git a/common/autoconf/buildjdk-spec.gmk.in b/common/autoconf/buildjdk-spec.gmk.in index 89167a388fb..e02f893c515 100644 --- a/common/autoconf/buildjdk-spec.gmk.in +++ b/common/autoconf/buildjdk-spec.gmk.in @@ -133,8 +133,9 @@ ifeq ($(JVM_INTERPRETER), cpp) endif HOTSPOT_MAKE_ARGS := product docs export_product -# Control wether Hotspot runs Queens test after building -TEST_IN_BUILD := false + +# Control wether Hotspot builds gtest tests +BUILD_GTEST := false USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@ diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 2da06049d7f..9def48f6cfa 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -652,6 +652,7 @@ MEMORY_SIZE NUM_CORES BUILD_FAILURE_HANDLER ENABLE_INTREE_EC +STLPORT_LIB LIBZIP_CAN_USE_MMAP LIBDL LIBM @@ -4701,6 +4702,13 @@ VALID_JVM_VARIANTS="server client minimal core zero zeroshark custom" ################################################################################ +################################################################################ +# libstlport.so.1 is needed for running gtest on Solaris. Find it to +# redistribute it in the test image. +################################################################################ + + + # # Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -5042,7 +5050,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1462268995 +DATE_WHEN_GENERATED=1462793660 ############################################################################### # @@ -63697,6 +63705,157 @@ fi + if test "$OPENJDK_TARGET_OS" = "solaris"; then + # Find the root of the Solaris Studio installation from the compiler path + SOLARIS_STUDIO_DIR="$(dirname $CC)/.." + STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libstlport.so.1" >&5 +$as_echo_n "checking for libstlport.so.1... " >&6; } + if test -f "$STLPORT_LIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, $STLPORT_LIB" >&5 +$as_echo "yes, $STLPORT_LIB" >&6; } + + # Only process if variable expands to non-empty + + if test "x$STLPORT_LIB" != x; then + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # Input might be given as Windows format, start by converting to + # unix format. + path="$STLPORT_LIB" + new_path=`$CYGPATH -u "$path"` + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file precense. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STLPORT_LIB, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of STLPORT_LIB, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Cannot locate the the path of STLPORT_LIB" "$LINENO" 5 + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-style (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + + if test "x$path" != "x$new_path"; then + STLPORT_LIB="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting STLPORT_LIB to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting STLPORT_LIB to \"$new_path\"" >&6;} + fi + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + path="$STLPORT_LIB" + has_colon=`$ECHO $path | $GREP ^.:` + new_path="$path" + if test "x$has_colon" = x; then + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $path` + fi + + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + if test "x$path" != "x$new_path"; then + STLPORT_LIB="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting STLPORT_LIB to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting STLPORT_LIB to \"$new_path\"" >&6;} + fi + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + + else + # We're on a unix platform. Hooray! :) + path="$STLPORT_LIB" + has_space=`$ECHO "$path" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STLPORT_LIB, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of STLPORT_LIB, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 + fi + + # Use eval to expand a potential ~ + eval path="$path" + if test ! -f "$path" && test ! -d "$path"; then + as_fn_error $? "The path of STLPORT_LIB, which resolves as \"$path\", is not found." "$LINENO" 5 + fi + + if test -d "$path"; then + STLPORT_LIB="`cd "$path"; $THEPWDCMD -L`" + else + dir="`$DIRNAME "$path"`" + base="`$BASENAME "$path"`" + STLPORT_LIB="`cd "$dir"; $THEPWDCMD -L`/$base" + fi + fi + fi + + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, not found at $STLPORT_LIB" >&5 +$as_echo "no, not found at $STLPORT_LIB" >&6; } + as_fn_error $? "Failed to find libstlport.so.1, cannot build Hotspot gtests" "$LINENO" 5 + fi + + fi + + + diff --git a/common/autoconf/libraries.m4 b/common/autoconf/libraries.m4 index e1e91d678d6..4238a17fe82 100644 --- a/common/autoconf/libraries.m4 +++ b/common/autoconf/libraries.m4 @@ -95,6 +95,7 @@ AC_DEFUN_ONCE([LIB_SETUP_LIBRARIES], LIB_SETUP_LLVM LIB_SETUP_BUNDLED_LIBS LIB_SETUP_MISC_LIBS + LIB_SETUP_SOLARIS_STLPORT ]) ################################################################################ @@ -189,3 +190,26 @@ AC_DEFUN_ONCE([LIB_SETUP_MISC_LIBS], LIBZIP_CAN_USE_MMAP=true AC_SUBST(LIBZIP_CAN_USE_MMAP) ]) + +################################################################################ +# libstlport.so.1 is needed for running gtest on Solaris. Find it to +# redistribute it in the test image. +################################################################################ +AC_DEFUN_ONCE([LIB_SETUP_SOLARIS_STLPORT], +[ + if test "$OPENJDK_TARGET_OS" = "solaris"; then + # Find the root of the Solaris Studio installation from the compiler path + SOLARIS_STUDIO_DIR="$(dirname $CC)/.." + STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1" + AC_MSG_CHECKING([for libstlport.so.1]) + if test -f "$STLPORT_LIB"; then + AC_MSG_RESULT([yes, $STLPORT_LIB]) + BASIC_FIXUP_PATH([STLPORT_LIB]) + else + AC_MSG_RESULT([no, not found at $STLPORT_LIB]) + AC_MSG_ERROR([Failed to find libstlport.so.1, cannot build Hotspot gtests]) + fi + AC_SUBST(STLPORT_LIB) + fi +]) + diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 0d51a3e7c48..69d58cc06ab 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -232,6 +232,9 @@ JVM_FEATURES_custom := @JVM_FEATURES_custom@ VALID_JVM_FEATURES := @VALID_JVM_FEATURES@ VALID_JVM_VARIANTS := @VALID_JVM_VARIANTS@ +# Control wether Hotspot builds gtest tests +BUILD_GTEST := true + # Control use of precompiled header in hotspot libjvm build USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@ @@ -684,6 +687,7 @@ USE_EXTERNAL_LIBZ:=@USE_EXTERNAL_LIBZ@ LIBZIP_CAN_USE_MMAP:=@LIBZIP_CAN_USE_MMAP@ MSVCR_DLL:=@MSVCR_DLL@ MSVCP_DLL:=@MSVCP_DLL@ +STLPORT_LIB:=@STLPORT_LIB@ #################################################### # diff --git a/make/Main.gmk b/make/Main.gmk index a95ec2ae5f3..fe179d3648b 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -388,6 +388,11 @@ test-image-jdk-jtreg-native: +($(CD) $(JDK_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNative.gmk \ test-image-jdk-jtreg-native) +ifeq ($(BUILD_GTEST), true) + test-image-hotspot-gtest: + +($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f GtestImage.gmk) +endif + build-test-lib: +($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f BuildTestLib.gmk) @@ -411,7 +416,7 @@ endif ALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \ test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \ test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \ - test-failure-handler test-image-failure-handler + test-failure-handler test-image-failure-handler test-image-hotspot-gtest ################################################################################ # Run tests @@ -624,6 +629,8 @@ else test-image-jdk-jtreg-native: build-test-jdk-jtreg-native + test-image-hotspot-gtest: hotspot + test-hotspot-internal: exploded-image test-hotspot-jtreg: jimages test-image @@ -705,7 +712,7 @@ docs-image: docs-javadoc docs-jvmtidoc # This target builds the test image test-image: prepare-test-image test-image-hotspot-jtreg-native \ - test-image-jdk-jtreg-native test-image-failure-handler + test-image-jdk-jtreg-native test-image-failure-handler test-image-hotspot-gtest # all-images is the top-most target, it builds all our deliverables ("images"). all-images: product-images test-image docs-image diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk index d595e044013..62fd2287867 100644 --- a/make/common/NativeCompilation.gmk +++ b/make/common/NativeCompilation.gmk @@ -372,6 +372,9 @@ endef # toolchain when compiling C++ code # STRIP_SYMBOLS Set to true to strip the final binary if the toolchain allows for it # DEBUG_SYMBOLS Set to false to disable generation of debug symbols +# COPY_DEBUG_SYMBOLS Set to false to override global setting of debug symbol copying +# ZIP_EXTERNAL_DEBUG_SYMBOLS Set to false to override global setting of debug symbol +# zipping # CFLAGS_DEBUG_SYMBOLS Overrides the default cflags for enabling debug symbols # CXXFLAGS_DEBUG_SYMBOLS Overrides the default cxxflags for enabling debug symbols # STRIPFLAGS Optionally change the flags given to the strip command @@ -807,7 +810,15 @@ define SetupNativeCompilationBody # Need to make sure TARGET is first on list $1 := $$($1_TARGET) - ifeq ($(COPY_DEBUG_SYMBOLS), true) + ifneq ($$($1_COPY_DEBUG_SYMBOLS), false) + $1_COPY_DEBUG_SYMBOLS := $(COPY_DEBUG_SYMBOLS) + endif + + ifneq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), false) + $1_ZIP_EXTERNAL_DEBUG_SYMBOLS := $(ZIP_EXTERNAL_DEBUG_SYMBOLS) + endif + + ifeq ($$($1_COPY_DEBUG_SYMBOLS), true) ifneq ($$($1_DEBUG_SYMBOLS), false) # Only copy debug symbols for dynamic libraries and programs. ifeq ($$($1_STATIC_LIBRARY), ) @@ -854,7 +865,7 @@ define SetupNativeCompilationBody $$($1_TARGET): $$($1_DEBUGINFO_FILES) $$($1_DEBUGINFO_FILES): $$($1_ALL_OBJS) - ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true) + ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true) $1_DEBUGINFO_ZIP := $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).diz $1 += $$(subst $$($1_OBJECT_DIR),$$($1_OUTPUT_DIR),$$($1_DEBUGINFO_ZIP)) diff --git a/make/jprt.properties b/make/jprt.properties index 40a75b1140f..0e558641f98 100644 --- a/make/jprt.properties +++ b/make/jprt.properties @@ -438,6 +438,16 @@ my.make.rule.test.targets.hotspot.basicvmtests= \ windows_i586_6.3-*-default-hotspot_basicvmtest, \ windows_x64_6.3-*-default-hotspot_basicvmtest +my.make.rule.test.targets.hotspot.gtest= \ + linux_i586_3.8-*-default-hotspot_gtest, \ + linux_x64_3.8-*-default-hotspot_gtest, \ + macosx_x64_10.9-*-default-hotspot_gtest, \ + solaris_sparcv9_5.11-*-default-hotspot_gtest, \ + solaris_x64_5.11-*-default-hotspot_gtest, \ + windows_i586_6.3-*-default-hotspot_gtest, \ + windows_x64_6.3-*-default-hotspot_gtest, \ + ${my.additional.make.rule.test.targets.hotspot.gtest} + my.make.rule.test.targets.hotspot.reg.group= \ solaris_sparcv9_5.11-fastdebug-c2-GROUP, \ solaris_x64_5.11-fastdebug-c2-GROUP, \ @@ -465,6 +475,7 @@ my.make.rule.test.targets.hotspot.reg= \ # Other Makefile based Hotspot tests my.make.rule.test.targets.hotspot.other= \ ${my.make.rule.test.targets.hotspot.basicvmtests}, \ + ${my.make.rule.test.targets.hotspot.gtest}, \ ${my.additional.make.rule.test.targets.hotspot.other} # All the makefile based tests to run @@ -474,7 +485,9 @@ my.make.rule.test.targets.hotspot= \ # Install the test bundle for the testset hotspot jtreg tests # (but not for the other Makefile based tests) -my.jprt.test.bundle.targets.hotspot=${my.make.rule.test.targets.hotspot.reg} +my.jprt.test.bundle.targets.hotspot= \ + ${my.make.rule.test.targets.hotspot.reg}, \ + ${my.make.rule.test.targets.hotspot.gtest} # Native jdk and hotspot test targets (testset=nativesanity) my.make.rule.test.targets.nativesanity= \ diff --git a/test/fmw/gtest/CHANGES b/test/fmw/gtest/CHANGES new file mode 100644 index 00000000000..05521324212 --- /dev/null +++ b/test/fmw/gtest/CHANGES @@ -0,0 +1,157 @@ +Changes for 1.7.0: + +* New feature: death tests are supported on OpenBSD and in iOS + simulator now. +* New feature: Google Test now implements a protocol to allow + a test runner to detect that a test program has exited + prematurely and report it as a failure (before it would be + falsely reported as a success if the exit code is 0). +* New feature: Test::RecordProperty() can now be used outside of the + lifespan of a test method, in which case it will be attributed to + the current test case or the test program in the XML report. +* New feature (potentially breaking): --gtest_list_tests now prints + the type parameters and value parameters for each test. +* Improvement: char pointers and char arrays are now escaped properly + in failure messages. +* Improvement: failure summary in XML reports now includes file and + line information. +* Improvement: the XML element now has a timestamp attribute. +* Improvement: When --gtest_filter is specified, XML report now doesn't + contain information about tests that are filtered out. +* Fixed the bug where long --gtest_filter flag values are truncated in + death tests. +* Potentially breaking change: RUN_ALL_TESTS() is now implemented as a + function instead of a macro in order to work better with Clang. +* Compatibility fixes with C++ 11 and various platforms. +* Bug/warning fixes. + +Changes for 1.6.0: + +* New feature: ADD_FAILURE_AT() for reporting a test failure at the + given source location -- useful for writing testing utilities. +* New feature: the universal value printer is moved from Google Mock + to Google Test. +* New feature: type parameters and value parameters are reported in + the XML report now. +* A gtest_disable_pthreads CMake option. +* Colored output works in GNU Screen sessions now. +* Parameters of value-parameterized tests are now printed in the + textual output. +* Failures from ad hoc test assertions run before RUN_ALL_TESTS() are + now correctly reported. +* Arguments of ASSERT_XY and EXPECT_XY no longer need to support << to + ostream. +* More complete handling of exceptions. +* GTEST_ASSERT_XY can be used instead of ASSERT_XY in case the latter + name is already used by another library. +* --gtest_catch_exceptions is now true by default, allowing a test + program to continue after an exception is thrown. +* Value-parameterized test fixtures can now derive from Test and + WithParamInterface separately, easing conversion of legacy tests. +* Death test messages are clearly marked to make them more + distinguishable from other messages. +* Compatibility fixes for Android, Google Native Client, MinGW, HP UX, + PowerPC, Lucid autotools, libCStd, Sun C++, Borland C++ Builder (Code Gear), + IBM XL C++ (Visual Age C++), and C++0x. +* Bug fixes and implementation clean-ups. +* Potentially incompatible changes: disables the harmful 'make install' + command in autotools. + +Changes for 1.5.0: + + * New feature: assertions can be safely called in multiple threads + where the pthreads library is available. + * New feature: predicates used inside EXPECT_TRUE() and friends + can now generate custom failure messages. + * New feature: Google Test can now be compiled as a DLL. + * New feature: fused source files are included. + * New feature: prints help when encountering unrecognized Google Test flags. + * Experimental feature: CMake build script (requires CMake 2.6.4+). + * Experimental feature: the Pump script for meta programming. + * double values streamed to an assertion are printed with enough precision + to differentiate any two different values. + * Google Test now works on Solaris and AIX. + * Build and test script improvements. + * Bug fixes and implementation clean-ups. + + Potentially breaking changes: + + * Stopped supporting VC++ 7.1 with exceptions disabled. + * Dropped support for 'make install'. + +Changes for 1.4.0: + + * New feature: the event listener API + * New feature: test shuffling + * New feature: the XML report format is closer to junitreport and can + be parsed by Hudson now. + * New feature: when a test runs under Visual Studio, its failures are + integrated in the IDE. + * New feature: /MD(d) versions of VC++ projects. + * New feature: elapsed time for the tests is printed by default. + * New feature: comes with a TR1 tuple implementation such that Boost + is no longer needed for Combine(). + * New feature: EXPECT_DEATH_IF_SUPPORTED macro and friends. + * New feature: the Xcode project can now produce static gtest + libraries in addition to a framework. + * Compatibility fixes for Solaris, Cygwin, minGW, Windows Mobile, + Symbian, gcc, and C++Builder. + * Bug fixes and implementation clean-ups. + +Changes for 1.3.0: + + * New feature: death tests on Windows, Cygwin, and Mac. + * New feature: ability to use Google Test assertions in other testing + frameworks. + * New feature: ability to run disabled test via + --gtest_also_run_disabled_tests. + * New feature: the --help flag for printing the usage. + * New feature: access to Google Test flag values in user code. + * New feature: a script that packs Google Test into one .h and one + .cc file for easy deployment. + * New feature: support for distributing test functions to multiple + machines (requires support from the test runner). + * Bug fixes and implementation clean-ups. + +Changes for 1.2.1: + + * Compatibility fixes for Linux IA-64 and IBM z/OS. + * Added support for using Boost and other TR1 implementations. + * Changes to the build scripts to support upcoming release of Google C++ + Mocking Framework. + * Added Makefile to the distribution package. + * Improved build instructions in README. + +Changes for 1.2.0: + + * New feature: value-parameterized tests. + * New feature: the ASSERT/EXPECT_(NON)FATAL_FAILURE(_ON_ALL_THREADS) + macros. + * Changed the XML report format to match JUnit/Ant's. + * Added tests to the Xcode project. + * Added scons/SConscript for building with SCons. + * Added src/gtest-all.cc for building Google Test from a single file. + * Fixed compatibility with Solaris and z/OS. + * Enabled running Python tests on systems with python 2.3 installed, + e.g. Mac OS X 10.4. + * Bug fixes. + +Changes for 1.1.0: + + * New feature: type-parameterized tests. + * New feature: exception assertions. + * New feature: printing elapsed time of tests. + * Improved the robustness of death tests. + * Added an Xcode project and samples. + * Adjusted the output format on Windows to be understandable by Visual Studio. + * Minor bug fixes. + +Changes for 1.0.1: + + * Added project files for Visual Studio 7.1. + * Fixed issues with compiling on Mac OS X. + * Fixed issues with compiling on Cygwin. + +Changes for 1.0.0: + + * Initial Open Source release of Google Test diff --git a/test/fmw/gtest/LICENSE b/test/fmw/gtest/LICENSE new file mode 100644 index 00000000000..1941a11f8ce --- /dev/null +++ b/test/fmw/gtest/LICENSE @@ -0,0 +1,28 @@ +Copyright 2008, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/test/fmw/gtest/README b/test/fmw/gtest/README new file mode 100644 index 00000000000..26f35a84794 --- /dev/null +++ b/test/fmw/gtest/README @@ -0,0 +1,435 @@ +Google C++ Testing Framework +============================ + +http://code.google.com/p/googletest/ + +Overview +-------- + +Google's framework for writing C++ tests on a variety of platforms +(Linux, Mac OS X, Windows, Windows CE, Symbian, etc). Based on the +xUnit architecture. Supports automatic test discovery, a rich set of +assertions, user-defined assertions, death tests, fatal and non-fatal +failures, various options for running the tests, and XML test report +generation. + +Please see the project page above for more information as well as the +mailing list for questions, discussions, and development. There is +also an IRC channel on OFTC (irc.oftc.net) #gtest available. Please +join us! + +Requirements for End Users +-------------------------- + +Google Test is designed to have fairly minimal requirements to build +and use with your projects, but there are some. Currently, we support +Linux, Windows, Mac OS X, and Cygwin. We will also make our best +effort to support other platforms (e.g. Solaris, AIX, and z/OS). +However, since core members of the Google Test project have no access +to these platforms, Google Test may have outstanding issues there. If +you notice any problems on your platform, please notify +googletestframework@googlegroups.com. Patches for fixing them are +even more welcome! + +### Linux Requirements ### + +These are the base requirements to build and use Google Test from a source +package (as described below): + * GNU-compatible Make or gmake + * POSIX-standard shell + * POSIX(-2) Regular Expressions (regex.h) + * A C++98-standard-compliant compiler + +### Windows Requirements ### + + * Microsoft Visual C++ 7.1 or newer + +### Cygwin Requirements ### + + * Cygwin 1.5.25-14 or newer + +### Mac OS X Requirements ### + + * Mac OS X 10.4 Tiger or newer + * Developer Tools Installed + +Also, you'll need CMake 2.6.4 or higher if you want to build the +samples using the provided CMake script, regardless of the platform. + +Requirements for Contributors +----------------------------- + +We welcome patches. If you plan to contribute a patch, you need to +build Google Test and its own tests from an SVN checkout (described +below), which has further requirements: + + * Python version 2.3 or newer (for running some of the tests and + re-generating certain source files from templates) + * CMake 2.6.4 or newer + +Getting the Source +------------------ + +There are two primary ways of getting Google Test's source code: you +can download a stable source release in your preferred archive format, +or directly check out the source from our Subversion (SVN) repositary. +The SVN checkout requires a few extra steps and some extra software +packages on your system, but lets you track the latest development and +make patches much more easily, so we highly encourage it. + +### Source Package ### + +Google Test is released in versioned source packages which can be +downloaded from the download page [1]. Several different archive +formats are provided, but the only difference is the tools used to +manipulate them, and the size of the resulting file. Download +whichever you are most comfortable with. + + [1] http://code.google.com/p/googletest/downloads/list + +Once the package is downloaded, expand it using whichever tools you +prefer for that type. This will result in a new directory with the +name "gtest-X.Y.Z" which contains all of the source code. Here are +some examples on Linux: + + tar -xvzf gtest-X.Y.Z.tar.gz + tar -xvjf gtest-X.Y.Z.tar.bz2 + unzip gtest-X.Y.Z.zip + +### SVN Checkout ### + +To check out the main branch (also known as the "trunk") of Google +Test, run the following Subversion command: + + svn checkout http://googletest.googlecode.com/svn/trunk/ gtest-svn + +Setting up the Build +-------------------- + +To build Google Test and your tests that use it, you need to tell your +build system where to find its headers and source files. The exact +way to do it depends on which build system you use, and is usually +straightforward. + +### Generic Build Instructions ### + +Suppose you put Google Test in directory ${GTEST_DIR}. To build it, +create a library build target (or a project as called by Visual Studio +and Xcode) to compile + + ${GTEST_DIR}/src/gtest-all.cc + +with ${GTEST_DIR}/include in the system header search path and ${GTEST_DIR} +in the normal header search path. Assuming a Linux-like system and gcc, +something like the following will do: + + g++ -isystem ${GTEST_DIR}/include -I${GTEST_DIR} \ + -pthread -c ${GTEST_DIR}/src/gtest-all.cc + ar -rv libgtest.a gtest-all.o + +(We need -pthread as Google Test uses threads.) + +Next, you should compile your test source file with +${GTEST_DIR}/include in the system header search path, and link it +with gtest and any other necessary libraries: + + g++ -isystem ${GTEST_DIR}/include -pthread path/to/your_test.cc libgtest.a \ + -o your_test + +As an example, the make/ directory contains a Makefile that you can +use to build Google Test on systems where GNU make is available +(e.g. Linux, Mac OS X, and Cygwin). It doesn't try to build Google +Test's own tests. Instead, it just builds the Google Test library and +a sample test. You can use it as a starting point for your own build +script. + +If the default settings are correct for your environment, the +following commands should succeed: + + cd ${GTEST_DIR}/make + make + ./sample1_unittest + +If you see errors, try to tweak the contents of make/Makefile to make +them go away. There are instructions in make/Makefile on how to do +it. + +### Using CMake ### + +Google Test comes with a CMake build script (CMakeLists.txt) that can +be used on a wide range of platforms ("C" stands for cross-platofrm.). +If you don't have CMake installed already, you can download it for +free from http://www.cmake.org/. + +CMake works by generating native makefiles or build projects that can +be used in the compiler environment of your choice. The typical +workflow starts with: + + mkdir mybuild # Create a directory to hold the build output. + cd mybuild + cmake ${GTEST_DIR} # Generate native build scripts. + +If you want to build Google Test's samples, you should replace the +last command with + + cmake -Dgtest_build_samples=ON ${GTEST_DIR} + +If you are on a *nix system, you should now see a Makefile in the +current directory. Just type 'make' to build gtest. + +If you use Windows and have Vistual Studio installed, a gtest.sln file +and several .vcproj files will be created. You can then build them +using Visual Studio. + +On Mac OS X with Xcode installed, a .xcodeproj file will be generated. + +### Legacy Build Scripts ### + +Before settling on CMake, we have been providing hand-maintained build +projects/scripts for Visual Studio, Xcode, and Autotools. While we +continue to provide them for convenience, they are not actively +maintained any more. We highly recommend that you follow the +instructions in the previous two sections to integrate Google Test +with your existing build system. + +If you still need to use the legacy build scripts, here's how: + +The msvc\ folder contains two solutions with Visual C++ projects. +Open the gtest.sln or gtest-md.sln file using Visual Studio, and you +are ready to build Google Test the same way you build any Visual +Studio project. Files that have names ending with -md use DLL +versions of Microsoft runtime libraries (the /MD or the /MDd compiler +option). Files without that suffix use static versions of the runtime +libraries (the /MT or the /MTd option). Please note that one must use +the same option to compile both gtest and the test code. If you use +Visual Studio 2005 or above, we recommend the -md version as /MD is +the default for new projects in these versions of Visual Studio. + +On Mac OS X, open the gtest.xcodeproj in the xcode/ folder using +Xcode. Build the "gtest" target. The universal binary framework will +end up in your selected build directory (selected in the Xcode +"Preferences..." -> "Building" pane and defaults to xcode/build). +Alternatively, at the command line, enter: + + xcodebuild + +This will build the "Release" configuration of gtest.framework in your +default build location. See the "xcodebuild" man page for more +information about building different configurations and building in +different locations. + +If you wish to use the Google Test Xcode project with Xcode 4.x and +above, you need to either: + * update the SDK configuration options in xcode/Config/General.xconfig. + Comment options SDKROOT, MACOS_DEPLOYMENT_TARGET, and GCC_VERSION. If + you choose this route you lose the ability to target earlier versions + of MacOS X. + * Install an SDK for an earlier version. This doesn't appear to be + supported by Apple, but has been reported to work + (http://stackoverflow.com/questions/5378518). + +Tweaking Google Test +-------------------- + +Google Test can be used in diverse environments. The default +configuration may not work (or may not work well) out of the box in +some environments. However, you can easily tweak Google Test by +defining control macros on the compiler command line. Generally, +these macros are named like GTEST_XYZ and you define them to either 1 +or 0 to enable or disable a certain feature. + +We list the most frequently used macros below. For a complete list, +see file include/gtest/internal/gtest-port.h. + +### Choosing a TR1 Tuple Library ### + +Some Google Test features require the C++ Technical Report 1 (TR1) +tuple library, which is not yet available with all compilers. The +good news is that Google Test implements a subset of TR1 tuple that's +enough for its own need, and will automatically use this when the +compiler doesn't provide TR1 tuple. + +Usually you don't need to care about which tuple library Google Test +uses. However, if your project already uses TR1 tuple, you need to +tell Google Test to use the same TR1 tuple library the rest of your +project uses, or the two tuple implementations will clash. To do +that, add + + -DGTEST_USE_OWN_TR1_TUPLE=0 + +to the compiler flags while compiling Google Test and your tests. If +you want to force Google Test to use its own tuple library, just add + + -DGTEST_USE_OWN_TR1_TUPLE=1 + +to the compiler flags instead. + +If you don't want Google Test to use tuple at all, add + + -DGTEST_HAS_TR1_TUPLE=0 + +and all features using tuple will be disabled. + +### Multi-threaded Tests ### + +Google Test is thread-safe where the pthread library is available. +After #include "gtest/gtest.h", you can check the GTEST_IS_THREADSAFE +macro to see whether this is the case (yes if the macro is #defined to +1, no if it's undefined.). + +If Google Test doesn't correctly detect whether pthread is available +in your environment, you can force it with + + -DGTEST_HAS_PTHREAD=1 + +or + + -DGTEST_HAS_PTHREAD=0 + +When Google Test uses pthread, you may need to add flags to your +compiler and/or linker to select the pthread library, or you'll get +link errors. If you use the CMake script or the deprecated Autotools +script, this is taken care of for you. If you use your own build +script, you'll need to read your compiler and linker's manual to +figure out what flags to add. + +### As a Shared Library (DLL) ### + +Google Test is compact, so most users can build and link it as a +static library for the simplicity. You can choose to use Google Test +as a shared library (known as a DLL on Windows) if you prefer. + +To compile *gtest* as a shared library, add + + -DGTEST_CREATE_SHARED_LIBRARY=1 + +to the compiler flags. You'll also need to tell the linker to produce +a shared library instead - consult your linker's manual for how to do +it. + +To compile your *tests* that use the gtest shared library, add + + -DGTEST_LINKED_AS_SHARED_LIBRARY=1 + +to the compiler flags. + +Note: while the above steps aren't technically necessary today when +using some compilers (e.g. GCC), they may become necessary in the +future, if we decide to improve the speed of loading the library (see +http://gcc.gnu.org/wiki/Visibility for details). Therefore you are +recommended to always add the above flags when using Google Test as a +shared library. Otherwise a future release of Google Test may break +your build script. + +### Avoiding Macro Name Clashes ### + +In C++, macros don't obey namespaces. Therefore two libraries that +both define a macro of the same name will clash if you #include both +definitions. In case a Google Test macro clashes with another +library, you can force Google Test to rename its macro to avoid the +conflict. + +Specifically, if both Google Test and some other code define macro +FOO, you can add + + -DGTEST_DONT_DEFINE_FOO=1 + +to the compiler flags to tell Google Test to change the macro's name +from FOO to GTEST_FOO. Currently FOO can be FAIL, SUCCEED, or TEST. +For example, with -DGTEST_DONT_DEFINE_TEST=1, you'll need to write + + GTEST_TEST(SomeTest, DoesThis) { ... } + +instead of + + TEST(SomeTest, DoesThis) { ... } + +in order to define a test. + +Upgrating from an Earlier Version +--------------------------------- + +We strive to keep Google Test releases backward compatible. +Sometimes, though, we have to make some breaking changes for the +users' long-term benefits. This section describes what you'll need to +do if you are upgrading from an earlier version of Google Test. + +### Upgrading from 1.3.0 or Earlier ### + +You may need to explicitly enable or disable Google Test's own TR1 +tuple library. See the instructions in section "Choosing a TR1 Tuple +Library". + +### Upgrading from 1.4.0 or Earlier ### + +The Autotools build script (configure + make) is no longer officially +supportted. You are encouraged to migrate to your own build system or +use CMake. If you still need to use Autotools, you can find +instructions in the README file from Google Test 1.4.0. + +On platforms where the pthread library is available, Google Test uses +it in order to be thread-safe. See the "Multi-threaded Tests" section +for what this means to your build script. + +If you use Microsoft Visual C++ 7.1 with exceptions disabled, Google +Test will no longer compile. This should affect very few people, as a +large portion of STL (including ) doesn't compile in this mode +anyway. We decided to stop supporting it in order to greatly simplify +Google Test's implementation. + +Developing Google Test +---------------------- + +This section discusses how to make your own changes to Google Test. + +### Testing Google Test Itself ### + +To make sure your changes work as intended and don't break existing +functionality, you'll want to compile and run Google Test's own tests. +For that you can use CMake: + + mkdir mybuild + cd mybuild + cmake -Dgtest_build_tests=ON ${GTEST_DIR} + +Make sure you have Python installed, as some of Google Test's tests +are written in Python. If the cmake command complains about not being +able to find Python ("Could NOT find PythonInterp (missing: +PYTHON_EXECUTABLE)"), try telling it explicitly where your Python +executable can be found: + + cmake -DPYTHON_EXECUTABLE=path/to/python -Dgtest_build_tests=ON ${GTEST_DIR} + +Next, you can build Google Test and all of its own tests. On *nix, +this is usually done by 'make'. To run the tests, do + + make test + +All tests should pass. + +### Regenerating Source Files ### + +Some of Google Test's source files are generated from templates (not +in the C++ sense) using a script. A template file is named FOO.pump, +where FOO is the name of the file it will generate. For example, the +file include/gtest/internal/gtest-type-util.h.pump is used to generate +gtest-type-util.h in the same directory. + +Normally you don't need to worry about regenerating the source files, +unless you need to modify them. In that case, you should modify the +corresponding .pump files instead and run the pump.py Python script to +regenerate them. You can find pump.py in the scripts/ directory. +Read the Pump manual [2] for how to use it. + + [2] http://code.google.com/p/googletest/wiki/PumpManual + +### Contributing a Patch ### + +We welcome patches. Please read the Google Test developer's guide [3] +for how you can contribute. In particular, make sure you have signed +the Contributor License Agreement, or we won't be able to accept the +patch. + + [3] http://code.google.com/p/googletest/wiki/GoogleTestDevGuide + +Happy testing! diff --git a/test/fmw/gtest/include/gtest/gtest-death-test.h b/test/fmw/gtest/include/gtest/gtest-death-test.h new file mode 100644 index 00000000000..957a69c6a9e --- /dev/null +++ b/test/fmw/gtest/include/gtest/gtest-death-test.h @@ -0,0 +1,294 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) +// +// The Google C++ Testing Framework (Google Test) +// +// This header file defines the public API for death tests. It is +// #included by gtest.h so a user doesn't need to include this +// directly. + +#ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_ +#define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_ + +#include "gtest/internal/gtest-death-test-internal.h" + +namespace testing { + +// This flag controls the style of death tests. Valid values are "threadsafe", +// meaning that the death test child process will re-execute the test binary +// from the start, running only a single death test, or "fast", +// meaning that the child process will execute the test logic immediately +// after forking. +GTEST_DECLARE_string_(death_test_style); + +#if GTEST_HAS_DEATH_TEST + +namespace internal { + +// Returns a Boolean value indicating whether the caller is currently +// executing in the context of the death test child process. Tools such as +// Valgrind heap checkers may need this to modify their behavior in death +// tests. IMPORTANT: This is an internal utility. Using it may break the +// implementation of death tests. User code MUST NOT use it. +GTEST_API_ bool InDeathTestChild(); + +} // namespace internal + +// The following macros are useful for writing death tests. + +// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is +// executed: +// +// 1. It generates a warning if there is more than one active +// thread. This is because it's safe to fork() or clone() only +// when there is a single thread. +// +// 2. The parent process clone()s a sub-process and runs the death +// test in it; the sub-process exits with code 0 at the end of the +// death test, if it hasn't exited already. +// +// 3. The parent process waits for the sub-process to terminate. +// +// 4. The parent process checks the exit code and error message of +// the sub-process. +// +// Examples: +// +// ASSERT_DEATH(server.SendMessage(56, "Hello"), "Invalid port number"); +// for (int i = 0; i < 5; i++) { +// EXPECT_DEATH(server.ProcessRequest(i), +// "Invalid request .* in ProcessRequest()") +// << "Failed to die on request " << i; +// } +// +// ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting"); +// +// bool KilledBySIGHUP(int exit_code) { +// return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP; +// } +// +// ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!"); +// +// On the regular expressions used in death tests: +// +// On POSIX-compliant systems (*nix), we use the library, +// which uses the POSIX extended regex syntax. +// +// On other platforms (e.g. Windows), we only support a simple regex +// syntax implemented as part of Google Test. This limited +// implementation should be enough most of the time when writing +// death tests; though it lacks many features you can find in PCRE +// or POSIX extended regex syntax. For example, we don't support +// union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and +// repetition count ("x{5,7}"), among others. +// +// Below is the syntax that we do support. We chose it to be a +// subset of both PCRE and POSIX extended regex, so it's easy to +// learn wherever you come from. In the following: 'A' denotes a +// literal character, period (.), or a single \\ escape sequence; +// 'x' and 'y' denote regular expressions; 'm' and 'n' are for +// natural numbers. +// +// c matches any literal character c +// \\d matches any decimal digit +// \\D matches any character that's not a decimal digit +// \\f matches \f +// \\n matches \n +// \\r matches \r +// \\s matches any ASCII whitespace, including \n +// \\S matches any character that's not a whitespace +// \\t matches \t +// \\v matches \v +// \\w matches any letter, _, or decimal digit +// \\W matches any character that \\w doesn't match +// \\c matches any literal character c, which must be a punctuation +// . matches any single character except \n +// A? matches 0 or 1 occurrences of A +// A* matches 0 or many occurrences of A +// A+ matches 1 or many occurrences of A +// ^ matches the beginning of a string (not that of each line) +// $ matches the end of a string (not that of each line) +// xy matches x followed by y +// +// If you accidentally use PCRE or POSIX extended regex features +// not implemented by us, you will get a run-time failure. In that +// case, please try to rewrite your regular expression within the +// above syntax. +// +// This implementation is *not* meant to be as highly tuned or robust +// as a compiled regex library, but should perform well enough for a +// death test, which already incurs significant overhead by launching +// a child process. +// +// Known caveats: +// +// A "threadsafe" style death test obtains the path to the test +// program from argv[0] and re-executes it in the sub-process. For +// simplicity, the current implementation doesn't search the PATH +// when launching the sub-process. This means that the user must +// invoke the test program via a path that contains at least one +// path separator (e.g. path/to/foo_test and +// /absolute/path/to/bar_test are fine, but foo_test is not). This +// is rarely a problem as people usually don't put the test binary +// directory in PATH. +// +// TODO(wan@google.com): make thread-safe death tests search the PATH. + +// Asserts that a given statement causes the program to exit, with an +// integer exit status that satisfies predicate, and emitting error output +// that matches regex. +# define ASSERT_EXIT(statement, predicate, regex) \ + GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_) + +// Like ASSERT_EXIT, but continues on to successive tests in the +// test case, if any: +# define EXPECT_EXIT(statement, predicate, regex) \ + GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_) + +// Asserts that a given statement causes the program to exit, either by +// explicitly exiting with a nonzero exit code or being killed by a +// signal, and emitting error output that matches regex. +# define ASSERT_DEATH(statement, regex) \ + ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) + +// Like ASSERT_DEATH, but continues on to successive tests in the +// test case, if any: +# define EXPECT_DEATH(statement, regex) \ + EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex) + +// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*: + +// Tests that an exit code describes a normal exit with a given exit code. +class GTEST_API_ ExitedWithCode { + public: + explicit ExitedWithCode(int exit_code); + bool operator()(int exit_status) const; + private: + // No implementation - assignment is unsupported. + void operator=(const ExitedWithCode& other); + + const int exit_code_; +}; + +# if !GTEST_OS_WINDOWS +// Tests that an exit code describes an exit due to termination by a +// given signal. +class GTEST_API_ KilledBySignal { + public: + explicit KilledBySignal(int signum); + bool operator()(int exit_status) const; + private: + const int signum_; +}; +# endif // !GTEST_OS_WINDOWS + +// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode. +// The death testing framework causes this to have interesting semantics, +// since the sideeffects of the call are only visible in opt mode, and not +// in debug mode. +// +// In practice, this can be used to test functions that utilize the +// LOG(DFATAL) macro using the following style: +// +// int DieInDebugOr12(int* sideeffect) { +// if (sideeffect) { +// *sideeffect = 12; +// } +// LOG(DFATAL) << "death"; +// return 12; +// } +// +// TEST(TestCase, TestDieOr12WorksInDgbAndOpt) { +// int sideeffect = 0; +// // Only asserts in dbg. +// EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death"); +// +// #ifdef NDEBUG +// // opt-mode has sideeffect visible. +// EXPECT_EQ(12, sideeffect); +// #else +// // dbg-mode no visible sideeffect. +// EXPECT_EQ(0, sideeffect); +// #endif +// } +// +// This will assert that DieInDebugReturn12InOpt() crashes in debug +// mode, usually due to a DCHECK or LOG(DFATAL), but returns the +// appropriate fallback value (12 in this case) in opt mode. If you +// need to test that a function has appropriate side-effects in opt +// mode, include assertions against the side-effects. A general +// pattern for this is: +// +// EXPECT_DEBUG_DEATH({ +// // Side-effects here will have an effect after this statement in +// // opt mode, but none in debug mode. +// EXPECT_EQ(12, DieInDebugOr12(&sideeffect)); +// }, "death"); +// +# ifdef NDEBUG + +# define EXPECT_DEBUG_DEATH(statement, regex) \ + GTEST_EXECUTE_STATEMENT_(statement, regex) + +# define ASSERT_DEBUG_DEATH(statement, regex) \ + GTEST_EXECUTE_STATEMENT_(statement, regex) + +# else + +# define EXPECT_DEBUG_DEATH(statement, regex) \ + EXPECT_DEATH(statement, regex) + +# define ASSERT_DEBUG_DEATH(statement, regex) \ + ASSERT_DEATH(statement, regex) + +# endif // NDEBUG for EXPECT_DEBUG_DEATH +#endif // GTEST_HAS_DEATH_TEST + +// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and +// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if +// death tests are supported; otherwise they just issue a warning. This is +// useful when you are combining death test assertions with normal test +// assertions in one test. +#if GTEST_HAS_DEATH_TEST +# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ + EXPECT_DEATH(statement, regex) +# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ + ASSERT_DEATH(statement, regex) +#else +# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \ + GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, ) +# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \ + GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return) +#endif + +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_ diff --git a/test/fmw/gtest/include/gtest/gtest-message.h b/test/fmw/gtest/include/gtest/gtest-message.h new file mode 100644 index 00000000000..fe879bca792 --- /dev/null +++ b/test/fmw/gtest/include/gtest/gtest-message.h @@ -0,0 +1,250 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) +// +// The Google C++ Testing Framework (Google Test) +// +// This header file defines the Message class. +// +// IMPORTANT NOTE: Due to limitation of the C++ language, we have to +// leave some internal implementation details in this header file. +// They are clearly marked by comments like this: +// +// // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +// +// Such code is NOT meant to be used by a user directly, and is subject +// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user +// program! + +#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ +#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ + +#include + +#include "gtest/internal/gtest-port.h" + +// Ensures that there is at least one operator<< in the global namespace. +// See Message& operator<<(...) below for why. +void operator<<(const testing::internal::Secret&, int); + +namespace testing { + +// The Message class works like an ostream repeater. +// +// Typical usage: +// +// 1. You stream a bunch of values to a Message object. +// It will remember the text in a stringstream. +// 2. Then you stream the Message object to an ostream. +// This causes the text in the Message to be streamed +// to the ostream. +// +// For example; +// +// testing::Message foo; +// foo << 1 << " != " << 2; +// std::cout << foo; +// +// will print "1 != 2". +// +// Message is not intended to be inherited from. In particular, its +// destructor is not virtual. +// +// Note that stringstream behaves differently in gcc and in MSVC. You +// can stream a NULL char pointer to it in the former, but not in the +// latter (it causes an access violation if you do). The Message +// class hides this difference by treating a NULL char pointer as +// "(null)". +class GTEST_API_ Message { + private: + // The type of basic IO manipulators (endl, ends, and flush) for + // narrow streams. + typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&); + + public: + // Constructs an empty Message. + Message(); + + // Copy constructor. + Message(const Message& msg) : ss_(new ::std::stringstream) { // NOLINT + *ss_ << msg.GetString(); + } + + // Constructs a Message from a C-string. + explicit Message(const char* str) : ss_(new ::std::stringstream) { + *ss_ << str; + } + +#if GTEST_OS_SYMBIAN + // Streams a value (either a pointer or not) to this object. + template + inline Message& operator <<(const T& value) { + StreamHelper(typename internal::is_pointer::type(), value); + return *this; + } +#else + // Streams a non-pointer value to this object. + template + inline Message& operator <<(const T& val) { + // Some libraries overload << for STL containers. These + // overloads are defined in the global namespace instead of ::std. + // + // C++'s symbol lookup rule (i.e. Koenig lookup) says that these + // overloads are visible in either the std namespace or the global + // namespace, but not other namespaces, including the testing + // namespace which Google Test's Message class is in. + // + // To allow STL containers (and other types that has a << operator + // defined in the global namespace) to be used in Google Test + // assertions, testing::Message must access the custom << operator + // from the global namespace. With this using declaration, + // overloads of << defined in the global namespace and those + // visible via Koenig lookup are both exposed in this function. + using ::operator <<; + *ss_ << val; + return *this; + } + + // Streams a pointer value to this object. + // + // This function is an overload of the previous one. When you + // stream a pointer to a Message, this definition will be used as it + // is more specialized. (The C++ Standard, section + // [temp.func.order].) If you stream a non-pointer, then the + // previous definition will be used. + // + // The reason for this overload is that streaming a NULL pointer to + // ostream is undefined behavior. Depending on the compiler, you + // may get "0", "(nil)", "(null)", or an access violation. To + // ensure consistent result across compilers, we always treat NULL + // as "(null)". + template + inline Message& operator <<(T* const& pointer) { // NOLINT + if (pointer == NULL) { + *ss_ << "(null)"; + } else { + *ss_ << pointer; + } + return *this; + } +#endif // GTEST_OS_SYMBIAN + + // Since the basic IO manipulators are overloaded for both narrow + // and wide streams, we have to provide this specialized definition + // of operator <<, even though its body is the same as the + // templatized version above. Without this definition, streaming + // endl or other basic IO manipulators to Message will confuse the + // compiler. + Message& operator <<(BasicNarrowIoManip val) { + *ss_ << val; + return *this; + } + + // Instead of 1/0, we want to see true/false for bool values. + Message& operator <<(bool b) { + return *this << (b ? "true" : "false"); + } + + // These two overloads allow streaming a wide C string to a Message + // using the UTF-8 encoding. + Message& operator <<(const wchar_t* wide_c_str); + Message& operator <<(wchar_t* wide_c_str); + +#if GTEST_HAS_STD_WSTRING + // Converts the given wide string to a narrow string using the UTF-8 + // encoding, and streams the result to this Message object. + Message& operator <<(const ::std::wstring& wstr); +#endif // GTEST_HAS_STD_WSTRING + +#if GTEST_HAS_GLOBAL_WSTRING + // Converts the given wide string to a narrow string using the UTF-8 + // encoding, and streams the result to this Message object. + Message& operator <<(const ::wstring& wstr); +#endif // GTEST_HAS_GLOBAL_WSTRING + + // Gets the text streamed to this object so far as an std::string. + // Each '\0' character in the buffer is replaced with "\\0". + // + // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + std::string GetString() const; + + private: + +#if GTEST_OS_SYMBIAN + // These are needed as the Nokia Symbian Compiler cannot decide between + // const T& and const T* in a function template. The Nokia compiler _can_ + // decide between class template specializations for T and T*, so a + // tr1::type_traits-like is_pointer works, and we can overload on that. + template + inline void StreamHelper(internal::true_type /*is_pointer*/, T* pointer) { + if (pointer == NULL) { + *ss_ << "(null)"; + } else { + *ss_ << pointer; + } + } + template + inline void StreamHelper(internal::false_type /*is_pointer*/, + const T& value) { + // See the comments in Message& operator <<(const T&) above for why + // we need this using statement. + using ::operator <<; + *ss_ << value; + } +#endif // GTEST_OS_SYMBIAN + + // We'll hold the text streamed to this object here. + const internal::scoped_ptr< ::std::stringstream> ss_; + + // We declare (but don't implement) this to prevent the compiler + // from implementing the assignment operator. + void operator=(const Message&); +}; + +// Streams a Message to an ostream. +inline std::ostream& operator <<(std::ostream& os, const Message& sb) { + return os << sb.GetString(); +} + +namespace internal { + +// Converts a streamable value to an std::string. A NULL pointer is +// converted to "(null)". When the input value is a ::string, +// ::std::string, ::wstring, or ::std::wstring object, each NUL +// character in it is replaced with "\\0". +template +std::string StreamableToString(const T& streamable) { + return (Message() << streamable).GetString(); +} + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_ diff --git a/test/fmw/gtest/include/gtest/gtest-param-test.h b/test/fmw/gtest/include/gtest/gtest-param-test.h new file mode 100644 index 00000000000..d6702c8f162 --- /dev/null +++ b/test/fmw/gtest/include/gtest/gtest-param-test.h @@ -0,0 +1,1421 @@ +// This file was GENERATED by command: +// pump.py gtest-param-test.h.pump +// DO NOT EDIT BY HAND!!! + +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Authors: vladl@google.com (Vlad Losev) +// +// Macros and functions for implementing parameterized tests +// in Google C++ Testing Framework (Google Test) +// +// This file is generated by a SCRIPT. DO NOT EDIT BY HAND! +// +#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ +#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ + + +// Value-parameterized tests allow you to test your code with different +// parameters without writing multiple copies of the same test. +// +// Here is how you use value-parameterized tests: + +#if 0 + +// To write value-parameterized tests, first you should define a fixture +// class. It is usually derived from testing::TestWithParam (see below for +// another inheritance scheme that's sometimes useful in more complicated +// class hierarchies), where the type of your parameter values. +// TestWithParam is itself derived from testing::Test. T can be any +// copyable type. If it's a raw pointer, you are responsible for managing the +// lifespan of the pointed values. + +class FooTest : public ::testing::TestWithParam { + // You can implement all the usual class fixture members here. +}; + +// Then, use the TEST_P macro to define as many parameterized tests +// for this fixture as you want. The _P suffix is for "parameterized" +// or "pattern", whichever you prefer to think. + +TEST_P(FooTest, DoesBlah) { + // Inside a test, access the test parameter with the GetParam() method + // of the TestWithParam class: + EXPECT_TRUE(foo.Blah(GetParam())); + ... +} + +TEST_P(FooTest, HasBlahBlah) { + ... +} + +// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test +// case with any set of parameters you want. Google Test defines a number +// of functions for generating test parameters. They return what we call +// (surprise!) parameter generators. Here is a summary of them, which +// are all in the testing namespace: +// +// +// Range(begin, end [, step]) - Yields values {begin, begin+step, +// begin+step+step, ...}. The values do not +// include end. step defaults to 1. +// Values(v1, v2, ..., vN) - Yields values {v1, v2, ..., vN}. +// ValuesIn(container) - Yields values from a C-style array, an STL +// ValuesIn(begin,end) container, or an iterator range [begin, end). +// Bool() - Yields sequence {false, true}. +// Combine(g1, g2, ..., gN) - Yields all combinations (the Cartesian product +// for the math savvy) of the values generated +// by the N generators. +// +// For more details, see comments at the definitions of these functions below +// in this file. +// +// The following statement will instantiate tests from the FooTest test case +// each with parameter values "meeny", "miny", and "moe". + +INSTANTIATE_TEST_CASE_P(InstantiationName, + FooTest, + Values("meeny", "miny", "moe")); + +// To distinguish different instances of the pattern, (yes, you +// can instantiate it more then once) the first argument to the +// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the +// actual test case name. Remember to pick unique prefixes for different +// instantiations. The tests from the instantiation above will have +// these names: +// +// * InstantiationName/FooTest.DoesBlah/0 for "meeny" +// * InstantiationName/FooTest.DoesBlah/1 for "miny" +// * InstantiationName/FooTest.DoesBlah/2 for "moe" +// * InstantiationName/FooTest.HasBlahBlah/0 for "meeny" +// * InstantiationName/FooTest.HasBlahBlah/1 for "miny" +// * InstantiationName/FooTest.HasBlahBlah/2 for "moe" +// +// You can use these names in --gtest_filter. +// +// This statement will instantiate all tests from FooTest again, each +// with parameter values "cat" and "dog": + +const char* pets[] = {"cat", "dog"}; +INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets)); + +// The tests from the instantiation above will have these names: +// +// * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat" +// * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog" +// * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat" +// * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog" +// +// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests +// in the given test case, whether their definitions come before or +// AFTER the INSTANTIATE_TEST_CASE_P statement. +// +// Please also note that generator expressions (including parameters to the +// generators) are evaluated in InitGoogleTest(), after main() has started. +// This allows the user on one hand, to adjust generator parameters in order +// to dynamically determine a set of tests to run and on the other hand, +// give the user a chance to inspect the generated tests with Google Test +// reflection API before RUN_ALL_TESTS() is executed. +// +// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc +// for more examples. +// +// In the future, we plan to publish the API for defining new parameter +// generators. But for now this interface remains part of the internal +// implementation and is subject to change. +// +// +// A parameterized test fixture must be derived from testing::Test and from +// testing::WithParamInterface, where T is the type of the parameter +// values. Inheriting from TestWithParam satisfies that requirement because +// TestWithParam inherits from both Test and WithParamInterface. In more +// complicated hierarchies, however, it is occasionally useful to inherit +// separately from Test and WithParamInterface. For example: + +class BaseTest : public ::testing::Test { + // You can inherit all the usual members for a non-parameterized test + // fixture here. +}; + +class DerivedTest : public BaseTest, public ::testing::WithParamInterface { + // The usual test fixture members go here too. +}; + +TEST_F(BaseTest, HasFoo) { + // This is an ordinary non-parameterized test. +} + +TEST_P(DerivedTest, DoesBlah) { + // GetParam works just the same here as if you inherit from TestWithParam. + EXPECT_TRUE(foo.Blah(GetParam())); +} + +#endif // 0 + +#include "gtest/internal/gtest-port.h" + +#if !GTEST_OS_SYMBIAN +# include +#endif + +// scripts/fuse_gtest.py depends on gtest's own header being #included +// *unconditionally*. Therefore these #includes cannot be moved +// inside #if GTEST_HAS_PARAM_TEST. +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-param-util.h" +#include "gtest/internal/gtest-param-util-generated.h" + +#if GTEST_HAS_PARAM_TEST + +namespace testing { + +// Functions producing parameter generators. +// +// Google Test uses these generators to produce parameters for value- +// parameterized tests. When a parameterized test case is instantiated +// with a particular generator, Google Test creates and runs tests +// for each element in the sequence produced by the generator. +// +// In the following sample, tests from test case FooTest are instantiated +// each three times with parameter values 3, 5, and 8: +// +// class FooTest : public TestWithParam { ... }; +// +// TEST_P(FooTest, TestThis) { +// } +// TEST_P(FooTest, TestThat) { +// } +// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8)); +// + +// Range() returns generators providing sequences of values in a range. +// +// Synopsis: +// Range(start, end) +// - returns a generator producing a sequence of values {start, start+1, +// start+2, ..., }. +// Range(start, end, step) +// - returns a generator producing a sequence of values {start, start+step, +// start+step+step, ..., }. +// Notes: +// * The generated sequences never include end. For example, Range(1, 5) +// returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2) +// returns a generator producing {1, 3, 5, 7}. +// * start and end must have the same type. That type may be any integral or +// floating-point type or a user defined type satisfying these conditions: +// * It must be assignable (have operator=() defined). +// * It must have operator+() (operator+(int-compatible type) for +// two-operand version). +// * It must have operator<() defined. +// Elements in the resulting sequences will also have that type. +// * Condition start < end must be satisfied in order for resulting sequences +// to contain any elements. +// +template +internal::ParamGenerator Range(T start, T end, IncrementT step) { + return internal::ParamGenerator( + new internal::RangeGenerator(start, end, step)); +} + +template +internal::ParamGenerator Range(T start, T end) { + return Range(start, end, 1); +} + +// ValuesIn() function allows generation of tests with parameters coming from +// a container. +// +// Synopsis: +// ValuesIn(const T (&array)[N]) +// - returns a generator producing sequences with elements from +// a C-style array. +// ValuesIn(const Container& container) +// - returns a generator producing sequences with elements from +// an STL-style container. +// ValuesIn(Iterator begin, Iterator end) +// - returns a generator producing sequences with elements from +// a range [begin, end) defined by a pair of STL-style iterators. These +// iterators can also be plain C pointers. +// +// Please note that ValuesIn copies the values from the containers +// passed in and keeps them to generate tests in RUN_ALL_TESTS(). +// +// Examples: +// +// This instantiates tests from test case StringTest +// each with C-string values of "foo", "bar", and "baz": +// +// const char* strings[] = {"foo", "bar", "baz"}; +// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings)); +// +// This instantiates tests from test case StlStringTest +// each with STL strings with values "a" and "b": +// +// ::std::vector< ::std::string> GetParameterStrings() { +// ::std::vector< ::std::string> v; +// v.push_back("a"); +// v.push_back("b"); +// return v; +// } +// +// INSTANTIATE_TEST_CASE_P(CharSequence, +// StlStringTest, +// ValuesIn(GetParameterStrings())); +// +// +// This will also instantiate tests from CharTest +// each with parameter values 'a' and 'b': +// +// ::std::list GetParameterChars() { +// ::std::list list; +// list.push_back('a'); +// list.push_back('b'); +// return list; +// } +// ::std::list l = GetParameterChars(); +// INSTANTIATE_TEST_CASE_P(CharSequence2, +// CharTest, +// ValuesIn(l.begin(), l.end())); +// +template +internal::ParamGenerator< + typename ::testing::internal::IteratorTraits::value_type> +ValuesIn(ForwardIterator begin, ForwardIterator end) { + typedef typename ::testing::internal::IteratorTraits + ::value_type ParamType; + return internal::ParamGenerator( + new internal::ValuesInIteratorRangeGenerator(begin, end)); +} + +template +internal::ParamGenerator ValuesIn(const T (&array)[N]) { + return ValuesIn(array, array + N); +} + +template +internal::ParamGenerator ValuesIn( + const Container& container) { + return ValuesIn(container.begin(), container.end()); +} + +// Values() allows generating tests from explicitly specified list of +// parameters. +// +// Synopsis: +// Values(T v1, T v2, ..., T vN) +// - returns a generator producing sequences with elements v1, v2, ..., vN. +// +// For example, this instantiates tests from test case BarTest each +// with values "one", "two", and "three": +// +// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values("one", "two", "three")); +// +// This instantiates tests from test case BazTest each with values 1, 2, 3.5. +// The exact type of values will depend on the type of parameter in BazTest. +// +// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5)); +// +// Currently, Values() supports from 1 to 50 parameters. +// +template +internal::ValueArray1 Values(T1 v1) { + return internal::ValueArray1(v1); +} + +template +internal::ValueArray2 Values(T1 v1, T2 v2) { + return internal::ValueArray2(v1, v2); +} + +template +internal::ValueArray3 Values(T1 v1, T2 v2, T3 v3) { + return internal::ValueArray3(v1, v2, v3); +} + +template +internal::ValueArray4 Values(T1 v1, T2 v2, T3 v3, T4 v4) { + return internal::ValueArray4(v1, v2, v3, v4); +} + +template +internal::ValueArray5 Values(T1 v1, T2 v2, T3 v3, T4 v4, + T5 v5) { + return internal::ValueArray5(v1, v2, v3, v4, v5); +} + +template +internal::ValueArray6 Values(T1 v1, T2 v2, T3 v3, + T4 v4, T5 v5, T6 v6) { + return internal::ValueArray6(v1, v2, v3, v4, v5, v6); +} + +template +internal::ValueArray7 Values(T1 v1, T2 v2, T3 v3, + T4 v4, T5 v5, T6 v6, T7 v7) { + return internal::ValueArray7(v1, v2, v3, v4, v5, + v6, v7); +} + +template +internal::ValueArray8 Values(T1 v1, T2 v2, + T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) { + return internal::ValueArray8(v1, v2, v3, v4, + v5, v6, v7, v8); +} + +template +internal::ValueArray9 Values(T1 v1, T2 v2, + T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) { + return internal::ValueArray9(v1, v2, v3, + v4, v5, v6, v7, v8, v9); +} + +template +internal::ValueArray10 Values(T1 v1, + T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10) { + return internal::ValueArray10(v1, + v2, v3, v4, v5, v6, v7, v8, v9, v10); +} + +template +internal::ValueArray11 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11) { + return internal::ValueArray11(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11); +} + +template +internal::ValueArray12 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12) { + return internal::ValueArray12(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12); +} + +template +internal::ValueArray13 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13) { + return internal::ValueArray13(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13); +} + +template +internal::ValueArray14 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) { + return internal::ValueArray14(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, + v14); +} + +template +internal::ValueArray15 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, + T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) { + return internal::ValueArray15(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, + v13, v14, v15); +} + +template +internal::ValueArray16 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, + T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, + T16 v16) { + return internal::ValueArray16(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, + v12, v13, v14, v15, v16); +} + +template +internal::ValueArray17 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, + T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, + T16 v16, T17 v17) { + return internal::ValueArray17(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, + v11, v12, v13, v14, v15, v16, v17); +} + +template +internal::ValueArray18 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, + T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, + T16 v16, T17 v17, T18 v18) { + return internal::ValueArray18(v1, v2, v3, v4, v5, v6, v7, v8, v9, + v10, v11, v12, v13, v14, v15, v16, v17, v18); +} + +template +internal::ValueArray19 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, + T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, + T15 v15, T16 v16, T17 v17, T18 v18, T19 v19) { + return internal::ValueArray19(v1, v2, v3, v4, v5, v6, v7, v8, + v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19); +} + +template +internal::ValueArray20 Values(T1 v1, T2 v2, T3 v3, T4 v4, + T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, + T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20) { + return internal::ValueArray20(v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20); +} + +template +internal::ValueArray21 Values(T1 v1, T2 v2, T3 v3, T4 v4, + T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, + T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21) { + return internal::ValueArray21(v1, v2, v3, v4, v5, v6, + v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21); +} + +template +internal::ValueArray22 Values(T1 v1, T2 v2, T3 v3, + T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, + T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, + T21 v21, T22 v22) { + return internal::ValueArray22(v1, v2, v3, v4, + v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, + v20, v21, v22); +} + +template +internal::ValueArray23 Values(T1 v1, T2 v2, + T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, + T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, + T21 v21, T22 v22, T23 v23) { + return internal::ValueArray23(v1, v2, v3, + v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, + v20, v21, v22, v23); +} + +template +internal::ValueArray24 Values(T1 v1, T2 v2, + T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, + T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, + T21 v21, T22 v22, T23 v23, T24 v24) { + return internal::ValueArray24(v1, v2, + v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, + v19, v20, v21, v22, v23, v24); +} + +template +internal::ValueArray25 Values(T1 v1, + T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, + T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, + T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25) { + return internal::ValueArray25(v1, + v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, + v18, v19, v20, v21, v22, v23, v24, v25); +} + +template +internal::ValueArray26 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26) { + return internal::ValueArray26(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, + v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26); +} + +template +internal::ValueArray27 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27) { + return internal::ValueArray27(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, + v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27); +} + +template +internal::ValueArray28 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28) { + return internal::ValueArray28(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, + v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, + v28); +} + +template +internal::ValueArray29 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29) { + return internal::ValueArray29(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, + v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, + v27, v28, v29); +} + +template +internal::ValueArray30 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, + T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, + T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, + T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) { + return internal::ValueArray30(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, + v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, + v26, v27, v28, v29, v30); +} + +template +internal::ValueArray31 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, + T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, + T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, + T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) { + return internal::ValueArray31(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, + v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, + v25, v26, v27, v28, v29, v30, v31); +} + +template +internal::ValueArray32 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, + T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, + T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, + T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, + T32 v32) { + return internal::ValueArray32(v1, v2, v3, v4, v5, v6, v7, v8, v9, + v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, + v24, v25, v26, v27, v28, v29, v30, v31, v32); +} + +template +internal::ValueArray33 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, + T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, + T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, + T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, + T32 v32, T33 v33) { + return internal::ValueArray33(v1, v2, v3, v4, v5, v6, v7, v8, + v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, + v24, v25, v26, v27, v28, v29, v30, v31, v32, v33); +} + +template +internal::ValueArray34 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, + T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, + T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, + T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, + T31 v31, T32 v32, T33 v33, T34 v34) { + return internal::ValueArray34(v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, + v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34); +} + +template +internal::ValueArray35 Values(T1 v1, T2 v2, T3 v3, T4 v4, + T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, + T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, + T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, + T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35) { + return internal::ValueArray35(v1, v2, v3, v4, v5, v6, + v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, + v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35); +} + +template +internal::ValueArray36 Values(T1 v1, T2 v2, T3 v3, T4 v4, + T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, + T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, + T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, + T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36) { + return internal::ValueArray36(v1, v2, v3, v4, + v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, + v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, + v34, v35, v36); +} + +template +internal::ValueArray37 Values(T1 v1, T2 v2, T3 v3, + T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, + T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, + T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, + T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, + T37 v37) { + return internal::ValueArray37(v1, v2, v3, + v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, + v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, + v34, v35, v36, v37); +} + +template +internal::ValueArray38 Values(T1 v1, T2 v2, + T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, + T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, + T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, + T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, + T37 v37, T38 v38) { + return internal::ValueArray38(v1, v2, + v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, + v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, + v33, v34, v35, v36, v37, v38); +} + +template +internal::ValueArray39 Values(T1 v1, T2 v2, + T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, + T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, + T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, + T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, + T37 v37, T38 v38, T39 v39) { + return internal::ValueArray39(v1, + v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, + v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, + v32, v33, v34, v35, v36, v37, v38, v39); +} + +template +internal::ValueArray40 Values(T1 v1, + T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, + T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, + T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, + T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, + T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) { + return internal::ValueArray40(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, + v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, + v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40); +} + +template +internal::ValueArray41 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41) { + return internal::ValueArray41(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, + v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, + v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41); +} + +template +internal::ValueArray42 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41, + T42 v42) { + return internal::ValueArray42(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, + v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, + v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41, + v42); +} + +template +internal::ValueArray43 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41, + T42 v42, T43 v43) { + return internal::ValueArray43(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, + v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, + v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, + v41, v42, v43); +} + +template +internal::ValueArray44 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41, + T42 v42, T43 v43, T44 v44) { + return internal::ValueArray44(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, + v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, + v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, + v40, v41, v42, v43, v44); +} + +template +internal::ValueArray45 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, + T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, + T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, + T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, + T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, + T41 v41, T42 v42, T43 v43, T44 v44, T45 v45) { + return internal::ValueArray45(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, + v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, + v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, + v39, v40, v41, v42, v43, v44, v45); +} + +template +internal::ValueArray46 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, + T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, + T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, + T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, + T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, + T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) { + return internal::ValueArray46(v1, v2, v3, v4, v5, v6, v7, v8, v9, + v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, + v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, + v38, v39, v40, v41, v42, v43, v44, v45, v46); +} + +template +internal::ValueArray47 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, + T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, + T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, + T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, + T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, + T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) { + return internal::ValueArray47(v1, v2, v3, v4, v5, v6, v7, v8, + v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, + v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, + v38, v39, v40, v41, v42, v43, v44, v45, v46, v47); +} + +template +internal::ValueArray48 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, + T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, + T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, + T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, + T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, + T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, + T48 v48) { + return internal::ValueArray48(v1, v2, v3, v4, v5, v6, v7, + v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, + v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, + v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48); +} + +template +internal::ValueArray49 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, + T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, + T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, + T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, + T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, + T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, + T47 v47, T48 v48, T49 v49) { + return internal::ValueArray49(v1, v2, v3, v4, v5, v6, + v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, + v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, + v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49); +} + +template +internal::ValueArray50 Values(T1 v1, T2 v2, T3 v3, T4 v4, + T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, + T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, + T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, + T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, + T38 v38, T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, + T46 v46, T47 v47, T48 v48, T49 v49, T50 v50) { + return internal::ValueArray50(v1, v2, v3, v4, + v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, + v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, + v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, + v48, v49, v50); +} + +// Bool() allows generating tests with parameters in a set of (false, true). +// +// Synopsis: +// Bool() +// - returns a generator producing sequences with elements {false, true}. +// +// It is useful when testing code that depends on Boolean flags. Combinations +// of multiple flags can be tested when several Bool()'s are combined using +// Combine() function. +// +// In the following example all tests in the test case FlagDependentTest +// will be instantiated twice with parameters false and true. +// +// class FlagDependentTest : public testing::TestWithParam { +// virtual void SetUp() { +// external_flag = GetParam(); +// } +// } +// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool()); +// +inline internal::ParamGenerator Bool() { + return Values(false, true); +} + +# if GTEST_HAS_COMBINE +// Combine() allows the user to combine two or more sequences to produce +// values of a Cartesian product of those sequences' elements. +// +// Synopsis: +// Combine(gen1, gen2, ..., genN) +// - returns a generator producing sequences with elements coming from +// the Cartesian product of elements from the sequences generated by +// gen1, gen2, ..., genN. The sequence elements will have a type of +// tuple where T1, T2, ..., TN are the types +// of elements from sequences produces by gen1, gen2, ..., genN. +// +// Combine can have up to 10 arguments. This number is currently limited +// by the maximum number of elements in the tuple implementation used by Google +// Test. +// +// Example: +// +// This will instantiate tests in test case AnimalTest each one with +// the parameter values tuple("cat", BLACK), tuple("cat", WHITE), +// tuple("dog", BLACK), and tuple("dog", WHITE): +// +// enum Color { BLACK, GRAY, WHITE }; +// class AnimalTest +// : public testing::TestWithParam > {...}; +// +// TEST_P(AnimalTest, AnimalLooksNice) {...} +// +// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest, +// Combine(Values("cat", "dog"), +// Values(BLACK, WHITE))); +// +// This will instantiate tests in FlagDependentTest with all variations of two +// Boolean flags: +// +// class FlagDependentTest +// : public testing::TestWithParam > { +// virtual void SetUp() { +// // Assigns external_flag_1 and external_flag_2 values from the tuple. +// tie(external_flag_1, external_flag_2) = GetParam(); +// } +// }; +// +// TEST_P(FlagDependentTest, TestFeature1) { +// // Test your code using external_flag_1 and external_flag_2 here. +// } +// INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest, +// Combine(Bool(), Bool())); +// +template +internal::CartesianProductHolder2 Combine( + const Generator1& g1, const Generator2& g2) { + return internal::CartesianProductHolder2( + g1, g2); +} + +template +internal::CartesianProductHolder3 Combine( + const Generator1& g1, const Generator2& g2, const Generator3& g3) { + return internal::CartesianProductHolder3( + g1, g2, g3); +} + +template +internal::CartesianProductHolder4 Combine( + const Generator1& g1, const Generator2& g2, const Generator3& g3, + const Generator4& g4) { + return internal::CartesianProductHolder4( + g1, g2, g3, g4); +} + +template +internal::CartesianProductHolder5 Combine( + const Generator1& g1, const Generator2& g2, const Generator3& g3, + const Generator4& g4, const Generator5& g5) { + return internal::CartesianProductHolder5( + g1, g2, g3, g4, g5); +} + +template +internal::CartesianProductHolder6 Combine( + const Generator1& g1, const Generator2& g2, const Generator3& g3, + const Generator4& g4, const Generator5& g5, const Generator6& g6) { + return internal::CartesianProductHolder6( + g1, g2, g3, g4, g5, g6); +} + +template +internal::CartesianProductHolder7 Combine( + const Generator1& g1, const Generator2& g2, const Generator3& g3, + const Generator4& g4, const Generator5& g5, const Generator6& g6, + const Generator7& g7) { + return internal::CartesianProductHolder7( + g1, g2, g3, g4, g5, g6, g7); +} + +template +internal::CartesianProductHolder8 Combine( + const Generator1& g1, const Generator2& g2, const Generator3& g3, + const Generator4& g4, const Generator5& g5, const Generator6& g6, + const Generator7& g7, const Generator8& g8) { + return internal::CartesianProductHolder8( + g1, g2, g3, g4, g5, g6, g7, g8); +} + +template +internal::CartesianProductHolder9 Combine( + const Generator1& g1, const Generator2& g2, const Generator3& g3, + const Generator4& g4, const Generator5& g5, const Generator6& g6, + const Generator7& g7, const Generator8& g8, const Generator9& g9) { + return internal::CartesianProductHolder9( + g1, g2, g3, g4, g5, g6, g7, g8, g9); +} + +template +internal::CartesianProductHolder10 Combine( + const Generator1& g1, const Generator2& g2, const Generator3& g3, + const Generator4& g4, const Generator5& g5, const Generator6& g6, + const Generator7& g7, const Generator8& g8, const Generator9& g9, + const Generator10& g10) { + return internal::CartesianProductHolder10( + g1, g2, g3, g4, g5, g6, g7, g8, g9, g10); +} +# endif // GTEST_HAS_COMBINE + + + +# define TEST_P(test_case_name, test_name) \ + class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \ + : public test_case_name { \ + public: \ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \ + virtual void TestBody(); \ + private: \ + static int AddToRegistry() { \ + ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ + GetTestCasePatternHolder(\ + #test_case_name, __FILE__, __LINE__)->AddTestPattern(\ + #test_case_name, \ + #test_name, \ + new ::testing::internal::TestMetaFactory< \ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \ + return 0; \ + } \ + static int gtest_registering_dummy_; \ + GTEST_DISALLOW_COPY_AND_ASSIGN_(\ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \ + }; \ + int GTEST_TEST_CLASS_NAME_(test_case_name, \ + test_name)::gtest_registering_dummy_ = \ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \ + void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() + +# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \ + ::testing::internal::ParamGenerator \ + gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \ + int gtest_##prefix##test_case_name##_dummy_ = \ + ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ + GetTestCasePatternHolder(\ + #test_case_name, __FILE__, __LINE__)->AddTestCaseInstantiation(\ + #prefix, \ + >est_##prefix##test_case_name##_EvalGenerator_, \ + __FILE__, __LINE__) + +} // namespace testing + +#endif // GTEST_HAS_PARAM_TEST + +#endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ diff --git a/test/fmw/gtest/include/gtest/gtest-param-test.h.pump b/test/fmw/gtest/include/gtest/gtest-param-test.h.pump new file mode 100644 index 00000000000..2dc9303b5e3 --- /dev/null +++ b/test/fmw/gtest/include/gtest/gtest-param-test.h.pump @@ -0,0 +1,487 @@ +$$ -*- mode: c++; -*- +$var n = 50 $$ Maximum length of Values arguments we want to support. +$var maxtuple = 10 $$ Maximum number of Combine arguments we want to support. +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Authors: vladl@google.com (Vlad Losev) +// +// Macros and functions for implementing parameterized tests +// in Google C++ Testing Framework (Google Test) +// +// This file is generated by a SCRIPT. DO NOT EDIT BY HAND! +// +#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ +#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ + + +// Value-parameterized tests allow you to test your code with different +// parameters without writing multiple copies of the same test. +// +// Here is how you use value-parameterized tests: + +#if 0 + +// To write value-parameterized tests, first you should define a fixture +// class. It is usually derived from testing::TestWithParam (see below for +// another inheritance scheme that's sometimes useful in more complicated +// class hierarchies), where the type of your parameter values. +// TestWithParam is itself derived from testing::Test. T can be any +// copyable type. If it's a raw pointer, you are responsible for managing the +// lifespan of the pointed values. + +class FooTest : public ::testing::TestWithParam { + // You can implement all the usual class fixture members here. +}; + +// Then, use the TEST_P macro to define as many parameterized tests +// for this fixture as you want. The _P suffix is for "parameterized" +// or "pattern", whichever you prefer to think. + +TEST_P(FooTest, DoesBlah) { + // Inside a test, access the test parameter with the GetParam() method + // of the TestWithParam class: + EXPECT_TRUE(foo.Blah(GetParam())); + ... +} + +TEST_P(FooTest, HasBlahBlah) { + ... +} + +// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test +// case with any set of parameters you want. Google Test defines a number +// of functions for generating test parameters. They return what we call +// (surprise!) parameter generators. Here is a summary of them, which +// are all in the testing namespace: +// +// +// Range(begin, end [, step]) - Yields values {begin, begin+step, +// begin+step+step, ...}. The values do not +// include end. step defaults to 1. +// Values(v1, v2, ..., vN) - Yields values {v1, v2, ..., vN}. +// ValuesIn(container) - Yields values from a C-style array, an STL +// ValuesIn(begin,end) container, or an iterator range [begin, end). +// Bool() - Yields sequence {false, true}. +// Combine(g1, g2, ..., gN) - Yields all combinations (the Cartesian product +// for the math savvy) of the values generated +// by the N generators. +// +// For more details, see comments at the definitions of these functions below +// in this file. +// +// The following statement will instantiate tests from the FooTest test case +// each with parameter values "meeny", "miny", and "moe". + +INSTANTIATE_TEST_CASE_P(InstantiationName, + FooTest, + Values("meeny", "miny", "moe")); + +// To distinguish different instances of the pattern, (yes, you +// can instantiate it more then once) the first argument to the +// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the +// actual test case name. Remember to pick unique prefixes for different +// instantiations. The tests from the instantiation above will have +// these names: +// +// * InstantiationName/FooTest.DoesBlah/0 for "meeny" +// * InstantiationName/FooTest.DoesBlah/1 for "miny" +// * InstantiationName/FooTest.DoesBlah/2 for "moe" +// * InstantiationName/FooTest.HasBlahBlah/0 for "meeny" +// * InstantiationName/FooTest.HasBlahBlah/1 for "miny" +// * InstantiationName/FooTest.HasBlahBlah/2 for "moe" +// +// You can use these names in --gtest_filter. +// +// This statement will instantiate all tests from FooTest again, each +// with parameter values "cat" and "dog": + +const char* pets[] = {"cat", "dog"}; +INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets)); + +// The tests from the instantiation above will have these names: +// +// * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat" +// * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog" +// * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat" +// * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog" +// +// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests +// in the given test case, whether their definitions come before or +// AFTER the INSTANTIATE_TEST_CASE_P statement. +// +// Please also note that generator expressions (including parameters to the +// generators) are evaluated in InitGoogleTest(), after main() has started. +// This allows the user on one hand, to adjust generator parameters in order +// to dynamically determine a set of tests to run and on the other hand, +// give the user a chance to inspect the generated tests with Google Test +// reflection API before RUN_ALL_TESTS() is executed. +// +// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc +// for more examples. +// +// In the future, we plan to publish the API for defining new parameter +// generators. But for now this interface remains part of the internal +// implementation and is subject to change. +// +// +// A parameterized test fixture must be derived from testing::Test and from +// testing::WithParamInterface, where T is the type of the parameter +// values. Inheriting from TestWithParam satisfies that requirement because +// TestWithParam inherits from both Test and WithParamInterface. In more +// complicated hierarchies, however, it is occasionally useful to inherit +// separately from Test and WithParamInterface. For example: + +class BaseTest : public ::testing::Test { + // You can inherit all the usual members for a non-parameterized test + // fixture here. +}; + +class DerivedTest : public BaseTest, public ::testing::WithParamInterface { + // The usual test fixture members go here too. +}; + +TEST_F(BaseTest, HasFoo) { + // This is an ordinary non-parameterized test. +} + +TEST_P(DerivedTest, DoesBlah) { + // GetParam works just the same here as if you inherit from TestWithParam. + EXPECT_TRUE(foo.Blah(GetParam())); +} + +#endif // 0 + +#include "gtest/internal/gtest-port.h" + +#if !GTEST_OS_SYMBIAN +# include +#endif + +// scripts/fuse_gtest.py depends on gtest's own header being #included +// *unconditionally*. Therefore these #includes cannot be moved +// inside #if GTEST_HAS_PARAM_TEST. +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-param-util.h" +#include "gtest/internal/gtest-param-util-generated.h" + +#if GTEST_HAS_PARAM_TEST + +namespace testing { + +// Functions producing parameter generators. +// +// Google Test uses these generators to produce parameters for value- +// parameterized tests. When a parameterized test case is instantiated +// with a particular generator, Google Test creates and runs tests +// for each element in the sequence produced by the generator. +// +// In the following sample, tests from test case FooTest are instantiated +// each three times with parameter values 3, 5, and 8: +// +// class FooTest : public TestWithParam { ... }; +// +// TEST_P(FooTest, TestThis) { +// } +// TEST_P(FooTest, TestThat) { +// } +// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8)); +// + +// Range() returns generators providing sequences of values in a range. +// +// Synopsis: +// Range(start, end) +// - returns a generator producing a sequence of values {start, start+1, +// start+2, ..., }. +// Range(start, end, step) +// - returns a generator producing a sequence of values {start, start+step, +// start+step+step, ..., }. +// Notes: +// * The generated sequences never include end. For example, Range(1, 5) +// returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2) +// returns a generator producing {1, 3, 5, 7}. +// * start and end must have the same type. That type may be any integral or +// floating-point type or a user defined type satisfying these conditions: +// * It must be assignable (have operator=() defined). +// * It must have operator+() (operator+(int-compatible type) for +// two-operand version). +// * It must have operator<() defined. +// Elements in the resulting sequences will also have that type. +// * Condition start < end must be satisfied in order for resulting sequences +// to contain any elements. +// +template +internal::ParamGenerator Range(T start, T end, IncrementT step) { + return internal::ParamGenerator( + new internal::RangeGenerator(start, end, step)); +} + +template +internal::ParamGenerator Range(T start, T end) { + return Range(start, end, 1); +} + +// ValuesIn() function allows generation of tests with parameters coming from +// a container. +// +// Synopsis: +// ValuesIn(const T (&array)[N]) +// - returns a generator producing sequences with elements from +// a C-style array. +// ValuesIn(const Container& container) +// - returns a generator producing sequences with elements from +// an STL-style container. +// ValuesIn(Iterator begin, Iterator end) +// - returns a generator producing sequences with elements from +// a range [begin, end) defined by a pair of STL-style iterators. These +// iterators can also be plain C pointers. +// +// Please note that ValuesIn copies the values from the containers +// passed in and keeps them to generate tests in RUN_ALL_TESTS(). +// +// Examples: +// +// This instantiates tests from test case StringTest +// each with C-string values of "foo", "bar", and "baz": +// +// const char* strings[] = {"foo", "bar", "baz"}; +// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings)); +// +// This instantiates tests from test case StlStringTest +// each with STL strings with values "a" and "b": +// +// ::std::vector< ::std::string> GetParameterStrings() { +// ::std::vector< ::std::string> v; +// v.push_back("a"); +// v.push_back("b"); +// return v; +// } +// +// INSTANTIATE_TEST_CASE_P(CharSequence, +// StlStringTest, +// ValuesIn(GetParameterStrings())); +// +// +// This will also instantiate tests from CharTest +// each with parameter values 'a' and 'b': +// +// ::std::list GetParameterChars() { +// ::std::list list; +// list.push_back('a'); +// list.push_back('b'); +// return list; +// } +// ::std::list l = GetParameterChars(); +// INSTANTIATE_TEST_CASE_P(CharSequence2, +// CharTest, +// ValuesIn(l.begin(), l.end())); +// +template +internal::ParamGenerator< + typename ::testing::internal::IteratorTraits::value_type> +ValuesIn(ForwardIterator begin, ForwardIterator end) { + typedef typename ::testing::internal::IteratorTraits + ::value_type ParamType; + return internal::ParamGenerator( + new internal::ValuesInIteratorRangeGenerator(begin, end)); +} + +template +internal::ParamGenerator ValuesIn(const T (&array)[N]) { + return ValuesIn(array, array + N); +} + +template +internal::ParamGenerator ValuesIn( + const Container& container) { + return ValuesIn(container.begin(), container.end()); +} + +// Values() allows generating tests from explicitly specified list of +// parameters. +// +// Synopsis: +// Values(T v1, T v2, ..., T vN) +// - returns a generator producing sequences with elements v1, v2, ..., vN. +// +// For example, this instantiates tests from test case BarTest each +// with values "one", "two", and "three": +// +// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values("one", "two", "three")); +// +// This instantiates tests from test case BazTest each with values 1, 2, 3.5. +// The exact type of values will depend on the type of parameter in BazTest. +// +// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5)); +// +// Currently, Values() supports from 1 to $n parameters. +// +$range i 1..n +$for i [[ +$range j 1..i + +template <$for j, [[typename T$j]]> +internal::ValueArray$i<$for j, [[T$j]]> Values($for j, [[T$j v$j]]) { + return internal::ValueArray$i<$for j, [[T$j]]>($for j, [[v$j]]); +} + +]] + +// Bool() allows generating tests with parameters in a set of (false, true). +// +// Synopsis: +// Bool() +// - returns a generator producing sequences with elements {false, true}. +// +// It is useful when testing code that depends on Boolean flags. Combinations +// of multiple flags can be tested when several Bool()'s are combined using +// Combine() function. +// +// In the following example all tests in the test case FlagDependentTest +// will be instantiated twice with parameters false and true. +// +// class FlagDependentTest : public testing::TestWithParam { +// virtual void SetUp() { +// external_flag = GetParam(); +// } +// } +// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool()); +// +inline internal::ParamGenerator Bool() { + return Values(false, true); +} + +# if GTEST_HAS_COMBINE +// Combine() allows the user to combine two or more sequences to produce +// values of a Cartesian product of those sequences' elements. +// +// Synopsis: +// Combine(gen1, gen2, ..., genN) +// - returns a generator producing sequences with elements coming from +// the Cartesian product of elements from the sequences generated by +// gen1, gen2, ..., genN. The sequence elements will have a type of +// tuple where T1, T2, ..., TN are the types +// of elements from sequences produces by gen1, gen2, ..., genN. +// +// Combine can have up to $maxtuple arguments. This number is currently limited +// by the maximum number of elements in the tuple implementation used by Google +// Test. +// +// Example: +// +// This will instantiate tests in test case AnimalTest each one with +// the parameter values tuple("cat", BLACK), tuple("cat", WHITE), +// tuple("dog", BLACK), and tuple("dog", WHITE): +// +// enum Color { BLACK, GRAY, WHITE }; +// class AnimalTest +// : public testing::TestWithParam > {...}; +// +// TEST_P(AnimalTest, AnimalLooksNice) {...} +// +// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest, +// Combine(Values("cat", "dog"), +// Values(BLACK, WHITE))); +// +// This will instantiate tests in FlagDependentTest with all variations of two +// Boolean flags: +// +// class FlagDependentTest +// : public testing::TestWithParam > { +// virtual void SetUp() { +// // Assigns external_flag_1 and external_flag_2 values from the tuple. +// tie(external_flag_1, external_flag_2) = GetParam(); +// } +// }; +// +// TEST_P(FlagDependentTest, TestFeature1) { +// // Test your code using external_flag_1 and external_flag_2 here. +// } +// INSTANTIATE_TEST_CASE_P(TwoBoolSequence, FlagDependentTest, +// Combine(Bool(), Bool())); +// +$range i 2..maxtuple +$for i [[ +$range j 1..i + +template <$for j, [[typename Generator$j]]> +internal::CartesianProductHolder$i<$for j, [[Generator$j]]> Combine( + $for j, [[const Generator$j& g$j]]) { + return internal::CartesianProductHolder$i<$for j, [[Generator$j]]>( + $for j, [[g$j]]); +} + +]] +# endif // GTEST_HAS_COMBINE + + + +# define TEST_P(test_case_name, test_name) \ + class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \ + : public test_case_name { \ + public: \ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {} \ + virtual void TestBody(); \ + private: \ + static int AddToRegistry() { \ + ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ + GetTestCasePatternHolder(\ + #test_case_name, __FILE__, __LINE__)->AddTestPattern(\ + #test_case_name, \ + #test_name, \ + new ::testing::internal::TestMetaFactory< \ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>()); \ + return 0; \ + } \ + static int gtest_registering_dummy_; \ + GTEST_DISALLOW_COPY_AND_ASSIGN_(\ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)); \ + }; \ + int GTEST_TEST_CLASS_NAME_(test_case_name, \ + test_name)::gtest_registering_dummy_ = \ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::AddToRegistry(); \ + void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() + +# define INSTANTIATE_TEST_CASE_P(prefix, test_case_name, generator) \ + ::testing::internal::ParamGenerator \ + gtest_##prefix##test_case_name##_EvalGenerator_() { return generator; } \ + int gtest_##prefix##test_case_name##_dummy_ = \ + ::testing::UnitTest::GetInstance()->parameterized_test_registry(). \ + GetTestCasePatternHolder(\ + #test_case_name, __FILE__, __LINE__)->AddTestCaseInstantiation(\ + #prefix, \ + >est_##prefix##test_case_name##_EvalGenerator_, \ + __FILE__, __LINE__) + +} // namespace testing + +#endif // GTEST_HAS_PARAM_TEST + +#endif // GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_ diff --git a/test/fmw/gtest/include/gtest/gtest-printers.h b/test/fmw/gtest/include/gtest/gtest-printers.h new file mode 100644 index 00000000000..0639d9f5869 --- /dev/null +++ b/test/fmw/gtest/include/gtest/gtest-printers.h @@ -0,0 +1,855 @@ +// Copyright 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) + +// Google Test - The Google C++ Testing Framework +// +// This file implements a universal value printer that can print a +// value of any type T: +// +// void ::testing::internal::UniversalPrinter::Print(value, ostream_ptr); +// +// A user can teach this function how to print a class type T by +// defining either operator<<() or PrintTo() in the namespace that +// defines T. More specifically, the FIRST defined function in the +// following list will be used (assuming T is defined in namespace +// foo): +// +// 1. foo::PrintTo(const T&, ostream*) +// 2. operator<<(ostream&, const T&) defined in either foo or the +// global namespace. +// +// If none of the above is defined, it will print the debug string of +// the value if it is a protocol buffer, or print the raw bytes in the +// value otherwise. +// +// To aid debugging: when T is a reference type, the address of the +// value is also printed; when T is a (const) char pointer, both the +// pointer value and the NUL-terminated string it points to are +// printed. +// +// We also provide some convenient wrappers: +// +// // Prints a value to a string. For a (const or not) char +// // pointer, the NUL-terminated string (but not the pointer) is +// // printed. +// std::string ::testing::PrintToString(const T& value); +// +// // Prints a value tersely: for a reference type, the referenced +// // value (but not the address) is printed; for a (const or not) char +// // pointer, the NUL-terminated string (but not the pointer) is +// // printed. +// void ::testing::internal::UniversalTersePrint(const T& value, ostream*); +// +// // Prints value using the type inferred by the compiler. The difference +// // from UniversalTersePrint() is that this function prints both the +// // pointer and the NUL-terminated string for a (const or not) char pointer. +// void ::testing::internal::UniversalPrint(const T& value, ostream*); +// +// // Prints the fields of a tuple tersely to a string vector, one +// // element for each field. Tuple support must be enabled in +// // gtest-port.h. +// std::vector UniversalTersePrintTupleFieldsToStrings( +// const Tuple& value); +// +// Known limitation: +// +// The print primitives print the elements of an STL-style container +// using the compiler-inferred type of *iter where iter is a +// const_iterator of the container. When const_iterator is an input +// iterator but not a forward iterator, this inferred type may not +// match value_type, and the print output may be incorrect. In +// practice, this is rarely a problem as for most containers +// const_iterator is a forward iterator. We'll fix this if there's an +// actual need for it. Note that this fix cannot rely on value_type +// being defined as many user-defined container types don't have +// value_type. + +#ifndef GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ +#define GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ + +#include // NOLINT +#include +#include +#include +#include +#include "gtest/internal/gtest-port.h" +#include "gtest/internal/gtest-internal.h" + +namespace testing { + +// Definitions in the 'internal' and 'internal2' name spaces are +// subject to change without notice. DO NOT USE THEM IN USER CODE! +namespace internal2 { + +// Prints the given number of bytes in the given object to the given +// ostream. +GTEST_API_ void PrintBytesInObjectTo(const unsigned char* obj_bytes, + size_t count, + ::std::ostream* os); + +// For selecting which printer to use when a given type has neither << +// nor PrintTo(). +enum TypeKind { + kProtobuf, // a protobuf type + kConvertibleToInteger, // a type implicitly convertible to BiggestInt + // (e.g. a named or unnamed enum type) + kOtherType // anything else +}; + +// TypeWithoutFormatter::PrintValue(value, os) is called +// by the universal printer to print a value of type T when neither +// operator<< nor PrintTo() is defined for T, where kTypeKind is the +// "kind" of T as defined by enum TypeKind. +template +class TypeWithoutFormatter { + public: + // This default version is called when kTypeKind is kOtherType. + static void PrintValue(const T& value, ::std::ostream* os) { + PrintBytesInObjectTo(reinterpret_cast(&value), + sizeof(value), os); + } +}; + +// We print a protobuf using its ShortDebugString() when the string +// doesn't exceed this many characters; otherwise we print it using +// DebugString() for better readability. +const size_t kProtobufOneLinerMaxLength = 50; + +template +class TypeWithoutFormatter { + public: + static void PrintValue(const T& value, ::std::ostream* os) { + const ::testing::internal::string short_str = value.ShortDebugString(); + const ::testing::internal::string pretty_str = + short_str.length() <= kProtobufOneLinerMaxLength ? + short_str : ("\n" + value.DebugString()); + *os << ("<" + pretty_str + ">"); + } +}; + +template +class TypeWithoutFormatter { + public: + // Since T has no << operator or PrintTo() but can be implicitly + // converted to BiggestInt, we print it as a BiggestInt. + // + // Most likely T is an enum type (either named or unnamed), in which + // case printing it as an integer is the desired behavior. In case + // T is not an enum, printing it as an integer is the best we can do + // given that it has no user-defined printer. + static void PrintValue(const T& value, ::std::ostream* os) { + const internal::BiggestInt kBigInt = value; + *os << kBigInt; + } +}; + +// Prints the given value to the given ostream. If the value is a +// protocol message, its debug string is printed; if it's an enum or +// of a type implicitly convertible to BiggestInt, it's printed as an +// integer; otherwise the bytes in the value are printed. This is +// what UniversalPrinter::Print() does when it knows nothing about +// type T and T has neither << operator nor PrintTo(). +// +// A user can override this behavior for a class type Foo by defining +// a << operator in the namespace where Foo is defined. +// +// We put this operator in namespace 'internal2' instead of 'internal' +// to simplify the implementation, as much code in 'internal' needs to +// use << in STL, which would conflict with our own << were it defined +// in 'internal'. +// +// Note that this operator<< takes a generic std::basic_ostream type instead of the more restricted std::ostream. If +// we define it to take an std::ostream instead, we'll get an +// "ambiguous overloads" compiler error when trying to print a type +// Foo that supports streaming to std::basic_ostream, as the compiler cannot tell whether +// operator<<(std::ostream&, const T&) or +// operator<<(std::basic_stream, const Foo&) is more +// specific. +template +::std::basic_ostream& operator<<( + ::std::basic_ostream& os, const T& x) { + TypeWithoutFormatter::value ? kProtobuf : + internal::ImplicitlyConvertible::value ? + kConvertibleToInteger : kOtherType)>::PrintValue(x, &os); + return os; +} + +} // namespace internal2 +} // namespace testing + +// This namespace MUST NOT BE NESTED IN ::testing, or the name look-up +// magic needed for implementing UniversalPrinter won't work. +namespace testing_internal { + +// Used to print a value that is not an STL-style container when the +// user doesn't define PrintTo() for it. +template +void DefaultPrintNonContainerTo(const T& value, ::std::ostream* os) { + // With the following statement, during unqualified name lookup, + // testing::internal2::operator<< appears as if it was declared in + // the nearest enclosing namespace that contains both + // ::testing_internal and ::testing::internal2, i.e. the global + // namespace. For more details, refer to the C++ Standard section + // 7.3.4-1 [namespace.udir]. This allows us to fall back onto + // testing::internal2::operator<< in case T doesn't come with a << + // operator. + // + // We cannot write 'using ::testing::internal2::operator<<;', which + // gcc 3.3 fails to compile due to a compiler bug. + using namespace ::testing::internal2; // NOLINT + + // Assuming T is defined in namespace foo, in the next statement, + // the compiler will consider all of: + // + // 1. foo::operator<< (thanks to Koenig look-up), + // 2. ::operator<< (as the current namespace is enclosed in ::), + // 3. testing::internal2::operator<< (thanks to the using statement above). + // + // The operator<< whose type matches T best will be picked. + // + // We deliberately allow #2 to be a candidate, as sometimes it's + // impossible to define #1 (e.g. when foo is ::std, defining + // anything in it is undefined behavior unless you are a compiler + // vendor.). + *os << value; +} + +} // namespace testing_internal + +namespace testing { +namespace internal { + +// UniversalPrinter::Print(value, ostream_ptr) prints the given +// value to the given ostream. The caller must ensure that +// 'ostream_ptr' is not NULL, or the behavior is undefined. +// +// We define UniversalPrinter as a class template (as opposed to a +// function template), as we need to partially specialize it for +// reference types, which cannot be done with function templates. +template +class UniversalPrinter; + +template +void UniversalPrint(const T& value, ::std::ostream* os); + +// Used to print an STL-style container when the user doesn't define +// a PrintTo() for it. +template +void DefaultPrintTo(IsContainer /* dummy */, + false_type /* is not a pointer */, + const C& container, ::std::ostream* os) { + const size_t kMaxCount = 32; // The maximum number of elements to print. + *os << '{'; + size_t count = 0; + for (typename C::const_iterator it = container.begin(); + it != container.end(); ++it, ++count) { + if (count > 0) { + *os << ','; + if (count == kMaxCount) { // Enough has been printed. + *os << " ..."; + break; + } + } + *os << ' '; + // We cannot call PrintTo(*it, os) here as PrintTo() doesn't + // handle *it being a native array. + internal::UniversalPrint(*it, os); + } + + if (count > 0) { + *os << ' '; + } + *os << '}'; +} + +// Used to print a pointer that is neither a char pointer nor a member +// pointer, when the user doesn't define PrintTo() for it. (A member +// variable pointer or member function pointer doesn't really point to +// a location in the address space. Their representation is +// implementation-defined. Therefore they will be printed as raw +// bytes.) +template +void DefaultPrintTo(IsNotContainer /* dummy */, + true_type /* is a pointer */, + T* p, ::std::ostream* os) { + if (p == NULL) { + *os << "NULL"; + } else { + // C++ doesn't allow casting from a function pointer to any object + // pointer. + // + // IsTrue() silences warnings: "Condition is always true", + // "unreachable code". + if (IsTrue(ImplicitlyConvertible::value)) { + // T is not a function type. We just call << to print p, + // relying on ADL to pick up user-defined << for their pointer + // types, if any. + *os << p; + } else { + // T is a function type, so '*os << p' doesn't do what we want + // (it just prints p as bool). We want to print p as a const + // void*. However, we cannot cast it to const void* directly, + // even using reinterpret_cast, as earlier versions of gcc + // (e.g. 3.4.5) cannot compile the cast when p is a function + // pointer. Casting to UInt64 first solves the problem. + *os << reinterpret_cast( + reinterpret_cast(p)); + } + } +} + +// Used to print a non-container, non-pointer value when the user +// doesn't define PrintTo() for it. +template +void DefaultPrintTo(IsNotContainer /* dummy */, + false_type /* is not a pointer */, + const T& value, ::std::ostream* os) { + ::testing_internal::DefaultPrintNonContainerTo(value, os); +} + +// Prints the given value using the << operator if it has one; +// otherwise prints the bytes in it. This is what +// UniversalPrinter::Print() does when PrintTo() is not specialized +// or overloaded for type T. +// +// A user can override this behavior for a class type Foo by defining +// an overload of PrintTo() in the namespace where Foo is defined. We +// give the user this option as sometimes defining a << operator for +// Foo is not desirable (e.g. the coding style may prevent doing it, +// or there is already a << operator but it doesn't do what the user +// wants). +template +void PrintTo(const T& value, ::std::ostream* os) { + // DefaultPrintTo() is overloaded. The type of its first two + // arguments determine which version will be picked. If T is an + // STL-style container, the version for container will be called; if + // T is a pointer, the pointer version will be called; otherwise the + // generic version will be called. + // + // Note that we check for container types here, prior to we check + // for protocol message types in our operator<<. The rationale is: + // + // For protocol messages, we want to give people a chance to + // override Google Mock's format by defining a PrintTo() or + // operator<<. For STL containers, other formats can be + // incompatible with Google Mock's format for the container + // elements; therefore we check for container types here to ensure + // that our format is used. + // + // The second argument of DefaultPrintTo() is needed to bypass a bug + // in Symbian's C++ compiler that prevents it from picking the right + // overload between: + // + // PrintTo(const T& x, ...); + // PrintTo(T* x, ...); + DefaultPrintTo(IsContainerTest(0), is_pointer(), value, os); +} + +// The following list of PrintTo() overloads tells +// UniversalPrinter::Print() how to print standard types (built-in +// types, strings, plain arrays, and pointers). + +// Overloads for various char types. +GTEST_API_ void PrintTo(unsigned char c, ::std::ostream* os); +GTEST_API_ void PrintTo(signed char c, ::std::ostream* os); +inline void PrintTo(char c, ::std::ostream* os) { + // When printing a plain char, we always treat it as unsigned. This + // way, the output won't be affected by whether the compiler thinks + // char is signed or not. + PrintTo(static_cast(c), os); +} + +// Overloads for other simple built-in types. +inline void PrintTo(bool x, ::std::ostream* os) { + *os << (x ? "true" : "false"); +} + +// Overload for wchar_t type. +// Prints a wchar_t as a symbol if it is printable or as its internal +// code otherwise and also as its decimal code (except for L'\0'). +// The L'\0' char is printed as "L'\\0'". The decimal code is printed +// as signed integer when wchar_t is implemented by the compiler +// as a signed type and is printed as an unsigned integer when wchar_t +// is implemented as an unsigned type. +GTEST_API_ void PrintTo(wchar_t wc, ::std::ostream* os); + +// Overloads for C strings. +GTEST_API_ void PrintTo(const char* s, ::std::ostream* os); +inline void PrintTo(char* s, ::std::ostream* os) { + PrintTo(ImplicitCast_(s), os); +} + +// signed/unsigned char is often used for representing binary data, so +// we print pointers to it as void* to be safe. +inline void PrintTo(const signed char* s, ::std::ostream* os) { + PrintTo(ImplicitCast_(s), os); +} +inline void PrintTo(signed char* s, ::std::ostream* os) { + PrintTo(ImplicitCast_(s), os); +} +inline void PrintTo(const unsigned char* s, ::std::ostream* os) { + PrintTo(ImplicitCast_(s), os); +} +inline void PrintTo(unsigned char* s, ::std::ostream* os) { + PrintTo(ImplicitCast_(s), os); +} + +// MSVC can be configured to define wchar_t as a typedef of unsigned +// short. It defines _NATIVE_WCHAR_T_DEFINED when wchar_t is a native +// type. When wchar_t is a typedef, defining an overload for const +// wchar_t* would cause unsigned short* be printed as a wide string, +// possibly causing invalid memory accesses. +#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) +// Overloads for wide C strings +GTEST_API_ void PrintTo(const wchar_t* s, ::std::ostream* os); +inline void PrintTo(wchar_t* s, ::std::ostream* os) { + PrintTo(ImplicitCast_(s), os); +} +#endif + +// Overload for C arrays. Multi-dimensional arrays are printed +// properly. + +// Prints the given number of elements in an array, without printing +// the curly braces. +template +void PrintRawArrayTo(const T a[], size_t count, ::std::ostream* os) { + UniversalPrint(a[0], os); + for (size_t i = 1; i != count; i++) { + *os << ", "; + UniversalPrint(a[i], os); + } +} + +// Overloads for ::string and ::std::string. +#if GTEST_HAS_GLOBAL_STRING +GTEST_API_ void PrintStringTo(const ::string&s, ::std::ostream* os); +inline void PrintTo(const ::string& s, ::std::ostream* os) { + PrintStringTo(s, os); +} +#endif // GTEST_HAS_GLOBAL_STRING + +GTEST_API_ void PrintStringTo(const ::std::string&s, ::std::ostream* os); +inline void PrintTo(const ::std::string& s, ::std::ostream* os) { + PrintStringTo(s, os); +} + +// Overloads for ::wstring and ::std::wstring. +#if GTEST_HAS_GLOBAL_WSTRING +GTEST_API_ void PrintWideStringTo(const ::wstring&s, ::std::ostream* os); +inline void PrintTo(const ::wstring& s, ::std::ostream* os) { + PrintWideStringTo(s, os); +} +#endif // GTEST_HAS_GLOBAL_WSTRING + +#if GTEST_HAS_STD_WSTRING +GTEST_API_ void PrintWideStringTo(const ::std::wstring&s, ::std::ostream* os); +inline void PrintTo(const ::std::wstring& s, ::std::ostream* os) { + PrintWideStringTo(s, os); +} +#endif // GTEST_HAS_STD_WSTRING + +#if GTEST_HAS_TR1_TUPLE +// Overload for ::std::tr1::tuple. Needed for printing function arguments, +// which are packed as tuples. + +// Helper function for printing a tuple. T must be instantiated with +// a tuple type. +template +void PrintTupleTo(const T& t, ::std::ostream* os); + +// Overloaded PrintTo() for tuples of various arities. We support +// tuples of up-to 10 fields. The following implementation works +// regardless of whether tr1::tuple is implemented using the +// non-standard variadic template feature or not. + +inline void PrintTo(const ::std::tr1::tuple<>& t, ::std::ostream* os) { + PrintTupleTo(t, os); +} + +template +void PrintTo(const ::std::tr1::tuple& t, ::std::ostream* os) { + PrintTupleTo(t, os); +} + +template +void PrintTo(const ::std::tr1::tuple& t, ::std::ostream* os) { + PrintTupleTo(t, os); +} + +template +void PrintTo(const ::std::tr1::tuple& t, ::std::ostream* os) { + PrintTupleTo(t, os); +} + +template +void PrintTo(const ::std::tr1::tuple& t, ::std::ostream* os) { + PrintTupleTo(t, os); +} + +template +void PrintTo(const ::std::tr1::tuple& t, + ::std::ostream* os) { + PrintTupleTo(t, os); +} + +template +void PrintTo(const ::std::tr1::tuple& t, + ::std::ostream* os) { + PrintTupleTo(t, os); +} + +template +void PrintTo(const ::std::tr1::tuple& t, + ::std::ostream* os) { + PrintTupleTo(t, os); +} + +template +void PrintTo(const ::std::tr1::tuple& t, + ::std::ostream* os) { + PrintTupleTo(t, os); +} + +template +void PrintTo(const ::std::tr1::tuple& t, + ::std::ostream* os) { + PrintTupleTo(t, os); +} + +template +void PrintTo( + const ::std::tr1::tuple& t, + ::std::ostream* os) { + PrintTupleTo(t, os); +} +#endif // GTEST_HAS_TR1_TUPLE + +// Overload for std::pair. +template +void PrintTo(const ::std::pair& value, ::std::ostream* os) { + *os << '('; + // We cannot use UniversalPrint(value.first, os) here, as T1 may be + // a reference type. The same for printing value.second. + UniversalPrinter::Print(value.first, os); + *os << ", "; + UniversalPrinter::Print(value.second, os); + *os << ')'; +} + +// Implements printing a non-reference type T by letting the compiler +// pick the right overload of PrintTo() for T. +template +class UniversalPrinter { + public: + // MSVC warns about adding const to a function type, so we want to + // disable the warning. +#ifdef _MSC_VER +# pragma warning(push) // Saves the current warning state. +# pragma warning(disable:4180) // Temporarily disables warning 4180. +#endif // _MSC_VER + + // Note: we deliberately don't call this PrintTo(), as that name + // conflicts with ::testing::internal::PrintTo in the body of the + // function. + static void Print(const T& value, ::std::ostream* os) { + // By default, ::testing::internal::PrintTo() is used for printing + // the value. + // + // Thanks to Koenig look-up, if T is a class and has its own + // PrintTo() function defined in its namespace, that function will + // be visible here. Since it is more specific than the generic ones + // in ::testing::internal, it will be picked by the compiler in the + // following statement - exactly what we want. + PrintTo(value, os); + } + +#ifdef _MSC_VER +# pragma warning(pop) // Restores the warning state. +#endif // _MSC_VER +}; + +// UniversalPrintArray(begin, len, os) prints an array of 'len' +// elements, starting at address 'begin'. +template +void UniversalPrintArray(const T* begin, size_t len, ::std::ostream* os) { + if (len == 0) { + *os << "{}"; + } else { + *os << "{ "; + const size_t kThreshold = 18; + const size_t kChunkSize = 8; + // If the array has more than kThreshold elements, we'll have to + // omit some details by printing only the first and the last + // kChunkSize elements. + // TODO(wan@google.com): let the user control the threshold using a flag. + if (len <= kThreshold) { + PrintRawArrayTo(begin, len, os); + } else { + PrintRawArrayTo(begin, kChunkSize, os); + *os << ", ..., "; + PrintRawArrayTo(begin + len - kChunkSize, kChunkSize, os); + } + *os << " }"; + } +} +// This overload prints a (const) char array compactly. +GTEST_API_ void UniversalPrintArray( + const char* begin, size_t len, ::std::ostream* os); + +// This overload prints a (const) wchar_t array compactly. +GTEST_API_ void UniversalPrintArray( + const wchar_t* begin, size_t len, ::std::ostream* os); + +// Implements printing an array type T[N]. +template +class UniversalPrinter { + public: + // Prints the given array, omitting some elements when there are too + // many. + static void Print(const T (&a)[N], ::std::ostream* os) { + UniversalPrintArray(a, N, os); + } +}; + +// Implements printing a reference type T&. +template +class UniversalPrinter { + public: + // MSVC warns about adding const to a function type, so we want to + // disable the warning. +#ifdef _MSC_VER +# pragma warning(push) // Saves the current warning state. +# pragma warning(disable:4180) // Temporarily disables warning 4180. +#endif // _MSC_VER + + static void Print(const T& value, ::std::ostream* os) { + // Prints the address of the value. We use reinterpret_cast here + // as static_cast doesn't compile when T is a function type. + *os << "@" << reinterpret_cast(&value) << " "; + + // Then prints the value itself. + UniversalPrint(value, os); + } + +#ifdef _MSC_VER +# pragma warning(pop) // Restores the warning state. +#endif // _MSC_VER +}; + +// Prints a value tersely: for a reference type, the referenced value +// (but not the address) is printed; for a (const) char pointer, the +// NUL-terminated string (but not the pointer) is printed. + +template +class UniversalTersePrinter { + public: + static void Print(const T& value, ::std::ostream* os) { + UniversalPrint(value, os); + } +}; +template +class UniversalTersePrinter { + public: + static void Print(const T& value, ::std::ostream* os) { + UniversalPrint(value, os); + } +}; +template +class UniversalTersePrinter { + public: + static void Print(const T (&value)[N], ::std::ostream* os) { + UniversalPrinter::Print(value, os); + } +}; +template <> +class UniversalTersePrinter { + public: + static void Print(const char* str, ::std::ostream* os) { + if (str == NULL) { + *os << "NULL"; + } else { + UniversalPrint(string(str), os); + } + } +}; +template <> +class UniversalTersePrinter { + public: + static void Print(char* str, ::std::ostream* os) { + UniversalTersePrinter::Print(str, os); + } +}; + +#if GTEST_HAS_STD_WSTRING +template <> +class UniversalTersePrinter { + public: + static void Print(const wchar_t* str, ::std::ostream* os) { + if (str == NULL) { + *os << "NULL"; + } else { + UniversalPrint(::std::wstring(str), os); + } + } +}; +#endif + +template <> +class UniversalTersePrinter { + public: + static void Print(wchar_t* str, ::std::ostream* os) { + UniversalTersePrinter::Print(str, os); + } +}; + +template +void UniversalTersePrint(const T& value, ::std::ostream* os) { + UniversalTersePrinter::Print(value, os); +} + +// Prints a value using the type inferred by the compiler. The +// difference between this and UniversalTersePrint() is that for a +// (const) char pointer, this prints both the pointer and the +// NUL-terminated string. +template +void UniversalPrint(const T& value, ::std::ostream* os) { + // A workarond for the bug in VC++ 7.1 that prevents us from instantiating + // UniversalPrinter with T directly. + typedef T T1; + UniversalPrinter::Print(value, os); +} + +#if GTEST_HAS_TR1_TUPLE +typedef ::std::vector Strings; + +// This helper template allows PrintTo() for tuples and +// UniversalTersePrintTupleFieldsToStrings() to be defined by +// induction on the number of tuple fields. The idea is that +// TuplePrefixPrinter::PrintPrefixTo(t, os) prints the first N +// fields in tuple t, and can be defined in terms of +// TuplePrefixPrinter. + +// The inductive case. +template +struct TuplePrefixPrinter { + // Prints the first N fields of a tuple. + template + static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) { + TuplePrefixPrinter::PrintPrefixTo(t, os); + *os << ", "; + UniversalPrinter::type> + ::Print(::std::tr1::get(t), os); + } + + // Tersely prints the first N fields of a tuple to a string vector, + // one element for each field. + template + static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) { + TuplePrefixPrinter::TersePrintPrefixToStrings(t, strings); + ::std::stringstream ss; + UniversalTersePrint(::std::tr1::get(t), &ss); + strings->push_back(ss.str()); + } +}; + +// Base cases. +template <> +struct TuplePrefixPrinter<0> { + template + static void PrintPrefixTo(const Tuple&, ::std::ostream*) {} + + template + static void TersePrintPrefixToStrings(const Tuple&, Strings*) {} +}; +// We have to specialize the entire TuplePrefixPrinter<> class +// template here, even though the definition of +// TersePrintPrefixToStrings() is the same as the generic version, as +// Embarcadero (formerly CodeGear, formerly Borland) C++ doesn't +// support specializing a method template of a class template. +template <> +struct TuplePrefixPrinter<1> { + template + static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) { + UniversalPrinter::type>:: + Print(::std::tr1::get<0>(t), os); + } + + template + static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) { + ::std::stringstream ss; + UniversalTersePrint(::std::tr1::get<0>(t), &ss); + strings->push_back(ss.str()); + } +}; + +// Helper function for printing a tuple. T must be instantiated with +// a tuple type. +template +void PrintTupleTo(const T& t, ::std::ostream* os) { + *os << "("; + TuplePrefixPrinter< ::std::tr1::tuple_size::value>:: + PrintPrefixTo(t, os); + *os << ")"; +} + +// Prints the fields of a tuple tersely to a string vector, one +// element for each field. See the comment before +// UniversalTersePrint() for how we define "tersely". +template +Strings UniversalTersePrintTupleFieldsToStrings(const Tuple& value) { + Strings result; + TuplePrefixPrinter< ::std::tr1::tuple_size::value>:: + TersePrintPrefixToStrings(value, &result); + return result; +} +#endif // GTEST_HAS_TR1_TUPLE + +} // namespace internal + +template +::std::string PrintToString(const T& value) { + ::std::stringstream ss; + internal::UniversalTersePrinter::Print(value, &ss); + return ss.str(); +} + +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_GTEST_PRINTERS_H_ diff --git a/test/fmw/gtest/include/gtest/gtest-spi.h b/test/fmw/gtest/include/gtest/gtest-spi.h new file mode 100644 index 00000000000..f63fa9a1b2a --- /dev/null +++ b/test/fmw/gtest/include/gtest/gtest-spi.h @@ -0,0 +1,232 @@ +// Copyright 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) +// +// Utilities for testing Google Test itself and code that uses Google Test +// (e.g. frameworks built on top of Google Test). + +#ifndef GTEST_INCLUDE_GTEST_GTEST_SPI_H_ +#define GTEST_INCLUDE_GTEST_GTEST_SPI_H_ + +#include "gtest/gtest.h" + +namespace testing { + +// This helper class can be used to mock out Google Test failure reporting +// so that we can test Google Test or code that builds on Google Test. +// +// An object of this class appends a TestPartResult object to the +// TestPartResultArray object given in the constructor whenever a Google Test +// failure is reported. It can either intercept only failures that are +// generated in the same thread that created this object or it can intercept +// all generated failures. The scope of this mock object can be controlled with +// the second argument to the two arguments constructor. +class GTEST_API_ ScopedFakeTestPartResultReporter + : public TestPartResultReporterInterface { + public: + // The two possible mocking modes of this object. + enum InterceptMode { + INTERCEPT_ONLY_CURRENT_THREAD, // Intercepts only thread local failures. + INTERCEPT_ALL_THREADS // Intercepts all failures. + }; + + // The c'tor sets this object as the test part result reporter used + // by Google Test. The 'result' parameter specifies where to report the + // results. This reporter will only catch failures generated in the current + // thread. DEPRECATED + explicit ScopedFakeTestPartResultReporter(TestPartResultArray* result); + + // Same as above, but you can choose the interception scope of this object. + ScopedFakeTestPartResultReporter(InterceptMode intercept_mode, + TestPartResultArray* result); + + // The d'tor restores the previous test part result reporter. + virtual ~ScopedFakeTestPartResultReporter(); + + // Appends the TestPartResult object to the TestPartResultArray + // received in the constructor. + // + // This method is from the TestPartResultReporterInterface + // interface. + virtual void ReportTestPartResult(const TestPartResult& result); + private: + void Init(); + + const InterceptMode intercept_mode_; + TestPartResultReporterInterface* old_reporter_; + TestPartResultArray* const result_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedFakeTestPartResultReporter); +}; + +namespace internal { + +// A helper class for implementing EXPECT_FATAL_FAILURE() and +// EXPECT_NONFATAL_FAILURE(). Its destructor verifies that the given +// TestPartResultArray contains exactly one failure that has the given +// type and contains the given substring. If that's not the case, a +// non-fatal failure will be generated. +class GTEST_API_ SingleFailureChecker { + public: + // The constructor remembers the arguments. + SingleFailureChecker(const TestPartResultArray* results, + TestPartResult::Type type, + const string& substr); + ~SingleFailureChecker(); + private: + const TestPartResultArray* const results_; + const TestPartResult::Type type_; + const string substr_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(SingleFailureChecker); +}; + +} // namespace internal + +} // namespace testing + +// A set of macros for testing Google Test assertions or code that's expected +// to generate Google Test fatal failures. It verifies that the given +// statement will cause exactly one fatal Google Test failure with 'substr' +// being part of the failure message. +// +// There are two different versions of this macro. EXPECT_FATAL_FAILURE only +// affects and considers failures generated in the current thread and +// EXPECT_FATAL_FAILURE_ON_ALL_THREADS does the same but for all threads. +// +// The verification of the assertion is done correctly even when the statement +// throws an exception or aborts the current function. +// +// Known restrictions: +// - 'statement' cannot reference local non-static variables or +// non-static members of the current object. +// - 'statement' cannot return a value. +// - You cannot stream a failure message to this macro. +// +// Note that even though the implementations of the following two +// macros are much alike, we cannot refactor them to use a common +// helper macro, due to some peculiarity in how the preprocessor +// works. The AcceptsMacroThatExpandsToUnprotectedComma test in +// gtest_unittest.cc will fail to compile if we do that. +#define EXPECT_FATAL_FAILURE(statement, substr) \ + do { \ + class GTestExpectFatalFailureHelper {\ + public:\ + static void Execute() { statement; }\ + };\ + ::testing::TestPartResultArray gtest_failures;\ + ::testing::internal::SingleFailureChecker gtest_checker(\ + >est_failures, ::testing::TestPartResult::kFatalFailure, (substr));\ + {\ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ + ::testing::ScopedFakeTestPartResultReporter:: \ + INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\ + GTestExpectFatalFailureHelper::Execute();\ + }\ + } while (::testing::internal::AlwaysFalse()) + +#define EXPECT_FATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ + do { \ + class GTestExpectFatalFailureHelper {\ + public:\ + static void Execute() { statement; }\ + };\ + ::testing::TestPartResultArray gtest_failures;\ + ::testing::internal::SingleFailureChecker gtest_checker(\ + >est_failures, ::testing::TestPartResult::kFatalFailure, (substr));\ + {\ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ + ::testing::ScopedFakeTestPartResultReporter:: \ + INTERCEPT_ALL_THREADS, >est_failures);\ + GTestExpectFatalFailureHelper::Execute();\ + }\ + } while (::testing::internal::AlwaysFalse()) + +// A macro for testing Google Test assertions or code that's expected to +// generate Google Test non-fatal failures. It asserts that the given +// statement will cause exactly one non-fatal Google Test failure with 'substr' +// being part of the failure message. +// +// There are two different versions of this macro. EXPECT_NONFATAL_FAILURE only +// affects and considers failures generated in the current thread and +// EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS does the same but for all threads. +// +// 'statement' is allowed to reference local variables and members of +// the current object. +// +// The verification of the assertion is done correctly even when the statement +// throws an exception or aborts the current function. +// +// Known restrictions: +// - You cannot stream a failure message to this macro. +// +// Note that even though the implementations of the following two +// macros are much alike, we cannot refactor them to use a common +// helper macro, due to some peculiarity in how the preprocessor +// works. If we do that, the code won't compile when the user gives +// EXPECT_NONFATAL_FAILURE() a statement that contains a macro that +// expands to code containing an unprotected comma. The +// AcceptsMacroThatExpandsToUnprotectedComma test in gtest_unittest.cc +// catches that. +// +// For the same reason, we have to write +// if (::testing::internal::AlwaysTrue()) { statement; } +// instead of +// GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) +// to avoid an MSVC warning on unreachable code. +#define EXPECT_NONFATAL_FAILURE(statement, substr) \ + do {\ + ::testing::TestPartResultArray gtest_failures;\ + ::testing::internal::SingleFailureChecker gtest_checker(\ + >est_failures, ::testing::TestPartResult::kNonFatalFailure, \ + (substr));\ + {\ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ + ::testing::ScopedFakeTestPartResultReporter:: \ + INTERCEPT_ONLY_CURRENT_THREAD, >est_failures);\ + if (::testing::internal::AlwaysTrue()) { statement; }\ + }\ + } while (::testing::internal::AlwaysFalse()) + +#define EXPECT_NONFATAL_FAILURE_ON_ALL_THREADS(statement, substr) \ + do {\ + ::testing::TestPartResultArray gtest_failures;\ + ::testing::internal::SingleFailureChecker gtest_checker(\ + >est_failures, ::testing::TestPartResult::kNonFatalFailure, \ + (substr));\ + {\ + ::testing::ScopedFakeTestPartResultReporter gtest_reporter(\ + ::testing::ScopedFakeTestPartResultReporter::INTERCEPT_ALL_THREADS, \ + >est_failures);\ + if (::testing::internal::AlwaysTrue()) { statement; }\ + }\ + } while (::testing::internal::AlwaysFalse()) + +#endif // GTEST_INCLUDE_GTEST_GTEST_SPI_H_ diff --git a/test/fmw/gtest/include/gtest/gtest-test-part.h b/test/fmw/gtest/include/gtest/gtest-test-part.h new file mode 100644 index 00000000000..77eb844839d --- /dev/null +++ b/test/fmw/gtest/include/gtest/gtest-test-part.h @@ -0,0 +1,179 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: mheule@google.com (Markus Heule) +// + +#ifndef GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ +#define GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ + +#include +#include +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-string.h" + +namespace testing { + +// A copyable object representing the result of a test part (i.e. an +// assertion or an explicit FAIL(), ADD_FAILURE(), or SUCCESS()). +// +// Don't inherit from TestPartResult as its destructor is not virtual. +class GTEST_API_ TestPartResult { + public: + // The possible outcomes of a test part (i.e. an assertion or an + // explicit SUCCEED(), FAIL(), or ADD_FAILURE()). + enum Type { + kSuccess, // Succeeded. + kNonFatalFailure, // Failed but the test can continue. + kFatalFailure // Failed and the test should be terminated. + }; + + // C'tor. TestPartResult does NOT have a default constructor. + // Always use this constructor (with parameters) to create a + // TestPartResult object. + TestPartResult(Type a_type, + const char* a_file_name, + int a_line_number, + const char* a_message) + : type_(a_type), + file_name_(a_file_name == NULL ? "" : a_file_name), + line_number_(a_line_number), + summary_(ExtractSummary(a_message)), + message_(a_message) { + } + + // Gets the outcome of the test part. + Type type() const { return type_; } + + // Gets the name of the source file where the test part took place, or + // NULL if it's unknown. + const char* file_name() const { + return file_name_.empty() ? NULL : file_name_.c_str(); + } + + // Gets the line in the source file where the test part took place, + // or -1 if it's unknown. + int line_number() const { return line_number_; } + + // Gets the summary of the failure message. + const char* summary() const { return summary_.c_str(); } + + // Gets the message associated with the test part. + const char* message() const { return message_.c_str(); } + + // Returns true iff the test part passed. + bool passed() const { return type_ == kSuccess; } + + // Returns true iff the test part failed. + bool failed() const { return type_ != kSuccess; } + + // Returns true iff the test part non-fatally failed. + bool nonfatally_failed() const { return type_ == kNonFatalFailure; } + + // Returns true iff the test part fatally failed. + bool fatally_failed() const { return type_ == kFatalFailure; } + + private: + Type type_; + + // Gets the summary of the failure message by omitting the stack + // trace in it. + static std::string ExtractSummary(const char* message); + + // The name of the source file where the test part took place, or + // "" if the source file is unknown. + std::string file_name_; + // The line in the source file where the test part took place, or -1 + // if the line number is unknown. + int line_number_; + std::string summary_; // The test failure summary. + std::string message_; // The test failure message. +}; + +// Prints a TestPartResult object. +std::ostream& operator<<(std::ostream& os, const TestPartResult& result); + +// An array of TestPartResult objects. +// +// Don't inherit from TestPartResultArray as its destructor is not +// virtual. +class GTEST_API_ TestPartResultArray { + public: + TestPartResultArray() {} + + // Appends the given TestPartResult to the array. + void Append(const TestPartResult& result); + + // Returns the TestPartResult at the given index (0-based). + const TestPartResult& GetTestPartResult(int index) const; + + // Returns the number of TestPartResult objects in the array. + int size() const; + + private: + std::vector array_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestPartResultArray); +}; + +// This interface knows how to report a test part result. +class TestPartResultReporterInterface { + public: + virtual ~TestPartResultReporterInterface() {} + + virtual void ReportTestPartResult(const TestPartResult& result) = 0; +}; + +namespace internal { + +// This helper class is used by {ASSERT|EXPECT}_NO_FATAL_FAILURE to check if a +// statement generates new fatal failures. To do so it registers itself as the +// current test part result reporter. Besides checking if fatal failures were +// reported, it only delegates the reporting to the former result reporter. +// The original result reporter is restored in the destructor. +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +class GTEST_API_ HasNewFatalFailureHelper + : public TestPartResultReporterInterface { + public: + HasNewFatalFailureHelper(); + virtual ~HasNewFatalFailureHelper(); + virtual void ReportTestPartResult(const TestPartResult& result); + bool has_new_fatal_failure() const { return has_new_fatal_failure_; } + private: + bool has_new_fatal_failure_; + TestPartResultReporterInterface* original_reporter_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(HasNewFatalFailureHelper); +}; + +} // namespace internal + +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_GTEST_TEST_PART_H_ diff --git a/test/fmw/gtest/include/gtest/gtest-typed-test.h b/test/fmw/gtest/include/gtest/gtest-typed-test.h new file mode 100644 index 00000000000..fe1e83b274b --- /dev/null +++ b/test/fmw/gtest/include/gtest/gtest-typed-test.h @@ -0,0 +1,259 @@ +// Copyright 2008 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) + +#ifndef GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_ +#define GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_ + +// This header implements typed tests and type-parameterized tests. + +// Typed (aka type-driven) tests repeat the same test for types in a +// list. You must know which types you want to test with when writing +// typed tests. Here's how you do it: + +#if 0 + +// First, define a fixture class template. It should be parameterized +// by a type. Remember to derive it from testing::Test. +template +class FooTest : public testing::Test { + public: + ... + typedef std::list List; + static T shared_; + T value_; +}; + +// Next, associate a list of types with the test case, which will be +// repeated for each type in the list. The typedef is necessary for +// the macro to parse correctly. +typedef testing::Types MyTypes; +TYPED_TEST_CASE(FooTest, MyTypes); + +// If the type list contains only one type, you can write that type +// directly without Types<...>: +// TYPED_TEST_CASE(FooTest, int); + +// Then, use TYPED_TEST() instead of TEST_F() to define as many typed +// tests for this test case as you want. +TYPED_TEST(FooTest, DoesBlah) { + // Inside a test, refer to TypeParam to get the type parameter. + // Since we are inside a derived class template, C++ requires use to + // visit the members of FooTest via 'this'. + TypeParam n = this->value_; + + // To visit static members of the fixture, add the TestFixture:: + // prefix. + n += TestFixture::shared_; + + // To refer to typedefs in the fixture, add the "typename + // TestFixture::" prefix. + typename TestFixture::List values; + values.push_back(n); + ... +} + +TYPED_TEST(FooTest, HasPropertyA) { ... } + +#endif // 0 + +// Type-parameterized tests are abstract test patterns parameterized +// by a type. Compared with typed tests, type-parameterized tests +// allow you to define the test pattern without knowing what the type +// parameters are. The defined pattern can be instantiated with +// different types any number of times, in any number of translation +// units. +// +// If you are designing an interface or concept, you can define a +// suite of type-parameterized tests to verify properties that any +// valid implementation of the interface/concept should have. Then, +// each implementation can easily instantiate the test suite to verify +// that it conforms to the requirements, without having to write +// similar tests repeatedly. Here's an example: + +#if 0 + +// First, define a fixture class template. It should be parameterized +// by a type. Remember to derive it from testing::Test. +template +class FooTest : public testing::Test { + ... +}; + +// Next, declare that you will define a type-parameterized test case +// (the _P suffix is for "parameterized" or "pattern", whichever you +// prefer): +TYPED_TEST_CASE_P(FooTest); + +// Then, use TYPED_TEST_P() to define as many type-parameterized tests +// for this type-parameterized test case as you want. +TYPED_TEST_P(FooTest, DoesBlah) { + // Inside a test, refer to TypeParam to get the type parameter. + TypeParam n = 0; + ... +} + +TYPED_TEST_P(FooTest, HasPropertyA) { ... } + +// Now the tricky part: you need to register all test patterns before +// you can instantiate them. The first argument of the macro is the +// test case name; the rest are the names of the tests in this test +// case. +REGISTER_TYPED_TEST_CASE_P(FooTest, + DoesBlah, HasPropertyA); + +// Finally, you are free to instantiate the pattern with the types you +// want. If you put the above code in a header file, you can #include +// it in multiple C++ source files and instantiate it multiple times. +// +// To distinguish different instances of the pattern, the first +// argument to the INSTANTIATE_* macro is a prefix that will be added +// to the actual test case name. Remember to pick unique prefixes for +// different instances. +typedef testing::Types MyTypes; +INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, MyTypes); + +// If the type list contains only one type, you can write that type +// directly without Types<...>: +// INSTANTIATE_TYPED_TEST_CASE_P(My, FooTest, int); + +#endif // 0 + +#include "gtest/internal/gtest-port.h" +#include "gtest/internal/gtest-type-util.h" + +// Implements typed tests. + +#if GTEST_HAS_TYPED_TEST + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Expands to the name of the typedef for the type parameters of the +// given test case. +# define GTEST_TYPE_PARAMS_(TestCaseName) gtest_type_params_##TestCaseName##_ + +// The 'Types' template argument below must have spaces around it +// since some compilers may choke on '>>' when passing a template +// instance (e.g. Types) +# define TYPED_TEST_CASE(CaseName, Types) \ + typedef ::testing::internal::TypeList< Types >::type \ + GTEST_TYPE_PARAMS_(CaseName) + +# define TYPED_TEST(CaseName, TestName) \ + template \ + class GTEST_TEST_CLASS_NAME_(CaseName, TestName) \ + : public CaseName { \ + private: \ + typedef CaseName TestFixture; \ + typedef gtest_TypeParam_ TypeParam; \ + virtual void TestBody(); \ + }; \ + bool gtest_##CaseName##_##TestName##_registered_ GTEST_ATTRIBUTE_UNUSED_ = \ + ::testing::internal::TypeParameterizedTest< \ + CaseName, \ + ::testing::internal::TemplateSel< \ + GTEST_TEST_CLASS_NAME_(CaseName, TestName)>, \ + GTEST_TYPE_PARAMS_(CaseName)>::Register(\ + "", #CaseName, #TestName, 0); \ + template \ + void GTEST_TEST_CLASS_NAME_(CaseName, TestName)::TestBody() + +#endif // GTEST_HAS_TYPED_TEST + +// Implements type-parameterized tests. + +#if GTEST_HAS_TYPED_TEST_P + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Expands to the namespace name that the type-parameterized tests for +// the given type-parameterized test case are defined in. The exact +// name of the namespace is subject to change without notice. +# define GTEST_CASE_NAMESPACE_(TestCaseName) \ + gtest_case_##TestCaseName##_ + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Expands to the name of the variable used to remember the names of +// the defined tests in the given test case. +# define GTEST_TYPED_TEST_CASE_P_STATE_(TestCaseName) \ + gtest_typed_test_case_p_state_##TestCaseName##_ + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE DIRECTLY. +// +// Expands to the name of the variable used to remember the names of +// the registered tests in the given test case. +# define GTEST_REGISTERED_TEST_NAMES_(TestCaseName) \ + gtest_registered_test_names_##TestCaseName##_ + +// The variables defined in the type-parameterized test macros are +// static as typically these macros are used in a .h file that can be +// #included in multiple translation units linked together. +# define TYPED_TEST_CASE_P(CaseName) \ + static ::testing::internal::TypedTestCasePState \ + GTEST_TYPED_TEST_CASE_P_STATE_(CaseName) + +# define TYPED_TEST_P(CaseName, TestName) \ + namespace GTEST_CASE_NAMESPACE_(CaseName) { \ + template \ + class TestName : public CaseName { \ + private: \ + typedef CaseName TestFixture; \ + typedef gtest_TypeParam_ TypeParam; \ + virtual void TestBody(); \ + }; \ + static bool gtest_##TestName##_defined_ GTEST_ATTRIBUTE_UNUSED_ = \ + GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).AddTestName(\ + __FILE__, __LINE__, #CaseName, #TestName); \ + } \ + template \ + void GTEST_CASE_NAMESPACE_(CaseName)::TestName::TestBody() + +# define REGISTER_TYPED_TEST_CASE_P(CaseName, ...) \ + namespace GTEST_CASE_NAMESPACE_(CaseName) { \ + typedef ::testing::internal::Templates<__VA_ARGS__>::type gtest_AllTests_; \ + } \ + static const char* const GTEST_REGISTERED_TEST_NAMES_(CaseName) = \ + GTEST_TYPED_TEST_CASE_P_STATE_(CaseName).VerifyRegisteredTestNames(\ + __FILE__, __LINE__, #__VA_ARGS__) + +// The 'Types' template argument below must have spaces around it +// since some compilers may choke on '>>' when passing a template +// instance (e.g. Types) +# define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, CaseName, Types) \ + bool gtest_##Prefix##_##CaseName GTEST_ATTRIBUTE_UNUSED_ = \ + ::testing::internal::TypeParameterizedTestCase::type>::Register(\ + #Prefix, #CaseName, GTEST_REGISTERED_TEST_NAMES_(CaseName)) + +#endif // GTEST_HAS_TYPED_TEST_P + +#endif // GTEST_INCLUDE_GTEST_GTEST_TYPED_TEST_H_ diff --git a/test/fmw/gtest/include/gtest/gtest.h b/test/fmw/gtest/include/gtest/gtest.h new file mode 100644 index 00000000000..6fa0a3925e7 --- /dev/null +++ b/test/fmw/gtest/include/gtest/gtest.h @@ -0,0 +1,2291 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) +// +// The Google C++ Testing Framework (Google Test) +// +// This header file defines the public API for Google Test. It should be +// included by any test program that uses Google Test. +// +// IMPORTANT NOTE: Due to limitation of the C++ language, we have to +// leave some internal implementation details in this header file. +// They are clearly marked by comments like this: +// +// // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +// +// Such code is NOT meant to be used by a user directly, and is subject +// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user +// program! +// +// Acknowledgment: Google Test borrowed the idea of automatic test +// registration from Barthelemy Dagenais' (barthelemy@prologique.com) +// easyUnit framework. + +#ifndef GTEST_INCLUDE_GTEST_GTEST_H_ +#define GTEST_INCLUDE_GTEST_GTEST_H_ + +#include +#include +#include + +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-string.h" +#include "gtest/gtest-death-test.h" +#include "gtest/gtest-message.h" +#include "gtest/gtest-param-test.h" +#include "gtest/gtest-printers.h" +#include "gtest/gtest_prod.h" +#include "gtest/gtest-test-part.h" +#include "gtest/gtest-typed-test.h" + +// Depending on the platform, different string classes are available. +// On Linux, in addition to ::std::string, Google also makes use of +// class ::string, which has the same interface as ::std::string, but +// has a different implementation. +// +// The user can define GTEST_HAS_GLOBAL_STRING to 1 to indicate that +// ::string is available AND is a distinct type to ::std::string, or +// define it to 0 to indicate otherwise. +// +// If the user's ::std::string and ::string are the same class due to +// aliasing, he should define GTEST_HAS_GLOBAL_STRING to 0. +// +// If the user doesn't define GTEST_HAS_GLOBAL_STRING, it is defined +// heuristically. + +namespace testing { + +// Declares the flags. + +// This flag temporary enables the disabled tests. +GTEST_DECLARE_bool_(also_run_disabled_tests); + +// This flag brings the debugger on an assertion failure. +GTEST_DECLARE_bool_(break_on_failure); + +// This flag controls whether Google Test catches all test-thrown exceptions +// and logs them as failures. +GTEST_DECLARE_bool_(catch_exceptions); + +// This flag enables using colors in terminal output. Available values are +// "yes" to enable colors, "no" (disable colors), or "auto" (the default) +// to let Google Test decide. +GTEST_DECLARE_string_(color); + +// This flag sets up the filter to select by name using a glob pattern +// the tests to run. If the filter is not given all tests are executed. +GTEST_DECLARE_string_(filter); + +// This flag causes the Google Test to list tests. None of the tests listed +// are actually run if the flag is provided. +GTEST_DECLARE_bool_(list_tests); + +// This flag controls whether Google Test emits a detailed XML report to a file +// in addition to its normal textual output. +GTEST_DECLARE_string_(output); + +// This flags control whether Google Test prints the elapsed time for each +// test. +GTEST_DECLARE_bool_(print_time); + +// This flag specifies the random number seed. +GTEST_DECLARE_int32_(random_seed); + +// This flag sets how many times the tests are repeated. The default value +// is 1. If the value is -1 the tests are repeating forever. +GTEST_DECLARE_int32_(repeat); + +// This flag controls whether Google Test includes Google Test internal +// stack frames in failure stack traces. +GTEST_DECLARE_bool_(show_internal_stack_frames); + +// When this flag is specified, tests' order is randomized on every iteration. +GTEST_DECLARE_bool_(shuffle); + +// This flag specifies the maximum number of stack frames to be +// printed in a failure message. +GTEST_DECLARE_int32_(stack_trace_depth); + +// When this flag is specified, a failed assertion will throw an +// exception if exceptions are enabled, or exit the program with a +// non-zero code otherwise. +GTEST_DECLARE_bool_(throw_on_failure); + +// When this flag is set with a "host:port" string, on supported +// platforms test results are streamed to the specified port on +// the specified host machine. +GTEST_DECLARE_string_(stream_result_to); + +// The upper limit for valid stack trace depths. +const int kMaxStackTraceDepth = 100; + +namespace internal { + +class AssertHelper; +class DefaultGlobalTestPartResultReporter; +class ExecDeathTest; +class NoExecDeathTest; +class FinalSuccessChecker; +class GTestFlagSaver; +class StreamingListenerTest; +class TestResultAccessor; +class TestEventListenersAccessor; +class TestEventRepeater; +class UnitTestRecordPropertyTestHelper; +class WindowsDeathTest; +class UnitTestImpl* GetUnitTestImpl(); +void ReportFailureInUnknownLocation(TestPartResult::Type result_type, + const std::string& message); + +} // namespace internal + +// The friend relationship of some of these classes is cyclic. +// If we don't forward declare them the compiler might confuse the classes +// in friendship clauses with same named classes on the scope. +class Test; +class TestCase; +class TestInfo; +class UnitTest; + +// A class for indicating whether an assertion was successful. When +// the assertion wasn't successful, the AssertionResult object +// remembers a non-empty message that describes how it failed. +// +// To create an instance of this class, use one of the factory functions +// (AssertionSuccess() and AssertionFailure()). +// +// This class is useful for two purposes: +// 1. Defining predicate functions to be used with Boolean test assertions +// EXPECT_TRUE/EXPECT_FALSE and their ASSERT_ counterparts +// 2. Defining predicate-format functions to be +// used with predicate assertions (ASSERT_PRED_FORMAT*, etc). +// +// For example, if you define IsEven predicate: +// +// testing::AssertionResult IsEven(int n) { +// if ((n % 2) == 0) +// return testing::AssertionSuccess(); +// else +// return testing::AssertionFailure() << n << " is odd"; +// } +// +// Then the failed expectation EXPECT_TRUE(IsEven(Fib(5))) +// will print the message +// +// Value of: IsEven(Fib(5)) +// Actual: false (5 is odd) +// Expected: true +// +// instead of a more opaque +// +// Value of: IsEven(Fib(5)) +// Actual: false +// Expected: true +// +// in case IsEven is a simple Boolean predicate. +// +// If you expect your predicate to be reused and want to support informative +// messages in EXPECT_FALSE and ASSERT_FALSE (negative assertions show up +// about half as often as positive ones in our tests), supply messages for +// both success and failure cases: +// +// testing::AssertionResult IsEven(int n) { +// if ((n % 2) == 0) +// return testing::AssertionSuccess() << n << " is even"; +// else +// return testing::AssertionFailure() << n << " is odd"; +// } +// +// Then a statement EXPECT_FALSE(IsEven(Fib(6))) will print +// +// Value of: IsEven(Fib(6)) +// Actual: true (8 is even) +// Expected: false +// +// NB: Predicates that support negative Boolean assertions have reduced +// performance in positive ones so be careful not to use them in tests +// that have lots (tens of thousands) of positive Boolean assertions. +// +// To use this class with EXPECT_PRED_FORMAT assertions such as: +// +// // Verifies that Foo() returns an even number. +// EXPECT_PRED_FORMAT1(IsEven, Foo()); +// +// you need to define: +// +// testing::AssertionResult IsEven(const char* expr, int n) { +// if ((n % 2) == 0) +// return testing::AssertionSuccess(); +// else +// return testing::AssertionFailure() +// << "Expected: " << expr << " is even\n Actual: it's " << n; +// } +// +// If Foo() returns 5, you will see the following message: +// +// Expected: Foo() is even +// Actual: it's 5 +// +class GTEST_API_ AssertionResult { + public: + // Copy constructor. + // Used in EXPECT_TRUE/FALSE(assertion_result). + AssertionResult(const AssertionResult& other); + // Used in the EXPECT_TRUE/FALSE(bool_expression). + explicit AssertionResult(bool success) : success_(success) {} + + // Returns true iff the assertion succeeded. + operator bool() const { return success_; } // NOLINT + + // Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE. + AssertionResult operator!() const; + + // Returns the text streamed into this AssertionResult. Test assertions + // use it when they fail (i.e., the predicate's outcome doesn't match the + // assertion's expectation). When nothing has been streamed into the + // object, returns an empty string. + const char* message() const { + return message_.get() != NULL ? message_->c_str() : ""; + } + // TODO(vladl@google.com): Remove this after making sure no clients use it. + // Deprecated; please use message() instead. + const char* failure_message() const { return message(); } + + // Streams a custom failure message into this object. + template AssertionResult& operator<<(const T& value) { + AppendMessage(Message() << value); + return *this; + } + + // Allows streaming basic output manipulators such as endl or flush into + // this object. + AssertionResult& operator<<( + ::std::ostream& (*basic_manipulator)(::std::ostream& stream)) { + AppendMessage(Message() << basic_manipulator); + return *this; + } + + private: + // Appends the contents of message to message_. + void AppendMessage(const Message& a_message) { + if (message_.get() == NULL) + message_.reset(new ::std::string); + message_->append(a_message.GetString().c_str()); + } + + // Stores result of the assertion predicate. + bool success_; + // Stores the message describing the condition in case the expectation + // construct is not satisfied with the predicate's outcome. + // Referenced via a pointer to avoid taking too much stack frame space + // with test assertions. + internal::scoped_ptr< ::std::string> message_; + + GTEST_DISALLOW_ASSIGN_(AssertionResult); +}; + +// Makes a successful assertion result. +GTEST_API_ AssertionResult AssertionSuccess(); + +// Makes a failed assertion result. +GTEST_API_ AssertionResult AssertionFailure(); + +// Makes a failed assertion result with the given failure message. +// Deprecated; use AssertionFailure() << msg. +GTEST_API_ AssertionResult AssertionFailure(const Message& msg); + +// The abstract class that all tests inherit from. +// +// In Google Test, a unit test program contains one or many TestCases, and +// each TestCase contains one or many Tests. +// +// When you define a test using the TEST macro, you don't need to +// explicitly derive from Test - the TEST macro automatically does +// this for you. +// +// The only time you derive from Test is when defining a test fixture +// to be used a TEST_F. For example: +// +// class FooTest : public testing::Test { +// protected: +// virtual void SetUp() { ... } +// virtual void TearDown() { ... } +// ... +// }; +// +// TEST_F(FooTest, Bar) { ... } +// TEST_F(FooTest, Baz) { ... } +// +// Test is not copyable. +class GTEST_API_ Test { + public: + friend class TestInfo; + + // Defines types for pointers to functions that set up and tear down + // a test case. + typedef internal::SetUpTestCaseFunc SetUpTestCaseFunc; + typedef internal::TearDownTestCaseFunc TearDownTestCaseFunc; + + // The d'tor is virtual as we intend to inherit from Test. + virtual ~Test(); + + // Sets up the stuff shared by all tests in this test case. + // + // Google Test will call Foo::SetUpTestCase() before running the first + // test in test case Foo. Hence a sub-class can define its own + // SetUpTestCase() method to shadow the one defined in the super + // class. + static void SetUpTestCase() {} + + // Tears down the stuff shared by all tests in this test case. + // + // Google Test will call Foo::TearDownTestCase() after running the last + // test in test case Foo. Hence a sub-class can define its own + // TearDownTestCase() method to shadow the one defined in the super + // class. + static void TearDownTestCase() {} + + // Returns true iff the current test has a fatal failure. + static bool HasFatalFailure(); + + // Returns true iff the current test has a non-fatal failure. + static bool HasNonfatalFailure(); + + // Returns true iff the current test has a (either fatal or + // non-fatal) failure. + static bool HasFailure() { return HasFatalFailure() || HasNonfatalFailure(); } + + // Logs a property for the current test, test case, or for the entire + // invocation of the test program when used outside of the context of a + // test case. Only the last value for a given key is remembered. These + // are public static so they can be called from utility functions that are + // not members of the test fixture. Calls to RecordProperty made during + // lifespan of the test (from the moment its constructor starts to the + // moment its destructor finishes) will be output in XML as attributes of + // the element. Properties recorded from fixture's + // SetUpTestCase or TearDownTestCase are logged as attributes of the + // corresponding element. Calls to RecordProperty made in the + // global context (before or after invocation of RUN_ALL_TESTS and from + // SetUp/TearDown method of Environment objects registered with Google + // Test) will be output as attributes of the element. + static void RecordProperty(const std::string& key, const std::string& value); + static void RecordProperty(const std::string& key, int value); + + protected: + // Creates a Test object. + Test(); + + // Sets up the test fixture. + virtual void SetUp(); + + // Tears down the test fixture. + virtual void TearDown(); + + private: + // Returns true iff the current test has the same fixture class as + // the first test in the current test case. + static bool HasSameFixtureClass(); + + // Runs the test after the test fixture has been set up. + // + // A sub-class must implement this to define the test logic. + // + // DO NOT OVERRIDE THIS FUNCTION DIRECTLY IN A USER PROGRAM. + // Instead, use the TEST or TEST_F macro. + virtual void TestBody() = 0; + + // Sets up, executes, and tears down the test. + void Run(); + + // Deletes self. We deliberately pick an unusual name for this + // internal method to avoid clashing with names used in user TESTs. + void DeleteSelf_() { delete this; } + + // Uses a GTestFlagSaver to save and restore all Google Test flags. + const internal::GTestFlagSaver* const gtest_flag_saver_; + + // Often a user mis-spells SetUp() as Setup() and spends a long time + // wondering why it is never called by Google Test. The declaration of + // the following method is solely for catching such an error at + // compile time: + // + // - The return type is deliberately chosen to be not void, so it + // will be a conflict if a user declares void Setup() in his test + // fixture. + // + // - This method is private, so it will be another compiler error + // if a user calls it from his test fixture. + // + // DO NOT OVERRIDE THIS FUNCTION. + // + // If you see an error about overriding the following function or + // about it being private, you have mis-spelled SetUp() as Setup(). + struct Setup_should_be_spelled_SetUp {}; + virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; } + + // We disallow copying Tests. + GTEST_DISALLOW_COPY_AND_ASSIGN_(Test); +}; + +typedef internal::TimeInMillis TimeInMillis; + +// A copyable object representing a user specified test property which can be +// output as a key/value string pair. +// +// Don't inherit from TestProperty as its destructor is not virtual. +class TestProperty { + public: + // C'tor. TestProperty does NOT have a default constructor. + // Always use this constructor (with parameters) to create a + // TestProperty object. + TestProperty(const std::string& a_key, const std::string& a_value) : + key_(a_key), value_(a_value) { + } + + // Gets the user supplied key. + const char* key() const { + return key_.c_str(); + } + + // Gets the user supplied value. + const char* value() const { + return value_.c_str(); + } + + // Sets a new value, overriding the one supplied in the constructor. + void SetValue(const std::string& new_value) { + value_ = new_value; + } + + private: + // The key supplied by the user. + std::string key_; + // The value supplied by the user. + std::string value_; +}; + +// The result of a single Test. This includes a list of +// TestPartResults, a list of TestProperties, a count of how many +// death tests there are in the Test, and how much time it took to run +// the Test. +// +// TestResult is not copyable. +class GTEST_API_ TestResult { + public: + // Creates an empty TestResult. + TestResult(); + + // D'tor. Do not inherit from TestResult. + ~TestResult(); + + // Gets the number of all test parts. This is the sum of the number + // of successful test parts and the number of failed test parts. + int total_part_count() const; + + // Returns the number of the test properties. + int test_property_count() const; + + // Returns true iff the test passed (i.e. no test part failed). + bool Passed() const { return !Failed(); } + + // Returns true iff the test failed. + bool Failed() const; + + // Returns true iff the test fatally failed. + bool HasFatalFailure() const; + + // Returns true iff the test has a non-fatal failure. + bool HasNonfatalFailure() const; + + // Returns the elapsed time, in milliseconds. + TimeInMillis elapsed_time() const { return elapsed_time_; } + + // Returns the i-th test part result among all the results. i can range + // from 0 to test_property_count() - 1. If i is not in that range, aborts + // the program. + const TestPartResult& GetTestPartResult(int i) const; + + // Returns the i-th test property. i can range from 0 to + // test_property_count() - 1. If i is not in that range, aborts the + // program. + const TestProperty& GetTestProperty(int i) const; + + private: + friend class TestInfo; + friend class TestCase; + friend class UnitTest; + friend class internal::DefaultGlobalTestPartResultReporter; + friend class internal::ExecDeathTest; + friend class internal::TestResultAccessor; + friend class internal::UnitTestImpl; + friend class internal::WindowsDeathTest; + + // Gets the vector of TestPartResults. + const std::vector& test_part_results() const { + return test_part_results_; + } + + // Gets the vector of TestProperties. + const std::vector& test_properties() const { + return test_properties_; + } + + // Sets the elapsed time. + void set_elapsed_time(TimeInMillis elapsed) { elapsed_time_ = elapsed; } + + // Adds a test property to the list. The property is validated and may add + // a non-fatal failure if invalid (e.g., if it conflicts with reserved + // key names). If a property is already recorded for the same key, the + // value will be updated, rather than storing multiple values for the same + // key. xml_element specifies the element for which the property is being + // recorded and is used for validation. + void RecordProperty(const std::string& xml_element, + const TestProperty& test_property); + + // Adds a failure if the key is a reserved attribute of Google Test + // testcase tags. Returns true if the property is valid. + // TODO(russr): Validate attribute names are legal and human readable. + static bool ValidateTestProperty(const std::string& xml_element, + const TestProperty& test_property); + + // Adds a test part result to the list. + void AddTestPartResult(const TestPartResult& test_part_result); + + // Returns the death test count. + int death_test_count() const { return death_test_count_; } + + // Increments the death test count, returning the new count. + int increment_death_test_count() { return ++death_test_count_; } + + // Clears the test part results. + void ClearTestPartResults(); + + // Clears the object. + void Clear(); + + // Protects mutable state of the property vector and of owned + // properties, whose values may be updated. + internal::Mutex test_properites_mutex_; + + // The vector of TestPartResults + std::vector test_part_results_; + // The vector of TestProperties + std::vector test_properties_; + // Running count of death tests. + int death_test_count_; + // The elapsed time, in milliseconds. + TimeInMillis elapsed_time_; + + // We disallow copying TestResult. + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestResult); +}; // class TestResult + +// A TestInfo object stores the following information about a test: +// +// Test case name +// Test name +// Whether the test should be run +// A function pointer that creates the test object when invoked +// Test result +// +// The constructor of TestInfo registers itself with the UnitTest +// singleton such that the RUN_ALL_TESTS() macro knows which tests to +// run. +class GTEST_API_ TestInfo { + public: + // Destructs a TestInfo object. This function is not virtual, so + // don't inherit from TestInfo. + ~TestInfo(); + + // Returns the test case name. + const char* test_case_name() const { return test_case_name_.c_str(); } + + // Returns the test name. + const char* name() const { return name_.c_str(); } + + // Returns the name of the parameter type, or NULL if this is not a typed + // or a type-parameterized test. + const char* type_param() const { + if (type_param_.get() != NULL) + return type_param_->c_str(); + return NULL; + } + + // Returns the text representation of the value parameter, or NULL if this + // is not a value-parameterized test. + const char* value_param() const { + if (value_param_.get() != NULL) + return value_param_->c_str(); + return NULL; + } + + // Returns true if this test should run, that is if the test is not + // disabled (or it is disabled but the also_run_disabled_tests flag has + // been specified) and its full name matches the user-specified filter. + // + // Google Test allows the user to filter the tests by their full names. + // The full name of a test Bar in test case Foo is defined as + // "Foo.Bar". Only the tests that match the filter will run. + // + // A filter is a colon-separated list of glob (not regex) patterns, + // optionally followed by a '-' and a colon-separated list of + // negative patterns (tests to exclude). A test is run if it + // matches one of the positive patterns and does not match any of + // the negative patterns. + // + // For example, *A*:Foo.* is a filter that matches any string that + // contains the character 'A' or starts with "Foo.". + bool should_run() const { return should_run_; } + + // Returns true iff this test will appear in the XML report. + bool is_reportable() const { + // For now, the XML report includes all tests matching the filter. + // In the future, we may trim tests that are excluded because of + // sharding. + return matches_filter_; + } + + // Returns the result of the test. + const TestResult* result() const { return &result_; } + + private: +#if GTEST_HAS_DEATH_TEST + friend class internal::DefaultDeathTestFactory; +#endif // GTEST_HAS_DEATH_TEST + friend class Test; + friend class TestCase; + friend class internal::UnitTestImpl; + friend class internal::StreamingListenerTest; + friend TestInfo* internal::MakeAndRegisterTestInfo( + const char* test_case_name, + const char* name, + const char* type_param, + const char* value_param, + internal::TypeId fixture_class_id, + Test::SetUpTestCaseFunc set_up_tc, + Test::TearDownTestCaseFunc tear_down_tc, + internal::TestFactoryBase* factory); + + // Constructs a TestInfo object. The newly constructed instance assumes + // ownership of the factory object. + TestInfo(const std::string& test_case_name, + const std::string& name, + const char* a_type_param, // NULL if not a type-parameterized test + const char* a_value_param, // NULL if not a value-parameterized test + internal::TypeId fixture_class_id, + internal::TestFactoryBase* factory); + + // Increments the number of death tests encountered in this test so + // far. + int increment_death_test_count() { + return result_.increment_death_test_count(); + } + + // Creates the test object, runs it, records its result, and then + // deletes it. + void Run(); + + static void ClearTestResult(TestInfo* test_info) { + test_info->result_.Clear(); + } + + // These fields are immutable properties of the test. + const std::string test_case_name_; // Test case name + const std::string name_; // Test name + // Name of the parameter type, or NULL if this is not a typed or a + // type-parameterized test. + const internal::scoped_ptr type_param_; + // Text representation of the value parameter, or NULL if this is not a + // value-parameterized test. + const internal::scoped_ptr value_param_; + const internal::TypeId fixture_class_id_; // ID of the test fixture class + bool should_run_; // True iff this test should run + bool is_disabled_; // True iff this test is disabled + bool matches_filter_; // True if this test matches the + // user-specified filter. + internal::TestFactoryBase* const factory_; // The factory that creates + // the test object + + // This field is mutable and needs to be reset before running the + // test for the second time. + TestResult result_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestInfo); +}; + +// A test case, which consists of a vector of TestInfos. +// +// TestCase is not copyable. +class GTEST_API_ TestCase { + public: + // Creates a TestCase with the given name. + // + // TestCase does NOT have a default constructor. Always use this + // constructor to create a TestCase object. + // + // Arguments: + // + // name: name of the test case + // a_type_param: the name of the test's type parameter, or NULL if + // this is not a type-parameterized test. + // set_up_tc: pointer to the function that sets up the test case + // tear_down_tc: pointer to the function that tears down the test case + TestCase(const char* name, const char* a_type_param, + Test::SetUpTestCaseFunc set_up_tc, + Test::TearDownTestCaseFunc tear_down_tc); + + // Destructor of TestCase. + virtual ~TestCase(); + + // Gets the name of the TestCase. + const char* name() const { return name_.c_str(); } + + // Returns the name of the parameter type, or NULL if this is not a + // type-parameterized test case. + const char* type_param() const { + if (type_param_.get() != NULL) + return type_param_->c_str(); + return NULL; + } + + // Returns true if any test in this test case should run. + bool should_run() const { return should_run_; } + + // Gets the number of successful tests in this test case. + int successful_test_count() const; + + // Gets the number of failed tests in this test case. + int failed_test_count() const; + + // Gets the number of disabled tests that will be reported in the XML report. + int reportable_disabled_test_count() const; + + // Gets the number of disabled tests in this test case. + int disabled_test_count() const; + + // Gets the number of tests to be printed in the XML report. + int reportable_test_count() const; + + // Get the number of tests in this test case that should run. + int test_to_run_count() const; + + // Gets the number of all tests in this test case. + int total_test_count() const; + + // Returns true iff the test case passed. + bool Passed() const { return !Failed(); } + + // Returns true iff the test case failed. + bool Failed() const { return failed_test_count() > 0; } + + // Returns the elapsed time, in milliseconds. + TimeInMillis elapsed_time() const { return elapsed_time_; } + + // Returns the i-th test among all the tests. i can range from 0 to + // total_test_count() - 1. If i is not in that range, returns NULL. + const TestInfo* GetTestInfo(int i) const; + + // Returns the TestResult that holds test properties recorded during + // execution of SetUpTestCase and TearDownTestCase. + const TestResult& ad_hoc_test_result() const { return ad_hoc_test_result_; } + + private: + friend class Test; + friend class internal::UnitTestImpl; + + // Gets the (mutable) vector of TestInfos in this TestCase. + std::vector& test_info_list() { return test_info_list_; } + + // Gets the (immutable) vector of TestInfos in this TestCase. + const std::vector& test_info_list() const { + return test_info_list_; + } + + // Returns the i-th test among all the tests. i can range from 0 to + // total_test_count() - 1. If i is not in that range, returns NULL. + TestInfo* GetMutableTestInfo(int i); + + // Sets the should_run member. + void set_should_run(bool should) { should_run_ = should; } + + // Adds a TestInfo to this test case. Will delete the TestInfo upon + // destruction of the TestCase object. + void AddTestInfo(TestInfo * test_info); + + // Clears the results of all tests in this test case. + void ClearResult(); + + // Clears the results of all tests in the given test case. + static void ClearTestCaseResult(TestCase* test_case) { + test_case->ClearResult(); + } + + // Runs every test in this TestCase. + void Run(); + + // Runs SetUpTestCase() for this TestCase. This wrapper is needed + // for catching exceptions thrown from SetUpTestCase(). + void RunSetUpTestCase() { (*set_up_tc_)(); } + + // Runs TearDownTestCase() for this TestCase. This wrapper is + // needed for catching exceptions thrown from TearDownTestCase(). + void RunTearDownTestCase() { (*tear_down_tc_)(); } + + // Returns true iff test passed. + static bool TestPassed(const TestInfo* test_info) { + return test_info->should_run() && test_info->result()->Passed(); + } + + // Returns true iff test failed. + static bool TestFailed(const TestInfo* test_info) { + return test_info->should_run() && test_info->result()->Failed(); + } + + // Returns true iff the test is disabled and will be reported in the XML + // report. + static bool TestReportableDisabled(const TestInfo* test_info) { + return test_info->is_reportable() && test_info->is_disabled_; + } + + // Returns true iff test is disabled. + static bool TestDisabled(const TestInfo* test_info) { + return test_info->is_disabled_; + } + + // Returns true iff this test will appear in the XML report. + static bool TestReportable(const TestInfo* test_info) { + return test_info->is_reportable(); + } + + // Returns true if the given test should run. + static bool ShouldRunTest(const TestInfo* test_info) { + return test_info->should_run(); + } + + // Shuffles the tests in this test case. + void ShuffleTests(internal::Random* random); + + // Restores the test order to before the first shuffle. + void UnshuffleTests(); + + // Name of the test case. + std::string name_; + // Name of the parameter type, or NULL if this is not a typed or a + // type-parameterized test. + const internal::scoped_ptr type_param_; + // The vector of TestInfos in their original order. It owns the + // elements in the vector. + std::vector test_info_list_; + // Provides a level of indirection for the test list to allow easy + // shuffling and restoring the test order. The i-th element in this + // vector is the index of the i-th test in the shuffled test list. + std::vector test_indices_; + // Pointer to the function that sets up the test case. + Test::SetUpTestCaseFunc set_up_tc_; + // Pointer to the function that tears down the test case. + Test::TearDownTestCaseFunc tear_down_tc_; + // True iff any test in this test case should run. + bool should_run_; + // Elapsed time, in milliseconds. + TimeInMillis elapsed_time_; + // Holds test properties recorded during execution of SetUpTestCase and + // TearDownTestCase. + TestResult ad_hoc_test_result_; + + // We disallow copying TestCases. + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestCase); +}; + +// An Environment object is capable of setting up and tearing down an +// environment. The user should subclass this to define his own +// environment(s). +// +// An Environment object does the set-up and tear-down in virtual +// methods SetUp() and TearDown() instead of the constructor and the +// destructor, as: +// +// 1. You cannot safely throw from a destructor. This is a problem +// as in some cases Google Test is used where exceptions are enabled, and +// we may want to implement ASSERT_* using exceptions where they are +// available. +// 2. You cannot use ASSERT_* directly in a constructor or +// destructor. +class Environment { + public: + // The d'tor is virtual as we need to subclass Environment. + virtual ~Environment() {} + + // Override this to define how to set up the environment. + virtual void SetUp() {} + + // Override this to define how to tear down the environment. + virtual void TearDown() {} + private: + // If you see an error about overriding the following function or + // about it being private, you have mis-spelled SetUp() as Setup(). + struct Setup_should_be_spelled_SetUp {}; + virtual Setup_should_be_spelled_SetUp* Setup() { return NULL; } +}; + +// The interface for tracing execution of tests. The methods are organized in +// the order the corresponding events are fired. +class TestEventListener { + public: + virtual ~TestEventListener() {} + + // Fired before any test activity starts. + virtual void OnTestProgramStart(const UnitTest& unit_test) = 0; + + // Fired before each iteration of tests starts. There may be more than + // one iteration if GTEST_FLAG(repeat) is set. iteration is the iteration + // index, starting from 0. + virtual void OnTestIterationStart(const UnitTest& unit_test, + int iteration) = 0; + + // Fired before environment set-up for each iteration of tests starts. + virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test) = 0; + + // Fired after environment set-up for each iteration of tests ends. + virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test) = 0; + + // Fired before the test case starts. + virtual void OnTestCaseStart(const TestCase& test_case) = 0; + + // Fired before the test starts. + virtual void OnTestStart(const TestInfo& test_info) = 0; + + // Fired after a failed assertion or a SUCCEED() invocation. + virtual void OnTestPartResult(const TestPartResult& test_part_result) = 0; + + // Fired after the test ends. + virtual void OnTestEnd(const TestInfo& test_info) = 0; + + // Fired after the test case ends. + virtual void OnTestCaseEnd(const TestCase& test_case) = 0; + + // Fired before environment tear-down for each iteration of tests starts. + virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test) = 0; + + // Fired after environment tear-down for each iteration of tests ends. + virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test) = 0; + + // Fired after each iteration of tests finishes. + virtual void OnTestIterationEnd(const UnitTest& unit_test, + int iteration) = 0; + + // Fired after all test activities have ended. + virtual void OnTestProgramEnd(const UnitTest& unit_test) = 0; +}; + +// The convenience class for users who need to override just one or two +// methods and are not concerned that a possible change to a signature of +// the methods they override will not be caught during the build. For +// comments about each method please see the definition of TestEventListener +// above. +class EmptyTestEventListener : public TestEventListener { + public: + virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {} + virtual void OnTestIterationStart(const UnitTest& /*unit_test*/, + int /*iteration*/) {} + virtual void OnEnvironmentsSetUpStart(const UnitTest& /*unit_test*/) {} + virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {} + virtual void OnTestCaseStart(const TestCase& /*test_case*/) {} + virtual void OnTestStart(const TestInfo& /*test_info*/) {} + virtual void OnTestPartResult(const TestPartResult& /*test_part_result*/) {} + virtual void OnTestEnd(const TestInfo& /*test_info*/) {} + virtual void OnTestCaseEnd(const TestCase& /*test_case*/) {} + virtual void OnEnvironmentsTearDownStart(const UnitTest& /*unit_test*/) {} + virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {} + virtual void OnTestIterationEnd(const UnitTest& /*unit_test*/, + int /*iteration*/) {} + virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {} +}; + +// TestEventListeners lets users add listeners to track events in Google Test. +class GTEST_API_ TestEventListeners { + public: + TestEventListeners(); + ~TestEventListeners(); + + // Appends an event listener to the end of the list. Google Test assumes + // the ownership of the listener (i.e. it will delete the listener when + // the test program finishes). + void Append(TestEventListener* listener); + + // Removes the given event listener from the list and returns it. It then + // becomes the caller's responsibility to delete the listener. Returns + // NULL if the listener is not found in the list. + TestEventListener* Release(TestEventListener* listener); + + // Returns the standard listener responsible for the default console + // output. Can be removed from the listeners list to shut down default + // console output. Note that removing this object from the listener list + // with Release transfers its ownership to the caller and makes this + // function return NULL the next time. + TestEventListener* default_result_printer() const { + return default_result_printer_; + } + + // Returns the standard listener responsible for the default XML output + // controlled by the --gtest_output=xml flag. Can be removed from the + // listeners list by users who want to shut down the default XML output + // controlled by this flag and substitute it with custom one. Note that + // removing this object from the listener list with Release transfers its + // ownership to the caller and makes this function return NULL the next + // time. + TestEventListener* default_xml_generator() const { + return default_xml_generator_; + } + + private: + friend class TestCase; + friend class TestInfo; + friend class internal::DefaultGlobalTestPartResultReporter; + friend class internal::NoExecDeathTest; + friend class internal::TestEventListenersAccessor; + friend class internal::UnitTestImpl; + + // Returns repeater that broadcasts the TestEventListener events to all + // subscribers. + TestEventListener* repeater(); + + // Sets the default_result_printer attribute to the provided listener. + // The listener is also added to the listener list and previous + // default_result_printer is removed from it and deleted. The listener can + // also be NULL in which case it will not be added to the list. Does + // nothing if the previous and the current listener objects are the same. + void SetDefaultResultPrinter(TestEventListener* listener); + + // Sets the default_xml_generator attribute to the provided listener. The + // listener is also added to the listener list and previous + // default_xml_generator is removed from it and deleted. The listener can + // also be NULL in which case it will not be added to the list. Does + // nothing if the previous and the current listener objects are the same. + void SetDefaultXmlGenerator(TestEventListener* listener); + + // Controls whether events will be forwarded by the repeater to the + // listeners in the list. + bool EventForwardingEnabled() const; + void SuppressEventForwarding(); + + // The actual list of listeners. + internal::TestEventRepeater* repeater_; + // Listener responsible for the standard result output. + TestEventListener* default_result_printer_; + // Listener responsible for the creation of the XML output file. + TestEventListener* default_xml_generator_; + + // We disallow copying TestEventListeners. + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventListeners); +}; + +// A UnitTest consists of a vector of TestCases. +// +// This is a singleton class. The only instance of UnitTest is +// created when UnitTest::GetInstance() is first called. This +// instance is never deleted. +// +// UnitTest is not copyable. +// +// This class is thread-safe as long as the methods are called +// according to their specification. +class GTEST_API_ UnitTest { + public: + // Gets the singleton UnitTest object. The first time this method + // is called, a UnitTest object is constructed and returned. + // Consecutive calls will return the same object. + static UnitTest* GetInstance(); + + // Runs all tests in this UnitTest object and prints the result. + // Returns 0 if successful, or 1 otherwise. + // + // This method can only be called from the main thread. + // + // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + int Run() GTEST_MUST_USE_RESULT_; + + // Returns the working directory when the first TEST() or TEST_F() + // was executed. The UnitTest object owns the string. + const char* original_working_dir() const; + + // Returns the TestCase object for the test that's currently running, + // or NULL if no test is running. + const TestCase* current_test_case() const + GTEST_LOCK_EXCLUDED_(mutex_); + + // Returns the TestInfo object for the test that's currently running, + // or NULL if no test is running. + const TestInfo* current_test_info() const + GTEST_LOCK_EXCLUDED_(mutex_); + + // Returns the random seed used at the start of the current test run. + int random_seed() const; + +#if GTEST_HAS_PARAM_TEST + // Returns the ParameterizedTestCaseRegistry object used to keep track of + // value-parameterized tests and instantiate and register them. + // + // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + internal::ParameterizedTestCaseRegistry& parameterized_test_registry() + GTEST_LOCK_EXCLUDED_(mutex_); +#endif // GTEST_HAS_PARAM_TEST + + // Gets the number of successful test cases. + int successful_test_case_count() const; + + // Gets the number of failed test cases. + int failed_test_case_count() const; + + // Gets the number of all test cases. + int total_test_case_count() const; + + // Gets the number of all test cases that contain at least one test + // that should run. + int test_case_to_run_count() const; + + // Gets the number of successful tests. + int successful_test_count() const; + + // Gets the number of failed tests. + int failed_test_count() const; + + // Gets the number of disabled tests that will be reported in the XML report. + int reportable_disabled_test_count() const; + + // Gets the number of disabled tests. + int disabled_test_count() const; + + // Gets the number of tests to be printed in the XML report. + int reportable_test_count() const; + + // Gets the number of all tests. + int total_test_count() const; + + // Gets the number of tests that should run. + int test_to_run_count() const; + + // Gets the time of the test program start, in ms from the start of the + // UNIX epoch. + TimeInMillis start_timestamp() const; + + // Gets the elapsed time, in milliseconds. + TimeInMillis elapsed_time() const; + + // Returns true iff the unit test passed (i.e. all test cases passed). + bool Passed() const; + + // Returns true iff the unit test failed (i.e. some test case failed + // or something outside of all tests failed). + bool Failed() const; + + // Gets the i-th test case among all the test cases. i can range from 0 to + // total_test_case_count() - 1. If i is not in that range, returns NULL. + const TestCase* GetTestCase(int i) const; + + // Returns the TestResult containing information on test failures and + // properties logged outside of individual test cases. + const TestResult& ad_hoc_test_result() const; + + // Returns the list of event listeners that can be used to track events + // inside Google Test. + TestEventListeners& listeners(); + + private: + // Registers and returns a global test environment. When a test + // program is run, all global test environments will be set-up in + // the order they were registered. After all tests in the program + // have finished, all global test environments will be torn-down in + // the *reverse* order they were registered. + // + // The UnitTest object takes ownership of the given environment. + // + // This method can only be called from the main thread. + Environment* AddEnvironment(Environment* env); + + // Adds a TestPartResult to the current TestResult object. All + // Google Test assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) + // eventually call this to report their results. The user code + // should use the assertion macros instead of calling this directly. + void AddTestPartResult(TestPartResult::Type result_type, + const char* file_name, + int line_number, + const std::string& message, + const std::string& os_stack_trace) + GTEST_LOCK_EXCLUDED_(mutex_); + + // Adds a TestProperty to the current TestResult object when invoked from + // inside a test, to current TestCase's ad_hoc_test_result_ when invoked + // from SetUpTestCase or TearDownTestCase, or to the global property set + // when invoked elsewhere. If the result already contains a property with + // the same key, the value will be updated. + void RecordProperty(const std::string& key, const std::string& value); + + // Gets the i-th test case among all the test cases. i can range from 0 to + // total_test_case_count() - 1. If i is not in that range, returns NULL. + TestCase* GetMutableTestCase(int i); + + // Accessors for the implementation object. + internal::UnitTestImpl* impl() { return impl_; } + const internal::UnitTestImpl* impl() const { return impl_; } + + // These classes and funcions are friends as they need to access private + // members of UnitTest. + friend class Test; + friend class internal::AssertHelper; + friend class internal::ScopedTrace; + friend class internal::StreamingListenerTest; + friend class internal::UnitTestRecordPropertyTestHelper; + friend Environment* AddGlobalTestEnvironment(Environment* env); + friend internal::UnitTestImpl* internal::GetUnitTestImpl(); + friend void internal::ReportFailureInUnknownLocation( + TestPartResult::Type result_type, + const std::string& message); + + // Creates an empty UnitTest. + UnitTest(); + + // D'tor + virtual ~UnitTest(); + + // Pushes a trace defined by SCOPED_TRACE() on to the per-thread + // Google Test trace stack. + void PushGTestTrace(const internal::TraceInfo& trace) + GTEST_LOCK_EXCLUDED_(mutex_); + + // Pops a trace from the per-thread Google Test trace stack. + void PopGTestTrace() + GTEST_LOCK_EXCLUDED_(mutex_); + + // Protects mutable state in *impl_. This is mutable as some const + // methods need to lock it too. + mutable internal::Mutex mutex_; + + // Opaque implementation object. This field is never changed once + // the object is constructed. We don't mark it as const here, as + // doing so will cause a warning in the constructor of UnitTest. + // Mutable state in *impl_ is protected by mutex_. + internal::UnitTestImpl* impl_; + + // We disallow copying UnitTest. + GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTest); +}; + +// A convenient wrapper for adding an environment for the test +// program. +// +// You should call this before RUN_ALL_TESTS() is called, probably in +// main(). If you use gtest_main, you need to call this before main() +// starts for it to take effect. For example, you can define a global +// variable like this: +// +// testing::Environment* const foo_env = +// testing::AddGlobalTestEnvironment(new FooEnvironment); +// +// However, we strongly recommend you to write your own main() and +// call AddGlobalTestEnvironment() there, as relying on initialization +// of global variables makes the code harder to read and may cause +// problems when you register multiple environments from different +// translation units and the environments have dependencies among them +// (remember that the compiler doesn't guarantee the order in which +// global variables from different translation units are initialized). +inline Environment* AddGlobalTestEnvironment(Environment* env) { + return UnitTest::GetInstance()->AddEnvironment(env); +} + +// Initializes Google Test. This must be called before calling +// RUN_ALL_TESTS(). In particular, it parses a command line for the +// flags that Google Test recognizes. Whenever a Google Test flag is +// seen, it is removed from argv, and *argc is decremented. +// +// No value is returned. Instead, the Google Test flag variables are +// updated. +// +// Calling the function for the second time has no user-visible effect. +GTEST_API_ void InitGoogleTest(int* argc, char** argv); + +// This overloaded version can be used in Windows programs compiled in +// UNICODE mode. +GTEST_API_ void InitGoogleTest(int* argc, wchar_t** argv); + +namespace internal { + +// FormatForComparison::Format(value) formats a +// value of type ToPrint that is an operand of a comparison assertion +// (e.g. ASSERT_EQ). OtherOperand is the type of the other operand in +// the comparison, and is used to help determine the best way to +// format the value. In particular, when the value is a C string +// (char pointer) and the other operand is an STL string object, we +// want to format the C string as a string, since we know it is +// compared by value with the string object. If the value is a char +// pointer but the other operand is not an STL string object, we don't +// know whether the pointer is supposed to point to a NUL-terminated +// string, and thus want to print it as a pointer to be safe. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + +// The default case. +template +class FormatForComparison { + public: + static ::std::string Format(const ToPrint& value) { + return ::testing::PrintToString(value); + } +}; + +// Array. +template +class FormatForComparison { + public: + static ::std::string Format(const ToPrint* value) { + return FormatForComparison::Format(value); + } +}; + +// By default, print C string as pointers to be safe, as we don't know +// whether they actually point to a NUL-terminated string. + +#define GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(CharType) \ + template \ + class FormatForComparison { \ + public: \ + static ::std::string Format(CharType* value) { \ + return ::testing::PrintToString(static_cast(value)); \ + } \ + } + +GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(char); +GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const char); +GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(wchar_t); +GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_(const wchar_t); + +#undef GTEST_IMPL_FORMAT_C_STRING_AS_POINTER_ + +// If a C string is compared with an STL string object, we know it's meant +// to point to a NUL-terminated string, and thus can print it as a string. + +#define GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(CharType, OtherStringType) \ + template <> \ + class FormatForComparison { \ + public: \ + static ::std::string Format(CharType* value) { \ + return ::testing::PrintToString(value); \ + } \ + } + +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::std::string); +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::std::string); + +#if GTEST_HAS_GLOBAL_STRING +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(char, ::string); +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const char, ::string); +#endif + +#if GTEST_HAS_GLOBAL_WSTRING +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::wstring); +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::wstring); +#endif + +#if GTEST_HAS_STD_WSTRING +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(wchar_t, ::std::wstring); +GTEST_IMPL_FORMAT_C_STRING_AS_STRING_(const wchar_t, ::std::wstring); +#endif + +#undef GTEST_IMPL_FORMAT_C_STRING_AS_STRING_ + +// Formats a comparison assertion (e.g. ASSERT_EQ, EXPECT_LT, and etc) +// operand to be used in a failure message. The type (but not value) +// of the other operand may affect the format. This allows us to +// print a char* as a raw pointer when it is compared against another +// char* or void*, and print it as a C string when it is compared +// against an std::string object, for example. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +template +std::string FormatForComparisonFailureMessage( + const T1& value, const T2& /* other_operand */) { + return FormatForComparison::Format(value); +} + +// The helper function for {ASSERT|EXPECT}_EQ. +template +AssertionResult CmpHelperEQ(const char* expected_expression, + const char* actual_expression, + const T1& expected, + const T2& actual) { +#ifdef _MSC_VER +# pragma warning(push) // Saves the current warning state. +# pragma warning(disable:4389) // Temporarily disables warning on + // signed/unsigned mismatch. +#endif + + if (expected == actual) { + return AssertionSuccess(); + } + +#ifdef _MSC_VER +# pragma warning(pop) // Restores the warning state. +#endif + + return EqFailure(expected_expression, + actual_expression, + FormatForComparisonFailureMessage(expected, actual), + FormatForComparisonFailureMessage(actual, expected), + false); +} + +// With this overloaded version, we allow anonymous enums to be used +// in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous enums +// can be implicitly cast to BiggestInt. +GTEST_API_ AssertionResult CmpHelperEQ(const char* expected_expression, + const char* actual_expression, + BiggestInt expected, + BiggestInt actual); + +// The helper class for {ASSERT|EXPECT}_EQ. The template argument +// lhs_is_null_literal is true iff the first argument to ASSERT_EQ() +// is a null pointer literal. The following default implementation is +// for lhs_is_null_literal being false. +template +class EqHelper { + public: + // This templatized version is for the general case. + template + static AssertionResult Compare(const char* expected_expression, + const char* actual_expression, + const T1& expected, + const T2& actual) { + return CmpHelperEQ(expected_expression, actual_expression, expected, + actual); + } + + // With this overloaded version, we allow anonymous enums to be used + // in {ASSERT|EXPECT}_EQ when compiled with gcc 4, as anonymous + // enums can be implicitly cast to BiggestInt. + // + // Even though its body looks the same as the above version, we + // cannot merge the two, as it will make anonymous enums unhappy. + static AssertionResult Compare(const char* expected_expression, + const char* actual_expression, + BiggestInt expected, + BiggestInt actual) { + return CmpHelperEQ(expected_expression, actual_expression, expected, + actual); + } +}; + +// This specialization is used when the first argument to ASSERT_EQ() +// is a null pointer literal, like NULL, false, or 0. +template <> +class EqHelper { + public: + // We define two overloaded versions of Compare(). The first + // version will be picked when the second argument to ASSERT_EQ() is + // NOT a pointer, e.g. ASSERT_EQ(0, AnIntFunction()) or + // EXPECT_EQ(false, a_bool). + template + static AssertionResult Compare( + const char* expected_expression, + const char* actual_expression, + const T1& expected, + const T2& actual, + // The following line prevents this overload from being considered if T2 + // is not a pointer type. We need this because ASSERT_EQ(NULL, my_ptr) + // expands to Compare("", "", NULL, my_ptr), which requires a conversion + // to match the Secret* in the other overload, which would otherwise make + // this template match better. + typename EnableIf::value>::type* = 0) { + return CmpHelperEQ(expected_expression, actual_expression, expected, + actual); + } + + // This version will be picked when the second argument to ASSERT_EQ() is a + // pointer, e.g. ASSERT_EQ(NULL, a_pointer). + template + static AssertionResult Compare( + const char* expected_expression, + const char* actual_expression, + // We used to have a second template parameter instead of Secret*. That + // template parameter would deduce to 'long', making this a better match + // than the first overload even without the first overload's EnableIf. + // Unfortunately, gcc with -Wconversion-null warns when "passing NULL to + // non-pointer argument" (even a deduced integral argument), so the old + // implementation caused warnings in user code. + Secret* /* expected (NULL) */, + T* actual) { + // We already know that 'expected' is a null pointer. + return CmpHelperEQ(expected_expression, actual_expression, + static_cast(NULL), actual); + } +}; + +// A macro for implementing the helper functions needed to implement +// ASSERT_?? and EXPECT_??. It is here just to avoid copy-and-paste +// of similar code. +// +// For each templatized helper function, we also define an overloaded +// version for BiggestInt in order to reduce code bloat and allow +// anonymous enums to be used with {ASSERT|EXPECT}_?? when compiled +// with gcc 4. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +#define GTEST_IMPL_CMP_HELPER_(op_name, op)\ +template \ +AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \ + const T1& val1, const T2& val2) {\ + if (val1 op val2) {\ + return AssertionSuccess();\ + } else {\ + return AssertionFailure() \ + << "Expected: (" << expr1 << ") " #op " (" << expr2\ + << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\ + << " vs " << FormatForComparisonFailureMessage(val2, val1);\ + }\ +}\ +GTEST_API_ AssertionResult CmpHelper##op_name(\ + const char* expr1, const char* expr2, BiggestInt val1, BiggestInt val2) + +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. + +// Implements the helper function for {ASSERT|EXPECT}_NE +GTEST_IMPL_CMP_HELPER_(NE, !=); +// Implements the helper function for {ASSERT|EXPECT}_LE +GTEST_IMPL_CMP_HELPER_(LE, <=); +// Implements the helper function for {ASSERT|EXPECT}_LT +GTEST_IMPL_CMP_HELPER_(LT, <); +// Implements the helper function for {ASSERT|EXPECT}_GE +GTEST_IMPL_CMP_HELPER_(GE, >=); +// Implements the helper function for {ASSERT|EXPECT}_GT +GTEST_IMPL_CMP_HELPER_(GT, >); + +#undef GTEST_IMPL_CMP_HELPER_ + +// The helper function for {ASSERT|EXPECT}_STREQ. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression, + const char* actual_expression, + const char* expected, + const char* actual); + +// The helper function for {ASSERT|EXPECT}_STRCASEEQ. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression, + const char* actual_expression, + const char* expected, + const char* actual); + +// The helper function for {ASSERT|EXPECT}_STRNE. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression, + const char* s2_expression, + const char* s1, + const char* s2); + +// The helper function for {ASSERT|EXPECT}_STRCASENE. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult CmpHelperSTRCASENE(const char* s1_expression, + const char* s2_expression, + const char* s1, + const char* s2); + + +// Helper function for *_STREQ on wide strings. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult CmpHelperSTREQ(const char* expected_expression, + const char* actual_expression, + const wchar_t* expected, + const wchar_t* actual); + +// Helper function for *_STRNE on wide strings. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult CmpHelperSTRNE(const char* s1_expression, + const char* s2_expression, + const wchar_t* s1, + const wchar_t* s2); + +} // namespace internal + +// IsSubstring() and IsNotSubstring() are intended to be used as the +// first argument to {EXPECT,ASSERT}_PRED_FORMAT2(), not by +// themselves. They check whether needle is a substring of haystack +// (NULL is considered a substring of itself only), and return an +// appropriate error message when they fail. +// +// The {needle,haystack}_expr arguments are the stringified +// expressions that generated the two real arguments. +GTEST_API_ AssertionResult IsSubstring( + const char* needle_expr, const char* haystack_expr, + const char* needle, const char* haystack); +GTEST_API_ AssertionResult IsSubstring( + const char* needle_expr, const char* haystack_expr, + const wchar_t* needle, const wchar_t* haystack); +GTEST_API_ AssertionResult IsNotSubstring( + const char* needle_expr, const char* haystack_expr, + const char* needle, const char* haystack); +GTEST_API_ AssertionResult IsNotSubstring( + const char* needle_expr, const char* haystack_expr, + const wchar_t* needle, const wchar_t* haystack); +GTEST_API_ AssertionResult IsSubstring( + const char* needle_expr, const char* haystack_expr, + const ::std::string& needle, const ::std::string& haystack); +GTEST_API_ AssertionResult IsNotSubstring( + const char* needle_expr, const char* haystack_expr, + const ::std::string& needle, const ::std::string& haystack); + +#if GTEST_HAS_STD_WSTRING +GTEST_API_ AssertionResult IsSubstring( + const char* needle_expr, const char* haystack_expr, + const ::std::wstring& needle, const ::std::wstring& haystack); +GTEST_API_ AssertionResult IsNotSubstring( + const char* needle_expr, const char* haystack_expr, + const ::std::wstring& needle, const ::std::wstring& haystack); +#endif // GTEST_HAS_STD_WSTRING + +namespace internal { + +// Helper template function for comparing floating-points. +// +// Template parameter: +// +// RawType: the raw floating-point type (either float or double) +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +template +AssertionResult CmpHelperFloatingPointEQ(const char* expected_expression, + const char* actual_expression, + RawType expected, + RawType actual) { + const FloatingPoint lhs(expected), rhs(actual); + + if (lhs.AlmostEquals(rhs)) { + return AssertionSuccess(); + } + + ::std::stringstream expected_ss; + expected_ss << std::setprecision(std::numeric_limits::digits10 + 2) + << expected; + + ::std::stringstream actual_ss; + actual_ss << std::setprecision(std::numeric_limits::digits10 + 2) + << actual; + + return EqFailure(expected_expression, + actual_expression, + StringStreamToString(&expected_ss), + StringStreamToString(&actual_ss), + false); +} + +// Helper function for implementing ASSERT_NEAR. +// +// INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM. +GTEST_API_ AssertionResult DoubleNearPredFormat(const char* expr1, + const char* expr2, + const char* abs_error_expr, + double val1, + double val2, + double abs_error); + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// A class that enables one to stream messages to assertion macros +class GTEST_API_ AssertHelper { + public: + // Constructor. + AssertHelper(TestPartResult::Type type, + const char* file, + int line, + const char* message); + ~AssertHelper(); + + // Message assignment is a semantic trick to enable assertion + // streaming; see the GTEST_MESSAGE_ macro below. + void operator=(const Message& message) const; + + private: + // We put our data in a struct so that the size of the AssertHelper class can + // be as small as possible. This is important because gcc is incapable of + // re-using stack space even for temporary variables, so every EXPECT_EQ + // reserves stack space for another AssertHelper. + struct AssertHelperData { + AssertHelperData(TestPartResult::Type t, + const char* srcfile, + int line_num, + const char* msg) + : type(t), file(srcfile), line(line_num), message(msg) { } + + TestPartResult::Type const type; + const char* const file; + int const line; + std::string const message; + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelperData); + }; + + AssertHelperData* const data_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(AssertHelper); +}; + +} // namespace internal + +#if GTEST_HAS_PARAM_TEST +// The pure interface class that all value-parameterized tests inherit from. +// A value-parameterized class must inherit from both ::testing::Test and +// ::testing::WithParamInterface. In most cases that just means inheriting +// from ::testing::TestWithParam, but more complicated test hierarchies +// may need to inherit from Test and WithParamInterface at different levels. +// +// This interface has support for accessing the test parameter value via +// the GetParam() method. +// +// Use it with one of the parameter generator defining functions, like Range(), +// Values(), ValuesIn(), Bool(), and Combine(). +// +// class FooTest : public ::testing::TestWithParam { +// protected: +// FooTest() { +// // Can use GetParam() here. +// } +// virtual ~FooTest() { +// // Can use GetParam() here. +// } +// virtual void SetUp() { +// // Can use GetParam() here. +// } +// virtual void TearDown { +// // Can use GetParam() here. +// } +// }; +// TEST_P(FooTest, DoesBar) { +// // Can use GetParam() method here. +// Foo foo; +// ASSERT_TRUE(foo.DoesBar(GetParam())); +// } +// INSTANTIATE_TEST_CASE_P(OneToTenRange, FooTest, ::testing::Range(1, 10)); + +template +class WithParamInterface { + public: + typedef T ParamType; + virtual ~WithParamInterface() {} + + // The current parameter value. Is also available in the test fixture's + // constructor. This member function is non-static, even though it only + // references static data, to reduce the opportunity for incorrect uses + // like writing 'WithParamInterface::GetParam()' for a test that + // uses a fixture whose parameter type is int. + const ParamType& GetParam() const { + GTEST_CHECK_(parameter_ != NULL) + << "GetParam() can only be called inside a value-parameterized test " + << "-- did you intend to write TEST_P instead of TEST_F?"; + return *parameter_; + } + + private: + // Sets parameter value. The caller is responsible for making sure the value + // remains alive and unchanged throughout the current test. + static void SetParam(const ParamType* parameter) { + parameter_ = parameter; + } + + // Static value used for accessing parameter during a test lifetime. + static const ParamType* parameter_; + + // TestClass must be a subclass of WithParamInterface and Test. + template friend class internal::ParameterizedTestFactory; +}; + +template +const T* WithParamInterface::parameter_ = NULL; + +// Most value-parameterized classes can ignore the existence of +// WithParamInterface, and can just inherit from ::testing::TestWithParam. + +template +class TestWithParam : public Test, public WithParamInterface { +}; + +#endif // GTEST_HAS_PARAM_TEST + +// Macros for indicating success/failure in test code. + +// ADD_FAILURE unconditionally adds a failure to the current test. +// SUCCEED generates a success - it doesn't automatically make the +// current test successful, as a test is only successful when it has +// no failure. +// +// EXPECT_* verifies that a certain condition is satisfied. If not, +// it behaves like ADD_FAILURE. In particular: +// +// EXPECT_TRUE verifies that a Boolean condition is true. +// EXPECT_FALSE verifies that a Boolean condition is false. +// +// FAIL and ASSERT_* are similar to ADD_FAILURE and EXPECT_*, except +// that they will also abort the current function on failure. People +// usually want the fail-fast behavior of FAIL and ASSERT_*, but those +// writing data-driven tests often find themselves using ADD_FAILURE +// and EXPECT_* more. + +// Generates a nonfatal failure with a generic message. +#define ADD_FAILURE() GTEST_NONFATAL_FAILURE_("Failed") + +// Generates a nonfatal failure at the given source file location with +// a generic message. +#define ADD_FAILURE_AT(file, line) \ + GTEST_MESSAGE_AT_(file, line, "Failed", \ + ::testing::TestPartResult::kNonFatalFailure) + +// Generates a fatal failure with a generic message. +#define GTEST_FAIL() GTEST_FATAL_FAILURE_("Failed") + +// Define this macro to 1 to omit the definition of FAIL(), which is a +// generic name and clashes with some other libraries. +#if !GTEST_DONT_DEFINE_FAIL +# define FAIL() GTEST_FAIL() +#endif + +// Generates a success with a generic message. +#define GTEST_SUCCEED() GTEST_SUCCESS_("Succeeded") + +// Define this macro to 1 to omit the definition of SUCCEED(), which +// is a generic name and clashes with some other libraries. +#if !GTEST_DONT_DEFINE_SUCCEED +# define SUCCEED() GTEST_SUCCEED() +#endif + +// Macros for testing exceptions. +// +// * {ASSERT|EXPECT}_THROW(statement, expected_exception): +// Tests that the statement throws the expected exception. +// * {ASSERT|EXPECT}_NO_THROW(statement): +// Tests that the statement doesn't throw any exception. +// * {ASSERT|EXPECT}_ANY_THROW(statement): +// Tests that the statement throws an exception. + +#define EXPECT_THROW(statement, expected_exception) \ + GTEST_TEST_THROW_(statement, expected_exception, GTEST_NONFATAL_FAILURE_) +#define EXPECT_NO_THROW(statement) \ + GTEST_TEST_NO_THROW_(statement, GTEST_NONFATAL_FAILURE_) +#define EXPECT_ANY_THROW(statement) \ + GTEST_TEST_ANY_THROW_(statement, GTEST_NONFATAL_FAILURE_) +#define ASSERT_THROW(statement, expected_exception) \ + GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_) +#define ASSERT_NO_THROW(statement) \ + GTEST_TEST_NO_THROW_(statement, GTEST_FATAL_FAILURE_) +#define ASSERT_ANY_THROW(statement) \ + GTEST_TEST_ANY_THROW_(statement, GTEST_FATAL_FAILURE_) + +// Boolean assertions. Condition can be either a Boolean expression or an +// AssertionResult. For more information on how to use AssertionResult with +// these macros see comments on that class. +#define EXPECT_TRUE(condition) \ + GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ + GTEST_NONFATAL_FAILURE_) +#define EXPECT_FALSE(condition) \ + GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ + GTEST_NONFATAL_FAILURE_) +#define ASSERT_TRUE(condition) \ + GTEST_TEST_BOOLEAN_(condition, #condition, false, true, \ + GTEST_FATAL_FAILURE_) +#define ASSERT_FALSE(condition) \ + GTEST_TEST_BOOLEAN_(!(condition), #condition, true, false, \ + GTEST_FATAL_FAILURE_) + +// Includes the auto-generated header that implements a family of +// generic predicate assertion macros. +#include "gtest/gtest_pred_impl.h" + +// Macros for testing equalities and inequalities. +// +// * {ASSERT|EXPECT}_EQ(expected, actual): Tests that expected == actual +// * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2 +// * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2 +// * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2 +// * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2 +// * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2 +// +// When they are not, Google Test prints both the tested expressions and +// their actual values. The values must be compatible built-in types, +// or you will get a compiler error. By "compatible" we mean that the +// values can be compared by the respective operator. +// +// Note: +// +// 1. It is possible to make a user-defined type work with +// {ASSERT|EXPECT}_??(), but that requires overloading the +// comparison operators and is thus discouraged by the Google C++ +// Usage Guide. Therefore, you are advised to use the +// {ASSERT|EXPECT}_TRUE() macro to assert that two objects are +// equal. +// +// 2. The {ASSERT|EXPECT}_??() macros do pointer comparisons on +// pointers (in particular, C strings). Therefore, if you use it +// with two C strings, you are testing how their locations in memory +// are related, not how their content is related. To compare two C +// strings by content, use {ASSERT|EXPECT}_STR*(). +// +// 3. {ASSERT|EXPECT}_EQ(expected, actual) is preferred to +// {ASSERT|EXPECT}_TRUE(expected == actual), as the former tells you +// what the actual value is when it fails, and similarly for the +// other comparisons. +// +// 4. Do not depend on the order in which {ASSERT|EXPECT}_??() +// evaluate their arguments, which is undefined. +// +// 5. These macros evaluate their arguments exactly once. +// +// Examples: +// +// EXPECT_NE(5, Foo()); +// EXPECT_EQ(NULL, a_pointer); +// ASSERT_LT(i, array_size); +// ASSERT_GT(records.size(), 0) << "There is no record left."; + +#define EXPECT_EQ(expected, actual) \ + EXPECT_PRED_FORMAT2(::testing::internal:: \ + EqHelper::Compare, \ + expected, actual) +#define EXPECT_NE(expected, actual) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperNE, expected, actual) +#define EXPECT_LE(val1, val2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2) +#define EXPECT_LT(val1, val2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2) +#define EXPECT_GE(val1, val2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2) +#define EXPECT_GT(val1, val2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2) + +#define GTEST_ASSERT_EQ(expected, actual) \ + ASSERT_PRED_FORMAT2(::testing::internal:: \ + EqHelper::Compare, \ + expected, actual) +#define GTEST_ASSERT_NE(val1, val2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2) +#define GTEST_ASSERT_LE(val1, val2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLE, val1, val2) +#define GTEST_ASSERT_LT(val1, val2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperLT, val1, val2) +#define GTEST_ASSERT_GE(val1, val2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGE, val1, val2) +#define GTEST_ASSERT_GT(val1, val2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperGT, val1, val2) + +// Define macro GTEST_DONT_DEFINE_ASSERT_XY to 1 to omit the definition of +// ASSERT_XY(), which clashes with some users' own code. + +#if !GTEST_DONT_DEFINE_ASSERT_EQ +# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2) +#endif + +#if !GTEST_DONT_DEFINE_ASSERT_NE +# define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2) +#endif + +#if !GTEST_DONT_DEFINE_ASSERT_LE +# define ASSERT_LE(val1, val2) GTEST_ASSERT_LE(val1, val2) +#endif + +#if !GTEST_DONT_DEFINE_ASSERT_LT +# define ASSERT_LT(val1, val2) GTEST_ASSERT_LT(val1, val2) +#endif + +#if !GTEST_DONT_DEFINE_ASSERT_GE +# define ASSERT_GE(val1, val2) GTEST_ASSERT_GE(val1, val2) +#endif + +#if !GTEST_DONT_DEFINE_ASSERT_GT +# define ASSERT_GT(val1, val2) GTEST_ASSERT_GT(val1, val2) +#endif + +// C-string Comparisons. All tests treat NULL and any non-NULL string +// as different. Two NULLs are equal. +// +// * {ASSERT|EXPECT}_STREQ(s1, s2): Tests that s1 == s2 +// * {ASSERT|EXPECT}_STRNE(s1, s2): Tests that s1 != s2 +// * {ASSERT|EXPECT}_STRCASEEQ(s1, s2): Tests that s1 == s2, ignoring case +// * {ASSERT|EXPECT}_STRCASENE(s1, s2): Tests that s1 != s2, ignoring case +// +// For wide or narrow string objects, you can use the +// {ASSERT|EXPECT}_??() macros. +// +// Don't depend on the order in which the arguments are evaluated, +// which is undefined. +// +// These macros evaluate their arguments exactly once. + +#define EXPECT_STREQ(expected, actual) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, expected, actual) +#define EXPECT_STRNE(s1, s2) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2) +#define EXPECT_STRCASEEQ(expected, actual) \ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, expected, actual) +#define EXPECT_STRCASENE(s1, s2)\ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2) + +#define ASSERT_STREQ(expected, actual) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTREQ, expected, actual) +#define ASSERT_STRNE(s1, s2) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRNE, s1, s2) +#define ASSERT_STRCASEEQ(expected, actual) \ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASEEQ, expected, actual) +#define ASSERT_STRCASENE(s1, s2)\ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperSTRCASENE, s1, s2) + +// Macros for comparing floating-point numbers. +// +// * {ASSERT|EXPECT}_FLOAT_EQ(expected, actual): +// Tests that two float values are almost equal. +// * {ASSERT|EXPECT}_DOUBLE_EQ(expected, actual): +// Tests that two double values are almost equal. +// * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error): +// Tests that v1 and v2 are within the given distance to each other. +// +// Google Test uses ULP-based comparison to automatically pick a default +// error bound that is appropriate for the operands. See the +// FloatingPoint template class in gtest-internal.h if you are +// interested in the implementation details. + +#define EXPECT_FLOAT_EQ(expected, actual)\ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ, \ + expected, actual) + +#define EXPECT_DOUBLE_EQ(expected, actual)\ + EXPECT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ, \ + expected, actual) + +#define ASSERT_FLOAT_EQ(expected, actual)\ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ, \ + expected, actual) + +#define ASSERT_DOUBLE_EQ(expected, actual)\ + ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperFloatingPointEQ, \ + expected, actual) + +#define EXPECT_NEAR(val1, val2, abs_error)\ + EXPECT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \ + val1, val2, abs_error) + +#define ASSERT_NEAR(val1, val2, abs_error)\ + ASSERT_PRED_FORMAT3(::testing::internal::DoubleNearPredFormat, \ + val1, val2, abs_error) + +// These predicate format functions work on floating-point values, and +// can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g. +// +// EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0); + +// Asserts that val1 is less than, or almost equal to, val2. Fails +// otherwise. In particular, it fails if either val1 or val2 is NaN. +GTEST_API_ AssertionResult FloatLE(const char* expr1, const char* expr2, + float val1, float val2); +GTEST_API_ AssertionResult DoubleLE(const char* expr1, const char* expr2, + double val1, double val2); + + +#if GTEST_OS_WINDOWS + +// Macros that test for HRESULT failure and success, these are only useful +// on Windows, and rely on Windows SDK macros and APIs to compile. +// +// * {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED}(expr) +// +// When expr unexpectedly fails or succeeds, Google Test prints the +// expected result and the actual result with both a human-readable +// string representation of the error, if available, as well as the +// hex result code. +# define EXPECT_HRESULT_SUCCEEDED(expr) \ + EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr)) + +# define ASSERT_HRESULT_SUCCEEDED(expr) \ + ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTSuccess, (expr)) + +# define EXPECT_HRESULT_FAILED(expr) \ + EXPECT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr)) + +# define ASSERT_HRESULT_FAILED(expr) \ + ASSERT_PRED_FORMAT1(::testing::internal::IsHRESULTFailure, (expr)) + +#endif // GTEST_OS_WINDOWS + +// Macros that execute statement and check that it doesn't generate new fatal +// failures in the current thread. +// +// * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement); +// +// Examples: +// +// EXPECT_NO_FATAL_FAILURE(Process()); +// ASSERT_NO_FATAL_FAILURE(Process()) << "Process() failed"; +// +#define ASSERT_NO_FATAL_FAILURE(statement) \ + GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_FATAL_FAILURE_) +#define EXPECT_NO_FATAL_FAILURE(statement) \ + GTEST_TEST_NO_FATAL_FAILURE_(statement, GTEST_NONFATAL_FAILURE_) + +// Causes a trace (including the source file path, the current line +// number, and the given message) to be included in every test failure +// message generated by code in the current scope. The effect is +// undone when the control leaves the current scope. +// +// The message argument can be anything streamable to std::ostream. +// +// In the implementation, we include the current line number as part +// of the dummy variable name, thus allowing multiple SCOPED_TRACE()s +// to appear in the same block - as long as they are on different +// lines. +#define SCOPED_TRACE(message) \ + ::testing::internal::ScopedTrace GTEST_CONCAT_TOKEN_(gtest_trace_, __LINE__)(\ + __FILE__, __LINE__, ::testing::Message() << (message)) + +// Compile-time assertion for type equality. +// StaticAssertTypeEq() compiles iff type1 and type2 are +// the same type. The value it returns is not interesting. +// +// Instead of making StaticAssertTypeEq a class template, we make it a +// function template that invokes a helper class template. This +// prevents a user from misusing StaticAssertTypeEq by +// defining objects of that type. +// +// CAVEAT: +// +// When used inside a method of a class template, +// StaticAssertTypeEq() is effective ONLY IF the method is +// instantiated. For example, given: +// +// template class Foo { +// public: +// void Bar() { testing::StaticAssertTypeEq(); } +// }; +// +// the code: +// +// void Test1() { Foo foo; } +// +// will NOT generate a compiler error, as Foo::Bar() is never +// actually instantiated. Instead, you need: +// +// void Test2() { Foo foo; foo.Bar(); } +// +// to cause a compiler error. +template +bool StaticAssertTypeEq() { + (void)internal::StaticAssertTypeEqHelper(); + return true; +} + +// Defines a test. +// +// The first parameter is the name of the test case, and the second +// parameter is the name of the test within the test case. +// +// The convention is to end the test case name with "Test". For +// example, a test case for the Foo class can be named FooTest. +// +// The user should put his test code between braces after using this +// macro. Example: +// +// TEST(FooTest, InitializesCorrectly) { +// Foo foo; +// EXPECT_TRUE(foo.StatusIsOK()); +// } + +// Note that we call GetTestTypeId() instead of GetTypeId< +// ::testing::Test>() here to get the type ID of testing::Test. This +// is to work around a suspected linker bug when using Google Test as +// a framework on Mac OS X. The bug causes GetTypeId< +// ::testing::Test>() to return different values depending on whether +// the call is from the Google Test framework itself or from user test +// code. GetTestTypeId() is guaranteed to always return the same +// value, as it always calls GetTypeId<>() from the Google Test +// framework. +#define GTEST_TEST(test_case_name, test_name)\ + GTEST_TEST_(test_case_name, test_name, \ + ::testing::Test, ::testing::internal::GetTestTypeId()) + +// Define this macro to 1 to omit the definition of TEST(), which +// is a generic name and clashes with some other libraries. +#if !GTEST_DONT_DEFINE_TEST +# define TEST(test_case_name, test_name) GTEST_TEST(test_case_name, test_name) +#endif + +// Defines a test that uses a test fixture. +// +// The first parameter is the name of the test fixture class, which +// also doubles as the test case name. The second parameter is the +// name of the test within the test case. +// +// A test fixture class must be declared earlier. The user should put +// his test code between braces after using this macro. Example: +// +// class FooTest : public testing::Test { +// protected: +// virtual void SetUp() { b_.AddElement(3); } +// +// Foo a_; +// Foo b_; +// }; +// +// TEST_F(FooTest, InitializesCorrectly) { +// EXPECT_TRUE(a_.StatusIsOK()); +// } +// +// TEST_F(FooTest, ReturnsElementCountCorrectly) { +// EXPECT_EQ(0, a_.size()); +// EXPECT_EQ(1, b_.size()); +// } + +#define TEST_F(test_fixture, test_name)\ + GTEST_TEST_(test_fixture, test_name, test_fixture, \ + ::testing::internal::GetTypeId()) + +} // namespace testing + +// Use this function in main() to run all tests. It returns 0 if all +// tests are successful, or 1 otherwise. +// +// RUN_ALL_TESTS() should be invoked after the command line has been +// parsed by InitGoogleTest(). +// +// This function was formerly a macro; thus, it is in the global +// namespace and has an all-caps name. +int RUN_ALL_TESTS() GTEST_MUST_USE_RESULT_; + +inline int RUN_ALL_TESTS() { + return ::testing::UnitTest::GetInstance()->Run(); +} + +#endif // GTEST_INCLUDE_GTEST_GTEST_H_ diff --git a/test/fmw/gtest/include/gtest/gtest_pred_impl.h b/test/fmw/gtest/include/gtest/gtest_pred_impl.h new file mode 100644 index 00000000000..30ae712f50e --- /dev/null +++ b/test/fmw/gtest/include/gtest/gtest_pred_impl.h @@ -0,0 +1,358 @@ +// Copyright 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// This file is AUTOMATICALLY GENERATED on 10/31/2011 by command +// 'gen_gtest_pred_impl.py 5'. DO NOT EDIT BY HAND! +// +// Implements a family of generic predicate assertion macros. + +#ifndef GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ +#define GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ + +// Makes sure this header is not included before gtest.h. +#ifndef GTEST_INCLUDE_GTEST_GTEST_H_ +# error Do not include gtest_pred_impl.h directly. Include gtest.h instead. +#endif // GTEST_INCLUDE_GTEST_GTEST_H_ + +// This header implements a family of generic predicate assertion +// macros: +// +// ASSERT_PRED_FORMAT1(pred_format, v1) +// ASSERT_PRED_FORMAT2(pred_format, v1, v2) +// ... +// +// where pred_format is a function or functor that takes n (in the +// case of ASSERT_PRED_FORMATn) values and their source expression +// text, and returns a testing::AssertionResult. See the definition +// of ASSERT_EQ in gtest.h for an example. +// +// If you don't care about formatting, you can use the more +// restrictive version: +// +// ASSERT_PRED1(pred, v1) +// ASSERT_PRED2(pred, v1, v2) +// ... +// +// where pred is an n-ary function or functor that returns bool, +// and the values v1, v2, ..., must support the << operator for +// streaming to std::ostream. +// +// We also define the EXPECT_* variations. +// +// For now we only support predicates whose arity is at most 5. +// Please email googletestframework@googlegroups.com if you need +// support for higher arities. + +// GTEST_ASSERT_ is the basic statement to which all of the assertions +// in this file reduce. Don't use this in your code. + +#define GTEST_ASSERT_(expression, on_failure) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (const ::testing::AssertionResult gtest_ar = (expression)) \ + ; \ + else \ + on_failure(gtest_ar.failure_message()) + + +// Helper function for implementing {EXPECT|ASSERT}_PRED1. Don't use +// this in your code. +template +AssertionResult AssertPred1Helper(const char* pred_text, + const char* e1, + Pred pred, + const T1& v1) { + if (pred(v1)) return AssertionSuccess(); + + return AssertionFailure() << pred_text << "(" + << e1 << ") evaluates to false, where" + << "\n" << e1 << " evaluates to " << v1; +} + +// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT1. +// Don't use this in your code. +#define GTEST_PRED_FORMAT1_(pred_format, v1, on_failure)\ + GTEST_ASSERT_(pred_format(#v1, v1), \ + on_failure) + +// Internal macro for implementing {EXPECT|ASSERT}_PRED1. Don't use +// this in your code. +#define GTEST_PRED1_(pred, v1, on_failure)\ + GTEST_ASSERT_(::testing::AssertPred1Helper(#pred, \ + #v1, \ + pred, \ + v1), on_failure) + +// Unary predicate assertion macros. +#define EXPECT_PRED_FORMAT1(pred_format, v1) \ + GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_NONFATAL_FAILURE_) +#define EXPECT_PRED1(pred, v1) \ + GTEST_PRED1_(pred, v1, GTEST_NONFATAL_FAILURE_) +#define ASSERT_PRED_FORMAT1(pred_format, v1) \ + GTEST_PRED_FORMAT1_(pred_format, v1, GTEST_FATAL_FAILURE_) +#define ASSERT_PRED1(pred, v1) \ + GTEST_PRED1_(pred, v1, GTEST_FATAL_FAILURE_) + + + +// Helper function for implementing {EXPECT|ASSERT}_PRED2. Don't use +// this in your code. +template +AssertionResult AssertPred2Helper(const char* pred_text, + const char* e1, + const char* e2, + Pred pred, + const T1& v1, + const T2& v2) { + if (pred(v1, v2)) return AssertionSuccess(); + + return AssertionFailure() << pred_text << "(" + << e1 << ", " + << e2 << ") evaluates to false, where" + << "\n" << e1 << " evaluates to " << v1 + << "\n" << e2 << " evaluates to " << v2; +} + +// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT2. +// Don't use this in your code. +#define GTEST_PRED_FORMAT2_(pred_format, v1, v2, on_failure)\ + GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), \ + on_failure) + +// Internal macro for implementing {EXPECT|ASSERT}_PRED2. Don't use +// this in your code. +#define GTEST_PRED2_(pred, v1, v2, on_failure)\ + GTEST_ASSERT_(::testing::AssertPred2Helper(#pred, \ + #v1, \ + #v2, \ + pred, \ + v1, \ + v2), on_failure) + +// Binary predicate assertion macros. +#define EXPECT_PRED_FORMAT2(pred_format, v1, v2) \ + GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_) +#define EXPECT_PRED2(pred, v1, v2) \ + GTEST_PRED2_(pred, v1, v2, GTEST_NONFATAL_FAILURE_) +#define ASSERT_PRED_FORMAT2(pred_format, v1, v2) \ + GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_) +#define ASSERT_PRED2(pred, v1, v2) \ + GTEST_PRED2_(pred, v1, v2, GTEST_FATAL_FAILURE_) + + + +// Helper function for implementing {EXPECT|ASSERT}_PRED3. Don't use +// this in your code. +template +AssertionResult AssertPred3Helper(const char* pred_text, + const char* e1, + const char* e2, + const char* e3, + Pred pred, + const T1& v1, + const T2& v2, + const T3& v3) { + if (pred(v1, v2, v3)) return AssertionSuccess(); + + return AssertionFailure() << pred_text << "(" + << e1 << ", " + << e2 << ", " + << e3 << ") evaluates to false, where" + << "\n" << e1 << " evaluates to " << v1 + << "\n" << e2 << " evaluates to " << v2 + << "\n" << e3 << " evaluates to " << v3; +} + +// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT3. +// Don't use this in your code. +#define GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, on_failure)\ + GTEST_ASSERT_(pred_format(#v1, #v2, #v3, v1, v2, v3), \ + on_failure) + +// Internal macro for implementing {EXPECT|ASSERT}_PRED3. Don't use +// this in your code. +#define GTEST_PRED3_(pred, v1, v2, v3, on_failure)\ + GTEST_ASSERT_(::testing::AssertPred3Helper(#pred, \ + #v1, \ + #v2, \ + #v3, \ + pred, \ + v1, \ + v2, \ + v3), on_failure) + +// Ternary predicate assertion macros. +#define EXPECT_PRED_FORMAT3(pred_format, v1, v2, v3) \ + GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_NONFATAL_FAILURE_) +#define EXPECT_PRED3(pred, v1, v2, v3) \ + GTEST_PRED3_(pred, v1, v2, v3, GTEST_NONFATAL_FAILURE_) +#define ASSERT_PRED_FORMAT3(pred_format, v1, v2, v3) \ + GTEST_PRED_FORMAT3_(pred_format, v1, v2, v3, GTEST_FATAL_FAILURE_) +#define ASSERT_PRED3(pred, v1, v2, v3) \ + GTEST_PRED3_(pred, v1, v2, v3, GTEST_FATAL_FAILURE_) + + + +// Helper function for implementing {EXPECT|ASSERT}_PRED4. Don't use +// this in your code. +template +AssertionResult AssertPred4Helper(const char* pred_text, + const char* e1, + const char* e2, + const char* e3, + const char* e4, + Pred pred, + const T1& v1, + const T2& v2, + const T3& v3, + const T4& v4) { + if (pred(v1, v2, v3, v4)) return AssertionSuccess(); + + return AssertionFailure() << pred_text << "(" + << e1 << ", " + << e2 << ", " + << e3 << ", " + << e4 << ") evaluates to false, where" + << "\n" << e1 << " evaluates to " << v1 + << "\n" << e2 << " evaluates to " << v2 + << "\n" << e3 << " evaluates to " << v3 + << "\n" << e4 << " evaluates to " << v4; +} + +// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT4. +// Don't use this in your code. +#define GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, on_failure)\ + GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, v1, v2, v3, v4), \ + on_failure) + +// Internal macro for implementing {EXPECT|ASSERT}_PRED4. Don't use +// this in your code. +#define GTEST_PRED4_(pred, v1, v2, v3, v4, on_failure)\ + GTEST_ASSERT_(::testing::AssertPred4Helper(#pred, \ + #v1, \ + #v2, \ + #v3, \ + #v4, \ + pred, \ + v1, \ + v2, \ + v3, \ + v4), on_failure) + +// 4-ary predicate assertion macros. +#define EXPECT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \ + GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_) +#define EXPECT_PRED4(pred, v1, v2, v3, v4) \ + GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_NONFATAL_FAILURE_) +#define ASSERT_PRED_FORMAT4(pred_format, v1, v2, v3, v4) \ + GTEST_PRED_FORMAT4_(pred_format, v1, v2, v3, v4, GTEST_FATAL_FAILURE_) +#define ASSERT_PRED4(pred, v1, v2, v3, v4) \ + GTEST_PRED4_(pred, v1, v2, v3, v4, GTEST_FATAL_FAILURE_) + + + +// Helper function for implementing {EXPECT|ASSERT}_PRED5. Don't use +// this in your code. +template +AssertionResult AssertPred5Helper(const char* pred_text, + const char* e1, + const char* e2, + const char* e3, + const char* e4, + const char* e5, + Pred pred, + const T1& v1, + const T2& v2, + const T3& v3, + const T4& v4, + const T5& v5) { + if (pred(v1, v2, v3, v4, v5)) return AssertionSuccess(); + + return AssertionFailure() << pred_text << "(" + << e1 << ", " + << e2 << ", " + << e3 << ", " + << e4 << ", " + << e5 << ") evaluates to false, where" + << "\n" << e1 << " evaluates to " << v1 + << "\n" << e2 << " evaluates to " << v2 + << "\n" << e3 << " evaluates to " << v3 + << "\n" << e4 << " evaluates to " << v4 + << "\n" << e5 << " evaluates to " << v5; +} + +// Internal macro for implementing {EXPECT|ASSERT}_PRED_FORMAT5. +// Don't use this in your code. +#define GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, on_failure)\ + GTEST_ASSERT_(pred_format(#v1, #v2, #v3, #v4, #v5, v1, v2, v3, v4, v5), \ + on_failure) + +// Internal macro for implementing {EXPECT|ASSERT}_PRED5. Don't use +// this in your code. +#define GTEST_PRED5_(pred, v1, v2, v3, v4, v5, on_failure)\ + GTEST_ASSERT_(::testing::AssertPred5Helper(#pred, \ + #v1, \ + #v2, \ + #v3, \ + #v4, \ + #v5, \ + pred, \ + v1, \ + v2, \ + v3, \ + v4, \ + v5), on_failure) + +// 5-ary predicate assertion macros. +#define EXPECT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \ + GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_) +#define EXPECT_PRED5(pred, v1, v2, v3, v4, v5) \ + GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_NONFATAL_FAILURE_) +#define ASSERT_PRED_FORMAT5(pred_format, v1, v2, v3, v4, v5) \ + GTEST_PRED_FORMAT5_(pred_format, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_) +#define ASSERT_PRED5(pred, v1, v2, v3, v4, v5) \ + GTEST_PRED5_(pred, v1, v2, v3, v4, v5, GTEST_FATAL_FAILURE_) + + + +#endif // GTEST_INCLUDE_GTEST_GTEST_PRED_IMPL_H_ diff --git a/test/fmw/gtest/include/gtest/gtest_prod.h b/test/fmw/gtest/include/gtest/gtest_prod.h new file mode 100644 index 00000000000..da80ddc6c70 --- /dev/null +++ b/test/fmw/gtest/include/gtest/gtest_prod.h @@ -0,0 +1,58 @@ +// Copyright 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) +// +// Google C++ Testing Framework definitions useful in production code. + +#ifndef GTEST_INCLUDE_GTEST_GTEST_PROD_H_ +#define GTEST_INCLUDE_GTEST_GTEST_PROD_H_ + +// When you need to test the private or protected members of a class, +// use the FRIEND_TEST macro to declare your tests as friends of the +// class. For example: +// +// class MyClass { +// private: +// void MyMethod(); +// FRIEND_TEST(MyClassTest, MyMethod); +// }; +// +// class MyClassTest : public testing::Test { +// // ... +// }; +// +// TEST_F(MyClassTest, MyMethod) { +// // Can call MyClass::MyMethod() here. +// } + +#define FRIEND_TEST(test_case_name, test_name)\ +friend class test_case_name##_##test_name##_Test + +#endif // GTEST_INCLUDE_GTEST_GTEST_PROD_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-death-test-internal.h b/test/fmw/gtest/include/gtest/internal/gtest-death-test-internal.h new file mode 100644 index 00000000000..2b3a78f5bf8 --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-death-test-internal.h @@ -0,0 +1,319 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee) +// +// The Google C++ Testing Framework (Google Test) +// +// This header file defines internal utilities needed for implementing +// death tests. They are subject to change without notice. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ + +#include "gtest/internal/gtest-internal.h" + +#include + +namespace testing { +namespace internal { + +GTEST_DECLARE_string_(internal_run_death_test); + +// Names of the flags (needed for parsing Google Test flags). +const char kDeathTestStyleFlag[] = "death_test_style"; +const char kDeathTestUseFork[] = "death_test_use_fork"; +const char kInternalRunDeathTestFlag[] = "internal_run_death_test"; + +#if GTEST_HAS_DEATH_TEST + +// DeathTest is a class that hides much of the complexity of the +// GTEST_DEATH_TEST_ macro. It is abstract; its static Create method +// returns a concrete class that depends on the prevailing death test +// style, as defined by the --gtest_death_test_style and/or +// --gtest_internal_run_death_test flags. + +// In describing the results of death tests, these terms are used with +// the corresponding definitions: +// +// exit status: The integer exit information in the format specified +// by wait(2) +// exit code: The integer code passed to exit(3), _exit(2), or +// returned from main() +class GTEST_API_ DeathTest { + public: + // Create returns false if there was an error determining the + // appropriate action to take for the current death test; for example, + // if the gtest_death_test_style flag is set to an invalid value. + // The LastMessage method will return a more detailed message in that + // case. Otherwise, the DeathTest pointer pointed to by the "test" + // argument is set. If the death test should be skipped, the pointer + // is set to NULL; otherwise, it is set to the address of a new concrete + // DeathTest object that controls the execution of the current test. + static bool Create(const char* statement, const RE* regex, + const char* file, int line, DeathTest** test); + DeathTest(); + virtual ~DeathTest() { } + + // A helper class that aborts a death test when it's deleted. + class ReturnSentinel { + public: + explicit ReturnSentinel(DeathTest* test) : test_(test) { } + ~ReturnSentinel() { test_->Abort(TEST_ENCOUNTERED_RETURN_STATEMENT); } + private: + DeathTest* const test_; + GTEST_DISALLOW_COPY_AND_ASSIGN_(ReturnSentinel); + } GTEST_ATTRIBUTE_UNUSED_; + + // An enumeration of possible roles that may be taken when a death + // test is encountered. EXECUTE means that the death test logic should + // be executed immediately. OVERSEE means that the program should prepare + // the appropriate environment for a child process to execute the death + // test, then wait for it to complete. + enum TestRole { OVERSEE_TEST, EXECUTE_TEST }; + + // An enumeration of the three reasons that a test might be aborted. + enum AbortReason { + TEST_ENCOUNTERED_RETURN_STATEMENT, + TEST_THREW_EXCEPTION, + TEST_DID_NOT_DIE + }; + + // Assumes one of the above roles. + virtual TestRole AssumeRole() = 0; + + // Waits for the death test to finish and returns its status. + virtual int Wait() = 0; + + // Returns true if the death test passed; that is, the test process + // exited during the test, its exit status matches a user-supplied + // predicate, and its stderr output matches a user-supplied regular + // expression. + // The user-supplied predicate may be a macro expression rather + // than a function pointer or functor, or else Wait and Passed could + // be combined. + virtual bool Passed(bool exit_status_ok) = 0; + + // Signals that the death test did not die as expected. + virtual void Abort(AbortReason reason) = 0; + + // Returns a human-readable outcome message regarding the outcome of + // the last death test. + static const char* LastMessage(); + + static void set_last_death_test_message(const std::string& message); + + private: + // A string containing a description of the outcome of the last death test. + static std::string last_death_test_message_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(DeathTest); +}; + +// Factory interface for death tests. May be mocked out for testing. +class DeathTestFactory { + public: + virtual ~DeathTestFactory() { } + virtual bool Create(const char* statement, const RE* regex, + const char* file, int line, DeathTest** test) = 0; +}; + +// A concrete DeathTestFactory implementation for normal use. +class DefaultDeathTestFactory : public DeathTestFactory { + public: + virtual bool Create(const char* statement, const RE* regex, + const char* file, int line, DeathTest** test); +}; + +// Returns true if exit_status describes a process that was terminated +// by a signal, or exited normally with a nonzero exit code. +GTEST_API_ bool ExitedUnsuccessfully(int exit_status); + +// Traps C++ exceptions escaping statement and reports them as test +// failures. Note that trapping SEH exceptions is not implemented here. +# if GTEST_HAS_EXCEPTIONS +# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \ + try { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } catch (const ::std::exception& gtest_exception) { \ + fprintf(\ + stderr, \ + "\n%s: Caught std::exception-derived exception escaping the " \ + "death test statement. Exception message: %s\n", \ + ::testing::internal::FormatFileLocation(__FILE__, __LINE__).c_str(), \ + gtest_exception.what()); \ + fflush(stderr); \ + death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \ + } catch (...) { \ + death_test->Abort(::testing::internal::DeathTest::TEST_THREW_EXCEPTION); \ + } + +# else +# define GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, death_test) \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) + +# endif + +// This macro is for implementing ASSERT_DEATH*, EXPECT_DEATH*, +// ASSERT_EXIT*, and EXPECT_EXIT*. +# define GTEST_DEATH_TEST_(statement, predicate, regex, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + const ::testing::internal::RE& gtest_regex = (regex); \ + ::testing::internal::DeathTest* gtest_dt; \ + if (!::testing::internal::DeathTest::Create(#statement, >est_regex, \ + __FILE__, __LINE__, >est_dt)) { \ + goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \ + } \ + if (gtest_dt != NULL) { \ + ::testing::internal::scoped_ptr< ::testing::internal::DeathTest> \ + gtest_dt_ptr(gtest_dt); \ + switch (gtest_dt->AssumeRole()) { \ + case ::testing::internal::DeathTest::OVERSEE_TEST: \ + if (!gtest_dt->Passed(predicate(gtest_dt->Wait()))) { \ + goto GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__); \ + } \ + break; \ + case ::testing::internal::DeathTest::EXECUTE_TEST: { \ + ::testing::internal::DeathTest::ReturnSentinel \ + gtest_sentinel(gtest_dt); \ + GTEST_EXECUTE_DEATH_TEST_STATEMENT_(statement, gtest_dt); \ + gtest_dt->Abort(::testing::internal::DeathTest::TEST_DID_NOT_DIE); \ + break; \ + } \ + default: \ + break; \ + } \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_, __LINE__): \ + fail(::testing::internal::DeathTest::LastMessage()) +// The symbol "fail" here expands to something into which a message +// can be streamed. + +// This macro is for implementing ASSERT/EXPECT_DEBUG_DEATH when compiled in +// NDEBUG mode. In this case we need the statements to be executed, the regex is +// ignored, and the macro must accept a streamed message even though the message +// is never printed. +# define GTEST_EXECUTE_STATEMENT_(statement, regex) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } else \ + ::testing::Message() + +// A class representing the parsed contents of the +// --gtest_internal_run_death_test flag, as it existed when +// RUN_ALL_TESTS was called. +class InternalRunDeathTestFlag { + public: + InternalRunDeathTestFlag(const std::string& a_file, + int a_line, + int an_index, + int a_write_fd) + : file_(a_file), line_(a_line), index_(an_index), + write_fd_(a_write_fd) {} + + ~InternalRunDeathTestFlag() { + if (write_fd_ >= 0) + posix::Close(write_fd_); + } + + const std::string& file() const { return file_; } + int line() const { return line_; } + int index() const { return index_; } + int write_fd() const { return write_fd_; } + + private: + std::string file_; + int line_; + int index_; + int write_fd_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(InternalRunDeathTestFlag); +}; + +// Returns a newly created InternalRunDeathTestFlag object with fields +// initialized from the GTEST_FLAG(internal_run_death_test) flag if +// the flag is specified; otherwise returns NULL. +InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag(); + +#else // GTEST_HAS_DEATH_TEST + +// This macro is used for implementing macros such as +// EXPECT_DEATH_IF_SUPPORTED and ASSERT_DEATH_IF_SUPPORTED on systems where +// death tests are not supported. Those macros must compile on such systems +// iff EXPECT_DEATH and ASSERT_DEATH compile with the same parameters on +// systems that support death tests. This allows one to write such a macro +// on a system that does not support death tests and be sure that it will +// compile on a death-test supporting system. +// +// Parameters: +// statement - A statement that a macro such as EXPECT_DEATH would test +// for program termination. This macro has to make sure this +// statement is compiled but not executed, to ensure that +// EXPECT_DEATH_IF_SUPPORTED compiles with a certain +// parameter iff EXPECT_DEATH compiles with it. +// regex - A regex that a macro such as EXPECT_DEATH would use to test +// the output of statement. This parameter has to be +// compiled but not evaluated by this macro, to ensure that +// this macro only accepts expressions that a macro such as +// EXPECT_DEATH would accept. +// terminator - Must be an empty statement for EXPECT_DEATH_IF_SUPPORTED +// and a return statement for ASSERT_DEATH_IF_SUPPORTED. +// This ensures that ASSERT_DEATH_IF_SUPPORTED will not +// compile inside functions where ASSERT_DEATH doesn't +// compile. +// +// The branch that has an always false condition is used to ensure that +// statement and regex are compiled (and thus syntactically correct) but +// never executed. The unreachable code macro protects the terminator +// statement from generating an 'unreachable code' warning in case +// statement unconditionally returns or throws. The Message constructor at +// the end allows the syntax of streaming additional messages into the +// macro, for compilational compatibility with EXPECT_DEATH/ASSERT_DEATH. +# define GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, terminator) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + GTEST_LOG_(WARNING) \ + << "Death tests are not supported on this platform.\n" \ + << "Statement '" #statement "' cannot be verified."; \ + } else if (::testing::internal::AlwaysFalse()) { \ + ::testing::internal::RE::PartialMatch(".*", (regex)); \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + terminator; \ + } else \ + ::testing::Message() + +#endif // GTEST_HAS_DEATH_TEST + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_DEATH_TEST_INTERNAL_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-filepath.h b/test/fmw/gtest/include/gtest/internal/gtest-filepath.h new file mode 100644 index 00000000000..7a13b4b0de6 --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-filepath.h @@ -0,0 +1,206 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: keith.ray@gmail.com (Keith Ray) +// +// Google Test filepath utilities +// +// This header file declares classes and functions used internally by +// Google Test. They are subject to change without notice. +// +// This file is #included in . +// Do not include this header file separately! + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ + +#include "gtest/internal/gtest-string.h" + +namespace testing { +namespace internal { + +// FilePath - a class for file and directory pathname manipulation which +// handles platform-specific conventions (like the pathname separator). +// Used for helper functions for naming files in a directory for xml output. +// Except for Set methods, all methods are const or static, which provides an +// "immutable value object" -- useful for peace of mind. +// A FilePath with a value ending in a path separator ("like/this/") represents +// a directory, otherwise it is assumed to represent a file. In either case, +// it may or may not represent an actual file or directory in the file system. +// Names are NOT checked for syntax correctness -- no checking for illegal +// characters, malformed paths, etc. + +class GTEST_API_ FilePath { + public: + FilePath() : pathname_("") { } + FilePath(const FilePath& rhs) : pathname_(rhs.pathname_) { } + + explicit FilePath(const std::string& pathname) : pathname_(pathname) { + Normalize(); + } + + FilePath& operator=(const FilePath& rhs) { + Set(rhs); + return *this; + } + + void Set(const FilePath& rhs) { + pathname_ = rhs.pathname_; + } + + const std::string& string() const { return pathname_; } + const char* c_str() const { return pathname_.c_str(); } + + // Returns the current working directory, or "" if unsuccessful. + static FilePath GetCurrentDir(); + + // Given directory = "dir", base_name = "test", number = 0, + // extension = "xml", returns "dir/test.xml". If number is greater + // than zero (e.g., 12), returns "dir/test_12.xml". + // On Windows platform, uses \ as the separator rather than /. + static FilePath MakeFileName(const FilePath& directory, + const FilePath& base_name, + int number, + const char* extension); + + // Given directory = "dir", relative_path = "test.xml", + // returns "dir/test.xml". + // On Windows, uses \ as the separator rather than /. + static FilePath ConcatPaths(const FilePath& directory, + const FilePath& relative_path); + + // Returns a pathname for a file that does not currently exist. The pathname + // will be directory/base_name.extension or + // directory/base_name_.extension if directory/base_name.extension + // already exists. The number will be incremented until a pathname is found + // that does not already exist. + // Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'. + // There could be a race condition if two or more processes are calling this + // function at the same time -- they could both pick the same filename. + static FilePath GenerateUniqueFileName(const FilePath& directory, + const FilePath& base_name, + const char* extension); + + // Returns true iff the path is "". + bool IsEmpty() const { return pathname_.empty(); } + + // If input name has a trailing separator character, removes it and returns + // the name, otherwise return the name string unmodified. + // On Windows platform, uses \ as the separator, other platforms use /. + FilePath RemoveTrailingPathSeparator() const; + + // Returns a copy of the FilePath with the directory part removed. + // Example: FilePath("path/to/file").RemoveDirectoryName() returns + // FilePath("file"). If there is no directory part ("just_a_file"), it returns + // the FilePath unmodified. If there is no file part ("just_a_dir/") it + // returns an empty FilePath (""). + // On Windows platform, '\' is the path separator, otherwise it is '/'. + FilePath RemoveDirectoryName() const; + + // RemoveFileName returns the directory path with the filename removed. + // Example: FilePath("path/to/file").RemoveFileName() returns "path/to/". + // If the FilePath is "a_file" or "/a_file", RemoveFileName returns + // FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does + // not have a file, like "just/a/dir/", it returns the FilePath unmodified. + // On Windows platform, '\' is the path separator, otherwise it is '/'. + FilePath RemoveFileName() const; + + // Returns a copy of the FilePath with the case-insensitive extension removed. + // Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns + // FilePath("dir/file"). If a case-insensitive extension is not + // found, returns a copy of the original FilePath. + FilePath RemoveExtension(const char* extension) const; + + // Creates directories so that path exists. Returns true if successful or if + // the directories already exist; returns false if unable to create + // directories for any reason. Will also return false if the FilePath does + // not represent a directory (that is, it doesn't end with a path separator). + bool CreateDirectoriesRecursively() const; + + // Create the directory so that path exists. Returns true if successful or + // if the directory already exists; returns false if unable to create the + // directory for any reason, including if the parent directory does not + // exist. Not named "CreateDirectory" because that's a macro on Windows. + bool CreateFolder() const; + + // Returns true if FilePath describes something in the file-system, + // either a file, directory, or whatever, and that something exists. + bool FileOrDirectoryExists() const; + + // Returns true if pathname describes a directory in the file-system + // that exists. + bool DirectoryExists() const; + + // Returns true if FilePath ends with a path separator, which indicates that + // it is intended to represent a directory. Returns false otherwise. + // This does NOT check that a directory (or file) actually exists. + bool IsDirectory() const; + + // Returns true if pathname describes a root directory. (Windows has one + // root directory per disk drive.) + bool IsRootDirectory() const; + + // Returns true if pathname describes an absolute path. + bool IsAbsolutePath() const; + + private: + // Replaces multiple consecutive separators with a single separator. + // For example, "bar///foo" becomes "bar/foo". Does not eliminate other + // redundancies that might be in a pathname involving "." or "..". + // + // A pathname with multiple consecutive separators may occur either through + // user error or as a result of some scripts or APIs that generate a pathname + // with a trailing separator. On other platforms the same API or script + // may NOT generate a pathname with a trailing "/". Then elsewhere that + // pathname may have another "/" and pathname components added to it, + // without checking for the separator already being there. + // The script language and operating system may allow paths like "foo//bar" + // but some of the functions in FilePath will not handle that correctly. In + // particular, RemoveTrailingPathSeparator() only removes one separator, and + // it is called in CreateDirectoriesRecursively() assuming that it will change + // a pathname from directory syntax (trailing separator) to filename syntax. + // + // On Windows this method also replaces the alternate path separator '/' with + // the primary path separator '\\', so that for example "bar\\/\\foo" becomes + // "bar\\foo". + + void Normalize(); + + // Returns a pointer to the last occurence of a valid path separator in + // the FilePath. On Windows, for example, both '/' and '\' are valid path + // separators. Returns NULL if no path separator was found. + const char* FindLastPathSeparator() const; + + std::string pathname_; +}; // class FilePath + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_FILEPATH_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-internal.h b/test/fmw/gtest/include/gtest/internal/gtest-internal.h new file mode 100644 index 00000000000..0dcc3a3194f --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-internal.h @@ -0,0 +1,1158 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee) +// +// The Google C++ Testing Framework (Google Test) +// +// This header file declares functions and macros used internally by +// Google Test. They are subject to change without notice. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ + +#include "gtest/internal/gtest-port.h" + +#if GTEST_OS_LINUX +# include +# include +# include +# include +#endif // GTEST_OS_LINUX + +#if GTEST_HAS_EXCEPTIONS +# include +#endif + +#include +#include +#include +#include +#include +#include + +#include "gtest/gtest-message.h" +#include "gtest/internal/gtest-string.h" +#include "gtest/internal/gtest-filepath.h" +#include "gtest/internal/gtest-type-util.h" + +// Due to C++ preprocessor weirdness, we need double indirection to +// concatenate two tokens when one of them is __LINE__. Writing +// +// foo ## __LINE__ +// +// will result in the token foo__LINE__, instead of foo followed by +// the current line number. For more details, see +// http://www.parashift.com/c++-faq-lite/misc-technical-issues.html#faq-39.6 +#define GTEST_CONCAT_TOKEN_(foo, bar) GTEST_CONCAT_TOKEN_IMPL_(foo, bar) +#define GTEST_CONCAT_TOKEN_IMPL_(foo, bar) foo ## bar + +class ProtocolMessage; +namespace proto2 { class Message; } + +namespace testing { + +// Forward declarations. + +class AssertionResult; // Result of an assertion. +class Message; // Represents a failure message. +class Test; // Represents a test. +class TestInfo; // Information about a test. +class TestPartResult; // Result of a test part. +class UnitTest; // A collection of test cases. + +template +::std::string PrintToString(const T& value); + +namespace internal { + +struct TraceInfo; // Information about a trace point. +class ScopedTrace; // Implements scoped trace. +class TestInfoImpl; // Opaque implementation of TestInfo +class UnitTestImpl; // Opaque implementation of UnitTest + +// How many times InitGoogleTest() has been called. +GTEST_API_ extern int g_init_gtest_count; + +// The text used in failure messages to indicate the start of the +// stack trace. +GTEST_API_ extern const char kStackTraceMarker[]; + +// Two overloaded helpers for checking at compile time whether an +// expression is a null pointer literal (i.e. NULL or any 0-valued +// compile-time integral constant). Their return values have +// different sizes, so we can use sizeof() to test which version is +// picked by the compiler. These helpers have no implementations, as +// we only need their signatures. +// +// Given IsNullLiteralHelper(x), the compiler will pick the first +// version if x can be implicitly converted to Secret*, and pick the +// second version otherwise. Since Secret is a secret and incomplete +// type, the only expression a user can write that has type Secret* is +// a null pointer literal. Therefore, we know that x is a null +// pointer literal if and only if the first version is picked by the +// compiler. +char IsNullLiteralHelper(Secret* p); +char (&IsNullLiteralHelper(...))[2]; // NOLINT + +// A compile-time bool constant that is true if and only if x is a +// null pointer literal (i.e. NULL or any 0-valued compile-time +// integral constant). +#ifdef GTEST_ELLIPSIS_NEEDS_POD_ +// We lose support for NULL detection where the compiler doesn't like +// passing non-POD classes through ellipsis (...). +# define GTEST_IS_NULL_LITERAL_(x) false +#else +# define GTEST_IS_NULL_LITERAL_(x) \ + (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1) +#endif // GTEST_ELLIPSIS_NEEDS_POD_ + +// Appends the user-supplied message to the Google-Test-generated message. +GTEST_API_ std::string AppendUserMessage( + const std::string& gtest_msg, const Message& user_msg); + +#if GTEST_HAS_EXCEPTIONS + +// This exception is thrown by (and only by) a failed Google Test +// assertion when GTEST_FLAG(throw_on_failure) is true (if exceptions +// are enabled). We derive it from std::runtime_error, which is for +// errors presumably detectable only at run time. Since +// std::runtime_error inherits from std::exception, many testing +// frameworks know how to extract and print the message inside it. +class GTEST_API_ GoogleTestFailureException : public ::std::runtime_error { + public: + explicit GoogleTestFailureException(const TestPartResult& failure); +}; + +#endif // GTEST_HAS_EXCEPTIONS + +// A helper class for creating scoped traces in user programs. +class GTEST_API_ ScopedTrace { + public: + // The c'tor pushes the given source file location and message onto + // a trace stack maintained by Google Test. + ScopedTrace(const char* file, int line, const Message& message); + + // The d'tor pops the info pushed by the c'tor. + // + // Note that the d'tor is not virtual in order to be efficient. + // Don't inherit from ScopedTrace! + ~ScopedTrace(); + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedTrace); +} GTEST_ATTRIBUTE_UNUSED_; // A ScopedTrace object does its job in its + // c'tor and d'tor. Therefore it doesn't + // need to be used otherwise. + +// Constructs and returns the message for an equality assertion +// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure. +// +// The first four parameters are the expressions used in the assertion +// and their values, as strings. For example, for ASSERT_EQ(foo, bar) +// where foo is 5 and bar is 6, we have: +// +// expected_expression: "foo" +// actual_expression: "bar" +// expected_value: "5" +// actual_value: "6" +// +// The ignoring_case parameter is true iff the assertion is a +// *_STRCASEEQ*. When it's true, the string " (ignoring case)" will +// be inserted into the message. +GTEST_API_ AssertionResult EqFailure(const char* expected_expression, + const char* actual_expression, + const std::string& expected_value, + const std::string& actual_value, + bool ignoring_case); + +// Constructs a failure message for Boolean assertions such as EXPECT_TRUE. +GTEST_API_ std::string GetBoolAssertionFailureMessage( + const AssertionResult& assertion_result, + const char* expression_text, + const char* actual_predicate_value, + const char* expected_predicate_value); + +// This template class represents an IEEE floating-point number +// (either single-precision or double-precision, depending on the +// template parameters). +// +// The purpose of this class is to do more sophisticated number +// comparison. (Due to round-off error, etc, it's very unlikely that +// two floating-points will be equal exactly. Hence a naive +// comparison by the == operation often doesn't work.) +// +// Format of IEEE floating-point: +// +// The most-significant bit being the leftmost, an IEEE +// floating-point looks like +// +// sign_bit exponent_bits fraction_bits +// +// Here, sign_bit is a single bit that designates the sign of the +// number. +// +// For float, there are 8 exponent bits and 23 fraction bits. +// +// For double, there are 11 exponent bits and 52 fraction bits. +// +// More details can be found at +// http://en.wikipedia.org/wiki/IEEE_floating-point_standard. +// +// Template parameter: +// +// RawType: the raw floating-point type (either float or double) +template +class FloatingPoint { + public: + // Defines the unsigned integer type that has the same size as the + // floating point number. + typedef typename TypeWithSize::UInt Bits; + + // Constants. + + // # of bits in a number. + static const size_t kBitCount = 8*sizeof(RawType); + + // # of fraction bits in a number. + static const size_t kFractionBitCount = + std::numeric_limits::digits - 1; + + // # of exponent bits in a number. + static const size_t kExponentBitCount = kBitCount - 1 - kFractionBitCount; + + // The mask for the sign bit. + static const Bits kSignBitMask = static_cast(1) << (kBitCount - 1); + + // The mask for the fraction bits. + static const Bits kFractionBitMask = + ~static_cast(0) >> (kExponentBitCount + 1); + + // The mask for the exponent bits. + static const Bits kExponentBitMask = ~(kSignBitMask | kFractionBitMask); + + // How many ULP's (Units in the Last Place) we want to tolerate when + // comparing two numbers. The larger the value, the more error we + // allow. A 0 value means that two numbers must be exactly the same + // to be considered equal. + // + // The maximum error of a single floating-point operation is 0.5 + // units in the last place. On Intel CPU's, all floating-point + // calculations are done with 80-bit precision, while double has 64 + // bits. Therefore, 4 should be enough for ordinary use. + // + // See the following article for more details on ULP: + // http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ + static const size_t kMaxUlps = 4; + + // Constructs a FloatingPoint from a raw floating-point number. + // + // On an Intel CPU, passing a non-normalized NAN (Not a Number) + // around may change its bits, although the new value is guaranteed + // to be also a NAN. Therefore, don't expect this constructor to + // preserve the bits in x when x is a NAN. + explicit FloatingPoint(const RawType& x) { u_.value_ = x; } + + // Static methods + + // Reinterprets a bit pattern as a floating-point number. + // + // This function is needed to test the AlmostEquals() method. + static RawType ReinterpretBits(const Bits bits) { + FloatingPoint fp(0); + fp.u_.bits_ = bits; + return fp.u_.value_; + } + + // Returns the floating-point number that represent positive infinity. + static RawType Infinity() { + return ReinterpretBits(kExponentBitMask); + } + + // Returns the maximum representable finite floating-point number. + static RawType Max(); + + // Non-static methods + + // Returns the bits that represents this number. + const Bits &bits() const { return u_.bits_; } + + // Returns the exponent bits of this number. + Bits exponent_bits() const { return kExponentBitMask & u_.bits_; } + + // Returns the fraction bits of this number. + Bits fraction_bits() const { return kFractionBitMask & u_.bits_; } + + // Returns the sign bit of this number. + Bits sign_bit() const { return kSignBitMask & u_.bits_; } + + // Returns true iff this is NAN (not a number). + bool is_nan() const { + // It's a NAN if the exponent bits are all ones and the fraction + // bits are not entirely zeros. + return (exponent_bits() == kExponentBitMask) && (fraction_bits() != 0); + } + + // Returns true iff this number is at most kMaxUlps ULP's away from + // rhs. In particular, this function: + // + // - returns false if either number is (or both are) NAN. + // - treats really large numbers as almost equal to infinity. + // - thinks +0.0 and -0.0 are 0 DLP's apart. + bool AlmostEquals(const FloatingPoint& rhs) const { + // The IEEE standard says that any comparison operation involving + // a NAN must return false. + if (is_nan() || rhs.is_nan()) return false; + + return DistanceBetweenSignAndMagnitudeNumbers(u_.bits_, rhs.u_.bits_) + <= kMaxUlps; + } + + private: + // The data type used to store the actual floating-point number. + union FloatingPointUnion { + RawType value_; // The raw floating-point number. + Bits bits_; // The bits that represent the number. + }; + + // Converts an integer from the sign-and-magnitude representation to + // the biased representation. More precisely, let N be 2 to the + // power of (kBitCount - 1), an integer x is represented by the + // unsigned number x + N. + // + // For instance, + // + // -N + 1 (the most negative number representable using + // sign-and-magnitude) is represented by 1; + // 0 is represented by N; and + // N - 1 (the biggest number representable using + // sign-and-magnitude) is represented by 2N - 1. + // + // Read http://en.wikipedia.org/wiki/Signed_number_representations + // for more details on signed number representations. + static Bits SignAndMagnitudeToBiased(const Bits &sam) { + if (kSignBitMask & sam) { + // sam represents a negative number. + return ~sam + 1; + } else { + // sam represents a positive number. + return kSignBitMask | sam; + } + } + + // Given two numbers in the sign-and-magnitude representation, + // returns the distance between them as an unsigned number. + static Bits DistanceBetweenSignAndMagnitudeNumbers(const Bits &sam1, + const Bits &sam2) { + const Bits biased1 = SignAndMagnitudeToBiased(sam1); + const Bits biased2 = SignAndMagnitudeToBiased(sam2); + return (biased1 >= biased2) ? (biased1 - biased2) : (biased2 - biased1); + } + + FloatingPointUnion u_; +}; + +// We cannot use std::numeric_limits::max() as it clashes with the max() +// macro defined by . +template <> +inline float FloatingPoint::Max() { return FLT_MAX; } +template <> +inline double FloatingPoint::Max() { return DBL_MAX; } + +// Typedefs the instances of the FloatingPoint template class that we +// care to use. +typedef FloatingPoint Float; +typedef FloatingPoint Double; + +// In order to catch the mistake of putting tests that use different +// test fixture classes in the same test case, we need to assign +// unique IDs to fixture classes and compare them. The TypeId type is +// used to hold such IDs. The user should treat TypeId as an opaque +// type: the only operation allowed on TypeId values is to compare +// them for equality using the == operator. +typedef const void* TypeId; + +template +class TypeIdHelper { + public: + // dummy_ must not have a const type. Otherwise an overly eager + // compiler (e.g. MSVC 7.1 & 8.0) may try to merge + // TypeIdHelper::dummy_ for different Ts as an "optimization". + static bool dummy_; +}; + +template +bool TypeIdHelper::dummy_ = false; + +// GetTypeId() returns the ID of type T. Different values will be +// returned for different types. Calling the function twice with the +// same type argument is guaranteed to return the same ID. +template +TypeId GetTypeId() { + // The compiler is required to allocate a different + // TypeIdHelper::dummy_ variable for each T used to instantiate + // the template. Therefore, the address of dummy_ is guaranteed to + // be unique. + return &(TypeIdHelper::dummy_); +} + +// Returns the type ID of ::testing::Test. Always call this instead +// of GetTypeId< ::testing::Test>() to get the type ID of +// ::testing::Test, as the latter may give the wrong result due to a +// suspected linker bug when compiling Google Test as a Mac OS X +// framework. +GTEST_API_ TypeId GetTestTypeId(); + +// Defines the abstract factory interface that creates instances +// of a Test object. +class TestFactoryBase { + public: + virtual ~TestFactoryBase() {} + + // Creates a test instance to run. The instance is both created and destroyed + // within TestInfoImpl::Run() + virtual Test* CreateTest() = 0; + + protected: + TestFactoryBase() {} + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestFactoryBase); +}; + +// This class provides implementation of TeastFactoryBase interface. +// It is used in TEST and TEST_F macros. +template +class TestFactoryImpl : public TestFactoryBase { + public: + virtual Test* CreateTest() { return new TestClass; } +}; + +#if GTEST_OS_WINDOWS + +// Predicate-formatters for implementing the HRESULT checking macros +// {ASSERT|EXPECT}_HRESULT_{SUCCEEDED|FAILED} +// We pass a long instead of HRESULT to avoid causing an +// include dependency for the HRESULT type. +GTEST_API_ AssertionResult IsHRESULTSuccess(const char* expr, + long hr); // NOLINT +GTEST_API_ AssertionResult IsHRESULTFailure(const char* expr, + long hr); // NOLINT + +#endif // GTEST_OS_WINDOWS + +// Types of SetUpTestCase() and TearDownTestCase() functions. +typedef void (*SetUpTestCaseFunc)(); +typedef void (*TearDownTestCaseFunc)(); + +// Creates a new TestInfo object and registers it with Google Test; +// returns the created object. +// +// Arguments: +// +// test_case_name: name of the test case +// name: name of the test +// type_param the name of the test's type parameter, or NULL if +// this is not a typed or a type-parameterized test. +// value_param text representation of the test's value parameter, +// or NULL if this is not a type-parameterized test. +// fixture_class_id: ID of the test fixture class +// set_up_tc: pointer to the function that sets up the test case +// tear_down_tc: pointer to the function that tears down the test case +// factory: pointer to the factory that creates a test object. +// The newly created TestInfo instance will assume +// ownership of the factory object. +GTEST_API_ TestInfo* MakeAndRegisterTestInfo( + const char* test_case_name, + const char* name, + const char* type_param, + const char* value_param, + TypeId fixture_class_id, + SetUpTestCaseFunc set_up_tc, + TearDownTestCaseFunc tear_down_tc, + TestFactoryBase* factory); + +// If *pstr starts with the given prefix, modifies *pstr to be right +// past the prefix and returns true; otherwise leaves *pstr unchanged +// and returns false. None of pstr, *pstr, and prefix can be NULL. +GTEST_API_ bool SkipPrefix(const char* prefix, const char** pstr); + +#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +// State of the definition of a type-parameterized test case. +class GTEST_API_ TypedTestCasePState { + public: + TypedTestCasePState() : registered_(false) {} + + // Adds the given test name to defined_test_names_ and return true + // if the test case hasn't been registered; otherwise aborts the + // program. + bool AddTestName(const char* file, int line, const char* case_name, + const char* test_name) { + if (registered_) { + fprintf(stderr, "%s Test %s must be defined before " + "REGISTER_TYPED_TEST_CASE_P(%s, ...).\n", + FormatFileLocation(file, line).c_str(), test_name, case_name); + fflush(stderr); + posix::Abort(); + } + defined_test_names_.insert(test_name); + return true; + } + + // Verifies that registered_tests match the test names in + // defined_test_names_; returns registered_tests if successful, or + // aborts the program otherwise. + const char* VerifyRegisteredTestNames( + const char* file, int line, const char* registered_tests); + + private: + bool registered_; + ::std::set defined_test_names_; +}; + +// Skips to the first non-space char after the first comma in 'str'; +// returns NULL if no comma is found in 'str'. +inline const char* SkipComma(const char* str) { + const char* comma = strchr(str, ','); + if (comma == NULL) { + return NULL; + } + while (IsSpace(*(++comma))) {} + return comma; +} + +// Returns the prefix of 'str' before the first comma in it; returns +// the entire string if it contains no comma. +inline std::string GetPrefixUntilComma(const char* str) { + const char* comma = strchr(str, ','); + return comma == NULL ? str : std::string(str, comma); +} + +// TypeParameterizedTest::Register() +// registers a list of type-parameterized tests with Google Test. The +// return value is insignificant - we just need to return something +// such that we can call this function in a namespace scope. +// +// Implementation note: The GTEST_TEMPLATE_ macro declares a template +// template parameter. It's defined in gtest-type-util.h. +template +class TypeParameterizedTest { + public: + // 'index' is the index of the test in the type list 'Types' + // specified in INSTANTIATE_TYPED_TEST_CASE_P(Prefix, TestCase, + // Types). Valid values for 'index' are [0, N - 1] where N is the + // length of Types. + static bool Register(const char* prefix, const char* case_name, + const char* test_names, int index) { + typedef typename Types::Head Type; + typedef Fixture FixtureClass; + typedef typename GTEST_BIND_(TestSel, Type) TestClass; + + // First, registers the first type-parameterized test in the type + // list. + MakeAndRegisterTestInfo( + (std::string(prefix) + (prefix[0] == '\0' ? "" : "/") + case_name + "/" + + StreamableToString(index)).c_str(), + GetPrefixUntilComma(test_names).c_str(), + GetTypeName().c_str(), + NULL, // No value parameter. + GetTypeId(), + TestClass::SetUpTestCase, + TestClass::TearDownTestCase, + new TestFactoryImpl); + + // Next, recurses (at compile time) with the tail of the type list. + return TypeParameterizedTest + ::Register(prefix, case_name, test_names, index + 1); + } +}; + +// The base case for the compile time recursion. +template +class TypeParameterizedTest { + public: + static bool Register(const char* /*prefix*/, const char* /*case_name*/, + const char* /*test_names*/, int /*index*/) { + return true; + } +}; + +// TypeParameterizedTestCase::Register() +// registers *all combinations* of 'Tests' and 'Types' with Google +// Test. The return value is insignificant - we just need to return +// something such that we can call this function in a namespace scope. +template +class TypeParameterizedTestCase { + public: + static bool Register(const char* prefix, const char* case_name, + const char* test_names) { + typedef typename Tests::Head Head; + + // First, register the first test in 'Test' for each type in 'Types'. + TypeParameterizedTest::Register( + prefix, case_name, test_names, 0); + + // Next, recurses (at compile time) with the tail of the test list. + return TypeParameterizedTestCase + ::Register(prefix, case_name, SkipComma(test_names)); + } +}; + +// The base case for the compile time recursion. +template +class TypeParameterizedTestCase { + public: + static bool Register(const char* /*prefix*/, const char* /*case_name*/, + const char* /*test_names*/) { + return true; + } +}; + +#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +// Returns the current OS stack trace as an std::string. +// +// The maximum number of stack frames to be included is specified by +// the gtest_stack_trace_depth flag. The skip_count parameter +// specifies the number of top frames to be skipped, which doesn't +// count against the number of frames to be included. +// +// For example, if Foo() calls Bar(), which in turn calls +// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in +// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't. +GTEST_API_ std::string GetCurrentOsStackTraceExceptTop( + UnitTest* unit_test, int skip_count); + +// Helpers for suppressing warnings on unreachable code or constant +// condition. + +// Always returns true. +GTEST_API_ bool AlwaysTrue(); + +// Always returns false. +inline bool AlwaysFalse() { return !AlwaysTrue(); } + +// Helper for suppressing false warning from Clang on a const char* +// variable declared in a conditional expression always being NULL in +// the else branch. +struct GTEST_API_ ConstCharPtr { + ConstCharPtr(const char* str) : value(str) {} + operator bool() const { return true; } + const char* value; +}; + +// A simple Linear Congruential Generator for generating random +// numbers with a uniform distribution. Unlike rand() and srand(), it +// doesn't use global state (and therefore can't interfere with user +// code). Unlike rand_r(), it's portable. An LCG isn't very random, +// but it's good enough for our purposes. +class GTEST_API_ Random { + public: + static const UInt32 kMaxRange = 1u << 31; + + explicit Random(UInt32 seed) : state_(seed) {} + + void Reseed(UInt32 seed) { state_ = seed; } + + // Generates a random number from [0, range). Crashes if 'range' is + // 0 or greater than kMaxRange. + UInt32 Generate(UInt32 range); + + private: + UInt32 state_; + GTEST_DISALLOW_COPY_AND_ASSIGN_(Random); +}; + +// Defining a variable of type CompileAssertTypesEqual will cause a +// compiler error iff T1 and T2 are different types. +template +struct CompileAssertTypesEqual; + +template +struct CompileAssertTypesEqual { +}; + +// Removes the reference from a type if it is a reference type, +// otherwise leaves it unchanged. This is the same as +// tr1::remove_reference, which is not widely available yet. +template +struct RemoveReference { typedef T type; }; // NOLINT +template +struct RemoveReference { typedef T type; }; // NOLINT + +// A handy wrapper around RemoveReference that works when the argument +// T depends on template parameters. +#define GTEST_REMOVE_REFERENCE_(T) \ + typename ::testing::internal::RemoveReference::type + +// Removes const from a type if it is a const type, otherwise leaves +// it unchanged. This is the same as tr1::remove_const, which is not +// widely available yet. +template +struct RemoveConst { typedef T type; }; // NOLINT +template +struct RemoveConst { typedef T type; }; // NOLINT + +// MSVC 8.0, Sun C++, and IBM XL C++ have a bug which causes the above +// definition to fail to remove the const in 'const int[3]' and 'const +// char[3][4]'. The following specialization works around the bug. +template +struct RemoveConst { + typedef typename RemoveConst::type type[N]; +}; + +#if defined(_MSC_VER) && _MSC_VER < 1400 +// This is the only specialization that allows VC++ 7.1 to remove const in +// 'const int[3] and 'const int[3][4]'. However, it causes trouble with GCC +// and thus needs to be conditionally compiled. +template +struct RemoveConst { + typedef typename RemoveConst::type type[N]; +}; +#endif + +// A handy wrapper around RemoveConst that works when the argument +// T depends on template parameters. +#define GTEST_REMOVE_CONST_(T) \ + typename ::testing::internal::RemoveConst::type + +// Turns const U&, U&, const U, and U all into U. +#define GTEST_REMOVE_REFERENCE_AND_CONST_(T) \ + GTEST_REMOVE_CONST_(GTEST_REMOVE_REFERENCE_(T)) + +// Adds reference to a type if it is not a reference type, +// otherwise leaves it unchanged. This is the same as +// tr1::add_reference, which is not widely available yet. +template +struct AddReference { typedef T& type; }; // NOLINT +template +struct AddReference { typedef T& type; }; // NOLINT + +// A handy wrapper around AddReference that works when the argument T +// depends on template parameters. +#define GTEST_ADD_REFERENCE_(T) \ + typename ::testing::internal::AddReference::type + +// Adds a reference to const on top of T as necessary. For example, +// it transforms +// +// char ==> const char& +// const char ==> const char& +// char& ==> const char& +// const char& ==> const char& +// +// The argument T must depend on some template parameters. +#define GTEST_REFERENCE_TO_CONST_(T) \ + GTEST_ADD_REFERENCE_(const GTEST_REMOVE_REFERENCE_(T)) + +// ImplicitlyConvertible::value is a compile-time bool +// constant that's true iff type From can be implicitly converted to +// type To. +template +class ImplicitlyConvertible { + private: + // We need the following helper functions only for their types. + // They have no implementations. + + // MakeFrom() is an expression whose type is From. We cannot simply + // use From(), as the type From may not have a public default + // constructor. + static From MakeFrom(); + + // These two functions are overloaded. Given an expression + // Helper(x), the compiler will pick the first version if x can be + // implicitly converted to type To; otherwise it will pick the + // second version. + // + // The first version returns a value of size 1, and the second + // version returns a value of size 2. Therefore, by checking the + // size of Helper(x), which can be done at compile time, we can tell + // which version of Helper() is used, and hence whether x can be + // implicitly converted to type To. + static char Helper(To); + static char (&Helper(...))[2]; // NOLINT + + // We have to put the 'public' section after the 'private' section, + // or MSVC refuses to compile the code. + public: + // MSVC warns about implicitly converting from double to int for + // possible loss of data, so we need to temporarily disable the + // warning. +#ifdef _MSC_VER +# pragma warning(push) // Saves the current warning state. +# pragma warning(disable:4244) // Temporarily disables warning 4244. + + static const bool value = + sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1; +# pragma warning(pop) // Restores the warning state. +#elif defined(__BORLANDC__) + // C++Builder cannot use member overload resolution during template + // instantiation. The simplest workaround is to use its C++0x type traits + // functions (C++Builder 2009 and above only). + static const bool value = __is_convertible(From, To); +#else + static const bool value = + sizeof(Helper(ImplicitlyConvertible::MakeFrom())) == 1; +#endif // _MSV_VER +}; +template +const bool ImplicitlyConvertible::value; + +// IsAProtocolMessage::value is a compile-time bool constant that's +// true iff T is type ProtocolMessage, proto2::Message, or a subclass +// of those. +template +struct IsAProtocolMessage + : public bool_constant< + ImplicitlyConvertible::value || + ImplicitlyConvertible::value> { +}; + +// When the compiler sees expression IsContainerTest(0), if C is an +// STL-style container class, the first overload of IsContainerTest +// will be viable (since both C::iterator* and C::const_iterator* are +// valid types and NULL can be implicitly converted to them). It will +// be picked over the second overload as 'int' is a perfect match for +// the type of argument 0. If C::iterator or C::const_iterator is not +// a valid type, the first overload is not viable, and the second +// overload will be picked. Therefore, we can determine whether C is +// a container class by checking the type of IsContainerTest(0). +// The value of the expression is insignificant. +// +// Note that we look for both C::iterator and C::const_iterator. The +// reason is that C++ injects the name of a class as a member of the +// class itself (e.g. you can refer to class iterator as either +// 'iterator' or 'iterator::iterator'). If we look for C::iterator +// only, for example, we would mistakenly think that a class named +// iterator is an STL container. +// +// Also note that the simpler approach of overloading +// IsContainerTest(typename C::const_iterator*) and +// IsContainerTest(...) doesn't work with Visual Age C++ and Sun C++. +typedef int IsContainer; +template +IsContainer IsContainerTest(int /* dummy */, + typename C::iterator* /* it */ = NULL, + typename C::const_iterator* /* const_it */ = NULL) { + return 0; +} + +typedef char IsNotContainer; +template +IsNotContainer IsContainerTest(long /* dummy */) { return '\0'; } + +// EnableIf::type is void when 'Cond' is true, and +// undefined when 'Cond' is false. To use SFINAE to make a function +// overload only apply when a particular expression is true, add +// "typename EnableIf::type* = 0" as the last parameter. +template struct EnableIf; +template<> struct EnableIf { typedef void type; }; // NOLINT + +// Utilities for native arrays. + +// ArrayEq() compares two k-dimensional native arrays using the +// elements' operator==, where k can be any integer >= 0. When k is +// 0, ArrayEq() degenerates into comparing a single pair of values. + +template +bool ArrayEq(const T* lhs, size_t size, const U* rhs); + +// This generic version is used when k is 0. +template +inline bool ArrayEq(const T& lhs, const U& rhs) { return lhs == rhs; } + +// This overload is used when k >= 1. +template +inline bool ArrayEq(const T(&lhs)[N], const U(&rhs)[N]) { + return internal::ArrayEq(lhs, N, rhs); +} + +// This helper reduces code bloat. If we instead put its logic inside +// the previous ArrayEq() function, arrays with different sizes would +// lead to different copies of the template code. +template +bool ArrayEq(const T* lhs, size_t size, const U* rhs) { + for (size_t i = 0; i != size; i++) { + if (!internal::ArrayEq(lhs[i], rhs[i])) + return false; + } + return true; +} + +// Finds the first element in the iterator range [begin, end) that +// equals elem. Element may be a native array type itself. +template +Iter ArrayAwareFind(Iter begin, Iter end, const Element& elem) { + for (Iter it = begin; it != end; ++it) { + if (internal::ArrayEq(*it, elem)) + return it; + } + return end; +} + +// CopyArray() copies a k-dimensional native array using the elements' +// operator=, where k can be any integer >= 0. When k is 0, +// CopyArray() degenerates into copying a single value. + +template +void CopyArray(const T* from, size_t size, U* to); + +// This generic version is used when k is 0. +template +inline void CopyArray(const T& from, U* to) { *to = from; } + +// This overload is used when k >= 1. +template +inline void CopyArray(const T(&from)[N], U(*to)[N]) { + internal::CopyArray(from, N, *to); +} + +// This helper reduces code bloat. If we instead put its logic inside +// the previous CopyArray() function, arrays with different sizes +// would lead to different copies of the template code. +template +void CopyArray(const T* from, size_t size, U* to) { + for (size_t i = 0; i != size; i++) { + internal::CopyArray(from[i], to + i); + } +} + +// The relation between an NativeArray object (see below) and the +// native array it represents. +enum RelationToSource { + kReference, // The NativeArray references the native array. + kCopy // The NativeArray makes a copy of the native array and + // owns the copy. +}; + +// Adapts a native array to a read-only STL-style container. Instead +// of the complete STL container concept, this adaptor only implements +// members useful for Google Mock's container matchers. New members +// should be added as needed. To simplify the implementation, we only +// support Element being a raw type (i.e. having no top-level const or +// reference modifier). It's the client's responsibility to satisfy +// this requirement. Element can be an array type itself (hence +// multi-dimensional arrays are supported). +template +class NativeArray { + public: + // STL-style container typedefs. + typedef Element value_type; + typedef Element* iterator; + typedef const Element* const_iterator; + + // Constructs from a native array. + NativeArray(const Element* array, size_t count, RelationToSource relation) { + Init(array, count, relation); + } + + // Copy constructor. + NativeArray(const NativeArray& rhs) { + Init(rhs.array_, rhs.size_, rhs.relation_to_source_); + } + + ~NativeArray() { + // Ensures that the user doesn't instantiate NativeArray with a + // const or reference type. + static_cast(StaticAssertTypeEqHelper()); + if (relation_to_source_ == kCopy) + delete[] array_; + } + + // STL-style container methods. + size_t size() const { return size_; } + const_iterator begin() const { return array_; } + const_iterator end() const { return array_ + size_; } + bool operator==(const NativeArray& rhs) const { + return size() == rhs.size() && + ArrayEq(begin(), size(), rhs.begin()); + } + + private: + // Initializes this object; makes a copy of the input array if + // 'relation' is kCopy. + void Init(const Element* array, size_t a_size, RelationToSource relation) { + if (relation == kReference) { + array_ = array; + } else { + Element* const copy = new Element[a_size]; + CopyArray(array, a_size, copy); + array_ = copy; + } + size_ = a_size; + relation_to_source_ = relation; + } + + const Element* array_; + size_t size_; + RelationToSource relation_to_source_; + + GTEST_DISALLOW_ASSIGN_(NativeArray); +}; + +} // namespace internal +} // namespace testing + +#define GTEST_MESSAGE_AT_(file, line, message, result_type) \ + ::testing::internal::AssertHelper(result_type, file, line, message) \ + = ::testing::Message() + +#define GTEST_MESSAGE_(message, result_type) \ + GTEST_MESSAGE_AT_(__FILE__, __LINE__, message, result_type) + +#define GTEST_FATAL_FAILURE_(message) \ + return GTEST_MESSAGE_(message, ::testing::TestPartResult::kFatalFailure) + +#define GTEST_NONFATAL_FAILURE_(message) \ + GTEST_MESSAGE_(message, ::testing::TestPartResult::kNonFatalFailure) + +#define GTEST_SUCCESS_(message) \ + GTEST_MESSAGE_(message, ::testing::TestPartResult::kSuccess) + +// Suppresses MSVC warnings 4072 (unreachable code) for the code following +// statement if it returns or throws (or doesn't return or throw in some +// situations). +#define GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement) \ + if (::testing::internal::AlwaysTrue()) { statement; } + +#define GTEST_TEST_THROW_(statement, expected_exception, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::ConstCharPtr gtest_msg = "") { \ + bool gtest_caught_expected = false; \ + try { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } \ + catch (expected_exception const&) { \ + gtest_caught_expected = true; \ + } \ + catch (...) { \ + gtest_msg.value = \ + "Expected: " #statement " throws an exception of type " \ + #expected_exception ".\n Actual: it throws a different type."; \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ + } \ + if (!gtest_caught_expected) { \ + gtest_msg.value = \ + "Expected: " #statement " throws an exception of type " \ + #expected_exception ".\n Actual: it throws nothing."; \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__); \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_testthrow_, __LINE__): \ + fail(gtest_msg.value) + +#define GTEST_TEST_NO_THROW_(statement, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + try { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } \ + catch (...) { \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__); \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_testnothrow_, __LINE__): \ + fail("Expected: " #statement " doesn't throw an exception.\n" \ + " Actual: it throws.") + +#define GTEST_TEST_ANY_THROW_(statement, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + bool gtest_caught_any = false; \ + try { \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + } \ + catch (...) { \ + gtest_caught_any = true; \ + } \ + if (!gtest_caught_any) { \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__); \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_testanythrow_, __LINE__): \ + fail("Expected: " #statement " throws an exception.\n" \ + " Actual: it doesn't.") + + +// Implements Boolean test assertions such as EXPECT_TRUE. expression can be +// either a boolean expression or an AssertionResult. text is a textual +// represenation of expression as it was passed into the EXPECT_TRUE. +#define GTEST_TEST_BOOLEAN_(expression, text, actual, expected, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (const ::testing::AssertionResult gtest_ar_ = \ + ::testing::AssertionResult(expression)) \ + ; \ + else \ + fail(::testing::internal::GetBoolAssertionFailureMessage(\ + gtest_ar_, text, #actual, #expected).c_str()) + +#define GTEST_TEST_NO_FATAL_FAILURE_(statement, fail) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::AlwaysTrue()) { \ + ::testing::internal::HasNewFatalFailureHelper gtest_fatal_failure_checker; \ + GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \ + if (gtest_fatal_failure_checker.has_new_fatal_failure()) { \ + goto GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__); \ + } \ + } else \ + GTEST_CONCAT_TOKEN_(gtest_label_testnofatal_, __LINE__): \ + fail("Expected: " #statement " doesn't generate new fatal " \ + "failures in the current thread.\n" \ + " Actual: it does.") + +// Expands to the name of the class that implements the given test. +#define GTEST_TEST_CLASS_NAME_(test_case_name, test_name) \ + test_case_name##_##test_name##_Test + +// Helper macro for defining tests. +#define GTEST_TEST_(test_case_name, test_name, parent_class, parent_id)\ +class GTEST_TEST_CLASS_NAME_(test_case_name, test_name) : public parent_class {\ + public:\ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)() {}\ + private:\ + virtual void TestBody();\ + static ::testing::TestInfo* const test_info_ GTEST_ATTRIBUTE_UNUSED_;\ + GTEST_DISALLOW_COPY_AND_ASSIGN_(\ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name));\ +};\ +\ +::testing::TestInfo* const GTEST_TEST_CLASS_NAME_(test_case_name, test_name)\ + ::test_info_ =\ + ::testing::internal::MakeAndRegisterTestInfo(\ + #test_case_name, #test_name, NULL, NULL, \ + (parent_id), \ + parent_class::SetUpTestCase, \ + parent_class::TearDownTestCase, \ + new ::testing::internal::TestFactoryImpl<\ + GTEST_TEST_CLASS_NAME_(test_case_name, test_name)>);\ +void GTEST_TEST_CLASS_NAME_(test_case_name, test_name)::TestBody() + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_INTERNAL_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-linked_ptr.h b/test/fmw/gtest/include/gtest/internal/gtest-linked_ptr.h new file mode 100644 index 00000000000..b1362cd002c --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-linked_ptr.h @@ -0,0 +1,233 @@ +// Copyright 2003 Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Authors: Dan Egnor (egnor@google.com) +// +// A "smart" pointer type with reference tracking. Every pointer to a +// particular object is kept on a circular linked list. When the last pointer +// to an object is destroyed or reassigned, the object is deleted. +// +// Used properly, this deletes the object when the last reference goes away. +// There are several caveats: +// - Like all reference counting schemes, cycles lead to leaks. +// - Each smart pointer is actually two pointers (8 bytes instead of 4). +// - Every time a pointer is assigned, the entire list of pointers to that +// object is traversed. This class is therefore NOT SUITABLE when there +// will often be more than two or three pointers to a particular object. +// - References are only tracked as long as linked_ptr<> objects are copied. +// If a linked_ptr<> is converted to a raw pointer and back, BAD THINGS +// will happen (double deletion). +// +// A good use of this class is storing object references in STL containers. +// You can safely put linked_ptr<> in a vector<>. +// Other uses may not be as good. +// +// Note: If you use an incomplete type with linked_ptr<>, the class +// *containing* linked_ptr<> must have a constructor and destructor (even +// if they do nothing!). +// +// Bill Gibbons suggested we use something like this. +// +// Thread Safety: +// Unlike other linked_ptr implementations, in this implementation +// a linked_ptr object is thread-safe in the sense that: +// - it's safe to copy linked_ptr objects concurrently, +// - it's safe to copy *from* a linked_ptr and read its underlying +// raw pointer (e.g. via get()) concurrently, and +// - it's safe to write to two linked_ptrs that point to the same +// shared object concurrently. +// TODO(wan@google.com): rename this to safe_linked_ptr to avoid +// confusion with normal linked_ptr. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_ + +#include +#include + +#include "gtest/internal/gtest-port.h" + +namespace testing { +namespace internal { + +// Protects copying of all linked_ptr objects. +GTEST_API_ GTEST_DECLARE_STATIC_MUTEX_(g_linked_ptr_mutex); + +// This is used internally by all instances of linked_ptr<>. It needs to be +// a non-template class because different types of linked_ptr<> can refer to +// the same object (linked_ptr(obj) vs linked_ptr(obj)). +// So, it needs to be possible for different types of linked_ptr to participate +// in the same circular linked list, so we need a single class type here. +// +// DO NOT USE THIS CLASS DIRECTLY YOURSELF. Use linked_ptr. +class linked_ptr_internal { + public: + // Create a new circle that includes only this instance. + void join_new() { + next_ = this; + } + + // Many linked_ptr operations may change p.link_ for some linked_ptr + // variable p in the same circle as this object. Therefore we need + // to prevent two such operations from occurring concurrently. + // + // Note that different types of linked_ptr objects can coexist in a + // circle (e.g. linked_ptr, linked_ptr, and + // linked_ptr). Therefore we must use a single mutex to + // protect all linked_ptr objects. This can create serious + // contention in production code, but is acceptable in a testing + // framework. + + // Join an existing circle. + void join(linked_ptr_internal const* ptr) + GTEST_LOCK_EXCLUDED_(g_linked_ptr_mutex) { + MutexLock lock(&g_linked_ptr_mutex); + + linked_ptr_internal const* p = ptr; + while (p->next_ != ptr) p = p->next_; + p->next_ = this; + next_ = ptr; + } + + // Leave whatever circle we're part of. Returns true if we were the + // last member of the circle. Once this is done, you can join() another. + bool depart() + GTEST_LOCK_EXCLUDED_(g_linked_ptr_mutex) { + MutexLock lock(&g_linked_ptr_mutex); + + if (next_ == this) return true; + linked_ptr_internal const* p = next_; + while (p->next_ != this) p = p->next_; + p->next_ = next_; + return false; + } + + private: + mutable linked_ptr_internal const* next_; +}; + +template +class linked_ptr { + public: + typedef T element_type; + + // Take over ownership of a raw pointer. This should happen as soon as + // possible after the object is created. + explicit linked_ptr(T* ptr = NULL) { capture(ptr); } + ~linked_ptr() { depart(); } + + // Copy an existing linked_ptr<>, adding ourselves to the list of references. + template linked_ptr(linked_ptr const& ptr) { copy(&ptr); } + linked_ptr(linked_ptr const& ptr) { // NOLINT + assert(&ptr != this); + copy(&ptr); + } + + // Assignment releases the old value and acquires the new. + template linked_ptr& operator=(linked_ptr const& ptr) { + depart(); + copy(&ptr); + return *this; + } + + linked_ptr& operator=(linked_ptr const& ptr) { + if (&ptr != this) { + depart(); + copy(&ptr); + } + return *this; + } + + // Smart pointer members. + void reset(T* ptr = NULL) { + depart(); + capture(ptr); + } + T* get() const { return value_; } + T* operator->() const { return value_; } + T& operator*() const { return *value_; } + + bool operator==(T* p) const { return value_ == p; } + bool operator!=(T* p) const { return value_ != p; } + template + bool operator==(linked_ptr const& ptr) const { + return value_ == ptr.get(); + } + template + bool operator!=(linked_ptr const& ptr) const { + return value_ != ptr.get(); + } + + private: + template + friend class linked_ptr; + + T* value_; + linked_ptr_internal link_; + + void depart() { + if (link_.depart()) delete value_; + } + + void capture(T* ptr) { + value_ = ptr; + link_.join_new(); + } + + template void copy(linked_ptr const* ptr) { + value_ = ptr->get(); + if (value_) + link_.join(&ptr->link_); + else + link_.join_new(); + } +}; + +template inline +bool operator==(T* ptr, const linked_ptr& x) { + return ptr == x.get(); +} + +template inline +bool operator!=(T* ptr, const linked_ptr& x) { + return ptr != x.get(); +} + +// A function to convert T* into linked_ptr +// Doing e.g. make_linked_ptr(new FooBarBaz(arg)) is a shorter notation +// for linked_ptr >(new FooBarBaz(arg)) +template +linked_ptr make_linked_ptr(T* ptr) { + return linked_ptr(ptr); +} + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_LINKED_PTR_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h b/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h new file mode 100644 index 00000000000..e80548592c7 --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h @@ -0,0 +1,5143 @@ +// This file was GENERATED by command: +// pump.py gtest-param-util-generated.h.pump +// DO NOT EDIT BY HAND!!! + +// Copyright 2008 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: vladl@google.com (Vlad Losev) + +// Type and function utilities for implementing parameterized tests. +// This file is generated by a SCRIPT. DO NOT EDIT BY HAND! +// +// Currently Google Test supports at most 50 arguments in Values, +// and at most 10 arguments in Combine. Please contact +// googletestframework@googlegroups.com if you need more. +// Please note that the number of arguments to Combine is limited +// by the maximum arity of the implementation of tr1::tuple which is +// currently set at 10. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ + +// scripts/fuse_gtest.py depends on gtest's own header being #included +// *unconditionally*. Therefore these #includes cannot be moved +// inside #if GTEST_HAS_PARAM_TEST. +#include "gtest/internal/gtest-param-util.h" +#include "gtest/internal/gtest-port.h" + +#if GTEST_HAS_PARAM_TEST + +namespace testing { + +// Forward declarations of ValuesIn(), which is implemented in +// include/gtest/gtest-param-test.h. +template +internal::ParamGenerator< + typename ::testing::internal::IteratorTraits::value_type> +ValuesIn(ForwardIterator begin, ForwardIterator end); + +template +internal::ParamGenerator ValuesIn(const T (&array)[N]); + +template +internal::ParamGenerator ValuesIn( + const Container& container); + +namespace internal { + +// Used in the Values() function to provide polymorphic capabilities. +template +class ValueArray1 { + public: + explicit ValueArray1(T1 v1) : v1_(v1) {} + + template + operator ParamGenerator() const { return ValuesIn(&v1_, &v1_ + 1); } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray1& other); + + const T1 v1_; +}; + +template +class ValueArray2 { + public: + ValueArray2(T1 v1, T2 v2) : v1_(v1), v2_(v2) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray2& other); + + const T1 v1_; + const T2 v2_; +}; + +template +class ValueArray3 { + public: + ValueArray3(T1 v1, T2 v2, T3 v3) : v1_(v1), v2_(v2), v3_(v3) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray3& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; +}; + +template +class ValueArray4 { + public: + ValueArray4(T1 v1, T2 v2, T3 v3, T4 v4) : v1_(v1), v2_(v2), v3_(v3), + v4_(v4) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray4& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; +}; + +template +class ValueArray5 { + public: + ValueArray5(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5) : v1_(v1), v2_(v2), v3_(v3), + v4_(v4), v5_(v5) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray5& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; +}; + +template +class ValueArray6 { + public: + ValueArray6(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6) : v1_(v1), v2_(v2), + v3_(v3), v4_(v4), v5_(v5), v6_(v6) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray6& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; +}; + +template +class ValueArray7 { + public: + ValueArray7(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7) : v1_(v1), + v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray7& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; +}; + +template +class ValueArray8 { + public: + ValueArray8(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, + T8 v8) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray8& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; +}; + +template +class ValueArray9 { + public: + ValueArray9(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, + T9 v9) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8), v9_(v9) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray9& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; +}; + +template +class ValueArray10 { + public: + ValueArray10(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8), v9_(v9), v10_(v10) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray10& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; +}; + +template +class ValueArray11 { + public: + ValueArray11(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), + v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray11& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; +}; + +template +class ValueArray12 { + public: + ValueArray12(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), + v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray12& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; +}; + +template +class ValueArray13 { + public: + ValueArray13(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), + v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), + v12_(v12), v13_(v13) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray13& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; +}; + +template +class ValueArray14 { + public: + ValueArray14(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) : v1_(v1), v2_(v2), v3_(v3), + v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), + v11_(v11), v12_(v12), v13_(v13), v14_(v14) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray14& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; +}; + +template +class ValueArray15 { + public: + ValueArray15(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) : v1_(v1), v2_(v2), + v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), + v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray15& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; +}; + +template +class ValueArray16 { + public: + ValueArray16(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16) : v1_(v1), + v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), + v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), + v16_(v16) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray16& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; +}; + +template +class ValueArray17 { + public: + ValueArray17(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, + T17 v17) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), + v15_(v15), v16_(v16), v17_(v17) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray17& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; +}; + +template +class ValueArray18 { + public: + ValueArray18(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), + v15_(v15), v16_(v16), v17_(v17), v18_(v18) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray18& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; +}; + +template +class ValueArray19 { + public: + ValueArray19(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), + v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), + v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray19& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; +}; + +template +class ValueArray20 { + public: + ValueArray20(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), + v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), + v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), + v19_(v19), v20_(v20) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray20& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; +}; + +template +class ValueArray21 { + public: + ValueArray21(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), + v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), + v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), + v18_(v18), v19_(v19), v20_(v20), v21_(v21) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray21& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; +}; + +template +class ValueArray22 { + public: + ValueArray22(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22) : v1_(v1), v2_(v2), v3_(v3), + v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), + v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), + v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray22& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; +}; + +template +class ValueArray23 { + public: + ValueArray23(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23) : v1_(v1), v2_(v2), + v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), + v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), + v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), + v23_(v23) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray23& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; +}; + +template +class ValueArray24 { + public: + ValueArray24(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24) : v1_(v1), + v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), + v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), + v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), + v22_(v22), v23_(v23), v24_(v24) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray24& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; +}; + +template +class ValueArray25 { + public: + ValueArray25(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, + T25 v25) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), + v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), + v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray25& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; +}; + +template +class ValueArray26 { + public: + ValueArray26(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), + v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), + v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray26& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; +}; + +template +class ValueArray27 { + public: + ValueArray27(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), + v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), + v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), + v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), + v26_(v26), v27_(v27) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray27& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; +}; + +template +class ValueArray28 { + public: + ValueArray28(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), + v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), + v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), + v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), + v25_(v25), v26_(v26), v27_(v27), v28_(v28) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray28& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; +}; + +template +class ValueArray29 { + public: + ValueArray29(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), + v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), + v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), + v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), + v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray29& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; +}; + +template +class ValueArray30 { + public: + ValueArray30(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) : v1_(v1), v2_(v2), v3_(v3), + v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), + v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), + v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), + v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), + v29_(v29), v30_(v30) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray30& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; +}; + +template +class ValueArray31 { + public: + ValueArray31(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) : v1_(v1), v2_(v2), + v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), + v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), + v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), + v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), + v29_(v29), v30_(v30), v31_(v31) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray31& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; +}; + +template +class ValueArray32 { + public: + ValueArray32(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32) : v1_(v1), + v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), + v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), + v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), + v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), + v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray32& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; +}; + +template +class ValueArray33 { + public: + ValueArray33(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, + T33 v33) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), + v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), + v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), + v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), + v33_(v33) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray33& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; +}; + +template +class ValueArray34 { + public: + ValueArray34(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), + v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), + v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), + v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), + v33_(v33), v34_(v34) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray34& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; +}; + +template +class ValueArray35 { + public: + ValueArray35(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), + v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), + v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), + v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), + v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), + v32_(v32), v33_(v33), v34_(v34), v35_(v35) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray35& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; +}; + +template +class ValueArray36 { + public: + ValueArray36(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), + v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), + v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), + v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), + v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), + v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray36& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; +}; + +template +class ValueArray37 { + public: + ValueArray37(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), + v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), + v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), + v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), + v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), + v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), + v36_(v36), v37_(v37) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray37& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; +}; + +template +class ValueArray38 { + public: + ValueArray38(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38) : v1_(v1), v2_(v2), v3_(v3), + v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), + v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), + v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), + v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), + v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), + v35_(v35), v36_(v36), v37_(v37), v38_(v38) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray38& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; +}; + +template +class ValueArray39 { + public: + ValueArray39(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39) : v1_(v1), v2_(v2), + v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), + v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), + v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), + v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), + v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), + v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_), + static_cast(v39_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray39& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; + const T39 v39_; +}; + +template +class ValueArray40 { + public: + ValueArray40(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) : v1_(v1), + v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), + v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), + v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), + v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), + v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), + v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), + v40_(v40) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_), + static_cast(v39_), static_cast(v40_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray40& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; + const T39 v39_; + const T40 v40_; +}; + +template +class ValueArray41 { + public: + ValueArray41(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, + T41 v41) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), + v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), + v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), + v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), + v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), + v39_(v39), v40_(v40), v41_(v41) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_), + static_cast(v39_), static_cast(v40_), static_cast(v41_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray41& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; + const T39 v39_; + const T40 v40_; + const T41 v41_; +}; + +template +class ValueArray42 { + public: + ValueArray42(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41, + T42 v42) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), + v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), + v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), + v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), + v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), + v39_(v39), v40_(v40), v41_(v41), v42_(v42) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_), + static_cast(v39_), static_cast(v40_), static_cast(v41_), + static_cast(v42_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray42& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; + const T39 v39_; + const T40 v40_; + const T41 v41_; + const T42 v42_; +}; + +template +class ValueArray43 { + public: + ValueArray43(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41, + T42 v42, T43 v43) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), + v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), + v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), + v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), + v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), + v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), + v38_(v38), v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_), + static_cast(v39_), static_cast(v40_), static_cast(v41_), + static_cast(v42_), static_cast(v43_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray43& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; + const T39 v39_; + const T40 v40_; + const T41 v41_; + const T42 v42_; + const T43 v43_; +}; + +template +class ValueArray44 { + public: + ValueArray44(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41, + T42 v42, T43 v43, T44 v44) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), + v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), + v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), v18_(v18), + v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), v24_(v24), + v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), v30_(v30), + v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), v36_(v36), + v37_(v37), v38_(v38), v39_(v39), v40_(v40), v41_(v41), v42_(v42), + v43_(v43), v44_(v44) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_), + static_cast(v39_), static_cast(v40_), static_cast(v41_), + static_cast(v42_), static_cast(v43_), static_cast(v44_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray44& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; + const T39 v39_; + const T40 v40_; + const T41 v41_; + const T42 v42_; + const T43 v43_; + const T44 v44_; +}; + +template +class ValueArray45 { + public: + ValueArray45(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41, + T42 v42, T43 v43, T44 v44, T45 v45) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), + v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), v11_(v11), + v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), v17_(v17), + v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), v23_(v23), + v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), v29_(v29), + v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), v35_(v35), + v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40), v41_(v41), + v42_(v42), v43_(v43), v44_(v44), v45_(v45) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_), + static_cast(v39_), static_cast(v40_), static_cast(v41_), + static_cast(v42_), static_cast(v43_), static_cast(v44_), + static_cast(v45_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray45& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; + const T39 v39_; + const T40 v40_; + const T41 v41_; + const T42 v42_; + const T43 v43_; + const T44 v44_; + const T45 v45_; +}; + +template +class ValueArray46 { + public: + ValueArray46(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41, + T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) : v1_(v1), v2_(v2), v3_(v3), + v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), + v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), + v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), + v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), + v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), + v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40), + v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), v46_(v46) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_), + static_cast(v39_), static_cast(v40_), static_cast(v41_), + static_cast(v42_), static_cast(v43_), static_cast(v44_), + static_cast(v45_), static_cast(v46_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray46& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; + const T39 v39_; + const T40 v40_; + const T41 v41_; + const T42 v42_; + const T43 v43_; + const T44 v44_; + const T45 v45_; + const T46 v46_; +}; + +template +class ValueArray47 { + public: + ValueArray47(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41, + T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) : v1_(v1), v2_(v2), + v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), v10_(v10), + v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), v16_(v16), + v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), v22_(v22), + v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), v28_(v28), + v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), v34_(v34), + v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), v40_(v40), + v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), v46_(v46), + v47_(v47) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_), + static_cast(v39_), static_cast(v40_), static_cast(v41_), + static_cast(v42_), static_cast(v43_), static_cast(v44_), + static_cast(v45_), static_cast(v46_), static_cast(v47_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray47& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; + const T39 v39_; + const T40 v40_; + const T41 v41_; + const T42 v42_; + const T43 v43_; + const T44 v44_; + const T45 v45_; + const T46 v46_; + const T47 v47_; +}; + +template +class ValueArray48 { + public: + ValueArray48(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41, + T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48) : v1_(v1), + v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), v8_(v8), v9_(v9), + v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), v15_(v15), + v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), v21_(v21), + v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), v27_(v27), + v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), v33_(v33), + v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), v39_(v39), + v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44), v45_(v45), + v46_(v46), v47_(v47), v48_(v48) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_), + static_cast(v39_), static_cast(v40_), static_cast(v41_), + static_cast(v42_), static_cast(v43_), static_cast(v44_), + static_cast(v45_), static_cast(v46_), static_cast(v47_), + static_cast(v48_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray48& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; + const T39 v39_; + const T40 v40_; + const T41 v41_; + const T42 v42_; + const T43 v43_; + const T44 v44_; + const T45 v45_; + const T46 v46_; + const T47 v47_; + const T48 v48_; +}; + +template +class ValueArray49 { + public: + ValueArray49(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41, + T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48, + T49 v49) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), + v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), + v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), + v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), + v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), + v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44), + v45_(v45), v46_(v46), v47_(v47), v48_(v48), v49_(v49) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_), + static_cast(v39_), static_cast(v40_), static_cast(v41_), + static_cast(v42_), static_cast(v43_), static_cast(v44_), + static_cast(v45_), static_cast(v46_), static_cast(v47_), + static_cast(v48_), static_cast(v49_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray49& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; + const T39 v39_; + const T40 v40_; + const T41 v41_; + const T42 v42_; + const T43 v43_; + const T44 v44_; + const T45 v45_; + const T46 v46_; + const T47 v47_; + const T48 v48_; + const T49 v49_; +}; + +template +class ValueArray50 { + public: + ValueArray50(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, + T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, + T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, + T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, + T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41, + T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47, T48 v48, T49 v49, + T50 v50) : v1_(v1), v2_(v2), v3_(v3), v4_(v4), v5_(v5), v6_(v6), v7_(v7), + v8_(v8), v9_(v9), v10_(v10), v11_(v11), v12_(v12), v13_(v13), v14_(v14), + v15_(v15), v16_(v16), v17_(v17), v18_(v18), v19_(v19), v20_(v20), + v21_(v21), v22_(v22), v23_(v23), v24_(v24), v25_(v25), v26_(v26), + v27_(v27), v28_(v28), v29_(v29), v30_(v30), v31_(v31), v32_(v32), + v33_(v33), v34_(v34), v35_(v35), v36_(v36), v37_(v37), v38_(v38), + v39_(v39), v40_(v40), v41_(v41), v42_(v42), v43_(v43), v44_(v44), + v45_(v45), v46_(v46), v47_(v47), v48_(v48), v49_(v49), v50_(v50) {} + + template + operator ParamGenerator() const { + const T array[] = {static_cast(v1_), static_cast(v2_), + static_cast(v3_), static_cast(v4_), static_cast(v5_), + static_cast(v6_), static_cast(v7_), static_cast(v8_), + static_cast(v9_), static_cast(v10_), static_cast(v11_), + static_cast(v12_), static_cast(v13_), static_cast(v14_), + static_cast(v15_), static_cast(v16_), static_cast(v17_), + static_cast(v18_), static_cast(v19_), static_cast(v20_), + static_cast(v21_), static_cast(v22_), static_cast(v23_), + static_cast(v24_), static_cast(v25_), static_cast(v26_), + static_cast(v27_), static_cast(v28_), static_cast(v29_), + static_cast(v30_), static_cast(v31_), static_cast(v32_), + static_cast(v33_), static_cast(v34_), static_cast(v35_), + static_cast(v36_), static_cast(v37_), static_cast(v38_), + static_cast(v39_), static_cast(v40_), static_cast(v41_), + static_cast(v42_), static_cast(v43_), static_cast(v44_), + static_cast(v45_), static_cast(v46_), static_cast(v47_), + static_cast(v48_), static_cast(v49_), static_cast(v50_)}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray50& other); + + const T1 v1_; + const T2 v2_; + const T3 v3_; + const T4 v4_; + const T5 v5_; + const T6 v6_; + const T7 v7_; + const T8 v8_; + const T9 v9_; + const T10 v10_; + const T11 v11_; + const T12 v12_; + const T13 v13_; + const T14 v14_; + const T15 v15_; + const T16 v16_; + const T17 v17_; + const T18 v18_; + const T19 v19_; + const T20 v20_; + const T21 v21_; + const T22 v22_; + const T23 v23_; + const T24 v24_; + const T25 v25_; + const T26 v26_; + const T27 v27_; + const T28 v28_; + const T29 v29_; + const T30 v30_; + const T31 v31_; + const T32 v32_; + const T33 v33_; + const T34 v34_; + const T35 v35_; + const T36 v36_; + const T37 v37_; + const T38 v38_; + const T39 v39_; + const T40 v40_; + const T41 v41_; + const T42 v42_; + const T43 v43_; + const T44 v44_; + const T45 v45_; + const T46 v46_; + const T47 v47_; + const T48 v48_; + const T49 v49_; + const T50 v50_; +}; + +# if GTEST_HAS_COMBINE +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Generates values from the Cartesian product of values produced +// by the argument generators. +// +template +class CartesianProductGenerator2 + : public ParamGeneratorInterface< ::std::tr1::tuple > { + public: + typedef ::std::tr1::tuple ParamType; + + CartesianProductGenerator2(const ParamGenerator& g1, + const ParamGenerator& g2) + : g1_(g1), g2_(g2) {} + virtual ~CartesianProductGenerator2() {} + + virtual ParamIteratorInterface* Begin() const { + return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin()); + } + virtual ParamIteratorInterface* End() const { + return new Iterator(this, g1_, g1_.end(), g2_, g2_.end()); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, + const ParamGenerator& g1, + const typename ParamGenerator::iterator& current1, + const ParamGenerator& g2, + const typename ParamGenerator::iterator& current2) + : base_(base), + begin1_(g1.begin()), end1_(g1.end()), current1_(current1), + begin2_(g2.begin()), end2_(g2.end()), current2_(current2) { + ComputeCurrentValue(); + } + virtual ~Iterator() {} + + virtual const ParamGeneratorInterface* BaseGenerator() const { + return base_; + } + // Advance should not be called on beyond-of-range iterators + // so no component iterators must be beyond end of range, either. + virtual void Advance() { + assert(!AtEnd()); + ++current2_; + if (current2_ == end2_) { + current2_ = begin2_; + ++current1_; + } + ComputeCurrentValue(); + } + virtual ParamIteratorInterface* Clone() const { + return new Iterator(*this); + } + virtual const ParamType* Current() const { return ¤t_value_; } + virtual bool Equals(const ParamIteratorInterface& other) const { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const Iterator* typed_other = + CheckedDowncastToActualType(&other); + // We must report iterators equal if they both point beyond their + // respective ranges. That can happen in a variety of fashions, + // so we have to consult AtEnd(). + return (AtEnd() && typed_other->AtEnd()) || + ( + current1_ == typed_other->current1_ && + current2_ == typed_other->current2_); + } + + private: + Iterator(const Iterator& other) + : base_(other.base_), + begin1_(other.begin1_), + end1_(other.end1_), + current1_(other.current1_), + begin2_(other.begin2_), + end2_(other.end2_), + current2_(other.current2_) { + ComputeCurrentValue(); + } + + void ComputeCurrentValue() { + if (!AtEnd()) + current_value_ = ParamType(*current1_, *current2_); + } + bool AtEnd() const { + // We must report iterator past the end of the range when either of the + // component iterators has reached the end of its range. + return + current1_ == end1_ || + current2_ == end2_; + } + + // No implementation - assignment is unsupported. + void operator=(const Iterator& other); + + const ParamGeneratorInterface* const base_; + // begin[i]_ and end[i]_ define the i-th range that Iterator traverses. + // current[i]_ is the actual traversing iterator. + const typename ParamGenerator::iterator begin1_; + const typename ParamGenerator::iterator end1_; + typename ParamGenerator::iterator current1_; + const typename ParamGenerator::iterator begin2_; + const typename ParamGenerator::iterator end2_; + typename ParamGenerator::iterator current2_; + ParamType current_value_; + }; // class CartesianProductGenerator2::Iterator + + // No implementation - assignment is unsupported. + void operator=(const CartesianProductGenerator2& other); + + const ParamGenerator g1_; + const ParamGenerator g2_; +}; // class CartesianProductGenerator2 + + +template +class CartesianProductGenerator3 + : public ParamGeneratorInterface< ::std::tr1::tuple > { + public: + typedef ::std::tr1::tuple ParamType; + + CartesianProductGenerator3(const ParamGenerator& g1, + const ParamGenerator& g2, const ParamGenerator& g3) + : g1_(g1), g2_(g2), g3_(g3) {} + virtual ~CartesianProductGenerator3() {} + + virtual ParamIteratorInterface* Begin() const { + return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_, + g3_.begin()); + } + virtual ParamIteratorInterface* End() const { + return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end()); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, + const ParamGenerator& g1, + const typename ParamGenerator::iterator& current1, + const ParamGenerator& g2, + const typename ParamGenerator::iterator& current2, + const ParamGenerator& g3, + const typename ParamGenerator::iterator& current3) + : base_(base), + begin1_(g1.begin()), end1_(g1.end()), current1_(current1), + begin2_(g2.begin()), end2_(g2.end()), current2_(current2), + begin3_(g3.begin()), end3_(g3.end()), current3_(current3) { + ComputeCurrentValue(); + } + virtual ~Iterator() {} + + virtual const ParamGeneratorInterface* BaseGenerator() const { + return base_; + } + // Advance should not be called on beyond-of-range iterators + // so no component iterators must be beyond end of range, either. + virtual void Advance() { + assert(!AtEnd()); + ++current3_; + if (current3_ == end3_) { + current3_ = begin3_; + ++current2_; + } + if (current2_ == end2_) { + current2_ = begin2_; + ++current1_; + } + ComputeCurrentValue(); + } + virtual ParamIteratorInterface* Clone() const { + return new Iterator(*this); + } + virtual const ParamType* Current() const { return ¤t_value_; } + virtual bool Equals(const ParamIteratorInterface& other) const { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const Iterator* typed_other = + CheckedDowncastToActualType(&other); + // We must report iterators equal if they both point beyond their + // respective ranges. That can happen in a variety of fashions, + // so we have to consult AtEnd(). + return (AtEnd() && typed_other->AtEnd()) || + ( + current1_ == typed_other->current1_ && + current2_ == typed_other->current2_ && + current3_ == typed_other->current3_); + } + + private: + Iterator(const Iterator& other) + : base_(other.base_), + begin1_(other.begin1_), + end1_(other.end1_), + current1_(other.current1_), + begin2_(other.begin2_), + end2_(other.end2_), + current2_(other.current2_), + begin3_(other.begin3_), + end3_(other.end3_), + current3_(other.current3_) { + ComputeCurrentValue(); + } + + void ComputeCurrentValue() { + if (!AtEnd()) + current_value_ = ParamType(*current1_, *current2_, *current3_); + } + bool AtEnd() const { + // We must report iterator past the end of the range when either of the + // component iterators has reached the end of its range. + return + current1_ == end1_ || + current2_ == end2_ || + current3_ == end3_; + } + + // No implementation - assignment is unsupported. + void operator=(const Iterator& other); + + const ParamGeneratorInterface* const base_; + // begin[i]_ and end[i]_ define the i-th range that Iterator traverses. + // current[i]_ is the actual traversing iterator. + const typename ParamGenerator::iterator begin1_; + const typename ParamGenerator::iterator end1_; + typename ParamGenerator::iterator current1_; + const typename ParamGenerator::iterator begin2_; + const typename ParamGenerator::iterator end2_; + typename ParamGenerator::iterator current2_; + const typename ParamGenerator::iterator begin3_; + const typename ParamGenerator::iterator end3_; + typename ParamGenerator::iterator current3_; + ParamType current_value_; + }; // class CartesianProductGenerator3::Iterator + + // No implementation - assignment is unsupported. + void operator=(const CartesianProductGenerator3& other); + + const ParamGenerator g1_; + const ParamGenerator g2_; + const ParamGenerator g3_; +}; // class CartesianProductGenerator3 + + +template +class CartesianProductGenerator4 + : public ParamGeneratorInterface< ::std::tr1::tuple > { + public: + typedef ::std::tr1::tuple ParamType; + + CartesianProductGenerator4(const ParamGenerator& g1, + const ParamGenerator& g2, const ParamGenerator& g3, + const ParamGenerator& g4) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {} + virtual ~CartesianProductGenerator4() {} + + virtual ParamIteratorInterface* Begin() const { + return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_, + g3_.begin(), g4_, g4_.begin()); + } + virtual ParamIteratorInterface* End() const { + return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(), + g4_, g4_.end()); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, + const ParamGenerator& g1, + const typename ParamGenerator::iterator& current1, + const ParamGenerator& g2, + const typename ParamGenerator::iterator& current2, + const ParamGenerator& g3, + const typename ParamGenerator::iterator& current3, + const ParamGenerator& g4, + const typename ParamGenerator::iterator& current4) + : base_(base), + begin1_(g1.begin()), end1_(g1.end()), current1_(current1), + begin2_(g2.begin()), end2_(g2.end()), current2_(current2), + begin3_(g3.begin()), end3_(g3.end()), current3_(current3), + begin4_(g4.begin()), end4_(g4.end()), current4_(current4) { + ComputeCurrentValue(); + } + virtual ~Iterator() {} + + virtual const ParamGeneratorInterface* BaseGenerator() const { + return base_; + } + // Advance should not be called on beyond-of-range iterators + // so no component iterators must be beyond end of range, either. + virtual void Advance() { + assert(!AtEnd()); + ++current4_; + if (current4_ == end4_) { + current4_ = begin4_; + ++current3_; + } + if (current3_ == end3_) { + current3_ = begin3_; + ++current2_; + } + if (current2_ == end2_) { + current2_ = begin2_; + ++current1_; + } + ComputeCurrentValue(); + } + virtual ParamIteratorInterface* Clone() const { + return new Iterator(*this); + } + virtual const ParamType* Current() const { return ¤t_value_; } + virtual bool Equals(const ParamIteratorInterface& other) const { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const Iterator* typed_other = + CheckedDowncastToActualType(&other); + // We must report iterators equal if they both point beyond their + // respective ranges. That can happen in a variety of fashions, + // so we have to consult AtEnd(). + return (AtEnd() && typed_other->AtEnd()) || + ( + current1_ == typed_other->current1_ && + current2_ == typed_other->current2_ && + current3_ == typed_other->current3_ && + current4_ == typed_other->current4_); + } + + private: + Iterator(const Iterator& other) + : base_(other.base_), + begin1_(other.begin1_), + end1_(other.end1_), + current1_(other.current1_), + begin2_(other.begin2_), + end2_(other.end2_), + current2_(other.current2_), + begin3_(other.begin3_), + end3_(other.end3_), + current3_(other.current3_), + begin4_(other.begin4_), + end4_(other.end4_), + current4_(other.current4_) { + ComputeCurrentValue(); + } + + void ComputeCurrentValue() { + if (!AtEnd()) + current_value_ = ParamType(*current1_, *current2_, *current3_, + *current4_); + } + bool AtEnd() const { + // We must report iterator past the end of the range when either of the + // component iterators has reached the end of its range. + return + current1_ == end1_ || + current2_ == end2_ || + current3_ == end3_ || + current4_ == end4_; + } + + // No implementation - assignment is unsupported. + void operator=(const Iterator& other); + + const ParamGeneratorInterface* const base_; + // begin[i]_ and end[i]_ define the i-th range that Iterator traverses. + // current[i]_ is the actual traversing iterator. + const typename ParamGenerator::iterator begin1_; + const typename ParamGenerator::iterator end1_; + typename ParamGenerator::iterator current1_; + const typename ParamGenerator::iterator begin2_; + const typename ParamGenerator::iterator end2_; + typename ParamGenerator::iterator current2_; + const typename ParamGenerator::iterator begin3_; + const typename ParamGenerator::iterator end3_; + typename ParamGenerator::iterator current3_; + const typename ParamGenerator::iterator begin4_; + const typename ParamGenerator::iterator end4_; + typename ParamGenerator::iterator current4_; + ParamType current_value_; + }; // class CartesianProductGenerator4::Iterator + + // No implementation - assignment is unsupported. + void operator=(const CartesianProductGenerator4& other); + + const ParamGenerator g1_; + const ParamGenerator g2_; + const ParamGenerator g3_; + const ParamGenerator g4_; +}; // class CartesianProductGenerator4 + + +template +class CartesianProductGenerator5 + : public ParamGeneratorInterface< ::std::tr1::tuple > { + public: + typedef ::std::tr1::tuple ParamType; + + CartesianProductGenerator5(const ParamGenerator& g1, + const ParamGenerator& g2, const ParamGenerator& g3, + const ParamGenerator& g4, const ParamGenerator& g5) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {} + virtual ~CartesianProductGenerator5() {} + + virtual ParamIteratorInterface* Begin() const { + return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_, + g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin()); + } + virtual ParamIteratorInterface* End() const { + return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(), + g4_, g4_.end(), g5_, g5_.end()); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, + const ParamGenerator& g1, + const typename ParamGenerator::iterator& current1, + const ParamGenerator& g2, + const typename ParamGenerator::iterator& current2, + const ParamGenerator& g3, + const typename ParamGenerator::iterator& current3, + const ParamGenerator& g4, + const typename ParamGenerator::iterator& current4, + const ParamGenerator& g5, + const typename ParamGenerator::iterator& current5) + : base_(base), + begin1_(g1.begin()), end1_(g1.end()), current1_(current1), + begin2_(g2.begin()), end2_(g2.end()), current2_(current2), + begin3_(g3.begin()), end3_(g3.end()), current3_(current3), + begin4_(g4.begin()), end4_(g4.end()), current4_(current4), + begin5_(g5.begin()), end5_(g5.end()), current5_(current5) { + ComputeCurrentValue(); + } + virtual ~Iterator() {} + + virtual const ParamGeneratorInterface* BaseGenerator() const { + return base_; + } + // Advance should not be called on beyond-of-range iterators + // so no component iterators must be beyond end of range, either. + virtual void Advance() { + assert(!AtEnd()); + ++current5_; + if (current5_ == end5_) { + current5_ = begin5_; + ++current4_; + } + if (current4_ == end4_) { + current4_ = begin4_; + ++current3_; + } + if (current3_ == end3_) { + current3_ = begin3_; + ++current2_; + } + if (current2_ == end2_) { + current2_ = begin2_; + ++current1_; + } + ComputeCurrentValue(); + } + virtual ParamIteratorInterface* Clone() const { + return new Iterator(*this); + } + virtual const ParamType* Current() const { return ¤t_value_; } + virtual bool Equals(const ParamIteratorInterface& other) const { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const Iterator* typed_other = + CheckedDowncastToActualType(&other); + // We must report iterators equal if they both point beyond their + // respective ranges. That can happen in a variety of fashions, + // so we have to consult AtEnd(). + return (AtEnd() && typed_other->AtEnd()) || + ( + current1_ == typed_other->current1_ && + current2_ == typed_other->current2_ && + current3_ == typed_other->current3_ && + current4_ == typed_other->current4_ && + current5_ == typed_other->current5_); + } + + private: + Iterator(const Iterator& other) + : base_(other.base_), + begin1_(other.begin1_), + end1_(other.end1_), + current1_(other.current1_), + begin2_(other.begin2_), + end2_(other.end2_), + current2_(other.current2_), + begin3_(other.begin3_), + end3_(other.end3_), + current3_(other.current3_), + begin4_(other.begin4_), + end4_(other.end4_), + current4_(other.current4_), + begin5_(other.begin5_), + end5_(other.end5_), + current5_(other.current5_) { + ComputeCurrentValue(); + } + + void ComputeCurrentValue() { + if (!AtEnd()) + current_value_ = ParamType(*current1_, *current2_, *current3_, + *current4_, *current5_); + } + bool AtEnd() const { + // We must report iterator past the end of the range when either of the + // component iterators has reached the end of its range. + return + current1_ == end1_ || + current2_ == end2_ || + current3_ == end3_ || + current4_ == end4_ || + current5_ == end5_; + } + + // No implementation - assignment is unsupported. + void operator=(const Iterator& other); + + const ParamGeneratorInterface* const base_; + // begin[i]_ and end[i]_ define the i-th range that Iterator traverses. + // current[i]_ is the actual traversing iterator. + const typename ParamGenerator::iterator begin1_; + const typename ParamGenerator::iterator end1_; + typename ParamGenerator::iterator current1_; + const typename ParamGenerator::iterator begin2_; + const typename ParamGenerator::iterator end2_; + typename ParamGenerator::iterator current2_; + const typename ParamGenerator::iterator begin3_; + const typename ParamGenerator::iterator end3_; + typename ParamGenerator::iterator current3_; + const typename ParamGenerator::iterator begin4_; + const typename ParamGenerator::iterator end4_; + typename ParamGenerator::iterator current4_; + const typename ParamGenerator::iterator begin5_; + const typename ParamGenerator::iterator end5_; + typename ParamGenerator::iterator current5_; + ParamType current_value_; + }; // class CartesianProductGenerator5::Iterator + + // No implementation - assignment is unsupported. + void operator=(const CartesianProductGenerator5& other); + + const ParamGenerator g1_; + const ParamGenerator g2_; + const ParamGenerator g3_; + const ParamGenerator g4_; + const ParamGenerator g5_; +}; // class CartesianProductGenerator5 + + +template +class CartesianProductGenerator6 + : public ParamGeneratorInterface< ::std::tr1::tuple > { + public: + typedef ::std::tr1::tuple ParamType; + + CartesianProductGenerator6(const ParamGenerator& g1, + const ParamGenerator& g2, const ParamGenerator& g3, + const ParamGenerator& g4, const ParamGenerator& g5, + const ParamGenerator& g6) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {} + virtual ~CartesianProductGenerator6() {} + + virtual ParamIteratorInterface* Begin() const { + return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_, + g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin()); + } + virtual ParamIteratorInterface* End() const { + return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(), + g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end()); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, + const ParamGenerator& g1, + const typename ParamGenerator::iterator& current1, + const ParamGenerator& g2, + const typename ParamGenerator::iterator& current2, + const ParamGenerator& g3, + const typename ParamGenerator::iterator& current3, + const ParamGenerator& g4, + const typename ParamGenerator::iterator& current4, + const ParamGenerator& g5, + const typename ParamGenerator::iterator& current5, + const ParamGenerator& g6, + const typename ParamGenerator::iterator& current6) + : base_(base), + begin1_(g1.begin()), end1_(g1.end()), current1_(current1), + begin2_(g2.begin()), end2_(g2.end()), current2_(current2), + begin3_(g3.begin()), end3_(g3.end()), current3_(current3), + begin4_(g4.begin()), end4_(g4.end()), current4_(current4), + begin5_(g5.begin()), end5_(g5.end()), current5_(current5), + begin6_(g6.begin()), end6_(g6.end()), current6_(current6) { + ComputeCurrentValue(); + } + virtual ~Iterator() {} + + virtual const ParamGeneratorInterface* BaseGenerator() const { + return base_; + } + // Advance should not be called on beyond-of-range iterators + // so no component iterators must be beyond end of range, either. + virtual void Advance() { + assert(!AtEnd()); + ++current6_; + if (current6_ == end6_) { + current6_ = begin6_; + ++current5_; + } + if (current5_ == end5_) { + current5_ = begin5_; + ++current4_; + } + if (current4_ == end4_) { + current4_ = begin4_; + ++current3_; + } + if (current3_ == end3_) { + current3_ = begin3_; + ++current2_; + } + if (current2_ == end2_) { + current2_ = begin2_; + ++current1_; + } + ComputeCurrentValue(); + } + virtual ParamIteratorInterface* Clone() const { + return new Iterator(*this); + } + virtual const ParamType* Current() const { return ¤t_value_; } + virtual bool Equals(const ParamIteratorInterface& other) const { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const Iterator* typed_other = + CheckedDowncastToActualType(&other); + // We must report iterators equal if they both point beyond their + // respective ranges. That can happen in a variety of fashions, + // so we have to consult AtEnd(). + return (AtEnd() && typed_other->AtEnd()) || + ( + current1_ == typed_other->current1_ && + current2_ == typed_other->current2_ && + current3_ == typed_other->current3_ && + current4_ == typed_other->current4_ && + current5_ == typed_other->current5_ && + current6_ == typed_other->current6_); + } + + private: + Iterator(const Iterator& other) + : base_(other.base_), + begin1_(other.begin1_), + end1_(other.end1_), + current1_(other.current1_), + begin2_(other.begin2_), + end2_(other.end2_), + current2_(other.current2_), + begin3_(other.begin3_), + end3_(other.end3_), + current3_(other.current3_), + begin4_(other.begin4_), + end4_(other.end4_), + current4_(other.current4_), + begin5_(other.begin5_), + end5_(other.end5_), + current5_(other.current5_), + begin6_(other.begin6_), + end6_(other.end6_), + current6_(other.current6_) { + ComputeCurrentValue(); + } + + void ComputeCurrentValue() { + if (!AtEnd()) + current_value_ = ParamType(*current1_, *current2_, *current3_, + *current4_, *current5_, *current6_); + } + bool AtEnd() const { + // We must report iterator past the end of the range when either of the + // component iterators has reached the end of its range. + return + current1_ == end1_ || + current2_ == end2_ || + current3_ == end3_ || + current4_ == end4_ || + current5_ == end5_ || + current6_ == end6_; + } + + // No implementation - assignment is unsupported. + void operator=(const Iterator& other); + + const ParamGeneratorInterface* const base_; + // begin[i]_ and end[i]_ define the i-th range that Iterator traverses. + // current[i]_ is the actual traversing iterator. + const typename ParamGenerator::iterator begin1_; + const typename ParamGenerator::iterator end1_; + typename ParamGenerator::iterator current1_; + const typename ParamGenerator::iterator begin2_; + const typename ParamGenerator::iterator end2_; + typename ParamGenerator::iterator current2_; + const typename ParamGenerator::iterator begin3_; + const typename ParamGenerator::iterator end3_; + typename ParamGenerator::iterator current3_; + const typename ParamGenerator::iterator begin4_; + const typename ParamGenerator::iterator end4_; + typename ParamGenerator::iterator current4_; + const typename ParamGenerator::iterator begin5_; + const typename ParamGenerator::iterator end5_; + typename ParamGenerator::iterator current5_; + const typename ParamGenerator::iterator begin6_; + const typename ParamGenerator::iterator end6_; + typename ParamGenerator::iterator current6_; + ParamType current_value_; + }; // class CartesianProductGenerator6::Iterator + + // No implementation - assignment is unsupported. + void operator=(const CartesianProductGenerator6& other); + + const ParamGenerator g1_; + const ParamGenerator g2_; + const ParamGenerator g3_; + const ParamGenerator g4_; + const ParamGenerator g5_; + const ParamGenerator g6_; +}; // class CartesianProductGenerator6 + + +template +class CartesianProductGenerator7 + : public ParamGeneratorInterface< ::std::tr1::tuple > { + public: + typedef ::std::tr1::tuple ParamType; + + CartesianProductGenerator7(const ParamGenerator& g1, + const ParamGenerator& g2, const ParamGenerator& g3, + const ParamGenerator& g4, const ParamGenerator& g5, + const ParamGenerator& g6, const ParamGenerator& g7) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {} + virtual ~CartesianProductGenerator7() {} + + virtual ParamIteratorInterface* Begin() const { + return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_, + g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_, + g7_.begin()); + } + virtual ParamIteratorInterface* End() const { + return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(), + g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end()); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, + const ParamGenerator& g1, + const typename ParamGenerator::iterator& current1, + const ParamGenerator& g2, + const typename ParamGenerator::iterator& current2, + const ParamGenerator& g3, + const typename ParamGenerator::iterator& current3, + const ParamGenerator& g4, + const typename ParamGenerator::iterator& current4, + const ParamGenerator& g5, + const typename ParamGenerator::iterator& current5, + const ParamGenerator& g6, + const typename ParamGenerator::iterator& current6, + const ParamGenerator& g7, + const typename ParamGenerator::iterator& current7) + : base_(base), + begin1_(g1.begin()), end1_(g1.end()), current1_(current1), + begin2_(g2.begin()), end2_(g2.end()), current2_(current2), + begin3_(g3.begin()), end3_(g3.end()), current3_(current3), + begin4_(g4.begin()), end4_(g4.end()), current4_(current4), + begin5_(g5.begin()), end5_(g5.end()), current5_(current5), + begin6_(g6.begin()), end6_(g6.end()), current6_(current6), + begin7_(g7.begin()), end7_(g7.end()), current7_(current7) { + ComputeCurrentValue(); + } + virtual ~Iterator() {} + + virtual const ParamGeneratorInterface* BaseGenerator() const { + return base_; + } + // Advance should not be called on beyond-of-range iterators + // so no component iterators must be beyond end of range, either. + virtual void Advance() { + assert(!AtEnd()); + ++current7_; + if (current7_ == end7_) { + current7_ = begin7_; + ++current6_; + } + if (current6_ == end6_) { + current6_ = begin6_; + ++current5_; + } + if (current5_ == end5_) { + current5_ = begin5_; + ++current4_; + } + if (current4_ == end4_) { + current4_ = begin4_; + ++current3_; + } + if (current3_ == end3_) { + current3_ = begin3_; + ++current2_; + } + if (current2_ == end2_) { + current2_ = begin2_; + ++current1_; + } + ComputeCurrentValue(); + } + virtual ParamIteratorInterface* Clone() const { + return new Iterator(*this); + } + virtual const ParamType* Current() const { return ¤t_value_; } + virtual bool Equals(const ParamIteratorInterface& other) const { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const Iterator* typed_other = + CheckedDowncastToActualType(&other); + // We must report iterators equal if they both point beyond their + // respective ranges. That can happen in a variety of fashions, + // so we have to consult AtEnd(). + return (AtEnd() && typed_other->AtEnd()) || + ( + current1_ == typed_other->current1_ && + current2_ == typed_other->current2_ && + current3_ == typed_other->current3_ && + current4_ == typed_other->current4_ && + current5_ == typed_other->current5_ && + current6_ == typed_other->current6_ && + current7_ == typed_other->current7_); + } + + private: + Iterator(const Iterator& other) + : base_(other.base_), + begin1_(other.begin1_), + end1_(other.end1_), + current1_(other.current1_), + begin2_(other.begin2_), + end2_(other.end2_), + current2_(other.current2_), + begin3_(other.begin3_), + end3_(other.end3_), + current3_(other.current3_), + begin4_(other.begin4_), + end4_(other.end4_), + current4_(other.current4_), + begin5_(other.begin5_), + end5_(other.end5_), + current5_(other.current5_), + begin6_(other.begin6_), + end6_(other.end6_), + current6_(other.current6_), + begin7_(other.begin7_), + end7_(other.end7_), + current7_(other.current7_) { + ComputeCurrentValue(); + } + + void ComputeCurrentValue() { + if (!AtEnd()) + current_value_ = ParamType(*current1_, *current2_, *current3_, + *current4_, *current5_, *current6_, *current7_); + } + bool AtEnd() const { + // We must report iterator past the end of the range when either of the + // component iterators has reached the end of its range. + return + current1_ == end1_ || + current2_ == end2_ || + current3_ == end3_ || + current4_ == end4_ || + current5_ == end5_ || + current6_ == end6_ || + current7_ == end7_; + } + + // No implementation - assignment is unsupported. + void operator=(const Iterator& other); + + const ParamGeneratorInterface* const base_; + // begin[i]_ and end[i]_ define the i-th range that Iterator traverses. + // current[i]_ is the actual traversing iterator. + const typename ParamGenerator::iterator begin1_; + const typename ParamGenerator::iterator end1_; + typename ParamGenerator::iterator current1_; + const typename ParamGenerator::iterator begin2_; + const typename ParamGenerator::iterator end2_; + typename ParamGenerator::iterator current2_; + const typename ParamGenerator::iterator begin3_; + const typename ParamGenerator::iterator end3_; + typename ParamGenerator::iterator current3_; + const typename ParamGenerator::iterator begin4_; + const typename ParamGenerator::iterator end4_; + typename ParamGenerator::iterator current4_; + const typename ParamGenerator::iterator begin5_; + const typename ParamGenerator::iterator end5_; + typename ParamGenerator::iterator current5_; + const typename ParamGenerator::iterator begin6_; + const typename ParamGenerator::iterator end6_; + typename ParamGenerator::iterator current6_; + const typename ParamGenerator::iterator begin7_; + const typename ParamGenerator::iterator end7_; + typename ParamGenerator::iterator current7_; + ParamType current_value_; + }; // class CartesianProductGenerator7::Iterator + + // No implementation - assignment is unsupported. + void operator=(const CartesianProductGenerator7& other); + + const ParamGenerator g1_; + const ParamGenerator g2_; + const ParamGenerator g3_; + const ParamGenerator g4_; + const ParamGenerator g5_; + const ParamGenerator g6_; + const ParamGenerator g7_; +}; // class CartesianProductGenerator7 + + +template +class CartesianProductGenerator8 + : public ParamGeneratorInterface< ::std::tr1::tuple > { + public: + typedef ::std::tr1::tuple ParamType; + + CartesianProductGenerator8(const ParamGenerator& g1, + const ParamGenerator& g2, const ParamGenerator& g3, + const ParamGenerator& g4, const ParamGenerator& g5, + const ParamGenerator& g6, const ParamGenerator& g7, + const ParamGenerator& g8) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), + g8_(g8) {} + virtual ~CartesianProductGenerator8() {} + + virtual ParamIteratorInterface* Begin() const { + return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_, + g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_, + g7_.begin(), g8_, g8_.begin()); + } + virtual ParamIteratorInterface* End() const { + return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(), + g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_, + g8_.end()); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, + const ParamGenerator& g1, + const typename ParamGenerator::iterator& current1, + const ParamGenerator& g2, + const typename ParamGenerator::iterator& current2, + const ParamGenerator& g3, + const typename ParamGenerator::iterator& current3, + const ParamGenerator& g4, + const typename ParamGenerator::iterator& current4, + const ParamGenerator& g5, + const typename ParamGenerator::iterator& current5, + const ParamGenerator& g6, + const typename ParamGenerator::iterator& current6, + const ParamGenerator& g7, + const typename ParamGenerator::iterator& current7, + const ParamGenerator& g8, + const typename ParamGenerator::iterator& current8) + : base_(base), + begin1_(g1.begin()), end1_(g1.end()), current1_(current1), + begin2_(g2.begin()), end2_(g2.end()), current2_(current2), + begin3_(g3.begin()), end3_(g3.end()), current3_(current3), + begin4_(g4.begin()), end4_(g4.end()), current4_(current4), + begin5_(g5.begin()), end5_(g5.end()), current5_(current5), + begin6_(g6.begin()), end6_(g6.end()), current6_(current6), + begin7_(g7.begin()), end7_(g7.end()), current7_(current7), + begin8_(g8.begin()), end8_(g8.end()), current8_(current8) { + ComputeCurrentValue(); + } + virtual ~Iterator() {} + + virtual const ParamGeneratorInterface* BaseGenerator() const { + return base_; + } + // Advance should not be called on beyond-of-range iterators + // so no component iterators must be beyond end of range, either. + virtual void Advance() { + assert(!AtEnd()); + ++current8_; + if (current8_ == end8_) { + current8_ = begin8_; + ++current7_; + } + if (current7_ == end7_) { + current7_ = begin7_; + ++current6_; + } + if (current6_ == end6_) { + current6_ = begin6_; + ++current5_; + } + if (current5_ == end5_) { + current5_ = begin5_; + ++current4_; + } + if (current4_ == end4_) { + current4_ = begin4_; + ++current3_; + } + if (current3_ == end3_) { + current3_ = begin3_; + ++current2_; + } + if (current2_ == end2_) { + current2_ = begin2_; + ++current1_; + } + ComputeCurrentValue(); + } + virtual ParamIteratorInterface* Clone() const { + return new Iterator(*this); + } + virtual const ParamType* Current() const { return ¤t_value_; } + virtual bool Equals(const ParamIteratorInterface& other) const { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const Iterator* typed_other = + CheckedDowncastToActualType(&other); + // We must report iterators equal if they both point beyond their + // respective ranges. That can happen in a variety of fashions, + // so we have to consult AtEnd(). + return (AtEnd() && typed_other->AtEnd()) || + ( + current1_ == typed_other->current1_ && + current2_ == typed_other->current2_ && + current3_ == typed_other->current3_ && + current4_ == typed_other->current4_ && + current5_ == typed_other->current5_ && + current6_ == typed_other->current6_ && + current7_ == typed_other->current7_ && + current8_ == typed_other->current8_); + } + + private: + Iterator(const Iterator& other) + : base_(other.base_), + begin1_(other.begin1_), + end1_(other.end1_), + current1_(other.current1_), + begin2_(other.begin2_), + end2_(other.end2_), + current2_(other.current2_), + begin3_(other.begin3_), + end3_(other.end3_), + current3_(other.current3_), + begin4_(other.begin4_), + end4_(other.end4_), + current4_(other.current4_), + begin5_(other.begin5_), + end5_(other.end5_), + current5_(other.current5_), + begin6_(other.begin6_), + end6_(other.end6_), + current6_(other.current6_), + begin7_(other.begin7_), + end7_(other.end7_), + current7_(other.current7_), + begin8_(other.begin8_), + end8_(other.end8_), + current8_(other.current8_) { + ComputeCurrentValue(); + } + + void ComputeCurrentValue() { + if (!AtEnd()) + current_value_ = ParamType(*current1_, *current2_, *current3_, + *current4_, *current5_, *current6_, *current7_, *current8_); + } + bool AtEnd() const { + // We must report iterator past the end of the range when either of the + // component iterators has reached the end of its range. + return + current1_ == end1_ || + current2_ == end2_ || + current3_ == end3_ || + current4_ == end4_ || + current5_ == end5_ || + current6_ == end6_ || + current7_ == end7_ || + current8_ == end8_; + } + + // No implementation - assignment is unsupported. + void operator=(const Iterator& other); + + const ParamGeneratorInterface* const base_; + // begin[i]_ and end[i]_ define the i-th range that Iterator traverses. + // current[i]_ is the actual traversing iterator. + const typename ParamGenerator::iterator begin1_; + const typename ParamGenerator::iterator end1_; + typename ParamGenerator::iterator current1_; + const typename ParamGenerator::iterator begin2_; + const typename ParamGenerator::iterator end2_; + typename ParamGenerator::iterator current2_; + const typename ParamGenerator::iterator begin3_; + const typename ParamGenerator::iterator end3_; + typename ParamGenerator::iterator current3_; + const typename ParamGenerator::iterator begin4_; + const typename ParamGenerator::iterator end4_; + typename ParamGenerator::iterator current4_; + const typename ParamGenerator::iterator begin5_; + const typename ParamGenerator::iterator end5_; + typename ParamGenerator::iterator current5_; + const typename ParamGenerator::iterator begin6_; + const typename ParamGenerator::iterator end6_; + typename ParamGenerator::iterator current6_; + const typename ParamGenerator::iterator begin7_; + const typename ParamGenerator::iterator end7_; + typename ParamGenerator::iterator current7_; + const typename ParamGenerator::iterator begin8_; + const typename ParamGenerator::iterator end8_; + typename ParamGenerator::iterator current8_; + ParamType current_value_; + }; // class CartesianProductGenerator8::Iterator + + // No implementation - assignment is unsupported. + void operator=(const CartesianProductGenerator8& other); + + const ParamGenerator g1_; + const ParamGenerator g2_; + const ParamGenerator g3_; + const ParamGenerator g4_; + const ParamGenerator g5_; + const ParamGenerator g6_; + const ParamGenerator g7_; + const ParamGenerator g8_; +}; // class CartesianProductGenerator8 + + +template +class CartesianProductGenerator9 + : public ParamGeneratorInterface< ::std::tr1::tuple > { + public: + typedef ::std::tr1::tuple ParamType; + + CartesianProductGenerator9(const ParamGenerator& g1, + const ParamGenerator& g2, const ParamGenerator& g3, + const ParamGenerator& g4, const ParamGenerator& g5, + const ParamGenerator& g6, const ParamGenerator& g7, + const ParamGenerator& g8, const ParamGenerator& g9) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8), + g9_(g9) {} + virtual ~CartesianProductGenerator9() {} + + virtual ParamIteratorInterface* Begin() const { + return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_, + g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_, + g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin()); + } + virtual ParamIteratorInterface* End() const { + return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(), + g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_, + g8_.end(), g9_, g9_.end()); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, + const ParamGenerator& g1, + const typename ParamGenerator::iterator& current1, + const ParamGenerator& g2, + const typename ParamGenerator::iterator& current2, + const ParamGenerator& g3, + const typename ParamGenerator::iterator& current3, + const ParamGenerator& g4, + const typename ParamGenerator::iterator& current4, + const ParamGenerator& g5, + const typename ParamGenerator::iterator& current5, + const ParamGenerator& g6, + const typename ParamGenerator::iterator& current6, + const ParamGenerator& g7, + const typename ParamGenerator::iterator& current7, + const ParamGenerator& g8, + const typename ParamGenerator::iterator& current8, + const ParamGenerator& g9, + const typename ParamGenerator::iterator& current9) + : base_(base), + begin1_(g1.begin()), end1_(g1.end()), current1_(current1), + begin2_(g2.begin()), end2_(g2.end()), current2_(current2), + begin3_(g3.begin()), end3_(g3.end()), current3_(current3), + begin4_(g4.begin()), end4_(g4.end()), current4_(current4), + begin5_(g5.begin()), end5_(g5.end()), current5_(current5), + begin6_(g6.begin()), end6_(g6.end()), current6_(current6), + begin7_(g7.begin()), end7_(g7.end()), current7_(current7), + begin8_(g8.begin()), end8_(g8.end()), current8_(current8), + begin9_(g9.begin()), end9_(g9.end()), current9_(current9) { + ComputeCurrentValue(); + } + virtual ~Iterator() {} + + virtual const ParamGeneratorInterface* BaseGenerator() const { + return base_; + } + // Advance should not be called on beyond-of-range iterators + // so no component iterators must be beyond end of range, either. + virtual void Advance() { + assert(!AtEnd()); + ++current9_; + if (current9_ == end9_) { + current9_ = begin9_; + ++current8_; + } + if (current8_ == end8_) { + current8_ = begin8_; + ++current7_; + } + if (current7_ == end7_) { + current7_ = begin7_; + ++current6_; + } + if (current6_ == end6_) { + current6_ = begin6_; + ++current5_; + } + if (current5_ == end5_) { + current5_ = begin5_; + ++current4_; + } + if (current4_ == end4_) { + current4_ = begin4_; + ++current3_; + } + if (current3_ == end3_) { + current3_ = begin3_; + ++current2_; + } + if (current2_ == end2_) { + current2_ = begin2_; + ++current1_; + } + ComputeCurrentValue(); + } + virtual ParamIteratorInterface* Clone() const { + return new Iterator(*this); + } + virtual const ParamType* Current() const { return ¤t_value_; } + virtual bool Equals(const ParamIteratorInterface& other) const { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const Iterator* typed_other = + CheckedDowncastToActualType(&other); + // We must report iterators equal if they both point beyond their + // respective ranges. That can happen in a variety of fashions, + // so we have to consult AtEnd(). + return (AtEnd() && typed_other->AtEnd()) || + ( + current1_ == typed_other->current1_ && + current2_ == typed_other->current2_ && + current3_ == typed_other->current3_ && + current4_ == typed_other->current4_ && + current5_ == typed_other->current5_ && + current6_ == typed_other->current6_ && + current7_ == typed_other->current7_ && + current8_ == typed_other->current8_ && + current9_ == typed_other->current9_); + } + + private: + Iterator(const Iterator& other) + : base_(other.base_), + begin1_(other.begin1_), + end1_(other.end1_), + current1_(other.current1_), + begin2_(other.begin2_), + end2_(other.end2_), + current2_(other.current2_), + begin3_(other.begin3_), + end3_(other.end3_), + current3_(other.current3_), + begin4_(other.begin4_), + end4_(other.end4_), + current4_(other.current4_), + begin5_(other.begin5_), + end5_(other.end5_), + current5_(other.current5_), + begin6_(other.begin6_), + end6_(other.end6_), + current6_(other.current6_), + begin7_(other.begin7_), + end7_(other.end7_), + current7_(other.current7_), + begin8_(other.begin8_), + end8_(other.end8_), + current8_(other.current8_), + begin9_(other.begin9_), + end9_(other.end9_), + current9_(other.current9_) { + ComputeCurrentValue(); + } + + void ComputeCurrentValue() { + if (!AtEnd()) + current_value_ = ParamType(*current1_, *current2_, *current3_, + *current4_, *current5_, *current6_, *current7_, *current8_, + *current9_); + } + bool AtEnd() const { + // We must report iterator past the end of the range when either of the + // component iterators has reached the end of its range. + return + current1_ == end1_ || + current2_ == end2_ || + current3_ == end3_ || + current4_ == end4_ || + current5_ == end5_ || + current6_ == end6_ || + current7_ == end7_ || + current8_ == end8_ || + current9_ == end9_; + } + + // No implementation - assignment is unsupported. + void operator=(const Iterator& other); + + const ParamGeneratorInterface* const base_; + // begin[i]_ and end[i]_ define the i-th range that Iterator traverses. + // current[i]_ is the actual traversing iterator. + const typename ParamGenerator::iterator begin1_; + const typename ParamGenerator::iterator end1_; + typename ParamGenerator::iterator current1_; + const typename ParamGenerator::iterator begin2_; + const typename ParamGenerator::iterator end2_; + typename ParamGenerator::iterator current2_; + const typename ParamGenerator::iterator begin3_; + const typename ParamGenerator::iterator end3_; + typename ParamGenerator::iterator current3_; + const typename ParamGenerator::iterator begin4_; + const typename ParamGenerator::iterator end4_; + typename ParamGenerator::iterator current4_; + const typename ParamGenerator::iterator begin5_; + const typename ParamGenerator::iterator end5_; + typename ParamGenerator::iterator current5_; + const typename ParamGenerator::iterator begin6_; + const typename ParamGenerator::iterator end6_; + typename ParamGenerator::iterator current6_; + const typename ParamGenerator::iterator begin7_; + const typename ParamGenerator::iterator end7_; + typename ParamGenerator::iterator current7_; + const typename ParamGenerator::iterator begin8_; + const typename ParamGenerator::iterator end8_; + typename ParamGenerator::iterator current8_; + const typename ParamGenerator::iterator begin9_; + const typename ParamGenerator::iterator end9_; + typename ParamGenerator::iterator current9_; + ParamType current_value_; + }; // class CartesianProductGenerator9::Iterator + + // No implementation - assignment is unsupported. + void operator=(const CartesianProductGenerator9& other); + + const ParamGenerator g1_; + const ParamGenerator g2_; + const ParamGenerator g3_; + const ParamGenerator g4_; + const ParamGenerator g5_; + const ParamGenerator g6_; + const ParamGenerator g7_; + const ParamGenerator g8_; + const ParamGenerator g9_; +}; // class CartesianProductGenerator9 + + +template +class CartesianProductGenerator10 + : public ParamGeneratorInterface< ::std::tr1::tuple > { + public: + typedef ::std::tr1::tuple ParamType; + + CartesianProductGenerator10(const ParamGenerator& g1, + const ParamGenerator& g2, const ParamGenerator& g3, + const ParamGenerator& g4, const ParamGenerator& g5, + const ParamGenerator& g6, const ParamGenerator& g7, + const ParamGenerator& g8, const ParamGenerator& g9, + const ParamGenerator& g10) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8), + g9_(g9), g10_(g10) {} + virtual ~CartesianProductGenerator10() {} + + virtual ParamIteratorInterface* Begin() const { + return new Iterator(this, g1_, g1_.begin(), g2_, g2_.begin(), g3_, + g3_.begin(), g4_, g4_.begin(), g5_, g5_.begin(), g6_, g6_.begin(), g7_, + g7_.begin(), g8_, g8_.begin(), g9_, g9_.begin(), g10_, g10_.begin()); + } + virtual ParamIteratorInterface* End() const { + return new Iterator(this, g1_, g1_.end(), g2_, g2_.end(), g3_, g3_.end(), + g4_, g4_.end(), g5_, g5_.end(), g6_, g6_.end(), g7_, g7_.end(), g8_, + g8_.end(), g9_, g9_.end(), g10_, g10_.end()); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, + const ParamGenerator& g1, + const typename ParamGenerator::iterator& current1, + const ParamGenerator& g2, + const typename ParamGenerator::iterator& current2, + const ParamGenerator& g3, + const typename ParamGenerator::iterator& current3, + const ParamGenerator& g4, + const typename ParamGenerator::iterator& current4, + const ParamGenerator& g5, + const typename ParamGenerator::iterator& current5, + const ParamGenerator& g6, + const typename ParamGenerator::iterator& current6, + const ParamGenerator& g7, + const typename ParamGenerator::iterator& current7, + const ParamGenerator& g8, + const typename ParamGenerator::iterator& current8, + const ParamGenerator& g9, + const typename ParamGenerator::iterator& current9, + const ParamGenerator& g10, + const typename ParamGenerator::iterator& current10) + : base_(base), + begin1_(g1.begin()), end1_(g1.end()), current1_(current1), + begin2_(g2.begin()), end2_(g2.end()), current2_(current2), + begin3_(g3.begin()), end3_(g3.end()), current3_(current3), + begin4_(g4.begin()), end4_(g4.end()), current4_(current4), + begin5_(g5.begin()), end5_(g5.end()), current5_(current5), + begin6_(g6.begin()), end6_(g6.end()), current6_(current6), + begin7_(g7.begin()), end7_(g7.end()), current7_(current7), + begin8_(g8.begin()), end8_(g8.end()), current8_(current8), + begin9_(g9.begin()), end9_(g9.end()), current9_(current9), + begin10_(g10.begin()), end10_(g10.end()), current10_(current10) { + ComputeCurrentValue(); + } + virtual ~Iterator() {} + + virtual const ParamGeneratorInterface* BaseGenerator() const { + return base_; + } + // Advance should not be called on beyond-of-range iterators + // so no component iterators must be beyond end of range, either. + virtual void Advance() { + assert(!AtEnd()); + ++current10_; + if (current10_ == end10_) { + current10_ = begin10_; + ++current9_; + } + if (current9_ == end9_) { + current9_ = begin9_; + ++current8_; + } + if (current8_ == end8_) { + current8_ = begin8_; + ++current7_; + } + if (current7_ == end7_) { + current7_ = begin7_; + ++current6_; + } + if (current6_ == end6_) { + current6_ = begin6_; + ++current5_; + } + if (current5_ == end5_) { + current5_ = begin5_; + ++current4_; + } + if (current4_ == end4_) { + current4_ = begin4_; + ++current3_; + } + if (current3_ == end3_) { + current3_ = begin3_; + ++current2_; + } + if (current2_ == end2_) { + current2_ = begin2_; + ++current1_; + } + ComputeCurrentValue(); + } + virtual ParamIteratorInterface* Clone() const { + return new Iterator(*this); + } + virtual const ParamType* Current() const { return ¤t_value_; } + virtual bool Equals(const ParamIteratorInterface& other) const { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const Iterator* typed_other = + CheckedDowncastToActualType(&other); + // We must report iterators equal if they both point beyond their + // respective ranges. That can happen in a variety of fashions, + // so we have to consult AtEnd(). + return (AtEnd() && typed_other->AtEnd()) || + ( + current1_ == typed_other->current1_ && + current2_ == typed_other->current2_ && + current3_ == typed_other->current3_ && + current4_ == typed_other->current4_ && + current5_ == typed_other->current5_ && + current6_ == typed_other->current6_ && + current7_ == typed_other->current7_ && + current8_ == typed_other->current8_ && + current9_ == typed_other->current9_ && + current10_ == typed_other->current10_); + } + + private: + Iterator(const Iterator& other) + : base_(other.base_), + begin1_(other.begin1_), + end1_(other.end1_), + current1_(other.current1_), + begin2_(other.begin2_), + end2_(other.end2_), + current2_(other.current2_), + begin3_(other.begin3_), + end3_(other.end3_), + current3_(other.current3_), + begin4_(other.begin4_), + end4_(other.end4_), + current4_(other.current4_), + begin5_(other.begin5_), + end5_(other.end5_), + current5_(other.current5_), + begin6_(other.begin6_), + end6_(other.end6_), + current6_(other.current6_), + begin7_(other.begin7_), + end7_(other.end7_), + current7_(other.current7_), + begin8_(other.begin8_), + end8_(other.end8_), + current8_(other.current8_), + begin9_(other.begin9_), + end9_(other.end9_), + current9_(other.current9_), + begin10_(other.begin10_), + end10_(other.end10_), + current10_(other.current10_) { + ComputeCurrentValue(); + } + + void ComputeCurrentValue() { + if (!AtEnd()) + current_value_ = ParamType(*current1_, *current2_, *current3_, + *current4_, *current5_, *current6_, *current7_, *current8_, + *current9_, *current10_); + } + bool AtEnd() const { + // We must report iterator past the end of the range when either of the + // component iterators has reached the end of its range. + return + current1_ == end1_ || + current2_ == end2_ || + current3_ == end3_ || + current4_ == end4_ || + current5_ == end5_ || + current6_ == end6_ || + current7_ == end7_ || + current8_ == end8_ || + current9_ == end9_ || + current10_ == end10_; + } + + // No implementation - assignment is unsupported. + void operator=(const Iterator& other); + + const ParamGeneratorInterface* const base_; + // begin[i]_ and end[i]_ define the i-th range that Iterator traverses. + // current[i]_ is the actual traversing iterator. + const typename ParamGenerator::iterator begin1_; + const typename ParamGenerator::iterator end1_; + typename ParamGenerator::iterator current1_; + const typename ParamGenerator::iterator begin2_; + const typename ParamGenerator::iterator end2_; + typename ParamGenerator::iterator current2_; + const typename ParamGenerator::iterator begin3_; + const typename ParamGenerator::iterator end3_; + typename ParamGenerator::iterator current3_; + const typename ParamGenerator::iterator begin4_; + const typename ParamGenerator::iterator end4_; + typename ParamGenerator::iterator current4_; + const typename ParamGenerator::iterator begin5_; + const typename ParamGenerator::iterator end5_; + typename ParamGenerator::iterator current5_; + const typename ParamGenerator::iterator begin6_; + const typename ParamGenerator::iterator end6_; + typename ParamGenerator::iterator current6_; + const typename ParamGenerator::iterator begin7_; + const typename ParamGenerator::iterator end7_; + typename ParamGenerator::iterator current7_; + const typename ParamGenerator::iterator begin8_; + const typename ParamGenerator::iterator end8_; + typename ParamGenerator::iterator current8_; + const typename ParamGenerator::iterator begin9_; + const typename ParamGenerator::iterator end9_; + typename ParamGenerator::iterator current9_; + const typename ParamGenerator::iterator begin10_; + const typename ParamGenerator::iterator end10_; + typename ParamGenerator::iterator current10_; + ParamType current_value_; + }; // class CartesianProductGenerator10::Iterator + + // No implementation - assignment is unsupported. + void operator=(const CartesianProductGenerator10& other); + + const ParamGenerator g1_; + const ParamGenerator g2_; + const ParamGenerator g3_; + const ParamGenerator g4_; + const ParamGenerator g5_; + const ParamGenerator g6_; + const ParamGenerator g7_; + const ParamGenerator g8_; + const ParamGenerator g9_; + const ParamGenerator g10_; +}; // class CartesianProductGenerator10 + + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Helper classes providing Combine() with polymorphic features. They allow +// casting CartesianProductGeneratorN to ParamGenerator if T is +// convertible to U. +// +template +class CartesianProductHolder2 { + public: +CartesianProductHolder2(const Generator1& g1, const Generator2& g2) + : g1_(g1), g2_(g2) {} + template + operator ParamGenerator< ::std::tr1::tuple >() const { + return ParamGenerator< ::std::tr1::tuple >( + new CartesianProductGenerator2( + static_cast >(g1_), + static_cast >(g2_))); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const CartesianProductHolder2& other); + + const Generator1 g1_; + const Generator2 g2_; +}; // class CartesianProductHolder2 + +template +class CartesianProductHolder3 { + public: +CartesianProductHolder3(const Generator1& g1, const Generator2& g2, + const Generator3& g3) + : g1_(g1), g2_(g2), g3_(g3) {} + template + operator ParamGenerator< ::std::tr1::tuple >() const { + return ParamGenerator< ::std::tr1::tuple >( + new CartesianProductGenerator3( + static_cast >(g1_), + static_cast >(g2_), + static_cast >(g3_))); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const CartesianProductHolder3& other); + + const Generator1 g1_; + const Generator2 g2_; + const Generator3 g3_; +}; // class CartesianProductHolder3 + +template +class CartesianProductHolder4 { + public: +CartesianProductHolder4(const Generator1& g1, const Generator2& g2, + const Generator3& g3, const Generator4& g4) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4) {} + template + operator ParamGenerator< ::std::tr1::tuple >() const { + return ParamGenerator< ::std::tr1::tuple >( + new CartesianProductGenerator4( + static_cast >(g1_), + static_cast >(g2_), + static_cast >(g3_), + static_cast >(g4_))); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const CartesianProductHolder4& other); + + const Generator1 g1_; + const Generator2 g2_; + const Generator3 g3_; + const Generator4 g4_; +}; // class CartesianProductHolder4 + +template +class CartesianProductHolder5 { + public: +CartesianProductHolder5(const Generator1& g1, const Generator2& g2, + const Generator3& g3, const Generator4& g4, const Generator5& g5) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5) {} + template + operator ParamGenerator< ::std::tr1::tuple >() const { + return ParamGenerator< ::std::tr1::tuple >( + new CartesianProductGenerator5( + static_cast >(g1_), + static_cast >(g2_), + static_cast >(g3_), + static_cast >(g4_), + static_cast >(g5_))); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const CartesianProductHolder5& other); + + const Generator1 g1_; + const Generator2 g2_; + const Generator3 g3_; + const Generator4 g4_; + const Generator5 g5_; +}; // class CartesianProductHolder5 + +template +class CartesianProductHolder6 { + public: +CartesianProductHolder6(const Generator1& g1, const Generator2& g2, + const Generator3& g3, const Generator4& g4, const Generator5& g5, + const Generator6& g6) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6) {} + template + operator ParamGenerator< ::std::tr1::tuple >() const { + return ParamGenerator< ::std::tr1::tuple >( + new CartesianProductGenerator6( + static_cast >(g1_), + static_cast >(g2_), + static_cast >(g3_), + static_cast >(g4_), + static_cast >(g5_), + static_cast >(g6_))); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const CartesianProductHolder6& other); + + const Generator1 g1_; + const Generator2 g2_; + const Generator3 g3_; + const Generator4 g4_; + const Generator5 g5_; + const Generator6 g6_; +}; // class CartesianProductHolder6 + +template +class CartesianProductHolder7 { + public: +CartesianProductHolder7(const Generator1& g1, const Generator2& g2, + const Generator3& g3, const Generator4& g4, const Generator5& g5, + const Generator6& g6, const Generator7& g7) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7) {} + template + operator ParamGenerator< ::std::tr1::tuple >() const { + return ParamGenerator< ::std::tr1::tuple >( + new CartesianProductGenerator7( + static_cast >(g1_), + static_cast >(g2_), + static_cast >(g3_), + static_cast >(g4_), + static_cast >(g5_), + static_cast >(g6_), + static_cast >(g7_))); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const CartesianProductHolder7& other); + + const Generator1 g1_; + const Generator2 g2_; + const Generator3 g3_; + const Generator4 g4_; + const Generator5 g5_; + const Generator6 g6_; + const Generator7 g7_; +}; // class CartesianProductHolder7 + +template +class CartesianProductHolder8 { + public: +CartesianProductHolder8(const Generator1& g1, const Generator2& g2, + const Generator3& g3, const Generator4& g4, const Generator5& g5, + const Generator6& g6, const Generator7& g7, const Generator8& g8) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), + g8_(g8) {} + template + operator ParamGenerator< ::std::tr1::tuple >() const { + return ParamGenerator< ::std::tr1::tuple >( + new CartesianProductGenerator8( + static_cast >(g1_), + static_cast >(g2_), + static_cast >(g3_), + static_cast >(g4_), + static_cast >(g5_), + static_cast >(g6_), + static_cast >(g7_), + static_cast >(g8_))); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const CartesianProductHolder8& other); + + const Generator1 g1_; + const Generator2 g2_; + const Generator3 g3_; + const Generator4 g4_; + const Generator5 g5_; + const Generator6 g6_; + const Generator7 g7_; + const Generator8 g8_; +}; // class CartesianProductHolder8 + +template +class CartesianProductHolder9 { + public: +CartesianProductHolder9(const Generator1& g1, const Generator2& g2, + const Generator3& g3, const Generator4& g4, const Generator5& g5, + const Generator6& g6, const Generator7& g7, const Generator8& g8, + const Generator9& g9) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8), + g9_(g9) {} + template + operator ParamGenerator< ::std::tr1::tuple >() const { + return ParamGenerator< ::std::tr1::tuple >( + new CartesianProductGenerator9( + static_cast >(g1_), + static_cast >(g2_), + static_cast >(g3_), + static_cast >(g4_), + static_cast >(g5_), + static_cast >(g6_), + static_cast >(g7_), + static_cast >(g8_), + static_cast >(g9_))); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const CartesianProductHolder9& other); + + const Generator1 g1_; + const Generator2 g2_; + const Generator3 g3_; + const Generator4 g4_; + const Generator5 g5_; + const Generator6 g6_; + const Generator7 g7_; + const Generator8 g8_; + const Generator9 g9_; +}; // class CartesianProductHolder9 + +template +class CartesianProductHolder10 { + public: +CartesianProductHolder10(const Generator1& g1, const Generator2& g2, + const Generator3& g3, const Generator4& g4, const Generator5& g5, + const Generator6& g6, const Generator7& g7, const Generator8& g8, + const Generator9& g9, const Generator10& g10) + : g1_(g1), g2_(g2), g3_(g3), g4_(g4), g5_(g5), g6_(g6), g7_(g7), g8_(g8), + g9_(g9), g10_(g10) {} + template + operator ParamGenerator< ::std::tr1::tuple >() const { + return ParamGenerator< ::std::tr1::tuple >( + new CartesianProductGenerator10( + static_cast >(g1_), + static_cast >(g2_), + static_cast >(g3_), + static_cast >(g4_), + static_cast >(g5_), + static_cast >(g6_), + static_cast >(g7_), + static_cast >(g8_), + static_cast >(g9_), + static_cast >(g10_))); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const CartesianProductHolder10& other); + + const Generator1 g1_; + const Generator2 g2_; + const Generator3 g3_; + const Generator4 g4_; + const Generator5 g5_; + const Generator6 g6_; + const Generator7 g7_; + const Generator8 g8_; + const Generator9 g9_; + const Generator10 g10_; +}; // class CartesianProductHolder10 + +# endif // GTEST_HAS_COMBINE + +} // namespace internal +} // namespace testing + +#endif // GTEST_HAS_PARAM_TEST + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h.pump b/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h.pump new file mode 100644 index 00000000000..009206fd319 --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-param-util-generated.h.pump @@ -0,0 +1,301 @@ +$$ -*- mode: c++; -*- +$var n = 50 $$ Maximum length of Values arguments we want to support. +$var maxtuple = 10 $$ Maximum number of Combine arguments we want to support. +// Copyright 2008 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: vladl@google.com (Vlad Losev) + +// Type and function utilities for implementing parameterized tests. +// This file is generated by a SCRIPT. DO NOT EDIT BY HAND! +// +// Currently Google Test supports at most $n arguments in Values, +// and at most $maxtuple arguments in Combine. Please contact +// googletestframework@googlegroups.com if you need more. +// Please note that the number of arguments to Combine is limited +// by the maximum arity of the implementation of tr1::tuple which is +// currently set at $maxtuple. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ + +// scripts/fuse_gtest.py depends on gtest's own header being #included +// *unconditionally*. Therefore these #includes cannot be moved +// inside #if GTEST_HAS_PARAM_TEST. +#include "gtest/internal/gtest-param-util.h" +#include "gtest/internal/gtest-port.h" + +#if GTEST_HAS_PARAM_TEST + +namespace testing { + +// Forward declarations of ValuesIn(), which is implemented in +// include/gtest/gtest-param-test.h. +template +internal::ParamGenerator< + typename ::testing::internal::IteratorTraits::value_type> +ValuesIn(ForwardIterator begin, ForwardIterator end); + +template +internal::ParamGenerator ValuesIn(const T (&array)[N]); + +template +internal::ParamGenerator ValuesIn( + const Container& container); + +namespace internal { + +// Used in the Values() function to provide polymorphic capabilities. +template +class ValueArray1 { + public: + explicit ValueArray1(T1 v1) : v1_(v1) {} + + template + operator ParamGenerator() const { return ValuesIn(&v1_, &v1_ + 1); } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray1& other); + + const T1 v1_; +}; + +$range i 2..n +$for i [[ +$range j 1..i + +template <$for j, [[typename T$j]]> +class ValueArray$i { + public: + ValueArray$i($for j, [[T$j v$j]]) : $for j, [[v$(j)_(v$j)]] {} + + template + operator ParamGenerator() const { + const T array[] = {$for j, [[static_cast(v$(j)_)]]}; + return ValuesIn(array); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const ValueArray$i& other); + +$for j [[ + + const T$j v$(j)_; +]] + +}; + +]] + +# if GTEST_HAS_COMBINE +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Generates values from the Cartesian product of values produced +// by the argument generators. +// +$range i 2..maxtuple +$for i [[ +$range j 1..i +$range k 2..i + +template <$for j, [[typename T$j]]> +class CartesianProductGenerator$i + : public ParamGeneratorInterface< ::std::tr1::tuple<$for j, [[T$j]]> > { + public: + typedef ::std::tr1::tuple<$for j, [[T$j]]> ParamType; + + CartesianProductGenerator$i($for j, [[const ParamGenerator& g$j]]) + : $for j, [[g$(j)_(g$j)]] {} + virtual ~CartesianProductGenerator$i() {} + + virtual ParamIteratorInterface* Begin() const { + return new Iterator(this, $for j, [[g$(j)_, g$(j)_.begin()]]); + } + virtual ParamIteratorInterface* End() const { + return new Iterator(this, $for j, [[g$(j)_, g$(j)_.end()]]); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, $for j, [[ + + const ParamGenerator& g$j, + const typename ParamGenerator::iterator& current$(j)]]) + : base_(base), +$for j, [[ + + begin$(j)_(g$j.begin()), end$(j)_(g$j.end()), current$(j)_(current$j) +]] { + ComputeCurrentValue(); + } + virtual ~Iterator() {} + + virtual const ParamGeneratorInterface* BaseGenerator() const { + return base_; + } + // Advance should not be called on beyond-of-range iterators + // so no component iterators must be beyond end of range, either. + virtual void Advance() { + assert(!AtEnd()); + ++current$(i)_; + +$for k [[ + if (current$(i+2-k)_ == end$(i+2-k)_) { + current$(i+2-k)_ = begin$(i+2-k)_; + ++current$(i+2-k-1)_; + } + +]] + ComputeCurrentValue(); + } + virtual ParamIteratorInterface* Clone() const { + return new Iterator(*this); + } + virtual const ParamType* Current() const { return ¤t_value_; } + virtual bool Equals(const ParamIteratorInterface& other) const { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const Iterator* typed_other = + CheckedDowncastToActualType(&other); + // We must report iterators equal if they both point beyond their + // respective ranges. That can happen in a variety of fashions, + // so we have to consult AtEnd(). + return (AtEnd() && typed_other->AtEnd()) || + ($for j && [[ + + current$(j)_ == typed_other->current$(j)_ +]]); + } + + private: + Iterator(const Iterator& other) + : base_(other.base_), $for j, [[ + + begin$(j)_(other.begin$(j)_), + end$(j)_(other.end$(j)_), + current$(j)_(other.current$(j)_) +]] { + ComputeCurrentValue(); + } + + void ComputeCurrentValue() { + if (!AtEnd()) + current_value_ = ParamType($for j, [[*current$(j)_]]); + } + bool AtEnd() const { + // We must report iterator past the end of the range when either of the + // component iterators has reached the end of its range. + return +$for j || [[ + + current$(j)_ == end$(j)_ +]]; + } + + // No implementation - assignment is unsupported. + void operator=(const Iterator& other); + + const ParamGeneratorInterface* const base_; + // begin[i]_ and end[i]_ define the i-th range that Iterator traverses. + // current[i]_ is the actual traversing iterator. +$for j [[ + + const typename ParamGenerator::iterator begin$(j)_; + const typename ParamGenerator::iterator end$(j)_; + typename ParamGenerator::iterator current$(j)_; +]] + + ParamType current_value_; + }; // class CartesianProductGenerator$i::Iterator + + // No implementation - assignment is unsupported. + void operator=(const CartesianProductGenerator$i& other); + + +$for j [[ + const ParamGenerator g$(j)_; + +]] +}; // class CartesianProductGenerator$i + + +]] + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Helper classes providing Combine() with polymorphic features. They allow +// casting CartesianProductGeneratorN to ParamGenerator if T is +// convertible to U. +// +$range i 2..maxtuple +$for i [[ +$range j 1..i + +template <$for j, [[class Generator$j]]> +class CartesianProductHolder$i { + public: +CartesianProductHolder$i($for j, [[const Generator$j& g$j]]) + : $for j, [[g$(j)_(g$j)]] {} + template <$for j, [[typename T$j]]> + operator ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >() const { + return ParamGenerator< ::std::tr1::tuple<$for j, [[T$j]]> >( + new CartesianProductGenerator$i<$for j, [[T$j]]>( +$for j,[[ + + static_cast >(g$(j)_) +]])); + } + + private: + // No implementation - assignment is unsupported. + void operator=(const CartesianProductHolder$i& other); + + +$for j [[ + const Generator$j g$(j)_; + +]] +}; // class CartesianProductHolder$i + +]] + +# endif // GTEST_HAS_COMBINE + +} // namespace internal +} // namespace testing + +#endif // GTEST_HAS_PARAM_TEST + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_GENERATED_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-param-util.h b/test/fmw/gtest/include/gtest/internal/gtest-param-util.h new file mode 100644 index 00000000000..d5e1028b0c1 --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-param-util.h @@ -0,0 +1,619 @@ +// Copyright 2008 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: vladl@google.com (Vlad Losev) + +// Type and function utilities for implementing parameterized tests. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ + +#include +#include +#include + +// scripts/fuse_gtest.py depends on gtest's own header being #included +// *unconditionally*. Therefore these #includes cannot be moved +// inside #if GTEST_HAS_PARAM_TEST. +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-linked_ptr.h" +#include "gtest/internal/gtest-port.h" +#include "gtest/gtest-printers.h" + +#if GTEST_HAS_PARAM_TEST + +namespace testing { +namespace internal { + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Outputs a message explaining invalid registration of different +// fixture class for the same test case. This may happen when +// TEST_P macro is used to define two tests with the same name +// but in different namespaces. +GTEST_API_ void ReportInvalidTestCaseType(const char* test_case_name, + const char* file, int line); + +template class ParamGeneratorInterface; +template class ParamGenerator; + +// Interface for iterating over elements provided by an implementation +// of ParamGeneratorInterface. +template +class ParamIteratorInterface { + public: + virtual ~ParamIteratorInterface() {} + // A pointer to the base generator instance. + // Used only for the purposes of iterator comparison + // to make sure that two iterators belong to the same generator. + virtual const ParamGeneratorInterface* BaseGenerator() const = 0; + // Advances iterator to point to the next element + // provided by the generator. The caller is responsible + // for not calling Advance() on an iterator equal to + // BaseGenerator()->End(). + virtual void Advance() = 0; + // Clones the iterator object. Used for implementing copy semantics + // of ParamIterator. + virtual ParamIteratorInterface* Clone() const = 0; + // Dereferences the current iterator and provides (read-only) access + // to the pointed value. It is the caller's responsibility not to call + // Current() on an iterator equal to BaseGenerator()->End(). + // Used for implementing ParamGenerator::operator*(). + virtual const T* Current() const = 0; + // Determines whether the given iterator and other point to the same + // element in the sequence generated by the generator. + // Used for implementing ParamGenerator::operator==(). + virtual bool Equals(const ParamIteratorInterface& other) const = 0; +}; + +// Class iterating over elements provided by an implementation of +// ParamGeneratorInterface. It wraps ParamIteratorInterface +// and implements the const forward iterator concept. +template +class ParamIterator { + public: + typedef T value_type; + typedef const T& reference; + typedef ptrdiff_t difference_type; + + // ParamIterator assumes ownership of the impl_ pointer. + ParamIterator(const ParamIterator& other) : impl_(other.impl_->Clone()) {} + ParamIterator& operator=(const ParamIterator& other) { + if (this != &other) + impl_.reset(other.impl_->Clone()); + return *this; + } + + const T& operator*() const { return *impl_->Current(); } + const T* operator->() const { return impl_->Current(); } + // Prefix version of operator++. + ParamIterator& operator++() { + impl_->Advance(); + return *this; + } + // Postfix version of operator++. + ParamIterator operator++(int /*unused*/) { + ParamIteratorInterface* clone = impl_->Clone(); + impl_->Advance(); + return ParamIterator(clone); + } + bool operator==(const ParamIterator& other) const { + return impl_.get() == other.impl_.get() || impl_->Equals(*other.impl_); + } + bool operator!=(const ParamIterator& other) const { + return !(*this == other); + } + + private: + friend class ParamGenerator; + explicit ParamIterator(ParamIteratorInterface* impl) : impl_(impl) {} + scoped_ptr > impl_; +}; + +// ParamGeneratorInterface is the binary interface to access generators +// defined in other translation units. +template +class ParamGeneratorInterface { + public: + typedef T ParamType; + + virtual ~ParamGeneratorInterface() {} + + // Generator interface definition + virtual ParamIteratorInterface* Begin() const = 0; + virtual ParamIteratorInterface* End() const = 0; +}; + +// Wraps ParamGeneratorInterface and provides general generator syntax +// compatible with the STL Container concept. +// This class implements copy initialization semantics and the contained +// ParamGeneratorInterface instance is shared among all copies +// of the original object. This is possible because that instance is immutable. +template +class ParamGenerator { + public: + typedef ParamIterator iterator; + + explicit ParamGenerator(ParamGeneratorInterface* impl) : impl_(impl) {} + ParamGenerator(const ParamGenerator& other) : impl_(other.impl_) {} + + ParamGenerator& operator=(const ParamGenerator& other) { + impl_ = other.impl_; + return *this; + } + + iterator begin() const { return iterator(impl_->Begin()); } + iterator end() const { return iterator(impl_->End()); } + + private: + linked_ptr > impl_; +}; + +// Generates values from a range of two comparable values. Can be used to +// generate sequences of user-defined types that implement operator+() and +// operator<(). +// This class is used in the Range() function. +template +class RangeGenerator : public ParamGeneratorInterface { + public: + RangeGenerator(T begin, T end, IncrementT step) + : begin_(begin), end_(end), + step_(step), end_index_(CalculateEndIndex(begin, end, step)) {} + virtual ~RangeGenerator() {} + + virtual ParamIteratorInterface* Begin() const { + return new Iterator(this, begin_, 0, step_); + } + virtual ParamIteratorInterface* End() const { + return new Iterator(this, end_, end_index_, step_); + } + + private: + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, T value, int index, + IncrementT step) + : base_(base), value_(value), index_(index), step_(step) {} + virtual ~Iterator() {} + + virtual const ParamGeneratorInterface* BaseGenerator() const { + return base_; + } + virtual void Advance() { + value_ = value_ + step_; + index_++; + } + virtual ParamIteratorInterface* Clone() const { + return new Iterator(*this); + } + virtual const T* Current() const { return &value_; } + virtual bool Equals(const ParamIteratorInterface& other) const { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + const int other_index = + CheckedDowncastToActualType(&other)->index_; + return index_ == other_index; + } + + private: + Iterator(const Iterator& other) + : ParamIteratorInterface(), + base_(other.base_), value_(other.value_), index_(other.index_), + step_(other.step_) {} + + // No implementation - assignment is unsupported. + void operator=(const Iterator& other); + + const ParamGeneratorInterface* const base_; + T value_; + int index_; + const IncrementT step_; + }; // class RangeGenerator::Iterator + + static int CalculateEndIndex(const T& begin, + const T& end, + const IncrementT& step) { + int end_index = 0; + for (T i = begin; i < end; i = i + step) + end_index++; + return end_index; + } + + // No implementation - assignment is unsupported. + void operator=(const RangeGenerator& other); + + const T begin_; + const T end_; + const IncrementT step_; + // The index for the end() iterator. All the elements in the generated + // sequence are indexed (0-based) to aid iterator comparison. + const int end_index_; +}; // class RangeGenerator + + +// Generates values from a pair of STL-style iterators. Used in the +// ValuesIn() function. The elements are copied from the source range +// since the source can be located on the stack, and the generator +// is likely to persist beyond that stack frame. +template +class ValuesInIteratorRangeGenerator : public ParamGeneratorInterface { + public: + template + ValuesInIteratorRangeGenerator(ForwardIterator begin, ForwardIterator end) + : container_(begin, end) {} + virtual ~ValuesInIteratorRangeGenerator() {} + + virtual ParamIteratorInterface* Begin() const { + return new Iterator(this, container_.begin()); + } + virtual ParamIteratorInterface* End() const { + return new Iterator(this, container_.end()); + } + + private: + typedef typename ::std::vector ContainerType; + + class Iterator : public ParamIteratorInterface { + public: + Iterator(const ParamGeneratorInterface* base, + typename ContainerType::const_iterator iterator) + : base_(base), iterator_(iterator) {} + virtual ~Iterator() {} + + virtual const ParamGeneratorInterface* BaseGenerator() const { + return base_; + } + virtual void Advance() { + ++iterator_; + value_.reset(); + } + virtual ParamIteratorInterface* Clone() const { + return new Iterator(*this); + } + // We need to use cached value referenced by iterator_ because *iterator_ + // can return a temporary object (and of type other then T), so just + // having "return &*iterator_;" doesn't work. + // value_ is updated here and not in Advance() because Advance() + // can advance iterator_ beyond the end of the range, and we cannot + // detect that fact. The client code, on the other hand, is + // responsible for not calling Current() on an out-of-range iterator. + virtual const T* Current() const { + if (value_.get() == NULL) + value_.reset(new T(*iterator_)); + return value_.get(); + } + virtual bool Equals(const ParamIteratorInterface& other) const { + // Having the same base generator guarantees that the other + // iterator is of the same type and we can downcast. + GTEST_CHECK_(BaseGenerator() == other.BaseGenerator()) + << "The program attempted to compare iterators " + << "from different generators." << std::endl; + return iterator_ == + CheckedDowncastToActualType(&other)->iterator_; + } + + private: + Iterator(const Iterator& other) + // The explicit constructor call suppresses a false warning + // emitted by gcc when supplied with the -Wextra option. + : ParamIteratorInterface(), + base_(other.base_), + iterator_(other.iterator_) {} + + const ParamGeneratorInterface* const base_; + typename ContainerType::const_iterator iterator_; + // A cached value of *iterator_. We keep it here to allow access by + // pointer in the wrapping iterator's operator->(). + // value_ needs to be mutable to be accessed in Current(). + // Use of scoped_ptr helps manage cached value's lifetime, + // which is bound by the lifespan of the iterator itself. + mutable scoped_ptr value_; + }; // class ValuesInIteratorRangeGenerator::Iterator + + // No implementation - assignment is unsupported. + void operator=(const ValuesInIteratorRangeGenerator& other); + + const ContainerType container_; +}; // class ValuesInIteratorRangeGenerator + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Stores a parameter value and later creates tests parameterized with that +// value. +template +class ParameterizedTestFactory : public TestFactoryBase { + public: + typedef typename TestClass::ParamType ParamType; + explicit ParameterizedTestFactory(ParamType parameter) : + parameter_(parameter) {} + virtual Test* CreateTest() { + TestClass::SetParam(¶meter_); + return new TestClass(); + } + + private: + const ParamType parameter_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestFactory); +}; + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// TestMetaFactoryBase is a base class for meta-factories that create +// test factories for passing into MakeAndRegisterTestInfo function. +template +class TestMetaFactoryBase { + public: + virtual ~TestMetaFactoryBase() {} + + virtual TestFactoryBase* CreateTestFactory(ParamType parameter) = 0; +}; + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// TestMetaFactory creates test factories for passing into +// MakeAndRegisterTestInfo function. Since MakeAndRegisterTestInfo receives +// ownership of test factory pointer, same factory object cannot be passed +// into that method twice. But ParameterizedTestCaseInfo is going to call +// it for each Test/Parameter value combination. Thus it needs meta factory +// creator class. +template +class TestMetaFactory + : public TestMetaFactoryBase { + public: + typedef typename TestCase::ParamType ParamType; + + TestMetaFactory() {} + + virtual TestFactoryBase* CreateTestFactory(ParamType parameter) { + return new ParameterizedTestFactory(parameter); + } + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestMetaFactory); +}; + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// ParameterizedTestCaseInfoBase is a generic interface +// to ParameterizedTestCaseInfo classes. ParameterizedTestCaseInfoBase +// accumulates test information provided by TEST_P macro invocations +// and generators provided by INSTANTIATE_TEST_CASE_P macro invocations +// and uses that information to register all resulting test instances +// in RegisterTests method. The ParameterizeTestCaseRegistry class holds +// a collection of pointers to the ParameterizedTestCaseInfo objects +// and calls RegisterTests() on each of them when asked. +class ParameterizedTestCaseInfoBase { + public: + virtual ~ParameterizedTestCaseInfoBase() {} + + // Base part of test case name for display purposes. + virtual const string& GetTestCaseName() const = 0; + // Test case id to verify identity. + virtual TypeId GetTestCaseTypeId() const = 0; + // UnitTest class invokes this method to register tests in this + // test case right before running them in RUN_ALL_TESTS macro. + // This method should not be called more then once on any single + // instance of a ParameterizedTestCaseInfoBase derived class. + virtual void RegisterTests() = 0; + + protected: + ParameterizedTestCaseInfoBase() {} + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfoBase); +}; + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// ParameterizedTestCaseInfo accumulates tests obtained from TEST_P +// macro invocations for a particular test case and generators +// obtained from INSTANTIATE_TEST_CASE_P macro invocations for that +// test case. It registers tests with all values generated by all +// generators when asked. +template +class ParameterizedTestCaseInfo : public ParameterizedTestCaseInfoBase { + public: + // ParamType and GeneratorCreationFunc are private types but are required + // for declarations of public methods AddTestPattern() and + // AddTestCaseInstantiation(). + typedef typename TestCase::ParamType ParamType; + // A function that returns an instance of appropriate generator type. + typedef ParamGenerator(GeneratorCreationFunc)(); + + explicit ParameterizedTestCaseInfo(const char* name) + : test_case_name_(name) {} + + // Test case base name for display purposes. + virtual const string& GetTestCaseName() const { return test_case_name_; } + // Test case id to verify identity. + virtual TypeId GetTestCaseTypeId() const { return GetTypeId(); } + // TEST_P macro uses AddTestPattern() to record information + // about a single test in a LocalTestInfo structure. + // test_case_name is the base name of the test case (without invocation + // prefix). test_base_name is the name of an individual test without + // parameter index. For the test SequenceA/FooTest.DoBar/1 FooTest is + // test case base name and DoBar is test base name. + void AddTestPattern(const char* test_case_name, + const char* test_base_name, + TestMetaFactoryBase* meta_factory) { + tests_.push_back(linked_ptr(new TestInfo(test_case_name, + test_base_name, + meta_factory))); + } + // INSTANTIATE_TEST_CASE_P macro uses AddGenerator() to record information + // about a generator. + int AddTestCaseInstantiation(const string& instantiation_name, + GeneratorCreationFunc* func, + const char* /* file */, + int /* line */) { + instantiations_.push_back(::std::make_pair(instantiation_name, func)); + return 0; // Return value used only to run this method in namespace scope. + } + // UnitTest class invokes this method to register tests in this test case + // test cases right before running tests in RUN_ALL_TESTS macro. + // This method should not be called more then once on any single + // instance of a ParameterizedTestCaseInfoBase derived class. + // UnitTest has a guard to prevent from calling this method more then once. + virtual void RegisterTests() { + for (typename TestInfoContainer::iterator test_it = tests_.begin(); + test_it != tests_.end(); ++test_it) { + linked_ptr test_info = *test_it; + for (typename InstantiationContainer::iterator gen_it = + instantiations_.begin(); gen_it != instantiations_.end(); + ++gen_it) { + const string& instantiation_name = gen_it->first; + ParamGenerator generator((*gen_it->second)()); + + string test_case_name; + if ( !instantiation_name.empty() ) + test_case_name = instantiation_name + "/"; + test_case_name += test_info->test_case_base_name; + + int i = 0; + for (typename ParamGenerator::iterator param_it = + generator.begin(); + param_it != generator.end(); ++param_it, ++i) { + Message test_name_stream; + test_name_stream << test_info->test_base_name << "/" << i; + MakeAndRegisterTestInfo( + test_case_name.c_str(), + test_name_stream.GetString().c_str(), + NULL, // No type parameter. + PrintToString(*param_it).c_str(), + GetTestCaseTypeId(), + TestCase::SetUpTestCase, + TestCase::TearDownTestCase, + test_info->test_meta_factory->CreateTestFactory(*param_it)); + } // for param_it + } // for gen_it + } // for test_it + } // RegisterTests + + private: + // LocalTestInfo structure keeps information about a single test registered + // with TEST_P macro. + struct TestInfo { + TestInfo(const char* a_test_case_base_name, + const char* a_test_base_name, + TestMetaFactoryBase* a_test_meta_factory) : + test_case_base_name(a_test_case_base_name), + test_base_name(a_test_base_name), + test_meta_factory(a_test_meta_factory) {} + + const string test_case_base_name; + const string test_base_name; + const scoped_ptr > test_meta_factory; + }; + typedef ::std::vector > TestInfoContainer; + // Keeps pairs of + // received from INSTANTIATE_TEST_CASE_P macros. + typedef ::std::vector > + InstantiationContainer; + + const string test_case_name_; + TestInfoContainer tests_; + InstantiationContainer instantiations_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseInfo); +}; // class ParameterizedTestCaseInfo + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// ParameterizedTestCaseRegistry contains a map of ParameterizedTestCaseInfoBase +// classes accessed by test case names. TEST_P and INSTANTIATE_TEST_CASE_P +// macros use it to locate their corresponding ParameterizedTestCaseInfo +// descriptors. +class ParameterizedTestCaseRegistry { + public: + ParameterizedTestCaseRegistry() {} + ~ParameterizedTestCaseRegistry() { + for (TestCaseInfoContainer::iterator it = test_case_infos_.begin(); + it != test_case_infos_.end(); ++it) { + delete *it; + } + } + + // Looks up or creates and returns a structure containing information about + // tests and instantiations of a particular test case. + template + ParameterizedTestCaseInfo* GetTestCasePatternHolder( + const char* test_case_name, + const char* file, + int line) { + ParameterizedTestCaseInfo* typed_test_info = NULL; + for (TestCaseInfoContainer::iterator it = test_case_infos_.begin(); + it != test_case_infos_.end(); ++it) { + if ((*it)->GetTestCaseName() == test_case_name) { + if ((*it)->GetTestCaseTypeId() != GetTypeId()) { + // Complain about incorrect usage of Google Test facilities + // and terminate the program since we cannot guaranty correct + // test case setup and tear-down in this case. + ReportInvalidTestCaseType(test_case_name, file, line); + posix::Abort(); + } else { + // At this point we are sure that the object we found is of the same + // type we are looking for, so we downcast it to that type + // without further checks. + typed_test_info = CheckedDowncastToActualType< + ParameterizedTestCaseInfo >(*it); + } + break; + } + } + if (typed_test_info == NULL) { + typed_test_info = new ParameterizedTestCaseInfo(test_case_name); + test_case_infos_.push_back(typed_test_info); + } + return typed_test_info; + } + void RegisterTests() { + for (TestCaseInfoContainer::iterator it = test_case_infos_.begin(); + it != test_case_infos_.end(); ++it) { + (*it)->RegisterTests(); + } + } + + private: + typedef ::std::vector TestCaseInfoContainer; + + TestCaseInfoContainer test_case_infos_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ParameterizedTestCaseRegistry); +}; + +} // namespace internal +} // namespace testing + +#endif // GTEST_HAS_PARAM_TEST + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PARAM_UTIL_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-port.h b/test/fmw/gtest/include/gtest/internal/gtest-port.h new file mode 100644 index 00000000000..dc4fe0cb6b8 --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-port.h @@ -0,0 +1,1947 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Authors: wan@google.com (Zhanyong Wan) +// +// Low-level types and utilities for porting Google Test to various +// platforms. They are subject to change without notice. DO NOT USE +// THEM IN USER CODE. +// +// This file is fundamental to Google Test. All other Google Test source +// files are expected to #include this. Therefore, it cannot #include +// any other Google Test header. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ + +// The user can define the following macros in the build script to +// control Google Test's behavior. If the user doesn't define a macro +// in this list, Google Test will define it. +// +// GTEST_HAS_CLONE - Define it to 1/0 to indicate that clone(2) +// is/isn't available. +// GTEST_HAS_EXCEPTIONS - Define it to 1/0 to indicate that exceptions +// are enabled. +// GTEST_HAS_GLOBAL_STRING - Define it to 1/0 to indicate that ::string +// is/isn't available (some systems define +// ::string, which is different to std::string). +// GTEST_HAS_GLOBAL_WSTRING - Define it to 1/0 to indicate that ::string +// is/isn't available (some systems define +// ::wstring, which is different to std::wstring). +// GTEST_HAS_POSIX_RE - Define it to 1/0 to indicate that POSIX regular +// expressions are/aren't available. +// GTEST_HAS_PTHREAD - Define it to 1/0 to indicate that +// is/isn't available. +// GTEST_HAS_RTTI - Define it to 1/0 to indicate that RTTI is/isn't +// enabled. +// GTEST_HAS_STD_WSTRING - Define it to 1/0 to indicate that +// std::wstring does/doesn't work (Google Test can +// be used where std::wstring is unavailable). +// GTEST_HAS_TR1_TUPLE - Define it to 1/0 to indicate tr1::tuple +// is/isn't available. +// GTEST_HAS_SEH - Define it to 1/0 to indicate whether the +// compiler supports Microsoft's "Structured +// Exception Handling". +// GTEST_HAS_STREAM_REDIRECTION +// - Define it to 1/0 to indicate whether the +// platform supports I/O stream redirection using +// dup() and dup2(). +// GTEST_USE_OWN_TR1_TUPLE - Define it to 1/0 to indicate whether Google +// Test's own tr1 tuple implementation should be +// used. Unused when the user sets +// GTEST_HAS_TR1_TUPLE to 0. +// GTEST_LANG_CXX11 - Define it to 1/0 to indicate that Google Test +// is building in C++11/C++98 mode. +// GTEST_LINKED_AS_SHARED_LIBRARY +// - Define to 1 when compiling tests that use +// Google Test as a shared library (known as +// DLL on Windows). +// GTEST_CREATE_SHARED_LIBRARY +// - Define to 1 when compiling Google Test itself +// as a shared library. + +// This header defines the following utilities: +// +// Macros indicating the current platform (defined to 1 if compiled on +// the given platform; otherwise undefined): +// GTEST_OS_AIX - IBM AIX +// GTEST_OS_CYGWIN - Cygwin +// GTEST_OS_HPUX - HP-UX +// GTEST_OS_LINUX - Linux +// GTEST_OS_LINUX_ANDROID - Google Android +// GTEST_OS_MAC - Mac OS X +// GTEST_OS_IOS - iOS +// GTEST_OS_IOS_SIMULATOR - iOS simulator +// GTEST_OS_NACL - Google Native Client (NaCl) +// GTEST_OS_OPENBSD - OpenBSD +// GTEST_OS_QNX - QNX +// GTEST_OS_SOLARIS - Sun Solaris +// GTEST_OS_SYMBIAN - Symbian +// GTEST_OS_WINDOWS - Windows (Desktop, MinGW, or Mobile) +// GTEST_OS_WINDOWS_DESKTOP - Windows Desktop +// GTEST_OS_WINDOWS_MINGW - MinGW +// GTEST_OS_WINDOWS_MOBILE - Windows Mobile +// GTEST_OS_ZOS - z/OS +// +// Among the platforms, Cygwin, Linux, Max OS X, and Windows have the +// most stable support. Since core members of the Google Test project +// don't have access to other platforms, support for them may be less +// stable. If you notice any problems on your platform, please notify +// googletestframework@googlegroups.com (patches for fixing them are +// even more welcome!). +// +// Note that it is possible that none of the GTEST_OS_* macros are defined. +// +// Macros indicating available Google Test features (defined to 1 if +// the corresponding feature is supported; otherwise undefined): +// GTEST_HAS_COMBINE - the Combine() function (for value-parameterized +// tests) +// GTEST_HAS_DEATH_TEST - death tests +// GTEST_HAS_PARAM_TEST - value-parameterized tests +// GTEST_HAS_TYPED_TEST - typed tests +// GTEST_HAS_TYPED_TEST_P - type-parameterized tests +// GTEST_USES_POSIX_RE - enhanced POSIX regex is used. Do not confuse with +// GTEST_HAS_POSIX_RE (see above) which users can +// define themselves. +// GTEST_USES_SIMPLE_RE - our own simple regex is used; +// the above two are mutually exclusive. +// GTEST_CAN_COMPARE_NULL - accepts untyped NULL in EXPECT_EQ(). +// +// Macros for basic C++ coding: +// GTEST_AMBIGUOUS_ELSE_BLOCKER_ - for disabling a gcc warning. +// GTEST_ATTRIBUTE_UNUSED_ - declares that a class' instances or a +// variable don't have to be used. +// GTEST_DISALLOW_ASSIGN_ - disables operator=. +// GTEST_DISALLOW_COPY_AND_ASSIGN_ - disables copy ctor and operator=. +// GTEST_MUST_USE_RESULT_ - declares that a function's result must be used. +// +// Synchronization: +// Mutex, MutexLock, ThreadLocal, GetThreadCount() +// - synchronization primitives. +// GTEST_IS_THREADSAFE - defined to 1 to indicate that the above +// synchronization primitives have real implementations +// and Google Test is thread-safe; or 0 otherwise. +// +// Template meta programming: +// is_pointer - as in TR1; needed on Symbian and IBM XL C/C++ only. +// IteratorTraits - partial implementation of std::iterator_traits, which +// is not available in libCstd when compiled with Sun C++. +// +// Smart pointers: +// scoped_ptr - as in TR2. +// +// Regular expressions: +// RE - a simple regular expression class using the POSIX +// Extended Regular Expression syntax on UNIX-like +// platforms, or a reduced regular exception syntax on +// other platforms, including Windows. +// +// Logging: +// GTEST_LOG_() - logs messages at the specified severity level. +// LogToStderr() - directs all log messages to stderr. +// FlushInfoLog() - flushes informational log messages. +// +// Stdout and stderr capturing: +// CaptureStdout() - starts capturing stdout. +// GetCapturedStdout() - stops capturing stdout and returns the captured +// string. +// CaptureStderr() - starts capturing stderr. +// GetCapturedStderr() - stops capturing stderr and returns the captured +// string. +// +// Integer types: +// TypeWithSize - maps an integer to a int type. +// Int32, UInt32, Int64, UInt64, TimeInMillis +// - integers of known sizes. +// BiggestInt - the biggest signed integer type. +// +// Command-line utilities: +// GTEST_FLAG() - references a flag. +// GTEST_DECLARE_*() - declares a flag. +// GTEST_DEFINE_*() - defines a flag. +// GetInjectableArgvs() - returns the command line as a vector of strings. +// +// Environment variable utilities: +// GetEnv() - gets the value of an environment variable. +// BoolFromGTestEnv() - parses a bool environment variable. +// Int32FromGTestEnv() - parses an Int32 environment variable. +// StringFromGTestEnv() - parses a string environment variable. + +#include // for isspace, etc +#include // for ptrdiff_t +#include +#include +#include +#ifndef _WIN32_WCE +# include +# include +#endif // !_WIN32_WCE + +#if defined __APPLE__ +# include +# include +#endif + +#include // NOLINT +#include // NOLINT +#include // NOLINT + +#define GTEST_DEV_EMAIL_ "googletestframework@@googlegroups.com" +#define GTEST_FLAG_PREFIX_ "gtest_" +#define GTEST_FLAG_PREFIX_DASH_ "gtest-" +#define GTEST_FLAG_PREFIX_UPPER_ "GTEST_" +#define GTEST_NAME_ "Google Test" +#define GTEST_PROJECT_URL_ "http://code.google.com/p/googletest/" + +// Determines the version of gcc that is used to compile this. +#ifdef __GNUC__ +// 40302 means version 4.3.2. +# define GTEST_GCC_VER_ \ + (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__) +#endif // __GNUC__ + +// Determines the platform on which Google Test is compiled. +#ifdef __CYGWIN__ +# define GTEST_OS_CYGWIN 1 +#elif defined __SYMBIAN32__ +# define GTEST_OS_SYMBIAN 1 +#elif defined _WIN32 +# define GTEST_OS_WINDOWS 1 +# ifdef _WIN32_WCE +# define GTEST_OS_WINDOWS_MOBILE 1 +# elif defined(__MINGW__) || defined(__MINGW32__) +# define GTEST_OS_WINDOWS_MINGW 1 +# else +# define GTEST_OS_WINDOWS_DESKTOP 1 +# endif // _WIN32_WCE +#elif defined __APPLE__ +# define GTEST_OS_MAC 1 +# if TARGET_OS_IPHONE +# define GTEST_OS_IOS 1 +# if TARGET_IPHONE_SIMULATOR +# define GTEST_OS_IOS_SIMULATOR 1 +# endif +# endif +#elif defined __linux__ +# define GTEST_OS_LINUX 1 +# if defined __ANDROID__ +# define GTEST_OS_LINUX_ANDROID 1 +# endif +#elif defined __MVS__ +# define GTEST_OS_ZOS 1 +#elif defined(__sun) && defined(__SVR4) +# define GTEST_OS_SOLARIS 1 +#elif defined(_AIX) +# define GTEST_OS_AIX 1 +#elif defined(__hpux) +# define GTEST_OS_HPUX 1 +#elif defined __native_client__ +# define GTEST_OS_NACL 1 +#elif defined __OpenBSD__ +# define GTEST_OS_OPENBSD 1 +#elif defined __QNX__ +# define GTEST_OS_QNX 1 +#endif // __CYGWIN__ + +#ifndef GTEST_LANG_CXX11 +// gcc and clang define __GXX_EXPERIMENTAL_CXX0X__ when +// -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a +// value for __cplusplus, and recent versions of clang, gcc, and +// probably other compilers set that too in C++11 mode. +# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L +// Compiling in at least C++11 mode. +# define GTEST_LANG_CXX11 1 +# else +# define GTEST_LANG_CXX11 0 +# endif +#endif + +// Brings in definitions for functions used in the testing::internal::posix +// namespace (read, write, close, chdir, isatty, stat). We do not currently +// use them on Windows Mobile. +#if !GTEST_OS_WINDOWS +// This assumes that non-Windows OSes provide unistd.h. For OSes where this +// is not the case, we need to include headers that provide the functions +// mentioned above. +# include +# include +#elif !GTEST_OS_WINDOWS_MOBILE +# include +# include +#endif + +#if GTEST_OS_LINUX_ANDROID +// Used to define __ANDROID_API__ matching the target NDK API level. +# include // NOLINT +#endif + +// Defines this to true iff Google Test can use POSIX regular expressions. +#ifndef GTEST_HAS_POSIX_RE +# if GTEST_OS_LINUX_ANDROID +// On Android, is only available starting with Gingerbread. +# define GTEST_HAS_POSIX_RE (__ANDROID_API__ >= 9) +# else +# define GTEST_HAS_POSIX_RE (!GTEST_OS_WINDOWS) +# endif +#endif + +#if GTEST_HAS_POSIX_RE + +// On some platforms, needs someone to define size_t, and +// won't compile otherwise. We can #include it here as we already +// included , which is guaranteed to define size_t through +// . +# include // NOLINT + +# define GTEST_USES_POSIX_RE 1 + +#elif GTEST_OS_WINDOWS + +// is not available on Windows. Use our own simple regex +// implementation instead. +# define GTEST_USES_SIMPLE_RE 1 + +#else + +// may not be available on this platform. Use our own +// simple regex implementation instead. +# define GTEST_USES_SIMPLE_RE 1 + +#endif // GTEST_HAS_POSIX_RE + +#ifndef GTEST_HAS_EXCEPTIONS +// The user didn't tell us whether exceptions are enabled, so we need +// to figure it out. +# if defined(_MSC_VER) || defined(__BORLANDC__) +// MSVC's and C++Builder's implementations of the STL use the _HAS_EXCEPTIONS +// macro to enable exceptions, so we'll do the same. +// Assumes that exceptions are enabled by default. +# ifndef _HAS_EXCEPTIONS +# define _HAS_EXCEPTIONS 1 +# endif // _HAS_EXCEPTIONS +# define GTEST_HAS_EXCEPTIONS _HAS_EXCEPTIONS +# elif defined(__GNUC__) && __EXCEPTIONS +// gcc defines __EXCEPTIONS to 1 iff exceptions are enabled. +# define GTEST_HAS_EXCEPTIONS 1 +# elif defined(__SUNPRO_CC) +// Sun Pro CC supports exceptions. However, there is no compile-time way of +// detecting whether they are enabled or not. Therefore, we assume that +// they are enabled unless the user tells us otherwise. +# define GTEST_HAS_EXCEPTIONS 1 +# elif defined(__IBMCPP__) && __EXCEPTIONS +// xlC defines __EXCEPTIONS to 1 iff exceptions are enabled. +# define GTEST_HAS_EXCEPTIONS 1 +# elif defined(__HP_aCC) +// Exception handling is in effect by default in HP aCC compiler. It has to +// be turned of by +noeh compiler option if desired. +# define GTEST_HAS_EXCEPTIONS 1 +# else +// For other compilers, we assume exceptions are disabled to be +// conservative. +# define GTEST_HAS_EXCEPTIONS 0 +# endif // defined(_MSC_VER) || defined(__BORLANDC__) +#endif // GTEST_HAS_EXCEPTIONS + +#if !defined(GTEST_HAS_STD_STRING) +// Even though we don't use this macro any longer, we keep it in case +// some clients still depend on it. +# define GTEST_HAS_STD_STRING 1 +#elif !GTEST_HAS_STD_STRING +// The user told us that ::std::string isn't available. +# error "Google Test cannot be used where ::std::string isn't available." +#endif // !defined(GTEST_HAS_STD_STRING) + +#ifndef GTEST_HAS_GLOBAL_STRING +// The user didn't tell us whether ::string is available, so we need +// to figure it out. + +# define GTEST_HAS_GLOBAL_STRING 0 + +#endif // GTEST_HAS_GLOBAL_STRING + +#ifndef GTEST_HAS_STD_WSTRING +// The user didn't tell us whether ::std::wstring is available, so we need +// to figure it out. +// TODO(wan@google.com): uses autoconf to detect whether ::std::wstring +// is available. + +// Cygwin 1.7 and below doesn't support ::std::wstring. +// Solaris' libc++ doesn't support it either. Android has +// no support for it at least as recent as Froyo (2.2). +# define GTEST_HAS_STD_WSTRING \ + (!(GTEST_OS_LINUX_ANDROID || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS)) + +#endif // GTEST_HAS_STD_WSTRING + +#ifndef GTEST_HAS_GLOBAL_WSTRING +// The user didn't tell us whether ::wstring is available, so we need +// to figure it out. +# define GTEST_HAS_GLOBAL_WSTRING \ + (GTEST_HAS_STD_WSTRING && GTEST_HAS_GLOBAL_STRING) +#endif // GTEST_HAS_GLOBAL_WSTRING + +// Determines whether RTTI is available. +#ifndef GTEST_HAS_RTTI +// The user didn't tell us whether RTTI is enabled, so we need to +// figure it out. + +# ifdef _MSC_VER + +# ifdef _CPPRTTI // MSVC defines this macro iff RTTI is enabled. +# define GTEST_HAS_RTTI 1 +# else +# define GTEST_HAS_RTTI 0 +# endif + +// Starting with version 4.3.2, gcc defines __GXX_RTTI iff RTTI is enabled. +# elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40302) + +# ifdef __GXX_RTTI +// When building against STLport with the Android NDK and with +// -frtti -fno-exceptions, the build fails at link time with undefined +// references to __cxa_bad_typeid. Note sure if STL or toolchain bug, +// so disable RTTI when detected. +# if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) && \ + !defined(__EXCEPTIONS) +# define GTEST_HAS_RTTI 0 +# else +# define GTEST_HAS_RTTI 1 +# endif // GTEST_OS_LINUX_ANDROID && __STLPORT_MAJOR && !__EXCEPTIONS +# else +# define GTEST_HAS_RTTI 0 +# endif // __GXX_RTTI + +// Clang defines __GXX_RTTI starting with version 3.0, but its manual recommends +// using has_feature instead. has_feature(cxx_rtti) is supported since 2.7, the +// first version with C++ support. +# elif defined(__clang__) + +# define GTEST_HAS_RTTI __has_feature(cxx_rtti) + +// Starting with version 9.0 IBM Visual Age defines __RTTI_ALL__ to 1 if +// both the typeid and dynamic_cast features are present. +# elif defined(__IBMCPP__) && (__IBMCPP__ >= 900) + +# ifdef __RTTI_ALL__ +# define GTEST_HAS_RTTI 1 +# else +# define GTEST_HAS_RTTI 0 +# endif + +# else + +// For all other compilers, we assume RTTI is enabled. +# define GTEST_HAS_RTTI 1 + +# endif // _MSC_VER + +#endif // GTEST_HAS_RTTI + +// It's this header's responsibility to #include when RTTI +// is enabled. +#if GTEST_HAS_RTTI +# include +#endif + +// Determines whether Google Test can use the pthreads library. +#ifndef GTEST_HAS_PTHREAD +// The user didn't tell us explicitly, so we assume pthreads support is +// available on Linux and Mac. +// +// To disable threading support in Google Test, add -DGTEST_HAS_PTHREAD=0 +// to your compiler flags. +# define GTEST_HAS_PTHREAD (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_HPUX \ + || GTEST_OS_QNX) +#endif // GTEST_HAS_PTHREAD + +#if GTEST_HAS_PTHREAD +// gtest-port.h guarantees to #include when GTEST_HAS_PTHREAD is +// true. +# include // NOLINT + +// For timespec and nanosleep, used below. +# include // NOLINT +#endif + +// Determines whether Google Test can use tr1/tuple. You can define +// this macro to 0 to prevent Google Test from using tuple (any +// feature depending on tuple with be disabled in this mode). +#ifndef GTEST_HAS_TR1_TUPLE +# if GTEST_OS_LINUX_ANDROID && defined(_STLPORT_MAJOR) +// STLport, provided with the Android NDK, has neither or . +# define GTEST_HAS_TR1_TUPLE 0 +# else +// The user didn't tell us not to do it, so we assume it's OK. +# define GTEST_HAS_TR1_TUPLE 1 +# endif +#endif // GTEST_HAS_TR1_TUPLE + +// Determines whether Google Test's own tr1 tuple implementation +// should be used. +#ifndef GTEST_USE_OWN_TR1_TUPLE +// The user didn't tell us, so we need to figure it out. + +// We use our own TR1 tuple if we aren't sure the user has an +// implementation of it already. At this time, libstdc++ 4.0.0+ and +// MSVC 2010 are the only mainstream standard libraries that come +// with a TR1 tuple implementation. NVIDIA's CUDA NVCC compiler +// pretends to be GCC by defining __GNUC__ and friends, but cannot +// compile GCC's tuple implementation. MSVC 2008 (9.0) provides TR1 +// tuple in a 323 MB Feature Pack download, which we cannot assume the +// user has. QNX's QCC compiler is a modified GCC but it doesn't +// support TR1 tuple. libc++ only provides std::tuple, in C++11 mode, +// and it can be used with some compilers that define __GNUC__. +# if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \ + && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600 +# define GTEST_ENV_HAS_TR1_TUPLE_ 1 +# endif + +// C++11 specifies that provides std::tuple. Use that if gtest is used +// in C++11 mode and libstdc++ isn't very old (binaries targeting OS X 10.6 +// can build with clang but need to use gcc4.2's libstdc++). +# if GTEST_LANG_CXX11 && (!defined(__GLIBCXX__) || __GLIBCXX__ > 20110325) +# define GTEST_ENV_HAS_STD_TUPLE_ 1 +# endif + +# if GTEST_ENV_HAS_TR1_TUPLE_ || GTEST_ENV_HAS_STD_TUPLE_ +# define GTEST_USE_OWN_TR1_TUPLE 0 +# else +# define GTEST_USE_OWN_TR1_TUPLE 1 +# endif + +#endif // GTEST_USE_OWN_TR1_TUPLE + +// To avoid conditional compilation everywhere, we make it +// gtest-port.h's responsibility to #include the header implementing +// tr1/tuple. +#if GTEST_HAS_TR1_TUPLE + +# if GTEST_USE_OWN_TR1_TUPLE +# include "gtest/internal/gtest-tuple.h" +# elif GTEST_ENV_HAS_STD_TUPLE_ +# include +// C++11 puts its tuple into the ::std namespace rather than +// ::std::tr1. gtest expects tuple to live in ::std::tr1, so put it there. +// This causes undefined behavior, but supported compilers react in +// the way we intend. +namespace std { +namespace tr1 { +using ::std::get; +using ::std::make_tuple; +using ::std::tuple; +using ::std::tuple_element; +using ::std::tuple_size; +} +} + +# elif GTEST_OS_SYMBIAN + +// On Symbian, BOOST_HAS_TR1_TUPLE causes Boost's TR1 tuple library to +// use STLport's tuple implementation, which unfortunately doesn't +// work as the copy of STLport distributed with Symbian is incomplete. +// By making sure BOOST_HAS_TR1_TUPLE is undefined, we force Boost to +// use its own tuple implementation. +# ifdef BOOST_HAS_TR1_TUPLE +# undef BOOST_HAS_TR1_TUPLE +# endif // BOOST_HAS_TR1_TUPLE + +// This prevents , which defines +// BOOST_HAS_TR1_TUPLE, from being #included by Boost's . +# define BOOST_TR1_DETAIL_CONFIG_HPP_INCLUDED +# include + +# elif defined(__GNUC__) && (GTEST_GCC_VER_ >= 40000) +// GCC 4.0+ implements tr1/tuple in the header. This does +// not conform to the TR1 spec, which requires the header to be . + +# if !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302 +// Until version 4.3.2, gcc has a bug that causes , +// which is #included by , to not compile when RTTI is +// disabled. _TR1_FUNCTIONAL is the header guard for +// . Hence the following #define is a hack to prevent +// from being included. +# define _TR1_FUNCTIONAL 1 +# include +# undef _TR1_FUNCTIONAL // Allows the user to #include + // if he chooses to. +# else +# include // NOLINT +# endif // !GTEST_HAS_RTTI && GTEST_GCC_VER_ < 40302 + +# else +// If the compiler is not GCC 4.0+, we assume the user is using a +// spec-conforming TR1 implementation. +# include // NOLINT +# endif // GTEST_USE_OWN_TR1_TUPLE + +#endif // GTEST_HAS_TR1_TUPLE + +// Determines whether clone(2) is supported. +// Usually it will only be available on Linux, excluding +// Linux on the Itanium architecture. +// Also see http://linux.die.net/man/2/clone. +#ifndef GTEST_HAS_CLONE +// The user didn't tell us, so we need to figure it out. + +# if GTEST_OS_LINUX && !defined(__ia64__) +# if GTEST_OS_LINUX_ANDROID +// On Android, clone() is only available on ARM starting with Gingerbread. +# if defined(__arm__) && __ANDROID_API__ >= 9 +# define GTEST_HAS_CLONE 1 +# else +# define GTEST_HAS_CLONE 0 +# endif +# else +# define GTEST_HAS_CLONE 1 +# endif +# else +# define GTEST_HAS_CLONE 0 +# endif // GTEST_OS_LINUX && !defined(__ia64__) + +#endif // GTEST_HAS_CLONE + +// Determines whether to support stream redirection. This is used to test +// output correctness and to implement death tests. +#ifndef GTEST_HAS_STREAM_REDIRECTION +// By default, we assume that stream redirection is supported on all +// platforms except known mobile ones. +# if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN +# define GTEST_HAS_STREAM_REDIRECTION 0 +# else +# define GTEST_HAS_STREAM_REDIRECTION 1 +# endif // !GTEST_OS_WINDOWS_MOBILE && !GTEST_OS_SYMBIAN +#endif // GTEST_HAS_STREAM_REDIRECTION + +// Determines whether to support death tests. +// Google Test does not support death tests for VC 7.1 and earlier as +// abort() in a VC 7.1 application compiled as GUI in debug config +// pops up a dialog window that cannot be suppressed programmatically. +#if (GTEST_OS_LINUX || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \ + (GTEST_OS_MAC && !GTEST_OS_IOS) || GTEST_OS_IOS_SIMULATOR || \ + (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \ + GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX || GTEST_OS_HPUX || \ + GTEST_OS_OPENBSD || GTEST_OS_QNX) +# define GTEST_HAS_DEATH_TEST 1 +# include // NOLINT +#endif + +// We don't support MSVC 7.1 with exceptions disabled now. Therefore +// all the compilers we care about are adequate for supporting +// value-parameterized tests. +#define GTEST_HAS_PARAM_TEST 1 + +// Determines whether to support type-driven tests. + +// Typed tests need and variadic macros, which GCC, VC++ 8.0, +// Sun Pro CC, IBM Visual Age, and HP aCC support. +#if defined(__GNUC__) || (_MSC_VER >= 1400) || defined(__SUNPRO_CC) || \ + defined(__IBMCPP__) || defined(__HP_aCC) +# define GTEST_HAS_TYPED_TEST 1 +# define GTEST_HAS_TYPED_TEST_P 1 +#endif + +// Determines whether to support Combine(). This only makes sense when +// value-parameterized tests are enabled. The implementation doesn't +// work on Sun Studio since it doesn't understand templated conversion +// operators. +#if GTEST_HAS_PARAM_TEST && GTEST_HAS_TR1_TUPLE && !defined(__SUNPRO_CC) +# define GTEST_HAS_COMBINE 1 +#endif + +// Determines whether the system compiler uses UTF-16 for encoding wide strings. +#define GTEST_WIDE_STRING_USES_UTF16_ \ + (GTEST_OS_WINDOWS || GTEST_OS_CYGWIN || GTEST_OS_SYMBIAN || GTEST_OS_AIX) + +// Determines whether test results can be streamed to a socket. +#if GTEST_OS_LINUX +# define GTEST_CAN_STREAM_RESULTS_ 1 +#endif + +// Defines some utility macros. + +// The GNU compiler emits a warning if nested "if" statements are followed by +// an "else" statement and braces are not used to explicitly disambiguate the +// "else" binding. This leads to problems with code like: +// +// if (gate) +// ASSERT_*(condition) << "Some message"; +// +// The "switch (0) case 0:" idiom is used to suppress this. +#ifdef __INTEL_COMPILER +# define GTEST_AMBIGUOUS_ELSE_BLOCKER_ +#else +# define GTEST_AMBIGUOUS_ELSE_BLOCKER_ switch (0) case 0: default: // NOLINT +#endif + +// Use this annotation at the end of a struct/class definition to +// prevent the compiler from optimizing away instances that are never +// used. This is useful when all interesting logic happens inside the +// c'tor and / or d'tor. Example: +// +// struct Foo { +// Foo() { ... } +// } GTEST_ATTRIBUTE_UNUSED_; +// +// Also use it after a variable or parameter declaration to tell the +// compiler the variable/parameter does not have to be used. +#if defined(__GNUC__) && !defined(COMPILER_ICC) +# define GTEST_ATTRIBUTE_UNUSED_ __attribute__ ((unused)) +#else +# define GTEST_ATTRIBUTE_UNUSED_ +#endif + +// A macro to disallow operator= +// This should be used in the private: declarations for a class. +#define GTEST_DISALLOW_ASSIGN_(type)\ + void operator=(type const &) + +// A macro to disallow copy constructor and operator= +// This should be used in the private: declarations for a class. +#define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\ + type(type const &);\ + GTEST_DISALLOW_ASSIGN_(type) + +// Tell the compiler to warn about unused return values for functions declared +// with this macro. The macro should be used on function declarations +// following the argument list: +// +// Sprocket* AllocateSprocket() GTEST_MUST_USE_RESULT_; +#if defined(__GNUC__) && (GTEST_GCC_VER_ >= 30400) && !defined(COMPILER_ICC) +# define GTEST_MUST_USE_RESULT_ __attribute__ ((warn_unused_result)) +#else +# define GTEST_MUST_USE_RESULT_ +#endif // __GNUC__ && (GTEST_GCC_VER_ >= 30400) && !COMPILER_ICC + +// Determine whether the compiler supports Microsoft's Structured Exception +// Handling. This is supported by several Windows compilers but generally +// does not exist on any other system. +#ifndef GTEST_HAS_SEH +// The user didn't tell us, so we need to figure it out. + +# if defined(_MSC_VER) || defined(__BORLANDC__) +// These two compilers are known to support SEH. +# define GTEST_HAS_SEH 1 +# else +// Assume no SEH. +# define GTEST_HAS_SEH 0 +# endif + +#endif // GTEST_HAS_SEH + +#ifdef _MSC_VER + +# if GTEST_LINKED_AS_SHARED_LIBRARY +# define GTEST_API_ __declspec(dllimport) +# elif GTEST_CREATE_SHARED_LIBRARY +# define GTEST_API_ __declspec(dllexport) +# endif + +#endif // _MSC_VER + +#ifndef GTEST_API_ +# define GTEST_API_ +#endif + +#ifdef __GNUC__ +// Ask the compiler to never inline a given function. +# define GTEST_NO_INLINE_ __attribute__((noinline)) +#else +# define GTEST_NO_INLINE_ +#endif + +// _LIBCPP_VERSION is defined by the libc++ library from the LLVM project. +#if defined(__GLIBCXX__) || defined(_LIBCPP_VERSION) +# define GTEST_HAS_CXXABI_H_ 1 +#else +# define GTEST_HAS_CXXABI_H_ 0 +#endif + +namespace testing { + +class Message; + +namespace internal { + +// A secret type that Google Test users don't know about. It has no +// definition on purpose. Therefore it's impossible to create a +// Secret object, which is what we want. +class Secret; + +// The GTEST_COMPILE_ASSERT_ macro can be used to verify that a compile time +// expression is true. For example, you could use it to verify the +// size of a static array: +// +// GTEST_COMPILE_ASSERT_(ARRAYSIZE(content_type_names) == CONTENT_NUM_TYPES, +// content_type_names_incorrect_size); +// +// or to make sure a struct is smaller than a certain size: +// +// GTEST_COMPILE_ASSERT_(sizeof(foo) < 128, foo_too_large); +// +// The second argument to the macro is the name of the variable. If +// the expression is false, most compilers will issue a warning/error +// containing the name of the variable. + +template +struct CompileAssert { +}; + +#define GTEST_COMPILE_ASSERT_(expr, msg) \ + typedef ::testing::internal::CompileAssert<(static_cast(expr))> \ + msg[static_cast(expr) ? 1 : -1] GTEST_ATTRIBUTE_UNUSED_ + +// Implementation details of GTEST_COMPILE_ASSERT_: +// +// - GTEST_COMPILE_ASSERT_ works by defining an array type that has -1 +// elements (and thus is invalid) when the expression is false. +// +// - The simpler definition +// +// #define GTEST_COMPILE_ASSERT_(expr, msg) typedef char msg[(expr) ? 1 : -1] +// +// does not work, as gcc supports variable-length arrays whose sizes +// are determined at run-time (this is gcc's extension and not part +// of the C++ standard). As a result, gcc fails to reject the +// following code with the simple definition: +// +// int foo; +// GTEST_COMPILE_ASSERT_(foo, msg); // not supposed to compile as foo is +// // not a compile-time constant. +// +// - By using the type CompileAssert<(bool(expr))>, we ensures that +// expr is a compile-time constant. (Template arguments must be +// determined at compile-time.) +// +// - The outter parentheses in CompileAssert<(bool(expr))> are necessary +// to work around a bug in gcc 3.4.4 and 4.0.1. If we had written +// +// CompileAssert +// +// instead, these compilers will refuse to compile +// +// GTEST_COMPILE_ASSERT_(5 > 0, some_message); +// +// (They seem to think the ">" in "5 > 0" marks the end of the +// template argument list.) +// +// - The array size is (bool(expr) ? 1 : -1), instead of simply +// +// ((expr) ? 1 : -1). +// +// This is to avoid running into a bug in MS VC 7.1, which +// causes ((0.0) ? 1 : -1) to incorrectly evaluate to 1. + +// StaticAssertTypeEqHelper is used by StaticAssertTypeEq defined in gtest.h. +// +// This template is declared, but intentionally undefined. +template +struct StaticAssertTypeEqHelper; + +template +struct StaticAssertTypeEqHelper {}; + +#if GTEST_HAS_GLOBAL_STRING +typedef ::string string; +#else +typedef ::std::string string; +#endif // GTEST_HAS_GLOBAL_STRING + +#if GTEST_HAS_GLOBAL_WSTRING +typedef ::wstring wstring; +#elif GTEST_HAS_STD_WSTRING +typedef ::std::wstring wstring; +#endif // GTEST_HAS_GLOBAL_WSTRING + +// A helper for suppressing warnings on constant condition. It just +// returns 'condition'. +GTEST_API_ bool IsTrue(bool condition); + +// Defines scoped_ptr. + +// This implementation of scoped_ptr is PARTIAL - it only contains +// enough stuff to satisfy Google Test's need. +template +class scoped_ptr { + public: + typedef T element_type; + + explicit scoped_ptr(T* p = NULL) : ptr_(p) {} + ~scoped_ptr() { reset(); } + + T& operator*() const { return *ptr_; } + T* operator->() const { return ptr_; } + T* get() const { return ptr_; } + + T* release() { + T* const ptr = ptr_; + ptr_ = NULL; + return ptr; + } + + void reset(T* p = NULL) { + if (p != ptr_) { + if (IsTrue(sizeof(T) > 0)) { // Makes sure T is a complete type. + delete ptr_; + } + ptr_ = p; + } + } + + private: + T* ptr_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(scoped_ptr); +}; + +// Defines RE. + +// A simple C++ wrapper for . It uses the POSIX Extended +// Regular Expression syntax. +class GTEST_API_ RE { + public: + // A copy constructor is required by the Standard to initialize object + // references from r-values. + RE(const RE& other) { Init(other.pattern()); } + + // Constructs an RE from a string. + RE(const ::std::string& regex) { Init(regex.c_str()); } // NOLINT + +#if GTEST_HAS_GLOBAL_STRING + + RE(const ::string& regex) { Init(regex.c_str()); } // NOLINT + +#endif // GTEST_HAS_GLOBAL_STRING + + RE(const char* regex) { Init(regex); } // NOLINT + ~RE(); + + // Returns the string representation of the regex. + const char* pattern() const { return pattern_; } + + // FullMatch(str, re) returns true iff regular expression re matches + // the entire str. + // PartialMatch(str, re) returns true iff regular expression re + // matches a substring of str (including str itself). + // + // TODO(wan@google.com): make FullMatch() and PartialMatch() work + // when str contains NUL characters. + static bool FullMatch(const ::std::string& str, const RE& re) { + return FullMatch(str.c_str(), re); + } + static bool PartialMatch(const ::std::string& str, const RE& re) { + return PartialMatch(str.c_str(), re); + } + +#if GTEST_HAS_GLOBAL_STRING + + static bool FullMatch(const ::string& str, const RE& re) { + return FullMatch(str.c_str(), re); + } + static bool PartialMatch(const ::string& str, const RE& re) { + return PartialMatch(str.c_str(), re); + } + +#endif // GTEST_HAS_GLOBAL_STRING + + static bool FullMatch(const char* str, const RE& re); + static bool PartialMatch(const char* str, const RE& re); + + private: + void Init(const char* regex); + + // We use a const char* instead of an std::string, as Google Test used to be + // used where std::string is not available. TODO(wan@google.com): change to + // std::string. + const char* pattern_; + bool is_valid_; + +#if GTEST_USES_POSIX_RE + + regex_t full_regex_; // For FullMatch(). + regex_t partial_regex_; // For PartialMatch(). + +#else // GTEST_USES_SIMPLE_RE + + const char* full_pattern_; // For FullMatch(); + +#endif + + GTEST_DISALLOW_ASSIGN_(RE); +}; + +// Formats a source file path and a line number as they would appear +// in an error message from the compiler used to compile this code. +GTEST_API_ ::std::string FormatFileLocation(const char* file, int line); + +// Formats a file location for compiler-independent XML output. +// Although this function is not platform dependent, we put it next to +// FormatFileLocation in order to contrast the two functions. +GTEST_API_ ::std::string FormatCompilerIndependentFileLocation(const char* file, + int line); + +// Defines logging utilities: +// GTEST_LOG_(severity) - logs messages at the specified severity level. The +// message itself is streamed into the macro. +// LogToStderr() - directs all log messages to stderr. +// FlushInfoLog() - flushes informational log messages. + +enum GTestLogSeverity { + GTEST_INFO, + GTEST_WARNING, + GTEST_ERROR, + GTEST_FATAL +}; + +// Formats log entry severity, provides a stream object for streaming the +// log message, and terminates the message with a newline when going out of +// scope. +class GTEST_API_ GTestLog { + public: + GTestLog(GTestLogSeverity severity, const char* file, int line); + + // Flushes the buffers and, if severity is GTEST_FATAL, aborts the program. + ~GTestLog(); + + ::std::ostream& GetStream() { return ::std::cerr; } + + private: + const GTestLogSeverity severity_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestLog); +}; + +#define GTEST_LOG_(severity) \ + ::testing::internal::GTestLog(::testing::internal::GTEST_##severity, \ + __FILE__, __LINE__).GetStream() + +inline void LogToStderr() {} +inline void FlushInfoLog() { fflush(NULL); } + +// INTERNAL IMPLEMENTATION - DO NOT USE. +// +// GTEST_CHECK_ is an all-mode assert. It aborts the program if the condition +// is not satisfied. +// Synopsys: +// GTEST_CHECK_(boolean_condition); +// or +// GTEST_CHECK_(boolean_condition) << "Additional message"; +// +// This checks the condition and if the condition is not satisfied +// it prints message about the condition violation, including the +// condition itself, plus additional message streamed into it, if any, +// and then it aborts the program. It aborts the program irrespective of +// whether it is built in the debug mode or not. +#define GTEST_CHECK_(condition) \ + GTEST_AMBIGUOUS_ELSE_BLOCKER_ \ + if (::testing::internal::IsTrue(condition)) \ + ; \ + else \ + GTEST_LOG_(FATAL) << "Condition " #condition " failed. " + +// An all-mode assert to verify that the given POSIX-style function +// call returns 0 (indicating success). Known limitation: this +// doesn't expand to a balanced 'if' statement, so enclose the macro +// in {} if you need to use it as the only statement in an 'if' +// branch. +#define GTEST_CHECK_POSIX_SUCCESS_(posix_call) \ + if (const int gtest_error = (posix_call)) \ + GTEST_LOG_(FATAL) << #posix_call << "failed with error " \ + << gtest_error + +// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE. +// +// Use ImplicitCast_ as a safe version of static_cast for upcasting in +// the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a +// const Foo*). When you use ImplicitCast_, the compiler checks that +// the cast is safe. Such explicit ImplicitCast_s are necessary in +// surprisingly many situations where C++ demands an exact type match +// instead of an argument type convertable to a target type. +// +// The syntax for using ImplicitCast_ is the same as for static_cast: +// +// ImplicitCast_(expr) +// +// ImplicitCast_ would have been part of the C++ standard library, +// but the proposal was submitted too late. It will probably make +// its way into the language in the future. +// +// This relatively ugly name is intentional. It prevents clashes with +// similar functions users may have (e.g., implicit_cast). The internal +// namespace alone is not enough because the function can be found by ADL. +template +inline To ImplicitCast_(To x) { return x; } + +// When you upcast (that is, cast a pointer from type Foo to type +// SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts +// always succeed. When you downcast (that is, cast a pointer from +// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because +// how do you know the pointer is really of type SubclassOfFoo? It +// could be a bare Foo, or of type DifferentSubclassOfFoo. Thus, +// when you downcast, you should use this macro. In debug mode, we +// use dynamic_cast<> to double-check the downcast is legal (we die +// if it's not). In normal mode, we do the efficient static_cast<> +// instead. Thus, it's important to test in debug mode to make sure +// the cast is legal! +// This is the only place in the code we should use dynamic_cast<>. +// In particular, you SHOULDN'T be using dynamic_cast<> in order to +// do RTTI (eg code like this: +// if (dynamic_cast(foo)) HandleASubclass1Object(foo); +// if (dynamic_cast(foo)) HandleASubclass2Object(foo); +// You should design the code some other way not to need this. +// +// This relatively ugly name is intentional. It prevents clashes with +// similar functions users may have (e.g., down_cast). The internal +// namespace alone is not enough because the function can be found by ADL. +template // use like this: DownCast_(foo); +inline To DownCast_(From* f) { // so we only accept pointers + // Ensures that To is a sub-type of From *. This test is here only + // for compile-time type checking, and has no overhead in an + // optimized build at run-time, as it will be optimized away + // completely. + if (false) { + const To to = NULL; + ::testing::internal::ImplicitCast_(to); + } + +#if GTEST_HAS_RTTI + // RTTI: debug mode only! + GTEST_CHECK_(f == NULL || dynamic_cast(f) != NULL); +#endif + return static_cast(f); +} + +// Downcasts the pointer of type Base to Derived. +// Derived must be a subclass of Base. The parameter MUST +// point to a class of type Derived, not any subclass of it. +// When RTTI is available, the function performs a runtime +// check to enforce this. +template +Derived* CheckedDowncastToActualType(Base* base) { +#if GTEST_HAS_RTTI + GTEST_CHECK_(typeid(*base) == typeid(Derived)); + return dynamic_cast(base); // NOLINT +#else + return static_cast(base); // Poor man's downcast. +#endif +} + +#if GTEST_HAS_STREAM_REDIRECTION + +// Defines the stderr capturer: +// CaptureStdout - starts capturing stdout. +// GetCapturedStdout - stops capturing stdout and returns the captured string. +// CaptureStderr - starts capturing stderr. +// GetCapturedStderr - stops capturing stderr and returns the captured string. +// +GTEST_API_ void CaptureStdout(); +GTEST_API_ std::string GetCapturedStdout(); +GTEST_API_ void CaptureStderr(); +GTEST_API_ std::string GetCapturedStderr(); + +#endif // GTEST_HAS_STREAM_REDIRECTION + + +#if GTEST_HAS_DEATH_TEST + +const ::std::vector& GetInjectableArgvs(); +void SetInjectableArgvs(const ::std::vector* + new_argvs); + +// A copy of all command line arguments. Set by InitGoogleTest(). +extern ::std::vector g_argvs; + +#endif // GTEST_HAS_DEATH_TEST + +// Defines synchronization primitives. + +#if GTEST_HAS_PTHREAD + +// Sleeps for (roughly) n milli-seconds. This function is only for +// testing Google Test's own constructs. Don't use it in user tests, +// either directly or indirectly. +inline void SleepMilliseconds(int n) { + const timespec time = { + 0, // 0 seconds. + n * 1000L * 1000L, // And n ms. + }; + nanosleep(&time, NULL); +} + +// Allows a controller thread to pause execution of newly created +// threads until notified. Instances of this class must be created +// and destroyed in the controller thread. +// +// This class is only for testing Google Test's own constructs. Do not +// use it in user tests, either directly or indirectly. +class Notification { + public: + Notification() : notified_(false) { + GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL)); + } + ~Notification() { + pthread_mutex_destroy(&mutex_); + } + + // Notifies all threads created with this notification to start. Must + // be called from the controller thread. + void Notify() { + pthread_mutex_lock(&mutex_); + notified_ = true; + pthread_mutex_unlock(&mutex_); + } + + // Blocks until the controller thread notifies. Must be called from a test + // thread. + void WaitForNotification() { + for (;;) { + pthread_mutex_lock(&mutex_); + const bool notified = notified_; + pthread_mutex_unlock(&mutex_); + if (notified) + break; + SleepMilliseconds(10); + } + } + + private: + pthread_mutex_t mutex_; + bool notified_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(Notification); +}; + +// As a C-function, ThreadFuncWithCLinkage cannot be templated itself. +// Consequently, it cannot select a correct instantiation of ThreadWithParam +// in order to call its Run(). Introducing ThreadWithParamBase as a +// non-templated base class for ThreadWithParam allows us to bypass this +// problem. +class ThreadWithParamBase { + public: + virtual ~ThreadWithParamBase() {} + virtual void Run() = 0; +}; + +// pthread_create() accepts a pointer to a function type with the C linkage. +// According to the Standard (7.5/1), function types with different linkages +// are different even if they are otherwise identical. Some compilers (for +// example, SunStudio) treat them as different types. Since class methods +// cannot be defined with C-linkage we need to define a free C-function to +// pass into pthread_create(). +extern "C" inline void* ThreadFuncWithCLinkage(void* thread) { + static_cast(thread)->Run(); + return NULL; +} + +// Helper class for testing Google Test's multi-threading constructs. +// To use it, write: +// +// void ThreadFunc(int param) { /* Do things with param */ } +// Notification thread_can_start; +// ... +// // The thread_can_start parameter is optional; you can supply NULL. +// ThreadWithParam thread(&ThreadFunc, 5, &thread_can_start); +// thread_can_start.Notify(); +// +// These classes are only for testing Google Test's own constructs. Do +// not use them in user tests, either directly or indirectly. +template +class ThreadWithParam : public ThreadWithParamBase { + public: + typedef void (*UserThreadFunc)(T); + + ThreadWithParam( + UserThreadFunc func, T param, Notification* thread_can_start) + : func_(func), + param_(param), + thread_can_start_(thread_can_start), + finished_(false) { + ThreadWithParamBase* const base = this; + // The thread can be created only after all fields except thread_ + // have been initialized. + GTEST_CHECK_POSIX_SUCCESS_( + pthread_create(&thread_, 0, &ThreadFuncWithCLinkage, base)); + } + ~ThreadWithParam() { Join(); } + + void Join() { + if (!finished_) { + GTEST_CHECK_POSIX_SUCCESS_(pthread_join(thread_, 0)); + finished_ = true; + } + } + + virtual void Run() { + if (thread_can_start_ != NULL) + thread_can_start_->WaitForNotification(); + func_(param_); + } + + private: + const UserThreadFunc func_; // User-supplied thread function. + const T param_; // User-supplied parameter to the thread function. + // When non-NULL, used to block execution until the controller thread + // notifies. + Notification* const thread_can_start_; + bool finished_; // true iff we know that the thread function has finished. + pthread_t thread_; // The native thread object. + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadWithParam); +}; + +// MutexBase and Mutex implement mutex on pthreads-based platforms. They +// are used in conjunction with class MutexLock: +// +// Mutex mutex; +// ... +// MutexLock lock(&mutex); // Acquires the mutex and releases it at the end +// // of the current scope. +// +// MutexBase implements behavior for both statically and dynamically +// allocated mutexes. Do not use MutexBase directly. Instead, write +// the following to define a static mutex: +// +// GTEST_DEFINE_STATIC_MUTEX_(g_some_mutex); +// +// You can forward declare a static mutex like this: +// +// GTEST_DECLARE_STATIC_MUTEX_(g_some_mutex); +// +// To create a dynamic mutex, just define an object of type Mutex. +class MutexBase { + public: + // Acquires this mutex. + void Lock() { + GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_lock(&mutex_)); + owner_ = pthread_self(); + has_owner_ = true; + } + + // Releases this mutex. + void Unlock() { + // Since the lock is being released the owner_ field should no longer be + // considered valid. We don't protect writing to has_owner_ here, as it's + // the caller's responsibility to ensure that the current thread holds the + // mutex when this is called. + has_owner_ = false; + GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_unlock(&mutex_)); + } + + // Does nothing if the current thread holds the mutex. Otherwise, crashes + // with high probability. + void AssertHeld() const { + GTEST_CHECK_(has_owner_ && pthread_equal(owner_, pthread_self())) + << "The current thread is not holding the mutex @" << this; + } + + // A static mutex may be used before main() is entered. It may even + // be used before the dynamic initialization stage. Therefore we + // must be able to initialize a static mutex object at link time. + // This means MutexBase has to be a POD and its member variables + // have to be public. + public: + pthread_mutex_t mutex_; // The underlying pthread mutex. + // has_owner_ indicates whether the owner_ field below contains a valid thread + // ID and is therefore safe to inspect (e.g., to use in pthread_equal()). All + // accesses to the owner_ field should be protected by a check of this field. + // An alternative might be to memset() owner_ to all zeros, but there's no + // guarantee that a zero'd pthread_t is necessarily invalid or even different + // from pthread_self(). + bool has_owner_; + pthread_t owner_; // The thread holding the mutex. +}; + +// Forward-declares a static mutex. +# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ + extern ::testing::internal::MutexBase mutex + +// Defines and statically (i.e. at link time) initializes a static mutex. +// The initialization list here does not explicitly initialize each field, +// instead relying on default initialization for the unspecified fields. In +// particular, the owner_ field (a pthread_t) is not explicitly initialized. +// This allows initialization to work whether pthread_t is a scalar or struct. +// The flag -Wmissing-field-initializers must not be specified for this to work. +# define GTEST_DEFINE_STATIC_MUTEX_(mutex) \ + ::testing::internal::MutexBase mutex = { PTHREAD_MUTEX_INITIALIZER, false } + +// The Mutex class can only be used for mutexes created at runtime. It +// shares its API with MutexBase otherwise. +class Mutex : public MutexBase { + public: + Mutex() { + GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_init(&mutex_, NULL)); + has_owner_ = false; + } + ~Mutex() { + GTEST_CHECK_POSIX_SUCCESS_(pthread_mutex_destroy(&mutex_)); + } + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(Mutex); +}; + +// We cannot name this class MutexLock as the ctor declaration would +// conflict with a macro named MutexLock, which is defined on some +// platforms. Hence the typedef trick below. +class GTestMutexLock { + public: + explicit GTestMutexLock(MutexBase* mutex) + : mutex_(mutex) { mutex_->Lock(); } + + ~GTestMutexLock() { mutex_->Unlock(); } + + private: + MutexBase* const mutex_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(GTestMutexLock); +}; + +typedef GTestMutexLock MutexLock; + +// Helpers for ThreadLocal. + +// pthread_key_create() requires DeleteThreadLocalValue() to have +// C-linkage. Therefore it cannot be templatized to access +// ThreadLocal. Hence the need for class +// ThreadLocalValueHolderBase. +class ThreadLocalValueHolderBase { + public: + virtual ~ThreadLocalValueHolderBase() {} +}; + +// Called by pthread to delete thread-local data stored by +// pthread_setspecific(). +extern "C" inline void DeleteThreadLocalValue(void* value_holder) { + delete static_cast(value_holder); +} + +// Implements thread-local storage on pthreads-based systems. +// +// // Thread 1 +// ThreadLocal tl(100); // 100 is the default value for each thread. +// +// // Thread 2 +// tl.set(150); // Changes the value for thread 2 only. +// EXPECT_EQ(150, tl.get()); +// +// // Thread 1 +// EXPECT_EQ(100, tl.get()); // In thread 1, tl has the original value. +// tl.set(200); +// EXPECT_EQ(200, tl.get()); +// +// The template type argument T must have a public copy constructor. +// In addition, the default ThreadLocal constructor requires T to have +// a public default constructor. +// +// An object managed for a thread by a ThreadLocal instance is deleted +// when the thread exits. Or, if the ThreadLocal instance dies in +// that thread, when the ThreadLocal dies. It's the user's +// responsibility to ensure that all other threads using a ThreadLocal +// have exited when it dies, or the per-thread objects for those +// threads will not be deleted. +// +// Google Test only uses global ThreadLocal objects. That means they +// will die after main() has returned. Therefore, no per-thread +// object managed by Google Test will be leaked as long as all threads +// using Google Test have exited when main() returns. +template +class ThreadLocal { + public: + ThreadLocal() : key_(CreateKey()), + default_() {} + explicit ThreadLocal(const T& value) : key_(CreateKey()), + default_(value) {} + + ~ThreadLocal() { + // Destroys the managed object for the current thread, if any. + DeleteThreadLocalValue(pthread_getspecific(key_)); + + // Releases resources associated with the key. This will *not* + // delete managed objects for other threads. + GTEST_CHECK_POSIX_SUCCESS_(pthread_key_delete(key_)); + } + + T* pointer() { return GetOrCreateValue(); } + const T* pointer() const { return GetOrCreateValue(); } + const T& get() const { return *pointer(); } + void set(const T& value) { *pointer() = value; } + + private: + // Holds a value of type T. + class ValueHolder : public ThreadLocalValueHolderBase { + public: + explicit ValueHolder(const T& value) : value_(value) {} + + T* pointer() { return &value_; } + + private: + T value_; + GTEST_DISALLOW_COPY_AND_ASSIGN_(ValueHolder); + }; + + static pthread_key_t CreateKey() { + pthread_key_t key; + // When a thread exits, DeleteThreadLocalValue() will be called on + // the object managed for that thread. + GTEST_CHECK_POSIX_SUCCESS_( + pthread_key_create(&key, &DeleteThreadLocalValue)); + return key; + } + + T* GetOrCreateValue() const { + ThreadLocalValueHolderBase* const holder = + static_cast(pthread_getspecific(key_)); + if (holder != NULL) { + return CheckedDowncastToActualType(holder)->pointer(); + } + + ValueHolder* const new_holder = new ValueHolder(default_); + ThreadLocalValueHolderBase* const holder_base = new_holder; + GTEST_CHECK_POSIX_SUCCESS_(pthread_setspecific(key_, holder_base)); + return new_holder->pointer(); + } + + // A key pthreads uses for looking up per-thread values. + const pthread_key_t key_; + const T default_; // The default value for each thread. + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ThreadLocal); +}; + +# define GTEST_IS_THREADSAFE 1 + +#else // GTEST_HAS_PTHREAD + +// A dummy implementation of synchronization primitives (mutex, lock, +// and thread-local variable). Necessary for compiling Google Test where +// mutex is not supported - using Google Test in multiple threads is not +// supported on such platforms. + +class Mutex { + public: + Mutex() {} + void Lock() {} + void Unlock() {} + void AssertHeld() const {} +}; + +# define GTEST_DECLARE_STATIC_MUTEX_(mutex) \ + extern ::testing::internal::Mutex mutex + +# define GTEST_DEFINE_STATIC_MUTEX_(mutex) ::testing::internal::Mutex mutex + +class GTestMutexLock { + public: + explicit GTestMutexLock(Mutex*) {} // NOLINT +}; + +typedef GTestMutexLock MutexLock; + +template +class ThreadLocal { + public: + ThreadLocal() : value_() {} + explicit ThreadLocal(const T& value) : value_(value) {} + T* pointer() { return &value_; } + const T* pointer() const { return &value_; } + const T& get() const { return value_; } + void set(const T& value) { value_ = value; } + private: + T value_; +}; + +// The above synchronization primitives have dummy implementations. +// Therefore Google Test is not thread-safe. +# define GTEST_IS_THREADSAFE 0 + +#endif // GTEST_HAS_PTHREAD + +// Returns the number of threads running in the process, or 0 to indicate that +// we cannot detect it. +GTEST_API_ size_t GetThreadCount(); + +// Passing non-POD classes through ellipsis (...) crashes the ARM +// compiler and generates a warning in Sun Studio. The Nokia Symbian +// and the IBM XL C/C++ compiler try to instantiate a copy constructor +// for objects passed through ellipsis (...), failing for uncopyable +// objects. We define this to ensure that only POD is passed through +// ellipsis on these systems. +#if defined(__SYMBIAN32__) || defined(__IBMCPP__) || defined(__SUNPRO_CC) +// We lose support for NULL detection where the compiler doesn't like +// passing non-POD classes through ellipsis (...). +# define GTEST_ELLIPSIS_NEEDS_POD_ 1 +#else +# define GTEST_CAN_COMPARE_NULL 1 +#endif + +// The Nokia Symbian and IBM XL C/C++ compilers cannot decide between +// const T& and const T* in a function template. These compilers +// _can_ decide between class template specializations for T and T*, +// so a tr1::type_traits-like is_pointer works. +#if defined(__SYMBIAN32__) || defined(__IBMCPP__) +# define GTEST_NEEDS_IS_POINTER_ 1 +#endif + +template +struct bool_constant { + typedef bool_constant type; + static const bool value = bool_value; +}; +template const bool bool_constant::value; + +typedef bool_constant false_type; +typedef bool_constant true_type; + +template +struct is_pointer : public false_type {}; + +template +struct is_pointer : public true_type {}; + +template +struct IteratorTraits { + typedef typename Iterator::value_type value_type; +}; + +template +struct IteratorTraits { + typedef T value_type; +}; + +template +struct IteratorTraits { + typedef T value_type; +}; + +#if GTEST_OS_WINDOWS +# define GTEST_PATH_SEP_ "\\" +# define GTEST_HAS_ALT_PATH_SEP_ 1 +// The biggest signed integer type the compiler supports. +typedef __int64 BiggestInt; +#else +# define GTEST_PATH_SEP_ "/" +# define GTEST_HAS_ALT_PATH_SEP_ 0 +typedef long long BiggestInt; // NOLINT +#endif // GTEST_OS_WINDOWS + +// Utilities for char. + +// isspace(int ch) and friends accept an unsigned char or EOF. char +// may be signed, depending on the compiler (or compiler flags). +// Therefore we need to cast a char to unsigned char before calling +// isspace(), etc. + +inline bool IsAlpha(char ch) { + return isalpha(static_cast(ch)) != 0; +} +inline bool IsAlNum(char ch) { + return isalnum(static_cast(ch)) != 0; +} +inline bool IsDigit(char ch) { + return isdigit(static_cast(ch)) != 0; +} +inline bool IsLower(char ch) { + return islower(static_cast(ch)) != 0; +} +inline bool IsSpace(char ch) { + return isspace(static_cast(ch)) != 0; +} +inline bool IsUpper(char ch) { + return isupper(static_cast(ch)) != 0; +} +inline bool IsXDigit(char ch) { + return isxdigit(static_cast(ch)) != 0; +} +inline bool IsXDigit(wchar_t ch) { + const unsigned char low_byte = static_cast(ch); + return ch == low_byte && isxdigit(low_byte) != 0; +} + +inline char ToLower(char ch) { + return static_cast(tolower(static_cast(ch))); +} +inline char ToUpper(char ch) { + return static_cast(toupper(static_cast(ch))); +} + +// The testing::internal::posix namespace holds wrappers for common +// POSIX functions. These wrappers hide the differences between +// Windows/MSVC and POSIX systems. Since some compilers define these +// standard functions as macros, the wrapper cannot have the same name +// as the wrapped function. + +namespace posix { + +// Functions with a different name on Windows. + +#if GTEST_OS_WINDOWS + +typedef struct _stat StatStruct; + +# ifdef __BORLANDC__ +inline int IsATTY(int fd) { return isatty(fd); } +inline int StrCaseCmp(const char* s1, const char* s2) { + return stricmp(s1, s2); +} +inline char* StrDup(const char* src) { return strdup(src); } +# else // !__BORLANDC__ +# if GTEST_OS_WINDOWS_MOBILE +inline int IsATTY(int /* fd */) { return 0; } +# else +inline int IsATTY(int fd) { return _isatty(fd); } +# endif // GTEST_OS_WINDOWS_MOBILE +inline int StrCaseCmp(const char* s1, const char* s2) { + return _stricmp(s1, s2); +} +inline char* StrDup(const char* src) { return _strdup(src); } +# endif // __BORLANDC__ + +# if GTEST_OS_WINDOWS_MOBILE +inline int FileNo(FILE* file) { return reinterpret_cast(_fileno(file)); } +// Stat(), RmDir(), and IsDir() are not needed on Windows CE at this +// time and thus not defined there. +# else +inline int FileNo(FILE* file) { return _fileno(file); } +inline int Stat(const char* path, StatStruct* buf) { return _stat(path, buf); } +inline int RmDir(const char* dir) { return _rmdir(dir); } +inline bool IsDir(const StatStruct& st) { + return (_S_IFDIR & st.st_mode) != 0; +} +# endif // GTEST_OS_WINDOWS_MOBILE + +#else + +typedef struct stat StatStruct; + +inline int FileNo(FILE* file) { return fileno(file); } +inline int IsATTY(int fd) { return isatty(fd); } +inline int Stat(const char* path, StatStruct* buf) { return stat(path, buf); } +inline int StrCaseCmp(const char* s1, const char* s2) { + return strcasecmp(s1, s2); +} +inline char* StrDup(const char* src) { return strdup(src); } +inline int RmDir(const char* dir) { return rmdir(dir); } +inline bool IsDir(const StatStruct& st) { return S_ISDIR(st.st_mode); } + +#endif // GTEST_OS_WINDOWS + +// Functions deprecated by MSVC 8.0. + +#ifdef _MSC_VER +// Temporarily disable warning 4996 (deprecated function). +# pragma warning(push) +# pragma warning(disable:4996) +#endif + +inline const char* StrNCpy(char* dest, const char* src, size_t n) { + return strncpy(dest, src, n); +} + +// ChDir(), FReopen(), FDOpen(), Read(), Write(), Close(), and +// StrError() aren't needed on Windows CE at this time and thus not +// defined there. + +#if !GTEST_OS_WINDOWS_MOBILE +inline int ChDir(const char* dir) { return chdir(dir); } +#endif +inline FILE* FOpen(const char* path, const char* mode) { + return fopen(path, mode); +} +#if !GTEST_OS_WINDOWS_MOBILE +inline FILE *FReopen(const char* path, const char* mode, FILE* stream) { + return freopen(path, mode, stream); +} +inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); } +#endif +inline int FClose(FILE* fp) { return fclose(fp); } +#if !GTEST_OS_WINDOWS_MOBILE +inline int Read(int fd, void* buf, unsigned int count) { + return static_cast(read(fd, buf, count)); +} +inline int Write(int fd, const void* buf, unsigned int count) { + return static_cast(write(fd, buf, count)); +} +inline int Close(int fd) { return close(fd); } +inline const char* StrError(int errnum) { return strerror(errnum); } +#endif +inline const char* GetEnv(const char* name) { +#if GTEST_OS_WINDOWS_MOBILE + // We are on Windows CE, which has no environment variables. + return NULL; +#elif defined(__BORLANDC__) || defined(__SunOS_5_8) || defined(__SunOS_5_9) + // Environment variables which we programmatically clear will be set to the + // empty string rather than unset (NULL). Handle that case. + const char* const env = getenv(name); + return (env != NULL && env[0] != '\0') ? env : NULL; +#else + return getenv(name); +#endif +} + +#ifdef _MSC_VER +# pragma warning(pop) // Restores the warning state. +#endif + +#if GTEST_OS_WINDOWS_MOBILE +// Windows CE has no C library. The abort() function is used in +// several places in Google Test. This implementation provides a reasonable +// imitation of standard behaviour. +void Abort(); +#else +inline void Abort() { abort(); } +#endif // GTEST_OS_WINDOWS_MOBILE + +} // namespace posix + +// MSVC "deprecates" snprintf and issues warnings wherever it is used. In +// order to avoid these warnings, we need to use _snprintf or _snprintf_s on +// MSVC-based platforms. We map the GTEST_SNPRINTF_ macro to the appropriate +// function in order to achieve that. We use macro definition here because +// snprintf is a variadic function. +#if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE +// MSVC 2005 and above support variadic macros. +# define GTEST_SNPRINTF_(buffer, size, format, ...) \ + _snprintf_s(buffer, size, size, format, __VA_ARGS__) +#elif defined(_MSC_VER) +// Windows CE does not define _snprintf_s and MSVC prior to 2005 doesn't +// complain about _snprintf. +# define GTEST_SNPRINTF_ _snprintf +#else +# define GTEST_SNPRINTF_ snprintf +#endif + +// The maximum number a BiggestInt can represent. This definition +// works no matter BiggestInt is represented in one's complement or +// two's complement. +// +// We cannot rely on numeric_limits in STL, as __int64 and long long +// are not part of standard C++ and numeric_limits doesn't need to be +// defined for them. +const BiggestInt kMaxBiggestInt = + ~(static_cast(1) << (8*sizeof(BiggestInt) - 1)); + +// This template class serves as a compile-time function from size to +// type. It maps a size in bytes to a primitive type with that +// size. e.g. +// +// TypeWithSize<4>::UInt +// +// is typedef-ed to be unsigned int (unsigned integer made up of 4 +// bytes). +// +// Such functionality should belong to STL, but I cannot find it +// there. +// +// Google Test uses this class in the implementation of floating-point +// comparison. +// +// For now it only handles UInt (unsigned int) as that's all Google Test +// needs. Other types can be easily added in the future if need +// arises. +template +class TypeWithSize { + public: + // This prevents the user from using TypeWithSize with incorrect + // values of N. + typedef void UInt; +}; + +// The specialization for size 4. +template <> +class TypeWithSize<4> { + public: + // unsigned int has size 4 in both gcc and MSVC. + // + // As base/basictypes.h doesn't compile on Windows, we cannot use + // uint32, uint64, and etc here. + typedef int Int; + typedef unsigned int UInt; +}; + +// The specialization for size 8. +template <> +class TypeWithSize<8> { + public: +#if GTEST_OS_WINDOWS + typedef __int64 Int; + typedef unsigned __int64 UInt; +#else + typedef long long Int; // NOLINT + typedef unsigned long long UInt; // NOLINT +#endif // GTEST_OS_WINDOWS +}; + +// Integer types of known sizes. +typedef TypeWithSize<4>::Int Int32; +typedef TypeWithSize<4>::UInt UInt32; +typedef TypeWithSize<8>::Int Int64; +typedef TypeWithSize<8>::UInt UInt64; +typedef TypeWithSize<8>::Int TimeInMillis; // Represents time in milliseconds. + +// Utilities for command line flags and environment variables. + +// Macro for referencing flags. +#define GTEST_FLAG(name) FLAGS_gtest_##name + +// Macros for declaring flags. +#define GTEST_DECLARE_bool_(name) GTEST_API_ extern bool GTEST_FLAG(name) +#define GTEST_DECLARE_int32_(name) \ + GTEST_API_ extern ::testing::internal::Int32 GTEST_FLAG(name) +#define GTEST_DECLARE_string_(name) \ + GTEST_API_ extern ::std::string GTEST_FLAG(name) + +// Macros for defining flags. +#define GTEST_DEFINE_bool_(name, default_val, doc) \ + GTEST_API_ bool GTEST_FLAG(name) = (default_val) +#define GTEST_DEFINE_int32_(name, default_val, doc) \ + GTEST_API_ ::testing::internal::Int32 GTEST_FLAG(name) = (default_val) +#define GTEST_DEFINE_string_(name, default_val, doc) \ + GTEST_API_ ::std::string GTEST_FLAG(name) = (default_val) + +// Thread annotations +#define GTEST_EXCLUSIVE_LOCK_REQUIRED_(locks) +#define GTEST_LOCK_EXCLUDED_(locks) + +// Parses 'str' for a 32-bit signed integer. If successful, writes the result +// to *value and returns true; otherwise leaves *value unchanged and returns +// false. +// TODO(chandlerc): Find a better way to refactor flag and environment parsing +// out of both gtest-port.cc and gtest.cc to avoid exporting this utility +// function. +bool ParseInt32(const Message& src_text, const char* str, Int32* value); + +// Parses a bool/Int32/string from the environment variable +// corresponding to the given Google Test flag. +bool BoolFromGTestEnv(const char* flag, bool default_val); +GTEST_API_ Int32 Int32FromGTestEnv(const char* flag, Int32 default_val); +const char* StringFromGTestEnv(const char* flag, const char* default_val); + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_PORT_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-string.h b/test/fmw/gtest/include/gtest/internal/gtest-string.h new file mode 100644 index 00000000000..97f1a7fdd2c --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-string.h @@ -0,0 +1,167 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Authors: wan@google.com (Zhanyong Wan), eefacm@gmail.com (Sean Mcafee) +// +// The Google C++ Testing Framework (Google Test) +// +// This header file declares the String class and functions used internally by +// Google Test. They are subject to change without notice. They should not used +// by code external to Google Test. +// +// This header file is #included by . +// It should not be #included by other files. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ + +#ifdef __BORLANDC__ +// string.h is not guaranteed to provide strcpy on C++ Builder. +# include +#endif + +#include +#include + +#include "gtest/internal/gtest-port.h" + +namespace testing { +namespace internal { + +// String - an abstract class holding static string utilities. +class GTEST_API_ String { + public: + // Static utility methods + + // Clones a 0-terminated C string, allocating memory using new. The + // caller is responsible for deleting the return value using + // delete[]. Returns the cloned string, or NULL if the input is + // NULL. + // + // This is different from strdup() in string.h, which allocates + // memory using malloc(). + static const char* CloneCString(const char* c_str); + +#if GTEST_OS_WINDOWS_MOBILE + // Windows CE does not have the 'ANSI' versions of Win32 APIs. To be + // able to pass strings to Win32 APIs on CE we need to convert them + // to 'Unicode', UTF-16. + + // Creates a UTF-16 wide string from the given ANSI string, allocating + // memory using new. The caller is responsible for deleting the return + // value using delete[]. Returns the wide string, or NULL if the + // input is NULL. + // + // The wide string is created using the ANSI codepage (CP_ACP) to + // match the behaviour of the ANSI versions of Win32 calls and the + // C runtime. + static LPCWSTR AnsiToUtf16(const char* c_str); + + // Creates an ANSI string from the given wide string, allocating + // memory using new. The caller is responsible for deleting the return + // value using delete[]. Returns the ANSI string, or NULL if the + // input is NULL. + // + // The returned string is created using the ANSI codepage (CP_ACP) to + // match the behaviour of the ANSI versions of Win32 calls and the + // C runtime. + static const char* Utf16ToAnsi(LPCWSTR utf16_str); +#endif + + // Compares two C strings. Returns true iff they have the same content. + // + // Unlike strcmp(), this function can handle NULL argument(s). A + // NULL C string is considered different to any non-NULL C string, + // including the empty string. + static bool CStringEquals(const char* lhs, const char* rhs); + + // Converts a wide C string to a String using the UTF-8 encoding. + // NULL will be converted to "(null)". If an error occurred during + // the conversion, "(failed to convert from wide string)" is + // returned. + static std::string ShowWideCString(const wchar_t* wide_c_str); + + // Compares two wide C strings. Returns true iff they have the same + // content. + // + // Unlike wcscmp(), this function can handle NULL argument(s). A + // NULL C string is considered different to any non-NULL C string, + // including the empty string. + static bool WideCStringEquals(const wchar_t* lhs, const wchar_t* rhs); + + // Compares two C strings, ignoring case. Returns true iff they + // have the same content. + // + // Unlike strcasecmp(), this function can handle NULL argument(s). + // A NULL C string is considered different to any non-NULL C string, + // including the empty string. + static bool CaseInsensitiveCStringEquals(const char* lhs, + const char* rhs); + + // Compares two wide C strings, ignoring case. Returns true iff they + // have the same content. + // + // Unlike wcscasecmp(), this function can handle NULL argument(s). + // A NULL C string is considered different to any non-NULL wide C string, + // including the empty string. + // NB: The implementations on different platforms slightly differ. + // On windows, this method uses _wcsicmp which compares according to LC_CTYPE + // environment variable. On GNU platform this method uses wcscasecmp + // which compares according to LC_CTYPE category of the current locale. + // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the + // current locale. + static bool CaseInsensitiveWideCStringEquals(const wchar_t* lhs, + const wchar_t* rhs); + + // Returns true iff the given string ends with the given suffix, ignoring + // case. Any string is considered to end with an empty suffix. + static bool EndsWithCaseInsensitive( + const std::string& str, const std::string& suffix); + + // Formats an int value as "%02d". + static std::string FormatIntWidth2(int value); // "%02d" for width == 2 + + // Formats an int value as "%X". + static std::string FormatHexInt(int value); + + // Formats a byte as "%02X". + static std::string FormatByte(unsigned char value); + + private: + String(); // Not meant to be instantiated. +}; // class String + +// Gets the content of the stringstream's buffer as an std::string. Each '\0' +// character in the buffer is replaced with "\\0". +GTEST_API_ std::string StringStreamToString(::std::stringstream* stream); + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_STRING_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-tuple.h b/test/fmw/gtest/include/gtest/internal/gtest-tuple.h new file mode 100644 index 00000000000..7b3dfc312dc --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-tuple.h @@ -0,0 +1,1012 @@ +// This file was GENERATED by command: +// pump.py gtest-tuple.h.pump +// DO NOT EDIT BY HAND!!! + +// Copyright 2009 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) + +// Implements a subset of TR1 tuple needed by Google Test and Google Mock. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ + +#include // For ::std::pair. + +// The compiler used in Symbian has a bug that prevents us from declaring the +// tuple template as a friend (it complains that tuple is redefined). This +// hack bypasses the bug by declaring the members that should otherwise be +// private as public. +// Sun Studio versions < 12 also have the above bug. +#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590) +# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public: +#else +# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \ + template friend class tuple; \ + private: +#endif + +// GTEST_n_TUPLE_(T) is the type of an n-tuple. +#define GTEST_0_TUPLE_(T) tuple<> +#define GTEST_1_TUPLE_(T) tuple +#define GTEST_2_TUPLE_(T) tuple +#define GTEST_3_TUPLE_(T) tuple +#define GTEST_4_TUPLE_(T) tuple +#define GTEST_5_TUPLE_(T) tuple +#define GTEST_6_TUPLE_(T) tuple +#define GTEST_7_TUPLE_(T) tuple +#define GTEST_8_TUPLE_(T) tuple +#define GTEST_9_TUPLE_(T) tuple +#define GTEST_10_TUPLE_(T) tuple + +// GTEST_n_TYPENAMES_(T) declares a list of n typenames. +#define GTEST_0_TYPENAMES_(T) +#define GTEST_1_TYPENAMES_(T) typename T##0 +#define GTEST_2_TYPENAMES_(T) typename T##0, typename T##1 +#define GTEST_3_TYPENAMES_(T) typename T##0, typename T##1, typename T##2 +#define GTEST_4_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \ + typename T##3 +#define GTEST_5_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \ + typename T##3, typename T##4 +#define GTEST_6_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \ + typename T##3, typename T##4, typename T##5 +#define GTEST_7_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \ + typename T##3, typename T##4, typename T##5, typename T##6 +#define GTEST_8_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \ + typename T##3, typename T##4, typename T##5, typename T##6, typename T##7 +#define GTEST_9_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \ + typename T##3, typename T##4, typename T##5, typename T##6, \ + typename T##7, typename T##8 +#define GTEST_10_TYPENAMES_(T) typename T##0, typename T##1, typename T##2, \ + typename T##3, typename T##4, typename T##5, typename T##6, \ + typename T##7, typename T##8, typename T##9 + +// In theory, defining stuff in the ::std namespace is undefined +// behavior. We can do this as we are playing the role of a standard +// library vendor. +namespace std { +namespace tr1 { + +template +class tuple; + +// Anything in namespace gtest_internal is Google Test's INTERNAL +// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code. +namespace gtest_internal { + +// ByRef::type is T if T is a reference; otherwise it's const T&. +template +struct ByRef { typedef const T& type; }; // NOLINT +template +struct ByRef { typedef T& type; }; // NOLINT + +// A handy wrapper for ByRef. +#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef::type + +// AddRef::type is T if T is a reference; otherwise it's T&. This +// is the same as tr1::add_reference::type. +template +struct AddRef { typedef T& type; }; // NOLINT +template +struct AddRef { typedef T& type; }; // NOLINT + +// A handy wrapper for AddRef. +#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef::type + +// A helper for implementing get(). +template class Get; + +// A helper for implementing tuple_element. kIndexValid is true +// iff k < the number of fields in tuple type T. +template +struct TupleElement; + +template +struct TupleElement { + typedef T0 type; +}; + +template +struct TupleElement { + typedef T1 type; +}; + +template +struct TupleElement { + typedef T2 type; +}; + +template +struct TupleElement { + typedef T3 type; +}; + +template +struct TupleElement { + typedef T4 type; +}; + +template +struct TupleElement { + typedef T5 type; +}; + +template +struct TupleElement { + typedef T6 type; +}; + +template +struct TupleElement { + typedef T7 type; +}; + +template +struct TupleElement { + typedef T8 type; +}; + +template +struct TupleElement { + typedef T9 type; +}; + +} // namespace gtest_internal + +template <> +class tuple<> { + public: + tuple() {} + tuple(const tuple& /* t */) {} + tuple& operator=(const tuple& /* t */) { return *this; } +}; + +template +class GTEST_1_TUPLE_(T) { + public: + template friend class gtest_internal::Get; + + tuple() : f0_() {} + + explicit tuple(GTEST_BY_REF_(T0) f0) : f0_(f0) {} + + tuple(const tuple& t) : f0_(t.f0_) {} + + template + tuple(const GTEST_1_TUPLE_(U)& t) : f0_(t.f0_) {} + + tuple& operator=(const tuple& t) { return CopyFrom(t); } + + template + tuple& operator=(const GTEST_1_TUPLE_(U)& t) { + return CopyFrom(t); + } + + GTEST_DECLARE_TUPLE_AS_FRIEND_ + + template + tuple& CopyFrom(const GTEST_1_TUPLE_(U)& t) { + f0_ = t.f0_; + return *this; + } + + T0 f0_; +}; + +template +class GTEST_2_TUPLE_(T) { + public: + template friend class gtest_internal::Get; + + tuple() : f0_(), f1_() {} + + explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1) : f0_(f0), + f1_(f1) {} + + tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_) {} + + template + tuple(const GTEST_2_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_) {} + template + tuple(const ::std::pair& p) : f0_(p.first), f1_(p.second) {} + + tuple& operator=(const tuple& t) { return CopyFrom(t); } + + template + tuple& operator=(const GTEST_2_TUPLE_(U)& t) { + return CopyFrom(t); + } + template + tuple& operator=(const ::std::pair& p) { + f0_ = p.first; + f1_ = p.second; + return *this; + } + + GTEST_DECLARE_TUPLE_AS_FRIEND_ + + template + tuple& CopyFrom(const GTEST_2_TUPLE_(U)& t) { + f0_ = t.f0_; + f1_ = t.f1_; + return *this; + } + + T0 f0_; + T1 f1_; +}; + +template +class GTEST_3_TUPLE_(T) { + public: + template friend class gtest_internal::Get; + + tuple() : f0_(), f1_(), f2_() {} + + explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1, + GTEST_BY_REF_(T2) f2) : f0_(f0), f1_(f1), f2_(f2) {} + + tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {} + + template + tuple(const GTEST_3_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_) {} + + tuple& operator=(const tuple& t) { return CopyFrom(t); } + + template + tuple& operator=(const GTEST_3_TUPLE_(U)& t) { + return CopyFrom(t); + } + + GTEST_DECLARE_TUPLE_AS_FRIEND_ + + template + tuple& CopyFrom(const GTEST_3_TUPLE_(U)& t) { + f0_ = t.f0_; + f1_ = t.f1_; + f2_ = t.f2_; + return *this; + } + + T0 f0_; + T1 f1_; + T2 f2_; +}; + +template +class GTEST_4_TUPLE_(T) { + public: + template friend class gtest_internal::Get; + + tuple() : f0_(), f1_(), f2_(), f3_() {} + + explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1, + GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3) : f0_(f0), f1_(f1), f2_(f2), + f3_(f3) {} + + tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_) {} + + template + tuple(const GTEST_4_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), + f3_(t.f3_) {} + + tuple& operator=(const tuple& t) { return CopyFrom(t); } + + template + tuple& operator=(const GTEST_4_TUPLE_(U)& t) { + return CopyFrom(t); + } + + GTEST_DECLARE_TUPLE_AS_FRIEND_ + + template + tuple& CopyFrom(const GTEST_4_TUPLE_(U)& t) { + f0_ = t.f0_; + f1_ = t.f1_; + f2_ = t.f2_; + f3_ = t.f3_; + return *this; + } + + T0 f0_; + T1 f1_; + T2 f2_; + T3 f3_; +}; + +template +class GTEST_5_TUPLE_(T) { + public: + template friend class gtest_internal::Get; + + tuple() : f0_(), f1_(), f2_(), f3_(), f4_() {} + + explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1, + GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, + GTEST_BY_REF_(T4) f4) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4) {} + + tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_), + f4_(t.f4_) {} + + template + tuple(const GTEST_5_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), + f3_(t.f3_), f4_(t.f4_) {} + + tuple& operator=(const tuple& t) { return CopyFrom(t); } + + template + tuple& operator=(const GTEST_5_TUPLE_(U)& t) { + return CopyFrom(t); + } + + GTEST_DECLARE_TUPLE_AS_FRIEND_ + + template + tuple& CopyFrom(const GTEST_5_TUPLE_(U)& t) { + f0_ = t.f0_; + f1_ = t.f1_; + f2_ = t.f2_; + f3_ = t.f3_; + f4_ = t.f4_; + return *this; + } + + T0 f0_; + T1 f1_; + T2 f2_; + T3 f3_; + T4 f4_; +}; + +template +class GTEST_6_TUPLE_(T) { + public: + template friend class gtest_internal::Get; + + tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_() {} + + explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1, + GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4, + GTEST_BY_REF_(T5) f5) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4), + f5_(f5) {} + + tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_), + f4_(t.f4_), f5_(t.f5_) {} + + template + tuple(const GTEST_6_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), + f3_(t.f3_), f4_(t.f4_), f5_(t.f5_) {} + + tuple& operator=(const tuple& t) { return CopyFrom(t); } + + template + tuple& operator=(const GTEST_6_TUPLE_(U)& t) { + return CopyFrom(t); + } + + GTEST_DECLARE_TUPLE_AS_FRIEND_ + + template + tuple& CopyFrom(const GTEST_6_TUPLE_(U)& t) { + f0_ = t.f0_; + f1_ = t.f1_; + f2_ = t.f2_; + f3_ = t.f3_; + f4_ = t.f4_; + f5_ = t.f5_; + return *this; + } + + T0 f0_; + T1 f1_; + T2 f2_; + T3 f3_; + T4 f4_; + T5 f5_; +}; + +template +class GTEST_7_TUPLE_(T) { + public: + template friend class gtest_internal::Get; + + tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_() {} + + explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1, + GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4, + GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6) : f0_(f0), f1_(f1), f2_(f2), + f3_(f3), f4_(f4), f5_(f5), f6_(f6) {} + + tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_), + f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {} + + template + tuple(const GTEST_7_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), + f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_) {} + + tuple& operator=(const tuple& t) { return CopyFrom(t); } + + template + tuple& operator=(const GTEST_7_TUPLE_(U)& t) { + return CopyFrom(t); + } + + GTEST_DECLARE_TUPLE_AS_FRIEND_ + + template + tuple& CopyFrom(const GTEST_7_TUPLE_(U)& t) { + f0_ = t.f0_; + f1_ = t.f1_; + f2_ = t.f2_; + f3_ = t.f3_; + f4_ = t.f4_; + f5_ = t.f5_; + f6_ = t.f6_; + return *this; + } + + T0 f0_; + T1 f1_; + T2 f2_; + T3 f3_; + T4 f4_; + T5 f5_; + T6 f6_; +}; + +template +class GTEST_8_TUPLE_(T) { + public: + template friend class gtest_internal::Get; + + tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_() {} + + explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1, + GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4, + GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, + GTEST_BY_REF_(T7) f7) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4), + f5_(f5), f6_(f6), f7_(f7) {} + + tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_), + f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {} + + template + tuple(const GTEST_8_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), + f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_) {} + + tuple& operator=(const tuple& t) { return CopyFrom(t); } + + template + tuple& operator=(const GTEST_8_TUPLE_(U)& t) { + return CopyFrom(t); + } + + GTEST_DECLARE_TUPLE_AS_FRIEND_ + + template + tuple& CopyFrom(const GTEST_8_TUPLE_(U)& t) { + f0_ = t.f0_; + f1_ = t.f1_; + f2_ = t.f2_; + f3_ = t.f3_; + f4_ = t.f4_; + f5_ = t.f5_; + f6_ = t.f6_; + f7_ = t.f7_; + return *this; + } + + T0 f0_; + T1 f1_; + T2 f2_; + T3 f3_; + T4 f4_; + T5 f5_; + T6 f6_; + T7 f7_; +}; + +template +class GTEST_9_TUPLE_(T) { + public: + template friend class gtest_internal::Get; + + tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_() {} + + explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1, + GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4, + GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7, + GTEST_BY_REF_(T8) f8) : f0_(f0), f1_(f1), f2_(f2), f3_(f3), f4_(f4), + f5_(f5), f6_(f6), f7_(f7), f8_(f8) {} + + tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_), + f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {} + + template + tuple(const GTEST_9_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), + f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_) {} + + tuple& operator=(const tuple& t) { return CopyFrom(t); } + + template + tuple& operator=(const GTEST_9_TUPLE_(U)& t) { + return CopyFrom(t); + } + + GTEST_DECLARE_TUPLE_AS_FRIEND_ + + template + tuple& CopyFrom(const GTEST_9_TUPLE_(U)& t) { + f0_ = t.f0_; + f1_ = t.f1_; + f2_ = t.f2_; + f3_ = t.f3_; + f4_ = t.f4_; + f5_ = t.f5_; + f6_ = t.f6_; + f7_ = t.f7_; + f8_ = t.f8_; + return *this; + } + + T0 f0_; + T1 f1_; + T2 f2_; + T3 f3_; + T4 f4_; + T5 f5_; + T6 f6_; + T7 f7_; + T8 f8_; +}; + +template +class tuple { + public: + template friend class gtest_internal::Get; + + tuple() : f0_(), f1_(), f2_(), f3_(), f4_(), f5_(), f6_(), f7_(), f8_(), + f9_() {} + + explicit tuple(GTEST_BY_REF_(T0) f0, GTEST_BY_REF_(T1) f1, + GTEST_BY_REF_(T2) f2, GTEST_BY_REF_(T3) f3, GTEST_BY_REF_(T4) f4, + GTEST_BY_REF_(T5) f5, GTEST_BY_REF_(T6) f6, GTEST_BY_REF_(T7) f7, + GTEST_BY_REF_(T8) f8, GTEST_BY_REF_(T9) f9) : f0_(f0), f1_(f1), f2_(f2), + f3_(f3), f4_(f4), f5_(f5), f6_(f6), f7_(f7), f8_(f8), f9_(f9) {} + + tuple(const tuple& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), f3_(t.f3_), + f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_), f9_(t.f9_) {} + + template + tuple(const GTEST_10_TUPLE_(U)& t) : f0_(t.f0_), f1_(t.f1_), f2_(t.f2_), + f3_(t.f3_), f4_(t.f4_), f5_(t.f5_), f6_(t.f6_), f7_(t.f7_), f8_(t.f8_), + f9_(t.f9_) {} + + tuple& operator=(const tuple& t) { return CopyFrom(t); } + + template + tuple& operator=(const GTEST_10_TUPLE_(U)& t) { + return CopyFrom(t); + } + + GTEST_DECLARE_TUPLE_AS_FRIEND_ + + template + tuple& CopyFrom(const GTEST_10_TUPLE_(U)& t) { + f0_ = t.f0_; + f1_ = t.f1_; + f2_ = t.f2_; + f3_ = t.f3_; + f4_ = t.f4_; + f5_ = t.f5_; + f6_ = t.f6_; + f7_ = t.f7_; + f8_ = t.f8_; + f9_ = t.f9_; + return *this; + } + + T0 f0_; + T1 f1_; + T2 f2_; + T3 f3_; + T4 f4_; + T5 f5_; + T6 f6_; + T7 f7_; + T8 f8_; + T9 f9_; +}; + +// 6.1.3.2 Tuple creation functions. + +// Known limitations: we don't support passing an +// std::tr1::reference_wrapper to make_tuple(). And we don't +// implement tie(). + +inline tuple<> make_tuple() { return tuple<>(); } + +template +inline GTEST_1_TUPLE_(T) make_tuple(const T0& f0) { + return GTEST_1_TUPLE_(T)(f0); +} + +template +inline GTEST_2_TUPLE_(T) make_tuple(const T0& f0, const T1& f1) { + return GTEST_2_TUPLE_(T)(f0, f1); +} + +template +inline GTEST_3_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2) { + return GTEST_3_TUPLE_(T)(f0, f1, f2); +} + +template +inline GTEST_4_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2, + const T3& f3) { + return GTEST_4_TUPLE_(T)(f0, f1, f2, f3); +} + +template +inline GTEST_5_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2, + const T3& f3, const T4& f4) { + return GTEST_5_TUPLE_(T)(f0, f1, f2, f3, f4); +} + +template +inline GTEST_6_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2, + const T3& f3, const T4& f4, const T5& f5) { + return GTEST_6_TUPLE_(T)(f0, f1, f2, f3, f4, f5); +} + +template +inline GTEST_7_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2, + const T3& f3, const T4& f4, const T5& f5, const T6& f6) { + return GTEST_7_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6); +} + +template +inline GTEST_8_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2, + const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7) { + return GTEST_8_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7); +} + +template +inline GTEST_9_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2, + const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7, + const T8& f8) { + return GTEST_9_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8); +} + +template +inline GTEST_10_TUPLE_(T) make_tuple(const T0& f0, const T1& f1, const T2& f2, + const T3& f3, const T4& f4, const T5& f5, const T6& f6, const T7& f7, + const T8& f8, const T9& f9) { + return GTEST_10_TUPLE_(T)(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9); +} + +// 6.1.3.3 Tuple helper classes. + +template struct tuple_size; + +template +struct tuple_size { + static const int value = 0; +}; + +template +struct tuple_size { + static const int value = 1; +}; + +template +struct tuple_size { + static const int value = 2; +}; + +template +struct tuple_size { + static const int value = 3; +}; + +template +struct tuple_size { + static const int value = 4; +}; + +template +struct tuple_size { + static const int value = 5; +}; + +template +struct tuple_size { + static const int value = 6; +}; + +template +struct tuple_size { + static const int value = 7; +}; + +template +struct tuple_size { + static const int value = 8; +}; + +template +struct tuple_size { + static const int value = 9; +}; + +template +struct tuple_size { + static const int value = 10; +}; + +template +struct tuple_element { + typedef typename gtest_internal::TupleElement< + k < (tuple_size::value), k, Tuple>::type type; +}; + +#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element::type + +// 6.1.3.4 Element access. + +namespace gtest_internal { + +template <> +class Get<0> { + public: + template + static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple)) + Field(Tuple& t) { return t.f0_; } // NOLINT + + template + static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(0, Tuple)) + ConstField(const Tuple& t) { return t.f0_; } +}; + +template <> +class Get<1> { + public: + template + static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple)) + Field(Tuple& t) { return t.f1_; } // NOLINT + + template + static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(1, Tuple)) + ConstField(const Tuple& t) { return t.f1_; } +}; + +template <> +class Get<2> { + public: + template + static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple)) + Field(Tuple& t) { return t.f2_; } // NOLINT + + template + static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(2, Tuple)) + ConstField(const Tuple& t) { return t.f2_; } +}; + +template <> +class Get<3> { + public: + template + static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple)) + Field(Tuple& t) { return t.f3_; } // NOLINT + + template + static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(3, Tuple)) + ConstField(const Tuple& t) { return t.f3_; } +}; + +template <> +class Get<4> { + public: + template + static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple)) + Field(Tuple& t) { return t.f4_; } // NOLINT + + template + static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(4, Tuple)) + ConstField(const Tuple& t) { return t.f4_; } +}; + +template <> +class Get<5> { + public: + template + static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple)) + Field(Tuple& t) { return t.f5_; } // NOLINT + + template + static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(5, Tuple)) + ConstField(const Tuple& t) { return t.f5_; } +}; + +template <> +class Get<6> { + public: + template + static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple)) + Field(Tuple& t) { return t.f6_; } // NOLINT + + template + static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(6, Tuple)) + ConstField(const Tuple& t) { return t.f6_; } +}; + +template <> +class Get<7> { + public: + template + static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple)) + Field(Tuple& t) { return t.f7_; } // NOLINT + + template + static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(7, Tuple)) + ConstField(const Tuple& t) { return t.f7_; } +}; + +template <> +class Get<8> { + public: + template + static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple)) + Field(Tuple& t) { return t.f8_; } // NOLINT + + template + static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(8, Tuple)) + ConstField(const Tuple& t) { return t.f8_; } +}; + +template <> +class Get<9> { + public: + template + static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple)) + Field(Tuple& t) { return t.f9_; } // NOLINT + + template + static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(9, Tuple)) + ConstField(const Tuple& t) { return t.f9_; } +}; + +} // namespace gtest_internal + +template +GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T))) +get(GTEST_10_TUPLE_(T)& t) { + return gtest_internal::Get::Field(t); +} + +template +GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_10_TUPLE_(T))) +get(const GTEST_10_TUPLE_(T)& t) { + return gtest_internal::Get::ConstField(t); +} + +// 6.1.3.5 Relational operators + +// We only implement == and !=, as we don't have a need for the rest yet. + +namespace gtest_internal { + +// SameSizeTuplePrefixComparator::Eq(t1, t2) returns true if the +// first k fields of t1 equals the first k fields of t2. +// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if +// k1 != k2. +template +struct SameSizeTuplePrefixComparator; + +template <> +struct SameSizeTuplePrefixComparator<0, 0> { + template + static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) { + return true; + } +}; + +template +struct SameSizeTuplePrefixComparator { + template + static bool Eq(const Tuple1& t1, const Tuple2& t2) { + return SameSizeTuplePrefixComparator::Eq(t1, t2) && + ::std::tr1::get(t1) == ::std::tr1::get(t2); + } +}; + +} // namespace gtest_internal + +template +inline bool operator==(const GTEST_10_TUPLE_(T)& t, + const GTEST_10_TUPLE_(U)& u) { + return gtest_internal::SameSizeTuplePrefixComparator< + tuple_size::value, + tuple_size::value>::Eq(t, u); +} + +template +inline bool operator!=(const GTEST_10_TUPLE_(T)& t, + const GTEST_10_TUPLE_(U)& u) { return !(t == u); } + +// 6.1.4 Pairs. +// Unimplemented. + +} // namespace tr1 +} // namespace std + +#undef GTEST_0_TUPLE_ +#undef GTEST_1_TUPLE_ +#undef GTEST_2_TUPLE_ +#undef GTEST_3_TUPLE_ +#undef GTEST_4_TUPLE_ +#undef GTEST_5_TUPLE_ +#undef GTEST_6_TUPLE_ +#undef GTEST_7_TUPLE_ +#undef GTEST_8_TUPLE_ +#undef GTEST_9_TUPLE_ +#undef GTEST_10_TUPLE_ + +#undef GTEST_0_TYPENAMES_ +#undef GTEST_1_TYPENAMES_ +#undef GTEST_2_TYPENAMES_ +#undef GTEST_3_TYPENAMES_ +#undef GTEST_4_TYPENAMES_ +#undef GTEST_5_TYPENAMES_ +#undef GTEST_6_TYPENAMES_ +#undef GTEST_7_TYPENAMES_ +#undef GTEST_8_TYPENAMES_ +#undef GTEST_9_TYPENAMES_ +#undef GTEST_10_TYPENAMES_ + +#undef GTEST_DECLARE_TUPLE_AS_FRIEND_ +#undef GTEST_BY_REF_ +#undef GTEST_ADD_REF_ +#undef GTEST_TUPLE_ELEMENT_ + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-tuple.h.pump b/test/fmw/gtest/include/gtest/internal/gtest-tuple.h.pump new file mode 100644 index 00000000000..c7d9e039b1f --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-tuple.h.pump @@ -0,0 +1,339 @@ +$$ -*- mode: c++; -*- +$var n = 10 $$ Maximum number of tuple fields we want to support. +$$ This meta comment fixes auto-indentation in Emacs. }} +// Copyright 2009 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) + +// Implements a subset of TR1 tuple needed by Google Test and Google Mock. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ + +#include // For ::std::pair. + +// The compiler used in Symbian has a bug that prevents us from declaring the +// tuple template as a friend (it complains that tuple is redefined). This +// hack bypasses the bug by declaring the members that should otherwise be +// private as public. +// Sun Studio versions < 12 also have the above bug. +#if defined(__SYMBIAN32__) || (defined(__SUNPRO_CC) && __SUNPRO_CC < 0x590) +# define GTEST_DECLARE_TUPLE_AS_FRIEND_ public: +#else +# define GTEST_DECLARE_TUPLE_AS_FRIEND_ \ + template friend class tuple; \ + private: +#endif + + +$range i 0..n-1 +$range j 0..n +$range k 1..n +// GTEST_n_TUPLE_(T) is the type of an n-tuple. +#define GTEST_0_TUPLE_(T) tuple<> + +$for k [[ +$range m 0..k-1 +$range m2 k..n-1 +#define GTEST_$(k)_TUPLE_(T) tuple<$for m, [[T##$m]]$for m2 [[, void]]> + +]] + +// GTEST_n_TYPENAMES_(T) declares a list of n typenames. + +$for j [[ +$range m 0..j-1 +#define GTEST_$(j)_TYPENAMES_(T) $for m, [[typename T##$m]] + + +]] + +// In theory, defining stuff in the ::std namespace is undefined +// behavior. We can do this as we are playing the role of a standard +// library vendor. +namespace std { +namespace tr1 { + +template <$for i, [[typename T$i = void]]> +class tuple; + +// Anything in namespace gtest_internal is Google Test's INTERNAL +// IMPLEMENTATION DETAIL and MUST NOT BE USED DIRECTLY in user code. +namespace gtest_internal { + +// ByRef::type is T if T is a reference; otherwise it's const T&. +template +struct ByRef { typedef const T& type; }; // NOLINT +template +struct ByRef { typedef T& type; }; // NOLINT + +// A handy wrapper for ByRef. +#define GTEST_BY_REF_(T) typename ::std::tr1::gtest_internal::ByRef::type + +// AddRef::type is T if T is a reference; otherwise it's T&. This +// is the same as tr1::add_reference::type. +template +struct AddRef { typedef T& type; }; // NOLINT +template +struct AddRef { typedef T& type; }; // NOLINT + +// A handy wrapper for AddRef. +#define GTEST_ADD_REF_(T) typename ::std::tr1::gtest_internal::AddRef::type + +// A helper for implementing get(). +template class Get; + +// A helper for implementing tuple_element. kIndexValid is true +// iff k < the number of fields in tuple type T. +template +struct TupleElement; + + +$for i [[ +template +struct TupleElement { + typedef T$i type; +}; + + +]] +} // namespace gtest_internal + +template <> +class tuple<> { + public: + tuple() {} + tuple(const tuple& /* t */) {} + tuple& operator=(const tuple& /* t */) { return *this; } +}; + + +$for k [[ +$range m 0..k-1 +template +class $if k < n [[GTEST_$(k)_TUPLE_(T)]] $else [[tuple]] { + public: + template friend class gtest_internal::Get; + + tuple() : $for m, [[f$(m)_()]] {} + + explicit tuple($for m, [[GTEST_BY_REF_(T$m) f$m]]) : [[]] +$for m, [[f$(m)_(f$m)]] {} + + tuple(const tuple& t) : $for m, [[f$(m)_(t.f$(m)_)]] {} + + template + tuple(const GTEST_$(k)_TUPLE_(U)& t) : $for m, [[f$(m)_(t.f$(m)_)]] {} + +$if k == 2 [[ + template + tuple(const ::std::pair& p) : f0_(p.first), f1_(p.second) {} + +]] + + tuple& operator=(const tuple& t) { return CopyFrom(t); } + + template + tuple& operator=(const GTEST_$(k)_TUPLE_(U)& t) { + return CopyFrom(t); + } + +$if k == 2 [[ + template + tuple& operator=(const ::std::pair& p) { + f0_ = p.first; + f1_ = p.second; + return *this; + } + +]] + + GTEST_DECLARE_TUPLE_AS_FRIEND_ + + template + tuple& CopyFrom(const GTEST_$(k)_TUPLE_(U)& t) { + +$for m [[ + f$(m)_ = t.f$(m)_; + +]] + return *this; + } + + +$for m [[ + T$m f$(m)_; + +]] +}; + + +]] +// 6.1.3.2 Tuple creation functions. + +// Known limitations: we don't support passing an +// std::tr1::reference_wrapper to make_tuple(). And we don't +// implement tie(). + +inline tuple<> make_tuple() { return tuple<>(); } + +$for k [[ +$range m 0..k-1 + +template +inline GTEST_$(k)_TUPLE_(T) make_tuple($for m, [[const T$m& f$m]]) { + return GTEST_$(k)_TUPLE_(T)($for m, [[f$m]]); +} + +]] + +// 6.1.3.3 Tuple helper classes. + +template struct tuple_size; + + +$for j [[ +template +struct tuple_size { + static const int value = $j; +}; + + +]] +template +struct tuple_element { + typedef typename gtest_internal::TupleElement< + k < (tuple_size::value), k, Tuple>::type type; +}; + +#define GTEST_TUPLE_ELEMENT_(k, Tuple) typename tuple_element::type + +// 6.1.3.4 Element access. + +namespace gtest_internal { + + +$for i [[ +template <> +class Get<$i> { + public: + template + static GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple)) + Field(Tuple& t) { return t.f$(i)_; } // NOLINT + + template + static GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_($i, Tuple)) + ConstField(const Tuple& t) { return t.f$(i)_; } +}; + + +]] +} // namespace gtest_internal + +template +GTEST_ADD_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T))) +get(GTEST_$(n)_TUPLE_(T)& t) { + return gtest_internal::Get::Field(t); +} + +template +GTEST_BY_REF_(GTEST_TUPLE_ELEMENT_(k, GTEST_$(n)_TUPLE_(T))) +get(const GTEST_$(n)_TUPLE_(T)& t) { + return gtest_internal::Get::ConstField(t); +} + +// 6.1.3.5 Relational operators + +// We only implement == and !=, as we don't have a need for the rest yet. + +namespace gtest_internal { + +// SameSizeTuplePrefixComparator::Eq(t1, t2) returns true if the +// first k fields of t1 equals the first k fields of t2. +// SameSizeTuplePrefixComparator(k1, k2) would be a compiler error if +// k1 != k2. +template +struct SameSizeTuplePrefixComparator; + +template <> +struct SameSizeTuplePrefixComparator<0, 0> { + template + static bool Eq(const Tuple1& /* t1 */, const Tuple2& /* t2 */) { + return true; + } +}; + +template +struct SameSizeTuplePrefixComparator { + template + static bool Eq(const Tuple1& t1, const Tuple2& t2) { + return SameSizeTuplePrefixComparator::Eq(t1, t2) && + ::std::tr1::get(t1) == ::std::tr1::get(t2); + } +}; + +} // namespace gtest_internal + +template +inline bool operator==(const GTEST_$(n)_TUPLE_(T)& t, + const GTEST_$(n)_TUPLE_(U)& u) { + return gtest_internal::SameSizeTuplePrefixComparator< + tuple_size::value, + tuple_size::value>::Eq(t, u); +} + +template +inline bool operator!=(const GTEST_$(n)_TUPLE_(T)& t, + const GTEST_$(n)_TUPLE_(U)& u) { return !(t == u); } + +// 6.1.4 Pairs. +// Unimplemented. + +} // namespace tr1 +} // namespace std + + +$for j [[ +#undef GTEST_$(j)_TUPLE_ + +]] + + +$for j [[ +#undef GTEST_$(j)_TYPENAMES_ + +]] + +#undef GTEST_DECLARE_TUPLE_AS_FRIEND_ +#undef GTEST_BY_REF_ +#undef GTEST_ADD_REF_ +#undef GTEST_TUPLE_ELEMENT_ + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TUPLE_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-type-util.h b/test/fmw/gtest/include/gtest/internal/gtest-type-util.h new file mode 100644 index 00000000000..e46f7cfcb48 --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-type-util.h @@ -0,0 +1,3331 @@ +// This file was GENERATED by command: +// pump.py gtest-type-util.h.pump +// DO NOT EDIT BY HAND!!! + +// Copyright 2008 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) + +// Type utilities needed for implementing typed and type-parameterized +// tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND! +// +// Currently we support at most 50 types in a list, and at most 50 +// type-parameterized tests in one type-parameterized test case. +// Please contact googletestframework@googlegroups.com if you need +// more. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ + +#include "gtest/internal/gtest-port.h" + +// #ifdef __GNUC__ is too general here. It is possible to use gcc without using +// libstdc++ (which is where cxxabi.h comes from). +# if GTEST_HAS_CXXABI_H_ +# include +# elif defined(__HP_aCC) +# include +# endif // GTEST_HASH_CXXABI_H_ + +namespace testing { +namespace internal { + +// GetTypeName() returns a human-readable name of type T. +// NB: This function is also used in Google Mock, so don't move it inside of +// the typed-test-only section below. +template +std::string GetTypeName() { +# if GTEST_HAS_RTTI + + const char* const name = typeid(T).name(); +# if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC) + int status = 0; + // gcc's implementation of typeid(T).name() mangles the type name, + // so we have to demangle it. +# if GTEST_HAS_CXXABI_H_ + using abi::__cxa_demangle; +# endif // GTEST_HAS_CXXABI_H_ + char* const readable_name = __cxa_demangle(name, 0, 0, &status); + const std::string name_str(status == 0 ? readable_name : name); + free(readable_name); + return name_str; +# else + return name; +# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC + +# else + + return ""; + +# endif // GTEST_HAS_RTTI +} + +#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +// AssertyTypeEq::type is defined iff T1 and T2 are the same +// type. This can be used as a compile-time assertion to ensure that +// two types are equal. + +template +struct AssertTypeEq; + +template +struct AssertTypeEq { + typedef bool type; +}; + +// A unique type used as the default value for the arguments of class +// template Types. This allows us to simulate variadic templates +// (e.g. Types, Type, and etc), which C++ doesn't +// support directly. +struct None {}; + +// The following family of struct and struct templates are used to +// represent type lists. In particular, TypesN +// represents a type list with N types (T1, T2, ..., and TN) in it. +// Except for Types0, every struct in the family has two member types: +// Head for the first type in the list, and Tail for the rest of the +// list. + +// The empty type list. +struct Types0 {}; + +// Type lists of length 1, 2, 3, and so on. + +template +struct Types1 { + typedef T1 Head; + typedef Types0 Tail; +}; +template +struct Types2 { + typedef T1 Head; + typedef Types1 Tail; +}; + +template +struct Types3 { + typedef T1 Head; + typedef Types2 Tail; +}; + +template +struct Types4 { + typedef T1 Head; + typedef Types3 Tail; +}; + +template +struct Types5 { + typedef T1 Head; + typedef Types4 Tail; +}; + +template +struct Types6 { + typedef T1 Head; + typedef Types5 Tail; +}; + +template +struct Types7 { + typedef T1 Head; + typedef Types6 Tail; +}; + +template +struct Types8 { + typedef T1 Head; + typedef Types7 Tail; +}; + +template +struct Types9 { + typedef T1 Head; + typedef Types8 Tail; +}; + +template +struct Types10 { + typedef T1 Head; + typedef Types9 Tail; +}; + +template +struct Types11 { + typedef T1 Head; + typedef Types10 Tail; +}; + +template +struct Types12 { + typedef T1 Head; + typedef Types11 Tail; +}; + +template +struct Types13 { + typedef T1 Head; + typedef Types12 Tail; +}; + +template +struct Types14 { + typedef T1 Head; + typedef Types13 Tail; +}; + +template +struct Types15 { + typedef T1 Head; + typedef Types14 Tail; +}; + +template +struct Types16 { + typedef T1 Head; + typedef Types15 Tail; +}; + +template +struct Types17 { + typedef T1 Head; + typedef Types16 Tail; +}; + +template +struct Types18 { + typedef T1 Head; + typedef Types17 Tail; +}; + +template +struct Types19 { + typedef T1 Head; + typedef Types18 Tail; +}; + +template +struct Types20 { + typedef T1 Head; + typedef Types19 Tail; +}; + +template +struct Types21 { + typedef T1 Head; + typedef Types20 Tail; +}; + +template +struct Types22 { + typedef T1 Head; + typedef Types21 Tail; +}; + +template +struct Types23 { + typedef T1 Head; + typedef Types22 Tail; +}; + +template +struct Types24 { + typedef T1 Head; + typedef Types23 Tail; +}; + +template +struct Types25 { + typedef T1 Head; + typedef Types24 Tail; +}; + +template +struct Types26 { + typedef T1 Head; + typedef Types25 Tail; +}; + +template +struct Types27 { + typedef T1 Head; + typedef Types26 Tail; +}; + +template +struct Types28 { + typedef T1 Head; + typedef Types27 Tail; +}; + +template +struct Types29 { + typedef T1 Head; + typedef Types28 Tail; +}; + +template +struct Types30 { + typedef T1 Head; + typedef Types29 Tail; +}; + +template +struct Types31 { + typedef T1 Head; + typedef Types30 Tail; +}; + +template +struct Types32 { + typedef T1 Head; + typedef Types31 Tail; +}; + +template +struct Types33 { + typedef T1 Head; + typedef Types32 Tail; +}; + +template +struct Types34 { + typedef T1 Head; + typedef Types33 Tail; +}; + +template +struct Types35 { + typedef T1 Head; + typedef Types34 Tail; +}; + +template +struct Types36 { + typedef T1 Head; + typedef Types35 Tail; +}; + +template +struct Types37 { + typedef T1 Head; + typedef Types36 Tail; +}; + +template +struct Types38 { + typedef T1 Head; + typedef Types37 Tail; +}; + +template +struct Types39 { + typedef T1 Head; + typedef Types38 Tail; +}; + +template +struct Types40 { + typedef T1 Head; + typedef Types39 Tail; +}; + +template +struct Types41 { + typedef T1 Head; + typedef Types40 Tail; +}; + +template +struct Types42 { + typedef T1 Head; + typedef Types41 Tail; +}; + +template +struct Types43 { + typedef T1 Head; + typedef Types42 Tail; +}; + +template +struct Types44 { + typedef T1 Head; + typedef Types43 Tail; +}; + +template +struct Types45 { + typedef T1 Head; + typedef Types44 Tail; +}; + +template +struct Types46 { + typedef T1 Head; + typedef Types45 Tail; +}; + +template +struct Types47 { + typedef T1 Head; + typedef Types46 Tail; +}; + +template +struct Types48 { + typedef T1 Head; + typedef Types47 Tail; +}; + +template +struct Types49 { + typedef T1 Head; + typedef Types48 Tail; +}; + +template +struct Types50 { + typedef T1 Head; + typedef Types49 Tail; +}; + + +} // namespace internal + +// We don't want to require the users to write TypesN<...> directly, +// as that would require them to count the length. Types<...> is much +// easier to write, but generates horrible messages when there is a +// compiler error, as gcc insists on printing out each template +// argument, even if it has the default value (this means Types +// will appear as Types in the compiler +// errors). +// +// Our solution is to combine the best part of the two approaches: a +// user would write Types, and Google Test will translate +// that to TypesN internally to make error messages +// readable. The translation is done by the 'type' member of the +// Types template. +template +struct Types { + typedef internal::Types50 type; +}; + +template <> +struct Types { + typedef internal::Types0 type; +}; +template +struct Types { + typedef internal::Types1 type; +}; +template +struct Types { + typedef internal::Types2 type; +}; +template +struct Types { + typedef internal::Types3 type; +}; +template +struct Types { + typedef internal::Types4 type; +}; +template +struct Types { + typedef internal::Types5 type; +}; +template +struct Types { + typedef internal::Types6 type; +}; +template +struct Types { + typedef internal::Types7 type; +}; +template +struct Types { + typedef internal::Types8 type; +}; +template +struct Types { + typedef internal::Types9 type; +}; +template +struct Types { + typedef internal::Types10 type; +}; +template +struct Types { + typedef internal::Types11 type; +}; +template +struct Types { + typedef internal::Types12 type; +}; +template +struct Types { + typedef internal::Types13 type; +}; +template +struct Types { + typedef internal::Types14 type; +}; +template +struct Types { + typedef internal::Types15 type; +}; +template +struct Types { + typedef internal::Types16 type; +}; +template +struct Types { + typedef internal::Types17 type; +}; +template +struct Types { + typedef internal::Types18 type; +}; +template +struct Types { + typedef internal::Types19 type; +}; +template +struct Types { + typedef internal::Types20 type; +}; +template +struct Types { + typedef internal::Types21 type; +}; +template +struct Types { + typedef internal::Types22 type; +}; +template +struct Types { + typedef internal::Types23 type; +}; +template +struct Types { + typedef internal::Types24 type; +}; +template +struct Types { + typedef internal::Types25 type; +}; +template +struct Types { + typedef internal::Types26 type; +}; +template +struct Types { + typedef internal::Types27 type; +}; +template +struct Types { + typedef internal::Types28 type; +}; +template +struct Types { + typedef internal::Types29 type; +}; +template +struct Types { + typedef internal::Types30 type; +}; +template +struct Types { + typedef internal::Types31 type; +}; +template +struct Types { + typedef internal::Types32 type; +}; +template +struct Types { + typedef internal::Types33 type; +}; +template +struct Types { + typedef internal::Types34 type; +}; +template +struct Types { + typedef internal::Types35 type; +}; +template +struct Types { + typedef internal::Types36 type; +}; +template +struct Types { + typedef internal::Types37 type; +}; +template +struct Types { + typedef internal::Types38 type; +}; +template +struct Types { + typedef internal::Types39 type; +}; +template +struct Types { + typedef internal::Types40 type; +}; +template +struct Types { + typedef internal::Types41 type; +}; +template +struct Types { + typedef internal::Types42 type; +}; +template +struct Types { + typedef internal::Types43 type; +}; +template +struct Types { + typedef internal::Types44 type; +}; +template +struct Types { + typedef internal::Types45 type; +}; +template +struct Types { + typedef internal::Types46 type; +}; +template +struct Types { + typedef internal::Types47 type; +}; +template +struct Types { + typedef internal::Types48 type; +}; +template +struct Types { + typedef internal::Types49 type; +}; + +namespace internal { + +# define GTEST_TEMPLATE_ template class + +// The template "selector" struct TemplateSel is used to +// represent Tmpl, which must be a class template with one type +// parameter, as a type. TemplateSel::Bind::type is defined +// as the type Tmpl. This allows us to actually instantiate the +// template "selected" by TemplateSel. +// +// This trick is necessary for simulating typedef for class templates, +// which C++ doesn't support directly. +template +struct TemplateSel { + template + struct Bind { + typedef Tmpl type; + }; +}; + +# define GTEST_BIND_(TmplSel, T) \ + TmplSel::template Bind::type + +// A unique struct template used as the default value for the +// arguments of class template Templates. This allows us to simulate +// variadic templates (e.g. Templates, Templates, +// and etc), which C++ doesn't support directly. +template +struct NoneT {}; + +// The following family of struct and struct templates are used to +// represent template lists. In particular, TemplatesN represents a list of N templates (T1, T2, ..., and TN). Except +// for Templates0, every struct in the family has two member types: +// Head for the selector of the first template in the list, and Tail +// for the rest of the list. + +// The empty template list. +struct Templates0 {}; + +// Template lists of length 1, 2, 3, and so on. + +template +struct Templates1 { + typedef TemplateSel Head; + typedef Templates0 Tail; +}; +template +struct Templates2 { + typedef TemplateSel Head; + typedef Templates1 Tail; +}; + +template +struct Templates3 { + typedef TemplateSel Head; + typedef Templates2 Tail; +}; + +template +struct Templates4 { + typedef TemplateSel Head; + typedef Templates3 Tail; +}; + +template +struct Templates5 { + typedef TemplateSel Head; + typedef Templates4 Tail; +}; + +template +struct Templates6 { + typedef TemplateSel Head; + typedef Templates5 Tail; +}; + +template +struct Templates7 { + typedef TemplateSel Head; + typedef Templates6 Tail; +}; + +template +struct Templates8 { + typedef TemplateSel Head; + typedef Templates7 Tail; +}; + +template +struct Templates9 { + typedef TemplateSel Head; + typedef Templates8 Tail; +}; + +template +struct Templates10 { + typedef TemplateSel Head; + typedef Templates9 Tail; +}; + +template +struct Templates11 { + typedef TemplateSel Head; + typedef Templates10 Tail; +}; + +template +struct Templates12 { + typedef TemplateSel Head; + typedef Templates11 Tail; +}; + +template +struct Templates13 { + typedef TemplateSel Head; + typedef Templates12 Tail; +}; + +template +struct Templates14 { + typedef TemplateSel Head; + typedef Templates13 Tail; +}; + +template +struct Templates15 { + typedef TemplateSel Head; + typedef Templates14 Tail; +}; + +template +struct Templates16 { + typedef TemplateSel Head; + typedef Templates15 Tail; +}; + +template +struct Templates17 { + typedef TemplateSel Head; + typedef Templates16 Tail; +}; + +template +struct Templates18 { + typedef TemplateSel Head; + typedef Templates17 Tail; +}; + +template +struct Templates19 { + typedef TemplateSel Head; + typedef Templates18 Tail; +}; + +template +struct Templates20 { + typedef TemplateSel Head; + typedef Templates19 Tail; +}; + +template +struct Templates21 { + typedef TemplateSel Head; + typedef Templates20 Tail; +}; + +template +struct Templates22 { + typedef TemplateSel Head; + typedef Templates21 Tail; +}; + +template +struct Templates23 { + typedef TemplateSel Head; + typedef Templates22 Tail; +}; + +template +struct Templates24 { + typedef TemplateSel Head; + typedef Templates23 Tail; +}; + +template +struct Templates25 { + typedef TemplateSel Head; + typedef Templates24 Tail; +}; + +template +struct Templates26 { + typedef TemplateSel Head; + typedef Templates25 Tail; +}; + +template +struct Templates27 { + typedef TemplateSel Head; + typedef Templates26 Tail; +}; + +template +struct Templates28 { + typedef TemplateSel Head; + typedef Templates27 Tail; +}; + +template +struct Templates29 { + typedef TemplateSel Head; + typedef Templates28 Tail; +}; + +template +struct Templates30 { + typedef TemplateSel Head; + typedef Templates29 Tail; +}; + +template +struct Templates31 { + typedef TemplateSel Head; + typedef Templates30 Tail; +}; + +template +struct Templates32 { + typedef TemplateSel Head; + typedef Templates31 Tail; +}; + +template +struct Templates33 { + typedef TemplateSel Head; + typedef Templates32 Tail; +}; + +template +struct Templates34 { + typedef TemplateSel Head; + typedef Templates33 Tail; +}; + +template +struct Templates35 { + typedef TemplateSel Head; + typedef Templates34 Tail; +}; + +template +struct Templates36 { + typedef TemplateSel Head; + typedef Templates35 Tail; +}; + +template +struct Templates37 { + typedef TemplateSel Head; + typedef Templates36 Tail; +}; + +template +struct Templates38 { + typedef TemplateSel Head; + typedef Templates37 Tail; +}; + +template +struct Templates39 { + typedef TemplateSel Head; + typedef Templates38 Tail; +}; + +template +struct Templates40 { + typedef TemplateSel Head; + typedef Templates39 Tail; +}; + +template +struct Templates41 { + typedef TemplateSel Head; + typedef Templates40 Tail; +}; + +template +struct Templates42 { + typedef TemplateSel Head; + typedef Templates41 Tail; +}; + +template +struct Templates43 { + typedef TemplateSel Head; + typedef Templates42 Tail; +}; + +template +struct Templates44 { + typedef TemplateSel Head; + typedef Templates43 Tail; +}; + +template +struct Templates45 { + typedef TemplateSel Head; + typedef Templates44 Tail; +}; + +template +struct Templates46 { + typedef TemplateSel Head; + typedef Templates45 Tail; +}; + +template +struct Templates47 { + typedef TemplateSel Head; + typedef Templates46 Tail; +}; + +template +struct Templates48 { + typedef TemplateSel Head; + typedef Templates47 Tail; +}; + +template +struct Templates49 { + typedef TemplateSel Head; + typedef Templates48 Tail; +}; + +template +struct Templates50 { + typedef TemplateSel Head; + typedef Templates49 Tail; +}; + + +// We don't want to require the users to write TemplatesN<...> directly, +// as that would require them to count the length. Templates<...> is much +// easier to write, but generates horrible messages when there is a +// compiler error, as gcc insists on printing out each template +// argument, even if it has the default value (this means Templates +// will appear as Templates in the compiler +// errors). +// +// Our solution is to combine the best part of the two approaches: a +// user would write Templates, and Google Test will translate +// that to TemplatesN internally to make error messages +// readable. The translation is done by the 'type' member of the +// Templates template. +template +struct Templates { + typedef Templates50 type; +}; + +template <> +struct Templates { + typedef Templates0 type; +}; +template +struct Templates { + typedef Templates1 type; +}; +template +struct Templates { + typedef Templates2 type; +}; +template +struct Templates { + typedef Templates3 type; +}; +template +struct Templates { + typedef Templates4 type; +}; +template +struct Templates { + typedef Templates5 type; +}; +template +struct Templates { + typedef Templates6 type; +}; +template +struct Templates { + typedef Templates7 type; +}; +template +struct Templates { + typedef Templates8 type; +}; +template +struct Templates { + typedef Templates9 type; +}; +template +struct Templates { + typedef Templates10 type; +}; +template +struct Templates { + typedef Templates11 type; +}; +template +struct Templates { + typedef Templates12 type; +}; +template +struct Templates { + typedef Templates13 type; +}; +template +struct Templates { + typedef Templates14 type; +}; +template +struct Templates { + typedef Templates15 type; +}; +template +struct Templates { + typedef Templates16 type; +}; +template +struct Templates { + typedef Templates17 type; +}; +template +struct Templates { + typedef Templates18 type; +}; +template +struct Templates { + typedef Templates19 type; +}; +template +struct Templates { + typedef Templates20 type; +}; +template +struct Templates { + typedef Templates21 type; +}; +template +struct Templates { + typedef Templates22 type; +}; +template +struct Templates { + typedef Templates23 type; +}; +template +struct Templates { + typedef Templates24 type; +}; +template +struct Templates { + typedef Templates25 type; +}; +template +struct Templates { + typedef Templates26 type; +}; +template +struct Templates { + typedef Templates27 type; +}; +template +struct Templates { + typedef Templates28 type; +}; +template +struct Templates { + typedef Templates29 type; +}; +template +struct Templates { + typedef Templates30 type; +}; +template +struct Templates { + typedef Templates31 type; +}; +template +struct Templates { + typedef Templates32 type; +}; +template +struct Templates { + typedef Templates33 type; +}; +template +struct Templates { + typedef Templates34 type; +}; +template +struct Templates { + typedef Templates35 type; +}; +template +struct Templates { + typedef Templates36 type; +}; +template +struct Templates { + typedef Templates37 type; +}; +template +struct Templates { + typedef Templates38 type; +}; +template +struct Templates { + typedef Templates39 type; +}; +template +struct Templates { + typedef Templates40 type; +}; +template +struct Templates { + typedef Templates41 type; +}; +template +struct Templates { + typedef Templates42 type; +}; +template +struct Templates { + typedef Templates43 type; +}; +template +struct Templates { + typedef Templates44 type; +}; +template +struct Templates { + typedef Templates45 type; +}; +template +struct Templates { + typedef Templates46 type; +}; +template +struct Templates { + typedef Templates47 type; +}; +template +struct Templates { + typedef Templates48 type; +}; +template +struct Templates { + typedef Templates49 type; +}; + +// The TypeList template makes it possible to use either a single type +// or a Types<...> list in TYPED_TEST_CASE() and +// INSTANTIATE_TYPED_TEST_CASE_P(). + +template +struct TypeList { + typedef Types1 type; +}; + +template +struct TypeList > { + typedef typename Types::type type; +}; + +#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ diff --git a/test/fmw/gtest/include/gtest/internal/gtest-type-util.h.pump b/test/fmw/gtest/include/gtest/internal/gtest-type-util.h.pump new file mode 100644 index 00000000000..251fdf025b2 --- /dev/null +++ b/test/fmw/gtest/include/gtest/internal/gtest-type-util.h.pump @@ -0,0 +1,297 @@ +$$ -*- mode: c++; -*- +$var n = 50 $$ Maximum length of type lists we want to support. +// Copyright 2008 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) + +// Type utilities needed for implementing typed and type-parameterized +// tests. This file is generated by a SCRIPT. DO NOT EDIT BY HAND! +// +// Currently we support at most $n types in a list, and at most $n +// type-parameterized tests in one type-parameterized test case. +// Please contact googletestframework@googlegroups.com if you need +// more. + +#ifndef GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ +#define GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ + +#include "gtest/internal/gtest-port.h" + +// #ifdef __GNUC__ is too general here. It is possible to use gcc without using +// libstdc++ (which is where cxxabi.h comes from). +# if GTEST_HAS_CXXABI_H_ +# include +# elif defined(__HP_aCC) +# include +# endif // GTEST_HASH_CXXABI_H_ + +namespace testing { +namespace internal { + +// GetTypeName() returns a human-readable name of type T. +// NB: This function is also used in Google Mock, so don't move it inside of +// the typed-test-only section below. +template +std::string GetTypeName() { +# if GTEST_HAS_RTTI + + const char* const name = typeid(T).name(); +# if GTEST_HAS_CXXABI_H_ || defined(__HP_aCC) + int status = 0; + // gcc's implementation of typeid(T).name() mangles the type name, + // so we have to demangle it. +# if GTEST_HAS_CXXABI_H_ + using abi::__cxa_demangle; +# endif // GTEST_HAS_CXXABI_H_ + char* const readable_name = __cxa_demangle(name, 0, 0, &status); + const std::string name_str(status == 0 ? readable_name : name); + free(readable_name); + return name_str; +# else + return name; +# endif // GTEST_HAS_CXXABI_H_ || __HP_aCC + +# else + + return ""; + +# endif // GTEST_HAS_RTTI +} + +#if GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +// AssertyTypeEq::type is defined iff T1 and T2 are the same +// type. This can be used as a compile-time assertion to ensure that +// two types are equal. + +template +struct AssertTypeEq; + +template +struct AssertTypeEq { + typedef bool type; +}; + +// A unique type used as the default value for the arguments of class +// template Types. This allows us to simulate variadic templates +// (e.g. Types, Type, and etc), which C++ doesn't +// support directly. +struct None {}; + +// The following family of struct and struct templates are used to +// represent type lists. In particular, TypesN +// represents a type list with N types (T1, T2, ..., and TN) in it. +// Except for Types0, every struct in the family has two member types: +// Head for the first type in the list, and Tail for the rest of the +// list. + +// The empty type list. +struct Types0 {}; + +// Type lists of length 1, 2, 3, and so on. + +template +struct Types1 { + typedef T1 Head; + typedef Types0 Tail; +}; + +$range i 2..n + +$for i [[ +$range j 1..i +$range k 2..i +template <$for j, [[typename T$j]]> +struct Types$i { + typedef T1 Head; + typedef Types$(i-1)<$for k, [[T$k]]> Tail; +}; + + +]] + +} // namespace internal + +// We don't want to require the users to write TypesN<...> directly, +// as that would require them to count the length. Types<...> is much +// easier to write, but generates horrible messages when there is a +// compiler error, as gcc insists on printing out each template +// argument, even if it has the default value (this means Types +// will appear as Types in the compiler +// errors). +// +// Our solution is to combine the best part of the two approaches: a +// user would write Types, and Google Test will translate +// that to TypesN internally to make error messages +// readable. The translation is done by the 'type' member of the +// Types template. + +$range i 1..n +template <$for i, [[typename T$i = internal::None]]> +struct Types { + typedef internal::Types$n<$for i, [[T$i]]> type; +}; + +template <> +struct Types<$for i, [[internal::None]]> { + typedef internal::Types0 type; +}; + +$range i 1..n-1 +$for i [[ +$range j 1..i +$range k i+1..n +template <$for j, [[typename T$j]]> +struct Types<$for j, [[T$j]]$for k[[, internal::None]]> { + typedef internal::Types$i<$for j, [[T$j]]> type; +}; + +]] + +namespace internal { + +# define GTEST_TEMPLATE_ template class + +// The template "selector" struct TemplateSel is used to +// represent Tmpl, which must be a class template with one type +// parameter, as a type. TemplateSel::Bind::type is defined +// as the type Tmpl. This allows us to actually instantiate the +// template "selected" by TemplateSel. +// +// This trick is necessary for simulating typedef for class templates, +// which C++ doesn't support directly. +template +struct TemplateSel { + template + struct Bind { + typedef Tmpl type; + }; +}; + +# define GTEST_BIND_(TmplSel, T) \ + TmplSel::template Bind::type + +// A unique struct template used as the default value for the +// arguments of class template Templates. This allows us to simulate +// variadic templates (e.g. Templates, Templates, +// and etc), which C++ doesn't support directly. +template +struct NoneT {}; + +// The following family of struct and struct templates are used to +// represent template lists. In particular, TemplatesN represents a list of N templates (T1, T2, ..., and TN). Except +// for Templates0, every struct in the family has two member types: +// Head for the selector of the first template in the list, and Tail +// for the rest of the list. + +// The empty template list. +struct Templates0 {}; + +// Template lists of length 1, 2, 3, and so on. + +template +struct Templates1 { + typedef TemplateSel Head; + typedef Templates0 Tail; +}; + +$range i 2..n + +$for i [[ +$range j 1..i +$range k 2..i +template <$for j, [[GTEST_TEMPLATE_ T$j]]> +struct Templates$i { + typedef TemplateSel Head; + typedef Templates$(i-1)<$for k, [[T$k]]> Tail; +}; + + +]] + +// We don't want to require the users to write TemplatesN<...> directly, +// as that would require them to count the length. Templates<...> is much +// easier to write, but generates horrible messages when there is a +// compiler error, as gcc insists on printing out each template +// argument, even if it has the default value (this means Templates +// will appear as Templates in the compiler +// errors). +// +// Our solution is to combine the best part of the two approaches: a +// user would write Templates, and Google Test will translate +// that to TemplatesN internally to make error messages +// readable. The translation is done by the 'type' member of the +// Templates template. + +$range i 1..n +template <$for i, [[GTEST_TEMPLATE_ T$i = NoneT]]> +struct Templates { + typedef Templates$n<$for i, [[T$i]]> type; +}; + +template <> +struct Templates<$for i, [[NoneT]]> { + typedef Templates0 type; +}; + +$range i 1..n-1 +$for i [[ +$range j 1..i +$range k i+1..n +template <$for j, [[GTEST_TEMPLATE_ T$j]]> +struct Templates<$for j, [[T$j]]$for k[[, NoneT]]> { + typedef Templates$i<$for j, [[T$j]]> type; +}; + +]] + +// The TypeList template makes it possible to use either a single type +// or a Types<...> list in TYPED_TEST_CASE() and +// INSTANTIATE_TYPED_TEST_CASE_P(). + +template +struct TypeList { + typedef Types1 type; +}; + + +$range i 1..n +template <$for i, [[typename T$i]]> +struct TypeList > { + typedef typename Types<$for i, [[T$i]]>::type type; +}; + +#endif // GTEST_HAS_TYPED_TEST || GTEST_HAS_TYPED_TEST_P + +} // namespace internal +} // namespace testing + +#endif // GTEST_INCLUDE_GTEST_INTERNAL_GTEST_TYPE_UTIL_H_ diff --git a/test/fmw/gtest/src/gtest-all.cc b/test/fmw/gtest/src/gtest-all.cc new file mode 100644 index 00000000000..0a9cee52233 --- /dev/null +++ b/test/fmw/gtest/src/gtest-all.cc @@ -0,0 +1,48 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: mheule@google.com (Markus Heule) +// +// Google C++ Testing Framework (Google Test) +// +// Sometimes it's desirable to build Google Test by compiling a single file. +// This file serves this purpose. + +// This line ensures that gtest.h can be compiled on its own, even +// when it's fused. +#include "gtest/gtest.h" + +// The following lines pull in the real gtest *.cc files. +#include "src/gtest.cc" +#include "src/gtest-death-test.cc" +#include "src/gtest-filepath.cc" +#include "src/gtest-port.cc" +#include "src/gtest-printers.cc" +#include "src/gtest-test-part.cc" +#include "src/gtest-typed-test.cc" diff --git a/test/fmw/gtest/src/gtest-death-test.cc b/test/fmw/gtest/src/gtest-death-test.cc new file mode 100644 index 00000000000..a6023fce4fa --- /dev/null +++ b/test/fmw/gtest/src/gtest-death-test.cc @@ -0,0 +1,1344 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan), vladl@google.com (Vlad Losev) +// +// This file implements death tests. + +#include "gtest/gtest-death-test.h" +#include "gtest/internal/gtest-port.h" + +#if GTEST_HAS_DEATH_TEST + +# if GTEST_OS_MAC +# include +# endif // GTEST_OS_MAC + +# include +# include +# include + +# if GTEST_OS_LINUX +# include +# endif // GTEST_OS_LINUX + +# include + +# if GTEST_OS_WINDOWS +# include +# else +# include +# include +# endif // GTEST_OS_WINDOWS + +# if GTEST_OS_QNX +# include +# endif // GTEST_OS_QNX + +#endif // GTEST_HAS_DEATH_TEST + +#include "gtest/gtest-message.h" +#include "gtest/internal/gtest-string.h" + +// Indicates that this translation unit is part of Google Test's +// implementation. It must come before gtest-internal-inl.h is +// included, or there will be a compiler error. This trick is to +// prevent a user from accidentally including gtest-internal-inl.h in +// his code. +#define GTEST_IMPLEMENTATION_ 1 +#include "src/gtest-internal-inl.h" +#undef GTEST_IMPLEMENTATION_ + +namespace testing { + +// Constants. + +// The default death test style. +static const char kDefaultDeathTestStyle[] = "fast"; + +GTEST_DEFINE_string_( + death_test_style, + internal::StringFromGTestEnv("death_test_style", kDefaultDeathTestStyle), + "Indicates how to run a death test in a forked child process: " + "\"threadsafe\" (child process re-executes the test binary " + "from the beginning, running only the specific death test) or " + "\"fast\" (child process runs the death test immediately " + "after forking)."); + +GTEST_DEFINE_bool_( + death_test_use_fork, + internal::BoolFromGTestEnv("death_test_use_fork", false), + "Instructs to use fork()/_exit() instead of clone() in death tests. " + "Ignored and always uses fork() on POSIX systems where clone() is not " + "implemented. Useful when running under valgrind or similar tools if " + "those do not support clone(). Valgrind 3.3.1 will just fail if " + "it sees an unsupported combination of clone() flags. " + "It is not recommended to use this flag w/o valgrind though it will " + "work in 99% of the cases. Once valgrind is fixed, this flag will " + "most likely be removed."); + +namespace internal { +GTEST_DEFINE_string_( + internal_run_death_test, "", + "Indicates the file, line number, temporal index of " + "the single death test to run, and a file descriptor to " + "which a success code may be sent, all separated by " + "the '|' characters. This flag is specified if and only if the current " + "process is a sub-process launched for running a thread-safe " + "death test. FOR INTERNAL USE ONLY."); +} // namespace internal + +#if GTEST_HAS_DEATH_TEST + +namespace internal { + +// Valid only for fast death tests. Indicates the code is running in the +// child process of a fast style death test. +static bool g_in_fast_death_test_child = false; + +// Returns a Boolean value indicating whether the caller is currently +// executing in the context of the death test child process. Tools such as +// Valgrind heap checkers may need this to modify their behavior in death +// tests. IMPORTANT: This is an internal utility. Using it may break the +// implementation of death tests. User code MUST NOT use it. +bool InDeathTestChild() { +# if GTEST_OS_WINDOWS + + // On Windows, death tests are thread-safe regardless of the value of the + // death_test_style flag. + return !GTEST_FLAG(internal_run_death_test).empty(); + +# else + + if (GTEST_FLAG(death_test_style) == "threadsafe") + return !GTEST_FLAG(internal_run_death_test).empty(); + else + return g_in_fast_death_test_child; +#endif +} + +} // namespace internal + +// ExitedWithCode constructor. +ExitedWithCode::ExitedWithCode(int exit_code) : exit_code_(exit_code) { +} + +// ExitedWithCode function-call operator. +bool ExitedWithCode::operator()(int exit_status) const { +# if GTEST_OS_WINDOWS + + return exit_status == exit_code_; + +# else + + return WIFEXITED(exit_status) && WEXITSTATUS(exit_status) == exit_code_; + +# endif // GTEST_OS_WINDOWS +} + +# if !GTEST_OS_WINDOWS +// KilledBySignal constructor. +KilledBySignal::KilledBySignal(int signum) : signum_(signum) { +} + +// KilledBySignal function-call operator. +bool KilledBySignal::operator()(int exit_status) const { + return WIFSIGNALED(exit_status) && WTERMSIG(exit_status) == signum_; +} +# endif // !GTEST_OS_WINDOWS + +namespace internal { + +// Utilities needed for death tests. + +// Generates a textual description of a given exit code, in the format +// specified by wait(2). +static std::string ExitSummary(int exit_code) { + Message m; + +# if GTEST_OS_WINDOWS + + m << "Exited with exit status " << exit_code; + +# else + + if (WIFEXITED(exit_code)) { + m << "Exited with exit status " << WEXITSTATUS(exit_code); + } else if (WIFSIGNALED(exit_code)) { + m << "Terminated by signal " << WTERMSIG(exit_code); + } +# ifdef WCOREDUMP + if (WCOREDUMP(exit_code)) { + m << " (core dumped)"; + } +# endif +# endif // GTEST_OS_WINDOWS + + return m.GetString(); +} + +// Returns true if exit_status describes a process that was terminated +// by a signal, or exited normally with a nonzero exit code. +bool ExitedUnsuccessfully(int exit_status) { + return !ExitedWithCode(0)(exit_status); +} + +# if !GTEST_OS_WINDOWS +// Generates a textual failure message when a death test finds more than +// one thread running, or cannot determine the number of threads, prior +// to executing the given statement. It is the responsibility of the +// caller not to pass a thread_count of 1. +static std::string DeathTestThreadWarning(size_t thread_count) { + Message msg; + msg << "Death tests use fork(), which is unsafe particularly" + << " in a threaded context. For this test, " << GTEST_NAME_ << " "; + if (thread_count == 0) + msg << "couldn't detect the number of threads."; + else + msg << "detected " << thread_count << " threads."; + return msg.GetString(); +} +# endif // !GTEST_OS_WINDOWS + +// Flag characters for reporting a death test that did not die. +static const char kDeathTestLived = 'L'; +static const char kDeathTestReturned = 'R'; +static const char kDeathTestThrew = 'T'; +static const char kDeathTestInternalError = 'I'; + +// An enumeration describing all of the possible ways that a death test can +// conclude. DIED means that the process died while executing the test +// code; LIVED means that process lived beyond the end of the test code; +// RETURNED means that the test statement attempted to execute a return +// statement, which is not allowed; THREW means that the test statement +// returned control by throwing an exception. IN_PROGRESS means the test +// has not yet concluded. +// TODO(vladl@google.com): Unify names and possibly values for +// AbortReason, DeathTestOutcome, and flag characters above. +enum DeathTestOutcome { IN_PROGRESS, DIED, LIVED, RETURNED, THREW }; + +// Routine for aborting the program which is safe to call from an +// exec-style death test child process, in which case the error +// message is propagated back to the parent process. Otherwise, the +// message is simply printed to stderr. In either case, the program +// then exits with status 1. +void DeathTestAbort(const std::string& message) { + // On a POSIX system, this function may be called from a threadsafe-style + // death test child process, which operates on a very small stack. Use + // the heap for any additional non-minuscule memory requirements. + const InternalRunDeathTestFlag* const flag = + GetUnitTestImpl()->internal_run_death_test_flag(); + if (flag != NULL) { + FILE* parent = posix::FDOpen(flag->write_fd(), "w"); + fputc(kDeathTestInternalError, parent); + fprintf(parent, "%s", message.c_str()); + fflush(parent); + _exit(1); + } else { + fprintf(stderr, "%s", message.c_str()); + fflush(stderr); + posix::Abort(); + } +} + +// A replacement for CHECK that calls DeathTestAbort if the assertion +// fails. +# define GTEST_DEATH_TEST_CHECK_(expression) \ + do { \ + if (!::testing::internal::IsTrue(expression)) { \ + DeathTestAbort( \ + ::std::string("CHECK failed: File ") + __FILE__ + ", line " \ + + ::testing::internal::StreamableToString(__LINE__) + ": " \ + + #expression); \ + } \ + } while (::testing::internal::AlwaysFalse()) + +// This macro is similar to GTEST_DEATH_TEST_CHECK_, but it is meant for +// evaluating any system call that fulfills two conditions: it must return +// -1 on failure, and set errno to EINTR when it is interrupted and +// should be tried again. The macro expands to a loop that repeatedly +// evaluates the expression as long as it evaluates to -1 and sets +// errno to EINTR. If the expression evaluates to -1 but errno is +// something other than EINTR, DeathTestAbort is called. +# define GTEST_DEATH_TEST_CHECK_SYSCALL_(expression) \ + do { \ + int gtest_retval; \ + do { \ + gtest_retval = (expression); \ + } while (gtest_retval == -1 && errno == EINTR); \ + if (gtest_retval == -1) { \ + DeathTestAbort( \ + ::std::string("CHECK failed: File ") + __FILE__ + ", line " \ + + ::testing::internal::StreamableToString(__LINE__) + ": " \ + + #expression + " != -1"); \ + } \ + } while (::testing::internal::AlwaysFalse()) + +// Returns the message describing the last system error in errno. +std::string GetLastErrnoDescription() { + return errno == 0 ? "" : posix::StrError(errno); +} + +// This is called from a death test parent process to read a failure +// message from the death test child process and log it with the FATAL +// severity. On Windows, the message is read from a pipe handle. On other +// platforms, it is read from a file descriptor. +static void FailFromInternalError(int fd) { + Message error; + char buffer[256]; + int num_read; + + do { + while ((num_read = posix::Read(fd, buffer, 255)) > 0) { + buffer[num_read] = '\0'; + error << buffer; + } + } while (num_read == -1 && errno == EINTR); + + if (num_read == 0) { + GTEST_LOG_(FATAL) << error.GetString(); + } else { + const int last_error = errno; + GTEST_LOG_(FATAL) << "Error while reading death test internal: " + << GetLastErrnoDescription() << " [" << last_error << "]"; + } +} + +// Death test constructor. Increments the running death test count +// for the current test. +DeathTest::DeathTest() { + TestInfo* const info = GetUnitTestImpl()->current_test_info(); + if (info == NULL) { + DeathTestAbort("Cannot run a death test outside of a TEST or " + "TEST_F construct"); + } +} + +// Creates and returns a death test by dispatching to the current +// death test factory. +bool DeathTest::Create(const char* statement, const RE* regex, + const char* file, int line, DeathTest** test) { + return GetUnitTestImpl()->death_test_factory()->Create( + statement, regex, file, line, test); +} + +const char* DeathTest::LastMessage() { + return last_death_test_message_.c_str(); +} + +void DeathTest::set_last_death_test_message(const std::string& message) { + last_death_test_message_ = message; +} + +std::string DeathTest::last_death_test_message_; + +// Provides cross platform implementation for some death functionality. +class DeathTestImpl : public DeathTest { + protected: + DeathTestImpl(const char* a_statement, const RE* a_regex) + : statement_(a_statement), + regex_(a_regex), + spawned_(false), + status_(-1), + outcome_(IN_PROGRESS), + read_fd_(-1), + write_fd_(-1) {} + + // read_fd_ is expected to be closed and cleared by a derived class. + ~DeathTestImpl() { GTEST_DEATH_TEST_CHECK_(read_fd_ == -1); } + + void Abort(AbortReason reason); + virtual bool Passed(bool status_ok); + + const char* statement() const { return statement_; } + const RE* regex() const { return regex_; } + bool spawned() const { return spawned_; } + void set_spawned(bool is_spawned) { spawned_ = is_spawned; } + int status() const { return status_; } + void set_status(int a_status) { status_ = a_status; } + DeathTestOutcome outcome() const { return outcome_; } + void set_outcome(DeathTestOutcome an_outcome) { outcome_ = an_outcome; } + int read_fd() const { return read_fd_; } + void set_read_fd(int fd) { read_fd_ = fd; } + int write_fd() const { return write_fd_; } + void set_write_fd(int fd) { write_fd_ = fd; } + + // Called in the parent process only. Reads the result code of the death + // test child process via a pipe, interprets it to set the outcome_ + // member, and closes read_fd_. Outputs diagnostics and terminates in + // case of unexpected codes. + void ReadAndInterpretStatusByte(); + + private: + // The textual content of the code this object is testing. This class + // doesn't own this string and should not attempt to delete it. + const char* const statement_; + // The regular expression which test output must match. DeathTestImpl + // doesn't own this object and should not attempt to delete it. + const RE* const regex_; + // True if the death test child process has been successfully spawned. + bool spawned_; + // The exit status of the child process. + int status_; + // How the death test concluded. + DeathTestOutcome outcome_; + // Descriptor to the read end of the pipe to the child process. It is + // always -1 in the child process. The child keeps its write end of the + // pipe in write_fd_. + int read_fd_; + // Descriptor to the child's write end of the pipe to the parent process. + // It is always -1 in the parent process. The parent keeps its end of the + // pipe in read_fd_. + int write_fd_; +}; + +// Called in the parent process only. Reads the result code of the death +// test child process via a pipe, interprets it to set the outcome_ +// member, and closes read_fd_. Outputs diagnostics and terminates in +// case of unexpected codes. +void DeathTestImpl::ReadAndInterpretStatusByte() { + char flag; + int bytes_read; + + // The read() here blocks until data is available (signifying the + // failure of the death test) or until the pipe is closed (signifying + // its success), so it's okay to call this in the parent before + // the child process has exited. + do { + bytes_read = posix::Read(read_fd(), &flag, 1); + } while (bytes_read == -1 && errno == EINTR); + + if (bytes_read == 0) { + set_outcome(DIED); + } else if (bytes_read == 1) { + switch (flag) { + case kDeathTestReturned: + set_outcome(RETURNED); + break; + case kDeathTestThrew: + set_outcome(THREW); + break; + case kDeathTestLived: + set_outcome(LIVED); + break; + case kDeathTestInternalError: + FailFromInternalError(read_fd()); // Does not return. + break; + default: + GTEST_LOG_(FATAL) << "Death test child process reported " + << "unexpected status byte (" + << static_cast(flag) << ")"; + } + } else { + GTEST_LOG_(FATAL) << "Read from death test child process failed: " + << GetLastErrnoDescription(); + } + GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Close(read_fd())); + set_read_fd(-1); +} + +// Signals that the death test code which should have exited, didn't. +// Should be called only in a death test child process. +// Writes a status byte to the child's status file descriptor, then +// calls _exit(1). +void DeathTestImpl::Abort(AbortReason reason) { + // The parent process considers the death test to be a failure if + // it finds any data in our pipe. So, here we write a single flag byte + // to the pipe, then exit. + const char status_ch = + reason == TEST_DID_NOT_DIE ? kDeathTestLived : + reason == TEST_THREW_EXCEPTION ? kDeathTestThrew : kDeathTestReturned; + + GTEST_DEATH_TEST_CHECK_SYSCALL_(posix::Write(write_fd(), &status_ch, 1)); + // We are leaking the descriptor here because on some platforms (i.e., + // when built as Windows DLL), destructors of global objects will still + // run after calling _exit(). On such systems, write_fd_ will be + // indirectly closed from the destructor of UnitTestImpl, causing double + // close if it is also closed here. On debug configurations, double close + // may assert. As there are no in-process buffers to flush here, we are + // relying on the OS to close the descriptor after the process terminates + // when the destructors are not run. + _exit(1); // Exits w/o any normal exit hooks (we were supposed to crash) +} + +// Returns an indented copy of stderr output for a death test. +// This makes distinguishing death test output lines from regular log lines +// much easier. +static ::std::string FormatDeathTestOutput(const ::std::string& output) { + ::std::string ret; + for (size_t at = 0; ; ) { + const size_t line_end = output.find('\n', at); + ret += "[ DEATH ] "; + if (line_end == ::std::string::npos) { + ret += output.substr(at); + break; + } + ret += output.substr(at, line_end + 1 - at); + at = line_end + 1; + } + return ret; +} + +// Assesses the success or failure of a death test, using both private +// members which have previously been set, and one argument: +// +// Private data members: +// outcome: An enumeration describing how the death test +// concluded: DIED, LIVED, THREW, or RETURNED. The death test +// fails in the latter three cases. +// status: The exit status of the child process. On *nix, it is in the +// in the format specified by wait(2). On Windows, this is the +// value supplied to the ExitProcess() API or a numeric code +// of the exception that terminated the program. +// regex: A regular expression object to be applied to +// the test's captured standard error output; the death test +// fails if it does not match. +// +// Argument: +// status_ok: true if exit_status is acceptable in the context of +// this particular death test, which fails if it is false +// +// Returns true iff all of the above conditions are met. Otherwise, the +// first failing condition, in the order given above, is the one that is +// reported. Also sets the last death test message string. +bool DeathTestImpl::Passed(bool status_ok) { + if (!spawned()) + return false; + + const std::string error_message = GetCapturedStderr(); + + bool success = false; + Message buffer; + + buffer << "Death test: " << statement() << "\n"; + switch (outcome()) { + case LIVED: + buffer << " Result: failed to die.\n" + << " Error msg:\n" << FormatDeathTestOutput(error_message); + break; + case THREW: + buffer << " Result: threw an exception.\n" + << " Error msg:\n" << FormatDeathTestOutput(error_message); + break; + case RETURNED: + buffer << " Result: illegal return in test statement.\n" + << " Error msg:\n" << FormatDeathTestOutput(error_message); + break; + case DIED: + if (status_ok) { + const bool matched = RE::PartialMatch(error_message.c_str(), *regex()); + if (matched) { + success = true; + } else { + buffer << " Result: died but not with expected error.\n" + << " Expected: " << regex()->pattern() << "\n" + << "Actual msg:\n" << FormatDeathTestOutput(error_message); + } + } else { + buffer << " Result: died but not with expected exit code:\n" + << " " << ExitSummary(status()) << "\n" + << "Actual msg:\n" << FormatDeathTestOutput(error_message); + } + break; + case IN_PROGRESS: + default: + GTEST_LOG_(FATAL) + << "DeathTest::Passed somehow called before conclusion of test"; + } + + DeathTest::set_last_death_test_message(buffer.GetString()); + return success; +} + +# if GTEST_OS_WINDOWS +// WindowsDeathTest implements death tests on Windows. Due to the +// specifics of starting new processes on Windows, death tests there are +// always threadsafe, and Google Test considers the +// --gtest_death_test_style=fast setting to be equivalent to +// --gtest_death_test_style=threadsafe there. +// +// A few implementation notes: Like the Linux version, the Windows +// implementation uses pipes for child-to-parent communication. But due to +// the specifics of pipes on Windows, some extra steps are required: +// +// 1. The parent creates a communication pipe and stores handles to both +// ends of it. +// 2. The parent starts the child and provides it with the information +// necessary to acquire the handle to the write end of the pipe. +// 3. The child acquires the write end of the pipe and signals the parent +// using a Windows event. +// 4. Now the parent can release the write end of the pipe on its side. If +// this is done before step 3, the object's reference count goes down to +// 0 and it is destroyed, preventing the child from acquiring it. The +// parent now has to release it, or read operations on the read end of +// the pipe will not return when the child terminates. +// 5. The parent reads child's output through the pipe (outcome code and +// any possible error messages) from the pipe, and its stderr and then +// determines whether to fail the test. +// +// Note: to distinguish Win32 API calls from the local method and function +// calls, the former are explicitly resolved in the global namespace. +// +class WindowsDeathTest : public DeathTestImpl { + public: + WindowsDeathTest(const char* a_statement, + const RE* a_regex, + const char* file, + int line) + : DeathTestImpl(a_statement, a_regex), file_(file), line_(line) {} + + // All of these virtual functions are inherited from DeathTest. + virtual int Wait(); + virtual TestRole AssumeRole(); + + private: + // The name of the file in which the death test is located. + const char* const file_; + // The line number on which the death test is located. + const int line_; + // Handle to the write end of the pipe to the child process. + AutoHandle write_handle_; + // Child process handle. + AutoHandle child_handle_; + // Event the child process uses to signal the parent that it has + // acquired the handle to the write end of the pipe. After seeing this + // event the parent can release its own handles to make sure its + // ReadFile() calls return when the child terminates. + AutoHandle event_handle_; +}; + +// Waits for the child in a death test to exit, returning its exit +// status, or 0 if no child process exists. As a side effect, sets the +// outcome data member. +int WindowsDeathTest::Wait() { + if (!spawned()) + return 0; + + // Wait until the child either signals that it has acquired the write end + // of the pipe or it dies. + const HANDLE wait_handles[2] = { child_handle_.Get(), event_handle_.Get() }; + switch (::WaitForMultipleObjects(2, + wait_handles, + FALSE, // Waits for any of the handles. + INFINITE)) { + case WAIT_OBJECT_0: + case WAIT_OBJECT_0 + 1: + break; + default: + GTEST_DEATH_TEST_CHECK_(false); // Should not get here. + } + + // The child has acquired the write end of the pipe or exited. + // We release the handle on our side and continue. + write_handle_.Reset(); + event_handle_.Reset(); + + ReadAndInterpretStatusByte(); + + // Waits for the child process to exit if it haven't already. This + // returns immediately if the child has already exited, regardless of + // whether previous calls to WaitForMultipleObjects synchronized on this + // handle or not. + GTEST_DEATH_TEST_CHECK_( + WAIT_OBJECT_0 == ::WaitForSingleObject(child_handle_.Get(), + INFINITE)); + DWORD status_code; + GTEST_DEATH_TEST_CHECK_( + ::GetExitCodeProcess(child_handle_.Get(), &status_code) != FALSE); + child_handle_.Reset(); + set_status(static_cast(status_code)); + return status(); +} + +// The AssumeRole process for a Windows death test. It creates a child +// process with the same executable as the current process to run the +// death test. The child process is given the --gtest_filter and +// --gtest_internal_run_death_test flags such that it knows to run the +// current death test only. +DeathTest::TestRole WindowsDeathTest::AssumeRole() { + const UnitTestImpl* const impl = GetUnitTestImpl(); + const InternalRunDeathTestFlag* const flag = + impl->internal_run_death_test_flag(); + const TestInfo* const info = impl->current_test_info(); + const int death_test_index = info->result()->death_test_count(); + + if (flag != NULL) { + // ParseInternalRunDeathTestFlag() has performed all the necessary + // processing. + set_write_fd(flag->write_fd()); + return EXECUTE_TEST; + } + + // WindowsDeathTest uses an anonymous pipe to communicate results of + // a death test. + SECURITY_ATTRIBUTES handles_are_inheritable = { + sizeof(SECURITY_ATTRIBUTES), NULL, TRUE }; + HANDLE read_handle, write_handle; + GTEST_DEATH_TEST_CHECK_( + ::CreatePipe(&read_handle, &write_handle, &handles_are_inheritable, + 0) // Default buffer size. + != FALSE); + set_read_fd(::_open_osfhandle(reinterpret_cast(read_handle), + O_RDONLY)); + write_handle_.Reset(write_handle); + event_handle_.Reset(::CreateEvent( + &handles_are_inheritable, + TRUE, // The event will automatically reset to non-signaled state. + FALSE, // The initial state is non-signalled. + NULL)); // The even is unnamed. + GTEST_DEATH_TEST_CHECK_(event_handle_.Get() != NULL); + const std::string filter_flag = + std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + + info->test_case_name() + "." + info->name(); + const std::string internal_flag = + std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + + "=" + file_ + "|" + StreamableToString(line_) + "|" + + StreamableToString(death_test_index) + "|" + + StreamableToString(static_cast(::GetCurrentProcessId())) + + // size_t has the same width as pointers on both 32-bit and 64-bit + // Windows platforms. + // See http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx. + "|" + StreamableToString(reinterpret_cast(write_handle)) + + "|" + StreamableToString(reinterpret_cast(event_handle_.Get())); + + char executable_path[_MAX_PATH + 1]; // NOLINT + GTEST_DEATH_TEST_CHECK_( + _MAX_PATH + 1 != ::GetModuleFileNameA(NULL, + executable_path, + _MAX_PATH)); + + std::string command_line = + std::string(::GetCommandLineA()) + " " + filter_flag + " \"" + + internal_flag + "\""; + + DeathTest::set_last_death_test_message(""); + + CaptureStderr(); + // Flush the log buffers since the log streams are shared with the child. + FlushInfoLog(); + + // The child process will share the standard handles with the parent. + STARTUPINFOA startup_info; + memset(&startup_info, 0, sizeof(STARTUPINFO)); + startup_info.dwFlags = STARTF_USESTDHANDLES; + startup_info.hStdInput = ::GetStdHandle(STD_INPUT_HANDLE); + startup_info.hStdOutput = ::GetStdHandle(STD_OUTPUT_HANDLE); + startup_info.hStdError = ::GetStdHandle(STD_ERROR_HANDLE); + + PROCESS_INFORMATION process_info; + GTEST_DEATH_TEST_CHECK_(::CreateProcessA( + executable_path, + const_cast(command_line.c_str()), + NULL, // Retuned process handle is not inheritable. + NULL, // Retuned thread handle is not inheritable. + TRUE, // Child inherits all inheritable handles (for write_handle_). + 0x0, // Default creation flags. + NULL, // Inherit the parent's environment. + UnitTest::GetInstance()->original_working_dir(), + &startup_info, + &process_info) != FALSE); + child_handle_.Reset(process_info.hProcess); + ::CloseHandle(process_info.hThread); + set_spawned(true); + return OVERSEE_TEST; +} +# else // We are not on Windows. + +// ForkingDeathTest provides implementations for most of the abstract +// methods of the DeathTest interface. Only the AssumeRole method is +// left undefined. +class ForkingDeathTest : public DeathTestImpl { + public: + ForkingDeathTest(const char* statement, const RE* regex); + + // All of these virtual functions are inherited from DeathTest. + virtual int Wait(); + + protected: + void set_child_pid(pid_t child_pid) { child_pid_ = child_pid; } + + private: + // PID of child process during death test; 0 in the child process itself. + pid_t child_pid_; +}; + +// Constructs a ForkingDeathTest. +ForkingDeathTest::ForkingDeathTest(const char* a_statement, const RE* a_regex) + : DeathTestImpl(a_statement, a_regex), + child_pid_(-1) {} + +// Waits for the child in a death test to exit, returning its exit +// status, or 0 if no child process exists. As a side effect, sets the +// outcome data member. +int ForkingDeathTest::Wait() { + if (!spawned()) + return 0; + + ReadAndInterpretStatusByte(); + + int status_value; + GTEST_DEATH_TEST_CHECK_SYSCALL_(waitpid(child_pid_, &status_value, 0)); + set_status(status_value); + return status_value; +} + +// A concrete death test class that forks, then immediately runs the test +// in the child process. +class NoExecDeathTest : public ForkingDeathTest { + public: + NoExecDeathTest(const char* a_statement, const RE* a_regex) : + ForkingDeathTest(a_statement, a_regex) { } + virtual TestRole AssumeRole(); +}; + +// The AssumeRole process for a fork-and-run death test. It implements a +// straightforward fork, with a simple pipe to transmit the status byte. +DeathTest::TestRole NoExecDeathTest::AssumeRole() { + const size_t thread_count = GetThreadCount(); + if (thread_count != 1) { + GTEST_LOG_(WARNING) << DeathTestThreadWarning(thread_count); + } + + int pipe_fd[2]; + GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1); + + DeathTest::set_last_death_test_message(""); + CaptureStderr(); + // When we fork the process below, the log file buffers are copied, but the + // file descriptors are shared. We flush all log files here so that closing + // the file descriptors in the child process doesn't throw off the + // synchronization between descriptors and buffers in the parent process. + // This is as close to the fork as possible to avoid a race condition in case + // there are multiple threads running before the death test, and another + // thread writes to the log file. + FlushInfoLog(); + + const pid_t child_pid = fork(); + GTEST_DEATH_TEST_CHECK_(child_pid != -1); + set_child_pid(child_pid); + if (child_pid == 0) { + GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[0])); + set_write_fd(pipe_fd[1]); + // Redirects all logging to stderr in the child process to prevent + // concurrent writes to the log files. We capture stderr in the parent + // process and append the child process' output to a log. + LogToStderr(); + // Event forwarding to the listeners of event listener API mush be shut + // down in death test subprocesses. + GetUnitTestImpl()->listeners()->SuppressEventForwarding(); + g_in_fast_death_test_child = true; + return EXECUTE_TEST; + } else { + GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1])); + set_read_fd(pipe_fd[0]); + set_spawned(true); + return OVERSEE_TEST; + } +} + +// A concrete death test class that forks and re-executes the main +// program from the beginning, with command-line flags set that cause +// only this specific death test to be run. +class ExecDeathTest : public ForkingDeathTest { + public: + ExecDeathTest(const char* a_statement, const RE* a_regex, + const char* file, int line) : + ForkingDeathTest(a_statement, a_regex), file_(file), line_(line) { } + virtual TestRole AssumeRole(); + private: + static ::std::vector + GetArgvsForDeathTestChildProcess() { + ::std::vector args = GetInjectableArgvs(); + return args; + } + // The name of the file in which the death test is located. + const char* const file_; + // The line number on which the death test is located. + const int line_; +}; + +// Utility class for accumulating command-line arguments. +class Arguments { + public: + Arguments() { + args_.push_back(NULL); + } + + ~Arguments() { + for (std::vector::iterator i = args_.begin(); i != args_.end(); + ++i) { + free(*i); + } + } + void AddArgument(const char* argument) { + args_.insert(args_.end() - 1, posix::StrDup(argument)); + } + + template + void AddArguments(const ::std::vector& arguments) { + for (typename ::std::vector::const_iterator i = arguments.begin(); + i != arguments.end(); + ++i) { + args_.insert(args_.end() - 1, posix::StrDup(i->c_str())); + } + } + char* const* Argv() { + return &args_[0]; + } + + private: + std::vector args_; +}; + +// A struct that encompasses the arguments to the child process of a +// threadsafe-style death test process. +struct ExecDeathTestArgs { + char* const* argv; // Command-line arguments for the child's call to exec + int close_fd; // File descriptor to close; the read end of a pipe +}; + +# if GTEST_OS_MAC +inline char** GetEnviron() { + // When Google Test is built as a framework on MacOS X, the environ variable + // is unavailable. Apple's documentation (man environ) recommends using + // _NSGetEnviron() instead. + return *_NSGetEnviron(); +} +# else +// Some POSIX platforms expect you to declare environ. extern "C" makes +// it reside in the global namespace. +extern "C" char** environ; +inline char** GetEnviron() { return environ; } +# endif // GTEST_OS_MAC + +# if !GTEST_OS_QNX +// The main function for a threadsafe-style death test child process. +// This function is called in a clone()-ed process and thus must avoid +// any potentially unsafe operations like malloc or libc functions. +static int ExecDeathTestChildMain(void* child_arg) { + ExecDeathTestArgs* const args = static_cast(child_arg); + GTEST_DEATH_TEST_CHECK_SYSCALL_(close(args->close_fd)); + + // We need to execute the test program in the same environment where + // it was originally invoked. Therefore we change to the original + // working directory first. + const char* const original_dir = + UnitTest::GetInstance()->original_working_dir(); + // We can safely call chdir() as it's a direct system call. + if (chdir(original_dir) != 0) { + DeathTestAbort(std::string("chdir(\"") + original_dir + "\") failed: " + + GetLastErrnoDescription()); + return EXIT_FAILURE; + } + + // We can safely call execve() as it's a direct system call. We + // cannot use execvp() as it's a libc function and thus potentially + // unsafe. Since execve() doesn't search the PATH, the user must + // invoke the test program via a valid path that contains at least + // one path separator. + execve(args->argv[0], args->argv, GetEnviron()); + DeathTestAbort(std::string("execve(") + args->argv[0] + ", ...) in " + + original_dir + " failed: " + + GetLastErrnoDescription()); + return EXIT_FAILURE; +} +# endif // !GTEST_OS_QNX + +// Two utility routines that together determine the direction the stack +// grows. +// This could be accomplished more elegantly by a single recursive +// function, but we want to guard against the unlikely possibility of +// a smart compiler optimizing the recursion away. +// +// GTEST_NO_INLINE_ is required to prevent GCC 4.6 from inlining +// StackLowerThanAddress into StackGrowsDown, which then doesn't give +// correct answer. +void StackLowerThanAddress(const void* ptr, bool* result) GTEST_NO_INLINE_; +void StackLowerThanAddress(const void* ptr, bool* result) { + int dummy; + *result = (&dummy < ptr); +} + +bool StackGrowsDown() { + int dummy; + bool result; + StackLowerThanAddress(&dummy, &result); + return result; +} + +// Spawns a child process with the same executable as the current process in +// a thread-safe manner and instructs it to run the death test. The +// implementation uses fork(2) + exec. On systems where clone(2) is +// available, it is used instead, being slightly more thread-safe. On QNX, +// fork supports only single-threaded environments, so this function uses +// spawn(2) there instead. The function dies with an error message if +// anything goes wrong. +static pid_t ExecDeathTestSpawnChild(char* const* argv, int close_fd) { + ExecDeathTestArgs args = { argv, close_fd }; + pid_t child_pid = -1; + +# if GTEST_OS_QNX + // Obtains the current directory and sets it to be closed in the child + // process. + const int cwd_fd = open(".", O_RDONLY); + GTEST_DEATH_TEST_CHECK_(cwd_fd != -1); + GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(cwd_fd, F_SETFD, FD_CLOEXEC)); + // We need to execute the test program in the same environment where + // it was originally invoked. Therefore we change to the original + // working directory first. + const char* const original_dir = + UnitTest::GetInstance()->original_working_dir(); + // We can safely call chdir() as it's a direct system call. + if (chdir(original_dir) != 0) { + DeathTestAbort(std::string("chdir(\"") + original_dir + "\") failed: " + + GetLastErrnoDescription()); + return EXIT_FAILURE; + } + + int fd_flags; + // Set close_fd to be closed after spawn. + GTEST_DEATH_TEST_CHECK_SYSCALL_(fd_flags = fcntl(close_fd, F_GETFD)); + GTEST_DEATH_TEST_CHECK_SYSCALL_(fcntl(close_fd, F_SETFD, + fd_flags | FD_CLOEXEC)); + struct inheritance inherit = {0}; + // spawn is a system call. + child_pid = spawn(args.argv[0], 0, NULL, &inherit, args.argv, GetEnviron()); + // Restores the current working directory. + GTEST_DEATH_TEST_CHECK_(fchdir(cwd_fd) != -1); + GTEST_DEATH_TEST_CHECK_SYSCALL_(close(cwd_fd)); + +# else // GTEST_OS_QNX +# if GTEST_OS_LINUX + // When a SIGPROF signal is received while fork() or clone() are executing, + // the process may hang. To avoid this, we ignore SIGPROF here and re-enable + // it after the call to fork()/clone() is complete. + struct sigaction saved_sigprof_action; + struct sigaction ignore_sigprof_action; + memset(&ignore_sigprof_action, 0, sizeof(ignore_sigprof_action)); + sigemptyset(&ignore_sigprof_action.sa_mask); + ignore_sigprof_action.sa_handler = SIG_IGN; + GTEST_DEATH_TEST_CHECK_SYSCALL_(sigaction( + SIGPROF, &ignore_sigprof_action, &saved_sigprof_action)); +# endif // GTEST_OS_LINUX + +# if GTEST_HAS_CLONE + const bool use_fork = GTEST_FLAG(death_test_use_fork); + + if (!use_fork) { + static const bool stack_grows_down = StackGrowsDown(); + const size_t stack_size = getpagesize(); + // MMAP_ANONYMOUS is not defined on Mac, so we use MAP_ANON instead. + void* const stack = mmap(NULL, stack_size, PROT_READ | PROT_WRITE, + MAP_ANON | MAP_PRIVATE, -1, 0); + GTEST_DEATH_TEST_CHECK_(stack != MAP_FAILED); + + // Maximum stack alignment in bytes: For a downward-growing stack, this + // amount is subtracted from size of the stack space to get an address + // that is within the stack space and is aligned on all systems we care + // about. As far as I know there is no ABI with stack alignment greater + // than 64. We assume stack and stack_size already have alignment of + // kMaxStackAlignment. + const size_t kMaxStackAlignment = 64; + void* const stack_top = + static_cast(stack) + + (stack_grows_down ? stack_size - kMaxStackAlignment : 0); + GTEST_DEATH_TEST_CHECK_(stack_size > kMaxStackAlignment && + reinterpret_cast(stack_top) % kMaxStackAlignment == 0); + + child_pid = clone(&ExecDeathTestChildMain, stack_top, SIGCHLD, &args); + + GTEST_DEATH_TEST_CHECK_(munmap(stack, stack_size) != -1); + } +# else + const bool use_fork = true; +# endif // GTEST_HAS_CLONE + + if (use_fork && (child_pid = fork()) == 0) { + ExecDeathTestChildMain(&args); + _exit(0); + } +# endif // GTEST_OS_QNX +# if GTEST_OS_LINUX + GTEST_DEATH_TEST_CHECK_SYSCALL_( + sigaction(SIGPROF, &saved_sigprof_action, NULL)); +# endif // GTEST_OS_LINUX + + GTEST_DEATH_TEST_CHECK_(child_pid != -1); + return child_pid; +} + +// The AssumeRole process for a fork-and-exec death test. It re-executes the +// main program from the beginning, setting the --gtest_filter +// and --gtest_internal_run_death_test flags to cause only the current +// death test to be re-run. +DeathTest::TestRole ExecDeathTest::AssumeRole() { + const UnitTestImpl* const impl = GetUnitTestImpl(); + const InternalRunDeathTestFlag* const flag = + impl->internal_run_death_test_flag(); + const TestInfo* const info = impl->current_test_info(); + const int death_test_index = info->result()->death_test_count(); + + if (flag != NULL) { + set_write_fd(flag->write_fd()); + return EXECUTE_TEST; + } + + int pipe_fd[2]; + GTEST_DEATH_TEST_CHECK_(pipe(pipe_fd) != -1); + // Clear the close-on-exec flag on the write end of the pipe, lest + // it be closed when the child process does an exec: + GTEST_DEATH_TEST_CHECK_(fcntl(pipe_fd[1], F_SETFD, 0) != -1); + + const std::string filter_flag = + std::string("--") + GTEST_FLAG_PREFIX_ + kFilterFlag + "=" + + info->test_case_name() + "." + info->name(); + const std::string internal_flag = + std::string("--") + GTEST_FLAG_PREFIX_ + kInternalRunDeathTestFlag + "=" + + file_ + "|" + StreamableToString(line_) + "|" + + StreamableToString(death_test_index) + "|" + + StreamableToString(pipe_fd[1]); + Arguments args; + args.AddArguments(GetArgvsForDeathTestChildProcess()); + args.AddArgument(filter_flag.c_str()); + args.AddArgument(internal_flag.c_str()); + + DeathTest::set_last_death_test_message(""); + + CaptureStderr(); + // See the comment in NoExecDeathTest::AssumeRole for why the next line + // is necessary. + FlushInfoLog(); + + const pid_t child_pid = ExecDeathTestSpawnChild(args.Argv(), pipe_fd[0]); + GTEST_DEATH_TEST_CHECK_SYSCALL_(close(pipe_fd[1])); + set_child_pid(child_pid); + set_read_fd(pipe_fd[0]); + set_spawned(true); + return OVERSEE_TEST; +} + +# endif // !GTEST_OS_WINDOWS + +// Creates a concrete DeathTest-derived class that depends on the +// --gtest_death_test_style flag, and sets the pointer pointed to +// by the "test" argument to its address. If the test should be +// skipped, sets that pointer to NULL. Returns true, unless the +// flag is set to an invalid value. +bool DefaultDeathTestFactory::Create(const char* statement, const RE* regex, + const char* file, int line, + DeathTest** test) { + UnitTestImpl* const impl = GetUnitTestImpl(); + const InternalRunDeathTestFlag* const flag = + impl->internal_run_death_test_flag(); + const int death_test_index = impl->current_test_info() + ->increment_death_test_count(); + + if (flag != NULL) { + if (death_test_index > flag->index()) { + DeathTest::set_last_death_test_message( + "Death test count (" + StreamableToString(death_test_index) + + ") somehow exceeded expected maximum (" + + StreamableToString(flag->index()) + ")"); + return false; + } + + if (!(flag->file() == file && flag->line() == line && + flag->index() == death_test_index)) { + *test = NULL; + return true; + } + } + +# if GTEST_OS_WINDOWS + + if (GTEST_FLAG(death_test_style) == "threadsafe" || + GTEST_FLAG(death_test_style) == "fast") { + *test = new WindowsDeathTest(statement, regex, file, line); + } + +# else + + if (GTEST_FLAG(death_test_style) == "threadsafe") { + *test = new ExecDeathTest(statement, regex, file, line); + } else if (GTEST_FLAG(death_test_style) == "fast") { + *test = new NoExecDeathTest(statement, regex); + } + +# endif // GTEST_OS_WINDOWS + + else { // NOLINT - this is more readable than unbalanced brackets inside #if. + DeathTest::set_last_death_test_message( + "Unknown death test style \"" + GTEST_FLAG(death_test_style) + + "\" encountered"); + return false; + } + + return true; +} + +// Splits a given string on a given delimiter, populating a given +// vector with the fields. GTEST_HAS_DEATH_TEST implies that we have +// ::std::string, so we can use it here. +static void SplitString(const ::std::string& str, char delimiter, + ::std::vector< ::std::string>* dest) { + ::std::vector< ::std::string> parsed; + ::std::string::size_type pos = 0; + while (::testing::internal::AlwaysTrue()) { + const ::std::string::size_type colon = str.find(delimiter, pos); + if (colon == ::std::string::npos) { + parsed.push_back(str.substr(pos)); + break; + } else { + parsed.push_back(str.substr(pos, colon - pos)); + pos = colon + 1; + } + } + dest->swap(parsed); +} + +# if GTEST_OS_WINDOWS +// Recreates the pipe and event handles from the provided parameters, +// signals the event, and returns a file descriptor wrapped around the pipe +// handle. This function is called in the child process only. +int GetStatusFileDescriptor(unsigned int parent_process_id, + size_t write_handle_as_size_t, + size_t event_handle_as_size_t) { + AutoHandle parent_process_handle(::OpenProcess(PROCESS_DUP_HANDLE, + FALSE, // Non-inheritable. + parent_process_id)); + if (parent_process_handle.Get() == INVALID_HANDLE_VALUE) { + DeathTestAbort("Unable to open parent process " + + StreamableToString(parent_process_id)); + } + + // TODO(vladl@google.com): Replace the following check with a + // compile-time assertion when available. + GTEST_CHECK_(sizeof(HANDLE) <= sizeof(size_t)); + + const HANDLE write_handle = + reinterpret_cast(write_handle_as_size_t); + HANDLE dup_write_handle; + + // The newly initialized handle is accessible only in in the parent + // process. To obtain one accessible within the child, we need to use + // DuplicateHandle. + if (!::DuplicateHandle(parent_process_handle.Get(), write_handle, + ::GetCurrentProcess(), &dup_write_handle, + 0x0, // Requested privileges ignored since + // DUPLICATE_SAME_ACCESS is used. + FALSE, // Request non-inheritable handler. + DUPLICATE_SAME_ACCESS)) { + DeathTestAbort("Unable to duplicate the pipe handle " + + StreamableToString(write_handle_as_size_t) + + " from the parent process " + + StreamableToString(parent_process_id)); + } + + const HANDLE event_handle = reinterpret_cast(event_handle_as_size_t); + HANDLE dup_event_handle; + + if (!::DuplicateHandle(parent_process_handle.Get(), event_handle, + ::GetCurrentProcess(), &dup_event_handle, + 0x0, + FALSE, + DUPLICATE_SAME_ACCESS)) { + DeathTestAbort("Unable to duplicate the event handle " + + StreamableToString(event_handle_as_size_t) + + " from the parent process " + + StreamableToString(parent_process_id)); + } + + const int write_fd = + ::_open_osfhandle(reinterpret_cast(dup_write_handle), O_APPEND); + if (write_fd == -1) { + DeathTestAbort("Unable to convert pipe handle " + + StreamableToString(write_handle_as_size_t) + + " to a file descriptor"); + } + + // Signals the parent that the write end of the pipe has been acquired + // so the parent can release its own write end. + ::SetEvent(dup_event_handle); + + return write_fd; +} +# endif // GTEST_OS_WINDOWS + +// Returns a newly created InternalRunDeathTestFlag object with fields +// initialized from the GTEST_FLAG(internal_run_death_test) flag if +// the flag is specified; otherwise returns NULL. +InternalRunDeathTestFlag* ParseInternalRunDeathTestFlag() { + if (GTEST_FLAG(internal_run_death_test) == "") return NULL; + + // GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we + // can use it here. + int line = -1; + int index = -1; + ::std::vector< ::std::string> fields; + SplitString(GTEST_FLAG(internal_run_death_test).c_str(), '|', &fields); + int write_fd = -1; + +# if GTEST_OS_WINDOWS + + unsigned int parent_process_id = 0; + size_t write_handle_as_size_t = 0; + size_t event_handle_as_size_t = 0; + + if (fields.size() != 6 + || !ParseNaturalNumber(fields[1], &line) + || !ParseNaturalNumber(fields[2], &index) + || !ParseNaturalNumber(fields[3], &parent_process_id) + || !ParseNaturalNumber(fields[4], &write_handle_as_size_t) + || !ParseNaturalNumber(fields[5], &event_handle_as_size_t)) { + DeathTestAbort("Bad --gtest_internal_run_death_test flag: " + + GTEST_FLAG(internal_run_death_test)); + } + write_fd = GetStatusFileDescriptor(parent_process_id, + write_handle_as_size_t, + event_handle_as_size_t); +# else + + if (fields.size() != 4 + || !ParseNaturalNumber(fields[1], &line) + || !ParseNaturalNumber(fields[2], &index) + || !ParseNaturalNumber(fields[3], &write_fd)) { + DeathTestAbort("Bad --gtest_internal_run_death_test flag: " + + GTEST_FLAG(internal_run_death_test)); + } + +# endif // GTEST_OS_WINDOWS + + return new InternalRunDeathTestFlag(fields[0], line, index, write_fd); +} + +} // namespace internal + +#endif // GTEST_HAS_DEATH_TEST + +} // namespace testing diff --git a/test/fmw/gtest/src/gtest-filepath.cc b/test/fmw/gtest/src/gtest-filepath.cc new file mode 100644 index 00000000000..6be58b6fca2 --- /dev/null +++ b/test/fmw/gtest/src/gtest-filepath.cc @@ -0,0 +1,382 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Authors: keith.ray@gmail.com (Keith Ray) + +#include "gtest/gtest-message.h" +#include "gtest/internal/gtest-filepath.h" +#include "gtest/internal/gtest-port.h" + +#include + +#if GTEST_OS_WINDOWS_MOBILE +# include +#elif GTEST_OS_WINDOWS +# include +# include +#elif GTEST_OS_SYMBIAN +// Symbian OpenC has PATH_MAX in sys/syslimits.h +# include +#else +# include +# include // Some Linux distributions define PATH_MAX here. +#endif // GTEST_OS_WINDOWS_MOBILE + +#if GTEST_OS_WINDOWS +# define GTEST_PATH_MAX_ _MAX_PATH +#elif defined(PATH_MAX) +# define GTEST_PATH_MAX_ PATH_MAX +#elif defined(_XOPEN_PATH_MAX) +# define GTEST_PATH_MAX_ _XOPEN_PATH_MAX +#else +# define GTEST_PATH_MAX_ _POSIX_PATH_MAX +#endif // GTEST_OS_WINDOWS + +#include "gtest/internal/gtest-string.h" + +namespace testing { +namespace internal { + +#if GTEST_OS_WINDOWS +// On Windows, '\\' is the standard path separator, but many tools and the +// Windows API also accept '/' as an alternate path separator. Unless otherwise +// noted, a file path can contain either kind of path separators, or a mixture +// of them. +const char kPathSeparator = '\\'; +const char kAlternatePathSeparator = '/'; +const char kPathSeparatorString[] = "\\"; +const char kAlternatePathSeparatorString[] = "/"; +# if GTEST_OS_WINDOWS_MOBILE +// Windows CE doesn't have a current directory. You should not use +// the current directory in tests on Windows CE, but this at least +// provides a reasonable fallback. +const char kCurrentDirectoryString[] = "\\"; +// Windows CE doesn't define INVALID_FILE_ATTRIBUTES +const DWORD kInvalidFileAttributes = 0xffffffff; +# else +const char kCurrentDirectoryString[] = ".\\"; +# endif // GTEST_OS_WINDOWS_MOBILE +#else +const char kPathSeparator = '/'; +const char kPathSeparatorString[] = "/"; +const char kCurrentDirectoryString[] = "./"; +#endif // GTEST_OS_WINDOWS + +// Returns whether the given character is a valid path separator. +static bool IsPathSeparator(char c) { +#if GTEST_HAS_ALT_PATH_SEP_ + return (c == kPathSeparator) || (c == kAlternatePathSeparator); +#else + return c == kPathSeparator; +#endif +} + +// Returns the current working directory, or "" if unsuccessful. +FilePath FilePath::GetCurrentDir() { +#if GTEST_OS_WINDOWS_MOBILE + // Windows CE doesn't have a current directory, so we just return + // something reasonable. + return FilePath(kCurrentDirectoryString); +#elif GTEST_OS_WINDOWS + char cwd[GTEST_PATH_MAX_ + 1] = { '\0' }; + return FilePath(_getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd); +#else + char cwd[GTEST_PATH_MAX_ + 1] = { '\0' }; + return FilePath(getcwd(cwd, sizeof(cwd)) == NULL ? "" : cwd); +#endif // GTEST_OS_WINDOWS_MOBILE +} + +// Returns a copy of the FilePath with the case-insensitive extension removed. +// Example: FilePath("dir/file.exe").RemoveExtension("EXE") returns +// FilePath("dir/file"). If a case-insensitive extension is not +// found, returns a copy of the original FilePath. +FilePath FilePath::RemoveExtension(const char* extension) const { + const std::string dot_extension = std::string(".") + extension; + if (String::EndsWithCaseInsensitive(pathname_, dot_extension)) { + return FilePath(pathname_.substr( + 0, pathname_.length() - dot_extension.length())); + } + return *this; +} + +// Returns a pointer to the last occurence of a valid path separator in +// the FilePath. On Windows, for example, both '/' and '\' are valid path +// separators. Returns NULL if no path separator was found. +const char* FilePath::FindLastPathSeparator() const { + const char* const last_sep = strrchr(c_str(), kPathSeparator); +#if GTEST_HAS_ALT_PATH_SEP_ + const char* const last_alt_sep = strrchr(c_str(), kAlternatePathSeparator); + // Comparing two pointers of which only one is NULL is undefined. + if (last_alt_sep != NULL && + (last_sep == NULL || last_alt_sep > last_sep)) { + return last_alt_sep; + } +#endif + return last_sep; +} + +// Returns a copy of the FilePath with the directory part removed. +// Example: FilePath("path/to/file").RemoveDirectoryName() returns +// FilePath("file"). If there is no directory part ("just_a_file"), it returns +// the FilePath unmodified. If there is no file part ("just_a_dir/") it +// returns an empty FilePath (""). +// On Windows platform, '\' is the path separator, otherwise it is '/'. +FilePath FilePath::RemoveDirectoryName() const { + const char* const last_sep = FindLastPathSeparator(); + return last_sep ? FilePath(last_sep + 1) : *this; +} + +// RemoveFileName returns the directory path with the filename removed. +// Example: FilePath("path/to/file").RemoveFileName() returns "path/to/". +// If the FilePath is "a_file" or "/a_file", RemoveFileName returns +// FilePath("./") or, on Windows, FilePath(".\\"). If the filepath does +// not have a file, like "just/a/dir/", it returns the FilePath unmodified. +// On Windows platform, '\' is the path separator, otherwise it is '/'. +FilePath FilePath::RemoveFileName() const { + const char* const last_sep = FindLastPathSeparator(); + std::string dir; + if (last_sep) { + dir = std::string(c_str(), last_sep + 1 - c_str()); + } else { + dir = kCurrentDirectoryString; + } + return FilePath(dir); +} + +// Helper functions for naming files in a directory for xml output. + +// Given directory = "dir", base_name = "test", number = 0, +// extension = "xml", returns "dir/test.xml". If number is greater +// than zero (e.g., 12), returns "dir/test_12.xml". +// On Windows platform, uses \ as the separator rather than /. +FilePath FilePath::MakeFileName(const FilePath& directory, + const FilePath& base_name, + int number, + const char* extension) { + std::string file; + if (number == 0) { + file = base_name.string() + "." + extension; + } else { + file = base_name.string() + "_" + StreamableToString(number) + + "." + extension; + } + return ConcatPaths(directory, FilePath(file)); +} + +// Given directory = "dir", relative_path = "test.xml", returns "dir/test.xml". +// On Windows, uses \ as the separator rather than /. +FilePath FilePath::ConcatPaths(const FilePath& directory, + const FilePath& relative_path) { + if (directory.IsEmpty()) + return relative_path; + const FilePath dir(directory.RemoveTrailingPathSeparator()); + return FilePath(dir.string() + kPathSeparator + relative_path.string()); +} + +// Returns true if pathname describes something findable in the file-system, +// either a file, directory, or whatever. +bool FilePath::FileOrDirectoryExists() const { +#if GTEST_OS_WINDOWS_MOBILE + LPCWSTR unicode = String::AnsiToUtf16(pathname_.c_str()); + const DWORD attributes = GetFileAttributes(unicode); + delete [] unicode; + return attributes != kInvalidFileAttributes; +#else + posix::StatStruct file_stat; + return posix::Stat(pathname_.c_str(), &file_stat) == 0; +#endif // GTEST_OS_WINDOWS_MOBILE +} + +// Returns true if pathname describes a directory in the file-system +// that exists. +bool FilePath::DirectoryExists() const { + bool result = false; +#if GTEST_OS_WINDOWS + // Don't strip off trailing separator if path is a root directory on + // Windows (like "C:\\"). + const FilePath& path(IsRootDirectory() ? *this : + RemoveTrailingPathSeparator()); +#else + const FilePath& path(*this); +#endif + +#if GTEST_OS_WINDOWS_MOBILE + LPCWSTR unicode = String::AnsiToUtf16(path.c_str()); + const DWORD attributes = GetFileAttributes(unicode); + delete [] unicode; + if ((attributes != kInvalidFileAttributes) && + (attributes & FILE_ATTRIBUTE_DIRECTORY)) { + result = true; + } +#else + posix::StatStruct file_stat; + result = posix::Stat(path.c_str(), &file_stat) == 0 && + posix::IsDir(file_stat); +#endif // GTEST_OS_WINDOWS_MOBILE + + return result; +} + +// Returns true if pathname describes a root directory. (Windows has one +// root directory per disk drive.) +bool FilePath::IsRootDirectory() const { +#if GTEST_OS_WINDOWS + // TODO(wan@google.com): on Windows a network share like + // \\server\share can be a root directory, although it cannot be the + // current directory. Handle this properly. + return pathname_.length() == 3 && IsAbsolutePath(); +#else + return pathname_.length() == 1 && IsPathSeparator(pathname_.c_str()[0]); +#endif +} + +// Returns true if pathname describes an absolute path. +bool FilePath::IsAbsolutePath() const { + const char* const name = pathname_.c_str(); +#if GTEST_OS_WINDOWS + return pathname_.length() >= 3 && + ((name[0] >= 'a' && name[0] <= 'z') || + (name[0] >= 'A' && name[0] <= 'Z')) && + name[1] == ':' && + IsPathSeparator(name[2]); +#else + return IsPathSeparator(name[0]); +#endif +} + +// Returns a pathname for a file that does not currently exist. The pathname +// will be directory/base_name.extension or +// directory/base_name_.extension if directory/base_name.extension +// already exists. The number will be incremented until a pathname is found +// that does not already exist. +// Examples: 'dir/foo_test.xml' or 'dir/foo_test_1.xml'. +// There could be a race condition if two or more processes are calling this +// function at the same time -- they could both pick the same filename. +FilePath FilePath::GenerateUniqueFileName(const FilePath& directory, + const FilePath& base_name, + const char* extension) { + FilePath full_pathname; + int number = 0; + do { + full_pathname.Set(MakeFileName(directory, base_name, number++, extension)); + } while (full_pathname.FileOrDirectoryExists()); + return full_pathname; +} + +// Returns true if FilePath ends with a path separator, which indicates that +// it is intended to represent a directory. Returns false otherwise. +// This does NOT check that a directory (or file) actually exists. +bool FilePath::IsDirectory() const { + return !pathname_.empty() && + IsPathSeparator(pathname_.c_str()[pathname_.length() - 1]); +} + +// Create directories so that path exists. Returns true if successful or if +// the directories already exist; returns false if unable to create directories +// for any reason. +bool FilePath::CreateDirectoriesRecursively() const { + if (!this->IsDirectory()) { + return false; + } + + if (pathname_.length() == 0 || this->DirectoryExists()) { + return true; + } + + const FilePath parent(this->RemoveTrailingPathSeparator().RemoveFileName()); + return parent.CreateDirectoriesRecursively() && this->CreateFolder(); +} + +// Create the directory so that path exists. Returns true if successful or +// if the directory already exists; returns false if unable to create the +// directory for any reason, including if the parent directory does not +// exist. Not named "CreateDirectory" because that's a macro on Windows. +bool FilePath::CreateFolder() const { +#if GTEST_OS_WINDOWS_MOBILE + FilePath removed_sep(this->RemoveTrailingPathSeparator()); + LPCWSTR unicode = String::AnsiToUtf16(removed_sep.c_str()); + int result = CreateDirectory(unicode, NULL) ? 0 : -1; + delete [] unicode; +#elif GTEST_OS_WINDOWS + int result = _mkdir(pathname_.c_str()); +#else + int result = mkdir(pathname_.c_str(), 0777); +#endif // GTEST_OS_WINDOWS_MOBILE + + if (result == -1) { + return this->DirectoryExists(); // An error is OK if the directory exists. + } + return true; // No error. +} + +// If input name has a trailing separator character, remove it and return the +// name, otherwise return the name string unmodified. +// On Windows platform, uses \ as the separator, other platforms use /. +FilePath FilePath::RemoveTrailingPathSeparator() const { + return IsDirectory() + ? FilePath(pathname_.substr(0, pathname_.length() - 1)) + : *this; +} + +// Removes any redundant separators that might be in the pathname. +// For example, "bar///foo" becomes "bar/foo". Does not eliminate other +// redundancies that might be in a pathname involving "." or "..". +// TODO(wan@google.com): handle Windows network shares (e.g. \\server\share). +void FilePath::Normalize() { + if (pathname_.c_str() == NULL) { + pathname_ = ""; + return; + } + const char* src = pathname_.c_str(); + char* const dest = new char[pathname_.length() + 1]; + char* dest_ptr = dest; + memset(dest_ptr, 0, pathname_.length() + 1); + + while (*src != '\0') { + *dest_ptr = *src; + if (!IsPathSeparator(*src)) { + src++; + } else { +#if GTEST_HAS_ALT_PATH_SEP_ + if (*dest_ptr == kAlternatePathSeparator) { + *dest_ptr = kPathSeparator; + } +#endif + while (IsPathSeparator(*src)) + src++; + } + dest_ptr++; + } + *dest_ptr = '\0'; + pathname_ = dest; + delete[] dest; +} + +} // namespace internal +} // namespace testing diff --git a/test/fmw/gtest/src/gtest-internal-inl.h b/test/fmw/gtest/src/gtest-internal-inl.h new file mode 100644 index 00000000000..35df303cca6 --- /dev/null +++ b/test/fmw/gtest/src/gtest-internal-inl.h @@ -0,0 +1,1218 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Utility functions and classes used by the Google C++ testing framework. +// +// Author: wan@google.com (Zhanyong Wan) +// +// This file contains purely Google Test's internal implementation. Please +// DO NOT #INCLUDE IT IN A USER PROGRAM. + +#ifndef GTEST_SRC_GTEST_INTERNAL_INL_H_ +#define GTEST_SRC_GTEST_INTERNAL_INL_H_ + +// GTEST_IMPLEMENTATION_ is defined to 1 iff the current translation unit is +// part of Google Test's implementation; otherwise it's undefined. +#if !GTEST_IMPLEMENTATION_ +// A user is trying to include this from his code - just say no. +# error "gtest-internal-inl.h is part of Google Test's internal implementation." +# error "It must not be included except by Google Test itself." +#endif // GTEST_IMPLEMENTATION_ + +#ifndef _WIN32_WCE +# include +#endif // !_WIN32_WCE +#include +#include // For strtoll/_strtoul64/malloc/free. +#include // For memmove. + +#include +#include +#include + +#include "gtest/internal/gtest-port.h" + +#if GTEST_CAN_STREAM_RESULTS_ +# include // NOLINT +# include // NOLINT +#endif + +#if GTEST_OS_WINDOWS +# include // NOLINT +#endif // GTEST_OS_WINDOWS + +#include "gtest/gtest.h" // NOLINT +#include "gtest/gtest-spi.h" + +namespace testing { + +// Declares the flags. +// +// We don't want the users to modify this flag in the code, but want +// Google Test's own unit tests to be able to access it. Therefore we +// declare it here as opposed to in gtest.h. +GTEST_DECLARE_bool_(death_test_use_fork); + +namespace internal { + +// The value of GetTestTypeId() as seen from within the Google Test +// library. This is solely for testing GetTestTypeId(). +GTEST_API_ extern const TypeId kTestTypeIdInGoogleTest; + +// Names of the flags (needed for parsing Google Test flags). +const char kAlsoRunDisabledTestsFlag[] = "also_run_disabled_tests"; +const char kBreakOnFailureFlag[] = "break_on_failure"; +const char kCatchExceptionsFlag[] = "catch_exceptions"; +const char kColorFlag[] = "color"; +const char kFilterFlag[] = "filter"; +const char kListTestsFlag[] = "list_tests"; +const char kOutputFlag[] = "output"; +const char kPrintTimeFlag[] = "print_time"; +const char kRandomSeedFlag[] = "random_seed"; +const char kRepeatFlag[] = "repeat"; +const char kShuffleFlag[] = "shuffle"; +const char kStackTraceDepthFlag[] = "stack_trace_depth"; +const char kStreamResultToFlag[] = "stream_result_to"; +const char kThrowOnFailureFlag[] = "throw_on_failure"; + +// A valid random seed must be in [1, kMaxRandomSeed]. +const int kMaxRandomSeed = 99999; + +// g_help_flag is true iff the --help flag or an equivalent form is +// specified on the command line. +GTEST_API_ extern bool g_help_flag; + +// Returns the current time in milliseconds. +GTEST_API_ TimeInMillis GetTimeInMillis(); + +// Returns true iff Google Test should use colors in the output. +GTEST_API_ bool ShouldUseColor(bool stdout_is_tty); + +// Formats the given time in milliseconds as seconds. +GTEST_API_ std::string FormatTimeInMillisAsSeconds(TimeInMillis ms); + +// Converts the given time in milliseconds to a date string in the ISO 8601 +// format, without the timezone information. N.B.: due to the use the +// non-reentrant localtime() function, this function is not thread safe. Do +// not use it in any code that can be called from multiple threads. +GTEST_API_ std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms); + +// Parses a string for an Int32 flag, in the form of "--flag=value". +// +// On success, stores the value of the flag in *value, and returns +// true. On failure, returns false without changing *value. +GTEST_API_ bool ParseInt32Flag( + const char* str, const char* flag, Int32* value); + +// Returns a random seed in range [1, kMaxRandomSeed] based on the +// given --gtest_random_seed flag value. +inline int GetRandomSeedFromFlag(Int32 random_seed_flag) { + const unsigned int raw_seed = (random_seed_flag == 0) ? + static_cast(GetTimeInMillis()) : + static_cast(random_seed_flag); + + // Normalizes the actual seed to range [1, kMaxRandomSeed] such that + // it's easy to type. + const int normalized_seed = + static_cast((raw_seed - 1U) % + static_cast(kMaxRandomSeed)) + 1; + return normalized_seed; +} + +// Returns the first valid random seed after 'seed'. The behavior is +// undefined if 'seed' is invalid. The seed after kMaxRandomSeed is +// considered to be 1. +inline int GetNextRandomSeed(int seed) { + GTEST_CHECK_(1 <= seed && seed <= kMaxRandomSeed) + << "Invalid random seed " << seed << " - must be in [1, " + << kMaxRandomSeed << "]."; + const int next_seed = seed + 1; + return (next_seed > kMaxRandomSeed) ? 1 : next_seed; +} + +// This class saves the values of all Google Test flags in its c'tor, and +// restores them in its d'tor. +class GTestFlagSaver { + public: + // The c'tor. + GTestFlagSaver() { + also_run_disabled_tests_ = GTEST_FLAG(also_run_disabled_tests); + break_on_failure_ = GTEST_FLAG(break_on_failure); + catch_exceptions_ = GTEST_FLAG(catch_exceptions); + color_ = GTEST_FLAG(color); + death_test_style_ = GTEST_FLAG(death_test_style); + death_test_use_fork_ = GTEST_FLAG(death_test_use_fork); + filter_ = GTEST_FLAG(filter); + internal_run_death_test_ = GTEST_FLAG(internal_run_death_test); + list_tests_ = GTEST_FLAG(list_tests); + output_ = GTEST_FLAG(output); + print_time_ = GTEST_FLAG(print_time); + random_seed_ = GTEST_FLAG(random_seed); + repeat_ = GTEST_FLAG(repeat); + shuffle_ = GTEST_FLAG(shuffle); + stack_trace_depth_ = GTEST_FLAG(stack_trace_depth); + stream_result_to_ = GTEST_FLAG(stream_result_to); + throw_on_failure_ = GTEST_FLAG(throw_on_failure); + } + + // The d'tor is not virtual. DO NOT INHERIT FROM THIS CLASS. + ~GTestFlagSaver() { + GTEST_FLAG(also_run_disabled_tests) = also_run_disabled_tests_; + GTEST_FLAG(break_on_failure) = break_on_failure_; + GTEST_FLAG(catch_exceptions) = catch_exceptions_; + GTEST_FLAG(color) = color_; + GTEST_FLAG(death_test_style) = death_test_style_; + GTEST_FLAG(death_test_use_fork) = death_test_use_fork_; + GTEST_FLAG(filter) = filter_; + GTEST_FLAG(internal_run_death_test) = internal_run_death_test_; + GTEST_FLAG(list_tests) = list_tests_; + GTEST_FLAG(output) = output_; + GTEST_FLAG(print_time) = print_time_; + GTEST_FLAG(random_seed) = random_seed_; + GTEST_FLAG(repeat) = repeat_; + GTEST_FLAG(shuffle) = shuffle_; + GTEST_FLAG(stack_trace_depth) = stack_trace_depth_; + GTEST_FLAG(stream_result_to) = stream_result_to_; + GTEST_FLAG(throw_on_failure) = throw_on_failure_; + } + + private: + // Fields for saving the original values of flags. + bool also_run_disabled_tests_; + bool break_on_failure_; + bool catch_exceptions_; + std::string color_; + std::string death_test_style_; + bool death_test_use_fork_; + std::string filter_; + std::string internal_run_death_test_; + bool list_tests_; + std::string output_; + bool print_time_; + internal::Int32 random_seed_; + internal::Int32 repeat_; + bool shuffle_; + internal::Int32 stack_trace_depth_; + std::string stream_result_to_; + bool throw_on_failure_; +} GTEST_ATTRIBUTE_UNUSED_; + +// Converts a Unicode code point to a narrow string in UTF-8 encoding. +// code_point parameter is of type UInt32 because wchar_t may not be +// wide enough to contain a code point. +// If the code_point is not a valid Unicode code point +// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted +// to "(Invalid Unicode 0xXXXXXXXX)". +GTEST_API_ std::string CodePointToUtf8(UInt32 code_point); + +// Converts a wide string to a narrow string in UTF-8 encoding. +// The wide string is assumed to have the following encoding: +// UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS) +// UTF-32 if sizeof(wchar_t) == 4 (on Linux) +// Parameter str points to a null-terminated wide string. +// Parameter num_chars may additionally limit the number +// of wchar_t characters processed. -1 is used when the entire string +// should be processed. +// If the string contains code points that are not valid Unicode code points +// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output +// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding +// and contains invalid UTF-16 surrogate pairs, values in those pairs +// will be encoded as individual Unicode characters from Basic Normal Plane. +GTEST_API_ std::string WideStringToUtf8(const wchar_t* str, int num_chars); + +// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file +// if the variable is present. If a file already exists at this location, this +// function will write over it. If the variable is present, but the file cannot +// be created, prints an error and exits. +void WriteToShardStatusFileIfNeeded(); + +// Checks whether sharding is enabled by examining the relevant +// environment variable values. If the variables are present, +// but inconsistent (e.g., shard_index >= total_shards), prints +// an error and exits. If in_subprocess_for_death_test, sharding is +// disabled because it must only be applied to the original test +// process. Otherwise, we could filter out death tests we intended to execute. +GTEST_API_ bool ShouldShard(const char* total_shards_str, + const char* shard_index_str, + bool in_subprocess_for_death_test); + +// Parses the environment variable var as an Int32. If it is unset, +// returns default_val. If it is not an Int32, prints an error and +// and aborts. +GTEST_API_ Int32 Int32FromEnvOrDie(const char* env_var, Int32 default_val); + +// Given the total number of shards, the shard index, and the test id, +// returns true iff the test should be run on this shard. The test id is +// some arbitrary but unique non-negative integer assigned to each test +// method. Assumes that 0 <= shard_index < total_shards. +GTEST_API_ bool ShouldRunTestOnShard( + int total_shards, int shard_index, int test_id); + +// STL container utilities. + +// Returns the number of elements in the given container that satisfy +// the given predicate. +template +inline int CountIf(const Container& c, Predicate predicate) { + // Implemented as an explicit loop since std::count_if() in libCstd on + // Solaris has a non-standard signature. + int count = 0; + for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) { + if (predicate(*it)) + ++count; + } + return count; +} + +// Applies a function/functor to each element in the container. +template +void ForEach(const Container& c, Functor functor) { + std::for_each(c.begin(), c.end(), functor); +} + +// Returns the i-th element of the vector, or default_value if i is not +// in range [0, v.size()). +template +inline E GetElementOr(const std::vector& v, int i, E default_value) { + return (i < 0 || i >= static_cast(v.size())) ? default_value : v[i]; +} + +// Performs an in-place shuffle of a range of the vector's elements. +// 'begin' and 'end' are element indices as an STL-style range; +// i.e. [begin, end) are shuffled, where 'end' == size() means to +// shuffle to the end of the vector. +template +void ShuffleRange(internal::Random* random, int begin, int end, + std::vector* v) { + const int size = static_cast(v->size()); + GTEST_CHECK_(0 <= begin && begin <= size) + << "Invalid shuffle range start " << begin << ": must be in range [0, " + << size << "]."; + GTEST_CHECK_(begin <= end && end <= size) + << "Invalid shuffle range finish " << end << ": must be in range [" + << begin << ", " << size << "]."; + + // Fisher-Yates shuffle, from + // http://en.wikipedia.org/wiki/Fisher-Yates_shuffle + for (int range_width = end - begin; range_width >= 2; range_width--) { + const int last_in_range = begin + range_width - 1; + const int selected = begin + random->Generate(range_width); + std::swap((*v)[selected], (*v)[last_in_range]); + } +} + +// Performs an in-place shuffle of the vector's elements. +template +inline void Shuffle(internal::Random* random, std::vector* v) { + ShuffleRange(random, 0, static_cast(v->size()), v); +} + +// A function for deleting an object. Handy for being used as a +// functor. +template +static void Delete(T* x) { + delete x; +} + +// A predicate that checks the key of a TestProperty against a known key. +// +// TestPropertyKeyIs is copyable. +class TestPropertyKeyIs { + public: + // Constructor. + // + // TestPropertyKeyIs has NO default constructor. + explicit TestPropertyKeyIs(const std::string& key) : key_(key) {} + + // Returns true iff the test name of test property matches on key_. + bool operator()(const TestProperty& test_property) const { + return test_property.key() == key_; + } + + private: + std::string key_; +}; + +// Class UnitTestOptions. +// +// This class contains functions for processing options the user +// specifies when running the tests. It has only static members. +// +// In most cases, the user can specify an option using either an +// environment variable or a command line flag. E.g. you can set the +// test filter using either GTEST_FILTER or --gtest_filter. If both +// the variable and the flag are present, the latter overrides the +// former. +class GTEST_API_ UnitTestOptions { + public: + // Functions for processing the gtest_output flag. + + // Returns the output format, or "" for normal printed output. + static std::string GetOutputFormat(); + + // Returns the absolute path of the requested output file, or the + // default (test_detail.xml in the original working directory) if + // none was explicitly specified. + static std::string GetAbsolutePathToOutputFile(); + + // Functions for processing the gtest_filter flag. + + // Returns true iff the wildcard pattern matches the string. The + // first ':' or '\0' character in pattern marks the end of it. + // + // This recursive algorithm isn't very efficient, but is clear and + // works well enough for matching test names, which are short. + static bool PatternMatchesString(const char *pattern, const char *str); + + // Returns true iff the user-specified filter matches the test case + // name and the test name. + static bool FilterMatchesTest(const std::string &test_case_name, + const std::string &test_name); + +#if GTEST_OS_WINDOWS + // Function for supporting the gtest_catch_exception flag. + + // Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the + // given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise. + // This function is useful as an __except condition. + static int GTestShouldProcessSEH(DWORD exception_code); +#endif // GTEST_OS_WINDOWS + + // Returns true if "name" matches the ':' separated list of glob-style + // filters in "filter". + static bool MatchesFilter(const std::string& name, const char* filter); +}; + +// Returns the current application's name, removing directory path if that +// is present. Used by UnitTestOptions::GetOutputFile. +GTEST_API_ FilePath GetCurrentExecutableName(); + +// The role interface for getting the OS stack trace as a string. +class OsStackTraceGetterInterface { + public: + OsStackTraceGetterInterface() {} + virtual ~OsStackTraceGetterInterface() {} + + // Returns the current OS stack trace as an std::string. Parameters: + // + // max_depth - the maximum number of stack frames to be included + // in the trace. + // skip_count - the number of top frames to be skipped; doesn't count + // against max_depth. + virtual string CurrentStackTrace(int max_depth, int skip_count) = 0; + + // UponLeavingGTest() should be called immediately before Google Test calls + // user code. It saves some information about the current stack that + // CurrentStackTrace() will use to find and hide Google Test stack frames. + virtual void UponLeavingGTest() = 0; + + private: + GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetterInterface); +}; + +// A working implementation of the OsStackTraceGetterInterface interface. +class OsStackTraceGetter : public OsStackTraceGetterInterface { + public: + OsStackTraceGetter() : caller_frame_(NULL) {} + + virtual string CurrentStackTrace(int max_depth, int skip_count) + GTEST_LOCK_EXCLUDED_(mutex_); + + virtual void UponLeavingGTest() GTEST_LOCK_EXCLUDED_(mutex_); + + // This string is inserted in place of stack frames that are part of + // Google Test's implementation. + static const char* const kElidedFramesMarker; + + private: + Mutex mutex_; // protects all internal state + + // We save the stack frame below the frame that calls user code. + // We do this because the address of the frame immediately below + // the user code changes between the call to UponLeavingGTest() + // and any calls to CurrentStackTrace() from within the user code. + void* caller_frame_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(OsStackTraceGetter); +}; + +// Information about a Google Test trace point. +struct TraceInfo { + const char* file; + int line; + std::string message; +}; + +// This is the default global test part result reporter used in UnitTestImpl. +// This class should only be used by UnitTestImpl. +class DefaultGlobalTestPartResultReporter + : public TestPartResultReporterInterface { + public: + explicit DefaultGlobalTestPartResultReporter(UnitTestImpl* unit_test); + // Implements the TestPartResultReporterInterface. Reports the test part + // result in the current test. + virtual void ReportTestPartResult(const TestPartResult& result); + + private: + UnitTestImpl* const unit_test_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultGlobalTestPartResultReporter); +}; + +// This is the default per thread test part result reporter used in +// UnitTestImpl. This class should only be used by UnitTestImpl. +class DefaultPerThreadTestPartResultReporter + : public TestPartResultReporterInterface { + public: + explicit DefaultPerThreadTestPartResultReporter(UnitTestImpl* unit_test); + // Implements the TestPartResultReporterInterface. The implementation just + // delegates to the current global test part result reporter of *unit_test_. + virtual void ReportTestPartResult(const TestPartResult& result); + + private: + UnitTestImpl* const unit_test_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(DefaultPerThreadTestPartResultReporter); +}; + +// The private implementation of the UnitTest class. We don't protect +// the methods under a mutex, as this class is not accessible by a +// user and the UnitTest class that delegates work to this class does +// proper locking. +class GTEST_API_ UnitTestImpl { + public: + explicit UnitTestImpl(UnitTest* parent); + virtual ~UnitTestImpl(); + + // There are two different ways to register your own TestPartResultReporter. + // You can register your own repoter to listen either only for test results + // from the current thread or for results from all threads. + // By default, each per-thread test result repoter just passes a new + // TestPartResult to the global test result reporter, which registers the + // test part result for the currently running test. + + // Returns the global test part result reporter. + TestPartResultReporterInterface* GetGlobalTestPartResultReporter(); + + // Sets the global test part result reporter. + void SetGlobalTestPartResultReporter( + TestPartResultReporterInterface* reporter); + + // Returns the test part result reporter for the current thread. + TestPartResultReporterInterface* GetTestPartResultReporterForCurrentThread(); + + // Sets the test part result reporter for the current thread. + void SetTestPartResultReporterForCurrentThread( + TestPartResultReporterInterface* reporter); + + // Gets the number of successful test cases. + int successful_test_case_count() const; + + // Gets the number of failed test cases. + int failed_test_case_count() const; + + // Gets the number of all test cases. + int total_test_case_count() const; + + // Gets the number of all test cases that contain at least one test + // that should run. + int test_case_to_run_count() const; + + // Gets the number of successful tests. + int successful_test_count() const; + + // Gets the number of failed tests. + int failed_test_count() const; + + // Gets the number of disabled tests that will be reported in the XML report. + int reportable_disabled_test_count() const; + + // Gets the number of disabled tests. + int disabled_test_count() const; + + // Gets the number of tests to be printed in the XML report. + int reportable_test_count() const; + + // Gets the number of all tests. + int total_test_count() const; + + // Gets the number of tests that should run. + int test_to_run_count() const; + + // Gets the time of the test program start, in ms from the start of the + // UNIX epoch. + TimeInMillis start_timestamp() const { return start_timestamp_; } + + // Gets the elapsed time, in milliseconds. + TimeInMillis elapsed_time() const { return elapsed_time_; } + + // Returns true iff the unit test passed (i.e. all test cases passed). + bool Passed() const { return !Failed(); } + + // Returns true iff the unit test failed (i.e. some test case failed + // or something outside of all tests failed). + bool Failed() const { + return failed_test_case_count() > 0 || ad_hoc_test_result()->Failed(); + } + + // Gets the i-th test case among all the test cases. i can range from 0 to + // total_test_case_count() - 1. If i is not in that range, returns NULL. + const TestCase* GetTestCase(int i) const { + const int index = GetElementOr(test_case_indices_, i, -1); + return index < 0 ? NULL : test_cases_[i]; + } + + // Gets the i-th test case among all the test cases. i can range from 0 to + // total_test_case_count() - 1. If i is not in that range, returns NULL. + TestCase* GetMutableTestCase(int i) { + const int index = GetElementOr(test_case_indices_, i, -1); + return index < 0 ? NULL : test_cases_[index]; + } + + // Provides access to the event listener list. + TestEventListeners* listeners() { return &listeners_; } + + // Returns the TestResult for the test that's currently running, or + // the TestResult for the ad hoc test if no test is running. + TestResult* current_test_result(); + + // Returns the TestResult for the ad hoc test. + const TestResult* ad_hoc_test_result() const { return &ad_hoc_test_result_; } + + // Sets the OS stack trace getter. + // + // Does nothing if the input and the current OS stack trace getter + // are the same; otherwise, deletes the old getter and makes the + // input the current getter. + void set_os_stack_trace_getter(OsStackTraceGetterInterface* getter); + + // Returns the current OS stack trace getter if it is not NULL; + // otherwise, creates an OsStackTraceGetter, makes it the current + // getter, and returns it. + OsStackTraceGetterInterface* os_stack_trace_getter(); + + // Returns the current OS stack trace as an std::string. + // + // The maximum number of stack frames to be included is specified by + // the gtest_stack_trace_depth flag. The skip_count parameter + // specifies the number of top frames to be skipped, which doesn't + // count against the number of frames to be included. + // + // For example, if Foo() calls Bar(), which in turn calls + // CurrentOsStackTraceExceptTop(1), Foo() will be included in the + // trace but Bar() and CurrentOsStackTraceExceptTop() won't. + std::string CurrentOsStackTraceExceptTop(int skip_count) GTEST_NO_INLINE_; + + // Finds and returns a TestCase with the given name. If one doesn't + // exist, creates one and returns it. + // + // Arguments: + // + // test_case_name: name of the test case + // type_param: the name of the test's type parameter, or NULL if + // this is not a typed or a type-parameterized test. + // set_up_tc: pointer to the function that sets up the test case + // tear_down_tc: pointer to the function that tears down the test case + TestCase* GetTestCase(const char* test_case_name, + const char* type_param, + Test::SetUpTestCaseFunc set_up_tc, + Test::TearDownTestCaseFunc tear_down_tc); + + // Adds a TestInfo to the unit test. + // + // Arguments: + // + // set_up_tc: pointer to the function that sets up the test case + // tear_down_tc: pointer to the function that tears down the test case + // test_info: the TestInfo object + void AddTestInfo(Test::SetUpTestCaseFunc set_up_tc, + Test::TearDownTestCaseFunc tear_down_tc, + TestInfo* test_info) { + // In order to support thread-safe death tests, we need to + // remember the original working directory when the test program + // was first invoked. We cannot do this in RUN_ALL_TESTS(), as + // the user may have changed the current directory before calling + // RUN_ALL_TESTS(). Therefore we capture the current directory in + // AddTestInfo(), which is called to register a TEST or TEST_F + // before main() is reached. + if (original_working_dir_.IsEmpty()) { + original_working_dir_.Set(FilePath::GetCurrentDir()); + GTEST_CHECK_(!original_working_dir_.IsEmpty()) + << "Failed to get the current working directory."; + } + + GetTestCase(test_info->test_case_name(), + test_info->type_param(), + set_up_tc, + tear_down_tc)->AddTestInfo(test_info); + } + +#if GTEST_HAS_PARAM_TEST + // Returns ParameterizedTestCaseRegistry object used to keep track of + // value-parameterized tests and instantiate and register them. + internal::ParameterizedTestCaseRegistry& parameterized_test_registry() { + return parameterized_test_registry_; + } +#endif // GTEST_HAS_PARAM_TEST + + // Sets the TestCase object for the test that's currently running. + void set_current_test_case(TestCase* a_current_test_case) { + current_test_case_ = a_current_test_case; + } + + // Sets the TestInfo object for the test that's currently running. If + // current_test_info is NULL, the assertion results will be stored in + // ad_hoc_test_result_. + void set_current_test_info(TestInfo* a_current_test_info) { + current_test_info_ = a_current_test_info; + } + + // Registers all parameterized tests defined using TEST_P and + // INSTANTIATE_TEST_CASE_P, creating regular tests for each test/parameter + // combination. This method can be called more then once; it has guards + // protecting from registering the tests more then once. If + // value-parameterized tests are disabled, RegisterParameterizedTests is + // present but does nothing. + void RegisterParameterizedTests(); + + // Runs all tests in this UnitTest object, prints the result, and + // returns true if all tests are successful. If any exception is + // thrown during a test, this test is considered to be failed, but + // the rest of the tests will still be run. + bool RunAllTests(); + + // Clears the results of all tests, except the ad hoc tests. + void ClearNonAdHocTestResult() { + ForEach(test_cases_, TestCase::ClearTestCaseResult); + } + + // Clears the results of ad-hoc test assertions. + void ClearAdHocTestResult() { + ad_hoc_test_result_.Clear(); + } + + // Adds a TestProperty to the current TestResult object when invoked in a + // context of a test or a test case, or to the global property set. If the + // result already contains a property with the same key, the value will be + // updated. + void RecordProperty(const TestProperty& test_property); + + enum ReactionToSharding { + HONOR_SHARDING_PROTOCOL, + IGNORE_SHARDING_PROTOCOL + }; + + // Matches the full name of each test against the user-specified + // filter to decide whether the test should run, then records the + // result in each TestCase and TestInfo object. + // If shard_tests == HONOR_SHARDING_PROTOCOL, further filters tests + // based on sharding variables in the environment. + // Returns the number of tests that should run. + int FilterTests(ReactionToSharding shard_tests); + + // Prints the names of the tests matching the user-specified filter flag. + void ListTestsMatchingFilter(); + + const TestCase* current_test_case() const { return current_test_case_; } + TestInfo* current_test_info() { return current_test_info_; } + const TestInfo* current_test_info() const { return current_test_info_; } + + // Returns the vector of environments that need to be set-up/torn-down + // before/after the tests are run. + std::vector& environments() { return environments_; } + + // Getters for the per-thread Google Test trace stack. + std::vector& gtest_trace_stack() { + return *(gtest_trace_stack_.pointer()); + } + const std::vector& gtest_trace_stack() const { + return gtest_trace_stack_.get(); + } + +#if GTEST_HAS_DEATH_TEST + void InitDeathTestSubprocessControlInfo() { + internal_run_death_test_flag_.reset(ParseInternalRunDeathTestFlag()); + } + // Returns a pointer to the parsed --gtest_internal_run_death_test + // flag, or NULL if that flag was not specified. + // This information is useful only in a death test child process. + // Must not be called before a call to InitGoogleTest. + const InternalRunDeathTestFlag* internal_run_death_test_flag() const { + return internal_run_death_test_flag_.get(); + } + + // Returns a pointer to the current death test factory. + internal::DeathTestFactory* death_test_factory() { + return death_test_factory_.get(); + } + + void SuppressTestEventsIfInSubprocess(); + + friend class ReplaceDeathTestFactory; +#endif // GTEST_HAS_DEATH_TEST + + // Initializes the event listener performing XML output as specified by + // UnitTestOptions. Must not be called before InitGoogleTest. + void ConfigureXmlOutput(); + +#if GTEST_CAN_STREAM_RESULTS_ + // Initializes the event listener for streaming test results to a socket. + // Must not be called before InitGoogleTest. + void ConfigureStreamingOutput(); +#endif + + // Performs initialization dependent upon flag values obtained in + // ParseGoogleTestFlagsOnly. Is called from InitGoogleTest after the call to + // ParseGoogleTestFlagsOnly. In case a user neglects to call InitGoogleTest + // this function is also called from RunAllTests. Since this function can be + // called more than once, it has to be idempotent. + void PostFlagParsingInit(); + + // Gets the random seed used at the start of the current test iteration. + int random_seed() const { return random_seed_; } + + // Gets the random number generator. + internal::Random* random() { return &random_; } + + // Shuffles all test cases, and the tests within each test case, + // making sure that death tests are still run first. + void ShuffleTests(); + + // Restores the test cases and tests to their order before the first shuffle. + void UnshuffleTests(); + + // Returns the value of GTEST_FLAG(catch_exceptions) at the moment + // UnitTest::Run() starts. + bool catch_exceptions() const { return catch_exceptions_; } + + private: + friend class ::testing::UnitTest; + + // Used by UnitTest::Run() to capture the state of + // GTEST_FLAG(catch_exceptions) at the moment it starts. + void set_catch_exceptions(bool value) { catch_exceptions_ = value; } + + // The UnitTest object that owns this implementation object. + UnitTest* const parent_; + + // The working directory when the first TEST() or TEST_F() was + // executed. + internal::FilePath original_working_dir_; + + // The default test part result reporters. + DefaultGlobalTestPartResultReporter default_global_test_part_result_reporter_; + DefaultPerThreadTestPartResultReporter + default_per_thread_test_part_result_reporter_; + + // Points to (but doesn't own) the global test part result reporter. + TestPartResultReporterInterface* global_test_part_result_repoter_; + + // Protects read and write access to global_test_part_result_reporter_. + internal::Mutex global_test_part_result_reporter_mutex_; + + // Points to (but doesn't own) the per-thread test part result reporter. + internal::ThreadLocal + per_thread_test_part_result_reporter_; + + // The vector of environments that need to be set-up/torn-down + // before/after the tests are run. + std::vector environments_; + + // The vector of TestCases in their original order. It owns the + // elements in the vector. + std::vector test_cases_; + + // Provides a level of indirection for the test case list to allow + // easy shuffling and restoring the test case order. The i-th + // element of this vector is the index of the i-th test case in the + // shuffled order. + std::vector test_case_indices_; + +#if GTEST_HAS_PARAM_TEST + // ParameterizedTestRegistry object used to register value-parameterized + // tests. + internal::ParameterizedTestCaseRegistry parameterized_test_registry_; + + // Indicates whether RegisterParameterizedTests() has been called already. + bool parameterized_tests_registered_; +#endif // GTEST_HAS_PARAM_TEST + + // Index of the last death test case registered. Initially -1. + int last_death_test_case_; + + // This points to the TestCase for the currently running test. It + // changes as Google Test goes through one test case after another. + // When no test is running, this is set to NULL and Google Test + // stores assertion results in ad_hoc_test_result_. Initially NULL. + TestCase* current_test_case_; + + // This points to the TestInfo for the currently running test. It + // changes as Google Test goes through one test after another. When + // no test is running, this is set to NULL and Google Test stores + // assertion results in ad_hoc_test_result_. Initially NULL. + TestInfo* current_test_info_; + + // Normally, a user only writes assertions inside a TEST or TEST_F, + // or inside a function called by a TEST or TEST_F. Since Google + // Test keeps track of which test is current running, it can + // associate such an assertion with the test it belongs to. + // + // If an assertion is encountered when no TEST or TEST_F is running, + // Google Test attributes the assertion result to an imaginary "ad hoc" + // test, and records the result in ad_hoc_test_result_. + TestResult ad_hoc_test_result_; + + // The list of event listeners that can be used to track events inside + // Google Test. + TestEventListeners listeners_; + + // The OS stack trace getter. Will be deleted when the UnitTest + // object is destructed. By default, an OsStackTraceGetter is used, + // but the user can set this field to use a custom getter if that is + // desired. + OsStackTraceGetterInterface* os_stack_trace_getter_; + + // True iff PostFlagParsingInit() has been called. + bool post_flag_parse_init_performed_; + + // The random number seed used at the beginning of the test run. + int random_seed_; + + // Our random number generator. + internal::Random random_; + + // The time of the test program start, in ms from the start of the + // UNIX epoch. + TimeInMillis start_timestamp_; + + // How long the test took to run, in milliseconds. + TimeInMillis elapsed_time_; + +#if GTEST_HAS_DEATH_TEST + // The decomposed components of the gtest_internal_run_death_test flag, + // parsed when RUN_ALL_TESTS is called. + internal::scoped_ptr internal_run_death_test_flag_; + internal::scoped_ptr death_test_factory_; +#endif // GTEST_HAS_DEATH_TEST + + // A per-thread stack of traces created by the SCOPED_TRACE() macro. + internal::ThreadLocal > gtest_trace_stack_; + + // The value of GTEST_FLAG(catch_exceptions) at the moment RunAllTests() + // starts. + bool catch_exceptions_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(UnitTestImpl); +}; // class UnitTestImpl + +// Convenience function for accessing the global UnitTest +// implementation object. +inline UnitTestImpl* GetUnitTestImpl() { + return UnitTest::GetInstance()->impl(); +} + +#if GTEST_USES_SIMPLE_RE + +// Internal helper functions for implementing the simple regular +// expression matcher. +GTEST_API_ bool IsInSet(char ch, const char* str); +GTEST_API_ bool IsAsciiDigit(char ch); +GTEST_API_ bool IsAsciiPunct(char ch); +GTEST_API_ bool IsRepeat(char ch); +GTEST_API_ bool IsAsciiWhiteSpace(char ch); +GTEST_API_ bool IsAsciiWordChar(char ch); +GTEST_API_ bool IsValidEscape(char ch); +GTEST_API_ bool AtomMatchesChar(bool escaped, char pattern, char ch); +GTEST_API_ bool ValidateRegex(const char* regex); +GTEST_API_ bool MatchRegexAtHead(const char* regex, const char* str); +GTEST_API_ bool MatchRepetitionAndRegexAtHead( + bool escaped, char ch, char repeat, const char* regex, const char* str); +GTEST_API_ bool MatchRegexAnywhere(const char* regex, const char* str); + +#endif // GTEST_USES_SIMPLE_RE + +// Parses the command line for Google Test flags, without initializing +// other parts of Google Test. +GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, char** argv); +GTEST_API_ void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv); + +#if GTEST_HAS_DEATH_TEST + +// Returns the message describing the last system error, regardless of the +// platform. +GTEST_API_ std::string GetLastErrnoDescription(); + +# if GTEST_OS_WINDOWS +// Provides leak-safe Windows kernel handle ownership. +class AutoHandle { + public: + AutoHandle() : handle_(INVALID_HANDLE_VALUE) {} + explicit AutoHandle(HANDLE handle) : handle_(handle) {} + + ~AutoHandle() { Reset(); } + + HANDLE Get() const { return handle_; } + void Reset() { Reset(INVALID_HANDLE_VALUE); } + void Reset(HANDLE handle) { + if (handle != handle_) { + if (handle_ != INVALID_HANDLE_VALUE) + ::CloseHandle(handle_); + handle_ = handle; + } + } + + private: + HANDLE handle_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(AutoHandle); +}; +# endif // GTEST_OS_WINDOWS + +// Attempts to parse a string into a positive integer pointed to by the +// number parameter. Returns true if that is possible. +// GTEST_HAS_DEATH_TEST implies that we have ::std::string, so we can use +// it here. +template +bool ParseNaturalNumber(const ::std::string& str, Integer* number) { + // Fail fast if the given string does not begin with a digit; + // this bypasses strtoXXX's "optional leading whitespace and plus + // or minus sign" semantics, which are undesirable here. + if (str.empty() || !IsDigit(str[0])) { + return false; + } + errno = 0; + + char* end; + // BiggestConvertible is the largest integer type that system-provided + // string-to-number conversion routines can return. + +# if GTEST_OS_WINDOWS && !defined(__GNUC__) + + // MSVC and C++ Builder define __int64 instead of the standard long long. + typedef unsigned __int64 BiggestConvertible; + const BiggestConvertible parsed = _strtoui64(str.c_str(), &end, 10); + +# else + + typedef unsigned long long BiggestConvertible; // NOLINT + const BiggestConvertible parsed = strtoull(str.c_str(), &end, 10); + +# endif // GTEST_OS_WINDOWS && !defined(__GNUC__) + + const bool parse_success = *end == '\0' && errno == 0; + + // TODO(vladl@google.com): Convert this to compile time assertion when it is + // available. + GTEST_CHECK_(sizeof(Integer) <= sizeof(parsed)); + + const Integer result = static_cast(parsed); + if (parse_success && static_cast(result) == parsed) { + *number = result; + return true; + } + return false; +} +#endif // GTEST_HAS_DEATH_TEST + +// TestResult contains some private methods that should be hidden from +// Google Test user but are required for testing. This class allow our tests +// to access them. +// +// This class is supplied only for the purpose of testing Google Test's own +// constructs. Do not use it in user tests, either directly or indirectly. +class TestResultAccessor { + public: + static void RecordProperty(TestResult* test_result, + const std::string& xml_element, + const TestProperty& property) { + test_result->RecordProperty(xml_element, property); + } + + static void ClearTestPartResults(TestResult* test_result) { + test_result->ClearTestPartResults(); + } + + static const std::vector& test_part_results( + const TestResult& test_result) { + return test_result.test_part_results(); + } +}; + +#if GTEST_CAN_STREAM_RESULTS_ + +// Streams test results to the given port on the given host machine. +class StreamingListener : public EmptyTestEventListener { + public: + // Abstract base class for writing strings to a socket. + class AbstractSocketWriter { + public: + virtual ~AbstractSocketWriter() {} + + // Sends a string to the socket. + virtual void Send(const string& message) = 0; + + // Closes the socket. + virtual void CloseConnection() {} + + // Sends a string and a newline to the socket. + void SendLn(const string& message) { + Send(message + "\n"); + } + }; + + // Concrete class for actually writing strings to a socket. + class SocketWriter : public AbstractSocketWriter { + public: + SocketWriter(const string& host, const string& port) + : sockfd_(-1), host_name_(host), port_num_(port) { + MakeConnection(); + } + + virtual ~SocketWriter() { + if (sockfd_ != -1) + CloseConnection(); + } + + // Sends a string to the socket. + virtual void Send(const string& message) { + GTEST_CHECK_(sockfd_ != -1) + << "Send() can be called only when there is a connection."; + + const int len = static_cast(message.length()); + if (write(sockfd_, message.c_str(), len) != len) { + GTEST_LOG_(WARNING) + << "stream_result_to: failed to stream to " + << host_name_ << ":" << port_num_; + } + } + + private: + // Creates a client socket and connects to the server. + void MakeConnection(); + + // Closes the socket. + void CloseConnection() { + GTEST_CHECK_(sockfd_ != -1) + << "CloseConnection() can be called only when there is a connection."; + + close(sockfd_); + sockfd_ = -1; + } + + int sockfd_; // socket file descriptor + const string host_name_; + const string port_num_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(SocketWriter); + }; // class SocketWriter + + // Escapes '=', '&', '%', and '\n' characters in str as "%xx". + static string UrlEncode(const char* str); + + StreamingListener(const string& host, const string& port) + : socket_writer_(new SocketWriter(host, port)) { Start(); } + + explicit StreamingListener(AbstractSocketWriter* socket_writer) + : socket_writer_(socket_writer) { Start(); } + + void OnTestProgramStart(const UnitTest& /* unit_test */) { + SendLn("event=TestProgramStart"); + } + + void OnTestProgramEnd(const UnitTest& unit_test) { + // Note that Google Test current only report elapsed time for each + // test iteration, not for the entire test program. + SendLn("event=TestProgramEnd&passed=" + FormatBool(unit_test.Passed())); + + // Notify the streaming server to stop. + socket_writer_->CloseConnection(); + } + + void OnTestIterationStart(const UnitTest& /* unit_test */, int iteration) { + SendLn("event=TestIterationStart&iteration=" + + StreamableToString(iteration)); + } + + void OnTestIterationEnd(const UnitTest& unit_test, int /* iteration */) { + SendLn("event=TestIterationEnd&passed=" + + FormatBool(unit_test.Passed()) + "&elapsed_time=" + + StreamableToString(unit_test.elapsed_time()) + "ms"); + } + + void OnTestCaseStart(const TestCase& test_case) { + SendLn(std::string("event=TestCaseStart&name=") + test_case.name()); + } + + void OnTestCaseEnd(const TestCase& test_case) { + SendLn("event=TestCaseEnd&passed=" + FormatBool(test_case.Passed()) + + "&elapsed_time=" + StreamableToString(test_case.elapsed_time()) + + "ms"); + } + + void OnTestStart(const TestInfo& test_info) { + SendLn(std::string("event=TestStart&name=") + test_info.name()); + } + + void OnTestEnd(const TestInfo& test_info) { + SendLn("event=TestEnd&passed=" + + FormatBool((test_info.result())->Passed()) + + "&elapsed_time=" + + StreamableToString((test_info.result())->elapsed_time()) + "ms"); + } + + void OnTestPartResult(const TestPartResult& test_part_result) { + const char* file_name = test_part_result.file_name(); + if (file_name == NULL) + file_name = ""; + SendLn("event=TestPartResult&file=" + UrlEncode(file_name) + + "&line=" + StreamableToString(test_part_result.line_number()) + + "&message=" + UrlEncode(test_part_result.message())); + } + + private: + // Sends the given message and a newline to the socket. + void SendLn(const string& message) { socket_writer_->SendLn(message); } + + // Called at the start of streaming to notify the receiver what + // protocol we are using. + void Start() { SendLn("gtest_streaming_protocol_version=1.0"); } + + string FormatBool(bool value) { return value ? "1" : "0"; } + + const scoped_ptr socket_writer_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(StreamingListener); +}; // class StreamingListener + +#endif // GTEST_CAN_STREAM_RESULTS_ + +} // namespace internal +} // namespace testing + +#endif // GTEST_SRC_GTEST_INTERNAL_INL_H_ diff --git a/test/fmw/gtest/src/gtest-port.cc b/test/fmw/gtest/src/gtest-port.cc new file mode 100644 index 00000000000..0c4df5f29a7 --- /dev/null +++ b/test/fmw/gtest/src/gtest-port.cc @@ -0,0 +1,805 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) + +#include "gtest/internal/gtest-port.h" + +#include +#include +#include +#include + +#if GTEST_OS_WINDOWS_MOBILE +# include // For TerminateProcess() +#elif GTEST_OS_WINDOWS +# include +# include +#else +# include +#endif // GTEST_OS_WINDOWS_MOBILE + +#if GTEST_OS_MAC +# include +# include +# include +#endif // GTEST_OS_MAC + +#if GTEST_OS_QNX +# include +# include +#endif // GTEST_OS_QNX + +#include "gtest/gtest-spi.h" +#include "gtest/gtest-message.h" +#include "gtest/internal/gtest-internal.h" +#include "gtest/internal/gtest-string.h" + +// Indicates that this translation unit is part of Google Test's +// implementation. It must come before gtest-internal-inl.h is +// included, or there will be a compiler error. This trick is to +// prevent a user from accidentally including gtest-internal-inl.h in +// his code. +#define GTEST_IMPLEMENTATION_ 1 +#include "src/gtest-internal-inl.h" +#undef GTEST_IMPLEMENTATION_ + +namespace testing { +namespace internal { + +#if defined(_MSC_VER) || defined(__BORLANDC__) +// MSVC and C++Builder do not provide a definition of STDERR_FILENO. +const int kStdOutFileno = 1; +const int kStdErrFileno = 2; +#else +const int kStdOutFileno = STDOUT_FILENO; +const int kStdErrFileno = STDERR_FILENO; +#endif // _MSC_VER + +#if GTEST_OS_MAC + +// Returns the number of threads running in the process, or 0 to indicate that +// we cannot detect it. +size_t GetThreadCount() { + const task_t task = mach_task_self(); + mach_msg_type_number_t thread_count; + thread_act_array_t thread_list; + const kern_return_t status = task_threads(task, &thread_list, &thread_count); + if (status == KERN_SUCCESS) { + // task_threads allocates resources in thread_list and we need to free them + // to avoid leaks. + vm_deallocate(task, + reinterpret_cast(thread_list), + sizeof(thread_t) * thread_count); + return static_cast(thread_count); + } else { + return 0; + } +} + +#elif GTEST_OS_QNX + +// Returns the number of threads running in the process, or 0 to indicate that +// we cannot detect it. +size_t GetThreadCount() { + const int fd = open("/proc/self/as", O_RDONLY); + if (fd < 0) { + return 0; + } + procfs_info process_info; + const int status = + devctl(fd, DCMD_PROC_INFO, &process_info, sizeof(process_info), NULL); + close(fd); + if (status == EOK) { + return static_cast(process_info.num_threads); + } else { + return 0; + } +} + +#else + +size_t GetThreadCount() { + // There's no portable way to detect the number of threads, so we just + // return 0 to indicate that we cannot detect it. + return 0; +} + +#endif // GTEST_OS_MAC + +#if GTEST_USES_POSIX_RE + +// Implements RE. Currently only needed for death tests. + +RE::~RE() { + if (is_valid_) { + // regfree'ing an invalid regex might crash because the content + // of the regex is undefined. Since the regex's are essentially + // the same, one cannot be valid (or invalid) without the other + // being so too. + regfree(&partial_regex_); + regfree(&full_regex_); + } + free(const_cast(pattern_)); +} + +// Returns true iff regular expression re matches the entire str. +bool RE::FullMatch(const char* str, const RE& re) { + if (!re.is_valid_) return false; + + regmatch_t match; + return regexec(&re.full_regex_, str, 1, &match, 0) == 0; +} + +// Returns true iff regular expression re matches a substring of str +// (including str itself). +bool RE::PartialMatch(const char* str, const RE& re) { + if (!re.is_valid_) return false; + + regmatch_t match; + return regexec(&re.partial_regex_, str, 1, &match, 0) == 0; +} + +// Initializes an RE from its string representation. +void RE::Init(const char* regex) { + pattern_ = posix::StrDup(regex); + + // Reserves enough bytes to hold the regular expression used for a + // full match. + const size_t full_regex_len = strlen(regex) + 10; + char* const full_pattern = new char[full_regex_len]; + + snprintf(full_pattern, full_regex_len, "^(%s)$", regex); + is_valid_ = regcomp(&full_regex_, full_pattern, REG_EXTENDED) == 0; + // We want to call regcomp(&partial_regex_, ...) even if the + // previous expression returns false. Otherwise partial_regex_ may + // not be properly initialized can may cause trouble when it's + // freed. + // + // Some implementation of POSIX regex (e.g. on at least some + // versions of Cygwin) doesn't accept the empty string as a valid + // regex. We change it to an equivalent form "()" to be safe. + if (is_valid_) { + const char* const partial_regex = (*regex == '\0') ? "()" : regex; + is_valid_ = regcomp(&partial_regex_, partial_regex, REG_EXTENDED) == 0; + } + EXPECT_TRUE(is_valid_) + << "Regular expression \"" << regex + << "\" is not a valid POSIX Extended regular expression."; + + delete[] full_pattern; +} + +#elif GTEST_USES_SIMPLE_RE + +// Returns true iff ch appears anywhere in str (excluding the +// terminating '\0' character). +bool IsInSet(char ch, const char* str) { + return ch != '\0' && strchr(str, ch) != NULL; +} + +// Returns true iff ch belongs to the given classification. Unlike +// similar functions in , these aren't affected by the +// current locale. +bool IsAsciiDigit(char ch) { return '0' <= ch && ch <= '9'; } +bool IsAsciiPunct(char ch) { + return IsInSet(ch, "^-!\"#$%&'()*+,./:;<=>?@[\\]_`{|}~"); +} +bool IsRepeat(char ch) { return IsInSet(ch, "?*+"); } +bool IsAsciiWhiteSpace(char ch) { return IsInSet(ch, " \f\n\r\t\v"); } +bool IsAsciiWordChar(char ch) { + return ('a' <= ch && ch <= 'z') || ('A' <= ch && ch <= 'Z') || + ('0' <= ch && ch <= '9') || ch == '_'; +} + +// Returns true iff "\\c" is a supported escape sequence. +bool IsValidEscape(char c) { + return (IsAsciiPunct(c) || IsInSet(c, "dDfnrsStvwW")); +} + +// Returns true iff the given atom (specified by escaped and pattern) +// matches ch. The result is undefined if the atom is invalid. +bool AtomMatchesChar(bool escaped, char pattern_char, char ch) { + if (escaped) { // "\\p" where p is pattern_char. + switch (pattern_char) { + case 'd': return IsAsciiDigit(ch); + case 'D': return !IsAsciiDigit(ch); + case 'f': return ch == '\f'; + case 'n': return ch == '\n'; + case 'r': return ch == '\r'; + case 's': return IsAsciiWhiteSpace(ch); + case 'S': return !IsAsciiWhiteSpace(ch); + case 't': return ch == '\t'; + case 'v': return ch == '\v'; + case 'w': return IsAsciiWordChar(ch); + case 'W': return !IsAsciiWordChar(ch); + } + return IsAsciiPunct(pattern_char) && pattern_char == ch; + } + + return (pattern_char == '.' && ch != '\n') || pattern_char == ch; +} + +// Helper function used by ValidateRegex() to format error messages. +std::string FormatRegexSyntaxError(const char* regex, int index) { + return (Message() << "Syntax error at index " << index + << " in simple regular expression \"" << regex << "\": ").GetString(); +} + +// Generates non-fatal failures and returns false if regex is invalid; +// otherwise returns true. +bool ValidateRegex(const char* regex) { + if (regex == NULL) { + // TODO(wan@google.com): fix the source file location in the + // assertion failures to match where the regex is used in user + // code. + ADD_FAILURE() << "NULL is not a valid simple regular expression."; + return false; + } + + bool is_valid = true; + + // True iff ?, *, or + can follow the previous atom. + bool prev_repeatable = false; + for (int i = 0; regex[i]; i++) { + if (regex[i] == '\\') { // An escape sequence + i++; + if (regex[i] == '\0') { + ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1) + << "'\\' cannot appear at the end."; + return false; + } + + if (!IsValidEscape(regex[i])) { + ADD_FAILURE() << FormatRegexSyntaxError(regex, i - 1) + << "invalid escape sequence \"\\" << regex[i] << "\"."; + is_valid = false; + } + prev_repeatable = true; + } else { // Not an escape sequence. + const char ch = regex[i]; + + if (ch == '^' && i > 0) { + ADD_FAILURE() << FormatRegexSyntaxError(regex, i) + << "'^' can only appear at the beginning."; + is_valid = false; + } else if (ch == '$' && regex[i + 1] != '\0') { + ADD_FAILURE() << FormatRegexSyntaxError(regex, i) + << "'$' can only appear at the end."; + is_valid = false; + } else if (IsInSet(ch, "()[]{}|")) { + ADD_FAILURE() << FormatRegexSyntaxError(regex, i) + << "'" << ch << "' is unsupported."; + is_valid = false; + } else if (IsRepeat(ch) && !prev_repeatable) { + ADD_FAILURE() << FormatRegexSyntaxError(regex, i) + << "'" << ch << "' can only follow a repeatable token."; + is_valid = false; + } + + prev_repeatable = !IsInSet(ch, "^$?*+"); + } + } + + return is_valid; +} + +// Matches a repeated regex atom followed by a valid simple regular +// expression. The regex atom is defined as c if escaped is false, +// or \c otherwise. repeat is the repetition meta character (?, *, +// or +). The behavior is undefined if str contains too many +// characters to be indexable by size_t, in which case the test will +// probably time out anyway. We are fine with this limitation as +// std::string has it too. +bool MatchRepetitionAndRegexAtHead( + bool escaped, char c, char repeat, const char* regex, + const char* str) { + const size_t min_count = (repeat == '+') ? 1 : 0; + const size_t max_count = (repeat == '?') ? 1 : + static_cast(-1) - 1; + // We cannot call numeric_limits::max() as it conflicts with the + // max() macro on Windows. + + for (size_t i = 0; i <= max_count; ++i) { + // We know that the atom matches each of the first i characters in str. + if (i >= min_count && MatchRegexAtHead(regex, str + i)) { + // We have enough matches at the head, and the tail matches too. + // Since we only care about *whether* the pattern matches str + // (as opposed to *how* it matches), there is no need to find a + // greedy match. + return true; + } + if (str[i] == '\0' || !AtomMatchesChar(escaped, c, str[i])) + return false; + } + return false; +} + +// Returns true iff regex matches a prefix of str. regex must be a +// valid simple regular expression and not start with "^", or the +// result is undefined. +bool MatchRegexAtHead(const char* regex, const char* str) { + if (*regex == '\0') // An empty regex matches a prefix of anything. + return true; + + // "$" only matches the end of a string. Note that regex being + // valid guarantees that there's nothing after "$" in it. + if (*regex == '$') + return *str == '\0'; + + // Is the first thing in regex an escape sequence? + const bool escaped = *regex == '\\'; + if (escaped) + ++regex; + if (IsRepeat(regex[1])) { + // MatchRepetitionAndRegexAtHead() calls MatchRegexAtHead(), so + // here's an indirect recursion. It terminates as the regex gets + // shorter in each recursion. + return MatchRepetitionAndRegexAtHead( + escaped, regex[0], regex[1], regex + 2, str); + } else { + // regex isn't empty, isn't "$", and doesn't start with a + // repetition. We match the first atom of regex with the first + // character of str and recurse. + return (*str != '\0') && AtomMatchesChar(escaped, *regex, *str) && + MatchRegexAtHead(regex + 1, str + 1); + } +} + +// Returns true iff regex matches any substring of str. regex must be +// a valid simple regular expression, or the result is undefined. +// +// The algorithm is recursive, but the recursion depth doesn't exceed +// the regex length, so we won't need to worry about running out of +// stack space normally. In rare cases the time complexity can be +// exponential with respect to the regex length + the string length, +// but usually it's must faster (often close to linear). +bool MatchRegexAnywhere(const char* regex, const char* str) { + if (regex == NULL || str == NULL) + return false; + + if (*regex == '^') + return MatchRegexAtHead(regex + 1, str); + + // A successful match can be anywhere in str. + do { + if (MatchRegexAtHead(regex, str)) + return true; + } while (*str++ != '\0'); + return false; +} + +// Implements the RE class. + +RE::~RE() { + free(const_cast(pattern_)); + free(const_cast(full_pattern_)); +} + +// Returns true iff regular expression re matches the entire str. +bool RE::FullMatch(const char* str, const RE& re) { + return re.is_valid_ && MatchRegexAnywhere(re.full_pattern_, str); +} + +// Returns true iff regular expression re matches a substring of str +// (including str itself). +bool RE::PartialMatch(const char* str, const RE& re) { + return re.is_valid_ && MatchRegexAnywhere(re.pattern_, str); +} + +// Initializes an RE from its string representation. +void RE::Init(const char* regex) { + pattern_ = full_pattern_ = NULL; + if (regex != NULL) { + pattern_ = posix::StrDup(regex); + } + + is_valid_ = ValidateRegex(regex); + if (!is_valid_) { + // No need to calculate the full pattern when the regex is invalid. + return; + } + + const size_t len = strlen(regex); + // Reserves enough bytes to hold the regular expression used for a + // full match: we need space to prepend a '^', append a '$', and + // terminate the string with '\0'. + char* buffer = static_cast(malloc(len + 3)); + full_pattern_ = buffer; + + if (*regex != '^') + *buffer++ = '^'; // Makes sure full_pattern_ starts with '^'. + + // We don't use snprintf or strncpy, as they trigger a warning when + // compiled with VC++ 8.0. + memcpy(buffer, regex, len); + buffer += len; + + if (len == 0 || regex[len - 1] != '$') + *buffer++ = '$'; // Makes sure full_pattern_ ends with '$'. + + *buffer = '\0'; +} + +#endif // GTEST_USES_POSIX_RE + +const char kUnknownFile[] = "unknown file"; + +// Formats a source file path and a line number as they would appear +// in an error message from the compiler used to compile this code. +GTEST_API_ ::std::string FormatFileLocation(const char* file, int line) { + const std::string file_name(file == NULL ? kUnknownFile : file); + + if (line < 0) { + return file_name + ":"; + } +#ifdef _MSC_VER + return file_name + "(" + StreamableToString(line) + "):"; +#else + return file_name + ":" + StreamableToString(line) + ":"; +#endif // _MSC_VER +} + +// Formats a file location for compiler-independent XML output. +// Although this function is not platform dependent, we put it next to +// FormatFileLocation in order to contrast the two functions. +// Note that FormatCompilerIndependentFileLocation() does NOT append colon +// to the file location it produces, unlike FormatFileLocation(). +GTEST_API_ ::std::string FormatCompilerIndependentFileLocation( + const char* file, int line) { + const std::string file_name(file == NULL ? kUnknownFile : file); + + if (line < 0) + return file_name; + else + return file_name + ":" + StreamableToString(line); +} + + +GTestLog::GTestLog(GTestLogSeverity severity, const char* file, int line) + : severity_(severity) { + const char* const marker = + severity == GTEST_INFO ? "[ INFO ]" : + severity == GTEST_WARNING ? "[WARNING]" : + severity == GTEST_ERROR ? "[ ERROR ]" : "[ FATAL ]"; + GetStream() << ::std::endl << marker << " " + << FormatFileLocation(file, line).c_str() << ": "; +} + +// Flushes the buffers and, if severity is GTEST_FATAL, aborts the program. +GTestLog::~GTestLog() { + GetStream() << ::std::endl; + if (severity_ == GTEST_FATAL) { + fflush(stderr); + posix::Abort(); + } +} +// Disable Microsoft deprecation warnings for POSIX functions called from +// this class (creat, dup, dup2, and close) +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4996) +#endif // _MSC_VER + +#if GTEST_HAS_STREAM_REDIRECTION + +// Object that captures an output stream (stdout/stderr). +class CapturedStream { + public: + // The ctor redirects the stream to a temporary file. + explicit CapturedStream(int fd) : fd_(fd), uncaptured_fd_(dup(fd)) { +# if GTEST_OS_WINDOWS + char temp_dir_path[MAX_PATH + 1] = { '\0' }; // NOLINT + char temp_file_path[MAX_PATH + 1] = { '\0' }; // NOLINT + + ::GetTempPathA(sizeof(temp_dir_path), temp_dir_path); + const UINT success = ::GetTempFileNameA(temp_dir_path, + "gtest_redir", + 0, // Generate unique file name. + temp_file_path); + GTEST_CHECK_(success != 0) + << "Unable to create a temporary file in " << temp_dir_path; + const int captured_fd = creat(temp_file_path, _S_IREAD | _S_IWRITE); + GTEST_CHECK_(captured_fd != -1) << "Unable to open temporary file " + << temp_file_path; + filename_ = temp_file_path; +# else + // There's no guarantee that a test has write access to the current + // directory, so we create the temporary file in the /tmp directory + // instead. We use /tmp on most systems, and /sdcard on Android. + // That's because Android doesn't have /tmp. +# if GTEST_OS_LINUX_ANDROID + // Note: Android applications are expected to call the framework's + // Context.getExternalStorageDirectory() method through JNI to get + // the location of the world-writable SD Card directory. However, + // this requires a Context handle, which cannot be retrieved + // globally from native code. Doing so also precludes running the + // code as part of a regular standalone executable, which doesn't + // run in a Dalvik process (e.g. when running it through 'adb shell'). + // + // The location /sdcard is directly accessible from native code + // and is the only location (unofficially) supported by the Android + // team. It's generally a symlink to the real SD Card mount point + // which can be /mnt/sdcard, /mnt/sdcard0, /system/media/sdcard, or + // other OEM-customized locations. Never rely on these, and always + // use /sdcard. + char name_template[] = "/sdcard/gtest_captured_stream.XXXXXX"; +# else + char name_template[] = "/tmp/captured_stream.XXXXXX"; +# endif // GTEST_OS_LINUX_ANDROID + const int captured_fd = mkstemp(name_template); + filename_ = name_template; +# endif // GTEST_OS_WINDOWS + fflush(NULL); + dup2(captured_fd, fd_); + close(captured_fd); + } + + ~CapturedStream() { + remove(filename_.c_str()); + } + + std::string GetCapturedString() { + if (uncaptured_fd_ != -1) { + // Restores the original stream. + fflush(NULL); + dup2(uncaptured_fd_, fd_); + close(uncaptured_fd_); + uncaptured_fd_ = -1; + } + + FILE* const file = posix::FOpen(filename_.c_str(), "r"); + const std::string content = ReadEntireFile(file); + posix::FClose(file); + return content; + } + + private: + // Reads the entire content of a file as an std::string. + static std::string ReadEntireFile(FILE* file); + + // Returns the size (in bytes) of a file. + static size_t GetFileSize(FILE* file); + + const int fd_; // A stream to capture. + int uncaptured_fd_; + // Name of the temporary file holding the stderr output. + ::std::string filename_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(CapturedStream); +}; + +// Returns the size (in bytes) of a file. +size_t CapturedStream::GetFileSize(FILE* file) { + fseek(file, 0, SEEK_END); + return static_cast(ftell(file)); +} + +// Reads the entire content of a file as a string. +std::string CapturedStream::ReadEntireFile(FILE* file) { + const size_t file_size = GetFileSize(file); + char* const buffer = new char[file_size]; + + size_t bytes_last_read = 0; // # of bytes read in the last fread() + size_t bytes_read = 0; // # of bytes read so far + + fseek(file, 0, SEEK_SET); + + // Keeps reading the file until we cannot read further or the + // pre-determined file size is reached. + do { + bytes_last_read = fread(buffer+bytes_read, 1, file_size-bytes_read, file); + bytes_read += bytes_last_read; + } while (bytes_last_read > 0 && bytes_read < file_size); + + const std::string content(buffer, bytes_read); + delete[] buffer; + + return content; +} + +# ifdef _MSC_VER +# pragma warning(pop) +# endif // _MSC_VER + +static CapturedStream* g_captured_stderr = NULL; +static CapturedStream* g_captured_stdout = NULL; + +// Starts capturing an output stream (stdout/stderr). +void CaptureStream(int fd, const char* stream_name, CapturedStream** stream) { + if (*stream != NULL) { + GTEST_LOG_(FATAL) << "Only one " << stream_name + << " capturer can exist at a time."; + } + *stream = new CapturedStream(fd); +} + +// Stops capturing the output stream and returns the captured string. +std::string GetCapturedStream(CapturedStream** captured_stream) { + const std::string content = (*captured_stream)->GetCapturedString(); + + delete *captured_stream; + *captured_stream = NULL; + + return content; +} + +// Starts capturing stdout. +void CaptureStdout() { + CaptureStream(kStdOutFileno, "stdout", &g_captured_stdout); +} + +// Starts capturing stderr. +void CaptureStderr() { + CaptureStream(kStdErrFileno, "stderr", &g_captured_stderr); +} + +// Stops capturing stdout and returns the captured string. +std::string GetCapturedStdout() { + return GetCapturedStream(&g_captured_stdout); +} + +// Stops capturing stderr and returns the captured string. +std::string GetCapturedStderr() { + return GetCapturedStream(&g_captured_stderr); +} + +#endif // GTEST_HAS_STREAM_REDIRECTION + +#if GTEST_HAS_DEATH_TEST + +// A copy of all command line arguments. Set by InitGoogleTest(). +::std::vector g_argvs; + +static const ::std::vector* g_injected_test_argvs = + NULL; // Owned. + +void SetInjectableArgvs(const ::std::vector* argvs) { + if (g_injected_test_argvs != argvs) + delete g_injected_test_argvs; + g_injected_test_argvs = argvs; +} + +const ::std::vector& GetInjectableArgvs() { + if (g_injected_test_argvs != NULL) { + return *g_injected_test_argvs; + } + return g_argvs; +} +#endif // GTEST_HAS_DEATH_TEST + +#if GTEST_OS_WINDOWS_MOBILE +namespace posix { +void Abort() { + DebugBreak(); + TerminateProcess(GetCurrentProcess(), 1); +} +} // namespace posix +#endif // GTEST_OS_WINDOWS_MOBILE + +// Returns the name of the environment variable corresponding to the +// given flag. For example, FlagToEnvVar("foo") will return +// "GTEST_FOO" in the open-source version. +static std::string FlagToEnvVar(const char* flag) { + const std::string full_flag = + (Message() << GTEST_FLAG_PREFIX_ << flag).GetString(); + + Message env_var; + for (size_t i = 0; i != full_flag.length(); i++) { + env_var << ToUpper(full_flag.c_str()[i]); + } + + return env_var.GetString(); +} + +// Parses 'str' for a 32-bit signed integer. If successful, writes +// the result to *value and returns true; otherwise leaves *value +// unchanged and returns false. +bool ParseInt32(const Message& src_text, const char* str, Int32* value) { + // Parses the environment variable as a decimal integer. + char* end = NULL; + const long long_value = strtol(str, &end, 10); // NOLINT + + // Has strtol() consumed all characters in the string? + if (*end != '\0') { + // No - an invalid character was encountered. + Message msg; + msg << "WARNING: " << src_text + << " is expected to be a 32-bit integer, but actually" + << " has value \"" << str << "\".\n"; + printf("%s", msg.GetString().c_str()); + fflush(stdout); + return false; + } + + // Is the parsed value in the range of an Int32? + const Int32 result = static_cast(long_value); + if (long_value == LONG_MAX || long_value == LONG_MIN || + // The parsed value overflows as a long. (strtol() returns + // LONG_MAX or LONG_MIN when the input overflows.) + result != long_value + // The parsed value overflows as an Int32. + ) { + Message msg; + msg << "WARNING: " << src_text + << " is expected to be a 32-bit integer, but actually" + << " has value " << str << ", which overflows.\n"; + printf("%s", msg.GetString().c_str()); + fflush(stdout); + return false; + } + + *value = result; + return true; +} + +// Reads and returns the Boolean environment variable corresponding to +// the given flag; if it's not set, returns default_value. +// +// The value is considered true iff it's not "0". +bool BoolFromGTestEnv(const char* flag, bool default_value) { + const std::string env_var = FlagToEnvVar(flag); + const char* const string_value = posix::GetEnv(env_var.c_str()); + return string_value == NULL ? + default_value : strcmp(string_value, "0") != 0; +} + +// Reads and returns a 32-bit integer stored in the environment +// variable corresponding to the given flag; if it isn't set or +// doesn't represent a valid 32-bit integer, returns default_value. +Int32 Int32FromGTestEnv(const char* flag, Int32 default_value) { + const std::string env_var = FlagToEnvVar(flag); + const char* const string_value = posix::GetEnv(env_var.c_str()); + if (string_value == NULL) { + // The environment variable is not set. + return default_value; + } + + Int32 result = default_value; + if (!ParseInt32(Message() << "Environment variable " << env_var, + string_value, &result)) { + printf("The default value %s is used.\n", + (Message() << default_value).GetString().c_str()); + fflush(stdout); + return default_value; + } + + return result; +} + +// Reads and returns the string environment variable corresponding to +// the given flag; if it's not set, returns default_value. +const char* StringFromGTestEnv(const char* flag, const char* default_value) { + const std::string env_var = FlagToEnvVar(flag); + const char* const value = posix::GetEnv(env_var.c_str()); + return value == NULL ? default_value : value; +} + +} // namespace internal +} // namespace testing diff --git a/test/fmw/gtest/src/gtest-printers.cc b/test/fmw/gtest/src/gtest-printers.cc new file mode 100644 index 00000000000..75fa4081009 --- /dev/null +++ b/test/fmw/gtest/src/gtest-printers.cc @@ -0,0 +1,363 @@ +// Copyright 2007, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) + +// Google Test - The Google C++ Testing Framework +// +// This file implements a universal value printer that can print a +// value of any type T: +// +// void ::testing::internal::UniversalPrinter::Print(value, ostream_ptr); +// +// It uses the << operator when possible, and prints the bytes in the +// object otherwise. A user can override its behavior for a class +// type Foo by defining either operator<<(::std::ostream&, const Foo&) +// or void PrintTo(const Foo&, ::std::ostream*) in the namespace that +// defines Foo. + +#include "gtest/gtest-printers.h" +#include +#include +#include // NOLINT +#include +#include "gtest/internal/gtest-port.h" + +namespace testing { + +namespace { + +using ::std::ostream; + +// Prints a segment of bytes in the given object. +void PrintByteSegmentInObjectTo(const unsigned char* obj_bytes, size_t start, + size_t count, ostream* os) { + char text[5] = ""; + for (size_t i = 0; i != count; i++) { + const size_t j = start + i; + if (i != 0) { + // Organizes the bytes into groups of 2 for easy parsing by + // human. + if ((j % 2) == 0) + *os << ' '; + else + *os << '-'; + } + GTEST_SNPRINTF_(text, sizeof(text), "%02X", obj_bytes[j]); + *os << text; + } +} + +// Prints the bytes in the given value to the given ostream. +void PrintBytesInObjectToImpl(const unsigned char* obj_bytes, size_t count, + ostream* os) { + // Tells the user how big the object is. + *os << count << "-byte object <"; + + const size_t kThreshold = 132; + const size_t kChunkSize = 64; + // If the object size is bigger than kThreshold, we'll have to omit + // some details by printing only the first and the last kChunkSize + // bytes. + // TODO(wan): let the user control the threshold using a flag. + if (count < kThreshold) { + PrintByteSegmentInObjectTo(obj_bytes, 0, count, os); + } else { + PrintByteSegmentInObjectTo(obj_bytes, 0, kChunkSize, os); + *os << " ... "; + // Rounds up to 2-byte boundary. + const size_t resume_pos = (count - kChunkSize + 1)/2*2; + PrintByteSegmentInObjectTo(obj_bytes, resume_pos, count - resume_pos, os); + } + *os << ">"; +} + +} // namespace + +namespace internal2 { + +// Delegates to PrintBytesInObjectToImpl() to print the bytes in the +// given object. The delegation simplifies the implementation, which +// uses the << operator and thus is easier done outside of the +// ::testing::internal namespace, which contains a << operator that +// sometimes conflicts with the one in STL. +void PrintBytesInObjectTo(const unsigned char* obj_bytes, size_t count, + ostream* os) { + PrintBytesInObjectToImpl(obj_bytes, count, os); +} + +} // namespace internal2 + +namespace internal { + +// Depending on the value of a char (or wchar_t), we print it in one +// of three formats: +// - as is if it's a printable ASCII (e.g. 'a', '2', ' '), +// - as a hexidecimal escape sequence (e.g. '\x7F'), or +// - as a special escape sequence (e.g. '\r', '\n'). +enum CharFormat { + kAsIs, + kHexEscape, + kSpecialEscape +}; + +// Returns true if c is a printable ASCII character. We test the +// value of c directly instead of calling isprint(), which is buggy on +// Windows Mobile. +inline bool IsPrintableAscii(wchar_t c) { + return 0x20 <= c && c <= 0x7E; +} + +// Prints a wide or narrow char c as a character literal without the +// quotes, escaping it when necessary; returns how c was formatted. +// The template argument UnsignedChar is the unsigned version of Char, +// which is the type of c. +template +static CharFormat PrintAsCharLiteralTo(Char c, ostream* os) { + switch (static_cast(c)) { + case L'\0': + *os << "\\0"; + break; + case L'\'': + *os << "\\'"; + break; + case L'\\': + *os << "\\\\"; + break; + case L'\a': + *os << "\\a"; + break; + case L'\b': + *os << "\\b"; + break; + case L'\f': + *os << "\\f"; + break; + case L'\n': + *os << "\\n"; + break; + case L'\r': + *os << "\\r"; + break; + case L'\t': + *os << "\\t"; + break; + case L'\v': + *os << "\\v"; + break; + default: + if (IsPrintableAscii(c)) { + *os << static_cast(c); + return kAsIs; + } else { + *os << "\\x" + String::FormatHexInt(static_cast(c)); + return kHexEscape; + } + } + return kSpecialEscape; +} + +// Prints a wchar_t c as if it's part of a string literal, escaping it when +// necessary; returns how c was formatted. +static CharFormat PrintAsStringLiteralTo(wchar_t c, ostream* os) { + switch (c) { + case L'\'': + *os << "'"; + return kAsIs; + case L'"': + *os << "\\\""; + return kSpecialEscape; + default: + return PrintAsCharLiteralTo(c, os); + } +} + +// Prints a char c as if it's part of a string literal, escaping it when +// necessary; returns how c was formatted. +static CharFormat PrintAsStringLiteralTo(char c, ostream* os) { + return PrintAsStringLiteralTo( + static_cast(static_cast(c)), os); +} + +// Prints a wide or narrow character c and its code. '\0' is printed +// as "'\\0'", other unprintable characters are also properly escaped +// using the standard C++ escape sequence. The template argument +// UnsignedChar is the unsigned version of Char, which is the type of c. +template +void PrintCharAndCodeTo(Char c, ostream* os) { + // First, print c as a literal in the most readable form we can find. + *os << ((sizeof(c) > 1) ? "L'" : "'"); + const CharFormat format = PrintAsCharLiteralTo(c, os); + *os << "'"; + + // To aid user debugging, we also print c's code in decimal, unless + // it's 0 (in which case c was printed as '\\0', making the code + // obvious). + if (c == 0) + return; + *os << " (" << static_cast(c); + + // For more convenience, we print c's code again in hexidecimal, + // unless c was already printed in the form '\x##' or the code is in + // [1, 9]. + if (format == kHexEscape || (1 <= c && c <= 9)) { + // Do nothing. + } else { + *os << ", 0x" << String::FormatHexInt(static_cast(c)); + } + *os << ")"; +} + +void PrintTo(unsigned char c, ::std::ostream* os) { + PrintCharAndCodeTo(c, os); +} +void PrintTo(signed char c, ::std::ostream* os) { + PrintCharAndCodeTo(c, os); +} + +// Prints a wchar_t as a symbol if it is printable or as its internal +// code otherwise and also as its code. L'\0' is printed as "L'\\0'". +void PrintTo(wchar_t wc, ostream* os) { + PrintCharAndCodeTo(wc, os); +} + +// Prints the given array of characters to the ostream. CharType must be either +// char or wchar_t. +// The array starts at begin, the length is len, it may include '\0' characters +// and may not be NUL-terminated. +template +static void PrintCharsAsStringTo( + const CharType* begin, size_t len, ostream* os) { + const char* const kQuoteBegin = sizeof(CharType) == 1 ? "\"" : "L\""; + *os << kQuoteBegin; + bool is_previous_hex = false; + for (size_t index = 0; index < len; ++index) { + const CharType cur = begin[index]; + if (is_previous_hex && IsXDigit(cur)) { + // Previous character is of '\x..' form and this character can be + // interpreted as another hexadecimal digit in its number. Break string to + // disambiguate. + *os << "\" " << kQuoteBegin; + } + is_previous_hex = PrintAsStringLiteralTo(cur, os) == kHexEscape; + } + *os << "\""; +} + +// Prints a (const) char/wchar_t array of 'len' elements, starting at address +// 'begin'. CharType must be either char or wchar_t. +template +static void UniversalPrintCharArray( + const CharType* begin, size_t len, ostream* os) { + // The code + // const char kFoo[] = "foo"; + // generates an array of 4, not 3, elements, with the last one being '\0'. + // + // Therefore when printing a char array, we don't print the last element if + // it's '\0', such that the output matches the string literal as it's + // written in the source code. + if (len > 0 && begin[len - 1] == '\0') { + PrintCharsAsStringTo(begin, len - 1, os); + return; + } + + // If, however, the last element in the array is not '\0', e.g. + // const char kFoo[] = { 'f', 'o', 'o' }; + // we must print the entire array. We also print a message to indicate + // that the array is not NUL-terminated. + PrintCharsAsStringTo(begin, len, os); + *os << " (no terminating NUL)"; +} + +// Prints a (const) char array of 'len' elements, starting at address 'begin'. +void UniversalPrintArray(const char* begin, size_t len, ostream* os) { + UniversalPrintCharArray(begin, len, os); +} + +// Prints a (const) wchar_t array of 'len' elements, starting at address +// 'begin'. +void UniversalPrintArray(const wchar_t* begin, size_t len, ostream* os) { + UniversalPrintCharArray(begin, len, os); +} + +// Prints the given C string to the ostream. +void PrintTo(const char* s, ostream* os) { + if (s == NULL) { + *os << "NULL"; + } else { + *os << ImplicitCast_(s) << " pointing to "; + PrintCharsAsStringTo(s, strlen(s), os); + } +} + +// MSVC compiler can be configured to define whar_t as a typedef +// of unsigned short. Defining an overload for const wchar_t* in that case +// would cause pointers to unsigned shorts be printed as wide strings, +// possibly accessing more memory than intended and causing invalid +// memory accesses. MSVC defines _NATIVE_WCHAR_T_DEFINED symbol when +// wchar_t is implemented as a native type. +#if !defined(_MSC_VER) || defined(_NATIVE_WCHAR_T_DEFINED) +// Prints the given wide C string to the ostream. +void PrintTo(const wchar_t* s, ostream* os) { + if (s == NULL) { + *os << "NULL"; + } else { + *os << ImplicitCast_(s) << " pointing to "; + PrintCharsAsStringTo(s, wcslen(s), os); + } +} +#endif // wchar_t is native + +// Prints a ::string object. +#if GTEST_HAS_GLOBAL_STRING +void PrintStringTo(const ::string& s, ostream* os) { + PrintCharsAsStringTo(s.data(), s.size(), os); +} +#endif // GTEST_HAS_GLOBAL_STRING + +void PrintStringTo(const ::std::string& s, ostream* os) { + PrintCharsAsStringTo(s.data(), s.size(), os); +} + +// Prints a ::wstring object. +#if GTEST_HAS_GLOBAL_WSTRING +void PrintWideStringTo(const ::wstring& s, ostream* os) { + PrintCharsAsStringTo(s.data(), s.size(), os); +} +#endif // GTEST_HAS_GLOBAL_WSTRING + +#if GTEST_HAS_STD_WSTRING +void PrintWideStringTo(const ::std::wstring& s, ostream* os) { + PrintCharsAsStringTo(s.data(), s.size(), os); +} +#endif // GTEST_HAS_STD_WSTRING + +} // namespace internal + +} // namespace testing diff --git a/test/fmw/gtest/src/gtest-test-part.cc b/test/fmw/gtest/src/gtest-test-part.cc new file mode 100644 index 00000000000..c60eef3ab35 --- /dev/null +++ b/test/fmw/gtest/src/gtest-test-part.cc @@ -0,0 +1,110 @@ +// Copyright 2008, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: mheule@google.com (Markus Heule) +// +// The Google C++ Testing Framework (Google Test) + +#include "gtest/gtest-test-part.h" + +// Indicates that this translation unit is part of Google Test's +// implementation. It must come before gtest-internal-inl.h is +// included, or there will be a compiler error. This trick is to +// prevent a user from accidentally including gtest-internal-inl.h in +// his code. +#define GTEST_IMPLEMENTATION_ 1 +#include "src/gtest-internal-inl.h" +#undef GTEST_IMPLEMENTATION_ + +namespace testing { + +using internal::GetUnitTestImpl; + +// Gets the summary of the failure message by omitting the stack trace +// in it. +std::string TestPartResult::ExtractSummary(const char* message) { + const char* const stack_trace = strstr(message, internal::kStackTraceMarker); + return stack_trace == NULL ? message : + std::string(message, stack_trace); +} + +// Prints a TestPartResult object. +std::ostream& operator<<(std::ostream& os, const TestPartResult& result) { + return os + << result.file_name() << ":" << result.line_number() << ": " + << (result.type() == TestPartResult::kSuccess ? "Success" : + result.type() == TestPartResult::kFatalFailure ? "Fatal failure" : + "Non-fatal failure") << ":\n" + << result.message() << std::endl; +} + +// Appends a TestPartResult to the array. +void TestPartResultArray::Append(const TestPartResult& result) { + array_.push_back(result); +} + +// Returns the TestPartResult at the given index (0-based). +const TestPartResult& TestPartResultArray::GetTestPartResult(int index) const { + if (index < 0 || index >= size()) { + printf("\nInvalid index (%d) into TestPartResultArray.\n", index); + internal::posix::Abort(); + } + + return array_[index]; +} + +// Returns the number of TestPartResult objects in the array. +int TestPartResultArray::size() const { + return static_cast(array_.size()); +} + +namespace internal { + +HasNewFatalFailureHelper::HasNewFatalFailureHelper() + : has_new_fatal_failure_(false), + original_reporter_(GetUnitTestImpl()-> + GetTestPartResultReporterForCurrentThread()) { + GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread(this); +} + +HasNewFatalFailureHelper::~HasNewFatalFailureHelper() { + GetUnitTestImpl()->SetTestPartResultReporterForCurrentThread( + original_reporter_); +} + +void HasNewFatalFailureHelper::ReportTestPartResult( + const TestPartResult& result) { + if (result.fatally_failed()) + has_new_fatal_failure_ = true; + original_reporter_->ReportTestPartResult(result); +} + +} // namespace internal + +} // namespace testing diff --git a/test/fmw/gtest/src/gtest-typed-test.cc b/test/fmw/gtest/src/gtest-typed-test.cc new file mode 100644 index 00000000000..f0079f407c5 --- /dev/null +++ b/test/fmw/gtest/src/gtest-typed-test.cc @@ -0,0 +1,110 @@ +// Copyright 2008 Google Inc. +// All Rights Reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) + +#include "gtest/gtest-typed-test.h" +#include "gtest/gtest.h" + +namespace testing { +namespace internal { + +#if GTEST_HAS_TYPED_TEST_P + +// Skips to the first non-space char in str. Returns an empty string if str +// contains only whitespace characters. +static const char* SkipSpaces(const char* str) { + while (IsSpace(*str)) + str++; + return str; +} + +// Verifies that registered_tests match the test names in +// defined_test_names_; returns registered_tests if successful, or +// aborts the program otherwise. +const char* TypedTestCasePState::VerifyRegisteredTestNames( + const char* file, int line, const char* registered_tests) { + typedef ::std::set::const_iterator DefinedTestIter; + registered_ = true; + + // Skip initial whitespace in registered_tests since some + // preprocessors prefix stringizied literals with whitespace. + registered_tests = SkipSpaces(registered_tests); + + Message errors; + ::std::set tests; + for (const char* names = registered_tests; names != NULL; + names = SkipComma(names)) { + const std::string name = GetPrefixUntilComma(names); + if (tests.count(name) != 0) { + errors << "Test " << name << " is listed more than once.\n"; + continue; + } + + bool found = false; + for (DefinedTestIter it = defined_test_names_.begin(); + it != defined_test_names_.end(); + ++it) { + if (name == *it) { + found = true; + break; + } + } + + if (found) { + tests.insert(name); + } else { + errors << "No test named " << name + << " can be found in this test case.\n"; + } + } + + for (DefinedTestIter it = defined_test_names_.begin(); + it != defined_test_names_.end(); + ++it) { + if (tests.count(*it) == 0) { + errors << "You forgot to list test " << *it << ".\n"; + } + } + + const std::string& errors_str = errors.GetString(); + if (errors_str != "") { + fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(), + errors_str.c_str()); + fflush(stderr); + posix::Abort(); + } + + return registered_tests; +} + +#endif // GTEST_HAS_TYPED_TEST_P + +} // namespace internal +} // namespace testing diff --git a/test/fmw/gtest/src/gtest.cc b/test/fmw/gtest/src/gtest.cc new file mode 100644 index 00000000000..6de53dd0198 --- /dev/null +++ b/test/fmw/gtest/src/gtest.cc @@ -0,0 +1,5015 @@ +// Copyright 2005, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Author: wan@google.com (Zhanyong Wan) +// +// The Google C++ Testing Framework (Google Test) + +#include "gtest/gtest.h" +#include "gtest/gtest-spi.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include // NOLINT +#include +#include + +#if GTEST_OS_LINUX + +// TODO(kenton@google.com): Use autoconf to detect availability of +// gettimeofday(). +# define GTEST_HAS_GETTIMEOFDAY_ 1 + +# include // NOLINT +# include // NOLINT +# include // NOLINT +// Declares vsnprintf(). This header is not available on Windows. +# include // NOLINT +# include // NOLINT +# include // NOLINT +# include // NOLINT +# include + +#elif GTEST_OS_SYMBIAN +# define GTEST_HAS_GETTIMEOFDAY_ 1 +# include // NOLINT + +#elif GTEST_OS_ZOS +# define GTEST_HAS_GETTIMEOFDAY_ 1 +# include // NOLINT + +// On z/OS we additionally need strings.h for strcasecmp. +# include // NOLINT + +#elif GTEST_OS_WINDOWS_MOBILE // We are on Windows CE. + +# include // NOLINT + +#elif GTEST_OS_WINDOWS // We are on Windows proper. + +# include // NOLINT +# include // NOLINT +# include // NOLINT +# include // NOLINT + +# if GTEST_OS_WINDOWS_MINGW +// MinGW has gettimeofday() but not _ftime64(). +// TODO(kenton@google.com): Use autoconf to detect availability of +// gettimeofday(). +// TODO(kenton@google.com): There are other ways to get the time on +// Windows, like GetTickCount() or GetSystemTimeAsFileTime(). MinGW +// supports these. consider using them instead. +# define GTEST_HAS_GETTIMEOFDAY_ 1 +# include // NOLINT +# endif // GTEST_OS_WINDOWS_MINGW + +// cpplint thinks that the header is already included, so we want to +// silence it. +# include // NOLINT + +#else + +// Assume other platforms have gettimeofday(). +// TODO(kenton@google.com): Use autoconf to detect availability of +// gettimeofday(). +# define GTEST_HAS_GETTIMEOFDAY_ 1 + +// cpplint thinks that the header is already included, so we want to +// silence it. +# include // NOLINT +# include // NOLINT + +#endif // GTEST_OS_LINUX + +#if GTEST_HAS_EXCEPTIONS +# include +#endif + +#if GTEST_CAN_STREAM_RESULTS_ +# include // NOLINT +# include // NOLINT +#endif + +// Indicates that this translation unit is part of Google Test's +// implementation. It must come before gtest-internal-inl.h is +// included, or there will be a compiler error. This trick is to +// prevent a user from accidentally including gtest-internal-inl.h in +// his code. +#define GTEST_IMPLEMENTATION_ 1 +#include "src/gtest-internal-inl.h" +#undef GTEST_IMPLEMENTATION_ + +#if GTEST_OS_WINDOWS +# define vsnprintf _vsnprintf +#endif // GTEST_OS_WINDOWS + +namespace testing { + +using internal::CountIf; +using internal::ForEach; +using internal::GetElementOr; +using internal::Shuffle; + +// Constants. + +// A test whose test case name or test name matches this filter is +// disabled and not run. +static const char kDisableTestFilter[] = "DISABLED_*:*/DISABLED_*"; + +// A test case whose name matches this filter is considered a death +// test case and will be run before test cases whose name doesn't +// match this filter. +static const char kDeathTestCaseFilter[] = "*DeathTest:*DeathTest/*"; + +// A test filter that matches everything. +static const char kUniversalFilter[] = "*"; + +// The default output file for XML output. +static const char kDefaultOutputFile[] = "test_detail.xml"; + +// The environment variable name for the test shard index. +static const char kTestShardIndex[] = "GTEST_SHARD_INDEX"; +// The environment variable name for the total number of test shards. +static const char kTestTotalShards[] = "GTEST_TOTAL_SHARDS"; +// The environment variable name for the test shard status file. +static const char kTestShardStatusFile[] = "GTEST_SHARD_STATUS_FILE"; + +namespace internal { + +// The text used in failure messages to indicate the start of the +// stack trace. +const char kStackTraceMarker[] = "\nStack trace:\n"; + +// g_help_flag is true iff the --help flag or an equivalent form is +// specified on the command line. +bool g_help_flag = false; + +} // namespace internal + +static const char* GetDefaultFilter() { + return kUniversalFilter; +} + +GTEST_DEFINE_bool_( + also_run_disabled_tests, + internal::BoolFromGTestEnv("also_run_disabled_tests", false), + "Run disabled tests too, in addition to the tests normally being run."); + +GTEST_DEFINE_bool_( + break_on_failure, + internal::BoolFromGTestEnv("break_on_failure", false), + "True iff a failed assertion should be a debugger break-point."); + +GTEST_DEFINE_bool_( + catch_exceptions, + internal::BoolFromGTestEnv("catch_exceptions", true), + "True iff " GTEST_NAME_ + " should catch exceptions and treat them as test failures."); + +GTEST_DEFINE_string_( + color, + internal::StringFromGTestEnv("color", "auto"), + "Whether to use colors in the output. Valid values: yes, no, " + "and auto. 'auto' means to use colors if the output is " + "being sent to a terminal and the TERM environment variable " + "is set to a terminal type that supports colors."); + +GTEST_DEFINE_string_( + filter, + internal::StringFromGTestEnv("filter", GetDefaultFilter()), + "A colon-separated list of glob (not regex) patterns " + "for filtering the tests to run, optionally followed by a " + "'-' and a : separated list of negative patterns (tests to " + "exclude). A test is run if it matches one of the positive " + "patterns and does not match any of the negative patterns."); + +GTEST_DEFINE_bool_(list_tests, false, + "List all tests without running them."); + +GTEST_DEFINE_string_( + output, + internal::StringFromGTestEnv("output", ""), + "A format (currently must be \"xml\"), optionally followed " + "by a colon and an output file name or directory. A directory " + "is indicated by a trailing pathname separator. " + "Examples: \"xml:filename.xml\", \"xml::directoryname/\". " + "If a directory is specified, output files will be created " + "within that directory, with file-names based on the test " + "executable's name and, if necessary, made unique by adding " + "digits."); + +GTEST_DEFINE_bool_( + print_time, + internal::BoolFromGTestEnv("print_time", true), + "True iff " GTEST_NAME_ + " should display elapsed time in text output."); + +GTEST_DEFINE_int32_( + random_seed, + internal::Int32FromGTestEnv("random_seed", 0), + "Random number seed to use when shuffling test orders. Must be in range " + "[1, 99999], or 0 to use a seed based on the current time."); + +GTEST_DEFINE_int32_( + repeat, + internal::Int32FromGTestEnv("repeat", 1), + "How many times to repeat each test. Specify a negative number " + "for repeating forever. Useful for shaking out flaky tests."); + +GTEST_DEFINE_bool_( + show_internal_stack_frames, false, + "True iff " GTEST_NAME_ " should include internal stack frames when " + "printing test failure stack traces."); + +GTEST_DEFINE_bool_( + shuffle, + internal::BoolFromGTestEnv("shuffle", false), + "True iff " GTEST_NAME_ + " should randomize tests' order on every run."); + +GTEST_DEFINE_int32_( + stack_trace_depth, + internal::Int32FromGTestEnv("stack_trace_depth", kMaxStackTraceDepth), + "The maximum number of stack frames to print when an " + "assertion fails. The valid range is 0 through 100, inclusive."); + +GTEST_DEFINE_string_( + stream_result_to, + internal::StringFromGTestEnv("stream_result_to", ""), + "This flag specifies the host name and the port number on which to stream " + "test results. Example: \"localhost:555\". The flag is effective only on " + "Linux."); + +GTEST_DEFINE_bool_( + throw_on_failure, + internal::BoolFromGTestEnv("throw_on_failure", false), + "When this flag is specified, a failed assertion will throw an exception " + "if exceptions are enabled or exit the program with a non-zero code " + "otherwise."); + +namespace internal { + +// Generates a random number from [0, range), using a Linear +// Congruential Generator (LCG). Crashes if 'range' is 0 or greater +// than kMaxRange. +UInt32 Random::Generate(UInt32 range) { + // These constants are the same as are used in glibc's rand(3). + state_ = (1103515245U*state_ + 12345U) % kMaxRange; + + GTEST_CHECK_(range > 0) + << "Cannot generate a number in the range [0, 0)."; + GTEST_CHECK_(range <= kMaxRange) + << "Generation of a number in [0, " << range << ") was requested, " + << "but this can only generate numbers in [0, " << kMaxRange << ")."; + + // Converting via modulus introduces a bit of downward bias, but + // it's simple, and a linear congruential generator isn't too good + // to begin with. + return state_ % range; +} + +// GTestIsInitialized() returns true iff the user has initialized +// Google Test. Useful for catching the user mistake of not initializing +// Google Test before calling RUN_ALL_TESTS(). +// +// A user must call testing::InitGoogleTest() to initialize Google +// Test. g_init_gtest_count is set to the number of times +// InitGoogleTest() has been called. We don't protect this variable +// under a mutex as it is only accessed in the main thread. +GTEST_API_ int g_init_gtest_count = 0; +static bool GTestIsInitialized() { return g_init_gtest_count != 0; } + +// Iterates over a vector of TestCases, keeping a running sum of the +// results of calling a given int-returning method on each. +// Returns the sum. +static int SumOverTestCaseList(const std::vector& case_list, + int (TestCase::*method)() const) { + int sum = 0; + for (size_t i = 0; i < case_list.size(); i++) { + sum += (case_list[i]->*method)(); + } + return sum; +} + +// Returns true iff the test case passed. +static bool TestCasePassed(const TestCase* test_case) { + return test_case->should_run() && test_case->Passed(); +} + +// Returns true iff the test case failed. +static bool TestCaseFailed(const TestCase* test_case) { + return test_case->should_run() && test_case->Failed(); +} + +// Returns true iff test_case contains at least one test that should +// run. +static bool ShouldRunTestCase(const TestCase* test_case) { + return test_case->should_run(); +} + +// AssertHelper constructor. +AssertHelper::AssertHelper(TestPartResult::Type type, + const char* file, + int line, + const char* message) + : data_(new AssertHelperData(type, file, line, message)) { +} + +AssertHelper::~AssertHelper() { + delete data_; +} + +// Message assignment, for assertion streaming support. +void AssertHelper::operator=(const Message& message) const { + UnitTest::GetInstance()-> + AddTestPartResult(data_->type, data_->file, data_->line, + AppendUserMessage(data_->message, message), + UnitTest::GetInstance()->impl() + ->CurrentOsStackTraceExceptTop(1) + // Skips the stack frame for this function itself. + ); // NOLINT +} + +// Mutex for linked pointers. +GTEST_API_ GTEST_DEFINE_STATIC_MUTEX_(g_linked_ptr_mutex); + +// Application pathname gotten in InitGoogleTest. +std::string g_executable_path; + +// Returns the current application's name, removing directory path if that +// is present. +FilePath GetCurrentExecutableName() { + FilePath result; + +#if GTEST_OS_WINDOWS + result.Set(FilePath(g_executable_path).RemoveExtension("exe")); +#else + result.Set(FilePath(g_executable_path)); +#endif // GTEST_OS_WINDOWS + + return result.RemoveDirectoryName(); +} + +// Functions for processing the gtest_output flag. + +// Returns the output format, or "" for normal printed output. +std::string UnitTestOptions::GetOutputFormat() { + const char* const gtest_output_flag = GTEST_FLAG(output).c_str(); + if (gtest_output_flag == NULL) return std::string(""); + + const char* const colon = strchr(gtest_output_flag, ':'); + return (colon == NULL) ? + std::string(gtest_output_flag) : + std::string(gtest_output_flag, colon - gtest_output_flag); +} + +// Returns the name of the requested output file, or the default if none +// was explicitly specified. +std::string UnitTestOptions::GetAbsolutePathToOutputFile() { + const char* const gtest_output_flag = GTEST_FLAG(output).c_str(); + if (gtest_output_flag == NULL) + return ""; + + const char* const colon = strchr(gtest_output_flag, ':'); + if (colon == NULL) + return internal::FilePath::ConcatPaths( + internal::FilePath( + UnitTest::GetInstance()->original_working_dir()), + internal::FilePath(kDefaultOutputFile)).string(); + + internal::FilePath output_name(colon + 1); + if (!output_name.IsAbsolutePath()) + // TODO(wan@google.com): on Windows \some\path is not an absolute + // path (as its meaning depends on the current drive), yet the + // following logic for turning it into an absolute path is wrong. + // Fix it. + output_name = internal::FilePath::ConcatPaths( + internal::FilePath(UnitTest::GetInstance()->original_working_dir()), + internal::FilePath(colon + 1)); + + if (!output_name.IsDirectory()) + return output_name.string(); + + internal::FilePath result(internal::FilePath::GenerateUniqueFileName( + output_name, internal::GetCurrentExecutableName(), + GetOutputFormat().c_str())); + return result.string(); +} + +// Returns true iff the wildcard pattern matches the string. The +// first ':' or '\0' character in pattern marks the end of it. +// +// This recursive algorithm isn't very efficient, but is clear and +// works well enough for matching test names, which are short. +bool UnitTestOptions::PatternMatchesString(const char *pattern, + const char *str) { + switch (*pattern) { + case '\0': + case ':': // Either ':' or '\0' marks the end of the pattern. + return *str == '\0'; + case '?': // Matches any single character. + return *str != '\0' && PatternMatchesString(pattern + 1, str + 1); + case '*': // Matches any string (possibly empty) of characters. + return (*str != '\0' && PatternMatchesString(pattern, str + 1)) || + PatternMatchesString(pattern + 1, str); + default: // Non-special character. Matches itself. + return *pattern == *str && + PatternMatchesString(pattern + 1, str + 1); + } +} + +bool UnitTestOptions::MatchesFilter( + const std::string& name, const char* filter) { + const char *cur_pattern = filter; + for (;;) { + if (PatternMatchesString(cur_pattern, name.c_str())) { + return true; + } + + // Finds the next pattern in the filter. + cur_pattern = strchr(cur_pattern, ':'); + + // Returns if no more pattern can be found. + if (cur_pattern == NULL) { + return false; + } + + // Skips the pattern separater (the ':' character). + cur_pattern++; + } +} + +// Returns true iff the user-specified filter matches the test case +// name and the test name. +bool UnitTestOptions::FilterMatchesTest(const std::string &test_case_name, + const std::string &test_name) { + const std::string& full_name = test_case_name + "." + test_name.c_str(); + + // Split --gtest_filter at '-', if there is one, to separate into + // positive filter and negative filter portions + const char* const p = GTEST_FLAG(filter).c_str(); + const char* const dash = strchr(p, '-'); + std::string positive; + std::string negative; + if (dash == NULL) { + positive = GTEST_FLAG(filter).c_str(); // Whole string is a positive filter + negative = ""; + } else { + positive = std::string(p, dash); // Everything up to the dash + negative = std::string(dash + 1); // Everything after the dash + if (positive.empty()) { + // Treat '-test1' as the same as '*-test1' + positive = kUniversalFilter; + } + } + + // A filter is a colon-separated list of patterns. It matches a + // test if any pattern in it matches the test. + return (MatchesFilter(full_name, positive.c_str()) && + !MatchesFilter(full_name, negative.c_str())); +} + +#if GTEST_HAS_SEH +// Returns EXCEPTION_EXECUTE_HANDLER if Google Test should handle the +// given SEH exception, or EXCEPTION_CONTINUE_SEARCH otherwise. +// This function is useful as an __except condition. +int UnitTestOptions::GTestShouldProcessSEH(DWORD exception_code) { + // Google Test should handle a SEH exception if: + // 1. the user wants it to, AND + // 2. this is not a breakpoint exception, AND + // 3. this is not a C++ exception (VC++ implements them via SEH, + // apparently). + // + // SEH exception code for C++ exceptions. + // (see http://support.microsoft.com/kb/185294 for more information). + const DWORD kCxxExceptionCode = 0xe06d7363; + + bool should_handle = true; + + if (!GTEST_FLAG(catch_exceptions)) + should_handle = false; + else if (exception_code == EXCEPTION_BREAKPOINT) + should_handle = false; + else if (exception_code == kCxxExceptionCode) + should_handle = false; + + return should_handle ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH; +} +#endif // GTEST_HAS_SEH + +} // namespace internal + +// The c'tor sets this object as the test part result reporter used by +// Google Test. The 'result' parameter specifies where to report the +// results. Intercepts only failures from the current thread. +ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter( + TestPartResultArray* result) + : intercept_mode_(INTERCEPT_ONLY_CURRENT_THREAD), + result_(result) { + Init(); +} + +// The c'tor sets this object as the test part result reporter used by +// Google Test. The 'result' parameter specifies where to report the +// results. +ScopedFakeTestPartResultReporter::ScopedFakeTestPartResultReporter( + InterceptMode intercept_mode, TestPartResultArray* result) + : intercept_mode_(intercept_mode), + result_(result) { + Init(); +} + +void ScopedFakeTestPartResultReporter::Init() { + internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); + if (intercept_mode_ == INTERCEPT_ALL_THREADS) { + old_reporter_ = impl->GetGlobalTestPartResultReporter(); + impl->SetGlobalTestPartResultReporter(this); + } else { + old_reporter_ = impl->GetTestPartResultReporterForCurrentThread(); + impl->SetTestPartResultReporterForCurrentThread(this); + } +} + +// The d'tor restores the test part result reporter used by Google Test +// before. +ScopedFakeTestPartResultReporter::~ScopedFakeTestPartResultReporter() { + internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); + if (intercept_mode_ == INTERCEPT_ALL_THREADS) { + impl->SetGlobalTestPartResultReporter(old_reporter_); + } else { + impl->SetTestPartResultReporterForCurrentThread(old_reporter_); + } +} + +// Increments the test part result count and remembers the result. +// This method is from the TestPartResultReporterInterface interface. +void ScopedFakeTestPartResultReporter::ReportTestPartResult( + const TestPartResult& result) { + result_->Append(result); +} + +namespace internal { + +// Returns the type ID of ::testing::Test. We should always call this +// instead of GetTypeId< ::testing::Test>() to get the type ID of +// testing::Test. This is to work around a suspected linker bug when +// using Google Test as a framework on Mac OS X. The bug causes +// GetTypeId< ::testing::Test>() to return different values depending +// on whether the call is from the Google Test framework itself or +// from user test code. GetTestTypeId() is guaranteed to always +// return the same value, as it always calls GetTypeId<>() from the +// gtest.cc, which is within the Google Test framework. +TypeId GetTestTypeId() { + return GetTypeId(); +} + +// The value of GetTestTypeId() as seen from within the Google Test +// library. This is solely for testing GetTestTypeId(). +extern const TypeId kTestTypeIdInGoogleTest = GetTestTypeId(); + +// This predicate-formatter checks that 'results' contains a test part +// failure of the given type and that the failure message contains the +// given substring. +AssertionResult HasOneFailure(const char* /* results_expr */, + const char* /* type_expr */, + const char* /* substr_expr */, + const TestPartResultArray& results, + TestPartResult::Type type, + const string& substr) { + const std::string expected(type == TestPartResult::kFatalFailure ? + "1 fatal failure" : + "1 non-fatal failure"); + Message msg; + if (results.size() != 1) { + msg << "Expected: " << expected << "\n" + << " Actual: " << results.size() << " failures"; + for (int i = 0; i < results.size(); i++) { + msg << "\n" << results.GetTestPartResult(i); + } + return AssertionFailure() << msg; + } + + const TestPartResult& r = results.GetTestPartResult(0); + if (r.type() != type) { + return AssertionFailure() << "Expected: " << expected << "\n" + << " Actual:\n" + << r; + } + + if (strstr(r.message(), substr.c_str()) == NULL) { + return AssertionFailure() << "Expected: " << expected << " containing \"" + << substr << "\"\n" + << " Actual:\n" + << r; + } + + return AssertionSuccess(); +} + +// The constructor of SingleFailureChecker remembers where to look up +// test part results, what type of failure we expect, and what +// substring the failure message should contain. +SingleFailureChecker:: SingleFailureChecker( + const TestPartResultArray* results, + TestPartResult::Type type, + const string& substr) + : results_(results), + type_(type), + substr_(substr) {} + +// The destructor of SingleFailureChecker verifies that the given +// TestPartResultArray contains exactly one failure that has the given +// type and contains the given substring. If that's not the case, a +// non-fatal failure will be generated. +SingleFailureChecker::~SingleFailureChecker() { + EXPECT_PRED_FORMAT3(HasOneFailure, *results_, type_, substr_); +} + +DefaultGlobalTestPartResultReporter::DefaultGlobalTestPartResultReporter( + UnitTestImpl* unit_test) : unit_test_(unit_test) {} + +void DefaultGlobalTestPartResultReporter::ReportTestPartResult( + const TestPartResult& result) { + unit_test_->current_test_result()->AddTestPartResult(result); + unit_test_->listeners()->repeater()->OnTestPartResult(result); +} + +DefaultPerThreadTestPartResultReporter::DefaultPerThreadTestPartResultReporter( + UnitTestImpl* unit_test) : unit_test_(unit_test) {} + +void DefaultPerThreadTestPartResultReporter::ReportTestPartResult( + const TestPartResult& result) { + unit_test_->GetGlobalTestPartResultReporter()->ReportTestPartResult(result); +} + +// Returns the global test part result reporter. +TestPartResultReporterInterface* +UnitTestImpl::GetGlobalTestPartResultReporter() { + internal::MutexLock lock(&global_test_part_result_reporter_mutex_); + return global_test_part_result_repoter_; +} + +// Sets the global test part result reporter. +void UnitTestImpl::SetGlobalTestPartResultReporter( + TestPartResultReporterInterface* reporter) { + internal::MutexLock lock(&global_test_part_result_reporter_mutex_); + global_test_part_result_repoter_ = reporter; +} + +// Returns the test part result reporter for the current thread. +TestPartResultReporterInterface* +UnitTestImpl::GetTestPartResultReporterForCurrentThread() { + return per_thread_test_part_result_reporter_.get(); +} + +// Sets the test part result reporter for the current thread. +void UnitTestImpl::SetTestPartResultReporterForCurrentThread( + TestPartResultReporterInterface* reporter) { + per_thread_test_part_result_reporter_.set(reporter); +} + +// Gets the number of successful test cases. +int UnitTestImpl::successful_test_case_count() const { + return CountIf(test_cases_, TestCasePassed); +} + +// Gets the number of failed test cases. +int UnitTestImpl::failed_test_case_count() const { + return CountIf(test_cases_, TestCaseFailed); +} + +// Gets the number of all test cases. +int UnitTestImpl::total_test_case_count() const { + return static_cast(test_cases_.size()); +} + +// Gets the number of all test cases that contain at least one test +// that should run. +int UnitTestImpl::test_case_to_run_count() const { + return CountIf(test_cases_, ShouldRunTestCase); +} + +// Gets the number of successful tests. +int UnitTestImpl::successful_test_count() const { + return SumOverTestCaseList(test_cases_, &TestCase::successful_test_count); +} + +// Gets the number of failed tests. +int UnitTestImpl::failed_test_count() const { + return SumOverTestCaseList(test_cases_, &TestCase::failed_test_count); +} + +// Gets the number of disabled tests that will be reported in the XML report. +int UnitTestImpl::reportable_disabled_test_count() const { + return SumOverTestCaseList(test_cases_, + &TestCase::reportable_disabled_test_count); +} + +// Gets the number of disabled tests. +int UnitTestImpl::disabled_test_count() const { + return SumOverTestCaseList(test_cases_, &TestCase::disabled_test_count); +} + +// Gets the number of tests to be printed in the XML report. +int UnitTestImpl::reportable_test_count() const { + return SumOverTestCaseList(test_cases_, &TestCase::reportable_test_count); +} + +// Gets the number of all tests. +int UnitTestImpl::total_test_count() const { + return SumOverTestCaseList(test_cases_, &TestCase::total_test_count); +} + +// Gets the number of tests that should run. +int UnitTestImpl::test_to_run_count() const { + return SumOverTestCaseList(test_cases_, &TestCase::test_to_run_count); +} + +// Returns the current OS stack trace as an std::string. +// +// The maximum number of stack frames to be included is specified by +// the gtest_stack_trace_depth flag. The skip_count parameter +// specifies the number of top frames to be skipped, which doesn't +// count against the number of frames to be included. +// +// For example, if Foo() calls Bar(), which in turn calls +// CurrentOsStackTraceExceptTop(1), Foo() will be included in the +// trace but Bar() and CurrentOsStackTraceExceptTop() won't. +std::string UnitTestImpl::CurrentOsStackTraceExceptTop(int skip_count) { + (void)skip_count; + return ""; +} + +// Returns the current time in milliseconds. +TimeInMillis GetTimeInMillis() { +#if GTEST_OS_WINDOWS_MOBILE || defined(__BORLANDC__) + // Difference between 1970-01-01 and 1601-01-01 in milliseconds. + // http://analogous.blogspot.com/2005/04/epoch.html + const TimeInMillis kJavaEpochToWinFileTimeDelta = + static_cast(116444736UL) * 100000UL; + const DWORD kTenthMicrosInMilliSecond = 10000; + + SYSTEMTIME now_systime; + FILETIME now_filetime; + ULARGE_INTEGER now_int64; + // TODO(kenton@google.com): Shouldn't this just use + // GetSystemTimeAsFileTime()? + GetSystemTime(&now_systime); + if (SystemTimeToFileTime(&now_systime, &now_filetime)) { + now_int64.LowPart = now_filetime.dwLowDateTime; + now_int64.HighPart = now_filetime.dwHighDateTime; + now_int64.QuadPart = (now_int64.QuadPart / kTenthMicrosInMilliSecond) - + kJavaEpochToWinFileTimeDelta; + return now_int64.QuadPart; + } + return 0; +#elif GTEST_OS_WINDOWS && !GTEST_HAS_GETTIMEOFDAY_ + __timeb64 now; + +# ifdef _MSC_VER + + // MSVC 8 deprecates _ftime64(), so we want to suppress warning 4996 + // (deprecated function) there. + // TODO(kenton@google.com): Use GetTickCount()? Or use + // SystemTimeToFileTime() +# pragma warning(push) // Saves the current warning state. +# pragma warning(disable:4996) // Temporarily disables warning 4996. + _ftime64(&now); +# pragma warning(pop) // Restores the warning state. +# else + + _ftime64(&now); + +# endif // _MSC_VER + + return static_cast(now.time) * 1000 + now.millitm; +#elif GTEST_HAS_GETTIMEOFDAY_ + struct timeval now; + gettimeofday(&now, NULL); + return static_cast(now.tv_sec) * 1000 + now.tv_usec / 1000; +#else +# error "Don't know how to get the current time on your system." +#endif +} + +// Utilities + +// class String. + +#if GTEST_OS_WINDOWS_MOBILE +// Creates a UTF-16 wide string from the given ANSI string, allocating +// memory using new. The caller is responsible for deleting the return +// value using delete[]. Returns the wide string, or NULL if the +// input is NULL. +LPCWSTR String::AnsiToUtf16(const char* ansi) { + if (!ansi) return NULL; + const int length = strlen(ansi); + const int unicode_length = + MultiByteToWideChar(CP_ACP, 0, ansi, length, + NULL, 0); + WCHAR* unicode = new WCHAR[unicode_length + 1]; + MultiByteToWideChar(CP_ACP, 0, ansi, length, + unicode, unicode_length); + unicode[unicode_length] = 0; + return unicode; +} + +// Creates an ANSI string from the given wide string, allocating +// memory using new. The caller is responsible for deleting the return +// value using delete[]. Returns the ANSI string, or NULL if the +// input is NULL. +const char* String::Utf16ToAnsi(LPCWSTR utf16_str) { + if (!utf16_str) return NULL; + const int ansi_length = + WideCharToMultiByte(CP_ACP, 0, utf16_str, -1, + NULL, 0, NULL, NULL); + char* ansi = new char[ansi_length + 1]; + WideCharToMultiByte(CP_ACP, 0, utf16_str, -1, + ansi, ansi_length, NULL, NULL); + ansi[ansi_length] = 0; + return ansi; +} + +#endif // GTEST_OS_WINDOWS_MOBILE + +// Compares two C strings. Returns true iff they have the same content. +// +// Unlike strcmp(), this function can handle NULL argument(s). A NULL +// C string is considered different to any non-NULL C string, +// including the empty string. +bool String::CStringEquals(const char * lhs, const char * rhs) { + if ( lhs == NULL ) return rhs == NULL; + + if ( rhs == NULL ) return false; + + return strcmp(lhs, rhs) == 0; +} + +#if GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING + +// Converts an array of wide chars to a narrow string using the UTF-8 +// encoding, and streams the result to the given Message object. +static void StreamWideCharsToMessage(const wchar_t* wstr, size_t length, + Message* msg) { + for (size_t i = 0; i != length; ) { // NOLINT + if (wstr[i] != L'\0') { + *msg << WideStringToUtf8(wstr + i, static_cast(length - i)); + while (i != length && wstr[i] != L'\0') + i++; + } else { + *msg << '\0'; + i++; + } + } +} + +#endif // GTEST_HAS_STD_WSTRING || GTEST_HAS_GLOBAL_WSTRING + +} // namespace internal + +// Constructs an empty Message. +// We allocate the stringstream separately because otherwise each use of +// ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's +// stack frame leading to huge stack frames in some cases; gcc does not reuse +// the stack space. +Message::Message() : ss_(new ::std::stringstream) { + // By default, we want there to be enough precision when printing + // a double to a Message. + *ss_ << std::setprecision(std::numeric_limits::digits10 + 2); +} + +// These two overloads allow streaming a wide C string to a Message +// using the UTF-8 encoding. +Message& Message::operator <<(const wchar_t* wide_c_str) { + return *this << internal::String::ShowWideCString(wide_c_str); +} +Message& Message::operator <<(wchar_t* wide_c_str) { + return *this << internal::String::ShowWideCString(wide_c_str); +} + +#if GTEST_HAS_STD_WSTRING +// Converts the given wide string to a narrow string using the UTF-8 +// encoding, and streams the result to this Message object. +Message& Message::operator <<(const ::std::wstring& wstr) { + internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this); + return *this; +} +#endif // GTEST_HAS_STD_WSTRING + +#if GTEST_HAS_GLOBAL_WSTRING +// Converts the given wide string to a narrow string using the UTF-8 +// encoding, and streams the result to this Message object. +Message& Message::operator <<(const ::wstring& wstr) { + internal::StreamWideCharsToMessage(wstr.c_str(), wstr.length(), this); + return *this; +} +#endif // GTEST_HAS_GLOBAL_WSTRING + +// Gets the text streamed to this object so far as an std::string. +// Each '\0' character in the buffer is replaced with "\\0". +std::string Message::GetString() const { + return internal::StringStreamToString(ss_.get()); +} + +// AssertionResult constructors. +// Used in EXPECT_TRUE/FALSE(assertion_result). +AssertionResult::AssertionResult(const AssertionResult& other) + : success_(other.success_), + message_(other.message_.get() != NULL ? + new ::std::string(*other.message_) : + static_cast< ::std::string*>(NULL)) { +} + +// Returns the assertion's negation. Used with EXPECT/ASSERT_FALSE. +AssertionResult AssertionResult::operator!() const { + AssertionResult negation(!success_); + if (message_.get() != NULL) + negation << *message_; + return negation; +} + +// Makes a successful assertion result. +AssertionResult AssertionSuccess() { + return AssertionResult(true); +} + +// Makes a failed assertion result. +AssertionResult AssertionFailure() { + return AssertionResult(false); +} + +// Makes a failed assertion result with the given failure message. +// Deprecated; use AssertionFailure() << message. +AssertionResult AssertionFailure(const Message& message) { + return AssertionFailure() << message; +} + +namespace internal { + +// Constructs and returns the message for an equality assertion +// (e.g. ASSERT_EQ, EXPECT_STREQ, etc) failure. +// +// The first four parameters are the expressions used in the assertion +// and their values, as strings. For example, for ASSERT_EQ(foo, bar) +// where foo is 5 and bar is 6, we have: +// +// expected_expression: "foo" +// actual_expression: "bar" +// expected_value: "5" +// actual_value: "6" +// +// The ignoring_case parameter is true iff the assertion is a +// *_STRCASEEQ*. When it's true, the string " (ignoring case)" will +// be inserted into the message. +AssertionResult EqFailure(const char* expected_expression, + const char* actual_expression, + const std::string& expected_value, + const std::string& actual_value, + bool ignoring_case) { + Message msg; + msg << "Value of: " << actual_expression; + if (actual_value != actual_expression) { + msg << "\n Actual: " << actual_value; + } + + msg << "\nExpected: " << expected_expression; + if (ignoring_case) { + msg << " (ignoring case)"; + } + if (expected_value != expected_expression) { + msg << "\nWhich is: " << expected_value; + } + + return AssertionFailure() << msg; +} + +// Constructs a failure message for Boolean assertions such as EXPECT_TRUE. +std::string GetBoolAssertionFailureMessage( + const AssertionResult& assertion_result, + const char* expression_text, + const char* actual_predicate_value, + const char* expected_predicate_value) { + const char* actual_message = assertion_result.message(); + Message msg; + msg << "Value of: " << expression_text + << "\n Actual: " << actual_predicate_value; + if (actual_message[0] != '\0') + msg << " (" << actual_message << ")"; + msg << "\nExpected: " << expected_predicate_value; + return msg.GetString(); +} + +// Helper function for implementing ASSERT_NEAR. +AssertionResult DoubleNearPredFormat(const char* expr1, + const char* expr2, + const char* abs_error_expr, + double val1, + double val2, + double abs_error) { + const double diff = fabs(val1 - val2); + if (diff <= abs_error) return AssertionSuccess(); + + // TODO(wan): do not print the value of an expression if it's + // already a literal. + return AssertionFailure() + << "The difference between " << expr1 << " and " << expr2 + << " is " << diff << ", which exceeds " << abs_error_expr << ", where\n" + << expr1 << " evaluates to " << val1 << ",\n" + << expr2 << " evaluates to " << val2 << ", and\n" + << abs_error_expr << " evaluates to " << abs_error << "."; +} + + +// Helper template for implementing FloatLE() and DoubleLE(). +template +AssertionResult FloatingPointLE(const char* expr1, + const char* expr2, + RawType val1, + RawType val2) { + // Returns success if val1 is less than val2, + if (val1 < val2) { + return AssertionSuccess(); + } + + // or if val1 is almost equal to val2. + const FloatingPoint lhs(val1), rhs(val2); + if (lhs.AlmostEquals(rhs)) { + return AssertionSuccess(); + } + + // Note that the above two checks will both fail if either val1 or + // val2 is NaN, as the IEEE floating-point standard requires that + // any predicate involving a NaN must return false. + + ::std::stringstream val1_ss; + val1_ss << std::setprecision(std::numeric_limits::digits10 + 2) + << val1; + + ::std::stringstream val2_ss; + val2_ss << std::setprecision(std::numeric_limits::digits10 + 2) + << val2; + + return AssertionFailure() + << "Expected: (" << expr1 << ") <= (" << expr2 << ")\n" + << " Actual: " << StringStreamToString(&val1_ss) << " vs " + << StringStreamToString(&val2_ss); +} + +} // namespace internal + +// Asserts that val1 is less than, or almost equal to, val2. Fails +// otherwise. In particular, it fails if either val1 or val2 is NaN. +AssertionResult FloatLE(const char* expr1, const char* expr2, + float val1, float val2) { + return internal::FloatingPointLE(expr1, expr2, val1, val2); +} + +// Asserts that val1 is less than, or almost equal to, val2. Fails +// otherwise. In particular, it fails if either val1 or val2 is NaN. +AssertionResult DoubleLE(const char* expr1, const char* expr2, + double val1, double val2) { + return internal::FloatingPointLE(expr1, expr2, val1, val2); +} + +namespace internal { + +// The helper function for {ASSERT|EXPECT}_EQ with int or enum +// arguments. +AssertionResult CmpHelperEQ(const char* expected_expression, + const char* actual_expression, + BiggestInt expected, + BiggestInt actual) { + if (expected == actual) { + return AssertionSuccess(); + } + + return EqFailure(expected_expression, + actual_expression, + FormatForComparisonFailureMessage(expected, actual), + FormatForComparisonFailureMessage(actual, expected), + false); +} + +// A macro for implementing the helper functions needed to implement +// ASSERT_?? and EXPECT_?? with integer or enum arguments. It is here +// just to avoid copy-and-paste of similar code. +#define GTEST_IMPL_CMP_HELPER_(op_name, op)\ +AssertionResult CmpHelper##op_name(const char* expr1, const char* expr2, \ + BiggestInt val1, BiggestInt val2) {\ + if (val1 op val2) {\ + return AssertionSuccess();\ + } else {\ + return AssertionFailure() \ + << "Expected: (" << expr1 << ") " #op " (" << expr2\ + << "), actual: " << FormatForComparisonFailureMessage(val1, val2)\ + << " vs " << FormatForComparisonFailureMessage(val2, val1);\ + }\ +} + +// Implements the helper function for {ASSERT|EXPECT}_NE with int or +// enum arguments. +GTEST_IMPL_CMP_HELPER_(NE, !=) +// Implements the helper function for {ASSERT|EXPECT}_LE with int or +// enum arguments. +GTEST_IMPL_CMP_HELPER_(LE, <=) +// Implements the helper function for {ASSERT|EXPECT}_LT with int or +// enum arguments. +GTEST_IMPL_CMP_HELPER_(LT, < ) +// Implements the helper function for {ASSERT|EXPECT}_GE with int or +// enum arguments. +GTEST_IMPL_CMP_HELPER_(GE, >=) +// Implements the helper function for {ASSERT|EXPECT}_GT with int or +// enum arguments. +GTEST_IMPL_CMP_HELPER_(GT, > ) + +#undef GTEST_IMPL_CMP_HELPER_ + +// The helper function for {ASSERT|EXPECT}_STREQ. +AssertionResult CmpHelperSTREQ(const char* expected_expression, + const char* actual_expression, + const char* expected, + const char* actual) { + if (String::CStringEquals(expected, actual)) { + return AssertionSuccess(); + } + + return EqFailure(expected_expression, + actual_expression, + PrintToString(expected), + PrintToString(actual), + false); +} + +// The helper function for {ASSERT|EXPECT}_STRCASEEQ. +AssertionResult CmpHelperSTRCASEEQ(const char* expected_expression, + const char* actual_expression, + const char* expected, + const char* actual) { + if (String::CaseInsensitiveCStringEquals(expected, actual)) { + return AssertionSuccess(); + } + + return EqFailure(expected_expression, + actual_expression, + PrintToString(expected), + PrintToString(actual), + true); +} + +// The helper function for {ASSERT|EXPECT}_STRNE. +AssertionResult CmpHelperSTRNE(const char* s1_expression, + const char* s2_expression, + const char* s1, + const char* s2) { + if (!String::CStringEquals(s1, s2)) { + return AssertionSuccess(); + } else { + return AssertionFailure() << "Expected: (" << s1_expression << ") != (" + << s2_expression << "), actual: \"" + << s1 << "\" vs \"" << s2 << "\""; + } +} + +// The helper function for {ASSERT|EXPECT}_STRCASENE. +AssertionResult CmpHelperSTRCASENE(const char* s1_expression, + const char* s2_expression, + const char* s1, + const char* s2) { + if (!String::CaseInsensitiveCStringEquals(s1, s2)) { + return AssertionSuccess(); + } else { + return AssertionFailure() + << "Expected: (" << s1_expression << ") != (" + << s2_expression << ") (ignoring case), actual: \"" + << s1 << "\" vs \"" << s2 << "\""; + } +} + +} // namespace internal + +namespace { + +// Helper functions for implementing IsSubString() and IsNotSubstring(). + +// This group of overloaded functions return true iff needle is a +// substring of haystack. NULL is considered a substring of itself +// only. + +bool IsSubstringPred(const char* needle, const char* haystack) { + if (needle == NULL || haystack == NULL) + return needle == haystack; + + return strstr(haystack, needle) != NULL; +} + +bool IsSubstringPred(const wchar_t* needle, const wchar_t* haystack) { + if (needle == NULL || haystack == NULL) + return needle == haystack; + + return wcsstr(haystack, needle) != NULL; +} + +// StringType here can be either ::std::string or ::std::wstring. +template +bool IsSubstringPred(const StringType& needle, + const StringType& haystack) { + return haystack.find(needle) != StringType::npos; +} + +// This function implements either IsSubstring() or IsNotSubstring(), +// depending on the value of the expected_to_be_substring parameter. +// StringType here can be const char*, const wchar_t*, ::std::string, +// or ::std::wstring. +template +AssertionResult IsSubstringImpl( + bool expected_to_be_substring, + const char* needle_expr, const char* haystack_expr, + const StringType& needle, const StringType& haystack) { + if (IsSubstringPred(needle, haystack) == expected_to_be_substring) + return AssertionSuccess(); + + const bool is_wide_string = sizeof(needle[0]) > 1; + const char* const begin_string_quote = is_wide_string ? "L\"" : "\""; + return AssertionFailure() + << "Value of: " << needle_expr << "\n" + << " Actual: " << begin_string_quote << needle << "\"\n" + << "Expected: " << (expected_to_be_substring ? "" : "not ") + << "a substring of " << haystack_expr << "\n" + << "Which is: " << begin_string_quote << haystack << "\""; +} + +} // namespace + +// IsSubstring() and IsNotSubstring() check whether needle is a +// substring of haystack (NULL is considered a substring of itself +// only), and return an appropriate error message when they fail. + +AssertionResult IsSubstring( + const char* needle_expr, const char* haystack_expr, + const char* needle, const char* haystack) { + return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack); +} + +AssertionResult IsSubstring( + const char* needle_expr, const char* haystack_expr, + const wchar_t* needle, const wchar_t* haystack) { + return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack); +} + +AssertionResult IsNotSubstring( + const char* needle_expr, const char* haystack_expr, + const char* needle, const char* haystack) { + return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack); +} + +AssertionResult IsNotSubstring( + const char* needle_expr, const char* haystack_expr, + const wchar_t* needle, const wchar_t* haystack) { + return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack); +} + +AssertionResult IsSubstring( + const char* needle_expr, const char* haystack_expr, + const ::std::string& needle, const ::std::string& haystack) { + return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack); +} + +AssertionResult IsNotSubstring( + const char* needle_expr, const char* haystack_expr, + const ::std::string& needle, const ::std::string& haystack) { + return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack); +} + +#if GTEST_HAS_STD_WSTRING +AssertionResult IsSubstring( + const char* needle_expr, const char* haystack_expr, + const ::std::wstring& needle, const ::std::wstring& haystack) { + return IsSubstringImpl(true, needle_expr, haystack_expr, needle, haystack); +} + +AssertionResult IsNotSubstring( + const char* needle_expr, const char* haystack_expr, + const ::std::wstring& needle, const ::std::wstring& haystack) { + return IsSubstringImpl(false, needle_expr, haystack_expr, needle, haystack); +} +#endif // GTEST_HAS_STD_WSTRING + +namespace internal { + +#if GTEST_OS_WINDOWS + +namespace { + +// Helper function for IsHRESULT{SuccessFailure} predicates +AssertionResult HRESULTFailureHelper(const char* expr, + const char* expected, + long hr) { // NOLINT +# if GTEST_OS_WINDOWS_MOBILE + + // Windows CE doesn't support FormatMessage. + const char error_text[] = ""; + +# else + + // Looks up the human-readable system message for the HRESULT code + // and since we're not passing any params to FormatMessage, we don't + // want inserts expanded. + const DWORD kFlags = FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS; + const DWORD kBufSize = 4096; + // Gets the system's human readable message string for this HRESULT. + char error_text[kBufSize] = { '\0' }; + DWORD message_length = ::FormatMessageA(kFlags, + 0, // no source, we're asking system + hr, // the error + 0, // no line width restrictions + error_text, // output buffer + kBufSize, // buf size + NULL); // no arguments for inserts + // Trims tailing white space (FormatMessage leaves a trailing CR-LF) + for (; message_length && IsSpace(error_text[message_length - 1]); + --message_length) { + error_text[message_length - 1] = '\0'; + } + +# endif // GTEST_OS_WINDOWS_MOBILE + + const std::string error_hex("0x" + String::FormatHexInt(hr)); + return ::testing::AssertionFailure() + << "Expected: " << expr << " " << expected << ".\n" + << " Actual: " << error_hex << " " << error_text << "\n"; +} + +} // namespace + +AssertionResult IsHRESULTSuccess(const char* expr, long hr) { // NOLINT + if (SUCCEEDED(hr)) { + return AssertionSuccess(); + } + return HRESULTFailureHelper(expr, "succeeds", hr); +} + +AssertionResult IsHRESULTFailure(const char* expr, long hr) { // NOLINT + if (FAILED(hr)) { + return AssertionSuccess(); + } + return HRESULTFailureHelper(expr, "fails", hr); +} + +#endif // GTEST_OS_WINDOWS + +// Utility functions for encoding Unicode text (wide strings) in +// UTF-8. + +// A Unicode code-point can have upto 21 bits, and is encoded in UTF-8 +// like this: +// +// Code-point length Encoding +// 0 - 7 bits 0xxxxxxx +// 8 - 11 bits 110xxxxx 10xxxxxx +// 12 - 16 bits 1110xxxx 10xxxxxx 10xxxxxx +// 17 - 21 bits 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx + +// The maximum code-point a one-byte UTF-8 sequence can represent. +const UInt32 kMaxCodePoint1 = (static_cast(1) << 7) - 1; + +// The maximum code-point a two-byte UTF-8 sequence can represent. +const UInt32 kMaxCodePoint2 = (static_cast(1) << (5 + 6)) - 1; + +// The maximum code-point a three-byte UTF-8 sequence can represent. +const UInt32 kMaxCodePoint3 = (static_cast(1) << (4 + 2*6)) - 1; + +// The maximum code-point a four-byte UTF-8 sequence can represent. +const UInt32 kMaxCodePoint4 = (static_cast(1) << (3 + 3*6)) - 1; + +// Chops off the n lowest bits from a bit pattern. Returns the n +// lowest bits. As a side effect, the original bit pattern will be +// shifted to the right by n bits. +inline UInt32 ChopLowBits(UInt32* bits, int n) { + const UInt32 low_bits = *bits & ((static_cast(1) << n) - 1); + *bits >>= n; + return low_bits; +} + +// Converts a Unicode code point to a narrow string in UTF-8 encoding. +// code_point parameter is of type UInt32 because wchar_t may not be +// wide enough to contain a code point. +// If the code_point is not a valid Unicode code point +// (i.e. outside of Unicode range U+0 to U+10FFFF) it will be converted +// to "(Invalid Unicode 0xXXXXXXXX)". +std::string CodePointToUtf8(UInt32 code_point) { + if (code_point > kMaxCodePoint4) { + return "(Invalid Unicode 0x" + String::FormatHexInt(code_point) + ")"; + } + + char str[5]; // Big enough for the largest valid code point. + if (code_point <= kMaxCodePoint1) { + str[1] = '\0'; + str[0] = static_cast(code_point); // 0xxxxxxx + } else if (code_point <= kMaxCodePoint2) { + str[2] = '\0'; + str[1] = static_cast(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx + str[0] = static_cast(0xC0 | code_point); // 110xxxxx + } else if (code_point <= kMaxCodePoint3) { + str[3] = '\0'; + str[2] = static_cast(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx + str[1] = static_cast(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx + str[0] = static_cast(0xE0 | code_point); // 1110xxxx + } else { // code_point <= kMaxCodePoint4 + str[4] = '\0'; + str[3] = static_cast(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx + str[2] = static_cast(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx + str[1] = static_cast(0x80 | ChopLowBits(&code_point, 6)); // 10xxxxxx + str[0] = static_cast(0xF0 | code_point); // 11110xxx + } + return str; +} + +// The following two functions only make sense if the the system +// uses UTF-16 for wide string encoding. All supported systems +// with 16 bit wchar_t (Windows, Cygwin, Symbian OS) do use UTF-16. + +// Determines if the arguments constitute UTF-16 surrogate pair +// and thus should be combined into a single Unicode code point +// using CreateCodePointFromUtf16SurrogatePair. +inline bool IsUtf16SurrogatePair(wchar_t first, wchar_t second) { + return sizeof(wchar_t) == 2 && + (first & 0xFC00) == 0xD800 && (second & 0xFC00) == 0xDC00; +} + +// Creates a Unicode code point from UTF16 surrogate pair. +inline UInt32 CreateCodePointFromUtf16SurrogatePair(wchar_t first, + wchar_t second) { + const UInt32 mask = (1 << 10) - 1; + return (sizeof(wchar_t) == 2) ? + (((first & mask) << 10) | (second & mask)) + 0x10000 : + // This function should not be called when the condition is + // false, but we provide a sensible default in case it is. + static_cast(first); +} + +// Converts a wide string to a narrow string in UTF-8 encoding. +// The wide string is assumed to have the following encoding: +// UTF-16 if sizeof(wchar_t) == 2 (on Windows, Cygwin, Symbian OS) +// UTF-32 if sizeof(wchar_t) == 4 (on Linux) +// Parameter str points to a null-terminated wide string. +// Parameter num_chars may additionally limit the number +// of wchar_t characters processed. -1 is used when the entire string +// should be processed. +// If the string contains code points that are not valid Unicode code points +// (i.e. outside of Unicode range U+0 to U+10FFFF) they will be output +// as '(Invalid Unicode 0xXXXXXXXX)'. If the string is in UTF16 encoding +// and contains invalid UTF-16 surrogate pairs, values in those pairs +// will be encoded as individual Unicode characters from Basic Normal Plane. +std::string WideStringToUtf8(const wchar_t* str, int num_chars) { + if (num_chars == -1) + num_chars = static_cast(wcslen(str)); + + ::std::stringstream stream; + for (int i = 0; i < num_chars; ++i) { + UInt32 unicode_code_point; + + if (str[i] == L'\0') { + break; + } else if (i + 1 < num_chars && IsUtf16SurrogatePair(str[i], str[i + 1])) { + unicode_code_point = CreateCodePointFromUtf16SurrogatePair(str[i], + str[i + 1]); + i++; + } else { + unicode_code_point = static_cast(str[i]); + } + + stream << CodePointToUtf8(unicode_code_point); + } + return StringStreamToString(&stream); +} + +// Converts a wide C string to an std::string using the UTF-8 encoding. +// NULL will be converted to "(null)". +std::string String::ShowWideCString(const wchar_t * wide_c_str) { + if (wide_c_str == NULL) return "(null)"; + + return internal::WideStringToUtf8(wide_c_str, -1); +} + +// Compares two wide C strings. Returns true iff they have the same +// content. +// +// Unlike wcscmp(), this function can handle NULL argument(s). A NULL +// C string is considered different to any non-NULL C string, +// including the empty string. +bool String::WideCStringEquals(const wchar_t * lhs, const wchar_t * rhs) { + if (lhs == NULL) return rhs == NULL; + + if (rhs == NULL) return false; + + return wcscmp(lhs, rhs) == 0; +} + +// Helper function for *_STREQ on wide strings. +AssertionResult CmpHelperSTREQ(const char* expected_expression, + const char* actual_expression, + const wchar_t* expected, + const wchar_t* actual) { + if (String::WideCStringEquals(expected, actual)) { + return AssertionSuccess(); + } + + return EqFailure(expected_expression, + actual_expression, + PrintToString(expected), + PrintToString(actual), + false); +} + +// Helper function for *_STRNE on wide strings. +AssertionResult CmpHelperSTRNE(const char* s1_expression, + const char* s2_expression, + const wchar_t* s1, + const wchar_t* s2) { + if (!String::WideCStringEquals(s1, s2)) { + return AssertionSuccess(); + } + + return AssertionFailure() << "Expected: (" << s1_expression << ") != (" + << s2_expression << "), actual: " + << PrintToString(s1) + << " vs " << PrintToString(s2); +} + +// Compares two C strings, ignoring case. Returns true iff they have +// the same content. +// +// Unlike strcasecmp(), this function can handle NULL argument(s). A +// NULL C string is considered different to any non-NULL C string, +// including the empty string. +bool String::CaseInsensitiveCStringEquals(const char * lhs, const char * rhs) { + if (lhs == NULL) + return rhs == NULL; + if (rhs == NULL) + return false; + return posix::StrCaseCmp(lhs, rhs) == 0; +} + + // Compares two wide C strings, ignoring case. Returns true iff they + // have the same content. + // + // Unlike wcscasecmp(), this function can handle NULL argument(s). + // A NULL C string is considered different to any non-NULL wide C string, + // including the empty string. + // NB: The implementations on different platforms slightly differ. + // On windows, this method uses _wcsicmp which compares according to LC_CTYPE + // environment variable. On GNU platform this method uses wcscasecmp + // which compares according to LC_CTYPE category of the current locale. + // On MacOS X, it uses towlower, which also uses LC_CTYPE category of the + // current locale. +bool String::CaseInsensitiveWideCStringEquals(const wchar_t* lhs, + const wchar_t* rhs) { + if (lhs == NULL) return rhs == NULL; + + if (rhs == NULL) return false; + +#if GTEST_OS_WINDOWS + return _wcsicmp(lhs, rhs) == 0; +#elif GTEST_OS_LINUX && !GTEST_OS_LINUX_ANDROID + return wcscasecmp(lhs, rhs) == 0; +#else + // Android, Mac OS X and Cygwin don't define wcscasecmp. + // Other unknown OSes may not define it either. + wint_t left, right; + do { + left = towlower(*lhs++); + right = towlower(*rhs++); + } while (left && left == right); + return left == right; +#endif // OS selector +} + +// Returns true iff str ends with the given suffix, ignoring case. +// Any string is considered to end with an empty suffix. +bool String::EndsWithCaseInsensitive( + const std::string& str, const std::string& suffix) { + const size_t str_len = str.length(); + const size_t suffix_len = suffix.length(); + return (str_len >= suffix_len) && + CaseInsensitiveCStringEquals(str.c_str() + str_len - suffix_len, + suffix.c_str()); +} + +// Formats an int value as "%02d". +std::string String::FormatIntWidth2(int value) { + std::stringstream ss; + ss << std::setfill('0') << std::setw(2) << value; + return ss.str(); +} + +// Formats an int value as "%X". +std::string String::FormatHexInt(int value) { + std::stringstream ss; + ss << std::hex << std::uppercase << value; + return ss.str(); +} + +// Formats a byte as "%02X". +std::string String::FormatByte(unsigned char value) { + std::stringstream ss; + ss << std::setfill('0') << std::setw(2) << std::hex << std::uppercase + << static_cast(value); + return ss.str(); +} + +// Converts the buffer in a stringstream to an std::string, converting NUL +// bytes to "\\0" along the way. +std::string StringStreamToString(::std::stringstream* ss) { + const ::std::string& str = ss->str(); + const char* const start = str.c_str(); + const char* const end = start + str.length(); + + std::string result; + result.reserve(2 * (end - start)); + for (const char* ch = start; ch != end; ++ch) { + if (*ch == '\0') { + result += "\\0"; // Replaces NUL with "\\0"; + } else { + result += *ch; + } + } + + return result; +} + +// Appends the user-supplied message to the Google-Test-generated message. +std::string AppendUserMessage(const std::string& gtest_msg, + const Message& user_msg) { + // Appends the user message if it's non-empty. + const std::string user_msg_string = user_msg.GetString(); + if (user_msg_string.empty()) { + return gtest_msg; + } + + return gtest_msg + "\n" + user_msg_string; +} + +} // namespace internal + +// class TestResult + +// Creates an empty TestResult. +TestResult::TestResult() + : death_test_count_(0), + elapsed_time_(0) { +} + +// D'tor. +TestResult::~TestResult() { +} + +// Returns the i-th test part result among all the results. i can +// range from 0 to total_part_count() - 1. If i is not in that range, +// aborts the program. +const TestPartResult& TestResult::GetTestPartResult(int i) const { + if (i < 0 || i >= total_part_count()) + internal::posix::Abort(); + return test_part_results_.at(i); +} + +// Returns the i-th test property. i can range from 0 to +// test_property_count() - 1. If i is not in that range, aborts the +// program. +const TestProperty& TestResult::GetTestProperty(int i) const { + if (i < 0 || i >= test_property_count()) + internal::posix::Abort(); + return test_properties_.at(i); +} + +// Clears the test part results. +void TestResult::ClearTestPartResults() { + test_part_results_.clear(); +} + +// Adds a test part result to the list. +void TestResult::AddTestPartResult(const TestPartResult& test_part_result) { + test_part_results_.push_back(test_part_result); +} + +// Adds a test property to the list. If a property with the same key as the +// supplied property is already represented, the value of this test_property +// replaces the old value for that key. +void TestResult::RecordProperty(const std::string& xml_element, + const TestProperty& test_property) { + if (!ValidateTestProperty(xml_element, test_property)) { + return; + } + internal::MutexLock lock(&test_properites_mutex_); + const std::vector::iterator property_with_matching_key = + std::find_if(test_properties_.begin(), test_properties_.end(), + internal::TestPropertyKeyIs(test_property.key())); + if (property_with_matching_key == test_properties_.end()) { + test_properties_.push_back(test_property); + return; + } + property_with_matching_key->SetValue(test_property.value()); +} + +// The list of reserved attributes used in the element of XML +// output. +static const char* const kReservedTestSuitesAttributes[] = { + "disabled", + "errors", + "failures", + "name", + "random_seed", + "tests", + "time", + "timestamp" +}; + +// The list of reserved attributes used in the element of XML +// output. +static const char* const kReservedTestSuiteAttributes[] = { + "disabled", + "errors", + "failures", + "name", + "tests", + "time" +}; + +// The list of reserved attributes used in the element of XML output. +static const char* const kReservedTestCaseAttributes[] = { + "classname", + "name", + "status", + "time", + "type_param", + "value_param" +}; + +template +std::vector ArrayAsVector(const char* const (&array)[kSize]) { + return std::vector(array, array + kSize); +} + +static std::vector GetReservedAttributesForElement( + const std::string& xml_element) { + if (xml_element == "testsuites") { + return ArrayAsVector(kReservedTestSuitesAttributes); + } else if (xml_element == "testsuite") { + return ArrayAsVector(kReservedTestSuiteAttributes); + } else if (xml_element == "testcase") { + return ArrayAsVector(kReservedTestCaseAttributes); + } else { + GTEST_CHECK_(false) << "Unrecognized xml_element provided: " << xml_element; + } + // This code is unreachable but some compilers may not realizes that. + return std::vector(); +} + +static std::string FormatWordList(const std::vector& words) { + Message word_list; + for (size_t i = 0; i < words.size(); ++i) { + if (i > 0 && words.size() > 2) { + word_list << ", "; + } + if (i == words.size() - 1) { + word_list << "and "; + } + word_list << "'" << words[i] << "'"; + } + return word_list.GetString(); +} + +bool ValidateTestPropertyName(const std::string& property_name, + const std::vector& reserved_names) { + if (std::find(reserved_names.begin(), reserved_names.end(), property_name) != + reserved_names.end()) { + ADD_FAILURE() << "Reserved key used in RecordProperty(): " << property_name + << " (" << FormatWordList(reserved_names) + << " are reserved by " << GTEST_NAME_ << ")"; + return false; + } + return true; +} + +// Adds a failure if the key is a reserved attribute of the element named +// xml_element. Returns true if the property is valid. +bool TestResult::ValidateTestProperty(const std::string& xml_element, + const TestProperty& test_property) { + return ValidateTestPropertyName(test_property.key(), + GetReservedAttributesForElement(xml_element)); +} + +// Clears the object. +void TestResult::Clear() { + test_part_results_.clear(); + test_properties_.clear(); + death_test_count_ = 0; + elapsed_time_ = 0; +} + +// Returns true iff the test failed. +bool TestResult::Failed() const { + for (int i = 0; i < total_part_count(); ++i) { + if (GetTestPartResult(i).failed()) + return true; + } + return false; +} + +// Returns true iff the test part fatally failed. +static bool TestPartFatallyFailed(const TestPartResult& result) { + return result.fatally_failed(); +} + +// Returns true iff the test fatally failed. +bool TestResult::HasFatalFailure() const { + return CountIf(test_part_results_, TestPartFatallyFailed) > 0; +} + +// Returns true iff the test part non-fatally failed. +static bool TestPartNonfatallyFailed(const TestPartResult& result) { + return result.nonfatally_failed(); +} + +// Returns true iff the test has a non-fatal failure. +bool TestResult::HasNonfatalFailure() const { + return CountIf(test_part_results_, TestPartNonfatallyFailed) > 0; +} + +// Gets the number of all test parts. This is the sum of the number +// of successful test parts and the number of failed test parts. +int TestResult::total_part_count() const { + return static_cast(test_part_results_.size()); +} + +// Returns the number of the test properties. +int TestResult::test_property_count() const { + return static_cast(test_properties_.size()); +} + +// class Test + +// Creates a Test object. + +// The c'tor saves the values of all Google Test flags. +Test::Test() + : gtest_flag_saver_(new internal::GTestFlagSaver) { +} + +// The d'tor restores the values of all Google Test flags. +Test::~Test() { + delete gtest_flag_saver_; +} + +// Sets up the test fixture. +// +// A sub-class may override this. +void Test::SetUp() { +} + +// Tears down the test fixture. +// +// A sub-class may override this. +void Test::TearDown() { +} + +// Allows user supplied key value pairs to be recorded for later output. +void Test::RecordProperty(const std::string& key, const std::string& value) { + UnitTest::GetInstance()->RecordProperty(key, value); +} + +// Allows user supplied key value pairs to be recorded for later output. +void Test::RecordProperty(const std::string& key, int value) { + Message value_message; + value_message << value; + RecordProperty(key, value_message.GetString().c_str()); +} + +namespace internal { + +void ReportFailureInUnknownLocation(TestPartResult::Type result_type, + const std::string& message) { + // This function is a friend of UnitTest and as such has access to + // AddTestPartResult. + UnitTest::GetInstance()->AddTestPartResult( + result_type, + NULL, // No info about the source file where the exception occurred. + -1, // We have no info on which line caused the exception. + message, + ""); // No stack trace, either. +} + +} // namespace internal + +// Google Test requires all tests in the same test case to use the same test +// fixture class. This function checks if the current test has the +// same fixture class as the first test in the current test case. If +// yes, it returns true; otherwise it generates a Google Test failure and +// returns false. +bool Test::HasSameFixtureClass() { + internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); + const TestCase* const test_case = impl->current_test_case(); + + // Info about the first test in the current test case. + const TestInfo* const first_test_info = test_case->test_info_list()[0]; + const internal::TypeId first_fixture_id = first_test_info->fixture_class_id_; + const char* const first_test_name = first_test_info->name(); + + // Info about the current test. + const TestInfo* const this_test_info = impl->current_test_info(); + const internal::TypeId this_fixture_id = this_test_info->fixture_class_id_; + const char* const this_test_name = this_test_info->name(); + + if (this_fixture_id != first_fixture_id) { + // Is the first test defined using TEST? + const bool first_is_TEST = first_fixture_id == internal::GetTestTypeId(); + // Is this test defined using TEST? + const bool this_is_TEST = this_fixture_id == internal::GetTestTypeId(); + + if (first_is_TEST || this_is_TEST) { + // The user mixed TEST and TEST_F in this test case - we'll tell + // him/her how to fix it. + + // Gets the name of the TEST and the name of the TEST_F. Note + // that first_is_TEST and this_is_TEST cannot both be true, as + // the fixture IDs are different for the two tests. + const char* const TEST_name = + first_is_TEST ? first_test_name : this_test_name; + const char* const TEST_F_name = + first_is_TEST ? this_test_name : first_test_name; + + ADD_FAILURE() + << "All tests in the same test case must use the same test fixture\n" + << "class, so mixing TEST_F and TEST in the same test case is\n" + << "illegal. In test case " << this_test_info->test_case_name() + << ",\n" + << "test " << TEST_F_name << " is defined using TEST_F but\n" + << "test " << TEST_name << " is defined using TEST. You probably\n" + << "want to change the TEST to TEST_F or move it to another test\n" + << "case."; + } else { + // The user defined two fixture classes with the same name in + // two namespaces - we'll tell him/her how to fix it. + ADD_FAILURE() + << "All tests in the same test case must use the same test fixture\n" + << "class. However, in test case " + << this_test_info->test_case_name() << ",\n" + << "you defined test " << first_test_name + << " and test " << this_test_name << "\n" + << "using two different test fixture classes. This can happen if\n" + << "the two classes are from different namespaces or translation\n" + << "units and have the same name. You should probably rename one\n" + << "of the classes to put the tests into different test cases."; + } + return false; + } + + return true; +} + +#if GTEST_HAS_SEH + +// Adds an "exception thrown" fatal failure to the current test. This +// function returns its result via an output parameter pointer because VC++ +// prohibits creation of objects with destructors on stack in functions +// using __try (see error C2712). +static std::string* FormatSehExceptionMessage(DWORD exception_code, + const char* location) { + Message message; + message << "SEH exception with code 0x" << std::setbase(16) << + exception_code << std::setbase(10) << " thrown in " << location << "."; + + return new std::string(message.GetString()); +} + +#endif // GTEST_HAS_SEH + +namespace internal { + +#if GTEST_HAS_EXCEPTIONS + +// Adds an "exception thrown" fatal failure to the current test. +static std::string FormatCxxExceptionMessage(const char* description, + const char* location) { + Message message; + if (description != NULL) { + message << "C++ exception with description \"" << description << "\""; + } else { + message << "Unknown C++ exception"; + } + message << " thrown in " << location << "."; + + return message.GetString(); +} + +static std::string PrintTestPartResultToString( + const TestPartResult& test_part_result); + +GoogleTestFailureException::GoogleTestFailureException( + const TestPartResult& failure) + : ::std::runtime_error(PrintTestPartResultToString(failure).c_str()) {} + +#endif // GTEST_HAS_EXCEPTIONS + +// We put these helper functions in the internal namespace as IBM's xlC +// compiler rejects the code if they were declared static. + +// Runs the given method and handles SEH exceptions it throws, when +// SEH is supported; returns the 0-value for type Result in case of an +// SEH exception. (Microsoft compilers cannot handle SEH and C++ +// exceptions in the same function. Therefore, we provide a separate +// wrapper function for handling SEH exceptions.) +template +Result HandleSehExceptionsInMethodIfSupported( + T* object, Result (T::*method)(), const char* location) { +#if GTEST_HAS_SEH + __try { + return (object->*method)(); + } __except (internal::UnitTestOptions::GTestShouldProcessSEH( // NOLINT + GetExceptionCode())) { + // We create the exception message on the heap because VC++ prohibits + // creation of objects with destructors on stack in functions using __try + // (see error C2712). + std::string* exception_message = FormatSehExceptionMessage( + GetExceptionCode(), location); + internal::ReportFailureInUnknownLocation(TestPartResult::kFatalFailure, + *exception_message); + delete exception_message; + return static_cast(0); + } +#else + (void)location; + return (object->*method)(); +#endif // GTEST_HAS_SEH +} + +// Runs the given method and catches and reports C++ and/or SEH-style +// exceptions, if they are supported; returns the 0-value for type +// Result in case of an SEH exception. +template +Result HandleExceptionsInMethodIfSupported( + T* object, Result (T::*method)(), const char* location) { + // NOTE: The user code can affect the way in which Google Test handles + // exceptions by setting GTEST_FLAG(catch_exceptions), but only before + // RUN_ALL_TESTS() starts. It is technically possible to check the flag + // after the exception is caught and either report or re-throw the + // exception based on the flag's value: + // + // try { + // // Perform the test method. + // } catch (...) { + // if (GTEST_FLAG(catch_exceptions)) + // // Report the exception as failure. + // else + // throw; // Re-throws the original exception. + // } + // + // However, the purpose of this flag is to allow the program to drop into + // the debugger when the exception is thrown. On most platforms, once the + // control enters the catch block, the exception origin information is + // lost and the debugger will stop the program at the point of the + // re-throw in this function -- instead of at the point of the original + // throw statement in the code under test. For this reason, we perform + // the check early, sacrificing the ability to affect Google Test's + // exception handling in the method where the exception is thrown. + if (internal::GetUnitTestImpl()->catch_exceptions()) { +#if GTEST_HAS_EXCEPTIONS + try { + return HandleSehExceptionsInMethodIfSupported(object, method, location); + } catch (const internal::GoogleTestFailureException&) { // NOLINT + // This exception type can only be thrown by a failed Google + // Test assertion with the intention of letting another testing + // framework catch it. Therefore we just re-throw it. + throw; + } catch (const std::exception& e) { // NOLINT + internal::ReportFailureInUnknownLocation( + TestPartResult::kFatalFailure, + FormatCxxExceptionMessage(e.what(), location)); + } catch (...) { // NOLINT + internal::ReportFailureInUnknownLocation( + TestPartResult::kFatalFailure, + FormatCxxExceptionMessage(NULL, location)); + } + return static_cast(0); +#else + return HandleSehExceptionsInMethodIfSupported(object, method, location); +#endif // GTEST_HAS_EXCEPTIONS + } else { + return (object->*method)(); + } +} + +} // namespace internal + +// Runs the test and updates the test result. +void Test::Run() { + if (!HasSameFixtureClass()) return; + + internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); + impl->os_stack_trace_getter()->UponLeavingGTest(); + internal::HandleExceptionsInMethodIfSupported(this, &Test::SetUp, "SetUp()"); + // We will run the test only if SetUp() was successful. + if (!HasFatalFailure()) { + impl->os_stack_trace_getter()->UponLeavingGTest(); + internal::HandleExceptionsInMethodIfSupported( + this, &Test::TestBody, "the test body"); + } + + // However, we want to clean up as much as possible. Hence we will + // always call TearDown(), even if SetUp() or the test body has + // failed. + impl->os_stack_trace_getter()->UponLeavingGTest(); + internal::HandleExceptionsInMethodIfSupported( + this, &Test::TearDown, "TearDown()"); +} + +// Returns true iff the current test has a fatal failure. +bool Test::HasFatalFailure() { + return internal::GetUnitTestImpl()->current_test_result()->HasFatalFailure(); +} + +// Returns true iff the current test has a non-fatal failure. +bool Test::HasNonfatalFailure() { + return internal::GetUnitTestImpl()->current_test_result()-> + HasNonfatalFailure(); +} + +// class TestInfo + +// Constructs a TestInfo object. It assumes ownership of the test factory +// object. +TestInfo::TestInfo(const std::string& a_test_case_name, + const std::string& a_name, + const char* a_type_param, + const char* a_value_param, + internal::TypeId fixture_class_id, + internal::TestFactoryBase* factory) + : test_case_name_(a_test_case_name), + name_(a_name), + type_param_(a_type_param ? new std::string(a_type_param) : NULL), + value_param_(a_value_param ? new std::string(a_value_param) : NULL), + fixture_class_id_(fixture_class_id), + should_run_(false), + is_disabled_(false), + matches_filter_(false), + factory_(factory), + result_() {} + +// Destructs a TestInfo object. +TestInfo::~TestInfo() { delete factory_; } + +namespace internal { + +// Creates a new TestInfo object and registers it with Google Test; +// returns the created object. +// +// Arguments: +// +// test_case_name: name of the test case +// name: name of the test +// type_param: the name of the test's type parameter, or NULL if +// this is not a typed or a type-parameterized test. +// value_param: text representation of the test's value parameter, +// or NULL if this is not a value-parameterized test. +// fixture_class_id: ID of the test fixture class +// set_up_tc: pointer to the function that sets up the test case +// tear_down_tc: pointer to the function that tears down the test case +// factory: pointer to the factory that creates a test object. +// The newly created TestInfo instance will assume +// ownership of the factory object. +TestInfo* MakeAndRegisterTestInfo( + const char* test_case_name, + const char* name, + const char* type_param, + const char* value_param, + TypeId fixture_class_id, + SetUpTestCaseFunc set_up_tc, + TearDownTestCaseFunc tear_down_tc, + TestFactoryBase* factory) { + TestInfo* const test_info = + new TestInfo(test_case_name, name, type_param, value_param, + fixture_class_id, factory); + GetUnitTestImpl()->AddTestInfo(set_up_tc, tear_down_tc, test_info); + return test_info; +} + +#if GTEST_HAS_PARAM_TEST +void ReportInvalidTestCaseType(const char* test_case_name, + const char* file, int line) { + Message errors; + errors + << "Attempted redefinition of test case " << test_case_name << ".\n" + << "All tests in the same test case must use the same test fixture\n" + << "class. However, in test case " << test_case_name << ", you tried\n" + << "to define a test using a fixture class different from the one\n" + << "used earlier. This can happen if the two fixture classes are\n" + << "from different namespaces and have the same name. You should\n" + << "probably rename one of the classes to put the tests into different\n" + << "test cases."; + + fprintf(stderr, "%s %s", FormatFileLocation(file, line).c_str(), + errors.GetString().c_str()); +} +#endif // GTEST_HAS_PARAM_TEST + +} // namespace internal + +namespace { + +// A predicate that checks the test name of a TestInfo against a known +// value. +// +// This is used for implementation of the TestCase class only. We put +// it in the anonymous namespace to prevent polluting the outer +// namespace. +// +// TestNameIs is copyable. +class TestNameIs { + public: + // Constructor. + // + // TestNameIs has NO default constructor. + explicit TestNameIs(const char* name) + : name_(name) {} + + // Returns true iff the test name of test_info matches name_. + bool operator()(const TestInfo * test_info) const { + return test_info && test_info->name() == name_; + } + + private: + std::string name_; +}; + +} // namespace + +namespace internal { + +// This method expands all parameterized tests registered with macros TEST_P +// and INSTANTIATE_TEST_CASE_P into regular tests and registers those. +// This will be done just once during the program runtime. +void UnitTestImpl::RegisterParameterizedTests() { +#if GTEST_HAS_PARAM_TEST + if (!parameterized_tests_registered_) { + parameterized_test_registry_.RegisterTests(); + parameterized_tests_registered_ = true; + } +#endif +} + +} // namespace internal + +// Creates the test object, runs it, records its result, and then +// deletes it. +void TestInfo::Run() { + if (!should_run_) return; + + // Tells UnitTest where to store test result. + internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); + impl->set_current_test_info(this); + + TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater(); + + // Notifies the unit test event listeners that a test is about to start. + repeater->OnTestStart(*this); + + const TimeInMillis start = internal::GetTimeInMillis(); + + impl->os_stack_trace_getter()->UponLeavingGTest(); + + // Creates the test object. + Test* const test = internal::HandleExceptionsInMethodIfSupported( + factory_, &internal::TestFactoryBase::CreateTest, + "the test fixture's constructor"); + + // Runs the test only if the test object was created and its + // constructor didn't generate a fatal failure. + if ((test != NULL) && !Test::HasFatalFailure()) { + // This doesn't throw as all user code that can throw are wrapped into + // exception handling code. + test->Run(); + } + + // Deletes the test object. + impl->os_stack_trace_getter()->UponLeavingGTest(); + internal::HandleExceptionsInMethodIfSupported( + test, &Test::DeleteSelf_, "the test fixture's destructor"); + + result_.set_elapsed_time(internal::GetTimeInMillis() - start); + + // Notifies the unit test event listener that a test has just finished. + repeater->OnTestEnd(*this); + + // Tells UnitTest to stop associating assertion results to this + // test. + impl->set_current_test_info(NULL); +} + +// class TestCase + +// Gets the number of successful tests in this test case. +int TestCase::successful_test_count() const { + return CountIf(test_info_list_, TestPassed); +} + +// Gets the number of failed tests in this test case. +int TestCase::failed_test_count() const { + return CountIf(test_info_list_, TestFailed); +} + +// Gets the number of disabled tests that will be reported in the XML report. +int TestCase::reportable_disabled_test_count() const { + return CountIf(test_info_list_, TestReportableDisabled); +} + +// Gets the number of disabled tests in this test case. +int TestCase::disabled_test_count() const { + return CountIf(test_info_list_, TestDisabled); +} + +// Gets the number of tests to be printed in the XML report. +int TestCase::reportable_test_count() const { + return CountIf(test_info_list_, TestReportable); +} + +// Get the number of tests in this test case that should run. +int TestCase::test_to_run_count() const { + return CountIf(test_info_list_, ShouldRunTest); +} + +// Gets the number of all tests. +int TestCase::total_test_count() const { + return static_cast(test_info_list_.size()); +} + +// Creates a TestCase with the given name. +// +// Arguments: +// +// name: name of the test case +// a_type_param: the name of the test case's type parameter, or NULL if +// this is not a typed or a type-parameterized test case. +// set_up_tc: pointer to the function that sets up the test case +// tear_down_tc: pointer to the function that tears down the test case +TestCase::TestCase(const char* a_name, const char* a_type_param, + Test::SetUpTestCaseFunc set_up_tc, + Test::TearDownTestCaseFunc tear_down_tc) + : name_(a_name), + type_param_(a_type_param ? new std::string(a_type_param) : NULL), + set_up_tc_(set_up_tc), + tear_down_tc_(tear_down_tc), + should_run_(false), + elapsed_time_(0) { +} + +// Destructor of TestCase. +TestCase::~TestCase() { + // Deletes every Test in the collection. + ForEach(test_info_list_, internal::Delete); +} + +// Returns the i-th test among all the tests. i can range from 0 to +// total_test_count() - 1. If i is not in that range, returns NULL. +const TestInfo* TestCase::GetTestInfo(int i) const { + const int index = GetElementOr(test_indices_, i, -1); + return index < 0 ? NULL : test_info_list_[index]; +} + +// Returns the i-th test among all the tests. i can range from 0 to +// total_test_count() - 1. If i is not in that range, returns NULL. +TestInfo* TestCase::GetMutableTestInfo(int i) { + const int index = GetElementOr(test_indices_, i, -1); + return index < 0 ? NULL : test_info_list_[index]; +} + +// Adds a test to this test case. Will delete the test upon +// destruction of the TestCase object. +void TestCase::AddTestInfo(TestInfo * test_info) { + test_info_list_.push_back(test_info); + test_indices_.push_back(static_cast(test_indices_.size())); +} + +// Runs every test in this TestCase. +void TestCase::Run() { + if (!should_run_) return; + + internal::UnitTestImpl* const impl = internal::GetUnitTestImpl(); + impl->set_current_test_case(this); + + TestEventListener* repeater = UnitTest::GetInstance()->listeners().repeater(); + + repeater->OnTestCaseStart(*this); + impl->os_stack_trace_getter()->UponLeavingGTest(); + internal::HandleExceptionsInMethodIfSupported( + this, &TestCase::RunSetUpTestCase, "SetUpTestCase()"); + + const internal::TimeInMillis start = internal::GetTimeInMillis(); + for (int i = 0; i < total_test_count(); i++) { + GetMutableTestInfo(i)->Run(); + } + elapsed_time_ = internal::GetTimeInMillis() - start; + + impl->os_stack_trace_getter()->UponLeavingGTest(); + internal::HandleExceptionsInMethodIfSupported( + this, &TestCase::RunTearDownTestCase, "TearDownTestCase()"); + + repeater->OnTestCaseEnd(*this); + impl->set_current_test_case(NULL); +} + +// Clears the results of all tests in this test case. +void TestCase::ClearResult() { + ad_hoc_test_result_.Clear(); + ForEach(test_info_list_, TestInfo::ClearTestResult); +} + +// Shuffles the tests in this test case. +void TestCase::ShuffleTests(internal::Random* random) { + Shuffle(random, &test_indices_); +} + +// Restores the test order to before the first shuffle. +void TestCase::UnshuffleTests() { + for (size_t i = 0; i < test_indices_.size(); i++) { + test_indices_[i] = static_cast(i); + } +} + +// Formats a countable noun. Depending on its quantity, either the +// singular form or the plural form is used. e.g. +// +// FormatCountableNoun(1, "formula", "formuli") returns "1 formula". +// FormatCountableNoun(5, "book", "books") returns "5 books". +static std::string FormatCountableNoun(int count, + const char * singular_form, + const char * plural_form) { + return internal::StreamableToString(count) + " " + + (count == 1 ? singular_form : plural_form); +} + +// Formats the count of tests. +static std::string FormatTestCount(int test_count) { + return FormatCountableNoun(test_count, "test", "tests"); +} + +// Formats the count of test cases. +static std::string FormatTestCaseCount(int test_case_count) { + return FormatCountableNoun(test_case_count, "test case", "test cases"); +} + +// Converts a TestPartResult::Type enum to human-friendly string +// representation. Both kNonFatalFailure and kFatalFailure are translated +// to "Failure", as the user usually doesn't care about the difference +// between the two when viewing the test result. +static const char * TestPartResultTypeToString(TestPartResult::Type type) { + switch (type) { + case TestPartResult::kSuccess: + return "Success"; + + case TestPartResult::kNonFatalFailure: + case TestPartResult::kFatalFailure: +#ifdef _MSC_VER + return "error: "; +#else + return "Failure\n"; +#endif + default: + return "Unknown result type"; + } +} + +namespace internal { + +// Prints a TestPartResult to an std::string. +static std::string PrintTestPartResultToString( + const TestPartResult& test_part_result) { + return (Message() + << internal::FormatFileLocation(test_part_result.file_name(), + test_part_result.line_number()) + << " " << TestPartResultTypeToString(test_part_result.type()) + << test_part_result.message()).GetString(); +} + +// Prints a TestPartResult. +static void PrintTestPartResult(const TestPartResult& test_part_result) { + const std::string& result = + PrintTestPartResultToString(test_part_result); + printf("%s\n", result.c_str()); + fflush(stdout); + // If the test program runs in Visual Studio or a debugger, the + // following statements add the test part result message to the Output + // window such that the user can double-click on it to jump to the + // corresponding source code location; otherwise they do nothing. +#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE + // We don't call OutputDebugString*() on Windows Mobile, as printing + // to stdout is done by OutputDebugString() there already - we don't + // want the same message printed twice. + ::OutputDebugStringA(result.c_str()); + ::OutputDebugStringA("\n"); +#endif +} + +// class PrettyUnitTestResultPrinter + +enum GTestColor { + COLOR_DEFAULT, + COLOR_RED, + COLOR_GREEN, + COLOR_YELLOW +}; + +#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE + +// Returns the character attribute for the given color. +WORD GetColorAttribute(GTestColor color) { + switch (color) { + case COLOR_RED: return FOREGROUND_RED; + case COLOR_GREEN: return FOREGROUND_GREEN; + case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN; + default: return 0; + } +} + +#else + +// Returns the ANSI color code for the given color. COLOR_DEFAULT is +// an invalid input. +const char* GetAnsiColorCode(GTestColor color) { + switch (color) { + case COLOR_RED: return "1"; + case COLOR_GREEN: return "2"; + case COLOR_YELLOW: return "3"; + default: return NULL; + }; +} + +#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE + +// Returns true iff Google Test should use colors in the output. +bool ShouldUseColor(bool stdout_is_tty) { + const char* const gtest_color = GTEST_FLAG(color).c_str(); + + if (String::CaseInsensitiveCStringEquals(gtest_color, "auto")) { +#if GTEST_OS_WINDOWS + // On Windows the TERM variable is usually not set, but the + // console there does support colors. + return stdout_is_tty; +#else + // On non-Windows platforms, we rely on the TERM variable. + const char* const term = posix::GetEnv("TERM"); + const bool term_supports_color = + String::CStringEquals(term, "xterm") || + String::CStringEquals(term, "xterm-color") || + String::CStringEquals(term, "xterm-256color") || + String::CStringEquals(term, "screen") || + String::CStringEquals(term, "screen-256color") || + String::CStringEquals(term, "linux") || + String::CStringEquals(term, "cygwin"); + return stdout_is_tty && term_supports_color; +#endif // GTEST_OS_WINDOWS + } + + return String::CaseInsensitiveCStringEquals(gtest_color, "yes") || + String::CaseInsensitiveCStringEquals(gtest_color, "true") || + String::CaseInsensitiveCStringEquals(gtest_color, "t") || + String::CStringEquals(gtest_color, "1"); + // We take "yes", "true", "t", and "1" as meaning "yes". If the + // value is neither one of these nor "auto", we treat it as "no" to + // be conservative. +} + +// Helpers for printing colored strings to stdout. Note that on Windows, we +// cannot simply emit special characters and have the terminal change colors. +// This routine must actually emit the characters rather than return a string +// that would be colored when printed, as can be done on Linux. +void ColoredPrintf(GTestColor color, const char* fmt, ...) { + va_list args; + va_start(args, fmt); + +#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS || GTEST_OS_IOS + const bool use_color = false; +#else + static const bool in_color_mode = + ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0); + const bool use_color = in_color_mode && (color != COLOR_DEFAULT); +#endif // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_SYMBIAN || GTEST_OS_ZOS + // The '!= 0' comparison is necessary to satisfy MSVC 7.1. + + if (!use_color) { + vprintf(fmt, args); + va_end(args); + return; + } + +#if GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE + const HANDLE stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE); + + // Gets the current text color. + CONSOLE_SCREEN_BUFFER_INFO buffer_info; + GetConsoleScreenBufferInfo(stdout_handle, &buffer_info); + const WORD old_color_attrs = buffer_info.wAttributes; + + // We need to flush the stream buffers into the console before each + // SetConsoleTextAttribute call lest it affect the text that is already + // printed but has not yet reached the console. + fflush(stdout); + SetConsoleTextAttribute(stdout_handle, + GetColorAttribute(color) | FOREGROUND_INTENSITY); + vprintf(fmt, args); + + fflush(stdout); + // Restores the text color. + SetConsoleTextAttribute(stdout_handle, old_color_attrs); +#else + printf("\033[0;3%sm", GetAnsiColorCode(color)); + vprintf(fmt, args); + printf("\033[m"); // Resets the terminal to default. +#endif // GTEST_OS_WINDOWS && !GTEST_OS_WINDOWS_MOBILE + va_end(args); +} + +// Text printed in Google Test's text output and --gunit_list_tests +// output to label the type parameter and value parameter for a test. +static const char kTypeParamLabel[] = "TypeParam"; +static const char kValueParamLabel[] = "GetParam()"; + +void PrintFullTestCommentIfPresent(const TestInfo& test_info) { + const char* const type_param = test_info.type_param(); + const char* const value_param = test_info.value_param(); + + if (type_param != NULL || value_param != NULL) { + printf(", where "); + if (type_param != NULL) { + printf("%s = %s", kTypeParamLabel, type_param); + if (value_param != NULL) + printf(" and "); + } + if (value_param != NULL) { + printf("%s = %s", kValueParamLabel, value_param); + } + } +} + +// This class implements the TestEventListener interface. +// +// Class PrettyUnitTestResultPrinter is copyable. +class PrettyUnitTestResultPrinter : public TestEventListener { + public: + PrettyUnitTestResultPrinter() {} + static void PrintTestName(const char * test_case, const char * test) { + printf("%s.%s", test_case, test); + } + + // The following methods override what's in the TestEventListener class. + virtual void OnTestProgramStart(const UnitTest& /*unit_test*/) {} + virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration); + virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test); + virtual void OnEnvironmentsSetUpEnd(const UnitTest& /*unit_test*/) {} + virtual void OnTestCaseStart(const TestCase& test_case); + virtual void OnTestStart(const TestInfo& test_info); + virtual void OnTestPartResult(const TestPartResult& result); + virtual void OnTestEnd(const TestInfo& test_info); + virtual void OnTestCaseEnd(const TestCase& test_case); + virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test); + virtual void OnEnvironmentsTearDownEnd(const UnitTest& /*unit_test*/) {} + virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); + virtual void OnTestProgramEnd(const UnitTest& /*unit_test*/) {} + + private: + static void PrintFailedTests(const UnitTest& unit_test); +}; + + // Fired before each iteration of tests starts. +void PrettyUnitTestResultPrinter::OnTestIterationStart( + const UnitTest& unit_test, int iteration) { + if (GTEST_FLAG(repeat) != 1) + printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1); + + const char* const filter = GTEST_FLAG(filter).c_str(); + + // Prints the filter if it's not *. This reminds the user that some + // tests may be skipped. + if (!String::CStringEquals(filter, kUniversalFilter)) { + ColoredPrintf(COLOR_YELLOW, + "Note: %s filter = %s\n", GTEST_NAME_, filter); + } + + if (internal::ShouldShard(kTestTotalShards, kTestShardIndex, false)) { + const Int32 shard_index = Int32FromEnvOrDie(kTestShardIndex, -1); + ColoredPrintf(COLOR_YELLOW, + "Note: This is test shard %d of %s.\n", + static_cast(shard_index) + 1, + internal::posix::GetEnv(kTestTotalShards)); + } + + if (GTEST_FLAG(shuffle)) { + ColoredPrintf(COLOR_YELLOW, + "Note: Randomizing tests' orders with a seed of %d .\n", + unit_test.random_seed()); + } + + ColoredPrintf(COLOR_GREEN, "[==========] "); + printf("Running %s from %s.\n", + FormatTestCount(unit_test.test_to_run_count()).c_str(), + FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str()); + fflush(stdout); +} + +void PrettyUnitTestResultPrinter::OnEnvironmentsSetUpStart( + const UnitTest& /*unit_test*/) { + ColoredPrintf(COLOR_GREEN, "[----------] "); + printf("Global test environment set-up.\n"); + fflush(stdout); +} + +void PrettyUnitTestResultPrinter::OnTestCaseStart(const TestCase& test_case) { + const std::string counts = + FormatCountableNoun(test_case.test_to_run_count(), "test", "tests"); + ColoredPrintf(COLOR_GREEN, "[----------] "); + printf("%s from %s", counts.c_str(), test_case.name()); + if (test_case.type_param() == NULL) { + printf("\n"); + } else { + printf(", where %s = %s\n", kTypeParamLabel, test_case.type_param()); + } + fflush(stdout); +} + +void PrettyUnitTestResultPrinter::OnTestStart(const TestInfo& test_info) { + ColoredPrintf(COLOR_GREEN, "[ RUN ] "); + PrintTestName(test_info.test_case_name(), test_info.name()); + printf("\n"); + fflush(stdout); +} + +// Called after an assertion failure. +void PrettyUnitTestResultPrinter::OnTestPartResult( + const TestPartResult& result) { + // If the test part succeeded, we don't need to do anything. + if (result.type() == TestPartResult::kSuccess) + return; + + // Print failure message from the assertion (e.g. expected this and got that). + PrintTestPartResult(result); + fflush(stdout); +} + +void PrettyUnitTestResultPrinter::OnTestEnd(const TestInfo& test_info) { + if (test_info.result()->Passed()) { + ColoredPrintf(COLOR_GREEN, "[ OK ] "); + } else { + ColoredPrintf(COLOR_RED, "[ FAILED ] "); + } + PrintTestName(test_info.test_case_name(), test_info.name()); + if (test_info.result()->Failed()) + PrintFullTestCommentIfPresent(test_info); + + if (GTEST_FLAG(print_time)) { + printf(" (%s ms)\n", internal::StreamableToString( + test_info.result()->elapsed_time()).c_str()); + } else { + printf("\n"); + } + fflush(stdout); +} + +void PrettyUnitTestResultPrinter::OnTestCaseEnd(const TestCase& test_case) { + if (!GTEST_FLAG(print_time)) return; + + const std::string counts = + FormatCountableNoun(test_case.test_to_run_count(), "test", "tests"); + ColoredPrintf(COLOR_GREEN, "[----------] "); + printf("%s from %s (%s ms total)\n\n", + counts.c_str(), test_case.name(), + internal::StreamableToString(test_case.elapsed_time()).c_str()); + fflush(stdout); +} + +void PrettyUnitTestResultPrinter::OnEnvironmentsTearDownStart( + const UnitTest& /*unit_test*/) { + ColoredPrintf(COLOR_GREEN, "[----------] "); + printf("Global test environment tear-down\n"); + fflush(stdout); +} + +// Internal helper for printing the list of failed tests. +void PrettyUnitTestResultPrinter::PrintFailedTests(const UnitTest& unit_test) { + const int failed_test_count = unit_test.failed_test_count(); + if (failed_test_count == 0) { + return; + } + + for (int i = 0; i < unit_test.total_test_case_count(); ++i) { + const TestCase& test_case = *unit_test.GetTestCase(i); + if (!test_case.should_run() || (test_case.failed_test_count() == 0)) { + continue; + } + for (int j = 0; j < test_case.total_test_count(); ++j) { + const TestInfo& test_info = *test_case.GetTestInfo(j); + if (!test_info.should_run() || test_info.result()->Passed()) { + continue; + } + ColoredPrintf(COLOR_RED, "[ FAILED ] "); + printf("%s.%s", test_case.name(), test_info.name()); + PrintFullTestCommentIfPresent(test_info); + printf("\n"); + } + } +} + +void PrettyUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, + int /*iteration*/) { + ColoredPrintf(COLOR_GREEN, "[==========] "); + printf("%s from %s ran.", + FormatTestCount(unit_test.test_to_run_count()).c_str(), + FormatTestCaseCount(unit_test.test_case_to_run_count()).c_str()); + if (GTEST_FLAG(print_time)) { + printf(" (%s ms total)", + internal::StreamableToString(unit_test.elapsed_time()).c_str()); + } + printf("\n"); + ColoredPrintf(COLOR_GREEN, "[ PASSED ] "); + printf("%s.\n", FormatTestCount(unit_test.successful_test_count()).c_str()); + + int num_failures = unit_test.failed_test_count(); + if (!unit_test.Passed()) { + const int failed_test_count = unit_test.failed_test_count(); + ColoredPrintf(COLOR_RED, "[ FAILED ] "); + printf("%s, listed below:\n", FormatTestCount(failed_test_count).c_str()); + PrintFailedTests(unit_test); + printf("\n%2d FAILED %s\n", num_failures, + num_failures == 1 ? "TEST" : "TESTS"); + } + + int num_disabled = unit_test.reportable_disabled_test_count(); + if (num_disabled && !GTEST_FLAG(also_run_disabled_tests)) { + if (!num_failures) { + printf("\n"); // Add a spacer if no FAILURE banner is displayed. + } + ColoredPrintf(COLOR_YELLOW, + " YOU HAVE %d DISABLED %s\n\n", + num_disabled, + num_disabled == 1 ? "TEST" : "TESTS"); + } + // Ensure that Google Test output is printed before, e.g., heapchecker output. + fflush(stdout); +} + +// End PrettyUnitTestResultPrinter + +// class TestEventRepeater +// +// This class forwards events to other event listeners. +class TestEventRepeater : public TestEventListener { + public: + TestEventRepeater() : forwarding_enabled_(true) {} + virtual ~TestEventRepeater(); + void Append(TestEventListener *listener); + TestEventListener* Release(TestEventListener* listener); + + // Controls whether events will be forwarded to listeners_. Set to false + // in death test child processes. + bool forwarding_enabled() const { return forwarding_enabled_; } + void set_forwarding_enabled(bool enable) { forwarding_enabled_ = enable; } + + virtual void OnTestProgramStart(const UnitTest& unit_test); + virtual void OnTestIterationStart(const UnitTest& unit_test, int iteration); + virtual void OnEnvironmentsSetUpStart(const UnitTest& unit_test); + virtual void OnEnvironmentsSetUpEnd(const UnitTest& unit_test); + virtual void OnTestCaseStart(const TestCase& test_case); + virtual void OnTestStart(const TestInfo& test_info); + virtual void OnTestPartResult(const TestPartResult& result); + virtual void OnTestEnd(const TestInfo& test_info); + virtual void OnTestCaseEnd(const TestCase& test_case); + virtual void OnEnvironmentsTearDownStart(const UnitTest& unit_test); + virtual void OnEnvironmentsTearDownEnd(const UnitTest& unit_test); + virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); + virtual void OnTestProgramEnd(const UnitTest& unit_test); + + private: + // Controls whether events will be forwarded to listeners_. Set to false + // in death test child processes. + bool forwarding_enabled_; + // The list of listeners that receive events. + std::vector listeners_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(TestEventRepeater); +}; + +TestEventRepeater::~TestEventRepeater() { + ForEach(listeners_, Delete); +} + +void TestEventRepeater::Append(TestEventListener *listener) { + listeners_.push_back(listener); +} + +// TODO(vladl@google.com): Factor the search functionality into Vector::Find. +TestEventListener* TestEventRepeater::Release(TestEventListener *listener) { + for (size_t i = 0; i < listeners_.size(); ++i) { + if (listeners_[i] == listener) { + listeners_.erase(listeners_.begin() + i); + return listener; + } + } + + return NULL; +} + +// Since most methods are very similar, use macros to reduce boilerplate. +// This defines a member that forwards the call to all listeners. +#define GTEST_REPEATER_METHOD_(Name, Type) \ +void TestEventRepeater::Name(const Type& parameter) { \ + if (forwarding_enabled_) { \ + for (size_t i = 0; i < listeners_.size(); i++) { \ + listeners_[i]->Name(parameter); \ + } \ + } \ +} +// This defines a member that forwards the call to all listeners in reverse +// order. +#define GTEST_REVERSE_REPEATER_METHOD_(Name, Type) \ +void TestEventRepeater::Name(const Type& parameter) { \ + if (forwarding_enabled_) { \ + for (int i = static_cast(listeners_.size()) - 1; i >= 0; i--) { \ + listeners_[i]->Name(parameter); \ + } \ + } \ +} + +GTEST_REPEATER_METHOD_(OnTestProgramStart, UnitTest) +GTEST_REPEATER_METHOD_(OnEnvironmentsSetUpStart, UnitTest) +GTEST_REPEATER_METHOD_(OnTestCaseStart, TestCase) +GTEST_REPEATER_METHOD_(OnTestStart, TestInfo) +GTEST_REPEATER_METHOD_(OnTestPartResult, TestPartResult) +GTEST_REPEATER_METHOD_(OnEnvironmentsTearDownStart, UnitTest) +GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsSetUpEnd, UnitTest) +GTEST_REVERSE_REPEATER_METHOD_(OnEnvironmentsTearDownEnd, UnitTest) +GTEST_REVERSE_REPEATER_METHOD_(OnTestEnd, TestInfo) +GTEST_REVERSE_REPEATER_METHOD_(OnTestCaseEnd, TestCase) +GTEST_REVERSE_REPEATER_METHOD_(OnTestProgramEnd, UnitTest) + +#undef GTEST_REPEATER_METHOD_ +#undef GTEST_REVERSE_REPEATER_METHOD_ + +void TestEventRepeater::OnTestIterationStart(const UnitTest& unit_test, + int iteration) { + if (forwarding_enabled_) { + for (size_t i = 0; i < listeners_.size(); i++) { + listeners_[i]->OnTestIterationStart(unit_test, iteration); + } + } +} + +void TestEventRepeater::OnTestIterationEnd(const UnitTest& unit_test, + int iteration) { + if (forwarding_enabled_) { + for (int i = static_cast(listeners_.size()) - 1; i >= 0; i--) { + listeners_[i]->OnTestIterationEnd(unit_test, iteration); + } + } +} + +// End TestEventRepeater + +// This class generates an XML output file. +class XmlUnitTestResultPrinter : public EmptyTestEventListener { + public: + explicit XmlUnitTestResultPrinter(const char* output_file); + + virtual void OnTestIterationEnd(const UnitTest& unit_test, int iteration); + + private: + // Is c a whitespace character that is normalized to a space character + // when it appears in an XML attribute value? + static bool IsNormalizableWhitespace(char c) { + return c == 0x9 || c == 0xA || c == 0xD; + } + + // May c appear in a well-formed XML document? + static bool IsValidXmlCharacter(char c) { + return IsNormalizableWhitespace(c) || c >= 0x20; + } + + // Returns an XML-escaped copy of the input string str. If + // is_attribute is true, the text is meant to appear as an attribute + // value, and normalizable whitespace is preserved by replacing it + // with character references. + static std::string EscapeXml(const std::string& str, bool is_attribute); + + // Returns the given string with all characters invalid in XML removed. + static std::string RemoveInvalidXmlCharacters(const std::string& str); + + // Convenience wrapper around EscapeXml when str is an attribute value. + static std::string EscapeXmlAttribute(const std::string& str) { + return EscapeXml(str, true); + } + + // Convenience wrapper around EscapeXml when str is not an attribute value. + static std::string EscapeXmlText(const char* str) { + return EscapeXml(str, false); + } + + // Verifies that the given attribute belongs to the given element and + // streams the attribute as XML. + static void OutputXmlAttribute(std::ostream* stream, + const std::string& element_name, + const std::string& name, + const std::string& value); + + // Streams an XML CDATA section, escaping invalid CDATA sequences as needed. + static void OutputXmlCDataSection(::std::ostream* stream, const char* data); + + // Streams an XML representation of a TestInfo object. + static void OutputXmlTestInfo(::std::ostream* stream, + const char* test_case_name, + const TestInfo& test_info); + + // Prints an XML representation of a TestCase object + static void PrintXmlTestCase(::std::ostream* stream, + const TestCase& test_case); + + // Prints an XML summary of unit_test to output stream out. + static void PrintXmlUnitTest(::std::ostream* stream, + const UnitTest& unit_test); + + // Produces a string representing the test properties in a result as space + // delimited XML attributes based on the property key="value" pairs. + // When the std::string is not empty, it includes a space at the beginning, + // to delimit this attribute from prior attributes. + static std::string TestPropertiesAsXmlAttributes(const TestResult& result); + + // The output file. + const std::string output_file_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(XmlUnitTestResultPrinter); +}; + +// Creates a new XmlUnitTestResultPrinter. +XmlUnitTestResultPrinter::XmlUnitTestResultPrinter(const char* output_file) + : output_file_(output_file) { + if (output_file_.c_str() == NULL || output_file_.empty()) { + fprintf(stderr, "XML output file may not be null\n"); + fflush(stderr); + exit(EXIT_FAILURE); + } +} + +// Called after the unit test ends. +void XmlUnitTestResultPrinter::OnTestIterationEnd(const UnitTest& unit_test, + int /*iteration*/) { + FILE* xmlout = NULL; + FilePath output_file(output_file_); + FilePath output_dir(output_file.RemoveFileName()); + + if (output_dir.CreateDirectoriesRecursively()) { + xmlout = posix::FOpen(output_file_.c_str(), "w"); + } + if (xmlout == NULL) { + // TODO(wan): report the reason of the failure. + // + // We don't do it for now as: + // + // 1. There is no urgent need for it. + // 2. It's a bit involved to make the errno variable thread-safe on + // all three operating systems (Linux, Windows, and Mac OS). + // 3. To interpret the meaning of errno in a thread-safe way, + // we need the strerror_r() function, which is not available on + // Windows. + fprintf(stderr, + "Unable to open file \"%s\"\n", + output_file_.c_str()); + fflush(stderr); + exit(EXIT_FAILURE); + } + std::stringstream stream; + PrintXmlUnitTest(&stream, unit_test); + fprintf(xmlout, "%s", StringStreamToString(&stream).c_str()); + fclose(xmlout); +} + +// Returns an XML-escaped copy of the input string str. If is_attribute +// is true, the text is meant to appear as an attribute value, and +// normalizable whitespace is preserved by replacing it with character +// references. +// +// Invalid XML characters in str, if any, are stripped from the output. +// It is expected that most, if not all, of the text processed by this +// module will consist of ordinary English text. +// If this module is ever modified to produce version 1.1 XML output, +// most invalid characters can be retained using character references. +// TODO(wan): It might be nice to have a minimally invasive, human-readable +// escaping scheme for invalid characters, rather than dropping them. +std::string XmlUnitTestResultPrinter::EscapeXml( + const std::string& str, bool is_attribute) { + Message m; + + for (size_t i = 0; i < str.size(); ++i) { + const char ch = str[i]; + switch (ch) { + case '<': + m << "<"; + break; + case '>': + m << ">"; + break; + case '&': + m << "&"; + break; + case '\'': + if (is_attribute) + m << "'"; + else + m << '\''; + break; + case '"': + if (is_attribute) + m << """; + else + m << '"'; + break; + default: + if (IsValidXmlCharacter(ch)) { + if (is_attribute && IsNormalizableWhitespace(ch)) + m << "&#x" << String::FormatByte(static_cast(ch)) + << ";"; + else + m << ch; + } + break; + } + } + + return m.GetString(); +} + +// Returns the given string with all characters invalid in XML removed. +// Currently invalid characters are dropped from the string. An +// alternative is to replace them with certain characters such as . or ?. +std::string XmlUnitTestResultPrinter::RemoveInvalidXmlCharacters( + const std::string& str) { + std::string output; + output.reserve(str.size()); + for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) + if (IsValidXmlCharacter(*it)) + output.push_back(*it); + + return output; +} + +// The following routines generate an XML representation of a UnitTest +// object. +// +// This is how Google Test concepts map to the DTD: +// +// <-- corresponds to a UnitTest object +// <-- corresponds to a TestCase object +// <-- corresponds to a TestInfo object +// ... +// ... +// ... +// <-- individual assertion failures +// +// +// + +// Formats the given time in milliseconds as seconds. +std::string FormatTimeInMillisAsSeconds(TimeInMillis ms) { + ::std::stringstream ss; + ss << ms/1000.0; + return ss.str(); +} + +// Converts the given epoch time in milliseconds to a date string in the ISO +// 8601 format, without the timezone information. +std::string FormatEpochTimeInMillisAsIso8601(TimeInMillis ms) { + // Using non-reentrant version as localtime_r is not portable. + time_t seconds = static_cast(ms / 1000); +#ifdef _MSC_VER +# pragma warning(push) // Saves the current warning state. +# pragma warning(disable:4996) // Temporarily disables warning 4996 + // (function or variable may be unsafe). + const struct tm* const time_struct = localtime(&seconds); // NOLINT +# pragma warning(pop) // Restores the warning state again. +#else + const struct tm* const time_struct = localtime(&seconds); // NOLINT +#endif + if (time_struct == NULL) + return ""; // Invalid ms value + + // YYYY-MM-DDThh:mm:ss + return StreamableToString(time_struct->tm_year + 1900) + "-" + + String::FormatIntWidth2(time_struct->tm_mon + 1) + "-" + + String::FormatIntWidth2(time_struct->tm_mday) + "T" + + String::FormatIntWidth2(time_struct->tm_hour) + ":" + + String::FormatIntWidth2(time_struct->tm_min) + ":" + + String::FormatIntWidth2(time_struct->tm_sec); +} + +// Streams an XML CDATA section, escaping invalid CDATA sequences as needed. +void XmlUnitTestResultPrinter::OutputXmlCDataSection(::std::ostream* stream, + const char* data) { + const char* segment = data; + *stream << ""); + if (next_segment != NULL) { + stream->write( + segment, static_cast(next_segment - segment)); + *stream << "]]>]]>"); + } else { + *stream << segment; + break; + } + } + *stream << "]]>"; +} + +void XmlUnitTestResultPrinter::OutputXmlAttribute( + std::ostream* stream, + const std::string& element_name, + const std::string& name, + const std::string& value) { + const std::vector& allowed_names = + GetReservedAttributesForElement(element_name); + + GTEST_CHECK_(std::find(allowed_names.begin(), allowed_names.end(), name) != + allowed_names.end()) + << "Attribute " << name << " is not allowed for element <" << element_name + << ">."; + + *stream << " " << name << "=\"" << EscapeXmlAttribute(value) << "\""; +} + +// Prints an XML representation of a TestInfo object. +// TODO(wan): There is also value in printing properties with the plain printer. +void XmlUnitTestResultPrinter::OutputXmlTestInfo(::std::ostream* stream, + const char* test_case_name, + const TestInfo& test_info) { + const TestResult& result = *test_info.result(); + const std::string kTestcase = "testcase"; + + *stream << " \n"; + } + const string location = internal::FormatCompilerIndependentFileLocation( + part.file_name(), part.line_number()); + const string summary = location + "\n" + part.summary(); + *stream << " "; + const string detail = location + "\n" + part.message(); + OutputXmlCDataSection(stream, RemoveInvalidXmlCharacters(detail).c_str()); + *stream << "\n"; + } + } + + if (failures == 0) + *stream << " />\n"; + else + *stream << " \n"; +} + +// Prints an XML representation of a TestCase object +void XmlUnitTestResultPrinter::PrintXmlTestCase(std::ostream* stream, + const TestCase& test_case) { + const std::string kTestsuite = "testsuite"; + *stream << " <" << kTestsuite; + OutputXmlAttribute(stream, kTestsuite, "name", test_case.name()); + OutputXmlAttribute(stream, kTestsuite, "tests", + StreamableToString(test_case.reportable_test_count())); + OutputXmlAttribute(stream, kTestsuite, "failures", + StreamableToString(test_case.failed_test_count())); + OutputXmlAttribute( + stream, kTestsuite, "disabled", + StreamableToString(test_case.reportable_disabled_test_count())); + OutputXmlAttribute(stream, kTestsuite, "errors", "0"); + OutputXmlAttribute(stream, kTestsuite, "time", + FormatTimeInMillisAsSeconds(test_case.elapsed_time())); + *stream << TestPropertiesAsXmlAttributes(test_case.ad_hoc_test_result()) + << ">\n"; + + for (int i = 0; i < test_case.total_test_count(); ++i) { + if (test_case.GetTestInfo(i)->is_reportable()) + OutputXmlTestInfo(stream, test_case.name(), *test_case.GetTestInfo(i)); + } + *stream << " \n"; +} + +// Prints an XML summary of unit_test to output stream out. +void XmlUnitTestResultPrinter::PrintXmlUnitTest(std::ostream* stream, + const UnitTest& unit_test) { + const std::string kTestsuites = "testsuites"; + + *stream << "\n"; + *stream << "<" << kTestsuites; + + OutputXmlAttribute(stream, kTestsuites, "tests", + StreamableToString(unit_test.reportable_test_count())); + OutputXmlAttribute(stream, kTestsuites, "failures", + StreamableToString(unit_test.failed_test_count())); + OutputXmlAttribute( + stream, kTestsuites, "disabled", + StreamableToString(unit_test.reportable_disabled_test_count())); + OutputXmlAttribute(stream, kTestsuites, "errors", "0"); + OutputXmlAttribute( + stream, kTestsuites, "timestamp", + FormatEpochTimeInMillisAsIso8601(unit_test.start_timestamp())); + OutputXmlAttribute(stream, kTestsuites, "time", + FormatTimeInMillisAsSeconds(unit_test.elapsed_time())); + + if (GTEST_FLAG(shuffle)) { + OutputXmlAttribute(stream, kTestsuites, "random_seed", + StreamableToString(unit_test.random_seed())); + } + + *stream << TestPropertiesAsXmlAttributes(unit_test.ad_hoc_test_result()); + + OutputXmlAttribute(stream, kTestsuites, "name", "AllTests"); + *stream << ">\n"; + + for (int i = 0; i < unit_test.total_test_case_count(); ++i) { + if (unit_test.GetTestCase(i)->reportable_test_count() > 0) + PrintXmlTestCase(stream, *unit_test.GetTestCase(i)); + } + *stream << "\n"; +} + +// Produces a string representing the test properties in a result as space +// delimited XML attributes based on the property key="value" pairs. +std::string XmlUnitTestResultPrinter::TestPropertiesAsXmlAttributes( + const TestResult& result) { + Message attributes; + for (int i = 0; i < result.test_property_count(); ++i) { + const TestProperty& property = result.GetTestProperty(i); + attributes << " " << property.key() << "=" + << "\"" << EscapeXmlAttribute(property.value()) << "\""; + } + return attributes.GetString(); +} + +// End XmlUnitTestResultPrinter + +#if GTEST_CAN_STREAM_RESULTS_ + +// Checks if str contains '=', '&', '%' or '\n' characters. If yes, +// replaces them by "%xx" where xx is their hexadecimal value. For +// example, replaces "=" with "%3D". This algorithm is O(strlen(str)) +// in both time and space -- important as the input str may contain an +// arbitrarily long test failure message and stack trace. +string StreamingListener::UrlEncode(const char* str) { + string result; + result.reserve(strlen(str) + 1); + for (char ch = *str; ch != '\0'; ch = *++str) { + switch (ch) { + case '%': + case '=': + case '&': + case '\n': + result.append("%" + String::FormatByte(static_cast(ch))); + break; + default: + result.push_back(ch); + break; + } + } + return result; +} + +void StreamingListener::SocketWriter::MakeConnection() { + GTEST_CHECK_(sockfd_ == -1) + << "MakeConnection() can't be called when there is already a connection."; + + addrinfo hints; + memset(&hints, 0, sizeof(hints)); + hints.ai_family = AF_UNSPEC; // To allow both IPv4 and IPv6 addresses. + hints.ai_socktype = SOCK_STREAM; + addrinfo* servinfo = NULL; + + // Use the getaddrinfo() to get a linked list of IP addresses for + // the given host name. + const int error_num = getaddrinfo( + host_name_.c_str(), port_num_.c_str(), &hints, &servinfo); + if (error_num != 0) { + GTEST_LOG_(WARNING) << "stream_result_to: getaddrinfo() failed: " + << gai_strerror(error_num); + } + + // Loop through all the results and connect to the first we can. + for (addrinfo* cur_addr = servinfo; sockfd_ == -1 && cur_addr != NULL; + cur_addr = cur_addr->ai_next) { + sockfd_ = socket( + cur_addr->ai_family, cur_addr->ai_socktype, cur_addr->ai_protocol); + if (sockfd_ != -1) { + // Connect the client socket to the server socket. + if (connect(sockfd_, cur_addr->ai_addr, cur_addr->ai_addrlen) == -1) { + close(sockfd_); + sockfd_ = -1; + } + } + } + + freeaddrinfo(servinfo); // all done with this structure + + if (sockfd_ == -1) { + GTEST_LOG_(WARNING) << "stream_result_to: failed to connect to " + << host_name_ << ":" << port_num_; + } +} + +// End of class Streaming Listener +#endif // GTEST_CAN_STREAM_RESULTS__ + +// Class ScopedTrace + +// Pushes the given source file location and message onto a per-thread +// trace stack maintained by Google Test. +ScopedTrace::ScopedTrace(const char* file, int line, const Message& message) + GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) { + TraceInfo trace; + trace.file = file; + trace.line = line; + trace.message = message.GetString(); + + UnitTest::GetInstance()->PushGTestTrace(trace); +} + +// Pops the info pushed by the c'tor. +ScopedTrace::~ScopedTrace() + GTEST_LOCK_EXCLUDED_(&UnitTest::mutex_) { + UnitTest::GetInstance()->PopGTestTrace(); +} + + +// class OsStackTraceGetter + +// Returns the current OS stack trace as an std::string. Parameters: +// +// max_depth - the maximum number of stack frames to be included +// in the trace. +// skip_count - the number of top frames to be skipped; doesn't count +// against max_depth. +// +string OsStackTraceGetter::CurrentStackTrace(int /* max_depth */, + int /* skip_count */) + GTEST_LOCK_EXCLUDED_(mutex_) { + return ""; +} + +void OsStackTraceGetter::UponLeavingGTest() + GTEST_LOCK_EXCLUDED_(mutex_) { +} + +const char* const +OsStackTraceGetter::kElidedFramesMarker = + "... " GTEST_NAME_ " internal frames ..."; + +// A helper class that creates the premature-exit file in its +// constructor and deletes the file in its destructor. +class ScopedPrematureExitFile { + public: + explicit ScopedPrematureExitFile(const char* premature_exit_filepath) + : premature_exit_filepath_(premature_exit_filepath) { + // If a path to the premature-exit file is specified... + if (premature_exit_filepath != NULL && *premature_exit_filepath != '\0') { + // create the file with a single "0" character in it. I/O + // errors are ignored as there's nothing better we can do and we + // don't want to fail the test because of this. + FILE* pfile = posix::FOpen(premature_exit_filepath, "w"); + fwrite("0", 1, 1, pfile); + fclose(pfile); + } + } + + ~ScopedPrematureExitFile() { + if (premature_exit_filepath_ != NULL && *premature_exit_filepath_ != '\0') { + remove(premature_exit_filepath_); + } + } + + private: + const char* const premature_exit_filepath_; + + GTEST_DISALLOW_COPY_AND_ASSIGN_(ScopedPrematureExitFile); +}; + +} // namespace internal + +// class TestEventListeners + +TestEventListeners::TestEventListeners() + : repeater_(new internal::TestEventRepeater()), + default_result_printer_(NULL), + default_xml_generator_(NULL) { +} + +TestEventListeners::~TestEventListeners() { delete repeater_; } + +// Returns the standard listener responsible for the default console +// output. Can be removed from the listeners list to shut down default +// console output. Note that removing this object from the listener list +// with Release transfers its ownership to the user. +void TestEventListeners::Append(TestEventListener* listener) { + repeater_->Append(listener); +} + +// Removes the given event listener from the list and returns it. It then +// becomes the caller's responsibility to delete the listener. Returns +// NULL if the listener is not found in the list. +TestEventListener* TestEventListeners::Release(TestEventListener* listener) { + if (listener == default_result_printer_) + default_result_printer_ = NULL; + else if (listener == default_xml_generator_) + default_xml_generator_ = NULL; + return repeater_->Release(listener); +} + +// Returns repeater that broadcasts the TestEventListener events to all +// subscribers. +TestEventListener* TestEventListeners::repeater() { return repeater_; } + +// Sets the default_result_printer attribute to the provided listener. +// The listener is also added to the listener list and previous +// default_result_printer is removed from it and deleted. The listener can +// also be NULL in which case it will not be added to the list. Does +// nothing if the previous and the current listener objects are the same. +void TestEventListeners::SetDefaultResultPrinter(TestEventListener* listener) { + if (default_result_printer_ != listener) { + // It is an error to pass this method a listener that is already in the + // list. + delete Release(default_result_printer_); + default_result_printer_ = listener; + if (listener != NULL) + Append(listener); + } +} + +// Sets the default_xml_generator attribute to the provided listener. The +// listener is also added to the listener list and previous +// default_xml_generator is removed from it and deleted. The listener can +// also be NULL in which case it will not be added to the list. Does +// nothing if the previous and the current listener objects are the same. +void TestEventListeners::SetDefaultXmlGenerator(TestEventListener* listener) { + if (default_xml_generator_ != listener) { + // It is an error to pass this method a listener that is already in the + // list. + delete Release(default_xml_generator_); + default_xml_generator_ = listener; + if (listener != NULL) + Append(listener); + } +} + +// Controls whether events will be forwarded by the repeater to the +// listeners in the list. +bool TestEventListeners::EventForwardingEnabled() const { + return repeater_->forwarding_enabled(); +} + +void TestEventListeners::SuppressEventForwarding() { + repeater_->set_forwarding_enabled(false); +} + +// class UnitTest + +// Gets the singleton UnitTest object. The first time this method is +// called, a UnitTest object is constructed and returned. Consecutive +// calls will return the same object. +// +// We don't protect this under mutex_ as a user is not supposed to +// call this before main() starts, from which point on the return +// value will never change. +UnitTest* UnitTest::GetInstance() { + // When compiled with MSVC 7.1 in optimized mode, destroying the + // UnitTest object upon exiting the program messes up the exit code, + // causing successful tests to appear failed. We have to use a + // different implementation in this case to bypass the compiler bug. + // This implementation makes the compiler happy, at the cost of + // leaking the UnitTest object. + + // CodeGear C++Builder insists on a public destructor for the + // default implementation. Use this implementation to keep good OO + // design with private destructor. + +#if (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) + static UnitTest* const instance = new UnitTest; + return instance; +#else + static UnitTest instance; + return &instance; +#endif // (_MSC_VER == 1310 && !defined(_DEBUG)) || defined(__BORLANDC__) +} + +// Gets the number of successful test cases. +int UnitTest::successful_test_case_count() const { + return impl()->successful_test_case_count(); +} + +// Gets the number of failed test cases. +int UnitTest::failed_test_case_count() const { + return impl()->failed_test_case_count(); +} + +// Gets the number of all test cases. +int UnitTest::total_test_case_count() const { + return impl()->total_test_case_count(); +} + +// Gets the number of all test cases that contain at least one test +// that should run. +int UnitTest::test_case_to_run_count() const { + return impl()->test_case_to_run_count(); +} + +// Gets the number of successful tests. +int UnitTest::successful_test_count() const { + return impl()->successful_test_count(); +} + +// Gets the number of failed tests. +int UnitTest::failed_test_count() const { return impl()->failed_test_count(); } + +// Gets the number of disabled tests that will be reported in the XML report. +int UnitTest::reportable_disabled_test_count() const { + return impl()->reportable_disabled_test_count(); +} + +// Gets the number of disabled tests. +int UnitTest::disabled_test_count() const { + return impl()->disabled_test_count(); +} + +// Gets the number of tests to be printed in the XML report. +int UnitTest::reportable_test_count() const { + return impl()->reportable_test_count(); +} + +// Gets the number of all tests. +int UnitTest::total_test_count() const { return impl()->total_test_count(); } + +// Gets the number of tests that should run. +int UnitTest::test_to_run_count() const { return impl()->test_to_run_count(); } + +// Gets the time of the test program start, in ms from the start of the +// UNIX epoch. +internal::TimeInMillis UnitTest::start_timestamp() const { + return impl()->start_timestamp(); +} + +// Gets the elapsed time, in milliseconds. +internal::TimeInMillis UnitTest::elapsed_time() const { + return impl()->elapsed_time(); +} + +// Returns true iff the unit test passed (i.e. all test cases passed). +bool UnitTest::Passed() const { return impl()->Passed(); } + +// Returns true iff the unit test failed (i.e. some test case failed +// or something outside of all tests failed). +bool UnitTest::Failed() const { return impl()->Failed(); } + +// Gets the i-th test case among all the test cases. i can range from 0 to +// total_test_case_count() - 1. If i is not in that range, returns NULL. +const TestCase* UnitTest::GetTestCase(int i) const { + return impl()->GetTestCase(i); +} + +// Returns the TestResult containing information on test failures and +// properties logged outside of individual test cases. +const TestResult& UnitTest::ad_hoc_test_result() const { + return *impl()->ad_hoc_test_result(); +} + +// Gets the i-th test case among all the test cases. i can range from 0 to +// total_test_case_count() - 1. If i is not in that range, returns NULL. +TestCase* UnitTest::GetMutableTestCase(int i) { + return impl()->GetMutableTestCase(i); +} + +// Returns the list of event listeners that can be used to track events +// inside Google Test. +TestEventListeners& UnitTest::listeners() { + return *impl()->listeners(); +} + +// Registers and returns a global test environment. When a test +// program is run, all global test environments will be set-up in the +// order they were registered. After all tests in the program have +// finished, all global test environments will be torn-down in the +// *reverse* order they were registered. +// +// The UnitTest object takes ownership of the given environment. +// +// We don't protect this under mutex_, as we only support calling it +// from the main thread. +Environment* UnitTest::AddEnvironment(Environment* env) { + if (env == NULL) { + return NULL; + } + + impl_->environments().push_back(env); + return env; +} + +// Adds a TestPartResult to the current TestResult object. All Google Test +// assertion macros (e.g. ASSERT_TRUE, EXPECT_EQ, etc) eventually call +// this to report their results. The user code should use the +// assertion macros instead of calling this directly. +void UnitTest::AddTestPartResult( + TestPartResult::Type result_type, + const char* file_name, + int line_number, + const std::string& message, + const std::string& os_stack_trace) GTEST_LOCK_EXCLUDED_(mutex_) { + Message msg; + msg << message; + + internal::MutexLock lock(&mutex_); + if (impl_->gtest_trace_stack().size() > 0) { + msg << "\n" << GTEST_NAME_ << " trace:"; + + for (int i = static_cast(impl_->gtest_trace_stack().size()); + i > 0; --i) { + const internal::TraceInfo& trace = impl_->gtest_trace_stack()[i - 1]; + msg << "\n" << internal::FormatFileLocation(trace.file, trace.line) + << " " << trace.message; + } + } + + if (os_stack_trace.c_str() != NULL && !os_stack_trace.empty()) { + msg << internal::kStackTraceMarker << os_stack_trace; + } + + const TestPartResult result = + TestPartResult(result_type, file_name, line_number, + msg.GetString().c_str()); + impl_->GetTestPartResultReporterForCurrentThread()-> + ReportTestPartResult(result); + + if (result_type != TestPartResult::kSuccess) { + // gtest_break_on_failure takes precedence over + // gtest_throw_on_failure. This allows a user to set the latter + // in the code (perhaps in order to use Google Test assertions + // with another testing framework) and specify the former on the + // command line for debugging. + if (GTEST_FLAG(break_on_failure)) { +#if GTEST_OS_WINDOWS + // Using DebugBreak on Windows allows gtest to still break into a debugger + // when a failure happens and both the --gtest_break_on_failure and + // the --gtest_catch_exceptions flags are specified. + DebugBreak(); +#else + // Dereference NULL through a volatile pointer to prevent the compiler + // from removing. We use this rather than abort() or __builtin_trap() for + // portability: Symbian doesn't implement abort() well, and some debuggers + // don't correctly trap abort(). + *static_cast(NULL) = 1; +#endif // GTEST_OS_WINDOWS + } else if (GTEST_FLAG(throw_on_failure)) { +#if GTEST_HAS_EXCEPTIONS + throw internal::GoogleTestFailureException(result); +#else + // We cannot call abort() as it generates a pop-up in debug mode + // that cannot be suppressed in VC 7.1 or below. + exit(1); +#endif + } + } +} + +// Adds a TestProperty to the current TestResult object when invoked from +// inside a test, to current TestCase's ad_hoc_test_result_ when invoked +// from SetUpTestCase or TearDownTestCase, or to the global property set +// when invoked elsewhere. If the result already contains a property with +// the same key, the value will be updated. +void UnitTest::RecordProperty(const std::string& key, + const std::string& value) { + impl_->RecordProperty(TestProperty(key, value)); +} + +// Runs all tests in this UnitTest object and prints the result. +// Returns 0 if successful, or 1 otherwise. +// +// We don't protect this under mutex_, as we only support calling it +// from the main thread. +int UnitTest::Run() { + const bool in_death_test_child_process = + internal::GTEST_FLAG(internal_run_death_test).length() > 0; + + // Google Test implements this protocol for catching that a test + // program exits before returning control to Google Test: + // + // 1. Upon start, Google Test creates a file whose absolute path + // is specified by the environment variable + // TEST_PREMATURE_EXIT_FILE. + // 2. When Google Test has finished its work, it deletes the file. + // + // This allows a test runner to set TEST_PREMATURE_EXIT_FILE before + // running a Google-Test-based test program and check the existence + // of the file at the end of the test execution to see if it has + // exited prematurely. + + // If we are in the child process of a death test, don't + // create/delete the premature exit file, as doing so is unnecessary + // and will confuse the parent process. Otherwise, create/delete + // the file upon entering/leaving this function. If the program + // somehow exits before this function has a chance to return, the + // premature-exit file will be left undeleted, causing a test runner + // that understands the premature-exit-file protocol to report the + // test as having failed. + const internal::ScopedPrematureExitFile premature_exit_file( + in_death_test_child_process ? + NULL : internal::posix::GetEnv("TEST_PREMATURE_EXIT_FILE")); + + // Captures the value of GTEST_FLAG(catch_exceptions). This value will be + // used for the duration of the program. + impl()->set_catch_exceptions(GTEST_FLAG(catch_exceptions)); + +#if GTEST_HAS_SEH + // Either the user wants Google Test to catch exceptions thrown by the + // tests or this is executing in the context of death test child + // process. In either case the user does not want to see pop-up dialogs + // about crashes - they are expected. + if (impl()->catch_exceptions() || in_death_test_child_process) { +# if !GTEST_OS_WINDOWS_MOBILE + // SetErrorMode doesn't exist on CE. + SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT | + SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX); +# endif // !GTEST_OS_WINDOWS_MOBILE + +# if (defined(_MSC_VER) || GTEST_OS_WINDOWS_MINGW) && !GTEST_OS_WINDOWS_MOBILE + // Death test children can be terminated with _abort(). On Windows, + // _abort() can show a dialog with a warning message. This forces the + // abort message to go to stderr instead. + _set_error_mode(_OUT_TO_STDERR); +# endif + +# if _MSC_VER >= 1400 && !GTEST_OS_WINDOWS_MOBILE + // In the debug version, Visual Studio pops up a separate dialog + // offering a choice to debug the aborted program. We need to suppress + // this dialog or it will pop up for every EXPECT/ASSERT_DEATH statement + // executed. Google Test will notify the user of any unexpected + // failure via stderr. + // + // VC++ doesn't define _set_abort_behavior() prior to the version 8.0. + // Users of prior VC versions shall suffer the agony and pain of + // clicking through the countless debug dialogs. + // TODO(vladl@google.com): find a way to suppress the abort dialog() in the + // debug mode when compiled with VC 7.1 or lower. + if (!GTEST_FLAG(break_on_failure)) + _set_abort_behavior( + 0x0, // Clear the following flags: + _WRITE_ABORT_MSG | _CALL_REPORTFAULT); // pop-up window, core dump. +# endif + } +#endif // GTEST_HAS_SEH + + return internal::HandleExceptionsInMethodIfSupported( + impl(), + &internal::UnitTestImpl::RunAllTests, + "auxiliary test code (environments or event listeners)") ? 0 : 1; +} + +// Returns the working directory when the first TEST() or TEST_F() was +// executed. +const char* UnitTest::original_working_dir() const { + return impl_->original_working_dir_.c_str(); +} + +// Returns the TestCase object for the test that's currently running, +// or NULL if no test is running. +const TestCase* UnitTest::current_test_case() const + GTEST_LOCK_EXCLUDED_(mutex_) { + internal::MutexLock lock(&mutex_); + return impl_->current_test_case(); +} + +// Returns the TestInfo object for the test that's currently running, +// or NULL if no test is running. +const TestInfo* UnitTest::current_test_info() const + GTEST_LOCK_EXCLUDED_(mutex_) { + internal::MutexLock lock(&mutex_); + return impl_->current_test_info(); +} + +// Returns the random seed used at the start of the current test run. +int UnitTest::random_seed() const { return impl_->random_seed(); } + +#if GTEST_HAS_PARAM_TEST +// Returns ParameterizedTestCaseRegistry object used to keep track of +// value-parameterized tests and instantiate and register them. +internal::ParameterizedTestCaseRegistry& + UnitTest::parameterized_test_registry() + GTEST_LOCK_EXCLUDED_(mutex_) { + return impl_->parameterized_test_registry(); +} +#endif // GTEST_HAS_PARAM_TEST + +// Creates an empty UnitTest. +UnitTest::UnitTest() { + impl_ = new internal::UnitTestImpl(this); +} + +// Destructor of UnitTest. +UnitTest::~UnitTest() { + delete impl_; +} + +// Pushes a trace defined by SCOPED_TRACE() on to the per-thread +// Google Test trace stack. +void UnitTest::PushGTestTrace(const internal::TraceInfo& trace) + GTEST_LOCK_EXCLUDED_(mutex_) { + internal::MutexLock lock(&mutex_); + impl_->gtest_trace_stack().push_back(trace); +} + +// Pops a trace from the per-thread Google Test trace stack. +void UnitTest::PopGTestTrace() + GTEST_LOCK_EXCLUDED_(mutex_) { + internal::MutexLock lock(&mutex_); + impl_->gtest_trace_stack().pop_back(); +} + +namespace internal { + +UnitTestImpl::UnitTestImpl(UnitTest* parent) + : parent_(parent), +#ifdef _MSC_VER +# pragma warning(push) // Saves the current warning state. +# pragma warning(disable:4355) // Temporarily disables warning 4355 + // (using this in initializer). + default_global_test_part_result_reporter_(this), + default_per_thread_test_part_result_reporter_(this), +# pragma warning(pop) // Restores the warning state again. +#else + default_global_test_part_result_reporter_(this), + default_per_thread_test_part_result_reporter_(this), +#endif // _MSC_VER + global_test_part_result_repoter_( + &default_global_test_part_result_reporter_), + per_thread_test_part_result_reporter_( + &default_per_thread_test_part_result_reporter_), +#if GTEST_HAS_PARAM_TEST + parameterized_test_registry_(), + parameterized_tests_registered_(false), +#endif // GTEST_HAS_PARAM_TEST + last_death_test_case_(-1), + current_test_case_(NULL), + current_test_info_(NULL), + ad_hoc_test_result_(), + os_stack_trace_getter_(NULL), + post_flag_parse_init_performed_(false), + random_seed_(0), // Will be overridden by the flag before first use. + random_(0), // Will be reseeded before first use. + start_timestamp_(0), + elapsed_time_(0), +#if GTEST_HAS_DEATH_TEST + death_test_factory_(new DefaultDeathTestFactory), +#endif + // Will be overridden by the flag before first use. + catch_exceptions_(false) { + listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter); +} + +UnitTestImpl::~UnitTestImpl() { + // Deletes every TestCase. + ForEach(test_cases_, internal::Delete); + + // Deletes every Environment. + ForEach(environments_, internal::Delete); + + delete os_stack_trace_getter_; +} + +// Adds a TestProperty to the current TestResult object when invoked in a +// context of a test, to current test case's ad_hoc_test_result when invoke +// from SetUpTestCase/TearDownTestCase, or to the global property set +// otherwise. If the result already contains a property with the same key, +// the value will be updated. +void UnitTestImpl::RecordProperty(const TestProperty& test_property) { + std::string xml_element; + TestResult* test_result; // TestResult appropriate for property recording. + + if (current_test_info_ != NULL) { + xml_element = "testcase"; + test_result = &(current_test_info_->result_); + } else if (current_test_case_ != NULL) { + xml_element = "testsuite"; + test_result = &(current_test_case_->ad_hoc_test_result_); + } else { + xml_element = "testsuites"; + test_result = &ad_hoc_test_result_; + } + test_result->RecordProperty(xml_element, test_property); +} + +#if GTEST_HAS_DEATH_TEST +// Disables event forwarding if the control is currently in a death test +// subprocess. Must not be called before InitGoogleTest. +void UnitTestImpl::SuppressTestEventsIfInSubprocess() { + if (internal_run_death_test_flag_.get() != NULL) + listeners()->SuppressEventForwarding(); +} +#endif // GTEST_HAS_DEATH_TEST + +// Initializes event listeners performing XML output as specified by +// UnitTestOptions. Must not be called before InitGoogleTest. +void UnitTestImpl::ConfigureXmlOutput() { + const std::string& output_format = UnitTestOptions::GetOutputFormat(); + if (output_format == "xml") { + listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter( + UnitTestOptions::GetAbsolutePathToOutputFile().c_str())); + } else if (output_format != "") { + printf("WARNING: unrecognized output format \"%s\" ignored.\n", + output_format.c_str()); + fflush(stdout); + } +} + +#if GTEST_CAN_STREAM_RESULTS_ +// Initializes event listeners for streaming test results in string form. +// Must not be called before InitGoogleTest. +void UnitTestImpl::ConfigureStreamingOutput() { + const std::string& target = GTEST_FLAG(stream_result_to); + if (!target.empty()) { + const size_t pos = target.find(':'); + if (pos != std::string::npos) { + listeners()->Append(new StreamingListener(target.substr(0, pos), + target.substr(pos+1))); + } else { + printf("WARNING: unrecognized streaming target \"%s\" ignored.\n", + target.c_str()); + fflush(stdout); + } + } +} +#endif // GTEST_CAN_STREAM_RESULTS_ + +// Performs initialization dependent upon flag values obtained in +// ParseGoogleTestFlagsOnly. Is called from InitGoogleTest after the call to +// ParseGoogleTestFlagsOnly. In case a user neglects to call InitGoogleTest +// this function is also called from RunAllTests. Since this function can be +// called more than once, it has to be idempotent. +void UnitTestImpl::PostFlagParsingInit() { + // Ensures that this function does not execute more than once. + if (!post_flag_parse_init_performed_) { + post_flag_parse_init_performed_ = true; + +#if GTEST_HAS_DEATH_TEST + InitDeathTestSubprocessControlInfo(); + SuppressTestEventsIfInSubprocess(); +#endif // GTEST_HAS_DEATH_TEST + + // Registers parameterized tests. This makes parameterized tests + // available to the UnitTest reflection API without running + // RUN_ALL_TESTS. + RegisterParameterizedTests(); + + // Configures listeners for XML output. This makes it possible for users + // to shut down the default XML output before invoking RUN_ALL_TESTS. + ConfigureXmlOutput(); + +#if GTEST_CAN_STREAM_RESULTS_ + // Configures listeners for streaming test results to the specified server. + ConfigureStreamingOutput(); +#endif // GTEST_CAN_STREAM_RESULTS_ + } +} + +// A predicate that checks the name of a TestCase against a known +// value. +// +// This is used for implementation of the UnitTest class only. We put +// it in the anonymous namespace to prevent polluting the outer +// namespace. +// +// TestCaseNameIs is copyable. +class TestCaseNameIs { + public: + // Constructor. + explicit TestCaseNameIs(const std::string& name) + : name_(name) {} + + // Returns true iff the name of test_case matches name_. + bool operator()(const TestCase* test_case) const { + return test_case != NULL && strcmp(test_case->name(), name_.c_str()) == 0; + } + + private: + std::string name_; +}; + +// Finds and returns a TestCase with the given name. If one doesn't +// exist, creates one and returns it. It's the CALLER'S +// RESPONSIBILITY to ensure that this function is only called WHEN THE +// TESTS ARE NOT SHUFFLED. +// +// Arguments: +// +// test_case_name: name of the test case +// type_param: the name of the test case's type parameter, or NULL if +// this is not a typed or a type-parameterized test case. +// set_up_tc: pointer to the function that sets up the test case +// tear_down_tc: pointer to the function that tears down the test case +TestCase* UnitTestImpl::GetTestCase(const char* test_case_name, + const char* type_param, + Test::SetUpTestCaseFunc set_up_tc, + Test::TearDownTestCaseFunc tear_down_tc) { + // Can we find a TestCase with the given name? + const std::vector::const_iterator test_case = + std::find_if(test_cases_.begin(), test_cases_.end(), + TestCaseNameIs(test_case_name)); + + if (test_case != test_cases_.end()) + return *test_case; + + // No. Let's create one. + TestCase* const new_test_case = + new TestCase(test_case_name, type_param, set_up_tc, tear_down_tc); + + // Is this a death test case? + if (internal::UnitTestOptions::MatchesFilter(test_case_name, + kDeathTestCaseFilter)) { + // Yes. Inserts the test case after the last death test case + // defined so far. This only works when the test cases haven't + // been shuffled. Otherwise we may end up running a death test + // after a non-death test. + ++last_death_test_case_; + test_cases_.insert(test_cases_.begin() + last_death_test_case_, + new_test_case); + } else { + // No. Appends to the end of the list. + test_cases_.push_back(new_test_case); + } + + test_case_indices_.push_back(static_cast(test_case_indices_.size())); + return new_test_case; +} + +// Helpers for setting up / tearing down the given environment. They +// are for use in the ForEach() function. +static void SetUpEnvironment(Environment* env) { env->SetUp(); } +static void TearDownEnvironment(Environment* env) { env->TearDown(); } + +// Runs all tests in this UnitTest object, prints the result, and +// returns true if all tests are successful. If any exception is +// thrown during a test, the test is considered to be failed, but the +// rest of the tests will still be run. +// +// When parameterized tests are enabled, it expands and registers +// parameterized tests first in RegisterParameterizedTests(). +// All other functions called from RunAllTests() may safely assume that +// parameterized tests are ready to be counted and run. +bool UnitTestImpl::RunAllTests() { + // Makes sure InitGoogleTest() was called. + if (!GTestIsInitialized()) { + printf("%s", + "\nThis test program did NOT call ::testing::InitGoogleTest " + "before calling RUN_ALL_TESTS(). Please fix it.\n"); + return false; + } + + // Do not run any test if the --help flag was specified. + if (g_help_flag) + return true; + + // Repeats the call to the post-flag parsing initialization in case the + // user didn't call InitGoogleTest. + PostFlagParsingInit(); + + // Even if sharding is not on, test runners may want to use the + // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding + // protocol. + internal::WriteToShardStatusFileIfNeeded(); + + // True iff we are in a subprocess for running a thread-safe-style + // death test. + bool in_subprocess_for_death_test = false; + +#if GTEST_HAS_DEATH_TEST + in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL); +#endif // GTEST_HAS_DEATH_TEST + + const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex, + in_subprocess_for_death_test); + + // Compares the full test names with the filter to decide which + // tests to run. + const bool has_tests_to_run = FilterTests(should_shard + ? HONOR_SHARDING_PROTOCOL + : IGNORE_SHARDING_PROTOCOL) > 0; + + // Lists the tests and exits if the --gtest_list_tests flag was specified. + if (GTEST_FLAG(list_tests)) { + // This must be called *after* FilterTests() has been called. + ListTestsMatchingFilter(); + return true; + } + + random_seed_ = GTEST_FLAG(shuffle) ? + GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0; + + // True iff at least one test has failed. + bool failed = false; + + TestEventListener* repeater = listeners()->repeater(); + + start_timestamp_ = GetTimeInMillis(); + repeater->OnTestProgramStart(*parent_); + + // How many times to repeat the tests? We don't want to repeat them + // when we are inside the subprocess of a death test. + const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat); + // Repeats forever if the repeat count is negative. + const bool forever = repeat < 0; + for (int i = 0; forever || i != repeat; i++) { + // We want to preserve failures generated by ad-hoc test + // assertions executed before RUN_ALL_TESTS(). + ClearNonAdHocTestResult(); + + const TimeInMillis start = GetTimeInMillis(); + + // Shuffles test cases and tests if requested. + if (has_tests_to_run && GTEST_FLAG(shuffle)) { + random()->Reseed(random_seed_); + // This should be done before calling OnTestIterationStart(), + // such that a test event listener can see the actual test order + // in the event. + ShuffleTests(); + } + + // Tells the unit test event listeners that the tests are about to start. + repeater->OnTestIterationStart(*parent_, i); + + // Runs each test case if there is at least one test to run. + if (has_tests_to_run) { + // Sets up all environments beforehand. + repeater->OnEnvironmentsSetUpStart(*parent_); + ForEach(environments_, SetUpEnvironment); + repeater->OnEnvironmentsSetUpEnd(*parent_); + + // Runs the tests only if there was no fatal failure during global + // set-up. + if (!Test::HasFatalFailure()) { + for (int test_index = 0; test_index < total_test_case_count(); + test_index++) { + GetMutableTestCase(test_index)->Run(); + } + } + + // Tears down all environments in reverse order afterwards. + repeater->OnEnvironmentsTearDownStart(*parent_); + std::for_each(environments_.rbegin(), environments_.rend(), + TearDownEnvironment); + repeater->OnEnvironmentsTearDownEnd(*parent_); + } + + elapsed_time_ = GetTimeInMillis() - start; + + // Tells the unit test event listener that the tests have just finished. + repeater->OnTestIterationEnd(*parent_, i); + + // Gets the result and clears it. + if (!Passed()) { + failed = true; + } + + // Restores the original test order after the iteration. This + // allows the user to quickly repro a failure that happens in the + // N-th iteration without repeating the first (N - 1) iterations. + // This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in + // case the user somehow changes the value of the flag somewhere + // (it's always safe to unshuffle the tests). + UnshuffleTests(); + + if (GTEST_FLAG(shuffle)) { + // Picks a new random seed for each iteration. + random_seed_ = GetNextRandomSeed(random_seed_); + } + } + + repeater->OnTestProgramEnd(*parent_); + + return !failed; +} + +// Reads the GTEST_SHARD_STATUS_FILE environment variable, and creates the file +// if the variable is present. If a file already exists at this location, this +// function will write over it. If the variable is present, but the file cannot +// be created, prints an error and exits. +void WriteToShardStatusFileIfNeeded() { + const char* const test_shard_file = posix::GetEnv(kTestShardStatusFile); + if (test_shard_file != NULL) { + FILE* const file = posix::FOpen(test_shard_file, "w"); + if (file == NULL) { + ColoredPrintf(COLOR_RED, + "Could not write to the test shard status file \"%s\" " + "specified by the %s environment variable.\n", + test_shard_file, kTestShardStatusFile); + fflush(stdout); + exit(EXIT_FAILURE); + } + fclose(file); + } +} + +// Checks whether sharding is enabled by examining the relevant +// environment variable values. If the variables are present, +// but inconsistent (i.e., shard_index >= total_shards), prints +// an error and exits. If in_subprocess_for_death_test, sharding is +// disabled because it must only be applied to the original test +// process. Otherwise, we could filter out death tests we intended to execute. +bool ShouldShard(const char* total_shards_env, + const char* shard_index_env, + bool in_subprocess_for_death_test) { + if (in_subprocess_for_death_test) { + return false; + } + + const Int32 total_shards = Int32FromEnvOrDie(total_shards_env, -1); + const Int32 shard_index = Int32FromEnvOrDie(shard_index_env, -1); + + if (total_shards == -1 && shard_index == -1) { + return false; + } else if (total_shards == -1 && shard_index != -1) { + const Message msg = Message() + << "Invalid environment variables: you have " + << kTestShardIndex << " = " << shard_index + << ", but have left " << kTestTotalShards << " unset.\n"; + ColoredPrintf(COLOR_RED, msg.GetString().c_str()); + fflush(stdout); + exit(EXIT_FAILURE); + } else if (total_shards != -1 && shard_index == -1) { + const Message msg = Message() + << "Invalid environment variables: you have " + << kTestTotalShards << " = " << total_shards + << ", but have left " << kTestShardIndex << " unset.\n"; + ColoredPrintf(COLOR_RED, msg.GetString().c_str()); + fflush(stdout); + exit(EXIT_FAILURE); + } else if (shard_index < 0 || shard_index >= total_shards) { + const Message msg = Message() + << "Invalid environment variables: we require 0 <= " + << kTestShardIndex << " < " << kTestTotalShards + << ", but you have " << kTestShardIndex << "=" << shard_index + << ", " << kTestTotalShards << "=" << total_shards << ".\n"; + ColoredPrintf(COLOR_RED, msg.GetString().c_str()); + fflush(stdout); + exit(EXIT_FAILURE); + } + + return total_shards > 1; +} + +// Parses the environment variable var as an Int32. If it is unset, +// returns default_val. If it is not an Int32, prints an error +// and aborts. +Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) { + const char* str_val = posix::GetEnv(var); + if (str_val == NULL) { + return default_val; + } + + Int32 result; + if (!ParseInt32(Message() << "The value of environment variable " << var, + str_val, &result)) { + exit(EXIT_FAILURE); + } + return result; +} + +// Given the total number of shards, the shard index, and the test id, +// returns true iff the test should be run on this shard. The test id is +// some arbitrary but unique non-negative integer assigned to each test +// method. Assumes that 0 <= shard_index < total_shards. +bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id) { + return (test_id % total_shards) == shard_index; +} + +// Compares the name of each test with the user-specified filter to +// decide whether the test should be run, then records the result in +// each TestCase and TestInfo object. +// If shard_tests == true, further filters tests based on sharding +// variables in the environment - see +// http://code.google.com/p/googletest/wiki/GoogleTestAdvancedGuide. +// Returns the number of tests that should run. +int UnitTestImpl::FilterTests(ReactionToSharding shard_tests) { + const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ? + Int32FromEnvOrDie(kTestTotalShards, -1) : -1; + const Int32 shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ? + Int32FromEnvOrDie(kTestShardIndex, -1) : -1; + + // num_runnable_tests are the number of tests that will + // run across all shards (i.e., match filter and are not disabled). + // num_selected_tests are the number of tests to be run on + // this shard. + int num_runnable_tests = 0; + int num_selected_tests = 0; + for (size_t i = 0; i < test_cases_.size(); i++) { + TestCase* const test_case = test_cases_[i]; + const std::string &test_case_name = test_case->name(); + test_case->set_should_run(false); + + for (size_t j = 0; j < test_case->test_info_list().size(); j++) { + TestInfo* const test_info = test_case->test_info_list()[j]; + const std::string test_name(test_info->name()); + // A test is disabled if test case name or test name matches + // kDisableTestFilter. + const bool is_disabled = + internal::UnitTestOptions::MatchesFilter(test_case_name, + kDisableTestFilter) || + internal::UnitTestOptions::MatchesFilter(test_name, + kDisableTestFilter); + test_info->is_disabled_ = is_disabled; + + const bool matches_filter = + internal::UnitTestOptions::FilterMatchesTest(test_case_name, + test_name); + test_info->matches_filter_ = matches_filter; + + const bool is_runnable = + (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) && + matches_filter; + + const bool is_selected = is_runnable && + (shard_tests == IGNORE_SHARDING_PROTOCOL || + ShouldRunTestOnShard(total_shards, shard_index, + num_runnable_tests)); + + num_runnable_tests += is_runnable; + num_selected_tests += is_selected; + + test_info->should_run_ = is_selected; + test_case->set_should_run(test_case->should_run() || is_selected); + } + } + return num_selected_tests; +} + +// Prints the given C-string on a single line by replacing all '\n' +// characters with string "\\n". If the output takes more than +// max_length characters, only prints the first max_length characters +// and "...". +static void PrintOnOneLine(const char* str, int max_length) { + if (str != NULL) { + for (int i = 0; *str != '\0'; ++str) { + if (i >= max_length) { + printf("..."); + break; + } + if (*str == '\n') { + printf("\\n"); + i += 2; + } else { + printf("%c", *str); + ++i; + } + } + } +} + +// Prints the names of the tests matching the user-specified filter flag. +void UnitTestImpl::ListTestsMatchingFilter() { + // Print at most this many characters for each type/value parameter. + const int kMaxParamLength = 250; + + for (size_t i = 0; i < test_cases_.size(); i++) { + const TestCase* const test_case = test_cases_[i]; + bool printed_test_case_name = false; + + for (size_t j = 0; j < test_case->test_info_list().size(); j++) { + const TestInfo* const test_info = + test_case->test_info_list()[j]; + if (test_info->matches_filter_) { + if (!printed_test_case_name) { + printed_test_case_name = true; + printf("%s.", test_case->name()); + if (test_case->type_param() != NULL) { + printf(" # %s = ", kTypeParamLabel); + // We print the type parameter on a single line to make + // the output easy to parse by a program. + PrintOnOneLine(test_case->type_param(), kMaxParamLength); + } + printf("\n"); + } + printf(" %s", test_info->name()); + if (test_info->value_param() != NULL) { + printf(" # %s = ", kValueParamLabel); + // We print the value parameter on a single line to make the + // output easy to parse by a program. + PrintOnOneLine(test_info->value_param(), kMaxParamLength); + } + printf("\n"); + } + } + } + fflush(stdout); +} + +// Sets the OS stack trace getter. +// +// Does nothing if the input and the current OS stack trace getter are +// the same; otherwise, deletes the old getter and makes the input the +// current getter. +void UnitTestImpl::set_os_stack_trace_getter( + OsStackTraceGetterInterface* getter) { + if (os_stack_trace_getter_ != getter) { + delete os_stack_trace_getter_; + os_stack_trace_getter_ = getter; + } +} + +// Returns the current OS stack trace getter if it is not NULL; +// otherwise, creates an OsStackTraceGetter, makes it the current +// getter, and returns it. +OsStackTraceGetterInterface* UnitTestImpl::os_stack_trace_getter() { + if (os_stack_trace_getter_ == NULL) { + os_stack_trace_getter_ = new OsStackTraceGetter; + } + + return os_stack_trace_getter_; +} + +// Returns the TestResult for the test that's currently running, or +// the TestResult for the ad hoc test if no test is running. +TestResult* UnitTestImpl::current_test_result() { + return current_test_info_ ? + &(current_test_info_->result_) : &ad_hoc_test_result_; +} + +// Shuffles all test cases, and the tests within each test case, +// making sure that death tests are still run first. +void UnitTestImpl::ShuffleTests() { + // Shuffles the death test cases. + ShuffleRange(random(), 0, last_death_test_case_ + 1, &test_case_indices_); + + // Shuffles the non-death test cases. + ShuffleRange(random(), last_death_test_case_ + 1, + static_cast(test_cases_.size()), &test_case_indices_); + + // Shuffles the tests inside each test case. + for (size_t i = 0; i < test_cases_.size(); i++) { + test_cases_[i]->ShuffleTests(random()); + } +} + +// Restores the test cases and tests to their order before the first shuffle. +void UnitTestImpl::UnshuffleTests() { + for (size_t i = 0; i < test_cases_.size(); i++) { + // Unshuffles the tests in each test case. + test_cases_[i]->UnshuffleTests(); + // Resets the index of each test case. + test_case_indices_[i] = static_cast(i); + } +} + +// Returns the current OS stack trace as an std::string. +// +// The maximum number of stack frames to be included is specified by +// the gtest_stack_trace_depth flag. The skip_count parameter +// specifies the number of top frames to be skipped, which doesn't +// count against the number of frames to be included. +// +// For example, if Foo() calls Bar(), which in turn calls +// GetCurrentOsStackTraceExceptTop(..., 1), Foo() will be included in +// the trace but Bar() and GetCurrentOsStackTraceExceptTop() won't. +std::string GetCurrentOsStackTraceExceptTop(UnitTest* /*unit_test*/, + int skip_count) { + // We pass skip_count + 1 to skip this wrapper function in addition + // to what the user really wants to skip. + return GetUnitTestImpl()->CurrentOsStackTraceExceptTop(skip_count + 1); +} + +// Used by the GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_ macro to +// suppress unreachable code warnings. +namespace { +class ClassUniqueToAlwaysTrue {}; +} + +bool IsTrue(bool condition) { return condition; } + +bool AlwaysTrue() { +#if GTEST_HAS_EXCEPTIONS + // This condition is always false so AlwaysTrue() never actually throws, + // but it makes the compiler think that it may throw. + if (IsTrue(false)) + throw ClassUniqueToAlwaysTrue(); +#endif // GTEST_HAS_EXCEPTIONS + return true; +} + +// If *pstr starts with the given prefix, modifies *pstr to be right +// past the prefix and returns true; otherwise leaves *pstr unchanged +// and returns false. None of pstr, *pstr, and prefix can be NULL. +bool SkipPrefix(const char* prefix, const char** pstr) { + const size_t prefix_len = strlen(prefix); + if (strncmp(*pstr, prefix, prefix_len) == 0) { + *pstr += prefix_len; + return true; + } + return false; +} + +// Parses a string as a command line flag. The string should have +// the format "--flag=value". When def_optional is true, the "=value" +// part can be omitted. +// +// Returns the value of the flag, or NULL if the parsing failed. +const char* ParseFlagValue(const char* str, + const char* flag, + bool def_optional) { + // str and flag must not be NULL. + if (str == NULL || flag == NULL) return NULL; + + // The flag must start with "--" followed by GTEST_FLAG_PREFIX_. + const std::string flag_str = std::string("--") + GTEST_FLAG_PREFIX_ + flag; + const size_t flag_len = flag_str.length(); + if (strncmp(str, flag_str.c_str(), flag_len) != 0) return NULL; + + // Skips the flag name. + const char* flag_end = str + flag_len; + + // When def_optional is true, it's OK to not have a "=value" part. + if (def_optional && (flag_end[0] == '\0')) { + return flag_end; + } + + // If def_optional is true and there are more characters after the + // flag name, or if def_optional is false, there must be a '=' after + // the flag name. + if (flag_end[0] != '=') return NULL; + + // Returns the string after "=". + return flag_end + 1; +} + +// Parses a string for a bool flag, in the form of either +// "--flag=value" or "--flag". +// +// In the former case, the value is taken as true as long as it does +// not start with '0', 'f', or 'F'. +// +// In the latter case, the value is taken as true. +// +// On success, stores the value of the flag in *value, and returns +// true. On failure, returns false without changing *value. +bool ParseBoolFlag(const char* str, const char* flag, bool* value) { + // Gets the value of the flag as a string. + const char* const value_str = ParseFlagValue(str, flag, true); + + // Aborts if the parsing failed. + if (value_str == NULL) return false; + + // Converts the string value to a bool. + *value = !(*value_str == '0' || *value_str == 'f' || *value_str == 'F'); + return true; +} + +// Parses a string for an Int32 flag, in the form of +// "--flag=value". +// +// On success, stores the value of the flag in *value, and returns +// true. On failure, returns false without changing *value. +bool ParseInt32Flag(const char* str, const char* flag, Int32* value) { + // Gets the value of the flag as a string. + const char* const value_str = ParseFlagValue(str, flag, false); + + // Aborts if the parsing failed. + if (value_str == NULL) return false; + + // Sets *value to the value of the flag. + return ParseInt32(Message() << "The value of flag --" << flag, + value_str, value); +} + +// Parses a string for a string flag, in the form of +// "--flag=value". +// +// On success, stores the value of the flag in *value, and returns +// true. On failure, returns false without changing *value. +bool ParseStringFlag(const char* str, const char* flag, std::string* value) { + // Gets the value of the flag as a string. + const char* const value_str = ParseFlagValue(str, flag, false); + + // Aborts if the parsing failed. + if (value_str == NULL) return false; + + // Sets *value to the value of the flag. + *value = value_str; + return true; +} + +// Determines whether a string has a prefix that Google Test uses for its +// flags, i.e., starts with GTEST_FLAG_PREFIX_ or GTEST_FLAG_PREFIX_DASH_. +// If Google Test detects that a command line flag has its prefix but is not +// recognized, it will print its help message. Flags starting with +// GTEST_INTERNAL_PREFIX_ followed by "internal_" are considered Google Test +// internal flags and do not trigger the help message. +static bool HasGoogleTestFlagPrefix(const char* str) { + return (SkipPrefix("--", &str) || + SkipPrefix("-", &str) || + SkipPrefix("/", &str)) && + !SkipPrefix(GTEST_FLAG_PREFIX_ "internal_", &str) && + (SkipPrefix(GTEST_FLAG_PREFIX_, &str) || + SkipPrefix(GTEST_FLAG_PREFIX_DASH_, &str)); +} + +// Prints a string containing code-encoded text. The following escape +// sequences can be used in the string to control the text color: +// +// @@ prints a single '@' character. +// @R changes the color to red. +// @G changes the color to green. +// @Y changes the color to yellow. +// @D changes to the default terminal text color. +// +// TODO(wan@google.com): Write tests for this once we add stdout +// capturing to Google Test. +static void PrintColorEncoded(const char* str) { + GTestColor color = COLOR_DEFAULT; // The current color. + + // Conceptually, we split the string into segments divided by escape + // sequences. Then we print one segment at a time. At the end of + // each iteration, the str pointer advances to the beginning of the + // next segment. + for (;;) { + const char* p = strchr(str, '@'); + if (p == NULL) { + ColoredPrintf(color, "%s", str); + return; + } + + ColoredPrintf(color, "%s", std::string(str, p).c_str()); + + const char ch = p[1]; + str = p + 2; + if (ch == '@') { + ColoredPrintf(color, "@"); + } else if (ch == 'D') { + color = COLOR_DEFAULT; + } else if (ch == 'R') { + color = COLOR_RED; + } else if (ch == 'G') { + color = COLOR_GREEN; + } else if (ch == 'Y') { + color = COLOR_YELLOW; + } else { + --str; + } + } +} + +static const char kColorEncodedHelpMessage[] = +"This program contains tests written using " GTEST_NAME_ ". You can use the\n" +"following command line flags to control its behavior:\n" +"\n" +"Test Selection:\n" +" @G--" GTEST_FLAG_PREFIX_ "list_tests@D\n" +" List the names of all tests instead of running them. The name of\n" +" TEST(Foo, Bar) is \"Foo.Bar\".\n" +" @G--" GTEST_FLAG_PREFIX_ "filter=@YPOSTIVE_PATTERNS" + "[@G-@YNEGATIVE_PATTERNS]@D\n" +" Run only the tests whose name matches one of the positive patterns but\n" +" none of the negative patterns. '?' matches any single character; '*'\n" +" matches any substring; ':' separates two patterns.\n" +" @G--" GTEST_FLAG_PREFIX_ "also_run_disabled_tests@D\n" +" Run all disabled tests too.\n" +"\n" +"Test Execution:\n" +" @G--" GTEST_FLAG_PREFIX_ "repeat=@Y[COUNT]@D\n" +" Run the tests repeatedly; use a negative count to repeat forever.\n" +" @G--" GTEST_FLAG_PREFIX_ "shuffle@D\n" +" Randomize tests' orders on every iteration.\n" +" @G--" GTEST_FLAG_PREFIX_ "random_seed=@Y[NUMBER]@D\n" +" Random number seed to use for shuffling test orders (between 1 and\n" +" 99999, or 0 to use a seed based on the current time).\n" +"\n" +"Test Output:\n" +" @G--" GTEST_FLAG_PREFIX_ "color=@Y(@Gyes@Y|@Gno@Y|@Gauto@Y)@D\n" +" Enable/disable colored output. The default is @Gauto@D.\n" +" -@G-" GTEST_FLAG_PREFIX_ "print_time=0@D\n" +" Don't print the elapsed time of each test.\n" +" @G--" GTEST_FLAG_PREFIX_ "output=xml@Y[@G:@YDIRECTORY_PATH@G" + GTEST_PATH_SEP_ "@Y|@G:@YFILE_PATH]@D\n" +" Generate an XML report in the given directory or with the given file\n" +" name. @YFILE_PATH@D defaults to @Gtest_details.xml@D.\n" +#if GTEST_CAN_STREAM_RESULTS_ +" @G--" GTEST_FLAG_PREFIX_ "stream_result_to=@YHOST@G:@YPORT@D\n" +" Stream test results to the given server.\n" +#endif // GTEST_CAN_STREAM_RESULTS_ +"\n" +"Assertion Behavior:\n" +#if GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS +" @G--" GTEST_FLAG_PREFIX_ "death_test_style=@Y(@Gfast@Y|@Gthreadsafe@Y)@D\n" +" Set the default death test style.\n" +#endif // GTEST_HAS_DEATH_TEST && !GTEST_OS_WINDOWS +" @G--" GTEST_FLAG_PREFIX_ "break_on_failure@D\n" +" Turn assertion failures into debugger break-points.\n" +" @G--" GTEST_FLAG_PREFIX_ "throw_on_failure@D\n" +" Turn assertion failures into C++ exceptions.\n" +" @G--" GTEST_FLAG_PREFIX_ "catch_exceptions=0@D\n" +" Do not report exceptions as test failures. Instead, allow them\n" +" to crash the program or throw a pop-up (on Windows).\n" +"\n" +"Except for @G--" GTEST_FLAG_PREFIX_ "list_tests@D, you can alternatively set " + "the corresponding\n" +"environment variable of a flag (all letters in upper-case). For example, to\n" +"disable colored text output, you can either specify @G--" GTEST_FLAG_PREFIX_ + "color=no@D or set\n" +"the @G" GTEST_FLAG_PREFIX_UPPER_ "COLOR@D environment variable to @Gno@D.\n" +"\n" +"For more information, please read the " GTEST_NAME_ " documentation at\n" +"@G" GTEST_PROJECT_URL_ "@D. If you find a bug in " GTEST_NAME_ "\n" +"(not one in your own code or tests), please report it to\n" +"@G<" GTEST_DEV_EMAIL_ ">@D.\n"; + +// Parses the command line for Google Test flags, without initializing +// other parts of Google Test. The type parameter CharType can be +// instantiated to either char or wchar_t. +template +void ParseGoogleTestFlagsOnlyImpl(int* argc, CharType** argv) { + for (int i = 1; i < *argc; i++) { + const std::string arg_string = StreamableToString(argv[i]); + const char* const arg = arg_string.c_str(); + + using internal::ParseBoolFlag; + using internal::ParseInt32Flag; + using internal::ParseStringFlag; + + // Do we see a Google Test flag? + if (ParseBoolFlag(arg, kAlsoRunDisabledTestsFlag, + >EST_FLAG(also_run_disabled_tests)) || + ParseBoolFlag(arg, kBreakOnFailureFlag, + >EST_FLAG(break_on_failure)) || + ParseBoolFlag(arg, kCatchExceptionsFlag, + >EST_FLAG(catch_exceptions)) || + ParseStringFlag(arg, kColorFlag, >EST_FLAG(color)) || + ParseStringFlag(arg, kDeathTestStyleFlag, + >EST_FLAG(death_test_style)) || + ParseBoolFlag(arg, kDeathTestUseFork, + >EST_FLAG(death_test_use_fork)) || + ParseStringFlag(arg, kFilterFlag, >EST_FLAG(filter)) || + ParseStringFlag(arg, kInternalRunDeathTestFlag, + >EST_FLAG(internal_run_death_test)) || + ParseBoolFlag(arg, kListTestsFlag, >EST_FLAG(list_tests)) || + ParseStringFlag(arg, kOutputFlag, >EST_FLAG(output)) || + ParseBoolFlag(arg, kPrintTimeFlag, >EST_FLAG(print_time)) || + ParseInt32Flag(arg, kRandomSeedFlag, >EST_FLAG(random_seed)) || + ParseInt32Flag(arg, kRepeatFlag, >EST_FLAG(repeat)) || + ParseBoolFlag(arg, kShuffleFlag, >EST_FLAG(shuffle)) || + ParseInt32Flag(arg, kStackTraceDepthFlag, + >EST_FLAG(stack_trace_depth)) || + ParseStringFlag(arg, kStreamResultToFlag, + >EST_FLAG(stream_result_to)) || + ParseBoolFlag(arg, kThrowOnFailureFlag, + >EST_FLAG(throw_on_failure)) + ) { + // Yes. Shift the remainder of the argv list left by one. Note + // that argv has (*argc + 1) elements, the last one always being + // NULL. The following loop moves the trailing NULL element as + // well. + for (int j = i; j != *argc; j++) { + argv[j] = argv[j + 1]; + } + + // Decrements the argument count. + (*argc)--; + + // We also need to decrement the iterator as we just removed + // an element. + i--; + } else if (arg_string == "--help" || arg_string == "-h" || + arg_string == "-?" || arg_string == "/?" || + HasGoogleTestFlagPrefix(arg)) { + // Both help flag and unrecognized Google Test flags (excluding + // internal ones) trigger help display. + g_help_flag = true; + } + } + + if (g_help_flag) { + // We print the help here instead of in RUN_ALL_TESTS(), as the + // latter may not be called at all if the user is using Google + // Test with another testing framework. + PrintColorEncoded(kColorEncodedHelpMessage); + } +} + +// Parses the command line for Google Test flags, without initializing +// other parts of Google Test. +void ParseGoogleTestFlagsOnly(int* argc, char** argv) { + ParseGoogleTestFlagsOnlyImpl(argc, argv); +} +void ParseGoogleTestFlagsOnly(int* argc, wchar_t** argv) { + ParseGoogleTestFlagsOnlyImpl(argc, argv); +} + +// The internal implementation of InitGoogleTest(). +// +// The type parameter CharType can be instantiated to either char or +// wchar_t. +template +void InitGoogleTestImpl(int* argc, CharType** argv) { + g_init_gtest_count++; + + // We don't want to run the initialization code twice. + if (g_init_gtest_count != 1) return; + + if (*argc <= 0) return; + + internal::g_executable_path = internal::StreamableToString(argv[0]); + +#if GTEST_HAS_DEATH_TEST + + g_argvs.clear(); + for (int i = 0; i != *argc; i++) { + g_argvs.push_back(StreamableToString(argv[i])); + } + +#endif // GTEST_HAS_DEATH_TEST + + ParseGoogleTestFlagsOnly(argc, argv); + GetUnitTestImpl()->PostFlagParsingInit(); +} + +} // namespace internal + +// Initializes Google Test. This must be called before calling +// RUN_ALL_TESTS(). In particular, it parses a command line for the +// flags that Google Test recognizes. Whenever a Google Test flag is +// seen, it is removed from argv, and *argc is decremented. +// +// No value is returned. Instead, the Google Test flag variables are +// updated. +// +// Calling the function for the second time has no user-visible effect. +void InitGoogleTest(int* argc, char** argv) { + internal::InitGoogleTestImpl(argc, argv); +} + +// This overloaded version can be used in Windows programs compiled in +// UNICODE mode. +void InitGoogleTest(int* argc, wchar_t** argv) { + internal::InitGoogleTestImpl(argc, argv); +} + +} // namespace testing diff --git a/test/fmw/gtest/src/gtest_main.cc b/test/fmw/gtest/src/gtest_main.cc new file mode 100644 index 00000000000..f3028225523 --- /dev/null +++ b/test/fmw/gtest/src/gtest_main.cc @@ -0,0 +1,38 @@ +// Copyright 2006, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#include + +#include "gtest/gtest.h" + +GTEST_API_ int main(int argc, char **argv) { + printf("Running main() from gtest_main.cc\n"); + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} -- GitLab From fdc03a7cd83a209a27c9bef85e0452c871ca6fbe Mon Sep 17 00:00:00 2001 From: Erik Helin Date: Wed, 4 May 2016 11:29:05 +0200 Subject: [PATCH 288/400] 8156022: Add prediction for cost_per_byte_ms to G1Analytics Reviewed-by: sjohanss, mgerdin --- hotspot/src/share/vm/gc/g1/g1Analytics.cpp | 5 ++++- hotspot/src/share/vm/gc/g1/g1Analytics.hpp | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/gc/g1/g1Analytics.cpp b/hotspot/src/share/vm/gc/g1/g1Analytics.cpp index 16d4af949ce..c43b4169e49 100644 --- a/hotspot/src/share/vm/gc/g1/g1Analytics.cpp +++ b/hotspot/src/share/vm/gc/g1/g1Analytics.cpp @@ -284,6 +284,10 @@ double G1Analytics::predict_object_copy_time_ms(size_t bytes_to_copy, bool durin } } +double G1Analytics::predict_cost_per_byte_ms() const { + return get_new_prediction(_cost_per_byte_ms_seq); +} + double G1Analytics::predict_constant_other_time_ms() const { return get_new_prediction(_constant_other_time_ms_seq); } @@ -326,4 +330,3 @@ void G1Analytics::update_recent_gc_times(double end_time_sec, void G1Analytics::report_concurrent_mark_cleanup_times_ms(double ms) { _concurrent_mark_cleanup_times_ms->add(ms); } - diff --git a/hotspot/src/share/vm/gc/g1/g1Analytics.hpp b/hotspot/src/share/vm/gc/g1/g1Analytics.hpp index 603a751c198..a22d0dd72bd 100644 --- a/hotspot/src/share/vm/gc/g1/g1Analytics.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Analytics.hpp @@ -149,6 +149,8 @@ public: size_t predict_rs_lengths() const; size_t predict_pending_cards() const; + double predict_cost_per_byte_ms() const; + // Add a new GC of the given duration and end time to the record. void update_recent_gc_times(double end_time_sec, double elapsed_ms); void compute_pause_time_ratio(double interval_ms, double pause_time_ms); -- GitLab From ca2c5065799733fdb81d3237f845624ca9e88a8d Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Wed, 11 May 2016 20:05:26 -0400 Subject: [PATCH 289/400] 8155627: Enable SA on AArch64 Reviewed-by: roland, dholmes --- common/autoconf/generated-configure.sh | 5 +---- common/autoconf/jdk-options.m4 | 3 --- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 9def48f6cfa..7d5f6af13f2 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -5050,7 +5050,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1462793660 +DATE_WHEN_GENERATED=1463011468 ############################################################################### # @@ -23766,9 +23766,6 @@ fi if test "x$OPENJDK_TARGET_OS" = xaix ; then INCLUDE_SA=false fi - if test "x$OPENJDK_TARGET_CPU" = xaarch64; then - INCLUDE_SA=false - fi # Compress jars diff --git a/common/autoconf/jdk-options.m4 b/common/autoconf/jdk-options.m4 index e34e4d927dd..076b6cfaa09 100644 --- a/common/autoconf/jdk-options.m4 +++ b/common/autoconf/jdk-options.m4 @@ -209,9 +209,6 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS], if test "x$OPENJDK_TARGET_OS" = xaix ; then INCLUDE_SA=false fi - if test "x$OPENJDK_TARGET_CPU" = xaarch64; then - INCLUDE_SA=false - fi AC_SUBST(INCLUDE_SA) # Compress jars -- GitLab From 93a253535c326a5b437139325c1a2d12ecc84332 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Mon, 16 May 2016 14:50:43 +0530 Subject: [PATCH 290/400] 8156914: jlink API minor cleanups Reviewed-by: mchung --- make/Javadoc.gmk | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk index d1e85b4b746..5cff3c46bdd 100644 --- a/make/Javadoc.gmk +++ b/make/Javadoc.gmk @@ -1634,9 +1634,7 @@ JLINK_PLUGIN_DOCTITLE := JLink Plugin API - EXPERIMENTAL JLINK_PLUGIN_WINDOWTITLE := JLink Plugin API - EXPERIMENTAL JLINK_PLUGIN_HEADER := JLink Plugin API - EXPERIMENTAL JLINK_PLUGIN_BOTTOM := $(call CommonBottom,$(JLINK_PLUGIN_FIRST_COPYRIGHT_YEAR)) -JLINK_PLUGIN_PKGS = jdk.tools.jlink \ - jdk.tools.jlink.builder \ - jdk.tools.jlink.plugin +JLINK_PLUGIN_PKGS = jdk.tools.jlink.plugin JLINK_PLUGIN_INDEX_HTML = $(JLINK_PLUGIN_DOCDIR)/index.html JLINK_PLUGIN_OPTIONS_FILE = $(DOCSTMPDIR)/jlinkplugins.options -- GitLab From 7750aa7661b1c59670d0da173e1f0d22eb51b737 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Mon, 16 May 2016 20:51:01 +0530 Subject: [PATCH 291/400] 8156847: jdk.dynalink package is shown under "Other Packages" section Reviewed-by: jlaskey --- make/Javadoc.gmk | 1 - 1 file changed, 1 deletion(-) diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk index 5cff3c46bdd..8804cff3f68 100644 --- a/make/Javadoc.gmk +++ b/make/Javadoc.gmk @@ -1437,7 +1437,6 @@ $(DYNALINKAPI_OPTIONS_FILE): $(call OptionPair,-windowtitle,$(DYNALINKAPI_WINDOWTITLE) $(DRAFT_WINTITLE)); \ $(call OptionPair,-header,$(DYNALINKAPI_HEADER)$(DRAFT_HEADER)) ; \ $(call OptionPair,-bottom,$(DYNALINKAPI_BOTTOM)$(DRAFT_BOTTOM)) ; \ - $(call OptionTrip,-group,$(DYNALINKAPI_GROUPNAME),$(DYNALINKAPI_REGEXP)); \ $(call OptionTrip,-linkoffline,$(DYNALINKAPI2COREAPI),$(COREAPI_DOCSDIR)/); \ ) >> $@ -- GitLab From 69cc0c7ebeff5407670a2c3f0962306718a18be9 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 17 May 2016 18:18:18 +0200 Subject: [PATCH 292/400] 8156036: Enable building of arm targets in default JPRT testset Reviewed-by: tbell, chegar --- make/jprt.properties | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/make/jprt.properties b/make/jprt.properties index 0e558641f98..93ccd1eb560 100644 --- a/make/jprt.properties +++ b/make/jprt.properties @@ -194,14 +194,15 @@ jprt.build.configure.args= \ my.build.flavors.default=fastdebug,product # Standard list of jprt build targets for this source tree -my.build.targets.default= \ - solaris_sparcv9_5.11-{product|fastdebug}, \ - solaris_x64_5.11-{product|fastdebug}, \ - linux_i586_3.8-{product|fastdebug}, \ - linux_x64_3.8-{product|fastdebug}, \ - macosx_x64_10.9-{product|fastdebug}, \ - windows_i586_6.3-{product|fastdebug}, \ - windows_x64_6.3-{product|fastdebug} +my.build.targets.default= \ + solaris_sparcv9_5.11-{product|fastdebug}, \ + solaris_x64_5.11-{product|fastdebug}, \ + linux_i586_3.8-{product|fastdebug}, \ + linux_x64_3.8-{product|fastdebug}, \ + macosx_x64_10.9-{product|fastdebug}, \ + windows_i586_6.3-{product|fastdebug}, \ + windows_x64_6.3-{product|fastdebug}, \ + ${my.additional.build.targets.default} # Test target list (no fastdebug & limited c2 testing) my.test.target.set= \ -- GitLab From 251735466a6cb62afbb72f6f6422275f5f7f9f70 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 4 May 2016 15:29:01 +0200 Subject: [PATCH 293/400] 8136777: Introduce bundle targets Reviewed-by: tbell, ihse --- common/autoconf/basics.m4 | 29 +- common/autoconf/compare.sh.in | 4 +- common/autoconf/generated-configure.sh | 488 ++++++++++++++++++++++++- common/autoconf/platform.m4 | 17 + common/autoconf/spec.gmk.in | 48 ++- common/bin/compare.sh | 22 +- common/conf/jib-profiles.js | 4 +- make/Bundles.gmk | 300 +++++++++++++++ make/Javadoc.gmk | 2 +- make/Jprt.gmk | 135 ++----- make/MacBundles.gmk | 26 +- make/Main.gmk | 31 +- make/common/MakeBase.gmk | 110 +++++- 13 files changed, 1085 insertions(+), 131 deletions(-) create mode 100644 make/Bundles.gmk diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index 355acf4c430..6a64c47b964 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -484,6 +484,8 @@ AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS], BASIC_REQUIRE_PROGS(FILE, file) BASIC_REQUIRE_PROGS(FIND, find) BASIC_REQUIRE_PROGS(HEAD, head) + BASIC_REQUIRE_PROGS(GUNZIP, gunzip) + BASIC_REQUIRE_PROGS(GZIP, pigz gzip) BASIC_REQUIRE_PROGS(LN, ln) BASIC_REQUIRE_PROGS(LS, ls) BASIC_REQUIRE_PROGS(MKDIR, mkdir) @@ -496,7 +498,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_FUNDAMENTAL_TOOLS], BASIC_REQUIRE_PROGS(SH, sh) BASIC_REQUIRE_PROGS(SORT, sort) BASIC_REQUIRE_PROGS(TAIL, tail) - BASIC_REQUIRE_PROGS(TAR, tar) + BASIC_REQUIRE_PROGS(TAR, gtar tar) BASIC_REQUIRE_PROGS(TEE, tee) BASIC_REQUIRE_PROGS(TOUCH, touch) BASIC_REQUIRE_PROGS(TR, tr) @@ -1007,11 +1009,36 @@ AC_DEFUN([BASIC_CHECK_FIND_DELETE], AC_SUBST(FIND_DELETE) ]) +AC_DEFUN([BASIC_CHECK_TAR], +[ + # Test which kind of tar was found + if test "x$($TAR --version | $GREP "GNU tar")" != "x"; then + TAR_TYPE="gnu" + elif test "x$($TAR -v | $GREP "bsdtar")" != "x"; then + TAR_TYPE="bsd" + elif test "x$OPENJDK_BUILD_OS" = "xsolaris"; then + TAR_TYPE="solaris" + fi + AC_MSG_CHECKING([what type of tar was found]) + AC_MSG_RESULT([$TAR_TYPE]) + + if test "x$TAR_TYPE" = "xgnu"; then + TAR_INCLUDE_PARAM="T" + TAR_SUPPORTS_TRANSFORM="true" + else + TAR_INCLUDE_PARAM="I" + TAR_SUPPORTS_TRANSFORM="false" + fi + AC_SUBST(TAR_INCLUDE_PARAM) + AC_SUBST(TAR_SUPPORTS_TRANSFORM) +]) + AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS], [ BASIC_CHECK_GNU_MAKE BASIC_CHECK_FIND_DELETE + BASIC_CHECK_TAR # These tools might not be installed by default, # need hint on how to install them. diff --git a/common/autoconf/compare.sh.in b/common/autoconf/compare.sh.in index 67a69ff73bd..f7e2003ca32 100644 --- a/common/autoconf/compare.sh.in +++ b/common/autoconf/compare.sh.in @@ -48,6 +48,7 @@ export EXPR="@EXPR@" export FILE="@FILE@" export FIND="@FIND@" export GREP="@GREP@" +export GUNZIP="@GUNZIP@" export LDD="@LDD@" export LN="@LN@" export MKDIR="@MKDIR@" @@ -63,10 +64,11 @@ export SED="@SED@" export SORT="@SORT@" export STAT="@STAT@" export STRIP="@STRIP@ @STRIPFLAGS@" +export TAR="@TAR@" export TEE="@TEE@" export UNIQ="@UNIQ@" export UNPACK200="@FIXPATH@ @BOOT_JDK@/bin/unpack200" -export UNARCHIVE="@UNZIP@ -q" +export UNARCHIVE="@UNZIP@ -q -o" export SRC_ROOT="@TOPDIR@" export OUTPUT_ROOT="@OUTPUT_ROOT@" diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 5e906c7b74a..b64d91f82de 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -949,6 +949,8 @@ OTOOL LDD ZIP UNZIP +TAR_SUPPORTS_TRANSFORM +TAR_INCLUDE_PARAM FIND_DELETE OUTPUT_SYNC OUTPUT_SYNC_SUPPORTED @@ -981,6 +983,9 @@ HOTSPOT_BUILD_CPU_ARCH HOTSPOT_BUILD_CPU HOTSPOT_BUILD_OS_TYPE HOTSPOT_BUILD_OS +OPENJDK_BUILD_BUNDLE_PLATFORM +OPENJDK_BUILD_CPU_BUNDLE +OPENJDK_BUILD_OS_BUNDLE OPENJDK_BUILD_OS_EXPORT_DIR OPENJDK_BUILD_CPU_JLI_CFLAGS OPENJDK_BUILD_CPU_OSARCH @@ -995,6 +1000,9 @@ HOTSPOT_TARGET_OS_TYPE HOTSPOT_TARGET_OS DEFINE_CROSS_COMPILE_ARCH LP64 +OPENJDK_TARGET_BUNDLE_PLATFORM +OPENJDK_TARGET_CPU_BUNDLE +OPENJDK_TARGET_OS_BUNDLE OPENJDK_TARGET_OS_EXPORT_DIR OPENJDK_TARGET_CPU_JLI_CFLAGS OPENJDK_TARGET_CPU_OSARCH @@ -1064,6 +1072,8 @@ MKTEMP MKDIR LS LN +GZIP +GUNZIP HEAD FIND FILE @@ -1246,6 +1256,8 @@ EXPR FILE FIND HEAD +GUNZIP +GZIP LN LS MKDIR @@ -2184,6 +2196,8 @@ Some influential environment variables: FILE Override default value for FILE FIND Override default value for FIND HEAD Override default value for HEAD + GUNZIP Override default value for GUNZIP + GZIP Override default value for GZIP LN Override default value for LN LS Override default value for LS MKDIR Override default value for MKDIR @@ -3686,6 +3700,8 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + # Check if build directory is on local disk. If not possible to determine, # we prefer to claim it's local. # Argument 1: directory to test @@ -5056,7 +5072,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1463011468 +DATE_WHEN_GENERATED=1463500649 ############################################################################### # @@ -8381,6 +8397,414 @@ $as_echo "$tool_specified" >&6; } + # Publish this variable in the help. + + + if [ -z "${GUNZIP+x}" ]; then + # The variable is not set by user, try to locate tool using the code snippet + for ac_prog in gunzip +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_GUNZIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GUNZIP in + [\\/]* | ?:[\\/]*) + ac_cv_path_GUNZIP="$GUNZIP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GUNZIP="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +GUNZIP=$ac_cv_path_GUNZIP +if test -n "$GUNZIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUNZIP" >&5 +$as_echo "$GUNZIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$GUNZIP" && break +done + + else + # The variable is set, but is it from the command line or the environment? + + # Try to remove the string !GUNZIP! from our list. + try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!GUNZIP!/} + if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then + # If it failed, the variable was not from the command line. Ignore it, + # but warn the user (except for BASH, which is always set by the calling BASH). + if test "xGUNZIP" != xBASH; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of GUNZIP from the environment. Use command line variables instead." >&5 +$as_echo "$as_me: WARNING: Ignoring value of GUNZIP from the environment. Use command line variables instead." >&2;} + fi + # Try to locate tool using the code snippet + for ac_prog in gunzip +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_GUNZIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GUNZIP in + [\\/]* | ?:[\\/]*) + ac_cv_path_GUNZIP="$GUNZIP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GUNZIP="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +GUNZIP=$ac_cv_path_GUNZIP +if test -n "$GUNZIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUNZIP" >&5 +$as_echo "$GUNZIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$GUNZIP" && break +done + + else + # If it succeeded, then it was overridden by the user. We will use it + # for the tool. + + # First remove it from the list of overridden variables, so we can test + # for unknown variables in the end. + CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var" + + # Check if we try to supply an empty value + if test "x$GUNZIP" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool GUNZIP= (no value)" >&5 +$as_echo "$as_me: Setting user supplied tool GUNZIP= (no value)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GUNZIP" >&5 +$as_echo_n "checking for GUNZIP... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 +$as_echo "disabled" >&6; } + else + # Check if the provided tool contains a complete path. + tool_specified="$GUNZIP" + tool_basename="${tool_specified##*/}" + if test "x$tool_basename" = "x$tool_specified"; then + # A command without a complete path is provided, search $PATH. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool GUNZIP=$tool_basename" >&5 +$as_echo "$as_me: Will search for user supplied tool GUNZIP=$tool_basename" >&6;} + # Extract the first word of "$tool_basename", so it can be a program name with args. +set dummy $tool_basename; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_GUNZIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GUNZIP in + [\\/]* | ?:[\\/]*) + ac_cv_path_GUNZIP="$GUNZIP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GUNZIP="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +GUNZIP=$ac_cv_path_GUNZIP +if test -n "$GUNZIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUNZIP" >&5 +$as_echo "$GUNZIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test "x$GUNZIP" = x; then + as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5 + fi + else + # Otherwise we believe it is a complete path. Use it as it is. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool GUNZIP=$tool_specified" >&5 +$as_echo "$as_me: Will use user supplied tool GUNZIP=$tool_specified" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GUNZIP" >&5 +$as_echo_n "checking for GUNZIP... " >&6; } + if test ! -x "$tool_specified"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + as_fn_error $? "User supplied tool GUNZIP=$tool_specified does not exist or is not executable" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5 +$as_echo "$tool_specified" >&6; } + fi + fi + fi + + fi + + + + if test "x$GUNZIP" = x; then + as_fn_error $? "Could not find required tool for GUNZIP" "$LINENO" 5 + fi + + + + + + # Publish this variable in the help. + + + if [ -z "${GZIP+x}" ]; then + # The variable is not set by user, try to locate tool using the code snippet + for ac_prog in pigz gzip +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_GZIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GZIP in + [\\/]* | ?:[\\/]*) + ac_cv_path_GZIP="$GZIP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GZIP="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +GZIP=$ac_cv_path_GZIP +if test -n "$GZIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GZIP" >&5 +$as_echo "$GZIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$GZIP" && break +done + + else + # The variable is set, but is it from the command line or the environment? + + # Try to remove the string !GZIP! from our list. + try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!GZIP!/} + if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then + # If it failed, the variable was not from the command line. Ignore it, + # but warn the user (except for BASH, which is always set by the calling BASH). + if test "xGZIP" != xBASH; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of GZIP from the environment. Use command line variables instead." >&5 +$as_echo "$as_me: WARNING: Ignoring value of GZIP from the environment. Use command line variables instead." >&2;} + fi + # Try to locate tool using the code snippet + for ac_prog in pigz gzip +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_GZIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GZIP in + [\\/]* | ?:[\\/]*) + ac_cv_path_GZIP="$GZIP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GZIP="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +GZIP=$ac_cv_path_GZIP +if test -n "$GZIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GZIP" >&5 +$as_echo "$GZIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$GZIP" && break +done + + else + # If it succeeded, then it was overridden by the user. We will use it + # for the tool. + + # First remove it from the list of overridden variables, so we can test + # for unknown variables in the end. + CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var" + + # Check if we try to supply an empty value + if test "x$GZIP" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool GZIP= (no value)" >&5 +$as_echo "$as_me: Setting user supplied tool GZIP= (no value)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GZIP" >&5 +$as_echo_n "checking for GZIP... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5 +$as_echo "disabled" >&6; } + else + # Check if the provided tool contains a complete path. + tool_specified="$GZIP" + tool_basename="${tool_specified##*/}" + if test "x$tool_basename" = "x$tool_specified"; then + # A command without a complete path is provided, search $PATH. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool GZIP=$tool_basename" >&5 +$as_echo "$as_me: Will search for user supplied tool GZIP=$tool_basename" >&6;} + # Extract the first word of "$tool_basename", so it can be a program name with args. +set dummy $tool_basename; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_GZIP+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $GZIP in + [\\/]* | ?:[\\/]*) + ac_cv_path_GZIP="$GZIP" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_GZIP="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +GZIP=$ac_cv_path_GZIP +if test -n "$GZIP"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GZIP" >&5 +$as_echo "$GZIP" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test "x$GZIP" = x; then + as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5 + fi + else + # Otherwise we believe it is a complete path. Use it as it is. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool GZIP=$tool_specified" >&5 +$as_echo "$as_me: Will use user supplied tool GZIP=$tool_specified" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GZIP" >&5 +$as_echo_n "checking for GZIP... " >&6; } + if test ! -x "$tool_specified"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + as_fn_error $? "User supplied tool GZIP=$tool_specified does not exist or is not executable" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5 +$as_echo "$tool_specified" >&6; } + fi + fi + fi + + fi + + + + if test "x$GZIP" = x; then + as_fn_error $? "Could not find required tool for GZIP" "$LINENO" 5 + fi + + + + + # Publish this variable in the help. @@ -10834,7 +11258,7 @@ $as_echo "$tool_specified" >&6; } if [ -z "${TAR+x}" ]; then # The variable is not set by user, try to locate tool using the code snippet - for ac_prog in tar + for ac_prog in gtar tar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -10892,7 +11316,7 @@ done $as_echo "$as_me: WARNING: Ignoring value of TAR from the environment. Use command line variables instead." >&2;} fi # Try to locate tool using the code snippet - for ac_prog in tar + for ac_prog in gtar tar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 @@ -15408,6 +15832,23 @@ $as_echo "$COMPILE_TYPE" >&6; } fi + # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles + # Macosx is osx and x86_64 is x64 + if test "x$OPENJDK_TARGET_OS" = xmacosx; then + OPENJDK_TARGET_OS_BUNDLE="osx" + else + OPENJDK_TARGET_OS_BUNDLE="$OPENJDK_TARGET_OS" + fi + if test "x$OPENJDK_TARGET_CPU" = xx86_64; then + OPENJDK_TARGET_CPU_BUNDLE="x64" + else + OPENJDK_TARGET_CPU_BUNDLE="$OPENJDK_TARGET_CPU" + fi + OPENJDK_TARGET_BUNDLE_PLATFORM="${OPENJDK_TARGET_OS_BUNDLE}-${OPENJDK_TARGET_CPU_BUNDLE}" + + + + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then A_LP64="LP64:=" # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in @@ -15564,6 +16005,23 @@ $as_echo "$COMPILE_TYPE" >&6; } fi + # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles + # Macosx is osx and x86_64 is x64 + if test "x$OPENJDK_BUILD_OS" = xmacosx; then + OPENJDK_BUILD_OS_BUNDLE="osx" + else + OPENJDK_BUILD_OS_BUNDLE="$OPENJDK_TARGET_OS" + fi + if test "x$OPENJDK_BUILD_CPU" = xx86_64; then + OPENJDK_BUILD_CPU_BUNDLE="x64" + else + OPENJDK_BUILD_CPU_BUNDLE="$OPENJDK_BUILD_CPU" + fi + OPENJDK_BUILD_BUNDLE_PLATFORM="${OPENJDK_BUILD_OS_BUNDLE}-${OPENJDK_BUILD_CPU_BUNDLE}" + + + + if test "x$OPENJDK_BUILD_CPU_BITS" = x64; then A_LP64="LP64:=" # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in @@ -20681,6 +21139,30 @@ $as_echo "yes" >&6; } + # Test which kind of tar was found + if test "x$($TAR --version | $GREP "GNU tar")" != "x"; then + TAR_TYPE="gnu" + elif test "x$($TAR -v | $GREP "bsdtar")" != "x"; then + TAR_TYPE="bsd" + elif test "x$OPENJDK_BUILD_OS" = "xsolaris"; then + TAR_TYPE="solaris" + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking what type of tar was found" >&5 +$as_echo_n "checking what type of tar was found... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAR_TYPE" >&5 +$as_echo "$TAR_TYPE" >&6; } + + if test "x$TAR_TYPE" = "xgnu"; then + TAR_INCLUDE_PARAM="T" + TAR_SUPPORTS_TRANSFORM="true" + else + TAR_INCLUDE_PARAM="I" + TAR_SUPPORTS_TRANSFORM="false" + fi + + + + # These tools might not be installed by default, # need hint on how to install them. diff --git a/common/autoconf/platform.m4 b/common/autoconf/platform.m4 index 2e99c452694..2fbac1d0dd3 100644 --- a/common/autoconf/platform.m4 +++ b/common/autoconf/platform.m4 @@ -366,6 +366,23 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER], fi AC_SUBST(OPENJDK_$1_OS_EXPORT_DIR) + # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles + # Macosx is osx and x86_64 is x64 + if test "x$OPENJDK_$1_OS" = xmacosx; then + OPENJDK_$1_OS_BUNDLE="osx" + else + OPENJDK_$1_OS_BUNDLE="$OPENJDK_TARGET_OS" + fi + if test "x$OPENJDK_$1_CPU" = xx86_64; then + OPENJDK_$1_CPU_BUNDLE="x64" + else + OPENJDK_$1_CPU_BUNDLE="$OPENJDK_$1_CPU" + fi + OPENJDK_$1_BUNDLE_PLATFORM="${OPENJDK_$1_OS_BUNDLE}-${OPENJDK_$1_CPU_BUNDLE}" + AC_SUBST(OPENJDK_$1_OS_BUNDLE) + AC_SUBST(OPENJDK_$1_CPU_BUNDLE) + AC_SUBST(OPENJDK_$1_BUNDLE_PLATFORM) + if test "x$OPENJDK_$1_CPU_BITS" = x64; then A_LP64="LP64:=" # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 891975f7209..02b761ef037 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -89,6 +89,10 @@ HOTSPOT_TARGET_CPU := @HOTSPOT_TARGET_CPU@ HOTSPOT_TARGET_CPU_ARCH := @HOTSPOT_TARGET_CPU_ARCH@ HOTSPOT_TARGET_CPU_DEFINE := @HOTSPOT_TARGET_CPU_DEFINE@ +OPENJDK_TARGET_CPU_BUNDLE:=@OPENJDK_TARGET_CPU_BUNDLE@ +OPENJDK_TARGET_OS_BUNDLE:=@OPENJDK_TARGET_OS_BUNDLE@ +OPENJDK_TARGET_BUNDLE_PLATFORM:=@OPENJDK_TARGET_BUNDLE_PLATFORM@ + # We are building on this build system. # When not cross-compiling, it is the same as the target. OPENJDK_BUILD_OS:=@OPENJDK_BUILD_OS@ @@ -268,6 +272,7 @@ BUILDTOOLS_OUTPUTDIR=$(BUILD_OUTPUT)/buildtools HOTSPOT_OUTPUTDIR=$(BUILD_OUTPUT)/hotspot JDK_OUTPUTDIR=$(BUILD_OUTPUT)/jdk IMAGES_OUTPUTDIR=$(BUILD_OUTPUT)/images +BUNDLES_OUTPUTDIR=$(BUILD_OUTPUT)/bundles TESTMAKE_OUTPUTDIR=$(BUILD_OUTPUT)/test-make MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/make-support # This does not get overridden in a bootcycle build @@ -632,6 +637,7 @@ ECHO:=@ECHO@ EGREP:=@EGREP@ FGREP:=@FGREP@ GREP:=@GREP@ +GZIP:=@GZIP@ HEAD:=@HEAD@ LS:=@LS@ LN:=@LN@ @@ -679,6 +685,9 @@ XCODEBUILD=@XCODEBUILD@ DTRACE := @DTRACE@ FIXPATH:=@FIXPATH@ +TAR_INCLUDE_PARAM:=@TAR_INCLUDE_PARAM@ +TAR_SUPPORTS_TRANSFORM:=@TAR_SUPPORTS_TRANSFORM@ + # Build setup ENABLE_JFR=@ENABLE_JFR@ ENABLE_INTREE_EC=@ENABLE_INTREE_EC@ @@ -785,11 +794,46 @@ SYMBOLS_IMAGE_DIR=$(IMAGES_OUTPUTDIR)/$(SYMBOLS_IMAGE_SUBDIR) # Interim image INTERIM_IMAGE_DIR := $(SUPPORT_OUTPUTDIR)/interim-image +# Docs image +DOCS_IMAGE_SUBDIR := docs +DOCS_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(DOCS_IMAGE_SUBDIR) + # Macosx bundles directory definitions -JDK_MACOSX_BUNDLE_SUBDIR=jdk-bundle/jdk-$(VERSION_NUMBER).jdk/Contents -JRE_MACOSX_BUNDLE_SUBDIR=jre-bundle/jre-$(VERSION_NUMBER).jre/Contents +JDK_MACOSX_BUNDLE_SUBDIR=jdk-bundle +JRE_MACOSX_BUNDLE_SUBDIR=jre-bundle JDK_MACOSX_BUNDLE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_MACOSX_BUNDLE_SUBDIR) JRE_MACOSX_BUNDLE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_MACOSX_BUNDLE_SUBDIR) +JDK_MACOSX_CONTENTS_SUBDIR=jdk-$(VERSION_NUMBER).jdk/Contents +JRE_MACOSX_CONTENTS_SUBDIR=jre-$(VERSION_NUMBER).jre/Contents +JDK_MACOSX_CONTENTS_DIR=$(JDK_MACOSX_BUNDLE_DIR)/$(JDK_MACOSX_CONTENTS_SUBDIR) +JRE_MACOSX_CONTENTS_DIR=$(JRE_MACOSX_BUNDLE_DIR)/$(JRE_MACOSX_CONTENTS_SUBDIR) + +# Bundle names +BASE_NAME := $(VERSION_SHORT)+$(VERSION_BUILD)_$(OPENJDK_TARGET_BUNDLE_PLATFORM) +ifeq ($(DEBUG_LEVEL), fastdebug) + DEBUG_PART := -debug +else ifneq ($(DEBUG_LEVEL), release) + DEBUG_PART := -$(DEBUG_LEVEL) +endif +JDK_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART).tar.gz +JRE_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART).tar.gz +JDK_SYMBOLS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz +JRE_SYMBOLS_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz +ifeq ($(OPENJDK_TARGET_OS), windows) + DEMOS_BUNDLE_NAME := jdk-$(BASE_NAME)_demo$(DEBUG_PART).zip +else + DEMOS_BUNDLE_NAME := jdk-$(BASE_NAME)_demo$(DEBUG_PART).tar.gz +endif +TEST_BUNDLE_NAME := jdk-$(BASE_NAME)_bin-tests$(DEBUG_PART).tar.gz +DOCS_BUNDLE_NAME := jdk-$(BASE_NAME)_doc-api-spec$(DEBUG_PART).tar.gz + +JDK_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(JDK_BUNDLE_NAME) +JRE_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(JRE_BUNDLE_NAME) +JDK_SYMBOLS_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(JDK_SYMBOLS_BUNDLE_NAME) +JRE_SYMBOLS_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(JRE_SYMBOLS_BUNDLE_NAME) +DEMOS_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(DEMOS_BUNDLE_NAME) +TEST_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(TEST_BUNDLE_NAME) +DOCS_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(DOCS_BUNDLE_NAME) # This macro is called to allow inclusion of closed source counterparts. # Unless overridden in closed sources, it expands to nothing. diff --git a/common/bin/compare.sh b/common/bin/compare.sh index db73426481d..0126b9c23ce 100644 --- a/common/bin/compare.sh +++ b/common/bin/compare.sh @@ -274,14 +274,19 @@ compare_file_types() { $MKDIR -p $WORK_DIR + FILE_TYPES_FILTER="$SED \ + -e 's/BuildID[^,]*//' \ + -e 's/last modified: .*//' \ + " + echo -n File types... found="" for f in `cd $OTHER_DIR && $FIND . ! -type d` do if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi if [ ! -f ${THIS_DIR}/$f ]; then continue; fi - OF=`cd ${OTHER_DIR} && $FILE -h $f | $SED 's/BuildID[^,]*//g'` - TF=`cd ${THIS_DIR} && $FILE -h $f | $SED 's/BuildID[^,]*//g'` + OF=$(cd ${OTHER_DIR} && $FILE -h $f | eval $FILE_TYPES_FILTER) + TF=$(cd ${THIS_DIR} && $FILE -h $f | eval $FILE_TYPES_FILTER) if [ "$OF" != "$TF" ] then if [ "`echo $OF | $GREP -c 'Zip archive data'`" -gt 0 ] \ @@ -320,7 +325,7 @@ compare_general_files() { ! -name "*.obj" ! -name "*.o" ! -name "JavaControlPanelHelper" \ ! -name "JavaUpdater" ! -name "JavaWSApplicationStub" \ ! -name "jspawnhelper" ! -name "JavawsLauncher" ! -name "*.a" \ - ! -name "finish_installation" ! -name "Sparkle" \ + ! -name "finish_installation" ! -name "Sparkle" ! -name "*.tar.gz" \ | $GREP -v "./bin/" | $SORT | $FILTER) echo Other files with binary differences... @@ -423,6 +428,10 @@ compare_zip_file() { then (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP) (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP) + elif [ "$TYPE" = "gz" ] + then + (cd $THIS_UNZIPDIR && $GUNZIP -c $THIS_ZIP | $TAR xf -) + (cd $OTHER_UNZIPDIR && $GUNZIP -c $OTHER_ZIP | $TAR xf -) else (cd $THIS_UNZIPDIR && $JIMAGE extract $THIS_ZIP) (cd $OTHER_UNZIPDIR && $JIMAGE extract $OTHER_ZIP) @@ -526,10 +535,11 @@ compare_all_zip_files() { OTHER_DIR=$2 WORK_DIR=$3 - ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" | $SORT | $FILTER ) + ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" -o -name "*.tar.gz" \ + | $SORT | $FILTER ) if [ -n "$ZIPS" ]; then - echo Zip files... + echo Zip/tar.gz files... return_value=0 for f in $ZIPS; do @@ -913,7 +923,7 @@ compare_bin_file() { FULLDUMP_MSG=" " DIFF_FULLDUMP= if [[ "$KNOWN_FULLDUMP_DIFF $ACCEPTED_FULLDUMP_DIFF" = *"$BIN_FILE"* ]]; then - FULLDUMP_MSG=" ! " + FULLDUMP_MSG=" ! " fi fi fi diff --git a/common/conf/jib-profiles.js b/common/conf/jib-profiles.js index a2e9cb50d84..2d752fd1074 100644 --- a/common/conf/jib-profiles.js +++ b/common/conf/jib-profiles.js @@ -215,7 +215,7 @@ var getJibProfilesCommon = function (input) { var common = {}; common.dependencies = ["boot_jdk", "gnumake", "jtreg"], - common.default_make_targets = ["product-images", "test-image"], + common.default_make_targets = ["product-bundles", "test-bundles"], common.default_make_targets_debug = common.default_make_targets; common.default_make_targets_slowdebug = common.default_make_targets; common.configure_args = ["--enable-jtreg-failure-handler"], @@ -245,7 +245,7 @@ var getJibProfilesProfiles = function (input, common) { target_cpu: "x64", dependencies: concat(common.dependencies, "devkit"), configure_args: concat(common.configure_args, "--with-zlib=system"), - default_make_targets: concat(common.default_make_targets, "docs-image") + default_make_targets: concat(common.default_make_targets, "docs-bundles") }, "linux-x86": { diff --git a/make/Bundles.gmk b/make/Bundles.gmk new file mode 100644 index 00000000000..8a1064aafb3 --- /dev/null +++ b/make/Bundles.gmk @@ -0,0 +1,300 @@ +# +# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +default: all + +include $(SPEC) +include MakeBase.gmk + +PRODUCT_TARGETS := +TEST_TARGETS := +DOCS_TARGETS := + +# On Windows tar frequently complains that "file changed as we read it" for +# some random source files. This seems to be cause by anti virus scanners and +# is most likely safe to ignore. When it happens, tar returns '1'. +ifeq ($(OPENJDK_BUILD_OS), windows) + TAR_IGNORE_EXIT_VALUE := || test "$$$$?" = "1" +endif + +# Hook to include the corresponding custom file, if present. +$(eval $(call IncludeCustomExtension, , Bundles-pre.gmk)) +################################################################################ +# BUNDLE : Name of bundle to create +# FILES : Files in BASE_DIR to add to bundle +# SPECIAL_INCLUDES : List of directories inside BASE_DIR to look for additional +# files in. These files will not get proper dependency handling. Use when +# files or directories may contain spaces. +# BASE_DIR : Base directory for the root dir in the bundle. +# SUBDIR : Optional name of root dir in bundle. +SetupBundleFile = $(NamedParamsMacroTemplate) +define SetupBundleFileBody + + $1_RELATIVE_FILES := $$(patsubst $$($1_BASE_DIR)/%, ./%, $$($1_FILES)) + + ifneq ($$(filter %.tar.gz, $$($1_BUNDLE_NAME)), ) + $1_TYPE := tar.gz + else ifneq ($$(filter %.zip, $$($1_BUNDLE_NAME)), ) + $1_TYPE := zip + else + $$(error Unknown bundle type $$($1_BUNDLE_NAME)) + endif + + $$(call SetIfEmpty, $1_UNZIP_DEBUGINFO, false) + + $(BUNDLES_OUTPUTDIR)/$$($1_BUNDLE_NAME): $$($1_FILES) + $$(eval $$(call ListPathsSafely, \ + $1_RELATIVE_FILES, \ + $(SUPPORT_OUTPUTDIR)/bundles/_$1_files)) + $$(call MakeDir, $$(@D)) + ifneq ($$($1_SPECIAL_INCLUDES), ) + $$(foreach i, $$($1_SPECIAL_INCLUDES), \ + ($(CD) $$($1_BASE_DIR) && $(FIND) ./$$i \ + >> $(SUPPORT_OUTPUTDIR)/bundles/_$1_files ) ; ) + endif + ifneq ($$($1_SUBDIR), ) + ifeq ($$($1_TYPE)-$(TAR_SUPPORTS_TRANSFORM)-$$($1_UNZIP_DEBUGINFO), tar.gz-true-false) + $(CD) $$($1_BASE_DIR) \ + && ( $(TAR) cf - -$(TAR_INCLUDE_PARAM) $(SUPPORT_OUTPUTDIR)/bundles/_$1_files \ + --transform 's|^|$$($1_SUBDIR)/|' $(TAR_IGNORE_EXIT_VALUE) ) \ + | $(GZIP) > $$@ + else + # If a subdir has been specified, copy all files into a temporary + # location with this subdir before creating the tar file + $(RM) -r $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) + $(MKDIR) -p $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) + ( $(CD) $$($1_BASE_DIR) \ + && $(TAR) cf - -$(TAR_INCLUDE_PARAM) $(SUPPORT_OUTPUTDIR)/bundles/_$1_files \ + $(TAR_IGNORE_EXIT_VALUE) ) \ + | ( $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) && $(TAR) xf - ) + # Unzip any zipped debuginfo files + ifeq ($$($1_UNZIP_DEBUGINFO), true) + for f in `$(FIND) $(SUPPORT_OUTPUTDIR)/bundles/$1/$$($1_SUBDIR) -name "*.diz"`; do \ + $(CD) $$$${f%/*} && $(UNZIP) -q $$$${f} && $(RM) $$$${f}; \ + done + endif + ifeq ($$($1_TYPE), tar.gz) + $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1 && \ + ( $(TAR) cf - $$($1_SUBDIR) $(TAR_IGNORE_EXIT_VALUE) ) | $(GZIP) > $$@ + else ifeq ($$($1_TYPE), zip) + $(CD) $(SUPPORT_OUTPUTDIR)/bundles/$1 && $(ZIP) -qr $$@ . + endif + endif + else + ifeq ($$($1_TYPE), tar.gz) + $(CD) $$($1_BASE_DIR) \ + && ( $(TAR) cf - -$(TAR_INCLUDE_PARAM) $(SUPPORT_OUTPUTDIR)/bundles/_$1_files \ + $(TAR_IGNORE_EXIT_VALUE) ) \ + | $(GZIP) > $$@ + else ifeq ($$($1_TYPE), zip) + $(CD) $$($1_BASE_DIR) \ + && $(ZIP) -qr $$@ . -i@$(SUPPORT_OUTPUTDIR)/bundles/_$1_files + endif + endif + + $1 += $(BUNDLES_OUTPUTDIR)/$$($1_BUNDLE_NAME) + +endef + +################################################################################ + +# On Macosx, we bundle up the macosx specific images which already have the +# correct base directories. +ifeq ($(OPENJDK_TARGET_OS), macosx) + JDK_IMAGE_DIR := $(JDK_MACOSX_BUNDLE_DIR) + JRE_IMAGE_DIR := $(JRE_MACOSX_BUNDLE_DIR) + JDK_IMAGE_HOMEDIR := $(JDK_MACOSX_CONTENTS_DIR)/Home + JRE_IMAGE_HOMEDIR := $(JRE_MACOSX_CONTENTS_DIR)/Home + JDK_BUNDLE_SUBDIR := + JRE_BUNDLE_SUBDIR := +else + JDK_IMAGE_HOMEDIR := $(JDK_IMAGE_DIR) + JRE_IMAGE_HOMEDIR := $(JRE_IMAGE_DIR) + JDK_BUNDLE_SUBDIR := jdk-$(VERSION_NUMBER) + JRE_BUNDLE_SUBDIR := jre-$(VERSION_NUMBER) + ifneq ($(DEBUG_LEVEL), release) + JDK_BUNDLE_SUBDIR := $(JDK_BUNDLE_SUBDIR)/$(DEBUG_LEVEL) + JRE_BUNDLE_SUBDIR := $(JRE_BUNDLE_SUBDIR)/$(DEBUG_LEVEL) + endif +endif + +################################################################################ + +ifneq ($(filter product-bundles, $(MAKECMDGOALS)), ) + $(eval $(call FillCacheFind, $(IMAGES_OUTPUTDIR))) + + SYMBOLS_EXCLUDE_PATTERN := %.debuginfo %.diz %.pdb %.map + + ALL_JDK_FILES := $(call CacheFind, $(JDK_IMAGE_DIR)) + + # Create special filter rules when dealing with unzipped .dSYM directories on + # macosx + ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(ZIP_DEBUGINFO_FILES), false) + JDK_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \ + $(call containing, .dSYM/, $(patsubst $(JDK_IMAGE_DIR)/%, %, $(ALL_JDK_FILES)))) + endif + endif + + JDK_BUNDLE_FILES := \ + $(filter-out \ + $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ + $(JDK_EXTRA_EXCLUDES) \ + $(SYMBOLS_EXCLUDE_PATTERN) \ + $(JDK_IMAGE_HOMEDIR)/demo/% $(JDK_IMAGE_HOMEDIR)/sample/% \ + , \ + $(ALL_JDK_FILES) \ + ) + DEMOS_BUNDLE_FILES := \ + $(filter-out \ + $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ + $(SYMBOLS_EXCLUDE_PATTERN) \ + , \ + $(filter \ + $(JDK_IMAGE_HOMEDIR)/demo/% $(JDK_IMAGE_HOMEDIR)/sample/% \ + $(JDK_IMAGE_HOMEDIR)/release \ + , \ + $(ALL_JDK_FILES) \ + ) \ + ) + JDK_SYMBOLS_BUNDLE_FILES := \ + $(filter \ + $(JDK_SYMBOLS_EXCLUDE_PATTERN) \ + $(SYMBOLS_EXCLUDE_PATTERN) \ + , \ + $(ALL_JDK_FILES) \ + ) \ + $(call CacheFind, $(SYMBOLS_IMAGE_DIR)) + + ALL_JRE_FILES := $(call CacheFind, $(JRE_IMAGE_DIR)) + + # Create special filter rules when dealing with unzipped .dSYM directories on + # macosx + ifeq ($(OPENJDK_TARGET_OS), macosx) + ifeq ($(ZIP_DEBUGINFO_FILES), false) + JRE_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \ + $(call containing, .dSYM/, $(patsubst $(JRE_IMAGE_DIR)/%, %, $(ALL_JRE_FILES)))) + endif + endif + + JRE_BUNDLE_FILES := $(filter-out \ + $(JRE_SYMBOLS_EXCLUDE_PATTERN) \ + $(SYMBOLS_EXCLUDE_PATTERN), \ + $(ALL_JRE_FILES)) + JRE_SYMBOLS_BUNDLE_FILES := $(filter \ + $(JRE_SYMBOLS_EXCLUDE_PATTERN) \ + $(SYMBOLS_EXCLUDE_PATTERN), \ + $(ALL_JRE_FILES)) + + $(eval $(call SetupBundleFile, BUILD_JDK_BUNDLE, \ + BUNDLE_NAME := $(JDK_BUNDLE_NAME), \ + FILES := $(JDK_BUNDLE_FILES), \ + SPECIAL_INCLUDES := $(JDK_SPECIAL_INCLUDES), \ + BASE_DIR := $(JDK_IMAGE_DIR), \ + SUBDIR := $(JDK_BUNDLE_SUBDIR), \ + )) + + PRODUCT_TARGETS += $(BUILD_JDK_BUNDLE) + + $(eval $(call SetupBundleFile, BUILD_JRE_BUNDLE, \ + BUNDLE_NAME := $(JRE_BUNDLE_NAME), \ + FILES := $(JRE_BUNDLE_FILES), \ + BASE_DIR := $(JRE_IMAGE_DIR), \ + SUBDIR := $(JRE_BUNDLE_SUBDIR), \ + )) + + PRODUCT_TARGETS += $(BUILD_JRE_BUNDLE) + + $(eval $(call SetupBundleFile, BUILD_JDK_SYMBOLS_BUNDLE, \ + BUNDLE_NAME := $(JDK_SYMBOLS_BUNDLE_NAME), \ + FILES := $(JDK_SYMBOLS_BUNDLE_FILES), \ + BASE_DIR := $(JDK_IMAGE_DIR), \ + SUBDIR := $(JDK_BUNDLE_SUBDIR), \ + UNZIP_DEBUGINFO := true, \ + )) + + PRODUCT_TARGETS += $(BUILD_JDK_SYMBOLS_BUNDLE) + + $(eval $(call SetupBundleFile, BUILD_JRE_SYMBOLS_BUNDLE, \ + BUNDLE_NAME := $(JRE_SYMBOLS_BUNDLE_NAME), \ + FILES := $(JRE_SYMBOLS_BUNDLE_FILES), \ + BASE_DIR := $(JRE_IMAGE_DIR), \ + SUBDIR := $(JRE_BUNDLE_SUBDIR), \ + UNZIP_DEBUGINFO := true, \ + )) + + PRODUCT_TARGETS += $(BUILD_JRE_SYMBOLS_BUNDLE) + + $(eval $(call SetupBundleFile, BUILD_DEMOS_BUNDLE, \ + BUNDLE_NAME := $(DEMOS_BUNDLE_NAME), \ + FILES := $(call DoubleDollar, $(DEMOS_BUNDLE_FILES)), \ + BASE_DIR := $(JDK_IMAGE_DIR), \ + SUBDIR := $(JDK_BUNDLE_SUBDIR), \ + )) + + PRODUCT_TARGETS += $(BUILD_DEMOS_BUNDLE) +endif + +################################################################################ + +ifneq ($(filter test-bundles, $(MAKECMDGOALS)), ) + TEST_BUNDLE_FILES := $(call CacheFind, $(TEST_IMAGE_DIR)) + + $(eval $(call SetupBundleFile, BUILD_TEST_BUNDLE, \ + BUNDLE_NAME := $(TEST_BUNDLE_NAME), \ + FILES := $(call DoubleDollar, $(TEST_BUNDLE_FILES)), \ + BASE_DIR := $(TEST_IMAGE_DIR), \ + )) + + TEST_TARGETS += $(BUILD_TEST_BUNDLE) +endif + +################################################################################ + +ifneq ($(filter docs-bundles, $(MAKECMDGOALS)), ) + DOCS_BUNDLE_FILES := $(call CacheFind, $(DOCS_IMAGE_DIR)) + + $(eval $(call SetupBundleFile, BUILD_DOCS_BUNDLE, \ + BUNDLE_NAME := $(DOCS_BUNDLE_NAME), \ + FILES := $(DOCS_BUNDLE_FILES), \ + BASE_DIR := $(DOCS_IMAGE_DIR), \ + SUBDIR := docs, \ + )) + + DOCS_TARGETS += $(BUILD_DOCS_BUNDLE) +endif + +################################################################################ + +# Hook to include the corresponding custom file, if present. +$(eval $(call IncludeCustomExtension, , Bundles.gmk)) + +################################################################################ + +product-bundles: $(PRODUCT_TARGETS) +test-bundles: $(TEST_TARGETS) +docs-bundles: $(DOCS_TARGETS) + +.PHONY: all default product-bundles test-bundles docs-bundles diff --git a/make/Javadoc.gmk b/make/Javadoc.gmk index 8804cff3f68..d27caaf85f1 100644 --- a/make/Javadoc.gmk +++ b/make/Javadoc.gmk @@ -44,7 +44,7 @@ include NON_CORE_PKGS.gmk # Definitions for directories # -DOCSDIR := $(IMAGES_OUTPUTDIR)/docs +DOCSDIR := $(DOCS_IMAGE_DIR) DOCSTMPDIR = $(SUPPORT_OUTPUTDIR)/docs HOTSPOT_DOCS_IMPORT_PATH=$(HOTSPOT_OUTPUTDIR)/docs diff --git a/make/Jprt.gmk b/make/Jprt.gmk index e82b84d5e11..09d6dc7ef7b 100644 --- a/make/Jprt.gmk +++ b/make/Jprt.gmk @@ -32,14 +32,6 @@ ifneq ($(CYGPATH), ) ifdef JPRT_ARCHIVE_BUNDLE override JPRT_ARCHIVE_BUNDLE := $(shell $(CYGPATH) -u $(JPRT_ARCHIVE_BUNDLE)) endif - ifdef JPRT_ARCHIVE_INSTALL_BUNDLE - override JPRT_ARCHIVE_INSTALL_BUNDLE := \ - $(shell $(CYGPATH) -u $(JPRT_ARCHIVE_INSTALL_BUNDLE)) - endif - ifdef JPRT_ARCHIVE_MODULES_BUNDLE - override JPRT_ARCHIVE_MODULES_BUNDLE := \ - $(shell $(CYGPATH) -u $(JPRT_ARCHIVE_MODULES_BUNDLE)) - endif ifdef JPRT_ARCHIVE_TEST_BUNDLE override JPRT_ARCHIVE_TEST_BUNDLE := \ $(shell $(CYGPATH) -u $(JPRT_ARCHIVE_TEST_BUNDLE)) @@ -55,12 +47,6 @@ endif ifndef JPRT_ARCHIVE_BUNDLE JPRT_ARCHIVE_BUNDLE=/tmp/jprt_bundles/jdk-image.zip endif -ifndef JPRT_ARCHIVE_INSTALL_BUNDLE - JPRT_ARCHIVE_INSTALL_BUNDLE=/tmp/jprt_bundles/product-install.zip -endif -ifndef JPRT_ARCHIVE_MODULES_BUNDLE - JPRT_ARCHIVE_MODULES_BUNDLE=/tmp/jprt_bundles/modules.zip -endif ifndef JPRT_ARCHIVE_TEST_BUNDLE JPRT_ARCHIVE_TEST_BUNDLE=/tmp/jprt_bundles/test-image.zip endif @@ -72,94 +58,51 @@ ifeq ($(SKIP_BOOT_CYCLE), false) jprt_bundle: bootcycle-images endif -# This target must be called in the context of a SPEC file -jprt_bundle: $(JPRT_ARCHIVE_BUNDLE) $(JPRT_ARCHIVE_TEST_BUNDLE) \ - $(JPRT_ARCHIVE_MODULES_BUNDLE) +################################################################################ +# JPRT specific bundling targets +JPRT_TARGET ?= $(DEFAULT_MAKE_TARGET) +ifeq ($(JPRT_TARGET), $(DEFAULT_MAKE_TARGET)) + jprt_bundle: $(DEFAULT_MAKE_TARGET) $(JPRT_ARCHIVE_BUNDLE) \ + $(JPRT_ARCHIVE_TEST_BUNDLE) -ifeq ($(GCOV_ENABLED), true) - jprt_bundle: $(JPRT_ARCHIVE_SYMBOLS_BUNDLE) -endif + SRC_JDK_IMAGE_DIR := $(JDK_IMAGE_DIR) + SRC_TEST_IMAGE_DIR := $(TEST_IMAGE_DIR) + + # This target must be called in the context of a SPEC file + $(JPRT_ARCHIVE_BUNDLE): product-images + $(call MakeDir, $(@D)) + $(CD) $(SRC_JDK_IMAGE_DIR) && $(ZIP) -y -q -r $@ . + + $(JPRT_ARCHIVE_TEST_BUNDLE): test-image + $(call MakeDir, $(@D)) + $(CD) $(SRC_TEST_IMAGE_DIR) && $(ZIP) -y -q -r $@ . + + ############################################################################## + # Optional symbols bundle + ifeq ($(GCOV_ENABLED), true) + jprt_bundle: $(JPRT_ARCHIVE_SYMBOLS_BUNDLE) + zip-bundles: $(SYMBOLS_ZIP_BUNDLE) + + $(JPRT_ARCHIVE_SYMBOLS_BUNDLE): product-images + $(call MakeDir, $(@D)) + $(CD) $(SYMBOLS_IMAGE_DIR) && $(ZIP) -y -q -r $@ . + + endif + + ############################################################################## -# This target must be called in the context of a SPEC file -$(JPRT_ARCHIVE_BUNDLE): bundles - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $(BUILD_OUTPUT)/bundles/$(JDK_IMAGE_SUBDIR).zip $@ - -$(JPRT_ARCHIVE_MODULES_BUNDLE): bundles - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $(BUILD_OUTPUT)/bundles/modules.zip $@ - -$(JPRT_ARCHIVE_TEST_BUNDLE): bundles - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $(BUILD_OUTPUT)/bundles/$(TEST_IMAGE_SUBDIR).zip $@ - -$(JPRT_ARCHIVE_SYMBOLS_BUNDLE): bundles - $(MKDIR) -p $(@D) - $(RM) $@ - $(CP) $(BUILD_OUTPUT)/bundles/$(SYMBOLS_IMAGE_SUBDIR).zip $@ - -SRC_JDK_IMAGE_DIR := $(JDK_IMAGE_DIR) -SRC_JRE_IMAGE_DIR := $(JRE_IMAGE_DIR) -SRC_TEST_IMAGE_DIR := $(TEST_IMAGE_DIR) -SRC_JDK_MACOSX_BUNDLE_DIR := $(JDK_MACOSX_BUNDLE_DIR) -SRC_JRE_MACOSX_BUNDLE_DIR := $(JRE_MACOSX_BUNDLE_DIR) - -# Bundle up the images -JPRT_TARGET ?= default -ifeq ($(JPRT_TARGET), default) - bundles: $(JPRT_TARGET) - @$(call TargetEnter) - $(MKDIR) -p $(BUILD_OUTPUT)/bundles - $(CD) $(SRC_JDK_IMAGE_DIR) && $(ZIP) -y -q -r \ - $(BUILD_OUTPUT)/bundles/$(JDK_IMAGE_SUBDIR).zip . - $(CD) $(SRC_JRE_IMAGE_DIR) && $(ZIP) -y -q -r \ - $(BUILD_OUTPUT)/bundles/$(JRE_IMAGE_SUBDIR).zip . - $(CD) $(SRC_TEST_IMAGE_DIR) && $(ZIP) -y -q -r \ - $(BUILD_OUTPUT)/bundles/$(TEST_IMAGE_SUBDIR).zip . - $(CD) $(IMAGES_OUTPUTDIR)/jmods && $(ZIP) -y -q -r \ - $(BUILD_OUTPUT)/bundles/modules.zip . - if [ -d $(BUILD_OUTPUT)/install/bundles ] ; then \ - $(CD) $(BUILD_OUTPUT)/install/bundles && $(ZIP) -y -q -r \ - $(JPRT_ARCHIVE_INSTALL_BUNDLE) . ; \ - fi - if [ -d $(SYMBOLS_IMAGE_DIR) ] ; then \ - $(CD) $(SYMBOLS_IMAGE_DIR) && $(ZIP) -y -q -r \ - $(BUILD_OUTPUT)/bundles/$(SYMBOLS_IMAGE_SUBDIR).zip . ; \ - fi - @$(call TargetExit) else - # Just fake the bundles - bundles: $(JPRT_TARGET) + # Just fake the main bundle to satisfy JPRT + jprt_bundle: $(JPRT_TARGET) @$(call TargetEnter) $(MKDIR) -p $(BUILD_OUTPUT)/bundles - $(CD) $(TOPDIR) && $(ZIP) -y -q -r \ - $(BUILD_OUTPUT)/bundles/$(JDK_IMAGE_SUBDIR).zip README - $(CD) $(TOPDIR) && $(ZIP) -y -q -r \ - $(BUILD_OUTPUT)/bundles/$(JRE_IMAGE_SUBDIR).zip README - $(CD) $(TOPDIR) && $(ZIP) -y -q -r \ - $(BUILD_OUTPUT)/bundles/$(TEST_IMAGE_SUBDIR).zip README - $(CD) $(TOPDIR) && $(ZIP) -y -q -r \ - $(BUILD_OUTPUT)/bundles/modules.zip README + $(CD) $(TOPDIR) && $(TAR) cf - README | $(GZIP) > \ + $(JPRT_ARCHIVE_BUNDLE) @$(call TargetExit) endif -# Copy images to one unified location regardless of platform etc. -final-images: $(JPRT_TARGET) - @$(call TargetEnter) - $(RM) -r $(BUILD_OUTPUT)/final-images - $(MKDIR) -p $(BUILD_OUTPUT)/final-images/$(JDK_IMAGE_SUBDIR) - $(MKDIR) -p $(BUILD_OUTPUT)/final-images/$(JRE_IMAGE_SUBDIR) - $(CP) -R -P $(SRC_JDK_IMAGE_DIR)/* $(BUILD_OUTPUT)/final-images/$(JDK_IMAGE_SUBDIR)/ - $(CP) -R -P $(SRC_JRE_IMAGE_DIR)/* $(BUILD_OUTPUT)/final-images/$(JRE_IMAGE_SUBDIR)/ - ifeq ($(OPENJDK_TARGET_OS),macosx) - $(MKDIR) -p $(BUILD_OUTPUT)/final-images/$(JDK_MACOSX_BUNDLE_SUBDIR) - $(MKDIR) -p $(BUILD_OUTPUT)/final-images/$(JRE_MACOSX_BUNDLE_SUBDIR) - $(CP) -R -P $(SRC_JDK_MACOSX_BUNDLE_DIR)/* $(BUILD_OUTPUT)/final-images/$(JDK_MACOSX_BUNDLE_SUBDIR)/ - $(CP) -R -P $(SRC_JRE_MACOSX_BUNDLE_DIR)/* $(BUILD_OUTPUT)/final-images/$(JRE_MACOSX_BUNDLE_SUBDIR)/ - endif - @$(call TargetExit) +ALL_TARGETS += jprt_bundle + +################################################################################ -ALL_TARGETS += jprt_bundle bundles final-images +$(eval $(call IncludeCustomExtension, , Jprt.gmk)) diff --git a/make/MacBundles.gmk b/make/MacBundles.gmk index ea8913eded5..f860e5e074a 100644 --- a/make/MacBundles.gmk +++ b/make/MacBundles.gmk @@ -34,7 +34,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) bundles: jre-bundle jdk-bundle - # JDK_MACOSX_BUNDLE_DIR and JRE_MACOSX_BUNDLE_DIR are defined in SPEC. + # JDK_MACOSX_CONTENTS_DIR and JRE_MACOSX_CONTENTS_DIR are defined in SPEC. MACOSX_PLIST_SRC := $(JDK_TOPDIR)/make/data/bundle @@ -52,27 +52,27 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) JDK_FILE_LIST := $(shell $(FIND) $(JDK_IMAGE_DIR)) JRE_FILE_LIST := $(shell $(FIND) $(JRE_IMAGE_DIR)) - JDK_TARGET_LIST := $(subst $(JDK_IMAGE_DIR)/,$(JDK_MACOSX_BUNDLE_DIR)/Home/,$(JDK_FILE_LIST)) - JRE_TARGET_LIST := $(subst $(JRE_IMAGE_DIR)/,$(JRE_MACOSX_BUNDLE_DIR)/Home/,$(JRE_FILE_LIST)) + JDK_TARGET_LIST := $(subst $(JDK_IMAGE_DIR)/,$(JDK_MACOSX_CONTENTS_DIR)/Home/,$(JDK_FILE_LIST)) + JRE_TARGET_LIST := $(subst $(JRE_IMAGE_DIR)/,$(JRE_MACOSX_CONTENTS_DIR)/Home/,$(JRE_FILE_LIST)) # Copy empty directories (jre/lib/applet). - $(JDK_MACOSX_BUNDLE_DIR)/Home/%: $(JDK_IMAGE_DIR)/% + $(JDK_MACOSX_CONTENTS_DIR)/Home/%: $(JDK_IMAGE_DIR)/% $(call LogInfo, Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)) $(MKDIR) -p $(@D) if [ -d "$<" ]; then $(MKDIR) -p $@; else $(CP) -f -R -P '$<' '$@'; fi - $(JRE_MACOSX_BUNDLE_DIR)/Home/%: $(JRE_IMAGE_DIR)/% + $(JRE_MACOSX_CONTENTS_DIR)/Home/%: $(JRE_IMAGE_DIR)/% $(call LogInfo, Copying $(patsubst $(OUTPUT_ROOT)/%,%,$@)) $(MKDIR) -p $(@D) if [ -d "$<" ]; then $(MKDIR) -p $@; else $(CP) -f -R -P '$<' '$@'; fi - $(JDK_MACOSX_BUNDLE_DIR)/MacOS/libjli.dylib: + $(JDK_MACOSX_CONTENTS_DIR)/MacOS/libjli.dylib: $(call LogInfo, Creating link $(patsubst $(OUTPUT_ROOT)/%,%,$@)) $(MKDIR) -p $(@D) $(RM) $@ $(LN) -s ../Home/lib/jli/libjli.dylib $@ - $(JRE_MACOSX_BUNDLE_DIR)/MacOS/libjli.dylib: + $(JRE_MACOSX_CONTENTS_DIR)/MacOS/libjli.dylib: $(call LogInfo, Creating link $(patsubst $(OUTPUT_ROOT)/%,%,$@)) $(MKDIR) -p $(@D) $(RM) $@ @@ -80,7 +80,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) $(eval $(call SetupTextFileProcessing, BUILD_JDK_PLIST, \ SOURCE_FILES := $(MACOSX_PLIST_SRC)/JDK-Info.plist, \ - OUTPUT_FILE := $(JDK_MACOSX_BUNDLE_DIR)/Info.plist, \ + OUTPUT_FILE := $(JDK_MACOSX_CONTENTS_DIR)/Info.plist, \ REPLACEMENTS := \ @@ID@@ => $(BUNDLE_ID).jdk ; \ @@NAME@@ => $(BUNDLE_NAME) ; \ @@ -92,7 +92,7 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) $(eval $(call SetupTextFileProcessing, BUILD_JRE_PLIST, \ SOURCE_FILES := $(MACOSX_PLIST_SRC)/JRE-Info.plist, \ - OUTPUT_FILE := $(JRE_MACOSX_BUNDLE_DIR)/Info.plist, \ + OUTPUT_FILE := $(JRE_MACOSX_CONTENTS_DIR)/Info.plist, \ REPLACEMENTS := \ @@ID@@ => $(BUNDLE_ID).jre ; \ @@NAME@@ => $(BUNDLE_NAME) ; \ @@ -102,13 +102,13 @@ ifeq ($(OPENJDK_TARGET_OS), macosx) @@VENDOR@@ => $(BUNDLE_VENDOR) , \ )) - jdk-bundle: $(JDK_TARGET_LIST) $(JDK_MACOSX_BUNDLE_DIR)/MacOS/libjli.dylib \ + jdk-bundle: $(JDK_TARGET_LIST) $(JDK_MACOSX_CONTENTS_DIR)/MacOS/libjli.dylib \ $(BUILD_JDK_PLIST) - $(SETFILE) -a B $(dir $(JDK_MACOSX_BUNDLE_DIR)) + $(SETFILE) -a B $(dir $(JDK_MACOSX_CONTENTS_DIR)) - jre-bundle: $(JRE_TARGET_LIST) $(JRE_MACOSX_BUNDLE_DIR)/MacOS/libjli.dylib \ + jre-bundle: $(JRE_TARGET_LIST) $(JRE_MACOSX_CONTENTS_DIR)/MacOS/libjli.dylib \ $(BUILD_JRE_PLIST) - $(SETFILE) -a B $(dir $(JRE_MACOSX_BUNDLE_DIR)) + $(SETFILE) -a B $(dir $(JRE_MACOSX_CONTENTS_DIR)) else # Not macosx diff --git a/make/Main.gmk b/make/Main.gmk index cd39052330d..823c0ad16d3 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -453,6 +453,20 @@ test-make: ALL_TARGETS += test test-hotspot-jtreg test-hotspot-jtreg-native \ test-hotspot-internal test-jdk-jtreg-native test-make +################################################################################ +# Bundles + +product-bundles: + +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk product-bundles) + +test-bundles: + +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk test-bundles) + +docs-bundles: + +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f Bundles.gmk docs-bundles) + +ALL_TARGETS += product-bundles test-bundles docs-bundles + ################################################################################ # Install targets @@ -678,6 +692,12 @@ else install: product-images + product-bundles: product-images + + test-bundles: test-image + + docs-bundles: docs-image + generate-summary: jmods endif @@ -758,12 +778,16 @@ docs-image: docs-javadoc docs-jvmtidoc test-image: prepare-test-image test-image-hotspot-jtreg-native \ test-image-jdk-jtreg-native test-image-failure-handler test-image-hotspot-gtest -# all-images is the top-most target, it builds all our deliverables ("images"). +# all-images builds all our deliverables as images. all-images: product-images test-image docs-image +# all-bundles packages all our deliverables as tar.gz bundles. +all-bundles: product-bundles test-bundles docs-bundles + ALL_TARGETS += buildtools gensrc gendata copy java rmic libs launchers jmods \ jdk.jdwp.agent-gensrc $(ALL_MODULES) demos samples exploded-image \ - create-buildjdk mac-bundles product-images docs-image test-image all-images + create-buildjdk mac-bundles product-images docs-image test-image all-images \ + all-bundles ################################################################################ @@ -774,9 +798,10 @@ default: $(DEFAULT_MAKE_TARGET) jdk: exploded-image images: product-images docs: docs-image +bundles: all-bundles all: all-images -ALL_TARGETS += default jdk images docs all +ALL_TARGETS += default jdk images docs bundles all ################################################################################ ################################################################################ diff --git a/make/common/MakeBase.gmk b/make/common/MakeBase.gmk index 1a33d69f3bb..3665297d036 100644 --- a/make/common/MakeBase.gmk +++ b/make/common/MakeBase.gmk @@ -145,7 +145,7 @@ ifeq ($(HAS_FILE_FUNCTION), true) $$(strip $2),$$(subst $$(SPACE),$$(NEWLINE),$$(strip $$($$(strip $1))))) endef -else # HAS_FILE_FUNCTION +else # HAS_FILE_FUNCTION = false $(eval compress_paths = \ $(strip $(shell $(CAT) $(SRC_ROOT)/make/common/support/ListPathsSafely-pre-compress.incl))) @@ -172,8 +172,8 @@ else # HAS_FILE_FUNCTION # Param 2 - File to print to # Param 3 - Set to true to append to file instead of overwriting define ListPathsSafely - ifneq (,$$(word 10001,$$($1))) - $$(error Cannot list safely more than 10000 paths. $1 has $$(words $$($1)) paths!) + ifneq (,$$(word 30001,$$($$(strip $1)))) + $$(error Cannot list safely more than 30000 paths. $1 has $$(words $$($$(strip $1))) paths!) endif $$(call MakeDir, $$(dir $2)) ifneq ($$(strip $3), true) @@ -229,6 +229,106 @@ else # HAS_FILE_FUNCTION $$(call ListPathsSafely_IfPrintf,$1,$2,9251,9500) $$(call ListPathsSafely_IfPrintf,$1,$2,9501,9750) $$(call ListPathsSafely_IfPrintf,$1,$2,9751,10000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,10001,10250) + $$(call ListPathsSafely_IfPrintf,$1,$2,10251,10500) + $$(call ListPathsSafely_IfPrintf,$1,$2,10501,10750) + $$(call ListPathsSafely_IfPrintf,$1,$2,10751,11000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,11001,11250) + $$(call ListPathsSafely_IfPrintf,$1,$2,11251,11500) + $$(call ListPathsSafely_IfPrintf,$1,$2,11501,11750) + $$(call ListPathsSafely_IfPrintf,$1,$2,11751,12000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,12001,12250) + $$(call ListPathsSafely_IfPrintf,$1,$2,12251,12500) + $$(call ListPathsSafely_IfPrintf,$1,$2,12501,12750) + $$(call ListPathsSafely_IfPrintf,$1,$2,12751,13000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,13001,13250) + $$(call ListPathsSafely_IfPrintf,$1,$2,13251,13500) + $$(call ListPathsSafely_IfPrintf,$1,$2,13501,13750) + $$(call ListPathsSafely_IfPrintf,$1,$2,13751,14000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,14001,14250) + $$(call ListPathsSafely_IfPrintf,$1,$2,14251,14500) + $$(call ListPathsSafely_IfPrintf,$1,$2,14501,14750) + $$(call ListPathsSafely_IfPrintf,$1,$2,14751,15000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,15001,15250) + $$(call ListPathsSafely_IfPrintf,$1,$2,15251,15500) + $$(call ListPathsSafely_IfPrintf,$1,$2,15501,15750) + $$(call ListPathsSafely_IfPrintf,$1,$2,15751,16000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,16001,16250) + $$(call ListPathsSafely_IfPrintf,$1,$2,16251,16500) + $$(call ListPathsSafely_IfPrintf,$1,$2,16501,16750) + $$(call ListPathsSafely_IfPrintf,$1,$2,16751,17000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,17001,17250) + $$(call ListPathsSafely_IfPrintf,$1,$2,17251,17500) + $$(call ListPathsSafely_IfPrintf,$1,$2,17501,17750) + $$(call ListPathsSafely_IfPrintf,$1,$2,17751,18000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,18001,18250) + $$(call ListPathsSafely_IfPrintf,$1,$2,18251,18500) + $$(call ListPathsSafely_IfPrintf,$1,$2,18501,18750) + $$(call ListPathsSafely_IfPrintf,$1,$2,18751,19000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,19001,19250) + $$(call ListPathsSafely_IfPrintf,$1,$2,19251,19500) + $$(call ListPathsSafely_IfPrintf,$1,$2,19501,19750) + $$(call ListPathsSafely_IfPrintf,$1,$2,19751,20000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,20001,20250) + $$(call ListPathsSafely_IfPrintf,$1,$2,20251,20500) + $$(call ListPathsSafely_IfPrintf,$1,$2,20501,20750) + $$(call ListPathsSafely_IfPrintf,$1,$2,20751,21000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,21001,21250) + $$(call ListPathsSafely_IfPrintf,$1,$2,21251,21500) + $$(call ListPathsSafely_IfPrintf,$1,$2,21501,21750) + $$(call ListPathsSafely_IfPrintf,$1,$2,21751,22000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,22001,22250) + $$(call ListPathsSafely_IfPrintf,$1,$2,22251,22500) + $$(call ListPathsSafely_IfPrintf,$1,$2,22501,22750) + $$(call ListPathsSafely_IfPrintf,$1,$2,22751,23000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,23001,23250) + $$(call ListPathsSafely_IfPrintf,$1,$2,23251,23500) + $$(call ListPathsSafely_IfPrintf,$1,$2,23501,23750) + $$(call ListPathsSafely_IfPrintf,$1,$2,23751,24000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,24001,24250) + $$(call ListPathsSafely_IfPrintf,$1,$2,24251,24500) + $$(call ListPathsSafely_IfPrintf,$1,$2,24501,24750) + $$(call ListPathsSafely_IfPrintf,$1,$2,24751,25000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,25001,25250) + $$(call ListPathsSafely_IfPrintf,$1,$2,25251,25500) + $$(call ListPathsSafely_IfPrintf,$1,$2,25501,25750) + $$(call ListPathsSafely_IfPrintf,$1,$2,25751,26000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,26001,26250) + $$(call ListPathsSafely_IfPrintf,$1,$2,26251,26500) + $$(call ListPathsSafely_IfPrintf,$1,$2,26501,26750) + $$(call ListPathsSafely_IfPrintf,$1,$2,26751,27000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,27001,27250) + $$(call ListPathsSafely_IfPrintf,$1,$2,27251,27500) + $$(call ListPathsSafely_IfPrintf,$1,$2,27501,27750) + $$(call ListPathsSafely_IfPrintf,$1,$2,27751,28000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,28001,28250) + $$(call ListPathsSafely_IfPrintf,$1,$2,28251,28500) + $$(call ListPathsSafely_IfPrintf,$1,$2,28501,28750) + $$(call ListPathsSafely_IfPrintf,$1,$2,28751,29000) + + $$(call ListPathsSafely_IfPrintf,$1,$2,29001,29250) + $$(call ListPathsSafely_IfPrintf,$1,$2,29251,29500) + $$(call ListPathsSafely_IfPrintf,$1,$2,29501,29750) + $$(call ListPathsSafely_IfPrintf,$1,$2,29751,30000) endef endif # HAS_FILE_FUNCTION @@ -420,8 +520,12 @@ else ifeq ($(OPENJDK_TARGET_OS),macosx) # set. Some files get their write permissions removed after being copied to the # output dir. When these are copied again to images, xattr would fail. By only clearing # attributes when they are present, failing on this is avoided. + # + # If copying a soft link to a directory, need to delete the target first to avoid + # weird errors. define install-file $(MKDIR) -p '$(@D)' + $(RM) '$@' $(CP) -fRP '$<' '$@' if [ -n "`$(XATTR) -l '$@'`" ]; then $(XATTR) -c '$@'; fi endef -- GitLab From 05ae0adfe417c94367242a17bacc43ed31242c9b Mon Sep 17 00:00:00 2001 From: Jon Masamitsu Date: Wed, 4 May 2016 15:04:15 -0700 Subject: [PATCH 294/400] 8156050: ParallelCompact_test should skip test if UseParallelOldGC is off Reviewed-by: drwhite, pliden --- hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp index 1586a771e48..8f36021afc9 100644 --- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp @@ -379,7 +379,7 @@ print_initial_summary_data(ParallelCompactData& summary_data, } void ParallelCompact_test() { - if (!UseParallelGC) { + if (!UseParallelOldGC) { return; } // Check that print_generic_summary_data() does not print the -- GitLab From 7057abda2966b6f679c457873bbe4b5e1cd5dd28 Mon Sep 17 00:00:00 2001 From: Ahmed Khawaja Date: Wed, 4 May 2016 15:30:21 -0700 Subject: [PATCH 295/400] 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC Reviewed-by: kvn --- .../aarch64/vm/c1_LIRGenerator_aarch64.cpp | 4 + .../src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp | 4 + .../cpu/sparc/vm/c1_LIRGenerator_sparc.cpp | 84 ++++++++ .../src/cpu/sparc/vm/macroAssembler_sparc.cpp | 197 ++++++++++++++++-- .../src/cpu/sparc/vm/macroAssembler_sparc.hpp | 2 + .../src/cpu/sparc/vm/stubGenerator_sparc.cpp | 184 +--------------- .../src/cpu/sparc/vm/stubRoutines_sparc.cpp | 61 +++++- .../src/cpu/sparc/vm/stubRoutines_sparc.hpp | 3 +- .../vm/templateInterpreterGenerator_sparc.cpp | 50 ++++- .../src/cpu/x86/vm/c1_LIRGenerator_x86.cpp | 4 + hotspot/src/share/vm/c1/c1_Compiler.cpp | 6 +- hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 5 + hotspot/src/share/vm/c1/c1_LIRGenerator.hpp | 1 + hotspot/src/share/vm/c1/c1_Runtime1.cpp | 1 + 14 files changed, 414 insertions(+), 192 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp index 5d47ae7a9b7..4f07b70b605 100644 --- a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp @@ -1029,6 +1029,10 @@ void LIRGenerator::do_update_CRC32(Intrinsic* x) { } } +void LIRGenerator::do_update_CRC32C(Intrinsic* x) { + Unimplemented(); +} + // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f // _i2b, _i2c, _i2s void LIRGenerator::do_Convert(Convert* x) { diff --git a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp index d8f51ff9cf2..99f8ca08bd7 100644 --- a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp @@ -1427,3 +1427,7 @@ void LIRGenerator::do_update_CRC32(Intrinsic* x) { } } } + +void LIRGenerator::do_update_CRC32C(Intrinsic* x) { + Unimplemented(); +} diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp index f81a79a664a..8f79dca209f 100644 --- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp @@ -868,6 +868,90 @@ void LIRGenerator::do_update_CRC32(Intrinsic* x) { } } +void LIRGenerator::do_update_CRC32C(Intrinsic* x) { + // Make all state_for calls early since they can emit code + LIR_Opr result = rlock_result(x); + int flags = 0; + switch (x->id()) { + case vmIntrinsics::_updateBytesCRC32C: + case vmIntrinsics::_updateDirectByteBufferCRC32C: { + + bool is_updateBytes = (x->id() == vmIntrinsics::_updateBytesCRC32C); + int array_offset = is_updateBytes ? arrayOopDesc::base_offset_in_bytes(T_BYTE) : 0; + + LIRItem crc(x->argument_at(0), this); + LIRItem buf(x->argument_at(1), this); + LIRItem off(x->argument_at(2), this); + LIRItem end(x->argument_at(3), this); + + buf.load_item(); + off.load_nonconstant(); + end.load_nonconstant(); + + // len = end - off + LIR_Opr len = end.result(); + LIR_Opr tmpA = new_register(T_INT); + LIR_Opr tmpB = new_register(T_INT); + __ move(end.result(), tmpA); + __ move(off.result(), tmpB); + __ sub(tmpA, tmpB, tmpA); + len = tmpA; + + LIR_Opr index = off.result(); + + if(off.result()->is_constant()) { + index = LIR_OprFact::illegalOpr; + array_offset += off.result()->as_jint(); + } + + LIR_Opr base_op = buf.result(); + + if (index->is_valid()) { + LIR_Opr tmp = new_register(T_LONG); + __ convert(Bytecodes::_i2l, index, tmp); + index = tmp; + if (index->is_constant()) { + array_offset += index->as_constant_ptr()->as_jint(); + index = LIR_OprFact::illegalOpr; + } else if (index->is_register()) { + LIR_Opr tmp2 = new_register(T_LONG); + LIR_Opr tmp3 = new_register(T_LONG); + __ move(base_op, tmp2); + __ move(index, tmp3); + __ add(tmp2, tmp3, tmp2); + base_op = tmp2; + } else { + ShouldNotReachHere(); + } + } + + LIR_Address* a = new LIR_Address(base_op, array_offset, T_BYTE); + + BasicTypeList signature(3); + signature.append(T_INT); + signature.append(T_ADDRESS); + signature.append(T_INT); + CallingConvention* cc = frame_map()->c_calling_convention(&signature); + const LIR_Opr result_reg = result_register_for(x->type()); + + LIR_Opr addr = new_pointer_register(); + __ leal(LIR_OprFact::address(a), addr); + + crc.load_item_force(cc->at(0)); + __ move(addr, cc->at(1)); + __ move(len, cc->at(2)); + + __ call_runtime_leaf(StubRoutines::updateBytesCRC32C(), getThreadTemp(), result_reg, cc->args()); + __ move(result_reg, result); + + break; + } + default: { + ShouldNotReachHere(); + } + } +} + // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f // _i2b, _i2c, _i2s void LIRGenerator::do_Convert(Convert* x) { diff --git a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp index 90ba2168eab..d6cf85f4a53 100644 --- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.cpp @@ -4837,21 +4837,21 @@ void MacroAssembler::update_byte_crc32(Register crc, Register val, Register tabl // Reverse byte order of lower 32 bits, assuming upper 32 bits all zeros void MacroAssembler::reverse_bytes_32(Register src, Register dst, Register tmp) { - srlx(src, 24, dst); + srlx(src, 24, dst); - sllx(src, 32+8, tmp); - srlx(tmp, 32+24, tmp); - sllx(tmp, 8, tmp); - or3(dst, tmp, dst); + sllx(src, 32+8, tmp); + srlx(tmp, 32+24, tmp); + sllx(tmp, 8, tmp); + or3(dst, tmp, dst); - sllx(src, 32+16, tmp); - srlx(tmp, 32+24, tmp); - sllx(tmp, 16, tmp); - or3(dst, tmp, dst); + sllx(src, 32+16, tmp); + srlx(tmp, 32+24, tmp); + sllx(tmp, 16, tmp); + or3(dst, tmp, dst); - sllx(src, 32+24, tmp); - srlx(tmp, 32, tmp); - or3(dst, tmp, dst); + sllx(src, 32+24, tmp); + srlx(tmp, 32, tmp); + or3(dst, tmp, dst); } void MacroAssembler::movitof_revbytes(Register src, FloatRegister dst, Register tmp1, Register tmp2) { @@ -5103,3 +5103,176 @@ void MacroAssembler::kernel_crc32(Register crc, Register buf, Register len, Regi not1(crc); } +#define CHUNK_LEN 128 /* 128 x 8B = 1KB */ +#define CHUNK_K1 0x1307a0206 /* reverseBits(pow(x, CHUNK_LEN*8*8*3 - 32) mod P(x)) << 1 */ +#define CHUNK_K2 0x1a0f717c4 /* reverseBits(pow(x, CHUNK_LEN*8*8*2 - 32) mod P(x)) << 1 */ +#define CHUNK_K3 0x0170076fa /* reverseBits(pow(x, CHUNK_LEN*8*8*1 - 32) mod P(x)) << 1 */ + +void MacroAssembler::kernel_crc32c(Register crc, Register buf, Register len, Register table) { + + Label L_crc32c_head, L_crc32c_aligned; + Label L_crc32c_parallel, L_crc32c_parallel_loop; + Label L_crc32c_serial, L_crc32c_x32_loop, L_crc32c_x8, L_crc32c_x8_loop; + Label L_crc32c_done, L_crc32c_tail, L_crc32c_return; + + set(ExternalAddress(StubRoutines::crc32c_table_addr()), table); + + cmp_and_br_short(len, 0, Assembler::lessEqual, Assembler::pn, L_crc32c_return); + + // clear upper 32 bits of crc + clruwu(crc); + + and3(buf, 7, G4); + cmp_and_brx_short(G4, 0, Assembler::equal, Assembler::pt, L_crc32c_aligned); + + mov(8, G1); + sub(G1, G4, G4); + + // ------ process the misaligned head (7 bytes or less) ------ + bind(L_crc32c_head); + + // crc = (crc >>> 8) ^ byteTable[(crc ^ b) & 0xFF]; + ldub(buf, 0, G1); + update_byte_crc32(crc, G1, table); + + inc(buf); + dec(len); + cmp_and_br_short(len, 0, Assembler::equal, Assembler::pn, L_crc32c_return); + dec(G4); + cmp_and_br_short(G4, 0, Assembler::greater, Assembler::pt, L_crc32c_head); + + // ------ process the 8-byte-aligned body ------ + bind(L_crc32c_aligned); + nop(); + cmp_and_br_short(len, 8, Assembler::less, Assembler::pn, L_crc32c_tail); + + // reverse the byte order of lower 32 bits to big endian, and move to FP side + movitof_revbytes(crc, F0, G1, G3); + + set(CHUNK_LEN*8*4, G4); + cmp_and_br_short(len, G4, Assembler::less, Assembler::pt, L_crc32c_serial); + + // ------ process four 1KB chunks in parallel ------ + bind(L_crc32c_parallel); + + fzero(FloatRegisterImpl::D, F2); + fzero(FloatRegisterImpl::D, F4); + fzero(FloatRegisterImpl::D, F6); + + mov(CHUNK_LEN - 1, G4); + bind(L_crc32c_parallel_loop); + // schedule ldf's ahead of crc32c's to hide the load-use latency + ldf(FloatRegisterImpl::D, buf, 0, F8); + ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*8, F10); + ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*16, F12); + ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*24, F14); + crc32c(F0, F8, F0); + crc32c(F2, F10, F2); + crc32c(F4, F12, F4); + crc32c(F6, F14, F6); + inc(buf, 8); + dec(G4); + cmp_and_br_short(G4, 0, Assembler::greater, Assembler::pt, L_crc32c_parallel_loop); + + ldf(FloatRegisterImpl::D, buf, 0, F8); + ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*8, F10); + ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*16, F12); + crc32c(F0, F8, F0); + crc32c(F2, F10, F2); + crc32c(F4, F12, F4); + + inc(buf, CHUNK_LEN*24); + ldfl(FloatRegisterImpl::D, buf, G0, F14); // load in little endian + inc(buf, 8); + + prefetch(buf, 0, Assembler::severalReads); + prefetch(buf, CHUNK_LEN*8, Assembler::severalReads); + prefetch(buf, CHUNK_LEN*16, Assembler::severalReads); + prefetch(buf, CHUNK_LEN*24, Assembler::severalReads); + + // move to INT side, and reverse the byte order of lower 32 bits to little endian + movftoi_revbytes(F0, O4, G1, G4); + movftoi_revbytes(F2, O5, G1, G4); + movftoi_revbytes(F4, G5, G1, G4); + + // combine the results of 4 chunks + set64(CHUNK_K1, G3, G1); + xmulx(O4, G3, O4); + set64(CHUNK_K2, G3, G1); + xmulx(O5, G3, O5); + set64(CHUNK_K3, G3, G1); + xmulx(G5, G3, G5); + + movdtox(F14, G4); + xor3(O4, O5, O5); + xor3(G5, O5, O5); + xor3(G4, O5, O5); + + // reverse the byte order to big endian, via stack, and move to FP side + // TODO: use new revb instruction + add(SP, -8, G1); + srlx(G1, 3, G1); + sllx(G1, 3, G1); + stx(O5, G1, G0); + ldfl(FloatRegisterImpl::D, G1, G0, F2); // load in little endian + + crc32c(F6, F2, F0); + + set(CHUNK_LEN*8*4, G4); + sub(len, G4, len); + cmp_and_br_short(len, G4, Assembler::greaterEqual, Assembler::pt, L_crc32c_parallel); + nop(); + cmp_and_br_short(len, 0, Assembler::equal, Assembler::pt, L_crc32c_done); + + bind(L_crc32c_serial); + + mov(32, G4); + cmp_and_br_short(len, G4, Assembler::less, Assembler::pn, L_crc32c_x8); + + // ------ process 32B chunks ------ + bind(L_crc32c_x32_loop); + ldf(FloatRegisterImpl::D, buf, 0, F2); + crc32c(F0, F2, F0); + ldf(FloatRegisterImpl::D, buf, 8, F2); + crc32c(F0, F2, F0); + ldf(FloatRegisterImpl::D, buf, 16, F2); + crc32c(F0, F2, F0); + ldf(FloatRegisterImpl::D, buf, 24, F2); + inc(buf, 32); + crc32c(F0, F2, F0); + dec(len, 32); + cmp_and_br_short(len, G4, Assembler::greaterEqual, Assembler::pt, L_crc32c_x32_loop); + + bind(L_crc32c_x8); + nop(); + cmp_and_br_short(len, 8, Assembler::less, Assembler::pt, L_crc32c_done); + + // ------ process 8B chunks ------ + bind(L_crc32c_x8_loop); + ldf(FloatRegisterImpl::D, buf, 0, F2); + inc(buf, 8); + crc32c(F0, F2, F0); + dec(len, 8); + cmp_and_br_short(len, 8, Assembler::greaterEqual, Assembler::pt, L_crc32c_x8_loop); + + bind(L_crc32c_done); + + // move to INT side, and reverse the byte order of lower 32 bits to little endian + movftoi_revbytes(F0, crc, G1, G3); + + cmp_and_br_short(len, 0, Assembler::equal, Assembler::pt, L_crc32c_return); + + // ------ process the misaligned tail (7 bytes or less) ------ + bind(L_crc32c_tail); + + // crc = (crc >>> 8) ^ byteTable[(crc ^ b) & 0xFF]; + ldub(buf, 0, G1); + update_byte_crc32(crc, G1, table); + + inc(buf); + dec(len); + cmp_and_br_short(len, 0, Assembler::greater, Assembler::pt, L_crc32c_tail); + + bind(L_crc32c_return); + nop(); +} diff --git a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.hpp b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.hpp index dbbfbbc1267..af2a1b8e7c1 100644 --- a/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/macroAssembler_sparc.hpp @@ -1418,6 +1418,8 @@ public: // Fold 8-bit data void fold_8bit_crc32(Register xcrc, Register table, Register xtmp, Register tmp); void fold_8bit_crc32(Register crc, Register table, Register tmp); + // CRC32C code for java.util.zip.CRC32C::updateBytes/updateDirectByteBuffer instrinsic. + void kernel_crc32c(Register crc, Register buf, Register len, Register table); }; diff --git a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp index db2c5eefac8..c8f78cbfadc 100644 --- a/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/stubGenerator_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -4909,11 +4909,6 @@ class StubGenerator: public StubCodeGenerator { return start; } -#define CHUNK_LEN 128 /* 128 x 8B = 1KB */ -#define CHUNK_K1 0x1307a0206 /* reverseBits(pow(x, CHUNK_LEN*8*8*3 - 32) mod P(x)) << 1 */ -#define CHUNK_K2 0x1a0f717c4 /* reverseBits(pow(x, CHUNK_LEN*8*8*2 - 32) mod P(x)) << 1 */ -#define CHUNK_K3 0x0170076fa /* reverseBits(pow(x, CHUNK_LEN*8*8*1 - 32) mod P(x)) << 1 */ - /** * Arguments: * @@ -4938,171 +4933,8 @@ class StubGenerator: public StubCodeGenerator { const Register len = O2; // number of bytes const Register table = O3; // byteTable - Label L_crc32c_head, L_crc32c_aligned; - Label L_crc32c_parallel, L_crc32c_parallel_loop; - Label L_crc32c_serial, L_crc32c_x32_loop, L_crc32c_x8, L_crc32c_x8_loop; - Label L_crc32c_done, L_crc32c_tail, L_crc32c_return; - - __ cmp_and_br_short(len, 0, Assembler::lessEqual, Assembler::pn, L_crc32c_return); - - // clear upper 32 bits of crc - __ clruwu(crc); - - __ and3(buf, 7, G4); - __ cmp_and_brx_short(G4, 0, Assembler::equal, Assembler::pt, L_crc32c_aligned); - - __ mov(8, G1); - __ sub(G1, G4, G4); - - // ------ process the misaligned head (7 bytes or less) ------ - __ BIND(L_crc32c_head); - - // crc = (crc >>> 8) ^ byteTable[(crc ^ b) & 0xFF]; - __ ldub(buf, 0, G1); - __ update_byte_crc32(crc, G1, table); - - __ inc(buf); - __ dec(len); - __ cmp_and_br_short(len, 0, Assembler::equal, Assembler::pn, L_crc32c_return); - __ dec(G4); - __ cmp_and_br_short(G4, 0, Assembler::greater, Assembler::pt, L_crc32c_head); - - // ------ process the 8-byte-aligned body ------ - __ BIND(L_crc32c_aligned); - __ nop(); - __ cmp_and_br_short(len, 8, Assembler::less, Assembler::pn, L_crc32c_tail); - - // reverse the byte order of lower 32 bits to big endian, and move to FP side - __ movitof_revbytes(crc, F0, G1, G3); - - __ set(CHUNK_LEN*8*4, G4); - __ cmp_and_br_short(len, G4, Assembler::less, Assembler::pt, L_crc32c_serial); - - // ------ process four 1KB chunks in parallel ------ - __ BIND(L_crc32c_parallel); - - __ fzero(FloatRegisterImpl::D, F2); - __ fzero(FloatRegisterImpl::D, F4); - __ fzero(FloatRegisterImpl::D, F6); - - __ mov(CHUNK_LEN - 1, G4); - __ BIND(L_crc32c_parallel_loop); - // schedule ldf's ahead of crc32c's to hide the load-use latency - __ ldf(FloatRegisterImpl::D, buf, 0, F8); - __ ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*8, F10); - __ ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*16, F12); - __ ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*24, F14); - __ crc32c(F0, F8, F0); - __ crc32c(F2, F10, F2); - __ crc32c(F4, F12, F4); - __ crc32c(F6, F14, F6); - __ inc(buf, 8); - __ dec(G4); - __ cmp_and_br_short(G4, 0, Assembler::greater, Assembler::pt, L_crc32c_parallel_loop); - - __ ldf(FloatRegisterImpl::D, buf, 0, F8); - __ ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*8, F10); - __ ldf(FloatRegisterImpl::D, buf, CHUNK_LEN*16, F12); - __ crc32c(F0, F8, F0); - __ crc32c(F2, F10, F2); - __ crc32c(F4, F12, F4); - - __ inc(buf, CHUNK_LEN*24); - __ ldfl(FloatRegisterImpl::D, buf, G0, F14); // load in little endian - __ inc(buf, 8); - - __ prefetch(buf, 0, Assembler::severalReads); - __ prefetch(buf, CHUNK_LEN*8, Assembler::severalReads); - __ prefetch(buf, CHUNK_LEN*16, Assembler::severalReads); - __ prefetch(buf, CHUNK_LEN*24, Assembler::severalReads); - - // move to INT side, and reverse the byte order of lower 32 bits to little endian - __ movftoi_revbytes(F0, O4, G1, G4); - __ movftoi_revbytes(F2, O5, G1, G4); - __ movftoi_revbytes(F4, G5, G1, G4); - - // combine the results of 4 chunks - __ set64(CHUNK_K1, G3, G1); - __ xmulx(O4, G3, O4); - __ set64(CHUNK_K2, G3, G1); - __ xmulx(O5, G3, O5); - __ set64(CHUNK_K3, G3, G1); - __ xmulx(G5, G3, G5); - - __ movdtox(F14, G4); - __ xor3(O4, O5, O5); - __ xor3(G5, O5, O5); - __ xor3(G4, O5, O5); - - // reverse the byte order to big endian, via stack, and move to FP side - __ add(SP, -8, G1); - __ srlx(G1, 3, G1); - __ sllx(G1, 3, G1); - __ stx(O5, G1, G0); - __ ldfl(FloatRegisterImpl::D, G1, G0, F2); // load in little endian - - __ crc32c(F6, F2, F0); - - __ set(CHUNK_LEN*8*4, G4); - __ sub(len, G4, len); - __ cmp_and_br_short(len, G4, Assembler::greaterEqual, Assembler::pt, L_crc32c_parallel); - __ nop(); - __ cmp_and_br_short(len, 0, Assembler::equal, Assembler::pt, L_crc32c_done); - - __ BIND(L_crc32c_serial); - - __ mov(32, G4); - __ cmp_and_br_short(len, G4, Assembler::less, Assembler::pn, L_crc32c_x8); - - // ------ process 32B chunks ------ - __ BIND(L_crc32c_x32_loop); - __ ldf(FloatRegisterImpl::D, buf, 0, F2); - __ inc(buf, 8); - __ crc32c(F0, F2, F0); - __ ldf(FloatRegisterImpl::D, buf, 0, F2); - __ inc(buf, 8); - __ crc32c(F0, F2, F0); - __ ldf(FloatRegisterImpl::D, buf, 0, F2); - __ inc(buf, 8); - __ crc32c(F0, F2, F0); - __ ldf(FloatRegisterImpl::D, buf, 0, F2); - __ inc(buf, 8); - __ crc32c(F0, F2, F0); - __ dec(len, 32); - __ cmp_and_br_short(len, G4, Assembler::greaterEqual, Assembler::pt, L_crc32c_x32_loop); - - __ BIND(L_crc32c_x8); - __ nop(); - __ cmp_and_br_short(len, 8, Assembler::less, Assembler::pt, L_crc32c_done); - - // ------ process 8B chunks ------ - __ BIND(L_crc32c_x8_loop); - __ ldf(FloatRegisterImpl::D, buf, 0, F2); - __ inc(buf, 8); - __ crc32c(F0, F2, F0); - __ dec(len, 8); - __ cmp_and_br_short(len, 8, Assembler::greaterEqual, Assembler::pt, L_crc32c_x8_loop); - - __ BIND(L_crc32c_done); - - // move to INT side, and reverse the byte order of lower 32 bits to little endian - __ movftoi_revbytes(F0, crc, G1, G3); + __ kernel_crc32c(crc, buf, len, table); - __ cmp_and_br_short(len, 0, Assembler::equal, Assembler::pt, L_crc32c_return); - - // ------ process the misaligned tail (7 bytes or less) ------ - __ BIND(L_crc32c_tail); - - // crc = (crc >>> 8) ^ byteTable[(crc ^ b) & 0xFF]; - __ ldub(buf, 0, G1); - __ update_byte_crc32(crc, G1, table); - - __ inc(buf); - __ dec(len); - __ cmp_and_br_short(len, 0, Assembler::greater, Assembler::pt, L_crc32c_tail); - - __ BIND(L_crc32c_return); - __ nop(); __ retl(); __ delayed()->nop(); @@ -5366,6 +5198,12 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_crc_table_adr = (address)StubRoutines::Sparc::_crc_table; StubRoutines::_updateBytesCRC32 = generate_updateBytesCRC32(); } + + if (UseCRC32CIntrinsics) { + // set table address before stub generation which use it + StubRoutines::_crc32c_table_addr = (address)StubRoutines::Sparc::_crc32c_table; + StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(); + } } @@ -5425,12 +5263,6 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_sha512_implCompress = generate_sha512_implCompress(false, "sha512_implCompress"); StubRoutines::_sha512_implCompressMB = generate_sha512_implCompress(true, "sha512_implCompressMB"); } - - // generate CRC32C intrinsic code - if (UseCRC32CIntrinsics) { - StubRoutines::_updateBytesCRC32C = generate_updateBytesCRC32C(); - } - // generate Adler32 intrinsics code if (UseAdler32Intrinsics) { StubRoutines::_updateBytesAdler32 = generate_updateBytesAdler32(); diff --git a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.cpp b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.cpp index f8083c0f273..63cbcf05945 100644 --- a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -147,3 +147,62 @@ juint StubRoutines::Sparc::_crc_table[] = 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, 0x2d02ef8dUL }; + +/** + * CRC32C constants lookup table + */ +juint StubRoutines::Sparc::_crc32c_table[] = +{ + 0x00000000UL, 0xF26B8303UL, 0xE13B70F7UL, 0x1350F3F4UL, 0xC79A971FUL, + 0x35F1141CUL, 0x26A1E7E8UL, 0xD4CA64EBUL, 0x8AD958CFUL, 0x78B2DBCCUL, + 0x6BE22838UL, 0x9989AB3BUL, 0x4D43CFD0UL, 0xBF284CD3UL, 0xAC78BF27UL, + 0x5E133C24UL, 0x105EC76FUL, 0xE235446CUL, 0xF165B798UL, 0x030E349BUL, + 0xD7C45070UL, 0x25AFD373UL, 0x36FF2087UL, 0xC494A384UL, 0x9A879FA0UL, + 0x68EC1CA3UL, 0x7BBCEF57UL, 0x89D76C54UL, 0x5D1D08BFUL, 0xAF768BBCUL, + 0xBC267848UL, 0x4E4DFB4BUL, 0x20BD8EDEUL, 0xD2D60DDDUL, 0xC186FE29UL, + 0x33ED7D2AUL, 0xE72719C1UL, 0x154C9AC2UL, 0x061C6936UL, 0xF477EA35UL, + 0xAA64D611UL, 0x580F5512UL, 0x4B5FA6E6UL, 0xB93425E5UL, 0x6DFE410EUL, + 0x9F95C20DUL, 0x8CC531F9UL, 0x7EAEB2FAUL, 0x30E349B1UL, 0xC288CAB2UL, + 0xD1D83946UL, 0x23B3BA45UL, 0xF779DEAEUL, 0x05125DADUL, 0x1642AE59UL, + 0xE4292D5AUL, 0xBA3A117EUL, 0x4851927DUL, 0x5B016189UL, 0xA96AE28AUL, + 0x7DA08661UL, 0x8FCB0562UL, 0x9C9BF696UL, 0x6EF07595UL, 0x417B1DBCUL, + 0xB3109EBFUL, 0xA0406D4BUL, 0x522BEE48UL, 0x86E18AA3UL, 0x748A09A0UL, + 0x67DAFA54UL, 0x95B17957UL, 0xCBA24573UL, 0x39C9C670UL, 0x2A993584UL, + 0xD8F2B687UL, 0x0C38D26CUL, 0xFE53516FUL, 0xED03A29BUL, 0x1F682198UL, + 0x5125DAD3UL, 0xA34E59D0UL, 0xB01EAA24UL, 0x42752927UL, 0x96BF4DCCUL, + 0x64D4CECFUL, 0x77843D3BUL, 0x85EFBE38UL, 0xDBFC821CUL, 0x2997011FUL, + 0x3AC7F2EBUL, 0xC8AC71E8UL, 0x1C661503UL, 0xEE0D9600UL, 0xFD5D65F4UL, + 0x0F36E6F7UL, 0x61C69362UL, 0x93AD1061UL, 0x80FDE395UL, 0x72966096UL, + 0xA65C047DUL, 0x5437877EUL, 0x4767748AUL, 0xB50CF789UL, 0xEB1FCBADUL, + 0x197448AEUL, 0x0A24BB5AUL, 0xF84F3859UL, 0x2C855CB2UL, 0xDEEEDFB1UL, + 0xCDBE2C45UL, 0x3FD5AF46UL, 0x7198540DUL, 0x83F3D70EUL, 0x90A324FAUL, + 0x62C8A7F9UL, 0xB602C312UL, 0x44694011UL, 0x5739B3E5UL, 0xA55230E6UL, + 0xFB410CC2UL, 0x092A8FC1UL, 0x1A7A7C35UL, 0xE811FF36UL, 0x3CDB9BDDUL, + 0xCEB018DEUL, 0xDDE0EB2AUL, 0x2F8B6829UL, 0x82F63B78UL, 0x709DB87BUL, + 0x63CD4B8FUL, 0x91A6C88CUL, 0x456CAC67UL, 0xB7072F64UL, 0xA457DC90UL, + 0x563C5F93UL, 0x082F63B7UL, 0xFA44E0B4UL, 0xE9141340UL, 0x1B7F9043UL, + 0xCFB5F4A8UL, 0x3DDE77ABUL, 0x2E8E845FUL, 0xDCE5075CUL, 0x92A8FC17UL, + 0x60C37F14UL, 0x73938CE0UL, 0x81F80FE3UL, 0x55326B08UL, 0xA759E80BUL, + 0xB4091BFFUL, 0x466298FCUL, 0x1871A4D8UL, 0xEA1A27DBUL, 0xF94AD42FUL, + 0x0B21572CUL, 0xDFEB33C7UL, 0x2D80B0C4UL, 0x3ED04330UL, 0xCCBBC033UL, + 0xA24BB5A6UL, 0x502036A5UL, 0x4370C551UL, 0xB11B4652UL, 0x65D122B9UL, + 0x97BAA1BAUL, 0x84EA524EUL, 0x7681D14DUL, 0x2892ED69UL, 0xDAF96E6AUL, + 0xC9A99D9EUL, 0x3BC21E9DUL, 0xEF087A76UL, 0x1D63F975UL, 0x0E330A81UL, + 0xFC588982UL, 0xB21572C9UL, 0x407EF1CAUL, 0x532E023EUL, 0xA145813DUL, + 0x758FE5D6UL, 0x87E466D5UL, 0x94B49521UL, 0x66DF1622UL, 0x38CC2A06UL, + 0xCAA7A905UL, 0xD9F75AF1UL, 0x2B9CD9F2UL, 0xFF56BD19UL, 0x0D3D3E1AUL, + 0x1E6DCDEEUL, 0xEC064EEDUL, 0xC38D26C4UL, 0x31E6A5C7UL, 0x22B65633UL, + 0xD0DDD530UL, 0x0417B1DBUL, 0xF67C32D8UL, 0xE52CC12CUL, 0x1747422FUL, + 0x49547E0BUL, 0xBB3FFD08UL, 0xA86F0EFCUL, 0x5A048DFFUL, 0x8ECEE914UL, + 0x7CA56A17UL, 0x6FF599E3UL, 0x9D9E1AE0UL, 0xD3D3E1ABUL, 0x21B862A8UL, + 0x32E8915CUL, 0xC083125FUL, 0x144976B4UL, 0xE622F5B7UL, 0xF5720643UL, + 0x07198540UL, 0x590AB964UL, 0xAB613A67UL, 0xB831C993UL, 0x4A5A4A90UL, + 0x9E902E7BUL, 0x6CFBAD78UL, 0x7FAB5E8CUL, 0x8DC0DD8FUL, 0xE330A81AUL, + 0x115B2B19UL, 0x020BD8EDUL, 0xF0605BEEUL, 0x24AA3F05UL, 0xD6C1BC06UL, + 0xC5914FF2UL, 0x37FACCF1UL, 0x69E9F0D5UL, 0x9B8273D6UL, 0x88D28022UL, + 0x7AB90321UL, 0xAE7367CAUL, 0x5C18E4C9UL, 0x4F48173DUL, 0xBD23943EUL, + 0xF36E6F75UL, 0x0105EC76UL, 0x12551F82UL, 0xE03E9C81UL, 0x34F4F86AUL, + 0xC69F7B69UL, 0xD5CF889DUL, 0x27A40B9EUL, 0x79B737BAUL, 0x8BDCB4B9UL, + 0x988C474DUL, 0x6AE7C44EUL, 0xBE2DA0A5UL, 0x4C4623A6UL, 0x5F16D052UL, + 0xAD7D5351UL +}; diff --git a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp index e28ec2ffb31..eb6c909c0b3 100644 --- a/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/stubRoutines_sparc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,6 +56,7 @@ class Sparc { // masks and table for CRC32 static uint64_t _crc_by128_masks[]; static juint _crc_table[]; + static juint _crc32c_table[]; public: // test assembler stop routine by setting registers diff --git a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp index 008fcee7a6a..a5b94695016 100644 --- a/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/templateInterpreterGenerator_sparc.cpp @@ -1082,8 +1082,56 @@ address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractI return NULL; } -// Not supported +/** + * Method entry for intrinsic-candidate (non-native) methods: + * int java.util.zip.CRC32C.updateBytes(int crc, byte[] b, int off, int end) + * int java.util.zip.CRC32C.updateDirectByteBuffer(int crc, long buf, int off, int end) + * Unlike CRC32, CRC32C does not have any methods marked as native + * CRC32C also uses an "end" variable instead of the length variable CRC32 uses + */ address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) { + + if (UseCRC32CIntrinsics) { + address entry = __ pc(); + + // Load parameters from the stack + const Register crc = O0; // initial crc + const Register buf = O1; // source java byte array address + const Register offset = O2; // offset + const Register end = O3; // index of last element to process + const Register len = O2; // len argument to the kernel + const Register table = O3; // crc32c lookup table address + + // Arguments are reversed on java expression stack + // Calculate address of start element + if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) { + __ lduw(Gargs, 0, end); + __ lduw(Gargs, 8, offset); + __ ldx( Gargs, 16, buf); + __ lduw(Gargs, 32, crc); + __ add(buf, offset, buf); + __ sub(end, offset, len); + } else { + __ lduw(Gargs, 0, end); + __ lduw(Gargs, 8, offset); + __ ldx( Gargs, 16, buf); + __ lduw(Gargs, 24, crc); + __ add(buf, arrayOopDesc::base_offset_in_bytes(T_BYTE), buf); // account for the header size + __ add(buf, offset, buf); + __ sub(end, offset, len); + } + + // Call the crc32c kernel + __ MacroAssembler::save_thread(L7_thread_cache); + __ kernel_crc32c(crc, buf, len, table); + __ MacroAssembler::restore_thread(L7_thread_cache); + + // result in O0 + __ retl(); + __ delayed()->nop(); + + return entry; + } return NULL; } diff --git a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp index eaebe505fb0..224a1e4f577 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp @@ -1108,6 +1108,10 @@ void LIRGenerator::do_update_CRC32(Intrinsic* x) { } } +void LIRGenerator::do_update_CRC32C(Intrinsic* x) { + Unimplemented(); +} + // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f // _i2b, _i2c, _i2s LIR_Opr fixed_register_for(BasicType type) { diff --git a/hotspot/src/share/vm/c1/c1_Compiler.cpp b/hotspot/src/share/vm/c1/c1_Compiler.cpp index 4903ab682f3..211f0250f30 100644 --- a/hotspot/src/share/vm/c1/c1_Compiler.cpp +++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -224,6 +224,10 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) { case vmIntrinsics::_updateCRC32: case vmIntrinsics::_updateBytesCRC32: case vmIntrinsics::_updateByteBufferCRC32: +#ifdef SPARC + case vmIntrinsics::_updateBytesCRC32C: + case vmIntrinsics::_updateDirectByteBufferCRC32C: +#endif case vmIntrinsics::_compareAndSwapInt: case vmIntrinsics::_compareAndSwapObject: case vmIntrinsics::_getCharStringU: diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index eb90875a038..ada615a2502 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -3174,6 +3174,11 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) { do_update_CRC32(x); break; + case vmIntrinsics::_updateBytesCRC32C: + case vmIntrinsics::_updateDirectByteBufferCRC32C: + do_update_CRC32C(x); + break; + default: ShouldNotReachHere(); break; } } diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp index aae7ade53b1..c11b59aa71a 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp @@ -253,6 +253,7 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { void do_FPIntrinsics(Intrinsic* x); void do_Reference_get(Intrinsic* x); void do_update_CRC32(Intrinsic* x); + void do_update_CRC32C(Intrinsic* x); LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info); LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info); diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp index e01976a6687..6d3e7363348 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp @@ -318,6 +318,7 @@ const char* Runtime1::name_for_address(address entry) { FUNCTION_CASE(entry, TRACE_TIME_METHOD); #endif FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32()); + FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32C()); FUNCTION_CASE(entry, StubRoutines::dexp()); FUNCTION_CASE(entry, StubRoutines::dlog()); FUNCTION_CASE(entry, StubRoutines::dlog10()); -- GitLab From 80dc8b84bc5cc94352759ef4caad70fb884d0870 Mon Sep 17 00:00:00 2001 From: Antonios Printezis Date: Thu, 5 May 2016 08:51:27 -0700 Subject: [PATCH 296/400] 8155257: ParNew/CMS: Clean up promoted object tracking Reviewed-by: jmasa, ysr --- .../gc/cms/concurrentMarkSweepGeneration.cpp | 27 ++++++++++++++----- .../src/share/vm/gc/cms/parNewGeneration.cpp | 11 +++++++- hotspot/src/share/vm/gc/cms/promotionInfo.cpp | 4 ++- hotspot/src/share/vm/gc/cms/promotionInfo.hpp | 2 +- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp index d19b503455e..af5e47dc2d7 100644 --- a/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc/cms/concurrentMarkSweepGeneration.cpp @@ -1019,7 +1019,7 @@ ConcurrentMarkSweepGeneration::par_promote(int thread_num, return NULL; } } - assert(promoInfo->has_spooling_space(), "Control point invariant"); + assert(!promoInfo->tracking() || promoInfo->has_spooling_space(), "Control point invariant"); const size_t alloc_sz = CompactibleFreeListSpace::adjustObjectSize(word_sz); HeapWord* obj_ptr = ps->lab.alloc(alloc_sz); if (obj_ptr == NULL) { @@ -1094,6 +1094,12 @@ par_oop_since_save_marks_iterate_done(int thread_num) { CMSParGCThreadState* ps = _par_gc_thread_states[thread_num]; ParScanWithoutBarrierClosure* dummy_cl = NULL; ps->promo.promoted_oops_iterate_nv(dummy_cl); + + // Because card-scanning has been completed, subsequent phases + // (e.g., reference processing) will not need to recognize which + // objects have been promoted during this GC. So, we can now disable + // promotion tracking. + ps->promo.stopTrackingPromotions(); } bool ConcurrentMarkSweepGeneration::should_collect(bool full, @@ -2032,6 +2038,12 @@ void ConcurrentMarkSweepGeneration::gc_prologue(bool full) { _capacity_at_prologue = capacity(); _used_at_prologue = used(); + // We enable promotion tracking so that card-scanning can recognize + // which objects have been promoted during this GC and skip them. + for (uint i = 0; i < ParallelGCThreads; i++) { + _par_gc_thread_states[i]->promo.startTrackingPromotions(); + } + // Delegate to CMScollector which knows how to coordinate between // this and any other CMS generations that it is responsible for // collecting. @@ -2118,9 +2130,15 @@ void CMSCollector::gc_epilogue(bool full) { void ConcurrentMarkSweepGeneration::gc_epilogue(bool full) { collector()->gc_epilogue(full); - // Also reset promotion tracking in par gc thread states. + // When using ParNew, promotion tracking should have already been + // disabled. However, the prologue (which enables promotion + // tracking) and epilogue are called irrespective of the type of + // GC. So they will also be called before and after Full GCs, during + // which promotion tracking will not be explicitly disabled. So, + // it's safer to also disable it here too (to be symmetric with + // enabling it in the prologue). for (uint i = 0; i < ParallelGCThreads; i++) { - _par_gc_thread_states[i]->promo.stopTrackingPromotions(i); + _par_gc_thread_states[i]->promo.stopTrackingPromotions(); } } @@ -2431,9 +2449,6 @@ void CMSCollector::verify_after_remark_work_2() { void ConcurrentMarkSweepGeneration::save_marks() { // delegate to CMS space cmsSpace()->save_marks(); - for (uint i = 0; i < ParallelGCThreads; i++) { - _par_gc_thread_states[i]->promo.startTrackingPromotions(); - } } bool ConcurrentMarkSweepGeneration::no_allocs_since_save_marks() { diff --git a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp index 3b1e073db0b..adf515623bf 100644 --- a/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp +++ b/hotspot/src/share/vm/gc/cms/parNewGeneration.cpp @@ -476,7 +476,6 @@ void ParScanThreadStateSet::flush() { // Inform old gen that we're done. _old_gen.par_promote_alloc_done(i); - _old_gen.par_oop_since_save_marks_iterate_done(i); } if (UseConcMarkSweepGC) { @@ -619,6 +618,16 @@ void ParNewGenTask::work(uint worker_id) { // "evacuate followers". par_scan_state.evacuate_followers_closure().do_void(); + + // This will collapse this worker's promoted object list that's + // created during the main ParNew parallel phase of ParNew. This has + // to be called after all workers have finished promoting objects + // and scanning promoted objects. It should be safe calling it from + // here, given that we can only reach here after all thread have + // offered termination, i.e., after there is no more work to be + // done. It will also disable promotion tracking for the rest of + // this GC as it's not necessary to be on during reference processing. + _old_gen->par_oop_since_save_marks_iterate_done((int) worker_id); } ParNewGeneration::ParNewGeneration(ReservedSpace rs, size_t initial_byte_size) diff --git a/hotspot/src/share/vm/gc/cms/promotionInfo.cpp b/hotspot/src/share/vm/gc/cms/promotionInfo.cpp index 92c5725361f..40b4b3916dc 100644 --- a/hotspot/src/share/vm/gc/cms/promotionInfo.cpp +++ b/hotspot/src/share/vm/gc/cms/promotionInfo.cpp @@ -252,13 +252,15 @@ SpoolBlock* PromotionInfo::getSpoolBlock() { } void PromotionInfo::startTrackingPromotions() { + assert(noPromotions(), "sanity"); assert(_spoolHead == _spoolTail && _firstIndex == _nextIndex, "spooling inconsistency?"); _firstIndex = _nextIndex = 1; _tracking = true; } -void PromotionInfo::stopTrackingPromotions(uint worker_id) { +void PromotionInfo::stopTrackingPromotions() { + assert(noPromotions(), "we should have torn down the lists by now"); assert(_spoolHead == _spoolTail && _firstIndex == _nextIndex, "spooling inconsistency?"); _firstIndex = _nextIndex = 1; diff --git a/hotspot/src/share/vm/gc/cms/promotionInfo.hpp b/hotspot/src/share/vm/gc/cms/promotionInfo.hpp index 387da17ed95..90ca0626e50 100644 --- a/hotspot/src/share/vm/gc/cms/promotionInfo.hpp +++ b/hotspot/src/share/vm/gc/cms/promotionInfo.hpp @@ -144,7 +144,7 @@ class PromotionInfo VALUE_OBJ_CLASS_SPEC { return _promoHead == NULL; } void startTrackingPromotions(); - void stopTrackingPromotions(uint worker_id = 0); + void stopTrackingPromotions(); bool tracking() const { return _tracking; } void track(PromotedObject* trackOop); // keep track of a promoted oop // The following variant must be used when trackOop is not fully -- GitLab From 88be76356f69ea6c55f3929a17f1a3f212e3ae9d Mon Sep 17 00:00:00 2001 From: George Triantafillou Date: Thu, 5 May 2016 12:25:29 -0400 Subject: [PATCH 297/400] 8154942: Remove ProcessTools.getVmInputArguments() from the hotspot test library, as it is not used by any of the hotspot tests Reviewed-by: ctornqvi, hseigel --- .../testlibrary/jdk/test/lib/ProcessTools.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java b/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java index a8586dc3c1b..21ff4159761 100644 --- a/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java +++ b/hotspot/test/testlibrary/jdk/test/lib/ProcessTools.java @@ -94,22 +94,6 @@ public final class ProcessTools { return ProcessHandle.current().getPid(); } - /** - * Get the string containing input arguments passed to the VM - * - * @return arguments - */ - public static String getVmInputArguments() { - RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean(); - - List args = runtime.getInputArguments(); - StringBuilder result = new StringBuilder(); - for (String arg : args) - result.append(arg).append(' '); - - return result.toString(); - } - /** * Gets the array of strings containing input arguments passed to the VM * -- GitLab From 472a1bc607ed046e4b832caec69c8a3d3c9c18be Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 5 May 2016 10:03:26 -0700 Subject: [PATCH 298/400] 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1 Reviewed-by: kvn --- .../aarch64/vm/c1_LIRGenerator_aarch64.cpp | 4 + .../src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp | 4 + .../cpu/sparc/vm/c1_LIRGenerator_sparc.cpp | 4 + .../src/cpu/x86/vm/c1_LIRGenerator_x86.cpp | 77 +++++++++++++++++++ hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp | 2 +- .../src/cpu/x86/vm/stubGenerator_x86_64.cpp | 12 ++- .../templateInterpreterGenerator_x86_64.cpp | 6 +- hotspot/src/share/vm/c1/c1_Compiler.cpp | 1 + hotspot/src/share/vm/c1/c1_LIRGenerator.cpp | 4 + hotspot/src/share/vm/c1/c1_LIRGenerator.hpp | 1 + hotspot/src/share/vm/c1/c1_Runtime1.cpp | 1 + hotspot/src/share/vm/classfile/vmSymbols.cpp | 8 +- 12 files changed, 113 insertions(+), 11 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp index 4f07b70b605..8f1da0bffb3 100644 --- a/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/c1_LIRGenerator_aarch64.cpp @@ -1033,6 +1033,10 @@ void LIRGenerator::do_update_CRC32C(Intrinsic* x) { Unimplemented(); } +void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) { + fatal("vectorizedMismatch intrinsic is not implemented on this platform"); +} + // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f // _i2b, _i2c, _i2s void LIRGenerator::do_Convert(Convert* x) { diff --git a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp index 99f8ca08bd7..eec6909ac59 100644 --- a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp @@ -1426,6 +1426,10 @@ void LIRGenerator::do_update_CRC32(Intrinsic* x) { ShouldNotReachHere(); } } + + void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) { + fatal("vectorizedMismatch intrinsic is not implemented on this platform"); + } } void LIRGenerator::do_update_CRC32C(Intrinsic* x) { diff --git a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp index 8f79dca209f..3fdb29b73cd 100644 --- a/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/c1_LIRGenerator_sparc.cpp @@ -952,6 +952,10 @@ void LIRGenerator::do_update_CRC32C(Intrinsic* x) { } } +void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) { + fatal("vectorizedMismatch intrinsic is not implemented on this platform"); +} + // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f // _i2b, _i2c, _i2s void LIRGenerator::do_Convert(Convert* x) { diff --git a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp index 224a1e4f577..1074fa1aa62 100644 --- a/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp +++ b/hotspot/src/cpu/x86/vm/c1_LIRGenerator_x86.cpp @@ -1112,6 +1112,83 @@ void LIRGenerator::do_update_CRC32C(Intrinsic* x) { Unimplemented(); } +void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) { + assert(UseVectorizedMismatchIntrinsic, "need AVX instruction support"); + + // Make all state_for calls early since they can emit code + LIR_Opr result = rlock_result(x); + + LIRItem a(x->argument_at(0), this); // Object + LIRItem aOffset(x->argument_at(1), this); // long + LIRItem b(x->argument_at(2), this); // Object + LIRItem bOffset(x->argument_at(3), this); // long + LIRItem length(x->argument_at(4), this); // int + LIRItem log2ArrayIndexScale(x->argument_at(5), this); // int + + a.load_item(); + aOffset.load_nonconstant(); + b.load_item(); + bOffset.load_nonconstant(); + + long constant_aOffset = 0; + LIR_Opr result_aOffset = aOffset.result(); + if (result_aOffset->is_constant()) { + constant_aOffset = result_aOffset->as_jlong(); + result_aOffset = LIR_OprFact::illegalOpr; + } + LIR_Opr result_a = a.result(); + + long constant_bOffset = 0; + LIR_Opr result_bOffset = bOffset.result(); + if (result_bOffset->is_constant()) { + constant_bOffset = result_bOffset->as_jlong(); + result_bOffset = LIR_OprFact::illegalOpr; + } + LIR_Opr result_b = b.result(); + +#ifndef _LP64 + result_a = new_register(T_INT); + __ convert(Bytecodes::_l2i, a.result(), result_a); + result_b = new_register(T_INT); + __ convert(Bytecodes::_l2i, b.result(), result_b); +#endif + + + LIR_Address* addr_a = new LIR_Address(result_a, + result_aOffset, + LIR_Address::times_1, + constant_aOffset, + T_BYTE); + + LIR_Address* addr_b = new LIR_Address(result_b, + result_bOffset, + LIR_Address::times_1, + constant_bOffset, + T_BYTE); + + BasicTypeList signature(4); + signature.append(T_ADDRESS); + signature.append(T_ADDRESS); + signature.append(T_INT); + signature.append(T_INT); + CallingConvention* cc = frame_map()->c_calling_convention(&signature); + const LIR_Opr result_reg = result_register_for(x->type()); + + LIR_Opr ptr_addr_a = new_pointer_register(); + __ leal(LIR_OprFact::address(addr_a), ptr_addr_a); + + LIR_Opr ptr_addr_b = new_pointer_register(); + __ leal(LIR_OprFact::address(addr_b), ptr_addr_b); + + __ move(ptr_addr_a, cc->at(0)); + __ move(ptr_addr_b, cc->at(1)); + length.load_item_force(cc->at(2)); + log2ArrayIndexScale.load_item_force(cc->at(3)); + + __ call_runtime_leaf(StubRoutines::vectorizedMismatch(), getThreadTemp(), result_reg, cc->args()); + __ move(result_reg, result); +} + // _i2l, _i2f, _i2d, _l2i, _l2f, _l2d, _f2i, _f2l, _f2d, _d2i, _d2l, _d2f // _i2b, _i2c, _i2s LIR_Opr fixed_register_for(BasicType type) { diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp index e52306d3a1a..56e5bad89fb 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp @@ -845,7 +845,7 @@ class MacroAssembler: public Assembler { void call(Label& L, relocInfo::relocType rtype); void call(Register entry); - // NOTE: this call tranfers to the effective address of entry NOT + // NOTE: this call transfers to the effective address of entry NOT // the address contained by entry. This is because this is more natural // for jumps/calls. void call(AddressLiteral entry); diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp index 3d8acc78947..1d7fcb18b64 100644 --- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp @@ -4409,7 +4409,7 @@ class StubGenerator: public StubCodeGenerator { * c_rarg0 - int crc * c_rarg1 - byte* buf * c_rarg2 - long length - * c_rarg3 - table_start - optional (present only when doing a library_calll, + * c_rarg3 - table_start - optional (present only when doing a library_call, * not used by x86 algorithm) * * Ouput: @@ -4532,6 +4532,9 @@ class StubGenerator: public StubCodeGenerator { * c_rarg1 - objb address * c_rarg3 - length length * c_rarg4 - scale log2_array_indxscale + * + * Output: + * rax - int >= mismatched index, < 0 bitwise complement of tail */ address generate_vectorizedMismatch() { __ align(CodeEntryAlignment); @@ -5291,9 +5294,6 @@ class StubGenerator: public StubCodeGenerator { if (UseMulAddIntrinsic) { StubRoutines::_mulAdd = generate_mulAdd(); } - if (UseVectorizedMismatchIntrinsic) { - StubRoutines::_vectorizedMismatch = generate_vectorizedMismatch(); - } #ifndef _WINDOWS if (UseMontgomeryMultiplyIntrinsic) { StubRoutines::_montgomeryMultiply @@ -5305,6 +5305,10 @@ class StubGenerator: public StubCodeGenerator { } #endif // WINDOWS #endif // COMPILER2 + + if (UseVectorizedMismatchIntrinsic) { + StubRoutines::_vectorizedMismatch = generate_vectorizedMismatch(); + } } public: diff --git a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp index 6af708febf5..a9cb7962fb1 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreterGenerator_x86_64.cpp @@ -289,9 +289,9 @@ address TemplateInterpreterGenerator::generate_CRC32_updateBytes_entry(AbstractI } /** -* Method entry for static native methods: +* Method entry for static (non-native) methods: * int java.util.zip.CRC32C.updateBytes(int crc, byte[] b, int off, int end) -* int java.util.zip.CRC32C.updateByteBuffer(int crc, long address, int off, int end) +* int java.util.zip.CRC32C.updateDirectByteBuffer(int crc, long address, int off, int end) */ address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(AbstractInterpreter::MethodKind kind) { if (UseCRC32CIntrinsics) { @@ -306,7 +306,7 @@ address TemplateInterpreterGenerator::generate_CRC32C_updateBytes_entry(Abstract // Arguments are reversed on java expression stack // Calculate address of start element if (kind == Interpreter::java_util_zip_CRC32C_updateDirectByteBuffer) { - __ movptr(buf, Address(rsp, 3 * wordSize)); // long buf + __ movptr(buf, Address(rsp, 3 * wordSize)); // long address __ movl2ptr(off, Address(rsp, 2 * wordSize)); // offset __ addq(buf, off); // + offset __ movl(crc, Address(rsp, 5 * wordSize)); // Initial CRC diff --git a/hotspot/src/share/vm/c1/c1_Compiler.cpp b/hotspot/src/share/vm/c1/c1_Compiler.cpp index 211f0250f30..2f1c0d61613 100644 --- a/hotspot/src/share/vm/c1/c1_Compiler.cpp +++ b/hotspot/src/share/vm/c1/c1_Compiler.cpp @@ -228,6 +228,7 @@ bool Compiler::is_intrinsic_supported(const methodHandle& method) { case vmIntrinsics::_updateBytesCRC32C: case vmIntrinsics::_updateDirectByteBufferCRC32C: #endif + case vmIntrinsics::_vectorizedMismatch: case vmIntrinsics::_compareAndSwapInt: case vmIntrinsics::_compareAndSwapObject: case vmIntrinsics::_getCharStringU: diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp index ada615a2502..274f5a54ca1 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.cpp @@ -3179,6 +3179,10 @@ void LIRGenerator::do_Intrinsic(Intrinsic* x) { do_update_CRC32C(x); break; + case vmIntrinsics::_vectorizedMismatch: + do_vectorizedMismatch(x); + break; + default: ShouldNotReachHere(); break; } } diff --git a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp index c11b59aa71a..86b364bfc05 100644 --- a/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp +++ b/hotspot/src/share/vm/c1/c1_LIRGenerator.hpp @@ -254,6 +254,7 @@ class LIRGenerator: public InstructionVisitor, public BlockClosure { void do_Reference_get(Intrinsic* x); void do_update_CRC32(Intrinsic* x); void do_update_CRC32C(Intrinsic* x); + void do_vectorizedMismatch(Intrinsic* x); LIR_Opr call_runtime(BasicTypeArray* signature, LIRItemList* args, address entry, ValueType* result_type, CodeEmitInfo* info); LIR_Opr call_runtime(BasicTypeArray* signature, LIR_OprList* args, address entry, ValueType* result_type, CodeEmitInfo* info); diff --git a/hotspot/src/share/vm/c1/c1_Runtime1.cpp b/hotspot/src/share/vm/c1/c1_Runtime1.cpp index 6d3e7363348..be57ef53e78 100644 --- a/hotspot/src/share/vm/c1/c1_Runtime1.cpp +++ b/hotspot/src/share/vm/c1/c1_Runtime1.cpp @@ -319,6 +319,7 @@ const char* Runtime1::name_for_address(address entry) { #endif FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32()); FUNCTION_CASE(entry, StubRoutines::updateBytesCRC32C()); + FUNCTION_CASE(entry, StubRoutines::vectorizedMismatch()); FUNCTION_CASE(entry, StubRoutines::dexp()); FUNCTION_CASE(entry, StubRoutines::dlog()); FUNCTION_CASE(entry, StubRoutines::dlog10()); diff --git a/hotspot/src/share/vm/classfile/vmSymbols.cpp b/hotspot/src/share/vm/classfile/vmSymbols.cpp index 42555054305..ca3c9a98c69 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.cpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.cpp @@ -353,6 +353,7 @@ bool vmIntrinsics::preserves_state(vmIntrinsics::ID id) { case vmIntrinsics::_updateCRC32: case vmIntrinsics::_updateBytesCRC32: case vmIntrinsics::_updateByteBufferCRC32: + case vmIntrinsics::_vectorizedMismatch: return true; default: return false; @@ -384,6 +385,7 @@ bool vmIntrinsics::can_trap(vmIntrinsics::ID id) { case vmIntrinsics::_updateCRC32: case vmIntrinsics::_updateBytesCRC32: case vmIntrinsics::_updateByteBufferCRC32: + case vmIntrinsics::_vectorizedMismatch: return false; default: return true; @@ -669,6 +671,9 @@ bool vmIntrinsics::is_disabled_by_flags(const methodHandle& method) { case vmIntrinsics::_updateDirectByteBufferCRC32C: if (!UseCRC32CIntrinsics) return true; break; + case vmIntrinsics::_vectorizedMismatch: + if (!UseVectorizedMismatchIntrinsic) return true; + break; case vmIntrinsics::_updateBytesAdler32: case vmIntrinsics::_updateByteBufferAdler32: if (!UseAdler32Intrinsics) return true; @@ -734,9 +739,6 @@ bool vmIntrinsics::is_disabled_by_flags(const methodHandle& method) { case vmIntrinsics::_montgomerySquare: if (!UseMontgomerySquareIntrinsic) return true; break; - case vmIntrinsics::_vectorizedMismatch: - if (!UseVectorizedMismatchIntrinsic) return true; - break; case vmIntrinsics::_addExactI: case vmIntrinsics::_addExactL: case vmIntrinsics::_decrementExactI: -- GitLab From b260a19e7bf264e5d9ad3aa78c5f1f379b6c2e96 Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Thu, 5 May 2016 13:47:46 -0400 Subject: [PATCH 299/400] 8156072: AllocatedObj msgs coming out during -version etc Removed obsolete print. Reviewed-by: jmasa, ecaspole --- hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index 3c8eae8afee..37d72134cfd 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -590,8 +590,6 @@ void G1DefaultPolicy::record_collection_pause_end(double pause_time_ms, size_t c bool last_pause_included_initial_mark = false; bool update_stats = !_g1->evacuation_failed(); - NOT_PRODUCT(_short_lived_surv_rate_group->print()); - record_pause(young_gc_pause_kind(), end_time_sec - pause_time_ms / 1000.0, end_time_sec); last_pause_included_initial_mark = collector_state()->during_initial_mark_pause(); -- GitLab From 05e186869f7553e8529bfbb8b7f08d63570f9b4d Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Fri, 6 May 2016 09:13:31 +0900 Subject: [PATCH 300/400] 8156133: FindCrashesAction in HSDB does not work except Solaris platform Reviewed-by: dsamersoff --- .../sun/jvm/hotspot/ui/JavaThreadsPanel.java | 36 ++++++++++--------- hotspot/src/share/vm/runtime/vmStructs.cpp | 12 +++++++ hotspot/src/share/vm/utilities/vmError.hpp | 1 + 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JavaThreadsPanel.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JavaThreadsPanel.java index 6316d3538ce..a9397001b84 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JavaThreadsPanel.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JavaThreadsPanel.java @@ -39,6 +39,7 @@ import javax.swing.table.*; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.runtime.*; +import sun.jvm.hotspot.types.*; import sun.jvm.hotspot.ui.action.*; @@ -55,9 +56,19 @@ public class JavaThreadsPanel extends SAPanel implements ActionListener { private JavaThreadsTableModel dataModel; private StatusBar statusBar; private JTable threadTable; - private java.util.List cachedThreads = new ArrayList(); + private java.util.List cachedThreads = new ArrayList(); + private static AddressField crashThread; + static { + VM.registerVMInitializedObserver( + (o, a) -> initialize(VM.getVM().getTypeDataBase())); + } + + private static void initialize(TypeDataBase db) { + crashThread = db.lookupType("VMError").getAddressField("_thread"); + } + /** Constructor assumes the threads panel is created while the VM is suspended. Subsequent resume and suspend operations of the VM will cause the threads panel to clear and fill itself back in, @@ -437,21 +448,14 @@ public class JavaThreadsPanel extends SAPanel implements ActionListener { * @return a flag which indicates if crashes were encountered. */ private boolean fireShowThreadCrashes() { - boolean crash = false; - for (Iterator iter = cachedThreads.iterator(); iter.hasNext(); ) { - JavaThread t = (JavaThread) ((CachedThread) iter.next()).getThread(); - sun.jvm.hotspot.runtime.Frame tmpFrame = t.getCurrentFrameGuess(); - RegisterMap tmpMap = t.newRegisterMap(false); - while ((tmpFrame != null) && (!tmpFrame.isFirstFrame())) { - if (tmpFrame.isSignalHandlerFrameDbg()) { - showThreadStackMemory(t); - crash = true; - break; - } - tmpFrame = tmpFrame.sender(tmpMap); - } - } - return crash; + Optional crashed = + cachedThreads.stream() + .map(t -> t.getThread()) + .filter(t -> t.getAddress().equals( + crashThread.getValue())) + .findAny(); + crashed.ifPresent(this::showThreadStackMemory); + return crashed.isPresent(); } private void cache() { diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index c0e486ef5e3..dab3dbbd629 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -1365,6 +1365,12 @@ typedef CompactHashtable SymbolCompactHashTable; static_field(java_lang_Class, _oop_size_offset, int) \ static_field(java_lang_Class, _static_oop_field_count_offset, int) \ \ + /******************/ \ + /* VMError fields */ \ + /******************/ \ + \ + static_field(VMError, _thread, Thread*) \ + \ /************************/ \ /* Miscellaneous fields */ \ /************************/ \ @@ -2215,6 +2221,12 @@ typedef CompactHashtable SymbolCompactHashTable; \ declare_toplevel_type(Arguments) \ \ + /***********/ \ + /* VMError */ \ + /***********/ \ + \ + declare_toplevel_type(VMError) \ + \ /***************/ \ /* Other types */ \ /***************/ \ diff --git a/hotspot/src/share/vm/utilities/vmError.hpp b/hotspot/src/share/vm/utilities/vmError.hpp index 62ce62e3e30..23f973b27fb 100644 --- a/hotspot/src/share/vm/utilities/vmError.hpp +++ b/hotspot/src/share/vm/utilities/vmError.hpp @@ -33,6 +33,7 @@ class VM_ReportJavaOutOfMemory; class VMError : public AllStatic { friend class VM_ReportJavaOutOfMemory; friend class Decoder; + friend class VMStructs; static int _id; // Solaris/Linux signals: 0 - SIGRTMAX // Windows exceptions: 0xCxxxxxxx system errors -- GitLab From 0a123cad8fdbc7817c89251ac7c9fb3157288bf9 Mon Sep 17 00:00:00 2001 From: Tomasz Wojtowicz Date: Thu, 5 May 2016 17:16:08 -0700 Subject: [PATCH 301/400] 8154974: AVX-512 equipped inflate, has_negatives & compress intrinsics Reviewed-by: kvn --- hotspot/src/cpu/x86/vm/assembler_x86.cpp | 161 +++++- hotspot/src/cpu/x86/vm/assembler_x86.hpp | 39 +- hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp | 488 +++++++++++++++--- 3 files changed, 593 insertions(+), 95 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp index dccf9c8cfb0..d65577ffca5 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp @@ -2332,6 +2332,22 @@ void Assembler::ktestql(KRegister src1, KRegister src2) { emit_int8((unsigned char)(0xC0 | encode)); } +void Assembler::ktestq(KRegister src1, KRegister src2) { + assert(VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(AVX_128bit, /* rex_w */ true, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = vex_prefix_and_encode(src1->encoding(), 0, src2->encoding(), VEX_SIMD_NONE, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0x99); + emit_int8((unsigned char)(0xC0 | encode)); +} + +void Assembler::ktestd(KRegister src1, KRegister src2) { + assert(VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(AVX_128bit, /* rex_w */ true, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false); + int encode = vex_prefix_and_encode(src1->encoding(), 0, src2->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0x99); + emit_int8((unsigned char)(0xC0 | encode)); +} + void Assembler::movb(Address dst, int imm8) { InstructionMark im(this); prefix(dst); @@ -2500,7 +2516,7 @@ void Assembler::evmovdqub(Address dst, XMMRegister src, int vector_len) { emit_operand(src, dst); } -void Assembler::evmovdqub(KRegister mask, XMMRegister dst, Address src, int vector_len) { +void Assembler::evmovdqub(XMMRegister dst, KRegister mask, Address src, int vector_len) { assert(VM_Version::supports_avx512vlbw(), ""); assert(is_vector_masking(), ""); // For stub code use only InstructionMark im(this); @@ -2513,24 +2529,27 @@ void Assembler::evmovdqub(KRegister mask, XMMRegister dst, Address src, int vect emit_operand(dst, src); } -void Assembler::evmovdquw(XMMRegister dst, XMMRegister src, int vector_len) { +void Assembler::evmovdquw(XMMRegister dst, Address src, int vector_len) { assert(VM_Version::supports_evex(), ""); + InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); attributes.set_is_evex_instruction(); int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3; - int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes); + vex_prefix(src, 0, dst->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes); emit_int8(0x6F); - emit_int8((unsigned char)(0xC0 | encode)); + emit_operand(dst, src); } -void Assembler::evmovdquw(XMMRegister dst, Address src, int vector_len) { - assert(VM_Version::supports_evex(), ""); +void Assembler::evmovdquw(XMMRegister dst, KRegister mask, Address src, int vector_len) { + assert(is_vector_masking(), ""); + assert(VM_Version::supports_avx512vlbw(), ""); InstructionMark im(this); - InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); attributes.set_is_evex_instruction(); - int prefix = (_legacy_mode_bw) ? VEX_SIMD_F2 : VEX_SIMD_F3; - vex_prefix(src, 0, dst->encoding(), (Assembler::VexSimdPrefix)prefix, VEX_OPCODE_0F, &attributes); + vex_prefix(src, 0, dst->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); emit_int8(0x6F); emit_operand(dst, src); } @@ -2548,6 +2567,19 @@ void Assembler::evmovdquw(Address dst, XMMRegister src, int vector_len) { emit_operand(src, dst); } +void Assembler::evmovdquw(Address dst, KRegister mask, XMMRegister src, int vector_len) { + assert(VM_Version::supports_avx512vlbw(), ""); + assert(src != xnoreg, "sanity"); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + attributes.set_is_evex_instruction(); + vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); + emit_int8(0x7F); + emit_operand(src, dst); +} + void Assembler::evmovdqul(XMMRegister dst, XMMRegister src, int vector_len) { assert(VM_Version::supports_evex(), ""); InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); @@ -3295,10 +3327,71 @@ void Assembler::evpcmpeqb(KRegister kdst, XMMRegister nds, XMMRegister src, int emit_int8((unsigned char)(0xC0 | encode)); } +void Assembler::evpcmpgtb(KRegister kdst, XMMRegister nds, Address src, int vector_len) { + assert(VM_Version::supports_avx512vlbw(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); + int dst_enc = kdst->encoding(); + vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8(0x64); + emit_operand(as_Register(dst_enc), src); +} + +void Assembler::evpcmpgtb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len) { + assert(is_vector_masking(), ""); + assert(VM_Version::supports_avx512vlbw(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + attributes.set_is_evex_instruction(); + int dst_enc = kdst->encoding(); + vex_prefix(src, nds->encoding(), dst_enc, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8(0x64); + emit_operand(as_Register(dst_enc), src); +} + +void Assembler::evpcmpuw(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len) { + assert(VM_Version::supports_avx512vlbw(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); + emit_int8(0x3E); + emit_int8((unsigned char)(0xC0 | encode)); + emit_int8(vcc); +} + +void Assembler::evpcmpuw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len) { + assert(is_vector_masking(), ""); + assert(VM_Version::supports_avx512vlbw(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_embedded_opmask_register_specifier(mask); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); + emit_int8(0x3E); + emit_int8((unsigned char)(0xC0 | encode)); + emit_int8(vcc); +} + +void Assembler::evpcmpuw(KRegister kdst, XMMRegister nds, Address src, ComparisonPredicate vcc, int vector_len) { + assert(VM_Version::supports_avx512vlbw(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); + int dst_enc = kdst->encoding(); + vex_prefix(src, nds->encoding(), kdst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); + emit_int8(0x3E); + emit_operand(as_Register(dst_enc), src); + emit_int8(vcc); +} + void Assembler::evpcmpeqb(KRegister kdst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx512bw(), ""); InstructionMark im(this); - InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); attributes.set_is_evex_instruction(); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); int dst_enc = kdst->encoding(); @@ -3307,7 +3400,7 @@ void Assembler::evpcmpeqb(KRegister kdst, XMMRegister nds, Address src, int vect emit_operand(as_Register(dst_enc), src); } -void Assembler::evpcmpeqb(KRegister mask, KRegister kdst, XMMRegister nds, Address src, int vector_len) { +void Assembler::evpcmpeqb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx512vlbw(), ""); assert(is_vector_masking(), ""); // For stub code use only InstructionMark im(this); @@ -3620,6 +3713,46 @@ void Assembler::vpmovzxbw(XMMRegister dst, Address src, int vector_len) { emit_operand(dst, src); } +void Assembler::evpmovzxbw(XMMRegister dst, KRegister mask, Address src, int vector_len) { + assert(is_vector_masking(), ""); + assert(VM_Version::supports_avx512vlbw(), ""); + assert(dst != xnoreg, "sanity"); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_HVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + attributes.set_is_evex_instruction(); + vex_prefix(src, 0, dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x30); + emit_operand(dst, src); +} + +void Assembler::evpmovwb(Address dst, XMMRegister src, int vector_len) { + assert(VM_Version::supports_avx512vlbw(), ""); + assert(src != xnoreg, "sanity"); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_HVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); + vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x30); + emit_operand(src, dst); +} + +void Assembler::evpmovwb(Address dst, KRegister mask, XMMRegister src, int vector_len) { + assert(is_vector_masking(), ""); + assert(VM_Version::supports_avx512vlbw(), ""); + assert(src != xnoreg, "sanity"); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ false); + attributes.set_address_attributes(/* tuple_type */ EVEX_HVM, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + attributes.set_is_evex_instruction(); + vex_prefix(dst, 0, src->encoding(), VEX_SIMD_F3, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x30); + emit_operand(src, dst); +} + // generic void Assembler::pop(Register dst) { int encode = prefix_and_encode(dst->encoding()); @@ -6406,7 +6539,6 @@ void Assembler::vzeroupper() { emit_int8(0x77); } - #ifndef _LP64 // 32bit only pieces of the assembler @@ -6973,7 +7105,10 @@ void Assembler::evex_prefix(bool vex_r, bool vex_b, bool vex_x, bool evex_r, boo emit_int8(byte3); // P2: byte 4 as zL'Lbv'aaa - int byte4 = (_attributes->is_no_reg_mask()) ? 0 : _attributes->get_embedded_opmask_register_specifier(); // kregs are implemented in the low 3 bits as aaa (hard code k1, it will be initialized for now) + // kregs are implemented in the low 3 bits as aaa (hard code k1, it will be initialized for now) + int byte4 = (_attributes->is_no_reg_mask()) ? + 0 : + _attributes->get_embedded_opmask_register_specifier(); // EVEX.v` for extending EVEX.vvvv or VIDX byte4 |= (evex_v ? 0: EVEX_V); // third EXEC.b for broadcast actions diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp index 9e40bbb90dd..56165382936 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp @@ -587,6 +587,16 @@ class Assembler : public AbstractAssembler { #endif }; + enum ComparisonPredicate { + eq = 0, + lt = 1, + le = 2, + _false = 3, + neq = 4, + nlt = 5, + nle = 6, + _true = 7 + }; // NOTE: The general philopsophy of the declarations here is that 64bit versions @@ -830,7 +840,6 @@ private: void clear_vector_masking(void) { _vector_masking = false; } bool is_vector_masking(void) { return _vector_masking; } - void lea(Register dst, Address src); void mov(Register dst, Register src); @@ -1362,6 +1371,9 @@ private: void kortestdl(KRegister dst, KRegister src); void kortestql(KRegister dst, KRegister src); + void ktestq(KRegister src1, KRegister src2); + void ktestd(KRegister src1, KRegister src2); + void ktestql(KRegister dst, KRegister src); void movdl(XMMRegister dst, Register src); @@ -1391,10 +1403,11 @@ private: void evmovdqub(Address dst, XMMRegister src, int vector_len); void evmovdqub(XMMRegister dst, Address src, int vector_len); void evmovdqub(XMMRegister dst, XMMRegister src, int vector_len); - void evmovdqub(KRegister mask, XMMRegister dst, Address src, int vector_len); + void evmovdqub(XMMRegister dst, KRegister mask, Address src, int vector_len); void evmovdquw(Address dst, XMMRegister src, int vector_len); + void evmovdquw(Address dst, KRegister mask, XMMRegister src, int vector_len); void evmovdquw(XMMRegister dst, Address src, int vector_len); - void evmovdquw(XMMRegister dst, XMMRegister src, int vector_len); + void evmovdquw(XMMRegister dst, KRegister mask, Address src, int vector_len); void evmovdqul(Address dst, XMMRegister src, int vector_len); void evmovdqul(XMMRegister dst, Address src, int vector_len); void evmovdqul(XMMRegister dst, XMMRegister src, int vector_len); @@ -1545,7 +1558,14 @@ private: void vpcmpeqb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void evpcmpeqb(KRegister kdst, XMMRegister nds, XMMRegister src, int vector_len); void evpcmpeqb(KRegister kdst, XMMRegister nds, Address src, int vector_len); - void evpcmpeqb(KRegister mask, KRegister kdst, XMMRegister nds, Address src, int vector_len); + void evpcmpeqb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len); + + void evpcmpgtb(KRegister kdst, XMMRegister nds, Address src, int vector_len); + void evpcmpgtb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len); + + void evpcmpuw(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len); + void evpcmpuw(KRegister kdst, KRegister mask, XMMRegister nds, XMMRegister src, ComparisonPredicate of, int vector_len); + void evpcmpuw(KRegister kdst, XMMRegister nds, Address src, ComparisonPredicate vcc, int vector_len); void pcmpeqw(XMMRegister dst, XMMRegister src); void vpcmpeqw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); @@ -1589,7 +1609,11 @@ private: void pmovzxbw(XMMRegister dst, XMMRegister src); void pmovzxbw(XMMRegister dst, Address src); - void vpmovzxbw(XMMRegister dst, Address src, int vector_len); + void vpmovzxbw( XMMRegister dst, Address src, int vector_len); + void evpmovzxbw(XMMRegister dst, KRegister mask, Address src, int vector_len); + + void evpmovwb(Address dst, XMMRegister src, int vector_len); + void evpmovwb(Address dst, KRegister mask, XMMRegister src, int vector_len); #ifndef _LP64 // no 32bit push/pop on amd64 void popl(Address dst); @@ -1839,6 +1863,8 @@ private: void vsubss(XMMRegister dst, XMMRegister nds, Address src); void vsubss(XMMRegister dst, XMMRegister nds, XMMRegister src); + void shlxl(Register dst, Register src1, Register src2); + void shlxq(Register dst, Register src1, Register src2); //====================VECTOR ARITHMETIC===================================== @@ -2073,9 +2099,6 @@ private: void cmppd(XMMRegister dst, XMMRegister nds, XMMRegister src, int cop, int vector_len); void vpblendd(XMMRegister dst, XMMRegister nds, XMMRegister src1, XMMRegister src2, int vector_len); - void shlxl(Register dst, Register src1, Register src2); - void shlxq(Register dst, Register src1, Register src2); - protected: // Next instructions require address alignment 16 bytes SSE mode. // They should be called only from corresponding MacroAssembler instructions. diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index 32a33e307f2..fc41ecec4b2 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -8251,10 +8251,19 @@ void MacroAssembler::string_compare(Register str1, Register str2, // Search for Non-ASCII character (Negative byte value) in a byte array, // return true if it has any and false otherwise. +// ..\jdk\src\java.base\share\classes\java\lang\StringCoding.java +// @HotSpotIntrinsicCandidate +// private static boolean hasNegatives(byte[] ba, int off, int len) { +// for (int i = off; i < off + len; i++) { +// if (ba[i] < 0) { +// return true; +// } +// } +// return false; +// } void MacroAssembler::has_negatives(Register ary1, Register len, - Register result, Register tmp1, - XMMRegister vec1, XMMRegister vec2) { - + Register result, Register tmp1, + XMMRegister vec1, XMMRegister vec2) { // rsi: byte array // rcx: len // rax: result @@ -8267,79 +8276,161 @@ void MacroAssembler::has_negatives(Register ary1, Register len, testl(len, len); jcc(Assembler::zero, FALSE_LABEL); - movl(result, len); // copy + if ((UseAVX > 2) && // AVX512 + VM_Version::supports_avx512vlbw() && + VM_Version::supports_bmi2()) { - if (UseAVX >= 2 && UseSSE >= 2) { - // With AVX2, use 32-byte vector compare - Label COMPARE_WIDE_VECTORS, COMPARE_TAIL; + set_vector_masking(); // opening of the stub context for programming mask registers - // Compare 32-byte vectors - andl(result, 0x0000001f); // tail count (in bytes) - andl(len, 0xffffffe0); // vector count (in bytes) - jcc(Assembler::zero, COMPARE_TAIL); + Label test_64_loop, test_tail; + Register tmp3_aliased = len; + + movl(tmp1, len); + vpxor(vec2, vec2, vec2, Assembler::AVX_512bit); + + andl(tmp1, 64 - 1); // tail count (in chars) 0x3F + andl(len, ~(64 - 1)); // vector count (in chars) + jccb(Assembler::zero, test_tail); lea(ary1, Address(ary1, len, Address::times_1)); negptr(len); - movl(tmp1, 0x80808080); // create mask to test for Unicode chars in vector - movdl(vec2, tmp1); - vpbroadcastd(vec2, vec2); - - bind(COMPARE_WIDE_VECTORS); - vmovdqu(vec1, Address(ary1, len, Address::times_1)); - vptest(vec1, vec2); + bind(test_64_loop); + // Check whether our 64 elements of size byte contain negatives + evpcmpgtb(k2, vec2, Address(ary1, len, Address::times_1), Assembler::AVX_512bit); + kortestql(k2, k2); jcc(Assembler::notZero, TRUE_LABEL); - addptr(len, 32); - jcc(Assembler::notZero, COMPARE_WIDE_VECTORS); - testl(result, result); + addptr(len, 64); + jccb(Assembler::notZero, test_64_loop); + + + bind(test_tail); + // bail out when there is nothing to be done + testl(tmp1, -1); jcc(Assembler::zero, FALSE_LABEL); - vmovdqu(vec1, Address(ary1, result, Address::times_1, -32)); - vptest(vec1, vec2); + // Save k1 + kmovql(k3, k1); + + // ~(~0 << len) applied up to two times (for 32-bit scenario) +#ifdef _LP64 + mov64(tmp3_aliased, 0xFFFFFFFFFFFFFFFF); + shlxq(tmp3_aliased, tmp3_aliased, tmp1); + notq(tmp3_aliased); + kmovql(k1, tmp3_aliased); +#else + Label k_init; + jmp(k_init); + + // We could not read 64-bits from a general purpose register thus we move + // data required to compose 64 1's to the instruction stream + // We emit 64 byte wide series of elements from 0..63 which later on would + // be used as a compare targets with tail count contained in tmp1 register. + // Result would be a k1 register having tmp1 consecutive number or 1 + // counting from least significant bit. + address tmp = pc(); + emit_int64(0x0706050403020100); + emit_int64(0x0F0E0D0C0B0A0908); + emit_int64(0x1716151413121110); + emit_int64(0x1F1E1D1C1B1A1918); + emit_int64(0x2726252423222120); + emit_int64(0x2F2E2D2C2B2A2928); + emit_int64(0x3736353433323130); + emit_int64(0x3F3E3D3C3B3A3938); + + bind(k_init); + lea(len, InternalAddress(tmp)); + // create mask to test for negative byte inside a vector + evpbroadcastb(vec1, tmp1, Assembler::AVX_512bit); + evpcmpgtb(k1, vec1, Address(len, 0), Assembler::AVX_512bit); + +#endif + evpcmpgtb(k2, k1, vec2, Address(ary1, 0), Assembler::AVX_512bit); + ktestq(k2, k1); + // Restore k1 + kmovql(k1, k3); jcc(Assembler::notZero, TRUE_LABEL); + jmp(FALSE_LABEL); - bind(COMPARE_TAIL); // len is zero - movl(len, result); - // Fallthru to tail compare - } else if (UseSSE42Intrinsics) { - assert(UseSSE >= 4, "SSE4 must be for SSE4.2 intrinsics to be available"); - // With SSE4.2, use double quad vector compare - Label COMPARE_WIDE_VECTORS, COMPARE_TAIL; + clear_vector_masking(); // closing of the stub context for programming mask registers + } + else { + movl(result, len); // copy - // Compare 16-byte vectors - andl(result, 0x0000000f); // tail count (in bytes) - andl(len, 0xfffffff0); // vector count (in bytes) - jccb(Assembler::zero, COMPARE_TAIL); + if (UseAVX == 2 && UseSSE >= 2) { + // With AVX2, use 32-byte vector compare + Label COMPARE_WIDE_VECTORS, COMPARE_TAIL; - lea(ary1, Address(ary1, len, Address::times_1)); - negptr(len); + // Compare 32-byte vectors + andl(result, 0x0000001f); // tail count (in bytes) + andl(len, 0xffffffe0); // vector count (in bytes) + jccb(Assembler::zero, COMPARE_TAIL); - movl(tmp1, 0x80808080); - movdl(vec2, tmp1); - pshufd(vec2, vec2, 0); + lea(ary1, Address(ary1, len, Address::times_1)); + negptr(len); - bind(COMPARE_WIDE_VECTORS); - movdqu(vec1, Address(ary1, len, Address::times_1)); - ptest(vec1, vec2); - jcc(Assembler::notZero, TRUE_LABEL); - addptr(len, 16); - jcc(Assembler::notZero, COMPARE_WIDE_VECTORS); + movl(tmp1, 0x80808080); // create mask to test for Unicode chars in vector + movdl(vec2, tmp1); + vpbroadcastd(vec2, vec2); - testl(result, result); - jcc(Assembler::zero, FALSE_LABEL); + bind(COMPARE_WIDE_VECTORS); + vmovdqu(vec1, Address(ary1, len, Address::times_1)); + vptest(vec1, vec2); + jccb(Assembler::notZero, TRUE_LABEL); + addptr(len, 32); + jcc(Assembler::notZero, COMPARE_WIDE_VECTORS); - movdqu(vec1, Address(ary1, result, Address::times_1, -16)); - ptest(vec1, vec2); - jccb(Assembler::notZero, TRUE_LABEL); - jmpb(FALSE_LABEL); + testl(result, result); + jccb(Assembler::zero, FALSE_LABEL); - bind(COMPARE_TAIL); // len is zero - movl(len, result); - // Fallthru to tail compare - } + vmovdqu(vec1, Address(ary1, result, Address::times_1, -32)); + vptest(vec1, vec2); + jccb(Assembler::notZero, TRUE_LABEL); + jmpb(FALSE_LABEL); + bind(COMPARE_TAIL); // len is zero + movl(len, result); + // Fallthru to tail compare + } + else if (UseSSE42Intrinsics) { + assert(UseSSE >= 4, "SSE4 must be for SSE4.2 intrinsics to be available"); + // With SSE4.2, use double quad vector compare + Label COMPARE_WIDE_VECTORS, COMPARE_TAIL; + + // Compare 16-byte vectors + andl(result, 0x0000000f); // tail count (in bytes) + andl(len, 0xfffffff0); // vector count (in bytes) + jccb(Assembler::zero, COMPARE_TAIL); + + lea(ary1, Address(ary1, len, Address::times_1)); + negptr(len); + + movl(tmp1, 0x80808080); + movdl(vec2, tmp1); + pshufd(vec2, vec2, 0); + + bind(COMPARE_WIDE_VECTORS); + movdqu(vec1, Address(ary1, len, Address::times_1)); + ptest(vec1, vec2); + jccb(Assembler::notZero, TRUE_LABEL); + addptr(len, 16); + jcc(Assembler::notZero, COMPARE_WIDE_VECTORS); + + testl(result, result); + jccb(Assembler::zero, FALSE_LABEL); + + movdqu(vec1, Address(ary1, result, Address::times_1, -16)); + ptest(vec1, vec2); + jccb(Assembler::notZero, TRUE_LABEL); + jmpb(FALSE_LABEL); + + bind(COMPARE_TAIL); // len is zero + movl(len, result); + // Fallthru to tail compare + } + } // Compare 4-byte vectors andl(len, 0xfffffffc); // vector count (in bytes) jccb(Assembler::zero, COMPARE_CHAR); @@ -8387,7 +8478,6 @@ void MacroAssembler::has_negatives(Register ary1, Register len, vpxor(vec2, vec2); } } - // Compare char[] or byte[] arrays aligned to 4 bytes or substrings. void MacroAssembler::arrays_equals(bool is_array_equ, Register ary1, Register ary2, Register limit, Register result, Register chr, @@ -8833,10 +8923,23 @@ void MacroAssembler::generate_fill(BasicType t, bool aligned, } // encode char[] to byte[] in ISO_8859_1 + //@HotSpotIntrinsicCandidate + //private static int implEncodeISOArray(byte[] sa, int sp, + //byte[] da, int dp, int len) { + // int i = 0; + // for (; i < len; i++) { + // char c = StringUTF16.getChar(sa, sp++); + // if (c > '\u00FF') + // break; + // da[dp++] = (byte)c; + // } + // return i; + //} void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, - XMMRegister tmp1Reg, XMMRegister tmp2Reg, - XMMRegister tmp3Reg, XMMRegister tmp4Reg, - Register tmp5, Register result) { + XMMRegister tmp1Reg, XMMRegister tmp2Reg, + XMMRegister tmp3Reg, XMMRegister tmp4Reg, + Register tmp5, Register result) { + // rsi: src // rdi: dst // rdx: len @@ -8851,6 +8954,7 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, // check for zero length testl(len, len); jcc(Assembler::zero, L_done); + movl(result, len); // Setup pointers @@ -8959,6 +9063,7 @@ void MacroAssembler::encode_iso_array(Register src, Register dst, Register len, bind(L_copy_1_char_exit); addptr(result, len); // len is negative count of not processed elements + bind(L_done); } @@ -9470,8 +9575,8 @@ void MacroAssembler::vectorized_mismatch(Register obja, Register objb, Register notq(tmp2); kmovql(k1, tmp2); - evmovdqub(k1, rymm0, Address(obja, result), Assembler::AVX_512bit); - evpcmpeqb(k1, k7, rymm0, Address(objb, result), Assembler::AVX_512bit); + evmovdqub(rymm0, k1, Address(obja, result), Assembler::AVX_512bit); + evpcmpeqb(k7, k1, rymm0, Address(objb, result), Assembler::AVX_512bit); ktestql(k7, k1); // Restore k1 @@ -10830,13 +10935,24 @@ void MacroAssembler::crc32c_ipl_alg2_alt2(Register in_out, Register in1, Registe #undef BIND #undef BLOCK_COMMENT - // Compress char[] array to byte[]. +// ..\jdk\src\java.base\share\classes\java\lang\StringUTF16.java +// @HotSpotIntrinsicCandidate +// private static int compress(char[] src, int srcOff, byte[] dst, int dstOff, int len) { +// for (int i = 0; i < len; i++) { +// int c = src[srcOff++]; +// if (c >>> 8 != 0) { +// return 0; +// } +// dst[dstOff++] = (byte)c; +// } +// return len; +// } void MacroAssembler::char_array_compress(Register src, Register dst, Register len, - XMMRegister tmp1Reg, XMMRegister tmp2Reg, - XMMRegister tmp3Reg, XMMRegister tmp4Reg, - Register tmp5, Register result) { - Label copy_chars_loop, return_length, return_zero, done; + XMMRegister tmp1Reg, XMMRegister tmp2Reg, + XMMRegister tmp3Reg, XMMRegister tmp4Reg, + Register tmp5, Register result) { + Label copy_chars_loop, return_length, return_zero, done, below_threshold; // rsi: src // rdi: dst @@ -10853,11 +10969,141 @@ void MacroAssembler::char_array_compress(Register src, Register dst, Register le // save length for return push(len); + if ((UseAVX > 2) && // AVX512 + VM_Version::supports_avx512vlbw() && + VM_Version::supports_bmi2()) { + + set_vector_masking(); // opening of the stub context for programming mask registers + + Label copy_32_loop, copy_loop_tail, copy_just_portion_of_candidates; + + // alignement + Label post_alignement; + + // if length of the string is less than 16, handle it in an old fashioned + // way + testl(len, -32); + jcc(Assembler::zero, below_threshold); + + // First check whether a character is compressable ( <= 0xFF). + // Create mask to test for Unicode chars inside zmm vector + movl(result, 0x00FF); + evpbroadcastw(tmp2Reg, result, Assembler::AVX_512bit); + + testl(len, -64); + jcc(Assembler::zero, post_alignement); + + // Save k1 + kmovql(k3, k1); + + movl(tmp5, dst); + andl(tmp5, (64 - 1)); + negl(tmp5); + andl(tmp5, (64 - 1)); + + // bail out when there is nothing to be done + testl(tmp5, 0xFFFFFFFF); + jcc(Assembler::zero, post_alignement); + + // ~(~0 << len), where len is the # of remaining elements to process + movl(result, 0xFFFFFFFF); + shlxl(result, result, tmp5); + notl(result); + + kmovdl(k1, result); + + evmovdquw(tmp1Reg, k1, Address(src, 0), Assembler::AVX_512bit); + evpcmpuw(k2, k1, tmp1Reg, tmp2Reg, Assembler::le, Assembler::AVX_512bit); + ktestd(k2, k1); + jcc(Assembler::carryClear, copy_just_portion_of_candidates); + + evpmovwb(Address(dst, 0), k1, tmp1Reg, Assembler::AVX_512bit); + + addptr(src, tmp5); + addptr(src, tmp5); + addptr(dst, tmp5); + subl(len, tmp5); + + bind(post_alignement); + // end of alignement + + movl(tmp5, len); + andl(tmp5, (32 - 1)); // tail count (in chars) + andl(len, ~(32 - 1)); // vector count (in chars) + jcc(Assembler::zero, copy_loop_tail); + + lea(src, Address(src, len, Address::times_2)); + lea(dst, Address(dst, len, Address::times_1)); + negptr(len); + + bind(copy_32_loop); + evmovdquw(tmp1Reg, Address(src, len, Address::times_2), Assembler::AVX_512bit); + evpcmpuw(k2, tmp1Reg, tmp2Reg, Assembler::le, Assembler::AVX_512bit); + kortestdl(k2, k2); + jcc(Assembler::carryClear, copy_just_portion_of_candidates); + + // All elements in current processed chunk are valid candidates for + // compression. Write a truncated byte elements to the memory. + evpmovwb(Address(dst, len, Address::times_1), tmp1Reg, Assembler::AVX_512bit); + addptr(len, 32); + jcc(Assembler::notZero, copy_32_loop); + + bind(copy_loop_tail); + // bail out when there is nothing to be done + testl(tmp5, 0xFFFFFFFF); + jcc(Assembler::zero, return_length); + + // Save k1 + kmovql(k3, k1); + + movl(len, tmp5); + + // ~(~0 << len), where len is the # of remaining elements to process + movl(result, 0xFFFFFFFF); + shlxl(result, result, len); + notl(result); + + kmovdl(k1, result); + + evmovdquw(tmp1Reg, k1, Address(src, 0), Assembler::AVX_512bit); + evpcmpuw(k2, k1, tmp1Reg, tmp2Reg, Assembler::le, Assembler::AVX_512bit); + ktestd(k2, k1); + jcc(Assembler::carryClear, copy_just_portion_of_candidates); + + evpmovwb(Address(dst, 0), k1, tmp1Reg, Assembler::AVX_512bit); + // Restore k1 + kmovql(k1, k3); + + jmp(return_length); + + bind(copy_just_portion_of_candidates); + kmovdl(tmp5, k2); + tzcntl(tmp5, tmp5); + + // ~(~0 << tmp5), where tmp5 is a number of elements in an array from the + // result to the first element larger than 0xFF + movl(result, 0xFFFFFFFF); + shlxl(result, result, tmp5); + notl(result); + + kmovdl(k1, result); + + evpmovwb(Address(dst, 0), k1, tmp1Reg, Assembler::AVX_512bit); + // Restore k1 + kmovql(k1, k3); + + jmp(return_zero); + + clear_vector_masking(); // closing of the stub context for programming mask registers + } if (UseSSE42Intrinsics) { assert(UseSSE >= 4, "SSE4 must be enabled for SSE4.2 intrinsics to be available"); Label copy_32_loop, copy_16, copy_tail; + bind(below_threshold); + movl(result, len); + movl(tmp5, 0xff00ff00); // create mask to test for Unicode chars in vectors // vectored compression @@ -10939,10 +11185,16 @@ void MacroAssembler::char_array_compress(Register src, Register dst, Register le } // Inflate byte[] array to char[]. +// ..\jdk\src\java.base\share\classes\java\lang\StringLatin1.java +// @HotSpotIntrinsicCandidate +// private static void inflate(byte[] src, int srcOff, char[] dst, int dstOff, int len) { +// for (int i = 0; i < len; i++) { +// dst[dstOff++] = (char)(src[srcOff++] & 0xff); +// } +// } void MacroAssembler::byte_array_inflate(Register src, Register dst, Register len, - XMMRegister tmp1, Register tmp2) { - Label copy_chars_loop, done; - + XMMRegister tmp1, Register tmp2) { + Label copy_chars_loop, done, below_threshold; // rsi: src // rdi: dst // rdx: len @@ -10953,20 +11205,109 @@ void MacroAssembler::byte_array_inflate(Register src, Register dst, Register len // rdx holds length assert_different_registers(src, dst, len, tmp2); + if ((UseAVX > 2) && // AVX512 + VM_Version::supports_avx512vlbw() && + VM_Version::supports_bmi2()) { + + set_vector_masking(); // opening of the stub context for programming mask registers + + Label copy_32_loop, copy_tail; + Register tmp3_aliased = len; + + // if length of the string is less than 16, handle it in an old fashioned + // way + testl(len, -16); + jcc(Assembler::zero, below_threshold); + + // In order to use only one arithmetic operation for the main loop we use + // this pre-calculation + movl(tmp2, len); + andl(tmp2, (32 - 1)); // tail count (in chars), 32 element wide loop + andl(len, -32); // vector count + jccb(Assembler::zero, copy_tail); + + lea(src, Address(src, len, Address::times_1)); + lea(dst, Address(dst, len, Address::times_2)); + negptr(len); + + + // inflate 32 chars per iter + bind(copy_32_loop); + vpmovzxbw(tmp1, Address(src, len, Address::times_1), Assembler::AVX_512bit); + evmovdquw(Address(dst, len, Address::times_2), tmp1, Assembler::AVX_512bit); + addptr(len, 32); + jcc(Assembler::notZero, copy_32_loop); + + bind(copy_tail); + // bail out when there is nothing to be done + testl(tmp2, -1); // we don't destroy the contents of tmp2 here + jcc(Assembler::zero, done); + + // Save k1 + kmovql(k2, k1); + + // ~(~0 << length), where length is the # of remaining elements to process + movl(tmp3_aliased, -1); + shlxl(tmp3_aliased, tmp3_aliased, tmp2); + notl(tmp3_aliased); + kmovdl(k1, tmp3_aliased); + evpmovzxbw(tmp1, k1, Address(src, 0), Assembler::AVX_512bit); + evmovdquw(Address(dst, 0), k1, tmp1, Assembler::AVX_512bit); + + // Restore k1 + kmovql(k1, k2); + jmp(done); + + clear_vector_masking(); // closing of the stub context for programming mask registers + } if (UseSSE42Intrinsics) { assert(UseSSE >= 4, "SSE4 must be enabled for SSE4.2 intrinsics to be available"); - Label copy_8_loop, copy_bytes, copy_tail; + Label copy_16_loop, copy_8_loop, copy_bytes, copy_new_tail, copy_tail; movl(tmp2, len); - andl(tmp2, 0x00000007); // tail count (in chars) - andl(len, 0xfffffff8); // vector count (in chars) - jccb(Assembler::zero, copy_tail); + + if (UseAVX > 1) { + andl(tmp2, (16 - 1)); + andl(len, -16); + jccb(Assembler::zero, copy_new_tail); + } else { + andl(tmp2, 0x00000007); // tail count (in chars) + andl(len, 0xfffffff8); // vector count (in chars) + jccb(Assembler::zero, copy_tail); + } // vectored inflation lea(src, Address(src, len, Address::times_1)); lea(dst, Address(dst, len, Address::times_2)); negptr(len); + if (UseAVX > 1) { + bind(copy_16_loop); + vpmovzxbw(tmp1, Address(src, len, Address::times_1), Assembler::AVX_256bit); + vmovdqu(Address(dst, len, Address::times_2), tmp1); + addptr(len, 16); + jcc(Assembler::notZero, copy_16_loop); + + bind(below_threshold); + bind(copy_new_tail); + if (UseAVX > 2) { + movl(tmp2, len); + } + else { + movl(len, tmp2); + } + andl(tmp2, 0x00000007); + andl(len, 0xFFFFFFF8); + jccb(Assembler::zero, copy_tail); + + pmovzxbw(tmp1, Address(src, 0)); + movdqu(Address(dst, 0), tmp1); + addptr(src, 8); + addptr(dst, 2 * 8); + + jmp(copy_tail, true); + } + // inflate 8 chars per iter bind(copy_8_loop); pmovzxbw(tmp1, Address(src, len, Address::times_1)); // unpack to 8 words @@ -11005,7 +11346,6 @@ void MacroAssembler::byte_array_inflate(Register src, Register dst, Register len bind(done); } - Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) { switch (cond) { // Note some conditions are synonyms for others -- GitLab From 107de3478c5339e7eac1218909d2c4870300e4ef Mon Sep 17 00:00:00 2001 From: Paul Sandoz Date: Thu, 5 May 2016 18:14:51 -0700 Subject: [PATCH 302/400] 8155794: Move Objects.checkIndex BiFunction accepting methods to an internal package Reviewed-by: shade, vlivanov --- hotspot/src/share/vm/classfile/vmSymbols.hpp | 5 +++-- hotspot/src/share/vm/opto/c2compiler.cpp | 4 ++-- hotspot/src/share/vm/opto/library_call.cpp | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index 8b68c90523c..bd708f1e8da 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -117,6 +117,7 @@ template(java_util_Hashtable, "java/util/Hashtable") \ template(java_lang_Compiler, "java/lang/Compiler") \ template(jdk_internal_misc_Signal, "jdk/internal/misc/Signal") \ + template(jdk_internal_util_Preconditions, "jdk/internal/util/Preconditions") \ template(java_lang_AssertionStatusDirectives, "java/lang/AssertionStatusDirectives") \ template(getBootClassPathEntryForClass_name, "getBootClassPathEntryForClass") \ template(jdk_internal_vm_PostVMInitHook, "jdk/internal/vm/PostVMInitHook") \ @@ -940,8 +941,8 @@ do_intrinsic(_equalsL, java_lang_StringLatin1,equals_name, equalsB_signature, F_S) \ do_intrinsic(_equalsU, java_lang_StringUTF16, equals_name, equalsB_signature, F_S) \ \ - do_intrinsic(_Objects_checkIndex, java_util_Objects, checkIndex_name, Objects_checkIndex_signature, F_S) \ - do_signature(Objects_checkIndex_signature, "(IILjava/util/function/BiFunction;)I") \ + do_intrinsic(_Preconditions_checkIndex, jdk_internal_util_Preconditions, checkIndex_name, Preconditions_checkIndex_signature, F_S) \ + do_signature(Preconditions_checkIndex_signature, "(IILjava/util/function/BiFunction;)I") \ \ do_class(java_nio_Buffer, "java/nio/Buffer") \ do_intrinsic(_checkIndex, java_nio_Buffer, checkIndex_name, int_int_signature, F_R) \ diff --git a/hotspot/src/share/vm/opto/c2compiler.cpp b/hotspot/src/share/vm/opto/c2compiler.cpp index b46b3c8d30f..0c067f8ab8e 100644 --- a/hotspot/src/share/vm/opto/c2compiler.cpp +++ b/hotspot/src/share/vm/opto/c2compiler.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -545,7 +545,7 @@ bool C2Compiler::is_intrinsic_supported(const methodHandle& method, bool is_virt case vmIntrinsics::_updateByteBufferAdler32: case vmIntrinsics::_profileBoolean: case vmIntrinsics::_isCompileConstant: - case vmIntrinsics::_Objects_checkIndex: + case vmIntrinsics::_Preconditions_checkIndex: break; default: return false; diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index aca79cbc6e2..092e6c7f899 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -261,7 +261,7 @@ class LibraryCallKit : public GraphKit { bool inline_native_getLength(); bool inline_array_copyOf(bool is_copyOfRange); bool inline_array_equals(StrIntrinsicNode::ArgEnc ae); - bool inline_objects_checkIndex(); + bool inline_preconditions_checkIndex(); void copy_to_clone(Node* obj, Node* alloc_obj, Node* obj_size, bool is_array, bool card_mark); bool inline_native_clone(bool is_virtual); bool inline_native_Reflection_getCallerClass(); @@ -714,7 +714,7 @@ bool LibraryCallKit::try_to_inline(int predicate) { case vmIntrinsics::_copyOfRange: return inline_array_copyOf(true); case vmIntrinsics::_equalsB: return inline_array_equals(StrIntrinsicNode::LL); case vmIntrinsics::_equalsC: return inline_array_equals(StrIntrinsicNode::UU); - case vmIntrinsics::_Objects_checkIndex: return inline_objects_checkIndex(); + case vmIntrinsics::_Preconditions_checkIndex: return inline_preconditions_checkIndex(); case vmIntrinsics::_clone: return inline_native_clone(intrinsic()->is_virtual()); case vmIntrinsics::_allocateUninitializedArray: return inline_unsafe_newArray(true); @@ -1141,7 +1141,7 @@ bool LibraryCallKit::inline_hasNegatives() { return true; } -bool LibraryCallKit::inline_objects_checkIndex() { +bool LibraryCallKit::inline_preconditions_checkIndex() { Node* index = argument(0); Node* length = argument(1); if (too_many_traps(Deoptimization::Reason_intrinsic) || too_many_traps(Deoptimization::Reason_range_check)) { -- GitLab From b9a1863e453835d39876c17d5a4a81c33d61e4b9 Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Thu, 5 May 2016 20:14:46 -0700 Subject: [PATCH 303/400] 8156178: [JVMCI] expose StubRoutines trig functions Reviewed-by: kvn --- .../jdk/vm/ci/hotspot/HotSpotVMConfig.java | 14 +++++------ .../src/share/vm/jvmci/jvmciCompilerToVM.cpp | 25 +++++++++++++++++++ .../src/share/vm/jvmci/jvmciCompilerToVM.hpp | 8 ++++++ .../src/share/vm/jvmci/vmStructs_jvmci.cpp | 15 +++++------ 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java index e3dd24edbb4..1f7ffc18a71 100644 --- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java +++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java @@ -1559,13 +1559,13 @@ public class HotSpotVMConfig { @HotSpotVMAddress(name = "os::javaTimeMillis") @Stable public long javaTimeMillisAddress; @HotSpotVMAddress(name = "os::javaTimeNanos") @Stable public long javaTimeNanosAddress; - @HotSpotVMAddress(name = "SharedRuntime::dsin") @Stable public long arithmeticSinAddress; - @HotSpotVMAddress(name = "SharedRuntime::dcos") @Stable public long arithmeticCosAddress; - @HotSpotVMAddress(name = "SharedRuntime::dtan") @Stable public long arithmeticTanAddress; - @HotSpotVMAddress(name = "SharedRuntime::dexp") @Stable public long arithmeticExpAddress; - @HotSpotVMAddress(name = "SharedRuntime::dlog") @Stable public long arithmeticLogAddress; - @HotSpotVMAddress(name = "SharedRuntime::dlog10") @Stable public long arithmeticLog10Address; - @HotSpotVMAddress(name = "SharedRuntime::dpow") @Stable public long arithmeticPowAddress; + @HotSpotVMField(name = "CompilerToVM::Data::dsin", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticSinAddress; + @HotSpotVMField(name = "CompilerToVM::Data::dcos", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticCosAddress; + @HotSpotVMField(name = "CompilerToVM::Data::dtan", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticTanAddress; + @HotSpotVMField(name = "CompilerToVM::Data::dexp", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticExpAddress; + @HotSpotVMField(name = "CompilerToVM::Data::dlog", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticLogAddress; + @HotSpotVMField(name = "CompilerToVM::Data::dlog10", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticLog10Address; + @HotSpotVMField(name = "CompilerToVM::Data::dpow", type = "address", get = HotSpotVMField.Type.VALUE) @Stable public long arithmeticPowAddress; @HotSpotVMFlag(name = "JVMCICounterSize") @Stable public int jvmciCountersSize; diff --git a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp index 5c1f8c37fea..94108e6c75c 100644 --- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp +++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp @@ -154,6 +154,14 @@ int CompilerToVM::Data::cardtable_shift; int CompilerToVM::Data::vm_page_size; +address CompilerToVM::Data::dsin; +address CompilerToVM::Data::dcos; +address CompilerToVM::Data::dtan; +address CompilerToVM::Data::dexp; +address CompilerToVM::Data::dlog; +address CompilerToVM::Data::dlog10; +address CompilerToVM::Data::dpow; + void CompilerToVM::Data::initialize() { Klass_vtable_start_offset = in_bytes(Klass::vtable_start_offset()); Klass_vtable_length_offset = in_bytes(Klass::vtable_length_offset()); @@ -205,6 +213,23 @@ void CompilerToVM::Data::initialize() { } vm_page_size = os::vm_page_size(); + +#define SET_TRIGFUNC(name) \ + if (StubRoutines::name() != NULL) { \ + name = StubRoutines::name(); \ + } else { \ + name = CAST_FROM_FN_PTR(address, SharedRuntime::name); \ + } + + SET_TRIGFUNC(dsin); + SET_TRIGFUNC(dcos); + SET_TRIGFUNC(dtan); + SET_TRIGFUNC(dexp); + SET_TRIGFUNC(dlog10); + SET_TRIGFUNC(dlog); + SET_TRIGFUNC(dpow); + +#undef SET_TRIGFUNC } /** diff --git a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp index 9ec78fd7358..f6790375d64 100644 --- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp +++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.hpp @@ -65,6 +65,14 @@ class CompilerToVM { static int vm_page_size; + static address dsin; + static address dcos; + static address dtan; + static address dexp; + static address dlog; + static address dlog10; + static address dpow; + public: static void initialize(); }; diff --git a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp index 7488bcc3f21..a40a3e11867 100644 --- a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp +++ b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp @@ -76,6 +76,14 @@ \ static_field(CompilerToVM::Data, vm_page_size, int) \ \ + static_field(CompilerToVM::Data, dsin, address) \ + static_field(CompilerToVM::Data, dcos, address) \ + static_field(CompilerToVM::Data, dtan, address) \ + static_field(CompilerToVM::Data, dexp, address) \ + static_field(CompilerToVM::Data, dlog, address) \ + static_field(CompilerToVM::Data, dlog10, address) \ + static_field(CompilerToVM::Data, dpow, address) \ + \ static_field(Abstract_VM_Version, _features, uint64_t) \ \ nonstatic_field(Array, _length, int) \ @@ -524,13 +532,6 @@ declare_function(SharedRuntime::exception_handler_for_return_address) \ declare_function(SharedRuntime::OSR_migration_end) \ declare_function(SharedRuntime::enable_stack_reserved_zone) \ - declare_function(SharedRuntime::dsin) \ - declare_function(SharedRuntime::dcos) \ - declare_function(SharedRuntime::dtan) \ - declare_function(SharedRuntime::dexp) \ - declare_function(SharedRuntime::dlog) \ - declare_function(SharedRuntime::dlog10) \ - declare_function(SharedRuntime::dpow) \ \ declare_function(os::dll_load) \ declare_function(os::dll_lookup) \ -- GitLab From 37389f4e6086d20cb57e03972bf0c6238a7faff0 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Fri, 6 May 2016 09:10:47 +0200 Subject: [PATCH 304/400] 8156190: [ppc] Fix build after "8151268: Wire up the x86 _vectorizedMismatch stub routine in C1" New function was placed within other function. Reviewed-by: mdoerr --- hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp index eec6909ac59..120a87c0d28 100644 --- a/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/c1_LIRGenerator_ppc.cpp @@ -1426,10 +1426,10 @@ void LIRGenerator::do_update_CRC32(Intrinsic* x) { ShouldNotReachHere(); } } +} - void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) { - fatal("vectorizedMismatch intrinsic is not implemented on this platform"); - } +void LIRGenerator::do_vectorizedMismatch(Intrinsic* x) { + fatal("vectorizedMismatch intrinsic is not implemented on this platform"); } void LIRGenerator::do_update_CRC32C(Intrinsic* x) { -- GitLab From b3f1f110f4db7ceb3c05acea5e45cd3a8fcfd7c1 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 6 May 2016 15:41:15 +0300 Subject: [PATCH 305/400] 8156068: Unsafe.{get|set}Opaque should be single copy atomic Reviewed-by: psandoz, vlivanov --- hotspot/src/share/vm/opto/library_call.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 092e6c7f899..06365f14579 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -2472,9 +2472,10 @@ bool LibraryCallKit::inline_unsafe_access(const bool is_native_ptr, bool is_stor bool requires_atomic_access = false; switch (kind) { case Relaxed: - case Opaque: requires_atomic_access = AlwaysAtomicAccesses; break; + case Opaque: + // Opaque accesses are atomic. case Acquire: case Release: case Volatile: -- GitLab From 28efea6754b869028ec66af134c93d4bffe2afbd Mon Sep 17 00:00:00 2001 From: Jamsheed Mohammed C M Date: Fri, 6 May 2016 05:42:36 -0700 Subject: [PATCH 306/400] 8156126: LogCompilation: Dump additional info about deoptimization events Added reason and pc information to deoptimization info. Reviewed-by: vlivanov --- hotspot/src/share/vm/runtime/deoptimization.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/runtime/deoptimization.cpp b/hotspot/src/share/vm/runtime/deoptimization.cpp index 4524f2b6d4e..f926b88eca8 100644 --- a/hotspot/src/share/vm/runtime/deoptimization.cpp +++ b/hotspot/src/share/vm/runtime/deoptimization.cpp @@ -1321,7 +1321,7 @@ void Deoptimization::deoptimize_single_frame(JavaThread* thread, frame fr, Deopt assert(cm != NULL, "only compiled methods can deopt"); ttyLocker ttyl; - xtty->begin_head("deoptimized thread='" UINTX_FORMAT "'", (uintx)thread->osthread()->thread_id()); + xtty->begin_head("deoptimized thread='" UINTX_FORMAT "' reason='%s' pc='" INTPTR_FORMAT "'",(uintx)thread->osthread()->thread_id(), trap_reason_name(reason), p2i(fr.pc())); cm->log_identity(xtty); xtty->end_head(); for (ScopeDesc* sd = cm->scope_desc_at(fr.pc()); ; sd = sd->sender()) { -- GitLab From 88cbbd634e9b7a077a4b779f7b0ca0ce4a4aea19 Mon Sep 17 00:00:00 2001 From: Jamsheed Mohammed C M Date: Fri, 6 May 2016 05:57:43 -0700 Subject: [PATCH 307/400] 8156124: Update compiler/unsafe/UnsafeGetConstantField after JDK-8148518 is fixed Removed workaround added for 8148518. Reviewed-by: vlivanov --- hotspot/test/compiler/unsafe/UnsafeGetConstantField.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java b/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java index d338047da5e..e5cc32607aa 100644 --- a/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java +++ b/hotspot/test/compiler/unsafe/UnsafeGetConstantField.java @@ -147,10 +147,7 @@ public class UnsafeGetConstantField { if (!hasDefaultValue && (stable || g.isFinal())) { Asserts.assertEQ(t.value, test.testDirect(), "direct read doesn't return prev value"); - // fails for getCharUnaligned due to JDK-8148518 - if (!(t == JavaType.C && "Unaligned".equals(postfix))) { - Asserts.assertEQ(test.testDirect(), test.testUnsafe()); - } + Asserts.assertEQ(test.testDirect(), test.testUnsafe()); } else { Asserts.assertEQ(t.defaultValue, test.testDirect(), "direct read doesn't return default value"); -- GitLab From 08dac03ddc4545674c2bbccd6efe7df1363eec4e Mon Sep 17 00:00:00 2001 From: Jamsheed Mohammed C M Date: Fri, 6 May 2016 06:08:15 -0700 Subject: [PATCH 308/400] 8156131: C2: MachProj dumps data on tty w/ -XX:+WizardMode Made to dump on output stream on wizard mode. Reviewed-by: vlivanov --- hotspot/src/share/vm/opto/machnode.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/opto/machnode.cpp b/hotspot/src/share/vm/opto/machnode.cpp index fc5b08625e5..cd0839c3294 100644 --- a/hotspot/src/share/vm/opto/machnode.cpp +++ b/hotspot/src/share/vm/opto/machnode.cpp @@ -600,8 +600,8 @@ const TypePtr *MachProjNode::adr_type() const { void MachProjNode::dump_spec(outputStream *st) const { ProjNode::dump_spec(st); switch (_ideal_reg) { - case unmatched_proj: st->print("/unmatched"); break; - case fat_proj: st->print("/fat"); if (WizardMode) _rout.dump(); break; + case unmatched_proj: st->print("/unmatched"); break; + case fat_proj: st->print("/fat"); if (WizardMode) _rout.dump(st); break; } } #endif -- GitLab From 66686b8152106e9dbd8dbbcbe5a27b509232530f Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Mon, 9 May 2016 14:15:39 +0300 Subject: [PATCH 309/400] 8149591: Prepare hotspot for GTest Co-authored-by: Stefan Karlsson Co-authored-by: Stefan Sarne Co-authored-by: Jesper Wilhelmsson Co-authored-by: Erik Helin Co-authored-by: Alexandre Iline Reviewed-by: jwilhelm --- hotspot/src/os/posix/vm/os_posix.cpp | 6 ++ hotspot/src/share/vm/memory/allocation.cpp | 58 ------------ hotspot/src/share/vm/memory/operator_new.cpp | 92 ++++++++++++++++++++ hotspot/src/share/vm/runtime/globals.hpp | 3 + hotspot/src/share/vm/services/management.cpp | 6 +- hotspot/src/share/vm/utilities/debug.cpp | 19 +++- hotspot/src/share/vm/utilities/debug.hpp | 24 ++++- 7 files changed, 145 insertions(+), 63 deletions(-) create mode 100644 hotspot/src/share/vm/memory/operator_new.cpp diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp index 065d44b427e..a7622b6cb96 100644 --- a/hotspot/src/os/posix/vm/os_posix.cpp +++ b/hotspot/src/os/posix/vm/os_posix.cpp @@ -47,6 +47,12 @@ // Check core dump limit and report possible place where core can be found void os::check_dump_limit(char* buffer, size_t bufferSize) { + if (!FLAG_IS_DEFAULT(CreateCoredumpOnCrash) && !CreateCoredumpOnCrash) { + jio_snprintf(buffer, bufferSize, "CreateCoredumpOnCrash is disabled from command line"); + VMError::record_coredump_status(buffer, false); + return; + } + int n; struct rlimit rlim; bool success; diff --git a/hotspot/src/share/vm/memory/allocation.cpp b/hotspot/src/share/vm/memory/allocation.cpp index 5a3ae92cb60..f7dea3d6c91 100644 --- a/hotspot/src/share/vm/memory/allocation.cpp +++ b/hotspot/src/share/vm/memory/allocation.cpp @@ -664,64 +664,6 @@ void* Arena::internal_malloc_4(size_t x) { // Non-product code #ifndef PRODUCT -// The global operator new should never be called since it will usually indicate -// a memory leak. Use CHeapObj as the base class of such objects to make it explicit -// that they're allocated on the C heap. -// Commented out in product version to avoid conflicts with third-party C++ native code. -// -// In C++98/03 the throwing new operators are defined with the following signature: -// -// void* operator new(std::size_tsize) throw(std::bad_alloc); -// void* operator new[](std::size_tsize) throw(std::bad_alloc); -// -// while all the other (non-throwing) new and delete operators are defined with an empty -// throw clause (i.e. "operator delete(void* p) throw()") which means that they do not -// throw any exceptions (see section 18.4 of the C++ standard). -// -// In the new C++11/14 standard, the signature of the throwing new operators was changed -// by completely omitting the throw clause (which effectively means they could throw any -// exception) while all the other new/delete operators where changed to have a 'nothrow' -// clause instead of an empty throw clause. -// -// Unfortunately, the support for exception specifications among C++ compilers is still -// very fragile. While some more strict compilers like AIX xlC or HP aCC reject to -// override the default throwing new operator with a user operator with an empty throw() -// clause, the MS Visual C++ compiler warns for every non-empty throw clause like -// throw(std::bad_alloc) that it will ignore the exception specification. The following -// operator definitions have been checked to correctly work with all currently supported -// compilers and they should be upwards compatible with C++11/14. Therefore -// PLEASE BE CAREFUL if you change the signature of the following operators! - -static void * zero = (void *) 0; - -void* operator new(size_t size) /* throw(std::bad_alloc) */ { - fatal("Should not call global operator new"); - return zero; -} - -void* operator new [](size_t size) /* throw(std::bad_alloc) */ { - fatal("Should not call global operator new[]"); - return zero; -} - -void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() { - fatal("Should not call global operator new"); - return 0; -} - -void* operator new [](size_t size, std::nothrow_t& nothrow_constant) throw() { - fatal("Should not call global operator new[]"); - return 0; -} - -void operator delete(void* p) throw() { - fatal("Should not call global delete"); -} - -void operator delete [](void* p) throw() { - fatal("Should not call global delete []"); -} - void AllocatedObj::print() const { print_on(tty); } void AllocatedObj::print_value() const { print_value_on(tty); } diff --git a/hotspot/src/share/vm/memory/operator_new.cpp b/hotspot/src/share/vm/memory/operator_new.cpp new file mode 100644 index 00000000000..69181a40103 --- /dev/null +++ b/hotspot/src/share/vm/memory/operator_new.cpp @@ -0,0 +1,92 @@ +/* + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "utilities/debug.hpp" + +#include + +//-------------------------------------------------------------------------------------- +// Non-product code + +#ifndef PRODUCT +// The global operator new should never be called since it will usually indicate +// a memory leak. Use CHeapObj as the base class of such objects to make it explicit +// that they're allocated on the C heap. +// Commented out in product version to avoid conflicts with third-party C++ native code. +// +// In C++98/03 the throwing new operators are defined with the following signature: +// +// void* operator new(std::size_tsize) throw(std::bad_alloc); +// void* operator new[](std::size_tsize) throw(std::bad_alloc); +// +// while all the other (non-throwing) new and delete operators are defined with an empty +// throw clause (i.e. "operator delete(void* p) throw()") which means that they do not +// throw any exceptions (see section 18.4 of the C++ standard). +// +// In the new C++11/14 standard, the signature of the throwing new operators was changed +// by completely omitting the throw clause (which effectively means they could throw any +// exception) while all the other new/delete operators where changed to have a 'nothrow' +// clause instead of an empty throw clause. +// +// Unfortunately, the support for exception specifications among C++ compilers is still +// very fragile. While some more strict compilers like AIX xlC or HP aCC reject to +// override the default throwing new operator with a user operator with an empty throw() +// clause, the MS Visual C++ compiler warns for every non-empty throw clause like +// throw(std::bad_alloc) that it will ignore the exception specification. The following +// operator definitions have been checked to correctly work with all currently supported +// compilers and they should be upwards compatible with C++11/14. Therefore +// PLEASE BE CAREFUL if you change the signature of the following operators! + +static void * zero = (void *) 0; + +void* operator new(size_t size) /* throw(std::bad_alloc) */ { + fatal("Should not call global operator new"); + return zero; +} + +void* operator new [](size_t size) /* throw(std::bad_alloc) */ { + fatal("Should not call global operator new[]"); + return zero; +} + +void* operator new(size_t size, const std::nothrow_t& nothrow_constant) throw() { + fatal("Should not call global operator new"); + return 0; +} + +void* operator new [](size_t size, std::nothrow_t& nothrow_constant) throw() { + fatal("Should not call global operator new[]"); + return 0; +} + +void operator delete(void* p) throw() { + fatal("Should not call global delete"); +} + +void operator delete [](void* p) throw() { + fatal("Should not call global delete []"); +} + +#endif // Non-product diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 3fb93e1b236..2772c1f2632 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -2070,6 +2070,9 @@ public: notproduct(bool, VerboseInternalVMTests, false, \ "Turn on logging for internal VM tests.") \ \ + product(bool, ExecutingUnitTests, false, \ + "Whether the JVM is running unit tests or not") \ + \ product_pd(bool, UseTLAB, "Use thread-local object allocation") \ \ product_pd(bool, ResizeTLAB, \ diff --git a/hotspot/src/share/vm/services/management.cpp b/hotspot/src/share/vm/services/management.cpp index 6de924a21ab..ff4da35c88b 100644 --- a/hotspot/src/share/vm/services/management.cpp +++ b/hotspot/src/share/vm/services/management.cpp @@ -1609,8 +1609,8 @@ JVM_ENTRY(void, jmm_SetVMGlobal(JNIEnv *env, jstring flag_name, jvalue new_value } char* name = java_lang_String::as_utf8_string(fn); - FormatBuffer<80> err_msg("%s", ""); - int succeed = WriteableFlags::set_flag(name, new_value, Flag::MANAGEMENT, err_msg); + FormatBuffer<80> error_msg("%s", ""); + int succeed = WriteableFlags::set_flag(name, new_value, Flag::MANAGEMENT, error_msg); if (succeed != Flag::SUCCESS) { if (succeed == Flag::MISSING_VALUE) { @@ -1619,7 +1619,7 @@ JVM_ENTRY(void, jmm_SetVMGlobal(JNIEnv *env, jstring flag_name, jvalue new_value } else { // all the other errors are reported as IAE with the appropriate error message THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(), - err_msg.buffer()); + error_msg.buffer()); } } assert(succeed == Flag::SUCCESS, "Setting flag should succeed"); diff --git a/hotspot/src/share/vm/utilities/debug.cpp b/hotspot/src/share/vm/utilities/debug.cpp index ad1e9e43a78..b2844487530 100644 --- a/hotspot/src/share/vm/utilities/debug.cpp +++ b/hotspot/src/share/vm/utilities/debug.cpp @@ -58,6 +58,8 @@ #include "trace/tracing.hpp" #endif +#include + #ifndef ASSERT # ifdef _DEBUG // NOTE: don't turn the lines below into a comment -- if you're getting @@ -187,7 +189,7 @@ bool error_is_suppressed(const char* file_name, int line_no) { return true; } - if (!is_error_reported()) { + if (!is_error_reported() && !SuppressFatalErrorMessage) { // print a friendly hint: fdStream out(defaultStream::output_fd()); out.print_raw_cr("# To suppress the following error report, specify this argument"); @@ -262,6 +264,21 @@ void report_unimplemented(const char* file, int line) { report_vm_error(file, line, "Unimplemented()"); } +#ifdef ASSERT +bool is_executing_unit_tests() { + return ExecutingUnitTests; +} + +void report_assert_msg(const char* msg, ...) { + va_list ap; + va_start(ap, msg); + + fprintf(stderr, "assert failed: %s\n", err_msg(FormatBufferDummy(), msg, ap).buffer()); + + va_end(ap); +} +#endif // ASSERT + void report_untested(const char* file, int line, const char* message) { #ifndef PRODUCT warning("Untested: %s in %s: %d\n", message, file, line); diff --git a/hotspot/src/share/vm/utilities/debug.hpp b/hotspot/src/share/vm/utilities/debug.hpp index 398e38b6f84..d5da6db4cab 100644 --- a/hotspot/src/share/vm/utilities/debug.hpp +++ b/hotspot/src/share/vm/utilities/debug.hpp @@ -46,11 +46,15 @@ class FormatBufferResource : public FormatBufferBase { FormatBufferResource(const char * format, ...) ATTRIBUTE_PRINTF(2, 3); }; +class FormatBufferDummy {}; + // Use stack for buffer template class FormatBuffer : public FormatBufferBase { public: inline FormatBuffer(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); + // since va_list is unspecified type (can be char*), we use FormatBufferDummy to disambiguate these constructors + inline FormatBuffer(FormatBufferDummy dummy, const char* format, va_list ap) ATTRIBUTE_PRINTF(3, 0); inline void append(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); inline void print(const char* format, ...) ATTRIBUTE_PRINTF(2, 3); inline void printv(const char* format, va_list ap) ATTRIBUTE_PRINTF(2, 0); @@ -74,6 +78,11 @@ FormatBuffer::FormatBuffer(const char * format, ...) : FormatBufferBase(_ va_end(argp); } +template +FormatBuffer::FormatBuffer(FormatBufferDummy dummy, const char * format, va_list ap) : FormatBufferBase(_buffer) { + jio_vsnprintf(_buf, bufsz, format, ap); +} + template FormatBuffer::FormatBuffer() : FormatBufferBase(_buffer) { _buf[0] = '\0'; @@ -119,11 +128,13 @@ typedef FormatBuffer<> err_msg; #define vmassert(p, ...) \ do { \ if (!(p)) { \ + if (is_executing_unit_tests()) { \ + report_assert_msg(__VA_ARGS__); \ + } \ report_vm_error(__FILE__, __LINE__, "assert(" #p ") failed", __VA_ARGS__); \ BREAKPOINT; \ } \ } while (0) - #endif // For backward compatibility. @@ -210,10 +221,16 @@ void report_vm_error(const char* file, int line, const char* error_msg); // ATTRIBUTE_PRINTF works with gcc >= 4.8 and any other compiler. void report_vm_error(const char* file, int line, const char* error_msg, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(4, 5); +#ifdef ASSERT +void report_assert_msg(const char* msg, ...) ATTRIBUTE_PRINTF(1, 2); +#endif // ASSERT #else // GCC < 4.8 warns because of empty format string. Warning can not be switched off selectively. void report_vm_error(const char* file, int line, const char* error_msg, const char* detail_fmt, ...); +#ifdef ASSERT +void report_assert_msg(const char* msg, ...); +#endif // ASSERT #endif void report_vm_status_error(const char* file, int line, const char* error_msg, int status, const char* detail); @@ -225,6 +242,11 @@ void report_should_not_reach_here(const char* file, int line); void report_unimplemented(const char* file, int line); void report_untested(const char* file, int line, const char* message); +#ifdef ASSERT +// unit test support +bool is_executing_unit_tests(); +#endif // ASSERT + void warning(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); // Compile-time asserts. Cond must be a compile-time constant expression that -- GitLab From dc12061bb6b99a20952e7d21627f2df1c90f2c41 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Mon, 9 May 2016 14:15:40 +0300 Subject: [PATCH 310/400] 8148244: Finalize and integrate GTest implementation Co-authored-by: Stefan Karlsson Co-authored-by: Stefan Sarne Co-authored-by: Jesper Wilhelmsson Co-authored-by: Erik Helin Co-authored-by: Alexandre Iline Co-authored-by: Erik Joelsson Reviewed-by: jwilhelm, erikj --- hotspot/make/lib/CompileGtest.gmk | 116 ++++++++++ hotspot/make/lib/CompileLibraries.gmk | 4 + hotspot/make/lib/JvmMapfile.gmk | 33 ++- hotspot/make/test/GtestImage.gmk | 67 ++++++ hotspot/test/Makefile | 19 ++ hotspot/test/native/gtestLauncher.cpp | 34 +++ hotspot/test/native/gtestMain.cpp | 203 ++++++++++++++++++ hotspot/test/native/runtime/test_os.cpp | 45 ++++ hotspot/test/native/unittest.hpp | 104 +++++++++ .../test/native/utilities/test_quicksort.cpp | 47 ++++ 10 files changed, 662 insertions(+), 10 deletions(-) create mode 100644 hotspot/make/lib/CompileGtest.gmk create mode 100644 hotspot/make/test/GtestImage.gmk create mode 100644 hotspot/test/native/gtestLauncher.cpp create mode 100644 hotspot/test/native/gtestMain.cpp create mode 100644 hotspot/test/native/runtime/test_os.cpp create mode 100644 hotspot/test/native/unittest.hpp create mode 100644 hotspot/test/native/utilities/test_quicksort.cpp diff --git a/hotspot/make/lib/CompileGtest.gmk b/hotspot/make/lib/CompileGtest.gmk new file mode 100644 index 00000000000..9cf1d891255 --- /dev/null +++ b/hotspot/make/lib/CompileGtest.gmk @@ -0,0 +1,116 @@ +# +# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +GTEST_TEST_SRC := $(HOTSPOT_TOPDIR)/test/native +GTEST_FRAMEWORK_SRC := $(SRC_ROOT)/test/fmw/gtest + +# On Windows, there are no internal debug symbols so must set copying to true +# to get any at all. +ifeq ($(OPENJDK_TARGET_OS), windows) + GTEST_COPY_DEBUG_SYMBOLS := true +else + GTEST_COPY_DEBUG_SYMBOLS := false +endif + +################################################################################ + +GTEST_TEST_SRC_FILES := $(shell $(FIND) $(HOTSPOT_TOPDIR)/test/native -name \ + "test*.cpp" -type f) + +ifeq ($(OPENJDK_TARGET_OS), windows) + GTEST_JVM_MAPFILE := $(JVM_MAPFILE) +else + GTEST_JVM_MAPFILE := $(JVM_OUTPUTDIR)/gtest/mapfile + + $(JVM_OUTPUTDIR)/gtest/symbols: $(JVM_OUTPUTDIR)/symbols + $(call MakeDir, $(@D)) + ( $(CAT) $< ; echo "runUnitTests" ) > $@ + + $(GTEST_JVM_MAPFILE): $(JVM_OUTPUTDIR)/gtest/symbols + $(call create-mapfile) +endif + +# Disabling switch warning for clang because of test source. + +$(eval $(call SetupNativeCompilation, BUILD_GTEST_LIBJVM, \ + TOOLCHAIN := $(JVM_TOOLCHAIN), \ + LIBRARY := jvm, \ + OUTPUT_DIR := $(JVM_OUTPUTDIR)/gtest, \ + EXTRA_FILES := $(GTEST_TEST_SRC_FILES) \ + $(GTEST_FRAMEWORK_SRC)/src/gtest-all.cc \ + $(GTEST_TEST_SRC)/gtestMain.cpp, \ + OBJECT_DIR := $(JVM_OUTPUTDIR)/gtest/objs, \ + EXTRA_OBJECT_FILES := $(filter-out %/operator_new$(OBJ_SUFFIX), \ + $(BUILD_LIBJVM_ALL_OBJS)), \ + CFLAGS := $(JVM_CFLAGS) -I$(GTEST_FRAMEWORK_SRC) \ + -I$(GTEST_FRAMEWORK_SRC)/include \ + -I$(GTEST_TEST_SRC), \ + CFLAGS_windows := /EHsc, \ + CFLAGS_solaris := -DGTEST_HAS_EXCEPTIONS=0 -library=stlport4, \ + CFLAGS_macosx := -DGTEST_OS_MAC=1, \ + CFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \ + CXXFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \ + DISABLED_WARNINGS_gcc := undef, \ + DISABLED_WARNINGS_clang := undef switch format-nonliteral \ + tautological-undefined-compare, \ + DISABLED_WARNINGS_solstudio := identexpected, \ + LDFLAGS := $(JVM_LDFLAGS), \ + LDFLAGS_solaris := -library=stlport4 $(call SET_SHARED_LIBRARY_ORIGIN), \ + LIBS := $(JVM_LIBS), \ + OPTIMIZATION := $(JVM_OPTIMIZATION), \ + MAPFILE := $(GTEST_JVM_MAPFILE), \ + USE_MAPFILE_FOR_SYMBOLS := true, \ + COPY_DEBUG_SYMBOLS := $(GTEST_COPY_DEBUG_SYMBOLS), \ + ZIP_EXTERNAL_DEBUG_SYMBOLS := false, \ +)) + +TARGETS += $(BUILD_GTEST_LIBJVM) + +################################################################################ + +$(eval $(call SetupNativeCompilation, BUILD_GTEST_LAUNCHER, \ + TOOLCHAIN := $(JVM_TOOLCHAIN), \ + PROGRAM := gtestLauncher, \ + OUTPUT_DIR := $(JVM_OUTPUTDIR)/gtest, \ + EXTRA_FILES := $(GTEST_TEST_SRC)/gtestLauncher.cpp, \ + OBJECT_DIR := $(JVM_OUTPUTDIR)/gtest/launcher-objs, \ + CFLAGS := $(JVM_CFLAGS) -I$(GTEST_FRAMEWORK_SRC) \ + -I$(GTEST_FRAMEWORK_SRC)/include, \ + CFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \ + CXXFLAGS_DEBUG_SYMBOLS := $(JVM_CFLAGS_SYMBOLS), \ + LDFLAGS := $(LDFLAGS_TESTEXE), \ + LDFLAGS_unix := -L$(JVM_OUTPUTDIR)/gtest $(call SET_SHARED_LIBRARY_ORIGIN), \ + LDFLAGS_solaris := -library=stlport4, \ + LIBS_unix := -ljvm, \ + LIBS_windows := $(JVM_OUTPUTDIR)/gtest/objs/jvm.lib, \ + COPY_DEBUG_SYMBOLS := $(GTEST_COPY_DEBUG_SYMBOLS), \ + ZIP_EXTERNAL_DEBUG_SYMBOLS := false, \ +)) + +$(BUILD_GTEST_LAUNCHER): $(BUILD_GTEST_LIBJVM) + +TARGETS += $(BUILD_GTEST_LAUNCHER) + +################################################################################ diff --git a/hotspot/make/lib/CompileLibraries.gmk b/hotspot/make/lib/CompileLibraries.gmk index 7a7a1651194..d7e39e7f7b0 100644 --- a/hotspot/make/lib/CompileLibraries.gmk +++ b/hotspot/make/lib/CompileLibraries.gmk @@ -37,6 +37,10 @@ include lib/CompileDtracePreJvm.gmk include lib/CompileJvm.gmk include lib/CompileDtracePostJvm.gmk +ifeq ($(BUILD_GTEST), true) + include lib/CompileGtest.gmk +endif + all: $(TARGETS) .PHONY: all diff --git a/hotspot/make/lib/JvmMapfile.gmk b/hotspot/make/lib/JvmMapfile.gmk index 4ad3e99512b..9f9c928d8f5 100644 --- a/hotspot/make/lib/JvmMapfile.gmk +++ b/hotspot/make/lib/JvmMapfile.gmk @@ -153,20 +153,33 @@ $(JVM_OUTPUTDIR)/symbols: $(SYMBOLS_SRC) ################################################################################ # Finally convert the symbol list into a platform-specific mapfile -$(JVM_MAPFILE): $(JVM_OUTPUTDIR)/symbols - $(call LogInfo, Creating mapfile) - $(RM) $@ - ifeq ($(OPENJDK_TARGET_OS), macosx) - # On macosx, we need to add a leading underscore +ifeq ($(OPENJDK_TARGET_OS), macosx) + # On macosx, we need to add a leading underscore + define create-mapfile-work $(AWK) '{ if ($$0 ~ ".") { print " _" $$0 } }' < $^ > $@.tmp - else ifeq ($(OPENJDK_TARGET_OS), windows) - # On windows, add an 'EXPORTS' header + endef +else ifeq ($(OPENJDK_TARGET_OS), windows) + # On windows, add an 'EXPORTS' header + define create-mapfile-work $(ECHO) "EXPORTS" > $@.tmp $(AWK) '{ if ($$0 ~ ".") { print " " $$0 } }' < $^ >> $@.tmp - else - # Assume standard linker script + endef +else + # Assume standard linker script + define create-mapfile-work $(PRINTF) "SUNWprivate_1.1 { \n global: \n" > $@.tmp $(AWK) '{ if ($$0 ~ ".") { print " " $$0 ";" } }' < $^ >> $@.tmp $(PRINTF) " local: \n *; \n }; \n" >> $@.tmp - endif + endef +endif + +define create-mapfile + $(call LogInfo, Creating mapfile) + $(call MakeDir, $(@D)) + $(call create-mapfile-work) + $(RM) $@ $(MV) $@.tmp $@ +endef + +$(JVM_MAPFILE): $(JVM_OUTPUTDIR)/symbols + $(call create-mapfile) diff --git a/hotspot/make/test/GtestImage.gmk b/hotspot/make/test/GtestImage.gmk new file mode 100644 index 00000000000..f24b1a73fcd --- /dev/null +++ b/hotspot/make/test/GtestImage.gmk @@ -0,0 +1,67 @@ +# +# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +default: all + +include $(SPEC) +include MakeBase.gmk + +$(foreach v, $(JVM_VARIANTS), \ + $(eval $(call SetupCopyFiles, COPY_GTEST_$v, \ + SRC := $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/gtest, \ + DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ + FILES := $(call SHARED_LIBRARY,jvm) gtestLauncher$(EXE_SUFFIX), \ + )) \ + $(eval TARGETS += $$(COPY_GTEST_$v)) \ +) + +ifeq ($(OPENJDK_TARGET_OS), windows) + $(foreach v, $(JVM_VARIANTS), \ + $(eval $(call SetupCopyFiles, COPY_GTEST_MSVCR_$v, \ + DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ + FILES := $(MSVCR_DLL) $(MSVCP_DLL), \ + FLATTEN := true, \ + )) \ + $(eval TARGETS += $$(COPY_GTEST_MSVCR_$v)) \ + $(eval $(call SetupCopyFiles, COPY_GTEST_PDB_$v, \ + SRC := $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/gtest, \ + DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ + FILES := jvm.pdb gtestLauncher.pdb, \ + )) \ + $(eval TARGETS += $$(COPY_GTEST_PDB_$v)) \ + ) +endif + +ifeq ($(OPENJDK_TARGET_OS), solaris) + $(foreach v, $(JVM_VARIANTS), \ + $(eval $(call SetupCopyFiles, COPY_GTEST_STLPORT_$v, \ + DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \ + FILES := $(STLPORT_LIB), \ + )) \ + $(eval TARGETS += $$(COPY_GTEST_STLPORT_$v)) \ + ) +endif + +all: $(TARGETS) diff --git a/hotspot/test/Makefile b/hotspot/test/Makefile index 3468e65bcac..ea9c5a60e69 100644 --- a/hotspot/test/Makefile +++ b/hotspot/test/Makefile @@ -52,6 +52,11 @@ UNIQ = uniq WC = wc ZIP = zip +define NEWLINE + + +endef + # Get OS name from uname (Cygwin inexplicably adds _NT-5.1) UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_) ifeq ($(UNAME_S), SunOS) @@ -427,6 +432,20 @@ PHONY_LIST += hotspot_servertest servertest ################################################################ +# Run the native gtest tests from the test image + +hotspot_gtest: + $(foreach v, $(JVM_VARIANTS), \ + $(MAKE) hotspot_gtest$v $(NEWLINE) ) + +hotspot_gtestserver hotspot_gtestclient hotspot_gtestminimal: hotspot_gtest%: + $(TESTNATIVE_DIR)/hotspot/gtest/$*/gtestLauncher \ + -jdk $(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)") + +PHONY_LIST += hotspot_gtest hotspot_gtestserver hotspot_gtestclient \ + hotspot_gtestminimal + +################################################################ # Phony targets (e.g. these are not filenames) .PHONY: all clean prep $(PHONY_LIST) diff --git a/hotspot/test/native/gtestLauncher.cpp b/hotspot/test/native/gtestLauncher.cpp new file mode 100644 index 00000000000..d25a0f9b14f --- /dev/null +++ b/hotspot/test/native/gtestLauncher.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "prims/jni.h" + +extern "C" { + JNIIMPORT void JNICALL runUnitTests(int argv, char** argc); +} + +int main(int argc, char** argv) { + runUnitTests(argc, argv); + return 0; +} diff --git a/hotspot/test/native/gtestMain.cpp b/hotspot/test/native/gtestMain.cpp new file mode 100644 index 00000000000..3c48e80d752 --- /dev/null +++ b/hotspot/test/native/gtestMain.cpp @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include +#include +#include +#ifdef __APPLE__ +# include +#endif + +#include "prims/jni.h" +#include "unittest.hpp" + +extern "C" { + +static int init_jvm(int argc, char **argv, bool is_executing_death_test) { + // don't care about the program name + argc--; + argv++; + + int extra_jvm_args = is_executing_death_test ? 4 : 2; + int num_jvm_options = argc + extra_jvm_args; + + JavaVMOption* options = new JavaVMOption[num_jvm_options]; + options[0].optionString = (char*) "-Dsun.java.launcher.is_altjvm=true"; + options[1].optionString = (char*) "-XX:+ExecutingUnitTests"; + + if (is_executing_death_test) { + // don't create core files or hs_err files when executing death tests + options[2].optionString = (char*) "-XX:+SuppressFatalErrorMessage"; + options[3].optionString = (char*) "-XX:-CreateCoredumpOnCrash"; + } + + for (int i = 0; i < argc; i++) { + options[extra_jvm_args + i].optionString = argv[i]; + } + + JavaVMInitArgs args; + args.version = JNI_VERSION_1_8; + args.nOptions = num_jvm_options; + args.options = options; + + JavaVM* jvm; + JNIEnv* env; + + return JNI_CreateJavaVM(&jvm, (void**)&env, &args); +} + +class JVMInitializerListener : public ::testing::EmptyTestEventListener { + private: + int _argc; + char** _argv; + bool _is_initialized; + + void initialize_jvm() { + } + + public: + JVMInitializerListener(int argc, char** argv) : + _argc(argc), _argv(argv), _is_initialized(false) { + } + + virtual void OnTestStart(const ::testing::TestInfo& test_info) { + const char* name = test_info.name(); + if (strstr(name, "_test_vm") != NULL && !_is_initialized) { + ASSERT_EQ(init_jvm(_argc, _argv, false), 0) << "Could not initialize the JVM"; + _is_initialized = true; + } + } +}; + +static bool is_prefix(const char* prefix, const char* str) { + return strncmp(str, prefix, strlen(prefix)) == 0; +} + +static char* get_java_home_arg(int argc, char** argv) { + for (int i = 0; i < argc; i++) { + if (strncmp(argv[i], "-jdk", strlen(argv[i])) == 0) { + return argv[i+1]; + } + if (is_prefix("--jdk=", argv[i])) { + return argv[i] + strlen("--jdk="); + } + if (is_prefix("-jdk:", argv[i])) { + return argv[i] + strlen("-jdk:"); + } + } + return NULL; +} + +static int num_args_to_skip(char* arg) { + if (strcmp(arg, "-jdk") == 0) { + return 2; // skip the argument after -jdk as well + } + if (is_prefix("--jdk=", arg)) { + return 1; + } + if (is_prefix("-jdk:", arg)) { + return 1; + } + return 0; +} + +static char** remove_test_runner_arguments(int* argcp, char **argv) { + int argc = *argcp; + char** new_argv = (char**) malloc(sizeof(char*) * argc); + int new_argc = 0; + + int i = 0; + while (i < argc) { + int args_to_skip = num_args_to_skip(argv[i]); + if (args_to_skip == 0) { + new_argv[new_argc] = argv[i]; + i++; + new_argc++; + } else { + i += num_args_to_skip(argv[i]); + } + } + + *argcp = new_argc; + return new_argv; +} + +JNIEXPORT void JNICALL runUnitTests(int argc, char** argv) { + // Must look at googletest options before initializing googletest, since + // InitGoogleTest removes googletest options from argv. + bool is_executing_death_test = true; + for (int i = 0; i < argc; i++) { + const char* death_test_flag = "--gtest_internal_run_death_test"; + if (is_prefix(death_test_flag, argv[i])) { + is_executing_death_test = true; + } + } + + ::testing::InitGoogleTest(&argc, argv); + ::testing::GTEST_FLAG(death_test_style) = "threadsafe"; +// ::testing::GTEST_FLAG(death_test_output_prefix) = "Other VM"; + + char* java_home = get_java_home_arg(argc, argv); + if (java_home == NULL) { + fprintf(stderr, "ERROR: You must specify a JDK to use for running the unit tests.\n"); + exit(1); + } +#ifndef _WIN32 + int overwrite = 1; // overwrite an eventual existing value for JAVA_HOME + setenv("JAVA_HOME", java_home, overwrite); + +// workaround for JDK-7131356 +#ifdef __APPLE__ + size_t len = strlen(java_home) + strlen("/lib/jli/libjli.dylib") + 1; + char* path = new char[len]; + snprintf(path, len, "%s/lib/jli/libjli.dylib", java_home); + dlopen(path, RTLD_NOW | RTLD_GLOBAL); +#endif // __APPLE__ + +#else // _WIN32 + char* java_home_var = "_ALT_JAVA_HOME_DIR"; + size_t len = strlen(java_home) + strlen(java_home_var) + 2; + char * envString = new char[len]; + sprintf_s(envString, len, "%s=%s", java_home_var, java_home); + _putenv(envString); +#endif // _WIN32 + argv = remove_test_runner_arguments(&argc, argv); + + if (is_executing_death_test) { + if (init_jvm(argc, argv, true) != 0) { + abort(); + } + } else { + ::testing::TestEventListeners& listeners = ::testing::UnitTest::GetInstance()->listeners(); + listeners.Append(new JVMInitializerListener(argc, argv)); + } + + int result = RUN_ALL_TESTS(); + if (result != 0) { + fprintf(stderr, "ERROR: RUN_ALL_TESTS() failed. Error %d\n", result); + exit(2); + } +} + +} // extern "C" diff --git a/hotspot/test/native/runtime/test_os.cpp b/hotspot/test/native/runtime/test_os.cpp new file mode 100644 index 00000000000..734668501fb --- /dev/null +++ b/hotspot/test/native/runtime/test_os.cpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "runtime/os.hpp" +#include "unittest.hpp" + +TEST_VM(os, page_size_for_region) { + size_t large_page_example = 4 * M; + size_t large_page = os::page_size_for_region_aligned(large_page_example, 1); + + size_t small_page = os::vm_page_size(); + if (large_page > small_page) { + size_t num_small_in_large = large_page / small_page; + size_t page = os::page_size_for_region_aligned(large_page, num_small_in_large); + ASSERT_EQ(page, small_page) << "Did not get a small page"; + } +} + +#ifdef ASSERT +TEST_VM_ASSERT_MSG(os, page_size_for_region_with_zero_min_pages, "sanity") { + size_t region_size = 16 * os::vm_page_size(); + os::page_size_for_region_aligned(region_size, 0); // should assert +} +#endif diff --git a/hotspot/test/native/unittest.hpp b/hotspot/test/native/unittest.hpp new file mode 100644 index 00000000000..5f3f28eeecf --- /dev/null +++ b/hotspot/test/native/unittest.hpp @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include +#include + +#define GTEST_DONT_DEFINE_TEST 1 +#include "gtest/gtest.h" +#ifdef assert + #undef assert +#endif + +#define CONCAT(a, b) a ## b + +#define TEST(category, name) GTEST_TEST(category, CONCAT(name, _test)) + +#define TEST_VM(category, name) GTEST_TEST(category, CONCAT(name, _test_vm)) + +#define TEST_VM_F(test_fixture, name) \ + GTEST_TEST_(test_fixture, name ## _test_vm, test_fixture, \ + ::testing::internal::GetTypeId()) + +#define TEST_OTHER_VM(category, name) \ + static void test_ ## category ## _ ## name ## _(); \ + \ + static void child_ ## category ## _ ## name ## _() { \ + ::testing::GTEST_FLAG(throw_on_failure) = true; \ + test_ ## category ## _ ## name ## _(); \ + fprintf(stderr, "OKIDOKI"); \ + exit(0); \ + } \ + \ + TEST(category, CONCAT(name, _other_vm)) { \ + ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \ + ::testing::ExitedWithCode(0), \ + ".*OKIDOKI.*"); \ + } \ + \ + void test_ ## category ## _ ## name ## _() + +#ifdef ASSERT +#define TEST_VM_ASSERT(category, name) \ + static void test_ ## category ## _ ## name ## _(); \ + \ + static void child_ ## category ## _ ## name ## _() { \ + ::testing::GTEST_FLAG(throw_on_failure) = true; \ + test_ ## category ## _ ## name ## _(); \ + exit(0); \ + } \ + \ + TEST(category, CONCAT(name, _vm_assert)) { \ + ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \ + ::testing::ExitedWithCode(1), \ + "assert failed"); \ + } \ + \ + void test_ ## category ## _ ## name ## _() +#else +#define TEST_VM_ASSERT(...) \ + TEST_VM_ASSERT is only available in debug builds +#endif + +#ifdef ASSERT +#define TEST_VM_ASSERT_MSG(category, name, msg) \ + static void test_ ## category ## _ ## name ## _(); \ + \ + static void child_ ## category ## _ ## name ## _() { \ + ::testing::GTEST_FLAG(throw_on_failure) = true; \ + test_ ## category ## _ ## name ## _(); \ + exit(0); \ + } \ + \ + TEST(category, CONCAT(name, _vm_assert)) { \ + ASSERT_EXIT(child_ ## category ## _ ## name ## _(), \ + ::testing::ExitedWithCode(1), \ + "assert failed: " msg); \ + } \ + \ + void test_ ## category ## _ ## name ## _() +#else +#define TEST_VM_ASSERT_MSG(...) \ + TEST_VM_ASSERT_MSG is only available in debug builds +#endif diff --git a/hotspot/test/native/utilities/test_quicksort.cpp b/hotspot/test/native/utilities/test_quicksort.cpp new file mode 100644 index 00000000000..5a56c877786 --- /dev/null +++ b/hotspot/test/native/utilities/test_quicksort.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "prims/jvm.h" +#include "utilities/quickSort.hpp" +#include "unittest.hpp" + +static int int_comparator(int a, int b) { + if (a == b) { + return 0; + } else if (a < b) { + return -1; + } + + // a > b + return 1; +} + +TEST(utilities, quicksort) { + int test_array[] = {3,2,1}; + QuickSort::sort(test_array, 3, int_comparator, false); + + ASSERT_EQ(1, test_array[0]); + ASSERT_EQ(2, test_array[1]); + ASSERT_EQ(3, test_array[2]); +} -- GitLab From bb79607f67334ff220347af1f041620cebc0b50d Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Fri, 6 May 2016 17:51:11 +0300 Subject: [PATCH 311/400] 8132710: Add tests which check that Humongous objects behave as expected after Young GC 8132712: Add tests which check that Humongous objects behave as expected after Full GC Reviewed-by: jmasa, dfazunen --- .../humongousObjects/objectGraphTest/GC.java | 199 ++++++++++++++ .../objectGraphTest/GCTokens.java | 42 +++ .../objectGraphTest/ObjectGraph.java | 150 +++++++++++ .../humongousObjects/objectGraphTest/README | 56 ++++ .../objectGraphTest/ReferenceInfo.java | 63 +++++ .../TestObjectGraphAfterGC.java | 247 ++++++++++++++++++ .../objectGraphTest/TestcaseData.java | 207 +++++++++++++++ 7 files changed, 964 insertions(+) create mode 100644 hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java create mode 100644 hotspot/test/gc/g1/humongousObjects/objectGraphTest/GCTokens.java create mode 100644 hotspot/test/gc/g1/humongousObjects/objectGraphTest/ObjectGraph.java create mode 100644 hotspot/test/gc/g1/humongousObjects/objectGraphTest/README create mode 100644 hotspot/test/gc/g1/humongousObjects/objectGraphTest/ReferenceInfo.java create mode 100644 hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java create mode 100644 hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestcaseData.java diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java new file mode 100644 index 00000000000..17aa97413eb --- /dev/null +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GC.java @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package gc.g1.humongousObjects.objectGraphTest; + +import gc.testlibrary.Helpers; +import jdk.test.lib.Asserts; +import sun.hotspot.WhiteBox; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Consumer; + +/** + * Provides methods to initiate GC of requested type and + * checks for states of humongous and non-humongous soft/weak externally + * referenced objects after GCs + */ +public enum GC { + + YOUNG_GC { + @Override + public Runnable get() { + return WHITE_BOX::youngGC; + } + + public Consumer> getChecker() { + return getCheckerImpl(false, false, true, false); + } + + @Override + public List shouldContain() { + return Arrays.asList(GCTokens.WB_INITIATED_YOUNG_GC); + } + + @Override + public List shouldNotContain() { + return Arrays.asList(GCTokens.WB_INITIATED_MIXED_GC, GCTokens.FULL_GC, GCTokens.WB_INITIATED_CMC, + GCTokens.CMC, GCTokens.YOUNG_GC); + } + }, + FULL_GC { + @Override + public Runnable get() { + return System::gc; + } + + public Consumer> getChecker() { + return getCheckerImpl(true, false, true, false); + } + + @Override + public List shouldContain() { + return Arrays.asList(GCTokens.FULL_GC); + } + + @Override + public List shouldNotContain() { + return Arrays.asList(GCTokens.WB_INITIATED_YOUNG_GC, GCTokens.WB_INITIATED_MIXED_GC, + GCTokens.WB_INITIATED_CMC, GCTokens.CMC, GCTokens.YOUNG_GC); + } + }, + + FULL_GC_MEMORY_PRESSURE { + @Override + public Runnable get() { + return WHITE_BOX::fullGC; + } + + public Consumer> getChecker() { + return getCheckerImpl(true, true, true, true); + } + + @Override + public List shouldContain() { + return Arrays.asList(GCTokens.FULL_GC_MEMORY_PRESSURE); + } + + @Override + public List shouldNotContain() { + return Arrays.asList(GCTokens.WB_INITIATED_YOUNG_GC, GCTokens.WB_INITIATED_MIXED_GC, + GCTokens.WB_INITIATED_CMC, GCTokens.CMC, GCTokens.YOUNG_GC, GCTokens.FULL_GC); + } + }; + + protected String getErrorMessage(ReferenceInfo ref, boolean expectedNull, String gcType) { + return String.format("Externally effectively %s referenced %shumongous object was%s deleted after %s", + (ref.softlyReachable ? "soft" : "weak"), (ref.effectiveHumongous ? "" : "non-"), + (expectedNull ? " not" : ""), gcType); + } + + protected Consumer> getCaseCheck(boolean expectedNull) { + return expectedNull + ? r -> Asserts.assertNull(r.reference.get(), getErrorMessage(r, true, name())) + : r -> Asserts.assertNotNull(r.reference.get(), getErrorMessage(r, false, name())); + } + + protected Consumer> getCheckerImpl(boolean weakH, boolean softH, + boolean weakS, boolean softS) { + return new Checker(getCaseCheck(weakH), getCaseCheck(softH), getCaseCheck(weakS), getCaseCheck(softS)); + } + + protected String getGcLogName(String prefix) { + return prefix + "_" + name() + ".gc.log"; + } + + private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); + + /** + * @return method to initiate GC + */ + public abstract Runnable get(); + + /** + * @return checker for objects' states after GC + */ + public abstract Consumer> getChecker(); + + /** + * @return list of tokens that should be contained in gc log after gc of specified type + */ + public abstract List shouldContain(); + + /** + * @return list of tokens that should not be contained in gc log after gc of specified type + */ + public abstract List shouldNotContain(); + + + /** + * Checks object' state after gc + * Contains 4 Consumers which are called depending on humongous/non-humongous and + * external weak/soft referenced objects + */ + private static class Checker implements Consumer> { + // 4 consumers with checks for (humongous /simple objects)*(weak/soft referenced) + final Consumer> weakHumongousCheck; + final Consumer> softHumongousCheck; + final Consumer> weakSimpleCheck; + final Consumer> softSimpleCheck; + + public Checker(Consumer> weakHumongousCheck, + Consumer> softHumongousCheck, + Consumer> weakSimpleCheck, + Consumer> softSimpleCheck) { + this.weakHumongousCheck = weakHumongousCheck; + this.softHumongousCheck = softHumongousCheck; + this.weakSimpleCheck = weakSimpleCheck; + this.softSimpleCheck = softSimpleCheck; + } + + public void accept(ReferenceInfo ref) { + + System.out.println("reference.get() returned " + ref.reference.get()); + if (ref.effectiveHumongous && ref.softlyReachable) { + System.out.println("soft and humongous"); + softHumongousCheck.accept(ref); + } + + if (ref.effectiveHumongous && !ref.softlyReachable) { + System.out.println("weak and humongous"); + weakHumongousCheck.accept(ref); + + } + + if (!ref.effectiveHumongous && ref.softlyReachable) { + System.out.println("soft and non-humongous"); + softSimpleCheck.accept(ref); + } + + if (!ref.effectiveHumongous && !ref.softlyReachable) { + System.out.println("weak and non-humongous"); + weakSimpleCheck.accept(ref); + } + } + } + +} diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GCTokens.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GCTokens.java new file mode 100644 index 00000000000..e8a52001d65 --- /dev/null +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/GCTokens.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package gc.g1.humongousObjects.objectGraphTest; + +/** + * Contains tokens that could appear in gc log + */ +public final class GCTokens { + // Private c-tor to prevent instantiating + private GCTokens() { + } + + public static final String WB_INITIATED_YOUNG_GC = "Young (WhiteBox Initiated Young GC)"; + public static final String WB_INITIATED_MIXED_GC = "Pause Mixed (WhiteBox Initiated Young GC)"; + public static final String WB_INITIATED_CMC = "WhiteBox Initiated Concurrent Mark"; + public static final String FULL_GC = "Full (System.gc())"; + public static final String FULL_GC_MEMORY_PRESSURE = "WhiteBox Initiated Full GC"; + public static final String CMC = "Concurrent Mark)"; + public static final String YOUNG_GC = "GC pause (young)"; +} diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ObjectGraph.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ObjectGraph.java new file mode 100644 index 00000000000..48ca3d3fdcc --- /dev/null +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ObjectGraph.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package gc.g1.humongousObjects.objectGraphTest; + +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Predicate; + +public class ObjectGraph { + + private ObjectGraph() { + } + + public enum ReferenceType { + NONE, + WEAK, + SOFT, + STRONG; + } + + /** + * Performs operation on all nodes that are reachable from initial ones + * + * @param nodes initial nodes + * @param operation operation + */ + public static void propagateTransitiveProperty(Set nodes, Consumer operation) { + Deque roots = new ArrayDeque<>(); + nodes.stream().forEach(roots::push); + ObjectGraph.enumerateAndMark(roots, operation); + } + + /** + * Connects graph's vertexes with single-directed (vertex -> neighbour) link + * + * @param vertex who is connected + * @param neighbour connected to whom + */ + private static void connectVertexes(Object[] vertex, Object[] neighbour) { + + // check if vertex array is full + if (vertex[vertex.length - 1] != null) { + throw new Error("Array is full and no connections could be added"); + } + int i = 0; + while (vertex[i] != null) { + ++i; + } + vertex[i] = neighbour; + } + + + /** + * Builds object graph using description from list of parsed nodes. Graph uses Object[] as nodes, first n elements + * of array are links to connected nodes, others are null. Then runs visitors on generated graph + * + * @param parsedNodes list of nodes' description + * @param visitors visitors that will visit each node of generated graph + * @param humongousAllocationSize size of humongous node + * @param simpleAllocationSize size of simple (non-humongous) node + * @return root reference to generated graph + */ + public static Object[] generateObjectNodes(List parsedNodes, + Map, + BiConsumer> visitors, + int humongousAllocationSize, int simpleAllocationSize) { + + Object[][] objectNodes = new Object[parsedNodes.size()][]; + + // Allocating nodes on Object[] + for (int i = 0; i < parsedNodes.size(); ++i) { + objectNodes[i] = new Object[(parsedNodes.get(i).isHumongous ? + humongousAllocationSize : simpleAllocationSize)]; + } + + // Connecting nodes on allocated on Object[] + for (int i = 0; i < parsedNodes.size(); ++i) { + for (int j = 0; j < parsedNodes.get(i).getConnectedTo().size(); ++j) { + connectVertexes(objectNodes[i], objectNodes[parsedNodes.get(i).getConnectedTo().get(j)]); + } + } + + // Calling visitors + visitors.entrySet() + .stream() + .forEach( + entry -> parsedNodes.stream() + .filter(parsedNode -> entry.getKey().test(parsedNode)) + .forEach(node -> entry.getValue().accept(node, objectNodes)) + ); + + return objectNodes[0]; + } + + /** + * Enumerates graph starting with provided vertexes. All vertexes that are reachable from the provided ones are + * marked + * + * @param markedParents provided vertexes + * @param markVertex lambda which marks vertexes + */ + public static void enumerateAndMark(Deque markedParents, + Consumer markVertex) { + Map isVisited = new HashMap<>(); + while (!markedParents.isEmpty()) { + Object[] vertex = markedParents.pop(); + if (vertex == null || isVisited.containsKey(vertex)) { + continue; + } + isVisited.put(vertex, true); + markVertex.accept(vertex); + + for (int i = 0; i < vertex.length; ++i) { + if (vertex[i] == null) { + break; + } + markedParents.add((Object[]) vertex[i]); + } + } + } + +} diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/README b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/README new file mode 100644 index 00000000000..1c3522e6ff3 --- /dev/null +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/README @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +The test checks that after different type of GC unreachable objects behave as expected: + +1. Young GC - weakly referenced non-humongous objects are collected, other objects are not collected. + +2. Full GC - weakly referenced non-humongous and humongous objects are collected, softly referenced non-humongous and + humongous objects are not collected. + +3. Full GC with memory pressure - weakly and softly referenced non-humongous and humongous objects are collected. + +The test gets gc type as a command line argument. +Then the test allocates object graph in heap (currently testing scenarios are pre-generated and stored in +TestcaseData.getPregeneratedTestcases()) with TestObjectGraphAfterGC::allocateObjectGraph. + +Since we are testing humongous objects we need pretty unusual nodes - arrays of Object. +We need this since only large enough array could be Humongous object (in fact class with huge amount of fields is +humongous too but it's for other tests). +ObjectGraph class generates object graph with Object[] nodes. It also provides a way to collect +information about each node using "visitor" pattern. + +Using visitors we build Set of ReferenceInfo instances which contains the following information: +reference - external weak/soft reference to graph's node +graphId and nodeId - graph's and node's ids - we need this for error handling +softlyReachable - is node effectively referenced by external soft reference. It could be when external +soft reference or when this node is reachable from node that exteranally referenced by soft reference +effectiveHumongous - if node behaves effectively humongous. It could be when node is humongous +or when this node is reachable from humongous node. + +When we leave TestObjectGraphAfterGC::allocateObjectGraph we make graph reachable only with references from Set of +ReferenceInfo instances. + +We run specified gc and check that each instance of ReferenceInfo set behaves as expected. +Then we check that gc log file contains expected tokens and doesn't contain tokens that it should not contain. diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ReferenceInfo.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ReferenceInfo.java new file mode 100644 index 00000000000..98e249a2c7b --- /dev/null +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/ReferenceInfo.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package gc.g1.humongousObjects.objectGraphTest; + +import java.lang.ref.Reference; + +/** + * Immutable structure that holds the following information about graph's node + * reference - weak/soft reference to graph's node + * graphId and nodeId - graph's and node's ids - we need this for error handling + * softlyReachable - is node effectively referenced by external soft reference. It could be when external + * soft reference or when this node is reachable from node that externally referenced by soft reference + * effectiveHumongous - if node behaves effectively humongous. It could be when node is humongous + * or when this node is reachable from humongous node. + * + * @param - actual type of node + */ +public class ReferenceInfo { + public final Reference reference; + public final String graphId; + public final String nodeId; + public final boolean softlyReachable; + public final boolean effectiveHumongous; + + public ReferenceInfo(Reference reference, String graphId, String nodeId, boolean softlyReachable, + boolean effectiveHumongous) { + this.reference = reference; + this.graphId = graphId; + this.nodeId = nodeId; + this.softlyReachable = softlyReachable; + this.effectiveHumongous = effectiveHumongous; + } + + @Override + public String toString() { + return String.format("Node %s is effectively %shumongous and effectively %ssoft referenced\n" + + "\tReference type is %s and it points to %s", nodeId, + (effectiveHumongous ? "" : "non-"), (softlyReachable ? "" : "non-"), + reference.getClass().getSimpleName(), reference.get()); + } +} diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java new file mode 100644 index 00000000000..ce834774333 --- /dev/null +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package gc.g1.humongousObjects.objectGraphTest; + +import jdk.test.lib.OutputAnalyzer; +import sun.hotspot.WhiteBox; + +import java.io.File; +import java.io.IOException; +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.SoftReference; +import java.lang.ref.WeakReference; +import java.nio.file.Files; +import java.util.Map; +import java.util.HashMap; +import java.util.List; +import java.util.HashSet; +import java.util.Set; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.stream.Collectors; + + +/** + * @test TestObjectGraphAfterGC + * @summary Checks that objects' graph behave as expected after gc + * @requires vm.gc=="G1" | vm.gc=="null" + * @requires vm.opt.ExplicitGCInvokesConcurrent != true + * @library /testlibrary /test/lib / + * @modules java.management java.base/jdk.internal.misc + * @build sun.hotspot.WhiteBox + * gc.testlibrary.Helpers + * gc.g1.humongousObjects.objectGraphTest.GCTokens + * gc.g1.humongousObjects.objectGraphTest.ReferenceInfo + * gc.g1.humongousObjects.objectGraphTest.GC + * gc.g1.humongousObjects.objectGraphTest.ObjectGraph + * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * + * @run main/othervm -Xms200M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -XX:G1HeapRegionSize=1M -Xlog:gc*=debug:file=TestObjectGraphAfterGC_YOUNG_GC.gc.log + * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC YOUNG_GC + * + * @run main/othervm -Xms200M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -XX:G1HeapRegionSize=1M -Xlog:gc=info:file=TestObjectGraphAfterGC_FULL_GC.gc.log + * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC FULL_GC + * + * @run main/othervm -Xms200M -XX:+UseG1GC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. + * -XX:G1HeapRegionSize=1M -Xlog:gc=info:file=TestObjectGraphAfterGC_FULL_GC_MEMORY_PRESSURE.gc.log + * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC FULL_GC_MEMORY_PRESSURE + * + */ + +/** + * Checks that objects' graph behave as expected after gc + * See README file for detailed info on test's logic + */ +public class TestObjectGraphAfterGC { + + private static final int simpleAllocationSize = 1024; + + /** + * Entry point + * + * @param args - first argument - gc name + */ + public static void main(String[] args) { + + if (args.length < 1) { + throw new Error("Expected gc name wasn't provided as command line argument"); + } + + GC gcType = GC.valueOf(args[0].toUpperCase()); + + System.out.println("Testing " + gcType.name()); + + TestcaseData.getPregeneratedTestcases().stream().forEach(testcase -> { + System.out.println("Testcase: " + testcase); + + try { + TestObjectGraphAfterGC.doTesting(testcase, gcType.get(), gcType.getChecker(), + gcType.getGcLogName(TestObjectGraphAfterGC.class.getSimpleName()), gcType.shouldContain(), + gcType.shouldNotContain()); + } catch (IOException e) { + throw new Error("Problems trying to find or open " + TestObjectGraphAfterGC.class.getSimpleName() + + ".gc.log", e); + } + System.out.println(" Passed"); + }); + } + + /** + * Implements testing with 3 methods - allocateObjectGraph, checkResults and checkGCLog + * + * @param testcaseData testcase in the following notation: + * H - humongous node + * S - non-humongous node + * s - external soft reference + * w - external weak reference + * Hs->Sw - 1st node is humongous, externally soft referenced and strong references to + * non-humongous node 2 which is externally weak referenced + * H->1 - humongous node connects to the first node of chain + * @param doGC method that initiates gc + * @param checker consumer that checks node's state after gc and throws Error if it's wrong + * @param gcLogName name of gc log + * @param shouldContain list of tokens that should be contained in gc log + * @param shouldNotContain list of tokens that should not be contained in gc log + * @throws IOException if there are some issues with gc log + */ + private static void doTesting(String testcaseData, Runnable doGC, Consumer> checker, + String gcLogName, List shouldContain, List shouldNotContain) + throws IOException { + Set> nodeData = allocateObjectGraph(testcaseData); + doGC.run(); + checkResults(nodeData, checker); + checkGCLog(gcLogName, shouldContain, shouldNotContain); + } + + /** + * Allocates a number of objects of humongous and regular size and links then with strong references. + * How many objects to create, their size and links between them is encoded in the given parameters. + * As the result an object graph will be created. + * For the testing purpose for each created object (a graph node) an extra ReferenceInfo object will be created. + * The ReferenceInfo instances will contain either weak or soft reference to the graph node. + * + * @param testcaseData testcase in the + *

        + * H - humongous node + * S - non-humongous node + * s - external soft reference + * w - external weak reference + * Hs->Sw - 1st node is humongous, externally soft referenced and strong references to + * non-humongous node 2 which is externally weak referenced + * H->1 - humongous node connects to the first node of chain + * @return set of ReferenceInfo objects containing weak/soft reference to the graph node and other data on how + * objects should behave after gc + */ + private static Set> allocateObjectGraph(String testcaseData) { + Map nodeIds = new HashMap<>(); + Set humongousNodes = new HashSet<>(); + Set externalSoftReferenced = new HashSet<>(); + Set externalWeakReferenced = new HashSet<>(); + + Map, BiConsumer> visitors + = new HashMap<>(); + + visitors.put((parsedNode -> true), + (parsedNode, objects) -> nodeIds.put(objects[Integer.valueOf(parsedNode.id)], parsedNode.id) + ); + + visitors.put((parsedNode -> parsedNode.isHumongous), + (parsedNode, objects) -> humongousNodes.add(objects[Integer.valueOf(parsedNode.id)]) + ); + + visitors.put(parsedNode -> parsedNode.getReferencesTypes().stream(). + anyMatch(referenceType -> referenceType == ObjectGraph.ReferenceType.SOFT), + (parsedNode, objects) -> externalSoftReferenced.add(objects[Integer.valueOf(parsedNode.id)]) + ); + + visitors.put(parsedNode -> parsedNode.getReferencesTypes().stream(). + anyMatch(referenceType -> referenceType == ObjectGraph.ReferenceType.WEAK), + (parsedNode, objects) -> externalWeakReferenced.add(objects[Integer.valueOf(parsedNode.id)]) + ); + + List internalParsedNodes = TestcaseData.parse(testcaseData); + + Object[] root = ObjectGraph.generateObjectNodes(internalParsedNodes, visitors, + WhiteBox.getWhiteBox().g1RegionSize(), simpleAllocationSize); + + ObjectGraph.propagateTransitiveProperty(humongousNodes, humongousNodes::add); + Set effectiveSoftReferenced = new HashSet<>(); + ObjectGraph.propagateTransitiveProperty(externalSoftReferenced, effectiveSoftReferenced::add); + + // Create external references + ReferenceQueue referenceQueue = new ReferenceQueue<>(); + Set> externalRefs = new HashSet<>(); + + externalWeakReferenced.stream() + .forEach(objects -> externalRefs.add(new WeakReference<>(objects, referenceQueue))); + externalSoftReferenced.stream() + .forEach(objects -> externalRefs.add(new SoftReference<>(objects, referenceQueue))); + + return externalRefs.stream() + .map(ref -> new ReferenceInfo<>(ref, testcaseData, nodeIds.get(ref.get()), + effectiveSoftReferenced.contains(ref.get()), humongousNodes.contains(ref.get()))) + .collect(Collectors.toSet()); + + } + + /** + * Checks that object' state after gc is as expected + * + * @param nodeData array with information about nodes + * @param checker consumer that checks node's state after gc and throws Error if it's wrong + */ + private static void checkResults(Set> nodeData, Consumer> checker) { + nodeData.stream().forEach(checker::accept); + } + + /** + * Checks that gc log contains what we expected and does not contain what we didn't expect + * + * @param gcLogName gc log name + * @param shouldContain list of tokens that should be contained in gc log + * @param shouldNotContain list of tokens that should not be contained in gc log + * @throws IOException if there are some issues with gc log + */ + private static void checkGCLog(String gcLogName, List shouldContain, List shouldNotContain) + throws IOException { + + if (gcLogName == null) { + return; + } + String gcLog = new String(Files.readAllBytes(new File(gcLogName).toPath())); + + OutputAnalyzer outputAnalyzer = new OutputAnalyzer(gcLog, ""); + + shouldContain.stream().forEach(outputAnalyzer::shouldContain); + shouldNotContain.stream().forEach(outputAnalyzer::shouldNotContain); + } + +} diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestcaseData.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestcaseData.java new file mode 100644 index 00000000000..022934683a6 --- /dev/null +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestcaseData.java @@ -0,0 +1,207 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package gc.g1.humongousObjects.objectGraphTest; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public final class TestcaseData { + /** + * Temporary node description used during parsing + */ + private static class InternalParsedNode { + public String id; + public final ArrayList connectedTo = new ArrayList<>(); + public final ArrayList connectedFrom = new ArrayList<>(); + public final List referencesTypes = new ArrayList<>(); + public boolean isHumongous; + } + + /** + * Immutable node description. + * Contains: + * Node id + * Humongous flag + * List of external references' types + * List of nodes connected to + */ + public static class FinalParsedNode { + public final String id; + public final boolean isHumongous; + private final List referencesTypes; + private final ArrayList connectedTo; + + + public FinalParsedNode(InternalParsedNode internalParsedNode) { + referencesTypes = internalParsedNode.referencesTypes; + connectedTo = internalParsedNode.connectedTo; + id = internalParsedNode.id; + isHumongous = internalParsedNode.isHumongous; + } + + public List getReferencesTypes() { + return Collections.unmodifiableList(referencesTypes); + } + + public List getConnectedTo() { + return Collections.unmodifiableList(connectedTo); + } + } + + /** + * @param testcaseDesc testcase in the following notation: + * H - humongous node + * S - non-humongous node + * s - external soft reference + * w - external weak reference + * Hs->Sw - 1st node is humongous, externally soft referenced and strong references to non-humongous node 2 which is + * externally weak referenced + * H->1 - humongous node connects to the first node of chain + * @return list of nodes description in FinalParsedNode structure + */ + public static List parse(String testcaseDesc) { + String[] nodes = testcaseDesc.split("-"); + List internalParsedNodeList = new ArrayList<>(); + + for (int i = 0; i < nodes.length; ++i) { + String node = nodes[i]; + InternalParsedNode nd; + if (node.contains("1")) { + nd = internalParsedNodeList.get(0); + + } else { + nd = new InternalParsedNode(); + internalParsedNodeList.add(nd); + nd.id = String.valueOf(i); + } + + if (node.startsWith(">")) { + nd.connectedFrom.add(i - 1); + } + if (node.endsWith("<")) { + nd.connectedFrom.add(i + 1); + } + if (node.contains("w")) { + nd.referencesTypes.add(ObjectGraph.ReferenceType.WEAK); + } + + if (node.contains("s")) { + nd.referencesTypes.add(ObjectGraph.ReferenceType.SOFT); + } + if (node.contains("H")) { + nd.isHumongous = true; + } + + if (node.contains("S")) { + nd.isHumongous = false; + } + } + + // we have connectedFrom but we need to get connectedTo + for (int i = 0; i < internalParsedNodeList.size(); ++i) { + for (Integer reference : internalParsedNodeList.get(i).connectedFrom) { + internalParsedNodeList.get(reference).connectedTo.add(i); + } + } + + List finalParsedNodes = internalParsedNodeList.stream().map(FinalParsedNode::new) + .collect(Collectors.toList()); + + return finalParsedNodes; + } + + /** + * @return List of pregenerated testing cases + */ + public static List getPregeneratedTestcases() { + return Arrays.asList( + "Hw", + "Sw", + "Sw->Hw", + "Hw->Sw", + "Sw<->Hw", + "Sw<->Sw", + "Hw->Sw->Sw", + "Hw->Sw->Sw", + "Sw->Hw->Sw", + "Hw->Sw->Sw->1", + "Sw->Hw->Sw->1", + "Sw->Hw->Hw->1", + "Sw<->Hw<->Hw->1", + "Sw<->Hw<->Sw->1", + "Sw->Hw<->Sw", + "Hs", + "Ss", + "Ss->Hs", + "Hs->Ss", + "Ss<->Hs", + "Ss<->Ss", + "Hs->Ss->Ss", + "Hs->Ss->Ss", + "Ss->Hs->Ss", + "Hs->Ss->Ss->1", + "Ss->Hs->Ss->1", + "Ss->Hs->Hs->1", + "Ss<->Hs<->Hs->1", + "Ss<->Hs<->Ss->1", + "Ss->Hs<->Ss", + "Ss->Hw", + "Sw->Hs", + "Hs->Sw", + "Hw->Ss", + "Ss<->Hw", + "Sw<->Hs", + "Ss<->Sw", + "Sw<->Ss", + "Hs->Sw->Sw", + "Hw->Ss->Sw", + "Hw->Sw->Ss", + "Ss->Hw->Sw", + "Sw->Hs->Sw", + "Sw->Hw->Ss", + "Hs->Sw->Sw->1", + "Hw->Ss->Sw->1", + "Hw->Sw->Ss->1", + "Ss->Hw->Sw->1", + "Ss->Hs->Sw->1", + "Sw->Hw->Ss->1", + "Ss->Hw->Hw->1", + "Sw->Hs->Hw->1", + "Sw->Hw->Hs->1", + "Ss<->Hw<->Hw->1", + "Sw<->Hs<->Hw->1", + "Sw<->Hw<->Hs->1", + "Ss<->Hw<->Sw->1", + "Sw<->Hs<->Sw->1", + "Sw<->Hw<->Ss->1", + "Ss->Hw<->Sw", + "Sw->Hs<->Sw", + "Sw->Hw<->Ss" + ); + } +} -- GitLab From ffc21de072e943fe40d059dd52877f63ce0cb0b6 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Fri, 6 May 2016 17:59:35 +0300 Subject: [PATCH 312/400] 8155965: Unsafe.weakCompareAndSetVolatile entry points and intrinsics Reviewed-by: psandoz, vlivanov --- hotspot/src/share/vm/classfile/vmSymbols.hpp | 6 ++++++ hotspot/src/share/vm/opto/library_call.cpp | 3 +++ .../unsafe/JdkInternalMiscUnsafeAccessTestInt.java | 12 ++++++++++++ .../unsafe/JdkInternalMiscUnsafeAccessTestLong.java | 12 ++++++++++++ .../JdkInternalMiscUnsafeAccessTestObject.java | 12 ++++++++++++ .../compiler/unsafe/SunMiscUnsafeAccessTestInt.java | 1 + .../compiler/unsafe/SunMiscUnsafeAccessTestLong.java | 1 + .../unsafe/SunMiscUnsafeAccessTestObject.java | 1 + .../compiler/unsafe/X-UnsafeAccessTest.java.template | 12 ++++++++++++ 9 files changed, 60 insertions(+) diff --git a/hotspot/src/share/vm/classfile/vmSymbols.hpp b/hotspot/src/share/vm/classfile/vmSymbols.hpp index bd708f1e8da..80cc8ffc0d9 100644 --- a/hotspot/src/share/vm/classfile/vmSymbols.hpp +++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp @@ -1298,12 +1298,15 @@ do_name(weakCompareAndSwapObject_name, "weakCompareAndSwapObject") \ do_name(weakCompareAndSwapObjectAcquire_name, "weakCompareAndSwapObjectAcquire") \ do_name(weakCompareAndSwapObjectRelease_name, "weakCompareAndSwapObjectRelease") \ + do_name(weakCompareAndSwapObjectVolatile_name, "weakCompareAndSwapObjectVolatile") \ do_name(weakCompareAndSwapLong_name, "weakCompareAndSwapLong") \ do_name(weakCompareAndSwapLongAcquire_name, "weakCompareAndSwapLongAcquire") \ do_name(weakCompareAndSwapLongRelease_name, "weakCompareAndSwapLongRelease") \ + do_name(weakCompareAndSwapLongVolatile_name, "weakCompareAndSwapLongVolatile") \ do_name(weakCompareAndSwapInt_name, "weakCompareAndSwapInt") \ do_name(weakCompareAndSwapIntAcquire_name, "weakCompareAndSwapIntAcquire") \ do_name(weakCompareAndSwapIntRelease_name, "weakCompareAndSwapIntRelease") \ + do_name(weakCompareAndSwapIntVolatile_name, "weakCompareAndSwapIntVolatile") \ \ do_intrinsic(_compareAndSwapObject, jdk_internal_misc_Unsafe, compareAndSwapObject_name, compareAndSwapObject_signature, F_RN) \ do_intrinsic(_compareAndExchangeObjectVolatile, jdk_internal_misc_Unsafe, compareAndExchangeObjectVolatile_name, compareAndExchangeObject_signature, F_RN) \ @@ -1321,12 +1324,15 @@ do_intrinsic(_weakCompareAndSwapObject, jdk_internal_misc_Unsafe, weakCompareAndSwapObject_name, compareAndSwapObject_signature, F_R) \ do_intrinsic(_weakCompareAndSwapObjectAcquire, jdk_internal_misc_Unsafe, weakCompareAndSwapObjectAcquire_name, compareAndSwapObject_signature, F_R) \ do_intrinsic(_weakCompareAndSwapObjectRelease, jdk_internal_misc_Unsafe, weakCompareAndSwapObjectRelease_name, compareAndSwapObject_signature, F_R) \ + do_intrinsic(_weakCompareAndSwapObjectVolatile, jdk_internal_misc_Unsafe, weakCompareAndSwapObjectVolatile_name, compareAndSwapObject_signature, F_R) \ do_intrinsic(_weakCompareAndSwapLong, jdk_internal_misc_Unsafe, weakCompareAndSwapLong_name, compareAndSwapLong_signature, F_R) \ do_intrinsic(_weakCompareAndSwapLongAcquire, jdk_internal_misc_Unsafe, weakCompareAndSwapLongAcquire_name, compareAndSwapLong_signature, F_R) \ do_intrinsic(_weakCompareAndSwapLongRelease, jdk_internal_misc_Unsafe, weakCompareAndSwapLongRelease_name, compareAndSwapLong_signature, F_R) \ + do_intrinsic(_weakCompareAndSwapLongVolatile, jdk_internal_misc_Unsafe, weakCompareAndSwapLongVolatile_name, compareAndSwapLong_signature, F_R) \ do_intrinsic(_weakCompareAndSwapInt, jdk_internal_misc_Unsafe, weakCompareAndSwapInt_name, compareAndSwapInt_signature, F_R) \ do_intrinsic(_weakCompareAndSwapIntAcquire, jdk_internal_misc_Unsafe, weakCompareAndSwapIntAcquire_name, compareAndSwapInt_signature, F_R) \ do_intrinsic(_weakCompareAndSwapIntRelease, jdk_internal_misc_Unsafe, weakCompareAndSwapIntRelease_name, compareAndSwapInt_signature, F_R) \ + do_intrinsic(_weakCompareAndSwapIntVolatile, jdk_internal_misc_Unsafe, weakCompareAndSwapIntVolatile_name, compareAndSwapInt_signature, F_R) \ \ do_intrinsic(_getAndAddInt, jdk_internal_misc_Unsafe, getAndAddInt_name, getAndAddInt_signature, F_R) \ do_name( getAndAddInt_name, "getAndAddInt") \ diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 06365f14579..a2d2283ddfd 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -670,12 +670,15 @@ bool LibraryCallKit::try_to_inline(int predicate) { case vmIntrinsics::_weakCompareAndSwapObject: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Relaxed); case vmIntrinsics::_weakCompareAndSwapObjectAcquire: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Acquire); case vmIntrinsics::_weakCompareAndSwapObjectRelease: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Release); + case vmIntrinsics::_weakCompareAndSwapObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_swap_weak, Volatile); case vmIntrinsics::_weakCompareAndSwapInt: return inline_unsafe_load_store(T_INT, LS_cmp_swap_weak, Relaxed); case vmIntrinsics::_weakCompareAndSwapIntAcquire: return inline_unsafe_load_store(T_INT, LS_cmp_swap_weak, Acquire); case vmIntrinsics::_weakCompareAndSwapIntRelease: return inline_unsafe_load_store(T_INT, LS_cmp_swap_weak, Release); + case vmIntrinsics::_weakCompareAndSwapIntVolatile: return inline_unsafe_load_store(T_INT, LS_cmp_swap_weak, Volatile); case vmIntrinsics::_weakCompareAndSwapLong: return inline_unsafe_load_store(T_LONG, LS_cmp_swap_weak, Relaxed); case vmIntrinsics::_weakCompareAndSwapLongAcquire: return inline_unsafe_load_store(T_LONG, LS_cmp_swap_weak, Acquire); case vmIntrinsics::_weakCompareAndSwapLongRelease: return inline_unsafe_load_store(T_LONG, LS_cmp_swap_weak, Release); + case vmIntrinsics::_weakCompareAndSwapLongVolatile: return inline_unsafe_load_store(T_LONG, LS_cmp_swap_weak, Volatile); case vmIntrinsics::_compareAndExchangeObjectVolatile: return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange, Volatile); case vmIntrinsics::_compareAndExchangeObjectAcquire: return inline_unsafe_load_store(T_OBJECT, LS_cmp_exchange, Acquire); diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java index b2555b06605..817e78da0bd 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestInt.java @@ -281,6 +281,18 @@ public class JdkInternalMiscUnsafeAccessTestInt { assertEquals(x, 2, "weakCompareAndSwapRelease int"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwapIntVolatile(base, offset, 2, 1); + } + assertEquals(success, true, "weakCompareAndSwapVolatile int"); + int x = UNSAFE.getInt(base, offset); + assertEquals(x, 1, "weakCompareAndSwapVolatile int"); + } + + UNSAFE.putInt(base, offset, 2); + // Compare set and get { int o = UNSAFE.getAndSetInt(base, offset, 1); diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java index 66608a2f2ad..d4b88370a65 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestLong.java @@ -281,6 +281,18 @@ public class JdkInternalMiscUnsafeAccessTestLong { assertEquals(x, 2L, "weakCompareAndSwapRelease long"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwapLongVolatile(base, offset, 2L, 1L); + } + assertEquals(success, true, "weakCompareAndSwapVolatile long"); + long x = UNSAFE.getLong(base, offset); + assertEquals(x, 1L, "weakCompareAndSwapVolatile long"); + } + + UNSAFE.putLong(base, offset, 2L); + // Compare set and get { long o = UNSAFE.getAndSetLong(base, offset, 1L); diff --git a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java index a667431f027..7fc59cd929c 100644 --- a/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java +++ b/hotspot/test/compiler/unsafe/JdkInternalMiscUnsafeAccessTestObject.java @@ -234,6 +234,18 @@ public class JdkInternalMiscUnsafeAccessTestObject { assertEquals(x, "bar", "weakCompareAndSwapRelease Object"); } + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwapObjectVolatile(base, offset, "bar", "foo"); + } + assertEquals(success, true, "weakCompareAndSwapVolatile Object"); + Object x = UNSAFE.getObject(base, offset); + assertEquals(x, "foo", "weakCompareAndSwapVolatile Object"); + } + + UNSAFE.putObject(base, offset, "bar"); + // Compare set and get { Object o = UNSAFE.getAndSetObject(base, offset, "foo"); diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java index 45cb6ffbd3d..4310a6e49ec 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestInt.java @@ -183,6 +183,7 @@ public class SunMiscUnsafeAccessTestInt { assertEquals(x, 2, "failing compareAndSwap int value"); } + UNSAFE.putInt(base, offset, 2); // Compare set and get { diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java index de0ddf5d301..6dd6434c774 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestLong.java @@ -183,6 +183,7 @@ public class SunMiscUnsafeAccessTestLong { assertEquals(x, 2L, "failing compareAndSwap long value"); } + UNSAFE.putLong(base, offset, 2L); // Compare set and get { diff --git a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java index a4d2aba6699..b56cc413504 100644 --- a/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java +++ b/hotspot/test/compiler/unsafe/SunMiscUnsafeAccessTestObject.java @@ -154,6 +154,7 @@ public class SunMiscUnsafeAccessTestObject { assertEquals(x, "bar", "failing compareAndSwap Object value"); } + UNSAFE.putObject(base, offset, "bar"); // Compare set and get { diff --git a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template index 0af2e805b36..19c3bfa7ef0 100644 --- a/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template +++ b/hotspot/test/compiler/unsafe/X-UnsafeAccessTest.java.template @@ -302,7 +302,19 @@ public class $Qualifier$UnsafeAccessTest$Type$ { $type$ x = UNSAFE.get$Type$(base, offset); assertEquals(x, $value2$, "weakCompareAndSwapRelease $type$"); } + + { + boolean success = false; + for (int c = 0; c < WEAK_ATTEMPTS && !success; c++) { + success = UNSAFE.weakCompareAndSwap$Type$Volatile(base, offset, $value2$, $value1$); + } + assertEquals(success, true, "weakCompareAndSwapVolatile $type$"); + $type$ x = UNSAFE.get$Type$(base, offset); + assertEquals(x, $value1$, "weakCompareAndSwapVolatile $type$"); + } + #end[JdkInternalMisc] + UNSAFE.put$Type$(base, offset, $value2$); // Compare set and get { -- GitLab From 01fcb7adcff38b1b26a96f9dc8f5cb87dcfb36ed Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Mon, 9 May 2016 13:22:39 +0200 Subject: [PATCH 313/400] 8156018: Hotspot visual studio project generation broken Reviewed-by: mgronlun, ctornqvi --- .../tools/projectcreator}/ArgsParser.java | 4 +- .../tools/projectcreator}/BuildConfig.java | 35 +++++++++------- .../projectcreator}/FileTreeCreator.java | 26 ++++++++++++ .../projectcreator}/FileTreeCreatorVC10.java | 4 +- .../tools/projectcreator}/ProjectCreator.java | 4 +- .../build/tools/projectcreator}/Util.java | 4 +- .../projectcreator}/WinGammaPlatform.java | 20 ++++++--- .../projectcreator}/WinGammaPlatformVC10.java | 41 ++++++++----------- 8 files changed, 92 insertions(+), 46 deletions(-) rename hotspot/{src/share/tools/ProjectCreator => make/src/classes/build/tools/projectcreator}/ArgsParser.java (96%) rename hotspot/{src/share/tools/ProjectCreator => make/src/classes/build/tools/projectcreator}/BuildConfig.java (94%) rename hotspot/{src/share/tools/ProjectCreator => make/src/classes/build/tools/projectcreator}/FileTreeCreator.java (66%) rename hotspot/{src/share/tools/ProjectCreator => make/src/classes/build/tools/projectcreator}/FileTreeCreatorVC10.java (98%) rename hotspot/{src/share/tools/ProjectCreator => make/src/classes/build/tools/projectcreator}/ProjectCreator.java (98%) rename hotspot/{src/share/tools/ProjectCreator => make/src/classes/build/tools/projectcreator}/Util.java (96%) rename hotspot/{src/share/tools/ProjectCreator => make/src/classes/build/tools/projectcreator}/WinGammaPlatform.java (98%) rename hotspot/{src/share/tools/ProjectCreator => make/src/classes/build/tools/projectcreator}/WinGammaPlatformVC10.java (91%) diff --git a/hotspot/src/share/tools/ProjectCreator/ArgsParser.java b/hotspot/make/src/classes/build/tools/projectcreator/ArgsParser.java similarity index 96% rename from hotspot/src/share/tools/ProjectCreator/ArgsParser.java rename to hotspot/make/src/classes/build/tools/projectcreator/ArgsParser.java index ca5d0a337f1..97dff3e460d 100644 --- a/hotspot/src/share/tools/ProjectCreator/ArgsParser.java +++ b/hotspot/make/src/classes/build/tools/projectcreator/ArgsParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,8 @@ * */ +package build.tools.projectcreator; + class ArgIterator { String[] args; int i; diff --git a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java b/hotspot/make/src/classes/build/tools/projectcreator/BuildConfig.java similarity index 94% rename from hotspot/src/share/tools/ProjectCreator/BuildConfig.java rename to hotspot/make/src/classes/build/tools/projectcreator/BuildConfig.java index 0ce7ecf039e..81e555233e2 100644 --- a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java +++ b/hotspot/make/src/classes/build/tools/projectcreator/BuildConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,8 @@ * */ +package build.tools.projectcreator; + import java.util.Enumeration; import java.util.Hashtable; import java.util.Vector; @@ -37,7 +39,7 @@ class BuildConfig { if (ci == null) { String comp = (String)getField(null, "CompilerVersion"); try { - ci = (CompilerInterface)Class.forName("CompilerInterface" + comp).newInstance(); + ci = (CompilerInterface)Class.forName("build.tools.projectcreator.CompilerInterface" + comp).newInstance(); } catch (Exception cnfe) { System.err.println("Cannot find support for compiler " + comp); throw new RuntimeException(cnfe.toString()); @@ -66,6 +68,8 @@ class BuildConfig { String buildSpace = getFieldString(null, "BuildSpace"); String outDir = buildBase; String jdkTargetRoot = getFieldString(null, "JdkTargetRoot"); + String makeBinary = getFieldString(null, "MakeBinary"); + String makeOutput = expandFormat(getFieldString(null, "MakeOutput")); put("Id", flavourBuild); put("OutputDir", outDir); @@ -74,6 +78,8 @@ class BuildConfig { put("BuildSpace", buildSpace); put("OutputDll", outDir + Util.sep + outDll); put("JdkTargetRoot", jdkTargetRoot); + put("MakeBinary", makeBinary); + put("MakeOutput", makeOutput); context = new String [] {flavourBuild, flavour, build, null}; } @@ -148,9 +154,11 @@ class BuildConfig { String relativeAltSrcInclude = getFieldString(null, "RelativeAltSrcInclude"); Vector v = getFieldVector(null, "AltRelativeInclude"); - for (String pathPart : v) { - if (path.contains(relativeAltSrcInclude + Util.sep + pathPart)) { - return true; + if (v != null) { + for (String pathPart : v) { + if (path.contains(relativeAltSrcInclude + Util.sep + pathPart)) { + return true; + } } } return false; @@ -360,8 +368,7 @@ class BuildConfig { static boolean appliesToTieredBuild(String cfg) { return (cfg != null && - (cfg.startsWith("compiler1") || - cfg.startsWith("compiler2"))); + cfg.startsWith("server")); } // Filters out the IgnoreFile and IgnorePaths since they are @@ -372,7 +379,7 @@ class BuildConfig { static String getTieredBuildCfg(String cfg) { assert appliesToTieredBuild(cfg) : "illegal configuration " + cfg; - return "tiered" + cfg.substring(9); + return "server"; } static Object getField(String cfg, String field) { @@ -524,7 +531,7 @@ class C1DebugConfig extends GenericDebugNonKernelConfig { } C1DebugConfig() { - initNames("compiler1", "debug", "jvm.dll"); + initNames("client", "debug", "jvm.dll"); init(getIncludes(), getDefines()); } } @@ -535,7 +542,7 @@ class C1FastDebugConfig extends GenericDebugNonKernelConfig { } C1FastDebugConfig() { - initNames("compiler1", "fastdebug", "jvm.dll"); + initNames("client", "fastdebug", "jvm.dll"); init(getIncludes(), getDefines()); } } @@ -546,7 +553,7 @@ class TieredDebugConfig extends GenericDebugNonKernelConfig { } TieredDebugConfig() { - initNames("tiered", "debug", "jvm.dll"); + initNames("server", "debug", "jvm.dll"); init(getIncludes(), getDefines()); } } @@ -557,7 +564,7 @@ class TieredFastDebugConfig extends GenericDebugNonKernelConfig { } TieredFastDebugConfig() { - initNames("tiered", "fastdebug", "jvm.dll"); + initNames("server", "fastdebug", "jvm.dll"); init(getIncludes(), getDefines()); } } @@ -576,14 +583,14 @@ abstract class ProductConfig extends BuildConfig { class C1ProductConfig extends ProductConfig { C1ProductConfig() { - initNames("compiler1", "product", "jvm.dll"); + initNames("client", "product", "jvm.dll"); init(getIncludes(), getDefines()); } } class TieredProductConfig extends ProductConfig { TieredProductConfig() { - initNames("tiered", "product", "jvm.dll"); + initNames("server", "product", "jvm.dll"); init(getIncludes(), getDefines()); } } diff --git a/hotspot/src/share/tools/ProjectCreator/FileTreeCreator.java b/hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreator.java similarity index 66% rename from hotspot/src/share/tools/ProjectCreator/FileTreeCreator.java rename to hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreator.java index a81132c7029..385903e676f 100644 --- a/hotspot/src/share/tools/ProjectCreator/FileTreeCreator.java +++ b/hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreator.java @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package build.tools.projectcreator; + import java.nio.file.FileSystems; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; diff --git a/hotspot/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java b/hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreatorVC10.java similarity index 98% rename from hotspot/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java rename to hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreatorVC10.java index cb0fe33577e..fb7a77f7256 100644 --- a/hotspot/src/share/tools/ProjectCreator/FileTreeCreatorVC10.java +++ b/hotspot/make/src/classes/build/tools/projectcreator/FileTreeCreatorVC10.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,8 @@ * */ +package build.tools.projectcreator; + import static java.nio.file.FileVisitResult.CONTINUE; import java.io.IOException; diff --git a/hotspot/src/share/tools/ProjectCreator/ProjectCreator.java b/hotspot/make/src/classes/build/tools/projectcreator/ProjectCreator.java similarity index 98% rename from hotspot/src/share/tools/ProjectCreator/ProjectCreator.java rename to hotspot/make/src/classes/build/tools/projectcreator/ProjectCreator.java index f1e16ea8a45..d5478230a42 100644 --- a/hotspot/src/share/tools/ProjectCreator/ProjectCreator.java +++ b/hotspot/make/src/classes/build/tools/projectcreator/ProjectCreator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,8 @@ * */ +package build.tools.projectcreator; + public class ProjectCreator { public static void usage() { diff --git a/hotspot/src/share/tools/ProjectCreator/Util.java b/hotspot/make/src/classes/build/tools/projectcreator/Util.java similarity index 96% rename from hotspot/src/share/tools/ProjectCreator/Util.java rename to hotspot/make/src/classes/build/tools/projectcreator/Util.java index ca830780048..9741c151dae 100644 --- a/hotspot/src/share/tools/ProjectCreator/Util.java +++ b/hotspot/make/src/classes/build/tools/projectcreator/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,8 @@ * */ +package build.tools.projectcreator; + import java.util.*; import java.io.File; diff --git a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java b/hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatform.java similarity index 98% rename from hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java rename to hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatform.java index a87d4471511..bc0cad7eb01 100644 --- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java +++ b/hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,8 @@ * */ +package build.tools.projectcreator; + import java.io.File; import java.io.IOException; import java.io.PrintWriter; @@ -317,6 +319,18 @@ public abstract class WinGammaPlatform { HsArgHandler.STRING ), + new HsArgRule("-makeBinary", + "MakeBinary", + null, + HsArgHandler.STRING + ), + + new HsArgRule("-makeOutput", + "MakeOutput", + null, + HsArgHandler.STRING + ), + new HsArgRule("-platformName", "PlatformName", null, @@ -554,10 +568,6 @@ public abstract class WinGammaPlatform { usage(); } - if (BuildConfig.getField(null, "UseToGeneratePch") == null) { - throw new RuntimeException("ERROR: need to specify one file to compute PCH, with -useToGeneratePch flag"); - } - BuildConfig.putField(null, "PlatformObject", this); } diff --git a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java b/hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java similarity index 91% rename from hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java rename to hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java index 3225f1e551d..d44fb04c588 100644 --- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC10.java +++ b/hotspot/make/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,8 @@ * */ +package build.tools.projectcreator; + import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -71,6 +73,7 @@ public class WinGammaPlatformVC10 extends WinGammaPlatform { startTag("PropertyGroup", "Label", "Globals"); tagData("ProjectGuid", "{8822CB5C-1C41-41C2-8493-9F6E1994338B}"); + tagData("Keyword", "MakeFileProj"); tag("SccProjectName"); tag("SccLocalPath"); endTag(); @@ -79,9 +82,8 @@ public class WinGammaPlatformVC10 extends WinGammaPlatform { for (BuildConfig cfg : allConfigs) { startTag(cfg, "PropertyGroup", "Label", "Configuration"); - tagData("ConfigurationType", "DynamicLibrary"); - tagData("UseOfMfc", "false"); - tagData("PlatformToolset", "v120"); + tagData("ConfigurationType", "Makefile"); + tagData("UseDebugLibraries", "true"); endTag(); } @@ -111,6 +113,14 @@ public class WinGammaPlatformVC10 extends WinGammaPlatform { tag(cfg, "CodeAnalysisRules"); tag(cfg, "CodeAnalysisRuleAssemblies"); } + for (BuildConfig cfg : allConfigs) { + tagData(cfg, "NMakeBuildCommandLine", cfg.get("MakeBinary") + " -f ../../Makefile import-hotspot LOG=info"); + tagData(cfg, "NMakeReBuildCommandLine", cfg.get("MakeBinary") + " -f ../../Makefile clean-hotspot import-hotspot LOG=info"); + tagData(cfg, "NMakeCleanCommandLine", cfg.get("MakeBinary") + " -f ../../Makefile clean-hotspot LOG=info"); + tagData(cfg, "NMakeOutput", cfg.get("MakeOutput") + Util.sep + "jvm.dll"); + tagData(cfg, "NMakePreprocessorDefinitions", Util.join(";", cfg.getDefines())); + tagData(cfg, "NMakeIncludeSearchPath", Util.join(";", cfg.getIncludes())); + } endTag(); for (BuildConfig cfg : allConfigs) { @@ -123,11 +133,6 @@ public class WinGammaPlatformVC10 extends WinGammaPlatform { tagV(cfg.getV("LinkerFlags")); endTag(); - startTag("PreLinkEvent"); - tagData("Message", BuildConfig.getFieldString(null, "PrelinkDescription")); - tagData("Command", cfg.expandFormat(BuildConfig.getFieldString(null, "PrelinkCommand").replace("\t", "\r\n"))); - endTag(); - endTag(); } @@ -162,18 +167,13 @@ public class WinGammaPlatformVC10 extends WinGammaPlatform { for (BuildConfig cfg : allConfigs) { startTag(cfg, "PropertyGroup"); tagData("LocalDebuggerCommand", cfg.get("JdkTargetRoot") + "\\bin\\java.exe"); - // The JVM loads some libraries using a path relative to - // itself because it expects to be in a JRE or a JDK. The java - // launcher's '-XXaltjvm=' option allows the JVM to be outside - // the JRE or JDK so '-Dsun.java.launcher.is_altjvm=true' - // forces a fake JAVA_HOME relative path to be used to - // find the other libraries. The '-XX:+PauseAtExit' option + // Since we run "make hotspot-import", we get the correct jvm.dll by java.exe. + // The '-XX:+PauseAtExit' option // causes the VM to wait for key press before exiting; this // allows any stdout or stderr messages to be seen before // the cmdtool exits. - tagData("LocalDebuggerCommandArguments", "-XXaltjvm=$(TargetDir) " - + "-Dsun.java.launcher.is_altjvm=true " - + "-XX:+UnlockDiagnosticVMOptions -XX:+PauseAtExit"); + tagData("LocalDebuggerCommandArguments", + "-XX:+UnlockDiagnosticVMOptions -XX:+PauseAtExit"); tagData("LocalDebuggerEnvironment", "JAVA_HOME=" + cfg.get("JdkTargetRoot")); endTag(); } @@ -209,11 +209,6 @@ public class WinGammaPlatformVC10 extends WinGammaPlatform { tagData("UniqueIdentifier", "{" + uuid.toString() + "}"); endTag(); } - startTag("Filter", "Include", "Resource Files"); - UUID uuid = UUID.randomUUID(); - tagData("UniqueIdentifier", "{" + uuid.toString() + "}"); - tagData("Extensions", "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"); - endTag(); endTag(); //TODO - do I need to split cpp and hpp files? -- GitLab From fbe14c52502359b7432f37c08130b62e6c57a1c0 Mon Sep 17 00:00:00 2001 From: Jon Masamitsu Date: Fri, 6 May 2016 14:35:59 -0700 Subject: [PATCH 314/400] 8155992: Change name of StealRegionCompactionTask to something that emphasizes the compaction task Reviewed-by: kbarrett, ehelin, drwhite --- hotspot/src/share/vm/gc/parallel/pcTasks.cpp | 6 +++--- hotspot/src/share/vm/gc/parallel/pcTasks.hpp | 8 ++++---- hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp | 2 +- hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/hotspot/src/share/vm/gc/parallel/pcTasks.cpp b/hotspot/src/share/vm/gc/parallel/pcTasks.cpp index df3d9a7f08d..05efac3e3b7 100644 --- a/hotspot/src/share/vm/gc/parallel/pcTasks.cpp +++ b/hotspot/src/share/vm/gc/parallel/pcTasks.cpp @@ -220,13 +220,13 @@ void StealMarkingTask::do_it(GCTaskManager* manager, uint which) { } // -// StealRegionCompactionTask +// CompactionWithStealingTask // -StealRegionCompactionTask::StealRegionCompactionTask(ParallelTaskTerminator* t): +CompactionWithStealingTask::CompactionWithStealingTask(ParallelTaskTerminator* t): _terminator(t) {} -void StealRegionCompactionTask::do_it(GCTaskManager* manager, uint which) { +void CompactionWithStealingTask::do_it(GCTaskManager* manager, uint which) { assert(ParallelScavengeHeap::heap()->is_gc_active(), "called outside gc"); ParCompactionManager* cm = diff --git a/hotspot/src/share/vm/gc/parallel/pcTasks.hpp b/hotspot/src/share/vm/gc/parallel/pcTasks.hpp index 6769f75a481..08bad720f3c 100644 --- a/hotspot/src/share/vm/gc/parallel/pcTasks.hpp +++ b/hotspot/src/share/vm/gc/parallel/pcTasks.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -195,16 +195,16 @@ class StealMarkingTask : public GCTask { }; // -// StealRegionCompactionTask +// CompactionWithStealingTask // // This task is used to distribute work to idle threads. // -class StealRegionCompactionTask : public GCTask { +class CompactionWithStealingTask : public GCTask { private: ParallelTaskTerminator* const _terminator; public: - StealRegionCompactionTask(ParallelTaskTerminator* t); + CompactionWithStealingTask(ParallelTaskTerminator* t); char* name() { return (char *)"steal-region-task"; } ParallelTaskTerminator* terminator() { return _terminator; } diff --git a/hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp b/hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp index 90819712d26..9eb8bceff57 100644 --- a/hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp +++ b/hotspot/src/share/vm/gc/parallel/psCompactionManager.hpp @@ -40,7 +40,7 @@ class ParCompactionManager : public CHeapObj { friend class ParallelTaskTerminator; friend class ParMarkBitMap; friend class PSParallelCompact; - friend class StealRegionCompactionTask; + friend class CompactionWithStealingTask; friend class UpdateAndFillClosure; friend class RefProcTaskExecutor; friend class IdleGCTask; diff --git a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp index 8f36021afc9..f7d1615c814 100644 --- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp @@ -2371,7 +2371,7 @@ void PSParallelCompact::enqueue_region_stealing_tasks( // Once a thread has drained it's stack, it should try to steal regions from // other threads. for (uint j = 0; j < parallel_gc_threads; j++) { - q->enqueue(new StealRegionCompactionTask(terminator_ptr)); + q->enqueue(new CompactionWithStealingTask(terminator_ptr)); } } -- GitLab From f2e1814b1a550f11028e696115492ddc056a1d02 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Sat, 7 May 2016 10:29:16 +0900 Subject: [PATCH 315/400] 8156033: jhsdb jmap cannot set heapdump name Reviewed-by: dsamersoff --- .../classes/sun/jvm/hotspot/SALauncher.java | 22 +++++++++- .../classes/sun/jvm/hotspot/tools/JMap.java | 44 +++++++++++++------ 2 files changed, 51 insertions(+), 15 deletions(-) diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java index dfbbb6ff440..83c86051ba9 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java @@ -73,6 +73,7 @@ public class SALauncher { System.out.println(" \tto print same info as Solaris pmap"); System.out.println(" --heap\tto print java heap summary"); System.out.println(" --binaryheap\tto dump java heap in hprof binary format"); + System.out.println(" --dumpfile\tname of the dump file"); System.out.println(" --histo\tto print histogram of java object heap"); System.out.println(" --clstats\tto print class loader statistics"); System.out.println(" --finalizerinfo\tto print information on objects awaiting finalization"); @@ -241,13 +242,15 @@ public class SALauncher { private static void runJMAP(String[] oldArgs) { SAGetopt sg = new SAGetopt(oldArgs); String[] longOpts = {"exe=", "core=", "pid=", - "heap", "binaryheap", "histo", "clstats", "finalizerinfo"}; + "heap", "binaryheap", "dumpfile=", "histo", "clstats", "finalizerinfo"}; ArrayList newArgs = new ArrayList(); String pid = null; String exe = null; String core = null; String s = null; + String dumpfile = null; + boolean requestHeapdump = false; while((s = sg.next(null, longOpts)) != null) { if (s.equals("exe")) { @@ -267,7 +270,11 @@ public class SALauncher { continue; } if (s.equals("binaryheap")) { - newArgs.add("-heap:format=b"); + requestHeapdump = true; + continue; + } + if (s.equals("dumpfile")) { + dumpfile = sg.getOptarg(); continue; } if (s.equals("histo")) { @@ -284,6 +291,17 @@ public class SALauncher { } } + if (!requestHeapdump && (dumpfile != null)) { + throw new IllegalArgumentException("Unexpected argument dumpfile"); + } + if (requestHeapdump) { + if (dumpfile == null) { + newArgs.add("-heap:format=b"); + } else { + newArgs.add("-heap:format=b,file=" + dumpfile); + } + } + buildAttachArgs(newArgs, pid, exe, core, false); JMap.main(newArgs.toArray(new String[newArgs.size()])); } diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JMap.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JMap.java index 847eac19468..21842a88a8f 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JMap.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JMap.java @@ -71,6 +71,8 @@ public class JMap extends Tool { public static final int MODE_HEAP_GRAPH_GXL = 5; public static final int MODE_FINALIZERINFO = 6; + private static String dumpfile = "heap.bin"; + public void run() { Tool tool = null; switch (mode) { @@ -92,11 +94,11 @@ public class JMap extends Tool { break; case MODE_HEAP_GRAPH_HPROF_BIN: - writeHeapHprofBin(); + writeHeapHprofBin(dumpfile); return; case MODE_HEAP_GRAPH_GXL: - writeHeapGXL(); + writeHeapGXL(dumpfile); return; case MODE_FINALIZERINFO: @@ -127,18 +129,34 @@ public class JMap extends Tool { } else if (modeFlag.equals("-finalizerinfo")) { mode = MODE_FINALIZERINFO; } else { - int index = modeFlag.indexOf("-heap:format="); + int index = modeFlag.indexOf("-heap:"); if (index != -1) { - String format = modeFlag.substring(1 + modeFlag.indexOf('=')); - if (format.equals("b")) { - mode = MODE_HEAP_GRAPH_HPROF_BIN; - } else if (format.equals("x")) { - mode = MODE_HEAP_GRAPH_GXL; - } else { - System.err.println("unknown heap format:" + format); - - // Exit with error status - System.exit(1); + String[] options = modeFlag.substring(6).split(","); + for (String option : options) { + String[] keyValue = option.split("="); + if (keyValue[0].equals("format")) { + if (keyValue[1].equals("b")) { + mode = MODE_HEAP_GRAPH_HPROF_BIN; + } else if (keyValue[1].equals("x")) { + mode = MODE_HEAP_GRAPH_GXL; + } else { + System.err.println("unknown heap format:" + keyValue[0]); + + // Exit with error status + System.exit(1); + } + } else if (keyValue[0].equals("file")) { + if ((keyValue[1] == null) || keyValue[1].equals("")) { + System.err.println("File name must be set."); + System.exit(1); + } + dumpfile = keyValue[1]; + } else { + System.err.println("unknown option:" + keyValue[0]); + + // Exit with error status + System.exit(1); + } } } else { copyArgs = false; -- GitLab From 7adc4034cd0cc69f5b9e045b57b047ffff64a9a0 Mon Sep 17 00:00:00 2001 From: Rahul Raghavan Date: Mon, 9 May 2016 01:21:55 -0700 Subject: [PATCH 316/400] 8153655: Make intrinsics flags diagnostic and update intrinsics tests to enable diagnostic options Converted all intrinsics flags to diagnostic and updated related intrinsics tests to enable diagnostic options Reviewed-by: kvn --- hotspot/src/share/vm/c1/c1_globals.hpp | 2 +- hotspot/src/share/vm/opto/c2_globals.hpp | 26 +++++++------- hotspot/src/share/vm/runtime/globals.hpp | 34 +++++++++---------- .../compiler/cpuflags/AESIntrinsicsBase.java | 17 ++++++---- .../intrinsics/muladd/TestMulAdd.java | 2 +- .../intrinsics/sha/cli/SHAOptionsBase.java | 5 +++ .../testcases/GenericTestCaseForOtherCPU.java | 7 +++- .../GenericTestCaseForSupportedCPU.java | 10 +++++- ...nericTestCaseForUnsupportedAArch64CPU.java | 7 +++- ...GenericTestCaseForUnsupportedSparcCPU.java | 7 +++- .../GenericTestCaseForUnsupportedX86CPU.java | 7 +++- ...sicsSpecificTestCaseForUnsupportedCPU.java | 1 + ...UseSHASpecificTestCaseForSupportedCPU.java | 4 +++ ...eSHASpecificTestCaseForUnsupportedCPU.java | 2 ++ .../compiler/runtime/6859338/Test6859338.java | 2 +- 15 files changed, 89 insertions(+), 44 deletions(-) diff --git a/hotspot/src/share/vm/c1/c1_globals.hpp b/hotspot/src/share/vm/c1/c1_globals.hpp index ad6548e4928..168262cf20a 100644 --- a/hotspot/src/share/vm/c1/c1_globals.hpp +++ b/hotspot/src/share/vm/c1/c1_globals.hpp @@ -176,7 +176,7 @@ product(bool, InlineSynchronizedMethods, true, \ "Inline synchronized methods") \ \ - develop(bool, InlineNIOCheckIndex, true, \ + diagnostic(bool, InlineNIOCheckIndex, true, \ "Intrinsify java.nio.Buffer.checkIndex") \ \ develop(bool, CanonicalizeNodes, true, \ diff --git a/hotspot/src/share/vm/opto/c2_globals.hpp b/hotspot/src/share/vm/opto/c2_globals.hpp index 802b0961e1a..acaa0e01878 100644 --- a/hotspot/src/share/vm/opto/c2_globals.hpp +++ b/hotspot/src/share/vm/opto/c2_globals.hpp @@ -589,26 +589,26 @@ product(bool, BlockLayoutRotateLoops, true, \ "Allow back branches to be fall throughs in the block layout") \ \ - develop(bool, InlineReflectionGetCallerClass, true, \ + diagnostic(bool, InlineReflectionGetCallerClass, true, \ "inline sun.reflect.Reflection.getCallerClass(), known to be " \ "part of base library DLL") \ \ - develop(bool, InlineObjectCopy, true, \ + diagnostic(bool, InlineObjectCopy, true, \ "inline Object.clone and Arrays.copyOf[Range] intrinsics") \ \ - develop(bool, SpecialStringCompareTo, true, \ + diagnostic(bool, SpecialStringCompareTo, true, \ "special version of string compareTo") \ \ - develop(bool, SpecialStringIndexOf, true, \ + diagnostic(bool, SpecialStringIndexOf, true, \ "special version of string indexOf") \ \ - develop(bool, SpecialStringEquals, true, \ + diagnostic(bool, SpecialStringEquals, true, \ "special version of string equals") \ \ - develop(bool, SpecialArraysEquals, true, \ + diagnostic(bool, SpecialArraysEquals, true, \ "special version of Arrays.equals(char[],char[])") \ \ - product(bool, SpecialEncodeISOArray, true, \ + diagnostic(bool, SpecialEncodeISOArray, true, \ "special version of ISO_8859_1$Encoder.encodeISOArray") \ \ develop(bool, BailoutToInterpreterForThrows, false, \ @@ -710,22 +710,22 @@ diagnostic(bool, OptimizeExpensiveOps, true, \ "Find best control for expensive operations") \ \ - product(bool, UseMathExactIntrinsics, true, \ + diagnostic(bool, UseMathExactIntrinsics, true, \ "Enables intrinsification of various java.lang.Math functions") \ \ - product(bool, UseMultiplyToLenIntrinsic, false, \ + diagnostic(bool, UseMultiplyToLenIntrinsic, false, \ "Enables intrinsification of BigInteger.multiplyToLen()") \ \ - product(bool, UseSquareToLenIntrinsic, false, \ + diagnostic(bool, UseSquareToLenIntrinsic, false, \ "Enables intrinsification of BigInteger.squareToLen()") \ \ - product(bool, UseMulAddIntrinsic, false, \ + diagnostic(bool, UseMulAddIntrinsic, false, \ "Enables intrinsification of BigInteger.mulAdd()") \ \ - product(bool, UseMontgomeryMultiplyIntrinsic, false, \ + diagnostic(bool, UseMontgomeryMultiplyIntrinsic, false, \ "Enables intrinsification of BigInteger.montgomeryMultiply()") \ \ - product(bool, UseMontgomerySquareIntrinsic, false, \ + diagnostic(bool, UseMontgomerySquareIntrinsic, false, \ "Enables intrinsification of BigInteger.montgomerySquare()") \ \ product(bool, UseTypeSpeculation, true, \ diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 3fb93e1b236..fc788a2d15f 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -732,7 +732,7 @@ public: "Control whether SHA instructions can be used " \ "on SPARC, on ARM and on x86") \ \ - product(bool, UseGHASHIntrinsics, false, \ + diagnostic(bool, UseGHASHIntrinsics, false, \ "Use intrinsics for GHASH versions of crypto") \ \ product(size_t, LargePageSizeInBytes, 0, \ @@ -802,27 +802,27 @@ public: product(bool, UseInlineCaches, true, \ "Use Inline Caches for virtual calls ") \ \ - develop(bool, InlineArrayCopy, true, \ + diagnostic(bool, InlineArrayCopy, true, \ "Inline arraycopy native that is known to be part of " \ "base library DLL") \ \ - develop(bool, InlineObjectHash, true, \ + diagnostic(bool, InlineObjectHash, true, \ "Inline Object::hashCode() native that is known to be part " \ "of base library DLL") \ \ - develop(bool, InlineNatives, true, \ + diagnostic(bool, InlineNatives, true, \ "Inline natives that are known to be part of base library DLL") \ \ - develop(bool, InlineMathNatives, true, \ + diagnostic(bool, InlineMathNatives, true, \ "Inline SinD, CosD, etc.") \ \ - develop(bool, InlineClassNatives, true, \ + diagnostic(bool, InlineClassNatives, true, \ "Inline Class.isInstance, etc") \ \ - develop(bool, InlineThreadNatives, true, \ + diagnostic(bool, InlineThreadNatives, true, \ "Inline Thread.currentThread, etc") \ \ - develop(bool, InlineUnsafeOps, true, \ + diagnostic(bool, InlineUnsafeOps, true, \ "Inline memory ops (native methods) from Unsafe") \ \ product(bool, CriticalJNINatives, true, \ @@ -831,34 +831,34 @@ public: notproduct(bool, StressCriticalJNINatives, false, \ "Exercise register saving code in critical natives") \ \ - product(bool, UseAESIntrinsics, false, \ + diagnostic(bool, UseAESIntrinsics, false, \ "Use intrinsics for AES versions of crypto") \ \ - product(bool, UseAESCTRIntrinsics, false, \ + diagnostic(bool, UseAESCTRIntrinsics, false, \ "Use intrinsics for the paralleled version of AES/CTR crypto") \ \ - product(bool, UseSHA1Intrinsics, false, \ + diagnostic(bool, UseSHA1Intrinsics, false, \ "Use intrinsics for SHA-1 crypto hash function. " \ "Requires that UseSHA is enabled.") \ \ - product(bool, UseSHA256Intrinsics, false, \ + diagnostic(bool, UseSHA256Intrinsics, false, \ "Use intrinsics for SHA-224 and SHA-256 crypto hash functions. " \ "Requires that UseSHA is enabled.") \ \ - product(bool, UseSHA512Intrinsics, false, \ + diagnostic(bool, UseSHA512Intrinsics, false, \ "Use intrinsics for SHA-384 and SHA-512 crypto hash functions. " \ "Requires that UseSHA is enabled.") \ \ - product(bool, UseCRC32Intrinsics, false, \ + diagnostic(bool, UseCRC32Intrinsics, false, \ "use intrinsics for java.util.zip.CRC32") \ \ - product(bool, UseCRC32CIntrinsics, false, \ + diagnostic(bool, UseCRC32CIntrinsics, false, \ "use intrinsics for java.util.zip.CRC32C") \ \ - product(bool, UseAdler32Intrinsics, false, \ + diagnostic(bool, UseAdler32Intrinsics, false, \ "use intrinsics for java.util.zip.Adler32") \ \ - product(bool, UseVectorizedMismatchIntrinsic, false, \ + diagnostic(bool, UseVectorizedMismatchIntrinsic, false, \ "Enables intrinsification of ArraysSupport.vectorizedMismatch()") \ \ diagnostic(ccstrlist, DisableIntrinsic, "", \ diff --git a/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java b/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java index 8e8deda71bd..7be9e436ad9 100644 --- a/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java +++ b/hotspot/test/compiler/cpuflags/AESIntrinsicsBase.java @@ -40,10 +40,11 @@ public abstract class AESIntrinsicsBase extends CommandLineOptionTest { public static final String USE_AES_INTRINSICS = "UseAESIntrinsics"; public static final String USE_SSE = "UseSSE"; public static final String USE_VIS = "UseVIS"; + public static final String[] USE_DIAGNOSTIC_CMD + = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintIntrinsics"}; public static final String[] TEST_AES_CMD = {"-XX:+IgnoreUnrecognizedVMOptions", "-XX:+PrintFlagsFinal", - "-Xbatch","-XX:+UnlockDiagnosticVMOptions", - "-XX:+PrintIntrinsics", "-DcheckOutput=true", "-Dmode=CBC", + "-Xbatch", "-DcheckOutput=true", "-Dmode=CBC", "TestAESMain"}; protected AESIntrinsicsBase(BooleanSupplier predicate) { @@ -52,14 +53,18 @@ public abstract class AESIntrinsicsBase extends CommandLineOptionTest { /** * Prepares command for TestAESMain execution. + * Intrinsics flags are of diagnostic type + * and must be preceded by UnlockDiagnosticVMOptions. * @param args flags that must be added to command * @return command for TestAESMain execution */ public static String[] prepareArguments(String... args) { - String[] command = Arrays.copyOf(args, TEST_AES_CMD.length - + args.length); - System.arraycopy(TEST_AES_CMD, 0, command, args.length, - TEST_AES_CMD.length); + String[] command = Arrays.copyOf(USE_DIAGNOSTIC_CMD, args.length + + USE_DIAGNOSTIC_CMD.length + TEST_AES_CMD.length); + System.arraycopy(args, 0, command, USE_DIAGNOSTIC_CMD.length, + args.length); + System.arraycopy(TEST_AES_CMD, 0, command, args.length + + USE_DIAGNOSTIC_CMD.length, TEST_AES_CMD.length); return command; } } diff --git a/hotspot/test/compiler/intrinsics/muladd/TestMulAdd.java b/hotspot/test/compiler/intrinsics/muladd/TestMulAdd.java index 4d7b274c284..4b310e9069e 100644 --- a/hotspot/test/compiler/intrinsics/muladd/TestMulAdd.java +++ b/hotspot/test/compiler/intrinsics/muladd/TestMulAdd.java @@ -28,7 +28,7 @@ * @summary Add C2 x86 intrinsic for BigInteger::mulAdd() method * * @run main/othervm/timeout=600 -XX:-TieredCompilation -Xbatch - * -XX:+IgnoreUnrecognizedVMOptions -XX:-UseSquareToLenIntrinsic -XX:-UseMultiplyToLenIntrinsic + * -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-UseSquareToLenIntrinsic -XX:-UseMultiplyToLenIntrinsic * -XX:CompileCommand=dontinline,TestMulAdd::main * -XX:CompileCommand=option,TestMulAdd::base_multiply,ccstr,DisableIntrinsic,_mulAdd * -XX:CompileCommand=option,java.math.BigInteger::multiply,ccstr,DisableIntrinsic,_mulAdd diff --git a/hotspot/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java b/hotspot/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java index 5c801cb6d1e..febf666aeb7 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/SHAOptionsBase.java @@ -42,6 +42,11 @@ public class SHAOptionsBase extends CommandLineOptionTest { protected static final String USE_SHA512_INTRINSICS_OPTION = "UseSHA512Intrinsics"; + // Intrinsics flags are of diagnostic type + // and must be preceded by UnlockDiagnosticVMOptions. + protected static final String UNLOCK_DIAGNOSTIC_VM_OPTIONS + = "-XX:+UnlockDiagnosticVMOptions"; + // Note that strings below will be passed to // CommandLineOptionTest.verifySameJVMStartup and thus are regular // expressions, not just a plain strings. diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java index ca11075c37d..09dc581e7fb 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForOtherCPU.java @@ -50,11 +50,13 @@ public class GenericTestCaseForOtherCPU extends CommandLineOptionTest.verifySameJVMStartup(null, new String[] { ".*" + optionName + ".*" }, shouldPassMessage, shouldPassMessage, ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); CommandLineOptionTest.verifySameJVMStartup(null, new String[] { ".*" + optionName + ".*" }, shouldPassMessage, shouldPassMessage, ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); } @@ -63,13 +65,15 @@ public class GenericTestCaseForOtherCPU extends // Verify that option is disabled by default. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", String.format("Option '%s' should be disabled by default", - optionName)); + optionName), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS); // Verify that option is disabled even if it was explicitly enabled // using CLI options. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", String.format("Option '%s' should be off on unsupported " + "CPU even if set to true directly", optionName), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); // Verify that option is disabled when it explicitly disabled @@ -79,6 +83,7 @@ public class GenericTestCaseForOtherCPU extends + " even if '%s' flag set to JVM", optionName, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true)), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); } } diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java index 69be4343825..553cfafa128 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForSupportedCPU.java @@ -49,6 +49,7 @@ public class GenericTestCaseForSupportedCPU extends CommandLineOptionTest.verifySameJVMStartup(null, new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, shouldPassMessage, shouldPassMessage, ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); // Verify that option could be disabled even if +UseSHA was passed to @@ -60,6 +61,7 @@ public class GenericTestCaseForSupportedCPU extends optionName, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true)), ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true), CommandLineOptionTest.prepareBooleanFlag(optionName, false)); @@ -75,6 +77,7 @@ public class GenericTestCaseForSupportedCPU extends optionName, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false)), ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false), CommandLineOptionTest.prepareBooleanFlag(optionName, true)); } @@ -86,18 +89,21 @@ public class GenericTestCaseForSupportedCPU extends CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", String.format("Option '%s' should be enabled by default", - optionName)); + optionName), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS); // Verify that it is possible to explicitly enable the option. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "true", String.format("Option '%s' was set to have value 'true'", optionName), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); // Verify that it is possible to explicitly disable the option. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", String.format("Option '%s' was set to have value 'false'", optionName), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); // verify that option is disabled when -UseSHA was passed to JVM. @@ -106,6 +112,7 @@ public class GenericTestCaseForSupportedCPU extends + " flag set to JVM", optionName, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, false)), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, true), CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, false)); @@ -117,6 +124,7 @@ public class GenericTestCaseForSupportedCPU extends + " even if %s flag set to JVM", optionName, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true)), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true), CommandLineOptionTest.prepareBooleanFlag(optionName, false)); diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java index 6730b9e9594..8fabc79bfaa 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedAArch64CPU.java @@ -47,6 +47,7 @@ public class GenericTestCaseForUnsupportedAArch64CPU extends CommandLineOptionTest.verifySameJVMStartup(null, new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, shouldPassMessage, shouldPassMessage, ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); shouldPassMessage = String.format("If JVM is started with '-XX:-" @@ -62,6 +63,7 @@ public class GenericTestCaseForUnsupportedAArch64CPU extends shouldPassMessage, shouldPassMessage, ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false), CommandLineOptionTest.prepareBooleanFlag(optionName, true)); } @@ -72,13 +74,15 @@ public class GenericTestCaseForUnsupportedAArch64CPU extends // Verify that option is disabled by default. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", String.format("Option '%s' should be disabled by default", - optionName)); + optionName), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS); // Verify that option is disabled even if it was explicitly enabled // using CLI options. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", String.format("Option '%s' should be off on unsupported " + "AArch64CPU even if set to true directly", optionName), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); // Verify that option is disabled when +UseSHA was passed to JVM. @@ -87,6 +91,7 @@ public class GenericTestCaseForUnsupportedAArch64CPU extends + "AArch64CPU even if %s flag set to JVM", optionName, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true)), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true)); } diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java index 58dde555551..1254b8a0649 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedSparcCPU.java @@ -47,6 +47,7 @@ public class GenericTestCaseForUnsupportedSparcCPU extends CommandLineOptionTest.verifySameJVMStartup(null, new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, shouldPassMessage, shouldPassMessage, ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); // Verify that when the tested option is enabled, then @@ -58,6 +59,7 @@ public class GenericTestCaseForUnsupportedSparcCPU extends shouldPassMessage, shouldPassMessage, ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false), CommandLineOptionTest.prepareBooleanFlag(optionName, true)); } @@ -68,13 +70,15 @@ public class GenericTestCaseForUnsupportedSparcCPU extends // Verify that option is disabled by default. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", String.format("Option '%s' should be disabled by default", - optionName)); + optionName), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS); // Verify that option is disabled even if it was explicitly enabled // using CLI options. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", String.format("Option '%s' should be off on unsupported " + "SparcCPU even if set to true directly", optionName), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); // Verify that option is disabled when +UseSHA was passed to JVM. @@ -83,6 +87,7 @@ public class GenericTestCaseForUnsupportedSparcCPU extends + "SparcCPU even if %s flag set to JVM", optionName, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true)), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true)); } diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java index 2caa1f59d6e..599be2c8061 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/GenericTestCaseForUnsupportedX86CPU.java @@ -49,6 +49,7 @@ public class GenericTestCaseForUnsupportedX86CPU CommandLineOptionTest.verifySameJVMStartup(null, new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, shouldPassMessage, shouldPassMessage, ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, false)); // Verify that when the tested option is enabled, then @@ -60,6 +61,7 @@ public class GenericTestCaseForUnsupportedX86CPU shouldPassMessage, shouldPassMessage, ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(SHAOptionsBase.USE_SHA_OPTION, false), CommandLineOptionTest.prepareBooleanFlag(optionName, true)); } @@ -70,12 +72,14 @@ public class GenericTestCaseForUnsupportedX86CPU // Verify that the tested option is disabled by default. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", String.format("Option '%s' should be disabled by default", - optionName)); + optionName), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS); // Verify that it is not possible to explicitly enable the option. CommandLineOptionTest.verifyOptionValueForSameVM(optionName, "false", String.format("Option '%s' should be off on unsupported " + "X86CPU even if set to true directly", optionName), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); // Verify that the tested option is disabled even if +UseSHA was passed @@ -85,6 +89,7 @@ public class GenericTestCaseForUnsupportedX86CPU + "X86CPU even if %s flag set to JVM", optionName, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true)), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true)); } diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU.java index 6ba51bb98ae..c75a66795b8 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU.java @@ -59,6 +59,7 @@ public class UseSHAIntrinsicsSpecificTestCaseForUnsupportedCPU CommandLineOptionTest.verifySameJVMStartup(new String[] { SHAOptionsBase.getWarningForUnsupportedCPU(optionName) }, null, shouldPassMessage, shouldPassMessage, ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag(optionName, true)); } } diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedCPU.java index 9349a3330bd..3c1d208790e 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedCPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForSupportedCPU.java @@ -57,6 +57,7 @@ public class UseSHASpecificTestCaseForSupportedCPU CommandLineOptionTest.verifySameJVMStartup( null, new String[] { ".*UseSHA.*" }, shouldPassMessage, shouldPassMessage, ExitCode.OK, + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true), CommandLineOptionTest.prepareBooleanFlag( @@ -75,6 +76,7 @@ public class UseSHASpecificTestCaseForSupportedCPU SHAOptionsBase.USE_SHA_OPTION, "false", String.format( "'%s' option should be disabled when all UseSHA*Intrinsics are" + " disabled", SHAOptionsBase.USE_SHA_OPTION), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, false), CommandLineOptionTest.prepareBooleanFlag( @@ -91,6 +93,7 @@ public class UseSHASpecificTestCaseForSupportedCPU + "to JVM", SHAOptionsBase.USE_SHA_OPTION, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true)), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true), CommandLineOptionTest.prepareBooleanFlag( @@ -109,6 +112,7 @@ public class UseSHASpecificTestCaseForSupportedCPU SHAOptionsBase.USE_SHA_OPTION, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, false)), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, false), CommandLineOptionTest.prepareBooleanFlag( diff --git a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedCPU.java b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedCPU.java index d325ddaf113..22f133deaa9 100644 --- a/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedCPU.java +++ b/hotspot/test/compiler/intrinsics/sha/cli/testcases/UseSHASpecificTestCaseForUnsupportedCPU.java @@ -68,6 +68,7 @@ public class UseSHASpecificTestCaseForUnsupportedCPU "%s option should be disabled on unsupported CPU" + " even if all UseSHA*Intrinsics options were enabled.", SHAOptionsBase.USE_SHA_OPTION), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA1_INTRINSICS_OPTION, true), CommandLineOptionTest.prepareBooleanFlag( @@ -84,6 +85,7 @@ public class UseSHASpecificTestCaseForUnsupportedCPU + " and %s was enabled as well", SHAOptionsBase.USE_SHA_OPTION, SHAOptionsBase.USE_SHA_OPTION), + SHAOptionsBase.UNLOCK_DIAGNOSTIC_VM_OPTIONS, CommandLineOptionTest.prepareBooleanFlag( SHAOptionsBase.USE_SHA_OPTION, true), CommandLineOptionTest.prepareBooleanFlag( diff --git a/hotspot/test/compiler/runtime/6859338/Test6859338.java b/hotspot/test/compiler/runtime/6859338/Test6859338.java index 03d68126f66..73576840db1 100644 --- a/hotspot/test/compiler/runtime/6859338/Test6859338.java +++ b/hotspot/test/compiler/runtime/6859338/Test6859338.java @@ -27,7 +27,7 @@ * @bug 6859338 * @summary Assertion failure in sharedRuntime.cpp * - * @run main/othervm -Xcomp -XX:+IgnoreUnrecognizedVMOptions -XX:-InlineObjectHash -Xbatch -XX:-ProfileInterpreter Test6859338 + * @run main/othervm -Xcomp -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-InlineObjectHash -Xbatch -XX:-ProfileInterpreter Test6859338 */ public class Test6859338 { -- GitLab From a1e5418d19386c3c49e5af8a0644c2cce4c097e2 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Mon, 9 May 2016 11:34:09 +0200 Subject: [PATCH 317/400] 8154826: AArch64: take advantage better of base + shifted offset addressing mode Reshape address subtree to fit aarch64 addressing mode Reviewed-by: kvn, aph --- hotspot/src/cpu/aarch64/vm/aarch64.ad | 296 ++++++++++++++------------ hotspot/src/cpu/ppc/vm/ppc.ad | 15 +- hotspot/src/cpu/sparc/vm/sparc.ad | 16 +- hotspot/src/cpu/x86/vm/x86.ad | 73 +++++++ hotspot/src/cpu/x86/vm/x86_32.ad | 5 - hotspot/src/cpu/x86/vm/x86_64.ad | 5 - hotspot/src/share/vm/opto/compile.cpp | 2 + hotspot/src/share/vm/opto/compile.hpp | 3 + hotspot/src/share/vm/opto/matcher.cpp | 112 ++-------- hotspot/src/share/vm/opto/matcher.hpp | 43 +++- 10 files changed, 309 insertions(+), 261 deletions(-) diff --git a/hotspot/src/cpu/aarch64/vm/aarch64.ad b/hotspot/src/cpu/aarch64/vm/aarch64.ad index e2e02cb6b30..5359f30f29c 100644 --- a/hotspot/src/cpu/aarch64/vm/aarch64.ad +++ b/hotspot/src/cpu/aarch64/vm/aarch64.ad @@ -996,6 +996,7 @@ definitions %{ source_hpp %{ #include "gc/shared/cardTableModRefBS.hpp" +#include "opto/addnode.hpp" class CallStubImpl { @@ -1061,6 +1062,9 @@ class HandlerImpl { // predicate controlling translation of StoreCM bool unnecessary_storestore(const Node *storecm); + + // predicate controlling addressing modes + bool size_fits_all_mem_uses(AddPNode* addp, int shift); %} source %{ @@ -3449,11 +3453,6 @@ const int Matcher::float_cmove_cost() { // Does the CPU require late expand (see block.cpp for description of late expand)? const bool Matcher::require_postalloc_expand = false; -// Should the Matcher clone shifts on addressing modes, expecting them -// to be subsumed into complex addressing expressions or compute them -// into registers? True for Intel but false for most RISCs -const bool Matcher::clone_shift_expressions = false; - // Do we need to mask the count passed to shift instructions or does // the cpu only look at the lower 5/6 bits anyway? const bool Matcher::need_masked_shift_count = false; @@ -3572,8 +3571,119 @@ const RegMask Matcher::method_handle_invoke_SP_save_mask() { return FP_REG_mask(); } +bool size_fits_all_mem_uses(AddPNode* addp, int shift) { + for (DUIterator_Fast imax, i = addp->fast_outs(imax); i < imax; i++) { + Node* u = addp->fast_out(i); + if (u->is_Mem()) { + int opsize = u->as_Mem()->memory_size(); + assert(opsize > 0, "unexpected memory operand size"); + if (u->as_Mem()->memory_size() != (1<in(AddPNode::Offset); + if (off->Opcode() == Op_LShiftL && off->in(2)->is_Con() && + size_fits_all_mem_uses(m, off->in(2)->get_int()) && + // Are there other uses besides address expressions? + !is_visited(off)) { + address_visited.set(off->_idx); // Flag as address_visited + mstack.push(off->in(2), Visit); + Node *conv = off->in(1); + if (conv->Opcode() == Op_ConvI2L && + // Are there other uses besides address expressions? + !is_visited(conv)) { + address_visited.set(conv->_idx); // Flag as address_visited + mstack.push(conv->in(1), Pre_Visit); + } else { + mstack.push(conv, Pre_Visit); + } + address_visited.test_set(m->_idx); // Flag as address_visited + mstack.push(m->in(AddPNode::Address), Pre_Visit); + mstack.push(m->in(AddPNode::Base), Pre_Visit); + return true; + } else if (off->Opcode() == Op_ConvI2L && + // Are there other uses besides address expressions? + !is_visited(off)) { + address_visited.test_set(m->_idx); // Flag as address_visited + address_visited.set(off->_idx); // Flag as address_visited + mstack.push(off->in(1), Pre_Visit); + mstack.push(m->in(AddPNode::Address), Pre_Visit); + mstack.push(m->in(AddPNode::Base), Pre_Visit); + return true; + } + return false; +} + +// Transform: +// (AddP base (AddP base address (LShiftL index con)) offset) +// into: +// (AddP base (AddP base offset) (LShiftL index con)) +// to take full advantage of ARM's addressing modes +void Compile::reshape_address(AddPNode* addp) { + Node *addr = addp->in(AddPNode::Address); + if (addr->is_AddP() && addr->in(AddPNode::Base) == addp->in(AddPNode::Base)) { + const AddPNode *addp2 = addr->as_AddP(); + if ((addp2->in(AddPNode::Offset)->Opcode() == Op_LShiftL && + addp2->in(AddPNode::Offset)->in(2)->is_Con() && + size_fits_all_mem_uses(addp, addp2->in(AddPNode::Offset)->in(2)->get_int())) || + addp2->in(AddPNode::Offset)->Opcode() == Op_ConvI2L) { + + // Any use that can't embed the address computation? + for (DUIterator_Fast imax, i = addp->fast_outs(imax); i < imax; i++) { + Node* u = addp->fast_out(i); + if (!u->is_Mem() || u->is_LoadVector() || u->is_StoreVector() || u->Opcode() == Op_StoreCM) { + return; + } + } + + Node* off = addp->in(AddPNode::Offset); + Node* addr2 = addp2->in(AddPNode::Address); + Node* base = addp->in(AddPNode::Base); + + Node* new_addr = NULL; + // Check whether the graph already has the new AddP we need + // before we create one (no GVN available here). + for (DUIterator_Fast imax, i = addr2->fast_outs(imax); i < imax; i++) { + Node* u = addr2->fast_out(i); + if (u->is_AddP() && + u->in(AddPNode::Base) == base && + u->in(AddPNode::Address) == addr2 && + u->in(AddPNode::Offset) == off) { + new_addr = u; + break; + } + } + + if (new_addr == NULL) { + new_addr = new AddPNode(base, addr2, off); + } + Node* new_off = addp2->in(AddPNode::Offset); + addp->set_req(AddPNode::Address, new_addr); + if (addr->outcnt() == 0) { + addr->disconnect_inputs(NULL, this); + } + addp->set_req(AddPNode::Offset, new_off); + if (off->outcnt() == 0) { + off->disconnect_inputs(NULL, this); + } + } + } +} + // helper for encoding java_to_runtime calls on sim // // this is needed to compute the extra arguments required when @@ -3643,12 +3753,10 @@ typedef void (MacroAssembler::* mem_vector_insn)(FloatRegister Rt, // encoder that the index needs to be sign extended, so we have to // enumerate all the cases. switch (opcode) { - case INDINDEXSCALEDOFFSETI2L: case INDINDEXSCALEDI2L: - case INDINDEXSCALEDOFFSETI2LN: case INDINDEXSCALEDI2LN: - case INDINDEXOFFSETI2L: - case INDINDEXOFFSETI2LN: + case INDINDEXI2L: + case INDINDEXI2LN: scale = Address::sxtw(size); break; default: @@ -3658,12 +3766,8 @@ typedef void (MacroAssembler::* mem_vector_insn)(FloatRegister Rt, if (index == -1) { (masm.*insn)(reg, Address(base, disp)); } else { - if (disp == 0) { - (masm.*insn)(reg, Address(base, as_Register(index), scale)); - } else { - masm.lea(rscratch1, Address(base, disp)); - (masm.*insn)(reg, Address(rscratch1, as_Register(index), scale)); - } + assert(disp == 0, "unsupported address mode: disp = %d", disp); + (masm.*insn)(reg, Address(base, as_Register(index), scale)); } } @@ -3674,9 +3778,7 @@ typedef void (MacroAssembler::* mem_vector_insn)(FloatRegister Rt, Address::extend scale; switch (opcode) { - case INDINDEXSCALEDOFFSETI2L: case INDINDEXSCALEDI2L: - case INDINDEXSCALEDOFFSETI2LN: case INDINDEXSCALEDI2LN: scale = Address::sxtw(size); break; @@ -3687,12 +3789,8 @@ typedef void (MacroAssembler::* mem_vector_insn)(FloatRegister Rt, if (index == -1) { (masm.*insn)(reg, Address(base, disp)); } else { - if (disp == 0) { - (masm.*insn)(reg, Address(base, as_Register(index), scale)); - } else { - masm.lea(rscratch1, Address(base, disp)); - (masm.*insn)(reg, Address(rscratch1, as_Register(index), scale)); - } + assert(disp == 0, "unsupported address mode: disp = %d", disp); + (masm.*insn)(reg, Address(base, as_Register(index), scale)); } } @@ -6106,65 +6204,10 @@ operand indirect(iRegP reg) %} %} -operand indIndexScaledOffsetI(iRegP reg, iRegL lreg, immIScale scale, immIU12 off) -%{ - constraint(ALLOC_IN_RC(ptr_reg)); - match(AddP (AddP reg (LShiftL lreg scale)) off); - op_cost(INSN_COST); - format %{ "$reg, $lreg lsl($scale), $off" %} - interface(MEMORY_INTER) %{ - base($reg); - index($lreg); - scale($scale); - disp($off); - %} -%} - -operand indIndexScaledOffsetL(iRegP reg, iRegL lreg, immIScale scale, immLU12 off) -%{ - constraint(ALLOC_IN_RC(ptr_reg)); - match(AddP (AddP reg (LShiftL lreg scale)) off); - op_cost(INSN_COST); - format %{ "$reg, $lreg lsl($scale), $off" %} - interface(MEMORY_INTER) %{ - base($reg); - index($lreg); - scale($scale); - disp($off); - %} -%} - -operand indIndexOffsetI2L(iRegP reg, iRegI ireg, immLU12 off) -%{ - constraint(ALLOC_IN_RC(ptr_reg)); - match(AddP (AddP reg (ConvI2L ireg)) off); - op_cost(INSN_COST); - format %{ "$reg, $ireg, $off I2L" %} - interface(MEMORY_INTER) %{ - base($reg); - index($ireg); - scale(0x0); - disp($off); - %} -%} - -operand indIndexScaledOffsetI2L(iRegP reg, iRegI ireg, immIScale scale, immLU12 off) -%{ - constraint(ALLOC_IN_RC(ptr_reg)); - match(AddP (AddP reg (LShiftL (ConvI2L ireg) scale)) off); - op_cost(INSN_COST); - format %{ "$reg, $ireg sxtw($scale), $off I2L" %} - interface(MEMORY_INTER) %{ - base($reg); - index($ireg); - scale($scale); - disp($off); - %} -%} - operand indIndexScaledI2L(iRegP reg, iRegI ireg, immIScale scale) %{ constraint(ALLOC_IN_RC(ptr_reg)); + predicate(size_fits_all_mem_uses(n->as_AddP(), n->in(AddPNode::Offset)->in(2)->get_int())); match(AddP reg (LShiftL (ConvI2L ireg) scale)); op_cost(0); format %{ "$reg, $ireg sxtw($scale), 0, I2L" %} @@ -6179,6 +6222,7 @@ operand indIndexScaledI2L(iRegP reg, iRegI ireg, immIScale scale) operand indIndexScaled(iRegP reg, iRegL lreg, immIScale scale) %{ constraint(ALLOC_IN_RC(ptr_reg)); + predicate(size_fits_all_mem_uses(n->as_AddP(), n->in(AddPNode::Offset)->in(2)->get_int())); match(AddP reg (LShiftL lreg scale)); op_cost(0); format %{ "$reg, $lreg lsl($scale)" %} @@ -6190,6 +6234,20 @@ operand indIndexScaled(iRegP reg, iRegL lreg, immIScale scale) %} %} +operand indIndexI2L(iRegP reg, iRegI ireg) +%{ + constraint(ALLOC_IN_RC(ptr_reg)); + match(AddP reg (ConvI2L ireg)); + op_cost(0); + format %{ "$reg, $ireg, 0, I2L" %} + interface(MEMORY_INTER) %{ + base($reg); + index($ireg); + scale(0x0); + disp(0x0); + %} +%} + operand indIndex(iRegP reg, iRegL lreg) %{ constraint(ALLOC_IN_RC(ptr_reg)); @@ -6331,92 +6389,47 @@ operand indirectN(iRegN reg) %} %} -operand indIndexScaledOffsetIN(iRegN reg, iRegL lreg, immIScale scale, immIU12 off) +operand indIndexScaledI2LN(iRegN reg, iRegI ireg, immIScale scale) %{ - predicate(Universe::narrow_oop_shift() == 0); + predicate(Universe::narrow_oop_shift() == 0 && size_fits_all_mem_uses(n->as_AddP(), n->in(AddPNode::Offset)->in(2)->get_int())); constraint(ALLOC_IN_RC(ptr_reg)); - match(AddP (AddP (DecodeN reg) (LShiftL lreg scale)) off); + match(AddP (DecodeN reg) (LShiftL (ConvI2L ireg) scale)); op_cost(0); - format %{ "$reg, $lreg lsl($scale), $off\t# narrow" %} - interface(MEMORY_INTER) %{ - base($reg); - index($lreg); - scale($scale); - disp($off); - %} -%} - -operand indIndexScaledOffsetLN(iRegN reg, iRegL lreg, immIScale scale, immLU12 off) -%{ - predicate(Universe::narrow_oop_shift() == 0); - constraint(ALLOC_IN_RC(ptr_reg)); - match(AddP (AddP (DecodeN reg) (LShiftL lreg scale)) off); - op_cost(INSN_COST); - format %{ "$reg, $lreg lsl($scale), $off\t# narrow" %} - interface(MEMORY_INTER) %{ - base($reg); - index($lreg); - scale($scale); - disp($off); - %} -%} - -operand indIndexOffsetI2LN(iRegN reg, iRegI ireg, immLU12 off) -%{ - predicate(Universe::narrow_oop_shift() == 0); - constraint(ALLOC_IN_RC(ptr_reg)); - match(AddP (AddP (DecodeN reg) (ConvI2L ireg)) off); - op_cost(INSN_COST); - format %{ "$reg, $ireg, $off I2L\t# narrow" %} - interface(MEMORY_INTER) %{ - base($reg); - index($ireg); - scale(0x0); - disp($off); - %} -%} - -operand indIndexScaledOffsetI2LN(iRegN reg, iRegI ireg, immIScale scale, immLU12 off) -%{ - predicate(Universe::narrow_oop_shift() == 0); - constraint(ALLOC_IN_RC(ptr_reg)); - match(AddP (AddP (DecodeN reg) (LShiftL (ConvI2L ireg) scale)) off); - op_cost(INSN_COST); - format %{ "$reg, $ireg sxtw($scale), $off I2L\t# narrow" %} + format %{ "$reg, $ireg sxtw($scale), 0, I2L\t# narrow" %} interface(MEMORY_INTER) %{ base($reg); index($ireg); scale($scale); - disp($off); + disp(0x0); %} %} -operand indIndexScaledI2LN(iRegN reg, iRegI ireg, immIScale scale) +operand indIndexScaledN(iRegN reg, iRegL lreg, immIScale scale) %{ - predicate(Universe::narrow_oop_shift() == 0); + predicate(Universe::narrow_oop_shift() == 0 && size_fits_all_mem_uses(n->as_AddP(), n->in(AddPNode::Offset)->in(2)->get_int())); constraint(ALLOC_IN_RC(ptr_reg)); - match(AddP (DecodeN reg) (LShiftL (ConvI2L ireg) scale)); + match(AddP (DecodeN reg) (LShiftL lreg scale)); op_cost(0); - format %{ "$reg, $ireg sxtw($scale), 0, I2L\t# narrow" %} + format %{ "$reg, $lreg lsl($scale)\t# narrow" %} interface(MEMORY_INTER) %{ base($reg); - index($ireg); + index($lreg); scale($scale); disp(0x0); %} %} -operand indIndexScaledN(iRegN reg, iRegL lreg, immIScale scale) +operand indIndexI2LN(iRegN reg, iRegI ireg) %{ predicate(Universe::narrow_oop_shift() == 0); constraint(ALLOC_IN_RC(ptr_reg)); - match(AddP (DecodeN reg) (LShiftL lreg scale)); + match(AddP (DecodeN reg) (ConvI2L ireg)); op_cost(0); - format %{ "$reg, $lreg lsl($scale)\t# narrow" %} + format %{ "$reg, $ireg, 0, I2L\t# narrow" %} interface(MEMORY_INTER) %{ base($reg); - index($lreg); - scale($scale); + index($ireg); + scale(0x0); disp(0x0); %} %} @@ -6641,9 +6654,8 @@ opclass vmem16(indirect, indIndex, indOffI16, indOffL16); // memory is used to define read/write location for load/store // instruction defs. we can turn a memory op into an Address -opclass memory(indirect, indIndexScaledOffsetI, indIndexScaledOffsetL, indIndexOffsetI2L, indIndexScaledOffsetI2L, indIndexScaled, indIndexScaledI2L, indIndex, indOffI, indOffL, - indirectN, indIndexScaledOffsetIN, indIndexScaledOffsetLN, indIndexOffsetI2LN, indIndexScaledOffsetI2LN, indIndexScaledN, indIndexScaledI2LN, indIndexN, indOffIN, indOffLN); - +opclass memory(indirect, indIndexScaled, indIndexScaledI2L, indIndexI2L, indIndex, indOffI, indOffL, + indirectN, indIndexScaledN, indIndexScaledI2LN, indIndexI2LN, indIndexN, indOffIN, indOffLN); // iRegIorL2I is used for src inputs in rules for 32 bit int (I) // operations. it allows the src to be either an iRegI or a (ConvL2I diff --git a/hotspot/src/cpu/ppc/vm/ppc.ad b/hotspot/src/cpu/ppc/vm/ppc.ad index b2b6ba500ea..0dc5a4d2b45 100644 --- a/hotspot/src/cpu/ppc/vm/ppc.ad +++ b/hotspot/src/cpu/ppc/vm/ppc.ad @@ -817,6 +817,16 @@ source_hpp %{ source %{ +// Should the Matcher clone shifts on addressing modes, expecting them +// to be subsumed into complex addressing expressions or compute them +// into registers? +bool Matcher::clone_address_expressions(AddPNode* m, Matcher::MStack& mstack, VectorSet& address_visited) { + return clone_base_plus_offset_address(m, mstack, address_visited); +} + +void Compile::reshape_address(AddPNode* addp) { +} + // Optimize load-acquire. // // Check if acquire is unnecessary due to following operation that does @@ -2157,11 +2167,6 @@ const int Matcher::float_cmove_cost() { return ConditionalMoveLimit; } // Power6 requires postalloc expand (see block.cpp for description of postalloc expand). const bool Matcher::require_postalloc_expand = true; -// Should the Matcher clone shifts on addressing modes, expecting them to -// be subsumed into complex addressing expressions or compute them into -// registers? True for Intel but false for most RISCs. -const bool Matcher::clone_shift_expressions = false; - // Do we need to mask the count passed to shift instructions or does // the cpu only look at the lower 5/6 bits anyway? // PowerPC requires masked shift counts. diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad index 7e610507004..653da26ba0b 100644 --- a/hotspot/src/cpu/sparc/vm/sparc.ad +++ b/hotspot/src/cpu/sparc/vm/sparc.ad @@ -1995,11 +1995,6 @@ const int Matcher::float_cmove_cost() { // Does the CPU require late expand (see block.cpp for description of late expand)? const bool Matcher::require_postalloc_expand = false; -// Should the Matcher clone shifts on addressing modes, expecting them to -// be subsumed into complex addressing expressions or compute them into -// registers? True for Intel but false for most RISCs -const bool Matcher::clone_shift_expressions = false; - // Do we need to mask the count passed to shift instructions or does // the cpu only look at the lower 5/6 bits anyway? const bool Matcher::need_masked_shift_count = false; @@ -2133,8 +2128,19 @@ const RegMask Matcher::method_handle_invoke_SP_save_mask() { return L7_REGP_mask(); } + const bool Matcher::convi2l_type_required = true; +// Should the Matcher clone shifts on addressing modes, expecting them +// to be subsumed into complex addressing expressions or compute them +// into registers? +bool Matcher::clone_address_expressions(AddPNode* m, Matcher::MStack& mstack, VectorSet& address_visited) { + return clone_base_plus_offset_address(m, mstack, address_visited); +} + +void Compile::reshape_address(AddPNode* addp) { +} + %} diff --git a/hotspot/src/cpu/x86/vm/x86.ad b/hotspot/src/cpu/x86/vm/x86.ad index dc9a734c7f1..ce14f4c742e 100644 --- a/hotspot/src/cpu/x86/vm/x86.ad +++ b/hotspot/src/cpu/x86/vm/x86.ad @@ -1586,6 +1586,8 @@ class HandlerImpl { source %{ +#include "opto/addnode.hpp" + // Emit exception handler code. // Stuff framesize into a register and call a VM stub routine. int HandlerImpl::emit_exception_handler(CodeBuffer& cbuf) { @@ -1861,8 +1863,79 @@ const bool Matcher::pass_original_key_for_aes() { return false; } + const bool Matcher::convi2l_type_required = true; +// Check for shift by small constant as well +static bool clone_shift(Node* shift, Matcher* matcher, Matcher::MStack& mstack, VectorSet& address_visited) { + if (shift->Opcode() == Op_LShiftX && shift->in(2)->is_Con() && + shift->in(2)->get_int() <= 3 && + // Are there other uses besides address expressions? + !matcher->is_visited(shift)) { + address_visited.set(shift->_idx); // Flag as address_visited + mstack.push(shift->in(2), Matcher::Visit); + Node *conv = shift->in(1); +#ifdef _LP64 + // Allow Matcher to match the rule which bypass + // ConvI2L operation for an array index on LP64 + // if the index value is positive. + if (conv->Opcode() == Op_ConvI2L && + conv->as_Type()->type()->is_long()->_lo >= 0 && + // Are there other uses besides address expressions? + !matcher->is_visited(conv)) { + address_visited.set(conv->_idx); // Flag as address_visited + mstack.push(conv->in(1), Matcher::Pre_Visit); + } else +#endif + mstack.push(conv, Matcher::Pre_Visit); + return true; + } + return false; +} + +// Should the Matcher clone shifts on addressing modes, expecting them +// to be subsumed into complex addressing expressions or compute them +// into registers? +bool Matcher::clone_address_expressions(AddPNode* m, Matcher::MStack& mstack, VectorSet& address_visited) { + Node *off = m->in(AddPNode::Offset); + if (off->is_Con()) { + address_visited.test_set(m->_idx); // Flag as address_visited + Node *adr = m->in(AddPNode::Address); + + // Intel can handle 2 adds in addressing mode + // AtomicAdd is not an addressing expression. + // Cheap to find it by looking for screwy base. + if (adr->is_AddP() && + !adr->in(AddPNode::Base)->is_top() && + // Are there other uses besides address expressions? + !is_visited(adr)) { + address_visited.set(adr->_idx); // Flag as address_visited + Node *shift = adr->in(AddPNode::Offset); + if (!clone_shift(shift, this, mstack, address_visited)) { + mstack.push(shift, Pre_Visit); + } + mstack.push(adr->in(AddPNode::Address), Pre_Visit); + mstack.push(adr->in(AddPNode::Base), Pre_Visit); + } else { + mstack.push(adr, Pre_Visit); + } + + // Clone X+offset as it also folds into most addressing expressions + mstack.push(off, Visit); + mstack.push(m->in(AddPNode::Base), Pre_Visit); + return true; + } else if (clone_shift(off, this, mstack, address_visited)) { + address_visited.test_set(m->_idx); // Flag as address_visited + mstack.push(m->in(AddPNode::Address), Pre_Visit); + mstack.push(m->in(AddPNode::Base), Pre_Visit); + return true; + } + return false; +} + +void Compile::reshape_address(AddPNode* addp) { +} + // Helper methods for MachSpillCopyNode::implementation(). static int vec_mov_helper(CodeBuffer *cbuf, bool do_size, int src_lo, int dst_lo, int src_hi, int dst_hi, uint ireg, outputStream* st) { diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad index 883d2bf6823..a45cb554e3c 100644 --- a/hotspot/src/cpu/x86/vm/x86_32.ad +++ b/hotspot/src/cpu/x86/vm/x86_32.ad @@ -1438,11 +1438,6 @@ const int Matcher::float_cmove_cost() { return (UseSSE>=1) ? ConditionalMoveLimi // Does the CPU require late expand (see block.cpp for description of late expand)? const bool Matcher::require_postalloc_expand = false; -// Should the Matcher clone shifts on addressing modes, expecting them to -// be subsumed into complex addressing expressions or compute them into -// registers? True for Intel but false for most RISCs -const bool Matcher::clone_shift_expressions = true; - // Do we need to mask the count passed to shift instructions or does // the cpu only look at the lower 5/6 bits anyway? const bool Matcher::need_masked_shift_count = false; diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad index d8409a2ddd2..a680d60e994 100644 --- a/hotspot/src/cpu/x86/vm/x86_64.ad +++ b/hotspot/src/cpu/x86/vm/x86_64.ad @@ -1646,11 +1646,6 @@ const int Matcher::float_cmove_cost() { return ConditionalMoveLimit; } // Does the CPU require late expand (see block.cpp for description of late expand)? const bool Matcher::require_postalloc_expand = false; -// Should the Matcher clone shifts on addressing modes, expecting them -// to be subsumed into complex addressing expressions or compute them -// into registers? True for Intel but false for most RISCs -const bool Matcher::clone_shift_expressions = true; - // Do we need to mask the count passed to shift instructions or does // the cpu only look at the lower 5/6 bits anyway? const bool Matcher::need_masked_shift_count = false; diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index cecd3098214..5e1e50ef6af 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -2905,6 +2905,8 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { } } #endif + // platform dependent reshaping of the address expression + reshape_address(n->as_AddP()); break; } diff --git a/hotspot/src/share/vm/opto/compile.hpp b/hotspot/src/share/vm/opto/compile.hpp index 3cbbf51cd1d..f8743d86ba9 100644 --- a/hotspot/src/share/vm/opto/compile.hpp +++ b/hotspot/src/share/vm/opto/compile.hpp @@ -44,6 +44,7 @@ #include "trace/tracing.hpp" #include "utilities/ticks.hpp" +class AddPNode; class Block; class Bundle; class C2Compiler; @@ -579,6 +580,8 @@ class Compile : public Phase { int _scratch_const_size; // For temporary code buffers. bool _in_scratch_emit_size; // true when in scratch_emit_size. + void reshape_address(AddPNode* n); + public: // Accessors diff --git a/hotspot/src/share/vm/opto/matcher.cpp b/hotspot/src/share/vm/opto/matcher.cpp index fbf861a3c2e..44127f3bc23 100644 --- a/hotspot/src/share/vm/opto/matcher.cpp +++ b/hotspot/src/share/vm/opto/matcher.cpp @@ -963,44 +963,6 @@ static void match_alias_type(Compile* C, Node* n, Node* m) { } #endif - -//------------------------------MStack----------------------------------------- -// State and MStack class used in xform() and find_shared() iterative methods. -enum Node_State { Pre_Visit, // node has to be pre-visited - Visit, // visit node - Post_Visit, // post-visit node - Alt_Post_Visit // alternative post-visit path - }; - -class MStack: public Node_Stack { - public: - MStack(int size) : Node_Stack(size) { } - - void push(Node *n, Node_State ns) { - Node_Stack::push(n, (uint)ns); - } - void push(Node *n, Node_State ns, Node *parent, int indx) { - ++_inode_top; - if ((_inode_top + 1) >= _inode_max) grow(); - _inode_top->node = parent; - _inode_top->indx = (uint)indx; - ++_inode_top; - _inode_top->node = n; - _inode_top->indx = (uint)ns; - } - Node *parent() { - pop(); - return node(); - } - Node_State state() const { - return (Node_State)index(); - } - void set_state(Node_State ns) { - set_index((uint)ns); - } -}; - - //------------------------------xform------------------------------------------ // Given a Node in old-space, Match him (Label/Reduce) to produce a machine // Node in new-space. Given a new-space Node, recursively walk his children. @@ -2046,37 +2008,22 @@ bool Matcher::is_bmi_pattern(Node *n, Node *m) { } #endif // X86 -// A method-klass-holder may be passed in the inline_cache_reg -// and then expanded into the inline_cache_reg and a method_oop register -// defined in ad_.cpp - -// Check for shift by small constant as well -static bool clone_shift(Node* shift, Matcher* matcher, MStack& mstack, VectorSet& address_visited) { - if (shift->Opcode() == Op_LShiftX && shift->in(2)->is_Con() && - shift->in(2)->get_int() <= 3 && - // Are there other uses besides address expressions? - !matcher->is_visited(shift)) { - address_visited.set(shift->_idx); // Flag as address_visited - mstack.push(shift->in(2), Visit); - Node *conv = shift->in(1); -#ifdef _LP64 - // Allow Matcher to match the rule which bypass - // ConvI2L operation for an array index on LP64 - // if the index value is positive. - if (conv->Opcode() == Op_ConvI2L && - conv->as_Type()->type()->is_long()->_lo >= 0 && - // Are there other uses besides address expressions? - !matcher->is_visited(conv)) { - address_visited.set(conv->_idx); // Flag as address_visited - mstack.push(conv->in(1), Pre_Visit); - } else -#endif - mstack.push(conv, Pre_Visit); +bool Matcher::clone_base_plus_offset_address(AddPNode* m, Matcher::MStack& mstack, VectorSet& address_visited) { + Node *off = m->in(AddPNode::Offset); + if (off->is_Con()) { + address_visited.test_set(m->_idx); // Flag as address_visited + mstack.push(m->in(AddPNode::Address), Pre_Visit); + // Clone X+offset as it also folds into most addressing expressions + mstack.push(off, Visit); + mstack.push(m->in(AddPNode::Base), Pre_Visit); return true; } return false; } +// A method-klass-holder may be passed in the inline_cache_reg +// and then expanded into the inline_cache_reg and a method_oop register +// defined in ad_.cpp //------------------------------find_shared------------------------------------ // Set bits if Node is shared or otherwise a root @@ -2251,40 +2198,9 @@ void Matcher::find_shared( Node *n ) { // But they should be marked as shared if there are other uses // besides address expressions. - Node *off = m->in(AddPNode::Offset); - if (off->is_Con()) { - address_visited.test_set(m->_idx); // Flag as address_visited - Node *adr = m->in(AddPNode::Address); - - // Intel, ARM and friends can handle 2 adds in addressing mode - if( clone_shift_expressions && adr->is_AddP() && - // AtomicAdd is not an addressing expression. - // Cheap to find it by looking for screwy base. - !adr->in(AddPNode::Base)->is_top() && - // Are there other uses besides address expressions? - !is_visited(adr) ) { - address_visited.set(adr->_idx); // Flag as address_visited - Node *shift = adr->in(AddPNode::Offset); - if (!clone_shift(shift, this, mstack, address_visited)) { - mstack.push(shift, Pre_Visit); - } - mstack.push(adr->in(AddPNode::Address), Pre_Visit); - mstack.push(adr->in(AddPNode::Base), Pre_Visit); - } else { // Sparc, Alpha, PPC and friends - mstack.push(adr, Pre_Visit); - } - - // Clone X+offset as it also folds into most addressing expressions - mstack.push(off, Visit); - mstack.push(m->in(AddPNode::Base), Pre_Visit); - continue; // for(int i = ...) - } else if (clone_shift_expressions && - clone_shift(off, this, mstack, address_visited)) { - address_visited.test_set(m->_idx); // Flag as address_visited - mstack.push(m->in(AddPNode::Address), Pre_Visit); - mstack.push(m->in(AddPNode::Base), Pre_Visit); - continue; - } // if( off->is_Con() ) + if (clone_address_expressions(m->as_AddP(), mstack, address_visited)) { + continue; + } } // if( mem_op && mstack.push(m, Pre_Visit); } // for(int i = ...) diff --git a/hotspot/src/share/vm/opto/matcher.hpp b/hotspot/src/share/vm/opto/matcher.hpp index aa9311d7788..74d7361d08c 100644 --- a/hotspot/src/share/vm/opto/matcher.hpp +++ b/hotspot/src/share/vm/opto/matcher.hpp @@ -40,6 +40,45 @@ class MachOper; //---------------------------Matcher------------------------------------------- class Matcher : public PhaseTransform { friend class VMStructs; + +public: + + // State and MStack class used in xform() and find_shared() iterative methods. + enum Node_State { Pre_Visit, // node has to be pre-visited + Visit, // visit node + Post_Visit, // post-visit node + Alt_Post_Visit // alternative post-visit path + }; + + class MStack: public Node_Stack { + public: + MStack(int size) : Node_Stack(size) { } + + void push(Node *n, Node_State ns) { + Node_Stack::push(n, (uint)ns); + } + void push(Node *n, Node_State ns, Node *parent, int indx) { + ++_inode_top; + if ((_inode_top + 1) >= _inode_max) grow(); + _inode_top->node = parent; + _inode_top->indx = (uint)indx; + ++_inode_top; + _inode_top->node = n; + _inode_top->indx = (uint)ns; + } + Node *parent() { + pop(); + return node(); + } + Node_State state() const { + return (Node_State)index(); + } + void set_state(Node_State ns) { + set_index((uint)ns); + } + }; + +private: // Private arena of State objects ResourceArea _states_arena; @@ -411,7 +450,9 @@ public: // Should the Matcher clone shifts on addressing modes, expecting them to // be subsumed into complex addressing expressions or compute them into // registers? True for Intel but false for most RISCs - static const bool clone_shift_expressions; + bool clone_address_expressions(AddPNode* m, MStack& mstack, VectorSet& address_visited); + // Clone base + offset address expression + bool clone_base_plus_offset_address(AddPNode* m, MStack& mstack, VectorSet& address_visited); static bool narrow_oop_use_complex_address(); static bool narrow_klass_use_complex_address(); -- GitLab From fef5de6f41924bddacc7fb5d866cb10405e1edbb Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Mon, 9 May 2016 12:20:02 -0700 Subject: [PATCH 318/400] 8155574: ClassLoader::initialize_module_loader_map crashes if the char_buf is not NULL terminated Reviewed-by: jiangli, iklam --- hotspot/src/share/vm/classfile/classLoader.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 3145992e86d..58ad06fc9bc 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -1057,7 +1057,8 @@ void ClassLoader::initialize_module_loader_map(JImageFile* jimage) { vm_exit_during_initialization( "Cannot find ModuleLoaderMap location from modules jimage.", NULL); } - char* buffer = NEW_RESOURCE_ARRAY(char, size); + char* buffer = NEW_RESOURCE_ARRAY(char, size + 1); + buffer[size] = '\0'; jlong read = (*JImageGetResource)(jimage, location, buffer, size); if (read != size) { vm_exit_during_initialization( -- GitLab From 2523b1942a76d36dd2d31f4c84e1cda376b2ffe6 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Mon, 9 May 2016 22:22:15 +0200 Subject: [PATCH 319/400] 8153535: Convert TraceRedefineClasses to Unified Logging Reviewed-by: rprotacio, coleenp --- .../cpu/aarch64/vm/interp_masm_aarch64.cpp | 4 +- .../cpu/aarch64/vm/sharedRuntime_aarch64.cpp | 4 +- hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp | 1 - .../src/cpu/sparc/vm/interp_masm_sparc.cpp | 4 +- .../src/cpu/sparc/vm/sharedRuntime_sparc.cpp | 4 +- hotspot/src/cpu/x86/vm/interp_masm_x86.cpp | 4 +- .../src/cpu/x86/vm/sharedRuntime_x86_32.cpp | 4 +- .../src/cpu/x86/vm/sharedRuntime_x86_64.cpp | 4 +- .../src/cpu/zero/vm/sharedRuntime_zero.cpp | 1 - hotspot/src/share/vm/classfile/dictionary.cpp | 1 - .../src/share/vm/classfile/javaClasses.cpp | 1 - hotspot/src/share/vm/code/nmethod.cpp | 23 +- .../src/share/vm/interpreter/oopMapCache.cpp | 12 +- hotspot/src/share/vm/logging/logTag.hpp | 21 +- hotspot/src/share/vm/memory/universe.cpp | 1 - hotspot/src/share/vm/oops/cpCache.cpp | 28 +- hotspot/src/share/vm/oops/instanceKlass.cpp | 66 +- hotspot/src/share/vm/oops/klassVtable.cpp | 32 +- hotspot/src/share/vm/prims/jvmtiImpl.cpp | 9 +- .../share/vm/prims/jvmtiRedefineClasses.cpp | 626 +++++++----------- .../share/vm/prims/jvmtiRedefineClasses.hpp | 1 - .../vm/prims/jvmtiRedefineClassesTrace.hpp | 138 ---- .../src/share/vm/prims/methodComparator.cpp | 11 +- hotspot/src/share/vm/prims/methodHandles.cpp | 15 +- hotspot/src/share/vm/runtime/arguments.cpp | 10 +- hotspot/src/share/vm/runtime/globals.hpp | 4 - .../src/share/vm/runtime/sharedRuntime.cpp | 18 +- 27 files changed, 394 insertions(+), 653 deletions(-) delete mode 100644 hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp diff --git a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp index 882cccceb2b..22712102137 100644 --- a/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/interp_masm_aarch64.cpp @@ -27,12 +27,12 @@ #include "interp_masm_aarch64.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interpreterRuntime.hpp" +#include "logging/log.hpp" #include "oops/arrayOop.hpp" #include "oops/markOop.hpp" #include "oops/methodData.hpp" #include "oops/method.hpp" #include "prims/jvmtiExport.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "prims/jvmtiThreadState.hpp" #include "runtime/basicLock.hpp" #include "runtime/biasedLocking.hpp" @@ -1450,7 +1450,7 @@ void InterpreterMacroAssembler::notify_method_entry() { } // RedefineClasses() tracing support for obsolete method entry - if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) { + if (log_is_enabled(Trace, redefine, class, obsolete)) { get_method(c_rarg1); call_VM_leaf( CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry), diff --git a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp index 760256da378..6a5bb7a66b7 100644 --- a/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp +++ b/hotspot/src/cpu/aarch64/vm/sharedRuntime_aarch64.cpp @@ -31,9 +31,9 @@ #include "code/vtableStubs.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interp_masm.hpp" +#include "logging/log.hpp" #include "memory/resourceArea.hpp" #include "oops/compiledICHolder.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/vframeArray.hpp" #include "vmreg_aarch64.inline.hpp" @@ -1781,7 +1781,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, } // RedefineClasses() tracing support for obsolete method entry - if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) { + if (log_is_enabled(Trace, redefine, class, obsolete)) { // protect the args we've loaded save_args(masm, total_c_args, c_arg, out_regs); __ mov_metadata(c_rarg1, method()); diff --git a/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp b/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp index ee8685f4f0a..38c83d39e65 100644 --- a/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp +++ b/hotspot/src/cpu/ppc/vm/sharedRuntime_ppc.cpp @@ -33,7 +33,6 @@ #include "interpreter/interp_masm.hpp" #include "memory/resourceArea.hpp" #include "oops/compiledICHolder.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/vframeArray.hpp" #include "vmreg_ppc.inline.hpp" diff --git a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp index 580b1336bf3..ba25825ca5a 100644 --- a/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/interp_masm_sparc.cpp @@ -26,13 +26,13 @@ #include "interp_masm_sparc.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interpreterRuntime.hpp" +#include "logging/log.hpp" #include "oops/arrayOop.hpp" #include "oops/markOop.hpp" #include "oops/methodData.hpp" #include "oops/method.hpp" #include "oops/methodCounters.hpp" #include "prims/jvmtiExport.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "prims/jvmtiThreadState.hpp" #include "runtime/basicLock.hpp" #include "runtime/biasedLocking.hpp" @@ -2645,7 +2645,7 @@ void InterpreterMacroAssembler::notify_method_entry() { } // RedefineClasses() tracing support for obsolete method entry - if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) { + if (log_is_enabled(Trace, redefine, class, obsolete)) { call_VM_leaf(noreg, CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry), G2_thread, Lmethod); diff --git a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp index 6727c14d63b..a587b55762e 100644 --- a/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/sharedRuntime_sparc.cpp @@ -28,9 +28,9 @@ #include "code/icBuffer.hpp" #include "code/vtableStubs.hpp" #include "interpreter/interpreter.hpp" +#include "logging/log.hpp" #include "memory/resourceArea.hpp" #include "oops/compiledICHolder.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/vframeArray.hpp" #include "vmreg_sparc.inline.hpp" @@ -2450,7 +2450,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, } // RedefineClasses() tracing support for obsolete method entry - if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) { + if (log_is_enabled(Trace, redefine, class, obsolete)) { // create inner frame __ save_frame(0); __ mov(G2_thread, L7_thread_cache); diff --git a/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp b/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp index f8578f9f420..15cf1f751a7 100644 --- a/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp +++ b/hotspot/src/cpu/x86/vm/interp_masm_x86.cpp @@ -26,12 +26,12 @@ #include "interp_masm_x86.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/interpreterRuntime.hpp" +#include "logging/log.hpp" #include "oops/arrayOop.hpp" #include "oops/markOop.hpp" #include "oops/methodData.hpp" #include "oops/method.hpp" #include "prims/jvmtiExport.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "prims/jvmtiThreadState.hpp" #include "runtime/basicLock.hpp" #include "runtime/biasedLocking.hpp" @@ -1953,7 +1953,7 @@ void InterpreterMacroAssembler::notify_method_entry() { } // RedefineClasses() tracing support for obsolete method entry - if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) { + if (log_is_enabled(Trace, redefine, class, obsolete)) { NOT_LP64(get_thread(rthread);) get_method(rarg); call_VM_leaf( diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp index 3763b058b8b..a24397f4c8f 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp @@ -29,9 +29,9 @@ #include "code/icBuffer.hpp" #include "code/vtableStubs.hpp" #include "interpreter/interpreter.hpp" +#include "logging/log.hpp" #include "memory/resourceArea.hpp" #include "oops/compiledICHolder.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/vframeArray.hpp" #include "vmreg_x86.inline.hpp" @@ -1953,7 +1953,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, } // RedefineClasses() tracing support for obsolete method entry - if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) { + if (log_is_enabled(Trace, redefine, class, obsolete)) { __ mov_metadata(rax, method()); __ call_VM_leaf( CAST_FROM_FN_PTR(address, SharedRuntime::rc_trace_method_entry), diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp index 8fca552dd34..81ed472f462 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp @@ -32,9 +32,9 @@ #include "code/icBuffer.hpp" #include "code/vtableStubs.hpp" #include "interpreter/interpreter.hpp" +#include "logging/log.hpp" #include "memory/resourceArea.hpp" #include "oops/compiledICHolder.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/vframeArray.hpp" #include "vmreg_x86.inline.hpp" @@ -2322,7 +2322,7 @@ nmethod* SharedRuntime::generate_native_wrapper(MacroAssembler* masm, } // RedefineClasses() tracing support for obsolete method entry - if (RC_TRACE_IN_RANGE(0x00001000, 0x00002000)) { + if (log_is_enabled(Trace, redefine, class, obsolete)) { // protect the args we've loaded save_args(masm, total_c_args, c_arg, out_regs); __ mov_metadata(c_rarg1, method()); diff --git a/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp b/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp index 0fb36b01b75..27b96b57bec 100644 --- a/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp +++ b/hotspot/src/cpu/zero/vm/sharedRuntime_zero.cpp @@ -31,7 +31,6 @@ #include "code/vtableStubs.hpp" #include "interpreter/interpreter.hpp" #include "oops/compiledICHolder.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/sharedRuntime.hpp" #include "runtime/vframeArray.hpp" #include "vmreg_zero.inline.hpp" diff --git a/hotspot/src/share/vm/classfile/dictionary.cpp b/hotspot/src/share/vm/classfile/dictionary.cpp index ee351942cb5..c7ea145c3d2 100644 --- a/hotspot/src/share/vm/classfile/dictionary.cpp +++ b/hotspot/src/share/vm/classfile/dictionary.cpp @@ -31,7 +31,6 @@ #include "memory/iterator.hpp" #include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/orderAccess.inline.hpp" #include "utilities/hashtable.inline.hpp" diff --git a/hotspot/src/share/vm/classfile/javaClasses.cpp b/hotspot/src/share/vm/classfile/javaClasses.cpp index 70b9d4d1525..b99c918996d 100644 --- a/hotspot/src/share/vm/classfile/javaClasses.cpp +++ b/hotspot/src/share/vm/classfile/javaClasses.cpp @@ -45,7 +45,6 @@ #include "oops/oop.inline.hpp" #include "oops/symbol.hpp" #include "oops/typeArrayOop.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/fieldDescriptor.hpp" #include "runtime/handles.inline.hpp" #include "runtime/interfaceSupport.hpp" diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 3a20bc0bd21..e15e7324cf9 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -36,10 +36,10 @@ #include "compiler/directivesParser.hpp" #include "compiler/disassembler.hpp" #include "interpreter/bytecode.hpp" +#include "logging/log.hpp" #include "memory/resourceArea.hpp" #include "oops/methodData.hpp" #include "oops/oop.inline.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "prims/jvmtiImpl.hpp" #include "runtime/atomic.inline.hpp" #include "runtime/orderAccess.inline.hpp" @@ -2001,15 +2001,18 @@ bool nmethod::is_evol_dependent_on(Klass* dependee) { Method* method = deps.method_argument(0); for (int j = 0; j < dependee_methods->length(); j++) { if (dependee_methods->at(j) == method) { - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE(0x01000000, - ("Found evol dependency of nmethod %s.%s(%s) compile_id=%d on method %s.%s(%s)", - _method->method_holder()->external_name(), - _method->name()->as_C_string(), - _method->signature()->as_C_string(), compile_id(), - method->method_holder()->external_name(), - method->name()->as_C_string(), - method->signature()->as_C_string())); + if (log_is_enabled(Debug, redefine, class, nmethod)) { + ResourceMark rm; + log_debug(redefine, class, nmethod) + ("Found evol dependency of nmethod %s.%s(%s) compile_id=%d on method %s.%s(%s)", + _method->method_holder()->external_name(), + _method->name()->as_C_string(), + _method->signature()->as_C_string(), + compile_id(), + method->method_holder()->external_name(), + method->name()->as_C_string(), + method->signature()->as_C_string()); + } if (TraceDependencies || LogCompilation) deps.log_dependency(dependee); return true; diff --git a/hotspot/src/share/vm/interpreter/oopMapCache.cpp b/hotspot/src/share/vm/interpreter/oopMapCache.cpp index 7dcf024532e..a32949ad340 100644 --- a/hotspot/src/share/vm/interpreter/oopMapCache.cpp +++ b/hotspot/src/share/vm/interpreter/oopMapCache.cpp @@ -24,10 +24,10 @@ #include "precompiled.hpp" #include "interpreter/oopMapCache.hpp" +#include "logging/log.hpp" #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" #include "oops/oop.inline.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/handles.inline.hpp" #include "runtime/signature.hpp" @@ -469,10 +469,12 @@ void OopMapCache::flush_obsolete_entries() { if (!_array[i].is_empty() && _array[i].method()->is_old()) { // Cache entry is occupied by an old redefined method and we don't want // to pin it down so flush the entry. - RC_TRACE(0x08000000, ("flush: %s(%s): cached entry @%d", - _array[i].method()->name()->as_C_string(), - _array[i].method()->signature()->as_C_string(), i)); - + if (log_is_enabled(Debug, redefine, class, oopmap)) { + ResourceMark rm; + log_debug(redefine, class, oopmap) + ("flush: %s(%s): cached entry @%d", + _array[i].method()->name()->as_C_string(), _array[i].method()->signature()->as_C_string(), i); + } _array[i].flush(); } } diff --git a/hotspot/src/share/vm/logging/logTag.hpp b/hotspot/src/share/vm/logging/logTag.hpp index 5e7cbbc9ea4..f5dc582c6b5 100644 --- a/hotspot/src/share/vm/logging/logTag.hpp +++ b/hotspot/src/share/vm/logging/logTag.hpp @@ -32,23 +32,28 @@ // (The tags 'all', 'disable' and 'help' are special tags that can // not be used in log calls, and should not be listed below.) #define LOG_TAG_LIST \ - LOG_TAG(alloc) \ + LOG_TAG(add) \ LOG_TAG(age) \ + LOG_TAG(alloc) \ LOG_TAG(arguments) \ + LOG_TAG(annotation) \ LOG_TAG(barrier) \ LOG_TAG(biasedlocking) \ LOG_TAG(bot) \ + LOG_TAG(breakpoint) \ LOG_TAG(census) \ LOG_TAG(class) \ LOG_TAG(classhisto) \ LOG_TAG(cleanup) \ LOG_TAG(compaction) \ LOG_TAG(constraints) \ + LOG_TAG(constantpool) \ LOG_TAG(coops) \ LOG_TAG(cpu) \ LOG_TAG(cset) \ LOG_TAG(data) \ LOG_TAG(defaultmethods) \ + LOG_TAG(dump) \ LOG_TAG(ergo) \ LOG_TAG(exceptions) \ LOG_TAG(exit) \ @@ -57,6 +62,7 @@ LOG_TAG(heap) \ LOG_TAG(humongous) \ LOG_TAG(ihop) \ + LOG_TAG(iklass) \ LOG_TAG(init) \ LOG_TAG(itables) \ LOG_TAG(jni) \ @@ -65,13 +71,20 @@ LOG_TAG(load) /* Trace all classes loaded */ \ LOG_TAG(loader) \ LOG_TAG(logging) \ + LOG_TAG(mark) \ LOG_TAG(marking) \ + LOG_TAG(methodcomparator) \ + LOG_TAG(metadata) \ LOG_TAG(metaspace) \ LOG_TAG(mmu) \ LOG_TAG(modules) \ LOG_TAG(monitorinflation) \ LOG_TAG(monitormismatch) \ + LOG_TAG(nmethod) \ + LOG_TAG(normalize) \ LOG_TAG(objecttagging) \ + LOG_TAG(obsolete) \ + LOG_TAG(oopmap) \ LOG_TAG(os) \ LOG_TAG(pagesize) \ LOG_TAG(path) \ @@ -81,9 +94,11 @@ LOG_TAG(preorder) /* Trace all classes loaded in order referenced (not loaded) */ \ LOG_TAG(protectiondomain) /* "Trace protection domain verification" */ \ LOG_TAG(ref) \ + LOG_TAG(redefine) \ LOG_TAG(refine) \ LOG_TAG(region) \ LOG_TAG(remset) \ + LOG_TAG(purge) \ LOG_TAG(resolve) \ LOG_TAG(safepoint) \ LOG_TAG(scavenge) \ @@ -95,6 +110,8 @@ LOG_TAG(stats) \ LOG_TAG(stringdedup) \ LOG_TAG(stringtable) \ + LOG_TAG(stackmap) \ + LOG_TAG(subclass) \ LOG_TAG(survivor) \ LOG_TAG(sweep) \ LOG_TAG(task) \ @@ -102,6 +119,8 @@ LOG_TAG(thread) \ LOG_TAG(tlab) \ LOG_TAG(time) \ + LOG_TAG(timer) \ + LOG_TAG(update) \ LOG_TAG(unload) /* Trace unloading of classes */ \ LOG_TAG(verification) \ LOG_TAG(verify) \ diff --git a/hotspot/src/share/vm/memory/universe.cpp b/hotspot/src/share/vm/memory/universe.cpp index 11037c539f0..9c17574bed9 100644 --- a/hotspot/src/share/vm/memory/universe.cpp +++ b/hotspot/src/share/vm/memory/universe.cpp @@ -55,7 +55,6 @@ #include "oops/objArrayOop.inline.hpp" #include "oops/oop.inline.hpp" #include "oops/typeArrayKlass.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/arguments.hpp" #include "runtime/atomic.inline.hpp" #include "runtime/commandLineFlagConstraintList.hpp" diff --git a/hotspot/src/share/vm/oops/cpCache.cpp b/hotspot/src/share/vm/oops/cpCache.cpp index 8418656e7b0..ee2425fc615 100644 --- a/hotspot/src/share/vm/oops/cpCache.cpp +++ b/hotspot/src/share/vm/oops/cpCache.cpp @@ -25,12 +25,12 @@ #include "precompiled.hpp" #include "interpreter/interpreter.hpp" #include "interpreter/rewriter.hpp" +#include "logging/log.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.inline.hpp" #include "oops/cpCache.hpp" #include "oops/objArrayOop.inline.hpp" #include "oops/oop.inline.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "prims/methodHandles.hpp" #include "runtime/atomic.inline.hpp" #include "runtime/handles.inline.hpp" @@ -438,17 +438,14 @@ bool ConstantPoolCacheEntry::adjust_method_entry(Method* old_method, // match old_method so need an update // NOTE: can't use set_f2_as_vfinal_method as it asserts on different values _f2 = (intptr_t)new_method; - if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) { + if (log_is_enabled(Info, redefine, class, update)) { + ResourceMark rm; if (!(*trace_name_printed)) { - // RC_TRACE_MESG macro has an embedded ResourceMark - RC_TRACE_MESG(("adjust: name=%s", - old_method->method_holder()->external_name())); + log_info(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name()); *trace_name_printed = true; } - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE(0x00400000, ("cpc vf-entry update: %s(%s)", - new_method->name()->as_C_string(), - new_method->signature()->as_C_string())); + log_debug(redefine, class, update, constantpool) + ("cpc vf-entry update: %s(%s)", new_method->name()->as_C_string(), new_method->signature()->as_C_string()); } return true; } @@ -465,17 +462,14 @@ bool ConstantPoolCacheEntry::adjust_method_entry(Method* old_method, if (_f1 == old_method) { _f1 = new_method; - if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) { + if (log_is_enabled(Info, redefine, class, update)) { + ResourceMark rm; if (!(*trace_name_printed)) { - // RC_TRACE_MESG macro has an embedded ResourceMark - RC_TRACE_MESG(("adjust: name=%s", - old_method->method_holder()->external_name())); + log_info(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name()); *trace_name_printed = true; } - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE(0x00400000, ("cpc entry update: %s(%s)", - new_method->name()->as_C_string(), - new_method->signature()->as_C_string())); + log_debug(redefine, class, update, constantpool) + ("cpc entry update: %s(%s)", new_method->name()->as_C_string(), new_method->signature()->as_C_string()); } return true; } diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 4726909957a..074fc0039d0 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -53,7 +53,6 @@ #include "oops/symbol.hpp" #include "prims/jvmtiExport.hpp" #include "prims/jvmtiRedefineClasses.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "prims/jvmtiThreadState.hpp" #include "prims/methodComparator.hpp" #include "runtime/atomic.inline.hpp" @@ -2574,17 +2573,17 @@ void InstanceKlass::adjust_default_methods(InstanceKlass* holder, bool* trace_na assert(old_method != new_method, "sanity check"); default_methods()->at_put(index, new_method); - if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) { + if (log_is_enabled(Info, redefine, class, update)) { + ResourceMark rm; if (!(*trace_name_printed)) { - // RC_TRACE_MESG macro has an embedded ResourceMark - RC_TRACE_MESG(("adjust: klassname=%s default methods from name=%s", - external_name(), - old_method->method_holder()->external_name())); + log_info(redefine, class, update) + ("adjust: klassname=%s default methods from name=%s", + external_name(), old_method->method_holder()->external_name()); *trace_name_printed = true; } - RC_TRACE(0x00100000, ("default method update: %s(%s) ", - new_method->name()->as_C_string(), - new_method->signature()->as_C_string())); + log_debug(redefine, class, update, vtables) + ("default method update: %s(%s) ", + new_method->name()->as_C_string(), new_method->signature()->as_C_string()); } } } @@ -3353,8 +3352,8 @@ void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { ClassLoaderData* loader_data = ik->class_loader_data(); assert(loader_data != NULL, "should never be null"); - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE(0x00000200, ("purge: %s: previous versions", ik->external_name())); + ResourceMark rm; + log_trace(redefine, class, iklass, purge)("%s: previous versions", ik->external_name()); // previous versions are linked together through the InstanceKlass InstanceKlass* pv_node = ik->previous_versions(); @@ -3372,8 +3371,7 @@ void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { // are executing. Unlink this previous_version. // The previous version InstanceKlass is on the ClassLoaderData deallocate list // so will be deallocated during the next phase of class unloading. - RC_TRACE(0x00000200, ("purge: previous version " INTPTR_FORMAT " is dead", - p2i(pv_node))); + log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is dead", p2i(pv_node)); // For debugging purposes. pv_node->set_is_scratch_class(); pv_node->class_loader_data()->add_to_deallocate_list(pv_node); @@ -3383,8 +3381,7 @@ void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { version++; continue; } else { - RC_TRACE(0x00000200, ("purge: previous version " INTPTR_FORMAT " is alive", - p2i(pv_node))); + log_trace(redefine, class, iklass, purge)("previous version " INTPTR_FORMAT " is alive", p2i(pv_node)); assert(pvcp->pool_holder() != NULL, "Constant pool with no holder"); guarantee (!loader_data->is_unloading(), "unloaded classes can't be on the stack"); live_count++; @@ -3396,8 +3393,7 @@ void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { // longer running. Array* method_refs = pv_node->methods(); if (method_refs != NULL) { - RC_TRACE(0x00000200, ("purge: previous methods length=%d", - method_refs->length())); + log_trace(redefine, class, iklass, purge)("previous methods length=%d", method_refs->length()); for (int j = 0; j < method_refs->length(); j++) { Method* method = method_refs->at(j); @@ -3409,11 +3405,9 @@ void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { } else { assert (method->is_obsolete() || method->is_running_emcp(), "emcp method cannot run after emcp bit is cleared"); - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE(0x00000200, + log_trace(redefine, class, iklass, purge) ("purge: %s(%s): prev method @%d in version @%d is alive", - method->name()->as_C_string(), - method->signature()->as_C_string(), j, version)); + method->name()->as_C_string(), method->signature()->as_C_string(), j, version); } } } @@ -3422,9 +3416,9 @@ void InstanceKlass::purge_previous_versions(InstanceKlass* ik) { pv_node = pv_node->previous_versions(); version++; } - RC_TRACE(0x00000200, - ("purge: previous version stats: live=%d, deleted=%d", live_count, - deleted_count)); + log_trace(redefine, class, iklass, purge) + ("previous version stats: live=%d, deleted=%d", + live_count, deleted_count); } } @@ -3459,9 +3453,9 @@ void InstanceKlass::mark_newly_obsolete_methods(Array* old_methods, method->signature() == m_signature) { // The current RedefineClasses() call has made all EMCP // versions of this method obsolete so mark it as obsolete - RC_TRACE(0x00000400, - ("add: %s(%s): flush obsolete method @%d in version @%d", - m_name->as_C_string(), m_signature->as_C_string(), k, j)); + log_trace(redefine, class, iklass, add) + ("%s(%s): flush obsolete method @%d in version @%d", + m_name->as_C_string(), m_signature->as_C_string(), k, j); method->set_is_obsolete(); break; @@ -3493,9 +3487,9 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, assert(Thread::current()->is_VM_thread(), "only VMThread can add previous versions"); - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE(0x00000400, ("adding previous version ref for %s, EMCP_cnt=%d", - scratch_class->external_name(), emcp_method_count)); + ResourceMark rm; + log_trace(redefine, class, iklass, add) + ("adding previous version ref for %s, EMCP_cnt=%d", scratch_class->external_name(), emcp_method_count); // Clean out old previous versions purge_previous_versions(this); @@ -3511,7 +3505,7 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, // we don't need to add this as a previous version. ConstantPool* cp_ref = scratch_class->constants(); if (!cp_ref->on_stack()) { - RC_TRACE(0x00000400, ("add: scratch class not added; no methods are running")); + log_trace(redefine, class, iklass, add)("scratch class not added; no methods are running"); // For debugging purposes. scratch_class->set_is_scratch_class(); scratch_class->class_loader_data()->add_to_deallocate_list(scratch_class()); @@ -3534,17 +3528,17 @@ void InstanceKlass::add_previous_version(instanceKlassHandle scratch_class, // method may exit. If so, we would set a breakpoint in a method that // is never reached, but this won't be noticeable to the programmer. old_method->set_running_emcp(true); - RC_TRACE(0x00000400, ("add: EMCP method %s is on_stack " INTPTR_FORMAT, - old_method->name_and_sig_as_C_string(), p2i(old_method))); + log_trace(redefine, class, iklass, add) + ("EMCP method %s is on_stack " INTPTR_FORMAT, old_method->name_and_sig_as_C_string(), p2i(old_method)); } else if (!old_method->is_obsolete()) { - RC_TRACE(0x00000400, ("add: EMCP method %s is NOT on_stack " INTPTR_FORMAT, - old_method->name_and_sig_as_C_string(), p2i(old_method))); + log_trace(redefine, class, iklass, add) + ("EMCP method %s is NOT on_stack " INTPTR_FORMAT, old_method->name_and_sig_as_C_string(), p2i(old_method)); } } } // Add previous version if any methods are still running. - RC_TRACE(0x00000400, ("add: scratch class added; one of its methods is on_stack")); + log_trace(redefine, class, iklass, add)("scratch class added; one of its methods is on_stack"); assert(scratch_class->previous_versions() == NULL, "shouldn't have a previous version"); scratch_class->link_previous_versions(previous_versions()); link_previous_versions(scratch_class()); diff --git a/hotspot/src/share/vm/oops/klassVtable.cpp b/hotspot/src/share/vm/oops/klassVtable.cpp index af4bde9b751..6d0c895f812 100644 --- a/hotspot/src/share/vm/oops/klassVtable.cpp +++ b/hotspot/src/share/vm/oops/klassVtable.cpp @@ -34,7 +34,6 @@ #include "oops/method.hpp" #include "oops/objArrayOop.hpp" #include "oops/oop.inline.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/arguments.hpp" #include "runtime/handles.inline.hpp" #include "utilities/copy.hpp" @@ -887,19 +886,17 @@ void klassVtable::adjust_method_entries(InstanceKlass* holder, bool * trace_name updated_default = adjust_default_method(index, old_method, new_method); } - if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) { + if (log_is_enabled(Info, redefine, class, update)) { + ResourceMark rm; if (!(*trace_name_printed)) { - // RC_TRACE_MESG macro has an embedded ResourceMark - RC_TRACE_MESG(("adjust: klassname=%s for methods from name=%s", - klass()->external_name(), - old_method->method_holder()->external_name())); + log_info(redefine, class, update) + ("adjust: klassname=%s for methods from name=%s", + klass()->external_name(), old_method->method_holder()->external_name()); *trace_name_printed = true; } - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE(0x00100000, ("vtable method update: %s(%s), updated default = %s", - new_method->name()->as_C_string(), - new_method->signature()->as_C_string(), - updated_default ? "true" : "false")); + log_debug(redefine, class, update, vtables) + ("vtable method update: %s(%s), updated default = %s", + new_method->name()->as_C_string(), new_method->signature()->as_C_string(), updated_default ? "true" : "false"); } } } @@ -1205,17 +1202,14 @@ void klassItable::adjust_method_entries(InstanceKlass* holder, bool * trace_name ime->initialize(new_method); - if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) { + if (log_is_enabled(Info, redefine, class, update)) { + ResourceMark rm; if (!(*trace_name_printed)) { - // RC_TRACE_MESG macro has an embedded ResourceMark - RC_TRACE_MESG(("adjust: name=%s", - old_method->method_holder()->external_name())); + log_info(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name()); *trace_name_printed = true; } - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE(0x00200000, ("itable method update: %s(%s)", - new_method->name()->as_C_string(), - new_method->signature()->as_C_string())); + log_trace(redefine, class, update, itables) + ("itable method update: %s(%s)", new_method->name()->as_C_string(), new_method->signature()->as_C_string()); } } } diff --git a/hotspot/src/share/vm/prims/jvmtiImpl.cpp b/hotspot/src/share/vm/prims/jvmtiImpl.cpp index 34c07ee3a44..398f5720b13 100644 --- a/hotspot/src/share/vm/prims/jvmtiImpl.cpp +++ b/hotspot/src/share/vm/prims/jvmtiImpl.cpp @@ -303,11 +303,10 @@ void JvmtiBreakpoint::each_method_version_do(method_action meth_act) { if (method->is_running_emcp() && method->name() == m_name && method->signature() == m_signature) { - RC_TRACE(0x00000800, ("%sing breakpoint in %s(%s)", - meth_act == &Method::set_breakpoint ? "sett" : "clear", - method->name()->as_C_string(), - method->signature()->as_C_string())); - + ResourceMark rm; + log_debug(redefine, class, breakpoint) + ("%sing breakpoint in %s(%s)", meth_act == &Method::set_breakpoint ? "sett" : "clear", + method->name()->as_C_string(), method->signature()->as_C_string()); (method->*meth_act)(_bci); break; } diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp index acbff95f44c..185270bf5f3 100644 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp @@ -32,6 +32,7 @@ #include "gc/shared/gcLocker.hpp" #include "interpreter/oopMapCache.hpp" #include "interpreter/rewriter.hpp" +#include "logging/logStream.hpp" #include "memory/metadataFactory.hpp" #include "memory/metaspaceShared.hpp" #include "memory/resourceArea.hpp" @@ -94,7 +95,9 @@ bool VM_RedefineClasses::doit_prologue() { // Start timer after all the sanity checks; not quite accurate, but // better than adding a bunch of stop() calls. - RC_TIMER_START(_timer_vm_op_prologue); + if (log_is_enabled(Info, redefine, class, timer)) { + _timer_vm_op_prologue.start(); + } // We first load new class versions in the prologue, because somewhere down the // call chain it is required that the current thread is a Java thread. @@ -111,11 +114,11 @@ bool VM_RedefineClasses::doit_prologue() { } // Free os::malloc allocated memory in load_new_class_version. os::free(_scratch_classes); - RC_TIMER_STOP(_timer_vm_op_prologue); + _timer_vm_op_prologue.stop(); return false; } - RC_TIMER_STOP(_timer_vm_op_prologue); + _timer_vm_op_prologue.stop(); return true; } @@ -128,8 +131,7 @@ void VM_RedefineClasses::doit() { // a shared class. We do the remap during the doit() phase of // the safepoint to be safer. if (!MetaspaceShared::remap_shared_readonly_as_readwrite()) { - RC_TRACE_WITH_THREAD(0x00000001, thread, - ("failed to remap shared readonly space to readwrite, private")); + log_info(redefine, class, load)("failed to remap shared readonly space to readwrite, private"); _res = JVMTI_ERROR_INTERNAL; return; } @@ -161,9 +163,9 @@ void VM_RedefineClasses::doit() { // check_class() is optionally called for product bits, but is // always called for non-product bits. #ifdef PRODUCT - if (RC_TRACE_ENABLED(0x00004000)) { + if (log_is_enabled(Trace, redefine, class, obsolete, metadata)) { #endif - RC_TRACE_WITH_THREAD(0x00004000, thread, ("calling check_class")); + log_trace(redefine, class, obsolete, metadata)("calling check_class"); CheckClass check_class(thread); ClassLoaderDataGraph::classes_do(&check_class); #ifdef PRODUCT @@ -178,19 +180,19 @@ void VM_RedefineClasses::doit_epilogue() { // Reset the_class_oop to null for error printing. _the_class_oop = NULL; - if (RC_TRACE_ENABLED(0x00000004)) { + if (log_is_enabled(Info, redefine, class, timer)) { // Used to have separate timers for "doit" and "all", but the timer // overhead skewed the measurements. jlong doit_time = _timer_rsc_phase1.milliseconds() + _timer_rsc_phase2.milliseconds(); jlong all_time = _timer_vm_op_prologue.milliseconds() + doit_time; - RC_TRACE(0x00000004, ("vm_op: all=" UINT64_FORMAT - " prologue=" UINT64_FORMAT " doit=" UINT64_FORMAT, all_time, - _timer_vm_op_prologue.milliseconds(), doit_time)); - RC_TRACE(0x00000004, + log_info(redefine, class, timer) + ("vm_op: all=" UINT64_FORMAT " prologue=" UINT64_FORMAT " doit=" UINT64_FORMAT, + all_time, _timer_vm_op_prologue.milliseconds(), doit_time); + log_info(redefine, class, timer) ("redefine_single_class: phase1=" UINT64_FORMAT " phase2=" UINT64_FORMAT, - _timer_rsc_phase1.milliseconds(), _timer_rsc_phase2.milliseconds())); + _timer_rsc_phase1.milliseconds(), _timer_rsc_phase2.milliseconds()); } } @@ -305,14 +307,14 @@ void VM_RedefineClasses::append_entry(const constantPoolHandle& scratch_cp, // both new_name_ref_i and new_signature_ref_i will both be 0. // In that case, all we are appending is the current entry. if (new_name_ref_i != name_ref_i) { - RC_TRACE(0x00080000, + log_trace(redefine, class, constantpool) ("NameAndType entry@%d name_ref_index change: %d to %d", - *merge_cp_length_p, name_ref_i, new_name_ref_i)); + *merge_cp_length_p, name_ref_i, new_name_ref_i); } if (new_signature_ref_i != signature_ref_i) { - RC_TRACE(0x00080000, + log_trace(redefine, class, constantpool) ("NameAndType entry@%d signature_ref_index change: %d to %d", - *merge_cp_length_p, signature_ref_i, new_signature_ref_i)); + *merge_cp_length_p, signature_ref_i, new_signature_ref_i); } (*merge_cp_p)->name_and_type_at_put(*merge_cp_length_p, @@ -361,14 +363,13 @@ void VM_RedefineClasses::append_entry(const constantPoolHandle& scratch_cp, } if (klass_ref_i != new_klass_ref_i) { - RC_TRACE(0x00080000, ("%s entry@%d class_index changed: %d to %d", - entry_name, *merge_cp_length_p, klass_ref_i, new_klass_ref_i)); + log_trace(redefine, class, constantpool) + ("%s entry@%d class_index changed: %d to %d", entry_name, *merge_cp_length_p, klass_ref_i, new_klass_ref_i); } if (name_and_type_ref_i != new_name_and_type_ref_i) { - RC_TRACE(0x00080000, + log_trace(redefine, class, constantpool) ("%s entry@%d name_and_type_index changed: %d to %d", - entry_name, *merge_cp_length_p, name_and_type_ref_i, - new_name_and_type_ref_i)); + entry_name, *merge_cp_length_p, name_and_type_ref_i, new_name_and_type_ref_i); } if (scratch_i != *merge_cp_length_p) { @@ -386,9 +387,8 @@ void VM_RedefineClasses::append_entry(const constantPoolHandle& scratch_cp, int new_ref_i = find_or_append_indirect_entry(scratch_cp, ref_i, merge_cp_p, merge_cp_length_p, THREAD); if (new_ref_i != ref_i) { - RC_TRACE(0x00080000, - ("MethodType entry@%d ref_index change: %d to %d", - *merge_cp_length_p, ref_i, new_ref_i)); + log_trace(redefine, class, constantpool) + ("MethodType entry@%d ref_index change: %d to %d", *merge_cp_length_p, ref_i, new_ref_i); } (*merge_cp_p)->method_type_index_at_put(*merge_cp_length_p, new_ref_i); if (scratch_i != *merge_cp_length_p) { @@ -407,9 +407,8 @@ void VM_RedefineClasses::append_entry(const constantPoolHandle& scratch_cp, int new_ref_i = find_or_append_indirect_entry(scratch_cp, ref_i, merge_cp_p, merge_cp_length_p, THREAD); if (new_ref_i != ref_i) { - RC_TRACE(0x00080000, - ("MethodHandle entry@%d ref_index change: %d to %d", - *merge_cp_length_p, ref_i, new_ref_i)); + log_trace(redefine, class, constantpool) + ("MethodHandle entry@%d ref_index change: %d to %d", *merge_cp_length_p, ref_i, new_ref_i); } (*merge_cp_p)->method_handle_index_at_put(*merge_cp_length_p, ref_kind, new_ref_i); if (scratch_i != *merge_cp_length_p) { @@ -432,14 +431,13 @@ void VM_RedefineClasses::append_entry(const constantPoolHandle& scratch_cp, int new_ref_i = find_or_append_indirect_entry(scratch_cp, old_ref_i, merge_cp_p, merge_cp_length_p, THREAD); if (new_bs_i != old_bs_i) { - RC_TRACE(0x00080000, - ("InvokeDynamic entry@%d bootstrap_method_attr_index change: %d to %d", - *merge_cp_length_p, old_bs_i, new_bs_i)); + log_trace(redefine, class, constantpool) + ("InvokeDynamic entry@%d bootstrap_method_attr_index change: %d to %d", + *merge_cp_length_p, old_bs_i, new_bs_i); } if (new_ref_i != old_ref_i) { - RC_TRACE(0x00080000, - ("InvokeDynamic entry@%d name_and_type_index change: %d to %d", - *merge_cp_length_p, old_ref_i, new_ref_i)); + log_trace(redefine, class, constantpool) + ("InvokeDynamic entry@%d name_and_type_index change: %d to %d", *merge_cp_length_p, old_ref_i, new_ref_i); } (*merge_cp_p)->invoke_dynamic_at_put(*merge_cp_length_p, new_bs_i, new_ref_i); @@ -516,9 +514,8 @@ void VM_RedefineClasses::append_operand(const constantPoolHandle& scratch_cp, in int new_ref_i = find_or_append_indirect_entry(scratch_cp, old_ref_i, merge_cp_p, merge_cp_length_p, THREAD); if (new_ref_i != old_ref_i) { - RC_TRACE(0x00080000, - ("operands entry@%d bootstrap method ref_index change: %d to %d", - _operands_cur_length, old_ref_i, new_ref_i)); + log_trace(redefine, class, constantpool) + ("operands entry@%d bootstrap method ref_index change: %d to %d", _operands_cur_length, old_ref_i, new_ref_i); } Array* merge_ops = (*merge_cp_p)->operands(); @@ -539,9 +536,9 @@ void VM_RedefineClasses::append_operand(const constantPoolHandle& scratch_cp, in merge_cp_length_p, THREAD); merge_ops->at_put(new_base++, new_arg_ref_i); if (new_arg_ref_i != old_arg_ref_i) { - RC_TRACE(0x00080000, - ("operands entry@%d bootstrap method argument ref_index change: %d to %d", - _operands_cur_length, old_arg_ref_i, new_arg_ref_i)); + log_trace(redefine, class, constantpool) + ("operands entry@%d bootstrap method argument ref_index change: %d to %d", + _operands_cur_length, old_arg_ref_i, new_arg_ref_i); } } if (old_bs_i != _operands_cur_length) { @@ -586,14 +583,13 @@ void VM_RedefineClasses::finalize_operands_merge(const constantPoolHandle& merge // Shrink the merge_cp operands merge_cp->shrink_operands(_operands_cur_length, CHECK); - if (RC_TRACE_ENABLED(0x00040000)) { + if (log_is_enabled(Trace, redefine, class, constantpool)) { // don't want to loop unless we are tracing int count = 0; for (int i = 1; i < _operands_index_map_p->length(); i++) { int value = _operands_index_map_p->at(i); if (value != -1) { - RC_TRACE_WITH_THREAD(0x00040000, THREAD, - ("operands_index_map[%d]: old=%d new=%d", count, i, value)); + log_trace(redefine, class, constantpool)("operands_index_map[%d]: old=%d new=%d", count, i, value); count++; } } @@ -795,9 +791,9 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions( } } } - RC_TRACE(0x00008000, ("Method matched: new: %s [%d] == old: %s [%d]", - k_new_method->name_and_sig_as_C_string(), ni, - k_old_method->name_and_sig_as_C_string(), oi)); + log_trace(redefine, class, normalize) + ("Method matched: new: %s [%d] == old: %s [%d]", + k_new_method->name_and_sig_as_C_string(), ni, k_old_method->name_and_sig_as_C_string(), oi); // advance to next pair of methods ++oi; ++ni; @@ -832,8 +828,8 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions( return JVMTI_ERROR_OUT_OF_MEMORY; } } - RC_TRACE(0x00008000, ("Method added: new: %s [%d]", - k_new_method->name_and_sig_as_C_string(), ni)); + log_trace(redefine, class, normalize) + ("Method added: new: %s [%d]", k_new_method->name_and_sig_as_C_string(), ni); ++ni; // advance to next new method break; case deleted: @@ -846,8 +842,8 @@ jvmtiError VM_RedefineClasses::compare_and_normalize_class_versions( // deleted methods must be private return JVMTI_ERROR_UNSUPPORTED_REDEFINITION_METHOD_DELETED; } - RC_TRACE(0x00008000, ("Method deleted: old: %s [%d]", - k_old_method->name_and_sig_as_C_string(), oi)); + log_trace(redefine, class, normalize) + ("Method deleted: old: %s [%d]", k_old_method->name_and_sig_as_C_string(), oi); ++oi; // advance to next old method break; default: @@ -973,11 +969,9 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) { instanceKlassHandle the_class = instanceKlassHandle(THREAD, the_class_oop); Symbol* the_class_sym = the_class->name(); - // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark - RC_TRACE_WITH_THREAD(0x00000001, THREAD, + log_debug(redefine, class, load) ("loading name=%s kind=%d (avail_mem=" UINT64_FORMAT "K)", - the_class->external_name(), _class_load_kind, - os::available_memory() >> 10)); + the_class->external_name(), _class_load_kind, os::available_memory() >> 10); ClassFileStream st((u1*)_class_defs[i].class_bytes, _class_defs[i].class_byte_count, @@ -1011,9 +1005,7 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) { if (HAS_PENDING_EXCEPTION) { Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); - // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark - RC_TRACE_WITH_THREAD(0x00000002, THREAD, ("parse_stream exception: '%s'", - ex_name->as_C_string())); + log_info(redefine, class, load, exceptions)("parse_stream exception: '%s'", ex_name->as_C_string()); CLEAR_PENDING_EXCEPTION; if (ex_name == vmSymbols::java_lang_UnsupportedClassVersionError()) { @@ -1037,9 +1029,7 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) { the_class->link_class(THREAD); if (HAS_PENDING_EXCEPTION) { Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); - // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark - RC_TRACE_WITH_THREAD(0x00000002, THREAD, ("link_class exception: '%s'", - ex_name->as_C_string())); + log_info(redefine, class, load, exceptions)("link_class exception: '%s'", ex_name->as_C_string()); CLEAR_PENDING_EXCEPTION; if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) { return JVMTI_ERROR_OUT_OF_MEMORY; @@ -1075,9 +1065,7 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) { if (HAS_PENDING_EXCEPTION) { Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); - // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark - RC_TRACE_WITH_THREAD(0x00000002, THREAD, - ("verify_byte_codes exception: '%s'", ex_name->as_C_string())); + log_info(redefine, class, load, exceptions)("verify_byte_codes exception: '%s'", ex_name->as_C_string()); CLEAR_PENDING_EXCEPTION; if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) { return JVMTI_ERROR_OUT_OF_MEMORY; @@ -1090,9 +1078,7 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) { res = merge_cp_and_rewrite(the_class, scratch_class, THREAD); if (HAS_PENDING_EXCEPTION) { Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); - // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark - RC_TRACE_WITH_THREAD(0x00000002, THREAD, - ("merge_cp_and_rewrite exception: '%s'", ex_name->as_C_string())); + log_info(redefine, class, load, exceptions)("merge_cp_and_rewrite exception: '%s'", ex_name->as_C_string()); CLEAR_PENDING_EXCEPTION; if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) { return JVMTI_ERROR_OUT_OF_MEMORY; @@ -1110,10 +1096,8 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) { if (HAS_PENDING_EXCEPTION) { Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); - // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark - RC_TRACE_WITH_THREAD(0x00000002, THREAD, - ("verify_byte_codes post merge-CP exception: '%s'", - ex_name->as_C_string())); + log_info(redefine, class, load, exceptions) + ("verify_byte_codes post merge-CP exception: '%s'", ex_name->as_C_string()); CLEAR_PENDING_EXCEPTION; if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) { return JVMTI_ERROR_OUT_OF_MEMORY; @@ -1130,9 +1114,8 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) { } if (HAS_PENDING_EXCEPTION) { Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); - // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark - RC_TRACE_WITH_THREAD(0x00000002, THREAD, - ("Rewriter::rewrite or link_methods exception: '%s'", ex_name->as_C_string())); + log_info(redefine, class, load, exceptions) + ("Rewriter::rewrite or link_methods exception: '%s'", ex_name->as_C_string()); CLEAR_PENDING_EXCEPTION; if (ex_name == vmSymbols::java_lang_OutOfMemoryError()) { return JVMTI_ERROR_OUT_OF_MEMORY; @@ -1141,10 +1124,8 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) { } } - // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark - RC_TRACE_WITH_THREAD(0x00000001, THREAD, - ("loaded name=%s (avail_mem=" UINT64_FORMAT "K)", - the_class->external_name(), os::available_memory() >> 10)); + log_debug(redefine, class, load) + ("loaded name=%s (avail_mem=" UINT64_FORMAT "K)", the_class->external_name(), os::available_memory() >> 10); } return JVMTI_ERROR_NONE; @@ -1152,7 +1133,7 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) { // Map old_index to new_index as needed. scratch_cp is only needed -// for RC_TRACE() calls. +// for log calls. void VM_RedefineClasses::map_index(const constantPoolHandle& scratch_cp, int old_index, int new_index) { if (find_new_index(old_index) != 0) { @@ -1168,8 +1149,8 @@ void VM_RedefineClasses::map_index(const constantPoolHandle& scratch_cp, _index_map_p->at_put(old_index, new_index); _index_map_count++; - RC_TRACE(0x00040000, ("mapped tag %d at index %d to %d", - scratch_cp->tag_at(old_index).value(), old_index, new_index)); + log_trace(redefine, class, constantpool) + ("mapped tag %d at index %d to %d", scratch_cp->tag_at(old_index).value(), old_index, new_index); } // end map_index() @@ -1188,7 +1169,7 @@ void VM_RedefineClasses::map_operand_index(int old_index, int new_index) { _operands_index_map_p->at_put(old_index, new_index); _operands_index_map_count++; - RC_TRACE(0x00040000, ("mapped bootstrap specifier at index %d to %d", old_index, new_index)); + log_trace(redefine, class, constantpool)("mapped bootstrap specifier at index %d to %d", old_index, new_index); } // end map_index() @@ -1219,9 +1200,7 @@ bool VM_RedefineClasses::merge_constant_pools(const constantPoolHandle& old_cp, return false; // robustness } - RC_TRACE_WITH_THREAD(0x00010000, THREAD, - ("old_cp_len=%d, scratch_cp_len=%d", old_cp->length(), - scratch_cp->length())); + log_info(redefine, class, constantpool)("old_cp_len=%d, scratch_cp_len=%d", old_cp->length(), scratch_cp->length()); { // Pass 0: @@ -1273,8 +1252,7 @@ bool VM_RedefineClasses::merge_constant_pools(const constantPoolHandle& old_cp, // merge_cp_len should be the same as old_cp->length() at this point // so this trace message is really a "warm-and-breathing" message. - RC_TRACE_WITH_THREAD(0x00020000, THREAD, - ("after pass 0: merge_cp_len=%d", *merge_cp_length_p)); + log_debug(redefine, class, constantpool)("after pass 0: merge_cp_len=%d", *merge_cp_length_p); int scratch_i; // index into scratch_cp { @@ -1339,9 +1317,9 @@ bool VM_RedefineClasses::merge_constant_pools(const constantPoolHandle& old_cp, } } - RC_TRACE_WITH_THREAD(0x00020000, THREAD, + log_debug(redefine, class, constantpool) ("after pass 1a: merge_cp_len=%d, scratch_i=%d, index_map_len=%d", - *merge_cp_length_p, scratch_i, _index_map_count)); + *merge_cp_length_p, scratch_i, _index_map_count); if (scratch_i < scratch_cp->length()) { // Pass 1b: @@ -1377,9 +1355,9 @@ bool VM_RedefineClasses::merge_constant_pools(const constantPoolHandle& old_cp, CHECK_0); } - RC_TRACE_WITH_THREAD(0x00020000, THREAD, + log_debug(redefine, class, constantpool) ("after pass 1b: merge_cp_len=%d, scratch_i=%d, index_map_len=%d", - *merge_cp_length_p, scratch_i, _index_map_count)); + *merge_cp_length_p, scratch_i, _index_map_count); } finalize_operands_merge(*merge_cp_p, THREAD); @@ -1468,8 +1446,7 @@ jvmtiError VM_RedefineClasses::merge_cp_and_rewrite( return JVMTI_ERROR_INTERNAL; } - RC_TRACE_WITH_THREAD(0x00010000, THREAD, - ("merge_cp_len=%d, index_map_len=%d", merge_cp_length, _index_map_count)); + log_info(redefine, class, constantpool)("merge_cp_len=%d, index_map_len=%d", merge_cp_length, _index_map_count); if (_index_map_count == 0) { // there is nothing to map between the new and merged constant pools @@ -1508,15 +1485,14 @@ jvmtiError VM_RedefineClasses::merge_cp_and_rewrite( cp_cleaner.add_scratch_cp(scratch_cp()); } } else { - if (RC_TRACE_ENABLED(0x00040000)) { + if (log_is_enabled(Trace, redefine, class, constantpool)) { // don't want to loop unless we are tracing int count = 0; for (int i = 1; i < _index_map_p->length(); i++) { int value = _index_map_p->at(i); if (value != -1) { - RC_TRACE_WITH_THREAD(0x00040000, THREAD, - ("index_map[%d]: old=%d new=%d", count, i, value)); + log_trace(redefine, class, constantpool)("index_map[%d]: old=%d new=%d", count, i, value); count++; } } @@ -1653,9 +1629,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods( } if (HAS_PENDING_EXCEPTION) { Symbol* ex_name = PENDING_EXCEPTION->klass()->name(); - // RC_TRACE_WITH_THREAD macro has an embedded ResourceMark - RC_TRACE_WITH_THREAD(0x00000002, THREAD, - ("rewrite_cp_refs_in_method exception: '%s'", ex_name->as_C_string())); + log_info(redefine, class, load, exceptions)("rewrite_cp_refs_in_method exception: '%s'", ex_name->as_C_string()); // Need to clear pending exception here as the super caller sets // the JVMTI_ERROR_INTERNAL if the returned value is false. CLEAR_PENDING_EXCEPTION; @@ -1715,14 +1689,12 @@ void VM_RedefineClasses::rewrite_cp_refs_in_method(methodHandle method, if (!StressLdcRewrite && new_index <= max_jubyte) { // The new value can still use ldc instead of ldc_w // unless we are trying to stress ldc -> ldc_w rewriting - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("%s@" INTPTR_FORMAT " old=%d, new=%d", Bytecodes::name(c), - p2i(bcp), cp_index, new_index)); + log_trace(redefine, class, constantpool) + ("%s@" INTPTR_FORMAT " old=%d, new=%d", Bytecodes::name(c), p2i(bcp), cp_index, new_index); *(bcp + 1) = new_index; } else { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("%s->ldc_w@" INTPTR_FORMAT " old=%d, new=%d", - Bytecodes::name(c), p2i(bcp), cp_index, new_index)); + log_trace(redefine, class, constantpool) + ("%s->ldc_w@" INTPTR_FORMAT " old=%d, new=%d", Bytecodes::name(c), p2i(bcp), cp_index, new_index); // the new value needs ldc_w instead of ldc u_char inst_buffer[4]; // max instruction size is 4 bytes bcp = (address)inst_buffer; @@ -1781,9 +1753,8 @@ void VM_RedefineClasses::rewrite_cp_refs_in_method(methodHandle method, int new_index = find_new_index(cp_index); if (new_index != 0) { // the original index is mapped so update w/ new value - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("%s@" INTPTR_FORMAT " old=%d, new=%d", Bytecodes::name(c), - p2i(bcp), cp_index, new_index)); + log_trace(redefine, class, constantpool) + ("%s@" INTPTR_FORMAT " old=%d, new=%d", Bytecodes::name(c),p2i(bcp), cp_index, new_index); // Rewriter::rewrite_method() uses put_native_u2() in this // situation because it is reusing the constant pool index // location for a native index into the ConstantPoolCache. @@ -1823,8 +1794,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_class_annotations( return true; } - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("class_annotations length=%d", class_annotations->length())); + log_debug(redefine, class, annotation)("class_annotations length=%d", class_annotations->length()); int byte_i = 0; // byte index into class_annotations return rewrite_cp_refs_in_annotations_typeArray(class_annotations, byte_i, @@ -1846,8 +1816,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_annotations_typeArray( if ((byte_i_ref + 2) > annotations_typeArray->length()) { // not enough room for num_annotations field - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for num_annotations field")); + log_debug(redefine, class, annotation)("length() is too small for num_annotations field"); return false; } @@ -1855,15 +1824,13 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_annotations_typeArray( annotations_typeArray->adr_at(byte_i_ref)); byte_i_ref += 2; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("num_annotations=%d", num_annotations)); + log_debug(redefine, class, annotation)("num_annotations=%d", num_annotations); int calc_num_annotations = 0; for (; calc_num_annotations < num_annotations; calc_num_annotations++) { if (!rewrite_cp_refs_in_annotation_struct(annotations_typeArray, byte_i_ref, THREAD)) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("bad annotation_struct at %d", calc_num_annotations)); + log_debug(redefine, class, annotation)("bad annotation_struct at %d", calc_num_annotations); // propagate failure back to caller return false; } @@ -1891,8 +1858,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_annotation_struct( AnnotationArray* annotations_typeArray, int &byte_i_ref, TRAPS) { if ((byte_i_ref + 2 + 2) > annotations_typeArray->length()) { // not enough room for smallest annotation_struct - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for annotation_struct")); + log_debug(redefine, class, annotation)("length() is too small for annotation_struct"); return false; } @@ -1903,9 +1869,8 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_annotation_struct( annotations_typeArray->adr_at(byte_i_ref)); byte_i_ref += 2; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("type_index=%d num_element_value_pairs=%d", type_index, - num_element_value_pairs)); + log_debug(redefine, class, annotation) + ("type_index=%d num_element_value_pairs=%d", type_index, num_element_value_pairs); int calc_num_element_value_pairs = 0; for (; calc_num_element_value_pairs < num_element_value_pairs; @@ -1913,8 +1878,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_annotation_struct( if ((byte_i_ref + 2) > annotations_typeArray->length()) { // not enough room for another element_name_index, let alone // the rest of another component - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for element_name_index")); + log_debug(redefine, class, annotation)("length() is too small for element_name_index"); return false; } @@ -1922,13 +1886,11 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_annotation_struct( annotations_typeArray, byte_i_ref, "element_name_index", THREAD); - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("element_name_index=%d", element_name_index)); + log_debug(redefine, class, annotation)("element_name_index=%d", element_name_index); if (!rewrite_cp_refs_in_element_value(annotations_typeArray, byte_i_ref, THREAD)) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("bad element_value at %d", calc_num_element_value_pairs)); + log_debug(redefine, class, annotation)("bad element_value at %d", calc_num_element_value_pairs); // propagate failure back to caller return false; } @@ -1953,7 +1915,7 @@ u2 VM_RedefineClasses::rewrite_cp_ref_in_annotation_data( u2 old_cp_index = Bytes::get_Java_u2(cp_index_addr); u2 new_cp_index = find_new_index(old_cp_index); if (new_cp_index != 0) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("mapped old %s=%d", trace_mesg, old_cp_index)); + log_debug(redefine, class, annotation)("mapped old %s=%d", trace_mesg, old_cp_index); Bytes::put_Java_u2(cp_index_addr, new_cp_index); old_cp_index = new_cp_index; } @@ -1988,14 +1950,13 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_element_value( if ((byte_i_ref + 1) > annotations_typeArray->length()) { // not enough room for a tag let alone the rest of an element_value - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a tag")); + log_debug(redefine, class, annotation)("length() is too small for a tag"); return false; } u1 tag = annotations_typeArray->at(byte_i_ref); byte_i_ref++; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("tag='%c'", tag)); + log_debug(redefine, class, annotation)("tag='%c'", tag); switch (tag) { // These BaseType tag values are from Table 4.2 in VM spec: @@ -2017,8 +1978,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_element_value( if ((byte_i_ref + 2) > annotations_typeArray->length()) { // not enough room for a const_value_index - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a const_value_index")); + log_debug(redefine, class, annotation)("length() is too small for a const_value_index"); return false; } @@ -2026,8 +1986,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_element_value( annotations_typeArray, byte_i_ref, "const_value_index", THREAD); - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("const_value_index=%d", const_value_index)); + log_debug(redefine, class, annotation)("const_value_index=%d", const_value_index); } break; case 'e': @@ -2036,8 +1995,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_element_value( if ((byte_i_ref + 4) > annotations_typeArray->length()) { // not enough room for a enum_const_value - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a enum_const_value")); + log_debug(redefine, class, annotation)("length() is too small for a enum_const_value"); return false; } @@ -2049,9 +2007,8 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_element_value( annotations_typeArray, byte_i_ref, "const_name_index", THREAD); - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("type_name_index=%d const_name_index=%d", type_name_index, - const_name_index)); + log_debug(redefine, class, annotation) + ("type_name_index=%d const_name_index=%d", type_name_index, const_name_index); } break; case 'c': @@ -2060,8 +2017,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_element_value( if ((byte_i_ref + 2) > annotations_typeArray->length()) { // not enough room for a class_info_index - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a class_info_index")); + log_debug(redefine, class, annotation)("length() is too small for a class_info_index"); return false; } @@ -2069,8 +2025,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_element_value( annotations_typeArray, byte_i_ref, "class_info_index", THREAD); - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("class_info_index=%d", class_info_index)); + log_debug(redefine, class, annotation)("class_info_index=%d", class_info_index); } break; case '@': @@ -2087,8 +2042,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_element_value( { if ((byte_i_ref + 2) > annotations_typeArray->length()) { // not enough room for a num_values field - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a num_values field")); + log_debug(redefine, class, annotation)("length() is too small for a num_values field"); return false; } @@ -2097,14 +2051,13 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_element_value( u2 num_values = Bytes::get_Java_u2((address) annotations_typeArray->adr_at(byte_i_ref)); byte_i_ref += 2; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("num_values=%d", num_values)); + log_debug(redefine, class, annotation)("num_values=%d", num_values); int calc_num_values = 0; for (; calc_num_values < num_values; calc_num_values++) { if (!rewrite_cp_refs_in_element_value( annotations_typeArray, byte_i_ref, THREAD)) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("bad nested element_value at %d", calc_num_values)); + log_debug(redefine, class, annotation)("bad nested element_value at %d", calc_num_values); // propagate failure back to caller return false; } @@ -2113,7 +2066,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_element_value( } break; default: - RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("bad tag=0x%x", tag)); + log_debug(redefine, class, annotation)("bad tag=0x%x", tag); return false; } // end decode tag field @@ -2132,8 +2085,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_fields_annotations( return true; } - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("fields_annotations length=%d", fields_annotations->length())); + log_debug(redefine, class, annotation)("fields_annotations length=%d", fields_annotations->length()); for (int i = 0; i < fields_annotations->length(); i++) { AnnotationArray* field_annotations = fields_annotations->at(i); @@ -2145,8 +2097,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_fields_annotations( int byte_i = 0; // byte index into field_annotations if (!rewrite_cp_refs_in_annotations_typeArray(field_annotations, byte_i, THREAD)) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("bad field_annotations at %d", i)); + log_debug(redefine, class, annotation)("bad field_annotations at %d", i); // propagate failure back to caller return false; } @@ -2172,8 +2123,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods_annotations( int byte_i = 0; // byte index into method_annotations if (!rewrite_cp_refs_in_annotations_typeArray(method_annotations, byte_i, THREAD)) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("bad method_annotations at %d", i)); + log_debug(redefine, class, annotation)("bad method_annotations at %d", i); // propagate failure back to caller return false; } @@ -2210,8 +2160,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods_parameter_annotations( if (method_parameter_annotations->length() < 1) { // not enough room for a num_parameters field - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a num_parameters field at %d", i)); + log_debug(redefine, class, annotation)("length() is too small for a num_parameters field at %d", i); return false; } @@ -2220,15 +2169,13 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods_parameter_annotations( u1 num_parameters = method_parameter_annotations->at(byte_i); byte_i++; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("num_parameters=%d", num_parameters)); + log_debug(redefine, class, annotation)("num_parameters=%d", num_parameters); int calc_num_parameters = 0; for (; calc_num_parameters < num_parameters; calc_num_parameters++) { if (!rewrite_cp_refs_in_annotations_typeArray( method_parameter_annotations, byte_i, THREAD)) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("bad method_parameter_annotations at %d", calc_num_parameters)); + log_debug(redefine, class, annotation)("bad method_parameter_annotations at %d", calc_num_parameters); // propagate failure back to caller return false; } @@ -2264,8 +2211,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods_default_annotations( if (!rewrite_cp_refs_in_element_value( method_default_annotations, byte_i, THREAD)) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("bad default element_value at %d", i)); + log_debug(redefine, class, annotation)("bad default element_value at %d", i); // propagate failure back to caller return false; } @@ -2285,8 +2231,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_class_type_annotations( return true; } - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("class_type_annotations length=%d", class_type_annotations->length())); + log_debug(redefine, class, annotation)("class_type_annotations length=%d", class_type_annotations->length()); int byte_i = 0; // byte index into class_type_annotations return rewrite_cp_refs_in_type_annotations_typeArray(class_type_annotations, @@ -2304,8 +2249,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_fields_type_annotations( return true; } - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("fields_type_annotations length=%d", fields_type_annotations->length())); + log_debug(redefine, class, annotation)("fields_type_annotations length=%d", fields_type_annotations->length()); for (int i = 0; i < fields_type_annotations->length(); i++) { AnnotationArray* field_type_annotations = fields_type_annotations->at(i); @@ -2317,8 +2261,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_fields_type_annotations( int byte_i = 0; // byte index into field_type_annotations if (!rewrite_cp_refs_in_type_annotations_typeArray(field_type_annotations, byte_i, "field_info", THREAD)) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("bad field_type_annotations at %d", i)); + log_debug(redefine, class, annotation)("bad field_type_annotations at %d", i); // propagate failure back to caller return false; } @@ -2341,14 +2284,12 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_methods_type_annotations( continue; } - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("methods type_annotations length=%d", method_type_annotations->length())); + log_debug(redefine, class, annotation)("methods type_annotations length=%d", method_type_annotations->length()); int byte_i = 0; // byte index into method_type_annotations if (!rewrite_cp_refs_in_type_annotations_typeArray(method_type_annotations, byte_i, "method_info", THREAD)) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("bad method_type_annotations at %d", i)); + log_debug(redefine, class, annotation)("bad method_type_annotations at %d", i); // propagate failure back to caller return false; } @@ -2374,8 +2315,7 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_type_annotations_typeArray( if ((byte_i_ref + 2) > type_annotations_typeArray->length()) { // not enough room for num_annotations field - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for num_annotations field")); + log_debug(redefine, class, annotation)("length() is too small for num_annotations field"); return false; } @@ -2383,15 +2323,13 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_type_annotations_typeArray( type_annotations_typeArray->adr_at(byte_i_ref)); byte_i_ref += 2; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("num_type_annotations=%d", num_annotations)); + log_debug(redefine, class, annotation)("num_type_annotations=%d", num_annotations); int calc_num_annotations = 0; for (; calc_num_annotations < num_annotations; calc_num_annotations++) { if (!rewrite_cp_refs_in_type_annotation_struct(type_annotations_typeArray, byte_i_ref, location_mesg, THREAD)) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("bad type_annotation_struct at %d", calc_num_annotations)); + log_debug(redefine, class, annotation)("bad type_annotation_struct at %d", calc_num_annotations); // propagate failure back to caller return false; } @@ -2399,10 +2337,9 @@ bool VM_RedefineClasses::rewrite_cp_refs_in_type_annotations_typeArray( assert(num_annotations == calc_num_annotations, "sanity check"); if (byte_i_ref != type_annotations_typeArray->length()) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("read wrong amount of bytes at end of processing " - "type_annotations_typeArray (%d of %d bytes were read)", - byte_i_ref, type_annotations_typeArray->length())); + log_debug(redefine, class, annotation) + ("read wrong amount of bytes at end of processing type_annotations_typeArray (%d of %d bytes were read)", + byte_i_ref, type_annotations_typeArray->length()); return false; } @@ -2479,15 +2416,14 @@ bool VM_RedefineClasses::skip_type_annotation_target( if ((byte_i_ref + 1) > type_annotations_typeArray->length()) { // not enough room for a target_type let alone the rest of a type_annotation - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a target_type")); + log_debug(redefine, class, annotation)("length() is too small for a target_type"); return false; } u1 target_type = type_annotations_typeArray->at(byte_i_ref); byte_i_ref += 1; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("target_type=0x%.2x", target_type)); - RC_TRACE_WITH_THREAD(0x02000000, THREAD, ("location=%s", location_mesg)); + log_debug(redefine, class, annotation)("target_type=0x%.2x", target_type); + log_debug(redefine, class, annotation)("location=%s", location_mesg); // Skip over target_info switch (target_type) { @@ -2505,17 +2441,14 @@ bool VM_RedefineClasses::skip_type_annotation_target( // } // if ((byte_i_ref + 1) > type_annotations_typeArray->length()) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a type_parameter_target")); + log_debug(redefine, class, annotation)("length() is too small for a type_parameter_target"); return false; } u1 type_parameter_index = type_annotations_typeArray->at(byte_i_ref); byte_i_ref += 1; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("type_parameter_target: type_parameter_index=%d", - type_parameter_index)); + log_debug(redefine, class, annotation)("type_parameter_target: type_parameter_index=%d", type_parameter_index); } break; case 0x10: @@ -2531,8 +2464,7 @@ bool VM_RedefineClasses::skip_type_annotation_target( // } // if ((byte_i_ref + 2) > type_annotations_typeArray->length()) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a supertype_target")); + log_debug(redefine, class, annotation)("length() is too small for a supertype_target"); return false; } @@ -2540,8 +2472,7 @@ bool VM_RedefineClasses::skip_type_annotation_target( type_annotations_typeArray->adr_at(byte_i_ref)); byte_i_ref += 2; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("supertype_target: supertype_index=%d", supertype_index)); + log_debug(redefine, class, annotation)("supertype_target: supertype_index=%d", supertype_index); } break; case 0x11: @@ -2559,8 +2490,7 @@ bool VM_RedefineClasses::skip_type_annotation_target( // } // if ((byte_i_ref + 2) > type_annotations_typeArray->length()) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a type_parameter_bound_target")); + log_debug(redefine, class, annotation)("length() is too small for a type_parameter_bound_target"); return false; } @@ -2569,9 +2499,8 @@ bool VM_RedefineClasses::skip_type_annotation_target( u1 bound_index = type_annotations_typeArray->at(byte_i_ref); byte_i_ref += 1; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("type_parameter_bound_target: type_parameter_index=%d, bound_index=%d", - type_parameter_index, bound_index)); + log_debug(redefine, class, annotation) + ("type_parameter_bound_target: type_parameter_index=%d, bound_index=%d", type_parameter_index, bound_index); } break; case 0x13: @@ -2589,8 +2518,7 @@ bool VM_RedefineClasses::skip_type_annotation_target( // empty_target { // } // - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("empty_target")); + log_debug(redefine, class, annotation)("empty_target"); } break; case 0x16: @@ -2604,17 +2532,15 @@ bool VM_RedefineClasses::skip_type_annotation_target( // } // if ((byte_i_ref + 1) > type_annotations_typeArray->length()) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a formal_parameter_target")); + log_debug(redefine, class, annotation)("length() is too small for a formal_parameter_target"); return false; } u1 formal_parameter_index = type_annotations_typeArray->at(byte_i_ref); byte_i_ref += 1; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("formal_parameter_target: formal_parameter_index=%d", - formal_parameter_index)); + log_debug(redefine, class, annotation) + ("formal_parameter_target: formal_parameter_index=%d", formal_parameter_index); } break; case 0x17: @@ -2628,8 +2554,7 @@ bool VM_RedefineClasses::skip_type_annotation_target( // } // if ((byte_i_ref + 2) > type_annotations_typeArray->length()) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a throws_target")); + log_debug(redefine, class, annotation)("length() is too small for a throws_target"); return false; } @@ -2637,8 +2562,7 @@ bool VM_RedefineClasses::skip_type_annotation_target( type_annotations_typeArray->adr_at(byte_i_ref)); byte_i_ref += 2; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("throws_target: throws_type_index=%d", throws_type_index)); + log_debug(redefine, class, annotation)("throws_target: throws_type_index=%d", throws_type_index); } break; case 0x40: @@ -2661,8 +2585,7 @@ bool VM_RedefineClasses::skip_type_annotation_target( // if ((byte_i_ref + 2) > type_annotations_typeArray->length()) { // not enough room for a table_length let alone the rest of a localvar_target - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a localvar_target table_length")); + log_debug(redefine, class, annotation)("length() is too small for a localvar_target table_length"); return false; } @@ -2670,16 +2593,14 @@ bool VM_RedefineClasses::skip_type_annotation_target( type_annotations_typeArray->adr_at(byte_i_ref)); byte_i_ref += 2; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("localvar_target: table_length=%d", table_length)); + log_debug(redefine, class, annotation)("localvar_target: table_length=%d", table_length); int table_struct_size = 2 + 2 + 2; // 3 u2 variables per table entry int table_size = table_length * table_struct_size; if ((byte_i_ref + table_size) > type_annotations_typeArray->length()) { // not enough room for a table - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a table array of length %d", table_length)); + log_debug(redefine, class, annotation)("length() is too small for a table array of length %d", table_length); return false; } @@ -2698,8 +2619,7 @@ bool VM_RedefineClasses::skip_type_annotation_target( // } // if ((byte_i_ref + 2) > type_annotations_typeArray->length()) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a catch_target")); + log_debug(redefine, class, annotation)("length() is too small for a catch_target"); return false; } @@ -2707,8 +2627,7 @@ bool VM_RedefineClasses::skip_type_annotation_target( type_annotations_typeArray->adr_at(byte_i_ref)); byte_i_ref += 2; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("catch_target: exception_table_index=%d", exception_table_index)); + log_debug(redefine, class, annotation)("catch_target: exception_table_index=%d", exception_table_index); } break; case 0x43: @@ -2731,8 +2650,7 @@ bool VM_RedefineClasses::skip_type_annotation_target( // } // if ((byte_i_ref + 2) > type_annotations_typeArray->length()) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a offset_target")); + log_debug(redefine, class, annotation)("length() is too small for a offset_target"); return false; } @@ -2740,8 +2658,7 @@ bool VM_RedefineClasses::skip_type_annotation_target( type_annotations_typeArray->adr_at(byte_i_ref)); byte_i_ref += 2; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("offset_target: offset=%d", offset)); + log_debug(redefine, class, annotation)("offset_target: offset=%d", offset); } break; case 0x47: @@ -2769,8 +2686,7 @@ bool VM_RedefineClasses::skip_type_annotation_target( // } // if ((byte_i_ref + 3) > type_annotations_typeArray->length()) { - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a type_argument_target")); + log_debug(redefine, class, annotation)("length() is too small for a type_argument_target"); return false; } @@ -2780,14 +2696,12 @@ bool VM_RedefineClasses::skip_type_annotation_target( u1 type_argument_index = type_annotations_typeArray->at(byte_i_ref); byte_i_ref += 1; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("type_argument_target: offset=%d, type_argument_index=%d", - offset, type_argument_index)); + log_debug(redefine, class, annotation) + ("type_argument_target: offset=%d, type_argument_index=%d", offset, type_argument_index); } break; default: - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("unknown target_type")); + log_debug(redefine, class, annotation)("unknown target_type"); #ifdef ASSERT ShouldNotReachHere(); #endif @@ -2814,24 +2728,21 @@ bool VM_RedefineClasses::skip_type_annotation_type_path( if ((byte_i_ref + 1) > type_annotations_typeArray->length()) { // not enough room for a path_length let alone the rest of the type_path - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for a type_path")); + log_debug(redefine, class, annotation)("length() is too small for a type_path"); return false; } u1 path_length = type_annotations_typeArray->at(byte_i_ref); byte_i_ref += 1; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("type_path: path_length=%d", path_length)); + log_debug(redefine, class, annotation)("type_path: path_length=%d", path_length); int calc_path_length = 0; for (; calc_path_length < path_length; calc_path_length++) { if ((byte_i_ref + 1 + 1) > type_annotations_typeArray->length()) { // not enough room for a path - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("length() is too small for path entry %d of %d", - calc_path_length, path_length)); + log_debug(redefine, class, annotation) + ("length() is too small for path entry %d of %d", calc_path_length, path_length); return false; } @@ -2840,14 +2751,13 @@ bool VM_RedefineClasses::skip_type_annotation_type_path( u1 type_argument_index = type_annotations_typeArray->at(byte_i_ref); byte_i_ref += 1; - RC_TRACE_WITH_THREAD(0x02000000, THREAD, + log_debug(redefine, class, annotation) ("type_path: path[%d]: type_path_kind=%d, type_argument_index=%d", - calc_path_length, type_path_kind, type_argument_index)); + calc_path_length, type_path_kind, type_argument_index); if (type_path_kind > 3 || (type_path_kind != 3 && type_argument_index != 0)) { // not enough room for a path - RC_TRACE_WITH_THREAD(0x02000000, THREAD, - ("inconsistent type_path values")); + log_debug(redefine, class, annotation)("inconsistent type_path values"); return false; } } @@ -2883,8 +2793,7 @@ void VM_RedefineClasses::rewrite_cp_refs_in_stack_map_table( u2 number_of_entries = Bytes::get_Java_u2(stackmap_p); stackmap_p += 2; - RC_TRACE_WITH_THREAD(0x04000000, THREAD, - ("number_of_entries=%u", number_of_entries)); + log_debug(redefine, class, stackmap)("number_of_entries=%u", number_of_entries); // walk through each stack_map_frame u2 calc_number_of_entries = 0; @@ -3084,16 +2993,14 @@ void VM_RedefineClasses::rewrite_cp_refs_in_verification_type_info( u2 cpool_index = Bytes::get_Java_u2(stackmap_p_ref); u2 new_cp_index = find_new_index(cpool_index); if (new_cp_index != 0) { - RC_TRACE_WITH_THREAD(0x04000000, THREAD, - ("mapped old cpool_index=%d", cpool_index)); + log_debug(redefine, class, stackmap)("mapped old cpool_index=%d", cpool_index); Bytes::put_Java_u2(stackmap_p_ref, new_cp_index); cpool_index = new_cp_index; } stackmap_p_ref += 2; - RC_TRACE_WITH_THREAD(0x04000000, THREAD, - ("frame_i=%u, frame_type=%u, cpool_index=%d", frame_i, - frame_type, cpool_index)); + log_debug(redefine, class, stackmap) + ("frame_i=%u, frame_type=%u, cpool_index=%d", frame_i, frame_type, cpool_index); } break; // Uninitialized_variable_info { @@ -3106,8 +3013,7 @@ void VM_RedefineClasses::rewrite_cp_refs_in_verification_type_info( break; default: - RC_TRACE_WITH_THREAD(0x04000000, THREAD, - ("frame_i=%u, frame_type=%u, bad tag=0x%x", frame_i, frame_type, tag)); + log_debug(redefine, class, stackmap)("frame_i=%u, frame_type=%u, bad tag=0x%x", frame_i, frame_type, tag); ShouldNotReachHere(); break; } // end switch (tag) @@ -3157,29 +3063,25 @@ void VM_RedefineClasses::set_new_constant_pool( jshort cur_index = fs.name_index(); jshort new_index = find_new_index(cur_index); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("field-name_index change: %d to %d", cur_index, new_index)); + log_trace(redefine, class, constantpool)("field-name_index change: %d to %d", cur_index, new_index); fs.set_name_index(new_index); } cur_index = fs.signature_index(); new_index = find_new_index(cur_index); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("field-signature_index change: %d to %d", cur_index, new_index)); + log_trace(redefine, class, constantpool)("field-signature_index change: %d to %d", cur_index, new_index); fs.set_signature_index(new_index); } cur_index = fs.initval_index(); new_index = find_new_index(cur_index); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("field-initval_index change: %d to %d", cur_index, new_index)); + log_trace(redefine, class, constantpool)("field-initval_index change: %d to %d", cur_index, new_index); fs.set_initval_index(new_index); } cur_index = fs.generic_signature_index(); new_index = find_new_index(cur_index); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("field-generic_signature change: %d to %d", cur_index, new_index)); + log_trace(redefine, class, constantpool)("field-generic_signature change: %d to %d", cur_index, new_index); fs.set_generic_signature_index(new_index); } } // end for each field @@ -3196,22 +3098,19 @@ void VM_RedefineClasses::set_new_constant_pool( } int new_index = find_new_index(cur_index); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("inner_class_info change: %d to %d", cur_index, new_index)); + log_trace(redefine, class, constantpool)("inner_class_info change: %d to %d", cur_index, new_index); iter.set_inner_class_info_index(new_index); } cur_index = iter.outer_class_info_index(); new_index = find_new_index(cur_index); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("outer_class_info change: %d to %d", cur_index, new_index)); + log_trace(redefine, class, constantpool)("outer_class_info change: %d to %d", cur_index, new_index); iter.set_outer_class_info_index(new_index); } cur_index = iter.inner_name_index(); new_index = find_new_index(cur_index); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("inner_name change: %d to %d", cur_index, new_index)); + log_trace(redefine, class, constantpool)("inner_name change: %d to %d", cur_index, new_index); iter.set_inner_name_index(new_index); } } // end for each inner class @@ -3225,23 +3124,20 @@ void VM_RedefineClasses::set_new_constant_pool( int new_index = find_new_index(method->name_index()); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("method-name_index change: %d to %d", method->name_index(), - new_index)); + log_trace(redefine, class, constantpool) + ("method-name_index change: %d to %d", method->name_index(), new_index); method->set_name_index(new_index); } new_index = find_new_index(method->signature_index()); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("method-signature_index change: %d to %d", - method->signature_index(), new_index)); + log_trace(redefine, class, constantpool) + ("method-signature_index change: %d to %d", method->signature_index(), new_index); method->set_signature_index(new_index); } new_index = find_new_index(method->generic_signature_index()); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("method-generic_signature_index change: %d to %d", - method->generic_signature_index(), new_index)); + log_trace(redefine, class, constantpool) + ("method-generic_signature_index change: %d to %d", method->generic_signature_index(), new_index); method->set_generic_signature_index(new_index); } @@ -3255,8 +3151,7 @@ void VM_RedefineClasses::set_new_constant_pool( int cur_index = cext_table[j].class_cp_index; int new_index = find_new_index(cur_index); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("cext-class_cp_index change: %d to %d", cur_index, new_index)); + log_trace(redefine, class, constantpool)("cext-class_cp_index change: %d to %d", cur_index, new_index); cext_table[j].class_cp_index = (u2)new_index; } } // end for each checked exception table entry @@ -3274,8 +3169,7 @@ void VM_RedefineClasses::set_new_constant_pool( int cur_index = ex_table.catch_type_index(j); int new_index = find_new_index(cur_index); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("ext-klass_index change: %d to %d", cur_index, new_index)); + log_trace(redefine, class, constantpool)("ext-klass_index change: %d to %d", cur_index, new_index); ex_table.set_catch_type_index(j, new_index); } } // end for each exception table entry @@ -3292,23 +3186,19 @@ void VM_RedefineClasses::set_new_constant_pool( int cur_index = lv_table[j].name_cp_index; int new_index = find_new_index(cur_index); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("lvt-name_cp_index change: %d to %d", cur_index, new_index)); + log_trace(redefine, class, constantpool)("lvt-name_cp_index change: %d to %d", cur_index, new_index); lv_table[j].name_cp_index = (u2)new_index; } cur_index = lv_table[j].descriptor_cp_index; new_index = find_new_index(cur_index); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("lvt-descriptor_cp_index change: %d to %d", cur_index, - new_index)); + log_trace(redefine, class, constantpool)("lvt-descriptor_cp_index change: %d to %d", cur_index, new_index); lv_table[j].descriptor_cp_index = (u2)new_index; } cur_index = lv_table[j].signature_cp_index; new_index = find_new_index(cur_index); if (new_index != 0) { - RC_TRACE_WITH_THREAD(0x00080000, THREAD, - ("lvt-signature_cp_index change: %d to %d", cur_index, new_index)); + log_trace(redefine, class, constantpool)("lvt-signature_cp_index change: %d to %d", cur_index, new_index); lv_table[j].signature_cp_index = (u2)new_index; } } // end for each local variable table entry @@ -3332,13 +3222,6 @@ void VM_RedefineClasses::AdjustCpoolCacheAndVtable::do_klass(Klass* k) { bool trace_name_printed = false; InstanceKlass *the_class = InstanceKlass::cast(_the_class_oop); - // Very noisy: only enable this call if you are trying to determine - // that a specific class gets found by this routine. - // RC_TRACE macro has an embedded ResourceMark - // RC_TRACE_WITH_THREAD(0x00100000, THREAD, - // ("adjust check: name=%s", k->external_name())); - // trace_name_printed = true; - // If the class being redefined is java.lang.Object, we need to fix all // array class vtables also if (k->is_array_klass() && _the_class_oop == SystemDictionary::Object_klass()) { @@ -3576,9 +3459,11 @@ int VM_RedefineClasses::check_methods_and_mark_as_obsolete() { // With tracing we try not to "yack" too much. The position of // this trace assumes there are fewer obsolete methods than // EMCP methods. - RC_TRACE(0x00000100, ("mark %s(%s) as obsolete", - old_method->name()->as_C_string(), - old_method->signature()->as_C_string())); + if (log_is_enabled(Trace, redefine, class, obsolete, mark)) { + ResourceMark rm; + log_trace(redefine, class, obsolete, mark) + ("mark %s(%s) as obsolete", old_method->name()->as_C_string(), old_method->signature()->as_C_string()); + } } old_method->set_is_old(); } @@ -3596,14 +3481,15 @@ int VM_RedefineClasses::check_methods_and_mark_as_obsolete() { // With tracing we try not to "yack" too much. The position of // this trace assumes there are fewer obsolete methods than // EMCP methods. - RC_TRACE(0x00000100, ("mark deleted %s(%s) as obsolete", - old_method->name()->as_C_string(), - old_method->signature()->as_C_string())); + if (log_is_enabled(Trace, redefine, class, obsolete, mark)) { + ResourceMark rm; + log_trace(redefine, class, obsolete, mark) + ("mark deleted %s(%s) as obsolete", old_method->name()->as_C_string(), old_method->signature()->as_C_string()); + } } assert((emcp_method_count + obsolete_count) == _old_methods->length(), "sanity check"); - RC_TRACE(0x00000100, ("EMCP_cnt=%d, obsolete_cnt=%d", emcp_method_count, - obsolete_count)); + log_trace(redefine, class, obsolete, mark)("EMCP_cnt=%d, obsolete_cnt=%d", emcp_method_count, obsolete_count); return emcp_method_count; } @@ -3866,7 +3752,10 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass, Klass* scratch_class_oop, TRAPS) { HandleMark hm(THREAD); // make sure handles from this call are freed - RC_TIMER_START(_timer_rsc_phase1); + + if (log_is_enabled(Info, redefine, class, timer)) { + _timer_rsc_phase1.start(); + } instanceKlassHandle scratch_class(scratch_class_oop); @@ -4083,8 +3972,10 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass, // keep track of previous versions of this class the_class->add_previous_version(scratch_class, emcp_method_count); - RC_TIMER_STOP(_timer_rsc_phase1); - RC_TIMER_START(_timer_rsc_phase2); + _timer_rsc_phase1.stop(); + if (log_is_enabled(Info, redefine, class, timer)) { + _timer_rsc_phase2.start(); + } // Adjust constantpool caches and vtables for all classes // that reference methods of the evolved class. @@ -4104,25 +3995,20 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass, the_class->oop_map_cache()->flush_obsolete_entries(); } - // increment the classRedefinedCount field in the_class and in any - // direct and indirect subclasses of the_class - increment_class_counter((InstanceKlass *)the_class(), THREAD); - - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE_WITH_THREAD(0x00000001, THREAD, - ("redefined name=%s, count=%d (avail_mem=" UINT64_FORMAT "K)", - the_class->external_name(), - java_lang_Class::classRedefinedCount(the_class_mirror), - os::available_memory() >> 10)); - { ResourceMark rm(THREAD); + // increment the classRedefinedCount field in the_class and in any + // direct and indirect subclasses of the_class + increment_class_counter((InstanceKlass *)the_class(), THREAD); + log_info(redefine, class, load) + ("redefined name=%s, count=%d (avail_mem=" UINT64_FORMAT "K)", + the_class->external_name(), java_lang_Class::classRedefinedCount(the_class_mirror), os::available_memory() >> 10); Events::log_redefinition(THREAD, "redefined class name=%s, count=%d", the_class->external_name(), java_lang_Class::classRedefinedCount(the_class_mirror)); } - RC_TIMER_STOP(_timer_rsc_phase2); + _timer_rsc_phase2.stop(); } // end redefine_single_class() @@ -4136,8 +4022,7 @@ void VM_RedefineClasses::increment_class_counter(InstanceKlass *ik, TRAPS) { if (class_oop != _the_class_oop) { // _the_class_oop count is printed at end of redefine_single_class() - RC_TRACE_WITH_THREAD(0x00000008, THREAD, - ("updated count in subclass=%s to %d", ik->external_name(), new_count)); + log_debug(redefine, class, subclass)("updated count in subclass=%s to %d", ik->external_name(), new_count); } for (Klass *subk = ik->subklass(); subk != NULL; @@ -4159,11 +4044,10 @@ void VM_RedefineClasses::CheckClass::do_klass(Klass* k) { ResourceMark rm(_thread); if (k->vtable_length() > 0 && !k->vtable()->check_no_old_or_obsolete_entries()) { - if (RC_TRACE_ENABLED(0x00004000)) { - RC_TRACE_WITH_THREAD(0x00004000, _thread, - ("klassVtable::check_no_old_or_obsolete_entries failure" - " -- OLD or OBSOLETE method found -- class: %s", - k->signature_name())); + if (log_is_enabled(Trace, redefine, class, obsolete, metadata)) { + log_trace(redefine, class, obsolete, metadata) + ("klassVtable::check_no_old_or_obsolete_entries failure -- OLD or OBSOLETE method found -- class: %s", + k->signature_name()); k->vtable()->dump_vtable(); } no_old_methods = false; @@ -4176,11 +4060,10 @@ void VM_RedefineClasses::CheckClass::do_klass(Klass* k) { // an itable should never contain old or obsolete methods if (ik->itable_length() > 0 && !ik->itable()->check_no_old_or_obsolete_entries()) { - if (RC_TRACE_ENABLED(0x00004000)) { - RC_TRACE_WITH_THREAD(0x00004000, _thread, - ("klassItable::check_no_old_or_obsolete_entries failure" - " -- OLD or OBSOLETE method found -- class: %s", - ik->signature_name())); + if (log_is_enabled(Trace, redefine, class, obsolete, metadata)) { + log_trace(redefine, class, obsolete, metadata) + ("klassItable::check_no_old_or_obsolete_entries failure -- OLD or OBSOLETE method found -- class: %s", + ik->signature_name()); ik->itable()->dump_itable(); } no_old_methods = false; @@ -4190,11 +4073,10 @@ void VM_RedefineClasses::CheckClass::do_klass(Klass* k) { if (ik->constants() != NULL && ik->constants()->cache() != NULL && !ik->constants()->cache()->check_no_old_or_obsolete_entries()) { - if (RC_TRACE_ENABLED(0x00004000)) { - RC_TRACE_WITH_THREAD(0x00004000, _thread, - ("cp-cache::check_no_old_or_obsolete_entries failure" - " -- OLD or OBSOLETE method found -- class: %s", - ik->signature_name())); + if (log_is_enabled(Trace, redefine, class, obsolete, metadata)) { + log_trace(redefine, class, obsolete, metadata) + ("cp-cache::check_no_old_or_obsolete_entries failure -- OLD or OBSOLETE method found -- class: %s", + ik->signature_name()); ik->constants()->cache()->dump_cache(); } no_old_methods = false; @@ -4203,10 +4085,10 @@ void VM_RedefineClasses::CheckClass::do_klass(Klass* k) { // print and fail guarantee if old methods are found. if (!no_old_methods) { - if (RC_TRACE_ENABLED(0x00004000)) { + if (log_is_enabled(Trace, redefine, class, obsolete, metadata)) { dump_methods(); } else { - tty->print_cr("INFO: use the '-XX:TraceRedefineClasses=16384' option " + log_trace(redefine, class)("Use the '-Xlog:redefine+class*:' option " "to see more info about the following guarantee() failure."); } guarantee(false, "OLD and/or OBSOLETE method(s) found"); @@ -4216,54 +4098,60 @@ void VM_RedefineClasses::CheckClass::do_klass(Klass* k) { void VM_RedefineClasses::dump_methods() { int j; - RC_TRACE(0x00004000, ("_old_methods --")); + log_trace(redefine, class, dump)("_old_methods --"); for (j = 0; j < _old_methods->length(); ++j) { + LogStreamHandle(Trace, redefine, class, dump) log_stream; Method* m = _old_methods->at(j); - RC_TRACE_NO_CR(0x00004000, ("%4d (%5d) ", j, m->vtable_index())); - m->access_flags().print_on(tty); - tty->print(" -- "); - m->print_name(tty); - tty->cr(); + log_stream.print("%4d (%5d) ", j, m->vtable_index()); + m->access_flags().print_on(&log_stream); + log_stream.print(" -- "); + m->print_name(&log_stream); + log_stream.cr(); } - RC_TRACE(0x00004000, ("_new_methods --")); + log_trace(redefine, class, dump)("_new_methods --"); for (j = 0; j < _new_methods->length(); ++j) { + LogStreamHandle(Trace, redefine, class, dump) log_stream; Method* m = _new_methods->at(j); - RC_TRACE_NO_CR(0x00004000, ("%4d (%5d) ", j, m->vtable_index())); - m->access_flags().print_on(tty); - tty->print(" -- "); - m->print_name(tty); - tty->cr(); + log_stream.print("%4d (%5d) ", j, m->vtable_index()); + m->access_flags().print_on(&log_stream); + log_stream.print(" -- "); + m->print_name(&log_stream); + log_stream.cr(); } - RC_TRACE(0x00004000, ("_matching_(old/new)_methods --")); + log_trace(redefine, class, dump)("_matching_methods --"); for (j = 0; j < _matching_methods_length; ++j) { + LogStreamHandle(Trace, redefine, class, dump) log_stream; Method* m = _matching_old_methods[j]; - RC_TRACE_NO_CR(0x00004000, ("%4d (%5d) ", j, m->vtable_index())); - m->access_flags().print_on(tty); - tty->print(" -- "); - m->print_name(tty); - tty->cr(); + log_stream.print("%4d (%5d) ", j, m->vtable_index()); + m->access_flags().print_on(&log_stream); + log_stream.print(" -- "); + m->print_name(); + log_stream.cr(); + m = _matching_new_methods[j]; - RC_TRACE_NO_CR(0x00004000, (" (%5d) ", m->vtable_index())); - m->access_flags().print_on(tty); - tty->cr(); + log_stream.print(" (%5d) ", m->vtable_index()); + m->access_flags().print_on(&log_stream); + log_stream.cr(); } - RC_TRACE(0x00004000, ("_deleted_methods --")); + log_trace(redefine, class, dump)("_deleted_methods --"); for (j = 0; j < _deleted_methods_length; ++j) { + LogStreamHandle(Trace, redefine, class, dump) log_stream; Method* m = _deleted_methods[j]; - RC_TRACE_NO_CR(0x00004000, ("%4d (%5d) ", j, m->vtable_index())); - m->access_flags().print_on(tty); - tty->print(" -- "); - m->print_name(tty); - tty->cr(); + log_stream.print("%4d (%5d) ", j, m->vtable_index()); + m->access_flags().print_on(&log_stream); + log_stream.print(" -- "); + m->print_name(&log_stream); + log_stream.cr(); } - RC_TRACE(0x00004000, ("_added_methods --")); + log_trace(redefine, class, dump)("_added_methods --"); for (j = 0; j < _added_methods_length; ++j) { + LogStreamHandle(Trace, redefine, class, dump) log_stream; Method* m = _added_methods[j]; - RC_TRACE_NO_CR(0x00004000, ("%4d (%5d) ", j, m->vtable_index())); - m->access_flags().print_on(tty); - tty->print(" -- "); - m->print_name(tty); - tty->cr(); + log_stream.print("%4d (%5d) ", j, m->vtable_index()); + m->access_flags().print_on(&log_stream); + log_stream.print(" -- "); + m->print_name(&log_stream); + log_stream.cr(); } } diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp index b4c0cc63694..ffeebfb5754 100644 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp @@ -30,7 +30,6 @@ #include "memory/resourceArea.hpp" #include "oops/objArrayKlass.hpp" #include "oops/objArrayOop.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/vm_operations.hpp" // Introduction: diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp b/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp deleted file mode 100644 index 43174e49426..00000000000 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClassesTrace.hpp +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_VM_PRIMS_JVMTIREDEFINECLASSESTRACE_HPP -#define SHARE_VM_PRIMS_JVMTIREDEFINECLASSESTRACE_HPP - -// RedefineClasses tracing support via the TraceRedefineClasses -// option. A bit is assigned to each group of trace messages. -// Groups of messages are individually selectable. We have to use -// decimal values on the command line since the command option -// parsing logic doesn't like non-decimal numerics. The HEX values -// are used in the actual RC_TRACE() calls for sanity. To achieve -// the old cumulative behavior, pick the level after the one in -// which you are interested and subtract one, e.g., 33554431 will -// print every tracing message. -// -// 0x00000000 | 0 - default; no tracing messages -// 0x00000001 | 1 - name each target class before loading, after -// loading and after redefinition is completed -// 0x00000002 | 2 - print info if parsing, linking or -// verification throws an exception -// 0x00000004 | 4 - print timer info for the VM operation -// 0x00000008 | 8 - print subclass counter updates -// 0x00000010 | 16 - unused -// 0x00000020 | 32 - unused -// 0x00000040 | 64 - unused -// 0x00000080 | 128 - unused -// 0x00000100 | 256 - previous class weak reference addition -// 0x00000200 | 512 - previous class weak reference mgmt during -// class unloading checks (GC) -// 0x00000400 | 1024 - previous class weak reference mgmt during -// add previous ops (GC) -// 0x00000800 | 2048 - previous class breakpoint mgmt -// 0x00001000 | 4096 - detect calls to obsolete methods -// 0x00002000 | 8192 - fail a guarantee() in addition to detection -// 0x00004000 | 16384 - detect old/obsolete methods in metadata -// 0x00008000 | 32768 - old/new method matching/add/delete -// 0x00010000 | 65536 - impl details: CP size info -// 0x00020000 | 131072 - impl details: CP merge pass info -// 0x00040000 | 262144 - impl details: CP index maps -// 0x00080000 | 524288 - impl details: modified CP index values -// 0x00100000 | 1048576 - impl details: vtable updates -// 0x00200000 | 2097152 - impl details: itable updates -// 0x00400000 | 4194304 - impl details: constant pool cache updates -// 0x00800000 | 8388608 - impl details: methodComparator info -// 0x01000000 | 16777216 - impl details: nmethod evolution info -// 0x02000000 | 33554432 - impl details: annotation updates -// 0x04000000 | 67108864 - impl details: StackMapTable updates -// 0x08000000 | 134217728 - impl details: OopMapCache updates -// 0x10000000 | 268435456 - unused -// 0x20000000 | 536870912 - unused -// 0x40000000 | 1073741824 - unused -// 0x80000000 | 2147483648 - unused - -// Macro for checking if TraceRedefineClasses has a specific bit -// enabled. Returns true if the bit specified by level is set. -#define RC_TRACE_ENABLED(level) ((TraceRedefineClasses & level) != 0) - -// Macro for checking if TraceRedefineClasses has one or more bits -// set in a range of bit values. Returns true if one or more bits -// is set in the range from low..high inclusive. Assumes that low -// and high are single bit values. -// -// ((high << 1) - 1) -// Yields a mask that removes bits greater than the high bit value. -// This algorithm doesn't work with highest bit. -// ~(low - 1) -// Yields a mask that removes bits lower than the low bit value. -#define RC_TRACE_IN_RANGE(low, high) \ -(((TraceRedefineClasses & ((high << 1) - 1)) & ~(low - 1)) != 0) - -// Note: The ResourceMark is to cleanup resource allocated args. -// The "do {...} while (0)" is so we can use semi-colon at end of RC_TRACE(). -#define RC_TRACE(level, args) do { \ - if (RC_TRACE_ENABLED(level)) { \ - ResourceMark rm; \ - tty->print("RedefineClasses-0x%x: ", level); \ - tty->print_cr args; \ - } \ -} while (0) - -#define RC_TRACE_NO_CR(level, args) do { \ - if (RC_TRACE_ENABLED(level)) { \ - ResourceMark rm; \ - tty->print("RedefineClasses-0x%x: ", level); \ - tty->print args; \ - } \ -} while (0) - -#define RC_TRACE_WITH_THREAD(level, thread, args) do { \ - if (RC_TRACE_ENABLED(level)) { \ - ResourceMark rm(thread); \ - tty->print("RedefineClasses-0x%x: ", level); \ - tty->print_cr args; \ - } \ -} while (0) - -#define RC_TRACE_MESG(args) do { \ - ResourceMark rm; \ - tty->print("RedefineClasses: "); \ - tty->print_cr args; \ -} while (0) - -// Timer support macros. Only do timer operations if timer tracing is enabled. -// The "do {...} while (0)" is so we can use semi-colon at end of the macro. -#define RC_TIMER_START(t) do { \ - if (RC_TRACE_ENABLED(0x00000004)) { \ - t.start(); \ - } \ -} while (0) -#define RC_TIMER_STOP(t) do { \ - if (RC_TRACE_ENABLED(0x00000004)) { \ - t.stop(); \ - } \ -} while (0) - -#endif // SHARE_VM_PRIMS_JVMTIREDEFINECLASSESTRACE_HPP diff --git a/hotspot/src/share/vm/prims/methodComparator.cpp b/hotspot/src/share/vm/prims/methodComparator.cpp index e143409c6f4..5a5575729d5 100644 --- a/hotspot/src/share/vm/prims/methodComparator.cpp +++ b/hotspot/src/share/vm/prims/methodComparator.cpp @@ -25,7 +25,6 @@ #include "precompiled.hpp" #include "oops/oop.inline.hpp" #include "oops/symbol.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "prims/methodComparator.hpp" #include "runtime/handles.inline.hpp" #include "utilities/globalDefinitions.hpp" @@ -39,10 +38,12 @@ bool MethodComparator::methods_EMCP(Method* old_method, Method* new_method) { if (old_method->code_size() != new_method->code_size()) return false; if (check_stack_and_locals_size(old_method, new_method) != 0) { - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE(0x00800000, ("Methods %s non-comparable with diagnosis %d", - old_method->name()->as_C_string(), - check_stack_and_locals_size(old_method, new_method))); + if (log_is_enabled(Debug, redefine, class, methodcomparator)) { + ResourceMark rm; + log_debug(redefine, class, methodcomparator) + ("Methods %s non-comparable with diagnosis %d", + old_method->name()->as_C_string(), check_stack_and_locals_size(old_method, new_method)); + } return false; } diff --git a/hotspot/src/share/vm/prims/methodHandles.cpp b/hotspot/src/share/vm/prims/methodHandles.cpp index b4abd306781..7b1782a2904 100644 --- a/hotspot/src/share/vm/prims/methodHandles.cpp +++ b/hotspot/src/share/vm/prims/methodHandles.cpp @@ -38,7 +38,6 @@ #include "oops/objArrayOop.inline.hpp" #include "oops/oop.inline.hpp" #include "prims/methodHandles.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "runtime/compilationPolicy.hpp" #include "runtime/javaCalls.hpp" #include "runtime/timerTrace.hpp" @@ -1084,17 +1083,15 @@ void MemberNameTable::adjust_method_entries(InstanceKlass* holder, bool * trace_ java_lang_invoke_MemberName::set_vmtarget(mem_name, new_method); - if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) { + if (log_is_enabled(Info, redefine, class, update)) { + ResourceMark rm; if (!(*trace_name_printed)) { - // RC_TRACE_MESG macro has an embedded ResourceMark - RC_TRACE_MESG(("adjust: name=%s", - old_method->method_holder()->external_name())); + log_info(redefine, class, update)("adjust: name=%s", old_method->method_holder()->external_name()); *trace_name_printed = true; } - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE(0x00400000, ("MemberName method update: %s(%s)", - new_method->name()->as_C_string(), - new_method->signature()->as_C_string())); + log_debug(redefine, class, update, constantpool) + ("MemberName method update: %s(%s)", + new_method->name()->as_C_string(), new_method->signature()->as_C_string()); } } } diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 24014a2eab8..630f7a71794 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -420,6 +420,7 @@ static AliasedLoggingFlag const aliased_logging_flags[] = { { "TraceMonitorInflation", LogLevel::Debug, true, LOG_TAGS(monitorinflation) }, { "TraceSafepointCleanupTime", LogLevel::Info, true, LOG_TAGS(safepoint, cleanup) }, { "TraceJVMTIObjectTagging", LogLevel::Debug, true, LOG_TAGS(jvmti, objecttagging) }, + { "TraceRedefineClasses", LogLevel::Info, false, LOG_TAGS(redefine, class) }, { NULL, LogLevel::Off, false, LOG_TAGS(_NO_TAG) } }; @@ -804,7 +805,9 @@ void log_deprecated_flag(const char* name, bool on, AliasedLoggingFlag alf) { } strncat(tagset_buffer, LogTag::name(tagSet[i]), max_tagset_len - strlen(tagset_buffer)); } - + if (!alf.exactMatch) { + strncat(tagset_buffer, "*", max_tagset_len - strlen(tagset_buffer)); + } log_warning(arguments)("-XX:%s%s is deprecated. Will use -Xlog:%s=%s instead.", (on) ? "+" : "-", name, @@ -865,6 +868,11 @@ bool Arguments::parse_argument(const char* arg, Flag::Flags origin) { Flag* flag; // this scanf pattern matches both strings (handled here) and numbers (handled later)) + AliasedLoggingFlag alf = catch_logging_aliases(name, true); + if (alf.alias_name != NULL) { + LogConfiguration::configure_stdout(alf.level, alf.exactMatch, alf.tag0, alf.tag1, alf.tag2, alf.tag3, alf.tag4, alf.tag5); + return true; + } real_name = handle_aliases_and_deprecation(name, warn_if_deprecated); if (real_name == NULL) { return false; diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 3fb93e1b236..40ab68f43a2 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -1418,10 +1418,6 @@ public: product(bool, StressLdcRewrite, false, \ "Force ldc -> ldc_w rewrite during RedefineClasses") \ \ - product(uintx, TraceRedefineClasses, 0, \ - "Trace level for JVMTI RedefineClasses") \ - range(0, 0xFFFFFFFF) \ - \ /* change to false by default sometime after Mustang */ \ product(bool, VerifyMergedCPBytecodes, true, \ "Verify bytecodes after RedefineClasses constant pool merging") \ diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index 4e0aec4a423..eba1d72ff3a 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -46,7 +46,6 @@ #include "oops/oop.inline.hpp" #include "prims/forte.hpp" #include "prims/jvmtiExport.hpp" -#include "prims/jvmtiRedefineClassesTrace.hpp" #include "prims/methodHandles.hpp" #include "prims/nativeLookup.hpp" #include "runtime/arguments.hpp" @@ -603,27 +602,18 @@ void SharedRuntime::throw_and_post_jvmti_exception(JavaThread *thread, Symbol* n } // The interpreter code to call this tracing function is only -// called/generated when TraceRedefineClasses has the right bits -// set. Since obsolete methods are never compiled, we don't have +// called/generated when UL is on for redefine, class and has the right level +// and tags. Since obsolete methods are never compiled, we don't have // to modify the compilers to generate calls to this function. // JRT_LEAF(int, SharedRuntime::rc_trace_method_entry( JavaThread* thread, Method* method)) - assert(RC_TRACE_IN_RANGE(0x00001000, 0x00002000), "wrong call"); - if (method->is_obsolete()) { // We are calling an obsolete method, but this is not necessarily // an error. Our method could have been redefined just after we // fetched the Method* from the constant pool. - - // RC_TRACE macro has an embedded ResourceMark - RC_TRACE_WITH_THREAD(0x00001000, thread, - ("calling obsolete method '%s'", - method->name_and_sig_as_C_string())); - if (RC_TRACE_ENABLED(0x00002000)) { - // this option is provided to debug calls to obsolete methods - guarantee(false, "faulting at call to an obsolete method."); - } + ResourceMark rm; + log_trace(redefine, class, obsolete)("calling obsolete method '%s'", method->name_and_sig_as_C_string()); } return 0; JRT_END -- GitLab From f4ffadd18be7dc49cd2fed3dc100f6abc885069d Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Mon, 9 May 2016 23:41:41 +0300 Subject: [PATCH 320/400] 8155091: Remove SA related functions from tmtools Remove options that enables support for non-cooperative mode Reviewed-by: alanb, mchung, sla --- .../share/classes/module-info.java | 10 ---- .../jvm/hotspot/tools/ClassLoaderStats.java | 8 +-- .../sun/jvm/hotspot/tools/FinalizerInfo.java | 8 +-- .../sun/jvm/hotspot/tools/HeapDumper.java | 8 ++- .../sun/jvm/hotspot/tools/HeapSummary.java | 8 +-- .../classes/sun/jvm/hotspot/tools/JInfo.java | 9 ++-- .../classes/sun/jvm/hotspot/tools/JStack.java | 9 ++-- .../jvm/hotspot/tools/ObjectHistogram.java | 50 ++++++++----------- .../classes/sun/jvm/hotspot/tools/PMap.java | 8 +-- .../sa/jmap-hashcode/Test8028623.java | 9 ++-- .../sa/jmap-hprof/JMapHProfLargeHeapTest.java | 39 ++++++--------- 11 files changed, 56 insertions(+), 110 deletions(-) diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java b/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java index 85b163bcd02..65b804d0857 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/module-info.java @@ -28,7 +28,6 @@ module jdk.hotspot.agent { requires java.desktop; requires java.rmi; requires java.scripting; - requires jdk.jcmd; requires jdk.jdi; // RMI needs to serialize types in this package @@ -37,13 +36,4 @@ module jdk.hotspot.agent { provides com.sun.jdi.connect.Connector with sun.jvm.hotspot.jdi.SADebugServerAttachingConnector; provides com.sun.jdi.connect.Connector with sun.jvm.hotspot.jdi.SAPIDAttachingConnector; - provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.JStack; - provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.JInfo; - provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.ClassLoaderStats; - provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.FinalizerInfo; - provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.HeapDumper; - provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.HeapSummary; - provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.ObjectHistogram; - provides jdk.internal.vm.agent.spi.ToolProvider with sun.jvm.hotspot.tools.PMap; } - diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java index 34f5bfbefef..8dac3a84656 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ClassLoaderStats.java @@ -32,13 +32,12 @@ import sun.jvm.hotspot.memory.*; import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.utilities.*; -import jdk.internal.vm.agent.spi.ToolProvider; /** A command line tool to print class loader statistics. */ -public class ClassLoaderStats extends Tool implements ToolProvider { +public class ClassLoaderStats extends Tool { boolean verbose = true; public ClassLoaderStats() { @@ -54,11 +53,6 @@ public class ClassLoaderStats extends Tool implements ToolProvider { return "classLoaderStats"; } - @Override - public void run(String... arguments) { - execute(arguments); - } - public static void main(String[] args) { ClassLoaderStats cls = new ClassLoaderStats(); cls.execute(args); diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java index 9da8e523afb..3f5c55a46d6 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/FinalizerInfo.java @@ -28,7 +28,6 @@ import sun.jvm.hotspot.debugger.JVMDebugger; import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.utilities.SystemDictionaryHelper; -import jdk.internal.vm.agent.spi.ToolProvider; import java.util.ArrayList; import java.util.Collections; @@ -39,7 +38,7 @@ import java.util.HashMap; * Iterates over the queue of object pending finalization and prints a * summary of these objects in the form of a histogram. */ -public class FinalizerInfo extends Tool implements ToolProvider { +public class FinalizerInfo extends Tool { public FinalizerInfo() { super(); @@ -54,11 +53,6 @@ public class FinalizerInfo extends Tool implements ToolProvider { return "finalizerInfo"; } - @Override - public void run(String... arguments) { - execute(arguments); - } - public static void main(String[] args) { FinalizerInfo finfo = new FinalizerInfo(); finfo.execute(args); diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapDumper.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapDumper.java index d0a11abd095..b2cf190bf3b 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapDumper.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapDumper.java @@ -26,7 +26,6 @@ package sun.jvm.hotspot.tools; import sun.jvm.hotspot.utilities.HeapHprofBinWriter; import sun.jvm.hotspot.debugger.JVMDebugger; -import jdk.internal.vm.agent.spi.ToolProvider; import java.io.IOException; @@ -35,7 +34,7 @@ import java.io.IOException; * process/core as a HPROF binary file. It can also be used as a standalone * tool if required. */ -public class HeapDumper extends Tool implements ToolProvider { +public class HeapDumper extends Tool { private static String DEFAULT_DUMP_FILE = "heap.bin"; @@ -81,11 +80,10 @@ public class HeapDumper extends Tool implements ToolProvider { // HeapDumper -f public static void main(String args[]) { HeapDumper dumper = new HeapDumper(); - dumper.run(args); + dumper.runWithArgs(args); } - @Override - public void run(String... args) { + public void runWithArgs(String... args) { if (args.length > 2) { if (args[0].equals("-f")) { this.dumpFile = args[1]; diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java index 5c1012bf644..643109bc1e9 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java @@ -33,9 +33,8 @@ import sun.jvm.hotspot.debugger.JVMDebugger; import sun.jvm.hotspot.memory.*; import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.runtime.*; -import jdk.internal.vm.agent.spi.ToolProvider; -public class HeapSummary extends Tool implements ToolProvider { +public class HeapSummary extends Tool { public HeapSummary() { super(); @@ -55,11 +54,6 @@ public class HeapSummary extends Tool implements ToolProvider { return "heapSummary"; } - @Override - public void run(String... arguments) { - execute(arguments); - } - public void run() { CollectedHeap heap = VM.getVM().getUniverse().heap(); VM.Flag[] flags = VM.getVM().getCommandLineFlags(); diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JInfo.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JInfo.java index 50f9c30975b..3e724b979a0 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JInfo.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JInfo.java @@ -27,9 +27,8 @@ package sun.jvm.hotspot.tools; import sun.jvm.hotspot.debugger.JVMDebugger; import sun.jvm.hotspot.runtime.Arguments; import sun.jvm.hotspot.runtime.VM; -import jdk.internal.vm.agent.spi.ToolProvider; -public class JInfo extends Tool implements ToolProvider { +public class JInfo extends Tool { public JInfo() { super(); } @@ -46,6 +45,7 @@ public class JInfo extends Tool implements ToolProvider { return false; } + @Override public String getName() { return "jinfo"; } @@ -95,8 +95,7 @@ public class JInfo extends Tool implements ToolProvider { tool.run(); } - @Override - public void run(String... args) { + public void runWithArgs(String... args) { int mode = -1; switch (args.length) { case 1: @@ -142,7 +141,7 @@ public class JInfo extends Tool implements ToolProvider { public static void main(String[] args) { JInfo jinfo = new JInfo(); - jinfo.run(args); + jinfo.runWithArgs(args); } private void printVMFlags() { diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JStack.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JStack.java index 821ed388853..65757702645 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JStack.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/JStack.java @@ -25,9 +25,8 @@ package sun.jvm.hotspot.tools; import sun.jvm.hotspot.debugger.JVMDebugger; -import jdk.internal.vm.agent.spi.ToolProvider; -public class JStack extends Tool implements ToolProvider { +public class JStack extends Tool { public JStack(boolean mixedMode, boolean concurrentLocks) { this.mixedMode = mixedMode; this.concurrentLocks = concurrentLocks; @@ -45,6 +44,7 @@ public class JStack extends Tool implements ToolProvider { return false; } + @Override public String getName() { return "jstack"; } @@ -67,8 +67,7 @@ public class JStack extends Tool implements ToolProvider { tool.run(); } - @Override - public void run(String... args) { + public void runWithArgs(String... args) { int used = 0; for (int i = 0; i < args.length; i++) { if (args[i].equals("-m")) { @@ -93,7 +92,7 @@ public class JStack extends Tool implements ToolProvider { public static void main(String[] args) { JStack jstack = new JStack(); - jstack.run(args); + jstack.runWithArgs(args); } private boolean mixedMode; diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java index 0dc100eebe5..414f857df35 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/ObjectHistogram.java @@ -27,52 +27,46 @@ package sun.jvm.hotspot.tools; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.oops.*; import sun.jvm.hotspot.runtime.*; -import jdk.internal.vm.agent.spi.ToolProvider; import java.io.PrintStream; /** A sample tool which uses the Serviceability Agent's APIs to obtain an object histogram from a remote or crashed VM. */ -public class ObjectHistogram extends Tool implements ToolProvider { +public class ObjectHistogram extends Tool { public ObjectHistogram() { - super(); + super(); } public ObjectHistogram(JVMDebugger d) { - super(d); + super(d); } @Override public String getName() { - return "objectHistogram"; + return "objectHistogram"; } - @Override - public void run(String... arguments) { - execute(arguments); + public void run() { + run(System.out, System.err); } - public void run() { - run(System.out, System.err); - } - - public void run(PrintStream out, PrintStream err) { - // Ready to go with the database... - ObjectHeap heap = VM.getVM().getObjectHeap(); - sun.jvm.hotspot.oops.ObjectHistogram histogram = + public void run(PrintStream out, PrintStream err) { + // Ready to go with the database... + ObjectHeap heap = VM.getVM().getObjectHeap(); + sun.jvm.hotspot.oops.ObjectHistogram histogram = new sun.jvm.hotspot.oops.ObjectHistogram(); - err.println("Iterating over heap. This may take a while..."); - long startTime = System.currentTimeMillis(); - heap.iterate(histogram); - long endTime = System.currentTimeMillis(); - histogram.printOn(out); - float secs = (float) (endTime - startTime) / 1000.0f; - err.println("Heap traversal took " + secs + " seconds."); - } + err.println("Iterating over heap. This may take a while..."); + long startTime = System.currentTimeMillis(); + heap.iterate(histogram); + long endTime = System.currentTimeMillis(); + histogram.printOn(out); + float secs = (float) (endTime - startTime) / 1000.0f; + err.println("Heap traversal took " + secs + " seconds."); + } - public static void main(String[] args) { - ObjectHistogram oh = new ObjectHistogram(); - oh.execute(args); - } + public static void main(String[] args) { + ObjectHistogram oh = new ObjectHistogram(); + oh.execute(args); + } } diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java index 0c0ccbf6c8c..484994c666e 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/PMap.java @@ -28,9 +28,8 @@ import java.io.*; import java.util.*; import sun.jvm.hotspot.debugger.*; import sun.jvm.hotspot.debugger.cdbg.*; -import jdk.internal.vm.agent.spi.ToolProvider; -public class PMap extends Tool implements ToolProvider { +public class PMap extends Tool { public PMap() { super(); @@ -45,11 +44,6 @@ public class PMap extends Tool implements ToolProvider { return "pmap"; } - @Override - public void run(String... arguments) { - execute(arguments); - } - public void run() { run(System.out); } diff --git a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java index 746ef827957..0328e393339 100644 --- a/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java +++ b/hotspot/test/serviceability/sa/jmap-hashcode/Test8028623.java @@ -44,7 +44,7 @@ import java.io.File; public class Test8028623 { public static int \u00CB = 1; - public static String dumpFile = "heap.out"; + public static String dumpFile = "heap.bin"; public static void main (String[] args) { @@ -56,9 +56,10 @@ public class Test8028623 { return; } long pid = ProcessTools.getProcessId(); - JDKToolLauncher jmap = JDKToolLauncher.create("jmap") - .addToolArg("-F") - .addToolArg("-dump:live,format=b,file=" + dumpFile) + JDKToolLauncher jmap = JDKToolLauncher.create("jhsdb") + .addToolArg("jmap") + .addToolArg("--binaryheap") + .addToolArg("--pid") .addToolArg(Long.toString(pid)); ProcessBuilder pb = new ProcessBuilder(jmap.getCommand()); OutputBuffer output = ProcessTools.getOutput(pb); diff --git a/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java b/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java index c1b6e955ef8..077617b2fb0 100644 --- a/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java +++ b/hotspot/test/serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java @@ -53,33 +53,22 @@ import jdk.test.lib.ProcessTools; */ public class JMapHProfLargeHeapTest { - private static final String HEAP_DUMP_FILE_NAME = "heap.hprof"; + private static final String HEAP_DUMP_FILE_NAME = "heap.bin"; + private static final String HPROF_HEADER_1_0_1 = "JAVA PROFILE 1.0.1"; private static final String HPROF_HEADER_1_0_2 = "JAVA PROFILE 1.0.2"; private static final long M = 1024L; private static final long G = 1024L * M; public static void main(String[] args) throws Exception { - // If we are on MacOSX, test if JMap tool is signed, otherwise return - // since test will fail with privilege error. - if (Platform.isOSX()) { - String jmapToolPath = JDKToolFinder.getTestJDKTool("jmap"); - ProcessBuilder codesignProcessBuilder = new ProcessBuilder( - "codesign", "-v", jmapToolPath); - Process codesignProcess = codesignProcessBuilder.start(); - OutputAnalyzer analyser = new OutputAnalyzer(codesignProcess); - try { - analyser.shouldNotContain("code object is not signed at all"); - System.out.println("Signed jmap found at: " + jmapToolPath); - } catch (Exception e) { - // Abort since we can't know if the test will work - System.out - .println("Test aborted since we are on MacOSX and the jmap tool is not signed."); - return; - } + if (!Platform.shouldSAAttach()) { + System.out.println("SA attach not expected to work - test skipped."); + return; } // All heap dumps should create 1.0.2 file format - testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_2); + // Hotspot internal heapdumper always use HPROF_HEADER_1_0_2 format, + // but SA heapdumper still use HPROF_HEADER_1_0_1 for small heaps + testHProfFileFormat("-Xmx1g", 22 * M, HPROF_HEADER_1_0_1); /** * This test was deliberately commented out since the test system lacks @@ -110,9 +99,10 @@ public class JMapHProfLargeHeapTest { System.out.println("Extracted pid: " + pid); JDKToolLauncher jMapLauncher = JDKToolLauncher - .createUsingTestJDK("jmap"); - jMapLauncher.addToolArg("-dump:format=b,file=" + pid + "-" - + HEAP_DUMP_FILE_NAME); + .createUsingTestJDK("jhsdb"); + jMapLauncher.addToolArg("jmap"); + jMapLauncher.addToolArg("--binaryheap"); + jMapLauncher.addToolArg("--pid"); jMapLauncher.addToolArg(String.valueOf(pid)); ProcessBuilder jMapProcessBuilder = new ProcessBuilder( @@ -123,12 +113,11 @@ public class JMapHProfLargeHeapTest { Process jMapProcess = jMapProcessBuilder.start(); OutputAnalyzer analyzer = new OutputAnalyzer(jMapProcess); analyzer.shouldHaveExitValue(0); - analyzer.shouldContain(pid + "-" + HEAP_DUMP_FILE_NAME); - analyzer.shouldContain("Heap dump file created"); + analyzer.shouldContain(HEAP_DUMP_FILE_NAME); largeHeapProc.getOutputStream().write('\n'); - File dumpFile = new File(pid + "-" + HEAP_DUMP_FILE_NAME); + File dumpFile = new File(HEAP_DUMP_FILE_NAME); Asserts.assertTrue(dumpFile.exists(), "Heap dump file not found."); try (Reader reader = new BufferedReader(new FileReader(dumpFile))) { -- GitLab From 17dce93f31eaed849a915cc27bdb1088896b30da Mon Sep 17 00:00:00 2001 From: Marcus Larsson Date: Mon, 9 May 2016 15:46:12 +0200 Subject: [PATCH 321/400] 8145934: Make ttyLocker equivalent for Unified Logging framework Reviewed-by: rprotacio, stuefe, jrose --- hotspot/src/os/posix/vm/os_posix.cpp | 8 + hotspot/src/os/windows/vm/os_windows.cpp | 8 + hotspot/src/share/vm/logging/log.cpp | 399 +++++++++++++++--- hotspot/src/share/vm/logging/log.hpp | 6 + .../src/share/vm/logging/logDecorations.cpp | 7 +- .../src/share/vm/logging/logDecorations.hpp | 11 + .../src/share/vm/logging/logDecorators.hpp | 4 + .../src/share/vm/logging/logFileOutput.cpp | 18 + .../src/share/vm/logging/logFileOutput.hpp | 1 + .../share/vm/logging/logFileStreamOutput.cpp | 50 ++- .../share/vm/logging/logFileStreamOutput.hpp | 5 +- hotspot/src/share/vm/logging/logMessage.hpp | 105 +++++ .../src/share/vm/logging/logMessageBuffer.cpp | 146 +++++++ .../src/share/vm/logging/logMessageBuffer.hpp | 131 ++++++ hotspot/src/share/vm/logging/logOutput.hpp | 5 +- .../src/share/vm/logging/logOutputList.hpp | 4 + hotspot/src/share/vm/logging/logPrefix.hpp | 9 +- hotspot/src/share/vm/logging/logTagSet.cpp | 8 + hotspot/src/share/vm/logging/logTagSet.hpp | 3 + hotspot/src/share/vm/runtime/os.hpp | 2 + .../share/vm/utilities/internalVMTests.cpp | 1 + 21 files changed, 858 insertions(+), 73 deletions(-) create mode 100644 hotspot/src/share/vm/logging/logMessage.hpp create mode 100644 hotspot/src/share/vm/logging/logMessageBuffer.cpp create mode 100644 hotspot/src/share/vm/logging/logMessageBuffer.hpp diff --git a/hotspot/src/os/posix/vm/os_posix.cpp b/hotspot/src/os/posix/vm/os_posix.cpp index a7622b6cb96..ad10c82a5b2 100644 --- a/hotspot/src/os/posix/vm/os_posix.cpp +++ b/hotspot/src/os/posix/vm/os_posix.cpp @@ -327,6 +327,14 @@ FILE* os::open(int fd, const char* mode) { return ::fdopen(fd, mode); } +void os::flockfile(FILE* fp) { + ::flockfile(fp); +} + +void os::funlockfile(FILE* fp) { + ::funlockfile(fp); +} + // Builds a platform dependent Agent_OnLoad_ function name // which is used to find statically linked in agents. // Parameters: diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index f4ddaba010f..02ab770ccb3 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -4661,6 +4661,14 @@ int os::available(int fd, jlong *bytes) { } } +void os::flockfile(FILE* fp) { + _lock_file(fp); +} + +void os::funlockfile(FILE* fp) { + _unlock_file(fp); +} + // This code is a copy of JDK's nonSeekAvailable // from src/windows/hpi/src/sys_api_md.c diff --git a/hotspot/src/share/vm/logging/log.cpp b/hotspot/src/share/vm/logging/log.cpp index cdef6d8a7ab..598cb31fc4a 100644 --- a/hotspot/src/share/vm/logging/log.cpp +++ b/hotspot/src/share/vm/logging/log.cpp @@ -32,6 +32,8 @@ #include "logging/log.hpp" #include "logging/logConfiguration.hpp" #include "logging/logFileOutput.hpp" +#include "logging/logMessage.hpp" +#include "logging/logMessageBuffer.hpp" #include "logging/logOutput.hpp" #include "logging/logTagLevelExpression.hpp" #include "logging/logTagSet.hpp" @@ -54,6 +56,102 @@ void Test_log_tag_combinations_limit() { LogTagLevelExpression::MaxCombinations, LogTagSet::ntagsets()); } +// Read a complete line from fp and return it as a resource allocated string. +// Returns NULL on EOF. +static char* read_line(FILE* fp) { + assert(fp != NULL, "bad fp"); + int buflen = 512; + char* buf = NEW_RESOURCE_ARRAY(char, buflen); + long pos = ftell(fp); + + char* ret = fgets(buf, buflen, fp); + while (ret != NULL && buf[strlen(buf) - 1] != '\n' && !feof(fp)) { + // retry with a larger buffer + buf = REALLOC_RESOURCE_ARRAY(char, buf, buflen, buflen * 2); + buflen *= 2; + // rewind to beginning of line + fseek(fp, pos, SEEK_SET); + // retry read with new buffer + ret = fgets(buf, buflen, fp); + } + return ret; +} + +static bool file_contains_substrings_in_order(const char* filename, const char* substrs[]) { + FILE* fp = fopen(filename, "r"); + assert(fp != NULL, "error opening file %s: %s", filename, strerror(errno)); + + size_t idx = 0; + while (substrs[idx] != NULL) { + ResourceMark rm; + char* line = read_line(fp); + if (line == NULL) { + break; + } + for (char* match = strstr(line, substrs[idx]); match != NULL;) { + size_t match_len = strlen(substrs[idx]); + idx++; + if (substrs[idx] == NULL) { + break; + } + match = strstr(match + match_len, substrs[idx]); + } + } + + fclose(fp); + return substrs[idx] == NULL; +} + +static bool file_contains_substring(const char* filename, const char* substr) { + const char* strs[] = {substr, NULL}; + return file_contains_substrings_in_order(filename, strs); +} + +static size_t number_of_lines_with_substring_in_file(const char* filename, + const char* substr) { + FILE* fp = fopen(filename, "r"); + assert(fp != NULL, "error opening file %s: %s", filename, strerror(errno)); + + size_t ret = 0; + for (;;) { + ResourceMark rm; + char* line = read_line(fp); + if (line == NULL) { + break; + } + if (strstr(line, substr) != NULL) { + ret++; + } + } + + fclose(fp); + return ret; +} + +static bool file_exists(const char* filename) { + struct stat st; + return os::stat(filename, &st) == 0; +} + +static void delete_file(const char* filename) { + if (!file_exists(filename)) { + return; + } + int ret = remove(filename); + assert(ret == 0, "failed to remove file '%s': %s", filename, strerror(errno)); +} + +static void create_directory(const char* name) { + assert(!file_exists(name), "can't create directory: %s already exists", name); + bool failed; +#ifdef _WINDOWS + failed = !CreateDirectory(name, NULL); +#else + failed = mkdir(name, 0777); +#endif + assert(!failed, "failed to create directory %s", name); +} + class TestLogFile { private: char file_name[256]; @@ -139,60 +237,6 @@ void Test_configure_stdout() { assert_str_eq("all=off", stdoutput->config_string()); } -static size_t number_of_lines_with_substring_in_file(const char* filename, - const char* substr) { - ResourceMark rm; - size_t ret = 0; - FILE* fp = fopen(filename, "r"); - assert(fp != NULL, "error opening file %s: %s", filename, strerror(errno)); - - int buflen = 512; - char* buf = NEW_RESOURCE_ARRAY(char, buflen); - long pos = 0; - - while (fgets(buf, buflen, fp) != NULL) { - if (buf[strlen(buf) - 1] != '\n' && !feof(fp)) { - // retry with a larger buffer - buf = REALLOC_RESOURCE_ARRAY(char, buf, buflen, buflen * 2); - buflen *= 2; - // rewind to beginning of line - fseek(fp, pos, SEEK_SET); - continue; - } - pos = ftell(fp); - if (strstr(buf, substr) != NULL) { - ret++; - } - } - - fclose(fp); - return ret; -} - -static bool file_exists(const char* filename) { - struct stat st; - return os::stat(filename, &st) == 0; -} - -static void delete_file(const char* filename) { - if (!file_exists(filename)) { - return; - } - int ret = remove(filename); - assert(ret == 0, "failed to remove file '%s': %s", filename, strerror(errno)); -} - -static void create_directory(const char* name) { - assert(!file_exists(name), "can't create directory: %s already exists", name); - bool failed; -#ifdef _WINDOWS - failed = !CreateDirectory(name, NULL); -#else - failed = mkdir(name, 0777); -#endif - assert(!failed, "failed to create directory %s", name); -} - static const char* ExpectedLine = "a (hopefully) unique log line for testing"; static void init_file(const char* filename, const char* options = "") { @@ -264,6 +308,253 @@ void Test_log_file_startup_truncation() { delete_file(archived_filename); } +class LogMessageTest { + private: + static Log(logging) _log; + static const char* _level_filename[]; + + static void test_level_inclusion(); + static void test_long_message(); + static void test_message_with_many_lines(); + static void test_line_order(); + static void test_prefixing(); + static void test_scoped_messages(); + static void test_scoped_flushing(); + static void test_scoped_reset(); + + public: + static void test(); +}; + +const char* LogMessageTest::_level_filename[] = { + NULL, // LogLevel::Off +#define LOG_LEVEL(name, printname) "multiline-" #printname ".log", + LOG_LEVEL_LIST +#undef LOG_LEVEL +}; + +void Test_multiline_logging() { + LogMessageTest::test(); +} + +void LogMessageTest::test() { + ResourceMark rm; + + for (int i = 0; i < LogLevel::Count; i++) { + char buf[32]; + // Attempt to remove possibly pre-existing log files + remove(_level_filename[i]); + + jio_snprintf(buf, sizeof(buf), "logging=%s", LogLevel::name(static_cast(i))); + bool success = LogConfiguration::parse_log_arguments(_level_filename[i], buf, + NULL, NULL, _log.error_stream()); + assert(success, "unable to configure logging to file '%s'", _level_filename[i]); + } + + test_level_inclusion(); + test_line_order(); + test_long_message(); + test_message_with_many_lines(); + test_prefixing(); + test_scoped_messages(); + test_scoped_flushing(); + test_scoped_reset(); + + // Stop logging to the files and remove them. + for (int i = 0; i < LogLevel::Count; i++) { + LogConfiguration::parse_log_arguments(_level_filename[i], "all=off", NULL, NULL, _log.error_stream()); + remove(_level_filename[i]); + } +} + +// Verify that messages with multiple levels are written +// to outputs configured for all the corresponding levels +void LogMessageTest::test_level_inclusion() { + const size_t message_count = 10; + LogMessageBuffer msg[message_count]; + + struct { + int message_number; + LogLevelType level; + } lines[] = { + { 0, LogLevel::Error }, + { 1, LogLevel::Info }, + { 2, LogLevel::Info }, { 2, LogLevel::Debug }, + { 3, LogLevel::Info }, { 3, LogLevel::Warning }, + { 4, LogLevel::Debug }, { 4, LogLevel::Warning }, + { 5, LogLevel::Trace }, { 5, LogLevel::Debug }, + { 6, LogLevel::Warning }, { 6, LogLevel::Error }, + { 7, LogLevel::Trace }, { 7, LogLevel::Info }, { 7, LogLevel::Debug }, + { 8, LogLevel::Trace }, { 8, LogLevel::Debug }, { 8, LogLevel::Info }, + { 8, LogLevel::Warning }, { 8, LogLevel::Error}, + { 9, LogLevel::Trace } + }; + + // Fill in messages with the above lines + for (size_t i = 0; i < ARRAY_SIZE(lines); i++) { + switch (lines[i].level) { +#define LOG_LEVEL(name, printname) \ + case LogLevel::name: \ + msg[lines[i].message_number].printname("msg[%d]: " #printname, lines[i].message_number); \ + break; +LOG_LEVEL_LIST +#undef LOG_LEVEL + } + } + + for (size_t i = 0; i < message_count; i++) { + _log.write(msg[i]); + } + + // Verify that lines are written to the expected log files + for (size_t i = 0; i < ARRAY_SIZE(lines); i++) { + char expected[256]; + jio_snprintf(expected, sizeof(expected), "msg[%d]: %s", + lines[i].message_number, LogLevel::name(lines[i].level)); + for (int level = lines[i].level; level > 0; level--) { + assert(file_contains_substring(_level_filename[level], expected), + "line #" SIZE_FORMAT " missing from log file '%s'", i, _level_filename[level]); + } + for (int level = lines[i].level + 1; level < LogLevel::Count; level++) { + assert(!file_contains_substring(_level_filename[level], expected), + "line #" SIZE_FORMAT " erroneously included in log file '%s'", i, _level_filename[level]); + } + } +} + +// Verify that messages are logged in the order they are added to the log message +void LogMessageTest::test_line_order() { + LogMessageBuffer msg; + msg.info("info line").error("error line").trace("trace line") + .error("another error").warning("warning line").debug("debug line"); + _log.write(msg); + + const char* expected[] = { "info line", "error line", "trace line", + "another error", "warning line", "debug line", NULL }; + assert(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected), + "output missing or in incorrect order"); +} + +void LogMessageTest::test_long_message() { + // Write 10K bytes worth of log data + LogMessageBuffer msg; + const size_t size = 10 * K; + const char* start_marker = "#start#"; + const char* end_marker = "#the end#"; + char* data = NEW_C_HEAP_ARRAY(char, size, mtLogging); + + // fill buffer with start_marker...some data...end_marker + sprintf(data, "%s", start_marker); + for (size_t i = strlen(start_marker); i < size; i++) { + data[i] = '0' + (i % 10); + } + sprintf(data + size - strlen(end_marker) - 1, "%s", end_marker); + + msg.trace("%s", data); // Adds a newline, making the message exactly 10K in length. + _log.write(msg); + + const char* expected[] = { start_marker, "0123456789", end_marker, NULL }; + assert(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected), + "unable to print long line"); + FREE_C_HEAP_ARRAY(char, data); +} + +void LogMessageTest::test_message_with_many_lines() { + const size_t lines = 100; + const size_t line_length = 16; + + LogMessageBuffer msg; + for (size_t i = 0; i < lines; i++) { + msg.info("Line #" SIZE_FORMAT, i); + } + _log.write(msg); + + char expected_lines_data[lines][line_length]; + const char* expected_lines[lines + 1]; + for (size_t i = 0; i < lines; i++) { + jio_snprintf(&expected_lines_data[i][0], line_length, "Line #" SIZE_FORMAT, i); + expected_lines[i] = expected_lines_data[i]; + } + expected_lines[lines] = NULL; + + assert(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected_lines), + "couldn't find all lines in multiline message"); +} + +static size_t dummy_prefixer(char* buf, size_t len) { + static int i = 0; + const char* prefix = "some prefix: "; + const size_t prefix_len = strlen(prefix); + if (len < prefix_len) { + return prefix_len; + } + jio_snprintf(buf, len, "%s", prefix); + return prefix_len; +} + +void LogMessageTest::test_prefixing() { + LogMessageBuffer msg; + msg.set_prefix(dummy_prefixer); + for (int i = 0; i < 3; i++) { + msg.info("test %d", i); + } + msg.set_prefix(NULL); + msg.info("test 3"); + _log.write(msg); + + const char* expected[] = { + "] some prefix: test 0", + "] some prefix: test 1", + "] some prefix: test 2", + "] test 3", + NULL + }; + assert(file_contains_substrings_in_order(_level_filename[LogLevel::Trace], expected), "error in prefixed output"); +} + +void LogMessageTest::test_scoped_messages() { + { + LogMessage(logging) msg; + msg.info("scoped info"); + msg.warning("scoped warn"); + assert(!file_contains_substring(_level_filename[LogLevel::Info], "scoped info"), + "scoped log message written prematurely"); + } + assert(file_contains_substring(_level_filename[LogLevel::Info], "scoped info"), + "missing output from scoped log message"); + assert(file_contains_substring(_level_filename[LogLevel::Warning], "scoped warn"), + "missing output from scoped log message"); +} + +void LogMessageTest::test_scoped_flushing() { + { + LogMessage(logging) msg; + msg.info("manual flush info"); + msg.flush(); + assert(file_contains_substring(_level_filename[LogLevel::Info], "manual flush info"), + "missing output from manually flushed scoped log message"); + } + const char* tmp[] = {"manual flush info", "manual flush info", NULL}; + assert(!file_contains_substrings_in_order(_level_filename[LogLevel::Info], tmp), + "log file contains duplicate lines from single scoped log message"); +} + +void LogMessageTest::test_scoped_reset() { + { + LogMessage(logging) msg, partial; + msg.info("%s", "info reset msg"); + msg.reset(); + partial.info("%s", "info reset msg"); + partial.reset(); + partial.trace("%s", "trace reset msg"); + } + assert(!file_contains_substring(_level_filename[LogLevel::Info], "info reset msg"), + "reset message written anyway"); + assert(file_contains_substring(_level_filename[LogLevel::Trace], "trace reset msg"), + "missing message from partially reset scoped log message"); +} + + static int Test_logconfiguration_subscribe_triggered = 0; static void Test_logconfiguration_subscribe_helper() { diff --git a/hotspot/src/share/vm/logging/log.hpp b/hotspot/src/share/vm/logging/log.hpp index 64664a52366..5d36a6b4fe9 100644 --- a/hotspot/src/share/vm/logging/log.hpp +++ b/hotspot/src/share/vm/logging/log.hpp @@ -32,6 +32,8 @@ #include "runtime/os.hpp" #include "utilities/debug.hpp" +class LogMessageBuffer; + // // Logging macros // @@ -138,6 +140,10 @@ class LogImpl VALUE_OBJ_CLASS_SPEC { va_end(args); } + static void write(const LogMessageBuffer& msg) { + LogTagSetMapping::tagset().log(msg); + }; + template ATTRIBUTE_PRINTF(1, 2) static void write(const char* fmt, ...) { diff --git a/hotspot/src/share/vm/logging/logDecorations.cpp b/hotspot/src/share/vm/logging/logDecorations.cpp index 210ab31313a..79c221567a8 100644 --- a/hotspot/src/share/vm/logging/logDecorations.cpp +++ b/hotspot/src/share/vm/logging/logDecorations.cpp @@ -32,7 +32,7 @@ jlong LogDecorations::_vm_start_time_millis = 0; const char* LogDecorations::_host_name = ""; LogDecorations::LogDecorations(LogLevelType level, const LogTagSet &tagset, const LogDecorators &decorators) - : _level(level), _tagset(tagset), _millis(-1) { + : _level(level), _tagset(tagset), _millis(-1) { create_decorations(decorators); } @@ -110,8 +110,9 @@ char * LogDecorations::create_tid_decoration(char* pos) { } char* LogDecorations::create_level_decoration(char* pos) { - int written = jio_snprintf(pos, DecorationsBufferSize - (pos - _decorations_buffer), "%s", LogLevel::name(_level)); - ASSERT_AND_RETURN(written, pos) + // Avoid generating the level decoration because it may change. + // The decoration() method has a special case for level decorations. + return pos; } char* LogDecorations::create_tags_decoration(char* pos) { diff --git a/hotspot/src/share/vm/logging/logDecorations.hpp b/hotspot/src/share/vm/logging/logDecorations.hpp index fcc166147e8..3988bac83b3 100644 --- a/hotspot/src/share/vm/logging/logDecorations.hpp +++ b/hotspot/src/share/vm/logging/logDecorations.hpp @@ -53,7 +53,18 @@ class LogDecorations VALUE_OBJ_CLASS_SPEC { LogDecorations(LogLevelType level, const LogTagSet& tagset, const LogDecorators& decorators); + LogLevelType level() const { + return _level; + } + + void set_level(LogLevelType level) { + _level = level; + } + const char* decoration(LogDecorators::Decorator decorator) const { + if (decorator == LogDecorators::level_decorator) { + return LogLevel::name(_level); + } return _decoration_offset[decorator]; } }; diff --git a/hotspot/src/share/vm/logging/logDecorators.hpp b/hotspot/src/share/vm/logging/logDecorators.hpp index 1e52124060f..2d30700b614 100644 --- a/hotspot/src/share/vm/logging/logDecorators.hpp +++ b/hotspot/src/share/vm/logging/logDecorators.hpp @@ -102,6 +102,10 @@ class LogDecorators VALUE_OBJ_CLASS_SPEC { _decorators |= source._decorators; } + bool is_empty() const { + return _decorators == 0; + } + bool is_decorator(LogDecorators::Decorator decorator) const { return (_decorators & mask(decorator)) != 0; } diff --git a/hotspot/src/share/vm/logging/logFileOutput.cpp b/hotspot/src/share/vm/logging/logFileOutput.cpp index 17ced6f05d4..3000e61229f 100644 --- a/hotspot/src/share/vm/logging/logFileOutput.cpp +++ b/hotspot/src/share/vm/logging/logFileOutput.cpp @@ -278,6 +278,24 @@ int LogFileOutput::write(const LogDecorations& decorations, const char* msg) { return written; } +int LogFileOutput::write(LogMessageBuffer::Iterator msg_iterator) { + if (_stream == NULL) { + // An error has occurred with this output, avoid writing to it. + return 0; + } + + _rotation_semaphore.wait(); + int written = LogFileStreamOutput::write(msg_iterator); + _current_size += written; + + if (should_rotate()) { + rotate(); + } + _rotation_semaphore.signal(); + + return written; +} + void LogFileOutput::archive() { assert(_archive_name != NULL && _archive_name_len > 0, "Rotation must be configured before using this function."); int ret = jio_snprintf(_archive_name, _archive_name_len, "%s.%0*u", diff --git a/hotspot/src/share/vm/logging/logFileOutput.hpp b/hotspot/src/share/vm/logging/logFileOutput.hpp index adfd3722cef..1831016eb6c 100644 --- a/hotspot/src/share/vm/logging/logFileOutput.hpp +++ b/hotspot/src/share/vm/logging/logFileOutput.hpp @@ -83,6 +83,7 @@ class LogFileOutput : public LogFileStreamOutput { virtual ~LogFileOutput(); virtual bool initialize(const char* options, outputStream* errstream); virtual int write(const LogDecorations& decorations, const char* msg); + virtual int write(LogMessageBuffer::Iterator msg_iterator); virtual void force_rotate(); virtual const char* name() const { diff --git a/hotspot/src/share/vm/logging/logFileStreamOutput.cpp b/hotspot/src/share/vm/logging/logFileStreamOutput.cpp index 00dfcc5b76b..20dfd2db6db 100644 --- a/hotspot/src/share/vm/logging/logFileStreamOutput.cpp +++ b/hotspot/src/share/vm/logging/logFileStreamOutput.cpp @@ -25,14 +25,13 @@ #include "logging/logDecorators.hpp" #include "logging/logDecorations.hpp" #include "logging/logFileStreamOutput.hpp" +#include "logging/logMessageBuffer.hpp" #include "memory/allocation.inline.hpp" LogStdoutOutput LogStdoutOutput::_instance; LogStderrOutput LogStderrOutput::_instance; -int LogFileStreamOutput::write(const LogDecorations& decorations, const char* msg) { - char decoration_buf[LogDecorations::DecorationsBufferSize]; - char* position = decoration_buf; +int LogFileStreamOutput::write_decorations(const LogDecorations& decorations) { int total_written = 0; for (uint i = 0; i < LogDecorators::Count; i++) { @@ -40,23 +39,50 @@ int LogFileStreamOutput::write(const LogDecorations& decorations, const char* ms if (!_decorators.is_decorator(decorator)) { continue; } - int written = jio_snprintf(position, sizeof(decoration_buf) - total_written, "[%-*s]", - _decorator_padding[decorator], - decorations.decoration(decorator)); + + int written = jio_fprintf(_stream, "[%-*s]", + _decorator_padding[decorator], + decorations.decoration(decorator)); if (written <= 0) { return -1; } else if (static_cast(written - 2) > _decorator_padding[decorator]) { _decorator_padding[decorator] = written - 2; } - position += written; total_written += written; } + return total_written; +} - if (total_written == 0) { - total_written = jio_fprintf(_stream, "%s\n", msg); - } else { - total_written = jio_fprintf(_stream, "%s %s\n", decoration_buf, msg); +int LogFileStreamOutput::write(const LogDecorations& decorations, const char* msg) { + const bool use_decorations = !_decorators.is_empty(); + + int written = 0; + os::flockfile(_stream); + if (use_decorations) { + written += write_decorations(decorations); + written += jio_fprintf(_stream, " "); } + written += jio_fprintf(_stream, "%s\n", msg); fflush(_stream); - return total_written; + os::funlockfile(_stream); + + return written; +} + +int LogFileStreamOutput::write(LogMessageBuffer::Iterator msg_iterator) { + const bool use_decorations = !_decorators.is_empty(); + + int written = 0; + os::flockfile(_stream); + for (; !msg_iterator.is_at_end(); msg_iterator++) { + if (use_decorations) { + written += write_decorations(msg_iterator.decorations()); + written += jio_fprintf(_stream, " "); + } + written += jio_fprintf(_stream, "%s\n", msg_iterator.message()); + } + fflush(_stream); + os::funlockfile(_stream); + + return written; } diff --git a/hotspot/src/share/vm/logging/logFileStreamOutput.hpp b/hotspot/src/share/vm/logging/logFileStreamOutput.hpp index a4c739cfcfa..3a5c1b5b0fc 100644 --- a/hotspot/src/share/vm/logging/logFileStreamOutput.hpp +++ b/hotspot/src/share/vm/logging/logFileStreamOutput.hpp @@ -42,8 +42,11 @@ class LogFileStreamOutput : public LogOutput { } } + int write_decorations(const LogDecorations& decorations); + public: - virtual int write(const LogDecorations &decorations, const char* msg); + virtual int write(const LogDecorations& decorations, const char* msg); + virtual int write(LogMessageBuffer::Iterator msg_iterator); }; class LogStdoutOutput : public LogFileStreamOutput { diff --git a/hotspot/src/share/vm/logging/logMessage.hpp b/hotspot/src/share/vm/logging/logMessage.hpp new file mode 100644 index 00000000000..e8172d15062 --- /dev/null +++ b/hotspot/src/share/vm/logging/logMessage.hpp @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +#ifndef SHARE_VM_LOGGING_LOGMESSAGE_HPP +#define SHARE_VM_LOGGING_LOGMESSAGE_HPP + +#include "logging/log.hpp" +#include "logging/logMessageBuffer.hpp" +#include "logging/logPrefix.hpp" +#include "logging/logTag.hpp" + +// The LogMessage class represents a multi-part/multi-line message +// that is guaranteed to be sent and written to the log outputs +// in a way that prevents interleaving by other log messages. +// +// The interface of LogMessage is very similar to the Log class, +// with printf functions for each level (trace(), debug(), etc). +// The difference is that these functions will append/write to the +// LogMessage, which only buffers the message-parts until the whole +// message is sent to a log (using Log::write). Internal buffers +// are C heap allocated lazily on first write. LogMessages are +// automatically written when they go out of scope. +// +// Example usage: +// +// { +// LogMessage(logging) msg; +// if (msg.is_debug()) { +// msg.debug("debug message"); +// msg.trace("additional trace information"); +// } +// } +// +// Log outputs on trace level will see both of the messages above, +// and the trace line will immediately follow the debug line. +// They will have identical decorations (apart from level). +// Log outputs on debug level will see the debug message, +// but not the trace message. +// +#define LogMessage(...) LogMessageImpl +template +class LogMessageImpl : public LogMessageBuffer { + private: + LogImpl _log; + bool _has_content; + + public: + LogMessageImpl() : _has_content(false) { + } + + ~LogMessageImpl() { + if (_has_content) { + flush(); + } + } + + void flush() { + _log.write(*this); + reset(); + } + + void reset() { + _has_content = false; + LogMessageBuffer::reset(); + } + + ATTRIBUTE_PRINTF(3, 0) + void vwrite(LogLevelType level, const char* fmt, va_list args) { + if (!_has_content) { + _has_content = true; + set_prefix(LogPrefix::prefix); + } + LogMessageBuffer::vwrite(level, fmt, args); + } + +#define LOG_LEVEL(level, name) \ + bool is_##name() const { \ + return _log.is_level(LogLevel::level); \ + } + LOG_LEVEL_LIST +#undef LOG_LEVEL +}; + +#endif // SHARE_VM_LOGGING_LOGMESSAGE_HPP diff --git a/hotspot/src/share/vm/logging/logMessageBuffer.cpp b/hotspot/src/share/vm/logging/logMessageBuffer.cpp new file mode 100644 index 00000000000..f652dc5bd98 --- /dev/null +++ b/hotspot/src/share/vm/logging/logMessageBuffer.cpp @@ -0,0 +1,146 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +#include "precompiled.hpp" +#include "logging/logMessageBuffer.hpp" +#include "memory/allocation.inline.hpp" +#include "runtime/thread.inline.hpp" + +template +static void grow(T*& buffer, size_t& capacity, size_t minimum_length = 0) { + size_t new_size = capacity * 2; + if (new_size < minimum_length) { + new_size = minimum_length; + } + buffer = REALLOC_C_HEAP_ARRAY(T, buffer, new_size, mtLogging); + capacity = new_size; +} + +LogMessageBuffer::LogMessageBuffer() : _message_buffer_size(0), + _message_buffer_capacity(0), + _message_buffer(NULL), + _line_count(0), + _line_capacity(0), + _lines(NULL), + _allocated(false), + _least_detailed_level(LogLevel::Off), + _prefix_fn(NULL) { +} + +LogMessageBuffer::~LogMessageBuffer() { + if (_allocated) { + FREE_C_HEAP_ARRAY(char, _message_buffer); + FREE_C_HEAP_ARRAY(LogLine, _lines); + } +} + +void LogMessageBuffer::reset() { + _message_buffer_size = 0; + _line_count = 0; +} + +void LogMessageBuffer::initialize_buffers() { + assert(!_allocated, "buffer already initialized/allocated"); + _allocated = true; + _message_buffer = NEW_C_HEAP_ARRAY(char, InitialMessageBufferCapacity, mtLogging); + _lines = NEW_C_HEAP_ARRAY(LogLine, InitialLineCapacity, mtLogging); + _message_buffer_capacity = InitialMessageBufferCapacity; + _line_capacity = InitialLineCapacity; +} + +void LogMessageBuffer::Iterator::skip_messages_with_finer_level() { + for (; _current_line_index < _message._line_count; _current_line_index++) { + if (_message._lines[_current_line_index].level >= _level) { + break; + } + } +} + +void LogMessageBuffer::write(LogLevelType level, const char* fmt, ...) { + va_list args; + va_start(args, fmt); + vwrite(level, fmt, args); + va_end(args); +}; + +void LogMessageBuffer::vwrite(LogLevelType level, const char* fmt, va_list args) { + if (!_allocated) { + initialize_buffers(); + } + + if (level > _least_detailed_level) { + _least_detailed_level = level; + } + + size_t written; + for (int attempts = 0; attempts < 2; attempts++) { + written = 0; + size_t remaining_buffer_length = _message_buffer_capacity - _message_buffer_size; + char* current_buffer_position = _message_buffer + _message_buffer_size; + + if (_prefix_fn != NULL) { + written += _prefix_fn(current_buffer_position, remaining_buffer_length); + current_buffer_position += written; + if (remaining_buffer_length < written) { + remaining_buffer_length = 0; + } else { + remaining_buffer_length -= written; + } + } + + va_list copy; + va_copy(copy, args); + written += (size_t)os::log_vsnprintf(current_buffer_position, remaining_buffer_length, fmt, copy) + 1; + va_end(copy); + if (written > _message_buffer_capacity - _message_buffer_size) { + assert(attempts == 0, "Second attempt should always have a sufficiently large buffer (resized to fit)."); + grow(_message_buffer, _message_buffer_capacity, _message_buffer_size + written); + continue; + } + break; + } + + if (_line_count == _line_capacity) { + grow(_lines, _line_capacity); + } + + _lines[_line_count].level = level; + _lines[_line_count].message_offset = _message_buffer_size; + _message_buffer_size += written; + _line_count++; +} + +#define LOG_LEVEL(level, name) \ +LogMessageBuffer& LogMessageBuffer::v##name(const char* fmt, va_list args) { \ + vwrite(LogLevel::level, fmt, args); \ + return *this; \ +} \ +LogMessageBuffer& LogMessageBuffer::name(const char* fmt, ...) { \ + va_list args; \ + va_start(args, fmt); \ + vwrite(LogLevel::level, fmt, args); \ + va_end(args); \ + return *this; \ +} +LOG_LEVEL_LIST +#undef LOG_LEVEL diff --git a/hotspot/src/share/vm/logging/logMessageBuffer.hpp b/hotspot/src/share/vm/logging/logMessageBuffer.hpp new file mode 100644 index 00000000000..3b722d55e55 --- /dev/null +++ b/hotspot/src/share/vm/logging/logMessageBuffer.hpp @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +#ifndef SHARE_VM_LOGGING_LOGMESSAGEBUFFER_HPP +#define SHARE_VM_LOGGING_LOGMESSAGEBUFFER_HPP + +#include "logging/logDecorations.hpp" +#include "logging/logLevel.hpp" +#include "memory/allocation.hpp" + +class LogMessageBuffer : public StackObj { + friend class LogMessageTest; + protected: + struct LogLine VALUE_OBJ_CLASS_SPEC { + LogLevelType level; + size_t message_offset; + }; + static const size_t InitialLineCapacity = 10; + static const size_t InitialMessageBufferCapacity = 1024; + + size_t _message_buffer_size; + size_t _message_buffer_capacity; + char* _message_buffer; + + size_t _line_count; + size_t _line_capacity; + LogLine* _lines; + + bool _allocated; + LogLevelType _least_detailed_level; + size_t (*_prefix_fn)(char*, size_t); + + void initialize_buffers(); + + private: + // Forbid copy assignment and copy constructor. + void operator=(const LogMessageBuffer& ref) {} + LogMessageBuffer(const LogMessageBuffer& ref) {} + + public: + LogMessageBuffer(); + ~LogMessageBuffer(); + + class Iterator { + private: + const LogMessageBuffer& _message; + size_t _current_line_index; + LogLevelType _level; + LogDecorations &_decorations; + + void skip_messages_with_finer_level(); + + public: + Iterator(const LogMessageBuffer& message, LogLevelType level, LogDecorations& decorations) + : _message(message), _level(level), _decorations(decorations), _current_line_index(0) { + skip_messages_with_finer_level(); + } + + void operator++(int) { + _current_line_index++; + skip_messages_with_finer_level(); + } + + bool is_at_end() { + return _current_line_index == _message._line_count; + } + + const char* message() const { + return _message._message_buffer + _message._lines[_current_line_index].message_offset; + } + + const LogDecorations& decorations() { + _decorations.set_level(_message._lines[_current_line_index].level); + return _decorations; + } + }; + + void reset(); + + LogLevelType least_detailed_level() const { + return _least_detailed_level; + } + + Iterator iterator(LogLevelType level, LogDecorations& decorations) const { + return Iterator(*this, level, decorations); + } + + // Lines in LogMessageBuffers are not automatically prefixed based on tags + // like regular simple messages (see LogPrefix.hpp for more about prefixes). + // It is, however, possible to specify a prefix per LogMessageBuffer, + // using set_prefix(). Lines added to the LogMessageBuffer after a prefix + // function has been set will be prefixed automatically. + // Setting this to NULL will disable prefixing. + void set_prefix(size_t (*prefix_fn)(char*, size_t)) { + _prefix_fn = prefix_fn; + } + + ATTRIBUTE_PRINTF(3, 4) + void write(LogLevelType level, const char* fmt, ...); + + ATTRIBUTE_PRINTF(3, 0) + virtual void vwrite(LogLevelType level, const char* fmt, va_list args); + +#define LOG_LEVEL(level, name) \ + LogMessageBuffer& v##name(const char* fmt, va_list args) ATTRIBUTE_PRINTF(2, 0); \ + LogMessageBuffer& name(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3); + LOG_LEVEL_LIST +#undef LOG_LEVEL +}; + +#endif // SHARE_VM_LOGGING_LOGMESSAGEBUFFER_HPP diff --git a/hotspot/src/share/vm/logging/logOutput.hpp b/hotspot/src/share/vm/logging/logOutput.hpp index 5f06f388efd..cb5de53c319 100644 --- a/hotspot/src/share/vm/logging/logOutput.hpp +++ b/hotspot/src/share/vm/logging/logOutput.hpp @@ -26,10 +26,12 @@ #include "logging/logDecorators.hpp" #include "logging/logLevel.hpp" +#include "logging/logMessageBuffer.hpp" #include "memory/allocation.hpp" #include "utilities/globalDefinitions.hpp" class LogDecorations; +class LogMessageBuffer; class LogTagSet; // The base class/interface for log outputs. @@ -83,7 +85,8 @@ class LogOutput : public CHeapObj { virtual const char* name() const = 0; virtual bool initialize(const char* options, outputStream* errstream) = 0; - virtual int write(const LogDecorations &decorations, const char* msg) = 0; + virtual int write(const LogDecorations& decorations, const char* msg) = 0; + virtual int write(LogMessageBuffer::Iterator msg_iterator) = 0; }; #endif // SHARE_VM_LOGGING_LOGOUTPUT_HPP diff --git a/hotspot/src/share/vm/logging/logOutputList.hpp b/hotspot/src/share/vm/logging/logOutputList.hpp index c20edd56bf0..e983cb0d7c2 100644 --- a/hotspot/src/share/vm/logging/logOutputList.hpp +++ b/hotspot/src/share/vm/logging/logOutputList.hpp @@ -113,6 +113,10 @@ class LogOutputList VALUE_OBJ_CLASS_SPEC { bool operator!=(const LogOutputNode *ref) const { return _current != ref; } + + LogLevelType level() const { + return _current->_level; + } }; Iterator iterator(LogLevelType level = LogLevel::Last) { diff --git a/hotspot/src/share/vm/logging/logPrefix.hpp b/hotspot/src/share/vm/logging/logPrefix.hpp index 7e4da0f058e..e4a97ca1fd5 100644 --- a/hotspot/src/share/vm/logging/logPrefix.hpp +++ b/hotspot/src/share/vm/logging/logPrefix.hpp @@ -96,9 +96,14 @@ struct LogPrefix : public AllStatic { #define LOG_PREFIX(fn, ...) \ template <> struct LogPrefix<__VA_ARGS__> { \ static size_t prefix(char* buf, size_t len) { \ - DEBUG_ONLY(buf[0] = '\0';) \ size_t ret = fn(buf, len); \ - assert(ret == strlen(buf), "Length mismatch ret (" SIZE_FORMAT ") != buf length (" SIZE_FORMAT ")", ret, strlen(buf)); \ + /* Either prefix did fit (strlen(buf) == ret && ret < len) */ \ + /* or the prefix didn't fit in buffer (ret > len && strlen(buf) < len) */ \ + assert(ret == 0 || strlen(buf) < len, \ + "Buffer overrun by prefix function."); \ + assert(ret == 0 || strlen(buf) == ret || ret >= len, \ + "Prefix function should return length of prefix written," \ + " or the intended length of prefix if the buffer was too small."); \ return ret; \ } \ }; diff --git a/hotspot/src/share/vm/logging/logTagSet.cpp b/hotspot/src/share/vm/logging/logTagSet.cpp index 96aae628857..c4161abcd63 100644 --- a/hotspot/src/share/vm/logging/logTagSet.cpp +++ b/hotspot/src/share/vm/logging/logTagSet.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "logging/logDecorations.hpp" #include "logging/logLevel.hpp" +#include "logging/logMessageBuffer.hpp" #include "logging/logOutput.hpp" #include "logging/logTag.hpp" #include "logging/logTagSet.hpp" @@ -74,6 +75,13 @@ void LogTagSet::log(LogLevelType level, const char* msg) { } } +void LogTagSet::log(const LogMessageBuffer& msg) { + LogDecorations decorations(LogLevel::Invalid, *this, _decorators); + for (LogOutputList::Iterator it = _output_list.iterator(msg.least_detailed_level()); it != _output_list.end(); it++) { + (*it)->write(msg.iterator(it.level(), decorations)); + } +} + int LogTagSet::label(char* buf, size_t len, const char* separator) const { int tot_written = 0; for (size_t i = 0; i < _ntags; i++) { diff --git a/hotspot/src/share/vm/logging/logTagSet.hpp b/hotspot/src/share/vm/logging/logTagSet.hpp index 60080700d79..d95c1a3c8d0 100644 --- a/hotspot/src/share/vm/logging/logTagSet.hpp +++ b/hotspot/src/share/vm/logging/logTagSet.hpp @@ -31,6 +31,8 @@ #include "logging/logTag.hpp" #include "utilities/globalDefinitions.hpp" +class LogMessageBuffer; + // The tagset represents a combination of tags that occur in a log call somewhere. // Tagsets are created automatically by the LogTagSetMappings and should never be // instantiated directly somewhere else. @@ -110,6 +112,7 @@ class LogTagSet VALUE_OBJ_CLASS_SPEC { return _output_list.is_level(level); } void log(LogLevelType level, const char* msg); + void log(const LogMessageBuffer& msg); ATTRIBUTE_PRINTF(3, 4) void write(LogLevelType level, const char* fmt, ...); diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index 0e00e3bdb64..4abbdbb0a52 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -521,6 +521,8 @@ class os: AllStatic { static int fsync(int fd); static int available(int fd, jlong *bytes); static int get_fileno(FILE* fp); + static void flockfile(FILE* fp); + static void funlockfile(FILE* fp); static int compare_file_modified_times(const char* file1, const char* file2); diff --git a/hotspot/src/share/vm/utilities/internalVMTests.cpp b/hotspot/src/share/vm/utilities/internalVMTests.cpp index d59dc716d41..45b90094bd6 100644 --- a/hotspot/src/share/vm/utilities/internalVMTests.cpp +++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp @@ -81,6 +81,7 @@ void InternalVMTests::run() { run_unit_test(Test_log_file_startup_rotation); run_unit_test(Test_log_file_startup_truncation); run_unit_test(Test_invalid_log_file); + run_unit_test(Test_multiline_logging); run_unit_test(DirectivesParser_test); run_unit_test(Test_TempNewSymbol); #if INCLUDE_VM_STRUCTS -- GitLab From 029fbccccb813ea82837a94ea8108bd158cc427e Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 10 May 2016 16:40:04 +0200 Subject: [PATCH 322/400] 8156660: JDK-8150393 does not set _scan_in_progress properly Reviewed-by: ehelin, mgerdin --- hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp index 10c88f09a3d..2f915d1b5b6 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp @@ -273,7 +273,7 @@ void G1CMRootRegions::prepare_for_scan() { // Currently, only survivors can be root regions. _claimed_survivor_index = 0; - _scan_in_progress = true; + _scan_in_progress = _survivors->regions()->is_nonempty(); _should_abort = false; } -- GitLab From a7471fdca3fbabab67e87c0f6baf7409428ba12b Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 10 May 2016 16:40:09 +0200 Subject: [PATCH 323/400] 8155721: Sparse remset wastes half of entry memory Only allocate as much SparsePRTEntry memory as required, not for the theoretical maximum. Reviewed-by: mgerdin, sjohanss --- hotspot/src/share/vm/gc/g1/sparsePRT.cpp | 19 +++++++++++-------- hotspot/src/share/vm/gc/g1/sparsePRT.hpp | 16 ++++++++++++++-- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/sparsePRT.cpp b/hotspot/src/share/vm/gc/g1/sparsePRT.cpp index f282ae922d0..8ebbec70ccd 100644 --- a/hotspot/src/share/vm/gc/g1/sparsePRT.cpp +++ b/hotspot/src/share/vm/gc/g1/sparsePRT.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -76,13 +76,17 @@ void SparsePRTEntry::copy_cards(SparsePRTEntry* e) const { // ---------------------------------------------------------------------- +float RSHashTable::TableOccupancyFactor = 0.5f; + RSHashTable::RSHashTable(size_t capacity) : _capacity(capacity), _capacity_mask(capacity-1), _occupied_entries(0), _occupied_cards(0), - _entries((SparsePRTEntry*)NEW_C_HEAP_ARRAY(char, SparsePRTEntry::size() * capacity, mtGC)), + _entries(NULL), _buckets(NEW_C_HEAP_ARRAY(int, capacity, mtGC)), _free_list(NullEntry), _free_region(0) { + _num_entries = (capacity * TableOccupancyFactor) + 1; + _entries = (SparsePRTEntry*)NEW_C_HEAP_ARRAY(char, _num_entries * SparsePRTEntry::size(), mtGC); clear(); } @@ -107,7 +111,7 @@ void RSHashTable::clear() { "_capacity too large"); // This will put -1 == NullEntry in the key field of all entries. - memset(_entries, NullEntry, _capacity * SparsePRTEntry::size()); + memset(_entries, NullEntry, _num_entries * SparsePRTEntry::size()); memset(_buckets, NullEntry, _capacity * sizeof(int)); _free_list = NullEntry; _free_region = 0; @@ -174,7 +178,6 @@ RSHashTable::entry_for_region_ind_create(RegionIdx_t region_ind) { SparsePRTEntry* res = get_entry(region_ind); if (res == NULL) { int new_ind = alloc_entry(); - assert(0 <= new_ind && (size_t)new_ind < capacity(), "There should be room."); res = entry(new_ind); res->init(region_ind); // Insert at front. @@ -192,7 +195,7 @@ int RSHashTable::alloc_entry() { res = _free_list; _free_list = entry(res)->next_index(); return res; - } else if ((size_t) _free_region+1 < capacity()) { + } else if ((size_t)_free_region < _num_entries) { res = _free_region; _free_region++; return res; @@ -275,7 +278,7 @@ bool RSHashTable::contains_card(RegionIdx_t region_index, CardIdx_t card_index) size_t RSHashTable::mem_size() const { return sizeof(RSHashTable) + - capacity() * (SparsePRTEntry::size() + sizeof(int)); + _num_entries * (SparsePRTEntry::size() + sizeof(int)); } // ---------------------------------------------------------------------- @@ -380,7 +383,7 @@ size_t SparsePRT::mem_size() const { } bool SparsePRT::add_card(RegionIdx_t region_id, CardIdx_t card_index) { - if (_next->occupied_entries() * 2 > _next->capacity()) { + if (_next->should_expand()) { expand(); } return _next->add_card(region_id, card_index); @@ -427,7 +430,7 @@ void SparsePRT::cleanup() { void SparsePRT::expand() { RSHashTable* last = _next; _next = new RSHashTable(last->capacity() * 2); - for (size_t i = 0; i < last->capacity(); i++) { + for (size_t i = 0; i < last->num_entries(); i++) { SparsePRTEntry* e = last->entry((int)i); if (e->valid_entry()) { _next->add_entry(e); diff --git a/hotspot/src/share/vm/gc/g1/sparsePRT.hpp b/hotspot/src/share/vm/gc/g1/sparsePRT.hpp index b5ea3cde9a9..2778c3638c2 100644 --- a/hotspot/src/share/vm/gc/g1/sparsePRT.hpp +++ b/hotspot/src/share/vm/gc/g1/sparsePRT.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -109,6 +109,11 @@ class RSHashTable : public CHeapObj { NullEntry = -1 }; + // Inverse maximum hash table occupancy used. + static float TableOccupancyFactor; + + size_t _num_entries; + size_t _capacity; size_t _capacity_mask; size_t _occupied_entries; @@ -136,6 +141,8 @@ public: RSHashTable(size_t capacity); ~RSHashTable(); + bool should_expand() const { return _occupied_entries == _num_entries; } + // Attempts to ensure that the given card_index in the given region is in // the sparse table. If successful (because the card was already // present, or because it was successfully added) returns "true". @@ -161,8 +168,13 @@ public: size_t occupied_entries() const { return _occupied_entries; } size_t occupied_cards() const { return _occupied_cards; } size_t mem_size() const; + // The number of SparsePRTEntry instances available. + size_t num_entries() const { return _num_entries; } - SparsePRTEntry* entry(int i) const { return (SparsePRTEntry*)((char*)_entries + SparsePRTEntry::size() * i); } + SparsePRTEntry* entry(int i) const { + assert(i >= 0 && (size_t)i < _num_entries, "precondition"); + return (SparsePRTEntry*)((char*)_entries + SparsePRTEntry::size() * i); + } void print(); }; -- GitLab From 99c9a7f6f6bb1a21d3dd1d76974a94bb0bc4236b Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 10 May 2016 16:40:15 +0200 Subject: [PATCH 324/400] 8155810: Bound the number of root region scan threads to the number of survivor regions Reviewed-by: jmasa, sjohanss --- .../src/share/vm/gc/g1/g1ConcurrentMark.cpp | 30 ++++++++++++------- .../src/share/vm/gc/g1/g1ConcurrentMark.hpp | 3 ++ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp index 2f915d1b5b6..a409304b8cf 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp @@ -294,6 +294,10 @@ HeapRegion* G1CMRootRegions::claim_next() { return NULL; } +uint G1CMRootRegions::num_root_regions() const { + return (uint)_survivors->regions()->length(); +} + void G1CMRootRegions::notify_scan_done() { MutexLockerEx x(RootRegionScan_lock, Mutex::_no_safepoint_check_flag); _scan_in_progress = false; @@ -912,15 +916,16 @@ uint G1ConcurrentMark::calc_parallel_marking_threads() { n_conc_workers = max_parallel_marking_threads(); } else { n_conc_workers = - AdaptiveSizePolicy::calc_default_active_workers( - max_parallel_marking_threads(), - 1, /* Minimum workers */ - parallel_marking_threads(), - Threads::number_of_non_daemon_threads()); + AdaptiveSizePolicy::calc_default_active_workers(max_parallel_marking_threads(), + 1, /* Minimum workers */ + parallel_marking_threads(), + Threads::number_of_non_daemon_threads()); // Don't scale down "n_conc_workers" by scale_parallel_threads() because // that scaling has already gone into "_max_parallel_marking_threads". } - assert(n_conc_workers > 0, "Always need at least 1"); + assert(n_conc_workers > 0 && n_conc_workers <= max_parallel_marking_threads(), + "Calculated number of workers must be larger than zero and at most the maximum %u, but is %u", + max_parallel_marking_threads(), n_conc_workers); return n_conc_workers; } @@ -947,7 +952,7 @@ private: public: G1CMRootRegionScanTask(G1ConcurrentMark* cm) : - AbstractGangTask("Root Region Scan"), _cm(cm) { } + AbstractGangTask("G1 Root Region Scan"), _cm(cm) { } void work(uint worker_id) { assert(Thread::current()->is_ConcurrentGC_thread(), @@ -969,14 +974,17 @@ void G1ConcurrentMark::scan_root_regions() { if (root_regions()->scan_in_progress()) { assert(!has_aborted(), "Aborting before root region scanning is finished not supported."); - _parallel_marking_threads = calc_parallel_marking_threads(); + _parallel_marking_threads = MIN2(calc_parallel_marking_threads(), + // We distribute work on a per-region basis, so starting + // more threads than that is useless. + root_regions()->num_root_regions()); assert(parallel_marking_threads() <= max_parallel_marking_threads(), "Maximum number of marking threads exceeded"); - uint active_workers = MAX2(1U, parallel_marking_threads()); G1CMRootRegionScanTask task(this); - _parallel_workers->set_active_workers(active_workers); - _parallel_workers->run_task(&task); + log_debug(gc, ergo)("Running %s using %u workers for %u work units.", + task.name(), _parallel_marking_threads, root_regions()->num_root_regions()); + _parallel_workers->run_task(&task, _parallel_marking_threads); // It's possible that has_aborted() is true here without actually // aborting the survivor scan earlier. This is OK as it's diff --git a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp index 3cb11db1eb8..03e33461b44 100644 --- a/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp +++ b/hotspot/src/share/vm/gc/g1/g1ConcurrentMark.hpp @@ -248,6 +248,9 @@ public: // all have been claimed. HeapRegion* claim_next(); + // The number of root regions to scan. + uint num_root_regions() const; + void cancel_scan(); // Flag that we're done with root region scanning and notify anyone -- GitLab From 125e864c0dda58a5a70832efafaf1cc7a0c005f5 Mon Sep 17 00:00:00 2001 From: Thomas Schatzl Date: Tue, 10 May 2016 16:42:14 +0200 Subject: [PATCH 325/400] 8047328: Improve memory usage for cards in SparsePRTEntry Use uint16_t for cards in a SparsePRTEntry, and use an additional integer to record the current position on where to add the next card. Co-authored-by: Andreas Sjoberg Reviewed-by: mgerdin, ehelin --- .../src/share/vm/gc/g1/heapRegionRemSet.cpp | 12 +-- hotspot/src/share/vm/gc/g1/sparsePRT.cpp | 100 +++++++++--------- hotspot/src/share/vm/gc/g1/sparsePRT.hpp | 61 ++++++----- 3 files changed, 85 insertions(+), 88 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp index ef32ebc3284..ad4821ae4fd 100644 --- a/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp +++ b/hotspot/src/share/vm/gc/g1/heapRegionRemSet.cpp @@ -103,7 +103,7 @@ protected: CardIdx_t from_card = (CardIdx_t) hw_offset >> (CardTableModRefBS::card_shift - LogHeapWordSize); - assert(0 <= from_card && (size_t)from_card < HeapRegion::CardsPerRegion, + assert((size_t)from_card < HeapRegion::CardsPerRegion, "Must be in range."); add_card_work(from_card, par); } @@ -386,7 +386,7 @@ void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, uint tid) { uintptr_t(from_hr->bottom()) >> CardTableModRefBS::card_shift; CardIdx_t card_index = from_card - from_hr_bot_card_index; - assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion, + assert((size_t)card_index < HeapRegion::CardsPerRegion, "Must be in range."); if (G1HRRSUseSparseTable && _sparse_table.add_card(from_hrm_ind, card_index)) { @@ -421,11 +421,9 @@ void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, uint tid) { // Transfer from sparse to fine-grain. SparsePRTEntry *sprt_entry = _sparse_table.get_entry(from_hrm_ind); assert(sprt_entry != NULL, "There should have been an entry"); - for (int i = 0; i < SparsePRTEntry::cards_num(); i++) { + for (int i = 0; i < sprt_entry->num_valid_cards(); i++) { CardIdx_t c = sprt_entry->card(i); - if (c != SparsePRTEntry::NullEntry) { - prt->add_card(c); - } + prt->add_card(c); } // Now we can delete the sparse entry. bool res = _sparse_table.delete_entry(from_hrm_ind); @@ -680,7 +678,7 @@ bool OtherRegionsTable::contains_reference_locked(OopOrNarrowOopStar from) const uintptr_t(hr->bottom()) >> CardTableModRefBS::card_shift; assert(from_card >= hr_bot_card_index, "Inv"); CardIdx_t card_index = from_card - hr_bot_card_index; - assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion, + assert((size_t)card_index < HeapRegion::CardsPerRegion, "Must be in range."); return _sparse_table.contains_card(hr_ind, card_index); } diff --git a/hotspot/src/share/vm/gc/g1/sparsePRT.cpp b/hotspot/src/share/vm/gc/g1/sparsePRT.cpp index 8ebbec70ccd..cab39b36e91 100644 --- a/hotspot/src/share/vm/gc/g1/sparsePRT.cpp +++ b/hotspot/src/share/vm/gc/g1/sparsePRT.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc/g1/heapRegion.hpp" +#include "gc/g1/heapRegionBounds.inline.hpp" #include "gc/g1/heapRegionRemSet.hpp" #include "gc/g1/sparsePRT.hpp" #include "gc/shared/cardTableModRefBS.hpp" @@ -32,46 +33,54 @@ #include "runtime/atomic.inline.hpp" #include "runtime/mutexLocker.hpp" +// Check that the size of the SparsePRTEntry is evenly divisible by the maximum +// member type to avoid SIGBUS when accessing them. +STATIC_ASSERT(sizeof(SparsePRTEntry) % sizeof(int) == 0); + void SparsePRTEntry::init(RegionIdx_t region_ind) { + // Check that the card array element type can represent all cards in the region. + // Choose a large SparsePRTEntry::card_elem_t (e.g. CardIdx_t) if required. + assert(((size_t)1 << (sizeof(SparsePRTEntry::card_elem_t) * BitsPerByte)) * + G1SATBCardTableModRefBS::card_size >= HeapRegionBounds::max_size(), "precondition"); + assert(G1RSetSparseRegionEntries > 0, "precondition"); _region_ind = region_ind; - _next_index = NullEntry; - - for (int i = 0; i < cards_num(); i++) { - _cards[i] = NullEntry; - } + _next_index = RSHashTable::NullEntry; + _next_null = 0; } bool SparsePRTEntry::contains_card(CardIdx_t card_index) const { - for (int i = 0; i < cards_num(); i++) { - if (_cards[i] == card_index) return true; + for (int i = 0; i < num_valid_cards(); i++) { + if (card(i) == card_index) { + return true; + } } return false; } -int SparsePRTEntry::num_valid_cards() const { - int sum = 0; - for (int i = 0; i < cards_num(); i++) { - sum += (_cards[i] != NullEntry); - } - return sum; -} - SparsePRTEntry::AddCardResult SparsePRTEntry::add_card(CardIdx_t card_index) { - for (int i = 0; i < cards_num(); i++) { - CardIdx_t c = _cards[i]; - if (c == card_index) return found; - if (c == NullEntry) { _cards[i] = card_index; return added; } + for (int i = 0; i < num_valid_cards(); i++) { + if (card(i) == card_index) { + return found; + } } + if (num_valid_cards() < cards_num() - 1) { + _cards[_next_null] = (card_elem_t)card_index; + _next_null++; + return added; + } // Otherwise, we're full. return overflow; } -void SparsePRTEntry::copy_cards(CardIdx_t* cards) const { - memcpy(cards, _cards, cards_num() * sizeof(CardIdx_t)); +void SparsePRTEntry::copy_cards(card_elem_t* cards) const { + memcpy(cards, _cards, cards_num() * sizeof(card_elem_t)); } void SparsePRTEntry::copy_cards(SparsePRTEntry* e) const { - copy_cards(&e->_cards[0]); + copy_cards(e->_cards); + assert(_next_null >= 0, "invariant"); + assert(_next_null <= cards_num(), "invariant"); + e->_next_null = _next_null; } // ---------------------------------------------------------------------- @@ -127,16 +136,6 @@ bool RSHashTable::add_card(RegionIdx_t region_ind, CardIdx_t card_index) { return res != SparsePRTEntry::overflow; } -bool RSHashTable::get_cards(RegionIdx_t region_ind, CardIdx_t* cards) { - SparsePRTEntry* entry = get_entry(region_ind); - if (entry == NULL) { - return false; - } - // Otherwise... - entry->copy_cards(cards); - return true; -} - SparsePRTEntry* RSHashTable::get_entry(RegionIdx_t region_ind) const { int ind = (int) (region_ind & capacity_mask()); int cur_ind = _buckets[ind]; @@ -218,17 +217,16 @@ void RSHashTable::add_entry(SparsePRTEntry* e) { } CardIdx_t RSHashTableIter::find_first_card_in_list() { - CardIdx_t res; while (_bl_ind != RSHashTable::NullEntry) { - res = _rsht->entry(_bl_ind)->card(0); - if (res != SparsePRTEntry::NullEntry) { - return res; + SparsePRTEntry* sparse_entry = _rsht->entry(_bl_ind); + if (sparse_entry->num_valid_cards() > 0) { + return sparse_entry->card(0); } else { - _bl_ind = _rsht->entry(_bl_ind)->next_index(); + _bl_ind = sparse_entry->next_index(); } } // Otherwise, none found: - return SparsePRTEntry::NullEntry; + return NoCardFound; } size_t RSHashTableIter::compute_card_ind(CardIdx_t ci) { @@ -237,20 +235,22 @@ size_t RSHashTableIter::compute_card_ind(CardIdx_t ci) { bool RSHashTableIter::has_next(size_t& card_index) { _card_ind++; - CardIdx_t ci; - if (_card_ind < SparsePRTEntry::cards_num() && - ((ci = _rsht->entry(_bl_ind)->card(_card_ind)) != - SparsePRTEntry::NullEntry)) { - card_index = compute_card_ind(ci); - return true; + if (_bl_ind >= 0) { + SparsePRTEntry* e = _rsht->entry(_bl_ind); + if (_card_ind < e->num_valid_cards()) { + CardIdx_t ci = e->card(_card_ind); + card_index = compute_card_ind(ci); + return true; + } } + // Otherwise, must find the next valid entry. _card_ind = 0; if (_bl_ind != RSHashTable::NullEntry) { _bl_ind = _rsht->entry(_bl_ind)->next_index(); - ci = find_first_card_in_list(); - if (ci != SparsePRTEntry::NullEntry) { + CardIdx_t ci = find_first_card_in_list(); + if (ci != NoCardFound) { card_index = compute_card_ind(ci); return true; } @@ -259,8 +259,8 @@ bool RSHashTableIter::has_next(size_t& card_index) { _tbl_ind++; while ((size_t)_tbl_ind < _rsht->capacity()) { _bl_ind = _rsht->_buckets[_tbl_ind]; - ci = find_first_card_in_list(); - if (ci != SparsePRTEntry::NullEntry) { + CardIdx_t ci = find_first_card_in_list(); + if (ci != NoCardFound) { card_index = compute_card_ind(ci); return true; } @@ -389,10 +389,6 @@ bool SparsePRT::add_card(RegionIdx_t region_id, CardIdx_t card_index) { return _next->add_card(region_id, card_index); } -bool SparsePRT::get_cards(RegionIdx_t region_id, CardIdx_t* cards) { - return _next->get_cards(region_id, cards); -} - SparsePRTEntry* SparsePRT::get_entry(RegionIdx_t region_id) { return _next->get_entry(region_id); } diff --git a/hotspot/src/share/vm/gc/g1/sparsePRT.hpp b/hotspot/src/share/vm/gc/g1/sparsePRT.hpp index 2778c3638c2..5ea825ced8c 100644 --- a/hotspot/src/share/vm/gc/g1/sparsePRT.hpp +++ b/hotspot/src/share/vm/gc/g1/sparsePRT.hpp @@ -43,26 +43,32 @@ // old versions synchronously. class SparsePRTEntry: public CHeapObj { -public: - enum SomePublicConstants { - NullEntry = -1, - UnrollFactor = 4 - }; private: + // The type of a card entry. + typedef uint16_t card_elem_t; + + // We need to make sizeof(SparsePRTEntry) an even multiple of maximum member size, + // in order to force correct alignment that could otherwise cause SIGBUS errors + // when reading the member variables. This calculates the minimum number of card + // array elements required to get that alignment. + static const size_t card_array_alignment = sizeof(int) / sizeof(card_elem_t); + RegionIdx_t _region_ind; int _next_index; - CardIdx_t _cards[1]; + int _next_null; + // The actual cards stored in this array. // WARNING: Don't put any data members beyond this line. Card array has, in fact, variable length. // It should always be the last data member. + card_elem_t _cards[card_array_alignment]; + + // Copy the current entry's cards into "cards". + inline void copy_cards(card_elem_t* cards) const; public: // Returns the size of the entry, used for entry allocation. - static size_t size() { return sizeof(SparsePRTEntry) + sizeof(CardIdx_t) * (cards_num() - 1); } + static size_t size() { return sizeof(SparsePRTEntry) + sizeof(card_elem_t) * (cards_num() - card_array_alignment); } // Returns the size of the card array. static int cards_num() { - // The number of cards should be a multiple of 4, because that's our current - // unrolling factor. - static const int s = MAX2(G1RSetSparseRegionEntries & ~(UnrollFactor - 1), UnrollFactor); - return s; + return align_size_up(G1RSetSparseRegionEntries, card_array_alignment); } // Set the region_ind to the given value, and delete all cards. @@ -80,7 +86,7 @@ public: inline bool contains_card(CardIdx_t card_index) const; // Returns the number of non-NULL card entries. - inline int num_valid_cards() const; + inline int num_valid_cards() const { return _next_null; } // Requires that the entry not contain the given card index. If there is // space available, add the given card index to the entry and return @@ -92,22 +98,20 @@ public: }; inline AddCardResult add_card(CardIdx_t card_index); - // Copy the current entry's cards into "cards". - inline void copy_cards(CardIdx_t* cards) const; // Copy the current entry's cards into the "_card" array of "e." inline void copy_cards(SparsePRTEntry* e) const; - inline CardIdx_t card(int i) const { return _cards[i]; } + inline CardIdx_t card(int i) const { + assert(i >= 0, "must be nonnegative"); + assert(i < cards_num(), "range checking"); + return (CardIdx_t)_cards[i]; + } }; - class RSHashTable : public CHeapObj { friend class RSHashTableIter; - enum SomePrivateConstants { - NullEntry = -1 - }; // Inverse maximum hash table occupancy used. static float TableOccupancyFactor; @@ -141,6 +145,8 @@ public: RSHashTable(size_t capacity); ~RSHashTable(); + static const int NullEntry = -1; + bool should_expand() const { return _occupied_entries == _num_entries; } // Attempts to ensure that the given card_index in the given region is in @@ -163,10 +169,10 @@ public: void clear(); - size_t capacity() const { return _capacity; } + size_t capacity() const { return _capacity; } size_t capacity_mask() const { return _capacity_mask; } size_t occupied_entries() const { return _occupied_entries; } - size_t occupied_cards() const { return _occupied_cards; } + size_t occupied_cards() const { return _occupied_cards; } size_t mem_size() const; // The number of SparsePRTEntry instances available. size_t num_entries() const { return _num_entries; } @@ -181,14 +187,17 @@ public: // ValueObj because will be embedded in HRRS iterator. class RSHashTableIter VALUE_OBJ_CLASS_SPEC { + // Return value indicating "invalid/no card". + static const int NoCardFound = -1; + int _tbl_ind; // [-1, 0.._rsht->_capacity) int _bl_ind; // [-1, 0.._rsht->_capacity) short _card_ind; // [0..SparsePRTEntry::cards_num()) RSHashTable* _rsht; // If the bucket list pointed to by _bl_ind contains a card, sets - // _bl_ind to the index of that entry, and returns the card. - // Otherwise, returns SparseEntry::NullEntry. + // _bl_ind to the index of that entry, + // Returns the card found if there is, otherwise returns InvalidCard. CardIdx_t find_first_card_in_list(); // Computes the proper card index for the card whose offset in the @@ -259,12 +268,6 @@ public: // entries to a larger-capacity representation. bool add_card(RegionIdx_t region_id, CardIdx_t card_index); - // If the table hold an entry for "region_ind", Copies its - // cards into "cards", which must be an array of length at least - // "SparePRTEntry::cards_num()", and returns "true"; otherwise, - // returns "false". - bool get_cards(RegionIdx_t region_ind, CardIdx_t* cards); - // Return the pointer to the entry associated with the given region. SparsePRTEntry* get_entry(RegionIdx_t region_ind); -- GitLab From a991801b42c2bec8106ee706e49f53f5ce7b9397 Mon Sep 17 00:00:00 2001 From: Gerard Ziemski Date: Tue, 10 May 2016 12:10:21 -0500 Subject: [PATCH 326/400] 8073500: Prevent certain commercial flags from being changed at runtime Implement new writeable mechanism for flag control Reviewed-by: coleenp, iklam --- .../src/cpu/aarch64/vm/globals_aarch64.hpp | 18 +- hotspot/src/cpu/ppc/vm/globals_ppc.hpp | 9 +- hotspot/src/cpu/sparc/vm/globals_sparc.hpp | 9 +- hotspot/src/cpu/x86/vm/globals_x86.hpp | 9 +- hotspot/src/cpu/zero/vm/globals_zero.hpp | 9 +- hotspot/src/os/aix/vm/globals_aix.hpp | 12 +- hotspot/src/os/bsd/vm/globals_bsd.hpp | 12 +- hotspot/src/os/linux/vm/globals_linux.hpp | 10 +- hotspot/src/os/solaris/vm/globals_solaris.hpp | 12 +- hotspot/src/os/windows/vm/globals_windows.hpp | 10 +- hotspot/src/share/vm/c1/c1_globals.cpp | 12 +- hotspot/src/share/vm/c1/c1_globals.hpp | 15 +- hotspot/src/share/vm/gc/g1/g1_globals.cpp | 5 +- hotspot/src/share/vm/gc/g1/g1_globals.hpp | 16 +- hotspot/src/share/vm/jvmci/jvmci_globals.cpp | 23 +- hotspot/src/share/vm/jvmci/jvmci_globals.hpp | 16 +- hotspot/src/share/vm/opto/c2_globals.cpp | 5 +- hotspot/src/share/vm/opto/c2_globals.hpp | 16 +- hotspot/src/share/vm/runtime/arguments.cpp | 4 +- .../runtime/commandLineFlagConstraintList.cpp | 17 +- .../vm/runtime/commandLineFlagRangeList.cpp | 18 +- .../vm/runtime/commandLineFlagRangeList.hpp | 1 - .../runtime/commandLineFlagWriteableList.cpp | 220 ++++++++++++++++++ .../runtime/commandLineFlagWriteableList.hpp | 68 ++++++ hotspot/src/share/vm/runtime/globals.cpp | 185 ++++++++++----- hotspot/src/share/vm/runtime/globals.hpp | 62 +++-- .../share/vm/runtime/globals_extension.hpp | 42 ++-- hotspot/src/share/vm/runtime/os_ext.hpp | 1 + hotspot/src/share/vm/runtime/thread.cpp | 3 + 29 files changed, 699 insertions(+), 140 deletions(-) create mode 100644 hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp create mode 100644 hotspot/src/share/vm/runtime/commandLineFlagWriteableList.hpp diff --git a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp index ec3b7953c41..604b8cd34fb 100644 --- a/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp +++ b/hotspot/src/cpu/aarch64/vm/globals_aarch64.hpp @@ -85,7 +85,14 @@ define_pd_global(intx, InlineSmallCode, 1000); #ifdef BUILTIN_SIM #define UseBuiltinSim true -#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint) \ +#define ARCH_FLAGS(develop, \ + product, \ + diagnostic, \ + experimental, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ product(bool, NotifySimulator, UseBuiltinSim, \ "tell the AArch64 sim where we are in method code") \ @@ -117,7 +124,14 @@ define_pd_global(intx, InlineSmallCode, 1000); #define NotifySimulator false #define UseSimulatorCache false #define DisableBCCheck true -#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint) \ +#define ARCH_FLAGS(develop, \ + product, \ + diagnostic, \ + experimental, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ product(bool, NearCpool, true, \ "constant pool is close to instructions") \ diff --git a/hotspot/src/cpu/ppc/vm/globals_ppc.hpp b/hotspot/src/cpu/ppc/vm/globals_ppc.hpp index 77f7a491b02..b69e4058507 100644 --- a/hotspot/src/cpu/ppc/vm/globals_ppc.hpp +++ b/hotspot/src/cpu/ppc/vm/globals_ppc.hpp @@ -79,7 +79,14 @@ define_pd_global(bool, CompactStrings, true); define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong); // Platform dependent flag handling: flags only defined on this platform. -#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint) \ +#define ARCH_FLAGS(develop, \ + product, \ + diagnostic, \ + experimental, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ /* Load poll address from thread. This is used to implement per-thread */ \ /* safepoints on platforms != IA64. */ \ diff --git a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp index 66889ae73b3..1e1ef759b45 100644 --- a/hotspot/src/cpu/sparc/vm/globals_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/globals_sparc.hpp @@ -92,7 +92,14 @@ define_pd_global(bool, CompactStrings, true); define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong); -#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint) \ +#define ARCH_FLAGS(develop, \ + product, \ + diagnostic, \ + experimental, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ product(intx, UseVIS, 99, \ "Highest supported VIS instructions set on Sparc") \ diff --git a/hotspot/src/cpu/x86/vm/globals_x86.hpp b/hotspot/src/cpu/x86/vm/globals_x86.hpp index 407a8af217a..93aea2a18d7 100644 --- a/hotspot/src/cpu/x86/vm/globals_x86.hpp +++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp @@ -99,7 +99,14 @@ define_pd_global(bool, PreserveFramePointer, false); define_pd_global(intx, InitArrayShortSize, 8*BytesPerLong); -#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint) \ +#define ARCH_FLAGS(develop, \ + product, \ + diagnostic, \ + experimental, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ develop(bool, IEEEPrecision, true, \ "Enables IEEE precision (for INTEL only)") \ diff --git a/hotspot/src/cpu/zero/vm/globals_zero.hpp b/hotspot/src/cpu/zero/vm/globals_zero.hpp index eb09f466c62..7ce33a94447 100644 --- a/hotspot/src/cpu/zero/vm/globals_zero.hpp +++ b/hotspot/src/cpu/zero/vm/globals_zero.hpp @@ -80,7 +80,14 @@ define_pd_global(bool, PreserveFramePointer, false); // No performance work done here yet. define_pd_global(bool, CompactStrings, false); -#define ARCH_FLAGS(develop, product, diagnostic, experimental, notproduct, range, constraint) \ +#define ARCH_FLAGS(develop, \ + product, \ + diagnostic, \ + experimental, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ product(bool, UseFastEmptyMethods, true, \ "Use fast method entry code for empty methods") \ diff --git a/hotspot/src/os/aix/vm/globals_aix.hpp b/hotspot/src/os/aix/vm/globals_aix.hpp index bfd244eb6fc..21f250bd161 100644 --- a/hotspot/src/os/aix/vm/globals_aix.hpp +++ b/hotspot/src/os/aix/vm/globals_aix.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2015 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -30,7 +30,15 @@ // Defines Aix specific flags. They are not available on other platforms. // // (Please keep the switches sorted alphabetically.) -#define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct, range, constraint) \ +#define RUNTIME_OS_FLAGS(develop, \ + develop_pd, \ + product, \ + product_pd, \ + diagnostic, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ /* Whether to allow the VM to run if EXTSHM=ON. EXTSHM is an environment */ \ /* variable used on AIX to activate certain hacks which allow more shm segments */\ diff --git a/hotspot/src/os/bsd/vm/globals_bsd.hpp b/hotspot/src/os/bsd/vm/globals_bsd.hpp index a085cbe5114..f3b076e825e 100644 --- a/hotspot/src/os/bsd/vm/globals_bsd.hpp +++ b/hotspot/src/os/bsd/vm/globals_bsd.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,15 @@ // // Defines Bsd specific flags. They are not available on other platforms. // -#define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct, range, constraint) \ +#define RUNTIME_OS_FLAGS(develop, \ + develop_pd, \ + product, \ + product_pd, \ + diagnostic, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ product(bool, UseOprofile, false, \ "enable support for Oprofile profiler") \ diff --git a/hotspot/src/os/linux/vm/globals_linux.hpp b/hotspot/src/os/linux/vm/globals_linux.hpp index 05f4c181336..39bedf3ff59 100644 --- a/hotspot/src/os/linux/vm/globals_linux.hpp +++ b/hotspot/src/os/linux/vm/globals_linux.hpp @@ -28,7 +28,15 @@ // // Defines Linux specific flags. They are not available on other platforms. // -#define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct, range, constraint) \ +#define RUNTIME_OS_FLAGS(develop, \ + develop_pd, \ + product, \ + product_pd, \ + diagnostic, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ product(bool, UseOprofile, false, \ "enable support for Oprofile profiler") \ diff --git a/hotspot/src/os/solaris/vm/globals_solaris.hpp b/hotspot/src/os/solaris/vm/globals_solaris.hpp index 4e6d8182533..b3e2e34a314 100644 --- a/hotspot/src/os/solaris/vm/globals_solaris.hpp +++ b/hotspot/src/os/solaris/vm/globals_solaris.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,15 @@ // // Defines Solaris specific flags. They are not available on other platforms. // -#define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct, range, constraint) \ +#define RUNTIME_OS_FLAGS(develop, \ + develop_pd, \ + product, \ + product_pd, \ + diagnostic, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ product(bool, UseExtendedFileIO, true, \ "Enable workaround for limitations of stdio FILE structure") diff --git a/hotspot/src/os/windows/vm/globals_windows.hpp b/hotspot/src/os/windows/vm/globals_windows.hpp index 1a2eb4fdd4a..3d831ec1257 100644 --- a/hotspot/src/os/windows/vm/globals_windows.hpp +++ b/hotspot/src/os/windows/vm/globals_windows.hpp @@ -28,7 +28,15 @@ // // Defines Windows specific flags. They are not available on other platforms. // -#define RUNTIME_OS_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct, range, constraint) \ +#define RUNTIME_OS_FLAGS(develop, \ + develop_pd, \ + product, \ + product_pd, \ + diagnostic, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ product(bool, UseUTCFileTimestamp, true, \ "Adjust the timestamp returned from stat() to be UTC") diff --git a/hotspot/src/share/vm/c1/c1_globals.cpp b/hotspot/src/share/vm/c1/c1_globals.cpp index 18e324f5f8b..58bd059520f 100644 --- a/hotspot/src/share/vm/c1/c1_globals.cpp +++ b/hotspot/src/share/vm/c1/c1_globals.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,4 +25,12 @@ #include "precompiled.hpp" #include "c1/c1_globals.hpp" -C1_FLAGS(MATERIALIZE_DEVELOPER_FLAG, MATERIALIZE_PD_DEVELOPER_FLAG, MATERIALIZE_PRODUCT_FLAG, MATERIALIZE_PD_PRODUCT_FLAG, MATERIALIZE_DIAGNOSTIC_FLAG, MATERIALIZE_NOTPRODUCT_FLAG, IGNORE_RANGE, IGNORE_CONSTRAINT) +C1_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ + MATERIALIZE_PD_DEVELOPER_FLAG, \ + MATERIALIZE_PRODUCT_FLAG, \ + MATERIALIZE_PD_PRODUCT_FLAG, \ + MATERIALIZE_DIAGNOSTIC_FLAG, \ + MATERIALIZE_NOTPRODUCT_FLAG, \ + IGNORE_RANGE, \ + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) diff --git a/hotspot/src/share/vm/c1/c1_globals.hpp b/hotspot/src/share/vm/c1/c1_globals.hpp index ad6548e4928..13ac975ecd6 100644 --- a/hotspot/src/share/vm/c1/c1_globals.hpp +++ b/hotspot/src/share/vm/c1/c1_globals.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,15 @@ // // Defines all global flags used by the client compiler. // -#define C1_FLAGS(develop, develop_pd, product, product_pd, diagnostic, notproduct, range, constraint) \ +#define C1_FLAGS(develop, \ + develop_pd, \ + product, \ + product_pd, \ + diagnostic, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ /* Printing */ \ notproduct(bool, PrintC1Statistics, false, \ @@ -350,6 +358,7 @@ C1_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #endif // SHARE_VM_C1_C1_GLOBALS_HPP diff --git a/hotspot/src/share/vm/gc/g1/g1_globals.cpp b/hotspot/src/share/vm/gc/g1/g1_globals.cpp index c1bf99eca40..0b25b03f2b2 100644 --- a/hotspot/src/share/vm/gc/g1/g1_globals.cpp +++ b/hotspot/src/share/vm/gc/g1/g1_globals.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,4 +35,5 @@ G1_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_MANAGEABLE_FLAG, \ MATERIALIZE_PRODUCT_RW_FLAG, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) diff --git a/hotspot/src/share/vm/gc/g1/g1_globals.hpp b/hotspot/src/share/vm/gc/g1/g1_globals.hpp index e44411190f7..3abcba4df9e 100644 --- a/hotspot/src/share/vm/gc/g1/g1_globals.hpp +++ b/hotspot/src/share/vm/gc/g1/g1_globals.hpp @@ -31,7 +31,18 @@ // Defines all globals flags used by the garbage-first compiler. // -#define G1_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, manageable, product_rw, range, constraint) \ +#define G1_FLAGS(develop, \ + develop_pd, \ + product, \ + product_pd, \ + diagnostic, \ + experimental, \ + notproduct, \ + manageable, \ + product_rw, \ + range, \ + constraint, \ + writeable) \ \ product(bool, G1UseAdaptiveIHOP, true, \ "Adaptively adjust the initiating heap occupancy from the " \ @@ -317,6 +328,7 @@ G1_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_MANAGEABLE_FLAG, \ DECLARE_PRODUCT_RW_FLAG, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #endif // SHARE_VM_GC_G1_G1_GLOBALS_HPP diff --git a/hotspot/src/share/vm/jvmci/jvmci_globals.cpp b/hotspot/src/share/vm/jvmci/jvmci_globals.cpp index 992746975f4..2b2155a969a 100644 --- a/hotspot/src/share/vm/jvmci/jvmci_globals.cpp +++ b/hotspot/src/share/vm/jvmci/jvmci_globals.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,8 @@ JVMCI_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_EXPERIMENTAL_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #define JVMCI_IGNORE_FLAG_FOUR_PARAM(type, name, value, doc) #define JVMCI_IGNORE_FLAG_THREE_PARAM(type, name, doc) @@ -91,7 +92,8 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() { JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) } // Check consistency of experimental flags if UnlockExperimentalVMOptions is @@ -105,7 +107,8 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() { JVMCI_EXPERIMENTAL_FLAG_VALUE_CHANGED_CHECK_CODE, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) } #ifndef PRODUCT @@ -129,7 +132,8 @@ bool JVMCIGlobals::check_jvmci_flags_are_consistent() { JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_NOTPRODUCT_FLAG_VALUE_CHANGED_CHECK_CODE, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #undef EMIT_FLAG_VALUE_CHANGED_CHECK_CODE #undef JVMCI_DEVELOP_FLAG_VALUE_CHANGED_CHECK_CODE @@ -167,7 +171,8 @@ void JVMCIGlobals::print_jvmci_args_inconsistency_error_message() { JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) } if (UnlockExperimentalVMOptions || !FLAG_IS_DEFAULT(UnlockExperimentalVMOptions)) { @@ -179,7 +184,8 @@ void JVMCIGlobals::print_jvmci_args_inconsistency_error_message() { JVMCI_EXPERIMENTAL_FLAG_CHECK_PRINT_ERR_MSG_CODE, \ JVMCI_IGNORE_FLAG_FOUR_PARAM, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) } #ifndef PRODUCT @@ -203,7 +209,8 @@ void JVMCIGlobals::print_jvmci_args_inconsistency_error_message() { JVMCI_IGNORE_FLAG_FOUR_PARAM, \ JVMCI_NOTPRODUCT_FLAG_CHECK_PRINT_ERR_MSG_CODE, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #undef EMIT_CHECK_PRINT_ERR_MSG_CODE #undef JVMCI_DEVELOP_FLAG_CHECK_PRINT_ERR_MSG_CODE diff --git a/hotspot/src/share/vm/jvmci/jvmci_globals.hpp b/hotspot/src/share/vm/jvmci/jvmci_globals.hpp index 03285e3bdfc..d42e09cc0b1 100644 --- a/hotspot/src/share/vm/jvmci/jvmci_globals.hpp +++ b/hotspot/src/share/vm/jvmci/jvmci_globals.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,7 +32,16 @@ // to be accessible to the JVMCI C++ code should be defined here. All other // JVMCI flags should be defined in JVMCIOptions.java. // -#define JVMCI_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, range, constraint) \ +#define JVMCI_FLAGS(develop, \ + develop_pd, \ + product, \ + product_pd, \ + diagnostic, \ + experimental, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ experimental(bool, EnableJVMCI, false, \ "Enable JVMCI") \ @@ -96,7 +105,8 @@ JVMCI_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_EXPERIMENTAL_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) class JVMCIGlobals { public: diff --git a/hotspot/src/share/vm/opto/c2_globals.cpp b/hotspot/src/share/vm/opto/c2_globals.cpp index 16cdfa711d0..d0a1bae95aa 100644 --- a/hotspot/src/share/vm/opto/c2_globals.cpp +++ b/hotspot/src/share/vm/opto/c2_globals.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,4 +33,5 @@ C2_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_EXPERIMENTAL_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) diff --git a/hotspot/src/share/vm/opto/c2_globals.hpp b/hotspot/src/share/vm/opto/c2_globals.hpp index 802b0961e1a..793f87aa98d 100644 --- a/hotspot/src/share/vm/opto/c2_globals.hpp +++ b/hotspot/src/share/vm/opto/c2_globals.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,16 @@ // Defines all globals flags used by the server compiler. // -#define C2_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, range, constraint) \ +#define C2_FLAGS(develop, \ + develop_pd, \ + product, \ + product_pd, \ + diagnostic, \ + experimental, \ + notproduct, \ + range, \ + constraint, \ + writeable) \ \ develop(bool, StressLCM, false, \ "Randomize instruction scheduling in LCM") \ @@ -758,6 +767,7 @@ C2_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_EXPERIMENTAL_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #endif // SHARE_VM_OPTO_C2_GLOBALS_HPP diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 630f7a71794..9395a5ccc49 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -42,6 +42,7 @@ #include "runtime/arguments.hpp" #include "runtime/arguments_ext.hpp" #include "runtime/commandLineFlagConstraintList.hpp" +#include "runtime/commandLineFlagWriteableList.hpp" #include "runtime/commandLineFlagRangeList.hpp" #include "runtime/globals.hpp" #include "runtime/globals_extension.hpp" @@ -4081,9 +4082,10 @@ bool Arguments::handle_deprecated_print_gc_flags() { jint Arguments::parse(const JavaVMInitArgs* initial_cmd_args) { assert(verify_special_jvm_flags(), "deprecated and obsolete flag table inconsistent"); - // Initialize ranges and constraints + // Initialize ranges, constraints and writeables CommandLineFlagRangeList::init(); CommandLineFlagConstraintList::init(); + CommandLineFlagWriteableList::init(); // If flag "-XX:Flags=flags-file" is used it will be the first option to be processed. const char* hotspotrc = ".hotspotrc"; diff --git a/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp b/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp index c79a48c9700..27d7a3291ba 100644 --- a/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp +++ b/hotspot/src/share/vm/runtime/commandLineFlagConstraintList.cpp @@ -217,7 +217,7 @@ void emit_constraint_double(const char* name, CommandLineFlagConstraintFunc_doub #define EMIT_CONSTRAINT_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_constraint_##type(#name // Generate func argument to pass into emit_constraint_xxx functions -#define EMIT_CONSTRAINT_CHECK(func, type) , func, CommandLineFlagConstraint::type +#define EMIT_CONSTRAINT_CHECK(func, type) , func, CommandLineFlagConstraint::type // the "name" argument must be a string literal #define INITIAL_CONSTRAINTS_SIZE 72 @@ -239,7 +239,8 @@ void CommandLineFlagConstraintList::init(void) { EMIT_CONSTRAINT_PRODUCT_RW_FLAG, EMIT_CONSTRAINT_LP64_PRODUCT_FLAG, IGNORE_RANGE, - EMIT_CONSTRAINT_CHECK)); + EMIT_CONSTRAINT_CHECK, + IGNORE_WRITEABLE)); EMIT_CONSTRAINTS_FOR_GLOBALS_EXT @@ -249,7 +250,8 @@ void CommandLineFlagConstraintList::init(void) { EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, EMIT_CONSTRAINT_NOTPRODUCT_FLAG, IGNORE_RANGE, - EMIT_CONSTRAINT_CHECK)); + EMIT_CONSTRAINT_CHECK, + IGNORE_WRITEABLE)); #ifdef COMPILER1 @@ -260,7 +262,8 @@ void CommandLineFlagConstraintList::init(void) { EMIT_CONSTRAINT_DIAGNOSTIC_FLAG, EMIT_CONSTRAINT_NOTPRODUCT_FLAG, IGNORE_RANGE, - EMIT_CONSTRAINT_CHECK)); + EMIT_CONSTRAINT_CHECK, + IGNORE_WRITEABLE)); #endif // COMPILER1 #ifdef COMPILER2 @@ -272,7 +275,8 @@ void CommandLineFlagConstraintList::init(void) { EMIT_CONSTRAINT_EXPERIMENTAL_FLAG, EMIT_CONSTRAINT_NOTPRODUCT_FLAG, IGNORE_RANGE, - EMIT_CONSTRAINT_CHECK)); + EMIT_CONSTRAINT_CHECK, + IGNORE_WRITEABLE)); #endif // COMPILER2 #if INCLUDE_ALL_GCS @@ -286,7 +290,8 @@ void CommandLineFlagConstraintList::init(void) { EMIT_CONSTRAINT_MANAGEABLE_FLAG, EMIT_CONSTRAINT_PRODUCT_RW_FLAG, IGNORE_RANGE, - EMIT_CONSTRAINT_CHECK)); + EMIT_CONSTRAINT_CHECK, + IGNORE_WRITEABLE)); #endif // INCLUDE_ALL_GCS } diff --git a/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp b/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp index 89acace33f7..ba9d8f11358 100644 --- a/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp +++ b/hotspot/src/share/vm/runtime/commandLineFlagRangeList.cpp @@ -305,7 +305,8 @@ void CommandLineFlagRangeList::init(void) { EMIT_RANGE_PRODUCT_RW_FLAG, EMIT_RANGE_LP64_PRODUCT_FLAG, EMIT_RANGE_CHECK, - IGNORE_CONSTRAINT) ); + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE)); EMIT_RANGES_FOR_GLOBALS_EXT @@ -315,7 +316,8 @@ void CommandLineFlagRangeList::init(void) { EMIT_RANGE_EXPERIMENTAL_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_CHECK, - IGNORE_CONSTRAINT)); + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE)); #if INCLUDE_JVMCI emit_range_no(NULL JVMCI_FLAGS(EMIT_RANGE_DEVELOPER_FLAG, @@ -326,7 +328,8 @@ void CommandLineFlagRangeList::init(void) { EMIT_RANGE_EXPERIMENTAL_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_CHECK, - IGNORE_CONSTRAINT)); + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE)); #endif // INCLUDE_JVMCI #ifdef COMPILER1 @@ -337,7 +340,8 @@ void CommandLineFlagRangeList::init(void) { EMIT_RANGE_DIAGNOSTIC_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_CHECK, - IGNORE_CONSTRAINT)); + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE)); #endif // COMPILER1 #ifdef COMPILER2 @@ -349,7 +353,8 @@ void CommandLineFlagRangeList::init(void) { EMIT_RANGE_EXPERIMENTAL_FLAG, EMIT_RANGE_NOTPRODUCT_FLAG, EMIT_RANGE_CHECK, - IGNORE_CONSTRAINT)); + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE)); #endif // COMPILER2 #if INCLUDE_ALL_GCS @@ -363,7 +368,8 @@ void CommandLineFlagRangeList::init(void) { EMIT_RANGE_MANAGEABLE_FLAG, EMIT_RANGE_PRODUCT_RW_FLAG, EMIT_RANGE_CHECK, - IGNORE_CONSTRAINT)); + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE)); #endif // INCLUDE_ALL_GCS } diff --git a/hotspot/src/share/vm/runtime/commandLineFlagRangeList.hpp b/hotspot/src/share/vm/runtime/commandLineFlagRangeList.hpp index bc299d4f2a5..6531da66008 100644 --- a/hotspot/src/share/vm/runtime/commandLineFlagRangeList.hpp +++ b/hotspot/src/share/vm/runtime/commandLineFlagRangeList.hpp @@ -66,7 +66,6 @@ class CommandLineFlagRangeList : public AllStatic { static GrowableArray* _ranges; public: static void init(); - static void add_globals_ext(); static int length() { return (_ranges != NULL) ? _ranges->length() : 0; } static CommandLineFlagRange* at(int i) { return (_ranges != NULL) ? _ranges->at(i) : NULL; } static CommandLineFlagRange* find(const char* name); diff --git a/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp b/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp new file mode 100644 index 00000000000..51b0117d8d7 --- /dev/null +++ b/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.cpp @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "runtime/commandLineFlagWriteableList.hpp" +#include "runtime/os.hpp" +#if INCLUDE_ALL_GCS +#include "gc/cms/concurrentMarkSweepGeneration.inline.hpp" +#include "gc/g1/g1_globals.hpp" +#include "gc/g1/heapRegionBounds.inline.hpp" +#include "gc/shared/plab.hpp" +#endif // INCLUDE_ALL_GCS +#ifdef COMPILER1 +#include "c1/c1_globals.hpp" +#endif // COMPILER1 +#ifdef COMPILER2 +#include "opto/c2_globals.hpp" +#endif // COMPILER2 +#if INCLUDE_JVMCI +#include "jvmci/jvmci_globals.hpp" +#endif + +bool CommandLineFlagWriteable::is_writeable(void) { + return _writeable; +} + +void CommandLineFlagWriteable::mark_once(void) { + if (_type == Once) { + _writeable = false; + } +} + +void CommandLineFlagWriteable::mark_startup(void) { + if (_type == CommandLineFlagWriteable::CommandLineOnly) { + _writeable = false; + } +} + +// No control emitting +void emit_writeable_no(...) { /* NOP */ } + +// No control emitting if type argument is NOT provided +void emit_writeable_bool(const char* /*name*/) { /* NOP */ } +void emit_writeable_ccstr(const char* /*name*/) { /* NOP */ } +void emit_writeable_ccstrlist(const char* /*name*/) { /* NOP */ } +void emit_writeable_int(const char* /*name*/) { /* NOP */ } +void emit_writeable_intx(const char* /*name*/) { /* NOP */ } +void emit_writeable_uint(const char* /*name*/) { /* NOP */ } +void emit_writeable_uintx(const char* /*name*/) { /* NOP */ } +void emit_writeable_uint64_t(const char* /*name*/) { /* NOP */ } +void emit_writeable_size_t(const char* /*name*/) { /* NOP */ } +void emit_writeable_double(const char* /*name*/) { /* NOP */ } + +// CommandLineFlagWriteable emitting code functions if range arguments are provided +void emit_writeable_bool(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_int(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_intx(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_uint(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_uintx(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_uint64_t(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_size_t(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} +void emit_writeable_double(const char* name, CommandLineFlagWriteable::WriteableType type) { + CommandLineFlagWriteableList::add(new CommandLineFlagWriteable(name, type)); +} + +// Generate code to call emit_writeable_xxx function +#define EMIT_WRITEABLE_PRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_COMMERCIAL_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_DIAGNOSTIC_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_EXPERIMENTAL_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_MANAGEABLE_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_PRODUCT_RW_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_PD_PRODUCT_FLAG(type, name, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_DEVELOPER_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_PD_DEVELOPER_FLAG(type, name, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_NOTPRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name +#define EMIT_WRITEABLE_LP64_PRODUCT_FLAG(type, name, value, doc) ); emit_writeable_##type(#name + +// Generate type argument to pass into emit_writeable_xxx functions +#define EMIT_WRITEABLE(a) , CommandLineFlagWriteable::a + +#define INITIAL_WRITEABLES_SIZE 2 +GrowableArray* CommandLineFlagWriteableList::_controls = NULL; + +void CommandLineFlagWriteableList::init(void) { + + _controls = new (ResourceObj::C_HEAP, mtArguments) GrowableArray(INITIAL_WRITEABLES_SIZE, true); + + emit_writeable_no(NULL RUNTIME_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, + EMIT_WRITEABLE_PD_DEVELOPER_FLAG, + EMIT_WRITEABLE_PRODUCT_FLAG, + EMIT_WRITEABLE_PD_PRODUCT_FLAG, + EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_EXPERIMENTAL_FLAG, + EMIT_WRITEABLE_NOTPRODUCT_FLAG, + EMIT_WRITEABLE_MANAGEABLE_FLAG, + EMIT_WRITEABLE_PRODUCT_RW_FLAG, + EMIT_WRITEABLE_LP64_PRODUCT_FLAG, + IGNORE_RANGE, + IGNORE_CONSTRAINT, + EMIT_WRITEABLE)); + + EMIT_WRITEABLES_FOR_GLOBALS_EXT + + emit_writeable_no(NULL ARCH_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, + EMIT_WRITEABLE_PRODUCT_FLAG, + EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_EXPERIMENTAL_FLAG, + EMIT_WRITEABLE_NOTPRODUCT_FLAG, + IGNORE_RANGE, + IGNORE_CONSTRAINT, + EMIT_WRITEABLE)); + +#if INCLUDE_JVMCI + emit_writeable_no(NULL JVMCI_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, + EMIT_WRITEABLE_PD_DEVELOPER_FLAG, + EMIT_WRITEABLE_PRODUCT_FLAG, + EMIT_WRITEABLE_PD_PRODUCT_FLAG, + EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_EXPERIMENTAL_FLAG, + EMIT_WRITEABLE_NOTPRODUCT_FLAG, + IGNORE_RANGE, + IGNORE_CONSTRAINT, + EMIT_WRITEABLE)); +#endif // INCLUDE_JVMCI + +#ifdef COMPILER1 + emit_writeable_no(NULL C1_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, + EMIT_WRITEABLE_PD_DEVELOPER_FLAG, + EMIT_WRITEABLE_PRODUCT_FLAG, + EMIT_WRITEABLE_PD_PRODUCT_FLAG, + EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_NOTPRODUCT_FLAG, + IGNORE_RANGE, + IGNORE_CONSTRAINT, + EMIT_WRITEABLE)); +#endif // COMPILER1 + +#ifdef COMPILER2 + emit_writeable_no(NULL C2_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, + EMIT_WRITEABLE_PD_DEVELOPER_FLAG, + EMIT_WRITEABLE_PRODUCT_FLAG, + EMIT_WRITEABLE_PD_PRODUCT_FLAG, + EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_EXPERIMENTAL_FLAG, + EMIT_WRITEABLE_NOTPRODUCT_FLAG, + IGNORE_RANGE, + IGNORE_CONSTRAINT, + EMIT_WRITEABLE)); +#endif // COMPILER2 + +#if INCLUDE_ALL_GCS + emit_writeable_no(NULL G1_FLAGS(EMIT_WRITEABLE_DEVELOPER_FLAG, + EMIT_WRITEABLE_PD_DEVELOPER_FLAG, + EMIT_WRITEABLE_PRODUCT_FLAG, + EMIT_WRITEABLE_PD_PRODUCT_FLAG, + EMIT_WRITEABLE_DIAGNOSTIC_FLAG, + EMIT_WRITEABLE_EXPERIMENTAL_FLAG, + EMIT_WRITEABLE_NOTPRODUCT_FLAG, + EMIT_WRITEABLE_MANAGEABLE_FLAG, + EMIT_WRITEABLE_PRODUCT_RW_FLAG, + IGNORE_RANGE, + IGNORE_CONSTRAINT, + EMIT_WRITEABLE)); +#endif // INCLUDE_ALL_GCS +} + +CommandLineFlagWriteable* CommandLineFlagWriteableList::find(const char* name) { + CommandLineFlagWriteable* found = NULL; + for (int i=0; iname(), name) == 0) { + found = writeable; + break; + } + } + return found; +} + +void CommandLineFlagWriteableList::mark_startup(void) { + for (int i=0; imark_startup(); + } +} diff --git a/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.hpp b/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.hpp new file mode 100644 index 00000000000..84220851fb2 --- /dev/null +++ b/hotspot/src/share/vm/runtime/commandLineFlagWriteableList.hpp @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#ifndef SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP +#define SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP + +#include "runtime/globals.hpp" +#include "utilities/growableArray.hpp" + +class CommandLineFlagWriteable : public CHeapObj { +public: + enum WriteableType { + // can be set without any limits + Always = 0, + // can only be set once, either via command lines or during runtime + Once = 1, + // can only be set on command line (multiple times allowed) + CommandLineOnly = 2 + }; +private: + const char* _name; + WriteableType _type; + bool _writeable; + bool _startup_done; +public: + // the "name" argument must be a string literal + CommandLineFlagWriteable(const char* name, WriteableType type) { _name=name; _type=type; _writeable=true; _startup_done=false; } + ~CommandLineFlagWriteable() {} + const char* name() { return _name; } + const WriteableType type() { return _type; } + bool is_writeable(void); + void mark_once(void); + void mark_startup(void); +}; + +class CommandLineFlagWriteableList : public AllStatic { + static GrowableArray* _controls; +public: + static void init(); + static int length() { return (_controls != NULL) ? _controls->length() : 0; } + static CommandLineFlagWriteable* at(int i) { return (_controls != NULL) ? _controls->at(i) : NULL; } + static CommandLineFlagWriteable* find(const char* name); + static void add(CommandLineFlagWriteable* range) { _controls->append(range); } + static void mark_startup(void); +}; + +#endif // SHARE_VM_RUNTIME_COMMANDLINEFLAGWRITEABLE_HPP diff --git a/hotspot/src/share/vm/runtime/globals.cpp b/hotspot/src/share/vm/runtime/globals.cpp index ef98dd77f94..06742212f19 100644 --- a/hotspot/src/share/vm/runtime/globals.cpp +++ b/hotspot/src/share/vm/runtime/globals.cpp @@ -29,10 +29,12 @@ #include "runtime/globals.hpp" #include "runtime/globals_extension.hpp" #include "runtime/commandLineFlagConstraintList.hpp" +#include "runtime/commandLineFlagWriteableList.hpp" #include "runtime/commandLineFlagRangeList.hpp" #include "runtime/os.hpp" #include "runtime/sharedRuntime.hpp" #include "trace/tracing.hpp" +#include "utilities/defaultStream.hpp" #include "utilities/macros.hpp" #include "utilities/ostream.hpp" #if INCLUDE_ALL_GCS @@ -62,7 +64,8 @@ RUNTIME_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_PRODUCT_RW_FLAG, \ MATERIALIZE_LP64_PRODUCT_FLAG, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) RUNTIME_OS_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_PD_DEVELOPER_FLAG, \ @@ -71,7 +74,8 @@ RUNTIME_OS_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_DIAGNOSTIC_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) ARCH_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_PRODUCT_FLAG, \ @@ -79,7 +83,8 @@ ARCH_FLAGS(MATERIALIZE_DEVELOPER_FLAG, \ MATERIALIZE_EXPERIMENTAL_FLAG, \ MATERIALIZE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) MATERIALIZE_FLAGS_EXT @@ -141,10 +146,35 @@ static bool is_product_build() { #endif } -void Flag::check_writable() { +Flag::Error Flag::check_writable(bool changed) { if (is_constant_in_binary()) { fatal("flag is constant: %s", _name); } + + Flag::Error error = Flag::SUCCESS; + if (changed) { + CommandLineFlagWriteable* writeable = CommandLineFlagWriteableList::find(_name); + if (writeable) { + if (writeable->is_writeable() == false) { + switch (writeable->type()) + { + case CommandLineFlagWriteable::Once: + error = Flag::SET_ONLY_ONCE; + jio_fprintf(defaultStream::error_stream(), "Error: %s may not be set more than once\n", _name); + break; + case CommandLineFlagWriteable::CommandLineOnly: + error = Flag::COMMAND_LINE_ONLY; + jio_fprintf(defaultStream::error_stream(), "Error: %s may be modified only from commad line\n", _name); + break; + default: + ShouldNotReachHere(); + break; + } + } + writeable->mark_once(); + } + } + return error; } bool Flag::is_bool() const { @@ -155,9 +185,12 @@ bool Flag::get_bool() const { return *((bool*) _addr); } -void Flag::set_bool(bool value) { - check_writable(); - *((bool*) _addr) = value; +Flag::Error Flag::set_bool(bool value) { + Flag::Error error = check_writable(value!=get_bool()); + if (error == Flag::SUCCESS) { + *((bool*) _addr) = value; + } + return error; } bool Flag::is_int() const { @@ -168,9 +201,12 @@ int Flag::get_int() const { return *((int*) _addr); } -void Flag::set_int(int value) { - check_writable(); - *((int*) _addr) = value; +Flag::Error Flag::set_int(int value) { + Flag::Error error = check_writable(value!=get_int()); + if (error == Flag::SUCCESS) { + *((int*) _addr) = value; + } + return error; } bool Flag::is_uint() const { @@ -181,9 +217,12 @@ uint Flag::get_uint() const { return *((uint*) _addr); } -void Flag::set_uint(uint value) { - check_writable(); - *((uint*) _addr) = value; +Flag::Error Flag::set_uint(uint value) { + Flag::Error error = check_writable(value!=get_uint()); + if (error == Flag::SUCCESS) { + *((uint*) _addr) = value; + } + return error; } bool Flag::is_intx() const { @@ -194,9 +233,12 @@ intx Flag::get_intx() const { return *((intx*) _addr); } -void Flag::set_intx(intx value) { - check_writable(); - *((intx*) _addr) = value; +Flag::Error Flag::set_intx(intx value) { + Flag::Error error = check_writable(value!=get_intx()); + if (error == Flag::SUCCESS) { + *((intx*) _addr) = value; + } + return error; } bool Flag::is_uintx() const { @@ -207,9 +249,12 @@ uintx Flag::get_uintx() const { return *((uintx*) _addr); } -void Flag::set_uintx(uintx value) { - check_writable(); - *((uintx*) _addr) = value; +Flag::Error Flag::set_uintx(uintx value) { + Flag::Error error = check_writable(value!=get_uintx()); + if (error == Flag::SUCCESS) { + *((uintx*) _addr) = value; + } + return error; } bool Flag::is_uint64_t() const { @@ -220,9 +265,12 @@ uint64_t Flag::get_uint64_t() const { return *((uint64_t*) _addr); } -void Flag::set_uint64_t(uint64_t value) { - check_writable(); - *((uint64_t*) _addr) = value; +Flag::Error Flag::set_uint64_t(uint64_t value) { + Flag::Error error = check_writable(value!=get_uint64_t()); + if (error == Flag::SUCCESS) { + *((uint64_t*) _addr) = value; + } + return error; } bool Flag::is_size_t() const { @@ -233,9 +281,12 @@ size_t Flag::get_size_t() const { return *((size_t*) _addr); } -void Flag::set_size_t(size_t value) { - check_writable(); - *((size_t*) _addr) = value; +Flag::Error Flag::set_size_t(size_t value) { + Flag::Error error = check_writable(value!=get_size_t()); + if (error == Flag::SUCCESS) { + *((size_t*) _addr) = value; + } + return error; } bool Flag::is_double() const { @@ -246,9 +297,12 @@ double Flag::get_double() const { return *((double*) _addr); } -void Flag::set_double(double value) { - check_writable(); - *((double*) _addr) = value; +Flag::Error Flag::set_double(double value) { + Flag::Error error = check_writable(value!=get_double()); + if (error == Flag::SUCCESS) { + *((double*) _addr) = value; + } + return error; } bool Flag::is_ccstr() const { @@ -263,9 +317,12 @@ ccstr Flag::get_ccstr() const { return *((ccstr*) _addr); } -void Flag::set_ccstr(ccstr value) { - check_writable(); - *((ccstr*) _addr) = value; +Flag::Error Flag::set_ccstr(ccstr value) { + Flag::Error error = check_writable(value!=get_ccstr()); + if (error == Flag::SUCCESS) { + *((ccstr*) _addr) = value; + } + return error; } @@ -654,7 +711,8 @@ static Flag flagTable[] = { RUNTIME_PRODUCT_RW_FLAG_STRUCT, \ RUNTIME_LP64_PRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) RUNTIME_OS_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, \ RUNTIME_PD_DEVELOP_FLAG_STRUCT, \ RUNTIME_PRODUCT_FLAG_STRUCT, \ @@ -662,7 +720,8 @@ static Flag flagTable[] = { RUNTIME_DIAGNOSTIC_FLAG_STRUCT, \ RUNTIME_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #if INCLUDE_ALL_GCS G1_FLAGS(RUNTIME_DEVELOP_FLAG_STRUCT, \ RUNTIME_PD_DEVELOP_FLAG_STRUCT, \ @@ -674,7 +733,8 @@ static Flag flagTable[] = { RUNTIME_MANAGEABLE_FLAG_STRUCT, \ RUNTIME_PRODUCT_RW_FLAG_STRUCT, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #endif // INCLUDE_ALL_GCS #if INCLUDE_JVMCI JVMCI_FLAGS(JVMCI_DEVELOP_FLAG_STRUCT, \ @@ -685,7 +745,8 @@ static Flag flagTable[] = { JVMCI_EXPERIMENTAL_FLAG_STRUCT, \ JVMCI_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #endif // INCLUDE_JVMCI #ifdef COMPILER1 C1_FLAGS(C1_DEVELOP_FLAG_STRUCT, \ @@ -695,7 +756,8 @@ static Flag flagTable[] = { C1_DIAGNOSTIC_FLAG_STRUCT, \ C1_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #endif // COMPILER1 #ifdef COMPILER2 C2_FLAGS(C2_DEVELOP_FLAG_STRUCT, \ @@ -706,7 +768,8 @@ static Flag flagTable[] = { C2_EXPERIMENTAL_FLAG_STRUCT, \ C2_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #endif // COMPILER2 #ifdef SHARK SHARK_FLAGS(SHARK_DEVELOP_FLAG_STRUCT, \ @@ -714,7 +777,10 @@ static Flag flagTable[] = { SHARK_PRODUCT_FLAG_STRUCT, \ SHARK_PD_PRODUCT_FLAG_STRUCT, \ SHARK_DIAGNOSTIC_FLAG_STRUCT, \ - SHARK_NOTPRODUCT_FLAG_STRUCT) + SHARK_NOTPRODUCT_FLAG_STRUCT, \ + IGNORE_RANGE, \ + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #endif // SHARK ARCH_FLAGS(ARCH_DEVELOP_FLAG_STRUCT, \ ARCH_PRODUCT_FLAG_STRUCT, \ @@ -722,7 +788,8 @@ static Flag flagTable[] = { ARCH_EXPERIMENTAL_FLAG_STRUCT, \ ARCH_NOTPRODUCT_FLAG_STRUCT, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) FLAGTABLE_EXT {0, NULL, NULL} }; @@ -873,10 +940,10 @@ Flag::Error CommandLineFlags::boolAtPut(Flag* flag, bool* value, Flag::Flags ori if (check != Flag::SUCCESS) return check; bool old_value = flag->get_bool(); trace_flag_changed(name, old_value, *value, origin); - flag->set_bool(*value); + check = flag->set_bool(*value); *value = old_value; flag->set_origin(origin); - return Flag::SUCCESS; + return check; } Flag::Error CommandLineFlags::boolAtPut(const char* name, size_t len, bool* value, Flag::Flags origin) { @@ -922,10 +989,10 @@ Flag::Error CommandLineFlags::intAtPut(Flag* flag, int* value, Flag::Flags origi if (check != Flag::SUCCESS) return check; int old_value = flag->get_int(); trace_flag_changed(name, old_value, *value, origin); - flag->set_int(*value); + check = flag->set_int(*value); *value = old_value; flag->set_origin(origin); - return Flag::SUCCESS; + return check; } Flag::Error CommandLineFlags::intAtPut(const char* name, size_t len, int* value, Flag::Flags origin) { @@ -971,10 +1038,10 @@ Flag::Error CommandLineFlags::uintAtPut(Flag* flag, uint* value, Flag::Flags ori if (check != Flag::SUCCESS) return check; uint old_value = flag->get_uint(); trace_flag_changed(name, old_value, *value, origin); - flag->set_uint(*value); + check = flag->set_uint(*value); *value = old_value; flag->set_origin(origin); - return Flag::SUCCESS; + return check; } Flag::Error CommandLineFlags::uintAtPut(const char* name, size_t len, uint* value, Flag::Flags origin) { @@ -1020,10 +1087,10 @@ Flag::Error CommandLineFlags::intxAtPut(Flag* flag, intx* value, Flag::Flags ori if (check != Flag::SUCCESS) return check; intx old_value = flag->get_intx(); trace_flag_changed(name, old_value, *value, origin); - flag->set_intx(*value); + check = flag->set_intx(*value); *value = old_value; flag->set_origin(origin); - return Flag::SUCCESS; + return check; } Flag::Error CommandLineFlags::intxAtPut(const char* name, size_t len, intx* value, Flag::Flags origin) { @@ -1069,10 +1136,10 @@ Flag::Error CommandLineFlags::uintxAtPut(Flag* flag, uintx* value, Flag::Flags o if (check != Flag::SUCCESS) return check; uintx old_value = flag->get_uintx(); trace_flag_changed(name, old_value, *value, origin); - flag->set_uintx(*value); + check = flag->set_uintx(*value); *value = old_value; flag->set_origin(origin); - return Flag::SUCCESS; + return check; } Flag::Error CommandLineFlags::uintxAtPut(const char* name, size_t len, uintx* value, Flag::Flags origin) { @@ -1118,10 +1185,10 @@ Flag::Error CommandLineFlags::uint64_tAtPut(Flag* flag, uint64_t* value, Flag::F if (check != Flag::SUCCESS) return check; uint64_t old_value = flag->get_uint64_t(); trace_flag_changed(name, old_value, *value, origin); - flag->set_uint64_t(*value); + check = flag->set_uint64_t(*value); *value = old_value; flag->set_origin(origin); - return Flag::SUCCESS; + return check; } Flag::Error CommandLineFlags::uint64_tAtPut(const char* name, size_t len, uint64_t* value, Flag::Flags origin) { @@ -1168,10 +1235,10 @@ Flag::Error CommandLineFlags::size_tAtPut(Flag* flag, size_t* value, Flag::Flags if (check != Flag::SUCCESS) return check; size_t old_value = flag->get_size_t(); trace_flag_changed(name, old_value, *value, origin); - flag->set_size_t(*value); + check = flag->set_size_t(*value); *value = old_value; flag->set_origin(origin); - return Flag::SUCCESS; + return check; } Flag::Error CommandLineFlags::size_tAtPut(const char* name, size_t len, size_t* value, Flag::Flags origin) { @@ -1217,10 +1284,10 @@ Flag::Error CommandLineFlags::doubleAtPut(Flag* flag, double* value, Flag::Flags if (check != Flag::SUCCESS) return check; double old_value = flag->get_double(); trace_flag_changed(name, old_value, *value, origin); - flag->set_double(*value); + check = flag->set_double(*value); *value = old_value; flag->set_origin(origin); - return Flag::SUCCESS; + return check; } Flag::Error CommandLineFlags::doubleAtPut(const char* name, size_t len, double* value, Flag::Flags origin) { @@ -1252,14 +1319,14 @@ Flag::Error CommandLineFlags::ccstrAtPut(const char* name, size_t len, ccstr* va if (*value != NULL) { new_value = os::strdup_check_oom(*value); } - result->set_ccstr(new_value); + Flag::Error check = result->set_ccstr(new_value); if (result->is_default() && old_value != NULL) { // Prior value is NOT heap allocated, but was a literal constant. old_value = os::strdup_check_oom(old_value); } *value = old_value; result->set_origin(origin); - return Flag::SUCCESS; + return check; } Flag::Error CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr value, Flag::Flags origin) { @@ -1268,13 +1335,13 @@ Flag::Error CommandLineFlagsEx::ccstrAtPut(CommandLineFlagWithType flag, ccstr v ccstr old_value = faddr->get_ccstr(); trace_flag_changed(faddr->_name, old_value, value, origin); char* new_value = os::strdup_check_oom(value); - faddr->set_ccstr(new_value); + Flag::Error check = faddr->set_ccstr(new_value); if (!faddr->is_default() && old_value != NULL) { // Prior value is heap allocated so free it. FREE_C_HEAP_ARRAY(char, old_value); } faddr->set_origin(origin); - return Flag::SUCCESS; + return check; } extern "C" { diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index e1cceec6f7d..2b1a730ea04 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -280,6 +280,12 @@ struct Flag { VIOLATES_CONSTRAINT, // there is no flag with the given name INVALID_FLAG, + // the flag can only be set only on command line during invocation of the VM + COMMAND_LINE_ONLY, + // the flag may only be set once + SET_ONLY_ONCE, + // the flag is not writable in this combination of product/debug build + CONSTANT, // other, unspecified error related to setting the flag ERR_OTHER }; @@ -316,44 +322,44 @@ struct Flag { static const char* get_size_t_default_range_str(); static const char* get_double_default_range_str(); - void check_writable(); + Flag::Error check_writable(bool changed); bool is_bool() const; bool get_bool() const; - void set_bool(bool value); + Flag::Error set_bool(bool value); bool is_int() const; int get_int() const; - void set_int(int value); + Flag::Error set_int(int value); bool is_uint() const; uint get_uint() const; - void set_uint(uint value); + Flag::Error set_uint(uint value); bool is_intx() const; intx get_intx() const; - void set_intx(intx value); + Flag::Error set_intx(intx value); bool is_uintx() const; uintx get_uintx() const; - void set_uintx(uintx value); + Flag::Error set_uintx(uintx value); bool is_uint64_t() const; uint64_t get_uint64_t() const; - void set_uint64_t(uint64_t value); + Flag::Error set_uint64_t(uint64_t value); bool is_size_t() const; size_t get_size_t() const; - void set_size_t(size_t value); + Flag::Error set_size_t(size_t value); bool is_double() const; double get_double() const; - void set_double(double value); + Flag::Error set_double(double value); bool is_ccstr() const; bool ccstr_accumulates() const; ccstr get_ccstr() const; - void set_ccstr(ccstr value); + Flag::Error set_ccstr(ccstr value); Flags get_origin(); void set_origin(Flags origin); @@ -621,8 +627,31 @@ public: // constraint is a macro that will expand to custom function call // for constraint checking if provided - see commandLineFlagConstraintList.hpp // +// writeable is a macro that controls if and how the value can change during the runtime +// +// writeable(Always) is optional and allows the flag to have its value changed +// without any limitations at any time +// +// writeable(Once) flag value's can be only set once during the lifetime of VM +// +// writeable(CommandLineOnly) flag value's can be only set from command line +// (multiple times allowed) +// + -#define RUNTIME_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, manageable, product_rw, lp64_product, range, constraint) \ +#define RUNTIME_FLAGS(develop, \ + develop_pd, \ + product, \ + product_pd, \ + diagnostic, \ + experimental, \ + notproduct, \ + manageable, \ + product_rw, \ + lp64_product, \ + range, \ + constraint, \ + writeable) \ \ lp64_product(bool, UseCompressedOops, false, \ "Use 32-bit object references in 64-bit VM. " \ @@ -4185,6 +4214,8 @@ public: // Only materialize src code for contraint checking when required, ignore otherwise #define IGNORE_CONSTRAINT(func,type) +#define IGNORE_WRITEABLE(type) + RUNTIME_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_PD_DEVELOPER_FLAG, \ DECLARE_PRODUCT_FLAG, \ @@ -4196,7 +4227,8 @@ RUNTIME_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_PRODUCT_RW_FLAG, \ DECLARE_LP64_PRODUCT_FLAG, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) RUNTIME_OS_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_PD_DEVELOPER_FLAG, \ @@ -4205,7 +4237,8 @@ RUNTIME_OS_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_DIAGNOSTIC_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) ARCH_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_PRODUCT_FLAG, \ @@ -4213,7 +4246,8 @@ ARCH_FLAGS(DECLARE_DEVELOPER_FLAG, \ DECLARE_EXPERIMENTAL_FLAG, \ DECLARE_NOTPRODUCT_FLAG, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) // Extensions diff --git a/hotspot/src/share/vm/runtime/globals_extension.hpp b/hotspot/src/share/vm/runtime/globals_extension.hpp index b550f236042..810fcd7a73f 100644 --- a/hotspot/src/share/vm/runtime/globals_extension.hpp +++ b/hotspot/src/share/vm/runtime/globals_extension.hpp @@ -103,7 +103,8 @@ typedef enum { RUNTIME_PRODUCT_RW_FLAG_MEMBER, \ RUNTIME_LP64_PRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) RUNTIME_OS_FLAGS(RUNTIME_DEVELOP_FLAG_MEMBER, \ RUNTIME_PD_DEVELOP_FLAG_MEMBER, \ RUNTIME_PRODUCT_FLAG_MEMBER, \ @@ -111,7 +112,8 @@ typedef enum { RUNTIME_DIAGNOSTIC_FLAG_MEMBER, \ RUNTIME_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #if INCLUDE_ALL_GCS G1_FLAGS(RUNTIME_DEVELOP_FLAG_MEMBER, \ RUNTIME_PD_DEVELOP_FLAG_MEMBER, \ @@ -123,7 +125,8 @@ typedef enum { RUNTIME_MANAGEABLE_FLAG_MEMBER, \ RUNTIME_PRODUCT_RW_FLAG_MEMBER, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #endif // INCLUDE_ALL_GCS #if INCLUDE_JVMCI JVMCI_FLAGS(JVMCI_DEVELOP_FLAG_MEMBER, \ @@ -134,7 +137,8 @@ typedef enum { JVMCI_EXPERIMENTAL_FLAG_MEMBER, \ JVMCI_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #endif // INCLUDE_JVMCI #ifdef COMPILER1 C1_FLAGS(C1_DEVELOP_FLAG_MEMBER, \ @@ -144,7 +148,8 @@ typedef enum { C1_DIAGNOSTIC_FLAG_MEMBER, \ C1_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #endif #ifdef COMPILER2 C2_FLAGS(C2_DEVELOP_FLAG_MEMBER, \ @@ -155,7 +160,8 @@ typedef enum { C2_EXPERIMENTAL_FLAG_MEMBER, \ C2_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) #endif ARCH_FLAGS(ARCH_DEVELOP_FLAG_MEMBER, \ ARCH_PRODUCT_FLAG_MEMBER, \ @@ -163,7 +169,8 @@ typedef enum { ARCH_EXPERIMENTAL_FLAG_MEMBER, \ ARCH_NOTPRODUCT_FLAG_MEMBER, \ IGNORE_RANGE, \ - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, \ + IGNORE_WRITEABLE) COMMANDLINEFLAG_EXT NUM_CommandLineFlag } CommandLineFlag; @@ -229,7 +236,8 @@ typedef enum { RUNTIME_PRODUCT_RW_FLAG_MEMBER_WITH_TYPE, RUNTIME_LP64_PRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE) RUNTIME_OS_FLAGS(RUNTIME_DEVELOP_FLAG_MEMBER_WITH_TYPE, RUNTIME_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE, RUNTIME_PRODUCT_FLAG_MEMBER_WITH_TYPE, @@ -237,7 +245,8 @@ typedef enum { RUNTIME_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, RUNTIME_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE) #if INCLUDE_ALL_GCS G1_FLAGS(RUNTIME_DEVELOP_FLAG_MEMBER_WITH_TYPE, RUNTIME_PD_DEVELOP_FLAG_MEMBER_WITH_TYPE, @@ -249,7 +258,8 @@ typedef enum { RUNTIME_MANAGEABLE_FLAG_MEMBER_WITH_TYPE, RUNTIME_PRODUCT_RW_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE) #endif // INCLUDE_ALL_GCS #if INCLUDE_JVMCI JVMCI_FLAGS(JVMCI_DEVELOP_FLAG_MEMBER_WITH_TYPE, @@ -260,7 +270,8 @@ typedef enum { JVMCI_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE, JVMCI_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE) #endif // INCLUDE_JVMCI #ifdef COMPILER1 C1_FLAGS(C1_DEVELOP_FLAG_MEMBER_WITH_TYPE, @@ -270,7 +281,8 @@ typedef enum { C1_DIAGNOSTIC_FLAG_MEMBER_WITH_TYPE, C1_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE) #endif #ifdef COMPILER2 C2_FLAGS(C2_DEVELOP_FLAG_MEMBER_WITH_TYPE, @@ -281,7 +293,8 @@ typedef enum { C2_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE, C2_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE) #endif ARCH_FLAGS(ARCH_DEVELOP_FLAG_MEMBER_WITH_TYPE, ARCH_PRODUCT_FLAG_MEMBER_WITH_TYPE, @@ -289,7 +302,8 @@ typedef enum { ARCH_EXPERIMENTAL_FLAG_MEMBER_WITH_TYPE, ARCH_NOTPRODUCT_FLAG_MEMBER_WITH_TYPE, IGNORE_RANGE, - IGNORE_CONSTRAINT) + IGNORE_CONSTRAINT, + IGNORE_WRITEABLE) COMMANDLINEFLAGWITHTYPE_EXT NUM_CommandLineFlagWithType } CommandLineFlagWithType; diff --git a/hotspot/src/share/vm/runtime/os_ext.hpp b/hotspot/src/share/vm/runtime/os_ext.hpp index 80b87f2dbbb..3aa733a322a 100644 --- a/hotspot/src/share/vm/runtime/os_ext.hpp +++ b/hotspot/src/share/vm/runtime/os_ext.hpp @@ -27,6 +27,7 @@ #define EMIT_RANGES_FOR_GLOBALS_EXT // NOP #define EMIT_CONSTRAINTS_FOR_GLOBALS_EXT // NOP +#define EMIT_WRITEABLES_FOR_GLOBALS_EXT // NOP public: static void init_globals_ext() {} // Run from init_globals(). diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index f1794e0e692..6c6bb684638 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -60,6 +60,7 @@ #include "runtime/atomic.inline.hpp" #include "runtime/biasedLocking.hpp" #include "runtime/commandLineFlagConstraintList.hpp" +#include "runtime/commandLineFlagWriteableList.hpp" #include "runtime/commandLineFlagRangeList.hpp" #include "runtime/deoptimization.hpp" #include "runtime/fprofiler.hpp" @@ -3544,6 +3545,8 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { return JNI_EINVAL; } + CommandLineFlagWriteableList::mark_startup(); + if (PauseAtStartup) { os::pause(); } -- GitLab From 5992b4a6b2531270de2c3d3fd4d8eef72a8ee849 Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Tue, 10 May 2016 21:23:33 +0300 Subject: [PATCH 327/400] 8150865: SQE test: GC unified logging: check that dynamic log level doesn't break anything Reviewed-by: jwilhelm, dfazunen --- hotspot/test/TEST.groups | 1 + .../TestUnifiedLoggingSwitchStress.java | 245 ++++++++++++++++++ 2 files changed, 246 insertions(+) create mode 100644 hotspot/test/gc/logging/TestUnifiedLoggingSwitchStress.java diff --git a/hotspot/test/TEST.groups b/hotspot/test/TEST.groups index 729dd77d328..262232e706c 100644 --- a/hotspot/test/TEST.groups +++ b/hotspot/test/TEST.groups @@ -338,6 +338,7 @@ hotspot_fast_gc_2 = \ sanity/ExecuteInternalVMTests.java \ gc/ \ -gc/g1/ \ + -gc/logging/TestUnifiedLoggingSwitchStress.java \ -gc/stress \ -gc/survivorAlignment/TestPromotionFromSurvivorToTenuredAfterMinorGC.java \ -gc/cms/TestMBeanCMS.java \ diff --git a/hotspot/test/gc/logging/TestUnifiedLoggingSwitchStress.java b/hotspot/test/gc/logging/TestUnifiedLoggingSwitchStress.java new file mode 100644 index 00000000000..647cd63128e --- /dev/null +++ b/hotspot/test/gc/logging/TestUnifiedLoggingSwitchStress.java @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package gc.logging; + +import jdk.test.lib.Utils; + +import javax.management.InstanceNotFoundException; +import javax.management.MBeanException; +import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; +import javax.management.ReflectionException; +import java.lang.management.ManagementFactory; +import java.util.LinkedList; +import java.util.List; +import java.util.Random; + + +/** + * @test TestUnifiedLoggingSwitchStress + * @summary Switches gc log level on fly while stressing memory/gc + * @key gc + * @key stress + * @library /testlibrary /test/lib / + * @modules java.management java.base/jdk.internal.misc + * + * @run main/othervm -Xmx256M -Xms256M + * gc.logging.TestUnifiedLoggingSwitchStress 60 + */ + +class MemoryStresser implements Runnable { + public static volatile boolean shouldStop = false; + + private final List liveObjects = new LinkedList<>(); + private final List liveHObjects = new LinkedList<>(); + private int maxSimpleAllocationMemory = 0; + private int usedMemory = 0; + + /** + * Maximum amount of huge allocations + */ + private static int H_ALLOCATION_MAX_COUNT = 4; + /** + * Maximum regions in one huge allocation + */ + private static int H_ALLOCATION_REGION_SIZE = 2; + private static final int G1_REGION_SIZE = 1024 * 1024; + /** + * Maximum size of simple allocation + */ + private static final int MAX_SIMPLE_ALLOCATION_SIZE = (int) (G1_REGION_SIZE / 2 * 0.9); + + /** + * Maximum size of dead (i.e. one which is made unreachable right after allocation) object + */ + private static final int DEAD_OBJECT_MAX_SIZE = G1_REGION_SIZE / 10; + private static final Random RND = Utils.getRandomInstance(); + + /** + * @param maxMemory maximum memory that could be allocated + */ + public MemoryStresser(int maxMemory) { + maxSimpleAllocationMemory = maxMemory - G1_REGION_SIZE * H_ALLOCATION_MAX_COUNT * H_ALLOCATION_REGION_SIZE; + } + + public final Runnable[] actions = new Runnable[]{ + // Huge allocation + () -> { + if (liveHObjects.size() < H_ALLOCATION_MAX_COUNT) { + int allocationSize = RND.nextInt((int) (G1_REGION_SIZE * (H_ALLOCATION_REGION_SIZE - 0.5) + * 0.9)); + liveHObjects.add(new byte[allocationSize + G1_REGION_SIZE / 2]); + } + }, + + // Huge deallocation + () -> { + if (liveHObjects.size() > 0) { + int elementNum = RND.nextInt(liveHObjects.size()); + liveHObjects.remove(elementNum); + } + }, + + // Simple allocation + () -> { + if (maxSimpleAllocationMemory - usedMemory != 0) { + int arraySize = RND.nextInt(Math.min(maxSimpleAllocationMemory - usedMemory, + MAX_SIMPLE_ALLOCATION_SIZE)); + if (arraySize != 0) { + liveObjects.add(new byte[arraySize]); + usedMemory += arraySize; + } + } + }, + + // Simple deallocation + () -> { + if (liveObjects.size() != 0) { + int elementNum = RND.nextInt(liveObjects.size()); + int shouldFree = liveObjects.get(elementNum).length; + liveObjects.remove(elementNum); + usedMemory -= shouldFree; + } + }, + + // Dead object allocation + () -> { + int size = RND.nextInt(DEAD_OBJECT_MAX_SIZE); + byte[] deadObject = new byte[size]; + } + }; + + @Override + public void run() { + while (!shouldStop) { + actions[RND.nextInt(actions.length)].run(); + Thread.yield(); + } + + System.out.println("Memory Stresser finished"); + } +} + +class LogLevelSwitcher implements Runnable { + + public static volatile boolean shouldStop = false; + private final int logCount; // how many various log files will be used + private final String logFilePrefix; // name of log file will be logFilePrefix + index + private final Random RND = Utils.getRandomInstance(); + private final MBeanServer MBS = ManagementFactory.getPlatformMBeanServer(); + + /** + * @param logFilePrefix prefix for log files + * @param logCount amount of log files + */ + public LogLevelSwitcher(String logFilePrefix, int logCount) { + this.logCount = logCount; + this.logFilePrefix = logFilePrefix; + + } + + private static final String[] LOG_LEVELS = {"error", "warning", "info", "debug", "trace"}; + + @Override + public void run() { + + while (!shouldStop) { + int fileNum = RND.nextInt(logCount); + int logLevel = RND.nextInt(LOG_LEVELS.length); + + String outputCommand = String.format("output=%s_%d.log", logFilePrefix, fileNum); + String logLevelCommand = "what='gc*=" + LOG_LEVELS[logLevel] + "'"; + + try { + Object out = MBS.invoke(new ObjectName("com.sun.management:type=DiagnosticCommand"), + "vmLog", + new Object[]{new String[]{outputCommand, logLevelCommand}}, + new String[]{String[].class.getName()}); + + if (!out.toString().isEmpty()) { + System.out.format("WARNING: Diagnostic command vmLog with arguments %s,%s returned not empty" + + " output %s\n", + outputCommand, logLevelCommand, out); + } + } catch (InstanceNotFoundException | MBeanException | ReflectionException | MalformedObjectNameException e) { + System.out.println("Got exception trying to change log level:" + e); + e.printStackTrace(); + throw new Error(e); + } + Thread.yield(); + } + System.out.println("Log Switcher finished"); + } +} + + +public class TestUnifiedLoggingSwitchStress { + /** + * Count of memory stressing threads + */ + private static final int MEMORY_STRESSERS_COUNT = 3; + /** + * Count of log switching threads + */ + private static final int LOG_LEVEL_SWITCHERS_COUNT = 2; + /** + * Count of log files created by each log switching thread + */ + private static final int LOG_FILES_COUNT = 2; + /** + * Maximum amount memory allocated by each stressing thread + */ + private static final int MAX_MEMORY_PER_STRESSER = (int) (Runtime.getRuntime().freeMemory() + / MEMORY_STRESSERS_COUNT * 0.7); + + public static void main(String[] args) throws InterruptedException { + if (args.length != 1) { + throw new Error("Test Bug: Expected duration (in seconds) wasn't provided as command line argument"); + } + long duration = Integer.parseInt(args[0]) * 1000; + + long startTime = System.currentTimeMillis(); + + List threads = new LinkedList<>(); + + for (int i = 0; i < LOG_LEVEL_SWITCHERS_COUNT; i++) { + threads.add(new Thread(new LogLevelSwitcher("Output_" + i, LOG_FILES_COUNT))); + } + + for (int i = 0; i < MEMORY_STRESSERS_COUNT; i++) { + threads.add(new Thread(new MemoryStresser(MAX_MEMORY_PER_STRESSER))); + } + + threads.stream().forEach(Thread::start); + + while (System.currentTimeMillis() - startTime < duration) { + Thread.yield(); + } + + MemoryStresser.shouldStop = true; + LogLevelSwitcher.shouldStop = true; + } +} -- GitLab From 0e8376bd171d28909a5707fd2b39f246a510e2bd Mon Sep 17 00:00:00 2001 From: Brian Gardner Date: Wed, 11 May 2016 01:02:28 -0400 Subject: [PATCH 328/400] 8154715: Missing destructor and/or TLS clearing calls for terminating threads Clear TLS on return from thread->run() unless already done. Prohibit asynchronous thread deletion. Reviewed-by: stefank, sspitsyn --- hotspot/src/os/aix/vm/os_aix.cpp | 26 ++++++++++++----- hotspot/src/os/bsd/vm/os_bsd.cpp | 26 ++++++++++++----- hotspot/src/os/linux/vm/os_linux.cpp | 34 +++++++++++++++-------- hotspot/src/os/solaris/vm/os_solaris.cpp | 32 ++++++++++++--------- hotspot/src/os/windows/vm/os_windows.cpp | 21 ++++++++++++-- hotspot/src/os/windows/vm/os_windows.hpp | 2 +- hotspot/src/share/vm/runtime/thread.hpp | 9 ++++-- hotspot/src/share/vm/runtime/vmThread.cpp | 12 +++----- hotspot/src/share/vm/runtime/vmThread.hpp | 6 ++++ 9 files changed, 116 insertions(+), 52 deletions(-) diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp index a39238f5db8..20e3770af33 100644 --- a/hotspot/src/os/aix/vm/os_aix.cpp +++ b/hotspot/src/os/aix/vm/os_aix.cpp @@ -777,7 +777,7 @@ bool os::Aix::get_meminfo(meminfo_t* pmi) { // create new thread // Thread start routine for all newly created threads -static void *java_start(Thread *thread) { +static void *thread_native_entry(Thread *thread) { // find out my own stack dimensions { @@ -838,6 +838,15 @@ static void *java_start(Thread *thread) { log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", kernel thread id: " UINTX_FORMAT ").", os::current_thread_id(), (uintx) kernel_thread_id); + // If a thread has not deleted itself ("delete this") as part of its + // termination sequence, we have to ensure thread-local-storage is + // cleared before we actually terminate. No threads should ever be + // deleted asynchronously with respect to their termination. + if (Thread::current_or_null_safe() != NULL) { + assert(Thread::current_or_null_safe() == thread, "current thread is wrong"); + thread->clear_thread_current(); + } + return 0; } @@ -902,7 +911,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { pthread_attr_setstacksize(&attr, stack_size); pthread_t tid; - int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread); + int ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread); char buf[64]; @@ -993,11 +1002,14 @@ void os::pd_start_thread(Thread* thread) { void os::free_thread(OSThread* osthread) { assert(osthread != NULL, "osthread not set"); - if (Thread::current()->osthread() == osthread) { - // Restore caller's signal mask - sigset_t sigmask = osthread->caller_sigmask(); - pthread_sigmask(SIG_SETMASK, &sigmask, NULL); - } + // We are told to free resources of the argument thread, + // but we can only really operate on the current thread. + assert(Thread::current()->osthread() == osthread, + "os::free_thread but not current thread"); + + // Restore caller's signal mask + sigset_t sigmask = osthread->caller_sigmask(); + pthread_sigmask(SIG_SETMASK, &sigmask, NULL); delete osthread; } diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index 78def166e58..6de75924e8d 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -665,7 +665,7 @@ static uint64_t locate_unique_thread_id(mach_port_t mach_thread_port) { #endif // Thread start routine for all newly created threads -static void *java_start(Thread *thread) { +static void *thread_native_entry(Thread *thread) { // Try to randomize the cache line index of hot stack frames. // This helps when threads of the same stack traces evict each other's // cache lines. The threads can be either from the same JVM instance, or @@ -723,6 +723,15 @@ static void *java_start(Thread *thread) { log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", pthread id: " UINTX_FORMAT ").", os::current_thread_id(), (uintx) pthread_self()); + // If a thread has not deleted itself ("delete this") as part of its + // termination sequence, we have to ensure thread-local-storage is + // cleared before we actually terminate. No threads should ever be + // deleted asynchronously with respect to their termination. + if (Thread::current_or_null_safe() != NULL) { + assert(Thread::current_or_null_safe() == thread, "current thread is wrong"); + thread->clear_thread_current(); + } + return 0; } @@ -781,7 +790,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, size_t stack_size) { { pthread_t tid; - int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread); + int ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread); char buf[64]; if (ret == 0) { @@ -889,11 +898,14 @@ void os::pd_start_thread(Thread* thread) { void os::free_thread(OSThread* osthread) { assert(osthread != NULL, "osthread not set"); - if (Thread::current()->osthread() == osthread) { - // Restore caller's signal mask - sigset_t sigmask = osthread->caller_sigmask(); - pthread_sigmask(SIG_SETMASK, &sigmask, NULL); - } + // We are told to free resources of the argument thread, + // but we can only really operate on the current thread. + assert(Thread::current()->osthread() == osthread, + "os::free_thread but not current thread"); + + // Restore caller's signal mask + sigset_t sigmask = osthread->caller_sigmask(); + pthread_sigmask(SIG_SETMASK, &sigmask, NULL); delete osthread; } diff --git a/hotspot/src/os/linux/vm/os_linux.cpp b/hotspot/src/os/linux/vm/os_linux.cpp index a9efaec274d..3becb38278b 100644 --- a/hotspot/src/os/linux/vm/os_linux.cpp +++ b/hotspot/src/os/linux/vm/os_linux.cpp @@ -638,7 +638,7 @@ bool os::Linux::manually_expand_stack(JavaThread * t, address addr) { // create new thread // Thread start routine for all newly created threads -static void *java_start(Thread *thread) { +static void *thread_native_entry(Thread *thread) { // Try to randomize the cache line index of hot stack frames. // This helps when threads of the same stack traces evict each other's // cache lines. The threads can be either from the same JVM instance, or @@ -690,6 +690,15 @@ static void *java_start(Thread *thread) { log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", pthread id: " UINTX_FORMAT ").", os::current_thread_id(), (uintx) pthread_self()); + // If a thread has not deleted itself ("delete this") as part of its + // termination sequence, we have to ensure thread-local-storage is + // cleared before we actually terminate. No threads should ever be + // deleted asynchronously with respect to their termination. + if (Thread::current_or_null_safe() != NULL) { + assert(Thread::current_or_null_safe() == thread, "current thread is wrong"); + thread->clear_thread_current(); + } + return 0; } @@ -753,7 +762,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, { pthread_t tid; - int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread); + int ret = pthread_create(&tid, &attr, (void* (*)(void*)) thread_native_entry, thread); char buf[64]; if (ret == 0) { @@ -881,18 +890,21 @@ void os::pd_start_thread(Thread* thread) { void os::free_thread(OSThread* osthread) { assert(osthread != NULL, "osthread not set"); - if (Thread::current()->osthread() == osthread) { + // We are told to free resources of the argument thread, + // but we can only really operate on the current thread. + assert(Thread::current()->osthread() == osthread, + "os::free_thread but not current thread"); + #ifdef ASSERT - sigset_t current; - sigemptyset(¤t); - pthread_sigmask(SIG_SETMASK, NULL, ¤t); - assert(!sigismember(¤t, SR_signum), "SR signal should not be blocked!"); + sigset_t current; + sigemptyset(¤t); + pthread_sigmask(SIG_SETMASK, NULL, ¤t); + assert(!sigismember(¤t, SR_signum), "SR signal should not be blocked!"); #endif - // Restore caller's signal mask - sigset_t sigmask = osthread->caller_sigmask(); - pthread_sigmask(SIG_SETMASK, &sigmask, NULL); - } + // Restore caller's signal mask + sigset_t sigmask = osthread->caller_sigmask(); + pthread_sigmask(SIG_SETMASK, &sigmask, NULL); delete osthread; } diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index dbb8d555b8f..1b02694822e 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -725,8 +725,8 @@ extern "C" void breakpoint() { static thread_t main_thread; -// Thread start routine for all new Java threads -extern "C" void* java_start(void* thread_addr) { +// Thread start routine for all newly created threads +extern "C" void* thread_native_entry(void* thread_addr) { // Try to randomize the cache line index of hot stack frames. // This helps when threads of the same stack traces evict each other's // cache lines. The threads can be either from the same JVM instance, or @@ -796,6 +796,15 @@ extern "C" void* java_start(void* thread_addr) { log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ").", os::current_thread_id()); + // If a thread has not deleted itself ("delete this") as part of its + // termination sequence, we have to ensure thread-local-storage is + // cleared before we actually terminate. No threads should ever be + // deleted asynchronously with respect to their termination. + if (Thread::current_or_null_safe() != NULL) { + assert(Thread::current_or_null_safe() == thread, "current thread is wrong"); + thread->clear_thread_current(); + } + if (UseDetachedThreads) { thr_exit(NULL); ShouldNotReachHere(); @@ -1009,7 +1018,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, osthread->set_lwp_id(-1); osthread->set_thread_id(-1); - status = thr_create(NULL, stack_size, java_start, thread, flags, &tid); + status = thr_create(NULL, stack_size, thread_native_entry, thread, flags, &tid); char buf[64]; if (status == 0) { @@ -1221,18 +1230,15 @@ void os::initialize_thread(Thread* thr) { void os::free_thread(OSThread* osthread) { assert(osthread != NULL, "os::free_thread but osthread not set"); - // We are told to free resources of the argument thread, // but we can only really operate on the current thread. - // The main thread must take the VMThread down synchronously - // before the main thread exits and frees up CodeHeap - guarantee((Thread::current()->osthread() == osthread - || (osthread == VMThread::vm_thread()->osthread())), "os::free_thread but not current thread"); - if (Thread::current()->osthread() == osthread) { - // Restore caller's signal mask - sigset_t sigmask = osthread->caller_sigmask(); - pthread_sigmask(SIG_SETMASK, &sigmask, NULL); - } + assert(Thread::current()->osthread() == osthread, + "os::free_thread but not current thread"); + + // Restore caller's signal mask + sigset_t sigmask = osthread->caller_sigmask(); + pthread_sigmask(SIG_SETMASK, &sigmask, NULL); + delete osthread; } diff --git a/hotspot/src/os/windows/vm/os_windows.cpp b/hotspot/src/os/windows/vm/os_windows.cpp index 02ab770ccb3..7c3b6da4ed4 100644 --- a/hotspot/src/os/windows/vm/os_windows.cpp +++ b/hotspot/src/os/windows/vm/os_windows.cpp @@ -409,8 +409,8 @@ struct tm* os::localtime_pd(const time_t* clock, struct tm* res) { LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo); -// Thread start routine for all new Java threads -static unsigned __stdcall java_start(Thread* thread) { +// Thread start routine for all newly created threads +static unsigned __stdcall thread_native_entry(Thread* thread) { // Try to randomize the cache line index of hot stack frames. // This helps when threads of the same stack traces evict each other's // cache lines. The threads can be either from the same JVM instance, or @@ -459,6 +459,15 @@ static unsigned __stdcall java_start(Thread* thread) { Atomic::dec_ptr((intptr_t*)&os::win32::_os_thread_count); } + // If a thread has not deleted itself ("delete this") as part of its + // termination sequence, we have to ensure thread-local-storage is + // cleared before we actually terminate. No threads should ever be + // deleted asynchronously with respect to their termination. + if (Thread::current_or_null_safe() != NULL) { + assert(Thread::current_or_null_safe() == thread, "current thread is wrong"); + thread->clear_thread_current(); + } + // Thread must not return from exit_process_or_thread(), but if it does, // let it proceed to exit normally return (unsigned)os::win32::exit_process_or_thread(os::win32::EPT_THREAD, res); @@ -631,7 +640,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, HANDLE thread_handle = (HANDLE)_beginthreadex(NULL, (unsigned)stack_size, - (unsigned (__stdcall *)(void*)) java_start, + (unsigned (__stdcall *)(void*)) thread_native_entry, thread, initflag, &thread_id); @@ -670,6 +679,12 @@ bool os::create_thread(Thread* thread, ThreadType thr_type, // Free Win32 resources related to the OSThread void os::free_thread(OSThread* osthread) { assert(osthread != NULL, "osthread not set"); + + // We are told to free resources of the argument thread, + // but we can only really operate on the current thread. + assert(Thread::current()->osthread() == osthread, + "os::free_thread but not current thread"); + CloseHandle(osthread->thread_handle()); CloseHandle(osthread->interrupt_event()); delete osthread; diff --git a/hotspot/src/os/windows/vm/os_windows.hpp b/hotspot/src/os/windows/vm/os_windows.hpp index 5bef412f904..9170dfe1665 100644 --- a/hotspot/src/os/windows/vm/os_windows.hpp +++ b/hotspot/src/os/windows/vm/os_windows.hpp @@ -36,7 +36,7 @@ static const char* path_separator() { return ";"; } class win32 { friend class os; - friend unsigned __stdcall java_start(class Thread*); + friend unsigned __stdcall thread_native_entry(class Thread*); protected: static int _vm_page_size; diff --git a/hotspot/src/share/vm/runtime/thread.hpp b/hotspot/src/share/vm/runtime/thread.hpp index bbbf21b462e..2b81b3131c2 100644 --- a/hotspot/src/share/vm/runtime/thread.hpp +++ b/hotspot/src/share/vm/runtime/thread.hpp @@ -96,6 +96,7 @@ class WorkerThread; // - GangWorker // - GCTaskThread // - JavaThread +// - various subclasses eg CompilerThread, ServiceThread // - WatcherThread class Thread: public ThreadShadow { @@ -314,8 +315,7 @@ class Thread: public ThreadShadow { // Manage Thread::current() void initialize_thread_current(); - private: - void clear_thread_current(); // needed for detaching JNI threads + void clear_thread_current(); // TLS cleanup needed before threads terminate public: // thread entry point @@ -743,6 +743,11 @@ class WatcherThread: public Thread { // Constructor WatcherThread(); + // No destruction allowed + ~WatcherThread() { + guarantee(false, "WatcherThread deletion must fix the race with VM termination"); + } + // Tester bool is_Watcher_thread() const { return true; } diff --git a/hotspot/src/share/vm/runtime/vmThread.cpp b/hotspot/src/share/vm/runtime/vmThread.cpp index c004a64873e..d7c0137a1f4 100644 --- a/hotspot/src/share/vm/runtime/vmThread.cpp +++ b/hotspot/src/share/vm/runtime/vmThread.cpp @@ -226,16 +226,12 @@ void VMThread::create() { } } - VMThread::VMThread() : NamedThread() { set_name("VM Thread"); } void VMThread::destroy() { - if (_vm_thread != NULL) { - delete _vm_thread; - _vm_thread = NULL; // VM thread is gone - } + _vm_thread = NULL; // VM thread is gone } void VMThread::run() { @@ -308,9 +304,9 @@ void VMThread::run() { _terminate_lock->notify(); } - // Deletion must be done synchronously by the JNI DestroyJavaVM thread - // so that the VMThread deletion completes before the main thread frees - // up the CodeHeap. + // We are now racing with the VM termination being carried out in + // another thread, so we don't "delete this". Numerous threads don't + // get deleted when the VM terminates } diff --git a/hotspot/src/share/vm/runtime/vmThread.hpp b/hotspot/src/share/vm/runtime/vmThread.hpp index c55b6f493dc..85c52cb4d0f 100644 --- a/hotspot/src/share/vm/runtime/vmThread.hpp +++ b/hotspot/src/share/vm/runtime/vmThread.hpp @@ -104,6 +104,12 @@ class VMThread: public NamedThread { // Constructor VMThread(); + // No destruction allowed + ~VMThread() { + guarantee(false, "VMThread deletion must fix the race with VM termination"); + } + + // Tester bool is_VM_thread() const { return true; } bool is_GC_thread() const { return true; } -- GitLab From ce9242dc8507490219762b11b81b3495f6418ef3 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Wed, 11 May 2016 02:32:14 -0400 Subject: [PATCH 329/400] 8156689: [TESTBUG] runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java disable range testing of Allocate*PrefetchLines Reviewed-by: kvn --- .../OptionsValidation/TestOptionsWithRanges.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java index 890ac26463d..7da0e14c225 100644 --- a/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java +++ b/hotspot/test/runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java @@ -89,6 +89,14 @@ public class TestOptionsWithRanges { */ excludeTestMaxRange("CICompilerCount"); + /* + * JDK-8156679 + * Temporarily exclude from range testing as the range is not + * valid for all platforms + */ + excludeTestRange("AllocatePrefetchLines"); + excludeTestRange("AllocateInstancePrefetchLines"); + /* * JDK-8136766 * Temporarily remove ThreadStackSize from testing because Windows can set it to 0 -- GitLab From b28f905e05c818e8a294ba5d513eda50635f5aff Mon Sep 17 00:00:00 2001 From: Marcus Larsson Date: Wed, 11 May 2016 10:54:31 +0200 Subject: [PATCH 330/400] 8146948: Enable listing of LogTagSets and add support for LogTagSet descriptions Reviewed-by: rehn, iklam, kbarrett --- hotspot/src/share/vm/logging/log.cpp | 25 +++++++++++ .../src/share/vm/logging/logConfiguration.cpp | 23 +++++++--- hotspot/src/share/vm/logging/logTagSet.cpp | 43 +++++++++++++++++++ hotspot/src/share/vm/logging/logTagSet.hpp | 17 +++++--- .../vm/logging/logTagSetDescriptions.cpp | 42 ++++++++++++++++++ .../vm/logging/logTagSetDescriptions.hpp | 36 ++++++++++++++++ .../share/vm/utilities/internalVMTests.cpp | 1 + 7 files changed, 174 insertions(+), 13 deletions(-) create mode 100644 hotspot/src/share/vm/logging/logTagSetDescriptions.cpp create mode 100644 hotspot/src/share/vm/logging/logTagSetDescriptions.hpp diff --git a/hotspot/src/share/vm/logging/log.cpp b/hotspot/src/share/vm/logging/log.cpp index 598cb31fc4a..59de3ef3289 100644 --- a/hotspot/src/share/vm/logging/log.cpp +++ b/hotspot/src/share/vm/logging/log.cpp @@ -37,6 +37,7 @@ #include "logging/logOutput.hpp" #include "logging/logTagLevelExpression.hpp" #include "logging/logTagSet.hpp" +#include "logging/logTagSetDescriptions.hpp" #include "logging/logStream.inline.hpp" #include "memory/resourceArea.hpp" @@ -1174,4 +1175,28 @@ void Test_invalid_log_file() { remove(target_name); } +// Ensure -Xlog:help and LogConfiguration::describe contain tagset descriptions +void Test_logtagset_descriptions() { + for (LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) { + char expected[1024]; + d->tagset->label(expected, sizeof(expected), "+"); + jio_snprintf(expected + strlen(expected), + sizeof(expected) - strlen(expected), + ": %s", d->descr); + + ResourceMark rm; + stringStream ss; + LogConfiguration::describe(&ss); + assert(strstr(ss.as_string(), expected) != NULL, + "missing log tag set descriptions in LogConfiguration::describe"); + + TestLogFile file("log_tagset_descriptions"); + FILE* fp = fopen(file.name(), "w+"); + assert(fp != NULL, "File open error"); + LogConfiguration::print_command_line_help(fp); + fclose(fp); + assert(number_of_lines_with_substring_in_file(file.name(), expected) > 0, + "missing log tag set descriptions in -Xlog:help output"); + } +} #endif // PRODUCT diff --git a/hotspot/src/share/vm/logging/logConfiguration.cpp b/hotspot/src/share/vm/logging/logConfiguration.cpp index 33281a9132b..f09b3b56596 100644 --- a/hotspot/src/share/vm/logging/logConfiguration.cpp +++ b/hotspot/src/share/vm/logging/logConfiguration.cpp @@ -29,6 +29,7 @@ #include "logging/logDiagnosticCommand.hpp" #include "logging/logFileOutput.hpp" #include "logging/logOutput.hpp" +#include "logging/logStream.hpp" #include "logging/logTagLevelExpression.hpp" #include "logging/logTagSet.hpp" #include "memory/allocation.inline.hpp" @@ -75,11 +76,17 @@ bool ConfigurationLock::current_thread_has_lock() { void LogConfiguration::post_initialize() { LogDiagnosticCommand::registerCommand(); Log(logging) log; - log.info("Log configuration fully initialized."); - log_develop_info(logging)("Develop logging is available."); - if (log.is_trace()) { - ResourceMark rm; - describe(log.trace_stream()); + if (log.is_info()) { + log.info("Log configuration fully initialized."); + log_develop_info(logging)("Develop logging is available."); + if (log.is_debug()) { + LogStream debug_stream(log.debug()); + describe(&debug_stream); + if (log.is_trace()) { + LogStream trace_stream(log.trace()); + LogTagSet::list_all_tagsets(&trace_stream); + } + } } } @@ -402,6 +409,7 @@ void LogConfiguration::describe_available(outputStream* out){ } out->cr(); + LogTagSet::describe_tagsets(out); } void LogConfiguration::describe_current_configuration(outputStream* out){ @@ -449,7 +457,10 @@ void LogConfiguration::print_command_line_help(FILE* out) { } jio_fprintf(out, "\n Specifying 'all' instead of a tag combination matches all tag combinations.\n\n"); - jio_fprintf(out, "Available log outputs:\n" + fileStream stream(out, false); + LogTagSet::describe_tagsets(&stream); + + jio_fprintf(out, "\nAvailable log outputs:\n" " stdout, stderr, file=\n" " Specifying %%p and/or %%t in the filename will expand to the JVM's PID and startup timestamp, respectively.\n\n" diff --git a/hotspot/src/share/vm/logging/logTagSet.cpp b/hotspot/src/share/vm/logging/logTagSet.cpp index c4161abcd63..446c2b46dc0 100644 --- a/hotspot/src/share/vm/logging/logTagSet.cpp +++ b/hotspot/src/share/vm/logging/logTagSet.cpp @@ -28,7 +28,9 @@ #include "logging/logOutput.hpp" #include "logging/logTag.hpp" #include "logging/logTagSet.hpp" +#include "logging/logTagSetDescriptions.hpp" #include "memory/allocation.inline.hpp" +#include "utilities/ostream.hpp" LogTagSet* LogTagSet::_list = NULL; size_t LogTagSet::_ntagsets = 0; @@ -127,3 +129,44 @@ void LogTagSet::vwrite(LogLevelType level, const char* fmt, va_list args) { } va_end(saved_args); } + +static const size_t TagSetBufferSize = 128; + +void LogTagSet::describe_tagsets(outputStream* out) { + out->print_cr("Described tag combinations:"); + for (const LogTagSetDescription* d = tagset_descriptions; d->tagset != NULL; d++) { + char buf[TagSetBufferSize]; + d->tagset->label(buf, sizeof(buf), "+"); + out->print_cr(" %s: %s", buf, d->descr); + } +} + +static int qsort_strcmp(const void* a, const void* b) { + return strcmp((*(const char**)a), (*(const char**)b)); +} + +void LogTagSet::list_all_tagsets(outputStream* out) { + char** tagset_labels = NEW_C_HEAP_ARRAY(char*, _ntagsets, mtLogging); + + // Generate the list of tagset labels + size_t idx = 0; + for (LogTagSet* ts = first(); ts != NULL; ts = ts->next()) { + char buf[TagSetBufferSize]; + ts->label(buf, sizeof(buf), "+"); + tagset_labels[idx++] = os::strdup_check_oom(buf, mtLogging); + } + assert(idx == _ntagsets, "_ntagsets and list of tagsets not in sync"); + + // Sort them lexicographically + qsort(tagset_labels, _ntagsets, sizeof(*tagset_labels), qsort_strcmp); + + // Print and then free the labels + out->print("All available tag sets: "); + for (idx = 0; idx < _ntagsets; idx++) { + out->print("%s%s", (idx == 0 ? "" : ", "), tagset_labels[idx]); + os::free(tagset_labels[idx]); + } + out->cr(); + FREE_C_HEAP_ARRAY(char*, tagset_labels); +} + diff --git a/hotspot/src/share/vm/logging/logTagSet.hpp b/hotspot/src/share/vm/logging/logTagSet.hpp index d95c1a3c8d0..0b238b32b52 100644 --- a/hotspot/src/share/vm/logging/logTagSet.hpp +++ b/hotspot/src/share/vm/logging/logTagSet.hpp @@ -39,17 +39,17 @@ class LogMessageBuffer; class LogTagSet VALUE_OBJ_CLASS_SPEC { private: static LogTagSet* _list; - static size_t _ntagsets; + static size_t _ntagsets; - LogTagSet* const _next; - size_t _ntags; - LogTagType _tag[LogTag::MaxTags]; + LogTagSet* const _next; + size_t _ntags; + LogTagType _tag[LogTag::MaxTags]; - LogOutputList _output_list; - LogDecorators _decorators; + LogOutputList _output_list; + LogDecorators _decorators; typedef size_t (*PrefixWriter)(char* buf, size_t size); - PrefixWriter _write_prefix; + PrefixWriter _write_prefix; // Keep constructor private to prevent incorrect instantiations of this class. // Only LogTagSetMappings can create/contain instances of this class. @@ -62,6 +62,9 @@ class LogTagSet VALUE_OBJ_CLASS_SPEC { friend class LogTagSetMapping; public: + static void describe_tagsets(outputStream* out); + static void list_all_tagsets(outputStream* out); + static LogTagSet* first() { return _list; } diff --git a/hotspot/src/share/vm/logging/logTagSetDescriptions.cpp b/hotspot/src/share/vm/logging/logTagSetDescriptions.cpp new file mode 100644 index 00000000000..807e88dd415 --- /dev/null +++ b/hotspot/src/share/vm/logging/logTagSetDescriptions.cpp @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +#include "precompiled.hpp" +#include "logging/logTag.hpp" +#include "logging/logTagSet.hpp" +#include "logging/logTagSetDescriptions.hpp" + +// List of described tag sets. Tags should be specified using the LOG_TAGS() +// macro. Described tag sets can be listed from command line (or DCMD) using +// -Xlog:help (or "VM.log list") +#define LOG_TAG_SET_DESCRIPTION_LIST \ + LOG_TAG_SET_DESCRIPTION(LOG_TAGS(logging), \ + "Logging for the log framework itself") + +#define LOG_TAG_SET_DESCRIPTION(tags, descr) \ + { &LogTagSetMapping::tagset(), descr }, + +struct LogTagSetDescription tagset_descriptions[] = { + LOG_TAG_SET_DESCRIPTION_LIST + { NULL, NULL } +}; diff --git a/hotspot/src/share/vm/logging/logTagSetDescriptions.hpp b/hotspot/src/share/vm/logging/logTagSetDescriptions.hpp new file mode 100644 index 00000000000..60e3660354d --- /dev/null +++ b/hotspot/src/share/vm/logging/logTagSetDescriptions.hpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +#ifndef SHARE_VM_LOGGING_LOGTAGSETDESCRIPTIONS_HPP +#define SHARE_VM_LOGGING_LOGTAGSETDESCRIPTIONS_HPP + +class LogTagSet; + +struct LogTagSetDescription { + const LogTagSet* tagset; + const char* descr; +}; + +extern struct LogTagSetDescription tagset_descriptions[]; + +#endif // SHARE_VM_LOGGING_LOGTAGSETDESCRIPTIONS_HPP diff --git a/hotspot/src/share/vm/utilities/internalVMTests.cpp b/hotspot/src/share/vm/utilities/internalVMTests.cpp index 45b90094bd6..c6543b71cab 100644 --- a/hotspot/src/share/vm/utilities/internalVMTests.cpp +++ b/hotspot/src/share/vm/utilities/internalVMTests.cpp @@ -78,6 +78,7 @@ void InternalVMTests::run() { run_unit_test(Test_log_prefix); run_unit_test(Test_log_big); run_unit_test(Test_logtagset_duplicates); + run_unit_test(Test_logtagset_descriptions); run_unit_test(Test_log_file_startup_rotation); run_unit_test(Test_log_file_startup_truncation); run_unit_test(Test_invalid_log_file); -- GitLab From 2b537997028e109dc2360264ffb05d327a472e32 Mon Sep 17 00:00:00 2001 From: Kirill Zhaldybin Date: Wed, 11 May 2016 18:49:29 +0300 Subject: [PATCH 331/400] 8156763: Quarantine gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java Reviewed-by: jprovino, tschatzl --- .../objectGraphTest/TestObjectGraphAfterGC.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java index ce834774333..53c58b49c09 100644 --- a/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java +++ b/hotspot/test/gc/g1/humongousObjects/objectGraphTest/TestObjectGraphAfterGC.java @@ -59,6 +59,9 @@ import java.util.stream.Collectors; * gc.g1.humongousObjects.objectGraphTest.GC * gc.g1.humongousObjects.objectGraphTest.ObjectGraph * gc.g1.humongousObjects.objectGraphTest.TestObjectGraphAfterGC + * + * @ignore 8156755 + * * @run driver ClassFileInstaller sun.hotspot.WhiteBox * sun.hotspot.WhiteBox$WhiteBoxPermission * -- GitLab From 87861c61e1d1e423bb1d7c86f381666a3c8159f2 Mon Sep 17 00:00:00 2001 From: Pavel Punegov Date: Wed, 11 May 2016 20:06:38 +0300 Subject: [PATCH 332/400] 8150247: CompilerControl: LogCompilation testing Add a test for standalone LogCompilation testing Reviewed-by: kvn --- .../logcompilation/LogTest.java | 53 +++++++++++++++++++ .../share/processors/LogProcessor.java | 28 +++++----- .../share/scenario/Scenario.java | 16 ++++++ 3 files changed, 85 insertions(+), 12 deletions(-) create mode 100644 hotspot/test/compiler/compilercontrol/logcompilation/LogTest.java diff --git a/hotspot/test/compiler/compilercontrol/logcompilation/LogTest.java b/hotspot/test/compiler/compilercontrol/logcompilation/LogTest.java new file mode 100644 index 00000000000..001251c4315 --- /dev/null +++ b/hotspot/test/compiler/compilercontrol/logcompilation/LogTest.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8137167 + * @summary Tests LogCompilation executed standalone without log commands or directives + * @modules java.base/jdk.internal.misc + * @library /testlibrary /test/lib /compiler/testlibrary ../share / + * @build compiler.compilercontrol.logcompilation.LogTest + * pool.sub.* pool.subpack.* sun.hotspot.WhiteBox + * compiler.testlibrary.CompilerUtils compiler.compilercontrol.share.actions.* + * @run driver ClassFileInstaller sun.hotspot.WhiteBox + * sun.hotspot.WhiteBox$WhiteBoxPermission + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:+UnlockDiagnosticVMOptions compiler.compilercontrol.logcompilation.LogTest + */ + +package compiler.compilercontrol.logcompilation; + +import compiler.compilercontrol.share.processors.LogProcessor; +import compiler.compilercontrol.share.scenario.Scenario; + +public class LogTest { + public static void main(String[] args) { + Scenario.Builder builder = Scenario.getBuilder(); + builder.addFlag("-XX:+UnlockDiagnosticVMOptions"); + builder.addFlag("-XX:+LogCompilation"); + builder.addFlag("-XX:LogFile=" + LogProcessor.LOG_FILE); + Scenario scenario = builder.build(); + scenario.execute(); + } +} diff --git a/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java b/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java index a1acd0d907c..d921d1d2304 100644 --- a/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java +++ b/hotspot/test/compiler/compilercontrol/share/processors/LogProcessor.java @@ -28,7 +28,6 @@ import compiler.compilercontrol.share.method.MethodGenerator; import compiler.compilercontrol.share.scenario.State; import jdk.test.lib.Asserts; import jdk.test.lib.OutputAnalyzer; -import jdk.test.lib.Pair; import pool.PoolHelper; import java.io.File; @@ -55,18 +54,17 @@ public class LogProcessor implements Consumer { "method='([^']+)'"); private final List loggedMethods; private final List testMethods; - private Scanner scanner = null; public LogProcessor(Map states) { loggedMethods = states.keySet().stream() .filter(x -> states.get(x).isLog()) - .map(MethodGenerator::logDescriptor) + .map(MethodGenerator::commandDescriptor) .map(MethodDescriptor::getString) .collect(Collectors.toList()); testMethods = new PoolHelper().getAllMethods() .stream() .map(pair -> pair.first) - .map(MethodGenerator::logDescriptor) + .map(MethodGenerator::commandDescriptor) .map(MethodDescriptor::getString) .collect(Collectors.toList()); } @@ -76,8 +74,7 @@ public class LogProcessor implements Consumer { if (loggedMethods.isEmpty()) { return; } - getScanner(); - matchTasks(); + matchTasks(getScanner()); } /* @@ -85,6 +82,7 @@ public class LogProcessor implements Consumer { */ private Scanner getScanner() { File logFile = new File(LOG_FILE); + Scanner scanner; try { scanner = new Scanner(logFile); } catch (FileNotFoundException e) { @@ -97,29 +95,35 @@ public class LogProcessor implements Consumer { * Parses for <task method='java.lang.String indexOf (I)I' > * and finds if there is a compilation log for this task */ - private void matchTasks() { + private void matchTasks(Scanner scanner) { String task = scanner.findWithinHorizon(TASK_ELEMENT, 0); while (task != null) { String element = scanner.findWithinHorizon(ANY_ELEMENT, 0); if (Pattern.matches(TASK_DONE_ELEMENT, element) || Pattern.matches(TASK_END_ELEMENT, element)) { /* If there is nothing between and - except then compilation log is empty */ - Asserts.assertTrue(matchMethod(task), "Compilation log " + except then compilation log is empty. + Check the method in this task should not be logged */ + Asserts.assertFalse(matchMethod(task), "Compilation log " + "expected. Met: " + element); } task = scanner.findWithinHorizon(TASK_ELEMENT, 0); } } - // Matches given string to regular expression + // Check that input method should be logged private boolean matchMethod(String input) { Matcher matcher = METHOD_PATTERN.matcher(input); Asserts.assertTrue(matcher.find(), "Wrong matcher or input"); // Get method and normalize it String method = normalize(matcher.group(1)); - // Check that this method matches regexp - return loggedMethods.contains(method) || !testMethods.contains(method); + if (loggedMethods.contains(method)) { + return true; + } + if (!testMethods.contains(method)) { + return false; + } + return false; } // Normalize given signature to conform regular expression used in tests diff --git a/hotspot/test/compiler/compilercontrol/share/scenario/Scenario.java b/hotspot/test/compiler/compilercontrol/share/scenario/Scenario.java index 505f36e7272..a0fefabac60 100644 --- a/hotspot/test/compiler/compilercontrol/share/scenario/Scenario.java +++ b/hotspot/test/compiler/compilercontrol/share/scenario/Scenario.java @@ -198,6 +198,7 @@ public final class Scenario { = new HashMap<>(); private final JcmdStateBuilder jcmdStateBuilder; private final List jcmdCommands = new ArrayList<>(); + private boolean logCommandMet = false; public Builder() { addFlag("-Xmixed"); @@ -215,6 +216,9 @@ public final class Scenario { public void add(CompileCommand compileCommand) { String[] vmOptions = compileCommand.command.vmOpts; Collections.addAll(vmopts, vmOptions); + if (compileCommand.command == Command.LOG) { + logCommandMet = true; + } if (compileCommand.type == Type.JCMD) { jcmdStateBuilder.add((JcmdCommand) compileCommand); jcmdCommands.add((JcmdCommand) compileCommand); @@ -294,6 +298,18 @@ public final class Scenario { isValid &= builder.isValid(); } options.addAll(jcmdStateBuilder.getOptions()); + + /* + * Update final states if LogCompilation is enabled and + * there is no any log command, then all methods should be logged + */ + boolean isLogComp = vmopts.stream() + .anyMatch(opt -> opt.contains("-XX:+LogCompilation")); + if (isLogComp && !logCommandMet) { + finalStates.entrySet() + .forEach(entry -> entry.getValue().setLog(true)); + } + return new Scenario(isValid, options, finalStates, ccList, jcmdCommands, directives); } -- GitLab From baca9fb3f6d38817ca65b2f5221e268773648268 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Wed, 11 May 2016 12:19:59 -0700 Subject: [PATCH 333/400] 8156789: missing condition in ClassPathZipEntry::open_versioned_entry() Added back the !_is_boot_append condition Reviewed-by: hseigel, jiangli --- hotspot/src/share/vm/classfile/classLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 58ad06fc9bc..d77aef277eb 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -320,7 +320,7 @@ u1* ClassPathZipEntry::open_entry(const char* name, jint* filesize, bool nul_ter #if INCLUDE_CDS u1* ClassPathZipEntry::open_versioned_entry(const char* name, jint* filesize, TRAPS) { u1* buffer = NULL; - if (DumpSharedSpaces) { + if (DumpSharedSpaces && !_is_boot_append) { // We presume default is multi-release enabled const char* multi_ver = Arguments::get_property("jdk.util.jar.enableMultiRelease"); const char* verstr = Arguments::get_property("jdk.util.jar.version"); -- GitLab From bff0e66d94c048b2d136edbf8a25d6cf100ccfa6 Mon Sep 17 00:00:00 2001 From: Andrew Haley Date: Wed, 11 May 2016 20:10:03 -0400 Subject: [PATCH 334/400] 8155627: Enable SA on AArch64 Reviewed-by: roland, dholmes --- .../sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java index 558117e30ca..80b6c79e608 100644 --- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java +++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/aarch64/AARCH64Frame.java @@ -49,11 +49,12 @@ public class AARCH64Frame extends Frame { private static final int SENDER_SP_OFFSET = 2; // Interpreter frames - private static final int INTERPRETER_FRAME_MIRROR_OFFSET = 2; // for native calls only private static final int INTERPRETER_FRAME_SENDER_SP_OFFSET = -1; private static final int INTERPRETER_FRAME_LAST_SP_OFFSET = INTERPRETER_FRAME_SENDER_SP_OFFSET - 1; private static final int INTERPRETER_FRAME_METHOD_OFFSET = INTERPRETER_FRAME_LAST_SP_OFFSET - 1; private static int INTERPRETER_FRAME_MDX_OFFSET; // Non-core builds only + private static int INTERPRETER_FRAME_PADDING_OFFSET; + private static int INTERPRETER_FRAME_MIRROR_OFFSET; private static int INTERPRETER_FRAME_CACHE_OFFSET; private static int INTERPRETER_FRAME_LOCALS_OFFSET; private static int INTERPRETER_FRAME_BCX_OFFSET; @@ -79,7 +80,9 @@ public class AARCH64Frame extends Frame { private static synchronized void initialize(TypeDataBase db) { INTERPRETER_FRAME_MDX_OFFSET = INTERPRETER_FRAME_METHOD_OFFSET - 1; - INTERPRETER_FRAME_CACHE_OFFSET = INTERPRETER_FRAME_MDX_OFFSET - 1; + INTERPRETER_FRAME_PADDING_OFFSET = INTERPRETER_FRAME_MDX_OFFSET - 1; + INTERPRETER_FRAME_MIRROR_OFFSET = INTERPRETER_FRAME_PADDING_OFFSET - 1; + INTERPRETER_FRAME_CACHE_OFFSET = INTERPRETER_FRAME_MIRROR_OFFSET - 1; INTERPRETER_FRAME_LOCALS_OFFSET = INTERPRETER_FRAME_CACHE_OFFSET - 1; INTERPRETER_FRAME_BCX_OFFSET = INTERPRETER_FRAME_LOCALS_OFFSET - 1; INTERPRETER_FRAME_INITIAL_SP_OFFSET = INTERPRETER_FRAME_BCX_OFFSET - 1; -- GitLab From cddb3b11ef2eafc7646dd832bbdafd79c54de4b5 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Thu, 12 May 2016 17:47:45 +0300 Subject: [PATCH 335/400] 8156769: gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java fails with java.lang.Exception Update test to use jhsdb instead of jmap Reviewed-by: sla --- .../gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java b/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java index da322a6d0c7..ebe90eebae0 100644 --- a/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java +++ b/hotspot/test/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java @@ -51,8 +51,10 @@ public class CompressedClassSpaceSizeInJmapHeap { String pid = Long.toString(ProcessTools.getProcessId()); - JDKToolLauncher jmap = JDKToolLauncher.create("jmap") - .addToolArg("-heap") + JDKToolLauncher jmap = JDKToolLauncher.create("jhsdb") + .addToolArg("jmap") + .addToolArg("--heap") + .addToolArg("--pid") .addToolArg(pid); ProcessBuilder pb = new ProcessBuilder(jmap.getCommand()); -- GitLab From 24fae493243b55c6bd204a08fe7ed3f403be6a66 Mon Sep 17 00:00:00 2001 From: Joseph Provino Date: Thu, 12 May 2016 11:54:03 -0400 Subject: [PATCH 336/400] 8156851: Compilation error compiling XpatchDupModule.java and XpatchDupJavaBase.java Test needs @modules java.base/jdk.internal.misc Reviewed-by: jwilhelm, drwhite --- hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java | 1 + hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java | 1 + 2 files changed, 2 insertions(+) diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java b/hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java index 93935df3ce4..69448a62796 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java +++ b/hotspot/test/runtime/modules/Xpatch/XpatchDupJavaBase.java @@ -24,6 +24,7 @@ /* * @test * @summary VM exit initialization results if java.base is specificed more than once to Xpatch. + * @modules java.base/jdk.internal.misc * @library /testlibrary */ diff --git a/hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java b/hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java index 2a44b97932b..9fcffa4157a 100644 --- a/hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java +++ b/hotspot/test/runtime/modules/Xpatch/XpatchDupModule.java @@ -24,6 +24,7 @@ /* * @test * @summary Module system initialization exception results if a module is specificed twice to Xpatch. + * @modules java.base/jdk.internal.misc * @library /testlibrary */ -- GitLab From db0f9f020b0e272ce94a3507ffd8ee128a45d50a Mon Sep 17 00:00:00 2001 From: Jon Masamitsu Date: Fri, 13 May 2016 12:36:03 -0700 Subject: [PATCH 337/400] 8156867: Simplify/reduce testing in ParallelCompact_test Reviewed-by: jwilhelm, jprovino --- hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp index f7d1615c814..d16e510a5f5 100644 --- a/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp +++ b/hotspot/src/share/vm/gc/parallel/psParallelCompact.cpp @@ -394,13 +394,6 @@ void ParallelCompact_test() { HeapWord* end_heap = (HeapWord*) heap->young_gen()->virtual_space()->high_boundary(); - size_t end_index = - PSParallelCompact::summary_data().addr_to_region_idx(end_heap); - ParallelCompactData::RegionData* c = PSParallelCompact::summary_data().region(end_index); - - // Initialize the end region with a bad destination. - c->set_destination(begin_heap - 1); - print_generic_summary_data(PSParallelCompact::summary_data(), begin_heap, end_heap); } -- GitLab From 6be4410a0e71056959809142bdf4a6b538d9ea7b Mon Sep 17 00:00:00 2001 From: Joseph Provino Date: Fri, 13 May 2016 15:57:17 -0400 Subject: [PATCH 338/400] 8156964: gc/logging/TestUnifiedLoggingSwitchStress.java hits assert Old debug code needs to be removed. Reviewed-by: stefank, jwilhelm --- hotspot/src/share/vm/gc/parallel/psScavenge.inline.hpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/hotspot/src/share/vm/gc/parallel/psScavenge.inline.hpp b/hotspot/src/share/vm/gc/parallel/psScavenge.inline.hpp index f7e98688277..a944277d00f 100644 --- a/hotspot/src/share/vm/gc/parallel/psScavenge.inline.hpp +++ b/hotspot/src/share/vm/gc/parallel/psScavenge.inline.hpp @@ -140,12 +140,6 @@ class PSScavengeKlassClosure: public KlassClosure { // If the klass has not been dirtied we know that there's // no references into the young gen and we can skip it. - NOT_PRODUCT(ResourceMark rm); - log_develop_trace(gc, scavenge)("PSScavengeKlassClosure::do_klass " PTR_FORMAT ", %s, dirty: %s", - p2i(klass), - klass->external_name(), - klass->has_modified_oops() ? "true" : "false"); - if (klass->has_modified_oops()) { // Clean the klass since we're going to scavenge all the metadata. klass->clear_modified_oops(); -- GitLab From bde74b92a08f377a41246926289560a835f0e3cd Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 18 May 2016 15:04:39 +0530 Subject: [PATCH 339/400] 8154192: Deprivilege java.scripting module Reviewed-by: jlaskey, alanb --- make/common/Modules.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk index ba1f82e5d5b..fa5aa54e6fc 100644 --- a/make/common/Modules.gmk +++ b/make/common/Modules.gmk @@ -72,7 +72,6 @@ BOOT_MODULES += \ # to be deprivileged BOOT_MODULES += \ - java.scripting \ java.sql.rowset \ java.smartcardio \ jdk.naming.rmi \ @@ -102,6 +101,7 @@ PLATFORM_MODULES += \ PLATFORM_MODULES += \ java.compiler \ + java.scripting \ jdk.accessibility \ jdk.charsets \ jdk.crypto.ec \ -- GitLab From a2ce513fbdcb9a8d64361fb8eee86d78fe32e29a Mon Sep 17 00:00:00 2001 From: Erik Helin Date: Mon, 16 May 2016 12:33:22 +0200 Subject: [PATCH 340/400] 8157028: Add make target for running gtest tests Reviewed-by: erikj, jwilhelm --- make/Main.gmk | 17 +++++++++++------ make/MainSupport.gmk | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/make/Main.gmk b/make/Main.gmk index 823c0ad16d3..29a9de44b2d 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -433,25 +433,28 @@ ALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \ # Run tests specified by $(TEST), or the default test set. test: - $(call RunTests, $(TEST)) + $(call RunTests, $(TEST), $(JDK_IMAGE_DIR)) test-hotspot-jtreg: - $(call RunTests, "hotspot_all") + $(call RunTests, "hotspot_all", $(JDK_IMAGE_DIR)) test-hotspot-jtreg-native: - $(call RunTests, "hotspot_native_sanity") + $(call RunTests, "hotspot_native_sanity", $(JDK_IMAGE_DIR)) test-hotspot-internal: - $(call RunTests, "hotspot_internal") + $(call RunTests, "hotspot_internal", $(JDK_OUTPUTDIR)) + +test-hotspot-gtest: + $(call RunTests, "hotspot_gtest", $(JDK_OUTPUTDIR)) test-jdk-jtreg-native: - $(call RunTests, "jdk_native_sanity") + $(call RunTests, "jdk_native_sanity", $(JDK_IMAGE_DIR)) test-make: ($(CD) $(SRC_ROOT)/test/make && $(MAKE) $(MAKE_ARGS) -f TestMake.gmk $(TEST_TARGET)) ALL_TARGETS += test test-hotspot-jtreg test-hotspot-jtreg-native \ - test-hotspot-internal test-jdk-jtreg-native test-make + test-hotspot-internal test-hotspot-gtest test-jdk-jtreg-native test-make ################################################################################ # Bundles @@ -690,6 +693,8 @@ else test-hotspot-jtreg: jimages test-image + test-hotspot-gtest: exploded-image test-image-hotspot-gtest + install: product-images product-bundles: product-images diff --git a/make/MainSupport.gmk b/make/MainSupport.gmk index d09331a0962..7683cfeb2af 100644 --- a/make/MainSupport.gmk +++ b/make/MainSupport.gmk @@ -30,10 +30,10 @@ ifndef _MAINSUPPORT_GMK _MAINSUPPORT_GMK := 1 -# Run the tests specified by $1. +# Run the tests specified by $1, with PRODUCT_HOME specified by $2 define RunTests ($(CD) $(SRC_ROOT)/test && $(MAKE) $(MAKE_ARGS) -j1 -k MAKEFLAGS= \ - JT_HOME=$(JT_HOME) PRODUCT_HOME=$(JDK_IMAGE_DIR) \ + JT_HOME=$(JT_HOME) PRODUCT_HOME=$(strip $2) \ TEST_IMAGE_DIR=$(TEST_IMAGE_DIR) \ ALT_OUTPUTDIR=$(OUTPUT_ROOT) TEST_JOBS=$(TEST_JOBS) \ JOBS=$(JOBS) $1) || true -- GitLab From e84506041e876f31269ec20fee960cc0d14d68ab Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Tue, 17 May 2016 03:26:07 -0400 Subject: [PATCH 341/400] 8156929: [aix] Add missing includes Reviewed-by: coleenp, dholmes --- hotspot/src/share/vm/gc/g1/g1HeapSizingPolicy_ext.cpp | 1 + hotspot/src/share/vm/runtime/mutex.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/hotspot/src/share/vm/gc/g1/g1HeapSizingPolicy_ext.cpp b/hotspot/src/share/vm/gc/g1/g1HeapSizingPolicy_ext.cpp index 48432568cc0..ec597f7a2cd 100644 --- a/hotspot/src/share/vm/gc/g1/g1HeapSizingPolicy_ext.cpp +++ b/hotspot/src/share/vm/gc/g1/g1HeapSizingPolicy_ext.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "gc/g1/g1HeapSizingPolicy.hpp" +#include "memory/allocation.inline.hpp" G1HeapSizingPolicy* G1HeapSizingPolicy::create(const G1CollectedHeap* g1, const G1Analytics* analytics) { return new G1HeapSizingPolicy(g1, analytics); diff --git a/hotspot/src/share/vm/runtime/mutex.cpp b/hotspot/src/share/vm/runtime/mutex.cpp index ef6ac43b5d6..a065fb13db2 100644 --- a/hotspot/src/share/vm/runtime/mutex.cpp +++ b/hotspot/src/share/vm/runtime/mutex.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "runtime/atomic.inline.hpp" +#include "runtime/interfaceSupport.hpp" #include "runtime/mutex.hpp" #include "runtime/orderAccess.inline.hpp" #include "runtime/osThread.hpp" -- GitLab From 178842d251e2565b84b2373687b2945c6842017a Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Tue, 17 May 2016 08:51:05 -0400 Subject: [PATCH 342/400] 8155951: VM crash in nsk/jvmti/RedefineClasses/StressRedefine: assert failed: Corrupted constant pool 8151066: assert(0 <= i && i < length()) failed: index out of bounds Lock classes for redefinition because constant pool merging isn't thread safe, use method constant pool because constant pool merging doesn't make equivalent cpCaches because of invokedynamic Reviewed-by: sspitsyn, dholmes --- hotspot/src/share/vm/ci/ciStreams.cpp | 9 +-- hotspot/src/share/vm/ci/ciStreams.hpp | 4 +- hotspot/src/share/vm/oops/instanceKlass.hpp | 5 ++ .../share/vm/prims/jvmtiRedefineClasses.cpp | 73 ++++++++++++++----- .../share/vm/prims/jvmtiRedefineClasses.hpp | 6 +- hotspot/src/share/vm/runtime/mutexLocker.cpp | 2 + hotspot/src/share/vm/runtime/mutexLocker.hpp | 1 + 7 files changed, 75 insertions(+), 25 deletions(-) diff --git a/hotspot/src/share/vm/ci/ciStreams.cpp b/hotspot/src/share/vm/ci/ciStreams.cpp index 76520fdff10..a4eaf473984 100644 --- a/hotspot/src/share/vm/ci/ciStreams.cpp +++ b/hotspot/src/share/vm/ci/ciStreams.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -361,14 +361,14 @@ int ciBytecodeStream::get_method_index() { ciMethod* ciBytecodeStream::get_method(bool& will_link, ciSignature* *declared_signature_result) { VM_ENTRY_MARK; ciEnv* env = CURRENT_ENV; - constantPoolHandle cpool(_method->get_Method()->constants()); + constantPoolHandle cpool(THREAD, _method->get_Method()->constants()); ciMethod* m = env->get_method_by_index(cpool, get_method_index(), cur_bc(), _holder); will_link = m->is_loaded(); // Use the MethodType stored in the CP cache to create a signature // with correct types (in respect to class loaders). if (has_method_type()) { - ciSymbol* sig_sym = env->get_symbol(cpool->symbol_at(get_method_signature_index())); + ciSymbol* sig_sym = env->get_symbol(cpool->symbol_at(get_method_signature_index(cpool))); ciKlass* pool_holder = env->get_klass(cpool->pool_holder()); ciMethodType* method_type = get_method_type(); ciSignature* declared_signature = new (env->arena()) ciSignature(pool_holder, sig_sym, method_type); @@ -465,9 +465,8 @@ int ciBytecodeStream::get_method_holder_index() { // Get the constant pool index of the signature of the method // referenced by the current bytecode. Used for generating // deoptimization information. -int ciBytecodeStream::get_method_signature_index() { +int ciBytecodeStream::get_method_signature_index(const constantPoolHandle& cpool) { GUARDED_VM_ENTRY( - ConstantPool* cpool = _holder->get_instanceKlass()->constants(); const int method_index = get_method_index(); const int name_and_type_index = cpool->name_and_type_ref_index_at(method_index); return cpool->signature_ref_index_at(name_and_type_index); diff --git a/hotspot/src/share/vm/ci/ciStreams.hpp b/hotspot/src/share/vm/ci/ciStreams.hpp index 091aa1bdf53..07e573b5963 100644 --- a/hotspot/src/share/vm/ci/ciStreams.hpp +++ b/hotspot/src/share/vm/ci/ciStreams.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -264,7 +264,7 @@ public: ciMethodType* get_method_type(); ciKlass* get_declared_method_holder(); int get_method_holder_index(); - int get_method_signature_index(); + int get_method_signature_index(const constantPoolHandle& cpool); // Get the resolved references arrays from the constant pool ciObjArray* get_resolved_references(); diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 125060bd80b..494173b3ded 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -190,6 +190,7 @@ class InstanceKlass: public Klass { // _is_marked_dependent can be set concurrently, thus cannot be part of the // _misc_flags. bool _is_marked_dependent; // used for marking during flushing and deoptimization + bool _is_being_redefined; // used for locking redefinition // The low two bits of _misc_flags contains the kind field. // This can be used to quickly discriminate among the four kinds of @@ -694,6 +695,10 @@ class InstanceKlass: public Klass { } #if INCLUDE_JVMTI + // Redefinition locking. Class can only be redefined by one thread at a time. + bool is_being_redefined() const { return _is_being_redefined; } + void set_is_being_redefined(bool value) { _is_being_redefined = value; } + // RedefineClasses() support for previous versions: void add_previous_version(instanceKlassHandle ikh, int emcp_method_count); diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp index 185270bf5f3..f173e570dce 100644 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp @@ -69,6 +69,43 @@ VM_RedefineClasses::VM_RedefineClasses(jint class_count, _res = JVMTI_ERROR_NONE; } +static inline InstanceKlass* get_ik(jclass def) { + oop mirror = JNIHandles::resolve_non_null(def); + return InstanceKlass::cast(java_lang_Class::as_Klass(mirror)); +} + +// If any of the classes are being redefined, wait +// Parallel constant pool merging leads to indeterminate constant pools. +void VM_RedefineClasses::lock_classes() { + MutexLocker ml(RedefineClasses_lock); + bool has_redefined; + do { + has_redefined = false; + // Go through classes each time until none are being redefined. + for (int i = 0; i < _class_count; i++) { + if (get_ik(_class_defs[i].klass)->is_being_redefined()) { + RedefineClasses_lock->wait(); + has_redefined = true; + break; // for loop + } + } + } while (has_redefined); + for (int i = 0; i < _class_count; i++) { + get_ik(_class_defs[i].klass)->set_is_being_redefined(true); + } + RedefineClasses_lock->notify_all(); +} + +void VM_RedefineClasses::unlock_classes() { + MutexLocker ml(RedefineClasses_lock); + for (int i = 0; i < _class_count; i++) { + assert(get_ik(_class_defs[i].klass)->is_being_redefined(), + "should be being redefined to get here"); + get_ik(_class_defs[i].klass)->set_is_being_redefined(false); + } + RedefineClasses_lock->notify_all(); +} + bool VM_RedefineClasses::doit_prologue() { if (_class_count == 0) { _res = JVMTI_ERROR_NONE; @@ -91,6 +128,14 @@ bool VM_RedefineClasses::doit_prologue() { _res = JVMTI_ERROR_NULL_POINTER; return false; } + + oop mirror = JNIHandles::resolve_non_null(_class_defs[i].klass); + // classes for primitives and arrays cannot be redefined + // check here so following code can assume these classes are InstanceKlass + if (!is_modifiable_class(mirror)) { + _res = JVMTI_ERROR_UNMODIFIABLE_CLASS; + return false; + } } // Start timer after all the sanity checks; not quite accurate, but @@ -99,6 +144,7 @@ bool VM_RedefineClasses::doit_prologue() { _timer_vm_op_prologue.start(); } + lock_classes(); // We first load new class versions in the prologue, because somewhere down the // call chain it is required that the current thread is a Java thread. _res = load_new_class_versions(Thread::current()); @@ -115,6 +161,7 @@ bool VM_RedefineClasses::doit_prologue() { // Free os::malloc allocated memory in load_new_class_version. os::free(_scratch_classes); _timer_vm_op_prologue.stop(); + unlock_classes(); return false; } @@ -174,6 +221,8 @@ void VM_RedefineClasses::doit() { } void VM_RedefineClasses::doit_epilogue() { + unlock_classes(); + // Free os::malloc allocated memory. os::free(_scratch_classes); @@ -959,14 +1008,7 @@ jvmtiError VM_RedefineClasses::load_new_class_versions(TRAPS) { // versions are deleted. Constant pools are deallocated while merging // constant pools HandleMark hm(THREAD); - - oop mirror = JNIHandles::resolve_non_null(_class_defs[i].klass); - // classes for primitives cannot be redefined - if (!is_modifiable_class(mirror)) { - return JVMTI_ERROR_UNMODIFIABLE_CLASS; - } - Klass* the_class_oop = java_lang_Class::as_Klass(mirror); - instanceKlassHandle the_class = instanceKlassHandle(THREAD, the_class_oop); + instanceKlassHandle the_class(THREAD, get_ik(_class_defs[i].klass)); Symbol* the_class_sym = the_class->name(); log_debug(redefine, class, load) @@ -3757,22 +3799,19 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass, _timer_rsc_phase1.start(); } - instanceKlassHandle scratch_class(scratch_class_oop); - - oop the_class_mirror = JNIHandles::resolve_non_null(the_jclass); - Klass* the_class_oop = java_lang_Class::as_Klass(the_class_mirror); - instanceKlassHandle the_class = instanceKlassHandle(THREAD, the_class_oop); + instanceKlassHandle scratch_class(THREAD, scratch_class_oop); + instanceKlassHandle the_class(THREAD, get_ik(the_jclass)); // Remove all breakpoints in methods of this class JvmtiBreakpoints& jvmti_breakpoints = JvmtiCurrentBreakpoints::get_jvmti_breakpoints(); - jvmti_breakpoints.clearall_in_class_at_safepoint(the_class_oop); + jvmti_breakpoints.clearall_in_class_at_safepoint(the_class()); // Deoptimize all compiled code that depends on this class flush_dependent_code(the_class, THREAD); _old_methods = the_class->methods(); _new_methods = scratch_class->methods(); - _the_class_oop = the_class_oop; + _the_class_oop = the_class(); compute_added_deleted_matching_methods(); update_jmethod_ids(); @@ -4002,10 +4041,10 @@ void VM_RedefineClasses::redefine_single_class(jclass the_jclass, increment_class_counter((InstanceKlass *)the_class(), THREAD); log_info(redefine, class, load) ("redefined name=%s, count=%d (avail_mem=" UINT64_FORMAT "K)", - the_class->external_name(), java_lang_Class::classRedefinedCount(the_class_mirror), os::available_memory() >> 10); + the_class->external_name(), java_lang_Class::classRedefinedCount(the_class->java_mirror()), os::available_memory() >> 10); Events::log_redefinition(THREAD, "redefined class name=%s, count=%d", the_class->external_name(), - java_lang_Class::classRedefinedCount(the_class_mirror)); + java_lang_Class::classRedefinedCount(the_class->java_mirror())); } _timer_rsc_phase2.stop(); diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp index ffeebfb5754..edba3dd51a0 100644 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -489,6 +489,10 @@ class VM_RedefineClasses: public VM_Operation { void flush_dependent_code(instanceKlassHandle k_h, TRAPS); + // lock classes to redefine since constant pool merging isn't thread safe. + void lock_classes(); + void unlock_classes(); + static void dump_methods(); // Check that there are no old or obsolete methods diff --git a/hotspot/src/share/vm/runtime/mutexLocker.cpp b/hotspot/src/share/vm/runtime/mutexLocker.cpp index 1a3767c003c..219194a4b21 100644 --- a/hotspot/src/share/vm/runtime/mutexLocker.cpp +++ b/hotspot/src/share/vm/runtime/mutexLocker.cpp @@ -120,6 +120,7 @@ Monitor* GCTaskManager_lock = NULL; Mutex* Management_lock = NULL; Monitor* Service_lock = NULL; Monitor* PeriodicTask_lock = NULL; +Monitor* RedefineClasses_lock = NULL; #ifdef INCLUDE_TRACE Mutex* JfrStacktrace_lock = NULL; @@ -264,6 +265,7 @@ void mutex_init() { def(Debug3_lock , Mutex , nonleaf+4, true, Monitor::_safepoint_check_never); def(CompileThread_lock , Monitor, nonleaf+5, false, Monitor::_safepoint_check_always); def(PeriodicTask_lock , Monitor, nonleaf+5, true, Monitor::_safepoint_check_sometimes); + def(RedefineClasses_lock , Monitor, nonleaf+5, true, Monitor::_safepoint_check_always); if (WhiteBoxAPI) { def(Compilation_lock , Monitor, leaf, false, Monitor::_safepoint_check_never); } diff --git a/hotspot/src/share/vm/runtime/mutexLocker.hpp b/hotspot/src/share/vm/runtime/mutexLocker.hpp index 014ffb28218..ae4c79954ea 100644 --- a/hotspot/src/share/vm/runtime/mutexLocker.hpp +++ b/hotspot/src/share/vm/runtime/mutexLocker.hpp @@ -121,6 +121,7 @@ extern Mutex* MMUTracker_lock; // protects the MMU extern Mutex* Management_lock; // a lock used to serialize JVM management extern Monitor* Service_lock; // a lock used for service thread operation extern Monitor* PeriodicTask_lock; // protects the periodic task structure +extern Monitor* RedefineClasses_lock; // locks classes from parallel redefinition #ifdef INCLUDE_TRACE extern Mutex* JfrStacktrace_lock; // used to guard access to the JFR stacktrace table -- GitLab From 100d77bf15634756e629b0b10b5c0bd4957cc899 Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Tue, 17 May 2016 11:39:38 -0400 Subject: [PATCH 343/400] 8156882: Remove hotspot/test/testlibrary/whitebox Reviewed-by: coleenp, mockner, dfazunen, iignatyev --- .../whitebox/sun/hotspot/WhiteBox.java | 264 ------------------ 1 file changed, 264 deletions(-) delete mode 100644 hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java diff --git a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java b/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java deleted file mode 100644 index 367e46965c0..00000000000 --- a/hotspot/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.hotspot; - -import java.lang.reflect.Executable; -import java.util.Arrays; -import java.util.List; -import java.util.function.Function; -import java.util.stream.Stream; -import java.security.BasicPermission; - -import sun.hotspot.parser.DiagnosticCommand; - -public class WhiteBox { - - @SuppressWarnings("serial") - public static class WhiteBoxPermission extends BasicPermission { - public WhiteBoxPermission(String s) { - super(s); - } - } - - private WhiteBox() {} - private static final WhiteBox instance = new WhiteBox(); - private static native void registerNatives(); - - /** - * Returns the singleton WhiteBox instance. - * - * The returned WhiteBox object should be carefully guarded - * by the caller, since it can be used to read and write data - * at arbitrary memory addresses. It must never be passed to - * untrusted code. - */ - public synchronized static WhiteBox getWhiteBox() { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission(new WhiteBoxPermission("getInstance")); - } - return instance; - } - - static { - registerNatives(); - } - - // Get the maximum heap size supporting COOPs - public native long getCompressedOopsMaxHeapSize(); - // Arguments - public native void printHeapSizes(); - - // Memory - public native long getObjectAddress(Object o); - public native int getHeapOopSize(); - public native int getVMPageSize(); - public native boolean isObjectInOldGen(Object o); - public native long getObjectSize(Object o); - - // Runtime - // Make sure class name is in the correct format - public boolean isClassAlive(String name) { - return isClassAlive0(name.replace('.', '/')); - } - private native boolean isClassAlive0(String name); - - // JVMTI - public native void addToBootstrapClassLoaderSearch(String segment); - public native void addToSystemClassLoaderSearch(String segment); - - // G1 - public native boolean g1InConcurrentMark(); - public native boolean g1IsHumongous(Object o); - public native long g1NumFreeRegions(); - public native int g1RegionSize(); - public native Object[] parseCommandLine(String commandline, char delim, DiagnosticCommand[] args); - - // NMT - public native long NMTMalloc(long size); - public native void NMTFree(long mem); - public native long NMTReserveMemory(long size); - public native void NMTCommitMemory(long addr, long size); - public native void NMTUncommitMemory(long addr, long size); - public native void NMTReleaseMemory(long addr, long size); - public native long NMTMallocWithPseudoStack(long size, int index); - public native boolean NMTIsDetailSupported(); - public native boolean NMTChangeTrackingLevel(); - public native int NMTGetHashSize(); - - // Compiler - public native void deoptimizeAll(); - public boolean isMethodCompiled(Executable method) { - return isMethodCompiled(method, false /*not osr*/); - } - public native boolean isMethodCompiled(Executable method, boolean isOsr); - public boolean isMethodCompilable(Executable method) { - return isMethodCompilable(method, -1 /*any*/); - } - public boolean isMethodCompilable(Executable method, int compLevel) { - return isMethodCompilable(method, compLevel, false /*not osr*/); - } - public native boolean isMethodCompilable(Executable method, int compLevel, boolean isOsr); - public native boolean isMethodQueuedForCompilation(Executable method); - public int deoptimizeMethod(Executable method) { - return deoptimizeMethod(method, false /*not osr*/); - } - public native int deoptimizeMethod(Executable method, boolean isOsr); - public void makeMethodNotCompilable(Executable method) { - makeMethodNotCompilable(method, -1 /*any*/); - } - public void makeMethodNotCompilable(Executable method, int compLevel) { - makeMethodNotCompilable(method, compLevel, false /*not osr*/); - } - public native void makeMethodNotCompilable(Executable method, int compLevel, boolean isOsr); - public int getMethodCompilationLevel(Executable method) { - return getMethodCompilationLevel(method, false /*not ost*/); - } - public native int getMethodCompilationLevel(Executable method, boolean isOsr); - public native boolean testSetDontInlineMethod(Executable method, boolean value); - public int getCompileQueuesSize() { - return getCompileQueueSize(-1 /*any*/); - } - public native int getCompileQueueSize(int compLevel); - public native boolean testSetForceInlineMethod(Executable method, boolean value); - public boolean enqueueMethodForCompilation(Executable method, int compLevel) { - return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/); - } - public native boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci); - public native void clearMethodState(Executable method); - public native void lockCompilation(); - public native void unlockCompilation(); - public native int getMethodEntryBci(Executable method); - public native Object[] getNMethod(Executable method, boolean isOsr); - public native long allocateCodeBlob(int size, int type); - public long allocateCodeBlob(long size, int type) { - int intSize = (int) size; - if ((long) intSize != size || size < 0) { - throw new IllegalArgumentException( - "size argument has illegal value " + size); - } - return allocateCodeBlob( intSize, type); - } - public native void freeCodeBlob(long addr); - public void forceNMethodSweep() { - try { - forceNMethodSweep0().join(); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - public native Thread forceNMethodSweep0(); - public native Object[] getCodeHeapEntries(int type); - public native int getCompilationActivityMode(); - public native Object[] getCodeBlob(long addr); - - // Intered strings - public native boolean isInStringTable(String str); - - // Memory - public native void readReservedMemory(); - public native long allocateMetaspace(ClassLoader classLoader, long size); - public native void freeMetaspace(ClassLoader classLoader, long addr, long size); - public native long incMetaspaceCapacityUntilGC(long increment); - public native long metaspaceCapacityUntilGC(); - - // Force Young GC - public native void youngGC(); - - // Force Full GC - public native void fullGC(); - - // Method tries to start concurrent mark cycle. - // It returns false if CM Thread is always in concurrent cycle. - public native boolean g1StartConcMarkCycle(); - - // Tests on ReservedSpace/VirtualSpace classes - public native int stressVirtualSpaceResize(long reservedSpaceSize, long magnitude, long iterations); - public native void runMemoryUnitTests(); - public native void readFromNoaccessArea(); - public native long getThreadStackSize(); - public native long getThreadRemainingStackSize(); - - // CPU features - public native String getCPUFeatures(); - - // Native extensions - public native long getHeapUsageForContext(int context); - public native long getHeapRegionCountForContext(int context); - public native int getContextForObject(Object obj); - public native void printRegionInfo(int context); - - // VM flags - public native boolean isConstantVMFlag(String name); - public native boolean isLockedVMFlag(String name); - public native void setBooleanVMFlag(String name, boolean value); - public native void setIntxVMFlag(String name, long value); - public native void setUintxVMFlag(String name, long value); - public native void setUint64VMFlag(String name, long value); - public native void setSizeTVMFlag(String name, long value); - public native void setStringVMFlag(String name, String value); - public native void setDoubleVMFlag(String name, double value); - public native Boolean getBooleanVMFlag(String name); - public native Long getIntxVMFlag(String name); - public native Long getUintxVMFlag(String name); - public native Long getUint64VMFlag(String name); - public native Long getSizeTVMFlag(String name); - public native String getStringVMFlag(String name); - public native Double getDoubleVMFlag(String name); - private final List> flagsGetters = Arrays.asList( - this::getBooleanVMFlag, this::getIntxVMFlag, this::getUintxVMFlag, - this::getUint64VMFlag, this::getSizeTVMFlag, this::getStringVMFlag, - this::getDoubleVMFlag); - - public Object getVMFlag(String name) { - return flagsGetters.stream() - .map(f -> f.apply(name)) - .filter(x -> x != null) - .findAny() - .orElse(null); - } - - // Jigsaw - public native Object DefineModule(String name, Object loader, Object[] packages); - public native void AddModuleExports(Object from_module, String pkg, Object to_module); - public native void AddReadsModule(Object from_module, Object to_module); - public native boolean CanReadModule(Object asking_module, Object target_module); - public native boolean IsExportedToModule(Object from_module, String pkg, Object to_module); - public native Object GetModule(Class clazz); - public native void AddModulePackage(Object module, String pkg); - - // Image File - public native boolean readImageFile(String imagefile); - - public native int getOffsetForName0(String name); - public int getOffsetForName(String name) throws Exception { - int offset = getOffsetForName0(name); - if (offset == -1) { - throw new RuntimeException(name + " not found"); - } - return offset; - } - -} -- GitLab From ec0e48670fdd3cd153c66909187a8e5de9826f5d Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Tue, 17 May 2016 14:14:15 -0700 Subject: [PATCH 344/400] 8156845: Uri is getting incorrectly unwrapped Reviewed-by: lancea --- .../xml/catalog/CatalogResolverImpl.java | 57 +------------------ .../xml/catalog/CatalogUriResolverImpl.java | 28 ++++++--- .../classes/javax/xml/catalog/GroupEntry.java | 5 +- .../classes/javax/xml/catalog/Normalizer.java | 4 +- .../classes/javax/xml/catalog/UriEntry.java | 9 ++- .../share/classes/javax/xml/catalog/Util.java | 56 ++++++++++++++++++ .../jaxp/unittest/catalog/CatalogTest.java | 34 +++++++++++ .../javax/xml/jaxp/unittest/catalog/uri.xml | 4 ++ 8 files changed, 130 insertions(+), 67 deletions(-) create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/uri.xml diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java index 131d87e354f..08e7f417256 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,7 +56,7 @@ final class CatalogResolverImpl implements CatalogResolver { publicId = Normalizer.normalizePublicId(Normalizer.decodeURN(Util.getNotNullOrEmpty(publicId))); //check whether systemId is an urn - if (systemId != null && systemId.startsWith("urn:publicid:")) { + if (systemId != null && systemId.startsWith(Util.URN)) { systemId = Normalizer.decodeURN(systemId); if (publicId != null && !publicId.equals(systemId)) { systemId = null; @@ -67,7 +67,7 @@ final class CatalogResolverImpl implements CatalogResolver { } CatalogImpl c = (CatalogImpl)catalog; - String resolvedSystemId = resolve(c, publicId, systemId); + String resolvedSystemId = Util.resolve(c, publicId, systemId); if (resolvedSystemId != null) { return new InputSource(resolvedSystemId); @@ -86,55 +86,4 @@ final class CatalogResolverImpl implements CatalogResolver { return null; } - /** - * Resolves the publicId or systemId using public or system entries in the catalog. - * - * The resolution follows the following rules determined by the prefer setting: - * - * prefer "system": attempts to resolve with a system entry; - * attempts to resolve with a public entry when only - * publicId is specified. - * - * prefer "public": attempts to resolve with a system entry; - * attempts to resolve with a public entry if no matching - * system entry is found. - * @param catalog the catalog - * @param publicId the publicId - * @param systemId the systemId - * @return the resolved systemId if a match is found, null otherwise - */ - String resolve(CatalogImpl catalog, String publicId, String systemId) { - String resolvedSystemId = null; - - //search the current catalog - catalog.reset(); - if (systemId != null) { - /* - If a system identifier is specified, it is used no matter how - prefer is set. - */ - resolvedSystemId = catalog.matchSystem(systemId); - } - - if (resolvedSystemId == null && publicId != null) { - resolvedSystemId = catalog.matchPublic(publicId); - } - - //mark the catalog as having been searched before trying alternatives - catalog.markAsSearched(); - - //search alternative catalogs - if (resolvedSystemId == null) { - Iterator iter = catalog.catalogs().iterator(); - while (iter.hasNext()) { - resolvedSystemId = resolve((CatalogImpl)iter.next(), publicId, systemId); - if (resolvedSystemId != null) { - break; - } - - } - } - - return resolvedSystemId; - } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java index e7cb9bcf1a7..497aacf18fd 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,18 +65,30 @@ final class CatalogUriResolverImpl implements CatalogUriResolver { if (href == null) return null; + String result = null; CatalogImpl c = (CatalogImpl)catalog; String uri = Normalizer.normalizeURI(href); - String result; + //check whether uri is an urn + if (uri != null && uri.startsWith(Util.URN)) { + String publicId = Normalizer.decodeURN(uri); + if (publicId != null) { + result = Util.resolve(c, publicId, null); + } + } - //remove fragment if any. - int hashPos = uri.indexOf("#"); - if (hashPos >= 0) { - uri = uri.substring(0, hashPos); + //if no match with a public id, continue search for an URI + if (result == null) { + //remove fragment if any. + int hashPos = uri.indexOf("#"); + if (hashPos >= 0) { + uri = uri.substring(0, hashPos); + } + + //search the current catalog + result = resolve(c, uri); } - //search the current catalog - result = resolve(c, uri); + //Report error or return the URI as is when no match is found if (result == null) { GroupEntry.ResolveType resolveType = c.getResolve(); switch (resolveType) { diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java index 0ebf25e4207..2c1a59c360c 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/GroupEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -298,6 +298,9 @@ class GroupEntry extends BaseEntry { case PUBLIC: match = ((PublicEntry) entry).match(publicId); break; + case URI: + match = ((UriEntry) entry).match(publicId); + break; case GROUP: match = ((GroupEntry) entry).matchPublic(publicId); break; diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Normalizer.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Normalizer.java index 6beb4a8287d..d5b19930c01 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Normalizer.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Normalizer.java @@ -100,7 +100,7 @@ class Normalizer { } catch (UnsupportedEncodingException ex) { CatalogMessages.reportRunTimeError(CatalogMessages.ERR_OTHER, ex); } - return "urn:publicid:" + urn; + return Util.URN + urn; } /** @@ -114,7 +114,7 @@ class Normalizer { static String decodeURN(String urn) { String publicId; - if (urn != null && urn.startsWith("urn:publicid:")) { + if (urn != null && urn.startsWith(Util.URN)) { publicId = urn.substring(13); } else { return urn; diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java index 498b7ae4ce1..0c1aa295c9c 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/UriEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,11 @@ final class UriEntry extends BaseEntry { */ public void setName(String name) { CatalogMessages.reportNPEOnNull("name", name); - this.name = Normalizer.normalizeURI(name); + if (name.startsWith(Util.PUBLICID_PREFIX) || name.startsWith(Util.PUBLICID_PREFIX_ALT)) { + this.name = Normalizer.normalizePublicId(name); + } else { + this.name = Normalizer.normalizeURI(name); + } } /** @@ -72,6 +76,7 @@ final class UriEntry extends BaseEntry { public String getName() { return name; } + /** * Get the uri attribute. * @return The uri attribute value. diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java index f0fd1fdbf33..b164f674dbd 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java @@ -31,6 +31,7 @@ import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.Iterator; import jdk.xml.internal.SecuritySupport; /** @@ -38,6 +39,61 @@ import jdk.xml.internal.SecuritySupport; * @since 9 */ class Util { + final static String URN = "urn:publicid:"; + final static String PUBLICID_PREFIX = "-//"; + final static String PUBLICID_PREFIX_ALT = "+//"; + + /** + * Finds an entry in the catalog that matches with the publicId or systemId. + * + * The resolution follows the following rules determined by the prefer setting: + * + * prefer "system": attempts to resolve with a system entry; + * attempts to resolve with a public entry when only + * publicId is specified. + * + * prefer "public": attempts to resolve with a system entry; + * attempts to resolve with a public entry if no matching + * system entry is found. + * @param catalog the catalog + * @param publicId the publicId + * @param systemId the systemId + * @return the resolved systemId if a match is found, null otherwise + */ + static String resolve(CatalogImpl catalog, String publicId, String systemId) { + String resolvedSystemId = null; + + //search the current catalog + catalog.reset(); + if (systemId != null) { + /* + If a system identifier is specified, it is used no matter how + prefer is set. + */ + resolvedSystemId = catalog.matchSystem(systemId); + } + + if (resolvedSystemId == null && publicId != null) { + resolvedSystemId = catalog.matchPublic(publicId); + } + + //mark the catalog as having been searched before trying alternatives + catalog.markAsSearched(); + + //search alternative catalogs + if (resolvedSystemId == null) { + Iterator iter = catalog.catalogs().iterator(); + while (iter.hasNext()) { + resolvedSystemId = resolve((CatalogImpl)iter.next(), publicId, systemId); + if (resolvedSystemId != null) { + break; + } + + } + } + + return resolvedSystemId; + } /** * Resolves the specified file path to an absolute systemId. If it is diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java index 01bf4f63e89..dc5e8816bfd 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java @@ -34,6 +34,7 @@ import javax.xml.catalog.CatalogUriResolver; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.Source; import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.DataProvider; @@ -67,6 +68,24 @@ public class CatalogTest { } } + /* + * @bug 8156845 + * Verifies that an URI reference with a urn:publicid is correctly resolved + * with an uri entry with a publicId. + * + * @param expectedFile is not used in this test, it's kept since we're + * copying the JCK test and its dataProvider. This test may be reused for + * other cases in that test. + */ + @Test(dataProvider = "resolveUri") + public void testMatch1(String cFile, String href, String expectedFile, String expectedUri, String msg) { + String catalogFile = getClass().getResource(cFile).getFile(); + CatalogUriResolver cur = CatalogManager.catalogUriResolver(CatalogFeatures.defaults(), catalogFile); + Source source = cur.resolve(href, null); + Assert.assertNotNull(source, "Source returned is null"); + Assert.assertEquals(expectedUri, source.getSystemId(), msg); + } + /* * @bug 8154220 * Verifies that the file input is validated properly. Valid input includes @@ -329,6 +348,21 @@ public class CatalogTest { } } + + /* + DataProvider: used to verify CatalogUriResolver's resolve function. + Data columns: + catalog, uri or publicId, expectedFile, expectedUri, msg + + This DataProvider is copied from JCK ResolveTests' dataMatch1 + */ + @DataProvider(name = "resolveUri") + Object[][] getDataForUriResolver() { + return new Object[][]{ + {"uri.xml", "urn:publicid:-:Acme,+Inc.:DTD+Book+Version+1.0", null, "http://local/base/dtd/book.dtd", "Uri in publicId namespace is incorrectly unwrapped"}, + }; + } + /* DataProvider: used to verify hierarchical catalogs. Refer to JCK test hierarchyOfCatFiles2. diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/uri.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/uri.xml new file mode 100644 index 00000000000..f092ae85df2 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/uri.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file -- GitLab From d40a606f069b7e1e79588bdf0aacc3beaf53e10a Mon Sep 17 00:00:00 2001 From: Jiangli Zhou Date: Tue, 17 May 2016 17:42:16 -0400 Subject: [PATCH 345/400] 8149977: DumpLoadedClassList should not include generated classes Exclude anonymous classes from the generated class list. Reviewed-by: ccheung, iklam, hseigel --- hotspot/src/share/vm/classfile/classFileParser.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index 81216bbd518..e561cdcf160 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -5708,8 +5708,10 @@ void ClassFileParser::parse_stream(const ClassFileStream* const stream, #if INCLUDE_CDS if (DumpLoadedClassList != NULL && stream->source() != NULL && classlist_file->is_open()) { - // Only dump the classes that can be stored into CDS archive - if (SystemDictionaryShared::is_sharing_possible(_loader_data)) { + // Only dump the classes that can be stored into CDS archive. + // Anonymous classes such as generated LambdaForm classes are also not included. + if (SystemDictionaryShared::is_sharing_possible(_loader_data) && + _host_klass == NULL) { ResourceMark rm(THREAD); classlist_file->print_cr("%s", _class_name->as_C_string()); classlist_file->flush(); -- GitLab From 2479973df844446fe074912f4428220d37f6bc1f Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 18 May 2016 14:08:38 +0530 Subject: [PATCH 346/400] 8157160: JSON.stringify does not work on ScriptObjectMirror objects Reviewed-by: hannesw, mhaupt --- .../nashorn/internal/objects/NativeJSON.java | 101 +++++++++++++--- nashorn/test/script/basic/JDK-8157160.js | 113 ++++++++++++++++++ .../test/script/basic/JDK-8157160.js.EXPECTED | 9 ++ 3 files changed, 208 insertions(+), 15 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8157160.js create mode 100644 nashorn/test/script/basic/JDK-8157160.js.EXPECTED diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSON.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSON.java index edf59c7a463..b5e139c79bc 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSON.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeJSON.java @@ -35,7 +35,10 @@ import java.util.IdentityHashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.concurrent.Callable; +import jdk.nashorn.api.scripting.JSObject; +import jdk.nashorn.api.scripting.ScriptObjectMirror; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Function; import jdk.nashorn.internal.objects.annotations.ScriptClass; @@ -68,6 +71,17 @@ public final class NativeJSON extends ScriptObject { }); } + private static final Object JSOBJECT_INVOKER = new Object(); + + private static MethodHandle getJSOBJECT_INVOKER() { + return Global.instance().getDynamicInvoker(JSOBJECT_INVOKER, + new Callable() { + @Override + public MethodHandle call() { + return Bootstrap.createDynamicCallInvoker(Object.class, Object.class, Object.class); + } + }); + } private static final Object REPLACER_INVOKER = new Object(); @@ -77,7 +91,7 @@ public final class NativeJSON extends ScriptObject { @Override public MethodHandle call() { return Bootstrap.createDynamicCallInvoker(Object.class, - ScriptFunction.class, ScriptObject.class, Object.class, Object.class); + Object.class, Object.class, Object.class, Object.class); } }); } @@ -127,9 +141,10 @@ public final class NativeJSON extends ScriptObject { final StringifyState state = new StringifyState(); // If there is a replacer, it must be a function or an array. - if (replacer instanceof ScriptFunction) { - state.replacerFunction = (ScriptFunction) replacer; + if (Bootstrap.isCallable(replacer)) { + state.replacerFunction = replacer; } else if (isArray(replacer) || + isJSObjectArray(replacer) || replacer instanceof Iterable || (replacer != null && replacer.getClass().isArray())) { @@ -201,18 +216,19 @@ public final class NativeJSON extends ScriptObject { // stringify helpers. private static class StringifyState { - final Map stack = new IdentityHashMap<>(); + final Map stack = new IdentityHashMap<>(); StringBuilder indent = new StringBuilder(); String gap = ""; List propertyList = null; - ScriptFunction replacerFunction = null; + Object replacerFunction = null; } // Spec: The abstract operation Str(key, holder). - private static Object str(final Object key, final ScriptObject holder, final StringifyState state) { - Object value = holder.get(key); + private static Object str(final Object key, final Object holder, final StringifyState state) { + assert holder instanceof ScriptObject || holder instanceof JSObject; + Object value = getProperty(holder, key); try { if (value instanceof ScriptObject) { final InvokeByName toJSONInvoker = getTO_JSON(); @@ -221,6 +237,12 @@ public final class NativeJSON extends ScriptObject { if (Bootstrap.isCallable(toJSON)) { value = toJSONInvoker.getInvoker().invokeExact(toJSON, svalue, key); } + } else if (value instanceof JSObject) { + final JSObject jsObj = (JSObject)value; + final Object toJSON = jsObj.getMember("toJSON"); + if (Bootstrap.isCallable(toJSON)) { + value = getJSOBJECT_INVOKER().invokeExact(toJSON, value); + } } if (state.replacerFunction != null) { @@ -262,10 +284,10 @@ public final class NativeJSON extends ScriptObject { final JSType type = JSType.of(value); if (type == JSType.OBJECT) { - if (isArray(value)) { - return JA((ScriptObject)value, state); - } else if (value instanceof ScriptObject) { - return JO((ScriptObject)value, state); + if (isArray(value) || isJSObjectArray(value)) { + return JA(value, state); + } else if (value instanceof ScriptObject || value instanceof JSObject) { + return JO(value, state); } } @@ -273,7 +295,9 @@ public final class NativeJSON extends ScriptObject { } // Spec: The abstract operation JO(value) serializes an object. - private static String JO(final ScriptObject value, final StringifyState state) { + private static String JO(final Object value, final StringifyState state) { + assert value instanceof ScriptObject || value instanceof JSObject; + if (state.stack.containsKey(value)) { throw typeError("JSON.stringify.cyclic"); } @@ -284,7 +308,8 @@ public final class NativeJSON extends ScriptObject { final StringBuilder finalStr = new StringBuilder(); final List partial = new ArrayList<>(); - final List k = state.propertyList == null ? Arrays.asList(value.getOwnKeys(false)) : state.propertyList; + final List k = state.propertyList == null ? + Arrays.asList(getOwnKeys(value)) : state.propertyList; for (final Object p : k) { final Object strP = str(p, value, state); @@ -349,7 +374,9 @@ public final class NativeJSON extends ScriptObject { } // Spec: The abstract operation JA(value) serializes an array. - private static Object JA(final ScriptObject value, final StringifyState state) { + private static Object JA(final Object value, final StringifyState state) { + assert value instanceof ScriptObject || value instanceof JSObject; + if (state.stack.containsKey(value)) { throw typeError("JSON.stringify.cyclic"); } @@ -359,7 +386,7 @@ public final class NativeJSON extends ScriptObject { state.indent.append(state.gap); final List partial = new ArrayList<>(); - final int length = JSType.toInteger(value.getLength()); + final int length = JSType.toInteger(getLength(value)); int index = 0; while (index < length) { @@ -413,4 +440,48 @@ public final class NativeJSON extends ScriptObject { return finalStr.toString(); } + + private static String[] getOwnKeys(final Object obj) { + if (obj instanceof ScriptObject) { + return ((ScriptObject)obj).getOwnKeys(false); + } else if (obj instanceof ScriptObjectMirror) { + return ((ScriptObjectMirror)obj).getOwnKeys(false); + } else if (obj instanceof JSObject) { + // No notion of "own keys" or "proto" for general JSObject! We just + // return all keys of the object. This will be useful for POJOs + // implementing JSObject interface. + return ((JSObject)obj).keySet().toArray(new String[0]); + } else { + throw new AssertionError("should not reach here"); + } + } + + private static Object getLength(final Object obj) { + if (obj instanceof ScriptObject) { + return ((ScriptObject)obj).getLength(); + } else if (obj instanceof JSObject) { + return ((JSObject)obj).getMember("length"); + } else { + throw new AssertionError("should not reach here"); + } + } + + private static boolean isJSObjectArray(final Object obj) { + return (obj instanceof JSObject) && ((JSObject)obj).isArray(); + } + + private static Object getProperty(final Object holder, final Object key) { + if (holder instanceof ScriptObject) { + return ((ScriptObject)holder).get(key); + } else if (holder instanceof JSObject) { + JSObject jsObj = (JSObject)holder; + if (key instanceof Integer) { + return jsObj.getSlot((Integer)key); + } else { + return jsObj.getMember(Objects.toString(key)); + } + } else { + return new AssertionError("should not reach here"); + } + } } diff --git a/nashorn/test/script/basic/JDK-8157160.js b/nashorn/test/script/basic/JDK-8157160.js new file mode 100644 index 00000000000..28077cde887 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8157160.js @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8157160: JSON.stringify does not work on ScriptObjectMirror objects + * + * @test + * @option -scripting + * @run + */ + +var SM = Java.type("javax.script.ScriptEngineManager"); +var AJSO = Java.type("jdk.nashorn.api.scripting.AbstractJSObject"); +var Supplier = Java.type("java.util.function.Supplier"); + +var engine = new SM().getEngineByName("nashorn"); + +// JSON stringify ScriptObjectMirror instances +print(JSON.stringify(engine.eval("({ foo : 42 })"))); +print(JSON.stringify(engine.eval("([5, 6, 76, 7])"))); +print(JSON.stringify(engine.eval(< Date: Wed, 18 May 2016 12:07:54 +0200 Subject: [PATCH 347/400] 8157225: adopt method handle for array length getter in BeanLinker Reviewed-by: hannesw, sundar --- .../classes/jdk/dynalink/beans/BeanLinker.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java index 9b580f12df2..70cb477bc81 100644 --- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java +++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -113,7 +113,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL // Some languages won't have a notion of manipulating collections. Exposing "length" on arrays as an // explicit property is beneficial for them. // REVISIT: is it maybe a code smell that StandardOperation.GET_LENGTH is not needed? - setPropertyGetter("length", GET_ARRAY_LENGTH, ValidationType.IS_ARRAY); + setPropertyGetter("length", MethodHandles.arrayLength(clazz), ValidationType.IS_ARRAY); } else if(List.class.isAssignableFrom(clazz)) { setPropertyGetter("length", GET_COLLECTION_LENGTH, ValidationType.INSTANCE_OF); } @@ -518,9 +518,6 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL gic.getValidatorClass(), gic.getValidationType()); } - private static final MethodHandle GET_ARRAY_LENGTH = Lookup.PUBLIC.findStatic(Array.class, "getLength", - MethodType.methodType(int.class, Object.class)); - private static final MethodHandle GET_COLLECTION_LENGTH = Lookup.PUBLIC.findVirtual(Collection.class, "size", MethodType.methodType(int.class)); @@ -537,7 +534,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL // Thing is, it'd be quite stupid of a call site creator to go though invokedynamic when it knows in advance // they're dealing with an array, collection, or map, but hey... if(declaredType.isArray()) { - return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType)); + return new GuardedInvocationComponent(MethodHandles.arrayLength(declaredType).asType(callSiteType)); } else if(Collection.class.isAssignableFrom(declaredType)) { return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType)); } else if(Map.class.isAssignableFrom(declaredType)) { @@ -546,8 +543,8 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL // Otherwise, create a binding based on the actual type of the argument with an appropriate guard. if(clazz.isArray()) { - return new GuardedInvocationComponent(GET_ARRAY_LENGTH.asType(callSiteType), Guards.isArray(0, - callSiteType), ValidationType.IS_ARRAY); + return new GuardedInvocationComponent(MethodHandles.arrayLength(clazz).asType(callSiteType), + Guards.isArray(0, callSiteType), ValidationType.IS_ARRAY); } if(Collection.class.isAssignableFrom(clazz)) { return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType( COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF); -- GitLab From dfcb34c13222c7c65f45ef4c904735c1bbeedb37 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Wed, 18 May 2016 20:17:48 +0530 Subject: [PATCH 348/400] 8157241: Remove javac warnings of Nashorn "ant clean test" Reviewed-by: mhaupt, hannesw --- .../src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java | 3 +++ .../nashorn/internal/tools/nasgen/ConstructorGenerator.java | 1 + .../jdk/nashorn/internal/tools/nasgen/MethodGenerator.java | 1 + .../classes/jdk/nashorn/internal/codegen/MethodEmitter.java | 3 +++ .../share/classes/jdk/nashorn/internal/objects/Global.java | 2 ++ .../jdk/nashorn/internal/objects/NativeArrayBuffer.java | 4 ++-- .../jdk/nashorn/internal/objects/NativeFloat32Array.java | 2 +- .../jdk/nashorn/internal/objects/NativeFloat64Array.java | 2 +- .../jdk/nashorn/internal/objects/NativeInt16Array.java | 2 +- .../jdk/nashorn/internal/objects/NativeInt32Array.java | 2 +- .../classes/jdk/nashorn/internal/objects/NativeInt8Array.java | 2 +- .../jdk/nashorn/internal/objects/NativeUint16Array.java | 2 +- .../jdk/nashorn/internal/objects/NativeUint32Array.java | 2 +- .../jdk/nashorn/internal/objects/NativeUint8Array.java | 2 +- .../jdk/nashorn/internal/objects/NativeUint8ClampedArray.java | 2 +- .../share/classes/jdk/nashorn/internal/parser/Parser.java | 3 +++ .../internal/runtime/linker/JavaAdapterBytecodeGenerator.java | 3 +++ .../nashorn/api/scripting/test/ScriptEngineSecurityTest.java | 2 +- 18 files changed, 28 insertions(+), 12 deletions(-) diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java index 9eb9f47e606..9f3380c0f1c 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ClassGenerator.java @@ -280,6 +280,7 @@ public class ClassGenerator { addField(cv, name, OBJECT_DESC); } + @SuppressWarnings("deprecation") static void newFunction(final MethodGenerator mi, final String objName, final String className, final MemberInfo memInfo, final List specs) { final boolean arityFound = (memInfo.getArity() != MemberInfo.DEFAULT_ARITY); @@ -305,6 +306,7 @@ public class ClassGenerator { mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETDOCUMENTATIONKEY, SCRIPTFUNCTION_SETDOCUMENTATIONKEY_DESC); } + @SuppressWarnings("deprecation") static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo memInfo) { final String propertyName = memInfo.getName(); // stack: Collection @@ -334,6 +336,7 @@ public class ClassGenerator { // stack: Collection } + @SuppressWarnings("deprecation") static void linkerAddGetterSetter(final MethodGenerator mi, final String className, final MemberInfo getter, final MemberInfo setter) { final String propertyName = getter.getName(); // stack: Collection diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java index 73bb21de38f..2d9cf74165e 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java @@ -178,6 +178,7 @@ public class ConstructorGenerator extends ClassGenerator { } } + @SuppressWarnings("deprecation") private void callSuper(final MethodGenerator mi) { String superClass, superDesc; mi.loadThis(); diff --git a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java index a4a906b4037..aecd9c5aadc 100644 --- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java +++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/MethodGenerator.java @@ -390,6 +390,7 @@ public class MethodGenerator extends MethodVisitor { return EMPTY_LINK_LOGIC_TYPE.equals(type); } + @SuppressWarnings("deprecation") void memberInfoArray(final String className, final List mis) { if (mis.isEmpty()) { pushNull(); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java index 9c0385d7f06..6d92c68d957 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/MethodEmitter.java @@ -170,9 +170,11 @@ public class MethodEmitter { } /** Bootstrap for normal indy:s */ + @SuppressWarnings("deprecation") private static final Handle LINKERBOOTSTRAP = new Handle(H_INVOKESTATIC, Bootstrap.BOOTSTRAP.className(), Bootstrap.BOOTSTRAP.name(), Bootstrap.BOOTSTRAP.descriptor()); /** Bootstrap for array populators */ + @SuppressWarnings("deprecation") private static final Handle POPULATE_ARRAY_BOOTSTRAP = new Handle(H_INVOKESTATIC, RewriteException.BOOTSTRAP.className(), RewriteException.BOOTSTRAP.name(), RewriteException.BOOTSTRAP.descriptor()); /** @@ -1005,6 +1007,7 @@ public class MethodEmitter { * * @return the method emitter */ + @SuppressWarnings("deprecation") MethodEmitter loadHandle(final String className, final String methodName, final String descName, final EnumSet flags) { debug("load handle "); pushType(Type.OBJECT.ldc(method, new Handle(Flag.getValue(flags), className, methodName, descName))); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java index ea64550a661..fba4d565b99 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java @@ -2839,6 +2839,7 @@ public final class Global extends Scope { sb.append("$Constructor"); final Class funcClass = Class.forName(sb.toString()); + @SuppressWarnings("deprecation") final T res = clazz.cast(funcClass.newInstance()); if (res instanceof ScriptFunction) { @@ -2866,6 +2867,7 @@ public final class Global extends Scope { final String className = PACKAGE_PREFIX + name + "$Prototype"; final Class funcClass = Class.forName(className); + @SuppressWarnings("deprecation") final ScriptObject res = (ScriptObject) funcClass.newInstance(); res.setIsBuiltin(); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArrayBuffer.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArrayBuffer.java index 4a27c1f8dd2..bfb8f1089e8 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArrayBuffer.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArrayBuffer.java @@ -232,10 +232,10 @@ public final class NativeArrayBuffer extends ScriptObject { } ByteBuffer getBuffer(final int offset) { - return (ByteBuffer)nb.duplicate().position(offset); + return nb.duplicate().position(offset); } ByteBuffer getBuffer(final int offset, final int length) { - return (ByteBuffer)getBuffer(offset).limit(length); + return getBuffer(offset).limit(length); } } diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java index bc0d68b20e6..0f67ec40b2b 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat32Array.java @@ -81,7 +81,7 @@ public final class NativeFloat32Array extends ArrayBufferView { private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Float32ArrayData.class, "setElem", void.class, int.class, double.class).methodHandle(); private Float32ArrayData(final FloatBuffer nb, final int start, final int end) { - super(((FloatBuffer)nb.position(start).limit(end)).slice(), end - start); + super((nb.position(start).limit(end)).slice(), end - start); } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java index cf7a15a10ff..de3d0f007fb 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFloat64Array.java @@ -81,7 +81,7 @@ public final class NativeFloat64Array extends ArrayBufferView { private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Float64ArrayData.class, "setElem", void.class, int.class, double.class).methodHandle(); private Float64ArrayData(final DoubleBuffer nb, final int start, final int end) { - super(((DoubleBuffer)nb.position(start).limit(end)).slice(), end - start); + super((nb.position(start).limit(end)).slice(), end - start); } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java index dce5174383a..735e6a37f6b 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt16Array.java @@ -82,7 +82,7 @@ public final class NativeInt16Array extends ArrayBufferView { private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Int16ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle(); private Int16ArrayData(final ShortBuffer nb, final int start, final int end) { - super(((ShortBuffer)nb.position(start).limit(end)).slice(), end - start); + super((nb.position(start).limit(end)).slice(), end - start); } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java index 877e27ab5ab..7eacedc9bc4 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt32Array.java @@ -81,7 +81,7 @@ public final class NativeInt32Array extends ArrayBufferView { private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Int32ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle(); private Int32ArrayData(final IntBuffer nb, final int start, final int end) { - super(((IntBuffer)nb.position(start).limit(end)).slice(), end - start); + super((nb.position(start).limit(end)).slice(), end - start); } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java index 9f146dd7869..75fde20eb65 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeInt8Array.java @@ -80,7 +80,7 @@ public final class NativeInt8Array extends ArrayBufferView { private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Int8ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle(); private Int8ArrayData(final ByteBuffer nb, final int start, final int end) { - super(((ByteBuffer)nb.position(start).limit(end)).slice(), end - start); + super((nb.position(start).limit(end)).slice(), end - start); } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java index d0b3e0586bd..fb3a6671153 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint16Array.java @@ -81,7 +81,7 @@ public final class NativeUint16Array extends ArrayBufferView { private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Uint16ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle(); private Uint16ArrayData(final CharBuffer nb, final int start, final int end) { - super(((CharBuffer)nb.position(start).limit(end)).slice(), end - start); + super((nb.position(start).limit(end)).slice(), end - start); } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java index 6760bdab780..4d691b290e0 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint32Array.java @@ -84,7 +84,7 @@ public final class NativeUint32Array extends ArrayBufferView { private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Uint32ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle(); private Uint32ArrayData(final IntBuffer nb, final int start, final int end) { - super(((IntBuffer)nb.position(start).limit(end)).slice(), end - start); + super((nb.position(start).limit(end)).slice(), end - start); } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java index 5f76f8f0710..229099e629a 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8Array.java @@ -81,7 +81,7 @@ public final class NativeUint8Array extends ArrayBufferView { private static final MethodHandle SET_ELEM = specialCall(MethodHandles.lookup(), Uint8ArrayData.class, "setElem", void.class, int.class, int.class).methodHandle(); private Uint8ArrayData(final ByteBuffer nb, final int start, final int end) { - super(((ByteBuffer)nb.position(start).limit(end)).slice(), end - start); + super((nb.position(start).limit(end)).slice(), end - start); } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java index 485349b9098..905d99fc5c0 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java @@ -85,7 +85,7 @@ public final class NativeUint8ClampedArray extends ArrayBufferView { private static final MethodHandle CLAMP_LONG = staticCall(MethodHandles.lookup(), Uint8ClampedArrayData.class, "clampLong", long.class, long.class).methodHandle(); private Uint8ClampedArrayData(final ByteBuffer nb, final int start, final int end) { - super(((ByteBuffer)nb.position(start).limit(end)).slice(), end - start); + super((nb.position(start).limit(end)).slice(), end - start); } @Override diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java index 6527f6be8d0..c8936ef94bc 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java @@ -2070,6 +2070,7 @@ public class Parser extends AbstractParser implements Loggable { } } + @SuppressWarnings("fallthrough") private boolean lookaheadIsLetDeclaration(final boolean ofContextualKeyword) { assert type == LET; for (int i = 1;; i++) { @@ -2323,6 +2324,7 @@ public class Parser extends AbstractParser implements Loggable { * yield [no LineTerminator here] AssignmentExpression[?In, Yield] * yield [no LineTerminator here] * AssignmentExpression[?In, Yield] */ + @SuppressWarnings("fallthrough") private Expression yieldExpression(final boolean noIn) { assert inGeneratorFunction(); // Capture YIELD token. @@ -2838,6 +2840,7 @@ public class Parser extends AbstractParser implements Loggable { * Parse array literal. * @return Expression node. */ + @SuppressWarnings("fallthrough") private LiteralNode arrayLiteral() { // Capture LBRACKET token. final long arrayToken = token; diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java index 59389e99d83..8dd697f6913 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java @@ -173,12 +173,14 @@ final class JavaAdapterBytecodeGenerator { private static final Call RUN = interfaceCallNoLookup(Runnable.class, "run", void.class); // ASM handle to the bootstrap method + @SuppressWarnings("deprecation") private static final Handle BOOTSTRAP_HANDLE = new Handle(H_INVOKESTATIC, Type.getInternalName(JavaAdapterServices.class), "bootstrap", MethodType.methodType(CallSite.class, Lookup.class, String.class, MethodType.class, int.class).toMethodDescriptorString()); // ASM handle to the bootstrap method for array populator + @SuppressWarnings("deprecation") private static final Handle CREATE_ARRAY_BOOTSTRAP_HANDLE = new Handle(H_INVOKESTATIC, Type.getInternalName(JavaAdapterServices.class), "createArrayBootstrap", MethodType.methodType(CallSite.class, Lookup.class, String.class, @@ -1048,6 +1050,7 @@ final class JavaAdapterBytecodeGenerator { endMethod(mv); } + @SuppressWarnings("deprecation") private void generateFinalizerOverride() { final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, "finalize", VOID_METHOD_DESCRIPTOR, null, null)); diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java index c6f5c2dae1f..3a992f76963 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptEngineSecurityTest.java @@ -172,7 +172,7 @@ public class ScriptEngineSecurityTest { } // @bug 8032948: Nashorn linkages awry - @SuppressWarnings("serial") + @SuppressWarnings({ "serial", "deprecation" }) public static class FakeProxy extends Proxy { public FakeProxy(final InvocationHandler ih) { super(ih); -- GitLab From 4ad196ec4f3a6f7680a6fd7a428866d0dc92193a Mon Sep 17 00:00:00 2001 From: Michael Haupt Date: Wed, 18 May 2016 17:37:34 +0200 Subject: [PATCH 349/400] 8157250: BeanLinker assumes fixed array type linkage Reviewed-by: attila, sundar --- .../jdk/dynalink/beans/BeanLinker.java | 4 +-- nashorn/test/script/basic/JDK-8157250.js | 34 +++++++++++++++++++ .../test/script/basic/JDK-8157250.js.EXPECTED | 1 + 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 nashorn/test/script/basic/JDK-8157250.js create mode 100644 nashorn/test/script/basic/JDK-8157250.js.EXPECTED diff --git a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java index 70cb477bc81..3f98c2b82f2 100644 --- a/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java +++ b/nashorn/src/jdk.dynalink/share/classes/jdk/dynalink/beans/BeanLinker.java @@ -113,7 +113,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL // Some languages won't have a notion of manipulating collections. Exposing "length" on arrays as an // explicit property is beneficial for them. // REVISIT: is it maybe a code smell that StandardOperation.GET_LENGTH is not needed? - setPropertyGetter("length", MethodHandles.arrayLength(clazz), ValidationType.IS_ARRAY); + setPropertyGetter("length", MethodHandles.arrayLength(clazz), ValidationType.EXACT_CLASS); } else if(List.class.isAssignableFrom(clazz)) { setPropertyGetter("length", GET_COLLECTION_LENGTH, ValidationType.INSTANCE_OF); } @@ -544,7 +544,7 @@ class BeanLinker extends AbstractJavaLinker implements TypeBasedGuardingDynamicL // Otherwise, create a binding based on the actual type of the argument with an appropriate guard. if(clazz.isArray()) { return new GuardedInvocationComponent(MethodHandles.arrayLength(clazz).asType(callSiteType), - Guards.isArray(0, callSiteType), ValidationType.IS_ARRAY); + Guards.isArray(0, callSiteType), ValidationType.EXACT_CLASS); } if(Collection.class.isAssignableFrom(clazz)) { return new GuardedInvocationComponent(GET_COLLECTION_LENGTH.asType(callSiteType), Guards.asType( COLLECTION_GUARD, callSiteType), Collection.class, ValidationType.INSTANCE_OF); diff --git a/nashorn/test/script/basic/JDK-8157250.js b/nashorn/test/script/basic/JDK-8157250.js new file mode 100644 index 00000000000..b392a0d00b4 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8157250.js @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8157250: BeanLinker assumes fixed array type linkage + * + * @test + * @run + */ + +var intArray = Java.type("int[]") +var doubleArray = Java.type("double[]") +var arrs = [new intArray(0), new doubleArray(0)] +for (var i in arrs) arrs[i].length diff --git a/nashorn/test/script/basic/JDK-8157250.js.EXPECTED b/nashorn/test/script/basic/JDK-8157250.js.EXPECTED new file mode 100644 index 00000000000..573541ac970 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8157250.js.EXPECTED @@ -0,0 +1 @@ +0 -- GitLab From 165edba622e2ac817694597080a5db2380228292 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Wed, 18 May 2016 18:44:44 +0200 Subject: [PATCH 350/400] 8066229: Fuzzing bug: Can't find scope depth Reviewed-by: sundar --- nashorn/test/script/basic/JDK-8066229.js | 42 +++++++++++++++++++ .../test/script/basic/JDK-8157250.js.EXPECTED | 1 - 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 nashorn/test/script/basic/JDK-8066229.js delete mode 100644 nashorn/test/script/basic/JDK-8157250.js.EXPECTED diff --git a/nashorn/test/script/basic/JDK-8066229.js b/nashorn/test/script/basic/JDK-8066229.js new file mode 100644 index 00000000000..2f98f57cc07 --- /dev/null +++ b/nashorn/test/script/basic/JDK-8066229.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * JDK-8066229: Fuzzing bug: Can't find scope depth + * + * @test + * @run + */ + +function f() { x; throw null; (function (){ var x; }); } + +try { + f(); + throw new Error("Expected error"); +} catch (e) { + if (!(e instanceof ReferenceError)) { + throw new Error("Unexpected error: " + e); + } +} + + diff --git a/nashorn/test/script/basic/JDK-8157250.js.EXPECTED b/nashorn/test/script/basic/JDK-8157250.js.EXPECTED deleted file mode 100644 index 573541ac970..00000000000 --- a/nashorn/test/script/basic/JDK-8157250.js.EXPECTED +++ /dev/null @@ -1 +0,0 @@ -0 -- GitLab From 0e4ffbab485011e4de777f58e3ca3f7bbce7b2f5 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 18 May 2016 21:00:22 +0200 Subject: [PATCH 351/400] 8133549: Generalize jshell's EditingHistory Using a generic EditingHistory in jjs Reviewed-by: sundar --- .../jdk/nashorn/tools/jjs/Console.java | 35 +++++++++++-------- .../jdk/nashorn/tools/jjs/HistoryObject.java | 5 ++- .../nashorn/tools/jjs/NashornCompleter.java | 16 +++++++++ 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java index 0c9b070af90..4df6b39bc6a 100644 --- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java +++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Console.java @@ -30,12 +30,10 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; +import java.io.Writer; +import java.nio.file.Files; import java.util.function.Function; +import java.util.stream.Collectors; import jdk.internal.jline.NoInterruptUnixTerminal; import jdk.internal.jline.Terminal; import jdk.internal.jline.TerminalFactory; @@ -43,23 +41,28 @@ import jdk.internal.jline.TerminalFactory.Flavor; import jdk.internal.jline.WindowsTerminal; import jdk.internal.jline.console.ConsoleReader; import jdk.internal.jline.console.KeyMap; -import jdk.internal.jline.console.completer.Completer; -import jdk.internal.jline.console.history.FileHistory; +import jdk.internal.jline.extra.EditingHistory; class Console implements AutoCloseable { private static final String DOCUMENTATION_SHORTCUT = "\033\133\132"; //Shift-TAB private final ConsoleReader in; - private final FileHistory history; + private final File historyFile; Console(final InputStream cmdin, final PrintStream cmdout, final File historyFile, - final Completer completer, final Function docHelper) throws IOException { + final NashornCompleter completer, final Function docHelper) throws IOException { + this.historyFile = historyFile; + TerminalFactory.registerFlavor(Flavor.WINDOWS, isCygwin()? JJSUnixTerminal::new : JJSWindowsTerminal::new); TerminalFactory.registerFlavor(Flavor.UNIX, JJSUnixTerminal::new); in = new ConsoleReader(cmdin, cmdout); in.setExpandEvents(false); in.setHandleUserInterrupt(true); in.setBellEnabled(true); - in.setHistory(history = new FileHistory(historyFile)); + in.setHistory(new EditingHistory(in, Files.readAllLines(historyFile.toPath())) { + @Override protected boolean isComplete(CharSequence input) { + return completer.isComplete(input.toString()); + } + }); in.addCompleter(completer); Runtime.getRuntime().addShutdownHook(new Thread((Runnable)this::saveHistory)); bind(DOCUMENTATION_SHORTCUT, (ActionListener)evt -> showDocumentation(docHelper)); @@ -75,13 +78,17 @@ class Console implements AutoCloseable { } private void saveHistory() { - try { - getHistory().flush(); + try (Writer out = Files.newBufferedWriter(historyFile.toPath())) { + String lineSeparator = System.getProperty("line.separator"); + + out.write(getHistory().save() + .stream() + .collect(Collectors.joining(lineSeparator))); } catch (final IOException exp) {} } - FileHistory getHistory() { - return (FileHistory) in.getHistory(); + EditingHistory getHistory() { + return (EditingHistory) in.getHistory(); } boolean terminalEditorRunning() { diff --git a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/HistoryObject.java b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/HistoryObject.java index e7ae0db8974..c8b7c10281c 100644 --- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/HistoryObject.java +++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/HistoryObject.java @@ -36,7 +36,6 @@ import java.util.Set; import java.util.function.Consumer; import java.util.function.Function; import java.util.function.Supplier; -import jdk.internal.jline.console.history.FileHistory; import jdk.internal.jline.console.history.History; import jdk.nashorn.api.scripting.AbstractJSObject; import jdk.nashorn.api.scripting.JSObject; @@ -61,11 +60,11 @@ final class HistoryObject extends AbstractJSObject { props = Collections.unmodifiableSet(s); } - private final FileHistory hist; + private final History hist; private final PrintWriter err; private final Consumer evaluator; - HistoryObject(final FileHistory hist, final PrintWriter err, + HistoryObject(final History hist, final PrintWriter err, final Consumer evaluator) { this.hist = hist; this.err = err; diff --git a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/NashornCompleter.java b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/NashornCompleter.java index 521bb6e401f..65c5e28b2a5 100644 --- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/NashornCompleter.java +++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/NashornCompleter.java @@ -185,6 +185,22 @@ final class NashornCompleter implements Completer { } } + public boolean isComplete(String input) { + try { + parser.parse("", input, null); + } catch (final Exception pexp) { + // Do we have a parse error at the end of current line? + // If so, read more lines from the console. + int line = input.split("\n").length; + int lastLineLen = input.length() - (input.lastIndexOf("\n") + 1); + + if (isParseErrorAt(pexp, line, lastLineLen)) { + return false; + } + } + return true; + } + // Pattern to match a unfinished member selection expression. object part and "." // but property name missing pattern. private static final Pattern SELECT_PROP_MISSING = Pattern.compile(".*\\.\\s*"); -- GitLab From cf9a1d4970bdf0f5903cc31d083821c36291d763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Wed, 18 May 2016 22:30:14 +0200 Subject: [PATCH 352/400] 8157263: Octane svn repository no longer exists Reviewed-by: sundar --- nashorn/make/build.xml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/nashorn/make/build.xml b/nashorn/make/build.xml index 0f255e23893..9aced2f767a 100644 --- a/nashorn/make/build.xml +++ b/nashorn/make/build.xml @@ -775,20 +775,16 @@ grant codeBase "file:/${basedir}/test/script/markdown.js" { - - - - - + + + - - - - + + -- GitLab From 23043ca1e6bd4a158e9d33d290a11ec0ed623170 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Thu, 19 May 2016 17:24:50 +0200 Subject: [PATCH 353/400] 8155786: Determine modules depending on upgradeable modules directly and indirectly Reviewed-by: alanb, mchung --- make/CreateJmods.gmk | 16 ++++------------ make/Main.gmk | 3 ++- make/common/Modules.gmk | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/make/CreateJmods.gmk b/make/CreateJmods.gmk index 394888c4970..40900ff91a9 100644 --- a/make/CreateJmods.gmk +++ b/make/CreateJmods.gmk @@ -69,21 +69,13 @@ endif # Add dependencies on other jmod files. Only java.base needs access to other # jmods. ifeq ($(MODULE), java.base) + ALL_UPGRADEABLE_MODULES = $(call FindAllUpgradeableModules) # When creating a BUILDJDK, we don't need to add hashes to java.base ifneq ($(CREATING_BUILDJDK), true) DEPS += $(patsubst %, $(JMODS_DIR)/%.jmod, \ - $(filter-out java.base, $(call FindAllModules))) - - # TODO: find modules that directly and indirectly depend on upgradeable - # modules - EXCLUDE_HASH_MODULES := $(UPGRADEABLE_MODULES) \ - java.se.ee \ - jdk.rmic \ - jdk.xml.bind \ - jdk.xml.ws \ - # - - EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(EXCLUDE_HASH_MODULES)))) + $(filter-out java.base $(ALL_UPGRADEABLE_MODULES), $(call FindAllModules))) + + EXCLUDE_PATTERN := $(strip $(subst $(SPACE),|,$(strip $(ALL_UPGRADEABLE_MODULES)))) JMOD_FLAGS += --modulepath $(JMODS_DIR) \ --hash-modules '^(?!$(EXCLUDE_PATTERN))' diff --git a/make/Main.gmk b/make/Main.gmk index 29a9de44b2d..b0361fb83c3 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -596,7 +596,8 @@ else # When creating a BUILDJDK, we don't need to add hashes to java.base, thus # we don't need to depend on all other jmods ifneq ($(CREATING_BUILDJDK), true) - java.base-jmod: $(filter-out java.base-jmod, $(JMOD_TARGETS)) + java.base-jmod: $(filter-out java.base-jmod \ + $(addsuffix -jmod, $(call FindAllUpgradeableModules)), $(JMOD_TARGETS)) endif # Declare dependencies from -jmod to all other module targets diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk index fa5aa54e6fc..90469d073fd 100644 --- a/make/common/Modules.gmk +++ b/make/common/Modules.gmk @@ -86,6 +86,10 @@ UPGRADEABLE_MODULES += \ java.xml.ws \ # +# Modules explicitly declared as not being upgradeable even though they require +# an upgradeable module. +NON_UPGRADEABLE_MODULES += + AGGREGATOR_MODULES += \ java.compact1 \ java.compact2 \ @@ -245,6 +249,19 @@ FindTransitiveDepsForModule = \ $(foreach n, $(call FindDepsForModule, $m), \ $(call FindDepsForModule, $n)))) +# Upgradeable modules are those that are either defined as upgradeable or that +# require an upradeable module. +FindAllUpgradeableModules = \ + $(filter-out $(MODULES_FILTER) $(NON_UPGRADEABLE_MODULES), \ + $(sort $(UPGRADEABLE_MODULES) $(foreach m, \ + $(filter-out $(UPGRADEABLE_MODULES), $(call FindAllModules)), \ + $(if $(filter $(UPGRADEABLE_MODULES), \ + $(call FindTransitiveDepsForModule, $m)), \ + $m \ + ) \ + )) \ + ) + ################################################################################ # Param 1 - Name of module -- GitLab From 16eae50cca262a6052f1534a530025dcf63208bb Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Thu, 19 May 2016 16:48:43 +0100 Subject: [PATCH 354/400] 8157061: Add support for running jtreg tests from IntelliJ project Add basic capabilities for running jtreg tests from the IDE using a custom ant target Reviewed-by: chegar --- common/bin/idea.sh | 10 ++ make/idea/idea.gmk | 1 + make/idea/template/ant.xml | 3 +- make/idea/template/build.xml | 91 ++++++++++++++----- .../template/src/idea/JdkIdeaAntLogger.java | 6 +- make/idea/template/workspace.xml | 8 ++ 6 files changed, 93 insertions(+), 26 deletions(-) diff --git a/common/bin/idea.sh b/common/bin/idea.sh index 911d309c070..2cd6f92bbb9 100644 --- a/common/bin/idea.sh +++ b/common/bin/idea.sh @@ -155,6 +155,14 @@ addBuildDir() { printf "%s\n" "$mn" >> $IDEA_ANT } +JTREG_HOME=" " + +addJtregHome() { + DIR=`dirname $SPEC` + mn="`echo "$JTREG_HOME" | sed -e s@"\(.*\)####\(.*\)"@"\1$JT_HOME\2"@`" + printf "%s\n" "$mn" >> $IDEA_ANT +} + ### Generate ant.xml rm -f $IDEA_ANT @@ -162,6 +170,8 @@ while IFS= read -r line do if echo "$line" | egrep "^ .* /dev/null ; then addModuleName + elif echo "$line" | egrep "^ .* /dev/null ; then + addJtregHome elif echo "$line" | egrep "^ .* /dev/null ; then addBuildDir else diff --git a/make/idea/idea.gmk b/make/idea/idea.gmk index 329c01cd5ea..299ffe805bc 100644 --- a/make/idea/idea.gmk +++ b/make/idea/idea.gmk @@ -35,5 +35,6 @@ else #with SPEC $(ECHO) "BOOT_JDK=\"$(BOOT_JDK)\"" >> $(OUT) $(ECHO) "CYGPATH=\"$(CYGPATH)\"" >> $(OUT) $(ECHO) "SPEC=\"$(SPEC)\"" >> $(OUT) + $(ECHO) "JT_HOME=\"$(JT_HOME)\"" >> $(OUT) endif diff --git a/make/idea/template/ant.xml b/make/idea/template/ant.xml index 6e72e478cbc..f5274deb5bb 100644 --- a/make/idea/template/ant.xml +++ b/make/idea/template/ant.xml @@ -5,9 +5,8 @@ - + - diff --git a/make/idea/template/build.xml b/make/idea/template/build.xml index ed62f296726..b10490f77f1 100644 --- a/make/idea/template/build.xml +++ b/make/idea/template/build.xml @@ -16,6 +16,10 @@ + + + + @@ -29,26 +33,6 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + diff --git a/make/idea/template/src/idea/JdkIdeaAntLogger.java b/make/idea/template/src/idea/JdkIdeaAntLogger.java index 9913499e7a0..22d42a93805 100644 --- a/make/idea/template/src/idea/JdkIdeaAntLogger.java +++ b/make/idea/template/src/idea/JdkIdeaAntLogger.java @@ -99,7 +99,9 @@ public final class JdkIdeaAntLogger extends DefaultLogger { /** jtreg test failure */ JTREG_TEST_FAILED(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "FAILED: "), /** jtreg test error */ - JTREG_TEST_ERROR(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "Error: "); + JTREG_TEST_ERROR(StringBinaryPredicate.STARTS_WITH, MSG_ERR, "Error: "), + /** jtreg report */ + JTREG_TEST_REPORT(StringBinaryPredicate.STARTS_WITH, MSG_INFO, "Report written"); StringBinaryPredicate sbp; int priority; @@ -132,7 +134,7 @@ public final class JdkIdeaAntLogger extends DefaultLogger { MAKE("exec", MessageKind.MAKE_ERROR, MessageKind.MAKE_WARNING, MessageKind.MAKE_NOTE, MessageKind.MAKE_OTHER, MessageKind.JAVAC_CRASH), /** jtreg task - invoked during test execution */ - JTREG("jtreg", MessageKind.JTREG_TEST_PASSED, MessageKind.JTREG_TEST_FAILED, MessageKind.JTREG_TEST_ERROR), + JTREG("jtreg", MessageKind.JTREG_TEST_PASSED, MessageKind.JTREG_TEST_FAILED, MessageKind.JTREG_TEST_ERROR, MessageKind.JTREG_TEST_REPORT), /** initial synthetic task when the logger is created */ ROOT("") { @Override diff --git a/make/idea/template/workspace.xml b/make/idea/template/workspace.xml index 2423c3d41fb..e6377dd53a2 100644 --- a/make/idea/template/workspace.xml +++ b/make/idea/template/workspace.xml @@ -8,6 +8,14 @@ + + + + + + +