--- a/hotspot/agent/src/os/linux/libproc_impl.c Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/agent/src/os/linux/libproc_impl.c Sat Feb 15 14:41:04 2014 -0500
@@ -29,54 +29,51 @@
#include <thread_db.h>
#include "libproc_impl.h"
-static const char* alt_root = NULL;
-static int alt_root_len = -1;
-
#define SA_ALTROOT "SA_ALTROOT"
-static void init_alt_root() {
- if (alt_root_len == -1) {
- alt_root = getenv(SA_ALTROOT);
- if (alt_root) {
- alt_root_len = strlen(alt_root);
- } else {
- alt_root_len = 0;
- }
- }
-}
-
int pathmap_open(const char* name) {
- int fd;
- char alt_path[PATH_MAX + 1];
+ static const char *alt_root = NULL;
+ static int alt_root_initialized = 0;
- init_alt_root();
+ int fd;
+ char alt_path[PATH_MAX + 1], *alt_path_end;
+ const char *s;
- if (alt_root_len > 0) {
- strcpy(alt_path, alt_root);
- strcat(alt_path, name);
- fd = open(alt_path, O_RDONLY);
- if (fd >= 0) {
- print_debug("path %s substituted for %s\n", alt_path, name);
- return fd;
- }
+ if (!alt_root_initialized) {
+ alt_root_initialized = -1;
+ alt_root = getenv(SA_ALTROOT);
+ }
+
+ if (alt_root == NULL) {
+ return open(name, O_RDONLY);
+ }
+
+ strcpy(alt_path, alt_root);
+ alt_path_end = alt_path + strlen(alt_path);
- if (strrchr(name, '/')) {
- strcpy(alt_path, alt_root);
- strcat(alt_path, strrchr(name, '/'));
- fd = open(alt_path, O_RDONLY);
- if (fd >= 0) {
- print_debug("path %s substituted for %s\n", alt_path, name);
- return fd;
- }
- }
- } else {
- fd = open(name, O_RDONLY);
- if (fd >= 0) {
- return fd;
- }
- }
+ // Strip path items one by one and try to open file with alt_root prepended
+ s = name;
+ while (1) {
+ strcat(alt_path, s);
+ s += 1;
+
+ fd = open(alt_path, O_RDONLY);
+ if (fd >= 0) {
+ print_debug("path %s substituted for %s\n", alt_path, name);
+ return fd;
+ }
- return -1;
+ // Linker always put full path to solib to process, so we can rely
+ // on presence of /. If slash is not present, it means, that SOlib doesn't
+ // physically exist (e.g. linux-gate.so) and we fail opening it anyway
+ if ((s = strchr(s, '/')) == NULL) {
+ break;
+ }
+
+ *alt_path_end = 0;
+ }
+
+ return -1;
}
static bool _libsaproc_debug;
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java Sat Feb 15 14:41:04 2014 -0500
@@ -55,31 +55,21 @@
if (pc == null) {
return null;
}
+
+ /* Typically we have about ten loaded objects here. So no reason to do
+ sort/binary search here. Linear search gives us acceptable performance.*/
+
List objs = getLoadObjectList();
- Object[] arr = objs.toArray();
- // load objects are sorted by base address, do binary search
- int mid = -1;
- int low = 0;
- int high = arr.length - 1;
- while (low <= high) {
- mid = (low + high) >> 1;
- LoadObject midVal = (LoadObject) arr[mid];
- long cmp = pc.minus(midVal.getBase());
- if (cmp < 0) {
- high = mid - 1;
- } else if (cmp > 0) {
- long size = midVal.getSize();
- if (cmp >= size) {
- low = mid + 1;
- } else {
- return (LoadObject) arr[mid];
- }
- } else { // match found
- return (LoadObject) arr[mid];
- }
+ for (int i = 0; i < objs.size(); i++) {
+ LoadObject ob = (LoadObject) objs.get(i);
+ Address base = ob.getBase();
+ long size = ob.getSize();
+ if ( pc.greaterThanOrEqual(base) && pc.lessThan(base.addOffsetTo(size))) {
+ return ob;
+ }
}
- // no match found.
+
return null;
}
--- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js Sat Feb 15 14:41:04 2014 -0500
@@ -371,19 +371,23 @@
return sa.dbg.lookup(dso, sym);
}
-// returns the ClosestSymbol or null
-function closestSymbolFor(addr) {
- if (sa.cdbg == null) {
+function loadObjectContainingPC(addr) {
+ if (sa.cdbg == null) {
// no CDebugger support, return null
return null;
- } else {
- var dso = sa.cdbg.loadObjectContainingPC(addr);
- if (dso != null) {
- return dso.closestSymbolToPC(addr);
- } else {
- return null;
- }
- }
+ }
+
+ return sa.cdbg.loadObjectContainingPC(addr);
+}
+
+// returns the ClosestSymbol or null
+function closestSymbolFor(addr) {
+ var dso = loadObjectContainingPC(addr);
+ if (dso != null) {
+ return dso.closestSymbolToPC(addr);
+ }
+
+ return null;
}
// Address-to-symbol
@@ -804,6 +808,16 @@
// VM type to SA class map
var vmType2Class = new Object();
+// C2 only classes
+try{
+ vmType2Class["ExceptionBlob"] = sapkg.code.ExceptionBlob;
+ vmType2Class["UncommonTrapBlob"] = sapkg.code.UncommonTrapBlob;
+} catch(e) {
+ // Ignore exception. C2 specific objects might be not
+ // available in client VM
+}
+
+
// This is *not* exhaustive. Add more if needed.
// code blobs
vmType2Class["BufferBlob"] = sapkg.code.BufferBlob;
@@ -812,10 +826,8 @@
vmType2Class["SafepointBlob"] = sapkg.code.SafepointBlob;
vmType2Class["C2IAdapter"] = sapkg.code.C2IAdapter;
vmType2Class["DeoptimizationBlob"] = sapkg.code.DeoptimizationBlob;
-vmType2Class["ExceptionBlob"] = sapkg.code.ExceptionBlob;
vmType2Class["I2CAdapter"] = sapkg.code.I2CAdapter;
vmType2Class["OSRAdapter"] = sapkg.code.OSRAdapter;
-vmType2Class["UncommonTrapBlob"] = sapkg.code.UncommonTrapBlob;
vmType2Class["PCDesc"] = sapkg.code.PCDesc;
// interpreter
@@ -876,21 +888,29 @@
// returns description of given pointer as a String
function whatis(addr) {
- addr = any2addr(addr);
- var ptrLoc = findPtr(addr);
- if (ptrLoc.isUnknown()) {
- var vmType = vmTypeof(addr);
- if (vmType != null) {
- return "pointer to " + vmType.name;
- } else {
- var sym = closestSymbolFor(addr);
- if (sym != null) {
- return sym.name + '+' + sym.offset;
- } else {
- return ptrLoc.toString();
- }
- }
- } else {
- return ptrLoc.toString();
- }
+ addr = any2addr(addr);
+ var ptrLoc = findPtr(addr);
+ if (!ptrLoc.isUnknown()) {
+ return ptrLoc.toString();
+ }
+
+ var vmType = vmTypeof(addr);
+ if (vmType != null) {
+ return "pointer to " + vmType.name;
+ }
+
+ var dso = loadObjectContainingPC(addr);
+ if (dso == null) {
+ return ptrLoc.toString();
+ }
+
+ var sym = dso.closestSymbolToPC(addr);
+ if (sym != null) {
+ return sym.name + '+' + sym.offset;
+ }
+
+ var s = dso.getName();
+ var p = s.lastIndexOf("/");
+ var base = dso.getBase();
+ return s.substring(p+1, s.length) + '+' + addr.minus(base);
}
--- a/hotspot/make/bsd/makefiles/gcc.make Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/make/bsd/makefiles/gcc.make Sat Feb 15 14:41:04 2014 -0500
@@ -260,7 +260,7 @@
WARNINGS_ARE_ERRORS += -Wno-empty-body
endif
-WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value
+WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2 -Wno-error=format-nonliteral
ifeq ($(USE_CLANG),)
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
@@ -289,7 +289,7 @@
# The flags to use for an Optimized g++ build
ifeq ($(OS_VENDOR), Darwin)
# use -Os by default, unless -O3 can be proved to be worth the cost, as per policy
- # <http://wikis.sun.com/display/OpenJDK/Mac+OS+X+Port+Compilers>
+ # <https://wiki.openjdk.java.net/display/MacOSXPort/Compiler+Errata>
OPT_CFLAGS_DEFAULT ?= SIZE
else
OPT_CFLAGS_DEFAULT ?= SPEED
--- a/hotspot/make/linux/makefiles/gcc.make Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/make/linux/makefiles/gcc.make Sat Feb 15 14:41:04 2014 -0500
@@ -214,7 +214,7 @@
WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body
endif
-WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value
+WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wno-error=format-nonliteral
ifeq ($(USE_CLANG),)
# Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit
--- a/hotspot/make/solaris/makefiles/gcc.make Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/make/solaris/makefiles/gcc.make Sat Feb 15 14:41:04 2014 -0500
@@ -118,7 +118,7 @@
# Compiler warnings are treated as errors
WARNINGS_ARE_ERRORS = -Werror
# Enable these warnings. See 'info gcc' about details on these options
-WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef
+WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef -Wformat=2 -Wno-error=format-nonliteral
CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS)
# Special cases
CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@))
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp Sat Feb 15 14:41:04 2014 -0500
@@ -1834,7 +1834,7 @@
jrelib_p = buf + len;
snprintf(jrelib_p, buflen-len, "/%s", COMPILER_VARIANT);
if (0 != access(buf, F_OK)) {
- snprintf(jrelib_p, buflen-len, "");
+ snprintf(jrelib_p, buflen-len, "%s", "");
}
// If the path exists within JAVA_HOME, add the JVM library name
--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp Sat Feb 15 14:41:04 2014 -0500
@@ -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
@@ -520,6 +520,13 @@
}
}
+bool ClassLoaderData::contains_klass(Klass* klass) {
+ for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
+ if (k == klass) return true;
+ }
+ return false;
+}
+
// GC root of class loader data created.
ClassLoaderData* ClassLoaderDataGraph::_head = NULL;
--- a/hotspot/src/share/vm/classfile/classLoaderData.hpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp Sat Feb 15 14:41:04 2014 -0500
@@ -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
@@ -260,6 +260,7 @@
jobject add_handle(Handle h);
void add_class(Klass* k);
void remove_class(Klass* k);
+ bool contains_klass(Klass* k);
void record_dependency(Klass* to, TRAPS);
void init_dependencies(TRAPS);
--- a/hotspot/src/share/vm/classfile/dictionary.cpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/classfile/dictionary.cpp Sat Feb 15 14:41:04 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -707,7 +707,7 @@
loader_data->class_loader() == NULL ||
loader_data->class_loader()->is_instance(),
"checking type of class_loader");
- e->verify(/*check_dictionary*/false);
+ e->verify();
probe->verify_protection_domain_set();
element_count++;
}
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp Sat Feb 15 14:41:04 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -2650,23 +2650,6 @@
constraints()->verify(dictionary(), placeholders());
}
-
-void SystemDictionary::verify_obj_klass_present(Symbol* class_name,
- ClassLoaderData* loader_data) {
- GCMutexLocker mu(SystemDictionary_lock);
- Symbol* name;
-
- Klass* probe = find_class(class_name, loader_data);
- if (probe == NULL) {
- probe = SystemDictionary::find_shared_class(class_name);
- if (probe == NULL) {
- name = find_placeholder(class_name, loader_data);
- }
- }
- guarantee(probe != NULL || name != NULL,
- "Loaded klasses should be in SystemDictionary");
-}
-
// utility function for class load event
void SystemDictionary::post_class_load_event(const Ticks& start_time,
instanceKlassHandle k,
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp Sat Feb 15 14:41:04 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -375,10 +375,6 @@
static bool is_internal_format(Symbol* class_name);
#endif
- // Verify class is in dictionary
- static void verify_obj_klass_present(Symbol* class_name,
- ClassLoaderData* loader_data);
-
// Initialization
static void initialize(TRAPS);
--- a/hotspot/src/share/vm/oops/arrayKlass.cpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/oops/arrayKlass.cpp Sat Feb 15 14:41:04 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -214,8 +214,8 @@
// Verification
-void ArrayKlass::verify_on(outputStream* st, bool check_dictionary) {
- Klass::verify_on(st, check_dictionary);
+void ArrayKlass::verify_on(outputStream* st) {
+ Klass::verify_on(st);
if (component_mirror() != NULL) {
guarantee(component_mirror()->klass() != NULL, "should have a class");
--- a/hotspot/src/share/vm/oops/arrayKlass.hpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/oops/arrayKlass.hpp Sat Feb 15 14:41:04 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -146,7 +146,7 @@
void oop_print_on(oop obj, outputStream* st);
// Verification
- void verify_on(outputStream* st, bool check_dictionary);
+ void verify_on(outputStream* st);
void oop_verify_on(oop obj, outputStream* st);
};
--- a/hotspot/src/share/vm/oops/instanceKlass.cpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/oops/instanceKlass.cpp Sat Feb 15 14:41:04 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -3180,7 +3180,7 @@
virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); }
};
-void InstanceKlass::verify_on(outputStream* st, bool check_dictionary) {
+void InstanceKlass::verify_on(outputStream* st) {
#ifndef PRODUCT
// Avoid redundant verifies, this really should be in product.
if (_verify_count == Universe::verify_count()) return;
@@ -3188,14 +3188,11 @@
#endif
// Verify Klass
- Klass::verify_on(st, check_dictionary);
-
- // Verify that klass is present in SystemDictionary if not already
- // verifying the SystemDictionary.
- if (is_loaded() && !is_anonymous() && check_dictionary) {
- Symbol* h_name = name();
- SystemDictionary::verify_obj_klass_present(h_name, class_loader_data());
- }
+ Klass::verify_on(st);
+
+ // Verify that klass is present in ClassLoaderData
+ guarantee(class_loader_data()->contains_klass(this),
+ "this class isn't found in class loader data");
// Verify vtables
if (is_linked()) {
--- a/hotspot/src/share/vm/oops/instanceKlass.hpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/oops/instanceKlass.hpp Sat Feb 15 14:41:04 2014 -0500
@@ -1087,7 +1087,7 @@
const char* internal_name() const;
// Verification
- void verify_on(outputStream* st, bool check_dictionary);
+ void verify_on(outputStream* st);
void oop_verify_on(oop obj, outputStream* st);
};
--- a/hotspot/src/share/vm/oops/klass.cpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/oops/klass.cpp Sat Feb 15 14:41:04 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -638,7 +638,7 @@
// Verification
-void Klass::verify_on(outputStream* st, bool check_dictionary) {
+void Klass::verify_on(outputStream* st) {
// This can be expensive, but it is worth checking that this klass is actually
// in the CLD graph but not in production.
--- a/hotspot/src/share/vm/oops/klass.hpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/oops/klass.hpp Sat Feb 15 14:41:04 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -695,8 +695,8 @@
virtual const char* internal_name() const = 0;
// Verification
- virtual void verify_on(outputStream* st, bool check_dictionary);
- void verify(bool check_dictionary = true) { verify_on(tty, check_dictionary); }
+ virtual void verify_on(outputStream* st);
+ void verify() { verify_on(tty); }
#ifndef PRODUCT
bool verify_vtable_index(int index);
--- a/hotspot/src/share/vm/oops/objArrayKlass.cpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp Sat Feb 15 14:41:04 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -674,8 +674,8 @@
// Verification
-void ObjArrayKlass::verify_on(outputStream* st, bool check_dictionary) {
- ArrayKlass::verify_on(st, check_dictionary);
+void ObjArrayKlass::verify_on(outputStream* st) {
+ ArrayKlass::verify_on(st);
guarantee(element_klass()->is_klass(), "should be klass");
guarantee(bottom_klass()->is_klass(), "should be klass");
Klass* bk = bottom_klass();
--- a/hotspot/src/share/vm/oops/objArrayKlass.hpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/oops/objArrayKlass.hpp Sat Feb 15 14:41:04 2014 -0500
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -151,7 +151,7 @@
const char* internal_name() const;
// Verification
- void verify_on(outputStream* st, bool check_dictionary);
+ void verify_on(outputStream* st);
void oop_verify_on(oop obj, outputStream* st);
};
--- a/hotspot/src/share/vm/opto/node.cpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/opto/node.cpp Sat Feb 15 14:41:04 2014 -0500
@@ -285,6 +285,10 @@
#ifdef _MSC_VER // the IDX_INIT hack falls foul of warning C4355
#pragma warning( disable:4355 ) // 'this' : used in base member initializer list
#endif
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma GCC diagnostic ignored "-Wuninitialized"
+#endif
// Out-of-line code from node constructors.
// Executed only when extra debug info. is being passed around.
@@ -468,6 +472,10 @@
_in[6] = n6; if (n6 != NULL) n6->add_out((Node *)this);
}
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
//------------------------------clone------------------------------------------
// Clone a Node.
--- a/hotspot/src/share/vm/prims/jni.cpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/prims/jni.cpp Sat Feb 15 14:41:04 2014 -0500
@@ -4348,8 +4348,23 @@
// Get needed field and method IDs
directByteBufferConstructor = env->GetMethodID(directByteBufferClass, "<init>", "(JI)V");
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ directBufferSupportInitializeFailed = 1;
+ return false;
+ }
directBufferAddressField = env->GetFieldID(bufferClass, "address", "J");
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ directBufferSupportInitializeFailed = 1;
+ return false;
+ }
bufferCapacityField = env->GetFieldID(bufferClass, "capacity", "I");
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ directBufferSupportInitializeFailed = 1;
+ return false;
+ }
if ((directByteBufferConstructor == NULL) ||
(directBufferAddressField == NULL) ||
--- a/hotspot/src/share/vm/prims/unsafe.cpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/prims/unsafe.cpp Sat Feb 15 14:41:04 2014 -0500
@@ -858,6 +858,11 @@
strcpy(buf, "java/lang/");
strcat(buf, ename);
jclass cls = env->FindClass(buf);
+ if (env->ExceptionCheck()) {
+ env->ExceptionClear();
+ tty->print_cr("Unsafe: cannot throw %s because FindClass has failed", buf);
+ return;
+ }
char* msg = NULL;
env->ThrowNew(cls, msg);
}
--- a/hotspot/src/share/vm/prims/whitebox.cpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/prims/whitebox.cpp Sat Feb 15 14:41:04 2014 -0500
@@ -316,9 +316,10 @@
WB_ENTRY(jint, WB_DeoptimizeMethod(JNIEnv* env, jobject o, jobject method, jboolean is_osr))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+ int result = 0;
+ CHECK_JNI_EXCEPTION_(env, result);
MutexLockerEx mu(Compile_lock);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
- int result = 0;
nmethod* code;
if (is_osr) {
int bci = InvocationEntryBci;
@@ -344,6 +345,7 @@
WB_ENTRY(jboolean, WB_IsMethodCompiled(JNIEnv* env, jobject o, jobject method, jboolean is_osr))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+ CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
MutexLockerEx mu(Compile_lock);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
@@ -355,6 +357,7 @@
WB_ENTRY(jboolean, WB_IsMethodCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+ CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
MutexLockerEx mu(Compile_lock);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
if (is_osr) {
@@ -366,6 +369,7 @@
WB_ENTRY(jboolean, WB_IsMethodQueuedForCompilation(JNIEnv* env, jobject o, jobject method))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+ CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
MutexLockerEx mu(Compile_lock);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
return mh->queued_for_compilation();
@@ -373,6 +377,7 @@
WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject method, jboolean is_osr))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+ CHECK_JNI_EXCEPTION_(env, CompLevel_none);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code();
return (code != NULL ? code->comp_level() : CompLevel_none);
@@ -380,6 +385,7 @@
WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+ CHECK_JNI_EXCEPTION(env);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
if (is_osr) {
mh->set_not_osr_compilable(comp_level, true /* report */, "WhiteBox");
@@ -390,6 +396,7 @@
WB_ENTRY(jint, WB_GetMethodEntryBci(JNIEnv* env, jobject o, jobject method))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+ CHECK_JNI_EXCEPTION_(env, InvocationEntryBci);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
nmethod* code = mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false);
return (code != NULL && code->is_osr_method() ? code->osr_entry_bci() : InvocationEntryBci);
@@ -397,6 +404,7 @@
WB_ENTRY(jboolean, WB_TestSetDontInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+ CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
bool result = mh->dont_inline();
mh->set_dont_inline(value == JNI_TRUE);
@@ -414,6 +422,7 @@
WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+ CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
bool result = mh->force_inline();
mh->set_force_inline(value == JNI_TRUE);
@@ -422,6 +431,7 @@
WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+ CHECK_JNI_EXCEPTION_(env, JNI_FALSE);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD);
MutexLockerEx mu(Compile_lock);
@@ -430,6 +440,7 @@
WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method))
jmethodID jmid = reflected_method_to_jmid(thread, env, method);
+ CHECK_JNI_EXCEPTION(env);
methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid));
MutexLockerEx mu(Compile_lock);
MethodData* mdo = mh->method_data();
@@ -616,14 +627,18 @@
bool result = true;
// one by one registration natives for exception catching
jclass exceptionKlass = env->FindClass(vmSymbols::java_lang_NoSuchMethodError()->as_C_string());
+ CHECK_JNI_EXCEPTION(env);
for (int i = 0, n = sizeof(methods) / sizeof(methods[0]); i < n; ++i) {
if (env->RegisterNatives(wbclass, methods + i, 1) != 0) {
result = false;
- if (env->ExceptionCheck() && env->IsInstanceOf(env->ExceptionOccurred(), exceptionKlass)) {
- // j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native
- // ignoring the exception
- tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature);
+ jthrowable throwable_obj = env->ExceptionOccurred();
+ if (throwable_obj != NULL) {
env->ExceptionClear();
+ if (env->IsInstanceOf(throwable_obj, exceptionKlass)) {
+ // j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native
+ // ignoring the exception
+ tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature);
+ }
} else {
// register is failed w/o exception or w/ unexpected exception
tty->print_cr("Warning: unexpected error on register of sun.hotspot.WhiteBox::%s%s. All methods will be unregistered", methods[i].name, methods[i].signature);
--- a/hotspot/src/share/vm/prims/whitebox.hpp Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/src/share/vm/prims/whitebox.hpp Sat Feb 15 14:41:04 2014 -0500
@@ -36,6 +36,24 @@
#define WB_END JNI_END
#define WB_METHOD_DECLARE(result_type) extern "C" result_type JNICALL
+#define CHECK_JNI_EXCEPTION_(env, value) \
+ do { \
+ JavaThread* THREAD = JavaThread::thread_from_jni_environment(env); \
+ if (HAS_PENDING_EXCEPTION) { \
+ CLEAR_PENDING_EXCEPTION; \
+ return(value); \
+ } \
+ } while (0)
+
+#define CHECK_JNI_EXCEPTION(env) \
+ do { \
+ JavaThread* THREAD = JavaThread::thread_from_jni_environment(env); \
+ if (HAS_PENDING_EXCEPTION) { \
+ CLEAR_PENDING_EXCEPTION; \
+ return; \
+ } \
+ } while (0)
+
class WhiteBox : public AllStatic {
private:
static bool _used;
--- a/hotspot/test/runtime/7158988/FieldMonitor.java Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/test/runtime/7158988/FieldMonitor.java Sat Feb 15 14:41:04 2014 -0500
@@ -34,10 +34,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Reader;
-import java.io.Writer;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -56,6 +52,7 @@
import com.sun.jdi.event.EventSet;
import com.sun.jdi.event.ModificationWatchpointEvent;
import com.sun.jdi.event.VMDeathEvent;
+import com.sun.jdi.event.VMStartEvent;
import com.sun.jdi.event.VMDisconnectEvent;
import com.sun.jdi.request.ClassPrepareRequest;
import com.sun.jdi.request.EventRequest;
@@ -71,24 +68,10 @@
public static void main(String[] args)
throws IOException, InterruptedException {
- StringBuffer sb = new StringBuffer();
-
- for (int i=0; i < args.length; i++) {
- sb.append(' ');
- sb.append(args[i]);
- }
//VirtualMachine vm = launchTarget(sb.toString());
VirtualMachine vm = launchTarget(CLASS_NAME);
System.out.println("Vm launched");
- // set watch field on already loaded classes
- List<ReferenceType> referenceTypes = vm
- .classesByName(CLASS_NAME);
- for (ReferenceType refType : referenceTypes) {
- addFieldWatch(vm, refType);
- }
- // watch for loaded classes
- addClassWatch(vm);
// process events
EventQueue eventQueue = vm.eventQueue();
@@ -104,13 +87,15 @@
errThread.start();
outThread.start();
-
- vm.resume();
boolean connected = true;
+ int watched = 0;
while (connected) {
EventSet eventSet = eventQueue.remove();
for (Event event : eventSet) {
- if (event instanceof VMDeathEvent
+ System.out.println("FieldMonitor-main receives: "+event);
+ if (event instanceof VMStartEvent) {
+ addClassWatch(vm);
+ } else if (event instanceof VMDeathEvent
|| event instanceof VMDisconnectEvent) {
// exit
connected = false;
@@ -122,17 +107,17 @@
.referenceType();
addFieldWatch(vm, refType);
} else if (event instanceof ModificationWatchpointEvent) {
+ watched++;
System.out.println("sleep for 500 ms");
Thread.sleep(500);
- System.out.println("resume...");
ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent) event;
System.out.println("old="
+ modEvent.valueCurrent());
System.out.println("new=" + modEvent.valueToBe());
- System.out.println();
}
}
+ System.out.println("resume...");
eventSet.resume();
}
// Shutdown begins when event thread terminates
@@ -142,6 +127,10 @@
} catch (InterruptedException exc) {
// we don't interrupt
}
+
+ if (watched != 11) { // init + 10 modifications in TestPostFieldModification class
+ throw new Error("Expected to receive 11 times ModificationWatchpointEvent, but got "+watched);
+ }
}
/**
--- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java Thu Feb 13 17:57:27 2014 +0100
+++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java Sat Feb 15 14:41:04 2014 -0500
@@ -154,7 +154,7 @@
if (addTestVmOptions) {
String vmopts = System.getProperty("test.vm.opts");
- if (vmopts != null) {
+ if (vmopts != null && vmopts.length() > 0) {
Collections.addAll(args, vmopts.split("\\s"));
}
}