--- a/hotspot/src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/cpu/aarch64/vm/jvmciCodeInstaller_aarch64.cpp Tue Mar 29 22:39:17 2016 +0000
@@ -65,7 +65,7 @@
Unimplemented();
} else {
NativeMovConstReg* move = nativeMovConstReg_at(pc);
- Metadata* reference = record_metadata_reference(constant, CHECK);
+ void* reference = record_metadata_reference(constant, CHECK);
move->set_data((intptr_t) reference);
TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference));
}
--- a/hotspot/src/cpu/sparc/vm/jvmciCodeInstaller_sparc.cpp Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/cpu/sparc/vm/jvmciCodeInstaller_sparc.cpp Tue Mar 29 22:39:17 2016 +0000
@@ -79,7 +79,7 @@
#endif
} else {
NativeMovConstReg* move = nativeMovConstReg_at(pc);
- Metadata* reference = record_metadata_reference(constant, CHECK);
+ void* reference = record_metadata_reference(constant, CHECK);
move->set_data((intptr_t)reference);
TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(reference));
}
--- a/hotspot/src/cpu/x86/vm/jvmciCodeInstaller_x86.cpp Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/cpu/x86/vm/jvmciCodeInstaller_x86.cpp Tue Mar 29 22:39:17 2016 +0000
@@ -96,7 +96,7 @@
#endif
} else {
address operand = Assembler::locate_operand(pc, Assembler::imm_operand);
- *((Metadata**) operand) = record_metadata_reference(constant, CHECK);
+ *((void**) operand) = record_metadata_reference(constant, CHECK);
TRACE_jvmci_3("relocating (metaspace constant) at " PTR_FORMAT "/" PTR_FORMAT, p2i(pc), p2i(operand));
}
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java Tue Mar 29 22:39:17 2016 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -480,6 +480,11 @@
native String getSymbol(long metaspaceSymbol);
/**
+ * Lookup a VMSymbol from a String.
+ */
+ native long lookupSymbol(String symbol);
+
+ /**
* Looks for the next Java stack frame matching an entry in {@code methods}.
*
* @param frame the starting point of the search, where {@code null} refers to the topmost frame
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProvider.java Tue Mar 29 22:39:17 2016 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -39,4 +39,6 @@
Constant readNarrowKlassPointerConstant(Constant base, long displacement, CompressEncoding encoding);
Constant readMethodPointerConstant(Constant base, long displacement);
+
+ Constant readSymbolConstant(Constant base, long displacement);
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMemoryAccessProviderImpl.java Tue Mar 29 22:39:17 2016 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -82,13 +82,13 @@
Object base = asObject(baseConstant);
if (base != null) {
switch (bits) {
- case 8:
+ case Byte.SIZE:
return UNSAFE.getByte(base, displacement);
- case 16:
+ case Short.SIZE:
return UNSAFE.getShort(base, displacement);
- case 32:
+ case Integer.SIZE:
return UNSAFE.getInt(base, displacement);
- case 64:
+ case Long.SIZE:
return UNSAFE.getLong(base, displacement);
default:
throw new JVMCIError("%d", bits);
@@ -96,13 +96,13 @@
} else {
long pointer = asRawPointer(baseConstant);
switch (bits) {
- case 8:
+ case Byte.SIZE:
return UNSAFE.getByte(pointer + displacement);
- case 16:
+ case Short.SIZE:
return UNSAFE.getShort(pointer + displacement);
- case 32:
+ case Integer.SIZE:
return UNSAFE.getInt(pointer + displacement);
- case 64:
+ case Long.SIZE:
return UNSAFE.getLong(pointer + displacement);
default:
throw new JVMCIError("%d", bits);
@@ -151,7 +151,8 @@
Object o = readRawObject(baseConstant, displacement, runtime.getConfig().useCompressedOops);
return HotSpotObjectConstantImpl.forObject(o);
} else {
- return readPrimitiveConstant(kind, baseConstant, displacement, kind.getByteCount() * 8);
+ int bits = kind.getByteCount() * Byte.SIZE;
+ return readPrimitiveConstant(kind, baseConstant, displacement, bits);
}
}
@@ -229,4 +230,16 @@
HotSpotResolvedJavaMethodImpl method = runtime.getCompilerToVM().getResolvedJavaMethod(baseObject, displacement);
return HotSpotMetaspaceConstantImpl.forMetaspaceObject(method, false);
}
+
+ @Override
+ public Constant readSymbolConstant(Constant base, long displacement) {
+ int bits = runtime.getConfig().symbolPointerSize * Byte.SIZE;
+ long pointer = readRawValue(base, displacement, bits);
+ if (pointer == 0) {
+ return JavaConstant.NULL_POINTER;
+ } else {
+ String symbol = runtime.getCompilerToVM().getSymbol(pointer);
+ return new HotSpotSymbol(symbol, pointer).asConstant();
+ }
+ }
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaAccessProvider.java Tue Mar 29 22:39:17 2016 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -78,6 +78,15 @@
return new HotSpotSignature(runtime, signature);
}
+ public HotSpotSymbol lookupSymbol(String symbol) {
+ long pointer = runtime.getCompilerToVM().lookupSymbol(symbol);
+ if (pointer == 0) {
+ return null;
+ } else {
+ return new HotSpotSymbol(symbol, pointer);
+ }
+ }
+
/**
* {@link Field} object of {@link Method#slot}.
*/
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstant.java Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstant.java Tue Mar 29 22:39:17 2016 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -29,4 +29,6 @@
HotSpotResolvedObjectType asResolvedJavaType();
HotSpotResolvedJavaMethod asResolvedJavaMethod();
+
+ HotSpotSymbol asSymbol();
}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java Tue Mar 29 22:39:17 2016 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -108,4 +108,11 @@
}
return null;
}
+
+ public HotSpotSymbol asSymbol() {
+ if (metaspaceObject instanceof HotSpotSymbol) {
+ return (HotSpotSymbol) metaspaceObject;
+ }
+ return null;
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSymbol.java Tue Mar 29 22:39:17 2016 +0000
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.vm.ci.hotspot;
+
+import jdk.vm.ci.meta.Constant;
+
+/**
+ * Class to access the C++ {@code vmSymbols} table.
+ */
+public final class HotSpotSymbol implements MetaspaceWrapperObject {
+
+ private final String symbol;
+ private final long pointer;
+
+ HotSpotSymbol(String symbol, long pointer) {
+ this.symbol = symbol;
+ this.pointer = pointer;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public Constant asConstant() {
+ return HotSpotMetaspaceConstantImpl.forMetaspaceObject(this, false);
+ }
+
+ @Override
+ public long getMetaspacePointer() {
+ return pointer;
+ }
+
+ @Override
+ public String toString() {
+ return "Symbol<" + symbol + ">";
+ }
+}
--- a/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotVMConfig.java Tue Mar 29 22:39:17 2016 +0000
@@ -1001,6 +1001,7 @@
@HotSpotVMField(name = "Klass::_modifier_flags", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int klassModifierFlagsOffset;
@HotSpotVMField(name = "Klass::_access_flags", type = "AccessFlags", get = HotSpotVMField.Type.OFFSET) @Stable public int klassAccessFlagsOffset;
@HotSpotVMField(name = "Klass::_layout_helper", type = "jint", get = HotSpotVMField.Type.OFFSET) @Stable public int klassLayoutHelperOffset;
+ @HotSpotVMField(name = "Klass::_name", type = "Symbol*", get = HotSpotVMField.Type.OFFSET) @Stable public int klassNameOffset;
@HotSpotVMConstant(name = "Klass::_lh_neutral_value") @Stable public int klassLayoutHelperNeutralValue;
@HotSpotVMConstant(name = "Klass::_lh_instance_slow_path_bit") @Stable public int klassLayoutHelperInstanceSlowPathBit;
@@ -1536,8 +1537,9 @@
@HotSpotVMAddress(name = "JVMCIRuntime::exception_handler_for_pc") @Stable public long exceptionHandlerForPcAddress;
@HotSpotVMAddress(name = "JVMCIRuntime::monitorenter") @Stable public long monitorenterAddress;
@HotSpotVMAddress(name = "JVMCIRuntime::monitorexit") @Stable public long monitorexitAddress;
- @HotSpotVMAddress(name = "JVMCIRuntime::create_null_exception") @Stable public long createNullPointerExceptionAddress;
- @HotSpotVMAddress(name = "JVMCIRuntime::create_out_of_bounds_exception") @Stable public long createOutOfBoundsExceptionAddress;
+ @HotSpotVMAddress(name = "JVMCIRuntime::throw_and_post_jvmti_exception") @Stable public long throwAndPostJvmtiExceptionAddress;
+ @HotSpotVMAddress(name = "JVMCIRuntime::throw_klass_external_name_exception") @Stable public long throwKlassExternalNameExceptionAddress;
+ @HotSpotVMAddress(name = "JVMCIRuntime::throw_class_cast_exception") @Stable public long throwClassCastExceptionAddress;
@HotSpotVMAddress(name = "JVMCIRuntime::log_primitive") @Stable public long logPrimitiveAddress;
@HotSpotVMAddress(name = "JVMCIRuntime::log_object") @Stable public long logObjectAddress;
@HotSpotVMAddress(name = "JVMCIRuntime::log_printf") @Stable public long logPrintfAddress;
--- a/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.cpp Tue Mar 29 22:39:17 2016 +0000
@@ -177,7 +177,13 @@
return map;
}
-Metadata* CodeInstaller::record_metadata_reference(Handle constant, TRAPS) {
+void* CodeInstaller::record_metadata_reference(Handle constant, TRAPS) {
+ /*
+ * This method needs to return a raw (untyped) pointer, since the value of a pointer to the base
+ * class is in general not equal to the pointer of the subclass. When patching metaspace pointers,
+ * the compiler expects a direct pointer to the subclass (Klass*, Method* or Symbol*), not a
+ * pointer to the base class (Metadata* or MetaspaceObj*).
+ */
oop obj = HotSpotMetaspaceConstantImpl::metaspaceObject(constant);
if (obj->is_a(HotSpotResolvedObjectTypeImpl::klass())) {
Klass* klass = java_lang_Class::as_Klass(HotSpotResolvedObjectTypeImpl::javaClass(obj));
@@ -191,6 +197,11 @@
int index = _oop_recorder->find_index(method);
TRACE_jvmci_3("metadata[%d of %d] = %s", index, _oop_recorder->metadata_count(), method->name()->as_C_string());
return method;
+ } else if (obj->is_a(HotSpotSymbol::klass())) {
+ Symbol* symbol = (Symbol*) (address) HotSpotSymbol::pointer(obj);
+ assert(!HotSpotMetaspaceConstantImpl::compressed(constant), "unexpected compressed symbol pointer %s @ " INTPTR_FORMAT, symbol->as_C_string(), p2i(symbol));
+ TRACE_jvmci_3("symbol = %s", symbol->as_C_string());
+ return symbol;
} else {
JVMCI_ERROR_NULL("unexpected metadata reference for constant of type %s", obj->klass()->signature_name());
}
@@ -706,7 +717,7 @@
JVMCI_ERROR_OK("unexpected compressed Klass* in 32-bit mode");
#endif
} else {
- *((Metadata**) dest) = record_metadata_reference(constant, CHECK_OK);
+ *((void**) dest) = record_metadata_reference(constant, CHECK_OK);
}
} else if (constant->is_a(HotSpotObjectConstantImpl::klass())) {
Handle obj = HotSpotObjectConstantImpl::object(constant);
--- a/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.hpp Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciCodeInstaller.hpp Tue Mar 29 22:39:17 2016 +0000
@@ -189,7 +189,7 @@
ScopeValue* get_scope_value(Handle value, BasicType type, GrowableArray<ScopeValue*>* objects, ScopeValue* &second, TRAPS);
MonitorValue* get_monitor_value(Handle value, GrowableArray<ScopeValue*>* objects, TRAPS);
- Metadata* record_metadata_reference(Handle constant, TRAPS);
+ void* record_metadata_reference(Handle constant, TRAPS);
#ifdef _LP64
narrowKlass record_narrow_metadata_reference(Handle constant, TRAPS);
#endif
--- a/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp Tue Mar 29 22:39:17 2016 +0000
@@ -1051,6 +1051,11 @@
return JNIHandles::make_local(THREAD, sym());
C2V_END
+C2V_VMENTRY(jlong, lookupSymbol, (JNIEnv*, jobject, jobject string))
+ Symbol* symbol = java_lang_String::as_symbol_or_null(JNIHandles::resolve(string));
+ return (jlong) symbol;
+C2V_END
+
bool matches(jobjectArray methods, Method* method) {
objArrayOop methods_oop = (objArrayOop) JNIHandles::resolve(methods);
@@ -1478,6 +1483,7 @@
{CC"isMature", CC"("METASPACE_METHOD_DATA")Z", FN_PTR(isMature)},
{CC"hasCompiledCodeForOSR", CC"("HS_RESOLVED_METHOD"II)Z", FN_PTR(hasCompiledCodeForOSR)},
{CC"getSymbol", CC"(J)"STRING, FN_PTR(getSymbol)},
+ {CC"lookupSymbol", CC"("STRING")J", FN_PTR(lookupSymbol)},
{CC"getNextStackFrame", CC"("HS_STACK_FRAME_REF "["RESOLVED_METHOD"I)"HS_STACK_FRAME_REF, FN_PTR(getNextStackFrame)},
{CC"materializeVirtualObjects", CC"("HS_STACK_FRAME_REF"Z)V", FN_PTR(materializeVirtualObjects)},
{CC"shouldDebugNonSafepoints", CC"()Z", FN_PTR(shouldDebugNonSafepoints)},
--- a/hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciJavaClasses.hpp Tue Mar 29 22:39:17 2016 +0000
@@ -64,6 +64,9 @@
start_class(HotSpotResolvedJavaMethodImpl) \
long_field(HotSpotResolvedJavaMethodImpl, metaspaceMethod) \
end_class \
+ start_class(HotSpotSymbol) \
+ long_field(HotSpotSymbol, pointer) \
+ end_class \
start_class(InstalledCode) \
long_field(InstalledCode, address) \
long_field(InstalledCode, entryPoint) \
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.cpp Tue Mar 29 22:39:17 2016 +0000
@@ -363,20 +363,6 @@
return continuation;
}
-JRT_ENTRY(void, JVMCIRuntime::create_null_exception(JavaThread* thread))
- SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_NullPointerException());
- thread->set_vm_result(PENDING_EXCEPTION);
- CLEAR_PENDING_EXCEPTION;
-JRT_END
-
-JRT_ENTRY(void, JVMCIRuntime::create_out_of_bounds_exception(JavaThread* thread, jint index))
- char message[jintAsStringSize];
- sprintf(message, "%d", index);
- SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message);
- thread->set_vm_result(PENDING_EXCEPTION);
- CLEAR_PENDING_EXCEPTION;
-JRT_END
-
JRT_ENTRY_NO_ASYNC(void, JVMCIRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock))
IF_TRACE_jvmci_3 {
char type[O_BUFLEN];
@@ -438,6 +424,21 @@
}
JRT_END
+JRT_ENTRY(void, JVMCIRuntime::throw_and_post_jvmti_exception(JavaThread* thread, Symbol* name, const char* message))
+ SharedRuntime::throw_and_post_jvmti_exception(thread, name, message);
+JRT_END
+
+JRT_ENTRY(void, JVMCIRuntime::throw_klass_external_name_exception(JavaThread* thread, Symbol* exception, Klass* klass))
+ ResourceMark rm(thread);
+ SharedRuntime::throw_and_post_jvmti_exception(thread, exception, klass->external_name());
+JRT_END
+
+JRT_ENTRY(void, JVMCIRuntime::throw_class_cast_exception(JavaThread* thread, Symbol* exception, Klass* caster_klass, Klass* target_klass))
+ ResourceMark rm(thread);
+ const char* message = SharedRuntime::generate_class_cast_message(caster_klass, target_klass);
+ SharedRuntime::throw_and_post_jvmti_exception(thread, exception, message);
+JRT_END
+
JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, bool as_string, bool newline))
ttyLocker ttyl;
--- a/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/jvmciRuntime.hpp Tue Mar 29 22:39:17 2016 +0000
@@ -141,8 +141,6 @@
static address exception_handler_for_pc(JavaThread* thread);
static void monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock);
static void monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock);
- static void create_null_exception(JavaThread* thread);
- static void create_out_of_bounds_exception(JavaThread* thread, jint index);
static void vm_error(JavaThread* thread, jlong where, jlong format, jlong value);
static oopDesc* load_and_clear_exception(JavaThread* thread);
static void log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3);
@@ -157,6 +155,12 @@
static jboolean validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child);
static void new_store_pre_barrier(JavaThread* thread);
+ // used to throw exceptions from compiled JVMCI code
+ static void throw_and_post_jvmti_exception(JavaThread* thread, Symbol* exception, const char* message);
+ // helper methods to throw exception with complex messages
+ static void throw_klass_external_name_exception(JavaThread* thread, Symbol* exception, Klass* klass);
+ static void throw_class_cast_exception(JavaThread* thread, Symbol* exception, Klass* caster_klass, Klass* target_klass);
+
// Test only function
static int test_deoptimize_call_int(JavaThread* thread, int value);
};
--- a/hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/systemDictionary_jvmci.hpp Tue Mar 29 22:39:17 2016 +0000
@@ -49,6 +49,7 @@
do_klass(HotSpotJVMCIMetaAccessContext_klass, jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext, Jvmci) \
do_klass(HotSpotJVMCIRuntime_klass, jdk_vm_ci_hotspot_HotSpotJVMCIRuntime, Jvmci) \
do_klass(HotSpotSpeculationLog_klass, jdk_vm_ci_hotspot_HotSpotSpeculationLog, Jvmci) \
+ do_klass(HotSpotSymbol_klass, jdk_vm_ci_hotspot_HotSpotSymbol, Jvmci) \
do_klass(Assumptions_ConcreteMethod_klass, jdk_vm_ci_meta_Assumptions_ConcreteMethod, Jvmci) \
do_klass(Assumptions_NoFinalizableSubclass_klass, jdk_vm_ci_meta_Assumptions_NoFinalizableSubclass, Jvmci) \
do_klass(Assumptions_ConcreteSubtype_klass, jdk_vm_ci_meta_Assumptions_ConcreteSubtype, Jvmci) \
--- a/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/vmStructs_jvmci.cpp Tue Mar 29 22:39:17 2016 +0000
@@ -165,6 +165,7 @@
nonstatic_field(Klass, _super_check_offset, juint) \
nonstatic_field(Klass, _subklass, Klass*) \
nonstatic_field(Klass, _layout_helper, jint) \
+ nonstatic_field(Klass, _name, Symbol*) \
nonstatic_field(Klass, _prototype_header, markOop) \
nonstatic_field(Klass, _next_sibling, Klass*) \
nonstatic_field(Klass, _java_mirror, oop) \
@@ -551,8 +552,9 @@
declare_function(JVMCIRuntime::exception_handler_for_pc) \
declare_function(JVMCIRuntime::monitorenter) \
declare_function(JVMCIRuntime::monitorexit) \
- declare_function(JVMCIRuntime::create_null_exception) \
- declare_function(JVMCIRuntime::create_out_of_bounds_exception) \
+ declare_function(JVMCIRuntime::throw_and_post_jvmti_exception) \
+ declare_function(JVMCIRuntime::throw_klass_external_name_exception) \
+ declare_function(JVMCIRuntime::throw_class_cast_exception) \
declare_function(JVMCIRuntime::log_primitive) \
declare_function(JVMCIRuntime::log_object) \
declare_function(JVMCIRuntime::log_printf) \
--- a/hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/src/share/vm/jvmci/vmSymbols_jvmci.hpp Tue Mar 29 22:39:17 2016 +0000
@@ -50,6 +50,7 @@
template(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext, "jdk/vm/ci/hotspot/HotSpotJVMCIMetaAccessContext") \
template(jdk_vm_ci_hotspot_HotSpotJVMCIRuntime, "jdk/vm/ci/hotspot/HotSpotJVMCIRuntime") \
template(jdk_vm_ci_hotspot_HotSpotSpeculationLog, "jdk/vm/ci/hotspot/HotSpotSpeculationLog") \
+ template(jdk_vm_ci_hotspot_HotSpotSymbol, "jdk/vm/ci/hotspot/HotSpotSymbol") \
template(jdk_vm_ci_meta_JavaConstant, "jdk/vm/ci/meta/JavaConstant") \
template(jdk_vm_ci_meta_PrimitiveConstant, "jdk/vm/ci/meta/PrimitiveConstant") \
template(jdk_vm_ci_meta_RawConstant, "jdk/vm/ci/meta/RawConstant") \
--- a/hotspot/test/compiler/jvmci/code/DataPatchTest.java Wed Mar 30 00:25:39 2016 +0300
+++ b/hotspot/test/compiler/jvmci/code/DataPatchTest.java Tue Mar 29 22:39:17 2016 +0000
@@ -40,6 +40,8 @@
import jdk.vm.ci.code.Register;
import jdk.vm.ci.code.site.DataSectionReference;
import jdk.vm.ci.hotspot.HotSpotConstant;
+import jdk.vm.ci.hotspot.HotSpotMetaAccessProvider;
+import jdk.vm.ci.hotspot.HotSpotSymbol;
import jdk.vm.ci.hotspot.HotSpotVMConfig;
import jdk.vm.ci.meta.ResolvedJavaType;
@@ -155,4 +157,33 @@
asm.emitPointerRet(ret);
});
}
+
+
+ public static long getConstSymbol(HotSpotMetaAccessProvider meta) {
+ HotSpotSymbol symbol = meta.lookupSymbol("java/lang/Object");
+ return symbol.getMetaspacePointer();
+ }
+
+ private void testSymbol(TestCompiler compiler) {
+ test(compiler, getMethod("getConstSymbol", HotSpotMetaAccessProvider.class), (HotSpotMetaAccessProvider) metaAccess);
+ }
+
+ @Test
+ public void testInlineSymbol() {
+ testSymbol(asm -> {
+ HotSpotSymbol symbol = ((HotSpotMetaAccessProvider) metaAccess).lookupSymbol("java/lang/Object");
+ Register ret = asm.emitLoadPointer((HotSpotConstant) symbol.asConstant());
+ asm.emitPointerRet(ret);
+ });
+ }
+
+ @Test
+ public void testSymbolInDataSection() {
+ testSymbol(asm -> {
+ HotSpotSymbol symbol = ((HotSpotMetaAccessProvider) metaAccess).lookupSymbol("java/lang/Object");
+ DataSectionReference ref = asm.emitDataItem((HotSpotConstant) symbol.asConstant());
+ Register ret = asm.emitLoadPointer(ref);
+ asm.emitPointerRet(ret);
+ });
+ }
}