This commit is contained in:
Jon Masamitsu 2014-06-25 20:41:16 -07:00
commit 0e622bfc55
56 changed files with 992 additions and 469 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -19,27 +19,27 @@
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
import sun.misc.Unsafe;
import java.lang.reflect.Field;
package sun.jvm.hotspot.gc_interface;
@SuppressWarnings("sunapi")
public class Test8001071 {
public static Unsafe unsafe;
//These definitions should be kept in sync with the definitions in the HotSpot
//code.
static {
try {
Field f = Unsafe.class.getDeclaredField("theUnsafe");
f.setAccessible(true);
unsafe = (Unsafe) f.get(null);
} catch ( Exception e ) {
e.printStackTrace();
}
}
public enum G1YCType {
Normal ("Normal"),
InitialMark ("Initial Mark"),
DuringMark ("During Mark"),
Mixed ("Mixed"),
G1YCTypeEndSentinel ("Unknown");
public static void main(String args[]) {
unsafe.getObject(new Test8001071(), Short.MAX_VALUE);
}
private final String value;
G1YCType(String val) {
this.value = val;
}
public String value() {
return value;
}
}

View File

@ -0,0 +1,69 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.gc_interface;
//These definitions should be kept in sync with the definitions in the HotSpot code.
public enum GCCause {
_java_lang_system_gc ("System.gc()"),
_full_gc_alot ("FullGCAlot"),
_scavenge_alot ("ScavengeAlot"),
_allocation_profiler ("Allocation Profiler"),
_jvmti_force_gc ("JvmtiEnv ForceGarbageCollection"),
_gc_locker ("GCLocker Initiated GC"),
_heap_inspection ("Heap Inspection Initiated GC"),
_heap_dump ("Heap Dump Initiated GC"),
_no_gc ("No GC"),
_no_cause_specified ("Unknown GCCause"),
_allocation_failure ("Allocation Failure"),
_tenured_generation_full ("Tenured Generation Full"),
_metadata_GC_threshold ("Metadata GC Threshold"),
_cms_generation_full ("CMS Generation Full"),
_cms_initial_mark ("CMS Initial Mark"),
_cms_final_remark ("CMS Final Remark"),
_cms_concurrent_mark ("CMS Concurrent Mark"),
_old_generation_expanded_on_last_scavenge ("Old Generation Expanded On Last Scavenge"),
_old_generation_too_full_to_scavenge ("Old Generation Too Full To Scavenge"),
_adaptive_size_policy ("Ergonomics"),
_g1_inc_collection_pause ("G1 Evacuation Pause"),
_g1_humongous_allocation ("G1 Humongous Allocation"),
_last_ditch_collection ("Last ditch collection"),
_last_gc_cause ("ILLEGAL VALUE - last gc cause - ILLEGAL VALUE");
private final String value;
GCCause(String val) {
this.value = val;
}
public String value() {
return value;
}
}

View File

@ -0,0 +1,50 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.gc_interface;
//These definitions should be kept in sync with the definitions in the HotSpot code.
public enum GCName {
ParallelOld ("ParallelOld"),
SerialOld ("SerialOld"),
PSMarkSweep ("PSMarkSweep"),
ParallelScavenge ("ParallelScavenge"),
DefNew ("DefNew"),
ParNew ("ParNew"),
G1New ("G1New"),
ConcurrentMarkSweep ("ConcurrentMarkSweep"),
G1Old ("G1Old"),
GCNameEndSentinel ("GCNameEndSentinel");
private final String value;
GCName(String val) {
this.value = val;
}
public String value() {
return value;
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.gc_interface;
//These definitions should be kept in sync with the definitions in the HotSpot code.
public enum GCWhen {
BeforeGC ("Before GC"),
AfterGC ("After GC"),
GCWhenEndSentinel ("GCWhenEndSentinel");
private final String value;
GCWhen(String val) {
this.value = val;
}
public String value() {
return value;
}
}

View File

@ -0,0 +1,45 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.gc_interface;
//These definitions should be kept in sync with the definitions in the HotSpot code.
public enum ReferenceType {
REF_NONE ("None reference"), // Regular class
REF_OTHER ("Other reference"), // Subclass of java/lang/ref/Reference, but not subclass of one of the classes below
REF_SOFT ("Soft reference"), // Subclass of java/lang/ref/SoftReference
REF_WEAK ("Weak reference"), // Subclass of java/lang/ref/WeakReference
REF_FINAL ("Final reference"), // Subclass of java/lang/ref/FinalReference
REF_PHANTOM ("Phantom reference"); // Subclass of java/lang/ref/PhantomReference
private final String value;
ReferenceType(String val) {
this.value = val;
}
public String value() {
return value;
}
}

View File

@ -56,6 +56,12 @@ public class Universe {
private static AddressField narrowKlassBaseField;
private static CIntegerField narrowKlassShiftField;
public enum NARROW_OOP_MODE {
UnscaledNarrowOop,
ZeroBasedNarrowOop,
HeapBasedNarrowOop
}
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
@ -94,7 +100,17 @@ public class Universe {
public Universe() {
}
public static String narrowOopModeToString(NARROW_OOP_MODE mode) {
switch (mode) {
case UnscaledNarrowOop:
return "32-bits Oops";
case ZeroBasedNarrowOop:
return "zero based Compressed Oops";
case HeapBasedNarrowOop:
return "Compressed Oops with base";
}
return "";
}
public CollectedHeap heap() {
try {
return (CollectedHeap) heapConstructor.instantiateWrapperFor(collectedHeapField.getValue());

View File

@ -55,6 +55,7 @@ public class Klass extends Metadata implements ClassConstants {
layoutHelper = new IntField(type.getJIntField("_layout_helper"), 0);
name = type.getAddressField("_name");
accessFlags = new CIntField(type.getCIntegerField("_access_flags"), 0);
traceIDField = type.getField("_trace_id");
subklass = new MetadataField(type.getAddressField("_subklass"), 0);
nextSibling = new MetadataField(type.getAddressField("_next_sibling"), 0);
@ -86,6 +87,7 @@ public class Klass extends Metadata implements ClassConstants {
private static CIntField accessFlags;
private static MetadataField subklass;
private static MetadataField nextSibling;
private static sun.jvm.hotspot.types.Field traceIDField;
private Address getValue(AddressField field) {
return addr.getAddressAt(field.getOffset());
@ -106,6 +108,7 @@ public class Klass extends Metadata implements ClassConstants {
public AccessFlags getAccessFlagsObj(){ return new AccessFlags(getAccessFlags()); }
public Klass getSubklassKlass() { return (Klass) subklass.getValue(this); }
public Klass getNextSiblingKlass() { return (Klass) nextSibling.getValue(this); }
public long traceID() { return traceIDField.getJLong(addr); }
// computed access flags - takes care of inner classes etc.
// This is closer to actual source level than getAccessFlags() etc.

View File

@ -54,6 +54,8 @@ public class OopUtilities implements /* imports */ JVMTIThreadState {
private static OopField threadNameField;
private static OopField threadGroupField;
private static LongField threadEETopField;
//tid field is new since 1.5
private static LongField threadTIDField;
// threadStatus field is new since 1.5
private static IntField threadStatusField;
// parkBlocker field is new since 1.6
@ -220,6 +222,7 @@ public class OopUtilities implements /* imports */ JVMTIThreadState {
threadNameField = (OopField) k.findField("name", "[C");
threadGroupField = (OopField) k.findField("group", "Ljava/lang/ThreadGroup;");
threadEETopField = (LongField) k.findField("eetop", "J");
threadTIDField = (LongField) k.findField("tid", "J");
threadStatusField = (IntField) k.findField("threadStatus", "I");
threadParkBlockerField = (OopField) k.findField("parkBlocker",
"Ljava/lang/Object;");
@ -268,6 +271,15 @@ public class OopUtilities implements /* imports */ JVMTIThreadState {
return VM.getVM().getThreads().createJavaThreadWrapper(addr);
}
public static long threadOopGetTID(Oop threadOop) {
initThreadFields();
if (threadTIDField != null) {
return threadTIDField.getValue(threadOop);
} else {
return 0;
}
}
/** returns value of java.lang.Thread.threadStatus field */
public static int threadOopGetThreadStatus(Oop threadOop) {
initThreadFields();

View File

@ -0,0 +1,67 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.opto;
//These definitions should be kept in sync with the definitions in the HotSpot code.
public enum CompilerPhaseType {
PHASE_BEFORE_STRINGOPTS ("Before StringOpts"),
PHASE_AFTER_STRINGOPTS ("After StringOpts"),
PHASE_BEFORE_REMOVEUSELESS ("Before RemoveUseless"),
PHASE_AFTER_PARSING ("After Parsing"),
PHASE_ITER_GVN1 ("Iter GVN 1"),
PHASE_PHASEIDEAL_BEFORE_EA ("PhaseIdealLoop before EA"),
PHASE_ITER_GVN_AFTER_EA ("Iter GVN after EA"),
PHASE_ITER_GVN_AFTER_ELIMINATION ("Iter GVN after eliminating allocations and locks"),
PHASE_PHASEIDEALLOOP1 ("PhaseIdealLoop 1"),
PHASE_PHASEIDEALLOOP2 ("PhaseIdealLoop 2"),
PHASE_PHASEIDEALLOOP3 ("PhaseIdealLoop 3"),
PHASE_CPP1 ("PhaseCPP 1"),
PHASE_ITER_GVN2 ("Iter GVN 2"),
PHASE_PHASEIDEALLOOP_ITERATIONS ("PhaseIdealLoop iterations"),
PHASE_OPTIMIZE_FINISHED ("Optimize finished"),
PHASE_GLOBAL_CODE_MOTION ("Global code motion"),
PHASE_FINAL_CODE ("Final Code"),
PHASE_AFTER_EA ("After Escape Analysis"),
PHASE_BEFORE_CLOOPS ("Before CountedLoop"),
PHASE_AFTER_CLOOPS ("After CountedLoop"),
PHASE_BEFORE_BEAUTIFY_LOOPS ("Before beautify loops"),
PHASE_AFTER_BEAUTIFY_LOOPS ("After beautify loops"),
PHASE_BEFORE_MATCHING ("Before Matching"),
PHASE_INCREMENTAL_INLINE ("Incremental Inline"),
PHASE_INCREMENTAL_BOXING_INLINE ("Incremental Boxing Inline"),
PHASE_END ("End"),
PHASE_FAILURE ("Failure"),
PHASE_NUM_TYPES ("Number of Phase Types");
private final String value;
CompilerPhaseType(String val) {
this.value = val;
}
public String value() {
return value;
}
}

View File

@ -0,0 +1,48 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.runtime;
//These definitions should be kept in sync with the definitions in the HotSpot code.
public enum Flags {
// value origin
DEFAULT ("Default"),
COMMAND_LINE ("Command line"),
ENVIRON_VAR ("Environment variable"),
CONFIG_FILE ("Config file"),
MANAGEMENT ("Management"),
ERGONOMIC ("Ergonomic"),
ATTACH_ON_DEMAND ("Attach on demand"),
INTERNAL ("Internal");
private final String value;
Flags(String val) {
this.value = val;
}
public String value() {
return value;
}
}

View File

@ -41,6 +41,8 @@ public class Thread extends VMObject {
private static AddressField currentPendingMonitorField;
private static AddressField currentWaitingMonitorField;
private static JLongField allocatedBytesField;
static {
VM.registerVMInitializedObserver(new Observer() {
public void update(Observable o, Object data) {
@ -61,6 +63,7 @@ public class Thread extends VMObject {
activeHandlesField = type.getAddressField("_active_handles");
currentPendingMonitorField = type.getAddressField("_current_pending_monitor");
currentWaitingMonitorField = type.getAddressField("_current_waiting_monitor");
allocatedBytesField = type.getJLongField("_allocated_bytes");
}
public Thread(Address addr) {
@ -104,6 +107,10 @@ public class Thread extends VMObject {
return new JNIHandleBlock(a);
}
public long allocatedBytes() {
return allocatedBytesField.getValue(addr);
}
public boolean isVMThread() { return false; }
public boolean isJavaThread() { return false; }
public boolean isCompilerThread() { return false; }

View File

@ -0,0 +1,86 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
package sun.jvm.hotspot.runtime;
//These definitions should be kept in sync with the definitions in the HotSpot code.
public enum VMOps {
Dummy,
ThreadStop,
ThreadDump,
PrintThreads,
FindDeadlocks,
ForceSafepoint,
ForceAsyncSafepoint,
Deoptimize,
DeoptimizeFrame,
DeoptimizeAll,
ZombieAll,
UnlinkSymbols,
Verify,
PrintJNI,
HeapDumper,
DeoptimizeTheWorld,
CollectForMetadataAllocation,
GC_HeapInspection,
GenCollectFull,
GenCollectFullConcurrent,
GenCollectForAllocation,
ParallelGCFailedAllocation,
ParallelGCSystemGC,
CGC_Operation,
CMS_Initial_Mark,
CMS_Final_Remark,
G1CollectFull,
G1CollectForAllocation,
G1IncCollectionPause,
EnableBiasedLocking,
RevokeBias,
BulkRevokeBias,
PopulateDumpSharedSpace,
JNIFunctionTableCopier,
RedefineClasses,
GetOwnedMonitorInfo,
GetObjectMonitorUsage,
GetCurrentContendedMonitor,
GetStackTrace,
GetMultipleStackTraces,
GetAllStackTraces,
GetThreadListStackTraces,
GetFrameCount,
GetFrameLocation,
ChangeBreakpoints,
GetOrSetLocal,
GetCurrentLocation,
EnterInterpOnlyMode,
ChangeSingleStep,
HeapWalkOperation,
HeapIterateOperation,
ReportJavaOutOfMemory,
JFRCheckpoint,
Exit,
LinuxDllLoad,
Terminating
}

View File

@ -82,14 +82,12 @@ VM_VER_DEFS = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" \
-DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" \
$(JDK_VER_DEFS)
HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
CXXFLAGS = \
${SYSDEFS} \
${INCLUDES} \
${BUILD_TARGET} \
${BUILD_USER} \
${HS_LIB_ARCH} \
${VM_DISTRO}

View File

@ -81,14 +81,12 @@ VM_VER_DEFS = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" \
-DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" \
$(JDK_VER_DEFS)
HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
CXXFLAGS = \
${SYSDEFS} \
${INCLUDES} \
${BUILD_TARGET} \
${BUILD_USER} \
${HS_LIB_ARCH} \
${VM_DISTRO}

View File

@ -135,8 +135,12 @@ endif
ifeq ($(JDK_MKTG_VERSION),)
JDK_MKTG_VERSION=$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
endif
ifeq ($(JDK_VERSION),)
JDK_VERSION=$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
ifeq ($(JDK_VERSION),)
ifeq ($(BUILD_FLAVOR), product)
JDK_VERSION=$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)
else
JDK_VERSION=$(JDK_MAJOR_VERSION).$(JDK_MINOR_VERSION).$(JDK_MICRO_VERSION)-$(BUILD_FLAVOR)
endif
endif
ifeq ($(FULL_VERSION),)
FULL_VERSION="$(JDK_VERSION)"

View File

@ -69,7 +69,7 @@ ifeq ($(ARCH), ia64)
endif
# sparc
ifeq ($(ARCH), sparc64)
ifneq (,$(findstring $(ARCH), sparc))
ifeq ($(ARCH_DATA_MODEL), 64)
ARCH_DATA_MODEL = 64
MAKE_ARGS += LP64=1
@ -83,30 +83,20 @@ ifeq ($(ARCH), sparc64)
HS_ARCH = sparc
endif
# amd64/x86_64
ifneq (,$(findstring $(ARCH), amd64 x86_64))
# i686/i586 and amd64/x86_64
ifneq (,$(findstring $(ARCH), amd64 x86_64 i686 i586))
ifeq ($(ARCH_DATA_MODEL), 64)
ARCH_DATA_MODEL = 64
MAKE_ARGS += LP64=1
PLATFORM = linux-amd64
VM_PLATFORM = linux_amd64
HS_ARCH = x86
else
ARCH_DATA_MODEL = 32
PLATFORM = linux-i586
VM_PLATFORM = linux_i486
HS_ARCH = x86
# We have to reset ARCH to i686 since SRCARCH relies on it
ARCH = i686
endif
endif
# i686/i586 ie 32-bit x86
ifneq (,$(findstring $(ARCH), i686 i586))
ARCH_DATA_MODEL = 32
PLATFORM = linux-i586
VM_PLATFORM = linux_i486
HS_ARCH = x86
HS_ARCH = x86
endif
# ARM
@ -118,20 +108,18 @@ ifeq ($(ARCH), arm)
endif
# PPC
ifeq ($(ARCH), ppc)
ARCH_DATA_MODEL = 32
PLATFORM = linux-ppc
VM_PLATFORM = linux_ppc
HS_ARCH = ppc
endif
ifneq (,$(findstring $(ARCH), ppc))
ifeq ($(ARCH_DATA_MODEL), 64)
MAKE_ARGS += LP64=1
PLATFORM = linux-ppc64
VM_PLATFORM = linux_ppc64
else
ARCH_DATA_MODEL = 32
PLATFORM = linux-ppc
VM_PLATFORM = linux_ppc
endif
# PPC64
ifeq ($(ARCH), ppc64)
ARCH_DATA_MODEL = 64
MAKE_ARGS += LP64=1
PLATFORM = linux-ppc64
VM_PLATFORM = linux_ppc64
HS_ARCH = ppc
HS_ARCH = ppc
endif
# On 32 bit linux we build server and client, on 64 bit just server.

View File

@ -82,14 +82,12 @@ VM_VER_DEFS = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" \
-DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" \
$(JDK_VER_DEFS)
HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
CXXFLAGS = \
${SYSDEFS} \
${INCLUDES} \
${BUILD_TARGET} \
${BUILD_USER} \
${HS_LIB_ARCH} \
${VM_DISTRO}

View File

@ -29,8 +29,12 @@
# and generate JNI header file for native methods.
include $(GAMMADIR)/make/solaris/makefiles/rules.make
include $(GAMMADIR)/make/defs.make
AGENT_DIR = $(GAMMADIR)/agent
include $(GAMMADIR)/make/sa.files
-include $(HS_ALT_MAKE)/solaris/makefiles/sa.make
GENERATED = ../generated
# tools.jar is needed by the JDI - SA binding

View File

@ -77,14 +77,12 @@ VM_VER_DEFS = -DHOTSPOT_RELEASE_VERSION="\"$(HS_BUILD_VER)\"" \
-DJRE_RELEASE_VERSION="\"$(JRE_RELEASE_VER)\"" \
$(JDK_VER_DEFS)
HS_LIB_ARCH = -DHOTSPOT_LIB_ARCH=\"$(LIBARCH)\"
BUILD_TARGET = -DHOTSPOT_BUILD_TARGET="\"$(TARGET)\""
BUILD_USER = -DHOTSPOT_BUILD_USER="\"$(HOTSPOT_BUILD_USER)\""
VM_DISTRO = -DHOTSPOT_VM_DISTRO="\"$(HOTSPOT_VM_DISTRO)\""
CXXFLAGS = \
${SYSDEFS} \
${INCLUDES} \
${BUILD_TARGET} \
${BUILD_USER} \
${HS_LIB_ARCH} \
${VM_DISTRO}

View File

@ -38,6 +38,22 @@ checkAndBuildSA::
GENERATED = ../generated
HS_COMMON_SRC_REL = src
!if "$(OPENJDK)" != "true"
HS_ALT_SRC_REL=src/closed
HS_ALT_SRC = $(WorkSpace)/$(HS_ALT_SRC_REL)
!ifndef HS_ALT_MAKE
HS_ALT_MAKE=$(WorkSpace)/make/closed
!endif
!endif
HS_COMMON_SRC = $(WorkSpace)/$(HS_COMMON_SRC_REL)
!ifdef HS_ALT_MAKE
!include $(HS_ALT_MAKE)/windows/makefiles/sa.make
!endif
# tools.jar is needed by the JDI - SA binding
SA_CLASSPATH = $(BOOT_JAVA_HOME)/lib/tools.jar

View File

@ -116,7 +116,7 @@ JDK_MAJOR_VERSION="\\\"$(JDK_MAJOR_VER)\\\""
JDK_MINOR_VERSION="\\\"$(JDK_MINOR_VER)\\\""
JDK_MICRO_VERSION="\\\"$(JDK_MICRO_VER)\\\""
ReleaseOptions = -define HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) -define JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION) -define HOTSPOT_VM_DISTRO=$(HOTSPOT_VM_DISTRO) -define JDK_MAJOR_VERSION=$(JDK_MAJOR_VERSION) -define JDK_MINOR_VERSION=$(JDK_MINOR_VERSION) -define JDK_MICRO_VERSION=$(JDK_MICRO_VERSION) -define JDK_BUILD_NUMBER=$(JDK_BUILD_NUMBER)
ReleaseOptions = -define HOTSPOT_RELEASE_VERSION=$(HOTSPOT_RELEASE_VERSION) -define JRE_RELEASE_VERSION=$(JRE_RELEASE_VERSION) -define HOTSPOT_VM_DISTRO=$(HOTSPOT_VM_DISTRO) -define JDK_MAJOR_VERSION=$(JDK_MAJOR_VERSION) -define JDK_MINOR_VERSION=$(JDK_MINOR_VERSION) -define JDK_MICRO_VERSION=$(JDK_MICRO_VERSION) -define JDK_BUILD_NUMBER=$(JDK_BUILD_NUMBER) -define VISUAL_STUDIO_BUILD=true
ProjectCreatorIDEOptions = $(ProjectCreatorIDEOptions) $(ReleaseOptions)
$(HOTSPOTBUILDSPACE)/$(ProjectFile): $(HOTSPOTBUILDSPACE)/classes/ProjectCreator.class

View File

@ -436,32 +436,6 @@ void frame::set_interpreter_frame_sender_sp(intptr_t* sender_sp) {
}
#endif // CC_INTERP
#ifdef ASSERT
// Debugging aid
static frame nth_sender(int n) {
frame f = JavaThread::current()->last_frame();
for(int i = 0; i < n; ++i)
f = f.sender((RegisterMap*)NULL);
printf("first frame %d\n", f.is_first_frame() ? 1 : 0);
printf("interpreted frame %d\n", f.is_interpreted_frame() ? 1 : 0);
printf("java frame %d\n", f.is_java_frame() ? 1 : 0);
printf("entry frame %d\n", f.is_entry_frame() ? 1 : 0);
printf("native frame %d\n", f.is_native_frame() ? 1 : 0);
if (f.is_compiled_frame()) {
if (f.is_deoptimized_frame())
printf("deoptimized frame 1\n");
else
printf("compiled frame 1\n");
}
return f;
}
#endif
frame frame::sender_for_entry_frame(RegisterMap *map) const {
assert(map != NULL, "map must be set");
// Java frame called from C; skip all C frames and return top C

View File

@ -2813,13 +2813,6 @@ void os::yield() {
os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
void os::yield_all() {
// Yields to all threads, including threads with lower priorities
// Threads on Linux are all with same priority. The Solaris style
// os::yield_all() with nanosleep(1ms) is not necessary.
sched_yield();
}
////////////////////////////////////////////////////////////////////////////////
// thread priority support
@ -3076,7 +3069,7 @@ static bool do_suspend(OSThread* osthread) {
for (int n = 0; !osthread->sr.is_suspended(); n++) {
for (int i = 0; i < RANDOMLY_LARGE_INTEGER2 && !osthread->sr.is_suspended(); i++) {
os::yield_all();
os::yield();
}
// timeout, try to cancel the request
@ -3110,7 +3103,7 @@ static void do_resume(OSThread* osthread) {
if (sr_notify(osthread) == 0) {
for (int n = 0; n < RANDOMLY_LARGE_INTEGER && !osthread->sr.is_running(); n++) {
for (int i = 0; i < 100 && !osthread->sr.is_running(); i++) {
os::yield_all();
os::yield();
}
}
} else {

View File

@ -2601,13 +2601,6 @@ void os::yield() {
os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
void os::yield_all() {
// Yields to all threads, including threads with lower priorities
// Threads on Bsd are all with same priority. The Solaris style
// os::yield_all() with nanosleep(1ms) is not necessary.
sched_yield();
}
////////////////////////////////////////////////////////////////////////////////
// thread priority support

View File

@ -3796,13 +3796,6 @@ void os::yield() {
os::YieldResult os::NakedYield() { sched_yield(); return os::YIELD_UNKNOWN; }
void os::yield_all() {
// Yields to all threads, including threads with lower priorities
// Threads on Linux are all with same priority. The Solaris style
// os::yield_all() with nanosleep(1ms) is not necessary.
sched_yield();
}
////////////////////////////////////////////////////////////////////////////////
// thread priority support

View File

@ -3187,11 +3187,6 @@ void os::yield() {
os::YieldResult os::NakedYield() { thr_yield(); return os::YIELD_UNKNOWN; }
void os::yield_all() {
// Yields to all threads, including threads with lower priorities
os::sleep(Thread::current(), 1, false);
}
// Interface for setting lwp priorities. If we are using T2 libthread,
// which forces the use of BoundThreads or we manually set UseBoundThreads,
// all of our threads will be assigned to real lwp's. Using the thr_setprio

View File

@ -3527,11 +3527,6 @@ os::YieldResult os::NakedYield() {
void os::yield() { os::NakedYield(); }
void os::yield_all() {
// Yields to all threads, including threads with lower priorities
Sleep(1);
}
// Win32 only gives you access to seven real priorities at a time,
// so we compress Java's ten down to seven. It would be better
// if we dynamically adjusted relative priorities.

View File

@ -512,24 +512,9 @@ ciKlass* ciEnv::get_klass_by_index_impl(constantPoolHandle cpool,
} else {
// Check if it's resolved if it's not a symbol constant pool entry.
klass = KlassHandle(THREAD, ConstantPool::klass_at_if_loaded(cpool, index));
if (klass.is_null()) {
// The klass has not been inserted into the constant pool.
// Try to look it up by name.
{
// We have to lock the cpool to keep the oop from being resolved
// while we are accessing it.
MonitorLockerEx ml(cpool->lock());
constantTag tag = cpool->tag_at(index);
if (tag.is_klass()) {
// The klass has been inserted into the constant pool
// very recently.
klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
} else {
assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
klass_name = cpool->unresolved_klass_at(index);
}
}
if (klass.is_null()) {
klass_name = cpool->klass_name_at(index);
}
}

View File

@ -1,4 +1,4 @@
/* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -686,7 +686,7 @@ class CompileReplay : public StackObj {
switch (cp->tag_at(i).value()) {
case JVM_CONSTANT_UnresolvedClass: {
if (tag == JVM_CONSTANT_Class) {
tty->print_cr("Resolving klass %s at %d", cp->unresolved_klass_at(i)->as_utf8(), i);
tty->print_cr("Resolving klass %s at %d", cp->klass_name_at(i)->as_utf8(), i);
Klass* k = cp->klass_at(i, CHECK);
}
break;

View File

@ -510,7 +510,7 @@ constantPoolHandle ClassFileParser::parse_constant_pool(TRAPS) {
jbyte tag = cp->tag_at(index).value();
switch (tag) {
case JVM_CONSTANT_UnresolvedClass: {
Symbol* class_name = cp->unresolved_klass_at(index);
Symbol* class_name = cp->klass_name_at(index);
// check the name, even if _cp_patches will overwrite it
verify_legal_class_name(class_name, CHECK_(nullHandle));
break;
@ -3161,7 +3161,7 @@ instanceKlassHandle ClassFileParser::parse_super_class(int super_class_index,
if (_need_verify)
is_array = super_klass->oop_is_array();
} else if (_need_verify) {
is_array = (_cp->unresolved_klass_at(super_class_index)->byte_at(0) == JVM_SIGNATURE_ARRAY);
is_array = (_cp->klass_name_at(super_class_index)->byte_at(0) == JVM_SIGNATURE_ARRAY);
}
if (_need_verify) {
guarantee_property(!is_array,
@ -3855,7 +3855,7 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
"Invalid this class index %u in constant pool in class file %s",
this_class_index, CHECK_(nullHandle));
Symbol* class_name = cp->unresolved_klass_at(this_class_index);
Symbol* class_name = cp->klass_name_at(this_class_index);
assert(class_name != NULL, "class_name can't be null");
// It's important to set parsed_name *before* resolving the super class.
@ -4139,8 +4139,8 @@ instanceKlassHandle ClassFileParser::parseClassFile(Symbol* name,
}
// Allocate mirror and initialize static fields
java_lang_Class::create_mirror(this_klass, protection_domain, CHECK_(nullHandle));
java_lang_Class::create_mirror(this_klass, class_loader, protection_domain,
CHECK_(nullHandle));
// Generate any default methods - default methods are interface methods
// that have a default implementation. This is new with Lambda project.

View File

@ -187,8 +187,6 @@ class ClassLoaderData : public CHeapObj<mtClass> {
JNIHandleBlock* handles() const;
void set_handles(JNIHandleBlock* handles);
Mutex* metaspace_lock() const { return _metaspace_lock; }
// GC interface.
void clear_claimed() { _claimed = 0; }
bool claimed() const { return _claimed == 1; }
@ -216,6 +214,8 @@ class ClassLoaderData : public CHeapObj<mtClass> {
return _the_null_class_loader_data;
}
Mutex* metaspace_lock() const { return _metaspace_lock; }
bool is_anonymous() const { return _is_anonymous; }
static void init_null_class_loader_data() {

View File

@ -558,7 +558,7 @@ void java_lang_Class::fixup_mirror(KlassHandle k, TRAPS) {
}
}
}
create_mirror(k, Handle(NULL), CHECK);
create_mirror(k, Handle(NULL), Handle(NULL), CHECK);
}
void java_lang_Class::initialize_mirror_fields(KlassHandle k,
@ -578,7 +578,8 @@ void java_lang_Class::initialize_mirror_fields(KlassHandle k,
InstanceKlass::cast(k())->do_local_static_fields(&initialize_static_field, mirror, CHECK);
}
void java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRAPS) {
void java_lang_Class::create_mirror(KlassHandle k, Handle class_loader,
Handle protection_domain, TRAPS) {
assert(k->java_mirror() == NULL, "should only assign mirror once");
// Use this moment of initialization to cache modifier_flags also,
// to support Class.getModifiers(). Instance classes recalculate
@ -633,6 +634,9 @@ void java_lang_Class::create_mirror(KlassHandle k, Handle protection_domain, TRA
}
}
// set the classLoader field in the java_lang_Class instance
set_class_loader(mirror(), class_loader());
// Setup indirection from klass->mirror last
// after any exceptions can happen during allocations.
if (!k.is_null()) {
@ -694,6 +698,18 @@ void java_lang_Class::set_signers(oop java_class, objArrayOop signers) {
}
void java_lang_Class::set_class_loader(oop java_class, oop loader) {
// jdk7 runs Queens in bootstrapping and jdk8-9 has no coordinated pushes yet.
if (_class_loader_offset != 0) {
java_class->obj_field_put(_class_loader_offset, loader);
}
}
oop java_lang_Class::class_loader(oop java_class) {
assert(_class_loader_offset != 0, "must be set");
return java_class->obj_field(_class_loader_offset);
}
oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS) {
// This should be improved by adding a field at the Java level or by
// introducing a new VM klass (see comment in ClassFileParser)
@ -853,6 +869,12 @@ void java_lang_Class::compute_offsets() {
compute_optional_offset(classRedefinedCount_offset,
klass_oop, vmSymbols::classRedefinedCount_name(), vmSymbols::int_signature());
// Needs to be optional because the old build runs Queens during bootstrapping
// and jdk8-9 doesn't have coordinated pushes yet.
compute_optional_offset(_class_loader_offset,
klass_oop, vmSymbols::classLoader_name(),
vmSymbols::classloader_signature());
CLASS_INJECTED_FIELDS(INJECTED_FIELD_COMPUTE_OFFSET);
}
@ -3073,6 +3095,7 @@ int java_lang_Class::_klass_offset;
int java_lang_Class::_array_klass_offset;
int java_lang_Class::_oop_size_offset;
int java_lang_Class::_static_oop_field_count_offset;
int java_lang_Class::_class_loader_offset;
int java_lang_Class::_protection_domain_offset;
int java_lang_Class::_init_lock_offset;
int java_lang_Class::_signers_offset;

View File

@ -240,19 +240,23 @@ class java_lang_Class : AllStatic {
static int _protection_domain_offset;
static int _init_lock_offset;
static int _signers_offset;
static int _class_loader_offset;
static bool offsets_computed;
static int classRedefinedCount_offset;
static GrowableArray<Klass*>* _fixup_mirror_list;
static void set_init_lock(oop java_class, oop init_lock);
static void set_protection_domain(oop java_class, oop protection_domain);
static void set_class_loader(oop java_class, oop class_loader);
static void initialize_mirror_fields(KlassHandle k, Handle mirror, Handle protection_domain, TRAPS);
public:
static void compute_offsets();
// Instance creation
static void create_mirror(KlassHandle k, Handle protection_domain, TRAPS);
static void create_mirror(KlassHandle k, Handle class_loader,
Handle protection_domain, TRAPS);
static void fixup_mirror(KlassHandle k, TRAPS);
static oop create_basic_type_mirror(const char* basic_type_name, BasicType type, TRAPS);
// Conversion
@ -290,6 +294,8 @@ class java_lang_Class : AllStatic {
static objArrayOop signers(oop java_class);
static void set_signers(oop java_class, objArrayOop signers);
static oop class_loader(oop java_class);
static int oop_size(oop java_class);
static void set_oop_size(oop java_class, int size);
static int static_oop_field_count(oop java_class);

View File

@ -572,6 +572,7 @@
template(serializePropertiesToByteArray_signature, "()[B") \
template(serializeAgentPropertiesToByteArray_name, "serializeAgentPropertiesToByteArray") \
template(classRedefinedCount_name, "classRedefinedCount") \
template(classLoader_name, "classLoader") \
\
/* trace signatures */ \
TRACE_TEMPLATES(template) \

View File

@ -93,7 +93,7 @@ void ArrayKlass::complete_create_array_klass(ArrayKlass* k, KlassHandle super_kl
ResourceMark rm(THREAD);
k->initialize_supers(super_klass(), CHECK);
k->vtable()->initialize_vtable(false, CHECK);
java_lang_Class::create_mirror(k, Handle(NULL), CHECK);
java_lang_Class::create_mirror(k, Handle(NULL), Handle(NULL), CHECK);
}
GrowableArray<Klass*>* ArrayKlass::compute_secondary_supers(int num_extra_slots) {

View File

@ -71,7 +71,6 @@ ConstantPool::ConstantPool(Array<u1>* tags) {
// only set to non-zero if constant pool is merged by RedefineClasses
set_version(0);
set_lock(new Monitor(Monitor::nonleaf + 2, "A constant pool lock"));
// initialize tag array
int length = tags->length();
@ -100,9 +99,6 @@ void ConstantPool::deallocate_contents(ClassLoaderData* loader_data) {
void ConstantPool::release_C_heap_structures() {
// walk constant pool and decrement symbol reference counts
unreference_symbols();
delete _lock;
set_lock(NULL);
}
objArrayOop ConstantPool::resolved_references() const {
@ -146,8 +142,7 @@ void ConstantPool::initialize_resolved_references(ClassLoaderData* loader_data,
// CDS support. Create a new resolved_references array.
void ConstantPool::restore_unshareable_info(TRAPS) {
// Only create the new resolved references array and lock if it hasn't been
// attempted before
// Only create the new resolved references array if it hasn't been attempted before
if (resolved_references() != NULL) return;
// restore the C++ vtable from the shared archive
@ -163,9 +158,6 @@ void ConstantPool::restore_unshareable_info(TRAPS) {
ClassLoaderData* loader_data = pool_holder()->class_loader_data();
set_resolved_references(loader_data->add_handle(refs_handle));
}
// Also need to recreate the mutex. Make sure this matches the constructor
set_lock(new Monitor(Monitor::nonleaf + 2, "A constant pool lock"));
}
}
@ -176,7 +168,6 @@ void ConstantPool::remove_unshareable_info() {
set_resolved_reference_length(
resolved_references() != NULL ? resolved_references()->length() : 0);
set_resolved_references(NULL);
set_lock(NULL);
}
int ConstantPool::cp_to_object_index(int cp_index) {
@ -186,11 +177,41 @@ int ConstantPool::cp_to_object_index(int cp_index) {
return (i < 0) ? _no_index_sentinel : i;
}
Klass* ConstantPool::klass_at_impl(constantPoolHandle this_cp, int which, TRAPS) {
// A resolved constantPool entry will contain a Klass*, otherwise a Symbol*.
// It is not safe to rely on the tag bit's here, since we don't have a lock, and the entry and
// tag is not updated atomicly.
void ConstantPool::trace_class_resolution(constantPoolHandle this_cp, KlassHandle k) {
ResourceMark rm;
int line_number = -1;
const char * source_file = NULL;
if (JavaThread::current()->has_last_Java_frame()) {
// try to identify the method which called this function.
vframeStream vfst(JavaThread::current());
if (!vfst.at_end()) {
line_number = vfst.method()->line_number_from_bci(vfst.bci());
Symbol* s = vfst.method()->method_holder()->source_file_name();
if (s != NULL) {
source_file = s->as_C_string();
}
}
}
if (k() != this_cp->pool_holder()) {
// only print something if the classes are different
if (source_file != NULL) {
tty->print("RESOLVE %s %s %s:%d\n",
this_cp->pool_holder()->external_name(),
InstanceKlass::cast(k())->external_name(), source_file, line_number);
} else {
tty->print("RESOLVE %s %s\n",
this_cp->pool_holder()->external_name(),
InstanceKlass::cast(k())->external_name());
}
}
}
Klass* ConstantPool::klass_at_impl(constantPoolHandle this_cp, int which, TRAPS) {
assert(THREAD->is_Java_thread(), "must be a Java thread");
// A resolved constantPool entry will contain a Klass*, otherwise a Symbol*.
// It is not safe to rely on the tag bit's here, since we don't have a lock, and
// the entry and tag is not updated atomicly.
CPSlot entry = this_cp->slot_at(which);
if (entry.is_resolved()) {
assert(entry.get_klass()->is_klass(), "must be");
@ -198,115 +219,51 @@ Klass* ConstantPool::klass_at_impl(constantPoolHandle this_cp, int which, TRAPS)
return entry.get_klass();
}
// Acquire lock on constant oop while doing update. After we get the lock, we check if another object
// already has updated the object
assert(THREAD->is_Java_thread(), "must be a Java thread");
bool do_resolve = false;
bool in_error = false;
// Create a handle for the mirror. This will preserve the resolved class
// until the loader_data is registered.
Handle mirror_handle;
Symbol* name = NULL;
Handle loader;
{ MonitorLockerEx ml(this_cp->lock());
if (this_cp->tag_at(which).is_unresolved_klass()) {
if (this_cp->tag_at(which).is_unresolved_klass_in_error()) {
in_error = true;
} else {
do_resolve = true;
name = this_cp->unresolved_klass_at(which);
loader = Handle(THREAD, this_cp->pool_holder()->class_loader());
}
}
} // unlocking constantPool
// The original attempt to resolve this constant pool entry failed so find the
// class of the original error and throw another error of the same class (JVMS 5.4.3).
// If there is a detail message, pass that detail message to the error constructor.
// The JVMS does not strictly require us to duplicate the same detail message,
// or any internal exception fields such as cause or stacktrace. But since the
// detail message is often a class name or other literal string, we will repeat it if
// we can find it in the symbol table.
if (in_error) {
// This tag doesn't change back to unresolved class unless at a safepoint.
if (this_cp->tag_at(which).is_unresolved_klass_in_error()) {
// The original attempt to resolve this constant pool entry failed so find the
// class of the original error and throw another error of the same class
// (JVMS 5.4.3).
// If there is a detail message, pass that detail message to the error.
// The JVMS does not strictly require us to duplicate the same detail message,
// or any internal exception fields such as cause or stacktrace. But since the
// detail message is often a class name or other literal string, we will repeat it
// if we can find it in the symbol table.
throw_resolution_error(this_cp, which, CHECK_0);
ShouldNotReachHere();
}
if (do_resolve) {
// this_cp must be unlocked during resolve_or_fail
oop protection_domain = this_cp->pool_holder()->protection_domain();
Handle h_prot (THREAD, protection_domain);
Klass* kk = SystemDictionary::resolve_or_fail(name, loader, h_prot, true, THREAD);
KlassHandle k;
if (!HAS_PENDING_EXCEPTION) {
k = KlassHandle(THREAD, kk);
// preserve the resolved klass.
mirror_handle = Handle(THREAD, kk->java_mirror());
// Do access check for klasses
verify_constant_pool_resolve(this_cp, k, THREAD);
}
Handle mirror_handle;
Symbol* name = entry.get_symbol();
Handle loader (THREAD, this_cp->pool_holder()->class_loader());
Handle protection_domain (THREAD, this_cp->pool_holder()->protection_domain());
Klass* kk = SystemDictionary::resolve_or_fail(name, loader, protection_domain, true, THREAD);
KlassHandle k (THREAD, kk);
if (!HAS_PENDING_EXCEPTION) {
// preserve the resolved klass from unloading
mirror_handle = Handle(THREAD, kk->java_mirror());
// Do access check for klasses
verify_constant_pool_resolve(this_cp, k, THREAD);
}
// Failed to resolve class. We must record the errors so that subsequent attempts
// to resolve this constant pool entry fail with the same error (JVMS 5.4.3).
if (HAS_PENDING_EXCEPTION) {
MonitorLockerEx ml(this_cp->lock());
// Failed to resolve class. We must record the errors so that subsequent attempts
// to resolve this constant pool entry fail with the same error (JVMS 5.4.3).
if (HAS_PENDING_EXCEPTION) {
save_and_throw_exception(this_cp, which, constantTag(JVM_CONSTANT_UnresolvedClass), CHECK_0);
}
// some other thread has beaten us and has resolved the class.
if (this_cp->tag_at(which).is_klass()) {
CLEAR_PENDING_EXCEPTION;
entry = this_cp->resolved_klass_at(which);
return entry.get_klass();
}
// Make this class loader depend upon the class loader owning the class reference
ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data();
this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM
// The tag could have changed to in-error before the lock but we have to
// handle that here for the class case.
save_and_throw_exception(this_cp, which, constantTag(JVM_CONSTANT_UnresolvedClass), CHECK_0);
}
if (TraceClassResolution && !k()->oop_is_array()) {
// skip resolving the constant pool so that this code get's
// called the next time some bytecodes refer to this class.
ResourceMark rm;
int line_number = -1;
const char * source_file = NULL;
if (JavaThread::current()->has_last_Java_frame()) {
// try to identify the method which called this function.
vframeStream vfst(JavaThread::current());
if (!vfst.at_end()) {
line_number = vfst.method()->line_number_from_bci(vfst.bci());
Symbol* s = vfst.method()->method_holder()->source_file_name();
if (s != NULL) {
source_file = s->as_C_string();
}
}
}
if (k() != this_cp->pool_holder()) {
// only print something if the classes are different
if (source_file != NULL) {
tty->print("RESOLVE %s %s %s:%d\n",
this_cp->pool_holder()->external_name(),
InstanceKlass::cast(k())->external_name(), source_file, line_number);
} else {
tty->print("RESOLVE %s %s\n",
this_cp->pool_holder()->external_name(),
InstanceKlass::cast(k())->external_name());
}
}
if (TraceClassResolution && !k->oop_is_array()) {
// skip resolving the constant pool so that this code gets
// called the next time some bytecodes refer to this class.
trace_class_resolution(this_cp, k);
return k();
} else {
MonitorLockerEx ml(this_cp->lock());
// Only updated constant pool - if it is resolved.
do_resolve = this_cp->tag_at(which).is_unresolved_klass();
if (do_resolve) {
ClassLoaderData* this_key = this_cp->pool_holder()->class_loader_data();
this_key->record_dependency(k(), CHECK_NULL); // Can throw OOM
this_cp->klass_at_put(which, k());
}
}
}
entry = this_cp->resolved_klass_at(which);
assert(entry.is_resolved() && entry.get_klass()->is_klass(), "must be resolved at this point");
@ -576,7 +533,7 @@ Symbol* ConstantPool::exception_message(constantPoolHandle this_cp, int which, c
switch (tag.value()) {
case JVM_CONSTANT_UnresolvedClass:
// return the class name in the error message
message = this_cp->unresolved_klass_at(which);
message = this_cp->klass_name_at(which);
break;
case JVM_CONSTANT_MethodHandle:
// return the method handle name in the error message
@ -606,7 +563,6 @@ void ConstantPool::throw_resolution_error(constantPoolHandle this_cp, int which,
// in the resolution error table, so that the same exception is thrown again.
void ConstantPool::save_and_throw_exception(constantPoolHandle this_cp, int which,
constantTag tag, TRAPS) {
assert(this_cp->lock()->is_locked(), "constant pool lock should be held");
Symbol* error = PENDING_EXCEPTION->klass()->name();
int error_tag = tag.error_value();
@ -620,7 +576,14 @@ void ConstantPool::save_and_throw_exception(constantPoolHandle this_cp, int whic
} else if (this_cp->tag_at(which).value() != error_tag) {
Symbol* message = exception_message(this_cp, which, tag, PENDING_EXCEPTION);
SystemDictionary::add_resolution_error(this_cp, which, error, message);
this_cp->tag_at_put(which, error_tag);
// CAS in the tag. If a thread beat us to registering this error that's fine.
// If another thread resolved the reference, this is an error. The resolution
// must deterministically get an error. So why do we save this?
// We save this because jvmti can add classes to the bootclass path after this
// error, so it needs to get the same error if the error is first.
jbyte old_tag = Atomic::cmpxchg((jbyte)error_tag,
(jbyte*)this_cp->tag_addr_at(which), (jbyte)tag.value());
assert(old_tag == error_tag || old_tag == tag.value(), "should not be resolved otherwise");
} else {
// some other thread put this in error state
throw_resolution_error(this_cp, which, CHECK);
@ -710,7 +673,6 @@ oop ConstantPool::resolve_constant_at_impl(constantPoolHandle this_cp, int index
THREAD);
result_oop = value();
if (HAS_PENDING_EXCEPTION) {
MonitorLockerEx ml(this_cp->lock()); // lock cpool to change tag.
save_and_throw_exception(this_cp, index, tag, CHECK_NULL);
}
break;
@ -727,7 +689,6 @@ oop ConstantPool::resolve_constant_at_impl(constantPoolHandle this_cp, int index
Handle value = SystemDictionary::find_method_handle_type(signature, klass, THREAD);
result_oop = value();
if (HAS_PENDING_EXCEPTION) {
MonitorLockerEx ml(this_cp->lock()); // lock cpool to change tag.
save_and_throw_exception(this_cp, index, tag, CHECK_NULL);
}
break;
@ -765,22 +726,17 @@ oop ConstantPool::resolve_constant_at_impl(constantPoolHandle this_cp, int index
}
if (cache_index >= 0) {
// Cache the oop here also.
Handle result_handle(THREAD, result_oop);
MonitorLockerEx ml(this_cp->lock()); // don't know if we really need this
oop result = this_cp->resolved_references()->obj_at(cache_index);
// Benign race condition: resolved_references may already be filled in while we were trying to lock.
// Benign race condition: resolved_references may already be filled in.
// The important thing here is that all threads pick up the same result.
// It doesn't matter which racing thread wins, as long as only one
// result is used by all threads, and all future queries.
// That result may be either a resolved constant or a failure exception.
if (result == NULL) {
this_cp->resolved_references()->obj_at_put(cache_index, result_handle());
return result_handle();
oop old_result = this_cp->resolved_references()->atomic_compare_exchange_oop(cache_index, result_oop, NULL);
if (old_result == NULL) {
return result_oop; // was installed
} else {
// Return the winning thread's result. This can be different than
// result_handle() for MethodHandles.
return result;
// the result here for MethodHandles.
return old_result;
}
} else {
return result_oop;
@ -853,9 +809,8 @@ bool ConstantPool::klass_name_at_matches(instanceKlassHandle k,
}
// Iterate over symbols and decrement ones which are Symbol*s.
// This is done during GC so do not need to lock constantPool unless we
// have per-thread safepoints.
// Iterate over symbols and decrement ones which are Symbol*s
// This is done during GC.
// Only decrement the UTF8 symbols. Unresolved classes and strings point to
// these symbols but didn't increment the reference count.
void ConstantPool::unreference_symbols() {
@ -987,8 +942,8 @@ bool ConstantPool::compare_entry_to(int index1, constantPoolHandle cp2,
case JVM_CONSTANT_UnresolvedClass:
{
Symbol* k1 = unresolved_klass_at(index1);
Symbol* k2 = cp2->unresolved_klass_at(index2);
Symbol* k1 = klass_name_at(index1);
Symbol* k2 = cp2->klass_name_at(index2);
if (k1 == k2) {
return true;
}
@ -1970,7 +1925,6 @@ void ConstantPool::print_entry_on(const int index, outputStream* st) {
break;
case JVM_CONSTANT_UnresolvedClass : // fall-through
case JVM_CONSTANT_UnresolvedClassInError: {
// unresolved_klass_at requires lock or safe world.
CPSlot entry = slot_at(index);
if (entry.is_resolved()) {
entry.get_klass()->print_value_on(st);

View File

@ -112,12 +112,12 @@ class ConstantPool : public Metadata {
int _version;
} _saved;
Monitor* _lock;
void set_tags(Array<u1>* tags) { _tags = tags; }
void tag_at_put(int which, jbyte t) { tags()->at_put(which, t); }
void release_tag_at_put(int which, jbyte t) { tags()->release_at_put(which, t); }
u1* tag_addr_at(int which) const { return tags()->adr_at(which); }
void set_operands(Array<u2>* operands) { _operands = operands; }
int flags() const { return _flags; }
@ -362,14 +362,6 @@ class ConstantPool : public Metadata {
return CPSlot((Klass*)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_klass();
}
// This method should only be used with a cpool lock or during parsing or gc
Symbol* unresolved_klass_at(int which) { // Temporary until actual use
Symbol* s = CPSlot((Symbol*)OrderAccess::load_ptr_acquire(obj_at_addr_raw(which))).get_symbol();
// check that the klass is still unresolved.
assert(tag_at(which).is_unresolved_klass(), "Corrupted constant pool");
return s;
}
// RedefineClasses() API support:
Symbol* klass_at_noresolve(int which) { return klass_name_at(which); }
@ -818,6 +810,8 @@ class ConstantPool : public Metadata {
static Klass* klass_at_impl(constantPoolHandle this_cp, int which, TRAPS);
static oop string_at_impl(constantPoolHandle this_cp, int which, int obj_index, TRAPS);
static void trace_class_resolution(constantPoolHandle this_cp, KlassHandle k);
// Resolve string constants (to prevent allocation during compilation)
static void resolve_string_constants_impl(constantPoolHandle this_cp, TRAPS);
@ -848,8 +842,6 @@ class ConstantPool : public Metadata {
void set_resolved_reference_length(int length) { _saved._resolved_reference_length = length; }
int resolved_reference_length() const { return _saved._resolved_reference_length; }
void set_lock(Monitor* lock) { _lock = lock; }
Monitor* lock() { return _lock; }
// Decrease ref counts of symbols that are in the constant pool
// when the holder class is unloaded

View File

@ -287,7 +287,9 @@ void ConstantPoolCacheEntry::set_method_handle_common(constantPoolHandle cpool,
// the lock, so that when the losing writer returns, he can use the linked
// cache entry.
MonitorLockerEx ml(cpool->lock());
// Use the lock from the metaspace for this, which cannot stop for safepoint.
Mutex* metaspace_lock = cpool->pool_holder()->class_loader_data()->metaspace_lock();
MutexLockerEx ml(metaspace_lock, Mutex::_no_safepoint_check_flag);
if (!is_f1_null()) {
return;
}

View File

@ -508,7 +508,7 @@ void Klass::restore_unshareable_info(TRAPS) {
// Only recreate it if not present. A previous attempt to restore may have
// gotten an OOM later but keep the mirror if it was created.
if (java_mirror() == NULL) {
java_lang_Class::create_mirror(this, Handle(NULL), CHECK);
java_lang_Class::create_mirror(this, Handle(NULL), Handle(NULL), CHECK);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -27,6 +27,22 @@
#include "oops/objArrayOop.hpp"
#include "oops/oop.inline.hpp"
oop objArrayOopDesc::atomic_compare_exchange_oop(int index, oop exchange_value,
oop compare_value) {
volatile HeapWord* dest;
if (UseCompressedOops) {
dest = (HeapWord*)obj_at_addr<narrowOop>(index);
} else {
dest = (HeapWord*)obj_at_addr<oop>(index);
}
oop res = oopDesc::atomic_compare_exchange_oop(exchange_value, dest, compare_value, true);
// update card mark if success
if (res == compare_value) {
update_barrier_set((void*)dest, exchange_value);
}
return res;
}
#define ObjArrayOop_OOP_ITERATE_DEFN(OopClosureType, nv_suffix) \
\
int objArrayOopDesc::oop_iterate_range(OopClosureType* blk, int start, int end) { \

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -95,6 +95,9 @@ private:
oop_store(obj_at_addr<oop>(index), value);
}
}
oop atomic_compare_exchange_oop(int index, oop exchange_value, oop compare_value);
// Sizing
static int header_size() { return arrayOopDesc::header_size(T_OBJECT); }
int object_size() { return object_size(length()); }

View File

@ -3337,13 +3337,7 @@ static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) {
directBufferSupportInitializeEnded = 1;
} else {
while (!directBufferSupportInitializeEnded && !directBufferSupportInitializeFailed) {
// Set state as yield_all can call os:sleep. On Solaris, yield_all calls
// os::sleep which requires the VM state transition. On other platforms, it
// is not necessary. The following call to change the VM state is purposely
// put inside the loop to avoid potential deadlock when multiple threads
// try to call this method. See 6791815 for more details.
ThreadInVMfromNative tivn(thread);
os::yield_all();
os::yield();
}
}

View File

@ -258,9 +258,6 @@ JvmtiEnv::RetransformClasses(jint class_count, const jclass* classes) {
// VM representation. We don't attach the reconstituted class
// bytes to the InstanceKlass here because they have not been
// validated and we're not at a safepoint.
constantPoolHandle constants(current_thread, ikh->constants());
MonitorLockerEx ml(constants->lock()); // lock constant pool while we query it
JvmtiClassFileReconstituter reconstituter(ikh);
if (reconstituter.get_error() != JVMTI_ERROR_NONE) {
return reconstituter.get_error();
@ -2445,9 +2442,6 @@ JvmtiEnv::GetConstantPool(oop k_mirror, jint* constant_pool_count_ptr, jint* con
}
instanceKlassHandle ikh(thread, k_oop);
constantPoolHandle constants(thread, ikh->constants());
MonitorLockerEx ml(constants->lock()); // lock constant pool while we query it
JvmtiConstantPoolReconstituter reconstituter(ikh);
if (reconstituter.get_error() != JVMTI_ERROR_NONE) {
return reconstituter.get_error();
@ -2467,6 +2461,7 @@ JvmtiEnv::GetConstantPool(oop k_mirror, jint* constant_pool_count_ptr, jint* con
return reconstituter.get_error();
}
constantPoolHandle constants(thread, ikh->constants());
*constant_pool_count_ptr = constants->length();
*constant_pool_byte_count_ptr = cpool_size;
*constant_pool_bytes_ptr = cpool_bytes;

View File

@ -892,6 +892,14 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass(JNIEnv *env, jobject unsafe, jstring nam
}
UNSAFE_END
static jobject get_class_loader(JNIEnv* env, jclass cls) {
if (java_lang_Class::is_primitive(JNIHandles::resolve_non_null(cls))) {
return NULL;
}
Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(cls));
oop loader = k->class_loader();
return JNIHandles::make_local(env, loader);
}
UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring name, jbyteArray data, int offset, int length))
UnsafeWrapper("Unsafe_DefineClass");
@ -900,7 +908,7 @@ UNSAFE_ENTRY(jclass, Unsafe_DefineClass0(JNIEnv *env, jobject unsafe, jstring na
int depthFromDefineClass0 = 1;
jclass caller = JVM_GetCallerClass(env, depthFromDefineClass0);
jobject loader = (caller == NULL) ? NULL : JVM_GetClassLoader(env, caller);
jobject loader = (caller == NULL) ? NULL : get_class_loader(env, caller);
jobject pd = (caller == NULL) ? NULL : JVM_GetProtectionDomain(env, caller);
return Unsafe_DefineClass_impl(env, name, data, offset, length, loader, pd);

View File

@ -452,8 +452,6 @@ class os: AllStatic {
// yield that can be used in lieu of blocking.
} ;
static YieldResult NakedYield () ;
static void yield_all(); // Yields to all other threads including lower priority
// (for the default scheduling policy)
static OSReturn set_priority(Thread* thread, ThreadPriority priority);
static OSReturn get_priority(const Thread* const thread, ThreadPriority& priority);

View File

@ -266,8 +266,8 @@ void SafepointSynchronize::begin() {
//
// Further complicating matters is that yield() does not work as naively expected
// on many platforms -- yield() does not guarantee that any other ready threads
// will run. As such we revert yield_all() after some number of iterations.
// Yield_all() is implemented as a short unconditional sleep on some platforms.
// will run. As such we revert to naked_short_sleep() after some number of iterations.
// nakes_short_sleep() is implemented as a short unconditional sleep.
// Typical operating systems round a "short" sleep period up to 10 msecs, so sleeping
// can actually increase the time it takes the VM thread to detect that a system-wide
// stop-the-world safepoint has been reached. In a pathological scenario such as that
@ -324,9 +324,7 @@ void SafepointSynchronize::begin() {
if (steps < DeferThrSuspendLoopCount) {
os::NakedYield() ;
} else {
os::yield_all() ;
// Alternately, the VM thread could transiently depress its scheduling priority or
// transiently increase the priority of the tardy mutator(s).
os::naked_short_sleep(1);
}
iterations ++ ;
@ -746,80 +744,12 @@ void SafepointSynchronize::block(JavaThread *thread) {
// ------------------------------------------------------------------------------------------------------
// Exception handlers
#ifndef PRODUCT
#ifdef SPARC
#ifdef _LP64
#define PTR_PAD ""
#else
#define PTR_PAD " "
#endif
static void print_ptrs(intptr_t oldptr, intptr_t newptr, bool wasoop) {
bool is_oop = newptr ? (cast_to_oop(newptr))->is_oop() : false;
tty->print_cr(PTR_FORMAT PTR_PAD " %s %c " PTR_FORMAT PTR_PAD " %s %s",
oldptr, wasoop?"oop":" ", oldptr == newptr ? ' ' : '!',
newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" "));
}
static void print_longs(jlong oldptr, jlong newptr, bool wasoop) {
bool is_oop = newptr ? (cast_to_oop(newptr))->is_oop() : false;
tty->print_cr(PTR64_FORMAT " %s %c " PTR64_FORMAT " %s %s",
oldptr, wasoop?"oop":" ", oldptr == newptr ? ' ' : '!',
newptr, is_oop?"oop":" ", (wasoop && !is_oop) ? "STALE" : ((wasoop==false&&is_oop==false&&oldptr !=newptr)?"STOMP":" "));
}
static void print_me(intptr_t *new_sp, intptr_t *old_sp, bool *was_oops) {
#ifdef _LP64
tty->print_cr("--------+------address-----+------before-----------+-------after----------+");
const int incr = 1; // Increment to skip a long, in units of intptr_t
#else
tty->print_cr("--------+--address-+------before-----------+-------after----------+");
const int incr = 2; // Increment to skip a long, in units of intptr_t
#endif
tty->print_cr("---SP---|");
for( int i=0; i<16; i++ ) {
tty->print("blob %c%d |"PTR_FORMAT" ","LO"[i>>3],i&7,new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); }
tty->print_cr("--------|");
for( int i1=0; i1<frame::memory_parameter_word_sp_offset-16; i1++ ) {
tty->print("argv pad|"PTR_FORMAT" ",new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); }
tty->print(" pad|"PTR_FORMAT" ",new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++);
tty->print_cr("--------|");
tty->print(" G1 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
tty->print(" G3 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
tty->print(" G4 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
tty->print(" G5 |"PTR_FORMAT" ",new_sp); print_longs(*(jlong*)old_sp,*(jlong*)new_sp,was_oops[incr-1]); old_sp += incr; new_sp += incr; was_oops += incr;
tty->print_cr(" FSR |"PTR_FORMAT" "PTR64_FORMAT" "PTR64_FORMAT,new_sp,*(jlong*)old_sp,*(jlong*)new_sp);
old_sp += incr; new_sp += incr; was_oops += incr;
// Skip the floats
tty->print_cr("--Float-|"PTR_FORMAT,new_sp);
tty->print_cr("---FP---|");
old_sp += incr*32; new_sp += incr*32; was_oops += incr*32;
for( int i2=0; i2<16; i2++ ) {
tty->print("call %c%d |"PTR_FORMAT" ","LI"[i2>>3],i2&7,new_sp); print_ptrs(*old_sp++,*new_sp++,*was_oops++); }
tty->cr();
}
#endif // SPARC
#endif // PRODUCT
void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) {
assert(thread->is_Java_thread(), "polling reference encountered by VM thread");
assert(thread->thread_state() == _thread_in_Java, "should come from Java code");
assert(SafepointSynchronize::is_synchronizing(), "polling encountered outside safepoint synchronization");
// Uncomment this to get some serious before/after printing of the
// Sparc safepoint-blob frame structure.
/*
intptr_t* sp = thread->last_Java_sp();
intptr_t stack_copy[150];
for( int i=0; i<150; i++ ) stack_copy[i] = sp[i];
bool was_oops[150];
for( int i=0; i<150; i++ )
was_oops[i] = stack_copy[i] ? ((oop)stack_copy[i])->is_oop() : false;
*/
if (ShowSafepointMsgs) {
tty->print("handle_polling_page_exception: ");
}
@ -831,7 +761,6 @@ void SafepointSynchronize::handle_polling_page_exception(JavaThread *thread) {
ThreadSafepointState* state = thread->safepoint_state();
state->handle_polling_page_exception();
// print_me(sp,stack_copy,was_oops);
}

View File

@ -104,6 +104,7 @@
#include "utilities/globalDefinitions.hpp"
#include "utilities/hashtable.hpp"
#include "utilities/macros.hpp"
#ifdef TARGET_ARCH_x86
# include "vmStructs_x86.hpp"
#endif
@ -168,6 +169,11 @@
#include "gc_implementation/parallelScavenge/vmStructs_parallelgc.hpp"
#include "gc_implementation/g1/vmStructs_g1.hpp"
#endif // INCLUDE_ALL_GCS
#if INCLUDE_TRACE
#include "runtime/vmStructs_trace.hpp"
#endif
#ifdef COMPILER2
#include "opto/addnode.hpp"
#include "opto/block.hpp"
@ -1390,6 +1396,8 @@ typedef TwoOopHashtable<Symbol*, mtClass> SymbolTwoOopHashtable;
/* unsigned short on Win32 */ \
declare_unsigned_integer_type(u1) \
declare_unsigned_integer_type(u2) \
declare_unsigned_integer_type(u4) \
declare_unsigned_integer_type(u8) \
declare_unsigned_integer_type(unsigned) \
\
/*****************************/ \
@ -2923,6 +2931,11 @@ VMStructEntry VMStructs::localHotSpotVMStructs[] = {
GENERATE_STATIC_VM_STRUCT_ENTRY)
#endif // INCLUDE_ALL_GCS
#if INCLUDE_TRACE
VM_STRUCTS_TRACE(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_STATIC_VM_STRUCT_ENTRY)
#endif
VM_STRUCTS_CPU(GENERATE_NONSTATIC_VM_STRUCT_ENTRY,
GENERATE_STATIC_VM_STRUCT_ENTRY,
GENERATE_UNCHECKED_NONSTATIC_VM_STRUCT_ENTRY,
@ -2968,6 +2981,11 @@ VMTypeEntry VMStructs::localHotSpotVMTypes[] = {
GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
#endif // INCLUDE_ALL_GCS
#if INCLUDE_TRACE
VM_TYPES_TRACE(GENERATE_VM_TYPE_ENTRY,
GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
#endif
VM_TYPES_CPU(GENERATE_VM_TYPE_ENTRY,
GENERATE_TOPLEVEL_VM_TYPE_ENTRY,
GENERATE_OOP_VM_TYPE_ENTRY,
@ -3003,6 +3021,10 @@ VMIntConstantEntry VMStructs::localHotSpotVMIntConstants[] = {
VM_INT_CONSTANTS_PARNEW(GENERATE_VM_INT_CONSTANT_ENTRY)
#endif // INCLUDE_ALL_GCS
#if INCLUDE_TRACE
VM_INT_CONSTANTS_TRACE(GENERATE_VM_INT_CONSTANT_ENTRY)
#endif
VM_INT_CONSTANTS_CPU(GENERATE_VM_INT_CONSTANT_ENTRY,
GENERATE_PREPROCESSOR_VM_INT_CONSTANT_ENTRY,
GENERATE_C1_VM_INT_CONSTANT_ENTRY,
@ -3065,8 +3087,14 @@ VMStructs::init() {
VM_STRUCTS_G1(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
CHECK_STATIC_VM_STRUCT_ENTRY);
#endif // INCLUDE_ALL_GCS
#if INCLUDE_TRACE
VM_STRUCTS_TRACE(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
CHECK_STATIC_VM_STRUCT_ENTRY);
#endif
VM_STRUCTS_CPU(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
CHECK_STATIC_VM_STRUCT_ENTRY,
CHECK_NO_OP,
@ -3105,8 +3133,14 @@ VMStructs::init() {
VM_TYPES_G1(CHECK_VM_TYPE_ENTRY,
CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
#endif // INCLUDE_ALL_GCS
#if INCLUDE_TRACE
VM_TYPES_TRACE(CHECK_VM_TYPE_ENTRY,
CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
#endif
VM_TYPES_CPU(CHECK_VM_TYPE_ENTRY,
CHECK_SINGLE_ARG_VM_TYPE_NO_OP,
CHECK_SINGLE_ARG_VM_TYPE_NO_OP,
@ -3169,6 +3203,12 @@ VMStructs::init() {
debug_only(VM_STRUCTS_G1(ENSURE_FIELD_TYPE_PRESENT,
ENSURE_FIELD_TYPE_PRESENT));
#endif // INCLUDE_ALL_GCS
#if INCLUDE_TRACE
debug_only(VM_STRUCTS_TRACE(ENSURE_FIELD_TYPE_PRESENT,
ENSURE_FIELD_TYPE_PRESENT));
#endif
debug_only(VM_STRUCTS_CPU(ENSURE_FIELD_TYPE_PRESENT,
ENSURE_FIELD_TYPE_PRESENT,
CHECK_NO_OP,

View File

@ -0,0 +1,35 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_VM_RUNTIME_VMSTRUCTS_TRACE_HPP
#define SHARE_VM_RUNTIME_VMSTRUCTS_TRACE_HPP
#define VM_INT_CONSTANTS_TRACE(a)
#define VM_STRUCTS_TRACE(a, b)
#define VM_TYPES_TRACE(a, b)
#endif // SHARE_VM_RUNTIME_VMSTRUCTS_TRACE_HPP

View File

@ -72,14 +72,16 @@ int Abstract_VM_Version::_reserve_for_allocation_prefetch = 0;
#ifndef JRE_RELEASE_VERSION
#error JRE_RELEASE_VERSION must be defined
#endif
#ifndef HOTSPOT_BUILD_TARGET
#error HOTSPOT_BUILD_TARGET must be defined
#endif
#ifdef PRODUCT
#define VM_RELEASE HOTSPOT_RELEASE_VERSION
#else
// NOTE: Builds within Visual Studio do not define the build target in
// HOTSPOT_RELEASE_VERSION, so it must be done here
#if defined(VISUAL_STUDIO_BUILD) && !defined(PRODUCT)
#ifndef HOTSPOT_BUILD_TARGET
#error HOTSPOT_BUILD_TARGET must be defined
#endif
#define VM_RELEASE HOTSPOT_RELEASE_VERSION "-" HOTSPOT_BUILD_TARGET
#else
#define VM_RELEASE HOTSPOT_RELEASE_VERSION
#endif
// HOTSPOT_RELEASE_VERSION follows the JDK release version naming convention

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -481,17 +481,9 @@ class MemTracker : AllStatic {
if (_slowdown_calling_thread && thr != _worker_thread) {
#ifdef _WINDOWS
// On Windows, os::NakedYield() does not work as well
// as os::yield_all()
os::yield_all();
// as short sleep.
os::naked_short_sleep(1);
#else
// On Solaris, os::yield_all() depends on os::sleep()
// which requires JavaTherad in _thread_in_vm state.
// Transits thread to _thread_in_vm state can be dangerous
// if caller holds lock, as it may deadlock with Threads_lock.
// So use NaKedYield instead.
//
// Linux and BSD, NakedYield() and yield_all() implementations
// are the same.
os::NakedYield();
#endif
}

View File

@ -1,63 +0,0 @@
#!/bin/sh
# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please 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 8001071
## @summary Add simple range check into VM implemenation of Unsafe access methods
## @compile Test8001071.java
## @run shell Test8001071.sh
## @author filipp.zhinkin@oracle.com
VERSION=`${TESTJAVA}/bin/java ${TESTVMOPTS} -version 2>&1`
if [ -n "`echo $VERSION | grep debug`" -o -n "`echo $VERSION | grep jvmg`" ]; then
echo "Build type check passed"
echo "Continue testing"
else
echo "Fastdebug build is required for this test"
exit 0
fi
${TESTJAVA}/bin/java -cp ${TESTCLASSES} ${TESTVMOPTS} Test8001071 2>&1
HS_ERR_FILE=hs_err_pid*.log
if [ ! -f $HS_ERR_FILE ]
then
echo "hs_err_pid log file was not found"
echo "Test failed"
exit 1
fi
grep "assert(byte_offset < p_size) failed: Unsafe access: offset.*> object's size.*" $HS_ERR_FILE
if [ "0" = "$?" ];
then
echo "Range check assertion failed as expected"
echo "Test passed"
exit 0
else
echo "Range check assertion was not failed"
echo "Test failed"
exit 1
fi

View File

@ -44,8 +44,16 @@ public class XShareAuto {
"-server", "-XX:+UnlockDiagnosticVMOptions",
"-XX:SharedArchiveFile=./sample.jsa", "-version");
output = new OutputAnalyzer(pb.start());
output.shouldNotContain("sharing");
output.shouldHaveExitValue(0);
// We asked for server but it could be aliased to something else
if (output.getOutput().contains("Server VM")) {
// In server case we don't expect to see sharing flag
output.shouldNotContain("sharing");
output.shouldHaveExitValue(0);
}
else {
System.out.println("Skipping test - no Server VM available");
return;
}
pb = ProcessTools.createJavaProcessBuilder(
"-server", "-Xshare:auto", "-XX:+UnlockDiagnosticVMOptions",

View File

@ -0,0 +1,58 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 8001071
* @summary Add simple range check into VM implemenation of Unsafe access methods
* @library /testlibrary
*/
import com.oracle.java.testlibrary.*;
import sun.misc.Unsafe;
public class RangeCheck {
public static void main(String args[]) throws Exception {
if (!Platform.isDebugBuild()) {
System.out.println("Testing assert which requires a debug build. Passing silently.");
return;
}
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
true,
"-Xmx32m",
"-XX:-TransmitErrorReport",
DummyClassWithMainRangeCheck.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldMatch("assert\\(byte_offset < p_size\\) failed: Unsafe access: offset \\d+ > object's size \\d+");
}
public static class DummyClassWithMainRangeCheck {
public static void main(String args[]) throws Exception {
Unsafe unsafe = Utils.getUnsafe();
unsafe.getObject(new DummyClassWithMainRangeCheck(), Short.MAX_VALUE);
}
}
}

View File

@ -47,6 +47,7 @@ public class ReadFromNoaccessArea {
"-XX:+WhiteBoxAPI",
"-XX:+UseCompressedOops",
"-XX:HeapBaseMinAddress=33G",
"-Xmx32m",
DummyClassWithMainTryingToReadFromNoaccessArea.class.getName());
OutputAnalyzer output = new OutputAnalyzer(pb.start());

View File

@ -57,6 +57,7 @@ public class ReserveMemory {
"-XX:+UnlockDiagnosticVMOptions",
"-XX:+WhiteBoxAPI",
"-XX:-TransmitErrorReport",
"-Xmx32m",
"ReserveMemory",
"test");

View File

@ -0,0 +1,148 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.File;
import java.io.FileOutputStream;
import jdk.internal.org.objectweb.asm.ClassWriter;
import jdk.internal.org.objectweb.asm.MethodVisitor;
import static jdk.internal.org.objectweb.asm.Opcodes.*;
import com.oracle.java.testlibrary.*;
/*
* @test
* @summary Test that anewarray bytecode is valid only if it specifies 255 or fewer dimensions.
* @library /testlibrary
* @compile -XDignore.symbol.file TestANewArray.java
* @run main/othervm TestANewArray 49
* @run main/othervm TestANewArray 50
* @run main/othervm TestANewArray 51
* @run main/othervm TestANewArray 52
*/
/*
* Testing anewarray instruction with 254, 255 & 264 dimensions to verify JVMS 8,
* Section 4.9.1, Static Constraints that states the following:
*
* "No anewarray instruction may be used to create an array of more than 255 dimensions."
*
*/
public class TestANewArray {
static String classCName = null; // the generated class name
static final int test_Dimension_254 = 254; // should always pass
static final int test_Dimension_255 = 255; // should always pass, except for cfv 49
static final int test_Dimension_264 = 264; // should always fail
static final String array_Dimension_254 = genArrayDim(test_Dimension_254);
static final String array_Dimension_255 = genArrayDim(test_Dimension_255);
static final String array_Dimension_264 = genArrayDim(test_Dimension_264);
public static void main(String... args) throws Exception {
int cfv = Integer.parseInt(args[0]);
// 254 array dimensions
byte[] classFile_254 = dumpClassFile(cfv, test_Dimension_254, array_Dimension_254);
writeClassFileFromByteArray(classFile_254);
System.err.println("Running with cfv: " + cfv + ", test_Dimension_254");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotContain("java.lang.VerifyError");
output.shouldHaveExitValue(0);
// 255 array dimensions
byte[] classFile_255 = dumpClassFile(cfv, test_Dimension_255, array_Dimension_255);
writeClassFileFromByteArray(classFile_255);
System.err.println("Running with cfv: " + cfv + ", test_Dimension_255");
pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName);
output = new OutputAnalyzer(pb.start());
if (cfv == 49) {
// The type-inferencing verifier used for <=49.0 ClassFiles detects an anewarray instruction
// with exactly 255 dimensions and incorrectly issues the "Array with too many dimensions" VerifyError.
output.shouldContain("Array with too many dimensions");
output.shouldHaveExitValue(1);
} else {
// 255 dimensions should always pass, except for cfv 49
output.shouldNotContain("java.lang.VerifyError");
output.shouldNotContain("java.lang.ClassFormatError");
output.shouldHaveExitValue(0);
}
// 264 array dimensions
byte[] classFile_264 = dumpClassFile(cfv, test_Dimension_264, array_Dimension_264);
writeClassFileFromByteArray(classFile_264);
System.err.println("Running with cfv: " + cfv + ", test_Dimension_264");
pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName);
output = new OutputAnalyzer(pb.start());
output.shouldContain("java.lang.ClassFormatError");
output.shouldHaveExitValue(1);
}
public static byte[] dumpClassFile(int cfv, int testDimension264, String arrayDim) throws Exception {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
MethodVisitor mv;
classCName = "classCName_" + cfv + "_" + testDimension264;
cw.visit(cfv, ACC_PUBLIC + ACC_SUPER, classCName, null, "java/lang/Object", null);
{
mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
mv.visitInsn(RETURN);
mv.visitMaxs(1, 1);
mv.visitEnd();
}
{ // classCName main method
mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "main", "([Ljava/lang/String;)V", null, null);
mv.visitCode();
mv.visitIntInsn(BIPUSH, 1);
mv.visitTypeInsn(ANEWARRAY, arrayDim); // Test ANEWARRAY bytecode with various dimensions
mv.visitInsn(RETURN);
mv.visitMaxs(2, 2);
mv.visitEnd();
}
cw.visitEnd();
return cw.toByteArray();
}
public static FileOutputStream writeClassFileFromByteArray(byte[] classFileByteArray) throws Exception {
FileOutputStream fos = new FileOutputStream(new File(classCName + ".class"));
fos.write(classFileByteArray);
fos.close();
return fos;
}
private static String genArrayDim(int testDim) {
StringBuilder array_Dimension = new StringBuilder();
for (int i = 0; i < testDim; i++)
{
array_Dimension.append("[");
}
return array_Dimension.append("Ljava/lang/Object;").toString();
}
}