Skip to content

Instantly share code, notes, and snippets.

@nicksieger
Created April 7, 2010 03:30
Show Gist options
  • Save nicksieger/358484 to your computer and use it in GitHub Desktop.
Save nicksieger/358484 to your computer and use it in GitHub Desktop.
From nick@nicksieger.com Tue Apr 06 22:28:02 2010
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [PATCH] Add minimal bits to get coro patch to compile on Mac OSX SL
X-Mercurial-Node: 77819688cf2d743032bbadfad18f04f27158dccf
Message-Id: <77819688cf2d743032bb.1270610881@vanguard.local>
User-Agent: Mercurial-patchbomb/1.3.1
Date: Wed, 07 Apr 2010 03:28:01 -0000
From: Nick Sieger <nick@nicksieger.com>
To: mlvm-dev@openjdk.java.net
# HG changeset patch
# User Nick Sieger <nick@nicksieger.com>
# Date 1270610516 18000
# Node ID 77819688cf2d743032bbadfad18f04f27158dccf
# Parent 90fe8277ed0f7663d1fe2f5bc390287df5cd73c8
Add minimal bits to get coro patch to compile on Mac OSX SL
diff --git a/coro.patch b/coro.patch
--- a/coro.patch
+++ b/coro.patch
@@ -1,7 +1,7 @@
diff --git a/src/cpu/x86/vm/assembler_x86.hpp b/src/cpu/x86/vm/assembler_x86.hpp
--- a/src/cpu/x86/vm/assembler_x86.hpp
+++ b/src/cpu/x86/vm/assembler_x86.hpp
-@@ -653,7 +653,7 @@ private:
+@@ -653,7 +653,7 @@
// Instruction prefixes
@@ -13,7 +13,7 @@
diff --git a/src/cpu/x86/vm/frame_x86.cpp b/src/cpu/x86/vm/frame_x86.cpp
--- a/src/cpu/x86/vm/frame_x86.cpp
+++ b/src/cpu/x86/vm/frame_x86.cpp
-@@ -289,7 +289,8 @@ BasicObjectLock* frame::interpreter_fram
+@@ -289,7 +289,8 @@
}
BasicObjectLock* frame::interpreter_frame_monitor_end() const {
@@ -38,7 +38,7 @@
diff --git a/src/cpu/x86/vm/frame_x86.inline.hpp b/src/cpu/x86/vm/frame_x86.inline.hpp
--- a/src/cpu/x86/vm/frame_x86.inline.hpp
+++ b/src/cpu/x86/vm/frame_x86.inline.hpp
-@@ -33,6 +33,7 @@ inline frame::frame() {
+@@ -33,6 +33,7 @@
_fp = NULL;
_cb = NULL;
_deopt_state = unknown;
@@ -46,7 +46,7 @@
}
inline frame::frame(intptr_t* sp, intptr_t* fp, address pc) {
-@@ -50,6 +51,25 @@ inline frame::frame(intptr_t* sp, intptr
+@@ -50,6 +51,25 @@
} else {
_deopt_state = not_deoptimized;
}
@@ -72,7 +72,7 @@
}
inline frame::frame(intptr_t* sp, intptr_t* unextended_sp, intptr_t* fp, address pc) {
-@@ -68,6 +88,7 @@ inline frame::frame(intptr_t* sp, intptr
+@@ -68,6 +88,7 @@
} else {
_deopt_state = not_deoptimized;
}
@@ -80,7 +80,7 @@
}
inline frame::frame(intptr_t* sp, intptr_t* fp) {
-@@ -96,6 +117,7 @@ inline frame::frame(intptr_t* sp, intptr
+@@ -96,6 +117,7 @@
} else {
_deopt_state = not_deoptimized;
}
@@ -91,7 +91,7 @@
diff --git a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp
--- a/src/cpu/x86/vm/sharedRuntime_x86_32.cpp
+++ b/src/cpu/x86/vm/sharedRuntime_x86_32.cpp
-@@ -1182,6 +1182,9 @@ void SharedRuntime::restore_native_resul
+@@ -1182,6 +1182,9 @@
}
}
@@ -101,7 +101,7 @@
// ---------------------------------------------------------------------------
// Generate a native wrapper for a given method. The method takes arguments
// in the Java compiled code convention, marshals them to the native
-@@ -1366,6 +1369,18 @@ nmethod *SharedRuntime::generate_native_
+@@ -1366,6 +1369,18 @@
__ bind (slowCase);
}
#endif // COMPILER1
@@ -120,7 +120,7 @@
// The instruction at the verified entry point must be 5 bytes or longer
// because it can be patched on the fly by make_non_entrant. The stack bang
-@@ -3078,3 +3093,381 @@ void SharedRuntime::generate_stubs() {
+@@ -3078,3 +3093,381 @@
generate_uncommon_trap_blob();
#endif // COMPILER2
}
@@ -451,10 +451,10 @@
+ __ get_thread(rax);
+ // set new handle and resource areas
+ __ movptr(temp, Address(target_coroutine, Coroutine::handle_area_offset()));
-+ __ movptr(Address(target_coroutine, Coroutine::handle_area_offset()), NULL); // TODO is this really needed?
++ __ movptr(Address(target_coroutine, Coroutine::handle_area_offset()), (RegisterImpl*)NULL); // TODO is this really needed?
+ __ movptr(Address(thread, Thread::handle_area_offset()), temp);
+ __ movptr(temp, Address(target_coroutine, Coroutine::resource_area_offset()));
-+ __ movptr(Address(target_coroutine, Coroutine::resource_area_offset()), NULL); // TODO is this really needed?
++ __ movptr(Address(target_coroutine, Coroutine::resource_area_offset()), (RegisterImpl*)NULL); // TODO is this really needed?
+ __ movptr(Address(thread, Thread::resource_area_offset()), temp);
+
+ // update the thread's stack base and size
@@ -496,16 +496,16 @@
+ // slow case (terminate old coroutine)
+ __ get_thread(rax);
+ __ movptr(rcx, Address(rax, JavaThread::coroutine_temp_offset()));
-+ __ movptr(Address(rax, JavaThread::coroutine_temp_offset()), NULL);
-+ __ movptr(rdx, 0);
++ __ movptr(Address(rax, JavaThread::coroutine_temp_offset()), (RegisterImpl*)NULL);
++ __ movptr(rdx, (RegisterImpl*)NULL);
+
+ }
+ }
+}
-diff --git a/src/os_cpu/linux_x86/vm/threadLS_linux_x86.cpp b/src/os_cpu/linux_x86/vm/threadLS_linux_x86.cpp
---- a/src/os_cpu/linux_x86/vm/threadLS_linux_x86.cpp
-+++ b/src/os_cpu/linux_x86/vm/threadLS_linux_x86.cpp
-@@ -89,3 +89,26 @@ void ThreadLocalStorage::pd_set_thread(T
+diff --git a/src/os_cpu/bsd_x86/vm/threadLS_bsd_x86.cpp b/src/os_cpu/bsd_x86/vm/threadLS_bsd_x86.cpp
+--- a/src/os_cpu/bsd_x86/vm/threadLS_bsd_x86.cpp
++++ b/src/os_cpu/bsd_x86/vm/threadLS_bsd_x86.cpp
+@@ -89,3 +89,25 @@
}
#endif // !AMD64
}
@@ -531,11 +531,40 @@
+ }
+#endif // !AMD64
+}
+diff --git a/src/os_cpu/linux_x86/vm/threadLS_linux_x86.cpp b/src/os_cpu/linux_x86/vm/threadLS_linux_x86.cpp
+--- a/src/os_cpu/linux_x86/vm/threadLS_linux_x86.cpp
++++ b/src/os_cpu/linux_x86/vm/threadLS_linux_x86.cpp
+@@ -89,3 +89,26 @@
+ }
+ #endif // !AMD64
+ }
++
++void ThreadLocalStorage::pd_add_coroutine_stack(Thread* thread, address stack_base, size_t stack_size) {
++#ifndef AMD64
++ for (address p = stack_base - stack_size; p < stack_base; p += PAGE_SIZE) {
++ assert(thread == NULL || _sp_map[(uintptr_t)p >> PAGE_SHIFT] == NULL ||
++ thread == _sp_map[(uintptr_t)p >> PAGE_SHIFT],
++ "coroutine exited without detaching from VM??");
++ _sp_map[(uintptr_t)p >> PAGE_SHIFT] = thread;
++ }
++#endif // !AMD64
++}
++
++
++void ThreadLocalStorage::pd_remove_coroutine_stack(Thread* thread, address stack_base, size_t stack_size) {
++#ifndef AMD64
++ for (address p = stack_base - stack_size; p < stack_base; p += PAGE_SIZE) {
++ assert(thread == _sp_map[(uintptr_t)p >> PAGE_SHIFT],
++ "coroutine exited without detaching from VM??");
++ _sp_map[(uintptr_t)p >> PAGE_SHIFT] = NULL;
++ }
++#endif // !AMD64
++}
+
diff --git a/src/os_cpu/windows_x86/vm/threadLS_windows_x86.cpp b/src/os_cpu/windows_x86/vm/threadLS_windows_x86.cpp
--- a/src/os_cpu/windows_x86/vm/threadLS_windows_x86.cpp
+++ b/src/os_cpu/windows_x86/vm/threadLS_windows_x86.cpp
-@@ -46,3 +46,12 @@ void ThreadLocalStorage::pd_set_thread(T
+@@ -46,3 +46,12 @@
void ThreadLocalStorage::pd_set_thread(Thread* thread) {
os::thread_local_storage_at_put(ThreadLocalStorage::thread_index(), thread);
}
@@ -551,7 +580,7 @@
diff --git a/src/share/vm/classfile/javaClasses.cpp b/src/share/vm/classfile/javaClasses.cpp
--- a/src/share/vm/classfile/javaClasses.cpp
+++ b/src/share/vm/classfile/javaClasses.cpp
-@@ -2724,6 +2724,26 @@ void sun_misc_AtomicLongCSImpl::compute_
+@@ -2728,6 +2728,26 @@
}
}
@@ -578,7 +607,7 @@
void java_util_concurrent_locks_AbstractOwnableSynchronizer::initialize(TRAPS) {
if (_owner_offset != 0) return;
-@@ -2847,6 +2867,8 @@ void JavaClasses::compute_offsets() {
+@@ -2851,6 +2871,8 @@
// generated interpreter code wants to know about the offsets we just computed:
AbstractAssembler::update_delayed_values();
@@ -590,7 +619,7 @@
diff --git a/src/share/vm/classfile/javaClasses.hpp b/src/share/vm/classfile/javaClasses.hpp
--- a/src/share/vm/classfile/javaClasses.hpp
+++ b/src/share/vm/classfile/javaClasses.hpp
-@@ -1255,6 +1255,25 @@ class java_util_concurrent_locks_Abstrac
+@@ -1256,6 +1256,25 @@
static oop get_owner_threadObj(oop obj);
};
@@ -619,7 +648,7 @@
diff --git a/src/share/vm/classfile/systemDictionary.hpp b/src/share/vm/classfile/systemDictionary.hpp
--- a/src/share/vm/classfile/systemDictionary.hpp
+++ b/src/share/vm/classfile/systemDictionary.hpp
-@@ -170,6 +170,10 @@ class SymbolPropertyTable;
+@@ -171,6 +171,10 @@
template(Short_klass, java_lang_Short, Pre) \
template(Integer_klass, java_lang_Integer, Pre) \
template(Long_klass, java_lang_Long, Pre) \
@@ -633,7 +662,7 @@
diff --git a/src/share/vm/classfile/vmSymbols.hpp b/src/share/vm/classfile/vmSymbols.hpp
--- a/src/share/vm/classfile/vmSymbols.hpp
+++ b/src/share/vm/classfile/vmSymbols.hpp
-@@ -356,6 +356,7 @@
+@@ -365,6 +365,7 @@
template(void_float_signature, "()F") \
template(void_double_signature, "()D") \
template(int_void_signature, "(I)V") \
@@ -641,7 +670,7 @@
template(int_int_signature, "(I)I") \
template(int_bool_signature, "(I)Z") \
template(float_int_signature, "(F)I") \
-@@ -461,7 +462,7 @@
+@@ -471,7 +472,7 @@
template(createGarbageCollectorMBean_signature, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/management/GarbageCollectorMBean;") \
template(trigger_name, "trigger") \
template(clear_name, "clear") \
@@ -650,7 +679,7 @@
template(startAgent_name, "startAgent") \
template(java_lang_management_ThreadInfo_constructor_signature, "(Ljava/lang/Thread;ILjava/lang/Object;Ljava/lang/Thread;JJJJ[Ljava/lang/StackTraceElement;)V") \
template(java_lang_management_ThreadInfo_with_locks_constructor_signature, "(Ljava/lang/Thread;ILjava/lang/Object;Ljava/lang/Thread;JJJJ[Ljava/lang/StackTraceElement;[Ljava/lang/Object;[I[Ljava/lang/Object;)V") \
-@@ -479,7 +480,7 @@
+@@ -489,7 +490,7 @@
template(addThreadDumpForMonitors_name, "addThreadDumpForMonitors") \
template(addThreadDumpForSynchronizers_name, "addThreadDumpForSynchronizers") \
template(addThreadDumpForMonitors_signature, "(Ljava/lang/management/ThreadInfo;[Ljava/lang/Object;[I)V") \
@@ -659,7 +688,7 @@
\
/* JVMTI/java.lang.instrument support and VM Attach mechanism */ \
template(sun_misc_VMSupport, "sun/misc/VMSupport") \
-@@ -489,6 +490,16 @@
+@@ -499,6 +500,16 @@
template(serializePropertiesToByteArray_signature, "()[B") \
template(serializeAgentPropertiesToByteArray_name, "serializeAgentPropertiesToByteArray") \
template(classRedefinedCount_name, "classRedefinedCount") \
@@ -676,14 +705,14 @@
/*end*/
-@@ -825,8 +836,21 @@
+@@ -835,9 +846,22 @@
do_name( prefetchReadStatic_name, "prefetchReadStatic") \
do_intrinsic(_prefetchWriteStatic, sun_misc_Unsafe, prefetchWriteStatic_name, prefetch_signature, F_SN) \
do_name( prefetchWriteStatic_name, "prefetchWriteStatic") \
+ \
/*== LAST_COMPILER_INLINE*/ \
/*the compiler does have special inlining code for these; bytecode inline is just fine */ \
-+ \
+ \
+ /* coroutine intrinsics */ \
+ do_intrinsic(_prepareSwitch, java_dyn_CoroutineSupport, prepareSwitch_name, prepareSwitch_signature, F_SN) \
+ do_name( prepareSwitch_name, "prepareSwitch") \
@@ -695,13 +724,14 @@
+ do_name( switchToAndTerminate_name, "switchToAndTerminate") \
+ do_intrinsic(_switchToAndExit, java_dyn_CoroutineSupport, switchToAndExit_name, switchTo_signature, F_SN) \
+ do_name( switchToAndExit_name, "switchToAndExit") \
- \
++ \
do_intrinsic(_fillInStackTrace, java_lang_Throwable, fillInStackTrace_name, void_throwable_signature, F_RNY) \
\
+ do_intrinsic(_StringBuilder_void, java_lang_StringBuilder, object_initializer_name, void_method_signature, F_R) \
diff --git a/src/share/vm/gc_implementation/includeDB_gc_g1 b/src/share/vm/gc_implementation/includeDB_gc_g1
--- a/src/share/vm/gc_implementation/includeDB_gc_g1
+++ b/src/share/vm/gc_implementation/includeDB_gc_g1
-@@ -323,7 +323,7 @@ ptrQueue.hpp
+@@ -323,7 +323,7 @@
ptrQueue.hpp allocation.hpp
ptrQueue.hpp sizes.hpp
@@ -713,11 +743,10 @@
diff --git a/src/share/vm/includeDB_core b/src/share/vm/includeDB_core
--- a/src/share/vm/includeDB_core
+++ b/src/share/vm/includeDB_core
-@@ -1300,6 +1300,14 @@ copy_<arch>.hpp
- copy_<arch>.hpp generate_platform_dependent_include
+@@ -1302,6 +1302,14 @@
copy_<os_arch>.inline.hpp generate_platform_dependent_include
-+
+
+coroutine.cpp coroutine.hpp
+
+coroutine.hpp jniHandles.hpp
@@ -725,10 +754,11 @@
+coroutine.hpp resourceArea.hpp
+coroutine.hpp javaFrameAnchor.hpp
+coroutine.hpp monitorChunk.hpp
-
++
cpCacheKlass.cpp bytecodes.hpp
cpCacheKlass.cpp collectedHeap.hpp
-@@ -4181,6 +4189,7 @@ thread.cpp
+ cpCacheKlass.cpp constantPoolOop.hpp
+@@ -4185,6 +4193,7 @@
thread.cpp attachListener.hpp
thread.cpp biasedLocking.hpp
thread.cpp classLoader.hpp
@@ -736,7 +766,7 @@
thread.cpp compileBroker.hpp
thread.cpp defaultStream.hpp
thread.cpp deoptimization.hpp
-@@ -4447,6 +4456,7 @@ universe.inline.hpp
+@@ -4451,6 +4460,7 @@
unsafe.cpp allocation.inline.hpp
unsafe.cpp copy.hpp
@@ -747,7 +777,7 @@
diff --git a/src/share/vm/prims/jni.cpp b/src/share/vm/prims/jni.cpp
--- a/src/share/vm/prims/jni.cpp
+++ b/src/share/vm/prims/jni.cpp
-@@ -3401,6 +3401,7 @@ static jint attach_current_thread(JavaVM
+@@ -3401,6 +3401,7 @@
thread->set_thread_state(_thread_in_vm);
// Must do this before initialize_thread_local_storage
thread->record_stack_base_and_size();
@@ -758,7 +788,7 @@
diff --git a/src/share/vm/prims/nativeLookup.cpp b/src/share/vm/prims/nativeLookup.cpp
--- a/src/share/vm/prims/nativeLookup.cpp
+++ b/src/share/vm/prims/nativeLookup.cpp
-@@ -77,6 +77,7 @@ char* NativeLookup::long_jni_name(method
+@@ -77,6 +77,7 @@
}
extern "C" {
@@ -766,20 +796,20 @@
void JNICALL JVM_RegisterUnsafeMethods(JNIEnv *env, jclass unsafecls);
void JNICALL JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass unsafecls);
void JNICALL JVM_RegisterPerfMethods(JNIEnv *env, jclass perfclass);
-@@ -94,6 +95,9 @@ static address lookup_special_native(cha
- if (strstr(jni_name, "Java_java_io_ObjectInputStream_setPrimitiveFieldValues") != NULL) {
+@@ -95,6 +96,9 @@
return CAST_FROM_FN_PTR(address, JVM_SetPrimitiveFieldValues);
}
-+ }
+ }
+ if (strstr(jni_name, "Java_java_dyn_CoroutineSupport_registerNatives") != NULL) {
+ return CAST_FROM_FN_PTR(address, JVM_RegisterCoroutineSupportMethods);
- }
++ }
if (strstr(jni_name, "Java_sun_misc_Unsafe_registerNatives") != NULL) {
return CAST_FROM_FN_PTR(address, JVM_RegisterUnsafeMethods);
+ }
diff --git a/src/share/vm/prims/unsafe.cpp b/src/share/vm/prims/unsafe.cpp
--- a/src/share/vm/prims/unsafe.cpp
+++ b/src/share/vm/prims/unsafe.cpp
-@@ -1162,6 +1162,172 @@ UNSAFE_ENTRY(void, Unsafe_PrefetchWrite(
+@@ -1162,6 +1162,172 @@
Prefetch::write(addr, (intx)offset);
UNSAFE_END
@@ -889,7 +919,7 @@
+ Coroutine* coro = (Coroutine*)java_dyn_CoroutineBase::data(old_oop);
+ assert(coro != NULL, "NULL old coroutine in switchToAndTerminate");
+
-+ java_dyn_CoroutineBase::set_data(old_oop, NULL);
++ java_dyn_CoroutineBase::set_data(old_oop, 0);
+
+ coro->remove_from_list(THREAD->coroutine_list());
+ Coroutine::free_coroutine(coro);
@@ -952,7 +982,7 @@
/// JVM_RegisterUnsafeMethods
-@@ -1457,6 +1623,27 @@ JNINativeMethod anonk_methods[] = {
+@@ -1457,6 +1623,27 @@
{CC"defineAnonymousClass", CC"("DAC_Args")"CLS, FN_PTR(Unsafe_DefineAnonymousClass)},
};
@@ -980,7 +1010,7 @@
#undef CC
#undef FN_PTR
-@@ -1555,3 +1742,28 @@ JVM_ENTRY(void, JVM_RegisterUnsafeMethod
+@@ -1555,3 +1742,28 @@
guarantee(status == 0, "register unsafe natives");
}
JVM_END
@@ -1013,7 +1043,7 @@
new file mode 100644
--- /dev/null
+++ b/src/share/vm/runtime/coroutine.cpp
-@@ -0,0 +1,386 @@
+@@ -0,0 +1,383 @@
+/*
+ * Copyright 2001-2010 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -1088,10 +1118,7 @@
+
+ ShouldNotReachHere();
+}
-+#endif
-+
-+#ifdef LINUX
-+
++#else
+void coroutine_start(Coroutine* coroutine, jobject coroutineObj) {
+ coroutine->thread()->set_thread_state(_thread_in_vm);
+
@@ -1235,12 +1262,12 @@
+
+ int capacity = data->capacity();
+ int size = 0;
-+ data->data()[capacity - ++size] = NULL;
++ data->data()[capacity - ++size] = (intptr_t)NULL;
+ data->data()[capacity - ++size] = (intptr_t)JNIHandles::make_global(coroutineObj);
+ data->data()[capacity - ++size] = (intptr_t)coro;
-+ data->data()[capacity - ++size] = NULL;
++ data->data()[capacity - ++size] = (intptr_t)NULL;
+ data->data()[capacity - ++size] = (intptr_t)coroutine_start;
-+ data->data()[capacity - ++size] = NULL;
++ data->data()[capacity - ++size] = (intptr_t)NULL;
+ data->set_size(size);
+
+ coro->_state = _stored;
@@ -1643,7 +1670,7 @@
diff --git a/src/share/vm/runtime/frame.cpp b/src/share/vm/runtime/frame.cpp
--- a/src/share/vm/runtime/frame.cpp
+++ b/src/share/vm/runtime/frame.cpp
-@@ -465,17 +465,17 @@ BasicObjectLock* frame::previous_monitor
+@@ -465,17 +465,17 @@
intptr_t* frame::interpreter_frame_local_at(int index) const {
const int n = Interpreter::local_offset_in_bytes(index)/wordSize;
@@ -1664,7 +1691,7 @@
}
intptr_t* frame::interpreter_frame_expression_stack_at(jint offset) const {
-@@ -1411,3 +1411,8 @@ StackFrameStream::StackFrameStream(JavaT
+@@ -1411,3 +1411,8 @@
_fr = thread->last_frame();
_is_done = false;
}
@@ -1676,16 +1703,16 @@
diff --git a/src/share/vm/runtime/frame.hpp b/src/share/vm/runtime/frame.hpp
--- a/src/share/vm/runtime/frame.hpp
+++ b/src/share/vm/runtime/frame.hpp
-@@ -47,6 +47,8 @@ class frame VALUE_OBJ_CLASS_SPEC {
- };
+@@ -48,6 +48,8 @@
deopt_state _deopt_state;
+
++ intptr_t _displacement;
+
-+ intptr_t _displacement;
-
public:
// Constructors
-@@ -462,6 +464,7 @@ class StackFrameStream : public StackObj
+ frame();
+@@ -462,6 +464,7 @@
bool _is_done;
public:
StackFrameStream(JavaThread *thread, bool update = true);
@@ -1696,7 +1723,7 @@
diff --git a/src/share/vm/runtime/globals.hpp b/src/share/vm/runtime/globals.hpp
--- a/src/share/vm/runtime/globals.hpp
+++ b/src/share/vm/runtime/globals.hpp
-@@ -3516,7 +3516,13 @@ class CommandLineFlags {
+@@ -3516,7 +3516,13 @@
product(bool, UseVMInterruptibleIO, false, \
"(Unstable, Solaris-specific) Thread interrupt before or with " \
"EINTR for I/O operations results in OS_INTRPT. The default value"\
@@ -1714,7 +1741,7 @@
diff --git a/src/share/vm/runtime/handles.hpp b/src/share/vm/runtime/handles.hpp
--- a/src/share/vm/runtime/handles.hpp
+++ b/src/share/vm/runtime/handles.hpp
-@@ -250,6 +250,11 @@ class HandleArea: public Arena {
+@@ -250,6 +250,11 @@
debug_only(_no_handle_mark_nesting = 0);
_prev = prev;
}
@@ -1729,7 +1756,7 @@
diff --git a/src/share/vm/runtime/thread.cpp b/src/share/vm/runtime/thread.cpp
--- a/src/share/vm/runtime/thread.cpp
+++ b/src/share/vm/runtime/thread.cpp
-@@ -1178,6 +1178,10 @@ void JavaThread::initialize() {
+@@ -1178,6 +1178,10 @@
_interp_only_mode = 0;
_special_runtime_exit_condition = _no_async_condition;
_pending_async_exception = NULL;
@@ -1740,16 +1767,16 @@
_is_compiling = false;
_thread_stat = NULL;
_thread_stat = new ThreadStatistics();
-@@ -1356,6 +1360,8 @@ void JavaThread::run() {
-
+@@ -1357,6 +1361,8 @@
// Record real stack base and size.
this->record_stack_base_and_size();
+
++ this->initialize_coroutine_support();
+
-+ this->initialize_coroutine_support();
-
// Initialize thread local storage; set before calling MutexLocker
this->initialize_thread_local_storage();
-@@ -2396,6 +2402,13 @@ void JavaThread::oops_do(OopClosure* f,
+
+@@ -2396,6 +2402,13 @@
fst.current()->oops_do(f, cf, fst.register_map());
}
}
@@ -1763,7 +1790,7 @@
// callee_target is never live across a gc point so NULL it here should
// it still contain a methdOop.
-@@ -2437,6 +2450,13 @@ void JavaThread::nmethods_do(CodeBlobClo
+@@ -2437,6 +2450,13 @@
fst.current()->nmethods_do(cf);
}
}
@@ -1777,7 +1804,7 @@
}
// Printing
-@@ -2922,6 +2942,7 @@ jint Threads::create_vm(JavaVMInitArgs*
+@@ -2922,6 +2942,7 @@
// stacksize. This adjusted size is what is used to figure the placement
// of the guard pages.
main_thread->record_stack_base_and_size();
@@ -1785,7 +1812,7 @@
main_thread->initialize_thread_local_storage();
main_thread->set_active_handles(JNIHandleBlock::allocate_block());
-@@ -4103,3 +4124,9 @@ void Threads::verify() {
+@@ -4103,3 +4124,9 @@
VMThread* thread = VMThread::vm_thread();
if (thread != NULL) thread->verify();
}
@@ -1798,17 +1825,17 @@
diff --git a/src/share/vm/runtime/thread.hpp b/src/share/vm/runtime/thread.hpp
--- a/src/share/vm/runtime/thread.hpp
+++ b/src/share/vm/runtime/thread.hpp
-@@ -45,6 +45,9 @@ class GCTaskQueue;
- class GCTaskQueue;
+@@ -46,6 +46,9 @@
class ThreadClosure;
class IdealGraphPrinter;
-+
+
+class Coroutine;
+class CoroutineStack;
-
++
// Class hierarchy
// - Thread
-@@ -486,6 +489,9 @@ public:
+ // - NamedThread
+@@ -486,6 +489,9 @@
void leaving_jvmti_env_iteration() { --_jvmti_env_iteration_count; }
bool is_inside_jvmti_env_iteration() { return _jvmti_env_iteration_count > 0; }
@@ -1818,11 +1845,10 @@
// Code generation
static ByteSize exception_file_offset() { return byte_offset_of(Thread, _exception_file ); }
static ByteSize exception_line_offset() { return byte_offset_of(Thread, _exception_line ); }
-@@ -786,6 +792,22 @@ class JavaThread: public Thread {
- // JVMTI PopFrame support
+@@ -787,6 +793,22 @@
// This is set to popframe_pending to signal that top Java frame should be popped immediately
int _popframe_condition;
-+
+
+ // coroutine support
+ CoroutineStack* _coroutine_stack_list;
+ Coroutine* _coroutine_list;
@@ -1838,13 +1864,14 @@
+ void initialize_coroutine_support();
+
+ private:
-
++
#ifndef PRODUCT
int _jmp_ring_index;
+ struct {
diff --git a/src/share/vm/runtime/threadLocalStorage.cpp b/src/share/vm/runtime/threadLocalStorage.cpp
--- a/src/share/vm/runtime/threadLocalStorage.cpp
+++ b/src/share/vm/runtime/threadLocalStorage.cpp
-@@ -41,6 +41,14 @@ void ThreadLocalStorage::set_thread(Thre
+@@ -41,6 +41,14 @@
guarantee(get_thread_slow() == thread, "must be the same thread, slowly");
}
@@ -1862,7 +1889,7 @@
diff --git a/src/share/vm/runtime/threadLocalStorage.hpp b/src/share/vm/runtime/threadLocalStorage.hpp
--- a/src/share/vm/runtime/threadLocalStorage.hpp
+++ b/src/share/vm/runtime/threadLocalStorage.hpp
-@@ -36,6 +36,9 @@ class ThreadLocalStorage : AllStatic {
+@@ -36,6 +36,9 @@
static Thread* get_thread_slow();
static void invalidate_all() { pd_invalidate_all(); }
@@ -1872,7 +1899,7 @@
// Machine dependent stuff
#include "incls/_threadLS_pd.hpp.incl"
-@@ -57,6 +60,10 @@ class ThreadLocalStorage : AllStatic {
+@@ -57,6 +60,10 @@
// Processor dependent parts of set_thread and initialization
static void pd_set_thread(Thread* thread);
static void pd_init();
import java.dyn.Coroutine;
import static java.dyn.Coroutine.yield;
public class CoroutineTest1 extends Coroutine {
@Override
public void run() {
System.out.println("Coroutine.run");
}
public static void main(String[] args) {
new CoroutineTest1();
System.out.println("main start");
yield();
System.out.println("main end");
}
}
#
# A fatal error has been detected by the Java Runtime Environment:
#
# Internal Error (/Users/nicksieger/Projects/openjdk/bsd-port/hotspot/src/share/vm/prims/unsafe.cpp:1265), pid=19235, tid=2953121792
# Error: assert(target_coroutine == __null,"expecting NULL")
#
# JRE version: 7.0
# Java VM: OpenJDK Server VM (17.0-b10-jvmg mixed mode bsd-x86 )
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
--------------- T H R E A D ---------------
Current thread (0x06015000): JavaThread "main" [_thread_in_native, id=-1341845504, stack(0xb0001000,0xb0051000)]
Stack: [0xb0001000,0xb0051000], sp=0xb0050740, free space=13db0051000k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.dylib+0x1c972]
V [libjvm.dylib+0x1de68]
V [libjvm.dylib+0xe08e]
V [libjvm.dylib+0x926848]
J java.dyn.CoroutineSupport.switchToAndTerminate(Ljava/dyn/CoroutineBase;Ljava/dyn/CoroutineBase;)V
j java.dyn.CoroutineSupport.coYieldInternal()V+82
j java.dyn.Coroutine.yield()V+6
j CoroutineTest1.main([Ljava/lang/String;)V+16
v ~StubRoutines::call_stub
V [libjvm.dylib+0x551a28]
V [libjvm.dylib+0x797a67]
V [libjvm.dylib+0x5508a7]
V [libjvm.dylib+0x565d0a]
V [libjvm.dylib+0x57bcbf]
C [java+0x194e] JavaMain+0x3b9
C [libSystem.B.dylib+0x2dfbd] _pthread_start+0x159
C [libSystem.B.dylib+0x2de42] thread_start+0x22
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
J java.dyn.CoroutineSupport.switchToAndTerminate(Ljava/dyn/CoroutineBase;Ljava/dyn/CoroutineBase;)V
j java.dyn.CoroutineSupport.coYieldInternal()V+82
j java.dyn.Coroutine.yield()V+6
j CoroutineTest1.main([Ljava/lang/String;)V+16
v ~StubRoutines::call_stub
--------------- P R O C E S S ---------------
Java Threads: ( => current thread )
0x00811800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=-1338904576, stack(0xb02cf000,0xb031f000)]
0x00810400 JavaThread "CompilerThread1" daemon [_thread_blocked, id=-1339240448, stack(0xb024d000,0xb02cd000)]
0x0080f000 JavaThread "CompilerThread0" daemon [_thread_blocked, id=-1339772928, stack(0xb01cb000,0xb024b000)]
0x0080dc00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=-1340305408, stack(0xb0179000,0xb01c9000)]
0x06052c00 JavaThread "Finalizer" daemon [_thread_blocked, id=-1340641280, stack(0xb0127000,0xb0177000)]
0x06051800 JavaThread "Reference Handler" daemon [_thread_blocked, id=-1340977152, stack(0xb00d5000,0xb0125000)]
=>0x06015000 JavaThread "main" [_thread_in_native, id=-1341845504, stack(0xb0001000,0xb0051000)]
Other Threads:
0x06017000 VMThread [stack: 0xb0053000,0xb00d3000] [id=-1341313024]
0x00813400 WatcherThread [stack: 0xb0321000,0xb03a1000] [id=-1338372096]
VM state:not at safepoint (normal execution)
VM Mutex/Monitor currently owned by a thread: None
Heap
def new generation total 6528K, used 327K [0x09800000, 0x09f10000, 0x10950000)
eden space 5824K, 5% used [0x09800000, 0x09851dd8, 0x09db0000)
from space 704K, 0% used [0x09db0000, 0x09db0000, 0x09e60000)
to space 704K, 0% used [0x09e60000, 0x09e60000, 0x09f10000)
tenured generation total 14528K, used 0K [0x10950000, 0x11780000, 0x1ec00000)
the space 14528K, 0% used [0x10950000, 0x10950000, 0x10950200, 0x11780000)
compacting perm gen total 16384K, used 1879K [0x1ec00000, 0x1fc00000, 0x22c00000)
the space 16384K, 11% used [0x1ec00000, 0x1edd5c60, 0x1edd5e00, 0x1fc00000)
No shared spaces configured.
Dynamic libraries:
0x00000000 /usr/lib/libSystem.B.dylib
0x00000000 /usr/lib/system/libmathCommon.A.dylib
0x01000000 /Users/nicksieger/Projects/openjdk/bsd-port/build/bsd-i586/j2sdk-image/jre/lib/i386/server/libjvm.dylib
0x00000000 /usr/lib/libstdc++.6.dylib
0x00039000 /Users/nicksieger/Projects/openjdk/bsd-port/build/bsd-i586/j2sdk-image/jre/lib/i386/libverify.dylib
0x0004a000 /Users/nicksieger/Projects/openjdk/bsd-port/build/bsd-i586/j2sdk-image/jre/lib/i386/libjava.dylib
0x00086000 /Users/nicksieger/Projects/openjdk/bsd-port/build/bsd-i586/j2sdk-image/jre/lib/i386/native_threads/libhpi.dylib
0x0009d000 /Users/nicksieger/Projects/openjdk/bsd-port/build/bsd-i586/j2sdk-image/jre/lib/i386/libzip.dylib
VM Arguments:
java_command: CoroutineTest1
Launcher Type: SUN_STANDARD
Environment Variables:
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.7.0/Home
PATH=/System/Library/Frameworks/JavaVM.framework/Versions/1.7.0/Home/bin:/usr/local/pgsql/bin:/usr/local/mysql/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/sbin:/opt/local/bin:/Users/nicksieger/.gem/ruby/1.8/bin:/Users/nicksieger/bin
SHELL=/bin/bash
DISPLAY=/tmp/launch-GsWyWs/:0
Signal Handlers:
SIGSEGV: [libjvm.dylib+0x94ce70], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGBUS: [libjvm.dylib+0x94ce70], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGFPE: [libjvm.dylib+0x79621e], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGPIPE: [libjvm.dylib+0x79621e], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGXFSZ: [libjvm.dylib+0x79621e], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGILL: [libjvm.dylib+0x79621e], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGUSR1: SIG_DFL, sa_mask[0]=0x63807efb, sa_flags=0x00000000
SIGUSR2: [libjvm.dylib+0x795c5a], sa_mask[0]=0x00000000, sa_flags=0x00000042
SIGHUP: [libjvm.dylib+0x7948cc], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGINT: [libjvm.dylib+0x7948cc], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGTERM: [libjvm.dylib+0x7948cc], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGQUIT: [libjvm.dylib+0x7948cc], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
--------------- S Y S T E M ---------------
OS:Bsd
uname:Darwin 10.2.0 Darwin Kernel Version 10.2.0: Tue Nov 3 10:37:10 PST 2009; root:xnu-1486.2.11~1/RELEASE_I386 i386
rlimit: STACK 8192k, CORE 0k, NPROC 266, NOFILE 10240
CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 23 stepping 10, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1
Memory: 4k page, physical 1392300k(348075k free)
vm_info: OpenJDK Server VM (17.0-b10-jvmg) for bsd-x86 JRE (1.7.0-internal-debug-nicksieger_2010_04_06_21_46-b00), built on Apr 6 2010 21:51:46 by "nicksieger" with gcc 4.0.1 (Apple Inc. build 5493)
time: Tue Apr 6 22:13:22 2010
elapsed time: 0 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment