From f78d8f1157f073d928092661db2d32e44ac98f2a Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Mon, 31 Jan 2011 17:48:21 -0800 Subject: [PATCH 001/105] 6354181: nsk.logging.stress.threads.scmhml001 fails assertion in "src/share/vm/oops/instanceKlass.cpp, 111" Reviewed-by: jrose, acorn --- hotspot/src/share/vm/ci/ciEnv.cpp | 17 ++++++++++------- hotspot/src/share/vm/ci/ciInstanceKlass.cpp | 1 + .../share/vm/classfile/loaderConstraints.cpp | 8 +++++++- .../src/share/vm/classfile/systemDictionary.cpp | 5 +++++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/hotspot/src/share/vm/ci/ciEnv.cpp b/hotspot/src/share/vm/ci/ciEnv.cpp index 55dfd0c78e2..521893b4929 100644 --- a/hotspot/src/share/vm/ci/ciEnv.cpp +++ b/hotspot/src/share/vm/ci/ciEnv.cpp @@ -412,13 +412,16 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass, fail_type = _unloaded_ciinstance_klass; } KlassHandle found_klass; - if (!require_local) { - klassOop kls = SystemDictionary::find_constrained_instance_or_array_klass( - sym, loader, KILL_COMPILE_ON_FATAL_(fail_type)); - found_klass = KlassHandle(THREAD, kls); - } else { - klassOop kls = SystemDictionary::find_instance_or_array_klass( - sym, loader, domain, KILL_COMPILE_ON_FATAL_(fail_type)); + { + MutexLocker ml(Compile_lock); + klassOop kls; + if (!require_local) { + kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, + KILL_COMPILE_ON_FATAL_(fail_type)); + } else { + kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, + KILL_COMPILE_ON_FATAL_(fail_type)); + } found_klass = KlassHandle(THREAD, kls); } diff --git a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp index 412f54f6e7f..8143649137e 100644 --- a/hotspot/src/share/vm/ci/ciInstanceKlass.cpp +++ b/hotspot/src/share/vm/ci/ciInstanceKlass.cpp @@ -46,6 +46,7 @@ ciInstanceKlass::ciInstanceKlass(KlassHandle h_k) : ciKlass(h_k), _non_static_fields(NULL) { assert(get_Klass()->oop_is_instance(), "wrong type"); + assert(get_instanceKlass()->is_loaded(), "must be at least loaded"); instanceKlass* ik = get_instanceKlass(); AccessFlags access_flags = ik->access_flags(); diff --git a/hotspot/src/share/vm/classfile/loaderConstraints.cpp b/hotspot/src/share/vm/classfile/loaderConstraints.cpp index 1cf77f9dab5..97ab80b3cae 100644 --- a/hotspot/src/share/vm/classfile/loaderConstraints.cpp +++ b/hotspot/src/share/vm/classfile/loaderConstraints.cpp @@ -322,8 +322,14 @@ bool LoaderConstraintTable::check_or_update(instanceKlassHandle k, klassOop LoaderConstraintTable::find_constrained_klass(Symbol* name, Handle loader) { LoaderConstraintEntry *p = *(find_loader_constraint(name, loader)); - if (p != NULL && p->klass() != NULL) + if (p != NULL && p->klass() != NULL) { + if (Klass::cast(p->klass())->oop_is_instance() && !instanceKlass::cast(p->klass())->is_loaded()) { + // Only return fully loaded classes. Classes found through the + // constraints might still be in the process of loading. + return NULL; + } return p->klass(); + } // No constraints, or else no klass loaded yet. return NULL; diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index 522de398db6..dfe58e18b2c 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -1690,6 +1690,8 @@ klassOop SystemDictionary::try_get_next_class() { void SystemDictionary::add_to_hierarchy(instanceKlassHandle k, TRAPS) { assert(k.not_null(), "just checking"); + assert_locked_or_safepoint(Compile_lock); + // Link into hierachy. Make sure the vtables are initialized before linking into k->append_to_sibling_list(); // add to superklass/sibling list k->process_interfaces(THREAD); // handle all "implements" declarations @@ -2152,6 +2154,9 @@ void SystemDictionary::update_dictionary(int d_index, unsigned int d_hash, } +// Try to find a class name using the loader constraints. The +// loader constraints might know about a class that isn't fully loaded +// yet and these will be ignored. klassOop SystemDictionary::find_constrained_instance_or_array_klass( Symbol* class_name, Handle class_loader, TRAPS) { From 561c090437b0c2619e801538222263e238fdb642 Mon Sep 17 00:00:00 2001 From: Christian Thalinger Date: Tue, 1 Feb 2011 03:38:44 -0800 Subject: [PATCH 002/105] 7009309: JSR 292: compiler/6991596/Test6991596.java crashes on fastdebug JDK7/b122 Reviewed-by: kvn, never --- .../sun/jvm/hotspot/runtime/StubRoutines.java | 28 +-------- hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp | 12 +--- hotspot/src/cpu/x86/vm/interpreter_x86.hpp | 10 +--- hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp | 5 +- .../src/cpu/x86/vm/sharedRuntime_x86_32.cpp | 55 +----------------- .../src/cpu/x86/vm/sharedRuntime_x86_64.cpp | 11 +--- .../src/cpu/x86/vm/stubGenerator_x86_32.cpp | 58 ++++++++----------- .../src/cpu/x86/vm/stubRoutines_x86_32.cpp | 7 +-- .../src/cpu/x86/vm/stubRoutines_x86_32.hpp | 14 +---- .../cpu/x86/vm/templateInterpreter_x86_32.cpp | 12 +--- .../cpu/x86/vm/templateInterpreter_x86_64.cpp | 8 +-- .../src/cpu/x86/vm/templateTable_x86_32.cpp | 33 ----------- hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp | 6 +- hotspot/src/cpu/zero/vm/stubRoutines_zero.hpp | 11 +--- hotspot/src/share/vm/runtime/vmStructs.cpp | 1 - 15 files changed, 41 insertions(+), 230 deletions(-) diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java index 984161314f9..9de5f3005aa 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/runtime/StubRoutines.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -31,8 +31,7 @@ import sun.jvm.hotspot.types.*; /** Very minimal port for now to get frames working */ public class StubRoutines { - private static AddressField callStubReturnAddressField; - private static AddressField callStubCompiledReturnAddressField; + private static AddressField callStubReturnAddressField; static { VM.registerVMInitializedObserver(new Observer() { @@ -44,20 +43,7 @@ public class StubRoutines { private static synchronized void initialize(TypeDataBase db) { Type type = db.lookupType("StubRoutines"); - callStubReturnAddressField = type.getAddressField("_call_stub_return_address"); - // Only some platforms have specific return from compiled to call_stub - try { - type = db.lookupType("StubRoutines::x86"); - if (type != null) { - callStubCompiledReturnAddressField = type.getAddressField("_call_stub_compiled_return"); - } - } catch (RuntimeException re) { - callStubCompiledReturnAddressField = null; - } - if (callStubCompiledReturnAddressField == null && VM.getVM().getCPU().equals("x86")) { - throw new InternalError("Missing definition for _call_stub_compiled_return"); - } } public StubRoutines() { @@ -65,20 +51,10 @@ public class StubRoutines { public boolean returnsToCallStub(Address returnPC) { Address addr = callStubReturnAddressField.getValue(); - boolean result = false; - if (addr == null) { - result = (addr == returnPC); - } else { - result = addr.equals(returnPC); - } - if (result || callStubCompiledReturnAddressField == null ) return result; - // Could be a return to compiled code return point - addr = callStubCompiledReturnAddressField.getValue(); if (addr == null) { return (addr == returnPC); } else { return (addr.equals(returnPC)); } - } } diff --git a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp index 936bde4d811..79bff4838a8 100644 --- a/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp +++ b/hotspot/src/cpu/x86/vm/cppInterpreter_x86.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -1899,8 +1899,6 @@ address InterpreterGenerator::generate_normal_entry(bool synchronized) { Label do_double; Label done_conv; - address compiled_entry = __ pc(); - // The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases if (UseSSE < 2) { __ lea(state, Address(rbp, -(int)sizeof(BytecodeInterpreter))); @@ -1934,15 +1932,7 @@ address InterpreterGenerator::generate_normal_entry(bool synchronized) { __ jmp(done_conv); } -#if 0 - // emit a sentinel we can test for when converting an interpreter - // entry point to a compiled entry point. - __ a_long(Interpreter::return_sentinel); - __ a_long((int)compiled_entry); -#endif - // Return point to interpreter from compiled/native method - InternalAddress return_from_native_method(__ pc()); __ bind(done_conv); diff --git a/hotspot/src/cpu/x86/vm/interpreter_x86.hpp b/hotspot/src/cpu/x86/vm/interpreter_x86.hpp index 105a4038ced..f3ff867b893 100644 --- a/hotspot/src/cpu/x86/vm/interpreter_x86.hpp +++ b/hotspot/src/cpu/x86/vm/interpreter_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -26,14 +26,6 @@ #define CPU_X86_VM_INTERPRETER_X86_HPP public: - - // Sentinel placed in the code for interpreter returns so - // that i2c adapters and osr code can recognize an interpreter - // return address and convert the return to a specialized - // block of code to handle compiedl return values and cleaning - // the fpu stack. - static const int return_sentinel; - static Address::ScaleFactor stackElementScale() { return Address::times_4; } // Offset from rsp (which points to the last stack element) diff --git a/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp b/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp index d5424c63c58..20abf49e441 100644 --- a/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/interpreter_x86_32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -51,9 +51,6 @@ #define __ _masm-> -// Initialize the sentinel used to distinguish an interpreter return address. -const int Interpreter::return_sentinel = 0xfeedbeed; - //------------------------------------------------------------------------------------------------------------------------ address AbstractInterpreterGenerator::generate_slow_signature_handler() { diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp index 9a1f72af1ab..181d4c2c62c 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -660,25 +660,6 @@ static void gen_i2c_adapter(MacroAssembler *masm, int comp_args_on_stack, const BasicType *sig_bt, const VMRegPair *regs) { - // we're being called from the interpreter but need to find the - // compiled return entry point. The return address on the stack - // should point at it and we just need to pull the old value out. - // load up the pointer to the compiled return entry point and - // rewrite our return pc. The code is arranged like so: - // - // .word Interpreter::return_sentinel - // .word address_of_compiled_return_point - // return_entry_point: blah_blah_blah - // - // So we can find the appropriate return point by loading up the word - // just prior to the current return address we have on the stack. - // - // We will only enter here from an interpreted frame and never from after - // passing thru a c2i. Azul allowed this but we do not. If we lose the - // race and use a c2i we will remain interpreted for the race loser(s). - // This removes all sorts of headaches on the x86 side and also eliminates - // the possibility of having c2i -> i2c -> c2i -> ... endless transitions. - // Note: rsi contains the senderSP on entry. We must preserve it since // we may do a i2c -> c2i transition if we lose a race where compiled @@ -687,40 +668,6 @@ static void gen_i2c_adapter(MacroAssembler *masm, // Pick up the return address __ movptr(rax, Address(rsp, 0)); - // If UseSSE >= 2 then no cleanup is needed on the return to the - // interpreter so skip fixing up the return entry point unless - // VerifyFPU is enabled. - if (UseSSE < 2 || VerifyFPU) { - Label skip, chk_int; - // If we were called from the call stub we need to do a little bit different - // cleanup than if the interpreter returned to the call stub. - - ExternalAddress stub_return_address(StubRoutines::_call_stub_return_address); - __ cmpptr(rax, stub_return_address.addr()); - __ jcc(Assembler::notEqual, chk_int); - assert(StubRoutines::x86::get_call_stub_compiled_return() != NULL, "must be set"); - __ lea(rax, ExternalAddress(StubRoutines::x86::get_call_stub_compiled_return())); - __ jmp(skip); - - // It must be the interpreter since we never get here via a c2i (unlike Azul) - - __ bind(chk_int); -#ifdef ASSERT - { - Label ok; - __ cmpl(Address(rax, -2*wordSize), Interpreter::return_sentinel); - __ jcc(Assembler::equal, ok); - __ int3(); - __ bind(ok); - } -#endif // ASSERT - __ movptr(rax, Address(rax, -wordSize)); - __ bind(skip); - } - - // rax, now contains the compiled return entry point which will do an - // cleanup needed for the return from compiled to interpreted. - // Must preserve original SP for loading incoming arguments because // we need to align the outgoing SP for compiled code. __ movptr(rdi, rsp); diff --git a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp index d26e69f3b43..dea7fb948da 100644 --- a/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/sharedRuntime_x86_64.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -610,14 +610,6 @@ static void gen_i2c_adapter(MacroAssembler *masm, const BasicType *sig_bt, const VMRegPair *regs) { - // - // We will only enter here from an interpreted frame and never from after - // passing thru a c2i. Azul allowed this but we do not. If we lose the - // race and use a c2i we will remain interpreted for the race loser(s). - // This removes all sorts of headaches on the x86 side and also eliminates - // the possibility of having c2i -> i2c -> c2i -> ... endless transitions. - - // Note: r13 contains the senderSP on entry. We must preserve it since // we may do a i2c -> c2i transition if we lose a race where compiled // code goes non-entrant while we get args ready. @@ -627,6 +619,7 @@ static void gen_i2c_adapter(MacroAssembler *masm, // save code can segv when fxsave instructions find improperly // aligned stack pointer. + // Pick up the return address __ movptr(rax, Address(rsp, 0)); // Must preserve original SP for loading incoming arguments because diff --git a/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp b/hotspot/src/cpu/x86/vm/stubGenerator_x86_32.cpp index c3cf3f84835..9a7371cf6dd 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, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -240,9 +240,30 @@ class StubGenerator: public StubCodeGenerator { BLOCK_COMMENT("call_stub_return_address:"); return_address = __ pc(); - Label common_return; +#ifdef COMPILER2 + { + Label L_skip; + if (UseSSE >= 2) { + __ verify_FPU(0, "call_stub_return"); + } else { + for (int i = 1; i < 8; i++) { + __ ffree(i); + } - __ BIND(common_return); + // UseSSE <= 1 so double result should be left on TOS + __ movl(rsi, result_type); + __ cmpl(rsi, T_DOUBLE); + __ jcc(Assembler::equal, L_skip); + if (UseSSE == 0) { + // UseSSE == 0 so float result should be left on TOS + __ cmpl(rsi, T_FLOAT); + __ jcc(Assembler::equal, L_skip); + } + __ ffree(0); + } + __ BIND(L_skip); + } +#endif // COMPILER2 // store result depending on type // (everything that is not T_LONG, T_FLOAT or T_DOUBLE is treated as T_INT) @@ -305,37 +326,6 @@ class StubGenerator: public StubCodeGenerator { } __ jmp(exit); - // If we call compiled code directly from the call stub we will - // need to adjust the return back to the call stub to a specialized - // piece of code that can handle compiled results and cleaning the fpu - // stack. compiled code will be set to return here instead of the - // return above that handles interpreter returns. - - BLOCK_COMMENT("call_stub_compiled_return:"); - StubRoutines::x86::set_call_stub_compiled_return( __ pc()); - -#ifdef COMPILER2 - if (UseSSE >= 2) { - __ verify_FPU(0, "call_stub_compiled_return"); - } else { - for (int i = 1; i < 8; i++) { - __ ffree(i); - } - - // UseSSE <= 1 so double result should be left on TOS - __ movl(rsi, result_type); - __ cmpl(rsi, T_DOUBLE); - __ jcc(Assembler::equal, common_return); - if (UseSSE == 0) { - // UseSSE == 0 so float result should be left on TOS - __ cmpl(rsi, T_FLOAT); - __ jcc(Assembler::equal, common_return); - } - __ ffree(0); - } -#endif /* COMPILER2 */ - __ jmp(common_return); - return start; } diff --git a/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.cpp b/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.cpp index a04b3f29a1a..dfdab6f0038 100644 --- a/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -39,6 +39,5 @@ // Implementation of the platform-specific part of StubRoutines - for // a description of how to extend it, see the stubRoutines.hpp file. -address StubRoutines::x86::_verify_mxcsr_entry = NULL; -address StubRoutines::x86::_verify_fpu_cntrl_wrd_entry= NULL; -address StubRoutines::x86::_call_stub_compiled_return = NULL; +address StubRoutines::x86::_verify_mxcsr_entry = NULL; +address StubRoutines::x86::_verify_fpu_cntrl_wrd_entry = NULL; diff --git a/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.hpp b/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.hpp index 0a78618e1b0..283274e3dde 100644 --- a/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.hpp +++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86_32.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -44,24 +44,14 @@ class x86 { friend class VMStructs; private: - // If we call compiled code directly from the call stub we will - // need to adjust the return back to the call stub to a specialized - // piece of code that can handle compiled results and cleaning the fpu - // stack. The variable holds that location. - static address _call_stub_compiled_return; static address _verify_mxcsr_entry; static address _verify_fpu_cntrl_wrd_entry; - static jint _mxcsr_std; public: static address verify_mxcsr_entry() { return _verify_mxcsr_entry; } static address verify_fpu_cntrl_wrd_entry() { return _verify_fpu_cntrl_wrd_entry; } - - static address get_call_stub_compiled_return() { return _call_stub_compiled_return; } - static void set_call_stub_compiled_return(address ret) { _call_stub_compiled_return = ret; } }; - static bool returns_to_call_stub(address return_pc) { return (return_pc == _call_stub_return_address) || - return_pc == x86::get_call_stub_compiled_return(); } + static bool returns_to_call_stub(address return_pc) { return return_pc == _call_stub_return_address; } #endif // CPU_X86_VM_STUBROUTINES_X86_32_HPP diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp index 74c4b6e3fb9..c3f20290e2b 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_32.cpp @@ -177,9 +177,7 @@ address TemplateInterpreterGenerator::generate_continuation_for(TosState state) address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step) { TosState incoming_state = state; - - Label interpreter_entry; - address compiled_entry = __ pc(); + address entry = __ pc(); #ifdef COMPILER2 // The FPU stack is clean if UseSSE >= 2 but must be cleaned in other cases @@ -197,14 +195,6 @@ address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, __ MacroAssembler::verify_FPU(0, "generate_return_entry_for compiled"); } - __ jmp(interpreter_entry, relocInfo::none); - // emit a sentinel we can test for when converting an interpreter - // entry point to a compiled entry point. - __ a_long(Interpreter::return_sentinel); - __ a_long((int)compiled_entry); - address entry = __ pc(); - __ bind(interpreter_entry); - // In SSE mode, interpreter returns FP results in xmm0 but they need // to end up back on the FPU so it can operate on them. if (incoming_state == ftos && UseSSE >= 1) { diff --git a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp index 8191a23878b..69ea49e8a88 100644 --- a/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp +++ b/hotspot/src/cpu/x86/vm/templateInterpreter_x86_64.cpp @@ -190,13 +190,7 @@ address TemplateInterpreterGenerator::generate_continuation_for(TosState state) } -address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, - int step) { - - // amd64 doesn't need to do anything special about compiled returns - // to the interpreter so the code that exists on x86 to place a sentinel - // here and the specialized cleanup code is not needed here. - +address TemplateInterpreterGenerator::generate_return_entry_for(TosState state, int step) { address entry = __ pc(); // Restore stack bottom in case i2c adjusted stack diff --git a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp index 844a32d7ab3..742b20443c9 100644 --- a/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp +++ b/hotspot/src/cpu/x86/vm/templateTable_x86_32.cpp @@ -1710,39 +1710,6 @@ void TemplateTable::branch(bool is_jsr, bool is_wide) { __ pop(rdi); // get return address __ mov(rsp, rdx); // set sp to sender sp - - Label skip; - Label chkint; - - // The interpreter frame we have removed may be returning to - // either the callstub or the interpreter. Since we will - // now be returning from a compiled (OSR) nmethod we must - // adjust the return to the return were it can handler compiled - // results and clean the fpu stack. This is very similar to - // what a i2c adapter must do. - - // Are we returning to the call stub? - - __ cmp32(rdi, ExternalAddress(StubRoutines::_call_stub_return_address)); - __ jcc(Assembler::notEqual, chkint); - - // yes adjust to the specialized call stub return. - assert(StubRoutines::x86::get_call_stub_compiled_return() != NULL, "must be set"); - __ lea(rdi, ExternalAddress(StubRoutines::x86::get_call_stub_compiled_return())); - __ jmp(skip); - - __ bind(chkint); - - // Are we returning to the interpreter? Look for sentinel - - __ cmpl(Address(rdi, -2*wordSize), Interpreter::return_sentinel); - __ jcc(Assembler::notEqual, skip); - - // Adjust to compiled return back to interpreter - - __ movptr(rdi, Address(rdi, -wordSize)); - __ bind(skip); - // Align stack pointer for compiled code (note that caller is // responsible for undoing this fixup by remembering the old SP // in an rbp,-relative location) diff --git a/hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp b/hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp index 4a8c7cb9329..96df53e0f5a 100644 --- a/hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp +++ b/hotspot/src/cpu/zero/vm/stubRoutines_zero.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright 2008, 2009 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -30,7 +30,3 @@ #ifdef TARGET_OS_FAMILY_linux # include "thread_linux.inline.hpp" #endif - -#ifdef IA32 -address StubRoutines::x86::_call_stub_compiled_return = NULL; -#endif // IA32 diff --git a/hotspot/src/cpu/zero/vm/stubRoutines_zero.hpp b/hotspot/src/cpu/zero/vm/stubRoutines_zero.hpp index d4d521b4bc4..cee7d14b95f 100644 --- a/hotspot/src/cpu/zero/vm/stubRoutines_zero.hpp +++ b/hotspot/src/cpu/zero/vm/stubRoutines_zero.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, 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. * @@ -48,13 +48,4 @@ method_handles_adapters_code_size = 0 }; -#ifdef IA32 - class x86 { - friend class VMStructs; - - private: - static address _call_stub_compiled_return; - }; -#endif // IA32 - #endif // CPU_ZERO_VM_STUBROUTINES_ZERO_HPP diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index bdcbbfd2581..1352c8701ed 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -729,7 +729,6 @@ static inline uint64_t cast_uint64_t(size_t x) /***********************************/ \ \ static_field(StubRoutines, _call_stub_return_address, address) \ - IA32_ONLY(static_field(StubRoutines::x86,_call_stub_compiled_return, address)) \ \ /***************************************/ \ /* PcDesc and other compiled code info */ \ From 6baa3e1f5666cdd41ac6480a56747c6e61aba843 Mon Sep 17 00:00:00 2001 From: Christian Thalinger Date: Tue, 1 Feb 2011 05:51:24 -0800 Subject: [PATCH 003/105] 7012339: JSR 292 crash in G1SATBCardTableModRefBS::write_ref_field_pre_work() Reviewed-by: jrose, never --- hotspot/src/share/vm/oops/cpCacheOop.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hotspot/src/share/vm/oops/cpCacheOop.cpp b/hotspot/src/share/vm/oops/cpCacheOop.cpp index e627a250b51..438fb7ef1e6 100644 --- a/hotspot/src/share/vm/oops/cpCacheOop.cpp +++ b/hotspot/src/share/vm/oops/cpCacheOop.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -98,15 +98,15 @@ void ConstantPoolCacheEntry::set_bytecode_2(Bytecodes::Code code) { // Atomically sets f1 if it is still NULL, otherwise it keeps the // current value. void ConstantPoolCacheEntry::set_f1_if_null_atomic(oop f1) { - // Use barriers as in oop_store - HeapWord* f1_addr = (HeapWord*) &_f1; - update_barrier_set_pre(f1_addr, f1); - void* result = Atomic::cmpxchg_ptr(f1, f1_addr, NULL); - bool success = (result == NULL); - if (success) { - update_barrier_set((void*) f1_addr, f1); - } + // Use barriers as in oop_store + oop* f1_addr = (oop*) &_f1; + update_barrier_set_pre(f1_addr, f1); + void* result = Atomic::cmpxchg_ptr(f1, f1_addr, NULL); + bool success = (result == NULL); + if (success) { + update_barrier_set(f1_addr, f1); } +} #ifdef ASSERT // It is possible to have two different dummy methodOops created From f743a9db849f0e320e93510d283514ad40f3da66 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Tue, 1 Feb 2011 10:27:02 -0800 Subject: [PATCH 004/105] 7014998: assert(is_T_family(features) == is_niagara(features)) failed: Niagara should be T series Use substring search instead of compare and convert string to upper case before search. Reviewed-by: never, phh, iveresov --- .../vm/vm_version_solaris_sparc.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp index 855e9a965f1..31f86cfaf52 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/vm_version_solaris_sparc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -189,14 +189,22 @@ int VM_Version::platform_features(int features) { tty->print_cr("cpu_info.implementation: %s", implementation); } #endif - if (strncmp(implementation, "SPARC64", 7) == 0) { + // Convert to UPPER case before compare. + char* impl = strdup(implementation); + + for (int i = 0; impl[i] != 0; i++) + impl[i] = (char)toupper((uint)impl[i]); + if (strstr(impl, "SPARC64") != NULL) { features |= sparc64_family_m; - } else if (strncmp(implementation, "UltraSPARC-T", 12) == 0) { + } else if (strstr(impl, "SPARC-T") != NULL) { features |= T_family_m; - if (strncmp(implementation, "UltraSPARC-T1", 13) == 0) { + if (strstr(impl, "SPARC-T1") != NULL) { features |= T1_model_m; } + } else { + assert(strstr(impl, "SPARC") != NULL, "should be sparc"); } + free((void*)impl); break; } } // for( From 60418bbde39724e57b0449b16e156fe55ef43a9a Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Thu, 3 Feb 2011 20:49:09 -0800 Subject: [PATCH 005/105] 7015169: GC Cause not always set Sometimes the gc cause was not always set. This caused JStat to print the wrong information. Reviewed-by: tonyp, ysr --- .../concurrentMarkSweep/vmCMSOperations.hpp | 5 ++-- .../gc_implementation/g1/vm_operations_g1.hpp | 8 +++--- .../parallelScavenge/vmPSOperations.cpp | 9 +++---- .../shared/vmGCOperations.cpp | 4 ++- .../shared/vmGCOperations.hpp | 15 ++++++----- hotspot/src/share/vm/gc_interface/gcCause.cpp | 27 +------------------ hotspot/src/share/vm/gc_interface/gcCause.hpp | 4 +-- hotspot/src/share/vm/services/heapDumper.cpp | 3 ++- 8 files changed, 24 insertions(+), 51 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp index 8c2fc490a2f..51d6e208875 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -132,8 +132,7 @@ class VM_GenCollectFullConcurrent: public VM_GC_Operation { VM_GenCollectFullConcurrent(unsigned int gc_count_before, unsigned int full_gc_count_before, GCCause::Cause gc_cause) - : VM_GC_Operation(gc_count_before, full_gc_count_before, true /* full */) { - _gc_cause = gc_cause; + : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */) { assert(FullGCCount_lock != NULL, "Error"); assert(UseAsyncConcMarkSweepGC, "Else will hang caller"); } diff --git a/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.hpp b/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.hpp index 1fc31d51dc4..825818dd4e6 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/vm_operations_g1.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -44,7 +44,7 @@ protected: public: VM_G1OperationWithAllocRequest(unsigned int gc_count_before, size_t word_size) - : VM_GC_Operation(gc_count_before), + : VM_GC_Operation(gc_count_before, GCCause::_allocation_failure), _word_size(word_size), _result(NULL), _pause_succeeded(false) { } HeapWord* result() { return _result; } bool pause_succeeded() { return _pause_succeeded; } @@ -55,9 +55,7 @@ public: VM_G1CollectFull(unsigned int gc_count_before, unsigned int full_gc_count_before, GCCause::Cause cause) - : VM_GC_Operation(gc_count_before, full_gc_count_before) { - _gc_cause = cause; - } + : VM_GC_Operation(gc_count_before, cause, full_gc_count_before) { } virtual VMOp_Type type() const { return VMOp_G1CollectFull; } virtual void doit(); virtual const char* name() const { diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp index 0f122a97b57..8a8419fef7f 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/vmPSOperations.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -34,7 +34,7 @@ // The following methods are used by the parallel scavenge collector VM_ParallelGCFailedAllocation::VM_ParallelGCFailedAllocation(size_t size, bool is_tlab, unsigned int gc_count) : - VM_GC_Operation(gc_count), + VM_GC_Operation(gc_count, GCCause::_allocation_failure), _size(size), _is_tlab(is_tlab), _result(NULL) @@ -57,7 +57,7 @@ void VM_ParallelGCFailedAllocation::doit() { VM_ParallelGCFailedPermanentAllocation::VM_ParallelGCFailedPermanentAllocation(size_t size, unsigned int gc_count, unsigned int full_gc_count) : - VM_GC_Operation(gc_count, full_gc_count, true /* full */), + VM_GC_Operation(gc_count, GCCause::_allocation_failure, full_gc_count, true /* full */), _size(size), _result(NULL) { @@ -80,9 +80,8 @@ void VM_ParallelGCFailedPermanentAllocation::doit() { VM_ParallelGCSystemGC::VM_ParallelGCSystemGC(unsigned int gc_count, unsigned int full_gc_count, GCCause::Cause gc_cause) : - VM_GC_Operation(gc_count, full_gc_count, true /* full */) + VM_GC_Operation(gc_count, gc_cause, full_gc_count, true /* full */) { - _gc_cause = gc_cause; } void VM_ParallelGCSystemGC::doit() { diff --git a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp index 5799550d114..0828c9ca7c2 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -87,6 +87,8 @@ bool VM_GC_Operation::skip_operation() const { bool VM_GC_Operation::doit_prologue() { assert(Thread::current()->is_Java_thread(), "just checking"); + assert(((_gc_cause != GCCause::_no_gc) && + (_gc_cause != GCCause::_no_cause_specified)), "Illegal GCCause"); acquire_pending_list_lock(); // If the GC count has changed someone beat us to the collection diff --git a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp index 1a828facadc..a7dd82ca4a5 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -85,6 +85,7 @@ class VM_GC_Operation: public VM_Operation { public: VM_GC_Operation(unsigned int gc_count_before, + GCCause::Cause _cause, unsigned int full_gc_count_before = 0, bool full = false) { _full = full; @@ -92,7 +93,7 @@ class VM_GC_Operation: public VM_Operation { _gc_count_before = gc_count_before; // A subclass constructor will likely overwrite the following - _gc_cause = GCCause::_no_cause_specified; + _gc_cause = _cause; _gc_locked = false; @@ -136,6 +137,7 @@ class VM_GC_HeapInspection: public VM_GC_Operation { VM_GC_HeapInspection(outputStream* out, bool request_full_gc, bool need_prologue) : VM_GC_Operation(0 /* total collections, dummy, ignored */, + GCCause::_heap_inspection /* GC Cause */, 0 /* total full collections, dummy, ignored */, request_full_gc) { _out = out; @@ -160,7 +162,7 @@ class VM_GenCollectForAllocation: public VM_GC_Operation { VM_GenCollectForAllocation(size_t size, bool tlab, unsigned int gc_count_before) - : VM_GC_Operation(gc_count_before), + : VM_GC_Operation(gc_count_before, GCCause::_allocation_failure), _size(size), _tlab(tlab) { _res = NULL; @@ -182,9 +184,8 @@ class VM_GenCollectFull: public VM_GC_Operation { unsigned int full_gc_count_before, GCCause::Cause gc_cause, int max_level) - : VM_GC_Operation(gc_count_before, full_gc_count_before, true /* full */), - _max_level(max_level) - { _gc_cause = gc_cause; } + : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */), + _max_level(max_level) { } ~VM_GenCollectFull() {} virtual VMOp_Type type() const { return VMOp_GenCollectFull; } virtual void doit(); @@ -199,7 +200,7 @@ class VM_GenCollectForPermanentAllocation: public VM_GC_Operation { unsigned int gc_count_before, unsigned int full_gc_count_before, GCCause::Cause gc_cause) - : VM_GC_Operation(gc_count_before, full_gc_count_before, true), + : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true), _size(size) { _res = NULL; _gc_cause = gc_cause; diff --git a/hotspot/src/share/vm/gc_interface/gcCause.cpp b/hotspot/src/share/vm/gc_interface/gcCause.cpp index 5868cd9c958..358b6b19e2f 100644 --- a/hotspot/src/share/vm/gc_interface/gcCause.cpp +++ b/hotspot/src/share/vm/gc_interface/gcCause.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -92,28 +92,3 @@ const char* GCCause::to_string(GCCause::Cause cause) { } ShouldNotReachHere(); } - -#ifndef PRODUCT - -bool GCCause::is_for_full_collection(GCCause::Cause cause) { - bool result; - - // There are more GCCause::Cause types than listed here. - // For brevity, we list only those that cause full collections. - switch (cause) { - case _allocation_failure: - case _tenured_generation_full: - case _permanent_generation_full: - case _cms_generation_full: - case _last_ditch_collection: - result = true; - break; - - default: - result = false; - break; - } - return result; -} - -#endif // PRODUCT diff --git a/hotspot/src/share/vm/gc_interface/gcCause.hpp b/hotspot/src/share/vm/gc_interface/gcCause.hpp index af40d989350..fc49e306bbc 100644 --- a/hotspot/src/share/vm/gc_interface/gcCause.hpp +++ b/hotspot/src/share/vm/gc_interface/gcCause.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -85,8 +85,6 @@ class GCCause : public AllStatic { // Return a string describing the GCCause. static const char* to_string(GCCause::Cause cause); - // Return true if the GCCause is for a full collection. - static bool is_for_full_collection(GCCause::Cause cause) PRODUCT_RETURN0; }; #endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP diff --git a/hotspot/src/share/vm/services/heapDumper.cpp b/hotspot/src/share/vm/services/heapDumper.cpp index be1b778242f..62c4756a040 100644 --- a/hotspot/src/share/vm/services/heapDumper.cpp +++ b/hotspot/src/share/vm/services/heapDumper.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -1397,6 +1397,7 @@ class VM_HeapDumper : public VM_GC_Operation { public: VM_HeapDumper(DumpWriter* writer, bool gc_before_heap_dump, bool oome) : VM_GC_Operation(0 /* total collections, dummy, ignored */, + GCCause::_heap_dump /* GC Cause */, 0 /* total full collections, dummy, ignored */, gc_before_heap_dump) { _local_writer = writer; From 947318a06f2a7084f2ff766698ca1284e6379c37 Mon Sep 17 00:00:00 2001 From: Jennifer Godinez Date: Fri, 4 Feb 2011 11:46:37 -0800 Subject: [PATCH 006/105] 7014796: Regression test java/awt/PrintJob/Text/stringwidth.sh cannot be terminated on Windows Reviewed-by: prr --- jdk/test/java/awt/PrintJob/Text/StringWidth.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdk/test/java/awt/PrintJob/Text/StringWidth.java b/jdk/test/java/awt/PrintJob/Text/StringWidth.java index 4c2250a21dd..e16229eba27 100644 --- a/jdk/test/java/awt/PrintJob/Text/StringWidth.java +++ b/jdk/test/java/awt/PrintJob/Text/StringWidth.java @@ -63,7 +63,8 @@ public class StringWidth extends Frame { } public static void main(String[] args) { - new StringWidth(); + StringWidth sw = new StringWidth(); + sw.dispose(); } } From 0b8033ccf3591b27fbf0d348a5c0f00b4ad686a1 Mon Sep 17 00:00:00 2001 From: Jennifer Godinez Date: Fri, 4 Feb 2011 11:48:51 -0800 Subject: [PATCH 007/105] 6995147: Case needs to be update. ServiceDialogTest.java failed as compilation error Reviewed-by: prr --- jdk/test/javax/print/attribute/ServiceDialogTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/test/javax/print/attribute/ServiceDialogTest.java b/jdk/test/javax/print/attribute/ServiceDialogTest.java index e5b6d2d969b..184c8c0687c 100644 --- a/jdk/test/javax/print/attribute/ServiceDialogTest.java +++ b/jdk/test/javax/print/attribute/ServiceDialogTest.java @@ -71,7 +71,7 @@ public class ServiceDialogTest { if (factories.length > 0) { services[0] = factories[0].getPrintService(fos); } else { - throw new RuntimeException("No StreamPrintService available which would support "+flavor"); + throw new RuntimeException("No StreamPrintService available which would support "+flavor); } services[2] = new TestPrintService("Test Printer"); From c00a50c8e99eaf71357ef0a05e69a0292309568f Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Mon, 7 Feb 2011 09:46:01 -0800 Subject: [PATCH 008/105] 7017240: C2: native memory leak in nsk/regression/b4675027 on windows-x86 in comp mode with G1 Add ResourceMark into PhaseIdealLoop::build_and_optimize(). Reviewed-by: never --- hotspot/src/share/vm/opto/loopnode.cpp | 6 ++++-- hotspot/src/share/vm/opto/loopnode.hpp | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hotspot/src/share/vm/opto/loopnode.cpp b/hotspot/src/share/vm/opto/loopnode.cpp index 785ef443985..204eeea65b8 100644 --- a/hotspot/src/share/vm/opto/loopnode.cpp +++ b/hotspot/src/share/vm/opto/loopnode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -1480,6 +1480,8 @@ void PhaseIdealLoop::eliminate_useless_predicates() { // Create a PhaseLoop. Build the ideal Loop tree. Map each Ideal Node to // its corresponding LoopNode. If 'optimize' is true, do some loop cleanups. void PhaseIdealLoop::build_and_optimize(bool do_split_ifs, bool do_loop_pred) { + ResourceMark rm; + int old_progress = C->major_progress(); // Reset major-progress flag for the driver's heuristics @@ -2013,7 +2015,7 @@ void PhaseIdealLoop::recompute_dom_depth() { if (_dom_stk == NULL) { uint init_size = C->unique() / 100; // Guess that 1/100 is a reasonable initial size. if (init_size < 10) init_size = 10; - _dom_stk = new (C->node_arena()) GrowableArray(C->node_arena(), init_size, 0, 0); + _dom_stk = new GrowableArray(init_size); } // Compute new depth for each node. for (i = 0; i < _idom_size; i++) { diff --git a/hotspot/src/share/vm/opto/loopnode.hpp b/hotspot/src/share/vm/opto/loopnode.hpp index f11b7c94233..7f44acccf63 100644 --- a/hotspot/src/share/vm/opto/loopnode.hpp +++ b/hotspot/src/share/vm/opto/loopnode.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -700,7 +700,7 @@ private: PhaseIdealLoop( PhaseIterGVN &igvn) : PhaseTransform(Ideal_Loop), _igvn(igvn), - _dom_lca_tags(C->comp_arena()), + _dom_lca_tags(arena()), // Thread::resource_area _verify_me(NULL), _verify_only(true) { build_and_optimize(false, false); @@ -721,7 +721,7 @@ public: PhaseIdealLoop( PhaseIterGVN &igvn, bool do_split_ifs, bool do_loop_pred) : PhaseTransform(Ideal_Loop), _igvn(igvn), - _dom_lca_tags(C->comp_arena()), + _dom_lca_tags(arena()), // Thread::resource_area _verify_me(NULL), _verify_only(false) { build_and_optimize(do_split_ifs, do_loop_pred); @@ -731,7 +731,7 @@ public: PhaseIdealLoop( PhaseIterGVN &igvn, const PhaseIdealLoop *verify_me) : PhaseTransform(Ideal_Loop), _igvn(igvn), - _dom_lca_tags(C->comp_arena()), + _dom_lca_tags(arena()), // Thread::resource_area _verify_me(verify_me), _verify_only(false) { build_and_optimize(false, false); From e7c3086ed3b56f81f7b88299c24cdad7ef45b21b Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Mon, 7 Feb 2011 10:25:39 -0800 Subject: [PATCH 009/105] 7013538: Java memory leak with escape analysis Don't allocate VectorSet iterator on C heap. Reuse resource storage in EA. Reviewed-by: never --- hotspot/src/share/vm/libadt/vectset.cpp | 23 +----- hotspot/src/share/vm/libadt/vectset.hpp | 32 ++++---- hotspot/src/share/vm/opto/escape.cpp | 97 ++++++++++--------------- hotspot/src/share/vm/opto/escape.hpp | 19 +++-- hotspot/src/share/vm/opto/phase.cpp | 13 ++-- 5 files changed, 80 insertions(+), 104 deletions(-) diff --git a/hotspot/src/share/vm/libadt/vectset.cpp b/hotspot/src/share/vm/libadt/vectset.cpp index 1dd9f4e26e3..93cb48d69d5 100644 --- a/hotspot/src/share/vm/libadt/vectset.cpp +++ b/hotspot/src/share/vm/libadt/vectset.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -350,28 +350,11 @@ int VectorSet::hash() const return (int)_xor; } -//------------------------------iterate---------------------------------------- -SetI_ *VectorSet::iterate(uint &elem) const -{ - VSetI_ *foo = (new(ResourceObj::C_HEAP) VSetI_(this)); - elem = foo->next(); - return foo; -} - //============================================================================= -//------------------------------VSetI_----------------------------------------- -// Initialize the innards of a VectorSet iterator -VSetI_::VSetI_( const VectorSet *vset ) : s(vset) -{ - i = (uint)-1L; - j = (uint)-1L; - mask = (unsigned)(1L<<31); -} - //------------------------------next------------------------------------------- // Find and return the next element of a vector set, or return garbage and -// make "VSetI_::test()" fail. -uint VSetI_::next(void) +// make "VectorSetI::test()" fail. +uint VectorSetI::next(void) { j++; // Next element in word mask = (mask & max_jint) << 1;// Next bit in word diff --git a/hotspot/src/share/vm/libadt/vectset.hpp b/hotspot/src/share/vm/libadt/vectset.hpp index 22c97b2a22d..c184773ca15 100644 --- a/hotspot/src/share/vm/libadt/vectset.hpp +++ b/hotspot/src/share/vm/libadt/vectset.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -98,6 +98,9 @@ public: uint Size(void) const; // Number of elements in the Set. void Sort(void); // Sort before iterating int hash() const; // Hash function + void Reset(void) { // Reset a set + memset( data, 0, size*sizeof(uint32) ); + } /* Removed for MCC BUG operator const VectorSet* (void) const { return this; } */ @@ -148,8 +151,7 @@ public: private: - friend class VSetI_; - SetI_ *iterate(uint&) const; + SetI_ *iterate(uint&) const { ShouldNotCallThis(); return NULL; } // Removed }; //------------------------------Iteration-------------------------------------- @@ -158,22 +160,26 @@ private: // or may not be iterated over; untouched elements will be affected once. // Usage: for( VectorSetI i(s); i.test(); i++ ) { body = i.elem; } -class VSetI_ : public SetI_ { +class VectorSetI : public StackObj { friend class VectorSet; - friend class VectorSetI; const VectorSet *s; uint i, j; uint32 mask; - VSetI_(const VectorSet *vset); uint next(void); + +public: + uint elem; // The publically accessible element + + VectorSetI( const VectorSet *vset ) : + s(vset), + i((uint)-1L), + j((uint)-1L), + mask((unsigned)(1L<<31)) { + elem = next(); + } + + void operator ++(void) { elem = next(); } int test(void) { return i < s->size; } }; -class VectorSetI : public SetI { -public: - VectorSetI( const VectorSet *s ) : SetI(s) { } - void operator ++(void) { elem = ((VSetI_*)impl)->next(); } - int test(void) { return ((VSetI_*)impl)->test(); } -}; - #endif // SHARE_VM_LIBADT_VECTSET_HPP diff --git a/hotspot/src/share/vm/opto/escape.cpp b/hotspot/src/share/vm/opto/escape.cpp index 62db164b520..788a79785bb 100644 --- a/hotspot/src/share/vm/opto/escape.cpp +++ b/hotspot/src/share/vm/opto/escape.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -93,6 +93,9 @@ void PointsToNode::dump(bool print_state) const { ConnectionGraph::ConnectionGraph(Compile * C, PhaseIterGVN *igvn) : _nodes(C->comp_arena(), C->unique(), C->unique(), PointsToNode()), _processed(C->comp_arena()), + pt_ptset(C->comp_arena()), + pt_visited(C->comp_arena()), + pt_worklist(C->comp_arena(), 4, 0, 0), _collecting(true), _progress(false), _compile(C), @@ -220,9 +223,7 @@ PointsToNode::EscapeState ConnectionGraph::escape_state(Node *n) { PointsToNode::EscapeState orig_es = es; // compute max escape state of anything this node could point to - VectorSet ptset(Thread::current()->resource_area()); - PointsTo(ptset, n); - for(VectorSetI i(&ptset); i.test() && es != PointsToNode::GlobalEscape; ++i) { + for(VectorSetI i(PointsTo(n)); i.test() && es != PointsToNode::GlobalEscape; ++i) { uint pt = i.elem; PointsToNode::EscapeState pes = ptnode_adr(pt)->escape_state(); if (pes > es) @@ -236,9 +237,10 @@ PointsToNode::EscapeState ConnectionGraph::escape_state(Node *n) { return es; } -void ConnectionGraph::PointsTo(VectorSet &ptset, Node * n) { - VectorSet visited(Thread::current()->resource_area()); - GrowableArray worklist; +VectorSet* ConnectionGraph::PointsTo(Node * n) { + pt_ptset.Reset(); + pt_visited.Reset(); + pt_worklist.clear(); #ifdef ASSERT Node *orig_n = n; @@ -249,8 +251,8 @@ void ConnectionGraph::PointsTo(VectorSet &ptset, Node * n) { // If we have a JavaObject, return just that object if (npt->node_type() == PointsToNode::JavaObject) { - ptset.set(n->_idx); - return; + pt_ptset.set(n->_idx); + return &pt_ptset; } #ifdef ASSERT if (npt->_node == NULL) { @@ -260,10 +262,10 @@ void ConnectionGraph::PointsTo(VectorSet &ptset, Node * n) { assert(npt->_node != NULL, "unregistered node"); } #endif - worklist.push(n->_idx); - while(worklist.length() > 0) { - int ni = worklist.pop(); - if (visited.test_set(ni)) + pt_worklist.push(n->_idx); + while(pt_worklist.length() > 0) { + int ni = pt_worklist.pop(); + if (pt_visited.test_set(ni)) continue; PointsToNode* pn = ptnode_adr(ni); @@ -276,10 +278,10 @@ void ConnectionGraph::PointsTo(VectorSet &ptset, Node * n) { uint etgt = pn->edge_target(e); PointsToNode::EdgeType et = pn->edge_type(e); if (et == PointsToNode::PointsToEdge) { - ptset.set(etgt); + pt_ptset.set(etgt); edges_processed++; } else if (et == PointsToNode::DeferredEdge) { - worklist.push(etgt); + pt_worklist.push(etgt); edges_processed++; } else { assert(false,"neither PointsToEdge or DeferredEdge"); @@ -288,16 +290,17 @@ void ConnectionGraph::PointsTo(VectorSet &ptset, Node * n) { if (edges_processed == 0) { // no deferred or pointsto edges found. Assume the value was set // outside this method. Add the phantom object to the pointsto set. - ptset.set(_phantom_object); + pt_ptset.set(_phantom_object); } } + return &pt_ptset; } void ConnectionGraph::remove_deferred(uint ni, GrowableArray* deferred_edges, VectorSet* visited) { // This method is most expensive during ConnectionGraph construction. // Reuse vectorSet and an additional growable array for deferred edges. deferred_edges->clear(); - visited->Clear(); + visited->Reset(); visited->set(ni); PointsToNode *ptn = ptnode_adr(ni); @@ -1009,7 +1012,6 @@ void ConnectionGraph::split_unique_types(GrowableArray &alloc_worklist) uint new_index_start = (uint) _compile->num_alias_types(); Arena* arena = Thread::current()->resource_area(); VectorSet visited(arena); - VectorSet ptset(arena); // Phase 1: Process possible allocations from alloc_worklist. @@ -1137,10 +1139,9 @@ void ConnectionGraph::split_unique_types(GrowableArray &alloc_worklist) } } } else if (n->is_AddP()) { - ptset.Clear(); - PointsTo(ptset, get_addp_base(n)); - assert(ptset.Size() == 1, "AddP address is unique"); - uint elem = ptset.getelem(); // Allocation node's index + VectorSet* ptset = PointsTo(get_addp_base(n)); + assert(ptset->Size() == 1, "AddP address is unique"); + uint elem = ptset->getelem(); // Allocation node's index if (elem == _phantom_object) { assert(false, "escaped allocation"); continue; // Assume the value was set outside this method. @@ -1157,10 +1158,9 @@ void ConnectionGraph::split_unique_types(GrowableArray &alloc_worklist) assert(n->is_Phi(), "loops only through Phi's"); continue; // already processed } - ptset.Clear(); - PointsTo(ptset, n); - if (ptset.Size() == 1) { - uint elem = ptset.getelem(); // Allocation node's index + VectorSet* ptset = PointsTo(n); + if (ptset->Size() == 1) { + uint elem = ptset->getelem(); // Allocation node's index if (elem == _phantom_object) { assert(false, "escaped allocation"); continue; // Assume the value was set outside this method. @@ -1434,7 +1434,7 @@ void ConnectionGraph::split_unique_types(GrowableArray &alloc_worklist) // Update the memory inputs of MemNodes with the value we computed // in Phase 2 and move stores memory users to corresponding memory slices. #ifdef ASSERT - visited.Clear(); + visited.Reset(); Node_Stack old_mems(arena, _compile->unique() >> 2); #endif for (uint i = 0; i < nodes_size(); i++) { @@ -1640,7 +1640,6 @@ bool ConnectionGraph::compute_escape() { #undef CG_BUILD_ITER_LIMIT Arena* arena = Thread::current()->resource_area(); - VectorSet ptset(arena); VectorSet visited(arena); worklist.clear(); @@ -1657,7 +1656,7 @@ bool ConnectionGraph::compute_escape() { if (n->is_AddP()) { // Search for objects which are not scalar replaceable // and adjust their escape state. - verify_escape_state(ni, ptset, igvn); + adjust_escape_state(ni, igvn); } } } @@ -1776,8 +1775,8 @@ bool ConnectionGraph::compute_escape() { return has_non_escaping_obj; } -// Search for objects which are not scalar replaceable. -void ConnectionGraph::verify_escape_state(int nidx, VectorSet& ptset, PhaseTransform* phase) { +// Adjust escape state after Connection Graph is built. +void ConnectionGraph::adjust_escape_state(int nidx, PhaseTransform* phase) { PointsToNode* ptn = ptnode_adr(nidx); Node* n = ptn->_node; assert(n->is_AddP(), "Should be called for AddP nodes only"); @@ -1792,9 +1791,8 @@ void ConnectionGraph::verify_escape_state(int nidx, VectorSet& ptset, PhaseTrans int offset = ptn->offset(); Node* base = get_addp_base(n); - ptset.Clear(); - PointsTo(ptset, base); - int ptset_size = ptset.Size(); + VectorSet* ptset = PointsTo(base); + int ptset_size = ptset->Size(); // Check if a oop field's initializing value is recorded and add // a corresponding NULL field's value if it is not recorded. @@ -1814,7 +1812,7 @@ void ConnectionGraph::verify_escape_state(int nidx, VectorSet& ptset, PhaseTrans // Do a simple control flow analysis to distinguish above cases. // if (offset != Type::OffsetBot && ptset_size == 1) { - uint elem = ptset.getelem(); // Allocation node's index + uint elem = ptset->getelem(); // Allocation node's index // It does not matter if it is not Allocation node since // only non-escaping allocations are scalar replaced. if (ptnode_adr(elem)->_node->is_Allocate() && @@ -1913,7 +1911,7 @@ void ConnectionGraph::verify_escape_state(int nidx, VectorSet& ptset, PhaseTrans // if (ptset_size > 1 || ptset_size != 0 && (has_LoadStore || offset == Type::OffsetBot)) { - for( VectorSetI j(&ptset); j.test(); ++j ) { + for( VectorSetI j(ptset); j.test(); ++j ) { set_escape_state(j.elem, PointsToNode::ArgEscape); ptnode_adr(j.elem)->_scalar_replaceable = false; } @@ -1937,7 +1935,6 @@ void ConnectionGraph::process_call_arguments(CallNode *call, PhaseTransform *pha // Stub calls, objects do not escape but they are not scale replaceable. // Adjust escape state for outgoing arguments. const TypeTuple * d = call->tf()->domain(); - VectorSet ptset(Thread::current()->resource_area()); for (uint i = TypeFunc::Parms; i < d->cnt(); i++) { const Type* at = d->field_at(i); Node *arg = call->in(i)->uncast(); @@ -1970,9 +1967,7 @@ void ConnectionGraph::process_call_arguments(CallNode *call, PhaseTransform *pha // arg = get_addp_base(arg); } - ptset.Clear(); - PointsTo(ptset, arg); - for( VectorSetI j(&ptset); j.test(); ++j ) { + for( VectorSetI j(PointsTo(arg)); j.test(); ++j ) { uint pt = j.elem; set_escape_state(pt, PointsToNode::ArgEscape); } @@ -1990,7 +1985,6 @@ void ConnectionGraph::process_call_arguments(CallNode *call, PhaseTransform *pha // fall-through if not a Java method or no analyzer information if (call_analyzer != NULL) { const TypeTuple * d = call->tf()->domain(); - VectorSet ptset(Thread::current()->resource_area()); bool copy_dependencies = false; for (uint i = TypeFunc::Parms; i < d->cnt(); i++) { const Type* at = d->field_at(i); @@ -2015,9 +2009,7 @@ void ConnectionGraph::process_call_arguments(CallNode *call, PhaseTransform *pha copy_dependencies = true; } - ptset.Clear(); - PointsTo(ptset, arg); - for( VectorSetI j(&ptset); j.test(); ++j ) { + for( VectorSetI j(PointsTo(arg)); j.test(); ++j ) { uint pt = j.elem; if (global_escapes) { //The argument global escapes, mark everything it could point to @@ -2045,15 +2037,12 @@ void ConnectionGraph::process_call_arguments(CallNode *call, PhaseTransform *pha { // adjust escape state for outgoing arguments const TypeTuple * d = call->tf()->domain(); - VectorSet ptset(Thread::current()->resource_area()); for (uint i = TypeFunc::Parms; i < d->cnt(); i++) { const Type* at = d->field_at(i); if (at->isa_oopptr() != NULL) { Node *arg = call->in(i)->uncast(); set_escape_state(arg->_idx, PointsToNode::GlobalEscape); - ptset.Clear(); - PointsTo(ptset, arg); - for( VectorSetI j(&ptset); j.test(); ++j ) { + for( VectorSetI j(PointsTo(arg)); j.test(); ++j ) { uint pt = j.elem; set_escape_state(pt, PointsToNode::GlobalEscape); } @@ -2515,9 +2504,7 @@ void ConnectionGraph::build_connection_graph(Node *n, PhaseTransform *phase) { { Node *base = get_addp_base(n); // Create a field edge to this node from everything base could point to. - VectorSet ptset(Thread::current()->resource_area()); - PointsTo(ptset, base); - for( VectorSetI i(&ptset); i.test(); ++i ) { + for( VectorSetI i(PointsTo(base)); i.test(); ++i ) { uint pt = i.elem; add_field_edge(pt, n_idx, address_offset(n, phase)); } @@ -2583,10 +2570,8 @@ void ConnectionGraph::build_connection_graph(Node *n, PhaseTransform *phase) { // For everything "adr_base" could point to, create a deferred edge from // this node to each field with the same offset. - VectorSet ptset(Thread::current()->resource_area()); - PointsTo(ptset, adr_base); int offset = address_offset(adr, phase); - for( VectorSetI i(&ptset); i.test(); ++i ) { + for( VectorSetI i(PointsTo(adr_base)); i.test(); ++i ) { uint pt = i.elem; add_deferred_edge_to_fields(n_idx, pt, offset); } @@ -2676,9 +2661,7 @@ void ConnectionGraph::build_connection_graph(Node *n, PhaseTransform *phase) { Node *val = n->in(MemNode::ValueIn)->uncast(); // For everything "adr_base" could point to, create a deferred edge // to "val" from each field with the same offset. - VectorSet ptset(Thread::current()->resource_area()); - PointsTo(ptset, adr_base); - for( VectorSetI i(&ptset); i.test(); ++i ) { + for( VectorSetI i(PointsTo(adr_base)); i.test(); ++i ) { uint pt = i.elem; add_edge_from_fields(pt, val->_idx, address_offset(adr, phase)); } diff --git a/hotspot/src/share/vm/opto/escape.hpp b/hotspot/src/share/vm/opto/escape.hpp index 51198305bbf..0cd00f406bf 100644 --- a/hotspot/src/share/vm/opto/escape.hpp +++ b/hotspot/src/share/vm/opto/escape.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -268,7 +268,12 @@ private: // walk the connection graph starting at the node corresponding to "n" and // add the index of everything it could point to, to "ptset". This may cause // Phi's encountered to get (re)processed (which requires "phase".) - void PointsTo(VectorSet &ptset, Node * n); + VectorSet* PointsTo(Node * n); + + // Reused structures for PointsTo(). + VectorSet pt_ptset; + VectorSet pt_visited; + GrowableArray pt_worklist; // Edge manipulation. The "from_i" and "to_i" arguments are the // node indices of the source and destination of the edge @@ -334,8 +339,11 @@ private: // Set the escape state of a node void set_escape_state(uint ni, PointsToNode::EscapeState es); - // Search for objects which are not scalar replaceable. - void verify_escape_state(int nidx, VectorSet& ptset, PhaseTransform* phase); + // Adjust escape state after Connection Graph is built. + void adjust_escape_state(int nidx, PhaseTransform* phase); + + // Compute the escape information + bool compute_escape(); public: ConnectionGraph(Compile *C, PhaseIterGVN *igvn); @@ -346,9 +354,6 @@ public: // Perform escape analysis static void do_analysis(Compile *C, PhaseIterGVN *igvn); - // Compute the escape information - bool compute_escape(); - // escape state of a node PointsToNode::EscapeState escape_state(Node *n); diff --git a/hotspot/src/share/vm/opto/phase.cpp b/hotspot/src/share/vm/opto/phase.cpp index 7bf7e6aec08..ae79a55d991 100644 --- a/hotspot/src/share/vm/opto/phase.cpp +++ b/hotspot/src/share/vm/opto/phase.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -99,16 +99,18 @@ void Phase::print_timers() { tty->print_cr (" stub compilation : %3.3f sec.", Phase::_t_stubCompilation.seconds()); tty->print_cr (" Phases:"); tty->print_cr (" parse : %3.3f sec", Phase::_t_parser.seconds()); - if (DoEscapeAnalysis) { - tty->print_cr (" escape analysis : %3.3f sec", Phase::_t_escapeAnalysis.seconds()); - } tty->print_cr (" optimizer : %3.3f sec", Phase::_t_optimizer.seconds()); if( Verbose || WizardMode ) { + if (DoEscapeAnalysis) { + // EA is part of Optimizer. + tty->print_cr (" escape analysis: %3.3f sec", Phase::_t_escapeAnalysis.seconds()); + } tty->print_cr (" iterGVN : %3.3f sec", Phase::_t_iterGVN.seconds()); tty->print_cr (" idealLoop : %3.3f sec", Phase::_t_idealLoop.seconds()); tty->print_cr (" idealLoopVerify: %3.3f sec", Phase::_t_idealLoopVerify.seconds()); tty->print_cr (" ccp : %3.3f sec", Phase::_t_ccp.seconds()); tty->print_cr (" iterGVN2 : %3.3f sec", Phase::_t_iterGVN2.seconds()); + tty->print_cr (" macroExpand : %3.3f sec", Phase::_t_macroExpand.seconds()); tty->print_cr (" graphReshape : %3.3f sec", Phase::_t_graphReshaping.seconds()); double optimizer_subtotal = Phase::_t_iterGVN.seconds() + Phase::_t_idealLoop.seconds() + Phase::_t_ccp.seconds() + @@ -133,18 +135,15 @@ void Phase::print_timers() { double percent_of_regalloc = ((regalloc_subtotal == 0.0) ? 0.0 : (regalloc_subtotal / Phase::_t_registerAllocation.seconds() * 100.0)); tty->print_cr (" subtotal : %3.3f sec, %3.2f %%", regalloc_subtotal, percent_of_regalloc); } - tty->print_cr (" macroExpand : %3.3f sec", Phase::_t_macroExpand.seconds()); tty->print_cr (" blockOrdering : %3.3f sec", Phase::_t_blockOrdering.seconds()); tty->print_cr (" peephole : %3.3f sec", Phase::_t_peephole.seconds()); tty->print_cr (" codeGen : %3.3f sec", Phase::_t_codeGeneration.seconds()); tty->print_cr (" install_code : %3.3f sec", Phase::_t_registerMethod.seconds()); tty->print_cr (" -------------- : ----------"); double phase_subtotal = Phase::_t_parser.seconds() + - (DoEscapeAnalysis ? Phase::_t_escapeAnalysis.seconds() : 0.0) + Phase::_t_optimizer.seconds() + Phase::_t_graphReshaping.seconds() + Phase::_t_matcher.seconds() + Phase::_t_scheduler.seconds() + Phase::_t_registerAllocation.seconds() + Phase::_t_blockOrdering.seconds() + - Phase::_t_macroExpand.seconds() + Phase::_t_peephole.seconds() + Phase::_t_codeGeneration.seconds() + Phase::_t_registerMethod.seconds(); double percent_of_method_compile = ((phase_subtotal == 0.0) ? 0.0 : phase_subtotal / Phase::_t_methodCompilation.seconds()) * 100.0; // counters inside Compile::CodeGen include time for adapters and stubs From b9633d42b40522ece82c72a2d4153688483f14f7 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Mon, 7 Feb 2011 10:34:39 -0800 Subject: [PATCH 010/105] 7017124: Fix some VM stats to avoid 32-bit overflow Added new method inc_stat_counter() to increment long statistic values and use atomic long load and store. Reviewed-by: dholmes, jrose, phh, never --- .../vm/atomic_solaris_sparc.inline.hpp | 1 - hotspot/src/share/vm/memory/allocation.cpp | 29 +++++----- hotspot/src/share/vm/memory/allocation.hpp | 24 +++++---- .../src/share/vm/memory/allocation.inline.hpp | 8 ++- hotspot/src/share/vm/opto/indexSet.cpp | 36 ++++++------- hotspot/src/share/vm/opto/indexSet.hpp | 12 ++--- hotspot/src/share/vm/runtime/globals.hpp | 5 +- hotspot/src/share/vm/runtime/java.cpp | 2 +- hotspot/src/share/vm/runtime/os.cpp | 54 ++++++++++--------- hotspot/src/share/vm/runtime/os.hpp | 9 ++-- 10 files changed, 100 insertions(+), 80 deletions(-) diff --git a/hotspot/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.inline.hpp b/hotspot/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.inline.hpp index 4830bfbb799..0d91eb967d5 100644 --- a/hotspot/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.inline.hpp +++ b/hotspot/src/os_cpu/solaris_sparc/vm/atomic_solaris_sparc.inline.hpp @@ -67,7 +67,6 @@ extern "C" void _Atomic_move_long_v9(volatile jlong* src, volatile jlong* dst); inline void Atomic_move_long(volatile jlong* src, volatile jlong* dst) { #ifdef COMPILER2 // Compiler2 does not support v8, it is used only for v9. - assert (VM_Version::v9_instructions_work(), "only supported on v9"); _Atomic_move_long_v9(src, dst); #else // The branch is cheaper then emulated LDD. diff --git a/hotspot/src/share/vm/memory/allocation.cpp b/hotspot/src/share/vm/memory/allocation.cpp index d334d4d8785..02197c5b684 100644 --- a/hotspot/src/share/vm/memory/allocation.cpp +++ b/hotspot/src/share/vm/memory/allocation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -157,7 +157,7 @@ ResourceObj::~ResourceObj() { void trace_heap_malloc(size_t size, const char* name, void* p) { // A lock is not needed here - tty uses a lock internally - tty->print_cr("Heap malloc " INTPTR_FORMAT " %7d %s", p, size, name == NULL ? "" : name); + tty->print_cr("Heap malloc " INTPTR_FORMAT " " SIZE_FORMAT " %s", p, size, name == NULL ? "" : name); } @@ -573,22 +573,27 @@ void AllocatedObj::print_value_on(outputStream* st) const { st->print("AllocatedObj(" INTPTR_FORMAT ")", this); } -size_t Arena::_bytes_allocated = 0; +julong Arena::_bytes_allocated = 0; + +void Arena::inc_bytes_allocated(size_t x) { inc_stat_counter(&_bytes_allocated, x); } AllocStats::AllocStats() { - start_mallocs = os::num_mallocs; - start_frees = os::num_frees; + start_mallocs = os::num_mallocs; + start_frees = os::num_frees; start_malloc_bytes = os::alloc_bytes; - start_res_bytes = Arena::_bytes_allocated; + start_mfree_bytes = os::free_bytes; + start_res_bytes = Arena::_bytes_allocated; } -int AllocStats::num_mallocs() { return os::num_mallocs - start_mallocs; } -size_t AllocStats::alloc_bytes() { return os::alloc_bytes - start_malloc_bytes; } -size_t AllocStats::resource_bytes() { return Arena::_bytes_allocated - start_res_bytes; } -int AllocStats::num_frees() { return os::num_frees - start_frees; } +julong AllocStats::num_mallocs() { return os::num_mallocs - start_mallocs; } +julong AllocStats::alloc_bytes() { return os::alloc_bytes - start_malloc_bytes; } +julong AllocStats::num_frees() { return os::num_frees - start_frees; } +julong AllocStats::free_bytes() { return os::free_bytes - start_mfree_bytes; } +julong AllocStats::resource_bytes() { return Arena::_bytes_allocated - start_res_bytes; } void AllocStats::print() { - tty->print("%d mallocs (%ldK), %d frees, %ldK resrc", - num_mallocs(), alloc_bytes()/K, num_frees(), resource_bytes()/K); + tty->print_cr(UINT64_FORMAT " mallocs (" UINT64_FORMAT "MB), " + UINT64_FORMAT" frees (" UINT64_FORMAT "MB), " UINT64_FORMAT "MB resrc", + num_mallocs(), alloc_bytes()/M, num_frees(), free_bytes()/M, resource_bytes()/M); } diff --git a/hotspot/src/share/vm/memory/allocation.hpp b/hotspot/src/share/vm/memory/allocation.hpp index c3eb1a5c49d..2c6845cd9f4 100644 --- a/hotspot/src/share/vm/memory/allocation.hpp +++ b/hotspot/src/share/vm/memory/allocation.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -202,10 +202,11 @@ protected: char *_hwm, *_max; // High water mark and max in current chunk void* grow(size_t x); // Get a new Chunk of at least size x NOT_PRODUCT(size_t _size_in_bytes;) // Size of arena (used for memory usage tracing) - NOT_PRODUCT(static size_t _bytes_allocated;) // total #bytes allocated since start + NOT_PRODUCT(static julong _bytes_allocated;) // total #bytes allocated since start friend class AllocStats; debug_only(void* malloc(size_t size);) debug_only(void* internal_malloc_4(size_t x);) + NOT_PRODUCT(void inc_bytes_allocated(size_t x);) public: Arena(); Arena(size_t init_size); @@ -219,7 +220,7 @@ protected: assert(is_power_of_2(ARENA_AMALLOC_ALIGNMENT) , "should be a power of 2"); x = ARENA_ALIGN(x); debug_only(if (UseMallocOnly) return malloc(x);) - NOT_PRODUCT(_bytes_allocated += x); + NOT_PRODUCT(inc_bytes_allocated(x);) if (_hwm + x > _max) { return grow(x); } else { @@ -232,7 +233,7 @@ protected: void *Amalloc_4(size_t x) { assert( (x&(sizeof(char*)-1)) == 0, "misaligned size" ); debug_only(if (UseMallocOnly) return malloc(x);) - NOT_PRODUCT(_bytes_allocated += x); + NOT_PRODUCT(inc_bytes_allocated(x);) if (_hwm + x > _max) { return grow(x); } else { @@ -252,7 +253,7 @@ protected: size_t delta = (((size_t)_hwm + DALIGN_M1) & ~DALIGN_M1) - (size_t)_hwm; x += delta; #endif - NOT_PRODUCT(_bytes_allocated += x); + NOT_PRODUCT(inc_bytes_allocated(x);) if (_hwm + x > _max) { return grow(x); // grow() returns a result aligned >= 8 bytes. } else { @@ -406,15 +407,16 @@ extern bool warn_new_operator; // for statistics #ifndef PRODUCT class AllocStats : StackObj { - int start_mallocs, start_frees; - size_t start_malloc_bytes, start_res_bytes; + julong start_mallocs, start_frees; + julong start_malloc_bytes, start_mfree_bytes, start_res_bytes; public: AllocStats(); - int num_mallocs(); // since creation of receiver - size_t alloc_bytes(); - size_t resource_bytes(); - int num_frees(); + julong num_mallocs(); // since creation of receiver + julong alloc_bytes(); + julong num_frees(); + julong free_bytes(); + julong resource_bytes(); void print(); }; #endif diff --git a/hotspot/src/share/vm/memory/allocation.inline.hpp b/hotspot/src/share/vm/memory/allocation.inline.hpp index 19bac7475e4..79d7ef5d666 100644 --- a/hotspot/src/share/vm/memory/allocation.inline.hpp +++ b/hotspot/src/share/vm/memory/allocation.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -32,6 +32,12 @@ void trace_heap_malloc(size_t size, const char* name, void *p); void trace_heap_free(void *p); +// Increments unsigned long value for statistics (not atomic on MP). +inline void inc_stat_counter(volatile julong* dest, julong add_value) { + julong value = Atomic::load((volatile jlong*)dest); + value += add_value; + Atomic::store((jlong)value, (volatile jlong*)dest); +} // allocate using malloc; will fail if no memory available inline char* AllocateHeap(size_t size, const char* name = NULL) { diff --git a/hotspot/src/share/vm/opto/indexSet.cpp b/hotspot/src/share/vm/opto/indexSet.cpp index efbb4e3c370..4ba99e72783 100644 --- a/hotspot/src/share/vm/opto/indexSet.cpp +++ b/hotspot/src/share/vm/opto/indexSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -39,12 +39,12 @@ IndexSet::BitBlock IndexSet::_empty_block = IndexSet::BitBlock(); #ifdef ASSERT // Initialize statistics counters -uint IndexSet::_alloc_new = 0; -uint IndexSet::_alloc_total = 0; +julong IndexSet::_alloc_new = 0; +julong IndexSet::_alloc_total = 0; -long IndexSet::_total_bits = 0; -long IndexSet::_total_used_blocks = 0; -long IndexSet::_total_unused_blocks = 0; +julong IndexSet::_total_bits = 0; +julong IndexSet::_total_used_blocks = 0; +julong IndexSet::_total_unused_blocks = 0; // Per set, or all sets operation tracing int IndexSet::_serial_count = 1; @@ -141,7 +141,7 @@ void IndexSet::populate_free_list() { #ifdef ASSERT if (CollectIndexSetStatistics) { - _alloc_new += bitblock_alloc_chunk_size; + inc_stat_counter(&_alloc_new, bitblock_alloc_chunk_size); } #endif } @@ -154,7 +154,7 @@ void IndexSet::populate_free_list() { IndexSet::BitBlock *IndexSet::alloc_block() { #ifdef ASSERT if (CollectIndexSetStatistics) { - _alloc_total++; + inc_stat_counter(&_alloc_total, 1); } #endif Compile *compile = Compile::current(); @@ -391,13 +391,13 @@ void IndexSet::dump() const { // Update block/bit counts to reflect that this set has been iterated over. void IndexSet::tally_iteration_statistics() const { - _total_bits += count(); + inc_stat_counter(&_total_bits, count()); for (uint i = 0; i < _max_blocks; i++) { if (_blocks[i] != &_empty_block) { - _total_used_blocks++; + inc_stat_counter(&_total_used_blocks, 1); } else { - _total_unused_blocks++; + inc_stat_counter(&_total_unused_blocks, 1); } } } @@ -406,17 +406,17 @@ void IndexSet::tally_iteration_statistics() const { // Print statistics about IndexSet usage. void IndexSet::print_statistics() { - long total_blocks = _total_used_blocks + _total_unused_blocks; + julong total_blocks = _total_used_blocks + _total_unused_blocks; tty->print_cr ("Accumulated IndexSet usage statistics:"); tty->print_cr ("--------------------------------------"); tty->print_cr (" Iteration:"); - tty->print_cr (" blocks visited: %d", total_blocks); - tty->print_cr (" blocks empty: %4.2f%%", 100.0*_total_unused_blocks/total_blocks); - tty->print_cr (" bit density (bits/used blocks): %4.2f%%", (double)_total_bits/_total_used_blocks); - tty->print_cr (" bit density (bits/all blocks): %4.2f%%", (double)_total_bits/total_blocks); + tty->print_cr (" blocks visited: " UINT64_FORMAT, total_blocks); + tty->print_cr (" blocks empty: %4.2f%%", 100.0*(double)_total_unused_blocks/total_blocks); + tty->print_cr (" bit density (bits/used blocks): %4.2f", (double)_total_bits/_total_used_blocks); + tty->print_cr (" bit density (bits/all blocks): %4.2f", (double)_total_bits/total_blocks); tty->print_cr (" Allocation:"); - tty->print_cr (" blocks allocated: %d", _alloc_new); - tty->print_cr (" blocks used/reused: %d", _alloc_total); + tty->print_cr (" blocks allocated: " UINT64_FORMAT, _alloc_new); + tty->print_cr (" blocks used/reused: " UINT64_FORMAT, _alloc_total); } //---------------------------- IndexSet::verify() ----------------------------- diff --git a/hotspot/src/share/vm/opto/indexSet.hpp b/hotspot/src/share/vm/opto/indexSet.hpp index 0c4119c2db2..ef5aed18b67 100644 --- a/hotspot/src/share/vm/opto/indexSet.hpp +++ b/hotspot/src/share/vm/opto/indexSet.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -352,13 +352,13 @@ class IndexSet : public ResourceObj { void tally_iteration_statistics() const; // BitBlock allocation statistics - static uint _alloc_new; - static uint _alloc_total; + static julong _alloc_new; + static julong _alloc_total; // Block density statistics - static long _total_bits; - static long _total_used_blocks; - static long _total_unused_blocks; + static julong _total_bits; + static julong _total_used_blocks; + static julong _total_unused_blocks; // Sanity tests void verify() const; diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 94bc7818841..5de17984108 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -712,6 +712,9 @@ class CommandLineFlags { develop(bool, PrintMalloc, false, \ "print all malloc/free calls") \ \ + develop(bool, PrintMallocStatistics, false, \ + "print malloc/free statistics") \ + \ develop(bool, ZapResourceArea, trueInDebug, \ "Zap freed resource/arena space with 0xABABABAB") \ \ diff --git a/hotspot/src/share/vm/runtime/java.cpp b/hotspot/src/share/vm/runtime/java.cpp index ea7cc2860e5..6007fc46045 100644 --- a/hotspot/src/share/vm/runtime/java.cpp +++ b/hotspot/src/share/vm/runtime/java.cpp @@ -320,7 +320,7 @@ void print_statistics() { } print_bytecode_count(); - if (WizardMode) { + if (PrintMallocStatistics) { tty->print("allocation stats: "); alloc_stats.print(); tty->cr(); diff --git a/hotspot/src/share/vm/runtime/os.cpp b/hotspot/src/share/vm/runtime/os.cpp index 5b106f4fee9..f13b5e28812 100644 --- a/hotspot/src/share/vm/runtime/os.cpp +++ b/hotspot/src/share/vm/runtime/os.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -72,9 +72,10 @@ int os::_processor_count = 0; size_t os::_page_sizes[os::page_sizes_max]; #ifndef PRODUCT -int os::num_mallocs = 0; // # of calls to malloc/realloc -size_t os::alloc_bytes = 0; // # of bytes allocated -int os::num_frees = 0; // # of calls to free +julong os::num_mallocs = 0; // # of calls to malloc/realloc +julong os::alloc_bytes = 0; // # of bytes allocated +julong os::num_frees = 0; // # of calls to free +julong os::free_bytes = 0; // # of bytes freed #endif // Fill in buffer with current local time as an ISO-8601 string. @@ -490,9 +491,9 @@ void print_neighbor_blocks(void* ptr) { } if (start_of_prev_block + space_before + size + space_after == start_of_this_block) { - tty->print_cr("### previous object: %p (%ld bytes)", obj, size); + tty->print_cr("### previous object: " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", obj, size); } else { - tty->print_cr("### previous object (not sure if correct): %p (%ld bytes)", obj, size); + tty->print_cr("### previous object (not sure if correct): " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", obj, size); } // now find successor block @@ -504,16 +505,16 @@ void print_neighbor_blocks(void* ptr) { start_of_next_block[1] == badResourceValue && start_of_next_block[2] == badResourceValue && start_of_next_block[3] == badResourceValue) { - tty->print_cr("### next object: %p (%ld bytes)", next_obj, next_size); + tty->print_cr("### next object: " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", next_obj, next_size); } else { - tty->print_cr("### next object (not sure if correct): %p (%ld bytes)", next_obj, next_size); + tty->print_cr("### next object (not sure if correct): " PTR_FORMAT " (" SSIZE_FORMAT " bytes)", next_obj, next_size); } } void report_heap_error(void* memblock, void* bad, const char* where) { - tty->print_cr("## nof_mallocs = %d, nof_frees = %d", os::num_mallocs, os::num_frees); - tty->print_cr("## memory stomp: byte at %p %s object %p", bad, where, memblock); + tty->print_cr("## nof_mallocs = " UINT64_FORMAT ", nof_frees = " UINT64_FORMAT, os::num_mallocs, os::num_frees); + tty->print_cr("## memory stomp: byte at " PTR_FORMAT " %s object " PTR_FORMAT, bad, where, memblock); print_neighbor_blocks(memblock); fatal("memory stomping error"); } @@ -538,8 +539,8 @@ void verify_block(void* memblock) { #endif void* os::malloc(size_t size) { - NOT_PRODUCT(num_mallocs++); - NOT_PRODUCT(alloc_bytes += size); + NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1)); + NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size)); if (size == 0) { // return a valid pointer if size is zero @@ -562,26 +563,26 @@ void* os::malloc(size_t size) { #endif u_char* memblock = ptr + space_before; if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) { - tty->print_cr("os::malloc caught, %lu bytes --> %p", size, memblock); + tty->print_cr("os::malloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, memblock); breakpoint(); } debug_only(if (paranoid) verify_block(memblock)); - if (PrintMalloc && tty != NULL) tty->print_cr("os::malloc %lu bytes --> %p", size, memblock); + if (PrintMalloc && tty != NULL) tty->print_cr("os::malloc " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, memblock); return memblock; } void* os::realloc(void *memblock, size_t size) { - NOT_PRODUCT(num_mallocs++); - NOT_PRODUCT(alloc_bytes += size); #ifndef ASSERT + NOT_PRODUCT(inc_stat_counter(&num_mallocs, 1)); + NOT_PRODUCT(inc_stat_counter(&alloc_bytes, size)); return ::realloc(memblock, size); #else if (memblock == NULL) { - return os::malloc(size); + return malloc(size); } if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) { - tty->print_cr("os::realloc caught %p", memblock); + tty->print_cr("os::realloc caught " PTR_FORMAT, memblock); breakpoint(); } verify_block(memblock); @@ -589,13 +590,13 @@ void* os::realloc(void *memblock, size_t size) { if (size == 0) return NULL; // always move the block void* ptr = malloc(size); - if (PrintMalloc) tty->print_cr("os::remalloc %lu bytes, %p --> %p", size, memblock, ptr); + if (PrintMalloc) tty->print_cr("os::remalloc " SIZE_FORMAT " bytes, " PTR_FORMAT " --> " PTR_FORMAT, size, memblock, ptr); // Copy to new memory if malloc didn't fail if ( ptr != NULL ) { memcpy(ptr, memblock, MIN2(size, get_size(memblock))); if (paranoid) verify_block(ptr); if ((intptr_t)ptr == (intptr_t)MallocCatchPtr) { - tty->print_cr("os::realloc caught, %lu bytes --> %p", size, ptr); + tty->print_cr("os::realloc caught, " SIZE_FORMAT " bytes --> " PTR_FORMAT, size, ptr); breakpoint(); } free(memblock); @@ -606,17 +607,14 @@ void* os::realloc(void *memblock, size_t size) { void os::free(void *memblock) { - NOT_PRODUCT(num_frees++); + NOT_PRODUCT(inc_stat_counter(&num_frees, 1)); #ifdef ASSERT if (memblock == NULL) return; if ((intptr_t)memblock == (intptr_t)MallocCatchPtr) { - if (tty != NULL) tty->print_cr("os::free caught %p", memblock); + if (tty != NULL) tty->print_cr("os::free caught " PTR_FORMAT, memblock); breakpoint(); } verify_block(memblock); - if (PrintMalloc && tty != NULL) - // tty->print_cr("os::free %p", memblock); - fprintf(stderr, "os::free %p\n", memblock); NOT_PRODUCT(if (MallocVerifyInterval > 0) check_heap()); // Added by detlefs. if (MallocCushion) { @@ -627,12 +625,18 @@ void os::free(void *memblock) { *p = (u_char)freeBlockPad; } size_t size = get_size(memblock); + inc_stat_counter(&free_bytes, size); u_char* end = ptr + space_before + size; for (u_char* q = end; q < end + MallocCushion; q++) { guarantee(*q == badResourceValue, "Thing freed should be malloc result."); *q = (u_char)freeBlockPad; } + if (PrintMalloc && tty != NULL) + fprintf(stderr, "os::free " SIZE_FORMAT " bytes --> " PTR_FORMAT "\n", size, memblock); + } else if (PrintMalloc && tty != NULL) { + // tty->print_cr("os::free %p", memblock); + fprintf(stderr, "os::free " PTR_FORMAT "\n", memblock); } #endif ::free((char*)memblock - space_before); diff --git a/hotspot/src/share/vm/runtime/os.hpp b/hotspot/src/share/vm/runtime/os.hpp index b1476b6395c..67ca1db76ce 100644 --- a/hotspot/src/share/vm/runtime/os.hpp +++ b/hotspot/src/share/vm/runtime/os.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -559,9 +559,10 @@ class os: AllStatic { static char* strdup(const char *); // Like strdup #ifndef PRODUCT - static int num_mallocs; // # of calls to malloc/realloc - static size_t alloc_bytes; // # of bytes allocated - static int num_frees; // # of calls to free + static julong num_mallocs; // # of calls to malloc/realloc + static julong alloc_bytes; // # of bytes allocated + static julong num_frees; // # of calls to free + static julong free_bytes; // # of bytes freed #endif // SocketInterface (ex HPI SocketInterface ) From 7eccb460db89551261387ab12bd695a5bf7ec5cf Mon Sep 17 00:00:00 2001 From: "Y. Srinivas Ramakrishna" Date: Mon, 7 Feb 2011 22:19:57 -0800 Subject: [PATCH 011/105] 6912621: iCMS: Error: assert(_markBitMap.isMarked(addr + 1),"Missing Printezis bit?") Fix block_size_if_printezis_bits() so it does not expect the bits, only uses them when available. Fix block_size_no_stall() so it does not stall when the bits are missing such cases, letting the caller deal with zero size returns. Constant pool cache oops do not need to be unparsable or conc_unsafe after their klass pointer is installed. Some cosmetic clean-ups and some assertion checking for conc-usafety which, in the presence of class file redefinition, has no a-priori time boundedness, so all GCs must be able to safely deal with putatively conc-unsafe objects in a stop-world pause. Reviewed-by: jmasa, johnc --- .../share/vm/classfile/classFileParser.cpp | 9 ++-- .../compactibleFreeListSpace.cpp | 8 ++-- .../concurrentMarkSweepGeneration.cpp | 10 ++--- .../share/vm/gc_interface/collectedHeap.cpp | 3 +- hotspot/src/share/vm/interpreter/rewriter.cpp | 6 +-- hotspot/src/share/vm/memory/oopFactory.cpp | 3 +- hotspot/src/share/vm/memory/oopFactory.hpp | 1 - .../src/share/vm/oops/constantPoolKlass.cpp | 8 ++++ hotspot/src/share/vm/oops/cpCacheKlass.cpp | 41 ++++++------------- hotspot/src/share/vm/oops/cpCacheKlass.hpp | 3 +- hotspot/src/share/vm/oops/cpCacheOop.hpp | 9 ---- hotspot/src/share/vm/oops/methodOop.cpp | 18 +++++++- hotspot/src/share/vm/oops/methodOop.hpp | 3 -- hotspot/src/share/vm/oops/oop.hpp | 5 +++ .../share/vm/prims/jvmtiRedefineClasses.cpp | 8 ++-- .../src/share/vm/prims/methodHandleWalk.cpp | 8 ++-- 16 files changed, 67 insertions(+), 76 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classFileParser.cpp b/hotspot/src/share/vm/classfile/classFileParser.cpp index b71a45c804f..3aacf66ff7b 100644 --- a/hotspot/src/share/vm/classfile/classFileParser.cpp +++ b/hotspot/src/share/vm/classfile/classFileParser.cpp @@ -331,7 +331,7 @@ constantPoolHandle ClassFileParser::parse_constant_pool(TRAPS) { length, CHECK_(nullHandle)); constantPoolOop constant_pool = oopFactory::new_constantPool(length, - methodOopDesc::IsSafeConc, + oopDesc::IsSafeConc, CHECK_(nullHandle)); constantPoolHandle cp (THREAD, constant_pool); @@ -1929,10 +1929,9 @@ methodHandle ClassFileParser::parse_method(constantPoolHandle cp, bool is_interf } // All sizing information for a methodOop is finally available, now create it - methodOop m_oop = oopFactory::new_method( - code_length, access_flags, linenumber_table_length, - total_lvt_length, checked_exceptions_length, - methodOopDesc::IsSafeConc, CHECK_(nullHandle)); + methodOop m_oop = oopFactory::new_method(code_length, access_flags, linenumber_table_length, + total_lvt_length, checked_exceptions_length, + oopDesc::IsSafeConc, CHECK_(nullHandle)); methodHandle m (THREAD, m_oop); ClassLoadingService::add_class_method_size(m_oop->size()*HeapWordSize); diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp index 953456f5ca2..67cf3c70464 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp @@ -1040,9 +1040,10 @@ const { } else { // must read from what 'p' points to in each loop. klassOop k = ((volatile oopDesc*)p)->klass_or_null(); - if (k != NULL && - ((oopDesc*)p)->is_parsable() && - ((oopDesc*)p)->is_conc_safe()) { + // We trust the size of any object that has a non-NULL + // klass and (for those in the perm gen) is parsable + // -- irrespective of its conc_safe-ty. + if (k != NULL && ((oopDesc*)p)->is_parsable()) { assert(k->is_oop(), "Should really be klass oop."); oop o = (oop)p; assert(o->is_oop(), "Should be an oop"); @@ -1051,6 +1052,7 @@ const { assert(res != 0, "Block size should not be 0"); return res; } else { + // May return 0 if P-bits not present. return c->block_size_if_printezis_bits(p); } } diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index 5b1d1eb47f3..e3134fecca3 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -6360,18 +6360,16 @@ size_t CMSCollector::block_size_using_printezis_bits(HeapWord* addr) const { // A variant of the above (block_size_using_printezis_bits()) except // that we return 0 if the P-bits are not yet set. size_t CMSCollector::block_size_if_printezis_bits(HeapWord* addr) const { - if (_markBitMap.isMarked(addr)) { - assert(_markBitMap.isMarked(addr + 1), "Missing Printezis bit?"); + if (_markBitMap.isMarked(addr + 1)) { + assert(_markBitMap.isMarked(addr), "P-bit can be set only for marked objects"); HeapWord* nextOneAddr = _markBitMap.getNextMarkedWordAddress(addr + 2); size_t size = pointer_delta(nextOneAddr + 1, addr); assert(size == CompactibleFreeListSpace::adjustObjectSize(size), "alignment problem"); assert(size >= 3, "Necessary for Printezis marks to work"); return size; - } else { - assert(!_markBitMap.isMarked(addr + 1), "Bit map inconsistency?"); - return 0; } + return 0; } HeapWord* CMSCollector::next_card_start_after_block(HeapWord* addr) const { @@ -9212,7 +9210,6 @@ bool MarkRefsIntoAndScanClosure::take_from_overflow_list() { size_t MarkDeadObjectsClosure::do_blk(HeapWord* addr) { size_t res = _sp->block_size_no_stall(addr, _collector); - assert(res != 0, "Should always be able to compute a size"); if (_sp->block_is_obj(addr)) { if (_live_bit_map->isMarked(addr)) { // It can't have been dead in a previous cycle @@ -9221,6 +9218,7 @@ size_t MarkDeadObjectsClosure::do_blk(HeapWord* addr) { _dead_bit_map->mark(addr); // mark the dead object } } + // Could be 0, if the block size could not be computed without stalling. return res; } diff --git a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp index 83a6777b7e2..6ffd07c97cb 100644 --- a/hotspot/src/share/vm/gc_interface/collectedHeap.cpp +++ b/hotspot/src/share/vm/gc_interface/collectedHeap.cpp @@ -100,8 +100,7 @@ void CollectedHeap::check_for_bad_heap_word_value(HeapWord* addr, size_t size) { } } -void CollectedHeap::check_for_non_bad_heap_word_value(HeapWord* addr, size_t size) - { +void CollectedHeap::check_for_non_bad_heap_word_value(HeapWord* addr, size_t size) { if (CheckMemoryInitialization && ZapUnusedHeapArea) { for (size_t slot = 0; slot < size; slot += 1) { assert((*(intptr_t*) (addr + slot)) == ((intptr_t) badHeapWordVal), diff --git a/hotspot/src/share/vm/interpreter/rewriter.cpp b/hotspot/src/share/vm/interpreter/rewriter.cpp index e80216c79c1..3bdebda0941 100644 --- a/hotspot/src/share/vm/interpreter/rewriter.cpp +++ b/hotspot/src/share/vm/interpreter/rewriter.cpp @@ -67,13 +67,11 @@ void Rewriter::compute_index_maps() { // Creates a constant pool cache given a CPC map -// This creates the constant pool cache initially in a state -// that is unsafe for concurrent GC processing but sets it to -// a safe mode before the constant pool cache is returned. void Rewriter::make_constant_pool_cache(TRAPS) { const int length = _cp_cache_map.length(); constantPoolCacheOop cache = - oopFactory::new_constantPoolCache(length, methodOopDesc::IsUnsafeConc, CHECK); + oopFactory::new_constantPoolCache(length, CHECK); + No_Safepoint_Verifier nsv; cache->initialize(_cp_cache_map); // Don't bother with the next pass if there is no JVM_CONSTANT_InvokeDynamic. diff --git a/hotspot/src/share/vm/memory/oopFactory.cpp b/hotspot/src/share/vm/memory/oopFactory.cpp index f737bfdadea..c8b45b68a04 100644 --- a/hotspot/src/share/vm/memory/oopFactory.cpp +++ b/hotspot/src/share/vm/memory/oopFactory.cpp @@ -111,10 +111,9 @@ constantPoolOop oopFactory::new_constantPool(int length, constantPoolCacheOop oopFactory::new_constantPoolCache(int length, - bool is_conc_safe, TRAPS) { constantPoolCacheKlass* ck = constantPoolCacheKlass::cast(Universe::constantPoolCacheKlassObj()); - return ck->allocate(length, is_conc_safe, CHECK_NULL); + return ck->allocate(length, CHECK_NULL); } diff --git a/hotspot/src/share/vm/memory/oopFactory.hpp b/hotspot/src/share/vm/memory/oopFactory.hpp index da01364d038..49b89bc3b17 100644 --- a/hotspot/src/share/vm/memory/oopFactory.hpp +++ b/hotspot/src/share/vm/memory/oopFactory.hpp @@ -69,7 +69,6 @@ class oopFactory: AllStatic { bool is_conc_safe, TRAPS); static constantPoolCacheOop new_constantPoolCache(int length, - bool is_conc_safe, TRAPS); // Instance classes diff --git a/hotspot/src/share/vm/oops/constantPoolKlass.cpp b/hotspot/src/share/vm/oops/constantPoolKlass.cpp index 85d363b3e5a..38bcdd3e095 100644 --- a/hotspot/src/share/vm/oops/constantPoolKlass.cpp +++ b/hotspot/src/share/vm/oops/constantPoolKlass.cpp @@ -71,6 +71,12 @@ constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS c->set_is_conc_safe(is_conc_safe); // all fields are initialized; needed for GC + // Note: because we may be in this "conc_unsafe" state when allocating + // t_oop below, which may in turn cause a GC, it is imperative that our + // size be correct, consistent and henceforth stable, at this stage. + assert(c->is_parsable(), "Else size() below is unreliable"); + DEBUG_ONLY(int sz = c->size();) + // initialize tag array // Note: cannot introduce constant pool handle before since it is not // completely initialized (no class) -> would cause assertion failure @@ -82,6 +88,8 @@ constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS } pool->set_tags(tags()); + // Check that our size was stable at its old value. + assert(sz == c->size(), "size() changed"); return pool(); } diff --git a/hotspot/src/share/vm/oops/cpCacheKlass.cpp b/hotspot/src/share/vm/oops/cpCacheKlass.cpp index c3ed892fe82..fa9d9ecaa69 100644 --- a/hotspot/src/share/vm/oops/cpCacheKlass.cpp +++ b/hotspot/src/share/vm/oops/cpCacheKlass.cpp @@ -49,43 +49,31 @@ int constantPoolCacheKlass::oop_size(oop obj) const { constantPoolCacheOop constantPoolCacheKlass::allocate(int length, - bool is_conc_safe, TRAPS) { // allocate memory int size = constantPoolCacheOopDesc::object_size(length); KlassHandle klass (THREAD, as_klassOop()); - // This is the original code. The code from permanent_obj_allocate() - // was in-lined to allow the setting of is_conc_safe before the klass - // is installed. + // Commented out below is the original code. The code from + // permanent_obj_allocate() was in-lined so that we could + // set the _length field, necessary to correctly compute its + // size(), before setting its klass word further below. // constantPoolCacheOop cache = (constantPoolCacheOop) // CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL); oop obj = CollectedHeap::permanent_obj_allocate_no_klass_install(klass, size, CHECK_NULL); - constantPoolCacheOop cache = (constantPoolCacheOop) obj; - cache->set_is_conc_safe(is_conc_safe); - // The store to is_conc_safe must be visible before the klass - // is set. This should be done safely because _is_conc_safe has - // been declared volatile. If there are any problems, consider adding - // OrderAccess::storestore(); - CollectedHeap::post_allocation_install_obj_klass(klass, obj, size); NOT_PRODUCT(Universe::heap()->check_for_bad_heap_word_value((HeapWord*) obj, size)); - - // The length field affects the size of the object. The allocation - // above allocates the correct size (see calculation of "size") but - // the size() method of the constant pool cache oop will not reflect - // that size until the correct length is set. - cache->set_length(length); - - // The store of the length must be visible before is_conc_safe is - // set to a safe state. - // This should be done safely because _is_conc_safe has - // been declared volatile. If there are any problems, consider adding - // OrderAccess::storestore(); - cache->set_is_conc_safe(methodOopDesc::IsSafeConc); + constantPoolCacheOop cache = (constantPoolCacheOop) obj; + assert(!UseConcMarkSweepGC || obj->klass_or_null() == NULL, + "klass should be NULL here when using CMS"); + cache->set_length(length); // should become visible before klass is set below. cache->set_constant_pool(NULL); + + OrderAccess::storestore(); + obj->set_klass(klass()); + assert(cache->size() == size, "Incorrect cache->size()"); return cache; } @@ -176,11 +164,6 @@ int constantPoolCacheKlass::oop_adjust_pointers(oop obj) { return size; } -bool constantPoolCacheKlass::oop_is_conc_safe(oop obj) const { - assert(obj->is_constantPoolCache(), "should be constant pool"); - return constantPoolCacheOop(obj)->is_conc_safe(); -} - #ifndef SERIALGC void constantPoolCacheKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { diff --git a/hotspot/src/share/vm/oops/cpCacheKlass.hpp b/hotspot/src/share/vm/oops/cpCacheKlass.hpp index a3f6f3ecc0f..4a1532cffef 100644 --- a/hotspot/src/share/vm/oops/cpCacheKlass.hpp +++ b/hotspot/src/share/vm/oops/cpCacheKlass.hpp @@ -39,7 +39,7 @@ class constantPoolCacheKlass: public Klass { // Allocation DEFINE_ALLOCATE_PERMANENT(constantPoolCacheKlass); - constantPoolCacheOop allocate(int length, bool is_conc_safe, TRAPS); + constantPoolCacheOop allocate(int length, TRAPS); static klassOop create_klass(TRAPS); // Casting from klassOop @@ -55,7 +55,6 @@ class constantPoolCacheKlass: public Klass { // Garbage collection void oop_follow_contents(oop obj); int oop_adjust_pointers(oop obj); - virtual bool oop_is_conc_safe(oop obj) const; // Parallel Scavenge and Parallel Old PARALLEL_GC_DECLS diff --git a/hotspot/src/share/vm/oops/cpCacheOop.hpp b/hotspot/src/share/vm/oops/cpCacheOop.hpp index e180634250b..233c432c181 100644 --- a/hotspot/src/share/vm/oops/cpCacheOop.hpp +++ b/hotspot/src/share/vm/oops/cpCacheOop.hpp @@ -321,9 +321,6 @@ class constantPoolCacheOopDesc: public oopDesc { private: int _length; constantPoolOop _constant_pool; // the corresponding constant pool - // If true, safe for concurrent GC processing, - // Set unconditionally in constantPoolCacheKlass::allocate() - volatile bool _is_conc_safe; // Sizing debug_only(friend class ClassVerifier;) @@ -390,12 +387,6 @@ class constantPoolCacheOopDesc: public oopDesc { return entry_at(primary_index); } - // GC support - // If the _length field has not been set, the size of the - // constantPoolCache cannot be correctly calculated. - bool is_conc_safe() { return _is_conc_safe; } - void set_is_conc_safe(bool v) { _is_conc_safe = v; } - // Code generation static ByteSize base_offset() { return in_ByteSize(sizeof(constantPoolCacheOopDesc)); } static ByteSize entry_offset(int raw_index) { diff --git a/hotspot/src/share/vm/oops/methodOop.cpp b/hotspot/src/share/vm/oops/methodOop.cpp index 42ffbec7f1a..7bd79878af0 100644 --- a/hotspot/src/share/vm/oops/methodOop.cpp +++ b/hotspot/src/share/vm/oops/methodOop.cpp @@ -985,9 +985,11 @@ methodHandle methodOopDesc:: clone_with_new_data(methodHandle m, u_char* new_cod IsUnsafeConc, CHECK_(methodHandle())); methodHandle newm (THREAD, newm_oop); + NOT_PRODUCT(int nmsz = newm->is_parsable() ? newm->size() : -1;) int new_method_size = newm->method_size(); // Create a shallow copy of methodOopDesc part, but be careful to preserve the new constMethodOop constMethodOop newcm = newm->constMethod(); + NOT_PRODUCT(int ncmsz = newcm->is_parsable() ? newcm->size() : -1;) int new_const_method_size = newm->constMethod()->object_size(); memcpy(newm(), m(), sizeof(methodOopDesc)); @@ -999,9 +1001,19 @@ methodHandle methodOopDesc:: clone_with_new_data(methodHandle m, u_char* new_cod // or concurrent marking but those phases will be correct. Setting and // resetting is done in preference to a careful copying into newcm to // avoid having to know the precise layout of a constMethodOop. - m->constMethod()->set_is_conc_safe(false); + m->constMethod()->set_is_conc_safe(oopDesc::IsUnsafeConc); + assert(m->constMethod()->is_parsable(), "Should remain parsable"); + + // NOTE: this is a reachable object that transiently signals "conc_unsafe" + // However, no allocations are done during this window + // during which it is tagged conc_unsafe, so we are assured that any concurrent + // thread will not wait forever for the object to revert to "conc_safe". + // Further, any such conc_unsafe object will indicate a stable size + // through the transition. memcpy(newcm, m->constMethod(), sizeof(constMethodOopDesc)); - m->constMethod()->set_is_conc_safe(true); + m->constMethod()->set_is_conc_safe(oopDesc::IsSafeConc); + assert(m->constMethod()->is_parsable(), "Should remain parsable"); + // Reset correct method/const method, method size, and parameter info newcm->set_method(newm()); newm->set_constMethod(newcm); @@ -1035,6 +1047,8 @@ methodHandle methodOopDesc:: clone_with_new_data(methodHandle m, u_char* new_cod // Only set is_conc_safe to true when changes to newcm are // complete. + assert(!newm->is_parsable() || nmsz < 0 || newm->size() == nmsz, "newm->size() inconsistency"); + assert(!newcm->is_parsable() || ncmsz < 0 || newcm->size() == ncmsz, "newcm->size() inconsistency"); newcm->set_is_conc_safe(true); return newm; } diff --git a/hotspot/src/share/vm/oops/methodOop.hpp b/hotspot/src/share/vm/oops/methodOop.hpp index 279424514d1..2134f29d814 100644 --- a/hotspot/src/share/vm/oops/methodOop.hpp +++ b/hotspot/src/share/vm/oops/methodOop.hpp @@ -144,9 +144,6 @@ class methodOopDesc : public oopDesc { public: - static const bool IsUnsafeConc = false; - static const bool IsSafeConc = true; - // accessors for instance variables constMethodOop constMethod() const { return _constMethod; } void set_constMethod(constMethodOop xconst) { oop_store_without_check((oop*)&_constMethod, (oop)xconst); } diff --git a/hotspot/src/share/vm/oops/oop.hpp b/hotspot/src/share/vm/oops/oop.hpp index dae1c43c0ff..4507e7d8e31 100644 --- a/hotspot/src/share/vm/oops/oop.hpp +++ b/hotspot/src/share/vm/oops/oop.hpp @@ -71,6 +71,11 @@ class oopDesc { static BarrierSet* _bs; public: + enum ConcSafeType { + IsUnsafeConc = false, + IsSafeConc = true + }; + markOop mark() const { return _mark; } markOop* mark_addr() const { return (markOop*) &_mark; } diff --git a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp index 0bc15e0b3bf..26e9e5bc857 100644 --- a/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp +++ b/hotspot/src/share/vm/prims/jvmtiRedefineClasses.cpp @@ -1247,12 +1247,12 @@ jvmtiError VM_RedefineClasses::merge_cp_and_rewrite( // Constant pools are not easily reused so we allocate a new one // each time. // merge_cp is created unsafe for concurrent GC processing. It - // should be marked safe before discarding it because, even if - // garbage. If it crosses a card boundary, it may be scanned + // should be marked safe before discarding it. Even though + // garbage, if it crosses a card boundary, it may be scanned // in order to find the start of the first complete object on the card. constantPoolHandle merge_cp(THREAD, oopFactory::new_constantPool(merge_cp_length, - methodOopDesc::IsUnsafeConc, + oopDesc::IsUnsafeConc, THREAD)); int orig_length = old_cp->orig_length(); if (orig_length == 0) { @@ -2343,7 +2343,7 @@ void VM_RedefineClasses::set_new_constant_pool( // sized constant pool with the klass to save space. constantPoolHandle smaller_cp(THREAD, oopFactory::new_constantPool(scratch_cp_length, - methodOopDesc::IsUnsafeConc, + oopDesc::IsUnsafeConc, THREAD)); // preserve orig_length() value in the smaller copy int orig_length = scratch_cp->orig_length(); diff --git a/hotspot/src/share/vm/prims/methodHandleWalk.cpp b/hotspot/src/share/vm/prims/methodHandleWalk.cpp index 6419b14622d..61a7eeb4f70 100644 --- a/hotspot/src/share/vm/prims/methodHandleWalk.cpp +++ b/hotspot/src/share/vm/prims/methodHandleWalk.cpp @@ -1134,8 +1134,9 @@ int MethodHandleCompiler::cpool_primitive_put(BasicType bt, jvalue* con) { constantPoolHandle MethodHandleCompiler::get_constant_pool(TRAPS) const { constantPoolHandle nullHandle; - bool is_conc_safe = true; - constantPoolOop cpool_oop = oopFactory::new_constantPool(_constants.length(), is_conc_safe, CHECK_(nullHandle)); + constantPoolOop cpool_oop = oopFactory::new_constantPool(_constants.length(), + oopDesc::IsSafeConc, + CHECK_(nullHandle)); constantPoolHandle cpool(THREAD, cpool_oop); // Fill the real constant pool skipping the zero element. @@ -1180,10 +1181,9 @@ methodHandle MethodHandleCompiler::get_method_oop(TRAPS) const { else flags_bits = (/*JVM_MH_INVOKE_BITS |*/ JVM_ACC_PUBLIC | JVM_ACC_FINAL | JVM_ACC_SYNTHETIC); - bool is_conc_safe = true; methodOop m_oop = oopFactory::new_method(bytecode_length(), accessFlags_from(flags_bits), - 0, 0, 0, is_conc_safe, CHECK_(nullHandle)); + 0, 0, 0, oopDesc::IsSafeConc, CHECK_(nullHandle)); methodHandle m(THREAD, m_oop); m_oop = NULL; // oop not GC safe From 0c395c779965a40fc15f995f3c49ac7df4da2930 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Tue, 8 Feb 2011 12:33:19 +0100 Subject: [PATCH 012/105] 7014851: Remove unused parallel compaction code Removed. Reviewed-by: jcoomes, brutisso --- .../parallelScavenge/psParallelCompact.hpp | 16 +------ hotspot/src/share/vm/oops/arrayKlassKlass.cpp | 23 +--------- .../share/vm/oops/compiledICHolderKlass.cpp | 17 +------ .../src/share/vm/oops/constMethodKlass.cpp | 17 +------ .../src/share/vm/oops/constantPoolKlass.cpp | 36 +-------------- hotspot/src/share/vm/oops/cpCacheKlass.cpp | 21 +-------- hotspot/src/share/vm/oops/cpCacheOop.cpp | 12 +---- hotspot/src/share/vm/oops/cpCacheOop.hpp | 3 +- hotspot/src/share/vm/oops/instanceKlass.cpp | 19 +------- hotspot/src/share/vm/oops/instanceKlass.hpp | 3 +- .../src/share/vm/oops/instanceKlassKlass.cpp | 31 +------------ .../src/share/vm/oops/instanceRefKlass.cpp | 29 +----------- hotspot/src/share/vm/oops/klassKlass.cpp | 15 +----- hotspot/src/share/vm/oops/klassPS.hpp | 10 ++-- hotspot/src/share/vm/oops/klassVtable.cpp | 40 +--------------- hotspot/src/share/vm/oops/klassVtable.hpp | 6 +-- hotspot/src/share/vm/oops/methodDataKlass.cpp | 21 +-------- hotspot/src/share/vm/oops/methodDataOop.cpp | 11 ----- hotspot/src/share/vm/oops/methodDataOop.hpp | 4 +- hotspot/src/share/vm/oops/methodKlass.cpp | 23 +--------- hotspot/src/share/vm/oops/objArrayKlass.cpp | 10 ---- .../src/share/vm/oops/objArrayKlassKlass.cpp | 18 +------- hotspot/src/share/vm/oops/oop.hpp | 10 +--- hotspot/src/share/vm/oops/oop.pcgc.inline.hpp | 46 +------------------ hotspot/src/share/vm/oops/typeArrayKlass.cpp | 7 --- 25 files changed, 24 insertions(+), 424 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp index e69730202d5..0e2c6477aff 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -1196,11 +1196,6 @@ class PSParallelCompact : AllStatic { static inline void adjust_pointer(oop* p) { adjust_pointer(p, false); } static inline void adjust_pointer(narrowOop* p) { adjust_pointer(p, false); } - template - static inline void adjust_pointer(T* p, - HeapWord* beg_addr, - HeapWord* end_addr); - // Reference Processing static ReferenceProcessor* const ref_processor() { return _ref_processor; } @@ -1408,15 +1403,6 @@ inline bool PSParallelCompact::should_update_klass(klassOop k) { return ((HeapWord*) k) >= dense_prefix(perm_space_id); } -template -inline void PSParallelCompact::adjust_pointer(T* p, - HeapWord* beg_addr, - HeapWord* end_addr) { - if (is_in((HeapWord*)p, beg_addr, end_addr)) { - adjust_pointer(p); - } -} - #ifdef ASSERT inline void PSParallelCompact::check_new_location(HeapWord* old_addr, HeapWord* new_addr) diff --git a/hotspot/src/share/vm/oops/arrayKlassKlass.cpp b/hotspot/src/share/vm/oops/arrayKlassKlass.cpp index a27e62f10ac..5215d146ce2 100644 --- a/hotspot/src/share/vm/oops/arrayKlassKlass.cpp +++ b/hotspot/src/share/vm/oops/arrayKlassKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -128,27 +128,6 @@ int arrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { } return klassKlass::oop_update_pointers(cm, obj); } - -int -arrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, HeapWord* end_addr) { - assert(obj->is_klass(), "must be klass"); - arrayKlass* ak = arrayKlass::cast(klassOop(obj)); - - oop* p; - p = ak->adr_component_mirror(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - p = ak->adr_lower_dimension(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - p = ak->adr_higher_dimension(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - - { - HandleMark hm; - ak->vtable()->oop_update_pointers(cm, beg_addr, end_addr); - } - return klassKlass::oop_update_pointers(cm, obj, beg_addr, end_addr); -} #endif // SERIALGC // Printing diff --git a/hotspot/src/share/vm/oops/compiledICHolderKlass.cpp b/hotspot/src/share/vm/oops/compiledICHolderKlass.cpp index f91716d1254..6f982bf99b0 100644 --- a/hotspot/src/share/vm/oops/compiledICHolderKlass.cpp +++ b/hotspot/src/share/vm/oops/compiledICHolderKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -145,21 +145,6 @@ int compiledICHolderKlass::oop_update_pointers(ParCompactionManager* cm, PSParallelCompact::adjust_pointer(c->adr_holder_klass()); return c->object_size(); } - -int compiledICHolderKlass::oop_update_pointers(ParCompactionManager* cm, - oop obj, - HeapWord* beg_addr, - HeapWord* end_addr) { - assert(obj->is_compiledICHolder(), "must be compiledICHolder"); - compiledICHolderOop c = compiledICHolderOop(obj); - - oop* p; - p = c->adr_holder_method(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - p = c->adr_holder_klass(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - return c->object_size(); -} #endif // SERIALGC // Printing diff --git a/hotspot/src/share/vm/oops/constMethodKlass.cpp b/hotspot/src/share/vm/oops/constMethodKlass.cpp index 19e292d7ad7..6e065317d5d 100644 --- a/hotspot/src/share/vm/oops/constMethodKlass.cpp +++ b/hotspot/src/share/vm/oops/constMethodKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -184,21 +184,6 @@ int constMethodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { } return cm_oop->object_size(); } - -int constMethodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, - HeapWord* end_addr) { - assert(obj->is_constMethod(), "should be constMethod"); - constMethodOop cm_oop = constMethodOop(obj); - - oop* const beg_oop = MAX2((oop*)beg_addr, cm_oop->oop_block_beg()); - oop* const end_oop = MIN2((oop*)end_addr, cm_oop->oop_block_end()); - for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { - PSParallelCompact::adjust_pointer(cur_oop); - } - - return cm_oop->object_size(); -} #endif // SERIALGC // Printing diff --git a/hotspot/src/share/vm/oops/constantPoolKlass.cpp b/hotspot/src/share/vm/oops/constantPoolKlass.cpp index 38bcdd3e095..3b097d9634d 100644 --- a/hotspot/src/share/vm/oops/constantPoolKlass.cpp +++ b/hotspot/src/share/vm/oops/constantPoolKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -279,40 +279,6 @@ int constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { return cp->object_size(); } -int -constantPoolKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, HeapWord* end_addr) { - assert (obj->is_constantPool(), "obj must be constant pool"); - constantPoolOop cp = (constantPoolOop) obj; - - // If the tags array is null we are in the middle of allocating this constant - // pool. - if (cp->tags() != NULL) { - oop* base = (oop*)cp->base(); - oop* const beg_oop = MAX2((oop*)beg_addr, base); - oop* const end_oop = MIN2((oop*)end_addr, base + cp->length()); - const size_t beg_idx = pointer_delta(beg_oop, base, sizeof(oop*)); - const size_t end_idx = pointer_delta(end_oop, base, sizeof(oop*)); - for (size_t cur_idx = beg_idx; cur_idx < end_idx; ++cur_idx, ++base) { - if (cp->is_pointer_entry(int(cur_idx))) { - PSParallelCompact::adjust_pointer(base); - } - } - } - - oop* p; - p = cp->tags_addr(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - p = cp->cache_addr(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - p = cp->operands_addr(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - p = cp->pool_holder_addr(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - - return cp->object_size(); -} - void constantPoolKlass::oop_push_contents(PSPromotionManager* pm, oop obj) { assert(obj->is_constantPool(), "should be constant pool"); constantPoolOop cp = (constantPoolOop) obj; diff --git a/hotspot/src/share/vm/oops/cpCacheKlass.cpp b/hotspot/src/share/vm/oops/cpCacheKlass.cpp index fa9d9ecaa69..233c7e64464 100644 --- a/hotspot/src/share/vm/oops/cpCacheKlass.cpp +++ b/hotspot/src/share/vm/oops/cpCacheKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -203,25 +203,6 @@ constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { return cache->object_size(); } - -int -constantPoolCacheKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, - HeapWord* end_addr) { - assert(obj->is_constantPoolCache(), "obj must be constant pool cache"); - constantPoolCacheOop cache = (constantPoolCacheOop)obj; - - // Iteration over constant pool cache instance variables - oop* p; - p = (oop*)cache->constant_pool_addr(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - - // Iteration over constant pool cache entries - for (int i = 0; i < cache->length(); ++i) { - cache->entry_at(i)->update_pointers(beg_addr, end_addr); - } - return cache->object_size(); -} #endif // SERIALGC void constantPoolCacheKlass::oop_print_on(oop obj, outputStream* st) { diff --git a/hotspot/src/share/vm/oops/cpCacheOop.cpp b/hotspot/src/share/vm/oops/cpCacheOop.cpp index e627a250b51..039fccf4283 100644 --- a/hotspot/src/share/vm/oops/cpCacheOop.cpp +++ b/hotspot/src/share/vm/oops/cpCacheOop.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -368,16 +368,6 @@ void ConstantPoolCacheEntry::update_pointers() { PSParallelCompact::adjust_pointer((oop*)&_f2); } } - -void ConstantPoolCacheEntry::update_pointers(HeapWord* beg_addr, - HeapWord* end_addr) { - assert(in_words(size()) == 4, "check code below - may need adjustment"); - // field[1] is always oop or NULL - PSParallelCompact::adjust_pointer((oop*)&_f1, beg_addr, end_addr); - if (is_vfinal()) { - PSParallelCompact::adjust_pointer((oop*)&_f2, beg_addr, end_addr); - } -} #endif // SERIALGC // RedefineClasses() API support: diff --git a/hotspot/src/share/vm/oops/cpCacheOop.hpp b/hotspot/src/share/vm/oops/cpCacheOop.hpp index 233c432c181..e59c4952182 100644 --- a/hotspot/src/share/vm/oops/cpCacheOop.hpp +++ b/hotspot/src/share/vm/oops/cpCacheOop.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -287,7 +287,6 @@ class ConstantPoolCacheEntry VALUE_OBJ_CLASS_SPEC { #endif // SERIALGC void update_pointers(); - void update_pointers(HeapWord* beg_addr, HeapWord* end_addr); // RedefineClasses() API support: // If this constantPoolCacheEntry refers to old_method then update it diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 893fddf3ba5..73f4d97dfcb 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -1736,14 +1736,6 @@ void instanceKlass::update_static_fields() { PSParallelCompact::adjust_pointer(p), \ assert_nothing) } - -void instanceKlass::update_static_fields(HeapWord* beg_addr, HeapWord* end_addr) { - InstanceKlass_BOUNDED_OOP_ITERATE( \ - start_of_static_fields(), static_oop_field_size(), \ - beg_addr, end_addr, \ - PSParallelCompact::adjust_pointer(p), \ - assert_nothing ) -} #endif // SERIALGC void instanceKlass::oop_follow_contents(oop obj) { @@ -1876,15 +1868,6 @@ int instanceKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { return size_helper(); } -int instanceKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, HeapWord* end_addr) { - InstanceKlass_BOUNDED_OOP_MAP_ITERATE( \ - obj, beg_addr, end_addr, \ - PSParallelCompact::adjust_pointer(p), \ - assert_nothing) - return size_helper(); -} - void instanceKlass::push_static_fields(PSPromotionManager* pm) { InstanceKlass_OOP_ITERATE( \ start_of_static_fields(), static_oop_field_size(), \ diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index 6a09bdfa5cc..c2f7da14ba6 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -740,7 +740,6 @@ class instanceKlass: public Klass { void follow_static_fields(ParCompactionManager* cm); void copy_static_fields(ParCompactionManager* cm); void update_static_fields(); - void update_static_fields(HeapWord* beg_addr, HeapWord* end_addr); #endif // SERIALGC // Naming diff --git a/hotspot/src/share/vm/oops/instanceKlassKlass.cpp b/hotspot/src/share/vm/oops/instanceKlassKlass.cpp index e2667bba792..150621fa708 100644 --- a/hotspot/src/share/vm/oops/instanceKlassKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlassKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -353,35 +353,6 @@ int instanceKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { return ik->object_size(); } -int instanceKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, - HeapWord* end_addr) { - assert(obj->is_klass(),"must be a klass"); - assert(klassOop(obj)->klass_part()->oop_is_instance_slow(), - "must be instance klass"); - - instanceKlass* ik = instanceKlass::cast(klassOop(obj)); - ik->update_static_fields(beg_addr, end_addr); - ik->vtable()->oop_update_pointers(cm, beg_addr, end_addr); - ik->itable()->oop_update_pointers(cm, beg_addr, end_addr); - - oop* const beg_oop = MAX2((oop*)beg_addr, ik->oop_block_beg()); - oop* const end_oop = MIN2((oop*)end_addr, ik->oop_block_end()); - for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { - PSParallelCompact::adjust_pointer(cur_oop); - } - - // The oop_map_cache, jni_ids and jni_id_map are allocated from the C heap, - // and so don't lie within any 'Chunk' boundaries. Update them when the - // lowest addressed oop in the instanceKlass 'oop_block' is updated. - if (beg_oop == ik->oop_block_beg()) { - OopClosure* closure = PSParallelCompact::adjust_root_pointer_closure(); - iterate_c_heap_oops(ik, closure); - } - - klassKlass::oop_update_pointers(cm, obj, beg_addr, end_addr); - return ik->object_size(); -} #endif // SERIALGC klassOop diff --git a/hotspot/src/share/vm/oops/instanceRefKlass.cpp b/hotspot/src/share/vm/oops/instanceRefKlass.cpp index da2005dc778..4518a9da17b 100644 --- a/hotspot/src/share/vm/oops/instanceRefKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceRefKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -344,33 +344,6 @@ int instanceRefKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { } return size_helper(); } - - -template void -specialized_oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, HeapWord* end_addr) { - T* p; - T* referent_addr = p = (T*)java_lang_ref_Reference::referent_addr(obj); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - T* next_addr = p = (T*)java_lang_ref_Reference::next_addr(obj); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - T* discovered_addr = p = (T*)java_lang_ref_Reference::discovered_addr(obj); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - debug_only(trace_reference_gc("instanceRefKlass::oop_update_ptrs", obj, - referent_addr, next_addr, discovered_addr);) -} - -int -instanceRefKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, HeapWord* end_addr) { - instanceKlass::oop_update_pointers(cm, obj, beg_addr, end_addr); - if (UseCompressedOops) { - specialized_oop_update_pointers(cm, obj, beg_addr, end_addr); - } else { - specialized_oop_update_pointers(cm, obj, beg_addr, end_addr); - } - return size_helper(); -} #endif // SERIALGC void instanceRefKlass::update_nonstatic_oop_maps(klassOop k) { diff --git a/hotspot/src/share/vm/oops/klassKlass.cpp b/hotspot/src/share/vm/oops/klassKlass.cpp index 79867acf06d..6411609d73e 100644 --- a/hotspot/src/share/vm/oops/klassKlass.cpp +++ b/hotspot/src/share/vm/oops/klassKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -188,19 +188,6 @@ int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { return oop_size(obj); } - -int klassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, HeapWord* end_addr) { - Klass* k = Klass::cast(klassOop(obj)); - - oop* const beg_oop = MAX2((oop*)beg_addr, k->oop_block_beg()); - oop* const end_oop = MIN2((oop*)end_addr, k->oop_block_end()); - for (oop* cur_oop = beg_oop; cur_oop < end_oop; ++cur_oop) { - PSParallelCompact::adjust_pointer(cur_oop); - } - - return oop_size(obj); -} #endif // SERIALGC diff --git a/hotspot/src/share/vm/oops/klassPS.hpp b/hotspot/src/share/vm/oops/klassPS.hpp index fa898b070ed..0aa7a580d4c 100644 --- a/hotspot/src/share/vm/oops/klassPS.hpp +++ b/hotspot/src/share/vm/oops/klassPS.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -37,17 +37,13 @@ objects that do (or may) cross chunk boundaries; it updates only those \ oops that are in the region [beg_addr, end_addr). */ \ virtual void oop_follow_contents(ParCompactionManager* cm, oop obj); \ - virtual int oop_update_pointers(ParCompactionManager* cm, oop obj); \ - virtual int oop_update_pointers(ParCompactionManager* cm, oop obj, \ - HeapWord* beg_addr, HeapWord* end_addr); + virtual int oop_update_pointers(ParCompactionManager* cm, oop obj); // Pure virtual version for klass.hpp #define PARALLEL_GC_DECLS_PV \ virtual void oop_push_contents(PSPromotionManager* pm, oop obj) = 0; \ virtual void oop_follow_contents(ParCompactionManager* cm, oop obj) = 0; \ - virtual int oop_update_pointers(ParCompactionManager* cm, oop obj) = 0; \ - virtual int oop_update_pointers(ParCompactionManager* cm, oop obj, \ - HeapWord* beg_addr, HeapWord* end_addr) = 0; + virtual int oop_update_pointers(ParCompactionManager* cm, oop obj) = 0; #else // SERIALGC #define PARALLEL_GC_DECLS #define PARALLEL_GC_DECLS_PV diff --git a/hotspot/src/share/vm/oops/klassVtable.cpp b/hotspot/src/share/vm/oops/klassVtable.cpp index 4ea39839b5e..f0939cb6919 100644 --- a/hotspot/src/share/vm/oops/klassVtable.cpp +++ b/hotspot/src/share/vm/oops/klassVtable.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -677,25 +677,6 @@ void klassVtable::oop_update_pointers(ParCompactionManager* cm) { PSParallelCompact::adjust_pointer(adr_method_at(i)); } } - -void klassVtable::oop_update_pointers(ParCompactionManager* cm, - HeapWord* beg_addr, HeapWord* end_addr) { - const int n = length(); - const int entry_size = vtableEntry::size(); - - int beg_idx = 0; - HeapWord* const method_0 = (HeapWord*)adr_method_at(0); - if (beg_addr > method_0) { - // it's safe to use cast, as we have guarantees on vtable size to be sane - beg_idx = int((pointer_delta(beg_addr, method_0) + entry_size - 1) / entry_size); - } - - oop* const beg_oop = adr_method_at(beg_idx); - oop* const end_oop = MIN2((oop*)end_addr, adr_method_at(n)); - for (oop* cur_oop = beg_oop; cur_oop < end_oop; cur_oop += entry_size) { - PSParallelCompact::adjust_pointer(cur_oop); - } -} #endif // SERIALGC // Iterators @@ -820,25 +801,6 @@ void klassItable::oop_update_pointers(ParCompactionManager* cm) { ime++; } } - -void klassItable::oop_update_pointers(ParCompactionManager* cm, - HeapWord* beg_addr, HeapWord* end_addr) { - // offset table - itableOffsetEntry* ioe = offset_entry(0); - for(int i = 0; i < _size_offset_table; i++) { - oop* p = (oop*)&ioe->_interface; - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - ioe++; - } - - // method table - itableMethodEntry* ime = method_entry(0); - for(int j = 0; j < _size_method_table; j++) { - oop* p = (oop*)&ime->_method; - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - ime++; - } -} #endif // SERIALGC // Iterators diff --git a/hotspot/src/share/vm/oops/klassVtable.hpp b/hotspot/src/share/vm/oops/klassVtable.hpp index 1f77ea7291d..33f5b62e19b 100644 --- a/hotspot/src/share/vm/oops/klassVtable.hpp +++ b/hotspot/src/share/vm/oops/klassVtable.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -99,8 +99,6 @@ class klassVtable : public ResourceObj { // Parallel Old void oop_follow_contents(ParCompactionManager* cm); void oop_update_pointers(ParCompactionManager* cm); - void oop_update_pointers(ParCompactionManager* cm, - HeapWord* beg_addr, HeapWord* end_addr); #endif // SERIALGC // Iterators @@ -295,8 +293,6 @@ class klassItable : public ResourceObj { // Parallel Old void oop_follow_contents(ParCompactionManager* cm); void oop_update_pointers(ParCompactionManager* cm); - void oop_update_pointers(ParCompactionManager* cm, - HeapWord* beg_addr, HeapWord* end_addr); #endif // SERIALGC // Iterators diff --git a/hotspot/src/share/vm/oops/methodDataKlass.cpp b/hotspot/src/share/vm/oops/methodDataKlass.cpp index 500dd7726db..c5202f538bc 100644 --- a/hotspot/src/share/vm/oops/methodDataKlass.cpp +++ b/hotspot/src/share/vm/oops/methodDataKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -188,25 +188,6 @@ int methodDataKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { } return m->object_size(); } - -int -methodDataKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, HeapWord* end_addr) { - assert(obj->is_methodData(), "should be method data"); - - oop* p; - methodDataOop m = methodDataOop(obj); - - p = m->adr_method(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - - ResourceMark rm; - ProfileData* data; - for (data = m->first_data(); m->is_valid(data); data = m->next_data(data)) { - data->update_pointers(beg_addr, end_addr); - } - return m->object_size(); -} #endif // SERIALGC #ifndef PRODUCT diff --git a/hotspot/src/share/vm/oops/methodDataOop.cpp b/hotspot/src/share/vm/oops/methodDataOop.cpp index b0856dbca46..7c4aeb0a906 100644 --- a/hotspot/src/share/vm/oops/methodDataOop.cpp +++ b/hotspot/src/share/vm/oops/methodDataOop.cpp @@ -271,17 +271,6 @@ void ReceiverTypeData::update_pointers() { } } } - -void ReceiverTypeData::update_pointers(HeapWord* beg_addr, HeapWord* end_addr) { - // The loop bounds could be computed based on beg_addr/end_addr and the - // boundary test hoisted outside the loop (see klassVTable for an example); - // however, row_limit() is small enough (2) to make that less efficient. - for (uint row = 0; row < row_limit(); row++) { - if (receiver_unchecked(row) != NULL) { - PSParallelCompact::adjust_pointer(adr_receiver(row), beg_addr, end_addr); - } - } -} #endif // SERIALGC #ifndef PRODUCT diff --git a/hotspot/src/share/vm/oops/methodDataOop.hpp b/hotspot/src/share/vm/oops/methodDataOop.hpp index a3f64948956..521ba9480b2 100644 --- a/hotspot/src/share/vm/oops/methodDataOop.hpp +++ b/hotspot/src/share/vm/oops/methodDataOop.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -452,7 +452,6 @@ public: // Parallel old support virtual void follow_contents(ParCompactionManager* cm) {} virtual void update_pointers() {} - virtual void update_pointers(HeapWord* beg_addr, HeapWord* end_addr) {} #endif // SERIALGC // CI translation: ProfileData can represent both MethodDataOop data @@ -748,7 +747,6 @@ public: // Parallel old support virtual void follow_contents(ParCompactionManager* cm); virtual void update_pointers(); - virtual void update_pointers(HeapWord* beg_addr, HeapWord* end_addr); #endif // SERIALGC oop* adr_receiver(uint row) { diff --git a/hotspot/src/share/vm/oops/methodKlass.cpp b/hotspot/src/share/vm/oops/methodKlass.cpp index 08c49ae4d6a..85ac2c4cb8f 100644 --- a/hotspot/src/share/vm/oops/methodKlass.cpp +++ b/hotspot/src/share/vm/oops/methodKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -214,27 +214,6 @@ int methodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { #endif // COMPILER2 return m->object_size(); } - -int methodKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, HeapWord* end_addr) { - assert(obj->is_method(), "should be method"); - - oop* p; - methodOop m = methodOop(obj); - - p = m->adr_constMethod(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - p = m->adr_constants(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - -#ifdef COMPILER2 - if (m->method_data() != NULL) { - p = m->adr_method_data(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - } -#endif // COMPILER2 - return m->object_size(); -} #endif // SERIALGC #ifndef PRODUCT diff --git a/hotspot/src/share/vm/oops/objArrayKlass.cpp b/hotspot/src/share/vm/oops/objArrayKlass.cpp index 405301d8d71..da9667dee7b 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp @@ -470,16 +470,6 @@ int objArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { ObjArrayKlass_OOP_ITERATE(a, p, PSParallelCompact::adjust_pointer(p)) return a->object_size(); } - -int objArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, HeapWord* end_addr) { - assert (obj->is_objArray(), "obj must be obj array"); - objArrayOop a = objArrayOop(obj); - ObjArrayKlass_BOUNDED_OOP_ITERATE( \ - a, p, beg_addr, end_addr, \ - PSParallelCompact::adjust_pointer(p)) - return a->object_size(); -} #endif // SERIALGC // JVM support diff --git a/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp b/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp index b85e8dffc66..a21110250a2 100644 --- a/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp +++ b/hotspot/src/share/vm/oops/objArrayKlassKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -254,22 +254,6 @@ int objArrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { return arrayKlassKlass::oop_update_pointers(cm, obj); } - -int objArrayKlassKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, - HeapWord* end_addr) { - assert(obj->is_klass(), "must be klass"); - assert(klassOop(obj)->klass_part()->oop_is_objArray_slow(), "must be obj array"); - - oop* p; - objArrayKlass* oak = objArrayKlass::cast((klassOop)obj); - p = oak->element_klass_addr(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - p = oak->bottom_klass_addr(); - PSParallelCompact::adjust_pointer(p, beg_addr, end_addr); - - return arrayKlassKlass::oop_update_pointers(cm, obj, beg_addr, end_addr); -} #endif // SERIALGC #ifndef PRODUCT diff --git a/hotspot/src/share/vm/oops/oop.hpp b/hotspot/src/share/vm/oops/oop.hpp index 4507e7d8e31..7553ec38ff9 100644 --- a/hotspot/src/share/vm/oops/oop.hpp +++ b/hotspot/src/share/vm/oops/oop.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -322,13 +322,6 @@ class oopDesc { // Parallel Old void update_contents(ParCompactionManager* cm); - void update_contents(ParCompactionManager* cm, - HeapWord* begin_limit, - HeapWord* end_limit); - void update_contents(ParCompactionManager* cm, - klassOop old_klass, - HeapWord* begin_limit, - HeapWord* end_limit); void follow_contents(ParCompactionManager* cm); void follow_header(ParCompactionManager* cm); @@ -369,7 +362,6 @@ class oopDesc { #ifndef SERIALGC // Parallel old void update_header(); - void update_header(HeapWord* beg_addr, HeapWord* end_addr); #endif // SERIALGC // mark-sweep support diff --git a/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp b/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp index fc969970cba..cee33200c1a 100644 --- a/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp +++ b/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -57,41 +57,6 @@ inline void oopDesc::update_contents(ParCompactionManager* cm) { // Else skip it. The typeArrayKlass in the header never needs scavenging. } -inline void oopDesc::update_contents(ParCompactionManager* cm, - HeapWord* begin_limit, - HeapWord* end_limit) { - // The klass field must be updated before anything else - // can be done. - debug_only(klassOopDesc* original_klass = klass()); - - update_contents(cm, klass(), begin_limit, end_limit); -} - -inline void oopDesc::update_contents(ParCompactionManager* cm, - klassOop old_klass, - HeapWord* begin_limit, - HeapWord* end_limit) { - - klassOop updated_klass = - PSParallelCompact::summary_data().calc_new_klass(old_klass); - - // Needs to be boundary aware for the 64 bit case - // update_header(); - // The klass has moved. Is the location of the klass - // within the limits? - if ((((HeapWord*)&_metadata._klass) >= begin_limit) && - (((HeapWord*)&_metadata._klass) < end_limit)) { - set_klass(updated_klass); - } - - Klass* klass = updated_klass->klass_part(); - if (!klass->oop_is_typeArray()) { - // It might contain oops beyond the header, so take the virtual call. - klass->oop_update_pointers(cm, this, begin_limit, end_limit); - } - // Else skip it. The typeArrayKlass in the header never needs scavenging. -} - inline void oopDesc::follow_contents(ParCompactionManager* cm) { assert (PSParallelCompact::mark_bitmap()->is_marked(this), "should be marked"); @@ -140,13 +105,4 @@ inline void oopDesc::update_header() { } } -inline void oopDesc::update_header(HeapWord* beg_addr, HeapWord* end_addr) { - if (UseCompressedOops) { - PSParallelCompact::adjust_pointer(compressed_klass_addr(), - beg_addr, end_addr); - } else { - PSParallelCompact::adjust_pointer(klass_addr(), beg_addr, end_addr); - } -} - #endif // SHARE_VM_OOPS_OOP_PCGC_INLINE_HPP diff --git a/hotspot/src/share/vm/oops/typeArrayKlass.cpp b/hotspot/src/share/vm/oops/typeArrayKlass.cpp index 3ec36256945..a733e4bb138 100644 --- a/hotspot/src/share/vm/oops/typeArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/typeArrayKlass.cpp @@ -250,13 +250,6 @@ typeArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj) { assert(obj->is_typeArray(),"must be a type array"); return typeArrayOop(obj)->object_size(); } - -int -typeArrayKlass::oop_update_pointers(ParCompactionManager* cm, oop obj, - HeapWord* beg_addr, HeapWord* end_addr) { - assert(obj->is_typeArray(),"must be a type array"); - return typeArrayOop(obj)->object_size(); -} #endif // SERIALGC void typeArrayKlass::initialize(TRAPS) { From a6241f31b17b7370bf777e24f2beb15e7194551b Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 8 Feb 2011 14:24:14 -0800 Subject: [PATCH 013/105] 7006865: Regression: Corrupted output when printing images with bit depth of 4 Reviewed-by: bae, jgodinez --- .../sun/awt/windows/WPathGraphics.java | 26 +- .../classes/sun/awt/windows/WPrinterJob.java | 5 +- .../PrinterJob/ImagePrinting/ImageTypes.java | 272 ++++++++++++++++++ 3 files changed, 299 insertions(+), 4 deletions(-) create mode 100644 jdk/test/java/awt/print/PrinterJob/ImagePrinting/ImageTypes.java diff --git a/jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java b/jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java index d2700a1c91d..180341f20f3 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java +++ b/jdk/src/windows/classes/sun/awt/windows/WPathGraphics.java @@ -51,9 +51,12 @@ import java.awt.image.ColorModel; import java.awt.image.DataBuffer; import java.awt.image.IndexColorModel; import java.awt.image.WritableRaster; +import java.awt.image.ComponentSampleModel; +import java.awt.image.MultiPixelPackedSampleModel; +import java.awt.image.SampleModel; + import sun.awt.image.ByteComponentRaster; import sun.awt.image.BytePackedRaster; - import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; @@ -1272,6 +1275,25 @@ class WPathGraphics extends PathGraphics { return false; } + int bitsPerPixel = 24; + SampleModel sm = deepImage.getSampleModel(); + if (sm instanceof ComponentSampleModel) { + ComponentSampleModel csm = (ComponentSampleModel)sm; + bitsPerPixel = csm.getPixelStride() * 8; + } else if (sm instanceof MultiPixelPackedSampleModel) { + MultiPixelPackedSampleModel mppsm = + (MultiPixelPackedSampleModel)sm; + bitsPerPixel = mppsm.getPixelBitStride(); + } else { + if (icm != null) { + int diw = deepImage.getWidth(); + int dih = deepImage.getHeight(); + if (diw > 0 && dih > 0) { + bitsPerPixel = data.length*8/diw/dih; + } + } + } + /* Because the caller's image has been rotated * and sheared into our BufferedImage and because * we will be handing that BufferedImage directly to @@ -1289,7 +1311,7 @@ class WPathGraphics extends PathGraphics { (float)Math.rint(scaledBounds.height+0.5), 0f, 0f, deepImage.getWidth(), deepImage.getHeight(), - icm); + bitsPerPixel, icm); setClip(holdClip); } diff --git a/jdk/src/windows/classes/sun/awt/windows/WPrinterJob.java b/jdk/src/windows/classes/sun/awt/windows/WPrinterJob.java index b73a1b51517..cf629bb0ae8 100644 --- a/jdk/src/windows/classes/sun/awt/windows/WPrinterJob.java +++ b/jdk/src/windows/classes/sun/awt/windows/WPrinterJob.java @@ -1212,13 +1212,14 @@ public class WPrinterJob extends RasterPrinterJob implements DisposerTarget { float destWidth, float destHeight, float srcX, float srcY, float srcWidth, float srcHeight, + int sampleBitsPerPixel, IndexColorModel icm) { int bitCount = 24; byte[] bmiColors = null; if (icm != null) { - bitCount = icm.getPixelSize(); - bmiColors = new byte[(1< 0) { + return Printable.NO_SUCH_PAGE; + } + Graphics2D g2d = (Graphics2D)g; + g2d.translate(pgFmt.getImageableX(), pgFmt.getImageableY()); + paint(g2d); + return Printable.PAGE_EXISTS; + } + + private void drawImage(Graphics g, int biType, IndexColorModel icm) { + + BufferedImage bi; + if (icm != null) { + bi = new BufferedImage(sw, sh, biType, icm); + } else { + bi = new BufferedImage(sw, sh, biType); + } + + Graphics big = bi.getGraphics(); + if (bi.getColorModel().getPixelSize() <=2) { + big.drawImage(opaqueImg, 0, 0, null); + } else { + big.drawImage(transImg, 0, 0, null); + } + g.drawImage(bi, 0, 0, null); + } + + public void paint(Graphics g) { + + int incX = sw+10, incY = sh+10; + + g.translate(10, 10); + + drawImage(g, TYPE_INT_RGB, null); + g.translate(incX, 0); + + drawImage(g, TYPE_INT_BGR, null); + g.translate(incX, 0); + + drawImage(g, TYPE_INT_ARGB, null); + g.translate(incX, 0); + + drawImage(g, TYPE_INT_ARGB_PRE, null); + g.translate(-3*incX, incY); + + drawImage(g, TYPE_3BYTE_BGR, null); + g.translate(incX, 0); + + drawImage(g, TYPE_4BYTE_ABGR, null); + g.translate(incX, 0); + + drawImage(g, TYPE_4BYTE_ABGR_PRE, null); + g.translate(incX, 0); + + drawImage(g, TYPE_USHORT_555_RGB, null); + g.translate(-3*incX, incY); + + drawImage(g, TYPE_USHORT_555_RGB, null); + g.translate(incX, 0); + + drawImage(g, TYPE_USHORT_GRAY, null); + g.translate(incX, 0); + + drawImage(g, TYPE_BYTE_GRAY, null); + g.translate(incX, 0); + + drawImage(g, TYPE_BYTE_INDEXED, null); + g.translate(-3*incX, incY); + + drawImage(g, TYPE_BYTE_BINARY, null); + g.translate(incX, 0); + + drawImage(g, TYPE_BYTE_BINARY, icm2); + g.translate(incX, 0); + + drawImage(g, TYPE_BYTE_BINARY, icm4); + g.translate(incX, 0); + + drawImage(g, TYPE_BYTE_INDEXED, icm2); + g.translate(-3*incX, incY); + + drawImage(g, TYPE_BYTE_INDEXED, icm4); + g.translate(incX, 0); + } + + + + /* Size is chosen to match default imageable width of a NA letter + * page. This means there will be clipping, what is clipped will + * depend on PageFormat orientation. + */ + public Dimension getPreferredSize() { + return new Dimension(468, 600); + } + +} From 287139e5a5e0641808d23768311f42cfbe49ff35 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Tue, 8 Feb 2011 16:12:16 -0800 Subject: [PATCH 014/105] 7014874: Incorrect COOPs modes on solaris-{sparcv9,amd64} with ParallelGC Align old gen size down to keep specified heap size. Reviewed-by: ysr --- .../parallelScavenge/parallelScavengeHeap.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp index 5eebf243751..98a9c957330 100644 --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/parallelScavengeHeap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -112,9 +112,12 @@ jint ParallelScavengeHeap::initialize() { yg_cur_size = MAX2(yg_cur_size, yg_min_size); og_min_size = align_size_up(og_min_size, og_align); - og_max_size = align_size_up(og_max_size, og_align); + // Align old gen size down to preserve specified heap size. + assert(og_align == yg_align, "sanity"); + og_max_size = align_size_down(og_max_size, og_align); + og_max_size = MAX2(og_max_size, og_min_size); size_t og_cur_size = - align_size_up(_collector_policy->old_gen_size(), og_align); + align_size_down(_collector_policy->old_gen_size(), og_align); og_cur_size = MAX2(og_cur_size, og_min_size); pg_min_size = align_size_up(pg_min_size, pg_align); From 5c4ea049dd371321d72370bdd99c287b80366f18 Mon Sep 17 00:00:00 2001 From: Yuka Kamiya Date: Wed, 9 Feb 2011 18:00:29 +0900 Subject: [PATCH 015/105] 7017800: (tz) Support tzdata2011b Reviewed-by: okutsu --- jdk/make/sun/javazic/tzdata/VERSION | 2 +- jdk/make/sun/javazic/tzdata/australasia | 13 ++-- jdk/make/sun/javazic/tzdata/northamerica | 77 +++++++++++++++---- jdk/make/sun/javazic/tzdata/zone.tab | 5 +- .../sun/util/resources/TimeZoneNames.java | 1 + .../sun/util/resources/TimeZoneNames_de.java | 1 + .../sun/util/resources/TimeZoneNames_es.java | 1 + .../sun/util/resources/TimeZoneNames_fr.java | 1 + .../sun/util/resources/TimeZoneNames_it.java | 1 + .../sun/util/resources/TimeZoneNames_ja.java | 1 + .../sun/util/resources/TimeZoneNames_ko.java | 1 + .../util/resources/TimeZoneNames_pt_BR.java | 1 + .../sun/util/resources/TimeZoneNames_sv.java | 1 + .../util/resources/TimeZoneNames_zh_CN.java | 1 + .../util/resources/TimeZoneNames_zh_TW.java | 1 + 15 files changed, 85 insertions(+), 23 deletions(-) diff --git a/jdk/make/sun/javazic/tzdata/VERSION b/jdk/make/sun/javazic/tzdata/VERSION index 5d158c9e6db..b82ee890a30 100644 --- a/jdk/make/sun/javazic/tzdata/VERSION +++ b/jdk/make/sun/javazic/tzdata/VERSION @@ -21,4 +21,4 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -tzdata2010o +tzdata2011b diff --git a/jdk/make/sun/javazic/tzdata/australasia b/jdk/make/sun/javazic/tzdata/australasia index 35ab9cfc9b8..430a6f146f5 100644 --- a/jdk/make/sun/javazic/tzdata/australasia +++ b/jdk/make/sun/javazic/tzdata/australasia @@ -106,14 +106,13 @@ Rule AS 1986 only - Oct 19 2:00s 1:00 - Rule AS 1987 2007 - Oct lastSun 2:00s 1:00 - Rule AS 1972 only - Feb 27 2:00s 0 - Rule AS 1973 1985 - Mar Sun>=1 2:00s 0 - -Rule AS 1986 1989 - Mar Sun>=15 2:00s 0 - -Rule AS 1990 only - Mar Sun>=18 2:00s 0 - -Rule AS 1991 only - Mar Sun>=1 2:00s 0 - -Rule AS 1992 only - Mar Sun>=18 2:00s 0 - -Rule AS 1993 only - Mar Sun>=1 2:00s 0 - -Rule AS 1994 only - Mar Sun>=18 2:00s 0 - +Rule AS 1986 1990 - Mar Sun>=15 2:00s 0 - +Rule AS 1991 only - Mar 3 2:00s 0 - +Rule AS 1992 only - Mar 22 2:00s 0 - +Rule AS 1993 only - Mar 7 2:00s 0 - +Rule AS 1994 only - Mar 20 2:00s 0 - Rule AS 1995 2005 - Mar lastSun 2:00s 0 - -Rule AS 2006 only - Apr Sun>=1 2:00s 0 - +Rule AS 2006 only - Apr 2 2:00s 0 - Rule AS 2007 only - Mar lastSun 2:00s 0 - Rule AS 2008 max - Apr Sun>=1 2:00s 0 - Rule AS 2008 max - Oct Sun>=1 2:00s 1:00 - diff --git a/jdk/make/sun/javazic/tzdata/northamerica b/jdk/make/sun/javazic/tzdata/northamerica index d07c69c9b45..281ab4f6748 100644 --- a/jdk/make/sun/javazic/tzdata/northamerica +++ b/jdk/make/sun/javazic/tzdata/northamerica @@ -368,6 +368,27 @@ Zone America/North_Dakota/New_Salem -6:45:39 - LMT 1883 Nov 18 12:14:21 -7:00 US M%sT 2003 Oct 26 02:00 -6:00 US C%sT +# From Josh Findley (2011-01-21): +# ...it appears that Mercer County, North Dakota, changed from the +# mountain time zone to the central time zone at the last transition from +# daylight-saving to standard time (on Nov. 7, 2010): +# +# http://www.gpo.gov/fdsys/pkg/FR-2010-09-29/html/2010-24376.htm +# +# +# http://www.bismarcktribune.com/news/local/article_1eb1b588-c758-11df-b472-001cc4c03286.html +# + +# From Andy Lipscomb (2011-01-24): +# ...according to the Census Bureau, the largest city is Beulah (although +# it's commonly referred to as Beulah-Hazen, with Hazen being the next +# largest city in Mercer County). Google Maps places Beulah's city hall +# at 4715'51" north, 10146'40" west, which yields an offset of 6h47'07". + +Zone America/North_Dakota/Beulah -6:47:07 - LMT 1883 Nov 18 12:12:53 + -7:00 US M%sT 2010 Nov 7 2:00 + -6:00 US C%sT + # US mountain time, represented by Denver # # Colorado, far western Kansas, Montana, western @@ -493,20 +514,50 @@ Zone America/Adak 12:13:21 - LMT 1867 Oct 18 # three votes for and one against." # Hawaii + +# From Arthur David Olson (2010-12-09): +# "Hawaiian Time" by Robert C. Schmitt and Doak C. Cox appears on pages 207-225 +# of volume 26 of The Hawaiian Journal of History (1992). As of 2010-12-09, +# the article is available at +# +# http://evols.library.manoa.hawaii.edu/bitstream/10524/239/2/JL26215.pdf +# +# and indicates that standard time was adopted effective noon, January +# 13, 1896 (page 218), that in "1933, the Legislature decreed daylight +# saving for the period between the last Sunday of each April and the +# last Sunday of each September, but less than a month later repealed the +# act," (page 220), that year-round daylight saving time was in effect +# from 1942-02-09 to 1945-09-30 (page 221, with no time of day given for +# when clocks changed) and that clocks were changed by 30 minutes +# effective the second Sunday of June, 1947 (page 219, with no time of +# day given for when clocks changed). A footnote for the 1933 changes +# cites Session Laws of Hawaii 1933, "Act. 90 (approved 26 Apr. 1933) +# and Act 163 (approved 21 May 1933)." + +# From Arthur David Olson (2011-01-19): +# The following is from "Laws of the Territory of Hawaii Passed by the +# Seventeenth Legislature: Regular Session 1933," available (as of +# 2011-01-19) at American University's Pence Law Library. Page 85: "Act +# 90...At 2 o'clock ante meridian of the last Sunday in April of each +# year, the standard time of this Territory shall be advanced one +# hour...This Act shall take effect upon its approval. Approved this 26th +# day of April, A. D. 1933. LAWRENCE M JUDD, Governor of the Territory of +# Hawaii." Page 172: "Act 163...Act 90 of the Session Laws of 1933 is +# hereby repealed...This Act shall take effect upon its approval, upon +# which date the standard time of this Territory shall be restored to +# that existing immediately prior to the taking effect of said Act 90. +# Approved this 21st day of May, A. D. 1933. LAWRENCE M. JUDD, Governor +# of the Territory of Hawaii." # -# From Arthur David Olson: -# And then there's Hawaii. -# DST was observed for one day in 1933; -# standard time was changed by half an hour in 1947; -# it's always standard as of 1986. -# -# From Paul Eggert: -# Shanks says the 1933 experiment lasted for three weeks. Go with Shanks. -# -Zone Pacific/Honolulu -10:31:26 - LMT 1900 Jan 1 12:00 - -10:30 - HST 1933 Apr 30 2:00 - -10:30 1:00 HDT 1933 May 21 2:00 - -10:30 US H%sT 1947 Jun 8 2:00 +# Note that 1933-05-21 was a Sunday. +# We're left to guess the time of day when Act 163 was approved; guess noon. + +Zone Pacific/Honolulu -10:31:26 - LMT 1896 Jan 13 12:00 #Schmitt&Cox + -10:30 - HST 1933 Apr 30 2:00 #Laws 1933 + -10:30 1:00 HDT 1933 May 21 12:00 #Laws 1933+12 + -10:30 - HST 1942 Feb 09 2:00 #Schmitt&Cox+2 + -10:30 1:00 HDT 1945 Sep 30 2:00 #Schmitt&Fox+2 + -10:30 US H%sT 1947 Jun 8 2:00 #Schmitt&Fox+2 -10:00 - HST # Now we turn to US areas that have diverged from the consensus since 1970. diff --git a/jdk/make/sun/javazic/tzdata/zone.tab b/jdk/make/sun/javazic/tzdata/zone.tab index c1b3e0707eb..cddfedae509 100644 --- a/jdk/make/sun/javazic/tzdata/zone.tab +++ b/jdk/make/sun/javazic/tzdata/zone.tab @@ -233,8 +233,8 @@ HT +1832-07220 America/Port-au-Prince HU +4730+01905 Europe/Budapest ID -0610+10648 Asia/Jakarta Java & Sumatra ID -0002+10920 Asia/Pontianak west & central Borneo -ID -0507+11924 Asia/Makassar east & south Borneo, Celebes, Bali, Nusa Tengarra, west Timor -ID -0232+14042 Asia/Jayapura Irian Jaya & the Moluccas +ID -0507+11924 Asia/Makassar east & south Borneo, Sulawesi (Celebes), Bali, Nusa Tengarra, west Timor +ID -0232+14042 Asia/Jayapura west New Guinea (Irian Jaya) & Malukus (Moluccas) IE +5320-00615 Europe/Dublin IL +3146+03514 Asia/Jerusalem IM +5409-00428 Europe/Isle_of_Man @@ -426,6 +426,7 @@ US +411745-0863730 America/Indiana/Knox Central Time - Indiana - Starke County US +450628-0873651 America/Menominee Central Time - Michigan - Dickinson, Gogebic, Iron & Menominee Counties US +470659-1011757 America/North_Dakota/Center Central Time - North Dakota - Oliver County US +465042-1012439 America/North_Dakota/New_Salem Central Time - North Dakota - Morton County (except Mandan area) +US +471551-1014640 America/North_Dakota/Beulah Central Time - North Dakota - Mercer County US +394421-1045903 America/Denver Mountain Time US +433649-1161209 America/Boise Mountain Time - south Idaho & east Oregon US +364708-1084111 America/Shiprock Mountain Time - Navajo diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java index 17d9fae84a9..a5c73549809 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames.java @@ -405,6 +405,7 @@ public final class TimeZoneNames extends TimeZoneNamesBundle { {"America/Nipigon", EST}, {"America/Nome", AKST}, {"America/Noronha", NORONHA}, + {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, {"America/Ojinaga", MST}, diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java index 45705ec799d..b3cb23224fa 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_de.java @@ -405,6 +405,7 @@ public final class TimeZoneNames_de extends TimeZoneNamesBundle { {"America/Nipigon", EST}, {"America/Nome", AKST}, {"America/Noronha", NORONHA}, + {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, {"America/Ojinaga", MST}, diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java index eecb3e31e55..613cc6419fb 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_es.java @@ -405,6 +405,7 @@ public final class TimeZoneNames_es extends TimeZoneNamesBundle { {"America/Nipigon", EST}, {"America/Nome", AKST}, {"America/Noronha", NORONHA}, + {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, {"America/Ojinaga", MST}, diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java index c39a001aaca..f1dc5300c25 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_fr.java @@ -405,6 +405,7 @@ public final class TimeZoneNames_fr extends TimeZoneNamesBundle { {"America/Nipigon", EST}, {"America/Nome", AKST}, {"America/Noronha", NORONHA}, + {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, {"America/Ojinaga", MST}, diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java index 1bbfc5d44a0..e983872e7a1 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_it.java @@ -405,6 +405,7 @@ public final class TimeZoneNames_it extends TimeZoneNamesBundle { {"America/Nipigon", EST}, {"America/Nome", AKST}, {"America/Noronha", NORONHA}, + {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, {"America/Ojinaga", MST}, diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java index f38a8e02537..56330acf91d 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ja.java @@ -405,6 +405,7 @@ public final class TimeZoneNames_ja extends TimeZoneNamesBundle { {"America/Nipigon", EST}, {"America/Nome", AKST}, {"America/Noronha", NORONHA}, + {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, {"America/Ojinaga", MST}, diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java index 5186d42ef99..82edcce1ec5 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_ko.java @@ -405,6 +405,7 @@ public final class TimeZoneNames_ko extends TimeZoneNamesBundle { {"America/Nipigon", EST}, {"America/Nome", AKST}, {"America/Noronha", NORONHA}, + {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, {"America/Ojinaga", MST}, diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java index 981281217f7..d9b83fe0491 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_pt_BR.java @@ -405,6 +405,7 @@ public final class TimeZoneNames_pt_BR extends TimeZoneNamesBundle { {"America/Nipigon", EST}, {"America/Nome", AKST}, {"America/Noronha", NORONHA}, + {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, {"America/Panama", EST}, diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java index 2813a181680..14108065241 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_sv.java @@ -405,6 +405,7 @@ public final class TimeZoneNames_sv extends TimeZoneNamesBundle { {"America/Nipigon", EST}, {"America/Nome", AKST}, {"America/Noronha", NORONHA}, + {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, {"America/Ojinaga", MST}, diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java index c79c6f2f69c..4f80a1b739c 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_CN.java @@ -405,6 +405,7 @@ public final class TimeZoneNames_zh_CN extends TimeZoneNamesBundle { {"America/Nipigon", EST}, {"America/Nome", AKST}, {"America/Noronha", NORONHA}, + {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, {"America/Ojinaga", MST}, diff --git a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java index 679ce531f83..5218bed7ed6 100644 --- a/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java +++ b/jdk/src/share/classes/sun/util/resources/TimeZoneNames_zh_TW.java @@ -405,6 +405,7 @@ public final class TimeZoneNames_zh_TW extends TimeZoneNamesBundle { {"America/Nipigon", EST}, {"America/Nome", AKST}, {"America/Noronha", NORONHA}, + {"America/North_Dakota/Beulah", CST}, {"America/North_Dakota/Center", CST}, {"America/North_Dakota/New_Salem", CST}, {"America/Ojinaga", MST}, From 7334402db57e370cfbcc0fb282921a03b641a8b2 Mon Sep 17 00:00:00 2001 From: John Cuthbertson Date: Wed, 9 Feb 2011 09:43:02 -0800 Subject: [PATCH 016/105] 7017008: G1: Turn on compressed oops by default Normally compressed oops is enabled when the maximum heap size is under a certain limit, except when G1 is also enabled. Remove this limitation. Also re-enable GCBasher testing with G1 on 64 bit windows in jprt. Reviewed-by: jcoomes, brutisso, tonyp --- hotspot/make/jprt.properties | 3 ++- hotspot/src/share/vm/runtime/arguments.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hotspot/make/jprt.properties b/hotspot/make/jprt.properties index c8bbb3c6c14..85e6d7ba9d5 100644 --- a/hotspot/make/jprt.properties +++ b/hotspot/make/jprt.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# 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 @@ -357,6 +357,7 @@ jprt.my.windows.x64.test.targets = \ ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCBasher_ParallelGC, \ ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCBasher_ParNewGC, \ ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCBasher_CMS, \ + ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCBasher_G1, \ ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCBasher_ParOldGC, \ ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCOld_default, \ ${jprt.my.windows.x64}-{product|fastdebug}-c2-GCOld_SerialGC, \ diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 814e0df928b..ed7533e9365 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -1410,7 +1410,7 @@ void Arguments::set_ergonomics_flags() { // by ergonomics. if (MaxHeapSize <= max_heap_for_compressed_oops()) { #if !defined(COMPILER1) || defined(TIERED) - if (FLAG_IS_DEFAULT(UseCompressedOops) && !UseG1GC) { + if (FLAG_IS_DEFAULT(UseCompressedOops)) { FLAG_SET_ERGO(bool, UseCompressedOops, true); } #endif From 763f89002915b7c057ee3f0c486b713782304de0 Mon Sep 17 00:00:00 2001 From: Andrew Brygin Date: Wed, 9 Feb 2011 22:24:42 +0300 Subject: [PATCH 017/105] 6818960: ImageFetcher ( MediaTracker) Thread leak Reviewed-by: igor, prr --- .../classes/sun/awt/image/ImageFetcher.java | 32 +++++++++++++++---- .../sun/awt/image/InputStreamImageSource.java | 9 ++++-- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/jdk/src/share/classes/sun/awt/image/ImageFetcher.java b/jdk/src/share/classes/sun/awt/image/ImageFetcher.java index 083ba79841b..5b1293fb043 100644 --- a/jdk/src/share/classes/sun/awt/image/ImageFetcher.java +++ b/jdk/src/share/classes/sun/awt/image/ImageFetcher.java @@ -61,8 +61,10 @@ class ImageFetcher extends Thread { /** * Adds an ImageFetchable to the queue of items to fetch. Instantiates * a new ImageFetcher if it's reasonable to do so. + * If there is no available fetcher to process an ImageFetchable, then + * reports failure to caller. */ - public static void add(ImageFetchable src) { + public static boolean add(ImageFetchable src) { final FetcherInfo info = FetcherInfo.getFetcherInfo(); synchronized(info.waitList) { if (!info.waitList.contains(src)) { @@ -71,9 +73,23 @@ class ImageFetcher extends Thread { info.numFetchers < info.fetchers.length) { createFetchers(info); } - info.waitList.notify(); + /* Creation of new fetcher may fail due to high vm load + * or some other reason. + * If there is already exist, but busy, fetcher, we leave + * the src in queue (it will be handled by existing + * fetcher later). + * Otherwise, we report failure: there is no fetcher + * to handle the src. + */ + if (info.numFetchers > 0) { + info.waitList.notify(); + } else { + info.waitList.removeElement(src); + return false; + } } } + return true; } /** @@ -291,11 +307,15 @@ class ImageFetcher extends Thread { public Object run() { for (int i = 0; i < info.fetchers.length; i++) { if (info.fetchers[i] == null) { - info.fetchers[i] = new ImageFetcher( + ImageFetcher f = new ImageFetcher( fetcherGroup, i); - info.fetchers[i].start(); - info.numFetchers++; - break; + try { + f.start(); + info.fetchers[i] = f; + info.numFetchers++; + break; + } catch (Error e) { + } } } return null; diff --git a/jdk/src/share/classes/sun/awt/image/InputStreamImageSource.java b/jdk/src/share/classes/sun/awt/image/InputStreamImageSource.java index e2aecb3073c..7d0b7eaf43b 100644 --- a/jdk/src/share/classes/sun/awt/image/InputStreamImageSource.java +++ b/jdk/src/share/classes/sun/awt/image/InputStreamImageSource.java @@ -164,8 +164,13 @@ public abstract class InputStreamImageSource implements ImageProducer, private synchronized void startProduction() { if (!awaitingFetch) { - ImageFetcher.add(this); - awaitingFetch = true; + if (ImageFetcher.add(this)) { + awaitingFetch = true; + } else { + ImageConsumerQueue cq = consumers; + consumers = null; + errorAllConsumers(cq, false); + } } } From a71eecc4f724db2d673acffb1f567d03588e7d56 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 9 Feb 2011 14:04:53 -0800 Subject: [PATCH 018/105] 7016750: tools/javac/nio/CompileTest failing in nightly test Reviewed-by: mcimadamore --- langtools/test/tools/javac/nio/compileTest/CompileTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/langtools/test/tools/javac/nio/compileTest/CompileTest.java b/langtools/test/tools/javac/nio/compileTest/CompileTest.java index e339b23186b..e04c97c2664 100644 --- a/langtools/test/tools/javac/nio/compileTest/CompileTest.java +++ b/langtools/test/tools/javac/nio/compileTest/CompileTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -25,7 +25,7 @@ * @test * @bug 6906175 6915476 6915497 7006564 * @summary Path-based JavaFileManager - * @compile -g HelloPathWorld.java + * @compile -g CompileTest.java HelloPathWorld.java * @run main CompileTest */ From c9335a55e11b33090993f5e4a421f2e553e8f974 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 9 Feb 2011 14:10:52 -0800 Subject: [PATCH 019/105] 7010792: remove bad debugging method from javac Reviewed-by: mcimadamore --- .../share/classes/com/sun/tools/javac/parser/Scanner.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java b/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java index 2cda5c47fe7..2f089759795 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Scanner.java @@ -282,12 +282,6 @@ public class Scanner implements Lexer { sbuf[sp++] = ch; } - /** For debugging purposes: print character. - */ - private void dch() { - System.err.print(ch); System.out.flush(); - } - /** Read next character in character or string literal and copy into sbuf. */ private void scanLitChar() { From 3f1466e7d2a02c03696221bfad9f37428e5f6dce Mon Sep 17 00:00:00 2001 From: Clemens Eisserer Date: Wed, 9 Feb 2011 14:34:04 -0800 Subject: [PATCH 020/105] 7018387: Xrender pipeline may leak GC's Reviewed-by: prr --- jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java b/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java index 0491e719c59..f09d0f3de4f 100644 --- a/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java +++ b/jdk/src/solaris/classes/sun/java2d/xr/XRSurfaceData.java @@ -479,8 +479,7 @@ public abstract class XRSurfaceData extends XSurfaceData { if (xrpipe == null) { try { SunToolkit.awtLock(); - xgc = renderQueue.createGC(xid); // TODO: GC leak? where to - // clean up? + xgc = XCreateGC(getNativeOps()); xrpipe = new XRRenderer(maskBuffer.getMaskBuffer()); xrtxpipe = new PixelToShapeConverter(xrpipe); From 6782422f01c1685668d5a12374309b18984ce329 Mon Sep 17 00:00:00 2001 From: Igor Veresov Date: Wed, 9 Feb 2011 16:34:34 -0800 Subject: [PATCH 021/105] 7017434: Tiered needs to support reprofiling Tiered needs to support proper method reprofiling after deopts. Reviewed-by: kvn --- hotspot/src/share/vm/c1/c1_Compilation.cpp | 9 +- hotspot/src/share/vm/oops/methodDataOop.cpp | 4 +- hotspot/src/share/vm/oops/methodDataOop.hpp | 25 ++++++ .../vm/runtime/simpleThresholdPolicy.cpp | 86 +++++++++++-------- .../vm/runtime/simpleThresholdPolicy.hpp | 6 +- 5 files changed, 86 insertions(+), 44 deletions(-) diff --git a/hotspot/src/share/vm/c1/c1_Compilation.cpp b/hotspot/src/share/vm/c1/c1_Compilation.cpp index 88dc8c7d0d5..4521b0f623b 100644 --- a/hotspot/src/share/vm/c1/c1_Compilation.cpp +++ b/hotspot/src/share/vm/c1/c1_Compilation.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -491,10 +491,11 @@ Compilation::Compilation(AbstractCompiler* compiler, ciEnv* env, ciMethod* metho // to start profiling on its own. _method->ensure_method_data(); } - } else if (is_profiling() && _would_profile) { + } else if (is_profiling()) { ciMethodData *md = method->method_data_or_null(); - assert(md != NULL, "Sanity"); - md->set_would_profile(_would_profile); + if (md != NULL) { + md->set_would_profile(_would_profile); + } } } diff --git a/hotspot/src/share/vm/oops/methodDataOop.cpp b/hotspot/src/share/vm/oops/methodDataOop.cpp index b0856dbca46..49a998c02c4 100644 --- a/hotspot/src/share/vm/oops/methodDataOop.cpp +++ b/hotspot/src/share/vm/oops/methodDataOop.cpp @@ -764,11 +764,13 @@ void methodDataOopDesc::initialize(methodHandle method) { if (TieredCompilation) { _invocation_counter.init(); _backedge_counter.init(); + _invocation_counter_start = 0; + _backedge_counter_start = 0; _num_loops = 0; _num_blocks = 0; _highest_comp_level = 0; _highest_osr_comp_level = 0; - _would_profile = false; + _would_profile = true; } set_creation_mileage(mileage_of(method())); diff --git a/hotspot/src/share/vm/oops/methodDataOop.hpp b/hotspot/src/share/vm/oops/methodDataOop.hpp index a3f64948956..a4ff6181ce7 100644 --- a/hotspot/src/share/vm/oops/methodDataOop.hpp +++ b/hotspot/src/share/vm/oops/methodDataOop.hpp @@ -1224,6 +1224,9 @@ private: InvocationCounter _invocation_counter; // Same for backedges. InvocationCounter _backedge_counter; + // Counter values at the time profiling started. + int _invocation_counter_start; + int _backedge_counter_start; // Number of loops and blocks is computed when compiling the first // time with C1. It is used to determine if method is trivial. short _num_loops; @@ -1333,6 +1336,28 @@ public: return backedge_counter()->count(); } + int invocation_count_start() { + if (invocation_counter()->carry()) { + return 0; + } + return _invocation_counter_start; + } + + int backedge_count_start() { + if (backedge_counter()->carry()) { + return 0; + } + return _backedge_counter_start; + } + + int invocation_count_delta() { return invocation_count() - invocation_count_start(); } + int backedge_count_delta() { return backedge_count() - backedge_count_start(); } + + void reset_start_counters() { + _invocation_counter_start = invocation_count(); + _backedge_counter_start = backedge_count(); + } + InvocationCounter* invocation_counter() { return &_invocation_counter; } InvocationCounter* backedge_counter() { return &_backedge_counter; } diff --git a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp index 409c7534026..4d23753521f 100644 --- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp +++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -28,6 +28,7 @@ #include "runtime/arguments.hpp" #include "runtime/simpleThresholdPolicy.hpp" #include "runtime/simpleThresholdPolicy.inline.hpp" +#include "code/scopeDesc.hpp" // Print an event. void SimpleThresholdPolicy::print_event(EventType type, methodHandle mh, methodHandle imh, @@ -48,6 +49,18 @@ void SimpleThresholdPolicy::print_event(EventType type, methodHandle mh, methodH break; case COMPILE: tty->print("compile"); + break; + case KILL: + tty->print("kill"); + break; + case UPDATE: + tty->print("update"); + break; + case REPROFILE: + tty->print("reprofile"); + break; + default: + tty->print("unknown"); } tty->print(" level: %d ", level); @@ -69,13 +82,17 @@ void SimpleThresholdPolicy::print_event(EventType type, methodHandle mh, methodH if (type != COMPILE) { methodDataHandle mdh = mh->method_data(); int mdo_invocations = 0, mdo_backedges = 0; + int mdo_invocations_start = 0, mdo_backedges_start = 0; if (mdh() != NULL) { mdo_invocations = mdh->invocation_count(); mdo_backedges = mdh->backedge_count(); + mdo_invocations_start = mdh->invocation_count_start(); + mdo_backedges_start = mdh->backedge_count_start(); } - tty->print(" total: %d,%d mdo: %d,%d", + tty->print(" total: %d,%d mdo: %d(%d),%d(%d)", invocation_count, backedge_count, - mdo_invocations, mdo_backedges); + mdo_invocations, mdo_invocations_start, + mdo_backedges, mdo_backedges_start); tty->print(" max levels: %d,%d", mh->highest_comp_level(), mh->highest_osr_comp_level()); if (inlinee_event) { @@ -138,6 +155,20 @@ CompileTask* SimpleThresholdPolicy::select_task(CompileQueue* compile_queue) { return compile_queue->first(); } +void SimpleThresholdPolicy::reprofile(ScopeDesc* trap_scope, bool is_osr) { + for (ScopeDesc* sd = trap_scope;; sd = sd->sender()) { + if (PrintTieredEvents) { + methodHandle mh(sd->method()); + print_event(REPROFILE, mh, mh, InvocationEntryBci, CompLevel_none); + } + methodDataOop mdo = sd->method()->method_data(); + if (mdo != NULL) { + mdo->reset_start_counters(); + } + if (sd->is_top()) break; + } +} + nmethod* SimpleThresholdPolicy::event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, TRAPS) { if (comp_level == CompLevel_none && @@ -254,46 +285,35 @@ bool SimpleThresholdPolicy::is_mature(methodOop method) { // Common transition function. Given a predicate determines if a method should transition to another level. CompLevel SimpleThresholdPolicy::common(Predicate p, methodOop method, CompLevel cur_level) { + if (is_trivial(method)) return CompLevel_simple; + CompLevel next_level = cur_level; int i = method->invocation_count(); int b = method->backedge_count(); switch(cur_level) { case CompLevel_none: - { - methodDataOop mdo = method->method_data(); - if (mdo != NULL) { - int mdo_i = mdo->invocation_count(); - int mdo_b = mdo->backedge_count(); - // If we were at full profile level, would we switch to full opt? - if ((this->*p)(mdo_i, mdo_b, CompLevel_full_profile)) { - next_level = CompLevel_full_optimization; - } - } - } - if (next_level == cur_level && (this->*p)(i, b, cur_level)) { - if (is_trivial(method)) { - next_level = CompLevel_simple; - } else { - next_level = CompLevel_full_profile; - } + // If we were at full profile level, would we switch to full opt? + if (common(p, method, CompLevel_full_profile) == CompLevel_full_optimization) { + next_level = CompLevel_full_optimization; + } else if ((this->*p)(i, b, cur_level)) { + next_level = CompLevel_full_profile; } break; case CompLevel_limited_profile: case CompLevel_full_profile: - if (is_trivial(method)) { - next_level = CompLevel_simple; - } else { + { methodDataOop mdo = method->method_data(); - guarantee(mdo != NULL, "MDO should always exist"); - if (mdo->would_profile()) { - int mdo_i = mdo->invocation_count(); - int mdo_b = mdo->backedge_count(); - if ((this->*p)(mdo_i, mdo_b, cur_level)) { + if (mdo != NULL) { + if (mdo->would_profile()) { + int mdo_i = mdo->invocation_count_delta(); + int mdo_b = mdo->backedge_count_delta(); + if ((this->*p)(mdo_i, mdo_b, cur_level)) { + next_level = CompLevel_full_optimization; + } + } else { next_level = CompLevel_full_optimization; } - } else { - next_level = CompLevel_full_optimization; } } break; @@ -303,12 +323,6 @@ CompLevel SimpleThresholdPolicy::common(Predicate p, methodOop method, CompLevel // Determine if a method should be compiled with a normal entry point at a different level. CompLevel SimpleThresholdPolicy::call_event(methodOop method, CompLevel cur_level) { - CompLevel highest_level = (CompLevel)method->highest_comp_level(); - if (cur_level == CompLevel_none && highest_level > cur_level) { - // TODO: We may want to try to do more extensive reprofiling in this case. - return highest_level; - } - CompLevel osr_level = (CompLevel) method->highest_osr_comp_level(); CompLevel next_level = common(&SimpleThresholdPolicy::call_predicate, method, cur_level); diff --git a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp index 9bc180df528..527c3f60b59 100644 --- a/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp +++ b/hotspot/src/share/vm/runtime/simpleThresholdPolicy.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -62,7 +62,7 @@ protected: void set_c1_count(int x) { _c1_count = x; } void set_c2_count(int x) { _c2_count = x; } - enum EventType { CALL, LOOP, COMPILE }; + enum EventType { CALL, LOOP, COMPILE, KILL, UPDATE, REPROFILE }; void print_event(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level); // Print policy-specific information if necessary virtual void print_specific(EventType type, methodHandle mh, methodHandle imh, int bci, CompLevel level) { } @@ -103,7 +103,7 @@ public: virtual void disable_compilation(methodOop method) { } // TODO: we should honour reprofiling requests in the future. Currently reprofiling // would happen but not to the extent we would ideally like. - virtual void reprofile(ScopeDesc* trap_scope, bool is_osr) { } + virtual void reprofile(ScopeDesc* trap_scope, bool is_osr); virtual nmethod* event(methodHandle method, methodHandle inlinee, int branch_bci, int bci, CompLevel comp_level, TRAPS); // Select task is called by CompileBroker. We should return a task or NULL. From 4c567f5969c351649f4c1d9651f79a57f5edf82a Mon Sep 17 00:00:00 2001 From: Christian Thalinger Date: Thu, 10 Feb 2011 00:47:59 -0800 Subject: [PATCH 022/105] 7018277: JSR 292 change test/compiler/6987555/Test6987555.java to new MH syntax Test/compiler/6987555/Test6987555.java currently does not compile because the MH return-type syntax has changed. Reviewed-by: never --- .../test/compiler/6987555/Test6987555.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/hotspot/test/compiler/6987555/Test6987555.java b/hotspot/test/compiler/6987555/Test6987555.java index 5e408039f5e..a438fee8dd1 100644 --- a/hotspot/test/compiler/6987555/Test6987555.java +++ b/hotspot/test/compiler/6987555/Test6987555.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -54,8 +54,8 @@ public class Test6987555 { if (DEBUG) System.out.println("boolean=" + x); MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(boolean.class, boolean.class)); MethodHandle mh2 = mh1.asType(MethodType.methodType(boolean.class, Boolean.class)); - boolean a = mh1.invokeExact(x); - boolean b = mh2.invokeExact(Boolean.valueOf(x)); + boolean a = (boolean) mh1.invokeExact(x); + boolean b = (boolean) mh2.invokeExact(Boolean.valueOf(x)); assert a == b : a + " != " + b; } @@ -80,8 +80,8 @@ public class Test6987555 { if (DEBUG) System.out.println("byte=" + x); MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(byte.class, byte.class)); MethodHandle mh2 = mh1.asType(MethodType.methodType(byte.class, Byte.class)); - byte a = mh1.invokeExact(x); - byte b = mh2.invokeExact(Byte.valueOf(x)); + byte a = (byte) mh1.invokeExact(x); + byte b = (byte) mh2.invokeExact(Byte.valueOf(x)); assert a == b : a + " != " + b; } @@ -104,8 +104,8 @@ public class Test6987555 { if (DEBUG) System.out.println("char=" + x); MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(char.class, char.class)); MethodHandle mh2 = mh1.asType(MethodType.methodType(char.class, Character.class)); - char a = mh1.invokeExact(x); - char b = mh2.invokeExact(Character.valueOf(x)); + char a = (char) mh1.invokeExact(x); + char b = (char) mh2.invokeExact(Character.valueOf(x)); assert a == b : a + " != " + b; } @@ -134,8 +134,8 @@ public class Test6987555 { if (DEBUG) System.out.println("short=" + x); MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(short.class, short.class)); MethodHandle mh2 = mh1.asType(MethodType.methodType(short.class, Short.class)); - short a = mh1.invokeExact(x); - short b = mh2.invokeExact(Short.valueOf(x)); + short a = (short) mh1.invokeExact(x); + short b = (short) mh2.invokeExact(Short.valueOf(x)); assert a == b : a + " != " + b; } @@ -164,8 +164,8 @@ public class Test6987555 { if (DEBUG) System.out.println("int=" + x); MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(int.class, int.class)); MethodHandle mh2 = mh1.asType(MethodType.methodType(int.class, Integer.class)); - int a = mh1.invokeExact(x); - int b = mh2.invokeExact(Integer.valueOf(x)); + int a = (int) mh1.invokeExact(x); + int b = (int) mh2.invokeExact(Integer.valueOf(x)); assert a == b : a + " != " + b; } From 5d3ab72d1d05e0e725c9d25c25ec1c0298004233 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Thu, 10 Feb 2011 14:25:59 -0800 Subject: [PATCH 023/105] 7017746: Regression : C2 compiler crash due to SIGSEGV in PhaseCFG::schedule_early() Add TEMP edges (and KILL projections) before duplicated operands are removed in Expand() methods. Reviewed-by: never --- hotspot/src/cpu/sparc/vm/sparc.ad | 25 ++--- hotspot/src/share/vm/adlc/output_c.cpp | 140 ++++++++++++------------ hotspot/src/share/vm/opto/node.cpp | 3 + hotspot/test/compiler/7017746/Test.java | 50 +++++++++ 4 files changed, 135 insertions(+), 83 deletions(-) create mode 100644 hotspot/test/compiler/7017746/Test.java diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad index 422b83f1476..cffc8fb5f7f 100644 --- a/hotspot/src/cpu/sparc/vm/sparc.ad +++ b/hotspot/src/cpu/sparc/vm/sparc.ad @@ -8125,6 +8125,17 @@ instruct convP2B( iRegI dst, iRegP src ) %{ %} #endif +instruct cmpLTMask0( iRegI dst, iRegI src, immI0 zero, flagsReg ccr ) %{ + match(Set dst (CmpLTMask src zero)); + effect(KILL ccr); + size(4); + format %{ "SRA $src,#31,$dst\t# cmpLTMask0" %} + ins_encode %{ + __ sra($src$$Register, 31, $dst$$Register); + %} + ins_pipe(ialu_reg_imm); +%} + instruct cmpLTMask_reg_reg( iRegI dst, iRegI p, iRegI q, flagsReg ccr ) %{ match(Set dst (CmpLTMask p q)); effect( KILL ccr ); @@ -8144,19 +8155,7 @@ instruct cadd_cmpLTMask( iRegI p, iRegI q, iRegI y, iRegI tmp, flagsReg ccr ) %{ format %{ "SUBcc $p,$q,$p\t! p' = p-q\n\t" "ADD $p,$y,$tmp\t! g3=p-q+y\n\t" - "MOVl $tmp,$p\t! p' < 0 ? p'+y : p'" %} - ins_encode( enc_cadd_cmpLTMask(p, q, y, tmp) ); - ins_pipe( cadd_cmpltmask ); -%} - -instruct cadd_cmpLTMask2( iRegI p, iRegI q, iRegI y, iRegI tmp, flagsReg ccr ) %{ - match(Set p (AddI (SubI p q) (AndI (CmpLTMask p q) y))); - effect( KILL ccr, TEMP tmp); - ins_cost(DEFAULT_COST*3); - - format %{ "SUBcc $p,$q,$p\t! p' = p-q\n\t" - "ADD $p,$y,$tmp\t! g3=p-q+y\n\t" - "MOVl $tmp,$p\t! p' < 0 ? p'+y : p'" %} + "MOVlt $tmp,$p\t! p' < 0 ? p'+y : p'" %} ins_encode( enc_cadd_cmpLTMask(p, q, y, tmp) ); ins_pipe( cadd_cmpltmask ); %} diff --git a/hotspot/src/share/vm/adlc/output_c.cpp b/hotspot/src/share/vm/adlc/output_c.cpp index 776c486f179..ddf1f99343b 100644 --- a/hotspot/src/share/vm/adlc/output_c.cpp +++ b/hotspot/src/share/vm/adlc/output_c.cpp @@ -1698,7 +1698,75 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { fprintf(fp,"\n"); } // done generating expand rule - else if( node->_matrule != NULL ) { + // Generate projections for instruction's additional DEFs and KILLs + if( ! node->expands() && (node->needs_projections() || node->has_temps())) { + // Get string representing the MachNode that projections point at + const char *machNode = "this"; + // Generate the projections + fprintf(fp," // Add projection edges for additional defs or kills\n"); + + // Examine each component to see if it is a DEF or KILL + node->_components.reset(); + // Skip the first component, if already handled as (SET dst (...)) + Component *comp = NULL; + // For kills, the choice of projection numbers is arbitrary + int proj_no = 1; + bool declared_def = false; + bool declared_kill = false; + + while( (comp = node->_components.iter()) != NULL ) { + // Lookup register class associated with operand type + Form *form = (Form*)_globalNames[comp->_type]; + assert( form, "component type must be a defined form"); + OperandForm *op = form->is_operand(); + + if (comp->is(Component::TEMP)) { + fprintf(fp, " // TEMP %s\n", comp->_name); + if (!declared_def) { + // Define the variable "def" to hold new MachProjNodes + fprintf(fp, " MachTempNode *def;\n"); + declared_def = true; + } + if (op && op->_interface && op->_interface->is_RegInterface()) { + fprintf(fp," def = new (C) MachTempNode(state->MachOperGenerator( %s, C ));\n", + machOperEnum(op->_ident)); + fprintf(fp," add_req(def);\n"); + // The operand for TEMP is already constructed during + // this mach node construction, see buildMachNode(). + // + // int idx = node->operand_position_format(comp->_name); + // fprintf(fp," set_opnd_array(%d, state->MachOperGenerator( %s, C ));\n", + // idx, machOperEnum(op->_ident)); + } else { + assert(false, "can't have temps which aren't registers"); + } + } else if (comp->isa(Component::KILL)) { + fprintf(fp, " // DEF/KILL %s\n", comp->_name); + + if (!declared_kill) { + // Define the variable "kill" to hold new MachProjNodes + fprintf(fp, " MachProjNode *kill;\n"); + declared_kill = true; + } + + assert( op, "Support additional KILLS for base operands"); + const char *regmask = reg_mask(*op); + const char *ideal_type = op->ideal_type(_globalNames, _register); + + if (!op->is_bound_register()) { + syntax_err(node->_linenum, "In %s only bound registers can be killed: %s %s\n", + node->_ident, comp->_type, comp->_name); + } + + fprintf(fp," kill = "); + fprintf(fp,"new (C, 1) MachProjNode( %s, %d, (%s), Op_%s );\n", + machNode, proj_no++, regmask, ideal_type); + fprintf(fp," proj_list.push(kill);\n"); + } + } + } + + if( !node->expands() && node->_matrule != NULL ) { // Remove duplicated operands and inputs which use the same name. // Seach through match operands for the same name usage. uint cur_num_opnds = node->num_opnds(); @@ -1752,72 +1820,6 @@ void ArchDesc::defineExpand(FILE *fp, InstructForm *node) { } } - - // Generate projections for instruction's additional DEFs and KILLs - if( ! node->expands() && (node->needs_projections() || node->has_temps())) { - // Get string representing the MachNode that projections point at - const char *machNode = "this"; - // Generate the projections - fprintf(fp," // Add projection edges for additional defs or kills\n"); - - // Examine each component to see if it is a DEF or KILL - node->_components.reset(); - // Skip the first component, if already handled as (SET dst (...)) - Component *comp = NULL; - // For kills, the choice of projection numbers is arbitrary - int proj_no = 1; - bool declared_def = false; - bool declared_kill = false; - - while( (comp = node->_components.iter()) != NULL ) { - // Lookup register class associated with operand type - Form *form = (Form*)_globalNames[comp->_type]; - assert( form, "component type must be a defined form"); - OperandForm *op = form->is_operand(); - - if (comp->is(Component::TEMP)) { - fprintf(fp, " // TEMP %s\n", comp->_name); - if (!declared_def) { - // Define the variable "def" to hold new MachProjNodes - fprintf(fp, " MachTempNode *def;\n"); - declared_def = true; - } - if (op && op->_interface && op->_interface->is_RegInterface()) { - fprintf(fp," def = new (C) MachTempNode(state->MachOperGenerator( %s, C ));\n", - machOperEnum(op->_ident)); - fprintf(fp," add_req(def);\n"); - int idx = node->operand_position_format(comp->_name); - fprintf(fp," set_opnd_array(%d, state->MachOperGenerator( %s, C ));\n", - idx, machOperEnum(op->_ident)); - } else { - assert(false, "can't have temps which aren't registers"); - } - } else if (comp->isa(Component::KILL)) { - fprintf(fp, " // DEF/KILL %s\n", comp->_name); - - if (!declared_kill) { - // Define the variable "kill" to hold new MachProjNodes - fprintf(fp, " MachProjNode *kill;\n"); - declared_kill = true; - } - - assert( op, "Support additional KILLS for base operands"); - const char *regmask = reg_mask(*op); - const char *ideal_type = op->ideal_type(_globalNames, _register); - - if (!op->is_bound_register()) { - syntax_err(node->_linenum, "In %s only bound registers can be killed: %s %s\n", - node->_ident, comp->_type, comp->_name); - } - - fprintf(fp," kill = "); - fprintf(fp,"new (C, 1) MachProjNode( %s, %d, (%s), Op_%s );\n", - machNode, proj_no++, regmask, ideal_type); - fprintf(fp," proj_list.push(kill);\n"); - } - } - } - // If the node is a MachConstantNode, insert the MachConstantBaseNode edge. // NOTE: this edge must be the last input (see MachConstantNode::mach_constant_base_node_input). if (node->is_mach_constant()) { @@ -3776,12 +3778,10 @@ void ArchDesc::buildMachNode(FILE *fp_cpp, InstructForm *inst, const char *inden } dont_care = true; // For each operand not in the match rule, call MachOperGenerator - // with the enum for the opcode that needs to be built - // and the node just built, the parent of the operand. + // with the enum for the opcode that needs to be built. ComponentList clist = inst->_components; int index = clist.operand_position(comp->_name, comp->_usedef); const char *opcode = machOperEnum(comp->_type); - const char *parent = "node"; fprintf(fp_cpp, "%s node->set_opnd_array(%d, ", indent, index); fprintf(fp_cpp, "MachOperGenerator(%s, C));\n", opcode); } diff --git a/hotspot/src/share/vm/opto/node.cpp b/hotspot/src/share/vm/opto/node.cpp index 70f809b2973..8174605f4e5 100644 --- a/hotspot/src/share/vm/opto/node.cpp +++ b/hotspot/src/share/vm/opto/node.cpp @@ -743,6 +743,9 @@ void Node::add_req_batch( Node *n, uint m ) { //------------------------------del_req---------------------------------------- // Delete the required edge and compact the edge array void Node::del_req( uint idx ) { + assert( idx < _cnt, "oob"); + assert( !VerifyHashTableKeys || _hash_lock == 0, + "remove node from hash table before modifying it"); // First remove corresponding def-use edge Node *n = in(idx); if (n != NULL) n->del_out((Node *)this); diff --git a/hotspot/test/compiler/7017746/Test.java b/hotspot/test/compiler/7017746/Test.java new file mode 100644 index 00000000000..eab4b7e0f40 --- /dev/null +++ b/hotspot/test/compiler/7017746/Test.java @@ -0,0 +1,50 @@ +/* + * 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. + */ + +/** + * @test + * @bug 7017746 + * @summary Regression : C2 compiler crash due to SIGSEGV in PhaseCFG::schedule_early() + * + * @run main/othervm -Xbatch Test + */ + +public class Test { + + int i; + + static int test(Test t, int a, int b) { + int j = t.i; + int x = a - b; + if (a < b) x = x + j; + return x - j; + } + + public static void main(String args[]) { + Test t = new Test(); + for (int n = 0; n < 1000000; n++) { + int i = test(t, 1, 2); + } + } +} + From c13062093b7a10093101a77f821c70379d78771f Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Thu, 10 Feb 2011 19:34:48 -0800 Subject: [PATCH 024/105] 7018849: 7017124 fix broke VM build on some platforms Use atomic load and store in inc_stat_counter() only on SPARC and X86. Reviewed-by: iveresov --- hotspot/src/share/vm/memory/allocation.inline.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hotspot/src/share/vm/memory/allocation.inline.hpp b/hotspot/src/share/vm/memory/allocation.inline.hpp index 79d7ef5d666..795016df838 100644 --- a/hotspot/src/share/vm/memory/allocation.inline.hpp +++ b/hotspot/src/share/vm/memory/allocation.inline.hpp @@ -32,12 +32,20 @@ void trace_heap_malloc(size_t size, const char* name, void *p); void trace_heap_free(void *p); +#ifndef PRODUCT // Increments unsigned long value for statistics (not atomic on MP). inline void inc_stat_counter(volatile julong* dest, julong add_value) { +#if defined(SPARC) || defined(X86) + // Sparc and X86 have atomic jlong (8 bytes) instructions julong value = Atomic::load((volatile jlong*)dest); value += add_value; Atomic::store((jlong)value, (volatile jlong*)dest); +#else + // possible word-tearing during load/store + *dest += add_value; +#endif } +#endif // allocate using malloc; will fail if no memory available inline char* AllocateHeap(size_t size, const char* name = NULL) { From 01cc76e02d04b0c9febe66b57b45e6c3cdced172 Mon Sep 17 00:00:00 2001 From: Christian Thalinger Date: Fri, 11 Feb 2011 03:17:53 -0800 Subject: [PATCH 025/105] 7018673: Zero: 6953144, 6990754 and 7009756 made some changes which broke Zero Reviewed-by: kvn, chrisphi, twisti --- .../linux_zero/vm/atomic_linux_zero.inline.hpp | 18 ++++++++++++++++-- .../src/share/vm/compiler/compileBroker.cpp | 4 +++- .../vm/interpreter/bytecodeInterpreter.cpp | 6 +++--- hotspot/src/share/vm/oops/methodOop.cpp | 2 +- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp b/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp index fcada2aa417..9bee2332f87 100644 --- a/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp +++ b/hotspot/src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. - * Copyright 2007, 2008 Red Hat, Inc. + * Copyright (c) 2003, 2011, 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. * * This code is free software; you can redistribute it and/or modify it @@ -300,4 +300,18 @@ inline void* Atomic::cmpxchg_ptr(void* exchange_value, (intptr_t) compare_value); } +inline jlong Atomic::load(volatile jlong* src) { + volatile jlong dest; + os::atomic_copy64(src, &dest); + return dest; +} + +inline void Atomic::store(jlong store_value, jlong* dest) { + os::atomic_copy64((volatile jlong*)&store_value, (volatile jlong*)dest); +} + +inline void Atomic::store(jlong store_value, volatile jlong* dest) { + os::atomic_copy64((volatile jlong*)&store_value, dest); +} + #endif // OS_CPU_LINUX_ZERO_VM_ATOMIC_LINUX_ZERO_INLINE_HPP diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index b8f7ae47383..39bb2f3b6a3 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -768,7 +768,9 @@ CompilerThread* CompileBroker::make_compiler_thread(const char* name, CompileQue // Initialize the compilation queue void CompileBroker::init_compiler_threads(int c1_compiler_count, int c2_compiler_count) { EXCEPTION_MARK; +#ifndef ZERO assert(c2_compiler_count > 0 || c1_compiler_count > 0, "No compilers?"); +#endif // !ZERO if (c2_compiler_count > 0) { _c2_method_queue = new CompileQueue("C2MethodQueue", MethodCompileQueue_lock); } diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp index c214457b4f4..8abd80508df 100644 --- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp +++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp @@ -1936,7 +1936,7 @@ run: constantPoolOop constants = istate->method()->constants(); if (!constants->tag_at(index).is_unresolved_klass()) { // Make sure klass is initialized and doesn't have a finalizer - oop entry = (klassOop) *constants->obj_at_addr(index); + oop entry = constants->slot_at(index).get_oop(); assert(entry->is_klass(), "Should be resolved klass"); klassOop k_entry = (klassOop) entry; assert(k_entry->klass_part()->oop_is_instance(), "Should be instanceKlass"); @@ -2026,7 +2026,7 @@ run: if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); } - klassOop klassOf = (klassOop) *(METHOD->constants()->obj_at_addr(index)); + klassOop klassOf = (klassOop) METHOD->constants()->slot_at(index).get_oop(); klassOop objKlassOop = STACK_OBJECT(-1)->klass(); //ebx // // Check for compatibilty. This check must not GC!! @@ -2061,7 +2061,7 @@ run: if (METHOD->constants()->tag_at(index).is_unresolved_klass()) { CALL_VM(InterpreterRuntime::quicken_io_cc(THREAD), handle_exception); } - klassOop klassOf = (klassOop) *(METHOD->constants()->obj_at_addr(index)); + klassOop klassOf = (klassOop) METHOD->constants()->slot_at(index).get_oop(); klassOop objKlassOop = STACK_OBJECT(-1)->klass(); // // Check for compatibilty. This check must not GC!! diff --git a/hotspot/src/share/vm/oops/methodOop.cpp b/hotspot/src/share/vm/oops/methodOop.cpp index 42ffbec7f1a..3f55ed4a4f6 100644 --- a/hotspot/src/share/vm/oops/methodOop.cpp +++ b/hotspot/src/share/vm/oops/methodOop.cpp @@ -934,7 +934,7 @@ methodHandle methodOopDesc::make_invoke_method(KlassHandle holder, assert(m->signature() == signature, ""); assert(m->is_method_handle_invoke(), ""); #ifdef CC_INTERP - ResultTypeFinder rtf(signature()); + ResultTypeFinder rtf(signature); m->set_result_index(rtf.type()); #endif m->compute_size_of_parameters(THREAD); From add4b5bf69d8089aed43ac1c040bd77601682ac8 Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Fri, 11 Feb 2011 12:05:43 -0800 Subject: [PATCH 026/105] 7018506: CTW swallowing OOMs after symbol changes Reviewed-by: kvn, iveresov, coleenp --- hotspot/src/share/vm/classfile/classLoader.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classLoader.cpp b/hotspot/src/share/vm/classfile/classLoader.cpp index 41ca1692139..01ed5c0c174 100644 --- a/hotspot/src/share/vm/classfile/classLoader.cpp +++ b/hotspot/src/share/vm/classfile/classLoader.cpp @@ -1290,6 +1290,15 @@ void ClassLoader::compile_the_world() { int ClassLoader::_compile_the_world_counter = 0; static int _codecache_sweep_counter = 0; +// Filter out all exceptions except OOMs +static void clear_pending_exception_if_not_oom(TRAPS) { + if (HAS_PENDING_EXCEPTION && + !PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())) { + CLEAR_PENDING_EXCEPTION; + } + // The CHECK at the caller will propagate the exception out +} + void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) { int len = (int)strlen(name); if (len > 6 && strcmp(".class", name + len - 6) == 0) { @@ -1312,12 +1321,12 @@ void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) { k->initialize(THREAD); } bool exception_occurred = HAS_PENDING_EXCEPTION; - CLEAR_PENDING_EXCEPTION; + clear_pending_exception_if_not_oom(CHECK); if (CompileTheWorldPreloadClasses && k.not_null()) { constantPoolKlass::preload_and_initialize_all_classes(k->constants(), THREAD); if (HAS_PENDING_EXCEPTION) { // If something went wrong in preloading we just ignore it - CLEAR_PENDING_EXCEPTION; + clear_pending_exception_if_not_oom(CHECK); tty->print_cr("Preloading failed for (%d) %s", _compile_the_world_counter, buffer); } } @@ -1344,7 +1353,7 @@ void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) { CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_initial_compile, methodHandle(), 0, "CTW", THREAD); if (HAS_PENDING_EXCEPTION) { - CLEAR_PENDING_EXCEPTION; + clear_pending_exception_if_not_oom(CHECK); tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_counter, m->name()->as_C_string()); } if (TieredCompilation) { @@ -1358,7 +1367,7 @@ void ClassLoader::compile_the_world_in(char* name, Handle loader, TRAPS) { CompileBroker::compile_method(m, InvocationEntryBci, CompLevel_full_optimization, methodHandle(), 0, "CTW", THREAD); if (HAS_PENDING_EXCEPTION) { - CLEAR_PENDING_EXCEPTION; + clear_pending_exception_if_not_oom(CHECK); tty->print_cr("CompileTheWorld (%d) : Skipping method: %s", _compile_the_world_counter, m->name()->as_C_string()); } } From c2b37037c6e9f54ea5e78b9a7741c0cdb627e54c Mon Sep 17 00:00:00 2001 From: Christian Thalinger Date: Mon, 14 Feb 2011 03:21:18 -0800 Subject: [PATCH 027/105] 7018378: JSR 292: _bound_int_mh produces wrong result on 64-bit SPARC Reviewed-by: kvn --- hotspot/src/cpu/sparc/vm/assembler_sparc.cpp | 23 +++++++---- hotspot/src/cpu/sparc/vm/assembler_sparc.hpp | 5 ++- .../src/cpu/sparc/vm/methodHandles_sparc.cpp | 21 +++------- hotspot/src/cpu/x86/vm/assembler_x86.cpp | 39 ++++++++++++++----- hotspot/src/cpu/x86/vm/assembler_x86.hpp | 5 ++- hotspot/src/cpu/x86/vm/methodHandles_x86.cpp | 18 +++------ 6 files changed, 63 insertions(+), 48 deletions(-) diff --git a/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp index 0d81e2d1254..9d8642b3c09 100644 --- a/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.cpp @@ -2407,14 +2407,23 @@ void MacroAssembler::lcmp( Register Ra, Register Rb, Register Rresult) { #endif -void MacroAssembler::load_sized_value(Address src, Register dst, - size_t size_in_bytes, bool is_signed) { +void MacroAssembler::load_sized_value(Address src, Register dst, size_t size_in_bytes, bool is_signed) { switch (size_in_bytes) { - case 8: ldx(src, dst); break; - case 4: ld( src, dst); break; - case 2: is_signed ? ldsh(src, dst) : lduh(src, dst); break; - case 1: is_signed ? ldsb(src, dst) : ldub(src, dst); break; - default: ShouldNotReachHere(); + case 8: ld_long(src, dst); break; + case 4: ld( src, dst); break; + case 2: is_signed ? ldsh(src, dst) : lduh(src, dst); break; + case 1: is_signed ? ldsb(src, dst) : ldub(src, dst); break; + default: ShouldNotReachHere(); + } +} + +void MacroAssembler::store_sized_value(Register src, Address dst, size_t size_in_bytes) { + switch (size_in_bytes) { + case 8: st_long(src, dst); break; + case 4: st( src, dst); break; + case 2: sth( src, dst); break; + case 1: stb( src, dst); break; + default: ShouldNotReachHere(); } } diff --git a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp index b6d7d9ab14a..86c616fb043 100644 --- a/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp +++ b/hotspot/src/cpu/sparc/vm/assembler_sparc.hpp @@ -2330,8 +2330,9 @@ public: void lcmp( Register Ra, Register Rb, Register Rresult); #endif - // Loading values by size and signed-ness - void load_sized_value(Address src, Register dst, size_t size_in_bytes, bool is_signed); + // Load and store values by size and signed-ness + void load_sized_value( Address src, Register dst, size_t size_in_bytes, bool is_signed); + void store_sized_value(Register src, Address dst, size_t size_in_bytes); void float_cmp( bool is_float, int unordered_result, FloatRegister Fa, FloatRegister Fb, diff --git a/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp b/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp index 4fc102fa480..38213b7f054 100644 --- a/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp +++ b/hotspot/src/cpu/sparc/vm/methodHandles_sparc.cpp @@ -596,16 +596,9 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan __ st_ptr(O1_scratch, Address(O0_argslot, 0)); } else { Address prim_value_addr(O1_scratch, java_lang_boxing_object::value_offset_in_bytes(arg_type)); - __ load_sized_value(prim_value_addr, O2_scratch, type2aelembytes(arg_type), is_signed_subword_type(arg_type)); - if (arg_slots == 2) { - __ unimplemented("not yet tested"); -#ifndef _LP64 - __ signx(O2_scratch, O3_scratch); // Sign extend -#endif - __ st_long(O2_scratch, Address(O0_argslot, 0)); // Uses O2/O3 on !_LP64 - } else { - __ st_ptr( O2_scratch, Address(O0_argslot, 0)); - } + const int arg_size = type2aelembytes(arg_type); + __ load_sized_value(prim_value_addr, O2_scratch, arg_size, is_signed_subword_type(arg_type)); + __ store_sized_value(O2_scratch, Address(O0_argslot, 0), arg_size); // long store uses O2/O3 on !_LP64 } if (direct_to_method) { @@ -784,11 +777,9 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan switch (ek) { case _adapter_opt_i2l: { - __ ldsw(arg_lsw, O2_scratch); // Load LSW -#ifndef _LP64 - __ signx(O2_scratch, O3_scratch); // Sign extend -#endif - __ st_long(O2_scratch, arg_msw); // Uses O2/O3 on !_LP64 + __ ldsw(arg_lsw, O2_scratch); // Load LSW + NOT_LP64(__ srlx(O2_scratch, BitsPerInt, O3_scratch)); // Move high bits to lower bits for std + __ st_long(O2_scratch, arg_msw); // Uses O2/O3 on !_LP64 } break; case _adapter_opt_unboxl: diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp index 4c87f23cd13..52d8b0b621f 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp @@ -6528,20 +6528,39 @@ int MacroAssembler::load_unsigned_short(Register dst, Address src) { return off; } -void MacroAssembler::load_sized_value(Register dst, Address src, - size_t size_in_bytes, bool is_signed) { +void MacroAssembler::load_sized_value(Register dst, Address src, size_t size_in_bytes, bool is_signed, Register dst2) { switch (size_in_bytes) { #ifndef _LP64 - // For case 8, caller is responsible for manually loading - // the second word into another register. - case 8: movl(dst, src); break; + case 8: + assert(dst2 != noreg, "second dest register required"); + movl(dst, src); + movl(dst2, src.plus_disp(BytesPerInt)); + break; #else - case 8: movq(dst, src); break; + case 8: movq(dst, src); break; #endif - case 4: movl(dst, src); break; - case 2: is_signed ? load_signed_short(dst, src) : load_unsigned_short(dst, src); break; - case 1: is_signed ? load_signed_byte( dst, src) : load_unsigned_byte( dst, src); break; - default: ShouldNotReachHere(); + case 4: movl(dst, src); break; + case 2: is_signed ? load_signed_short(dst, src) : load_unsigned_short(dst, src); break; + case 1: is_signed ? load_signed_byte( dst, src) : load_unsigned_byte( dst, src); break; + default: ShouldNotReachHere(); + } +} + +void MacroAssembler::store_sized_value(Address dst, Register src, size_t size_in_bytes, Register src2) { + switch (size_in_bytes) { +#ifndef _LP64 + case 8: + assert(src2 != noreg, "second source register required"); + movl(dst, src); + movl(dst.plus_disp(BytesPerInt), src2); + break; +#else + case 8: movq(dst, src); break; +#endif + case 4: movl(dst, src); break; + case 2: movw(dst, src); break; + case 1: movb(dst, src); break; + default: ShouldNotReachHere(); } } diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp index a1a8a96dee6..d26f1639d1f 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp @@ -1522,8 +1522,9 @@ class MacroAssembler: public Assembler { // Support for sign-extension (hi:lo = extend_sign(lo)) void extend_sign(Register hi, Register lo); - // Loading values by size and signed-ness - void load_sized_value(Register dst, Address src, size_t size_in_bytes, bool is_signed); + // Load and store values by size and signed-ness + void load_sized_value(Register dst, Address src, size_t size_in_bytes, bool is_signed, Register dst2 = noreg); + void store_sized_value(Address dst, Register src, size_t size_in_bytes, Register src2 = noreg); // Support for inc/dec with optimal instruction selection depending on value diff --git a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp index bbbc29d6408..59c1c28eec8 100644 --- a/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp +++ b/hotspot/src/cpu/x86/vm/methodHandles_x86.cpp @@ -602,24 +602,18 @@ void MethodHandles::generate_method_handle_stub(MacroAssembler* _masm, MethodHan // make room for the new argument: __ movl(rax_argslot, rcx_bmh_vmargslot); __ lea(rax_argslot, __ argument_address(rax_argslot)); - insert_arg_slots(_masm, arg_slots * stack_move_unit(), arg_mask, - rax_argslot, rbx_temp, rdx_temp); + + insert_arg_slots(_masm, arg_slots * stack_move_unit(), arg_mask, rax_argslot, rbx_temp, rdx_temp); // store bound argument into the new stack slot: __ load_heap_oop(rbx_temp, rcx_bmh_argument); - Address prim_value_addr(rbx_temp, java_lang_boxing_object::value_offset_in_bytes(arg_type)); if (arg_type == T_OBJECT) { __ movptr(Address(rax_argslot, 0), rbx_temp); } else { - __ load_sized_value(rdx_temp, prim_value_addr, - type2aelembytes(arg_type), is_signed_subword_type(arg_type)); - __ movptr(Address(rax_argslot, 0), rdx_temp); -#ifndef _LP64 - if (arg_slots == 2) { - __ movl(rdx_temp, prim_value_addr.plus_disp(wordSize)); - __ movl(Address(rax_argslot, Interpreter::stackElementSize), rdx_temp); - } -#endif //_LP64 + Address prim_value_addr(rbx_temp, java_lang_boxing_object::value_offset_in_bytes(arg_type)); + const int arg_size = type2aelembytes(arg_type); + __ load_sized_value(rdx_temp, prim_value_addr, arg_size, is_signed_subword_type(arg_type), rbx_temp); + __ store_sized_value(Address(rax_argslot, 0), rdx_temp, arg_size, rbx_temp); } if (direct_to_method) { From a7f9351b5d9b47c2bdfaf810e881b3bcbad3f21c Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Mon, 14 Feb 2011 11:46:58 -0800 Subject: [PATCH 028/105] 7018101: os::dll_address_to_function_name returning wrong answers in 64 bit Reviewed-by: acorn, kvn, dsamersoff --- hotspot/src/os/solaris/vm/os_solaris.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hotspot/src/os/solaris/vm/os_solaris.cpp b/hotspot/src/os/solaris/vm/os_solaris.cpp index 80c7c4d5058..a187276da4d 100644 --- a/hotspot/src/os/solaris/vm/os_solaris.cpp +++ b/hotspot/src/os/solaris/vm/os_solaris.cpp @@ -1975,7 +1975,11 @@ bool os::dll_address_to_function_name(address addr, char *buf, #ifndef RTLD_DL_SYMENT #define RTLD_DL_SYMENT 1 #endif - Sym * info; +#ifdef _LP64 + Elf64_Sym * info; +#else + Elf32_Sym * info; +#endif if (dladdr1_func((void *)addr, &dlinfo, (void **)&info, RTLD_DL_SYMENT)) { if ((char *)dlinfo.dli_saddr + info->st_size > (char *)addr) { @@ -6422,4 +6426,3 @@ int os::bind(int fd, struct sockaddr *him, int len) { INTERRUPTIBLE_RETURN_INT_NORESTART(::bind(fd, him, len),\ os::Solaris::clear_interrupted); } - From 477cbff4b6906763acf4569e0830b6f13b36a92d Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Tue, 15 Feb 2011 22:18:33 -0800 Subject: [PATCH 029/105] 7019819: bare oop in ciField Reviewed-by: kvn, iveresov --- hotspot/src/share/vm/ci/ciField.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hotspot/src/share/vm/ci/ciField.cpp b/hotspot/src/share/vm/ci/ciField.cpp index ef12c7c0ce9..82d141af9eb 100644 --- a/hotspot/src/share/vm/ci/ciField.cpp +++ b/hotspot/src/share/vm/ci/ciField.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -212,9 +212,9 @@ void ciField::initialize_from(fieldDescriptor* fd) { // may change. The three examples are java.lang.System.in, // java.lang.System.out, and java.lang.System.err. - klassOop k = _holder->get_klassOop(); + Handle k = _holder->get_klassOop(); assert( SystemDictionary::System_klass() != NULL, "Check once per vm"); - if( k == SystemDictionary::System_klass() ) { + 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() || From 4b3ada699de3c4c46ae7c79b7fc83cea331c7bef Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Wed, 9 Feb 2011 15:02:23 -0800 Subject: [PATCH 030/105] 7016474: string compare intrinsic improvements Reviewed-by: kvn --- hotspot/src/cpu/x86/vm/assembler_x86.cpp | 123 ++++++++++++++++------- hotspot/src/cpu/x86/vm/assembler_x86.hpp | 5 +- hotspot/src/cpu/x86/vm/x86_32.ad | 10 +- hotspot/src/cpu/x86/vm/x86_64.ad | 10 +- 4 files changed, 99 insertions(+), 49 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.cpp b/hotspot/src/cpu/x86/vm/assembler_x86.cpp index 52d8b0b621f..63f53d72b6e 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp @@ -2349,6 +2349,17 @@ void Assembler::prefix(Prefix p) { a_byte(p); } +void Assembler::por(XMMRegister dst, XMMRegister src) { + NOT_LP64(assert(VM_Version::supports_sse2(), "")); + + emit_byte(0x66); + int encode = prefix_and_encode(dst->encoding(), src->encoding()); + emit_byte(0x0F); + + emit_byte(0xEB); + emit_byte(0xC0 | encode); +} + void Assembler::pshufd(XMMRegister dst, XMMRegister src, int mode) { assert(isByte(mode), "invalid value"); NOT_LP64(assert(VM_Version::supports_sse2(), "")); @@ -8655,7 +8666,7 @@ void MacroAssembler::string_indexof(Register str1, Register str2, // Compare strings. void MacroAssembler::string_compare(Register str1, Register str2, Register cnt1, Register cnt2, Register result, - XMMRegister vec1, XMMRegister vec2) { + XMMRegister vec1) { Label LENGTH_DIFF_LABEL, POP_LABEL, DONE_LABEL, WHILE_HEAD_LABEL; // Compute the minimum of the string lengths and the @@ -8702,62 +8713,85 @@ void MacroAssembler::string_compare(Register str1, Register str2, bind(LSkip2); } - // Advance to next character - addptr(str1, 2); - addptr(str2, 2); + Address::ScaleFactor scale = Address::times_2; + int stride = 8; + + // Advance to next element + addptr(str1, 16/stride); + addptr(str2, 16/stride); if (UseSSE42Intrinsics) { - // With SSE4.2, use double quad vector compare - Label COMPARE_VECTORS, VECTOR_NOT_EQUAL, COMPARE_TAIL; + Label COMPARE_WIDE_VECTORS, VECTOR_NOT_EQUAL, COMPARE_TAIL; + int pcmpmask = 0x19; // Setup to compare 16-byte vectors - movl(cnt1, cnt2); - andl(cnt2, 0xfffffff8); // cnt2 holds the vector count - andl(cnt1, 0x00000007); // cnt1 holds the tail count - testl(cnt2, cnt2); + movl(result, cnt2); + andl(cnt2, ~(stride - 1)); // cnt2 holds the vector count jccb(Assembler::zero, COMPARE_TAIL); - lea(str2, Address(str2, cnt2, Address::times_2)); - lea(str1, Address(str1, cnt2, Address::times_2)); - negptr(cnt2); + lea(str1, Address(str1, result, scale)); + lea(str2, Address(str2, result, scale)); + negptr(result); - bind(COMPARE_VECTORS); - movdqu(vec1, Address(str1, cnt2, Address::times_2)); - movdqu(vec2, Address(str2, cnt2, Address::times_2)); - pxor(vec1, vec2); - ptest(vec1, vec1); - jccb(Assembler::notZero, VECTOR_NOT_EQUAL); - addptr(cnt2, 8); - jcc(Assembler::notZero, COMPARE_VECTORS); - jmpb(COMPARE_TAIL); + // pcmpestri + // inputs: + // vec1- substring + // rax - negative string length (elements count) + // mem - scaned string + // rdx - string length (elements count) + // pcmpmask - cmp mode: 11000 (string compare with negated result) + // + 00 (unsigned bytes) or + 01 (unsigned shorts) + // outputs: + // rcx - first mismatched element index + assert(result == rax && cnt2 == rdx && cnt1 == rcx, "pcmpestri"); + + bind(COMPARE_WIDE_VECTORS); + movdqu(vec1, Address(str1, result, scale)); + pcmpestri(vec1, Address(str2, result, scale), pcmpmask); + // After pcmpestri cnt1(rcx) contains mismatched element index + + jccb(Assembler::below, VECTOR_NOT_EQUAL); // CF==1 + addptr(result, stride); + subptr(cnt2, stride); + jccb(Assembler::notZero, COMPARE_WIDE_VECTORS); + + // compare wide vectors tail + testl(result, result); + jccb(Assembler::zero, LENGTH_DIFF_LABEL); + + movl(cnt2, stride); + movl(result, stride); + negptr(result); + movdqu(vec1, Address(str1, result, scale)); + pcmpestri(vec1, Address(str2, result, scale), pcmpmask); + jccb(Assembler::aboveEqual, LENGTH_DIFF_LABEL); // Mismatched characters in the vectors bind(VECTOR_NOT_EQUAL); - lea(str1, Address(str1, cnt2, Address::times_2)); - lea(str2, Address(str2, cnt2, Address::times_2)); - movl(cnt1, 8); + addptr(result, cnt1); + movptr(cnt2, result); + load_unsigned_short(result, Address(str1, cnt2, scale)); + load_unsigned_short(cnt1, Address(str2, cnt2, scale)); + subl(result, cnt1); + jmpb(POP_LABEL); - // Compare tail (< 8 chars), or rescan last vectors to - // find 1st mismatched characters - bind(COMPARE_TAIL); - testl(cnt1, cnt1); - jccb(Assembler::zero, LENGTH_DIFF_LABEL); - movl(cnt2, cnt1); + bind(COMPARE_TAIL); // limit is zero + movl(cnt2, result); // Fallthru to tail compare } // Shift str2 and str1 to the end of the arrays, negate min - lea(str1, Address(str1, cnt2, Address::times_2, 0)); - lea(str2, Address(str2, cnt2, Address::times_2, 0)); + lea(str1, Address(str1, cnt2, scale, 0)); + lea(str2, Address(str2, cnt2, scale, 0)); negptr(cnt2); - // Compare the rest of the characters + // Compare the rest of the elements bind(WHILE_HEAD_LABEL); - load_unsigned_short(result, Address(str1, cnt2, Address::times_2, 0)); - load_unsigned_short(cnt1, Address(str2, cnt2, Address::times_2, 0)); + load_unsigned_short(result, Address(str1, cnt2, scale, 0)); + load_unsigned_short(cnt1, Address(str2, cnt2, scale, 0)); subl(result, cnt1); jccb(Assembler::notZero, POP_LABEL); increment(cnt2); - jcc(Assembler::notZero, WHILE_HEAD_LABEL); + jccb(Assembler::notZero, WHILE_HEAD_LABEL); // Strings are equal up to min length. Return the length difference. bind(LENGTH_DIFF_LABEL); @@ -8766,7 +8800,7 @@ void MacroAssembler::string_compare(Register str1, Register str2, // Discard the stored length difference bind(POP_LABEL); - addptr(rsp, wordSize); + pop(cnt1); // That's it bind(DONE_LABEL); @@ -8814,6 +8848,7 @@ void MacroAssembler::char_arrays_equals(bool is_array_equ, Register ary1, Regist if (UseSSE42Intrinsics) { // With SSE4.2, use double quad vector compare Label COMPARE_WIDE_VECTORS, COMPARE_TAIL; + // Compare 16-byte vectors andl(result, 0x0000000e); // tail count (in bytes) andl(limit, 0xfffffff0); // vector count (in bytes) @@ -8827,11 +8862,23 @@ void MacroAssembler::char_arrays_equals(bool is_array_equ, Register ary1, Regist movdqu(vec1, Address(ary1, limit, Address::times_1)); movdqu(vec2, Address(ary2, limit, Address::times_1)); pxor(vec1, vec2); + ptest(vec1, vec1); jccb(Assembler::notZero, FALSE_LABEL); addptr(limit, 16); jcc(Assembler::notZero, COMPARE_WIDE_VECTORS); + testl(result, result); + jccb(Assembler::zero, TRUE_LABEL); + + movdqu(vec1, Address(ary1, result, Address::times_1, -16)); + movdqu(vec2, Address(ary2, result, Address::times_1, -16)); + pxor(vec1, vec2); + + ptest(vec1, vec1); + jccb(Assembler::notZero, FALSE_LABEL); + jmpb(TRUE_LABEL); + bind(COMPARE_TAIL); // limit is zero movl(limit, result); // Fallthru to tail compare diff --git a/hotspot/src/cpu/x86/vm/assembler_x86.hpp b/hotspot/src/cpu/x86/vm/assembler_x86.hpp index d26f1639d1f..85139341414 100644 --- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp @@ -1277,6 +1277,9 @@ private: void prefetcht2(Address src); void prefetchw(Address src); + // POR - Bitwise logical OR + void por(XMMRegister dst, XMMRegister src); + // Shuffle Packed Doublewords void pshufd(XMMRegister dst, XMMRegister src, int mode); void pshufd(XMMRegister dst, Address src, int mode); @@ -2294,7 +2297,7 @@ public: // Compare strings. void string_compare(Register str1, Register str2, Register cnt1, Register cnt2, Register result, - XMMRegister vec1, XMMRegister vec2); + XMMRegister vec1); // Compare char[] arrays. void char_arrays_equals(bool is_array_equ, Register ary1, Register ary2, diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad index b73bcda7fa9..a064d2999bc 100644 --- a/hotspot/src/cpu/x86/vm/x86_32.ad +++ b/hotspot/src/cpu/x86/vm/x86_32.ad @@ -12629,16 +12629,16 @@ instruct rep_stos(eCXRegI cnt, eDIRegP base, eAXRegI zero, Universe dummy, eFlag ins_pipe( pipe_slow ); %} -instruct string_compare(eDIRegP str1, eCXRegI cnt1, eSIRegP str2, eBXRegI cnt2, - eAXRegI result, regXD tmp1, regXD tmp2, eFlagsReg cr) %{ +instruct string_compare(eDIRegP str1, eCXRegI cnt1, eSIRegP str2, eDXRegI cnt2, + eAXRegI result, regXD tmp1, eFlagsReg cr) %{ match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2))); - effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr); + effect(TEMP tmp1, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr); - format %{ "String Compare $str1,$cnt1,$str2,$cnt2 -> $result // KILL $tmp1, $tmp2" %} + format %{ "String Compare $str1,$cnt1,$str2,$cnt2 -> $result // KILL $tmp1" %} ins_encode %{ __ string_compare($str1$$Register, $str2$$Register, $cnt1$$Register, $cnt2$$Register, $result$$Register, - $tmp1$$XMMRegister, $tmp2$$XMMRegister); + $tmp1$$XMMRegister); %} ins_pipe( pipe_slow ); %} diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad index e007ce96cc8..b89d46a2996 100644 --- a/hotspot/src/cpu/x86/vm/x86_64.ad +++ b/hotspot/src/cpu/x86/vm/x86_64.ad @@ -11583,17 +11583,17 @@ instruct rep_stos(rcx_RegL cnt, rdi_RegP base, rax_RegI zero, Universe dummy, ins_pipe(pipe_slow); %} -instruct string_compare(rdi_RegP str1, rcx_RegI cnt1, rsi_RegP str2, rbx_RegI cnt2, - rax_RegI result, regD tmp1, regD tmp2, rFlagsReg cr) +instruct string_compare(rdi_RegP str1, rcx_RegI cnt1, rsi_RegP str2, rdx_RegI cnt2, + rax_RegI result, regD tmp1, rFlagsReg cr) %{ match(Set result (StrComp (Binary str1 cnt1) (Binary str2 cnt2))); - effect(TEMP tmp1, TEMP tmp2, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr); + effect(TEMP tmp1, USE_KILL str1, USE_KILL str2, USE_KILL cnt1, USE_KILL cnt2, KILL cr); - format %{ "String Compare $str1,$cnt1,$str2,$cnt2 -> $result // KILL $tmp1, $tmp2" %} + format %{ "String Compare $str1,$cnt1,$str2,$cnt2 -> $result // KILL $tmp1" %} ins_encode %{ __ string_compare($str1$$Register, $str2$$Register, $cnt1$$Register, $cnt2$$Register, $result$$Register, - $tmp1$$XMMRegister, $tmp2$$XMMRegister); + $tmp1$$XMMRegister); %} ins_pipe( pipe_slow ); %} From 76468b0bcfdc283db767e038ddce1e71717fc090 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Wed, 9 Feb 2011 18:26:08 -0800 Subject: [PATCH 031/105] 7018447: langtools launcher template fails if tools run from their own directory Reviewed-by: jjg --- langtools/src/share/bin/launcher.sh-template | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/langtools/src/share/bin/launcher.sh-template b/langtools/src/share/bin/launcher.sh-template index c4abbf4f742..d2f0d108d0b 100644 --- a/langtools/src/share/bin/launcher.sh-template +++ b/langtools/src/share/bin/launcher.sh-template @@ -31,8 +31,7 @@ case `uname -s` in mydir=`cygpath -m $mydir` ;; esac - -mylib="`dirname $mydir`"/lib +mylib="$mydir/../lib" # By default, put the jar file and its dependencies on the bootclasspath. # This is always required on a Mac, because the system langtools classes @@ -73,4 +72,4 @@ done unset DUALCASE IFS=$nl -"#TARGET_JAVA#" "${bcp:+-Xbootclasspath/p:"$bcp"}" ${ea} ${javaOpts} -jar "${mydir}"/../lib/#PROGRAM#.jar ${toolOpts} +"#TARGET_JAVA#" "${bcp:+-Xbootclasspath/p:"$bcp"}" ${ea} ${javaOpts} -jar "${mylib}/#PROGRAM#.jar" ${toolOpts} From 4598218eac4918cf91706d5caf6bb4d32c14fb76 Mon Sep 17 00:00:00 2001 From: Andrew Brygin Date: Thu, 10 Feb 2011 13:44:36 +0300 Subject: [PATCH 032/105] 6989774: imageio compiler warnings in native code Reviewed-by: igor, prr --- jdk/make/sun/jpeg/Makefile | 13 ++++ jdk/make/sun/jpeg/reorder-i586 | 46 ++++++------- jdk/make/sun/jpeg/reorder-sparc | 20 +++--- jdk/make/sun/jpeg/reorder-sparcv9 | 18 ++--- .../native/sun/awt/image/jpeg/imageioJPEG.c | 66 +++++++++++-------- .../native/sun/awt/image/jpeg/jdmarker.c | 4 +- .../share/native/sun/awt/image/jpeg/jmemmgr.c | 12 ++-- .../native/sun/awt/image/jpeg/jmemnobs.c | 8 +-- .../share/native/sun/awt/image/jpeg/jmemsys.h | 10 +-- .../native/sun/awt/image/jpeg/jpegdecoder.c | 4 +- .../share/native/sun/awt/image/jpeg/jpeglib.h | 4 +- 11 files changed, 114 insertions(+), 91 deletions(-) diff --git a/jdk/make/sun/jpeg/Makefile b/jdk/make/sun/jpeg/Makefile index b669ad48de2..b16ebea9f0f 100644 --- a/jdk/make/sun/jpeg/Makefile +++ b/jdk/make/sun/jpeg/Makefile @@ -65,6 +65,19 @@ ifeq ($(PLATFORM), solaris) FILES_reorder += reorder-$(ARCH) endif endif + +ifeq ($(PLATFORM), linux) + + # Suppress gcc warnings like "variable might be clobbered by 'longjmp' + # or 'vfork'": this warning indicates that some variable is placed to + # a register by optimized compiler and it's value might be lost on longjmp(). + # Recommended way to avoid such warning is to declare the variable as + # volatile to prevent the optimization. However, this approach does not + # work because we have to declare all variables as volatile in result. + + OTHER_CFLAGS += -Wno-clobbered +endif + include $(BUILDDIR)/common/Mapfile-vers.gmk include $(BUILDDIR)/common/Library.gmk diff --git a/jdk/make/sun/jpeg/reorder-i586 b/jdk/make/sun/jpeg/reorder-i586 index 3fe7ea991bf..47e18ca44d1 100644 --- a/jdk/make/sun/jpeg/reorder-i586 +++ b/jdk/make/sun/jpeg/reorder-i586 @@ -22,7 +22,7 @@ text: .text%jIMReader; text: .text%alloc_small: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jmemmgr.o; text: .text%reset_marker_reader: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%jIInCtlr; -text: .text%GET_ARRAYS: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jpegdecoder.o; +# text: .text%GET_ARRAYS: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jpegdecoder.o; text: .text%jReadHeader; text: .text%jConsumeInput; text: .text%reset_input_controller: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; @@ -30,36 +30,36 @@ text: .text%reset_error_mgr: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jerror.o; text: .text%sun_jpeg_init_source; text: .text%consume_markers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; text: .text%read_markers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; -text: .text%first_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; +# text: .text%first_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%sun_jpeg_fill_input_buffer; -text: .text%RELEASE_ARRAYS: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jpegdecoder.o; -text: .text%get_soi: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; +# text: .text%RELEASE_ARRAYS: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jpegdecoder.o; +# text: .text%get_soi: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%emit_message: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jerror.o; -text: .text%next_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; +# text: .text%next_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%get_interesting_appn: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; -text: .text%examine_app0: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; +# text: .text%examine_app0: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%skip_variable: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%sun_jpeg_skip_input_data; -text: .text%examine_app14: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; +# text: .text%examine_app14: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%get_dqt: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%jAlcQTable; text: .text%get_sof: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; -text: .text%get_dri: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; +# text: .text%get_dri: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%get_dht: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%jAlcHTable; text: .text%get_sos: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; -text: .text%initial_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; +# text: .text%initial_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; text: .text%jDivRound; -text: .text%default_decompress_parms: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdapimin.o; +# text: .text%default_decompress_parms: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdapimin.o; text: .text%jHasMultScn; text: .text%jStrtDecompress; text: .text%jIDMaster; -text: .text%master_selection: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; +# text: .text%master_selection: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; text: .text%jCalcDimensions; -text: .text%use_merged_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; -text: .text%prepare_range_limit_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; +# text: .text%use_merged_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; +# text: .text%prepare_range_limit_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; text: .text%jIDColor; -text: .text%build_ycc_rgb_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o; +# text: .text%build_ycc_rgb_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o; text: .text%jIUpsampler; text: .text%jRound; text: .text%alloc_sarray: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jmemmgr.o; @@ -70,16 +70,16 @@ text: .text%jIIDCT; text: .text%jIHDecoder; text: .text%jIDCoefC; text: .text%jIDMainC; -text: .text%alloc_funny_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; +# text: .text%alloc_funny_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; text: .text%realize_virt_arrays: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jmemmgr.o; text: .text%start_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; -text: .text%per_scan_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; -text: .text%latch_quant_tables: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; +# text: .text%per_scan_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; +# text: .text%latch_quant_tables: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; text: .text%start_pass_huff_decoder: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdhuff.o; text: .text%jMkDDerived; text: .text%start_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o; -text: .text%start_iMCU_row: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o; -text: .text%output_pass_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdapistd.o; +# text: .text%start_iMCU_row: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o; +# text: .text%output_pass_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdapistd.o; text: .text%prepare_for_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; text: .text%start_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jddctmgr.o; text: .text%start_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o; @@ -87,7 +87,7 @@ text: .text%start_pass_dcolor: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o; text: .text%start_pass_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdsample.o; text: .text%start_pass_dpost: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdpostct.o; text: .text%start_pass_main: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; -text: .text%make_funny_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; +# text: .text%make_funny_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; text: .text%jReadScanlines; text: .text%process_data_context_main: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; text: .text%decompress_onepass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o; @@ -100,11 +100,11 @@ text: .text%sep_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdsample.o; text: .text%fullsize_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdsample.o; text: .text%h2v2_fancy_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdsample.o; text: .text%ycc_rgb_convert: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o; -text: .text%set_wraparound_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; -text: .text%process_restart: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdhuff.o; +# text: .text%set_wraparound_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; +# text: .text%process_restart: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdhuff.o; text: .text%read_restart_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%finish_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; -text: .text%set_bottom_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; +# text: .text%set_bottom_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; text: .text%jFinDecompress; text: .text%finish_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; text: .text%sun_jpeg_term_source; diff --git a/jdk/make/sun/jpeg/reorder-sparc b/jdk/make/sun/jpeg/reorder-sparc index 3fe7ea991bf..a7b21edca43 100644 --- a/jdk/make/sun/jpeg/reorder-sparc +++ b/jdk/make/sun/jpeg/reorder-sparc @@ -30,10 +30,10 @@ text: .text%reset_error_mgr: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jerror.o; text: .text%sun_jpeg_init_source; text: .text%consume_markers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; text: .text%read_markers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; -text: .text%first_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; +# text: .text%first_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%sun_jpeg_fill_input_buffer; text: .text%RELEASE_ARRAYS: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jpegdecoder.o; -text: .text%get_soi: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; +# text: .text%get_soi: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%emit_message: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jerror.o; text: .text%next_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%get_interesting_appn: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; @@ -44,7 +44,7 @@ text: .text%examine_app14: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%get_dqt: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%jAlcQTable; text: .text%get_sof: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; -text: .text%get_dri: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; +# text: .text%get_dri: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%get_dht: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%jAlcHTable; text: .text%get_sos: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; @@ -56,10 +56,10 @@ text: .text%jStrtDecompress; text: .text%jIDMaster; text: .text%master_selection: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; text: .text%jCalcDimensions; -text: .text%use_merged_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; -text: .text%prepare_range_limit_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; +# text: .text%use_merged_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; +# text: .text%prepare_range_limit_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; text: .text%jIDColor; -text: .text%build_ycc_rgb_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o; +# text: .text%build_ycc_rgb_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o; text: .text%jIUpsampler; text: .text%jRound; text: .text%alloc_sarray: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jmemmgr.o; @@ -78,7 +78,7 @@ text: .text%latch_quant_tables: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; text: .text%start_pass_huff_decoder: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdhuff.o; text: .text%jMkDDerived; text: .text%start_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o; -text: .text%start_iMCU_row: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o; +# text: .text%start_iMCU_row: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcoefct.o; text: .text%output_pass_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdapistd.o; text: .text%prepare_for_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; text: .text%start_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jddctmgr.o; @@ -100,11 +100,11 @@ text: .text%sep_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdsample.o; text: .text%fullsize_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdsample.o; text: .text%h2v2_fancy_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdsample.o; text: .text%ycc_rgb_convert: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdcolor.o; -text: .text%set_wraparound_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; -text: .text%process_restart: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdhuff.o; +# text: .text%set_wraparound_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; +#text: .text%process_restart: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdhuff.o; text: .text%read_restart_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmarker.o; text: .text%finish_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdinput.o; -text: .text%set_bottom_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; +# text: .text%set_bottom_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmainct.o; text: .text%jFinDecompress; text: .text%finish_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj/jdmaster.o; text: .text%sun_jpeg_term_source; diff --git a/jdk/make/sun/jpeg/reorder-sparcv9 b/jdk/make/sun/jpeg/reorder-sparcv9 index e5447a4f56f..3af1a21eb80 100644 --- a/jdk/make/sun/jpeg/reorder-sparcv9 +++ b/jdk/make/sun/jpeg/reorder-sparcv9 @@ -30,10 +30,10 @@ text: .text%reset_error_mgr: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jerror.o; text: .text%sun_jpeg_init_source; text: .text%consume_markers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdinput.o; text: .text%read_markers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; -text: .text%first_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; +# text: .text%first_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; text: .text%sun_jpeg_fill_input_buffer; text: .text%RELEASE_ARRAYS: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jpegdecoder.o; -text: .text%get_soi: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; +# text: .text%get_soi: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; text: .text%emit_message: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jerror.o; text: .text%next_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; text: .text%get_interesting_appn: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; @@ -44,7 +44,7 @@ text: .text%examine_app14: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; text: .text%get_dqt: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; text: .text%jAlcQTable; text: .text%get_sof: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; -text: .text%get_dri: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; +# text: .text%get_dri: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; text: .text%get_dht: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; text: .text%jAlcHTable; text: .text%get_sos: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; @@ -56,10 +56,10 @@ text: .text%jStrtDecompress; text: .text%jIDMaster; text: .text%master_selection: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o; text: .text%jCalcDimensions; -text: .text%use_merged_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o; -text: .text%prepare_range_limit_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o; +# text: .text%use_merged_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o; +# text: .text%prepare_range_limit_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o; text: .text%jIDColor; -text: .text%build_ycc_rgb_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdcolor.o; +# text: .text%build_ycc_rgb_table: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdcolor.o; text: .text%jIUpsampler; text: .text%jRound; text: .text%alloc_sarray: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jmemmgr.o; @@ -78,7 +78,7 @@ text: .text%latch_quant_tables: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdinput.o; text: .text%start_pass_huff_decoder: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdhuff.o; text: .text%jMkDDerived; text: .text%start_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdcoefct.o; -text: .text%start_iMCU_row: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdcoefct.o; +# text: .text%start_iMCU_row: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdcoefct.o; text: .text%output_pass_setup: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdapistd.o; text: .text%prepare_for_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o; text: .text%start_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jddctmgr.o; @@ -100,11 +100,11 @@ text: .text%sep_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdsample.o; text: .text%fullsize_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdsample.o; text: .text%h2v2_fancy_upsample: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdsample.o; text: .text%ycc_rgb_convert: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdcolor.o; -text: .text%set_wraparound_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmainct.o; +# text: .text%set_wraparound_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmainct.o; text: .text%process_restart: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdhuff.o; text: .text%read_restart_marker: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmarker.o; text: .text%finish_input_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdinput.o; -text: .text%set_bottom_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmainct.o; +# text: .text%set_bottom_pointers: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmainct.o; text: .text%jFinDecompress; text: .text%finish_output_pass: OUTPUTDIR/tmp/sun/sun.awt/jpeg/obj64/jdmaster.o; text: .text%sun_jpeg_term_source; diff --git a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c index bfbef221dbd..e9c98702366 100644 --- a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c +++ b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c @@ -109,8 +109,8 @@ typedef struct streamBufferStruct { jobject stream; // ImageInputStream or ImageOutputStream jbyteArray hstreamBuffer; // Handle to a Java buffer for the stream JOCTET *buf; // Pinned buffer pointer */ - int bufferOffset; // holds offset between unpin and the next pin - int bufferLength; // Allocated, nut just used + size_t bufferOffset; // holds offset between unpin and the next pin + size_t bufferLength; // Allocated, nut just used int suspendable; // Set to true to suspend input long remaining_skip; // Used only on input } streamBuffer, *streamBufferPtr; @@ -129,7 +129,7 @@ typedef struct streamBufferStruct { * Used to signal that no data need be restored from an unpin to a pin. * I.e. the buffer is empty. */ -#define NO_DATA -1 +#define NO_DATA ((size_t)-1) // Forward reference static void resetStreamBuffer(JNIEnv *env, streamBufferPtr sb); @@ -389,7 +389,6 @@ typedef struct imageIODataStruct { static imageIODataPtr initImageioData (JNIEnv *env, j_common_ptr cinfo, jobject obj) { - int i, j; imageIODataPtr data = (imageIODataPtr) malloc (sizeof(imageIOData)); if (data == NULL) { @@ -982,7 +981,7 @@ imageio_fill_suspended_buffer(j_decompress_ptr cinfo) streamBufferPtr sb = &data->streamBuf; JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); jint ret; - int offset, buflen; + size_t offset, buflen; /* * The original (jpegdecoder.c) had code here that called @@ -1520,7 +1519,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initJPEGImageReader imageio_dispose((j_common_ptr)cinfo); return 0; } - return (jlong) ret; + return ptr_to_jlong(ret); } /* @@ -1535,7 +1534,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setSource jlong ptr, jobject source) { - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); j_common_ptr cinfo; if (data == NULL) { @@ -1574,7 +1573,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader int h_samp0, h_samp1, h_samp2; int v_samp0, v_samp1, v_samp2; jboolean retval = JNI_FALSE; - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); j_decompress_ptr cinfo; struct jpeg_source_mgr *src; sun_jpeg_error_ptr jerr; @@ -1772,7 +1771,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setOutColorSpace jlong ptr, jint code) { - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); j_decompress_ptr cinfo; if (data == NULL) { @@ -1814,7 +1813,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage struct jpeg_source_mgr *src; JSAMPROW scanLinePtr = NULL; jint bands[MAX_BANDS]; - int i, j; + int i; jint *body; int scanlineLimit; int pixelStride; @@ -1824,14 +1823,12 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage pixelBufferPtr pb; sun_jpeg_error_ptr jerr; boolean done; - jint *bandSize; - int maxBandValue, halfMaxBandValue; boolean mustScale = FALSE; boolean progressive = FALSE; boolean orderedBands = TRUE; - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); j_decompress_ptr cinfo; - unsigned int numBytes; + size_t numBytes; /* verify the inputs */ @@ -1863,10 +1860,10 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage return JNI_FALSE; } - if (stepX > cinfo->image_width) { + if (stepX > (jint)cinfo->image_width) { stepX = cinfo->image_width; } - if (stepY > cinfo->image_height) { + if (stepY > (jint)cinfo->image_height) { stepY = cinfo->image_height; } @@ -2119,7 +2116,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_abortRead jobject this, jlong ptr) { - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); if (data == NULL) { JNU_ThrowByName(env, @@ -2137,7 +2134,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetLibraryState (JNIEnv *env, jobject this, jlong ptr) { - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); j_decompress_ptr cinfo; if (data == NULL) { @@ -2159,7 +2156,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetReader jobject this, jlong ptr) { - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); j_decompress_ptr cinfo; sun_jpeg_error_ptr jerr; @@ -2232,7 +2229,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_disposeReader jclass reader, jlong ptr) { - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); j_common_ptr info = destroyImageioData(env, data); imageio_dispose(info); @@ -2317,8 +2314,8 @@ imageio_term_destination (j_compress_ptr cinfo) JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2); /* find out how much needs to be written */ - jint datacount = sb->bufferLength - dest->free_in_buffer; - + /* this conversion from size_t to jint is safe, because the lenght of the buffer is limited by jint */ + jint datacount = (jint)(sb->bufferLength - dest->free_in_buffer); if (datacount != 0) { RELEASE_ARRAYS(env, data, (const JOCTET *)(dest->next_output_byte)); @@ -2485,7 +2482,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initJPEGImageWriter imageio_dispose((j_common_ptr)cinfo); return 0; } - return (jlong) ret; + return ptr_to_jlong(ret); } JNIEXPORT void JNICALL @@ -2495,7 +2492,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_setDest jlong ptr, jobject destination) { - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); j_compress_ptr cinfo; if (data == NULL) { @@ -2526,7 +2523,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeTables struct jpeg_destination_mgr *dest; sun_jpeg_error_ptr jerr; - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); j_compress_ptr cinfo; if (data == NULL) { @@ -2625,10 +2622,11 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage jint *scanData; jint *bandSize; int maxBandValue, halfMaxBandValue; - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); j_compress_ptr cinfo; UINT8** scale = NULL; + /* verify the inputs */ if (data == NULL) { @@ -2740,6 +2738,16 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage buffer); JNU_ThrowByName(env, "javax/imageio/IIOException", buffer); } + + if (scale != NULL) { + for (i = 0; i < numBands; i++) { + if (scale[i] != NULL) { + free(scale[i]); + } + } + free(scale); + } + free(scanLinePtr); return data->abortFlag; } @@ -2953,7 +2961,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_abortWrite jobject this, jlong ptr) { - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); if (data == NULL) { JNU_ThrowByName(env, @@ -2970,7 +2978,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_resetWriter (JNIEnv *env, jobject this, jlong ptr) { - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); j_compress_ptr cinfo; if (data == NULL) { @@ -3002,7 +3010,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_disposeWriter jclass writer, jlong ptr) { - imageIODataPtr data = (imageIODataPtr) ptr; + imageIODataPtr data = (imageIODataPtr)jlong_to_ptr(ptr); j_common_ptr info = destroyImageioData(env, data); imageio_dispose(info); diff --git a/jdk/src/share/native/sun/awt/image/jpeg/jdmarker.c b/jdk/src/share/native/sun/awt/image/jpeg/jdmarker.c index e52661f6645..eeb9b64fd1e 100644 --- a/jdk/src/share/native/sun/awt/image/jpeg/jdmarker.c +++ b/jdk/src/share/native/sun/awt/image/jpeg/jdmarker.c @@ -1325,14 +1325,14 @@ jpeg_save_markers (j_decompress_ptr cinfo, int marker_code, unsigned int length_limit) { my_marker_ptr marker = (my_marker_ptr) cinfo->marker; - long maxlength; + size_t maxlength; jpeg_marker_parser_method processor; /* Length limit mustn't be larger than what we can allocate * (should only be a concern in a 16-bit environment). */ maxlength = cinfo->mem->max_alloc_chunk - SIZEOF(struct jpeg_marker_struct); - if (((long) length_limit) > maxlength) + if (length_limit > maxlength) length_limit = (unsigned int) maxlength; /* Choose processor routine to use. diff --git a/jdk/src/share/native/sun/awt/image/jpeg/jmemmgr.c b/jdk/src/share/native/sun/awt/image/jpeg/jmemmgr.c index 778a1f186f7..5ee681333c1 100644 --- a/jdk/src/share/native/sun/awt/image/jpeg/jmemmgr.c +++ b/jdk/src/share/native/sun/awt/image/jpeg/jmemmgr.c @@ -133,7 +133,7 @@ typedef struct { jvirt_barray_ptr virt_barray_list; /* This counts total space obtained from jpeg_get_small/large */ - long total_space_allocated; + size_t total_space_allocated; /* alloc_sarray and alloc_barray set this value for use by virtual * array routines. @@ -588,8 +588,8 @@ realize_virt_arrays (j_common_ptr cinfo) /* Allocate the in-memory buffers for any unrealized virtual arrays */ { my_mem_ptr mem = (my_mem_ptr) cinfo->mem; - long space_per_minheight, maximum_space, avail_mem; - long minheights, max_minheights; + size_t space_per_minheight, maximum_space, avail_mem; + size_t minheights, max_minheights; jvirt_sarray_ptr sptr; jvirt_barray_ptr bptr; @@ -1032,7 +1032,7 @@ GLOBAL(void) jinit_memory_mgr (j_common_ptr cinfo) { my_mem_ptr mem; - long max_to_use; + size_t max_to_use; int pool; size_t test_mac; @@ -1109,8 +1109,10 @@ jinit_memory_mgr (j_common_ptr cinfo) if ((memenv = getenv("JPEGMEM")) != NULL) { char ch = 'x'; + unsigned int mem_max = 0u; - if (sscanf(memenv, "%ld%c", &max_to_use, &ch) > 0) { + if (sscanf(memenv, "%u%c", &mem_max, &ch) > 0) { + max_to_use = (size_t)mem_max; if (ch == 'm' || ch == 'M') max_to_use *= 1000L; mem->pub.max_memory_to_use = max_to_use * 1000L; diff --git a/jdk/src/share/native/sun/awt/image/jpeg/jmemnobs.c b/jdk/src/share/native/sun/awt/image/jpeg/jmemnobs.c index bf4936d02d1..884c5a16830 100644 --- a/jdk/src/share/native/sun/awt/image/jpeg/jmemnobs.c +++ b/jdk/src/share/native/sun/awt/image/jpeg/jmemnobs.c @@ -73,9 +73,9 @@ jpeg_free_large (j_common_ptr cinfo, void FAR * object, size_t sizeofobject) * Here we always say, "we got all you want bud!" */ -GLOBAL(long) -jpeg_mem_available (j_common_ptr cinfo, long min_bytes_needed, - long max_bytes_needed, long already_allocated) +GLOBAL(size_t) +jpeg_mem_available (j_common_ptr cinfo, size_t min_bytes_needed, + size_t max_bytes_needed, size_t already_allocated) { return max_bytes_needed; } @@ -100,7 +100,7 @@ jpeg_open_backing_store (j_common_ptr cinfo, backing_store_ptr info, * cleanup required. Here, there isn't any. */ -GLOBAL(long) +GLOBAL(size_t) jpeg_mem_init (j_common_ptr cinfo) { return 0; /* just set max_memory_to_use to 0 */ diff --git a/jdk/src/share/native/sun/awt/image/jpeg/jmemsys.h b/jdk/src/share/native/sun/awt/image/jpeg/jmemsys.h index b427da0f352..c5c64b31886 100644 --- a/jdk/src/share/native/sun/awt/image/jpeg/jmemsys.h +++ b/jdk/src/share/native/sun/awt/image/jpeg/jmemsys.h @@ -104,10 +104,10 @@ EXTERN(void) jpeg_free_large JPP((j_common_ptr cinfo, void FAR * object, * Conversely, zero may be returned to always use the minimum amount of memory. */ -EXTERN(long) jpeg_mem_available JPP((j_common_ptr cinfo, - long min_bytes_needed, - long max_bytes_needed, - long already_allocated)); +EXTERN(size_t) jpeg_mem_available JPP((j_common_ptr cinfo, + size_t min_bytes_needed, + size_t max_bytes_needed, + size_t already_allocated)); /* @@ -198,5 +198,5 @@ EXTERN(void) jpeg_open_backing_store JPP((j_common_ptr cinfo, * all opened backing-store objects have been closed. */ -EXTERN(long) jpeg_mem_init JPP((j_common_ptr cinfo)); +EXTERN(size_t) jpeg_mem_init JPP((j_common_ptr cinfo)); EXTERN(void) jpeg_mem_term JPP((j_common_ptr cinfo)); diff --git a/jdk/src/share/native/sun/awt/image/jpeg/jpegdecoder.c b/jdk/src/share/native/sun/awt/image/jpeg/jpegdecoder.c index d896231b5f4..2b0992b5151 100644 --- a/jdk/src/share/native/sun/awt/image/jpeg/jpegdecoder.c +++ b/jdk/src/share/native/sun/awt/image/jpeg/jpegdecoder.c @@ -328,7 +328,7 @@ sun_jpeg_fill_suspended_buffer(j_decompress_ptr cinfo) if ((*env)->ExceptionOccurred(env) || !GET_ARRAYS(env, src)) { cinfo->err->error_exit((struct jpeg_common_struct *) cinfo); } - if (ret <= src->remaining_skip) { + if (ret < 0 || (unsigned int)ret <= src->remaining_skip) { return; } if (src->remaining_skip) { @@ -397,7 +397,7 @@ sun_jpeg_skip_input_data(j_decompress_ptr cinfo, long num_bytes) } num_bytes += src->remaining_skip; src->remaining_skip = 0; - ret = src->pub.bytes_in_buffer; + ret = (int)src->pub.bytes_in_buffer; /* this conversion is safe, because capacity of the buffer is limited by jnit */ if (ret >= num_bytes) { src->pub.next_input_byte += num_bytes; src->pub.bytes_in_buffer -= num_bytes; diff --git a/jdk/src/share/native/sun/awt/image/jpeg/jpeglib.h b/jdk/src/share/native/sun/awt/image/jpeg/jpeglib.h index 49c67e28935..d3821f36158 100644 --- a/jdk/src/share/native/sun/awt/image/jpeg/jpeglib.h +++ b/jdk/src/share/native/sun/awt/image/jpeg/jpeglib.h @@ -800,10 +800,10 @@ struct jpeg_memory_mgr { * used for virtual-array buffers.) May be changed by outer application * after creating the JPEG object. */ - long max_memory_to_use; + size_t max_memory_to_use; /* Maximum allocation request accepted by alloc_large. */ - long max_alloc_chunk; + size_t max_alloc_chunk; }; From 32b46da6e32151fa0e7ce85ba9fdc6732e08880e Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Thu, 10 Feb 2011 13:03:22 +0100 Subject: [PATCH 033/105] 7017824: Add support for creating 64-bit Visual Studio projects Updated create.bat and ProjectCreator Reviewed-by: brutisso, stefank, ohair --- hotspot/make/windows/create.bat | 23 +-- hotspot/make/windows/makefiles/compile.make | 5 +- .../windows/makefiles/projectcreator.make | 19 +- hotspot/make/windows/makefiles/rules.make | 4 +- hotspot/make/windows/platform_amd64 | 15 -- hotspot/make/windows/platform_i486 | 15 -- hotspot/make/windows/platform_ia64 | 12 -- .../make/windows/projectfiles/common/Makefile | 9 +- .../windows_x86/vm/unwind_windows_x86.hpp | 4 +- .../tools/ProjectCreator/BuildConfig.java | 57 +++--- .../tools/ProjectCreator/DirectoryTree.java | 10 +- .../ProjectCreator/FileFormatException.java | 4 +- .../src/share/tools/ProjectCreator/Macro.java | 28 --- .../ProjectCreator/MacroDefinitions.java | 154 ---------------- .../src/share/tools/ProjectCreator/Util.java | 15 +- .../ProjectCreator/WinGammaPlatform.java | 52 +++--- .../ProjectCreator/WinGammaPlatformVC6.java | 14 +- .../ProjectCreator/WinGammaPlatformVC7.java | 171 +++++++++++++----- hotspot/src/share/vm/adlc/adlc.hpp | 7 +- hotspot/src/share/vm/oops/methodOop.cpp | 2 +- hotspot/src/share/vm/oops/methodOop.hpp | 4 +- 21 files changed, 237 insertions(+), 387 deletions(-) delete mode 100644 hotspot/make/windows/platform_amd64 delete mode 100644 hotspot/make/windows/platform_i486 delete mode 100644 hotspot/make/windows/platform_ia64 delete mode 100644 hotspot/src/share/tools/ProjectCreator/Macro.java delete mode 100644 hotspot/src/share/tools/ProjectCreator/MacroDefinitions.java diff --git a/hotspot/make/windows/create.bat b/hotspot/make/windows/create.bat index 4592d8becfe..8d9c83aefab 100644 --- a/hotspot/make/windows/create.bat +++ b/hotspot/make/windows/create.bat @@ -1,6 +1,6 @@ @echo off REM -REM Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. +REM Copyright (c) 1999, 2011, 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 @@ -50,9 +50,7 @@ goto end :testit -cl 2>&1 | grep "IA-64" >NUL -if %errorlevel% == 0 goto isia64 -cl 2>&1 | grep "AMD64" >NUL +cl 2>&1 | grep "x64" >NUL if %errorlevel% == 0 goto amd64 set ARCH=x86 set BUILDARCH=i486 @@ -64,12 +62,6 @@ set ARCH=x86 set BUILDARCH=amd64 set Platform_arch=x86 set Platform_arch_model=x86_64 -goto done -:isia64 -set ARCH=ia64 -set BUILDARCH=ia64 -set Platform_arch=ia64 -set Platform_arch_model=ia64 :done setlocal @@ -81,7 +73,7 @@ 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 +set HotSpotBuildSpace=%HotSpotBuildRoot%\vs-%BUILDARCH% set HotSpotJDKDist=%1 @@ -89,9 +81,9 @@ REM figure out MSC version for /F %%i in ('sh %HotSpotWorkSpace%/make/windows/get_msc_ver.sh') do set %%i echo ************************************************************** -set ProjectFile=jvm.vcproj +set ProjectFile=%HotSpotBuildSpace%\jvm.vcproj if "%MSC_VER%" == "1200" ( -set ProjectFile=jvm.dsp +set ProjectFile=%HotSpotBuildSpace%\jvm.dsp echo Will generate VC6 project {unsupported} ) else ( if "%MSC_VER%" == "1400" ( @@ -163,7 +155,7 @@ copy %HotSpotWorkSpace%\make\windows\projectfiles\%%i\* %HotSpotBuildSpace%\%%i\ ) REM force regneration of ProjectFile -if exist %HotSpotBuildSpace%\%ProjectFile% del %HotSpotBuildSpace%\%ProjectFile% +if exist %ProjectFile% del %ProjectFile% for /D %%i in (compiler1, compiler2, tiered, core, kernel) do ( echo -- %%i -- @@ -182,6 +174,7 @@ echo ARCH=%ARCH% >> %HotSpotBuildSpace%\%%i\local.m echo BUILDARCH=%BUILDARCH% >> %HotSpotBuildSpace%\%%i\local.make echo Platform_arch=%Platform_arch% >> %HotSpotBuildSpace%\%%i\local.make echo Platform_arch_model=%Platform_arch_model% >> %HotSpotBuildSpace%\%%i\local.make +echo MSC_VER=%MSC_VER% >> %HotSpotBuildSpace%\%%i\local.make for /D %%j in (debug, fastdebug, product) do ( if NOT EXIST %HotSpotBuildSpace%\%%i\%%j mkdir %HotSpotBuildSpace%\%%i\%%j @@ -196,7 +189,7 @@ popd pushd %HotSpotBuildRoot% REM It doesn't matter which variant we use here, "compiler1" 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%\compiler1\local.make %HotSpotBuildRoot%/%ProjectFile% +nmake /nologo /F %HotSpotWorkSpace%/make/windows/projectfiles/common/Makefile LOCAL_MAKE=%HotSpotBuildSpace%\compiler1\local.make %ProjectFile% popd diff --git a/hotspot/make/windows/makefiles/compile.make b/hotspot/make/windows/makefiles/compile.make index 47d924418b2..d70bb5217fb 100644 --- a/hotspot/make/windows/makefiles/compile.make +++ b/hotspot/make/windows/makefiles/compile.make @@ -1,5 +1,5 @@ # -# Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1997, 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 @@ -141,9 +141,6 @@ COMPILER_NAME=VS2010 !endif !endif -# Add what version of the compiler we think this is to the compile line -CPP_FLAGS=$(CPP_FLAGS) /D "MSC_VER=$(MSC_VER)" - # 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 diff --git a/hotspot/make/windows/makefiles/projectcreator.make b/hotspot/make/windows/makefiles/projectcreator.make index 1dc307f9545..e7a9528c605 100644 --- a/hotspot/make/windows/makefiles/projectcreator.make +++ b/hotspot/make/windows/makefiles/projectcreator.make @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 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 @@ -36,8 +36,6 @@ ProjectCreatorSources=\ $(WorkSpace)\src\share\tools\ProjectCreator\DirectoryTree.java \ $(WorkSpace)\src\share\tools\ProjectCreator\DirectoryTreeNode.java \ $(WorkSpace)\src\share\tools\ProjectCreator\FileFormatException.java \ - $(WorkSpace)\src\share\tools\ProjectCreator\Macro.java \ - $(WorkSpace)\src\share\tools\ProjectCreator\MacroDefinitions.java \ $(WorkSpace)\src\share\tools\ProjectCreator\ProjectCreator.java \ $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatform.java \ $(WorkSpace)\src\share\tools\ProjectCreator\WinGammaPlatformVC6.java \ @@ -50,6 +48,10 @@ ProjectCreatorSources=\ # This is only used internally ProjectCreatorIncludesPRIVATE=\ + -relativeInclude src\closed\share\vm \ + -relativeInclude src\closed\os\windows\vm \ + -relativeInclude src\closed\os_cpu\windows_$(Platform_arch)\vm \ + -relativeInclude src\closed\cpu\$(Platform_arch)\vm \ -relativeInclude src\share\vm \ -relativeInclude src\share\vm\prims \ -relativeInclude src\os\windows\vm \ @@ -84,7 +86,7 @@ ProjectCreatorIDEOptions=\ -buildBase $(HOTSPOTBUILDSPACE)\%f\%b \ -startAt src \ -compiler $(VcVersion) \ - -projectFileName $(HOTSPOTBUILDROOT)\$(ProjectFile) \ + -projectFileName $(HOTSPOTBUILDSPACE)\$(ProjectFile) \ -jdkTargetRoot $(HOTSPOTJDKDIST) \ -define ALIGN_STACK_FRAMES \ -define VM_LITTLE_ENDIAN \ @@ -106,13 +108,20 @@ ProjectCreatorIDEOptions=\ # Add in build-specific options !if "$(BUILDARCH)" == "i486" ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ + -platformName Win32 \ -define IA32 \ -ignorePath x86_64 \ -define TARGET_ARCH_MODEL_x86_32 !else +!if "$(BUILDARCH)" == "amd64" ProjectCreatorIDEOptions=$(ProjectCreatorIDEOptions) \ + -platformName x64 \ + -define AMD64 \ + -define _LP64 \ -ignorePath x86_32 \ - -define TARGET_ARCH_MODEL_x86_64 + -define TARGET_ARCH_MODEL_x86_64 \ + -define TARGET_OS_ARCH_MODEL_windows_x86_64 +!endif !endif ProjectCreatorIDEOptionsIgnoreCompiler1=\ diff --git a/hotspot/make/windows/makefiles/rules.make b/hotspot/make/windows/makefiles/rules.make index 431ff3ecb85..4d884c1b71d 100644 --- a/hotspot/make/windows/makefiles/rules.make +++ b/hotspot/make/windows/makefiles/rules.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. +# 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 @@ -53,7 +53,7 @@ ProjectFile=jvm.vcproj !if "$(MSC_VER)" == "1200" VcVersion=VC6 -ProjectFile=vm.dsp +ProjectFile=jvm.dsp !elseif "$(MSC_VER)" == "1400" diff --git a/hotspot/make/windows/platform_amd64 b/hotspot/make/windows/platform_amd64 deleted file mode 100644 index 49a326e5690..00000000000 --- a/hotspot/make/windows/platform_amd64 +++ /dev/null @@ -1,15 +0,0 @@ -// Platform file for win32 NT platform - -os_family = windows - -arch = x86 - -arch_model = x86_64 - -os_arch = windows_x86 - -os_arch_model = windows_x86_64 - -lib_arch = amd64 - -compiler = visCPP diff --git a/hotspot/make/windows/platform_i486 b/hotspot/make/windows/platform_i486 deleted file mode 100644 index bdb31681038..00000000000 --- a/hotspot/make/windows/platform_i486 +++ /dev/null @@ -1,15 +0,0 @@ -// Platform file for windows platform - -os_family = windows - -arch = x86 - -arch_model = x86_32 - -os_arch = windows_x86 - -os_arch_model = windows_x86_32 - -lib_arch = i386 - -compiler = visCPP diff --git a/hotspot/make/windows/platform_ia64 b/hotspot/make/windows/platform_ia64 deleted file mode 100644 index ca269b499fd..00000000000 --- a/hotspot/make/windows/platform_ia64 +++ /dev/null @@ -1,12 +0,0 @@ -// Platform file for Itanium Windows platform $Revision: 1.0 $ - -os_family = win32 - -arch = ia64 - -os_arch = win32_ia64 - -compiler = visCPP - -gnu_dis_arch = ia64 - diff --git a/hotspot/make/windows/projectfiles/common/Makefile b/hotspot/make/windows/projectfiles/common/Makefile index 8d55b9097f9..3e7d159ac38 100644 --- a/hotspot/make/windows/projectfiles/common/Makefile +++ b/hotspot/make/windows/projectfiles/common/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 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 @@ -54,8 +54,6 @@ BootStrapDir=$(HOTSPOTJDKDIST) JvmtiOutDir=$(HOTSPOTBUILDSPACE)\$(Variant)\generated\jvmtifiles !include $(HOTSPOTWORKSPACE)/make/windows/makefiles/jvmti.make -Platform=$(HOTSPOTWORKSPACE)/make/windows/platform_$(BUILDARCH) - !if "$(Variant)" == "compiler2" # Pick up rules for building adlc !include $(HOTSPOTWORKSPACE)/make/windows/makefiles/adlc.make @@ -105,17 +103,16 @@ HOTSPOT_VM_DISTRO="OpenJDK" !endif ProjectCreatorIDEOptions = $(ProjectCreatorIDEOptions) \ - -platform $(Platform) \ -define HOTSPOT_RELEASE_VERSION=\\\"$(HOTSPOT_RELEASE_VERSION)\\\" \ -define JRE_RELEASE_VERSION=\\\"$(JRE_RELEASE_VERSION)\\\" \ -define HOTSPOT_VM_DISTRO=\\\"$(HOTSPOT_VM_DISTRO)\\\" -$(HOTSPOTBUILDROOT)/$(ProjectFile): $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class +$(HOTSPOTBUILDSPACE)/$(ProjectFile): $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class @$(RUN_JAVA) -Djava.class.path=$(HOTSPOTBUILDSPACE)/classes ProjectCreator WinGammaPlatform$(VcVersion) $(ProjectCreatorIDEOptions) clean: @rm -rf $(HOTSPOTBUILDSPACE)/classes - @rm -r ../$(ProjectFile) + @rm -r $(HOTSPOTBUILDSPACE)/$(ProjectFile) $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class: $(ProjectCreatorSources) @if exist $(HOTSPOTBUILDSPACE)\classes rmdir /s /q $(HOTSPOTBUILDSPACE)\classes diff --git a/hotspot/src/os_cpu/windows_x86/vm/unwind_windows_x86.hpp b/hotspot/src/os_cpu/windows_x86/vm/unwind_windows_x86.hpp index 6762bf2308a..00b9b6c305d 100644 --- a/hotspot/src/os_cpu/windows_x86/vm/unwind_windows_x86.hpp +++ b/hotspot/src/os_cpu/windows_x86/vm/unwind_windows_x86.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -71,7 +71,7 @@ typedef struct _DISPATCHER_CONTEXT { PVOID HandlerData; } DISPATCHER_CONTEXT, *PDISPATCHER_CONTEXT; -#if MSC_VER < 1500 +#if _MSC_VER < 1500 /* Not needed for VS2008 compiler, comes from winnt.h. */ typedef EXCEPTION_DISPOSITION (*PEXCEPTION_ROUTINE) ( diff --git a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java b/hotspot/src/share/tools/ProjectCreator/BuildConfig.java index 6e97b28f1e6..82d7279c6ef 100644 --- a/hotspot/src/share/tools/ProjectCreator/BuildConfig.java +++ b/hotspot/src/share/tools/ProjectCreator/BuildConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -51,12 +51,14 @@ class BuildConfig { if (vars == null) vars = new Hashtable(); String flavourBuild = flavour + "_" + build; + String platformName = getFieldString(null, "PlatformName"); System.out.println(); System.out.println(flavourBuild); - put("Name", getCI().makeCfgName(flavourBuild)); + put("Name", getCI().makeCfgName(flavourBuild, platformName)); put("Flavour", flavour); put("Build", build); + put("PlatformName", platformName); // ones mentioned above were needed to expand format String buildBase = expandFormat(getFieldString(null, "BuildBase")); @@ -93,7 +95,7 @@ class BuildConfig { protected void initDefaultLinkerFlags() { Vector linkerFlags = new Vector(); - linkerFlags.addAll(getCI().getBaseLinkerFlags( get("OutputDir"), get("OutputDll"))); + linkerFlags.addAll(getCI().getBaseLinkerFlags( get("OutputDir"), get("OutputDll"), get("PlatformName"))); put("LinkerFlags", linkerFlags); } @@ -115,18 +117,15 @@ class BuildConfig { } - Vector getPreferredPaths(MacroDefinitions macros) { + Vector getPreferredPaths() { Vector preferredPaths = new Vector(); + // In the case of multiple files with the same name in - // different subdirectories, prefer the versions specified in - // the platform file as the "os_family" and "arch" macros. - for (Iterator iter = macros.getMacros(); iter.hasNext(); ) { - Macro macro = (Macro) iter.next(); - if (macro.name.equals("os_family") || - macro.name.equals("arch")) { - preferredPaths.add(macro.contents); - } - } + // different subdirectories, prefer these versions + preferredPaths.add("windows"); + preferredPaths.add("x86"); + preferredPaths.add("closed"); + // Also prefer "opto" over "adlc" for adlcVMDeps.hpp preferredPaths.add("opto"); @@ -137,18 +136,7 @@ class BuildConfig { void handleDB() { WinGammaPlatform platform = (WinGammaPlatform)getField(null, "PlatformObject"); - File incls = new File(get("OutputDir")+Util.sep+"incls"); - - incls.mkdirs(); - - MacroDefinitions macros = new MacroDefinitions(); - try { - macros.readFrom(getFieldString(null, "Platform"), false); - } catch (Exception e) { - throw new RuntimeException(e); - } - - putSpecificField("AllFilesHash", computeAllFiles(platform, macros)); + putSpecificField("AllFilesHash", computeAllFiles(platform)); } @@ -190,10 +178,10 @@ class BuildConfig { ht.put(expandFormat(key), expandFormat(value)); } - Hashtable computeAllFiles(WinGammaPlatform platform, MacroDefinitions macros) { + Hashtable computeAllFiles(WinGammaPlatform platform) { Hashtable rv = new Hashtable(); DirectoryTree tree = getSourceTree(get("SourceBase"), getFieldString(null, "StartAt")); - Vector preferredPaths = getPreferredPaths(macros); + Vector preferredPaths = getPreferredPaths(); // Hold errors until end Vector filesNotFound = new Vector(); @@ -228,8 +216,7 @@ class BuildConfig { System.err.println("Error: some files were not found or " + "appeared in multiple subdirectories of " + "directory " + get("SourceBase") + " and could not " + - "be resolved with the os_family and arch " + - "macros in the platform file."); + "be resolved with os_family and arch."); if (filesNotFound.size() != 0) { System.err.println("Files not found:"); for (Iterator iter = filesNotFound.iterator(); @@ -254,10 +241,14 @@ class BuildConfig { Vector sysDefines = new Vector(); sysDefines.add("WIN32"); sysDefines.add("_WINDOWS"); - sysDefines.add("HOTSPOT_BUILD_USER="+System.getProperty("user.name")); + sysDefines.add("HOTSPOT_BUILD_USER=\\\""+System.getProperty("user.name")+"\\\""); sysDefines.add("HOTSPOT_BUILD_TARGET=\\\""+get("Build")+"\\\""); sysDefines.add("_JNI_IMPLEMENTATION_"); - sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i386\\\""); + if (vars.get("PlatformName").equals("Win32")) { + sysDefines.add("HOTSPOT_LIB_ARCH=\\\"i386\\\""); + } else { + sysDefines.add("HOTSPOT_LIB_ARCH=\\\"amd64\\\""); + } sysDefines.addAll(defines); @@ -710,7 +701,7 @@ class KernelProductConfig extends ProductConfig { } abstract class CompilerInterface { abstract Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir); - abstract Vector getBaseLinkerFlags(String outDir, String outDll); + abstract Vector getBaseLinkerFlags(String outDir, String outDll, String platformName); abstract Vector getDebugCompilerFlags(String opt); abstract Vector getDebugLinkerFlags(); abstract void getAdditionalNonKernelLinkerFlags(Vector rv); @@ -718,7 +709,7 @@ abstract class CompilerInterface { abstract Vector getProductLinkerFlags(); abstract String getOptFlag(); abstract String getNoOptFlag(); - abstract String makeCfgName(String flavourBuild); + abstract String makeCfgName(String flavourBuild, String platformName); void addAttr(Vector receiver, String attr, String value) { receiver.add(attr); receiver.add(value); diff --git a/hotspot/src/share/tools/ProjectCreator/DirectoryTree.java b/hotspot/src/share/tools/ProjectCreator/DirectoryTree.java index 7bfbc6a8ed8..76a5e4668ae 100644 --- a/hotspot/src/share/tools/ProjectCreator/DirectoryTree.java +++ b/hotspot/src/share/tools/ProjectCreator/DirectoryTree.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -55,6 +55,9 @@ public class DirectoryTree { private Vector nodes = new Vector(); public FileIterator(Node rootNode) { + if(rootNode == null) { + return; + } nodes.add(rootNode); prune(); } @@ -112,10 +115,7 @@ public class DirectoryTree { throws IllegalArgumentException { File root = new File(Util.normalize(baseDirectory)); if (!root.isDirectory()) { - throw new IllegalArgumentException("baseDirectory \"" + - baseDirectory + - "\" does not exist or " + - "is not a directory"); + return; } try { root = root.getCanonicalFile(); diff --git a/hotspot/src/share/tools/ProjectCreator/FileFormatException.java b/hotspot/src/share/tools/ProjectCreator/FileFormatException.java index f16f0b2adca..077886f85dd 100644 --- a/hotspot/src/share/tools/ProjectCreator/FileFormatException.java +++ b/hotspot/src/share/tools/ProjectCreator/FileFormatException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -22,7 +22,9 @@ * */ +@SuppressWarnings("serial") public class FileFormatException extends Exception { + public FileFormatException() { super(); } diff --git a/hotspot/src/share/tools/ProjectCreator/Macro.java b/hotspot/src/share/tools/ProjectCreator/Macro.java deleted file mode 100644 index 43309ab24da..00000000000 --- a/hotspot/src/share/tools/ProjectCreator/Macro.java +++ /dev/null @@ -1,28 +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. - * - */ - -public class Macro { - public String name; - public String contents; -} diff --git a/hotspot/src/share/tools/ProjectCreator/MacroDefinitions.java b/hotspot/src/share/tools/ProjectCreator/MacroDefinitions.java deleted file mode 100644 index 9ed801ac95d..00000000000 --- a/hotspot/src/share/tools/ProjectCreator/MacroDefinitions.java +++ /dev/null @@ -1,154 +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. - * - */ - -import java.io.*; -import java.util.*; - -public class MacroDefinitions { - private Vector macros; - - public MacroDefinitions() { - macros = new Vector(); - } - - public void addMacro(String name, String contents) { - Macro macro = new Macro(); - macro.name = name; - macro.contents = contents; - macros.add(macro); - } - - private boolean lineIsEmpty(String s) { - for (int i = 0; i < s.length(); i++) { - if (!Character.isWhitespace(s.charAt(i))) { - return false; - } - } - return true; - } - - public void readFrom(String fileName, boolean missingOk) - throws FileNotFoundException, FileFormatException, IOException { - BufferedReader reader = null; - try { - reader = new BufferedReader(new FileReader(fileName)); - } catch (FileNotFoundException e) { - if (missingOk) { - return; - } else { - throw(e); - } - } - String line; - do { - line = reader.readLine(); - if (line != null) { - // This had to be rewritten (compare to Database.java) - // because the Solaris platform file has been - // repurposed and now contains "macros" with spaces in - // them. - - if ((!line.startsWith("//")) && - (!lineIsEmpty(line))) { - int nameBegin = -1; - int nameEnd = -1; - boolean gotEquals = false; - int contentsBegin = -1; - int contentsEnd = -1; - - int i = 0; - // Scan forward for beginning of name - while (i < line.length()) { - if (!Character.isWhitespace(line.charAt(i))) { - break; - } - i++; - } - nameBegin = i; - - // Scan forward for end of name - while (i < line.length()) { - if (Character.isWhitespace(line.charAt(i))) { - break; - } - i++; - } - nameEnd = i; - - // Scan forward for equals sign - while (i < line.length()) { - if (line.charAt(i) == '=') { - gotEquals = true; - break; - } - i++; - } - - // Scan forward for start of contents - i++; - while (i < line.length()) { - if (!Character.isWhitespace(line.charAt(i))) { - break; - } - i++; - } - contentsBegin = i; - - // Scan *backward* for end of contents - i = line.length() - 1; - while (i >= 0) { - if (!Character.isWhitespace(line.charAt(i))) { - break; - } - } - contentsEnd = i+1; - - // Now do consistency check - if (!((nameBegin < nameEnd) && - (nameEnd < contentsBegin) && - (contentsBegin < contentsEnd) && - (gotEquals == true))) { - throw new FileFormatException( - "Expected \"macroname = value\", " + - "but found: " + line - ); - } - - String name = line.substring(nameBegin, nameEnd); - String contents = line.substring(contentsBegin, - contentsEnd); - addMacro(name, contents); - } - } - } while (line != null); - reader.close(); - } - - /** This returns an Iterator of Macros. You should not mutate the - returned Macro objects or use the Iterator to remove - macros. */ - public Iterator getMacros() { - return macros.iterator(); - } -} diff --git a/hotspot/src/share/tools/ProjectCreator/Util.java b/hotspot/src/share/tools/ProjectCreator/Util.java index e44b4f09c34..18b2f57b7b8 100644 --- a/hotspot/src/share/tools/ProjectCreator/Util.java +++ b/hotspot/src/share/tools/ProjectCreator/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -47,7 +47,7 @@ public class Util { return sb.toString(); } - static String join(String padder, String v[]) { + static String join(String padder, String v[]) { StringBuffer sb = new StringBuffer(); for (int i=0; i 2) { + if (file.charAt(1) == ':' && file.charAt(2) == '/') { + // convert drive letter to uppercase + String drive = file.substring(0, 1).toUpperCase(); + return drive + file.substring(1); + } + } + return file; } static String sep = File.separator; - static String os = "Win32"; //System.getProperty("os.name"); } diff --git a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java index a2416f50be7..9d206f57b72 100644 --- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java +++ b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -235,13 +235,6 @@ public abstract class WinGammaPlatform { (locationsInTree.size() == 0)) { filesNotFound.add(fileName); } else if (locationsInTree.size() > 1) { - // We shouldn't have duplicate file names in our workspace. - System.err.println(); - System.err.println("There are multiple files named as: " + fileName); - System.exit(-1); - // The following code could be safely removed if we don't need duplicate - // file names. - // Iterate through them, trying to find one with a // preferred path search: @@ -336,7 +329,7 @@ public abstract class WinGammaPlatform { String projectName = getProjectName(projectFileName, ext); - writeProjectFile(projectFileName, projectName, createAllConfigs()); + writeProjectFile(projectFileName, projectName, createAllConfigs(BuildConfig.getFieldString(null, "PlatformName"))); } protected void writePrologue(String[] args) { @@ -376,7 +369,13 @@ public abstract class WinGammaPlatform { HsArgHandler.STRING ), - new HsArgRule("-projectFileName", + new HsArgRule("-platformName", + "PlatformName", + null, + HsArgHandler.STRING + ), + + new HsArgRule("-projectFileName", "ProjectFileName", null, HsArgHandler.STRING @@ -394,12 +393,6 @@ public abstract class WinGammaPlatform { HsArgHandler.STRING ), - new HsArgRule("-platform", - "Platform", - null, - HsArgHandler.STRING - ), - new HsArgRule("-absoluteInclude", "AbsoluteInclude", null, @@ -590,28 +583,27 @@ public abstract class WinGammaPlatform { BuildConfig.putField(null, "PlatformObject", this); } - Vector createAllConfigs() { + Vector createAllConfigs(String platform) { Vector allConfigs = new Vector(); allConfigs.add(new C1DebugConfig()); - boolean b = true; - if (b) { - allConfigs.add(new C1FastDebugConfig()); - allConfigs.add(new C1ProductConfig()); + allConfigs.add(new C1FastDebugConfig()); + allConfigs.add(new C1ProductConfig()); - allConfigs.add(new C2DebugConfig()); - allConfigs.add(new C2FastDebugConfig()); - allConfigs.add(new C2ProductConfig()); + allConfigs.add(new C2DebugConfig()); + allConfigs.add(new C2FastDebugConfig()); + allConfigs.add(new C2ProductConfig()); - allConfigs.add(new TieredDebugConfig()); - allConfigs.add(new TieredFastDebugConfig()); - allConfigs.add(new TieredProductConfig()); + allConfigs.add(new TieredDebugConfig()); + allConfigs.add(new TieredFastDebugConfig()); + allConfigs.add(new TieredProductConfig()); - allConfigs.add(new CoreDebugConfig()); - allConfigs.add(new CoreFastDebugConfig()); - allConfigs.add(new CoreProductConfig()); + allConfigs.add(new CoreDebugConfig()); + allConfigs.add(new CoreFastDebugConfig()); + allConfigs.add(new CoreProductConfig()); + if (platform.equals("Win32")) { allConfigs.add(new KernelDebugConfig()); allConfigs.add(new KernelFastDebugConfig()); allConfigs.add(new KernelProductConfig()); diff --git a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC6.java b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC6.java index 6e59d78673b..f29abc051e4 100644 --- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC6.java +++ b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -223,7 +223,7 @@ class CompilerInterfaceVC6 extends CompilerInterface { return rv; } - Vector getBaseLinkerFlags(String outDir, String outDll) { + Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) { Vector rv = new Vector(); rv.add("PROP Ignore_Export_Lib 0"); @@ -231,8 +231,12 @@ class CompilerInterfaceVC6 extends CompilerInterface { rv.add("ADD CPP /MD"); rv.add("ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib " + " advapi32.lib shell32.lib ole32.lib oleaut32.lib winmm.lib"); + String machine = "/machine:I386"; + if (platformName.equals("x64")) { + machine = "/machine:X64"; + } rv.add("ADD LINK32 /out:\""+outDll+"\" "+ - " /nologo /subsystem:windows /machine:I386" + + " /nologo /subsystem:windows /machine:" + machine + " /nologo /base:\"0x8000000\" /subsystem:windows /dll" + " /export:JNI_GetDefaultJavaVMInitArgs /export:JNI_CreateJavaVM /export:JNI_GetCreatedJavaVMs "+ " /export:jio_snprintf /export:jio_printf /export:jio_fprintf /export:jio_vfprintf "+ @@ -287,7 +291,7 @@ class CompilerInterfaceVC6 extends CompilerInterface { return "d"; } - String makeCfgName(String flavourBuild) { - return "vm - "+ Util.os + " " + flavourBuild; + String makeCfgName(String flavourBuild, String platform) { + return "vm - "+ platform + " " + flavourBuild; } } diff --git a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java index dad8ed6d108..fd6fbfea83e 100644 --- a/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java +++ b/hotspot/src/share/tools/ProjectCreator/WinGammaPlatformVC7.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -37,7 +37,7 @@ public class WinGammaPlatformVC7 extends WinGammaPlatform { public void writeProjectFile(String projectFileName, String projectName, Vector allConfigs) throws IOException { System.out.println(); - System.out.println(" Writing .vcproj file..."); + System.out.println(" Writing .vcproj file: "+projectFileName); // If we got this far without an error, we're safe to actually // write the .vcproj file printWriter = new PrintWriter(new FileWriter(projectFileName)); @@ -54,9 +54,8 @@ public class WinGammaPlatformVC7 extends WinGammaPlatform { "SccLocalPath", "" } ); - startTag("Platforms", null); - tag("Platform", new String[] {"Name", Util.os}); + tag("Platform", new String[] {"Name", (String) BuildConfig.getField(null, "PlatformName")}); endTag("Platforms"); startTag("Configurations", null); @@ -81,12 +80,47 @@ public class WinGammaPlatformVC7 extends WinGammaPlatform { abstract class NameFilter { - protected String fname; + protected String fname; abstract boolean match(FileInfo fi); String filterString() { return ""; } String name() { return this.fname;} + + @Override + // eclipse auto-generated + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + getOuterType().hashCode(); + result = prime * result + ((fname == null) ? 0 : fname.hashCode()); + return result; + } + + @Override + // eclipse auto-generated + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + NameFilter other = (NameFilter) obj; + if (!getOuterType().equals(other.getOuterType())) + return false; + if (fname == null) { + if (other.fname != null) + return false; + } else if (!fname.equals(other.fname)) + return false; + return true; + } + + // eclipse auto-generated + private WinGammaPlatformVC7 getOuterType() { + return WinGammaPlatformVC7.this; + } } class DirectoryFilter extends NameFilter { @@ -109,9 +143,50 @@ public class WinGammaPlatformVC7 extends WinGammaPlatform { boolean match(FileInfo fi) { - int lastSlashIndex = fi.full.lastIndexOf('/'); - String fullDir = fi.full.substring(0, lastSlashIndex); - return fullDir.endsWith(dir); + int lastSlashIndex = fi.full.lastIndexOf('/'); + String fullDir = fi.full.substring(0, lastSlashIndex); + return fullDir.endsWith(dir); + } + + @Override + // eclipse auto-generated + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + getOuterType().hashCode(); + result = prime * result + baseLen; + result = prime * result + ((dir == null) ? 0 : dir.hashCode()); + result = prime * result + dirLen; + return result; + } + + @Override + // eclipse auto-generated + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + DirectoryFilter other = (DirectoryFilter) obj; + if (!getOuterType().equals(other.getOuterType())) + return false; + if (baseLen != other.baseLen) + return false; + if (dir == null) { + if (other.dir != null) + return false; + } else if (!dir.equals(other.dir)) + return false; + if (dirLen != other.dirLen) + return false; + return true; + } + + // eclipse auto-generated + private WinGammaPlatformVC7 getOuterType() { + return WinGammaPlatformVC7.this; } } @@ -232,32 +307,39 @@ public class WinGammaPlatformVC7 extends WinGammaPlatform { DirectoryFilter container = null; for(FileInfo fileInfo : files) { - if (!fileInfo.full.startsWith(sbase)) { - continue; - } + if (!fileInfo.full.startsWith(sbase)) { + continue; + } - int lastSlash = fileInfo.full.lastIndexOf('/'); - String dir = fileInfo.full.substring(sbase.length(), lastSlash); - if(dir.equals("share/vm")) { - // skip files directly in share/vm - should only be precompiled.hpp which is handled below - continue; - } - if (!dir.equals(currentDir)) { - currentDir = dir; - if (container != null) { - rv.add(container); - } + int lastSlash = fileInfo.full.lastIndexOf('/'); + String dir = fileInfo.full.substring(sbase.length(), lastSlash); + if(dir.equals("share/vm")) { + // skip files directly in share/vm - should only be precompiled.hpp which is handled below + continue; + } + if (!dir.equals(currentDir)) { + currentDir = dir; + if (container != null && !rv.contains(container)) { + rv.add(container); + } - // remove "share/vm/" from names - String name = dir; - if (dir.startsWith("share/vm/")) { - name = dir.substring("share/vm/".length(), dir.length()); - } - container = new DirectoryFilter(name, dir, sbase); - } + // remove "share/vm/" from names + String name = dir; + if (dir.startsWith("share/vm/")) { + name = dir.substring("share/vm/".length(), dir.length()); + } + DirectoryFilter newfilter = new DirectoryFilter(name, dir, sbase); + int i = rv.indexOf(newfilter); + if(i == -1) { + container = newfilter; + } else { + // if the filter already exists, reuse it + container = (DirectoryFilter) rv.get(i); + } + } } - if (container != null) { - rv.add(container); + if (container != null && !rv.contains(container)) { + rv.add(container); } ContainerFilter generated = new ContainerFilter("Generated"); @@ -583,7 +665,7 @@ class CompilerInterfaceVC7 extends CompilerInterface { return rv; } - Vector getBaseLinkerFlags(String outDir, String outDll) { + Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) { Vector rv = new Vector(); addAttr(rv, "Name", "VCLinkerTool"); @@ -610,8 +692,13 @@ class CompilerInterfaceVC7 extends CompilerInterface { addAttr(rv, "SubSystem", "2"); addAttr(rv, "BaseAddress", "0x8000000"); addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib"); - // Set /MACHINE option. 1 is machineX86 - addAttr(rv, "TargetMachine", "1"); + if(platformName.equals("Win32")) { + // Set /MACHINE option. 1 is X86 + addAttr(rv, "TargetMachine", "1"); + } else { + // Set /MACHINE option. 17 is X64 + addAttr(rv, "TargetMachine", "17"); + } return rv; } @@ -656,12 +743,6 @@ class CompilerInterfaceVC7 extends CompilerInterface { addAttr(rv, "Optimization", "2"); // Set /Oy- option addAttr(rv, "OmitFramePointers", "FALSE"); - } - - Vector getProductCompilerFlags() { - Vector rv = new Vector(); - - getProductCompilerFlags_common(rv); // Set /Ob option. 1 is expandOnlyInline addAttr(rv, "InlineFunctionExpansion", "1"); // Set /GF option. @@ -670,6 +751,12 @@ class CompilerInterfaceVC7 extends CompilerInterface { addAttr(rv, "RuntimeLibrary", "2"); // Set /Gy option addAttr(rv, "EnableFunctionLevelLinking", "TRUE"); + } + + Vector getProductCompilerFlags() { + Vector rv = new Vector(); + + getProductCompilerFlags_common(rv); return rv; } @@ -693,7 +780,7 @@ class CompilerInterfaceVC7 extends CompilerInterface { return "0"; } - String makeCfgName(String flavourBuild) { - return flavourBuild + "|" + Util.os; + String makeCfgName(String flavourBuild, String platform) { + return flavourBuild + "|" + platform; } } diff --git a/hotspot/src/share/vm/adlc/adlc.hpp b/hotspot/src/share/vm/adlc/adlc.hpp index 3e00570f1e8..0ed4b77ed2f 100644 --- a/hotspot/src/share/vm/adlc/adlc.hpp +++ b/hotspot/src/share/vm/adlc/adlc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -42,11 +42,6 @@ using namespace std; #endif -// make sure the MSC_VER and _MSC_VER settings make sense -#if _MSC_VER != MSC_VER && (_MSC_VER != 1400 || MSC_VER != 1399) -#error "Something is wrong with the detection of MSC_VER in the makefiles" -#endif - #if _MSC_VER >= 1400 #define strdup _strdup #endif diff --git a/hotspot/src/share/vm/oops/methodOop.cpp b/hotspot/src/share/vm/oops/methodOop.cpp index 42ffbec7f1a..a196d080672 100644 --- a/hotspot/src/share/vm/oops/methodOop.cpp +++ b/hotspot/src/share/vm/oops/methodOop.cpp @@ -1372,7 +1372,7 @@ void CompressedLineNumberWriteStream::write_pair_regular(int bci_delta, int line } // See comment in methodOop.hpp which explains why this exists. -#if defined(_M_AMD64) && MSC_VER >= 1400 +#if defined(_M_AMD64) && _MSC_VER >= 1400 #pragma optimize("", off) void CompressedLineNumberWriteStream::write_pair(int bci, int line) { write_pair_inline(bci, line); diff --git a/hotspot/src/share/vm/oops/methodOop.hpp b/hotspot/src/share/vm/oops/methodOop.hpp index 279424514d1..2cce5309aa8 100644 --- a/hotspot/src/share/vm/oops/methodOop.hpp +++ b/hotspot/src/share/vm/oops/methodOop.hpp @@ -732,8 +732,8 @@ class CompressedLineNumberWriteStream: public CompressedWriteStream { // Disabling optimization doesn't work for methods in header files // so we force it to call through the non-optimized version in the .cpp. // It's gross, but it's the only way we can ensure that all callers are -// fixed. MSC_VER is defined in build/windows/makefiles/compile.make. -#if defined(_M_AMD64) && MSC_VER >= 1400 +// fixed. _MSC_VER is defined by the windows compiler +#if defined(_M_AMD64) && _MSC_VER >= 1400 void write_pair(int bci, int line); #else void write_pair(int bci, int line) { write_pair_inline(bci, line); } From 17088aceaaaa0f6fd50a13cad86fda762d870757 Mon Sep 17 00:00:00 2001 From: Alexander Potochkin Date: Thu, 10 Feb 2011 21:36:18 +0300 Subject: [PATCH 034/105] 6993171: JavaTest/JDK7b114 - no help text is shown for interview questions, JavaTest HANGS UP Reviewed-by: rupashka --- .../share/classes/javax/swing/JComponent.java | 24 ++- jdk/src/share/classes/javax/swing/JLayer.java | 36 ++-- .../classes/javax/swing/RepaintManager.java | 11 -- .../classes/javax/swing/SwingUtilities.java | 11 ++ .../classes/javax/swing/plaf/LayerUI.java | 22 ++- .../swing/JComponent/6989617/bug6989617.java | 163 +++++++++++------- 6 files changed, 162 insertions(+), 105 deletions(-) diff --git a/jdk/src/share/classes/javax/swing/JComponent.java b/jdk/src/share/classes/javax/swing/JComponent.java index 9ef57bacadd..ef235a26a26 100644 --- a/jdk/src/share/classes/javax/swing/JComponent.java +++ b/jdk/src/share/classes/javax/swing/JComponent.java @@ -4910,14 +4910,17 @@ public abstract class JComponent extends Container implements Serializable, * Returns {@code true} if a paint triggered on a child component should cause * painting to originate from this Component, or one of its ancestors. *

- * Calling {@link JComponent#repaint} on a Swing component will be delegated to - * the first ancestor which {@code isPaintingOrigin()} returns {@true}, - * if there are any. + * Calling {@link #repaint} or {@link #paintImmediately(int, int, int, int)} + * on a Swing component will result in calling + * the {@link JComponent#paintImmediately(int, int, int, int)} method of + * the first ancestor which {@code isPaintingOrigin()} returns {@true}, if there are any. *

- * {@code JComponent} subclasses that need to be repainted when any of their + * {@code JComponent} subclasses that need to be painted when any of their * children are repainted should override this method to return {@code true}. * * @return always returns {@code false} + * + * @see #paintImmediately(int, int, int, int) */ protected boolean isPaintingOrigin() { return false; @@ -4932,12 +4935,16 @@ public abstract class JComponent extends Container implements Serializable, * and can collapse redundant requests into a single paint call. * This method is useful if one needs to update the display while * the current event is being dispatched. + *

+ * This method is to be overridden when the dirty region needs to be changed + * for components that are painting origins. * * @param x the x value of the region to be painted * @param y the y value of the region to be painted * @param w the width of the region to be painted * @param h the height of the region to be painted * @see #repaint + * @see #isPaintingOrigin() */ public void paintImmediately(int x,int y,int w, int h) { Component c = this; @@ -4946,6 +4953,15 @@ public abstract class JComponent extends Container implements Serializable, if(!isShowing()) { return; } + + JComponent paintingOigin = SwingUtilities.getPaintingOrigin(this); + if (paintingOigin != null) { + Rectangle rectangle = SwingUtilities.convertRectangle( + c, new Rectangle(x, y, w, h), paintingOigin); + paintingOigin.paintImmediately(rectangle.x, rectangle.y, rectangle.width, rectangle.height); + return; + } + while(!c.isOpaque()) { parent = c.getParent(); if(parent != null) { diff --git a/jdk/src/share/classes/javax/swing/JLayer.java b/jdk/src/share/classes/javax/swing/JLayer.java index 764e553fd61..592fe82e24c 100644 --- a/jdk/src/share/classes/javax/swing/JLayer.java +++ b/jdk/src/share/classes/javax/swing/JLayer.java @@ -156,8 +156,9 @@ public final class JLayer // when layerUI is serializable private LayerUI layerUI; private JPanel glassPane; - private boolean isPainting; private long eventMask; + private transient boolean isPainting; + private transient boolean isPaintingImmediately; private static final LayerEventController eventController = new LayerEventController(); @@ -393,17 +394,25 @@ public final class JLayer } /** - * Delegates repainting to {@link javax.swing.plaf.LayerUI#repaint} method. + * Delegates its functionality to the + * {@link javax.swing.plaf.LayerUI#paintImmediately(int, int, int, int, JLayer)} method, + * if {@code LayerUI} is set. * - * @param tm this parameter is not used - * @param x the x value of the dirty region - * @param y the y value of the dirty region - * @param width the width of the dirty region - * @param height the height of the dirty region + * @param x the x value of the region to be painted + * @param y the y value of the region to be painted + * @param w the width of the region to be painted + * @param h the height of the region to be painted */ - public void repaint(long tm, int x, int y, int width, int height) { - if (getUI() != null) { - getUI().repaint(tm, x, y, width, height, this); + public void paintImmediately(int x, int y, int w, int h) { + if (!isPaintingImmediately && getUI() != null) { + isPaintingImmediately = true; + try { + getUI().paintImmediately(x, y, w, h, this); + } finally { + isPaintingImmediately = false; + } + } else { + super.paintImmediately(x, y, w, h); } } @@ -415,8 +424,11 @@ public final class JLayer public void paint(Graphics g) { if (!isPainting) { isPainting = true; - super.paintComponent(g); - isPainting = false; + try { + super.paintComponent(g); + } finally { + isPainting = false; + } } else { super.paint(g); } diff --git a/jdk/src/share/classes/javax/swing/RepaintManager.java b/jdk/src/share/classes/javax/swing/RepaintManager.java index 062d2e70b09..361e863a518 100644 --- a/jdk/src/share/classes/javax/swing/RepaintManager.java +++ b/jdk/src/share/classes/javax/swing/RepaintManager.java @@ -438,7 +438,6 @@ public class RepaintManager * @param y Y coordinate of the region to repaint * @param w Width of the region to repaint * @param h Height of the region to repaint - * @see JComponent#isPaintingOrigin() * @see JComponent#repaint */ public void addDirtyRegion(JComponent c, int x, int y, int w, int h) @@ -448,16 +447,6 @@ public class RepaintManager delegate.addDirtyRegion(c, x, y, w, h); return; } - Container p = c; - while ((p = p.getParent()) instanceof JComponent) { - JComponent jp = (JComponent) p; - if (jp.isPaintingOrigin()) { - Rectangle rectangle = SwingUtilities.convertRectangle( - c, new Rectangle(x, y, w, h), jp); - jp.repaint(0, rectangle.x, rectangle.y, rectangle.width, rectangle.height); - return; - } - } addDirtyRegion0(c, x, y, w, h); } diff --git a/jdk/src/share/classes/javax/swing/SwingUtilities.java b/jdk/src/share/classes/javax/swing/SwingUtilities.java index 61dde01e93c..86948132cea 100644 --- a/jdk/src/share/classes/javax/swing/SwingUtilities.java +++ b/jdk/src/share/classes/javax/swing/SwingUtilities.java @@ -1532,6 +1532,17 @@ public class SwingUtilities implements SwingConstants return applet; } + static JComponent getPaintingOrigin(JComponent c) { + Container p = c; + while ((p = p.getParent()) instanceof JComponent) { + JComponent jp = (JComponent) p; + if (jp.isPaintingOrigin()) { + return jp; + } + } + return null; + } + /** * Process the key bindings for the Component associated with * event. This method is only useful if diff --git a/jdk/src/share/classes/javax/swing/plaf/LayerUI.java b/jdk/src/share/classes/javax/swing/plaf/LayerUI.java index 655d9f27177..e118467aa99 100644 --- a/jdk/src/share/classes/javax/swing/plaf/LayerUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/LayerUI.java @@ -703,21 +703,19 @@ public class LayerUI } /** - * Adds the specified region to the dirty region list if the component - * is showing. The component will be repainted after all of the - * currently pending events have been dispatched. + * Paints the specified region in the {@code JLayer} this {@code LayerUI} is set to, immediately. *

* This method is to be overridden when the dirty region needs to be changed. + * The default implementation delegates its functionality to {@link JComponent#paintImmediately(int, int, int, int)}. * - * @param tm this parameter is not used - * @param x the x value of the dirty region - * @param y the y value of the dirty region - * @param width the width of the dirty region - * @param height the height of the dirty region - * @see java.awt.Component#isShowing - * @see RepaintManager#addDirtyRegion + * @param x the x value of the region to be painted + * @param y the y value of the region to be painted + * @param w the width of the region to be painted + * @param h the height of the region to be painted + * + * @see JComponent#paintImmediately(int, int, int, int) */ - public void repaint(long tm, int x, int y, int width, int height, JLayer l) { - RepaintManager.currentManager(l).addDirtyRegion(l, x, y, width, height); + public void paintImmediately(int x, int y, int width, int height, JLayer l) { + l.paintImmediately(x, y, width, height); } } diff --git a/jdk/test/javax/swing/JComponent/6989617/bug6989617.java b/jdk/test/javax/swing/JComponent/6989617/bug6989617.java index 7f7aa958bf6..7c85e255f72 100644 --- a/jdk/test/javax/swing/JComponent/6989617/bug6989617.java +++ b/jdk/test/javax/swing/JComponent/6989617/bug6989617.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -28,76 +28,107 @@ @run main bug6989617 */ +import sun.awt.SunToolkit; + import javax.swing.*; import java.awt.*; public class bug6989617 { - - private boolean isPaintingOrigin; - private boolean innerPanelRepainted, outerPanelRepainted; - - public bug6989617() { - - final JButton button = new JButton("button"); - - JPanel innerPanel = new JPanel() { - protected boolean isPaintingOrigin() { - return isPaintingOrigin; - } - - public void repaint(long tm, int x, int y, int width, int height) { - if (button.getParent() != null) { - innerPanelRepainted = true; - if (!button.getSize().equals(new Dimension(width, height))) { - throw new RuntimeException("Wrong size of the dirty area"); - } - if (!button.getLocation().equals(new Point(x, y))) { - throw new RuntimeException("Wrong location of the dirty area"); - } - } - super.repaint(tm, x, y, width, height); - } - }; - - JPanel outerPanel = new JPanel() { - protected boolean isPaintingOrigin() { - return isPaintingOrigin; - } - - public void repaint(long tm, int x, int y, int width, int height) { - if (button.getParent() != null) { - outerPanelRepainted = true; - if (!button.getSize().equals(new Dimension(width, height))) { - throw new RuntimeException("Wrong size of the dirty area"); - } - } - super.repaint(tm, x, y, width, height); - } - }; - - - outerPanel.add(innerPanel); - innerPanel.add(button); - - outerPanel.setSize(100, 100); - innerPanel.setBounds(10, 10, 50, 50); - button.setBounds(10, 10, 20, 20); - - if (innerPanelRepainted || outerPanelRepainted) { - throw new RuntimeException("Repainted flag is unexpectedly on"); - } - button.repaint(); - if (innerPanelRepainted || outerPanelRepainted) { - throw new RuntimeException("Repainted flag is unexpectedly on"); - } - isPaintingOrigin = true; - button.repaint(); - if (!innerPanelRepainted || !outerPanelRepainted) { - throw new RuntimeException("Repainted flag is unexpectedly off"); - } - } + private static MyPanel panel; + private static JButton button; public static void main(String... args) throws Exception { - new bug6989617(); + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + JFrame frame = new JFrame(); + frame. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + panel = new MyPanel(); + + button = new JButton("Hello"); + panel.add(button); + frame.add(panel); + + frame.setSize(200, 300); + frame.setVisible(true); + } + }); + // Testing the panel as a painting origin, + // the panel.paintImmediately() must be triggered + // when button.repaint() is called + toolkit.realSync(); + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + if (panel.getPaintRectangle() != null) { + throw new RuntimeException("paint rectangle is not null"); + } + button.repaint(); + } + }); + toolkit.realSync(); + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + Rectangle pr = panel.getPaintRectangle(); + if (!pr.getSize().equals(button.getSize())) { + throw new RuntimeException("wrong size of the dirty area"); + } + if (!pr.getLocation().equals(button.getLocation())) { + throw new RuntimeException("wrong location of the dirty area"); + } + } + }); + // Testing the panel as NOT a painting origin + // the panel.paintImmediately() must NOT be triggered + // when button.repaint() is called + toolkit.realSync(); + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + panel.resetPaintRectangle(); + panel.setPaintingOrigin(false); + if (panel.getPaintRectangle() != null) { + throw new RuntimeException("paint rectangle is not null"); + } + button.repaint(); + } + }); + toolkit.realSync(); + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + if(panel.getPaintRectangle() != null) { + throw new RuntimeException("paint rectangle is not null"); + } + System.out.println("Test passed..."); + } + }); + } + + static class MyPanel extends JPanel { + private boolean isPaintingOrigin = true; + private Rectangle paintRectangle; + + { + setLayout(new GridBagLayout()); + } + + public boolean isPaintingOrigin() { + return isPaintingOrigin; + } + + public void setPaintingOrigin(boolean paintingOrigin) { + isPaintingOrigin = paintingOrigin; + } + + public void paintImmediately(int x, int y, int w, int h) { + super.paintImmediately(x, y, w, h); + paintRectangle = new Rectangle(x, y, w, h); + } + + public Rectangle getPaintRectangle() { + return paintRectangle == null? null: new Rectangle(paintRectangle); + } + + public void resetPaintRectangle() { + this.paintRectangle = null; + } } } From 1406a86c7d0b5956488485d3b1f283392db7dc61 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 10 Feb 2011 14:24:26 -0800 Subject: [PATCH 035/105] 7018098: CacheFSInfo persists too long Reviewed-by: mcimadamore --- .../com/sun/tools/javac/file/CacheFSInfo.java | 9 +- .../JavacProcessingEnvironment.java | 5 + langtools/test/tools/javac/file/T7018098.java | 121 ++++++++++++++++++ 3 files changed, 129 insertions(+), 6 deletions(-) create mode 100644 langtools/test/tools/javac/file/T7018098.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/file/CacheFSInfo.java b/langtools/src/share/classes/com/sun/tools/javac/file/CacheFSInfo.java index 03fe8a28234..1e034aa7fc8 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/file/CacheFSInfo.java +++ b/langtools/src/share/classes/com/sun/tools/javac/file/CacheFSInfo.java @@ -49,16 +49,13 @@ public class CacheFSInfo extends FSInfo { public static void preRegister(final Context context) { context.put(FSInfo.class, new Context.Factory() { public FSInfo make() { - if (singleton == null) - singleton = new CacheFSInfo(); - context.put(FSInfo.class, singleton); - return singleton; + FSInfo instance = new CacheFSInfo(); + context.put(FSInfo.class, instance); + return instance; } }); } - static CacheFSInfo singleton; - public void clearCache() { cache.clear(); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java index a5617e3f737..207e12909c6 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java +++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java @@ -55,6 +55,7 @@ import com.sun.tools.javac.api.JavacTaskImpl; import com.sun.tools.javac.api.JavacTrees; import com.sun.tools.javac.code.*; import com.sun.tools.javac.code.Symbol.*; +import com.sun.tools.javac.file.FSInfo; import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.jvm.*; import com.sun.tools.javac.main.JavaCompiler; @@ -1069,6 +1070,10 @@ public class JavacProcessingEnvironment implements ProcessingEnvironment, Closea if (tl != null) next.put(TaskListener.class, tl); + FSInfo fsInfo = context.get(FSInfo.class); + if (fsInfo != null) + next.put(FSInfo.class, fsInfo); + JavaFileManager jfm = context.get(JavaFileManager.class); Assert.checkNonNull(jfm); next.put(JavaFileManager.class, jfm); diff --git a/langtools/test/tools/javac/file/T7018098.java b/langtools/test/tools/javac/file/T7018098.java new file mode 100644 index 00000000000..bc8009c5e65 --- /dev/null +++ b/langtools/test/tools/javac/file/T7018098.java @@ -0,0 +1,121 @@ +/* + * 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. + */ + +/** + * @test + * @bug 7018098 + * @summary CacheFSInfo persists too long + * @library ../lib + * @build JavacTestingAbstractProcessor T7018098 + * @run main T7018098 + */ + +import java.io.*; +import java.util.*; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedOptions; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic; + +import com.sun.tools.javac.file.FSInfo; +import com.sun.tools.javac.processing.JavacProcessingEnvironment; +import com.sun.tools.javac.util.Context; + +@SupportedOptions("expect") +public class T7018098 extends JavacTestingAbstractProcessor { + public static void main(String... args) throws Exception { + new T7018098().run(); + } + + static File testDir = new File("T7018098.dir"); + + void run() throws Exception { + String myName = T7018098.class.getSimpleName(); + File testSrc = new File(System.getProperty("test.src")); + File file = new File(testSrc, myName + ".java"); + + _assert(!testDir.exists()); + + compile( + "-proc:only", + "-processor", myName, + "-Aexpect=false", + file.getPath()); + + testDir.mkdirs(); + _assert(testDir.exists()); + + compile( + "-proc:only", + "-processor", myName, + "-Aexpect=true", + file.getPath()); + } + + void _assert(boolean cond) { + if (!cond) + throw new AssertionError(); + } + + void compile(String... args) throws Exception { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + int rc = com.sun.tools.javac.Main.compile(args, pw); + pw.close(); + String out = sw.toString(); + if (!out.isEmpty()) + System.err.println(out); + if (rc != 0) + throw new Exception("compilation failed unexpectedly: rc=" + rc); + } + + //--------------- + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + Context context = ((JavacProcessingEnvironment) processingEnv).getContext(); + FSInfo fsInfo = context.get(FSInfo.class); + + round++; + if (round == 1) { + boolean expect = Boolean.valueOf(options.get("expect")); + checkEqual("cache result", fsInfo.isDirectory(testDir), expect); + initialFSInfo = fsInfo; + } else { + checkEqual("fsInfo", fsInfo, initialFSInfo); + } + + return true; + } + + void checkEqual(String label, T actual, T expected) { + if (actual != expected) + messager.printMessage(Diagnostic.Kind.ERROR, + "Unexpected value for " + label + + "; expected: " + expected + + "; found: " + actual); + } + + int round = 0; + FSInfo initialFSInfo; +} From 5ca7f854cf1f494f1446b27373ad7a3c419f33c3 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 10 Feb 2011 14:27:34 -0800 Subject: [PATCH 036/105] 7018452: langtools not buildable on Mac Reviewed-by: ohair --- langtools/make/build.xml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/langtools/make/build.xml b/langtools/make/build.xml index e2cc6547ef4..d093d24f1de 100644 --- a/langtools/make/build.xml +++ b/langtools/make/build.xml @@ -868,8 +868,10 @@ executable="${boot.java.home}/bin/javac" srcdir="${make.tools.dir}/GenStubs" destdir="${build.toolclasses.dir}/" - classpath="${build.bootstrap.dir}/classes:${ant.core.lib}" - includeantruntime="false"/> + classpath="${ant.core.lib}" + includeantruntime="false"> + + From 2c35cde75045fd9d8436e01a4141ff3f3e5208c1 Mon Sep 17 00:00:00 2001 From: "Y. Srinivas Ramakrishna" Date: Thu, 10 Feb 2011 14:48:07 -0800 Subject: [PATCH 037/105] 7018302: newly added assert related to size of constantPoolOop causes secondary assertions or crashes 6912621 used a raw oop in the newly added assert following an allocation attempt that could result in a GC. Reviewed-by: jmasa --- .../src/share/vm/oops/constantPoolKlass.cpp | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/hotspot/src/share/vm/oops/constantPoolKlass.cpp b/hotspot/src/share/vm/oops/constantPoolKlass.cpp index 3b097d9634d..ad1d7329551 100644 --- a/hotspot/src/share/vm/oops/constantPoolKlass.cpp +++ b/hotspot/src/share/vm/oops/constantPoolKlass.cpp @@ -55,32 +55,35 @@ constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS) { int size = constantPoolOopDesc::object_size(length); KlassHandle klass (THREAD, as_klassOop()); - constantPoolOop c = - (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL); + assert(klass()->is_oop(), "Can't be null, else handlizing of c below won't work"); + constantPoolHandle pool; + { + constantPoolOop c = + (constantPoolOop)CollectedHeap::permanent_obj_allocate(klass, size, CHECK_NULL); + assert(c->klass_or_null() != NULL, "Handlizing below won't work"); + pool = constantPoolHandle(THREAD, c); + } - c->set_length(length); - c->set_tags(NULL); - c->set_cache(NULL); - c->set_operands(NULL); - c->set_pool_holder(NULL); - c->set_flags(0); + pool->set_length(length); + pool->set_tags(NULL); + pool->set_cache(NULL); + pool->set_operands(NULL); + pool->set_pool_holder(NULL); + pool->set_flags(0); // only set to non-zero if constant pool is merged by RedefineClasses - c->set_orig_length(0); + pool->set_orig_length(0); // if constant pool may change during RedefineClasses, it is created // unsafe for GC concurrent processing. - c->set_is_conc_safe(is_conc_safe); + pool->set_is_conc_safe(is_conc_safe); // all fields are initialized; needed for GC // Note: because we may be in this "conc_unsafe" state when allocating // t_oop below, which may in turn cause a GC, it is imperative that our // size be correct, consistent and henceforth stable, at this stage. - assert(c->is_parsable(), "Else size() below is unreliable"); - DEBUG_ONLY(int sz = c->size();) + assert(pool->is_oop() && pool->is_parsable(), "Else size() below is unreliable"); + assert(size == pool->size(), "size() is wrong"); // initialize tag array - // Note: cannot introduce constant pool handle before since it is not - // completely initialized (no class) -> would cause assertion failure - constantPoolHandle pool (THREAD, c); typeArrayOop t_oop = oopFactory::new_permanent_byteArray(length, CHECK_NULL); typeArrayHandle tags (THREAD, t_oop); for (int index = 0; index < length; index++) { @@ -89,7 +92,7 @@ constantPoolOop constantPoolKlass::allocate(int length, bool is_conc_safe, TRAPS pool->set_tags(tags()); // Check that our size was stable at its old value. - assert(sz == c->size(), "size() changed"); + assert(size == pool->size(), "size() changed"); return pool(); } From caf02570752b121c774ee6abd01c6fcfc81c93c5 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 10 Feb 2011 15:05:33 -0800 Subject: [PATCH 038/105] 6485027: javac incorrectly handles relative paths in manifest classpath Reviewed-by: mcimadamore --- .../com/sun/tools/javac/file/Paths.java | 14 ++- .../test/tools/javac/Paths/Class-Path.sh | 8 +- .../test/tools/javac/Paths/Class-Path2.sh | 111 ++++++++++++++++++ .../test/tools/javac/Paths/Diagnostics.sh | 8 +- 4 files changed, 129 insertions(+), 12 deletions(-) create mode 100644 langtools/test/tools/javac/Paths/Class-Path2.sh diff --git a/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java b/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java index 7cb36003289..3e0ec5abd15 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java +++ b/langtools/src/share/classes/com/sun/tools/javac/file/Paths.java @@ -247,10 +247,16 @@ public class Paths { public Path() { super(); } public Path addDirectories(String dirs, boolean warn) { - if (dirs != null) - for (File dir : getPathEntries(dirs)) - addDirectory(dir, warn); - return this; + boolean prev = expandJarClassPaths; + expandJarClassPaths = true; + try { + if (dirs != null) + for (File dir : getPathEntries(dirs)) + addDirectory(dir, warn); + return this; + } finally { + expandJarClassPaths = prev; + } } public Path addDirectories(String dirs) { diff --git a/langtools/test/tools/javac/Paths/Class-Path.sh b/langtools/test/tools/javac/Paths/Class-Path.sh index e52184ff519..7cdb4a71ea9 100644 --- a/langtools/test/tools/javac/Paths/Class-Path.sh +++ b/langtools/test/tools/javac/Paths/Class-Path.sh @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved. +# 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 @@ -24,7 +24,7 @@ # -# @test @(#)Class-Path.sh 1.3 03/10/31 +# @test # @bug 4212732 # @summary Test handling of the Class-Path attribute in jar file manifests # @author Martin Buchholz @@ -184,8 +184,8 @@ Success "$jar" umf MANIFEST.MF "Hello.jar" # Success "$jar" cfe "Hello.jar" "Hello" Bye.class -# Jar creation and update when there is no manifest and inputfiles -specified +# Jar creation and update when there is no manifest and inputfiles +# specified Failure "$jar" cvf "A.jar" Failure "$jar" uvf "A.jar" diff --git a/langtools/test/tools/javac/Paths/Class-Path2.sh b/langtools/test/tools/javac/Paths/Class-Path2.sh new file mode 100644 index 00000000000..180ba7c7f77 --- /dev/null +++ b/langtools/test/tools/javac/Paths/Class-Path2.sh @@ -0,0 +1,111 @@ +#!/bin/sh +# +# 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. +# + +# @test +# @bug 4212732 6485027 +# @summary Test handling of the Class-Path attribute in jar file manifests +# @author Martin Buchholz +# +# @run shell Class-Path2.sh + +# To run this test manually, simply do ./Class-Path2.sh + +. ${TESTSRC-.}/Util.sh + +set -u + +Cleanup() { + Sys rm -rf pkg Main.java Main.class Main.jar jars + Sys rm -rf MANIFEST.MF A.jar B.zip +} + +Cleanup +Sys mkdir pkg + +#---------------------------------------------------------------- +# Create mutually referential jar files +#---------------------------------------------------------------- +cat >pkg/A.java <pkg/B.java <Main.java < Date: Fri, 11 Feb 2011 10:38:10 +0530 Subject: [PATCH 039/105] 6604827: JavaDoc for ScriptEngineFactory.getMethodCallSyntax contains an error Reviewed-by: mchung --- jdk/src/share/classes/javax/script/ScriptEngineFactory.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/javax/script/ScriptEngineFactory.java b/jdk/src/share/classes/javax/script/ScriptEngineFactory.java index 9fc08a92bbd..46b56ef66fc 100644 --- a/jdk/src/share/classes/javax/script/ScriptEngineFactory.java +++ b/jdk/src/share/classes/javax/script/ScriptEngineFactory.java @@ -152,12 +152,11 @@ public interface ScriptEngineFactory { * ret += "." + m + "("; * for (int i = 0; i < args.length; i++) { * ret += args[i]; - * if (i == args.length - 1) { - * ret += ")"; - * } else { + * if (i < args.length - 1) { * ret += ","; * } * } + * ret += ")"; * return ret; * } * From 311bd2a9a98e80f77c1c08ed703325130fbc0fda Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Fri, 11 Feb 2011 14:15:16 +0100 Subject: [PATCH 040/105] 7018257: jmm_DumpThreads allocates into permgen Don't allocate in permgen Reviewed-by: ysr, sla --- hotspot/src/share/vm/memory/oopFactory.cpp | 15 ++++++++++++--- hotspot/src/share/vm/memory/oopFactory.hpp | 1 + hotspot/src/share/vm/services/management.cpp | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/memory/oopFactory.cpp b/hotspot/src/share/vm/memory/oopFactory.cpp index c8b45b68a04..7ef11b15f08 100644 --- a/hotspot/src/share/vm/memory/oopFactory.cpp +++ b/hotspot/src/share/vm/memory/oopFactory.cpp @@ -92,12 +92,21 @@ objArrayOop oopFactory::new_objArray(klassOop klass, int length, TRAPS) { } } -objArrayOop oopFactory::new_system_objArray(int length, TRAPS) { +objArrayOop oopFactory::new_system_objArray(int length, bool in_perm_gen, TRAPS) { int size = objArrayOopDesc::object_size(length); KlassHandle klass (THREAD, Universe::systemObjArrayKlassObj()); - objArrayOop o = (objArrayOop) - Universe::heap()->permanent_array_allocate(klass, size, length, CHECK_NULL); + oop o; + if (in_perm_gen) { + o = Universe::heap()->permanent_array_allocate(klass, size, length, CHECK_NULL); + } else { + o = Universe::heap()->array_allocate(klass, size, length, CHECK_NULL); + } // initialization not needed, allocated cleared + return (objArrayOop) o; +} + +objArrayOop oopFactory::new_system_objArray(int length, TRAPS) { + objArrayOop o = oopFactory::new_system_objArray(length, true, CHECK_NULL); return o; } diff --git a/hotspot/src/share/vm/memory/oopFactory.hpp b/hotspot/src/share/vm/memory/oopFactory.hpp index 49b89bc3b17..a2b34de8cda 100644 --- a/hotspot/src/share/vm/memory/oopFactory.hpp +++ b/hotspot/src/share/vm/memory/oopFactory.hpp @@ -102,6 +102,7 @@ public: // System object arrays static objArrayOop new_system_objArray(int length, TRAPS); + static objArrayOop new_system_objArray(int length, bool in_perm_gen, TRAPS); // Regular object arrays static objArrayOop new_objArray(klassOop klass, int length, TRAPS); diff --git a/hotspot/src/share/vm/services/management.cpp b/hotspot/src/share/vm/services/management.cpp index c0a2f401e32..7f01072138d 100644 --- a/hotspot/src/share/vm/services/management.cpp +++ b/hotspot/src/share/vm/services/management.cpp @@ -1310,7 +1310,7 @@ JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboo if (locked_monitors) { // Constructs Object[] and int[] to contain the object monitor and the stack depth // where the thread locked it - objArrayOop array = oopFactory::new_system_objArray(num_locked_monitors, CHECK_NULL); + objArrayOop array = oopFactory::new_system_objArray(num_locked_monitors, false, CHECK_NULL); objArrayHandle mh(THREAD, array); monitors_array = mh; @@ -1352,7 +1352,7 @@ JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboo GrowableArray* locks = (tcl != NULL ? tcl->owned_locks() : NULL); int num_locked_synchronizers = (locks != NULL ? locks->length() : 0); - objArrayOop array = oopFactory::new_system_objArray(num_locked_synchronizers, CHECK_NULL); + objArrayOop array = oopFactory::new_system_objArray(num_locked_synchronizers, false, CHECK_NULL); objArrayHandle sh(THREAD, array); synchronizers_array = sh; From 8a19e99f74be008dad6caca4b52dc0cc39fe39c2 Mon Sep 17 00:00:00 2001 From: Clemens Eisserer Date: Fri, 11 Feb 2011 10:40:24 -0800 Subject: [PATCH 041/105] 7018364: XShmGetImage with image's > drawable's size causes BadMatch Reviewed-by: art, anthony --- .../native/sun/java2d/x11/X11SurfaceData.c | 52 ++++++++++++++----- .../native/sun/java2d/x11/X11SurfaceData.h | 10 +++- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c index 7b1d717008f..1a715ca1369 100644 --- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c +++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.c @@ -595,15 +595,16 @@ XImage* X11SD_CreateSharedImage(X11SDOps *xsdo, } XImage* X11SD_GetSharedImage(X11SDOps *xsdo, jint width, jint height, - jboolean readBits) + jint maxWidth, jint maxHeight, jboolean readBits) { XImage * retImage = NULL; if (cachedXImage != NULL && - X11SD_CachedXImageFits(width, height, xsdo->depth, readBits)) { - /* sync so previous data gets flushed */ - XSync(awt_display, False); - retImage = cachedXImage; - cachedXImage = (XImage *)NULL; + X11SD_CachedXImageFits(width, height, maxWidth, maxHeight, + xsdo->depth, readBits)) { + /* sync so previous data gets flushed */ + XSync(awt_display, False); + retImage = cachedXImage; + cachedXImage = (XImage *)NULL; } else if (width * height * xsdo->depth > 0x10000) { retImage = X11SD_CreateSharedImage(xsdo, width, height); } @@ -728,8 +729,8 @@ void X11SD_UnPuntPixmap(X11SDOps *xsdo) * it must be close enough to avoid excessive reading from the screen; * otherwise it should just be at least the size requested. */ -jboolean X11SD_CachedXImageFits(jint width, jint height, jint depth, - jboolean readBits) +jboolean X11SD_CachedXImageFits(jint width, jint height, jint maxWidth, + jint maxHeight, jint depth, jboolean readBits) { /* we assume here that the cached image exists */ jint imgWidth = cachedXImage->width; @@ -747,10 +748,14 @@ jboolean X11SD_CachedXImageFits(jint width, jint height, jint depth, return JNI_TRUE; } - if ((imgWidth < width + 64) && (imgHeight < height + 64)) { + if ((imgWidth < width + 64) && (imgHeight < height + 64) + && imgWidth <= maxWidth && imgHeight <= maxHeight) + { /* Cached image's width/height shouldn't be more than 64 pixels * larger than requested, because the region in XShmGetImage * can't be specified and we don't want to read too much. + * Furthermore it has to be smaller than maxWidth/Height + * so drawables are not read out of bounds. */ return JNI_TRUE; } @@ -1295,7 +1300,7 @@ static XImage * X11SD_GetImage(JNIEnv *env, X11SDOps *xsdo, SurfaceDataBounds *bounds, jint lockFlags) { - int x, y, w, h; + int x, y, w, h, maxWidth, maxHeight; int scan; XImage * img = NULL; Drawable drawable; @@ -1311,10 +1316,31 @@ static XImage * X11SD_GetImage(JNIEnv *env, X11SDOps *xsdo, #ifdef MITSHM if (useMitShmExt == CAN_USE_MITSHM) { - if (xsdo->isPixmap && readBits) { - X11SD_PuntPixmap(xsdo, w, h); + if (xsdo->isPixmap) { + if (readBits) { + X11SD_PuntPixmap(xsdo, w, h); + } + maxWidth = xsdo->pmWidth; + maxHeight = xsdo->pmHeight; + } else { + XWindowAttributes winAttr; + if (XGetWindowAttributes(awt_display, + (Window) xsdo->drawable, &winAttr) != 0) { + maxWidth = winAttr.width; + maxHeight = winAttr.height; + } else { + /* XGWA failed which isn't a good thing. Defaulting to using + * x,y means that after the subtraction of these we will use + * w=0, h=0 which is a reasonable default on such a failure. + */ + maxWidth = x; + maxHeight = y; + } } - img = X11SD_GetSharedImage(xsdo, w, h, readBits); + maxWidth -= x; + maxHeight -= y; + + img = X11SD_GetSharedImage(xsdo, w, h, maxWidth, maxHeight, readBits); } #endif /* MITSHM */ drawable = xsdo->drawable; diff --git a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h index 818688e31e7..104d7b1021a 100644 --- a/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h +++ b/jdk/src/solaris/native/sun/java2d/x11/X11SurfaceData.h @@ -125,15 +125,21 @@ struct _X11SDOps { #define X11SD_LOCK_BY_SHMEM 4 /* surface locked by ShMemExt */ #ifdef MITSHM -XImage * X11SD_GetSharedImage (X11SDOps *xsdo, jint width, jint height, jboolean readBits); +XImage * X11SD_GetSharedImage (X11SDOps *xsdo, + jint width, jint height, + jint maxWidth, jint maxHeight, + jboolean readBits); XImage * X11SD_CreateSharedImage (X11SDOps *xsdo, jint width, jint height); Drawable X11SD_CreateSharedPixmap (X11SDOps *xsdo); void X11SD_DropSharedSegment (XShmSegmentInfo *shminfo); void X11SD_PuntPixmap (X11SDOps *xsdo, jint width, jint height); void X11SD_UnPuntPixmap (X11SDOps *xsdo); -jboolean X11SD_CachedXImageFits (jint width, jint height, jint depth, jboolean readBits); +jboolean X11SD_CachedXImageFits (jint width, jint height, + jint maxWidth, jint maxHeight, + jint depth, jboolean readBits); XImage * X11SD_GetCachedXImage (jint width, jint height, jboolean readBits); #endif /* MITSHM */ +jint X11SD_InitWindow(JNIEnv *env, X11SDOps *xsdo); void X11SD_DisposeOrCacheXImage (XImage * image); void X11SD_DisposeXImage(XImage * image); void X11SD_DirectRenderNotify(JNIEnv *env, X11SDOps *xsdo); From 0e639011569c3874372d4d7ffc3af9c59ab03e8a Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Fri, 11 Feb 2011 12:20:45 -0800 Subject: [PATCH 042/105] 7007596: (zipfs) FileSystems.newFileSystem(FileRef...) always employs zipfs regardless the real Path type Updated newFileSystem() to throw UOE exception for non-zip/jar file Reviewed-by: alanb --- .../sun/nio/zipfs/ZipFileSystemProvider.java | 64 +++++++++++++------ jdk/test/demo/zipfs/ZipFSTester.java | 12 ++++ jdk/test/demo/zipfs/basic.sh | 2 +- 3 files changed, 56 insertions(+), 22 deletions(-) diff --git a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java index 60c8fed9291..d8aa305d29b 100644 --- a/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java +++ b/jdk/src/share/demo/nio/zipfs/src/com/sun/nio/zipfs/ZipFileSystemProvider.java @@ -42,6 +42,7 @@ import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.zip.ZipError; import java.util.concurrent.ExecutorService; /* @@ -78,39 +79,60 @@ public class ZipFileSystemProvider extends FileSystemProvider { } } + private boolean ensureFile(Path path) { + try { + BasicFileAttributes attrs = + Files.readAttributes(path, BasicFileAttributes.class); + if (!attrs.isRegularFile()) + throw new UnsupportedOperationException(); + return true; + } catch (IOException ioe) { + return false; + } + } + @Override public FileSystem newFileSystem(URI uri, Map env) throws IOException { - return newFileSystem(uriToPath(uri), env, true); + Path path = uriToPath(uri); + synchronized(filesystems) { + Path realPath = null; + if (ensureFile(path)) { + realPath = path.toRealPath(true); + if (filesystems.containsKey(realPath)) + throw new FileSystemAlreadyExistsException(); + } + ZipFileSystem zipfs = null; + try { + zipfs = new ZipFileSystem(this, path, env); + } catch (ZipError ze) { + String pname = path.toString(); + if (pname.endsWith(".zip") || pname.endsWith(".jar")) + throw ze; + // assume NOT a zip/jar file + throw new UnsupportedOperationException(); + } + filesystems.put(realPath, zipfs); + return zipfs; + } } @Override public FileSystem newFileSystem(Path path, Map env) throws IOException { - if (!path.toUri().getScheme().equalsIgnoreCase("file")) { + if (path.getFileSystem() != FileSystems.getDefault()) { throw new UnsupportedOperationException(); } - return newFileSystem(path, env, false); - } - - private FileSystem newFileSystem(Path path, Map env, boolean checkIfFSExists) - throws IOException - { - synchronized(filesystems) { - Path realPath = null; - if (checkIfFSExists && Files.exists(path)) { - realPath = path.toRealPath(true); - if (filesystems.containsKey(realPath)) - throw new FileSystemAlreadyExistsException(); - } - ZipFileSystem zipfs = new ZipFileSystem(this, path, env); - if (realPath == null) - realPath = path.toRealPath(true); - if (!filesystems.containsKey(realPath)) - filesystems.put(realPath, zipfs); - return zipfs; + ensureFile(path); + try { + return new ZipFileSystem(this, path, env); + } catch (ZipError ze) { + String pname = path.toString(); + if (pname.endsWith(".zip") || pname.endsWith(".jar")) + throw ze; + throw new UnsupportedOperationException(); } } diff --git a/jdk/test/demo/zipfs/ZipFSTester.java b/jdk/test/demo/zipfs/ZipFSTester.java index 14aebbdf685..4969c21f361 100644 --- a/jdk/test/demo/zipfs/ZipFSTester.java +++ b/jdk/test/demo/zipfs/ZipFSTester.java @@ -105,6 +105,18 @@ public class ZipFSTester { os.write(bits); os.close(); + try { + provider.newFileSystem(new File(System.getProperty("test.src", ".")).toPath(), + new HashMap()); + throw new RuntimeException("newFileSystem() opens a directory as zipfs"); + } catch (UnsupportedOperationException uoe) {} + + try { + provider.newFileSystem(src, new HashMap()); + throw new RuntimeException("newFileSystem() opens a non-zip file as zipfs"); + } catch (UnsupportedOperationException uoe) {} + + // copyin Path dst = getPathWithParents(fs, tmpName); Files.copy(src, dst); diff --git a/jdk/test/demo/zipfs/basic.sh b/jdk/test/demo/zipfs/basic.sh index 832a75d4fb4..06353dfa761 100644 --- a/jdk/test/demo/zipfs/basic.sh +++ b/jdk/test/demo/zipfs/basic.sh @@ -21,7 +21,7 @@ # questions. # # @test -# @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 +# @bug 6990846 7009092 7009085 7015391 7014948 7005986 7017840 7007596 # @summary Test ZipFileSystem demo # @build Basic PathOps ZipFSTester # @run shell basic.sh From d43bb4114c7f066b0b65a16a27df4648d1f80116 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Sat, 12 Feb 2011 05:09:36 +0800 Subject: [PATCH 043/105] 6742654: Code insertion/replacement attacks against signed jars 6911041: JCK api/signaturetest tests fails for Mixed Code PIT builds (b91) for all trains 6921823: JarVerifier csdomain field not initialized 6921839: Update trusted.libraries list Reviewed-by: dgu --- jdk/make/java/security/Makefile | 13 +- .../share/classes/java/util/jar/JarFile.java | 195 +++++++- .../classes/java/util/jar/JarVerifier.java | 435 +++++++++++++++++- .../java/util/jar/JavaUtilJarAccessImpl.java | 30 +- jdk/src/share/classes/sun/misc/JarIndex.java | 13 + .../classes/sun/misc/JavaUtilJarAccess.java | 13 +- .../security/util/SignatureFileVerifier.java | 17 +- 7 files changed, 699 insertions(+), 17 deletions(-) diff --git a/jdk/make/java/security/Makefile b/jdk/make/java/security/Makefile index 95c56767fae..1d28b60f2ff 100644 --- a/jdk/make/java/security/Makefile +++ b/jdk/make/java/security/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 1996, 2010 Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1996, 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 @@ -65,6 +65,8 @@ CACERTS_BUILD = $(LIBDIR)/security/cacerts ifndef OPENJDK BLACKLIST_SRC = $(CLOSED_SHARE_SRC)/lib/security/blacklist BLACKLIST_BUILD = $(LIBDIR)/security/blacklist + TRUSTEDLIBS_SRC = $(CLOSED_SHARE_SRC)/lib/security/trusted.libraries + TRUSTEDLIBS_BUILD = $(LIBDIR)/security/trusted.libraries endif FILES_class = $(FILES_java:%.java=$(CLASSBINDIR)/%.class) @@ -77,7 +79,7 @@ include $(BUILDDIR)/common/Rules.gmk ifdef OPENJDK build: properties policy cacerts else -build: properties policy cacerts blacklist +build: properties policy cacerts blacklist trustedlibs endif install: all @@ -90,6 +92,8 @@ cacerts: classes $(CACERTS_BUILD) blacklist: classes $(BLACKLIST_BUILD) +trustedlibs: classes $(TRUSTEDLIBS_BUILD) + $(PROPS_BUILD): $(PROPS_SRC) $(install-file) @@ -102,9 +106,12 @@ $(CACERTS_BUILD): $(CACERTS_SRC) $(BLACKLIST_BUILD): $(BLACKLIST_SRC) $(install-file) +$(TRUSTEDLIBS_BUILD): $(TRUSTEDLIBS_SRC) + $(install-file) + clean clobber:: .delete.classlist $(RM) -r $(CLASSBINDIR)/java/security - $(RM) $(PROPS_BUILD) $(POLICY_BUILD) $(CACERTS_BUILD) $(BLACKLIST_BUILD) + $(RM) $(PROPS_BUILD) $(POLICY_BUILD) $(CACERTS_BUILD) $(BLACKLIST_BUILD) $(TRUSTEDLIBS_BUILD) # Additional Rule for building sun.security.util $(CLASSBINDIR)/%.class: $(SHARE_SRC)/sun/%.java diff --git a/jdk/src/share/classes/java/util/jar/JarFile.java b/jdk/src/share/classes/java/util/jar/JarFile.java index e42d41fb799..a5795c72763 100644 --- a/jdk/src/share/classes/java/util/jar/JarFile.java +++ b/jdk/src/share/classes/java/util/jar/JarFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -27,11 +27,13 @@ package java.util.jar; import java.io.*; import java.lang.ref.SoftReference; +import java.net.URL; import java.util.*; import java.util.zip.*; import java.security.CodeSigner; import java.security.cert.Certificate; import java.security.AccessController; +import java.security.CodeSource; import sun.security.action.GetPropertyAction; import sun.security.util.ManifestEntryVerifier; import sun.misc.SharedSecrets; @@ -262,7 +264,7 @@ class JarFile extends ZipFile { throw new RuntimeException(e); } if (certs == null && jv != null) { - certs = jv.getCerts(getName()); + certs = jv.getCerts(JarFile.this, this); } return certs == null ? null : certs.clone(); } @@ -273,7 +275,7 @@ class JarFile extends ZipFile { throw new RuntimeException(e); } if (signers == null && jv != null) { - signers = jv.getCodeSigners(getName()); + signers = jv.getCodeSigners(JarFile.this, this); } return signers == null ? null : signers.clone(); } @@ -544,4 +546,191 @@ class JarFile extends ZipFile { } return false; } + + private synchronized void ensureInitialization() { + try { + maybeInstantiateVerifier(); + } catch (IOException e) { + throw new RuntimeException(e); + } + if (jv != null && !jvInitialized) { + initializeVerifier(); + jvInitialized = true; + } + } + + JarEntry newEntry(ZipEntry ze) { + return new JarFileEntry(ze); + } + + Enumeration entryNames(CodeSource[] cs) { + ensureInitialization(); + if (jv != null) { + return jv.entryNames(this, cs); + } + + /* + * JAR file has no signed content. Is there a non-signing + * code source? + */ + boolean includeUnsigned = false; + for (int i = 0; i < cs.length; i++) { + if (cs[i].getCodeSigners() == null) { + includeUnsigned = true; + break; + } + } + if (includeUnsigned) { + return unsignedEntryNames(); + } else { + return new Enumeration() { + + public boolean hasMoreElements() { + return false; + } + + public String nextElement() { + throw new NoSuchElementException(); + } + }; + } + } + + /** + * Returns an enumeration of the zip file entries + * excluding internal JAR mechanism entries and including + * signed entries missing from the ZIP directory. + */ + Enumeration entries2() { + ensureInitialization(); + if (jv != null) { + return jv.entries2(this, super.entries()); + } + + // screen out entries which are never signed + final Enumeration enum_ = super.entries(); + return new Enumeration() { + + ZipEntry entry; + + public boolean hasMoreElements() { + if (entry != null) { + return true; + } + while (enum_.hasMoreElements()) { + ZipEntry ze = (ZipEntry) enum_.nextElement(); + if (JarVerifier.isSigningRelated(ze.getName())) { + continue; + } + entry = ze; + return true; + } + return false; + } + + public JarFileEntry nextElement() { + if (hasMoreElements()) { + ZipEntry ze = entry; + entry = null; + return new JarFileEntry(ze); + } + throw new NoSuchElementException(); + } + }; + } + + CodeSource[] getCodeSources(URL url) { + ensureInitialization(); + if (jv != null) { + return jv.getCodeSources(this, url); + } + + /* + * JAR file has no signed content. Is there a non-signing + * code source? + */ + Enumeration unsigned = unsignedEntryNames(); + if (unsigned.hasMoreElements()) { + return new CodeSource[]{JarVerifier.getUnsignedCS(url)}; + } else { + return null; + } + } + + private Enumeration unsignedEntryNames() { + final Enumeration entries = entries(); + return new Enumeration() { + + String name; + + /* + * Grab entries from ZIP directory but screen out + * metadata. + */ + public boolean hasMoreElements() { + if (name != null) { + return true; + } + while (entries.hasMoreElements()) { + String value; + ZipEntry e = (ZipEntry) entries.nextElement(); + value = e.getName(); + if (e.isDirectory() || JarVerifier.isSigningRelated(value)) { + continue; + } + name = value; + return true; + } + return false; + } + + public String nextElement() { + if (hasMoreElements()) { + String value = name; + name = null; + return value; + } + throw new NoSuchElementException(); + } + }; + } + + CodeSource getCodeSource(URL url, String name) { + ensureInitialization(); + if (jv != null) { + if (jv.eagerValidation) { + CodeSource cs = null; + JarEntry je = getJarEntry(name); + if (je != null) { + cs = jv.getCodeSource(url, this, je); + } else { + cs = jv.getCodeSource(url, name); + } + return cs; + } else { + return jv.getCodeSource(url, name); + } + } + + return JarVerifier.getUnsignedCS(url); + } + + void setEagerValidation(boolean eager) { + try { + maybeInstantiateVerifier(); + } catch (IOException e) { + throw new RuntimeException(e); + } + if (jv != null) { + jv.setEagerValidation(eager); + } + } + + List getManifestDigests() { + ensureInitialization(); + if (jv != null) { + return jv.getManifestDigests(); + } + return new ArrayList(); + } } diff --git a/jdk/src/share/classes/java/util/jar/JarVerifier.java b/jdk/src/share/classes/java/util/jar/JarVerifier.java index 33c67c15a6d..abbb85e3768 100644 --- a/jdk/src/share/classes/java/util/jar/JarVerifier.java +++ b/jdk/src/share/classes/java/util/jar/JarVerifier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -26,9 +26,11 @@ package java.util.jar; import java.io.*; +import java.net.URL; import java.util.*; import java.security.*; import java.security.cert.CertificateException; +import java.util.zip.ZipEntry; import sun.security.util.ManifestDigester; import sun.security.util.ManifestEntryVerifier; @@ -81,6 +83,15 @@ class JarVerifier { /** the bytes for the manDig object */ byte manifestRawBytes[] = null; + /** controls eager signature validation */ + boolean eagerValidation; + + /** makes code source singleton instances unique to us */ + private Object csdomain = new Object(); + + /** collect -DIGEST-MANIFEST values for blacklist */ + private List manifestDigests; + public JarVerifier(byte rawBytes[]) { manifestRawBytes = rawBytes; sigFileSigners = new Hashtable(); @@ -88,6 +99,7 @@ class JarVerifier { sigFileData = new Hashtable(11); pendingBlocks = new ArrayList(); baos = new ByteArrayOutputStream(); + manifestDigests = new ArrayList(); } /** @@ -247,7 +259,7 @@ class JarVerifier { } sfv.setSignatureFile(bytes); - sfv.process(sigFileSigners); + sfv.process(sigFileSigners, manifestDigests); } } return; @@ -290,7 +302,7 @@ class JarVerifier { sfv.setSignatureFile(bytes); } } - sfv.process(sigFileSigners); + sfv.process(sigFileSigners, manifestDigests); } catch (IOException ioe) { // e.g. sun.security.pkcs.ParsingException @@ -312,12 +324,18 @@ class JarVerifier { /** * Return an array of java.security.cert.Certificate objects for * the given file in the jar. + * @deprecated */ public java.security.cert.Certificate[] getCerts(String name) { return mapSignersToCertArray(getCodeSigners(name)); } + public java.security.cert.Certificate[] getCerts(JarFile jar, JarEntry entry) + { + return mapSignersToCertArray(getCodeSigners(jar, entry)); + } + /** * return an array of CodeSigner objects for * the given file in the jar. this array is not cloned. @@ -328,6 +346,28 @@ class JarVerifier { return (CodeSigner[])verifiedSigners.get(name); } + public CodeSigner[] getCodeSigners(JarFile jar, JarEntry entry) + { + String name = entry.getName(); + if (eagerValidation && sigFileSigners.get(name) != null) { + /* + * Force a read of the entry data to generate the + * verification hash. + */ + try { + InputStream s = jar.getInputStream(entry); + byte[] buffer = new byte[1024]; + int n = buffer.length; + while (n != -1) { + n = s.read(buffer, 0, buffer.length); + } + s.close(); + } catch (IOException e) { + } + } + return getCodeSigners(name); + } + /* * Convert an array of signers into an array of concatenated certificate * arrays. @@ -444,4 +484,393 @@ class JarVerifier { } } + + // Extended JavaUtilJarAccess CodeSource API Support + + private Map urlToCodeSourceMap = new HashMap(); + private Map signerToCodeSource = new HashMap(); + private URL lastURL; + private Map lastURLMap; + + /* + * Create a unique mapping from codeSigner cache entries to CodeSource. + * In theory, multiple URLs origins could map to a single locally cached + * and shared JAR file although in practice there will be a single URL in use. + */ + private synchronized CodeSource mapSignersToCodeSource(URL url, CodeSigner[] signers) { + Map map; + if (url == lastURL) { + map = lastURLMap; + } else { + map = (Map) urlToCodeSourceMap.get(url); + if (map == null) { + map = new HashMap(); + urlToCodeSourceMap.put(url, map); + } + lastURLMap = map; + lastURL = url; + } + CodeSource cs = (CodeSource) map.get(signers); + if (cs == null) { + cs = new VerifierCodeSource(csdomain, url, signers); + signerToCodeSource.put(signers, cs); + } + return cs; + } + + private CodeSource[] mapSignersToCodeSources(URL url, List signers, boolean unsigned) { + List sources = new ArrayList(); + + for (int i = 0; i < signers.size(); i++) { + sources.add(mapSignersToCodeSource(url, (CodeSigner[]) signers.get(i))); + } + if (unsigned) { + sources.add(mapSignersToCodeSource(url, null)); + } + return (CodeSource[]) sources.toArray(new CodeSource[sources.size()]); + } + private CodeSigner[] emptySigner = new CodeSigner[0]; + + /* + * Match CodeSource to a CodeSigner[] in the signer cache. + */ + private CodeSigner[] findMatchingSigners(CodeSource cs) { + if (cs instanceof VerifierCodeSource) { + VerifierCodeSource vcs = (VerifierCodeSource) cs; + if (vcs.isSameDomain(csdomain)) { + return ((VerifierCodeSource) cs).getPrivateSigners(); + } + } + + /* + * In practice signers should always be optimized above + * but this handles a CodeSource of any type, just in case. + */ + CodeSource[] sources = mapSignersToCodeSources(cs.getLocation(), getJarCodeSigners(), true); + List sourceList = new ArrayList(); + for (int i = 0; i < sources.length; i++) { + sourceList.add(sources[i]); + } + int j = sourceList.indexOf(cs); + if (j != -1) { + CodeSigner[] match; + match = ((VerifierCodeSource) sourceList.get(j)).getPrivateSigners(); + if (match == null) { + match = emptySigner; + } + return match; + } + return null; + } + + /* + * Instances of this class hold uncopied references to internal + * signing data that can be compared by object reference identity. + */ + private static class VerifierCodeSource extends CodeSource { + + URL vlocation; + CodeSigner[] vsigners; + java.security.cert.Certificate[] vcerts; + Object csdomain; + + VerifierCodeSource(Object csdomain, URL location, CodeSigner[] signers) { + super(location, signers); + this.csdomain = csdomain; + vlocation = location; + vsigners = signers; // from signerCache + } + + VerifierCodeSource(Object csdomain, URL location, java.security.cert.Certificate[] certs) { + super(location, certs); + this.csdomain = csdomain; + vlocation = location; + vcerts = certs; // from signerCache + } + + /* + * All VerifierCodeSource instances are constructed based on + * singleton signerCache or signerCacheCert entries for each unique signer. + * No CodeSigner<->Certificate[] conversion is required. + * We use these assumptions to optimize equality comparisons. + */ + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof VerifierCodeSource) { + VerifierCodeSource that = (VerifierCodeSource) obj; + + /* + * Only compare against other per-signer singletons constructed + * on behalf of the same JarFile instance. Otherwise, compare + * things the slower way. + */ + if (isSameDomain(that.csdomain)) { + if (that.vsigners != this.vsigners + || that.vcerts != this.vcerts) { + return false; + } + if (that.vlocation != null) { + return that.vlocation.equals(this.vlocation); + } else if (this.vlocation != null) { + return this.vlocation.equals(that.vlocation); + } else { // both null + return true; + } + } + } + return super.equals(obj); + } + + boolean isSameDomain(Object csdomain) { + return this.csdomain == csdomain; + } + + private CodeSigner[] getPrivateSigners() { + return vsigners; + } + + private java.security.cert.Certificate[] getPrivateCertificates() { + return vcerts; + } + } + private Map signerMap; + + private synchronized Map signerMap() { + if (signerMap == null) { + /* + * Snapshot signer state so it doesn't change on us. We care + * only about the asserted signatures. Verification of + * signature validity happens via the JarEntry apis. + */ + signerMap = new HashMap(verifiedSigners.size() + sigFileSigners.size()); + signerMap.putAll(verifiedSigners); + signerMap.putAll(sigFileSigners); + } + return signerMap; + } + + public synchronized Enumeration entryNames(JarFile jar, final CodeSource[] cs) { + final Map map = signerMap(); + final Iterator itor = map.entrySet().iterator(); + boolean matchUnsigned = false; + + /* + * Grab a single copy of the CodeSigner arrays. Check + * to see if we can optimize CodeSigner equality test. + */ + List req = new ArrayList(cs.length); + for (int i = 0; i < cs.length; i++) { + CodeSigner[] match = findMatchingSigners(cs[i]); + if (match != null) { + if (match.length > 0) { + req.add(match); + } else { + matchUnsigned = true; + } + } + } + + final List signersReq = req; + final Enumeration enum2 = (matchUnsigned) ? unsignedEntryNames(jar) : emptyEnumeration; + + return new Enumeration() { + + String name; + + public boolean hasMoreElements() { + if (name != null) { + return true; + } + + while (itor.hasNext()) { + Map.Entry e = (Map.Entry) itor.next(); + if (signersReq.contains((CodeSigner[]) e.getValue())) { + name = (String) e.getKey(); + return true; + } + } + while (enum2.hasMoreElements()) { + name = (String) enum2.nextElement(); + return true; + } + return false; + } + + public String nextElement() { + if (hasMoreElements()) { + String value = name; + name = null; + return value; + } + throw new NoSuchElementException(); + } + }; + } + + /* + * Like entries() but screens out internal JAR mechanism entries + * and includes signed entries with no ZIP data. + */ + public Enumeration entries2(final JarFile jar, Enumeration e) { + final Map map = new HashMap(); + map.putAll(signerMap()); + final Enumeration enum_ = e; + return new Enumeration() { + + Enumeration signers = null; + JarEntry entry; + + public boolean hasMoreElements() { + if (entry != null) { + return true; + } + while (enum_.hasMoreElements()) { + ZipEntry ze = (ZipEntry) enum_.nextElement(); + if (JarVerifier.isSigningRelated(ze.getName())) { + continue; + } + entry = jar.newEntry(ze); + return true; + } + if (signers == null) { + signers = Collections.enumeration(map.keySet()); + } + while (signers.hasMoreElements()) { + String name = (String) signers.nextElement(); + entry = jar.newEntry(new ZipEntry(name)); + return true; + } + + // Any map entries left? + return false; + } + + public JarEntry nextElement() { + if (hasMoreElements()) { + JarEntry je = entry; + map.remove(je.getName()); + entry = null; + return je; + } + throw new NoSuchElementException(); + } + }; + } + private Enumeration emptyEnumeration = new Enumeration() { + + public boolean hasMoreElements() { + return false; + } + + public String nextElement() { + throw new NoSuchElementException(); + } + }; + + // true if file is part of the signature mechanism itself + static boolean isSigningRelated(String name) { + name = name.toUpperCase(Locale.ENGLISH); + if (!name.startsWith("META-INF/")) { + return false; + } + name = name.substring(9); + if (name.indexOf('/') != -1) { + return false; + } + if (name.endsWith(".DSA") + || name.endsWith(".RSA") + || name.endsWith(".SF") + || name.endsWith(".EC") + || name.startsWith("SIG-") + || name.equals("MANIFEST.MF")) { + return true; + } + return false; + } + + private Enumeration unsignedEntryNames(JarFile jar) { + final Map map = signerMap(); + final Enumeration entries = jar.entries(); + return new Enumeration() { + + String name; + + /* + * Grab entries from ZIP directory but screen out + * metadata. + */ + public boolean hasMoreElements() { + if (name != null) { + return true; + } + while (entries.hasMoreElements()) { + String value; + ZipEntry e = (ZipEntry) entries.nextElement(); + value = e.getName(); + if (e.isDirectory() || isSigningRelated(value)) { + continue; + } + if (map.get(value) == null) { + name = value; + return true; + } + } + return false; + } + + public String nextElement() { + if (hasMoreElements()) { + String value = name; + name = null; + return value; + } + throw new NoSuchElementException(); + } + }; + } + private List jarCodeSigners; + + private synchronized List getJarCodeSigners() { + CodeSigner[] signers; + if (jarCodeSigners == null) { + HashSet set = new HashSet(); + set.addAll(signerMap().values()); + jarCodeSigners = new ArrayList(); + jarCodeSigners.addAll(set); + } + return jarCodeSigners; + } + + public synchronized CodeSource[] getCodeSources(JarFile jar, URL url) { + boolean hasUnsigned = unsignedEntryNames(jar).hasMoreElements(); + + return mapSignersToCodeSources(url, getJarCodeSigners(), hasUnsigned); + } + + public CodeSource getCodeSource(URL url, String name) { + CodeSigner[] signers; + + signers = (CodeSigner[]) signerMap().get(name); + return mapSignersToCodeSource(url, signers); + } + + public CodeSource getCodeSource(URL url, JarFile jar, JarEntry je) { + CodeSigner[] signers; + + return mapSignersToCodeSource(url, getCodeSigners(jar, je)); + } + + public void setEagerValidation(boolean eager) { + eagerValidation = eager; + } + + public synchronized List getManifestDigests() { + return Collections.unmodifiableList(manifestDigests); + } + + static CodeSource getUnsignedCS(URL url) { + return new VerifierCodeSource(null, url, (java.security.cert.Certificate[]) null); + } } diff --git a/jdk/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java b/jdk/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java index bed2b5a77e5..c53ba0c6f52 100644 --- a/jdk/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java +++ b/jdk/src/share/classes/java/util/jar/JavaUtilJarAccessImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -26,10 +26,38 @@ package java.util.jar; import java.io.IOException; +import java.net.URL; +import java.security.CodeSource; +import java.util.Enumeration; +import java.util.List; import sun.misc.JavaUtilJarAccess; class JavaUtilJarAccessImpl implements JavaUtilJarAccess { public boolean jarFileHasClassPathAttribute(JarFile jar) throws IOException { return jar.hasClassPathAttribute(); } + + public CodeSource[] getCodeSources(JarFile jar, URL url) { + return jar.getCodeSources(url); + } + + public CodeSource getCodeSource(JarFile jar, URL url, String name) { + return jar.getCodeSource(url, name); + } + + public Enumeration entryNames(JarFile jar, CodeSource[] cs) { + return jar.entryNames(cs); + } + + public Enumeration entries2(JarFile jar) { + return jar.entries2(); + } + + public void setEagerValidation(JarFile jar, boolean eager) { + jar.setEagerValidation(eager); + } + + public List getManifestDigests(JarFile jar) { + return jar.getManifestDigests(); + } } diff --git a/jdk/src/share/classes/sun/misc/JarIndex.java b/jdk/src/share/classes/sun/misc/JarIndex.java index 39e2eca91d8..f9781d65a0d 100644 --- a/jdk/src/share/classes/sun/misc/JarIndex.java +++ b/jdk/src/share/classes/sun/misc/JarIndex.java @@ -103,6 +103,19 @@ public class JarIndex { parseJars(files); } + /** + * Returns the jar index, or null if none. + * + * This single parameter version of the method is retained + * for binary compatibility with earlier releases. + * + * @param jar the JAR file to get the index from. + * @exception IOException if an I/O error has occurred. + */ + public static JarIndex getJarIndex(JarFile jar) throws IOException { + return getJarIndex(jar, null); + } + /** * Returns the jar index, or null if none. * diff --git a/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java b/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java index e5e6b608ee8..0f1efd1d2cb 100644 --- a/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java +++ b/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -26,8 +26,19 @@ package sun.misc; import java.io.IOException; +import java.net.URL; +import java.security.CodeSource; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarEntry; import java.util.jar.JarFile; public interface JavaUtilJarAccess { public boolean jarFileHasClassPathAttribute(JarFile jar) throws IOException; + public CodeSource[] getCodeSources(JarFile jar, URL url); + public CodeSource getCodeSource(JarFile jar, URL url, String name); + public Enumeration entryNames(JarFile jar, CodeSource[] cs); + public Enumeration entries2(JarFile jar); + public void setEagerValidation(JarFile jar, boolean eager); + public List getManifestDigests(JarFile jar); } diff --git a/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java b/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java index d3ce9013e15..f60fcb75f8b 100644 --- a/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java +++ b/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -181,7 +181,8 @@ public class SignatureFileVerifier { * * */ - public void process(Hashtable signers) + public void process(Hashtable signers, + List manifestDigests) throws IOException, SignatureException, NoSuchAlgorithmException, JarException, CertificateException { @@ -190,14 +191,15 @@ public class SignatureFileVerifier { Object obj = null; try { obj = Providers.startJarVerification(); - processImpl(signers); + processImpl(signers, manifestDigests); } finally { Providers.stopJarVerification(obj); } } - private void processImpl(Hashtable signers) + private void processImpl(Hashtable signers, + List manifestDigests) throws IOException, SignatureException, NoSuchAlgorithmException, JarException, CertificateException { @@ -232,7 +234,7 @@ public class SignatureFileVerifier { sf.getEntries().entrySet().iterator(); // see if we can verify the whole manifest first - boolean manifestSigned = verifyManifestHash(sf, md, decoder); + boolean manifestSigned = verifyManifestHash(sf, md, decoder, manifestDigests); // verify manifest main attributes if (!manifestSigned && !verifyManifestMainAttrs(sf, md, decoder)) { @@ -275,7 +277,8 @@ public class SignatureFileVerifier { */ private boolean verifyManifestHash(Manifest sf, ManifestDigester md, - BASE64Decoder decoder) + BASE64Decoder decoder, + List manifestDigests) throws IOException { Attributes mattr = sf.getMainAttributes(); @@ -290,6 +293,8 @@ public class SignatureFileVerifier { // 16 is length of "-Digest-Manifest" String algorithm = key.substring(0, key.length()-16); + manifestDigests.add(key); + manifestDigests.add(se.getValue()); MessageDigest digest = getDigest(algorithm); if (digest != null) { byte[] computedHash = md.manifestDigest(digest); From 3cda6b5fd043fcaf8ff271282ed18397d952934e Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Sat, 12 Feb 2011 07:30:01 +0800 Subject: [PATCH 044/105] 7016698: test sun/security/krb5/runNameEquals.sh failed on Ubuntu Reviewed-by: valeriep --- .../classes/sun/security/jgss/wrapper/SunNativeProvider.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/src/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java b/jdk/src/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java index 328aadf7f5d..c7694023d6b 100644 --- a/jdk/src/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java +++ b/jdk/src/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java @@ -87,6 +87,7 @@ public final class SunNativeProvider extends Provider { gssLibs = new String[]{ "libgssapi.so", "libgssapi_krb5.so", + "libgssapi_krb5.so.2", }; } } else { From 05a3d3acb6014b9623fcc6967444f6282fcce87c Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Fri, 11 Feb 2011 17:09:35 -0800 Subject: [PATCH 045/105] 6996192: Console.readPassword race: input echo off must be prior to writing prompt To turn off echo before prompt Reviewed-by: alanb --- jdk/src/share/classes/java/io/Console.java | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/java/io/Console.java b/jdk/src/share/classes/java/io/Console.java index 783dafd28e4..9bfbaf00497 100644 --- a/jdk/src/share/classes/java/io/Console.java +++ b/jdk/src/share/classes/java/io/Console.java @@ -308,17 +308,29 @@ public final class Console implements Flushable char[] passwd = null; synchronized (writeLock) { synchronized(readLock) { - if (fmt.length() != 0) - pw.format(fmt, args); try { echoOff = echo(false); - passwd = readline(true); } catch (IOException x) { throw new IOError(x); + } + IOError ioe = null; + try { + if (fmt.length() != 0) + pw.format(fmt, args); + passwd = readline(true); + } catch (IOException x) { + ioe = new IOError(x); } finally { try { echoOff = echo(true); - } catch (IOException xx) {} + } catch (IOException x) { + if (ioe == null) + ioe = new IOError(x); + else + ioe.addSuppressed(x); + } + if (ioe != null) + throw ioe; } pw.println(); } From 710ec9f95dde194501d551d27a627240cf100c01 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 11 Feb 2011 17:10:26 -0800 Subject: [PATCH 046/105] 6505047: javax.lang.model.element.Element.getEnclosingElement() doesn't return null for type parameter Reviewed-by: darcy --- .../model/element/TestTypeParameter.java | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 langtools/test/tools/javac/processing/model/element/TestTypeParameter.java diff --git a/langtools/test/tools/javac/processing/model/element/TestTypeParameter.java b/langtools/test/tools/javac/processing/model/element/TestTypeParameter.java new file mode 100644 index 00000000000..9fc6aa21a66 --- /dev/null +++ b/langtools/test/tools/javac/processing/model/element/TestTypeParameter.java @@ -0,0 +1,129 @@ +/* + * 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. + */ + +/* + * @test + * @bug 6505047 + * @summary javax.lang.model.element.Element.getEnclosingElement() doesn't return null for type parameter + * @library ../../../lib + * @build JavacTestingAbstractProcessor TestTypeParameter + * @compile -processor TestTypeParameter -proc:only TestTypeParameter.java + */ + +import java.util.*; +import javax.annotation.processing.*; +import javax.lang.model.element.*; +import javax.lang.model.util.*; +import javax.tools.*; + +public class TestTypeParameter extends JavacTestingAbstractProcessor { + int round = 0; + + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (++round == 1) { + int found = (new Scanner()).scan(roundEnv.getRootElements(), null); + if (found == expect) { + note("generic elements found and verified: " + found); + } else { + error("unexpected number of results: expected " + expect + + ", found " + found); + } + + } + return true; + } + + class Scanner extends ElementScanner7 { + @Override + public Integer visitExecutable(ExecutableElement e, Void p) { + super.visitExecutable(e, p); + found += check(e, e.getTypeParameters()); + return found; + } + + @Override + public Integer visitType(TypeElement e, Void p) { + super.visitType(e, p); + found += check(e, e.getTypeParameters()); + return found; + } + + int found; + } + + /** + * Check if type parameters, if any, have expected owner. + * Return 1 if typarams not empty and all have expected owner, else return 0. + */ + int check(Element e, List typarams) { + note("checking " + e, e); + if (typarams.isEmpty()) { + note("no type parameters found", e); + return 0; + } + for (TypeParameterElement tpe: typarams) { + note("checking type parameter " + tpe, tpe); + if (tpe.getEnclosingElement() != e) { + error("unexpected owner; expected: " + e + + ", found " + tpe.getEnclosingElement(), + tpe); + return 0; + } + if (tpe.getEnclosingElement() != tpe.getGenericElement()) { + error("unexpected generic element; expected: " + tpe.getGenericElement() + + ", found " + tpe.getEnclosingElement(), + tpe); + return 0; + } + } + note("verified " + e, e); + return 1; + } + + void note(String msg) { + messager.printMessage(Diagnostic.Kind.NOTE, msg); + } + + void note(String msg, Element e) { + messager.printMessage(Diagnostic.Kind.NOTE, msg, e); + } + + void error(String msg, Element e) { + messager.printMessage(Diagnostic.Kind.ERROR, msg, e); + } + + void error(String msg) { + messager.printMessage(Diagnostic.Kind.ERROR, msg); + } + + // additional generic elements to test + X m(X x) { return x; } + + interface Intf { X m() ; } + + class Class { + Class() { } + } + + final int expect = 5; // top level class, plus preceding examples +} From 876fbcb9f7d90d13211f39acfc02f42160007ab4 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Sat, 12 Feb 2011 10:28:34 -0500 Subject: [PATCH 047/105] 7019157: errorHandler doesn't compile with super old gcc without precompiled headers Old gccs don't support precompiled headers so have to supply includes Reviewed-by: phh, kamg --- hotspot/src/share/vm/utilities/errorReporter.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/src/share/vm/utilities/errorReporter.hpp b/hotspot/src/share/vm/utilities/errorReporter.hpp index e7fae5fba22..130ae2af301 100644 --- a/hotspot/src/share/vm/utilities/errorReporter.hpp +++ b/hotspot/src/share/vm/utilities/errorReporter.hpp @@ -26,6 +26,7 @@ #define SHARE_VM_UTILITIES_ERRORREPORTER_HPP #include "utilities/globalDefinitions.hpp" +#include "memory/allocation.hpp" class ErrorReporter : public StackObj { From dcf0b454c618d3cf0b0c45804789abf817b26600 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Sat, 12 Feb 2011 10:28:34 -0500 Subject: [PATCH 048/105] 7022659: errorHandler doesn't compile without precompiled headers Add proper includes in errorHandler.hpp Reviewed-by: phh, kamg --- hotspot/src/share/vm/utilities/errorReporter.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/src/share/vm/utilities/errorReporter.hpp b/hotspot/src/share/vm/utilities/errorReporter.hpp index e7fae5fba22..130ae2af301 100644 --- a/hotspot/src/share/vm/utilities/errorReporter.hpp +++ b/hotspot/src/share/vm/utilities/errorReporter.hpp @@ -26,6 +26,7 @@ #define SHARE_VM_UTILITIES_ERRORREPORTER_HPP #include "utilities/globalDefinitions.hpp" +#include "memory/allocation.hpp" class ErrorReporter : public StackObj { From 29b4c54984748fa086e5abcbd43e13efd178f97a Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Mon, 14 Feb 2011 09:31:58 -0800 Subject: [PATCH 049/105] 6637230: 2/3 jps doesn't work for application waiting for direct attach Properly handle exceptions thrown when querying a monitored VM. Reviewed-by: dsamersoff, swamyv --- jdk/src/share/classes/sun/tools/jps/Jps.java | 76 ++++++++++++-------- 1 file changed, 46 insertions(+), 30 deletions(-) diff --git a/jdk/src/share/classes/sun/tools/jps/Jps.java b/jdk/src/share/classes/sun/tools/jps/Jps.java index 7850f9656c2..9611dd3a007 100644 --- a/jdk/src/share/classes/sun/tools/jps/Jps.java +++ b/jdk/src/share/classes/sun/tools/jps/Jps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -77,9 +77,52 @@ public class Jps { MonitoredVm vm = null; String vmidString = "//" + lvmid + "?mode=r"; + String errorString = null; + try { + // Note: The VM associated with the current VM id may + // no longer be running so these queries may fail. We + // already added the VM id to the output stream above. + // If one of the queries fails, then we try to add a + // reasonable message to indicate that the requested + // info is not available. + + errorString = " -- process information unavailable"; VmIdentifier id = new VmIdentifier(vmidString); vm = monitoredHost.getMonitoredVm(id, 0); + + errorString = " -- main class information unavailable"; + output.append(" " + MonitoredVmUtil.mainClass(vm, + arguments.showLongPaths())); + + if (arguments.showMainArgs()) { + errorString = " -- main args information unavailable"; + String mainArgs = MonitoredVmUtil.mainArgs(vm); + if (mainArgs != null && mainArgs.length() > 0) { + output.append(" " + mainArgs); + } + } + if (arguments.showVmArgs()) { + errorString = " -- jvm args information unavailable"; + String jvmArgs = MonitoredVmUtil.jvmArgs(vm); + if (jvmArgs != null && jvmArgs.length() > 0) { + output.append(" " + jvmArgs); + } + } + if (arguments.showVmFlags()) { + errorString = " -- jvm flags information unavailable"; + String jvmFlags = MonitoredVmUtil.jvmFlags(vm); + if (jvmFlags != null && jvmFlags.length() > 0) { + output.append(" " + jvmFlags); + } + } + + errorString = " -- detach failed"; + monitoredHost.detach(vm); + + System.out.println(output); + + errorString = null; } catch (URISyntaxException e) { // unexpected as vmidString is based on a validated hostid lastError = e; @@ -87,7 +130,7 @@ public class Jps { } catch (Exception e) { lastError = e; } finally { - if (vm == null) { + if (errorString != null) { /* * we ignore most exceptions, as there are race * conditions where a JVM in 'jvms' may terminate @@ -95,7 +138,7 @@ public class Jps { * Other errors, such as access and I/O exceptions * should stop us from iterating over the complete set. */ - output.append(" -- process information unavailable"); + output.append(errorString); if (arguments.isDebug()) { if ((lastError != null) && (lastError.getMessage() != null)) { @@ -110,33 +153,6 @@ public class Jps { continue; } } - - output.append(" "); - output.append(MonitoredVmUtil.mainClass(vm, - arguments.showLongPaths())); - - if (arguments.showMainArgs()) { - String mainArgs = MonitoredVmUtil.mainArgs(vm); - if (mainArgs != null && mainArgs.length() > 0) { - output.append(" ").append(mainArgs); - } - } - if (arguments.showVmArgs()) { - String jvmArgs = MonitoredVmUtil.jvmArgs(vm); - if (jvmArgs != null && jvmArgs.length() > 0) { - output.append(" ").append(jvmArgs); - } - } - if (arguments.showVmFlags()) { - String jvmFlags = MonitoredVmUtil.jvmFlags(vm); - if (jvmFlags != null && jvmFlags.length() > 0) { - output.append(" ").append(jvmFlags); - } - } - - System.out.println(output); - - monitoredHost.detach(vm); } } catch (MonitorException e) { if (e.getMessage() != null) { From 14997b102e836d37dd8dc63adb1ab470644b048c Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 14 Feb 2011 18:30:53 +0000 Subject: [PATCH 050/105] 7016704: TEST_BUG: java/nio/file/Files/walk_file_tree.sh fails with new version of find (lnx) Reviewed-by: forax --- .../nio/file/Files/walkFileTree/PrintFileTree.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/jdk/test/java/nio/file/Files/walkFileTree/PrintFileTree.java b/jdk/test/java/nio/file/Files/walkFileTree/PrintFileTree.java index 83d554dc689..048298bcb19 100644 --- a/jdk/test/java/nio/file/Files/walkFileTree/PrintFileTree.java +++ b/jdk/test/java/nio/file/Files/walkFileTree/PrintFileTree.java @@ -54,6 +54,7 @@ public class PrintFileTree { if (followLinks) options.add(FileVisitOption.FOLLOW_LINKS); + final boolean follow = followLinks; final boolean reportCycles = printCycles; Files.walkFileTree(dir, options, Integer.MAX_VALUE, new FileVisitor() { @Override @@ -63,8 +64,7 @@ public class PrintFileTree { } @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) { - if (!attrs.isDirectory() || reportCycles) - System.out.println(file); + System.out.println(file); return FileVisitResult.CONTINUE; } @Override @@ -79,11 +79,13 @@ public class PrintFileTree { public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException { - if (reportCycles && (exc instanceof FileSystemLoopException)) { - System.out.println(file); + if (follow && (exc instanceof FileSystemLoopException)) { + if (reportCycles) + System.out.println(file); return FileVisitResult.CONTINUE; + } else { + throw exc; } - throw exc; } }); } From 709cabc2f1877a1eba508a3ab98b0ce783c7ddd6 Mon Sep 17 00:00:00 2001 From: Neil Richards Date: Mon, 14 Feb 2011 10:38:51 -0800 Subject: [PATCH 051/105] 6934356: Vector.writeObject() serialization may deadlock No longer synchronize on self while writing other objects. Reviewed-by: alanb, forax, mduigou, peterjones --- jdk/src/share/classes/java/util/Vector.java | 20 ++- .../util/Vector/SerializationDeadlock.java | 157 ++++++++++++++++++ .../java/util/Vector/SimpleSerialization.java | 87 ++++++++++ 3 files changed, 258 insertions(+), 6 deletions(-) create mode 100644 jdk/test/java/util/Vector/SerializationDeadlock.java create mode 100644 jdk/test/java/util/Vector/SimpleSerialization.java diff --git a/jdk/src/share/classes/java/util/Vector.java b/jdk/src/share/classes/java/util/Vector.java index 1ce0abf86f3..11c0c60a481 100644 --- a/jdk/src/share/classes/java/util/Vector.java +++ b/jdk/src/share/classes/java/util/Vector.java @@ -1050,13 +1050,21 @@ public class Vector /** * Save the state of the {@code Vector} instance to a stream (that - * is, serialize it). This method is present merely for synchronization. - * It just calls the default writeObject method. + * is, serialize it). + * This method performs synchronization to ensure the consistency + * of the serialized data. */ - private synchronized void writeObject(java.io.ObjectOutputStream s) - throws java.io.IOException - { - s.defaultWriteObject(); + private void writeObject(java.io.ObjectOutputStream s) + throws java.io.IOException { + final java.io.ObjectOutputStream.PutField fields = s.putFields(); + final Object[] data; + synchronized (this) { + fields.put("capacityIncrement", capacityIncrement); + fields.put("elementCount", elementCount); + data = elementData.clone(); + } + fields.put("elementData", data); + s.writeFields(); } /** diff --git a/jdk/test/java/util/Vector/SerializationDeadlock.java b/jdk/test/java/util/Vector/SerializationDeadlock.java new file mode 100644 index 00000000000..dd4471e0304 --- /dev/null +++ b/jdk/test/java/util/Vector/SerializationDeadlock.java @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2010, 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. + */ + +/* + * Portions Copyright (c) 2010, 2011 IBM Corporation + */ + +/* + * @test + * @bug 6934356 + * @summary Serializing Vector objects which refer to each other should not be able to deadlock. + * @author Neil Richards , + */ + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.PrintWriter; +import java.io.Serializable; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; +import java.util.concurrent.CyclicBarrier; + +public class SerializationDeadlock { + public static void main(final String[] args) throws Exception { + // Test for Vector serialization deadlock + final Vector v1 = new Vector<>(); + final Vector v2 = new Vector<>(); + final TestBarrier testStart = new TestBarrier(3); + + // Populate the vectors so that they refer to each other + v1.add(testStart); + v1.add(v2); + v2.add(testStart); + v2.add(v1); + + final CyclicBarrier testEnd = new CyclicBarrier(3); + final TestThread t1 = new TestThread(v1, testEnd); + final TestThread t2 = new TestThread(v2, testEnd); + + t1.start(); + t2.start(); + + // Wait for both test threads to have initiated serialization + // of the 'testStart' object (and hence of both 'v1' and 'v2') + testStart.await(); + + // Wait for both test threads to successfully finish serialization + // of 'v1' and 'v2'. + System.out.println("Waiting for Vector serialization to complete ..."); + System.out.println("(This test will hang if serialization deadlocks)"); + testEnd.await(); + System.out.println("Test PASSED: serialization completed successfully"); + + TestThread.handleExceptions(); + } + + static final class TestBarrier extends CyclicBarrier + implements Serializable { + public TestBarrier(final int count) { + super(count); + } + + private void writeObject(final ObjectOutputStream oos) + throws IOException { + oos.defaultWriteObject(); + // Wait until all test threads have started serializing data + try { + await(); + } catch (final Exception e) { + throw new IOException("Test ERROR: Unexpected exception caught", e); + } + } + } + + static final class TestThread extends Thread { + private static final List exceptions = new ArrayList<>(); + + private final Vector vector; + private final CyclicBarrier testEnd; + + public TestThread(final Vector vector, final CyclicBarrier testEnd) { + this.vector = vector; + this.testEnd = testEnd; + setDaemon(true); + } + + public void run() { + try { + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(baos); + + oos.writeObject(vector); + oos.close(); + } catch (final IOException ioe) { + addException(ioe); + } finally { + try { + testEnd.await(); + } catch (Exception e) { + addException(e); + } + } + } + + private static synchronized void addException(final Exception exception) { + exceptions.add(exception); + } + + public static synchronized void handleExceptions() { + if (false == exceptions.isEmpty()) { + throw new RuntimeException(getErrorText(exceptions)); + } + } + + private static String getErrorText(final List exceptions) { + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); + + pw.println("Test ERROR: Unexpected exceptions thrown on test threads:"); + for (Exception exception : exceptions) { + pw.print("\t"); + pw.println(exception); + for (StackTraceElement element : exception.getStackTrace()) { + pw.print("\t\tat "); + pw.println(element); + } + } + + pw.close(); + return sw.toString(); + } + } +} + diff --git a/jdk/test/java/util/Vector/SimpleSerialization.java b/jdk/test/java/util/Vector/SimpleSerialization.java new file mode 100644 index 00000000000..f7fe2e6199f --- /dev/null +++ b/jdk/test/java/util/Vector/SimpleSerialization.java @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2010, 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. + */ + +/* + * Portions Copyright (c) 2010, 2011 IBM Corporation + */ + +/* + * @test + * @bug 6934356 + * @summary A serialized Vector can be successfully de-serialized. + * @author Neil Richards , + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Vector; + +public class SimpleSerialization { + public static void main(final String[] args) throws Exception { + final Vector v1 = new Vector<>(); + + v1.add("entry1"); + v1.add("entry2"); + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(baos); + + oos.writeObject(v1); + oos.close(); + + final byte[] data = baos.toByteArray(); + final ByteArrayInputStream bais = new ByteArrayInputStream(data); + final ObjectInputStream ois = new ObjectInputStream(bais); + + final Object deserializedObject = ois.readObject(); + ois.close(); + + if (false == v1.equals(deserializedObject)) { + throw new RuntimeException(getFailureText(v1, deserializedObject)); + } + } + + private static String getFailureText(final Object orig, final Object copy) { + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); + + pw.println("Test FAILED: Deserialized object is not equal to the original object"); + pw.print("\tOriginal: "); + printObject(pw, orig).println(); + pw.print("\tCopy: "); + printObject(pw, copy).println(); + + pw.close(); + return sw.toString(); + } + + private static PrintWriter printObject(final PrintWriter pw, final Object o) { + pw.printf("%s@%08x", o.getClass().getName(), System.identityHashCode(o)); + return pw; + } +} From 32b8c54ea3562b96c6df844bfde5527e29a01cd7 Mon Sep 17 00:00:00 2001 From: Neil Richards Date: Mon, 14 Feb 2011 11:00:02 -0800 Subject: [PATCH 052/105] 6927486: Hashtable writeObject() may deadlock Do not synchronize on self while writing hash table elements Reviewed-by: alanb, mduigou --- .../share/classes/java/util/Hashtable.java | 40 +++-- .../util/Hashtable/SerializationDeadlock.java | 156 ++++++++++++++++++ .../util/Hashtable/SimpleSerialization.java | 86 ++++++++++ 3 files changed, 268 insertions(+), 14 deletions(-) create mode 100644 jdk/test/java/util/Hashtable/SerializationDeadlock.java create mode 100644 jdk/test/java/util/Hashtable/SimpleSerialization.java diff --git a/jdk/src/share/classes/java/util/Hashtable.java b/jdk/src/share/classes/java/util/Hashtable.java index 63af5581cf7..b354bbc50f1 100644 --- a/jdk/src/share/classes/java/util/Hashtable.java +++ b/jdk/src/share/classes/java/util/Hashtable.java @@ -845,24 +845,36 @@ public class Hashtable * for each key-value mapping represented by the Hashtable * The key-value mappings are emitted in no particular order. */ - private synchronized void writeObject(java.io.ObjectOutputStream s) - throws IOException - { - // Write out the length, threshold, loadfactor - s.defaultWriteObject(); + private void writeObject(java.io.ObjectOutputStream s) + throws IOException { + Entry entryStack = null; - // Write out length, count of elements and then the key/value objects - s.writeInt(table.length); - s.writeInt(count); - for (int index = table.length-1; index >= 0; index--) { - Entry entry = table[index]; + synchronized (this) { + // Write out the length, threshold, loadfactor + s.defaultWriteObject(); - while (entry != null) { - s.writeObject(entry.key); - s.writeObject(entry.value); - entry = entry.next; + // Write out length, count of elements + s.writeInt(table.length); + s.writeInt(count); + + // Stack copies of the entries in the table + for (int index = 0; index < table.length; index++) { + Entry entry = table[index]; + + while (entry != null) { + entryStack = + new Entry<>(0, entry.key, entry.value, entryStack); + entry = entry.next; + } } } + + // Write out the key/value objects from the stacked entries + while (entryStack != null) { + s.writeObject(entryStack.key); + s.writeObject(entryStack.value); + entryStack = entryStack.next; + } } /** diff --git a/jdk/test/java/util/Hashtable/SerializationDeadlock.java b/jdk/test/java/util/Hashtable/SerializationDeadlock.java new file mode 100644 index 00000000000..c9048fb691f --- /dev/null +++ b/jdk/test/java/util/Hashtable/SerializationDeadlock.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2010, 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. + * + * ------------------------------------------- + * + * Portions Copyright (c) 2010, 2011 IBM Corporation + */ + +/* + * @test + * @bug 6927486 + * @summary Serializing Hashtable objects which refer to each other should not be able to deadlock. + * @author Neil Richards , + */ + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.PrintWriter; +import java.io.Serializable; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; +import java.util.concurrent.CyclicBarrier; + +public class SerializationDeadlock { + public static void main(final String[] args) throws Exception { + // Test for Hashtable serialization deadlock + final Hashtable h1 = new Hashtable<>(); + final Hashtable h2 = new Hashtable<>(); + final TestBarrier testStart = new TestBarrier(3); + + // Populate the hashtables so that they refer to each other + h1.put(testStart, h2); + h2.put(testStart, h1); + + final CyclicBarrier testEnd = new CyclicBarrier(3); + final TestThread t1 = new TestThread(h1, testEnd); + final TestThread t2 = new TestThread(h2, testEnd); + + t1.start(); + t2.start(); + + // Wait for both test threads to have initiated serialization + // of the 'testStart' object (and hence of both 'h1' and 'h2') + testStart.await(); + + // Wait for both test threads to successfully finish serialization + // of 'h1' and 'h2'. + System.out.println("Waiting for Hashtable serialization to complete ..."); + System.out.println("(This test will hang if serialization deadlocks)"); + testEnd.await(); + System.out.println("Test PASSED: serialization completed successfully"); + + TestThread.handleExceptions(); + } + + static final class TestBarrier extends CyclicBarrier + implements Serializable { + public TestBarrier(final int count) { + super(count); + } + + private void writeObject(final ObjectOutputStream oos) + throws IOException { + oos.defaultWriteObject(); + // Wait until all test threads have started serializing data + try { + await(); + } catch (final Exception e) { + throw new IOException("Test ERROR: Unexpected exception caught", e); + } + } + } + + static final class TestThread extends Thread { + private static final List exceptions = new ArrayList<>(); + + private final Hashtable hashtable; + private final CyclicBarrier testEnd; + + public TestThread(final Hashtable hashtable, + final CyclicBarrier testEnd) { + this.hashtable = hashtable; + this.testEnd = testEnd; + setDaemon(true); + } + + public void run() { + try { + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(baos); + + oos.writeObject(hashtable); + oos.close(); + } catch (final IOException ioe) { + addException(ioe); + } finally { + try { + testEnd.await(); + } catch (Exception e) { + addException(e); + } + } + } + + private static synchronized void addException(final Exception exception) { + exceptions.add(exception); + } + + public static synchronized void handleExceptions() { + if (false == exceptions.isEmpty()) { + throw new RuntimeException(getErrorText(exceptions)); + } + } + + private static String getErrorText(final List exceptions) { + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); + + pw.println("Test ERROR: Unexpected exceptions thrown on test threads:"); + for (Exception exception : exceptions) { + pw.print("\t"); + pw.println(exception); + for (StackTraceElement element : exception.getStackTrace()) { + pw.print("\t\tat "); + pw.println(element); + } + } + + pw.close(); + return sw.toString(); + } + } +} + diff --git a/jdk/test/java/util/Hashtable/SimpleSerialization.java b/jdk/test/java/util/Hashtable/SimpleSerialization.java new file mode 100644 index 00000000000..257cf105b57 --- /dev/null +++ b/jdk/test/java/util/Hashtable/SimpleSerialization.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2010, 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. + * + * ------------------------------------------- + * + * Portions Copyright (c) 2010, 2011 IBM Corporation + */ + +/* + * @test + * @bug 6927486 + * @summary A serialized Hashtable can be de-serialized properly. + * @author Neil Richards , + */ + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Hashtable; + +public class SimpleSerialization { + public static void main(final String[] args) throws Exception { + Hashtable h1 = new Hashtable<>(); + + h1.put("key", "value"); + + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final ObjectOutputStream oos = new ObjectOutputStream(baos); + + oos.writeObject(h1); + oos.close(); + + final byte[] data = baos.toByteArray(); + final ByteArrayInputStream bais = new ByteArrayInputStream(data); + final ObjectInputStream ois = new ObjectInputStream(bais); + + final Object deserializedObject = ois.readObject(); + ois.close(); + + if (false == h1.equals(deserializedObject)) { + throw new RuntimeException(getFailureText(h1, deserializedObject)); + } + } + + private static String getFailureText(final Object orig, final Object copy) { + final StringWriter sw = new StringWriter(); + final PrintWriter pw = new PrintWriter(sw); + + pw.println("Test FAILED: Deserialized object is not equal to the original object"); + pw.print("\tOriginal: "); + printObject(pw, orig).println(); + pw.print("\tCopy: "); + printObject(pw, copy).println(); + + pw.close(); + return sw.toString(); + } + + private static PrintWriter printObject(final PrintWriter pw, final Object o) { + pw.printf("%s@%08x", o.getClass().getName(), System.identityHashCode(o)); + return pw; + } +} From ce7292003a1f2c0faf51eb675f9a3f315b93ddbf Mon Sep 17 00:00:00 2001 From: Xue-Lei Andrew Fan Date: Mon, 14 Feb 2011 13:31:13 -0800 Subject: [PATCH 053/105] 7018897: CertPath validation cannot handle self-signed cert with bad KeyUsage Remove KeyUsage checking for trust anchors Reviewed-by: mullan --- .../security/provider/certpath/PKIXCertPathValidator.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/jdk/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java b/jdk/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java index a4f83c87bbb..63989de46ee 100644 --- a/jdk/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java +++ b/jdk/src/share/classes/sun/security/provider/certpath/PKIXCertPathValidator.java @@ -231,13 +231,6 @@ public class PKIXCertPathValidator extends CertPathValidatorSpi { AdaptableX509CertSelector issuerSelector = new AdaptableX509CertSelector(); - // check trusted certificate's key usage - boolean[] usages = trustedCert.getKeyUsage(); - if (usages != null) { - usages[5] = true; // keyCertSign - issuerSelector.setKeyUsage(usages); - } - // check trusted certificate's subject issuerSelector.setSubject(firstCert.getIssuerX500Principal()); From 511e9c3dcbfe43c2bc320d1fab4d2b6cd3f14b17 Mon Sep 17 00:00:00 2001 From: Kelly O'Hair Date: Mon, 14 Feb 2011 14:27:47 -0800 Subject: [PATCH 054/105] 7008433: Minor copyright changes Reviewed-by: jjg --- langtools/test/tools/javac/4917091/Test255.java | 8 ++++---- langtools/test/tools/javac/4917091/Test256a.java | 8 ++++---- langtools/test/tools/javac/4917091/Test256b.java | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/langtools/test/tools/javac/4917091/Test255.java b/langtools/test/tools/javac/4917091/Test255.java index af143912615..24c2b244266 100644 --- a/langtools/test/tools/javac/4917091/Test255.java +++ b/langtools/test/tools/javac/4917091/Test255.java @@ -1,5 +1,5 @@ /* - * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 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 @@ -16,9 +16,9 @@ * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * Please 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/langtools/test/tools/javac/4917091/Test256a.java b/langtools/test/tools/javac/4917091/Test256a.java index b0f9ae6d7ca..e00857315bf 100644 --- a/langtools/test/tools/javac/4917091/Test256a.java +++ b/langtools/test/tools/javac/4917091/Test256a.java @@ -1,5 +1,5 @@ /* - * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 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 @@ -16,9 +16,9 @@ * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * Please 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/langtools/test/tools/javac/4917091/Test256b.java b/langtools/test/tools/javac/4917091/Test256b.java index fd247fa8757..84b74250622 100644 --- a/langtools/test/tools/javac/4917091/Test256b.java +++ b/langtools/test/tools/javac/4917091/Test256b.java @@ -1,5 +1,5 @@ /* - * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. + * Copyright (c) 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 @@ -16,9 +16,9 @@ * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. */ /* From 74c63197eb1200e703e4f70c862835071cc215b7 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Mon, 14 Feb 2011 19:27:36 -0500 Subject: [PATCH 055/105] 7018429: JPRT: Update Makefile to use ALT_JDK_TARGET_IMPORT_PATH for copying JDK Set JDK_IMPORT_PATH to ALT_JDK_TARGET_IMPORT_PATH if it is defined Reviewed-by: phh, ohair --- hotspot/make/Makefile | 3 ++- hotspot/make/defs.make | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hotspot/make/Makefile b/hotspot/make/Makefile index fd46aeef087..64f9f0b60c3 100644 --- a/hotspot/make/Makefile +++ b/hotspot/make/Makefile @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 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 @@ -43,6 +43,7 @@ # 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 # ALT_BUILD_WIN_SA Building SA on Windows is disabled by default. # Set ALT_BUILD_WIN_SA=1 to enable building SA on # Windows. diff --git a/hotspot/make/defs.make b/hotspot/make/defs.make index 48b91684ba7..fe6c4a27bb3 100644 --- a/hotspot/make/defs.make +++ b/hotspot/make/defs.make @@ -1,5 +1,5 @@ # -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# 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 @@ -162,6 +162,13 @@ 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/$(PREVIOUS_JDK_VERSION)/latest/binaries/$(PLATFORM) ifneq ($(ALT_BOOTDIR),) From d4fbb08ec06a9541acf65fd93d2c0a037a63dce4 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Tue, 15 Feb 2011 12:11:15 +0800 Subject: [PATCH 056/105] 7018928: test failure: sun/security/krb5/auto/SSL.java Reviewed-by: valeriep --- jdk/test/sun/security/krb5/auto/BadKdc1.java | 4 ++-- jdk/test/sun/security/krb5/auto/BadKdc2.java | 4 ++-- jdk/test/sun/security/krb5/auto/BadKdc3.java | 4 ++-- jdk/test/sun/security/krb5/auto/BadKdc4.java | 4 ++-- .../sun/security/krb5/auto/CleanState.java | 3 ++- .../sun/security/krb5/auto/CrossRealm.java | 3 ++- .../krb5/auto/HttpNegotiateServer.java | 3 ++- .../krb5/auto/IgnoreChannelBinding.java | 3 ++- .../krb5/auto/KerberosHashEqualsTest.java | 3 ++- .../security/krb5/auto/LifeTimeInSeconds.java | 3 ++- .../krb5/auto/LoginModuleOptions.java | 3 ++- .../sun/security/krb5/auto/MaxRetries.java | 4 ++-- jdk/test/sun/security/krb5/auto/MoreKvno.java | 3 ++- jdk/test/sun/security/krb5/auto/NewSalt.java | 4 ++-- .../security/krb5/auto/NonMutualSpnego.java | 3 ++- jdk/test/sun/security/krb5/auto/SSL.java | 22 +++++++++---------- .../security/krb5/auto/SpnegoReqFlags.java | 3 ++- jdk/test/sun/security/krb5/auto/Test5653.java | 3 ++- 18 files changed, 45 insertions(+), 34 deletions(-) diff --git a/jdk/test/sun/security/krb5/auto/BadKdc1.java b/jdk/test/sun/security/krb5/auto/BadKdc1.java index 524e6d32e67..a4f52b490e2 100644 --- a/jdk/test/sun/security/krb5/auto/BadKdc1.java +++ b/jdk/test/sun/security/krb5/auto/BadKdc1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -24,7 +24,7 @@ /* * @test * @bug 6843127 - * @run main/timeout=300 BadKdc1 + * @run main/othervm/timeout=300 BadKdc1 * @summary krb5 should not try to access unavailable kdc too often */ diff --git a/jdk/test/sun/security/krb5/auto/BadKdc2.java b/jdk/test/sun/security/krb5/auto/BadKdc2.java index 88b7b0cdf7b..9a556429293 100644 --- a/jdk/test/sun/security/krb5/auto/BadKdc2.java +++ b/jdk/test/sun/security/krb5/auto/BadKdc2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -24,7 +24,7 @@ /* * @test * @bug 6843127 - * @run main/timeout=300 BadKdc2 + * @run main/othervm/timeout=300 BadKdc2 * @summary krb5 should not try to access unavailable kdc too often */ diff --git a/jdk/test/sun/security/krb5/auto/BadKdc3.java b/jdk/test/sun/security/krb5/auto/BadKdc3.java index 95399b072c3..c9ce4db3827 100644 --- a/jdk/test/sun/security/krb5/auto/BadKdc3.java +++ b/jdk/test/sun/security/krb5/auto/BadKdc3.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -24,7 +24,7 @@ /* * @test * @bug 6843127 - * @run main/timeout=300 BadKdc3 + * @run main/othervm/timeout=300 BadKdc3 * @summary krb5 should not try to access unavailable kdc too often */ diff --git a/jdk/test/sun/security/krb5/auto/BadKdc4.java b/jdk/test/sun/security/krb5/auto/BadKdc4.java index 3a148712c05..eef77f282c4 100644 --- a/jdk/test/sun/security/krb5/auto/BadKdc4.java +++ b/jdk/test/sun/security/krb5/auto/BadKdc4.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -24,7 +24,7 @@ /* * @test * @bug 6843127 - * @run main/timeout=300 BadKdc4 + * @run main/othervm/timeout=300 BadKdc4 * @summary krb5 should not try to access unavailable kdc too often */ diff --git a/jdk/test/sun/security/krb5/auto/CleanState.java b/jdk/test/sun/security/krb5/auto/CleanState.java index 316a730edfe..fbd8785cbab 100644 --- a/jdk/test/sun/security/krb5/auto/CleanState.java +++ b/jdk/test/sun/security/krb5/auto/CleanState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -24,6 +24,7 @@ /* * @test * @bug 6716534 + * @run main/othervm CleanState * @summary Krb5LoginModule has not cleaned temp info between authentication attempts */ import com.sun.security.auth.module.Krb5LoginModule; diff --git a/jdk/test/sun/security/krb5/auto/CrossRealm.java b/jdk/test/sun/security/krb5/auto/CrossRealm.java index 8b7ecc3d6ee..ecaafedaa62 100644 --- a/jdk/test/sun/security/krb5/auto/CrossRealm.java +++ b/jdk/test/sun/security/krb5/auto/CrossRealm.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -24,6 +24,7 @@ /* * @test * @bug 6706974 + * @run main/othervm CrossRealm * @summary Add krb5 test infrastructure */ import java.io.File; diff --git a/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java b/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java index e25e60d6ab5..423ef0d853d 100644 --- a/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java +++ b/jdk/test/sun/security/krb5/auto/HttpNegotiateServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -24,6 +24,7 @@ /* * @test * @bug 6578647 6829283 + * @run main/othervm HttpNegotiateServer * @summary Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication() * @summary HTTP/Negotiate: Authenticator triggered again when user cancels the first one */ diff --git a/jdk/test/sun/security/krb5/auto/IgnoreChannelBinding.java b/jdk/test/sun/security/krb5/auto/IgnoreChannelBinding.java index 0995fd8ed61..e2641a9a4f9 100644 --- a/jdk/test/sun/security/krb5/auto/IgnoreChannelBinding.java +++ b/jdk/test/sun/security/krb5/auto/IgnoreChannelBinding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -24,6 +24,7 @@ /* * @test * @bug 6851973 + * @run main/othervm IgnoreChannelBinding * @summary ignore incoming channel binding if acceptor does not set one */ diff --git a/jdk/test/sun/security/krb5/auto/KerberosHashEqualsTest.java b/jdk/test/sun/security/krb5/auto/KerberosHashEqualsTest.java index b6cd147f6cf..e7c026dab03 100644 --- a/jdk/test/sun/security/krb5/auto/KerberosHashEqualsTest.java +++ b/jdk/test/sun/security/krb5/auto/KerberosHashEqualsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -24,6 +24,7 @@ /* * @test * @bug 4641821 + * @run main/othervm KerberosHashEqualsTest * @summary hashCode() and equals() for KerberosKey and KerberosTicket */ diff --git a/jdk/test/sun/security/krb5/auto/LifeTimeInSeconds.java b/jdk/test/sun/security/krb5/auto/LifeTimeInSeconds.java index 9f948cc8e67..9c518ff6cbb 100644 --- a/jdk/test/sun/security/krb5/auto/LifeTimeInSeconds.java +++ b/jdk/test/sun/security/krb5/auto/LifeTimeInSeconds.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -24,6 +24,7 @@ /* * @test * @bug 6857802 + * @run main/othervm LifeTimeInSeconds * @summary GSS getRemainingInitLifetime method returns milliseconds not seconds */ import org.ietf.jgss.GSSCredential; diff --git a/jdk/test/sun/security/krb5/auto/LoginModuleOptions.java b/jdk/test/sun/security/krb5/auto/LoginModuleOptions.java index f22f774316f..a6dd33b8029 100644 --- a/jdk/test/sun/security/krb5/auto/LoginModuleOptions.java +++ b/jdk/test/sun/security/krb5/auto/LoginModuleOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -24,6 +24,7 @@ /* * @test * @bug 6765491 + * @run main/othervm LoginModuleOptions * @summary Krb5LoginModule a little too restrictive, and the doc is not clear. */ import com.sun.security.auth.module.Krb5LoginModule; diff --git a/jdk/test/sun/security/krb5/auto/MaxRetries.java b/jdk/test/sun/security/krb5/auto/MaxRetries.java index 4f13878c98d..fec1bec68a6 100644 --- a/jdk/test/sun/security/krb5/auto/MaxRetries.java +++ b/jdk/test/sun/security/krb5/auto/MaxRetries.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -24,7 +24,7 @@ /* * @test * @bug 6844193 - * @run main/timeout=300 MaxRetries + * @run main/othervm/timeout=300 MaxRetries * @summary support max_retries in krb5.conf */ diff --git a/jdk/test/sun/security/krb5/auto/MoreKvno.java b/jdk/test/sun/security/krb5/auto/MoreKvno.java index 84cfa362d0d..20cac93d0a0 100644 --- a/jdk/test/sun/security/krb5/auto/MoreKvno.java +++ b/jdk/test/sun/security/krb5/auto/MoreKvno.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -25,6 +25,7 @@ * @test * @bug 6893158 * @bug 6907425 + * @run main/othervm MoreKvno * @summary AP_REQ check should use key version number */ diff --git a/jdk/test/sun/security/krb5/auto/NewSalt.java b/jdk/test/sun/security/krb5/auto/NewSalt.java index 54cc9562f37..2a0a17fcd9f 100644 --- a/jdk/test/sun/security/krb5/auto/NewSalt.java +++ b/jdk/test/sun/security/krb5/auto/NewSalt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -25,7 +25,7 @@ * @test * @bug 6960894 * @summary Better AS-REQ creation and processing - * @run main NewSalt + * @run main/othervm NewSalt * @run main/othervm -Dnopreauth NewSalt * @run main/othervm -Donlyonepreauth NewSalt */ diff --git a/jdk/test/sun/security/krb5/auto/NonMutualSpnego.java b/jdk/test/sun/security/krb5/auto/NonMutualSpnego.java index f5b387b1186..304dca1be89 100644 --- a/jdk/test/sun/security/krb5/auto/NonMutualSpnego.java +++ b/jdk/test/sun/security/krb5/auto/NonMutualSpnego.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -24,6 +24,7 @@ /* * @test * @bug 6733095 + * @run main/othervm NonMutualSpnego * @summary Failure when SPNEGO request non-Mutual */ diff --git a/jdk/test/sun/security/krb5/auto/SSL.java b/jdk/test/sun/security/krb5/auto/SSL.java index 1deae8e6f16..7bd4601481e 100644 --- a/jdk/test/sun/security/krb5/auto/SSL.java +++ b/jdk/test/sun/security/krb5/auto/SSL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -25,16 +25,16 @@ * @test * @bug 6894643 6913636 * @summary Test JSSE Kerberos ciphersuite - * @run main SSL TLS_KRB5_WITH_RC4_128_SHA - * @run main SSL TLS_KRB5_WITH_RC4_128_MD5 - * @run main SSL TLS_KRB5_WITH_3DES_EDE_CBC_SHA - * @run main SSL TLS_KRB5_WITH_3DES_EDE_CBC_MD5 - * @run main SSL TLS_KRB5_WITH_DES_CBC_SHA - * @run main SSL TLS_KRB5_WITH_DES_CBC_MD5 - * @run main SSL TLS_KRB5_EXPORT_WITH_RC4_40_SHA - * @run main SSL TLS_KRB5_EXPORT_WITH_RC4_40_MD5 - * @run main SSL TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA - * @run main SSL TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 + * @run main/othervm SSL TLS_KRB5_WITH_RC4_128_SHA + * @run main/othervm SSL TLS_KRB5_WITH_RC4_128_MD5 + * @run main/othervm SSL TLS_KRB5_WITH_3DES_EDE_CBC_SHA + * @run main/othervm SSL TLS_KRB5_WITH_3DES_EDE_CBC_MD5 + * @run main/othervm SSL TLS_KRB5_WITH_DES_CBC_SHA + * @run main/othervm SSL TLS_KRB5_WITH_DES_CBC_MD5 + * @run main/othervm SSL TLS_KRB5_EXPORT_WITH_RC4_40_SHA + * @run main/othervm SSL TLS_KRB5_EXPORT_WITH_RC4_40_MD5 + * @run main/othervm SSL TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA + * @run main/othervm SSL TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5 */ import java.io.*; import java.net.InetAddress; diff --git a/jdk/test/sun/security/krb5/auto/SpnegoReqFlags.java b/jdk/test/sun/security/krb5/auto/SpnegoReqFlags.java index 75d6b884bbb..62c55048d1f 100644 --- a/jdk/test/sun/security/krb5/auto/SpnegoReqFlags.java +++ b/jdk/test/sun/security/krb5/auto/SpnegoReqFlags.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -24,6 +24,7 @@ /* * @test * @bug 6815182 + * @run main/othervm SpnegoReqFlags * @summary GSSAPI/SPNEGO does not work with server using MIT Kerberos library */ diff --git a/jdk/test/sun/security/krb5/auto/Test5653.java b/jdk/test/sun/security/krb5/auto/Test5653.java index 71fc92b823f..4384b87ee0b 100644 --- a/jdk/test/sun/security/krb5/auto/Test5653.java +++ b/jdk/test/sun/security/krb5/auto/Test5653.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -24,6 +24,7 @@ /* * @test * @bug 6895424 + * @run main/othervm Test5653 * @summary RFC 5653 */ From 77f10a1c5f2624c93a1c92daacaa7163668346c3 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 15 Feb 2011 11:49:46 +0000 Subject: [PATCH 057/105] 7017664: Add listeners infrastracture to javac scopes Add listeners to javac scopes, added CompoundScope and correct invalidation logic for ImplementationCache Reviewed-by: jjg --- .../com/sun/tools/javac/code/Scope.java | 202 ++++++++++++++++- .../com/sun/tools/javac/code/Symbol.java | 2 +- .../com/sun/tools/javac/code/Types.java | 52 ++--- .../com/sun/tools/javac/comp/Check.java | 29 ++- .../scope/7017664/CompoundScopeTest.java | 212 ++++++++++++++++++ .../7017664/ImplementationCacheTest.java | 129 +++++++++++ 6 files changed, 575 insertions(+), 51 deletions(-) create mode 100644 langtools/test/tools/javac/scope/7017664/CompoundScopeTest.java create mode 100644 langtools/test/tools/javac/scope/7017664/ImplementationCacheTest.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java index 51c467858ae..066715f582b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java @@ -74,7 +74,7 @@ public class Scope { /** A list of scopes to be notified if items are to be removed from this scope. */ - List listeners = List.nil(); + List listeners = List.nil(); /** Use as a "not-found" result for lookup. * Also used to mark deleted entries in the table. @@ -219,12 +219,27 @@ public class Scope { Entry e = makeEntry(sym, old, elems, s, origin); table[hash] = e; elems = e; + + //notify listeners + for (List l = listeners; l.nonEmpty(); l = l.tail) { + l.head.symbolAdded(sym, this); + } } Entry makeEntry(Symbol sym, Entry shadowed, Entry sibling, Scope scope, Scope origin) { return new Entry(sym, shadowed, sibling, scope); } + + public interface ScopeListener { + public void symbolAdded(Symbol sym, Scope s); + public void symbolRemoved(Symbol sym, Scope s); + } + + public void addScopeListener(ScopeListener sl) { + listeners = listeners.prepend(sl); + } + /** Remove symbol from this scope. Used when an inner class * attribute tells us that the class isn't a package member. */ @@ -258,9 +273,9 @@ public class Scope { te = te.sibling; } - // remove items from scopes that have done importAll - for (List l = listeners; l.nonEmpty(); l = l.tail) { - l.head.remove(sym); + //notify listeners + for (List l = listeners; l.nonEmpty(); l = l.tail) { + l.head.symbolRemoved(sym, this); } } @@ -393,7 +408,32 @@ public class Scope { }; } }; + } + public Iterable getElementsByName(Name name) { + return getElementsByName(name, noFilter); + } + + public Iterable getElementsByName(final Name name, final Filter sf) { + return new Iterable() { + public Iterator iterator() { + return new Iterator() { + Scope.Entry currentEntry = lookup(name, sf); + + public boolean hasNext() { + return currentEntry.scope != null; + } + public Symbol next() { + Scope.Entry prevEntry = currentEntry; + currentEntry = currentEntry.next(sf); + return prevEntry.sym; + } + public void remove() { + throw new UnsupportedOperationException(); + } + }; + } + }; } public String toString() { @@ -488,7 +528,7 @@ public class Scope { } } - public static class StarImportScope extends ImportScope { + public static class StarImportScope extends ImportScope implements ScopeListener { public StarImportScope(Symbol owner) { super(owner); @@ -500,8 +540,13 @@ public class Scope { enter(e.sym, fromScope); } // Register to be notified when imported items are removed - fromScope.listeners = fromScope.listeners.prepend(this); + fromScope.addScopeListener(this); } + + public void symbolRemoved(Symbol sym, Scope s) { + remove(sym); + } + public void symbolAdded(Symbol sym, Scope s) { } } /** An empty scope, into which you can't place anything. Used for @@ -538,6 +583,151 @@ public class Scope { } } + /** A class scope adds capabilities to keep track of changes in related + * class scopes - this allows client to realize whether a class scope + * has changed, either directly (because a new member has been added/removed + * to this scope) or indirectly (i.e. because a new member has been + * added/removed into a supertype scope) + */ + public static class CompoundScope extends Scope implements ScopeListener { + + public static final Entry[] emptyTable = new Entry[0]; + + private List subScopes = List.nil(); + private int mark = 0; + + public CompoundScope(Symbol owner) { + super(null, owner, emptyTable); + } + + public void addSubScope(Scope that) { + if (that != null) { + subScopes = subScopes.prepend(that); + that.addScopeListener(this); + mark++; + for (ScopeListener sl : listeners) { + sl.symbolAdded(null, this); //propagate upwards in case of nested CompoundScopes + } + } + } + + public void symbolAdded(Symbol sym, Scope s) { + mark++; + for (ScopeListener sl : listeners) { + sl.symbolAdded(sym, s); + } + } + + public void symbolRemoved(Symbol sym, Scope s) { + mark++; + for (ScopeListener sl : listeners) { + sl.symbolRemoved(sym, s); + } + } + + public int getMark() { + return mark; + } + + @Override + public String toString() { + StringBuilder buf = new StringBuilder(); + buf.append("CompoundScope{"); + String sep = ""; + for (Scope s : subScopes) { + buf.append(sep); + buf.append(s); + sep = ","; + } + buf.append("}"); + return buf.toString(); + } + + @Override + public Iterable getElements(final Filter sf) { + return new Iterable() { + public Iterator iterator() { + return new CompoundScopeIterator(subScopes) { + Iterator nextIterator(Scope s) { + return s.getElements().iterator(); + } + }; + } + }; + } + + @Override + public Iterable getElementsByName(final Name name, final Filter sf) { + return new Iterable() { + public Iterator iterator() { + return new CompoundScopeIterator(subScopes) { + Iterator nextIterator(Scope s) { + return s.getElementsByName(name, sf).iterator(); + } + }; + } + }; + } + + abstract class CompoundScopeIterator implements Iterator { + + private Iterator currentIterator; + private List scopesToScan; + + public CompoundScopeIterator(List scopesToScan) { + this.scopesToScan = scopesToScan; + update(); + } + + abstract Iterator nextIterator(Scope s); + + public boolean hasNext() { + return currentIterator != null; + } + + public Symbol next() { + Symbol sym = currentIterator.next(); + if (!currentIterator.hasNext()) { + update(); + } + return sym; + } + + public void remove() { + throw new UnsupportedOperationException(); + } + + private void update() { + while (scopesToScan.nonEmpty()) { + currentIterator = nextIterator(scopesToScan.head); + scopesToScan = scopesToScan.tail; + if (currentIterator.hasNext()) return; + } + currentIterator = null; + } + } + + @Override + public Entry lookup(Name name, Filter sf) { + throw new UnsupportedOperationException(); + } + + @Override + public Scope dup(Symbol newOwner) { + throw new UnsupportedOperationException(); + } + + @Override + public void enter(Symbol sym, Scope s, Scope origin) { + throw new UnsupportedOperationException(); + } + + @Override + public void remove(Symbol sym) { + throw new UnsupportedOperationException(); + } + } + /** An error scope, for which the owner should be an error symbol. */ public static class ErrorScope extends Scope { ErrorScope(Scope next, Symbol errSymbol, Entry[] table) { diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java index 04424145a88..27c914d8642 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Symbol.java @@ -731,7 +731,7 @@ public abstract class Symbol implements Element { /** members closure cache (set by Types.membersClosure) */ - Scope membersClosure; + Scope.CompoundScope membersClosure; public ClassSymbol(long flags, Name name, Type type, Symbol owner) { super(flags, name, type, owner); diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index 56e8172c9c5..f3674ee0a66 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -2023,18 +2023,22 @@ public class Types { final MethodSymbol cachedImpl; final Filter implFilter; final boolean checkResult; + final int prevMark; public Entry(MethodSymbol cachedImpl, Filter scopeFilter, - boolean checkResult) { + boolean checkResult, + int prevMark) { this.cachedImpl = cachedImpl; this.implFilter = scopeFilter; this.checkResult = checkResult; + this.prevMark = prevMark; } - boolean matches(Filter scopeFilter, boolean checkResult) { + boolean matches(Filter scopeFilter, boolean checkResult, int mark) { return this.implFilter == scopeFilter && - this.checkResult == checkResult; + this.checkResult == checkResult && + this.prevMark == mark; } } @@ -2046,10 +2050,11 @@ public class Types { _map.put(ms, new SoftReference>(cache)); } Entry e = cache.get(origin); + CompoundScope members = membersClosure(origin.type); if (e == null || - !e.matches(implFilter, checkResult)) { - MethodSymbol impl = implementationInternal(ms, origin, Types.this, checkResult, implFilter); - cache.put(origin, new Entry(impl, implFilter, checkResult)); + !e.matches(implFilter, checkResult, members.getMark())) { + MethodSymbol impl = implementationInternal(ms, origin, checkResult, implFilter); + cache.put(origin, new Entry(impl, implFilter, checkResult, members.getMark())); return impl; } else { @@ -2057,8 +2062,8 @@ public class Types { } } - private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult, Filter implFilter) { - for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = types.supertype(t)) { + private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter implFilter) { + for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = supertype(t)) { while (t.tag == TYPEVAR) t = t.getUpperBound(); TypeSymbol c = t.tsym; @@ -2066,7 +2071,7 @@ public class Types { e.scope != null; e = e.next(implFilter)) { if (e.sym != null && - e.sym.overrides(ms, origin, types, checkResult)) + e.sym.overrides(ms, origin, Types.this, checkResult)) return (MethodSymbol)e.sym; } } @@ -2082,46 +2087,35 @@ public class Types { // // - public Scope membersClosure(Type site) { + public CompoundScope membersClosure(Type site) { return membersClosure.visit(site); } - UnaryVisitor membersClosure = new UnaryVisitor() { + UnaryVisitor membersClosure = new UnaryVisitor() { - public Scope visitType(Type t, Void s) { + public CompoundScope visitType(Type t, Void s) { return null; } @Override - public Scope visitClassType(ClassType t, Void s) { + public CompoundScope visitClassType(ClassType t, Void s) { ClassSymbol csym = (ClassSymbol)t.tsym; if (csym.membersClosure == null) { - Scope membersClosure = new Scope(csym); + CompoundScope membersClosure = new CompoundScope(csym); for (Type i : interfaces(t)) { - enterAll(visit(i), membersClosure); + membersClosure.addSubScope(visit(i)); } - enterAll(visit(supertype(t)), membersClosure); - enterAll(csym.members(), membersClosure); + membersClosure.addSubScope(visit(supertype(t))); + membersClosure.addSubScope(csym.members()); csym.membersClosure = membersClosure; } return csym.membersClosure; } @Override - public Scope visitTypeVar(TypeVar t, Void s) { + public CompoundScope visitTypeVar(TypeVar t, Void s) { return visit(t.getUpperBound()); } - - public void enterAll(Scope s, Scope to) { - if (s == null) return; - List syms = List.nil(); - for (Scope.Entry e = s.elems ; e != null ; e = e.sibling) { - syms = syms.prepend(e.sym); - } - for (Symbol sym : syms) { - to.enter(sym); - } - } }; // diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java index a10f8214689..81a20000e31 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java @@ -2106,32 +2106,32 @@ public class Check { void checkOverrideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) { ClashFilter cf = new ClashFilter(site); //for each method m1 that is a member of 'site'... - for (Scope.Entry e1 = types.membersClosure(site).lookup(sym.name, cf) ; - e1.scope != null ; e1 = e1.next(cf)) { + for (Symbol s1 : types.membersClosure(site).getElementsByName(sym.name, cf)) { //...find another method m2 that is overridden (directly or indirectly) //by method 'sym' in 'site' - for (Scope.Entry e2 = types.membersClosure(site).lookup(sym.name, cf) ; - e2.scope != null ; e2 = e2.next(cf)) { - if (e1.sym == e2.sym || !sym.overrides(e2.sym, site.tsym, types, false)) continue; + for (Symbol s2 : types.membersClosure(site).getElementsByName(sym.name, cf)) { + if (s1 == s2 || !sym.overrides(s2, site.tsym, types, false)) continue; //if (i) the signature of 'sym' is not a subsignature of m1 (seen as //a member of 'site') and (ii) m1 has the same erasure as m2, issue an error - if (!types.isSubSignature(sym.type, types.memberType(site, e1.sym)) && - types.hasSameArgs(e1.sym.erasure(types), e2.sym.erasure(types))) { + if (!types.isSubSignature(sym.type, types.memberType(site, s1)) && + types.hasSameArgs(s1.erasure(types), s2.erasure(types))) { sym.flags_field |= CLASH; - String key = e2.sym == sym ? + String key = s2 == sym ? "name.clash.same.erasure.no.override" : "name.clash.same.erasure.no.override.1"; log.error(pos, key, sym, sym.location(), - e1.sym, e1.sym.location(), - e2.sym, e2.sym.location()); + s1, s1.location(), + s2, s2.location()); return; } } } } + + /** Check that all static methods accessible from 'site' are * mutually compatible (JLS 8.4.8). * @@ -2142,16 +2142,15 @@ public class Check { void checkHideClashes(DiagnosticPosition pos, Type site, MethodSymbol sym) { ClashFilter cf = new ClashFilter(site); //for each method m1 that is a member of 'site'... - for (Scope.Entry e = types.membersClosure(site).lookup(sym.name, cf) ; - e.scope != null ; e = e.next(cf)) { + for (Symbol s : types.membersClosure(site).getElementsByName(sym.name, cf)) { //if (i) the signature of 'sym' is not a subsignature of m1 (seen as //a member of 'site') and (ii) 'sym' has the same erasure as m1, issue an error - if (!types.isSubSignature(sym.type, types.memberType(site, e.sym)) && - types.hasSameArgs(e.sym.erasure(types), sym.erasure(types))) { + if (!types.isSubSignature(sym.type, types.memberType(site, s)) && + types.hasSameArgs(s.erasure(types), sym.erasure(types))) { log.error(pos, "name.clash.same.erasure.no.hide", sym, sym.location(), - e.sym, e.sym.location()); + s, s.location()); return; } } diff --git a/langtools/test/tools/javac/scope/7017664/CompoundScopeTest.java b/langtools/test/tools/javac/scope/7017664/CompoundScopeTest.java new file mode 100644 index 00000000000..a6e1065670e --- /dev/null +++ b/langtools/test/tools/javac/scope/7017664/CompoundScopeTest.java @@ -0,0 +1,212 @@ +/* + * 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. + */ + +/* + * @test + * @bug 7017664 + * @summary Basher for CompoundScopes + */ + +import java.util.Random; +import java.util.Map; +import java.util.HashMap; +import com.sun.tools.javac.util.*; +import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Scope.*; +import com.sun.tools.javac.code.Symbol.*; +import com.sun.tools.javac.file.JavacFileManager; + +public class CompoundScopeTest { + public static void main(String... args) throws Exception { + new CompoundScopeTest().run(args); + } + + static final int MAX_SYMBOLS_COUNT = 20; + static final int PASSES = 10; + + void run(String... args) throws Exception { + int count = PASSES; + + for (int i = 0; i < args.length; i++) { + String arg = args[i]; + if (arg.equals("-seed") && (i + 1 < args.length)) + seed = Long.parseLong(args[++i]); + else if(arg.equals("-tests") && (i + 1 < args.length)) + count = Integer.parseInt(args[++i]); + else + throw new Exception("unknown arg: " + arg); + } + + rgen = new Random(seed); + + for (int i = 0; i < count; i++) { + Test t = new Test(); + t.run(); + } + + if (errors > 0) + throw new Exception(errors + " errors found"); + } + + /** + * Write a message to stderr. + */ + void log(String msg) { + System.err.println(msg); + } + + /** + * Write an error message to stderr. + */ + void error(String msg) { + System.err.println("Error: " + msg); + errors++; + } + + Random rgen; + long seed = 0; + + int errors; + + /** Class to encapsulate a test run. */ + class Test { + + List elems = List.nil(); + Map> shadowedMap = new HashMap>(); + + /** Run the test. */ + void run() throws Exception { + log ("starting test"); + setup(); + Scope[] scopes = { createScope(rgen.nextInt(MAX_SYMBOLS_COUNT)), + createScope(rgen.nextInt(MAX_SYMBOLS_COUNT)), + createScope(rgen.nextInt(MAX_SYMBOLS_COUNT)) }; + boolean[][] scopeNesting = { {false, true, false, true}, + {false, true, true, true}, + {false, false, true, true} }; + /** + * We want to generate (and check) the following compound scopes: + * C1 = C(S1, S2, S3) + * C2 = C((S1, S2), S3) + * C3 = C(S1, (S2, S3)) + * C3 = C(C(S1, S2, S3)) + */ + for (int i = 0 ; i < 4 ; i ++) { + CompoundScope root = new CompoundScope(symtab.noSymbol); + CompoundScope sub = new CompoundScope(symtab.noSymbol); + boolean subAdded = false; + for (int sc = 0 ; sc < 3 ; sc ++) { + if (scopeNesting[sc][i]) { + sub.addSubScope(scopes[sc]); + if (!subAdded) { + root.addSubScope(sub); + subAdded = true; + } + } else { + root.addSubScope(scopes[sc]); + } + } + log("testing scope: " + root); + checkElems(root); + checkShadowed(root); + } + } + + /** + * Create a scope containing a given number of synthetic symbols + */ + Scope createScope(int nelems) { + Scope s = new Scope(symtab.noSymbol); + for (int i = 0 ; i < nelems ; i++) { + Symbol sym = new TypeSymbol(0, names.fromString("s" + i), null, null); + s.enter(sym); + elems = elems.prepend(sym); + List shadowed = shadowedMap.get(sym.name); + if (shadowed == null) { + shadowed = List.nil(); + } + shadowedMap.put(sym.name, shadowed.prepend(sym)); + } + return s; + } + + /** + * Setup compiler context + */ + void setup() { + log ("setup"); + context = new Context(); + JavacFileManager.preRegister(context); // required by ClassReader which is required by Symtab + names = Names.instance(context); // Name.Table impls tied to an instance of Names + symtab = Symtab.instance(context); + } + + /** + * Check that CompoundScope.getElements() correctly visits all symbols + * in all subscopes (in the correct order) + */ + void checkElems(CompoundScope cs) { + List allSymbols = elems; + int count = 0; + for (Symbol s : cs.getElements()) { + checkSameSymbols(s, allSymbols.head); + allSymbols = allSymbols.tail; + count++; + } + if (count != elems.size()) { + error("CompoundScope.getElements() did not returned enough symbols"); + } + } + + /** + * Check that CompoundScope.getElements() correctly visits all symbols + * with a given name in all subscopes (in the correct order) + */ + void checkShadowed(CompoundScope cs) { + for (Map.Entry> shadowedEntry : shadowedMap.entrySet()) { + int count = 0; + List shadowed = shadowedEntry.getValue(); + Name name = shadowedEntry.getKey(); + for (Symbol s : cs.getElementsByName(name)) { + checkSameSymbols(s, shadowed.head); + shadowed = shadowed.tail; + count++; + } + if (count != shadowedEntry.getValue().size()) { + error("CompoundScope.lookup() did not returned enough symbols for name " + name); + } + } + } + + void checkSameSymbols(Symbol found, Symbol req) { + if (found != req) { + error("Symbol mismatch - found : " + found + ":" + found.hashCode() + "\n" + + " required : " + req + ":" + req.hashCode()); + } + } + + Context context; + Symtab symtab; + Names names; + } +} diff --git a/langtools/test/tools/javac/scope/7017664/ImplementationCacheTest.java b/langtools/test/tools/javac/scope/7017664/ImplementationCacheTest.java new file mode 100644 index 00000000000..3654ad3dcab --- /dev/null +++ b/langtools/test/tools/javac/scope/7017664/ImplementationCacheTest.java @@ -0,0 +1,129 @@ +/* + * 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. + */ + +/* + * @test + * @bug 7017664 + * @summary Basher for CompoundScopes + */ + +import com.sun.source.util.JavacTask; +import com.sun.tools.javac.code.Symbol; +import com.sun.tools.javac.code.Types; +import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.util.Context; + +import com.sun.tools.javac.code.Symbol.*; + +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; +import java.util.List; +import javax.lang.model.element.Element; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +import static javax.tools.JavaFileObject.Kind; + +public class ImplementationCacheTest { + + static class SourceFile extends SimpleJavaFileObject { + + final String source = "interface I { void m(); }\n" + + "class A implements I { public void m() {} }\n" + + "class B extends A { }\n"; + + public SourceFile() { + super(URI.create("test.java"), Kind.SOURCE); + } + + public CharSequence getCharContent(boolean ignoreEncodingErrors) { + return source; + } + } + + public static void main(String[] args) throws IOException { + List files = Arrays.asList(new SourceFile()); + JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); + JavacTask ct = (JavacTask)tool.getTask(null, null, null, null, null, files); + Context ctx = new Context(); + JavacFileManager.preRegister(ctx); + checkImplementationCache(ct.analyze(), Types.instance(ctx)); + } + + static void checkImplementationCache(Iterable elements, Types types) { + if (types == null) { + throw new AssertionError("problems initializing Types"); + } + + Symbol a = null; + Symbol b = null; + Symbol i = null; + + for (Element e : elements) { + if (e.getSimpleName().contentEquals("A")) { + a = (Symbol)e; + } else if (e.getSimpleName().contentEquals("B")) { + b = (Symbol)e; + } else if (e.getSimpleName().contentEquals("I")) { + i = (Symbol)e; + } + } + + if (a == null || b == null || i == null) { + throw new AssertionError("missing class"); + } + + MethodSymbol I_m = null; + + for (Symbol sym : i.members().getElements()) { + if (sym.name.contentEquals("m")) { + I_m = (MethodSymbol)sym; + } + } + + if (I_m == null) { + throw new AssertionError("missing method m() in scope of interface I"); + } + + Symbol impl = I_m.implementation((TypeSymbol)b, types, true); + + if (impl == null || impl.owner != a) { + throw new AssertionError("wrong implementation for m() in B"); + } + + b.members().enter(I_m.clone(b)); + + Symbol newImpl = I_m.implementation((TypeSymbol)b, types, true); + + if (newImpl == impl) { + throw new AssertionError("stale implementation for m() in B"); + } + + if (newImpl == null || newImpl.owner != b) { + throw new AssertionError("wrong implementation for m() in B"); + } + } +} From dd20e6fdd72300d0e37a10a58b9124aaee5d9868 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Tue, 15 Feb 2011 11:51:04 +0000 Subject: [PATCH 058/105] 7017104: improve error reporting for uncaught/undeclared exceptions from try-with-resources Twr should generate better error message when uncaught exceptions are thrown by implicit call of close() method Reviewed-by: jjg --- .../com/sun/tools/javac/comp/Flow.java | 25 +++++++++----- .../tools/javac/resources/compiler.properties | 5 +++ .../TryWithResources/ResourceInterface.out | 2 +- .../tools/javac/TryWithResources/TwrFlow.out | 2 +- .../UnreportedExceptionImplicitClose.java | 33 +++++++++++++++++++ 5 files changed, 57 insertions(+), 10 deletions(-) create mode 100644 langtools/test/tools/javac/diags/examples/UnreportedExceptionImplicitClose.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java index 6b43c46d77f..c0a1827bd02 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -314,13 +314,22 @@ public class Flow extends TreeScanner { for (PendingExit exit = pendingExits.next(); exit != null; exit = pendingExits.next()) { - boolean synthetic = classDef != null && - classDef.pos == exit.tree.pos; - log.error(exit.tree.pos(), - synthetic - ? "unreported.exception.default.constructor" - : "unreported.exception.need.to.catch.or.throw", - exit.thrown); + if (classDef != null && + classDef.pos == exit.tree.pos) { + log.error(exit.tree.pos(), + "unreported.exception.default.constructor", + exit.thrown); + } else if (exit.tree.getTag() == JCTree.VARDEF && + ((JCVariableDecl)exit.tree).sym.isResourceVariable()) { + log.error(exit.tree.pos(), + "unreported.exception.implicit.close", + exit.thrown, + ((JCVariableDecl)exit.tree).sym.name); + } else { + log.error(exit.tree.pos(), + "unreported.exception.need.to.catch.or.throw", + exit.thrown); + } } } @@ -1021,7 +1030,7 @@ public class Flow extends TreeScanner { List.nil()); if (closeMethod.kind == MTH) { for (Type t : ((MethodSymbol)closeMethod).getThrownTypes()) { - markThrown(tree.body, t); + markThrown(resource, t); } } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 2945971e2e1..2e4476aa2eb 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -800,6 +800,11 @@ compiler.err.unreported.exception.need.to.catch.or.throw=\ compiler.err.unreported.exception.default.constructor=\ unreported exception {0} in default constructor +# 0: type, 1: name +compiler.err.unreported.exception.implicit.close=\ + unreported exception {0}; must be caught or declared to be thrown\n\ + exception thrown from implicit call to close() on resource variable ''{1}'' + compiler.err.unsupported.cross.fp.lit=\ hexadecimal floating-point literals are not supported on this VM diff --git a/langtools/test/tools/javac/TryWithResources/ResourceInterface.out b/langtools/test/tools/javac/TryWithResources/ResourceInterface.out index d052ba641c4..4cb21d913ce 100644 --- a/langtools/test/tools/javac/TryWithResources/ResourceInterface.out +++ b/langtools/test/tools/javac/TryWithResources/ResourceInterface.out @@ -1,2 +1,2 @@ -ResourceInterface.java:38:34: compiler.err.unreported.exception.need.to.catch.or.throw: ResourceInterface.E1 +ResourceInterface.java:38:13: compiler.err.unreported.exception.implicit.close: ResourceInterface.E1, r2 1 error diff --git a/langtools/test/tools/javac/TryWithResources/TwrFlow.out b/langtools/test/tools/javac/TryWithResources/TwrFlow.out index a91ea1aceee..f6740ae60d2 100644 --- a/langtools/test/tools/javac/TryWithResources/TwrFlow.out +++ b/langtools/test/tools/javac/TryWithResources/TwrFlow.out @@ -1,3 +1,3 @@ TwrFlow.java:14:11: compiler.err.except.never.thrown.in.try: java.io.IOException -TwrFlow.java:12:46: compiler.err.unreported.exception.need.to.catch.or.throw: CustomCloseException +TwrFlow.java:12:13: compiler.err.unreported.exception.implicit.close: CustomCloseException, twrFlow 2 errors diff --git a/langtools/test/tools/javac/diags/examples/UnreportedExceptionImplicitClose.java b/langtools/test/tools/javac/diags/examples/UnreportedExceptionImplicitClose.java new file mode 100644 index 00000000000..fcbc8a91705 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/UnreportedExceptionImplicitClose.java @@ -0,0 +1,33 @@ +/* + * 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. + */ + +// key: compiler.err.unreported.exception.implicit.close + +class UnreportedExceptionImplicitClose { + static class MyCloseable implements AutoCloseable { + public void close() throws Exception { } + } + void test() { + try (MyCloseable x = new MyCloseable()) { } + } +} From a2309c8fe0415e2533392b564b848edec500c806 Mon Sep 17 00:00:00 2001 From: Alexander Potochkin Date: Tue, 15 Feb 2011 16:40:25 +0300 Subject: [PATCH 059/105] 6956842: BasicTreeUI.getPreferredSize(JComp c) is delegated to getPreferredSize(c, true) not (c, false) Reviewed-by: rupashka --- .../share/classes/javax/swing/plaf/basic/BasicTreeUI.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java index 23e8f7dce79..fb97f12eb8c 100644 --- a/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java +++ b/jdk/src/share/classes/javax/swing/plaf/basic/BasicTreeUI.java @@ -1965,18 +1965,18 @@ public class BasicTreeUI extends TreeUI } /** Returns the preferred size to properly display the tree, - * this is a cover method for getPreferredSize(c, false). + * this is a cover method for getPreferredSize(c, true). */ public Dimension getPreferredSize(JComponent c) { return getPreferredSize(c, true); } /** Returns the preferred size to represent the tree in - * c. If checkConsistancy is true - * checkConsistancy is messaged first. + * c. If checkConsistency is true + * checkConsistency is messaged first. */ public Dimension getPreferredSize(JComponent c, - boolean checkConsistancy) { + boolean checkConsistency) { Dimension pSize = this.getPreferredMinSize(); if(!validCachedPreferredSize) From 3073a7866449c30b98dc33091fad6aaefb3c9674 Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Tue, 15 Feb 2011 15:09:20 +0000 Subject: [PATCH 060/105] 7017581: missing copyright header in test/sun/java2d/pipe/RegionOps.java Reviewed-by: anthony --- jdk/test/sun/java2d/pipe/RegionOps.java | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/jdk/test/sun/java2d/pipe/RegionOps.java b/jdk/test/sun/java2d/pipe/RegionOps.java index 30f8c223a25..e02f280b1fe 100644 --- a/jdk/test/sun/java2d/pipe/RegionOps.java +++ b/jdk/test/sun/java2d/pipe/RegionOps.java @@ -1,3 +1,26 @@ +/* + * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please 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 %W% %E% * @bug 6504874 From 0a926d8d57a6c6663dcaee15ee09ecc1329cc140 Mon Sep 17 00:00:00 2001 From: Andrei Dmitriev Date: Wed, 16 Feb 2011 01:12:53 +0300 Subject: [PATCH 061/105] 6994933: java.awt.Desktop feature is "intermittently" supported on Solaris. Really unexpected behavior Reviewed-by: art, dcherepanov --- .../classes/sun/awt/X11/XDesktopPeer.java | 35 +++++++++++++++---- jdk/src/solaris/native/sun/xawt/awt_Desktop.c | 8 ++++- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/jdk/src/solaris/classes/sun/awt/X11/XDesktopPeer.java b/jdk/src/solaris/classes/sun/awt/X11/XDesktopPeer.java index ce6ae164154..740eabac485 100644 --- a/jdk/src/solaris/classes/sun/awt/X11/XDesktopPeer.java +++ b/jdk/src/solaris/classes/sun/awt/X11/XDesktopPeer.java @@ -44,11 +44,27 @@ import java.awt.peer.DesktopPeer; public class XDesktopPeer implements DesktopPeer { private static boolean nativeLibraryLoaded = false; - static { - nativeLibraryLoaded = init(); + private static boolean initExecuted = false; + + private static void initWithLock(){ + XToolkit.awtLock(); + try { + if (!initExecuted) { + nativeLibraryLoaded = init(); + } + } finally { + initExecuted = true; + XToolkit.awtUnlock(); + } + } + + //package-private + XDesktopPeer(){ + initWithLock(); } static boolean isDesktopSupported() { + initWithLock(); return nativeLibraryLoaded; } @@ -83,12 +99,17 @@ public class XDesktopPeer implements DesktopPeer { } private void launch(URI uri) throws IOException { - if (!nativeLibraryLoaded) { - throw new IOException("Failed to load native libraries."); - } - byte[] uriByteArray = ( uri.toString() + '\0' ).getBytes(); - boolean result = gnome_url_show(uriByteArray); + boolean result = false; + XToolkit.awtLock(); + try { + if (!nativeLibraryLoaded) { + throw new IOException("Failed to load native libraries."); + } + result = gnome_url_show(uriByteArray); + } finally { + XToolkit.awtUnlock(); + } if (!result) { throw new IOException("Failed to show URI:" + uri); } diff --git a/jdk/src/solaris/native/sun/xawt/awt_Desktop.c b/jdk/src/solaris/native/sun/xawt/awt_Desktop.c index d9f9be2bf1c..69b9207bc99 100644 --- a/jdk/src/solaris/native/sun/xawt/awt_Desktop.c +++ b/jdk/src/solaris/native/sun/xawt/awt_Desktop.c @@ -48,9 +48,15 @@ int init(){ } dlerror(); /* Clear errors */ gnome_vfs_init = (GNOME_VFS_INIT_TYPE*)dlsym(vfs_handle, "gnome_vfs_init"); + if (gnome_vfs_init == NULL){ +#ifdef INTERNAL_BUILD + fprintf(stderr, "dlsym( gnome_vfs_init) returned NULL\n"); +#endif + return 0; + } if ((errmsg = dlerror()) != NULL) { #ifdef INTERNAL_BUILD - fprintf(stderr, "can not find symble gnome_vfs_init\n"); + fprintf(stderr, "can not find symbol gnome_vfs_init %s \n", errmsg); #endif return 0; } From 5d5154fbeacf60da332efa60d1cc2c38ba20d831 Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Tue, 15 Feb 2011 19:00:22 -0800 Subject: [PATCH 062/105] 6954420: 2/4 jps shows "process information unavailable" sometimes Make sure the backing store file is flushed in create_sharedmem_resources() and get_user_name_slow() no longer checks the size of the backing store file. Reviewed-by: briand, swamyv, acorn, poonam --- .../src/os/windows/vm/perfMemory_windows.cpp | 71 +++++++++++++++---- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/hotspot/src/os/windows/vm/perfMemory_windows.cpp b/hotspot/src/os/windows/vm/perfMemory_windows.cpp index fbccc3c89fa..4f3280d5906 100644 --- a/hotspot/src/os/windows/vm/perfMemory_windows.cpp +++ b/hotspot/src/os/windows/vm/perfMemory_windows.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -298,8 +298,8 @@ static char* get_user_name() { static char* get_user_name_slow(int vmid) { // directory search - char* oldest_user = NULL; - time_t oldest_ctime = 0; + char* latest_user = NULL; + time_t latest_ctime = 0; const char* tmpdirname = os::get_temp_directory(); @@ -375,18 +375,29 @@ static char* get_user_name_slow(int vmid) { continue; } - // compare and save filename with latest creation time - if (statbuf.st_size > 0 && statbuf.st_ctime > oldest_ctime) { + // If we found a matching file with a newer creation time, then + // save the user name. The newer creation time indicates that + // we found a newer incarnation of the process associated with + // vmid. Due to the way that Windows recycles pids and the fact + // that we can't delete the file from the file system namespace + // until last close, it is possible for there to be more than + // one hsperfdata file with a name matching vmid (diff users). + // + // We no longer ignore hsperfdata files where (st_size == 0). + // In this function, all we're trying to do is determine the + // name of the user that owns the process associated with vmid + // so the size doesn't matter. Very rarely, we have observed + // hsperfdata files where (st_size == 0) and the st_size field + // later becomes the expected value. + // + if (statbuf.st_ctime > latest_ctime) { + char* user = strchr(dentry->d_name, '_') + 1; - if (statbuf.st_ctime > oldest_ctime) { - char* user = strchr(dentry->d_name, '_') + 1; + if (latest_user != NULL) FREE_C_HEAP_ARRAY(char, latest_user); + latest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1); - if (oldest_user != NULL) FREE_C_HEAP_ARRAY(char, oldest_user); - oldest_user = NEW_C_HEAP_ARRAY(char, strlen(user)+1); - - strcpy(oldest_user, user); - oldest_ctime = statbuf.st_ctime; - } + strcpy(latest_user, user); + latest_ctime = statbuf.st_ctime; } FREE_C_HEAP_ARRAY(char, filename); @@ -399,7 +410,7 @@ static char* get_user_name_slow(int vmid) { os::closedir(tmpdirp); FREE_C_HEAP_ARRAY(char, tdbuf); - return(oldest_user); + return(latest_user); } // return the name of the user that owns the process identified by vmid. @@ -1339,6 +1350,38 @@ static HANDLE create_sharedmem_resources(const char* dirname, const char* filena CloseHandle(fh); fh = NULL; return NULL; + } else { + // We created the file mapping, but rarely the size of the + // backing store file is reported as zero (0) which can cause + // failures when trying to use the hsperfdata file. + struct stat statbuf; + int ret_code = ::stat(filename, &statbuf); + if (ret_code == OS_ERR) { + if (PrintMiscellaneous && Verbose) { + warning("Could not get status information from file %s: %s\n", + filename, strerror(errno)); + } + CloseHandle(fmh); + CloseHandle(fh); + fh = NULL; + fmh = NULL; + return NULL; + } + + // We could always call FlushFileBuffers() but the Microsoft + // docs indicate that it is considered expensive so we only + // call it when we observe the size as zero (0). + if (statbuf.st_size == 0 && FlushFileBuffers(fh) != TRUE) { + DWORD lasterror = GetLastError(); + if (PrintMiscellaneous && Verbose) { + warning("could not flush file %s: %d\n", filename, lasterror); + } + CloseHandle(fmh); + CloseHandle(fh); + fh = NULL; + fmh = NULL; + return NULL; + } } // the file has been successfully created and the file mapping From 0bfde7d2430e23938515500bd14c0f68f75f1905 Mon Sep 17 00:00:00 2001 From: Masayoshi Okutsu Date: Wed, 16 Feb 2011 16:51:21 +0900 Subject: [PATCH 063/105] 6936350: API clarification needed on useDaylightTime() for timezones that have defined usage dates Reviewed-by: peytoia --- .../classes/java/util/SimpleTimeZone.java | 21 +++- jdk/src/share/classes/java/util/TimeZone.java | 82 ++++++++++---- .../java/util/TimeZone/DaylightTimeTest.java | 103 ++++++++++++++++++ 3 files changed, 179 insertions(+), 27 deletions(-) create mode 100644 jdk/test/java/util/TimeZone/DaylightTimeTest.java diff --git a/jdk/src/share/classes/java/util/SimpleTimeZone.java b/jdk/src/share/classes/java/util/SimpleTimeZone.java index 86427733290..ef70b960ee0 100644 --- a/jdk/src/share/classes/java/util/SimpleTimeZone.java +++ b/jdk/src/share/classes/java/util/SimpleTimeZone.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -825,10 +825,7 @@ public class SimpleTimeZone extends TimeZone { * @since 1.2 */ public int getDSTSavings() { - if (useDaylight) { - return dstSavings; - } - return 0; + return useDaylight ? dstSavings : 0; } /** @@ -841,6 +838,20 @@ public class SimpleTimeZone extends TimeZone { return useDaylight; } + /** + * Returns {@code true} if this {@code SimpleTimeZone} observes + * Daylight Saving Time. This method is equivalent to {@link + * #useDaylightTime()}. + * + * @return {@code true} if this {@code SimpleTimeZone} observes + * Daylight Saving Time; {@code false} otherwise. + * @since 1.7 + */ + @Override + public boolean observesDaylightTime() { + return useDaylightTime(); + } + /** * Queries if the given date is in daylight saving time. * @return true if daylight saving time is in effective at the diff --git a/jdk/src/share/classes/java/util/TimeZone.java b/jdk/src/share/classes/java/util/TimeZone.java index ca62e0ed7da..9799be601fe 100644 --- a/jdk/src/share/classes/java/util/TimeZone.java +++ b/jdk/src/share/classes/java/util/TimeZone.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -455,17 +455,28 @@ abstract public class TimeZone implements Serializable, Cloneable { /** * Returns the amount of time to be added to local standard time * to get local wall clock time. - *

- * The default implementation always returns 3600000 milliseconds - * (i.e., one hour) if this time zone observes Daylight Saving - * Time. Otherwise, 0 (zero) is returned. - *

- * If an underlying TimeZone implementation subclass supports - * historical Daylight Saving Time changes, this method returns - * the known latest daylight saving value. + * + *

The default implementation returns 3600000 milliseconds + * (i.e., one hour) if a call to {@link #useDaylightTime()} + * returns {@code true}. Otherwise, 0 (zero) is returned. + * + *

If an underlying {@code TimeZone} implementation subclass + * supports historical and future Daylight Saving Time schedule + * changes, this method returns the amount of saving time of the + * last known Daylight Saving Time rule that can be a future + * prediction. + * + *

If the amount of saving time at any given time stamp is + * required, construct a {@link Calendar} with this {@code + * TimeZone} and the time stamp, and call {@link Calendar#get(int) + * Calendar.get}{@code (}{@link Calendar#DST_OFFSET}{@code )}. * * @return the amount of saving time in milliseconds * @since 1.4 + * @see #inDaylightTime(Date) + * @see #getOffset(long) + * @see #getOffset(int,int,int,int,int,int) + * @see Calendar#ZONE_OFFSET */ public int getDSTSavings() { if (useDaylightTime()) { @@ -475,24 +486,51 @@ abstract public class TimeZone implements Serializable, Cloneable { } /** - * Queries if this time zone uses daylight savings time. - *

- * If an underlying TimeZone implementation subclass - * supports historical Daylight Saving Time schedule changes, the - * method refers to the latest Daylight Saving Time schedule - * information. + * Queries if this {@code TimeZone} uses Daylight Saving Time. * - * @return true if this time zone uses daylight savings time, - * false, otherwise. + *

If an underlying {@code TimeZone} implementation subclass + * supports historical and future Daylight Saving Time schedule + * changes, this method refers to the last known Daylight Saving Time + * rule that can be a future prediction and may not be the same as + * the current rule. Consider calling {@link #observesDaylightTime()} + * if the current rule should also be taken into account. + * + * @return {@code true} if this {@code TimeZone} uses Daylight Saving Time, + * {@code false}, otherwise. + * @see #inDaylightTime(Date) + * @see Calendar#DST_OFFSET */ public abstract boolean useDaylightTime(); /** - * Queries if the given date is in daylight savings time in - * this time zone. - * @param date the given Date. - * @return true if the given date is in daylight savings time, - * false, otherwise. + * Returns {@code true} if this {@code TimeZone} is currently in + * Daylight Saving Time, or if a transition from Standard Time to + * Daylight Saving Time occurs at any future time. + * + *

The default implementation returns {@code true} if + * {@code useDaylightTime()} or {@code inDaylightTime(new Date())} + * returns {@code true}. + * + * @return {@code true} if this {@code TimeZone} is currently in + * Daylight Saving Time, or if a transition from Standard Time to + * Daylight Saving Time occurs at any future time; {@code false} + * otherwise. + * @since 1.7 + * @see #useDaylightTime() + * @see #inDaylightTime(Date) + * @see Calendar#DST_OFFSET + */ + public boolean observesDaylightTime() { + return useDaylightTime() || inDaylightTime(new Date()); + } + + /** + * Queries if the given {@code date} is in Daylight Saving Time in + * this {@code TimeZone}. + * + * @param date the given {@code Date}. + * @return {@code true} if the given {@code date} is in Daylight Saving Time, + * {@code false}, otherwise. */ abstract public boolean inDaylightTime(Date date); diff --git a/jdk/test/java/util/TimeZone/DaylightTimeTest.java b/jdk/test/java/util/TimeZone/DaylightTimeTest.java new file mode 100644 index 00000000000..4b637136f96 --- /dev/null +++ b/jdk/test/java/util/TimeZone/DaylightTimeTest.java @@ -0,0 +1,103 @@ +/* + * 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. + */ + +/* + * @test + * @bug 6936350 + * @summary Test case for TimeZone.observesDaylightTime() + */ + +import java.util.*; +import static java.util.GregorianCalendar.*; + +public class DaylightTimeTest { + private static final int ONE_HOUR = 60 * 60 * 1000; // one hour + private static final int INTERVAL = 24 * ONE_HOUR; // one day + private static final String[] ZONES = TimeZone.getAvailableIDs(); + private static int errors = 0; + + public static void main(String[] args) { + + // Test default TimeZone + for (String id : ZONES) { + TimeZone tz = TimeZone.getTimeZone(id); + long now = System.currentTimeMillis(); + boolean observes = tz.observesDaylightTime(); + boolean found = findDSTTransition(tz, now); + if (observes != found) { + // There's a critical section. If DST ends after the + // System.currentTimeMills() call, there should be + // inconsistency in the determination. Try the same + // thing again to see the inconsistency was due to the + // critical section. + now = System.currentTimeMillis(); + observes = tz.observesDaylightTime(); + found = findDSTTransition(tz, now); + if (observes != found) { + System.err.printf("%s: observesDaylightTime() should return %s at %d%n", + tz.getID(), found, now); + errors++; + } + } + } + + // Test SimpleTimeZone in which observesDaylightTime() is + // equivalent to useDaylightTime(). + testSimpleTimeZone(new SimpleTimeZone(-8*ONE_HOUR, "X", + APRIL, 1, -SUNDAY, 2*ONE_HOUR, + OCTOBER, -1, SUNDAY, 2*ONE_HOUR, + 1*ONE_HOUR)); + testSimpleTimeZone(new SimpleTimeZone(-8*ONE_HOUR, "Y")); + + if (errors > 0) { + throw new RuntimeException("DaylightTimeTest: failed"); + } + } + + /** + * Returns true if it's `now' in DST or there's any + * standard-to-daylight transition within 50 years after `now'. + */ + private static boolean findDSTTransition(TimeZone tz, long now) { + GregorianCalendar cal = new GregorianCalendar(tz, Locale.US); + cal.setTimeInMillis(now); + cal.add(YEAR, 50); + long end = cal.getTimeInMillis(); + + for (long t = now; t < end; t += INTERVAL) { + cal.setTimeInMillis(t); + if (cal.get(DST_OFFSET) > 0) { + return true; + } + } + return false; + } + + private static void testSimpleTimeZone(SimpleTimeZone stz) { + if (stz.useDaylightTime() != stz.observesDaylightTime()) { + System.err.printf("Failed: useDaylightTime=%b, observesDaylightTime()=%b%n\t%s%n", + stz.useDaylightTime(),stz.observesDaylightTime(), stz); + errors++; + } + } +} From 560ab81595b4331ac3b69484e1b813763d4f904b Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 16 Feb 2011 12:38:13 +0000 Subject: [PATCH 064/105] 6562203: Thread doesn't terminate immediately if it was stopped before start Reviewed-by: dholmes, alanb --- jdk/src/share/classes/java/lang/Thread.java | 44 ++---- .../java/lang/Thread/StopBeforeStart.java | 132 ------------------ 2 files changed, 9 insertions(+), 167 deletions(-) delete mode 100644 jdk/test/java/lang/Thread/StopBeforeStart.java diff --git a/jdk/src/share/classes/java/lang/Thread.java b/jdk/src/share/classes/java/lang/Thread.java index d35e082b844..d64d55b7404 100644 --- a/jdk/src/share/classes/java/lang/Thread.java +++ b/jdk/src/share/classes/java/lang/Thread.java @@ -254,12 +254,6 @@ class Thread implements Runnable { */ public final static int MAX_PRIORITY = 10; - /* If stop was called before start */ - private boolean stopBeforeStart; - - /* Remembered Throwable from stop before start */ - private Throwable throwableFromStop; - /** * Returns a reference to the currently executing thread object. * @@ -706,10 +700,6 @@ class Thread implements Runnable { it will be passed up the call stack */ } } - - if (stopBeforeStart) { - stop0(throwableFromStop); - } } private native void start0(); @@ -820,12 +810,7 @@ class Thread implements Runnable { */ @Deprecated public final void stop() { - // If the thread is already dead, return. - // A zero status value corresponds to "NEW". - if ((threadStatus != 0) && !isAlive()) { - return; - } - stop1(new ThreadDeath()); + stop(new ThreadDeath()); } /** @@ -879,36 +864,25 @@ class Thread implements Runnable { */ @Deprecated public final synchronized void stop(Throwable obj) { - stop1(obj); - } + if (obj == null) + throw new NullPointerException(); - /** - * Common impl for stop() and stop(Throwable). - */ - private final synchronized void stop1(Throwable th) { SecurityManager security = System.getSecurityManager(); if (security != null) { checkAccess(); if ((this != Thread.currentThread()) || - (!(th instanceof ThreadDeath))) { + (!(obj instanceof ThreadDeath))) { security.checkPermission(SecurityConstants.STOP_THREAD_PERMISSION); } } - // A zero status value corresponds to "NEW" + // A zero status value corresponds to "NEW", it can't change to + // not-NEW because we hold the lock. if (threadStatus != 0) { resume(); // Wake up thread if it was suspended; no-op otherwise - stop0(th); - } else { - - // Must do the null arg check that the VM would do with stop0 - if (th == null) { - throw new NullPointerException(); - } - - // Remember this stop attempt for if/when start is used - stopBeforeStart = true; - throwableFromStop = th; } + + // The VM can handle all thread states + stop0(obj); } /** diff --git a/jdk/test/java/lang/Thread/StopBeforeStart.java b/jdk/test/java/lang/Thread/StopBeforeStart.java deleted file mode 100644 index 91b62597cb6..00000000000 --- a/jdk/test/java/lang/Thread/StopBeforeStart.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please 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 4519200 - * @summary Confirm a Thread.stop before start complies with the spec - * @author Pete Soper - * - * Confirm that a thread that had its stop method invoked before start - * does properly terminate with expected exception behavior. NOTE that - * arbitrary application threads could return from their run methods faster - * than the VM can throw an async exception. - */ -public class StopBeforeStart { - - private static final int JOIN_TIMEOUT=10000; - - private class MyThrowable extends Throwable { - } - - private class Catcher implements Thread.UncaughtExceptionHandler { - private boolean nullaryStop; - private Throwable theThrowable; - private Throwable expectedThrowable; - private boolean exceptionThrown; - - Catcher(boolean nullaryStop) { - this.nullaryStop = nullaryStop; - if (!nullaryStop) { - expectedThrowable = new MyThrowable(); - } - } - - public void uncaughtException(Thread t, Throwable th) { - exceptionThrown = true; - theThrowable = th; - } - - void check(String label) throws Throwable { - if (!exceptionThrown) { - throw new RuntimeException(label + - " test:" + " missing uncaught exception"); - } - - if (nullaryStop) { - if (! (theThrowable instanceof ThreadDeath)) { - throw new RuntimeException(label + - " test:" + " expected ThreadDeath in uncaught handler"); - } - } else if (theThrowable != expectedThrowable) { - throw new RuntimeException(label + - " test:" + " wrong Throwable in uncaught handler"); - } - } - } - - private class MyRunnable implements Runnable { - public void run() { - while(true) - ; - } - } - - private class MyThread extends Thread { - public void run() { - while(true) - ; - } - } - - - public static void main(String args[]) throws Throwable { - (new StopBeforeStart()).doit(); - System.out.println("Test passed"); - } - - private void doit() throws Throwable { - - runit(false, new Thread(new MyRunnable()),"Thread"); - runit(true, new Thread(new MyRunnable()),"Thread"); - runit(false, new MyThread(),"Runnable"); - runit(true, new MyThread(),"Runnable"); - } - - private void runit(boolean nullaryStop, Thread thread, - String type) throws Throwable { - - Catcher c = new Catcher(nullaryStop); - thread.setUncaughtExceptionHandler(c); - - if (nullaryStop) { - thread.stop(); - } else { - thread.stop(c.expectedThrowable); - } - - thread.start(); - thread.join(JOIN_TIMEOUT); - - if (thread.getState() != Thread.State.TERMINATED) { - - thread.stop(); - - // Under high load this could be a false positive - throw new RuntimeException(type + - " test:" + " app thread did not terminate"); - } - - c.check(type); - } -} From 9c787663dc5df5deb42ace42fd8f5db503fe33f2 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Wed, 16 Feb 2011 18:32:06 +0300 Subject: [PATCH 065/105] 6980124: closed/javax/swing/plaf/synth/SynthPainter/unitTest/UnitTest.java fails Reviewed-by: alexp --- .../share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java b/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java index 0a4fa276752..63a8f377cea 100644 --- a/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java +++ b/jdk/src/share/classes/javax/swing/plaf/synth/SynthGraphicsUtils.java @@ -510,7 +510,6 @@ public class SynthGraphicsUtils { Font holdf = g.getFont(); Color holdc = g.getColor(); - paintBackground(g, lh); paintCheckIcon(g, lh, lr); paintIcon(g, lh, lr); paintText(g, lh, lr); From 9c5679fe532e8e92496eba538be9f0c89150612c Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Wed, 16 Feb 2011 11:34:44 -0500 Subject: [PATCH 066/105] 6840152: JVM crashes when heavyweight monitors are used Turn off biased locking if !UseFastLocking or UseHeavyMonitors options are requested. Reviewed-by: phh, never, dcubed, dholmes --- hotspot/src/share/vm/runtime/arguments.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 814e0df928b..b4a48a63ab6 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -3103,6 +3103,19 @@ jint Arguments::parse(const JavaVMInitArgs* args) { // Set flags if Aggressive optimization flags (-XX:+AggressiveOpts) enabled. set_aggressive_opts_flags(); + // Turn off biased locking for locking debug mode flags, + // which are subtlely different from each other but neither works with + // biased locking. + if (!UseFastLocking || UseHeavyMonitors) { + if (!FLAG_IS_DEFAULT(UseBiasedLocking) && UseBiasedLocking) { + // flag set to true on command line; warn the user that they + // can't enable biased locking here + warning("Biased Locking is not supported with locking debug flags" + "; ignoring UseBiasedLocking flag." ); + } + UseBiasedLocking = false; + } + #ifdef CC_INTERP // Clear flags not supported by the C++ interpreter FLAG_SET_DEFAULT(ProfileInterpreter, false); From f1181c706c7965d1a22fe0c224b4fdfdc66f4a4c Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 16 Feb 2011 10:27:00 -0800 Subject: [PATCH 067/105] 6990136: Cleanup use of Type.clone() Introduced factory methods in class Types which can be used rather than clone(). Reviewed-by: jjg, mcimadamore --- .../com/sun/tools/javac/code/Type.java | 33 ++----------------- .../com/sun/tools/javac/code/Types.java | 32 ++++++++++++++++++ .../com/sun/tools/javac/comp/Flow.java | 5 ++- .../com/sun/tools/javac/comp/Resolve.java | 16 +++------ 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java index a67cd0f9583..c9e564eaa36 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java @@ -270,10 +270,6 @@ public class Type implements PrimitiveType { public Type getUpperBound() { return null; } public Type getLowerBound() { return null; } - public void setThrown(List ts) { - throw new AssertionError(); - } - /** Navigation methods, these will work for classes, type variables, * foralls, but will return null for arrays and methods. */ @@ -388,14 +384,6 @@ public class Type implements PrimitiveType { */ public void complete() {} - public Object clone() { - try { - return super.clone(); - } catch (CloneNotSupportedException e) { - throw new AssertionError(e); - } - } - public TypeSymbol asElement() { return tsym; } @@ -817,8 +805,7 @@ public class Type implements PrimitiveType { } } - public static class MethodType extends Type - implements Cloneable, ExecutableType { + public static class MethodType extends Type implements ExecutableType { public List argtypes; public Type restype; @@ -880,10 +867,6 @@ public class Type implements PrimitiveType { public Type getReturnType() { return restype; } public List getThrownTypes() { return thrown; } - public void setThrown(List t) { - thrown = t; - } - public boolean isErroneous() { return isErroneous(argtypes) || @@ -1068,12 +1051,10 @@ public class Type implements PrimitiveType { public List getThrownTypes() { return qtype.getThrownTypes(); } public List allparams() { return qtype.allparams(); } public Type getUpperBound() { return qtype.getUpperBound(); } - public Object clone() { DelegatedType t = (DelegatedType)super.clone(); t.qtype = (Type)qtype.clone(); return t; } public boolean isErroneous() { return qtype.isErroneous(); } } - public static class ForAll extends DelegatedType - implements Cloneable, ExecutableType { + public static class ForAll extends DelegatedType implements ExecutableType { public List tvars; public ForAll(List tvars, Type qtype) { @@ -1092,16 +1073,6 @@ public class Type implements PrimitiveType { public List getTypeArguments() { return tvars; } - public void setThrown(List t) { - qtype.setThrown(t); - } - - public Object clone() { - ForAll result = (ForAll)super.clone(); - result.qtype = (Type)result.qtype.clone(); - return result; - } - public boolean isErroneous() { return qtype.isErroneous(); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java index f3674ee0a66..c29b317115f 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java @@ -2407,6 +2407,38 @@ public class Types { }; // + public Type createMethodTypeWithParameters(Type original, List newParams) { + return original.accept(methodWithParameters, newParams); + } + // where + private final MapVisitor> methodWithParameters = new MapVisitor>() { + public Type visitType(Type t, List newParams) { + throw new IllegalArgumentException("Not a method type: " + t); + } + public Type visitMethodType(MethodType t, List newParams) { + return new MethodType(newParams, t.restype, t.thrown, t.tsym); + } + public Type visitForAll(ForAll t, List newParams) { + return new ForAll(t.tvars, t.qtype.accept(this, newParams)); + } + }; + + public Type createMethodTypeWithThrown(Type original, List newThrown) { + return original.accept(methodWithThrown, newThrown); + } + // where + private final MapVisitor> methodWithThrown = new MapVisitor>() { + public Type visitType(Type t, List newThrown) { + throw new IllegalArgumentException("Not a method type: " + t); + } + public Type visitMethodType(MethodType t, List newThrown) { + return new MethodType(t.argtypes, t.restype, newThrown, t.tsym); + } + public Type visitForAll(ForAll t, List newThrown) { + return new ForAll(t.tvars, t.qtype.accept(this, newThrown)); + } + }; + // public Type createErrorType(Type originalType) { return new ErrorType(originalType, syms.errSymbol); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java index c0a1827bd02..5a45cca728a 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java @@ -673,12 +673,15 @@ public class Flow extends TreeScanner { // in an anonymous class, add the set of thrown exceptions to // the throws clause of the synthetic constructor and propagate // outwards. + // Changing the throws clause on the fly is okay here because + // the anonymous constructor can't be invoked anywhere else, + // and its type hasn't been cached. if (tree.name == names.empty) { for (List l = tree.defs; l.nonEmpty(); l = l.tail) { if (TreeInfo.isInitialConstructor(l.head)) { JCMethodDecl mdef = (JCMethodDecl)l.head; mdef.thrown = make.Types(thrown); - mdef.sym.type.setThrown(thrown); + mdef.sym.type = types.createMethodTypeWithThrown(mdef.sym.type, thrown); } } thrownPrev = chk.union(thrown, thrownPrev); diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java index ceed3b3a417..92b53ca1078 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java @@ -776,10 +776,12 @@ public class Resolve { // due to error recovery or mixing incompatible class files return ambiguityError(m1, m2); } + List allThrown = chk.intersect(mt1.getThrownTypes(), mt2.getThrownTypes()); + Type newSig = types.createMethodTypeWithThrown(mostSpecific.type, allThrown); MethodSymbol result = new MethodSymbol( mostSpecific.flags(), mostSpecific.name, - null, + newSig, mostSpecific.owner) { @Override public MethodSymbol implementation(TypeSymbol origin, Types types, boolean checkResult) { @@ -789,9 +791,6 @@ public class Resolve { return super.implementation(origin, types, checkResult); } }; - result.type = (Type)mostSpecific.type.clone(); - result.type.setThrown(chk.intersect(mt1.getThrownTypes(), - mt2.getThrownTypes())); return result; } if (m1SignatureMoreSpecific) return m1; @@ -852,13 +851,8 @@ public class Resolve { } //append varargs element type as last synthetic formal args.append(types.elemtype(varargsTypeTo)); - MethodSymbol msym = new MethodSymbol(to.flags_field, - to.name, - (Type)to.type.clone(), //see: 6990136 - to.owner); - MethodType mtype = msym.type.asMethodType(); - mtype.argtypes = args.toList(); - return msym; + Type mtype = types.createMethodTypeWithParameters(to.type, args.toList()); + return new MethodSymbol(to.flags_field, to.name, mtype, to.owner); } else { return to; } From 2c97d8fb44cf5db0be72be9ffcc2c7e52cfa4278 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Wed, 16 Feb 2011 11:11:31 -0800 Subject: [PATCH 068/105] 6999337: java.exe fails to start if some directory names in path to java binaries contain Russian characters Updated to make sure the system properties are accessable by vm during initialization Reviewed-by: alanb, mchung --- jdk/src/share/classes/java/lang/System.java | 32 ++++++++++++--------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/jdk/src/share/classes/java/lang/System.java b/jdk/src/share/classes/java/lang/System.java index 59e15ee1d04..3eafd1b3cbb 100644 --- a/jdk/src/share/classes/java/lang/System.java +++ b/jdk/src/share/classes/java/lang/System.java @@ -1102,6 +1102,18 @@ public final class System { * Initialize the system class. Called after thread initialization. */ private static void initializeSystemClass() { + + // VM might invoke JNU_NewStringPlatform() to set those encoding + // sensitive properties (user.home, user.name, boot.class.path, etc.) + // during "props" initialization, in which it may need access, via + // System.getProperty(), to the related system encoding property that + // have been initialized (put into "props") at early stage of the + // initialization. So make sure the "props" is available at the + // very beginning of the initialization and all system properties to + // be put into it directly. + props = new Properties(); + initProperties(props); // initialized by the VM + // There are certain system configurations that may be controlled by // VM options such as the maximum amount of direct memory and // Integer cache size used to support the object identity semantics @@ -1112,7 +1124,12 @@ public final class System { // // See java.lang.Integer.IntegerCache and the // sun.misc.VM.saveAndRemoveProperties method for example. - props = initSystemProperties(); + // + // Save a private copy of the system properties object that + // can only be accessed by the internal implementation. Remove + // certain system properties that are not intended for public access. + sun.misc.VM.saveAndRemoveProperties(props); + lineSeparator = props.getProperty("line.separator"); sun.misc.Version.init(); @@ -1123,7 +1140,6 @@ public final class System { setIn0(new BufferedInputStream(fdIn)); setOut0(new PrintStream(new BufferedOutputStream(fdOut, 128), true)); setErr0(new PrintStream(new BufferedOutputStream(fdErr, 128), true)); - // Load the zip library now in order to keep java.util.zip.ZipFile // from trying to use itself to load this library later. loadLibrary("zip"); @@ -1151,18 +1167,6 @@ public final class System { setJavaLangAccess(); } - private static Properties initSystemProperties() { - Properties props = new Properties(); - initProperties(props); // initialized by the VM - - // Save a private copy of the system properties object that - // can only be accessed by the internal implementation. Remove - // certain system properties that are not intended for public access. - sun.misc.VM.saveAndRemoveProperties(props); - - return props; - } - private static void setJavaLangAccess() { // Allow privileged classes outside of java.lang sun.misc.SharedSecrets.setJavaLangAccess(new sun.misc.JavaLangAccess(){ From 5e83438315bfbd454f52ca32d71c0c419b09ce69 Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Wed, 16 Feb 2011 17:12:31 -0500 Subject: [PATCH 069/105] 7019689: Non-dependent name is found in dependent base class although it should be rejected Fix hashtable.hpp to qualify non-dependant name with "this" Reviewed-by: phh, never, poonam --- hotspot/src/share/vm/utilities/hashtable.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/src/share/vm/utilities/hashtable.hpp b/hotspot/src/share/vm/utilities/hashtable.hpp index 011da0b502a..21747e6855b 100644 --- a/hotspot/src/share/vm/utilities/hashtable.hpp +++ b/hotspot/src/share/vm/utilities/hashtable.hpp @@ -276,7 +276,7 @@ public: } int index_for(Symbol* name, Handle loader) { - return hash_to_index(compute_hash(name, loader)); + return this->hash_to_index(compute_hash(name, loader)); } }; From daf8e751d42741bde80bdbcbe68967ec3e1fcf51 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Wed, 16 Feb 2011 15:58:28 -0800 Subject: [PATCH 070/105] 7019441: No lookup cache for internal composite font creation leads to java heap growth Reviewed-by: igor, jgodinez --- .../share/classes/sun/font/FontUtilities.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/sun/font/FontUtilities.java b/jdk/src/share/classes/sun/font/FontUtilities.java index ef53c60de08..6f3c6d12a14 100644 --- a/jdk/src/share/classes/sun/font/FontUtilities.java +++ b/jdk/src/share/classes/sun/font/FontUtilities.java @@ -30,6 +30,8 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.InputStreamReader; +import java.lang.ref.SoftReference; +import java.util.concurrent.ConcurrentHashMap; import java.security.AccessController; import java.security.PrivilegedAction; @@ -383,6 +385,10 @@ public final class FontUtilities { * } * return fuir; */ + private static volatile + SoftReference> + compMapRef = new SoftReference(null); + public static FontUIResource getCompositeFontUIResource(Font font) { FontUIResource fuir = new FontUIResource(font); @@ -402,12 +408,22 @@ public final class FontUtilities { FontManager fm = FontManagerFactory.getInstance(); CompositeFont dialog2D = - (CompositeFont) fm.findFont2D("dialog", font.getStyle(), FontManager.NO_FALLBACK); + (CompositeFont) fm.findFont2D("dialog", font.getStyle(), + FontManager.NO_FALLBACK); if (dialog2D == null) { /* shouldn't happen */ return fuir; } PhysicalFont physicalFont = (PhysicalFont)font2D; - CompositeFont compFont = new CompositeFont(physicalFont, dialog2D); + ConcurrentHashMap compMap = compMapRef.get(); + if (compMap == null) { // Its been collected. + compMap = new ConcurrentHashMap(); + compMapRef = new SoftReference(compMap); + } + CompositeFont compFont = compMap.get(physicalFont); + if (compFont == null) { + compFont = new CompositeFont(physicalFont, dialog2D); + compMap.put(physicalFont, compFont); + } FontAccess.getFontAccess().setFont2D(fuir, compFont.handle); /* marking this as a created font is needed as only created fonts * copy their creator's handles. From 313991183b716ea420c2a2155ada03191faca6b7 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Wed, 16 Feb 2011 18:22:52 -0800 Subject: [PATCH 071/105] 7018392: update URLJarFile.java to use try-with-resources Reviewed-by: alanb, chegar, hawtin --- .../sun/net/www/protocol/jar/URLJarFile.java | 42 +++++++------------ 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/jdk/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java b/jdk/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java index 36acd9cc381..f32141d5030 100644 --- a/jdk/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java +++ b/jdk/src/share/classes/sun/net/www/protocol/jar/URLJarFile.java @@ -27,6 +27,9 @@ package sun.net.www.protocol.jar; import java.io.*; import java.net.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.util.*; import java.util.jar.*; import java.util.zip.ZipFile; @@ -208,38 +211,23 @@ public class URLJarFile extends JarFile { JarFile result = null; /* get the stream before asserting privileges */ - final InputStream in = url.openConnection().getInputStream(); - - try { + try (final InputStream in = url.openConnection().getInputStream()) { result = AccessController.doPrivileged( new PrivilegedExceptionAction() { public JarFile run() throws IOException { - OutputStream out = null; - File tmpFile = null; + Path tmpFile = Files.createTempFile("jar_cache", null); try { - tmpFile = File.createTempFile("jar_cache", null); - tmpFile.deleteOnExit(); - out = new FileOutputStream(tmpFile); - int read = 0; - byte[] buf = new byte[BUF_SIZE]; - while ((read = in.read(buf)) != -1) { - out.write(buf, 0, read); - } - out.close(); - out = null; - return new URLJarFile(tmpFile, closeController); - } catch (IOException e) { - if (tmpFile != null) { - tmpFile.delete(); - } - throw e; - } finally { - if (in != null) { - in.close(); - } - if (out != null) { - out.close(); + Files.copy(in, tmpFile, StandardCopyOption.REPLACE_EXISTING); + JarFile jarFile = new URLJarFile(tmpFile.toFile(), closeController); + tmpFile.toFile().deleteOnExit(); + return jarFile; + } catch (Throwable thr) { + try { + Files.delete(tmpFile); + } catch (IOException ioe) { + thr.addSuppressed(ioe); } + throw thr; } } }); From e5d4746fb471416a7b89f6c7d2e70b172def494a Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Thu, 17 Feb 2011 09:56:38 +0000 Subject: [PATCH 072/105] 7017901: OOME in java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java Unbounded queues should be disabled in the test Reviewed-by: alanb --- .../BlockingQueue/CancelledProducerConsumerLoops.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/test/java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java b/jdk/test/java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java index 34f0722d8bd..755ff9c2d97 100644 --- a/jdk/test/java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java +++ b/jdk/test/java/util/concurrent/BlockingQueue/CancelledProducerConsumerLoops.java @@ -124,11 +124,11 @@ public class CancelledProducerConsumerLoops { oneRun(new ArrayBlockingQueue(CAPACITY), pairs, iters); oneRun(new LinkedBlockingQueue(CAPACITY), pairs, iters); oneRun(new LinkedBlockingDeque(CAPACITY), pairs, iters); - oneRun(new LinkedTransferQueue(), pairs, iters); oneRun(new SynchronousQueue(), pairs, iters / 8); - /* PriorityBlockingQueue is unbounded + /* unbounded queue implementations are prone to OOME oneRun(new PriorityBlockingQueue(iters / 2 * pairs), pairs, iters / 4); + oneRun(new LinkedTransferQueue(), pairs, iters); */ } From f1c2d419cb6a02a64b03f0e5073b219eec0b3472 Mon Sep 17 00:00:00 2001 From: Andrew Brygin Date: Thu, 17 Feb 2011 13:42:26 +0300 Subject: [PATCH 073/105] 7018912: [parfait] potential buffer overruns in imageio jpeg Reviewed-by: jgodinez, prr --- jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c index e9c98702366..04a87fd1cac 100644 --- a/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c +++ b/jdk/src/share/native/sun/awt/image/jpeg/imageioJPEG.c @@ -1846,7 +1846,7 @@ Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage cinfo = (j_decompress_ptr) data->jpegObj; - if ((numBands < 1) || + if ((numBands < 1) || (numBands > MAX_BANDS) || (sourceXStart < 0) || (sourceXStart >= (jint)cinfo->image_width) || (sourceYStart < 0) || (sourceYStart >= (jint)cinfo->image_height) || (sourceWidth < 1) || (sourceWidth > (jint)cinfo->image_width) || From 9aa277a5417347707faaf3735de085ec48873ad8 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Thu, 17 Feb 2011 20:50:22 +0000 Subject: [PATCH 074/105] 6526860: (fc) FileChannel.position returns 0 when FileOutputStream opened in append mode Reviewed-by: forax --- .../classes/sun/nio/ch/FileChannelImpl.java | 5 +- .../sun/nio/fs/UnixChannelFactory.java | 2 +- .../nio/channels/FileChannel/Position.java | 77 +++++++++++-------- 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java index e9344cdab64..b15086eab12 100644 --- a/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java +++ b/jdk/src/share/classes/sun/nio/ch/FileChannelImpl.java @@ -51,6 +51,7 @@ public class FileChannelImpl // File access mode (immutable) private final boolean writable; private final boolean readable; + private final boolean append; // Required to prevent finalization of creating stream (immutable) private final Object parent; @@ -67,6 +68,7 @@ public class FileChannelImpl this.fd = fd; this.readable = readable; this.writable = writable; + this.append = append; this.parent = parent; this.nd = new FileDispatcherImpl(append); } @@ -242,7 +244,8 @@ public class FileChannelImpl if (!isOpen()) return 0; do { - p = position0(fd, -1); + // in append-mode then position is advanced to end before writing + p = (append) ? nd.size(fd) : position0(fd, -1); } while ((p == IOStatus.INTERRUPTED) && isOpen()); return IOStatus.normalize(p); } finally { diff --git a/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java b/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java index 7bb58c73638..21c69ae4f4c 100644 --- a/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java +++ b/jdk/src/solaris/classes/sun/nio/fs/UnixChannelFactory.java @@ -136,7 +136,7 @@ class UnixChannelFactory { throw new IllegalArgumentException("APPEND + TRUNCATE_EXISTING not allowed"); FileDescriptor fdObj = open(dfd, path, pathForPermissionCheck, flags, mode); - return FileChannelImpl.open(fdObj, flags.read, flags.write, null); + return FileChannelImpl.open(fdObj, flags.read, flags.write, flags.append, null); } /** diff --git a/jdk/test/java/nio/channels/FileChannel/Position.java b/jdk/test/java/nio/channels/FileChannel/Position.java index dc10f27afd2..c6c674d9f4f 100644 --- a/jdk/test/java/nio/channels/FileChannel/Position.java +++ b/jdk/test/java/nio/channels/FileChannel/Position.java @@ -22,13 +22,16 @@ */ /* @test + * @bug 4429043 6526860 * @summary Test position method of FileChannel */ import java.io.*; -import java.nio.MappedByteBuffer; -import java.nio.channels.*; +import java.nio.ByteBuffer; import java.nio.channels.FileChannel; +import java.nio.file.*; +import static java.nio.file.StandardOpenOption.*; +import java.nio.charset.Charset; import java.util.Random; @@ -38,32 +41,42 @@ import java.util.Random; public class Position { - private static PrintStream err = System.err; + private static final Charset ISO8859_1 = Charset.forName("8859_1"); - private static Random generator = new Random(); - - private static int CHARS_PER_LINE = File.separatorChar == '/' ? 5 : 6; - - private static File blah; + private static final Random generator = new Random(); public static void main(String[] args) throws Exception { - blah = File.createTempFile("blah", null); - blah.deleteOnExit(); + Path blah = Files.createTempFile("blah", null); + blah.toFile().deleteOnExit(); initTestFile(blah); - FileInputStream fis = new FileInputStream(blah); - FileChannel c = fis.getChannel(); - - for(int i=0; i<100; i++) { - long newPos = generator.nextInt(1000); - c.position(newPos); - if (c.position() != newPos) - throw new RuntimeException("Position failed"); + for (int i=0; i<10; i++) { + try (FileChannel fc = (generator.nextBoolean()) ? + FileChannel.open(blah, READ) : + new FileInputStream(blah.toFile()).getChannel()) { + for (int j=0; j<100; j++) { + long newPos = generator.nextInt(1000); + fc.position(newPos); + if (fc.position() != newPos) + throw new RuntimeException("Position failed"); + } + } } - c.close(); - fis.close(); - blah.delete(); + for (int i=0; i<10; i++) { + try (FileChannel fc = (generator.nextBoolean()) ? + FileChannel.open(blah, APPEND) : + new FileOutputStream(blah.toFile(), true).getChannel()) { + for (int j=0; j<10; j++) { + if (fc.position() != fc.size()) + throw new RuntimeException("Position expected to be size"); + byte[] buf = new byte[generator.nextInt(100)]; + fc.write(ByteBuffer.wrap(buf)); + } + } + } + + Files.delete(blah); } /** @@ -78,19 +91,15 @@ public class Position { * 3999 * */ - private static void initTestFile(File blah) throws Exception { - FileOutputStream fos = new FileOutputStream(blah); - BufferedWriter awriter - = new BufferedWriter(new OutputStreamWriter(fos, "8859_1")); - - for(int i=0; i<4000; i++) { - String number = new Integer(i).toString(); - for (int h=0; h<4-number.length(); h++) - awriter.write("0"); - awriter.write(""+i); - awriter.newLine(); + private static void initTestFile(Path blah) throws IOException { + try (BufferedWriter awriter = Files.newBufferedWriter(blah, ISO8859_1)) { + for(int i=0; i<4000; i++) { + String number = new Integer(i).toString(); + for (int h=0; h<4-number.length(); h++) + awriter.write("0"); + awriter.write(""+i); + awriter.newLine(); + } } - awriter.flush(); - awriter.close(); } } From daf96106165eea8cebaa5bb8fb64b45acea81d7e Mon Sep 17 00:00:00 2001 From: Pavel Porvatov Date: Fri, 18 Feb 2011 00:16:53 +0300 Subject: [PATCH 075/105] 7016693: javax/swing/JScrollBar/6542335/bug6542335.java failed on Ubuntu Reviewed-by: alexp --- jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java b/jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java index d4ed4736e34..b71ae1cde51 100644 --- a/jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java +++ b/jdk/test/javax/swing/JScrollBar/6542335/bug6542335.java @@ -69,8 +69,6 @@ public class bug6542335 { frame.setSize(200, 100); frame.setVisible(true); - - thumbBounds[0] = new Rectangle(ui.getThumbBounds()); } }); @@ -78,6 +76,8 @@ public class bug6542335 { SwingUtilities.invokeAndWait(new Runnable() { public void run() { + thumbBounds[0] = new Rectangle(ui.getThumbBounds()); + Point l = sb.getLocationOnScreen(); robot.mouseMove(l.x + (int) (0.75 * sb.getWidth()), l.y + sb.getHeight() / 2); From 437b0f5f717ad06368a37c5a0e8a21405eddfc99 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Fri, 18 Feb 2011 12:07:46 +0530 Subject: [PATCH 076/105] 7018459: javax.script code comments have issues with HTML4 validation and Accessibility compliance Reviewed-by: jjh --- .../javax/script/ScriptEngineFactory.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/jdk/src/share/classes/javax/script/ScriptEngineFactory.java b/jdk/src/share/classes/javax/script/ScriptEngineFactory.java index 46b56ef66fc..f39f33de4c0 100644 --- a/jdk/src/share/classes/javax/script/ScriptEngineFactory.java +++ b/jdk/src/share/classes/javax/script/ScriptEngineFactory.java @@ -115,20 +115,19 @@ public interface ScriptEngineFactory { * with respect to concurrent execution of scripts and maintenance of state is also defined. * These values for the THREADING key are:

*

    - *

    null - The engine implementation is not thread safe, and cannot + *

  • null - The engine implementation is not thread safe, and cannot * be used to execute scripts concurrently on multiple threads. - *

    "MULTITHREADED" - The engine implementation is internally + *

  • "MULTITHREADED" - The engine implementation is internally * thread-safe and scripts may execute concurrently although effects of script execution * on one thread may be visible to scripts on other threads. - *

    "THREAD-ISOLATED" - The implementation satisfies the requirements + *

  • "THREAD-ISOLATED" - The implementation satisfies the requirements * of "MULTITHREADED", and also, the engine maintains independent values * for symbols in scripts executing on different threads. - *

    "STATELESS" - The implementation satisfies the requirements of - * "THREAD-ISOLATED". In addition, script executions do not alter the + *

  • "STATELESS" - The implementation satisfies the requirements of + *
  • "THREAD-ISOLATED". In addition, script executions do not alter the * mappings in the Bindings which is the engine scope of the * ScriptEngine. In particular, the keys in the Bindings * and their associated values are the same before and after the execution of the script. - *
  • *
*

* Implementations may define implementation-specific keys. @@ -145,7 +144,8 @@ public interface ScriptEngineFactory { * of the supported scripting language. For instance, an implementaton for a Javascript * engine might be; *

- *

+     * 
+     * 
      * public String getMethodCallSyntax(String obj,
      *                                   String m, String... args) {
      *      String ret = obj;
@@ -159,7 +159,8 @@ public interface ScriptEngineFactory {
      *      ret += ")";
      *      return ret;
      * }
-     *
+ *
+ *
*

* * @param obj The name representing the object whose method is to be invoked. The From 5e361485c1a479804526889e8cee64fd95784775 Mon Sep 17 00:00:00 2001 From: Alex Menkov Date: Fri, 18 Feb 2011 13:21:49 +0300 Subject: [PATCH 077/105] 6801236: test closed/javax/sound/sampled/FileWriter/WaveBigEndian.java fails Reviewed-by: alexp --- .../services/javax.sound.sampled.spi.FormatConversionProvider | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/share/classes/com/sun/media/sound/services/javax.sound.sampled.spi.FormatConversionProvider b/jdk/src/share/classes/com/sun/media/sound/services/javax.sound.sampled.spi.FormatConversionProvider index 2ea4f8b8040..a92a6020d50 100644 --- a/jdk/src/share/classes/com/sun/media/sound/services/javax.sound.sampled.spi.FormatConversionProvider +++ b/jdk/src/share/classes/com/sun/media/sound/services/javax.sound.sampled.spi.FormatConversionProvider @@ -1,5 +1,5 @@ # Providers for FormatConversion +com.sun.media.sound.AudioFloatFormatConverter com.sun.media.sound.UlawCodec com.sun.media.sound.AlawCodec com.sun.media.sound.PCMtoPCMCodec -com.sun.media.sound.AudioFloatFormatConverter From ba7c4a35c3aed9c0b4ebdcf0337ccbff6e04b62a Mon Sep 17 00:00:00 2001 From: Alex Menkov Date: Fri, 18 Feb 2011 13:27:29 +0300 Subject: [PATCH 078/105] 7000132: Misplaced description in javax.sound.sampled.AudioSystem.getTargetDataLine Reviewed-by: dav --- .../classes/javax/sound/sampled/AudioSystem.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java index 3724cc2cdac..fe3347540ff 100644 --- a/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java +++ b/jdk/src/share/classes/javax/sound/sampled/AudioSystem.java @@ -670,6 +670,12 @@ public class AudioSystem { *

The returned TargetDataLine's default * audio format will be initialized with format. * + *

If the system property + * {@code javax.sound.sampled.TargetDataLine} + * is defined or it is defined in the file "sound.properties", + * it is used to retrieve the default target data line. + * For details, refer to the {@link AudioSystem class description}. + * * @param format an AudioFormat object specifying * the supported audio format of the returned line, * or null for any audio format @@ -712,12 +718,6 @@ public class AudioSystem { *

The returned TargetDataLine's default * audio format will be initialized with format. * - *

If the system property - * javax.sound.sampled.TargetDataLine - * is defined or it is defined in the file "sound.properties", - * it is used to retrieve the default target data line. - * For details, refer to the {@link AudioSystem class description}. - * * @param format an AudioFormat object specifying * the supported audio format of the returned line, * or null for any audio format From 7d8c3e94602bb2182b2c98d46c54f35d21de795d Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 18 Feb 2011 12:28:49 +0000 Subject: [PATCH 079/105] 7020043: Project Coin: diamond allowed on non-generic type Diamond oerator should be disallowed on non-generic class types (i.e. String) Reviewed-by: jjg --- .../classes/com/sun/tools/javac/comp/Attr.java | 7 ++++++- .../sun/tools/javac/resources/compiler.properties | 4 ++++ .../tools/javac/generics/diamond/neg/Neg12.java | 15 +++++++++++++++ .../tools/javac/generics/diamond/neg/Neg12.out | 2 ++ 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 langtools/test/tools/javac/generics/diamond/neg/Neg12.java create mode 100644 langtools/test/tools/javac/generics/diamond/neg/Neg12.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java index 2da16a7e858..5db2dfb188e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java @@ -1584,6 +1584,11 @@ public class Attr extends JCTree.Visitor { if (!TreeInfo.isDiamond(tree)) { clazztype = chk.checkClassType( tree.clazz.pos(), clazztype, true); + } else if (!clazztype.isErroneous() && + !clazztype.tsym.type.isParameterized()) { + log.error(tree.clazz.pos(), + "cant.apply.diamond.1", + clazztype, diags.fragment("diamond.non.generic", clazztype)); } chk.validate(clazz, localEnv); if (tree.encl != null) { @@ -1609,7 +1614,7 @@ public class Attr extends JCTree.Visitor { List argtypes = attribArgs(tree.args, localEnv); List typeargtypes = attribTypes(tree.typeargs, localEnv); - if (TreeInfo.isDiamond(tree)) { + if (TreeInfo.isDiamond(tree) && clazztype.tsym.type.isParameterized()) { clazztype = attribDiamond(localEnv, tree, clazztype, mapping, argtypes, typeargtypes); clazz.type = clazztype; } else if (allowDiamondFinder && diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 2e4476aa2eb..02566b76b5c 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -1584,6 +1584,10 @@ compiler.misc.inferred.do.not.conform.to.bounds=\ compiler.misc.diamond=\ {0}<> +# 0: type +compiler.misc.diamond.non.generic=\ + cannot use ''<>'' with non-generic class {0} + # 0: list of type, 1: message segment compiler.misc.diamond.invalid.arg=\ type argument {0} inferred for {1} is not allowed in this context diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg12.java b/langtools/test/tools/javac/generics/diamond/neg/Neg12.java new file mode 100644 index 00000000000..4b8692230c2 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg12.java @@ -0,0 +1,15 @@ +/* + * @test /nodynamiccopyright/ + * @bug 7020043 + * + * @summary Project Coin: diamond allowed on non-generic type + * @author Rémi Forax + * @compile/fail/ref=Neg12.out Neg12.java -XDrawDiagnostics + * + */ + +class DiamondRaw { + public static void main(String[] args) { + String s = new String<>("foo"); + } +} diff --git a/langtools/test/tools/javac/generics/diamond/neg/Neg12.out b/langtools/test/tools/javac/generics/diamond/neg/Neg12.out new file mode 100644 index 00000000000..b722d017fc2 --- /dev/null +++ b/langtools/test/tools/javac/generics/diamond/neg/Neg12.out @@ -0,0 +1,2 @@ +Neg12.java:13:27: compiler.err.cant.apply.diamond.1: java.lang.String, (compiler.misc.diamond.non.generic: java.lang.String) +1 error From 3b676c492537066b07afd99fba06c724697f8ed2 Mon Sep 17 00:00:00 2001 From: Kumar Srinivasan Date: Fri, 18 Feb 2011 08:12:06 -0800 Subject: [PATCH 080/105] 7018859: javac turn off the Zip optimization by default Reviewed-by: jjg --- .../tools/javac/file/JavacFileManager.java | 7 +-- .../test/tools/javac/4241573/T4241573.java | 15 ++++-- .../javac/6508981/TestInferBinaryName.java | 9 ++-- .../test/tools/javac/api/6411310/Test.java | 46 +++++----------- langtools/test/tools/javac/api/T6838467.java | 36 ++++--------- langtools/test/tools/javac/api/T6877206.java | 54 ++++++------------- 6 files changed, 54 insertions(+), 113 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java index e4f621a585c..afcc3d750b8 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java +++ b/langtools/src/share/classes/com/sun/tools/javac/file/JavacFileManager.java @@ -164,9 +164,7 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil fsInfo = FSInfo.instance(context); - // retain check for system property for compatibility - useZipFileIndex = options.isUnset("useJavaUtilZip") - && System.getProperty("useJavaUtilZip") == null; + useZipFileIndex = options.isSet("useOptimizedZip"); if (useZipFileIndex) zipFileIndexCache = ZipFileIndexCache.getSharedInstance(); @@ -499,8 +497,7 @@ public class JavacFileManager extends BaseFileManager implements StandardJavaFil if (!useZipFileIndex) { zdir = new ZipFile(zipFileName); - } - else { + } else { usePreindexedCache = options.isSet("usezipindex"); preindexCacheLocation = options.get("java.io.tmpdir"); String optCacheLoc = options.get("cachezipindexdir"); diff --git a/langtools/test/tools/javac/4241573/T4241573.java b/langtools/test/tools/javac/4241573/T4241573.java index 4801256d398..cc51dbefff6 100644 --- a/langtools/test/tools/javac/4241573/T4241573.java +++ b/langtools/test/tools/javac/4241573/T4241573.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -123,7 +123,7 @@ public class T4241573 { if (!dir.mkdirs()) throw new Exception("cannot create directories " + dir); for (String e: entries) { - writeFile(new File(dir, getPathForEntry(e)), getBodyForEntry(e)); + writeFile(new File(dir, getPathForDirEntry(e)), getBodyForEntry(e)); } return dir; } @@ -134,7 +134,7 @@ public class T4241573 { try { JarOutputStream jos = new JarOutputStream(out); for (String e: entries) { - jos.putNextEntry(new JarEntry(getPathForEntry(e))); + jos.putNextEntry(new JarEntry(getPathForZipEntry(e))); jos.write(getBodyForEntry(e).getBytes()); } jos.close(); @@ -144,11 +144,16 @@ public class T4241573 { return jar; } - /** Return the path for an entry given to createDir or createJar. */ - String getPathForEntry(String e) { + /** Return the path for an entry given to createDir */ + String getPathForDirEntry(String e) { return e.replace(".", File.separator) + ".java"; } + /** Return the path for an entry given to createJar. */ + String getPathForZipEntry(String e) { + return e.replace(".", "/") + ".java"; + } + /** Return the body text for an entry given to createDir or createJar. */ String getBodyForEntry(String e) { int sep = e.lastIndexOf("."); diff --git a/langtools/test/tools/javac/6508981/TestInferBinaryName.java b/langtools/test/tools/javac/6508981/TestInferBinaryName.java index d866edcfe8f..aeb91cfebba 100644 --- a/langtools/test/tools/javac/6508981/TestInferBinaryName.java +++ b/langtools/test/tools/javac/6508981/TestInferBinaryName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -138,12 +138,11 @@ public class TestInferBinaryName { boolean zipFileIndexKind) throws IOException { Context ctx = new Context(); + Options options = Options.instance(ctx); // uugh, ugly back door, should be cleaned up, someday if (zipFileIndexKind == USE_ZIP_FILE_INDEX) - System.clearProperty("useJavaUtilZip"); - else - System.setProperty("useJavaUtilZip", "true"); - Options options = Options.instance(ctx); + options.put("useOptimizedZip", "true"); + if (symFileKind == IGNORE_SYMBOL_FILE) options.put("ignore.symbol.file", "true"); JavacFileManager fm = new JavacFileManager(ctx, false, null); diff --git a/langtools/test/tools/javac/api/6411310/Test.java b/langtools/test/tools/javac/api/6411310/Test.java index 463f4dbddfe..b7702d705a6 100644 --- a/langtools/test/tools/javac/api/6411310/Test.java +++ b/langtools/test/tools/javac/api/6411310/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -59,12 +59,12 @@ public class Test { test(createFileManager(), createDir("dir", entries), "p", entries); test(createFileManager(), createDir("a b/dir", entries), "p", entries); - for (boolean useJavaUtilZip: new boolean[] { false, true }) { - test(createFileManager(useJavaUtilZip), createJar("jar", entries), "p", entries); - test(createFileManager(useJavaUtilZip), createJar("jar jar", entries), "p", entries); + for (boolean useOptimizedZip: new boolean[] { false, true }) { + test(createFileManager(useOptimizedZip), createJar("jar", entries), "p", entries); + test(createFileManager(useOptimizedZip), createJar("jar jar", entries), "p", entries); for (boolean useSymbolFile: new boolean[] { false, true }) { - test(createFileManager(useJavaUtilZip, useSymbolFile), rt_jar, "java.lang.ref", null); + test(createFileManager(useOptimizedZip, useSymbolFile), rt_jar, "java.lang.ref", null); } } @@ -145,42 +145,22 @@ public class Test { return createFileManager(false, false); } - JavacFileManager createFileManager(boolean useJavaUtilZip) { - return createFileManager(useJavaUtilZip, false); + JavacFileManager createFileManager(boolean useOptimizedZip) { + return createFileManager(useOptimizedZip, false); } - JavacFileManager createFileManager(boolean useJavaUtilZip, boolean useSymbolFile) { - // javac should really not be using system properties like this - // -- it should really be using (hidden) options -- but until then - // take care to leave system properties as we find them, so as not - // to adversely affect other tests that might follow. - String prev = System.getProperty("useJavaUtilZip"); - boolean resetProperties = false; - try { - if (useJavaUtilZip) { - System.setProperty("useJavaUtilZip", "true"); - resetProperties = true; - } else if (System.getProperty("useJavaUtilZip") != null) { - System.getProperties().remove("useJavaUtilZip"); - resetProperties = true; + JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) { + Context c = new Context(); + Options options = Options.instance(c); + + if (useOptimizedZip) { + options.put("useOptimizedZip", "true"); } - Context c = new Context(); if (!useSymbolFile) { - Options options = Options.instance(c); options.put("ignore.symbol.file", "true"); } - return new JavacFileManager(c, false, null); - } finally { - if (resetProperties) { - if (prev == null) { - System.getProperties().remove("useJavaUtilZip"); - } else { - System.setProperty("useJavaUtilZip", prev); - } - } - } } File createDir(String name, String... entries) throws Exception { diff --git a/langtools/test/tools/javac/api/T6838467.java b/langtools/test/tools/javac/api/T6838467.java index b8070e2c9b1..daa5a654a76 100644 --- a/langtools/test/tools/javac/api/T6838467.java +++ b/langtools/test/tools/javac/api/T6838467.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -32,7 +32,9 @@ import java.util.*; import java.util.zip.*; import javax.tools.*; import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.main.OptionName; import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.Options; public class T6838467 { boolean fileSystemIsCaseSignificant = !new File("a").equals(new File("A")); @@ -176,33 +178,13 @@ public class T6838467 { return fm; } - JavacFileManager createFileManager(boolean useJavaUtilZip) { - // javac should really not be using system properties like this - // -- it should really be using (hidden) options -- but until then - // take care to leave system properties as we find them, so as not - // to adversely affect other tests that might follow. - String prev = System.getProperty("useJavaUtilZip"); - boolean resetProperties = false; - try { - if (useJavaUtilZip) { - System.setProperty("useJavaUtilZip", "true"); - resetProperties = true; - } else if (System.getProperty("useJavaUtilZip") != null) { - System.getProperties().remove("useJavaUtilZip"); - resetProperties = true; - } - - Context c = new Context(); - return new JavacFileManager(c, false, null); - } finally { - if (resetProperties) { - if (prev == null) { - System.getProperties().remove("useJavaUtilZip"); - } else { - System.setProperty("useJavaUtilZip", prev); - } - } + JavacFileManager createFileManager(boolean useOptimedZipIndex) { + Context ctx = new Context(); + if (useOptimedZipIndex) { + Options options = Options.instance(ctx); + options.put("useOptimizedZip", "true"); } + return new JavacFileManager(ctx, false, null); } // create a directory containing a given set of paths diff --git a/langtools/test/tools/javac/api/T6877206.java b/langtools/test/tools/javac/api/T6877206.java index 4bd4af18505..5a8442ad22a 100644 --- a/langtools/test/tools/javac/api/T6877206.java +++ b/langtools/test/tools/javac/api/T6877206.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -63,12 +63,12 @@ public class T6877206 { test(createFileManager(), createDir("dir", entries), "p", entries.length); test(createFileManager(), createDir("a b/dir", entries), "p", entries.length); - for (boolean useJavaUtilZip: new boolean[] { false, true }) { - test(createFileManager(useJavaUtilZip), createJar("jar", entries), "p", entries.length); - test(createFileManager(useJavaUtilZip), createJar("jar jar", entries), "p", entries.length); + for (boolean useOptimizedZip: new boolean[] { false, true }) { + test(createFileManager(useOptimizedZip), createJar("jar", entries), "p", entries.length); + test(createFileManager(useOptimizedZip), createJar("jar jar", entries), "p", entries.length); for (boolean useSymbolFile: new boolean[] { false, true }) { - test(createFileManager(useJavaUtilZip, useSymbolFile), rt_jar, "java.lang.ref", -1); + test(createFileManager(useOptimizedZip, useSymbolFile), rt_jar, "java.lang.ref", -1); } } @@ -161,42 +161,20 @@ public class T6877206 { return createFileManager(false, false); } - JavacFileManager createFileManager(boolean useJavaUtilZip) { - return createFileManager(useJavaUtilZip, false); + JavacFileManager createFileManager(boolean useOptimizedZip) { + return createFileManager(useOptimizedZip, false); } - JavacFileManager createFileManager(boolean useJavaUtilZip, boolean useSymbolFile) { - // javac should really not be using system properties like this - // -- it should really be using (hidden) options -- but until then - // take care to leave system properties as we find them, so as not - // to adversely affect other tests that might follow. - String prev = System.getProperty("useJavaUtilZip"); - boolean resetProperties = false; - try { - if (useJavaUtilZip) { - System.setProperty("useJavaUtilZip", "true"); - resetProperties = true; - } else if (System.getProperty("useJavaUtilZip") != null) { - System.getProperties().remove("useJavaUtilZip"); - resetProperties = true; - } - - Context c = new Context(); - if (!useSymbolFile) { - Options options = Options.instance(c); - options.put("ignore.symbol.file", "true"); - } - - return new JavacFileManager(c, false, null); - } finally { - if (resetProperties) { - if (prev == null) { - System.getProperties().remove("useJavaUtilZip"); - } else { - System.setProperty("useJavaUtilZip", prev); - } - } + JavacFileManager createFileManager(boolean useOptimizedZip, boolean useSymbolFile) { + Context ctx = new Context(); + Options options = Options.instance(ctx); + if (useOptimizedZip) { + options.put("useOptimizedZip", "true"); } + if (!useSymbolFile) { + options.put("ignore.symbol.file", "true"); + } + return new JavacFileManager(ctx, false, null); } File createDir(String name, String... entries) throws Exception { From 0f411471669c47f5d946905c3d362ba58cb7f95b Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Fri, 18 Feb 2011 16:17:44 +0000 Subject: [PATCH 081/105] 7020626: diamond: add diagnostic test for diamond and non-generic classes Fix failure in regression test CheckExamples Reviewed-by: jjg --- .../diags/examples/DiamondNonGeneric.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 langtools/test/tools/javac/diags/examples/DiamondNonGeneric.java diff --git a/langtools/test/tools/javac/diags/examples/DiamondNonGeneric.java b/langtools/test/tools/javac/diags/examples/DiamondNonGeneric.java new file mode 100644 index 00000000000..fa01e3ae3a5 --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/DiamondNonGeneric.java @@ -0,0 +1,29 @@ +/* + * 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. + */ + +// key: compiler.misc.diamond.non.generic +// key: compiler.err.cant.apply.diamond.1 + +class DiamondNonGeneric { + String s = new String<>("foo"); +} From 5ddedf5391e11cc828140b821b1abb74e576ebef Mon Sep 17 00:00:00 2001 From: Alexander Potochkin Date: Fri, 18 Feb 2011 19:21:57 +0300 Subject: [PATCH 082/105] 6474153: LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size Reviewed-by: rupashka --- .../classes/javax/swing/LookAndFeel.java | 13 ++--- .../swing/LookAndFeel/6474153/bug6474153.java | 53 +++++++++++++++++++ 2 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 jdk/test/javax/swing/LookAndFeel/6474153/bug6474153.java diff --git a/jdk/src/share/classes/javax/swing/LookAndFeel.java b/jdk/src/share/classes/javax/swing/LookAndFeel.java index 8c61c18f96a..bcaa06247b9 100644 --- a/jdk/src/share/classes/javax/swing/LookAndFeel.java +++ b/jdk/src/share/classes/javax/swing/LookAndFeel.java @@ -332,12 +332,13 @@ public abstract class LookAndFeel { JTextComponent.KeyBinding[] rv = new JTextComponent.KeyBinding[keyBindingList.length / 2]; - for(int i = 0; i < keyBindingList.length; i += 2) { - KeyStroke keystroke = (keyBindingList[i] instanceof KeyStroke) - ? (KeyStroke)keyBindingList[i] - : KeyStroke.getKeyStroke((String)keyBindingList[i]); - String action = (String)keyBindingList[i+1]; - rv[i / 2] = new JTextComponent.KeyBinding(keystroke, action); + for(int i = 0; i < rv.length; i ++) { + Object o = keyBindingList[2 * i]; + KeyStroke keystroke = (o instanceof KeyStroke) + ? (KeyStroke) o + : KeyStroke.getKeyStroke((String) o); + String action = (String) keyBindingList[2 * i + 1]; + rv[i] = new JTextComponent.KeyBinding(keystroke, action); } return rv; diff --git a/jdk/test/javax/swing/LookAndFeel/6474153/bug6474153.java b/jdk/test/javax/swing/LookAndFeel/6474153/bug6474153.java new file mode 100644 index 00000000000..4ee5198f4cb --- /dev/null +++ b/jdk/test/javax/swing/LookAndFeel/6474153/bug6474153.java @@ -0,0 +1,53 @@ +/* + * 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. + */ + +/* @test + * @bug 6474153 + * @summary LookAndFeel.makeKeyBindings(...) doesn't ignore last element in keyBindingList with odd size + * @author Alexander Potochkin + */ + +import javax.swing.KeyStroke; +import javax.swing.LookAndFeel; +import javax.swing.text.DefaultEditorKit; +import javax.swing.text.JTextComponent; + +public class bug6474153 { + + public static void main(String... args) throws Exception { + checkArray(LookAndFeel.makeKeyBindings(new Object[] {"UP", DefaultEditorKit.upAction} )); + checkArray(LookAndFeel.makeKeyBindings(new Object[] {"UP", DefaultEditorKit.upAction, "PAGE_UP"} )); + } + + private static void checkArray(JTextComponent.KeyBinding[] keyActionArray) { + if (keyActionArray.length != 1) { + throw new RuntimeException("Wrong array lenght!"); + } + if (!DefaultEditorKit.upAction.equals(keyActionArray[0].actionName)) { + throw new RuntimeException("Wrong action name!"); + } + if (!KeyStroke.getKeyStroke("UP").equals(keyActionArray[0].key)) { + throw new RuntimeException("Wrong keystroke!"); + } + } +} From e70749d90d34863c7a79196ace4b5d7c4ac5ec70 Mon Sep 17 00:00:00 2001 From: Pavel Porvatov Date: Fri, 18 Feb 2011 20:09:35 +0300 Subject: [PATCH 083/105] 6997102: Test case has hard code, so that applet thread threw exception Reviewed-by: alexp --- .../JFileChooser/6798062/bug6798062.html | 2 ++ .../JFileChooser/6798062/bug6798062.java | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/jdk/test/javax/swing/JFileChooser/6798062/bug6798062.html b/jdk/test/javax/swing/JFileChooser/6798062/bug6798062.html index 12955f6eee7..80a3e1c503d 100644 --- a/jdk/test/javax/swing/JFileChooser/6798062/bug6798062.html +++ b/jdk/test/javax/swing/JFileChooser/6798062/bug6798062.html @@ -1,6 +1,8 @@ +The test is suitable only for Windows + 1. Create a link 2. Copy path to the link into TextField 3. Run the Windows Task Manager. Select the Processes tab and find the java process diff --git a/jdk/test/javax/swing/JFileChooser/6798062/bug6798062.java b/jdk/test/javax/swing/JFileChooser/6798062/bug6798062.java index 44d59dc8278..45df0b643de 100644 --- a/jdk/test/javax/swing/JFileChooser/6798062/bug6798062.java +++ b/jdk/test/javax/swing/JFileChooser/6798062/bug6798062.java @@ -28,6 +28,7 @@ @run applet/manual=done bug6798062.html */ +import sun.awt.OSInfo; import sun.awt.shell.ShellFolder; import javax.swing.*; @@ -68,13 +69,23 @@ public class bug6798062 extends JApplet { add(initialize()); } - private JPanel initialize() { - File file = new File("c:/"); + private JComponent initialize() { + if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) { + return new JLabel("The test is suitable only for Windows"); + } + + String tempDir = System.getProperty("java.io.tmpdir"); + + if (tempDir.length() == 0) { // 'java.io.tmpdir' isn't guaranteed to be defined + tempDir = System.getProperty("user.home"); + } + + System.out.println("Temp directory: " + tempDir); try { - folder = ShellFolder.getShellFolder(file); + folder = ShellFolder.getShellFolder(new File(tempDir)); } catch (FileNotFoundException e) { - fail("Directory " + file.getPath() + " not found"); + fail("Directory " + tempDir + " not found"); } slider.setMajorTickSpacing(10); From e640a52207b76266524d53397a8d4047aacac2de Mon Sep 17 00:00:00 2001 From: Phil Race Date: Fri, 18 Feb 2011 09:14:07 -0800 Subject: [PATCH 084/105] 6857592: Getting warning while moving or resizing the frame when component.printAll() is called on local JNI Reviewed-by: bae, flar --- .../native/sun/java2d/windows/GDIBlitLoops.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/jdk/src/windows/native/sun/java2d/windows/GDIBlitLoops.cpp b/jdk/src/windows/native/sun/java2d/windows/GDIBlitLoops.cpp index d9d2a000b96..d3dc21dae14 100644 --- a/jdk/src/windows/native/sun/java2d/windows/GDIBlitLoops.cpp +++ b/jdk/src/windows/native/sun/java2d/windows/GDIBlitLoops.cpp @@ -107,8 +107,16 @@ Java_sun_java2d_windows_GDIBlitLoops_nativeBlit // could retain their own DIB info and we would not need to // recreate it every time. + // GetRasInfo implicitly calls GetPrimitiveArrayCritical + // and since GetDC uses JNI it needs to be called first. + HDC hDC = dstOps->GetDC(env, dstOps, 0, NULL, clip, NULL, 0); + if (hDC == NULL) { + SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); + return; + } srcOps->GetRasInfo(env, srcOps, &srcInfo); if (srcInfo.rasBase == NULL) { + dstOps->ReleaseDC(env, dstOps, hDC); SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); return; } @@ -174,13 +182,6 @@ Java_sun_java2d_windows_GDIBlitLoops_nativeBlit bmi.colors.dwMasks[2] = bmask; } - HDC hDC = dstOps->GetDC(env, dstOps, 0, NULL, clip, NULL, 0); - if (hDC == NULL) { - SurfaceData_InvokeRelease(env, srcOps, &srcInfo); - SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); - return; - } - if (fastBlt) { // Window could go away at any time, leaving bits on the screen // from this GDI call, so make sure window still exists From 7b9e1ea0d5df2d06973edf35ab2bec755c50c534 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Fri, 18 Feb 2011 09:18:32 -0800 Subject: [PATCH 085/105] 7017637: closed/java/awt/font/StyledMetrics/BoldSpace.java failed : Space char should have 0 advance Reviewed-by: igor, jgodinez --- .../awt/font/StyledMetrics/BoldSpace.java | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 jdk/test/java/awt/font/StyledMetrics/BoldSpace.java diff --git a/jdk/test/java/awt/font/StyledMetrics/BoldSpace.java b/jdk/test/java/awt/font/StyledMetrics/BoldSpace.java new file mode 100644 index 00000000000..bbdff5feebe --- /dev/null +++ b/jdk/test/java/awt/font/StyledMetrics/BoldSpace.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2008, 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. + */ + +/* + @test + @bug 6686365 7017637 + @summary Confirm that styling does not affect metrics of zero advance glyphs +*/ + +import java.awt.*; +import java.awt.image.*; + +public class BoldSpace { + public static void main(String[] s) { + BufferedImage bi = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB); + + String errMsg = "ZWJ Space char should have 0 advance\n"; + + Graphics g = bi.getGraphics(); + + // It turns out that some fonts inexplicably treat this as + // a standard character. In this 14 pt font, if we see an advance + // that's clearly bigger than we'd have introduced in bolding we'll + // not error out this test, presuming that its a consequence of + // the actual font data. A Linux font 'TLwg Type Bold' is the case + // in point. + int errorMargin = 4; + g.setFont(new Font("monospaced", Font.BOLD, 14)); + //g.setFont(new Font("Lucida Sans Regular", Font.BOLD, 14)); + FontMetrics fm = g.getFontMetrics(); + System.out.println("Bold: " + fm.charWidth('\u200b')); + int cwid = fm.charWidth('\u200b'); + if (cwid > 0 && cwid < errorMargin) { + throw new RuntimeException(errMsg); + } + + ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB); + fm = g.getFontMetrics(); + System.out.println("Bold + LCD: "+fm.charWidth('\u200b')); + cwid = fm.charWidth('\u200b'); + if (cwid > 0 && cwid < errorMargin) { + throw new RuntimeException(errMsg); + } + + + ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, + RenderingHints.VALUE_FRACTIONALMETRICS_ON); + ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + fm = g.getFontMetrics(); + System.out.println("Bold FM OFF + AA: " + fm.charWidth('\u200b')); + cwid = fm.charWidth('\u200b'); + if (cwid > 0 && cwid < errorMargin) { + throw new RuntimeException(errMsg); + } + + ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, + RenderingHints.VALUE_FRACTIONALMETRICS_OFF); + ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + fm = g.getFontMetrics(); + System.out.println("Bold FM ON + AA: " + fm.charWidth('\u200b')); + cwid = fm.charWidth('\u200b'); + if (cwid > 0 && cwid < errorMargin) { + throw new RuntimeException(errMsg); + } + + ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, + RenderingHints.VALUE_FRACTIONALMETRICS_ON); + ((Graphics2D)g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); + fm = g.getFontMetrics(); + System.out.println("Bold FM ON + nonAA: " + fm.charWidth('\u200b')); + cwid = fm.charWidth('\u200b'); + if (cwid > 0 && cwid < errorMargin) { + throw new RuntimeException(errMsg); + } + + System.out.println("All printed values should be 0 to PASS"); + } +} From b88a6b82c58ee30f92098a9e050b331753bcf314 Mon Sep 17 00:00:00 2001 From: Jennifer Godinez Date: Fri, 18 Feb 2011 11:15:40 -0800 Subject: [PATCH 086/105] 6722351: sun.print.Win32PrintService.initMedia() is slow Reviewed-by: igor, prr --- .../classes/sun/print/Win32PrintService.java | 188 +++++++++++------- 1 file changed, 119 insertions(+), 69 deletions(-) diff --git a/jdk/src/windows/classes/sun/print/Win32PrintService.java b/jdk/src/windows/classes/sun/print/Win32PrintService.java index 2697032f6e3..5b2734e1880 100644 --- a/jdk/src/windows/classes/sun/print/Win32PrintService.java +++ b/jdk/src/windows/classes/sun/print/Win32PrintService.java @@ -31,6 +31,7 @@ import java.net.URISyntaxException; import java.net.URL; import java.util.Vector; +import java.util.HashMap; import javax.print.DocFlavor; import javax.print.DocPrintJob; @@ -205,6 +206,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater, private MediaPrintableArea[] mediaPrintables; private MediaTray[] mediaTrays; private PrinterResolution[] printRes; + private HashMap mpaMap; private int nCopies; private int prnCaps; private int[] defaultSettings; @@ -212,6 +214,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater, private boolean gotTrays; private boolean gotCopies; private boolean mediaInitialized; + private boolean mpaListInitialized; private ArrayList idList; private MediaSize[] mediaSizes; @@ -380,43 +383,115 @@ public class Win32PrintService implements PrintService, AttributeUpdater, // Add mediaName to the msnList if (mediaName != null) { added = addToUniqueList(msnList, mediaName); - - // get MediaPrintableArea only for supported MediaSizeName ? - if (added && !queryFailure) { - prnArea=getMediaPrintableArea(printer, - ((Integer)idList.get(i)).intValue()); - if (prnArea != null) { - try { - MediaPrintableArea mpa = - new MediaPrintableArea(prnArea[0], - prnArea[1], - prnArea[2], - prnArea[3], - MediaPrintableArea.INCH); - printableList.add(mpa); - } catch (IllegalArgumentException iae) { - } - } else { - // Calling getMediaPrintableArea causes - // much overhead so if first attempt failed, we should - // just bail out. - if (i==0) { - queryFailure = true; - } - } - } } } // init mediaSizeNames mediaSizeNames = new MediaSizeName[msnList.size()]; msnList.toArray(mediaSizeNames); - - // init mediaPrintables - mediaPrintables = new MediaPrintableArea[printableList.size()]; - printableList.toArray(mediaPrintables); } + + /* + * Gets a list of MediaPrintableAreas using a call to native function. + * msn is MediaSizeName used to get a specific printable area. If null, + * it will get all the supported MediPrintableAreas. + */ + private synchronized MediaPrintableArea[] getMediaPrintables(MediaSizeName msn) + { + if (msn == null) { + if (mpaListInitialized == true) { + return mediaPrintables; + } + } else { + // get from cached mapping of MPAs + if (mpaMap != null && (mpaMap.get(msn) != null)) { + MediaPrintableArea[] mpaArr = new MediaPrintableArea[1]; + mpaArr[0] = (MediaPrintableArea)mpaMap.get(msn); + return mpaArr; + } + } + + initMedia(); + + if ((mediaSizeNames == null) && (mediaSizeNames.length == 0)) { + return null; + } + + MediaSizeName[] loopNames; + if (msn != null) { + loopNames = new MediaSizeName[1]; + loopNames[0] = msn; + } else { + loopNames = mediaSizeNames; + } + + if (mpaMap == null) { + mpaMap = new HashMap(); + } + + for (int i=0; i < loopNames.length; i++) { + MediaSizeName mediaName = loopNames[i]; + + if (mpaMap.get(mediaName) != null) { + continue; + } + + if (mediaName != null) { + int defPaper = findPaperID(mediaName); + float[] prnArea = getMediaPrintableArea(printer, defPaper); + MediaPrintableArea printableArea = null; + if (prnArea != null) { + try { + printableArea = new MediaPrintableArea(prnArea[0], + prnArea[1], + prnArea[2], + prnArea[3], + MediaPrintableArea.INCH); + + mpaMap.put(mediaName, printableArea); + } + catch (IllegalArgumentException e) { + } + } else { + // if getting MPA failed, we use MediaSize + MediaSize ms = + MediaSize.getMediaSizeForName((MediaSizeName)mediaName); + + if (ms != null) { + try { + printableArea = new MediaPrintableArea(0, 0, + ms.getX(MediaSize.INCH), + ms.getY(MediaSize.INCH), + MediaPrintableArea.INCH); + mpaMap.put(mediaName, printableArea); + } catch (IllegalArgumentException e) { + } + } + } + } //mediaName != null + } + + if (mpaMap.size() == 0) { + return null; + } + + if (msn != null) { + if (mpaMap.get(msn) == null) { + return null; + } + MediaPrintableArea[] mpaArr = new MediaPrintableArea[1]; + // by this time, we've already gotten the desired MPA + mpaArr[0] = (MediaPrintableArea)mpaMap.get(msn); + return mpaArr; + } else { + mediaPrintables = (MediaPrintableArea[])mpaMap.values().toArray(new MediaPrintableArea[0]); + mpaListInitialized = true; + return mediaPrintables; + } + } + + private synchronized MediaTray[] getMediaTrays() { if (gotTrays == true && mediaTrays != null) { return mediaTrays; @@ -626,7 +701,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater, private boolean isSupportedMediaPrintableArea(MediaPrintableArea mpa) { - initMedia(); + getMediaPrintables(null); if (mediaPrintables != null) { for (int i=0; i Date: Fri, 18 Feb 2011 12:43:14 -0800 Subject: [PATCH 087/105] 7018385: update javax.sql classes to use try-with-resources Reviewed-by: alanb, lancea, darcy --- .../javax/sql/rowset/serial/SerialClob.java | 63 +++++++++++-------- .../javax/sql/rowset/spi/SyncFactory.java | 18 ++++-- 2 files changed, 50 insertions(+), 31 deletions(-) diff --git a/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java b/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java index ff482082e7c..ad7238d1baf 100644 --- a/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java +++ b/jdk/src/share/classes/javax/sql/rowset/serial/SerialClob.java @@ -57,10 +57,10 @@ public class SerialClob implements Clob, Serializable, Cloneable { private char buf[]; /** - * Internal Clob representation if SerialClob is intialized with a - * Clob + * Internal Clob representation if SerialClob is initialized with a + * Clob. Null if SerialClob is initialized with a char[]. */ - private Clob clob; + private final Clob clob; /** * The length in characters of this SerialClob object's @@ -71,12 +71,12 @@ public class SerialClob implements Clob, Serializable, Cloneable { private long len; /** - * The original length in characters of tgus SerialClob - * objects internal array of characters. + * The original length in characters of this SerialClob + * object's internal array of characters. * * @serial */ - private long origLen; + private final long origLen; /** * Constructs a SerialClob object that is a serialized version of @@ -104,6 +104,7 @@ public class SerialClob implements Clob, Serializable, Cloneable { buf[i] = ch[i]; } origLen = len; + clob = null; } /** @@ -117,19 +118,19 @@ public class SerialClob implements Clob, Serializable, Cloneable { * the database. Otherwise, the new SerialClob object * object will contain no data. *

- * Note: The Clob object supplied to this constructor cannot - * return null for the Clob.getCharacterStream() + * Note: The Clob object supplied to this constructor must + * return non-null for both the Clob.getCharacterStream() * and Clob.getAsciiStream methods. This SerialClob - * constructor cannot serialize a Clob object in this instance + * constructor cannot serialize a Clob object in this instance * and will throw an SQLException object. * * @param clob the Clob object from which this * SerialClob object is to be constructed; cannot be null * @throws SerialException if an error occurs during serialization * @throws SQLException if a SQL error occurs in capturing the CLOB; - * if the Clob object is a null; or if both the + * if the Clob object is a null; or if either of the * Clob.getCharacterStream() and Clob.getAsciiStream() - * methods on the Clob return a null + * methods on the Clob returns a null * @see java.sql.Clob */ public SerialClob(Clob clob) throws SerialException, SQLException { @@ -144,19 +145,27 @@ public class SerialClob implements Clob, Serializable, Cloneable { int read = 0; int offset = 0; - BufferedReader reader; - if ( (((reader = new BufferedReader(clob.getCharacterStream())) == null)) && - (clob.getAsciiStream() == null)) { - throw new SQLException("Invalid Clob object. Calls to getCharacterStream " + - "and getAsciiStream return null which cannot be serialized."); - } + try (Reader charStream = clob.getCharacterStream()) { + if (charStream == null) { + throw new SQLException("Invalid Clob object. The call to getCharacterStream " + + "returned null which cannot be serialized."); + } - try { - do { - read = reader.read(buf, offset, (int)(len - offset)); - offset += read; - } while (read > 0); + // Note: get an ASCII stream in order to null-check it, + // even though we don't do anything with it. + try (InputStream asciiStream = clob.getAsciiStream()) { + if (asciiStream == null) { + throw new SQLException("Invalid Clob object. The call to getAsciiStream " + + "returned null which cannot be serialized."); + } + } + try (Reader reader = new BufferedReader(charStream)) { + do { + read = reader.read(buf, offset, (int)(len - offset)); + offset += read; + } while (read > 0); + } } catch (java.io.IOException ex) { throw new SerialException("SerialClob: " + ex.getMessage()); } @@ -207,13 +216,13 @@ public class SerialClob implements Clob, Serializable, Cloneable { * used to create this SerialClob object */ public java.io.InputStream getAsciiStream() throws SerialException, SQLException { - if (this.clob != null) { - return this.clob.getAsciiStream(); - } else { - throw new SerialException("Unsupported operation. SerialClob cannot " + + if (this.clob != null) { + return this.clob.getAsciiStream(); + } else { + throw new SerialException("Unsupported operation. SerialClob cannot " + "return a the CLOB value as an ascii stream, unless instantiated " + "with a fully implemented Clob object."); - } + } } /** diff --git a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java index f3358e0fb12..b52f345caf5 100644 --- a/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java +++ b/jdk/src/share/classes/javax/sql/rowset/spi/SyncFactory.java @@ -32,6 +32,7 @@ import java.sql.*; import javax.sql.*; import java.io.FileInputStream; +import java.io.InputStream; import java.io.IOException; import java.io.FileNotFoundException; @@ -366,7 +367,9 @@ public class SyncFactory { // Load user's implementation of SyncProvider // here. -Drowset.properties=/abc/def/pqr.txt ROWSET_PROPERTIES = strRowsetProperties; - properties.load(new FileInputStream(ROWSET_PROPERTIES)); + try (FileInputStream fis = new FileInputStream(ROWSET_PROPERTIES)) { + properties.load(fis); + } parseProperties(properties); } @@ -376,12 +379,19 @@ public class SyncFactory { ROWSET_PROPERTIES = "javax" + strFileSep + "sql" + strFileSep + "rowset" + strFileSep + "rowset.properties"; - // properties.load( - // ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES)); ClassLoader cl = Thread.currentThread().getContextClassLoader(); - properties.load(cl.getResourceAsStream(ROWSET_PROPERTIES)); + try (InputStream stream = + (cl == null) ? ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES) + : cl.getResourceAsStream(ROWSET_PROPERTIES)) { + if (stream == null) { + throw new SyncFactoryException( + "Resource " + ROWSET_PROPERTIES + " not found"); + } + properties.load(stream); + } + parseProperties(properties); // removed else, has properties should sum together From 00a47ca240ab184f4f66bd247cf4f909baf29ab3 Mon Sep 17 00:00:00 2001 From: Jennifer Godinez Date: Fri, 18 Feb 2011 13:47:07 -0800 Subject: [PATCH 088/105] 6850806: NPE exception throws in PrintServce.getSupportedAttributeValues Reviewed-by: igor, prr --- jdk/src/windows/classes/sun/print/Win32PrintService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/windows/classes/sun/print/Win32PrintService.java b/jdk/src/windows/classes/sun/print/Win32PrintService.java index 5b2734e1880..6e60888092f 100644 --- a/jdk/src/windows/classes/sun/print/Win32PrintService.java +++ b/jdk/src/windows/classes/sun/print/Win32PrintService.java @@ -1325,7 +1325,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater, } if (trays != null) { System.arraycopy(trays, 0, arr, - mediaSizeNames.length, trays.length); + len - trays.length, trays.length); } return arr; } else if (category == MediaPrintableArea.class) { From 3899f14f1f9c96304ac1400935cefc2021aa55f3 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Fri, 18 Feb 2011 18:26:17 -0500 Subject: [PATCH 089/105] 7019557: SharedMiscDataSize too small for 64-bit fastdebug JVM Increase default SharedMiscDataSize Reviewed-by: dcubed, kamg --- 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 e900b6ce8e2..b67c54cd433 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -3692,7 +3692,7 @@ class CommandLineFlags { product(uintx, SharedReadOnlySize, 10*M, \ "Size of read-only space in permanent generation (in bytes)") \ \ - product(uintx, SharedMiscDataSize, 4*M, \ + product(uintx, SharedMiscDataSize, NOT_LP64(4*M) LP64_ONLY(5*M), \ "Size of the shared data area adjacent to the heap (in bytes)") \ \ product(uintx, SharedMiscCodeSize, 4*M, \ From dc728d5d5ae71f685f5a17551eb5796907ba813b Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Fri, 18 Feb 2011 15:55:20 -0800 Subject: [PATCH 090/105] 7020047: Project Coin: generate null-check around try-with-resources close call Reviewed-by: jjg --- .../com/sun/tools/javac/comp/Lower.java | 78 ++++++++++++++----- .../javac/TryWithResources/TwrNullTests.java | 72 +++++++++++++++++ 2 files changed, 130 insertions(+), 20 deletions(-) create mode 100644 langtools/test/tools/javac/TryWithResources/TwrNullTests.java diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java index 8675759f3a6..03e3d21322e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java @@ -1425,25 +1425,55 @@ public class Lower extends TreeTranslator { } } - /** Optionally replace a try statement with an automatic resource - * management (ARM) block. + /** + * Optionally replace a try statement with the desugaring of a + * try-with-resources statement. The canonical desugaring of + * + * try ResourceSpecification + * Block + * + * is + * + * { + * final VariableModifiers_minus_final R #resource = Expression; + * Throwable #primaryException = null; + * + * try ResourceSpecificationtail + * Block + * catch (Throwable #t) { + * #primaryException = t; + * throw #t; + * } finally { + * if (#resource != null) { + * if (#primaryException != null) { + * try { + * #resource.close(); + * } catch(Throwable #suppressedException) { + * #primaryException.addSuppressed(#suppressedException); + * } + * } else { + * #resource.close(); + * } + * } + * } + * * @param tree The try statement to inspect. - * @return An ARM block, or the original try block if there are no - * resources to manage. + * @return A a desugared try-with-resources tree, or the original + * try block if there are no resources to manage. */ - JCTree makeArmTry(JCTry tree) { + JCTree makeTwrTry(JCTry tree) { make_at(tree.pos()); twrVars = twrVars.dup(); - JCBlock armBlock = makeArmBlock(tree.resources, tree.body, 0); + JCBlock twrBlock = makeTwrBlock(tree.resources, tree.body, 0); if (tree.catchers.isEmpty() && tree.finalizer == null) - result = translate(armBlock); + result = translate(twrBlock); else - result = translate(make.Try(armBlock, tree.catchers, tree.finalizer)); + result = translate(make.Try(twrBlock, tree.catchers, tree.finalizer)); twrVars = twrVars.leave(); return result; } - private JCBlock makeArmBlock(List resources, JCBlock block, int depth) { + private JCBlock makeTwrBlock(List resources, JCBlock block, int depth) { if (resources.isEmpty()) return block; @@ -1497,16 +1527,16 @@ public class Lower extends TreeTranslator { int oldPos = make.pos; make.at(TreeInfo.endPos(block)); - JCBlock finallyClause = makeArmFinallyClause(primaryException, expr); + JCBlock finallyClause = makeTwrFinallyClause(primaryException, expr); make.at(oldPos); - JCTry outerTry = make.Try(makeArmBlock(resources.tail, block, depth + 1), + JCTry outerTry = make.Try(makeTwrBlock(resources.tail, block, depth + 1), List.of(catchClause), finallyClause); stats.add(outerTry); return make.Block(0L, stats.toList()); } - private JCBlock makeArmFinallyClause(Symbol primaryException, JCExpression resource) { + private JCBlock makeTwrFinallyClause(Symbol primaryException, JCExpression resource) { // primaryException.addSuppressed(catchException); VarSymbol catchException = new VarSymbol(0, make.paramName(2), @@ -1525,22 +1555,30 @@ public class Lower extends TreeTranslator { List catchClauses = List.of(make.Catch(catchExceptionDecl, catchBlock)); JCTry tryTree = make.Try(tryBlock, catchClauses, null); - // if (resource != null) resourceClose; - JCExpression nullCheck = makeBinary(JCTree.NE, - make.Ident(primaryException), - makeNull()); - JCIf closeIfStatement = make.If(nullCheck, + // if (primaryException != null) {try...} else resourceClose; + JCIf closeIfStatement = make.If(makeNonNullCheck(make.Ident(primaryException)), tryTree, makeResourceCloseInvocation(resource)); - return make.Block(0L, List.of(closeIfStatement)); + + // if (#resource != null) { if (primaryException ... } + return make.Block(0L, + List.of(make.If(makeNonNullCheck(resource), + closeIfStatement, + null))); } private JCStatement makeResourceCloseInvocation(JCExpression resource) { // create resource.close() method invocation - JCExpression resourceClose = makeCall(resource, names.close, List.nil()); + JCExpression resourceClose = makeCall(resource, + names.close, + List.nil()); return make.Exec(resourceClose); } + private JCExpression makeNonNullCheck(JCExpression expression) { + return makeBinary(JCTree.NE, expression, makeNull()); + } + /** Construct a tree that represents the outer instance * . Never pick the current `this'. * @param pos The source code position to be used for the tree. @@ -3573,7 +3611,7 @@ public class Lower extends TreeTranslator { if (tree.resources.isEmpty()) { super.visitTry(tree); } else { - result = makeArmTry(tree); + result = makeTwrTry(tree); } } diff --git a/langtools/test/tools/javac/TryWithResources/TwrNullTests.java b/langtools/test/tools/javac/TryWithResources/TwrNullTests.java new file mode 100644 index 00000000000..93a976a50d4 --- /dev/null +++ b/langtools/test/tools/javac/TryWithResources/TwrNullTests.java @@ -0,0 +1,72 @@ +/* + * 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. + */ + +/* + * @test + * @bug 7020047 + * @summary Test null handling of try-with-resources statement + */ + +public class TwrNullTests { + /* + * Each try-with-resources statement generates two calls to the + * close method for each resource: one for when there is a primary + * exception present and the second for when a primary exception + * is absent. The null handling of both cases needs to be + * checked. + */ + public static void main(String... args) { + testNormalCompletion(); + testNoSuppression(); + } + + /* + * Verify empty try-with-resources on a null resource completes + * normally; no NPE from the generated close call. + */ + private static void testNormalCompletion() { + try(AutoCloseable resource = null) { + return; // Nothing to see here, move along. + } catch (Exception e) { + throw new AssertionError("Should not be reached", e); + } + } + + /* + * Verify that a NPE on a null resource is not added as a + * suppressed exception to an exception from try block. + */ + private static void testNoSuppression() { + try(AutoCloseable resource = null) { + throw new java.io.IOException(); + } catch(java.io.IOException ioe) { + Throwable[] suppressed = ioe.getSuppressed(); + if (suppressed.length != 0) { + throw new AssertionError("Non-empty suppressed exceptions", + ioe); + } + } catch (Exception e) { + throw new AssertionError("Should not be reached", e); + } + } +} From 46bcea93efe2a6303ce70ab035aefd2ee2cbd4a1 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Mon, 21 Feb 2011 11:26:45 +0100 Subject: [PATCH 091/105] 7020992: jmm_DumpThreads should not allocate system object arrays outside the perm gen Allocate ordinary object arrays Reviewed-by: ysr, never, mchung --- hotspot/src/share/vm/memory/oopFactory.cpp | 15 +++------------ hotspot/src/share/vm/memory/oopFactory.hpp | 1 - hotspot/src/share/vm/services/management.cpp | 4 ++-- 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/hotspot/src/share/vm/memory/oopFactory.cpp b/hotspot/src/share/vm/memory/oopFactory.cpp index 7ef11b15f08..c8b45b68a04 100644 --- a/hotspot/src/share/vm/memory/oopFactory.cpp +++ b/hotspot/src/share/vm/memory/oopFactory.cpp @@ -92,21 +92,12 @@ objArrayOop oopFactory::new_objArray(klassOop klass, int length, TRAPS) { } } -objArrayOop oopFactory::new_system_objArray(int length, bool in_perm_gen, TRAPS) { +objArrayOop oopFactory::new_system_objArray(int length, TRAPS) { int size = objArrayOopDesc::object_size(length); KlassHandle klass (THREAD, Universe::systemObjArrayKlassObj()); - oop o; - if (in_perm_gen) { - o = Universe::heap()->permanent_array_allocate(klass, size, length, CHECK_NULL); - } else { - o = Universe::heap()->array_allocate(klass, size, length, CHECK_NULL); - } + objArrayOop o = (objArrayOop) + Universe::heap()->permanent_array_allocate(klass, size, length, CHECK_NULL); // initialization not needed, allocated cleared - return (objArrayOop) o; -} - -objArrayOop oopFactory::new_system_objArray(int length, TRAPS) { - objArrayOop o = oopFactory::new_system_objArray(length, true, CHECK_NULL); return o; } diff --git a/hotspot/src/share/vm/memory/oopFactory.hpp b/hotspot/src/share/vm/memory/oopFactory.hpp index a2b34de8cda..49b89bc3b17 100644 --- a/hotspot/src/share/vm/memory/oopFactory.hpp +++ b/hotspot/src/share/vm/memory/oopFactory.hpp @@ -102,7 +102,6 @@ public: // System object arrays static objArrayOop new_system_objArray(int length, TRAPS); - static objArrayOop new_system_objArray(int length, bool in_perm_gen, TRAPS); // Regular object arrays static objArrayOop new_objArray(klassOop klass, int length, TRAPS); diff --git a/hotspot/src/share/vm/services/management.cpp b/hotspot/src/share/vm/services/management.cpp index fb2bda70712..3c4f1481c75 100644 --- a/hotspot/src/share/vm/services/management.cpp +++ b/hotspot/src/share/vm/services/management.cpp @@ -1311,7 +1311,7 @@ JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboo if (locked_monitors) { // Constructs Object[] and int[] to contain the object monitor and the stack depth // where the thread locked it - objArrayOop array = oopFactory::new_system_objArray(num_locked_monitors, false, CHECK_NULL); + objArrayOop array = oopFactory::new_objArray(SystemDictionary::Object_klass(), num_locked_monitors, CHECK_NULL); objArrayHandle mh(THREAD, array); monitors_array = mh; @@ -1353,7 +1353,7 @@ JVM_ENTRY(jobjectArray, jmm_DumpThreads(JNIEnv *env, jlongArray thread_ids, jboo GrowableArray* locks = (tcl != NULL ? tcl->owned_locks() : NULL); int num_locked_synchronizers = (locks != NULL ? locks->length() : 0); - objArrayOop array = oopFactory::new_system_objArray(num_locked_synchronizers, false, CHECK_NULL); + objArrayOop array = oopFactory::new_objArray(SystemDictionary::Object_klass(), num_locked_synchronizers, CHECK_NULL); objArrayHandle sh(THREAD, array); synchronizers_array = sh; From 99aa7bad62391379dab4c0c0b01b9a4e63409c91 Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Mon, 21 Feb 2011 13:37:22 -0800 Subject: [PATCH 092/105] 7001685: Renable EnumSetBash Test Reviewed-by: alanb, ohair, darcy --- jdk/test/ProblemList.txt | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index f2380764a1a..46b8cc1e855 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -41,14 +41,14 @@ # # Shell tests are othervm by default. # -# List items are testnames followed by labels, all MUST BE commented +# List items are testnames followed by labels, all MUST BE commented # as to why they are here and use a label: # generic-all Problems on all platforms # generic-ARCH Where ARCH is one of: sparc, sparcv9, x64, i586, etc. # OSNAME-all Where OSNAME is one of: solaris, linux, windows # OSNAME-ARCH Specific on to one OSNAME and ARCH, e.g. solaris-x64 # OSNAME-REV Specific on to one OSNAME and REV, e.g. solaris-5.8 -# +# # More than one label is allowed but must be on the same line. # ############################################################################# @@ -234,7 +234,7 @@ javax/management/remote/mandatory/threads/ExecutorTest.java generic-all # Linux 32bit Fedora 9, IllegalStateException javax/management/monitor/RuntimeExceptionTest.java generic-all -# Problems with rmi connection, othervm +# Problems with rmi connection, othervm javax/management/remote/mandatory/subjectDelegation/SubjectDelegation2Test.java generic-all # Fails with port already in use @@ -411,7 +411,7 @@ com/sun/nio/sctp/SctpChannel/SocketOptionTests.java com/sun/nio/sctp/SctpChannel/Send.java generic-all com/sun/nio/sctp/SctpChannel/Shutdown.java generic-all -# Fails on OpenSolaris, IllegalStateException: Cannot add or remove addresses +# Fails on OpenSolaris, IllegalStateException: Cannot add or remove addresses # from a channel that is bound to the wildcard address com/sun/nio/sctp/SctpChannel/Bind.java generic-all @@ -456,10 +456,10 @@ java/rmi/transport/pinLastArguments/PinLastArguments.java generic-all java/rmi/server/RemoteServer/AddrInUse.java generic-all # Connection error on Windows i586 -server -# Also connection errors in othervm on Solaris 10 sparc, same port??? +# Also connection errors in othervm on Solaris 10 sparc, same port??? sun/rmi/transport/tcp/DeadCachedConnection.java generic-all -# Connection errors in othervm on Solaris 10 sparc, same port??? +# Connection errors in othervm on Solaris 10 sparc, same port??? java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java generic-all java/rmi/activation/Activatable/checkAnnotations/CheckAnnotations.java generic-all java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java generic-all @@ -532,7 +532,7 @@ sun/security/pkcs11/ec/TestKeyFactory.java solaris-i586 java/security/Security/SynchronizedAccess.java generic-all # Failing on Solaris X64 (-d64 -server) with: -# GSSException: Failure unspecified at GSS-API level +# GSSException: Failure unspecified at GSS-API level # (Mechanism level: Specified version of key is not available (44)) sun/security/krb5/auto/BasicKrb5Test.java generic-all @@ -546,14 +546,14 @@ sun/security/tools/keytool/standard.sh generic-all sun/security/krb5/auto/HttpNegotiateServer.java generic-all # Fails on almost all platforms -# java.lang.UnsupportedClassVersionError: SerialTest : +# java.lang.UnsupportedClassVersionError: SerialTest : # Unsupported major.minor version 51.0 # at java.lang.ClassLoader.defineClass1(Native Method) sun/security/util/Oid/S11N.sh generic-all # Fails on Fedora 9 32bit -# GSSException: Failure unspecified at GSS-API level (Mechanism level: -# Invalid argument (400) - Cannot find key of appropriate type to decrypt +# GSSException: Failure unspecified at GSS-API level (Mechanism level: +# Invalid argument (400) - Cannot find key of appropriate type to decrypt # AP REP - DES CBC mode with MD5) # at sun.security.jgss.krb5.Krb5Context.acceptSecContext(Krb5Context.java:778) sun/security/krb5/auto/NonMutualSpnego.java generic-all @@ -673,7 +673,7 @@ sun/security/rsa/TestSignatures.java solaris-all # Timeout on solaris-sparc and i586 and x64, -client and -server sun/security/ssl/com/sun/net/ssl/internal/ssl/InputRecord/InterruptedIO.java solaris-all -# Do not seem to run on windows machines? dll missing? +# Do not seem to run on windows machines? dll missing? sun/security/tools/jarsigner/emptymanifest.sh windows-all # Files does not exist or no encoding? solaris-sparcv9 @@ -734,8 +734,5 @@ java/util/concurrent/FutureTask/BlockingTaskExecutor.java generic-all # Problems on windows, jmap.exe hangs? (these run jmap), fails on Solaris 10 x86 java/util/concurrent/locks/Lock/TimedAcquireLeak.java generic-all -# Fails on solaris-sparc -server (Set not equal to copy. 1) -java/util/EnumSet/EnumSetBash.java solaris-sparc - ############################################################################ From 8967db2c3580aefb1125ce23d0705f5560c9115f Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Tue, 22 Feb 2011 15:26:36 -0800 Subject: [PATCH 093/105] 7021531: lock ordering problems after fix for 6354181 Reviewed-by: kvn, jrose --- hotspot/src/share/vm/ci/ciEnv.cpp | 1 + hotspot/src/share/vm/utilities/ostream.cpp | 11 +++++++++++ hotspot/src/share/vm/utilities/ostream.hpp | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/hotspot/src/share/vm/ci/ciEnv.cpp b/hotspot/src/share/vm/ci/ciEnv.cpp index 521893b4929..14018b4729c 100644 --- a/hotspot/src/share/vm/ci/ciEnv.cpp +++ b/hotspot/src/share/vm/ci/ciEnv.cpp @@ -413,6 +413,7 @@ ciKlass* ciEnv::get_klass_by_name_impl(ciKlass* accessing_klass, } KlassHandle found_klass; { + ttyUnlocker ttyul; // release tty lock to avoid ordering problems MutexLocker ml(Compile_lock); klassOop kls; if (!require_local) { diff --git a/hotspot/src/share/vm/utilities/ostream.cpp b/hotspot/src/share/vm/utilities/ostream.cpp index 897dba137ac..26e630a187c 100644 --- a/hotspot/src/share/vm/utilities/ostream.cpp +++ b/hotspot/src/share/vm/utilities/ostream.cpp @@ -699,6 +699,17 @@ void ttyLocker::release_tty(intx holder) { defaultStream::instance->release(holder); } +bool ttyLocker::release_tty_if_locked() { + intx thread_id = os::current_thread_id(); + if (defaultStream::instance->writer() == thread_id) { + // release the lock and return true so callers know if was + // previously held. + release_tty(thread_id); + return true; + } + return false; +} + void ttyLocker::break_tty_lock_for_safepoint(intx holder) { if (defaultStream::instance != NULL && defaultStream::instance->writer() == holder) { diff --git a/hotspot/src/share/vm/utilities/ostream.hpp b/hotspot/src/share/vm/utilities/ostream.hpp index 1776a5b98e7..047cdac5821 100644 --- a/hotspot/src/share/vm/utilities/ostream.hpp +++ b/hotspot/src/share/vm/utilities/ostream.hpp @@ -123,18 +123,36 @@ extern outputStream* gclog_or_tty; // stream for gc log if -Xloggc:, or tty // advisory locking for the shared tty stream: class ttyLocker: StackObj { + friend class ttyUnlocker; private: intx _holder; public: static intx hold_tty(); // returns a "holder" token static void release_tty(intx holder); // must witness same token + static bool release_tty_if_locked(); // returns true if lock was released static void break_tty_lock_for_safepoint(intx holder); ttyLocker() { _holder = hold_tty(); } ~ttyLocker() { release_tty(_holder); } }; +// Release the tty lock if it's held and reacquire it if it was +// locked. Used to avoid lock ordering problems. +class ttyUnlocker: StackObj { + private: + bool _was_locked; + public: + ttyUnlocker() { + _was_locked = ttyLocker::release_tty_if_locked(); + } + ~ttyUnlocker() { + if (_was_locked) { + ttyLocker::hold_tty(); + } + } +}; + // for writing to strings; buffer will expand automatically class stringStream : public outputStream { protected: From b4bb5b3e26194ff21258cf4cdd572cc80af40e64 Mon Sep 17 00:00:00 2001 From: Jennifer Godinez Date: Thu, 24 Feb 2011 15:00:50 -0800 Subject: [PATCH 094/105] 7022228: JPRT failure: RuntimeException in SupportedMedia regression test Reviewed-by: igor, prr --- .../classes/sun/print/Win32PrintService.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/jdk/src/windows/classes/sun/print/Win32PrintService.java b/jdk/src/windows/classes/sun/print/Win32PrintService.java index 6e60888092f..e9f1eb7df82 100644 --- a/jdk/src/windows/classes/sun/print/Win32PrintService.java +++ b/jdk/src/windows/classes/sun/print/Win32PrintService.java @@ -273,6 +273,20 @@ public class Win32PrintService implements PrintService, AttributeUpdater, return DMPAPER_B6_JIS; } } + + // If not found in predefined Windows ID, then we search through + // the returned IDs of the driver because they can define their own + // unique IDs. + initMedia(); + + if ((idList != null) && (mediaSizes != null) && + (idList.size() == mediaSizes.length)) { + for (int i=0; i< idList.size(); i++) { + if (mediaSizes[i].getMediaSizeName() == msn) { + return ((Integer)idList.get(i)).intValue(); + } + } + } return 0; } @@ -439,7 +453,7 @@ public class Win32PrintService implements PrintService, AttributeUpdater, if (mediaName != null) { int defPaper = findPaperID(mediaName); - float[] prnArea = getMediaPrintableArea(printer, defPaper); + float[] prnArea = (defPaper != 0) ? getMediaPrintableArea(printer, defPaper) : null; MediaPrintableArea printableArea = null; if (prnArea != null) { try { From 058b3bbd6d950bcacdac5ccd7022f95375f1b68b Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 24 Feb 2011 15:15:45 -0800 Subject: [PATCH 095/105] Added tag jdk7-b131 for changeset 836de2e4bdee --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index b6d73caeb29..d493b08a8bf 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -105,3 +105,4 @@ bd70f76b0309068f157ae759c36eac8f2c6d098e jdk7-b127 57d702105b23fb90e40beaf00f8f8aeae5e249e7 jdk7-b128 a6b015b59fbc2518762c17ccc35702f03ef7713a jdk7-b129 cc58c11af15411042719e9c82707fdbef60a9e0f jdk7-b130 +5d86d951426aaf340b1ba84ae2d5ab5da65a71e2 jdk7-b131 From 71dddd7634eda217c29be65e4bc906041bc3c6bf Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 24 Feb 2011 15:15:46 -0800 Subject: [PATCH 096/105] Added tag jdk7-b131 for changeset 590b6cc6f974 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 36bf49bbda2..84ba8dffd14 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -105,3 +105,4 @@ d7532bcd3742f1576dd07ff9fbb535c9c9a276e9 jdk7-b126 9baa8f94a11d6c5cab3f9f0e5a20106326d0932e jdk7-b128 66fa0fcc779296c99746b09efce6109944f82f30 jdk7-b129 563a8f8b5be3940e9346cffac4eff9ed02b3c69f jdk7-b130 +9d6dd2cdfcb92612dbd836ecded87770d52b49db jdk7-b131 From 15d041a24021ef69ddc62bebee1c6a5f9b47f244 Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 24 Feb 2011 15:15:50 -0800 Subject: [PATCH 097/105] Added tag jdk7-b131 for changeset e0205cb94879 --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 83b71afb041..68a1b2e5454 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -149,3 +149,4 @@ d535bf4c12355a2897e918da9f8910c0aceec4fb hs20-b07 ae4b185f2ed14af7bab610738c333840598cdcc4 jdk7-b129 ae4b185f2ed14af7bab610738c333840598cdcc4 hs21-b01 e9aa2ca89ad6c53420623d579765f9706ec523d7 jdk7-b130 +0aa3b49089112d5faa77902ad680c582ab53f651 jdk7-b131 From 72cafcadc8f92376f61a0e17c6653b15c5cd4eb7 Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 24 Feb 2011 15:15:56 -0800 Subject: [PATCH 098/105] Added tag jdk7-b131 for changeset df8969303f96 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 9de4729e52b..c83a89558fb 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -105,3 +105,4 @@ c532d6dbc8d18d55b5d693599ee5cd8250e16eb4 jdk7-b127 a42c6132c746c86e9fc27ec80cbd699f6ee5edca jdk7-b128 f5b60c5a310f992c6ca627d17ca3e042f0e0b2c3 jdk7-b129 ab107c1bc4b918404b191838c455e9b2892389f3 jdk7-b130 +eab6f27131e4e2f0af0016b35b18ae65cdd249d9 jdk7-b131 From 9c4f7e6ac0142e7026b59ddd3f3b929ad65d704c Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 24 Feb 2011 15:15:56 -0800 Subject: [PATCH 099/105] Added tag jdk7-b131 for changeset a13a950d71df --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index c0e9eb3a6dc..e3313645422 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -105,3 +105,4 @@ ef19f173578c804772d586a959fa3ab8a12c0598 jdk7-b127 88d74afc55938033e744b537a22714bb2c82c9c0 jdk7-b128 0f7b39ad902424e949e3d2dca8411b884888a76f jdk7-b129 ba1fac1c2083196422a12130db174334179a4d44 jdk7-b130 +438abc0356cd97d91b25f67cd1abc9883e22f6ed jdk7-b131 From 6c237e3450d0054cc05c3f46f90a066e5e7a18ce Mon Sep 17 00:00:00 2001 From: Christine Lu Date: Thu, 24 Feb 2011 15:16:13 -0800 Subject: [PATCH 100/105] Added tag jdk7-b131 for changeset 4de608132976 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index d29cef2af52..32488ca8d8e 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -105,3 +105,4 @@ a3b5b531542a372f30e014b1543a619a15a90780 jdk7-b123 d7225b476a5d1aebffb8827e7c72ba2e1651f4e7 jdk7-b128 1383d1ee8b5db13d5df9523d1760df17b9d228d4 jdk7-b129 7a98db8cbfce77a619057aa4fdde69d2a06d4101 jdk7-b130 +67221b8643b478c4fceacc89240db876455aae76 jdk7-b131 From e6b07111eac6bd51c830c62c7ee88dcb515fd737 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Thu, 24 Feb 2011 21:38:37 -0500 Subject: [PATCH 101/105] 7021953: Remove flags from globals.hpp inadvertently dragged in by 7016023 Removed erroneous flags Reviewed-by: kvn, dcubed --- hotspot/src/share/vm/runtime/globals.hpp | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index 58127e2d294..bcb518661b9 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -2664,25 +2664,6 @@ class CommandLineFlags { product(bool, UseStringCache, false, \ "Enable String cache capabilities on String.java") \ \ - /* byte strings */ \ - product(bool, UseCompressedStrings, false, \ - "Enable byte-valued strings") \ - \ - product(bool, SpecialStringCompress, true, \ - "special version of string compress") \ - \ - product(bool, SpecialStringInflate, true, \ - "special version of string inflate") \ - \ - product(bool, SpecialStringCompareToCC, true, \ - "special version of string compareToCC") \ - \ - product(bool, SpecialStringIndexOfCC, true, \ - "special version of string indexOfCC") \ - \ - product(bool, SpecialStringEqualsCC, true, \ - "special version of string equalsCC") \ - \ /* statistics */ \ develop(bool, CountCompiledCalls, false, \ "counts method invocations") \ From 19f730fedf23ecc7e06be7bfc0c169ab92a46243 Mon Sep 17 00:00:00 2001 From: Erik Trimble Date: Fri, 25 Feb 2011 11:42:03 -0800 Subject: [PATCH 102/105] Added tag hs21-b02 for changeset 70ed6d8368bc --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 68a1b2e5454..7fdd4b33c1a 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -150,3 +150,4 @@ ae4b185f2ed14af7bab610738c333840598cdcc4 jdk7-b129 ae4b185f2ed14af7bab610738c333840598cdcc4 hs21-b01 e9aa2ca89ad6c53420623d579765f9706ec523d7 jdk7-b130 0aa3b49089112d5faa77902ad680c582ab53f651 jdk7-b131 +e9aa2ca89ad6c53420623d579765f9706ec523d7 hs21-b02 From 81c907a4b82c6524a840fa398cfb0a840f0fb9ee Mon Sep 17 00:00:00 2001 From: Erik Trimble Date: Fri, 25 Feb 2011 12:46:49 -0800 Subject: [PATCH 103/105] 7022570: Bump the HS21 build number to 03 Update the HS21 build number to 03 Reviewed-by: jcoomes --- hotspot/make/hotspot_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/make/hotspot_version b/hotspot/make/hotspot_version index dfa5badbaa5..31407e75dde 100644 --- a/hotspot/make/hotspot_version +++ b/hotspot/make/hotspot_version @@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2011 HS_MAJOR_VER=21 HS_MINOR_VER=0 -HS_BUILD_NUMBER=02 +HS_BUILD_NUMBER=03 JDK_MAJOR_VER=1 JDK_MINOR_VER=7 From 2531594fa28e154ad110c52dd7951c08d51f43e8 Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 17:35:48 +0200 Subject: [PATCH 104/105] Added tag jdk7-b131 for changeset d8af56da89bc --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 2c732e8244f..ae6ca3b1732 100644 --- a/.hgtags +++ b/.hgtags @@ -105,3 +105,4 @@ f83cd8bd35c678f94e526990e03dc838d0ec2717 jdk7-b127 7da3f5f30855dec6bf3a86529e87dee883b90c72 jdk7-b128 6823ea7eb8eb6fab405d7edb7a5c2f690887a2fa jdk7-b129 a36beda9b9de91231d92a2c529f21cc218fcf8d5 jdk7-b130 +d8af56da89bc0fc02a6b6ad78f51157a46d665ab jdk7-b131 From d3dc82585cfd945f1612c8db82c625ec631ea44c Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 3 Mar 2011 14:13:10 -0800 Subject: [PATCH 105/105] Added tag jdk7-b132 for changeset 6f39c4c0f737 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 6c91e6ff726..39177739d9e 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -106,3 +106,4 @@ f08682e23279d6cccbdcafda1eb0647ba4900874 jdk7-b128 14cd5d54a8d0b9c368d60ea83a066735b9931015 jdk7-b129 bdc069d3f9101f89ec3f81c2950ee2d68fa846d3 jdk7-b130 8ac52c85f9e91336dc00b52ef90b42eecf3230b3 jdk7-b131 +6bbc7a4734952ae7604578f270e1566639fa8752 jdk7-b132