You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gs...@apache.org on 2006/11/14 17:35:28 UTC
svn commit: r474860 - in /incubator/harmony/enhanced/drlvm/trunk:
build/make/components/ build/make/components/vm/ build/make/targets/
vm/gc_cc/src/ vm/include/open/ vm/interpreter/src/ vm/port/src/lil/ipf/pim/
vm/vmcore/include/ vm/vmcore/src/class_su...
Author: gshimansky
Date: Tue Nov 14 08:35:26 2006
New Revision: 474860
URL: http://svn.apache.org/viewvc?view=rev&rev=474860
Log:
Applied HARMONY-2004 [DRLVM] IPF support in interpreter mode, 'Hello World' stage
Tests passed on win32 and ubuntu. Many tests on x86_64 passed too.
Modified:
incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm.xml
incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/encoder.xml
incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/jitrino.xml
incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/jthread.xml
incubator/harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml
incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/include/open/thread_externals.h
incubator/harmony/enhanced/drlvm/trunk/vm/include/open/thread_helpers.h
incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ipf.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ipf/pim/m2n_ipf.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ipf/pim/stack_iterator_ipf.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/String_Pool.h
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_break_intf.h
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break_intf.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_dasm.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_step.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/compile_ipf.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/exceptions_ipf.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/ini_ipf.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/native_stack_ipf.cpp
incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp
Modified: incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm.xml?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm.xml (original)
+++ incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm.xml Tue Nov 14 08:35:26 2006
@@ -48,7 +48,6 @@
vm.gc_cc,
vm.interpreter,
vm.hythr,
- vm.jitrino,
vm.kernel_classes" />
</select>
Modified: incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/encoder.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/encoder.xml?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/encoder.xml (original)
+++ incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/encoder.xml Tue Nov 14 08:35:26 2006
@@ -44,7 +44,7 @@
<include name="ia32_em64t/*.cpp" />
</select>
<select arch="ipf">
- <include name="ia32_em64t/*.cpp" />
+ <include name="ipf/*.cpp" />
</select>
</fileset>
</compiler>
Modified: incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/jitrino.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/jitrino.xml?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/jitrino.xml (original)
+++ incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/jitrino.xml Tue Nov 14 08:35:26 2006
@@ -26,6 +26,7 @@
<project name="vm.jitrino">
<target name="init">
+ <select arch="ia32,em64t">
<property name="build.depends" value="extra.apr,vm.vmcore,vm.encoder,vm.hythr" />
<property name="outtype" value="shared" />
<property name="libname" value="jitrino" />
@@ -342,5 +343,6 @@
<include name="${build.arch}/**" />
</fileset>
</copy>
+ </select>
</target>
</project>
Modified: incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/jthread.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/jthread.xml?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/jthread.xml (original)
+++ incubator/harmony/enhanced/drlvm/trunk/build/make/components/vm/jthread.xml Tue Nov 14 08:35:26 2006
@@ -46,6 +46,7 @@
<fileset dir="${src}">
<include name="thread/src/*java*.c" />
<include name="thread/src/thread_ti_*.c" />
+ <include name="thread/src/*_${build.arch}.c" />
</fileset>
<select os="win" cfg="release" cxx="icl">
Modified: incubator/harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml (original)
+++ incubator/harmony/enhanced/drlvm/trunk/build/make/targets/common_vm.xml Tue Nov 14 08:35:26 2006
@@ -54,6 +54,7 @@
<select arch="ipf">
<defineset define="_IPF_" />
<defineset define="POINTER64" />
+ <defineset define="HYIA64" />
</select>
<select arch="em64t">
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/gc_cc/src/init.cpp Tue Nov 14 08:35:26 2006
@@ -207,13 +207,15 @@
* to find some of bad pointers. */
size_t four_gig = 4 * 1024 * (size_t) 1024 * 1024;
size_t padding = 4 * 1024 * (size_t) 1024 * 1024;
- void *addr = mmap(0, padding + four_gig, PROT_READ | PROT_WRITE,
+ four_gig = 0;
+ padding = 0;
+ void *addr = mmap(0, padding + max_heap_size + four_gig, PROT_READ | PROT_WRITE,
MAP_NORESERVE | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
assert(addr != MAP_FAILED);
UNUSED int err = mprotect((Ptr)addr, padding, PROT_NONE);
assert(!err);
err = mprotect((Ptr)addr + padding + max_heap_size,
- four_gig - max_heap_size, PROT_NONE);
+ four_gig, PROT_NONE);
assert(!err);
return (Ptr)addr + padding;
#else
@@ -234,6 +236,7 @@
INFO("max heap size " << mb(max_heap_size) << " mb");
heap_base = 0;
+
heap_base = NULL;
if (lp_hint) {
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/include/open/thread_externals.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/include/open/thread_externals.h?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/include/open/thread_externals.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/include/open/thread_externals.h Tue Nov 14 08:35:26 2006
@@ -121,14 +121,6 @@
#ifdef __cplusplus
}
-
-/**
- * all folowing entries is requiried for VM helpers only
- */
-
-#include "encoder.h"
-
-
#endif
#endif /* OPEN_THREAD_EXTERNALS_H */
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/include/open/thread_helpers.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/include/open/thread_helpers.h?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/include/open/thread_helpers.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/include/open/thread_helpers.h Tue Nov 14 08:35:26 2006
@@ -31,16 +31,21 @@
#include "open/types.h"
#include "open/hythread_ext.h"
-#include "encoder.h"
+
+typedef void * fast_tls_func();
#ifdef __cplusplus
-extern "C" {
+extern "C"
#endif /* __cplusplus */
+fast_tls_func* get_tls_helper(hythread_tls_key_t key);
+#if (defined _IA32_) || (defined _EM64T_)
-typedef void * fast_tls_func();
+#include "encoder.h"
-fast_tls_func* get_tls_helper(hythread_tls_key_t key);
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
char* gen_hythread_self_helper(char *ss);
char* gen_monitorenter_fast_path_helper(char *ss, const R_Opnd & input_param1);
char* gen_monitorenter_slow_path_helper(char *ss, const R_Opnd & input_param1);
@@ -50,5 +55,7 @@
#ifdef __cplusplus
}
#endif
+
+#endif /* (defined _IA32_) || (defined _EM64T_) */
#endif /* OPEN_THREAD_NATIVE_H */
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ipf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ipf.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ipf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/interpreter/src/interp_native_ipf.cpp Tue Nov 14 08:35:26 2006
@@ -27,6 +27,7 @@
#include "interp_native.h"
#include "interp_defs.h"
#include "ini.h"
+#include "open/jthread.h"
@@ -75,7 +76,7 @@
assert(!hythread_is_suspend_enabled());
DEBUG_TRACE("\n<<< interpreter_invoke_native: "
- << method->get_class()->name->bytes << " "
+ << method->get_class()->get_name()->bytes << " "
<< method->get_name()->bytes
<< method->get_descriptor()->bytes << endl);
@@ -101,7 +102,7 @@
jobject _this;
if (method->is_static()) {
- _this = (jobject) method->get_class()->class_handle;
+ _this = (jobject) method->get_class()->get_class_handle();
} else {
_this = args[pos++].l;
}
@@ -263,12 +264,12 @@
interpreterInvokeStaticNative(StackFrame& prevFrame, StackFrame& frame, Method *method) {
DEBUG_TRACE("\n<<< native_invoke_static : "
- << method->get_class()->name->bytes << " "
+ << method->get_class()->get_name()->bytes << " "
<< method->get_name()->bytes
<< method->get_descriptor()->bytes << endl);
DEBUG_TRACE_PLAIN("interpreter static native: "
- << frame.method->get_class()->name->bytes
+ << frame.method->get_class()->get_name()->bytes
<< " " << frame.method->get_name()->bytes
<< frame.method->get_descriptor()->bytes << endl);
@@ -280,7 +281,7 @@
M2N_ALLOC_MACRO;
- frame.This = *(method->get_class()->class_handle);
+ frame.This = *(method->get_class()->get_class_handle());
int sz = method->get_num_arg_bytes() >> 2;
uword *args = (uword*) ALLOC_FRAME((sz + 2) * sizeof(uword));
uword fpargs[6 + 1/* for fptypes */];
@@ -416,7 +417,7 @@
DEBUG2(
"VM WARNING: Reference with null value returned from jni function:\n"
"VM WARNING: Method name: "
- << method->get_class()->name->bytes
+ << method->get_class()->get_name()->bytes
<< "/" << method->get_name()->bytes
<< method->get_descriptor()->bytes <<
"\nVM WARNING: Not allowed, return NULL (0) instead\n");
@@ -540,12 +541,12 @@
assert(!method->is_static());
DEBUG_TRACE_PLAIN("interpreter virtual native: "
- << frame.method->get_class()->name->bytes
+ << frame.method->get_class()->get_name()->bytes
<< " " << frame.method->get_name()->bytes
<< frame.method->get_descriptor()->bytes << endl);
DEBUG_TRACE("\n<<< native_invoke_virtual: "
- << method->get_class()->name->bytes << " "
+ << method->get_class()->get_name()->bytes << " "
<< method->get_name()->bytes
<< method->get_descriptor()->bytes << endl);
@@ -690,7 +691,7 @@
DEBUG2(
"VM WARNING: Reference with null value returned from jni function:\n"
"VM WARNING: Method name: "
- << method->get_class()->name->bytes
+ << method->get_class()->get_name()->bytes
<< "/" << method->get_name()->bytes
<< method->get_descriptor()->bytes <<
"\nVM WARNING: Not allowed, return NULL (0) instead\n");
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ipf/pim/m2n_ipf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ipf/pim/m2n_ipf.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ipf/pim/m2n_ipf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ipf/pim/m2n_ipf.cpp Tue Nov 14 08:35:26 2006
@@ -87,22 +87,31 @@
memset(m2n, 0, sizeof(M2nFrame));
}
+VMEXPORT // temporary solution for interpreter unplug
M2nFrame* m2n_get_last_frame()
{
return p_TLS_vmthread->last_m2n_frame;
}
+VMEXPORT // temporary solution for interpreter unplug
M2nFrame* m2n_get_last_frame(VM_thread* thread)
{
return thread->last_m2n_frame;
}
+VMEXPORT // temporary solution for interpreter unplug
void m2n_set_last_frame(M2nFrame* lm2nf)
{
- assert(!hythread_is_suspend_enabled());
p_TLS_vmthread->last_m2n_frame = lm2nf;
}
+VMEXPORT
+void m2n_set_last_frame(VM_thread* thread, M2nFrame* lm2nf)
+{
+ thread->last_m2n_frame = lm2nf;
+}
+
+VMEXPORT // temporary solution for interpreter unplug
M2nFrame* m2n_get_previous_frame(M2nFrame* m2nfl)
{
assert(m2nfl);
@@ -139,7 +148,22 @@
{
assert(lm2nf);
ABORT("Not implemented");
-}
+}
+
+// sets pointer to the registers used for jvmti PopFrame
+void set_pop_frame_registers(M2nFrame* m2nf, Registers* regs) {
+ // FIXME: not sure we want to support this function on IPF
+ assert(0);
+ abort();
+}
+
+// returns pointer to the registers used for jvmti PopFrame
+Registers* get_pop_frame_registers(M2nFrame* m2nf) {
+ // FIXME: not sure we want to support this function on IPF
+ assert(0);
+ abort();
+ return 0;
+}
Method_Handle m2n_get_method(M2nFrame* m2nf)
{
@@ -343,3 +367,41 @@
else
return ((uint64*)*get_stacked_register_address(m2n_get_bsp(m2nf), M2N_SAVED_SP))+(n-8+2); // +2 is for 16-bytes scratch on mem stack
}
+
+void m2n_push_suspended_frame(M2nFrame* m2nf, Registers* regs)
+{
+ abort(); // FIXME: check that it works
+ m2n_push_suspended_frame(p_TLS_vmthread, m2nf, regs);
+}
+
+void m2n_push_suspended_frame(VM_thread* thread, M2nFrame* m2nf, Registers* regs)
+{
+ // FIXME: not implemented
+ assert(0);
+ abort();
+}
+
+
+M2nFrame* m2n_push_suspended_frame(Registers* regs)
+{
+ abort(); // FIXME: check that it works
+ return m2n_push_suspended_frame(p_TLS_vmthread, regs);
+}
+
+M2nFrame* m2n_push_suspended_frame(VM_thread* thread, Registers* regs)
+{
+ abort(); // FIXME: check that it works
+ M2nFrame* m2nf = (M2nFrame*)STD_MALLOC(sizeof(M2nFrame));
+ assert(m2nf);
+ m2n_push_suspended_frame(thread, m2nf, regs);
+ return m2nf;
+}
+
+bool m2n_is_suspended_frame(M2nFrame * m2nf) {
+ // FIXME: not implemented
+ assert(0);
+ abort();
+ return false;
+
+}
+
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ipf/pim/stack_iterator_ipf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ipf/pim/stack_iterator_ipf.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ipf/pim/stack_iterator_ipf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/port/src/lil/ipf/pim/stack_iterator_ipf.cpp Tue Nov 14 08:35:26 2006
@@ -23,6 +23,7 @@
#define LOG_DOMAIN "port.old"
#include "cxxlog.h"
+#include "environment.h"
#include <ostream.h>
#include <pthread.h>
#include <signal.h>
@@ -41,6 +42,7 @@
#include "stack_iterator.h"
#include "stub_code_utils.h"
#include "root_set_enum_internal.h"
+#include "cci.h"
#include "dump.h"
#include "vm_stats.h"
@@ -134,7 +136,7 @@
static void si_unwind_from_m2n(StackIterator* si)
{
#ifdef VM_STATS
- VM_Statistic::get_vm_stats().num_unwind_native_frames_all++;
+ VM_Statistics::get_vm_stats().num_unwind_native_frames_all++;
#endif
// First setup the stack registers for the m2n frame
si->bsp = m2n_get_bsp(si->m2nfl);
@@ -348,6 +350,10 @@
#if defined (PLATFORM_POSIX)
StackIterator* si_create_from_native(VM_thread* thread)
{
+ // FIXME: code is outdated
+ assert(0);
+ abort();
+#if 0
// Allocate iterator
StackIterator* res = (StackIterator*)malloc(sizeof(StackIterator));
assert(res);
@@ -418,6 +424,7 @@
res->c.p_eip = &res->ip;
return res;
+#endif
}
#elif defined (PLATFORM_NT)
@@ -572,6 +579,14 @@
M2nFrame* si_get_m2n(StackIterator* si)
{
return si->m2nfl;
+}
+
+void** si_get_return_pointer(StackIterator* si)
+{
+ // FIXME: not implemented
+ assert(0);
+ abort();
+ return 0;
}
void si_set_return_pointer(StackIterator* si, void** return_value)
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/Class.h Tue Nov 14 08:35:26 2006
@@ -1190,12 +1190,14 @@
/** Gets an offset of <code>m_allocation_handle</code> in the class.
* @note Allocation helpers use returned offset.*/
size_t get_offset_of_allocation_handle() {
- return (size_t)((char*)(&m_num_class_init_checks) - (char*)this);
+ assert(sizeof(m_allocation_handle) == sizeof(void*));
+ return (size_t)((char*)(&m_allocation_handle) - (char*)this);
}
/** Gets an offset of <code>m_instance_data_size</code> in the class.
* @note Allocation helpers use returned offset.*/
size_t get_offset_of_instance_data_size() {
+ assert(sizeof(m_instance_data_size) == 4);
return (size_t)((char*)(&m_instance_data_size) - (char*)this);
}
@@ -1204,6 +1206,14 @@
* @note Class initialization helper on IPF uses returned offset.*/
static size_t get_offset_of_class_init_checks(Class* dummy) {
return (size_t)((char*)(&dummy->m_num_class_init_checks) - (char*)dummy);
+ }
+
+ /** Gets an offset of <code>m_array_element_class</code> in the class.
+ * @param dummy - dummy variable used to calculate field offset
+ * @note Class initialization helper on IPF uses returned offset.*/
+ static size_t get_offset_of_array_element_class(Class* dummy) {
+ assert(sizeof(dummy->m_array_element_class) == sizeof(void*));
+ return (size_t)((char*)(&dummy->m_array_element_class) - (char*)dummy);
}
/** Gets the number of array dimensions.
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/String_Pool.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/String_Pool.h?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/String_Pool.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/String_Pool.h Tue Nov 14 08:35:26 2006
@@ -28,7 +28,7 @@
#include "tl/memory_pool.h"
#include "object_layout.h"
-#define STRING_PADDING 4
+#define STRING_PADDING sizeof(void*)
struct String
{
@@ -37,13 +37,13 @@
#endif
// 20030507 Ref to the interned string used by java.lang.String.intern().
// It is compressed when compressing refs.
+ unsigned len;
union {
// raw reference to interned string if not compressing references
ManagedObject * raw_ref;
// equivalent compressed reference.
uint32 compressed_ref;
} intern;
- unsigned len;
char bytes[STRING_PADDING];
};
@@ -108,6 +108,9 @@
POINTER_SIZE_INT hash_it(const char * str, unsigned len);
String * lookup(const char *str, unsigned len, POINTER_SIZE_INT hash);
void register_interned_string(String * str);
+ private:
+ POINTER_SIZE_INT hash_it_unaligned(const char * str, unsigned len);
+ public:
// memory pool
tl::MemoryPool memory_pool;
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_break_intf.h
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_break_intf.h?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_break_intf.h (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/include/jvmti_break_intf.h Tue Nov 14 08:35:26 2006
@@ -28,7 +28,6 @@
#include "open/types.h"
#include "jni.h"
#include "lock_manager.h"
-#include "jvmti_dasm.h"
#include "environment.h"
#define INSTRUMENTATION_BYTE_HLT 0xf4 // HLT instruction
@@ -49,6 +48,7 @@
} jvmti_BreakPriority;
class VMBreakInterface;
+class InstructionDisassembler;
struct VMBreakPoint
{
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Class.cpp Tue Nov 14 08:35:26 2006
@@ -38,6 +38,10 @@
#include "jit_intf_cpp.h"
#include "type.h"
+#ifdef _IPF_
+#include "vm_ipf.h"
+#endif // _IPF_
+
//
// private static variable containing the id of the next class
// access to this needs to be thread safe; also, this will have to
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/Prepare.cpp Tue Nov 14 08:35:26 2006
@@ -761,14 +761,18 @@
next_vtable_offset += VTABLE_OVERHEAD;
}
unsigned i, j;
+ if (!interpreter_enabled())
+ for(i = 0; i < m_num_methods; i++) {
+ Method& method = m_methods[i];
+
+ // check if the method hasn't already been initialized or even compiled
+ assert(method.get_code_addr() == NULL);
+ // initialize method's code address
+ method.set_code_addr((char*)compile_gen_compile_me(&method));
+ }
+
for(i = 0; i < m_num_methods; i++) {
Method& method = m_methods[i];
-
- // check if the method hasn't already been initialized or even compiled
- assert(method.get_code_addr() == NULL);
- // initialize method's code address
- method.set_code_addr((char*)compile_gen_compile_me(&method));
-
if(!method.is_static()) {
// A virtual method. Look it up in virtual method tables of the
// super classes; if not found, then assign a new offset.
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/class_support/String_Pool.cpp Tue Nov 14 08:35:26 2006
@@ -101,7 +101,7 @@
// to be sure that the input string is aligned on the pointer size boundary
if (((POINTER_SIZE_INT)s & (sizeof(POINTER_SIZE_INT) - 1)) != 0) {
*len = strlen(s);
- *hash = hash_it(s, *len);
+ *hash = hash_it_unaligned(s, *len);
return;
}
@@ -130,11 +130,47 @@
}
POINTER_SIZE_INT String_Pool::hash_it(const char * s, unsigned len) {
+
+#ifdef _IPF_
+ // aligned loading is critical for _IPF_
+ if (((POINTER_SIZE_INT)s & (sizeof(POINTER_SIZE_INT) - 1)) != 0) {
+ return hash_it_unaligned(s, len);
+ }
+#endif
+
POINTER_SIZE_INT h1 = 0, h2 = 0;
const unsigned parts = len / sizeof(POINTER_SIZE_INT);
for (unsigned i = 0; i < parts; i++) {
h1 += *((POINTER_SIZE_INT *)s + i);
+ }
+
+ for (unsigned j = parts * sizeof(POINTER_SIZE_INT); j < len; j++) {
+ h2 += s[j];
+ }
+
+ return h1 - h2;
+}
+
+POINTER_SIZE_INT String_Pool::hash_it_unaligned(const char * s, unsigned len) {
+ POINTER_SIZE_INT h1 = 0, h2 = 0;
+ const unsigned parts = len / sizeof(POINTER_SIZE_INT);
+
+ // ATTENTION! we got here with unaligned s!
+
+ for (unsigned i = 0; i < parts; i++) {
+#ifdef _IPF_ /* 64 bit and little endian */
+ h1 += (POINTER_SIZE_INT) s[i * 8 + 0]
+ + ((POINTER_SIZE_INT)s[i * 8 + 1] << 8)
+ + ((POINTER_SIZE_INT)s[i * 8 + 2] << 16)
+ + ((POINTER_SIZE_INT)s[i * 8 + 3] << 24)
+ + ((POINTER_SIZE_INT)s[i * 8 + 4] << 32)
+ + ((POINTER_SIZE_INT)s[i * 8 + 5] << 40)
+ + ((POINTER_SIZE_INT)s[i * 8 + 6] << 48)
+ + ((POINTER_SIZE_INT)s[i * 8 + 7] << 56);
+#else /* also unaligned load */
+ h1 += *((POINTER_SIZE_INT *)s + i);
+#endif
}
for (unsigned j = parts * sizeof(POINTER_SIZE_INT); j < len; j++) {
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jni/jni.cpp Tue Nov 14 08:35:26 2006
@@ -22,7 +22,7 @@
#define LOG_DOMAIN "jni"
#include "cxxlog.h"
-#include <apr_atomic.h>
+#include <port_atomic.h>
#include <apr_pools.h>
#include <apr_thread_mutex.h>
@@ -379,7 +379,7 @@
status = apr_initialize();
if (status != APR_SUCCESS) return JNI_ERR;
- if (apr_atomic_cas32((volatile apr_uint32_t *)&get_init_status(), JNI_TRUE, JNI_FALSE) == JNI_FALSE) {
+ if (port_atomic_cas8((volatile uint8 *)&get_init_status(), JNI_TRUE, JNI_FALSE) == JNI_FALSE) {
APR_RING_INIT(&GLOBAL_VMS, JavaVM_Internal, link);
status = apr_pool_create(&GLOBAL_POOL, 0);
if (status != APR_SUCCESS) return JNI_ERR;
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break_intf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break_intf.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break_intf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_break_intf.cpp Tue Nov 14 08:35:26 2006
@@ -25,7 +25,6 @@
#include "cxxlog.h"
#include "environment.h"
-#include "encoder.h"
#include "interpreter.h"
#include "interpreter_exports.h"
#include "jit_intf_cpp.h"
@@ -39,9 +38,15 @@
#include "jvmti_break_intf.h"
#include "cci.h"
-// Forvard declarations
+
+#if (defined _IA32_) || (defined _EM64T_)
+
+#include "encoder.h"
+// Forward declarations
static ConditionCode
get_condition_code(InstructionDisassembler::CondJumpType jump_type);
+#endif
+
static bool set_jit_mode_breakpoint(VMBreakPoint* bp);
static bool set_native_breakpoint(VMBreakPoint* bp);
static bool clear_native_breakpoint(VMBreakPoint* bp);
@@ -583,6 +588,7 @@
void
VMBreakPoints::process_native_breakpoint()
{
+#if (defined _IA32_) || (defined _EM64T_)
// When we get here we know already that breakpoint occurred in JITted code,
// JVMTI handles it, and registers context is saved for us in TLS
VM_thread *vm_thread = p_TLS_vmthread;
@@ -618,6 +624,7 @@
m2n_set_frame_type(m2nf, m2nf_type);
jbyte orig_byte = bp->saved_byte;
+
// Copy disassembler instance in case a breakpoint is deleted
// inside of callbacks
InstructionDisassembler idisasm(*bp->disasm);
@@ -804,6 +811,10 @@
si_set_ip(si, instruction_buffer, false);
si_transfer_control(si);
+#else
+ // PLATFORM dependent code
+ abort();
+#endif
}
jbyte
@@ -1187,6 +1198,7 @@
//////////////////////////////////////////////////////////////////////////////
// Helper functions
+#if (defined _IA32_) || (defined _EM64T_)
static inline ConditionCode
get_condition_code(InstructionDisassembler::CondJumpType jump_type)
{
@@ -1194,6 +1206,7 @@
// equal to enums in ia32/em64t encoder, so this statement is ok
return (ConditionCode)jump_type;
}
+#endif
static bool set_jit_mode_breakpoint(VMBreakPoint* bp)
{
@@ -1234,6 +1247,7 @@
static bool set_native_breakpoint(VMBreakPoint* bp)
{
+#if (defined _IA32_) || (defined _EM64T_)
assert(bp);
assert(bp->addr);
@@ -1267,6 +1281,9 @@
}
return true;
+#else
+ return false;
+#endif
}
static bool clear_native_breakpoint(VMBreakPoint* bp)
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_dasm.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_dasm.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_dasm.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_dasm.cpp Tue Nov 14 08:35:26 2006
@@ -22,6 +22,11 @@
* @file
* @brief Disassembler for JVMTI implementation.
*/
+
+// FIXME: Highly platform specific, should be renamed to jvmti_dasm_x86.cpp
+// or go to arch specific directory.
+#if (defined _IA32_) || (defined _EM64T_)
+
#include "jvmti_dasm.h"
#include "dec_base.h"
@@ -196,3 +201,4 @@
return NULL;
}
+#endif
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_step.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_step.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_step.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/jvmti/jvmti_step.cpp Tue Nov 14 08:35:26 2006
@@ -34,6 +34,8 @@
#include "jvmti_break_intf.h"
#include "jni_utils.h"
+#define NOT_IMPLEMENTED assert(0); abort()
+
static inline short
jvmti_GetHalfWordValue( const unsigned char *bytecode,
unsigned location)
@@ -54,6 +56,7 @@
NativeCodePtr static get_ip_for_invoke_call_ip(VM_thread* thread,
unsigned location, unsigned next_location)
{
+#if (defined _IA32_) || (defined _EM64T_)
ASSERT_NO_INTERPRETER;
// create stack iterator from native
@@ -123,6 +126,10 @@
// table address and offset inside of it to determine exactly
// which method is going to invoked in runtime.
return call_ip;
+#else
+ NOT_IMPLEMENTED;
+ return 0;
+#endif
} // jvmti_get_invoked_virtual_method
void
@@ -473,6 +480,7 @@
static void jvmti_start_single_step_in_virtual_method(DebugUtilsTI *ti, VMBreakPoint* bp,
void *data)
{
+#if (defined _IA32_) || (defined _EM64T_)
VM_thread *vm_thread = p_TLS_vmthread;
Registers *regs = &vm_thread->jvmti_saved_exception_registers;
// This is a virtual breakpoint set exactly on the call
@@ -537,6 +545,9 @@
// invokevirtual or invokeinterface bytecodes. It should be
// started to be single stepped from the beginning
jvmti_set_single_step_breakpoints_for_method(ti, vm_thread, method);
+#else
+ NOT_IMPLEMENTED;
+#endif
}
// Callback function for JVMTI single step processing
@@ -732,6 +743,7 @@
unsigned *count,
bool invoked_frame)
{
+#if (defined _IA32_) || (defined _EM64T_)
ASSERT_NO_INTERPRETER;
VMBreakPoints *vm_brpt = VM_Global_State::loader_env->TI->vm_brpt;
@@ -882,6 +894,9 @@
}
}
si_free(si);
+#else
+ NOT_IMPLEMENTED;
+#endif
return JVMTI_ERROR_NONE;
} // jvmti_get_next_bytecodes_from_native
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/compile_ipf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/compile_ipf.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/compile_ipf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/compile_ipf.cpp Tue Nov 14 08:35:26 2006
@@ -176,10 +176,8 @@
// (p3) [g1] = g4 // set new current value
// (p3) return
size_t offset_gc_local = (Byte *)&(p_TLS_vmthread->_gc_private_information) - (Byte *)p_TLS_vmthread;
- size_t offset_allocation_handle = (Byte *)&(env->Void_Class->allocation_handle) - (Byte *)(env->Void_Class);
- size_t offset_instance_data_size = (Byte *)&(env->Void_Class->instance_data_size) - (Byte *)(env->Void_Class);
- assert(sizeof(env->Void_Class->allocation_handle) == 8); // else 8 byte load of the class's allocation_handle will fail
- assert(sizeof(env->Void_Class->instance_data_size) == 4); // else four byte load of the class's size will fail
+ size_t offset_allocation_handle = env->Void_Class->get_offset_of_allocation_handle();
+ size_t offset_instance_data_size = env->Void_Class->get_offset_of_instance_data_size();
current_offset += (unsigned) offset_gc_local;
limit_offset += (unsigned) offset_gc_local;
@@ -459,7 +457,7 @@
static NativeCodePtr addr = NULL;
if (!addr) {
NativeCodePtr (*p_jitter)(Method*) = compile_jit_a_method;
- NativeCodePtr (*p_rethrow)(Method*) = exn_rethrow_if_pending;
+ void (*p_rethrow)() = exn_rethrow_if_pending;
LilCodeStub* cs = lil_parse_code_stub(
"entry 1:managed:arbitrary;"
"push_m2n 0, %0i;"
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/exceptions_ipf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/exceptions_ipf.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/exceptions_ipf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/exceptions_ipf.cpp Tue Nov 14 08:35:26 2006
@@ -53,6 +53,7 @@
#include "nogc.h"
#include "exceptions.h"
+#include "exceptions_jit.h"
void gen_convert_managed_to_unmanaged_null_ipf(Emitter_Handle emitter,
unsigned reg);
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/ini_ipf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/ini_ipf.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/ini_ipf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/ini_ipf.cpp Tue Nov 14 08:35:26 2006
@@ -142,6 +142,9 @@
jvalue *return_value,
jvalue *args)
{
+ assert(("Doesn't compile", 0));
+ abort();
+#if 0
Method *meth = (Method*) methodID;
assert(!hythread_is_suspend_enabled());
void *entry_point = meth->get_code_addr();
@@ -312,5 +315,6 @@
#endif
DIE("Return type " << ret_type << " is not implemented\n");
}
+#endif
} //vm_execute_java_method_array
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/jit_runtime_support_ipf.cpp Tue Nov 14 08:35:26 2006
@@ -52,6 +52,7 @@
#include "compile.h"
#include "method_lookup.h"
#include "exceptions.h"
+#include "exceptions_jit.h"
#include "vm_strings.h"
#include "vm_arrays.h"
#include "vm_threads.h"
@@ -154,12 +155,15 @@
extern "C" ManagedObject *vm_rt_new_resolved(Class *c)
{
assert(!hythread_is_suspend_enabled());
- assert(strcmp(c->name->bytes, "java/lang/Class"));
+ assert(strcmp(c->get_name()->bytes, "java/lang/Class"));
#ifdef VM_STATS
VM_Statistics::get_vm_stats().num_class_alloc_new_object++;
c->instance_allocated(c->get_instance_data_size());
#endif //VM_STATS
- return (ManagedObject *)vm_malloc_with_thread_pointer(c->instance_data_size, c->allocation_handle, vm_get_gc_thread_local());
+ return (ManagedObject *)vm_malloc_with_thread_pointer(
+ c->get_instance_data_size(), c->get_allocation_handle(),
+ vm_get_gc_thread_local());
+
} //vm_rt_new_resolved
// this is a helper routine for rth_get_lil_multianewarray(see jit_runtime_support.cpp).
@@ -284,7 +288,7 @@
#ifdef VM_STATS
VTable *vt = ManagedObject::allocation_handle_to_vtable(ah);
Class *c = vt->clss;
- c->instance_allocated(get_instance_data_size(c));
+ c->instance_allocated(c->get_instance_data_size());
#endif
}
@@ -980,8 +984,7 @@
const int sc5 = SCRATCH_GENERAL_REG7;
Class *dummy_class = NULL;
- const int offset_array_element_class = (int) ((Byte*)&dummy_class->array_element_class - (Byte*)dummy_class);
- assert(sizeof(dummy_class->array_element_class) == 8);
+ const int offset_array_element_class = Class::get_offset_of_array_element_class(dummy_class);
VTable *dummy_vtable = NULL;
const int offset_clss = (int) ((Byte*)&dummy_vtable->clss - (Byte*)dummy_vtable);
@@ -1064,6 +1067,15 @@
} //get_vm_rt_aastore_test_address_compactor
+static Boolean is_class_initialized(Class *clss)
+{
+#ifdef VM_STATS
+ VM_Statistics::get_vm_stats().num_is_class_initialized++;
+ clss->initialization_checked();
+#endif // VM_STATS
+ assert(!hythread_is_suspend_enabled());
+ return clss->is_initialized();
+} //is_class_initialized
static void *get_vm_rt_initialize_class_compactor()
{
@@ -1094,11 +1106,14 @@
#endif // VM_STATS
// Check clss->state==ST_Initialized, quick return if true.
- emitter.ipf_adds(SCRATCH_GENERAL_REG, (int)((Byte*)&dummy->state-(Byte*)dummy), IN_REG0);
- emitter.ipf_adds(SCRATCH_GENERAL_REG3, ST_Initialized, 0);
- assert(sizeof(dummy->state) == 4); // because of int_mem_size_4 below
- emitter.ipf_ld(int_mem_size_4, mem_ld_none, mem_none, SCRATCH_GENERAL_REG2, SCRATCH_GENERAL_REG);
- emitter.ipf_cmp(icmp_eq, cmp_none, SCRATCH_PRED_REG, SCRATCH_PRED_REG2, SCRATCH_GENERAL_REG2, SCRATCH_GENERAL_REG3);
+ //emitter.ipf_adds(SCRATCH_GENERAL_REG, (int)((Byte*)&dummy->state-(Byte*)dummy), IN_REG0);
+ emitter.ipf_adds(SCRATCH_GENERAL_REG3, 0, 0);
+
+ Boolean (*p_is_class_initialized)(Class *clss);
+ p_is_class_initialized = is_class_initialized;
+ emit_call_with_gp(emitter, (void**)p_is_class_initialized);
+
+ emitter.ipf_cmp(icmp_ne, cmp_none, SCRATCH_PRED_REG, SCRATCH_PRED_REG2, RETURN_VALUE_REG, SCRATCH_GENERAL_REG3);
emitter.ipf_brret(br_many, br_sptk, br_none, BRANCH_RETURN_LINK_REG, SCRATCH_PRED_REG);
// push m2n frame
@@ -1142,6 +1157,10 @@
unsigned *lock_owner_width,
Boolean *jit_clears_ccv)
{
+ // FIXME: code outdated
+ assert(0);
+ abort();
+#if 0
if (!vm_get_boolean_property_value_with_default("vm.jit_may_inline_sync"))
return FALSE;
@@ -1152,12 +1171,17 @@
*lock_owner_width = 2;
*jit_clears_ccv = jit_clears_ccv_in_monitor_enter();
return TRUE;
+#endif
}
static void gen_vm_rt_monitorenter_fast_path(Merced_Code_Emitter &emitter, bool check_null)
{
+ // FIXME: code outdated
+ assert(0);
+ abort();
+#if 0
const int thread_stack_key_reg = THREAD_ID_REG;
const int object_stack_key_addr_reg = SCRATCH_GENERAL_REG4;
const int object_old_stack_key_reg = SCRATCH_GENERAL_REG5;
@@ -1230,12 +1254,17 @@
}
// If the cmpxchg failed, we fall through and execute the slow monitor enter path by calling vm_monitor_enter.
+#endif
} //gen_vm_rt_monitorenter_fast_path
static void gen_vm_rt_monitorexit_fast_path(Merced_Code_Emitter &emitter, bool check_null)
{
+ // FIXME: code is outdated
+ assert(0);
+ abort();
+#if 0
const int object_stack_key_addr_reg = SCRATCH_GENERAL_REG3;
const int object_lock_info_reg = SCRATCH_GENERAL_REG4;
const int thread_stack_key_reg = THREAD_ID_REG;
@@ -1317,6 +1346,7 @@
// If the object reference is null or the current thread doesn't own the object, we branch to here.
emitter.set_target(end_of_monitorexit_fast_path_target);
+#endif
} //gen_vm_rt_monitorexit_fast_path
@@ -2666,10 +2696,6 @@
break;
case VM_RT_MONITOR_ENTER_STATIC:
fptr = get_vm_rt_monitor_enter_static_address();
- dereference_fptr = false;
- break;
- case VM_RT_MONITOR_ENTER_NO_EXC:
- fptr = get_vm_rt_monitor_enter_address(false);
dereference_fptr = false;
break;
case VM_RT_MONITOR_EXIT:
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/native_stack_ipf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/native_stack_ipf.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/native_stack_ipf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/ipf/base/native_stack_ipf.cpp Tue Nov 14 08:35:26 2006
@@ -21,9 +21,10 @@
#include "native_stack.h"
-void native_get_frame_info(Registers* regs, void** ip, void** ret, void** bp, void** sp)
+void native_get_frame_info(Registers* regs, void** ip, void** bp, void** sp)
{
- // TODO: implement copying
+ // FIXME: not implemented
+ abort();
}
bool native_unwind_bp_based_frame(void* frame, void** ip, void** bp, void** sp)
@@ -66,3 +67,10 @@
*p_bp = NULL;
*p_sp = NULL;
}
+
+void si_set_callbak(StackIterator* si, NativeCodePtr* callback) {
+ // FIXME: not implemented
+ assert(0);
+ abort();
+}
+
Modified: incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp?view=diff&rev=474860&r1=474859&r2=474860
==============================================================================
--- incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp (original)
+++ incubator/harmony/enhanced/drlvm/trunk/vm/vmcore/src/util/linux/signals_ipf.cpp Tue Nov 14 08:35:26 2006
@@ -28,6 +28,7 @@
#include "cxxlog.h"
#include "platform.h"
+#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -67,89 +68,377 @@
#include "thread_manager.h"
#include "exception_filter.h"
+#include "interpreter.h"
#include "crash_handler.h"
+#include "stack_dump.h"
+#include "jvmti_break_intf.h"
#include <semaphore.h>
-static sigset_t signal_set;
+/**
+ * the saved copy of the executable name.
+ */
+static char executable[1024];
-extern "C" void get_rnat_and_bspstore(uint64* res);
-extern "C" void do_flushrs();
+void asm_jvmti_exception_catch_callback() {
+ // FIXME: not implemented
+ assert(0);
+ abort();
+}
+
+static bool java_throw_from_sigcontext(ucontext_t *uc, Class* exc_clss)
+{
+ // FIXME: not implemented
+ assert(0);
+ abort();
+ return false;
+}
+
+void abort_handler (int signum, siginfo_t* info, void* context) {
+ fprintf(stderr, "FIXME: abort_handler\n");
+ signal(signum, SIG_DFL);
+ kill(getpid(), signum);
+}
+
+
+static void throw_from_sigcontext(ucontext_t *uc, Class* exc_clss) {
+ // FIXME: not implemented
+ assert(0);
+ abort();
+}
+
+void linux_ucontext_to_regs(Registers* regs, ucontext_t* uc)
+{
+ //TODO: ADD Copying of IPF registers here like it was done on ia32!!
+ abort();
+}
+
+void null_java_divide_by_zero_handler(int signum, siginfo_t* UNREF info, void* context)
+{
+ ucontext_t *uc = (ucontext_t *)context;
+ Global_Env *env = VM_Global_State::loader_env;
-void get_context_handler(int signal, siginfo_t* info, void* context) {
- VM_thread* thread = p_active_threads_list;
- pthread_t self = GetCurrentThreadId();
- TRACE2("SIGNALLING", "get_context_handler, try to find pthread_t " << self);
-
- while (thread) {
-
- TRACE2("SIGNALLING", "get_context_handler, finding pthread_t " << self);
-
- if (thread->thread_id != self) {
- thread = thread->p_active;
- continue;
+ /* Will not compile on IPF:
+ * TRACE2("signals", "ArithmeticException detected at " <<
+ (void *)uc->uc_mcontext.gregs[REG_EIP]);
+ */
+
+ if (env->shutting_down != 0) {
+ fprintf(stderr, "null_java_divide_by_zero_handler(): called in shutdown stage\n");
+ } else if (!interpreter_enabled()) {
+ if (java_throw_from_sigcontext(
+ uc, env->java_lang_ArithmeticException_Class)) {
+ return;
+ }
}
- assert(thread->suspend_request >0);
- TRACE2("SIGNALLING", "get_context_handler, found pthread_t " << self);
+ fprintf(stderr, "SIGFPE in VM code.\n");
+ Registers regs;
+ linux_ucontext_to_regs(®s, uc);
+ st_print_stack(®s);
+
+ // crash with default handler
+ signal(signum, 0);
+}
- ucontext_t* c = (ucontext_t*) context;
- uint64 ip = c->uc_mcontext.sc_ip;
- thread->regs.ip = ip;
+/*
+ * Information about stack
+ */
+inline void* find_stack_addr() {
+ int err;
+ void* stack_addr;
+ pthread_attr_t pthread_attr;
+ size_t stack_size;
+
+ pthread_t thread = pthread_self();
+ err = pthread_getattr_np(thread, &pthread_attr);
+ assert(!err);
+ err = pthread_attr_getstack(&pthread_attr, &stack_addr, &stack_size);
+ assert(!err);
+ pthread_attr_destroy(&pthread_attr);
+ return (void *)((unsigned char *)stack_addr + stack_size);
+}
- TRACE2("SIGNALLING", "get_context_handler, ip is " << ip);
-
- uint64* bsp = (uint64*)c->uc_mcontext.sc_ar_bsp;
- uint64 rnat = c->uc_mcontext.sc_ar_rnat;
- thread->t[0] = rnat;
- thread->t[1] = (uint64)bsp;
- thread->suspended_state = SUSPENDED_IN_SIGNAL_HANDLER;
- do_flushrs();
+inline size_t find_stack_size() {
+ int err;
+ size_t stack_size;
+ pthread_attr_t pthread_attr;
+
+ pthread_attr_init(&pthread_attr);
+ err = pthread_attr_getstacksize(&pthread_attr, &stack_size);
+ pthread_attr_destroy(&pthread_attr);
+ return stack_size;
+}
+
+inline size_t find_guard_stack_size() {
+ return 64*1024;
- TRACE2("SIGNALLING", "HANDLER, before POST thread = " << self);
- sem_post(&thread->suspend_self);
- TRACE2("SIGNALLING", "HANDLER, after POST thread = " << self);
-
- //vm_wait_for_single_object(thread->resume_event, INFINITE);
-
- TRACE2("SIGNALLING", "get_context_handler, continue pthread_t " << self);
-
- //thread->suspended_state = NOT_SUSPENDED;
- do_flushrs();
- return;
+}
+
+inline size_t find_guard_page_size() {
+ int err;
+ size_t guard_size;
+ pthread_attr_t pthread_attr;
+
+ pthread_attr_init(&pthread_attr);
+ err = pthread_attr_getguardsize(&pthread_attr, &guard_size);
+ pthread_attr_destroy(&pthread_attr);
+ return guard_size;
+}
+
+static size_t common_stack_size;
+static size_t common_guard_stack_size;
+static size_t common_guard_page_size;
+
+inline void* get_stack_addr() {
+ return p_TLS_vmthread->stack_addr;
+}
+
+inline size_t get_stack_size() {
+ return common_stack_size;
+}
+
+inline size_t get_guard_stack_size() {
+ return common_guard_stack_size;
+}
+
+inline size_t get_guard_page_size() {
+ return common_guard_page_size;
+}
+
+
+void init_stack_info() {
+ p_TLS_vmthread->stack_addr = find_stack_addr();
+ common_stack_size = find_stack_size();
+ common_guard_stack_size = find_guard_stack_size();
+ common_guard_page_size =find_guard_page_size();
+
+ /* FIXME: doesn't work, BTW, move this code to common file for all linuxes
+ * to avoid code duplication
+ *
+ * set_guard_stack();
+ */
+}
+
+void set_guard_stack() {
+ int err;
+
+ char* stack_addr = (char*) get_stack_addr();
+ size_t stack_size = get_stack_size();
+ size_t guard_stack_size = get_guard_stack_size();
+ size_t guard_page_size = get_guard_page_size();
+
+ // map the guard page and protect it
+ void UNUSED *res = mmap(stack_addr - stack_size + guard_page_size +
+ guard_stack_size, guard_page_size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+ assert(res!=MAP_FAILED);
+
+ err = mprotect(stack_addr - stack_size + guard_page_size +
+ guard_stack_size, guard_page_size, PROT_NONE );
+
+ assert(!err);
+
+ //map the alternate stack on which we want to handle the signal
+ void UNUSED *res2 = mmap(stack_addr - stack_size + guard_page_size,
+ guard_stack_size, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+
+ assert(res2!=MAP_FAILED);
+
+
+ stack_t sigalt;
+ sigalt.ss_sp = stack_addr - stack_size + guard_page_size;
+ sigalt.ss_flags = SS_ONSTACK;
+ sigalt.ss_size = guard_stack_size;
+
+ err = sigaltstack (&sigalt, NULL);
+ assert(!err);
+
+}
+
+size_t get_available_stack_size() {
+ char* stack_adrr = (char*) get_stack_addr();
+ size_t used_stack_size = stack_adrr - ((char*)&stack_adrr);
+ size_t available_stack_size =
+ get_stack_size() - used_stack_size
+ - get_guard_page_size() - get_guard_stack_size();
+ return available_stack_size;
+}
+
+size_t get_default_stack_size() {
+ size_t default_stack_size = get_stack_size();
+ return default_stack_size;
+}
+
+bool check_available_stack_size(size_t required_size) {
+ if (get_available_stack_size() < required_size) {
+ exn_raise_by_name("java/lang/StackOverflowError");
+ return false;
+ } else {
+ return true;
+ }
+}
+
+void remove_guard_stack() {
+ int err;
+ char* stack_addr = (char*) get_stack_addr();
+ size_t stack_size = get_stack_size();
+ size_t guard_stack_size = get_guard_stack_size();
+ size_t guard_page_size = get_guard_page_size();
+
+
+ err = mprotect(stack_addr - stack_size + guard_page_size +
+ guard_stack_size, guard_page_size, PROT_READ | PROT_WRITE);
+
+
+ stack_t sigalt;
+ sigalt.ss_sp = stack_addr - stack_size + guard_page_size;
+ sigalt.ss_flags = SS_DISABLE;
+ sigalt.ss_size = guard_stack_size;
+
+ err = sigaltstack (&sigalt, NULL);
+
+}
+
+bool check_stack_overflow(siginfo_t *info, ucontext_t *uc) {
+ char* stack_addr = (char*) get_stack_addr();
+ size_t stack_size = get_stack_size();
+ size_t guard_stack_size = get_guard_stack_size();
+ size_t guard_page_size = get_guard_page_size();
+
+ char* guard_page_begin = stack_addr - stack_size + guard_page_size + guard_stack_size;
+ char* guard_page_end = guard_page_begin + guard_page_size;
+
+ char* fault_addr = (char*)(info->si_addr);
+ //char* esp_value = (char*)(uc->uc_mcontext.gregs[REG_ESP]);
+
+ return((guard_page_begin <= fault_addr) && (fault_addr < guard_page_end));
+}
+
+/*
+ * We find the true signal stack frame set-up by kernel,which is located
+ * by locate_sigcontext() below; then change its content according to
+ * exception handling semantics, so that when the signal handler is
+ * returned, application can continue its execution in Java exception handler.
+ */
+
+void stack_overflow_handler(int signum, siginfo_t* UNREF info, void* context)
+{
+ ucontext_t *uc = (ucontext_t *)context;
+ Global_Env *env = VM_Global_State::loader_env;
+
+ if (java_throw_from_sigcontext(
+ uc, env->java_lang_StackOverflowError_Class)) {
+ return;
+ } else {
+ if (is_unwindable()) {
+ if (hythread_is_suspend_enabled()) {
+ tmn_suspend_disable();
+ }
+ throw_from_sigcontext(
+ uc, env->java_lang_StackOverflowError_Class);
+ } else {
+ remove_guard_stack();
+ exn_raise_by_name("java/lang/StackOverflowError");
+ p_TLS_vmthread->restore_guard_page = true;
+ }
+ }
+}
+
+void null_java_reference_handler(int signum, siginfo_t* UNREF info, void* context)
+{
+ ucontext_t *uc = (ucontext_t *)context;
+ Global_Env *env = VM_Global_State::loader_env;
+
+
+ /* Will not compile on IPF:
+ TRACE2("signals", "NPE or SOE detected at " <<
+ (void *)uc->uc_mcontext.gregs[REG_EIP]); */
+
+ if (check_stack_overflow(info, uc)) {
+ stack_overflow_handler(signum, info, context);
+ return;
}
+
+ if (env->shutting_down != 0) {
+ fprintf(stderr, "null_java_reference_handler(): called in shutdown stage\n");
+ } else if (!interpreter_enabled()) {
+ if (java_throw_from_sigcontext(
+ uc, env->java_lang_NullPointerException_Class)) {
+ return;
+ }
+ }
+ fprintf(stderr, "SIGSEGV in VM code.\n");
+ Registers regs;
+ linux_ucontext_to_regs(®s, uc);
+ st_print_stack(®s);
- DIE("Cannot find Java thread using signal context");
+ signal(signum, 0);
}
void initialize_signals() {
struct sigaction sa;
+/*
+ * MOVED TO PORT, DO NOT USE USR2
+
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO | SA_RESTART;
- sa.sa_sigaction = get_context_handler;
- int res = sigaction(SIGUSR2, &sa, NULL);
+ sa.sa_sigaction = yield_other_handler;
+ sigaction(SIGUSR2, &sa, NULL);
+*/
- if (res != 0) {
- DIE("sigaction fail: SIGUSR2: " << strerror(errno) << "\nDRL VM will exit with error\n");
- }
+ /* FIXME: handler parameters mismatch
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_SIGINFO;
+ sa.sa_sigaction = &jvmti_jit_breakpoint_handler;
+ sigaction(SIGTRAP, &sa, NULL);
+ */
+
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_SIGINFO | SA_ONSTACK;;
+ sa.sa_sigaction = &null_java_reference_handler;
+ sigaction(SIGSEGV, &sa, NULL);
- sigemptyset(&signal_set);
- sigaddset(&signal_set, SIGCONT);
- sigprocmask(SIG_BLOCK, &signal_set, NULL);
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_SIGINFO;
+ sa.sa_sigaction = &null_java_divide_by_zero_handler;
+ sigaction(SIGFPE, &sa, NULL);
extern void interrupt_handler(int);
signal(SIGINT, (void (*)(int)) interrupt_handler);
extern void quit_handler(int);
signal(SIGQUIT, (void (*)(int)) quit_handler);
+ /* install abort_handler to print out call stack on assertion failures */
+ sigemptyset(&sa.sa_mask);
+ sa.sa_flags = SA_SIGINFO;
+ sa.sa_sigaction = &abort_handler;
+ sigaction( SIGABRT, &sa, NULL);
+ /* abort_handler installed */
+
+ extern int get_executable_name(char*, int);
+ /* initialize the name of the executable (to be used by addr2line) */
+ get_executable_name(executable, sizeof(executable));
+
if (vm_get_boolean_property_value_with_default("vm.crash_handler")) {
init_crash_handler();
- install_crash_handler(SIGABRT);
- install_crash_handler(SIGSEGV);
+ // can't install crash handler immediately,
+ // as we have already SIGABRT and SIGSEGV handlers
}
-}
+} //initialize_signals
+
+
+
+#if 0
+
+static sigset_t signal_set;
+
+extern "C" void get_rnat_and_bspstore(uint64* res);
+extern "C" void do_flushrs();
// Variables used to locate the context from the signal handler
static int sc_nest = -1;
@@ -159,11 +448,6 @@
bool SuspendThread(unsigned xx){ return 0; }
bool ResumeThread(unsigned xx){ return 1; }
-void linux_ucontext_to_regs(Registers* regs, ucontext_t* uc)
-{
-//TODO: ADD Copying of IPF registers here like it was done on ia32!!
-}
-
void linux_regs_to_ucontext(ucontext_t* uc, Registers* regs)
{
//TODO: ADD Copying of IPF registers here like it was done on ia32!!
@@ -179,33 +463,22 @@
//TODO: ADD Copying of IPF registers here like it was done on ia32!!
}
-static void linux_throw_from_sigcontext(uint32* top_ebp, Class* exc_clss)
+static bool linux_throw_from_sigcontext(ucontext_t *uc, Class* exc_clss)
{
- sigcontext *sc, *top_sc = NULL;
- uint32 *ebp;
- int i;
-
- ebp = top_ebp;
-
- for (i = 0; i < sc_nest; i++) {
- ebp = (uint32 *)((uint64)ebp[0]);
- }
- if (!use_ucontext) {
- sc = (sigcontext *)(ebp + 3);
- top_sc = (sigcontext *)(top_ebp + 3);
- } else {
- sc = (sigcontext *) &((struct ucontext *)((uint64)ebp[4]))->uc_mcontext;
- }
-
- assert(vm_identify_eip((void *)sc->sc_ip) == VM_TYPE_JAVA);
+ // FIXME: not implemented
+ assert(0);
+ abort();
+ return false;
+}
- Registers regs;
-// linux_sigcontext_to_regs(®s, sc); // FIXME: transfer to linux_ucontext_to_regs
- exn_athrow_regs(®s, exc_clss);
-// linux_regs_to_sigcontext(sc, ®s); // FIXME: transfer to linux_regs_to_ucontext
-// linux_regs_to_sigcontext(top_sc, ®s); // FIXME: transfer to linux_regs_to_ucontext
+static void throw_from_sigcontext(ucontext_t *uc, Class* exc_clss) {
+ // FIXME: not implemented
+ assert(0);
+ abort();
+ return false;
}
+
/*
* We find the true signal stack frame set-up by kernel,which is located
* by locate_sigcontext() below; then change its content according to
@@ -332,71 +605,4 @@
-void initialize_signals_old()
-{
- // First figure out how to locate the context in the
- // signal handler. Apparently you have to do it differently
- // on different versions of Linux.
-
- //attach signal handler locate_sigcontext() with SIGTRAP
-
- signal(SIGTRAP, (void (*)(int))locate_sigcontext);
-
- //this asm code sequence is to cause a signal SIGTRAP
- //delivered to itself by operating system
-
-//TODO: ADD correct signal handling here!!
-/* asm(
- ".align 16\n\t"
- ".byte 0xe8\n\t.long 0\n\t" // call 0
-
- //this is "call 0", which does nothing at runtime
- //but pushing the return address, i.e. instruction
- //pointer to next instruction, i.e. "popl %%eax"
-
- "popl %%eax\n\t" // 1 byte
-
- //pop the return address into eax for arithmetic
-
- "addb $9,%%al\n\t" // 2 byte
-
- //add the return address with 9, which is the address
- //pointing to instruction after the "int $0x3" below.
- //The instructions length in byte are shown on the
- //rightside of each.
-
- "movl %%eax,%0\n\t" // 5 byte
-
- //move eax content into static memory variable "exam_point",
- //which is used for sigcontext locating, because when "int 0x3"
- //happens, operating system will save the return address
- //into signal context for process execution resumption;
- //the trick here is that we also save that address in exam_point,
- //so that we can compare the return EIP saved in signal context
- //with exam_point to identify the correct stack frame
-
-
- "int $0x3" : "=m" (exam_point)
-
- //trigger int3 into operating system kernel, which sends a
- //signal SIGTRAP to current process, setups the signal stack
- //frame on user stack, then returns to user mode execution,
- //i.e. the signal handler locate_sigcontext()
-
- ); */
-
- //when execution goes here, the signal handler locate_sigcontext()
- //has successfully found the signal context setup method on current
- //system; resume SIGTRAP handler back to default
-
- signal(SIGTRAP, SIG_DFL);
-
- //Now register the real signal handlers. signal() function in Linux
- //kernel has SYSV semantics, i.e. the handler is a kind of ONE SHOT
- //behaviour, which is different from BSD. But glibc2 in Linux
- //implements BSD semantics.
-
- signal(SIGSEGV, null_java_reference_handler);
- signal(SIGFPE, null_java_divide_by_zero_handler);
-
-} //initialize_signals
+#endif